problem_id,submission_id,status,code p02957,s799365635,Accepted,"A,B = map(int,input().split()) N = A+B if N % 2 == 0: print((A+B)//2) elif N % 2 != 0: print(""IMPOSSIBLE"")" p03796,s192773874,Wrong Answer,"INF = 10**7 + 7 N = int(input()) power = 1 for i in range(1, N+1): power *= i power %= INF print(power)" p03309,s527090882,Accepted,"#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())) for i in range(N): A[i] -= i A.sort() if(N%2): b = A[N//2] else: b = (A[N//2]+A[N//2-1])//2 ans1 = 0 ans2 = 0 for a in A: ans1 += abs(a-b) ans2 += abs(a-(b+1)) print(min(ans1, ans2))" p03860,s573700277,Accepted,"a = input().split() s = a[1][0] ans = 'A' + s + 'C' print(ans)" p03761,s650372064,Accepted,"n = int(input()) s = [input() for _ in range(n)] ans = [float('inf')] * 26 for i in range(n): cnt = [0] * 26 for j in s[i]: cnt[ord(j) - ord('a')] += 1 for j in range(26): ans[j] = min(ans[j], cnt[j]) test = '' for i in range(26): for _ in range(ans[i]): test += chr(i + ord('a')) print(test) " p02918,s375735290,Accepted,"n,k = map(int,input().split()) s = list(input()) a = 0 for i in range(n-1): if s[i] != s[i+1]: a += 1 print(n-1-max(a-2*k,0))" p03644,s007259768,Wrong Answer," n = int(input()) for i in range(7): if 2**i> n: break print(2**(i-1)) " p03419,s775590483,Accepted,"n, m = map(int, input().split()) n, m = min(n, m), max(n, m) if n == m == 1: print(1) elif n == 1: print(m - 2) else: print((n-2)*(m-2))" p02687,s441160737,Accepted,"val = input() if val==""ABC"": print(""ARC"") elif val==""ARC"": print(""ABC"")" p03854,s638809439,Accepted,"S = str(input())[::-1] words = ['maerd', 'esare', 'remaerd', 'resare'] leng = len(S) while leng>=5: if S[:5] in words: S = S[5:] leng -= 5 elif leng>=7 and S[:7] in words: S = S[7:] leng -= 7 elif leng>=6 and S[:6] in words: S = S[6:] leng -= 6 else: print('NO') break if leng==0: print('YES')" p02583,s949554237,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[i] != l[k]: if l[i]+l[j]>l[k] and l[j]+l[k]>l[i] and l[i]+l[k]>l[j]: ans += 1 print(ans)" p03481,s184092636,Accepted,"x, y = map(int, input().split()) ans = 1 ; num = x while True : if num * 2 <= y : ans += 1 num *= 2 else : break print(ans) " p02933,s964864376,Accepted,"# A - Red or Not # 整数 a の入力 a = int(input()) # 文字列 s の入力 s = input() # print(a) # print(s) if a >= 3200: # print(s) answer = s else: # print('red') answer = 'red' # 結果の出力 print(answer) " p02823,s559428992,Wrong Answer,"n,a,b = map(int,input().split()) if a == b: ans = 0 elif abs(a-b)%2 == 0: ans = abs(a-b)//2 elif abs(a-b)%2 == 1: if a < b: if (a-1) > (n-b): ans = n-b else: ans = a-1 else: if (b-1) > (n-a): ans = n-a else: ans = b-1 print(ans)" p02766,s273682600,Wrong Answer,"N, K = map(int, input().split()) ans = 0 while N > 0: N /= K ans += 1 print(ans)" p03387,s272193523,Accepted,"a,b,c =map(int,input().split()) e = max(a,b,c) f = 3*e -a-b-c while f % 2 ==1: f += 3 print(int(f/2)) " p02829,s681621735,Accepted,"A = int(input()) B = int(input()) func = lambda A, B: 6-(A+B) print(func(A,B))" p02546,s454279730,Accepted,"s = input() if s[-1] == 's': print(s + ""es"") else: print(s + ""s"")" p03761,s576486089,Accepted,"from string import ascii_lowercase as l from collections import Counter _, *s = map(Counter, open(0)) t = """" for a in l: t += a * min(c.get(a, 0) for c in s) print(t)" p02988,s785147527,Accepted,"n = int(input()) p = list(map(int, input().split())) res = 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]: res += 1 print(res) " p03679,s656620614,Accepted,"X, A, B = list(map(int,input().split())) if A >= B: print('delicious') elif B-A<=X: print('safe') else: print('dangerous')" p03427,s211247066,Accepted,"import bisect N = int(input()) if len(str(N)) == 1: print(N) exit() L = len(list(str(N)))-1 A = [10**(L)*i+10**(L)-1 for i in range(10)] n = bisect.bisect_left(A,N)-1 if N in A: n += 1 ans = [int(list(str(A[n]))[i]) for i in range(len(list(str(A[n]))))] print(sum(ans)) " p03592,s051920090,Accepted,"from collections import Counter,defaultdict,deque from heapq import heappop,heappush 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,m,k = inpl() for i in range(n+1): for j in range(m+1): now = i*m+j*n-i*j*2 if now == k: print('Yes') quit() print('No')" p02814,s991479620,Wrong Answer,"N, M = map(int, input().split()) A = list(map(int, input().split())) memo = {} def gcm(a, b): if b == 0: return a if (a, b) in memo: return memo[(a, b)] ans = gcm(b, a % b) memo[(a, b)] = ans return ans def lcm(a, b): a, b = max(a, b), min(a, b) return a * b // gcm(a, b) b = 1 for a in A: b = lcm(a//2, b) ans = M // b print(ans - ans // 2) " p02831,s553867247,Wrong Answer,"from fractions import gcd a,b = map(int,input().split()) print(a*b/(gcd(a,b)))" p03136,s143605900,Accepted,"a=input() b=list(map(int,input().split())) b.sort() if sum(b)-max(b)-max(b)>0: print(""Yes"") else: print(""No"")" p02641,s334510804,Accepted,"X, N = input().split() X = int(X) N = int(N) searchA = X searchB = X max = 100 z = X if N != 0: A = list(map(int, input().split())) for val in range(max): if searchA in A: if searchA > -1: searchA -= 1 else: continue else: z = searchA break if searchB in A: if searchB < 102: searchB += 1 else: continue else: z = searchB break print(z) " p03331,s042673456,Wrong Answer,"n = int(input()) def sum_digit(num): sum = 0 while(num > 0): sum += num % 10 num /= 10 return sum all = [] for a in range(n): sum_A =sum_digit(a+2) sum_B =sum_digit(n-a+2) all.append(sum_A + sum_B) print(min(all))" p03419,s577528844,Accepted,"n, m = map(int, input().split()) if n == 1 and m == 1: print(1) exit(0) w = n - 2 h = m - 2 if n == 1: print(h) exit(0) if m == 1: print(w) exit(0) print(w*h) " p02688,s861341842,Accepted,"n, k = map(int, input().split()) a = [] for _ in range(k): d = int(input()) a += [int(m) for m in input().split()] print(n - len(set(a))) " p03592,s582671219,Wrong Answer,"# -*- coding: utf-8 -*- """""" Created on Tue Jun 2 22:08:10 2020 @author: NEC-PCuser """""" N, M, K = map(int, input().split()) ans = ""No"" for i in range(0, N): for j in range(0, M): kosu = i * M - 2 * j * i + j * N if (kosu == K): ans = ""Yes"" break else: continue break print(ans)" p02787,s939036759,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[i+1][h] := i番目の魔法まで見て、ライフをh以上削った時の最小魔力コスト dp=[[float(""inf"")]*(H+1) for _ in range(N+1)] for i in range(N): for h in range(H+1): if A[i]>=h: dp[i+1][h] = min(dp[i][h], B[i]) else: dp[i+1][h] = min(dp[i][h], dp[i+1][h-A[i]]+B[i]) print(dp[-1][-1])" p03073,s633202677,Wrong Answer,"s = input() ans0 = 0 ans1 = 1 for i, s_i in enumerate(s): if i % 2 == 0: if s_i == '0': ans1 += 1 else: ans0 += 1 else: if s_i == '0': ans0 += 1 else: ans1 += 1 print(min(ans0, ans1)) " p03126,s382411028,Accepted,"n, m = map(int, input().split()) l = [] for i in range(n): a = list(map(int, input().split())) a.pop(0) l.append(a) cnt1 = 0 for i in range(m): cnt2 = 0 for j in range(n): if i + 1 in l[j]: cnt2 += 1 if cnt2 == n: cnt1 += 1 print(cnt1)" p02689,s614886350,Accepted,"n, m = map(int, input().split()) h = list(map(int, input().split())) ab = [list(map(int, input().split())) for _ in range(m)] x = [set() for _ in range(n)] for a, b in ab: x[a-1].add(b-1) x[b-1].add(a-1) ans = 0 for i, xx in enumerate(x): for xxx in xx: if h[i] <= h[xxx]: break else: ans += 1 print(ans)" p02848,s677497986,Accepted,"def main(): N = int(input()) S = list(input()) alpha = list(""ABCDEFGHIJKLMNOPQRSTUVWXYZ"") for i in range(len(S)): idx = alpha.index(S[i]) idx += N if idx > len(alpha) - 1: idx -= len(alpha) S[i] = alpha[idx] print("""".join(S)) main()" p02818,s716089270,Accepted,"nums = input().split("" "") A = int(nums[0]) B = int(nums[1]) K = int(nums[2]) """""" ここで、まずはAとKの比較を行って、Aの方が大きければその場で試行は終了 し、Kの方が大きければ、A=0となり、その差|A-K|は残りのBから引くものになる。 """""" if A >= K: A -= K print(A, end="" "") print(B) else: K -= A A = 0 B -= K if B < 0: B = 0 print(A, end="" "") print(B)" p03548,s478471382,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) INF = 10**9 mod = 10**9+7 X,Y,Z = I() print(1+(X-Y)//(Y+Z))" p03001,s578954749,Accepted,"w,h,x,y=map(int, input().split()) if 2*x==w and 2*y==h:print(w*h/2,1) else:print(w*h/2,0)" p03137,s270668595,Accepted,"n,m = map(int,input().split()) x = [int(i) for i in input().split()] x.sort() memo = [] for i in range(m-1): memo.append(x[i+1]-x[i]) memo.sort() ans = 0 for i in range(m-n): ans += memo[i] print(ans)" p03377,s021271804,Accepted,"a,b,x=map(int,input().split()) print(""YES"" if a<=x and x<=a+b else ""NO"" )" p02994,s693889994,Accepted,"n,l=map(int,input().split()) t=[] tmp=0 for i in range(n): k=i+l t.append(k) tmp+=k if min(t)>0: tmp-=min(t) if max(t)<0: tmp-=max(t) print(tmp)" p02909,s524819771,Accepted,"lis = [""Sunny"", ""Cloudy"", ""Rainy""] S = input() x = lis.index(S) if x == 2: ans_key = 0 else: ans_key = x + 1 print(lis[ans_key])" p03817,s675884221,Accepted,"x = int(input()) div, mod = divmod(x, 11) add = 0 if 0 < mod <= 6: add = 1 elif mod > 6: add = 2 print(div * 2 + add)" p03632,s552326972,Accepted,"a, b, c, d = map(int, input().split()) alice = list(range(a, b+1)) bob = list(range(c, d+1)) ans = 0 for a in alice: if a in bob: ans += 1 if ans != 0: print(ans - 1) else: print(0)" p03160,s332370856,Wrong Answer,"#DPまとめコンテストA問題より infinity=10**6 N = int(input()) h = list(map(int,input().split())) dp=[infinity]*N dp[0]=0 for i in range(N-1): dp[i+1] = min(dp[i+1],dp[i]+abs(h[i+1]-h[i])) if i>=1: dp[i+1] = min(dp[i+1],dp[i-1]+abs(h[i+1]-h[i-1])) print(dp[-1])" p03377,s927366305,Wrong Answer,"a, b, x = map(int, input().split()) print(""Yes"" if a <= x and x <= a+b else ""No"")" p02711,s543376065,Accepted,"N = input() if '7' in N: print(""Yes"") else: print(""No"")" p04029,s261512829,Accepted,"def resolve(n): def ans(n, a): if n == 0: return a else: a += n return ans(n-1,a) return ans(n, 0) print(resolve(int(input())))" p03150,s000290929,Accepted,"S=input();N=len(S) for i in range(len(S)): if(S[:i]+S[N-7+i:]==""keyence""): print(""YES"") exit() print(""NO"")" p03221,s664608137,Accepted,"import bisect n,m = map(int,input().split()) l = [list(map(int,input().split())) for i in range(m)] ls = sorted(l,key=lambda x:x[1]) dict = {} for i in ls: p,y = i if not p in dict.keys(): dict[p] = [] dict[p].append(y) else: dict[p].append(y) for j in l: p,y = j print('{:0=6}'.format(p)+'{:0=6}'.format(bisect.bisect_left(dict[p],y) + 1)) " p03803,s530214284,Wrong Answer,"a , b =(map(int , input().split())) if a==1: a=a+13 if b==1: b=b+13 if a>b : print(""Alice"") elif bint: K = len(str(N)) #桁数 if(K == 1):return N c = N // 10**(K-1) #最上位の桁の数 if((c*10**(K-1) + int(""9""*(K-1)))<= N): return c + 9 *(K - 1) else: return c + 9 *(K - 1) -1 def modelAnswer(): tmp=1 def main(): N = int(input()) print(myAnswer(N)) if __name__ == '__main__': main()" p03711,s265054107,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')" p02695,s469438100,Wrong Answer," N, M, Q = map(int, input().split()) X = [list(map(int, input().split())) for _ in range(Q)] def dfs(x): if len(x) == N: res = 0 for a, b, c, d in X: if x[b - 1] - x[a - 1] == c: res += d return res res = 0 for i in range(1, M + 1): x.append(i) res = max(res, dfs(x)) x.pop() return res print(dfs([])) " p02777,s319255334,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) " p02754,s039123001,Accepted,"n, a, b = map(int, input().split()) line = n // (a + b) remain = n % (a + b) ans = line * a ans += min(a, remain) print(ans) " p03785,s351341990,Accepted,"N,C,K=map(int,input().split()) T=[int(input())for i in range(N)] T.sort() ans=0 bus_seat=0 tmp_time=0 for i in range(len(T)): if T[i]>tmp_time+K: bus_seat=0 if bus_seat==0: ans+=1 tmp_time=T[i] bus_seat+=1 if bus_seat==C: bus_seat=0 print(ans)" p03556,s246070590,Wrong Answer,"n = int(input()) answer = 0 for i in range(1,n): if (i**2) > n: answer = (i-1)**2 break print(answer)" p03673,s972694077,Wrong Answer,"import math def pushpush(n , a): ans = [a[i] for i in range(0 , n , 2)] ansb = [a[i] for i in range(1 , n , 2)] if n % 2 == 0: return ansb[::-1] + ans else: return ans[::-1] + ansb[::-1] def main(): n = int(input()) a = list(map(int , input().split())) print(*pushpush(n , a)) if __name__ == '__main__': main()" p02801,s842683788,Accepted,"s = input() print(chr(ord(s) + 1))" p03637,s822506819,Wrong Answer,"n=int(input()) a=list(map(int,input().split())) tmp=1 if n==2: if a[0]*a[1]%4==0: print('Yes') exit() else: print('No') exit() for i in range(n): tmp*=a[i] if tmp%(4**(n-2))==0: print('Yes') else: print('No')" p03779,s885053404,Accepted,"import sys input = sys.stdin.buffer.readline import math def main(): N = int(input()) num = ((1+8*N)**(1/2)-1)/2 print(math.ceil(num)) if __name__ == ""__main__"": main()" p02971,s490699520,Wrong Answer,"n=int(input()) v=[int(input()) for i in range(n)] m1=m2=v[0] for i in v: if i > m1: m2=m1 m1=i elif i>m2: m2=i for i in v: print(m2 if i==m1 else m1)" p02783,s917598766,Accepted,"H,A=map(int,input().split()) count = 0 while H > 0: count+=1 H -= A print(count)" p03163,s245192281,Accepted,"N,M = map(int,input().split()) dp = [[0]*(M+1) for _ in range(N+1)] for i in range(1, N+1): W,V = map(int,input().split()) for j in range(W): dp[i][j] = dp[i-1][j] for j in range(M-W+1): dp[i][j+W] = max(dp[i-1][j+W],dp[i-1][j]+V) print(max(dp[-1]))" p02995,s801659016,Wrong Answer,"A, B, C, D = map(int, input().split()) count = 0 for i in range(A,B): if i%C!=0 and i%D!=0: count += 1 print(count)" p02952,s696292771,Accepted,"N = int(input()) cnt = 0 for i in range(1, N+1): if len(str(i)) % 2 == 1: cnt += 1 print(cnt) " p02854,s818507525,Wrong Answer,"n = int(input()) a = list(map(int, input().split())) left = 0 right = 0 center = 0 sum_a = sum(a) flg = False for i in range(n): if left + a[i] > sum_a/2 and flg is False: flg = True center = a[i] right -= a[i] elif left + a[i] == sum_a // 2: print(0) exit() if flg is False: left += a[i] else: right += a[i] print(min(left+center-right, right+center-left)) " p03351,s319028359,Wrong Answer,"data = input() dataa,datab,datac,datad = data.split(' ') dataa = int(dataa) datab = int(datab) datac = int(datac) datad = int(datad) length1 = dataa -datab + datab - datac length2 = dataa - datac if length1 < datad: print('Yes') elif length2 < datad: print('Yes') else: print('No') " p03457,s876665142,Accepted,"import sys input = sys.stdin.readline n = int(input().strip()) t = 0 x = 0 y = 0 ans = ""Yes"" for _ in range(n): tn,xn,yn = map(int,input().split()) if tn%2 != (xn+yn)%2 or abs(xn-x)+abs(yn-y) > (tn - t): ans = ""No"" break print(ans)" p02742,s059169568,Wrong Answer,"hw = list(map(int, input().split())) if hw[0] % 2 == 0 and hw[1] % 2 == 0: count = hw[0] * hw[1] // 2 elif hw[0] % 2 != 0 and hw[1] % 2 == 0: count = (hw[0] + 1) * hw[1] // 2 - hw[1] // 2 elif hw[0] % 2 == 0 and hw[1] % 2 != 0: count = (hw[1] + 1) * hw[0] // 2 - hw[0] // 2 else: count = (hw[0] + 1) * (hw[1] + 1) // 2 - (hw[0] // 2 + 1) - (hw[1] // 2 + 1) + 1 print(count) " p03264,s001950051,Accepted,"import itertools a = int(input()) e = range(1, a + 1, 1) b = list(itertools.combinations(e, 2)) for i, item in enumerate(b): if sum(x % 2 == 0 for x in item) != 1: del b[i] elif sum(x % 2 != 0 for x in item) != 1: del b[i] print(len(b)) " p02911,s289710557,Accepted,"N, K, Q = map(int, input().split()) val = [K]*N for i in range(Q): val[int(input())-1] += 1 for i in val: if i - Q <= 0: print('No') else: print('Yes') " p03607,s334993713,Accepted,"# -*- coding: utf-8 -*- a = int(input()) b = set() for i in range(a): b ^= {input()} print(len(b)) " p02577,s997109110,Accepted,"n=input() num=0 for i in n: num+=int(i) print('Yes' if num%9==0 else 'No')" p03327,s977367643,Accepted,"n = int(input()) if n<1000: print(""ABC"") else: print(""ABD"")" p02629,s094700051,Accepted,"n=int(input()) alpha=[chr(i) for i in range(97,97+26)] def test(x,t): if x//t>0: return test(x//t-1,t)+alpha[x%t] return alpha[x%t] print(test(n-1,26))" p03693,s913023153,Wrong Answer,"def calc(): ans = r*100 + g*10 + b if ans%4 == 0: return ""YES"" else: return ""NO"" r, g, b = map(int, input().split()) print(calc)" p03814,s016886220,Accepted,"S = input() for i in range(len(S)): if S[i] == 'A': top = i break for j in reversed(range(len(S))): if S[j] == 'Z': tail = j break print(j-i+1) " p04043,s048200318,Wrong Answer,"List = input().split() print(List) if List.count(""5"") == 2 and List.count(""7"") == 1: print(""Yes"") else: print(""No"")" p03264,s744758682,Accepted,"K = input() K = int(K) tmp = 0 while True: tmp += (K // 2) K = K - 1 if (K == 0): break print(tmp) " p03309,s892443859,Accepted,"import statistics N = int(input()) L = input().split() A = sorted(int(L[X])-(X+1) for X in range(0,N)) B = int(statistics.median(A)) Disp = sum(abs(A[X]-B) for X in range(0,N)) print(Disp)" p03286,s179860325,Accepted,"# -*- coding: utf-8 -*- N = int(input().strip()) if N == 0: ans_list=[0] else: ans_list=[] while N != 0: digit1 = abs( N%(-2) ) ans_list += [digit1] N = (N - digit1) // (-2) print( *ans_list[::-1], sep="""" ) " p02660,s917499247,Accepted,"N = int(input()) f = {} p = 2 while p*p<=N: if N%p==0: f[p]=0 while N%p==0: N//=p f[p]+=1 p+=1 if N>1: f[N]=1 ans = 0 for v in f.values(): n = s = 0 while s<=v: n+=1 s+=n ans += n-1 print(ans)" p03252,s879553927,Accepted,"from collections import Counter s=input() t=input() cs=Counter(s) ct=Counter(t) print('Yes' if sorted(cs.values())==sorted(ct.values()) else 'No')" p02983,s440652654,Accepted,"lr=list(map(int,input().split())) mod=2019 ans=mod**2 if lr[0]%mod<=lr[1]%mod and lr[1]-lr[0]= K - 1: print(""1"") else: print(num) if __name__ == ""__main__"": main()" p02948,s585470458,Accepted,"from collections import defaultdict from heapq import heappush, heappop N, M = list(map(int, input().split())) jobs = defaultdict(list) heap = [] ans = 0 for _ in range(N): a, b = list(map(int, input().split())) if a <= M: jobs[a].append(b) for m in range(1, M+1): for b in jobs[m]: heappush(heap, -b) if heap: maxb = -heappop(heap) ans += maxb print(ans) " p02873,s412891574,Accepted,"S = input() ans = [0]*(len(S)+1) for i in range(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))" p02744,s651257113,Accepted,"N = int(input()) char = [""a"",""b"",""c"",""d"",""e"",""f"",""g"",""h"",""i"",""j""] pre = [("""",0)] for i in range(N): nx = [] for s,cnt in pre: for c in char[:cnt]: nx.append((s+c,cnt)) c = char[cnt] nx.append((s+c,cnt+1)) pre = nx for s,_ in pre: print(s) " p02642,s934910428,Accepted,"N = int(input()) A = list(map(int, input().split())) A.sort() maxnum = A[-1] checklist = [True]*(maxnum+1) before = 0 for a in A: if before == a: checklist[a] = False continue num = 2 while num * a <= maxnum: checklist[a * num] = False num += 1 before = a ans = 0 for i in A: ans += checklist[i] print(ans)" p03475,s661209309,Wrong Answer,"N = int(input()) csf = [0]*(N-1) for i in range(N-1): csf[i] = list(map(int,input().split())) for i in range(N-1): ans = 0 ans += csf[i][1] + csf[i][0] for j in range(i+1, N-1): if ans >= csf[j][1]: ans += csf[j][2] - (ans % csf[j][2]) + csf[j][0] else: ans = csf[j][1] + csf[j][0] print(ans) print(0) " p03860,s903061180,Accepted,"l = input().split() print('A'+l[1][0]+'C')" p02775,s589513841,Accepted,"S = map(int, input()) a, b = 0, 1 for s in S: a, b = a + s if a + s < b + 10 - s else b + 10 - s, a + (s + 1) if a + (s + 1) < b + 10 - (s + 1) else b + 10 - (s + 1) print(a)" p03319,s190976874,Accepted,"import math n, k = map(int, input().split()) a = list(map(int, input().split())) print(math.ceil((n - k) / (k - 1)) + 1) " p02622,s336429469,Accepted,"S = input() T = input() l = len(S) cnt = 0 for i in range(l): if S[i]!=T[i]: cnt += 1 print(cnt)" p03814,s154183576,Accepted,"s=input() print(s.rfind('Z')-s.find('A')+1)" p02777,s229384051,Accepted,"#s , t = 'red' , 'blue' #a , b = 3,4 #u = 'red' s,t = map(str,input().split()) a,b = map(int,input().split()) u = str(input()) if u == s : a -= 1 else : b -= 1 print('{} {}'.format(a,b))" p02713,s931117473,Accepted,"from math import gcd from functools import reduce n = int(input()) ans = 0 for i in range(1,n+1): for j in range(1,n+1): for k in range(1,n+1): ans += reduce(gcd,[i,j,k]) print(ans)" p02555,s644165729,Accepted,"import sys input = sys.stdin.readline mod = 1e9+7 S = int(input()) a = [None]*S if S == 1 or S == 2: print(0) exit() if S == 3: print(1) exit() a[0] = 0 a[1] = 0 a[2] = 1 for i in range(3,S): a[i] = a[i-1] + a[i-3] a[i] %= mod print(int(a[S-1])) " p03434,s324323379,Wrong Answer,"N = int(input()) a = sorted(map(int, input().split()[::-1])) print(sum(a[::2]) - sum(a[1::2]))" p03221,s212939976,Accepted,"N, M = map(int, input().split()) py = [] for i in range(M): p, y = map(int, input().split()) py += [[i, p, y]] py = sorted(py, key=lambda x:(x[1], x[2])) cnt = 0 pre = py[0][1] ans = [] for n, p, y in py: if pre != p: cnt = 1 pre = p else: cnt += 1 ans += [[n, str(p).zfill(6)+str(cnt).zfill(6)]] ans = sorted(ans, key=lambda x:x[0]) for _, n in ans: print(n) " p02754,s899294061,Wrong Answer,"n,b,r = map(int, input().split()) # 5 7 2 ans = (n//(b+r)) + min(n%(b+r),b) print(ans) " p02615,s765615283,Accepted,"N = int(input()) A = list(map(int, input().split())) A.sort() ans = 0 for i in range(N-1): ans += A[N - 1 - (i+1)//2] print(ans) " p02664,s177223970,Accepted,"T = input() ans = T.replace('?', 'D') print(ans)" p03035,s850605362,Accepted,"a, b = map(int, input().split()) if a >= 13: print(b) elif 6 <= a <= 12: print(int(b/2)) else: print(0)" p03150,s305670323,Accepted,"S=input() T=""keyence"" if S[:7]==T: print(""YES"") exit() for i in range(len(S)-1): for j in range(i,len(S)): if S[:i]+S[j:]==T: print(""YES"") exit() print(""NO"")" p03437,s231638647,Accepted,"import math x,y = map(int,input().split()) lcm = (x*y)//math.gcd(x,y) flag = False for i in range(x,lcm): if i%x==0 and i%y!=0: flag=True print(i) break if not flag: print(-1)" p02705,s913586079,Accepted,"import math x = int(input()) print(x * 2 * math.pi) " p03623,s466788030,Wrong Answer,"x,a,b=map(int,raw_input().split()) if a-x < b-x: print ""A"" else: print ""B""" p03286,s901945695,Accepted,"n = int(input()) ans="""" while n!=0: if n%2==0: ans = ""0""+ans else: n-=1 ans = ""1""+ans n//=-2 if ans=="""": print(""0"") else: print(ans) " p02947,s962879132,Accepted,"N = int(input()) S = [input() for _ in range(N)] d = {} ans = 0 for s in S: ss = """".join(sorted(s)) if ss in d: d[ss] += 1 ans += d[ss] else: d[ss] = 0 print(ans) " p02631,s005230103,Accepted,"N = int(input()) A = list(map(int, input().split())) L = 0 for a in A: L ^= a for a in A: print(L ^ a)" p03324,s390796762,Accepted,"D,N=map(int,input().split()) if N==100: print(101*100**D) else: print(N*100**D) " p03612,s308727575,Accepted,"def main(): n = int(input()) ps = list(map(int, input().split())) ans = 0 for i in range(n): if ps[i] == i+1: if ps[i] == n: ps[i-1], ps[i] = ps[i], ps[i-1] else: ps[i], ps[i+1] = ps[i+1], ps[i] ans += 1 print(ans) if __name__ == ""__main__"": main() " p02951,s348601280,Accepted,"a = list(map(int,input().split())) print(max(0,a[2]-(a[0]-a[1]))) " p03293,s923622130,Wrong Answer,"S = str(input()) T = str(input()) for i in range(len(S)): if S[i-1] != T[-i]: print(""No"") break else: print(""Yes"")" p03387,s173717783,Wrong Answer,"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 else ((m + 1) * 3 - (a + b + c)) // 2)" p02832,s448586975,Accepted,"# coding: utf-8 renga_count = int(input()) renga_list = [int(i) for i in input().rstrip().split("" "")] count = 0 for i in renga_list: if i == count + 1: count += 1 if count == 0: print(-1) else: print(renga_count - count)" p02953,s715037782,Accepted,"N=int(input()) A=list(map(int,input().split())) max_A=0 for i in range(N): if max_A 0: if x > y: ans = abs(x-y)+2 else: ans = abs(x-y) elif x*y < 0: ans = abs(abs(x)-abs(y))+1 else: if x == 0: if y < 0: ans = abs(x-y)+1 else: ans = abs(x-y) else: if x < 0: ans = abs(x-y) else: ans = abs(x-y)+1 print(ans)" p02645,s081753769,Wrong Answer,"s = input() print(s[0],s[1],s[2]) " p02640,s420692040,Accepted,"x, y = list(map(int, input().split())) for i in range(x+1): j = x - i if 2*i + 4*j == y: print('Yes') break else: print('No')" p02971,s199916580,Accepted,"n = int(input()) L = list(int(input()) for _ in range(n)) SL = sorted(L) first_max = SL[-1] second_max = SL[-2] for l in L: if (l != first_max): print(first_max) elif (l == first_max): print(second_max)" p02684,s945050318,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) doubling_list = [[-1] * n for i in range(60)] for i in range(n): tmp = a[i] - 1 doubling_list[0][i] = tmp for i in range(1, 60): for j in range(n): doubling_list[i][j] = doubling_list[i - 1][doubling_list[i - 1][j]] now = 0 for i in range(60)[::-1]: if k >> i & 1: now = doubling_list[i][now] ans = now + 1 print(ans)" p03437,s920350306,Wrong Answer,"X, Y = map(int, input().split()) if (X % Y == 0): print(X) else: print(-1)" p02743,s071799002,Wrong Answer,"import math A, B, C = map(int, input().split()) a, b, c = math.sqrt(A), math.sqrt(B), math.sqrt(C) if a + b < c: print(""Yes"") else: print(""No"") " p02707,s815530003,Accepted,"n = int(input()) a = list(map(int, input().split())) from collections import Counter c = Counter(a) for i in range(1,n+1): print(c[i])" p03745,s875899797,Accepted,"n = int(input()) a = list(map(int, input().split())) ans = 1 tmp = ""0"" for i in range(n-1): if a[i] < a[i+1]: if tmp == ""-"": ans += 1 tmp = ""0"" else: tmp =""+"" elif a[i] > a[i+1]: if tmp == ""+"": ans += 1 tmp = ""0"" else: tmp = ""-"" print(ans)" p03035,s156787720,Accepted,"# python 3.4.3 import sys input = sys.stdin.readline # ------------------------------------------------------------- # library # ------------------------------------------------------------- # ------------------------------------------------------------- # main # ------------------------------------------------------------- A,B = map(int,input().split()) ans = 0 if 13 <= A: ans = B elif 6 <= A <= 12: ans = B//2 print(ans)" p02687,s327927223,Accepted,"# import sys # input = sys.stdin.readline s = input() if s == ""ARC"": print(""ABC"") else: print(""ARC"")" p03637,s943140110,Accepted,"n = int(input()) a = list(map(int, input().split())) c_4 = 0 c_2 = 0 odd = 0 for i in range(n): if a[i]%4==0: c_4+=1 elif a[i]%2==1: odd += 1 else: c_2 += 1 if c_2==0: if odd <= c_4+1: print(""Yes"") else: print(""No"") else: if odd <= c_4: print(""Yes"") else: print(""No"")" p02725,s648601770,Accepted,"k, n = map(int, input().split()) a = list(map(int, input().split())) max_dist = 0 for i in range(n-1): cur_dist = a[i+1] - a[i] if cur_dist > max_dist: max_dist = cur_dist cur_dist = k + a[0] - a[-1] if cur_dist > max_dist: max_dist = cur_dist print(k - max_dist) " p03693,s066859450,Accepted,"r, g, b = map(int, input().split()) if (r*100+g*10+b) % 4 == 0: print(""YES"") else: print(""NO"") " p02773,s456153258,Wrong Answer,"from collections import Counter n = int(input()) s = [input() for _ in range(n)] ans = [] c = Counter(s) max_count = max(c.values()) for k, v in c.items(): if v == max_count: ans.append(k) ans.sort() print('\￿n'.join(ans)) " p02742,s461118860,Wrong Answer,"H,W=map(int,input().split()) print(H) if H==W else print(H*W//2 if H*W%2==0 else H*W//2+1)" p02793,s616695243,Wrong Answer,"import sys from fractions import gcd N=input() A=map(int, sys.stdin.readline().split()) mod=10**9+7 def lcm(a, b): g=gcd(a, b) return a*b*pow(g,mod-2,mod) lc=1 for a in A: lc=lcm(lc,a) ans=0 for a in A: b=lc*pow(a,mod-2,mod) ans+=b print ans%mod" p02583,s828897732,Accepted,"import collections N = int(input()) L = list(map(int, input().split())) L = collections.Counter(L) L = list(L.items()) L = sorted(L) N = len(L) ans = 0 for i in range(N-2): for j in range(i+1,N-1): for k in range(j+1,N): if L[i][0]+L[j][0] > L[k][0]: ans += L[i][1]*L[j][1]*L[k][1] print(ans)" p03681,s195422233,Accepted,"# -*- coding: utf-8 -*- """""" Created on Sun Sep 27 02:58:21 2020 @author: liang """""" N, M = map(int,input().split()) MOD = 10**9 + 7 if abs(N-M) >= 2: ans = 0 else: ans = 1 for i in range(1,N+1): ans *= i ans %= MOD for i in range(1,M+1): ans *= i ans %= MOD if N == M: ans *= 2 ans %= MOD print(ans) " p02963,s034813684,Accepted,"s=int(input()) if s+1<=10**9: b=str(s+1) a=['0','0',b,'1','1','1'] else: x2=int(s**(1/2)) y3=int(s**(1/2)) while x2*y310**9: x2+=1 y3=int(s**(1/2))+1 x2=str(x2) y3=str(y3) y2=str(1) x3=str(int(x2)*int(y3)-s) x1=str(0) y1=str(0) a=[x1,y1,x2,y2,x3,y3] print((' ').join(a))" p03986,s804859275,Accepted,"S=input() score=0 maxscore=0 for i in range(len(S)): if S[i]=='T': score+=1 maxscore=max(maxscore,score) else: score-=1 print(2*maxscore)" p02935,s807866240,Accepted,"N = int(input()) V = list(map(int, input().split())) sv = sorted(V) ans = sv[0] for i in range(1, N): ans = (ans + sv[i]) / 2 print(ans) " p02602,s915368348,Accepted,"N, K = [int(s) for s in input().split()] A = [int(s) for s in input().split()] x = 1 for i in range(K, N): if A[i] > A[i - K]: print('Yes') else: print('No')" p03162,s796787090,Wrong Answer,"N = int(input()) a = []*N for _ in range(N): a.append(list(map(int,input().split()))) dp = [[0,0]]*(N+1) m = max(a[0]) j = a[0].index(m) dp[0][0] = m dp[0][1] = j for i in range(1,N): prev = dp[i-1][1] m = 0 for j in range(3): if j!=prev: m = max(a[i][j],m) j = a[i].index(m) dp[i][0] = dp[i-1][0] + m dp[i][1] = j print(dp[N-1][0]) " p02790,s345799253,Accepted,"a, b = map(int, input().split()) print(''.join([str(min(a, b)) for i in range(max(a, b))]))" p03126,s800115583,Accepted,"from collections import Counter n, m = list(map(int, input().split())) s = [] for i in range(n): s += list(map(int, input().split()))[1:] ss = Counter(s) ans = [] for k, v in ss.items(): if v == n: ans.append(k) print(len(ans))" p03289,s842839171,Accepted,"def resolve(): S = input() if S[0] == ""A"" and S[2:-1].count(""C"") == 1: if S.count(""A"") == 1 and S.count(""C"") == 1: S = S.replace(""A"", """").replace(""C"", """") if S == S.lower(): print(""AC"") return print(""WA"") resolve() " p02970,s304230205,Accepted,"n, d = map(int, input().split()) ans = n // (2 * d + 1) if n % (2 * d + 1) != 0: ans += 1 print(ans)" p02916,s032156390,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 for i in range(N): if i>=1 and A[i]==A[i-1]+1: s=s+B[A[i]-1]+C[i-1] else: s=s+B[A[i]-1] print(s)" p02701,s198352918,Accepted,"from collections import Counter N, *S = open(0) C = Counter(S) print(len(C.keys()))" p02899,s190770055,Accepted,"N = int(input()) A = list(map(int, input().split())) B = [0]*N for i, j in enumerate(A): B[j-1] = i+1 print(*B) " p03836,s345625952,Accepted,"sx, sy, tx, ty = map(int,input().split()) ans = """" #1周目 ans += (ty-sy)*""U"" + (tx-sx)*""R"" + (ty-sy)*""D"" + (tx-sx)*""L"" #2周目 ans += ""L"" + (ty-sy+1)*""U"" + (tx-sx+1)*""R"" + ""DR"" + (ty-sy+1)*""D"" + (tx-sx+1)*""L"" + ""U"" print(ans) " p03289,s177638530,Wrong Answer,"s_list = list(input()) n = len(s_list) c_count = 0 if s_list[0] == ""A"": for s in s_list[2:-1]: if s == ""C"": c_count += 1 if c_count == 1: if all([s == ""A"" or ""C"" or s.islower() for s in set(s_list)]): print(""AC"") exit() print(""WA"")" p02802,s539923624,Accepted,"n, m = map(int, input().split()) ans = [list(input().split()) for i in range(m)] ac = [0 for i in range(n)] penali = [0 for i in range(n)] a = 0 for s,t in ans: if t== 'WA' and ac[int(s)-1] == 0: penali[int(s)-1] += 1 if t == 'AC': if ac[int(s)-1] == 0: a +=1 ac[int(s)-1] = 1 for i in range(n): if ac[i] == 0: penali[i] = 0 pena = 0 for i in penali: pena += i print(a, pena)" p03012,s156032169,Accepted,"N = int(input()) lstW = list(map(int, input().split())) S1 = 0 S2 = sum(lstW) minVal = S2 for i in range(0, len(lstW)): S1 = S1 + lstW[i] S2 = S2 - lstW[i] val = abs(S1 - S2) minVal = min(minVal, val) print(minVal)" p02787,s221363489,Wrong Answer,"from sys import stdin f_i = stdin H, N = map(int, f_i.readline().split()) import numpy as np dp = np.full((N + 1, H + 10 ** 4), 10 ** 8) dp[0][0] = 0 for i in range(N): A, B = map(int, f_i.readline().split()) dp[i+1][:A] = dp[i][:A] for j in range(A, H + A): dp[i+1][j] = min(dp[i][j], dp[i+1][j-A] + B) print(np.min(dp[-1][H:]))" p02988,s161361394,Accepted,"n = int(input()) p = list(map(int, input().split())) ans = 0 for i in range(n - 2): if p[i] <= p[i + 1] < p[i + 2]: ans += 1 elif p[i + 2] <= p[i + 1] < p[i]: ans += 1 else: continue print(ans) " p03565,s617642369,Accepted,"import re s, t = input().replace('?', '.'), input() l, m = len(s), len(t) if l < m: print(""UNRESTORABLE"") exit() can = [] # candidates for i in range(l - m + 1): if re.match(s[i:i + m], t): can.append((s[:i] + t + s[i + m:]).replace('.', 'a')) print(min(can) if can else ""UNRESTORABLE"")" p03284,s870585423,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, K = map(int, readline().split()) if N % K == 0: print(0) else: print(1) return if __name__ == '__main__': main() " p02572,s395324864,Wrong Answer,"p=10**9+7 n=int(input()) A=[int(x) for x in input().split()] A2=[(x**2) for x in A] print(int((((sum(A))**2-sum(A2))/2)%p))" p02659,s113739562,Accepted,"a,b=map(float,input().split()) a=int(a) b=int((b+10**-8)*100) print(a*b//100)" p03163,s771992778,Accepted,"N,W=map(int,input().split()) wv = [tuple(map(int,input().split())) for _ in range(N)] dp = [[0]*(W+1) for _ in range(N+1)] for i in range(1,N+1): for j in range(1, W+1): if j >= wv[i-1][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[-1][-1])" p02677,s720065909,Accepted,"# -*- coding: utf-8 -*- """""" Created on Sun May 17 20:23:09 2020 @author: Kanaru Sato """""" import math a,b,h,m = list(map(int,input().split())) s = a**2+b**2-2*a*b*math.cos(math.pi*(11*m-60*h)/360) ans = math.sqrt(s) print(ans)" p03328,s321923762,Accepted,"a, b = map(int, input().split()) c = b - a - 1 res = c * (c + 1) // 2 - a print(res) " p02744,s573177405,Accepted,"#!/usr/bin/env python3 import sys input = sys.stdin.readline sys.setrecursionlimit(10**5) n = int(input()) ans = [] def dfs(arr, max_val): if len(arr) == n: ans.append(arr) return for i in range(max_val + 2): next_arr = arr[:] next_arr.append(i) dfs(next_arr, max(max_val, i)) dfs([0], 0) ans.sort() orda = ord(""a"") for line in ans: print("""".join([chr(orda + item) for item in line]))" p03556,s905966841,Accepted,"n=int(input()) i=1 tmp=1 while True: if i**2 <= n: tmp = i**2 else: break i += 1 print(tmp)" p02714,s135837224,Accepted,"N=int(input()) S=input() R,G,B=0,0,0 for i in range(N): if(S[i]=='R'): R+=1 elif(S[i]=='G'): G+=1 else: B+=1 res=R*G*B cnt=0 for i in range(N): lr=0 while(i-lr>=0 and i+lr= K: result += (1 / N) * (0.5 ** count) break K /= 2 count += 1 print(result)" p02675,s880658115,Accepted,"N = int(input()) L = int(str(N)[-1]) if L==3: print(""bon"") elif L in [0,1,6,8]: print(""pon"") else: print(""hon"")" p02767,s007234484,Accepted,"n = int(input()) x = list(map(int, input().split())) sumX = 0 for i in x: sumX += (i - round(sum(x)/n)) ** 2 print(sumX) " p03241,s605474501,Accepted,"def divisor(n): cd = [] i = 1 while i*i <= n: if n%i==0: cd.append(i) if i != n//i: cd.append(n//i) i += 1 return cd N, M = map(int, input().split()) cd = divisor(M) cd.sort(reverse=True) for c in cd: if M//c>=N: print(c) break" p02594,s186414483,Wrong Answer,"X = int(input()) if X >30: print(""Yes"") else: print(""No"")" p03380,s443640714,Accepted,"N = int(input()) arr = list(map(int, input().split())) target_n = max(arr) target_m = 0 tmp = float('inf') for i in range(N): if abs((target_n/2)-arr[i]) <= tmp and target_n != arr[i]: target_m = arr[i] tmp = abs((target_n/2)-arr[i]) print(target_n,target_m)" p02701,s734920645,Accepted,"import sys from collections import deque import copy def main(): N = int(input()) S = [] for i in range(N): s = input() S.append(s) S.sort() count = N for i in range(1, len(S)): if S[i - 1] == S[i]: count -= 1 print(count) if __name__ == '__main__': main() " p02756,s420931780,Accepted,"s=input() n=int(input()) a=[input() for _ in range(n)] front=True f="""" b="""" for q in a: if q==""1"":front=not front;continue l=q.split() if l[1]==""1"": if front:f=l[2]+f else:b=b+l[2] if l[1]==""2"": if front:b=b+l[2] else:f=l[2]+f print(f+s+b if front else (f+s+b)[::-1])" p03145,s481656115,Accepted,"a, b, c= map(int, input().split()) if a > b and a > c: print(int(b*c/2)) elif b > a and b > c: print(int(a*c/2)) else: print(int(a*b/2))" p02577,s211390547,Accepted,"N = str(input()) tmp=0 for i in range(len(N)): tmp += int(N[i]) if tmp%9==0: print('Yes') else: print('No')" p02675,s128531553,Wrong Answer,"n=int(input()) x = n%10 if x in [2,4,7,9]: print(""hon"") elif x in [0,1,6,8]: print(""pon"") else: print(""bon"")" p03838,s613948873,Accepted,"x,y = map(int,input().split()) cnt = abs(abs(x) - abs(y)) if abs(x) < abs(y): if x >= 0 and y >= 0: print(cnt) elif x < 0 and y < 0: print(cnt+2) else: print(cnt+1) elif abs(x) > abs(y): if x >=0 and y > 0: print(cnt+2) elif x < 0 and y <= 0: print(cnt) else: print(cnt+1) elif abs(x) == abs(y): if x*y >= 0:print(cnt) else: print(cnt+1)" p04033,s869376675,Accepted,"a,b=map(int,input().split()) if a>=0: print(""Positive"" if a!=0 else ""Zero"") if a<0 and b>0: print(""Zero"") if b<=0: if b==0: print(""Zero"") else: if (a-b+1)%2==0: print(""Positive"") else: print(""Negative"")" p02832,s890283151,Wrong Answer,"n = int(input()) A = [int(i) for i in input().split("" "")] now = 1 ans = 0 for i in A: if i == now: now += 1 else: ans += 1 print(ans)" p03681,s122121732,Wrong Answer,"n,m=map(int,input().split()) import math mod=10**9+7 if n==m: x=math.factorial(n) x=x%mod x=x**2 x%=mod x*=2 x%=mod print(x) elif abs(n-m)==1: x=min(n,m) y=max(n,m) ans=math.factorial(x)%mod ans*=ans ans%=mod ans=ans*2*y ans%=mod print(ans) else: print(0)" p02642,s615387347,Accepted,"M=10**6+1 _,*l=map(int,open(0).read().split()) a=[0]*M for i in l: a[i]+=1 if a[i]==1: for j in range(2*i,M,i): a[j]=2 print(a.count(1))" p02718,s781771840,Accepted,"import math import sys N, M = map(int, input().split()) vote = [] vote = list(map(int, input().split())) sum_n = sum(vote) i = 0 while i < M: max_n = max(vote) if max_n < math.ceil(sum_n / (4 * M)): print(""No"") sys.exit() vote.pop(vote.index(max_n)) i += 1 print(""Yes"")" p02708,s842752227,Accepted,"n,k = map(int,input().split()) ans=0 mod = 10**9+7 for i in range(k,n+2): a0=(i*(i-1))//2 an=i*n-a0 ans+=an-a0+1 print(ans%mod)" p02681,s393630421,Accepted,"S = input() T = input() if len(S)+1 == len(T) and S == T[:len(S)]: print(""Yes"") else: print(""No"") " p02829,s993786002,Accepted,"A = int(input()) B = int(input()) print(6-A-B)" p02693,s461756795,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"")" p02730,s640834008,Accepted,"s = input() m = (len(s) - 1) // 2 l = s[:m] r = s[(len(s) + 3) // 2 - 1:] def check(s): mid = len(s) // 2 if len(s) % 2 != 0: left = s[:mid] right = s[mid+1:] else: left = s[:mid] right = s[mid:] if left == right[::-1]: return True else: return False if check(s) and check(r) and check(l): print(""Yes"") else: print(""No"") " p03994,s079913026,Accepted,"s=input() k=int(input()) num=[(123-ord(s[i]))%26 for i in range(len(s))] ans="""" for i in range(len(s)-1): if num[i]<=k: ans+=""a"" k-=num[i] else: ans+=s[i] k%=26 if num[-1]<=k: ans+=chr(97+k-num[-1]) else: ans+=chr(ord(s[-1])+k) print(ans) " p02576,s331957225,Accepted,"N, X, T = map(int, input().split()) ans = (N + X - 1)//X*T print(ans)" p03417,s300517466,Accepted,"n, m = map(int, input().split()) if n > 2: n = n-2 elif n == 2: n = 0 if m > 2: m = m-2 elif m == 2: m = 0 print(n*m) " p02880,s081552841,Accepted,"n=int(input()) a=0 for i in range(1,10): for j in range(i,10): if n==i*j: a=1 break else: continue if a!=0: print('Yes') else: print('No')" p02678,s770395882,Accepted,"from collections import deque N, M = map(int, input().split()) routes = [[] for _ in range(N+1)] for _ in range(M): a, b = map(int, input().split()) routes[a].append(b) routes[b].append(a) checked = [0 for _ in range(N+1)] route = deque(routes[1]) for r in routes[1]: checked[r] = 1 while(len(route) > 0): r = route.popleft() for rr in routes[r]: if checked[rr] == 0: checked[rr] = r route.append(rr) for i in range(2, N+1): if checked[i] == 0: print('No') exit() print('Yes') for j in range(2, N+1): print(checked[j]) " p02761,s873881413,Accepted,"n,m = map(int, input().split()) l = [list(map(int, input().split())) for _ in range(m)] for i in range(10001): if len(str(i)) != n: continue for j in l: if str(i)[j[0]-1] != str(j[1]): break else: print(i) exit() else: print(-1)" p03038,s538705378,Accepted,"n,m=map(int,input().split()) a=list(map(int,input().split())) a.sort() bc=[] for i in range(m): bc.append(list(map(int,input().split()))) bc.sort(key=lambda x:x[1],reverse=True) lis=[] for i in range(m): if len(lis)>=n: break for _ in range(bc[i][0]): lis.append(bc[i][1]) while len(lis) 0 and a[0] != 0: print(-1); exit() s = [0] * (n+2) for i in range(n+1)[::-1]: s[i] = s[i+1]+a[i] x = 1 ans = 0 for i in range(n+1): ans += x if x == s[i]: x -= a[i] continue x -= a[i] if (x <= 0 and i != n) or x < 0: print(-1); exit() if x*2 >= s[i+1]: x = s[i+1] else: x *= 2 print(ans) " p03264,s467295897,Accepted,"k = int(input()) even = k // 2 odd = (k+1) // 2 print(even*odd)" p02933,s180521587,Accepted,"a = int( input() ) s = input() if a >= 3200: print( s ) else: print( ""red"" ) " p02843,s981162359,Accepted,"x = int(input()) dp = [0]*(x + 105 + 1) dp[100] = 1 dp[101] = 1 dp[102] = 1 dp[103] = 1 dp[104] = 1 dp[105] = 1 for i in range(100,x-105+6): for j in range(100,106): dp[i+j] = max(dp[i] , dp[i+j]) print(dp[x])" p03632,s663388470,Accepted,"a, b, c, d = map(int, input().split()) x = [i for i in range(a, b)] y = [i for i in range(c, d)] s = 0 for i in x: if i in y: s += 1 print(s) " p03944,s224914457,Wrong Answer,"w, h, n = map(int, input().split()) num_w = 0 num_h = 0 for i in range(n): x, y, a = map(int, input().split()) if a == 1: if num_w < x: num_w = x elif a == 2: if w > x: w = x elif a == 3: if num_h < y: num_h = y else: if h > y: h = y print((w-num_w)*(h-num_h))" p03852,s843282529,Wrong Answer,"s = input() def solve(query): if query == """": print(""YES"") exit() for frag in (""eraser"", ""erase"", ""dream"", ""dreamer""): if query.startswith(frag): solve(query[len(frag):]) solve(s) print(""NO"") " p03286,s560951755,Accepted,"N = int(input()) S = """" for i in range(100): if abs(N) % (2 ** (i+1)) != 0: S += ""1"" N -= (-2) ** (i) else: S += ""0"" if N == 0: break print(S[::-1])" p02811,s227454031,Accepted,"K, X = map(int,input().split()) if (X <= 500*K): print(""Yes"") else: print(""No"")" p03220,s536235263,Wrong Answer,"N = int(input()) T,A = map(int,input().split()) a = list(map(int,input().split())) min_val = T-A min_num=0 for i in range(len(a)): if abs(T-0.006*a[i]-A) <= min_val: min_val = abs(T-0.006*a[i]-A) min_num = i print(min_num+1)" p02959,s694490401,Accepted,"N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) a1 = sum(A) for i in range(N): b = B[i] if A[i] >= b: A[i] -= b else: if A[i+1]+A[i] >= b: A[i+1] = A[i+1]+A[i]-b A[i] = 0 else: A[i], A[i+1] = 0, 0 a2 = sum(A) print(a1-a2)" p02618,s318633413,Accepted,"D = int(input()) C = list(map(int, input().split())) S = [list(map(int, input().split())) for _ in range(D)] N = 26 L = [0] * N for d in range(1, D + 1): mx = -10**18 nx = -1 for i, (c, l) in enumerate(zip(C, L)): r = c * (d - l) - S[d - 1][i] if mx < r: mx = r nx = i L[nx] = d print(nx + 1) " p03011,s754692678,Wrong Answer,"line = input() a, b, c = [int(n) for n in line.split()] print(a + b if a+b<=a+c else a+c )" p03711,s117091481,Accepted,"x, y = map(int, input().split()) X = [1,3,5,7,8,10,12] Y = [4,6,9,11] Z = [2] ax = 0 ay = 0 if x in X: ax = 1 elif x in Y: ax = 2 else: ax = 3 if y in X: ay = 1 elif y in Y: ay = 2 else: ay = 3 print('Yes') if ax == ay else print('No')" p02778,s312920253,Wrong Answer,"def resolve(): import sys input = sys.stdin.readline S = input() res = ""x"" * len(S) print(res) if __name__ == ""__main__"": resolve()" p03017,s155210003,Accepted,"N, A, B, C, D = map(int, input().split()) S = input() p = 0 t = 0 sti = 0 for i in range(A-1, max(C, D) - 1): if S[i:i+2] == '##': p = 1 for j in range(B-1, min(C, D) - 1): if S[j:j+3] == '...': if sti == 0: sti = j + 1 t = 1 if S[B] == '.' and S[B-2] == '.': t = 1 if (C < D and p == 0) or (C > D and p == 0 and t == 1 and sti <= D-1): print('Yes') else: print('No') " p02547,s324097292,Accepted,"n = int(input()) s = 0 b = False for _ in range(n): w = input().split() if w[0] == w[1]: s += 1 if s == 3: b = True break else: s = 0 print('Yes' if b else 'No') " p03672,s344728345,Accepted,"S=input() for i in range(1,len(S)//2+1): check=0 T=S[:len(S)-2*i] for j in range(0,len(T)//2): if T[j]!=T[j+len(T)//2]: check=1 if check==0: print(len(T)) break if check==1: print(0) " p03495,s570384676,Accepted,"N,K = map(int,input().split()) A = list(map(int,input().split())) A.sort() temp = 1 V = [] for i in range(N-1): if A[i] == A[i+1]: temp+=1 else: V.append(temp) temp = 1 V.append(temp) V.sort() ans = N- sum(V[-K:]) print(ans)" p03221,s103775496,Accepted,"n,m = map(int,input().split()) ipyx=[] for _ in range(m): p_,y_ = map(int,input().split()) ipyx.append([_+1,p_,y_,0]) """""" 2 3 1 32 2 63 1 12 -> 000001000002 000002000001 000001000001 2 3 2 5 2 77 2 99 -> 000002000001 000002000002 000002000003 """""" # ipyx = [i,p,y,x] A=[1]*(n+1) ipyx.sort(key=lambda x:x[2]) for j in ipyx: j[3] = A[j[1]] A[j[1]] += 1 ipyx.sort(key=lambda x:x[0]) for j in ipyx: print(('00000'+str(j[1]))[-6:]+('00000'+str(j[3]))[-6:]) " p02861,s312843541,Accepted,"import itertools import math N = int(input()) X = [] Y = [] for _ in range(N): x,y = map(int,input().split()) X.append(x); Y.append(y) num = [i for i in range(N)] distance_list = [] for perm in itertools.permutations(num): prev = None distance = 0 for v in perm: if prev is None: prev = v else: distance += math.sqrt((X[prev] - X[v]) ** 2 + (Y[prev] - Y[v]) ** 2) distance_list.append(distance) print(sum(distance_list) / len(distance_list)) " p02873,s428339808,Accepted,"s = input() a = [0 for _ in range(len(s)+1)] cur = 0 for i in range(len(s)): if s[i] == '<': cur += 1 else: cur = 0 a[i+1] = max(a[i+1], cur) cur = 0 for i in range(len(s)): j = len(s)-1 - i if s[j] == '>': cur += 1 else: cur = 0 a[j] = max(a[j], cur) print(sum(a))" p02922,s785275301,Accepted,"import math A, B = map(int, input().split()) print(math.ceil((B-1)/(A-1)))" p03371,s168887488,Accepted,"a, b, c, x, y = map(int,input().split()) if a+b <= c * 2: print(x*a + y*b) exit() ans = 0 ans += min(x,y) * c * 2 if x >= y: ans += min((x-y)*a, (x-y)*2*c) else: ans += min((y-x)*b, (y-x)*2*c) print(ans)" p03379,s866324904,Accepted,"# C - Many Medians # https://atcoder.jp/contests/abc094/tasks/arc095_a n = int(input()) X = list(map(int, input().split())) sortedX = sorted(X) l = sortedX[n // 2 - 1] r = sortedX[n // 2] for x in X: if x <= l: print(r) else: print(l)" p02554,s895297394,Wrong Answer,"import sys #sys.exit() #sorted( ,reverse=True) N = int(input()) if N ==1: print(0) sys.exit() #S,T = map(int, input().split()) #A = list(map(int, input().split())) #A = [int(input()) for _ in range(N)] c = 10**9+7 total = 10**N #0と9のみ a= 8**N #0のみ、9のみ b= 1 d = N for i in range (N-1): d = d*8 b += d ans = total - a - b*2 ans2 = ans % c #cnt = 0 #cnt += 1 print(ans2) #print(N) #print(S,T) #print(A) #print('Yes') #print('No') #print(cnt)" p03795,s606284708,Accepted,"# 全て1食800円のレストラン # 15食食べるごとにその場で200円もらえる # 合計N食たべた。払った金額=x円、もらった金額をy円としてx-yを求める # 入力されたNを数値に変換 N = int(input()) # 払った金額=x円を求める x = 800 * N # もらった金額=y円を求める # 200円 * 回数Nを15で割った時の整数の商 y = 200 * (N // 15) print(x-y)" p03043,s416064654,Accepted,"n, k = map(int, input().split()) total_prob = 0 for i in range(1, n+1): dice_count = 0 while (i << dice_count) < k: dice_count += 1 total_prob += (1 / n) * (0.5 ** dice_count) print(round(total_prob, 12))" p02780,s100822042,Accepted,"n,k = map(lambda x: int(x),input().split()) p = list(map(lambda x: (int(x) + 1)/2,input().split())) ruiseki = [0] max = 0 for i in range(n) : ruiseki.append(ruiseki[i]+p[i]) for j in range(n - k + 1): if max < (ruiseki[j+k] - ruiseki[j]) : max = (ruiseki[j+k] - ruiseki[j]) print(max) " p02797,s911021495,Accepted,"n,k,s=map(int,input().split()) for i in range(n): if i+1 <= k: print(s,end="" "") else: if s==10**9: print(10**9-1,end="" "") else: print(10**9,end="" "")" p02854,s421276601,Accepted,"import sys import numpy as np 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(input()) A = np.array(input().split(), np.int64) B = np.append(0, A.cumsum()) C = A[::-1].cumsum() C = np.append(C[::-1], 0) print(np.abs(B-C).min()) if __name__ == '__main__': main()" p03261,s542730421,Accepted,"N = int(input()) w = [input()] ans = 'Yes' for i in range(N-1): tmp = input() if (tmp in w) or (w[-1][-1] != tmp[0]): ans = 'No' break w.append(tmp) print(ans)" p02676,s520368084,Wrong Answer," n=int(input()) st=input() if n>=len(st): print(st) else: print(st[0:n-1])" p03285,s893222428,Accepted,"n=int(input()) f=0 for i in range(30): for j in range(30): if 4*i+7*j==n: f=1 print(""Yes"" if f==1 else ""No"") " p03095,s224452969,Accepted,"from collections import Counter n = int(input()) s = input() mod = 10**9+7 s_c = Counter(s) ans = 1 for c in s_c.values(): ans*=c+1 print((ans-1)%mod)" p02775,s772588133,Wrong Answer,"N = input() ans = 0 flag = False for i in range(len(N)-1, -1, -1): if flag and i != 0: ans -= 1 if int(N[i]) < 11-int(N[i]): ans += int(N[i]) flag = False else: ans += 11-int(N[i]) flag = True print(ans)" p02987,s337941290,Accepted,"s = input() if len(''.join(set(s)))==2: print(""Yes"") else: print(""No"")" p03486,s887122830,Wrong Answer,"s = input() t = input() if s < t: print('Yes') else: print('No') " p03852,s814076415,Accepted,"a=input() b=[""a"",""i"",""u"",""e"",""o""] if a in b: print(""vowel"") else: print(""consonant"")" p03659,s566581931,Accepted,"N = int(input()) A = list(map(int, input().split())) s = 0 t = 0 ans = 10 ** 12 for i in range(N): t += A[i] for n in range(N-1): s += A[n] t -= A[n] ans = min(ans, abs(s - t)) print(ans)" p03001,s922436586,Accepted,"W,H,x,y = list(map(float,input().split())) ans = W * H ans = float(float(ans) / 2.0) ans2 = 0 if x == float(float(W) / 2) and y == float(float(H) / 2): ans2 = 1 print(str(ans) + "" "" + str(ans2))" p03696,s859202745,Accepted,"n = int(input()) s = list(input()) c0 = 0 c1 = 0 z0 = 0 z1 = 0 for i in range(n): if s[i] == ""("": c0 += 1 else: if c0 > 0: c0 -= 1 else: c1 += 1 ans = [""(""]*c1 + s + ["")""]*c0 print("""".join(ans))" p02989,s906839098,Accepted,"n=int(input()) d=[int(x) for x in input().rstrip().split()] d.sort() if d[n//2-1]==d[n//2]: print(0) else: print(d[n//2]-d[n//2-1]) " p03433,s113366051,Accepted,"n = int(input()) a = int(input()) print(""Yes"" if (n % 500) <= a else ""No"")" p03241,s578445009,Accepted,"n, m = map(int, input().split()) import math gs = [] for i in range(1, int(math.sqrt(m))+1): if m%i == 0: gs.append(i) if i != m//i: gs.append(m//i) gs.sort(reverse=True) #print(gs) for j in gs: if m//j >= n: print(j) exit()" p03103,s232459511,Wrong Answer,"N, M = map(int, input().split()) AB = {} for i in range(N): a, b = map(int, input().split()) AB[a] = b ans = 0 for ab in sorted(AB.keys()): if M >= AB[ab]: ans += ab * AB[ab] M -= AB[ab] else: ans += ab * M break print(ans)" p04030,s381014579,Wrong Answer,"def solve(): s = list(input()) ans = [] for i in range(len(s)): if s[i] != 'B': ans.append(s[i]) elif s[i] == 'B' and ans: ans.remove(ans[-1]) return ''.join(ans) print(solve()) " p03131,s176037462,Wrong Answer,"k, a, b = map(int, input().split()) if a >= b-1: print(k+1) else: if k <= a: print(k+1) else: if k-a % 2 == 1: print((k-a+1)//2*(b-a)+a) else: print((k-a)//2*(b-a)+a+1) " p02801,s270021319,Accepted,"c = input() ans = chr(ord(c) + 1) print(ans) " p02553,s191317132,Wrong Answer,"a,b,c,d = (int(x) for x in input().split()) if b and d >= 0: if a*c > b*d : print(a*c) else: print(b+d) elif b and d < 0: print(a*c) elif b >=0 and d < 0: if a*d > b*c : print(a*d) else: print(b*c) elif b <0 and d >= 0: if a*d > b*c : print(a*d) else: print(b*c)" p02791,s847511727,Accepted,"n = int(input()) p = [int(x) for x in input().split()] cnt=1 saisyouti=p[0] for i in range(1,n): if p[i]= 0: n = N b = bin(N)[2:] for i in range(len(b)): if i%2==1 and b[-i-1]=='1': n += 2**(i+1) print(bin(n)[2:]) else: n = -N b = bin(-N)[2:] for i in range(len(b)): if i%2==0 and b[-i-1]=='1': n += 2**(i+1) print(bin(n)[2:])" p03284,s281231881,Accepted,"N, K = map(int, input().split()) print(0 if N%K==0 else 1)" p03038,s792109220,Wrong Answer,"import numpy as np def main(): N,M = map(int,input().split()) A = [int(x) for x in input().split()] for _ in range(M): b,c = map(int, input().split()) for i in range(b): A.append(c) np.array(A).sort() print(sum(A[-N:])) main()" p03076,s109984515,Accepted,"import math t=[0]*5 s=[0]*5 ans=0 for i in range(5): t[i]=int(input()) s[i]=math.ceil(t[i]/10)*10-t[i] ans+=math.ceil(t[i]/10)*10 print(ans-max(s))" p03632,s535625023,Accepted,"a,b,c,d = map(int, input().split()) print(max(0, min(b,d) - max(a,c))) " p03377,s303044413,Accepted,"a, b, x = list(map(int, input().split())) if a <= x <= a + b: print('YES') else: print('NO') " p02918,s566877019,Accepted,"N,K = map(int,input().split()) S = input() hapiness = [0 for i in range(N)] if S[0] == 'R' and S[1]=='R': hapiness[0]=1 for i in range(1,N-1): if S[i]=='L' and S[i-1]=='L': hapiness[i]=1 if S[i]=='R' and S[i+1]=='R': hapiness[i]=1 if S[N-1]=='L' and S[N-2]=='L': hapiness[N-1]=1 ans = sum(hapiness)+K*2 print(min(ans,N-1))" p03693,s677997163,Accepted,"r,g,b = input().split() print(""YES"" if int(r+g+b) % 4 == 0 else ""NO"")" p02879,s346235270,Accepted,"a,b = map(int, input().split()) if a > 9 or b > 9: print(-1) else: print(a*b) " p02602,s597583395,Accepted,"n,k=map(int,input().split()) a=list(map(int,input().split())) old = 0 for i in range(k,n+1): if i == k: new = 1 elif i != k: new = a[i-1] / a[i-k-1] if new > 1: print(""Yes"") else: print(""No"") old = new" p02594,s609323613,Accepted,"X=int(input()) if X>=30:print(""Yes"") else:print(""No"")" p02923,s703390626,Accepted," N = int(input()) X = list(map(int, input().split())) ans = 0 cnt = 0 cur = X[0] for i in range(1, N): if cur < X[i]: ans = max(ans, cnt) cnt = 0 else: cnt += 1 cur = X[i] print(max(ans, cnt)) " p03836,s229370522,Accepted,"#coding: utf-8 import math import heapq import bisect import numpy as np from collections import Counter, deque import itertools #from scipy.misc import comb sx,sy,tx,ty = map(int, input().split()) ans = 'U'*(ty-sy) + 'R'*(tx-sx) + 'D'*(ty-sy) + 'L'*(tx-sx+1) + 'U'*(ty-sy+1) + 'R'*(tx-sx+1) + ""DR"" + 'D'*(ty-sy+1) + 'L'*(tx-sx+1) + 'U' print(ans)" p02880,s674372658,Accepted,"import sys N = int(input()) for i in range(1, 10): for j in range(1, 10): if i*j == N: print('Yes') sys.exit() print('No')" p02924,s489546313,Accepted,"N = int(input()) print(N * (N - 1) // 2) " p03657,s840614490,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"")" p03241,s051199421,Accepted,"import math n, m = map(int, input().split()) fact = [] ans = 1 MAX = int(math.sqrt(m)) + 1 for i in range(1, MAX): if m % i == 0: fact.append(i) if i != m // i: fact.append(m//i) fact.sort() for x in fact: if m < n * x: break ans = x print(ans)" p03160,s067129222,Accepted,"def resolve(): n = int(input()) h = list(map(int, input().split())) dp = [float(""inf"") for i in range(n)] dp[0] = 0 for i in range(n-1): dp[i+1] = min(dp[i+1], dp[i] + abs(h[i+1] - h[i])) if i < n-2: dp[i+2] = min(dp[i+2], dp[i] + abs(h[i+2] - h[i])) print(dp[n-1]) resolve()" p02756,s447419458,Accepted,"from collections import deque f=input s=deque(f()) n=int(f()) t=0 for i in range(n): q=f() if q[0]=='1': t=1-t elif int(q[2])+t==2: s.append(q[4]) else: s.appendleft(q[4]) print(''.join([s,list(s)[::-1]][t]))" p02665,s337021882,Accepted,"n,*a=map(int,open(0).read().split()) b=sum(a) c=1 ans=1 if a[0]==1 and n==0: print(1) exit() if a[0]>0: print(-1) exit() for i in a[1:]: b-=i c=min(c*2-i,b) ans+=c if c<0: print(-1) exit() print(ans+sum(a))" p02732,s322400171,Accepted,"from collections import Counter n=int(input()) a=list(map(int,input().split())) c=Counter(a) s=0 for key in c: s+=c[key]*(c[key]-1)//2 for item in a: print(s-c[item]+1) " p03345,s974111983,Accepted,"A,B,C,K=map(int,input().split()) if K%2==1: ans=B-A else: ans=A-B print(ans)" p03069,s094989418,Accepted,"n=int(input()) s=input() sumBlack = [0]*(n+1) sumWhite = [0]*(n+1) for i in range(1,n+1): sumBlack[i] = sumBlack[i-1] if s[i-1] == '#': sumBlack[i] += 1 for i in range(n-1,-1,-1): sumWhite[i] = sumWhite[i+1] if s[i] == '.': sumWhite[i] += 1 ans = 12345678901234 for i in range(n+1): ans = min(ans,sumBlack[i]+sumWhite[i]) print(ans)" p02922,s645181560,Wrong Answer,"import sys a, b =map(int, input().split()) if a == b or b == 1: print(1) sys.exit() c = b//a if a*c == b: print(c) else: print(c +1)" p03241,s908197177,Accepted,"import sys input = lambda: sys.stdin.readline().rstrip() N, M = map(int, input().split()) def divisor(a): res = [] for i in range(1, int(a**0.5)+1): if a % i == 0: res.append(i) res.append(a//i) return res div = divisor(M) div.sort(reverse=True) for d in div: if d * N <= M: print(d) exit()" p03206,s872554779,Wrong Answer,"D = int(input()) print(""Christmas"" + ""Eve ""*(25-D))" p03623,s777187250,Accepted,"x, a, b = map(int, input().split()) A = abs(x - a) B = abs(x - b) if A < B: print(""A"") else: print(""B"") " p04045,s421866810,Accepted,"def main(): N, K = map(int, input().split()) D = list(input().split()) for i in range(N,100000): a = str(i) flag = True for d in D: if d in a: flag = False break if flag: print(i) exit() if __name__ == ""__main__"": main()" p03592,s428789522,Accepted,"N,M,K=map(int, input().split()) print(""YNeos""[not any(K==i*j+(N-i)*(M-j) for i in range(N+1) for j in range(M+1))::2])" p03592,s140903172,Accepted,"N,M,K = map(int,input().split()) ans = ""No"" for i in range(N+1): for j in range(M+1): black = i*M + j*N -2*i*j if black == K: ans = ""Yes"" break if ans == ""Yes"": break print(ans) " p02675,s355272701,Accepted,"def main(): import sys input = sys.stdin.readline N = int(input()) if N % 10 in (2,4,5,7,9): print(""hon"") elif N % 10 in (0,1,6,8): print(""pon"") else: print(""bon"") if __name__ == '__main__': main()" p02572,s611194712,Accepted,"N=int(input()) A=list(map(int,input().split())) _sum=sum(A[1:]) mod=10**9+7 re=0 for i in range(0,N-1): re+=A[i]*_sum _sum-=A[i+1] re%=mod _sum%=mod print(re%mod) " p02842,s857429579,Wrong Answer,"n = int(input()) if int(round(n/1.08)*1.08) == n : print(round(n/1.08)) else: print("":("")" p02706,s680383269,Accepted,"N,M=map(int,input().split("" "")) A=[int(s) for s in input().split("" "")] Ans=0 for i in range(M): Ans+=A[i] print(N-Ans if Ans<=N else -1)" p02917,s581232913,Accepted,"n=int(input()) b=list(map(int,input().split())) result = b[0] + b[n-2] for i in range(n-2): result += min(b[i],b[i+1]) print(result)" p03617,s249308055,Wrong Answer,"l = [[0.25],[0.5],[1],[2]] tmp = list(map(int,input().split())) for i in range(4): l[i].append(tmp[i]) for i in range(4): l[i].append(l[i][1]*4//(l[i][0]*4)) print(l) from operator import itemgetter l = sorted(l, key=itemgetter(2)) ans = 0 n = int(input()) for i in range(4): tmp = n//l[i][0] if tmp > 0: ans += tmp * l[i][1] n -= tmp*l[i][0] print(int(ans))" p02725,s076988279,Accepted,"K,N=map(int,input().split()) n=list(map(int,input().split())) if n[N-1]-n[0] < (K-n[1])+n[0]: dist=n[N-1]-n[0] else: dist=(K-n[1])+n[0] for i in range(1,N-1): if dist > (K-n[i-1])+n[i]: dist= (K-n[i-1])+n[i] if dist > (K-n[i+1])+(n[i]-0): dist= (K-n[i+1])+(n[i]-0) print(dist)" p03317,s237245530,Accepted,"N, K = map(int, input().split()) print((N-2)//(K-1)+1) " p02767,s660249843,Accepted,"n = int(input()) x = list(map(int, input().split())) x.sort() ans = 10**9+7 for i in range(x[0], x[n-1]+1): res = [] for j in range(n): res.append((i-x[j])**2) ans = min(sum(res), ans) print(ans)" p03126,s954451452,Accepted,"import sys import os def main(): if os.getenv(""LOCAL""): sys.stdin = open(""input.txt"", ""r"") N, M = list(map(int, sys.stdin.readline().split())) FOODS = set(range(1, M + 1)) for n in range(N): K, *A = list(map(int, sys.stdin.readline().split())) FOODS &= set(A) print(len(FOODS)) if __name__ == '__main__': main() " p02838,s904060684,Accepted,"MOD = 10**9 + 7 def main(): N = int(input()) A = [int(i) for i in input().split()] from collections import Counter c = Counter() for a in A: s = ""{:0>63b}"".format(a)[::-1] for i, s in enumerate(s): c[i] += int(s) ans = sum(A) * (N-1) for k, v in c.items(): if v > 1: ans -= 2*(2**k)*(v*(v-1)//2) print(ans % MOD) if __name__ == '__main__': main() " p03997,s077900706,Accepted,"a = int(input()) b = int(input()) h = int(input()) print((a+b)*h//2)" p02780,s982079261,Accepted,"n,k=map(int,input().split()) p=[int(i) for i in input().split()] ans=chk=0 w=[0]*(n+1) for i in range(n): w[i+1]=w[i]+p[i] for i in range(k,n+1): chk=max(chk,w[i]-w[i-k]) print((chk+k)/2) " p03821,s398556638,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 + cnt == 0: cnt += 1 ans += 1 else: t = b - ((a + cnt) % b) cnt += t ans += t print(ans) " p03285,s456699126,Wrong Answer,"N = int(input()) t = 0 if N % 4 == 0 or N % 7 == 0: ans = ""Yes"" elif N == 0: ans = ""No"" else: t = 0 for i in range(1,N//7): x = (N-7*i)/4 if x == int(x): t += 1 else: continue if t > 0: ans = ""Yes"" else: ans = ""No"" print(ans)" p02982,s274788678,Accepted,"import numpy as np N,D=map(int,input().split()) X=[np.array(input().split(),dtype=np.int64) for _ in range(N)] ans=0 for i in range(N): for j in range(i+1,N): d=((X[i]-X[j])*(X[i]-X[j])).sum() dd=int(round(d**.5)) if d==dd*dd: ans +=1 print(ans) " p04043,s517159904,Accepted,"nums = list(map(int, input().split())) fives = nums.count(5) sevens = nums.count(7) print(""YES"") if (fives == 2 and sevens == 1) else print(""NO"") " p03679,s308169192,Accepted,"X,A,B =map(int,input().split()) if A-B>=0: print('delicious') elif A-B<0 and B-A <= X: print('safe') else: print('dangerous') " p03821,s599218784,Accepted,"N=int(input()) A=[0]*N B=[0]*N for i in range(N): A[i],B[i] = map(int,input().split()) cnt=0 for i in range(N-1,-1,-1): A[i] += cnt s=A[i]%B[i] if s!=0: cnt +=B[i]-s #print(i,A,cnt) print(cnt)" p03481,s851676530,Wrong Answer,"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() from math import log2 x,y = readInts() print(int(log2(y)-log2(x)+1))" p02647,s540042282,Wrong Answer,"N, K = map(int, input().split()) A = list(map(int, input().split())) for _ in range(min(K, 50)): lamp = [0 for i in range(N + 1)] for i in range(N): lamp[max(0, i - A[i])] += 1 lamp[min(N, i + A[i] + 1)] -= 1 print(lamp) for i in range(1, N + 1): lamp[i] += lamp[i - 1] A = lamp [print(A[i], end=' ') for i in range(N)] print() " p03721,s856109893,Wrong Answer,"n,k=map(int,input().split()) a,b=map(int,input().split()) d=[0]*(10**5+1) for i in range(n-1): a,b=map(int,input().split()) d[a]+=b for i in range(10**5+1): if d[i]>=k: print(i) break else:k-=d[i] " p03487,s729475322,Wrong Answer,"n = int(input()) l = list(map(int, input().split())) dic = {} count = 0 for i in range(n): dic.setdefault(l[i],0) dic[l[i]] += 1 print(dic) for x,y in dic.items(): if x <= y: count += y - x else: count += y print(count) " p02796,s480693947,Accepted,"def solve(XL, N): XL.sort(key=lambda x:x[1]) count = N for i in range(1, N): if XL[i][0] < XL[i-1][1]: XL[i][1] = XL[i-1][1] count -= 1 return count N = int(input()) XL = [] for i in range(N): x, l = map(int, input().split(' ')) XL.append([x-l, x+l]) print(solve(XL, N)) " p02771,s332298321,Accepted,"A,B,C = map(int,input().split()) if A == B or A == C or B == C: if A == B and B ==C: print(""No"") else: print(""Yes"") else: print(""No"") " p02971,s346102656,Accepted,"N = int(input()) A = [int(input()) for _ in range(N)] mls = [-1 for _ in range(N+1)] for i, a in enumerate(A, 1): mls[i] = max(mls[i-1], a) mrs = [-1 for _ in range(N+1)] for i, a in enumerate(A[::-1], 1): mrs[i] = max(mrs[i-1], a) mrs = mrs[::-1] for i in range(N): print(max(mls[i], mrs[i+1])) " p03371,s174722776,Accepted,"a, b, c, x, y = map(int, input().split()) p2 = 0 for i in range(max(x, y)): ai = a * (x - i) if i < x else 0 bi = b * (y - i) if i < y else 0 abi = 2 * i * c p1 = ai + bi + abi ai1 = a * (x - i - 1) if i < x else 0 bi1 = b * (y - i - 1) if i < y else 0 abi1 = 2 * (i + 1) * c p2 = ai1 + bi1 + abi1 if p1 < p2: print(p1) exit() print(p2)" p02607,s363114143,Accepted,"N = int(input()) a = list(map(int, input().split())) cnt = 0 for i in range(N): if a[i] % 2 == 1 and (i+1)%2 == 1: cnt += 1 print(cnt) " p02766,s945617564,Accepted,"n,k = map(int, input().split()) s = 1 c = 0 while n//s > 0: s *= k c += 1 print(c)" p02665,s576049129,Accepted,"n,*a=map(int,open(0).read().split()) t=sum(a);v=w=1 for q in a: w=min(2*(w-q),t:=t-q);(v:=v+w) if w<0:print(-1);exit() print(v)" p02714,s602928508,Wrong Answer,"# -*- coding: utf-8 -*- N = int(input()) S = input() Ans = 0 for i in range(1, 1 + N): for j in range(1, 1 + N): for k in range(1, 1 + N): if i < j and j < k: if S[i-1] != S[j-1] and S[j-1] != S[k-1]: if (j-i) != (k-j): Ans += 1 print(Ans)" p03000,s335888065,Accepted,"#ABC 130 B N,X=map(int,input().split()) L= [int(j) for j in input().split()] cnt=0 import numpy as np jump = list(np.cumsum(L)) for j in jump: if j <= X: cnt+=1 print(cnt+1)" p03543,s330711501,Accepted,"N = input() if N[:3].count(N[0]) == 3 or N[1:].count(N[1]) == 3: print('Yes') else: print('No')" p02765,s770283364,Accepted,"def resolve(): N, R = map(int, input().split()) if N >= 10: print(R) else: print(R+100*(10-N)) resolve()" p02910,s669593906,Wrong Answer," s=str(input()) def n1(): for i in range(len(s)): if i%2 == 0: if ""L"" and ""U"" and ""D"" in s[i]: return True def n2(): for i in range(len(s)): if i%2 != 0: if ""R"" and ""U"" and ""D"" in s[i]: return True if n1() and n2() ==True: print(""Yes"") else: print(""No"") " p02916,s029205005,Wrong Answer,"n = int(input()) a_input = input() a = a_input.split("" "") b_input = input() b = b_input.split("" "") c_input = input() c = c_input.split("" "") b_sum = 0 for i in range(n): b_sum += int(b[i]) c_sum = 0 for i in range(n-1): if int(a[i]) != n: c_sum += int(c[int(a[i])-1]) sum = b_sum + c_sum print(sum)" p03011,s003345349,Wrong Answer,"p,q,r=map(int,input().split()) if p+qp+q: print(r+q) if p==q==r: print(p+q)" p02730,s932441204,Wrong Answer,"s = input() n = len(s) for i in range((n//2)): if(s[i] != s[-(i+1)]): print(""No"") exit() for i in range(((n//2)//2)): print(s[i],s[((n//2)-1)-i]) if((s[i] != s[((n//2)-1)-i]) and s[((n+3)/2) != s[-(i+1)]]): print(""No"") exit() print(""Yes"")" p03639,s510684386,Accepted,"n=int(input()) a=list(map(int,input().split())) cnt=[0,0]#2,4の倍数の個数 for i in a: if i%4==0: cnt[1]+=1 elif i%2==0: cnt[0]+=1 ans=n-cnt[0]-cnt[1]+1 if cnt[0]!=0 else n-cnt[1] print('Yes' if ans<=cnt[1]+1 else 'No')" p02678,s804022013,Wrong Answer,"from collections import deque N, M = map(int, input().split()) graph = [[] for _ in range(N)] for i in range(M): a, b = map(int, input().split()) print(a, b) graph[a-1].append(b-1) graph[b-1].append(a-1) # print(graph) res = [-1] * (N) que = deque() que.append(0) while que: i = que.popleft() for j in graph[i]: if res[j] == -1: res[j] = i que.append(j) print(""Yes"") for i in res[1:]: print(i+1) " p02623,s425238941,Accepted,"N, M, K = map(int, input().split()) A = [0] + list(map(int, input().split())) B = [0] + list(map(int, input().split())) for i in range(1, N+1): A[i] += A[i-1] for i in range(1, M+1): B[i] += B[i-1] ans = 0 b_count = M for a_count in range(N+1): if A[a_count] > K: continue while A[a_count] + B[b_count] > K: b_count -= 1 ans = max(ans, a_count + b_count) print(ans) " p02641,s410626438,Wrong Answer,"X,N = map(int,input().split()) if N == 0 : print(X) else : P = list(map(int,input().split())) a = list(range(0,10000000)) ab = 100 an = [] for i in range(N): a.remove(P[i]) a = a for j in range(101 - N): ab = min(ab,abs(X - a[j])) if X - ab in a : print(X - ab) elif X + ab in a: print(X + ab) " p02917,s134961648,Accepted,"n=int(input()) b=list(map(int,input().split())) ans=b[0]+b[n-2] for i in range(n-2): ans+=min(b[i],b[i+1]) print(ans)" p02723,s039171862,Accepted,"S = input().strip() if S[2]==S[3] and S[4]==S[5]: print(""Yes"") else: print(""No"")" p03262,s403231083,Accepted,"from fractions import gcd N,X = map(int,input().split()) XS = list(map(int,input().split())) DIST = [abs(X-x) for x in XS] ans = DIST[0] for d in DIST: ans = gcd(ans,d) print(ans) " p03261,s934473917,Accepted,"n=int(input()) w=[] w.append(input()) t=1 for i in range(1,n): word=input() if word in w: t=0 break if word[0]!=w[i-1][-1]: t=0 break w.append(word) if t==1: print(""Yes"") else: print(""No"")" p02684,s099088707,Wrong Answer,"n,k=map(int,input().split()) a=input().split() l=[] for i in a: l.append(int(i)) print(l[l[0]-1])" p03760,s383083902,Accepted,"s1 = list(input()) s2 = list(input()) n = len(s1) ans = """" for i in range(n): try: ans += s1[i]+s2[i] except: ans += s1[i] print(ans)" p03548,s147060977,Accepted,"#abc078 b x,y,z=map(int,input().split()) print((x-z)//(y+z))" p02813,s944186039,Wrong Answer,"import itertools import sys N = int(input()) T = [] T.append(tuple(map(int, input().split()))) T.append(tuple(map(int, input().split()))) if T[0] == T[1]: sys.exit(0) M = [0]*N for i in range(N): M[i] = i+1 ans = [] for i, v in enumerate(itertools.permutations(M, N)): if v in T: ans.append(i) print(abs(ans[0] - ans[1]))" p02756,s280953693,Wrong Answer,"import sys s = str(sys.stdin.readline()) Q = int(sys.stdin.readline()) for _ in range(Q): qu = input() if qu == '1': s = s[::-1] else: _, fi, ci = qu.split() if fi == '1': s = ci + s if fi == '2': s += ci print(s)" p02912,s473665100,Accepted,"import heapq N, M = map(int, input().split()) A = list(map(lambda x : int(x)*(-1), input().split())) heapq.heapify(A) for _ in range(M): t = heapq.heappop(A) heapq.heappush(A, (-1)*(-t//2)) print(-sum(A)) " p03286,s670655254,Wrong Answer,"N = int(input()) ans = """" while N: ans = str(N % 2)+ans N = -(N//2) print(ans) " p03681,s915588341,Accepted,"import sys import math input = sys.stdin.readline def log(*args): print(*args, file=sys.stderr) def main(): n, m = map(int, input().rstrip().split()) if abs(n - m) >= 2: print(""0"") return if n == m: print(math.factorial(n) * math.factorial(m) * 2 % (pow(10, 9) + 7)) else: print(math.factorial(n) * math.factorial(m) % (pow(10, 9) + 7)) if __name__ == '__main__': main() " p03485,s899334962,Accepted,"import math a,b = map(int,input().split()) print(math.ceil((a+b)/2))" p03013,s827155358,Accepted,"n, m = map(int, input().split()) broken = [0]*(n+1) #m個階段が壊れているからそれをbrokenに入れる for i in range(m): a = int(input()) broken[a] = 1 dp = [0]*(n+1) dp[0] = 1 mod = 1000000007 for i in range(1, n+1): if broken[i]: continue #dp[-1]は0だから上手く回る dp[i] = (dp[i-1] + dp[i-2]) % mod print(dp[n]) " p02628,s840349944,Accepted,"N,K = map(int,input().split()); p = [int(x) for x in input().split()]; p.sort(); sum = 0; for i in range(0,K) : sum = sum + p[i]; print(sum);" p04044,s321905052,Accepted,"N,L=map(int,input().split()) ans="""" S=[] for i in range(N): S.append(str(input())) S=sorted(S) for j in range(N): ans+=S[j] print(ans)" p02641,s945550629,Accepted,"X, N = map(int, input().split()) P = list(map(int, input().split())) min_val = -1 for i in range(-1000, 1000): if i in P: continue if abs(min_val - X) > abs(X - i): min_val = i if len(P) == 0: print(X) else: print(min_val) " p02688,s996532900,Accepted,"n,k=map(int,input().split()) li=[0]*n for _ in range(k): d=int(input()) a=list(map(int,input().split())) for i in a: li[i-1]+=1 print(li.count(0)) " p03611,s902549884,Wrong Answer,"def main(): N = int(input()) a = list(map(int, input().split())) c = [0] * (max(a)+1) for v in a: c[v] += 1 ans = 0 for i in range(len(c) - 2): x = c[i] + c[i+1] + c[i+2] ans = max(ans, x) print(ans) if __name__ == ""__main__"": main()" p02951,s617205635,Accepted,"a,b,c = [int(x) for x in input().split()] print(max(0, c-(a-b))) " p03479,s267763294,Wrong Answer,"X, Y = map(int, input().split()) import math print(1 + math.floor(math.log2(Y/X)))" p03720,s994297466,Accepted,"n,m=map(int,input().split()) road=[0]*n for i in range(m): a,b=map(int,input().split()) road[a-1]+=1 road[b-1]+=1 for i in road: print(i)" p02570,s565749429,Accepted,"d,t,s = [int(x) for x in input().split(' ')] if d / s > t: print('No') else: print('Yes')" p02947,s538051517,Accepted,"#!/usr/bin/env python3 # from numba import njit from collections import Counter # input = stdin.readline # @njit def solve(n,l): l_dash = ["""".join(sorted(s)) for s in l] d = Counter(l_dash) return sum(v*(v-1)//2 for v in d.values()) def main(): N = int(input()) l = [input() for _ in range(N)] print(solve(N,l)) return if __name__ == '__main__': main() " p02900,s089768137,Accepted,"def bunkai(x): x_set = set() for i in range(1, int(x**0.5)+2): if x % i == 0: x_set.add(i) x_set.add(x//i) return x_set def is_prime(x): for i in range(2, int(x**0.5)+1): if x % i == 0: return None ans.add(x) A, B = map(int, input().split()) A_set = bunkai(A) B_Set = bunkai(B) kari = A_set & B_Set ans = set() for x in kari: is_prime(x) print(len(ans))" p02627,s455386241,Wrong Answer,"a = input() if a.islower(): answer = a else: answer = a.lower() print(answer) " p02556,s759001938,Accepted,"num = int(input()) sumList = [0] * num minusList = [0] * num for id in range(num): x, y = map(int, input().split()) sumList[id-1] = x + y minusList[id-1] = x - y sumMax = max(sumList) - min(sumList) minusMax = max(minusList) - min(minusList) print(max(sumMax, minusMax)) " p02963,s421889315,Accepted,"import math S = int(input()) v = 10**9 x3 = (v-S%v)%v y3 = (S+x3)//v print(""0 0 %d 1 %d %d""%(10**9, x3, y3))" p03815,s317962315,Accepted,"x=int(input()) ans=0 if x%11==0: print(2*(x//11)) else: if x%11<=6: print(2*(x//11)+1) else: print(2*(x//11)+2)" p02793,s031137022,Accepted,"from fractions import gcd N = int(input()) A_List = list(map(int,input().split())) LCM = 1 for i in A_List: LCM = LCM * i // gcd(LCM, i) ans = 0 for i in A_List: ans += LCM // i print(ans%(10**9+7))" p03852,s971574101,Wrong Answer,"c = input() if c == (""a"" or ""e"" or ""i"" or ""o"" or ""u""): print(""vowel"") else: print(""consonant"")" p03679,s303153991,Accepted,"#n = int(input()) x, a, b = map(int, input().split()) #l = list(map(int,input().split())) #l = [list(map(int,input().split())) for i in range(n)] if a >= b: ans = 'delicious' elif a+x >= b: ans = 'safe' else: ans = 'dangerous' print(ans) " p02547,s538111121,Accepted,"# 初期入力 import sys input = sys.stdin.readline #文字列では使わない N = int(input()) renzoku =0 ans =""No"" for _ in range(N): d1,d2 = map(int, input().split()) if d1 ==d2: renzoku +=1 if renzoku ==3: print(""Yes"") sys.exit() else: renzoku =0 print(ans) " p04029,s895126292,Accepted,"a=int(input()) print(int(a*(a+1)/2))" p02973,s548819586,Wrong Answer,"from collections import deque import bisect import sys input = sys.stdin.readline N = int(input()) A = [int(input()) for _ in range(N)] A = A[::-1] col = [A.pop()] col = deque(col) while A: a = A.pop() if a <= col[0]: col.appendleft(a) else: x = bisect.bisect_right(col, a) col[x - 1] = a ans = len(col) print(ans) " p02766,s733723933,Accepted,"def modd(x, y): mod(x, y) n, k = map(int, input().split()) count = 0 while n >= k: shou = n//k n = shou count += 1 print(count+1)" p02899,s168021905,Accepted,"n=int(input()) a=list(map(int,input().split())) ans=[0]*(n) for i in range(n): x=a[i] ans[x-1]+=(i+1) ans2=[str(s) for s in ans] print("" "".join(ans2)) " p02924,s661185180,Accepted,"N = int(input()) def kaidan(k): return k * (k + 1) // 2 print(kaidan(N-1))" p02753,s302348608,Accepted,"#A, B = map(int,input().split()) S = input() if S == ""AAA"" or S == ""BBB"": print(""No"") else: print(""Yes"") " p03910,s315251198,Accepted,"n = int(input()) lst = [] tmp = 0 x = 1 while tmp<= n: tmp += x lst.append(x) x += 1 if tmp==n: pass else: dif = tmp - n lst.remove(dif) for l in lst: print(l)" p02796,s079087921,Wrong Answer,"N = int(input()) X = [] d = {} for _ in range(N): x,l = map(int, input().split()) X.append(x) d[x] = l X.sort() count = 0 for i in range(len(X)-1): I = (X[i]+d[X[i]]-1) J = (X[i+1]-d[X[i+1]]+1) if I>=J: count = count + 1 i = i + 1 if i>=N: break continue print(N-count)" p03943,s188554150,Wrong Answer,"x = list(map(int, input().split(' '))) if x[0] == x[1] + x[2]: print('yes') elif x[0] + x[1] == x[2]: print('yes') elif x[0] + x[2] == x[1]: print('yes') else: print('no')" p04005,s878788887,Accepted,"A = list(map(int, input().split())) A.sort() if A[0] % 2 == 0 or A[1] % 2 == 0 or A[2] % 2 == 0: print(0) else: print(A[0] * A[1])" p02706,s669811388,Accepted,"N,M = map(int,input().split()) A = input().split() for i in range(M): N -= int(A[i]) if N >= 0: print(N) else: print(-1) " p03386,s749401553,Wrong Answer,"A,B,K=map(int,input().split()) for i in range(A,B+1) : if i<=A+K or i>=B-K : print(i)" p03150,s124071575,Accepted,"import re s = input() a = [] a += [re.match(r'.*keyence$', s)] a += [re.match(r'k.*eyence$', s)] a += [re.match(r'ke.*yence$', s)] a += [re.match(r'key.*ence$', s)] a += [re.match(r'keye.*nce$', s)] a += [re.match(r'keyen.*ce$', s)] a += [re.match(r'keyenc.*e$', s)] a += [re.match(r'keyence.*$', s)] print('YES' if any(a) else 'NO')" p02951,s130645115,Wrong Answer,"a,b,c=map(int,input().split()) if b+c>=a: print(0) else: print(c-(a-b))" p03324,s314638265,Accepted,"D, N = map(int, input().split()) if N == 100: print(101 * 100**D) else: print(N * 100**D) " p03835,s609942364,Wrong Answer,"k,s= map(int,input().split()) cnt=0 for x in range(s+1): for y in range(s+1): if 0 <= s-x-y <= k: cnt+=1 print(cnt) " p03434,s586292446,Wrong Answer,"N = int(input()) A = list(map(int,input().split())) A = sorted(A,reverse = True) ans = 0 for i in range(0,N-1,2): ans += (A[i] - A[i+1]) print(ans)" p02946,s245625518,Wrong Answer,"n,k=map(int,input().split()) x=k-n+1 out="""" for i in range(2*n+1): out+=str(x+i)+"" "" print(out[:-1])" p02711,s786473557,Accepted,"A = input() Alist = list(A) j=0 for i in range(3): if Alist[i] == '7': j+=1 if j>=1: print('Yes') else: print('No')" p04019,s038321035,Accepted,"S = input() n, s, w, e = 0, 0, 0, 0 if 'N' in S: n = 1 if 'S' in S: s = 1 if 'W' in S: w = 1 if 'E' in S: e = 1 if n == s and w == e: print('Yes') else: print('No')" p03067,s430884678,Wrong Answer,"a, b, c = map(int, input().split()) if a <= c <= b: print(""Yes"") else: print(""No"") " p02811,s123279566,Accepted,"K,X = map(int,input().split()) if 500 * K >= X: print('Yes') else: print('No')" p02691,s992622828,Wrong Answer,"n=int(input()) a=list(map(int,input().split())) c,d=dict(),dict() for i in range(n): if a[i]-i-1 in c: c[a[i]-i-1]+=1 else: c[a[i]-i-1]=1 if a[i]+i+1 in d: d[a[i]+i+1]+=1 else: d[a[i]+i+1]=1 ans=0 for i in c: if i in d: ans+=(c[i]*d[i]) print(ans) " p03419,s715494267,Accepted,"N, M = map(int, input().split()) if N == 1 or M == 1: if N == M: print(1); exit() elif N == 2 or M == 2: print(0); exit() else: print(max(N, M) - 2); exit() elif N == 2 or M == 2: print(0); exit() else: print((N-2)*(M-2))" p02813,s909994182,Accepted,"import itertools N = int(input()) First_List = list(map(int,input().split())) Second_List = list(map(int,input().split())) Num_List = sorted(First_List) F_Flg = 0 S_Flg = 0 Loop_Num = 1 for Sorted_Pair in itertools.permutations(Num_List, N): Search_Pair = list(Sorted_Pair) if (Search_Pair == First_List) & (F_Flg == 0): F_Flg = Loop_Num if (Search_Pair == Second_List) & (S_Flg == 0): S_Flg = Loop_Num Loop_Num += 1 print(abs(F_Flg-S_Flg))" p03264,s493084354,Accepted,"k = int(input()) a = k//2 b = k-a print(a*b)" p02847,s446688171,Accepted,"day = {'SUN': 7, 'MON':6, 'TUE':5, 'WED': 4, 'THU':3, 'FRI':2, 'SAT':1} s = input() print(day[s])" p03211,s788400414,Accepted,"s = input() min_abs = 1000 for i in range(len(s) - 2): if abs(753 - int(s[i: i + 3])) < min_abs: min_abs = abs(753 - int(s[i: i + 3])) print(min_abs)" p02675,s587523607,Accepted,"n = int(input()) a = n%10 if a == 3: print(""bon"") elif (a == 0) | (a == 1) | (a == 6) | (a == 8): print(""pon"") else: print(""hon"")" p02578,s363342958,Accepted,"n = int(input()) a = list(map(int, input().split())) ret = 0 now = a[0] for i in range(1, n): if now > a[i]: ret += now - a[i] a[i] = now now = a[i] print(ret)" p02777,s436790756,Wrong Answer,"colors = list(map(str, input().split())) print(colors) numbers = list(map(int, input().split())) target_color = input() for index, color in enumerate(colors): if color == target_color: numbers[index] = numbers[index] - 1 for num in numbers: print(str(num) + "" "", end="""") " p02832,s700813090,Wrong Answer,"N = int(input()) a = list(map(int, input().split())) count = 1 broke = 0 while True: if count in a: print(a.index(count)) broke += a.index(count) a = a[a.index(count) + 1:] count += 1 else: break if broke == 0: print(-1) else: print(broke) " p02818,s929374423,Accepted,"A,B,K=map(int,input().split()) if A>K:print(A-K,B) elif A+B>K:print(0,A+B-K) else:print(0,0)" p03556,s202725216,Accepted,"N=int(input()) ans=1 for i in range(N+1): if i*i<=N: ans=i else: break print(ans**2) " p02597,s942538631,Accepted,"n = int(input()) S = input() r = S.count('R') w = len(S)-r if r == 0 or w == 0: print(0) exit() ans = 0 for i in range(len(S)): if S[i] == ""R"": r -= 1 else: r -= 1 w -= 1 ans += 1 if r == 0 or w == 0: break print(ans+r)" p02622,s579669601,Wrong Answer,"S =input() T = input() count = 0 for i in range(0,len(S)): if S[i] != T[i]: count=count+1 " p02946,s959985849,Accepted,"K,X = map(int,input().split()) ans = [] for i in range(-K+1,K): ans.append(str(i+X)) print(' '.join(ans)) " p02766,s431490119,Accepted,"n, k = map(int, input().split()) ans = 0 while n > 0: ans += 1 n //= k print(ans)" p03565,s954230753,Wrong Answer,"import re S = input() T = input() results = [] for i in range(len(S) - len(T)+1): pattern = S[i:len(T) + i].replace('?', '.') m = re.search(pattern, T) if m: result = re.sub(pattern, T, S) results.append(result) if len(results) > 0 : results = sorted([ r.replace('?', 'a') for r in results]) output = results[0] else : output = 'UNRESTORABLE' print(output)" p02832,s718379504,Wrong Answer,"n=int(input()) a=list(map(int,input().split())) cnt=0 for i in range(1,n): if i in a: cnt+=1 del a[:a.index(i)] else: if i==1: print(-1) break else: break print(n-cnt)" p02548,s576077570,Accepted,"N=int(input()) ans=[] for i in range(1,N): temp=(N-1)//i ans.append(temp) Ans=sum(ans) print(Ans)" p03013,s945666546,Wrong Answer,"n, m = map(int, input().split()) a = [] mod = 10 ** 9 + 7 for _ in range(m): a.append(int(input())) dp = [0] * (n + 1) dp[0] = 1 dp[1] = 1 for i in range(2, n + 1): if i in a: continue else: dp[i] = dp[i - 1] + dp[i - 2] print(dp[-1] % mod) " p03017,s476962801,Accepted,"n, a, b, c, d = map(int, input().split()) s = input() if a > b and c > d or a < b and c < d: if s[a - 1:c].count('##') + s[b - 1:d].count('##') == 0: print('Yes') else: print('No') else: i, j = (b, d) if a < b else (a, c) if any(s[k - 1] == s[k] == s[k + 1] == '.' for k in range(i - 1, j)): print('Yes') else: print('No')" p02700,s555807765,Accepted,"a,b,c,d=map(int,input().split()) while a>0 and b>0: c-=b a-=d if a<=0 and c>0: print('No') elif c<=0: print('Yes')" p02773,s044421743,Accepted,"from collections import Counter N = int(input()) S = [] for i in range(N): S.append(input()) A = [] d = Counter(S) md = d.most_common(1)[0][1] for key, value in d.items(): if value == md: A.append(key) As = sorted(A) for a in As: print(a) " p02917,s078325146,Accepted,"n = int(input()) b_list = list(map(int,input().split())) a_list = [0]*n a_list[0] = b_list[0] k = 0 while k <= n-2: if a_list[k] > b_list[k]: a_list[k] = b_list[k] a_list[k+1] = b_list[k] k += 1 print(sum(a_list))" p02714,s859192610,Wrong Answer,"if __name__ == '__main__': N = int(input()) S = input() cnt = 0 for i in range(N): for j in range(i+1, N): for k in range(j+2, N): if (S[i] != S[j] and S[i] != S[k] and S[j] != S[k]) and j - i != k - j: cnt += 1 print(cnt)" p02594,s626882390,Accepted,"x = int(input()) if x >= 30: print(""Yes"") else: print(""No"")" p03699,s128829674,Accepted,"n = int(input()) score = [int(input()) for _ in range(n)] score.append(0) score.sort() sum_value = sum(score) cnt = 0 for num in score: if (sum_value-num) % 10 != 0: sum_value -= num break cnt += 1 if cnt == n+1: sum_value = 0 print(sum_value)" p03994,s485433343,Accepted,"s=input() ls = len(s) k= int(input()) for i in range(ls-1): tn = ord('z')-ord(s[i])+1 if k>=tn and s[i]!='a': k-=tn print('a',end='') else: print(s[i],end='') ik = (k + ord(s[-1])-ord('a')) % 26 print(chr(ord('a')+ik))" p02922,s735494859,Accepted,"A, B = map(int, input().split()) res = 1 cnt = 0 while res < B: res += A - 1 cnt += 1 print(cnt)" p02577,s106348837,Accepted,"N = input() SUM = 0 for n in N: SUM += int(n) if SUM % 9 == 0: print('Yes') else: print('No')" p03427,s902068010,Accepted,"n=input() digit_sum=int(n[0])-1+9*(len(n)-1) digit_n=sum(int(j) for j in n) print(max(digit_n,digit_sum))" p02792,s203407555,Wrong Answer,"N = int(input()) C = [[0] * 10 for i in range(10)] for i in range(1, 10): for j in range(1, 10): for n in range(1, N+1): if str(n)[0] == i and str(n)[-1] == j: C[i][j] += 1 ans = 0 for i in range(1, 10): for j in range(1, 10): ans += C[i][j]*C[j][i] print(ans) " p03449,s906405974,Accepted,"n=int(input()) A1=list(map(int,input().split())) A2=list(map(int,input().split())) ans=0 for i in range(n): B1=A1[:i+1] B2=A2[i:] ans=max(ans,sum(B1)+sum(B2)) print(ans)" p03760,s369918926,Accepted,"O = input() E = input() if len(O) == len(E): for i in range(len(O)): print(O[i], end="""") print(E[i], end="""") elif len(O) > len(E): for i in range(len(E)): print(O[i], end="""") print(E[i], end="""") print(O[i+1]) else: for i in range(len(E)): print(O[i], end="""") print(E[i], end="""") print(E[i+1])" p02659,s290886416,Accepted,"from sys import stdin import math from decimal import Decimal A, B = input().split("" "") a = int(A) b = Decimal(B) print (math.floor(a*b)) " p02598,s812980303,Wrong Answer,"n,k,*a = map(int,open(0).read().split()) def func(b): c = k for i in a: if b == 0: c -= i+1 else: c -= i//b if c < 0: return False return True l = 0 r = max(a) while(r>l): lr = (l+r)//2 if func(lr): r = lr else: l = lr + 1 print(r)" p03136,s082004130,Wrong Answer,"def actual(n, L): max_l = max(L) others_l = sum(L) - max_l if max_l < others_l: return 'Yes' return 'No' n = int(input()) L = map(int, input().split()) print(actual(n, L))" p03137,s656442476,Accepted,"N, M = map(int, input().split()) X = list(map(int, input().split())) ans = 0 if M>N: X.sort() D = [] for i in range(M-1): d = X[i+1]-X[i] D.append(d) D.sort() D = D[:(M-N)] ans = sum(D) print(ans) " p02958,s467150703,Wrong Answer,"n=int(input()) p=list(map(int,input().split())) l=list(range(1,n+1)) k=0 for i in range(n): if p[i]==l[i]: k+=1 if k==0 or k==2: print(""YES"") else: print(""NO"")" p02820,s980399617,Accepted,"def main(): N, K = map(int, input().split()) R, S, P = map(int, input().split()) T = list(input()) score = 0 for i in range(K, N): if T[i] == T[i-K]: T[i] = 'x' for t in T: if t == 'r': score += P elif t == 's': score += R elif t == 'p': score += S print(score) if __name__ == ""__main__"": main()" p02744,s764885475,Accepted,"N = int(input()) alphabets = [chr(ord('a') + x) for x in range(26)] ans = [] def dfs(d, i_max, S): if d == N-1: ans.append(S) return for i in range(i_max+2): dfs(d+1, max(i_max, i), S + alphabets[i]) dfs(0, 0, ""a"") print(*ans, sep='\n') " p02621,s489971229,Accepted,"a = int(input()) print(a+a*a+a*a*a) " p02622,s843909880,Accepted,"S = input() T = input() print(sum(s != t for s, t in zip(S, T))) " p03086,s962200477,Accepted,"s = input() acgt = 'ACGT' max_count = 0 i = 0 while i < len(s): count = 0 if s[i] not in acgt: i += 1 continue count += 1 for j in range(i+1, len(s)): if s[j] not in acgt: break count += 1 if count > max_count: max_count = count i += count + 1 print(max_count) " p03672,s140476945,Wrong Answer,"S=input() S2=S[:(len(S))//2] while len(S)>=4: S=S[:-2] S2=S2[:-1] if S==S2+S2: print(len(S)) " p02933,s987230744,Accepted,"N = int(input()) M = input() if N >= 3200: print(M) else: print('red')" p02552,s296841268,Wrong Answer,"x=input() if x==1: print(0) if x==0: print(1)" p03274,s504930624,Accepted,"n, k = map(int, input().split()) x = list(map(int, input().split())) ans = 10 ** 9 now = 0 for i in range(n-k+1): ltor = abs(now - x[i]) + abs(x[i+k-1] - x[i]) rtol = abs(now - x[i+k-1]) + abs(x[i+k-1] - x[i]) tmp = min(ltor, rtol) ans = min(ans, tmp) print(ans)" p02831,s847584699,Accepted,"A, B = map(int, input().split()) L = max(A, B) S = min(A, B) ans = L while True: if ans%S==0: print(ans) break ans+=L" p03407,s909534621,Wrong Answer,"a,b,c=map(int, input().split()) print(""Yes"" if a+2*b>=c else ""No"")" p02933,s247375480,Accepted,"a = int(input()) s = input() if a >= 3200: print(s) else: print(""red"")" p03821,s455947398,Wrong Answer,"n = int(input()) a = [] b = [] for i in range(n): x, y = map(int, input().split()) a.append(x) b.append(y) ans = 0 a = a[::-1] b = b[::-1] for i in range(n): if a[i] % b[i] == 0: next else: ans += b[i] - ((a[i]+ ans) % b[i]) print(ans)" p03862,s477062382,Wrong Answer,"def candy(): boxNum, x = [int(i) for i in input().split()] ain = input() alist = ain.split(' ') s = 0 for i in range(0, boxNum-1): if int(alist[i]) > x: s = s + (int(alist[i+1]) -x) alist[i+1] = 0 elif int(alist[i+1]) + int(alist[i]) > x: s = s + (int(alist[i+1]) + int(alist[i]) - x) alist[i+1] = x - int(alist[i]) print(s) candy()" p03437,s281684732,Accepted,"import sys input = sys.stdin.readline def main(): X, Y = map(int, input().split()) if X % Y != 0: ans = X else: ans = -1 print(ans) if __name__ == ""__main__"": main() " p03681,s528922281,Wrong Answer,"import math N,M=map(int,input().split()) d=abs(N-M) if d>1: print(0) elif d==1: ans=math.factorial(N)*math.factorial(M)%(10**9+7) print(ans) else: ans=math.factorial(N)*math.factorial(M)*2%(10*9+7) print(ans)" p03359,s427491563,Accepted,"a, b = map(int, input().split()) if a > b: print(a-1) else: print(a)" p02720,s499465498,Accepted,"# import numpy as np # import math # import copy from collections import deque import sys input = sys.stdin.readline # sys.setrecursionlimit(10000) def main(): K = int(input()) queue = deque() for i in range(1,10): queue.append(i) for i in range(K): x = queue.popleft() d = x % 10 temp = 10 * x + d if d != 0: queue.append(temp - 1) queue.append(temp) if d != 9: queue.append(temp + 1) print(x) main() " p02607,s869078882,Accepted,"N = int(input()) a=list(map(int,input().split())) c = 0 for i in range(N): if i%2==0: if a[i]%2==1: c = c+1 print(c)" p02897,s835615935,Accepted,"# https://atcoder.jp/contests/abc142/tasks/abc142_a N = int(input()) ans = 1 - ((N // 2) / N) print(ans)" p02553,s962563160,Accepted,"a, b, c, d = map(int, input().split()) ans = [a*c, a*d, b*c, b*d] print(max(ans))" p02584,s461300391,Accepted,"x,k,d = map(int,input().split()) n = abs(x)//d if n>k: ans = min(abs(x-k*d),abs(x+k*d)) else: ans = min(abs(x+min(k,n)*d),abs(x-min(k,n)*d)) if (k-n)%2: ans = min(abs(ans-d),abs(ans+d)) print(ans)" p03136,s777795440,Accepted,"n = int(input()) l_list = list(map(int, input().split())) if sum(l_list) - 2* max(l_list) > 0: print('Yes') else: print('No')" p03827,s580899289,Accepted,"n=int(input()) s=input() x=0 ans=0 for i in range(n): if s[i]==""I"": x+=1 if ans= n: print(""Yes"") else: print(""No"")" p03011,s224161733,Accepted,"p = list(map(int, input().split())) print(sum(p) - max(p))" p03438,s046204186,Accepted,"n, *p = map(int, open(0).read().split()) s = sum(j - i - max(0, i - j) - max(0, j - i)%2 for i, j in zip(p, p[n:])) print(""Yes"" if s >= 0 == s%2 else ""No"")" p02720,s682064676,Accepted,"import queue k = int(input()) q = queue.Queue() x = 0 for i in range(1, 10): q.put(i) for j in range(k): x = q.get() if x%10!=0: q.put((x*10)+(x%10)-1) q.put((x*10)+(x%10)) if x%10!=9: q.put((x*10)+(x%10)+1) print(x) " p03997,s790061648,Wrong Answer,"n=int(input()) ans=0 for i in range(n): ans+=i+1 print(ans) " p02555,s699627099,Accepted,"import math def comb(n, r, mod): return math.factorial(n + r - 1)//(math.factorial(n - 1)*math.factorial(r))%mod s = int(input()) mod = 10**9 + 7 ans = 1 if s < 3: ans = 0 for i in range(2, 700): #分割数, 1の時は1通りなので除外 if s < 3*i: break r = s - i*3 ans = (ans + comb(i, r, mod))%mod print(ans) " p03161,s708460968,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])" p03607,s057828217,Accepted,"N = int(input()) dict = {} for i in range(N): a = int(input()) if not a in dict.keys(): dict[a] = 1 else: dict[a] += 1 sum = 0 for i in dict.keys(): if dict[i]%2 == 1: sum += 1 print(sum) " p02621,s509340116,Accepted,"a = int(input()) print(a + a**2 + a**3)" p02570,s664433988,Accepted,"strin = input() D, T, S = int(strin.split("" "")[0]), int(strin.split("" "")[1]), int(strin.split("" "")[2]) if (D / S) <= T: print(""Yes"") else: print(""No"")" p04031,s893258551,Accepted,"#043c N = int(input()) #N <= 100 a_list = list(map(int, input().split())) #-100 <= ai <= 100 #ループ数は200*100 = 20000.総当たりでOK min_cost = 111*(200**2) for y in range(min(a_list),max(a_list) + 1): cost = 0 for x in a_list: cost += (x - y)**2 if cost < min_cost: min_cost = cost print(min_cost)" p02554,s915480264,Accepted,"n=int(input()) num=10**n-2*9**n+8**n numa=num%(10**9+7) print(numa)" p02603,s843969347,Wrong Answer,"n = int(input()) a = list(map(int,input().split())) hold = 0 money = 1000 for i in range(n-1): if a[i+1] > a[i]:#buy hold = money//a[i] money = money % a[i] if a[i+1] < a[i]:#sell money += hold*a[i] hold = 0 print(money+a[-1]*hold)" p03719,s442015621,Accepted,"a, b, c = map(int, input().split()) if a <= c and c <= b: print(""Yes"") else: print(""No"")" p02813,s759315974,Accepted,"import itertools n = int(input()) p = tuple(int(i) for i in input().split()) q = tuple(int(i) for i in input().split()) a = tuple(itertools.permutations(list(range(1, n+1)), n)) print(abs(a.index(p) - a.index(q)))" p03760,s346560324,Wrong Answer,"O = list(input()) E = list(input()) for x,y in zip(O,E): print(x+y,end="""")" p03544,s573165587,Accepted,"l,m=2,1 for _ in range(int(input())): l,m=m,l+m print(l)" p03001,s260629668,Wrong Answer,"w,h,x,y = list(map(int, input().split())) if((x == w//2 or y == h//2)): print((w*h)//2 , 1) else: print((w*h)//2, 0)" p03328,s894899542,Wrong Answer,"a, b = map(int, input().split()) d = b - a c = 1 for i in range(2, 999): if d == i: print(c-a) exit() c += i" p02596,s598022753,Accepted,"K = int(input()) f = 1 j = 7%K while f < K and j != 0: j = (j*10 + 7)%K f += 1 if j == 0: print(f) else: print('-1')" p03105,s948500165,Wrong Answer,"a, b, c = map(int, input().split()) print(b // a) " p02576,s290595512,Wrong Answer,"import math N, X, T = map(int,input().split()) print((math.floor(N/X)+1)*T)" p03696,s261776608,Accepted,"n = int(input()) s = input() tmp = s while True: if tmp.count(""()"") == 0: break tmp = """".join(tmp.split(""()"")) x = 0 y = 0 for c in tmp: if c == "")"": x += 1 else: y += 1 ans = ""(""*x + s + "")""*y print(ans)" p03095,s610264246,Accepted,"N = int(input()) S = input() from collections import Counter ctr = Counter(S) MOD = 10**9+7 ans = 1 for v in ctr.values(): ans *= (v+1) ans %= MOD ans -= 1 ans %= MOD print(ans)" p02687,s552792800,Wrong Answer,"S=input('') if ('ABC==S'): print('ARC') else: print('ABC')" p03778,s180712210,Accepted,"w, a, b = map(int, input().split()) if b > a+w: print(b-a-w) elif b+w < a: print(a-b-w) else: print(0)" p03962,s817800080,Wrong Answer,"a,b,c = map(int,input().split()) d=0 if a ==b: if b==c: d =1 else: d =2 else: if b==c: d =2 else: d =3 print(d) " p03360,s071578671,Accepted,"abc = sorted(list(map(int, input().split()))) k = int(input()) ans = abc[0] + abc[1] + abc[2] * (2 ** k) print(ans) " p02548,s600239620,Wrong Answer,"N = int(input()) ans = 0 for c in range(N-1): for a in range(N-1): for b in range(N-1): if a*b+c == N: ans += 1 print(ans)" p03219,s718223180,Accepted,"x, y = map(int, input().split()) print(x+y//2)" p02939,s757163863,Accepted,"S = list(input()) i = 1 r = len(S) while True: if i >= len(S): break if S[i-1] == S[i]: r -= 1 i += 2 i += 1 print(r)" p03208,s713060072,Accepted,"def main(): # n = int(input()) n, m = map(int, input().split()) # v = list(map(int, input().split())) # s = input() h = [int(input()) for _ in range(n)] h.sort() temp = [] for i in range(n-m+1): temp.append(h[i+m-1]-h[i]) temp.sort() print(temp[0]) if __name__ == '__main__': main() " p03220,s910555032,Accepted,"N = int(input()) T, A = map(int,input().split()) H = list(map(int,input().split())) k = [] for h in H: temp = T - h * 0.006 sa = abs(A - temp) k.append(sa) min_k = min(k) print(k.index(min_k)+1)" p03323,s870051462,Accepted,"a,b=map(int, input().split()) if a<=8 and b<=8: print(""Yay!"") else: print("":("")" p02987,s980190238,Wrong Answer,"a = input() for i in range (4): if a.islower(): break elif a[0]==a[1] or a[0]==a[2] or a[0]==a[3] and a[1]==a[2] or a[1]==a[3]: print(""Yes"") else: print(""No"") break " p03795,s272490497,Accepted,"eat_N = int(input()) x = eat_N * 800 y = (eat_N // 15) * 200 print( x - y)" p02989,s979608882,Wrong Answer,"n = int(input()) d = list(map(int, input().split())) d = sorted(d) if d[n//2] == d[n//2]: print(0) else: print(d[n//2] - d[n//2-1])" p03061,s728556016,Accepted,"from fractions import gcd n = int(input()) a = list(map(int, input().split())) gcdl = [0] * n gcdr = gcdl[:] gcdl[0] = a[0] gcdr[-1] = a[-1] for i in range(1, n): gcdl[i] = gcd(a[i], gcdl[i - 1]) for i in range(n - 2, -1, -1): gcdr[i] = gcd(a[i], gcdr[i + 1]) max_gcd = max(gcdl[-2], gcdr[1]) for i in range(1, n - 1): temp_gcd = gcd(gcdl[i - 1], gcdr[i + 1]) if temp_gcd > max_gcd: max_gcd = temp_gcd print(max_gcd)" p02912,s922594493,Accepted,"def main(): import heapq n, m, *a = map(lambda x: -int(x), open(0).read().split()) heapq.heapify(a) for _ in range(-m): x = heapq.heappop(a) heapq.heappush(a, x / 2) ans = -sum(map(lambda x: int(x), a)) print(ans) if __name__ == '__main__': main() " p02988,s325730450,Accepted,"n = int(input()) p = list(map(int, input().split())) cnt = 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]: cnt += 1 print(cnt)" p02582,s650883857,Wrong Answer,"word = input() if word == ""SSS"": print(0) elif word == ""RSS"" or ""SRS"" or ""SSR"" or ""RSR"": print(1) elif word == ""SRR"" or ""RRS"": print(2) elif word == ""RRR"": print(3) " p03720,s776450823,Accepted,"n,m=map(int,input().split()) List=[] for i in range(m): road=list(map(int,input().split())) List.append(road) road=[road[1],road[0]] List.append(road) 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 " p03565,s234691511,Accepted,"S=list(input()) s=len(S) T=list(input()) t=len(T) for i in range(s-t+1): a=0 for j in range(t): if S[-1-i-j]==""?"": continue if S[-1-i-j]!=T[-1-j]: a=1 if a==0: for j in range(s): if S[j]==""?"": S[j]=""a"" S[s-t-i:s-i]=T for j in range(s): print(S[j],end="""") print() exit() print(""UNRESTORABLE"")" p02645,s893855709,Accepted,"S = input() print(S[:3])" p03043,s695379899,Accepted,"N,K = map(int,input().split()) ans_sum=0#確率合計 for i in range(1,N+1): num=i#現在の数字格納用 ans=1/N #Nの目が出る確率 while num 0 and i % 10 > 0: print('DENIED') exit() print('APPROVED')" p03319,s081936361,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) ans = 1 for i in range(K, N, K - 1): ans += 1 print(ans) " p03208,s582609281,Accepted,"N, K = map(int,input().split()) h = [int(input()) for i in range(N)] s_h = sorted(h) tmp = [] ans1 = 0 ans2 = 0 ans3 = 0 for i in range(N-K+1): ans1 = s_h[i+K-1] ans2 = s_h[i] ans3 = ans1 - ans2 tmp.append(ans3) print(min(tmp))" p03493,s911744396,Accepted,"s = str(input()) ans = 0 for i in range(3): if s[i]== '1': ans = ans +1 else: print(ans)" p02663,s806474273,Accepted,"a,b,c,d,e = map(int, input().split()) print(c*60+d-a*60-b-e)" p02571,s924759981,Wrong Answer,"def main(): S = input() T = input() temp = '' for i in range(1, len(T)+1): print(T[0:i]) if T[0:i] in S: temp = T[0:i] print(len(T)- len(temp)) if __name__ == '__main__': main()" p02699,s264132998,Accepted,"s,w=map(int,input().split()) if s>w: print(""safe"") else: print(""unsafe"")" p02882,s359113463,Accepted,"import math p = 3.14159 a,b,x = map(int,input().split()) x /= a if x >= a*b/2: print(math.atan(2/(a**2)*(a*b-x))/p*180) else: print(90-(math.atan((2*x/b**2))/p*180))" p02789,s816120771,Wrong Answer,"# coding: utf-8 # Your code here! a,b = map(int,input().split("" "")) if a == b: print(""YES"") else: print(""NO"") " p02779,s844514630,Accepted,"n = int(input()) # 被りの要素が削除される a = set(input().split()) print('YES' if len(a) == n else 'NO')" p03000,s812057720,Accepted,"N,X = map(int,input().split()) L = list(map(int,input().split())) D = 0 a = 1 for n in range(N): D+=L[n] if D<=X: a+=1 print(a)" p02792,s558382056,Accepted,"N = int(input()) numMap = {} answer = 0 def StartEnd(x): start = str(x)[0] end = str(x)[-1] return start, end for i in range(1, N+1): # print('numMap:', numMap) pair = StartEnd(i) if pair in numMap: numMap[pair] += 1 else: numMap[pair] = 1 for i in range(1, N+1): key = StartEnd(i) rev = key[::-1] # print('rev:', rev) if rev in numMap: answer += numMap[rev] print(answer) " p03474,s191583889,Accepted,"a,b=map(int,input().split()) s=input() print(""Yes"" if s[a]==""-"" and s.count(""-"")==1 else ""No"")" p02829,s529139622,Wrong Answer,"i = [input() for i in range(2)] if 1 not in i: print(""1"") elif 2 not in i: print(""2"") else: print(""3"")" p02909,s289454213,Wrong Answer,"s = input() ret = '' if( s =='Sunny'): ret = 'Cloudy' elif( s =='Cloudy'): ret = 'Rainy' elif( s =='Rainy '): ret = 'Sunny' print(ret) " p02873,s789684545,Accepted,"S = input() N = len(S) A = [0] * (N + 1) B = [0] * (N + 1) for i in range(N): if S[i] == ""<"": A[i+1] = A[i] + 1 else: A[i+1] = 0 for i in range(N-1, -1, -1): if S[i] == "">"": B[i] = B[i+1] + 1 else: B[i] = 0 print(sum([max(A[i], B[i]) for i in range(N + 1)]))" p03821,s674416323,Accepted,"from math import ceil N = int(input()) A, B = [], [] for _ in range(N): ai, bi = map(int, input().split()) A.append(ai) B.append(bi) # 回数だけ確定する # 後ろから順番にすれば良い気がする (iのボタンは1からiまでしか作用しないので) count = 0 for j in range(N - 1, -1, -1): if (count + A[j]) % B[j] == 0: continue else: # 足りない分をカウントする count += B[j] - (count + A[j]) % B[j] print(count)" p02859,s084777967,Accepted,"r = int(input()) ans = r**2 print(ans)" p02687,s608563317,Accepted,"inp = input() if (inp == ""ABC"") : print(""ARC"") else : print(""ABC"")" p03607,s856358555,Accepted,"n = int(input()) d = {} for i in range(n): a = int(input()) if a in d: if d[a] <= 0: d[a] += 1 else: d[a] -=1 else: d[a] = 1 cnt = 0 for i in d.values(): if i > 0: cnt += 1 print(cnt)" p02935,s682274694,Accepted,"N = int(input()) apple = sorted(list(map(int, input().split()))) c = (apple[0] + apple[1]) / 2 for i in range(2, N): c = (c + apple[i]) / 2 print(c)" p02802,s091247242,Wrong Answer,"n, m = [int(s) for s in input().split()] a = [0 for _ in range(n)] for i in range(m): p, res = input().split() p = int(p) - 1 if a[p]%2==0: a[p] += 2 if res=='WA' else 1 print(sum([tmp%2 for tmp in a]), sum([tmp//2 for tmp in a]))" p03986,s677037631,Wrong Answer,"S=input() N=len(S) s=1 for i in range(1,N): if S[N-1-i]==S[N-1]: s+=1 else: break if S[N-1]=='T': print(0) else: print(2*s) " p03723,s655756283,Accepted,"a,b,c = map(int, input().split()) if a % 2 != 0 or b % 2 != 0 or c % 2 != 0: print(0) else: for i in range(10**6): temp1 = a temp2 = b temp3 = c a = int((temp2+temp3)/2) b = int((temp1+temp3)/2) c = int((temp1+temp2)/2) if a % 2 != 0 or b % 2 != 0 or c % 2 != 0: break if i == 10**6 - 1: print(-1) else: print(i+1)" p02726,s665245812,Accepted,"import numpy as np from scipy.sparse.csgraph import shortest_path from scipy.sparse import csr_matrix n, x, y = map(int, input().split()) v = [x-1] u = [y-1] for i in range(n-1): v.append(i) u.append(i+1) csr = csr_matrix(([1]*n, (v, u)), shape=(n, n)) result = shortest_path(csr, method='D', directed=False).astype(int) ans = np.bincount(result.ravel(), minlength=n) // 2 print(*ans[1:], sep='\n')" p02688,s265871329,Accepted,"N,K=map(int,input().split()) A=[] for _ in range(K): d=int(input()) A.append(list(map(int,input().split()))) print(N-len(set(sum(A,[])))) " p02761,s316000766,Accepted,"n,m=map(int,input().split()) a=[list(map(int,input().split())) for i in range(m)] l=10**(n-1) if n==1: l=0 for i in range(l,10**n): s=str(i) for x,y in a: if s[x-1]!=str(y): break else: print(i) exit() print(-1) " p03472,s650687633,Accepted,"from heapq import * n, h = map(int,input().split()) ab = [list(map(int,input().split())) for i in range(n)] a = [] b = [] for i, j in ab: a.append(i) b.append(-j) heapify(b) max_a = max(a) cnt = 0 while h > 0: temp = heappop(b) * (-1) if b else 0 if temp > max_a: h -= temp cnt += 1 else: temp = (h + max_a - 1)/max_a h -= max_a * int(temp) cnt += int(temp) print(cnt)" p02779,s986758405,Accepted,"N = int(input()) A = list(map(int, input().split())) # [1, 2, 3, 4] になる len2 = len(set(A)) if N == len2: print('YES') else: print('NO')" p02795,s858690689,Accepted,"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) exit() " p03161,s777557912,Accepted,"n, k = map(int, input().split()) h = [int(_) for _ in input().split()] dp = [1000000000] * n 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] - h[i+j])) print(dp[n-1]) " p03524,s550528308,Accepted,"import sys input = sys.stdin.readline from collections import Counter def read(): S = input().strip() return S, def solve(S): C = Counter(S) + Counter(""abc"") V = list(sorted(C.values())) if V[-1] - V[0] <= 1: return ""YES"" else: return ""NO"" if __name__ == '__main__': inputs = read() print(solve(*inputs)) " p02598,s387410797,Accepted,"N,K = map(int,input().split()) A = list(map(int, input().split())) X = list(range(1,N+1)) lo = 1 hi = max(A) while hi-lo>=2: mid = (lo+hi)//2 temp = list(map(lambda x: x//mid - (x%mid==0) ,A)) if sum(temp) <= K: hi = mid else: lo = mid temp = list(map(lambda x: x//lo - (x%lo==0) ,A)) if sum(temp) <= K: print(lo) else: print(hi)" p03243,s092398538,Accepted,"n=input() k = int(n) % 111 if k==0: print(n) else: if n[0]>n[1] or (n[0]==n[1] and n[1]>n[2]): print(n[0]*3) else: print((str(int(n[0])+1))*3)" p02879,s747054617,Wrong Answer,"A,B=map(int,input().split()) if 1= a: t.append(b-i) y = list(set(t)) for x in sorted(y): print(x) " p02881,s981941536,Wrong Answer,"N=int(input()) for i in range(int(N**0.5)+1,1,-1): if N%i==0: print(N/i+i-2)" p02989,s159905883,Accepted,"n = int(input()) d = sorted(list(map(int,input().split()))) print(d[n//2] - d[n//2-1])" p03472,s928725212,Wrong Answer,"import sys input = sys.stdin.readline 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()) a_max = max(a) b_thr = [] for i in b: if i > a_max: b_thr.append(i) b.sort(reverse=True) ans = 0 for i in b_thr: if h > 0: h -= i ans += 1 else: print(ans) exit() if h % a_max == 0: ans += h // a_max else: ans += h // a_max + 1 print(ans)" p03860,s180554374,Accepted,"s=input() i=s.split("" "") print(i[0][0]+i[1][0]+i[2][0])" p03632,s131861698,Wrong Answer,"a,b,c,d = map(int, input().split()) if b < c or d < a: print(""0"") elif a <= c: if b <= d: print(b-c) else: print(d-c) else: if c <= a: print(d-a) else: print(d-c)" p03998,s108681099,Accepted,"A = input() B = input() C = input() S = dict() S['a'] = list(A[::-1]) S['b'] = list(B[::-1]) S['c'] = list(C[::-1]) next_p = 'a' while S[next_p]: next_p = S[next_p].pop() print(next_p.upper())" p02838,s221752428,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): one = np.count_nonzero(a >> i & 1) zero = n - one ans += one * zero * 2 ** i ans %= MOD print(ans)" p03345,s199515440,Accepted,"#template def inputlist(): return [int(j) for j in input().split()] #template #issueから始める A,B,C,K = inputlist() if abs(B-A) >= 10**18: print(""Unfair"") exit() ans = A-B if K % 2 == 1: ans *= -1 print(ans)" p02723,s666538873,Wrong Answer,"S = list(input()) if S[2] == S[3] and S[4] == S[5]: print('yes') else: print('no')" p03774,s643099458,Accepted,"N, M = map(int, input().split()) stdt = [] chpt = [] for _ in range(N): a, b = map(int, input().split()) stdt.append((a, b)) for _ in range(M): a, b = map(int, input().split()) chpt.append((a, b)) for s in stdt: a, b, = s[0], s[1] m = 100000000000000 i = 0 for j in range(M): d = abs(a - chpt[j][0]) + abs(b - chpt[j][1]) if m > d: m = d i = j + 1 print(i) " p03693,s732629300,Wrong Answer,"# -*- coding: utf-8 -*- r, g, b = map(int, list(input().split())) num = r * 100 + g * 10 + b print(num) if num % 4: print('No') else: print('Yes') " p02689,s631593277,Accepted,"n,m = map(int, input().split()) ten = list(map(int, input().split())) arr = [list(map(int,input().split())) for i in range(m)] hikui = [] for i in arr: if ten[i[0]-1] X: print('NO') exit() if A + B >= X: print('YES') else: print('NO') " p02832,s843101888,Accepted,"from sys import exit N = int(input()) A = list(int(x) for x in input().split()) break_count = 0 for key, a in enumerate(A, 1): if not a == key - break_count: break_count += 1 if break_count == N: print(-1) else: print(break_count) " p02916,s759947683,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(1, N): if A[i] - A[i - 1] == 1: ans += C[A[i - 1] - 1] print(ans)" p02861,s047088463,Accepted,"import math n = int(input()) xs = [] ys = [] for i in range(n): x, y = map(int, input().split()) xs.append(x) ys.append(y) sum_dist = 0 for i in range(n-1): for j in range(i+1, n): sum_dist += math.sqrt((xs[i]-xs[j]) ** 2 + (ys[i]-ys[j]) ** 2) print(sum_dist * 2 / n)" p03971,s341536596,Accepted,"N,A,B = map(int,input().split()) S = input() countA = 0 countB = 0 for i in range(len(S)): if S[i] == 'a' and countA + countB < A + B: countA += 1 print('Yes') elif S[i] == 'b' and countA + countB < A + B and countB < B: countB += 1 print('Yes') else: print('No')" p03612,s654251121,Accepted,"import sys,math,collections,itertools input = sys.stdin.readline N=int(input()) p=list(map(int,input().split())) pa = [] cnt = 0 for i in range(N): if i+1 == p[i]: cnt +=1 elif i+1 != p[i] and cnt>0: pa.append(cnt) cnt =0 if cnt >0: pa.append(cnt) cnt = 0 for cn in pa: cnt += cn//2+cn%2 print(cnt) " p03457,s587781133,Accepted,"n = int(input()) pt = 0 px, py = 0, 0 f = True for i in range(n): t, x, y = map(int, input().split()) dis = abs(px-x) + abs(py-y) dt = t - pt #print(""dis{0} dt = {1}"".format(dis, dt)) if dt >= dis and abs(dis - dt) % 2 == 0: pass else: f = False pt, px, py = t, x, y print(""Yes"" if f else ""No"") " p02766,s736154315,Accepted,"N, K = map(int, input().split()) for i in range(10000): if N//(K**i) >= K: continue else: print(i+1) exit(0)" p02612,s683949996,Accepted,"N = int(input()) count = int((N-1)/1000) + 1 print(1000*count-N) " p02793,s998264353,Accepted,"from fractions import * n,*a=map(int,open(0).read().split()) b=1 for i in a:b*=i//gcd(b,i) print(sum(b//i for i in a)%(10**9+7)) " p02552,s180315342,Wrong Answer,"a=int(input()) print(not a )" p02947,s058418577,Wrong Answer,"import sys input = sys.stdin.readline from collections import defaultdict N = int(input()) d = defaultdict(int) for _ in range(N): s = list(input().rstrip(""\r\n"")) s.sort() if d["""".join(s)] == 0: d["""".join(s)] += 1 else: d["""".join(s)] += d["""".join(s)] ans = 0 for k in d: ans += d[k]-1 print(ans)" p02793,s977682932,Accepted,"N = int(input()) As = list(map(int, input().split())) def calcgcd(a, b): if a > b: a, b = b, a while a > 0: a, b = b%a, a return b def calclcm(a, b): return a*b//calcgcd(a, b) r = 1 a = As[0] for i in range(1, N): b = As[i] d = calcgcd(a, b) r = (r*(b//d)+(a//d))%1000000007 a = a*b//d print(r) " p03457,s934087692,Accepted,"N=int(input()) a=[list(map(int,input().split())) for _ in range(N)] dp=[[0,0] for _ in range(N+1)] f=True for i in range(N): t=a[i][0]-dp[i][1] x=a[i][1] y=a[i][2] if t>=x+y-dp[i][0] and t%2==(x+y+dp[i][1])%2: dp[i+1][0]=x+y dp[i+1][1]=a[i][0] else: f=False break if f:print(""Yes"") else:print(""No"")" p03962,s297005367,Accepted,"a=input().split() b=list(set(a)) print(len(b))" p02690,s512345367,Wrong Answer,"x = int(input()) nums = [] i = 0 while i ** 5 <= 10 ** 10: nums.append(i ** 5) i += 1 for i in range(len(nums)): a5 = nums[i] for j in range(len(nums)): b5 = nums[j] if x == a5 - b5: print(i, j) exit() if x == a5 + b5: print(i, -j) exit() " p03487,s406540065,Accepted,"from collections import Counter N = int(input()) a = list(map(int,input().split())) c = Counter(a) cnt = 0 for key,value in Counter(a).items(): if key < value: cnt += value - key if key > value: cnt += value print(cnt)" p03673,s727820384,Accepted,"n = int(input()) a = list(map(int, input().split())) cnt = 0 b = [] c = [] for i in range(n): if i == 0: b.append(a[i]) elif i % 2 == 0: b.append(a[i]) elif i % 2 == 1: c.append(a[i]) if n % 2: ans = b[::-1] + c else: ans = c[::-1] + b print(*ans) " p02756,s730792265,Accepted,"def solve(): S = input() q = int(input()) flg = 0 li = ["""", """"] for _ in range(q): Q = input().split() if Q[0] == ""1"": flg = 1 - flg else: li[(int(Q[1]) - 1 + flg) % 2] += Q[2] if flg: S = S[::-1] print(li[flg][::-1] + S + li[1 - flg]) solve() " p02675,s978491512,Accepted,"n = input() hon = ['2','4','5','7','9'] pon = ['0','1','6','8'] bon = ['3'] if n[-1] in bon: print('bon') elif n[-1] in hon: print('hon') elif n[-1] in pon: print('pon') " p02866,s142743633,Wrong Answer,"n=int(input()) d=list(map(int,input().split())) ans=1 mod=998244353 pre=0 c=[0]*n for dd in d: c[dd]+=1 max_i=0 for cc in c: if cc>0: max_i+=1 for i in range(max_i): if i==0: if c[i]==1: pre=c[i] continue else: ans=0 break if c[i]!=0: ans*=pow(pre,c[i],mod) pre=c[i] ans%=mod elif c[i]==0: ans=0 break print(ans%mod) " p03107,s050628619,Wrong Answer,"s = input() # ans = 0 # while '01' in s or '10' in s: # # print('yes') # if '01' in s: # s = s.replace('01', '', 1) # ans += 2 # if '10' in s: # s = s.replace('10', '', 1) # ans += 2 # # print(s, ans) # # print(ans) ans = min(s.count('0'), s.count('1')) print(ans)" p02755,s836654428,Accepted,"A, B = list(map(int, input().split())) for x in range(1001): if (x * 8) // 100 == A and x // 10 == B: print(x) break else: print(-1) " p02989,s680000346,Accepted,"N = int(input()) D = list(map(int, input().split())) D.sort() print(D[N//2] - D[N//2-1])" p02705,s293086302,Accepted,"import math r = int(input()) print(2*r*math.pi)" p03705,s459685988,Accepted,"n, a, b = map(int, input().split()) if (n == 1 and a == b): ans = 1 elif (n == 1): ans = 0 elif a > b: ans = 0 else: ans = (b - a) * (n - 2) + 1 print(ans)" p03624,s750796075,Wrong Answer,"s = sorted(list(set(list(input())))) i = 0 while i < 25 and chr(i+97)==s[i]: i += 1 if i<=25: print(chr(i+97)) else: print(""None"")" p02888,s394962208,Accepted,"import bisect n = int(input()) l = list(map(int,input().split())) l.sort() #print(l) ans = 0 for i in range(n-1): a = l[i] for j in range(i+2,n): b = l[j] c = bisect.bisect_left(l,b-a+1) if j - c > 0: if i >= c: ans += j-i-1 else: ans += j-c #print(i,j,c,ans) print(ans) " p02946,s836575682,Accepted,"a, b = map(int, input().split()) ans=[int(x) for x in range(b-a+1,b+a)] print(*ans)" p03438,s029438297,Wrong Answer,"n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) t = sum(b)-sum(a) res=0 for i in range(n): res += (b[i]-a[i]+1)//2 if res > t: print('No') else: print('Yes')" p02700,s141093406,Accepted,"a, b, c, d = map(int, input().split()) while c > 0 and a > 0: c -= b a -= d print('Yes' if c <= 0 else 'No')" p03469,s953192850,Wrong Answer,"s = str(input()) strlist = list(s) strlist[3] = '8' s = str(strlist) print(s)" p03359,s272013804,Accepted,"a,b = map(int, input().split()) before = a - 1 now = 0 if a <= b: now = 1 print(before + now)" p02910,s957993059,Accepted,"for i,s in enumerate(input(),start=1): if i%2==0: if s=='R': print('No') exit(0) else: if s=='L': print('No') exit(0) print('Yes')" p02951,s808868042,Accepted,"A, B, C = map(int, input().split()) space = A - B print(max(0, C - space)) " p02663,s430977704,Wrong Answer,"FH, FM, TH, TM, K = map(int, input().split()) M = (TH-FH)*60+(TM-FM) ans = M // K-(1 if M%K == 0 else 0) print(ans*K) " p03633,s784240671,Accepted,"n=int(input()) lists=[] for i in range(n): a=int(input()) lists.append(a) #Nこの連続した数の最大公約数、最小公倍数を求めるアルゴリズム import math import fractions #最小公倍数 def union_lcm(lists): if len(lists)==1: return lists[0] elif len(lists)>1: num=lists[0] for i in range(1,len(lists)): num=num*lists[i]//fractions.gcd(num,lists[i]) return num P=union_lcm(lists) print(P)" p02697,s102153686,Accepted,"n,m=map(int,input().split()) for i in range(m): print(i+1,2*m-i+(n%2==0 and 2*(m-i)-1>=n//2))" p03286,s235315858,Wrong Answer,"n=int(input()) x="""" while n!=0: x=str(n%2)+x n=-(n//2) print(0 if n==0 else x)" p03705,s400079085,Accepted,"# Problem A - A+...+B Problem # input N, A, B = map(int, input().split()) # corner case if A>B: print(0) elif N==1 and A!=B: print(0) elif N==1 and A==B: print(1) else: ans = (N-2)*(B-A) + 1 print(ans) " p02731,s498414238,Accepted,"L = int(input()) ans = (L/3)**3 print(ans) " p03471,s004115273,Wrong Answer,"N,Y = map(int,input().split()) """""" a #10,000円 b #5,000円 c #1,000円 """""" ans = [] for a in range(N): for b in range(N): c = N - a - b if 10000*a + 5000*b + 1000*(N-a-b) == Y: print(a,b,N-a-b) exit() print(-1,-1,-1) " p02684,s656871488,Accepted,"n,k=map(int,input().split()) a=[0]+[int(j) for j in input().split()] l=[-1]*(n+1) ll=[] i=1 idx=0 while True: if l[i]==-1: l[i]=idx else: ll.append(i) break ll.append(i) i=a[i] idx+=1 p=ll[-1] nl=ll[l[p]:-1] ml=ll[:l[p]] n,m=len(nl),len(ml) if k 1: print("" "".join([str(s)] * k + [str(s - 1)] * (n - k))) else: print("" "".join([str(s)] * k + [str(s + 1)] * (n - k))) if __name__ == '__main__': main() " p02723,s674637743,Wrong Answer,"S = input() if(S[2] == S[3] and S[4] == S[5]): print('yes') else: print('no') " p02732,s773145758,Accepted,"N=int(input()) A=list(map(int,input().split())) B=[0]*(N+1) C=0 for i in A: B[i-1]+=1 for i in B: if i>=2: C+=i*(i-1)//2 for i in A: print(C-B[i-1]+1) " p02771,s229656560,Accepted,"a, b, c = map(int, open(0).read().split()) if a == b and b == c: print(""No"") elif a != b and b != c and c != a: print(""No"") else: print(""Yes"")" p02633,s499043971,Accepted,"def main(): import sys X=int(sys.stdin.readline()) i=1 while True: if 360*i%X==0: print(360*i//X) break i+=1 main()" p03210,s144800341,Wrong Answer,"x = int(input()) if x % 7 == 0 or x % 5 == 0 or x % 3 == 0: print('YES') else: print('NO')" p03861,s092961103,Accepted,"a, b, x = map(int, input().split()) m1 = a % x m2 = b % x if a == b: if a % x == 0: print(1) else: print(0) exit() if m1 != 0: a = (a//x)*x + x if m2 != 0: b = (b//x)*x print((b//x-a//x)+1)" p02582,s670811419,Accepted,"s=input() if ""RRR"" in s: print(""3"") elif ""RR"" in s: print(""2"") elif ""R"" in s: print(""1"") else: print(""0"") " p03475,s327031421,Accepted,"n=int(input()) a=[list(map(int,input().split())) for i in range(n-1)] def t(x,k): if a[k][1]<=x: return (x+a[k][2]-1)//a[k][2]*a[k][2]+a[k][0] return a[k][1]+a[k][0] for i in range(n-1): p=t(0,i) for j in range(i+1,n-1): p=t(p,j) print(p) print(0)" p03862,s446902981,Accepted,"N,x = map(int,input().split()) a = list(map(int,input().split())) cnt = 0 for i in range(N-1): if(a[i] > x): cnt += a[i] - x a[i] = x if(a[i] + a[i+1] > x): cnt += a[i] + a[i+1] - x a[i+1] = x - a[i] print(cnt)" p03721,s076048823,Accepted,"N,K = map(int,input().split()) num = [0]*(10**5+1) for i in range(N): a,b = map(int,input().split()) num[a] += b for i in range(1,10**5+1): if K <= num[i]: print(i) exit() K -= num[i] " p03448,s712012485,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)" p03380,s726368413,Accepted,"n = int(input()) a = list(map(int, input().split())) a.sort() large = max(a) a.remove(large) min_list = [0, large/2] for i in a: if abs(i - large/2) < min_list[1]: min_list = [i, abs(i - large/2)] print(large, min_list[0])" p03261,s379114794,Accepted,"n=int(input()) l = [] for _ in range(n): l.append(input()) if len(l)>len(set(l)): print(""No"") exit() i=0 while i H[i+1]: ans = ""No"" break print(ans)" p03797,s192522462,Accepted,"n,m = map(int,input().split()) ans = 0 if 2*n <= m: ans += n m -= 2*n if m >= 4: ans += m//4 else: ans += m//2 print(ans) " p02775,s699768556,Wrong Answer,"N=input() count=0 more_count=0 for n in N[::-1]: d=int(n) if d<=5: count+=d if more_count>=2: count-=more_count more_count=0 else: count+=(10-d)+1 more_count+=1 if more_count>=2: count-=more_count print(count)" p03331,s770942680,Wrong Answer,"n = input() mask = 10 ** (len(n)-1) n = int(n) if n //mask == 1: print(10) else: print(n//mask + n%10)" p03644,s032040639,Wrong Answer,"n=int(input()) a=0 for i in range(7): if 2**i > n: break print(2**(i-1))" p02629,s110891891,Accepted,"N=int(input()) alpha='abcdefghijklmnopqrstuvwxyz' ans='' while 26= K: print(answer+K*2) else: print(answer+(r_cnt//2+1)*2-1) " p03479,s607612017,Accepted,"x,y=map(int,input().split()) cnt=0 while x<=y: x=x*2 cnt+=1 print(cnt) " p02699,s255941205,Wrong Answer,"a,b = input().split() if a >= b: print(""safe"") else: print(""unsafe"")" p03494,s448482629,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)" p03695,s490577920,Accepted,"n = int(input()) a = list(map(int, input().split())) l = [False]*8 ov = 0 for i in range(n): if a[i] < 3200: l[a[i]//400] = True else: ov += 1 ans = l.count(True) print(max(ans, 1), ans + ov)" p03998,s055069145,Accepted,"A = list(input()) B = list(input()) C = list(input()) A.append(""#"") B.append(""#"") C.append(""#"") game = { ""A"" : A, ""B"" : B, ""C"" : C } turn = ""A"" finished = False while not finished: next_turn = game[turn].pop(0) if next_turn == ""#"": print(turn) finished = True else: turn = next_turn.upper() " p03860,s689726709,Accepted,"a,b,c = input().split() print(a[0]+b[0]+c[0])" p02796,s320563460,Accepted,"import sys input = sys.stdin.readline sys.setrecursionlimit(10000000) from collections import defaultdict from bisect import * mod = 10**9+7 N = int(input()) XL = [list(map(int, input().split())) for i in range(N)] A = [(X+L, X-L) for X, L in XL] A.sort() cnt, last = 0, A[0][0] for s, t in A[1:]: if t < last: cnt += 1 else: last = s print(N-cnt) " p03408,s299998011,Accepted,"n = int(input()) from collections import defaultdict s = defaultdict(int) for i in range(n): si = input() s[si] += 1 m = int(input()) for i in range(m): ti = input() s[ti] -= 1 print(max(0,max(s.values()))) " p04044,s204191904,Wrong Answer,"N,L = map(int,input().split()) L = sorted(input().split()) print(''.join(L))" p03767,s723685335,Wrong Answer,"N = int(input()) A = list(map(int,input().split())) A.sort() print(sum(A[N:2*N]))" p03001,s505811384,Accepted,"w,h,x,y=map(int,input().split()) if x==w/2 and y==h/2: print(w*h/2,1) else: print(w*h/2,0)" p03351,s904314355,Accepted,"a,b,c,d = map(int,input().split()) if abs(a - c) <= d or abs(b - a) <= d and abs(c - b) <= d: print(""Yes"") else: print(""No"")" p02603,s451369416,Accepted,"n = int(input()) a = list(map(int, input().split())) money = 1000 stock = 0 for i in range(n-1): if a[i+1] > a[i]: stock = money // a[i] money += (a[i+1] - a[i]) * stock print(money) " p03162,s904570133,Accepted,"n = int(input()) x = [list(map(int, input().split())) for i in range(n)] y = [[0 for j in i] for i in x] for i in range(len(x)): if i - 1 < 0: y[i] = [k for k in x[i]] continue for j in range(len(x[i])): x_1 = max([y[i - 1][k] for k in range(len(x[i - 1])) if k != j]) y[i][j] = x[i][j] + x_1 print(max(y[n - 1]))" p02953,s242106443,Accepted,"n = int(input()) hlst = list(map(int, input().split())) bef = 0 for h in hlst: if h < bef: print(""No"") break elif h == bef: bef = h else: bef = h - 1 else: print(""Yes"") " p02958,s595983464,Wrong Answer,"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"")" p02779,s314479247,Accepted,"n = int(input()) a = list(map(int, input().split())) p = set() for i in a: if i in p: print('NO') exit() p.add(i) print('YES')" p03210,s379719463,Accepted,"x = int(input()) if x == 5 or x == 3 or x == 7: print(""YES"") else: print(""NO"") " p03659,s482111270,Wrong Answer,"n = int(input()) a = list(map(int, input().split())) a.sort() b = 0 c = sum(a) ans = 10 ** 9 for i in range(n-1): b += a[i] c -= a[i] ans = min(ans, abs(b - c)) print(ans)" p03639,s063162573,Accepted,"n = int(input()) a=list(map(int,input().split())) cnt,cnt2,cnt4=0,0,0 for val in a: if val%4==0: cnt4+=1 elif val%2==0: cnt2+=1 else: cnt+=1 if cnt2==0: if cnt4>=cnt-1: print(""Yes"") else: print(""No"") else: if cnt4>=cnt: print(""Yes"") else: print(""No"")" p03555,s123451140,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') " p03778,s087541331,Accepted,"w, a, b = map(int, input().split()) if (a <= b <= a+w) or (a <= b+w <= a+w): print(0) elif (a < b) and (a+w < b): print(b - a - w) else: print(a - b - w)" p02684,s470118781,Accepted,"n, k = map(int, input().split()) A = list(map(int, input().split())) D = [1] seen = [0]*n seen[0] = 1 now = 0 while True: now = A[now] - 1 D.append(now+1) if seen[now]: break seen[now] = 1 f = D.index(D[-1]) if k < f: print(D[k]) else: cycle = len(D) - f - 1 k -= f print(D[f + k%(cycle)])" p02796,s434055058,Accepted,"n = int(input()) robots = [] for i in range(n): x,l = map(int, input().split()) robots.append((x+l, x-l)) INF = 1e10 last = -INF robots.sort() ans = 0 for (r, l) in robots: if l < last:continue ans += 1 last = r print(ans)" p02951,s512747964,Accepted,"A,B,C=map(int,input().split(' ')) rem=abs(A-B) print(abs(rem-C)) if rem i[1]: print(""No"") break else: print(""Yes"")" p02676,s947076302,Accepted,"k = int(input()) s = input() if(len(s) <= k): print(s) else: for i in range(k): print(s[i],end="""") print(""..."") " p03011,s115926603,Accepted," P, Q, R = map(int, input().split()) print(min(P+Q, Q+R, P+R)) " p03126,s795673616,Accepted,"n,m=map(int,input().split()) k=[] zisyo={} for i in range(n): k.append(list(map(int,input().split()))) for i in range(n): for j in range(1,k[i][0]+1): if str(k[i][j]) in zisyo: zisyo[str(k[i][j])]+=1 else: zisyo[str(k[i][j])]=1 count=0 for key,val in zisyo.items(): if val==n: count+=1 print(count)" p03162,s821455710,Accepted,"N = int(input()) x, y, z = 0, 0, 0 for _ in range(N): a, b, c = map(int, input().split()) x, y, z = max(y, z) + a, max(z, x) + b, max(x, y) + c print(max(x, y, z))" p02659,s655977761,Accepted,print(int((s:=input())[:-4])*int(s[-4]+s[-2:])//100) p02645,s900128251,Accepted,"s=input() print(s[0:3])" p02743,s466754146,Accepted,"a,b,c=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')" p02793,s219237264,Wrong Answer,"import sys from math import gcd import numpy as np from numba import jit read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines mod = 10 ** 9 + 7 N = int(readline()) A = list(map(int,readline().split())) @jit(cache=True) def lcm(N,a): x = a[0] for i in range(1, N): x = (x * a[i]) // gcd(x, a[i]) ans = 0 for i in range(N): ans += x // a[i] % mod return ans%mod A = np.array(A,np.int64) ans = lcm(N,A) print(ans)" p03220,s074934401,Accepted,"N=int(input()) T,A=map(int,input().split()) H=list(map(int,input().split())) h=abs(A-(T-(H[0]*0.006))) m=1 for i in range(1,N): if h>abs(A-(T-(H[i]*0.006))): h=abs(A-(T-(H[i]*0.006))) m=i+1 print(m)" p02732,s490493276,Accepted,"def MI():return map(int,input().split()) def LI():return list(MI()) from collections import Counter n=int(input()) a=LI() c=Counter(a) # print(c) M=0 for i,j in c.items(): M+=(j)*(j-1)//2 # print(M) for i in a: t=c[i] d=(t-1) print(M-d)" p03804,s147899317,Accepted,"n,m = map(int,input().split()) a = [list(input()) for i in range(n)] b = [list(input()) for i in range(m)] for i in range(n-m+1): for j in range(n-m+1): for k in range(m): if a[i+k][j:j+m] != b[k]: break else: print('Yes') exit() print('No')" p03556,s349571199,Accepted,"import sys input = lambda: sys.stdin.readline().rstrip() def resolve(): N = int(input()) print(int(N**0.5)**2) if __name__ == '__main__': resolve() " p03943,s845655824,Accepted,"a,b,c=map(int,input().split()) if a+b==c or a+c==b or a==b+c: print(""Yes"") else: print(""No"")" p02695,s015226252,Accepted,"from itertools import combinations_with_replacement n,m,q=map(int,input().split()) l=[list(map(int,input().split())) for _ in range(q)] A=list(combinations_with_replacement(range(1,m+1),n)) res=0 for i in range(len(A)): tmp=0 for j in range(len(l)): if A[i][l[j][1]-1]-A[i][l[j][0]-1]==l[j][2]: tmp+=l[j][3] res=max(res, tmp) print(res) " p02706,s265380135,Accepted,"N, M = input().split() N, M = [int(N), int(M)] a = list(map(int, input().split())) x = 0 for i in range(M): x += a[i] if x > N: print(-1) else: print(N - x)" p03469,s063592292,Accepted,"print(""2018""+input()[4:])" p04034,s018612763,Accepted,"n, m = map(int, input().split()) r = [False] * n r[0] = True l = [1] * n for _ in range(m): x, y = map(int, input().split()) l[x - 1] -= 1 l[y - 1] += 1 if r[x - 1]: r[y - 1] = True if l[x - 1] == 0: r[x - 1] = False c = 0 for i in range(n): if r[i] == True and l[i] > 0: c += 1 print(c) " p02697,s557551069,Accepted,"import sys,math,copy,queue,itertools,bisect,collections,heapq sys.setrecursionlimit(10**7) LI = lambda : [int(x) for x in sys.stdin.readline().split()] NI = lambda : int(sys.stdin.readline()) INF = 10**18 MOD = 10**9 + 7 DD = ((1,0),(-1,0),(0,1),(0,-1)) N,M = LI() p = [] i = 1 for j in range(M,0,-2): p.append([i,i+j]) i += 1 i = M+2 for j in range(M-1,0,-2): p.append([i,i+j]) i += 1 for ans in p: print (*ans)" p03000,s985761747,Accepted,"n,x = map(int,input().split()) ls = list(map(int, input().split())) d = 0 ans = 0 for l in ls: if d <= x: ans += 1 d += l if d <= x: ans += 1 print(ans)" p03416,s809331263,Accepted,"a,b=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) " p03625,s214325625,Wrong Answer,"n = int(input()) list1 = [int(x) for x in input().split()] list2 = list(reversed(sorted(list1))) m = list2[0] ans = [] for i in range(1, len(list2)): if list2[i] == m: ans.append(m) if len(ans) == 2: break m = list2[i] if len(ans) == 2: print(ans[0] * ans[1]) else: print(0) " p02731,s009691577,Wrong Answer,"import math l = int(input()) x = math.floor(l/3) if l%3 == 0: ans = x**3 elif l%3 == 1: ans = x*x*(x+1) else: ans = x*(x+1)*(x+1) print(str(ans))" p03160,s401620492,Accepted,"def solve(h): dp = [0, abs(h[0]-h[1])] for i in range(2, len(h)): one = dp[i-1] + abs(h[i-1]-h[i]) two = dp[i-2] + abs(h[i-2]-h[i]) dp.append(min(one, two)) return dp[-1] if __name__ == ""__main__"": n = int(input()) h = [int(x) for x in input().split()] print(solve(h))" p02768,s629227039,Accepted,"from sys import stdin, setrecursionlimit def cmb(n, r, mod=10 ** 9 + 7): r = min(r, n - r) x = y = 1 for i in range(r): x *= n - i x %= mod y *= i + 1 y %= mod return x * pow(y, mod - 2, mod) % mod def main(): input = stdin.buffer.readline n, a, b = map(int, input().split()) mod = 10 ** 9 + 7 print((pow(2, n, mod) - 1 - cmb(n, a, mod) - cmb(n, b, mod)) % mod) if __name__ == ""__main__"": setrecursionlimit(10000) main() " p02661,s934562832,Accepted,"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) from statistics import median if N%2 ==1: print(median(B)-median(A)+1) else: print(int((median(B)-median(A))*2+1))" p02796,s001587323,Accepted,"n=int(input()) lists=[] for i in range(n): x,y=map(int,input().split()) lists.append((x-y,x+y)) lists=sorted(lists,key=lambda x:(x[1])) A=1 P=lists[0] for i in range(1,len(lists)): if lists[i][0]>=P[1]: A+=1 P=lists[i] print(A)" p02600,s858188012,Accepted,"x=int(input()) y=x//200 print(10-y)" p02687,s270035209,Wrong Answer,"S = [""ABC"", ""ARC""] if S == S[0]: print(S[1]) else: print(S[0])" p03612,s360997909,Accepted,"N = input() p = [int(x)-1 for x in raw_input().split()] ans = 0 for i in range(N-1): if p[i]==i: p[i],p[i+1] = p[i+1],p[i] ans += 1 if p[-1]==N-1: ans += 1 print ans " p03041,s171339521,Accepted,"n,k=map(int,input().split()) s = list(input()) s[k-1] = s[k-1].lower() print("""".join(s)) " p03241,s983471654,Wrong Answer,"n,m=map(int,input().split()) yakusuu=[] import math for i in range(1,int(math.sqrt(m)+1)): if m%i==0: yakusuu.append(i) yakusuu.append(m//i) yakusuu.sort() for num in yakusuu: if num>=n: print(num) exit() " p02645,s345302078,Accepted,"S=str(input()) print(S[0:3])" p03407,s740539679,Accepted,"a,b,c = map(int, input().split()) if a+b < c: print('No') else: print('Yes')" p04044,s353229246,Accepted,"n, l = map(int, input().split()) s = [input() for _ in range(n)] s.sort() print(''.join(s)) " p02952,s329507362,Accepted,"S = int(input()) count = 0 for i in range(1, S+1): if len(str(i)) % 2 == 1: count += 1 print(count)" p02556,s960294912,Accepted,"n=int(input()) a=[] b=[] for _ in range(n): x,y=map(int,input().split()) a+=(x+y), b+=(x-y), c=max(a)-min(a) d=max(b)-min(b) ans=max(c,d,-c,-d) print(ans)" p02917,s323398642,Accepted,"n, *b = map(int, open(0).read().split()) a = [0]*n b.append(float(""inf"")) for i in range(n): a[i] = min(b[i-1], b[i]) print(sum(a))" p02657,s898998113,Accepted,"#!/usr/bin/env python3 # from typing import * import sys import math input = sys.stdin.readline sys.setrecursionlimit(10**6) def solve(A, B): print(A*B) def main(): A, B = map(int, input().split()) solve(A, B) if __name__ == '__main__': main() ''' cd ~/Desktop/Programming/AtCoder/contest/abc169/abc169_a && sh test_py.sh cd ~/Desktop/Programming/AtCoder/contest/abc169/abc169_a && sh etest_py.sh cd ~/Desktop/Programming/AtCoder/contest/abc169/abc169_a && sh submit_py.sh ''' " p02727,s513108729,Accepted,"X, Y , A, B, C = list(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[0:X] Q = q[0:Y] R = r[0:X+Y] S = P + Q + R S.sort(reverse = True) ans = sum(S[0:X+Y]) print(ans)" p03359,s354148185,Wrong Answer,"a, b = map(int, input().split()) print(""a"" if b>=a else ""b"")" p03951,s223375326,Accepted,"N = int(input()) s = input() t = input() for i in range(N): ok = 1 for j in range(N-i): if s[i+j] != t[j]: ok = 0 break if ok == 1: ans = N+i break if ok == 0: ans = 2*N print(ans) " p03657,s484320529,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,s236041499,Accepted,"s, c = map(int, input().split()) if s * 2 <= c: print((s*2+c)//4) else: print(c // 2)" p02602,s880377509,Accepted," def resolve(): N,K =map(int,input().split()) A = list(map(int,input().split())) for i in range(K,N): if A[i] > A[i-K]: print('Yes') else: print('No') resolve()" p02583,s827609653,Accepted,"# B - Making Triangle n = int(input()) l = list(map(int, input().split())) assert n == len(l) count = 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 a, b, c = sorted((l[i], l[j], l[k])) if a + b > c: count += 1 print(count) " p03106,s832719800,Accepted,"A,B,K = map(int,input().split()) ans = [] for i in range(1,min(A,B)+1): if A%i == 0 and B%i == 0: ans.append(i) ans.sort(reverse=True) print(ans[K-1]) " p03469,s470555836,Accepted,"s = input() print(s[:3] + ""8"" + s[4:])" p03293,s945649277,Accepted,"S = list(str(input())) T = list(str(input())) for i in range(len(S)): S.append(S[0]) del S[0] if S == T: print(""Yes"") exit() print(""No"") " p02576,s036537239,Accepted,"n, x, t = map(int, input().split()) total = int(n / x) * t total += t if (n % x) > 0 else 0 print(total) " p03219,s018027725,Accepted,"x,y = map(int,input().split()) print(x+y//2)" p02753,s219858497,Wrong Answer,"L=list(input()) print(""No"" if L.count(""A"")==0 else ""Yes"")" p03380,s101361922,Accepted,"# coding: utf-8 n=int(input()) A=list(map(int,input().split())) M=max(A) l=0 for i in range(n): if abs(M/2-A[i]) 0: Am[0][i] = A[0][i] + Am[0][i-1] # 2段目 for i in range(N): if i > 0: Am[1][i] = A[1][i] + max( Am[0][i] , Am[1][i - 1]) print(Am)" p03486,s676656527,Accepted,"s = input() t = input() ss = """".join(sorted(s)) ts = """".join(sorted(t,reverse=True)) if ss X: print(n) break" p03075,s591280296,Accepted,"a,b,c,d,e,f=[int(input()) for i in range(6)] print(""Yay!"" if abs(a-e)<=f else "":("")" p04045,s433810478,Wrong Answer,"n,k = map(int, input().split()) d = list(input().split()) for i in range(n,10000): for j in d: if j in str(i): break else: print (i) exit ()" p03059,s802851333,Accepted,"a, b, t = map(int, input().split()) if t < a: print(0) else: print(t // a * b) " p02602,s348586777,Wrong Answer,"import numpy as np N,K=map(int, input().split()) A=list(map(int, input().split())) x=np.prod(A[0:K]) y=np.prod(A[1:K+1]) for i in range(N-K): if i == 0: print('Yes' if x < y else 'No') else: x = x*A[K+i-1]/A[i-1] y = x*A[K+i]/A[i] print('Yes' if x < y else 'No')" p02831,s585201697,Wrong Answer,"import math a,b=map(int,input().split()) print(math.gcd(a, b))" p03013,s770241880,Accepted,"p=1000000007 n,m=map(int,input().split()) # 0段目 dp=[1] * (n +1) for i in range(m): a= int(input()) dp[a] = 0 for i in range(n-2,-1,-1): if dp[i] == 0: continue dp[i] = (dp[i+1] + dp[i+2]) %p print(dp[0]) " p03711,s721196133,Accepted,"x, y = map(int, input().split()) G = 'XACABABAABABA' print(""Yes"" if(G[x] == G[y]) else ""No"") " p03695,s424162292,Wrong Answer,"N=int(input()) A=list(map(int,input().split())) S=set() cnt=0 for i in A: if i>=3200: cnt+=1 else: S.add(i//400) low=len(S) high=cnt+low print(low,high)" p03071,s503249801,Wrong Answer,"a, b = list(map(int, input().split())) if a == b: my_result = a + b elif a > b: my_result = 2 * a + 1 else: my_result = 2 * b + 1 print(my_result)" p02548,s416361419,Wrong Answer,"def readInt(): return int(input()) def readList(): return list(map(int,input().split())) def readMap(): return map(int,input().split()) def readStr(): return input() inf=float('inf') mod = 10**9+7 import math from itertools import permutations def solve(N): count=0 for i in range(1,N): count+=(N-1)//i return count # N=readInt() # print(solve(N)) for i in range(1,101): print(solve(i))" p02765,s257827395,Wrong Answer,"N, R =(int(x) for x in input().split()) if N >= 10: print(R) else: print(R - 100 * (10 - N)) " p02583,s291433790,Accepted,"import itertools as it n=int(input()) a=sorted(map(int,input().split())) print(sum(sum(x)>2*x[2]and len(x)==len(set(x))for x in it.combinations(a, 3)))" p02823,s338643670,Accepted,"n, a, b = map(int, input().split()) if a % 2 == b % 2: print((b - a) // 2) else: if a > n - b + 1: rest = (b - a) // 2 print(n - a - rest) else: rest = (b - a) // 2 print(b - 1 - rest) #print(max(a, n - b + 1) - 1)" p03471,s243527559,Accepted,"n,y=map(int,input().split()) #1000円がn-a-b枚、5000円がa枚、10000万円がb枚とする for i in range(0,n+1): for j in range(0,n-i+1): if 1000*(n-i-j)+5000*i+10000*j==y: print(j,i,n-i-j) exit() print(-1,-1,-1)" p03000,s648231662,Accepted,"n,x=map(int,input().split()) L=list(map(int,input().split())) ans = 1 cnt = 0 for l in L: cnt += l if x >= cnt: ans += 1 print(ans)" p03407,s329224561,Wrong Answer,"a,b,c = map(int, input().split()) coins = [1,5,10,50,100,500] if a==1 or a==5 or a==10 or a==50 or a==100 or a==500: if b==1 or b==5 or b==10 or b==50 or b==100 or b==500: if a+b >= c: print(""Yes"") else: print(""No"") else: print(""No"") else: print(""No"")" p03387,s598147491,Accepted,"A,B,C=map(int, input().split()) m = max([A,B,C]) s = sum([m-A, m-B, m-C]) if s %2 == 0: print(s//2) else: s += 1 print(1+s//2)" p02694,s397695328,Accepted,"import math X = int(input()) m = 100 z=0 while X > m: m = m * 1.01 z = z + 1 m = math.floor(m) print(z)" p02657,s678653414,Accepted,"# 2101~2101 A,B=map(int,input().split()) print(A*B)" p03252,s508485385,Wrong Answer,"s = input() t = input() s2 = [] t2 = [] sdic = {} tdic = {} cnt = 0 for c in s: if c in sdic: s2.append(sdic[c]) else: s2.append(cnt) sdic[c] = cnt cnt += 1 cnt = 0 for c in t: if c in tdic: t2.append(tdic[c]) else: t2.append(cnt) tdic[c] = cnt cnt += 1 print(s2) print(t2) print(""Yes"" if s2 == t2 else ""No"") " p02909,s929032979,Accepted,"def resolve(): S = input() d = { ""Sunny"": ""Cloudy"", ""Cloudy"": ""Rainy"", ""Rainy"": ""Sunny"" } print(d[S]) if '__main__' == __name__: resolve()" p03745,s518233743,Accepted,"n = int(input()) a = list(map(int, input().split())) mode=""?"" cnt=0 last=a[0] for num in a: if mode==""a"": if last > num: cnt+=1 mode=""?"" elif mode==""d"": if last < num: cnt+=1 mode=""?"" else: if last > num: mode=""d"" if last < num: mode=""a"" last=num print(cnt+1)" p02600,s282576231,Wrong Answer,"x = int(input()) if 400 <= x < 600: 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)" p02665,s456742970,Accepted,"n=int(input()) A=list(map(int,input().split())) s=0 cap=[] flag=False for i,a in enumerate(A): s*=2 s+=a cap.append(min(2**i-s,(n+1-i)*10**8)) if s>2**i: flag=True break if flag: print(-1) else: remain=2**n-s ans=0 node=0 for i in range(n,-1,-1): a=A[i] c=cap[i] node=min(c,node)+a ans+=node print(ans) " p03485,s377019012,Wrong Answer,"a, b = (int(t) for t in input().split()) s = (a + b) % 2 x = (a + b) / 2 if s == 0: print(x) else: print(x + 0.5) " p02727,s067250108,Accepted,"X,Y,A,B,C=map(int,input().split()) p=sorted(map(int,input().split())) q=sorted(map(int,input().split())) r=sorted(map(int,input().split())) ans=[] ans+=p[A-X:] ans+=q[B-Y:] ans.sort() j=0 k=0 for i in ans: if len(r)>1: k=r[-1] elif len(r)==1: k=r[0] else: break if i=N: print(M//j) exit()" p02957,s064865235,Accepted,"A, B = map(int, input().split()) K = (B ** 2 - A ** 2) / (2 * A - 2 * B) print(int(abs(K))) if K.is_integer() else print('IMPOSSIBLE') " p03289,s308351495,Accepted,"import numpy as np def main(): test = input() if test[0] != ""A"": print(""WA"") return if test[:-1][2:].count(""C"") != 1: print(""WA"") return for i in range(len(test)): if i == 0 and test[i] == ""A"": continue if 2 <= i <= len(test) - 2 and test[i] == ""C"": continue if test[i].lower() != test[i]: print(""WA"") return print(""AC"") if __name__ == ""__main__"": main()" p02612,s207727581,Accepted,"str = input() int = int(str[-3:]) if(int == 0): print(0) else: print(1000-int)" p03624,s423148732,Accepted,"s = input() ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz' ans = 'None' for c in ascii_lowercase: if c not in s: ans = c break print(ans)" p02766,s115679889,Wrong Answer,"i= list(map(int, input().split())) j=1 while i[0]>i[1]**j: j+=1 print(j)" p02957,s307372559,Accepted,"a,b = map(int,input().split()) if (a + b) % 2 == 1: print('IMPOSSIBLE') exit() print((a+b) // 2)" p02694,s272432279,Accepted,"import math def resolve(): X = int(input()) ans = 100 year = 0 while ans < X: ans = math.floor(ans * 1.01) year += 1 print(year) resolve()" p03037,s313309034,Accepted,"n, m = map(int,input().split()) l_lis = [] r_lis = [] for _ in range(m): tmp = list(map(int,input().split())) l_lis.append(tmp[0]) r_lis.append(tmp[1]) ll = max(l_lis) rr = min(r_lis) count = rr - ll + 1 if count <= 0: print(0) else: print(count)" p03773,s168637608,Accepted,"a,b=map(int,input().split()) if a+b>=24: print(a+b-24) else: print(a+b)" p02623,s291851706,Wrong Answer,"import numpy as np from bisect import bisect_right n, m, k = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) a = np.cumsum(a) b = np.cumsum(b) ans = 0 for a_num, time in enumerate(a): if time > k: continue b_num = bisect_right(b, k - time) num = a_num + b_num + 1 if num > ans: ans = num print(ans) " p03131,s499839569,Accepted,"import sys K, A, B = map(int, sys.stdin.readline().split()) if K + 1 < A: print(K+1) else: if A + 2 < B: # print(""here"") n = K - (A - 1) r = n // 2 # print(n % 2) print(A + r * (B - A) + n % 2) else: print(K+1)" p02767,s993978325,Accepted,"N = int(input()) X = list(map(int, input().split())) print(min(sum((x - P) ** 2 for x in X) for P in range(max(X) + 1)))" p03796,s361291904,Accepted,"n = int(input()) ans = 1 for i in range(1, n+1): ans *= i ans %= 10**9+7 print(ans)" p03281,s809061633,Accepted,"n = int(input()) count = 0 for i in range(1,n+1): temp_count = 0 if i%2 == 0: continue for j in range(1,i+1): if i%j == 0: temp_count += 1 if temp_count == 8: count += 1 print(count) " p02796,s653930351,Accepted,"N, *XL = map(int, open(0).read().split()) A = sorted(((x + l, x - l) for x, l in zip(*[iter(XL)] * 2)), key=lambda x: x[0]) ans = 0 cur = -10 ** 9 for t, s in A: if cur <= s: cur = t ans += 1 print(ans)" p03095,s889102565,Wrong Answer,"from collections import Counter def solve(): N = int(input()) S = input() c = Counter(S) ans = 1 for v in c.values(): ans = ans*(v+1) return ans-1 print(solve())" p03723,s928979734,Accepted,"import sys input = sys.stdin.readline def main(): A, B, C = map(int, input().split()) if A == B == C and A % 2 == 0: print(-1) exit() ans = 0 while True: if (A % 2 == 1) or (B % 2 == 1) or (C % 2 == 1): break ans += 1 A, B, C = (B + C) // 2, (A + C) // 2, (A + B) // 2 print(ans) if __name__ == ""__main__"": main() " p03037,s098675673,Accepted,"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(right - left +1 , 0)) " p03612,s358746347,Wrong Answer,"N = int(input()) p = list(map(int, input().split())) answer = 0 streak = 0 for i in range(1, N): if i == p[i-1]: answer += 1 if i-1 == p[i-2]: answer -= 1 temp = p[i-1] p[i-1] = p[i-2] p[i-2] = temp print(answer) " p02661,s899247304,Accepted,"n=int(input()) al=list() bl=list() for i in range(n): a,b=map(int,input().split()) al.append(a) bl.append(b) al.sort() bl.sort() l=n//2 if n%2==0: print(bl[l-1]+bl[l]-al[l-1]-al[l]+1) else: print(bl[l]-al[l]+1)" p02832,s292252731,Accepted,"N=int(input()) a=list(map(int,input().split())) chk=1 for i in a: if i==chk: chk+=1 if chk==1: print(-1) else: print(len(a)-chk+1)" p02765,s305995263,Accepted,"from collections import defaultdict, deque import sys import heapq import bisect import math import itertools import string import queue import copy import time # import numpy as np from fractions import gcd sys.setrecursionlimit(10**8) INF = float('inf') mod = 10**9+7 eps = 10**-7 def inp(): return int(sys.stdin.readline()) def inp_list(): return list(map(int, sys.stdin.readline().split())) def lcm(x, y): return (x * y) // gcd(x, y) N, R = inp_list() I = 0 if N >= 10: I = R else: I = R + 100 * (10 - N) print(I) " p03799,s873825161,Accepted,"n,m=map(int,input().split()) if n==m//2: print(m//2) exit() if n>m//2: print(m//2) exit() ans=0 ans+=n m-=2*n ans+=m//4 print(ans) " p02552,s374401275,Accepted,"n = int(input()) if n == 0: print(1) else: print(0)" p02787,s327543795,Accepted,"from functools import lru_cache import sys H,N = [int(i) for i in input().rstrip().split(' ')] M = [[int(i) for i in input().rstrip().split(' ')] for _ in range(N)] sys.setrecursionlimit(10**9) DP = [0]*(H+1) for x in range(1,H+1): DP[x] = min(DP[max(x-a,0)] + b for a,b in M) print(DP[H])" p02713,s067010647,Wrong Answer,"import math from functools import reduce def gcd(*numbers): return reduce(math.gcd, numbers) def sumgcd(K): for a in range (len(la)): for b in range(len(lb)): for c in range(len(lc)): sum += gcd(la[a],lb[b],lc[c]) " p02958,s252965530,Wrong Answer,"from collections import deque N = int(input()) M = deque(map(int, input().split())) j = [] prev = M.popleft() for i in range(N-1): cor = M.popleft() if cor > prev: j.append(True) else: j.append(False) prev = cor if all(j) == True: print('YES') elif j[0] == j[-1] == False: print('YES') else: print('NO')" p03860,s717061758,Accepted,"#048-A a, b, c = input().split() print(a[0]+b[0]+c[0]) " p03043,s066471145,Wrong Answer,"import math n, k = list(map(int, input().split("" ""))) sum_v = 0 if n > k : j = k s = [0]*(k-1) else: j = n + 1 s = [0]*n for i in range(1, j): s[i-1] = math.ceil(math.log2(k/i)) sum_v += (1/2)**s[i-1] #print(i,s[i-1],sum_v) if n - k >= 0: p1 = (n-k+1)/n else: p1 = 0 p2 = sum_v/n print(p1 + p2)" p03556,s703720358,Accepted,"N = int(input()) while N**0.5 % 1: N -= 1 print(N)" p02923,s552736219,Wrong Answer,"n=int(input()) h=list(map(int,input().split())) cnt=0 for i in range(n-1): if h[i]>=h[i+1]: cnt+=1 else: cnt=0 print(cnt)" p02602,s188406833,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"")" p02663,s701355591,Accepted,"H,M,K,T,S = map(int,input().split()) print(max(((K*60+T-H*60-M-S)+1440)%1440,0))" p03624,s394130887,Accepted,"alfa = 'abcdefghijklmnopqrstuvwxyz' S = input() for i in range(len(alfa)): if alfa[i] not in S: print(alfa[i]) break else: print('None')" p03625,s603985972,Wrong Answer,"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 l, c in a: if c>=base: print(l*l) exit() elif count == 1: print(l*l1) exit() else: l1 = l count += 1 print(0) " p02773,s381799670,Accepted,"N=int(input()) S={} for n in range(N): s=input() S[s]=S.get(s,0)+1 maxS=max(S.values()) S=[k for k,v in S.items() if v==maxS] print('\n'.join(sorted(S))) " p03075,s089571650,Accepted,"a=int(input()) b=int(input()) c=int(input()) d=int(input()) e=int(input()) k=int(input()) if e-a>k: print(':(') else: print('Yay!')" p02773,s836191365,Accepted,"N=int(input()) List=[input() for i in range(N)] dict = {} for i in range(N): if List[i] in dict: dict[List[i]] += 1 else: dict[List[i]] = 1 dict_list = list(dict.items()) dict_list.sort(key=lambda x: x[1], reverse=True) max = dict_list[0][1] dict_list.sort(key=lambda x: x[0]) for id in dict_list: if max == id[1]: print(id[0]) " p02796,s927361606,Accepted,"n = int(input()) XL = [] for _ in range(n): x, l = map(int, input().split()) x_min = x - l x_max = x + l XL.append((x,l, x_min, x_max)) XL = sorted(XL, key=lambda x: x[3]) now = 0 count = 0 for i in range(1,n): if XL[now][3] > XL[i][2]: count += 1 else: now = i ans = n - count print(int(ans))" p02983,s488635803,Accepted,"a,b=map(int,input().split()) ans=[] i=0 while i<1000 and a+i<=b: ans.append((a+i)%2019) i+=1 ans.sort() minn=10**6 for i in range(len(ans)): for j in range(i+1,len(ans)): minn=min(minn,(ans[i]*ans[j])%2019) print(minn) " p02713,s529095720,Wrong Answer,"from math import gcd from numba import jit @jit def calc(): k=int(input()) ans=0 for a in range(1,k+1): for b in range(1,k+1): d=gcd(a,b) for c in range(1,k+1): ans+=gcd(d,c) print(ans) " p02790,s952012364,Accepted,"a, b = input().split() aa = a * int(b) bb = b * int(a) words = [aa, bb] words.sort() print(words[0]) " p03627,s680551048,Accepted,"n = int(input()) A = list(map(int, input().split())) d = dict() for a in A: d[a] = d.get(a, 0) + 1 x = [(l, n) for l, n in sorted(d.items(), reverse=True, key=lambda x:x[0]) if n >= 2] y = [(l, n) for l, n in sorted(d.items(), reverse=True, key=lambda x:x[0]) if n >= 4] if x == [] and y == []: print(0) else: ans = 0 if len(x) >= 2: ans = max(ans, x[0][0] * x[1][0]) if len(y) >= 1: ans = max(ans, y[0][0]**2) print(ans)" p02790,s572289818,Accepted,"import sys input = sys.stdin.readline ri = lambda: int(input()) rs = lambda: input().rstrip() ril = lambda: list(map(int, input().split())) rsl = lambda: input().rstrip().split() ris = lambda n: [ri() for _ in range(n)] rss = lambda n: [rs() for _ in range(n)] rils = lambda n: [ril() for _ in range(n)] rsls = lambda n: [rsl() for _ in range(n)] a, b = ril() x = str(a) * b y = str(b) * a print(min(x, y))" p03161,s815951285,Wrong Answer,"n,k=list(map(int, input().split())) stones=list(map(int, input().split())) infini=(10**4)*(10**5) dp = [infini for _ in range(n)] dp[0]=0 for pos in range(0, n-1): for m in range(1, k): if pos+k < n: dp[pos+k] = min(dp[pos+k], dp[pos] + abs(stones[pos] - stones[pos+k])) print(dp[-1]) " p02621,s790652012,Accepted,"a = int(input()) print(a + a**2 + a**3)" p03261,s340412788,Accepted,"def resolve(): N = int(input()) W = [input() for _ in range(N)] if len(set(W)) != N: print('No') return for i in range(N-1): if W[i][-1] != W[i+1][0]: print('No') return print('Yes') return resolve()" p02688,s994222436,Wrong Answer,"N, K = map(int, input().split()) A = [] a = [] for i in range(N): a.append(i + 1) for i in range(K): d = int(input()) A = [int(x) for x in input().split()] try: for j in range(d): a.remove(A[j]) except: pass d = """" A = [] print(len(a)) " p02594,s130942585,Wrong Answer,"if( int(input()) <= 30 ): print(""Yes"") else: print(""No"")" p03433,s867261765,Wrong Answer,"n,a=map(int,open(0));print('NYoe s'[n//500<=a::2])" p02664,s325062678,Accepted,"t = input() ans = 0 for x in t: print('P' if x == 'P' else 'D', end = '') print('')" p03043,s107444902,Accepted,"n,k=map(int,input().split()) ans=0 for i in range(1,n+1): now=int(i) cnt=int(0) while now v: a_cnt += v else: a_cnt += (v - k) total_cnt += a_cnt print(total_cnt)" p02923,s841213734,Accepted,"N = int(input()) H = list(map(int,input().split())) a = 0 b = 0 h = H[0] for i in range(1,N): if h >= H[i]: h = H[i] a +=1 else: b = (a if a > b else b) a = 0 h = H[i] b = (a if a > b else b) print(b)" p03282,s959901892,Accepted,"S=input() K=int(input()) for i in range(K): if S[i]!='1': break; print(S[i])" p03352,s434998898,Accepted,"x=int(input()) ans=1 for i in range(1,1000+1): for j in range(2,11): if i**j<=x: ans=max(ans,i**j) print(ans)" p03041,s612500486,Accepted,"n,k = list(map(int,input().split())) s = list(input()) s[k-1] = s[k-1].lower() print("""".join(s))" p02691,s748240978,Accepted,"import collections N = int(input()) A = list(map(int, input().split())) P = [i+A[i] for i in range(N)] Q = [j-A[j] for j in range(N)] Q_dict = collections.Counter(Q) cnt = 0 for i in range(N-1): Q_dict[Q[i]] -= 1 cnt += Q_dict[P[i]] print(cnt)" p03612,s097154586,Accepted,"n = int(input()) p = list(map(int,input().split())) ans = 0 skip = False for i in range(n): if skip: skip = False continue if i+1 == p[i]: ans += 1 skip = True print(ans) " p03673,s873524083,Accepted,"n = int(input()) a = list(map(int,input().split())) b1 = [] b2 = [] for i in range(n): if i%2==0:b1.append(a[i]) else:b2.append(a[i]) if n%2==0: b2.reverse() print(*b2+b1) else: b1.reverse() print(*b1+b2)" p02572,s540735699,Wrong Answer,"n = input() a = list(map(int, input().split())) s = 0 for i in a: for j in a: if i > j: s += i * j print(s % (10 ** 9 + 7)) " p02754,s140295111,Wrong Answer,"n,a,b = map(int,input().split()) if a+b>=n: print(a) elif a == 0: print(0) elif b == 0: print(n) else: c = n//(a+b) d = n%(a+b) if a>=d: print(c*a + d) else: print(c*a + a) " p02911,s711445263,Accepted,"n,k,q=list(map(int,input().split())) a=[] for i in range(q): a.append(int(input())) from collections import Counter ac_ans=Counter(a) for i in range(n): if (k-q)+ac_ans.get(i+1,0)>0: print(""Yes"") else: print(""No"") " p03799,s024602452,Accepted,"N, M = map(int,input().split()) ans = 0 if M - 2*N >= 0: M -= 2*N ans = N + M//4 else: ans = M//2 print(ans)" p03352,s284784834,Accepted,"x=int(input()) l=[] for i in range(1,x+1): for k in range(2,11): z = i**k if z <= x: l.append(z) print(max(l))" p02624,s930638925,Accepted,"n = int(input()) c = 0 for i in range(1,n+1): t = n//i c += i*t*(t+1)//2 print(c)" p03862,s233769971,Accepted,"n,x = list(map(int, input().split())) lst = [0]+list(map(int, input().split())) ans = 0 for i in range(n): if lst[i]+lst[i+1]>x: ans+=(lst[i]+lst[i+1]-x) lst[i+1]-=(lst[i]+lst[i+1]-x) print(ans) " p02768,s967911253,Wrong Answer,"n,a,b=map(int,input().split()) s=0 def kumi(x,y): k=1 for i in range(y): k=k*(x-i) return x def comb(x,y): return (kumi(x,y)//kumi(y,y)) for i in range(1,n+1): if i==a or i==b: s=s else: s=s+(comb(n,i)%(10**9+7)) print(s) " p03219,s767862704,Accepted,"x,y = map(int,input().split()) print(int(x+y/2))" p02711,s017161575,Accepted,"n=str(input()) n=list(n) count=0 for i in range(len(n)): if(n[i]==""7""): count+=1 if(count!=0): print(""Yes"") else: print(""No"")" p03672,s648194345,Accepted,"s=list(input()) while(True): s.pop() s.pop() tmp=len(s)//2 ans=0 for i in range(tmp): if s[i]==s[i+tmp]: ans+=1 if ans==tmp: print(tmp*2) break " p03607,s611464815,Accepted,"from collections import Counter n = int(input()) A = [int(input()) for _ in range(n)] cnt_A = Counter(A) ans = 0 for v in cnt_A.values(): if v % 2 == 1: ans += 1 print(ans)" p02888,s139363373,Accepted,"import bisect N = int(input()) L = list(map(int, input().split())) L.sort() cnt = 0 for i in range(N): for j in range(i + 1, N): cnt += bisect.bisect_left(L, L[i] + L[j]) - (j + 1) print(cnt)" p03037,s806518452,Accepted,"n,m=map(int,input().split()) r=[0]*m l=[0]*m for i in range(m): l[i],r[i]=map(int,input().split()) p=min(r)-max(l)+1 if p>0: print(p) else: print(0)" p03417,s704094855,Wrong Answer,"n,m=map(int,input().split()) if n==1 or m==1: print(n*m-2) exit() if n==2 or m==2: print(n*m) exit() print((m-2)*(n-2))" p02767,s823521925,Wrong Answer,"N = int(input()) X = list(map(int, input().split())) ans = 10000 P = 100 while P > 0: a = 0 for x in X: a += (x - P) ** 2 ans = min(ans, a) P -= 1 print(ans)" p02570,s661408561,Wrong Answer,"def dts(): return list(map(int,input().split())) d,t,s=dts() if d<=t*s: print(""yes"") else: print(""No"") " p02676,s803738454,Accepted,"k = int(input()) s = input() if len(s) <= k: print(s) else: print(s[:k] + ""..."") " p02624,s081622729,Accepted,"N = int(input()) ans = 0 for i in range(1, N+1): temp = N // i ans += i * temp * (temp + 1) // 2 print(ans)" p03338,s152395933,Accepted,"n=int(input()) s=input() ans=0 for i in range(n-1): l=[left for left in s[:i+1]] r=[right for right in s[i+1:]] st = set(l) & set(r) ans = max(len(st),ans) print(ans)" p03633,s267837566,Accepted,"import fractions def lcm(x, y): return (x * y) // fractions.gcd(x, y) n=int(input()) ans=0 ans=int(input()) if n==1: print(ans) exit() for i in range(n-1): t=int(input()) ans=lcm(ans,t) print(ans)" p02935,s945969585,Accepted,"n=int(input()) v=list(map(int,input().split())) v.sort() res=v[0]/(2**(n-1)) for i in range(1,n): res += v[i]/(2**(n-i)) print(res)" p02843,s019959088,Accepted,"x=int(input()) if x>=2000: print(1) else: if (x//100)*100<=x<=(x//100)*105: print(1) else: print(0)" p02778,s416557256,Accepted,"S = input() temp = 'x' * len(S) print(temp)" p03767,s372827348,Wrong Answer,"N = int(input()) a = list(map(int, input().split())) a.sort(reverse = True) ans = 0 if N ==1: print(a[1]) else: for n in range(N): ans += a[2*n-1] print(ans)" p02697,s329469040,Accepted,"# -*- coding: utf-8 -*- N,M = list(map(int, input().rstrip().split())) #----- ans = [] delta = 0 visited = set() for i in range(M): L = 1+i R = N-i diff = (R - delta) - L if (2*diff == N) or \ (diff in visited) or ((N - diff) in visited): delta = 1 ans.append( [L, R - delta] ) visited |= {diff , (N - diff)} for nums in ans: print(*nums) " p02583,s607425351,Wrong Answer,"n = int(input()) l = list(map(int,input().split())) count = 0 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] and l[j]!=l[k] and l[k]!=l[i]: count+=1 print(count)" p02959,s674834900,Accepted,"N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) sum_A = sum(A) for i in range(N): if B[i] > A[i]: B[i] -= A[i] A[i] = 0 A[i + 1] = max(0, A[i + 1] - B[i]) else: A[i] = max(0, A[i] - B[i]) ans = sum_A - sum(A) print(ans) " p03262,s331750889,Accepted,"from fractions import gcd from functools import reduce def gcd_list(numbers): return reduce(gcd, numbers) N, X=map(int, input().split()) x=list(map(int, input().split())) y=list() for i in x: y.append(abs(X-i)) #print(y) print(gcd_list(y)) " p03773,s915583695,Accepted,"a, b = map(int, input().split()) print((a+b)%24)" p02813,s124359594,Accepted,"import itertools N = int(input()) Q = tuple(map(lambda x: int(x)-1,input().split())) P = tuple(map(lambda x: int(x)-1,input().split())) a = 0 for _ in itertools.permutations(range(N)): if not(_ > Q) and not(_ < Q): break a += 1 b = 0 for _ in itertools.permutations(range(N)): if not(_ > P) and not(_ < P): break b += 1 print(abs(a-b))" p03799,s065382506,Accepted,"N,M = map(int, input().split()) # N : Sの数 # M : Cの数 if M <= 2*N: #Cの数が少ない print(M//2) else: cnt = N M -= 2*N print(cnt+M//4)" p03371,s862871461,Accepted,"import numpy as np def f(a, b, c, x, y): Min = np.inf for use_c in range(max(x, y) * 2 + 1): price = use_c * c + max(0, x - use_c // 2) * a + max(0, y - use_c // 2) * b if price < Min: Min = price print(Min) a, b, c, x, y = map(int, input().split()) f(a, b, c, x, y) " p03565,s132137392,Accepted,"def main(): s=input() t=input() ans=[] for i in range(len(s)-len(t)+1): for j in range(len(t)): if len(s) <= i+j or (s[i+j] != t[j] and s[i+j] != ""?""): break else: ans.append((s[:i]+t+s[i+j+1:]).replace(""?"", ""a"")) ans.sort() print(ans[0] if len(ans) > 0 else ""UNRESTORABLE"") if __name__ == ""__main__"": main()" p03126,s016359954,Accepted,"n, m = map(int, input().split()) k = [] for _ in range(n): a = list(map(int, input().split()))[1:] k.append(a) ans = 0 for i in range(m): flag = True for j in range(n): if i+1 not in k[j]: flag = False break if flag: ans += 1 print(ans) " p02953,s352295933,Wrong Answer,"n = int(input()) s = list(map(int, input().split())) mx, cnt = 0, 0 for i in s[::-1]: if i >= mx: mx = i cnt += 1 else: pass if cnt >= 2: break print(""Yes"") if cnt < 2 else print(""No"") " p03417,s034638366,Accepted,"N, M = map(int, input().split()) print(abs(N - 2) * abs(M - 2))" p02753,s337518112,Accepted,"S = input() if 'A' in S and 'B' in S: print('Yes') else: print('No') " p02987,s684176471,Accepted,"S = input() sorted_S = sorted(S) if len(set(S)) == 2 and sorted_S[0] != sorted_S[2]: print('Yes') else: print('No')" p02729,s054695846,Accepted,"n, m = map(int, input().split()) total = ((n + m) * (n + m -1)) / 2 odd = m * n #print(n, m) #print(total) #print(odd) print(int(total - odd))" p02789,s376478570,Wrong Answer,"a,b=map(int,input().split()) print(b**a if b>=a else a**b)" p03351,s036556154,Wrong Answer,"a,b,c,d = map(int, input().split()) if abs(a-b)<=d and abs(b-c)<=d: print('Yes') else: print('No')" p03254,s412992916,Accepted,"n, x = map(int, input().split()) lst = [0] + sorted(list(map(int, input().split()))) for i in range(n): lst[i + 1] += lst[i] for i in range(n): if lst[i] <= x < lst[i + 1]: print(i) exit() if x == lst[n]: print(n) else: print(n - 1)" p02630,s051842324,Accepted,"N = int(input()) A = list(map(int, input().split())) Q = int(input()) BC = [list(map(int, input().split())) for _ in range(Q)] indexA = {} for a in A: if a not in indexA: indexA[a] = 0 indexA[a] += 1 sumA = sum(A) for (b,c) in BC: if b in indexA: sumA += (c-b) * indexA[b] if c not in indexA: indexA[c] = 0 indexA[c] += indexA[b] indexA[b] = 0 print(sumA) " p02699,s343990139,Wrong Answer,"S,W = map(int,input().split()) if S/2 <= W: print('unsafe') else: print('safe')" p02720,s936826229,Wrong Answer,"def main(): k = int(input()) hp = [i for i in range(k+4)] r, w = 1, 10 while w < k: n = hp[r] r += 1 nm = n % 10 val = n * 10 + nm if nm != 0: hp[w] = val - 1 w += 1 hp[w] = val w += 1 if nm != 9: hp[w] = val + 1 w += 1 print(hp[k]) main() " p02953,s636958744,Accepted,"n = int(input()) h = list(map(int, input().split())) last=h[0]-1 for now in h[1:]: if last > now: print(""No"") exit() elif last == now: # don't last = now else: # do last = now-1 print(""Yes"")" p03639,s471917888,Accepted,"n = int(input()) A = list(map(int, input().split())) num_4 = 0 num_2 = 0 for a in A: if a%4 == 0: num_4 += 1 elif a%2 == 0: num_2 += 1 else: continue flag = False if num_4 >= n//2: flag = True else: num = num_2 - num_2%2 if num_4 >= (n - num)//2: flag = True if flag: print(""Yes"") else: print(""No"")" p02552,s732990779,Accepted,"#!/usr/bin/env python3 # coding:utf-8 def main(): stdIn = int(input()) stdOut = solve(stdIn) print(stdOut) """""" 方針 """""" def solve(stdIn): if stdIn == 0: return 1 return 0 if __name__ == ""__main__"": main() " p03543,s915204819,Wrong Answer,"n = input() if n[0] == n[1] == n[2] == n[3]: print('Yes') else: print('No') " p03544,s672870062,Accepted,"n = int(input()) prev = 2 now = 1 for i in range(1, n): temp = now now += prev prev = temp print(now)" p02708,s686457083,Accepted,"N, K = map(int, input().split()) MOD = 10 ** 9 + 7 ans = 0 for i in range(K, N + 2): ans += (N + N - i + 3) * i // 2 - i * (i + 1) // 2 + 1 ans %= MOD print(ans) " p02766,s347439700,Accepted,"N, K = (int(x) for x in input().split()) ans=0 while(N>=1): N = int(N/K) ans+=1 print(ans)" p02765,s306461037,Wrong Answer,"N = 2 R = 2919 if N<=10: R = R + (100*(10-N))" p02775,s651572604,Accepted,"n = input() a = int(n[-1]) b = 10 - int(n[-1]) for i in range(len(n)-2,-1,-1): a,b = min(a+int(n[i]), b + int(n[i]) + 1), min(a + 10-int(n[i]), b + 9 -int(n[i])) print(min(a,b+1))" p03605,s921743680,Wrong Answer,"n = str(input()) cnt = 0 for i in n: if n == ""9"": cnt += 1 if cnt >= 1: print(""Yes"") else: print(""No"")" p03524,s370024722,Accepted,"s = input() a, b, c = s.count('a'), s.count('b'), s.count('c') cnt = max(abs(a - b), abs(b - c), abs(c - a)) print('YES' if cnt <= 1 else 'NO') " p02718,s587627857,Wrong Answer,"n,m = list(map(int,input().split())) A = list(map(int,input().split())) sum = sum(A) MM = 4*m A.sort(reverse=True) for i in range(m): if A[i] < sum // MM: print('No') exit() print('Yes') " p02621,s958448912,Accepted,"a = int(input()) def main(): a_2 = a*a a_3 = a*a*a print(int(a+a_2+a_3)) main()" p02842,s312537847,Accepted,"n=int(input()) ans="":("" for i in range(1,n+1): if int(i*1.08)==n: ans=i print(ans) " p02613,s394237274,Accepted,"n =int(input()) list=[] for i in range(n): s = input() list.append(s) print('AC x '+str(list.count('AC'))) print('WA x '+str(list.count('WA'))) print('TLE x '+str(list.count('TLE'))) print('RE x '+str(list.count('RE')))" p03030,s011057375,Wrong Answer,"n = int(input()) d = {} for _ in range(n): s, p = input().split() if s not in d.keys(): d[s] = [p] else: d[s].append(p) c = 1 for i in sorted(d): for j in sorted(d[i], reverse=True): d[i][d[i].index(j)] = c c += 1 for k in d: for l in d[k]: print(l) " p02924,s385758481,Accepted,"N = int(input()) print(sum(range(N)))" p02641,s941605569,Accepted,"XN = [int(x) for x in input().split()] p = [int(x) for x in input().split()] tmp=100 tmp_i=0 for i in range(102): if not i in p: if abs(XN[0]-i)1: dp[i] = min(dp[i-1]+abs(l[i]-l[i-1]),dp[i-2]+abs(l[i]-l[i-2])) if i==1: dp[i] = abs(l[i]-l[i-1]) if i<1: dp[i] = 0 # print(dp) return dp[-2] l = list(map(int,input().split())) print(bupdp(l,h)) " p02873,s316889533,Accepted,"S = input() S = S.replace('><','>,<').split(',') ans = 0 for s in S: small = s.count('<') big = s.count('>') tmp = max(small,big)\ + (max(small,big)-1)*max(small,big)//2\ + (min(small,big)-1)*min(small,big)//2 ans += tmp print(ans)" p02946,s936676233,Accepted,"K, X = map(int, input().split()) left = X-K+1 right = X+K for i in range(left, right): print(i, end="" "")" p02718,s632466999,Wrong Answer,"def main(): n, m = map(int, input().split()) a = [int(x) for x in input().split()] threshold = sum(a) / (4 * m) if sum(1 for i in a if i >= threshold): print(""Yes"") else: print(""No"") if __name__ == ""__main__"": main() " p02963,s627478274,Accepted,"s = int(input()) y2 = -(-s//10**9) y1 = 10**9*y2-s print(0,0,10**9,y1,1,y2)" p02848,s733041562,Accepted,"n = int(input()) s = input() for i in s: print(chr((ord(i)-ord('A')+n)%26+ord('A')),end="""")" p03380,s350005639,Accepted,"n=int(input()) a=list(map(int,input().split())) a.sort() num1=a[-1] num2=a[-1]/2 num3=a[-1] ans=-1 for i in range(n-1): if abs(a[i]-num2) time + K) or bus==C: ans += 1 time = T bus = 1 else: bus += 1 print(ans)" p03971,s057034803,Accepted,"n,a,b=map(int,input().split()) s=input() all=a+b inter=b for i in range(n): if all==0: print('No') elif s[i]=='a': print('Yes') all-=1 elif s[i]=='b' and inter>0: print('Yes') all-=1 inter-=1 else: print('No')" p02959,s467403159,Accepted,"n=int(input()) A=list(map(int,input().split())) B=list(map(int,input().split())) s=0 for i in range(n): if A[i]>B[i]: s+=B[i] elif A[i]<=B[i] and B[i]<=A[i+1]+A[i]: s+=B[i] A[i+1]=A[i+1]+A[i]-B[i] elif B[i]>A[i+1]+A[i]: s+=A[i]+A[i+1] A[i+1]=0 print(s)" p02879,s576199035,Wrong Answer,"def kuku(a,b): if a<=9 and b<=9: return a*b return -1" p03721,s933580348,Accepted,"n,k=map(int,input().split()) count=0 ba=[0]*(10**5+1) for i in range(n): a,b=map(int,input().split()) ba[a]+=b for i in range(len(ba)): k-=ba[i] if k<=0: print(i) break" p02613,s976783226,Wrong Answer,"N = int(input()) C0 = 0 C1 = 0 C2 = 0 C3 = 0 for i in range(0,N): S = str(input()) if S == 'AC': C0 += 1 elif S == 'WA': C1 += 1 elif S == 'TLE': C2 += 1 elif S == 'RE': C3 += 1 print('AC ×',C0) print('WA ×',C1) print('TLE ×',C2) print('RE ×',C3)" p02630,s354814645,Wrong Answer,"def main(): n = int(input()) a = list(map(int,input().split())) q = int(input()) for _ in range(q): b, c = map(int, input().split()) sum=0 for i in range(0,n): if(a[i]==b): a[i]=c sum+=a[i] print(sum) main()" p03545,s326226418,Accepted,"def dfs(i,s,sum): if i == 3: if sum == 7: print(s+""=7"") exit() else: dfs(i+1, s + ""+"" + S[i+1], sum + int(S[i+1])) dfs(i+1, s + ""-"" + S[i+1], sum - int(S[i+1])) S = str(input()) dfs(0,S[0],int(S[0]))" p02552,s063352588,Accepted,"x = int(input()) if x == 1: print(0) else: print(1)" p03778,s855845271,Wrong Answer,"w,a,b = map(int,input().split()) c = b - a if c - w >= 0: print(c - w) else: print(0)" p03681,s877926589,Accepted,"import math n, m = map(int, input().split()) div = 10**9 + 7 if abs(n-m)>1: print(0) exit() elif n == m: ans1 = math.factorial(n) ans2 = math.factorial(m) ans = 2 * ans1 * ans2 else: ans1 = math.factorial(n) ans2 = math.factorial(m) ans = ans2*ans1 print(ans % div)" p03680,s453484507,Accepted,"def main(): N = int(input()) a = [int(input()) for _ in range(N)] tmp = 0 for i in range(N): if a[tmp] == 2: print(i+1) exit() else: tmp = a[tmp]-1 print(-1) if __name__ == ""__main__"": main() " p03524,s193012830,Accepted,"from collections import Counter S = input() d = Counter(S) na = 0 if ""a"" not in d.keys() else d[""a""] nb = 0 if ""b"" not in d.keys() else d[""b""] nc = 0 if ""c"" not in d.keys() else d[""c""] if abs(na - nb) <= 1 and abs(nc - na) <= 1 and abs(nb - nc) <= 1: print(""YES"") else: print(""NO"")" p02959,s462755271,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 b[i] <= a[i]: ans += b[i] elif b[i] < a[i] + a[i+1]: a[i+1] = a[i] - b[i] ans += b[i] else: ans += a[i] + a[i+1] a[i+1] = 0 print(ans)" p03607,s901467222,Accepted,"import collections N = int(input()) A = collections.Counter([int(input()) for _ in range(N)]) A = A.values() ans = [x for x in A if x&1] print(len(ans))" p02773,s119024389,Accepted,"N = int(input()) D = {} for _ in range(N): s = input() if s in D: D[s] += 1 else: D[s] = 1 m = max(D.values()) for k, v in sorted(D.items()): if v==m: print(k)" p03075,s456491616,Accepted,"A = [] for i in range(5): A.append(int(input())) K = int(input()) print(':(' if A[4]-A[0] > K else 'Yay!')" p03860,s111326795,Accepted,"a = input().split() print(a[0][0] + a[1][0] + a[2][0])" p02547,s010563244,Accepted,"N = int(input()) D = [list(map(int, input().split())) for _ in range(N)] for i, j, k in zip(range(N), range(1, N), range(2, N)): if D[i][0] == D[i][1] and D[j][0] == D[j][1] and D[k][0] == D[k][1]: print('Yes') exit() print('No') " p02973,s560428923,Accepted,"import bisect def main(): INF = 10 ** 10 N = int(input()) A = [int(input()) for _ in range(N)] A.reverse() B = [INF for _ in range(N)] for a in A: index = bisect.bisect_right(B, a) B[index] = a ans = 0 for b in B: if b == INF: break ans += 1 print(ans) if __name__ == '__main__': main()" p02664,s017895648,Wrong Answer,"t = list(input()) n = len(t) for i in range(n): if(t[i] == ""?"" ): if(t[i-1] == ""P""): t[i] = ""D"" elif(t[i-1] == ""D""): t[i] = ""D"" t1 = """".join(t) print(t1) " p02820,s735046583,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 point = 0 point += np.sum(t[:k]) for i in range(k+1,n): if t[i] == t[i-k]: pass elif t[i] != t[i-k]: point += t[i] print(point)" p03699,s252165715,Accepted,"n = int(input()) ls = [int(input()) for _ in range(n)] ls.sort() ans = sum(ls) if ans % 10 != 0: print(ans) else: for i in range(n): if ls[i] % 10 != 0: print(ans - ls[i]) break elif i == n - 1: print(0)" p02836,s678341210,Accepted,"s = input() n = len(s) print(len([i for i in range(n // 2) if s[i] != s[n - 1 - i]]))" p03379,s567027470,Accepted,"n = int(input()) X = tuple(map(int, input().split())) Xs = sorted(X) ml = Xs[n//2-1] mr = Xs[n//2] for i in range(n): if X[i] <= ml: print(mr) else: print(ml) " p03360,s871709697,Wrong Answer,"a,b,c = map(int, input().split()) k = int(input()) if max(a,b,c)==a: print(a*2*k+b+c) elif max(a,b,c)==b: print(b*2*k+a+c) else: print(c*2*k+b+a)" p02706,s237213218,Accepted,"n,m = map(int, input().split()) a_list = list(map(int, input().split())) cost_days = sum(a_list) play_days = n - cost_days if play_days < 0: print(-1) else: print(play_days)" p03637,s639509265,Accepted,"n=int(input()) l=map(int,input().split()) x,y,z=0,0,0 for a in l: if a%4==0: z+=1 elif a%2==0: y+=1 else: x+=1 if y>0: x+=1 print('Yes'if x<=z+1 else'No') " p02989,s837555281,Accepted,"n = int(input()) d = list(map(int, input().split())) d.sort() print(d[n//2]-d[n//2-1])" p03017,s500703102,Accepted,"n, a, b, c, d = map(int, input().split()) s = input() for i in range(a, max(c, d)): if s[i-1: i+1] == ""##"": print(""No"") exit() if c < d: print(""Yes"") exit() for i in range(b-1, d): if s[i-1:i+2] == ""..."": print(""Yes"") exit() print(""No"") " p02583,s270570120,Accepted,"n = int(input()) l = list(sorted(map(int, input().split()))) x = 0 for k in range(n - 2): for j in range(k + 1): for i in range(j + 1): if l[i] < l[j + 1] < l[k + 2] and l[i] + l[j + 1] > l[k + 2]: x += 1 print(x)" p02717,s846957683,Wrong Answer,"x, y, z = map(int, input().split()) print(""z"", ""x"", ""y"")" p02995,s464563741,Accepted,"import fractions a,b,c,d=map(int,input().split()) count=0 def cc(a,b,c): if a%c==0: k=a else: k=a+c-(a%c) return ((b//c)-(k//c)+1) print(b-a+1-cc(a,b,c)-cc(a,b,d)+cc(a,b,(c*d)//fractions.gcd(c,d)))" p04019,s769636631,Accepted,"s = set(input()) if {""N"",""S""} == s or {""W"",""E""} == s or {""N"",""S"",""W"",""E""} == s: print(""Yes"") else: print(""No"") " p02661,s458519057,Accepted,"N = int(input()) AB = [list(map(int,input().split())) for _ in range(N)] A = [] B = [] for i in range(N): A.append(AB[i][0]) B.append(AB[i][1]) A.sort() B.sort() if N % 2 == 0: n = N // 2 med1 = A[n-1] + A[n] med2 = B[n-1] + B[n] x = med2 - med1 + 1 else: n = N // 2 med1 = A[n] med2 = B[n] x = med2 - med1 + 1 print(x) " p03324,s884579445,Accepted,"D,N=map(int, input().split()) print((N+int(N/100))*100**D)" p02859,s778464181,Wrong Answer,"import math x=math.pi r=int(input()) print(int((r*r*x)/x)) " p03699,s276922823,Accepted,"N=int(input()) S=list(int(input()) for _ in range(N)) S=sorted(S) ans=0 if sum(S)%10!=0: ans=sum(S) else: for i in range(N): if (sum(S)-S[i])%10!=0: ans=sum(S)-S[i] break print(ans)" p03250,s798045101,Accepted,"a, b, c = map(int, input().split()) print(max(a * 10 + b + c, a + b * 10 + c, a + c * 10 + b)) " p03605,s104208095,Accepted,"N=input() if (""9"" in N): print (""Yes"") else: print (""No"")" p03239,s405080613,Wrong Answer,"N, L =map(int, input().split()) cost = 1000 count = 0 for i in range(N): c, t =map(int, input().split()) if t <= L: if c < cost: cost = c count += 1 elif t > L: continue; if count == 0: print(""TLE"") else: print(cost)" p03455,s625301303,Accepted,"a,b=map(int, input().split()) if a*b%2==0: print(""Even"") else: print(""Odd"") " p03449,s922784296,Wrong Answer,"N = int(input()) A = [list(map(int, input().split())) for _ in range(2)] result = A[0][0] + A[1][N - 1] s0 = sum(A[0][1:]) s1 = sum(A[1][:-1]) for j in range(1, N): if s0 <= s1: result += s1 break result += A[0][j] s0 -= A[0][j] s1 -= A[1][j - 1] print(result)" p02731,s622999734,Wrong Answer,"n = int(input()) print((n/3)*3)" p02747,s154711942,Accepted,"s = input() if s == ""hi"" or s == ""hihi"" or s == ""hihihi"" or s == ""hihihihi"" or s == ""hihihihihi"" : print(""Yes"") else: print(""No"")" p03075,s802360814,Accepted,"coordinate_lst = [] for _ in range(5): coordinate_lst.append(int(input())) k = int(input()) coordinate_lst.sort() max_distance = coordinate_lst[-1] - coordinate_lst[0] if max_distance <= k: print('Yay!') else: print(':(') " p02916,s223394636,Accepted,"N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) sum1 = sum(B) cn = 0 SUM = 0 for i in range(N-1): if A[i] + 1 == A[i+1]: SUM = SUM + C[A[i]-1] print(sum1 + SUM)" p02917,s281378799,Wrong Answer,"#52 1日かかった N = int(input()) b = list(map(int,input().split())) a = [min(b) for i in range(N)] for i in range(N-1): while b[i] > max(a[i],a[i+1]): a[i+1] += 1 while b[i] < max(a[i],a[i+1]): a[i] -= 1 if i <= N-3: if b[i] == b[i+1]: a[i+2] = a[i+1] = a[i] print(sum(a))" p02832,s672094734,Wrong Answer,"n = int(input()) a = list(map(int, input().split())) ans = 0 if 1 not in a: ans = -1 else: for i in range(1,n+1): if i not in a: break else: rn = a.index(i) ans+= rn del a[:rn+1] print(ans)" p03137,s015056242,Accepted,"n,m=map(int,input().split()) X=sorted(map(int,input().split())) L=sorted([X[i+1]-X[i] for i in range(m-1)]) if n>=m: print(0) else: print(sum(L)-sum([L[-i-1] for i in range(n-1)]))" p02572,s128469427,Accepted,"import sys input = lambda : sys.stdin.readline().rstrip() M = (10**9)+7 n = int(input()) As = map(int, input().split("" "")) cumsum = [] cur = 0 out = 0 for i in range(n-1): cur += As[i] out += cur*As[i+1] out = out % M print(out)" p03852,s309105602,Accepted,"s = input() if s==""a"" or s==""o"" or s==""u"" or s==""e"" or s==""i"": print(""vowel"") else: print(""consonant"")" p03962,s393937943,Accepted,"l = list(input().split()) d = {} for i in l: if i in d: d[i] +=1 else: d.setdefault(i,1) print(len(d))" p03329,s138868246,Accepted,"coin = [1, 6,6**2,6**3,6**4,6**5,6**6, 9,9**2,9**3,9**4,9**5] n = int(input()) inf = 10**9 dp = [inf]*(n+1) dp[0] = 0 for c in coin: for yen in range(c, n+1): dp[yen] = min(dp[yen], dp[yen-c] + 1) print(dp[n]) " p02640,s339606416,Accepted,"x, y = map(int, input().split()) for a in range(101): for b in range(101): if a+b==x and 2*a+4*b==y: print(""Yes"") exit() else: print(""No"") " p02916,s915690815,Accepted,"from sys import stdin n = int(input()) a = list(map(int, stdin.readline().split())) b = list(map(int, stdin.readline().split())) c = list(map(int, stdin.readline().split())) ans = sum(b) for i in range (n-1): if a[i]+1 == a[i+1]: t = a[i]-1 ans +=c[t] print(ans) " p03086,s565627548,Wrong Answer,"S=input() res=0 for st in [S[x:y] for x in range(len(S)) for y in range(len(S)) if x<=y]: for c in st: if not c in ('A','C','G','T'): break else: if res0: a = max(H-hcnt, W-wcnt) N -= a cnt+=1 if a==W: H-=1 hcnt+=1 elif a==H: W-=1 wcnt+=1 print(cnt)" p03274,s334696356,Accepted,"n, k = map(int, input().split()) x = list(map(int, input().split())) k -= 1 ans = 10**9 for i in range(n - k): l = x[i] r = x[i + k] if l < 0: if r < 0: ref = -l else: ref = min(l*-2 + r, -l + r*2) else: ref = r ans = min(ans, ref) print(ans)" p02900,s196963678,Wrong Answer,"A, B = map(int, input().split()) def prime_numbers(N): n = N res = [] for i in range(2, n): if i * i >= N: break if N % i != 0: continue while N % i == 0: N //= i res.append(i) res.append(N) return res a = prime_numbers(A) b = prime_numbers(B) ans = min(len(a), len(b)) + 1 print(ans) " p02577,s973135387,Wrong Answer,"N = int(input()) if N // 9 == 0: print(""Yes"") else: print(""No"")" p03387,s967751187,Accepted,"a = list(map(int, input().split())) a.sort() cnt = 0 while max(a)-min(a)>1: a[0] += 2 a.sort() cnt += 1 if a[0]==a[1]==a[2]: print(cnt) elif a[0]==a[1]: print(cnt+1) else: print(cnt+2)" p02744,s224853777,Accepted,"n = int(input()) ans = ['' for _ in range(n)] def dfs(i, mx): if i == n: print(''.join(ans)) return for j in range(mx+1): ans[i] = chr(ord('a') + j) dfs(i+1, max(j+1, mx)) dfs(0, 0)" p04043,s383805448,Accepted,"a = list(map(int,input().split())) if (a.count(5) == 2) and (a.count(7) == 1): print(""YES"") else: print(""NO"")" p02811,s093033748,Accepted,"s=list(map(int,input().split())) a=s[0]*500 if s[1]<=a: print('Yes') else: print('No')" p02700,s306517549,Accepted,"from itertools import count a, b, c, d = map(int, input().split()) for i in count(): if i % 2 == 0: c -= b if c <= 0: print('Yes') break else: a -= d if a <= 0: print('No') break " p04012,s828493867,Wrong Answer,"import collections s = input() lst = [] for i in s: lst.append(i) c = collections.Counter(lst) if sum(c.values()) % 2 == 0: print('YES') else: print('NO')" p02785,s408445023,Accepted,"from math import ceil n, k = map(int, input().split()) h_array = sorted([int(x) for x in input().split()]) if k >= n: print(0) exit() print(sum(h_array[:n-k])) " p02993,s644102620,Accepted,"s=input() if s[0]==s[1] or s[1]==s[2] or s[2]==s[3]: print(""Bad"") else: print(""Good"")" p02933,s625301023,Accepted,"print(""red"" if int(input())<3200 else input())" p03565,s979911899,Wrong Answer,"s = str(input().replace('\n', '')) t = str(input().replace('\n', '')) s, t = s[::-1], t[::-1] tt = len(t)-1 ss = '?'*tt + t[-1] flag = True ans = '' for i in s: ans += i if ss in ans and flag: flag=False ans = ans.replace(ss, t) print(ans.replace('?', 'a')[::-1] if flag==False else 'UNRESTORABLE') " p03544,s838154472,Accepted,"import sys from collections import Counter readline = sys.stdin.buffer.readline MOD = 10**9+7 def main(): N = int(readline()) L = [0]*(N+1) L[0]=2 L[1]=1 for i in range(2,N+1): L[i] = L[i-1] + L[i-2] print(L[N]) if __name__ == '__main__': main()" p03773,s322819069,Accepted,"a,b=map(int,input().split()) print(a+b if a+b < 24 else a+b-24)" p02597,s991461780,Wrong Answer,"# Nとcの定義 N = int(input()) C = input() # 赤色の個数 red_num = str.count(C, ""R"") # 左からred_num個までに含まれる白色の個数 white_num_left = str.count(C[:red_num], ""W"") # 最小の操作回数 min_ope = white_num_left # 最小の操作回数の出力 print(""最小の操作回数: "" + str(min_ope))" p02725,s074685357,Accepted,"import sys a=sys.stdin.buffer.read K,N,*A=map(int,a().split()) A+=[A[0]+K] print(K-max(y-x for x,y in zip(A,A[1:])))" p03639,s664339347,Accepted,"N = int(input()) A = list(map(int,input().split())) odd = 0 even = 0 eveneven = 0 for a in A: if a % 4 == 0: eveneven += 1 elif a % 2 == 0: even += 1 else: odd += 1 if even == 0: #間に挟み込む if eveneven +1 >= odd: print('Yes') else: print('No') else: #2を後ろに固める if odd <= eveneven: print('Yes') else: print('No') " p02647,s550632826,Accepted,"n,k,*l=map(int,open(0).read().split()) for _ in range(min(k,41)): 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)" p02732,s316390546,Accepted,"N=int(input()) A=list(map(int,input().split())) num_A = [0]*(N+1) for a in A: num_A[a]+=1 s=0 for n in num_A: s+=n*(n-1)//2 #print(s) for a in A: ans = s - (num_A[a]*(num_A[a]-1)//2) + ((num_A[a]-1)*(num_A[a]-2)//2) print(ans) " p02791,s478322420,Accepted,"n, a = input(), map(int, raw_input().split()) mi = n + 1 ans = 0 for i, x in enumerate(a): if mi > x: ans += 1 mi = min(mi, x) print ans " p02546,s807223626,Accepted,"s=input() if s[-1]=='s': print(s+'es') else: print(s+'s')" p03035,s687097906,Wrong Answer,"age, price = map(int, input().split()) price = price if age >= 13 else price / 2 if 6 <= age <= 12 else 0 print(price)" p02712,s112602150,Wrong Answer,"a = input() count = 0 for i in range(int(a)): if i % 3 == 0 and i % 5 == 0: #print('FizzBuzz') count += 0 elif i % 3 == 0: #print('Fizz') count += 0 elif i % 5 == 0: #print('Buzz') count += 0 else: count += i #print(i) print(count)" p02661,s937354924,Accepted,"N=int(input()) A=[0]*N B=[0]*N x,y=0,0 for i in range(N): x,y=map(int,input().split()) A[i]=x B[i]=y A.sort() B.sort() if N&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)" p03773,s983387755,Wrong Answer,"a,b=map(int,input().split()) print((a+b-1)%24 +1)" p04030,s031852063,Accepted,"s='' for i in input(): if i=='B': if s!='': s=s[:-1] else: s+=i #print(s) print(s)" p02880,s899810633,Accepted,"N = int(input()) ans = ""No"" for i in range(9): if (N % (i+1) == 0) & ( N / (i+1) <= 9): ans = ""Yes"" break print(ans)" p03416,s997555628,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)" p02897,s274149939,Accepted,"n = int(input()) c = 0 for i in range(1, n + 1): if i%2 != 0: c+=1 print(c/n)" p03329,s376455109,Accepted," n = int(input()) dp = [10**9]*(n+1) L = [6**i for i in range(1,7)] L += [9**i for i in range(1,6)] dp[0] = 0 for i in range(1,n+1): dp[i] = dp[i-1]+1 k = 6 while i-k >=0: dp[i] = min(dp[i],dp[i-k]+1) k *=6 k = 9 while i-k >=0: dp[i] = min(dp[i],dp[i-k]+1) k *=9 #print(dp) print(dp[n]) " p02842,s888906155,Accepted,"N = int(input()) t = int(N / 1.08) while True: if int(t*1.08) == N: print(t) break if int(t*1.08) > N: print("":("") break t += 1" p02717,s411649835,Accepted,"a, b, c = list(map(int, input().split())) print(c,a,b) " p02597,s697195239,Accepted,"n = int(input()) c = input() c = list(c) r = 0 w = 0 for i in range(n): if c[i] == 'R': r += 1 else: w += 1 ans = min(r,w) t = 0 v = 0 for i in range(ans): if c[i] == 'R': t -= 1 for i in range(ans): if c[n-i-1] == 'W': v -= 1 if r <= w: ans = ans + t else: ans = ans + v print(ans)" p03495,s931627152,Wrong Answer,"n, k = map(int, input().split()) al = list(map(int, input().split())) cnt = [0]*9 for i in range(1,10): cnt[i-1] = al.count(i) cnt.sort() cnt = cnt[cnt.count(0):] print(sum(cnt[:-k])) " p02882,s577749393,Accepted,"from math import atan,degrees a,b,x = map(int,input().split()) if x >= a**2*b/2: # けっっこうおおめ print(degrees(atan(2*(a**2*b-x)/a**3) )) elif x < a**2*b/2: # すっくねえ print(degrees(atan(b**2*a/(2*x)))) " p03761,s162907307,Wrong Answer,"n = int(input()) List = [] List2 = [] for i in range(n): List.append(input()) S1 = sorted(List[0]) for j in range(1,n): for k in range(len(S1)): if List[j].count(S1[k]) == 0: List2.append(S1[k]) List2 = (List2) List2 = set(List2) List2 = list(List2) for k in range(len(List2)): S1.remove(List2[k]) Answer = """".join(map(str,S1)) print(Answer) " p02796,s474065795,Accepted,"N = int(input()) ans = 0 a = - (1 << 100) X = [] for _ in range(N): x, l = map(int, input().split()) X.append((x, l)) X = sorted(X) for x, l in X: if a > x - l: a = min(a, x + l) else: a = x + l ans += 1 print(ans)" p02687,s594422349,Accepted,"S = input() if S == 'ABC': print('ARC') else: print('ABC') " p02765,s245466425,Wrong Answer,"n, k = map(int, input().split()) def calc(n, k): i = 1 tmp = n while (tmp > k): tmp = tmp - k**i i += 1 return i print(str(calc(n,k)))" p03994,s903697476,Accepted,"s = input() k = int(input()) ans = """" l = 26 for i in range(len(s)-1): if l - ord(s[i]) + 97 <= k and s[i] != ""a"": k -= l - ord(s[i]) + 97 ans += ""a"" else: ans += s[i] ans += (chr(((ord(s[-1]) - 97) + k + l) % l + 97)) print(ans)" p03607,s839955604,Wrong Answer,"N = int(input()) A = [] for _ in range(N): A.append(int(input())) if N == 1: print(1) exit() A.sort() current_number = A[0] current_count = 1 count = 0 for i in range(1,N): if current_number == A[i]: current_count += 1 else: current_number = A[i] if current_count % 2 != 0: count += 1 current_count = 0 print(count)" p03544,s939019357,Accepted,"L = [2, 1] for i in range(85): L.append(L[-1] + L[-2]) print(L[int(input())])" p02952,s779948363,Wrong Answer,"n=int(input()) cnt = 0 for i in range(1,n+1): if len(str(n))%2 == 1: cnt+=1 print(cnt)" p02916,s543145800,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()] ans=sum(b) pre=0 for i in range(n): tabeta=a[i] if tabeta==pre+1: ans+=c[pre-1] pre=tabeta print(ans)" p03681,s957995343,Accepted,"import sys sys.setrecursionlimit(10**7) mo=10**9+7 def fact(x): if x==0: return 1 else: return x*fact(x-1)%mo n,m=map(int,input().split()) if abs(n-m)>1: print(0) elif m==n: print((2*fact(m)*fact(n))%mo) else: print((fact(m)*fact(n))%mo) " p03211,s759179559,Accepted,"stng = input() mindif = 9999999999 for i in range(len(stng)-2): mindif = min(mindif,abs(int(stng[i:i+3])-753)) print(mindif)" p02676,s590183775,Wrong Answer,"k = int(input()) s = input() print(s if len(s)0: ss=ss.replace('?','a') ans.append(ss) else: pass else: break if ans!=[]: print(min(ans)) else: print('UNRESTORABLE')" p02642,s173758627,Wrong Answer,"N = int(input()) a = [int(x) for x in input().split()] from collections import defaultdict d = defaultdict(int) ans = 0 for i in range(N): d[a[i]] += 1 for i in range(1,1001): if d[i] == 1: ans += 1 for j in range(2,2+10**6//i): d[j*i] = 0 elif d[i] >= 2: for j in range(2,2+10**6//i): d[j*i] = 0 for i in range(1001,1000001): if d[i] >= 1: ans += 1 print(ans)" p02618,s644434053,Wrong Answer,"import sys input = lambda: sys.stdin.readline().rstrip(""\r\n"") import random D = int(input()) c = [int(x) for x in input().split()] s = [] for _ in range(D): s.append([int(x) for x in input().split()]) t = [random.randint(1, 26) for x in range(D)] last = [0]*26 ans = 0 for i in range(1, D + 1): ans += s[i - 1][t[i - 1] - 1] last[t[i - 1] - 1] = i for j in range(26): ans -= c[j]*(i - last[j]) print(ans) " p03345,s066147828,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 a,b,c,k = map(int,input().split()) if k%2 == 0: print(a-b) elif k%2 == 1: print(b-a) elif abs(a-b)>10**18: print(""Unfair"")" p02995,s315604057,Accepted,"from fractions import gcd a,b,c,d = map(int, input().split()) ci = b//c - (a-1)//c di = b//d - (a-1)//d e = c * d // gcd(c, d) cdi = b//e - (a-1)//e print(b-(a-1)-(ci+di-cdi))" p02727,s351820642,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() P_new = P[-X::] Q_new = Q[-Y::] agg = P_new + Q_new +R agg.sort() print(sum(agg[-X-Y::]))" p03773,s627902663,Wrong Answer,"a,b=map(int, input().split());print((a+b)//24)" p02743,s662693977,Accepted,"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"")" p02996,s259561999,Accepted,"def main(): from operator import itemgetter import sys sys.setrecursionlimit(10**9) input = sys.stdin.readline N = int(input()) AB = [tuple(map(int, input().split())) for _ in range(N)] AB.sort(key=itemgetter(1)) now = 0 for a, b in AB: if now + a <= b: now += a else: print(""No"") return print(""Yes"") main()" p03474,s498681630,Wrong Answer,"a,b = map(int, raw_input().split()) s = raw_input() def f(s): for l in s: if l not in map(str, range(10)): return False return True print 'Yes' if s[a] == '-' and f(s[a+1:]) else 'No'" p02628,s668690811,Accepted,"N,K=map(int,input().split()) p=list(map(int,input().split())) print(sum(sorted(p)[:K]))" p02743,s566576899,Accepted,"a,b,c=map(int,input().split()) x=a**2 + b**2 + c**2 - 2*a*b - 2*a*c - 2*b*c if x>0 and a+b-c<0: print(""Yes"") else: print(""No"")" p02660,s029246345,Wrong Answer,"N = int(input()) ans = 0 for i in range(2, int(N**0.5 + 1)): f = 1 while True: if N % i**f: f -= 1 break f += 1 N //= i**f ans += f print(ans) " p03352,s456049673,Accepted,"import math X=int(input()) ans=0 if X==1: print(1) else: for i in range(1,X//2): for j in range(2,11): tmp=i**j if tmp<=X: ans=max(ans,tmp) print(ans)" p03815,s523838929,Wrong Answer,"x = int(input()) if x % 11 <= 6: print((x // 11) * 2 + 1) else: print((x // 11) * 2 + 2) " p03150,s994900905,Accepted,"def main(): s = input() good = 'keyence' for start in range(len(s)): for end in range(len(s)): if s.replace(s[start:end],'',1) == good: print('YES') exit() print('NO') if __name__ == '__main__': main() " p03239,s086585376,Wrong Answer,"n,T = list(map(int,input().split())) ans = 10000 for i in range(n): c,t = map(int,input().split()) if(t<=T): ans=min(ans,c) else: None print(ans)" p02848,s546137058,Wrong Answer,"n=int(input()) s=list(input()) for i in s: ord_= ord(""A"") t_ord = (ord_ +n) % 26 i = chr(t_ord) print(''.join(s))" p03557,s406053305,Wrong Answer,"import bisect N = int(input()) A = list(map(int, input().split())) A.sort() B = list(map(int, input().split())) C = list(map(int, input().split())) C.sort() ans = 0 for b in B: top = bisect.bisect_right(A, b) bottom = N - bisect.bisect_left(C, b) ans += top * bottom print(ans)" p02647,s717710536,Accepted,"#pypy N, K = list(map(int, input().split())) A = list(map(int, input().split())) #累積和 for _ in range(K): 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] B,A = A,B if min(A) == N: break print(*A) " p02627,s014023976,Accepted,"a = input() if a.islower(): print('a') else: print('A')" p03711,s673283511,Accepted,"x, y = map(int, input().split()) grp1 = [1,3,5,7,8,10,12] grp2 = [4,6,9,11] grp3 = [2] if x in grp1 and y in grp1: print('Yes') elif x in grp2 and y in grp2: print('Yes') elif x in grp3 and y in grp3: print('Yes') else: print('No')" p03163,s276973849,Accepted,"N, W = map(int, input().split()) dp = [[0]*(W+1) for _ in range(N+1)] for i in range(N): w, v = map(int, input().split()) for j in range(1, W+1): if j 0: ans = chr(ord('a') + (N-1) % 26) + ans N = (N -1) // 26 print(ans) " p02797,s060189305,Accepted,"N, K, S = map(int, input().split()) X = [S] * K if S != 10 ** 9: Y = [10 ** 9] * (N - K) else: Y = [S - 1] * (N - K) Z = X+Y print(*Z, sep="" "") " p02983,s469206540,Accepted,"L,R=map(int,input().split()) mod=2019 ans=2018 if R-L>=mod: print(0) else: R%=mod L%=mod if R<=L: R+=mod for i in range(L+1,R+1): for j in range(L,i): ans=min(ans,i*j%mod) print(ans)" p02819,s653449803,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) break" p03433,s373525813,Accepted,"N=input() A=input() N=int(N) A=int(A) if N%500<=A: print('Yes') else: print('No')" p03524,s071491633,Wrong Answer,"from sys import stdin from itertools import groupby s = list(stdin.readline().rstrip()) s.sort() li = [] for key, value in groupby(s): li.append(len(list(value))) if len(li) == 1: li += [0]*2 elif len(li) == 2: li += [0] if sum(abs(li[i+1]-li[i]) for i in range(len(li)-1)) <= 2: print(""YES"") else: print(""NO"")" p02882,s721153406,Accepted,"from math import atan def find_angle(width, height, vol): area = vol/width if area > 1/2 * width * height: return atan(2*(width * height - area)/(width**2)) else: return atan(height**2/(2*area)) a, b, x = [int(i) for i in input().split()] print(find_angle(a, b, x) / (2*3.1415926535) * 360) " p02742,s752160586,Accepted,"h, w = map(int, input().split()) if w == 1 or h == 1: print(1) else: print(((h + 1) // 2) * ((w + 1) // 2) + (h // 2) * (w // 2))" p03804,s782367191,Wrong Answer,"n, m = map(int, input().split()) a = [ list(input()) for _ in range(n) ] b = [ list(input()) for _ in range(m) ] is_ok = False for dx in range(n-m): for dy in range(n-m): f = True for y in range(m): for x in range(m): if a[y+dy][x+dx] != b[y][x]: f = False is_ok = f print(""Yes"" if is_ok else ""No"")" p03971,s998601651,Accepted,"N,A,B=map(int, input().split()) S=input() cntA=0 cntB=0 for s in S: if s == 'c': print('No') continue if s == 'a' and (cntA+cntB) < A+B: print('Yes') cntA +=1 elif (s == 'b') and ((cntA+cntB) < A+B) and (cntB < B): print('Yes') cntB +=1 else: print('No') " p03324,s174268225,Accepted,"d,n = map(int, input().split()) if n == 100: n = 101 print((100**d)*n)" p02924,s027407179,Accepted,"N = int(input()) print((N - 1) * N // 2) " p03645,s302737587,Wrong Answer,"from collections import deque n,m=map(int,input().split()) tree=[[] for i in range(n)] for i in range(m): a,b=map(int,input().split()) a-=1 b-=1 tree[a].append(b) tree[b].append(a) dist=[-1 for i in range(n)] dist[0]=0 dq=deque() dq.append(0) while dq: x=dq.popleft() if x==n-1: if dist[x]==2: print('POSSIBLE') else: print('IMPOSSIBLE') exit() for i in tree[x]: if dist[i]==-1: dist[i]=dist[x]+1 dq.append(i)" p03037,s562942691,Wrong Answer,"n, m = map(int, input().split()) left, right = 1, n for _ in range(m): l, r = map(int, input().split()) if l > left: left = l if r < right: right = r if l > r: print(0) quit() print(right - left + 1)" p02847,s733210518,Wrong Answer,"s=input() if s==""SAT"": print(1) 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==""FRY"": print(2)" p03665,s376318369,Wrong Answer,"nCr = {} def cmb(n, r): if r == 0 or r == n: return 1 if r == 1: return n if (n,r) in nCr: return nCr[(n,r)] nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1) return nCr[(n,r)] n,p = map(int,input().split()) a = list(map(lambda x:int(x)%2,input().split())) cnt0 = a.count(0) cnt1 = n-cnt0 ans = 2**cnt0 temp=0 for i in range(p,cnt1+1,2): temp += cmb(n,i) print(ans*temp)" p02712,s166172356,Accepted,"N = int(input().strip()) s = 0 for i in range(1,N+1): if i%3 and i%5: s+=i print(s)" p02879,s567086369,Accepted,"# coding: utf-8 def main(): operand_a, operand_b = map(int, input().split(' ')) if operand_a < 10 and operand_b < 10: print(operand_a * operand_b) else: print(-1) return 0 if __name__ == '__main__': main() " p02582,s185505711,Wrong Answer,"S = input() max = 0 i = 0 m = 0 while(i != len(S)): if S[i] == ""R"": m += 1 else: max = m m = 0 break i += 1 print(max)" p02595,s429622367,Accepted,"#B N, D = map(int, input().split()) P= [list(map(int, input().split())) for i in range(N)] x=[] y=[] for i in P: x.append(i[0]) y.append(i[1]) d=[] for i, j in zip(x, y): dist =(i**2 + j**2)**(1/2) if dist <= D: d.append(dist) print(len(d)) " p02615,s085087064,Accepted,"import numpy as np N = int(input()) A = np.array(list(map(int, input().split()))) A = np.sort(A)[::-1] div, mod = divmod(N, 2) print(2 * np.sum(A[:div]) + (A[div] if mod==1 else 0) - A[0])" p02946,s973696979,Wrong Answer,"k,x=map(int,input().split()) s=[0]*((2*(k-1))+1) for i in range((2*(k-1))+1): s[i]=x-(k-1)+i print(s)" p03386,s595589715,Accepted,"a, b, k = map(int, input().split()) if b-a>=2*k: for i in range(a, a+k): print(i) for j in range(b-k+1, b+1): print(j) else: for n in range(a, b+1): print(n) " p03543,s298371736,Accepted,"s = input() cnt = 1 maxcnt=1 for i in range(1,4): if s[i] == s[i-1]: cnt += 1 else: maxcnt = max(maxcnt,cnt) cnt = 1 maxcnt = max(maxcnt,cnt) if maxcnt>=3: print(""Yes"") else: print(""No"")" p03435,s588895060,Wrong Answer,"c = [] for _ in range(3): tmp = list(map(int, input().split())) c.extend(tmp) # c.append(tmp) # print('c', c) if sum(c) % 3: print('No') else: print('Yes') " p02993,s139866620,Accepted,"s=input() for i in range(3): if (s[i]==s[i+1]): print(""Bad"") exit() print(""Good"") " p03799,s784419181,Accepted,"N, M = map(int, input().split()) if M//2 < N: print(M//2) elif M//2 == N: print(N) else: print((N+(M-N*2)//4))" p03625,s522719217,Accepted,"import collections N = int(input()) A = [int(x) for x in input().split()] A.sort(reverse=True) B = [] i = 0 while i < N-1: if A[i]==A[i+1]: B.append(A[i]) i += 2 else: i += 1 if len(B)<2: print(0) else: print(B[0] * B[1])" p02642,s564109843,Accepted,"N = int(input()) A = list(map(int, input().split())) A.sort() B = [0] * (10**6+1) ans = 0 for a in A: if B[a] == 0: ans += 1 B[a] = 2 tmp = 2*a while tmp <= 10**6: B[tmp] = 1 tmp += a elif B[a] == 2: B[a] = 1 ans -= 1 print(ans)" p03017,s595776137,Wrong Answer,"n, a, b, c, d = map(int, input().split()) s = input() a = a-1 b = b-1 c = c-1 d = d-1 for i in range(a+1, d): if s[i-1] == '#' and s[i] == '#': print('No') exit() if c < d: print('Yes') exit() for i in range(b+1, d+1): if s[i-1] == '.' and s[i] == '.' and s[i+1] == '.': print('Yes') exit() print('No') " p03013,s049597502,Accepted,"n, m = map(int, input().split()) ok = [1] * n for i in range(m): x = int(input()) ok[x-1] = 0 mod = 1000000007 dp = [0] * (n+2) dp[1] = 1 for i in range(n): dp[i+2] = (dp[i+1] + dp[i])%mod if ok[i] else 0 print(dp[n+1])" p03352,s481018916,Accepted,"X = int(input()) print(max([pow(b, p) for b in range(1, 1001) for p in range(2, 11) if pow(b, p) <= X])) " p04033,s180562353,Accepted,"import sys def input(): return sys.stdin.readline()[:-1] def main(): a, b = map(int,input().split()) if a > 0 and b > 0: print(""Positive"") elif a*b <= 0: print(""Zero"") else: if (b-a)%2 == 1: print(""Positive"") else: print(""Negative"") if __name__ == '__main__': main() " p03408,s342022515,Accepted,"n=int(input()) S=[] T=[] data=set() for i in range(n): s=input() S.append(s) data.add(s) m=int(input()) for i in range(m): t=input() T.append(t) data.add(t) ans=0 for i in data: ans=max(ans,S.count(i)-T.count(i)) print(ans)" p02819,s216620089,Accepted,"x = int(input()) def prime(n): ans = ""yes"" for i in range(2,round(n**0.5)+1): if n%i == 0: ans = ""no"" break else: continue if ans == ""yes"": return n else: return prime(n+1) if x == 2 or x == 3: print(x) else: print(prime(x)) " p02723,s981230840,Accepted,"from sys import exit, setrecursionlimit setrecursionlimit(10**6) def array2D(row, col ,val=0): return [[val]*col for i in range(row)] s = input() print('Yes' if s[2]==s[3] and s[4] == s[5] else 'No')" p03387,s544734235,Accepted,"import math A,B,C=map(int,input().split()) s=[A,B,C] t=sorted(s) u=(t[2]-t[0],t[2]-t[1],0) if u[0]%2==0 and u[1]%2==0: print(round(((u[0]+u[1])/2))) elif u[0]%2==1 and u[1]%2==1: print(round((1+u[0]//2+u[1]//2))) elif u[0]%2==1 and u[1]%2==0: print(round(((u[0]+1)/2+u[1]/2+1))) else: print(round(((u[1]+1)/2+u[0]/2+1))) " p02793,s890205124,Wrong Answer,"import fractions import sys input = sys.stdin.readline N = int(input()) A = list(map(int, input().split())) def modinv(a, mod=10**9+7): return pow(a, mod-2, mod) mod = 10**9+7 lcm = 1 for i in range(N): lcm = (lcm*A[i]) * modinv(fractions.gcd(lcm, A[i])) ans = 0 for i in range(N): ans += (lcm // A[i]) % mod ans %= mod print(ans) " p03862,s101107651,Accepted,"N, x = map(int, input().split()) a = list(map(int, input().split())) ans = 0 for i in range(N-1): if a[i]+a[i+1] > x: if -a[i]+x > 0: ans += a[i+1]+a[i]-x a[i+1] = x-a[i] else: ans += a[i+1] a[i+1] = 0 ans += a[i]-x a[i] -= a[i]-x # print(i) # print(a) # print(ans) print(ans)" p03665,s909768398,Wrong Answer,"n, p = map(int, input().split()) a = list(map(int, input().split())) length = len(a) even = len([i for i in a if i % 2 == 0]) odd = len([i for i in a if i % 2 == 1]) if length == even and p == 1 or length == odd and p == 0 and odd % 2 == 1: print(0) elif length == even: print(2 ** n) else: print(2 ** n // 2)" p02548,s581034263,Accepted,"N=int(input()) a=0 for i in range(1,N): a+=(N-1)//i print(a) " p03672,s948601701,Accepted,"s = input() s = s[:-1] while len(s) % 2 != 0 or s[:len(s)//2] != s[len(s)//2:]: s = s[:-1] print(len(s))" p03778,s664129652,Accepted,"w,a,b=map(int,input().split()) print(max(abs(a-b)-w,0))" p03617,s944007823,Accepted,"q, h, s, d = map(int, input().split()); n = int(input()) h = min(q*2, h); s = min(h*2, s); d = min(s*2, d); x = 0 x += n//2*d; n %= 2; x += n//1*s print(x)" p03438,s584755104,Accepted,"N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) operation = sum(B) - sum(A) cntp = 0 cntn = 0 for a, b in zip(A, B): c = b - a if c > 0: cntp += c if c % 2 != 0: operation -= 1 elif c < 0: cntn += -c if operation >= cntn: print('Yes') else: print('No')" p03075,s945964784,Accepted,"a, b, c, d, e, k = list(int(input()) for _ in range(6)) print(':(' if (e - a) > k else 'Yay!')" p03387,s560471403,Accepted,"A = list(map(int, input().split())) A = sorted(A) if (A[2]-A[0]-(A[2]-A[1]))%2==0: ans = A[2]-A[1]+(A[2]-A[0]-(A[2]-A[1]))//2 else: ans = A[2]-A[1]+(A[2]-A[0]-(A[2]-A[1]))//2+2 print(ans)" p02642,s026751013,Wrong Answer,"import numpy as np n = int(input()) a = list(map(int,input().split())) a.sort() na = np.array(a) #for i in na: cnt = 0 while cnt < len(a): #na = na[na % i != 0] tmp = na[0] na = na[na % a[cnt] != 0] #print(na) na = np.append(na, tmp) #print(na) cnt +=1 ans = len(set(na)) if ans == 1: print(0) exit() print(ans) " p03137,s075963945,Accepted,"N, M = map(int, input().split()) X = [int(x) for x in input().split()] X.sort(reverse=True) X_diff = [] for i in range(len(X)-1): X_diff.append(X[i] - X[i+1]) X_diff.sort() if N < M: print(sum(X_diff[:M-N])) else: print(0)" p03220,s846448627,Wrong Answer,"n = int(input()) t,a = map(int,input().split()) h = list(map(int, input().split())) a = 10**9 for i in range(n): c = h[i]*0.006 if abs(a-c)=x: y=y/2 count+=1 print(count)" p02661,s599923684,Wrong Answer,"import statistics N = int(input()) A = [] B = [] for i in range(N): a, b = list(map(int, input().split())) A.append(a) B.append(b) Am = statistics.median(A) Bm = statistics.median(B) if N % 2 == 0: print(2 * round(Bm - Am) + 1) else: print(Bm - Am + 1)" p02772,s884948050,Accepted,"# 数値の取得 num_cnt = int(input()) num_list = list(map(int,input().split())) # 数値の検査後メッセージを出力 judge = ""APPROVED"" for cnt in range(0,num_cnt,1): if num_list[cnt] % 2 == 0\ and num_list[cnt] % 3 != 0\ and num_list[cnt] % 5 != 0: judge = ""DENIED"" print(judge)" p03665,s322186857,Accepted,"n,p = map(int,input().split()) a = list(map(int,input().split())) o, e = 0, 0 for i in a: if i % 2 == 0: e += 1 else: o += 1 def comb(n, r): ret = 1 for i in range(r): ret *= n - i ret //= i + 1 return ret res = 0 if p == 0: for i in range(0, o + 1, 2): res += comb(o, i) else: for i in range(1, o + 1, 2): res += comb(o, i) res *= 2 ** e print(res) " p03161,s592478371,Accepted,"def chmin(a,b): if a > b: return b else: return a N, K = map(int, input().split()) h = list(map(int, input().split())) INF = float('inf') dp = [INF] * N dp[0] = 0 for i in range(N): for j in range(1,K+1): if i+j < N: dp[i+j] = chmin(dp[i+j], dp[i] + abs(h[i] - h[i+j])) print(dp[N-1])" p02683,s740170836,Accepted,"import itertools N, M, X = map(int,input().split()) arr = [] for i in range(N): arr.append(list(map(int,input().split()))) costl = [] for p in itertools.product([0,1],repeat=N): f = [0]*M cost = 0 for i in range(N): if p[i] == 1: for j in range(M): f[j] += arr[i][j+1] cost += arr[i][0] if all(point >= X for point in f): costl.append(cost) print(min(costl) if len(costl) >= 1 else -1)" p02663,s061419799,Accepted,"h1, m1, h2, m2, k = map(int, input().split()) time1 = 60*h1 + m1 time2 = 60*h2 + m2 print(time2 - time1 - k) " p02971,s920933656,Accepted,"N = int(input()) A = [int(input()) for _ in range(N)] sortedA = sorted(A, reverse=True) for a in A: if sortedA[0] != a: print(sortedA[0]) else: print(sortedA[1])" p02600,s374607626,Wrong Answer,"n = int(input()) if(n>=400 and n<600):print(8) elif(n>=600 and n<800):print(7) elif(n>=800 and n<1000):print(6) elif(n>=1000 and n<1200):print(5) elif(n>=1200 and n<1400):print(4) elif(n>=1400 and n<1600):print(3) elif(n>=1600 and n<1700):print(2)" p04034,s873655660,Accepted,"import copy N,M = [int(hoge) for hoge in input().split()] Ball = [False]*N BallNum = [1] * N Ball[0] = True for i in range(M): x,y = [int(hoge) - 1 for hoge in input().split()] BallNum[x] -= 1 BallNum[y] += 1 if Ball[x]: Ball[y] = True if BallNum[x] == 0: Ball[x] = False print(sum(Ball))" p02766,s828585623,Wrong Answer,"import math n,k=map(int,input().split()) if math.log(n,k) == int(math.log(n,k)): res=math.log(n,k) + 1 else: res=int(math.log(n,k)) + 1 print(res) " p02640,s912529552,Accepted,"x, y = map(int, input().split()) ans = False for i in range(101): for j in range(101): if i+j == x and 2*i+4*j == y: ans = True if ans: print(""Yes"") else: print(""No"")" p02881,s677760235,Wrong Answer,"import math N=int(input()) han=999999999999999999999999999999999999999999 b=0 for a in range(1,int(math.sqrt(N))+1): if N%a==0: A=N/a if A>a: gou=A-a else: gou=a-A b=a if gouA[i]: y=1 if x==1 and y==1: ans+=1 x=y=0 c=A[i] print(ans)" p03075,s225975369,Wrong Answer,"a,b,c,d,e,k = [int(input()) for i in range(6)] print('Yey!' if e-a m: h -= B[i] else: print(i+1+(h-1)//m) break if h <= 0: print(i+1) break else: print(n+1+(h-1)//m)" p02767,s485661319,Accepted,"N = int(input()) X = list(map(int, input().split())) tairyoku = [0]*100 for i in range(100): t=0 for j in range(N): t += (X[j]-i)**2 tairyoku[i]=t print(min(tairyoku))" p02882,s897970124,Accepted,"import math a, b, x = map(int, input().split()) if(x < ((a*a*b)/2)): print(math.degrees(math.atan( a*b*b/(2 * x) ))) else: print(math.degrees(math.atan( 2*(a*a*b - x)/(a*a*a) )))" p03323,s225775077,Accepted,"a, b = map(int, input().split()) print('Yay!' if a <= 8 and b <= 8 else ':(')" p02791,s241338765,Wrong Answer,"n = int(input()) a = list(map(int,input().split())) mx = 0 ans = 0 for i in a: if i<=mx: ans+=1 mx = max(mx,i) print(ans) " p03427,s628157838,Wrong Answer,"#! /usr/bin/env python3 import sys import numpy as np int1 = lambda x: int(x) - 1 read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(500000) N = int(readline()) N_chr = str(N) c = N_chr[0] acc = int(c) + 9 * (len(N_chr) - 1) if N == acc: print(acc) else: print(acc - 1) " p02700,s982652553,Wrong Answer,"A,B,C,D=map(int,input().split()) count1=0 count2=0 for i in range(A<=0): A=A-D*i count1+=1 for n in range(C<=0): C=C-B*n count2+=1 if count1<=count2: print('Yes') else: print('No')" p03803,s876473114,Wrong Answer,"a,b=map(int,input().split()) if (a==1): a=14 if (b==1): b=14 if (a>b): print('Alice') elif (b>a): print('Bob') else: print('draw') " p02607,s984876517,Accepted,"n = int(input()) a = list(map(int, input().split())) ans = 0 for i in range(n): if i%2 == 1: continue if a[i]%2 == 1: ans += 1 print(ans)" p02707,s683667579,Wrong Answer,"n = int(input()) lst = list(map(int,input().split())) ans = [0] * n for i in lst: ans[i] += 1 ans.remove(0) ans.append(0) print(ans)" p02862,s083003660,Accepted,"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 or b<0: print(0) else: print(binomial(a+b,a)%mod) else: print(0)" p04019,s071040056,Accepted,"s = set(list(input())) if s=={'N','W','S','E'} or s=={'N','S'} or s=={'W','E'}: print('Yes') else: print('No')" p02842,s905099058,Wrong Answer,"n=int(input()) x=int(n/1.08) if int(x*1.08)==n: print(x) else: print("":("")" p03160,s274704520,Accepted,"N = int(input()) heights = tuple(map(int, input().split(' '))) dp = [0] * (N + 1) dp[1] = 0 dp[2] = abs(heights[0] - heights[1]) for hi, i in enumerate(range(3, N + 1), start=2): dp[i] = min( dp[i - 1] + abs(heights[hi] - heights[hi - 1]), dp[i - 2] + abs(heights[hi] - heights[hi - 2]), ) print(dp[N]) " p02993,s254970680,Accepted,"a, b, c, d = map(int, input()) if a == b or b == c or c == d: print(""Bad"") else: print(""Good"")" p03352,s309759046,Accepted,"a = int(input()) print(max(j ** i for j in range(32) for i in range(2, 10) if j ** i <= a))" p02953,s881682981,Wrong Answer,"n = int(input()) l = list(map(int, input().split())) m = max(l) num = l.index(m) for i in range(num, len(l)): if l[i] + 2 <= m: print(""No"") exit() print(""Yes"")" p02792,s436301371,Accepted,"N=int(input()) P=list(range(100)) for y in range(100): P[y]=0 for i in range(N): if i+1<=9: c=(i+1)*11 P[c]+=1 else: z=str(i+1) d=len(z) e=int((i+1)/(10**(d-1))) f=(i+1)%10 g=10*e+f P[g]+=1 k=0 for i in range(9): for j in range(9): s=(i+1)*10+(j+1) t=(j+1)*10+(i+1) z=P[s]*P[t] k+=z print(k)" p02714,s708833793,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)" p02952,s377199330,Accepted,"N = int(input()) ans = 0 for i in range(1,N+1): for j in range(6): if 10 ** j <= i and i < 10**(j+1): if j % 2 == 0: ans += 1 break print(ans)" p04034,s729474817,Wrong Answer,"N, M = list(map(int, input().split())) C = [1] * (N + 1) B = [True, True] + [False] * (N - 1) flg = False for _ in range(M): x, y = list(map(int, input().split())) if B[x]: B[y] = True if x == 1 and not flg and C[1] == 1: B[1] = False flg = True if y == 1 and not flg: flg = True C[x] -= 1 C[y] += 1 res = 0 for i in range(1, N + 1): if B[i] and C[i] > 0: res += 1 print(res) " p03106,s885602569,Wrong Answer,"import math a,b,k=map(int,input().split()) cnt=0 for i in range(math.gcd(a,b),1,-1): if a%i==0 and b%i==0: cnt += 1 if cnt==k: print(i) break" p02785,s516880366,Accepted,"# coding: utf-8 # Your code here! N, K = map(int, input().split()) H = list(map(int, input().split())) newH = sorted(H) if K >= N: print(0) else: for i in range(K): newH.pop() print(sum(newH))" p02552,s665146866,Accepted,"x = int(input()) print(0 if x == 1 else 1) " p02900,s240143953,Accepted,"import math A,B = map(int,input().split()) G = math.gcd(A,B) N = G #素因数分解 sep = [] for i in range(2,int(math.sqrt(N))+2,1): if N % i ==0: count = 0 while N % i == 0: N = N//i count += 1 sep.append([i,count]) if N != 1: sep.append([N,1]) print(len(sep)+1)" p03555,s683469339,Wrong Answer,"C1 = input() C2 = input() ans = 'YES' if C1[0] != C2[2]: ans = 'NO' if C1[1] != C2[1]: ans = 'NO' if C1[2] != C2[1]: ans = 'NO' print(ans)" p02556,s421588284,Accepted,"N = int(input()) xy = [map(int, input().split()) for _ in range(N)] def get_output(): dist = [0 for _ in range(N)] X, Y = [], [] for i, (x, y) in enumerate(xy): x, y = x-y, x+y X.append(x) Y.append(y) a = max(X) - min(X) b = max(Y)-min(Y) return max(a, b) print(get_output()) " p03371,s037491416,Accepted,"a, b, c, x, y = [int(x) for x in input().split()] if x <= y: ans = min(a + b, 2 * c) * x ans += min(b, 2 * c) * (y - x) else: ans = min(a + b, 2 * c) * y ans += min(a, 2 * c) * (x - y) print(ans)" p03487,s506070556,Wrong Answer,"s = """".join(sorted(input())) t = """".join(sorted(input(), reverse=True)) if s < t: print(""Yes"") else: print(""No"")" p03061,s872969510,Accepted,"n=int(input()) a=list(map(int,input().split())) l=[0] r=[0] ans=0 from fractions import gcd for i in range(n-1): l.append(gcd(l[i],a[i])) r.append(gcd(r[i],a[-1-i])) for i in range(n): ans=max(ans,gcd(l[i],r[-1-i])) print(ans) " p02701,s929310445,Wrong Answer,"N = int(input()) #1行目のNを取得する s = [input() for i in range(N)] #複数行の数値の入力を取得 print(len(s))" p03434,s169822379,Accepted,"n = int(input()) nums = [int(x) for x in input().split()] nums.sort(reverse=True) print(sum(nums[::2]) - sum(nums[1::2]))" p02556,s130658738,Wrong Answer,"n=input() maxa=-1 mina=10000000000 maxb=-1 minb=10000000000 for i in range(int(n)): x,y=map(int,input().split()) maxa=max(maxa,x+y) mina=min(mina,x+y) maxb=max(maxb,x-y) minb=min(minb,x-y) print(max(abs(maxa-mina),abs(maxb-minb))) " p03804,s419617208,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)]) for i in range(N-M+1): for j in range(N-M+1): if (A[i:i+M, j:j+M] == B).all(): print('Yes') exit() print('No')" p03665,s380583379,Accepted,"n,p = map(int, input().split()) lis = list(map(int, input().split())) odd = [i for i in lis if i % 2==1] even = [i for i in lis if i % 2 == 0] if len(odd) == 0: if p == 0: print(2**n) else: print(0) else: odd_m = len(odd) even_m = len(even) t1 = 2**even_m t2 = 2**(odd_m-1) print(t1*t2)" p03944,s009201299,Accepted,"w,h,n = map(int, input().split()) x1,x2,y1,y2 = 0,w,0,h for _ in range(n): xi,yi,ai = map(int, input().split()) if ai==1: x1 = max(xi,x1) elif ai==2: x2 = min(xi,x2) elif ai==3: y1 = max(yi,y1) else: y2 = min(yi,y2) dx = max(0, x2-x1) dy = max(0, y2-y1) print(dx*dy)" p03359,s582945518,Accepted,"a,b=map(int,input().split()) if a<=b:print(a) else:print(a-1)" p02601,s154635138,Accepted,"a,b,c=map(int,input().split()) k=int(input()) for ai in range(k): for bi in range(k): if ai + bi > k: continue ci = k - (ai+bi) tmpa = a * (2 ** ai) tmpb = b * (2 ** bi) tmpc = c * (2 ** ci) if tmpa < tmpb and tmpb < tmpc: print('Yes') exit(0) print('No')" p03779,s656082005,Wrong Answer,"n = int(input()) count = 0 for i in range(1, n): count += i if count >= n: print(i) exit() " p03416,s903473944,Accepted,"def func(X,A,B): count = 0 for i in range(X,100): j = str(i) z = j[1]+j[0] for y in range(10): tmp = int(str(i)+str(y)+z) if A <= tmp and tmp <= B: count += 1 elif tmp > B: return count return count a,b = input().split() x = a[:2] A = int(a) B = int(b) X = int(x) print(func(X,A,B))" p03281,s441739435,Accepted,"n = int(input()) ans = 0 for i in range(1, n+1): if i%2 == 1: cnt = 0 for j in range(1, i+1): if i%j == 0: cnt += 1 if cnt == 8: ans += 1 print(ans)" p02689,s159465958,Wrong Answer,"n,m=map(int,input().split()) h=list(map(int,input().split())) ab=[] for _ in range(m): ab.append(list(map(int,input().split()))) good=[1]*n for i in range(m): if h[ab[i][0]-1]"") else: a = S.count(""<"") print(a * (a + 1) // 2)" p03251,s870555723,Accepted,"n, m, a, b = map(int, input().split()) x = list(map(int, input().split())) y = list(map(int, input().split())) x.append(a) y.append(b) if max(x) < min(y): print('No War') else: print('War')" p02684,s259584114,Wrong Answer,"N, K = map(int, input().split()) A = list(map(int, input().split())) now = 1 temp_l = [0]*N temp_count = [-1]*N temp_count[0] = 0 for i in range(N): pre = now now = A[pre-1] if temp_l[now-1] == 1: end = now temp = i+1 break else: temp_l[now-1] = 1 temp_count[now-1] = i+1 s_index = temp_count[end-1] repeat = temp - s_index K -= s_index K = K % repeat print(temp_count.index(K+s_index)+1)" p02753,s053256663,Accepted,"s = input() print(""No"" if s == ""AAA"" or s == ""BBB"" else ""Yes"")" p02602,s544406263,Accepted,"N,K=map(int,input().split()) *A,=map(int,input().split()) now=A[0] i=K while inow: print('Yes') else: print('No') i+=1 now=A[i-K]" p03345,s296918068,Accepted,"a , b , c , k = map(int,input().split()) if k % 2 == 0: ans = a-b elif k % 2 == 1: ans = b-a if abs(ans) > 10 **18: print(""Unfair"") elif abs(ans) <= 10**18: print(ans)" p03109,s026512757,Wrong Answer,"s = input() if s >= ""2019/04/30"": print(""Heisei"") else: print(""TBD"") " p03329,s276459741,Accepted,"import sys n = int(input()) INF = 10*n dp = [INF]*(n+1) dp[0] = 0 for i in range(1, n+1): tmp = dp[i-1] + 1 for j in range(10): if i-6**j<0: break tmp = min(tmp, dp[i-6**j] + 1) for j in range(10): if i-9**j<0: break tmp = min(tmp, dp[i-9**j] + 1) dp[i] = tmp print(dp[n])" p04020,s924164691,Accepted,"n = int(input()) ls = [0] * n for i in range(n): a = int(input()) ls[i] = a ans = 0 for i in range(n-1): if ls[i] % 2 == 1 and ls[i+1] > 0: ls[i] += 1 ls[i+1] -= 1 ans += ls[i] // 2 ans += ls[-1] // 2 print(ans) " p03862,s152067521,Accepted,"n, x = map(int, input().split()) a = list(map(int, input().split())) sum_a = 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] + a[i+1]) r = sum_a - sum(a) print(r)" p03544,s926850167,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[-1]+l[-2]) print(l[n]) " p03854,s150189826,Accepted,"import re;print(""YNEOS""[re.match(""(erase(r)?|dream(er)?)+$"",input())is None::2]) " p02988,s843260707,Accepted,"def main(): _ = input() A = list(map(int, input().split())) cnt = 0 for i in range(len(A)-2): A_sub = sorted(A[i:i+3]) a = A[i+1] if a == A_sub[1]: cnt += 1 print(cnt) if __name__ == '__main__': main() " p03285,s494246260,Accepted,"import sys bbn=1000000007 #+++++ def main(): a = int(input()) for i in range(16): if 7 * i <= a and (a - (7*i))%4==0: return 'Yes' return 'No' #+++++ isTest=False def pa(v): if isTest: print(v) if __name__ == ""__main__"": if sys.platform =='ios': sys.stdin=open('inputFile.txt') isTest=True else: pass #input = sys.stdin.readline ret = main() if ret is not None: print(ret)" p03486,s481862410,Accepted,"s=list(input()) t=list(input()) s.sort() t.sort(reverse=True) if s= 0: cnt += d[k] - k else: cnt += d[k] print(cnt)" p03131,s728322944,Accepted,"k,a,b=map(int,input().split()) if bK: ans=(a-K)*D+b else: ans=X-a*D-((K-a)%2)*D print(abs(ans)) " p02659,s964241033,Wrong Answer,"a,b = input().split() a = int(a) b = float(b)*100 ans = a*b // 100 print(int(ans))" p03282,s019866199,Accepted,"s = input() if set(s[:int(input())])=={'1'}: print(1) else: for i in s: if int(i) > 1: print(int(i)) break" p03548,s075550270,Accepted,"x,y,z = map(int,input().split()) ans = 0 while y * ans + z * (ans+1) <= x: ans += 1 print(ans-1) " p03971,s759320510,Accepted,"N, A, B = map(int, input().split()) L = [0, 0] S = input() for i in S: if i == ""a"": if sum(L) < A + B: print(""Yes"") L[0] += 1 else: print(""No"") elif i == ""b"": if sum(L) < A + B and L[1] < B: print(""Yes"") L[1] += 1 else: print(""No"") else: print(""No"") " p03799,s349137881,Accepted,"N, M = [int(i) for i in input().split()] cnt = min(N, M // 2) N -= cnt M -= cnt * 2 if M > 0: cnt += M // 4 print(cnt) " p03545,s444960937,Wrong Answer,"s = str(input()) n = len(s) - 1 for i in range(1 << n): f = """" f += s[0] for j in range(n): if 1 & (i >> j): f += ""+"" f += s[j + 1] else : f += ""-"" f += s[j + 1] print(eval(f)) " p02700,s801056309,Accepted,"a, b, c, d = map(int, input().split()) while a > 0 and c > 0: c -= b if c <= 0: break a -= d if d <= 0: break if c <= 0: print('Yes') else: print('No')" p03804,s802251607,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)]) flg = 0 for i in range(n-m+1): for j in range(n-m+1): if (a[i:i+m,j:j+m] == b).all(): flg = 1 print(""Yes"" if flg == 1 else ""No"")" p03416,s286358823,Wrong Answer,"a, b = map(int, input().split()) count = 0 for i in range(a, b+1): print(i) A = str(i) if A[0] == A[-1] and A[1] == A[-2]: count += 1 print(count)" p02693,s082408586,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"" print(ans)" p03680,s407928479,Accepted,"N = int(input()) A = list() for _ in range(N): A.append(int(input())) ans = 0 now = 1 for _ in range(N): if now == 2: break now = A[now - 1] ans += 1 print(ans if ans != N else -1) " p02880,s633095265,Accepted,"N=int(input()) ls1=[1,2,3,4,5,6,7,8,9] empty=[] for i in ls1: for j in ls1: empty.append(i*j) print('Yes' if N in empty else 'No')" p03721,s227218430,Wrong Answer,"n, k = map(int, input().split()) a = [] b = [] for i in range(n): a_, b_ = map(int, input().split()) a.append(a_) b.append(b_) for i in range(n): k = k-b[i] if k <= 0: print(a[i]) exit()" p03795,s114058636,Wrong Answer,"n=int(input()) print(800*n-n%15)" p02571,s703885442,Accepted,"s, t = input(), input() ret = len(t) for i in range(len(s)-len(t)+1): u = s[i:len(t)+i] count_diff = 0 for j in range(len(u)): if u[j] != t[j]: count_diff += 1 ret = min(ret, count_diff) print(ret)" p03328,s670246577,Wrong Answer,"a, b = map(int, input().split()) print(sum(range(b - a)) - b)" p02820,s761478829,Wrong Answer,"N, K = map(int, input().split()) R, S, P = map(int, input().split()) d = [[] for _ in range(K)] for i, s in enumerate(input()): score = R if s==""s"" else S if s==""p"" else P d[i%K].append(score) ans = 0 for l in d: prev_value = 10**5 for i in l: if i!=prev_value: ans += i prev_value = i else: prev_value = 10**5 print(ans)" p02859,s884745869,Accepted,"r = int(input()) print(r*r) " p03495,s054287479,Accepted,"import collections as c n,k=map(int,input().split());a=c.Counter(map(int,input().split())) print([0,sum(sorted([i for i in a.values()])[:len(a)-k])][len(a)>k])" p02880,s498642830,Accepted,"n = int(input()) x = 1 for i in range(9): if n/(i+1) == int(n/(i+1)): if n/(i+1) <= 9: x = 0 print(""Yes"" if x == 0 else ""No"")" p03042,s013075072,Accepted,"s=int(input()) a=s//100 b=s%100 if a>0 and a<=12: if b>0 and b<=12: print(""AMBIGUOUS"") else: print(""MMYY"") else: if b>0 and b<=12: print(""YYMM"") else: print(""NA"")" p02600,s518423786,Accepted,"def main(): X = input_ints() print(10 - (X // 200)) def input_ints(): line_list = input().split() if len(line_list) == 1: return int(line_list[0]) else: return map(int, line_list) def input_int_list_in_line(): return list(map(int, input().split())) def input_int_tuple_list(n: int): return [tuple(map(int, input().split())) for _ in range(n)] main() " p03730,s766307658,Accepted,"from fractions import gcd def check(): A, B, C = map(int, input().split()) if C%gcd(A,B)==0: return 'YES' return 'NO' print(check())" p03351,s841291378,Accepted,"a,b,c,d = map(int,input().split()) ans = 'No' if max(a,c)-min(a,c)<=d: ans = 'Yes' if max(a,b)-min(a,b)<=d and max(b,c)-min(b,c)<=d: ans = 'Yes' print(ans)" p02663,s801274732,Accepted,"H1,M1,H2,M2,K = map(int,input().split()) ans = 0 ans += (H2-H1) * 60 ans += M2 - M1 ans -= K print(ans) " p02714,s548809935,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(1,(n+1)//2): j = 0 while j + 2*i <= n-1: if s[j] != s[j+i] and s[j] != s[j+2*i] and s[j+i] != s[j+2*i]: ans -= 1 j += 1 print(ans)" p03673,s467489100,Accepted,"n = int(input()) a = list(map(str,input().split())) frn = ["""" for i in range((n+1)//2)] bck = ["""" for i in range(n//2)] for i in range(n): if i%2 == 0: frn[i//2] = a[i] else: bck[i//2] = a[i] if n%2 == 0: print("" "".join(bck[::-1]+frn)) else: print("" "".join(frn[::-1]+bck)) " p02714,s223296660,Wrong Answer,"import collections N = int(input()) S = input() temp_list = [] minus = 0 for i in range(0, N-2): for j in range(1, N-2): if i+j*2 >= N: break temp_list.append([i, i+j, i+j+j]) for temp in temp_list: if S[temp[0]] != S[temp[1]]: if S[temp[0]] != S[temp[2]]: if S[temp[1]] != S[temp[2]]: minus += 1 count_dict = collections.Counter(S) print(count_dict[""R""]*count_dict[""G""]*count_dict[""B""]-minus) " p03555,s754678849,Accepted,"s_1 = input() s_2 = input() if s_1[0] == s_2[2] and s_1[1] == s_2[1] and s_1[2] == s_2[0]: print('YES') else: print('NO')" p02572,s193501669,Accepted,"N=int(input()) List = list(map(int, input().split())) midList = [0]*(N-1) mid = 0 for i in range(N-2,-1,-1): mid += List[i+1] midList[i] = mid res=0 for i in range(N-1): a = List[i] % 1000000007 b = midList[i] % 1000000007 res += a*b print(res%1000000007)" p02819,s163018436,Accepted,"import math x=int(input()) def is_prime(n): if n <= 1: return False for i in range(2, int(math.sqrt(n)) +1): if n % i == 0: return False return True for i in range(x, 100003+1): if is_prime(i): print(i) exit()" p03069,s588801585,Accepted,"from itertools import accumulate from collections import Counter 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]) S = Counter(S) ans = min(ans, S[""#""], S["".""]) print(ans) " p02621,s750789676,Wrong Answer,"for a in range (1,11): print(str(a+a*a+a*a*a))" p02688,s601048469,Accepted,"N,K=(int(x) for x in input().split()) lists=[0]*N while 1: try: tmp=int(input()) except : break have_count=(int(x) for x in input().split()) for i in have_count: lists[i-1]=1 print(lists.count(0)) " p02647,s924403946,Wrong Answer,"N,K=map(int,input().split()) A=list(map(int,input().split())) imos=[0 for i in range(N+1)] zero=[0 for i in range(N+1)] for t in range(K): for i in range(N): l=max(0,i-A[i]) r=min(N,i+A[i]+1) imos[l]+=1 imos[r]-=1 for i in range(0,N): imos[i+1]+=imos[i] A[i]=imos[i] imos=zero if len(set(A))==1 and (N in set(A)): break for i in range(N): A[i]=str(A[i]) ans="" "".join(A) print(ans) " p02732,s367786858,Accepted,"n = int(input()) numlist = list(map(int, input().split("" ""))) import collections numcount=collections.Counter(numlist) sum = 0 for i in numcount.values(): sum += int(i * (i - 1) / 2) for i in numlist: print(sum - numcount[i] + 1)" p03208,s799293305,Accepted,"n,k=map(int,input().split()) L=sorted(list(int(input()) for i in range(n))) num=10**9 for i in range(n-k+1): num=min(num,L[i+k-1]-L[i]) print(num)" p03779,s657045257,Accepted,"X = int(input()) count = 0 num = 1 jamp_count = 0 while count < X: count += num num += 1 jamp_count += 1 print(jamp_count) " p03221,s533615199,Accepted,"n,m=list(map(int,input().split())) pre=[[] for i in range(n)] pre_num=[[] for i in range(n)] city=[] for i in range(m): #pの県に属してy年にできた p,y=map(int,input().split()) pre[p-1].append(y) city.append(p-1) from bisect import bisect_right for i in range(n): town=sorted(pre[i]) for j in range(len(town)): pre_num[i].append(bisect_right(town,pre[i][j])) cnt=[0 for i in range(n)] for i in city: print(str(i+1).zfill(6)+str(pre_num[i][cnt[i]]).zfill(6)) cnt[i]+=1 " p02760,s634801356,Accepted,"A=[[int(i) for i in input().split("" "")]for k in range(3)] N=int(input()) for i in range(N): b=int(input()) for x,y in [(x,y) for x in range(3) for y in range(3) if A[x][y]==b]: A[x][y]=0 M=1 for k in range(3): M*=sum(A[i][k] for i in range(3)) M*=sum(A[k][i] for i in range(3)) M*=sum(A[i][i] for i in range(3)) M*=sum(A[i][2-i] for i in range(3)) if M==0: print(""Yes"") else: print(""No"") " p03815,s709880959,Accepted,"x = int(input()) ans = x//11 * 2 ans += 0 if x%11==0 else 1 if x%11<=6 else 2 print(ans)" p02958,s102169170,Accepted,"n = int(input()) s = list(map(int,input().split())) t = 0 for i in range(n): s.append(i) for i in range(n): if(s[i] == i + 1): t += 0 else: t += 1 if(t == 0 or t == 2): print('YES') else: print('NO')" p02862,s410989111,Wrong Answer,"x,y = map(int,input().split()) mod = 10**9+7 def comb(a,b): comb = 1 chld = 1 for i in range(b): comb = comb*(a-i)%mod chld = chld*(b-i)%mod return (comb*pow(chld,mod-2,mod))%mod if (x+y)%3!=0: print(0) else: nm = (x+y)//3 n = y-nm m = x-nm print(comb(n+m,m))" p02695,s057361608,Accepted,"import itertools n,m,q = map(int,input().split()) a = [0]*q b = [0]*q c = [0]*q d = [0]*q for i in range(q): a[i],b[i],c[i],d[i] = map(int,input().split()) ans = 0 for A in itertools.combinations_with_replacement(range(1,m+1),n): cnt = 0 for i in range(q): if A[b[i]-1] - A[a[i]-1] == c[i]: cnt += d[i] ans = max(ans,cnt) print(ans) " p03862,s341784219,Accepted,"N, x=map(int, input().split()) a=list(map(int, input().split())) out=0 tmp=a[0]+a[1] if tmp>x: if tmp-x>a[1]: out+=a[1] a[1]=0 y=tmp-x-out out+=y else: out+=tmp-x a[1]-=tmp-x for i in range(1, N-1): tmp=a[i]+a[i+1] if tmp>x: out+=tmp-x a[i+1]-=tmp-x print(out)" p03612,s833295077,Accepted,"N=int(input()) alist=[0]+list(map(int,input().split())) answer=0 for i in range(1,N): if alist[i]==i: alist[i],alist[i+1]=alist[i+1],alist[i] answer+=1 if alist[N]==N: print(answer+1) else: print(answer)" p03827,s430492916,Accepted,"n = int(input()) s = 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,s989218499,Accepted,"N=list(map(int,input().split())) N.append(N[0]-1) N.append(N[1]-1) N.sort(reverse=True) print(sum(N[0:2])) " p02795,s398018428,Accepted,"import math h = int(input()) w = int(input()) n = int(input()) if h < w: print(math.ceil(n/w)) else: print(math.ceil(n/h)) " p03095,s942418313,Accepted,"import collections n,s=int(input()),list(input()) l=(collections.Counter(s)).values() ans=1 for x in l: ans*=(x+1) print((ans-1)%(10**9+7))" p02779,s646666282,Accepted,"N = int(input()) A = list(map(int, input().split())) S = list(set(A)) if len(A) == len(S): print(""YES"") else: print(""NO"")" p02724,s255860642,Wrong Answer,"X = int(input()) a = X // 500 b = (X % 500) // 5 print(a + b)" p03017,s638114949,Accepted,"N,A,B,C,D=map(int,input().split()) str=input() str_ac = str[A-1:C] str_bd = str[B-1:D] str_bd2 = str[B-2:D+1] #print(str_bd) #print(str_ac) #print(str_bd2) if C K: break while At[i] + Bt[j] > K: j = j - 1 if ans < i + j: ans = i+j print(ans)" p03252,s601219525,Accepted,"a=input() b=input() memo = [] def swap(word,x,y): word=word.replace(x,'+') word=word.replace(y,'-') word=word.replace('+',y) word=word.replace('-',x) return word for i in range(len(a)): if a[i] != b[i]: if a[i] in memo or b[i] in memo: print('No') break else: a=swap(a,a[i],b[i]) memo.append(a[i]) memo.append(b[i]) else: if a==b: print('Yes') else: print('No') " p04020,s069296461,Accepted,"R=[0] L=list() N=int(input()) for i in range(N): k=int(input()) L.append(k) if k==0: R.append(len(L)) S=sum(L) R.append(N) for i in range(len(R)-1): if sum(L[R[i]:R[i+1]])%2==1: S=S-1 print(S//2)" p03419,s120173428,Accepted,"n,m = map(int,input().split()) if n == m == 1: print(1) elif n == 1 or m == 1: print((max(1,n-2))*(max(1,m-2))) else: print((n-2)*(m-2)) " p03219,s879422919,Wrong Answer,"X,Y=map(int,input().split()) print(X+Y/2) " p02910,s881770976,Accepted,"S = input() if ""L"" in S[::2] or ""R"" in S[1::2]: print(""No"") else: print(""Yes"")" p03774,s452256979,Accepted,"N, M = map(int, input().split()) a = [0] * N b = [0] * N c = [0] * M d = [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): d1 = float('inf') for j in range(M): d2 = abs(a[i] - c[j]) + abs(b[i] - d[j]) if d1 > d2: d1 = d2 check = j + 1 print(check)" p02912,s691263388,Accepted,"import heapq N, M = map( int, input().split() ) A = list( map( int, input().split() )) A = list( map( lambda x: -x, A )) heapq.heapify( A ) for i in range( M ): a = - heapq.heappop(A) // 2 heapq.heappush( A, - a ) print( - sum( A ))" p03137,s736786623,Accepted,"N,M=map(int,input().split()) *X,=sorted(map(int,input().split())) print(sum(sorted([abs(X[i+1]-X[i]) for i in range(M-1)],reverse=True)[N-1:]))" p03127,s494763099,Accepted,"import sys import math import itertools stdin = sys.stdin mod = 10**9 + 7 ns = lambda: stdin.readline().rstrip() ni = lambda: int(ns()) na = lambda: list(map(int, stdin.readline().split())) sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)] #a,bの最大公約数 def gcd(a, b): while b: a, b = b, a % b return a n = ni() a = na() ans = a[0] for ai in a[1:]: ans = gcd(ans, ai) print(ans)" p02683,s048244729,Accepted,"f=lambda:map(int,input().split()) n,m,x=f() lc,ll=[],[] for _ in range(n): c,*l=f() lc.append(c) ll.append(l) a=10**9 for i in range(2**n): lm=[0]*m t=0 for j in range(n): if i>>j&1: for k in range(m): lm[k]+=ll[j][k] t+=lc[j] if all(s>=x for s in lm): a=min(a,t) print(a if a<10**9 else -1)" p03699,s300524156,Accepted,"n=int(input()) s=sorted([int(input()) for i in range(n)]) S=sum(s) if S%10!=0: print(S) else: flag=False for i in s: tmp=S-i if tmp%10!=0: flag=True break print(tmp if flag else 0)" p02802,s089036963,Accepted,"n,m=map(int,input().split()) ps=[list(input().split()) for i in range(m)] pen=[0]*n#ペナ数 rig=[0]*n#ACorWA for i in range(m): if ps[i][1]==""AC"": rig[int(ps[i][0])-1]=1 else: if rig[int(ps[i][0])-1]==0: pen[int(ps[i][0])-1]+=1 cnt1,cnt2=0,0 for i in range(n): if rig[i]==1: cnt1+=rig[i] cnt2+=pen[i] print(str(cnt1)+"" ""+str(cnt2))" p03456,s418293232,Wrong Answer,"a,b = map(str,input().split()) for i in range(100): if int(a+b) == i**2: print('Yes') exit() print('No')" p03625,s154404064,Accepted,"n = int(input()) a = list(map(int, input().split())) dict = {} b = [0,0] c = [0,0] for i in a: if i in dict: dict[i] += 1 else: dict[i] = 1 if dict[i] == 2: b.append(i) if dict[i] == 4: c.append(i) b.sort(reverse=True) c.sort(reverse=True) print (max(b[0] * b[1],c[0]**2))" p02691,s780984659,Wrong Answer,"x=int(input()) a=0 b=0 for i in range(-500,500): for j in range(-100,100): if i**5-j**5==x: a=i b=j break else: continue break print(a,b)" p03286,s119623543,Accepted,"# input N = int(input()) # check if N == 0: print(0) exit(0) r_bits = """" p = 0 d = 0 while N + p: if (N & 1) ^ p: r_bits += '1' if d ^ p: p ^= 1 else: r_bits += '0' N >>= 1 d ^= 1 print(r_bits[::-1])" p03817,s931324489,Accepted,"x = int(input()) q, r = divmod(x, 11) if r == 0: print(2*q) elif 0 < r <= 6: print(2*q+1) else: print(2*q+2) " p02951,s322827735,Wrong Answer,"import sys import copy import math import bisect import pprint import bisect from functools import reduce from copy import deepcopy from collections import deque if __name__ == '__main__': a = [int(i) for i in input().split()] print(a[2] - (a[0]-a[1])) " p03827,s235857597,Wrong Answer,"n = int(input()) s = list(input()) ans,box = 0,[] for i in range(n): if s[i] == ""I"": ans += 1 else: ans -= 1 box.append(ans) print(max(box))" p02646,s446946367,Accepted,"a,b=map(int,input().split()) c,d=map(int,input().split()) e=int(input()) n=abs(c-a) m=b-d if m<=0: print('NO') elif e>=n/m: print('YES') else: print('NO')" p03000,s440305394,Wrong Answer,"N,X=map(int,input().split("" "")) L=[int(s) for s in input().split("" "")] Sum=0 Count=0 while Sum<=X: Sum+=L[Count] Count+=1 if Count==N: Count=N+1 break print(Count)" p02987,s921526839,Accepted,"s = sorted(input()) if (s[0] == s[1]) and (s[2] == s[3]) and (s[0] != s[2]): print('Yes') elif (s[0] == s[2]) and (s[1] == s[3]) and (s[0] != s[1]): print('Yse') elif (s[0] == s[3]) and (s[1] == s[2]) and (s[0] != s[1]): print('Yes') else: print('No') " p02909,s760091371,Accepted,"a = input() if a == ""Sunny"": print(""Cloudy"") elif a == ""Rainy"": print(""Sunny"") else: print(""Rainy"")" p03720,s859086604,Accepted,"N,M=map(int,input().split()) Br=[None]*(2*M) for i in range(M): Br[2*i],Br[2*i+1]=map(int,input().split()) for i in range(N): print(Br.count(i+1))" p03251,s814457998,Accepted,"N, M, X, Y = map(int, input().split()) x = [int(s) for s in input().split()] y = [int(s) for s in input().split()] x.append(X) y.append(Y) print('No War') if max(x) < min(y) else print('War') " p02814,s525674213,Wrong Answer,"import fractions N,M=map(int,input().split()) a = list(map(int, input().split())) lcm = a[0] for i in range(1, N): lcm = lcm * a[i] // fractions.gcd(lcm, a[i]) M2=2*M ans=0 if M2>=lcm: M2-=lcm ans+=1 ans+=M2//(lcm*2) print(ans)" p03284,s662427986,Accepted,"n, k = map(int, input().split()) if n % k == 0: print(0) else: print(1) " p03625,s050095039,Accepted,"n=int(input()) a=sorted(list(map(int,input().split())),reverse=True) h,w,i=0,0,0 while i n: break attacks += a[i] # Printing how many attacks fennec needs. print(attacks) " p02958,s747798521,Accepted,"n = int(input()) s = list(map(int,input().split())) k = s.copy() k.sort(reverse = False) t = 0 for i in range(n): if s[i] != k[i]: t += 1 if t<3: print(""YES"") else: print(""NO"")" p03835,s976723148,Accepted,"K, S = map(int, input().split()) result = 0 for x in range(K+1): for y in range(K+1): if 0 <= S - x - y <= K: result += 1 print(result) " p02622,s409455338,Accepted,"import numpy as np S = np.array(list(input())) T = np.array(list(input())) print(np.count_nonzero(S != T))" p02608,s499470653,Accepted,"n = int(input()) ans = [0] * n cnt = 0 for x in range(1, 100): for y in range(1, 100): for z in range(1, 100): f = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x if f <= n: ans[f - 1] += 1 ans.append(cnt) for j in range(n): print(ans[j])" p03319,s807988420,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) elif saishou+1<=K: answer=1+math.ceil((N-1-saishou)/(K-1)) print(answer) elif N-saishou<=K: answer=math.ceil(saishou/(K-1))+1 print(answer) else: print(math.ceil(saishou/(K-1))+math.ceil((N-1-saishou)/(K-1))) " p02973,s273802249,Accepted,"n=int(input()) m=[] m.append(int(input())) count=1 for i in range(n-1): k=int(input()) if k<=m[-1]: m.append(k) count+=1 else: r=count-1 l=0 while l+1=k: l=try1 else: r=try1 if m[l]>=k: m[r]=k else: m[l]=k print(count)" p03206,s480565966,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')" p02829,s566936590,Accepted,"a = int(input()) b = int(input()) if a!=1 and b!=1: print(1) elif a!=2 and b!=2: print(2) else: print(3)" p02784,s639989609,Accepted,"h,n = map(int, input().split()) a = list(map(int, input().split())) for i in range(n): h -= a[i] if h <= 0: print(""Yes"") else: print(""No"") " p03324,s660104185,Accepted,"D,N=map(int, input().split()) d = 1 for i in range(D): d *= 100 if N==100: N += 1 print(d*N) " p02768,s561072952,Accepted,"n,a,b=list(map(int, input().split())) C=10**9+7 def perm(a,b): tmp=1 for i in range(b): tmp*=a-i tmp=tmp%C return tmp cta=perm(n,a)*pow(perm(a,a),C-2,C) ctb=perm(n,b)*pow(perm(b,b),C-2,C) ans=pow(2,n,C)-1-cta-ctb print(ans%C)" p02823,s802947417,Wrong Answer,"n, a, b = [int(w) for w in input().split()] if (a + b) % 2 == 0: ans = (b - a) // 2 else: ans = min(b - 1, n - a) print(ans) " p03038,s929612252,Accepted,"from collections import* n,m,*d=map(int,open(0).read().split()) a=Counter(d[:n]) for b,c in zip(d[n::2],d[n+1::2]):a[c]+=b s=0 for k, v in sorted(a.items())[::-1]: if nw and abs(a-b)/(v-w) <= t : ans = 1 if ans == 0: print(""NO"") else: print(""YES"")" p02627,s382926196,Accepted,"N = 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'] 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'] if N in a: print('a') else: print('A')" p04044,s660976365,Accepted,"N, L = map(int, input().split()) l = [] for i in range(N): s = input() l.append(s) l.sort() for i in l: print(f""{i}"", end="""") print()" p02833,s301377535,Accepted,"n = int(input()) if n % 2 == 1: print(0) elif n % 2 == 0: ans = 0 k = 10 while n >= k: ans += n//k k *= 5 print(ans)" p02789,s145283204,Accepted,"n,m=map(int,input().split()) if(n==m): print('Yes') else: print('No') " p03220,s189220423,Accepted,"N = int(input()) T,A = map(int, input().split()) H = list(map(int, input().split())) x = 0 temp = float('inf') ans = 0 tmp = 0 for i in range(N): x = T - H[i]*0.006 tmp = abs(x-A) if tmp < temp: temp = tmp ans = i+1 print(ans)" p02971,s008486957,Accepted,"n = int(input()) num_list = [] for _ in range(n): num_list.append(int(input())) copy = num_list.copy() copy.sort() maximum = copy[-1] second = copy[-2] for i in num_list: if i == maximum: print(second) else: print(maximum)" p03962,s778384182,Wrong Answer,"def iroha(): a, b, c = map(int, input().split()) if a == b == c: print(1) elif a != b != c: print(3) elif a == b or b == c or a == c: print(2) if __name__ == ""__main__"": iroha() " p02552,s289935340,Accepted,"n=int(input()) if n==1: print(0) else: print(1) " p03086,s117375874,Accepted,"S = input() count = 0 koremade = 0 for i in range(0,len(S)): if S[i] in 'ACGT': count += 1 if i == len(S)-1: if koremade <= count: koremade = count else: if koremade <= count: koremade = count count = 0 print(koremade)" p02577,s034818663,Accepted,"# https://atcoder.jp/contests/abc176/tasks/abc176_b n = int(input()) if n % 9 == 0: print('Yes') else: print('No')" p02939,s178374866,Wrong Answer,"# AtCoder Grand Contest 037 # A - Dividing a String S=input() ans=set() for i in range (len(S)): a=S[i] if a not in ans: ans.add(a) else: for j in range(i+1,len(S)): a=S[i:j] if a not in ans: ans.add(a) break else: continue # print(ans) print(len(ans))" p02801,s606763313,Accepted,"C = ord(input()) print(chr(C+1))" p03419,s852182748,Accepted,"def main(): N, M = map(int, input().split()) if N == 1 or M == 1: if N == 1 and M == 1: print(1) return print(N*M-2) return if N == 2 or M == 2: print(0) return print((N-2)*(M-2)) if __name__ == '__main__': main() " p02660,s511488632,Accepted,"n=int(input()) ans=0 #it is the power of every prime number #and as z is always a prime numer we should not bother about # combiations of prime numer dividing N for i in range(2,1000010): power=0 j=1 if(n%i==0): while(n%i==0): power+=1 n=(n//i) while(power>=j): power-=j j+=1 ans+=1 if(n>1): ans+=1 print(ans)" p03719,s350449249,Accepted,"a,b,c=map(int,input().split()) print('Yes' if a<=c<=b else 'No') " p02675,s232995846,Wrong Answer,"N = list(input()) if N[:-1] == ""3"": print(""bon"") elif N[:-1] in [""0"",""1"",""6"",""8""]: print(""pon"") else : print(""hon"") " p03673,s296613488,Wrong Answer,"from collections import deque n = int(input()) a = [int(i) for i in input().split()] b = deque() if n % 2 == 0: for i in a: if i % 2 == 0: b.appendleft(i) else: b.append(i) else: for i in a: if i % 2 == 0: b.append(i) else: b.appendleft(i) print(*b)" p02708,s197097730,Accepted,"n, k = map(int, input().split()) ans = 0 mod = 10 ** 9 + 7 n_min = sum([i for i in range(0, k-1)]) n_max = sum([n - i for i in range(0, k-1)]) for i in range(k-1, n+1): n_min += i n_max += n - i ans += n_max - n_min + 1 print(ans % mod)" p02689,s470033872,Accepted," N, M = map(int, input().split()) H = list(map(int, input().split())) X = [list(map(int, input().split())) for _ in range(M)] ok = [True] * (N + 1) for a, b in X: ok[a] &= H[a - 1] > H[b - 1] ok[b] &= H[a - 1] < H[b - 1] print(sum(ok[1:])) " p02556,s055885584,Accepted,"n = int(input()) ph = 0 pl = 10**10 mh = -10**10 ml = 10**10 for _ in range(n): x,y = map(int,input().split()) ph = max(ph,x+y) pl = min(pl,x+y) mh = max(mh,x-y) ml = min(ml,x-y) print(max(ph-pl,mh-ml))" p02786,s860638887,Accepted,"import numpy as np from sys import stdin from copy import deepcopy from functools import reduce from fractions import gcd import math import itertools from collections import Counter from itertools import chain ##list(chain.from_iterable(l)) ##flatten from heapq import heappush, heappop """""" N = int(input()) A, B = map(int,input().split()) A = list(map(int,input().split())) ## 横一列 A = [int(input()) for _ in range(N)] ## 縦一列 lst = [list(map(int,input().split())) for i in range(M)] ## 二次元 """""" H = int(input()) n_bin = len(bin(H)[2:]) ans = 2 ** n_bin - 1 print(ans)" p02899,s508604851,Wrong Answer,"N = int(input()) A = list(map(int, input().split())) A_re = [] for i in range(N): num = A[i] A_re.append([num, i+1]) A_re.sort() Ans = [] for j in range(N): ans = A_re[j][1] Ans.append(ans) print(Ans)" p02829,s339695893,Wrong Answer,"a=int(input()) b=int(input()) c=[1,2,3] c.remove(a) c.remove(b) print(c)" p03289,s014775620,Wrong Answer,"s = input() if s[0]==""A"" and s[2:-1].count(""C"")==1 and s[-1]!=1: print(""AC"") else: print(""WA"")" p03624,s557175043,Accepted,"S = input() ans = None for c in 'abcdefghijklmnopqrstuvwxyz': if c not in S: ans = c break print(ans)" p03328,s672591342,Accepted,"def actual(a, b): towers = [1] for x in range(2, 999 + 1): towers.append(towers[-1] + x) for i in range(len(towers)): west_tower_height = towers[i] east_tower_height = towers[i + 1] assert east_tower_height > west_tower_height diff = east_tower_height - west_tower_height if diff == (b - a): return east_tower_height - b a, b = map(int, input().split()) print(actual(a, b))" p02712,s345566225,Accepted," # input N = int(input()) # initialization ans = 0 # count for i in range(1, N+1): if not i%3==0 and not i%5==0: ans += i # output print(ans) " p02594,s842828338,Accepted,"N = int(input()) if N>=30: print('Yes') else: print('No')" p02601,s848826651,Wrong Answer,"a,b,c=map(int,input().split()) k=int(input()) i=0 while a>=b: b*=2 i+=1 while b>=c: c*=2 i+=1 if ab: print(a-1) else: print(a)" p02951,s123318001,Accepted,"import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) def main(): A, B, C = map(int, input().split()) print(max(0, C-(A-B))) if __name__ == ""__main__"": main() " p02633,s765876602,Accepted,"def GCM(x,y): if x%y==0: return y else: return GCM(y,x%y) X = int(input()) print(360//GCM(360,X))" p02596,s710351162,Accepted,"def main(): K = int(input()) x = 7 % K s = set() i = 1 while True: # 割り切れる if x == 0: print(i) return # 割り切れない、無限ループ if x in s: print(-1) return s.add(x) x = (x * 10 + 7) % K i += 1 if __name__ == ""__main__"": main() " p02547,s799449635,Wrong Answer,"n=int(input()) k=0 c=0 for i in range(n): a,b=map(int,input().split()) if(a==b): k+=1 if(k>=3): c=1 else: k=0 if(c==1): print(""YES"") else: print(""NO"") " p03293,s445532587,Accepted,"S=input() T=input() N=len(S) F=False for _ in range(N): S=S[-1]+S[:-1] F|=(S==T) if F: print(""Yes"") else: print(""No"") " p03745,s899442103,Accepted,"def check(a,b): if ab: return 'down' return '' def solve(): ans = 1 N = int(input()) A = list(map(int, input().split())) ud = '' for i in range(N-1): a = check(A[i],A[i+1]) if ud=='' or ud==a: ud = a continue if a=='': continue ans += 1 ud = '' return ans print(solve()) " p03854,s441955652,Accepted,"S = list(input()) S.reverse() S = ''.join(S) st = ['maerd','remaerd','esare','resare'] ans = 'YES' while S != '': if S[0:5] in st: S = S[5:] elif S[0:6] in st: S = S[6:] elif S[0:7] in st: S = S[7:] else: ans = 'NO' break print(ans)" p02615,s350631795,Accepted,"n=int(input()) arr=list(map(int,input().split())) arr=sorted(arr,reverse=True) ans=0 for i in range(1,n): ans+=arr[i//2] print(ans)" p02743,s801109666,Accepted,"from decimal import Decimal a, b, c = map(str,input().split()) if (Decimal(a).sqrt() + Decimal(b).sqrt()) < Decimal(c).sqrt(): print('Yes') else: print('No') " p02714,s311441471,Wrong Answer,"N = int(input()) S = str(input()) count = 0 Rlist = list() Blist = list() Glist = list() for i in range(1, len(S)): if S[i] == ""R"": Rlist.append(i + 1) elif S[i] == ""G"": Glist.append(i + 1) else: Blist.append(i + 1) for i in range(len(Rlist)): for j in range(len(Blist)): for k in range(len(Glist)): if j - i != k - j: count += 1 print(count) " p02683,s928447240,Wrong Answer,"n, m, x = map(int, input().split()) C = [list(map(int, input().split())) for _ in range(n)] import itertools as it import math cost = math.inf for comb in it.chain(*(it.combinations(C, r) for r in range(1, n+1))): print(comb) print(*comb) c, *a = map(sum, zip(*comb)) print(c,a) if c < cost and min(a) >= x: cost = c print(-1 if cost is math.inf else cost)" p03339,s160098681,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-1): yield wests[i-1] + easts_total - easts[i+1] print(min(linearsearch())) main()" p02753,s950029058,Accepted,"S = input() if ""A"" in S and ""B"" in S: print(""Yes"") else: print(""No"")" p02576,s148093291,Accepted,"n,x,t = map(int, input().split()) print(t * (n // x + 1) if n % x != 0 else t * (n // x))" p02900,s956820740,Accepted,"a,b=map(int,input().split()) def get_prime_dic(n): dic = {} i = 2 while i * i <= n: while n % i == 0: n //= i if i in dic: dic[i] += 1 else: dic[i] = 1 i += 1 if n > 1: dic[n] = 1 return dic c=get_prime_dic(a) d=get_prime_dic(b) ans=1 ans+=len(set(c)&set(d)) print(ans)" p03379,s144195162,Accepted,"n=int(input()) X=list(map(int,input().split())) S=list(sorted(X)) L=S[n//2-1] R=S[n//2] if L==R: for i in range(n): print(L) else: for x in X: if x<=L: print(R) else: print(L)" p04011,s817645628,Accepted,"# -*- coding: utf-8 -*- n = int(input()) k = int(input()) x = int(input()) y = int(input()) if n > k: ans = (k*x) + (n-k)*y else: ans = (n*x) print(ans) " p03095,s200777675,Accepted,"# -*- coding: utf-8 -*- N = int(input()) S = input() import collections n_frq_dict = collections.defaultdict(int) for s in S: n_frq_dict[s] += 1 mod=10**9+7 ret = 1 for frq in n_frq_dict.values(): ret *= frq + 1 ret %= mod print(ret - 1) " p03317,s145513629,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((n-1)//(k-1)+1)" p02759,s742501147,Accepted," N=int(input()) if N%2==0 : print(N//2) else : print(N//2+1) " p03679,s072034416,Accepted,"X, A, B = map(int,input().split()) if A >= B: print(""delicious"") elif A + X < B: print(""dangerous"") else: print(""safe"") " p02802,s756062453,Wrong Answer,"x=input().split() n=int(x[0]) m=int(x[1]) p=[] ref=[] for k in range(m): x=input().split() p.append(int(x[0])) ref.append(x[1]) first=[-1]*(n+1) penalties=[0]*(n+1) for k in range(m): prob=p[k] outcome=ref[k] if first[prob]==-1: if outcome=='AC': first[prob]=k else: penalties[prob]+=1 pb=0 pen=0 for k in range(n+1): if first[k]!=-1: pb+=1 pen+=penalties[prob] print(pb,pen) " p03417,s642232708,Accepted,"n,m = map(int,input().split()) if n > m: (n,m) = (m,n) if n == 1 and m == 1: print(1) elif (n == 1 and m == 2) or (n == 2 and m == 2) or (n == 2 and m == 3): print(0) elif (n == 1): print(m-2) else: print((n-2)*(m-2))" p02952,s797682424,Wrong Answer,"n = int(input()) nlen =len(str(n)) ans = 0 if n <= 9: print(n) else: for i in range(1,nlen): if i % 2 == 1: ans += 10 ** i -10 ** (i-1) if nlen % 2 == 1: ans = ans + (n - 10**(nlen-1) + 1) print(str(n - 10**(nlen-1) + 1)) print(ans)" p02861,s480656302,Accepted,"# -*- coding utf-8 -*- MOD = 10 ** 9 + 7 import math n = int(input()) xy = [list(map(int, input().split())) for _ in range(n)] s = sum([math.sqrt((xy[i][0] - xy[j][0]) ** 2 + (xy[i][1] - xy[j][1]) ** 2) for i in range(n) for j in range(n)]) ans = s / n print(ans) " p03221,s669921786,Wrong Answer,"N, M = map(int, input().split()) PYlist = [tuple(map(int, input().split())) for _ in range(M)] from copy import deepcopy PYsorted = sorted(deepcopy(PYlist), key=lambda x: x[1]) print(PYlist) print(PYsorted) def zero_ume(num: int) -> 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]) " p03625,s443141446,Wrong Answer,"from collections import Counter N = int(input()) A = list(map(int, input().split())) c = Counter(A) v = sorted([key for key, value in c.items() if value != 1], reverse=True) if len(v) >= 2: print(v[0] * v[1]) else: print(0) " p02700,s181052633,Wrong Answer,"a, b, c, d = map(int, input().split()) if a//d + 1 >= c//b : print('Yes') else: print('No')" p02675,s818374459,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"") " p02753,s452029325,Wrong Answer,"s = input() if s[0] == s[2] and s[0] != s[1] and s[1] != s[2]: print('Yes') else: print('No')" p02696,s498016261,Accepted,"def f(x): return a * x // b - a * (x // b) a, b, n = map(int, input().split()) if n >= b -1: print(f(b-1)) else: print(f(n))" p02618,s588065279,Accepted,"import numpy as np d = int(input()) c = list(map(int, input().split())) c_sum = sum(c) s = [[] for _ in range(d)] for i in range(d): s[i] = list(map(int, input().split())) last = [0 for _ in range(26)] plan = [-1 for _ in range(d)] def loss(today): sum = 0 for i in range(26): sum += c[i-1] * (today - last[i-1]) return sum v = 0 for today in range(1, d+1): t = np.argmax([s[today-1][i] - c_sum + c[i] for i in range(26)]) t += 1 last[t-1] = today plan[today-1] = t print(t)" p03261,s489203323,Accepted,"N = int(input()) words_set = set() words_list = [] OK = True for _ in range(N): s = input() words_list.append(s) words_set.add(s) # print(words_list) # print(words_set) last_word = words_list[0][-1] # print(last_word) for i in range(1, N): if last_word == words_list[i][0]: last_word = words_list[i][-1] else: OK = False break if OK and len(words_list) == len(words_set): print('Yes') else: print('No')" p02779,s830929546,Accepted,"N=int(input()) A=list(map(int,input().split())) if len(A)==len(set(A)): print(""YES"") else: print(""NO"") " p02682,s077658134,Accepted,"A, B, C, K = map(int, input().split()) if K <= A: max = K if A < K <= A + B: max = A if A + B < K: max = A - (K - A - B) print(max) " p03971,s066170350,Accepted,"n, a, b = map(int, input().split()) s = input() oversea = 0 c = [False for i in range(n)] cnt = 0 for i in range(n): if s[i] == ""a"": if cnt < a+b: c[i] = True cnt += 1 if s[i] == ""b"": if cnt < a+b and oversea < b: c[i] = True oversea += 1 cnt += 1 for i in c: if i: print (""Yes"") else: print (""No"")" p02630,s897800674,Accepted,"import sys sys.setrecursionlimit(10**6) input = sys.stdin.readline n = int(input()) A = list(map(int,input().split())) d = {} for a in A: if a not in d.keys():d[a] = 0 d[a] += 1 s = sum(A) q = int(input()) for i in range(q): b,c = map(int,input().split()) if b in d.keys(): s += d[b]*(c-b) if c not in d.keys():d[c] = 0 d[c] += d[b] d[b] = 0 print(s) " p03319,s825219683,Accepted,"N, K = map( int, input().split() ) import math print( 1 + math.ceil( ( N - K ) / ( K - 1 ) ) ) " p02691,s295243999,Accepted,"#j-i=Ai+Aj Ai+i=-Aj+j #Li=Ai+i #Ri=-Ai+i #とおくと、Li=Rjとなるとき、Aiが正なので、必ずi= 24: start = start - 24 print(start)" p03219,s221668502,Accepted,"X, Y = map(int, input().split()) print(X + Y // 2)" p03131,s858633969,Wrong Answer,"K,A,B=map(int,input().split()) bis=1 if K==1: bis+=1 elif A>=B-1: 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)" p03160,s994799870,Accepted,"n = int(input()) l = list(map(int,input().split())) dp = [0]*n dp[1] = abs(l[1] - l[0]) for i in range(2,n): dp[i] = min(dp[i-2]+abs(l[i]-l[i-2]),dp[i-1]+abs(l[i] - l[i-1])) print(dp[n-1])" p04005,s683187345,Accepted,"def resolve(): A, B, C = list(map(int, input().split())) ans = '' if A % 2 == 0 or B % 2 == 0 or C % 2 == 0: ans = 0 else: ans = min(B * C, C * A, A * B) print(ans) return resolve()" p02842,s484506169,Accepted," n = int(input()) for i in range(500000): if int(i*1.08) == n: print(i) break else: print("":("")" p03481,s758404620,Accepted,"X,Y = list(map(int,input().split())) #X, 2X, 4X,...,2^(t-1)*X<=Yとなる最大のt #10^18 はだいたい2^60だから全部試せそう for t in range(1,100): if 2**(t-1)*X<=Y: out = t else: break print(out) " p02879,s471680945,Wrong Answer,"a,b=map(int,input().split()) if (a>10 or b>10): print(-1) else: print(a*b) " p03804,s646859043,Accepted,"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): jud=True for k in range(m): if b[k]!=a[i+k][j:j+m]: jud=False break if jud: print(""Yes"") exit() print(""No"")" p03665,s288197280,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 if P == 0: for i in range(0, o+1, 2): ans += combi(o, i) print(ans * pow(2, e)) else: for i in range(1, o+1, 2): ans += combi(o, i) print(ans * pow(2, e))" p03745,s721147463,Accepted,"n = int(input()) a = list(map(int, input().split())) ans = 1 trend = '-' pre = a[0] for now in a: if (trend=='<' and pre>now) or (trend=='>' and prenow: trend = '>' pre = now print(ans)" p02702,s354633646,Accepted,"s = input() l = len(s) dp = [0]*2019 dp[0] = 1 r = 0 for i in range(1, l + 1): r += int(s[-i]) * pow(10, i - 1, 2019) r %= 2019 dp[r] += 1 print(sum([(i * (i - 1)) // 2 for i in dp]))" p03408,s706108256,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()) ans = 0 for i in s: ans = max(ans, s.count(i) - t.count(i)) print(ans) " p03487,s287346291,Accepted,"n = int(input()) l = map(int,input().split()) d = {} ans = 0 for i in l: if i not in d: d[i] = 1 else: d[i] += 1 for k,v in d.items(): if k != v: if k < v: ans += v - k else: ans += v print(ans)" p02953,s860458359,Accepted,"n = int(input()) h = list(map(int, input().split())) h[0] -= 1 for i in range(0, n-1): if h[i] <= h[i+1] -1: h[i+1] -= 1 elif h[i] > h[i+1]: print('No') break else: print('Yes')" p03339,s557885954,Wrong Answer,"def resolve(): n = int(input()) S = tuple(input()) c_e = S.count('E') c_w = 0 ans = n for s in S: ans = min(ans, c_w + c_e) if s == 'E': c_e -= 1 else: c_w += 1 print(ans) if __name__ == '__main__': resolve()" p03221,s674255276,Accepted,"n, m = map(int, input().split()) py = [] for _ in range(m): p, y = map(int, input().split()) py.append((p, y)) prefs = [[] for _ in range(n)] for ind, (p, y) in enumerate(py): prefs[p-1].append((y, ind)) ans = [None]*m for p, i in enumerate(prefs): i.sort() for j, (_, ind) in enumerate(i): ans[ind] = str(p+1).zfill(6)+str(j+1).zfill(6) for i in ans: print(i)" p02835,s297257217,Accepted,"A_s = list(map(int, input().split())) if sum(A_s) > 21: print('bust') else: print('win')" p03126,s978238718,Accepted,"n, m = map(int, input().split()) l = [0]*m for _ in range(n): k, *a = map(int, input().split()) for i in a: l[i-1] += 1 print(l.count(n))" p02688,s252929682,Accepted,"N,K = map(int,input().split()) treats = [[False for i in range(110)] for j in range(110)] res = 0 for i in range(1,K+1,1): d = int(input()) A = [i for i in map(int,input().split())] for a in A: treats[i][a] = True for j in range(1,N+1,1): flag = 1 for i in range(1,K+1,1): if treats[i][j] == True: flag = 0 if flag: res += 1 print(res)" p03815,s539790287,Accepted,"x = int(input()) # 6 -> 5- > 6 -> ....が最適? p, q = divmod(x, 11) p *= 2 if q != 0: if q <= 6: p += 1 else: p += 2 print(p) " p04011,s702370509,Accepted,"N,K,X,Y = [int(input()) for i in range(4)] if N>=K: print(K*X + (N-K)*Y) else: print(N*X)" p02713,s484920381,Accepted,"from math import gcd k=int(input()) r=range(1,k+1) ans=0 for i in r: for j in r: for k in r: ans+=gcd(k,gcd(i,j)) print(ans) # 間に合うはずなくない?? " p02933,s947630276,Wrong Answer,"import math a = int(input()) s = input() if(a >= 3200): print(s) else: print(""Red"")" p04031,s413559007,Wrong Answer,"import math n = int(input()) a = list(map(int, input().split())) X = math.ceil(sum(a) / n) P = 0 for i in range(n): P += (X - a[i])**2 print(P)" p03796,s127788920,Accepted,"n = int(input()) power = 1 for i in range(1,n+1): power=power*i%(10**9+7) print(power)" p02958,s097585471,Wrong Answer,"N=int(input()) M=list(map(int,input().split())) ans=0 list_= sorted(M) for i in range(N): if M[i]==list_[i]: ans+=1 if ans>=N-2: print('Yes') else: print('No') " p03371,s741783167,Accepted,"A, B, C, X, Y = map(int, input().split()) ans = float('inf') for i in range(10**5 + 1): price = 2*C*i + A*max(0, X - i) + B*max(0, Y - i) if ans > price: ans = price print(ans)" p02726,s111150821,Accepted,"N,X,Y=map(int,input().split()) b=[0 for i in range(N+1)] #print(b) for i in range(1,N): for j in range(i+1,N+1): #print('{},{}'.format(i,j)) minmin=min([abs(j-i),abs(X-i)+1+abs(Y-j)]) #print(minmin) b[minmin]=1+b[minmin] for i in range(1,N): print(b[i]) " p03345,s099607444,Wrong Answer,"a, b, c, k = map(int, input().split()) if k % 2 == 0: ans = a-b else: ans = b-a" p02641,s100394993,Accepted,"def solve(x, n, nums): if not nums or x not in nums: return x a = x - 1 b = x + 1 while True: if a not in nums: return a if b not in nums: return b a -= 1 b += 1 x, n = map(int, input().split()) A = None if n > 0: A = set(list(map(int, input().split()))) print(solve(x, n, A))" p03274,s758260171,Accepted,"N, K = list(map(int, input().split())) A = list(map(int, input().split())) ans = 10**9 for i in range(N-K+1): l, r = A[i], A[i+K-1] if l*r >= 0: ans = min(ans, max(abs(l), abs(r))) else: ans = min(ans, r-l+min(abs(l), abs(r))) print(ans) " p02640,s109350649,Accepted,"if __name__ == ""__main__"": x,y = map(int,input().split()) flag = 0 for i in range(x + 1) : if i * 4 + (x - i) * 2 == y : print(""Yes"") flag = 1 break if flag == 0 : print(""No"")" p03387,s389979113,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 a,b,c = map(int,input().split()) li = [a,b,c] li.sort() cnt = 0 while li[2] != li[1]: li[0] += 1 li[1] += 1 cnt+=1 cnt += (li[1]-li[0])//2 if (li[1]-li[0])%2 != 0: cnt += 2 print(cnt) " p03611,s850557909,Accepted,"import collections n = int(input()) a = list(map(int,input().split())) for i in range(n): a.append(a[i] + 1) a.append(a[i] - 1) l = collections.Counter(a) l = list(l.values()) print(max(l))" p03487,s243575490,Accepted,"N = int(input()) A = [int(x) for x in input().split()] c = dict() for a in A: if a not in c: c[a] = 1 else: c[a] += 1 tmp = 0 for k, v in c.items(): if v < k: tmp += v else: tmp += (v - k) print(tmp)" p03012,s321444028,Wrong Answer,"n = int(input()) w = list(map(int,input().split())) ans = 0 for i in range(n): ans += w[i] if ans > sum(w)//2: print(abs(ans - (sum(w)-ans))) break" p03324,s065128681,Wrong Answer,"s = input().split() d = int(s[0]) n = int(s[1]) answer = 0 if d == 0: if n == 100: answer = 101 else: answer = n elif d == 1: answer = 100 * n elif d == 2: answer = 10000 * n print(answer)" p02866,s001606498,Accepted,"import collections n = int(input()) d = list(map(int, input().split())) mod = 998244353 if d[0] != 0: print(0) exit() m = max(d) cnt = collections.Counter(d) if cnt[0] != 1: print(0) exit() ans = 1 for i in range(1, m + 1): if cnt[i] == 0: print(0) exit() ans *= pow(cnt[i - 1], cnt[i], mod) ans %= mod print(ans) " p02556,s869421197,Accepted,"N = int(input()) Zlist=[] Wlist = [] for i in range(N): x,y = map(int,input().split()) z = x+y w = x-y Zlist.append(z) Wlist.append(w) Zlist.sort() Wlist.sort() print(max(Zlist[-1]-Zlist[0],Wlist[-1]-Wlist[0]))" p03557,s273626314,Wrong Answer,"import bisect N = int(input()) Alist = sorted(list(map(int, input().split()))) Blist = sorted(list(map(int, input().split()))) Clist = sorted(list(map(int, input().split()))) ans = 0 for B in Blist: Aindex = bisect.bisect_left(Alist, B) Cindex = bisect.bisect_right(Clist, B) print(B, Aindex, N-Cindex) ans += Aindex * (N - Cindex) print(ans) " p02873,s281602264,Accepted,"S = input() N = len(S) A = [0] * (N+1) c = 0 for i in range(N): if S[i] == '<': c += 1 else: c = 0 A[i+1] = c c = 0 for i in range(N-1, -1, -1): if S[i] == '>': c += 1 else: c = 0 A[i] = max(A[i], c) print(sum(A))" p02598,s033126848,Wrong Answer,"from math import ceil def main(): n, k = map(int, input().split()) a = list(map(int, input().split())) a.sort() lower = 1 upper = 10 ** 9 + 7 while upper - lower >= 0.5: target = (lower + upper) / 2 now = 0 for i in range(n): now += ceil(a[i] / target) - 1 if now > k: lower = target else: upper = target print(ceil(lower) if k > 0 else a[-1]) if __name__ == '__main__': main() " p03679,s074353819,Accepted,"X, A, B = map(int, input().split()) a = A * (-1) if (a+B < X+1) and (A < B): print(""safe"") elif (A >= B): print(""delicious"") elif (a+B >= X+1): print(""dangerous"")" p02970,s252390794,Accepted,"n, d = map(int, input().split()) print((n-1)//(2*d+1)+1)" p02838,s311878097,Accepted,"n = int(input()) l = list(map(int,input().split())) mod = 10**9+7 ones = [0]*60 ans = 0 for i in range(n): x = l[i] for j in range(60): ones[j] += (x>>j)&1 ans = (ans + (n-1)*x)%mod # print(ans) for i in range(60): ans = (ans - ones[i]*(ones[i]-1)*2**i)%mod print(ans)" p02866,s397015929,Accepted,"from collections import Counter N = int(input()) d = list(map(int, input().split())) MOD = 998244353 dn = Counter(d) ans = 1 if dn[0] != 1 or d[0] != 0: ans = 0 else: for i in range(1, max(d)+1): ans *= (dn[i-1]**dn[i]) ans %= MOD print(ans)" p03030,s487635491,Accepted,"import sys readline = sys.stdin.readline N = int(readline()) rest = [None] * N for i in range(N): s,p = readline().split() rest[i] = [s,int(p),i + 1] rest = sorted(rest, key = lambda x:(x[0],-x[1])) for r in rest: print(r[2]) " p02880,s193753495,Accepted,"n = int(input()) product_list = list() for i in range(1, 10): for j in range(1, 10): product_list.append(i * j) if n in product_list: print('Yes') else: print('No') " p02702,s348687533,Wrong Answer,"S = input() for i in range(10**9): s = 1 + 1" p03131,s628014768,Accepted,"k,a,b = map(int,input().split()) if b - a < 2: ans = k + 1 else: k -= a - 1 ans = (k // 2) * (b - a) + a if k % 2 == 1: ans += 1 print(ans)" p02993,s622573463,Wrong Answer,"S=input() judge=0 for i in range(0,2): if S[i]==S[i+1]: judge+=1 if judge>=1: print(""Bad"") else: print(""Good"")" p03696,s022088734,Accepted,"from itertools import groupby N = int(input()) S = input() cnt_l = 0 cnt_r = 0 ans = '' for key, elems in groupby(S): elems = list(elems) if key == '(': cnt_l += len(elems) ans += '(' * len(elems) else: cnt_r += len(elems) ans += ')' * len(elems) if cnt_l < cnt_r: ans = '(' * (cnt_r - cnt_l) + ans cnt_l += (cnt_r - cnt_l) print(ans + ')' * (cnt_l - cnt_r)) " p03854,s964504808,Accepted,"def resolve(): S = list(input()) S.reverse() substr = '' p = ['dream', 'dreamer', 'erase', 'eraser'] for i in S: substr = i + substr if substr in p: substr = '' ans = 'YES' if substr == '' else 'NO' print(ans) if __name__ == ""__main__"": resolve() " p03723,s307819925,Wrong Answer,"x,y,z = map(int,input().split()) ans = 0 s = [] while True: x,y,z = y//2+z//2,x//2+z//2,x//2+y//2 if x%2 == 0 and y%2 == 0 and z%2 == 0: ans += 1 if [x,y,z] in s: print(-1) break else: s.append([x,y,z]) else: print(ans+1) break if tuple([x,y,z]) in s: print(-1) break" p03345,s729734225,Accepted,"a,b,c,k = map(int,input().split()) if k%2==0: print(a-b) else: print(b-a)" p02584,s357392750,Wrong Answer,"X,K,D = map(int,input().split()) X = abs(X) if X <= K * D : if K % 2 == 1 : answer = abs(X % D - D) else : answer = X % D else : answer = X - K * D print(answer)" p03779,s798968509,Wrong Answer,"import math x = int(input()) s = int(math.ceil(x**(0.5))) ss = s*(s+1)//2 if ss < x: print(s+1) else: print(s)" p03545,s325329445,Accepted,"import numpy as np abcd = input() #a,b,c,d = [s for s in abcd] for i in range(2**3): ops = [""-"",""-"",""-"",""""] for j in range(3): if i>>j&1: ops[j] = ""+"" equa = """" for s,op in zip(abcd,ops): equa += (s+op) if eval(equa) == 7 : break ans = equa + ""=7"" print(ans) " p03150,s977230611,Accepted,"s = input() n = len(s) k = 'keyence' a = 0 b = 6 for i in range(n): if k[a] == s[i]: a += 1 else: break if a == 7: break for i in range(n)[::-1]: if k[b] == s[i]: b -= 1 else: break if b == -1: break b = 7 - b - 1 if a + b >= 7: print('YES') else: print('NO')" p02578,s043410964,Accepted,"N = int(input()) A = list(map(int, input().split())) ans = 0 height = A[0] for i in range(1, N): if A[i]A[i-1]: height = A[i] print(ans)" p02761,s863657945,Accepted,"N, M = map(int, input().split()) A=[0]*N ans=0 e=0 for i in range(M): s, c = map(int, input().split()) if(s==1 and c==0 and N!=1): print(-1) e=1 break if A[s-1]==0 or A[s-1]==c: A[s-1]=c else: print(-1) e=1 break if A[0]==0 and N!=1: A[0]=1 for i in range(N): ans+=A[i]*(10**(N-i-1)) if e==0: print(ans)" p03623,s146222208,Accepted,"x,a,b = map(int,input().split()) print(""B"" if abs(x-a)>abs(x-b) else ""A"")" p02613,s588050526,Accepted,"n = int(input()) d = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0} for _ in range(n): s = str(input()) d[s] += 1 print('AC x {}\nWA x {}\nTLE x {}\nRE x {}\n'.format(d['AC'], d['WA'], d['TLE'], d['RE'])) " p03814,s087675731,Accepted,"MM = input() listM = list(MM) xx = len(listM) saisyo =0 saigo =xx xx = len(listM) for i in range(0,xx-1,1): if listM[i]=='A': saisyo = i break for i in range(xx-1,0,-1): if listM[i]=='Z': saigo = i break ans = saigo -saisyo print(ans+1)" p02702,s155462492,Accepted,"S = input() mods = [0 for _ in range(2019)] mods[0] = 1 t = 0 mod10 = 1 for s in reversed(S): t += int(s) * mod10 t = t % 2019 mod10 *= 10 mod10 %= 2019 mods[t] += 1 cnt = sum([m*(m-1)/2 for m in mods]) print(int(cnt)) " p02596,s068109122,Accepted,"import math import pprint import fractions import collections import itertools from decimal import * from collections import deque from bisect import * K=int(input()) flag=0 cnt=0 ans=0 for i in range(K): cnt=(cnt+7*pow(10,i,K))%K if cnt==0: flag=1 ans=i+1 break if flag==0: print(-1) else: print(ans) " p02631,s364547919,Accepted,"#!/usr/bin/env python3 import sys sys.setrecursionlimit(10**8) INF = float(""inf"") EPS = 1e-8 def main(): N = int(input()) A = list(map(int, input().split())) T = 0 for a in A: T ^= a print("" "".join([str(T ^ a) for a in A])) return if __name__ == '__main__': main() " p03469,s537617345,Accepted,"S = input() S = S[:3] + '8' + S[4:10] print(S)" p02693,s361992987,Accepted,"#A import sys k = int(input()) a, b = list(map(int, input().split())) for i in range(a, b+1): if i % k == 0: print(""OK"") sys.exit() print(""NG"")" p03219,s646109331,Accepted,"#!/usr/bin/env python3 X, Y = map(int, input().split()) print(int(X+Y/2))" p03821,s887686976,Accepted,"n = int(input()) ab = [map(int, input().split()) for _ in range(n)] ans = 0 for a, b in reversed(ab): a += ans ans += (-a) % b print(ans)" p04043,s071555510,Wrong Answer,"a = input().split() five = a.count(5) seven = a.count(7) if five == 2 and seven == 1: print('YES') else: print('NO')" p03804,s962307400,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)]) bl = False for i in range(n-m+1): for j in range(n-m+1): if (A[i:i+m,j:j+m] ==B).all(): bl =True print('Yes' if bl else 'No')" p03328,s781431476,Accepted,"a,b=list(map(int,input().split())) c=b-a l=[] for i in range(c): l.append(i+1) print(sum(l)-b) " p03778,s357425547,Accepted,"w, a, b = map(int, input().split()) if abs(a-b) < w: print(0) elif a < b: print(b-a-w) else: print(a-b-w)" p04031,s881756944,Accepted,"#ABC043C n=int(input()) a = list(map(int, input().split())) h=round(sum(a)/len(a)) sum_a=0 for i in range(len(a)): sum_a=sum_a+(a[i]-h)**2 print(int(sum_a))" p04044,s942655638,Accepted,"def main(): N, L = map(int, input().split()) S = [input() for _ in range(N)] S.sort() print(''.join(S)) if __name__ == ""__main__"": main() " p02947,s861283153,Accepted,"N = int(input()) S = [] Y = {} c = 0 for i in range(N): s = input() t = [s[0],s[1],s[2],s[3],s[4],s[5],s[6],s[7],s[8],s[9]] t.sort() u = t[0]+t[1]+t[2]+t[3]+t[4]+t[5]+t[6]+t[7]+t[8]+t[9] if u not in Y: Y[u] = 1 else : c += Y[u] Y[u] += 1 print(c) " p03485,s833293468,Accepted,"print((sum(map(int,input().split()))-1)//2+1) " p02603,s393392311,Accepted,"# print('input >>') N = input() As = list(map(int,(input().split()))) money = 1000 kab = 0 for i in range(len(As)-1): if As[i+1] >= As[i]: kounyu = money // As[i] kab += kounyu money -= kounyu * As[i] elif As[i+1] < As[i]: money += kab * As[i] kab = 0 # print(money, kab) money += kab * As[-1] # print('-----output-----') print(money)" p02843,s356502039,Accepted,"x = int(input()) h = x // 100 m = x % 100 if 0 <= m <= h * 5: print(1) else: print(0)" p02596,s240979232,Accepted,"k=int(input()) x=7 cnt=1 if k%2==0: print(-1) else: while True: if x%k ==0: print(cnt) break elif cnt<10000000: x=(x*10+7)%k cnt+=1 else: print(-1) break" p03319,s919677676,Accepted,"import sys def input(): return sys.stdin.readline().rstrip() N,K=map(int,input().split()) A=list(map(int,input().split())) ans=0 right=0 while True: if ans==0: right+=K else: right+=K-1 ans+=1 if N<=right: break; print(ans) " p03220,s728802338,Accepted,"#入力 N = int(input()) T, A = map(int, input().split()) H = list(map(int, input().split())) #空のリストを作る事で,求めた値をそのリストに追加していく #そして,そのリストの中から一番値が近いものをprintする l = [] for i in range(N): a = T - H[i]*0.006 b = abs(a-A) l.append(b) c = l.index(min(l)) print(c +1) #空のリストの作成方法 #l = [] #l.append(引数) " p02946,s130705959,Accepted,"def main(): k,x = map(int, input().split()) l = [] for i in range(x-k+1,x+k): print(i, end=' ') if __name__ == '__main__': main()" p03448,s318526637,Accepted,"a = int(input()) b = int(input()) c = int(input()) d = 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 == d: ans += 1 print(ans)" p03379,s869352797,Accepted,"n = int(input()) a = [int(x) for x in input().split()] x = sorted(a) m1 = x[n // 2] m2 = x[n // 2 - 1] for i in range(n): if a[i] < m1: print(m1) else: print(m2)" p02994,s426816275,Accepted,"n,l=map(int,input().split()) apple=[l+i for i in range(n)] s=0 while True: if s in apple: apple.remove(s) break elif abs(s) in apple: apple.remove(abs(s)) break s-=1 print(sum(apple))" p03069,s047636630,Accepted,"n=int(input());a=[0];b=[0] for i in input():t=i=='.';a+=[a[-1]+t];b+=[b[-1]+1-t*2]; print(min([i+a[n] for i in b]))" p03665,s727943917,Accepted,"import sys N, P = map(int, sys.stdin.readline().rstrip().split()) A = list(map(int, sys.stdin.readline().rstrip().split())) kisu = 0 gusu = 0 for a in A: if a % 2 == 1: kisu += 1 else: gusu += 1 total = 2 ** N # 全場合の数 if kisu == 0: ans = 2 ** gusu else: ans = (2 ** gusu) * (2 ** (kisu - 1)) # 偶数になる場合の数 if P == 0: print(ans) else: print(total - ans)" p02829,s547820505,Wrong Answer,"a = input(""A"") b = input(""B"") a = int(a) b = int(b) print(6-a-b)" p02848,s307120144,Accepted,"n = int(input()) s = input() l = ""ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"" ans = """" for i in s: ans += l[l.index(i)+n] print(ans)" p03221,s906908562,Wrong Answer," n,m = map(int, input().split()) pyl = [ [] for _ in range(n+1) ] for i in range(m): p,y = map(int, input().split()) pyl[p].append((y,i)) ans = ['']*m for p, yil in enumerate(pyl): top = str(p).zfill(6) yil.sort() for order,(y,i) in enumerate(yil): print(order,i) bottom = order+1 bottom = str(bottom).zfill(6) ans[i] = top+bottom for a in ans: print(a)" p03327,s064825925,Accepted,"import sys input = sys.stdin.readline N = int(input()) ans = ""ABC"" if N >= 1000 : ans = ""ABD"" print(ans)" p03838,s148741812,Accepted,"x,y = map(int,input().split()) if abs(x)<=abs(y): count = 0 if x <0: count += 1 if y <0: count += 1 count += abs(y)-abs(x) print(count) else: if x <=0: a = y -x b = abs(x)-abs(y)+1 print(min(a,b)) else: a = 1 + (y+x) b = 1 + abs(x) - abs(y) if y > 0: b+= 1 print(min(a,b))" p02727,s675187851,Accepted,"#create date: 2020-03-28 21:26 import sys stdin = sys.stdin import bisect def ns(): return stdin.readline().rstrip() def ni(): return int(ns()) def na(): return list(map(int, stdin.readline().split())) def main(): x, y, a, b, c = na() p = na() q = na() r = na() p.sort(reverse=True) q.sort(reverse=True) l = p[:x] l += q[:y] l += r l.sort(reverse=True) ans = sum(l[:(x+y)]) print(ans) if __name__ == ""__main__"": main()" p02948,s081652636,Accepted,"from heapq import heappush, heappop N, M = map(int, input().split()) AB = [] for i in range(N): a, b = map(int, input().split()) AB.append((a,b)) AB.sort() index = 0 result = 0 queue = [] for limit in range(1, M+1): while index < N and AB[index][0] <= limit: a, b = AB[index] heappush(queue, -b) index += 1 if queue: result += -heappop(queue) print(result)" p02647,s888781320,Wrong Answer,"N, K = map(int, input().split()) A = list(map(int, input().split())) for _ in range(min(K, 50)): lamp = [0 for i in range(N + 1)] for i in range(N): lamp[max(0, i - A[i])] += 1 lamp[min(N, i + A[i] + 1)] -= 1 print(lamp) for i in range(1, N + 1): lamp[i] += lamp[i - 1] A = lamp [print(A[i], end=' ') for i in range(N)] print() " p03971,s627452515,Accepted,"N, A, B = map(int, input().split()) S = input() qualified = 0 qualified_foreign = 0. for s in S: if s == 'c': print('No') elif s == 'a': if qualified < A + B: print('Yes') qualified += 1 else: print('No') else: if (qualified < A + B) & (qualified_foreign < B): print('Yes') qualified += 1 qualified_foreign += 1 else: print('No') " p02911,s164186155,Accepted,"N,K,Q = map(int,input().split()) A = {} for i in range(1,N+1): A[i] = 0 for i in range(Q): item = int(input()) A[item] += 1 for i in range(N): if Q - A[i+1] >= K: print(""No"") else: print(""Yes"")" p02971,s754814556,Wrong Answer,"n = int(input()) a = [input() for _ in range(n)] max_1st = sorted(a)[-1] max_2nd = sorted(a)[-2] for i in range(n): if a[i] == max_1st: print(max_2nd) else: print(max_1st) " p03544,s541870984,Accepted,"import sys def input(): return sys.stdin.readline().strip() def resolve(): n=int(input()) l=[2,1] for i in range(85): l.append(l[-2]+l[-1]) print(l[n]) resolve()" p03241,s763293727,Accepted,"N,M=map(int,input().split()) D=[] for i in range(1,int(M**0.5+1)): if M%i==0: D.append(i) D.append(M//i) D.sort() for j in D: if j >=N: print(M//j) exit()" p03759,s153450502,Accepted,"a, b, c = map(int, input().split()) if b - a == c - b: print(""YES"") else: print(""NO"") " p02786,s067329403,Accepted,"import math h = int(input()) tmp = int(math.log2(h)) print(2**(tmp+1)-1)" p02777,s584716702,Accepted,"# coding: utf-8 # Your code here! S,T = [i for i in input().split()] A,B = [int(i) for i in input().split()] U = input() if S == U: A-=1 else: B-=1 print(A,B)" p02918,s657145703,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 print(min(happy+k*2,n-1))" p02958,s218662731,Wrong Answer,"N = int(input()) p = list(map(int,input().split())) s_p = sorted(p) cnt = 0 for i in range(N): if p[i] != s_p[i]: cnt += 1 if cnt//2 > 1: print(""NO"") else: print(""YES"")" p03359,s839842270,Wrong Answer,"a, b = map(int,input().split()) if a < b: print(a-1) else: print(a)" p03485,s862251020,Accepted,"a, b = map(int, input().split()) if (a+b)%2 == 1: print((a+b)//2+1) else: print((a+b)//2)" p02786,s167493931,Accepted,"def f(H): if H == 1: return 1 return 2 * f(H//2) + 1 def solve(): H = int(input()) print(f(H)) if __name__ == ""__main__"": solve()" p04019,s661648184,Accepted,"s = input() if 'N' in s and 'S' not in s: print('No') elif 'N' not in s and 'S' in s: print('No') elif 'W' in s and 'E' not in s: print('No') elif 'W' not in s and 'E' in s: print('No') else: print('Yes') " p02633,s091606756,Wrong Answer,"import math x=int(input()) if 360%x==0: print(360//x) else: print(x * 360 // math.gcd(x, 360))" p02831,s550489946,Accepted,"import fractions a,b=map(int,input().split()) gcd=fractions.gcd(a,b) print(a*b//gcd)" p02766,s943647197,Accepted,"import sys def main(): # sys.stdin = open('input156b.txt') n, k = map(int, input().split()) ans = 0 m = 1 while n >= m: m *= k ans += 1 print(ans) if __name__ == '__main__': main() " p02707,s494756912,Accepted,"n = int(input()) arr = [0] * n for i in input().split(): i = int(i) arr[i - 1] += 1 for i in range(n): print(arr[i])" p03282,s509898186,Accepted,"S = input() K = int(input()) one = 0 for s in S: if s==""1"": one+=1 else: ans = s break if K<=one: print(1) else: print(ans)" p02660,s906754086,Accepted,"from math import sqrt N = int(input()) M = N p=2 ans=0 while p <= sqrt(M): z = p while N % z == 0: N //= z z *= p ans += 1 while N % p == 0: N //= p p+=1 if N > 1: ans+=1 print(ans)" p02659,s428101304,Wrong Answer,"inputs = list(map(float, input().split())) multiple = inputs[0] * inputs[1] multiple_str = str(multiple) if '.' in multiple_str: print(multiple_str.split('.')[0]) else: print(multiple_str)" p02691,s791362023,Accepted,"n = int(input()) a = list(map(int, input().split())) d = {} for i, ai in enumerate(a): l = ai + i+1 if l in d: d[l] += 1 else: d[l] = 1 p = 0 for i, ai in enumerate(a): r = i+1 - ai p += d.get(r, 0) print(p)" p02701,s036095160,Accepted,"import collections n=int(input()) s=[] for _ in range(n): s.append(input()) c = collections.Counter(s) print(len(c))" p03243,s720461983,Accepted,"n = int(input()) for i in range(10): if n <= i*111: print(i*111) exit() " p04005,s191770587,Accepted,"a,b,c=map(int,input().rstrip().split(' ')) if(a%2==0 or b%2==0 or c%2==0): print(0) else: x=min(a*b,b*c,c*a) print(x)" p02641,s430668232,Accepted,"x, n = map(int, input().split()) p = [int(s) for s in input().split()] min_val = 101 for i in range(102): if i not in p: if abs(i - x) < min_val: min_val = abs(i - x) ans = i print(ans)" p02602,s221933085,Accepted,"n,k=map(int,input().split()) a=list(map(int,input().split())) for i in range(k,n): if a[i-k]= n : print(0) else: for x in range(k): enemy[x] = 0 print(sum(enemy)) " p03951,s528398338,Accepted,"n=int(input()) s=input() t=input() for i in range(n+1): if s[i:]==t[:n-i]: print(n+i) break" p04019,s972190786,Accepted,"s = input() x = False if 'N' in s and 'S' in s: x = True if 'N' not in s and 'S' not in s: x = True y = False if 'W' in s and 'E' in s: y = True if 'W' not in s and 'E' not in s: y = True if x and y: print('Yes') else: print('No') " p02726,s350761744,Accepted,"N,X,Y=map(int,input().split()) d=[0]*N for i in range(N): for j in range(N): if not i=m: ans-=data_i[0]*(buf-m) break print(ans)" p03494,s719210214,Wrong Answer,"n=int(input()) a=list(map(int, input().split())) for i in range(30): x=2**i res=0 for j in a: if j%x !=0: res=1 if res==1: print(i-1) break" p03030,s232070506,Accepted,"from collections import Counter N = int(input()) A = [] B = [] E = [] for i in range(N): l = list(input().split()) l[1] = int(l[1]) A.append(l) B.append(l[0]) E.append(l[1]) A.sort() C = Counter(B) C = sorted(C.items(), key=lambda x:x[0]) cnt = 0 for c in C: c = c[1] D = reversed(A[cnt:cnt+c]) cnt += c for d in D: print(E.index(d[1])+1)" p03328,s876481411,Accepted,"a, b = map(int, input().split()) diff = b - a su = 0 for i in range(1, diff+1): su += i print(su - b) " p02696,s275619542,Accepted,"a,b,n=map(int,input().split()) nb=n//b #xmax=0 if n x: c = b[i] - x if a[i+1] >= c: cnt += c if i+1 <= N-1: b[i+1] -= c else: cnt += c print(cnt) " p03077,s523593842,Wrong Answer,"capacity = [] for i in range(6): c = int(input()) capacity.append(c) stage = [capacity[0]] ans = 0 mn = capacity[0] for i in range(1,6): if capacity[i] < mn: ans += (mn//capacity[i]) + 1 mn = capacity[i] else: ans += 1 print(ans) " p02729,s122625956,Accepted,"n, m = map(int,input().split()) print(n*(n-1)//2 + m*(m-1)//2) " p04012,s215243134,Accepted,"from collections import defaultdict s=input() dd=defaultdict(lambda: True) for c in s: dd[c]=not dd[c] for k in dd: if not dd[k]: print(""No"") exit() print(""Yes"")" p02787,s248819833,Accepted,"h, n = map(int,input().split()) lst = [list(map(int,input().split())) for _ in range(n)] max_a = max(a for a, _ in lst ) 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 lst) print(min(dp[h:]))" p02694,s906058714,Accepted,"X = int(input()) n = 100 a = 0 while n < X: n = int(n * 1.01) a = a + 1 print(a)" p03073,s648668143,Accepted,"S = list(str(input())) count = 0 if S[0] == ""1"": for i, j in enumerate(S): if i % 2 == 0 and j == ""0"": count += 1 elif i % 2 == 1 and j == ""1"": count += 1 else: for i, j in enumerate(S): if i % 2 == 0 and j == ""1"": count += 1 elif i % 2 == 1 and j == ""0"": count += 1 print(count)" p02813,s041649534,Accepted,"N=int(input()) P=tuple(map(int,input().split())) Q=tuple(map(int,input().split())) import itertools l=list(itertools.permutations([i for i in range(1, N+1)])) print(abs(l.index(P)-l.index(Q))) " p02759,s268752337,Wrong Answer,"n = int(input()) if n%2 == 0: print(n/2) elif n%2 == 1: print(n/2+1) " p02909,s804741054,Accepted,"S = input() if S == 'Sunny': print('Cloudy') elif S == 'Cloudy': print('Rainy') else: print('Sunny')" p03761,s570433344,Wrong Answer,"def intersection(lst1, lst2): lst3 = [value for value in lst1 if value in lst2] return lst3 n = int(input()) s = [i for i in input()] for _ in range(n-1): s = intersection(s, input()) s.sort() if len(s) == 0: print('') else: print(''.join(s))" p02684,s679142456,Wrong Answer,"n,k = map(int,input().split()) a = list(map(int,input().split())) m = 1 for i in range(k%n): m = a[m-1] print(m) " p02570,s429761801,Accepted,"d,t,s = map(float,input().split()) if t >= d/s: print(""Yes"") else: print(""No"")" p03838,s375714696,Accepted,"from sys import stdin N,Y=list(map(int,stdin.readline().strip().split())) count=0 flag=False if abs(N)-abs(Y)==0: print(1) exit() if N>Y and abs(N)>abs(Y) or N>Y and N<0: count+=1 N*=-1 flag=True YY=abs(Y) NN=abs(N) ans=0 if YY>NN: ans=YY-NN else: ans=NN-YY N+=ans if Y==N: print(count+ans) else: print(count+ans+1)" p03417,s113600768,Accepted,"n,m = map(int, input().split()) if n > m: n,m = m,n if n==1 and m==1: print(1) elif n==1: print(m-2) elif n==2 or m==2: print(0) else: print((m-2)*(n-2)) " p03617,s423228880,Accepted,"Q, H, S, D = map(int, input().split()) n = int(input()) coffee = [[Q*4, 0.25, Q], [H*2, 0.5, H], [S, 1, S], [D/2, 2, D]] coffee_cost = sorted(coffee) cost = 0 Qt = n for i in range(4): cost += (round(Qt // coffee_cost[i][1]) * coffee_cost[i][2]) Qt = round(Qt % coffee_cost[i][1]) if Qt == 0: print(int(cost)) exit() " p02595,s203463172,Accepted,"import math ans = 0 n, d = map(int, input().split()) for i in range(n): x, y = map(int, input().split()) distance = math.sqrt(x**2 + y**2) if distance <= d: ans += 1 print(ans)" p03329,s487063205,Accepted,"n=int(input()) dp=[10**18]*(n+1) dp[n]=0 for i in range(5,0,-1): for j in range(n,0,-1): if j-9**i>=0: dp[j-9**i]=min(dp[j-9**i],dp[j]+1) for i in range(6,-1,-1): for j in range(n,0,-1): if j-6**i>=0: dp[j-6**i]=min(dp[j-6**i],dp[j]+1) pass print(dp[0])" p02753,s537881854,Wrong Answer,"s = input() if s == ""AAA"" or ""BBB"" : print(""No"") else: print(""Yes"")" p03075,s706344243,Wrong Answer,"L=[int(input()) for _ in range(5)] k=int(input()) if sum(L)<=k*5: print(""Yay!"") else: print("":("")" p02836,s472990212,Accepted,"S = list(input()) R = list(reversed(S)) ans = 0 for i in range(len(S)): if S[i] != R[i]: ans += 1 print(ans//2)" p03773,s143088225,Accepted,"a,b = (int(x) for x in input().split()) if (a+b)<24: print(a+b) else: print((a+b)%24)" p02613,s850396427,Accepted,"N=int(input()) A=[0,0,0,0] for i in range(N): a=input() if a=='AC': A[0]+=1 elif a=='WA': A[1]+=1 elif a=='TLE': A[2]+=1 else: A[3]+=1 print('AC x',A[0]) print('WA x',A[1]) print('TLE x',A[2]) print('RE x',A[3])" p03251,s840955408,Accepted,"n,m,x,y = map(int,input().split()) a = max([int(i) for i in input().split()]) b = min([int(i) for i in input().split()]) if a < b and x < a+1 <= y: print('No War') else: print('War')" p04005,s357176361,Accepted,"A, B, C = map(int, input().split()) import math Asmall = math.floor(A/2) Abig = A- Asmall Bsmall = math.floor(B/2) Bbig = B- Bsmall Csmall = math.floor(C/2) Cbig = C- Csmall print(min((Cbig-Csmall)*A*B, (Abig-Asmall)*C*B, (Bbig-Bsmall)*A*C))" p02924,s698125615,Accepted,"n = int(input()) if n == 1: print(0) else: print((n * (n-1)) // 2)" p03338,s991461919,Wrong Answer,"n = int(input()) s = input() w = set(s) t = 0 for i in w: if s.count(i) >= 2: t += 1 print(t)" p02660,s373341751,Accepted,"#!/usr/bin/env python3 from collections import Counter prime_factor = [] N = int(input()) for i in range(2,int(N**0.5)+1): while N % i == 0: prime_factor.append(i) N /= i if N > 1: prime_factor.append(N) c = Counter(prime_factor) cnt = 0 for k, v in c.items(): diff = 1 while v > 0: v -= diff if v >= 0: cnt += 1 diff += 1 print(cnt)" p03107,s386979669,Accepted,"S = input() m1 = S.count('0') m2 = S.count('1') print(2*min(m1,m2))" p02801,s298122573,Accepted,"c = input() print(chr(ord(c) + 1)) " p03485,s336068189,Accepted,"import math a, b = map(int, input().split()) print(math.ceil((a + b) / 2))" p02608,s202174950,Accepted,"n = int(input()) ans = [0 for i in range(10050)] for x in range(1, 105): for y in range(1, 105): for z in range(1, 105): f = x**2 + y**2 + z**2 + x*y + y*z + z*x if f < 10050: ans[f] += 1 for i in range(n): print(ans[i+1])" p02700,s573284127,Accepted,"tH,tA,aH,aA=map(int,input().split()) print(""Yes"") if (aH-1)//tA+1<=(tH-1)//aA+1 else print(""No"")" p03328,s233255139,Accepted,"a,b = map(int, input().split()) l = [1]*999 for i in range(1, 999): l[i] = l[i-1] + i+1 print(l[b-a-1]-b)" p03380,s020209460,Accepted,"import numpy as np N = int(input()) M, *A = sorted(map(int, input().split()), reverse=True) if N == 2: print(M, *A) quit() print(M, A[np.abs(np.array(A, dtype=np.int64) - M / 2).argmin()]) " p03986,s884864664,Accepted,"x = input() stack = [] for xx in x: if xx == ""T"": if len(stack) > 0: if stack[-1] == ""S"": stack.pop() else: stack.append(xx) else: stack.append(xx) else: stack.append(xx) print(len(stack)) " p02640,s665599522,Accepted,"X, Y = map(int, input().split()) A = (4*X-Y)/2 B = (Y-2*X)/2 if A%1 == 0 and X >= abs(A) and A>=0: print('Yes') elif B%1 == 0 and X >= abs(B) and B>=0: print('Yes') else: print('No')" p02924,s108564800,Wrong Answer,"def main(): n = int(input()) # for i in range(n-1): # ans += i+1 # print(ans) print(int(((n-1) * n) / 2)) if __name__ == '__main__': main()" p02729,s182357293,Accepted," def main(): n, m = list(map(int, input().split("" ""))) ans = 0 ans += n*(n-1)/2 ans += m*(m-1)/2 print(int(ans)) if __name__ == ""__main__"": main()" p02647,s621845084,Accepted,"# C - Lamps # imos法, 累積和 N, K = map(int, input().split()) A = list(int(a) for a in input().split()) for _ in range(K): B = [0] * (N+1) for i, a in enumerate(A): left = max(0, i-a) right = min(i+a+1, N) B[left] += 1 B[right] -= 1 for i in range(N): B[i+1] += B[i] B.pop() if A == B: break else: A = B print(' '.join(map(str, A))) " p03136,s639175499,Accepted,"n=int(input()) l =list(map(int,input().split())) a = max(l) if a < sum(l) - a: print('Yes') else: print('No')" p03041,s654323537,Accepted,"n,k = map(int,input().split()) s = str(input()) ans = """" for i in range(n): if(i==k-1): if(s[i]==""A""): ans+=""a"" elif(s[i]==""B""): ans+=""b"" else: ans+=""c"" else: ans+=s[i] print(ans)" p02555,s385952281,Accepted,"mod = (10 ** 9 + 7) tot = 1 l = [1, 0, 0] for i in range(2000): nex = (tot - l[-1] - l[-2]) % mod tot = (tot + nex) % mod l.append(nex) print(l[int(input())])" p04044,s065351155,Wrong Answer,"n,l = map(int,input().split()) s = [] for i in range(n): s.append(input()) sorted(s) print(''.join(s))" p03262,s018514586,Accepted,"import fractions n , x = map(int,input().split()) p = list(map(int,input().split())) ans = abs(x - p[0]) for i in range(n): ans = fractions.gcd(ans,abs( x - p[i] )) print(ans)" p03251,s047386811,Accepted,"N, M, X, Y = map(int, input().split()) x_list = list(map(int, input().split())) y_list = list(map(int, input().split())) x_max = max(x_list) y_min = min(y_list) for Z in range(X+1,Y+1): if x_max < Z <= y_min: print('No War') break else: print('War') " p03624,s617552545,Accepted,"def main(): S = input() lst = [False] * 26 for ch in S: lst[ord(ch) - ord(""a"")] = True for i in range(26): if lst[i] == False: print(chr(i + ord(""a""))) break else: print(""None"") if __name__ == ""__main__"": main()" p02772,s038792810,Wrong Answer,"N = int(input()) A = list(map(int,input().split())) for i in range(N): if A[i]%2 ==0 and (A[i]%3==0 or A[i]%5==0): print('APPROVED') else: print('DENIED') break break" p02623,s778573873,Accepted,"n,m,k = map(int,input().split()) a = list(map(int,input().split())) b = list(map(int,input().split())) ans = 0 A = [0]*(n+1) for i in range(n): A[i+1] = A[i] + a[i] B = [0]*(m+1) for i in range(m): B[i+1] = B[i] + b[i] j = 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) " p03417,s764624244,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))" p03160,s039802859,Accepted,"def chmin(a,b): if a>b: a = b return a def chmax(a,b): if a1 : dp[i] = chmin(dp[i],dp[i-2]+abs(h[i]-h[i-2]))#2個前から移動 print(dp[-1])" p03623,s060409598,Accepted,"x,a,b=map(int,input().split()) if abs(a-x) 1: ans += 1 print(ans)" p02707,s755501502,Wrong Answer,"n = int(input()) L = list(map(int,input().split())) M = [0]*n for i in range(n-1): M[L[i]-1] +=1 print(M)" p03386,s278099624,Accepted,"A,B,K=map(int,input().split()) tmp = set(range(A,min(B+1,A+K))) | set(range(max(A, B-K+1),B+1)) [print(s) for s in sorted(tmp)]" p02771,s891032427,Accepted,"A, B, C = list(map(int, input().split())) a = set([A, B, C]) if len(a) == 2: print(""Yes"") else: print(""No"") " p02724,s441936174,Accepted,"x = int(input()) happiness_point=0 while x>=500: happiness_point+=1000 x-=500 while x>=5: happiness_point+=5 x-=5 print(happiness_point)" p03073,s166172720,Wrong Answer,"import collections s = map(int,list(raw_input())) count = 0 for i in range(len(s) - 1): if s[i] == s[i + 1]: s[i] = 1- s[i] count +=1 print count " p03061,s262798892,Accepted,"n = int(input()) a = list(map(int, input().split())) a_ = list(reversed(a)) import fractions l = [a[0]] r = [a_[0]] for i in range(n): l.append(fractions.gcd(l[-1], a[i])) r.append(fractions.gcd(r[-1], a_[i])) #print(l) #print(r) s = [0]*n for i in range(n): if i == 0: s[i] = r[n-1] elif i == n-1: s[i] = l[n-1] else: s[i] = fractions.gcd(l[i], r[n-(i+1)]) #print(s) print(max(s))" p03555,s134826185,Wrong Answer,"#入力例は合うがWAになる a = input() b = input() # if [S[0],S[1],S[2]] == [T[2],T[1],T[0]]: if [a[2],a[1],a[0]] == [b[0],b[1],b[2]]: print(""Yes"") else: print(""No"")" p02630,s637366807,Wrong Answer,"n=int(input()) a=list(map(int,input().split())) q=int(input()) dic={} for i in range(len(a)): if a[i] in dic: dic[a[i]]+=1 else: dic.setdefault(a[i],1) answer=sum(a) for i in range(q): b,c=map(int,input().split()) if b not in dic: dic.setdefault(b,0) elif c not in dic: dic.setdefault(c,dic[b]) else: dic[c]+=dic[b] answer=answer+dic[b]*c-dic[b]*b print(answer)" p03293,s875732352,Accepted,"ni = lambda: int(input()) nm = lambda: map(int, input().split()) nl = lambda: list(map(int, input().split())) s = [_ for _ in input()] t = [_ for _ in input()] for i in range(len(s)): s = [s[-1]] + s[:-1] if s==t: print('Yes') exit() print('No')" p03013,s739323428,Wrong Answer,"N,M=map(int,input().split()) a=[0]*N for i in range(M): a[int(input())]=1 MOD = 1000000007 dp=[0]*(N+1) dp[0]=1 if 1 in a: dp[1]=0 else:dp[1]=1 for i in range(2,N+1): #n-1段目が安全なら if a[i-1]==0: dp[i]+=dp[i-1] #n-2段目が安全なら if a[i-2]==0: dp[i]+=dp[i-2] dp[i] = dp[i]%MOD print(dp[N])" p02836,s423046376,Accepted,"S = input() cnt = 0 for i in range(len(S)): if S[i]!=S[len(S)-1-i]: cnt += 1 print(cnt//2)" p03433,s656864738,Accepted,"a=int(input()) b=int(input()) if a%500 <= b: print('Yes') else: print('No') " p02613,s796977375,Accepted,"n = int(input()) t = {""AC"":0, ""WA"":1, ""TLE"":2, ""RE"":3} u = [""AC"", ""WA"", ""TLE"", ""RE""] ans = [0]*4 for _ in range(n): ans[t[input()]] += 1 for i in range(4): print(u[i], ""x"", ans[i])" p03495,s308671299,Wrong Answer,"from collections import Counter n, k = map(int, input().split()) A = Counter(list(map(int, input().split()))) B = sorted(A.items()) if len(A) > k: print(n-sum(B[i][1] for i in range(k))) else: print(0)" p02912,s363489356,Accepted,"import sys input=sys.stdin.readline #文字列入力はするな!! import heapq n,m=map(int,input().split()) a=list(map(int,input().split())) for i in range(n): a[i]*=-1 a=sorted(a) for i in range(m): h=-heapq.heappop(a) h=h//2 heapq.heappush(a,-h) print(-sum(a)) " p03339,s166946408,Accepted,"n = int(input()) a = list(input()) wcnt,ecnt,ans,box = 0,0,0,[] W = a.count(""W"") E = a.count(""E"") for i in range(n-1): if a[i] == ""W"": box.append(E+wcnt) wcnt += 1 W -= 1 else: box.append(E+wcnt) ecnt += 1 E -= 1 if a[n-1] == ""W"": W -= 1 box.append(E+wcnt) wcnt += 1 else: E -= 1 box.append(E+wcnt) ecnt += 1 print(min(box))" p02707,s096049859,Accepted,"n = int(input()) a = list(map(int,input().split())) a_0 = [0 for i in range(n)] for i in a: a_0[i-1]+=1 for i in a_0: print(i)" p02688,s788195556,Accepted,"def main(): N, K = list(map(int, input().split())) haved = [0] * N ans = 0 for i in range(1, K+1, 1): d = int(input()) ai = list(map(int, input().split())) for j in range(0, d, 1): x = ai[j] - 1 haved[x] = haved[x] + 1 for i in range(0, N, 1): if haved[i] == 0: ans = ans+1 print(ans) if __name__ == '__main__': main() " p03127,s378647821,Accepted,"def gcd(a, b): return a if b == 0 else gcd(b, a % b) N = int(input()) A = list(map(int, input().split())) ans = 0 for i in range(N): ans = gcd(ans, A[i]) print(ans) " p02779,s900873278,Accepted,"from collections import Counter import sys N = int(input()) A = [int(x) for x in input().split()] C = dict(Counter(A)) for a in C: if C[a] > 1: print('NO') sys.exit() print('YES')" p03814,s995499646,Accepted,"s = input() for i in range(len(s)): if s[i] == ""A"": l = i break for i in range(len(s)-1, -1, -1): if s[i] == ""Z"": r = i break print(r-l+1)" p02645,s445990557,Accepted,"s = input() print(s[0],end="""") print(s[1],end="""") print(s[2],end="""")" p02552,s791660296,Accepted,"n = int(input()) if n == 0: print(1) else: print(0)" p03069,s150129335,Accepted,"n=int(input());s=input() b=0 w=s.count('.') ans=w for si in s: b+=(si=='#') w-=(si=='.') ans=min(ans,b+w) print(ans)" p03239,s691316484,Accepted,"N,T=map(int, input().split()) C=[] for n in range(N): c,t=map(int,input().split()) if t<=T: C.append(c) print(""TLE"" if not C else min(C))" p03408,s945983788,Wrong Answer,"N=int(input()) s=[] for i in range(N): s+=[input()] M=int(input()) t=[] for i in range(M): t+=[input()] ans1=0 for i in range(len(set(s))): ans=s.count(s[i])-t.count(s[i]) ans1=max(ans1,ans) if ans1<0: print(0) exit() print(ans1)" p03778,s686285864,Accepted,"w,a,b = map(int, input().split()) print(0 if abs(a-b) <= w else abs(a-b)-w)" p03862,s857728209,Accepted,"def main(): N, x = map(int, input().split()) A = list(map(int, input().split())) cnt = 0 for i in range(1,N): tmp = A[i] + A[i-1] if tmp > x: tmp -= x cnt += tmp A[i] = max(0, A[i]-tmp) print(cnt) if __name__ == ""__main__"": main()" p03681,s667125876,Accepted,"from math import factorial a, b = [int(i) for i in input().split()] if abs(a-b) > 1: print(0) elif a == b: print((2 * factorial(a) * factorial(b)) % (10 ** 9 + 7)) else: print((factorial(max(a, b)) * factorial(min(a, b))) % (10 ** 9 + 7))" p02665,s320702380,Wrong Answer,"n = int(input()) *a, = map(int,input().split()) a.reverse() b = [a[0]] for i in range(1,n+1): b.append(b[-1] + a[i]) b.reverse() c = [0 for _ in range(n+1)]; c[0] = 1 ans = -1 for i in range(1,n+1): c[i] = min(c[i-1]*2,b[i]) c[i] -= a[i] if i < n and c[i] <= 0 or i == n and c[i] < 0: print(-1);exit() print(sum(c) + sum(a[1:])) " p02861,s275506986,Wrong Answer,"import math import sys input = sys.stdin.readline def main(): N = int(input()) POS = [list(map(int, input().split())) for i in range(N)] DIS = [[0]*(N) for _ in range(N)] M = 1 for i in range(1,N+1): M *= i for i in range(N): for j in range(N): DIS[i][j] = math.sqrt((POS[i][0] - POS[j][0])**2 +(POS[i][1] - POS[j][1])**2) print(sum(map(sum, DIS))*(N-1)/M) if __name__ == '__main__': main()" p03862,s580134889,Accepted,"N,x=map(int,input().split()) a=list(map(int,input().split())) ans=0 for i in range(1,N): tmp=a[i-1]+a[i] if tmp>x: ans+=tmp-x if a[i]>=tmp-x: a[i]-=tmp-x else: a[i]=0 print(ans)" p02697,s739060491,Accepted,"n, m = map(int, input().split()) if n%2 == 1: for i in range(m): print(m-i, m+1+i) else: for i in range(m): if 4*(i+1) > n: print(m-i, m+2+i) else: print(m-i, m+1+i)" p03062,s130345094,Accepted,"n = int(input()) a = list(map(int, input().split())) num_sum = 0 num_min = abs(a[0]) num_minus = 0 for i in range(n): if (a[i] <= 0): num_minus += 1 num_min = min(num_min, abs(a[i])) num_sum += abs(a[i]) if (num_minus % 2 == 0): print (num_sum) else: print(num_sum-num_min*2) " p03076,s925986461,Accepted,"X = [0] * 5 for c in range(5): ABC = input() X[c] = [int(ABC), int(ABC[-1])] if X[c][1] == 0: X[c][1] = 10 X[c].append(X[c][0]) else: X[c].append(X[c][0] + (10 - X[c][1])) X.sort(reverse=True, key=lambda val:val[1]) ans = sum([X[x][2] for x in range(4)]) + X[4][0] print(ans)" p02838,s336806745,Wrong Answer,"import sys input = sys.stdin.readline import numpy as np N=int(input().rstrip('\n')) A=np.array([int(x) for x in input().rstrip('\n').split()]) res = 0 for i in range(60): n = sum(A%2) A = A//2 t = 2**i res += n*(N-n)*t res = res%(7+10**9) if all(x==0 for x in A): break print(res)" p02664,s080584575,Accepted,"T = input() print(T.replace('?', 'D'))" p02786,s000693895,Accepted,"h=int(input()) #a,b,x=map(int,input().split()) #hl=list(map(int,input().split())) #l=[list(map(int,input().split())) for i in range(n)] i=0 count=1 while h>1: i+=1 count+=2**i h=h//2 print(count)" p02624,s851858392,Wrong Answer,"import numpy n=int(input('')) b=numpy.zeros((n+1,1),dtype=int) for a in range(1,n+1): c=0 while(1): if a+a*c<=n: b[a+a*c][0]+=1 c+=1 else: break q=[numpy.arange(0,n+1,dtype=int)] s=numpy.dot(q,b) print(s[0])" p02963,s983985679,Accepted,"s = int(input()) x = (10**9 - s%10**9)%10**9 y = (s+x)//10**9 print(0,0,10**9,1,x,y)" p03408,s522190314,Wrong Answer,"n=int(input()) s=[input() for i in range(n)] m=int(input()) t=[input() for i in range(m)] ans=[] for i in set(s): ans.append(s.count(i)-t.count(i)) print(max(ans))" p03329,s716747815,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) sorted(list, reverse=True) N=int(input()) count=0 for i in list: if i <= N: N=N-i count+=1 if N == 0: print(count)" p03485,s488124686,Accepted,"import math a,b = list(map(int,input().split())) print(math.ceil((a+b)/2)) " p02759,s060028398,Wrong Answer,"a=int(input()) b=a//2 if b==1: b=b+1 print(b)" p03494,s130293828,Wrong Answer,"N = int(input()) A = list(map(int,input().split())) n = 0 can = True while can: for i in range(N): if A[i]%2 == 0: A[i] = (A[i]/2) n += 1 else: can = False break print(n) " p03835,s118248653,Wrong Answer,"k,s= map(int,input().split()) ans=0 for i in range(k): for j in range(k): z=s-i-j if 0<=z<=k: ans+=1 print(ans) " p02732,s249203479,Accepted,"import sys #input = sys.stdin.readline def main(): n=int(input()) a=list(map(int,input().split())) l=[0]*(n+1) s=0 for i in range(n): l[a[i]]+=1 for i in range(n+1): if l[i]==0: continue else: s+=l[i]*(l[i]-1)//2 for i in range(n): print(s-(l[a[i]]-1)) if __name__ == '__main__': main()" p03998,s374282785,Accepted,"sa=list(input()) sb=list(input()) sc=list(input()) sa_rev=sa[::-1] sb_rev=sb[::-1] sc_rev=sc[::-1] turn=""a"" while True: if turn==""a"": if not sa_rev: print(""A"") break else: turn=sa_rev.pop() elif turn==""b"": if not sb_rev: print(""B"") break else: turn=sb_rev.pop() elif turn==""c"": if not sc_rev: print(""C"") break else: turn=sc_rev.pop() " p03323,s762997394,Accepted,"a,b=map(int,input().split()) if a>8 or b>8: print("":("") else: print(""Yay!"")" p02773,s615157822,Accepted,"n = int(input()) d = {} for i in range(n): s = input() if s in d: d[s] += 1 else: d[s] = 1 m = max(d.values()) ans = [] for k, v in d.items(): if v == m: ans.append(k) ans.sort() print(*ans, sep = ""\n"") " p02642,s102481752,Accepted,"from collections import Counter N = int(input()) A = list(map(int, input().split())) A.sort() ma = max(A) prime = [0 for i in range(ma)] for a in A: for j in range(a, ma+1, a): prime[j-1] += 1 cnt = 0 for i in A: if(prime[i-1] == 1): cnt += 1 print(cnt)" p02645,s404707820,Accepted,print(input()[:3]) p02760,s044490844,Wrong Answer,"A = [[0] * 3 for _ in range(3)] for i in range(3): A[i] = list(map(int, input().split())) N = int(input()) for _ in range(N): b = int(input()) for i in range(3): for j in range(3): if A[i][j] == b: A[i][j] = -1 ans = ""No"" for i in range(3): if A[i] == [-1] * 3 or A[:][i] == [-1] * 3: ans = ""Yes"" if [A[0][0], A[1][1], A[2][2]] == [-1] * 3 or [A[0][2], A[1][1], A[2], 0] == [-1] * 3: ans = ""Yes"" print(ans) " p02718,s198929614,Accepted,"n,m=map(int,input().split()) a=list(map(int,input().split())) a=sorted(a,reverse=True) total=sum(a) c=0 for i in a: if i>=(total/(4*m)): c+=1 if c==m: print('Yes') exit() print('No') " p02578,s915267642,Accepted,"N=int(input()) A=list(map(int, input().split())) c=0 for i in range(N-1): if A[i]>A[i+1]: c=c+(A[i]-A[i+1]) A[i+1]=A[i] print(c)" p03617,s333894148,Accepted,"q,h,s,d = map(int,input().split()) n = int(input()) print(min(q*n*4,h*n*2,s*n,(n//2)*d+(n%2)*s,(n//2)*d+(n%2)*h*2,(n//2)*d+(n%2)*q*4))" p03695,s221894655,Accepted,"N, = list(map(int,input().split())) a = list(map(int,input().split())) s = set() c6=0 for ai in a: if ai>=3200: c6 += 1 else: s |= set({ai//400}) print(max(1,len(s)),len(s)+c6)" p02660,s304105186,Accepted,"n = int(input()) r = 0 for p in range(2, int(n**0.5)+1): e = 0 while n%p == 0: e += 1 n /= p i = 1 while e >= i: e -= i r += 1 i += 1 if n != 1: r += 1 print(r) " p03250,s825570543,Accepted,"A,B,C = sorted(map(int,input().split()))[::-1] print(A*10+B*1+C)" p03759,s291758892,Accepted,"import sys input = sys.stdin.readline a,b,c = [int(i) for i in input().split()] if b - a == c - b : print(""YES"") else : print(""NO"")" p03379,s401889824,Accepted,"n=int(input()) a=list(map(int,input().split())) b=sorted(a) x=b[n//2-1] y=b[n//2] for i in a: if i<=x: print(y) else: print(x) " p02785,s730178820,Accepted,"N, K = map(int, input().split()) H = list(map(int, input().split())) H = sorted(H, reverse=True) print(sum(H[K:])) " p02848,s579248765,Accepted,"N = int(input()) S = input() new_S = '' alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ' for s in range (len(S)): for i in range(26): if (S[s] == alphabet[i]): new_S += alphabet[i+N] break print(new_S)" p03723,s168966155,Accepted,"a, b, c = map(int, input().split()) ans = 0 while True: if a%2==1 or b%2==1 or c%2==1: print(ans) break if a == b == c: print(-1) break s = a // 2 t = b // 2 u = c // 2 a, b, c = t+u, s+u, s+t ans += 1 else: print(ans)" p03293,s000266995,Accepted,"S = input() T = input() answer = False for i in range(len(S)): S = S[-1] + S[:-1] if S == T: answer = True if answer: print('Yes') else: print('No') " p02697,s892644097,Wrong Answer,"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() if m == 1: print(1,2) elif n%2 == 1: l = list(range(1,n//2+1))[::-1] # print(l) for i in l[:m]: print(i,n-i) else: for i in range(1,m): print(i,n-1) print(m,n//2) " p04044,s681391970,Accepted,"n,l = map(int, input().split()) print("""".join(sorted([input() for _ in range(n)])))" p02818,s708387070,Accepted,"A,B,K=map(int, input().split()) if A>=K: print(A-K, B) else: if A+B>=K: print(0,B-(K-A)) else: print(0,0)" p03627,s535437748,Accepted,"import collections n = int(input()) a = list(map(int,input().split())) a = collections.Counter(a) a = list(a.items()) a.sort(reverse=True) e1 = 0 e2 = 0 for i in range(len(a)): if a[i][1] >= 4 and e1 == 0: e1 = e2 = a[i][0] break elif a[i][1] >= 2: if e1 == 0: e1 = a[i][0] else: e2 = a[i][0] break print(e1*e2) " p03838,s315244584,Accepted,"x,y = map(int,input().split()) if x*y >= 0: if x == 0: if y < 0: print(1-y) else: print(y) elif y == 0: if x > 0: print(1+x) else: print(-x) elif x > y: print(2+x-y) else: print(y-x) else: if x >= -y: print(1+x+y) else: print(1-x-y)" p03835,s442485183,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 z >= 0 and k >= z: count += 1 print(count)" p03126,s203143942,Accepted,"n,m = map(int,input().split()) people = [list(map(int,input().split())) for _ in range(n)] matrix = [[ False for _ in range(n)] for _ in range(m)] #横が人,縦がしなもの for person_id in range(n): person = people[person_id] for konomi_num in person[1:]: matrix[konomi_num-1][person_id] = True ans = 0 for food in range(m): if all(matrix[food]): ans += 1 print(ans) " p02743,s304232385,Wrong Answer,"import math a,b,c=map(int,input().split()) if((math.sqrt(a)+math.sqrt(b))= 0 and i <= len(a): x -= a[i] if i == len(a)-1: if x != a[i]: break if x >= 0: count += 1 i += 1 print(count)" p02953,s981280849,Wrong Answer,"n = int(input()) h = list(map(int, input().split())) sv = h[n-1] ok = True for i in range(n-1): if h[i] - sv >= 2: ok = False if ok: print('Yes') else: print('No')" p03493,s602482293,Accepted,print(input().count('1')) p03478,s973154099,Accepted,"N,A,B = map(int, input().split()) counter = 0 for i in range(1,N+1): if A <= sum(map(int, str(i))) <= B: counter += i print(counter)" p04043,s999105536,Wrong Answer,"s = [int(i) for i in input().split(' ')] n = [0] * 2 for i in s: if i == 5: n[0] += 1 elif i == 7: n[1] += 1 if n[0] == 2 and n[1] == 1: print('Yes') else: print('No')" p02641,s408473568,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()] X, N = ri_() p = ri_() d = 1000 ans = 1000 for i in range(-500, 501): f = 1 for pi in p: if i == pi: f = 0 if f == 1 and d > abs(X - i): d = abs(X - i) ans = i print(ans)" p02645,s466755265,Accepted,"import sys def input(): return sys.stdin.readline().strip() sys.setrecursionlimit(20000000) MOD = 10 ** 9 + 7 INF = float(""inf"") def main(): S = input() print(S[:3]) if __name__ == ""__main__"": main() " p03208,s090512295,Accepted,"N,K=map(int,input().split()) L=[] for i in range(N): L.append(int(input().rstrip())) L.sort() M=[] for i in range(N-K+1): M.append(L[K+i-1]-L[i]) M.sort() print(M[0])" p03672,s248612448,Accepted,"# B - ss def main(): s = list(input()) for _ in range(len(s)): s.pop() if len(s) % 2 == 0: p = len(s)//2 if s[0:p] == s[p:]: print(len(s)) exit() if __name__ == ""__main__"": main()" p02607,s552068541,Wrong Answer,"N=int(input()) a=list(map(int,input().split())) ans=0 for i in range(N): if i%2!=0 and a[i]%2!=0: ans+=1 print(ans)" p03672,s489471379,Wrong Answer,"import sys S = input() for i in range(1, len(S)): s = S[:-i] l = len(s) // 2 if s[:l] == s[l:]: print(len(s)) " p02699,s124145937,Wrong Answer,"S, W = map(int, input().split()) if W >= S / 2: print('unsafe') else: print('safe')" p04030,s792377772,Accepted,"s = list(input()) result = [] for word in s: if word == 'B': if result != []: result.pop() else: result.append(word) print(''.join(result))" p03448,s909087651,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 x==500*i+100*j+50*k: ans+=1 print(ans) " p03474,s874614840,Accepted,"a, b = list(map(int, input().split())) s = list(input()) na = """".join(s[: a]).isdigit() nb = """".join(s[a + 1 :]).isdigit() hf = s[a] print(""Yes"") if na and nb and hf == ""-"" else print(""No"") " p03103,s530065080,Accepted,"N, M = map(int, input().split()) shops = [tuple(map(int, input().split())) for _ in range(N)] shops.sort() cost = 0 for shop in shops: value, amount = shop if amount < M: cost += value * amount M -= amount else: cost += value * M break print(cost) " p02792,s730004353,Accepted,"N = int(input()) c = [[0 for i in range(10)] for j in range(10)] for i in range(1,N+1): stri = str(i) c[int(stri[0])][int(stri[-1])] += 1 ans = 0 for i in range(1,10): for j in range(1,10): ans += c[i][j]*c[j][i] print(ans)" p02576,s871303125,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,x,t=mp() print(((n-1)//x+1)*t)" p02772,s070691586,Accepted,"n = int(input()) a = list(map(int,input().split())) tmp = 0 for i in range(n): if a[i]%2==0: if a[i]%3!=0 and a[i]%5!=0: tmp += 1 if tmp == 0: print('APPROVED') else: print('DENIED') " p02633,s307764101,Accepted,"X=int(input()) from math import gcd ans=360//gcd(X, 360) print(ans)" p02910,s803873413,Accepted,"S = input() for i in range(1, len(S)+1): if (i % 2 == 1 and S[i-1] == ""L"") or (i % 2 == 0 and S[i-1] == ""R""): print(""No"") exit() print(""Yes"") " p03627,s168747216,Wrong Answer,"from collections import Counter _, *lst = map(int, open(0).read().split()) stick = [i for i, j in Counter(lst).items() if j > 1] if len(stick) > 1: stick.sort() print(stick[-1] * stick[-2]) else: print(0) " p03456,s150145292,Accepted,"a,b=input().split() ab=int(a+b) ans=0 for i in range(350): if ab**(1/2)==i: print(""Yes"") ans+=1 quit() if ans==0: print(""No"")" p02820,s669494363,Accepted,"import sys input = sys.stdin.readline N, K = map(int, input().split()) R, S, P = map(int, input().split()) T = list(input()) P = {'s':R, 'p':S, 'r':P, 'N':0} score = 0 for i in range(N): if i + K < N: if T[i] == T[i + K]: T[i + K] = 'N' score += P[T[i]] print(score)" p02624,s686045867,Accepted," n = int(input()) ans = 0 for i in range(1,n+1): lim = n//i ans += lim*(lim+1)*i//2 print(ans) " p02678,s352429814,Accepted,"from collections import deque n, m = map(int, input().split()) rooms = [[] for i in range(n + 1)] for i in range(m): a, b = map(int, input().split()) rooms[a].append(b) rooms[b].append(a) q = deque() q.append(1) paths = [-1]*(n + 1) paths[1] = 0 while q: rnum = q.popleft() for i in rooms[rnum]: if paths[i] == -1: paths[i] = rnum q.append(i) print(""Yes"") for i in paths[2:]: print(i)" p02548,s239915907,Wrong Answer," #!/usr/bin/env python from typing import List def input_int() -> int: return int(input()) def input_list_int() -> List[int]: return list(map(lambda x: int(x), input().split())) def f(n: int) -> int: ans = 0 for a in range(1, n - 1): ans += (n - 1) // a return ans if __name__ == '__main__': n = input_int() print(f(n))" p02790,s419156621,Accepted,"a, b = map(int, input().split()) if a < b: print(str(a) * b) else: print(str(b) * a)" p03997,s305330973,Accepted,"a = int(input()) b = int(input()) h = int(input()) print((a+b) * h // 2) " p02714,s196359248,Accepted,"N = int(input()) S = input() r_num = S.count(""R"") g_num = S.count(""G"") b_num = S.count(""B"") cnt = 0 for i in range(N - 2): for j in range(i + 1, N - 1): if not 2 * j - i < N: break if S[i] != S[j] and (S[2 * j - i] != S[i] and S[2 * j - i] != S[j]): cnt += 1 ans = r_num * g_num * b_num - cnt print(ans) " p03285,s920143916,Accepted,"n = int(input()) for i in range(n//7 + 1): if (n - 7*i) % 4 == 0: print('Yes') exit() print('No')" p02688,s454650839,Wrong Answer,"N, K =map(int, input().split()) snuke = [0]*N for i in range(K): d = int(input()) a = list(map(int,input().split())) for j in range(d): snuke[j] = 1 print(snuke.count(0))" p02767,s069706591,Wrong Answer,"n = int(input()) x = list(map(int, input().split())) s = sum(x) p = (s+n-1)/n r = 0 for y in x: r += (y - p)**2 print(r)" p02571,s689167990,Wrong Answer,"S = input() T = input() counter_dict = {} for i in range(len(S)): counter = 0 for j in range(len(T)): if i + j < len(S): if S[i + j] == T[j]: counter += 1 if str(i) in counter_dict.keys(): if counter_dict[str(i)] < counter: counter_dict[str(i)] = counter else: counter_dict[str(i)] = counter max_counter = max(counter_dict.values()) print(len(T) - max_counter)" p02963,s279883388,Accepted,"from math import * s=int(input()) x1=ceil(sqrt(s)) if x1>10**9: x1-=1 y2=ceil(s/x1) if y2>10**9: y2-=1 x2=x1*y2-s print(0,0,x1,1,x2,y2)" p03282,s310318900,Accepted,"s = list(map(int, input())) k = int(input()) res = 1 n = 0 for i in range(len(s)): if s[i] != 1: res = s[i] n = i + 1 break if k < n: print(1) else: print(res) " p02694,s642250743,Accepted,"import math x = int(input()) a = 100 s = 0 for i in range(10**111): a = a + math.floor(a*0.01) s += 1 if a >= x: print(s) exit()" p02658,s849225721,Accepted,"n= int(input()) a= list(map(int,input().split())) ans=1 a.sort() for i in a: ans=ans* i if i==0: break if ans>10**18: break if ans > 10**18: print(""-1"") else: print(ans)" p02811,s549390682,Accepted,"import sys sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) K, X = lr() bl = 500 * K >= X print('Yes' if bl else 'No') # 35" p02547,s128751717,Accepted,"N = int(input()) d = [ list(map(int,input().split())) for i in range(N)] for i in range(N-2): if d[i][0] == d[i][1] and d[i+1][0] == d[i+1][1] and d[i+2][0] == d[i+2][1]: print(""Yes"") break else: print(""No"")" p02994,s854974256,Accepted,"# AtCoder Beginner Contest 131 # B - Bite Eating N,L=map(int,input().split()) minabs=10**9 apples=[] for i in range (N): t=L+i apples.append(t) if abs(t) int: nums = sorted((a, b, c)) nums[-1] = nums[-1] * 2 * k return sum(nums) def main(): a, b, c = map(int, input().split()) k = int(input()) print(answer(a, b, c, k)) if __name__ == '__main__': main() " p04045,s682315422,Wrong Answer," n, k = map(int, input().split()) d = list(input().split()) def validate(strNum): for i in range(0, len(strNum)): if strNum[i] in d: return False return True for i in range(0, 1001): tf = validate(str(n)) # print(tf) if tf: print(n) exit() n += 1 " p02707,s643541747,Accepted,"N = int(input()) A = list(map(int, input().split())) ans = [0]*N for i in A: ans[i-1] += 1 for i in ans: print(i)" p02786,s797866670,Accepted,"h = int(input()) cnt = 0 while h > 0: h //= 2 cnt += 1 ans = 1 cur = 1 for _ in range(1, cnt): cur *= 2 ans += cur print(ans)" p03633,s295746906,Wrong Answer,"import sys a = [] for l in sys.stdin: a.append(int(l)) ans=1 import fractions for i in range(len(a)): ans=a[i]*ans//fractions.gcd(a[i],ans) print(ans)" p03803,s765349545,Wrong Answer,"a, b = map(int, input().split()) if a > b: print(""Alice"") elif a == b: print(""Draw"") else: print(""Bob"")" p02995,s619129180,Wrong Answer,"from fractions import gcd a,b,c,d = map(int,input().split()) lcm = c*d/gcd(c,d) print(b - a + 1 - int(b/c) + int((a-1)/c) - int(b/d) + int((a-1)/d) + int(b/lcm) - int((a-1)/lcm))" p03030,s289665237,Accepted,"n=int(input()) l=[] for i in range(n): city,point = input().split() point=int(point) l.append([city,-point,i+1]) l=sorted(l, key = lambda x: (x[1])) l=sorted(l, key = lambda x: (x[0])) for i in range(n): print(l[i][2])" p02706,s065414888,Accepted,"n,m=map(int,input().split()) a=[int(j) for j in input().split()] sum=0 for i in range(0,m): sum+=a[i] diff=n-sum if(diff<0): print(-1) else: print(diff) " p03001,s582269616,Accepted,"#中心を通る時面積は二等分される #つまり大きくない方の面積の最大値はw*h/2 #x、yが中心の時面積を2等分する直線は無限に引くことができる #中心でない時、中心との結ぶ線は1本しか弾けない w,h,x,y=list(map(int,input().split())) if 2*x==w and 2*y==h: print(w*h/2,1) else: print(w*h/2,0)" p03105,s078295318,Accepted,"a,b,c=map(int,input().split()) print(min(b//a,c))" p02787,s319314455,Accepted,"def run(): H, N = map(int, input().split()) ab = [list(map(int, input().split())) for n in range(N)] dp = [float('inf')]*(H+1) for h in range(H+1): for n in range(N): a, b = ab[n] if h <= a: dp[h] = min(dp[h], b) else: dp[h] = min(dp[h], dp[h-a]+b) print(dp[-1]) if __name__ == '__main__': run()" p02820,s828163791,Accepted,"n, k = map(int, input().split()) r, s, p = map(int, input().split()) t = list(input().rstrip()) tb = {'r': p, 's': r, 'p': s} ans = 0 for i in range(len(t)): if i < k: ans += tb[t[i]] else: if t[i - k] == t[i]: t[i] = '-' else: ans += tb[t[i]] print(ans) " p02973,s798581708,Accepted,"from bisect import bisect_right N = int(input()) A = [int(input()) for i in range(N)] A = [-a for a in A] X = [] for a in A: i = bisect_right(X, a) if i == len(X): X.append(a) else: X[i] = a print(len(X)) " p03017,s927545143,Accepted,"N, A, B, C, D = map(int, input().split()) S = input() if '##' in S[A-1:max(C, D)]: print('No') elif C < D: print('Yes') else: print('Yes' if '...' in S[B-2:D+1] else 'No')" p03623,s261905070,Accepted,"def main(): x, a, b = map(int, input().split()) if abs(x-a) < abs(x-b): print(""A"") else: print(""B"") main() " p03380,s544048801,Wrong Answer,"N = int(input()) A = sorted(list(map(int, input().split()))) ai = max(A) half_maxA = ai // 2 + 1 for idx, a in enumerate(A): if idx == 0: aj = a else: if abs(a - half_maxA) < abs(aj - half_maxA): aj = a print(ai, aj) " p03385,s464097780,Accepted,"#!/usr/bin/env python3 S = input() if ""a"" in S and ""b"" in S and ""c"" in S: print(""Yes"") else: print(""No"")" p02909,s665439427,Wrong Answer,print('CRSlauoinunndyyy'[id(id)%3::3]) p02987,s358788648,Wrong Answer,"S=input() from collections import Counter c = Counter(list(S)) cnt = 0 for char in list(""abcdefghijklmnopqrstuvwxyz""): if c[char] == 2: cnt += 1 if cnt == 2: print(""Yes"") else: print(""No"")" p02640,s116696078,Accepted,"x,y = map(int,input().split()) for i in range(x+1): if 2*i + 4*(x-i) == y: print(""Yes"") exit() print(""No"")" p03360,s513074621,Accepted,"line = input() a = [int(n) for n in line.split()] k = int(input()) a.sort() largest = a[-1]*2 for i in range(k-1): largest = largest * 2 a[-1] = largest print(sum(a)) #k = int(input()) #z = a+b+x # #if x < a: # print(""NO"") #elif x > a+b: # print(""NO"") #elif x <= a+b: # print(""YES"") # " p02548,s234182729,Accepted,"N = int(input()) ans = 0 #N, K = map(int, input().split()) #A = list(map(int, input().split())) #flag = True for B in range(1, N+1): ans += N//B if N%B == 0: ans -= 1 #ans = 0 print(ans)" p02696,s585043523,Accepted,"import math def LI():return list(map(int,input().split())) a,b,n=LI() def f(x): ret=math.floor(a*x/b)-a*math.floor(x/b) return ret if n h[i+K-1]-h[i]: res = h[i+K-1]-h[i] print(res)" p03998,s286515554,Accepted,"a_cards = list(input()) b_cards = list(input()) c_cards = list(input()) cards_dict = {'a': a_cards, 'b': b_cards, 'c': c_cards} turn = 'a' while(True): if (cards_dict[turn] == []): print(turn.upper()) break; trush = cards_dict[turn][0] cards_dict[turn] = cards_dict[turn][1:] turn = trush" p03457,s779277445,Accepted,"n = int(input()) pre_t, pre_x, pre_y = 0, 0, 0 for i in range(n): t , x, y = map(int, input().split()) dt = t - pre_t dist = abs(x - pre_x) + abs(y -pre_y) if dist > dt or (dist+dt)%2 != 0: print(""\nNo"") exit() pre_t, pre_x, pre_y = t, x, y print(""Yes"")" p03371,s893730989,Accepted,"a,b,c,x,y = map(int,input().split()) if x < y: a, b, x, y = b, a, y, x print(min(a*x+b*y,2*c*y + a*(x-y),2*c*x))" p03076,s618701435,Wrong Answer,"arr = [0]*5 for i in range(5): arr[i] = int(input()) time = 0 for ar in arr: time += (-(-ar//10))*10 amari = [] for i in arr: amari.append(i%10) amari.sort() print(time - (10-amari[0]))" p04043,s094548118,Accepted,"seq = [int(s) for s in input().split()] if seq.count(5) == 2 and seq.count(7) == 1: print(""YES"") else: print(""NO"")" p02719,s468845277,Accepted,"N,K = map(int,input().split()) a = N%K b = abs(a-K) print(min(a,b))" p02699,s762733382,Wrong Answer,"s, w = map(int, input().split()) if s < 2 * w: print(""unsafe"") else: print(""safe"") " p03042,s737773596,Wrong Answer,"S = input() f, r = int(S[:2]), int(S[2:]) #print(f) #print(r) if f > 12 and 0 < r <= 12: ans = ""YYMM"" elif 0 < f <= 12 and r > 12: ans = ""MMYY"" elif 0 < r <= 12 and 0 < f <= 12: ans = ""AMBIGUOUS"" else: ans = ""NA"" print(ans) " p04005,s078758924,Accepted,"A,B,C = list(map(int,input().split())) ans = 0 if A % 2==1 and B%2==1 and C%2==1: listA = [A,B,C] listA.sort() print(listA[0]*listA[1]) else: print(0)" p02744,s450451969,Wrong Answer,"import itertools n = int(input()) l = [i for i in range(1, n+1)] alpha_dict = {} for i,c in enumerate(range(ord('A'),ord('Z')+1)): alpha_dict[i+1] = chr(c) ans = set() for v in itertools.combinations_with_replacement(l, n): m = min(v) diff = m - 1 tmp = """" for n in v: tmp += str(alpha_dict[n-diff].lower()) ans.add(tmp) ans = sorted(list(ans)) for v in ans: print(v) " p02548,s776969848,Accepted,"n=int(input())-1 ans=0 for i in range(1,n+1): ans+=n//i print(ans)" p02860,s572873271,Accepted,"icase=0 if icase==0: n=int(input()) s=input() if n%2==0: if s[0:n//2]==s[n//2:]: print(""Yes"") else: print(""No"") else: print(""No"")" p03241,s794374736,Accepted,"N, M = map(int, input().split()) d = 1 ds = [] while d ** 2 <= M: if M % d == 0: ds.append(d) ds.append(M // d) d += 1 ds.sort(reverse=True) for d in ds: if N * d <= M: print(d) break" p04029,s868072602,Accepted,"a=int(input()) b=int((a*(a+1))/2) print(b)" p04044,s614813165,Accepted,"n,l = map(int,input().split()) s = [input() for _ in range(n)] an = '' for _ in range(n): an += min(s) s.remove(min(s)) print(an)" p03069,s392682499,Accepted,"n = int(input()) s = input() ans = 0 init = True m = s.count('#') l = [0] * m idx = 0 for i in range(n): if s[i] == '#': l[idx] = i idx += 1 ans = m for i in range(m): ans = min(ans, i + (n - l[i] - 1 - (m - i - 1))) print(ans)" p03495,s718549535,Wrong Answer,"n,k=map(int,input().split()) a=list(map(int,input().split())) p=list(set(a)) ans=0 d=[] for i in range(len(p)): d.append(a.count(p[i])) if len(d)<=k: print(0) quit() d.sort() for i in range(k-1): ans+=d[i] print(ans)" p03730,s786700688,Wrong Answer,"import sys a, b, c = map(int, input().split()) flag = False for i in range(a, b*a+1, a): if i % b == c: flag = True print(""Yes"") if flag else print(""No"")" p04030,s249328965,Accepted,"#!/usr/bin/env python3 def solve(s): l = [] for c in s: if c == ""0"" or c == ""1"": l.append(str(c)) elif len(l): l.pop() return """".join(l) def main(): s = input() print(solve(s)) return if __name__ == '__main__': main() " p02957,s140615388,Wrong Answer,"A,B = map(int,input().split()) K = (A+B)/2 judge = isinstance(K, float) if judge: print(""IMPOSSIBLE"")" p03639,s630753719,Accepted,"import sys input = lambda: sys.stdin.readline().rstrip() n = int(input()) a = list(map(int, input().split())) f = 0 even = 0 odd = 0 for i in a: if i % 4 == 0: f += 1 elif i % 2 == 0: even += 1 else: odd += 1 even %= 2 if f - even - odd < -1: print('No') else: print('Yes') " p02706,s323858315,Wrong Answer,"n = int(input().split()[0]) print(max(0, n - sum(map(int, input().split()))))" p03239,s468980191,Accepted,"import math inf = float('inf') n, t = map(int, input().split()) c_t = [list(map(int, input().split())) for i in range(n)] min_c = inf for i in c_t: if i[1] <= t: min_c = min(min_c, i[0]) if min_c == inf: print(""TLE"") else: print(min_c)" p03494,s970253604,Accepted,"N = int(input()) A = list(map(int, input().split())) ans = 0 flag = True while flag: for a in A: if a % 2 != 0: flag = False if flag: A = [a // 2 for a in A] ans += 1 print(ans) " p03208,s727126878,Wrong Answer,"## C - Christmas Eve N, K = map(int, input().split()) H = sorted([int(input()) for i in range(N)]) rt = 10**9 for i in range(0,N-K): rt = H[K - 1 + i] - H[i] if rt > H[K - 1 + i] - H[i] else rt print(rt)" p03478,s570785140,Wrong Answer,"input_line = input() x, y, z = map(str, input_line.split()) print(x, y, z) resultNum = 0 for i in range(int(x)): loopCnt = len(str(i)) addNum = 0 for j in range(loopCnt): addNum += int(str(i)[j]) if int(y) <= addNum <= int(z): resultNum += i print(resultNum)" p02820,s796527955,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]==T[i+K]: T[i+K]=""0"" def win(c): if c==""r"": return p elif c==""s"": return r elif c==""p"": return s else: return 0 ans=0 for i in T: ans+=win(i) print(ans) " p02612,s091972838,Wrong Answer,"n = int(input()) if n < 1000: print(n) elif n % 1000 == 0: print(0) else: x = n // 1000 y = (x+1)*1000 print(y-n)" p02792,s452193454,Accepted,"N = int(input()) results = {(str(i), str(j)): 0 for i in range(1, 10) for j in range(1, 10)} for i in range(N+1): s = str(i) if (s[0], s[-1]) in results.keys(): results[(s[0], s[-1])] += 1 cnt = 0 for i in range(1, 10): for j in range(1, 10): cnt += results[(str(i), str(j))] * results[(str(j), str(i))] print(cnt)" p02973,s896228209,Accepted,"import sys from bisect import bisect_left input = sys.stdin.readline def main(): N = int(input()) A = [0] * N for i in range(N): A[i] = int(input()) colors = [] for a in A: idx = bisect_left(colors, a) if idx == 0: colors.insert(0, a) else: colors[idx - 1] = a ans = len(colors) print(ans) if __name__ == ""__main__"": main() " p02615,s654442769,Wrong Answer,"n = int(input()) L = list(map(int,input().split())) L = sorted(L,reverse=True) #print(L) cnf = 0 for i in range(1,n): cnf += L[i-1] #print(i,cnf) print(cnf)" p02790,s996706476,Accepted,"a, b = input().split() atxt = ''.join([a for _ in range(int(b))]) btxt = ''.join([b for _ in range(int(a))]) if atxt <= btxt: print(atxt) else: print(btxt) " p03319,s715687091,Accepted,"n,k=map(int,input().split()) a=list(map(int,input().split())) res=n for i in range(n): if a[i]==1: res=i break x=(res+k-2)//(k-1) y=(max([0,n-1-x*(k-1)])+k-2)//(k-1) print(x+y) " p02657,s971964210,Wrong Answer,"import sys A,B=list(map(int,sys.stdin.readline().split())) if A%2==0: print(A*B) else: print('k') " p03087,s062587346,Wrong Answer,"N, Q = map(int, input().split()) S = input() T = [0]*(N+1) for i in range(1, N): T[i+1] = T[i] + (1 if S[i-1:i+1]=='AC' else 0) ans = [] for _ in range(Q): l, r = map(int, input().split()) ans.append(T[r] - T[l]) print(T) print(*ans, sep='\n')" p02583,s819448699,Wrong Answer,"def findnumberofTriangles(arr,n): n = len(arr) arr.sort() count = 0 for i in range(0, n-2): k = i + 2 for j in range(i + 1, n): while (k < n and (arr[i]!=arr[j]!=arr[k]) and (arr[i] + arr[j] > arr[k])): k += 1 if(k>j): count += k - j - 1 return count N = int(input()) A = list(map(int,input().split())) print(findnumberofTriangles(A,N))" p03861,s364470694,Accepted,"a, b, x = map(int, input().split()) aa = (a-1) // x bb = b // x ans = bb-max(aa, 0) if a == 0: ans += 1 print(ans) " p03250,s261545100,Accepted,"a, b, c = list(map(int, input().split())) print(10 * max([a, b, c]) + sum([a, b, c]) - max([a, b, c])) " p02647,s513446064,Wrong Answer,"[n, k] = raw_input().split() a = raw_input().split() A = [] n = int(n) k = int(k) for i in a: A.append(int(i)) for i in range(k): t = [0] * n for j in range(n): for k in range(j - A[j], j + A[j] + 1): if k<0 or k>n-1: continue t[k] += 1 A = t[:] print A " p03145,s916224215,Accepted,"AB, BC, CB = map(int, input().split()) print(AB*BC//2) " p03759,s184350355,Accepted,"# 入力 a, b, c = map(int,input().split()) # 処理 if b - a == c - b: print('YES') else: print('NO')" p03319,s181075713,Accepted,"from math import ceil def main(): n, k = map(int, input().split()) a = list(map(int, input().split())) target = float(""inf"") target_index = [] for i in range(n): if a[i] < target: target = a[i] target_index.append(i) answer = float(""inf"") for t in target_index: answer = min(answer, ceil(t / (k - 1)) + ceil((n - t - 1) / (k - 1))) print(answer) if __name__ == '__main__': main() " p02608,s043000268,Wrong Answer,"import numpy as np N = int(input()) l = [] for x in range(1,101): for y in range(1,101): for z in range(1,101): fn = x**2 + y**2 + z**2 + x*y + y*z + z*x l.append(fn) for i in range(N+1): print(l.count(i)) " p02923,s038213514,Accepted,"n = int(input()) H = list(map(int, input().split())) counter = 0 max_counter = 0 for i in range(n-1): if H[i] >= H[i+1]: counter += 1 else: max_counter = max(max_counter, counter) counter = 0 else: max_counter = max(max_counter, counter) print(max_counter)" p03474,s710427857,Accepted,"a,b = list(map(int,input().split())) s =input() for i in range(a+b+1): if i == a: if s[i] !='-': print('No') break else: if s[i]=='-': print(""No"") break else: if int(s[i])<0 or 9= M: print(0) exit() q1 = [] for i in range(M - 1): sec = X[i + 1] - X[i] heappush(q1, -sec) ans = 0 for _ in range(N - 1): ans -= heappop(q1) print(X[-1] - X[0] - ans) " p03059,s102510720,Accepted,"A,B,T = map(int, input().split()) print(int((T+0.5)/A)*B)" p03555,s567698169,Wrong Answer,"up = list(input()) down = list(input()) up.reverse() if up == down: print('Yes') else: print('No') " p02744,s861563017,Accepted,"d = ['a','b','c','d','e','f','g','h','i','j'] n = int(input()) result = [] def fig(s, mx): if len(s) == n: result.append(s) return for i in range(mx+1): if i == mx: mx += 1 fig(s + d[i], mx) fig('', 0) result.sort() for r in result: print(''.join(r)) " p03456,s967081151,Accepted,"import numpy as np a, b = input().split() c = int(a+b) if((np.sqrt(c)).is_integer() == True): print(""Yes"") else: print(""No"")" p02862,s720668350,Wrong Answer,"from functools import lru_cache MOD = 10**9+7 x,y = list(map(int, input().split())) a = (2*x - y) // 3 b = (2*y - x) // 3 if a == b == 0: print(0) exit() @lru_cache(maxsize=None) def fact(x): f = 1 for i in range(2, x+1): f *= i f %= MOD return f def fact_inv(x): return pow(fact(x), MOD-2, MOD) ans = fact(a+b) * fact_inv(a) * fact_inv(b) % MOD print(ans)" p03457,s065752519,Accepted,"n = int(input()) t=[0] x=[0] y=[0] for i in range(n): t_inp,x_inp,y_inp=(int(x) for x in input().split()) t.append(t_inp) x.append(x_inp) y.append(y_inp) flag=True for i in range(1,n+1): dt=t[i]-t[i-1] dist=abs(x[i]-x[i-1])+abs(y[i]-y[i-1]) if dt 1: for prime in primes: if p % prime == 0: continue primes.append(p) ans += 1 while C % p == 0: C //= p p += 2 print(ans)" p02730,s731570628,Wrong Answer,"S=list(input()) N=len(S) def circle_judge(S,N): circle=True for n in range((N-1)//2): if S[n]!=S[N-1-n]: circle=False break return circle def main(): circle=circle_judge(S,N) if circle==True: S_h=S[:(N-1)//2] if len(S_h)%2==0: circle=False else: circle=circle_judge(S_h,(N-1)//2) return circle result=main() if result==True: print('Yes') elif result==False: print('No')" p02866,s717367899,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()): 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)" p03679,s357152211,Wrong Answer,"x,a,b=map(int,input().split()) ans=b-a if ans>=x+1: print('dangerous') elif 0<=ans<=x: print('safe') else: print('delicious')" p03262,s556006382,Accepted,"import fractions n, y = map(int,input().split()) x = list(map(int,input().split())) x.append(y) x.sort() d = [] for i in range(n): d.append(x[i+1]-x[i]) if len(d) !=1: ans = fractions.gcd(d[0],d[1]) for i in range(n-1): ans = fractions.gcd(ans,d[i]) print(ans) else: ans = d[0] print(ans)" p02917,s860712202,Accepted,"import math from collections import defaultdict,deque #from itertools import permutations ml=lambda:map(int,input().split()) ll=lambda:list(map(int,input().split())) ii=lambda:int(input()) ip=lambda:list(input()) ips=lambda:input().split() """"""========main code==============="""""" n=ii() a=ll() lol=[] lol.append(a[0]) for i in range(1,n-1): lol.append(min(a[i-1],a[i])) lol.append(a[n-2]) print(sum(lol))" p04031,s982107110,Wrong Answer,"n = int(input()) arr = list(map(int, input().split())) arr.sort() hoge = [x for x in range(arr[0], arr[-1]+1)] if len(arr) == 1: print(0) exit() a = hoge[len(hoge)//2] b = hoge[len(hoge)//2-1] min_cost = 1 << 60 cost = 0 for i in arr: cost += (i-a)**2 min_cost = min(min_cost, cost) for i in arr: cost += (i-b)**2 min_cost = min(min_cost, cost) print(min_cost)" p03013,s398512080,Accepted,"N, M = map(int, input().split()) a = set([int(input()) for _ in range(M)]) INF = 1000000007 dp = [0] * (N + 1) dp[0] = 1 if 1 not in a: dp[1] = 1 else: dp[1] = 0 for i in range(2, N + 1): if i in a: continue dp[i] = dp[i - 1] + dp[i - 2] dp[i] %= INF print(dp[N])" p04019,s532703958,Accepted,"S = list(input()) flag = 1 if ""S"" in S: if not(""N"" in S): flag = 0 if ""N"" in S: if not(""S"" in S): flag = 0 if ""E"" in S: if not(""W"" in S): flag = 0 if ""W"" in S: if not(""E"" in S): flag = 0 if flag: print(""Yes"") else: print(""No"") " p03455,s459375459,Accepted,"a, b = map(int, input().split()) if a * b % 2 == 1: print('Odd') else: print('Even')" p02553,s663161820,Accepted,"s = input() nums = s.split() a = int(nums[0]) b = int(nums[1]) c = int(nums[2]) d = int(nums[3]) print(max(a*c,a*d,b*c,b*d))" p03379,s167924977,Accepted,"N = int(input()) A = list(map(int,input().split())) B = sorted(A) ans1 = B[N // 2 - 1] ans2 = B[N // 2] for i in range(N): if A[i] > ans1: print(ans1) else: print(ans2)" p02759,s983012240,Accepted,"import math X = int(input()) Y = X/2 print(math.ceil(Y)) " p03998,s069473842,Accepted,"sa = list(input()) sb = list(input()) sc = list(input()) n = ""a"" while True: if n == ""a"": if len(sa) == 0: print (""A"") exit () n = sa.pop(0) elif n == ""b"": if len(sb) == 0: print (""B"") exit () n = sb.pop(0) else: if len(sc) == 0: print (""C"") exit () n = sc.pop(0) " p02958,s982241183,Wrong Answer,"n = int(input()) p = list(map(int, input().split())) count = 0 flag = True for i in range(n): if p[i] != i+1: index = n-i-1 if p[index] == n-i: count += 1 else: flag = False break if flag: if count <= 1: print(""YES"") else: print(""NO"")" p02731,s371173720,Wrong Answer,"def resolve(): L = int(input()) ans = float(0) for x in range(1, L): for y in range(1, L-x): x = float(x) y = float(y) z = float(L) - x - y ans = max(ans, x*y*z) print(ans) if __name__ == '__main__': resolve()" p03773,s208566687,Accepted,"a, b = map(int, input().split()) print((a + b) % 24) " p02939,s829408039,Wrong Answer,"s = list(input()) n = len(s) lst = [] lst.append(s[0]) i = 1 while i < n: if s[i-1] != s[i]: lst.append(s[i]) i += 1 else: lst.append(s[i-1] + s[i]) i += 2 print(len(lst)) " p04031,s956283722,Accepted,"n = int(input()) A = list(map(int,input().split())) ans = [0]*201 for a in A: for i in range(201): ans[i] += (i-100 - a)**2 print(min(ans)) " p03625,s717461609,Accepted,"import sys import itertools sys.setrecursionlimit(1000000000) from heapq import heapify,heappop,heappush,heappushpop import math import collections n = int(input()) a = list(map(int,input().split())) c = collections.Counter(a) li2 = [0,0] li4 = [0] for key,value in c.items(): if value>=4: li4.append(key) elif value>=2: li2.append(key) li2.sort() li4.sort() ans1 = li2[-1]*li2[-2] ans2 = li4[-1]**2 ans3 = li4[-1]*li2[-1] ans = max(ans1,ans2) ans = max(ans,ans3) print(ans) " p03284,s097946515,Accepted,"n,k = map(int,input().split()) if n % k == 0: print(0) else: print(1)" p02899,s220880927,Accepted,"N = int(input()) a = list(map(int,input().split())) A = [] for i in range(N): A.append([a[i],i+1]) A.sort() for j in range(len(A)): print(A[j][1],end =' ') " p02627,s828069093,Accepted,"#A alpha = input() large = [""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""] if alpha in large: print(""A"") else: print(""a"")" p02780,s932371005,Accepted,"N, K= map(int,input().split()) p = list(map(int,input().split())) e = [(pi+1)/2 for pi in p] f = sum(e[:K]) ans = f for i in range(K,N): f = f - e[i-K] + e[i] ans = max(ans,f) print(ans) " p03380,s274560192,Accepted,"n = int(input()) A = sorted(map(int, input().split())) diff = float(""inf"") ans = 0 for a in A[:-1]: d = abs(a - A[-1] / 2) if d < diff: ans = a diff = d print(A[-1], ans) " p02571,s987697518,Accepted,"S=input();T=input() N=len(S);NP=len(T);M=len(T) for i in range(N-M+1): cnt=0 for j in range(M): if T[j]==S[j+i]:cnt+=1 if NP>M-cnt: NP=M-cnt print(NP)" p03639,s848594820,Wrong Answer,"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 + 1 if num_two >= 2: v += num_two ans = 'Yes' if v >= N else 'No' print(ans) # 2 2 2 2 o 4 o 4 o 4 ... o 4 o " p03131,s539711097,Accepted,"step,pay,gain=map(int,input().split()) b=step-pay+1 print(max(step+1,pay+b//2*(gain-pay)+b%2)) " p03617,s339471403,Accepted,"q,h,s,d = map(int, input().split()) n = int(input()) ans = 0 print(min(q * 8, h * 4, s * 2, d) * (n // 2)+min(q * 4, h * 2, s) *(n%2==1)) " p02690,s777342285,Accepted,"X =int(input()) b =False for x in range(-1000,1000): for y in range(-1000,1000): if (x**5)-(y**5)==X: print(x,y) b=True if b==True: break" p02785,s469389682,Wrong Answer,"# -*- coding: utf-8 -*- # Input s = [input() for i in range(2)] NK = list(s[0].split()) HI = list(s[1].split()) HI.sort(reverse=True) # Proccess survibe_monster = int(NK[0])-int(NK[1]) killed_monster = int(NK[1]) del HI[:killed_monster] how_many_attack = 0 for i in range(survibe_monster): how_many_attack = how_many_attack + int(HI[i]) # Output                    print(how_many_attack) " p03109,s417830808,Accepted,"y, m, d = map(int, input().split(""/"")) if m < 4: print(""Heisei"") elif m == 4 and d <= 30: print(""Heisei"") else: print(""TBD"")" p03136,s474126192,Accepted,"n = int(input()) l = list(map(int, input().split())) print(""Yes"" if max(l) < sum(l) - max(l) else ""No"") " p02958,s929834526,Accepted,"n = int(input()) p = list(map(int, input().split())) l = [] for i in range(n): p[i] -= 1 if p[i] != i: l.append([i, p[i]]) if len(l) == 0: print('YES') elif len(l) == 2 and l[0][1] == l[1][0] and l[0][0] == l[1][1]: print('YES') else: print('NO')" p02647,s428064285,Accepted,"from itertools import accumulate N, K = map(int, input().split()) A = list(map(int, input().split())) def calc_imos(arr): imos = [0] * (N + 1) for i, a in enumerate(arr): l = max(0, i - a) r = min(N - 1, i + a) imos[l] += 1 imos[r + 1] -= 1 imos = list(accumulate(imos)) return imos[:-1] for k in range(min(50, K)): A = calc_imos(A) print(*A, sep=' ')" p03479,s401433675,Wrong Answer,"import math x, y = map(int, input().split()) print(int(math.log2(y/x-0.0001) + 1))" p03699,s675017337,Wrong Answer,"N = int(input()) S = [int(input()) for _ in range(N)] S.sort() res = sum(S) i = 0 while i < N and res % 10 == 0: res -= S[i] i += 1 print(res) " p03612,s654423972,Accepted,"N = int(input()) p = list(map(int, input().split())) ans = 0 i = 1 while i <= N: if p[i - 1] == i: ans += 1 i += 2 else: i += 1 print(ans) " p02767,s059447490,Accepted,"N = int(input()) X = list(map(int, input().split())) ans = 10**9 for i in range(0, 101): tmp = 0 for x in X: tmp += (x - i)**2 ans = min(tmp, ans) print(ans) " p02633,s876396028,Accepted,"import math n=int(input()) print(int(n*360/math.gcd(n,360)/n))" p04029,s273522620,Accepted,"n = int(input()) ans = 0 for i in range(n+1): ans += i print(ans)" p02630,s092751861,Accepted,"import heapq n = int(input()) a = [int(i) for i in input().split()] q = int(input()) bc = [[int(i) for i in input().split()] for j in range(q)] dp = [0 for _ in range(100001)] for i in a: dp[i] += 1 total = sum(a) for i in range(q): total += (bc[i][1] - bc[i][0]) * dp[bc[i][0]] print(total) dp[bc[i][1]] += dp[bc[i][0]] dp[bc[i][0]] = 0" p02696,s174247476,Accepted,"a,b,n = map(int,input().split()) def floor(a,b,x): return a*x//b - a*(x//b) if n < b: print(floor(a,b,n)) else: print(floor(a,b,b-1))" p02971,s603247463,Accepted,"n = int(input()) a = [int(input()) for i in range(n)] sorted_list = sorted(a, reverse=True) a_max = sorted_list[0] a_sec = sorted_list[1] for i in range(n) : if a[i] != a_max : print(a_max) else : print(a_sec) " p02729,s155311693,Accepted,"#!/usr/bin/env python def main(): n, m = map(int, input().split()) ret = n * (n - 1) // 2 ret += m * (m - 1) // 2 print(ret) if __name__ == '__main__': main() " p03309,s849058658,Accepted,"n = int(input()) l = list(map(int, input().split())) ls = [0]*n sum = 0 for i in range(n): ls[i] = l[i] - (i+1) ls.sort() med = ls[n//2] for i in ls: sum += abs(i - med) print(sum)" p02665,s740875686,Accepted,"n,*a=map(int,open(0).read().split());t=sum(a);v=w=1 print(sum([1]+[exit(print(-1)) if(w:=min(2*(w-q),t:=t-q))<0 else w for q in a]))" p02862,s989923579,Wrong Answer,"def main(): MOD = 10 ** 9 + 7 X, Y = map(int, input().split()) if (X + Y) % 3: print(0) return a = (X * 2 - Y) // 3 b = X - a * 2 def choose(n, a, mod): x, y = 1, 1 for i in range(a): x = x * (n - i) % mod y = y * (i + 1) % mod return x * pow(y, mod - 2, mod) % mod ans = choose(a + b, min(a, b), mod=MOD) print(ans) if __name__ == '__main__': main() " p03435,s701467850,Accepted,"from itertools import permutations def main(): grid = [] num_sum = 0 for _ in range(3): tmp = list(map(int, input().split("" ""))) num_sum += sum(tmp) grid.append(tmp) num_sum //= 3 index_list = permutations([0, 1, 2]) answer = ""Yes"" for index in index_list: if not grid[0][index[0]] + grid[1][index[1]] + grid[2][index[2]] == num_sum: answer = ""No"" break print(answer) if __name__ == '__main__': main()" p03639,s717234140,Accepted,"N = int(input()) A = [int(a) for a in input().split()] cnt = 0 c2 = 0 c4 = 0 for a in A: if a%4 == 0: c4 += 1 elif a%2 == 0: c2 += 1 else: cnt += 1 if c4 >= cnt or (c2 == 0 and c4+1 == cnt): ans = ""Yes"" else: ans = ""No"" print(ans)" p03407,s105896341,Accepted,"a, b, c = map(int,input().split()) if a + b < c: print(""No"") else: print(""Yes"")" p02647,s021309507,Wrong Answer,"N, K = list(map(int, input().split())) A = list(map(int, input().split())) #累積和 B = [0]*N for _ in range(K): 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 A[0] = 0 for i in range(1,N): A[i] = 0 B[i] += B[i-1] if min(B) == N: break B, A = A, B print(*A) " p03162,s394271252,Accepted,"n = int(input()) dp = [[0 for _ in range(3)] for _ in range(n)] dp[0][0],dp[0][1],dp[0][2] = map(int,input().split()) for i in range(1,n): abc = map(int,input().split()) for j,v in enumerate(abc): for k in range(3): if j != k: dp[i][j] = max(dp[i][j],dp[i-1][k] + v) print(max(dp[n-1])) " p02700,s276737647,Wrong Answer,"nums = [int(e) for e in input().split()] if nums[2]%nums[1] == 0: A = nums[2]%nums[1] else: A = nums[2]%nums[1] + 1 if nums[0]%nums[3] == 0: T = nums[0]%nums[3] else: T = nums[0]%nums[3] + 1 if A <= T: print('Yes') else: print('No')" p02627,s305297409,Accepted,"N = input() m = N.upper() if N == m: print('A') else: print('a')" p02707,s261778012,Wrong Answer,"s = input().split() n = int(s[0]) s = input().split() d = [0]*n print(d) for i in s: d[int(i)-1]+=1 for i in range(n): print(d[i])" p03001,s710222232,Accepted,"w, h, x, y = map(int, input().split()) str1 = f'{w * h / 2:.09f}' str2 = '1' if w == x * 2 and h == y * 2 else '0' print(' '.join([str1,str2]))" p02859,s771588316,Accepted,"r = int(input()) print(r ** 2)" p02989,s296900506,Accepted,"n = int(input()) l = list(map(int,input().split())) l.sort() print(l[n//2]-l[n//2-1]) " p03524,s326044229,Accepted,"s=input() from collections import Counter sc=Counter(s) for a in sc: if sc[a]>(len(s)+2)//3: print(""NO"") exit() print(""YES"") " p03073,s928946852,Wrong Answer,"S = list(input()) res = 0 for i in range(1, len(S)): if S[i] == S[i-1]: res += 1 S[i] = ""0"" if int(S[i]) else ""1"" print(""S"") print(res) " p03241,s846705981,Accepted,"import sys 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] N,M=map(int,input().split()) c=M//N L=make_divisors(M) L=list(reversed(L)) for i in range(len(L)): if L[i]<=c: print(L[i]) sys.exit()" p03030,s744890584,Accepted,"N = int(input()) shops = [] for i in range(N): S, P = input().split() shops.append([S, int(P), i+1]) shops.sort(key=lambda x: x[1], reverse=True) shops.sort(key=lambda x: x[0]) for shop in shops: print(shop[2])" p02861,s324026779,Accepted,"N =int(input()) p = [list(map(int,input().split())) for _ in range(N)] import itertools,math ptr = list(itertools.permutations(range(N),N)) def dist(p1,p2): return math.sqrt((p1[0]-p2[0])**2+(p1[1]-p2[1])**2) total = 0 for pt in ptr: for i in range(len(p)-1): total += dist(p[pt[i]] ,p[pt[i+1]]) print(total/len(ptr)) " p02684,s208002444,Accepted,"n,k,*a=map(int,open(0).read().split()) a=[0]+a ans=1 while k: if k&1: ans=a[ans] a=[a[i] for i in a] k>>=1 print(ans)" p02595,s838895876,Accepted,"import math N,D = input().split() N = int(N) D = int(D) xylist = [input() for i in range(N)] cnt = 0 for xy in xylist: x = int(xy.split()[0]) y = int(xy.split()[1]) xy2 = x*x + y*y len = math.sqrt(xy2) if len <= D: cnt = cnt + 1 print(cnt)" p03524,s509549345,Accepted,"s=input() n=len(s) a,b,c=s.count(""a""),s.count(""b""),s.count(""c"") ma=max(a,b,c) mi=min(a,b,c) if ma-1<=mi:print('YES') else:print('NO')" p02578,s646745377,Accepted,"N = int(input()) A = list(map(int,input().split())) ans = 0 for i in range(1,N): if A[i] < A[i-1]: ans += A[i-1]-A[i] A[i] = A[i-1] print(ans)" p02724,s941914174,Wrong Answer,"X = int(input()) total = 0 C = 0 D = 0 while True: if X > 500: C = X // 500 P = 500 * C X = X - P elif X > 5: D = X // 5 L = 5 * D X = X - L else: break total = (1000 * C) + (5 * D) print(total) print()" p04044,s903754926,Accepted,"N,L=map(int,input().split()) S=[input() for i in range(N)] s=sorted(S) [print(i,end="""") for i in s] " p03435,s198535643,Wrong Answer,"c =[[],[],[]] c[0] = [int(x) for x in input().split("" "")] c[1] = [int(x) for x in input().split("" "")] c[2] = [int(x) for x in input().split("" "")] a=[0,0,0] b=[0,0,0] result = ""No"" cnt = 0 for i in range(0,3): for j in range(0,i): for a[i] in range(0,101): for b[j] in range(0,101): if c[i][j] == a[i]+b[j]: cnt +=1 if cnt == 6: result = ""Yes"" print(result) " p02947,s907925750,Accepted,"from collections import defaultdict n=int(input()) s=["""".join(sorted(input())) for _ in range(n)] d = defaultdict(int) for a in s: d[a]+=1 c=0 for a in d.values(): if a>1: c+=a*(a-1)//2 print(c)" p03339,s840316669,Accepted,"def resolve(): n = int(input()) S = list(input()) min_c = n count_e = S.count('E') count_w = 0 for s in S: if s == 'E': count_e -= 1 min_c = min(min_c, count_e + count_w) if s == 'W': count_w += 1 print(min_c) if __name__ == '__main__': resolve() " p02701,s613152922,Accepted,"N = int(input()) keihinList=set() for i in range(N): keihinList.add(input()) print(len(keihinList) )" p03338,s072403287,Accepted,"N = int(input()) S = list(input()) cnt = [0] for i in range(N): S1 = set(S[:i+1]) S2 = set(S[i+1:]) cnt.append(len(S1&S2)) max_cnt=max(cnt) print(max_cnt)" p02708,s824039963,Accepted,"n,k=map(int,input().split()) mod=10**9+7 ans=0 for i in range(k,n+2): ans+=i*(2*n-i+1)//2-i*(i-1)//2+1 print(ans%mod)" p03994,s182899092,Accepted,"s = input() k = int(input()) for i in range(len(s)): if s[i] != ""a"": req = ord(""z"") - ord(s[i]) + 1 if req <= k: k -= req s = s[:i] + ""a"" + s[i+1:] if k > 0: s = s[:-1] + chr(ord(s[-1]) + k%26) print(s)" p03778,s568847783,Accepted,"def resolve(): w, a, b = map(int, input().split()) a1 = a a2 = a + w b1 = b b2 = b + w ans = 0 if a2 < b1: ans = b1 - a2 elif b2 < a1: ans = a1 - b2 else: ans = 0 print(ans) resolve()" p02924,s039245655,Accepted,"N = int(input()) print((N-1)*N//2)" p02681,s368929963,Wrong Answer,"S = input() T = input() add = len(T) #print(add) if len(S) > 10 or len(S) < 2: print(""No"") exit() if S != T[:int(len(T)-1)]: print(""No"") exit() if len(S)+1 != len(T): print(""No"") exit() for i in range(len(T)): if T[i] not in ""abcdefghijklmnopqrstuvwxyz"": print(""No"") exit() else: pass print(""yes"") " p02696,s711440503,Accepted,"a,b,n=map(int,input().split()) x=min(b-1,n) print((a*x)//b)" p02693,s864048269,Wrong Answer,"k=int(input()) a,b =map(int,input().split()) adiv =a//k if k*(adiv+1)<=b: print('OK') elif b%k==0 : print('OK') else: print('NG')" p03448,s950561171,Wrong Answer,"A=int(input()) B=int(input()) C=int(input()) X=int(input()) count=0 for i in range(A): for j in range(B): for k in range(C): if 500*A+100*B+50*C==X: count+=1 else: pass print(count)" p02731,s093275193,Wrong Answer,print(float(input()) / 3 ** 3) p02924,s374502828,Accepted,"N = int(input()) if((N-1)%2==0): print(N*((N-1)//2)) else: print(N*((N-1)//2) + N//2 ) " p02676,s218020547,Accepted," n = int(input()) s = input() if len(s) <= n: print(s[:n]) else: print(s[:n]+""..."")" p03323,s514963511,Accepted,"A, B = map(int, input().split()) if A <= 8 and B <= 8: print(""Yay!"") else: print("":("") " p03986,s717386492,Accepted,"x = input().replace(""ST"", """") s = 0 cnt = 0 for i in range(len(x)): if x[i] == ""S"": s += 1 else: if s > 0: s -= 1 cnt += 1 print(len(x)-cnt*2)" p03681,s664356253,Accepted," import math N, M = map(int, input().split()) if abs(N-M) >= 2: print(0) exit() if N == M: print((math.factorial(N) * math.factorial(M)) * 2 % (10**9 + 7)) else: print((math.factorial(N) * math.factorial(M)) % (10**9 + 7))" p02602,s891565729,Wrong Answer,"n,k= list(map(int, input().strip().split())) a = list(map(int, input().strip().split())) b=[1]*n for j in range(0,k): b[k-1]*=a[j] for i in range(k+1,n+1): b[i-1]*=b[i-2]*a[i-1]//a[i-k-1] print(b) for i in range(k,n): if b[i-1] a: pass else: res = max(res,x) print(res)" p02888,s070488245,Wrong Answer,"import bisect n=int(input()) l=list(map(int,input().split())) l.sort() ans=0 for a in range(n): for b in range(a+1,n): ans+=bisect.bisect_right(l,l[a]+l[b])-b print(ans)" p03645,s284100875,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]==1 or dist[-1]==2: print(""POSSIBLE"") else: print(""IMPOSSIBLE"")" p03607,s808402103,Accepted,"import collections n=int(input()) num=[] l=[] count=0 for _ in range(n): a=int(input()) l.append(a) l=collections.Counter(l) for i in l.values(): if i%2!=0: count+=1 print(count)" p03803,s400819108,Wrong Answer,"a,b=map(int,input().split()) if a==b: print('Draw') elif a > b and b != 1: print('Alice') else: print('Bob')" p03555,s162738624,Accepted,"s = input() s += input() print(""YES"" if s == """".join(reversed(s)) else ""NO"") " p03962,s304788561,Accepted,"a,b,c=map(int,input().split()) s=[a,b,c] s=list(set(s)) print(len(s))" p03699,s407230029,Wrong Answer,"N = int(input()) s = [int(input()) for i in range(N)] s.sort() ans = sum(s) if ans % 10 != 0: print(s) exit() else: for i in s: if i % 10 != 0: print(ans-i) exit() print(0)" p03474,s404356500,Accepted,"a,b = map(int,input().split()) s = input() S = list(s) c = 0 for i in S: if i == ""-"": c += 1 if c > 1: print(""No"") exit() if s.isdecimal() is True: print(""No"") exit() if len(s) != a + b + 1: print(""No"") exit() if s[:a].isdecimal() is True and S[a] == ""-"": print(""Yes"") else: print(""No"")" p03264,s881285172,Wrong Answer,"K = int(input()) a = K // 2 b = K // 2 + 1 print(a * b) " p02796,s213596253,Accepted,"N = int(input()) xl = [] for i in range(N): x, l = map(int, input().split()) xl.append((x, l)) xl.sort() kept = [] cur = 0 for i in range(1, N): x_cur, l_cur = xl[cur] x_next, l_next = xl[i] if x_cur + l_cur <= x_next - l_next: kept.append(cur) cur = i elif x_cur + l_cur > x_next + l_next: cur = i kept.append(cur) print(len(kept)) " p03274,s428215763,Wrong Answer,"n,k=map(int,input().split()) l=list(map(int,input().split())) if l[0]<=0 and l[k-1]<=0: print(abs(l[0])) elif l[0]>=0 and l[k-1]>=0: print(l[k-1]) else: mi=min(l[k-1],abs(l[0])) ma=max(l[k-1],abs(l[0])) print(mi*2+ma) " p03814,s029768277,Wrong Answer,"s = list(input()) for i in s: if i == 'A': a = s.index(i) break for i in s: if i == 'Z': z = s.index(i) print(z-a+1)" p03095,s016837158,Wrong Answer,"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(): print(v) ans = (ans * (v+1)) % MOD print((ans-1)%MOD) " p02705,s382869741,Accepted,"r = int(input()) pi = 3.1415927 print(2 * pi * r)" p03455,s413185235,Accepted,"a, b = map(int, input().split()) if (a*b) % 2: print(""Odd"") else: print(""Even"")" p03385,s175957665,Accepted,"s = input() print('Yes' if len(set(s)) == 3 else 'No')" p04044,s392647938,Accepted,"n, l = map(int, input().split()) s = sorted([input() for _ in range(n)]) print(*s, sep='') " p02818,s384840197,Wrong Answer," A,B,K = [int(i) for i in input().split("" "")] def check(A,B,K): if A > K: A-=K K = 0 else: result = K-A A = 0 K = result B-=K return ""{0} {1}"".format(A,B) print(check(A,B,K))" p02859,s638833141,Accepted,"r = int(input()) print(r**2)" p02957,s575222586,Accepted,"a, b = map(int, input().split()) if (a-b)%2 == 0: print(int((a+b)/2)) else: print('IMPOSSIBLE')" p02982,s193505515,Accepted,"import numpy as np N, D = map(int, input().split()) X = [] for i in range(N): X.append(list(map(int, input().split()))) # OK! # Compute each distances dis = [[0 for i in range(N)] for j in range(N)] for i in range(N): for j in range(i+1, N): for k in range(D): dis[i][j] += (X[i][k]-X[j][k])**2 # OK! # Check integer or not dot = 0 for i in range(N): for j in range(i, N): dis[i][j] = np.sqrt(dis[i][j]) if dis[i][j].is_integer() and dis[i][j] != 0: dot += 1 print(dot)" p03075,s327280127,Wrong Answer,"a=int(input()) b=int(input()) c=int(input()) d=int(input()) e=int(input()) k=int(input()) if k > e-a and k > e-b and k > e-c and k > e-d and k > d-c and k > d-b and k > d-a and k > c-b and k > c-a and k > b-a: print('Yay!') else: print(':(')" p03796,s256698183,Accepted,"N = int(input()) power = 1 for i in range(N): power = ((i+1) * power) % 1000000007 print(power)" p03208,s116406889,Accepted,"N,K = map(int,input().split()) lsh = [int(input()) for _ in range(N)] lsh.sort() ans = 10**9 for i in range(N-K+1): ans = min(ans,lsh[i+K-1]-lsh[i]) print(ans)" p02880,s966538061,Accepted,"n = int(input()) for i in range(1,10): for s in range(1,10): if i*s==n: print(""Yes"") exit() print(""No"") " p03061,s152718060,Accepted,"from fractions import gcd n = int(input()) a = list(map(int,input().split())) l = [0] r = [0] ans = 0 for i in range(n-1): l.append(gcd(l[i],a[i])) for i in range(n-1): r.append(gcd(r[i],a[n-1-i])) for i in range(n): ans = max(ans,gcd(l[i],r[-i-1])) print(ans)" p02793,s958591007,Accepted,"import fractions from functools import reduce def lcm_base(x, y): return (x * y) // fractions.gcd(x, y) def lcm_list(numbers): return reduce(lcm_base, numbers, 1) N=int(input()) A=list(map(int,input().split())) MOD=(10**9)+7 S=list(set(A)) LCM=lcm_list(S) ans=0 for i in range(N): ans+=(LCM//A[i]) print(ans%MOD) " p03286,s131641455,Wrong Answer,"import math N = int(input()) S = '' while N: r = N%2 N = N//(-2)+r S += str(r) print(S[::-1])" p02924,s640968813,Accepted,"N=int(input()) ans=(N-1)*N//2 print(ans)" p03289,s908972787,Accepted,"A= input() if A[0]==""A"" and A[2:-1].count(""C"")==1: pass else: print(""WA"") exit() B=A[1:] B=B.replace(""C"","""") if B.islower()==True: print(""AC"") else: print(""WA"")" p02707,s744514986,Accepted,"# cook your dish here n=int(input()) arr=list(map(int,input().split())) blank=[0]*n for i in range(len(arr)): blank[arr[i]-1]+=1 for i in blank: print(i)" p02789,s699677341,Accepted,"n,m=list(map(int,input().split())) if n==m: print(""Yes"") else: print(""No"")" p02613,s859406349,Accepted,"N = int(input()) S_list = [] for _ in range(N): S = str(input()) S_list.append(S) # print(S_list) AC_list = [S == 'AC' for S in S_list] WA_list = [S == 'WA' for S in S_list] TLE_list = [S == 'TLE' for S in S_list] RE_list = [S == 'RE' for S in S_list] print('AC x {}'.format(sum(AC_list))) print('WA x {}'.format(sum(WA_list))) print('TLE x {}'.format(sum(TLE_list))) print('RE x {}'.format(sum(RE_list)))" p03745,s977120846,Accepted,"N = int(input()) A = list(map(int, input().split())) Ad = [A[i] - A[i+1] for i in range(N-1)] ans = 1 p = 0 for d in Ad: if d * p < 0: ans += 1 p = 0 elif d != 0: p = d print(ans)" p03407,s327501292,Wrong Answer,"A,B,C = map(int,input().split()) if C= n: print(f'{s[:n]}...') else: print(s) " p02664,s524988440,Accepted,"s = list(str(input())) c = """" for i in range(len(s)): if s[i] == ""?"": s[i] = ""D"" for i in range(len(s)): c += s[i] print(c) " p02742,s989831300,Accepted,"H,W = map(int,input().split()) if H == 1 or W == 1: print(1) exit(0) elif H % 2 != 0 and W % 2 != 0: print((H * W // 2) + 1) else: print(H * W // 2)" p03137,s473730712,Wrong Answer,"n,m = map(int,input().split()) x = list(map(int,input().split())) x = sorted(x) dif = [] for i in range(m-1): dif.append(x[i+1]-x[i]) dif = sorted(dif) print(sum(dif[:m-n]))" p03632,s315439525,Accepted,"a,b,c,d=map(int,input().split()) print(max(min(b,d)-max(a,c),0))" p02584,s629390744,Wrong Answer,"X, K, D = map(int, input().split()) if abs(X) - K * D < 0: d = abs(X) // D print(min(abs(abs(X) - d * D), abs(abs(X) - (d+1) * D))) else: print(abs(X) - K * D) " p03087,s768909552,Accepted,"n, q = map(int, input().split()) s = input() lr = [[0] * 2 for _ in range(q)] for i in range(q): l, r = map(int, input().split()) lr[i][0], lr[i][1] = l, r chk = [0] * n cnt = [0] * n for i in range(1, n): if s[i] == 'C': if s[i-1] == 'A': chk[i] = 1 cnt[i] = cnt[i-1] + chk[i] for i in lr: print(cnt[i[1]-1] - cnt[i[0]-1]) " p02554,s069040170,Accepted,"n = int(input()) def modpow(a, n, mod): res = 1 while n > 0: if n & 1: res = res * a % mod a = a * a % mod n >>= 1 return res mod = 1000000007 ans = modpow(10, n, mod) - (modpow(9, n, mod) + modpow(9, n, mod) - modpow(8, n, mod)) ans = ans % mod print(ans)" p02953,s074162341,Accepted,"N = int(input()) H = list(map(int, input().split())) for i in range(1, N): if H[i] - H[i - 1] > 0: H[i] -= 1 if H[i] - H[i - 1] < 0: print(""No"") break else: print(""Yes"")" p03076,s878471166,Accepted,"import math A = input() B = input() C = input() D = input() E = input() num = 10 for i in [int(A[-1]), int(B[-1]), int(C[-1]), int(D[-1]), int(E[-1])]: if i != 0: num = min(num, i) result = (math.ceil(int(A)/10) + math.ceil(int(B)/10) + math.ceil(int(C)/10) + math.ceil(int(D)/10) + math.ceil(int(E)/10)) * 10 if num != 10: result = result - 10 + num print(result)" p02700,s638741950,Accepted,"from sys import stdin import math import fractions a, b, c, d = [int(x) for x in stdin.readline().rstrip().split()] while True: c -= b if c <= 0: print('Yes') break a -= d if a <= 0: print('No') break " p03696,s570864570,Accepted,"N = int(input()) S = input() stack = [] for c in S: if len(stack) > 0: last = stack[-1] if last == '(' and c == ')': stack = stack[:-1] continue stack.append(c) left = stack.count(')') right = stack.count('(') print(left * '(' + S + right * ')')" p02718,s768719478,Accepted,"N, M = map(int, input().split()) A = list(map(int, input().split())) J = sum(A)/(4*M) cnt = 0 for i in range(N): if A[i]>=J: cnt+=1 if cnt>=M: print(""Yes"") else: print(""No"")" p02862,s005619582,Accepted,"x, y = map(int, input().split()) if 2 * y < x: print(0) elif y > 2 * x: print(0) elif (x + y) % 3 != 0: print(0) else: p = 10**9 + 7 s = int((2 * x - y) / 3) t = int((2 * y - x) / 3) u = min(s, t) v = s + t inv = [0] * (u + 1) inv[0] = 0 ans = 1 for i in range(1, u + 1): inv[i] = pow(i, p - 2, p) ans = (ans * (v - i + 1) * inv[i]) % p print(ans)" p02996,s142049946,Wrong Answer,"n = int(input()) i = 0 ab = [] while i < n: a, b = map(int, input().split()) ab.append((a, b)) i += 1 ab.sort(key=lambda x: x[1]) days = ab[0][0] i = 1 ans = 'Yes' while i < n: days += ab[i][0] print(days) if days > ab[i][1]: ans = 'No' break i += 1 print(ans)" p02726,s372078311,Accepted,"N, X, Y = map(int, input().split()) ans = [0] * (N - 1) ans[0] = 1 for i in range(1, N - 1): for j in range(i + 1, N + 1): d = min(j - i, abs(Y - j) + abs(X - i) + 1) ans[d - 1] += 1 for a in ans: print(a) " p02973,s988539243,Wrong Answer,"n = int(input()) color = [int(input())] for _ in range(n-1): key = int(input()) if key <= color[0]: color.append(key) else: l, r = 0, len(color) while r-l > 1: k = (r+l)//2 if key <= color[k]: l = k else: r = k if l == 0: if r == len(color): pass elif key > color[r]: l = r color[l] = key color.sort() print(len(color))" p03457,s724991739,Accepted,"n = int(input()) for i in range(n): t,x,y=map(int,input().split()) if (x + y) > t or (x + y + t) % 2: print(""No"") exit() print(""Yes"") " p02554,s931003662,Accepted,"import sys sys.setrecursionlimit(10000000) mod = 10 ** 9 + 7 def pow(a, n): if n == 0: return 1 if n == 1: return a tmp = pow(a, n//2) tmp = (tmp * tmp) % mod if n % 2 == 1: tmp = (tmp * a) % mod return tmp n = int(input()) print() print((((pow(10, n) - 2 * pow(9, n) + mod ** 2) % mod) + pow(8, n)) % mod)" p02727,s646748141,Wrong Answer,"x, y, a,b, c = map(int, input().split()) P = list(map(int, input().split())); P.reverse() Q = list(map(int, input().split())); Q.reverse() R = list(map(int, input().split())); R.reverse() ans = 0 PQ = P[:x] + Q[:y]; PQ.sort(); PQ.reverse() for i in range(len(PQ)): if max(PQ) >= max(R): ans += max(PQ) else: ans += max(R) del R[0] del PQ[0] print (ans)" p02732,s017899350,Accepted,"N = int(input()) A = list(map(lambda x: int(x) - 1, input().split())) C = [0] * N for a in A: C[a] += 1 def comb(n): if n <= 1: return 0 else: return n * (n - 1) // 2 t = sum(list(map(comb, C))) for a in A: print(t - comb(C[a]) + comb(C[a] - 1)) " p04019,s515519697,Accepted,"# --*-coding:utf-8-*-- S = input() T = set(s for s in S) print('No' if ('S' in T)^('N' in T) or ('E' in T)^('W' in T) else 'Yes') " p02947,s390502611,Accepted,"n=int(input()) def f(s): return """".join(sorted(list(s))) s=[f(input())for _ in range(n)] from collections import Counter d=Counter(s) ans=0 for i in d:ans+=d[i]*(d[i]-1)//2 print(ans)" p03211,s754951348,Accepted,"import sys import math import itertools s=input() min=9999999999 for i in range(0,len(s)-2,1): num=abs(int(s[i:i+3])-753) if min>=num: min=num print(min)" p02791,s400107989,Wrong Answer,"n = int(input()) p = list(map(lambda x: int(x), input().split())) mins = p[0] def function(p, i, mins): if mins >= p[i]: return 1 else: mins = p[i] return 0 sums = sum([function(p,i, mins) for i in range(1, n)]) print(sums)" p02723,s606526662,Accepted,"def main(): s = input() print('Yes' if s[2] == s[3] and s[4] == s[5] else 'No') if __name__ == '__main__': main() " p03437,s354814192,Accepted,"X,Y = map(int, input().split()) print(X if X%Y else -1)" p03433,s145368695,Wrong Answer,"N = int(input(""N--->"")) A = int(input(""A--->"")) b = N%500 if A > b: print(""Yes"") else: print(""No"")" p02582,s349395850,Accepted,"s = input() ans=0 if s.count(""R"")>0: ans = 1 if s[:2]==""RR"": ans = 2 if s[1:]==""RR"": ans = 2 if s == ""RRR"": ans = 3 print(ans) " p03211,s359683495,Wrong Answer,"def main(): S = input() mind = 1000 for i in range(len(S) - 3 + 1): print(S[i:i+3]) d = abs(753 - int(S[i:i+3])) if d < mind: mind = d print(mind) main()" p03338,s685468011,Accepted,"n = int(input()) s = input() M = 0 for i in range(1, n): cnt = 0 s1 = s[:i] s2 = s[i:] t = {} for x in s1: if x not in t: t[x]=1 for k in s2: if k not in t: t[k]=0 if t[k] == 1: t[k]+=1 for x, y in t.items(): if y==2: cnt+=1 M = max(cnt, M) print(M)" p02660,s112733396,Accepted,"n=int(input()) if n==1: print(0); exit() M=10**6+1 l=[] p=[1]*M p[0]=p[1]=0 for i in range(2,M): if p[i]: l.append(i) for j in range(2*i,M,i): p[j]=0 d={} for k in l: c=0 while n%k==0: n//=k; c+=1 if c>0: d[k]=c s=[1] for i in range(2,9): s.append(s[-1]+i) a=0 for i in d.values(): for j in s: if j>i: break a+=1 print(a+(n>1))" p02747,s310763303,Accepted,"s = input() if s == 'hi' or s == 'hihi' or s == 'hihihi' or s == 'hihihihi' or s == 'hihihihihi': print('Yes') else: print('No') " p02742,s770358161,Accepted,"H, W = list(map(int, input().split())) if(min(H, W) == 1): print(1) else: print(int(H*W/2) + H*W%2)" p03448,s062522419,Accepted,"A=[int(i)*500 for i in range(0,int(input())+1)] B=[int(i)*100 for i in range(0,int(input())+1)] C=[int(i)*50 for i in range(0,int(input())+1)] X=int(input()) l=[] for a in A: for b in B: for c in C: l.append(a+b+c) print(l.count(X)) " p03723,s030443583,Accepted,"import sys a, b, c = map(int, input().split()) var = 0 for i in range(1000): if a%2 != 0 or b%2 != 0 or c%2 != 0: print(var) sys.exit() a, b, c = b/2 + c/2, a/2 + c/2, a/2 + b/2 var += 1 print(-1)" p02601,s829585920,Accepted,"# -*- coding: utf-8 -*- """""" Created on Sat Jul 25 21:02:29 2020 @author: NEC-PCuser """""" A, B, C = map(int, input().split()) K = int(input()) # B > A C > B for i in range(K): if (C <= B): C *= 2 elif B <= A: B *= 2 if (A < B and B < C): print(""Yes"") else: print(""No"")" p02842,s077952233,Wrong Answer,"def resolve(): N = int(input()) if (N + 1) * 100 % 108 == 0: print("":("") else: print(int((N+1)/1.08)) resolve()" p03721,s686991049,Accepted,"N, K = [int(i) for i in input().split()] ab = [[int(i) for i in input().split()] for _ in range(N)] ab.sort(key=lambda x: x[0]) for a, b in ab: K -= b if K <= 0: print(a) break " p02796,s151489928,Accepted,"N = int(input()) arm_range = [] for _ in range(N): X,L = map(int,input().split()) arm_range.append([X+L,X-L]) arm_range = sorted(arm_range) limit = arm_range[0][0] ans = 1 for i in range(1,N): if arm_range[i][1] >= limit: ans += 1 limit = arm_range[i][0] print(ans)" p03545,s307292625,Wrong Answer,"A, B, C, D = (int(x) for x in input()) class Op(int): def __str__(self): return '-' if self < 0 else '+' pm = (Op(1), Op(-1)) for op1 in pm: for op2 in pm: for op3 in pm: if A + op1 * B + op2 * C + op3 * D == 7: print(''.join(str(x) for x in [A, op1, B, op2, C, op3, D]) + '=7') break " p03075,s354974162,Accepted,"a = int(input()) b = int(input()) c = int(input()) d = int(input()) e = int(input()) k = int(input()) list = [a, b, c, d, e] can = False for i in range(len(list)): for j in range(len(list)): if i == j: continue if abs(list[i] - list[j]) <= k: can = True else: can = False break if can: print(""Yay!"") else: print("":("") " p03037,s110688910,Accepted,"def main(): N, M = list(map(int, input().split(' '))) max_l, min_r = 1, N for _ in range(M): L, R = list(map(int, input().split(' '))) max_l = max([max_l, L]) min_r = min([min_r, R]) print(max([min_r - max_l + 1, 0])) if __name__ == '__main__': main() " p02603,s537266052,Accepted,"N = int(input()) A = list(map(int, input().split())) n_kabu = 0 money = 1000 for d in range(N-1): kabuka_today = A[d] kabuka_tomorrow = A[d+1] if kabuka_today < kabuka_tomorrow: can_buy = money//kabuka_today n_kabu += can_buy money -= can_buy*kabuka_today elif kabuka_today > kabuka_tomorrow: money += n_kabu*kabuka_today n_kabu = 0 money += n_kabu*A[N-1] print(money)" p03456,s199420671,Accepted,"a,b = input().split() x = int(a+b) for i in range(1,317): if i * i == x: print('Yes') exit() print('No')" p02723,s041237359,Accepted,"def resolve(): s = input() if s[2]==s[3] and s[4]==s[5]: print('Yes') else: print('No') resolve()" p03126,s363747129,Wrong Answer,"n,m = map(int,input().split()) li = [] for i in range(n): ka = list(map(int,input().split())) li.extend(ka[1:]) ans = 0 for i in range(m): if li.count(i) == n: ans += 1 print(ans)" p02624,s453847286,Wrong Answer,"N = int(input()) sum = 0 for i in range(1,N+1): sum+=i*(1+N//i)*(N//i)/2 print(sum)" p02547,s719222592,Accepted,"n=int(input()) count=0 for i in range(n): me1,me2=list(map(int,input().split())) if me1==me2: count+=1 if count==3: break else: count=0 if count>=3: print('Yes') else: print('No')" p03456,s708230409,Accepted,"a,b = map(int,input().split()) x = 0 if b < 10: x = 10*a + b elif b < 100: x = 100*a + b else: x = 1000*a + b if (x**0.5)%1 == 0: print(""Yes"") else: print(""No"") " p03309,s711186064,Accepted,"import statistics n = int(input()) a = list(map(int, input().split())) bi = [] for i in range(n): bi.append(a[i] - (i)) b = int(statistics.median(bi)) ans = 0 for i in range(n): ans += abs(bi[i] - b) print(ans)" p02993,s657453997,Accepted,"S=input() if S[0]==S[1] or S[1]==S[2] or S[2]==S[3]: print('Bad') else: print('Good')" p02831,s554234574,Accepted,"import fractions a,b=map(int, input().split()) print(round(a*b/fractions.gcd(a, b)))" p03435,s828612981,Wrong Answer,"c = [] for _ in range(3): tmp = list(map(int, input().split())) c.extend(tmp) # c.append(tmp) # print('c', c) if sum(c) % 3: print('No') else: print('Yes') " p02823,s838452311,Accepted,"n, a, b = map(int, input().split()) if b > a: a, b = b, a if (a - b) % 2 == 0: print((a - b) // 2) else: print(min(a - 1, n - b) + 1 + (b - a - 1) // 2) " p02732,s524289506,Wrong Answer,"import math num = int(input()) a_i = list(map(int, input().split())) anslist = [0] * (num + 1) for x in range(num): val = x + 1 cnt = a_i.count(val) if cnt <= 1: anslist[val] = 0 else: anslist[val] = math.factorial(cnt - 1) ans = sum(anslist) for x in range(num): val = a_i[x] cnt = a_i.count(val) if cnt <= 2: print(ans) else: sa = anslist[val] - math.factorial(cnt - 2) print(ans - sa)" p03449,s754229436,Accepted,"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())) for _ in range(2)] ans = 0 for i in range(n): ans = max(ans, sum(a[0][:i + 1:]) + sum(a[1][i::])) print(ans)" p02778,s092494349,Accepted,"l = (input()) s = '' for i in range(len(l)): s+='x' print(s) " p03339,s325040252,Accepted,"import sys def input(): return sys.stdin.readline().rstrip() def main(): N = int(input()) S = list(input()) ans = 10 ** 6 sum_count = S.count('E') for s in S: aft = 0 if s == 'W': aft = 1 else: sum_count -= 1 ans = min(ans, sum_count) sum_count += aft print(ans) if __name__ == '__main__': main() " p02813,s890339285,Accepted,"import math N = int(input()) P = [int(i) for i in input().split()] Q = [int(i) for i in input().split()] def count(U): S = sorted(U) C = 1 for i,j in enumerate(U): c = 0 for u,v in enumerate(S): if v == j: del S[u] break else: c += 1 C += (math.factorial(N-i-1))*c return C print(abs(count(P)-count(Q)))" p02993,s437222363,Accepted,"s=input() if s[0]==s[1] or s[1]==s[2] or s[2]==s[3]: print(""Bad"") else:print(""Good"")" p02897,s153420462,Accepted,"N=int(input()) print(1-(N//2)/N)" p03419,s450969736,Accepted,"n, m = map(int,input().split()) if n == 1 and m == 1: print(1) elif n == 1 or m == 1: print(max(max(n,m)-2,0)) else: print((n-2)*(m-2))" p02582,s385919603,Accepted,"S=input() if S==""RRR"" : print(3) elif S==""RRS"" : print(2) elif S==""SRR"" : print(2) elif S==""RSS"" : print(1) elif S==""SRS"" : print(1) elif S==""SSR"" : print(1) elif S==""RSR"" : print(1) else : print(0)" p03693,s345575566,Wrong Answer,"r,g ,b=map(int,input().split()) A=100*r+10*g+b if A%4==0: print(""Yes"") else : print(""No"")" p03997,s092072627,Accepted,"a=int(input()) b=int(input()) h=int(input()) print(int((a+b)*h/2))" p02787,s814684960,Accepted,"import sys def input(): return sys.stdin.readline().rstrip() import numpy as np def main(): h,n=map(int,input().split()) lis=np.array([list(map(int,input().split())) for _ in range(n)]) dp=np.zeros(h+1,int) dp[0]=0 for i in range(1,h+1): dp[i]=np.min(dp[np.maximum(i-lis[:,0],0)]+lis[:,1]) print(dp[h]) if __name__=='__main__': main()" p02899,s879154983,Accepted,"a=input() b=input() N=int(a) An = [int(b0) for b0 in b.split(' ')] Cn=[0]*len(An) for i in range(len(An)): Cn[An[i]-1] = i+1 for i in Cn: print(i, end=' ')" p03131,s449025858,Accepted,"k, a, b = map(int, input().split()) c = 1 if a + 2 >= b: print(c+k) else: if k - (a+1) >= 0: k = k - (a+1) c = b c += (k//2)*(b-a) + k%2 print(c) else: print(c+k)" p03852,s511549944,Wrong Answer,"c = input() print(""vowel"" if c in ""aiueo"" else ""constant"")" p02796,s593160943,Accepted,"from operator import itemgetter N, *A = map(int, open(0).read().split()) X = [(x-l, x+l) for x, l in zip(*[iter(A)]*2)] X.sort(key=itemgetter(1)) ans = 0 R = -float('inf') for l, r in X: if R <= l: ans += 1 R = r print(ans) " p03379,s859791809,Wrong Answer,"n = int(input()) x = list(map(int,input().split())) y = sorted(x) index = n//2 for i in range(n): print(y[index] if x[i] a: ans += a else: ans += n_mod print(ans)" p03131,s463923997,Accepted,"K, A, B = map(int, input().split()) if B - A <= 2: print(K + 1) else: time = max(0, (K - (A - 1)) // 2) ans = A + (B - A) * time if (K - (A - 1)) % 2 == 1: ans += 1 print(ans) " p03417,s408792302,Accepted,"N,M=map(int,input().split()) ans = 0 if (N == 1) and (M == 1): ans = 1 elif M == 1: ans = N - 2 elif N == 1: ans = M - 2 else: ans = (M-2)*(N-2) print(ans) " p02623,s834362986,Accepted,"import bisect import itertools n,m,k=map(int,input().split()) A=list(itertools.accumulate([0]+list(map(int,input().split())))) B=list(itertools.accumulate([0]+list(map(int,input().split())))) ans=0 for i,a in enumerate(A): if a>k: break cnt=bisect.bisect_right(B,k-a)-1 ans=max(ans,i+cnt) print(ans)" p02953,s481458858,Accepted,"n = int(input()) h = list(map(int,input().split())) a = h[0] for i in range(1,n): if a == h[i]: pass elif a < h[i]: h[i] -= 1 a = h[i] else: print(""No"") exit() print(""Yes"")" p03448,s041284763,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)" p03524,s677875237,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')" p02994,s786003817,Wrong Answer,"n,l = map(int,input().split()) lst = 0 if l>=0: for i in range(1,n+1): lst+=l+(i-1) a = lst - l elif l < 0 and l+n-1 >=0: for i in range(1,n+1): if l+i-1 == 0: lst+=l+(i-1) a = lst elif l+n-1 <0: for i in range(1,n+1): lst+=l+(i-1) a = lst - (l+n-1) print(a)" p02729,s696979154,Wrong Answer,"a, b = [int(i) for i in input().split()] x = 0 x = a*(a-1)/2+b*(b-1)/2 print(x) " p02783,s875709393,Accepted,"H, A = map(int,input().split()) for i in range(H+1): if H > 0: H = H - A else: print(i) break" p03479,s527014295,Accepted,"from sys import stdin [X, Y] = [int(x) for x in stdin.readline().rstrip().split()] index=1 while(True): X = 2*X if X<=Y: index+=1 else: break print(index) " p02645,s142183516,Accepted,"str = input() str_length = len(str) import random start_num = random.randint(0,str_length-3) print(str[start_num:start_num+3]) " p02701,s822891018,Accepted,"N = int(input()) s = set() for _ in range(N): s.add(input()) print(len(s))" p03612,s679697950,Wrong Answer,"N=int(input()) p=list(map(int,input().split())) p.append(0) count=0 for i in range(N): if p[i]==i+1: if p[i+1]!=i+2: count+=1 print(count)" p03623,s754870080,Accepted,"x,a,b=map(int,input().split()) print('A' if abs(a-x)= b: b *= 2 n += 1 if n > K: print(""No"") exit() while b >= c: c *= 2 n += 1 if n > K: print(""No"") exit() print(""Yes"") " p02923,s799391292,Accepted,"n = int(input()) h = list(map(int, input().split())) max_ = 0 cnt = 0 for i in range(n - 1, 0, -1): if h[i - 1] < h[i]: max_ = max(max_, cnt) cnt = 0 else: cnt += 1 max_ = max(max_, cnt) print(max_)" p03730,s529663267,Accepted,"def resolve(): a, b, c = map(int, input().split()) a %= b for i in range(b): if a*i %b == c: print(""YES"") exit() print(""NO"") resolve()" p02823,s938089022,Accepted,"n, a, b = list(map(int, input().split())) if (b - a) % 2 == 0: print((b - a) // 2) else: ans = min(a - 1, n - b) + 1 ans += (b - a - 1) // 2 print(ans)" p03126,s186443794,Wrong Answer,"N,M=map(int,input().split()) L=[[int(i) for i in input().split()][1:] for j in range(N)] #print(L) cnt=0 for i in range(1,M+1): for j in range(N): #print(L[i][1:]) if i in L[j]: break else: cnt+=1 print(cnt)" p03633,s604296083,Accepted,"n = int(input()) t = [int(input()) for _ in range(n)] def gcd(a,b): if b == 0: return a return gcd (b, a%b) #2数の積/最大公約数=最小公倍数 def lcm(a,b): return a*b//gcd(a,b) if n == 1: print(t[0]) exit(0) ans = lcm(t[0], t[1]) for i in range(1, n-1): ans = lcm(ans, t[i+1]) print(ans)" p02726,s247403308,Wrong Answer," N, X, Y = input().split() N = int(N) X = int(X) x = X - 1 Y = int(Y) y = Y -1 ans = [0] * (N-1) A = [[0] * N for _ in range(N)] for i in range(N): for j in range(N-i): path = min(abs(x- i) +1 +abs(y-i-j),j) ans[path] += 1 print(*ans, sep='\n') " p02918,s382450014,Accepted,"# D - Face Produces Unhappiness N, K = map(int, input().split()) S = str(input()) score = 0 for i in range(N - 1): if S[i] == S[i + 1]: score += 1 print(min(score + K * 2, N - 1)) " p02597,s527422755,Accepted,"n = int(input()) A = list(input()) r = A.count(""R"") ans = A[:r].count(""W"") print(ans)" p03327,s883970784,Accepted,"contest_num = int(input()) if contest_num >= 1999: result_str = 'The contest has not been held' elif contest_num < 1000: result_str = 'ABC' elif contest_num >= 1000: result_str = 'ABD' print(result_str) " p02832,s314945346,Accepted,"N = int(input()) A = list(map(int, input().split())) x = 1 list1 = [] count = 0 for i in range(N): count += 1 if A[i] == x: list1.append(i) count -= 1 x += 1 if list1 == []: print(-1) else: print(count) " p02731,s477389519,Accepted,"L = int(input()) a = L/3 print(a*a*a)" p03071,s585632605,Accepted,"a, b = map(int, input().split()) k = 0 for i in range(2): if a >= b: k += a a -= 1 else: k += b b -= 1 print(k)" p02683,s123875381,Accepted,"import itertools import numpy as np n,m,x = map(int,input().split()) c = [] total = [0] * m ans = float('inf') finish = False for i in range(n): c.append(list(map(int,input().split()))) for i in range(1,n+1): for comb in itertools.combinations(c,i): su = np.array(comb).sum(axis=0) if sum(su[1:] >= x) == m: ans = min(ans,su[0]) if ans != float('inf'): print(ans) else: print(-1)" p02953,s660375376,Accepted,"import sys n = int(input()) h = list(map(int, input().split())) def main(): for i in reversed(range(n-1)): if h[i] - h[i+1] > 1: return False exit() elif h[i] - h[i+1] == 1: h[i] -= 1 else: continue return True if main() == True: print('Yes') sys.exit() h[n-1] -= 1 if main() == True: print('Yes') else: print('No')" p03127,s893190498,Accepted,"from collections import deque n = int(input()) l = deque(map(int, input().split())) while len(l) > 1: key = min(l) for i in range(len(l)): j = l.popleft() sup = j % key if sup > 0: l.append(sup) l.append(key) print(l[0] if len(l) == 1 else 0)" p03309,s079823927,Accepted,"import numpy as np N = int(input()) list_ai = list(map(int,input().split())) list1 = [x-(i+1) for i,x in enumerate(list_ai)] a1 = np.array(list1) median1 = int(np.floor(np.median(a1))) ans = np.sum(np.abs(a1-median1)) print(ans)" p03351,s466851639,Accepted,"a,b,c,d=map(int,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"")" p03997,s293783750,Accepted,"a = int(input()) b = int(input()) h = int(input()) print((a+b)*h//2)" p03328,s123927902,Accepted,"l=[1] for i in range(2,1000): l.append(l[-1]+i) a,b=map(int,input().split()) print(l[b-a-2]-a) " p03705,s617677290,Accepted,"from itertools import product n, a, b = map(int, input().split()) if a > b : print(0) exit() elif n == 1: if a != b: print(0) exit() else: print(1) exit() else: print((b-a) * (n-2) + 1)" p03037,s075479070,Accepted,"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) count = min(R) - max(L) + 1 if count <= 0: print(0) else: print(count)" p03632,s828703567,Wrong Answer,"startA, finishA, startB, finishB = map(int,input().split()) if finishA <= finishB: if startB == startA: print(finishB - finishA) elif startA <= startB <= finishA: print(finishA - startB- startA) else: print(""0"") else: if startB == startA: print(finishA - finishB) elif startA <= startB <= finishB: print(finishB - startB) else: print(""0"")" p02897,s614622240,Wrong Answer,"N=int(input()) if N%2==0: print(0.5) else: print((0.5*N+1)/N)" p03623,s700913953,Accepted,"x, a, b = map(int, input().split()) if abs(x-a) > abs(x-b): print('B') else: print('A') " p02603,s749311446,Accepted,"N = int(input()) A = [int(a) for a in input().split()] Mcashe = 1000 Mkabu = 0 for i in range(len(A) - 1): Mcashe += (Mkabu * A[i]) Mkabu = 0 if A[i] < A[i+1]: Mkabu = Mcashe // A[i] Mcashe = Mcashe % A[i] Mcashe += (Mkabu * A[-1]) print(Mcashe) " p02848,s967926300,Accepted,"N = int(input()) S = input() ans = [chr((ord(i)-65 +N) % 26 + 65) for i in S] print(''.join(ans))" p02819,s750765751,Accepted,"X = int(input()) if X == 2: print(2) exit() while True: N = int(X**0.5) for i in range(1,N): if X % (i+1) == 0: break else: if i == N - 1: print(X) exit() X += 1" p03127,s115736370,Wrong Answer,"from collections import defaultdict from collections import deque from collections import Counter 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() a = list(set(readInts())) if len(a)==1: print(a[0]) exit() odd = [] even = [] for i in a: if i%2==0: even.append(i) else: odd.append(i) from math import gcd if len(odd)>0: print(1) exit() elif len(even)>0: d = even[0] for i in range(len(even)): d = gcd(even[i],d) print(d)" p02989,s294374039,Accepted,"N = int(input()) d = list(map(int, input().split())) d = sorted(d) print(d[(N//2)] - d[(N//2)-1])" p03239,s860449847,Accepted,"n, k = map(int, input().split()) ct = [] for i in range(n): c, t = map(int, input().split()) ct.append([c, t]) ct.sort() ans = 0 for i in range(n): if ct[i][1] <= k: ans = ct[i][0] break if ans: print(ans) else: print(""TLE"") " p02951,s872775604,Accepted,"a, b, c = [int(x) for x in input().split()] req = b + c print((req - a) if req > a else 0) " p02731,s461481803,Accepted,"# the answer is always a cube. so calculate the volume of that cube. total_length = float(input()) single_length = total_length/3 volume = single_length**3 print(volume)" p04034,s202169163,Accepted,"def int_(num_str): return int(num_str) - 1 N, M = map(int, input().split()) balls = [1] * N red = {0} for i in range(M): x, y = map(int_, input().split()) if x in red: if balls[x] == 1: red.remove(x) red.add(y) else: red.add(y) balls[x] -= 1 balls[y] += 1 print(len(red))" p02701,s412373219,Accepted,"N = int(input()) S = [(input()) for i in range(N)] print(len(set(S)))" p03860,s513289930,Accepted,"s=input() print('A'+s[8]+'C')" p04012,s933100047,Accepted,""""""" author : halo2halo date : 4, Feb, 2020 """""" import sys import itertools import numpy as np read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines S = readline().decode('utf8').rstrip() se = set(S) ans = True for m in se: if S.count(m) % 2 != 0: ans = False print('Yes' if ans else 'No') " p02578,s469249200,Wrong Answer,"##C - Step N = int(input()) A = list(map(int,input().split())) ans = 0 for i in range(N): print(i,A) if not A: Idx = A.index(max(A)) ans += max(A)*(len(A) - Idx) - sum(A[Idx::]) del A[Idx::] else: break print(ans)" p02615,s429163164,Accepted,"n = int(input()) a = list(map(int,input().split())); a.sort() com = 0; for k in range(n-1): kk = n - (k+1) // 2 - 1 com += a[kk] print(com);" p03797,s128090703,Accepted,"N, M = map(int, input().split()) if N >= M // 2: print(M // 2) else: print((N*2 + M) // 4)" p03041,s649383231,Accepted,"n,k=map(int,input().split()) s=list(input()) s[k-1]=s[k-1].lower() print(''.join(s))" p02595,s369637303,Accepted,"n,d=map(int,input().split("" "")) c=0 for i in range(n): x,y=map(int,input().split("" "")) distance=((x-0)**2+(y-0)**2)**(0.5) if distance<=d: c+=1 print(c)" p03637,s281255214,Accepted,"N = int(input()) lst = [int(x) for x in input().split()] a = 0 b = 0 for n in lst: if n % 4 == 0: a += 1 elif n % 2 == 0: b += 1 if b >= 2: N = N - (b - 1) if a >= N // 2: print(""Yes"") else: print(""No"") " p02861,s004081133,Accepted,"from itertools import permutations n=int(input()) l=[] for i in range(n): x,y=map(int,input().split()) l.append((x,y)) dist=[] for ll in list(permutations(l)): d=0.0 for i in range(len(ll)-1): d+=((ll[i][0]-ll[i+1][0])**2+(ll[i][1]-ll[i+1][1])**2)**0.5 dist.append(d) print(sum(dist)/len(dist)) " p02888,s240748572,Wrong Answer,"N = int(input()) L = list(map(int, input().split())) L.sort() L_max = L[-1] cnt = [0]*(L_max+1) ptr = 0 for i in range(1, L_max+1): cnt[i] = cnt[i - 1] while ptr < N and i == L[ptr]: cnt[i] += 1 ptr += 1 res = 0 for i in range(N): for j in range(i + 1, N): res += max(0, cnt[min(L[i], L[j])] - 1 - cnt[abs(L[i] - L[j])]) if L[i] == L[j]: res -= 1 print(res)" p03448,s868591041,Accepted,"inputlist = [input() for i in range(4)] n = 0 A,B,C= inputlist[0],inputlist[1],inputlist[2] for i in range(int(A)+1): X = inputlist[3] X = int(X) - i*500 for j in range(int(B)+1): X = X - j*100 for k in range(int(C)+1): X = X -k*50 if X == 0: n += 1 X= X + k*50 X = X + j*100 X = X + i*500 print(n)" p03076,s835707991,Accepted,"import math total_time = 0 los_ari = False min_los = 9 for i in range(5): T=int(input()) total_time = total_time + 10 * math.ceil(T/10) if T%10!=0: los_ari = True if T%10= 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()" p02817,s164950297,Wrong Answer,"print("""".join(map(str,input().split()))) " p02646,s331423965,Accepted,"A, V = map(int, input().split()) B, W = map(int, input().split()) T = int(input()) if B > A: if A - B + (V - W) * T >= 0: print(""YES"") else: print(""NO"") else: if B - A + (V - W) * T >= 0: print(""YES"") else: print(""NO"")" p03109,s777755458,Accepted,"s=input() s=int(s.replace(""/"","""")) print([""Heisei"",""TBD""][s>20190430])" p03469,s568760535,Wrong Answer,print('2018/01' + input()[-2:]) p03860,s942471739,Wrong Answer,"a,b,c=map(str,input().split()) print('A'+b[0].lower()+'C')" p02982,s426465624,Accepted,"N, D = map(int, input().split()) X = [] for n in range(N): X.append(list(map(int, input().split()))) cnt = 0 for i in range(N - 1): for j in range(i + 1, N): sum = 0 for d in range(D): sum += (X[i][d] - X[j][d]) ** 2 if (sum ** (1/2)) % 1 == 0: cnt += 1 print(cnt)" p02711,s349254749,Accepted,"S = (list(input())) if S[0] == ""7"" or S[1] == ""7"" or S[2] == ""7"": print(""Yes"") else: print(""No"")" p02854,s981491335,Wrong Answer,"import numpy as np N=int(input()) A=np.array(list(map(int, input().split()))) S=sum(A) X=A[0] ans=abs(S-X) for i in range(1,N-1): X+=A[i] ans=min(ans,abs(S-X)) print(ans)" p02553,s141048439,Accepted,"a, b, c, d = map(int, input().split()) ans = [a*c, a*d, b*c, b*d] print(max(ans))" p02935,s405037453,Accepted,"from collections import deque n = int(input()) v = deque(sorted(list(map(int, input().split())))) for i in range(n-1): v1 = v.popleft() v2 = v.popleft() v.appendleft((v1+v2)/2) print(v[0])" p03457,s183996745,Accepted,"n = int(input()) TXY = [(0, 0, 0)] for i in range(n): TXY.append(tuple(map(int, input().split()))) for (t1, x1, y1), (t2, x2, y2) in zip(TXY, TXY[1:]): dist = abs(x2 - x1) + abs(y2 - y1) d = t2 - t1 flag = False for t in range(d, -1, -2): if t == dist: flag = True break if flag == False: print(""No"") exit() else: print(""Yes"")" p02606,s912382325,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)" p03035,s176928881,Accepted,"A, B = map(int, input().split()) if A >= 13: print(B) elif 6 <= A <= 12: print(int(B/2)) else: print(0)" p02582,s789477146,Accepted,"# from pprint import pprint # import math # import collections s = input() # n, k = map(int, input().split(' ')) # a = list(map(int, input().split(' '))) # a = [] # for i in range(n): # a.append(int(input())) if s == 'RRR': ans = 3 elif s in ('RRS', 'SRR'): ans = 2 elif s == 'SSS': ans = 0 else: ans = 1 print(ans) " p03250,s582575963,Wrong Answer," a,b,c = map(int,input().split()) if a*10+b+c <= a+b*10+c: print(a+b*10+c) else: print(a*10+b+c) " p02754,s405139518,Accepted,"#!/usr/bin/env python # -*- coding: utf-8 -*- n, a, b = map(int, input().split()) if a == 0: print(a) exit() # 整数除算 m = n // (a+b) # あまり amari = n % (a+b) # まずはあまりを除いた青の数 blue_num = m * a if a > amari: blue_num += amari elif a <= amari: blue_num += a print(blue_num) " p02694,s706527838,Accepted,"X=int(input()) deposit=100 year=0 while(deposit n: tmp+=1 else: count[i] += 1 ans = 0 for i in range(n+1): if count[i] >= i: ans += count[i] - i else: ans+=count[i] print(ans+tmp)" p02779,s506074964,Accepted,"''' Sample Input 1 5 2 6 1 4 5 Sample Output 1 YES ''' lens = int(input()) arrs = [int(x) for x in input().split()] print([""NO"", ""YES""][len(arrs) == len(set(arrs))])" p03317,s097571492,Wrong Answer,"n, k = [int(i) for i in input().split()] nums = [int(i) for i in input().split()] print(n//(k-1)) " p03644,s316372379,Accepted,"N = int(input()) ans = 1 while True: ans *=2 if ans> N: print(int(ans /2)) break" p02813,s835328915,Accepted,"import math def number(plist): a = 1 memo = [] while len(plist) > 0: p = plist.pop(0) memo.append(p) num = len(set(range(1, p)) - set(memo)) a += math.factorial(len(plist)) * num return a n = int(input()) plist = list(map(int, input().split())) qlist = list(map(int, input().split())) a = number(plist) b = number(qlist) print(int(math.fabs(a - b)))" p02789,s429907801,Wrong Answer,"n,m=map(int,input().split()) if m>=n: print('YES') else: print('NO')" p03095,s167342785,Accepted,"alphabetlist=['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'] N=int(input()) S=input() dic={moji:0 for moji in alphabetlist} for i in range(N): dic[S[i]]+=1 ans=1 mod=10**9+7 for moji in dic: ans*=dic[moji]+1 ans%=mod ans-=1 ans%=mod print(ans)" p02767,s532675204,Accepted,"N = int(input()) X = list(map(int,input().split())) m = 10 ** 6 for p in range(1,100): s = 0 for i in range(N): s += (p-X[i])**2 m = min(m,s) print(m)" p03485,s524194168,Accepted,"a,b=map(int, input().split()) if (a+b)%2==0: print(int((a+b)/2)) else: print((a+b)//2+1)" p02717,s868231186,Accepted,"a,b,c=input().split() print(c,a,b)" p02909,s287531608,Accepted,"s = input() if(s == ""Sunny""): print(""Cloudy"") elif(s == ""Cloudy""): print(""Rainy"") elif(s == ""Rainy""): print(""Sunny"")" p03485,s030142422,Wrong Answer,"a, b = map(int, input().split()) print((a + b) // 2) " p03625,s997866467,Accepted,"n = int(input()) lst = list(map(int, input().split())) lst.sort() count = [] i = 0 while i 0: b = 1 else: b = 0 else: b = 0 print(ans)" p02729,s257322217,Accepted,"N, M = map(int, input().split()) x = N + M print(x * (x - 1) // 2 - N * M)" p03377,s900162608,Wrong Answer,"a, b, x = map(int, input().split()) if a > x: print('No') elif a + b >= x: print('YES') else: print('NO')" p03698,s679311850,Accepted,"s = input() l = len(s) m = set() for i in range(l): m.add(s[i]) m = len(list(m)) if l == m: print('yes') else: print('no')" p02546,s580752236,Accepted,"s = input() print(s + ('s' if s[-1] != 's' else 'es')) " p02786,s200369016,Wrong Answer,"import math H = int(input()) count = 0 count = int(math.log2(H)) total = 0 total = (1 - (2**(count + 1)))/(1 - 2) print(total) " p04044,s293233663,Accepted,"N, L = map(int, input().split()) s = sorted([input() for i in range(N)]) print(*s, sep="""") " p02994,s007952020,Wrong Answer,"n,l = list(map(int,input().split())) r = [l+i for i in range(n)] min_r = 1000000000 for i in r: if min_r > abs(i): min_r = abs(i) ans = i print(sum(r)-i) " p03251,s108521758,Accepted,"n,m,x,y = map(int,input().split()) a = list(map(int,input().split())) b = list(map(int,input().split())) ans = ""War"" am = max(a) bm = min(b) for z in range(x+1,y+1): if am=z: ans = ""No War"" break print(ans)" p03474,s176383591,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"")" p03319,s203601453,Wrong Answer,"n,m = map(int,input().split("" "")) ar = list(map(int,input().split("" ""))) i = ar.index(1) count = 0 am = 0 if n <= m: print(1) exit() if i % (m - 1) == 0: count += i // (m - 1) else: count += i // (m - 1) + 1 am += i % (m - 1) if (n - 1 - i) % (m - 1) == 0: count += (n - 1 - i) // (m - 1) else: count += (n - 1 - i) // (m - 1) + 1 am += (n - 1 - i) % (m - 1) if am == m - 1: count -= 1 print(count)" p03319,s255926979,Accepted,"n,k=map(int, input().split()) print(-(-~-n//~-k)) " p03284,s903033514,Wrong Answer,"n,k=map(int,input().split()) print(""1"" if n%k==0 else ""1"")" p02939,s436322339,Accepted,"S = input() li = [] st = '' for c in S: st += c if len(li) == 0: li.append(st) st = '' elif li[len(li) - 1] == st: continue else: li.append(st) st = '' print(len(li))" p02759,s696629268,Accepted,"import math a=int(input()) s=a/2 print(math.ceil(s)) " p02773,s845257878,Wrong Answer,"n = int(input()) s = [input() for _ in range(n)] ans = {} for si in s: if si in ans: ans[si] += 1 else: ans[si] = 0 max_cnt = ans[max(ans)] ans = [t for t in ans.keys() if ans[t] == max_cnt] for t in sorted(ans): print(t) " p02713,s078875845,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) " p02743,s046751369,Accepted,"a, b, c = map(int, input().split()) if a + b >= c: print(""No"") else: if (a + b - c) ** 2 > 4 * a * b: print(""Yes"") else: print(""No"")" p02771,s883464702,Wrong Answer,"a,b,c = map(int,input().split()) if (a==b and c==a): if a!=b and b!=c:print('No') else:print('Yes')" p02923,s962076395,Wrong Answer,"N = int(input()) H = list(map(int, input().split())) a, b = 0, 0 for i in range(N-1): if H[i] >= H[i+1]: b += 1 else: b = 0 a = max(a, b) print(a)" p02823,s599578521,Accepted,"n, a, b = map(int, input().split()) ans = (b-a)//2 if a%2 == b%2: print(ans) else: if a-1 >= n-b: ans += n-b+1 a = a+n-b+1 b = n print(ans) elif n-b > a-1: ans += a b = b-a a = 1 print(ans)" p02900,s619577173,Accepted,"a,b=map(int,input().split()) import fractions g=fractions.gcd(a,b) 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 set(a) print(len(prime_factorize(g))+1) " p03086,s740672420,Accepted,"s = input() acgt = 'ACGT' res = cnt = 0 for i in s: if i in acgt: cnt += 1 else: res = max(cnt, res) cnt = 0 res = max(cnt, res) print(res) " p03127,s135520711,Accepted,"import fractions from functools import reduce def gcd_list(numbers): return reduce(fractions.gcd, numbers) n = int(input()) a = list(map(int,input().split())) print(gcd_list(a))" p03387,s539215791,Accepted,"L = list(map(int, input().split())) L.sort() ans = 0 ans += L[2]-L[1] L[0] += L[2]-L[1] L[1] = L[2] if (L[2]-L[0])%2 == 0: ans += (L[2]-L[0])//2 else: ans += 1+(L[2]+1-L[0])//2 print(ans) " p03211,s077186630,Wrong Answer,"comp=753 s=input() ans=1000000000 for i in range(7,0,-1): if s.count(str(i)): left = s.find(str(i)) while left!=-1 and left<=len(s)-3: tmp = int(s[left:left+3]) ans = min(ans, abs(comp-tmp)) left = s.find(str(i),left+1) break print(ans) " p02706,s824170010,Wrong Answer,"a = input() b = input() temp = a.split() n = int(temp[0]) n -= 1 m = int(temp[1]) ai = b.split() sum = 0 for i in range(m): sum += int(ai[i]) temp1 = n - sum if n <= 0: print(-1) else: print(temp1)" p03469,s110220541,Wrong Answer,"y,m,d = map(int,input().split('/')) print(""2018""+'/'+str(m)+'/'+str(d)) " p03471,s025923402,Wrong Answer,"import sys list = input().split("" "") N = int(list[0]) Y = int(list[1]) for yukichi in range(0,N+1): for ichiyo in range(0,N - yukichi): hideyo = N - yukichi - ichiyo if 10000*yukichi + 5000*ichiyo + 1000*hideyo == Y: print(yukichi,ichiyo,hideyo) sys.exit() print(-1,-1,-1)" p02761,s654640551,Wrong Answer,"n, m = map(int, input().split()) s = ""0"" * n flag = 0 for _ in range(m): a, b = map(int, input().split()) if s[a - 1] != '0': if s[a - 1] != str(b): flag = 1 s = s[:a-1] + str(b) + s[a:] if flag == 0: if n == 1: print(s) elif int(s) >= 10 ** (n - 1): print(s) else: print(-1) else: print(-1)" p02838,s828772793,Wrong Answer,"n = int(input()) a = list(map(int, input().split())) bitsum = [0 for _ in range(60)] for x in a: for i in range(60): bitsum[i] += bool(x & (1 << i)) ans = 0 for x in a: for i in range(60): k = bitsum[i] if (x & (1 << i)): k = n - k ans += k << i print(ans//2)" p02556,s537393372,Accepted,"n=int(input()) P=[] M=[] for i in range(n): x,y=map(int,input().split()) P.append(x+y) M.append(x-y) dP=abs(max(P)-min(P)) dM=abs(max(M)-min(M)) print(max(dP,dM))" p03017,s029600087,Accepted,"import sys readline = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 8) INF = float('inf') MOD = 10 ** 9 + 7 def main(): int1 = lambda x: int(x) - 1 N, A, B, C, D = map(int1, input().split()) S = input() if ""##"" not in S[A:B + 1] and ""##"" not in S[C:D + 1]: if C > D and ""..."" not in S[B - 1:D + 2]: print(""No"") else: print(""Yes"") else: print(""No"") if __name__ == '__main__': main()" p03673,s231641247,Accepted,"n = int(input()) a = list(map(int,input().split())) o = [] for i in range(n)[::-2]: o.append(a[i]) for i in range(n)[n%2::2]: o.append(a[i]) print(*o)" p03557,s199473897,Wrong Answer,"import bisect n = int(input()) X = sorted(list(map(int,input().split())), reverse=True) Y = sorted(list(map(int,input().split())), reverse=True) Z = sorted(list(map(int,input().split())), reverse=True) print(sum(bisect.bisect_right(X,b) * (n-bisect.bisect_left(Z,b))) for b in Y)" p03360,s568511538,Accepted,"a = [int(i) for i in input().split()] k = int(input()) a.sort() note = a[2] for i in range(k): note *= 2 print(a[0] + a[1] + note) " p02608,s706973131,Accepted,"n = int(input()) l = [0] * (10**5) N = 10**4 for i in range(1, 10**2+1): for j in range(1, 10**2+1): for k in range(1, 10**2+1): a = i*i + j*j + k*k + i*j + j*k + k*i l[a] += 1 for i in range(n): print(l[i+1])" p04011,s700244020,Wrong Answer,"n=input() k=input() x=input() y=input() print (k*x) + (n-k)*y" p02547,s688689438,Wrong Answer,"N= int(input()) a = [input().split() for i in range(N)] Is = [] for i in range(N): Ds = a[i] if Ds[0] == Ds[1]: Is.append(i) Boooo = False for i in range(len(Is)-2): if Is[i] == Is[i+1] and Is[i+1] == Is[i+2]: Boooo = True if Boooo: print(""Yes"") else: print(""No"") " p02546,s437637534,Accepted,"str1=input() str5=""es"" str6='s' if(str1[-1]!='s'): str2=str1[0:]+str6[0:] else: str2=str1[0:]+str5[0:] print(str2)" p02726,s368368307,Accepted,"N, X, Y = map(int, input().split()) X -= 1 Y -= 1 output = [0]*N for i in range(N-1): for j in range(i+1, N): output[min((j-i), abs(i-X)+1+abs(j-Y))] += 1 for i in range(1, N): print(output[i])" p03862,s379638975,Accepted,"n,x=map(int,input().split()) a=[int(i) for i in 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: temp = a[i] + a[i+1] - x ans += temp a[i+1] -= temp print(ans)" p02681,s545346408,Wrong Answer,"s = input() t = input() print(s) print(t[0:-1]) if s == t[0:-1]: print(""Yes"") else: print(""No"")" p02767,s882155245,Accepted,"N = int(input()) X = list(map(int, input().split())) P = sum(X)//N ans1 = 0 ans2 = 0 for x in X: ans1 += (P-x)**2 ans2 += (P+1-x)**2 print(min(ans1, ans2)) " p03328,s620434606,Accepted,"a,b = map(int,input().split()) c = abs(b - a) x = 0 for i in range(1,c+1): x += i print(x-b)" p03659,s506497628,Accepted,"N = int(input()) a = list(map(int,input().split())) total = sum(a) ans = float('inf') x = 0 for i in range(N-1): x += a[i] ans = min(abs(total-2*x),ans) print (ans) " p03815,s183351872,Accepted,"x = int(input()) per11 = x // 11 remain_per11 = x % 11 if remain_per11 >= 7: print(per11*2 + 2) elif remain_per11 == 0: print(per11*2) else: print(per11*2 + 1)" p03105,s773034056,Accepted,"def resolve(): A, B, C = list(map(int, input().split())) print(min(C, B//A)) if '__main__' == __name__: resolve()" p03471,s338492470,Wrong Answer,"import sys inf = 10**15 mod = 10**9+7 n, y = map(int, input().split()) ans=0 A = y//10000 for i in range(A+1): restY = y-i*10000 restN = n-i if restY >= 0 and restN >= 0: B = restY//5000 for j in range(B+1): restY = restY-j*5000 restN = restN-j if restN>=0 and restY == restN*1000: print('{} {} {}'.format(i,j,restN)) sys.exit() print('{} {} {}'.format(-1,-1,-1))" p03250,s816770599,Wrong Answer,"A,B,C=map(int,input().split()) ichi=10*A+B+C two=A+10*B+C three=C*10+A+B print(max(ichi,two)) " p03761,s754924485,Accepted,"import sys def main(): n = int(input()) s = [x.rstrip() for x in sys.stdin.readlines()] alphabet = ""abcdefghijklmnopqrstuvwxyz"" for c in alphabet: minc = 10**10 for x in s: cnt = x.count(c) minc = min(cnt, minc) print(c*minc, end="""") if __name__ == '__main__': main() " p03611,s462862865,Accepted,"N=int(input()) a=list(map(int,input().split())) res=0 count=[0]*(10**5+2) for i in range(N) : count[a[i]]+=1 for i in range(10**5) : x=count[i]+count[i+1]+count[i-1] res=max(res,x) print(res)" p02970,s568923841,Accepted,"N, D = [int(s) for s in input().split()] print(N // (2 * D + 1) + (N % (2 * D + 1) != 0) )" p03962,s972954300,Accepted,"a, b, c = map(int,input().split()) i = 3 if a==b: i-=1 if b==c: i-=1 if c==a: i-=1 if not i: i=1 print(i)" p03852,s220687990,Accepted,"c = str(input()) if c in ""aiueo"": print(""vowel"") else: print(""consonant"") " p02570,s478998665,Accepted,"d, t, s = map(int, input().split()) if s * t >= d: print('Yes') else: print('No')" p04033,s100520407,Accepted,"a,b = map(int, input().split()) mafs = 0 if a < 1 and b >=0: print(""Zero"") elif a > 0 and b > 0: print(""Positive"") elif a < 0 and b < 0: if (abs(a) - abs(b) + 1) % 2 == 0: print(""Positive"") else: print(""Negative"")" p03162,s668167990,Accepted,"N = int(input()) a = [list(map(int, input().split())) for _ in range(N)] a.insert(0, [0, 0, 0]) dp = [[0, 0, 0] 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: dp[i][j] = max(dp[i][j], a[i][j] + dp[i - 1][k]) print(max(dp[-1]))" p02753,s650623769,Accepted,"s = input() if s in ['AAA', 'BBB']: print('No') else: print('Yes')" p02861,s235959972,Accepted,"n = int(input()) list = [[int(j) for j in input().split()] for _ in range(n)] ans = 0 for i in range(n): for j in range(n): ans += ((list[i][0] - list[j][0]) ** 2 + (list[i][1] - list[j][1]) ** 2) ** 0.5 print(ans / n)" p02594,s068638567,Accepted,"x = int(input()) if x >= 30: print('Yes') else: print('No')" p03206,s293200960,Accepted,"N = int(input()) if N==25:print(""Christmas"") elif N==24:print(""Christmas Eve"") elif N==23:print(""Christmas Eve Eve"") else : print(""Christmas Eve Eve Eve"")" p03371,s668407779,Wrong Answer,"A,B,C,X,Y = list(map(int, input().split())) ans1 = 0 ans2 = 0 ans3 = 0 # 通常のケース ans1 = A * X + B * Y # 半分のケース if X >= Y: ans2 = Y * 2 * C + (X - Y) * A if Y * 2 > X: ans3 = X * 2 * C else: ans2 = X * 2 * C + (Y - X) * A if X * 2 > Y: ans3 = Y * 2 * C print(min(ans1,ans2,ans3)) " p03639,s861688375,Accepted,"n = int(input()) a = list(map(int, input().split())) cnt_4, cnt_2 = 0, 0 for num in a: if num % 4 == 0: cnt_4 += 1 elif num % 2 == 0: cnt_2 += 1 if n//2 <= cnt_4 + cnt_2//2: print(""Yes"") else: print(""No"")" p03286,s612642955,Accepted,"n = int(input()) ans="""" if n == 0: print(0) exit() while n: if n % 2 != 0: ans += ""1"" n -= 1 else: ans += ""0"" n //= -2 print(ans[ : : -1])" p03827,s940802438,Accepted,"n = int(input()) s = input() x = 0 ans = 0 for i in range(n): if s[i] == 'I': x += 1 ans = max(ans, x) elif s[i] == 'D': x -= 1 print(ans)" p03795,s639254204,Accepted,"n=int(input()) print(800*n-200*(n//15))" p04020,s245288578,Wrong Answer,"import sys readline = sys.stdin.readline N,*A = map(int,open(0).read().split()) A += [0] ans = 0 for i in range(len(A)): if A[i] % 2 == 1 and A[i + 1] % 2 == 1: A[i] += 1 A[i + 1] -= 1 ans += A[i] // 2 print(ans)" p03206,s184361595,Accepted,"D = int(input()) print(""Christmas""+"" Eve""*(25-D))" p02843,s137937201,Accepted,"X = int(input()) dp = [0] * (X + 1000) dp[0] = 1 array = [100, 101, 102, 103, 104, 105] for x in range(X): for y in array: if dp[x] == 1: dp[x + y] = 1 print(dp[X]) " p03417,s807052521,Accepted,"a, b = map(int, input().split()) n = min(a, b) m = max(a, b) if n == 1 and m == 1: print(1) elif n == 1: print(m-2) else: print((n-2)*(m-2)) " p02880,s949084886,Wrong Answer,"N = int(input()) for i in range(1,10): if N % i != 0: print(""No"") elif N / i < 10: print(""Yes"") else: print(""No"")" p02596,s401145925,Accepted,"K = int(input()) count = 1 m = 7 % K s = set() while 1: if m == 0: print(count) break if m in s: print(-1) break count += 1 s.add(m) m = (m * 10 + 7) % K " p03835,s590278465,Wrong Answer,"k, s = map(int, input().split()) ans = 0 for x in range(k): for y in range(k): for z in range(k): if s == x+y+z: ans += 1 print(ans)" p02832,s899456593,Accepted,"N = int(input()) As = list(map(int, input().split())) isOKs = [False] * (N+1) isOKs[0] = True for A in As: if isOKs[A-1]: isOKs[A] = True for A in reversed(range(1, N+1)): if isOKs[A]: print(N-A) break else: print(-1) " p03061,s839158434,Accepted,"from fractions import gcd n = int(input()) A = list(map(int, input().split())) ans = 0 l = [A[0]] r = [A[n-1]] for i in range(1, n): l.append(gcd(l[i-1], A[i])) r.append(gcd(r[i-1], A[n-i-1])) r.reverse() # print(l, r) for i in range(n): if i == 0: cost = r[1] elif i == n-1: cost = l[n-2] else: cost = gcd(l[i-1], r[i+1]) if ans < cost: ans = cost print(ans) " p03495,s265621553,Wrong Answer,"N, K = map(int,input().split()) A = list(map(int,input().split())) Are = list(set(A)) if len(Are) <= K: print(0) exit() else: B = [] for i in range(len(Are)): B.append(A.count(Are[i])) B.sort() for i in range(len(B)): if i+1 >= len(Are)-K: print(sum(B[:i+1])) break print(B)" p03239,s902933266,Accepted,"N, T = map(int, input().split()) ans = 10 ** 9 for i in range(N): c, t = map(int, input().split()) if T >= t: ans = min(ans, c) if ans != 10 ** 9: print(ans) else: print(""TLE"") " p02603,s032174846,Accepted,"N = int(input()) A = list(map(int,input().split())) M = 1000 for i in range(N-1): if A[i] < A[i+1]: have = M // A[i] rest = M % A[i] M = have*A[i+1]+rest print(M)" p02881,s258697051,Accepted,"n = int(input()) import math start = math.floor(math.sqrt(n)) for i in reversed(range(start+1)): if i == 0: i = n else: if n/i == int(n/i): break print(i+n//i-2)" p02606,s686862206,Accepted,"L,R,d=list(map(int,input().split())) count = 0 for i in range(L,R+1): if i%d==0: count+=1 print(count)" p03612,s351307899,Accepted,"from itertools import groupby n = int(input()) a = list(map(int,input().split())) b = [i + 1 == j for i, j in enumerate(a)] res = 0 for k, v in groupby(b): if not k:continue vv = len(list(v)) res += (vv + 1) // 2 print(res)" p02897,s029471543,Wrong Answer,"N = int(input()) if N%2==0: print(""0.5000000000"") else: print(""0.6000000000"") " p03471,s146960137,Accepted,"n, y = [int(i) for i in input().split()] a, b, c, f = 0, 0, 0, 0 for i in range(n+1): for j in range(n+1): k = (y - 10000*i - 5000*j)/1000 if k == n-i-j and k>=0: a, b, c = i, j, k f += 1 break if f == 0: print(-1,-1,-1) else: print(int(a), int(b), int(c))" p03239,s630385699,Accepted,""""""" author : halo2halo date : 22, 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 sys.setrecursionlimit(10 ** 7) N, T = map(int, readline().split()) ans = 10000 for _ in range(N): c, t = map(int, readline().split()) if c <= ans and t <= T: ans = c print(""TLE"" if ans == 10000 else ans) " p03657,s322569156,Wrong Answer,"print(""Im""*(sum(map(int,input().split()))%3>0)+""Possible"")" p03632,s914333176,Accepted,"A,B,C,D = map(int,input().split()) if min(B,D)= x: ans = min(ans, c @ b.T) return str(ans if ans < n*10**5 else -1) if __name__ == '__main__': import sys print(solve(sys.stdin.read().strip())) " p03013,s870375631,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] = 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]) " p03087,s827367951,Accepted,"N, Q = map(int, input().split()) S = input() T = [0]*(N+1) for i in range(1, N): T[i+1] = T[i] + (1 if S[i-1:i+1]=='AC' else 0) ans = [] for _ in range(Q): l, r = map(int, input().split()) ans.append(T[r] - T[l]) print(*ans, sep='\n')" p02742,s343497983,Wrong Answer,"H, W = map(int, input().split()) total = H*W if total % 2 == 0: ans = total//2 else: total += 1 ans = total//2 print(ans) " p03448,s007308914,Accepted,"A = int(input()) B = int(input()) C = int(input()) X = int(input()) total = 0 for i in range(A+1): for j in range(B+1): for k in range(C+1): Ans = 500*i + 100*j + 50*k if Ans == X: total +=1 print(total) " p03211,s589150390,Accepted,"s=input() a=753 ans=999 for i in range(len(s)-2): n=int(s[i:i+3]) tmp=abs(a-n) if tmp ans: ans = cnt print(ans)" p04031,s731048886,Accepted,"n = int(input()) A = list(map(int,input().split())) ans = 10**9 for i in range(-100,101): a = 0 for j in A: a += (j-i)**2 ans = min(ans,a) print(ans)" p02712,s036668787,Wrong Answer,"N = int(input()) ans = 0 for i in range(N): if i % 3 !=0 and i % 5 != 0: ans += i print(ans)" p02622,s405945663,Wrong Answer,"S=input() T=input() count=0 for i in range(len(S)): if S[i]==T[i]: count+=1 print(count)" p03487,s761245667,Accepted,"from collections import * n=int(input()) l=list(map(int,input().split())) d=defaultdict(int) for i in l: d[i]+=1 c=0 for i in d: if(i!=d[i]): if(d[i]>i): c+=d[i]-i else: c+=d[i] print(c) " p02708,s493408822,Accepted,"N,K = map(int,input().split()) l = list() for i in range(K,N+2): min = i*(i - 1)/2 max = (2*N - i + 1)*i /2 cases = max - min + 1 l.append(cases) print(int(sum(l)) % (10**9 + 7))" p02818,s843071601,Accepted,"def solve(string): a, b, k = map(int, string.split()) return ""{} {}"".format(max(0, a - k), max(0, min(b, a + b - k))) if __name__ == '__main__': import sys print(solve(sys.stdin.read().strip())) " p03773,s026197299,Accepted,"a,b = map(int,input().split()) print((a+b)%24)" p03836,s935209242,Wrong Answer,"X = list(map(int, input().split())) sx = X[0] sy = X[1] tx = X[2] ty = X[3] x = tx - sx y = ty - sy print(x, y) l1 = ""U"" * y + ""R"" * x l2 = ""D"" * y + ""L"" * x l3 = ""L"" + ""U"" * (y + 1) + ""R"" * (x + 1) + ""D"" l4 = ""R"" + ""D"" * (y + 1) + ""L"" * (x + 1) + ""U"" print(l1 + l2 + l3 + l4)" p02618,s092839744,Accepted,"D = int(input()) for i in range(D): print(i%26+1)" p03317,s254294430,Wrong Answer,"import sys input = sys.stdin.readline def main(): N, K = [int(x) for x in input().split()] A = [int(x) for x in input().split()] x = A.index(1) l = -((-x) // (K - 1)) lmod = (x + 1) % K r = -(-(N - x - 1 - lmod) // (K - 1)) print(l + r) if __name__ == '__main__': main() " p03627,s887230790,Wrong Answer,"import sys from collections import Counter n = int(input()) a_ls = [int(i) for i in sys.stdin.readline().split()] ct = Counter(a_ls) ct = [(i, j) for i, j in sorted(ct.items(), key=lambda x:x[0], reverse=True) if j > 1] if len(ct) < 2: print(0) else: print(ct[0][0] * ct[1][0])" p03061,s762017757,Accepted,"from math import gcd N=int(input()) A=list(map(int,input().split())) L=[0] R=[0] for i in range(N): L.append(gcd(L[i],A[i])) R.append(gcd(R[i],A[-i-1])) R=R[::-1] P=0 for i in range(N): P=max(P,gcd(L[i],R[i+1])) print(P)" p02612,s522345078,Wrong Answer,"N = int(input()) a = 0 if N >= 1000: a = N - 1000 else: a = a while a >= 1000: a = a - 1000 if a != 0: a = 1000 - a print(a)" p03457,s403693498,Accepted,"N = int(input()) now = [0,0] tnow = 0 ans = 'Yes' for i in range(N): t,x,y = map(int,input().split()) dis = abs(x-now[0]) + abs(y-now[1]) if t-tnow >= dis and (t-tnow)%2 == dis%2: tnow = t now = [x,y] else: ans = 'No' break print(ans)" p03076,s235159362,Accepted,"L = [] for i in range(5): L.append(int(input())) L1 = [x for x in L if x%10 == 0] L2 = [x for x in L if x%10 != 0] L3 = [(x%10,x//10) for x in L2] ans = sum(L1) if len(L3)>0: L3.sort(reverse = True) for i in range(len(L3)-1): ans += (L3[i][1]+1)*10 ans += L3[-1][1]*10+L3[-1][0] print(ans) " p03208,s011571082,Accepted,"n, k = map(int, input().split()) h = [int(input()) for i in range(n)] h.sort() ans = h[n-1] for i in range(n-k+1): if ans > (h[i+k-1]-h[i]): ans = h[i+k-1]-h[i] print(ans) " p02993,s010711021,Accepted,"a = input() print('Good' if a[0] != a[1] !=a[2] !=a[3] else 'Bad')" p02747,s709416437,Accepted,"#A - Hitachi String S = list(input()) count = 0 if len(S) % 2 == 1: print(""No"") exit() else: for i in range(0,int(len(S)//2),2): if S[i]+S[i+1] == ""hi"": pass else: print(""No"") exit() print(""Yes"")" p03625,s855705087,Accepted,"n = int(input()) a = list(map(int, input().split())) count = {} for i in a: if i in count: count[i] += 1 else: count[i] = 1 edges = [] for i,j in count.items(): if j >= 2: edges.append(i) if j >= 4: edges.append(i) edges.sort(reverse=True) if len(edges)<2: print(0) else: print(edges[0]*edges[1])" p04029,s414526963,Accepted,"n = int(input()) print(n*(n+1)//2)" p02731,s275122195,Accepted,"L = int(input()) volume = (L / 3)**3 print(volume)" p03971,s142419666,Accepted,"n, a, b = map(int, input().split()) s = input() a_n = 0 b_n = 0 for i in range(len(s)): m = s[i:i+1] if(m == ""a""): if(a_n + b_n < a + b): print(""Yes"") a_n += 1 else: print(""No"") elif(m == ""b""): if((a_n + b_n < a + b) and (b_n < b)): print(""Yes"") b_n += 1 else: print(""No"") else: print(""No"")" p03494,s597207580,Accepted,"n = int(input()) nums = [int(i) for i in input().split()] ans = 0 while True: if [i for i in nums if i % 2 == 1]: break nums = [i//2 for i in nums] ans += 1 print(ans)" p03524,s481842252,Accepted,"from collections import defaultdict s = input() d = defaultdict(int) for i in s: d[i] += 1 if len(s) == 1: print ('YES') exit() if len(d) == 1: print ('NO') exit() if len(d) == 2: if len(s) == 2: print ('YES') exit() else: print ('NO') exit() a = list(d.values()) if max(a) - min(a) < 2: print ('YES') else: print ('NO') " p03795,s280651540,Accepted,"n = int(input()) print((800 * n) - (200 * (n // 15)))" p03767,s009887371,Accepted,"N = int(input()) A = sorted(list(map(int, input().split()))) # print([A[-i] for i in range(2, 2*N+1, 2)]) print(sum([A[-i] for i in range(2, 2*N+1, 2)])) " p02773,s993481262,Accepted,"N = int(input()) d = {} for _ in range(N): s = input() if s not in d: d[s] = 0 d[s] += 1 max_val = max(d.values()) keys = [k for k, v in d.items() if v == max_val] for k in sorted(keys): print(k)" p02866,s165237483,Wrong Answer,"from collections import Counter N = int(input()) D = list(map(int, input().split())) if D[0] != 0: print(0) exit() C = sorted(Counter(D).most_common(), key=lambda x: x[0]) if C[0][1] > 1: print(0) exit() ans = 1 for i in range(1, len(C)): ans *= C[i - 1][1] ** C[i][1] print(ans) " p02768,s802228039,Accepted,"def modinv(a,m): return pow(a,m-2,m) n,a,b = map(int,input().split()) P = 10**9+7 nCa = 1 for i in range(1,a+1): nCa = nCa*(n+1-i)*modinv(i,P)%P nCb = nCa for j in range(a+1,b+1): nCb = nCb*(n+1-j)*modinv(j,P)%P ans = (pow(2,n,P) -1 - nCa - nCb + 2*P)%P print(ans) " p02748,s505845700,Accepted,"A,B,M=map(int,input().split()) a=list(map(int,input().split())) b=list(map(int,input().split())) x=[] y=[] c=[] for _ in range(M): x0,y0,c0=map(int,input().split()) x.append(x0) y.append(y0) c.append(c0) ans = min(a) + min(b) for i in range(M): price = a[x[i]-1] + b[y[i]-1] - c[i] if price < ans: ans = price print(ans) " p02628,s187943823,Accepted,"N, K = list(map(int, input().split())) p = list(map(int, input().split())) p.sort() print(sum(p[:K]))" p02765,s975619215,Accepted,"N, R = map(int, input().split()) print(R if N >= 10 else R+100*(10-N))" p03665,s144999907,Accepted,"import math def combination(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())) odd = 0 even = 0 for a in A: if a % 2 == 0: even += 1 else: odd += 1 ans = 0 for i in range(P, odd+1, 2): tmp = combination(odd, i) for j in range(0, even+1): ans += tmp * combination(even, j) print(ans) " p03611,s621981609,Accepted,"from collections import Counter n = int(input()) A = list(map(int, input().split())) C = Counter(A) ans = 0 start, end = min(A), max(A) + 1 for v in range(start, end): ans = max(C[v - 1] + C[v] + C[v + 1], ans) print(ans)" p04031,s454942960,Wrong Answer,"#ABC043C n=int(input()) a = list(map(int, input().split())) h=sum(a)//len(a) sum_a=0 for i in range(len(a)): sum_a=sum_a+(a[i]-h)**2 print(int(sum_a))" p02693,s538506412,Accepted,"if __name__ == ""__main__"": k = int(input()) a, b = map(int, input().split()) ans = """" if a % k == 0: ans = ""OK"" else: x = a // k if k * (x + 1) <= b: ans = ""OK"" else: ans = ""NG"" print(ans)" p02731,s421004589,Accepted,print((int(input())/3)**3) p03836,s442339253,Accepted,"sx, sy, tx, ty = map(int, 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"", end="""")" p03417,s430594566,Wrong Answer,"n,m=map(int,input().split()) if n==1: print(m-2) elif m==1: print(n-2) else: print(0)" p02946,s072934650,Accepted,"K, X = map(int, input().split()) print(*[i for i in range(X-K+1, X+K)])" p02711,s333800909,Wrong Answer,"if __name__ == ""__main__"": n = input() if '7' in n: print('yes') else: print('no')" p02795,s900069742,Accepted,"h = int(input()) w = int(input()) N = int(input()) cnt, loop = 0, 0 while cnt < N: cnt += max(w, h) loop += 1 print(loop)" p02970,s621919241,Wrong Answer,"N,D=map(int,input().split()) total=0 i=0 while N>=total: i+=1 total=(2*D+1)*i print(i) " p03478,s129045773,Accepted,"N, A, B = map(int, input().split()) ans = 0 def FindSumOfDigits(x): count = 0 while x>0: count += x%10 x = x//10 return count for n in range(1, N+1): count = FindSumOfDigits(n) if A<= count <=B: ans += n print(ans) " p02628,s744349865,Accepted,"n, k = map(int, input().split()) p = list(map(int, input().split())) p.sort() print(sum(p[0:k]))" p02970,s650566426,Wrong Answer,"a,b=input().split() a=int(a) b=int(b) print(a//(b*2+1))" p03261,s561148127,Accepted,"N=int(input()) L=[] count=0 for i in range (N): L.append(input()) if len(set(L))!=N: print(""No"") else: for i in range (N-1): if L[i][-1]!=L[i+1][0]: count+=1 if count==0: print(""Yes"") else: print(""No"")" p03043,s828627842,Accepted,"import numpy as np N, K = map(int, input().split()) P = 0 for p in range(1, N+1): i = max(0, np.ceil(np.log2(K/p))) P += (1/N)*(0.5**i) print(P) " p02900,s623423036,Accepted,"import fractions a,b=map(int,input().split()) k=fractions.gcd(a,b) 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([i, cnt]) if temp!=1: arr.append([temp, 1]) return arr print(len(factorization(k))+1)" p03696,s750146947,Accepted,"n = int(input()) S = input() T = S.replace('()', '') for _ in range(50): T = T.replace('()', '') print('(' * T.count(')') + S + ')' * T.count('('))" p02775,s769028926,Accepted,"A = input() S = list(map(int,list(A))) N = len(S) output = 0 for i in range(N): t = N-1-i M = S[t] if M>5: output += 10-M S[t-1]+=1 elif M==5: if S[t-1]>=5: output += 10-M S[t-1]+=1 else: output+=M else: output += M if S[0]>5: output+=1 if A==""5"": output = 5 print(output)" p03427,s974847272,Accepted,"n = int(input()) s = str(n) l = list(s) for i in range(len(l)): l[i] = int(l[i]) print(max(sum(l), int(l[0])-1 + (len(l)-1)*9)) " p02755,s326642776,Wrong Answer,"import math A,B = map(int, input().split()) answerA = math.ceil(A/0.08) answerAA = math.floor((A+1)/0.08) answerB = math.ceil(B/0.1) answerBB = math.floor((B+1)/0.1) if answerA < answerB and answerAA >= answerB: print(answerB) elif answerB < answerA and answerBB >= answerA: print(answerA) elif answerA >= answerB and answerAA <= answerBB: print(answerA) elif answerB >= answerA and answerBB <= answerAA: print(answerB) else: print(""-1"") " p02784,s330589187,Accepted,"def main(): H, N = map(int, input().split(' ')) A = input().split(' ') total = 0 for i in A: total += int(i) if total >= H: print('Yes') else: print('No') main() " p04033,s745115804,Accepted,"# agc002_a.py A, B = map(int,input().split()) if A<=0 and B>=0: print('Zero') elif A>0 and B>0: print(""Positive"") elif A<0 and B<0: if (A-B)%2==0: print(""Negative"") else: print(""Positive"") " p04020,s418057111,Accepted,"n = int(input()) a = [] for i in range(n): a.append(int(input())) b = [] chain = 0 for i in range(n): if(chain>=1 and a[i]==0): b.append(chain) chain = 0 elif(a[i]>=1): chain += a[i] ans=0 b.append(chain) for i in b: ans += i//2 #print(i) print(ans) " p02697,s240016366,Wrong Answer,"N,M = map(int, input().split()) if N%2==1: for i in range(1,M+1): print(i,N-i) else: for i in range(1,M+1): print(2*i-1, N-i) " p02732,s878163850,Accepted,"def conbination_2(n): if n <= 1: return 0 else: return int(n * (n - 1) / 2) N = int(input()) A = list(map(int,input().split())) S = 0 Count = [0] * N for i in range(N): Count[A[i] - 1] += 1 for i in range(N): S += conbination_2(Count[i]) for i in range(N): Ans = S - (Count[A[i] - 1] - 1) print(Ans)" p03289,s769699079,Accepted,"import math def main(): s = input() flg=0 if s[0]=='A': if s[2:len(s)-1].count('C')==1: s=s.replace('C','c') if s[1:].islower(): print(""AC"") flg=1 if flg==0: print(""WA"") main() " p02657,s145741229,Accepted,"a,b = map(int,input().split()) print(a*b)" p03997,s438149458,Accepted,"a = int(input()) b = int(input()) h = int(input()) area = int((a + b) * h / 2) print(area) " p02700,s377632200,Wrong Answer,"A,B,C,D = map(int, input().split()) for i in range(1,201): while A > 0 and C > 0: if i%2==1: C=C-B*(((i-1)/2)+1) if i%2==0: A=A-D*(i/2) if A > 0 and C < 0: print('Yes') if A < 0 and C > 0: print('No') " p03386,s664862115,Accepted,"a,b,k=map(int,input().split()) if k>=b-a+1: for i in range(a,b+1): print(i) else: a_set={i for i in range(a,a+k)} b_set={i for i in range(b-k+1,b+1)} ans_set = sorted(a_set | b_set) for i in ans_set: print(i)" p03471,s167429539,Accepted,"n, y = map(int, input().split()) for senyen in range(n + 1): for gosenyen in range(n + 1 - senyen): manyen = n - senyen - gosenyen if senyen * 1000 + gosenyen * 5000 + manyen * 10000 == y: print(manyen, gosenyen, senyen) exit(0) print(""-1 -1 -1"")" p02771,s453180421,Accepted,"inputs = [int(x) for x in input().split()] if len(set(inputs)) == 2: print('Yes') else: print('No')" p03627,s632947146,Accepted,"from collections import Counter N = int(input()) A = list(map(int,input().split())) c = Counter(A) a, b = 0, 0 for key in sorted(c.keys(), reverse=True): if c[key] >= 4: a = max(a, key) b = max(b, key) elif c[key] >= 2: if a == 0: a = key elif a != 0 and b == 0: b = key print(a*b)" p02729,s729980021,Accepted,"n, m = map(int, input().split()) a = n * (n - 1) // 2 b = m*(m-1)// 2 print(a + b)" p02909,s874119553,Wrong Answer,"S = input() lst = ['Sunny', 'cloudy', 'Rainy'] if S == lst[0]: print(lst[1]) elif S == lst[1]: print(lst[2]) else: print(lst[0]) " p03695,s413977250,Wrong Answer,"from collections import defaultdict n = int(input()) al = list(map(int, input().split())) t = 0 d = defaultdict(lambda: 1) for a in al: if a >= 3200: t += 1 else: d[str(a // 400)] += 1 print(len(d), len(d)+t) " p03633,s116021776,Wrong Answer,"def gcd(a, b): if(a == 0): return b return gcd(b % a, a) def lcm(a, b): if((a * b) / gcd(a, b) > 1000000000000000000): return a/(gcd(a, b) * b) return (a * b) / gcd(a, b) t = int(input()) ans = 1 while(t != 0): t -= 1 n = int(input()) ans = lcm(ans, n) print(int(ans)) " p03136,s928904107,Accepted,"N=int(input()) A=list(map(int,input().split())) L=sorted(A,reverse=True) if L[0]= 2 ** n: n += 1 print(2 ** n - 1)" p03434,s701862563,Accepted,"from sys import stdin N = int(input()) a = list(map(int,stdin.readline().split())) a.sort(reverse=True) Alice = 0 for i in range(0,len(a),2): Alice += a[i] Bob = sum(a)-Alice print(Alice - Bob) " p02963,s574159858,Accepted,"from math import ceil,sqrt;s=int(input());a=ceil(sqrt(s));print(0,0,a,1,a**2-s,a)" p03479,s424286439,Accepted,"X, Y = map(int, input().split()) d = Y // X p = 0 while d != 0: p += 1 d //= 2 print(p)" p03548,s482415863,Accepted,"x,y,z=map(int,input().split()) mitumori=x//(y+z) if x - mitumori*(y+z)>=z:print(mitumori) else:print(mitumori-1) " p02787,s898257797,Accepted,"import numpy as np H, N = map(int, input().split()) AB = np.array([list(map(int, input().split())) for i in range(N)]) A = AB[:, 0] B = AB[:, 1] # インデックスはライフ 値はそれを以下にする最小MP dp = np.array([10**10 for i in range(H+1)], dtype=int) # dp = np.array([np.inf for i in range(H+1)], dtype=int) dp[0] = 0 for i in range(1, H+1): # print(np.maximum(i-A, 0)) dp[i] = min(dp[np.maximum(i-A, 0)] + B) print(dp[-1])" p02760,s260984521,Wrong Answer,"import numpy as np A=[] for i in range(3): A.append(list(map(int,input().split()))) N = int(input()) for line in range(N): b=int(input()) for a in range(3): for a_1 in range(3): if A[a][a_1]==b: A[a][a_1]=0 ans=[] A_r=np.array(A).T.tolist() for k in range(3): if sum(A[k])==0 or sum(A_r[k])==0: ans=[0,0,0] break else: ans.append(A[k][k]) if ans==[0,0,0]: print(""Yes"") else: print(""No"") " p02829,s120248356,Accepted,"#!/usr/bin/env python3 a = int(input()) b = int(input()) if a+b == 3: print(3) elif a+b == 4: print(2) else: print(1) " p02647,s515811009,Accepted,"import sys input = lambda: sys.stdin.readline().rstrip() n, k = map(int, input().split()) a = [int(x) for x in input().split()] from itertools import accumulate for i in range(k): temp = [0]*(n + 1) for j in range(n): b = a[j] left = max(0, j - b) right = min(n - 1, j + b) temp[left] += 1 temp[right + 1] -= 1 a = list(accumulate(temp))[:n] if min(a) == n: print(*a) sys.exit() print(*a) " p02988,s134359534,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: 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() li = rl() cnt = 0 for i in range(1, n-1): if li[i-1] < li[i] < li[i+1]: cnt += 1 print(cnt) " p03944,s757873109,Accepted,"x_max, y_max, N = map(int, input().split()) x_min, y_min = 0, 0 l = [[int(i) for i in input().split()] for _ in range(N)] for i in range(N): if l[i][2] == 1: x_min = max(x_min, l[i][0]) elif l[i][2] == 2: x_max = min(x_max, l[i][0]) elif l[i][2] == 3: y_min = max(y_min, l[i][1]) elif l[i][2] == 4: y_max = min(y_max, l[i][1]) if x_max-x_min > 0 and y_max-y_min: print((x_max-x_min)*(y_max-y_min)) else: print(0) " p02714,s805687440,Accepted,"n=int(input()) s=input() r=s.count(""R"") g=s.count(""G"") b=s.count(""B"") tmp=r*g*b for i in range(n): for dist in range(n): j=i+dist k=j+dist if k>=n: break if s[i]!=s[j] and s[j]!=s[k] and s[k]!=s[i]: tmp-=1 print(tmp)" p03274,s034494846,Accepted,"N, K = map(int, input().split()) X = list(map(int, input().split())) a= [] for i in range(N-K+1): l = X[i] r = X[i+K-1] a.append(min(abs(l)+abs(r-l), abs(r) + abs(r-l))) print(min(a)) " p02726,s333254525,Accepted,"''' ID: essi LANG: PYTHON3 TASK: ‌D.py ''' # edge between x and y make the way. # for every pair of vertix we have two way if x <= j n, x, y = map(int,input().split()) k = [0] * n k[0] = n # nothing for i in range(1, n): for j in range(i + 1, n + 1): if x > j: k[j - i]+= 1 else: way = abs(i-x) + 1 + abs(y-j) #way = min(abs(i-y) + 1 + abs(x-j), way) k[min(j - i, way)]+= 1 for i in range(1, n): print(k[i])" p03161,s852019536,Accepted,"N, K = map(int, input().split()) h = [int(i) for i in input().split()] dp = [10**6] * 100005 dp[0] = 0 # dp[1] = abs(h[1]-h[0]) for i in range(1, N): dp[i] = min(dp[i-j] + abs(h[i-j] - h[i]) for j in range(1,min(K,i)+1)) # print([dp[i-j] + abs(h[i-j] - h[i]) for j in range(1,min(K,i)+1)]) # for j in range(1, min(K,i)+1): # dp[i] = min(dp[i], dp[i-j] + abs(h[i-j] - h[i])) print(dp[N-1])" p03774,s721137796,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)] def dist(AB, CD): return abs(AB[0]-CD[0]) + abs(AB[1]-CD[1]) for i in range(N): d = 10**18; ans = -1; for j in range(M): tmp = dist(AB[i], CD[j]) if tmp < d: d = tmp; ans = j+1; print(ans)" p03705,s276575831,Accepted,"n, a, b = map(int, input().split()) if a > b: print(0) elif n == 1 and a != b: print(0) else: print((b * (n-1) + a) - (a * (n-1) + b) + 1)" p02695,s981761864,Accepted,"import itertools N,M,Q = list(map(int,input().split())) list1 = [None for i in range(Q)] for i in range(Q): list1[i] = list(map(int,input().split())) ans = 0 for x in itertools.combinations_with_replacement(range(1,M+1),N): score = 0 x1 = sorted(x) score = sum(y[3] for y in list1 if x1[y[1]-1]-x1[y[0]-1] == y[2]) if score > ans: ans = score print(ans)" p02596,s543022456,Accepted,"K=int(input()) i=1 if K%2==0 or K%5==0: print(-1) elif K%7==0: L=9*K/7 b=10 while True: b=b%L if b==1: print(i) break b=b*10 i+=1 else: L=9*K b=10 while True: b=b%L if b==1: print(i) break b=b*10 i+=1" p02657,s521691224,Accepted,"# coding: utf-8 a, b = input().split() a = int(a) b = float(b) * 1000 b = int(b) print(int((a * b) // 1000)) " p02982,s869731001,Wrong Answer,"import math N, D = map(int, input().split()) X = [] cnt = 0 for i in range(N): X.append(list(map(int, input().split()))) for i in range(1, N): for j in range(i): d = 0 for k in range(D): d += (X[i][k] - X[j][k])**2 for l in range(d): if l**2 == d: cnt += 1 break print(cnt)" p03013,s803634746,Accepted,"n, m = [int(x) for x in input().split()] a = set([int(input()) for _ in range(m)]) dp = [0]*(n+1) dp[0] = 1 for i in range(1, n+1): dp[i] = (dp[i-1] + dp[i-2]) % (10**9+7) if i in a: dp[i] = 0 print(dp[n])" p03145,s694910186,Wrong Answer,"a,b,c=map(int,input().split()) print(a*b*0.5)" p03371,s734068412,Wrong Answer,"a,b,c,x,y=map(int,input().split()) sum=0 if a+b>=2*c: sum+=2*c*min(x,y) x-=min(x,y) y-=min(x,y) if x==0: if b>=2*c: sum+=2*c*y else: sum+=b*y elif y==0: if a>=2*c: sum+=2*c*x else: sum+=a*x else: sum+=a*x+b*y print(sum)" p02578,s218552813,Accepted,"# vim: fileencoding=utf-8 def main(): n = int(input()) li = list(map(int, input().split())) max = 0 total = 0 for i in li: if max < i: max = i continue elif max == i: continue else: total += max - i print(total) if __name__ == ""__main__"": main() " p03038,s887407748,Accepted,"n,m = list(map(int, input().split())) a = list(map(int, input().split())) a1 = [[1,i] for i in a] bc = [list(map(int, input().split())) for _ in range(m)] abc = a1+bc abc.sort(key=lambda x:x[1]) abc.reverse() ans = 0 n1 = n+0 for x,y in abc: if n1 >x: ans += x*y n1 -= x else: ans += n1*y break print(ans)" p02772,s900809778,Accepted,"n = int(input()) a = list(map(int, input().split())) ans = ""APPROVED"" for x in a: if (x % 2 == 0): if (x % 3 != 0 and x % 5 != 0): ans = ""DENIED"" print(ans)" p03719,s777388600,Accepted,"a,b,c = map(int,input().split()) if a<=c<=b: print(""Yes"") else: print(""No"")" p03293,s069265953,Accepted,"s = list(input()) t = list(input()) for i in range(len(s)): if s == t: print(""Yes"") exit() else: a = s.pop(-1) s.insert(0, a) print(""No"") " p02582,s007122828,Accepted,"S = input() if S == ""RRR"": print(3) elif S == ""RRS"" or S == ""SRR"": print(2) elif S == ""SSS"": print(0) else: print(1)" p02597,s533967036,Wrong Answer,"n=int(input()) a=input() con=0 ans=n for i in range(n): if i==ans: break if a[i]==""W"": con+=1 while ans>=0: ans-=1 if i==ans: print(con) exit() if a[ans]==""R"": break print(con) " p02690,s938121633,Accepted,"n = int(input()) a = [] for i in range(1000): a.append(i ** 5) for i in range(1000): for j in range(-1000,1000): if (a[i]) - (j ** 5) == n: print(i,j) exit() " p03827,s026973725,Accepted,"a=int(input()) b=input() c=0 d=0 for i in range(a): if b[i]==""D"": c=c-1 if b[i]==""I"": c=c+1 if c>d: d=c print(d)" p02743,s547201683,Wrong Answer,"import math a, b, c = (int(x) for x in input().split()) sqr_a = math.sqrt(a) sqr_b = math.sqrt(b) sqr_c = math.sqrt(c) if (sqr_a+sqr_b) < sqr_c: print('Yes') else: print('No')" p02570,s765325588,Accepted,"#!/usr/bin/env python # coding: utf-8 def ri(): return int(input()) def rl(): return list(input().split()) def rli(): return list(map(int, input().split())) def main(): d, t, s = rli() if t*s >= d: print(""Yes"") else: print(""No"") if __name__ == '__main__': main() " p03067,s439159110,Accepted,"a,b,c=map(int,input().split()) if (a1: cnt+=1 x/=2 if cnt!=0: z-=(1/n)*(1-1/(2**cnt)) print(z)" p02912,s255361667,Accepted,"import heapq # heapqライブラリのimport N,M=map(int,input().split()) A = list(map(int,input().split())) for j in range(N): A[j]*=-1 heapq.heapify(A) # リストを優先度付きキューへ for i in range(M): c=heapq.heappop(A) c=((-c)//2) heapq.heappush(A, -c) print(-sum(A)) " p02730,s273383649,Accepted,"S = input() a = (len(S) - 1) // 2 b = (len(S) + 3) // 2 - 1 if S == S[::-1] and S[:a] == S[:a][::-1] and S[b:] == S[b:][::-1]: print(""Yes"") else: print(""No"") " p03951,s255386453,Accepted,"N=int(input()) s=str(input()) t=str(input()) c=0 tmp=0 S=list(s) T=list(t) for i in range(N): if s[N-i-1:N]==t[0:i+1]: c=i+1 #print(s[N-i-1:N],t[0:i+1]) #print(c) print(2*N-c) " p02684,s270167172,Wrong Answer,"n,k = map(int,input().split()) l = list(map(int,input().split())) curr_town = 1 for i in range(k) : temp = l[curr_town - 1] curr_town = l[temp - 1] print(curr_town + 1)" p03386,s113359962,Accepted,"A,B,K = list(map(int,input().split())) s = set() for i in range(0,K): s.add(A+i) for i in range(0,K): s.add(B-i) l = sorted(filter(lambda x: A <= x <=B,list(s))) for i in l: print(i)" p02987,s651588975,Accepted,"# A - Fifty-Fifty s = str(input()) ans = 'Yes' for i in range(len(s)): if s.count(s[i])!=2: ans = 'No' break print(ans)" p02601,s370492642,Wrong Answer,"def main(a, b, c, k): for _ in range(k + 1): if a >= b: b *= 2 elif b >= c: c *= 2 if a < b < c: print(""Yes"") return print(""No"") if __name__ == ""__main__"": a, b, c = map(int, input().split()) k = int(input()) main(a, b, c, k) " p03612,s495942857,Wrong Answer,"n=int(input()) a=list(map(int,input().split())) for i in range(n): a[i]-=1 ans=0 flg=True for i in range(1,n): if a[i]==i and a[i-1]==i-1 and flg: if flg: ans-=1 flg=False else: flg=True for i in range(n): if a[i]==i: ans+=1 print(ans) " p03681,s050243668,Wrong Answer,"MOD = 10**9 + 7 max = 10**5 + 1 facts = [1 for i in range(max)] invs = [1 for i in range(max)] def inv(x): return pow(x,MOD-2,MOD) for i in range(1,max): facts[i] = facts[i-1]*i%MOD invs[i] = inv(facts[i]) def comb(n,r): return facts[n]*invs[r] * invs[n-r] % MOD n,m = map(int,input().split()) if m > n: n,m = m,n if n-m >= 2: print(0) elif n-m == 1: print(facts[m]*facts[n]) else: print(facts[m]*facts[n]*2 % MOD)" p02947,s438085240,Accepted,"from collections import Counter N = int(input()) Sss = [''.join(sorted(input().rstrip())) for _ in range(N)] cnt = Counter(Sss) #print('cnt:', cnt) ans = 0 for num in cnt.values(): ans += num*(num-1)//2 print(ans) " p02939,s713692228,Wrong Answer,"s = list(input()) g = [] g.append(0) g.append(1) if s[1] == s[2]: g.append(1) else: g.append(2) for i in range(3,len(s)+1): if s[i-1] != s[i-2]: g.append(g[i-1]+1) else: g.append(g[i-3]+2) print(g[-1])" p02778,s720024316,Accepted,"hoge=input() for i in range(len(hoge)): print(""x"",end="""")" p02775,s895863835,Accepted,"n = input() dp = [0, 10000] for d in reversed('0' + n): newdp = [] newdp.append(min(int(d) + dp[0], int(d) + 1 + dp[1])) newdp.append(min(10 - int(d) + dp[0], 10 - int(d) - 1 + dp[1])) dp = newdp print(dp[0]) " p03220,s476925367,Accepted,"N = int(input()) T,A = map(int,input().split()) H = [int(i) for i in input().split()] res = - 1 res_val = 100000 for i in range(N): av_temp = T - H[i] * 0.006 if res_val > abs(av_temp - A): res = i res_val = abs(av_temp - A) print(res+1)" p02706,s716179511,Accepted,"n, m = map(int,input().split()) ai = [int(i) for i in input().split()] if n - sum(ai) >= 0 : print(n - sum(ai)) else : print(-1) " p02860,s939737931,Wrong Answer,"n = int(input()) s = input() ans =""Yes"" if n==1:ans=""No"" else: for i in range(n//2): if s[i]!=s[n//2+i]:ans=""No"" print(ans)" p02814,s154890206,Wrong Answer,"n,m=map(int,input().split()) def int_2(n): return int(n)//2 a=list(map(int_2,input().split())) def gcm(a,b): if a==0: return b elif b==0: return a else: return gcm(a%b,b) if a>=b else gcm(b%a,a) def lcm(a,b): return a*b//gcm(a,b) lis=[a[0]]*n for i in range(n-1): lis[i+1]=lcm(lis[i],a[i+1]) ma=m//lis[n-1] print((ma+1)//2)" p02823,s995012260,Accepted,"n,a,b = map(int, input().split()) #距離 d = b-a c = 0 if d % 2 == 0: c = d // 2 else: # 端っこに近い方に行く c = min(n-b, a-1) # 一試合距離を縮める c += 1 d -= 1 # お互い近づく c += (d // 2) print(c)" p02847,s930286848,Accepted,"s = input() dic = {'SUN': 7, 'MON':6, 'TUE':5, 'WED':4, 'THU':3, 'FRI':2, 'SAT':1} print(dic[s])" p02935,s161876621,Accepted,"N = int(input()) V = [int(x) for x in input().split()] for v in range(N-1): V.sort() min1 = V.pop(0) min2 = V.pop(0) new = (min1 + min2) / 2 V.append(new) print(V[0])" p03239,s627119303,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()) cc = [] for i in range(N): if t[i]<=T: cc.append(c[i]) if cc == []: print('TLE') exit() print(min(cc))" p03109,s538649530,Accepted,"Y,M,D=map(int,input().split('/')) if Y < 2019: print('Heisei') elif Y == 2019 and M <= 4: print('Heisei') else: print('TBD')" p03264,s523588034,Accepted,"import sys def main(lines): N = int(lines[0]) print(N // 2*(N - N // 2)) if __name__ == '__main__': lines = [] for l in sys.stdin: lines.append(l.rstrip('\r\n')) main(lines)" p03284,s487845365,Wrong Answer,"x,y=map(int,input().split()) print(x%y)" p02796,s566103503,Wrong Answer,"N=int(input()) cnt=1 R=[[0]*2 for _ in range(N)] for i in range(N): x,l=map(int,input().split()) R[i][0]=(x-l+1) R[i][1]=(x+l-1) #print(R) R.sort(key=lambda x: x[1]) #print(R) for i in range(1,N): if R[i][0]>R[i-1][1]: cnt+=1 print(cnt)" p02646,s547656015,Wrong Answer,"A, V = map(int, input().split()) B, W = map(int, input().split()) T = int(input()) if A+T*V < B+T*W: print('NO') else: print('YES') " p03767,s439453426,Wrong Answer,"N = int(input()) A = sorted(list(map(int, input().split()))) print(sum(A[N:N*2])) " p03705,s319120483,Accepted,"N,A,B = map(int,input().split()) if A > B: print(0) exit() if N == 1: if A == B: print(1) else: print(0) exit() print((B-A)*(N-2)+1)" p03345,s896851411,Wrong Answer,"import sys input=sys.stdin.buffer.readline a,b,c,k=map(int,input().split()) print(-a+b if k != 0 else ""-1"") " p03485,s625165704,Accepted,"A,B = map(int,input().split()) import math ans = math.ceil((A+B)/2) print(ans)" p02695,s024240515,Accepted,"import itertools N, M, Q = map(int, input().split()) A = [list(map(int, input().split())) for i in range(Q)] comb = list(itertools.combinations_with_replacement(range(1, M + 1), N)) saidai = 0 for c in comb: score = 0 for a in A: if (c[a[1] - 1] - c[a[0] - 1] == a[2]): score += a[3] saidai = max(saidai, score) print(saidai)" p02833,s011656253,Wrong Answer,"def findTrailingZeros(n): # If n is odd if (n & 1): return 0 # If n is even else: ans = 0 # Find the trailing zeros # in n/2 factorial n //= 2 while (n): ans += n // 5 n //= 5 # Return the required answer return ans n = 12 print(findTrailingZeros(n)) " p03720,s755963004,Accepted,"try: N, M = map(int, input().split()) dp = [[0 for i in range(N)] for j in range(N)] for i in range(M): a, b = map(int, input().split()) dp[a-1][b-1] += 1 dp[b-1][a-1] += 1 for k in range(len(dp)): print(sum(dp[k])) except EOFError: pass" p03251,s928707965,Accepted,"import sys n, m, x, y = map(int, input().split()) x1 = max(list(map(int, input().split()))) y1 = min(list(map(int, input().split()))) for i in range(x+1, y+1): if x1 < i <= y1: print('No War') sys.exit() print('War') " p02755,s508728713,Accepted,"A,B = map(int,input().split()) flag = 0 for i in range(10000): a = int(i*0.08) b = int(i*0.1) if A==a and B==b: flag = 1 ans = i break if flag == 1: print(ans) else: print(-1)" p02743,s925256099,Accepted,"from decimal import * a, b, c = [Decimal(i).sqrt() for i in input().strip().split("" "")] if a + b - c < 0: print(""Yes"") else: print(""No"") " p03778,s941919541,Accepted,"W, a, b = map(int, input().split()) if abs(a-b) < W: ans = 0 else: ans = abs(a-b) - W print(ans)" p03076,s549070159,Accepted,"import math a = [int(input()) for i in range(5)] sub = 0 cnt = 0 for i in a: if i%10!=0 and sub<(10-i%10): sub = 10-i%10 cnt += math.ceil(i/10)*10 print(cnt-sub)" p03827,s437433969,Wrong Answer,"input() s =input() a = [] n = 0 for i in s : if i == 'I': n +=1 else : n-=1 a.append(n) print(max(a))" p03745,s102668597,Wrong Answer,"N = int(input()) A = list(map(int,input().split())) ans = 1 i = 2 while (i < N): if ((A[i-2] <= A[i-1] <= A[i]) or (A[i-2] >= A[i-1] >= A[i])): i += 1 else: ans +=1 i += 2 print(ans)" p02689,s263868177,Accepted,"N, M = map(int, input().split()) hlist = list(map(int, input().split())) rlist=[] i=0 while(i= N: break else: ans += a itr += 1 if itr >= N: break ans += a itr += 1 if itr >= N: break print(ans) " p02835,s649956051,Accepted,"A1, A2, A3 = map(int, input().split()) if A1 + A2 + A3 <= 21: print(""win"") else: print(""bust"")" p03555,s242454243,Accepted,"print(""YES"" if input() == input()[::-1] else ""NO"")" p02811,s951238364,Wrong Answer,"input_line = input() Line = input_line.split() if 500*Line[0] > Line[1]: print('yes') else: print('no')" p03012,s750649336,Accepted,"N = int(input()) W = list(map(int, input().split())) d = sum(W) / 2 count = 0 for i in range(N): count += W[i] if count >= d: if i == 0: print(W[0] - sum(W[1:])) break else: print(min(sum(W[i:]) - sum(W[:i]), sum(W[:i + 1]) - sum(W[i+1:]))) break " p03997,s641075689,Wrong Answer,"def iroha(): a, b, c = [int(input()) for i in range(3)] result = (a+b)*2 / 2 print(result) if __name__ == ""__main__"": iroha() " p02665,s754468135,Accepted,"from itertools import accumulate n = int(input()) As = list(map(int, input().split())) if n == 0: if As[0] == 1:print(1) else:print(-1) exit() if As[0] != 0: print(-1) exit() b = 1 ans = 1 acc = list(accumulate(As)) s = acc[-1] for ac,a in zip(acc[1:], As[1:]): # print(s-ac,2*b-a) b = min(2*b-a, s-ac) if b < 0: print(-1) exit() ans += b+a print(ans) " p02813,s633260202,Wrong Answer,"import itertools N = int(input()) l = [i for i in range(1, N+1)] p = list(itertools.permutations(l, N)) print(p) P = tuple(map(int, input().split())) Q = tuple(map(int, input().split())) a = p.index(P) b = p.index(Q) print(abs(b-a))" p03821,s730630747,Accepted,"N=int(input()) rest=[list(map(int,input().split())) for _ in range(N)] #print(rest) push=0 a=0 b=0 for i in range(N-1,-1,-1): #print(i) a = rest[i][0] + push push=push+((rest[i][1]-a%rest[i][1])%rest[i][1]) #print(push) print(push) " p03161,s570572330,Accepted,"N,K = [int(i) for i in input().split()] h = [int(i) for i in input().split()] dp = [0]*(N) dp[1] = abs(h[0] - h[1]) for i in range(0,N-2): dp[i+2] = min([dp[i+2-j]+abs(h[i+2-j]-h[i+2]) for j in range(1,min(K+1, i+3))]) print(dp[-1])" p02838,s538113492,Accepted,"n = int(input()) a = list(map(int, input().split())) mod = 10 ** 9 + 7 # 解説AC ans, num = 0,1 for i in range(60): cnt = sum((ai & num) >> i for ai in a) ans += (cnt * (n - cnt) * num) % mod num <<= 1 print(ans % mod) " p03434,s112709095,Accepted,"import numpy as np n = int(input()) a = list(map(int, input().split())) a.sort(reverse=True) a = np.array(a) alice = a[0::2].sum() bob = a[1::2].sum() print(alice-bob)" p02706,s056521739,Accepted,"M, N = map(int ,input().split()) x = [int(x) for x in input().split()] if (sum(x)) > M: print(-1) elif(sum(x) == M): print(0) elif(sum(x)= 13: print(b) elif 6 <= a <= 12: print(b//2) else: print(0)" p02732,s182146875,Wrong Answer,"N = int(input()) A = list(map(int, input().split())) cnt = [0] * (N+1) ans = 0 for i in range(N): cnt[A[i]] += 1 for i in range(N): ans += cnt[i] * (cnt[i] - 1) // 2 for i in range(N): print(ans - cnt[A[i]] + 1)" p02768,s957844260,Wrong Answer,"mod = 10**9 + 7 n, a, b = 1000, 23, 30 res = pow(2, n, mod)-1 c1 = 1 for i in range(n-a+1, n+1): c1 *= i c1 %= mod for i in range(1, a+1): c1 *= pow(i, mod-2, mod) c1 %= mod c2 = 1 for i in range(n-a+1, n+1): c2 *= i c2 %= mod for i in range(1, a+1): c2 *= pow(i, mod-2, mod) c2 %= mod res -= (c1+c2) res %= mod print(res)" p02623,s768700250,Accepted,"N, M, K = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) C = A[::-1] + B right = 0 size = 0 ans = 0 for left in range(N+M): while right < (N+M) and size+C[right] <= K: size += C[right] right += 1 if left <= N and N <= right: ans = max(ans, (right-left)) if left == right: right += 1 else: size -= C[left] print(ans) " p02628,s265450477,Accepted,"shurui, kosuu = [int(idx) for idx in input().split()] price = [int(idx) for idx in input().split()] price.sort() result = 0 for idx in range(kosuu): result += min(price) price.remove(min(price)) print(result)" p03836,s700958265,Accepted,"sx, sy, tx, ty = map(int, input().split()) ans = (abs(tx - sx) * 'R') + (abs(ty - sy) * 'U') ans += ((abs(tx - sx) * 'L') + (abs(ty - sy) * 'D')) ans += 'L' + ((abs(ty - sy) + 1) * 'U') + ((abs(tx - sx) + 1) * 'R') + 'D' ans += 'R' + ((abs(ty - sy) + 1) * 'D') + ((abs(tx - sx) + 1) * 'L') + 'U' print(ans) " p02683,s759992929,Accepted,"N,M,X=map(int,input().split()) A=[list(map(int,input().split())) for i in range(N)] C=10**7 for i in range(2**N): P,T=[0]*M,0 for j in range(N): if i&2**j: T+=A[j][0] for k in range(M): P[k]+=A[j][k+1] for j in range(M): if P[j]0: if m-d[i][1] >= 0: cnt += d[i][0]*d[i][1] m -= d[i][1] i += 1 else: cnt += d[i][0]*m m = 0 i += 1 print(cnt) " p02793,s026975020,Accepted,"import sys read = sys.stdin.buffer.read from fractions import gcd N,*A = map(int,read().split()) lcm = 1 answer = 0 for x in A: n = x//gcd(lcm,x) lcm *= n answer *= n answer += lcm//x answer %= (10**9 + 7) print(answer) " p02622,s751899403,Accepted,"a = [str(input()) for i in range(2)] ans=0 for i in range(len(a[0])): if not a[0][i] == a[1][i]: ans +=1 print(ans)" p02702,s413575247,Accepted,"S = input() S_reverse = S[::-1] dp = [0] * 2019 now_mod = 0 digit = 1 for i_s in S_reverse: now_mod = (now_mod + int(i_s)*digit) % 2019 digit = (digit*10) % 2019 dp[now_mod] += 1 ans = sum(x*(x-1)//2 for x in dp) ans += dp[0] print(ans)" p03243,s686757856,Accepted,"N = int(input()) for i in range(N,1000): x = str(i) if x[0]==x[1]==x[2]: break print(x)" p02660,s778702352,Accepted,"import collections N = int(input()) # 素因数分解 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 num1 = prime_decomposition(N) num2 = collections.Counter(num1) ans = 0 for j in set(num1): number = 0 for k in range(50): number += k if number > num2[j]: ans += (k-1) break print(ans)" p02702,s009302017,Wrong Answer,"s = input('') max_s = 20000 rec = 0 for m in (range(max_s+1)): ms=str(2019*m) if not '0' in ms: idx=0 idx=s.find(ms) while idx >= 0: rec+=1 idx=s.find(ms,idx+1) print(""{} {}"".format(ms,idx)) print(rec) " p02952,s122145890,Accepted,"N=int(input()) count=0 if N//100000==1: count=90909 elif N//10000>0: count=N%10000+910+((N//10000)-1)*10000 elif N//1000>0: count=909 elif N//100>0: count=N%100+10+((N//100)-1)*100 elif N//10>0: count=9 else: count=N//1 print(count)" p03387,s553318326,Accepted,"# coding=utf-8 import math if __name__ == '__main__': A, B, C = map(int, input().split()) MV = max(A, B, C) * 3 SumABC = A + B + C if MV % 2 == 0 and SumABC % 2 == 0: ans = (MV - SumABC) / 2 elif MV % 2 == 1 and SumABC % 2 == 1: ans = math.ceil(MV - SumABC) / 2 else: ans = math.ceil((MV - SumABC) / 2) + 1 print(int(ans))" p03407,s482734212,Accepted,"a,b,c = map(int, input().split()) if a+b >= c: print('Yes') else: print('No')" p04005,s660597582,Accepted,"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,B,C}))" p04030,s716000920,Accepted,"s = input() ans = [] for i in s: if i == '1' or i == '0': ans.append(i) else: if ans == []: continue else: ans.pop() print(''.join(ans)) " p02729,s380103738,Accepted,"n,m=map(int,input().split()) if n>0 and m>0:print((n*(n-1))//2+(m*(m-1))//2) else: k=max(n,m) print((k*(k-1))//2)" p04030,s639692702,Accepted,"s = input() ans = '' for i in s: ans = ans[:-1] if i == 'B' else ans + i print(ans)" p02546,s734495252,Accepted,"s = input() if s[-1] == 's': print(s + 'es') else: print(s + 's')" p02933,s407594301,Accepted,"a = int(input()) color = str(input()) if a >= 3200: print(color) else: print('red')" p03471,s011242977,Accepted,"n, y = map(int, input().split()) for i in range(n + 1): for j in range(n - i + 1): if i * 10000 + j * 5000 + (n - i - j) * 1000 == y: print(i, j, n - i - j) exit() print(""-1 -1 -1"")" p03627,s482659446,Accepted,"N = int(input()) import collections A = list(map(int,input().split())) C = collections.Counter(A) use = [0,0] for i,val in C.items(): if val >= 4: use.append(i) if val >= 2: use.append(i) use.sort(reverse=True) print(use[0] * use[1]) " p03293,s110188160,Accepted,"s = str(input()) t = str(input()) n = len(s) x = s ans = 'No' for _ in range(n): if x == t: ans = 'Yes' break nx = x[-1] + x[:n-1] x = nx print(ans)" p02779,s421146020,Wrong Answer,"n = int(input()) a = list(input().split()) if len(set(a)) == len(a): print('Yes') else: print('No')" p02777,s434601545,Wrong Answer,"S = input() print('x'* len(S))" p02582,s552559728,Accepted,"s = input() maxCount = 0 count = 0 for i in s: if(i == 'R'): count += 1 else: maxCount = max(count, maxCount) count = 0 print(max(count, maxCount)) " p03285,s406643634,Accepted,"n =int(input()) for i in range(100//4+1): for j in range(100//7+1): if n == i*4+j*7: print(""Yes"") exit() print(""No"") " p03239,s944698185,Wrong Answer,"#template def inputlist(): return [int(j) for j in input().split()] from collections import Counter #template #issueから始める N,T = inputlist() ans = 10**9 for i in range(N): c,t = inputlist() if t <= T: ans = min(ans,c) if ans == 10**9+7: ans = 'TLE' print(ans)" p03543,s665009691,Accepted,"n = list(str(input())) def no(): print('No') exit(0) if n[1] != n[2]: no() if n[0] != n[1] and n[2] != n[3]: no() print('Yes')" p02817,s968247882,Accepted,"S, T = map(str, input().split()) ans = T + S print(ans) " p02706,s036903201,Accepted,"n, m = map(int,input().split()) a = list(map(int,input().split())) a_sum = sum(a) ans = n-a_sum if n >= m and ans >= 0: print(ans) else: print(-1) " p03986,s998829659,Accepted,"X = input() s, t = 0, 0 for i in X: if i=='S': s += 1 else: if s==0: t += 1 else: s-= 1 print(s+t)" p03282,s740265110,Accepted,"S = input() k = int(input()) for i, s in enumerate(S, start=1): if s != ""1"": print(s) break if i == k: print(1) break" p02548,s115141753,Wrong Answer,"n = int(input())-1 count=0 er=0 j = 0 for i in range(1, n): j=i if i*j>n: break count+=1 j+=1 print(count)" p02971,s297310448,Wrong Answer,"N = int(input()) A = [int(input()) for _ in range(N)] MAX = 0 SECOND = 0 MAX_COUNT = 0 for a in A: if a > MAX: MAX = a MAX_COUNT = 1 elif a == MAX: MAX_COUNT += 1 if a > SECOND and a != MAX: SECOND = a for a in A: if a == MAX and MAX_COUNT == 1: print(SECOND) elif a == MAX and MAX_COUNT > 1: print(MAX) else: print(MAX)" p03543,s010850585,Accepted,"n = input() if n[0]==n[1]==n[2] or n[1]==n[2]==n[3]: print('Yes') else: print('No')" p03284,s391094139,Accepted,"n,k = map(int,input().split()) if n % k == 0: print(0) else: print(1)" p03011,s592695585,Accepted,"P, Q, R = map(int, input().split()) print(P+Q+R-(max(P, Q, R)))" p02571,s741713947,Wrong Answer,"S, T = [input() for i in range(2)] ans = 0 for i in range(len(S)-len(T)): diff = 0 for j in range(len(T)): if T[j] == S[i+j]: diff +=1 ans = max(ans, diff) print(len(T)-ans)" p02633,s724706922,Wrong Answer,"import math X= int(input()) print(math.floor(360/X))" p02819,s575766022,Accepted,"X=int(input()) while True: for x in range(2,X): if X%x==0: break else: print(X) break X+=1" p02744,s680702908,Wrong Answer,"alpha_small_ = [chr(i) for i in range(97, 97+26)] #アルファベッドの小文字 n = int(input()) ans = [] def solve(now,i): if len(now) == n: ans.append(now) return for j in range(i+1): solve(now+alpha_small_[j],j+1) solve(""a"",1) for x in sorted(ans): print(x)" p02847,s896555520,Accepted,"S = str(input()) lst = [""SAT"",""FRI"",""THU"",""WED"",""TUE"",""MON"",""SUN""] for i in range(7): if S == lst[i]: print(i+1) break" p03478,s080113820,Accepted,"n, a, b = map(int, input().split()) ans = 0 for i in range(1, n+1): num = list(str(i)) num = sum([int(i) for i in num]) if num >= a and num <= b: ans += i print(ans) " p02848,s752391356,Accepted,"n=int(input()) s=input() List=list(s) for i in range(len(s)): if ord(List[i])+n<=90: List[i]=chr(ord(List[i])+n) else: List[i]=chr(ord(List[i])+n-26) new_s="""".join(List) print(new_s)" p03385,s766770248,Wrong Answer,"s = sorted(input()) if s == [""a"",""b"",""c""]: print(""Yes"") else: print(""No"") print(s)" p02924,s520820074,Wrong Answer,"def abc139d(): n = int(input()) print(int(n*((n-1)/2))) abc139d()" p03126,s478681386,Accepted,"#!/usr/bin/env python3 import collections n, m = map(int, input().split()) l = [] ans = 0 for _ in range(n): l.extend(list(map(int, input().split()))[1:]) c = collections.Counter(l) for k in c: if c[k] == n: ans += 1 print(ans)" p03001,s612251034,Wrong Answer,"W, H, x, y = map(int, input().split()) # 大きくない方とかって書いてあるけど、別にイコールの場合でもいいんかい! # 中心の座標を求める centerX = (W // 2) centerY = (H // 2) if ((x, y) == (centerX, centerY)): print((W * H) / 2, 1) else: print(W * H / 2, 0) " p02578,s815396100,Accepted,"n=int(input()) l=list(map(int, input().split())) a=0 for i in range(n-1): if l[i]>l[i+1]: a=a+l[i]-l[i+1] l[i+1]=l[i] print(a) " p02982,s773812493,Accepted,"def dist(a, b): res = 0 for i in range(D): res += (a[i] - b[i]) ** 2 res = res ** 0.5 return res N, D = map(int, input().split()) X = [list(map(int, input().split())) for _ in range(N)] ans = 0 for i in range(N - 1): for j in range(i + 1, N): if dist(X[i], X[j]).is_integer(): ans += 1 print(ans)" p02697,s477559657,Accepted,"n, m = map(int, input().split()) def dist(a, b): return min(abs(a - b), n - abs(a - b)) a, b = n, 1 S = set() for i in range(m): if 2 * dist(a, b) == n or dist(a, b) in S: a -= 1 print(a, b) S.add(dist(a, b)) a -= 1 b += 1" p03319,s937251657,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) mae = 0 ato = 0 bit = 0 for i in range(n): if a[i] != 1 and bit == 0: mae += 1 elif a[i] != 1 and bit == 1: ato += 1 else: bit = 1 waru = k-1 ans = (mae+ato+waru-1)//waru print(ans)" p03254,s529758476,Wrong Answer,"import sys input = sys.stdin.readline def main(): N, x = map(int, input().split()) a_list = list(map(int, input().split())) if sum(a_list) == x: print(N) sys.exit() for i, a in enumerate(sorted(a_list), start=1): x -= a if x < 0: break if x >= 0: print(i) else: print(i-1) " p02601,s502305178,Accepted,"import sys def I(): return int(sys.stdin.readline().rstrip()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) A,B,C = LI() K = I() count = 0 while 1: if A A[i]: ans += max - A[i] else: max = A[i] print(ans)" p03449,s589968871,Accepted,"import sys N = int(sys.stdin.readline()) data = sys.stdin.readlines() for i in range(2): data[i] = data[i].split(' ') data[i] = [int(j.replace('\n', '')) for j in data[i]] set = [0]*N for i in range(N): candy = 0 candy = sum(data[0][0:i+1]) + sum(data[1][i:N]) set[i] = candy print(max(set)) " p03637,s641043970,Accepted,"from collections import defaultdict d = defaultdict(int) n = int(input()) a = list(map(int, input().split())) for num in a: if num % 4 == 0: d[4] += 1 continue if num % 2 == 0: d[2] += 1 continue print(""Yes"" if n//2 <= d[4] + (d[2] // 2) else ""No"")" p02711,s950047685,Accepted,"n = input() if '7' in n : print('Yes') else : print('No') " p02847,s042345209,Accepted,"print([""SAT"",""FRI"",""THU"",""WED"",""TUE"",""MON"",""SUN""].index(input())+1)" p04029,s845089477,Accepted,"N = int(input()) ans = 0 for i in range(1,N+1): ans += i print(ans)" p03360,s866546336,Wrong Answer,"a, b, c = map(int, input().split()) K = int(input()) m = max(a, b, c) print(a + b + c + 2**(K-1) * m)" p03352,s507157333,Accepted,"n = int(input()) l = [1] for i in range(1, n+1): for j in range(2, int(n**0.5)): if n >= i**j: l.append(i**j) #print(l) print(max(l)) " p02848,s060355795,Wrong Answer,"a = int(input()) b = input() chr_a = 0 ans = '' for i in range(len(b)): if ord(b[i]) + a <= 90: chr_a = ord(b[i]) + a else: chr_a = ord(b[i]) + a -25 ans += chr(chr_a) print(ans)" p03910,s164607924,Accepted,"n = int(input()) sum = 0 num_list = [] for i in range(1, 10**7): sum += i num_list.append(i) if sum > n: break for i in num_list: if i == (sum - n): continue else: print(i)" p02756,s712963900,Accepted,"from collections import deque import sys read = sys.stdin.readline s = deque(read().rstrip()) q = int(read()) rev = 0 for _ in range(q): a = tuple(read().split()) if a[0] == '1': rev ^= 1 else: dir = rev ^ int(a[1]) - 1 if dir == 0: s.appendleft(a[2]) else: s.append(a[2]) if rev: print(''.join(s)[::-1]) else: print(''.join(s)) " p03817,s665857762,Accepted,"#88 C - X: Yet Another Die Game import decimal x = decimal.Decimal(input()) n = x/decimal.Decimal(11) ans = n*decimal.Decimal(2) judge = int(ans) if ans - judge < decimal.Decimal(0.1): print(int(ans)) else: print(int(ans) + 1)" p03210,s098280320,Accepted,"n=int(input()) print([""NO"",""YES""][n in {3,5,7}])" p02657,s474942940,Wrong Answer,"num1,num2 = [int(num) for num in input(""Enter a number"").split()] print(num1*num2)" p03345,s381354643,Accepted,"import sys sys.setrecursionlimit(10 ** 7) input = sys.stdin.readline 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) " p02627,s164523256,Accepted,"s=input() if s.islower(): print('a') else: print('A')" p03633,s279509174,Accepted,"n = int(input()) t = [int(input()) for i in range(n)] from functools import reduce from fractions import gcd def lcm(x,y): return x*y // gcd(x,y) def lcm2(args): return reduce(lcm,args) print(lcm2(t))" p02642,s778643015,Accepted,"n=int(input()) l=list(map(int,input().split())) l.sort() p=[1]*(l[-1]+1) ans=0 for i in range(n): a=l[i] if p[a]==1: b=a while a<=l[-1]: p[a]=0 a+=b if i int: if((B - A) <=2): return K + 1 else: return max(0,(K - (A - 1)) // 2)*(B - A) + A + (K - (A - 1)) % 2 def modelAnswer(): return def main(): K,A,B = map(int,input().split()) print(myAnswer(K,A,B)) if __name__ == '__main__': main()" p03555,s775508823,Accepted,print('YES' if input() == input()[::-1] else 'NO') p03387,s458549210,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) " p03013,s693113307,Wrong Answer,"n, m = list(map(int, input().split())) aaa = list(int(input()) for i in range(m)) dp = [0] * (n + 1) dp[0] = 1 dp[1] = 1 if 1 not in aaa else 0 MOD = 10 ** 9 + 7 for i in range(2, n + 1): if i in aaa: continue dp[i] = (dp[i - 2] + dp[i - 1]) % MOD " p03611,s783359438,Accepted,"import numpy as np from collections import Counter n = int(input()) a = np.array(list(map(int, input().split()))) b = a + 1 c = a - 1 d = np.concatenate((a, b, c)) e = Counter(d) print(e.most_common()[0][1])" p04030,s027828897,Wrong Answer,"from sys import stdin from collections import deque input = stdin.readline s = input().rstrip() d = deque([]) for i in s: if s != ""B"": d.append(s) else: if d: d.pop() else: pass while d: p = d.popleft() print(p, end="""") print() " p03745,s980554827,Wrong Answer,"n = int(input()) a = list(map(int, input().split())) ans = 1 judge = -1 for i in range(n-1): if a[i] == a[i+1]: break elif a[i] < a[i+1]: if judge == -1: ans += 1 else: judge = 1 elif a[i] > a[i+1]: if judge == 1: ans += 1 else: judge = 1 print(ans)" p03817,s021357592,Accepted,"n = int(input()) ans = n//11*2 if 0 < n%11 <= 6: ans += 1 elif 6 < n%11 <= 10: ans += 2 print(ans)" p02598,s485957562,Accepted,"import math N, K = map(int, input().split()) A = list(map(int, input().split())) # めぐる式二分探索で実装 def calc(x): count = 0 for a in A: count += (a - 1) // x return count <= K ok = 10 ** 9 ng = 0 while abs(ok - ng) > 1: mid = (ok + ng) // 2 if calc(mid): ok = mid else: ng = mid print(ok) " p02725,s818754852,Wrong Answer,"n,k=map(int,input().split()) l=list(map(int,input().split())) s=0 check=0 f=0 save=0 for i in range(1,k): s=s+l[i]-l[i-1] if(f==0 and l[i]>= n//2): check=i f=1 else: if(f==0): save=s s1=0 #print(save,check) for i in range(check+1,k+1): s1=s1+n-abs(l[i%k]-l[(i-1)%k]) s1=s1+save #print(s,s1) print(min(s,s1)) " p03680,s684160827,Accepted,"n = int(input()) dic = {i+1:int(input()) for i in range(n)} light = dic[1] ans = 1 for i in range(n): if light == 2: break elif light == 1 or i == n-1: ans = -1 break else: ans += 1 light = dic[light] print(ans)" p02694,s630755368,Accepted,"def INT(): return int(input()) def MAP(): return map(int, input().split()) X = INT() year = 0 cash = 100 while cash < X: year += 1 cash = int(cash * 1.01) print(year)" p02958,s641654488,Accepted,"N = int(input()) P = list(map(int, input().split())) ctr = 0 for i in range(N): if P[i] != i+1: ctr += 1 if ctr <= 2: print('YES') else: print('NO')" p03087,s260358010,Accepted,"N,Q=map(int,input().split()) S=input() t=[0]*(N+1) for i in range(N): t[i+1]=t[i]+(1 if S[i:i+2]=='AC' else 0) for i in range(Q): l,r=map(int,input().split()) print(t[r-1]-t[l-1])" p02553,s595206875,Accepted,"#!/usr/bin/env python3 from typing import * # def solve(a: int, b: int, c: int, d: int) -> int: def solve(a, b, c, d): ans=[a*c, a*d, b*c, b*d] return max(ans) def main(): a, b, c, d = map(int, input().split()) a1 = solve(a, b, c, d) print(a1) if __name__ == '__main__': main() " p03352,s666738337,Accepted,"x=int(input()) a=1 for i in range(1,x): for y in range(2,x): if i**y<=x: a=max(a,i**y) else:break print(a)" p03730,s096713874,Accepted,"A, B, C = map(int, input().split()) import fractions a = fractions.gcd(A, B) ans = 'NO' if a == 1: ans = 'YES' elif C % a == 0: ans = 'YES' print(ans)" p03555,s321683405,Wrong Answer,"x = str(input()) y = str(input()) if x[0] == y[2] and x[1] == y[1] and x[2] == y[0]: print('Yes') else: print('No')" p02603,s761782262,Accepted,"def buy(my_money, A, count): return my_money%A, count + my_money//A def sell(my_money, A, count): return my_money + A*count, 0 N = int(input()) A = list(map(int, input().split())) now = 1000 # 所持金 kabu = 0 for i in range(N-1): if A[i] < A[i+1]: now, kabu = buy(now, A[i], kabu) else: now, kabu = sell(now, A[i], kabu) now, kabu = sell(now, A[N-1], kabu) print(now) " p03719,s903633679,Accepted,"a, b, c = map(int, input().split()) if c >= a and c <= b: print(""Yes"") else: print(""No"") " p03639,s586985529,Accepted,"n = int(input()) a = [int(x) for x in input().split()] cnt2 = 0 cnt4 = 0 for i in range(n): if a[i] % 2 == 0 and a[i] % 4 != 0: cnt2 += 1 elif a[i] % 4 == 0: cnt4 += 1 n = n - cnt2 if cnt2 == 0: if n-cnt4 <= cnt4+1: print(""Yes"") else: print(""No"") else: if n-cnt4 <= cnt4: print(""Yes"") else: print(""No"") " p02661,s031053871,Accepted,"n = int(input()) l = [list(map(int,input().split())) for _ in range(n)] l1 = sorted([i for i,k in l]) l2 = sorted([k for i,k in l])[::-1] if n%2!=0: a = l1[int(n//2)] b = l2[int(n//2)] print(b-a+1) else: a1 = l1[int(n//2)-1] a2 = l1[int(n//2)] b1 = l2[int(n//2)-1] b2 = l2[int(n//2)] print((b1-a1+1)+(b2-a2+1)-1)" p02700,s182586129,Wrong Answer,"import math A, B, C, D = input().split() if math.ceil(int(C)*1.0/(int(B)*1.0)) >= math.ceil(int(A)*1.0/(int(D)*1.0)): print(""Yes"") else: print(""No"")" p02818,s556875226,Accepted,"A, B, K = map(int, input().split()) if A >= K: A -= K elif A+B <= K: A = 0 B = 0 else: B = A+B-K A = 0 print(A, B) " p02583,s836472008,Accepted,"N = int(input()) L = list(map(int, input().split())) from itertools import combinations c = combinations(L, 3) count = 0 for cs in c: if len(set(cs)) < 3: continue cs = sorted(cs) if cs[0] + cs[1] <= cs[2]: continue count += 1 print(count)" p03548,s633790167,Accepted,"X, Y, Z = map(int, input().split()) X -= Y + 2 * Z ans = X // (Y + Z) + 1 print(ans)" p03803,s081396142,Accepted,"# -*- coding: utf-8 -*- A,B = [int(i) for i in input().rstrip().split()] if A == 1: A=14 if B == 1: B=14 if A > B: print(""Alice"") elif A == B: print(""Draw"") else: print(""Bob"") " p03944,s788008600,Accepted,"w,h,n = map(int, input().split()) l,r,d,u = (0,w,0,h) 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((r-l)*(u-d) if r>l and u>d else 0)" p04011,s181924499,Accepted,"times, first, first_amount, second_amount = [int(input()) for i in range(4)] total = 0 for i in range(times): if first > 0: total += first_amount first -= 1 else: total += second_amount print(total) " p02768,s024320312,Accepted," mod = (10 ** 9 + 7) def comb(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 n, a, b = list(map(int, input().split())) s = pow(2, n, mod) - 1 print((s - comb(n, a) - comb(n, b)) % mod)" p03475,s652938239,Accepted,"n = int(input()) csf = [list(map(int, input().split())) for i in range(n - 1)] for i in range(n): ans = 0 for j in range(i, n - 1): c, s, f = csf[j][0], csf[j][1], csf[j][2] if ans < s: ans = s elif ans % f != 0: ans += f - ans % f ans += c print(ans)" p03210,s885251900,Accepted,"X = int(input()) print(""YES"" if 105%X == 0 and X != 1 else ""NO"")" p04045,s531679654,Wrong Answer,"import itertools N,K=map(int,input().split()) D=[int(x) for x in input().split()] T=[] answer=10000 for i in range(10): if not i in D: T+=[i] for x in itertools.product(T,repeat=4): p=x[-1]+x[-2]*10+x[-3]*100+x[-4]*1000 if p>=N: answer=min(p,answer) print(answer)" p02595,s145205760,Wrong Answer,"import math ND=input().split() N=int(ND[0]) D=int(ND[1]) cont=0 for i in range(N): XY=input().split() X=int(XY[0]) Y=int(XY[1]) d= math.sqrt( (pow(X,2)) + (pow(Y,2)) ) if int(d)==D: cont+=1 print(cont)" p02682,s516712689,Wrong Answer,"i = input().split() a = int(i[3])-int(i[0]) b = int(i[3])-int(i[0])-int(i[1]) if i[3] <= i[0]: print(i[0]) elif a <= int(i[1]): print(i[0]) elif b == int(i[2]): print(int(i[0])*2 + int(i[1]) - int(i[3])) else: print(int(i[3]) - int(i[1])- int(i[2]))" p03073,s917309094,Accepted,"s=input() tmp1 = '' tmp2 = '' for i in range(len(s)): if i % 2 == 0: tmp1 += '0' tmp2 += '1' else: tmp1 += '1' tmp2 += '0' diff_tmp1 = 0 diff_tmp2 = 0 for i in range(len(s)): if tmp1[i] != s[i]: diff_tmp1 += 1 elif tmp2[i] != s[i]: diff_tmp2 += 1 print(min(diff_tmp1,diff_tmp2))" p04034,s229907069,Accepted,"N, M = map(int, input().split()) ball = [1] * N red = {1} ans = 0 for _ in range(M): x, y = map(int, input().split()) ball[x - 1] -= 1 ball[y - 1] += 1 if x in red: red.add(y) if ball[x - 1] == 0: red.remove(x) print(len(red)) " p03437,s746453157,Wrong Answer,"from sys import exit X, Y = map(int,input().split()) if X % Y == 0 or Y % X == 0:pass else: for i in range(X,10 ** 18 + 1,X): if i % Y != 0: print(i) exit() print(-1) " p02659,s512370858,Accepted,"from decimal import Decimal a, b = input().split() a = Decimal(a) b = Decimal(b) print(int(a*b)) " p02718,s855840997,Accepted,"n,m=map(int,input().split()) A=list(map(int,input().split())) all=int(0) for i in range(n): all+=A[i] cnt=int(0) for i in range(n): if A[i]>=all/4/m: cnt+=1 if cnt>=m: print(""Yes"") else: print(""No"")" p03371,s099579948,Accepted,"a,b,c,x,y=map(int,input().split()) c*=2 d=a*x+b*y f=max(x,y)*c if x b: print(""Alice"") if b > a : print(""Bob"")" p03836,s974157396,Wrong Answer,"sx, sy, tx, ty = map(int, input().split()) A = ""L"" for i in range(ty-sy+1): A += ""U"" for i in range(tx-sx+1): A += ""R"" for i in range(ty-sy+1): A += ""D"" for i in range(tx-sx): A += ""L"" for i in range(ty-sy): A += ""U"" for i in range(tx-sx+1): A += ""R"" for i in range(ty-sy+1): A += ""D"" for i in range(tx-sx+1): A += ""L"" A += ""U"" " p02759,s141450011,Accepted,"import math n = int(input()) res = math.ceil(n/2) print(res)" p02548,s624837655,Accepted,"n = int(input()) ans = 0 for i in range(1, n): ans += (n-1)//i print(ans)" p03607,s190218827,Wrong Answer,"N = int(input()) A = [int(input()) for _ in range(N)] dic = {a: False for a in A} for a in A: dic[a] = True if not dic[a] else False ans = 0 for a in A: ans += dic[a] print(ans)" p03827,s190256022,Accepted,"input() s = input() while ""DI"" in s: s = s.replace(""DI"", """") print(s.count(""I""))" p02702,s458662267,Accepted,"#https://mirucacule.hatenablog.com/entry/2020/04/27/090908 #https://drken1215.hatenablog.com/entry/2020/04/29/171300 S=str(input())[::-1]#逆順で格納 N=len(S) counter=[0]*2019 counter[0]=1 ans=0 num,d=0,1 for c in S: num += int(c) * d num %= 2019 d *= 10 d %= 2019 counter[num]+=1 for i in counter: ans += i*(i-1)//2 print(ans)" p03126,s832866416,Wrong Answer,"# -*- coding: utf-8 -*- n,m = map(int,input().split() ) b = [0]*m for i in range(n): a = list(map(int, input().split())) for j in range(1, len(a)): print(j) b[a[j]-1] += 1 ans = b.count(n) print(ans) " p02791,s934791379,Accepted,"n = int(input()) num_list = list(map(int, input().split("" ""))) min = 200001 count = 0 for i in num_list: if min >= i: count += 1 min = i print(count)" p03345,s441793490,Accepted,"A, B, C, K = map(int, input().split()) print(A - B if K % 2 == 0 else B - A)" p03774,s659327414,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)] man = lambda x,y:abs(x[0] - y[0]) + abs(x[1] - y[1]) for i in range(n): a,b = ab[i] cost = float('INF') pos = 0 for j in range(m): c,d = cd[j] c = man(ab[i], cd[j]) if c < cost: cost = c pos = j+1 print(pos) " p02792,s599999699,Accepted,"if __name__ == '__main__': n = int(input()) total = 0 data = [[0] * 9 for i in range(9)] for i in range(1, n + 1): str_num = str(i) top = str_num[0] bottom = str_num[-1] if bottom == '0': continue else: data[int(top) - 1][int(bottom) - 1] += 1 for i in range(9): for j in range(9): total += (data[i][j] * data[j][i]) print(total)" p02724,s973456244,Accepted,"Y = int(input()) C500 = Y // 500 C5 = (Y - C500*500) // 5 if (Y - C500*500) // 5>0 else 0 print(C500*1000+C5*5)" p02784,s562293069,Accepted,"H, N = map(int, input().split()) lst = [int(x) for x in input().split()] if sum(lst) >= H: print(""Yes"") else: print(""No"") " p02972,s504800059,Wrong Answer,"N = int(input()) *b, = map(int, input().split()) ans = [] for i in range(N)[::-1]: n = i+1 if b[i]: ans.append(n) for j in range(1, int(n**0.5)+2): if n%j==0: b[j-1] ^= 1 if j!=n//j: b[n//j-1] ^= 1 M = sum(ans) print(M) if ans: print(*ans)" p03221,s182190841,Accepted,"from operator import itemgetter n,m=map(int,input().split()) l=[] for i in range(m): g=list(map(int,input().split())) l.append(g) l[i].append(i) l.sort() l[0][1]=1 for i in range(1,m): if l[i][0]==l[i-1][0]: l[i][1]=int(l[i-1][1])+1 else: l[i][1]=1 newl=sorted(l,key=itemgetter(2)) for i in range(m): print((6-len(str(newl[i][0])))*'0'+str(newl[i][0])+(6-len(str(newl[i][1])))*'0'+str(newl[i][1])) " p02682,s489440565,Accepted,"A , B, C, K = map(int, input().split()) if K >= A: result = A K -= A else: result = K K = 0 if K >= B: K -= B if K > 0: result -=K print(result)" p03001,s946532451,Accepted,"w, h, x, y = map(int, input().split()) ans_1 = w*h/2 if x == w/2 and y == h/2: ans_2 = 1*True else: ans_2 = 1*False print(ans_1, ans_2)" p02861,s773597068,Accepted,"import sys sys.setrecursionlimit(10 ** 7) read = sys.stdin.buffer.read input = sys.stdin.buffer.readline def inpuS(): return input().rstrip().decode() readlines = sys.stdin.buffer.readlines from itertools import permutations N = int(input()) XY = [list(map(int, input().split())) for _ in range(N)] P = list(permutations(XY)) ans = 0 count = 0 for p in P: for i in range(1,len(p)): dist = ((p[i-1][0]-p[i][0])**2 + (p[i-1][1]-p[i][1])**2) ans += dist**0.5 print(ans/len(P)) " p02708,s772950012,Accepted,"#D N, K = map(int, input().split()) count=0 for i in range(K,N+2): min_a=(i-1)*i/2 max_a=(N+(N-i+1))*i/2 count+=max_a-min_a+1 print(int(count)%(10**9+7))" p02678,s919046898,Wrong Answer,"N, M = map(int, input().split()) AB = [list(map(int, input().split())) for _ in range(M)] g = [set() for _ in range(N)] for a, b in AB: a, b = a-1, b-1 g[b].add(a) g[a].add(b) mark = [-1]*N mark[0] = 0 q = [0] while q: t = q.pop() for c in g[t]: if mark[c] == -1: mark[c] = t q.append(c) print(""Yes"") for m in mark[1:]: print(m+1)" p03487,s255048470,Wrong Answer,"from collections import Counter n=int(input()) sc=Counter(list(map(int,input().split()))) sm=0 for k,v in sc.items(): sm+=min(v,(k-v if v-k>=0 else 10**9+1)) print(sm)" p03061,s313323709,Wrong Answer,"import sys def gcd(m, n): r = m % n return gcd(n, r) if r else n def gcd_list(ln): tmp = gcd(ln[0], ln[1]) for x in ln[2:]: tmp = gcd(tmp, x) return tmp n = int(input()) a = list(map(int, sys.stdin.readline().split())) if n == 2: print(max(a)) else: ans = 0 for i in range(min(n, 4)): tmp = gcd_list(a[:i] + a[i+1:]) if tmp > ans: ans = tmp print(ans)" p02760,s265753275,Accepted,"a = [list(map(int, input().split())) for row in range(3)] n = int(input()) b = [int(input()) for hoge in range(n)] a1 = a[0] + a[1] + a[2] c = [] for poge in a1: if poge in b: c.append(0) else: c.append(1) if min((c[0]+c[1]+c[2]),(c[3]+c[4]+c[5]),(c[6]+c[7]+c[8]),(c[0]+c[3]+c[6]), (c[1]+c[4]+c[7]),(c[2]+c[5]+c[8]),(c[0]+c[4]+c[8]),(c[2]+c[4]+c[6])) == 0: print('Yes') else: print('No') " p02793,s548479580,Wrong Answer,"from functools import reduce def gcd(x, y): if x < y: x, y = y, x while x % y != 0: r = x % y x = y y = r return y def inv(x): return pow(x, MOD-2, MOD) def lcm(a, b): return a * b * inv(gcd(a, b)) def addmod(a, b): return (a+b) % MOD N = int(input()) a_list = list(map(int, input().split())) MOD = 10 ** 9 + 7 l = reduce(lcm, a_list) ans = reduce(addmod, (l*inv(a) for a in a_list)) print(ans%MOD)" p03803,s872370075,Accepted,"A,B=list(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')" p02628,s676981759,Accepted,"n,k=map(int,input().split()) a=sorted(map(int,input().split())) print(sum(a[:k]))" p03317,s676948744,Accepted,"import math N, K = map(int, input().split()) a = list(map(int, input().split())) M = math.ceil((N-1)/(K-1)) print(M)" p03592,s291147312,Accepted,"N, M, K = map(int, input().split()) Flg = ""No"" for i in range(N+1): for j in range(M+1): if((M-j)*i+(N-i)*j ==K): Flg = ""Yes"" break print(Flg)" p02790,s080494775,Accepted,"a, b = map(int, input().split()) if a < b: print(str(a)*b) elif a > b: print(str(b)*a) else: print(str(b)*a) " p03543,s310846674,Wrong Answer,"k = input() ans = ""No"" for i in k: if len(k.replace(i, """")) <= 1: ans = ""Yes"" break print(ans)" p03379,s226346987,Wrong Answer,"N = int(input()) A = list(map(int,input().split())) X = sorted(A,reverse=False) print(X) for i in range(N): if A[i] < X[N//2 ]: print(X[N//2 ]) else: print(X[N//2 - 1]) " p02608,s831093936,Accepted,"n = int(input()) count = 0 a = [0]*(10**5) for i in range(1, 100): for j in range(1, 100): for k in range(1, 100): a[(i+j+k)**2-(i*j+j*k+i*k)] += 1 for i in range(n): print(a[i+1])" p02647,s627131175,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) for _ in range(min(K, 50)): lamp = [0 for i in range(N + 1)] for i in range(N): lamp[max(0, i - A[i])] += 1 lamp[min(N, i + A[i] + 1)] -= 1 for i in range(1, N + 1): lamp[i] += lamp[i - 1] A = lamp [print(A[i], end=' ') for i in range(N)] print() " p02989,s547562359,Accepted,"N = int(input()) D = list(map(int, input().split())) D.sort() if N % 2 == 1: print(0) else: M = N //2 res = D[M] - D[M-1] print(res) " p04043,s876557753,Accepted,"a, b, c = map(int, input().split()) if a+b+c == 17: print('YES') else: print('NO')" p02707,s014104633,Wrong Answer,"N = int(input()) A = list(map(int,input().split())) A_max = max(A) for i in range(1,A_max+1): if A_max < i: print(0) else: print(A.count(i))" p02820,s164428530,Wrong Answer,"N,K=map(int,input().split()) p=[int(x) for x in input().split()] T=[0 if x=='r' else (1 if x=='s' else 2) for x in input()] B=[-1]*K s=0 for i in range(N): v=(T[i]+2)%3 if v!=B[i%K]: s+=p[v] B[i%K]=v else: B[i%K]=T[i] if i= S else ""safe"")" p03210,s460121726,Accepted,print('YES' if input() in '753' else 'NO') p03206,s355107715,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*2) else: print(C+E*3) " p02917,s503284557,Accepted,"import numpy as np N = int(input()) B = np.array([10 ** 5] + list(map(int, input().split())) + [10 ** 5], np.int32) print(np.minimum(B[1:], B[:-1]).sum())" p02555,s549516368,Accepted,"s = int(input()) mod = 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] %= mod print(dp[s])" p02627,s378571884,Wrong Answer,"a = (input()) if a.islower == True: print(""a"") else: print(""A"")" p02714,s085574740,Wrong Answer,"N = int(input()) S = list(input()) A = (S.count(""R""))*(S.count(""B""))*(S.count(""G"")) for i in range(1,N): for j in range(i+1,N+1): if j < 2*j - i <= N: if S[i-1] != S[j-1] != S[2*j - i - 1] : A -= 1 print(A)" p02718,s811727796,Accepted,"n,m = map(int, input().split()) A = sorted(map(int, input().split()), reverse = True) suma = sum(A) if A[m-1]>= suma/(4*m): print('Yes') else: print('No')" p02918,s964450743,Accepted,"n,k = map(int, input().split()) s = input() happy, no = 0,0 for i in range(1,n): if s[i] == s[i-1]: happy += 1 else: no += 1 for i in range(k): if no == 1: no -= 1 happy += 1 break no -= 2 happy += 2 print(min(happy, n-1))" p03457,s820998023,Wrong Answer,"n=int(input()) ans='Yes' t,a,b=map(int,input().split()) if (a+b) 1: res += 1 print(res) " p03478,s356877768,Accepted,"N,A,B = [int(i) for i in input().split()] ts = 0 for n in range(1,N+1): s = sum([int(i) for i in str(n)]) if A <= s <= B: ts += n print(ts)" p02835,s077400054,Accepted,"A1, A2, A3 = [int(s) for s in input().split(' ')] print('win' if A1+A2+A3 < 22 else 'bust') " p02584,s546671054,Accepted,"x,k,d=map(int,input().split()) x =abs(x) o =x//d if (x-d*k) >=0: print(x-d*k) exit() else: if (k-o)%2==0: print(abs(x%d)) exit() else: print(abs(x%d-d)) exit()" p03281,s148246686,Accepted,"N = int(input()) ans = 0 for i in range(1, N+1): if i % 2 == 0: continue a = 0 for j in range(1, i+1): if i % j == 0: a += 1 if a == 8: ans += 1 print(ans)" p02861,s230864282,Accepted,"from itertools import combinations n = int(input()) D = [] ans = 0 for i in range(n): x,y = map(int,input().split()) D.append((x,y)) for i,j in combinations(range(1,n+1),r=2): p,q = D[i-1] r,s = D[j-1] ans += ((p-r)**2+(q-s)**2)**(0.5) print(2*ans/n)" p03146,s848530115,Wrong Answer,"number = int(input()) count = 2 if number < 3: count = number + 3 else: while number != 1: count += 1 if number % 2 == 0: number = number / 2 else: number = number * 3 + 1 print(count)" p02802,s917840495,Accepted,"n, m = map(int, input().split()) p, s = [], [] result = [0] * (n + 1) wa = [0] * (n + 1) for _ in range(m): tmpp, tmps = map(str, input().split()) p.append(int(tmpp)), s.append(tmps) for i in range(m): if result[p[i]] == 0: if s[i] == ""AC"": result[p[i]] = 1 else: wa[p[i]] += 1 ac = sum(result) wa = sum(wa[i] for i in range(n + 1) if result[i] == 1) print(ac, wa) " p02696,s954259063,Accepted,"a, b, n = map(int, input().split()) i = min(b - 1, n) print((a * i) // b - a * (i // b)) " p03038,s724909934,Accepted,"n, m = map(int, input().split()) a = sorted(list(map(int, input().split()))) bc = [map(int, input().split()) for _ in range(m)] cb = sorted([[c, b] for b, c in bc]) j = len(cb) - 1 for i in range(n): if j >= 0 and a[i] < cb[j][0]: a[i] = cb[j][0] cb[j][1] -= 1 if cb[j][1] == 0: j -= 1 print(sum(a))" p02982,s006154820,Wrong Answer,"import math n,d=map(int,input().split()) l=[list(map(int,input().split())) for i in range(n)] ans=0 cnt=0 siki=0 for i in range(n-1): for j in range(i+1,n): siki=0 for k in range(d): siki+=((l[i][k]-l[j][k])**2) han=math.sqrt(ans) if han%1==0: cnt+=1 print(cnt)" p02596,s218903795,Accepted,"K = int(input()) base = 0 for count in range(1, K+1): num = base*10 + 7 if (num%K == 0): print(count) exit() else: base = num%K print(-1)" p03137,s258844323,Accepted,"from sys import stdin def main(): #入力 readline=stdin.readline n,m=map(int,readline().split()) x=list(map(int,readline().split())) x.sort() d=[0]*(m-1) for i in range(1,m): d[i-1]=x[i]-x[i-1] d.sort() print(sum(d[:max(0,m-n)])) if __name__==""__main__"": main()" p03838,s308334727,Accepted,"X, Y = map(int, input().split()) ans = 10**10 if Y-X >= 0: ans = min(ans, Y-X) if Y+X >= 0: ans = min(ans, Y+X+1) if -Y-X >= 0: ans = min(ans, -Y-X+1) if -Y+X >= 0: ans = min(ans, -Y+X+2) print(ans) " p02727,s844222776,Accepted,"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:] NEW = a + b + c NEWnew = sorted(NEW, reverse=True) del NEWnew[X+Y:] K = sum(NEWnew) print(K) " p03377,s399127425,Accepted,"a,b,x=map(int,input().split()) print(""YES"" if 0<=x-a<=b else ""NO"")" p02690,s329495099,Accepted,"x = int(input()) l = [] d = {} for i in range(1000): b = (-1000+i)**5 d[b] = -1000+i for i in range(1000): a = i**5 d[a] = i if a-x in d: b = d[a-x] a = i break print(a,b)" p02773,s590452109,Accepted,"N=int(input()) d=dict() for _ in range(N): S=input() if S not in d: d[S]=0 d[S]+=1 M=max(d.values()) ans=[] for S in d.keys(): if d[S]==M: ans.append(S) ans.sort() for S in ans: print(S) " p03779,s144782582,Wrong Answer,"x = int(input()) s = x//2 s = s*(s+1)//2 if s < x: print(x//2 + 1) else: print(x//2) " p03437,s719562510,Accepted,"import sys def IL(): return map(int,sys.stdin.readline().rstrip().split()) if __name__=='__main__': x,y = IL() if x==y: print(-1) exit() for rep in range(x,10**9+1,x): if rep%y!=0: print(rep) exit() print(-1) exit()" p03281,s870120068,Wrong Answer,"N = int(input()) count_1 = 0 for i in range(1,N+1,2): count_2 = 0 for j in range(1,i+1,2): if N % j == 0: count_2 += 1 if count_2 == 8: count_1 += 1 print(count_1) " p02603,s397528463,Accepted,"N=int(input()) A=list(map(int,input().split())) dp = [-1]*N dp[0] = 1000 dp[1] = 1000 #dp[i] = max(dp[i-2],dp[i-1], (dp[i-2]//A[i-2])*A[i]+dp[i-2]%A[i-2]) for i in range(1,N): dp[i] = max(dp[i-1], (dp[i-1]//A[i-1])*A[i]+dp[i-1]%A[i-1]) print(dp[N-1]) " p02720,s291475831,Accepted,"import sys sys.setrecursionlimit(1000000) K = int(input()) all = [] def dfs(number): all.append(number) if len(str(number)) == 10: return for i in range(-1, 2): n_number = number % 10 + i if n_number >= 0 and n_number <= 9: dfs(number*10+n_number) for i in range(1, 10): dfs(i) all.sort() print(all[K-1])" p02701,s352115960,Accepted,"N = int(input()) S = [input() for i in range(N)] a = set(S) print(len(a))" p03962,s330284545,Accepted,"ns = set(map(int, input().split())) print(len(ns))" p02629,s643694260,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) s = int(input()) n = num2alpha(s) print(n.lower())" p03352,s568516231,Accepted,"n=int(input()) res=1 k=1 for b in range(1,int(n**0.5)+1): for p in range(2,n): if b**p>n: break else: res=max(res,b**p) print(res)" p02995,s551124930,Accepted,"A, B, C, D = map(int, input().split()) def gcd(a, b): if a == 0: return b return int(gcd(b%a, a)) def lcm(a, b): return int(a * b / gcd(a, b)) E = lcm(C, D) ans = (B-A+1) - (B//C - (A-1)//C) - (B//D - (A-1)//D) + (B//E - (A-1)//E) print(ans)" p03438,s751097688,Accepted,"def ceil(a, b): return (a + b - 1) // b N = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) n = sum(b) - sum(a) cnt = 0 for _a, _b in zip(a, b): if _a < _b: cnt += ceil(_b - _a, 2) if cnt <= n: print('Yes') else: print('No') " p02900,s529666056,Accepted,"from fractions import gcd def factor(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 a,b = map(int,input().split()) c = gcd(a,b) print(len(set(factor(c)))+1)" p02699,s820886362,Accepted,"S,W = map(int,input().split()) if S > W: print(""safe"") else: print(""unsafe"")" p02879,s100765214,Accepted,"A,B=map(int,input().split()) if A<=9 and B<=9: print(A*B) else: print(""-1"")" p02779,s476633439,Accepted,"import collections N = int(input()) l = list(map(int,input().split())) c = collections.Counter(l) if c.most_common()[0][1] > 1: print('NO') else: print('YES')" p03252,s580782223,Accepted,"S = input() T = input() D = dict() for s, t in zip(S, T): if s in D: if D[s] != t: print('No') exit() elif t in D.values(): print('No') exit() else: D[s] = t print('Yes')" p02627,s456004249,Accepted,"if ord(input()) < 91: print('A') else: print('a')" p03243,s672026293,Accepted,"N=int(input()) for i in range(1,10): ans=i*100+i*10+i if ans>=N: print(ans) exit()" p03448,s253711956,Wrong Answer,"numof500 = int(input()) numof100 = int(input()) numof50 = int(input()) moneyneeded = int(input()) counter = 0 for i in range(numof500): for j in range(numof100): for k in range(numof50): if 500 * i + 100 * j + 50 * k == moneyneeded: counter += 1 print(counter)" p03555,s048406751,Accepted,"x =[str(input()) for i in range(2)] if x[0][0]==x[1][2] and x[0][1]==x[1][1] and x[0][2]==x[1][0]: print(""YES"") else: print(""NO"")" p02785,s361130379,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(sum(sorted(h[k + 1:], reverse=True))) if __name__ == '__main__': main() " p03037,s183224540,Accepted,"n,m = map(int,input().split()) lr = [list(map(int,input().split())) for _ in range(m)] for i in range(m-1): if lr[i][0] > lr[i+1][0]: lr[i+1][0] = lr[i][0] if lr[i][1] < lr[i+1][1]: lr[i+1][1] = lr[i][1] ans = lr[-1][1] - lr[-1][0] + 1 if ans >= 0: print(ans) else: print(0)" p03206,s255557854,Accepted,"D = int(input()) if D==25: print('Christmas') exit() if D==24: print('Christmas Eve') exit() if D==23: print('Christmas Eve Eve') exit() if D==22: print('Christmas Eve Eve Eve') exit() " p03474,s020059955,Accepted,"A, B = map(int, input().split()) S = input() S1 = S[:A] S2 = S[A] S3 = S[A+1:] print(""Yes"" if S1.isdecimal() and S2 ==""-"" and S3.isdecimal() else ""No"")" p02843,s806345907,Accepted,"X = int(input()) dp = [False for _ in range(X+1)] dp[0] = True for x in range(X+1): if x > 99: item = [100, 101, 102, 103, 104, 105] for i in item: if dp[x-i]: dp[x] = True if dp[X]: print(1) else: print(0)" p02797,s132530841,Wrong Answer,"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, K, S = map(int, readline().split()) ans = [S]*K + [S+1]*(N-K) print(' '.join(map(str, ans))) if __name__ == '__main__': main() " p02595,s776211306,Accepted,"import sys input=sys.stdin.readline 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) " p03456,s016925440,Wrong Answer,"a, b = input().split() num = int(a+b) for i in range(1, 150): if i**2 == num: print(""Yes"") break else: print(""No"")" p02677,s459399512,Accepted,"import math A,B,H,M = map(int,input().split()) kakudoA = (H+M/60)*30 kakudoB = M*6 kakudo = min(abs(kakudoA-kakudoB),360-abs(kakudoA-kakudoB)) henn2 = A**2+B**2-2*A*B*math.cos(math.radians(kakudo)) print(henn2**0.5)" p03565,s384166660,Accepted,"s = list(input()) t = list(input()) ns = len(s) nt = len(t) flag = False if ns < nt: print('UNRESTORABLE') exit() for i in reversed(range(ns-nt+1)): for j in range(nt): if s[i:i+nt][j] != '?' and s[i:i+nt][j] != t[j]: break else: s[i:i+nt] = t flag = True break if flag: ans = ''.join(s).replace('?', 'a') print(ans) else: print('UNRESTORABLE') " p03210,s759947112,Wrong Answer,"X = int(input()) ans = 'NO' if X in ['3','5','7']: ans = 'YES' print(ans)" p02661,s863198192,Accepted,"n = int(input()) a = [] b = [] for i in range(n): aa, bb = map(int, input().split()) a.append(aa) b.append(bb) a.sort() b.sort() ans = 0 if n%2 == 1: ans = b[n//2]-a[n//2]+1 else: ans = (b[n//2]-a[n//2])+(b[n//2-1]-a[n//2-1])+1 print (ans)" p03017,s144121137,Accepted,"n,a,b,c,d = map(int,input().split()) s = input() for i in range(a,max(c,d)): if s[i-1:i+1] == ""##"": print('No') exit() if c < d: print('Yes') exit() for i in range(b-1,d): if s[i-1:i+2] == ""..."": print(""Yes"") exit() print('No') " p02765,s278196148,Wrong Answer,"n,k=map(int,input().split()) ans=0 while n>k: n/=n n=int(n) ans+=1 print(ans+1)" p02823,s512442981,Accepted,"n,a,b = map(int,input().split()) if (b-a)%2==0: print(int((b-a)//2)) else: print(int(min(a-1,n-b)+1+(b-1-a)//2))" p04033,s840648648,Accepted,"a,b=map(int,input().split()) if a<=0 and b>=0: print(""Zero"") exit() if a>0: print(""Positive"") exit() tmp=0 for i in range(a,b+1): tmp+=1 if tmp%2==0: print(""Positive"") else: print(""Negative"")" p03107,s591522601,Accepted,"s=list(map(int,list(input()))) from collections import Counter s+=[0,1] cs=Counter(s) print(min(cs.values())*2-2)" p02547,s967614682,Accepted,"def main(): n = int(input()) count = 0 res = False for _ in range(n): d1, d2 = map(int, input().split()) if d1 == d2: count += 1 if count >= 3: res = True else: count = 0 if res: print(""Yes"") else: print(""No"") if __name__ == ""__main__"": main()" p02628,s065546126,Wrong Answer,"n, k = input().split() lists = list(input().split()) lists.sort() sum_fruit = 0 for i in range(int(k)): sum_fruit = sum_fruit + int(lists.pop(-1)) print(str(sum_fruit))" p02910,s753098708,Wrong Answer," s = list(input()) for i in range(1,len(s)+1): if i % 2 == 1: if s[i-1] == ""L"": print(""No"") exit() else: if s[i-1] == ""R"": print(""Yes"") exit() print(""Yes"") " p03438,s259271917,Wrong Answer,"N = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) a.sort() b.sort() for i in range(N): if a[i] > b[i]: print('No') exit() print('Yes')" p03680,s965986321,Wrong Answer,"N=int(input()) li = [] now = 0 ans = -1 count = 0 for n in range(N): li.append(int(input())) for n in range(N): if n == 0: now = li[0] count += 1 now = li[now - 1] count += 1 if now == 2: ans = count break print(ans)" p02603,s351427201,Wrong Answer,"n=int(input()) a=list(map(int,input().split())) tmp=[a[0]] ans=1000 for i in range(n): if type(tmp[-1])==int: if a[i]>tmp[-1]: tmp[-1]=[tmp[-1],a[i]] else: if a[i]=2: S.append(i) S=list(set(S)) S.sort() if len(S)>=2: ans=S[-1]*S[-2] else: print(0) exit() Q=[] for i,j in A.items(): if j>=4: Q.append(i) if Q==[]: print(ans) exit() print(max(ans, (max(Q))**2)) " p02819,s081513239,Wrong Answer,"prims = list() prims.append(2) base = int(input()) def _is_prim(n): global prims for p in prims: if n % p == 0: return False return True # 入力値までの素数を作る for n in range(base): if n < 2: continue elif n % 2 == 0: continue elif _is_prim(n): prims.append(n) # 作った素数値で。。。 while not _is_prim(base): base += 1 print(base) " p02659,s461917519,Accepted,"from decimal import Decimal as dec a, b=map(dec, input().split()) print(int(a*b))" p02880,s821704675,Wrong Answer,"a=int(input()) b=0 for i in range(9): for k in range(9): if (i+1)*(k+1)==a: print(""Yes"") break b=b+1 if b==81: print(""No"")" p02831,s316762952,Accepted,"x,y = [ int(i) for i in input().split("" "") ] start = 2 a, b = x, y while a != b: temp = abs(a - b) a = min(a, b) b = temp ans = x * y / a print(int(ans))" p03062,s159237489,Accepted,"n = int(input()) a = list(map(int, input().split())) k = 1 for i in range(n): if a[i] < 0: a[i] *= -1 k *= -1 a.sort() if k == -1: a[0] *= -1 print(sum(a)) " p02859,s704300526,Accepted,"print(int(input())**2) " p02714,s681918618,Accepted,"n=int(input()) s=input() c=s.count m=c('R')*c('G')*c('B') for i in range(n): for j in range(i+2,n,2): if s[i]!=s[i+j>>1]!=s[j]!=s[i]: m-=1 print(m) " p03243,s027979182,Accepted,"n = int(input()) while str(n)[0] != str(n)[1] or str(n)[1] != str(n)[2]: n+=1 print(n) " p02994,s201518438,Accepted,"n,l = map(int,input().split()) a = [i+l for i in range(n)] amax = max(a) amin = min(a) if a.count(0) == 0: if amax > 0: a.pop(0) else: a.pop() print(sum(a))" p03472,s327239230,Accepted,"import math def resolve(): N, H = list(map(int, input().split())) attacks = [] for i in range(N): a, b = list(map(int, input().split())) attacks.append((a, 0)) attacks.append((b, 1)) attacks = sorted(attacks) damage = 0 cnt = 0 while damage < H: dam, once = attacks.pop() damage += dam cnt += 1 if not once: cnt += math.ceil((H - damage) / dam) break print(cnt) if '__main__' == __name__: resolve()" p02854,s460116288,Accepted,"n=int(input()) a=list(map(int,input().split())) ans=float('inf') s=sum(a) res=0 for i in range(n): res+=a[i] s-=a[i] ans=min(ans,abs(s-res)) print(ans)" p02797,s773568341,Accepted,"N,K,S=map(int,input().split()) A=[S]*N for i in range(K,N): if S==1: A[i]=S+1 else: A[i]=S-1 print(*A)" p02621,s120253966,Wrong Answer,"a = 1 a = int(a) x = a + a**2 + a**3 print(x)" p03632,s208506305,Accepted,"A, B, C, D = map(int, input().split()) if A < C: if B < D: if C < B: print(B-C) else: print(0) else: print(D-C) else: if D < B: if A < D: print(D-A) else: print(0) else: print(B-A)" p03309,s089685884,Accepted,"def main(): N, *A = map(int, open(0).read().split()) for i in range(N): A[i] -= i + 1 A.sort() print(sum(A[N // 2 + N % 2:]) - sum(A[:N // 2])) return main() " p03062,s385054260,Wrong Answer,"N = int(input()) *A, = map(int, input().split()) cnt = sum([1 for i in range(N) if A[i] < 0]) if cnt % 2 == 0: print(sum([abs(a) for a in A])) else: A.sort(key=abs) print(sum([abs(a) for a in A[1:]]) - A[0])" p03796,s941105680,Wrong Answer,"times = int(input()) power = 1 for i in range(1, times+1): power = power*i print(power)" p03309,s718197921,Accepted,"N = int(input()) A = list(map(int,input().split())) A_sum = [a-i for i,a in enumerate(A)] middle = sorted(A_sum)[len(A)//2] f = [abs(a-middle) for a in A_sum] print(sum(f)) " p03069,s557858989,Accepted,"def main(): n = int(input()) s = list(input()) s_b = [1 if c=='#' else 0 for c in s] s_w = [1 if c=='.' else 0 for c in s[::-1]] s_b = cumsum(s_b) s_w = cumsum(s_w)[::-1] ans = [] for i in range(n): ans.append(s_b[i]+s_w[i+1]) print(min(ans)) def cumsum(a): s = 0 sums = [0] for a_i in a: s+=a_i sums.append(s) return sums if __name__ == ""__main__"": main()" p02797,s216006492,Accepted,"import sys input = sys.stdin.readline N, K, S = [int(x) for x in input().split()] ans = [S] * K if S == 10 ** 9: ans += [1] * (N - K) else: ans += [(10 ** 9) - S] * (N - K) print(*ans) " p02744,s437872088,Wrong Answer,"from itertools import combinations_with_replacement n=int(input()) L='abcdefghij' Li=L[:n] kumiawase=list(combinations_with_replacement(Li, n)) for kumi in kumiawase: print(''.join(kumi))" p02912,s101914834,Accepted,"from sys import stdin nii=lambda:map(int,stdin.readline().split()) lnii=lambda:list(map(int,stdin.readline().split())) from heapq import * n,m=nii() a=lnii() a=[-i for i in a] a.sort(reverse=True) heapify(a) for i in range(m): x=heappop(a) x*=-1 x//=2 heappush(a,-x) print(-sum(a))" p02820,s707022525,Accepted,"from collections import Counter from collections import defaultdict def main(n,k,r,s,p,t): score = 0 for i in range(len(t)): if i < k: continue if t[i] == t[i-k]: t[i] = ""N"" c = Counter(t) i = defaultdict(int,c) score += i[""r""]*p + i[""s""]*r + i[""p""]*s return score n,k = map(int, input().split()) r,s,p = map(int, input().split()) t = list(input()) print(main(n,k,r,s,p,t))" p03814,s838968217,Accepted,"s = input() s_start = 0 s_end = 0 count = 0 # 文字列sを右から探索できるように逆順に変換する s_reverse = s[::-1] # print(s_reverse) for i in s: if i == 'A': s_start = count break count += 1 # カウンタcountを逆順用に変更(降順) count = len(s) - 1 for j in s_reverse: if j == 'Z': s_end = count break count -= 1 ans = s_end - s_start + 1 print(ans) " p02796,s744222260,Accepted,"n = int(input()); sf = [ [0]*2 for i in range(n) ]; for i in range(n) : xl = input().split(' '); sf[i][0] = int(xl[0]) - int(xl[1]); sf[i][1] = int(xl[0]) + int(xl[1]); sf.sort(key=lambda x:x[1] ); ans = 1; end = sf[0][1]; for i in range(1,n) : if end <= sf[i][0] : end = sf[i][1]; ans += 1; print(ans);" p02726,s583029130,Accepted,"n, x, y = map(int, input().split()) x, y = x-1, y-1 ans = [0] * n for i in range(n): for j in range(i+1, n): ind = min(j-i, abs(x-i)+abs(y-j)+1) ans[ind] += 1 for k in range(1, n): print(ans[k])" p03681,s366754213,Accepted,"n,m = map(int,input().split()) if abs(n-m) > 1: print(0) exit() mod = 10**9+7 if n==m: ans = 2 a = 1 for i in range(1,n+1): a *= i a %= mod print(ans*a**2%mod) else: if m > n: n,m = m,n ans = 1 for i in range(1,m+1): ans *= i ans %= mod ans = ans**2*n ans %= mod print(ans) " p02947,s341730042,Accepted,"import collections N = int(input()) s = ["""".join(sorted(input())) for _ in range(N)] c = collections.Counter(s) ans = 0 for si in set(s): n = c[si] ans += n * (n - 1) // 2 print(ans)" p04020,s428781784,Accepted,"N = int(input()) A = [int(input()) for i in range(N)] count = A[0]//2 A[0] %= 2 for i in range(1,N): if A[i] == 0: continue if A[i-1] != 0: count += 1 A[i] -= 1 count += A[i]//2 A[i] %= 2 print(count) " p03696,s077473447,Accepted,"n = int(input()) s = input() over = 0 ans_f = 0 ans_e = 0 for c in s: if c == ""("": over += 1 else: # ) if over > 0: over -= 1 else: ans_f += 1 ans_e = over ans = (""("" * ans_f) + s + ("")"" * ans_e) print(ans) " p02866,s564455238,Accepted,"import bisect n = int(input()) D = list(map(int, input().split())) if D[0] != 0: print(0) else: c = 1 temp = 1 e = 1 D.sort() m = D[-1] if n > 1 and D[1] == 0: print(0) exit() else: for i in range(1, m+1): a = bisect.bisect_right(D, i) d = a - temp temp = a if d == 0 and i>0: print(0) exit() else: c *= e**d c %= 998244353 e = d print(c)" p02970,s134917977,Accepted,"import math N, D=list(map(int, input().split())) print(math.ceil(N/(2*D+1))) " p02640,s172051400,Accepted,"x, y = map(int, input().split()) for i in range(x+1): if 2*i + 4*(x-i) == y: print('Yes') break else: print('No')" p02646,s337517029,Wrong Answer,"a,v = list(map(int, input().split())) b,w = list(map(int, input().split())) t = int(input()) diff = abs(a-b) V = abs(v-w) if V <= 0: print('NO') else: if diff<=V*t: print('YES') else: print('NO') " p03607,s766254040,Accepted,"import bisect n=int(input()) a=[] lis=[] for i in range(n): inp=int(input()) a.insert(bisect.bisect_left(a,inp),inp) ans=0 bef=a[0] co=0 for i in a[1:]: if i!=bef: ans+=(co+1)%2 co=0 bef=i else: co+=1 ans+=(co+1)%2 print(ans)" p03680,s031802613,Accepted,"_, *A = map(lambda x: int(x) - 1, open(0).read().split()) A = list(A) pos = 0 cnt = 1 for i in range(10 ** 5 + 1): pos = A[pos] if pos == 1: print(cnt) break cnt += 1 else: print(-1) " p02922,s255769972,Accepted,"a,b=map(int,input().split()) ans=0 k=1 while k 0) * t ) " p02972,s986188238,Accepted,"from collections import deque N = int(input()) A = list(map(int, input().split())) check = [0] * N for i in reversed(range(1, N + 1)): if sum(check[i - 1::i]) % 2 != A[i - 1]: check[i - 1] = 1 M = sum(check) ans = deque() for index, value in enumerate(check): if value == 1: ans.append(index + 1) print(M) if M > 0: print(*ans) " p03087,s961922705,Accepted,"#ABC122C 累積和 from itertools import accumulate A = [] N, Q = map(int, input().split()) B = [0]*N S = list(input()) ans = [] for i in range(1, N): if S[i-1]=='A' and S[i]=='C': B[i] = 1 A = list(accumulate(B)) for j in range(Q): l, r = map(int, input().split()) ans.append(A[r-1]-A[l-1]) print('\n'.join(map(str, ans)))" p03319,s240718273,Accepted,"n, k = map(int, input().split()) a = [int(x) for x in input().split()] idx = r = 0 while idx < n: if idx == 0: idx += k else: idx += k - 1 r += 1 print(r)" p02659,s104361404,Accepted,"a, b = input().split() a = int(a) b = round(float(b) * 100) print(a * b // 100) " p03359,s141535725,Wrong Answer,"a,b=map(int,input().split()) if b>a: print(a) else: print(a-1)" p03711,s120454418,Accepted,"a = [1,3,5,7,8,10,12] b = [4,6,9,11] x, y = map(int,input().split()) if x in a and y in a or (x in b and y in b): print(""Yes"") else: print(""No"")" p02612,s035116540,Wrong Answer,"n = int(input()) print(1000-(n%1000))" p02719,s765458670,Accepted,"a = list(map(int,input().split())) N = a[0] K = a[1] if K >= 2*N: print(N) elif K > N : print(abs(N-K)) elif N >= K: res = N%K min = res cul_result1 = abs(res-K) if cul_result1 < min: min = cul_result1 cul_result2 = abs(cul_result1-K) if cul_result2 < min: min = cul_result2 print(min) " p03695,s474444878,Accepted,"N = int(input()) A = [int(T) for T in input().split()] Color = [T//400 for T in A if T<3200] ColL = len(Color) SetL = len(set(Color)) MIN = max(1,SetL) MAX = SetL+(N-ColL) print('{} {}'.format(MIN,MAX))" p02657,s702589106,Wrong Answer,"S = input().split() A = int(S[0]) B = float(S[1]) print(((A*B))) " p02682,s200864882,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))) " p03821,s118031095,Accepted,"import numpy as np n = int(input()) ab = [] for _ in range(n): ab.append(list(map(int, input().split()))) a = np.array([x[0] for x in ab]) b = np.array([x[1] for x in ab]) ans = 0 for x, y in zip(a[::-1], b[::-1]): mod = (x + ans) % y if mod == 0: continue else: add = y - mod ans += add print(ans)" p03163,s283461991,Accepted,"N, W = map(int, input().split()) wt, val = [], [] for i in range(N): w,v = map(int, input().split()) wt.append(w) val.append(v) K = [[0 for x in range(W+1)] for y in range(N+1)] for i in range(N+1): for w in range(W+1): if i == 0 or w == 0: K[i][w] = 0 elif wt[i-1] <= w: # print(""ayo"") K[i][w] = max(val[i-1]+K[i-1][w-wt[i-1]], K[i-1][w]) else: K[i][w] = K[i-1][w] print(K[N][W])" p02720,s347472660,Accepted,"k = int(input()) def lunlun(x): s = str(x) good = 0 for i in range(1, len(s)): if abs(int(s[i - 1]) - int(s[i])) > 1: # what is the ""digit value"" of s[i] return 10 ** (len(s) - i - 1) return good n = 1 last = 0 total = 0 while total < k: skip = lunlun(n) if skip == 0: last = n total += 1 n += 1 else: n += skip print(last)" p03075,s177541599,Accepted,"import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readline_s = sys.stdin.readline readlines = sys.stdin.buffer.readlines def main(): a = int(input()) b = int(input()) c = int(input()) d = int(input()) e = int(input()) k = int(input()) if abs(a - e) <= k: ans = 'Yay!' else: ans = ':(' print(ans) if __name__ == '__main__': main() " p02678,s231862756,Wrong Answer,"N,M=map(int,input().split()) G=[[] for _ in range(N+1)] for i in range(M): a,b=map(int,input().split()) G[a].append(b) G[b].append(a) ans=[0]*(N+1) checked=[False]*(N+1) d=[1] while d: c=d.pop() for g in G[c]: if not checked[g]: d.append(g) checked[g]=True ans[g]=c print('Yes') for i in range(2, len(ans)): print(ans[i])" p02552,s325357200,Wrong Answer,"a = input() if a==0: print(1) else: print(0)" p02583,s533541014,Accepted,"n = int(input()) l = list(map(int, input().split())) l.sort() if n <= 2: print(0) exit() cnt = 0 for i in range(n-2): for j in range(i+1, n-1): if l[i] != l[j]: for k in l[j+1:]: if k < l[i]+l[j] and k != l[i] and k != l[j]: cnt += 1 print(cnt)" p03592,s464709022,Wrong Answer,"import sys input = sys.stdin.readline # B - fLIP n, m, k = map(int, input().split()) black = 0 for i in range(m): black += n for j in range(n): if j > 0: if i == 0: black += m else: black += m - 1 if black == k: print('Yes') sys.exit() print('No')" p03852,s616336357,Accepted,"s = input() if s=='a' or s=='i' or s=='u' or s=='e' or s=='o': print('vowel') else: print('consonant')" p03359,s259751032,Accepted,"a,b=list(map(int,input().split())) if b>=a: print(a) else: print(a-1)" p03317,s256093382,Accepted,"# coding: utf-8 # https://atcoder.jp/contests/abc101 def main(): N, K = map(int, input().split()) A = list(map(int, input().split())) ans = 1 N -= K if N % (K-1) == 0: ans += N // (K-1) else: ans += N // (K-1) + 1 return ans print(main()) " p03679,s287050074,Accepted,"x,a,b = map(int,input().split()) if -a + b <= 0: print(""delicious"") elif 0 < -a + b < x+1: print(""safe"") elif -a + b >= x+1: print(""dangerous"")" p02948,s643740859,Wrong Answer,"import heapq n,m=map(int, input().split()) lst = [] for i in range(n): a,b=map(int, input().split()) lst.append((-b,a)) lst = sorted(lst, key=lambda x:x[1]) now_idx = 0 queue = [] sum_ = 0 for i in range(1,m+1): for j in range(now_idx, n): if lst[j][1] <= i: heapq.heappush(queue, lst[j]) else: now_idx = j break if len(queue)>0: sum_ -= heapq.heappop(queue)[0] print(sum_) " p04005,s406779290,Wrong Answer,"# AGC 04 a, b, c = map(int, input().split()) if c % 2 != 0: print(a * b) else: print(0)" p02629,s876370902,Wrong Answer,"n = int(input()) ans='' while n > 0: ans = chr(ord('a') + (n % 26) -1) + ans n //= 26 print(ans)" p02862,s140732222,Accepted,"X,Y = map(int,input().split()) def modinv(a, mod=10**9+7): return pow(a, mod-2, mod) def combi(n,r,mod=10**9+7): fac = [0]*(n+1) fac[0] = 1 fac[1] = 1 for i in range(2,n+1): fac[i] = fac[i-1] * i % mod return( ( fac[n] * modinv(fac[r]) )%mod * modinv(fac[n-r]) % mod) if (X+Y) % 3 != 0 or X > 2*Y or Y > 2*X: print(0) else: n = X - (X + Y)//3 m = (X + Y)//3 - n print(combi(n+m,m))" p02786,s673540753,Accepted,"H = int(input()) c = 1 while H != 1: H = H // 2 c += 1 print(2 ** c - 1)" p03150,s278838889,Accepted,"s = input() ans = '' if s == 'keyence': ans = 'YES' else: for i in range(len(s) - 7): for j in range(len(s) - i): if s[:j] + s[j + i + 1:] == 'keyence': ans = 'YES' break if ans == '': ans = 'NO' print(ans)" p02730,s497518140,Wrong Answer,"s = ""atcoder"" l = len(s) s1 = s[:int((l-1)/2)] s2 = s[int((l+3)/2) - 1:] if (s1 == s1[::-1]) and (s2 == s2[::-1]): print(""Yes"") else : print(""No"") print(s1,s2)" p02691,s596520792,Accepted,"n = int(input()) a = list(map(int, input().split())) d = {} ans = 0 for i in range(n): if i-a[i] in d: ans += d[i-a[i]] if i+a[i] in d: d[i+a[i]] += 1 else: d[i+a[i]] = 1 print(ans)" p02742,s565427377,Accepted,"#6 import sys H,W = map(int,input().split()) k = H*W if H ==1 or W == 1: print(1) sys.exit() if k%2 == 0: print(int(k/2)) else: print(int(k/2)+1)" p02882,s847291906,Accepted,"from collections import defaultdict from collections import deque from collections import OrderedDict import itertools import math from sys import stdin input = stdin.readline def main(): a, b, x = list(map(int, input().split())) # y = 2*(b-(x/a**2))/a # yd = 2*x/(a*b**2) # print(y, yd) if x > 0.5*a*a*b: print(math.degrees(math.atan( 2*(b-(x/a**2))/a ))) else: print(90 - math.degrees(math.atan( (2*x/(a*b**2)) ))) if(__name__ == '__main__'): main() " p03827,s169231691,Accepted,"def main(): N = int(input()) S = input() memo = [0]*(N+1) for i, ss in enumerate(S, 1): if ss == 'I': memo[i] = memo[i-1] + 1 else: memo[i] = memo[i-1] - 1 print(max(memo)) if __name__ == ""__main__"": main() " p03761,s368106124,Accepted,"import collections n = int(input()) dict = {} for i in range(26): dict[chr(ord('a') + i)] = 50 for _ in range(n): S = input() for char in dict.keys(): dict[char] = min(dict[char], S.count(char)) ans = '' for char, num in sorted(dict.items()): ans += (char * num) print(ans) " p03803,s024479057,Accepted,"import sys a,b=map(int,input().split()) if (a==1 and b==13): print('Alice') sys.exit() else: pass if a==13 and b==1: print('Bob') sys.exit() else: pass if a>b: print('Alice') elif a==b: print('Draw') else: print('Bob') " p03220,s642144395,Accepted,"import numpy as np N = input() T, A = map(int, input().split()) H = np.array(input().split(), dtype=np.float64) X = abs(T - H * 0.006 - A) print(np.argmin(X) + 1) " p02842,s485825306,Accepted,"import math N=int(input()) x=math.ceil(N/1.08) if math.floor(x*1.08) == N: print(x) else: print("":("") " p03455,s423478111,Accepted,"a,b=map(int,input().split()) c=a*b if c%2==0: print('Even') else: print('Odd') " p03131,s007633439,Accepted,"K, A, B = map(int, input().split()) if (A+2) >= B: print(K+1) else: print((((K-A+1)//2)*(B-A))+((K-A+1)%2)+(A))" p02783,s454344101,Accepted,"H, A=list(map(int, input().split())) if H%A==0: print(H//A) else: print(H//A+1) " p02780,s137381440,Wrong Answer,"N,K=map(int,input().split()) p=list(map(int,input().split())) E=[0]*N for i in range(N): E[i]=(p[i]+1)/2 S=[0]*N for i in range(N): S[i]=sum(E[:i]) A=[0]*(N-K+1) for i in range(N-K): A[i]=S[i+K]-S[i] print(max(A))" p02724,s286449150,Accepted,"X = int(input()) ans = 0 n = X // 500 X -= n * 500 ans = n * 1000 ans += (X // 5) * 5 print(ans) " p02971,s998973147,Accepted,"N=int(input()) list=[] for i in range(N): A=int(input()) list.append(A) l=sorted(list,reverse=True) A_1=l[0] A_2=l[1] for j in range(N): if list[j]!=A_1: print(A_1) else: print(A_2)" p03745,s345276907,Accepted,"n=int(input()) A=list(map(int,input().split())) c=1 d=0 for i in range(n-1): e=d+A[i+1]-A[i] if (de and d>0): c+=1 e=0 d=e print(c)" p03633,s887986636,Accepted,"import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 9) MOD = 10 ** 9 + 7 from fractions import gcd N = int(input()) T = int(input()) for _ in range(N - 1): t = int(input()) T = T * t // gcd(T, t) print (T)" p03944,s118358266,Accepted,"w,h,n=map(int,input().split()) x1,x2=0,w y1,y2=0,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) elif a==4: y2 = min(y2,y) print(max((x2-x1)*(y2-y1),0) if x2-x1>0 else 0)" p03835,s726590201,Accepted,"k, s = map(int, input().split()) ans = 0 for a in range(k+1): for b in range(k+1): if 0 <= s - a - b <= k: ans += 1 print(ans)" p03208,s360404149,Accepted,"from sys import stdin input = stdin.buffer.readline n, k = map(int, input().split()) h = [int(input()) for _ in range(n)] h.sort() ans = 10 ** 9 for i in range(n-k+1): diff = h[i+k-1] - h[i] if diff < ans: ans = diff print(ans)" p03387,s698566297,Accepted,"N = list(map(int,input().split())) N.sort() A = N[0] B = N[1] C = N[2] ans = 0 if max(N) == min(N): print(ans) exit() if (B-A)%2 == 0: ans += (B-A)//2 + C - B else: ans += 1 B += 1 C += 1 ans += (B-A)//2 + C - B print(ans) " p03951,s561182457,Accepted,"#!/usr/bin/env python n = int(input()) s = input() t = input() ans = '' for i in range(n+1): if s[n-i:] == t[:i]: ans = s + t[i:] print(len(ans)) " p03478,s027145186,Accepted,"n, a, b = [int(x) for x in input().split()] res = 0 for i in range(1, n + 1): s = str(i) cc = 0 for j in s: cc += int(j) res += i * (a <= cc <= b) print(res)" p02629,s546690888,Wrong Answer,"N = int(input()) resulter = ""abcdefghijklmnopqrstuvwxyz"" # NS = str(N) hoge = [] count = 10 while True: re = pow(26, count) if N > re: tmp = N // re hoge.append(resulter[tmp - 1]) N = N - re * tmp # count = 10 count = count - 1 if count < 1: hoge.append(resulter[N - 1]) break print("""".join(hoge)) " p02547,s865813160,Wrong Answer,"n = int(input().strip()) count = 0 for i in range(n): a,b = map(int,input().strip().split()) if a == b and count == 3: print('Yes') exit(0) elif a == b: count += 1 elif(a != b): count = 0 if count == 3: print('Yes') else: print('No') " p02618,s550864038,Accepted,"D = int(input()) listC = list(map(int, input().split())) answerL = [] for i in range(D): listS = list(map(int, input().split())) maxi = max(listS) target = listS.index(maxi) answerL.append(target+1) for ans in answerL: print(ans)" p03624,s367505580,Accepted,"S = input() alphabet_list = [chr(i) for i in range(97, 97 + 26)] flag = 0 for moji in alphabet_list: if moji not in S: print(moji) flag = 1 break if not flag: print(""None"")" p03331,s903394408,Accepted,"n = int(input()) ans = 1001001001 for i in range(1,n): j = n-i i_sum, j_sum = 0, 0 si, sj = list(str(i)), list(str(j)) for s1 in si: i_sum += int(s1) for s2 in sj: j_sum += int(s2) ans = min(ans, i_sum+j_sum) print(ans)" p02659,s544003019,Accepted,"import sys import math input = sys.stdin.readline ins = lambda: input().rstrip() ini = lambda: int(input().rstrip()) inm = lambda: map(float, input().split()) inl = lambda: list(map(int, input().split())) out = lambda x: print('\n'.join(map(str, x))) a, b = inm() a = int(a) b = int(b * 100 + 0.1) print(a*b // 100)" p03317,s749131708,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) cnt = 1 length = K while True: if length >= N: print(cnt) break length += K-1 cnt += 1" p02957,s565104266,Accepted,"a,b=list(map(int,input("""").split("" ""))) if((a+b)%2 == 0): print((a+b)//2) else: print(""IMPOSSIBLE"")" p03799,s624898380,Accepted,"N, M = map(int, input().split()) ans = min(N, M // 2) + max(M - 2 * N, 0) // 4 print(ans)" p03127,s640640880,Accepted,"from math import * n = int(input()) a = sorted(map(int, input().split())) g = a[0] for i in range(1,n): g = gcd(g, a[i]) print(g)" p02659,s273586335,Accepted,"from decimal import Decimal import math a, b = map(Decimal,input().split()) print(math.floor(a*b))" p03329,s842228221,Accepted,"N=int(input()) l=[1,6,9,36,81,216,729,1296,6561,7776,46656,59049] h=[None]*100001 h[0]=0 k=[0] c=1 while None in h: t=[] for i in k: for j in l: if i+j>100000: break if h[i+j]==None: h[i+j]=c t.append(i+j) k=t c+=1 print(h[N])" p03069,s503184367,Accepted,"n = int(input()) s = input() b = 0 w = s.count(""."") l = [w] for i in range(1, n + 1): if s[i - 1] == ""#"": b += 1 if s[i - 1] == ""."": w -= 1 l.append(b + w) print(min(l))" p03695,s264254877,Accepted,"N = int(input()) a = list(map(int, input().split())) ans = [0] * 8 free = 0 for r in a: if r > 3199: free += 1 else: ans[r // 400] = 1 min_ = max(sum(ans), 1) #max_ = min(sum(ans) + free, 8) max_ = sum(ans) + free print(min_, max_)" p02811,s125996524,Wrong Answer,"K,X = map(int,input().split()) if K * 500 > X: print(""Yes"") else: print(""No"") " p03219,s965813448,Accepted,"x, y = [int(i) for i in input().split()] print(x + y//2)" p02724,s069184672,Wrong Answer,"# -*- coding: utf-8 -*- s = int(input()) happy = 0 if s >= 500: happy += 1000 * (s // 500) s = s % 500 if s >= 5: happy += 5 * (s // 500) print(happy) " p03679,s474075553,Wrong Answer,"x, a, b = map(lambda x: int(x), input().split()) if b < a: print('delicious') elif x >= b - a: print('safe') else: print('dangerous')" p03474,s682213843,Wrong Answer,"import re a,b = list(map(int,input().split())) s = input() if re.match(r""[1-9][1-9]*"",s[0:a]): if s[a]==""-"": if re.match(r""[1-9][1-9]*"",s[(a+1):(a+b)]): if len(s)==a+b+1: print(""Yes"") exit() print(""No"")" p02572,s351652936,Wrong Answer,"n = int(input()) a = list(map(int, input().split())) s = sum(a) aa = sum(list(map(lambda x: x**2, a))) total = int((s**2 - aa) / 2) % (10**9 + 7) print(total)" p03696,s763504096,Accepted,"N = int(input()) S = input() l = S.count('(') r = S.count(')') d = r - l if d > 0: S = '(' * d + S if d < 0: S = S + ')' * (-d) l, r, d = 0, 0, 0 for s in S: if s == '(': l += 1 if s == ')': r += 1 d = max(d, r - l) if d > 0: S = '(' * d + S + ')' * d print(S) " p03251,s266108731,Wrong Answer,"n, m, x, y = map(int, input().split()) a = max(list(map(int, input().split()))) b = min(map(int, input().split())) print(['War', 'No War'][any((ax: ret+=a[0]-x a[0]-=x for i in range(1,n): if a[i-1]+a[i]>x: ret+=a[i-1]+a[i]-x a[i]-=a[i-1]+a[i]-x print(ret)" p03264,s485090294,Wrong Answer,"n = int(input()) print(-(-n//2)+((n+1)//2)) " p02661,s933801870,Wrong Answer,"n = int(input()) lister = [] for i in range(n): lister.append([int(i) for i in input().split()]) if n % 2 == 1: lister.sort(key=lambda x:x[0]) miner = lister[n//2][0] lister.sort(key=lambda x:x[1]) maxer = lister[n//2][1] print(maxer- miner + 1) else: lister.sort(key=lambda x:x[0]) miner = lister[n//2][0] lister.sort(key=lambda x:x[1]) maxer = lister[n//2][1] print(1 + (maxer- miner)*2) " p02988,s809971572,Wrong Answer,"n = int(input()) p = list(map(int, input().split())) ans = set() for i in range(1, n-1): a = [] a.append(p[i-1]) a.append(p[i]) a.append(p[i+1]) a.sort() ans.add(a[1]) print(len(ans))" p03437,s914359039,Wrong Answer,"def gcd(a,b): if a%b==0: return b return gcd(b,a%b) def check(n,m): x,y = max(n,m), min(n,m) sol = gcd(x,y) if sol == n: d = x//y if d!=1: return n*(d+1) else: return -1 elif sol == m: return -1 else: return n*(x//y+1) n,m = map(int, input().split()) c, limit = check(n,m), pow(10,9) print(-1 if c>limit else c)" p02971,s747884539,Accepted,"n,*a=map(int,open(0).read().split()) p=max(a) k=a.index(p)#かり s=max(a[:k]+a[k+1:])#second print('\n'.join(str(p) if i!=k else str(s) for i in range(n)))" p03680,s417373304,Accepted,"N=int(input()) A=[] ans=-1 for i in range(N): A.append(int(input())) num=A[0] for j in range(N): if num==2: ans=j+1 break num=A[num-1] print(ans)" p03146,s569309925,Accepted," from collections import defaultdict as dic s = int(input()) flag = dic(int) flag[s - 1] = 1 def f(n, i): if flag[n - 1] == 1: print(i) exit() else: flag[n - 1] = 1 if n % 2 == 1: f(3 * n + 1, i + 1) else: f(int(n / 2), i + 1) if s % 2 == 1: f(3 * s + 1, 2) else: f(int(s / 2), 2) " p02848,s289041548,Accepted,"N = int(input()) S = list(input()) stack = """" mi = ord('A') mx = ord('Z') for i in S : if ord(i)+N <= mx: stack = stack + chr(ord(i)+N) else: mem = ord(i)+N while mem > mx: mem = mem-26 stack = stack + chr(mem) print(stack)" p03251,s772246655,Accepted,"n,m,X,Y = map(int,input().split()) x = list(map(int,input().split())) y = list(map(int,input().split())) flag = True x_max = max(x) y_min = min(y) for z in range(X+1,Y+1): if x_max < z and y_min >= z: flag = False if flag: print('War') else: print('No War') " p03106,s492840186,Accepted,"a, b, k = map(int, input().split()) c = [] for i in range(1, min(a,b)+1): if a%i == 0 and b %i == 0: c.append(i) print(c[-k]) " p02623,s213138610,Wrong Answer,"n,m,k=map(int,input().split()) A=list(map(int,input().split())) B=list(map(int,input().split())) A.insert(0,0) cntB=0 cnt_list=[] for i in range(n+1): timeA=sum(A[:i+1]) cntA=i time=timeA if timeA>k: break for j in range(m): if time+B[j]<=k: timeB=sum(B[:j+1]) time=timeA+timeB cntB=j+1 else: break cnt=cntA+cntB cnt_list.append(cnt) print(max(cnt_list))" p03037,s693187808,Accepted,"N, M = list(map(int,input().rstrip().split())) Amin = 1 Amax = N for i in range(M): L, R = list(map(int,input().rstrip().split())) Amin = max(Amin,L) Amax = min(Amax,R) if Amin>Amax: print(0) break else: print(Amax-Amin+1)" p03281,s611324792,Accepted,"def div(x): cnt = 0 for i in range(1, x + 1): if x % i == 0: cnt += 1 return cnt n = int(input()) ans = 0 for i in range(1, n + 1, 2): if div(i) == 8: ans += 1 print(ans) " p03795,s171244269,Accepted,"n = int(input()) k = n//15 res = 800*n - 200*k print(res) " p02705,s843008174,Wrong Answer,"import math str = input().strip() print(int(str)*math.pi)" p03645,s918131300,Wrong Answer,"N,M=map(int,input().split()) f=set() t=set() for i in range(M): a,b=map(int,input().split()) if a<2: f.add(b) if b==N: t.add(a) print(""IM""*len(f&t)+""POSSIBLE"")" p02861,s021027635,Accepted,"from itertools import permutations n = int(input()) xy = [list(map(int, input().split())) for _ in range(n)] ans = 0 count = 0 for i in permutations(range(n), n): for j in range(n-1): ans += ((xy[i[j]][0] - xy[i[j+1]][0])**2 + (xy[i[j]][1] - xy[i[j+1]][1])**2)**0.5 count += 1 print(ans/count)" p02578,s341440754,Accepted,"n=int(input()) a=list(map(int,input().split())) ans=0 maenomax=a[0] for i in range(n): if maenomax > a[i]: ans += maenomax-a[i] elif maenomax < a[i]: maenomax=a[i] print(ans)" p03759,s125860235,Accepted,"a, b, c = map(int, input().split()) if b - a == c - b: print('YES') else: print('NO') " p02547,s792549085,Accepted,"N = int(input()) count = 0 flag = False for i in range(N): D1, D2 = map(int, input().split()) if D1 == D2: count += 1 else: count = 0 if count == 3: flag = True if flag: print(""Yes"") else: print(""No"")" p03720,s317115987,Wrong Answer,"N, M = map(int, input().split()) A = [[0]*(N+1) for _ in range(N+1)] for i in range(M): a, b = map(int, input().split()) A[a][b] = 1 A[b][a] = 1 for i in range(1, N+1): sum = 0 for j in range(1, N+1): sum += A[i][j] print(sum)" p02596,s568890181,Accepted,"K = int(input()) flag = 0 now = 0 for i in range(1,K+1): now = now + 7*pow(10, i-1, K) now = now%K if now==0: flag = 1 print(i) break if flag==0: print(-1) " p03324,s253881590,Accepted,"D, N = map(int, input().split()) count = 0 for i in range(1, 10 ** 7): tmp = i flag = True div_count = 0 for j in range(3): if tmp%100 == 0: tmp = tmp // 100 div_count += 1 if div_count == D: count += 1 if count == N: print(i) break" p02727,s468242445,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(reverse=True) A=P[:X]+Q[:Y]+R A.sort(reverse=True) print(A[X+Y])" p03284,s315286871,Accepted,"N, K = map(int, input().split()) if N % K == 0: print(0) else: print(1) " p02601,s636524050,Wrong Answer,"a,b,c=map(int,input().split()) k=int(input()) if c>b and b>a: print(""Yes"") exit() else: while(k>0): if bb and b>a: print(""Yes"") else: print(""No"")" p02756,s615167947,Accepted,"from collections import deque s = input() q = int(input()) Q = [input() for _ in range(q)] s = deque(list(s)) insert = s.appendleft append = s.append flag = True for query in Q: if query[0] == '1': flag = not flag else: if (query[2] == '1' and flag) or (query[2] == '2' and not flag): insert(query[4]) else: append(query[4]) if not flag: s.reverse() print(*s, sep='') " p02777,s761204322,Wrong Answer,"S, T = input().split() A, B = list(map(int, input().split())) U = input() if U == ""red"": A = A - 1 else: B = B - 1 print(A, B)" p02624,s421882340,Accepted,"def solve(): N = int(input()) cnt = [1]*(N+1) for i in range(2, N+1): j = 1 while i*j<=N: cnt[i*j] += 1 j += 1 ans = 0 for i in range(1, N+1): ans += i*cnt[i] print(ans) solve() " p02801,s597717676,Wrong Answer,"c = ord(input()) print(chr(c))" p02700,s277759541,Accepted,"import sys readline = sys.stdin.buffer.readline t1,t2,a1,a2= list(map(int,readline().rstrip().split())) nnn = lambda x: 0 if x == 0 else 1 if a1//t2 + nnn(a1%t2) <= t1//a2 + nnn(t1%a2): print('Yes') else: print('No') " p03427,s027682247,Wrong Answer,"n = input() if n[0] == '1': ans = 0 judge = set(n[1:]) if len(judge) == 1 and '9' in judge: for i in n: ans += int(i) print(ans) else: ans = 9 * (len(n) - 1) print(ans) else: ans = int(n[0]) - 1 for i in range(1,len(n)): ans += 9 print(ans) " p03814,s993972281,Wrong Answer,"s = input() t = 0 u = 0 n = len(s) for i in range(n): if s[i] == ""A"": t = i break for j in range(n): if s[n-j-1] == ""Z"": u = n-j-1 print(u-t+1)" p02797,s319560640,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 main(): n, k, s = MI() if s == 10 ** 9: ans = [s] * k + [1] * (n - k) else: ans = [s] * k + [s + 1] * (n - k) print(*ans) main() " p02646,s671853703,Accepted,"a,v = map(int,input().split()) b,w = map(int,input().split()) t = int(input()) l = abs(b-a) r = v-w if l-(r*t)<=0: print(""YES"") else: print(""NO"")" p02909,s116876698,Accepted,"s = input() if s == 'Sunny': print('Cloudy') elif s == 'Cloudy': print('Rainy') else: print('Sunny')" p02732,s637819097,Wrong Answer,"import collections N = int(input()) A = list(map(int, input().split())) c = collections.Counter(A) ans = 0 for i in range(N): ans+=c[i]*(c[i]-1)//2 for i in range(N): print(ans-(c[A[i]]-1))" p04020,s303856941,Accepted,"N = int(input()) tmp = 0 ans = 0 for _ in range(N): a = int(input()) if a != 0: tmp += a else: ans += tmp // 2 tmp = 0 ans += tmp // 2 print(ans) " p02612,s102964809,Accepted,"cost = input() amari = int(cost[-3:]) if amari == 0: amari = 1000 print(1000 - amari)" p02665,s084444175,Accepted,"n = int(input()) a = list(map(int,input().split())) cumsum_a = a.copy() for i in range(n-1, -1, -1): cumsum_a[i] += cumsum_a[i+1] ans = 0 childable_node = 1 for i in range(n + 1): if a[i] > childable_node: ans = -1 break ans += childable_node if i < n: b_max1 = 2 * (childable_node - a[i]) b_max2 = cumsum_a[i + 1] childable_node = min(b_max1, b_max2) print(ans)" p03077,s058522305,Accepted,"# 2020/02/22 # AtCoder Beginner Contest 123 - C # Input n = int(input()) ae = list() for i in range(5): ae.append(int(input())) # Calc minae = min(ae) ans = n // minae + 4 if n % minae > 0: ans = ans + 1 # Output print(ans) " p03069,s417359343,Accepted,"N = int(input()) S = input() Black = [0]*(N+1) White = [S.count('.')]*(N+1) DispS = [S.count('.')]*(N+1) for TN in range(0,N): Black[TN+1] = Black[TN]+[0,1][S[TN]=='#'] White[TN+1] = White[TN]-[0,1][S[TN]=='.'] DispS[TN+1] = Black[TN+1]+White[TN+1] print(min(DispS))" p02726,s241795961,Wrong Answer,"n, x, y = map(int, input().split()) loop = y-x+1 line = n-y+x l1 = x-1 l2 = n-y print(n) for k in range(2, n): ans = max(line-k+1, 0) if k<=loop//2: ans += loop if k-l1<=1 and k>2: ans += (loop//2)*2-1 else: ans += max((loop//2-(k-l1)+1), 0)*2 if k-l2<=1 and k>2: ans += (loop//2)*2-1 else: ans += max((loop//2-(k-l2)+1), 0)*2 print(ans) " p03408,s580003620,Wrong Answer,"x=[] n=int(input()) d1={} for i in range(n): s=input() x.append(s) if s in d1: d1[s]+=1 else: d1[s]=1 m=int(input()) d2={} for i in range(m): t=input() x.append(t) if t in d2: d2[t]+=1 else: d2[t]=1 ans=0 for s in x: cnt=0 if s in d1: cnt+=d1[s] if s in d2: cnt+=d2[s] if ans= sb: flg=False else: if (sb-sa)%2==0: flg=False if flg: print(""Yes"") else: print(""No"")" p03043,s894296951,Wrong Answer,"import math N,K = map(int,input().split()) p = [0] * (N+1) for i in range(1,N+1): if (1 <= i) and (i <= K-1): r = int(1+math.log(K/i,2)) p[i] = float( (1/N) * (math.pow(1/2,r)) ) elif i >= K: p[i] = float(1/N) ans = sum(p) print(ans)" p02556,s070918982,Accepted,"N = int(input()) points = [list(map(int, input().split())) for _ in range(N)] INF = 10**10 xmax = -INF xmin = INF ymax = -INF ymin = INF for x, y in points: minus = x-y plus = x+y xmax = max(xmax, minus) xmin = min(xmin, minus) ymax = max(ymax, plus) ymin = min(ymin, plus) print(max(xmax-xmin, ymax-ymin))" p03328,s718763980,Accepted,"a, b = map(int, raw_input().split()) c = b - a x = 1 + c y = x * c f = y / 2 print f - b" p02743,s695445275,Accepted,"a, b, c = map(int, input().split()) if c - a - b < 0: print('No') elif 4 * a * b < (c - a - b) ** 2: print('Yes') else: print('No')" p03317,s881415540,Accepted,"n, k = map(int, input().split()) A = list(map(int, input().split())) min_a = A.index(min(A)) left = min_a right = n - min_a - 1 min_ = min(left, right) max_ = max(left, right) t = 0 min_ = min_ - k t +=1 temp = 0 if min_ > 0: if min_ % (k - 1) != 0: temp = min_ // (k - 1) else: temp = min_ // (k - 1) + 1 min_ -= temp * (k - 1) t += temp max_ = max_ + min_ + 1 if max_ % (k - 1) == 0: t += max_ // (k - 1) else: t += max_ // (k - 1) + 1 print(t)" p02660,s617711811,Accepted,"from collections import Counter def factorization(n) -> list: ret = [] i = 2 while i * i <= n: while n % i == 0: n //= i ret.append(i) i += 1 if n != 1: ret.append(n) return ret n=int(input()) if n==1: print(0) exit() c=Counter(factorization(n)) ans=0 for x in c.values(): r=0 while r*(r+1)//2<=x: r+=1 ans+=r-1 print(ans)" p03206,s342205205,Wrong Answer,"S=int(input()) if S==25: print(""Crisitmas "") if S==24: print(""Christmas Eve"") if S==23: print(""Christmas Eve Eve"") if S==22: print(""Christmas Eve Eve Eve"") " p02624,s371048734,Accepted,"N=int(input()) ans=(N*(N+1))//2 #1の時 for i in range(2,N+1): m=N//i ans+=i*(m*(m+1)//2) print(ans)" p02578,s813310907,Wrong Answer,"n = int(input()) a = list(map(int,input().split())) max_n = max(a) min_n = min(a) result = max_n - min_n print(result)" p03434,s129208922,Accepted,"n = int(input()) #一応読むけど、ループ回せば不要では aList=list(map(int,input().split())) aList.sort(reverse = True) ap = 0 bp = 0 for i,a in enumerate(aList): if i%2 == 0: #0から始まるので偶数奇数逆で考える ap = ap + a else: bp = bp + a print(ap-bp)" p02682,s125927476,Accepted,"def main(): a, b, c, k = map(int, input().split()) res = 0 res += 1 * min(a, k) k -= a if k > 0: k -= b if k > 0: res += (-1 * min(c, k)) print(res) if __name__ == '__main__': main()" p03617,s578147990,Accepted,"q,h,s,d=map(int,input().split());n=int(input());print(n//2*min(8*q,4*h,2*s,d)+n%2*min(4*q,2*h,s))" p03323,s084049688,Accepted,"A,B = map(int,input().split(' ')) if A > 8 or B > 8: print(':(') else: print('Yay!') " p03785,s452925357,Accepted,"n, c, k = map(int, input().split()) t = [int(input()) for i in range(n)] t.sort() ans = 1 cur = t[0] cnt = 0 for i in t: if i > cur + k or cnt == c: ans += 1 cnt = 1 cur = i else: cnt += 1 print(ans)" p02629,s728450384,Wrong Answer,"N = int(input()) ans, i = 0, 1 def toN(X, n): if (int(X/n)): return toN(int(X/n), n)+str(X%n).zfill(2) return str(X%n).zfill(2) while N > ans + 26**i: ans += 26**i i += 1 a = toN(N, 26) lang = [] for j in range(0, i*2, 2): if j == 0: lang.append('a') else: lang.append(chr(int(a[j:j+2])+96)) pre = int(a[j:j+2]) print(''.join(lang)) " p03038,s997055124,Accepted,"n, m = map(int, input().split()) a = list(map(int, input().split())) bc = [] for _ in range(m): b, c = map(int, input().split()) bc.append([c, b]) a.sort() bc.sort(reverse = True) x = [0] * n i, j = 0, 0 while i < n: for _ in range(bc[j][1]): x[i] = bc[j][0] i += 1 if i == n: break j += 1 if j == m: break ans = 0 for i in range(n): ans += max(a[i], x[i]) print(ans)" p02682,s571843607,Wrong Answer,"x = list(map(int, input().split())) a = x[0] b = x[1] c = x[2] k = x[3] if a >= k: print(a) else: count = k - a if b >= count: print(a) else: count = k - a - b ans = a - count print(ans)" p03317,s255975589,Accepted,"import sys sys.setrecursionlimit(10000000) MOD = 10 ** 9 + 7 INF = 10 ** 15 def main(): N,K = map(int,input().split()) A = list(map(int,input().split())) ans = 1 N -= K ans += (N + K - 2)//(K - 1) print(ans) if __name__ == '__main__': main()" p03785,s249053960,Accepted,"n,c,k=map(int, input().split()) t=[int(input()) for _ in range(n)] t.sort() tmp_lim=t[0]+k num_bus=0 num_person=1 for i in range(1, n): if tmp_lim mx: mx = mxtemp print(mx)" p03252,s568175846,Wrong Answer,"S=input() T=input() dict_S={} dict_T={} for x, y in zip(S, T): if x not in dict_S: dict_S[x]=y else: if dict_S[x]!=y: print(""No"") break if y not in dict_T: dict_T[y]=x else: if dict_T[y]!=x: print(""No"") break print(""Yes"")" p02723,s716564837,Wrong Answer,"s=input() if s[2]==s[3] and s[4]==s[5]: print(""Yes"") else: print(""NO"") " p03962,s865233266,Wrong Answer,"a,b,c=map(int,input().split()) if (a==b and b==c and a==c): print(3) elif(a==b and b!=c): print(2) elif(b==c and c!=a): print(2) elif(c==a and a!=b): print(2) else: print(1)" p03281,s631250853,Accepted,"import math n=int(input()) count,cnt=0,0 for i in range(1,n+1,2): for j in range(1,math.ceil(i/2)): if i%j==0: count+=1 if count+1==8: cnt+=1 count=0 print(cnt)" p02811,s324074327,Accepted,"k,x=map(int,input().split()) print('Yes' if k*500>=x else 'No') " p04033,s427066947,Accepted,"a, b = map(int, input().split()) if a * b <= 0: print('Zero') elif 1 <= a: print('Positive') else: if (b - a) %2 == 0: print('Negative') else: print('Positive') " p03680,s457001522,Wrong Answer,"import sys input = sys.stdin.readline n=int(input()) B = [int(input())-1 for i in range(n)] def fun(k): if B[k] == 1: return False else: return B[k] ans = 0 cnt = 0 for i in range(n): cnt = fun(cnt) ans +=1 if cnt ==False: print(ans) sys.exit() print(-1) sys.exit()" p03163,s189246643,Accepted,"def main(): import sys num,capacity=map(int,input().split()) items=tuple([list(map(int,sys.stdin.readline().split())) for _ in range(num)]) DP=[-1]*(capacity+1) DP[0]=0 for item in items: weight=item[0] value=item[1] left=capacity-weight for i in range(left,-1,-1): if DP[i]<0: continue DP[i+weight]=max(DP[i]+value,DP[i+weight]) print(max(DP)) if __name__==""__main__"": main()" p02879,s611338543,Accepted,"A, B = map(int, input().split()) if A <= 9 and B <= 9: print(A*B) else: print(-1)" p02783,s559350851,Accepted,"h, a = map(int, input().split()) print(-(-h // a)) " p03759,s957437947,Accepted,"a, b, c = map(int, input().split()) if c-b == b-a: print(""YES"") else: print(""NO"")" p02731,s406673017,Accepted,"print((int(input()) / 3)**3) " p03319,s053368972,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) import math print(math.ceil((N-1)/(K-1))) " p02664,s533530088,Accepted,"t = input() t = t.replace(""P?"", ""PD"") t = t.replace(""?"", ""D"") print(t) " p02909,s262601325,Accepted,"weather=input() if(weather==""Sunny""): print(""Cloudy"") elif(weather==""Cloudy""): print(""Rainy"") else: print(""Sunny"")" p03760,s841560793,Accepted,"O = input() E = input() n = len(E) m = len(O) L = [] if m== n: for i in range(n): L.append(O[i]+E[i]) else: for i in range(n): L.append(O[i]+E[i]) L.append(O[m-1]) ans = ''.join(L) print(ans)" p02553,s661328704,Accepted,"a,b,c,d=map(int,input().split()) print(max(a*c,a*d,b*c,b*d)) " p03162,s187777689,Wrong Answer,"n = int(input()) A = [list(map(int, input().split())) for _ in range(n)] def chmax(a, b): if a > b: return a else: return b dp = [[ 0 for _ in range(3)]for _ in range(n+10)] for i in range(n): for j in range(3): for k in range(3): if j == k: continue else: dp[i][k] = chmax(dp[i+1][k], dp[i][j]+A[i][k]) print(max(dp[n-1])) " p02684,s758886051,Accepted,"N,K=map(int,input().split()) A=list(map(int,input().split())) F=[-1]*N l=0 prev=0 while True: if F[prev]!=-1: break if l==K: print(prev+1);exit() F[prev]=l l+=1 prev=A[prev]-1 #print(l,prev) l = (K-F[prev])%(l-F[prev]) #print(l) for i in range(l): prev=A[prev]-1 print(prev+1) " p03696,s337436480,Accepted,"n=int(input()) s=input() from itertools import groupby as gb head=0 m=0 for k,v in [(a,len(list(b))) for a,b in gb(s)]: if k=="")"": if m 0: print('Yes') else: print('No') " p02842,s868962673,Wrong Answer,"import sys input = sys.stdin.readline def main(): n = int(input()) for x in range(1, n): if int(x * 1.08) == n: print(x) return print("":("") main() " p02748,s679530317,Wrong Answer,"A,B,M=map(int,input().split()) aa=list(map(int,input().split())) bb=list(map(int,input().split())) coupon=[list(map(int,input().split())) for i in range(M)] min=2*(10**5) for j in range(M): p_a=coupon[j][0] p_b=coupon[j][1] p_c=coupon[j][2] ans=aa[p_a-1]+bb[p_b-1]-p_c if ans= k: # print(k) sys.exit() else: ans = a k = k -a if k != 0 and k - b > 0: print(a-(k-b)) else: print(a) " p02761,s185114415,Accepted,"N, M = map(int, input().split()) ans = [-1] * N for i in range(M): s, c = map(int, input().split()) s -= 1 if ans[s] != -1 and ans[s] != c: print(-1) exit() ans[s] = c if N != 1: if ans[0] == 0: print(-1) exit() if ans[0] == -1: ans[0] = 1 for i in range(N): if ans[i] == -1: ans[i] = 0 else: if ans[0] == -1: ans[0] = 0 print(''.join(map(str, ans))) " p02899,s918841921,Accepted,"n = int(input()) List = list(map(int, input().split())) Ans = [0 for _ in range(n)] for i in range(n): Ans[List[i]-1] = i + 1 print(*Ans)" p03219,s043996923,Accepted,"x,y = map(int,input().split()) print(x+y//2)" p02571,s773086404,Accepted,"S=input() T=input() lens=len(S) lent=len(T) ans=0 for i in range(lens-lent+1): tmp=0 for j in range(lent): if S[i+j]==T[j]: tmp+=1 if tmp>ans: ans=tmp print(lent-ans) " p02622,s532813281,Accepted,"S=input() T=input() ans=0 for s,t in zip(S,T): if s!=t: ans+=1 print(ans)" p02731,s092026259,Wrong Answer,"L=int(input()) ans=[] for i in range(1,1000): for j in range(1,1000): k=L-(i+j) ans.append(i*j*k) print(max(ans)) " p02873,s972906673,Accepted,"s=input() a=[0]*(len(s)+1) prev=0 for i in range(len(s)): if s[i]=='<': a[i+1]=a[i]+1 for j in range(len(s)-1,-1,-1): if s[j]=='>': if a[j]>a[j+1]+1: continue else: a[j]=a[j+1]+1 print(sum(a))" p02732,s810717262,Accepted,"N = int(input()) A = list(map(int, input().split())) B = [0]*(N+1) for i in range (0, N): B[A[i]]+=1 C = 0 import math for i in range (1, N+1): C+=math.comb(B[i],2) for i in range (0, N): print(C+math.comb(B[A[i]]-1,2)-math.comb(B[A[i]],2))" p02676,s368413641,Wrong Answer,"k = int(input()) s = str(input()) if k>=len(s): print(s) else: a = s+s[0:k] print(a)" p03493,s468664066,Wrong Answer,"s = input() print(s.count(""0""))" p02571,s086416291,Accepted,"S = input() T = input() s_len = len(S) t_len = len(T) R = s_len - t_len ans = 1000 for i in range(R + 1): s_new = S[i : t_len + i] count = 0 for j in range(t_len): if s_new[j] != T[j]: count += 1 ans = min(ans, count) print(ans)" p02854,s577274572,Wrong Answer,"n = int(input()) a = [int(i) for i in input().split()] len_f = sum(a) sum_a = 0 min = 2020202021 for i in range(1,len(a)): sum_a += a[i] len_f -= a[i] if min > abs(sum_a - len_f): min = abs(sum_a - len_f) print(min)" p02817,s546323181,Wrong Answer,"li = list(input()) print(li[1]+li[0])" p02675,s393299791,Accepted,"def resolve(): N = int(input()[-1]) hon = [2, 4, 5, 7, 9] pon = [0, 1, 6, 8] if N in hon: print('hon') elif N in pon: print('pon') elif N == 3: print('bon') if __name__ == '__main__': resolve()" p02861,s676406069,Accepted,"N = int(input()) P = [] for _ in range(N): P.append(list(map(int, input().split()))) total = 0 for i, p1 in enumerate(P[:-1]): for p2 in P[i+1:]: total += ((p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2) ** 0.5 print(total * 2 / N)" p02633,s505659685,Accepted,"N=int(input()) import math print(360//math.gcd(360,N)) " p03639,s064464440,Accepted,"N=int(input()) A=list(map(int,input().split())) a=0 b=0 for num in A: if num%2==1: a+=1 elif num%4==0: b+=1 if N%2==1: if a>b+1: print('No') else: print('Yes') else: if a<=b: print('Yes') else: print('No')" p03408,s658479358,Accepted,"n=int(input()) s=[input() for i in range(n)] m=int(input()) t=[input() for i in range(m)] l=list(set(s)) print(max(0,max(s.count(l[i])-t.count(l[i]) for i in range(len(l)))))" p03679,s734631273,Wrong Answer,"x,a,b = map(int, input().split()) d = b-a if (d <= 0): print('delicious ') elif(d < x): print('safe') else: print('dangerous') " p02797,s482697969,Accepted,"n,k,s = map(int,input().split()) INF = 10**9 ans = [INF] * n if s == INF: ans = [1] * n for i in range(k): ans[i] = s print(*ans)" p03285,s745015583,Wrong Answer,"n = int(input()) if(n % 4 == 0): print('Yes') elif(n % 7 == 0): print('Yes') elif(n % 11 == 0): print('Yes') else: print('No')" p04012,s284883538,Accepted,"import collections s = input() cnt = collections.Counter() for i in s: cnt[i] += 1 if all([True if i % 2 == 0 else False for i in cnt.values()]): print(""Yes"") else: print(""No"") " p02820,s343971417,Wrong Answer,"n,k=map(int,input().split()) a,b,c=map(int,input().split()) s=input() l=['']*k for i in range(n): l[i%k]+=s[i] ans=0 d={'s':a,'p':b,'r':c} for i in range(k): x=l[i] for j in range(len(x)//2): if x[2*j]==x[2*j+1]: ans+=d[x[2*j]] else: ans+=(d[x[2*j]]+d[x[2*j+1]]) if len(x)%2==1: ans+=d[x[-1]] print(ans)" p02761,s915424344,Accepted,"N, M = map(int, input().split()) s = [] c = [] for m in range(M): si, ci = map(int, input().split()) s.append(si) c.append(ci) ss = 10 ** (N - 1) if N == 1: ss -= 1 for i in range(ss, 10 ** N): for m in range(M): if str(i)[s[m] - 1] != str(c[m]): break else: print(i) exit() print(-1) " p03455,s521824074,Accepted,"a, b = map(int, input().split()) if (a*b)%2 == 1: print(""Odd"") else: print(""Even"")" p02595,s097405690,Wrong Answer,"i=0 N,D=map(int,input().split()) for i in range(N): X,Y=map(int,input().split()) if (X**2+Y**2)**0.5<=D: i=i+1 print(i)" p03062,s282890456,Accepted,"def main(): n = int(input()) a = list(map(int,input().split())) m = 0 for i in range(n): if a[i]<0: m += 1 ans = 0 for i in range(n): ans += abs(a[i]) if m%2==0: print(ans) else: mi = float('inf') for i in range(n): if mi>abs(a[i]): mi = abs(a[i]) print(ans-2*mi) if __name__ == ""__main__"": main() " p04043,s106235384,Accepted,"li=list(map(int,input().split())) ans = 'YES' if (li.count(5) == 2) and (li.count(7) == 1) else ""NO"" print(ans)" p02831,s684732006,Accepted,"from fractions import gcd A, B = map(int, input().split()) print(A*B//gcd(A, B))" p02860,s303031926,Accepted,"N = int(input()) S = input() if N % 2 != 0: print('No') exit() H = int(N / 2) if S[:H] == S[H:]: print('Yes') else: print('No')" p03059,s256988459,Accepted,"A, B, T = map(int, input().split()) ans = 0 time = A while time < T+0.5: time += A ans += B print(ans)" p02838,s072619463,Wrong Answer,"N = int(input()) MOD = 1e+9 + 7 shift = 70 a = [int(i) for i in input().split()] b = [0 for _ in range(shift)] for i in a: for j in range(shift): b[j] += (i >> j) & 1 ans = 0 for i, j in enumerate(b): second = 1 for _ in range(i): second *= 2 second %= MOD ans += ((j * (N - j)) * second) % MOD ans %= MOD print(int(ans))" p02972,s583473923,Wrong Answer,"import collections import heapq n = int(raw_input()) ais = [0] + map(int, raw_input().split(' ')) res = [0 for __ in range(n +1)] for u in range(n, 0, -1): c = u*2 cumul = 0 while(c <= n): cumul += res[c] c += u if ais[u] != (cumul % 2): res[u] = 1 s = sum(res) print s if s: print ''.join([str(i) for i in range(len(res)) if res[i] == 1])" p04043,s448302375,Accepted,"# -*- coding: utf-8 -*- # 整数の入力 lst = list(map(int, input().split())) if lst[0] == 5: if (lst[1] == 7 and lst[2] == 5) or (lst[1] == 5 and lst[2] == 7): print(""YES"") exit() elif lst[0] == 7: if lst[1] == 5 and lst[2] == 5: print(""YES"") exit() print(""NO"")" p03345,s616649118,Accepted,"A, B, C, K = map(int, input().split()) # 1回後 A:B+C B:A+C C:A+B A-B = B-A # 2回後 A:2A+B+C B:A+2B+C C:A+B+2C A-B = A-B if K % 2 == 0: print(A - B) else: print(B - A)" p02983,s439558483,Wrong Answer,"#!/usr/bin/env python3 def main(): L, R = map(int, input().split()) if R - L > 2017: print(0) return ans = min([n % 2019 for n in range(L, R + 1)]) ans = ans * (ans + 1) print(ans) if __name__ == '__main__': main() " p02713,s641749362,Accepted,"from math import gcd k = int(input()) sum = 0 for i in range(1, k + 1): for j in range(1, k + 1): for k in range(1, k + 1): sum += gcd(gcd(i, j), k) print(sum)" p02881,s077837607,Accepted,"import math N = 10000000019 N = 50 N = 10 N = int(input()) result = [] for i in range(1, math.ceil(math.sqrt(N))+1): if N % i == 0: result.append((i + (N // i)) - 2) print(min(result)) " p03796,s709417057,Accepted,"import math n=int(input()) print(math.factorial(n)%(10**9+7))" p02912,s925825687,Accepted,"import heapq import math N,M = map(int,input().split()) A = list(map(int,input().split())) # 各要素に1掛ける A = list(map(lambda x: x * -1, A)) heapq.heapify(A) for _ in range(M): heapq.heappush(A, ((-1*heapq.heappop(A))//2)*-1 ) print(sum(A) * -1)" p02917,s403962034,Accepted,"# For taking integer inputs. def inp(): return(int(input())) # For taking List inputs. def inlist(): return(list(map(int, input().split()))) # For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable. def instr(): s = input() return(list(s[:len(s)])) # For taking space seperated integer variable inputs. def invr(): return(map(int, input().split())) N = inp() B = inlist() A = [0] * N A[0] = B[0] for i in range(N-2): A[i+1] = min(B[i], B[i+1]) A[N-1] = B[N-2] print(sum(A)) " p02866,s242916026,Accepted,"a = int(input()) l = list(map(int,input().split())) d = [0]*a for i in l: d[i]+=1 r =1 if l[0]!=0: print(0) exit() for i in l[1:]: r=r*d[i-1]%998244353 print(r)" p02910,s940487744,Wrong Answer,"s=list(input()) l=[] for i in s[1::2]: l.append(i) new_l=[] for i in s[::2]: new_l.append(i) num =0 for i in new_l: if i == 'R' or i == 'U' or i == 'D': num='Yes' else: num='No' break ans=0 for i in l: if i == 'L' or i == 'U' or i == 'D': ans='Yes' else: ans='No' break if num == 'Yes' and ans == 'Yes': print('Yes') else: print('No') " p02847,s153313517,Accepted,"Array = [""SUN"",""MON"",""TUE"",""WED"",""THU"",""FRI"",""SAT""] S = input() print(abs(Array.index(S)-7))" p02935,s811541173,Wrong Answer,"import sys n = int(input()) v = list(map(int,input().split())) v.sort() ans,tmp = [],[] gab = (v[0]+v[1])/2 tmp.append(gab) if n == 2: print(tmp[0]) sys.exit() for i in range(2,n): j = 0 tmp.append((v[i] +tmp[j])/2) j += 1 print(tmp[-1])" p02702,s655601117,Accepted,"S = input()[::-1] remain_table = [0] * 2019 remain_table[0] = 1 d = 1 chk = 0 for s in S: chk += int(s) * d chk = chk % 2019 remain_table[chk] += 1 d *= 10 d %= 2019 ans = 0 for r in remain_table: ans += r * (r - 1) // 2 print(ans)" p03680,s697237622,Accepted,"n = int(input()) q = [int(input()) for i in range(n)] cnt = 0 ind = 0 for i in range(n): ind = q[ind]-1 cnt += 1 if ind == 1: print(cnt) exit() print(-1) " p02829,s042440761,Accepted,"l = [] l.append(input()) l.append(input()) if '1' not in l: print('1') elif '2' not in l: print('2') elif '3' not in l: print('3') " p03632,s055683425,Wrong Answer,"a, b, c, d = map(int, input().split()) ans = 0 start = True for i in range(101): if a <= i+1 <= b and c <= i+1 <= d: if start: start = False continue ans += 1 print(ans) " p03644,s658016594,Accepted,"n=int(input()) for i in range(0,n): if n<2**(i+1): ans=2**i break print(ans)" p04034,s856716764,Wrong Answer,"n, m = map(int, input().split()) a = [[1, False] for _ in range(n+1)] a[1] = [1, True] for _ in range(m): x, y = map(int, input().split()) if a[x][1]: a[x][0] -= 1 if a[x][0] == 0: a[x][1] = False a[y][0] += 1 a[y][1] = True print(sum(x[1] for x in a))" p03773,s975231142,Accepted,"print(eval(input().replace("" "",""+""))%24)" p02778,s641774444,Accepted,"#B S = input() print(""x""*len(S))" p02918,s242984998,Accepted,"#coding: utf-8 N, K = (int(i) for i in input().split()) S = input() while ""LL"" in S: S = S.replace(""LL"", ""L"") while ""RR"" in S: S = S.replace(""RR"", ""R"") sad = N - len(S) sad += K * 2 sad = min(N-1, sad) print(sad) " p02993,s373725204,Accepted,"n = input() for i in range(3): if n[i] == n[i+1]: print(""Bad"") exit() print(""Good"") " p02899,s626071251,Wrong Answer,"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=int(input()) A=[(e,i) for i,e in enumerate(list(map(int,input().split())))] #print(A) A.sort(key=lambda tup: tup[0]) #print(A) for e,i in A: print(e, i+1)" p02958,s353479618,Accepted,"n = int(input()) p = list(map(int,input().split())) cnt = 0 for i in range(len(p)): if p[i] != i+1: cnt += 1 if cnt==0 or cnt==2: print(""YES"") else: print(""NO"") " p03623,s541178897,Wrong Answer,"a,b,c=input().split() a=int(a) b=int(b) c=int(c) if (b-a)>=(c-b): print(c-b) else: print(b-a)" p02713,s258787459,Accepted,"# 最大公約数を格納するリストを初期化 max_codiv = [] # 繰り返す数を入力 n = int(input()) import math # 1からkまでの総当たりで最大公約数を調べる for i in range(1, n+1): for j in range(1, n+1): i_j = math.gcd(i, j) for k in range(1, n+1): i_j_k = math.gcd(i_j, k) max_codiv.append(i_j_k) print(sum(max_codiv))" p02639,s650378444,Wrong Answer,"x = list(map(int, input().split())) print(x) for i in range(5): if x[i] == 0: print(i+1) exit() " p02747,s160310185,Wrong Answer,"h = input() if ""hi"" in h: print(""No"") elif len(h.replace(""hi"","""")) < len(h): print(""Yes"") else: print(""No"")" p03013,s646522197,Accepted,"N, M = map(int,input().split()) oks = [True]*(N+1) mod = 1e9+7 for i in range(M): a = int(input()) oks[a]=False dp = [0]*(N+1) dp[0]=1 if oks[1]: dp[1]=1 else: dp[1]=0 for i in range(2,N+1): if oks[i]: dp[i]=dp[i-1]+dp[i-2] dp[i]%=mod print(int(dp[N]))" p02787,s735202515,Accepted,"H,N=map(int,input().split()) magic=[] for _ in range(N): A,B=map(int,input().split()) magic.append((A,B)) inf=float(""inf"") dp=[inf]*(H+1) dp[0]=0 for i in range(H): for a,b in magic: d=min(i+a,H) dp[d]=min(dp[d],dp[i]+b) print(dp[H])" p03997,s891660690,Accepted,"a=int(input()) b=int(input()) h=int(input()) print(((a+b)*h)//2)" p02958,s359078803,Accepted,"N = int(input()) list = list(map(int, input().split())) newlist = sorted(list) cnt = 0 for i in range(N): if list[i] != newlist[i]: cnt+=1 if cnt == 0 or cnt == 2: print(""YES"") else: print(""NO"")" p02771,s595647275,Accepted,"from collections import Counter, deque, defaultdict from functools import lru_cache a,b,c=map(lambda x:int(x),input().split()) if (a==b and b==c ) or (a!=b and b!=c and c !=a): print(""No"") else: print(""Yes"")" p03352,s338455165,Accepted,"x = int(input()) lis = [] for n in range(32): for e in range(2,11): if n**e <= x: lis.append(n**e) se = set(lis) print(max(se)) " p02772,s774401825,Accepted," N = int(input()) #N,K = map(int, input().split()) flag = False lst = list(map(int, input().split())) for elem in lst: if elem % 2 == 0: if ((elem % 3)==0) or ((elem % 5) ==0): pass else: flag = True break if flag: print('DENIED') else: print('APPROVED')" p03821,s033658492,Wrong Answer,"n = int(input()) a = [] b = [] for i in range(n): ai, bi = map(int, input().split()) a.append(ai) b.append(bi) a.reverse() b.reverse() ans = 0 for i in range(n): ai = a[i]+ans bi = b[i] if ai%bi != 0 or ai == 0: ans += bi-ai%bi print(ans) " p03293,s670954483,Wrong Answer,"s=input() t=input() l=len(s) for _ in range(l-1): if s==t: print(""Yes"") exit() else: s=s[-1]+s[:l-1] print(""No"")" p03359,s508149272,Wrong Answer,"a,b= map(int, input().split()) if a<=b: print(a) else: print(a-b)" p02660,s000241302,Wrong Answer,"import bisect as bi def fact(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([i,cnt]) if temp!=1: arr.append([temp,1]) if arr==[]: arr.append([n,1]) return arr n=int(input()) l=[i*(i+1)//2 for i in range(1,100)] c=0 for t in fact(n): c+=bi.bisect_right(l,t[1]) print(c)" p03555,s288819395,Wrong Answer,"line1 = str(input()) line2 = str(input()) newline1 = line2[::-1] newline2 = line1[::-1] if newline1==line1 and line2==newline2: print('Yes') else: print('No') " p03698,s838665210,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 fractions import gcd def resolve(): S=input() st=set() for s in S: if s in st:print(""no"");return st.add(s) print(""yes"") #%%submit! resolve()" p02759,s990028444,Accepted,"N = int(input()) if N%2 ==1: N += 1 print(int(N/2))" p03162,s128871599,Accepted,"n = int(input()) abc = [list(map(int, input().split())) for _ in range(n)] aabbcc = [[0], [0], [0]] tmp = [0]*3 for i in abc: for j in range(3): tmp[j] = i[j] + max(aabbcc[(j+1)%3][-1], aabbcc[(j+2)%3][-1]) for j in range(3): aabbcc[j].append(tmp[j]) print(max([i[-1] for i in aabbcc]))" p02779,s897028309,Accepted,"N = int(input()) A = list(map(int, input().split())) if N == len(list(set(A))): print('YES') else: print('NO') " p02910,s673897072,Accepted,"o=""RUD"" g=""LUD"" s=input() i=0 while i 0: sum += x % 10 x = x//10 if sum >= a and sum <= b: ans += i print(ans)" p03862,s560263346,Accepted,"N,x=map(int,input().split()) A=list(map(int,input().split())) cnt=0 for i in range(N): cnt+=max(A[i]-x,0) A[i]=min(A[i],x) for i in range(1,N): d=max(A[i]+A[i-1]-x,0) A[i]-=d cnt+=d print(cnt)" p02939,s988645590,Accepted,"s = str(input()) S = [] temp = '' for c in s: temp += c if S: if S[-1] != temp: S.append(temp) temp = '' else: S.append(temp) temp = '' print(len(S)) " p02583,s927251375,Accepted,"N = int(input()) L = list(map(int, input().split())) L.sort(reverse = True) i = j = k = 0 cnt = 0 while i=N: print(0) else: b=sorted(a) c=0 for i in range(N-K): c+=b[i] print(c)" p02768,s073134193,Accepted,"M=10**9+7 n,a,b=map(int,input().split()) s,r=pow(2,n,M),1 for i in range(b):r=r*(n-i)*pow(i+1,M-2,M)%M;s-=r*(i+1==a) print((~r+s)%M)" p03416,s362023045,Wrong Answer,"def isp(str): return True if str == str[::-1] else False a,b= map(int, input().split()) ans=0 for i in range(a,b+1): i_s=str(i) if isp(i_s): print(i) ans+=1 print(ans)" p02552,s866976108,Accepted,"x = int(input()) if x==0: print(1) elif x==1: print(0)" p02989,s043313787,Wrong Answer,"n=int(input()) d =list(map(int,input().split())) d.sort() ans = 0 for i in range(1,10**5): if d[n//2-1] =i: ans +=1 print(ans)" p02946,s646535316,Accepted,"K,X = map(int, input().split()) for i in range(X-K+1,X+K): print(i,end = "" "")" p02714,s238624704,Wrong Answer,"import collections import functools import operator n=int(input()) s=input() c=collections.Counter(s) # l=r*g*b l = functools.reduce(operator.mul, c.values()) for i in range(0,n-1): for j in range(i+1,n): k=j-i+j if k>=n: continue if s[i]!=s[j] and s[k]!=s[j] and s[i]!=s[k]: l-=1 print(l) " p02775,s307124371,Wrong Answer,"S = input().strip() ans = 0 for i in range(len(S)): if S[i] == '0': pass elif int(S[i]) > 5: ans += 10 - int(S[i]) + 1 else: ans += int(S[i]) print(ans) " p03759,s054064968,Accepted,"a,b,c=map(int,input().split()) if b-a==c-b: print(""YES"") else: print(""NO"")" p03814,s772600279,Accepted,"s=input() ans=False for i,v in enumerate(s): if ans==False: if v==""A"": a=i ans=True else: if v==""Z"": z=i print(z-a+1)" p03073,s401554907,Accepted,"S = input() T1 = len(S)*""01"" T2 = len(S)*""10"" ans = [] dif = 0 for s,t in zip(S,T1): if s!=t: dif+=1 ans+=[dif] dif = 0 for s,t in zip(S,T2): if s!=t: dif+=1 ans+=[dif] print(min(ans))" p02578,s843499047,Wrong Answer,"N = int(input()) A = list(map(int, input().split())) mini = A[0] ans = 0 for i in range(len(A) - 1): if A[i] < A[i+1]: ans += A[i+1] - A[i] print(ans)" p03556,s482225162,Accepted,"N = int(input()) max=1 for i in range(1, N): if int(i**2)<=N: max=i**2 else: break print(max)" p03210,s549715871,Wrong Answer,"a=input(int()) if a==3 or a==5 or a==7: print(""YES"") else: print(""NO"") " p02881,s036446214,Accepted,"N = int(input()) n = 1 ans = 10**13 while n*n <= N: if N%n==0: t = n + N//n - 2 ans = min(ans, t) n += 1 print(ans)" p03679,s538107098,Wrong Answer,"x,a,b = map(int,(input().split())) #x日までOK A日前に買ってきて B日語に食べた hantei = b - a if hantei < 0: print(""delicious"") elif x > hantei: print(""sefe"") else: print(""dangerous"")" p02755,s122199964,Accepted,"import numpy as np A, B = map(int,input().split()) A,B=int(A),int(B) c=0 d=True while(d): a=int(c*0.08) b=int(c*0.1) if a==A and b==B: print(c) d=False elif a>A or b>B: print('-1') d=False else: c+=1 continue" p02888,s205674670,Accepted,"from bisect import bisect_left, bisect_right # return index N = int(input()) L = sorted(list(map(int, input().split()))) ans = 0 for i in range(N): for j in range(i+1, N): tmp = L[i]+L[j] # tmpはこの値より短くなくてはいけない ### ここから下は二分探索 ix = bisect_left(L, tmp) ans += ix-(j+1) print(ans)" p03030,s780131013,Accepted,"N = int(input()) S = [list(input().split()) for _ in range(N)] for i in S: i[1] = 100 - int(i[1]) for i in range(N): S[i] += i+1, S.sort() for i in S: print(i[2])" p03211,s983611972,Accepted,"s = input() answer = 10000 for j in range(len(s)-2): t = s[j:j+3] answer = min(answer,abs(int(t)-753)) print(answer)" p02779,s714570778,Wrong Answer,"input() a=list(map(int, input().split())) #スペース区切りの数字をlistで取得 if int(len([i for i in a if a.count(i) >= 2])) !=0: print(""No"") else : print(""Yes"")" p02657,s334184001,Accepted,"a, b = map(int, input().split()) print(a*b) " p03087,s507901255,Accepted,"n,q=map(int,input().split()) s = input() a = [0,0] for i in range(1,n): a.append(a[i]+(s[i-1]==""A"" and s[i]=='C')) for i in range(q): l,r=map(int,input().split()) print(a[r]-a[l-1]-(s[l-2]=='A' and s[l-1]=='C')) " p02916,s210692560,Wrong Answer,"n = int(input()) a = list(map(int,input().split())) b = list(map(int,input().split())) c = list(map(int,input().split())) s = b[a[0]-1] for i in range(1,n): s += b[a[i]-1] if(a[i] == a[i-1]+1):s+=c[a[i-1]-1] print(i,s) print(s)" p03035,s268859773,Accepted,"# coding: utf-8 # Your code here! A, B = map(int, input().split()) if A>=13: print(B) elif A<=5: print(0) else: print(B//2) " p02897,s213315364,Wrong Answer,"N = int(input()) if N % 2 == 0: print(""0.5000000000"") elif N == 1: print(""1.0000000000"") else: print(""0.6000000000"")" p03221,s846777232,Accepted,"from collections import defaultdict import bisect N,M = map(int, input().split()) dic = defaultdict(list) cities = [] for _ in range(M): p,y = map(int,input().split()) cities.append([p,y]) for item in sorted(cities): dic[item[0]].append(item[1]) for item in cities: print(""%06d%06d""%(item[0],bisect.bisect(dic[item[0]],item[1])))" p02847,s799657097,Accepted,"S = str(input()) a = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT'] for i in range(len(a)): if S == a[i]: print(len(a) - i)" p03557,s525869029,Accepted,"import sys from bisect import bisect_left, bisect_right read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 def main(): N = int(readline()) A = list(map(int, readline().split())) B = list(map(int, readline().split())) C = list(map(int, readline().split())) A.sort() B.sort() C.sort() ans = sum(bisect_left(A, b) * (N - bisect_right(C, b)) for b in B) print(ans) return if __name__ == '__main__': main() " p03745,s718261765,Accepted,"from collections import deque n = int(input()) a = list(map(int,input().split())) d = deque(a) tmp = [] cnt = 0 while d: v = d.popleft() if len(tmp)>=2: if not (v >= tmp[-1] >= tmp[0] or v <= tmp[-1] <= tmp[0]): tmp = [] cnt += 1 tmp.append(v) print(cnt+1 if tmp else cnt)" p02681,s797939935,Accepted,"S = input() T = input() if S==T[:-1:]: print(""Yes"") else: print(""No"")" p02784,s093944329,Wrong Answer,"import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) H, A = map(int, input().split()) print(-(-H//A))" p04034,s216773150,Accepted,"N, M = map(int, input().split()) c = [1] * N r = [True] + [False] * (N-1) for i in range(M): x, y = map(int, input().split()) if r[x-1] == True: r[y-1] = True if c[x-1] == 1: r[x-1] = False c[x-1] -= 1 c[y-1] += 1 print(sum(r)) " p02933,s255214636,Accepted,"a = int(input()) s = input() if a >= 3200: print(s) else: print('red') " p02701,s647063112,Accepted,"n = int(input()) a = [input() for i in range(n)] l = sorted(a) count = 1 for i in range(n - 1): if l[i] != l[i + 1]: count += 1 print(count)" p03624,s027155799,Wrong Answer,"s = list(map(str,input())) s.sort() cnt = len(list(set(s))) if cnt == 26: print(""None"") else: x = chr(ord(s[0]) + 1) print(x) " p03773,s845814730,Accepted,"A,B = [int(i) for i in input().split()] if A + B >= 24: print(A + B -24) else: print(A+B) " p02693,s341728567,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"" print(ans) " p03555,s621449394,Accepted,"a = str(input()) b = str(input()) if a[0] == b[2] and a[1] == b[1] and a[2] == b[0]: print(""YES"") else: print(""NO"") " p02705,s377195840,Accepted,"import math r = int(input()) print(2*math.pi*r)" p02546,s549933991,Accepted,"s = input() st = s[-1] if st == ""s"": print(s+""es"") else: print(s+""s"")" p02847,s284170155,Wrong Answer,"s = input() ss = [""SUN"",""MON"",""TUE"",""WED"",""THU"",""FRI"",""SAT"",""SUN"",""MON"",""TUE"",""WED"",""THU"",""FRI"",""SAT""] print(ss[ss.index(s) + 1])" p02882,s651848438,Wrong Answer,"a,b,x=list(map(int,input().split())) import math import sys if a*a*b==x: print(90.0000000000) sys.exit() if a*a*b/2<=x: kakudo=a*a*a/2/(a*a*b-x) print(90-math.degrees(math.atan(kakudo))) else: kakudo=2*x/(a*b*b) print(90-math.degrees(math.atan(kakudo))) " p02724,s266329983,Accepted,"X = int(input()) ans = (X // 500) * 1000 + ((X % 500) // 5) * 5 print(ans)" p02793,s573768157,Wrong Answer,"import numpy as np from fractions import gcd N=int(input()) A=list(map(int, input().split())) A=np.array(A) mod=10**9+7 def lcm(a,b): return a//gcd(a,b)*b LCM=1 for x in A: LCM=lcm(LCM,x) #print(LCM) print(int((LCM//A).sum())%mod)" p03407,s894348729,Accepted,"A,B,C=list(map(int, input().split())) if A+B>=C: print('Yes') else: print('No')" p03475,s414292357,Accepted,"import math N = int(input()) csf = [list(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 = math.ceil(t/csf[j][2])*csf[j][2]+csf[j][0] else: t = csf[j][1] + csf[j][0] print(t) print(0)" p02835,s347078880,Wrong Answer,"a,b,c = map(int,input().split()) if a+b+c > 21: print ('burst') else: print ('win')" p02595,s592891024,Wrong Answer,"import math n, d = input().split() count = 0 for idx in range(int(n)): x, y = input().split() x, y = int(x), int(y) if math.sqrt(math.pow(int(x), 2) + math.pow(int(x), 2)) < (int(d) + 1): count += 1 print(count)" p04031,s132859747,Accepted,"import numpy as np N = int(input()) a = np.array(list(map(int, input().split()))) if (a/a[0]).sum() == len(a): total = 0 total = 10**9 for i in range(a.min(), a.max()+1): total_new = ((a - i)**2).sum() if total_new <= total: total = total_new print(total)" p03711,s935535225,Accepted,"x, y = map(int, input().split()) if x in [1, 3, 5, 7, 8, 10, 12] and y in [1, 3, 5, 7, 8, 10, 12]: print('Yes') elif x in [4, 6, 9, 11] and y in [4, 6, 9, 11]: print('Yes') elif x == 2 and y == 2: print('Yes') else: print('No')" p03723,s867170172,Accepted,"A, B, C = map(int, input().split()) if A == B == C and A%2 == 1: print('0') elif A == B == C: print('-1') else: ans = 0 while A%2 == B%2 == C%2 == 0: A, B, C = B//2+C//2, A//2+C//2, A//2+B//2 ans += 1 print(ans) " p02631,s059638760,Wrong Answer,"from sys import stdin input = stdin.readline N = int(input()) a = list(map(int, input().split())) ans = [] for i in range(N - 1): ans.append(a[i] ^ a[i + 1]) ans.append(a[0] ^ a[N - 1]) print(*ans) " p03042,s265065326,Accepted,"s = str(input()) top = int(s[:2]) bottom = int(s[2:]) if 1 <= top <= 12 and 1 <= bottom <= 12: print('AMBIGUOUS') elif top > 12 and bottom > 12: print('NA') elif 1 <= top <= 12: print('MMYY') elif 1 <= bottom <= 12: print('YYMM') else: print('NA')" p03107,s444587371,Accepted,"S=input() print(min(S.count('0'),S.count('1'))*2)" p02646,s156196324,Accepted,"a, v = map(int, input().split()) b, w = map(int, input().split()) t = int(input()) start1 = a end1 = a+v*t start2 = b end2 = b+w*t if(a==b): print(""YES"") exit() if(w>=v): print(""NO"") exit() dist = abs(a-b) rv = abs(v-w) if(dist <= t*rv): print(""YES"") else: print(""NO"")" p02683,s290785746,Wrong Answer,"n,m,x=map(int,input().split()) li=[0]*(m+1) k=[] for i in range(n): c=list(map(int,input().split())) li=li+c a=li.pop(0) k.append(a) if min(li)>=x: print(sum(k)) else: print(""-1"")" p02678,s035155787,Accepted,"from collections import deque n,m = map(int,input().split()) rootlist = [[] for i in range(n)] flag = [False]*n for i in range(m): a,b= map(int,input().split()) rootlist[a-1].append(b) rootlist[b-1].append(a) que = deque([1]) while que: now = que.popleft() for room in rootlist[now-1]: if flag[room-1] == False: flag[room-1] = now que.append(room) print('Yes') for root in flag[1:]: print(root)" p02572,s616988636,Accepted,"def read_ints(): return map(int, input().split(' ')) mod = int(1e9 + 7) def fexp(x, y): ret = 1 while y > 0: if y % 2 == 1: ret = ret * x % mod x = x * x % mod y = y // 2 return ret input() a = list(read_ints()) s = sum(a) ans = 0 for i in a: ans = (ans + i * (s - i)) % mod print(ans * fexp(2, mod - 2) % mod) " p02552,s205169230,Accepted,"from sys import stdin def main(): _in = [_.rstrip() for _ in stdin.readlines()] x = int(_in[0]) # type:int # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv ans = 1 if x==0 else 0 # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ print(ans) if __name__ == ""__main__"": main() " p03785,s761190016,Wrong Answer,"n, c, k = map(int, input().split()); a = [int(input()) for _ in range(n)] a.sort(); t = a[0]+k; m = 1; x = 1 for i in range(n): if a[i] > t or m > 3: t = a[i]+k; m = 1; x += 1 else: m += 1 print(x)" p02790,s686615911,Accepted,"a,b = map(int,input().split()) sa = [str(a)]*b sb = [str(b)]*a ans = min(sa,sb) for i in ans: print(i,end = """")" p03416,s070140448,Accepted,"A,B=map(int, input().split()) cnt=0 for i in range(A,B+1): s=str(i) if s[0]==s[4] and s[1]==s[3]: cnt+=1 print(cnt)" p03495,s406265129,Accepted,"from collections import Counter as CC N, K = map(int, input().split()) A = list(map(int, input().split())) B = CC(A) C = sorted(B.values()) print(sum(C[:max(0, len(C) - K)]))" p02995,s130546425,Accepted,"A,B,C,D = map(int,input().split()) import math E = C*D//math.gcd(C,D) A -= 1 c = B//C - A//C d = B//D - A//D e = B//E - A//E print(B-A-(c+d-e))" p03475,s972767094,Accepted,"N=int(input()) csf=[tuple(map(int,input().split(' '))) for i in range(N-1)] for i in range(N-1): now = 0 for j in csf[i:]: c,s,f= [k for k in j] while now > s: s += f now = s+c print(now) print(0)" p03059,s599666381,Wrong Answer,"a,b,t = map(int,input().split()) print(b * ((t+0.5)//a))" p02922,s871885003,Accepted,"def sum(A, B): n = 0 while True: if n >= (B-1)/(A-1): return n else: n += 1 num = input().split(' ') A = int(num[0]) B = int(num[1]) n = sum(A,B) print(n)" p03438,s744483115,Accepted,"n=int(input()) a=[int(x) for x in input().split()] b=[int(x) for x in input().split()] sa=[a[i]-b[i] for i in range(n)] p=0 m=0 for i in sa: if 0 0: #nをkで割った商が0になるまでcountに1を足し続ける。 count += 1 n //= k print(count)" p02718,s401209080,Accepted,"N,M = map(int,input().split()) A = list(map(int,input().split())) A.sort(reverse = True) if A[M-1]>= sum(A)/(4*M): print(""Yes"") else: print(""No"") " p02916,s353009705,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 i = -1 for j in range(n): if a[j]-1 == i+1: ans += c[i] i = a[j] - 1 ans += b[i] print(ans) " p04019,s058333838,Accepted,"#-*-coding:utf-8-*- import sys input=sys.stdin.readline def main(): #方角が南北/東西でセットであればよさげ s = input().rstrip() s = set(s) WE={'W','E'} NS={'N','S'} all_direction={'N', 'E', 'S', 'W'} if s == set(WE): print(""Yes"") elif s == set(NS): print(""Yes"") elif s == set(all_direction): print(""Yes"") else: print(""No"") if __name__==""__main__"": main()" p02719,s992988547,Wrong Answer,"n,k = map(int,input().split()) if n == n%k: print(n) else: n = n%k print(min(n,abs(n-k)))" p02829,s778944593,Accepted,"import sys ans=[1,2,3] ans.remove(int(sys.stdin.readline())) ans.remove(int(sys.stdin.readline())) print(*ans) " p03796,s474085697,Wrong Answer,"s=int(input()) ans=1 for i in range(1,s): ans*=i print(ans)" p03351,s525514421,Wrong Answer,"a, b, c, d = map(int, input().split()) def check(x, y): return abs(x - y) <= d if (check(a, b) and check(a, c)) or (check(a, b) and check(b, c)): print(""Yes"") else: print(""No"")" p02912,s513131861,Accepted,"# 優先度付キューのimport import heapq n, m = map(int, input().split()) a = [int(i) * -1 for i in input().split()] heapq.heapify(a) for i in range(m): minPrice = heapq.heappop(a) # 負の切捨てが面倒なので正の値にしてからまた負に戻す minPrice = -(abs(minPrice) // 2) heapq.heappush(a, minPrice) sum = 0 for i in a: sum += -i print(sum)" p03274,s869719278,Wrong Answer,"N, K = map(int, input().split()) x = list(map(int, input().split())) ans = 10 ** 8 * 2 for i in range(N - K + 1): if x[i + K - 1] <= 0: tmp = -x[i] elif x[i] >= 0: tmp = x[i + K - 1] else: tmp = -x[i] * 2 + x[i + K - 1] tmp = min(tmp, -x[i] + 2 * x[i + K - 1]) if tmp < ans: ans = tmp print(ans) " p03817,s151010033,Accepted,"#!/usr/bin/env python3 import sys def main(): x = int(input()) ans = 2 * (x // 11) if x % 11 > 6: print(ans + 2) elif x % 11 > 0: print(ans + 1) else: print(ans) if __name__ == '__main__': main() " p02843,s152217379,Wrong Answer,"x = int(input()) dp = [0]*(x + 105 + 1) dp[100] = 1 dp[101] = 1 dp[102] = 1 dp[103] = 1 dp[104] = 1 dp[105] = 1 for i in range(100,x-105+1): for j in range(100,106): dp[i+j] = max(dp[i] , dp[i+j]) print(dp[x]) " p03262,s776734926,Accepted,"#ABC109-C import math from functools import reduce def gcd(*numbers): return reduce(math.gcd,numbers) n,X = map(int,input().split()) x = list(map(int,input().split())) x.append(X) x.sort() kosa = [] for i in range(1,n+1): k = (x[i]-x[i-1]) kosa.append(k) print(gcd(*kosa))" p02880,s456011118,Wrong Answer,"N = int(input()) for i in range(2, 10): if (N%i == 0) & (N/i > 1): print('Yes') exit() print('No')" p02618,s267617995,Wrong Answer,"from random import randint D = int(input()) C = list(map(int, input().split())) S = [list(map(int, input().split())) for _ in range(D)] T = [] for i in range(D): T.append(S[i].index(max(S[i]))) print(*T, sep=""\n"")" p03107,s544067118,Accepted,"def main(): S = input() L = len(S) c = S.count('0') print(min(c, L - c) * 2) if __name__ == '__main__': main() " p02924,s203610638,Wrong Answer,"def main(): n = int(input()) print(int(n * (n - 1) / 2)) main() " p03377,s274187211,Accepted,"A,B,X = map(int,input().split()) cat = X-A if cat >= 0 and cat <= B : print('YES') else: print('NO') " p02768,s596582557,Wrong Answer,"import math n,a,b = map(int,input().split()) if n > 2: aa = math.factorial(n) // (math.factorial(n - a) * math.factorial(a)) bb = math.factorial(n) // (math.factorial(n - b) * math.factorial(b)) c = (n * n - aa - bb - 1) % 1000000007 print(""{}"".format(c)) else: print(""0"")" p02970,s280529223,Accepted,"import math N, D = map(int, input().split()) answer = math.ceil(N / (D * 2 + 1)) print(answer)" p02959,s026984341,Accepted,"n = int(input()) a_input = list(map(int,input().split())) b_input = list(map(int,input().split())) ans=0 for i in range(n): first_attack=0 second_attack=0 first_attack = min(b_input[i],a_input[i]) a_input[i]-=first_attack if first_attack r: r0 = r ans = j print(ans)" p02948,s442409732,Accepted,"import collections import heapq n,m = map(int,raw_input().split(' ')) elems = [map(int, raw_input().split(' ')) for _ in range(n)] elems.sort(key = lambda x:x[0]) heap = [] j = 0 cumul = 0 for i in range(1,m+1): while(j < len(elems) and elems[j][0] <= i): heapq.heappush(heap,-elems[j][1]) j+=1 if heap: cumul -= heapq.heappop(heap) print cumul" p02790,s710126082,Accepted,"a,b = list(map(int,input().split())) s = min(a,b) l = max(a,b) print(str(s)*l)" p03251,s060686908,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: 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 _ = rl() maxx = max(rm()) miny = min(rm()) if maxx >= miny-1: print('War') else: print('No War') " p02779,s927705588,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') exit() print('YES')" p02953,s116973395,Wrong Answer,"from collections import deque N = int(input()) H = deque(map(float, input().split())) prev = H.popleft() if N == 1: print('Yes') exit() for i in range(N-1): cor = H.popleft() if prev - cor < -1: print('No') exit() prev = cor print('Yes') " p03435,s763965514,Wrong Answer,"a = [list(map(int,input().split())) for i in range(3)] if a[0][0]-a[1][0] == a[0][1]-a[1][1] == a[0][2]-a[1][2] and a[1][0]-a[2][0] == a[1][1]-a[2][1] == a[1][2] == a[2][2]: print(""Yes"") else: print(""No"")" p02823,s178506639,Wrong Answer,"N, A, B = map(int, input().split()) if (B - A)%2==0: print((B - A)//2) else: print(min(B-1, N-A))" p02854,s348446998,Accepted,"def main(): import sys from itertools import accumulate n = int(input()) a = list(map(int, sys.stdin.readline().split())) b = list(accumulate(a)) diff = b[-1] total = b[-1] for x in b: diff = min(diff, abs(total - 2 * x)) print(diff) if __name__ == '__main__': main() " p02983,s310565928,Accepted,"l, r = map(int, input().split()) if r - l > 2019: 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)" p02546,s015692196,Wrong Answer,"s = input() if s[-1] == s: s += 'es' else: s += 's' print(s)" p03038,s611535281,Accepted,"n,m = map(int, input().split()) a = list(map(int, input().split())) a.sort() bc = sorted([list(map(int, input().split())) for i in range(m)], key =lambda x:x[1]) bc.reverse() flg = 0 cnt = 0 for i in range(n): if bc[flg][1] >a[i] and flg < m: a[i] = bc[flg][1] cnt +=1 if cnt == bc[flg][0]: flg += 1 cnt = 0 if flg == m: break else: break print(sum(a))" p03698,s450258182,Wrong Answer,"S = input() S_s = set(S) if len(S)==len(S_s): print(""yes"") else: print(""No"")" p02744,s190618334,Wrong Answer,"n=int(input()) s=""abcdefghij"" end=[0,1,2,3,4,5,6,7,8,9] lim=0 res=[0]*n for i in res: print(s[i],end="""") print("""") while res!=end[:n]: res[(n-1)]=res[(n-1)]+1 for i in range(n-1): if res[n-i-1]>(res[n-i-2]+1): res[n-i-1]=0 res[n-i-2]=res[n-i-2]+1 for i in res: print(s[i],end="""") print("""")" p02645,s952236768,Accepted,"s = input() print(s[:3])" p03617,s220825611,Wrong Answer,"q, h, s, d = map(int, input().split()) n = int(input()) a = [8*q, 4*h, 2*s, d] if n % 2 == 0: price = min(a) * n / 2 else: price = min(a) * (n-1) / 2 a.remove(d) price = price + min(a) / 2 print(int(price))" p03061,s984480883,Wrong Answer,"import math N = int(input().rstrip()) A = list(map(int,input().rstrip().split())) l = [A[0]] r = [A[-1]] for i in range(len(A)-1): l.append(math.gcd(A[i+1],l[i])) r.append(math.gcd(A[-(i+2)],r[i])) ans = [] ans.append(r[-2]) for i in range(len(A)-2): ans.append(math.gcd(l[i],r[-i])) ans.append(l[-2]) print(max(*ans))" p03605,s159743145,Wrong Answer,"c = input() if c in ""9"": print(""Yes"") else: print(""No"")" p02601,s702847023,Wrong Answer,"A, B, C = map(int, input().split()) K = int(input()) cnt = 0 while A > B and cnt >= K: B = B*2 cnt += 1 if cnt >= K: print(""No"") else: while B > C and cnt >= K: C = C*2 cnt += 1 if C > B: print(""Yes"") else: print(""No"") " p03161,s773324897,Accepted,"N, K = map(int, input().split()) *h, = map(int, input().split()) dp = [0] * N dp[1] = abs(h[1] - h[0]) for i in range(2, N): c = 10**10 for j in range(i - 1, max(i - K - 1, -1), -1): t = abs(h[j] - h[i]) + dp[j] if t < c: c = t dp[i] = c print(dp[N - 1]) " p02910,s415069579,Accepted,"S = list(input()) odd = ['R', 'U', 'D'] even = ['L', 'U', 'D'] for i, s in enumerate(S): if (i + 1) % 2 == 1 and (s not in odd): print(""No"") exit() if (i + 1) % 2 == 0 and (s not in even): print(""No"") exit() print(""Yes"") " p03030,s324188275,Wrong Answer,"N = int(input()) SP = [] for i in range(N): c, p = input().split() SP.append([i+1, c, p]) SP = sorted(SP, key=lambda x:x[2], reverse=True) SP = sorted(SP, key=lambda x:x[1]) for s in SP: print(s[0])" p03821,s984386769,Accepted,"import sys input = sys.stdin.buffer.readline def main(): N = int(input()) A = [list(map(int,input().split())) for _ in range(N)] p = 0 for i in reversed(range(N)): u,m = A[i] u += p p += (-(-u//m)*m-u) print(p) if __name__ == ""__main__"": main() " p03659,s960573008,Accepted,"n = int(input()) a = list(map(int,input().split())) max_ans = sum(a) ans = abs(a[0]-(max_ans - a[0])) sumu = a[0] for i in range(1,n-1): sumu += a[i] arai = max_ans - sumu kari = abs(sumu-arai) if kari < ans: ans = kari print(ans)" p02602,s309566880,Wrong Answer,"import numpy as np N, K = map(int, input().split()) A = np.array([1] + list(map(int, input().split())), np.int64) PA = np.cumprod(A) ans = [] f = ['No', 'Yes'] B = [] for i in range(K, N + 1): b = PA[i] // PA[i - K] B.append(int(b)) ans = [['No', 'Yes'][B[i - 1] < B[i]] for i in range(1, len(B))] print('\n'.join(ans))" p03331,s271615319,Accepted,"N = int(input()) minval = N for a in range(1,N): sum = 0 A = a B = N-a while A > 0: sum += A%10 A = int(A/10) while B > 0: sum += B%10 B = int(B/10) if minval > sum: minval = sum print(minval)" p03679,s846004992,Accepted,"x,a,b=map(int,input().split()) if b<=a: print(""delicious"") elif (x+a)>=b: print(""safe"") else: print(""dangerous"")" p02572,s911347308,Wrong Answer,"N = int(input()) A = list(map(int, input().split())) MOD = 1000000007 ans = 0 powsum = 0 sumpow = 0 for i in range(N): powsum += A[i] sumpow += (A[i]*A[i]) powsum = (powsum*powsum) ans = ((powsum-sumpow)/2) print(int(ans)%MOD) " p03282,s284723641,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(): s = input() k = I() for i, si in enumerate(s): if si != '1': print(si) sys.exit() if i == k-1: break print(1) if __name__ == '__main__': main()" p02693,s088051774,Wrong Answer,"K = int(input()) a,b = map(int,input().split()) ka = a/K kb = b/K kaama = a%K kbama = b%K if kaama == 0 or kbama == 0: print(""OK"") elif (kb-ka)>=1: print(""OK"") else: print(""NG"")" p02862,s833618615,Accepted,"x,y=map(int,input().split());n=0;mod=10**9+7;ans=0 if not (x+y)%3: n=(x+y)//3;x-=n;y-=n if x>=0 and y>=0: ans=1 for i in range(x):ans=ans*(n-i)*pow(i+1,mod-2,mod)%mod print(ans) " p03455,s914624169,Accepted,"a, b = map(int, input().split()) answer = (a * b) % 2 if answer == 0: print(""Even"") else: print(""Odd"") " p02613,s627424509,Wrong Answer,"N = int(input()) S_list = [input() for i in range(N)] AC = S_list.count('AC') WA = S_list.count('WA') TLE = S_list.count('TLE') RE = S_list.count(""RE"") print('AC × {}'.format(AC)) print('WA × {}'.format(WA)) print('TLE × {}'.format(TLE)) print('RE × {}'.format(RE)) " p02714,s741294001,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 - 2): for j in range(n): if i + j*2 < n: if s[i] != s[i + j]: if s[i] != s[i + j*2]: if s[i + j] != s[i + j*2]: ans -= 1 else: break print(ans)" p03472,s991339284,Accepted,"n, h = map(int, input().split()) a = [] b = [] for _ in range(n): tmp_a, tmp_b = map(int, input().split()) a.append(tmp_a) b.append(tmp_b) v = max(a) b.sort(reverse=True) i = 0 while i < n and b[i] > v and h > 0: h -= b[i] i += 1 if h <= 0: print(i) else: print(i + (h + v - 1) // v)" p02584,s651658485,Accepted,"x, k, d = map(int, input().split()) if abs(x)//d >= k: print(abs(abs(x) - k*d)) else: # a = 1 y = abs(x)//d a = y + 1 # while abs(x) - d*a >=0: # a += 1 if (k-(a-1)) % 2 ==0: print(abs(abs(x) - (a-1)*d)) else: print(abs(abs(x) - a*d)) " p03625,s792077653,Accepted,"N = int(input()) A = list(map(int,input().split())) ans = [] flg = 0 A.sort(reverse=True) for i in range(N-1): if A[i] == A[i+1] and flg == 0: ans.append(A[i]) flg = 1 else: flg = 0 if len(ans) > 1: print(ans[0]*ans[1]) else: print(0)" p03485,s843989673,Accepted,"import math a, b = map(int, input().split()) ave = (a + b) / 2 print(math.ceil(ave))" p02983,s414632124,Accepted,"l,r=map(int,input().split()) a=2018 for i in range (l,min(r,l+2019)): for j in range(i+1,min(r+1,i+2019)): c= ((i%2019)*(j%2019))%2019 if c2::2])" p03799,s067850102,Wrong Answer,"import math N, M = map(int, input().split()) if M >= 2*N: print(N + math.floor((M-2*N)/4)) else: print(N//2)" p03351,s670979924,Wrong Answer,"a,b,c,d = map(int, input().split()) if a - c < d: # a-cの直通 print(""Yes"") elif a - b < d and b - c < d: print(""Yes"") elif a == b == c: print(""Yes"") else: print(""No"") " p03013,s077363299,Accepted,"MOD=10**9+7 n,m=map(int,input().split()) a=[int(input()) for _ in range(m)] dp=[0]*(n+1) dp[0]=1 dp[1]=1 if 1 not in a else 0 a=sorted(list(set(range(2,n+1))-set(a))) for i in a: dp[i]=(dp[i-1]+dp[i-2])%MOD print(dp[n]%MOD)" p02629,s213078049,Accepted,"N = int(input()) ans='' for i in range(1, 99): if N <= 26 ** i: N -= 1 for j in range(i): ans += chr(ord('a') + N % 26) N //= 26 break else: N -= 26 ** i print(ans[::-1]) # reversed" p02829,s924710349,Accepted,"def main(): a = int(input()) b = int(input()) print(6-a-b) if __name__ == '__main__': main()" p03107,s889849409,Accepted,"s = str(input()) a = 0 b = 0 for i in range(len(s)): if s[i] == '0': a += 1 else: b += 1 print(min(a, b)*2) " p03438,s957052394,Wrong Answer,"N = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) p, m, cnt = 0, 0, 0 for i in range(N): if a[i]-b[i] >= 0: p += a[i]-b[i] else: m += b[i]-a[i] cnt += 1 if (2*p<=m) and (cnt<=p): print('Yes') else: print('No')" p03131,s597562201,Accepted,"import sys,math,collections,itertools input = sys.stdin.readline cnt =1 K,A,B=list(map(int,input().split())) if A+2<=B:#交換したほうがいい if A-1 >=K:#最低交換枚数に達しない cnt = 1+K else: cnt = A + (K-(A-1))//2*(B-A)+(K-(A-1))%2 else: cnt = 1+K print(cnt) " p02790,s994160779,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(): a,b=INTM() print(str(min(a,b))*max(a,b)) if __name__ == '__main__': do()" p03472,s241053379,Wrong Answer,"from math import ceil n,h=map(int,input().split()) a=[] b=[] ans=0 for i in range(n): aa,bb=map(int,input().split()) a.append(aa) b.append(bb) b.sort() b.reverse() pin=max(a) for i in range(n): p=b[i] if p<=pin: break ans+=1 h-=p ans+=h-1//pin ans+=1 print(ans)" p02881,s974463006,Accepted,"n = int(input()) a = n-1 for i in range(1,int(n**0.5)+1): if n%i==0: a = i+n//i-2 print(a)" p03136,s387674658,Wrong Answer,"n = int(input()) l = list(map(int,input().split())) m = max(l) ol = list(filter(lambda x: x != m,l)) ans = ""Yes"" if m < sum(ol) else ""No"" print(ans)" p02571,s270196832,Accepted,"S = input() T = input() def diff_count(A,B): diff = 0 for a,b in zip(A,B): if a!=b: diff += 1 return diff ans = len(T) for i in range(len(S) - len(T)+1): temp = S[i:i+len(T)] diff_num = diff_count(T,temp) ans = min(diff_num,ans) print(ans)" p02761,s816236281,Wrong Answer,"n,m = map(int,input().split()) d = dict() for i in range(m): k,v = map(int,input().split()) if k in d: if d[k] !=v: print(-1) exit() else: d[k] = v res = """" for i in (range(1,n+1)): if i not in d: d[i] = 0 res += str(d[i]) res = int(res) if n !=1: if res == 0: print(-1) exit() print(res)" p03680,s219541541,Accepted,"N = int(input()) a = [int(input()) for i in range(N)] push = [False] * N ans = 0 i = 0 while True: ans += 1 if a[i] == 2: break if push[i]: ans = -1 break push[i] = True i = a[i] - 1 print(ans)" p03672,s774219318,Accepted,"S = input() S = S[:-1] def stringcounter(M): if len(M)%2 ==0 and M[:len(M)//2]==M[len(M)//2:]: return True else: return False while True: if stringcounter(S)==True: print(len(S)) break else: S = S[:-1]" p03136,s664007965,Accepted,"n = int(input()) l = list(map(int, input().split())) l_max = max(l) sum_l = sum(l) - l_max if l_max < sum_l: print(""Yes"") else: print(""No"")" p03339,s447782590,Accepted,"from collections import Counter N = int(input()) S = input() C_E = Counter(S[1:]) C_W = Counter() ans = C_E['E'] for i in range(N - 1): C_E[S[i + 1]] -= 1 C_W[S[i]] += 1 ans = min(ans, C_E['E'] + C_W['W']) print(ans) " p03817,s674410054,Accepted,"x = int(input()) ans = (x//11)*2 if(x%11>6): ans += 2 elif(x%11>0): ans += 1 print(ans)" p02577,s516608586,Wrong Answer,"line = input() sum = 0 for i in range(len(line)): sum = sum + int(line[0]) if sum % 9 == 0: print(""yes"") else: print(""no"")" p02607,s493251797,Accepted,"n = int(input()) A = list(map(int,input().split())) ans = 0 for i in range(n): if (i+1) % 2 == 1 and A[i] % 2 == 1: ans += 1 print(ans)" p03455,s478564829,Accepted,"a, b = map(int, input().split("" "")) x = ""Even"" if (a*b)%2 == 0 else ""Odd"" print(x)" p03448,s174447768,Accepted,"A=int(input()) B=int(input()) C=int(input()) X=int(input()) ans=0 for i in range(0,A+1): for j in range(0,B+1): for k in range(0,C+1): if 500*i+100*j+50*k==X: ans+=1 print(ans)" p02571,s218575433,Wrong Answer,"s= input() t = input() ans = 100000000 for i in range(len(s)-len(t)): cnt = 0 for j in range(len(t)): if t[j] !=s[i+j]: cnt += 1 ans = min(ans,cnt) print(ans) " p02747,s814824201,Accepted,"s = input().split('hi') ans = 'Yes' for i in s: if i != '': ans = 'No' break print(ans)" p02882,s698599885,Accepted,"import math a,b,x = map(int,input().split()) if 2*x>=(a**2)*b: theta = math.degrees(math.atan(2*(b-x/a**2)/a)) else: theta = math.degrees(math.atan((a*b**2)/(2*x))) print(theta)" p02973,s975940448,Accepted,"import sys from collections import Counter from collections import deque import heapq import math import fractions import bisect import itertools 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()) l=deque([]) for i in range(n): a=int(input()) ind=bisect.bisect_right(l,a-1) if ind==0: l.appendleft(a) else: l[ind-1]=a print(len(l))" p02795,s671657400,Accepted,"h=int(input()) w=int(input()) n=int(input()) m=max(h,w) print(n//m+(n%m!=0))" p03059,s340203971,Wrong Answer,"a,b,t=map(int,input().split()) cnt=0 for i in range(a,t,a): cnt=cnt+1 print(cnt)" p03146,s059892242,Accepted,"# B - Collatz Problem s = int(input()) a = s S = set([s]) for i in range(2,10**6+1): a = a//2 if a%2==0 else 3*a+1 if a in S: print(i) break S.add(a)" p02627,s863353950,Accepted,"s=input() if 65<=ord(s)<=90: print(""A"") else: print(""a"")" p02818,s699681271,Accepted,"A, B, K = map(int, input().split()) if A >= K: A -= K else: K -= A A = 0 if B >= K: B -= K else: B = 0 print(A,B)" p03699,s782353475,Accepted,"n = int(input()) s = [int(input()) for _ in range(n)] s.sort() ac = sum(s) ans = 0 if ac % 10 != 0: ans = ac else: for i in range(n): tmp = ac - s[i] if tmp % 10 != 0: ans = tmp break print(ans) " p03665,s289187076,Accepted,"import collections import math def combinations_count(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())) H = [i%2 for i in A] B = collections.Counter(H)[1] ans = 0 for i in range(1,B//2+1): ans += combinations_count(B, 2*i) C = (ans+1) * (2**(len(A)-B)) print(C if P == 0 else 2**N - C)" p03633,s666884144,Wrong Answer,"import fractions N = int(input()) T = [] ans = 1 for i in range(0,N): T.append(int(input())) for i in range(0,N): ans = ans * T[i] / fractions.gcd(ans, T[i]) print(int(ans))" p02622,s324859678,Accepted,"S = input() T = input() answer = 0 for i in range(len(S)): if S[i] != T[i]: answer = answer + 1 print(answer)" p02802,s718646835,Accepted,"N, M = map(int,input().split()) myAC = [0 for n in range(N+1)] myWA = [0 for n in range(N+1)] ansAC = 0 ansWA = 0 for m in range(M): a, b = map(str, input().split()) a = int(a) if b == 'WA' and myAC[a] != 1: myWA[a] += 1 if b == 'AC' and myAC[a] != 1: myAC[a] = 1 ansWA += myWA[a] ansAC += 1 #print(myAC) #print(myWA) print(ansAC,ansWA) " p03543,s253123832,Wrong Answer,"n =input() print('Yes' if len(set(n))==2 else 'No')" p02570,s622523878,Accepted,"d,t,s=map(int,input().split()) if d/s<=t: print('Yes') else: print('No') " p02880,s553141426,Accepted,"N = int(input()) for i in range(1,10): if N%i == 0 and N/i <10: a = ""Yes"" break else: a = ""No"" print(a)" p02660,s301976451,Accepted,"ans = 0 N = int(input()) L = [0] * 10**6 ans = 0 for i in range(2,10**6): while N%i == 0: N = N//i L[i] += 1 if N != 1: L[10**6 - 1] = 1 L.sort(reverse=True) for i in range (10**6): if L[i] == 0: break k = 1 while L[i] > 0: L[i] -= k if L[i] >= 0: k += 1 ans += 1 print(ans)" p03592,s917041231,Wrong Answer,"from sys import stdin n,m,k = [int(x) for x in stdin.readline().rstrip().split()] if k > n+m: print(""No"") else: print(""Yes"")" p03067,s582631802,Accepted,"A, B, C = map(int, input().split()) count = 0 if A > B: for i in range (B, A): if i == C: count = 1 elif A < B: for i in range (A, B): if i == C: count = 1 if count == 1: print(""Yes"") else: print(""No"")" p03030,s499946090,Accepted,"n = int(input()) lst = [] for i in range(n): s, p = input().split() lst.append([s, int(p), i+1]) beta = sorted(lst, key=lambda x: x[1], reverse=True) alpha = sorted(beta, key=lambda x: x[0]) for i in range(n): print(alpha[i][2]) " p02802,s216896099,Accepted,"n,m = list(map(int, input().split())) ps = [input().split() for _ in range(m)] acCount = 0 penaltyCount = 0 wa = [0]*n aced = [False]*n for i in ps: ind = int(i[0])-1 if i[1]=='WA' and not aced[ind]: wa[ind] += 1 elif i[1]=='AC' and not aced[ind]: aced[ind] = True acCount += 1 penaltyCount += wa[ind] print(acCount, penaltyCount)" p03379,s921442011,Wrong Answer,"n = int(input()) x = list(map(int, input().split())) xsort = sorted(x) for i in range(n): if xsort[n//2] > x[i]: print(xsort[2//n]) else: print(xsort[n//2-1])" p04030,s884288292,Accepted,"s = input() ans = [] for l in s: if l == '0': ans.append('0') elif l == '1': ans.append('1') else: if ans: ans.pop() print(''.join(ans))" p03293,s642708990,Accepted,"S=input() T=input() for i in range(len(S)): S=S[-1]+S[:-1] if T==S: print('Yes') exit() print('No')" p03013,s141013507,Accepted,"MOD = 10 ** 9 + 7 N, M = map(int, input().split()) dp = [[0, 0] for _ in range(N + 1)] dp[0][0] = 1 for _ in range(M): x = int(input()) dp[x][1] = 1 for i in range(1, N + 1): if dp[i][1] == 0: dp[i][0] = (dp[i - 2][0] + dp[i - 1][0]) % MOD print(dp[N][0])" p02742,s214571133,Accepted,"h, w = [int(s) for s in input().split()] if h == 1 or w == 1: print(1) exit() rh, rw = h%2, w%2 eh, ew = h - rh, w- rw result = int( eh * ew //2) if rh == 1: result += ew //2 if rw == 1: result += eh //2 if rh == rw == 1: result += 1 print(result) " p02833,s821620331,Accepted,"def main(): N = int(input()) if N % 2 != 0: print(0) exit() ans = 0 i = 1 while 2*5**i<=N: ans += N//(2*5**i) i += 1 print(ans) main()" p03720,s632122412,Accepted,"N,M=map(int,input().split()) ans=[[0]*N for _ in range(N)] for i in range(M): a,b=map(int,input().split()) ans[a-1][b-1]+=1 ans[b-1][a-1]+=1 for i in range(N): print(sum(ans[i]))" p02641,s782009022,Accepted,"x,n = map(int,input().split()) p = set([int(x) for x in input().split()]) mn = 10**10 ans_li = [] for i in range(-200,201): if i not in p and abs(x - i) <= mn: ans_li.append(i) mn = abs(x - i) for aa in ans_li: if abs(aa - x) == mn: print(aa) break " p03557,s986418538,Wrong Answer,"import numpy as np N = int(raw_input()) A = map(int, raw_input().split()) B = map(int, raw_input().split()) C = map(int, raw_input().split()) A = sorted(A) B = sorted(B) C = sorted(C) num_A_on_B = 0 num_C_under_B = 0 ans = 0 for y in B: x = 0 z = 0 while x < N and A[x] <= y: x = x + 1 while z < N and A[z] >= y: z = z + 1 ans = ans + x*(N-z) print ans " p03556,s408438133,Wrong Answer,"N=int(input()) ans=0 for i in range(N): if i*i<=N: ans=i else: break print(ans**2) " p02578,s475421684,Accepted,"n = int(input()) p = list(map(int, input().split())) a = 0 for i in range(1,n): if p[i-1] > p[i]: a = a + p[i-1] - p[i] p[i] = p[i-1] else: p[i] = p[i] a = a print(a)" p03289,s394821659,Accepted,"import re S=input() good = True if S[0] != 'A': print('WA') exit() n = 0 iC = -1 for i in range(2,len(S)-1): if S[i] == 'C': n += 1 iC = i if n != 1: print('WA') exit() for i in range(1,len(S)): if i == iC: continue if not re.match(r'[a-z]', S[i]): print('WA') exit() print('AC') " p02860,s946128668,Accepted,"n=int(input()) s=input() m=int(n/2) if n%2==0 and s[:m]==s[m:]: print(""Yes"") else: print(""No"") " p02684,s457677810,Accepted,"n,k = map(int, input().split()) a = [0] + list(map(int, input().split())) now = 1 check = [-1]*(n+1) for i in range(k): if check[now] == -1: check[now] = i now = a[now] else: loop = i - check[now] afterloop = (k-(i-loop))%loop print(check.index((i-loop) + afterloop)) exit() print(now) " p02597,s234446232,Accepted,"n = int(input()) c = list(input()) d = sorted(c) count = 0 for i in range(n): if c[i] == 'W' and d[i] == 'R': count+=1 print(count) " p02664,s184490165,Wrong Answer,"T = input() ans = """" for i in range(len(T)): if(T[i] == ""?""): if(i != 0 and T[i-1] == ""P""): ans += ""D"" elif(i != len(T)-1 and T[i+1] == ""?""): ans += ""P"" else: ans += ""D"" else: ans += T[i] print(ans)" p03161,s941180133,Wrong Answer,"def main(): n, k = map(int, input().split()) h = list(map(int, input().split())) dp = [float('inf') for _ in range(n)] dp[0] = 0 dp[1] = abs(h[0]-h[1]) for i in range(1, n): for j in range(1, min(k+1, n-i)): num = dp[i]+abs(h[i]-h[i+j]) if num < dp[i+j]: dp[i+j] = num print(dp[-1]) main() " p02963,s529985206,Wrong Answer,"s = int(input()) x = [0,10**9] y = [0,1] tmp = 10**9 x3 = tmp - (s % tmp) y3 = (s + x3) // tmp print(0,0,10**9,1,x3,y3) " p03206,s043348179,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"") " p04005,s196597913,Wrong Answer,"A,B,C=map(int,input().split()) if A%2==0 or B%2==0 or C%2==0: ans = 0 else: ans = int(1/max(A,B,C)*A*B*C) print(ans)" p02847,s323883566,Wrong Answer,"S = 'SAT' 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) else: print(1)" p03627,s777829808,Wrong Answer,"from collections import Counter N = int(input()) A = list(map(int,input().split())) teihen,takasa = 0,0 check = 0 A = Counter(A) for i,j in A.items(): if j >= 2: if check == 0: teihen = i check = 1 else: takasa = i check = 0 elif j >= 4: teihen,takasa = i,i print(teihen * takasa)" p02880,s341637065,Wrong Answer,"n = int(input()) num = [1, 2, 3, 4, 5, 6, 7, 8, 9] ans = 0 for i in range(9): for j in range(9): if n//(num[i]) == num[j]: ans = 1 if ans == 1: print(""Yes"") else: print(""No"")" p03495,s454212613,Wrong Answer,"import collections def main(): N, K = map(int, input().split()) A =list(map(int, input().split())) LA = list(collections.Counter(A).values()) Ans = N-sum(LA[0:K]) if Ans > 0: print(Ans) else: print(0) main()" p03557,s412101816,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(reverse=True) C.sort() #2分探索を用いる ans = 0 for i in B: a = bisect.bisect_left(A,i) b = N - bisect.bisect_right(C,i) ans += a*b print(ans)" p03071,s980741847,Accepted,"# -*- coding: utf-8 -*- A,B = list(map(int, input().rstrip().split())) #----- cnt=0 for i in range(2): if A>=B: cnt += A A -= 1 else: cnt += B B -= 1 print( cnt ) " p02708,s265310466,Accepted,"import sys input = sys.stdin.readline P = 10 ** 9 + 7 def main(): N, K = map(int, input().split()) ans = 0 for k in range(K, N + 2): a = k * (k - 1) // 2 b = k * (2 * N - (k - 1)) // 2 ans = (ans + (b - a + 1)) % P print(ans) if __name__ == ""__main__"": main() " p02918,s424637688,Wrong Answer,"n,k = map(int,input().split()) s = list(input()) c = 0 a = 0 for i in range(n-1): if s[i] == s[i+1]: c += 1 i = 0 if s[-1] == 'R': s.append('L') else: s.append('R') print(s) while a < k and len(s) >= 2: if s[0] != s[1] and s[-1] != s[-2] and s[0] == s[-1]: c += 2 a += 1 s = s[1:] i += 1 print(c)" p03493,s825203965,Accepted,"s = list(input()) print(s.count('1'))" p02744,s368602637,Wrong Answer,"import itertools n = int(input()) cl = [""a"", ""b"", ""c"", ""d"", ""e"", ""f"", ""g"", ""h"", ""i"", ""j"", ] rl = itertools.product(cl[:2], repeat=n - 1) if not rl: print(""a"") else: for r in rl: print("""".join([""a""] + list(r))) " p03309,s094382832,Wrong Answer,"import math n = int(input()) lst = list(map(int, input().split())) res = 0 for i in range(n): res += lst[i] - i res = res/n p = math.floor(res) q = math.ceil(res) o = p - 1 r = q + 1 os = ps = qs = rs = 0 for i in range(n): ps += abs(lst[i] - (p+i)) qs += abs(lst[i] - (q+i)) rs += abs(lst[i] - (r+i)) os += abs(lst[i] - (o+i)) print(min(min(ps, qs), min(os, rs)))" p03548,s163009988,Accepted,"x, y, z = map(int, input().split()) i = 1 while True: if (y + z) * i + z > x: print(i-1) break i += 1 " p02629,s118137614,Accepted,"N = int(input()) al = 26 i = 1 while N > al**i: N -= al**(i) i += 1 ans = '' a = ord('a') while i > 0: ans += chr(a + (N-1) // al**(i-1)) N = (N-1) % al**(i-1) + 1 i -= 1 print(ans)" p03633,s423947754,Wrong Answer,"from functools import reduce from fractions import gcd N = int(input()) T = [] for i in range(N): T.append(int(input())) x = reduce(gcd,T) sum=x for i in set(T): sum*=(i//x) print(sum)" p03073,s996917138,Accepted,"s=input() g=0 for i in range(len(s)): if i%2==0: if s[i]=='0': g+=1 else: if s[i]=='1': g+=1 c=0 for i in range(len(s)): if i%2==0: if s[i]=='1': c+=1 else: if s[i]=='0': c+=1 if g>c: print(c) else: print(g) " p02843,s555185775,Wrong Answer,"X = int(input()) l = [0,1,2,3,4,5] a = X // 100 b = X % 100 if a == 0: print('1') elif ((b // a) in l) and ((b % a) in l): print('1') else: print('0')" p02796,s122826750,Accepted,"import sys N = int(input()) a = sorted([(x + l, x - l) for x, l in (map(int, l.split()) for l in sys.stdin)]) last = a[0][0] ans = 1 for r, l in a[1:]: if last <= l: ans += 1 last = r print(ans)" p02993,s447300012,Accepted,"a,b,c,d=input() print(""Good"" if a!=b and b!=c and c!=d else ""Bad"")" p03062,s973165678,Wrong Answer,"N = int(input()) A = list(map(int, input().split())) if abs(A[0]) < abs(A[-1]): A = A[::-1] B = list(map(abs, A)) B.sort() C = [x for x in A if x < 0] n = len(C) if (N % 2 == 0 and n % 2 == 1) or (N % 2 == 1 and n % 2 == 0): print(sum(B)) else: print(sum(B) - 2*B[0]) " p03557,s136077023,Accepted,"import bisect N= int(input()) a_list = list(map(int,input().split())) b_list = list(map(int,input().split())) c_list = list(map(int,input().split())) c_num = len(c_list) a_list.sort() c_list.sort() ans = 0 for b in b_list: a_point = bisect.bisect_left(a_list,b) c_point = bisect.bisect(c_list,b) ans+= a_point*(c_num-c_point) print(ans) " p02957,s269629068,Accepted,"a,b=map(int,input().split()) c=abs(a+b) if c%2==0: print(c//2) else: print(""IMPOSSIBLE"")" p03107,s231261993,Accepted,"from collections import deque S=input() stack=deque() cnt=0 for s in S: if not stack: stack.append(s) elif s!=stack[-1]: stack.pop() cnt+=2 else: stack.append(s) print(cnt) " p02657,s390755574,Accepted,"# 169A # A * B を整数として出力せよ # 1.入力をプログラムで扱えるように受け取ること a, b = map(int, input().split()) # print(a, b) # 2.受け取った入力値を使って適切に処理する(計算)こと answer = a * b # 3.計算した結果を出力すること print(answer) " p03994,s675635899,Wrong Answer,"s = str(input()) k = int(input()) n = len(s) l = [0]*n for i in range(n): l[i] = ord('z') -ord(s[i]) + 1 #print(l) ans = list(s) i = 0 while k > 0: if i > n-1: break if l[i] <= k: ans[i] = 'a' k -= l[i] i += 1 if k > 0: ans[-1] = chr((k + ord(ans[-1])-ord('a'))%26+97) #print(ans) print(''.join(ans)) " p03711,s861742703,Accepted,"def func(a): if a in (1,3,5,7,8,10,12): return ""a"" elif a in (4,6,9,11): return ""b"" else: return ""c"" x, y = [int(i) for i in input().split()] x_group = func(x) y_group = func(y) if x_group == y_group: print(""Yes"") else: print(""No"")" p03861,s348719273,Wrong Answer,"a,b,x=map(int,input().split()) k=b-a+1 if a%x!=0 and a!=0: k2=x-(a%x) elif a%x==0 and a!=0: k2=0 else: k2=x k-=k2 if k<=0: print(0) else: print(k//x+1) " p03944,s481853322,Wrong Answer,"W, H, N = map(int, input().split()) border = [0,W,0,H] for i in range(N): x, y, a = map(int, input().split()) if a == 1: border[a-1] = max(border[a-1], x) elif a == 2: border[a-1] = min(border[a-1], x) elif a == 3: border[a-1] = max(border[a-1], y) elif a== 4: border[a-1] = min(border[a-1], y) print(max((border[1] - border[0]) * (border[3] - border[2]), 0))" p03448,s698557228,Wrong Answer,"A = int(input()) B = int(input()) C = int(input()) X = int(input()) count = 0 ans = [] ans.append(min(X//500,A)) ans.append(min(X//100,B)) ans.append(min(X//50,C)) for i in range(ans[0]): for j in range(ans[1]): for k in range(ans[2]): p = i * 500 + j * 100 + k * 50 if p == X: count += 1 print(count)" p03605,s081059260,Accepted,"N = input() if N[0] == '9' or N[1] == '9': print('Yes') else: print('No')" p04012,s536215150,Accepted,"w = input() ans = 'No' for wd in w: if w.count(wd) % 2 != 0: break else: ans = 'Yes' print(ans)" p03852,s587221578,Accepted,"c = input() l = [""a"", ""e"", ""i"", ""o"", ""u""] if (c in l): print(""vowel"") else: print(""consonant"") " p02606,s028370089,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)''' a,b,c=map(int, input().split()) if a%c==0: print(b//c-a//c+1) else: print(b//c-a//c)" p02602,s833418391,Wrong Answer,"N,K=input().split() N=int(N) K=int(K) scores=input().split() scores=[int(i) for i in scores] count=0 boad=0 for gakki in range(K,N+1): score=1 for i in scores[gakki-K:gakki]: score*=i if count==0: count+=1 boad=score continue elif score>boad: print('Yes') continue else: print('No') boad=score " p04033,s288169395,Wrong Answer,"a,b=map(int,input().split()) cnt=0 if (a>0 and b<0) or (a<0 and b>0): ans=""Zero"" elif a==0 or b==0: ans=""Zero"" elif a>0 and b>0: ans=""Positive"" elif a<0 and b<0: a,b=a*-1,b*-1 print(a,b) for i in range(b,a+1): cnt+=1 if cnt%2==0: ans=""Positive"" else: ans=""Negative"" print(ans) " p03073,s382782441,Wrong Answer,"def main(): s = input() mudancas=0; s=list(s) if(len(s)==1): print(""0"") return; for i in range(1, len(s)-1): if(s[i]==s[i-1]): mudancas+=1 if(s[i]=='0'): s[i]='1' else: s[i]='0' print(mudancas) main() " p02947,s795005213,Accepted,"N = int(input()) S = [input() for _ in range(N)] from collections import Counter L = [''.join(sorted(list(s))) for s in S] C = Counter(L) ans = 0 for i in C.values(): ans += i*(i-1)//2 print(ans)" p03817,s553886176,Accepted,"x = int(input()) print(x // 11 * 2 + (x % 11 + 5) // 6)" p04045,s274321094,Accepted,"n,k = map(int,input().split()) d = input().replace("" "","""") for i in range(n,10**9): check = True for j in str(i): if j in d: check = False break if check: print(i) break" p02714,s020236379,Accepted,"n = int(input()) s = input() cnt = 0 for i in range(n): for j in range(i + 1, n): k = 2*j - i if j < k < n and len({s[i], s[j], s[k]}) == 3: cnt += 1 print(s.count('R') * s.count('G') * s.count('B') - cnt)" p04011,s957828492,Accepted,"n, k, x, y = map(int, [input() for i in range(4)]) if n <= k: print(x*n) else: print(x*k + y*(n-k))" p02910,s119265147,Wrong Answer,"S = input() even = [v for i, v in enumerate(S) if i % 2 == 0] odd = [v for i, v in enumerate(S) if i % 2 == 1] count = even.count(""R"") + odd.count(""L"") print(""Yes"" if count == 0 else ""No"")" p02675,s227709643,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')" p02917,s269979643,Accepted,"n = int(input()) B = list(map(int, input().split())) ans = B[0] + B[n-2] for i in range(0, n-2): ans += min(B[i], B[i+1]) print(ans)" p02910,s216980166,Accepted,"S = list(map(str, input())) count1 = 0 count2 = 1 while count1+1 <= len(S): if S[count1] == 'L': print('No') break else: count1 +=2 else: while count2 < len(S): if S[count2] == 'R': print('No') break else: count2 += 2 else: print('Yes')" p03011,s347896405,Accepted,"def LI(): return list(map(int, input().split())) P, Q, R = LI() ans = P+Q+R-max(P, Q, R) print(ans) " p04012,s588005465,Accepted,"import sys import string w = input() a_z = string.ascii_letters for i in a_z: if w.count(i) & 1: print('No') sys.exit() print('Yes')" p02719,s754712195,Wrong Answer,"N,K = map(int,input().split()) n = abs(N-K) if(N == K): print(0) if(K>N): if(n=a[i] and i!=N-1: Q+=1 x=x-a[i] elif i==N-1 and x==a[i]: Q+=1 print(Q)" p03548,s863052763,Accepted,"X,Y,Z=map(int,input().split()) W=Y+Z cnt=0 X-=Z*2 while X>W: X-=W cnt+=1 if X>=Y: cnt+=1 print(cnt) " p02718,s653128375,Accepted,"import numpy as np N, M = list(map(int, input().split())) A = list(map(int, input().split())) total_vote = np.sum(A) threshold = total_vote/(4*M) A.sort(reverse = True) if A[M-1] >= threshold: print('Yes') else: print('No')" p02629,s803956590,Accepted,"def main(): #N,K=map(int,input().split()) #p=list(map(int,input().split())) N=int(input()) ans="""" while N!=0: tmp=N%26 N//=26 if tmp==0: ans=""z""+ans N-=1 else: ans=chr(tmp-1+ord(""a""))+ans print(ans) main()" p03815,s212528374,Accepted,"x = int(input()) y = x // 11 z = x % 11 ans = 0 ans += y * 2 if z > 6: ans += 2 elif z > 0: ans += 1 print(ans)" p03493,s910588202,Wrong Answer,"a=int(input()) sum=0 if a//100==1: sum+=1 if a//10==(1 or 11): sum+=1 if a%2==1: sum+=1 print(sum)" p04031,s872242609,Accepted,"n = int(input()) l = list(map(int,input().split("" ""))) cost_list = [] for i in range (-100,101): cost = 0 for j in l: cost += (j - i)**2 cost_list.append(cost) cost_list.sort() print(cost_list[0])" p02993,s006973164,Accepted,"def pas(): s = input() for i in range(len(s)-1): if s[i] == s[i+1] and i !=len(s)-1: return 'Bad' return 'Good' print(pas())" p02747,s948079654,Accepted,"s = input() ans = [""hi"", ""hihi"", ""hihihi"", ""hihihihi"", ""hihihihihi""] if s in ans: print(""Yes"") else: print(""No"")" p03077,s842715324,Accepted,"import math n = int(input()) l = [int(input()) for i in range(5)] print(math.ceil(n / min(l))+4)" p03785,s430173056,Accepted,"N,C,K = map(int,input().split()) T = sorted([int(input()) for _ in range(N)]) bus = 1 tmp_bus = 1 bus_time = T[0] + K for t in T[1:]: if tmp_bus < C and t <= bus_time: tmp_bus += 1 else: bus += 1 bus_time = t + K tmp_bus = 1 print(bus)" p02681,s007767740,Accepted,"s = input() t = input() if s == t[:-1]: print(""Yes"") else: print(""No"") " p02973,s347516725,Wrong Answer,"n = int(input()) a = [] for i in range(n): p = int(input()) a.append(p) q = 0 ans = 0 a.reverse() s = a[0] for i in range(n-1): if a[i] <= a[i+1]: q += 1 else: ans = max(ans,q) q = 0 ans = max(ans,q) print(ans+1)" p02787,s133579654,Accepted,"def chmin(dp, i, *x): dp[i] = min(dp[i], *x) INF = float(""inf"") # dp[i] := min 消耗する魔力 to H -= i h, n = map(int, input().split()) dp = [0] + [INF]*h for _ in [None]*n: a, b = map(int, input().split()) for j in range(h + 1): chmin(dp, min(j + a, h), dp[j] + b) print(dp[h])" p03998,s131015380,Accepted,"a=list(input()) b=list(input()) c=list(input()) d=a.pop(0) while True: if d==""a"" and a!=[]: d=a.pop(0) elif d==""a"" and a==[]: flag=""A"" break if d==""b"" and b!=[]: d=b.pop(0) elif d==""b"" and b==[]: flag=""B"" break if d==""c"" and c!=[]: d=c.pop(0) elif d==""c"" and c==[]: flag=""C"" break print(flag) " p02547,s930115992,Accepted,"N=int(input()) d=[0]*N;D=[0]*N s=0 for i in range(N): d[i],D[i]=map(int,input().split()) if d[i]==D[i]:s+=1 else:s=0 if s==3: print('Yes') exit() print('No')" p02767,s326639781,Wrong Answer,"import sys import math input = sys.stdin.readline ins = lambda: input().rstrip() ini = lambda: int(input().rstrip()) inm = lambda: map(int, input().split()) inl = lambda: list(map(int, input().split())) n = ini() a = inl() x = sum(a) // n ans = 0 for i in a: ans += (i - x) * (i - x) print(ans)" p03797,s570035839,Accepted,"n,m=map(int,input().split()) if 2*n>=m: print(m//2) else: x=(m-2*n)//4 ans=min(n+x,(m-2*x)//2) x+=1 anser=min(n+x,(m-2*x)//2) print(max(ans,anser)) " p03471,s068478336,Accepted,"N, Y = [int(x) for x in input().split()] for x in range(Y // 10000 + 1): # 1万円札の枚数 for y in range((Y - 10000 * x) // 5000 + 1): # 5千円札の枚数 if 10000 * x + 5000 * y + 1000 * (N - x - y) == Y: print(x, y, N - x - y) break else: continue break else: print(-1, -1, -1)" p03986,s517414036,Accepted,"import sys input = sys.stdin.readline S = input().rstrip() s_cnt =0 t_cnt =0 for s in S: if s == 'S': s_cnt += 1 else: if s_cnt >0: s_cnt -= 1 else: t_cnt += 1 print(t_cnt + s_cnt) " p02640,s301906502,Accepted,"x, y = map(int, input().split()) #3, 8 ans = ""No"" for i in range(1, x+1): if (4*i + 2*(x-i)) == y: ans = ""Yes"" break if (2*(x)) == y: ans = ""Yes"" print(ans)" p03657,s010913438,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,s092830970,Accepted,"H, N = map(int, input().split()) A = list(map(int, input().split())) ans = 0 for i in A: ans += i if ans >= H: print(""Yes"") else: print(""No"")" p03696,s837744422,Accepted,"n = int(input()) s = input() cnt, L = 0, 0 for i in range(len(s)): if s[i] == '(': cnt += 1 else: cnt -= 1 if cnt < 0: L = min(L, cnt) ans = '('*abs(L) + s R = ans.count('(') - ans.count(')') ans += ')'*R print(ans) " p03076,s064288680,Wrong Answer,"# input cook_time = [] append = cook_time.append for i in range(5): append(int(input())) # check cook_time.sort(key=lambda x: round(x, -1) - x) res = 0 for c in cook_time: if res % 10 != 0: res = round(res, -1) res += c print(res) " p03359,s467632200,Accepted,"a, b = map(int, input().split()) if a <= b: print(a) else: print(a-1)" p03994,s542187455,Accepted,"s = input() K = int(input()) for i,c in enumerate(s): x = (ord('z')-ord(c)+1)%26 if x <= K: s = s[:i]+'a'+s[i+1:] K -= x print(s[:-1]+chr((ord(s[-1])-ord('a')+K)%26+ord('a')))" p02660,s056394445,Accepted,"import math l = [] n = int(input()) for i in range(2,int(math.sqrt(n))+1): flg = 0 while n % i == 0: if flg == 0: l.append(1) flg = 1 else: l[-1] += 1 n = n//i if n != 1: l.append(1) ans = 0 for i in range(len(l)): c = 1 while l[i] - c >= 0: l[i] -= c c += 1 ans += 1 print(ans) " p02615,s861515883,Wrong Answer,"l = int(input()) a = map(int, input().split()) a = sorted(a, reverse=True) #print(a) if l%2==0: print(a[0] + sum(a[1:(l-2)//2])*2 + a[(l-2)//2]) else: print(a[0] + sum(a[1:(l+1)//2])*2)" p02957,s157197111,Accepted,"a,b=map(int,input().split()) if (a+b)%2==0: print((a+b)//2) else: print(""IMPOSSIBLE"") " p02785,s078595695,Accepted,"n,k = map(int,input().split()) h = list(map(int,input().split())) h.sort(reverse=True) h = h[k:] print(sum(h))" p03799,s568860824,Accepted,"N, M = map(int, input().split()) if 2 * N >= M: print(M // 2) else: d = M - 2 * N d //= 4 print(N + d) " p02843,s206825158,Accepted,"x = int(input()) print(0) if (x - (x // 100)*100) / 5 > x // 100 else print(1)" p03456,s999241158,Accepted,"a,b = input().split() c = int(a+b) if c==int(c**.5)**2: print(""Yes"") else: print(""No"")" p02602,s787632438,Accepted,"N,K = map(int, input().split()) A_list = list(map(int, input().split())) for i in range(N-K): #print(i,K+i) #print(A_list[i],A_list[K+i]) if(A_list[i]9 or m>9: print(-1) else: print(n*m)" p02647,s110838242,Accepted,"n, k = map(int, input().split()) A = [*map(int, input().split())] for i in range(k): B = [0]*(n+1) for j in range(n): l = max(0, j - A[j]) r = min(n, j + A[j] + 1) B[l] += 1; B[r] -= 1 for j in range(n-1): B[j+1] += B[j] B.pop() if A == B: break A = B print(*A, sep=' ') " p02726,s390196113,Accepted,"N, X, Y= map(int, input().split()) K = [0]*(N-1) for i in range(1,N): for j in range(i+1, N+1): idx = min([j-i, abs(X-i)+ abs(j-Y)+1, abs(Y-i) + 1 + abs(X-j)])-1 K[idx] +=1 for value in K: print(value) " p02597,s140464054,Accepted,"n=int(input()) c=input() a=c.count('R') print(c[:a].count('W'))" p02675,s608737419,Accepted,"hon = ['2','4','5','7','9'] pon = ['0','1','6','8'] n = input() if n[-1] in hon: print('hon') elif n[-1] in pon: print('pon') else: print('bon')" p04029,s251031326,Wrong Answer,"N = int(input()) answer = (N + 1) * N / 2 print(answer)" p02658,s332991168,Accepted,"N = int(input()) A = list(map(int,input().split())) ret = 1 if 0 in A: print(0) exit() for i in A: ret *= i if ret > 10**18: ret = -1 break print(ret) " p02717,s955873216,Accepted,"a,b,c=(int(x) for x in input().split()) print(str(c)+"" ""+str(a)+"" ""+str(b)) " p02916,s983818176,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 n in range(1,N): if A[n]-A[n-1]==1: ans+=C[A[n-1]-1] print(ans) " p02772,s826173994,Accepted,"def please(n , a): for i in range(n): if a[i] % 2 == 0: if a[i] % 3 != 0 and a[i] % 5 != 0: return ""DENIED"" return ""APPROVED"" def main(): n = int(input()) a = list(map(int,input().split())) print(please(n , a)) if __name__ == '__main__': main()" p02835,s223740758,Accepted,"a, b, c = map(int, input().split()) if a + b + c >= 22: print(""bust"") else: print(""win"")" p02732,s168419880,Accepted,"n = int(input()) a = [int(i) for i in input().split()] ball_count = [0] * (n + 1) for i in a: ball_count[i] += 1 def nCr(i): if i<=1: return 0 else: return i*(i-1)//2 def get_total(ball_count): ans = 0 for i in ball_count: ans += nCr(i) return ans total = get_total(ball_count) for i in range(1, n + 1): num = ball_count[a[i - 1]] ans = total - nCr(num) + nCr(num-1) print(ans) " p02677,s035764672,Wrong Answer,"import math A,B,H,M = map(int, input().split()) sita = abs(0.5 * M - 30 * H) ans = (A**2 + B**2 - 2 * A * B * math.cos(math.radians(sita)))** 0.5 print(ans) " p03076,s450414130,Wrong Answer,"a = int(input()) b = int(input()) c = int(input()) d = int(input()) e = int(input()) l = [a % 10, b % 10, c % 10, d % 10, e % 10] print((a // 10) * 10 + (b // 10) * 10 + (c // 10) * 10 + (d // 10) * 10 + (d // 10) * 10 - max(l))" p02640,s889817881,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 : print(""Yes"") elif z==(y-2): print(""Yes"") else: print(""No"")" p03625,s079620105,Accepted,"N=int(input()) A=list(map(int,input().split())) A.sort() i=N-1 ans=1 count=0 while i>=1: if A[i-1]==A[i]: ans*=A[i] i-=2 count+=1 else: i-=1 if count==2: print(ans) break else: print(0) " p02835,s987326961,Accepted,"A,B,C=map(int,input().split()) if A+B+C>=22:print(""bust"") else:print(""win"")" p02615,s476561563,Accepted,"def solve(): N = int(input()) A = list(map(int,input().split())) A.sort(reverse=True) ans = 0 for i in range(N-1): if i == 0: ans += A[0] else: if i % 2 == 0: ans += A[i//2] else: ans += A[i//2 + 1] print(ans) if __name__ == '__main__': solve()" p02691,s867135259,Wrong Answer,"n = int(input()) a = list(map(int, input().split())) ans = 0 for i in range(n): for j in range(i+a[i]+1,n): print(i,j) if a[i]+a[j] == j-i: ans += 1 print(ans)" p02786,s553617580,Wrong Answer,"h = int(input()) res = 0 i = 1 while h > 0: h = h//2 res = res + i i*2 print(res)" p03206,s499000175,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')" p02747,s776699334,Wrong Answer,"#!/usr/bin/env python3 S = input() if 'hi' in S:print('Yes') else: print('No') " p03071,s171143793,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)" p03611,s362038759,Accepted,"N = int(input()) numbers = [0] * (10 ** 6) seq = list(map(int, input().split())) for i in seq: numbers[i - 1] += 1 numbers[i] += 1 numbers[i + 1] += 1 print(max(numbers)) " p04029,s002455828,Accepted,"N = int(input()) print((N*(N+1))//2)" p02663,s262935874,Wrong Answer,"h1, m1, h2, m2, k = map(int, input().split()) hm1 = h1 + m1/60 hm2 = h2 + m2/60 diff = hm2 - hm1 if diff > k/60: ans = int((diff - k/60)*60) else: ans = 0 print(ans)" p02622,s185640815,Accepted,"S = [input() for _ in range(2)] count = 0 for i in range(len(S[0])): if S[0][i] != S[1][i]: count += 1 print(count) " p02881,s258989865,Accepted,"n = int(raw_input()) d = 1 m = +float('inf') while(d * d <= n): if n % d == 0: m = min(m, n/d -1 + d -1) d+=1 print m" p03479,s032891339,Wrong Answer,"import math x,y = map(int,input().split()) print(int(math.log2(y/x))+1)" p02631,s490298688,Accepted,"n=int(input()) a=list(map(int,input().split())) r1=0 for jj in range(n): r1=r1^a[jj] r=[0]*n for ii in range(n): r[ii]=r1^a[ii] """""" for ii in range(n): print(bin(a[ii]),bin(r[ii])) """""" print(*r)" p03767,s579231175,Accepted,"n = int(input()) a = sorted(list(map(int,input().split()))) print(sum(a[n::2]))" p03475,s474590622,Accepted,"import math N = int(input()) stations = [] for n in range(N-1): tmp = tuple(map(int, input().split())) stations.append(tmp) for index in range(len(stations)): time = 0 sum_time = 0 for c, s, f in stations[index:]: if time <= s: time = s + c else: diff = time - s count = math.ceil(diff/f) time = s + f*count + c print(time) print(0)" p02598,s557587124,Accepted,"N,K=map(int, input().split()) A=list(map(int, input().split())) if K==0: print(max(A)) exit() def f(x): cnt=0 for i in A: if i%x==0: cnt+=i//x-1 else: cnt+=(i//x) if cnt<=K: return True else: return False ok=1 ng=1000000000 for i in range(50): mid=(ok+ng)//2 if f(mid): ng=mid else: ok=mid print(ng) " p02597,s181109892,Wrong Answer,"n = int(input()) c = input() rtow = c.count('R') wtor = 0 anses = [] for i in range(n): if c[i] == 'W': wtor += 1 else: rtow -= 1 anses.append(max(rtow, wtor)) print(min(anses)) " p02603,s482890002,Accepted,"N = int(input()) A = list(map(int,input().split())) M = 1000 for i in range(len(A)-1): if A[i+1] > A[i]: M+= M//A[i]*(A[i+1]-A[i]) print(M)" p02959,s613299020,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 += a[i] b[i] -= a[i] else: ans += b[i] b[i] = 0 if b[i] > 0: if a[i+1] > b[i]: ans += b[i] else: ans += a[i+1] a[i+1] = 0 print(ans)" p03062,s773118244,Wrong Answer,"n = int(input()) a = list(map(int, input().split())) if 0 in a: print(sum(map(abs, a))) exit() minus = len([i for i in range(n) if a[i]<0 ]) if minus % 2 == 0: print(sum(map(abs, a))) else: a = sorted(a, key=lambda x: abs(x)) print(sum(map(abs, a[1:])))" p03386,s656887578,Accepted,"#abc093 b a,b,k=map(int,input().split()) l1=[i for i in range(a,min(a+k,b+1))] l2=[i for i in range(max(a,b-k+1),b+1)] ans=set(l1+l2) for i in sorted(ans): print(i) " p03001,s098166036,Accepted,"w,h,x,y=map(int,input().split()) if x==(w/2)and y==(h/2): print(str((w*h)/2)+' 1') else: print(str((w*h)/2)+' 0')" p02695,s004506039,Wrong Answer,"N, M, Q = map(int, input().split()) A = [list(map(int,input().split())) for i in range(Q)] cnt_all = [ ] for i in range(M): cnt = 0 for j in range(Q): if 0 < (M-i)-A[j][2] == A[j][2] and M-i <= A[j][2]: cnt += A[j][3] cnt_all.append(cnt) print(max(cnt_all))" p02759,s315159213,Accepted,"n = int(input()) if n % 2 == 0: print(n // 2) else: print(n // 2 + 1)" p03645,s731610183,Accepted,"N, M = map(int, input().split()) edges = [[] for i in range(N)] for i in range(M): a, b = map(int, input().split()) a -= 1 b -= 1 edges[a].append(b) for i in edges[0]: if N-1 in edges[i]: print(""POSSIBLE"") exit() print(""IMPOSSIBLE"") " p02860,s587793195,Accepted,"a=int(input()) b=input() if a%2 == 0: if b[:a//2]==b[a//2:]: print(""Yes"") else: print(""No"") else: print(""No"")" p03433,s315705087,Accepted,"n = int(input()) a = int(input()) if n % 500 <= a: print('Yes') else: print('No')" p02933,s341560026,Accepted,"a = int(input()) s = input() if a >= 3200: print(s) else: print(""red"")" p02912,s525013156,Wrong Answer,"N,M = map(int,input().split()) A = list(map(int,input().split())) for i in range(M): A[-1] //= 2 A.sort() print(sum(A))" p03719,s952353078,Wrong Answer,"a,b,c = map(int, input().split()) if a <= c <= b: print(""YES"") else: print(""NO"")" p03605,s096556043,Accepted,"s=list(input()) if s[0]=='9' or s[1]=='9': print('Yes') else: print('No') " p03611,s087913083,Accepted,"from collections import Counter def solve(): ans = 0 N = int(input()) A = list(map(int, input().split())) c = Counter(A) for i in range(1,10**5-1): cnt = 0 if i-1 in c: cnt += c[i-1] if i in c: cnt += c[i] if i+1 in c: cnt += c[i+1] ans = max(ans,cnt) return ans print(solve())" p03250,s489016653,Accepted,"abc = list(map(int, input().split())) abc = sorted(abc, reverse=True) print(abc[0]*10 + abc[1] + abc[2])" p03061,s043628823,Wrong Answer,"n = int(input()) A = list(map(int,input().split())) from fractions import gcd first = A[0] second = A[0] for a in A: second = max(gcd(second, a) ,first) first = gcd(first,a) print(max(first,second))" p02642,s922615991,Accepted,"M = 10 ** 6 + 1 N = int(input()) A = list(map(int, input().split())) A.sort() not_divisible = [True] * (M) # print(A) result = 0 for i in range(N): target = A[i] if not_divisible[target]: if i+1 <= N-1 and A[i+1] == A[i]: pass else: result += 1 for j in range(target, M, target): not_divisible[j] = False print(result)" p02714,s742242973,Wrong Answer,"N = int(input()) S = input() # RGBそれぞれの字数カウント R = S.count('R') G = S.count('G') B = S.count('B') # 条件2の対象数カウント ad = R * G * B ed = 0 for i in range(0, N): for j in range(1, N): if (i + j) >= N or (i + j * 2) >= N: break # 判定 if S[i] != S[i+j] and S[j] != S[i+j*2] and S[i+j*2] != S[i+j]: ed += 1 print(ad-ed)" p03760,s807191609,Accepted,"O = input() E = input() password = [] for i in range(len(O)): password += [O[i]] if i == len(O) - 1: if i != len(E): password += [E[i]] else: password += [E[i]] print(''.join(password))" p03860,s410752879,Wrong Answer,"x=input().split() print(x[0]+x[1]+x[2])" p03317,s914414599,Wrong Answer,"import math n,k = map(int,input().split()) alist = list(map(int,input().split())) aleft = alist[:alist.index(1)] aright = alist[alist.index(1)+1:] ans = math.ceil(len(aleft)/(k-1)) + math.ceil(len(aright)/(k-1)) print(ans) " p03251,s938062819,Accepted,"n,m,x,y=map(int,input().split()) xx=list(map(int,input().split())) yy=list(map(int,input().split())) a = True for i in range(-100,100): if x < i <= y and max(xx) < i <= min(yy): a = False break print('War' if a else 'No War')" p03951,s526522607,Accepted,"N = int(input()) s = input() t = input() i = 0 while i < N: if s[i:] == t[:N-i]: break else: i+=1 print(N+i)" p02729,s803457081,Accepted,"n, m = map(int, input().split()) a = (n * (n - 1)) // 2 + (m * (m - 1)) // 2 print(a) " p02675,s104119641,Accepted,"a=int(input()) a = a % 10 if a == 2 or a == 4 or a == 5 or a == 7 or a == 9: print(""hon"") elif a == 0 or a == 1 or a == 6 or a == 8: print(""pon"") else: print(""bon"") " p02952,s958196382,Wrong Answer,"n = int(input()) cnt = 0 for i in range(1, n): if len(str(i)) % 2 == 1: cnt += 1 else: continue print(cnt)" p02726,s081975140,Wrong Answer,import numpy p03419,s288618633,Accepted,"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))" p03795,s956486850,Accepted,"N = int(input()) #払ったお金 x = N * 800 #15食ワンセットなら何セット?? y = 200 * (N//15) print(x-y)" p02706,s195734263,Accepted,"N, M = map(int, input().split()) A = sum(list(map(int, input().split()))) print(max(-1, N-A))" p02859,s304127431,Wrong Answer,"n = int(input()) print(n^2)" p02963,s891801756,Wrong Answer,"s = int(input()) x3 = s % (10**9) y3 = - (s // (10**9)) print(""0 0 "" + str(10**9) + "" 1 "" + str(x3) + "" "" + str(y3))" p02548,s920017998,Accepted,"N = int(input()) answer = 0 for n in range(1, int(N**0.5)+1): m = N//n if N%n != 0 else N//n-1 if m >= n: answer += (m-n+1)*2-1 print(answer)" p02917,s205383966,Wrong Answer,"N=int(input()) B=list(map(int,input().split())) A=[] B.insert(0,1000000) B.append(1000000) for i in range(1,N+1): a=min(B[i],B[i-1]) A.append(a) print(A) print(sum(A))" p03721,s428999781,Wrong Answer,"n,k=map(int,input().split()) s=0 while 1: a,b=map(int,input().split()) if k<=s+b: print(a) break s+=b" p02854,s448719280,Wrong Answer,"n=int(input()) a=list(map(int,input().split())) s=[0]*n diff=[0]*(n) Sum=0 for i in range(n): Sum+=a[i] s[i]=Sum SUM=sum(a) for i in range(n): diff[i]=s[i]-(SUM-s[i]) ans=[diff[i] for i in range(n) if diff[i]>=0] #print(diff) print(min(ans))" p03338,s328134699,Wrong Answer,"N=int(input()) S=input() ans=1 for i in range(N): ans=max(ans,len(list(set(list(set(list(S[:i+1])) & set(list(S[i+1:]))))))) print(ans)" p02718,s118925153,Wrong Answer,"i1 = input() i2 = input() # i1 = ""4 1"" # i2 = ""5 4 2 1"" list1 = [int(s) for s in i1.split()] list2 = [int(s) for s in i2.split()] n = list1[0] m = list1[1] total = sum(list2) # 選べる count = 0 for a in range(m): if (list2[a]/total > 1/(4*m)): count += 1 if count == m: print(""Yes"") else: print(""No"")" p02946,s073723198,Accepted,"k,x = map(int,input().split()) for i in range(x-(k-1),x+k): print(i,end="" "")" p03767,s144035133,Accepted,"n = int(input()) A = sorted(list(map(int, input().split())))[::-1] print(sum(A[1:2*n:2]))" p03109,s813901523,Accepted,"y,m,d = map(int,input().split('/')) if m <= 4: ans = 'Heisei' elif m > 4: ans = 'TBD' print(ans)" p03433,s071544942,Wrong Answer,"n=int(input()) a = int(input()) if a >= n//500: print('Yes') else: print('No') " p02697,s139461936,Wrong Answer,"import sys stdin = sys.stdin sys.setrecursionlimit(10**6) ni = lambda: int(ns()) na = lambda: list(map(int, stdin.readline().split())) nn = lambda: list(stdin.readline().split()) ns = lambda: stdin.readline().rstrip() n,m = na() if n%2 == 0: a,b = n//2,n//2+1 for i in range(m): print(a,b) a,b = a-1,b+1 else: a,b = n//2,n//2+1 for i in range(m): print(a,b) a,b = a-1,b+1 " p02676,s985547977,Accepted,"K = int(input()) S = input() Sl = list(S) if len(Sl) <= K: print(S) else: Po = """".join(Sl[0:K]) print(Po+'...')" p03030,s706912038,Accepted,"from functools import cmp_to_key N = int(input()) SN = [] for i in range(N): SN.append(input().split()) SN[i].append(i + 1) def cmp(a, b): if a[0] == b[0]: if int(a[1]) == int(b[1]): return 0 return 1 if int(a[1]) <= int(b[1]) else -1 return -1 if a[0] <= b[0] else 1 def cmpstr(a, b): return cmp(a, b) sorted_SN = sorted(SN, key=cmp_to_key(cmpstr)) answer = ""\n"".join([str(sorted_SNi[2]) for sorted_SNi in sorted_SN]) print(answer) " p03211,s505363443,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())) #S = list(str(input())) #N = int(input()) S = str(input()) minN = sys.maxsize for i in range(len(S)-2) : minN = min(minN, abs(int(S[i:i+3]) - 753)) print (minN)" p02552,s189286185,Accepted,"x = int(input()) if x == 0: print(1) else: print(0)" p02761,s051885814,Accepted,"N, M = map(int, input().split()) sc = [list(map(int, input().split())) for _ in range(M)] ans = [""0""] * N if N > 1: ans[0] = ""1"" rep = {} ok = True for s, c in sc: ans[s-1] = str(c) if s in rep and rep[s] != str(c): ok = False else: rep[s] = str(c) if ok: if ans[0] == ""0"" and N > 1: ok = False print("""".join(ans) if ok else -1)" p03352,s182330356,Wrong Answer,"a=1 kazu=[] while 1: if a*a>1000: break kazu.append(a*a) a+=1 x=int(input()) for i in range(len(kazu)): if kazu[len(kazu)-1-i]<=x: print(kazu[len(kazu)-1-i]) exit()" p03557,s759231108,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: a = bisect.bisect_left(A, b) c = len(C) - bisect.bisect_right(C, b) ans += a * c print(ans)" p03456,s776660087,Accepted,"import sys readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines read = sys.stdin.buffer.read sys.setrecursionlimit(10 ** 7) a, b = readline().rstrip().decode('utf-8').split() N = int(a + b) LIM = 10 ** 7 for i in range(1, LIM): tmp = i * i if tmp == N: print('Yes') exit() if tmp > N: print('No') exit() " p04034,s763246057,Accepted,"n,m=map(int,input().split()) l=[list(map(int,input().split())) for i in range(m)] num_l=[1 for i in range(n)] bit_l=[1]+[0 for i in range(n-1)] for x,y in l: x-=1 y-=1 if bit_l[x]==1: bit_l[y]=1 if num_l[x]==1: bit_l[x]=0 num_l[x]-=1 num_l[y]+=1 print(bit_l.count(1))" p03109,s356848790,Wrong Answer,"S = input() year = int(S[0:3]) month = int(S[5:6]) day = int(S[8:9]) if (S > ""2019/05/01""): print(""TBD"") else: print(""Heisei"") " p02601,s007243982,Accepted,"# cook your dish here a,b,c = map(int, input().split()) k = int(input()) c1, c2 = 0, 0 while b<=a: b=b*2 c1 = c1 + 1 while c <= b: c=c*2 c2 = c2 +1 if c1 + c2 <= k: print('Yes') else: print('No') " p02753,s529100308,Accepted,"S = input() if 'A' in S and 'B' in S: print('Yes') else: print('No')" p02623,s420629182,Accepted,"import sys from collections import deque import copy sys.setrecursionlimit(2147483647) input = sys.stdin.readline if __name__ == '__main__': n,m,k=map(int,input().strip(""\n"").split()) A=list(map(int,input().strip(""\n"").split())) B=list(map(int,input().strip(""\n"").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) " p03126,s788335846,Accepted,"n,m = map(int,input().split()) arr = [] ans = [0 for i in range(m+1)] for i in range(n): arr.append(list(map(int,input().split()))) for i in arr: for j in i[1:]: ans[j-1] +=1 val = 0 for i in ans: if i == n: val +=1 print(val)" p03835,s944783173,Accepted,"k,s = map(int, input().split()) cnt = 0 for x in range(k+1): for y in range(k+1): z = s-x-y if 0<=z and z<=k : cnt += 1 print(cnt)" p02989,s068290017,Accepted,"N = int(input()) d = list(map(int,input().split())) d = sorted(d) if len(d) % 2 == 1: print(0) exit(0) pick = len(d)//2 ans = d[pick] - d[pick-1] print(ans) " p02688,s654020030,Accepted,"N, K = [int(i) for i in input().split()] A = [] for i in range(K): input() A += [int(i) for i in input().split()] print(N - len(set(A))) " p02995,s530678042,Accepted,"a, b, c, d = map(int, input().split()) from fractions import gcd xc = (a-1)//c yc = b//c xd = (a-1)//d yd = b//d xcd = (a - 1) // ((c * d) // gcd(c, d)) ycd = b // ((c * d) // gcd(c, d)) print(b - a + 1 -((yc - xc) + (yd - xd) - (ycd - xcd)))" p02681,s500650989,Accepted,"s1=input() s2=input() if s1 == s2[:-1]: print('Yes') else: print('No')" p03544,s491378683,Accepted,"n = int(input()) a1=1 a2=2 for i in range(n-1): a=a1+a2 a2=a1 a1=a if n==1: a=1 print(a)" p03011,s654571841,Accepted,"a, b, c = map(int, input().split()) Li = [a, b, c] Li.sort() print(Li[0] + Li[1])" p03206,s185519690,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"")" p03042,s232671388,Accepted,"S = input() mm = [""0""+str(x) for x in range(1,10)]+[""10"",""11"",""12""] mmyy = (S[:2] in mm) yymm = (S[2:] in mm) a = ""NA"" if yymm and mmyy: a = ""AMBIGUOUS"" elif yymm: a = ""YYMM"" elif mmyy: a = ""MMYY"" print(a)" p03210,s095337167,Accepted,"N = int(input()) if N == 3 or N == 5 or N == 7: print(""YES"") else: print(""NO"")" p03387,s318872956,Accepted,"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() a,b,c = na() d = max(a,b,c)*3-(a+b+c) e = d//2 if d%2==0 else (d+3)//2 print(e)" p02647,s348370328,Accepted,"from itertools import accumulate n, k = map(int, input().split()) a = list(map(int, input().split())) for _ in range(k): newa = [0 for _ in range(n)] for i in range(n): l = max(0, i - a[i]) r = min(n - 1, i + a[i]) newa[l] += 1 if r + 1 < n: newa[r + 1] -= 1 a = list(accumulate(newa)) if all(i == n for i in a): break print(*a)" p02958,s053324169,Accepted,"N=int(input()) p=[int(i) for i in input().split()] q=sorted(p) count=0 for t in range(N): if p[t]!=q[t]: count+=1 if count==0 or count==2: print(""YES"") else: print(""NO"")" p03481,s464691093,Accepted,"x, y = map(int, input().split()) ans = 1 while x <= y//2: x *= 2 ans += 1 if x > y: ans -= 1 print(ans)" p03644,s348245222,Accepted,"N = int(input()) l_cnt = [1, 2, 4, 8, 16, 32, 64] l_ans = [x for x in l_cnt if x <= N] print((l_ans[-1]))" p03107,s676454325,Wrong Answer,"s = list(input()) n = len(s) cnt = 0 for i in range(n-1): if s[i] == '0' and s[i+1]: cnt += 2 print(cnt)" p02923,s957526737,Wrong Answer,"n=int(input()) h=list(map(int,input().split())) ans,tmp=0,0 for i in range(n-1): if h[i]>=h[i+1]: tmp+=1 ans=max(ans,tmp) else: tep=0 print(ans)" p02720,s174588569,Accepted,"k = int(input()) lunlun = [[1, 2, 3, 4, 5, 6, 7, 8, 9]] for i in range(11): last = lunlun[-1] add = [] for x in last: c = x % 10 add.append(x*10+c) if c != 0: add.append(x*10+c-1) if c != 9: add.append(x*10+c+1) lunlun.append(add) all = [] for i in range(11): for x in lunlun[i]: all.append(x) all.sort() print(all[k-1]) " p02973,s198817648,Accepted,"import bisect import sys input = sys.stdin.readline n = int(input()) colors_maxs = [] colors_maxs.append(int(input()) *(-1) ) for _ in range(n-1): a = int(input()) * (-1) if colors_maxs[-1] <= a: colors_maxs.append(a) else: ind = bisect.bisect_right(colors_maxs, a) # -> 4 colors_maxs[ind] = a print(len(colors_maxs))" p02784,s005612868,Accepted,"H, N = map(int, input().split()) A = sum(list(map(int, input().split()))) if H <= A: print('Yes') else: print('No') " p02645,s379462437,Accepted,"s = input() print(s[:3])" p02631,s058974847,Accepted,"N = int(input()) a = list(map(int, input().split())) x = 0 for r in a: x ^= r print(' '.join([str(x^r) for r in a]))" p03456,s440554538,Accepted,"import math ab = int(input().replace(' ', '')) print ('Yes' if math.sqrt(ab).is_integer() else 'No')" p02555,s494338158,Accepted,"num = (1,0,0) for _ in range(int(input()) - 2): num = (num[1],num[2],num[0]+num[2]) print(num[2]%(10**9+7))" p03281,s420292576,Accepted," N = int(input()) ans = 0 for i in range(1, N + 1): cnt = 0 for j in range(1, i + 1): if i % j == 0: cnt += 1 if cnt == 8 and i % 2 != 0: ans += 1 print(ans) " p03437,s268989540,Accepted,"import math x,y = map(int, input().split()) xy = x*y//(math.gcd(x,y)) if xy > x: print(x) else: print(-1)" p03433,s362748620,Accepted,"n = int(input()) a = int(input()) c = n % 500 if c <= a: print('Yes') else: print('No')" p02707,s902817876,Accepted,"import collections n = int(input()) a = list(map(int,input().split())) c = collections.Counter(a) for i in range(1,n+1): print(c[i])" p03679,s571301977,Accepted,"X, A, B = map(int,input().split()) if B <= A: print(""delicious"") elif B <= A+X: print(""safe"") else: print(""dangerous"") " p03352,s418001834,Wrong Answer,"t = set([]) for i in range(1,32): for s in range(2,32): if i**s<1001: t.add(i**s) t = list(t) t.sort(reverse = True) x = int(input()) for i in range(len(t)-1): if t[i]>x>=t[i+1]: print(t[i+1]) break " p02689,s841831992,Accepted,"N, M = map(int, input().split()) H = list(map(int, input().split())) Root = [] for i in range(M): temp = list(map(int, input().split())) Root.append(temp) ans = [1]*N for i in range(M): r_start = Root[i][0] - 1 r_stop = Root[i][1] - 1 if H[r_start] < H[r_stop]: ans[r_start] = 0 elif H[r_start] == H[r_stop]: ans[r_start] = 0 ans[r_stop] = 0 else: ans[r_stop] = 0 print(sum(ans))" p02639,s081029658,Accepted,"a=list(map(int, input().split("" ""))) print(a.index(0)+1)" p02791,s497821023,Wrong Answer,"N = int(input()) P = list(map(int, input().split())) count = 0 for i in range(N): for j in range(i+1): if P[i] > P[j]: break count += 1 print(count) " p02888,s096214802,Accepted,"import sys sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) N = ir() L = lr() L.sort() answer = 0 for i in range(N-1, -1, -1): # iが一番大きい辺 x = L[i] left = 0 right = i - 1 while left < right: if L[left] + L[right] <= x: left += 1 continue answer += (right - left) right -= 1 print(answer) " p02946,s768941902,Wrong Answer,"k,x=map(int,input().split()) ans=[] for i in range(-k+1,k): print(i,end=' ')" p04005,s019457584,Wrong Answer,"A,B,C=map(int,input().split()) if (A*B*C)%2==0: ans = 0 else: ans = int(A*B*C/max(A,B,C)) print(ans)" p02582,s469851246,Accepted,"S = input() s_num = len(S) i=0 max_count = 0 count = 0 while i < s_num: if S[i] != ""R"": if max_count < count: max_count = count count = 0 elif S[i] == ""R"": count += 1 i+=1 if max_count < count: max_count = count print(max_count)" p03012,s821024814,Accepted,"a = int(input()) b = list(map(int,input().split()[:a])) c = sum(b) for i in range(len(b)): c = min(c, abs(sum(b[:i]) - sum(b[i:]))) print(c)" p02730,s314800264,Accepted,"def s0():return input() def s1():return input().split() def s2(n):return [input() for x in range(n)] 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)] s=s0() n=len(s) print(""Yes"" if s==s[::-1] and s[:n//2]==s[n//2-1::-1] and s[n//2+1:]==s[:n//2:-1] else ""No"")" p02843,s591956412,Accepted,"X = int(input()) if X%100 <= (X//100 * 5): print(1) else: print(0)" p02787,s067405081,Wrong Answer,"# coding:utf-8 H, N = map(int, input().split(' ')) ab_list = [] for _ in range(N): a, b = map(int, input().split(' ')) ab_list.append([a, b]) dp = [0] * (H + 1) for i in range(1, H + 1): for j in range(N): if ab_list[j][0] <= H: dp[i] = dp[H - ab_list[j][0]] + ab_list[j][1] else: dp[i] = ab_list[j][1] print(dp[H])" p03951,s114629626,Wrong Answer,"n = int(input()) s = input() t = input() ans = n for i in range(n): f = True for j in range(n - i): f &= s[j + i] == t[j] if f: ans = i print(n+ans) " p02832,s317255069,Wrong Answer,"n = int(input()) block = list(map(int,input().split())) count = 0 num = 1 for i in range(0,n): if block[i] == num: num += 1 else: count += 1 if count == 0 and num != 2: print(-1) else: print(count)" p03379,s368813979,Accepted,"def resolve(): N=int(input()) X=list(map(int,input().split())) Y=sorted(X) l=Y[N // 2-1] r=Y[N//2] for i in X: if i j: dp[i+1][j+1] = dp[i][j+1] else: #print(j+1,w) dp[i+1][j+1] = max(dp[i][j+1], dp[i][j+2-w]+v) print(dp[-1][-1]) " p02665,s588302299,Accepted,"n = int(input()) a = list(map(int, input().split())) if a[0]: if n == 0 and a[0] == 1: print(1) else: print(-1) exit() b = [0 for _ in range(n)] b.append(a[-1]) for i in range(n)[::-1]: b[i] = b[i+1] + a[i] node = 1 ans = 1 for i in range(1, n+1): t = min(node*2, b[i]) ans += t node = t - a[i] if node < 0: print(-1) exit() print(ans) " p03785,s459153348,Accepted,"def main(): n, c, k = map(int, input().split()) t = [None]*n for i in range(n): t[i] = int(input()) t.sort() ans = 0 l = 0 x = t[0]+k for r in range(1, n): if x < t[r] or c < r-l+1: ans += 1 l = r x = t[r] + k if r == n-1: ans += 1 print(ans) if __name__ == ""__main__"": main()" p03387,s606021081,Accepted,"A = sorted(list(map(int, input().split()))) s = 0 for a in A[:-1]: s += A[-1] - a print(s//2 + 2 if s % 2 else s//2)" p03433,s549060512,Accepted,"N = int(input()) A = int(input()) n5 = int(N/500) a = N - n5 * 500 if a <= A: print(""Yes"") else: print(""No"")" p02705,s535062787,Accepted,"R = int(input()) print(3.1415926*R*2)" p02719,s923792985,Accepted,"n,k = map(int, input().split()) print(min(n%k, abs(n%k-k))) " p03042,s974824295,Accepted,"s = input() firstHalf = s[:2] secondHalf = s[2:] val1 = 0 val2 = 0 if firstHalf[0] == '0': val1 = int(firstHalf[1]) else: val1 = int(firstHalf) if secondHalf[0] == '0': val2 = int(secondHalf[1]) else: val2 = int(secondHalf) first = False second = False if val1 <= 12 and val1 > 0: first = True if val2 <= 12 and val2 > 0: second = True if first and second: print(""AMBIGUOUS"") elif first: print(""MMYY"") elif second: print(""YYMM"") else: print(""NA"")" p03437,s502227148,Wrong Answer,"def resolve(): X, Y = [int(i) for i in input().split()] if Y % X == 0: print(-1) else: print(X) resolve()" p02631,s753221691,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:]): print(bin(c_list[i]),bin(a)) c_list[1+i]=b^a^c_list[i] b=a ans="" "".join(list(map(str,c_list))) print(ans) " p03943,s630301070,Wrong Answer,"a, b, c = sorted(map(int, input().split())) print(""YES"" if a+b == c else ""No"")" p03252,s564651303,Accepted,"s = list(input()) t = list(input()) for _ in range(2): n = len(s) l = [set() for _ in range(26)] def f(c): return ord(c) - ord('a') for i, j in enumerate(s): l[f(j)].add(t[i]) for i in l: if len(list(i)) > 1: print('No') exit(0) s,t = t,s print('Yes') " p02796,s544895614,Accepted,"N = int(input()) X = [list(map(int, input().split())) for _ in range(N)] S = [[x - l, x + l] for x, l in X] S.sort(key=lambda x: x[1]) ans = 0 tmp = -10 ** 12 for x, y in S: if tmp <= x: ans += 1 tmp = y print(ans) " p02708,s995691985,Wrong Answer,"N, K = map(int, input("""").split("" "")) cnt = 0 for i in range(K, N+2): start_idx = 0 end_idx = 0 #for j in range(i): # start_idx += j start_idx = (i-1) * (i)//2 #for j in range(i): # end_idx += (N-j) end_idx = (i)*N - start_idx #print( end_idx - start_idx+1) cnt += (end_idx - start_idx+1) cnt %= (10^9+7) print(cnt%(10^9+7))" p03208,s727497413,Accepted,"n,k=map(int,input().split()) h=[int(input()) for _ in range(n)] h.sort() res=[] for i in range(n-k+1): s=h[i+k-1]-h[i] res.append(s) print(min(res))" p03796,s918156031,Accepted,"n = int(input()) dv = 10 ** 9 + 7 power = 1 for i in range(1, n + 1): power = (power * i) % dv print(power)" p03211,s814231525,Accepted,"s = input() print(min(abs(int(s[i:i+3]) - 753) for i in range(len(s)))) " p02811,s154646663,Accepted,"K,X=map(int,input().split()) print('Yes' if K*500>=X else 'No')" p02767,s189468387,Accepted,"import numpy as np n = int(input()) x = list(map(int,input().split())) x = np.array(x) ans = 9999999 for i in range(1,101): ans = min(ans,sum((x-i)**2)) print(ans)" p03017,s140871268,Wrong Answer,"n, a, b, c, d = map(int, input().split()) s = input() if ""##"" in s: print (""No"") exit() if c > d: if ""..."" not in s: print (""No"") exit() print (""Yes"")" p02952,s191802172,Accepted,"N = int(input()) count = 0 for i in range(1,N+1): if len(str(i)) % 2 != 0: count += 1 print(count)" p02660,s547249344,Accepted,"from collections import Counter import math def div(n): prime = [] tmp = int(math.sqrt(n)) + 1 for num in range(2,tmp): while n % num == 0: n //= num prime.append(num) if n != 1: prime.append(n) return prime n = int(input()) prime_div = Counter(div(n)) ans = 0 for p, ex in prime_div.items(): k = 1 while ex >= k: ex -= k ans += 1 k += 1 print(ans)" p02862,s753680108,Wrong Answer,"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)" p02695,s880325631,Accepted,"import itertools N, M, Q = map(int, input().split()) li = [list(map(int, input().split())) for _ in range(Q)] ans= 0 AA = [i for i in range(1, M+1)] A = [] for i in sorted(list(itertools.combinations_with_replacement(AA, N))): A.append(i) for i in A: result = 0 for j in range(Q): if i[li[j][1]-1]-i[li[j][0]-1] == li[j][2]: result += li[j][3] ans = max(ans, result) print(ans)" p02665,s541215759,Accepted,"N = int(input()) A = list(map(int, input().split())) left = sum(A) n = 1 ans = 1 for a in A: left -= a if a > n or n - a > left: print(-1) break n = min((n - a) * 2, left) ans += n else: if n > 0: print(-a) else: print(ans)" p03943,s044857303,Accepted," a = list(map(int,input().split())) a.sort(reverse = True) if a[0] == a[1]+a[2]: print(""Yes"") else: print(""No"")" p03146,s723224985,Wrong Answer,"s=int(input()) list=[s] num=2 while num<=1000000: if num%2==0: list.append(list[num-2]/2) else: list.append(list[num-2]*3+1) if list[num-1] in list[:num-1]: break num+=1 print(num)" p02820,s545805758,Accepted,"def hantei(a): if a == 'r': return p elif a == 's': return r else: return s n, k = map(int, input().split()) r, s, p = map(int, input().split()) t = input() ans = 0 for i in range(k): flag = True last1 = 'a' last2 = 'b' for j in range(i, n, k): if last1 != t[j]: ans += hantei(t[j]) elif last1 == last2 and last1 == t[j]: ans += hantei(t[j]) last1 = 'y' last2 = last1 last1 = t[j] print(ans)" p03472,s497218558,Accepted,"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 m_cut = max(cut) for t in throw: if t > m_cut: ans += 1 h -= t if h <= 0: break if h > 0: ans += ceil(h / m_cut) print(ans)" p03127,s935815300,Wrong Answer,"N=int(input()) A=list(map(int, input().split())) allsame=True alleven=True for a in A: if allsame: if a!=A[0]: allsame=False if a%2==1: alleven=False if allsame: print(A[0]) elif alleven: print(2) else: print(1) " p03623,s662600466,Accepted,"x,a,b=map(int,input().split()) if abs(x-a) < abs(x-b): print(""A"") else: print(""B"")" p03220,s469626255,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())) #S = list(str(input())) N = int(input()) #S = str(input()) T, A = map(int, input().split()) H = list(map(int, input().split())) id = 0 minN = sys.maxsize for i in range(N): ave = abs(A - (T-(H[i] * 0.006))) if minN > ave : minN = ave id = i print (id+1) " p02594,s852993025,Accepted,"x = int(input()) if x >= 30: print('Yes') else: print('No') " p02797,s405298471,Accepted,"n,k,s = map(int,input().split()) anaume = 10**9 if s == anaume: anaume = 10**9-1 lst1 = [] lst1 += [s]*k lst1 += [anaume]*(n-k) print(*lst1)" p03720,s975515968,Wrong Answer,"from collections import defaultdict N, M = map(int, input().split()) city_road_nums = defaultdict(int) for _ in range(M): a, b = map(int, input().split()) city_road_nums[a] += 1 city_road_nums[b] += 1 for _, value in sorted(city_road_nums.items()): print(value) " p03011,s991620876,Accepted,"P, Q, R = map(int, input().split()) print(P + Q + R - max(P, Q, R)) " p04019,s802689674,Accepted,"S = input() if (S.count(""W"") != 0 and S.count(""E"") != 0) and (S.count(""N"") == 0 and S.count(""S"") == 0): print(""Yes"") elif (S.count(""N"") != 0 and S.count(""S"") != 0) and (S.count(""W"") == 0 and S.count(""E"") == 0): print(""Yes"") elif S.count(""N"") != 0 and S.count(""S"") != 0 and S.count(""W"") != 0 and S.count(""E"") != 0: print(""Yes"") else: print(""No"")" p02888,s093993354,Accepted,"n = int(input()) l = list(map(int,input().split())) l = sorted(l) ans = 0 for i in range(n): for j in range(i+1,n): bottom = j top = n while top -bottom > 1: middle = (top+bottom)//2 if l[middle] 0: print(P*Y+K*X) else: print(N*X)" p03486,s037850939,Wrong Answer,"s = input() t = input() s = ''.join(sorted(s, reverse=True)) t = ''.join(sorted(t, reverse=True)) if s>=t: print('No' , flush=True) else: print('Yes' , flush=True) " p03286,s080483774,Accepted,"N = int(input()) if N == 0: print(0); exit() ans = [] while N !=0: #print(ans,N) if N%2 == 0: ans.append(0) else: N -= 1 ans.append(1) N//=-2 #print(ans) ans = reversed(ans) print(''.join([str(n) for n in ans]))" p02791,s810586587,Accepted,"input() cnt = 0 min_value = 200005 for x in map(int, input().split()): if min_value > x: cnt += 1 min_value = min(x, min_value) print(cnt)" p03385,s484247220,Wrong Answer,"s = str(input()) if 'a' and 'b' and 'c' in s: print('Yes') else: print('No')" p03062,s811576676,Accepted,"N = int(input()) A = list(map(int, input().split())) cnt = 1 ans = 0 for i in range(N): if(A[i] < 0): cnt = cnt * (-1) elif(A[i] == 0): cnt = cnt * 0 if(cnt >= 0): for i in range(N): ans += abs(A[i]) else: for i in range(N): A[i] = abs(A[i]) A.sort() for i in range(N): ans += A[i] ans -= A[0] * 2 print(ans) " p02989,s821007299,Accepted,"N = int(input()) K = list(map(int, input().split())) K.sort() num = len(K)//2 result = K[num] - K[num-1] print(result)" p03434,s003049762,Wrong Answer,"N =int(input()) a = list(map(int, input().split())) b = sorted(a,reverse=True) Alice = sum(b[::2]) Bob = sum(b[1::2]) ans = Alice - Bob print(ans) print(b)" p03797,s238829019,Accepted,"n,m = map(int, input().split()) ans = 0 if n*2 <= m: ans += n m -= n*2 else: ans += m//2 print(ans) exit() if 4 <= m: ans += m//4 print(ans)" p03607,s990277615,Wrong Answer,"n = int(input()) a = [] ans = 0 for i in range(n): a.append(int(input())) a.sort() i = 0 jud = 1 q = [a[0]] ans = 0 for i in range(1,): if(q[-1]==a[i+1]): jud += 1 else: if(jud%2==1): ans += 1 jud = 1 print(ans) " p02787,s174482959,Accepted,"H, N = map(int, input().split()) AB = [list(map(int, input().split())) for _ in range(N)] A_max = 10 ** 4 INF = float('inf') dp = [INF] * (H + A_max + 1) dp[0] = 0 for i in range(H): if dp[i] == INF: continue for a, b in AB: if dp[i] + b < dp[i + a]: dp[i + a] = dp[i] + b print(min(dp[H:])) " p02553,s234960147,Accepted,"a,b,c,d=list(map(int,input().split())) m = max(a*c, b*d) m = max(m, a*d) m = max(m, b*c) print(m) " p03309,s583247290,Accepted,"n = int(input()) a = list(map(int, input().split())) diff = [0] * n for i in range(n): d = a[i] - (i + 1) diff[i] = d diff = sorted(diff) if n % 2 == 1: x = diff[n // 2] else: x = (diff[(n // 2) - 1] + diff[n // 2]) // 2 ans = 0 for i in range(n): ans += abs(diff[i] - x) print(ans)" p03797,s268389920,Accepted,"n, m = map(int, input().split()) c = m - n * 2 if c > 0: print(n + c // 4) else: print(m // 2)" p03821,s205485431,Accepted,"n=int(input()) A=[];B=[] for i in range(n): a,b=map(int,input().split()) A.append(a);B.append(b) A=A[::-1];B=B[::-1] now=0 for i in range(n): qq=(A[i]+now) % B[i] if qq==0:continue now+=B[i]-qq print(now) " p03243,s741496480,Wrong Answer,"n = int(input()) a = n // 100 ans = a * 100 + a * 10 + a print(ans)" p02720,s192576181,Accepted,"k = int(input()) l = [0 for x in range(100005)] for i in range(10): l[i] = i+1 temp = 0 i = 9 while i < k: if l[temp] % 10 == 9: l[i] = l[temp] * 10 + 8 l[i+1] = l[temp] * 10 + 9 i+=2 elif l[temp] % 10 == 0: l[i] = l[temp] * 10 l[i+1] = l[temp] * 10 + 1 i+=2 else: l[i] = l[temp] * 10 + l[temp] % 10 - 1 l[i+1] = l[temp] * 10 + l[temp] % 10 l[i+2] = l[temp] * 10 + l[temp] % 10 + 1 i+=3 temp+=1 print(l[k-1]) " p03059,s808672786,Accepted,"x,y,z=map(int,input().split()) c=0 for i in range(100000): c=z-i*x if c<0: break print((i-1)*y) " p02708,s418421583,Accepted,"import sys def input(): return sys.stdin.readline()[:-1] def main(): N, K = map(int,input().split()) mod = 10 ** 9 + 7 ans = 0 for i in range(K, N + 1 + 1): mi = int((i - 1) * i / 2) #ma、miは i * (10 **100)を無視した上限下限 ma = i * N - mi ans += ma - mi + 1 print(ans % mod) if __name__ == ""__main__"": main()" p02747,s836363955,Accepted,"S = str(input()) l = len(S) if l%2 == 1: print(""No"") else: k = 1 for i in range (l//2): if S[2*i] != ""h"": k = 0 if S [2*i + 1] != ""i"": k = 0 if k == 0: print(""No"") else: print(""Yes"")" p03486,s648905753,Accepted,"s = list(input()) t = list(input()) s = sorted(s) t = sorted(t) t = t[::-1] s_ = '' t_ = '' for i in s: s_ += i for j in t: t_ += j if s_ < t_: print(""Yes"") else: print(""No"") " p03071,s359759674,Accepted,"a,b = map(int,input().split()) print(max(a+a-1,b+b-1,a+b))" p02818,s575481775,Accepted,"a,b,k = map(int,input().split()) if a-k >= 0: t = a-k a = b else: t = 0 a = max(0,b+(a-k)) print(t,a)" p02793,s744302672,Accepted,"import sys from math import gcd from functools import reduce read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 MOD = 1000000007 def lcm(a, b): return a // gcd(a, b) * b def main(): N, *A = map(int, read().split()) ans = 0 l = 1 for a in A: l, l_prev = lcm(l, a), l ans = (ans * (l // l_prev) % MOD + l // a) % MOD print(ans) return if __name__ == '__main__': main() " p02756,s109684761,Accepted,"right = input() q = int(input()) left = """" flag = 1 for i in range(q) : t = input() if t == ""1"" : flag ^= 1 continue t, f, c = t.split("" "") f = int(f) left += c*flag*(2-f) right += c*flag*(f-1) left += c*(1-flag)*(f-1) right += c*(1-flag)*(2-f) if flag == 1 : print(left[::-1]+right) else : print(right[::-1]+left)" p03693,s752671108,Wrong Answer,"N = list(map(int,input().split())) if N[1]*10+N[2] // 4 == 0: print(""YES"") else: print(""NO"")" p02988,s555220638,Accepted,"# B - Ordinary Number n = int(input()) p = list(int(x) for x in input().split()) ans = 0 for i in range(1, n-1): if (p[i-1] j[1]: print(""No"") return else: print(""Yes"") if __name__ == '__main__': main()" p03449,s091394966,Accepted,"n = int(input()) a = [list(map(int,input().split())) for i in range(2)] get = [] for i in range(n): get =get+ [sum(a[0][:i+1]) + sum(a[1][i:])] print(max(get)) " p03696,s055883113,Wrong Answer,"import collections n = int(input()) t = input() s = list(t) c = collections.Counter(s) if c["")""] > c[""(""]: for i in range(c["")""]-c[""(""]): print(""("",end="""") print(t) elif c[""(""] > c["")""]: print(t,end="""") for i in range(c[""(""]-c["")""]): print("")"",end="""") else: print(t)" p02718,s491429604,Accepted,"# -*- coding: utf-8 -*- import numpy as np n, m = map(int, input().split()) a = np.array(input().split(), dtype='int') sum_a = np.sum(a) b = np.sort(a)[::-1] if b[m-1] >= sum_a / 4 / m: print('Yes') else: print('No')" p03371,s839087759,Accepted,"#n=int(input()) a,b,c,x,y=map(int,input().split()) #l=list(map(int,input().split())) #l=[list(map(int,input().split())) for i in range(n)] ans=a*x+b*y for i in range(1,max(x,y)+1): ans=min(ans,2*c*i+a*max(x-i,0)+b*max(y-i,0)) print(ans) " p03286,s873219898,Accepted,"N = int(input()) if N == 0: print(0) else: ans = """" while N != 0: if N%2 == 1: ans += ""1"" N -= 1 else: ans += ""0"" N //= -2 print(ans[::-1]) # tmp = [1*(i==0) for i in ans][::-1] # print("""".join(map(str, tmp))) " p02688,s773855888,Accepted,"n,k = map(int,input().split()) sunuke = [0]*n for i in range(k): d = int(input()) a = [int(e)-1 for e in input().split()] for j in range(d): sunuke[a[j]] += 1 print(sunuke.count(0))" p02923,s462834786,Accepted,"n=int(input()) h=list(map(int,input().split())) b=0 c=0 cm=0 for m in h: if m <=b: c+=1 b=m else: b=m if c>cm: cm=c c=0 print(max(cm,c)) " p02802,s559003766,Accepted,"n, m = map(int, input().split()) ps = [] for i in range(m): p, s = input().split() ps.append([int(p), s]) flag = [False for _ in range(n)] ac = [0 for _ in range(n)] wa = [0 for _ in range(n)] i = 0 sumac = 0 sumwa = 0 for i in range(m): p = ps[i][0] s = ps[i][1] if s == ""WA"" and ac[p - 1] == 0: wa[p - 1] += 1 elif s == ""AC"" and ac[p - 1] == 0: ac[p - 1] += 1 sumac += 1 sumwa += wa[p - 1] print(str(sumac) + "" "" + str(sumwa))" p03485,s345197337,Accepted,"a, b = map(int, input().split()) if (a + b) % 2 == 0: print(int((a + b) / 2)) else: print(int((a + b) / 2 + 1)) " p03472,s413065780,Accepted,"from operator import itemgetter import math n, h = map(int, input().split()) ab = [] A = 0 B = 1 maxA = 0 for i in range(n): ab.append(list(map(int, input().split()))) maxA = max(maxA, ab[i][A]) ab.sort(key=itemgetter(B), reverse=True) sumB = 0 for _ab in ab: sumB += _ab[B] ans = 0 damage = 0 i = 0 while damage < h and ans < n: damage += max(maxA, ab[ans][B]) ans += 1 if damage < h: ans += math.ceil((h - damage)/maxA) print(ans)" p03073,s569217227,Accepted,"s = input() y1 = [0 if x % 2 ==0 else 1 for x in range(len(s))] y2 = [0 if x % 2 !=0 else 1 for x in range(len(s))] ans1 = sum([1 for i,j in zip(s,y1) if int(i)==j]) ans2 = sum([1 for i,j in zip(s,y2) if int(i)==j]) print(min([ans1,ans2]))" p02836,s584465339,Accepted,"s=input() s1=s[:len(s)//2] s2=s[len(s)//2:][::-1] ans=0 for i in range(len(s)//2): if s1[i]!=s2[i]: ans+=1 print(ans)" p03545,s073647755,Wrong Answer,"import sys a,b,c,d=input() op=[""-"",""+""] for i in op: for j in op: for k in op: o=a+i+b+j+c+k+d ans=eval(o) if ans==7: print(o+""+=7"") sys.exit()" p03417,s136882532,Wrong Answer," n,m=map(int,input().split()) if n==1 and m==1: print(1) elif m==1: print(m-1) elif n==1: print(m-1) else: print((n-2)*(m-2))" p03095,s918943714,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) " p02582,s557294662,Accepted,"def main(): s = input().split('S') x = max(map(len,s)) print(x) main()" p03723,s990240323,Wrong Answer,"a, b, c = map(int, input().split()) if a == b == c: print(-1) exit() cnt = 0 while True: if a % 2 or b % 2 or c % 2: break cnt += 1 next_a = b // 2 + c // 2 next_b = a // 2 + c // 2 next_c = a // 2 + b // 2 a = next_a; b = next_b; c = next_c print(cnt)" p02676,s466807525,Wrong Answer,"K = int(input()) s = input() if len(s)>K: print(s[:K]+""..."") " p03042,s889727188,Accepted,"s = input() s1 = int(s[0]+s[1]) s2 = int(s[2]+s[3]) #print(s1, s2) L=[] for i in range(1, 13): L.append(i) if s1 not in L and s2 not in L: print('NA') elif s1 in L and s2 not in L: print('MMYY') elif s1 not in L and s2 in L: print('YYMM') else: print('AMBIGUOUS') " p03262,s169995311,Accepted,"n, x = map(int, input().split()) X = tuple(map(lambda k:abs(int(k)-x), input().split())) from math import gcd from functools import reduce ans = reduce(gcd, X) print(ans)" p02771,s509401591,Wrong Answer,"a, b, c = map(int,input().split()) if a == b and (a == b) != c: print(""Yes"") elif a == c and (a == c) != b: print(""Yes"") elif b == c and (b == c) != a: print(""Yes"") else: print(""No"")" p03637,s699596432,Accepted,"N = int(input()) A = list(map(int, input().split())) memo = {1:0,2:0,4:0} for a in A: if a % 4 == 0: memo[4] += 1 elif a % 2 == 0: memo[2] += 1 else: memo[1] += 1 if memo[4] >= (N//2): print(""Yes"") elif memo[4] >= memo[1]: print(""Yes"") else: print(""No"") " p02576,s845184726,Accepted,"n, x, t = map(int, input().split()) y = int(n / x) if n % x == 0: time = y * t else: time = (y + 1) * t print(time)" p02989,s102488305,Accepted,"N=int(input()) List = list(map(int, input().split())) List.sort() divideNum=N//2 print(List[divideNum] - List[divideNum-1])" p04043,s433524063,Wrong Answer,"a=input().split() print('YES'if a.count('5')==2 and a.count('7')==1 else'No')" p02760,s730924889,Accepted,"a = [] b = [] ans = 'No' for i in range(3): a.extend([int(s) for s in input().split()]) n = int(input()) for j in range(n): value = int(input()) b.append(value) if value in a: a[a.index(value)] = '*' if a[0] == a[1] == a[2] or a[3] == a[4] == a[5] or a[6] == a[7] == a[8] or a[0] == a[4] == a[8]: ans = 'Yes' if a[0] == a[3] == a[6] or a[1] == a[4] == a[7] or a[2] == a[5] == a[8] or a[2] == a[4] == a[6]: ans = 'Yes' print(ans)" p02727,s178965948,Accepted,"from heapq import heappop, heappush x,y,a,b,c = map(int, input().split()) aa = sorted(map(int, input().split()), reverse=True) bb = sorted(map(int, input().split()), reverse=True) cc = sorted(map(int, input().split()), reverse=True) dd = [] for i in aa[:x]: heappush(dd,i) for i in bb[:y]: heappush(dd, i) for i in range(c): heappush(dd, cc[i]) heappop(dd) print(sum(dd)) " p03761,s320647832,Accepted,"from collections import defaultdict n=int(input()) s0=list(input()) answer_dic=defaultdict(int) for s in s0: answer_dic[s]+=1 for i in range(n-1): si=list(input()) tmp_dic=defaultdict(int) for s in si: tmp_dic[s]+=1 for s in answer_dic: answer_dic[s]=min(answer_dic[s],tmp_dic[s]) #print(answer_dic) answer_list=sorted(list(answer_dic.items())) #print(answer_list) answer_str=[] for c,i in answer_list: for ii in range(i): answer_str.append(c) print("""".join(answer_str))" p02547,s904887589,Accepted,"N = int(input()) counter =0 for i in range(N): D = list(map(int, input().split(' '))) if (D[0]==D[1]): counter = counter+1 else: counter = 0 if (counter==3): print('Yes') exit(0) print('No')" p03817,s683389606,Accepted,"x = int(input()) print(x // 11 * 2 + (x % 11 >= 7) + (x % 11 > 0)) " p03324,s910265044,Wrong Answer,"d,n=map(int,input().split()) print(n*(100**d)) " p02618,s995687872,Wrong Answer,"d=int(input()) c=list(map(int,input().split())) c_days=[0]*26 fir_ans=0 for i in range(d): s=list(map(int,input().split())) num=max(s) fir_ans+=num n=s.index(num) c_days[n]=i+1 for l in range(26): los=c[l]*(i+1-c_days[l]) fir_ans-=los print(fir_ans)" p02700,s034099694,Accepted,"A, B, C, D = map(int, input().split()) import math A_attack = math.ceil(C / B) B_attack = math.ceil(A / D) if A_attack <= B_attack: print(""Yes"") else: print(""No"")" p02818,s542637452,Accepted,"a, b, k = map(int, input().split()) if a >= k: print(a - k, b) else: print(0, max(0, b - k + a))" p03351,s018201521,Accepted,"a, b, c, d = map(int, input().split()) ans = max(abs(a - b), abs(b - c)) ans = min(ans, abs(a - c)) if ans > d: print(""No"") else: print(""Yes"")" p02993,s572197319,Accepted,"s=list(input()) for i in range(len(s)-1): if s[i] == s[i+1]: print('Bad') break else: print('Good')" p02924,s700569506,Wrong Answer,"n = int(input()) print(n*(n-1)/2)" p03438,s999680979,Wrong Answer,"import sys import math # noqa import bisect # noqa import queue # noqa def input(): return sys.stdin.readline().rstrip() def main(): _ = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) D = [b - a for a, b in zip(A, B)] neg = 0 pos = 0 for d in D: if d < 0: neg -= d else: pos += d if pos < neg * 2: print(""No"") else: print(""Yes"") if __name__ == '__main__': main() " p02963,s196551918,Wrong Answer,"import sys import math # noqa import bisect # noqa import queue # noqa def input(): return sys.stdin.readline().rstrip() if __name__ == '__main__': S = int(input()) r = S // 1000000000 m = S % 1000000000 print(0, 0, 1000000000, 1, r + 1, 1000000000 - m)" p03721,s151443999,Accepted,"n, k = map(int, input().split()) a = [0] * n b = [0] * n sum = 0 arr = [] for i in range(n): a[i], b[i] = map(int, input().split()) arr_list = list(zip(a, b)) arr_list = sorted(arr_list) # print(arr_list) for i in range(n): sum += arr_list[i][1] # print(sum, arr_list[i]) if sum >= k: answer = arr_list[i][0] break print(answer) " p03150,s103486986,Accepted,"import re s = input() pattern={ '.*keyence' ,'k.*eyence' ,'ke.*yence' ,'key.*ence' ,'keye.*nce' ,'keyen.*ce' ,'keyenc.*e' ,'keyence.*' } for p in pattern: if re.fullmatch(p, s): print('YES') break else: print('NO')" p03986,s801678018,Accepted,"X = input() N = len(X) tcnt_l = 0 scnt_l = 0 for i in range(N): if X[i] == ""T"" and scnt_l == 0: tcnt_l += 1 elif X[i] == ""S"": scnt_l += 1 else: scnt_l -= 1 tcnt_r = 0 scnt_r = 0 for i in range(N-1,-1,-1): if X[i] == ""S"" and tcnt_r == 0: scnt_r += 1 elif X[i] == ""T"": tcnt_r += 1 else: tcnt_r -= 1 print(tcnt_l+scnt_r) " p03785,s424541253,Accepted,"#!/usr/bin/env python3 _, c, k, *t = map(int, open(0).read().split()) t.sort() n = 0 f = t.pop(0) p = 1 for i in t: if i > f + k or p >= c: n += 1 p = 1 f = i else: p += 1 print(n + (c > 0)) " p03696,s041217294,Accepted,"N=int(input()) S=input() a=0 b=0 cnt=0 for i in range(N): if S[i]==')': b+=1 else: a+=1 cnt=max(cnt,b-a) A='('*cnt+S d=A.count(')') e=A.count('(') f=e-d print(A+')'*f)" p02948,s386096652,Accepted,"import heapq n, m = map(int, input().split()) num = sorted([list(map(int, input().split())) for i in range(n)], key = lambda x: x[0]) s = [] j = 0 count = 0 heapq.heapify(s) for i in range(1, m + 1): while (j < n and num[j][0] <= i): heapq.heappush(s, num[j][1] * (-1)) j += 1 if(len(s)): count += heapq.heappop(s) * (-1) print(count) " p03109,s604743136,Accepted,"y, m, d = map(lambda x: int(x), input().split('/')) if m <= 4: print('Heisei') else: print('TBD')" p03639,s795898034,Accepted,"N = int(input()) a = list(map(int, input().split())) odd = 0 mul2 = 0 mul4 = 0 for i in a: if i % 2 == 1: odd += 1 elif i % 4 == 0: mul4 += 1 else: mul2 += 1 if mul2: if odd <= mul4: print(""Yes"") else: print(""No"") else: if odd <= mul4 + 1: print(""Yes"") else: print(""No"") " p03681,s356882217,Wrong Answer,"n, m = map(int, input().split()) mod = 10 ** 9 + 7 def permitation(x): res = 1 for i in range(1, x + 1): res = res * i % mod return res pn = permitation(n) pm = permitation(m) if n == m: res = pn * pm * 2 % mod print(res) elif n == m - 1 or n == m + 1: res = pn * pm % mod print(res) else: print(-1) " p02613,s401809667,Accepted,"from collections import defaultdict n = int(input()) s = [input() for _ in range(n)] table = defaultdict(int) for i in s: table[i] += 1 for j in [""AC"", ""WA"", ""TLE"", ""RE""]: print(j+"" ""+""x""+"" ""+str(table[j]))" p02958,s662008167,Accepted,"N= int(input()) p=list(map(int,input().split())) q=sorted(p) count=0 for i in range(len(p)): if p[i]!=q[i]: count += 1 #print(N,p,q,count, sep=""\n"") #zipを使う count=0 for a,b in zip(p,q): if a!=b: count += 1 #print(N,p,q,count, sep=""\n"") print('YES' if count<=2 else 'NO') " p03730,s327951281,Accepted,"import sys a,b,c=map(int,input().split()) for i in range(1,b+1): if a*i%b==c: print(""YES"") sys.exit() else: continue print(""NO"")" p03679,s275802463,Accepted,"def solve(): x, a, b = map(int, input().split()) if b <= a: print('delicious') elif a < b <= a + x: print('safe') else: print('dangerous') if __name__ == ""__main__"": solve()" p03371,s328117087,Accepted,"a, b, c, x, y = map(int, input().split()) ans = 0 if a + b > c * 2: d = min(x, y) ans += c * d * 2 x -= d y -= d if x > 0: if a > c * 2: ans += x * c * 2 else: ans += x * a if y > 0: if b > c * 2: ans += y * c * 2 else: ans += y * b print(ans) " p02660,s157327018,Accepted,"from itertools import count # 素因数分解 def prime_factors(n): i = 2 while i * i <= n: if n % i: i += 1 else: n //= i yield i if n > 1: yield n from collections import Counter c = Counter(prime_factors(int(input()))) res = 0 for cnt in c.values(): for i in count(1): if cnt < 0: break cnt -= i res += 1 res -= 1 print(res) " p02725,s469862857,Accepted,"k, n = map(int, input().split()) x = list(map(int, input().split())) dist = [x[i] - x[i - 1] for i in range(1, n)] dist.append(x[0] + k - x[n - 1]) # print(len(dist)) ans = k - max(dist) print(ans)" p03220,s195883911,Accepted,"#入力(後でいじる) def pin(type=int): return map(type,input().split()) #どっかで最悪計算量の入力データを用意する関数を作ろう? """""" """""" #solution: #潜 影 蛇 手 ! ! N=int(input()) T,A=pin() H=[i for i in pin()] c=(T-A)/0.006 HH=[abs(h-c) for h in H] #print(c,HH) print(HH.index(min(HH))+1)" p02918,s254924345,Accepted,"n, k = map(int, input().split()) s = list(str(input())) unhappy = 0 for i in range(n - 1): if s[i] != s[i + 1]: unhappy += 1 print(n - unhappy - 1 + min(2 * k, unhappy))" p03011,s130187764,Accepted,"a,b,c = map(int,input().split()) ans = min(b+c,c+b,a+c,c+a,a+b,b+a) print(ans)" p03208,s000948487,Accepted,"import sys def main(): input = sys.stdin.readline N,K=map(int, input().split()) H=[int(input()) for _ in range(N)] H.sort() ans=10**12 for i in range(N): if i+K-1 >= N: break ans = min(ans, H[i+K-1]-H[i]) print(ans) if __name__ == '__main__': main()" p03659,s029093123,Accepted,"n = int(input()) a = list(map(int, input().split())) l = [0 for i in range(n+1)] r = [0 for i in range(n+1)] for i in range(1, n+1): l[i] = l[i-1] + a[i-1] r[-(i+1)] = r[-i] + a[-i] ans = 10e+12 for i in range(1, n): ans = min(ans, abs(l[i] - r[i])) print(ans)" p02678,s852163696,Accepted,"from collections import deque n, m = map(int, input().split()) graph = [[] for _ in range(n)] for _ in range(m): a, b = map(int, input().split()) graph[a - 1].append(b - 1) graph[b - 1].append(a - 1) ans = [-1] * (n - 1) used = [0]*n used[0] = 1 que = deque([0]) while que: posi = que.popleft() for p in graph[posi]: if not used[p]: que.append(p) ans[p-1] = posi+1 used[p] = 1 print('Yes') print(*ans, sep='\n')" p02873,s521787079,Wrong Answer,"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(data) print(sum(data))" p02786,s412799832,Accepted,"h = int(input()) def cal(h): if h == 1: return 1 return 2*cal(int(h/2)) + 1 print(cal(h))" p03161,s773188961,Accepted,"from sys import stdin import numpy as np def main(): #入力 readline=stdin.readline inf=10**10 n,k=map(int,readline().split()) h=np.array(list(map(int,readline().split())),dtype=np.int64) dp=np.full(n,inf,dtype=np.int64) dp[0]=0 for i in range(n-1): end=min(n,i+k+1) sa=np.abs(h[i]-h[i+1:end]) dp[i+1:end]=np.minimum(dp[i+1:end],dp[i]+sa) print(dp[n-1]) if __name__==""__main__"": main()" p03319,s838143000,Accepted,"N,K = map(int,input().split()) A = list(map(int,input().split())) print(-(-(N-1)//(K-1)))" p03861,s950855289,Wrong Answer,"a,b,c = map(int,input().split()) print((b-a+1)//c)" p02792,s044668461,Accepted,"import numpy as np def main(): N = np.array([str(i) for i in range(1,int(input())+1)]) C = np.zeros((10,10), dtype=np.int) ans = 0 # C[i][j](0 <= i,j <= 9)のテーブルを構築する: O(N) for n in N: C[int(n[0])][int(n[-1])] += 1 for i in range(1,9+1): for j in range(1,9+1): ans += C[i][j] * C[j][i] print(ans) if __name__ == '__main__': main()" p03289,s538691999,Accepted,"s=list(input()) if s[0]==""A"" and s[2:len(s)-1].count(""C"")==1: s[0]=""a"" s[s.index(""C"")]=""c"" if """".join(s).islower(): print(""AC"") else: print(""WA"") else: print(""WA"")" p03434,s751217364,Accepted,"#!/usr/bin/env python3 def main(): n = int(input()) l = list(map(int, input().split())) l.sort(reverse=True) alice = l[0::2] bob = l[1::2] print(sum(alice)-sum(bob)) if __name__ == '__main__': main()" p02606,s239771964,Accepted,"L, R, d = map(int, input().split()) ret = 0 for i in range(L, R + 1) : if i % d == 0 : ret += 1 print(ret)" p02596,s399872471,Wrong Answer,"import io import sys _INPUT = """"""\ 999983 """""" sys.stdin = io.StringIO(_INPUT) K = int(input()) x = 7 % K s = set() count = 0 while(True): count += 1 if x in s: print(-1) break else: s.add(x) if x == 0: print(count) break x = (10*x+7) % K " p02628,s743538026,Accepted,"# -*- coding: utf-8 -*- n, k = map(int, input().split()) p = list(map(int, input().split())) p.sort() kingaku = 0 for i in range(k): kingaku += p[i] print(kingaku)" p02658,s224701799,Accepted,"import sys input = sys.stdin.readline N = int(input()) x = sorted(list(map(int, input().split()))) t = 1 for num in x: t = t * num if t > 10 ** 18: print(-1) sys.exit() if (t > 10 ** 18): print(-1) else: print(t) " p03208,s365024672,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(ans, h[k+i-1]-h[i]) print(ans)" p04012,s803318684,Accepted,"# https://atcoder.jp/contests/abc044/tasks/abc044_b w = list(input()) for token in w: if w.count(token) % 2 != 0: print(""No"") exit() print(""Yes"") " p03037,s026275225,Wrong Answer,"N, M = map(int, input().split(' ')) l_val, r_val = map(int, input().split(' ')) for i in range(M-1): l, r = map(int, input().split(' ')) l_val = max(l_val, l) r_val = min(r_val, r) print(r_val - l_val + 1)" p03289,s442443133,Accepted,"S = input() sl = [] ans = 'AC' for i in S: sl.append(i) if S[0] != 'A': ans = 'WA' if S[2:-1].count('C') != 1: ans = 'WA' if S[1:].replace(""C"",""c"",1).islower() == False: ans = 'WA' #print(sl) print(ans)" p03127,s805290896,Wrong Answer,"N = int(input()) A = list(map(int, input().split())) A.sort() print(A[0], A[1]) if A[0] == max(A): print(A[0]) else: a = A[0] b = 0 for i in range(N): if a != A[i]: b = A[i] break def gcd(x, y): if y == 0: return x return gcd(y, x%y) print(gcd(a, b)) " p03317,s746156404,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) print((N+K-3)//(K-1))" p02705,s917616266,Accepted,"import math LI = lambda: list(map(int,input().split())) MI = lambda: map(int,input().split()) yes = lambda: print(""YES"") no = lambda: print(""NO"") I = lambda: list(input()) J = lambda x: """".join(x) II = lambda: int(input()) SI = lambda: input() #---khan17---template t = int(input()) print(round(math.pi*t*2,2))" p03309,s425966903,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))))" p02777,s400743839,Accepted,"S, T = map(str,input().split()) A, B = map(int,input().split()) U = str(input()) if(S == U): A -= 1 elif(T == U): B -= 1 else: A B print(""{} {}"".format(A, B))" p02820,s425452821,Accepted,"num, back = map(int, input().split(' ')) r_point, s_point, p_point = map(int, input().split(' ')) t = input() j_dict = {'r': 'p', 's': 'r', 'p': 's'} score = {'r': r_point, 's': s_point, 'p': p_point, 'e': 0} result = [j_dict[i] for i in t] for i in range(back, num): if result[i] == result[i - back]: result[i] = 'e' print(sum(score[i] for i in result))" p03289,s882116493,Accepted,"s=input() if s[0]=='A' and s[2:-1].count('C')==1 and s[1:].replace('C','').islower(): print('AC') else: print('WA')" p02693,s245028534,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"")" p03059,s203939486,Wrong Answer,"a,b,t = map(int,input().split()) print(((t+0.5)//a)*b)" p02793,s180944568,Accepted,"import sys import fractions input = sys.stdin.readline N = int(input()) list_A = list(map(int, input().split())) ans = list_A[0] sum = 0 for i in range(1, N): ans = ans * list_A[i] // fractions.gcd(ans, list_A[i]) for a in list_A: sum += ans//a print(sum%(7+10**9))" p04045,s876940099,Wrong Answer,"# -*- coding : utf-8 -*- n, k = map(int, input().split()) D = input().split() D = list(map(int, D)) E = [0,1,2,3,4,5,6,7,8,9] for i in range(len(D)): E.remove(D[i]) for i in range(n, 10 * n+1): a = i //1000 m = i - a*1000 b = m //100 l = m - b*100 c = l // 10 d = l - c*10 if a in E and b in E and c in E and d in E: print (i) " p03592,s900504302,Accepted,"n, m, k = map(int, input().split()) ans = set() for i in range(m+1): cnt = i * n rev = m - i for j in range(n+1): ans.add(cnt + (rev - i) * j) if k in ans: print('Yes') else: print('No') " p03814,s032474836,Accepted,"s=list(input()) 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)" p02730,s283555999,Accepted,"s = input() t = s[::-1] n = len(s) // 2 ans = False if s[0:n] == t[0:n]: if s[0:n] == s[n+1:n*2+2]: ans = True if ans: print('Yes') else: print('No')" p03282,s078284393,Accepted,"s=input() for i in range(int(input())): if s[i]!='1': print(s[i]);break else: print(1)" p03289,s814603914,Accepted,"import sys s = input() l = len(s) if s[0] != ""A"": print(""WA"") sys.exit() ss = s[2:l-1] if ss.count(""C"") != 1: print(""WA"") sys.exit() cidx = ss.find(""C"")+2 sss = s[1:cidx]+s[cidx+1:] if sss.islower(): print(""AC"") sys.exit() print(""WA"") " p03455,s364414792,Accepted,"a,b = map(int,input().split()) if a*b % 2 == 0: print(""Even"") else: print(""Odd"")" p02724,s993491516,Accepted,"X = int(input()) a = X // 500 b = X % 500 c = b // 5 print(a * 1000 + c * 5)" p02838,s963871517,Wrong Answer,"mod = 1000000007 n = int(input()) a = list(map(lambda x: format(int(x), 'b'), input().split())) cnt = [0] * 65 for i in range(n): for j in range(len(a[i])): if a[i][j] == '1': cnt[len(a[i])-j-1] += 1 ans = 0 for i in range(len(cnt)-1, -1, -1): ans *= 2 ans %= mod ans += cnt[i] * (n-cnt[i]) print(ans)" p04012,s322367636,Accepted,"import collections s=list(input()) l=collections.Counter(s) a=all(v%2==0 for v in l.values()) print(""Yes"" if a==True else ""No"")" p02784,s236747963,Accepted,"h, n = map(int, input().split()) A = list(map(int, input().split())) print(""Yes"" if h <= sum(A) else ""No"")" p02917,s706132101,Accepted,"n = int(input()) b = list(map(int, input().split())) sum = b[0] + b[-1] for i in range(1, n-1): sum += min(b[i-1], b[i]) print(sum) " p03639,s894737676,Accepted,"N=int(input()) A=list(int(i)%4 for i in input().split()) b1=A.count(1)+A.count(3) b2=A.count(2) b4=A.count(0) print('Yes' if ( (b2==0 and (b1<=b4+1)) or b1<=b4) else 'No')" p02793,s496815852,Wrong Answer,"n=int(input()) a=list(map(int,input().split())) mod=10**9+7 from fractions import gcd def lcm(x,y): return x * y // gcd(x,y) def list_gcd(list): c=list[0] for i in list: c=gcd(c,i) return c def list_lcm(list): c=1 for i in list: c=lcm(c,i) return c a = [i//list_gcd(a) for i in a] a = [list_lcm(a) // i for i in a] print(sum(a))" p02779,s022673631,Accepted,"a = int(input()) ar = list(map(int,input().split("" ""))) if len(set(ar)) == a: print(""YES"") else: print(""NO"")" p03254,s622728046,Accepted,"from sys import stdin n, x = [int(x) for x in stdin.readline().split()] a_lst = sorted([int(x) for x in stdin.readline().split()]) s = 0 for i, a in enumerate(a_lst): s += a if s > x: print(i) exit() if s == x: print(i+1) else: print(i)" p02983,s922421449,Accepted,"l, r = list(map(int,input().split())) if r - l >= 2019: print(0) else: ll = l % 2019 rr = r % 2019 if rr < ll: print(0) else: keep = 2020 for i in range(ll, rr+1): for j in range(i+1, rr+1): keep = min((i*j)%2019, keep) print(keep)" p03317,s901448249,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 - a - 1 if K > b: a -= K - b - 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) " p03457,s642117311,Accepted,"N = int(input()) t = [] x = [] y = [] for i in range(N): tadd, xadd, yadd = map(int, input().split()) t.append(tadd) x.append(xadd) y.append(yadd) ans = 'Yes' for j in range(N): if t[j] % 2 != (x[j] + y[j]) % 2 or t[j] < abs(x[j]) + abs(y[j]): ans = 'No' break print(ans)" p02959,s960127924,Wrong Answer,"N=int(input()) A=list(map(int,input().split())) B=list(map(int,input().split())) ans=min(A[0],B[0]) B[0]-=ans for i in range(N-1): score=min(A[i+1],B[i]+B[i+1]) ans+=score B[i+1]-=min(0,score-B[i]) print(ans+min(B[N-1],A[N]))" p02732,s632107935,Wrong Answer,"import sys sys.setrecursionlimit(2147483647) n = int(input()) a = list(map(int,input().split())) ans = 0 for k in range(n): c = a[k] del a[k] for v in range(1,n+1): co = a.count(v) co2 = co - 1 if co >= 2: ans += co*co2/2 ans = 0 print(int(ans)) a.append(c)" p02836,s557352566,Wrong Answer,"S = input() s = list(S) ss = list(reversed(S)) ans = 0 for i in range(len(S)): if s[i] == ss[i]: ans += 1 print(ans)" p02756,s953844961,Wrong Answer,"s=input() q=int(input()) que=[list(map(str,input().split())) for i in range(q)] count=0 for i in que: if i[0]==""1"": count+=1 ans=[[],[]] for i in que: if i[0]==""1"": count-=1 else: if i[1]==""1"": ans[count%2].append(i[2]) else: ans[(count+1)%2].append(i[2]) print("""".join(ans[0])+s+"""".join(ans[1]))" p03160,s203262140,Accepted,"N=int(input()) h=list(map(int,input().split())) dp=[0]*N dp[1]=abs(h[1]-h[0]) for i in range(2,N): dp[i]=min(abs(h[i]-h[i-1])+dp[i-1],abs(h[i]-h[i-2])+dp[i-2]) print(dp[N-1])" p02665,s091747907,Wrong Answer,"N =int(input()) A = list(map(int,input().split())) leaf = sum(A) if A[0] != 0: print(-1) exit() v = [[0,a] for a in A] v[0][0] = 1 MAX = 2 for i in range(1,N+1): v[i][0] = min((v[i-1][0]-v[i-1][1])*2,leaf) leaf -= v[i][1] MAX *= 2 if v[N][0] != v[N][1]: print(-1) exit() ans = 0 for a,b in v: if a <= 0: print(-1) exit() ans += a print(ans) " p03543,s873595536,Accepted,"a,b,c,d=input() print(""Yes"" if a==b==c or b==c==d else ""No"")" p03944,s697079779,Wrong Answer,"w,h,n=map(int,input().split()) minx=0 maxx=w miny=0 maxy=h for i in range(n): x,y,a=map(int,input().split()) if a==1: minx=max(minx,x) elif a==2: maxx=min(maxx,x) elif a==3: miny=max(miny,y) elif a==4: maxy=min(maxy,y) print((maxx-minx)*(maxy-miny))" p03069,s093231316,Accepted,"N = int(input()) S = input() lb = 0 rw = S.count('.') ans = rw for s in S: if s == '.': rw -= 1 else: lb += 1 ans = min(ans, lb + rw) print(ans) " p03210,s051274545,Accepted,"# A N = int(input()) if N in [7,5,3]: print('YES') else: print('NO')" p02681,s561540252,Wrong Answer,"S = input() T = input() print(T[:-1]) if S == T[:-1]: print(""Yes"") else: print(""No"")" p02724,s638072540,Accepted,"X = int(input()) print((X//500*1000)+(X % 500)//5*5)" p03338,s288536141,Accepted,"n=int(input()) s=input() ans=0 for i in range(1,n-1): ans=max(ans,len(set(list(s[:i]) )&set(list(s[i:])) )) print(ans)" p02695,s771432289,Wrong Answer,"from itertools import combinations_with_replacement n, m, q = map(int, input().split()) A = combinations_with_replacement(range(1, m), n) L = [] for _ in range(q): L.append(list(map(int, input().split()))) r = 0 for a in A: t = 0 for l in L: if a[l[1] - 1] - a[l[0] - 1] == l[2]: t += l[3] if t > r: r = t print(r) " p03721,s091693931,Accepted,"#!/usr/bin/env pytHon3 # -*- coding: utf-8 -*- def main(): N, K = map(int, input().split()) AB = [list(map(int, input().split())) for _ in range(N)] AB.sort() for a, b in AB: K -= b if K <= 0: break print(a) if __name__ == ""__main__"": main() " p02983,s316364136,Wrong Answer,"l,r=map(int,input().split()) x=[] if r-l>=2018: print(0) else: for i in range(l,r+1): x.append(i%2019) x.sort() print(x[0]*x[1])" p03455,s992761149,Wrong Answer,"a = input().split() b = int(a[0])*int(a[1]) if b / 2 == 0: print('Even') else: print('Odd')" p02747,s290647924,Wrong Answer,"s = input() n = list(s) if n == [""h"", ""i""]: print(""Yes"") else: print(""No"")" p02554,s488167465,Accepted,"N = int(input()) mod = 10**9 + 7 ans = pow(10, N, mod) ans -= 2 * pow(9, N, mod) ans += pow(8, N, mod) ans %= mod print(ans)" p03408,s649954574,Accepted,"N = int(input()) S = [input() for _ in range(N)] M = int(input()) T = [input() for _ in range(M)] ans = 0 for s in set(S+T): ans = max(ans, S.count(s) - T.count(s)) print(ans)" p03262,s187500048,Wrong Answer,"import bisect N,X = map(int, input().split()) x = sorted(map(int, input().split())) bisect.insort(x,X) ans = [x[i+1]-x[i] for i in range(N-1)] if N ==1: print(x[1]-x[0]) else: print(min(ans))" p03286,s499593740,Accepted,"from math import log2 def main(): N = int(input()) if N == 0: print(0) return Ans = [] while N != 0: r = N%2 Ans.append(r) N = -1*( N // 2) print(*Ans[::-1],sep="""") return if __name__ == ""__main__"": main()" p02796,s837537242,Wrong Answer,"if __name__ == '__main__': n = int(input()) robots = [] for i in range(n): x, l = map(int, input().split()) robots.append((x, l, x - l, x + l)) robots = sorted(robots, key=lambda x: x[2]) ans = [] for i in range(n): if i == 0: ans.append(robots[i][3]) else: if robots[i][2] >= ans[-1]: ans.append(robots[i][3]) print(len(ans)) " p03475,s884499141,Wrong Answer,"import sys N = int(input()) CSF = [list(map(int, sys.stdin.readline().rsplit())) for _ in range(N - 1)] for i in range(N - 1): res = 0 for c, s, f in CSF[i:]: if res < s: res = s + c elif (res - s) % f == 0: res += c else: res += (res - s) % f + c print(res) print(0) " p02817,s077255764,Accepted,"if __name__ == '__main__': line=input().split() print(line[1],end="""") print(line[0],end="""")" p03679,s026283586,Accepted,"X,A,B=map(int,input().split()) if((B-A) <= 0): print(""delicious"") elif(X >= (B-A)): print(""safe"") else: print(""dangerous"") " p03962,s015537701,Accepted,"a = list(input().split()) print(len(set(a))) " p02691,s798297245,Accepted,"import collections N = int(input()) Heights = list(map(int, input().split())) i_s = [i + 1 + Heights[i] for i in range(N)] j_s = [j + 1 - Heights[j] for j in range(N)] CTR_i = collections.Counter(i_s) CTR_j = collections.Counter(j_s) i_value = CTR_i.keys() total = 0 for v in i_value: N_i = CTR_i[v] N_j = CTR_j[v] total += N_i * N_j print(total) " p04033,s974977270,Accepted,"a, b = map(int, input().split()) if a<0 and b<0: if (b-a)%2 ==0: print(""Negative"") else: print(""Positive"") elif a>0 and b>0: print(""Positive"") else: print(""Zero"")" p03243,s476482485,Accepted,"n = int(input()) h = n // 100 x = h * 100 + h * 10 + h print(x) if n <= x else print(x + 111) " p03481,s840504196,Accepted,"X, Y = map(int, input().split()) now = X count = 0 while now <= Y: now = now * 2 count += 1 print(count) " p02742,s712455302,Wrong Answer,"H,W = map(int, input().split()) ans = int((W // 2) * H) if W % 2 != 0: if H % 2 == 0: ans += H / 2 else: ans += (H + 1) / 2 print(int(ans))" p03137,s193855920,Accepted,"n,m=map(int,input().split()) a=sorted(list(map(int,input().split()))) b=[] for i in range(m-1): b.append(a[i+1]-a[i]) b_sort=sorted(b,reverse=1) print(sum(b_sort[n-1:])) " p02951,s725265768,Accepted,"a,b,c=map(int,input().split()) if c-(a-b)<0: print(0) else: print(b+c-a)" p03475,s154624747,Accepted,"import sys n, *CSF = list(map(int, sys.stdin.buffer.read().split())) C = CSF[::3] S = CSF[1::3] F = CSF[2::3] def solve(x): cur = 0 for i in range(x, n - 1): y = cur % F[i] if S[i] > cur: cur = S[i] + C[i] elif y == 0: cur += C[i] else: cur += (F[i] - y) + C[i] return cur for i in range(n - 1): print(solve(i)) print(0) " p02595,s090525661,Accepted,"# B n, d = map(int, input().split()) xy_l = [[int(x) for x in input().split()] for y in range(n)] d2 = d ** 2 ans = 0 for i in range(n): if d2 >= (xy_l[i][0]**2 + xy_l[i][1]**2): ans += 1 print(ans)" p04005,s158459001,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,b*c,c*a))" p02756,s587293379,Accepted,"from collections import deque import sys input=sys.stdin.readline s=deque([input().rstrip()]) q=int(input()) rev=0 for _ in range(q): qw=input().split() if qw[0]==""1"": rev+=1 else: f=qw[1] c=qw[2] if f==""1"": if rev%2==0: s.appendleft(c) else: s.append(c) else: if rev%2==0: s.append(c) else: s.appendleft(c) ans="""" for x in s: ans+=x if rev%2==0: print(ans) else: print(ans[::-1]) " p02983,s701256702,Accepted,"L, R = map(int, input().split()) if R - L >= 2019: ans = 0 else: l, r = L % 2019, R % 2019 ans = 2018 ** 2 for i in range(l, r+1): for j in range(i+1, r+1): x = (i*j) % 2019 ans = min(ans, x) print(ans)" p02701,s566542008,Accepted,"# ========= /\ /| |====/| # | / \ | | / | # | /____\ | | / | # | / \ | | / | # ========= / \ ===== |/====| # code def main(): n = int(input()) s = set() for i in range(n): t = input() s.add(t) print(len(s)) return if __name__ == ""__main__"": main()" p03161,s448115867,Accepted,"# -*- coding: utf-8 -*- """""" Created on Tue Jan 21 16:49:00 2020 @author: matsui """""" N,K=map(int,input().split()) h=[int(num) for num in input().split()] dp=[0]*N dp[1]=abs(h[0]-h[1]) def cost(h,N,K,dp): for i in range(2,N): dp[i]=min([abs(h[i]-h[j])+dp[j] for j in range(max(0, i-K), i)]) return dp[-1] print(cost(h,N,K,dp))" p03494,s930780899,Accepted,"N=int(input()) A=list(map(int,input().split())) ans=float('inf') for a in A: aa=list(reversed(format(a,'b'))) ai=aa.index('1') if ans>ai: ans=ai print(ans) " p03719,s731420517,Accepted,"import sys def solve(): input = sys.stdin.readline A, B, C = map(int, input().split()) print(""Yes"" if A <= C <= B else ""No"") return 0 if __name__ == ""__main__"": solve()" p03760,s430433235,Accepted,"o=input() e=input() lo, le=len(o), len(e) s='' for i in range(le): s=s+o[i]+e[i] if lo>le: s+=o[-1] print(s)" p02582,s384691513,Accepted,"def solve(s): res=0 for i in range(len(s)): if s[i]==""R"": res+=1 elif s[i]==""S"" and res>0: return res return res s=input() print(solve(s))" p02688,s956418267,Accepted,"n,k=map(int,input().split()) f=set() for i in range(k): d=int(input()) a=list(map(int,input().split())) for i in a: f.add(i) print(n-len(f))" p03679,s243035764,Wrong Answer,"x,a,b = map(int,input().split()) if (a+b) <= x: print('delicious') elif (b-a) <= x: print('safe') else: print('dangerous')" p03407,s042196083,Wrong Answer,"a,b,c = map(int,input().split()) print('Yes' if 2*a+b*2-c>=0 else 'No')" p02916,s298552977,Accepted,"N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) answer = 0 for i in range(N-1): if A[i+1]==A[i]+1: answer += C[A[i]-1] print(answer+sum(B))" p03323,s845921373,Wrong Answer,"a,b=map(int,input().split()) if a>8 or b>8: print("":("") else: print(""Yey!"") " p03797,s979531143,Wrong Answer,"n,m=map(int,input().split()) ans=n+(m-2*n)//4 if m-2*n>=0 else n print(ans)" p03779,s991353350,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"") import collections import math import itertools import heapq as hq x = ni() tmp = 0 for i in range(1,10**9): tmp+=i if tmp>=x: break print(i) " p02873,s381109358,Accepted,"S = input() N = len(S) ans = [0] * (N+1) for i in range(N): if S[i] == '<': ans[i+1] = ans[i] + 1 for i in range(N-1, -1, -1): if S[i] == '>' and ans[i] <= ans[i+1]: ans[i] = ans[i+1]+1 print(sum(ans)) " p03721,s486005062,Wrong Answer,"n,k = map(int,input().split()) count = 0 for i in range(n): a,b = map(int,input().split()) count +=b if count >=k: print(a) break else: pass" p03472,s203223686,Accepted,"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()) p=max(a) b.sort(reverse=True) ans=0 for i in range(n): if b[i]>=p: ans+=1 h-=b[i] if h<=0: print(ans) exit() x=(-h//p)*(-1) ans+=x print(ans) " p03767,s528439383,Accepted,"n=int(input()) a=list(map(int,input().split())) from collections import Counter c=Counter(a) ans,nokori=0,0 c=sorted(c.items(),reverse=True) for k,v in c: cnt=min((v+nokori)//2,n) n-=cnt ans+=int(k)*cnt nokori=(v+nokori)%2 print(ans)" p02630,s659459226,Accepted,"N = int(input()) List = list(map(int,input().split())) Q = int(input()) arr = [0 for i in range(10**5+1)] S = 0 for i in range(N): a = List[i] arr[a] += 1 S += int(a) for i in range(Q): a,b = map(int,input().split()) aa = arr[a] arr[b] += aa arr[a] = 0 S += int ( (b-a) * aa ) print(int(S))" p03030,s658850382,Wrong Answer,"n=int(input()) s=[] for i in range(n): tmp=input().split() tmp[1]=100-int(tmp[1]) s.append(tmp+[str(i+1)]) print(s) s=sorted(s) print(s) for i in range(n): print(s[i][-1]) " p02713,s606799248,Accepted,"import math N = int(input()) ans = 0 for i in range(1, N+1): for j in range(1, N+1): tmp = math.gcd(i, j) for k in range(1, N+1): ans += math.gcd(tmp, k) print(ans)" p02755,s902648674,Accepted,"a,b=map(int,input().split()) x1=int(a//0.08)+1 x2=int((a+1)//0.08) y1=int(b//0.1)+1 y2=int((b+1)//0.1) xx=[i for i in range(x1,x2)] for z in xx: if z>=y1 and z<=y2: print(z) exit() print(-1) " p02720,s107418634,Wrong Answer,"K = int(input()) X = 1 while K != 0: if X <= 9: K -= 1 X += 1 continue for i in range(len(str(X))-1): if int(str(X)[i+1]) - 1 <= int(str(X)[i]) <= int(str(X)[i+1]) + 1: K -= 1 X += 1 else: X += 1 print(X)" p03719,s160145819,Wrong Answer,"a, b, c = input().split(' ') int(a) int(b) int(c) if c >= a and c <= b: print ('Yes') else: print ('No')" p02916,s096635518,Accepted,"n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) c = list(map(int, input().split())) pnt = 0 cnt = -2 for i in a: if i == cnt+1: pnt += c[cnt-1] pnt += b[i-1] cnt = i print(pnt)" p03281,s854515315,Accepted,"n = int(input()) ans = 0 for x in range(1, n + 1, 2): d = 0 for i in range(1, x + 1, 2): if x % i == 0: d += 1 if d == 8: ans += 1 print(ans) " p02718,s265874967,Wrong Answer,"N, M = map(int, input().split()) A = list(map(int, input().split())) s = sum(A) th = s / (4*M) cnt = 0 for a in A: if a > th: cnt += 1 if cnt < M: print(""No"") else: print(""Yes"")" p02547,s304488739,Accepted,"N = int(input()) c1 = 0 c2 = 0 for i in range(N): d1,d2 = map(int,input().split()) if d1 == d2: c1 += 1 else: c1 = 0 if c1 == 3: c2 += 1 if c2 > 0: print(""Yes"") else: print(""No"")" p02873,s798483993,Wrong Answer,"s = input() left, right = [0,], [] a, b = 0, 0 for i in range(len(s)): a = a+1 if s[i] == '<' else 0 left.append(a) b = b+1 if s[-1*i] == '>' else 0 right.append(b) right.append(0) right.reverse() ans = sum(max(x, y) for x, y in zip(left, right)) print(ans)" p03545,s960342162,Accepted,"s = input() n = len(s) def dfs(i, f, sum_): if i == n-1: if sum_ == 7: print(f+'=7') exit() else: dfs(i+1, f+'+'+s[i+1], sum_+int(s[i+1])) dfs(i+1, f+'-'+s[i+1], sum_-int(s[i+1])) print(dfs(0, s[0], int(s[0])))" p03264,s462148083,Wrong Answer,"N=int(input()) if N%2==0: print((N/2)**2) else: print((N//2)*(N//2+1))" p02696,s637485120,Accepted,"A, B, N = map(int, input().split()) ans = 0 x = min(B-1, N) print((A*x)//B-A*(x//B)) " p03565,s645710323,Wrong Answer,"import re S=input().replace(""?"", ""."") T=input() ans="""" moji = len(T) for i in range(len(S)-len(T)+1): m = re.search(S[i:moji+i], T) if m is not None: ans = S[0:i] + T + S[i+moji-1:-1] ans = ans.replace(""."", ""a"") if ans: print(ans) else: print(""UNRESTORABLE"")" p03061,s770274694,Wrong Answer,"def gcd(a,b): a,b=max(a,b),min(a,b) return a if b==0 else gcd(b,a%b) def GCD(t): if len(t)==0: return 0 l=t[0] r=t[-1] for i in range(1,len(t)//2): l=gcd(l,t[i]) r=gcd(r,t[-i-1]) return gcd(l,r) n=int(input()) a=list(map(int,input().split())) m=1 for i in range(n): t=a[:i]+a[i+1:] m=max(GCD(t),m) print(m)" p03109,s180048903,Accepted,"s=input() if s<=""2019/04/30"": print(""Heisei"") else: print(""TBD"")" p02783,s076286197,Accepted,"H,A = map(int,input().split()) i = 1 while (A*i < H): i = i+1 print(i)" p03774,s477525805,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)] r=[] for i in ab: x1,y1=i[0],i[1] temp=[] for j in cd: x2,y2=j[0],j[1] temp.append(abs(x1-x2)+abs(y1-y2)) r.append(temp.index(min(temp))+1) print(*r,sep='\n')" p03206,s888984119,Accepted,"D=input() D=int(D) if D==25: print(""Christmas"") if D==24: print(""Christmas Eve"") if D==23: print(""Christmas Eve Eve"") if D==22: print(""Christmas Eve Eve Eve"") " p03773,s914205433,Accepted,"a,b=map(int,input().split()) print((a+b)%24) " p02910,s345462217,Accepted,"S = input() N=len(S) flag=1 for i in range(N): if i%2==0 and S[i]=='L': flag=0 elif i%2==1 and S[i]=='R': flag=0 print('Yes' if flag==1 else 'No') " p03785,s077537830,Wrong Answer,"N, C, K = map(int, input().split()) T = [0] * N for i in range(N): T[i] = int(input()) T = sorted(T) ans = 0 waiting = [] for t in T: if len(waiting) == C: ans += 1 waiting = [] elif len(waiting) > 0 and t > waiting[0] + K: ans += 1 waiting = [] else: waiting.append(t) else: ans += 1 print(ans)" p03324,s053388854,Wrong Answer,"A,N=map(int, input().split()) print(N*10^A)" p02765,s278561160,Wrong Answer,"n, r = map(int, input().split()) if n >= 10: print(r) else: print(r - 100 * (10-n))" p02811,s469739703,Accepted,"import sys import math import bisect stdin = sys.stdin mod = 10**9 + 7 ns = lambda: stdin.readline().rstrip() ni = lambda: int(ns()) na = lambda: list(map(int, stdin.readline().split())) sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)] k, x = na() if 500 * k >= x: print(""Yes"") else: print(""No"")" p02951,s848224242,Accepted,"a,b,c = map(int,input().split()) print(0 if b+c <=a else b+c-a)" p03319,s893053108,Accepted,"n, m = map(int, input().split()) a = list(map(int, input().split())) ans = 0 while n > 1: n -= m - 1 ans += 1 print(ans)" p03069,s412901557,Accepted,"N = int(input()) S = input() lb = 0 rw = sum([s == ""."" for s in S]) ans = rw for s in S: if s == ""."": rw -= 1 else: lb += 1 ans = min(ans, rw+lb) print(ans)" p02641,s002074138,Wrong Answer,"X, N = map(int, input().split()) if N > 0: p = set(map(int, input().split())) else: print(X) exit() if X not in p: print(X) exit() for i in range(1,50): if X-i not in p: print(X-i) exit() elif X+i not in p: print(X+i) exit() print(X) " p03386,s080708868,Accepted,"a,b,k=map(int,input().split()) x=[] y=[] if b-a=K: ans=abs(X)-D*K print(ans) else: M=K-N if M%2==0: ans=abs(X)-D*N else: ans=D*(N+1)-abs(X) print(ans)" p03327,s483826504,Accepted,"a = int(input()) if a < 1000: print('ABC') else: print('ABD')" p03759,s295296674,Accepted,"a,b,c = map(int, input().split()) if (b - a) == (c - b): print('YES') else: print('NO')" p03106,s765362714,Accepted,"def main(): a, b, k = map(int, input().split()) count = 0 for i in range(max(a, b), 0, -1): if a % i == 0 and b % i == 0: count += 1 if count == k: print(i) return if __name__ == ""__main__"": main() " p03339,s449049474,Wrong Answer,"N = int(input()) S = list(input()) ans = 0+S.count(""E"") now = S[0] e = ans w = 0 for i in range(1,N): if now == ""W"": w += 1 now = S[i] if now == ""E"": e -= 1 if w+e < ans: ans = w+e print(ans)" p02972,s835929829,Accepted,"N = int(input()) a = [0] a.extend(list(map(int, input().split()))) b = [0 for _ in range(N+1)] for i in reversed(range(1, N+1)): total = 0 for j in range(i+i, N+1, i): total ^= b[j] b[i] = total ^ a[i] ans_n = 0 ans_l = [] for i in range(N+1): if b[i]: ans_n += 1 ans_l.append(str(i)) print(ans_n) print(' '.join(ans_l)) " p03352,s825131814,Wrong Answer,"from math import sqrt x = int(input()) cnt = 0 l = [] for i in range(1, x + 1): for j in range(1, int(sqrt(i)) +1): for k in range(2, max(2, j) + 1): if j ** k == i: l.append(i) print(max(l))" p02699,s444673591,Accepted,"s, w = map(int, input().split()) if s <= w: print('unsafe') else: print('safe') " p02598,s082561733,Accepted,"def f(x): return sum([(i-1)//x for i in a])<=k def main(): l,r=0,10**9 while r-l>1: m=(l+r)//2 if f(m): r=m; else: l=m; print(r) if __name__=='__main__': n,k=map(int,input().split()) a=list(map(int,input().split())) main()" p03455,s619078301,Wrong Answer,"a,b = map(int,input().split()) num = a * b mod = num % 2 if mod == 0: print(""Even"") else: print(""0dd"") " p02939,s828015160,Accepted,"s = input() i = 0 ans = 0 while i < len(s)-1: # print(i, s[i], s[i+1], ans) if s[i] != s[i+1]: i += 1 ans += 1 else: if i == len(s)-2: i += 3 ans += 1 else: i += 3 ans += 2 if i == len(s)-1: ans += 1 print(ans) " p03494,s684281294,Accepted,"def check(X): for i in range(len(X)): if X[i] % 2 != 0: return False X[i] /= 2 return True N = int(input()) A = list(map(int, input().split())) ans = 0 while check(A): ans += 1 print(ans)" p02861,s902191117,Accepted,"import itertools N = int(input()) xy_list = [list(map(int, input().split())) for _ in range(N)] ans = 0 num = 0 for xy in itertools.permutations(xy_list): ans_pre = 0 for i in range(N-1): ans_pre += ((xy[i][0]-xy[i+1][0])**2 + (xy[i][1]-xy[i+1][1])**2)**(0.5) num += 1 ans += ans_pre print(ans/num)" p02754,s814706862,Wrong Answer,"# import sys input=sys.stdin.readline def main(): N,A,B=map(int,input().split()) if N%(A+B)<=A: print(A*N//(A+B)+N%(A+B)) else: print(A*N//(A+B)+A) if __name__==""__main__"": main() " p02843,s505727235,Accepted,"x = int(input()) if x >= 2000: print(1) exit() for i in range(1, 20): if (100 * i <= x) and (x <= 105 * i): print(1) exit() print(0) " p03799,s284739256,Accepted,"N, M = map(int, input().split()) print(N + (M - 2*N)//4 if N < M//2 else M // 2)" p02784,s913572306,Accepted,"H, N = map(int, input().split()) A = list(map(int, input().split())) if sum(A) >= H: print(""Yes"") else: print(""No"")" p03109,s806219128,Accepted,"s = input() ok = True if int(s[0:4]) > 2019: ok = False if int(s[0:4]) == 2019 and int(s[5:7] + s[8:]) > 430: ok = False if ok: print('Heisei') else: print('TBD')" p03211,s461282796,Accepted,"s = input() ans = 753 for i in range(len(s)-2): if abs(753-int(s[i:i+3])) < ans: ans = abs(753-int(s[i:i+3])) print (ans)" p04044,s382503800,Accepted,"MM = input().split() N = int(MM[0]) L = int(MM[1]) list1 = [] for i in range(N): a = input() list1.append(a) list1.sort() for i in list1: print(i,end='')" p03250,s205045297,Accepted,"A = list(map(int,input().split())) A.sort() print(A[2]*10 + A[0] + A[1]) " p02829,s593896135,Wrong Answer,"A = int(input()) B = int(input()) L = A + B print(5 - L)" p02933,s352706415,Accepted,"a=int(input()) s=input() if a>=3200: print(s) else: print(""red"")" p03338,s293405705,Accepted,"def main(): N = int(input()) S = input() ans = 0 for i in range(1, N): X = set(S[:i]) Y = set(S[i:]) ans = max(ans, len(X & Y)) print(ans) main() " p02554,s217672508,Accepted,"n = int(input()) ten = 1 eight = 1 nine = 1 for i in range(n): ten *= 10 ten = ten%(10**9 + 7) eight *= 8 eight = eight%(10**9 + 7) nine *= 9 nine = nine%(10**9 + 7) print((ten+eight-(2*nine))%(10**9 + 7))" p02682,s132937067,Accepted,"a,b,c,k=map(int, input().split()) print(k if a>=k else a if a+b>k>a else 2*a+b-k)" p02993,s113191055,Accepted,"import sys s = [int(n) for n in list(input())] for i in range(3): if s[i] == s[i+1]: print('Bad') sys.exit(0) print('Good')" p03211,s324677913,Wrong Answer,"s=list(input()) t=[int(a) for a in s] n=int(len(t)) ans=0 b=0 list1=[] s=1000 for i in range(n-2): u=[t[i],t[i+1],t[i+2]] v="""".join(map(str, u)) w=int(v)-753 list1.append(w) u=int(len(list1)) for i in range(u-1): if abs(list1[i])-abs(s)<0: s=list1[i] else : pass print(abs(s))" p03438,s293044511,Accepted,"n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) cnt = 0 for i in range(n): if a[i] < b[i]: cnt += (b[i] - a[i]) // 2 else: cnt -= (a[i] - b[i]) print(""Yes"" if cnt >= 0 else ""No"") " p03435,s211443799,Accepted,"C = [list(map(int, input().split())) for _ in range(3)] # a1=0と仮定すると、b1=C[0][0], b2=C[0][1], b3=C[0][2] # a2=C[1][0]-b1=C[1][1]-b2=C[1][2]-b3 # a3=C[2][0]-b1=C[2][1]-b2=C[2][2]-b3 b1, b2, b3 = C[0][0], C[0][1], C[0][2] if (C[1][0]-b1 == C[1][1]-b2 == C[1][2]-b3) and (C[2][0]-b1 == C[2][1]-b2 == C[2][2]-b3): print(""Yes"") else: print(""No"")" p03721,s054546832,Accepted,"N, K = map(int, input().split()) ab = [list(map(int, input().split())) for _ in range(N)] ab.sort() n = 0 for i in range(N): if n + ab[i][1] < K: n += ab[i][1] else: print(ab[i][0]) break" p03059,s017212751,Accepted,"a,b,t=map(int,input().split()) print(t//a*b)" p02935,s238191400,Accepted,"n=int(input()) v=sorted(list(map(int,input().split()))) s=v[0] for i in range(1,n): s=(s+v[i])/2 print(s)" p03338,s828159638,Wrong Answer,"N = int(input()) S = input() sp = N - 1 ans = 0 for i in range(1,(sp+1)//2+1): cnt = 0 zenhan = list(set(S[:i])) kouhan = list(set(S[i:])) for j in zenhan: if kouhan.count(j) == 1: cnt += 1 else: ans = max(ans,cnt) print(ans)" p02606,s749340958,Wrong Answer,"l,r,d=map(int,input().split()) ans=0 for i in range(l,r+1): if i%d: ans+=1 print(ans) " p03607,s157724442,Accepted,"from collections import deque n = int(input()) a = [int(input()) for _ in range(n)] da = deque(sorted(a)) dans = deque() dans.append(da.popleft()) for _ in range(1,n): if len(dans) == 0: dans.append(da.popleft()) else: dlast = dans.pop() daleft = da.popleft() if dlast != daleft: dans.append(dlast) dans.append(daleft) print(len(dans)) " p02767,s856441821,Accepted,"#abc156 c n=int(input()) x=list(map(int,input().split())) s=min(x) b=max(x) ans=100100100 for i in range(s,b+1): hp=0 for j in x: hp+=(i-j)**2 if hp= a: print('OK') else: print('NG')" p03433,s576895235,Accepted,"print(""Yes"" if int(input())%500<=int(input()) else ""No"")" p03632,s220427687,Wrong Answer,"A, B, C, D = map(int, input().split()) print(max(min(C, D)-max(A, B), 0))" p02602,s142639363,Accepted,"import sys, math if(__name__ == ""__main__""): N, K = map(int, input().strip().split() ) AList = list( map(int, input().strip().split() ) ) """""" i = K+1 , K+2 ,..., N score[i] = i * i-1 * ...* (i-K+1) score[i]/score[i-1] = i / (i-K) """""" for i in range(K, N): if(AList[i] > AList[i-K]): print(""Yes"") else: print(""No"") " p03105,s571863919,Accepted,"A,B,C=list(map(int,input().split())) print(min(B//A,C))" p03624,s139208267,Accepted,"s=input() a=[chr(i) for i in range(ord(""a""),ord(""z"")+1) if chr(i) not in s] print(""None"" if len(a)==0 else a[0])" p03221,s464346807,Accepted,"N, M = map(int, input().split()) V = [[] for _ in range(N)] ans = [0] * M for i in range(M): p, y = map(int, input().split()) V[p-1].append((y, i)) for i, v in enumerate(V, start=1): v.sort() for k, (y, j) in enumerate(v, start=1): ans[j] = format(str(i), ""0>6"") + format(str(k), ""0>6"") for a in ans: print(a)" p03208,s920163345,Accepted,"n, k = map(int, input().split()) h = [] for _ in range(n): h.append(int(input())) h.sort() # answer = min(h[k - 1] - h[0], h[-1] - h[-k]) # print(answer) answer = float('inf') for i in range(n - k + 1): cost = h[k - 1 + i] - h[i] # print(h[i:k+i]) if answer > cost: answer = cost print(answer)" p03095,s295363983,Accepted,"from collections import Counter n = int(input()) S = input() counts = Counter(S) mod = int(1e9) + 7 ans = 1 for count in counts.values(): ans *= (count + 1) ans %= mod ans -= 1 print(ans) " p03469,s552508581,Accepted,"s = input() print(""2018""+s[4:])" p03472,s851980582,Accepted,"import math n,h = map(int ,raw_input().split()) ais = [map(int, raw_input().split()) for _ in range(n)] ais.sort(key = lambda x: (-x[1],x[0])) cumul = 0 r = +float('inf') m = max(ais)[0] for i in range(-1,len(ais)): if i >= 0: cumul += ais[i][1] if cumul >= h: r = min(r, (i+1)) break else: r = min(r, i+1 + math.ceil(abs(h - cumul) / float(m))) print int(r)" p03821,s092104140,Wrong Answer,"n = int(input()) l = [] for i in range(n): a, b = map(int, input().split()) a %= b l.append([a, b]) ans = 0 for i in range(1, n)[::-1]: ans += (l[i][1] - l[i][0]) l[i-1][0] += ans l[i-1][0] %= l[i-1][1] ans += (l[0][1] - l[0][0]) print(ans)" p03852,s935565972,Accepted,"c = input() if c in ""aiueo"": print(""vowel"") else : print(""consonant"")" p02766,s031313060,Accepted,"import numpy as np import math n,k = str(input()).split() if int(n) == 0: print(1) else: ans = np.log(int(n))/np.log(int(k)) print(int(ans)+1)" p03419,s383910043,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))" p02820,s589206617,Accepted,"N,K = map(int, input().split()) R,S,P = map(int, input().split()) T = input() score = 0 back = 0 for fst in range(K): index = fst while True: ch = T[index] if ch != back: back = ch if ch == ""r"": score += P elif ch == ""p"": score += S else: score += R else: back = 0 index += K if index >= N: break back = 0 print(score) " p03835,s880692508,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 and x+y+z == s: ans += 1 print(ans) " p02725,s310229460,Accepted,"k,n=map(int,input().split()) a=list(map(int,input().split())) dis=[] for i in range(len(a)-1): dis.append(a[i+1]-a[i]) dis.append(a[0]+k-a[n-1]) print(str(k-max(dis)))" p02768,s878473963,Accepted,"n,a,b=map(int,input().split()) mod=10**9+7 bunbo=1 bunshi=1 for i in range(1,max(a+1, b+1)): bunbo*=i bunshi*=n-i+1 bunshi%=mod bunbo%=mod if i==a: comba=bunshi*(pow(bunbo,mod-2,mod)) if i==b: combb=bunshi*(pow(bunbo,mod-2,mod)) print((2**n-1-comba-combb)%mod)" p02994,s589945470,Accepted,"N,L=map(int,input().split()) l=[L+i-1 for i in range(1,N+1)] MIN=l[0] for i in range(N): if abs(MIN)>abs(l[i]): MIN=l[i] print(sum(l)-MIN)" p02707,s691772603,Accepted,"n=int(input()) l=list(map(int,input().split())) k = [0]*n for i in range(len(l)): c = l[i] k[c-1] = k[c-1]+1 for j in range(len(k)): print(k[j])" p02601,s145981102,Accepted,"a,b,c = map(int,input().split()) k = int(input()) for i in range(k): if b<=a: b*=2 else: c*=2 if b>a and c>b: print('Yes') else: print('No')" p02730,s850891994,Accepted,"# coding: utf-8 # Your code here! import sys sys.setrecursionlimit(10**6) readline = sys.stdin.readline read = sys.stdin.read #n,m = [int(i) for i in read().split()] s = input() n = len(s) t = s[:(n-1)//2] u = s[(n-1)//2+1:] if s==s[::-1] and t==t[::-1] and u==u[::-1]: print(""Yes"") else: print(""No"") " p03162,s549252941,Accepted,"n = int(input()) dp = [[0 for _ in range(3)] for _ in range(n)] a, b, c = map(int, input().split()) dp[0][0] = a dp[0][1] = b dp[0][2] = c for i in range(1, n): abc = [int(x) for x in input().split()] for j in range(len(abc)): dp[i][j] = max(dp[i - 1][(j + 1) % 3] + abc[j], dp[i - 1][(j + 2) % 3] + abc[j]) print(max(dp[n - 1]))" p03339,s643359144,Accepted,"n = int(input()) s = input() res = n w = 0 e = 0 for i in range(n): if s[i] == ""W"": w += 1 else: e += 1 l_w = 0 l_e = 0 for i in range(n): if i == n - 1 and s[i] == ""E"": l_e += 1 tmp = l_w + (e - l_e) res = min(tmp, res) if s[i] == ""W"": l_w += 1 else: l_e += 1 print(res) " p03329,s600583342,Accepted,"N = int(input()) # dp[i] := i円引き出すのに必要な最小操作回数 dp = [float('inf')] * (N + 1) dp[0] = 0 operates = sorted([1, 6, 36, 216, 1296, 7776, 46656, 9, 81, 729, 6561, 59049]) for i in range(N): for ope in operates: if i + ope > N: break dp[i + ope] = min(dp[i + ope], dp[i] + 1) print(dp[N]) " p03317,s740543691,Accepted,"n, k = map(int, input().split()) *a, = map(int, input().split()) mar = k - 1 # max replacible count ret = 1 + (n - k + mar - 1) // mar print(ret) # 左端から長さKの区間をのりしろ1で貼り続ける # 最小値1を含む要素に重なる区間から順に操作を始めれば可能 # i = a.index(1) # mar = k - 1 # max replacible count # # le = (i + mar - 1) // mar # [0,i) # ri = (n - i - 1 + mar - 1) // mar # [i+1,n) # # print(le + ri) " p02888,s568081357,Accepted,"# -*- coding: utf-8 -*- import numpy as np from collections import deque import collections import itertools import bisect mod = 10 ** 9 + 7 N = int(input()) L = list(map(int, input().split())) L = sorted(L) count = 0 for i in range(len(L)): for j in range(i+1, len(L)): a = L[i] b = L[j] idx = insert_index = bisect.bisect_left(L, a+b) count += max(0, idx-j-1) print(count) " p03338,s793693745,Accepted,"n=int(input()) s=input() alphabet=[chr(i) for i in range(97,97+26)] ans=0 for i in range(1,n): s1=s[:i] s2=s[i:] cnt=0 for j in range(len(alphabet)): if s1.count(alphabet[j])>=1 and s2.count(alphabet[j])>=1: cnt+=1 if cnt>ans: ans=cnt print(ans)" p03543,s469757087,Accepted," n = int(input()) s = str(n) sl = list(s) if sl[0]==sl[1] and sl[1] ==sl[2]: print(""Yes"") elif sl[1]==sl[2] and sl[2] ==sl[3]: print(""Yes"") else: print(""No"")" p02917,s621047650,Wrong Answer,"n = int(input()) b = list(map(int,input().split())) a = [] a.append(b[0]) for i in range(n-2): tmp = max(a[i],b[i]) a.append(tmp) a.append(b[-1]) print(sum(a)) " p02690,s534247725,Accepted,"x = int(input()) flag = True for a in range(1, 1000): a5 = pow(a, 5) for b in range(-1000, 1000): b5 = pow(b, 5) if a5 - b5 == x and flag: print(a, b) flag = False " p03011,s242954467,Accepted,"p,q,r=map(int,input().split()) print(min(min((p+q),(p+r)),(q+r)))" p03438,s634643969,Accepted,"n = int(input()) a = list(map(int,input().split())) b = list(map(int,input().split())) s = 0 t = 0 for i in range(n): k = b[i] - a[i] if k < 0: s += -k elif k > 0: t += k//2 if s <= t: print(""Yes"") else: print(""No"")" p02922,s487497328,Wrong Answer,"A,B=map(int,input().split()) print(int(B/A)+1)" p03000,s114401169,Accepted,"n, x = map(int, input().split()) a = [ int(x) for x in input().split() ] cnt = 1 s = 0 for aa in a: s += aa if s <= x: cnt += 1 print(cnt) " p02860,s744610844,Accepted,"n = int(input()) s = input() if s[:n//2] == s[n//2:]: print('Yes') else: print('No')" p02678,s263159191,Wrong Answer,"# N 部屋の数 M通路の数 N, M = map(int, input().split()) field = [map(int, input().split()) for route in range(M)] print(field)" p03261,s084582263,Wrong Answer,"n = int(input()) l = [] for i in range(n): w = input() l.append(w) for k in range(n): if l[k-1][-1] == l[k][0]: for j in range(i): if l[k] == l[j]: flag = 0 break else: flag = 1 else: flag = 0 if(flag == 1): print('Yes') else: print('No')" p03486,s505486233,Accepted,"s = list(input()) t = list(input()) s.sort() t.sort(reverse=True) if(s < t): print('Yes') else: print('No') " p03557,s819482666,Accepted,"import bisect N = int(input(), 10) heads = list(sorted(map(int,input().split()))) bodies = list(map(int,input().split())) legs = list(sorted(map(int,input().split()))) cnt = 0 for body in bodies: # 頭は、体より小さくなければならない head_cnt = bisect.bisect_left(heads, body) # 足は、体より大きくなければならない leg_cnt = N - bisect.bisect_right(legs, body) cnt += head_cnt * leg_cnt # 組み合わせの掛け算 print(cnt) " p03672,s676731393,Accepted,"S = input() x = len(S) for i in range(0, x, 2): y = x - 2 - i if S[:y//2] == S[y//2 : y]: print(len(S[:y])) break" p03994,s004478557,Wrong Answer,"def main(): word = list(input()) operation = int(input()) cost = {} for i in range(26): cost[chr(ord(""a"") + i)] = ord(""z"") - ord(""a"") - i + 1 for i in range(len(word)): if cost[word[i]] <= operation: operation -= cost[word[i]] word[i] = ""a"" else: continue if 0 < operation: word[-1] = chr(ord(word[-1]) + operation % 26) print("""".join(word)) if __name__ == '__main__': main() " p03407,s668156174,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, A, C = map(int, readline().split()) print('Yes' if N + A >= C else 'No') " p02802,s363234673,Accepted,"N, M = map(int, input().split()) solve_problem = set() WA = [0 for _ in range(N)] ans = 0 penalty = 0 for i in range(M): p, S = input().split() if p in solve_problem: continue if S == 'AC': solve_problem.add(p) ans += 1 penalty += WA[int(p)-1] if S == 'WA': WA[int(p)-1] += 1 print('{} {}'.format(ans, penalty)) " p02818,s901354194,Wrong Answer,"A, B, K = map(int, input().split()) if A >= K: la = A - K lb = B else: la = 0 lb = A + B - K print(la, lb)" p04011,s451309588,Wrong Answer,"n=int(input()) k=int(input()) x=int(input()) y=int(input()) sum_=0 if n-k>=0: sum_=k*x+(n-k)*y else: sum_=k*x print(sum_)" p03109,s127423773,Accepted,"s = list(map(int, input().split('/'))) if s[1] <= 4: print('Heisei') else: print('TBD')" p02707,s429733363,Accepted,"n = int(input()) an = list(map(int, input().split())) an_map = [0] * n for ai in an: an_map[ai - 1] += 1 for ai_map in an_map: print(ai_map)" p02811,s212776101,Accepted,"k, x = map(int,input().split()) if k*500 >= x: print('Yes') else: print('No')" p02911,s061216859,Accepted,"N,K,Q=map(int,input().split()) check=[K-Q]*N for i in range(Q): A=int(input())-1 check[A]+=1 for i in range(N): print(""Yes"" if check[i]>0 else ""No"") " p04031,s769383177,Wrong Answer,"n = int(input()) a = list(map(int, input().split())) ans = 1e9 for p in a: sub = 0 for q in a: sub += pow(p - q, 2) ans = min(ans, sub) print(ans) " p02994,s414559400,Wrong Answer,"n, l = map(int, input().split()) pie = 0 comp = 300 for i in range(1, n+1): pie = pie + l + i - 1 if abs(l + i -1) < comp: comp = l + i -1 print(pie - comp) " p02681,s976312969,Accepted,"s = input() t = input() if s==t[:len(t)-1]: print('Yes') else: print('No')" p02732,s645747855,Accepted,"import sys myin = [x.rstrip() for x in sys.stdin.readlines()] n = int(myin[0]) a = [int(x) for x in myin[1].split()] cnt = [0] * (n+1) for v in a: cnt[v] += 1 tmp = 0 for c in cnt: tmp += c * (c-1) // 2 for v in a: print(tmp - cnt[v] + 1)" p02546,s362047318,Wrong Answer,"word = input() if word[-1] == ""s"": word_new =word[:-1] + ""es"" print(word_new) else: print(word + ""s"")" p02771,s538893696,Accepted,"a,b,c = map(int,input().split()) n=set([a,b,c]) if len(n)==2: print(""Yes"") else: print(""No"")" p03862,s722120906,Wrong Answer,"# coding: utf-8 n, x = map(int,input().split()) A = list(map(int,input().split())) S = sum(A) for i in range(n-1): s = A[i+1] + A[i] if s > x: A[i+1] -= s - x print(S - sum(A))" p02861,s968358461,Wrong Answer,"import math n=int(input()) c=[list(map(int,input().split())) for i in range(n)] a=0 for i in range(n): if i==0: a+=((c[-1][0]-c[0][0])**2+(c[-1][1]-c[0][1])**2)**(0.5) else: a+=((c[i][0]-c[i-1][0])**2+(c[i][1]-c[i-1][1])**2)**(0.5) ans=(a/n)*(n-1) print(ans)" p03331,s396396028,Accepted,"N = int(input()) my_array = [] for A in range (1, N): my_array.append(sum(map(int, str(A))) + sum(map(int, str(N - A)))) print(min(my_array))" p03339,s879018818,Accepted,"def main(): from itertools import accumulate n = int(input()) f = lambda x: 1 if x == ""W"" else 0 *s, = map(f, list(input())) t = list(accumulate(s)) u = t[-1] ans = n for i, (j, k) in enumerate(zip(s, t)): m = (k - j) + (n - 1 - i) - (u - k) ans = min(ans, m) print(ans) if __name__ == '__main__': main() " p02639,s237763498,Accepted,"x = [int(i) for i in input().split(' ')] ans = x.index(0) print(ans+1)" p03041,s370044196,Wrong Answer,"N,K=map(int,input().split()) a=input() b=list(a) c=b[K-1] b[K-1]='c'.lower() print(''.join(map(str,b)))" p02996,s848403175,Wrong Answer,"N = int(input()) data = [] for _ in range(N): A, B = map(int, input().split()) data.append([B, A]) data.sort() prefix_cost = [] current_cost = 0 for i in range(N): current_cost += data[i][1] prefix_cost.append(current_cost) for i in range(N): if not prefix_cost[i] <= data[i][0]: exit() print('Yes') " p02767,s910642545,Accepted,"N = int(input()) X = list(map(int, input().split())) X.sort() r = None for i in range(X[0], X[-1]+1): c = sum((m - i)**2 for m in X) if r is None or r > c: r = c print(r)" p02606,s583774769,Wrong Answer,"l, r, D = input().split() L=int(l) R=int(r) d=int(D) if L%d ==0: a=L else: while True: if L % d: break L += 1 a=L if R%d ==0: b=R else: while True: if R % d: break R =R-1 b=R if(b-a<1): print(0) else: print(int((b-a)/d)+1)" p03211,s810743394,Accepted,"s=input() n=0 ans=99999 for i in range(len(s)-2): n=int(s[i]+s[i+1]+s[i+2]) d=abs(753-n) ans=min(d,ans) print(ans)" p02910,s163807065,Accepted,"odd = ['R', 'U', 'D'] even = ['L', 'U', 'D'] S = list(input()) for i in range(len(S)): if i % 2 == 0 and S[i] not in odd: print('No') exit() elif i % 2 == 1 and S[i] not in even: print('No') exit() print('Yes')" p02912,s398754968,Accepted,"import heapq N, M = map(int, input().split()) A = [-int(x) for x in input().split()] heapq.heapify(A) for m in range(M): a = heapq.heappop(A) a = int(a/2) heapq.heappush(A, a) print(-sum(A)) " p03592,s221648855,Wrong Answer,"# 03 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, M, K = LI() if K == 0: print('Yes') exit() for i in range(N): for j in range(M): if i*(M-j) + j*(N-i) == K: print('Yes') exit() print('No') " p03352,s116500943,Accepted,"# まあ探索しましょうや 最低の2でも10回やりゃ1000越えるんだし ans = 0 x = int(input()) if x == 1: print(1) exit() for b in range(2, int(x * 0.5) + 1): p = 2 while True: if b ** p > x: break ans = max(ans, b ** p) p += 1 print(ans) " p03087,s079677869,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 r < 8: if slr[r] == slr[r-1]: ans -= 1 if slr[l] != slr[l-1]: ans += 1 print(ans)" p02754,s456815490,Wrong Answer,"N,A,B = map(int, input().split()) X = N//(A+B) Y = N%(A+B) if Y < B: print(A*X+Y) else: print(A*(X+1))" p02795,s013042661,Wrong Answer,"h=int(input()) w=int(input()) n=int(input()) print(min(h//n,w//n)+1)" p02708,s928339403,Accepted,"from math import factorial n, k = [int(i) for i in input().split()] mod = 10 ** 9 + 7 def s(n, m=0): # m~nの総和 global mod return (n * (n+1) // 2 - (n-m) * (n-m+1) // 2) % mod sm = 0 for i in range(k, n+1): sm = (sm + s(n, i) - s(i-1, i-1) + 1) % mod print((sm+1) % mod)" p03778,s993396496,Accepted,"w, a, b = map(int, input().split()) print(max(0, b - (a + w), a - (b + w))) " p02801,s256281279,Wrong Answer,print(str(ord(input())+1)) p03796,s310852642,Accepted,"n = int(input()) x = 1 for i in range(1,n+1): x=(i*x)%((10**9+7)) print(x)" p03449,s984952058,Accepted,"N = int(input()) A1 = list(map(int,input().split())) A2 = list(map(int,input().split())) R = [] for i in range(N): R.append(sum(A1[:i+1])+sum(A2[i:N])) print(max(R))" p03672,s057860932,Wrong Answer,"S = input() from collections import Counter C = Counter(S) ans = len(S) for c in S[::-1]: C[c] -= 1 ans -= 1 if all(v%2==0 for v in C.values()): print(ans) exit()" p04019,s958923538,Wrong Answer,"S=input() ans=""NO"" n=0 w=0 e=0 s=0 tate=0 yoko=0 for str in S: if str==""N"": n +=1 elif str==""E"": e +=1 elif str==""S"": s +=1 else: w +=1 if (n>0 and s>0) or (n==0 and s==0): tate=True if (e>0 and w>0) or (e==0 and w==0): yoko=True if tate and yoko: ans=""Yes"" print(ans)" p03146,s438802054,Accepted,"import sys s = int(input()) N = [s] while True: if s % 2 == 0: s = s // 2 N.append(s) else: s = 3 * s + 1 N.append(s) if N.count(s) > 1: print(len(N)) sys.exit()" p03150,s926102357,Accepted,"s=input() flag=False ans='keyence' for i in range(len(s)): for j in range(i,len(s)): if ans==s[:i]+s[j:]: flag=True break if flag: print(""YES"") else: print(""NO"")" p02684,s666292605,Accepted,"n,k = map(int,input().split()) A = list(map(int,input().split())) dp = [-1] * (n+1) B = [] f = 1 c = 0 ans = n bal = 0 while dp[f-1] == -1: dp[f-1] =c B.append(f) f = A[f-1] c +=1 t = B.index(f) if k>t: k -= t B = B[B.index(f):] k%=len(B) print(B[k]) else: print(B[k])" p02912,s442830164,Accepted,"import heapq as hp n,m=[int(x) for x in input().rstrip().split()] a=[-int(x) for x in input().rstrip().split()] hp.heapify(a) for i in range(m): now=hp.heappop(a) hp.heappush(a,-(-now//2)) print(-sum(a)) " p04033,s382750117,Wrong Answer,"import numpy a,b = map(int,input().split()) ans=a for i in range(b+1): ans = ans * (a+i) pm = numpy.sign(ans) if pm==0: print('zero') elif pm==1: print('Positive') else: print('Negative')" p03951,s754109933,Wrong Answer,"n = int(input()) s = list(input()) t = list(input()) ans = n * 2 if s == t: print(n) else: for i in range(n): if s[-i-1:] == t[:i+1]: ans -= 1 else: break print(ans) " p03693,s969805130,Accepted,"r, g, b = input().split() num = int(r + g + b) if num % 4 == 0: print('YES') else: print('NO')" p03011,s265801573,Wrong Answer,"a,b,c = sorted(map(int,input().split())) print(c-a) " p03221,s332191748,Wrong Answer,"N, M = map(int, input().split()) py = [] for i in range(M): p, y = map(int, input().split()) py += [[i, p, y]] py = sorted(py, key=lambda x:(x[1], x[2])) cnt = 0 pre = py[0][1] ans = [] for n, p, y in py: if pre != p: cnt = 1 pre = n else: cnt += 1 ans += [[n, str(p).zfill(6)+str(cnt).zfill(6)]] ans = sorted(ans, key=lambda x:x[0]) for _, n in ans: print(n) " p02792,s529992569,Accepted,"n = int(input()) ans = 0 numbers = [[0] * 10 for _ in range(10)] for i in range(1, n+1): ss = str(i) numbers[int(ss[0])][int(ss[-1])] += 1 for j in range(1, n+1): ss = str(j) ans += numbers[int(ss[-1])][int(ss[0])] print(ans) " p03803,s163112862,Wrong Answer,"a,b=map(int,input().split()) if a>b: print('Alice') elif a i: print(i) N -= i else: continue" p03625,s848021561,Accepted,"from collections import Counter input() lengths = tuple(map(int, input().split(' '))) counter = Counter(lengths) edges = [] for length in sorted(counter.keys(), reverse=True): if counter[length] >= 4: edges.append(length) edges.append(length) elif counter[length] >= 2: edges.append(length) if len(edges) >= 2: break edges.append(0) edges.append(0) edges.sort(reverse=True) print(edges[0] * edges[1]) " p02784,s374221483,Wrong Answer,"h,n=map(int,input().split()) A = list(map(int,input().split())) print(sum(A)) if h >sum(A): print('No') else: print('Yes') " p04043,s289971442,Accepted,"abc = input().split() d = abc[0] e = abc[1] f = abc[2] g = d + e + f g = int(g) a = 575 b = 557 c = 755 if g == a: print(""YES"") elif g == b: print(""YES"") elif g == c: print(""YES"") else: print(""NO"") " p03556,s950091764,Accepted,"N = int(input()) answer = 0 n = 1 while True: if n**2 <= N: answer = n**2 n += 1 else: break print(answer)" p03371,s151246398,Wrong Answer,"a,b,c,x,y = map(int, input().split()) if a>= c*2 and b >= c*2: print(max(x,y)*c*2) elif a>= c*2 and x >=y : print(x*c*2) elif b >= c*2 and y<=x: print(y*c*2) elif a + b < c*2: print(a*x+b*y) elif a+b >= c*2: if x > y: print(y*c*2+(x-y)*a) else: print(x*c*2+(y-x)*b)" p03150,s091838939,Accepted,"s=input() s_len=len(s) for i in range(s_len-1): for j in range(i,s_len): if s[:i]+s[j:]=='keyence': print('YES') exit() print('NO')" p03042,s369972276,Wrong Answer,"def resolve(): S = list(input()) front = int(''.join(S[:2])) back = int(''.join(S[2:])) if (0 == front or 0 == back): print('NA') return if (front <= 12 and back <= 12): print('AMBIGUOUS') return if (front > 12 and back <= 12): print('YYMM') return if (front <= 12 and back > 12): print('MMYY') return print('NA') resolve()" p03254,s933461446,Accepted,"N,x=map(int,input().split()) a=list(map(int,input().split())) a_sort=sorted(a,reverse=False) tot=0 if sum(a)==x: print(len(a)) elif sum(a)x: print(i) break" p03013,s986850312,Accepted,"MOD = 10 ** 9 + 7 N, M = map(int, input().split()) A = [int(input()) for _ in range(M)] A.append(N + 1) S = [0] * (N + 2) S[0] = 1 i = 1 for a in A: while i < a: S[i] = (S[i - 1] + S[i - 2]) % MOD i += 1 i += 1 print(S[N]) " p02630,s662676047,Accepted,"import sys input = sys.stdin.readline from collections import Counter N = int(input()) A = list(map(int, input().split())) S = sum(A) C = Counter(A) for _ in range(int(input())): b, c = map(int, input().split()) S -= C[b] * b S += C[b] * c C[c] += C[b] C[b] = 0 print(S) " p02972,s132364186,Wrong Answer,"import math n = int(input()) a = list(map(int,input().split())) sum = [0]*(n+1) for i in range(1,n+1): for k in range(1,math.floor(n/i)+1): j = int(k*i) sum[i] += a[j-1] L = [i+1 for i in range(n) if a[i] == 1] M=[str(a) for a in L] M="" "".join(M) print(len(M)) print(M)" p03073,s898371474,Accepted,"# coding: utf-8 import sys import numpy as np sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) S = np.array(list(sr()), np.int8) length = len(S) complete = np.arange(length) & 1 r1 = (S == complete).sum() r2 = (S != complete).sum() answer = min(r1, r2) print(answer) " p02922,s253943858,Wrong Answer,"''' INPUT SHORTCUTS N, K = map(int,input().split()) N ,A,B = map(int,input().split()) string = str(input()) arr = list(map(int,input().split())) N = int(input()) ''' A, B = map(int,input().split()) ans = 0 for i in range(21): if ((A*(i+1))-i)>=B: ans = i+1 break print(ans)" p04020,s229423614,Wrong Answer,"from collections import Counter,defaultdict,deque from heapq import heappop,heappush 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 = [inp() for _ in range(n)] res = 0 f = False for i,x in enumerate(a): if x%2: if f: res += 1 else: f = True else: f = False res += x//2 print(res)" p03067,s280663782,Accepted,"a,b,c=map(int,input().split()) if min(a,b) <= c <=max(a,b): print(""Yes"") else: print(""No"") " p02859,s756998262,Accepted,"n = int(input()) print(n*n)" p02818,s509590607,Accepted,"a,b,k = map(int,input().split()) takahashi = 0 aoki = 0 if a >= k: takahashi = a-k aoki = b else: takahashi = 0 aoki = b-k+a if aoki < 0: aoki = 0 print(takahashi,aoki)" p03076,s094961270,Accepted,"lis = [] ans = 0 for i in range(5): a = int(input()) amari = a%10 if a%10 == 0: amari = 10 lis.append([a, 10-amari]) lis = sorted(lis, key=lambda x:x[1]) #print(lis) for i in range(4): ans += lis[i][0] + lis[i][1] #print(ans) ans += lis[4][0] print(ans)" p03219,s949358726,Wrong Answer,"X, Y = map(int,input().split()) print(X + Y/2)" p03695,s064836369,Wrong Answer,"n = int(input()) a = list(map(int, input().split())) rate_list = [0, 0, 0, 0, 0, 0, 0, 0] perfect = 0 for i in range(n): rate = a[i]//400 if rate < 8: if rate_list[rate] == 0: rate_list[rate] += 1 else: perfect += 1 print('rate_list: ', rate_list) mini = max(sum(rate_list), 1) maxi = sum(rate_list)+perfect print(mini, maxi)" p03861,s842022067,Wrong Answer,"a,b,x = map(int,input().split()) tmp = 0 if a%x==0 or b%x==0: tmp += 1 print((b-a)//x+tmp)" p03012,s272254414,Accepted,"n=int(input()) w=list(map(int,input().split())) su =sum(w) ans = 1234567890 cnt =0 for i in range(n): cnt += w[i] ans = min(ans,abs(su-cnt - cnt)) print(ans)" p02639,s428473575,Accepted,"import sys def solve(): readline = sys.stdin.buffer.readline mod = 10 ** 9 + 7 x = list(map(int, readline().split())) print(x.index(0) + 1) if __name__ == '__main__': solve() " p03448,s070021077,Wrong Answer,"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*a + 100*b + 50*c == x: count += 1 print(count)" p02601,s048826251,Accepted,"a,b,c=map(int,input().split()) k=int(input()) count=0 while a>=b: b=b*2 count+=1 while b>=c: c=c*2 count+=1 if count<=k: print('Yes') else: print(""No"")" p03479,s938382088,Accepted,"x, y = map(int, input().split()) ans = 0 while x <= y: x *= 2 ans += 1 print(ans)" p03262,s973061636,Accepted,"from functools import reduce from fractions import gcd N,X=map(int,input().split()) x=[abs(X-int(i)) for i in input().split()] print(reduce(gcd,x))" p02880,s210181356,Accepted,"n = int(input()) count = 0 for i in range(1,10): for j in range(1,10): if n == i*j: count += 1 else: pass print(['No','Yes'][count != 0])" p03071,s305029426,Wrong Answer,"b = list(map(int, input().split())) if b[0]==b[1]: print(2*b[0]-1) else: print(2*max(b)-1)" p03854,s215350766,Accepted,"def reverse_str(s): return ''.join(list(s)[::-1]) words = list(map(reverse_str, 'dream dreamer erase eraser'.split())) S = reverse_str(input()) ok = True while S: for r in range(5, 8): tmp = S[:r] if tmp in words: # print(S, end=' => ') S = S[r:] # print(S) break else: ok = False break print('YES' if ok else 'NO') " p03592,s774180665,Accepted,"n, m, k = map(int, input().split()) for i in range(m+1): for j in range(n+1): #print((n - j) * i + (m - i) * j) if (n - j) * i + (m - i) * j == k: print(""Yes"") exit() print(""No"")" p02862,s232852746,Accepted,"mod = 10**9 + 7 X, Y = map(int, input().split()) if (X+Y) % 3 != 0: print(0) exit() a = (2*Y-X)//3 b = (2*X-Y)//3 if a < 0 or b < 0: print(0) exit() m = min(a, b) ifact = 1 for i in range(2, m+1): ifact = (ifact * i) % mod ifact = pow(ifact, mod-2, mod) fact = 1 for i in range(a+b, a+b-m, -1): fact = (fact * i) % mod print(fact*ifact % mod) " p02677,s367331572,Accepted,"import math a,b,h,m = map(int,input().split()) hour_deg = (h + m / 60) / 12 * 360 min_deg = (m / 60) * 360 deg_diff = abs(min_deg - hour_deg) ans = a**2 + b**2 - (2 * a * b * math.cos(math.radians(deg_diff))) print(math.sqrt(ans))" p03250,s504876463,Wrong Answer,"A, B, C = map(int, input().split()) print(max(A * 10 + B + C, A + B * 10 + C))" p02639,s639902696,Accepted,"num = list(map(float, input().split())) for i in range(5): if num[i] == 0: print(i + 1) break" p03264,s275348596,Wrong Answer,"k = int(input()) if k%2 == 0: print(k//2**2) else: print((k-1)*(k+1)//4)" p03035,s359546483,Accepted,"A, B = map(int,input().split()) if A < 6: print(0) elif A < 13: print(B//2) else: print(B)" p03309,s845066534,Accepted,"n = int(input()) a = list(map(int, input().split())) for i in range(n): a[i] -= i + 1 a.sort() b = a[n//2] print(b * (n//2) - sum(a[:n//2]) + sum(a[n//2:]) - b * (n - n//2))" p02933,s996192245,Accepted,"a=int(input()) s=input() if a>=3200: print(s) else: print(""red"")" p03723,s142188796,Accepted,"A, B, C = list(map(int, input().split())) ListA = [A]*10000 ListB = [B]*10000 ListC = [C]*10000 if A%2==1 or B%2==1 or C%2==1: print(0) exit() for i in range (1, 10000): ListA[i]= ListB[i-1]/2+ListC[i-1]/2 ListB[i]= ListA[i-1]/2+ListC[i-1]/2 ListC[i]= ListA[i-1]/2+ListB[i-1]/2 if ListA[i]%2==1 or ListB[i]%2==1 or ListC[i]%2==1: print(i) exit() print(-1)" p02700,s040818838,Accepted,"A, B, C, D = map(int, input().split()) while True: C -= B if C <= 0: print('Yes') break A -= D if A <= 0: print('No') break" p02725,s150147641,Accepted,"k, n = map(int, input().split()) a = list(map(int, input().split())) dist = [] for i in range(n-1): dist.append(a[i+1] - a[i]) dist.append(k-a[-1]+a[0]) print(k-max(dist)) " p03699,s353752942,Accepted,"N = int(input()) scores = [int(input()) for i in range(N)] not_multiple_of_ten = [i for i in scores if i % 10 != 0] max_score = sum(scores) if max_score % 10 != 0: print(max_score) else : if len(not_multiple_of_ten) == 0: print(0) else : print(max_score-min(not_multiple_of_ten))" p03160,s166199793,Wrong Answer,"n = int(input()) h = list(map(int,input().split())) dp = [1000001] * n dp[0] = 0 dp[1] = abs(h[1] - h[0]) def chmin(a, b): if a <= b: pass else: a = b return a for i in range(2, n): dp[i] = chmin(dp[i],dp[i - 2] + abs(h[i - 2] - h[i])) dp[i] = chmin(dp[i],dp[i - 1] + abs(h[i - 1] - h[i])) print(dp[n - 1]) " p02713,s547621819,Wrong Answer,"import itertools def gcd(a, b): while b: a, b = b, a % b return a def gcd_3(a,b,c): p = gcd(a,b) q = gcd(p,c) return q k = int(input()) ans = 0 num = list(itertools.combinations_with_replacement(range(1,k+1),3)) for l in num: a,b,c = l if a==b==c: ans += a else: ans += gcd_3(a,b,c)*3 print(ans)" p03592,s711582104,Wrong Answer,"n,m,k=map(int,input().split()) if k%n==0 or k%m==0: print('Yes') exit() k=min(m*n-k,k) for i in range(1,n): for j in range(1,m): if i*n+j*m-2*i*j==k: print('Yes') exit() print('No')" p02640,s761109186,Accepted,"X, Y = map(int, input().split()) m = 2 * X M = 4 * X if Y % 2 == 1: print(""No"") elif Y > M or Y < m: print(""No"") else: print(""Yes"")" p02755,s703155983,Accepted,"import math a, b = map(int, input().split()) a_low = math.ceil(a*12.5) a_high = math.floor((a+1)*12.5-0.01) b_low=b*10 b_high=b*10+9 if b_high < a_low or a_high < b_low: print(-1) else: print(max(a_low, b_low))" p02860,s293372773,Accepted,"N = int(input()) S = input() if N % 2 == 0: num = int(N/2) string = S[:num] strstr = string + string if S == strstr: print(""Yes"") else: print(""No"") else: print(""No"") " p02602,s326659519,Accepted,"def main(): n, k = [int(x) for x in input().split()] scores = [int(x) for x in input().split()] for index in range(n - k): if scores[index] < scores[index + k]: print('Yes') else: print('No') if __name__ == '__main__': main() " p03711,s242929693,Accepted,"def main(): x, y = map(int, input().split()) if x in [1, 3, 5, 7, 8, 10, 12] and y in [1, 3, 5, 7, 8, 10, 12]: print(""Yes"") elif x in [4, 6, 9, 11] and y in [4, 6, 9, 11]: print(""Yes"") elif x in [2] and y in [2]: print(""Yes"") else: print(""No"") if __name__ == ""__main__"": main() " p02618,s451478544,Accepted,"def solve(): D = int(input()) C = list(map(int, input().split())) S = [list(map(int, input().split())) for _ in range(D)] ans = [1]*D for d in range(D): maxi = 0 contest = 0 for i in range(26): if S[d][i]>maxi: contest = i maxi = S[d][i] ans[d] = contest+1 return ans print(*solve(),sep='\n')" p02570,s775842032,Accepted,"input_n = input() n = str(input_n) #listN = list(n) listN = n.split(' ') distance = int(listN[0]) time = int(listN[1]) speed = int(listN[2]) if (distance / speed) <= time: print(""Yes"") else: print(""No"") " p03037,s227643629,Accepted,"_, _, *lst = map(int, open(0).read().split()) l, r = max(lst[::2]), min(lst[1::2]) print(0 if l > r else r - l + 1)" p02983,s160801207,Wrong Answer,"import sys def input(): return sys.stdin.readline().rstrip() def main(): l,r=map(int,input().split()) l_m=l%2019 r_m=r%2019 if l//2019==r//2019: print(l_m*(l_m+1)%2019) else:print(0) if __name__=='__main__': main()" p03250,s255994992,Wrong Answer,"A,B,C = map(int, input().split()) r = max(A,B,C)*10 + B +C print(int(r))" p02690,s192335066,Wrong Answer,"def test2(x): t = int(pow((x//2),0.2)) if(pow(t,5) == x): print(t,-t) else: j = -int(pow(x,0.2)) i = int(pow((x + pow(j,5)),0.2)) print(i,j) return() # for i in range(1,100000): # test(i) # test2(i) x = int(input()) test2(x) " p02973,s076609168,Accepted,"import sys import bisect input = sys.stdin.readline 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))" p03061,s799917655,Accepted,"from math import gcd n = int(input()) a = list(map(int, input().split())) l = [a[-1], a[0]] r = [a[-1]] for x in a[1:-1]: l.append(gcd(l[-1], x)) for x in a[-2:0:-1]: r.append(gcd(r[-1], x)) r = r[::-1] r.append(a[0]) print(max(gcd(l[i], r[i]) for i in range(n)))" p02753,s233228896,Accepted,"S=input() if 'AAA'==S or 'BBB'==S: print('No') else: print('Yes')" p03479,s466913884,Accepted,"import sys,math,collections,itertools input = sys.stdin.readline X,Y =list(map(int,input().split())) count = 1 while X<=Y: count +=1 X*=2 print(count-1) " p02778,s665010451,Accepted,"S=input() print(""x""*len(S)) " p02612,s167050207,Accepted,"n = int(input()) if n % 1000 == 0: print(0) else: print(1000 - n % 1000)" p03150,s746619665,Accepted,"s = input() n = len(s) ans = 'NO' for i in range(n): for j in range(i-1, n): string = s[:i] + s[j+1:] if string == 'keyence': ans = 'YES' print(ans)" p03137,s426874828,Wrong Answer,"def main(): n, m = map(int, input().split()) xs = list(map(int, input().split())) xs = sorted(xs) diff_xs = sorted([xs[i+1] - xs[i] for i in range(m-1)]) ans = sum(diff_xs[:m-n]) print(ans) if __name__ == ""__main__"": main() " p03437,s047437141,Accepted,"X,Y=map(int,input().split()) if X%Y==0: print(-1) exit() i = 2 while True: if X*i % Y != 0 and X*i <= 10**18: print(X*i) exit() i += 1 if X*i > 10**18: print(-1) exit()" p02820,s339467312,Accepted,"n, k = map(int, input().split()) R, S, P = map(int, input().split()) a = input() flag = [False] * n def win(x): if x == ""r"": return P elif x == ""s"": return R else: return S su = 0 for i in range(n): if i - k >= 0 and a[i-k] == a[i] and not flag[i-k]: flag[i] = True continue else: su += win(a[i]) print(su) " p03860,s360527463,Wrong Answer,"s = input() print('A'+s[0]+'C')" p02879,s861889806,Accepted,"A, B = map(int, input().split()) print(A * B if A < 10 and B < 10 else -1)" p02817,s276973980,Accepted,"a = list(map(str, input().split())) print(""{}{}"".format(a[1], a[0]))" p03042,s721671297,Accepted,"s=(input()) s1=int(s[:2]) s2=int(s[2:]) if 1<= s1 <=12 and 1<= s2 <= 12: print(""AMBIGUOUS"") elif 0<= s1 <=99 and 1<= s2 <= 12: print(""YYMM"") elif 1<= s1 <=12 and 0<= s2 <= 99: print(""MMYY"") else: print(""NA"")" p03095,s957359384,Wrong Answer,"from collections import Counter N = int(input()) S = input() c = Counter(S) # print('c', c) ans = 1 for v in c.values(): ans *= v + 1 ans -= 1 print(ans) # 4C4 = 1 # 4C3 = 4 # 4C2 = 6 # 4C1 = 4 # b # a # a # ba # b a " p03862,s839888312,Accepted,"N, x = map(int, input().split()) A = list(map(int, input().split())) ans = 0 for i in range(len(A)-1): if A[i] + A[i+1] > x: if A[i] >= x: ans += A[i] - x ans += A[i+1] A[i+1] = 0 else: tmp = A[i] + A[i+1] - x ans += tmp A[i+1] -= tmp print(ans)" p03711,s214016957,Accepted,"x,y=map(int,input().split()) a=[0,1,3,1,2,1,2,1,1,2,1,2,1] print(""Yes"" if a[x]==a[y] else ""No"") " p03062,s781818524,Accepted,"n=int(input()) a=list(map(int,input().split())) if a.count(0)>0: a=list(map(abs,a)) print(sum(a)) else: a.append(0) for i in range(n): if a[i]<0: a[i+1]*=-1 if i!=n-1: a[i]=abs(a[i]) if a[-2]>0: print(sum(a)) else: a.pop(-1) a[-1]=abs(a[-1]) print(sum(a)-2*min(a))" p03803,s886594969,Accepted,"a,b = map(int,input().split()) if a>b and a!=1 and b!=1: print(""Alice"") elif a c * 2: yen += (c * 2 * min(x, y)) x, y = x - min(x, y), y - min(x, y) if x > 0: yen += min(x * a, x * 2 * c) else: yen += min(y * b, y * 2 * c) else: yen += a * x + b * y print(yen) resolve()" p02947,s957214999,Accepted,"n = int(input()) L = [] for i in range(n): s = input() cur = [] for j in range(10): cur.append(s[j]) cur.sort() t = '' for j in range(10): t += cur[j] L.append(t) L.sort() ans = 0 L.append('end') temp = 1 for i in range(1,n+1): if L[i] != L[i-1]: ans += temp*(temp-1)//2 temp = 1 else: temp += 1 print(ans)" p02836,s933153227,Accepted,"s = input() n = len(s) // 2 p = n j = -1 for i in range(n): if s[i] == s[j]: p -= 1 j -= 1 print(p)" p03038,s523301018,Accepted,"n,m=map(int,input().split()) ans=list(map(int,input().split())) arr=[list(map(int,input().split())) for _ in range(m)] arr=sorted(arr,reverse=True,key=lambda x:x[1]) tmp=0 for cnt,val in arr: ans+=[val]*cnt tmp+=cnt if tmp>=n: break ans=sorted(ans,reverse=True) print(sum(ans[:n]))" p04020,s896263068,Accepted,"N = int(input()) A = [] for _ in range(N): A.append(int(input())) cnt = 0 for i in range(N): if i > 0: if A[i - 1] == 1 and A[i] > 0: A[i] -= 1 cnt += 1 A[i - 1] -= 1 cnt += A[i] // 2 A[i] %= 2 print(cnt) " p02582,s437689917,Accepted,"s = input() ans1 = 0 ans = 0 for i in range(3): if s[i]==""R"": ans1 += 1 else: ans = ans1 ans1 = 0 if not s==""RSS"": print(max(ans,ans1)) else: print(""1"")" p02900,s109836997,Accepted,"import math A, B = [int(_) for _ in input().split()] N = math.gcd(A, B) ans = 1 for i in range(2, int(math.sqrt(N)+1) + 1): if N % i == 0: ans += 1 while N % i == 0: N //= i if N > 1: ans += 1 print(ans) " p02547,s904897320,Accepted,"n = int(input()) cnt = 0 for i in range(n): a, b = map(int, input().split()) if a == b: cnt += 1 else: cnt = 0 if cnt >= 3: print(""Yes"") break if cnt < 3 and i == n-1: print(""No"")" p02765,s598998001,Accepted,"N,R = map(int,input().split()) inside = 0 if N >= 10: inside = R else: inside = R + 100*(10-N) print(inside) " p02796,s114406982,Accepted,"N = int(input()) XL = [list(map(int, input().split())) for x in range(N)] XL = sorted(XL, key=lambda x: x[0]+x[1]) cnt = 0 prev_right = -10**9+10 for x, l in XL: left = x - l right = x + l if left >= prev_right: cnt += 1 prev_right = right print(cnt) " p02726,s233135031,Accepted,"n,x,y=map(int, input().split()) ans=[0]*n for i in range(1,n+1): for j in range(1,n+1): if i>=j: continue ans[min(j-i, abs(x-i)+abs(y-j)+1)]+=1 for k in range(1,n): print(ans[k])" p03852,s146465218,Accepted,"print('vowel' if input() in ['a', 'i', 'u', 'e', 'o'] else 'consonant')" p02731,s014486923,Accepted,"l=int(input()) print((l/3)**3)" p02583,s464614193,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): T = [L[i], L[j], L[k]] T.sort() if T[0] != T[1] and T[1] != T[2]: if T[2] < T[0]+T[1]: ans += 1 print(ans) " p02783,s962125252,Accepted,"import math hp , attack = map(int,input().split()) if(hp <= attack): ans = ""1"" else: ans = str(math.ceil(hp / attack)) print(int(ans))" p03625,s691293300,Accepted,"from collections import Counter n = int(input()) lst = list(map(int, input().split())) mclst = Counter(lst).most_common() sqlst = [] rclst = [] for tpl in mclst: if tpl[1] >= 2: rclst.append(tpl[0]) if tpl[1] >= 4: sqlst.append(tpl[0]) sqmax, rcmax = 0, 0 if len(sqlst) >= 1: sqmax = max(sqlst) ** 2 if len(rclst) >= 2: rclst.sort(reverse=True) rcmax = rclst[0] * rclst[1] print(max(sqmax, rcmax))" p03163,s376647933,Accepted,"n, w = map(int, input().split()) p = [list(map(int, input().split())) for _ in range(n)] p.insert(0, [0, 0]) dp = [[0 for _ in range(w + 1)] for _ in range(n + 1)] for i in range(1, n + 1): for j in range(1, w + 1): if j >= p[i][0]: dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - p[i][0]] + p[i][1]) else: dp[i][j] = dp[i - 1][j] print(dp[n][w])" p03264,s905044976,Accepted,"import math def main(): K = int(input()) if K % 2 == 0: print(K**2//4) else: print(math.floor(K//2)*(math.floor(K//2)+1)) if __name__ == ""__main__"": main()" p03625,s376396429,Wrong Answer,"from collections import defaultdict n=int(input()) a=list(map(int,input().split())) b=[] d=defaultdict(int) for i in range(n): d[a[i]]+=1 for i,j in d.items(): if j>=2: b.append(i) if len(b)<2: print(0) else: b.sort(reverse=True) print(b[0]*b[1])" p03206,s591686586,Accepted,"n = int(input()) ans = ""Christmas"" for _ in range(25-n): ans += "" Eve"" print(ans)" p02833,s344222646,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 = int(readline()) if N % 2: print(0) return N //= 10 ans = N while N: N //= 5 ans += N print(ans) return if __name__ == '__main__': main() " p03327,s760301517,Accepted,"N = int(input()) if N >= 1000: print(""ABD"") if N < 1000: print(""ABC"") " p03817,s826644380,Wrong Answer,"x = int(input()) c = x // 11 m = x % 11 if m > 5: ans = c * 2 + 2 elif m > 0: ans = c * 2 + 1 else: ans = c * 2 print(ans) " p03556,s523182219,Accepted,"import math N = int(input()) ans = math.floor(math.sqrt(N)) ** 2 print(ans)" p03721,s264429021,Accepted,"n,k=map(int,input().split()) l=[0]*(10**5+1) for _ in range(n): a,b=map(int,input().split()) l[a]+=b for i in range(10**5+1): k-=l[i] if k<=0: print(i) break" p02603,s431959544,Accepted,"n = int(input()) *a, = map(int, input().split()) ans = 1000 for i, j in zip(a, a[1:]): if in: print((i-1)**2) break " p02861,s486334261,Wrong Answer,"import itertools import math n=int(input()) lis=[list(map(int,input().split())) for i in range(n)] num=[j for j in range(n)] new=list(itertools.permutations(num)) ans=0 for i in range(len(new)): for j in range(n-1): a=new[i][j] b=new[i][j+1] ans+=math.sqrt((lis[a][0]-lis[a][1])**2+(lis[b][0]-lis[b][1])**2) print(ans/len(new))" p03338,s941139581,Accepted,"N = int(input()) S = input() ans = 0 for i in range(1,N-1): set1 = set(S[:i]) set2 = set(S[i:]) z = set1.intersection(set2) ans = max(ans,len(z)) print(ans) " p02694,s253626192,Wrong Answer,"# -*- coding: utf-8 -*- def main(): X = int(input()) num = 100 ans = 0 while num < X: num = num + int(num * 0.01) ans +=1 print(ans) if __name__ == ""__main__"": main()" p03407,s237742483,Wrong Answer,"A,B,C=map(int,input().split()) if A+B>C: print('Yes') else: print('No')" p03592,s554687160,Wrong Answer,"n,m,k = map(int,input().split()) for i in range(1,n+1): for j in range(1,m+1): if i*(n-j)+ j*(m-i) == k: print('Yes') exit() print('No') " p02848,s675232066,Accepted,"N=int(input()) S=input() print("""".join(chr(65+(ord(s)-65+N)%26) for s in S))" p04045,s496548696,Accepted,"n, k = map(int, input().split()) d = list(map(str, input().split())) for i in range(n, 10**5): num = str(i) for j in range(len(num)): if num[j] in d: break else: print(i) break " p03386,s179361788,Accepted,"a,b,k=map(int,input().split()) for i in range(a,b+1): if i not in range(a+k,b+1-k): print(i) " p02791,s953935264,Accepted,"n= int(input()) ans=1 P = list(map(int, input().split())) minmin= P[0] for i in P: if minmin>i: minmin=i ans+=1 print(ans) " p03069,s376123288,Wrong Answer,"n = int(input()) s = input() kuro = 0 siro = 0 p = 0 for i in range(n): if p == 0 and s[i] == ""#"": p = 1 if p == 1 and s[i] == ""."": siro += 1 p = 0 for i in reversed(range(n)): if p == 0 and s[i] == ""."": p = 1 if p == 1 and s[i] == ""#"": kuro += 1 print(min(siro,kuro))" p02970,s976885330,Accepted,"def readints(): return list(map(int, input().split())) n, d = map(int, input().split()) a = 2*d+1 print(-(-n // a)) " p03760,s809889531,Accepted,"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 o = rr() e = rr() s = '' for a, b in itertools.zip_longest(o, e, fillvalue=''): s += a + b print(s) " p02705,s686192834,Accepted,"import math r=input() a=(int)(r)*2*math.pi print(a) " p02922,s906637712,Accepted,"a, b = map(int, input().split()) import math ans = math.ceil((b-1)/(a-1)) print(ans)" p02772,s180774147,Wrong Answer,"n = int(input()) a = list((int(x) for x in input().split())) for num in a: if num%2 == 0: if not num%3 == 0 and num%5 == 0: print('DENIED') exit() print('APPROVED') " p02836,s059066638,Accepted,"S=input() count=0 if len(S)%2==0: for i in range(len(S)//2): if S[i]!=S[-i-1]: count+=1 else: for i in range((len(S)-1)//2): if S[i]!=S[-i-1]: count+=1 print(count)" p03637,s427711330,Accepted,"n = int(input()) a = list(map(int,input().split())) count2 = -1 count4 = 0 for i in range(n): if a[i] % 4 == 2: count2 += 1 if a[i] % 4 == 0: count4 += 1 if count2 >= 1: n -= count2 if count4 * 2 + 1 >= n: print(""Yes"") exit() print(""No"")" p03986,s111973120,Wrong Answer,"def main(): X = input() count = 0 for i in range(4*10**2): count += X.count(""ST"") X = X.replace(""ST"","""") print(len(X)) if __name__ == '__main__': main()" p02947,s020433812,Accepted,"from collections import defaultdict def main(): N = int(input()) s = defaultdict(int) ans = 0 for i in range(N): a = """".join(sorted(input())) s[a] += 1 if s[a] != 1: ans += (s[a]-1) print(ans) if __name__ == '__main__': main()" p03944,s266913510,Accepted,"w, h, n = map(int, input().split()) r_w = w l_w = 0 u_h = h d_h = 0 for i in range(n): x, y, a = map(int, input().split()) if a == 1: l_w = max(l_w, x) elif a == 2: r_w = min(r_w, x) elif a == 3: d_h = max(d_h, y) elif a == 4: u_h = min(u_h, y) res = max(0, r_w - l_w) * max(0, u_h - d_h) print(res) " p03385,s084805484,Accepted,"S = input() if (S[0]== ""a"" or S[1] == ""a"" or S[2] == ""a"") and (S[0]== ""b"" or S[1] == ""b"" or S[2] == ""b"") and (S[0] == ""c"" or S[1] == ""c"" or S[2] == ""c"") : print(""Yes"") else: print(""No"")" p03545,s416584566,Accepted,"a=input() for i in range(8): s=int(a[0]) ans=[a[0]] for j in range(3): if (i>>j)&1: s+=int(a[j+1]) ans+=[""+""]+[a[j+1]] else: s-=int(a[j+1]) ans+=[""-""]+[a[j+1]] if s==7: print(*ans,sep="""",end="""") print(""=7"") break" p02786,s686823710,Wrong Answer,"h = int(input()) k = h // 2 if k == 0: print(1) else: print(2**k + 2*k - 1)" p02785,s887852060,Accepted,"N, K = map(int, input().split()) H = list(map(int,input().split())) sum = 0 i = K; H.sort(reverse=True) if(K >= len(H)): print(0) else: for i in range(i, len(H)): sum += H[i]; print(sum)" p03030,s425510950,Accepted,"import sys def input(): return sys.stdin.readline().rstrip() def main(): n = int(input()) sp = [input().split() + [i+1] for i in range(n)] sp = sorted(sp, key=lambda x: (x[0], -int(x[1]))) for _, _, i in sp: print(i) if __name__ == '__main__': main() " p03861,s707203322,Accepted,"a, b, x = map(int, input().split()) ans = (b // x) - (a // x) if a % x == 0: ans +=1 print(ans)" p02918,s491011203,Accepted,"N, K = map(int, input().split()) S = input() assert len(S) == N first = S[0] target = ""R"" if first == ""L"" else ""L"" def count_unhappy(): tcnt = 0 consecutive = False for c in S: if c == target: consecutive = True elif consecutive: tcnt += 1 consecutive = False if consecutive: tcnt += 1 unhappy = 2 * tcnt + (0 if S[-1] == target else 1) return max(unhappy - 2 * K, 1) print(N - count_unhappy()) " p03723,s278255722,Accepted,"A,B,C = map(int,input().split()) def F(A,B,C): if any(x&1 for x in [A,B,C]): return 0 if A == B == C: return -1 return 1 + F((A+B)//2,(B+C)//2,(C+A)//2) answer = F(A,B,C) print(answer) " p02556,s620809675,Accepted,"n = int(input()) p = [] m = [] for i in range(n): x, y = map(int, input().split()) p.append(x+y) m.append(x-y) p.sort() m.sort() print(max(p[-1]-p[0], m[-1]-m[0])) " p03067,s211033202,Wrong Answer,"*s, t = map(int, input().split()) s.sort() for i in range(s[0],s[1]+1): if i == t: print(""Yes"") print(""No"")" p02700,s872054209,Accepted,"a, b, c, d = map(int,input().split()) if -(-c // b) <= -(-a // d): print('Yes') else: print('No') " p02873,s304594633,Wrong Answer,"s = input() n = len(s) a = [0]*(n+1) for i in range(n): if s[i] == '<': a[i+1] = a[i] + 1 for i in range(-1, -n, -1): if s[i] == '>': a[i-1] = max(a[i] + 1, a[i-1]) print(sum(a))" p02836,s240043620,Wrong Answer,"import math s = input() t = s[::-1] print(s,t) count = 0 for i in range(len(s)): if s[i] != t[i]: count += 1 print(math.ceil(count/2))" p03543,s100811603,Accepted,"n = input() if n[0] == n[1] == n[2] or n[3] == n[1] == n[2]: print('Yes') else: print('No') " p02972,s526662455,Accepted,"n,*a=map(int,open(0).read().split()) b=[0]*(n+1) for i in range(1,n+1)[::-1]: b[i]+=(sum(b[j] for j in range(i,n+1,i))+a[i-1])%2 print(sum(b)) print(*[i for i in range(n+1) if b[i]>0])" p02717,s188730253,Accepted,"x,y,z=map(int,input().split()) print(z,x,y)" p02657,s752014280,Accepted,"# coding: utf-8 #N = int(input()) a, b = map(int,input().split()) print(a*b)" p03494,s114996612,Wrong Answer,"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)" p03838,s277012048,Accepted,"x,y=map(int,input().split()) if x>0: if y>x: print(y-x) elif 00: print(y-x) else: print(x-y+1) else: if y 0: print(l) return elif r < 0: print(-r) return a1 = r - r // (2 * d) * (2 * d) a2 = a1 - (2 * d) ans = min(abs(a1), abs(a2)) print(ans) if __name__ == ""__main__"": solve() " p03659,s302495857,Accepted,"N=int(input()) a=list(map(int,input().split())) l,r=a.pop(0),sum(a) ans=10**10 for i in a: ans=min(ans,abs(l-r)) l,r=l+i,r-i print(ans)" p02664,s864977593,Accepted,"print(input().replace('?', 'D'))" p04043,s846063323,Wrong Answer,"# -*- coding: utf-8 -*- A_B_C = list(map(int, input().split())) if A_B_C == [5,5,7]: print('YES') else: print('NO')" p02681,s033291599,Accepted,"S = str(input()) T = str(input()) if T.startswith(S) and len(S)+1 ==len(T): print(""Yes"") else: print(""No"")" p02843,s667653413,Wrong Answer,"x=int(input()) if x<100: print(0) exit() elif 100<=x<=106: print(1) exit() else: DP=[False]*(x+1) for i in range(x+1): coin=list(range(100,106,1)) if i in coin: DP[i]=True continue DP[i]=True if any(DP[i-m] for m in coin) else False print(1 if DP[x]==True else 0)" p02594,s542468994,Accepted,"X=int(input()) if X>=30: print(""Yes"") else: print(""No"")" p03695,s555923958,Accepted,"n=int(input()) a=list(map(int,input().split())) cnt=0 l=[] for i in a: p=i//400 if p<=7: l.append(p) else: cnt+=1 d=len(set(l)) if d!=0: print(d,d+cnt) else: print(1,cnt)" p03407,s586659280,Accepted,"A =list(map(int, input().split())) if A[0]+A[1]>=A[2]: print('Yes') else: print('No') " p03565,s636259682,Accepted,"S=input() T=input() n=len(S) m=len(T) for i in range(n-m,-1,-1) : x=S[i:i+m] for j in range(m+1): if j==m : print((S[:i]+T+S[i+m:]).replace(""?"",""a"")) exit() if x[j]==""?"" : continue elif x[j]!=T[j] : break print(""UNRESTORABLE"") " p02719,s520738072,Wrong Answer,"n,k=map(int,input().split()) while n>0: n=n-k print(abs(n))" p02607,s611619258,Wrong Answer,"N = int(input()) an = map(int, input().split("" "")) ans = 0 for i, ai in enumerate(an): print(i+1, ai) if (i+1) % 2 == 1 and ai % 2 == 1: ans += 1 print(ans)" p03067,s780266416,Accepted,"A, B, C = map(int, input().split()) if A < C < B or B < C < A: print(""Yes"") else: print(""No"")" p03105,s239374418,Accepted,"A, B, C = (int(x) for x in input().split()) if B//A >= C: print(C) else: print(B//A)" p03285,s747319386,Accepted,"N = int(input()) p = 1 for i in range(N//7+1): if (N - i*7)%4 == 0: p = p*0 else: p = p*1 if p == 0: print('Yes') else: print('No')" p02881,s957810089,Accepted,"import math N = int(input()) def yakusuu(n): lst = [] for i in range(1, int(math.sqrt(n))+1): if(n%i == 0): lst.append(i) return lst lst = yakusuu(N) ans = 10**18 for i in range(len(lst)): a = lst[i] b = N//lst[i] ans = min(ans, (a-1)+(b-1)) print(ans)" p03000,s685682219,Accepted,"N, X = map(int, input().split(' ')) L_ls = map(int, input().split(' ')) D, cnt = 0, 1 for L in L_ls: D += L if D > X: break cnt += 1 print(cnt)" p02706,s153779312,Accepted,"N, M = map(int, input().split()) a_list = list(map(int, input().split())) days = sum(a_list) if N >= days: print(N-days) else: print(-1)" p02583,s310036089,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[i] != l[k] and l[j] != l[k]: if l[i] + l[j] > l[k] and l[i] + l[k] > l[j] and l[k] + l[j] > l[i]: ans += 1 print(ans) " p03623,s192697971,Accepted,"x, a, b = map(int, input().split()) if abs(x-a) > abs(x-b): print(""B"") else: print(""A"")" p02823,s858078265,Wrong Answer,"n,a,b = map(int,input().split()) if abs(a-b)%2: print(abs(a-b)//2+1+min((abs(1-a),abs(10-a),abs(1-b),abs(10-b)))) else: print(abs(a-b)//2)" p03779,s594094600,Accepted,"X = int(input()) t = 0 sum_x = 0 while sum_x < X: t += 1 sum_x += t # jump with t print(t)" p03262,s495275650,Accepted,"from fractions import gcd N, X = map(int, input().split()) x = list(map(int, input().split())) ans = abs(X - x[0]) if (N == 1): print(ans) exit(0) for i in range(1, len(x)): ans = gcd(abs(x[i] - x[i - 1]), ans) print(ans) " p03659,s217368131,Accepted,"n=int(input()) a=list(map(int,input().split())) suma=sum(a) b=[0]*(n-1) total=0 for i in range(n-1): total+=a[i] b[i]+=total mini=abs((suma-b[0])-b[0]) for i in range(n-1): if mini>abs((suma-b[i])-b[i]): mini=abs((suma-b[i])-b[i]) print(mini)" p03073,s151645586,Wrong Answer,"s = input() ans = len(s) for i in range(2): cnt = 0 for j in range(ans): if j % 2 == 0 and s[j] != 0: cnt += 1 if j % 2 == 1 and s[j] == 0: cnt += 1 ans = min(ans,cnt) print(ans)" p02729,s300397523,Accepted,"N, M = [int(_) for _ in input().split()] ans = N * (N - 1) // 2 ans += M * (M - 1) // 2 print(ans) " p03759,s589662299,Wrong Answer,"a,b,c = map(int,input().split()) array = [a,b,c] ans = array.copy() ans.sort() if ans == array: print('YES') else: print('NO')" p02879,s282241061,Accepted,"def judge99(x): if x <= 9: return True else: return False a, b = map(int,input().split()) if judge99(a) and judge99(b): print(a*b) else: print(-1) " p02584,s233378667,Accepted,"x,k,d=map(int,input().split()) x=abs(x) if x>=k*d: print(x-k*d) else: cnt=x//d if (k-cnt)%2==0: print(x-cnt*d) else: print(abs(x-(cnt+1)*d))" p02952,s360215891,Wrong Answer,"# # author Sidratul # from math import prod if __name__ == '__main__': n = int(input()) for i in range(n, 1, -1): c = str(i) if i%2 == 1 and not '0' in c: print(i) break " p03131,s755210567,Accepted,"K, A, B = map(int, input().split()) if B - A <= 2: print(K + 1) else: ans = 0 # 初回のA枚→B枚まで A-1 回かかる rest = K - A + 1 # このときにはA枚持っている ans += A # 残りをすべてA枚→B枚 ans += rest // 2 * (B - A) if rest % 2 != 0: ans += 1 print(ans) " p02987,s386646329,Accepted,"S = input() x = 0 for i in range(len(S)): if S.count(S[i]) == 2: x += 1 if x == 4: print('Yes') else: print('No')" p02712,s780319951,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) " p02814,s693107243,Accepted,"import sys import fractions from functools import reduce input = sys.stdin.readline n, m = [int(x) for x in input().strip().split()] a = [int(x)//2 for x in input().strip().split()] a = list(set(a)) def lcm_base(x, y): return x * y // fractions.gcd(x, y) lcm = reduce(lcm_base, a, 1) for x in a: if (lcm // x) % 2 == 0: print(0) break else: print((m // lcm + 1) // 2) " p03796,s961350338,Wrong Answer,"N=int(input()) P=1 for i in range(N): P = P*(i+1) print(P)" p03250,s740415348,Accepted,"a,b,c=sorted(map(int,input().split())) print(10*c+b+a) " p03986,s415520994,Wrong Answer,"X = input() N = len(X) right = N - 1 cnt = 0 for left in range(N - 1): if X[left] == 'S': while X[right] != 'T': right -= 1 if left < right: cnt += 1 print(N - cnt * 2)" p03475,s836418641,Accepted,"import sys N = int(input()) CSF = [list(map(int, sys.stdin.readline().rsplit())) for _ in range(N - 1)] for i in range(N - 1): res = 0 for c, s, f in CSF[i:]: if res < s: res = s + c elif res % f == 0: res += c else: res += f - (res % f) + c print(res) print(0) " p02995,s925686155,Wrong Answer,"import fractions as fc import math a,b,c,d=map(int,input().split()) ccnt=(b//c)-math.ceil(a//c) dcnt=(b//d)-math.ceil(a//d) e=int(c*d/fc.gcd(c,d)) ecnt=(b//e)-math.ceil(a//e) ans=(b-a+1)-(ccnt+dcnt-ecnt) if ans<0: ans=0 print(ans)" p03377,s764480433,Accepted,"A,B,X = map(int, input().split()) print(""YES"" if X-A<=B and A<=X else ""NO"") " p03220,s829755827,Accepted,"n = int(input()) t,a = map(int,input().split()) A = list(map(int,input().split())) B = [abs(t - A[i]*0.006 -a) for i in range(n)] print(min(enumerate(B), key = lambda x:x[1])[0] +1 ) " p03043,s804393094,Wrong Answer,"# -*- coding: utf-8 -*- import numpy as np from collections import deque from collections import defaultdict import heapq import collections import itertools import bisect def zz(): return list(map(int, input().split())) def z(): return int(input()) def S(): return input() def C(line): return [input() for _ in range(line)] N, K = zz() if(N >= K): ans = (N-K+1)/N else: ans = 0 for n in range(1, min(K, N+1)): x = max(int(np.log2(K/n))+1, 0) # print('n=', n, 'x=', x) tmp = 1/N * pow(1/2, x) ans += tmp print(ans) " p02660,s683674687,Accepted,"target = int(input()) num = target waru = 2 exp = [] while waru ** 2 <= target and num > 1: rep = 0 while num % waru == 0: num /= waru rep += 1 waru += 1 if rep > 0: exp.append(rep) if num > 1: exp.append(1) ans = 0 for item in exp: hiku = 1 while item - hiku >= 0: item -= hiku ans += 1 hiku += 1 print(ans)" p04019,s269032876,Accepted,"s = input() flag = True if (""N"" in s) ^ (""S"" in s): flag = False if (""W"" in s) ^ (""E"" in s): flag = False if flag == True: print(""Yes"") else: print(""No"")" p02787,s429771735,Accepted," import math H,N = map(int,input().split()) Damage = [] Cost = [] DP = [0] + [pow(10,9)] * (H+1) for i in range(N): a,b = map(int,input().split()) Damage.append(a) Cost.append(b) #print(DP) # DP[i] = min magic points to do i damage for i in range(1,len(DP)): for spell in range(N): DP[i] = min(DP[i],DP[max(0,i-Damage[spell])]+Cost[spell]) print (DP[H]) " p03407,s331864898,Accepted,"A, B, C =map(int, input().split()) if A + B < C: print(""No"") else: print(""Yes"") " p02640,s237097240,Accepted,"X, Y = map(int, input().split()) for i in range(X + 1): if i * 2 + (X - i) * 4 == Y: print('Yes') break else: print('No')" p03309,s558675009,Wrong Answer,"n = int(raw_input()) ais = map(int, raw_input().split()) b = ais[-1] - n q = 0 for i in range(len(ais)-1): u = i+1 q += abs(ais[i] - (b+u)) print q" p02916,s215800011,Accepted,"N = int(input()) A = list(map(int,input().split())) B = list(map(int,input().split())) C = list(map(int,input().split())) total = B[A[0]-1] for i in range(1,N): dish = A[i] score = B[dish-1] before = A[i-1] if dish == before + 1: score += C[before-1] total += score print(total) " p02971,s125308566,Accepted,"n = int(input()) a = [int(input()) for _ in range(n)] idx = a.index(max(a)) a.sort() for i in range(n): if i==idx: print(a[-2]) else: print(a[-1])" p02783,s433907206,Accepted,"H,A=map(int,input().split()) if(H%A==0): print(H//A) else: print(H//A+1) " p03469,s452987146,Accepted,"print (input().replace('2017/','2018/')) " p02729,s464098014,Accepted,"a,b = input().split() a = int(a) b = int(b) ans = a * (a-1) / 2 + b * (b-1) / 2 print(int(ans))" p03035,s569342158,Accepted,"stdin = input().split("" "") A = int(stdin[0]) B = int(stdin[1]) if A <= 5: print(""0"") elif 6 <= A <= 12: print(B//2) else: print(B)" p02766,s186395957,Accepted,"N,K=map(int, input().split()) list=[] while N>=K: x=N%K N=N//K list.append(x) list.append(N) print(len(list)) " p03838,s555627091,Accepted,"x, y = map(int, input().split()) a = max(0, y - x) b = max(0, -1 * y - x + 1) c = max(0, y + x + 1) d = max(0, -1 * y + x + 2) l = [a, b, c, d] ans = 1000000000000 for i in l: if i != 0 and i < ans: ans = i print(ans) " p03250,s344594162,Wrong Answer,"s = map(int, raw_input().split(' ')) print sum(s) + 10 *max(s)" p02660,s275789559,Accepted,"import math from collections import defaultdict from itertools import accumulate N=int(input()) data=defaultdict(int) result=0 for i in range(2,int(math.sqrt(N))+1): while N%i==0: N//=i data[i]+=1 if N!=1: data[N]+=1 cumsum=list(accumulate(range(1,10**6*2))) for value in data.values(): for i in range(10**6*2): if value= n-1: break if a[i] < a[i+1]: flg = True elif a[i] > a[i+1]: flg = False else: continue for k in range(i, n-1): if (flg and a[k] > a[k+1]) or ((not flg) and a[k] < a[k+1]): cnt += 1 i = k break" p02742,s792669084,Accepted,"h,w = map(int,input().split()) if h==1 or w==1: print(1) else: print((h*w+1)//2)" p02723,s739356261,Accepted,"S = input() if S[2] == S[3] and S[4] == S[5]: print(""Yes"") else: print(""No"")" p04029,s697812556,Accepted,"N = int(input()) Sum = 0 for i in range(1, N + 1): Sum += i print(Sum)" p02843,s707195542,Accepted,"n=int(input()) dp=[0]*(n+120) dp[100]=1 dp[101]=1 dp[102]=1 dp[103]=1 dp[104]=1 dp[105]=1 for i in range(100,n+1): if not dp[i]: continue dp[i+100:i+106]= [1]*6 print(dp[n]) " p03835,s596968127,Accepted,"k, s = map(int,input().split()) ans = 0 for i in range(k+1): for j in range(k+1): if 0 <= s-i-j and s-i-j <= k: ans += 1 else: continue print(ans)" p02792,s369947617,Accepted,"N = int(input()) res = [[0 for _ in range(9)] for _ in range(9)] for i in range(1, N + 1): if i % 10: res[int(str(i)[0]) - 1][i % 10 - 1] += 1 ans = 0 for i in range(1, N + 1): if i % 10: ans += res[i % 10 - 1][int(str(i)[0]) - 1] print(ans)" p02747,s098914578,Wrong Answer,"n = raw_input() if 'hii' in n: print(""No"") elif 'hi' in n: print(""Yes"") else: print(""No"") " p02778,s897057690,Accepted,"#python3 def main(): s = input() tmp = ['x']*len(s) ans = ''.join(tmp) print(ans) main() " p02793,s176558819,Accepted,"n = int(input()) lst1 = list(map(int,input().split())) mod = 10**9+7 def GCD(a,b): if b == 0: return a else: return GCD(b,a%b) def LCM(a,b): return (a//GCD(a,b)*b) l = 1 for i in lst1: l = LCM(l,i) ans = 0 for i in range(n): ans += l//lst1[i] print(ans%mod)" p02775,s954246238,Accepted,"import sys sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) N = list(map(int, input())) def solve(N): dp = (0, 1) # n円の場合とn+1円の場合 for n in N: a = min(dp[0] + n, dp[1] + 10 - n) b = min(dp[0] + n + 1, dp[1] + 10 - (n+1)) dp = (a, b) return dp[0] print(solve(N)) " p02663,s149860399,Wrong Answer,"h1, m1, h2, m2, k = map(int, input().split()) t1 = h1 * 60 + m1 t2 = h2 * 60 + m1 print(t2-t1 - k) " p03059,s450207972,Accepted,"import sys A,B,T = map(int,input().split()) if not ( 1 <= A <= 20 and 1 <= B <= 20 and 1 <= T <= 20 ): sys.exit() time_remind = T+0.5 sum = 0 for I in range(1,T+1): time_remind -= A if time_remind >= 0: sum += B print(sum)" p03785,s391937603,Wrong Answer,"N, C, K = map(int, input().split()) T = [0 for _ in range(N)] for i in range(N): T[i] = int(input()) T = sorted(T) flag = 0 cnt = 0 ans = 0 for i in range(len(T)): time = T[i] - T[flag] cnt += 1 if time > K or cnt > C: flag = i cnt = 0 ans += 1 print(ans + 1) " p03385,s372959299,Accepted,"S = input() if S=='abc' or S=='acb' or S=='bac' or S=='bca' or S=='cab' or S=='cba': print('Yes') else: print('No')" p03633,s163389912,Wrong Answer,"def gcd(x, y): while(x % y != 0 and y % x != 0): if(x > y): x = x % y else: y = y % x if(x > y): return y else: return x N = int(input()) A = list() for i in range(N): A.append(int(input())) ans = 1 for i in range(N): gcd_i = gcd(A[i], ans) print(gcd_i) ans = A[i] * ans // gcd_i print(ans)" p02778,s377014380,Accepted,"s = input() for i in range(len(s)): print(""x"", end="""") print() " p02646,s899398944,Accepted,"a,v=map(int,input().split()) b,w = map(int,input().split()) t=int(input()) if a<=b: dist_a = a + t*v dist_b = b + t*w if dist_a>=dist_b: print('YES') else: print('NO') else: dist_a = a - t*v dist_b = b - t*w if dist_a<=dist_b: print('YES') else: print('NO') " p03131,s601127358,Accepted,"def main(): k, a, b = map(int, input().split()) if (b - a) <= 2: ans = k + 1 else: n = (k - (a - 1)) // 2 ans = n * b - (n - 1) * a + (k - (a - 1)) % 2 print(ans) if __name__ == '__main__': main() " p02622,s208166248,Accepted,"#import functools def main(): S = input() T = input() ans = 0 for i in range(len(S)): if not S[i] == T[i]: ans += 1 print(ans) if __name__ == ""__main__"": main()" p02601,s167180003,Wrong Answer,"input_line = input() input2 = input_line.rstrip().split("" "") a,b,c = [int(i) for i in input2] count = 0 max_num = int(input()) while count<=max_num: if a >= b: b*=2 count += 1 else: break while count<=max_num: if b >= c: c*=2 count += 1 else: break if a 5: x-=105 else: print(""1"") exit() if x<100: print(""0"") exit() " p02681,s737550588,Accepted,"S=input() T=input() if len(T)!=len(S)+1: print('No') exit() if S!=T[:-1]: print('No') exit() print('Yes')" p02918,s923605256,Accepted,"(str_len,cng_cnt) = input().split("" "") str_input = list(input()) str_len= int(str_len) cng_cnt= int(cng_cnt) tmp1="""" cnt=0 cnt2=0 for st in str_input: if(tmp1 == st ): cnt = cnt+1 else: cnt2= cnt2 + 1 tmp1=st if (cng_cnt < cnt2-1 ): c_up = cng_cnt * 2 else: c_up= (cnt2 * 2) + (cng_cnt - cnt2) ans =cnt + c_up if(ans >= str_len): ans =str_len-1 print(ans)" p03645,s185005185,Accepted,"n,m =map(int,input().split()) s = [] e = [] for i in range(m): a,b = map(int,input().split()) if a ==1: s.append(b) if b == n: e.append(a) if set(s)&set(e): print(""POSSIBLE"") else: print(""IMPOSSIBLE"")" p02814,s608409548,Accepted,"import fractions from functools import reduce def lcm_base(x, y): return (x * y) // fractions.gcd(x, y) def lcm(*numbers): return reduce(lcm_base, numbers, 1) n, m = map(int, input().split()) a = list(map(int, input().split())) a.sort(reverse=True) num_lcm = lcm(*a) lst = [num_lcm//a_i for a_i in a] for i in lst: if i % 2 == 0: print(0) exit() harf_lcm = num_lcm // 2 if m < harf_lcm: print(0) else: print(1+(m-harf_lcm)//num_lcm)" p02691,s956115047,Accepted,"import sys readline = sys.stdin.readline from collections import Counter def main(): N = int(readline()) A = list(map(int, readline().rstrip().split())) A1 = [i + a for i, a in enumerate(A)] A2 = [i - a for i, a in enumerate(A)] c1 = Counter(A1) c2 = Counter(A2) c2_keys = c2.keys() ans = 0 for key, val in c1.items(): if key in c2_keys: ans += val * c2[key] print(ans) if __name__ == '__main__': main()" p03220,s706143464,Accepted,"N = int(input()) T,A = (int(X) for X in input().split()) H = [int(X) for X in input().split()] MIN = pow(10,9) MII = 0 for X in range(0,N): Diff = abs(A-(T-0.006*H[X])) if Diff= 2: if n % 2 == 0: print(int((n//2)*min(a[0]*8, a[1]*4, a[2]*2, a[3]))) else: print(int((n//2)*min(a[0]*8, a[1]*4, a[2]*2, a[3])+min(a[0]*4, a[1]*2, a[2]))) else: print(min(a[0]*4, a[1]*2, a[2])) " p02683,s352138382,Accepted,"import numpy as np N,M,X = map(int,input().split()) C = [] A = [] for _ in range(N): l = list(map(int,input().split())) C.append(l[0]) A.append(np.array(l[1:])) ans = 10**100 for i in range(2**N): rikaido = np.zeros(M) c = 0 for j in range(N): if (i >> j) & 1: c += C[j] rikaido += A[j] if all([x >= X for x in rikaido]): ans = min(ans, c) print(ans if ans != 10**100 else -1)" p02775,s136374614,Accepted,"a=input() N=len(a) count=0 bonus=0 for i in range(N-1,-1,-1): if int(a[i])+bonus>=6 or (int(a[i])+bonus==5 and (i!=0 and int(a[i-1])>=5)): count+=(10-int(a[i])-bonus) if i!=0: bonus=1 else: count+=1 else: count+=int(a[i])+bonus bonus=0 print(count)" p02730,s422506552,Accepted,"letter=input() def isKaibun(s): res = True for i in range(int((len(s))/2)): if s[i] != s[-1-i]: res = False break return res if isKaibun(letter[0:int((len(letter)-1)/2)]): if isKaibun(letter[int((len(letter)+3)/2-1):]): if isKaibun(letter): print('Yes') else: print('No') else: print('No') else: print('No') " p02783,s347142767,Wrong Answer,"# -*- coding: utf-8 -*- import math n = input().split("" "") h = int(n[0]) a = int(n[1]) def main(health, attack): total = health / attack return math.ceil(total) if __name__ == '__main__': main(h, a)" p03795,s913522149,Wrong Answer,"N = int(input('整数を入力してね>')) X = int(800 * N) Y = int((N/15)*200) print(X - Y)" p03160,s403385580,Accepted,"import sys input=sys.stdin.readline n=int(input()) h=tuple(map(int,input().split())) dp=[0]*n dp[1]=abs(h[1]-h[0]) for i in range(2,n): dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1])) print(dp[-1])" p02780,s894444566,Accepted,"import sys from collections import defaultdict sys.setrecursionlimit(10**7) input = sys.stdin.readline n,k = map(int, input().split()) p = list(map(int, input().split())) d = defaultdict(float) for i in range(1, 1001): j = i while 0 < j: t = j * (1 / i) d[i] += t j -= 1 sum = [0.0]*(n+1) for i in range(n): sum[i+1] = sum[i] + d[p[i]] ans = 0 for i in range(k-1, n+1): tmp = sum[i] - sum[i-k] ans = max(ans,tmp) print('{:.12f}'.format(ans)) " p02789,s346102487,Accepted,"N,M = [int(i) for i in input().rstrip().split(' ')] if N == M: print(""Yes"") else: print(""No"")" p03284,s036311670,Accepted,"def resolve(): N, K = map(int, input().split()) print(""0"" if N%K == 0 else ""1"") resolve()" p02832,s772304071,Accepted,"n = int(input()) a = list(map(int, input().split())) v = 0 for x in a: if x == v + 1: v += 1 print(n - v) if v != 0 else print(-1) " p02645,s174721360,Wrong Answer,"s = input() print(s[1:4])" p02766,s373387129,Wrong Answer,"import math N, R = map(int, input().split()) X = math.log(N + 1, R) Y = math.ceil(X) print(Y)" p02624,s392623454,Wrong Answer,"import math N = int(input()) ans = 0 A = [1 for i in range(N + 2)] k = 2 A[1] = 0 while k <= math.sqrt(N): for i in range(k,N + 1,k): q = i p = 1 while q % k == 0: q /= k p += 1 A[i] *= p while A[k] != 1: k += 1 print(A) for i in range(1,N + 1): if A[i] <= 1: A[i] += 1 ans += i * A[i] print(ans) " p02918,s648119776,Accepted,"N,k=map(int,input().split()) A=input() ans=0 for i in range(0,N): if A[i]=='R' and i0: if A[i-1]=='L': ans=ans+1 print(min(N-1,2*k+ans)) " p02917,s064414140,Accepted,"n = int(input()) A = [0]*n B = list(map(int,input().split())) A[0] = B[0] A[-1] = B[-1] for i in range(1,n-1): A[i] = min(B[i-1],B[i]) print(sum(A))" p03998,s015737696,Accepted,"S = [[{""a"": 0, ""b"": 1, ""c"": 2}[s] for s in input()[::-1]]for _ in range(3)] T = {0: ""A"", 1: ""B"", 2: ""C""} c = 0 while 1: c = S[c].pop() if not S[c]: print(T[c]) exit()" p02688,s491506709,Wrong Answer,"n,k = map(int,input().split()) N = list(range(1,n+1)) A = set() count = 0 for i in range(k): d = int(input()) Ad = list(map(int,input().split())) for j in range(d): A.add(Ad[j]) for i in range(n): if N[i] in A: count += 1 print(A) print(n-count) " p02596,s456921111,Accepted,"import sys k = int(input()) if k % 2 == 0 or k % 10 == 5: print(-1) sys.exit() else: cnt = 1 a = 0 while(True): a = (a * 10 + 7) % k if a % k == 0: print(cnt) break if cnt > 1000000: print(-1) break cnt += 1 " p02658,s507902133,Wrong Answer,"from collections import deque n=int(input()) a=deque() a=list(map(int,input().split())) s=1 if a.count(0) == 0: for i in range(n): l=a.pop() s=s*l if len(str(s)) == 19 and i == n-1: lst=list(str(s)) if len(str(s)) > 19: s=-1 break print(s)" p02862,s764038162,Accepted,"from functools import reduce m, n = map(int, input().split()) mod = 10 ** 9 + 7 def ncr(p, k): if k == 0: return 1 elif k < 0: return 0 else: num = reduce(lambda x, y: x * y % mod, range(p, p - k, -1)) den = reduce(lambda x, y: x * y % mod, range(1, k + 1)) return num * pow(den, mod - 2, mod) % mod if (m + n) % 3 != 0: print(0) else: p = (m + n) // 3 k = m - p print(ncr(p, k)) " p03317,s438509591,Wrong Answer,"import math n,k = map(int,input().split()) a = list(map(int,input().split())) if k >= n: print(1) exit() s = a.index(1) left = s right = n - (s + 1) print(math.ceil(left / (k-1)) + math.ceil(right / (k-1)))" p03556,s042585196,Accepted,"N = int(input()) i = 1 while i**2 <= N: i +=1 print((i-1)**2)" p03854,s446273375,Accepted,"import sys S = sys.stdin.readline().strip() S = S[::-1] i = 0 while i < len(S): if S[i:i+5] == ""maerd"": i += 5 elif S[i:i+7] == ""remaerd"": i += 7 elif S[i:i+5] == ""esare"": i += 5 elif S[i:i+6] == ""resare"": i += 6 else: break if i == len(S): print(""YES"") else: print(""NO"")" p02771,s468226143,Wrong Answer,"a, b, c = input().split() if a == b or a == c or b == c: print('Yes') else: print('No')" p03069,s115673276,Accepted,"n = int(input()) s = input() cost = 0 bc = 0 for it in s: if it ==""#"": bc += 1 else: if bc > 0: cost += 1 bc -= 1 print(cost) " p03073,s536693652,Accepted,"s = input() s_ls = [i for i in s] count = 0 for i in range(len(s)-1): if s_ls[i] == s_ls[i+1]: count += 1 if s_ls[i+1] == '1': s_ls[i+1] = '0' else: s_ls[i+1] = '1' print(count)" p03206,s208221281,Accepted,"d = int(input()) ans = 'Christmas' + ' Eve' * (25 - d) print(ans)" p02765,s780581389,Wrong Answer,"def main(): n, r = map(int,input().split()) if n >= 10: print(r) else: print(r + 100* (10 - r)) main()" p02689,s276297836,Accepted,"from sys import stdin, setrecursionlimit setrecursionlimit(10 ** 9) def input(): return stdin.readline().strip() N, M = map(int, input().split()) H = list(map(int, input().split())) g = [list() 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) ans = 0 for i in range(N): good = True for j in g[i]: if H[i] <= H[j]: good = False ans += good print(ans) " p03998,s652185605,Wrong Answer,"a, b, c = (input() for _ in range(3)) d = {""a"": a, ""b"": b, ""c"": c} nex = ""a"" while len(d[nex]) != 0: tmp = d[nex][0] d[nex] = d[nex][1:] nex = tmp print(nex)" p02797,s920913601,Accepted,"n,k,s = map(int, input().split()) if s<5: xx = 1 + s else: for i in range(2,s): if s%i != 0: xx = i break ans = [xx]* n for i in range(k): ans[i] = s print(' '.join(map(str, ans)))" p02797,s136835207,Accepted,"from collections import defaultdict from collections import deque from collections import Counter 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,k,s = readInts() for i in range(k): print(s, end="" "") for i in range(n-k): print(min(10**9-1,s+1),end="" "") print()" p02881,s733383517,Accepted,"import math n = int(input()) for i in range(int(math.sqrt(n)), 0, -1): if n % i == 0: print(int(i + n / i - 2)) break" p03730,s530487876,Accepted,"def main(): a,b,c=map(int,input().split()) sumi = set() for i in range(10**9): x = a*i%b if x in sumi: break elif x == c: print(""YES"") return else: sumi.add(x) print(""NO"") if __name__ == ""__main__"": main()" p04045,s261093003,Accepted,"N,K = map(int,input().split()) D = list(input().split()) while True: f = True for s in str(N): if s in D: f = False if f: print(str(N)) break else: N+=1" p02717,s710926945,Accepted," import heapq from collections import defaultdict, deque from math import ceil, factorial from fractions import gcd import sys sys.setrecursionlimit(10**7) INF = float('inf') MOD = 10**9+7 si = lambda: input().strip() ii = lambda: int(input()) mii = lambda: map(int, input().split()) lmii = lambda: list(map(int, input().split())) smii = lambda: sorted(map(int, input().split())) x, y, z = mii() print(z, x, y) " p03836,s313831619,Accepted,"xs,ys,xg,yg = map(int,input().split()) ans = '' for i in range(yg-ys): ans += 'U' for i in range(xg-xs): ans += 'R' for i in range(yg-ys): ans += 'D' for i in range(xg-xs + 1): ans += 'L' for i in range(yg-ys+1): ans += 'U' for i in range(xg-xs+1): ans += 'R' ans += 'DR' for i in range(yg-ys+1): ans += 'D' for i in range(xg-xs + 1): ans += 'L' ans += 'U' print(ans) " p02818,s445569893,Accepted,"a, b, k = map(int, input().split()) t_fin = max(0, a - k) a_fin = max(0, b - (k - (a - t_fin))) print('{} {}'.format(t_fin, a_fin)) " p03407,s309427802,Accepted,"import sys input = sys.stdin.readline A, B, C = map(int, input().split()) if A+B >= C: print(""Yes"") else: print(""No"")" p02987,s537184173,Accepted,"#!/usr/bin/env python3 import collections S = input() _set = set(S) if len(_set) == 2 and S.count(S[0]) == 2: print(""Yes"") else: print(""No"")" p03745,s852364447,Accepted,"N = int(input()) A = [int(i) for i in input().split()] nb = 0 da = 0 for i in range(len(A)-1): if A[i] > A[i+1] and da > 0: nb += 1 da = 0 elif A[i] < A[i+1] and da < 0: nb += 1 da = 0 else: if A[i+1] - A[i] != 0: da = A[i+1] - A[i] print(nb + 1)" p03448,s315585131,Wrong Answer,"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): if A*i + B*j + C*k == X: cnt +=1 print(cnt)" p02594,s235275974,Accepted,"n=int(input()) if n>=30: print(""Yes"") else: print(""No"")" p03555,s681437244,Accepted,"a = list(input()) b = list(input()) if a == list(reversed(b)): print(""YES"") else: print(""NO"")" p02571,s266570492,Accepted,"s = input() t = input() ls = [] for i in range(len(s) - len(t) + 1): ls.append(s[i:i+len(t)]) now = 0 minimum = len(t) for i in range(len(ls)): now = 0 for j in range(len(t)): if t[j] == ls[i][j]: now += 1 if len(t) - now < minimum: minimum = len(t) - now print(minimum)" p02725,s845221957,Accepted,"k, n = map(int, input().split()) a = list(map(int, input().split())) ans = [] for i in range(len(a)-1): ans.append(a[i+1]-a[i]) ans.append(k-a[-1]+a[0]) print(k-max(ans)) " p03264,s991499674,Wrong Answer,"K = int(input()) if K % 2 == 0: ans = (K/2)**2 else: ans = (K//2)*(K//2+1) print(ans)" p03555,s377912475,Wrong Answer,"# 077a def atc_077a(input_value: str) -> str: C1 = input_value[0] C2 = input_value[1] if C1[0] == C2[2] and C1[1] == C2[1]: return ""YES"" else: return ""NO"" C1 = input() C2 = input() print(atc_077a([C1,C2])) " p03495,s283528941,Accepted,"N, K = map(int, input().split()) d = {} for x in map(int, input().split()): n = d.get(x, 0) + 1 d[x] = n cnt = len(d) ret = 0 for k, v in sorted(d.items(), key=lambda item: item[1]): if K >= cnt: print(ret) exit() ret += v cnt -= 1 " p02726,s178119102,Accepted,"N, X, Y = map(int, input().split()) ans = [0] + [0]*(N-1) for i in range(1, N): for j in range(i+1, N+1): diff = min(j-i, abs(i-X)+abs(j-Y)+1) ans[diff] += 1 for i in range(1, N): print(ans[i]) " p02947,s867196266,Accepted,"n = int(input()) S = ["""".join(sorted(input())) for _ in range(n)] counters = {} for s in S: if s in counters: counters[s] += 1 else: counters[s] = 1 ans = 0 for v in counters.values(): if v == 1: continue ans += int(v * (v - 1) / 2) print(ans)" p03241,s140372864,Wrong Answer,"n, m = map(int, input().split()) if m % n == 0: print(m//n) else: a = m // n print(m % a)" p03061,s524806071,Wrong Answer,"import sys read = sys.stdin.read from math import gcd def main(): n, *a = map(int, read().split()) l = [0] * (n + 1) for i1 in range(n): l[i1 + 1] = gcd(l[i1], a[i1]) r = [0] * (n + 1) for j1 in range(n - 1, -1, -1): r[j1] = gcd(r[j1 + 1], a[j1]) m = [0] * (n + 1) for k1 in range(n - 1): m[k1] = gcd(l[k1], r[k1 + 1]) r = max(m) print(r) if __name__ == '__main__': main()" p03720,s626409446,Accepted,"N, M = list(map(int, input().split())) paths = [list(map(int, input().split())) for _ in range(M)] roads = {i : 0 for i in range(N)} for path in paths: roads[path[0]-1] +=1 roads[path[1]-1] +=1 for i in range(N): print(roads[i]) " p03815,s394065714,Wrong Answer,"import sys import math x=int(input()) if not ( 1 <= x <= 10**15 ): sys.exit() print(1) if x <= 6 else print(math.ceil((x/11)*2))" p03435,s768671418,Accepted,"from itertools import chain, groupby def flatten(list_of_lists): return chain.from_iterable(list_of_lists) def all_equal(iterable): g = groupby(iterable) return next(g, True) and not next(g, False) C = [list(map(int, input().split())) for _ in range(3)] s = sum(flatten(C)) x = all_equal([C[1][i] - C[0][i] for i in range(3)]) y = all_equal([C[2][i] - C[0][i] for i in range(3)]) z = all_equal([C[2][i] - C[1][i] for i in range(3)]) if all((x, y, z)) and s % 3 == 0: print(""Yes"") else: print(""No"") " p03000,s838157391,Wrong Answer,"n, x= input().split() n, x= int(n), int(x) lista=[] sum=0 for x in input().split(): x= int(x) lista.append(x) cont=1 for i in range(n): sum+=lista[i] if sum <= x: cont+=1 print(cont)" p02970,s989993090,Accepted,"N,D = map(int,input().split()) d = D * 2 + 1 if(N%d == 0): print(N//d) else: print(N//d+1)" p02639,s749832061,Wrong Answer,"X = [int(i) for i in input().split()] for c, x in enumerate(X): if x == 0: print(c) " p02720,s568840547,Accepted,"from collections import deque K = int(input()) q = deque([0]) cnt = 0 ans = [] while q: a = q.popleft() r = a % 10 a *= 10 for i in range(10): if abs(r - i) <= 1 or a == 0: if cnt < K and a + i != 0: q.append(a + i) ans.append(a + i) cnt += 1 print(ans[-1])" p02847,s588101138,Wrong Answer,"day = [""SUN"",""MON"",""TUE"",""WED"",""THU"",""FRI"",""SAT""] print(day[(day.index(input())+1)%7]) " p03644,s217130722,Accepted,"n = int(input()) ans = 1 while ans*2 <= n: ans *= 2 print(ans)" p03437,s342434806,Accepted,"X, Y = map(int, input().split()) if X == Y or X % Y == 0: print(-1) else: start = X while start % Y == 0: start += X print(start)" p03639,s817016851,Accepted,"N = int(input()) a_list = list(map(int, input().split())) r2 = 0 r4 = 0 for i in range(N): if a_list[i]%2==0: r2 += 1 if a_list[i]%4==0: r4 += 1 r2 -= r4 r0 = N - r2 - r4 if N % 2==0: print(""Yes"") if r4 >= r0 else print(""No"") else: print(""Yes"") if r4 >= r0-1 else print(""No"") " p02946,s576275853,Accepted,"import sys, heapq K, X =map(int, input().split()) for i in range(X - K + 1, X + K): print(i, end="" "") print("""")" p03161,s692778535,Accepted,"import numpy as np l,l2 = map(int,input().split()) x = np.array(list(map(int,input().split()))) dp = np.zeros(l,dtype=int) dp[1] = abs(x[0]-x[1]) for i in range(2,l): y = max(i - l2,0) dp[i] = np.min(dp[y:i] + abs(x[y:i] - x[i])) print(dp[-1])" p02948,s618083249,Accepted,"N,M = map(int, input().split()) L = [[int(l) for l in input().split()] for _ in range(N)] import heapq h = [] ans = 0 L.sort() m = 1 i = 0 while i < N and L[i][0] <= M: if L[i][0] == m: heapq.heappush(h, -L[i][1]) i += 1 else: m += 1 if h: ans -= heapq.heappop(h) while m <= M and h: ans -= heapq.heappop(h) m += 1 print(ans)" p03137,s451470509,Accepted,"N,M = map(int,input().split()) X= list(map(int,input().split())) X.sort() distance =[0]*(M-1) for i in range(M-1): distance[i] = X[i+1]-X[i] d_sum = sum(distance) distance.sort() if N>=M: d_sum = 0 elif N !=1: for i in range(N-1): d_sum-=distance[(M-2)-i] print(d_sum) " p02994,s898480286,Accepted,"N,L=map(int,input().split()) left=L right=left+N-1 if right<=0:eated=right elif 0b: print(""Alice"") elif a= MOD: x -= MOD dp[n] = x answer = dp[N] print(answer) " p02756,s650707988,Accepted,"s = input() q_number = int(input()) reverse_flag = 1 head = """" tail = """" for i in range(q_number): temp = input().split() if temp[0] == ""1"": reverse_flag = reverse_flag * -1 else: headstails = int(temp[1])*reverse_flag if headstails == 1 or headstails == -2: head = temp[2] + head else: tail = tail + temp[2] if reverse_flag == 1: print(head+s+tail) else: print(tail[::-1]+s[::-1]+head[::-1]) " p03243,s458881037,Wrong Answer,"N = int(input()) if N//111 == 0: print(N) else: print((N//111 + 1) * 111)" p02833,s601705883,Wrong Answer,"n=int(input()) ans=0 if n % 2==0: for i in range(1,19): waru = 2*5**i if n < waru: break else: tmp = n/waru ans += int(tmp) print(str(ans))" p02819,s784724106,Accepted,"import math x = int(input()) while True: for i in range(2, int(math.sqrt(x)+1)): if x % i == 0: x += 1 break else: break print(x) " p02951,s980968312,Accepted,"A, B, C = map(int, input().split()) print(max(C-A+B,0))" p02780,s914751233,Accepted,"n,k=map(int,input().split()) p=list(map(int,input().split())) s=[] for i in p: t=(1+i) s.append(t) t=[0,] for i in range(n): u=t[i]+s[i] t.append(u) ans=0 for i in range(n-k+1): ans=max(ans,t[i+k]-t[i]) print('{:.10f}'.format(ans/2))" p02576,s653459020,Accepted,"N,X,T = map(int,input().split()) if N%X == 0: a = N//X else: a = N//X + 1 print(a*T)" p04043,s735649991,Accepted,"s=input().split() print(""YES"" if s.count(""5"")==2 and s.count(""7"")==1 else ""NO"")" p03472,s665035769,Wrong Answer,"n, h = map(int, input().split()) a, b = [], [] for _ in range(n): x, y = map(int, input().split()) a.append(x) b.append(y) max_a = max(a) b.sort(reverse=True) cnt = 0 for i in range(n): if b[i] < max_a: break h -= b[i] cnt += 1 if h <= 0: break cnt += (h - 1) // max_a + 1 print(cnt)" p03699,s145132167,Wrong Answer,"N = int(input()) A=[] for i in range(N): A.append(int(input())) B = [0]*N B[0] = A[0] for i in range(1, N): B[i] += B[i-1]+A[i] B.sort(reverse=True) for i in B: if i%10 != 0: print(i) break else: print(0)" p02817,s448616842,Accepted,"s,t = map(str, input().split()) print(t+s)" p03657,s680007522,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')" p03721,s926254679,Wrong Answer,"n,k = map(int,input().split()) d = {} for i in range(n): a,b = map(int,input().split()) if a in d: d[a] += b else: d[a] = b cnt = 0 for i,j in enumerate(d.values()): cnt += j if cnt >= k: print(list(d.keys())[i]) break" p02607,s847354925,Accepted,"N = int(input()) A = list(map(int, input().split())) count = 0 for i in range(1, N+1, 2): if A[i-1]%2 == 1: count += 1 print(count)" p03623,s461298679,Wrong Answer,"x, a, b = map(int, input().split()) print(""A"" if abs(x-a) > abs(x-b) else ""B"")" p02570,s579643815,Accepted,"d,t,s = map(int,input().split()) print(""Yes"" if s*t>=d else ""No"")" p03494,s977947135,Wrong Answer," n=input() ans=0 i=0 b=list(map(int,input().split())) print(b) print(type(b[0])) end=True while end: b=list(map(lambda x:x/2,b)) print(b) ans+=1 for x in b: if x%2!=0: print(ans) end=False break " p03286,s994241954,Accepted,"n = int(input()) amari = [] while True: if n >1 or n<0: amari.append(-(n%(-2))) n = (n-(-(n%(-2))))//(-2) else: amari.append(n) break gyaku = amari[::-1] print(*gyaku,sep="""")" p02687,s805570678,Accepted,"s = input() if s == ""ARC"": print(""ABC"") else: print(""ARC"") " p02829,s210392498,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())) l=set([1,2,3]) for i in range(2): l=l-set([int(input())]) print(int(list(l)[0]))" p03127,s823963113,Accepted,"from fractions import gcd n=int(input()) a=list(map(int,input().split())) ans=a[0] for i in a[1:]: ans=gcd(ans,i) print(ans)" p03437,s744932925,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 x,y=MI() if x%y==0: print(-1) else: print(x*(y+1)) main() " p02701,s890258201,Accepted,"N = int(input()) S = [input() for _ in range(N)] print(len(set(S)))" p03251,s919875460,Accepted,"from typing import List def answer(n: int, m: int, x: int, y: int, xs: List[int], ys: List[int]) -> str: xs.append(x) ys.append(y) if min(ys) <= max(xs): return 'War' return 'No War' def main(): n, m, x, y = map(int, input().split()) xs = list(map(int, input().split())) ys = list(map(int, input().split())) print(answer(n, m, x, y, xs, ys)) if __name__ == '__main__': main() " p03637,s615903397,Accepted,"input();a,b1,b2,b4=list(map(int,input().split())),0,0,0 for i in a: if i%2!=0: b1+=1 elif i%4==0: b4+=1 else: b2+=1 print('Yes'if b1<=b4 else'No'if b2 else'Yes'if b1<=b4+1 else'No')" p03448,s842756224,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): if i * 500 + j * 100 + k * 50 == x: cnt += 1 print(cnt)" p02918,s509202794,Accepted,"def main(n,k,s): l=[0] for i in range(1,n): if s[i]==s[i-1]: l[-1]+=1 else: l.append(0) print(min(n-1,sum(l)+k*2)) if __name__=='__main__': import sys input = sys.stdin.readline n,k=map(int,input().split()) s=input() main(n,k,s) " p02607,s606852816,Accepted,"n = int(input()) a = list(map(int, input().split())) res = 0 for i in range(0, n, 2): if a[i] % 2 != 0: res += 1 print(res) " p03309,s807680596,Accepted,"from math import ceil n = int(input()) arr = list(map(int, input().split())) B = [] for i in range(n): B.append(arr[i] - (i+1)) B.sort() b1 = B[n//2] b2 = B[n//2] if n > 1: b2 = B[int(ceil(n/2))] ans1, ans2 = 0, 0 for i in range(n): ans1 += abs(arr[i]-(b1+i+1)) ans2 += abs(arr[i]-(b2+i+1)) print (min(ans1, ans2))" p02843,s672562394,Accepted,"X = int(input()) N, r = divmod(X, 100) if r <= 5*N: print(1) else: print(0)" p02988,s995883097,Accepted,"n = int(input()) p = input().split("" "") ans = 0 for i in range(1,n-1): if (int(p[i-1]) < int(p[i]) and int(p[i]) < int(p[i+1])) or(int(p[i-1]) > int(p[i]) and int(p[i]) > int(p[i+1])): ans += 1 else: ans += 0 print(ans)" p02646,s054342393,Accepted,"A, V = map(int, input().split()) B, W = map(int, input().split()) T = int(input()) dist = abs(A - B) velocity = V - W if velocity * T >= dist: print('YES') else: print('NO') " p03206,s004137099,Accepted,"d = int(input()) ans = [""Christmas"", ""Eve"", ""Eve"", ""Eve""] print("" "".join(ans[:26-d]))" p03720,s285277643,Wrong Answer," N,M = map(int,input().split()) adj = [[0]*N for _ in range(N)] intx = lambda x: int(x)-1 for i in range(M): a,b = map(intx,input().split()) #print(a,b) adj[a][b] = 1 adj[b][a] = 1 for i in range(N): print(sum(adj[i]))" p02720,s353773371,Accepted,"from collections import deque K=int(input()) Q=deque(list(range(1,10))) for _ in range(K): x=Q.popleft() if x%10 != 0: Q.append(10*x+x%10-1) Q.append(10*x+x%10) if x%10 != 9: Q.append(10*x+x%10+1) print(x)" p03221,s188501313,Accepted,"N, M = map(int, input().split()) C = [] for i in range(M): p, y = map(int, input().split()) C.append([i, p, y]) C.sort(key=lambda x: (x[1], x[2])) ans = [] k = C[0][1] n = 1 for i in range(M): city = C[i][1] if k != city: k = city n = 1 number = f'{city:06}{n:06}' ans.append([C[i][0], number]) n += 1 ans.sort(key=lambda x: x[0]) for i in range(M): print(ans[i][1]) " p03774,s101135597,Accepted,"n,m=map(int,input().split()) ab=[[int(x) for x in input().split()] for _ in range(n)] cd=[[int(x) for x in input().split()] for _ in range(m)] for a,b in ab: ans=list() for c,d in cd: ans.append(abs(a-c)+abs(b-d)) print(ans.index(min(ans))+1) " p02743,s094279618,Accepted,"a, b, c = map(int, input().split()) if 4*a*b < (c-a-b)**2 and c > a+b: print('Yes') else : print('No')" p03073,s162598904,Accepted,"s = input() pattern1 = 0 pattern2 = 0 for i in range(len(s)): if i %2 == 0: if s[i] == ""0"": pattern1 += 1 else: pattern2 += 1 else: if s[i] == ""0"": pattern2 += 1 else: pattern1 += 1 print(min(pattern1,pattern2))" p03417,s288224943,Accepted,"n, m = [int(i) for i in input().split()] if n > m: n, m = m, n if n == m == 1: print(1) elif n == 1 and m > 1: print(m - 2) else: print((n - 2) * (m - 2)) " p03665,s753321255,Wrong Answer,"n,p=map(int,input().split()) a=[i%2 for i in map(int,input().split())] print(2**(n-1)) " p02684,s762773177,Wrong Answer,"from collections import deque N,K = map(int,input().split()) telpo = [int(x) for x in input().split()] now = 1 loop = deque([now]) count = 0 for i in range(K): now = telpo[now-1] if now in loop: while now != loop[0]: loop.popleft() count += 1 break else: loop.append(now) remain = (K-count)%len(loop) for i in range(remain): now = telpo[now-1] print(now)" p02747,s488967089,Accepted,"S = input() for i in range(0, len(S), 2): if S[i:i+2] != ""hi"": print(""No"") break else: print(""Yes"")" p02818,s430651601,Wrong Answer,"A, B, K = map(int, input().split()) x = K - A if 0 <= x: A = 0 B = B - x else: A = A + x print(A, B) " p02831,s343166597,Wrong Answer," A, B = map(int, input().split("" "")) A_, B_ = A, B common = 1 n_max = int(min(A,B)**0.5+1) for n in range(2, n_max+1): while True: if (A_ % n == 0) and (B_ % n == 0): common *= n A_ = A_ // n B_ = B_ // n else: break print(A*B//common) " p02627,s918500518,Accepted,"a = input() if a.isupper()== True : print('A') else : print('a') " p03161,s163218433,Accepted,"N, K = map(int, input().split()) h = [int(x) for x in input().split()] INF = float('inf') dp = [INF] * N dp[0] = 0 for i in range(1, N): if i < K: k = i else: k = K for j in range(i-k, i): dp[i] = min(dp[i], dp[j] + abs(h[i]-h[j])) print(dp[-1])" p03556,s066591667,Wrong Answer,"n = int(input()) ans = 1 for i in range(n): if i**2 <= n: ans = i**2 else: break print(ans)" p03456,s337256550,Accepted,"import math a,b=input().split() n=a+b n=int(n) if int(math.sqrt(n))**2==n: print(""Yes"") else: print(""No"")" p02842,s736434075,Accepted,"N = int(input()) import math X = math.ceil(N/1.08) if math.floor(X * 1.08) == N: print(X) else: print("":("") " p03264,s218388412,Accepted,"n=int(input()) if n % 2 == 0: temp = int(n/2) print(temp ** 2) else: temp = n//2 print(temp*(temp+1))" p03379,s624115114,Accepted,"def main(): n = int(input()) x = [int(xn) for xn in input().split()] x_sorted = sorted(x) idx_median = n // 2 median_low = x_sorted[idx_median - 1] median_high = x_sorted[idx_median] for xn in x: print(median_high if xn <= median_low else median_low) if __name__ == '__main__': main() " p02658,s003670754,Wrong Answer,"import numpy as np N = int(input()) A_1n = np.array(list(map(int, input().split()))) if 0 not in A_1n: out = np.cumprod(A_1n)[-1] print(out) if out < 10 ** 18 else print(-1) else: print(0)" p02755,s425629891,Wrong Answer,"a,b = map(int,input().split()) o = 0.08 t = 0.1 x = a / o y = b / t if x > y: lst = [i for i in range(int(y),int(x+1))] else: lst = [i for i in range(int(x),int(y+1))] for i in lst: if int(i * o) == a and int(i*t)==b: print(i) exit() print(-1)" p03524,s850827990,Wrong Answer,"s=input() n=len(s) set=set(s) t=len(set) m=n//t res=0 for i in set: if m<=s.count(i) 1: print('No') sys.exit() print('Yes') " p02553,s923486239,Accepted,"a, b, c, d = map(int, input().split()) ans = -float('inf') for x in (a, b): for y in (c, d): ans = max(ans, x * y) print(ans) " p03607,s871355006,Accepted,"N=int(input()) A=[int(input()) for i in range(N)] dict = {} for i in A: if i not in dict: dict[i] = 1 else: dict[i] += 1 print(len([1 for i in dict.values() if i%2!=0]))" p03545,s501846671,Accepted,"nums = list(input()) for i in range(2**3): seven = int(nums[0]) opt = [] for j in range(3): if i >> j & 1: seven += int(nums[j+1]) opt.append(""+"") else: seven -= int(nums[j+1]) opt.append(""-"") if seven == 7: print(nums[0]+opt[0]+nums[1]+opt[1]+nums[2]+opt[2]+nums[3]+""=7"") exit() " p02597,s259719289,Accepted,"N = int(input()) c = input() right = N-1 left = 0 cnt = 0 for i in range(N): if right <= left: break if c[right] == ""W"": right -= 1 else: if c[left] == ""R"": left += 1 # 交換 else: cnt += 1 left += 1 right -= 1 print(cnt)" p04029,s703232116,Accepted,"n = int(input()) sum=0 for i in range(1,n+1): sum+=i print(sum) " p03456,s658259354,Wrong Answer,"a, b = input().split() l_a = len(a) l_b = len(b) if isinstance((int(a)*(10**l_b) + int(b))**0.5, int): print('Yes') else: print('No')" p02578,s045792235,Accepted,"import sys n=int(input()) li=[int(x) for x in input().split()] h=0 k=0 for i in range(n): if h<=li[i]: h=max(h,li[i]) else: k=k+(h-li[i]) h=max(h,li[i]) print(k)" p03804,s567156484,Accepted,"n,m = map(int,input().split()) A = [input() for i in range(n)] B = [input() for i in range(m)] ans = ""No"" for i in range(n-m+1): for j in range(n-m+1): for k in range(m): if B[k] != A[k+i][j:j+m]: break if k == m-1 and B[k] == A[k+i][j:j+m]: ans = ""Yes"" print(ans)" p03657,s735822499,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,s556320608,Accepted,"n,m=map(int,input().split()) a = [0]*n b = [0]*n for i in range(n): a[i] = list(map(int, input().split())) a.sort() ans=0 for i in range(n): ans+=a[i][0]*min(m,a[i][1]) m-=a[i][1] if m<=0: break print(ans)" p02789,s040348291,Wrong Answer,"n,m = map(int, input().split()) if n >= m: print('Yes') else: print('No')" p03000,s693549079,Wrong Answer,"n,x=map(int,input().split()) l=list(map(int,input().split())) cnt=0 d=[0 for _ in range(n+1)] d[0]=0 for i in range(1,n+1): d[i]=d[i-1]+l[i-1] if d[i]<=x: cnt+=1 print(cnt)" p02818,s278578244,Wrong Answer,"a,b,k=map(int,input().split()) if a>k: print(a-k,b) elif a+b>k: print(0,a-(k-a)) else: print(0,0)" p03711,s844005755,Wrong Answer,"a,b = map(int,input().split()) if a in {1,3,5,7,8,10,12} and b in {1,3,5,7,8,10,12}: print(""Yes"") if a in{2} and b in {2}: print(""Yes"") if a in {4,6,9,11} and b in {4,6,9,11}: print(""Yes"") else: print(""No"") " p03478,s373604652,Accepted,"n, a, b = map(int, input().split()) ans = 0 for i in range(1, n+1): s = str(i) tot = 0 for c in s: tot += ord(c) - ord('0') if tot >= a and tot <= b: ans += i print(ans) " p02697,s196749608,Accepted,"N, M = map(int, input().split()) res = [] if N % 2 == 0: x = 0 for i in range(N // 2 // 2): res.append((x + 1, (x + 2 * i + 1) % N + 1)) x -= 1 x %= N for i in range((N // 2 - 1) // 2): res.append((x + 1, (x - (N // 2 - 1) // 2 * 2 + 2 * i) % N + 1)) x -= 1 x %= N else: for i in range(N // 2): res.append((i + 1, N - i - 1)) for i in range(M): a, b = res[i] print(a, b)" p02847,s098275641,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) else: print(1)" p02754,s056404230,Accepted,"N, A, B = map(int, input().split()) if N % (A+B) > A: left = A else: left = N % (A+B) ans = (N // (A+B)) * A + left print(ans)" p03161,s509043747,Accepted,"import sys def input(): return sys.stdin.readline().strip() def main(): n, k = map(int, input().split()) cst = list(map(int, input().split())) arr = [0] * n arr[1] = abs(cst[1] - cst[0]) for i in range(2, n): arr[i] = min(abs(cst[j] - cst[i]) + arr[j] for j in range(max(i - k, 0), i)) print(arr[n - 1]) if __name__ == '__main__': main() " p02817,s244753454,Wrong Answer,"s,t = (i for i in input().split()) print(s+t)" p03416,s931017027,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)" p02820,s444331709,Accepted,"import math import bisect N,K = list(map(int,input().split("" ""))) r,s,p = list(map(int,input().split("" ""))) di = {} di[""r""] = p di[""s""] = r di[""p""] = s di[""@""] = 0 T = input() T = list(T) for i in range(K,N): if T[i - K] == T[i]: T[i] = ""@"" ans = 0 for temp in T: ans += di[temp] print(ans) " p02578,s159413741,Accepted,"n = int(input()) a = list(map(int, input().split())) mae = a[0] ans = 0 for i in a: if mae > i: ans += mae - i else: mae = i print(ans) " p03994,s606017340,Accepted,"s, k, t = input(), int(input()), """" for q in s: if (p := (123 - ord(q)) % 26) <= k: k -= p t += ""a"" else: t += q print(t[:-1] + chr((ord(t[-1]) - 97 + k) % 26 + 97))" p03795,s254438515,Accepted,"N = int(input()) print(N*800 - 200*(N//15))" p03544,s595685510,Wrong Answer,"n=int(input()) s=[] s.append(2) s.append(1) if n==1: print('2') exit() elif n==2: print('1') exit() else: for i in range(2,87): k = s[i-2]+s[i-1] s.append(k) if i==n: print(s[i]) exit() " p03493,s527220565,Accepted,"a=input() print(int(a[0])+int(a[1])+int(a[2]))" p02765,s030567461,Wrong Answer,"N,R=map(int,input().split()) print(R-100*(10-N))" p03632,s871381515,Accepted,"a, b, c, d = map(int, input().split()) print(max(min(b,d) - max(a,c), 0))" p02787,s600102196,Wrong Answer,"H, N = map(int, input().split()) # mahous = [(a, b) for a, b in list(map(int, input().split()))] mahous = [] for i in range(N): a, b = map(int, input().split()) mahous.append((a, b)) dp = [float(""inf"")] * (H + 1) dp[0] = 0 for h in range(1, H + 1): for n in range(N): a, b = mahous[n] if h - a >= 0: dp[h] = min(dp[h], dp[h - a] + b, dp[h - 1] + b) # print(dp) print(dp[H])" p02838,s831871905,Accepted,"n = int(input()) a = list(map(int,input().split())) c = [0]*100 for i in a: b = format(i,'b')[::-1] for x in range(len(b)): c[x] += int(b[x]) ans = 0 mod = 10**9+7 for i in range(100): ans += c[i]*(n-c[i])*2**i ans %= mod print(ans)" p04034,s848629879,Wrong Answer,"n,m=map(int,input().split()) li=[list(map(int,input().split())) for _ in range(m)] box=[[1,0]] for i in range(n-1): box.append([0,1]) for x,y in li: tmp=box[x-1].copy() box[x-1][0]-=tmp[0]/(tmp[0]+tmp[1]) box[x-1][1]-=tmp[1]/(tmp[0]+tmp[1]) box[y-1][0]+=tmp[0]/(tmp[0]+tmp[1]) box[y-1][1]+=tmp[1]/(tmp[0]+tmp[1]) ans=0 for i in box: if i[0]>0: ans+=1 print(ans)" p04019,s705889462,Wrong Answer,"S = input() now = (0, 0) d = {'S': (0, -1), 'E': (1, 0), 'N': (0, 1), 'W': (-1, 0)} res = ""No"" for i in range(len(S)): now = (now[0] + d[S[i]][0], now[1] + d[S[i]][1]) if now == (0, 0): res = ""Yes"" break print(res) " p03274,s145036994,Accepted,"def main(): _, k = map(int, input().split()) x = tuple(map(int, input().split())) print(min(r - l + min(abs(l), abs(r)) for l, r in zip(x, x[k - 1 :]))) if __name__ == ""__main__"": main()" p03220,s153691828,Wrong Answer,"N = int(input()) T,A = map(int,input().split()) H = list(map(int,input().split())) a_meter = (12-A)/0.006 ans = -1 diff = 10**6 for i in range(N): temp = abs(a_meter - H[i]) # print(""temp:"" + str(temp)) # print(""diff:"" + str(diff)) if diff > temp: diff = temp ans = i+1 print(ans)" p02705,s556303226,Wrong Answer,"import math i = int(input()) print(i*math.pi)" p03071,s501933915,Wrong Answer,"a,b=map(int,input().split()) if a==b: print(2*a) else: print(2*a-1)" p02888,s113826072,Wrong Answer,"import bisect N = int(input()) L = sorted(list(map(int, input().split()))) ans = 0 for i in range(N): for j in range(i+1, N): t = L[i] + L[j] idx = bisect.bisect_left(L, t) ans += max(0, idx-j-1) print(i, j, idx, ans) print(ans)" p02993,s555811570,Wrong Answer,"import collections s = str(input()) l = [] for i in range(0,4): l.append(s[i]) i += 1 c = collections.Counter(l) if len(c) == 4: print('Good') else: print('Bad')" p02951,s665807952,Accepted," a, b, c = map(int, input().split()) res = 0 if a < b+c: res = b + c - a else: res = 0 print(res) " p02993,s008156943,Wrong Answer,"S = input() if S[0] != S[1]!= S[2] != S[3]: print(""Bad"") else: print(""Good"")" p03486,s961069370,Accepted,"s = sorted(input()) t = sorted(input(), reverse=True) print(""Yes"") if s < t else print(""No"")" p02888,s165387729,Accepted,"import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N, *L = map(int, read().split()) L.sort() ans = 0 for i in range(1,N-1): upper = N-1 for j in reversed(range(0,i)): sum = L[i] + L[j] if upper == N : upper = N-1 while upper > i and sum <= L[upper]: upper -= 1 ans += upper-i print(ans) " p03705,s486476320,Wrong Answer,"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,A,B=MI() ans=0 rem=N-2 rem=max(rem,0) ans=rem*(B-A)+1 ans=max(ans,0) if A>B or rem==0: ans=0 print(ans) main() " p03633,s549129144,Accepted,"import fractions def lcm(a,b): return (a*b)//fractions.gcd(a,b) N=int(input()) T=1 for i in range(N): T=lcm(T,int(input())) print(T)" p02606,s165852534,Accepted,"import bisect, collections, copy, heapq, itertools, math, numpy, string import sys from bisect import bisect_left, bisect_right, insort from collections import deque def S(): return sys.stdin.readline().rstrip() def I(): return int(sys.stdin.readline().rstrip()) def MI(): return map(int, sys.stdin.readline().rstrip().split()) def MS(): return map(str, sys.stdin.readline().rstrip().split()) def LI(): return list(map(int, sys.stdin.readline().rstrip().split())) def LS(): return list(sys.stdin.readline().rstrip().split()) # N = I() # A = [LI() for _ in range(N)] l,r,d = MI() print(r//d-(l-1)//d)" p03455,s035667541,Wrong Answer,"a, b = map(int, input().split()) answer = (a * b)% 2 if answer == 0: print('even') else: print('odd')" p02717,s636979358,Wrong Answer,"a,b,c = map(int,input().split()) print(str(c),"""",str(a),"""",str(c)) " p03705,s809646234,Wrong Answer,"N, A, B = map(int, input().split()) if A>B: print(0) exit() ans = (B*(N-1)+A) - (A*(N-1)+B) + 1 print(ans) " p04033,s304620116,Accepted,"a,b = map(int,input().split()) if a <= 0 and b >= 0: print(""Zero"") elif a > 0: print(""Positive"") elif b < 0: tmp = b-a if tmp %2 == 1: print(""Positive"") else: print(""Negative"")" p03544,s454797848,Accepted,"N = int(input()) dp = [0] * (N + 1) dp[0] = 2 dp[1] = 1 for i in range(2, N + 1): dp[i] = dp[i - 2] + dp[i - 1] print(dp[N])" p03971,s065012670,Wrong Answer,"N, A, B = map(int, input().split()) S = input() a = b = 0 for s in S: if s == 'a' and a+b < A+B: print('Yes') a += 1 elif s == 'b' and b < B: print('Yes') b += 1 else: print('No')" p02775,s488206978,Accepted,"n = list(input()) r = list(map(int,n))[::-1] ans = 0 k = 0 f = 0 for i in r: i += k if f==5 and i>4: i += 1 ans += min(i,10-i) k = int(i>5) f = i print(ans+k)" p02664,s935234258,Accepted,"t=input() ans="""" for i in range(len(t)): if t[i]==""?"": ans+=""D"" else: ans+=t[i] print(ans) " p03693,s150049581,Accepted,"r, g, b = map(int, input().split()) if ((10 * g + b) % 4 == 0): print(""YES"") else: print(""NO"") " p02860,s746700387,Accepted,"n = int(input()) s = input() if n % 2 == 1: print('No') else: if s[:n // 2] == s[n // 2:]: print('Yes') else: print('No') " p02777,s596949687,Accepted,"S, T = [i for i in input().split()] A, B = [int(i) for i in input().split()] U = input() if U == S: print(A-1, B) else: print(A, B-1)" p03408,s724234099,Accepted,"from collections import Counter # ABC091 N = int(input()) S = Counter([input() for _ in range(N)]) M = int(input()) T = Counter([input() for _ in range(M)]) ans = 0 for word, count in S.items(): temp = count - T[word] ans = max(ans, temp) print(ans)" p03971,s183179787,Accepted,"N, A, B = map(int, input().split()) S = input() qual = {""A"": 0, ""B"": 0} for i in range(N): ans = False l = S[i] if qual[""A""] + qual[""B""] < A + B: if l == ""a"": ans = True qual[""A""] += 1 elif l == ""b"": if qual[""B""] < B: ans = True qual[""B""] += 1 if ans: print('Yes') else: print('No')" p03943,s470945546,Accepted,"li = sorted(list(map(int, input().split()))) # n, m = map(int, input().split()) if li[0] + li[1] == li[2]: print(""Yes"") else: print(""No"") # print(chr(ord('A')+ind[1])+str(ind[0]))" p03679,s869638139,Accepted,"X, A, B = map(int, input().split()) if A-B >= 0: print(""delicious"") elif B-A <= X: print(""safe"") else: print(""dangerous"")" p02761,s465090201,Wrong Answer,"ans=-1 n,m=map(int,input().split()) l=[list(map(int,input().split())) for i in range(m)] for k in range(10**(n-1),10**n): for i in range(m): if str(k)[l[i][0]-1]!=str(l[i][1]): break else: ans=k print(ans) break if ans==-1: print(-1)" p03854,s457661534,Accepted,"s = input() s = s[-1::-1] word = ['resare','esare','remaerd','maerd',] for i in word: s = s.replace(i,'') if s: print('NO') else: print('YES')" p03437,s437467206,Accepted,"x,y = map(int,input().split()) if x%y != 0: print(x) else: print(-1)" p03548,s422722353,Accepted,"x,y,z = map(int, input().split()) print(int((x-z)/(y+z))) " p03211,s911685834,Wrong Answer,"S = input() ans = 753 for i in range(len(S)-3): ans = min(ans, abs(int(S[i:i+3])-753)) print(ans)" p03471,s854599288,Accepted,"x,y=map(int,input().split()) a1=-1 b1=-1 c1=-1 for a in range(0,x+1): for b in range(0,x+1-a): c=x-a-b if 10000*a+5000*b+1000*c==y: a1=a b1=b c1=c print(a1,b1,c1)" p02988,s424629368,Accepted,"n=int(input()) t = list(map(int,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) " p02970,s378759011,Wrong Answer,"n,d=map(int,input().split()) for i in range(1,n): if (2*d+1)*i>=n: print(i) break" p03548,s172985562,Accepted,"X, Y, Z = map(int, input().split()) X -= Z people = 0 while X >= 0: X -= (Y + Z) if X >= 0: people += 1 print(people) " p02873,s824905170,Wrong Answer,"S = list(input()) before = '' count = 0 answer = 0 for s in S: if s == before: count += 1 else: before = s if count > 0: answer += (count+1)*(count+2)//2 count = 0 if count > 0: answer += (count+1)*(count+2)//2 print(answer) " p02600,s526311410,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" p03377,s832749689,Accepted,"A, B, X = map(int, input().split()) if X > A+B: print(""NO"") elif A > X: print(""NO"") else: print(""YES"")" p03107,s321892260,Accepted,"s=input() s0=s.count(""0"") s1=s.count(""1"") print(min(s0,s1)*2) " p03481,s558427603,Accepted,"a,b = map(int,input().split()) ans = 0 while a <= b: ans += 1 a *= 2 print(ans)" p02760,s832107319,Accepted,"import numpy as np A = np.array([]) f=False B= np.zeros((3,3)) for i in range(3): A=np.append(A,list(map(int,input().split()))) A=A.reshape(3,3) n=int(input()) for i in range(n): x=int(input()) B+=(A==x)*1 for i,j in zip(sum(B),sum(B.T)): f=f or (i//3) or (j//3) f = f or (sum(np.diag(B))//3) f = f or (sum(np.diag(np.fliplr(B)))//3) print(""Yes"" if f else ""No"")" p02659,s669338019,Accepted,"from decimal import * a, b = input().split() a = Decimal(a) b = Decimal(b) ans = a * b ans = Decimal(str(ans)).quantize(Decimal(str(0)), rounding=ROUND_DOWN) print(ans)" p02583,s820571766,Accepted,"N = int(input()) L = list(map(int,input().split())) count = 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[i] != L[k] and L[j] != L[k]: if L[i]+L[j] > L[k] and L[i]+L[k] > L[j] and L[j]+L[k] > L[i]: count += 1 print(count)" p02602,s065986090,Wrong Answer,"N,K=map(int,input().split()) A=list(map(int,input().split())) point=[1.0]*(N+1) for i in range(K): point[K]=point[K]*A[i] M=N-K+1 for i in range(1,M): point[K+i]=point[K+i-1]*A[K+i-1]/A[i-1] for i in range(M-1): if point[K+i]0: k-=s[i] i+=1 print(i)" p03150,s999831982,Wrong Answer,"import re s = input() pattern={ '.*keyence' ,'k.*eyence' ,'ke.*yence' ,'key.*ence' ,'keye.*nce' ,'keyen.*ce' ,'keyenc.*e' ,'keyence.*' ,'keyence' } for p in pattern: if re.match(p, s): print('YES') break else: print('NO')" p03607,s926171960,Accepted,"from collections import Counter N = int(input()) A = [int(input()) for _ in range(N)] CA = Counter(A) ans = 0 for value in CA.values(): if value % 2 == 1: ans += 1 print(ans) " p03041,s964789414,Accepted,"n, k = map(int, input().split()) s = list(input()) s[k-1] = s[k-1].lower() print("""".join(s))" p03262,s674899997,Accepted,"import math N, X = list(map(lambda n:int(n), input().split("" ""))) x = list(map(lambda y:int(y), input().split("" ""))) x.append(X) x.sort() d = list(filter(lambda r: r != 0, [abs(x[i + 1] - x[i]) for i in range(len(x) - 1)])) gcd = d[0] for i in range(len(d)): gcd = math.gcd(d[i], gcd) print(gcd) " p03146,s858948565,Accepted,"a_1=int(input()) a=[a_1] for i in range(1000000): if a[-1]%2==0: a_next=a[-1]//2 else: a_next=3*a[-1]+1 if a_next in a: print(i+2) break a.append(a_next)" p02583,s803195132,Accepted,"import sys import itertools n = int(input()) # = map(int, input().split()) l = sorted(list(map(int, input().split()))) if n < 3 or len(set(l)) < 3: print(0) sys.exit() c = list(itertools.combinations(l, 3)) ans = 0 for i in range(len(c)): if len(set(c[i])) < 3: continue if c[i][0] + c[i][1] <= c[i][2]: continue ans += 1 print(ans) " p03719,s642684252,Accepted,"A, B, C = map(int, input().split()) if (C >= A) & (C <= B): print(""Yes"") else: print(""No"")" p03162,s312412826,Wrong Answer,"N=int(input()) nums=[] for _ in range(N): nums.append(list(map(int, input().split()))) dp = [[0 for _ in range(3)] for _ in range(N)] for i in range(N): a,b,c=nums[i] dp[i][0]=max(dp[i-1][1]+a,dp[i-1][2]+a) dp[i][1]=max(dp[i-1][0]+b,dp[i-1][2]+b) dp[i][2]=max(dp[i-1][0]+c,dp[i-1][1]+c) print(max(dp[-1])) " p02714,s891461217,Accepted," N = int(input()) S = input() r = S.count(""R"") g = S.count(""G"") b = S.count(""B"") all_case = r*g*b excluded_case = 0 for i in range(N): for j in range(i+1, N): if S[i] == S[j]: continue k = j*2-i if k>= N or S[k] == S[i] or S[k] == S[j]: continue excluded_case += 1 print(all_case-excluded_case) " p03693,s762780931,Wrong Answer,"N = int("""".join(map(str,input().split()))) print((""No"",""Yes"")[N % 4 == 0])" p03030,s370928707,Accepted,"import sys N = int(input()) test = lambda x: [ x[0],int(x[1]) ] array = [ [test(input().split()),int(x+1)] for x in range(N) ] if not ( 1 <= N <= 100 ): sys.exit() for I in array: if not ( 1 <= len(I[0][0]) <= 10 ): sys.exit() if not I[0][0].islower(): sys.exit() if not ( 0 <= I[0][1] <= 100 ): sys.exit() if not isinstance(I[0][1],int): sys.exit() array.sort(key=lambda x: x[0][1], reverse=True) array.sort(key=lambda x: x[0][0]) for I in array: print(I[1])" p03252,s843772813,Accepted,"from collections import Counter print('Yes' if sorted(list(Counter(input()).values())) == sorted(list(Counter(input()).values())) else 'No') " p03351,s472204844,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"")" p02675,s038435793,Accepted,"from math import * from sys import stdin,stdout input=stdin.buffer.readline n=int(input()) d=n%10 if d==2 or d==4 or d==5 or d==7 or d==9: print(""hon"") elif d==0 or d==1 or d==6 or d==8: print(""pon"") else: print(""bon"")" p02608,s597020859,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])" p03730,s493215032,Accepted,"a,b,c=map(int,input().split()) ans=""NO"" for i in range(1,b+1): if a*i%b==c: ans=""YES"" break print(ans)" p03681,s980726888,Accepted,"MOD = 10**9+7 N,M = map(int,input().split()) if abs(N-M)>1: print(0) exit() #N=Mなら最後に2をかける dog = 1 monkey = 1 for i in range(1,N+1): dog = (dog*i)%MOD for j in range(1,M+1): monkey = (monkey*j)%MOD ans =(dog*monkey)%MOD if N==M: ans=(ans*2)%MOD print(ans) " p02854,s384335144,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() v = sum(a)/2 t = 0 for i in range(len(a)): t+=a[i] if t>v: break z1 = sum(a[:i]) k1 = sum(a[i:]) z2 = sum(a[:i+1]) k2 = sum(a[i+1:]) if abs(z1-k1)= 2): if(c[key] == 2 or c[key] == 3): area.append(key) if(len(area) == 2): print(area[0]*area[1]) break else: print(key*key) break else: print(0)" p02820,s643697691,Accepted,"N, K = map(int, input().split()) R, S, P = map(int, input().split()) T = str(input()) ans = 0 win = [1] * N for i in range(N): if T[i] == ""r"": ans += P x = P elif T[i] == ""s"": ans += R x = R else: ans += S x = S if i >= K: if (T[i] == T[i - K]) and (win[i - K] == 1): ans -= x win[i] = 0 #print(ans) print(ans)" p02923,s673859330,Accepted,"n = int(input()) h = list(map(int, 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 ans = max(ans, count) print(ans) " p02833,s807670684,Accepted,"from collections import Counter,defaultdict,deque from heapq import heappop,heappush,heapify import sys,bisect,math,itertools,fractions,copy 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() if n%2: print(0) quit() res = 0 now = 10 while now <= n: res += n//now now *= 5 print(res)" p02918,s517989213,Wrong Answer,"n,k = map(int,input().split()) s = list(input()) c = 0 a = 0 for i in range(n-1): if s[i] == s[i+1]: c += 1 if a < k: if s[i] == 'R' and s[i+1] == 'L': c += 2 a += 1 if a < k and a + 2 <= k: if s[0] == 'L': c += 1 if s[-1] == 'R': c += 1 if a < k and a + 1 >= k: if s[0] == 'L' or s[-1] == 'R': c += 1 print(c)" p02879,s313513742,Accepted,"# coding: utf-8 # Your code here! a,b=map(int,input().split()) if (1<=a<=9) and (1<=b<=9): print(a*b) else: print(-1)" p03105,s085673472,Accepted,"a, b, c = map(int, input().split()) print(min(b//a, c))" p03448,s383121496,Accepted,"a,b,c,x=[int(input()) for _ in range(4)] print([500*x+100*y+50*z for z in range(c+1) for y in range(b+1) for x in range(a+1)].count(x))" p02766,s489863426,Accepted,"n,k = map(int,input().split()) i = 0 if n == 0: print(1) exit() else: while k ** i <= n: i += 1 print(i)" p03861,s328506976,Accepted,"a, b, x = map(int, input().split()) print((b // x) - ((a - 1) // x))" p03127,s752145751,Wrong Answer,"N = int(input()) nums = [int(i) for i in input().split()] while min(nums) > 1: monster_index = nums.index(min(nums)) monster = nums.pop(monster_index) nums = [n-monster for n in nums] nums.append(monster) nums = [n for n in nums if n != 0] print(min(monster,min(nums)))" p03720,s136563384,Accepted,"def INT(): return int(input()) def MI(): return map(int, input().split()) def LI(): return list(map(int, input().split())) N, M = MI() city = [[] for _ in range(N)] for _ in range(M): a, b = MI() city[a - 1].append(b - 1) city[b - 1].append(a - 1) for c in city: print(len(c))" p03494,s484668108,Accepted,"N = int(input()) A = map(int, input().split()) # N が 2 で何回割れるか def how_many_times(N): exp = 0 while N % 2 == 0: N //= 2 exp += 1 return exp result = min(map(how_many_times, A)) print(result)" p03220,s073237864,Wrong Answer,"n = int(input()) t,a = map(int, input().split()) h = list(map(int, input().split())) best = float(""inf"") ind = 0 for i in range(n): temp = abs(a-t- h[i]*0.006) if temp < best: ind = i best = temp print(ind+1)" p02957,s918212147,Wrong Answer,"A, B = map(int, input().split()) K = A + B if K % 2 == 0: print(K) else: print(""IMPOSSIBLE"")" p02888,s187627085,Accepted,"from bisect import bisect_left n = int(input()) l = list(map(int, input().split())) l.sort() triangle = 0 for i in range(n-2): for j in range(i+1, n-1): index = bisect_left(l, l[i] + l[j], j + 1, n) - 1 triangle += index - j print(triangle)" p02836,s217624060,Accepted,"S=input() cou=0 for i in range (len(S)//2): if S[i]!=S[i*(-1)-1]: cou+=1 print(cou)" p02823,s052297219,Accepted,"N, A, B = map(int, input().split()) if (A - B) % 2 == 0: print((B - A) // 2) else: print(min(A - 1, N - B) + 1 + (B - A - 1) // 2) " p03338,s336947370,Accepted,"N = int(input()) S = input() ans = 0 for i in range(N-1): S1 = S[:i+1] S2 = S[i+1:] # print(S1, S2) ans = max(ans, len(set(list(S1)) & set(list(S2)))) print(ans)" p03419,s657576395,Accepted,"def main(): N, M = (int(i) for i in input().split()) ans = 0 if N == 1 and M == 1: ans = 1 elif N == 1: ans = M-2 elif M == 1: ans = N-2 else: h = N-2 w = M-2 ans = h*w print(ans) if __name__ == '__main__': main() " p02577,s016865218,Accepted,"n=int(input()) list1 = [] sum: int = 0 for i in str(n): list1.append(int(i)) sum +=int(i) print(""Yes"" if n % 9 == 0 and sum % 9 == 0 else ""No"")" p03665,s563726660,Accepted,"n, p = map(int, input().split()) A = list(map(int, input().split())) A = [a%2 for a in A] if sum(A) == 0: print(pow(2, n) if p==0 else 0) elif n>=2: print(pow(2, n)//2) else: print(1 if A[0]==p else 0)" p02773,s979130515,Wrong Answer,"def main(): n = int(input()) dict = {} for i in range(n): s = input() dict.setdefault(s, 0) dict[s] += 1 max_val = 0 ans_ls = [] for kv in dict.items(): if kv[1] > max_val: max_val = kv[1] ans_ls = [kv[0]] elif kv[1] == max_val: ans_ls.append(kv[0]) if __name__ == '__main__': main()" p02645,s661160071,Accepted,"import bisect, collections, copy, heapq, itertools, math, numpy, string import sys from bisect import bisect_left, bisect_right, insort from collections import deque def S(): return sys.stdin.readline().rstrip() def I(): return int(sys.stdin.readline().rstrip()) def MI(): return map(int, sys.stdin.readline().rstrip().split()) def MS(): return map(str, sys.stdin.readline().rstrip().split()) def LI(): return list(map(int, sys.stdin.readline().rstrip().split())) def LS(): return list(sys.stdin.readline().rstrip().split()) # N = I() # A = [LI() for _ in range(N)] s = S() print(s[:3]) " p02970,s589160736,Accepted,"N,D=map(int,input().split()) cnt=1 while True: if cnt*(2*D+1)>=N: print(cnt) break cnt+=1 " p04034,s582387288,Accepted,"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 if amount[x-1] == 0: red[x-1] = 0 ans = 0 for r,a in zip(red, amount): if r > 0 and a > 0: ans += 1 print(ans)" p02971,s737009841,Accepted,"N = int(input()) A = [0]*N for i in range(N): A[i] = int(input()) B = sorted(A) for i in range(N): if A[i] == B[-1]: print(B[-2]) else: print(B[-1])" p02953,s566221546,Accepted,"n = int(input()) h = list(map(int, input().split())) memo = 0 for i in range(n-1): if h[i] > h[i+1]: memo = max(memo, h[i] - 1) if h[i] - h[i+1] > 2 or h[i+1] < memo: print(""No"") exit() print(""Yes"")" p03274,s809392480,Accepted,"N,K = (int(T) for T in input().split()) X = [int(T) for T in input().split()] Cost = [0]*(N-K+1) for T in range(0,N-K+1): Left = X[T] Right = X[T+K-1] Cost[T] = min(abs(Left)+abs(Left-Right),abs(Right)+abs(Right-Left)) print(min(Cost))" p04012,s095374366,Accepted,"import sys from collections import Counter c = Counter(input()) for i in c.most_common(): if i[1]%2 == 1: print('No') sys.exit() print('Yes') " p02665,s802358721,Accepted,"n=int(input()) a=[int(j)for j in input().split()] ans=0 s=sum(a) p=1 b=True for i,j in enumerate(a): if p180): R=360-R COS=math.cos(math.radians(R)) ans=A**2+B**2-2*A*B*COS print(ans**(1/2))" p04044,s441243152,Accepted,"N, L = map(int, input().split()) table = [input() for _ in range(N)] table.sort() print("""".join(table)) " p02923,s448539631,Accepted,"N = int(input()) H = list(map(int, input().split())) H.append(10**10) r, ans = 0, 0 for l in range(N): while r < N and H[r] >= H[r+1]: r += 1 ans = max(ans, r-l) if l == r: r += 1 print(ans)" p03612,s545601268,Accepted,"n=int(input()) p=list(map(int,input().split())) num1=0 num=[] for i in range(1,n+1): if p[i-1]==i: num1+=1 else: if num1!=0: num.append(num1) num1=0 if num1!=0: num.append(num1) ans=0 for i in range(len(num)): ans+=-(num[i]//-2) print(ans) " p03243,s877382984,Accepted,"n=int(input()) while True: if n%111==0: print(n) break n+=1" p02754,s682474655,Accepted,"N, A, B = map(int, input().split()) print (A * (N // (A+B)) + min(N % (A+B), A))" p02682,s167391469,Wrong Answer,"A,B,C,num = map(int, input().split()) if num <= A+B: print(A) else: ans = A-(num-A-B) print(ans)" p02854,s520533973,Accepted,"N = int(input()) A = list(map(int, input().split())) sm = sum(A) t = 0 for i in range(N): if t > sm/2: break else: t += A[i] s = t-A[i] u = 2*t - sm v = sm - 2*s print(min(u,v))" p02659,s417455649,Wrong Answer,"il = input().split() A = float(il[0]) B = float(il[1]) import math print(math.floor(A*B)) " p03035,s341989980,Accepted,"a,b = map(int,input().split()) if a>=13:print(b) elif a>=6:print(b//2) else:print(0)" p02576,s395182378,Accepted,"import math n, x, t = map(int,input().split()) print(math.ceil(n/x)*t)" p02631,s019179097,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())) q = I() mylist = LI() result = 0 for i in mylist: result = result ^ i for i in mylist: print(result ^ i)" p03681,s934293393,Accepted,"from math import factorial def resolve(): n, m = map(int, input().split()) mod = 10**9+7 if abs(n - m) > 1: print(0) return a = factorial(m) % mod * factorial(n) % mod if (n + m) % 2 == 0: a = a * 2 % mod print(a) resolve()" p03479,s130651856,Accepted,"X, Y = map(int, input().split()) x = X ans = 1 while x * 2 <= Y: x *= 2 ans += 1 print(ans)" p02838,s234284147,Accepted,"N = int(input()) A = list(map(int, input().split())) mod = 10**9+7 D = {} for a in A: bit = bin(a)[2:][::-1] for i in range(len(bit)): if bit[i] == '1': if i not in D: D[i] = 1 else: D[i] += 1 ans = 0 for k, v in D.items(): ans += (N-v)*v*2**k % mod ans = ans % mod print(ans)" p02817,s675131545,Accepted,"lists=list((input().split())) print(lists[1]+lists[0])" p02860,s040387812,Wrong Answer,"import sys n = int(input()) s = input() if (n % 2 == 1): print('No') sys.exit() if (s[0:n//2-1] == s[n//2:n-1]): print('Yes') else: print('No')" p04029,s564459093,Wrong Answer,"def actual(N): return ((N + 1) * N) / 2 N = int(input()) print(actual(N))" p03146,s879528754,Wrong Answer,"s = int(input()) check = [0]*(10**6) check[s] == 1 i = 2 while True: if s % 2 == 0: s //= 2 else: s = 3*s+1 if check[s]: break check[s] = 1 i += 1 print(i)" p03211,s872387016,Accepted,"S=input() ans=10**9 for i in range(len(S)): ans=min(ans,abs(int(S[i:i+3])-753)) print(ans)" p02897,s667688481,Wrong Answer,"N = int(input()) numodd = N%2 print(numodd/N)" p03252,s493309710,Accepted,"S = input() T = input() ans = 'Yes' dic1,dic2 = {},{} for i,j in zip(S,T): if i in dic1: if dic1[i] != j: ans = 'No' else: dic1[i] = j if j in dic2: if dic2[j] != i: ans = 'No' else: dic2[j] = i #print(dic1) #print(dic2) print(ans)" p02911,s991166506,Wrong Answer,"n,k,q = map(int,input().split()) p_lis = [k-q] * n print(p_lis) for i in range(q): x = int(input()) p_lis[x-1] += 1 for j in p_lis: if j > 0: print(""Yes"") else: print(""No"")" p03723,s333788462,Accepted,"A,B,C=map(int,input().split()) ans=0 while A%2==0 and B%2==0 and C%2==0: if A == B == C: print(-1) exit() A1=A B1=B C1=C A = B1/2+C1/2 B = A1/2+C1/2 C = A1/2+B1/2 ans +=1 print(ans)" p03095,s928107376,Accepted,"n = int(input()) s = str(input()) mod = 10**9+7 d = {} for i in range(n): if s[i] not in d: d[s[i]] = 1 else: d[s[i]] += 1 ans = 1 for v in d.values(): ans *= (v+1)%mod ans -= 1 print(ans%mod)" p03767,s553544104,Accepted,"n = int(input()) a = list(map(int,input().split())) a=sorted(a) print(sum(a[-n*3+n:-1:2]))" p03835,s620002970,Accepted,"K,S = map(int,input().split()) C = 0 for x in range(K+1): for y in range(K+1): if K>=S-x-y>=0: C+=1 print(C)" p03416,s975348657,Accepted,"a,b = map(int,input().split()) count = 0 for i in range(a,b+1): moji = str(i) flag = True for j in range(1,len(moji)//2+1): if moji[j-1]!=moji[-j]: flag = False break if flag: count += 1 print(count)" p02630,s785965305,Accepted,"n = int(input()) arr = list(map(int, input().split())) s = sum(arr) m = {} for e in arr: m[e] = m.get(e, 0)+1 for _ in range(int(input())): a, b = map(int, input().split()) if a not in m: print(s) continue s += (b-a) * m[a] if b not in m: m[b] = 0 m[b] += m[a] m[a] = 0 print(s) " p02848,s058058281,Accepted,"A = ""abcdefghijklmnopqrstuvwxyz"" n = int(input()) N = input() for i in range(len(N)): a = A.index(N[i].lower()) a += n if a >= 26: a -= 26 print(A[a].upper(),end="""") print("""")" p02693,s419858886,Wrong Answer,"K = input() A, B = map(int, input().split()) if int(B) - int(A) + 1 >= int(K): print('OK') else: i = int(A) while i < int(B) + 1: if i % int(K) == 0: print('OK') break else: i = i+1 print('NG')" p03456,s834709070,Accepted,"a, b = map(int, input().split()) squares = [i ** 2 for i in range(1000)] if int(str(a) + str(b)) in squares: print(""Yes"") else: print(""No"") " p03327,s684311064,Accepted,"N = int(input()) if N < 1000 : print(""ABC"") else : print(""ABD"") " p03544,s602498928,Wrong Answer,"n = int(input()) L = [2,1] for i in range(n-1): tmp = L[i] + L[i+1] L.append(tmp) print(max(L))" p02584,s488788644,Accepted,"x, k, d = map(int, input().split()) x = abs(x) MIN = x-k*d if 0 <= MIN: print(MIN) else: a, R = divmod(x, d) L = d-R cnt = k-a if cnt % 2 == 0: print(R) else: print(L) " p03385,s754377069,Wrong Answer,"def main(): s = input() if s == 'abc' or s == 'bca' or s == 'cab': print('Yes') else: print('No') if __name__ == '__main__': main()" p03773,s704798897,Wrong Answer,"A,B = map(int,input().split()) print(A+B % 24)" p02602,s522223755,Wrong Answer,"n, k = map(int,input().split()) a = list(map(int, input().split())) s = 1 d = 1 last = 0 for i in range(n): s *= a[i] if i - k >= 0: d*=a[i-k] s = s % 1000000007 d = d % 1000000007 num = s // d #print(f'{num} {last}') if i-1 >= k-1: if last >= num: print('No') else: print('Yes') last = num" p02631,s240844150,Accepted,"from functools import reduce import sys from operator import xor def _i(): return int(sys.stdin.readline().strip()) def _ia(): return map(int, sys.stdin.readline().strip().split()) def main(): _ = _i() a = list(_ia()) s = reduce(xor, a, 0) return "" "".join(map(str, map(lambda x: s ^ x, a))) if __name__ == ""__main__"": print(main()) " p02681,s776361040,Wrong Answer,"def resolve(): s = str(input()) t = str(input()) if t[:len(s)] == s and len(t) == (len(s) + 1) and len(t) <= 10: print('Yes') else: print('No') resolve() " p02601,s459018319,Wrong Answer,"a = list(map(int, input().split())) num = int(input()) k = 0 for i in range(num): #num回2倍を繰り返す。でなければNoをprint if a[2] < max(a): #リストaの中のmaxよりも青が小さいならば青を二倍する a[2] = a[2] * 2 k += 1 elif a[1] < max(a) and k B): print(""Alice"") elif(A < B): print(""Bob"") else: print(""Draw"") " p03435,s983245184,Accepted,"c = [] for i in range(3): x,y,z = map(int,input().split()) c.append([x,y,z]) if (c[1][0]-c[0][0] == c[1][1]-c[0][1] == c[1][2]-c[0][2]) and (c[2][0]-c[0][0] == c[2][1]-c[0][1] == c[2][2]-c[0][2]): print('Yes') else: print('No') " p03944,s982356845,Wrong Answer,"W, H, N = map(int, input().split()) X_Y_A = [map(int, input().split()) for _ in range(N)] oX = 0 oY = 0 for x, y, a in X_Y_A: if a == 1: oX = max(x, oX) elif a == 2: W = min(x, W) elif a == 3: oY = max(y, oY) else: H = min(y, H) A = (W-oX)*(H-oY) print(A) if A > 0 else print(0) " p03761,s804436394,Wrong Answer,"N = int(input()) s_li = [] keys = [] ans = '' for i in range(N): s = input() if i == 0: keys = set(s) else: keys = set(s) & keys s_li.append(s) for k in keys: min_k = 50 for s in s_li: min_k = min(s.count(k), min_k) ans += k * min_k print(ans) " p02759,s483780969,Accepted,"import math N = int(input()) print(math.ceil(N/2)) " p02756,s622831458,Wrong Answer,"s = input() n = int(input()) for _ in range(n): q = input().split() if q[0] == ""1"": s = s[-1] + s[1:-1] + s[0] else: if q[1] == ""1"": s = q[2] + s else: s += q[2] print(s)" p03038,s566499890,Wrong Answer,"from bisect import bisect_left,bisect N,M = map(int,input().split()) A = list(map(int,input().split())) BC = [list(map(int,input().split())) for _ in range(M)] A.sort() for b,c in BC: i = bisect_left(A,c) if c <= A[0]: continue if b < i: A[:b] = [c]*b else: A[:i] = [c]*i print(sum(A))" p03556,s974976970,Wrong Answer,"N = int(input()) ans = 0 for i in range(10000): if i**2 > N: print(ans) exit ans = i**2 print(ans)" p03086,s332655776,Wrong Answer,"ACGT = ['A', 'C', 'G', 'T'] def ok(S): for c in S: if c not in ACGT: return False return True def main(): S = input() res = '' for i in range(len(S)-1): for j in range(1, len(S)): ps = S[i:j] if ok(ps) and len(ps) > len(res): res = ps print(len(res)) main()" p03720,s911123689,Accepted,"n,m = map(int,input().split()) ans = [0]*n for _ 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])" p03331,s617425205,Accepted,"def calc(x) -> int: sum = 0 while x//10!=0: sum += x%10 x = x//10 sum+=x return sum n = int(input()) best_score = float('inf') for a in range(1,n): b = n-a score = calc(a)+calc(b) if score < best_score: best_score = score print(best_score) " p02552,s618629209,Accepted,"X = int(input()) if X == 0: print(1) else: print(0)" p02676,s467964159,Accepted,"def resolve(): K = int(input()) S = input() print(S if len(S) <= K else S[:K]+""..."") if '__main__' == __name__: resolve()" p02702,s207965618,Accepted,"from collections import defaultdict S = input() N = len(S) dp = [0 for _ in range(N+1)] MOD = 2019 dp[-1] = int(S[-1]) tmp = 10 for i in range(N-1, 0, -1): m = int(S[i-1]) dp[i] = (dp[i+1]+tmp*m)%MOD tmp = tmp*10%MOD d = defaultdict(int) for i in range(N+1): d[dp[i]] += 1 ans = 0 for k in d.keys(): ans += d[k]*(d[k]-1)//2 print(ans) " p03524,s466311456,Accepted,"from collections import Counter from itertools import combinations s = input() sc = Counter(s) if len(sc.keys()) == 1: if len(s) == 1: print('YES') else: print('NO') elif len(sc.keys()) == 2: if len(s) == 2: print('YES') else: print('NO') else: ans = 'YES' for i,j in combinations(sc.values(),2): if abs(i-j) > 1: ans = 'NO' break print(ans)" p03433,s211408693,Accepted,"N = int(input()) A = int(input()) if N % 500 <= A: print('Yes') else: print('No')" p02663,s973785860,Accepted,"H1,M1,H2,M2,K = map(int,input().split()) print(60*(H2-H1)+M2-M1-K)" p02556,s555337763,Accepted,"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 = max(A) b = min(A) c = max(B) d = min(B) ans = max(a-b,c-d) print(ans)" p02983,s803296391,Wrong Answer,"l, r = map(int, input().split()) l2 = l // 2019 r2 = r // 2019 if l2 != r2: print(0) else: ans=2019 for i in range(l2, r2): for j in range(i+1, r2 + 1): ans = min(ans, (i * j) % 2019) print(l * (l + 1) % 2019) " p03861,s279831060,Accepted,"a, b, x = map(int, input().split()) a = (a - 1) // x b = b // x print(b - a)" p02641,s277846591,Wrong Answer,"X,N = map(int,input().split()) p = list(map(int, input().split())) num=list(range(-100,101)) for i in range(N): num.remove(p[i]) min_=210 for i in range(len(num)): s=abs(X-num[i]) if s K: break while b[j] > K-a[i]: j -= 1 ans = max(ans, i+j) print(ans) " p02555,s365671473,Accepted,"S = int(input()) dp = [0 for _ in range(S+1)] dp[0] = 1 MOD = 10**9+7 for i in range(3,S+1): dp[i] = dp[i-1]+dp[i-3] print(dp[S]%MOD)" p03487,s537955035,Accepted,"from collections import Counter N, *A = map(int, open(0).read().split()) cnt = Counter(A) ans = 0 for k, v in cnt.items(): if k > v: ans += v else: ans += v - k print(ans) " p03407,s586767253,Accepted,"a,b,c=map(int,input().split()) if (a+b)>=c: print('Yes') else: print('No') " p03109,s963414207,Accepted,"y,m,d = map(int, input().split(""/"")) if y < 2019: print (""Heisei"") exit () if y == 2019: if m < 4: print (""Heisei"") exit () elif m == 4: if d <= 30: print (""Heisei"") exit () else: pass print (""TBD"") " p03281,s128671359,Wrong Answer,"n = int(input()) ans = 0 yakusu = 0 for i in range(1,n+1): if n % i == 0: yakusu += 1 if yakusu == 8: ans += 1 print(ans) " p02705,s233960870,Wrong Answer,"import math def main(r): return math.pi * r ** 2" p03012,s942912369,Wrong Answer,"from sys import stdin n = int(stdin.readline().rstrip()) w = [int(x) for x in stdin.readline().rstrip().split()] ave = sum(w)/len(w) w1 = [w.pop(0)] while sum(w1)/len(w1) < ave: w1.append(w.pop(0)) print(abs(sum(w1) - sum(w))) " p02935,s759833940,Accepted,"N = int(input()) v = list(map(int, input().split())) v.sort() A=v[0] for i in range(N-1): A = (A+v[i+1])/2 print(A)" p03495,s417269644,Accepted,"from collections import Counter n,k = map(int,input().split()) a = list(map(int,input().split())) c = Counter(a) stay = 0 for k,v in c.most_common(k): stay += v print(n-stay)" p03557,s074319210,Accepted,"from bisect import bisect_right,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 i in range(n): na=bisect_left(a,b[i]) nc=bisect_right(c,b[i]) ans+=na*(n-nc) print(ans)" p02612,s186399658,Accepted,"import math N = int(input()) tmp = math.ceil(N / 1000) print(1000*tmp - N) " p02633,s726055319,Accepted,"y=x=int(input()) while y%360:y+=x print(y//x)" p02660,s136438757,Wrong Answer,"import math n = int(input()) count = 0 def prime_factors(number): listp = [] int_sqrtn = int(math.sqrt(number)) for prime in range(2, int_sqrtn+1): if number % prime == 0: listp.append(prime) number //= prime if number > int_sqrtn: listp.append(number) return listp print(len(prime_factors(n)))" p02818,s417819994,Accepted,"A,B,K=map(int, input().split()) if A>=K: print(A-K,B) else: print(0, max(0, B-(K-A)))" p02705,s826439187,Accepted,"import math R = int(input()) pi = math.pi print(2*R*pi)" p04030,s481299073,Wrong Answer,"s = input(str) ans = """" for i in range(len(s)): if (s[i] == '0'): ans += '0' elif (s[i] == '1'): ans += '0' else: if (len(ans) > 0): ans = ans[:len(ans)-1] print(ans)" p02630,s886686749,Accepted,"n = int(input()) a = [int(x) for x in input().split()] q = int(input()) bc=[] for i in range(q): bc.append([int(x) for x in input().split()]) a_cnt=[0]*(10**5+1) for i in range(len(a)): a_cnt[a[i]]+=1 a_goukei=sum(a) for gyou in range(q): a_goukei+=(bc[gyou][1]-bc[gyou][0])*a_cnt[bc[gyou][0]] print(a_goukei) a_cnt[bc[gyou][1]]+=a_cnt[bc[gyou][0]] a_cnt[bc[gyou][0]]=0" p02675,s123792385,Accepted,"n = input() nl = int(n[-1:]) if nl == 2 or nl == 4 or nl == 5 or nl == 7 or nl == 9: print('hon') elif nl == 0 or nl == 1 or nl == 6 or nl == 8: print('pon') else: print('bon')" p02957,s229282538,Wrong Answer,"A,B = map(int,input().split()) if (A+B)%2 != 0: print(""IMPOSSIBLE"") else: print((A+B)/2)" p03013,s959217571,Accepted,"n, m = map(int, input().split()) dp = [-1]*(n+1) for i in range(m): dp[int(input())] = 0 dp[0] = 1 if dp[1] != 0: dp[1] = 1 for i in range(2,n+1): if dp[i] != 0: dp[i] = (dp[i-1]+dp[i-2])%1000000007 print(dp[n])" p03767,s605230287,Accepted,"n = int(input()) elem = list(map(int, input().split())) elem.sort() ans = sum(elem[n::2]) print(ans)" p02687,s467170463,Wrong Answer,"s=input() if(s[1]=='B'): print('ARC') else: print('ARC')" p03705,s740356533,Accepted,"n, a, b = map(int, input().split()) if a > b: print(0) elif a < b: if n < 2: print(0) else: print((b - a) * (n - 2) + 1) else: print(1)" p02958,s000705477,Accepted,"import sys import copy N = int(input()) p = [int(x) for x in input().split()] comp = [i for i in range(1, N+1)] if p==comp: print(""YES"") sys.exit() for i in range(N-1): for j in range(i+1, N): tmp = copy.copy(p) x = tmp[i] tmp[i] = tmp[j] tmp[j] = x if tmp==comp: print(""YES"") sys.exit() print(""NO"")" p03239,s706181484,Accepted,"N,T =map(int,input().split()) a = 1001 for i in range(N): c,t = map(int,input().split()) if t <= T: if c < a: a = c if a == 1001: print(""TLE"") else: print(a) " p02773,s990283357,Accepted,"from collections import Counter n = int(input()) s = [input() for i in range(n)] s = Counter(s) maxs = max(s.values()) ss = [] for k, v in s.items(): if maxs == v: ss.append(k) ss.sort() for si in ss: print(si)" p02711,s030234481,Accepted,"n = input() if ""7"" in n: print(""Yes"") else: print(""No"") " p03730,s735295593,Accepted,"from sys import exit import math ii = lambda : int(input()) mi = lambda : map(int,input().split()) li = lambda : list(map(int,input().split())) a,b,c=mi() for i in range(1,b): if (b*i + c) % a == 0: print(""YES"") exit() print(""NO"") " p02842,s729027507,Accepted,"n = int(input()) res = 0 for i in range(50001): if int(i * 1.08) == n: res = i if res != 0: print(res) else: print(':(')" p02743,s067656388,Accepted,"try: while True: s = input().split("" "") if len(s)==3: a, b, c = map(int, s) cab = c-a-b ans = ""No"" if 00 and b>0: print('Positive') elif a<=0 and b>=0: print('0') elif a<0 and b<0: x=b-a+1 if x%2==0: print('Positive') else: print('Negative')" p03251,s277856414,Accepted,"n,m,X,Y=map(int,input().split()) x=list(map(int,input().split())) y=list(map(int,input().split())) if min(y)<=X: print(""War"") elif Y<=max(x): print(""War"") else: if max(x)>=min(y): print(""War"") else: print(""No War"")" p02694,s237442950,Accepted,"x = int(input()) deposit = 100 ans = 0 while deposit < x: deposit = int(deposit * 1.01) ans += 1 print(ans) " p02597,s562835239,Accepted,"n = int(input()) cs = input() cnt = 0 i = 0 j = n-1 while(1): if i >= j: break if cs[i] == ""R"": i += 1 if cs[j] == ""W"": j -= 1 if cs[i] == ""W"" and cs[j] == ""R"": cnt += 1 i += 1 j -= 1 print(cnt) " p04005,s224164472,Wrong Answer,"A, B, C = map(int, input().split()) A, B, C = sorted([A, B, C]) if C % 2 == 0: print(0) else: d1, d2 = C // 2, (C // 2) + 1 print(d1, d2) e = A * B print(abs(d1 - d2) * e) " p02916,s608175860,Wrong Answer,"n = int(input()) A=list(map(int,input().split())) B=list(map(int,input().split())) C=list(map(int,input().split())) print(A[0]) ans=B[int(A[0])-1] for i in range(1,n): if A[i-1]+1==A[i]: ans += B[int(A[i])-1]+C[int(A[i-1])-1] else: ans += B[int(A[i]-1)] print(ans)" p03221,s482451276,Wrong Answer,"N, M = list(map(int, input().split())) PY = [list(map(int, input().split())) for i in range(M)] # print(N, M) # print(PY) foo = {} for PYi in PY: if foo.get(PYi[0]) is None: foo[PYi[0]] = [] foo[PYi[0]].append(PYi[1]) # print(foo) for PYi in PY: print(PYi)" p03017,s614129132,Accepted,"N, A, B, C, D = map(int, input().split()) S = '.' + input() + '#' # S[A,C],S[B,D]には'##'が存在してはいけない if '##' in S[A: C + 1] or '##' in S[B: D + 1]: print('No') exit() # 追い越さなければいけないとき # S[B,D]に'...'が存在する必要がある if D < C: if not '...' in S[B - 1 : D + 2]: print('No') exit() print('Yes') " p03359,s250317031,Wrong Answer,"a,b = map(int,input().split()) if a >= b: print(b) else: print(a)" p03145,s248965296,Accepted,"ab, bc, ac = map(int,input().split("" "")) print((ab*bc)//2)" p03103,s220435560,Accepted,"n, m = map(int, input().split()) ab = [list(map(int, input().split())) for i in range(n)] ab.sort() ans = 0 cnt = 0 for i in ab: a, b = i[0], i[1] if cnt + b >= m: print(ans + (m - cnt) * a) exit() else: ans += a * b cnt += b " p04020,s661791421,Accepted,"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] : R[i + 1]]) % 2 == 1: S = S - 1 print(S // 2) " p02687,s956055537,Accepted,"S=input() print('ARC' if S=='ABC' else 'ABC')" p03962,s346575198,Accepted,"# https://atcoder.jp/contests/abc046/tasks/abc046_a a, b, c = map(int, input().split()) print(len(set([a, b, c]))) " p02742,s195717095,Accepted,"H,W = map(int,input().split()) if H==1: print(1) else: if W==1: print(1) elif W==2: print(H) else: if W%2==0: print((W//2)*H) else: if H%2==0: print(((W//2)+1)*(H//2) + (W//2)*(H//2)) else: print(((W//2)+1)*((H//2)+1) + (W//2)*(H//2)) " p03760,s854236583,Accepted,"from itertools import zip_longest def solve(): N = input() O = input() ans = '' for x, y in zip_longest(N, O, fillvalue=''): ans += x + y print(ans) if __name__ == ""__main__"": solve()" p03282,s576194700,Accepted,"S = input() K = int(input()) for i in range(K): c = S[i] if c != '1': print(c) break else: print(1) " p03548,s527418928,Accepted,"x, y, z = map(int, input().split()) print((x-z) // (y+z))" p03146,s893489360,Accepted,"def main(): def fun(n): if n % 2 == 0: return int(n / 2) else: return 3 * n + 1 s = int(input()) vals = [s] while True: new_v = fun(vals[-1]) if new_v in vals: print(len(vals) + 1) break else: vals.append(new_v) if __name__ == '__main__': main() " p02744,s616655003,Accepted,"# -*- coding: utf-8 -*- a = int(input()) l = 1 cur_ret = [[0]] while l < a: new_ret = [] na = new_ret.append for i in cur_ret: k = max(i) + 2 for j in range(k): na(i+[j]) cur_ret = new_ret l+=1 def format(x): x = list(map(lambda x : chr(x+97),x)) return """".join(x) cur_ret = list(map(format,cur_ret)) cur_ret.sort() for i in cur_ret: print(i)" p03438,s772834016,Accepted,"n=int(input()) a=list(map(int,input().split())) b=list(map(int,input().split())) sa=sum(a) sb=sum(b) if sbaa: husoku_b+=(bb-aa)//2 if husoku_a<=husoku_b: print(""Yes"") else: print(""No"")" p02756,s955489292,Wrong Answer,"S = input() Q = int(input()) f = 0 for _ in range(Q): a, *b = input().split() f += int(a) if a == ""2"": if int(b[0]) + f % 2 ==0 : S = b[1] + S else: S += b[1] print (S if f % 2 == 1 else S[::-1])" p03221,s673776985,Accepted,"n, m = map(int,input().split()) PY = [] for _ in range(m): PY.append(list(map(int,input().split()))) sortedPY = sorted(PY, key=lambda x: x[1]) d = {} o = [1]*(n+1) for i in sortedPY: d[(i[0],i[1])] = o[i[0]] o[i[0]] += 1 for i in PY: print(str(i[0]).zfill(6) + str(d[(i[0],i[1])]).zfill(6)) " p03252,s541527378,Wrong Answer,"s = str(input()) t = str(input()) A=[] B=[] for i in range(len(s)): if s[i] ==t[i]: A.append(s[i]) else: B.append(t[i]) for j in range(len(A)): if A[j] in B: print('No') exit() print('Yes')" p02917,s253827696,Wrong Answer,"N = int(input()) B = list(map(int,input().split())) # 双対考える # A1<=B1, A2<= min(B1,B2), A3<=min(B2,B3) ... A = [B[0]] for i in range(N-1): if i+1 != len(B): A.extend([min(B[i],B[i+1])]) else: A.extend([max(B[i-1],B[i])]) print(sum(A))" p02639,s130991134,Wrong Answer,"a=[] a=input().split() for i in range(0,4): if a[i]==0: print(i) else: pass" p02897,s740233743,Accepted,"N = int(input()) if N % 2 == 0: print(0.5) else: print(((N//2)+1)/N)" p04034,s258012108,Accepted,"n,m=map(int,input().split()) xy=[] for _ in range(m): xy.append(list(map(int,input().split()))) ans=1 n0=xy[0][1] rb=[1] rb[1:1]=[0]*(n-1) cb=[1]*n for i in range(m): if rb[xy[i][0]-1]==1: rb[xy[i][1]-1]=1 cb[xy[i][1]-1]+=1 cb[xy[i][0]-1]-=1 if cb[xy[i][0]-1]==0: rb[xy[i][0]-1]=0 print(sum(rb)) " p02996,s685171627,Accepted,"n = int(input()) ab =[list(map(int, input().split())) for _ in range(n)] ab.sort(key = lambda l: l[1]) t = 0 out = 'Yes' for i in range(n): t += ab[i][0] if t > ab[i][1]: out = 'No' break print(out)" p02727,s927782929,Wrong Answer,"#coding:utf-8 x, y, a, b, c = map(int, 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[0:x] q[0:y] p.extend(q) p.extend(r) p.sort(reverse = True) print(p) ans = 0 for i in range(x + y): ans += p[i] print(""{}"".format(ans))" p02963,s176589417,Accepted,"from math import ceil s = int(input()) y = ceil(s / (10 ** 9)) x = (10 ** 9) * y - s print(0, 0, 10 ** 9, 1, x, y)" p02760,s822350486,Accepted,"A1 = list(map(int, input().split())) A2 = list(map(int, input().split())) A3 = list(map(int, input().split())) N = int(input()) S = [] for _ in range(N): S.append(int(input())) mat = [0]*9 A = A1+A2+A3 for i in range(9): if A[i] in S: mat[i] = 1 res = 'No' if sum(mat[0:9:3])==3 or sum(mat[1:9:3])==3 or sum(mat[2:9:3])==3 or sum(mat[0:3])==3 or sum(mat[3:6])==3 or sum(mat[6:9])==3 or sum(mat[0:9:4])==3 or sum(mat[2:7:2])==3: res = 'Yes' print(res) " p02742,s376974012,Wrong Answer,"import math H,W = map(int,input().split()) ans = math.ceil(H * W / 2) print(ans)" p03555,s055639395,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')" p03059,s737892809,Accepted,"A, B, T = map(int, input().split()) print((T//A)*B)" p02697,s987692442,Accepted,"n, m = map(int, input().split()) if n % 2 == 1: for i in range(m): print(i+1,n-i) else: bd = m // 2 if m % 2 == 1: bd += 1 for i in range(bd): print(i+1, n-i) for i in range(bd, m): print(i+2, n-i) " p02963,s474744219,Accepted,"MOD = 10 ** 9 s = int(input()) y = -(-s // MOD) x = y * MOD - s print(0, 0, MOD, 1, x, y)" p03479,s094059824,Accepted,"x,y = map(int, input().split()) cnt = 0 a = x while a <= y: a += a cnt += 1 print(cnt)" p03328,s344813035,Accepted,"a, b = map(int, input().split()) print((b - a) * (b - a - 1) // 2 - a) " p03241,s419618847,Accepted,"N, M = map(int, input().split()) from math import sqrt def divisor(num): max_num = int(sqrt(num)) divisor_list = [] for i in range(1, max_num + 1): if num % i == 0: divisor_list.append(i) divisor_list.append(num//i) return divisor_list g_list = divisor(M) g_list.sort(reverse=True) ans = 0 for g in g_list: if M//g >= N: ans = g break print(ans)" p03387,s281060279,Accepted,"a = sorted(map(int, input().split())) b, c = a[2] - a[1], a[2] - a[0] あ = b // 2 + c // 2 ばいく = b % 2 + c % 2 if ばいく == 1: あ += 2 elif ばいく == 2: あ += 1 print(あ) " p02843,s553383399,Accepted,"X = int(input()) X_ = X % 100 N = int(X / 100) ans = 0 for i in range(5): X_ -= N if X_ > 0: print(0) else: print(1) " p03317,s548242520,Wrong Answer,"import math def process_smaller_index(K, min_index): if min_index == 0: return 0 else: return math.ceil(min_index / K) def process_larger_index(last_index, K, min_index): if min_index == last_index: return 0 else: return math.ceil((last_index - min_index) / K) N, K = map(int, input().split()) A = [int(i) for i in input().split()] min_index = A.index(1) print(process_smaller_index(K - 1, min_index) + process_larger_index(len(A)-1, K - 1, min_index))" p03109,s631388398,Accepted,"S=input() print(""Heisei"" if S<=""2019/04/30"" else ""TBD"")" p02691,s709825091,Accepted,"import collections N = int(input()) height = input() height = height.split() height = [int(s) for s in height] count = 0 d = dict(collections.Counter([i + height[i] for i in range(N)])) ans = sum([d.get(i - height[i], 0) for i in range(N)]) print(ans)" p03699,s813485153,Accepted,"n = int(input()) s = [] for i in range(n): s.append(int(input())) s.sort() m = sum(s) if m % 10 != 0: print(m) else: for i in range(n): if (m-s[i]) % 10 != 0: print(m-s[i]) break else: print(0)" p03161,s055869396,Accepted,"def mincost(n, k, A): dp = [0] * n for i in range(1, n): dp[i] = float('inf') for j in range(i - 1, i - k - 1, -1): if j >= 0: dp[i] = min(dp[i], dp[j] + abs(A[j] - A[i])) return dp[n - 1] if __name__ == '__main__': n, k = list(map(int, input().split())) A = list(map(int, input().split())) res = mincost(n, k, A) print(res)" p03699,s685102794,Accepted,"n = int(input()) L = [0] * n m = float('inf') for i in range(n): L[i] = int(input()) if L[i] % 10 != 0: m = min(m, L[i]) ans = sum(L) if ans % 10 == 0: ans -= m if ans < 0: print(0) exit() print(ans)" p02713,s947975819,Accepted,"N = int(input()) def gcd(p, q): if p % q == 0: return q return gcd(q, p % q) ans = 0 for x in range(1,N+1): for y in range(1,N+1): for z in range(1,N+1): ans += gcd(gcd(x, y), z) print(ans)" p03211,s231451323,Accepted,"S = input() num = 753 ans = 999 for i in range(len(S) - 2): cur = int(S[i:i + 3]) if (abs(num - cur) < ans): ans = abs(num - cur) print(ans) " p03385,s026358166,Accepted,"s = input() print(""Yes"" if len(set(s))==3 else ""No"")" p03107,s525757991,Accepted,"def main(): s = input() a = s.count('0') b = s.count('1') print(len(s) - abs(a - b)) if __name__ == '__main__': main()" p02838,s843720917,Wrong Answer,"import math import fractions import sys import itertools #入力:N(int:整数) def input1(): return int(input()) #入力:N,M(int:整数) def input2(): return map(int,input().split()) #入力:[n1,n2,...nk](int:整数配列) def input_array(): return list(map(int,input().split())) N=input1() A=input_array() xor=0 for i in range(N-1): for j in range(i+1,N): xor+=int(bin(A[i]^A[j]),2) print(xor % (10**9-7)) " p02594,s678854878,Wrong Answer,"if input()=='30':print('Yes') else:print('No')" p03386,s993396168,Wrong Answer,"A,B,K=map(int,input().split()) if B-A !=0: K=min(K,B-A) ans=set() for i in range(K): ans.add(A+i) ans.add(B-i) ans=list(ans) ans=sorted(ans) for i in ans: print(i)" p02910,s307820769,Accepted,"S = list(input()) odd = [""R"", ""U"", ""D""] even = [""L"", ""U"", ""D""] ans = ""Yes"" for i, s in enumerate(S): if i%2==0 and s not in odd: ans = ""No"" break elif i%2==1 and s not in even: ans = ""No"" break print(ans)" p03251,s648246648,Accepted,"n,m,x,y = map(int, input().split()) *xl, = map(int, input().split()) *yl, = map(int, input().split()) for i in range(x,y+1): if x> j) & 1): x[l - 1 - j]='+' for i in range(l): s.append(x[i]) s.append(n[i+1]) if eval(''.join(s))==7: s+='=7' print(''.join(s)) s=[n[0]]" p03077,s639388072,Wrong Answer,"import math n=int(input()) x=[] for i in range(5): x.append(int(input())) if n==min(x): print(5) else: print(5+math.ceil(n/min(x)))" p03012,s167576477,Accepted,"n = int(input()) a = list(map(int,input().split())) res = 10 ** 100 for i in range(1, n): res = min(res, abs(sum(a[:i]) - sum(a[i:]))) print(res) " p02783,s722976551,Wrong Answer,"a,b=input().split() a=int(a) b=int(b) if a%b==0: print(a/b) else: print(int(a/b+1))" p02624,s931625275,Accepted,"import numpy as np from numba import njit @njit def solve(N): ans = 0 for i in range(1, N + 1): ans += (i + i * (N // i)) * (N // i) // 2 return ans N = int(input()) print(solve(N)) " p02622,s574312935,Accepted,"S= list(input()) T= list(input()) count=0 for i in range(len(S)): if S[i]!=T[i]: count=count+1 print(count)" p02946,s541049127,Accepted,"k,x = map(int, input().split()) a = [] for i in range(1,2*k): a.append(x-k+i) print(*a)" p02546,s087456970,Accepted,"n = input() if n[len(n)-1] == ""s"": print(n+""es"") else: print(n+""s"")" p02996,s342837507,Accepted,"N=int(input()) L=[list(map(int,input().split())) for _ in range(N)] L.sort(key=lambda x:x[1]) t=0 p=True for l in L: t+=l[0] if t > l[1]: p=False break print(""Yes"" if p else ""No"")" p03644,s683510070,Wrong Answer,"N = int(input()) two_list = [1, 2, 4, 8, 16,32,64] for two in two_list: if N > two: if two == 64: print(""64"") else: print(two) exit()" p02615,s529157019,Wrong Answer,"N=int(input()) A=list(map(int,input().split())) A=sorted(A) i=len(A) i//=2 print(sum(A[-i-1:-1])*2+A[-1]) " p02859,s481043745,Accepted,"r = int(input()) print(r * r)" p03795,s350958838,Wrong Answer,"n = int(input()) if n % 15 == 0: print(int(n * 800 - (n/15) * 200)) elif n >= 15 and n % 15 != 0: print(n * 800 - int((n/15)*200))" p03861,s139436497,Wrong Answer,"a,b,x=map(int,input().split()) ta=(a-1)//x tb=b//x ans=tb-ta+1 print(ans)" p02665,s999269114,Accepted,"import sys N = int(input()) A = [int(c) for c in input().split()] B = [0]*(N+1) B[0] = 1 if A[0]>=1: if N==0 and A[0]==1: print(1) else: print(-1) sys.exit() for i in range(1,N+1): B[i] = B[i-1]*2-A[i] if B[i]<0: print(-1) sys.exit() ans = sum(A) num = 0 for i in range(N,0,-1): num = min(num+A[i],B[i-1]) ans += num print(ans)" p03360,s963200232,Accepted,"import math # b=input() # c=[] # for i in range(b): # c.append(a[i]) a = list(map(int,input().split())) #b = list(map(int,input().split())) s=int(input()) for i in range(s): a[a.index(max(a))]= a[a.index(max(a))]*2 print(sum(a))" p03986,s112429807,Wrong Answer,"x=input();print(len(x)-2*min(map(x.lstrip(""T"").rstrip(""S"").count,""ST"")))" p02665,s577477623,Accepted,"n=int(input()) a = list(map(int,input().split())) i=0 b=0 while i<=n: b+=a[i] i+=1 i=0 x=1 ans=0 while i<=n: if a[i] <=x: if x<=b: ans+=x x=(x-a[i])*2 else: ans+=b x = b b-=a[i] else: ans=-1 break i+=1 print(ans) " p03339,s146058235,Wrong Answer,"N = int(input()) S = list(input()) cumsum = [0]*N if S[0] == 'E': cumsum[0] += 1 for i in range(1, N): if S[i] == 'E': cumsum[i] += cumsum[i-1] + 1 else: cumsum[i] += cumsum[i-1] ans = float('inf') ans = min(ans, cumsum[-1]-cumsum[0]) for i in range(1, N): tmp = (i) - (cumsum[i-1] - cumsum[0]) tmp += (cumsum[-1]-cumsum[i]) ans = min(ans, tmp) print(ans)" p02595,s299689915,Wrong Answer,"N,D=input().split() N=int(N) D=int(D) cnt = 0 for i in range(N): p1,p2 = map(int,input().split()) t = ((p1*p1)+(p2*p2))**(0.5) if t >= D: cnt += 1 print(cnt)" p03644,s632661451,Accepted,"N = int (input()) max = 0 ans = 1 for i in range(1, N+1): count = 0 a = i while True: if a % 2 == 1: if max < count: max = count ans = i else: a = int(a / 2) count += 1 continue break print(ans)" p04033,s397662058,Accepted,"a,b=map(int,input().split()) if a>0: print(""Positive"") elif a<0 and b>0: print(""Zero"") else: if a%2 ==b%2: print(""Negative"") else: print(""Positive"")" p03565,s802283444,Accepted,"s = input() t = input() def match(i): for j in range(len(t)): if not s[i+j] == '?' and s[i+j] != t[j]: return False return True for i in range(len(s) - len(t), -1, -1): if not match(i): continue for j in range(i): print('a' if s[j] == '?' else s[j], end='') print(t, end='') for j in range(i+len(t), len(s)): print('a' if s[j] == '?' else s[j], end='') print() exit() print('UNRESTORABLE')" p02628,s865226604,Accepted,"N,K=map(int, input().split()) P=list(map(int, input().split())) Q=sorted(P) ans=0 for i in range(K): ans+=Q[i] print(ans)" p03086,s178143182,Accepted,"s=input() char=[""A"",""C"",""G"",""T""] ans=0 cnt=0 for i in range(len(s)): if s[i] in char: cnt+=1 else: ans=max(ans,cnt) cnt=0 ans=max(ans,cnt) print(ans)" p04045,s314978276,Accepted,"N, K = map(int, input().split()) D = input().split() i = 0 while i < 1: i = 1 for n in str(N): if n in D: i = 0 N += 1 print(N - 1)" p02882,s670670823,Accepted,"a,b,x=list(map(int,input().split())) import math import sys if a*a*b==x: print(0.0000000000) sys.exit() if a*a*b/2<=x: kakudo=a*a*a/2/(a*a*b-x) print(90-math.degrees(math.atan(kakudo))) else: kakudo=2*x/(a*b*b) print(90-math.degrees(math.atan(kakudo))) " p02657,s680663094,Accepted,"A, B = map(int, input().split()) print(A*B)" p02948,s849907271,Accepted,"import collections import heapq n, m = map(int, input().split()) que = [] for _ in range(n): a, b = map(int, input().split()) que.append((-b, a)) que.sort(key=lambda x: x[1]) que = collections.deque(que) h = [] heapq.heapify(h) ans = 0 for i in range(1, m + 1): while len(que) != 0 and que[0][1] <= i: tmp = que.popleft() heapq.heappush(h, tmp) if len(h) == 0: continue tmp = heapq.heappop(h) ans -= tmp[0] print(ans)" p02729,s338724684,Accepted,"N, M = map (int, input().split()) c=(N*(N-1)+M*(M-1))//2 print(c)" p02547,s032983445,Wrong Answer,"# https://atcoder.jp/contests/abc179/tasks/abc179_b t = int(input()) count = 0 pre = 0 test = '' for i in range(t): a, b = map(int, input().split()) if (a == b): test = 'Yes' pre = 1 else: pre = 0 test = 'No' if test == 'Yes' and (pre == 1): count += 1 test = 'Yes' pre = 1 if (count == 3) or (count == 6): print('Yes') else: print('No') " p03107,s688986653,Wrong Answer,"S = input() zero,one = 0,0 for s in S: if s=='0': zero += 1 else: if zero>0: one += 1 print(min(one,zero)*2)" p02983,s509898718,Accepted,"import numpy as np def ABC133C(l, r): Min = np.inf for i in range(l, r): for j in range(i+1, r+1): a = (i * j) % 2019 if a < Min: Min = a if a == 0: # ここに注目 print(Min) return print(Min) l, r = map(int, input().split()) ABC133C(l, r) " p03693,s990932077,Accepted,"r,g,b = map(str,input().split()) a = r+g+b a=int(a) if a%4 ==0: print(""YES"") else: print(""NO"") " p02699,s284904047,Accepted,"# coding: utf-8 import sys sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) S, W = lr() bl = W >= S print('unsafe' if bl else 'safe') " p03338,s631557697,Accepted,"n=int(input()) s = list(input()) wd = list(""abcdefghijklmnopqrstuvwxyz"") ans=0 for i in range(n): s1 = set(s[:i]) s2=set(s[i:]) tmp=0 for w in wd: if w in s1 and w in s2: tmp+=1 ans=max(ans,tmp) print(ans) " p03698,s066805631,Accepted,"s=input() s_set=set(list(s)) if len(s) == len(s_set): print(""yes"") else: print(""no"")" p03548,s040176174,Accepted,"X,Y,Z = map(int, input().split()) print((X-Z) // (Y+Z))" p03282,s408057575,Accepted,"S = input() K = int(input()) t = -1 for k in range(len(S)): t = k if S[k] != ""1"": break if K <= t: print(1) else: print(S[t]) " p03994,s486871048,Accepted,"s=list(input()) N=len(s) K=int(input()) num=123 for i in range(N): diff=(num-ord(s[i]))%26 if K==0: break if diff<=K: s[i]=""a"" K=K-diff #print(s) #print(K) if K>0: K=K%26 s[N-1]=chr(ord(s[N-1])+K) #print(s) print("""".join(s)) " p02661,s286354152,Accepted,"import statistics N = int(input()) AB = [map(int, input().split()) for _ in range(N)] A, B = [list(i) for i in zip(*AB)] A_median = statistics.median(A) B_median = statistics.median(B) if N%2==0: print(int((B_median-A_median)*2)+1) else: print(B_median-A_median+1)" p03282,s703850033,Accepted,"S = input() K = int(input()) for i in range(K): if int(S[i]) != 1: print(S[i]) exit() print(1)" p02719,s668383722,Accepted,"n,k=map(int,input().split()) print(min(n%k,abs(n%k-k))) " p03262,s785413218,Accepted,"from math import gcd n,x=map(int,input().split()) lst=list(map(int,input().split())) for i in range(n): lst[i]=abs(x-lst[i]) a=lst[0] for i in range(1,n): a=gcd(a,lst[i]) print(a)" p03001,s169280870,Accepted,"w,h,x,y = map(int,input().split()) if x==w/2 and y==h/2: print(w*h/2,1) else: print(w*h/2,0)" p02983,s569528591,Accepted,"l,r=map(int,input().split()) if r-l>=2019: ans=0 else: ans=2018 l=l%2019 r=r%2019 for i in range(l,r+1): for j in range(i+1,r+1): ans=min(ans,i*j%2019) print(ans)" p03943,s273048579,Accepted,"abc = list(map(int,input().split())) abc.sort() if abc[0]+abc[1] == abc[2]: print('Yes') else: print('No') " p03592,s019794547,Accepted,"N, M, K = map(int, input().split()) ans = ""No"" for h in range(0, N+1, 1): for w in range(0, M+1, 1): tmp = h * M + w * N - 2*h*w if tmp == K: ans = ""Yes"" print(ans) exit() print(ans)" p03062,s448685409,Accepted,"N = int(input()) A = list(map(int, input().split())) c = 0 f = 0 for i in range(N): if A[i] < 0: c += 1 elif A[i] == 0: f = 1 A[i] = abs(A[i]) if f == 1 or c % 2 == 0: ans = sum(A) else: ans = sum(A) - 2 * min(A) print(ans) " p04034,s533036948,Accepted,"import sys input = sys.stdin.readline # B - Box and Ball N, M = map(int, input().split()) boxes = [1] * (N + 1) boxes[0] = 0 ball_exists = set() ball_exists.add(1) for i in range(M): x, y = map(int, input().split()) boxes[x] -= 1 boxes[y] += 1 if x in ball_exists: if boxes[x] == 0: ball_exists.remove(x) if len(ball_exists) == 1 and y in ball_exists: ball_exists.clear() ball_exists.add(y) #print(boxes) #print(ball_exists) print(len(ball_exists))" p02787,s215374662,Accepted,"h,n = map(int,input().split()) dp = [0]+[1000000000 for _ in range(h)] for i in range(n): ai,bi = map(int,input().split()) for j in range(h): dp[min(j+ai,h)] = min(dp[min(j+ai,h)],dp[j]+bi) print(dp[h])" p02882,s727460462,Accepted,"a,b,x = map(int,input().split()) import math if a**2*b / 2 <= x: alpha = math.degrees(math.atan(2 * (a**2 * b - x) / a**3)) else: alpha = math.degrees(math.atan(a*b**2 / (2*x) )) print(alpha)" p03943,s374534849,Accepted,"a,b,c = map(int, input().split()) print(""Yes"" if a+b == c or a+c == b or b+c == a else ""No"")" p02727,s036793805,Accepted,"from collections import deque X, Y, A, B, C = [int(x) for x in input().split()] p = sorted([int(x) for x in input().split()], reverse=True)[:X] q = sorted([int(x) for x in input().split()], reverse=True)[:Y] pq = deque(sorted(p + q, reverse=True)) r = deque(sorted([int(x) for x in input().split()])) ans = sum(pq) for i in range(len(r)): if r[-1] > pq[-1]: ans += r.pop() - pq.pop() print(ans)" p03644,s938573891,Wrong Answer,"N=int(input()) for i in range(8): if N len(e): ans += o[len(o)-1] print(ans) " p02823,s218820531,Accepted,"N, A, B = map(int, input().split()) distance =(B - A - 1 )//2 if( (A % 2 == 0 and B % 2 ==0) or (A%2==1 and B%2==1)): ans=(B - A)//2 else: ans = min(A-1,N - B) + 1 + distance print(ans)" p03360,s621241355,Accepted,"A,B,C=map(int,input().split()) D=[A,B,C] a=0 K=int(input()) a+=(max(D)*(2**K)) D.remove(max(D)) for i in range(2): a+=D[i] print(a)" p03345,s147477342,Accepted,"a,b,c,k=map(int,input().split()) if abs(a-b)>10**18: print(""unfair"") else: if k%2==0: print(a-b) else: print(b-a) " p02677,s316212282,Accepted,"import math A,B,H,M = map(int,input().split( )) pi = 2*math.pi time = H*60. + M theta_A = (time/720.)*pi theta_B = (M/60.)*pi theta = abs(theta_A - theta_B) if theta >= 180: theta = pi - theta C = A**2 + B**2 - 2*A*B*math.cos(theta) print(math.sqrt(C))" p04012,s809790044,Accepted,"w = list(input()) w.sort() i = 0 if len(w) % 2 == 1: print('No') exit() while i < len(w)-1: if w[i] != w[i+1]: print('No') exit() i += 2 else: print('Yes') " p02790,s908219882,Accepted,"a, b = map(str, input().split()) num1 = a * int(b) num2 = b * int(a) print(min(num1, num2)) " p02576,s288995851,Accepted,"n,x,t = map(int,input().split()) if n%x == 0: print(int(t*n/x)) else: print(int(t*(n//x + 1)))" p02690,s470067233,Accepted,"X = int(input()) for A in range(-198,200): for B in range(-119,119): if pow(A,5) - pow(B,5) == X: print('{} {}'.format(A,B)) exit()" p03711,s297667825,Wrong Answer,"a = [0, 2, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0] x, y = map(int, input().split()) x -= 1 y -= 1 if a[x] == a[y]: print(""No"") else: print(""Yes"") " p03387,s914181072,Accepted,"a,b,c = map(int,input().split()) ans = max(a,b,c)*3-a-b-c if ans%2 == 0: print(ans//2) else: print(ans//2+2)" p02973,s700529692,Accepted,"from bisect import bisect_left N = int(input()) memo = [-1]*N for _ in range(N): a = int(input()) idx = bisect_left(memo,a)-1 memo[idx] = a print(N-memo.count(-1))" p02771,s980620782,Accepted,"import sys input = sys.stdin.readline rs = lambda: input().strip() ri = lambda: int(input()) rl = lambda: list(map(int, input().split())) mod = 10**9 + 7 A, B, C = rl() if len(set([A,B,C])) == 2: print('Yes') else: print('No') " p02724,s455920860,Accepted,"X = int(input()) print((X//500)*1000+((X%500)//5)*5)" p02933,s085078546,Accepted,"#138A #1.入力をちゃんと受け取ること x=input() a=int(x) s=input() #2.結果を出力する if a>=3200 : print(s) else: print('red')" p02987,s252086679,Accepted,"s = input() ans = 'Yes' for c in s: if s.count(c) != 2: ans = 'No' break print(ans) " p02946,s774174914,Accepted,"K,X=map(int,input().split()) print(*range(X-K+1,X+K))" p03001,s892096963,Accepted,"# 点(x, y)から長方形の中心を通る直線を引くと面積を半分にすることができ、分割された小さい方の面積が最大となる # 点(x, y)が長方形の中心と一致する場合、直線は複数存在する w, h, x, y = map(int, input().split()) s = w * h s_min = s / 2 # 中心 a = w / 2 b = h / 2 divide = 0 if x == a and y == b: divide = 1 print(s_min, divide) else: print(s_min, divide)" p02603,s653676483,Accepted,"n=int(input()) ar=list(map(int,input().split())) c=1000 for i in range(n-1): if ar[i+1]>ar[i]: cur=c//ar[i] c%=ar[i] c+=ar[i+1]*cur ## print(i,cur,c) print(c) " p02784,s671466437,Accepted,"H,N = map(int, input().split()) A = list(map(int, input().split())) if H <= sum(A): print('Yes') else: print('No') " p02951,s924746825,Wrong Answer,"A,B,C = map(int,input().split()) print(C-A+B)" p02628,s657639887,Wrong Answer,"import heapq N,K = map(int,input().split()) p = list(map(int,input().split())) sum(heapq.nsmallest(K,p))" p03627,s351164456,Accepted,"n = int(input()) a = list(map(int, input().split())) a.sort() a.reverse() ret = [] my_s = set() for item in a: if item in my_s: ret.append(item) if len(ret) == 2: print(ret[0] * ret[1]) exit() my_s.remove(item) else: my_s.add(item) print(0) " p02708,s369846105,Accepted,"N, K = map(int, input().split()) ans = 0 for i in range(K,N+2): ans += N*i -i**2 +i +1 print(ans%(10**9 + 7))" p03720,s105231804,Accepted," if __name__ == '__main__': N,M=list(map(int,input().split())) roads=[0 for i in range(N)] for i in range(M): a,b=list(map(int,input().split())) roads[a-1]+=1 roads[b-1]+=1 for road in roads: print(road)" p02697,s359198219,Wrong Answer,"N,M=map(int,input().split()) if N%2==1: for i in range(M): print(i+1,N-i) else: middle=int((M+1)/2) for i in range(middle): print(i+1,middle-i) for j in range(middle,M): print(j,N+middle-j)" p03160,s847062725,Accepted,"N = int(input()) steps = list(map(int, input().split())) costs = [0]*(N+1) for i in range(1, N): if i==1: costs[1] = abs(steps[1]-steps[0]) continue a = costs[i-1]+abs(steps[i]-steps[i-1]) b = costs[i-2]+abs(steps[i]-steps[i-2]) costs[i] = min(a, b) print(costs[N-1])" p03013,s667485213,Accepted,"n, m = list(map(int, input().split())) a = [] for _ in range(m): a.append(int(input())) a = set(a) cur = 0 dp = [0 for _ in range(n + 1)] dp[0], dp[1] = 1, 1 if 1 in a: dp[1] = 0 for i in range(2, n + 1): if i in a: continue dp[i] = (dp[i - 1] + dp[i - 2]) % (10 ** 9 + 7) print(dp[n]) " p03077,s803801770,Accepted,"import math n = int(input()) abc = sorted([int(input()) for _ in range(5)]) print(4+math.ceil(n/abc[0]))" p02917,s816218179,Accepted,"n = int(input()) li = list(map(int,input().split())) lia = [li[0]] li.append(100001) for i in range(n-1): lia.append(min(li[i],li[i+1])) print(sum(lia))" p02862,s204832985,Accepted,"x,y = map(int,input().split()) mod = 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 % mod if (x+y) % 3 == 0: a = (2*y-x) //3 b = (2*x-y) //3 if a >= 0 and b >= 0: print(comb(a+b,a)) exit() print(0)" p03327,s323072202,Wrong Answer,"n = int(input()) print(""ABC{0:03d}"".format(n) if n<1000 else ""ABD{0:03d}"".format(n-999))" p03338,s673937327,Wrong Answer,"#C - Attention N = int(input()) S = input() DP_w= [] DP_e = [] tmp = 0 tmpw = 0 tmpe = 0 ans = 0 # for i in range(N): # if S[i] == ""W"": # tmpw += 1 # DP_w.append(tmpw) # DP_e.append(tmpe) # else: # tmpe += 1 # DP_w.append(tmpw) # DP_e.append(tmpe) for i in range(N): tmpw = S[:i].count('W') tmpe = S[i:].count('E') ans = max(ans,tmpw+tmpw) print(ans)" p02663,s803452532,Accepted,"h1, m1, h2, m2, k = map(int, input().split()) print((h2 - h1) * 60 + (m2 - m1) - k) " p03067,s027969766,Wrong Answer,"a, b, c = map(int, input().split()) print(""Yes"" if b-a >=c else ""No"")" p03773,s552310463,Accepted,"print(sum(map(int,input().split()))%24)" p02795,s361936828,Accepted,"x = int(input()) y = int(input()) z = int(input()) a = max(x,y) if z%a == 0: print(z//a) else: print(z//a+1)" p03486,s676926299,Accepted,"s = sorted(list(input())) t = list(input()) t.sort(reverse = True) s += """".join(s) t += """".join(t) if s < t: print(""Yes"") else: print(""No"")" p02677,s067402769,Accepted,"import math A,B,H,M=map(int,input().split()) C2=A**2+B**2-2*A*B*math.cos((30*H-11*M/2)/180*math.pi) print(C2**(1/2))" p02697,s155805231,Accepted,"n,m = map(int,input().split()) if(n % 2 == 0): d = n // 2 - 1 c = 0 i = 1 while(d > 0): print(i,i+d) d -= 2 i += 1 c += 1 if(c == m):exit() d = n // 2 - 2 i = n // 2 + 1 while(d > 0): print(i,i+d) d -= 2 i += 1 c += 1 if(c == m):exit() else: for i in range(m): print(i+1,n-i) " p02783,s209604831,Accepted,"import sys sys.setrecursionlimit(1000000000) import math from fractions import gcd from itertools import count, permutations from functools import lru_cache from collections import deque, defaultdict from pprint import pprint ii = lambda: int(input()) mis = lambda: map(int, input().split()) lmis = lambda: list(mis()) INF = float('inf') N1097 = 10**9 + 7 def meg(f, ok, ng): while abs(ok-ng)>1: mid = (ok+ng)//2 if f(mid): ok=mid else: ng=mid return ok # def main(): H,A=mis() print(math.ceil(H/A)) main() " p02897,s495036419,Accepted,"import math N = int(input()) ans = (math.ceil(N/2))/N print(ans)" p03408,s811576481,Accepted,"blue={} red={} n=int(input()) for i in range(n): s=input() blue[s]=blue.get(s,0)+1 m=int(input()) for i in range(m): t=input() red[t]=red.get(t,0)+1 mx=0 for k,v in blue.items(): mx=max(mx,blue[k]-red.get(k,0)) print(mx) " p03778,s852966637,Wrong Answer,"W,a,b =map(int,input().split()) if b-(a+W)<0: print(0) elif b A-1: print(int(A+(B-A-1)//2)) else: print(int(N-B+1+((N-(A+N-B+1))//2))) " p02608,s096664546,Accepted,"import numpy as np N = int(input()) #N,K,d= map(int,input().split()) #A = list(map(int,input().split())) #S = str(input()) #T = str(input()) num=np.zeros(10**4+1) 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 if ans < 10**4+1: num[ans]+=1 for i in range(N): print(int(num[i+1])) " p02897,s030266388,Accepted,"N = int(input()) print(1 - (N//2) / N)" p03645,s215379801,Accepted," n,m = map(int,input().split()) s_L = [] for i in range(m): L = list(map(int,input().split())) a = min(L) b = max(L) if a == 1: s_L.append(b) elif b == n: s_L.append(a) #print(s_L) if len(set(s_L)) == len(s_L): print(""IMPOSSIBLE"") else: print(""POSSIBLE"") " p03495,s800010730,Wrong Answer,"from collections import Counter N,K=map(int,input().split()) A=Counter(list(map(int,input().split())) ) print(sum(sorted(A.keys(), reverse=True)[K:]))" p02621,s812889524,Wrong Answer,"a = int(input()) ans = (a + (a**2) + (a**3))" p03221,s102098171,Accepted,"N, M = map(int, input().split()) PYi = [list(map(int, input().split()))+[i] for i in range(M)] PYi.sort() ans = ['']*M counter = {} for v in PYi: P, Y, i = v if not P in counter: counter[P] = 1 else: counter[P] += 1 tmp = '' tmp += str(P).zfill(6) tmp += str(counter[P]).zfill(6) ans[i] = tmp for v in ans: print(v) " p03126,s070813870,Accepted,"N, M = map(int, input().split()) x = {i + 1 for i in range(M)} for _ in range(N): x &= set(list(map(int, input().split()))[1:]) print(len(x))" p02658,s882194928,Accepted,"n = int(input()) a = list(map(int, input().split())) ans = 1 a.sort() for i in range(n): ans *= a[i] if ans > 10**18: print(-1) exit() print(ans) " p02684,s820169931,Wrong Answer,"N,K= map(int, input().split()) A = list(map(int,input().split())) if(A[0] == 1): print(1) exit(0) p = 1 P = [] start,stop = 0, 0 for i in range(N): p = A[p-1] if p in P: start = P.index(p) break P.append(p) stop = len(P)-1 if len(P) == K: print(B[-1]) else: del P[0:start] Z = (K-start-1)%((stop-start+1)) print(P[Z]) " p03011,s891197281,Accepted,"p,r,q = map(int,input().split()) ans = [] ans.append(p+r) ans.append(q+r) ans.append(p+q) print(min(ans)) " p03861,s431398526,Accepted,"a,b,x = list(map(int, input().split())) print(b//x - (a-1)//x) " p03261,s171304557,Accepted,"n = int(input()) L = [input() for i in range(n)] LL = set(L) if len(LL) != n: print('No') exit() for i in range(n-1): if L[i][-1] != L[i+1][0]: print('No') exit() else: print('Yes')" p03095,s209898245,Wrong Answer,"input() S=input() s=set(S) a=1 for c in s:a*=(S.count(c)+1)%(10**9+7) print(a-1) " p02708,s748656499,Wrong Answer,"n, k = map(int, input().split()) MOD = 10**9+7 dp = [0] * (n+1) dp[1] = n+1 for i in range(2, n+1): dp[i] = dp[i-1] * (n + 1 - (i-1)) // i print(sum(dp[k:]) % MOD) " p02725,s504014252,Wrong Answer,"def main(): K,N = map(int, input().split()) A_list = list(map(int, input().split())) space_max = 0 if A_list[N-1] - A_list[0] <= K/2: print(A_list[N-1] - A_list[0]) exit() else: pass for i in range(N-1): space = A_list[i+1] - A_list[i] if space > space_max: space_max = space else: pass print(K-space_max) if __name__ == ""__main__"": main()" p03221,s142674414,Accepted,"N, M = map(int, input().split()) G = [[] for _ in range(N)] res = [10 ** 12] * M for i in range(M): p, y = map(int, input().split()) G[p - 1].append((y, i)) G = list(map(sorted, G)) for p in range(N): for m, (y, i) in enumerate(G[p], 1): res[i] += (p + 1) * 10 ** 6 + m for r in res: print(str(r)[1:]) " p02696,s222471705,Wrong Answer,"import sys A,B,N=map(int,input().split()) X=B-1 X=max(B-1,N) ans=(A*X)//B-A*(X//B) print(ans) " p02742,s880769150,Accepted,"import math h, w = [int(w) for w in input().split()] if h == 1 or w == 1: print(1) else: print(math.ceil(h * w / 2)) " p03331,s425592484,Accepted,"n = int(input()) def dig(num): ans = 0 while num>0: ans += num%10 num//=10 return ans mi = float('inf') for i in range(1,n//2+1): a = dig(i)+dig(n-i) mi = min(a,mi) print(mi) " p02578,s575735723,Wrong Answer,"n=int(input()) listA=list(map(int,input().split())) listB=[0] for i in range(len(listA)-1): if listA[i+1]>listA[i]: listB.append(listA[i+1]-listA[i]) print(sum(listB))" p03071,s828327172,Accepted,"a, b = map(int, input().split()) if a>=b: c = a a -= 1 else : c = b b -= 1 if a>b : d = a a -= 1 else : d = b b -= 1 print(c + d)" p03434,s124771498,Accepted,"def resolve(): N = int(input()) a = list(map(int, input().split())) Alice = sorted(a)[::2] Bob = sorted(a)[1::2] print(abs(sum(Alice)-sum(Bob))) resolve()" p03617,s002022048,Accepted,"q,h,s,d = map(int,input().split()) n = int(input()) h = min(h, 2*q) s = min(s, 2*h) d = min(d, 2*s) res = d*(n//2) res += s if n%2!=0 else 0 print(res)" p02622,s485671675,Accepted,"import sys sys.setrecursionlimit(10 ** 7) input = sys.stdin.readline f_inf = float('inf') mod = 10 ** 9 + 7 def resolve(): S = input() T = input() res = 0 for s, t in zip(S, T): if s != t: res += 1 print(res) if __name__ == '__main__': resolve() " p02756,s922897899,Wrong Answer,"s = [] s.append(input()) Q = int(input()) cnt = 0 for _ in range(Q): tmp = input().split() if tmp[0] == '1': cnt += 1 continue else: if cnt % 2: pass else: s.reverse() if tmp[2] == 1: s.insert(0, tmp[2]) else: s.append(tmp[2]) if cnt % 2: pass else: s.reverse() print(''.join(s))" p02881,s317111163,Wrong Answer,"n=int(input()) ro=n**0.5 # print( ro ) maxi=1 for i in range(2, int(ro)): if n%i==0: maxi=i print( maxi-1+n//maxi-1) " p03136,s964058841,Wrong Answer,"N = int(input()) List = list(map(int, input().split())) print(""Yes"" if max(List) <= sum(List)-max(List) else ""No"")" p04012,s699087879,Accepted,"w = list(input()) import collections c = collections.Counter(w) li = list(c.values()) ans = ""Yes"" for i in range(len(li)) : if li[i] % 2 == 1 : ans = ""No"" break print(ans)" p02983,s583077542,Wrong Answer,"l, r = map(int, input().split()) if (r % 2019 == 0) or (l % 2019 == 0) or (r-l >= 2019): print('1') else: min_num = 2020 for left in range(l, r): for right in range(left+1, r+1): mod = (left * right) % 2019 min_num = min(min_num, mod) print(min_num) " p03723,s660203468,Accepted,"#!/usr/bin/env python3 a, b, c = map(int, input().split()) o = 0 if a == b == c:print(a%2-1);exit() while 1-any([a%2, b%2, c%2]): a, b, c = (b+c)//2, (c+a)//2, (a+b)//2 o += 1 print(o) " p04044,s191123933,Accepted,"input_map = [] string_num, string_length = map(int, input().split()) for i in range(string_num): input_line = input() input_map.append(input_line) input_map.sort() line = """" for i in range(string_num): line = line + input_map[i] print(line)" p03836,s270329618,Wrong Answer,"sx,sy,tx,ty = map(int,input().split()) going1 = """" returning1 = """" going2 = """" returning2 = """" going1 = 'R' * (tx - sx) + 'U' * (ty - sy) returning1 = 'L' * (tx -sy) + 'D' * (ty - sy) going2 = 'D' + 'R' * (tx - sx + 1) + 'U' * (ty - sy + 1) + 'L' returning2 = 'U' + 'L' * (tx - sx + 1) + 'D' * (ty - sy + 1) + 'R' print(going1 + returning1 + going2 + returning2) " p04029,s871525461,Accepted,"n = int(input()) print(int((1/2)*n*(n+1)))" p02796,s393260924,Accepted,"n = int(input()) robot = [0]*n for i in range(n): a, b = map(int, input().split()) robot[i] = [a+b, a-b] robot.sort() ans = 0 for i in range(n): if i == 0: key = robot[0][0] ans += 1 continue if robot[i][1] < key: continue key = robot[i][0] ans += 1 print(ans)" p02606,s344037526,Wrong Answer,"L, R, d = map(int, input().split()) print((R - L + 1) // d) " p02658,s236033426,Accepted,"N=int(input()) lis = list(map(int, input().split())) ans=1 j=True if lis.count(0) > 0: print(0) else: for a in lis: ans*=a if ans > pow(10,18): j=False break if j: print(ans) else: print(-1)" p02621,s555521467,Accepted,"a = int(input()) print(int(a+a**2+a**3)) " p03264,s185239594,Accepted,"k = int(input()) print(k // 2 * -(-k // 2))" p02720,s607731867,Accepted,"from collections import deque K = int(input()) Q = list(range(1, 10)) for i in range(K): x = Q[i] y = x%10 if y != 0: Q.append(10*x + y-1) Q.append(10*x + y) if y != 9: Q.append(10*x + y+1) print(Q[K-1])" p02598,s822311596,Accepted,"# -*- coding: utf-8 -*- N,K = map(int, input().split()) A = list(map(int, input().split())) def num_cut(L): result = 0 for a in A: result += a//L if a%L == 0: result -= 1 return result m = 0 M = 10**9 while M-m>1: X = (m+M)//2 if num_cut(X)>K: m = X else: M = X print(M)" p03076,s447205115,Accepted,"#B import math a = [] a1 = [] f = 10 for i in range(5): a.append(int(input())) a1.append(math.ceil(a[i] / 10) * 10) if f > a[i] % 10 and a[i] % 10 != 0:#ロスタイムfが小さい0はすぐに注文できるから f = a[i] % 10 #累計時間sum(a1)-最小ロスタイムf print(sum(a1) - 10 + f)" p02726,s297027318,Accepted,"n,x,y = map(int,input().split()) s = [0]*(n) for i in range(1,n): for k in range(i+1,n+1): dist = min(k-i, abs(x-i) + 1 + abs(y-k)) s[dist] += 1 for i in range(1,n): print(s[i])" p02909,s805320839,Accepted,l=' RainyCloudySunny';print(l[l.find(input())-6:][:6]) p03106,s531157478,Wrong Answer,"import math num1, num2, target = map(int, input().split()) number = math.gcd(num1, num2) table = [] for j in range(1, number+1): if number % j == 0: table.append(j) print(table[target - 1]) " p02595,s045685449,Wrong Answer,"#=input() #=int(input()) n,d=map(int,input().split()) #=map(str,input().split()) #=list(map(int,input().split())) xy = [map(int , input().split())for _ in range(n)] x,y = [list(i) for i in zip(*xy)] t = 0 for k in range(n): xk=x[k] yk=y[k] if xk^2 + yk^2 <= d: t += 1 print(t)" p03475,s469424223,Wrong Answer,"n=int(input()) l=[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=l[j][0],l[j][1],l[j][2] if t p+q: b = p+q if c < p-q: c = p-q if d > p-q: d = p-q print(max(a-b,c-d)) " p03659,s980158731,Accepted,"N=int(input()) A=[int(i) for i in input().split()] CS=[A[0]] for i in range(1,N-1): CS.append(CS[-1]+A[i]) SUM=sum(A) ans=10**20 for s in CS: ans=min(ans,abs(SUM-s-s)) print(ans)" p03030,s281910709,Accepted,"n = int(input()) l = [] for i in range(n): s,p = input().split() l.append((s,-int(p),i+1)) l.sort() for i in range(n): print(l[i][2]) " p03698,s602984909,Accepted,"s = input() s = [c for c in s] leng = len(s) s = set(s) if leng==len(s): print('yes') else: print('no')" p03131,s109288213,Accepted,"K,A,B=map(int,input().split()) b_count=1 if B-A<=2: b_count+=K else: b_chenge_count=max(0,int((K-(A-1))/2)) b_count+=b_chenge_count*(B-A)+(A-1)+(K-(A-1)-b_chenge_count*2) print(b_count)" p02772,s419711480,Accepted,"n=input() a=list(map(int,input().split())) for x in a: if x%2 == 1: continue if x%3==0 or x%5 == 0: continue else: print('DENIED') break else: print('APPROVED')" p02924,s097602150,Accepted,"N = int(input()) print(N * (N - 1) // 2)" p02645,s233724719,Wrong Answer,"s=input() print(s[0:2])" p02708,s625818121,Accepted,"mods=10**9+7 N, K = map(int,input().split(' ')) cnt = 0 for k in range(K,N+1+1): minsum = k*(k+1)/2 -k maxsum = k*(k+1)/2 + (N-k)*(k) cnt+=(maxsum-minsum+1) cnt=cnt%mods print(int(cnt))" p02726,s813649845,Accepted,"n, x, y = map(int, input().split()) x -= 1 y -= 1 ans = [0] * n for i in range(n - 1): for j in range(i, n): dist = min(j-i, abs(x-i) + abs(y-j) + 1) ans[dist] += 1 for i in range(1, n): print(ans[i])" p02706,s682166667,Wrong Answer,"x, y = map(int, input().split()) A = list(map(int, input().split())) for num in range(y): x -= A[num] print(x)" p03438,s856043719,Accepted,"(n,),aa,bb = [list(map(int, s.split())) for s in open(0)] up = down = 0 for i in range(n): a = aa[i] b = bb[i] if a > b: down += a-b if b > a: d,m = divmod(b-a,2) up += d+m down += m diff = sum(bb) - sum(aa) if up <= diff and down <= diff: print('Yes') else: print('No')" p03208,s937662786,Accepted,"N, K = map(int, input().split()) H = sorted([int(input()) for i in range(N)]) list1 = [] for i in range(N - K + 1): h = H[i + K -1]-H[i] list1.append(h) print(min(list1)) " p04033,s430187438,Accepted,"a, b = map(int, input().split()) if (0 < a): res = ""Positive"" elif a <= 0 <= b: res = ""Zero"" else: if a == b: res = ""Positive"" elif (b-a) % 2 == 1: res = ""Positive"" else: res = ""Negative"" print(res)" p02639,s291491283,Accepted," a,b,c,d,e = map(int,input().split()) ans = 15 - a - b - c - d-e print(ans)" p03997,s820422802,Accepted,"# -*- coding:utf-8 -*- import sys input = sys.stdin.readline a = int(input()) b = int(input()) h = int(input()) print(int((a+b)*(h/2)))" p03001,s624236088,Accepted,"w, h, x, y = map(int, input().split()) if x == w/2 and y == h/2: print(w * h / 2, 1) else: print(w * h / 2, 0) " p02791,s386612098,Accepted,"n=int(input()) p=list(map(int,input().split())) cnt=0 m=10**9 for i in p: if i<=m: cnt+=1 m=i print(cnt)" p02546,s670317195,Accepted,"s = input() if s[-1] == 's': print(s + 'es') else: print(s + 's')" p02607,s710585692,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 else: pass print(ans)" p02723,s720394179,Accepted,"S = input() S = list(S) if S[2] == S[3] and S[4] == S[5]: print(""Yes"") else: print(""No"") " p03796,s700608414,Accepted,"from math import factorial n = int(input()) print(factorial(n) % 1000000007)" p02583,s520299551,Accepted,"N=int(input()) L=list(map(int,input().split())) L.sort() count=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]): count += 1 print(count)" p03481,s452515561,Accepted,"x, y = map(int, input().split()) ans = 0 while x <= y: ans += 1 x *= 2 print(ans) " p03998,s837512798,Wrong Answer,"A=list(input()) B=list(input()) C=list(input()) next=""a"" while True: if next==""a"": if len(A)==0: print(""A"");exit() next=A.pop() elif next==""b"": if len(B)==0: print(""B"");exit() next=B.pop() else: if len(C)==0: print(""C"");exit() next=C.pop() " p02663,s707515651,Accepted,"h,m,a,b,k=map(int,input().split()) h_to_min = h * 60 a_to_min = a * 60 re1 = a_to_min - h_to_min re2 = b - m re = re1 + re2 print(re-k)" p02767,s851422207,Accepted,"def main(): n = int(input()) x = list(map(int, input().split())) min = 10000000000 for point in range(10000): s = sum([(i - point)**2 for i in x]) if s < min: min = s print(min) if __name__ == ""__main__"": main() " p02988,s967882161,Accepted,"n = int(input()) L = list(map(int,input().split())) cnt = 0 for i in range(n-2): s = L[i:i+3][1] A = sorted(L[i:i+3]) t = A[1] if s == t: cnt += 1 print(cnt)" p03721,s911422154,Accepted,"n,k = map(int, input().split( )) ins = [tuple(map(int, input().split( ))) for _ in range(n)] ins.sort() cnt = 0 for i in range(n): cnt += ins[i][1] if cnt >= k: print(ins[i][0]) exit() " p03774,s519529483,Wrong Answer,"N, M = map(int, input().split()) n_student = [list(map(int, input().split())) for i in range(N)] m_point = [list(map(int, input().split())) for i in range(M)] for x in range(N): min_y = 0 min_value = 1000000 for y in range(M): distance = abs(n_student[x][0] - m_point[y][0]) + \ abs(n_student[x][1] - m_point[y][1]) if distance < min_value: min_value = distance min_y = y + 1 print(min_y) " p03719,s316255344,Accepted,"a,b,c=map(int,input().split()) if a<=c<=b: print(""Yes"") else: print(""No"")" p02727,s257712523,Wrong Answer,"x,y,a,b,c = list(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-a:] q = q[y-b:] ans = p+q+r ans.sort(reverse=True) print(sum(ans[:x+y]))" p03285,s200707194,Accepted,"n = int(input()) s = 'No' for i in range(26): for j in range(16): total = 4*i +7*j if total == n: s = 'Yes' break if total ==n: break print(s)" p02615,s828377929,Wrong Answer,"N = int(input()) A = [int(i) for i in input().split()] A.sort(reverse=True) comf = 0 for i in range(1,N): comf += A[i-1] print(comf)" p02909,s222634950,Accepted,"s=input() if s==""Sunny"":print(""Cloudy"") elif s==""Cloudy"":print(""Rainy"") elif s==""Rainy"":print(""Sunny"")" p03720,s406180976,Wrong Answer,"N,M = map(int,input().split()) AB = [list(map(int,input().split())) for _ in range(M)] WAY = [[] for _ in range(N+1)] for a,b in AB: WAY[a].append(b) WAY[b].append(a) ans = [] for i in range(1,N+1): c = len(set(WAY[i])) ans.append(c) print(""\n"".join(map(str,ans))) " p03494,s859541603,Accepted,"n = int(input()) list = list(map(int, input().split())) b = -1 cont = True while cont: b += 1 for i in range(n): if(list[i] % 2 == 0): list[i] = list[i] / 2 else: cont = False print(b) " p03386,s461454884,Accepted,"a,b,k=map(int,input().split()) lst=[] for i in range(a,a+k): if i>b: break lst.append(i) print(i) for i in range(b-k+1,b+1): if i0: if (x%11)%6!=0: ans=2*(x//11)+((x%11)//6)+1 else: ans=2*(x//11)+1 else: ans=2*(x//11) print(ans)" p02987,s382541752,Accepted,"from collections import defaultdict S = input() d = defaultdict(int) for i in range(len(S)): d[S[i]] += 1 f = 0 for i in range(len(S)): if d[S[i]] != 2: f = 1 if f == 0: print(""Yes"") else: print(""No"")" p02879,s092456634,Accepted,"a, b = map(int,input().split()) print(a * b if 10>a and 10>b else -1)" p02642,s392234810,Accepted,"import copy def main(): N = int(input()) A = list(map(int, input().split())) A.sort() A_max = A[N-1] div_count = [0] * (A_max + 1) for a in A: for n in range(a, A_max+1, a): div_count[n] += 1 exists = [False] * (A_max + 1) for a in A: exists[a] = True result = 0 for i, d in enumerate(div_count): if d == 1 and exists[i]: result += 1 print(result) main() " p02547,s718515338,Accepted,"N = int(input()) number = [0]*N for i in range(N): a,b = map(int,input().split()) if a==b: number[i]=1 for i in range(N-2): if number[i]==1 and number[i+1]==1 and number[i+2]==1: print(""Yes"") exit(0) print(""No"") " p02778,s252732524,Accepted,"S = input() ans = """" for i in range(len(S)): ans += ""x"" print(ans) " p03087,s616332540,Accepted,"#!/usr/bin/env python3 n, Q = map(int, input().split()) s = input() q = [[*map(int, input().split())] for _ in range(Q)] R = [0] for i in range(n - 1): R.append(R[-1] + (s[i:i + 2] == ""AC"")) for l, r in q: print(R[r-1]-R[l-1]) " p03001,s249056458,Wrong Answer,"w,h,x,y = map(int, input().split()) ans = 0 if w%2==0:ans += 1 if h%2==0:ans += 1 if ans > 0: ans -= 1 print((w*h)/2, ans)" p03827,s910720938,Accepted,"n = int(input()) s = input() cnt = 0 ans = 0 for i in s: if i == 'I': cnt += 1 else: cnt -= 1 ans = max(ans, cnt) print(ans) " p02994,s371808080,Wrong Answer,"N,L = list(map(int,input().split())) taste = list(range(L,L+N)) m = max(taste) for e in taste: if abs(e) < m: m = e print(sum(taste) - m)" p03252,s639980495,Accepted,"from collections import defaultdict as dd s=input() t=input() ds=dd(int) dt=dd(int) for ss in s: ds[ss]+=1 for tt in t: dt[tt]+=1 # print(ds) # print(dt) ls,lt=[],[] for k,v in ds.items(): ls.append(v) for k,v in dt.items(): lt.append(v) # print(ls) # print(lt) ls.sort() lt.sort() for a,b in zip(ls,lt): if a!=b: print('No') exit() print('Yes')" p02624,s941544304,Wrong Answer,"def prime_factorize(n): a = [1] 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()) sum = 0 for i in range(1,N+1): sum += i*len(prime_factorize(i)) print(sum)" p03487,s773917840,Accepted,"def count(list): dict = {} for i in range(len(list)): dict[list[i]] = dict.get(list[i], 0) + 1 return dict n = int(input()) a = list(map(int,input().split())) dic = count(a) ans = 0 for i, x in dic.items(): differ = x - i if differ>0: ans += differ elif differ<0: ans += x print(ans)" p03796,s855164921,Accepted,"N = int(input()) power = 1 for i in range(N): power*=i+1 power%=1000000007 print(power)" p02754,s539707429,Accepted,"n,a,b = map(int, input().split()) ans = n //(a+b) * a if n % (a+b) != 0: if n % (a+b) < a: ans += n%(a+b) else: ans += a print(ans)" p03285,s041888808,Accepted,"n = int(input()) ans = ""No"" for i in range(n // 4 + 1): for j in range(n // 7 + 1): if 4 * i + 7 * j == n: ans = ""Yes"" break print(ans)" p03252,s032937477,Accepted,"s = input() t = input() d = {x: 0 for x in ""abcdefghijklmnopqrstuvwxyz""} e = {x: 0 for x in ""abcdefghijklmnopqrstuvwxyz""} for i in range(len(s)): if d[s[i]] == 0 and e[t[i]] == 0: d[s[i]] = t[i] e[t[i]] = s[i] else: if d[s[i]] != t[i] or e[t[i]] != s[i]: print(""No"") exit() print(""Yes"")" p03161,s950476152,Accepted,"n,k = [int(x) for x in input().split()] h = [int(x) for x in input().split()] dp = [float(""inf"") for _ in range(n)] dp[0] = 0 for i in range(1,n): for j in range(1,min(k,i)+1): dp[i] = min(dp[i],dp[i-j]+abs(h[i]-h[i-j])) print(dp[-1])" p02759,s212958997,Accepted,"N = int(input()) print((N+1)//2)" p02924,s070474705,Wrong Answer,"N = int(input()) print(int(N*(N-1)/2))" p03163,s920991684,Accepted,"N, W = map(int, input().split()) wv = [] for _ in range(N): wv.append(list(map(int, input().split()))) # print(wv) dp = [[0] * 100100 for _ in range(110)] for i in range(N): for sum_w in range(W + 1): if wv[i][0] <= sum_w: dp[i + 1][sum_w] = max(dp[i + 1][sum_w], dp[i][sum_w - wv[i][0]] + wv[i][1]) dp[i + 1][sum_w] = max(dp[i + 1][sum_w], dp[i][sum_w]) print(dp[N][W]) " p03471,s056447267,Accepted,"from sys import exit n, y = map(int, input().split()) for i in range(n+1): for j in range(n-i+1): k = n - i - j if 10000 * i + 5000 * j + 1000 * k == y: print(i, j, k) exit() print(-1, -1, -1)" p03281,s041210352,Accepted,"n = int(input()) odd_list = [num for num in range(1, n+1, 2)] cnt_8 = 0 for i in odd_list: cnt = 0 for j in range(1, i+1, 2): if i % j == 0: cnt += 1 if cnt == 8: cnt_8 += 1 print(cnt_8) " p04005,s928618863,Accepted,"import math tmp = list(map(int, input().split())) tmp.sort() a = tmp[0] b = tmp[1] c = tmp[2] if a % 2 == 0 or b % 2 == 0 or c % 2 == 0: print(0) else: print(abs(a * b * (c // 2) - (a * b * (math.ceil(c / 2))))) " p03723,s473866878,Accepted,"A, B, C = map(int, input().split()) if A==B==C: if A%2==0: print(-1) else: print(0) else: for i in range(1000000000): if A %2==0 and B%2==0 and C%2==0: a = A/2 b = B/2 c = C/2 A = b+c B = a+c C = a+b else: print(i) exit() " p02922,s472710569,Accepted,"a, b = map(int, input().split()) sum = 1 count = 0 while sum < b: sum += a - 1 count += 1 print(count) " p03474,s558427571,Accepted,"import re A, B = input().split() print('Yes') if re.fullmatch(r'[0-9]{' + A + r'}-[0-9]{' + B + r'}', input()) else print('No')" p02659,s992330546,Accepted,"A, B= input().split() A = int(A) B = B.replace('.','') B = int(B) print(A*B//100)" p02843,s577105811,Wrong Answer,"X = int(input()) DP=[0]*(X+1) def dp(n): if n<100: return 0 if 100<=n and n<=105: return 1 res = 0 for i in range(100,106): res |= DP[n-i] return res for i in range(X+1): DP[i] = dp(i) ans=DP[X] print(DP) print(ans) #print(*ans, sep='/n')" p03623,s506453329,Wrong Answer,"x , a , b = map(int,input().split()) if abs(x-a) > abs(x-b): print(""A"") else: print(""B"")" p02743,s411573295,Accepted,"from decimal import Decimal a, b, c = list(map(int, input().split())) if Decimal(c).sqrt() > Decimal(a).sqrt() + Decimal(b).sqrt(): print('Yes') else: print('No')" p03659,s825418458,Wrong Answer,"n = int(input()) a = list(map(int, input().split())) ans = 1000000007 for i in range(1, len(a)): x = sum(a[0:i]) y = sum(a[i:len(a)]) if abs(x - y) < ans: ans = abs(x - y) print(ans) " p03665,s946711511,Accepted,"N, P = map(int, input().split()) A = list(map(int, input().split())) # すべて偶数か判定 if all(a % 2 == 0 for a in A): if P == 0: print(2**N) else: print(0) else: print(2**(N-1))" p02831,s249694374,Wrong Answer," A, B = map(int, input().split("" "")) A_, B_ = A, B common = 1 n_max = int(min(A,B)**0.5+1) for n in range(2, n_max+1): while True: if (A_ % n == 0) and (B_ % n == 0): common *= n A_ = A_ // n B_ = B_ // n else: break print(common * A_ * B_)" p02922,s930048711,Accepted,"import math A, B = map(int, input().split()) print(1+math.ceil((B-A)/(A-1)))" p03557,s202017211,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)] n=n0() a=n1() b=n1() c=n1() a.sort() b.sort() c.sort() from bisect import bisect_left,bisect_right b2=[] for i in b: b2.append(bisect_left(a,i)) import itertools b3=list(itertools.accumulate(b2)) ans=0 for i in c: t=bisect_left(b,i) if t>0: ans+=b3[t-1] print(ans)" p03106,s476001643,Wrong Answer,"a,b,k = map(int,input().split()) A=[] for i in range(1,101): if a%i == 0 and b%i==0: A.append(i) print(A[k-1])" p03416,s354485160,Accepted,"A,B = map(int,input().split()) count = 0 for i in range(A,B+1): i = str(i) if (i[0]==i[-1])and(i[1]==i[-2]): count += 1 print(count)" p02946,s604369944,Accepted,"k, x = map(int, input().split()) ans =[] for i in range(x-k+1, x+k): ans.append(i) ans = map(str, ans) print(' '.join(ans))" p03485,s498354050,Accepted,"print(eval('-(-('+input().replace(' ','+')+')//2)'))" p03323,s023549496,Accepted,"a,b=map(int,input().split("" "")) print(["":("",""Yay!""][max(a,b)<9])" p02971,s094683888,Accepted,"n = int(input()) import heapq a = [] heapq.heapify(a) # リストを変換 z = [] for i in range(n): ai = int(input()) z.append(ai) if i < 2: heapq.heappush(a, ai) else: t = heapq.heappop(a) #print(ai, t) heapq.heappush(a, max(ai, t)) x2 = heapq.heappop(a) x1 = heapq.heappop(a) for zi in z: if x1 != zi: print(x1) else: print(x2) " p02836,s609306784,Accepted,"N = input() A = N[::-1] #print(N) #print(A) cont = 0 for i in range(len(N)): if N[i] > A[i]: cont+=1 print(cont)" p03719,s818937571,Accepted,"arr = input().split() arr = list(map(int,arr)) a = int(arr[0]) b = int(arr[1]) c = int(arr[2]) if a <= c and c <= b: print('Yes') else: print('No') " p04031,s960722183,Accepted,"n = int(input()) l = list(map(int,input().split())) m = round(sum(l)/len(l)) ans = 0 for i in range(len(l)): ans += (m - l[i])**2 print(ans)" p03817,s210374422,Wrong Answer,"x = int(input()) print((x//11)*2+int(""01111122222""[x%11]))" p02695,s025982932,Wrong Answer,"def INT(): return int(input()) def MAP(): return map(int, input().split()) def LIST(): return list(map(int, input().split())) import itertools N, M, Q = MAP() a, b, c, d = [], [], [], [] for _ in range(Q): ai, bi, ci, di = MAP() a.append(ai-1); b.append(bi-1); c.append(ci); d.append(di) def solve(lst): ans = 0 for i in range(Q): if lst[b[i]] - lst[a[i]] == c[i]: ans += d[i] return ans ans = 0 for A in itertools.combinations_with_replacement(range(1, 11), N): ans = max(ans, solve(A)) print(ans)" p03448,s359713701,Accepted,"A, B, C, X = [int(input()) for x in range(4)] cnt = 0 for a in range(A+1): x = X - 500*a if x < 0: break for b in range(B+1): y = x - 100*b if y < 0: break else: if y/50 <= C: cnt += 1 print(cnt) " p03679,s818059619,Accepted,"x,a,b=map(int,input().split()) print('delicious' if b<=a else 'safe' if b<=a+x else 'dangerous') " p03605,s670470056,Accepted,"N = input() if '9' in N: print('Yes') else: print('No')" p03815,s695664096,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(): x=II() ans=x//11*2 x%=11 if x>6:ans+=2 elif x>0:ans+=1 print(ans) main()" p02691,s178821932,Accepted,"from collections import defaultdict def main(): n=int(input()) A=list(map(int,input().split())) B,C=[0]*n,[0]*n for i,a in enumerate(A): B[i]=a+i C[i]=i-a D=defaultdict(int) D[C[-1]]+=1 ans=0 for i in range(n-1)[::-1]: ans+=D[B[i]] D[C[i]]+=1 print(ans) if __name__=='__main__': main()" p02861,s044298655,Accepted,"import itertools import math N = int(input()) loc = [[int(s) for s in input().split()] for _ in range(N)] dist = [[0] * N for _ in range(N)] for i in range(N): for j in range(i + 1, N): dist[i][j] = math.sqrt((loc[i][0] - loc[j][0])** 2 + (loc[i][1] - loc[j][1])** 2) dist[j][i] = dist[i][j] d_cnt = 0 cnt = 0 for per in itertools.permutations(list(range(N)), N): for i, j in zip(per, per[1:]): d_cnt += dist[i][j] cnt += 1 print(d_cnt / cnt)" p04045,s754281694,Accepted,"import sys N, K = map(int, sys.stdin.readline().rstrip().split()) D = set(map(str, sys.stdin.readline().rstrip().split())) for i in range(N, N*10+1): price_str = str(i) for num_str in price_str: if num_str in D: break else: print(price_str) sys.exit()" p03106,s345853525,Wrong Answer,"a, b, k = map(int, input().split()) num_list = [] for i in range(1,101): if a % i == 0 & b % i == 0: num_list.append(i) # num_list.sort(reverse = True) print(num_list[-k])" p02910,s448226263,Accepted,"s=input() print(""Yes"" if all((i%2==0 and s[i] in ""RUD"") or (i%2!=0 and s[i] in ""LUD"") for i in range(len(s))) else ""No"") " p02829,s478834264,Accepted,"A=int(input()) B=int(input()) L=[1,2,3] L.remove(A) L.remove(B) print(L[0]) " p03795,s046144292,Wrong Answer,"N = int(input('整数を入力してね>')) x = (800 * N) y = (int(N/15)*200) print(x - y)" p04012,s727548163,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(map(lambda x: x%2,list(beau.values())))) if num == 0: print('YES') else: print('NO')" p03639,s051848708,Accepted,"N = int(input()) A = list(map(int,input().split())) a4 = 0 a2 = 0 a1 = 0 for a in A: if a % 4 == 0: a4 += 1 elif a % 2 == 0: a2 += 1 else: a1 += 1 if a2 == 0 and a1 <= a4 + 1: print('Yes') elif a4 >= a1: print('Yes') else: print('No')" p03073,s167913483,Accepted,"#!/usr/bin/env python3 # -*- coding: utf-8 -*- def main(): S = input() n = len(S) a = ""10"" * (n // 2) + ""1"" * (n % 2) b = ""01"" * (n // 2) + ""0"" * (n % 2) result = min(bin(int(S, 2) ^ int(a, 2)).count(""1""), bin(int(S, 2) ^ int(b, 2)).count(""1"")) print(result) if __name__ == ""__main__"": main() " p03611,s288859930,Wrong Answer,"n = int(input()) a = list(map(int, input().split())) if n == 1: print(1) else: a1 = max(a) - min(a) + 1 res = [] for i in a: res.append(i-1) res.append(i) res.append(i+1) res.sort() ans = 0 for j in range(1,a1): c = res.count(j) ans = max(ans, c) print(ans) " p03352,s274718188,Wrong Answer,"x=int(input()) a=[] for i in range(1,110): for j in range(2,100): if i**j<=x: a.append(i**j) print(a[-1])" p03408,s450105985,Accepted,"s_num=int(input()) s=[] for i in range(s_num): s.append(input()) t=[] t_num=int(input()) for i in range(t_num): t.append(input()) max=0 for i in range(s_num): if max < int(s.count(s[i]) - t.count(s[i])): max = int(s.count(s[i]) - t.count(s[i])) #print('int(s.count(s[i]) - t.count(s[i]))=',int(s.count(s[i]) - t.count(s[i]))) print(max)" p02576,s901336199,Accepted,"import collections as cc import sys import bisect as bi I=lambda:list(map(int,input().split())) n,x,t=I() print((n+x-1)//x*t)" p02645,s187355159,Accepted,"s = input() print(s[:3]) " p03351,s571985165,Wrong Answer,"a, b, c, d = map(int, input().split()) if abs(a-b)+abs(b-c) <= d*2 or abs(a-c) <= d: print('Yes') else: print('No')" p03623,s845896895,Accepted,"x,a,b=map(int,input().split()) if abs(x-a)>abs(x-b): print('B') else: print('A')" p03435,s642447036,Accepted,"c = [list(map(int, input().split())) for _ in range(3)] a = [0] * 3 b = [0] * 3 b[0] = c[0][0] for i in range(1, 3): a[i] = c[i][0] - b[0] for i in range(1, 3): b[i] = c[0][i] - a[0] for i in range(3): for j in range(3): if a[i] + b[j] != c[i][j]: print('No') exit(0) print('Yes') " p03951,s257958120,Wrong Answer,"n = int(input()) s = input() t = input() s1 = [] t1 = [] for i in range(0 , len(s)): s1.append(s[i]) for i in range(0 , len(t)): t1.append(t[i]) a = set(s1 + t1) if len(s1) == n: print(len(a)) print(a)" p02576,s937187009,Accepted,"import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii_uppercase, digits from bisect import bisect, bisect_left from heapq import heappush, heappop from functools import reduce def input(): return sys.stdin.readline().strip() def INT(): return int(input()) def MAP(): return map(int, input().split()) def LIST(): return list(map(int, input().split())) def ZIP(n): return zip(*(MAP() for _ in range(n))) sys.setrecursionlimit(10 ** 9) INF = float('inf') mod = 10 ** 9 + 7 N, X, T = MAP() print(0--N//X*T) " p03109,s120654257,Wrong Answer,"s=input().split('/') if int(s[0])<2018:print('Heisei') elif int(s[1])==2019 and int(s[2])<=4:print('Heisei') else:print('TBD')" p03774,s415373221,Accepted,"n,m=map(int,input().split()) stu=[list(map(int,input().split()))for i in range(n)] po=[list(map(int,input().split()))for i in range(m)] for i in stu: tmp=10**12 for j in po: ab=abs(i[0]-j[0])+abs(i[1]-j[1]) if ab= x: print(""Yes"") else: print(""No"")" p02618,s743310104,Wrong Answer,"def main(): D = int(input()) c = list(map(int, input().split())) last = [0] * 27 for d in range(1, D+1): s = list(map(int, input().split())) max_s = max(s) index_s = s.index(max_s) print(index_s) if __name__ == '__main__': main() " p02553,s419605770,Accepted,"a, b, c, d = map(int, input().split()) lst = [a * c, a * d, b * c, b * d] print(max(lst))" p03254,s333583700,Accepted,"#Candy Distribution Again n,x = map(int, input().split()) s= list(map(int,input().split())) s.sort() s.reverse ans=0 if s[0]>x: print(ans) else : for i in s: x=x-i if x>=0: ans+=1 else : break if x>0: ans-=1 print(ans) " p03633,s159146938,Wrong Answer,"n=int(input()) a=[int(input()) for i in range(n)] import fractions maxi=0 for i in range(n-1): x=fractions.gcd(a[i],a[i+1]) lcm=a[i]*a[i+1]/x maxi=max(maxi,lcm) print(int(maxi))" p02756,s565432385,Accepted,"s=input() n=int(input()) f=0 l="""" r="""" for i in range(n): q=input().split() if q[0]==""1"": f^=1 else: if (f==0 and q[1]==""1"") or (f==1 and q[1]==""2""): l=l+q[2] else: r=r+q[2] if f==0: ans=l[::-1]+s+r else: ans=r[::-1]+s[::-1]+l print(ans) " p02702,s352997193,Accepted,"S = input() S = S[::-1] N = len(S) cnt = [0] * 2019 mod = 2019 m = 0 cnt[0] += 1 for i in range(N): s = int(S[i]) * (pow(10, i, mod)) s %= mod m += s m %= mod cnt[m] += 1 ans = 0 for i in cnt: ans += (i * (i-1)) // 2 print(ans)" p02711,s736131272,Accepted,"n = input() if '7' in n: print(""Yes"") else: print(""No"")" p04043,s494110332,Accepted,"a=list(map(int,input().split())) if a.count(5)==2 and a.count(7)==1: print(""YES"") else: print(""NO"")" p03760,s268071169,Wrong Answer,"O = input() E = input() print(''.join(a + b for a, b in zip(O, E))) " p02727,s170294071,Accepted,"#!/usr/bin/env python3 X, Y, A, B, C = list(map(int, input().split())) p_list = list(map(int, input().split())) # 10 ** 5 q_list = list(map(int, input().split())) r_list = list(map(int, input().split())) p_list = list(sorted(p_list, reverse=True)) q_list = list(sorted(q_list, reverse=True)) # r_list = sorted(r_list, reverse=True) p_list = p_list[:X] q_list = q_list[:Y] all_list = p_list + q_list + r_list all_list = list(sorted(all_list, reverse=True)) total = sum(all_list[: X + Y]) ans = total print(ans) " p03331,s921214445,Accepted,"n = int(input()) res = 10000 for i in range(1, n // 2 + 1): s = str(i) t = str(n - i) cnt = 0 for j in s + t: cnt += int(j) res = min(res, cnt) print(res)" p02694,s662112625,Accepted,"x = int(input()) n = 100 c = 0 while n < x: n = int(n*1.01) c += 1 print(c)" p03799,s498928178,Accepted,"S, c = map(int, input().split()) if 2 * S > c: print(c // 2) exit() ans = S rest_c = c - 2 * S ans += rest_c // 4 print(ans)" p02939,s775457601,Accepted,"import sys sys.setrecursionlimit(10 ** 7) rl = sys.stdin.readline def solve(): S = input() ans = 0 ps, cs = '', '' for si in S: cs += si if cs != ps: ps = cs cs = '' ans += 1 print(ans) if __name__ == '__main__': solve() " p03986,s664892510,Wrong Answer,"X = str(input()) count= 0 count2 = 0 Nagasa = len(X) for i in range (0, len(X)): if count2 == int(Nagasa/2): print(2*count) exit() if X[i] == 'T': count+=1 count2+=1 if X[i] == 'S': count-=1 print(0)" p02747,s010362904,Accepted,"S = input() ans = 'Yes' while S: if S.startswith('hi'): S = S[2:] else: ans = 'No' break print(ans) " p03611,s108453737,Accepted,"N=int(input()) *A,=map(int, input().split()) B=[0]*(10**5+3) for a in A: a+=1 B[a-1]+=1 B[a]+=1 B[a+1]+=1 print(max(B))" p02658,s902964042,Accepted,"def main(): n = int(input()) ary = [int(i) for i in input().split()] ary = sorted(ary) if ary[0] == 0: print(0) return prod = 1 for i in reversed(range(n)): prod *= ary[i] if prod > 1000000000000000000: print(-1) return print(prod) main() " p02996,s702919195,Accepted,"N = int(input()) J = [tuple(map(int, input().split())) for _ in range(N)] J.sort(key=lambda x: (x[1], -x[0])) t = 0 for a, b in J: if t + a > b: res = 'No' break else: t += a else: res = 'Yes' print(res) " p03944,s960418078,Accepted,"W, H, N = map(int, input().split()) lstx = [[0], [W]] lsty = [[0], [H]] for i in range(N): x, y, a = map(int, input().split()) if a==1 or a==2: lstx[a-1].append(x) else: lsty[a-3].append(y) xmax = max(lstx[0]) xmin = min(lstx[1]) ymax = max(lsty[0]) ymin = min(lsty[1]) if xmax <= xmin and ymax <= ymin: print((xmax-xmin)*(ymax-ymin)) else: print(0) " p03427,s319858277,Accepted,"s = input() if s[1:].count(""9"") == len(s)-1: print(sum(map(int, s))) else: print(int(s[0])-1 + 9*(len(s)-1)) " p03345,s177658217,Accepted,"def main(): A, B, C, K = map(int, input().split()) if K%2 == 0: print(A-B) else: print(B-A) if __name__ == ""__main__"": main() " p03339,s759489259,Wrong Answer,"N = int(input()) S = list(input()) Lw = 0 Re = S[1:].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 ans = min(ans_lst) print(ans) " p03105,s169666047,Accepted,"a, b, c = map(int, input().split()) r = b//a if r >= c: print(c) else: print(r)" p02615,s870948913,Wrong Answer,"N = int(input()) AA= list(map(int,input().split())) AA.sort(reverse=True) ccurrent = AA.pop(0) conf = 0 for a in AA: conf+=ccurrent ccurrent = a print(conf)" p02833,s690731066,Accepted,"n=int(input()) if n%2 == 1: print(""0"") else: k = n//2 cnt = 1 ans = 0 while True: if k//(5**cnt) >= 1: ans += k//(5**cnt) cnt += 1 else: break print(ans)" p03773,s295754709,Accepted,"A, B = map(int, input().split()) print((A+B)%24)" p02993,s054991251,Accepted,"s = input() for i in range(len(s)-1): if s[i] == s[i+1]: print(""Bad"") exit() print(""Good"")" p03075,s294179037,Accepted,"from itertools import combinations L = [] for i in range(5): L.append(int(input())) k = int(input()) for i,j in combinations(L,2): if abs(i-j) > k: print("":("") break else: print(""Yay!"")" p04030,s940380292,Accepted,"s = input() def put_key(x,ans): if x ==""0"": return ans + ""0"" elif x== ""1"": return ans + ""1"" else: ls = list(ans) if len(ls) == 0: return ans else: ls[-1] = """" return """".join(ls) ans =str("""") for t in range(len(s)): ans = put_key(s[t],ans) print(ans)" p02663,s613838321,Accepted,"def find(H1,M1,H2,M2,K): left = H1*60+M1 right = H2*60+M2 remain = right-left-K return max(remain,0) H1,M1,H2,M2,K = list(map(int,input().strip().split())) print(find(H1,M1,H2,M2,K))" p03250,s404140275,Accepted,"a=list(map(int,input().split())) a=sorted(a,reverse=True) print(a[0]*10+a[1]+a[2])" p02659,s495669122,Accepted,"import math A,B = input().split() A = int(A) B = float(B) B = round(B*1000) B = int(B) print(math.floor(A*B//1000))" p03437,s680203088,Accepted,"from math import gcd X, Y = map(int, input().split()) l = X * Y // gcd(X, Y) if l == X: print(-1) else: print(X) " p02952,s048878341,Accepted,"n = int(input()) cnt = 0 for i in range(1,n+1): if len(str(i)) % 2 != 0: cnt += 1 print(cnt)" p02833,s616389340,Accepted,"n = int(input()) if n%2 == 1: print(0) else: ans = 0 cnt = 1 while n>=(5**cnt): ans += n//(5**cnt)//2 cnt += 1 print(ans)" p03077,s230327853,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() import numpy as np def main(): n=II() A=[II() for _ in range(5)] ans=0 for i in A: ans=max(ans,(n-1)//i) ans+=5 print(ans) if __name__ == ""__main__"": main() " p02624,s418618483,Wrong Answer,"N = int(input()) RL = [0] * (10 ** 7 + 10) for i in range(1, 10 ** 7 + 10): RL[i] = RL[i-1] + i print(""step"") ans = 0 for i in range(1, N+1): a = N // i #print(i, a) ans += RL[a] * i print(ans)" p03417,s376284122,Wrong Answer,"n,m = map(int,input().split()) n-=2 m-=2 print(n*m)" p02756,s475841419,Accepted,"string = input() N=int(input()) Que = [] for i in range(N): Que.append(input()) init = """" end = """" rev = 2 for Q in Que: if int(Q[0]) == 1: if rev != 1: rev=1 else: rev=2 elif int(Q[0])==2: T,F,C = Q.split(' ') if rev == 1: if int(F) == 1: F =2 else: F = 1 if int(F) == 1: init = init+C elif int(F) == 2: end = end + C final = init[-1::-1]+string+end if rev == 1: print(final[-1::-1]) else: print(init[-1::-1]+string+end) " p03639,s376468955,Accepted,"n = int(input()) a = list(map(int, input().split())) f, t = 0, 0 for i in a: if i % 4 == 0: f += 1 elif i % 2 == 0: t += 1 print('Yes' if f*2 + t >= n or n // 2 <= f else 'No')" p03243,s086075653,Accepted,"n = int(input()) for i in range(n,1000): if i % 111 == 0: print(i) break" p02713,s732351619,Accepted,"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(int(gcd)) " p02642,s861940736,Accepted,"N = int(input()) a = list(map(int, input().split())) cnt = {} for item in a: if item not in cnt: cnt[item] = 0 cnt[item] += 1 A = list(set(a)) candidate = [] for item in A: if cnt[item] == 1: candidate.append(item) judge = [True] *(10**6 + 1) for item in A: for i in range(2, ((10**6)//item) + 1): judge[item*i] = False ans = 0 for item in candidate: if judge[item]: ans += 1 print(ans)" p03338,s152120235,Accepted,"n = int(input()) s = list(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""] ans = 0 for i in range(1, n): x = s[0 : i] y = s[i : n] c = 0 for j in alph: if j in x and j in y: c += 1 if ans < c: ans = c print(ans)" p03705,s561200269,Accepted,"import itertools n, a, b = map(int, input().split()) if a > b: print(0) exit() if a != b and n == 1: print(0) exit() print((b-a)*(n-2)+1) " p02603,s528914220,Accepted,"from sys import stdin nii=lambda:map(int,stdin.readline().split()) lnii=lambda:list(map(int,stdin.readline().split())) n=int(input()) a=lnii() money=1000 kabu=0 for i in range(n-1): if a[i]a[i+1]: money+=kabu*a[i] kabu=0 money+=kabu*a[n-1] print(money)" p03254,s869903185,Accepted,"N, X = map(int,input().split()) S = map(int,input().split()) S = sorted(S) cnt = 0 for s in S: X -= s if X >= 0: cnt += 1 else: break if X > 0: cnt -= 1 print(cnt) " p02780,s395464815,Accepted,"from copy import copy N,K = map(int, input().split()) p=list(map(int, input().split())) expP = [(1+i)/2 for i in p] id_H = N-K id_T = N minus = sum(expP[:id_H]) minimum = minus for i in range(id_H): minus -= expP[id_H - i -1] minus += expP[id_T - i -1] if minus < minimum: minimum = copy(minus) ans = sum(expP) - minimum print(ans)" p04019,s564642404,Accepted,"from collections import Counter def main(): S = list(input()) c = Counter(S) if ((c[""N""] == 0 and c[""S""] == 0) or (c[""N""] > 0 and c[""S""] > 0)) and ((c[""W""] == 0 and c[""E""] == 0) or (c[""W""] > 0 and c[""E""] > 0)): print(""Yes"") else: print(""No"") if __name__ == '__main__': main()" p03695,s391985370,Wrong Answer,"N = int(input()) A = list(map(int, input().split())) C = [0] * 9 for a in A: C[min(8, a//400)] += 1 s = sum([c > 0 for c in C[:-1]]) print(C) print(max(s, 1), s + C[-1]) " p02754,s197340878,Accepted,"N, A, B = map(int, input().split()) answer = N // (A + B) * A if N % (A + B) <= A: answer += N % (A + B) else: answer += A print(answer)" p03126,s740783104,Accepted,"N, M = map(int, input().split()) a = [N]*M for i in range(N): A = list(map(int, input().split()))[1:] for j in A: a[j-1] -= 1 count = 0 for i in a: if i == 0: count += 1 print(count)" p02982,s935095163,Accepted,"import math import itertools N,D= map(int,input().split()) X = [] count=0 for x in range(N): X.append(list(map(int,input().split()))) listArray = list(itertools.combinations(X, 2)) for X in listArray: sumX = 0 for x in range(D): subX = X[0][x] - X[1][x] sumX += subX**2 if math.sqrt(sumX).is_integer(): count += 1 print(count) " p02676,s462136030,Accepted,"k = int(input()) s = input() print(s if len(s) <= k else s[:k] + ""..."")" p02797,s614022178,Accepted,"import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N,K,S = map(int,read().split()) if S > N: A = [S] * K + [1] * (N-K) else: A = [S] * K + [S+1] * (N-K) print(*A) " p02676,s183400773,Accepted,"K = int(input()) S = input() if len(S) <= K: print(S) else: print(S[:K]+""..."")" p03693,s024643880,Accepted,"r, g, b = map(int, input().split()) num = int(str(r)+str(g)+str(b)) if num %4 == 0: print('YES') else: print('NO') " p03163,s088199212,Accepted,"# PyPy3 N, W = map(int, input().split()) dp = [[0]*(W+1) for _ in range(N+1)] def npsk_1(N, W): for i in range(N): w, v = map(int, input().split()) for j in range(W+1): if j >= w: dp[i+1][j] = max(dp[i][j], dp[i][j - w] + v) else: dp[i+1][j] = dp[i][j] print(dp[N][W]) npsk_1(N, W)" p02732,s753468971,Accepted,"N = int(input()) A = list(map(int,input().split())) B = [0]*(N+1) for a in A: B[a]+=1 C = [0]*(N+1) for i in range(N+1): C[i] = (B[i]-1)*B[i]//2 S = sum(C) for k in range(N): s = A[k] ans = S-C[s] b = B[s]-1 print(ans+(b-1)*b//2) " p02811,s876121791,Wrong Answer,"K, X = input().split() if 500 * K >= X: print(""Yes"") elif 500 * K < X: print(""No"")" p02732,s823880915,Accepted,"n = int(input()) a = list(map(int,input().split())) d = {} ans = 0 for i in a: d[i] = d.get(i,0) + 1 for key in d: ans += d[key]*(d[key]-1)//2 for i in a: print(ans + 1 - d[i])" p03861,s323625169,Wrong Answer,"a, b, x = map(int, input().split()) diff = b-a ans = diff // x if a % x == 0: ans += 1 print(ans) " p02996,s646986994,Accepted,"N=int(input()) l=[] for i in range(N): l.append(list(map(int,input().split()))) L=sorted(l,key=lambda x:x[1]) time=0 error=0 for j in range(N): time += L[j][0] if time > L[j][1]: error += 1 if error >0: print('No') else: print('Yes')" p02836,s358475328,Accepted,"S = input() right = S[-len(S) // 2:][::-1] print(len(S) // 2 - sum(S[i]==right[i] for i in range(len(S) // 2)))" p03760,s891287228,Wrong Answer,"a = list(input()) b = list(input()) for x,y in zip(a,b): print(x+y, end = """")" p02952,s353174951,Accepted,"n=int(input()) cnt=0 def digit(k): ret=0 while k!=0: k//=10 ret+=1 return ret for i in range(n): if digit(i+1)%2==1: cnt+=1 print(cnt)" p02951,s577841347,Accepted,"A,B,C=map(int,input().split()) X=min(C,A-B) print(C-X)" p02594,s722275542,Accepted,print('YNeos'[int(input())<30::2]) p03067,s619991292,Accepted,"a,b,c=map(int,input().split()) a,b = min(a,b),max(a,b) if c in range(a,b+1): print('Yes') else: print('No')" p03814,s288854809,Wrong Answer,"S = input() st = 0 en = 0 for i in range(len(S)): if S[i] == ""A"" and st == 0: st = i if S[i] == ""Z"": en = i print(en - st + 1)" p02814,s515282706,Wrong Answer,"N, M = map(int, input().split()) A = list(set(map(int, input().split()))) #print(A) while not any(a % 2 for a in A): A = [a // 2 for a in A] #print(A) #print(all(a % 2 for a in A)) if not all(a % 2 for a in A): print(0) exit() #print(1) def gcd(a, b): while b: a, b = b, a % b return a def lcm(a, b): return a * b // gcd(a, b) ans = 1 for i in A: ans = lcm(ans, i) #print(ans) print((M // ans + 1) // 2)" p02814,s930639289,Accepted,"from fractions import gcd n,m = map(int, input().split()) a = list(map(int, input().split())) b = [] lcm = 1 for i in a: b.append(i//2) for i in b: lcm = lcm // gcd(lcm,i) * i ans = m // lcm sum = 0 for i in b: if (lcm // i) % 2 == 1: sum += 1 if sum != len(a): print(0) elif ans%2 ==1: print((ans+1)//2) else: print(ans//2)" p02987,s708983140,Accepted,"s = input() l = [s[0], s[1], s[2], s[3]] l.sort() if l[0] == l[1] != l[2] == l[3]: print('Yes') else: print('No')" p02682,s195734231,Accepted,"a,b,c,k = map(int, input().split()) if a>=k: print(k) elif a=k: print(a) else : print(2*a+b-k)" p02601,s315962628,Accepted,"a, b, c, k = map(int, open(0).read().split()) for i in range(k): if a >= b: b *= 2 continue if b >= c: c *= 2 if a < b < c: print('Yes') else: print('No') " p02859,s398851575,Accepted,print(int((input()))**2) p03493,s173810570,Wrong Answer,"s=input() c=1 for i in range(0,3): if s[i]==1: c+=1 print(c)" p03860,s133338119,Wrong Answer,"a,b,c=map(str,input().split()) print('A'+b.lower()+'C')" p03624,s322141185,Accepted,"s = input() alp = ""abcdefghijklmnopqrstuvwxyz"" for i in alp: if i not in s: print (i) exit() print (""None"")" p03557,s394625476,Accepted,"import bisect n = int(input()) A = sorted(map(int, input().split())) B = sorted(map(int, input().split())) C = sorted(map(int, input().split())) ans = 0 for b in B: a_ind = bisect.bisect_left(A, b) c_ind = bisect.bisect_right(C, b) ans += a_ind*(n-c_ind) print(ans)" p02639,s843117598,Accepted,"a = [int(e) for e in input().split()] for i in range(len(a)): if a[i] == 0: print(i+1) break" p03377,s485242198,Accepted,"a,b,x = map(int,input().split()) if a > x : print('NO') elif x-a <= b: print('YES') else: print('NO')" p02641,s630805403,Accepted,"import sys def input(): return sys.stdin.readline().strip() def main(): x, n= map(int, input().split()) if n == 0: print(x) return P=[] P = list(map(int, input().split())) for i in range(100): a = x-i b = x+i if a not in P: print(a) return elif b not in P: print(b) return main() " p02729,s914458363,Accepted,"a,b=map(int,input().split()) c=(a*(a-1)+b*(b-1))//2 print(c)" p03543,s564584621,Wrong Answer,"N = input() if N[0] == N[-1]: print('Yes') else: print('No') " p02633,s185684361,Accepted,"ni = lambda: int(input()) nm = lambda: map(int, input().split()) nl = lambda: list(map(int, input().split())) import math d=ni() x=0 y=1 cnt=0 dd=0 while True: cnt+=1 dd=(dd+d)%360 r = math.radians(dd) x += math.sin(r) y += math.cos(r) # print(""{}, {}"".format(x,y)) if abs(x)<10**(-10) and abs(y)<10**(-10): break print(cnt+1) " p03836,s741742769,Wrong Answer,"sx, sy, tx, ty = map(int, input().split()) dx = tx - sx dy = ty - sy ans = '' ans += 'U' * dx ans += 'R' * dy ans += 'D' * dx ans += 'L' * dy ans += 'L' ans += 'U' * (dx + 1) ans += 'R' * (dy + 1) ans += 'D' ans += 'R' ans += 'D' * (dx + 1) ans += 'L' * (dy + 1) ans += 'U' print(ans)" p03632,s306461007,Accepted,"A, B, C, D = map(int, input().split()) print(max(0, min(B, D) - max(A, C))) " p03475,s998483266,Wrong Answer,"n = int(input()) cost = [0]*n start = [0]*n freaq = [0]*n dp = [[0]*n for _ in range(n)] for i in range(n-1): cost[i],start[i],freaq[i] = map(int,input().split()) dp[i][i] = start[i] freaq[n-1] = 1 t = 0 for i in range(n-1): for j in range(i+1): t = dp[j][i] t += cost[i] t += t%freaq[i+1] t = max(t,start[i+1]) dp[j][i+1] = t for i in range(n): print(dp[i][n-1]) " p03799,s934570708,Accepted,"N,M=map(int,input().split()) if M>=N*2: M-=N*2 N+=M//4 print(N) else: print(M//2) " p02779,s943255425,Accepted,"N = int(input()) A = map(int,input().split()) B = set(A) if N == len(B): print(""YES"") else: print(""NO"")" p02688,s184571827,Accepted,"N, K = map(int, input().split()) result = [0] * N for k in range(K): d = int(input()) A = list(map(int, input().split())) for a in A: result[a-1] = 1 A.clear() print(result.count(0)) " p03672,s835923952,Accepted,"S=input() i=1 while i= r: print('OK') else: print('NG')" p03329,s278195011,Accepted,"N=int(input()) ans=N for i in range(N+1): cnt=0 t=i while t>0: cnt+=t%6 t//=6 j=N-i while j>0: cnt+=j%9 j//=9 ans = min(ans,cnt) print(ans)" p03069,s651873207,Accepted,"import sys def input(): return sys.stdin.readline().strip() sys.setrecursionlimit(20000000) MOD = 10 ** 9 + 7 INF = float(""inf"") def main(): N = int(input()) S = list(input()) numb = 0 numw = S.count(""."") answer = numb + numw for i in range(N): if S[i] == ""#"": numb += 1 else: numw -= 1 if answer > numb + numw: answer = numb + numw print(answer) if __name__ == ""__main__"": main() " p03206,s335251749,Accepted,"n = int(input()) if n == 25: print(""Christmas"") elif n == 24: print(""Christmas Eve"") elif n == 23: print(""Christmas Eve Eve"") else: print(""Christmas Eve Eve Eve"")" p03759,s738078675,Accepted,"a,b,c=map(int,input().split()) if a-b == b-c: print(""YES"") else: print(""NO"")" p03339,s835254151,Wrong Answer,"N = int(input()) S = input() oE = S.count(""E"") Wo = 0 L = [] for i in range(N): if i == 0: if S[i] == ""E"": oE -= 1 else: if S[i-1] == ""W"": Wo += 1 if S[i] == ""E"": oE -= 1 L.append(Wo + oE) if Wo + oE == 1: break print(L)" p03548,s328066275,Wrong Answer,"X, Y, Z = map(int, input().split()) print(X//(Z+Y))" p03286,s121472397,Wrong Answer,"N = int(input()) div = 2 ans = [] while N // 2 > 0: ans.append(N % 2) N //= 2 ans.reverse() print("""".join(map(lambda x: str(x), ans)))" p03971,s532914211,Accepted,"n,a,b = map(int,input().split()) s = list(input()) cap = a+b for i in s: if i == 'a' and cap > 0: print('Yes') cap -= 1 elif i == 'b' and cap > 0 and b > 0: print('Yes') cap -= 1 b -= 1 else: print('No') " p02912,s556391599,Wrong Answer,"from math import log2 from heapq import heappop, heapify, heappush def main(): n, m = list(map(int, input().split())) A = list(map(int, input().split())) A = [-log2(a) for a in A] heapify(A) for _ in range(m): a = heappop(A) a += 1 heappush(A, a) print(sum([int(pow(2, -a)) for a in A if a <= 0])) if __name__ == '__main__': main() " p03449,s500246938,Wrong Answer,"N = int(input()) candies_i = list(map(int, input().split())) candies_j = list(map(int, input().split())) l = [] for i in range(N): total_li = sum(candies_i[i:]) total_lj = sum(candies_j[:i+1]) total = total_li + total_lj l.append(total) print(max(l)) " p02607,s655542991,Accepted,"n = int(input()) a = list(map(int,input().split())) ans = 0 for i in range(n): if (i+1)%2 == 1 and a[i]%2 ==1: ans += 1 print(ans)" p03103,s773851639,Accepted,"N, M = list(map(int, input().split())) d = [list(map(int, input().split())) for _ in range(N)] ans = 0 d.sort() for i in d: if i[1] <= M: ans += i[0] * i[1] M -= i[1] if M == 0: break else: ans += i[0] * M break print(ans)" p02690,s323317183,Accepted,"def solve(string): x = int(string) a = {i**5: i for i in range(-10000, 10000)} for i in range(-10000, 10000): if x + i ** 5 in a: return str(f""{a[x+i**5]} {i}"") if __name__ == '__main__': import sys print(solve(sys.stdin.read().strip())) " p03380,s619200692,Wrong Answer,"n = int(input()) a = list(map(int,input().split())) d = max(a) f = d for v in a: if abs(v-d/2) < abs(f-d/2): f = v print(d,f)" p03565,s308565938,Accepted,"s = input() t = input() ans = 'UNRESTORABLE' for i in range(len(s)-len(t), -1, -1): valid = True for j in range(len(t)): if s[i+j] != '?' and s[i+j] != t[j]: break else: ans = (s[:i] + t + s[i+len(t):]).replace('?', 'a') break print(ans)" p03455,s204516299,Accepted,"a, b = map(int, input().split()) ab = a * b if ab % 2: print('Odd') else: print('Even')" p02612,s791658670,Wrong Answer,"N = int(input()) print((N // 1000 + 1) * 1000 - N) " p02647,s752996503,Accepted,"import sys readline = sys.stdin.readline N, K = map(int, readline().split()) A = list(map(int, readline().split())) K = min(100, K) while K: K -= 1 table = [0]*(N+1) for i in range(N): a = A[i] table[max(0, i-a)] += 1 table[min(N, i+a+1)] -= 1 for i in range(1, N): table[i] += table[i-1] A = table[:-1] print(*A)" p02676,s244506936,Accepted,"k = int(input()) s = list(input()) print("""".join(s[:k]) + (""..."" if len(s) > k else """")) " p02972,s318356263,Accepted,"N = int(input()) b = list(map(int,input().split())) box = [0 for i in range(N)] for i in range(N-1,-1,-1): rest = 0 for j in range(2 * (i+1),N+1,i+1): rest += box[j-1] box[i] = (b[i] - rest)%2 print(sum(box)) if sum(box): for idx,i in enumerate(box): if i == 1: print(idx+1)" p02687,s577069581,Wrong Answer,"print(""ARC"")" p03017,s068493492,Wrong Answer,"import sys n, a, b, c, d = map(int, input().split()) s = input() if c > d: s = s[:d-1] + '#' + s[d:] count1, count2 = 0, 0 for i in range(a-1, c): if count1 == 3: print('Yes') sys.exit() elif count2 == 2: print('No') sys.exit() elif s[i] == '#': count2 += 1 count1 = 0 elif s[i] == '.': count1 += 1 count2 = 0 print('Yes') " p02600,s813318876,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) elif n <2000: print(1)" p02787,s583743684,Accepted,"import sys sys.setrecursionlimit(10**5) h,n=map(int,input().split()) magic=[] for i in range(n): magic.append(tuple(map(int,input().split()))) memo={} def d(hp): if hp<=0: return 0 if hp in memo: return memo[hp] mn=10**10 for i in magic: mn=min(mn,d(hp-i[0])+i[1]) memo[hp]=mn return mn for i in range(1,h-1): d(i) print(d(h))" p03997,s705802386,Wrong Answer,"a = int(input()) b = int(input()) c = int(input()) d = 0 d = a + b d = d * c / 2 print(d)" p03073,s078894594,Accepted,"s = input() n = len(s) count = 0 for i in range(n): if (i & 1) ^ int(s[i]): count += 1 print(min(count,n-count))" p02862,s106421020,Accepted,"x,y = map(int,input().split()) m = 10**9+7 if not((x+y)%3== 0 and abs(x-y)<=(x+y)//3): print(0);exit() def comb(n,k): #if 2 * k > n: #k = n - k a = 1 for i in range(1,k+1): a *= (n - ( i - 1)) * pow(i,m-2,m) a = a%m return a n = (x+y)//3 k = x-n print(comb(n,k)) " p02547,s928785145,Accepted,"n=int(input()) m=0 l=0 for i in range(n): A,B=map(int,input().split()) if (A==B): m+=1 else: m=0 if (m==3): print(""Yes"") l=1 break if (l==0): print(""No"")" p03071,s604070549,Accepted,"def main(): A, B = map(int, input().split("" "")) L = [] L.append(A) L.append(B) L.append(A - 1) L.append(B - 1) L.sort(reverse=True) print(L[0] + L[1]) if __name__ == '__main__': main()" p02702,s543391365,Accepted,"def main(): S = list(input()) N = len(S) t = 0 A = [0] * 2019 A[0] += 1 d = 1 for s in reversed(S): d *= 10 d %= 2019 t += (int(s) * d) t %= 2019 A[t] += 1 result = sum([a*(a-1)//2 for a in A]) print(result) if __name__ == '__main__': main() " p03000,s729462711,Accepted,"N,X = map(int, input().split()) L = list(map(int, input().split())) cnt=1 d=0 for i in range(N): if d+L[i]<=X: cnt+=1 d=d+L[i] else: break print(cnt)" p03986,s061167473,Accepted,"import sys def input(): return sys.stdin.readline().strip() sys.setrecursionlimit(10 ** 9) def main(): X = input() answer = 0 cnt_s = 0 for x in X: if x == ""S"": cnt_s += 1 continue if cnt_s > 0: cnt_s -= 1 else: answer += 1 answer += cnt_s print(answer) if __name__ == ""__main__"": main() " p02797,s127393429,Accepted,"N, K, S = map(int, input().split()) if S == 1e9: ans = [S] * K + [1] * (N - K) else: ans = [S] * K + [S + 1] * (N - K) print(*ans)" p03076,s484763442,Wrong Answer,"import math x=0 y=9 for _ in range(5): i=int(input()) x+=math.ceil(i/10)*10 if i%100 and b>0: ans='Positive' elif abs(a-b)%2!=0 : ans='Positive' else: ans='Negative' print(ans)" p03162,s885133245,Wrong Answer,"n=int(input()) A=[] for i in range(n): A.append(list(map(int,input().split()))) prev=-100000 sum=0 tick=-10000000 for i in range(len(A)): max=0 print(""**"",prev) for j in range(len(A[i])): if(j!=tick and max= fix: fix *= 2 print(fix - 1)" p03971,s164205798,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): 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') " p03699,s942124914,Wrong Answer,"# Problem C - Bugged # input N = int(input()) # initialization max_score = 0 score_list = [] for i in range(N): tmp = int(input()) score_list.append(tmp) score_list = sorted(score_list, reverse=True) # score update min_score = 10**4 + 1 for score in score_list: max_score += score if tmp%10!=0 and min_score>score: min_score = score # output ans = 0 if max_score%10==0: ans = max(0, max_score-min_score) print(ans) " p03835,s800469171,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) " p02879,s087569332,Wrong Answer,"a, b = map(int, input().split()) if a * b > 81: print(-1) else: print(a*b)" p03407,s310857314,Accepted,"A, B, C = map(int, input().split()) print('No' if A + B < C else 'Yes')" p03773,s783212468,Accepted,"N, K = map(int, input().split()) print((N + K) % 24)" p02842,s468477905,Accepted,"import math n = int(input()) flag = False for i in range(1,n+1000): if math.floor(i*1.08) == n: flag = True ans = i break if flag: print(ans) else: print("":("") " p02623,s088961515,Accepted,"import bisect N, M, K = map(int,input().split()) A = list(map(int,input().split())) B = list(map(int,input().split())) S = [0]*N T = [0]*M S[0] = A[0] for k in range(1,N): S[k] = S[k-1] + A[k] T[0] = B[0] for k in range(1,M): T[k] = T[k-1] + B[k] ans = bisect.bisect_right(T,K) for k in range(N): if K-S[k] >= 0: ans = max(ans,k+1+bisect.bisect_right(T,K-S[k])) print(ans) " p02699,s133232923,Accepted,"S,W = map(int,input().split()) if S <= W: print('unsafe') else: print('safe')" p03545,s006365081,Accepted,"A,B,C,D = map(int,list(input())) dic = { 1:""+"" , -1:""-""} import itertools for AB,BC,CD in itertools.product([1,-1],repeat=3): tmp = A + B*AB + C*BC + D*CD if tmp ==7: ans = str(A)+dic[AB]+str(B)+dic[BC]+str(C)+dic[CD]+str(D)+""=7"" print(ans) exit()" p02935,s050813869,Accepted,"n = int(input()) v = list(map(int,input().split())) for i in range(n-1):v.sort();v.append((v[0]+v[1])/2);del v[:2] print(v[0])" p02683,s062062995,Wrong Answer,"import numpy N,M,X = map(int,input().split()) A = numpy.array([[int(i) for i in input().split()] for _ in range(N)]) ans = 10**6 for i in range(2**N) : i = format(i,'b').zfill(N) s = 0 check = numpy.array([0]*(M+1)) for j in range(N) : if i[j] == '0' : continue check += A[j][0:] if all (check[m] >= X for m in range(1,M+1)) : ans = min(ans,check[0]) if ans == 10**6 : print(-1) else : print(ans)" p03971,s756744768,Accepted,"n, a, b = map(int, input().split()) s = input() a_reviewed = 0 b_reviewed = 0 for x in s: if a_reviewed + b_reviewed < a + b: if x == 'a': print('Yes') a_reviewed += 1 elif x == 'b' and b_reviewed < b: print('Yes') b_reviewed += 1 else: print('No') else: print('No')" p04020,s949108148,Wrong Answer,"N = int(input()) cnt = 0 tmp = 0 for i in range(N): a = int(input()) cnt += a//2 tmp2 = a%2 if tmp2*tmp: cnt +=1 tmp = 0 else: tmp = tmp2 print(cnt) " p02623,s794823973,Accepted,"n, m, k = map(int, input().split()) an = list(map(int, input().split())) bn = list(map(int, input().split())) a_sum = [0] b_sum = [0] for i in range(1, n+1): a_sum.append(a_sum[i-1] + an[i-1]) for j in range(1, m+1): b_sum.append(b_sum[j-1] + bn[j-1]) idx = len(bn) ans = 0 for i in range(n+1): while a_sum[i] + b_sum[idx] > k: idx -= 1 if idx == -1: break if idx == -1: break ans = max(ans, i + idx) print(ans) " p02627,s914743689,Accepted,"a = input() print('A' if a.isupper() else 'a') " p02790,s084848936,Accepted,"a, b = input().split() if a= 0 else 0))" p02583,s150743231,Wrong Answer,"n = int(input()) l = list(map(int, input().split())) ans = 0 l.sort(reverse = True) print(l) for i in range(n): for j in range(n): for k in range(n): if l[i] == l[j] or l[i] == l[k] or l[j] == l[k]: continue elif l[i] < l[j] + l[k]: ans += 1 print(ans // 6)" p02742,s383250363,Accepted,"H, W = map(int, input().split()) if H == 1 or W == 1: ans = 1 else: if (H*W)%2 == 0: ans = int((H*W)/2) else: ans = int((H*W+1)/2) print(ans)" p02811,s316382012,Accepted,"k,x=map(int,input().split()) if(k*500>=x): print('Yes') else: print('No')" p04011,s937195984,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) " p02646,s866315866,Accepted,"a, v = map(int, input().split()) b, w = map(int, input().split()) t = int(input()) x = a - b if x < 0: x = -x if v > w and (v - w) * t >= x: print(""YES"") else: print(""NO"") " p02693,s609393254,Accepted,"K = int(input()) A, B = map(int, input().split("" "")) possible = False for i in range(A, B + 1): # print(i) if i % K == 0: possible = True if possible: print(""OK"") else: print(""NG"")" p02572,s809218802,Accepted,"N = int(input()) MOD = 10**9 + 7 A_s = list(map(int, input().split())) ruiseki = [] for i, A in enumerate(A_s): if i == 0: ruiseki.append(A) continue ruiseki.append(ruiseki[i-1]+A) answer = 0 for i, r in enumerate(ruiseki): answer += (A_s[i] * (ruiseki[N-1]-ruiseki[i])) answer %= MOD print(answer)" p02933,s020062815,Accepted,"a=int(input()) s=input() if a>=3200: print(s) else: print(""red"")" p02683,s265077429,Accepted,"n,m,x = map(int, input().split()) c = [list(map(int, input().split())) for _ in range(n)] ans = float(""inf"") for i in range(1 << n): money = 0 skill = [0]*m for j in range(n): if ((i >> j) & 1) == 1: money += c[j][0] for k in range(1,m+1): skill[k-1] += c[j][k] if all(l >= x for l in skill): ans = min(ans,money) print(-1 if ans==float(""inf"") else ans)" p03380,s993401964,Accepted,"import bisect n = int(input()) a = list(map(int,input().split())) a.sort() m = 0 ans = [] for i in a: R = i / 2 p = bisect.bisect_left(a,R) if p == 0: r = a[p] else: r = a[p] if abs(a[p] - R) < abs(a[p - 1] - R) else a[p - 1] if m < i + min(r,i - r): m = i + min(r,i - r) ans = [i,r] print(*ans)" p04044,s460978234,Accepted,"n, l = map(int, input().split()) sl = [] for i in range(n): s = input() sl.append(s) sl.sort() #print(sl) ans = """" for i in range(n): ans += sl[i] print(ans)" p02983,s846493134,Accepted,"L, R = map(int, input().split()) if R - L >= 2019: print(0) exit() ans = 2019 for i in range(L, R+1): for j in range(i+1, R+1): ans = min(ans, (i*j)%2019) print(ans)" p03617,s781086803,Wrong Answer,"import sys def solve(): input = sys.stdin.readline Q, H, S, D = map(int, input().split()) N = int(input()) Q *= 4 H *= 2 D /= 2 if N % 2 == 0: print(int(min([Q, H, S, D]) * N)) else: sub = int(min([Q, H, S, D]) * (N - 1)) print(sub + min([Q, H, S])) return 0 if __name__ == ""__main__"": solve()" p02923,s028716554,Accepted,"n = int(input()) h = list(map(int, input().split())) ans = 0 m = 0 for i in range(n-1): if h[i] >= h[i+1]: m += 1 ans = max(ans, m) else: ans = max(ans, m) m = 0 print(ans)" p03239,s274756893,Accepted,"N, T = map(int, input().split()) routes = [tuple(map(int, input().split())) for _ in range(N)] ans = [c for c, t in routes if t <= T] if len(ans): print(min(ans)) else: print(""TLE"") " p02691,s407722929,Accepted,"N = int(input()) A = list(map(int, input().split())) B = [i-A[i] for i in range(N)] C = [i+A[i] for i in range(N)] B.sort() C.sort() j = 0 ct = 0 cashe = 0 for i in range(N): if i >= 1 and B[i-1] == B[i]: ct += cashe else: cashe = 0 while C[j] <= B[i]: if C[j] == B[i]: ct += 1 cashe += 1 j += 1 print(ct) " p02900,s914441323,Wrong Answer,"a,b = map(int, input().split()) def gcd(a,b): m,n = max(a,b),min(a,b) r = n while r > 0: n = r r = m%n m = n return n def factorization(n): arr = {1} tmp = n for i in range(2,int(-(-10**0.5//1))): if tmp%i == 0: arr.add(i) while tmp%i == 0: tmp //= i if tmp != 1: arr.add(tmp) if arr == []: arr.add(n) return arr g = gcd(a,b) arr = factorization(g) print(len(arr))" p03043,s567768108,Accepted,"n,k = map(int, input().split()) ans = 0 for i in range(1,n+1): t = 0 while i < k: i *= 2 t += 1 ans += 0.5**t print(ans/n)" p03448,s293399420,Accepted,"A = int(input()) B = int(input()) C = int(input()) X = int(input()) case = 0 for a in range(A+1): for b in range(B+1): for c in range(C+1): if a*500 + b * 100 + c * 50 == X: case+=1 print(case)" p02708,s505730085,Accepted,"mod=pow(10,9)+7 n,k=map(int,input().split()) mini,maxi=-1,-1 ranges=[[0,0]] ans=0 for i in range(k,n+2): mini=(i*(i-1))//2 maxi=((i)*(n+n-i+1))//2 ans += (maxi-mini+1)%mod ans=ans%mod print(ans)" p02623,s384279087,Accepted,"N, M, K = map(int, input().split()) A = [0]+list(map(int, input().split())) B = [0]+list(map(int, input().split())) import itertools A_cs = list(itertools.accumulate(A)) B_cs = list(itertools.accumulate(B)) total = 0 j = len(B)-1 for i in range(len(A_cs)): while (j >= 0): if A_cs[i] + B_cs[j] <= K: total = max(total,i + j) break j -= 1 print(total) " p03644,s683070502,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 = int(readline()) for n in range(N, 0, -1): m = n while m % 2 == 0: m //= 2 if m == 1: ans = n break print(ans) return if __name__ == '__main__': main() " p03417,s796438842,Accepted,"N,M=map(int,input().split()) print(1 if N==1 and M==1 else max(N,M)-2 if N==1 or M==1 else N*M-2*N-2*M+4)" p02795,s306584579,Accepted,"h = int(input()) w = int(input()) n = int(input()) write = 0 result = 0 while write < n: if w > h: write += w h -= 1 else: write += h w -= 1 result += 1 print(result)" p02646,s871473931,Accepted,"a,v=(int(x) for x in input().split()) b,w=(int(x) for x in input().split()) t = int(input()) distance = abs(a-b) sa = v - w if distance <= t*sa: print('YES') else: print('NO')" p03323,s596697106,Accepted,"a,b=map(int,input().split()) if a<=8 and b<=8: print(""Yay!"") else: print("":("") " p02577,s995101335,Accepted,"N = int(input()) if N % 9 == 0: print(""Yes"") else: print(""No"") " p04031,s877869652,Accepted,"n=int(input()) a = list(map(int,input().split())) ans = 10**7 for i in range(102): p = 0 m = 0 for j, aa in enumerate(a): p += (aa-i)**2 m += (aa+i)**2 ans = min(ans,p,m) print(ans) " p02747,s962016664,Accepted,"S = input() if len(S)%2==0 and S=='hi'*(len(S)//2): print('Yes') else: print('No')" p03327,s998471887,Accepted,"n = int(input()) if n < 1000: print('ABC') else: print('ABD')" p03951,s056839613,Accepted,"n = int(input()) s = input() t = input() num = 0 for i in range(1, n+1): if s[-i:] == t[:i]: num = i print(n*2 - num)" p03474,s306319124,Accepted,"import sys def LI(): return list(map(int, input().split())) A, B = LI() S = input() ans = ""Yes"" for i in range(A): if S[i] == ""-"": ans = ""No"" break if S[A] != ""-"": ans = ""No"" for i in range(A+1, A+B+1): if S[i] == ""-"": ans = ""No"" break print(ans) " p03380,s873340499,Accepted,"n = int(input()) a = list(map(int, input().split())) x = max(a) half = x/2 y = sorted([ai for ai in a if ai < x], key=lambda x: abs(half-x))[0] print(""{} {}"".format(x,y))" p02880,s594374657,Accepted,"N = int(input()) def judge(N): for i in range(1, 10): for j in range(1, 10): if i * j == N: return ""Yes"" return ""No"" print(judge(N))" p03814,s878931708,Accepted,"S=input() A=S.index(""A"") Z=S[::-1].index(""Z"") print(len(S)-(A+Z)) " p02595,s811121926,Accepted,"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) ans=0 for i in range(N): if X[i]**2+Y[i]**2 <= D**2: ans += 1 print(ans) " p03254,s720460985,Accepted,"N,x = map(int, input().split()) a = list(map(int, input().split())) a.sort() A = sum(a) if x > A: print(N-1) else: cnt = 0 for i in range(N): if x >= a[i]: x -=a[i] cnt += 1 print(cnt)" p03680,s695609052,Wrong Answer,"N = int(input()) A = [(i+1, int(input())) for i in range(N)] cnt = 1 for i in range(N): if 2 not in A[i]: print(-1) exit() x = A[0] while x[1] != 2: x = A[x[1]-1] cnt += 1 if x[1] == 1: print(-1) exit() print(cnt+1)" p03611,s445907240,Wrong Answer,"N = int(input()) A = list(map(int, input().split())) ans=0 for i in range(min(A),max(A)): tmp = 0 for a in A: if a-1<=i<=a+1: tmp+=1 ans = max(ans, tmp) print(ans)" p03785,s821925223,Wrong Answer,"n,c,k=map(int,input().split()) T=[int(input()) for i in range(n)] i=0 ans=0 T.sort() while(i= H[i]: cnt += 1 print(max(ans, cnt))" p02970,s688739759,Wrong Answer,"a,b = list(map(int,input().split())) if a % (b *2)== 0: print(a//(b*2)) else: print(a//(b*2)+1)" p02814,s012976554,Accepted,"from fractions import gcd n, m = map(int, input().split()) a = [i//2 for i in map(int, input().split())] z = [] for i in a: n = 0 while i%2==0: i //= 2 n += 1 z.append(n) if all(z[0]==i for i in z): x = 1 for i in a: x = (x*i)//gcd(x, i) result = -(-(m//x)//2) print(result) else: print(0)" p02552,s471154680,Wrong Answer,"x = int (input(""Enter a value for x that is greater than or equal to 0 and less than or equal to 1: "")) if x == 0: print (""1"") elif x== 1: print (""0"") elif x>1 or x<0: print(x) " p02848,s329999381,Accepted,"N = int(input()) S = input() for c in S: print(chr(ord(c) + N) if ord(c) + N <= 90 else chr(ord(c) + N - 26), end='') print() " p02861,s674035934,Accepted,"from itertools import permutations import math N = int(input()) A = [] for i in range(N): A.append(list(map(int,input().split()))) #print(A) B = [] for i in permutations(A,2): B.append(i) #print(B) ans = 0 for i in range(len(B)): ans += math.sqrt((B[i][0][0] - B[i][1][0])**2 + (B[i][0][1] - B[i][1][1])**2) print(ans/N)" p03208,s489846527,Wrong Answer,"# coding:utf-8 n, k = map(int, input().split()) h = [int(input()) for _ in range(n)] h.sort() ans = h[0] for i in range(0, n - k + 1): ans = min(ans, h[i + k - 1] - h[i]) print(ans) " p02597,s349727698,Accepted,"n=int(input()) c=input() r=c.count(""R"") r_1=c[:r].count(""R"") ans=r-r_1 print(ans)" p03274,s370872933,Accepted,"N, K = map(int, input().split()) X = list(map(int, input().split())) ans = 10**18 for i in range(N - K + 1): x1 = X[i] x2 = X[i + K - 1] if x1 * x2 >= 0: dist = max(abs(x1), abs(x2)) else: dist = min(abs(x1), abs(x2)) + abs(x1 - x2) ans = min(ans, dist) print(ans) " p03773,s307318671,Accepted,"A, B = map(int, input().split()) AB = A + B if AB >= 24: print(AB - 24) else: print(AB)" p03359,s020849026,Accepted,"a, b = list(map(int, input().split())) if a <= b: my_result = a else: my_result = a - 1 print(my_result)" p03282,s771969727,Wrong Answer,"s = input() k = int(input()) if k == 1: print(s[0]) elif s[0] == ""1"": print(s[1]) else: print(s[0])" p02622,s313511935,Accepted,"s=input() t=input() a=0 for i in range(len(s)): if s[i]!=t[i]: a+=1 print(a)" p03835,s590940520,Accepted,"k,s=map(int,input().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)" p02658,s459991656,Accepted,"n = int(input()) a = [int(num) for num in input().split()] ans = 1 if 0 in a: ans = 0 for i in range(n): ans *= a[i] if ans > 10 ** 18: ans = -1 break print(ans)" p02647,s004170537,Accepted,"from itertools import accumulate N, K = map(int, input().split()) A = [int(i) for i in input().split()] for _ in range(K): 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 A = list(accumulate(S))[:-1] if all([a == N for a in A]): break print(*A)" p04005,s325391195,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(abs((A//2)*B*C-((A//2)+1)*B*C),abs((B//2)*A*C-((B//2)+1)*A*C),abs((C//2)*B*A-((C//2)+1)*B*A)))" p03815,s331850672,Accepted,"def main(): x = int(input()) ele = x // 11 answer = 2 * ele if x % 11 != 0: x -= 11 * ele answer = 2 * ele if x <= 6: answer += 1 else: answer += 2 print(answer) if __name__ == '__main__': main()" p03852,s407233374,Wrong Answer,"c = input() vowel = ['a','i','u','e,','o'] if c in vowel: print('vowel') else: print('consonant')" p02691,s463495606,Wrong Answer,"n = int(input()) from collections import defaultdict a = list(map(int,input().split())) ans = 0 dp = defaultdict(int) for e,i in enumerate(a,1): ans += dp[i-e] dp[i+e]+=1 print(ans) " p03407,s994512057,Accepted,"a, b, c = map(int, input().split()) if a + b >= c: print(""Yes"") else: print(""No"") " p02597,s893560839,Accepted,"n = int(input()) s = input() check = s.count(""R"") q = s[:check] print(q.count(""W""))" p03795,s062515789,Accepted,"A = int(input()) print(800*A-200*(A//15))" p03827,s368985427,Accepted,"N = int(input()) S = input() l = [0] x = 0 for i in range(N): if S[i] == ""I"": x+=1 else: x-=1 l.append(x) print(max(l))" p03262,s250389357,Accepted,"def main(): import fractions from functools import reduce n, x, *l = map(int, open(0).read().split()) a = list(map(lambda i: abs(i-x), l)) ans = reduce(fractions.gcd, a) print(ans) if __name__ == '__main__': main() " p02765,s578444252,Accepted,"n, r = map(int, input().split()) if n <= 10: print(r+100*(10-n)) elif n > 10: print(r)" p02660,s934029303,Wrong Answer,"ni = lambda: int(input()) nm = lambda: map(int, input().split()) nl = lambda: list(map(int, input().split())) import math n = ni() divs=[] for i in range(2,math.ceil(math.sqrt(n))+1): while n%i==0: divs.append(i) n//=i if len(divs)==0: divs.append(n) last=0 total=0 cnt=0 tmp_cnt=0 for d in divs: if last!=d: last=d cnt=0 tmp_cnt=0 if cnt==tmp_cnt: total+=1 cnt+=1 tmp_cnt=0 else: tmp_cnt+=1 print(total) # print(divs)" p03360,s799399536,Accepted,"a, b, c = map(int, input().split()) k = int(input()) rem = sum((a, b, c)) - max(a, b, c) print(max(a, b, c)*2**k + rem)" p03711,s936290698,Accepted,"print([""Yes"",""No""][input().count(""2"")])" p02660,s495295745,Accepted,"from collections import defaultdict def factorize(M): res=defaultdict(int) for i in range(2,int(M**0.5)+1): if M==1: break while M%i==0: M//=i res[i]+=1 if M!=1: res[M]=1 return res N=int(input()) fact=factorize(N) #print(fact) def times(n): ret=1 for i in range(2,10**9): if n max_a], reverse=True) sum_bs = sum(bs) if H <= sum_bs: for i in range(len(bs)): H -= bs[i] if H <= 0: print(i+1) exit() else: H -= sum_bs print((H+max_a-1)//max_a + len(bs)) " p02600,s973948252,Wrong Answer,"x = int(input()) def score(x): 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"") elif 1800 <= x <= 1999: print(""1"") print(score(x)) " p02711,s901947615,Accepted,"N = str(input()) if (N[0] == '7')or(N[1] == '7')or(N[2] == '7'): print('Yes') else: print('No')" p03107,s377637089,Wrong Answer,"import collections l=list(input()) c=collections.Counter(l) print(c['0'],c['1']) if c['0']==c['1']: print(c['0']*2) else: print(min(c['0'],c['1'])*2)" p03836,s863079426,Wrong Answer,"a,b,c,d = map(int,input().split()) A = c - a B = d - b ans = '' ans +='R'*A + 'U'*B ans +='L'*A + 'D'*B ans +='L'+'U'*B+'U'+'R'*A +'R' ans +='R'+'D'*B+'D'+'L'*A +'L'+'U' print(ans)" p02792,s159810100,Wrong Answer,"N = int(input()) A = 0 for i in range(N-1): for j in range(i,N): if str(i)[0] == str(j)[-1] and str(i)[-1] == str(j)[0]: print(str(i) + ' ' + str(j)) A += 1 print(A + 2)" p03943,s034457801,Accepted,"a,b,c =sorted(map(int,input().split())) print(""Yes"" if (a+b) == c else ""No"")" p02554,s495011785,Accepted,"n = int(input()) print((10**n -2*9**n +8**n) % 1000000007)" p03659,s027443924,Wrong Answer,"n=int(input()) a=list(map(int,input().split())) ans=float(""inf"") x=0 b=sum(a) for i in range(n): x+=a[1] if i+1=0 else 0) + s[i] b = (dp[i - 1][1] if i - 1 else 1) + 10 - s[i] dp[i][0] = min(a,b) a = (dp[i - 1][0] if i - 1 >=0 else 0) + s[i] + 1 b = (dp[i - 1][1] if i - 1 else 1) + 10 - s[i] - 1 dp[i][1] = min(a,b) print dp[-1][0] " p03548,s787047436,Accepted,"#import itertools #import fractions #import numpy as np #mod = 10**4 + 7 """"""def kiri(n,m): r_ = n / m if (r_ - (n // m)) > 0: return (n//m) + 1 else: return (n//m)"""""" # Written by NoKnowledgeGG @YlePhan import math #mod = 10**9+7 def main(): x,y,z = map(int,input().split()) x -= z print(x//(y+z)) if __name__ == '__main__': main()" p02784,s492182316,Accepted,"import sys H, N = map(int, input().split()) AList = list(map(int, input().split())) for i in range(0, N): H -= AList[i] if H <= 0: print('Yes') sys.exit(0) print('No')" p03319,s261539580,Wrong Answer,"import sys stdin = sys.stdin ni = lambda: int(ns()) na = lambda: list(map(int, stdin.readline().split())) ns = lambda: stdin.readline().rstrip() nas = lambda: stdin.readline().split() n, k = na() a = na() print(n // (k - 1))" p02696,s893907929,Accepted,"import sys def input(): return sys.stdin.readline().strip() def resolve(): a,b,n=map(int, input().split()) c=min(b-1,n) print((a*c)//b-a*(c//b)) resolve()" p03469,s317493853,Wrong Answer,"S = input() print(S.replace('7', '8'))" p03042,s030475600,Accepted,"a=int(input()) x=a//100 y=a%100 c=False d=False if 1<= x<=12: c=True if 1<= y<=12: d=True if c==True and d==True: print(""AMBIGUOUS"") if c==True and d==False: print(""MMYY"") if c==False and d==True: print(""YYMM"") if c==False and d==False: print(""NA"")" p02627,s689444451,Accepted,"a = input() if a.isupper(): print(""A"") else: print(""a"")" p02993,s136780096,Wrong Answer,"a=list(input()) for i in range(3): if a[i]==a[i+1]: print('Bad') break else: print('Good') break " p03042,s750856940,Accepted,"s = input() a = 1 <= int(s[:2]) <= 12 b = 1 <= int(s[2:]) <= 12 if a and b: print(""AMBIGUOUS"") elif a: print(""MMYY"") elif b: print(""YYMM"") else: print(""NA"") " p02706,s077931813,Accepted,"N,M = input().split() day = input().split() days = [] for d in day: days.append(int(d)) if int(N) >= sum(days): print(int(N) - sum(days)) else: print(-1)" p02640,s851738957,Accepted,"target = list(map(int, input().split())) num = target[0] total = target[1] for i in range(num + 1): tori = i kame = (num - i) if (tori * 2 + kame * 4) == total: print('Yes') break else: print('No') " p02660,s275977752,Wrong Answer,"import math from collections import defaultdict N = int(input()) n = N #素因数分解 factor = defaultdict(lambda: 0) tmp = int(math.sqrt(N))+1 for num in range(2,tmp): while N % num == 0: N //= num factor[num] += 1 if not factor: factor[n] += 1 else: factor[N] += 1 ans = 0 for num in factor: i = 1 while True: factor[num] -= i if factor[num]<0: break ans += 1 i+=1 print(ans) " p02811,s607233089,Wrong Answer,"K, X = map(int, input().split()) if (K * 500) > X: print('Yes') else: print('No') " p03544,s542167813,Accepted,"import sys sys.setrecursionlimit(2000) N = int(input()) # def Lucas(x): # if x == 2: # return 1 # if x == 1: # return 2 # return Lucas(x - 1) + Lucas(x - 2) # answer = Lucas(N) L = [0] * (N+1) L[0] = 2 L[1] = 1 for i in range(2, N+1): L[i] = L[i-1] + L[i-2] print(L[N])" p03699,s320612628,Accepted,"n = int(input()) S = [int(input()) for _ in range(n)] total = sum(S) if total % 10 == 0: l = [s for s in S if s % 10 != 0] if l: total -= min(l) else: total = 0 print(total) " p02795,s670474771,Wrong Answer,"h = int(input()) w = int(input()) n = int(input()) print(n // max(h,w))" p02639,s004686532,Wrong Answer,"arr = [1,2,3,0,5] def find(x): if x == 0: return arr[i]" p03838,s475768416,Wrong Answer,"x, y = map(int, input().split()) if 0 <= x <= y or x <= y <= 0: print(y - x) elif x <= 0 <= y: print(abs(y + x) + 1) elif 0 <= y <= x or y <= x <= 0: print(abs(x - y) + 2) else: print(abs(x + y) + 1) " p03814,s418195994,Accepted,"s=input() print(s.rfind('Z')-s.find('A')+1)" p02899,s107831354,Wrong Answer,"N = int(input()) A = list(map(int, input().split())) L = [0]*N for i in range(0, N): L[A[i]-1] = i + 1 print(L,A[i]) print(*L)" p02795,s664110746,Wrong Answer,"import math c=input() b=input() a=input() if c>b: print(math.ceil(int(a)/int(c))) else: print(math.ceil(int(a)/int(b)))" p02657,s689025856,Accepted,"def main(): import sys sys.setrecursionlimit(10**9) input = sys.stdin.readline a, b = map(int, input().split()) print(a*b) main()" p02658,s521424555,Accepted,"import numpy as np N = int(input()) Alist = list(map(int,input().split())) #ans = np.prod(Alist) Alist.sort() ans = 1 for i in range(N): #print (Alist[i]) ans*= Alist[i] if Alist[i]==0: break if ans >10**18: break if ans >10**18: print(-1) else: print(ans)" p03012,s590361361,Accepted,"N = int(input()) W = list(map(int, input().split())) ans =101 for i in range(N): s1 = sum(W[:i+1]) s2 = sum(W[i+1:]) ans = min(ans, abs(s1 -s2)) print(ans)" p02881,s654092936,Wrong Answer,"import math N = int(input()) min_cand = 10**9 for i in range(1,(int(math.sqrt(N))+1)): if N % i == 0 and min_cand > (i + (N // i)): min_cand = (i + (N // i)) print(min_cand - 2)" p02935,s753047593,Wrong Answer,"N = int(input()) A = list(map(int, input().split())) A.sort() while len(A)>=2: X = int((A[0]+A[1])/2) A.pop(0) A.pop(0) A.append(X) A.sort() else: print(*A)" p03681,s333921250,Accepted,"import math n,m=map(int,input().split()) a=math.factorial(n) * math.factorial(m) if abs(n-m) == 0: a *= 2 elif abs(n-m) > 1: a = 0 print(a%1000000007) " p02948,s477476887,Accepted,"import heapq n, m = map(int, input().split()) l = [[] for _ in range(m)] for i in range(n): a, b = map(int, input().split()) if a <= m: l[a - 1].append(b) a = [] ans = 0 for k in range(m - 1, -1, -1): i = m - k - 1 for j in l[i]: heapq.heappush(a, (-1) * j) if a: ans += heapq.heappop(a) * (-1) print(ans) " p02678,s825713207,Accepted,"from collections import deque print(""Yes"") N,M=map(int,input().split()) lst=[[] for _ in range(N)] for _ in range(M): a,b=map(int,input().split()) lst[a-1].append(b-1) lst[b-1].append(a-1) q=deque(lst[0]) go=[None]*N for i in lst[0]: go[i]=0 while q: v=q.popleft() for new in lst[v]: if go[new]==None: go[new]=v q.append(new) for i in go[1:]: print(i+1)" p02641,s818493565,Wrong Answer,"x, n = map(int, input().split()) p = list(map(int, input().split())) if n == 0: print(x) exit() cnt = [0] *101 ans1 = 0 ans2 = 0 for _p in p: cnt[_p] += 1 for i in range(x, 101): if cnt[i] == 0: ans1 = i break for i in range(x-1, -100, -1): if cnt[i] == 0: ans2 = i break if abs(ans1 - x) < abs(ans2 - x): print(ans1) elif abs(ans1 - x) >= abs(ans2 - x): print(ans2)" p03380,s110689524,Accepted,"N = int(input()) a = list(map(int, input().split())) a.sort(reverse=True) x = a[0] // 2 l = 1 r = N - 1 while r - l > 1: mid = l + (r - l) // 2 if a[mid] < x: r = mid else: l = mid if abs(x - a[l]) <= abs(x - a[r]): print(a[0], a[l]) else: print(a[0], a[r]) " p02939,s640306126,Accepted,"s = open(0).read().rstrip() n = len(s) from collections import defaultdict ans = defaultdict(int) ans[-2] = -1 ans[-1] = 0 ans[0] = 1 for i in range(1,n): if s[i] != s[i-1]: ans[i] = ans[i-1]+1 else: ans[i] = ans[i-3]+2 print(ans[n-1])" p03759,s057382279,Accepted,"a,b,c = map(int,input().split()) if b-a == c-b: print(""YES"") else: print(""NO"")" p02860,s488538065,Accepted,"import sys sys.setrecursionlimit(10 ** 5 + 10) def input(): return sys.stdin.readline().strip() def resolve(): N=int(input()) S=str(input()) print('Yes' if S[:N//2]==S[N//2:] else 'No') resolve()" p02847,s810386278,Wrong Answer,"s = str(input()) apple = [""SUN"",""MON"",""TUE"",""WED"",""THU"",""FRI"",""SAT"",""SUN""] print(apple[apple.index(s) + 1])" p03385,s445473052,Accepted,"s=input() if s[0]!=s[1] and s[1]!=s[2] and s[2]!=s[0]: print(""Yes"") else: print(""No"") " p02793,s788620062,Accepted,"# -*- coding: utf-8 -*- import fractions from functools import reduce N = int(input()) A = list(map(int, input().split())) mod = 10 ** 9 + 7 def lcm_base(x, y): return ((x * y) // fractions.gcd(x, y)) def lcm(*numbers): return reduce(lcm_base, numbers, 1) min_AB = lcm(*A) ans = 0 for a in A: ans += min_AB // a print(ans % mod) " p03211,s237712482,Accepted,"s = input() ans = 1000 for i in range(len(s)-2): t = int(s[i:i+3]) a = abs(753 - t) ans = min(ans, a) print(ans)" p03012,s660091854,Accepted,"def main(): n = int(input()) w = list(map(int, input().split())) minv = 100 for i in range(n): minv = min(minv, abs(sum(w[:i])-sum(w[i:]))) print(minv) if __name__ == '__main__': main()" p03645,s848625497,Accepted,"import sys n, m = map(int, input().split()) p = [list(map(int, input().split())) for _ in range(m)] ln1 = [] ln2 = [] for i in p: if i[0] == 1: ln1.append(i[1]) for j in p: if j[1] == n: ln2.append(j[0]) if len(set(ln1) & set(ln2)) == 0: print('IMPOSSIBLE') else: print('POSSIBLE') " p04031,s980486907,Accepted,"n=int(input()) a=list(map(int,input().split())) ans=float('inf') for i in range(-100, 101): tmp=0 for j in range(n): tmp+=(i-a[j])**2 ans=min(tmp,ans) print(ans) " p03767,s485557671,Accepted,"n,*a=map(int, open(0).read().split()) print(sum(sorted(a)[n:][::2])) " p03419,s152606405,Accepted,"n,m = list(map(int, input().split())) # 隅は必ず表 # 辺は行か列なら1なら裏、以外は表 # 上記以外は裏 if n==1 and m==1: print(1) elif n==1 or m==1: print(max(n,m)-2) else: print((n-2)*(m-2)) " p02697,s605583749,Accepted,"import sys sys.setrecursionlimit(10 ** 7) rl = sys.stdin.readline def solve(): N, M = map(int, rl().split()) left = [i for i in range(M)] right = [2 * M - 1 - v for v in left] for i in range(M // 2): right[i] -= 2 * M + 1 for i in range(M): left[i] %= N left[i] += 1 right[i] %= N right[i] += 1 for a, b in zip(left, right): print(a, b) if __name__ == '__main__': solve() " p02622,s966041614,Accepted,"s = input() t = input() count = 0 l = len(s) for i in range(l): if s[i] != t[i]: count += 1 print(count)" p03544,s756112713,Wrong Answer,"n = int(input()) l0 = 2 l1 = 1 if n==1: print(l1) ans = 0 for i in range(n - 1): ans = l0 + l1 l0 = l1 l1 = ans print(ans) " p02995,s464220845,Accepted,"from fractions import gcd a,b,c,d = [int(x) for x in input().split()] def div(x, y, z): return x - (x // y) - (x // z) + (x // (y * z // gcd(y, z))) ans = div(b, c, d) - div(a-1, c, d) print(ans)" p03495,s044318267,Accepted,"from collections import Counter from collections import deque n, k = map(int, input().split()) a = Counter(list(map(int, input().split()))) a = [tuple(i) for i in a.items()] a.sort(key=lambda x: x[1]) a = deque(a) ans = 0 while k=10: print(R) else: print(R+100*(10-N))" p02572,s440668199,Wrong Answer,"N=int(input()) A=list(map(int,input().split())) num=0 for i in range(N): num+=A[i]**2 print(int(((sum(A)*sum(A)-num)/2)%1000000007))" p02598,s519017853,Accepted,"import math n, k = map(int, input().split()) A = list(map(int, input().split())) l = 1 r = 10**9+1 while l < r: mid = (l+r)//2 count = 0 for i in range(n): if A[i] > mid: count += math.ceil(A[i]/mid-1) if count <= k: r = mid else: l = mid+1 print(l) " p03037,s821621030,Accepted,"n, m = map(int, input().split()) L = 1 R = n for i in range(m): l, r = map(int, input().split()) L = max(L, l) R = min(R, r) if l > R: print(0) else: print(R - L + 1) " p03282,s236170821,Accepted,"s = input() k = int(input()) for i in range(k): if s[i] != ""1"": print(s[i]) exit() print(1) " p03644,s570846180,Accepted,"n = int(input()) ans = 1 for i in range(7): if 2 ** i <= n: ans = 2 ** i print(ans)" p02951,s954031378,Accepted,"a, b, c = [int(x) for x in input().split()] if (c - (a - b)) > 0: print(c - (a - b)) else: print(0)" p03293,s291243159,Accepted,"import sys S = str(input()) T = str(input()) for i in range(len(S)): S = S[-1]+S[:-1] if S == T: print(""Yes"") sys.exit() print(""No"")" p03795,s938336081,Accepted,"N=int(input()) x=N*800 y=200*(N//15) print(x-y)" p02731,s152375009,Accepted,"l = int(input()) print((l/3)**3)" p02983,s363549258,Accepted,"L, R = map(int, input().split()) ans = 2020 for i in range(L, R + 1): for j in range(i + 1, R + 1): val = (i * j) % 2019 ans = min(ans, val) if val == 0: print(ans) exit() print(ans) " p03042,s631885036,Accepted,"y = str(input()) ans = [""NA"",""MMYY"",""YYMM"",""AMBIGUOUS""] k = 0 if 1 <= int(y[:2]) <= 12: k += 1 if 1 <= int(y[2:]) <= 12: k += 2 print(ans[k])" p02787,s114481129,Wrong Answer,"h,n = map(int,input().split()) dp = [1e8] * (h+1) dp[0] = 0 for i in range(n): a, b = map(int, input().split()) for j in range(h): nj = min(j+a, h) dp[nj] = min(dp[nj], dp[j]+b) print(dp[h]) " p03986,s166996388,Accepted,"x = input() visited = [0]*(len(x)) ans = 0 s = 0 t = 0 for i in range(len(x)): if not visited[i]: if x[i:i+2] == ""ST"": ans += 2 visited[i+1] = 1 elif x[i] == ""S"": s += 1 elif x[i] == ""T"" and s: ans += 2 s -= 1 print(len(x)-ans)" p03778,s683711470,Wrong Answer,"W, a, b = map(int,input().split()) print(min(max(0,a+W-b),max(0,a-W-b)))" p02854,s870562182,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]): for i, l in enumerate(A): 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:]) ans = min(abs(sum_left - sum_right), abs(sum_left2 - sum_right2)) print(ans)" p03359,s898758944,Accepted,"a,b = map(int,input().split()) print(a-(b m: m = s m_dig = digits if len(m_dig) == k: m += N0 - 1 print(m)" p03944,s068392031,Accepted,"import numpy as np w, h, n = map(int, input().split()) v = np.zeros((h, w), dtype=np.int) for i in range(n): x, y, a = map(int, input().split()) if a == 1: v[:, :x] = 1 elif a == 2: v[:, x:] = 1 elif a == 3: v[:y, :] = 1 else: v[y:, :] = 1 print(w*h-np.sum(v)) " p03478,s015498136,Wrong Answer,"n,a,b = map(int, input().split()) sum = 0 for i in range(10): for j in range(10): if 10*i+j==n and a result[j]: result[j] += (csfn[i][1] - result[j]) else: result[j] += (-result[j] % csfn[i][2]) result[j] += csfn[i][0] for r in result: print(r) " p03624,s586020183,Accepted,"S = list(input()) alphabet = [] for i in range(26): alphabet.append(chr(i+97)) x = set(S) for i in alphabet: if i not in x: print(i) exit() print('None')" p03836,s880177921,Accepted,"a,b,c,d = map(int,input().split()) s = [] s += [""U""]*(d-b)+[""R""]*(c-a)+[""D""]*(d-b)+[""L""]*(c-a) s += [""L""]+ [""U""]*(d-b+1)+[""R""]*(c-a+1)+[""D""]+[""R""] s += [""D""]*(d-b+1)+[""L""]*(c-a+1)+[""U""] print("""".join(s))" p02678,s112410242,Wrong Answer,"from collections import deque n,m=map(int,input().split()) l=[[0] for _ in range(n+1)] vi=[0 for _ in range(n+1)] vi[1]=-1 for i in range (m): a,b=map(int,input().split()) l[a].append(b) l[b].append(a) st=deque([1]) e=set() def bfs(x): if x not in e: e.add(x) for k in l[x]: if k not in e: st.append(k) vi[k]=x return while st: bfs(st.popleft()) print(""Yes"") for m in vi[2:]: print(m) " p03797,s441815788,Accepted,"N, M = map(int, input().split()) x = min(N, M//2) ans = x + (M - 2 * x) // 4 print(ans)" p03077,s862401407,Accepted,"n=int(input()) num=[int(input()) for _ in range(5)] print(4-(n//-min(num))) " p02778,s419388708,Wrong Answer," s=str(input()) a = len(s) for i in range(a): print('x',sep="""")" p03285,s758940983,Accepted,"import sys def main(): n = int(input()) a = n // 7 for i in range(a+1): mod = n - i*7 if mod % 4 == 0: print('Yes') sys.exit(0) print('No') if __name__ == ""__main__"": main() " p03711,s840419805,Wrong Answer,"x,y=map(int,input().split()) a=[4,6,9,11] print('Yes' if x==y==2 or (x in a and y in a) or (x not in a and y not in a) else 'No')" p02843,s479026739,Accepted,"n = int(input()) dp = [0]*100001 dp[100],dp[101],dp[102],dp[103],dp[104],dp[105] = 1,1,1,1,1,1 for i in range(99896): if dp[i] == 1: dp[i+100],dp[i+101],dp[i+102],dp[i+103],dp[i+104],dp[i+105] = 1,1,1,1,1,1 print(dp[n])" p04044,s212731527,Wrong Answer,"n, l = map(int, input().split()) list = [] for s in range(n-1): list.append(input()) s_list = sorted(list) print(*s_list, sep='')" p02759,s292406790,Accepted,print((int(input())+1)//2) p02697,s256071489,Accepted,"from math import ceil n, m = (int(x) for x in input().split()) if n % 2 == 1: for i in range(1, m + 1): print(i, n - i) else: k = (n - 2) // 2 l = ceil(k / 2) ANS = [] for i in range(1, l+1): ANS.append((i, n - i + 1)) for i in range(l+2, k+2): ANS.append((i, n - i + 2)) for a, b in ANS[:m]: print(a, b)" p03854,s457190475,Wrong Answer,"S = input() def solve(T) : while 1: flag = True for i in (""dream"", ""dreamer"", ""erase"", ""eraser""): if T.endswith(i): T = T[: -len(i)] flag = False break if flag: print(""NO"") break if len(T) == 0: print(""Yes"") break solve(S)" p02813,s500650141,Accepted,"from itertools import permutations as per N = int(input()) P = tuple(map(int, input().split())) Q = tuple(map(int, input().split())) PQ = list(per(list(range(1, N + 1)))) a = PQ.index(P) + 1 b = PQ.index(Q) + 1 print(abs(a - b))" p02854,s126687170,Accepted,"import itertools n = int(input()) a = list(itertools.accumulate(list(map(int, input().split())))) sum_a = a[-1] res = 2020202020 for i in range(n): res = min(res, abs(sum_a - a[i]*2)) print(res) " p03338,s069889553,Accepted,"n = int(input()) s = str(input()) dic = {} for i in s: dic.setdefault(i,0) dic[i] += 1 #print(dic) move = {} ans = [] cnt = 0 for i in s: dic[i] -= 1 move.setdefault(i,0) move[i] += 1 if dic[i]>0 and move[i]>0: if i not in ans: ans.append(i) elif dic[i]==0: if i in ans: ans.remove(i) cnt = max(cnt,len(ans)) print(cnt)" p03281,s311507425,Accepted,"n = int(input()) ans = 0 if n < 105: print(0) else: for i in range(1,n+1,2): count = 0 for l in range(1, i+1, 2): if i % l == 0: count += 1 if count == 8: ans += 1 print(ans)" p02608,s220272171,Accepted,"N = int(input()) f = [0] * (10 ** 4 + 1) for x in range(1, 101): for y in range(1, 101): for z in range(1, 101): n = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x if n <= 10 ** 4: f[n] += 1 print(*f[1 : N + 1], sep=""\n"") " p02935,s625223477,Accepted,"N = int(input()) v = list(map(int, input().split())) v = sorted(v) ans = (v[0]+v[1])/2 if N>2: for i in range(2,N): ans = (ans + v[i])/2 print(ans)" p03071,s067121726,Accepted,"a,b = map(int,input().split()) if a > b: n =a+(a-1) elif b > a: n = b+(b-1) else: n = a+b print(n)" p03371,s364691038,Accepted,"a, b, c, x, y = map(int, input().split()) if x > y: tmp = c*y*2+a*(x-y) else: tmp = c*x*2+b*(y-x) ans = min(a*x+b*y, c*max(x, y)*2, tmp) print(ans)" p03241,s264628877,Accepted,"n, m = map(int,input().split()) for i in range(m//n, -1 , -1): if m%i == 0: print(i) exit()" p03659,s913369396,Accepted,"n = int(input()) a = list(map(int, input().split())) X = sum(a) ans = float(""inf"") x = 0 for i in range(n): x += a[i] if (i + 1) < n: ans = min(ans, abs(X - 2 * x)) print(ans)" p02836,s471159703,Accepted,"s = input() l = len(s) // 2 a = s[:l] b = s[:-(l + 1):-1] count = 0 for i, j in zip(a, b): if i != j: count += 1 print(count)" p02645,s204436453,Accepted,print(input()[:3]) p03107,s703980325,Accepted,"from collections import Counter d={chr(i):0 for i in range(2)} s=Counter(input()) d=d.update(s) print(min(s[""0""],s[""1""])*2)" p02786,s933850317,Accepted,"h = int(input().strip()) c=0 while(h): h=h//2 c+=1 ans=(1-2**c)//(1-2) print(ans)" p02597,s155864248,Wrong Answer,"N = int(input()) C = list(input()) N1 = int(N/2) C1 = C[0:N1] C2 = C[N1:N] count = 0 if (C1.count('W') == C2.count('R')): #左右対象のとき count = C1.count('W') elif(C1.count('R') == C2.count('W')): count = C.count('W') print(count)" p03042,s341973752,Wrong Answer,"s=input() YY=[] MM=[""01"",""02"",""03"",""04"",""05"",""06"",""07"",""08"",""09"",""10"",""11"",""12""] for i in range(13,100): YY.append(str(i)) if s[:2] in YY and s[2:] in MM: print(""YYMM"") elif s[:2] in MM and s[2:] in YY: print(""MMYY"") elif s[:2] in MM and s[2:] in MM: print(""AMBIGUOUS"") elif s[:2] in YY and s[2:] in YY: print(""NA"") " p02690,s084712715,Accepted,"X = int(input()) l = range(-10**3,10**3) for i in l: for j in l: if i**5 - j**5 == X: print(str(i) + "" "" + str(j)) exit() " p03986,s638235875,Accepted,"x = input() ans = 0 s_cnt = 0 for i in range(len(x)): if s_cnt == 0: if x[i] == 'T': ans += 1 else: s_cnt += 1 else: if x[i] == 'T': s_cnt -= 1 else: s_cnt += 1 if s_cnt > 0: ans += s_cnt print(ans) " p02700,s180539117,Accepted,"import sys A,B,C,D = map(int,input().split()) for i in range(1000): C -= B if C <= 0: print(""Yes"") exit() A -= D if A <= 0: print(""No"") exit() " p03827,s989217207,Accepted,"n = int(input()) s = input() slist = [0] sval = 0 for i in s : if i == ""I"": sval += 1 slist.append(sval) else: sval -= 1 slist.append(sval) print(max(slist))" p02818,s579262035,Wrong Answer,"a, b, k = map(int, input().split()) takahasi = max(0, a - k) aoki = max(0, b - (k - a)) print(takahasi, aoki)" p03106,s105658702,Accepted,"def get_dividers(n): """""" 正の整数 n の約数を取得する """""" dividers = {i for i in range(1, int(n ** 0.5) + 1) if n % i == 0} return dividers | {n // d for d in dividers} A, B, K = map(int, input().split(' ')) a_dividers = get_dividers(A) b_dividers = get_dividers(B) ab_dividers = sorted(a_dividers & b_dividers) print(ab_dividers[-K]) " p02687,s593323104,Accepted,"S = input() if S == ""ABC"": print(""ARC"") else: print(""ABC"")" p02829,s965960299,Accepted,"# -*- coding -*- a = int(input()) b = int(input()) if a + b == 3: print(3) elif a + b == 4: print(2) else: print(1) " p02555,s321804724,Accepted,"S = int(input()) mod = 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] %= mod print(dp[S])" p02584,s632944098,Accepted,"x,k,d=map(int,input().split()) x=abs(x) ans=0 if x>k*d: ans=x-(k*d) else: if k%2==(x//d)%2: ans=x%d else: ans=abs(x%d-d) print(ans)" p02756,s000831311,Accepted,"from collections import deque s=input() n = int(input()) f=False q= deque(s) for _ in range(n): i = input() if i[0] == '1': f=False if f else True else: _,a,b =i.split() if f : if a == '1':q.append(b) else:q.appendleft(b) else: if a == '1':q.appendleft(b) else:q.append(b) if f: q.reverse() for i in q:print(i,end='') " p02847,s307325005,Accepted,"s = input() List = [""SUN"",""MON"",""TUE"",""WED"",""THU"",""FRI"",""SAT""] #print(List.index(s)) print(7-List.index(s))" p02725,s063497685,Accepted,"from collections import deque k, n = [int(i) for i in input().split()] data = [int(i) for i in input().split()] d = deque(data) d.appendleft(0) d.pop() bet = [i-j for i, j in zip(data, d)] bet[0] += k - data[-1] print(k - max(bet))" p02833,s825461288,Wrong Answer,"import sys n = int(input()) if n % 2 == 1: print(0) sys.exit() m = n/2 count = 0 i = 1 while m >= 5 ** i: count += (m // (5 ** i)) i += 1 print(int(count))" p02755,s784545693,Accepted,"import numpy as np import math as m def main(**kwargs): res = -1 now = 1263 while now > 0: now -= 1 if (int(now * 0.08) == a and int(now * 0.1) == b): res = now return res if __name__ == ""__main__"": cin = np.array(input().split("" "")).astype(""int"") a, b, *_ = cin cout = main(a=a, b=b) print(cout)" p02829,s045662822,Wrong Answer,"n=int(input()) if n%2==1: print(0) exit(0) k=n//2 from math import floor ans=0 deno=5 while deno<=k: ans+=k//deno deno*=5 print(ans) " p03360,s398528027,Accepted,"num = list(map(int,input().split())) for i in range(int(input())): tmp = max(num) num[num.index(tmp)] = tmp*2 print(sum(num)) " p03627,s032212934,Accepted,"N = int(input()) A = list(map(int, input().split())) A.sort(reverse=True) ans = [] s = A[0] n = 1 for i in range(1, N): if len(ans) == 2: break if A[i] == s: n += 1 if n == 2 or n == 4: ans.append(s) else: s = A[i] n = 1 print(ans[0] * ans[1] if len(ans) != 0 else 0)" p02780,s296250909,Accepted,"N, K = list(map(int,input().split())) p = list(map(int,input().split())) a = [] #各サイコロの期待値のリストaを作成 for i in range(N): a.append((p[i]+1)/2) #累積和のリストSの作成 S = [0] for i in range(N): S.append(S[i]+a[i]) #隣接N個のサイコロの期待値の和のリストansの作成 ans = [] for i in range(N-K+1): ans.append(S[i+K]-S[i]) print(max(ans))" p02695,s842322936,Accepted,"import itertools N,M,Q=map(int,input().split()) a=[] for _ in range(Q): b=list(map(int,input().split())) a.append(b) s=[] for i in range(1,M+1): s.append(i) alist=list(itertools.combinations_with_replacement(s, r=N+1)) tmp=0 for j in alist: s=0 for i in range(Q): j=list(j) if j[a[i][1]]-j[a[i][0]]==a[i][2]: s+=a[i][3] tmp=max(tmp,s) print(tmp)" p02988,s463162352,Wrong Answer,"n = int(input()) p = input().split() cnt = 0 for i in range(0, n-2): print(p[i]) if (p[i] < p[i+1] < p[i+2]) or (p[i] > p[i+1] > p[i+2]): cnt += 1 print(""cnt"", cnt)" p03627,s420592355,Wrong Answer,"from collections import Counter N = int(input()) A = list(map(int, input().split())) c = Counter(A) hen = [key for key, val in c.items() if val > 1] l = max(hen) if hen else 0 if l != 0: hen.remove(l) s = max(hen) if hen else 0 else: s = 0 print(l * s) " p02724,s730490051,Wrong Answer,"n=int(input()) cnt=0 c=0 d=0 e=0 if n==0: print(0) if int(n/500)>0: cnt=int(n/500) n=n%500 if int(n/100)>0: d=int(n/100) n=n%100 if int(n/50)>0: e=int(n/50) n=n%50 if int(n/5)>0: c=int(n/5) n=n%5 print(cnt*1000+c*5+d*0+e*0) " p02988,s121769790,Accepted,"n = int(input()) a = list(map(int,input().split())) c = 0 for i in range(n-2): if a[i]a[i+1]>a[i+2]: c+=1 print(c)" p03632,s866398250,Accepted,"a, b, c, d = map(int, input().split()) if b < c or d < a: print(0) elif a <= c and d <= b: print(d-c) elif c <= a and b <= d: print(b-a) elif a <= c and b <= d: print(b-c) elif c <= a and d <= b: print(d-a)" p03838,s766265138,Accepted,"x, y=map(int, input().split()) c1=x<=y c2=x*y>=0 a=0 if c1 and c2: # 正正か負負でx<Y print(y-x) elif c1 and not c2: # 負正でxy if x*y==0: a=1 else: a=2 print(x-y+a) elif not c1 and not c2: # 正負でx>y print(abs(x-abs(y))+1) " p02594,s045140134,Accepted,"print(""Yes"" if int(input()) >= 30 else ""No"")" p03437,s321854842,Accepted,"x, y = map(int, input().split()) if x % y == 0: ans = -1 else: ans = x print(ans) " p02615,s959799096,Accepted,"n=int(input()) a=list(map(int,input().split())) a.sort(reverse=True) ans=a[0] w=n//2 for aa in a[1:w]: ans+=aa*2 if n%2!=0: ans+=a[w] print(ans)" p03625,s631811240,Accepted,"N = int(input()) a = list(map(int, input().split())) a.sort(reverse=True) b = [] i = 0 while i+11: mid=(r+l)//2 #print(mid,check(mid)) if check(mid): l=mid else: r=mid print(l)" p03251,s826220986,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] < y[0] and X <= y[0] and x[n - 1] <= Y: print(""No War"") else: print(""War"") " p02699,s354506505,Accepted,"# encoding=""UTF-8"" S,W = input().split() S=int(S) W=int(W) if W >= S: print(""unsafe"") elif W < S: print(""safe"")" p03785,s956395669,Accepted,"n,c,k = map(int,input().split()) t = [int(input()) for i in range(n)] t.sort() pas = 1 last_bus = t[0] + k ans = 1 for i in t[1:]: if i <= last_bus and pas < c: pas +=1 else: ans +=1 pas =1 last_bus = i + k print(ans)" p03475,s906582763,Accepted,"import sys n, *CSF = list(map(int, sys.stdin.read().split())) C = CSF[::3] S = CSF[1::3] F = CSF[2::3] def solve(x): cur = 0 for i in range(x, n - 1): y = cur % F[i] if S[i] > cur: cur = S[i] + C[i] elif y == 0: cur += C[i] else: cur += (F[i] - y) + C[i] return cur for i in range(n - 1): print(solve(i)) print(0) " p02621,s319104632,Wrong Answer,"a = int(input(""整数を入力してください"")) answer = a+a*a+a*a*a print(""答えは"",answer)" p02767,s941246685,Wrong Answer,"n = int(input()) x = list(map(int, input().split())) x.sort() mid = x[len(x)//2] strt = mid res = 10**7 if strt>n//2: strt = n//2 for i in range(strt,x[-1]): tmp = 0 for j in x: tmp += (j-i)**2 res = min(tmp,res) else: strt = 0 for i in range(strt,mid): tmp = 0 for j in x: tmp += (j-i)**2 res = min(tmp,res) print(res)" p02888,s539100233,Accepted,"N = int(input()) L = list(map(int, input().split())) L.sort() def find(arr, x): if arr[0] >= x: return 0 if arr[-1] < x: return len(arr) l = 0 h = len(arr) while h - l > 1: m = (l+h) // 2 if arr[m] < x: l = m else: h = m return h ans = 0 for i in range(N-2): for j in range(i+1, N-1): x = L[i] + L[j] temp = find(L[j+1:], x) ans += temp print(ans)" p03474,s155901607,Accepted,"a, b = map(int,input().split()) s = input() n = s[:a] + s[a+1:] print('Yes' if s[a]=='-' and n.isdigit() else 'No')" p03779,s236217642,Accepted,"X=int(input()) for i in range(10**5): if i*(i+1)//2>=X: print(i) break" p02742,s384822888,Accepted,"# Panasonic2020 B h, w = map(int, input().split()) if h == 1 or w == 1: print(1) elif (h * w) % 2: print(1 + (h * w) // 2) else: print(h * w // 2)" p02772,s378078738,Accepted,"N = int(input()) is_approved = True l = list(map(int, input().split())) for i in l: if i % 2 == 0: if not (i % 5 == 0 or i % 3 == 0): is_approved = False break print('APPROVED' if is_approved else 'DENIED')" p02900,s222808784,Accepted,"from fractions import gcd from math import sqrt a,b = map(int,input().split()) n = gcd(a,b) k = n s = set() s.add(1) for i in range(2,int(sqrt(n))+1): while n%i == 0: n = n//i s.add(i) if n == 1: break s.add(n) print(len(s))" p02693,s702362663,Accepted,"k = int(input()) a,b = [int(x) for x in input().split()] ans=False for i in range(a,b+1): if(i%k==0): ans = True break if(ans): print(""OK"") else: print(""NG"") " p03087,s937784423,Accepted,"n, q = map(int, input().split()) s = input() ans = [0] for i in range(1, n): if s[i - 1:i + 1] == ""AC"": ans.append(ans[-1] + 1) else: ans.append(ans[-1]) for _ in range(q): l, r = map(int, input().split()) print(ans[r - 1] - ans[l - 1])" p02993,s976065604,Accepted,"s = input() ans = 'Good' for i in range(3): if s[i] == s[i+1]: ans = 'Bad' break print(ans)" p03323,s807769681,Accepted,"A,B = map(int,input().split()) if A > 8 or B > 8: print("":("") else: print(""Yay!"")" p02556,s491229395,Accepted,"N = int(input()) A = [list(map(int, input().split())) for _ in range(N)] Z = sorted([x+y for x,y in A]) W = sorted([x-y for x,y in A]) print(max(Z[-1]-Z[0], W[-1]-W[0]))" p03377,s231626043,Accepted,"a, b, x = map(int, input().split()) if a + b >= x: if a <= x: print(""YES"") else: print(""NO"") else: print(""NO"") " p02792,s045734640,Accepted,"n = int(input()) count_list = [] for i in range(10): count_list.append([0] * 10) for i in range(1, n + 1): i_str = str(i) j = int(i_str[0]) k = int(i_str[-1]) count_list[j][k] += 1 ans = sum([count_list[i][j] * count_list[j][i] for i in range(1, 10) for j in range(1, 10)]) print(ans)" p03803,s386354059,Accepted,"A, B = list(map(int,input().split())) if A == 1: A = 14 if B == 1: B = 14 print('Alice' if A > B else 'Bob' if A < B else 'Draw')" p03437,s917465958,Accepted,"x, y = map(int, input().split()) if x % y == 0: print(-1) else: print(x) " p03799,s087600197,Wrong Answer,"N, M = map(int, input().split()) print(max(N+(M-N*2)//4, N)) " p02732,s862253215,Accepted,"# A = [list(map(int, input().split())) for _ in range(3)] n = int(input()) # B = [int(input()) for _ in range(n)] A = list(map(int, input().split())) # a, b = map(int, input().split()) # S = input() def choose2(n): return n*(n-1)//2 cnt = [0 for _ in range(n+1)] for i in range(n): cnt[A[i]-1] += 1 total = 0 for i in range(n): total += choose2(cnt[i]) for i in range(n): ans = total ans -= choose2(cnt[A[i]-1]) ans += choose2(cnt[A[i]-1]-1) print(ans) " p03037,s370400997,Accepted,"n,m=map(int,input().split()) l=1 r=n for i in range(m): li,ri=map(int,input().split()) l = max(l,li) r = min(r,ri) print(max(r-l+1,0))" p02835,s974730855,Accepted,"a,b,c=map(int,input().split()) if a+b+c>=22: print(""bust"") else: print(""win"")" p02811,s316296732,Wrong Answer,"K, X = map(int, input().split("" "")) if 500*K>X: print(""Yes"") else: print(""No"")" p03449,s464646744,Accepted,"n=int(input()) a1=list(map(int,input().split())) a2=list(map(int,input().split())) ans=0 for i in range(n): a=0 a+=sum(a1[:i+1]) a+=sum(a2[i:]) ans=max(ans,a) print(ans)" p03360,s907154871,Accepted,"A,B,C=list(map(int, input().split())) K=int(input()) m=max(A,B,C) print(A+B+C-m+m*(2**K))" p02958,s538220465,Accepted,"N = int(input()) p = list(map(int, input().split())) diff = 0 for i in range(N): if p[i] != i+1: diff += 1 print(""YES"" if diff == 0 or diff == 2 else ""NO"")" p02720,s625725859,Accepted,"k = int(input()) nums = [] def inc(num): if num > 3234566667: return None if num <= 3234566667: nums.append(num) end = str(num)[-1:] end_num = int(end) if end_num < 9: inc(num * 10 + end_num + 1) inc(num * 10 + end_num) if end_num > 0: inc(num * 10 + end_num - 1) for i in range(1, 10): inc(i) sort_nums = sorted(nums) print(sorted(nums)[k - 1])" p03109,s486991406,Accepted,"import datetime t = datetime.datetime.strptime(""2019/04/30"",""%Y/%m/%d"") s = datetime.datetime.strptime(input(),""%Y/%m/%d"") print(""Heisei"") if t>=s else print(""TBD"")" p03126,s651778367,Accepted,"N, M = map(int,input().split()) f = [] for i in range(N): f.append(list(map(int,input().split()))) c = 0 for i in range(M): b = False for j in range(N): if not i+1 in f[j][1:]: b = True break if not b: c+=1 print(c) " p02819,s098343904,Accepted,"X = int(input()) done = False num = X - 1 while not done: num += 1 if num > 1: for i in range(2, num): if (num % i) == 0: break else: done = True print(num)" p02730,s617994458,Wrong Answer,"s = input() result = 'Yes' j = int((len(s)-1)/2) for i in range(int(j/2)): if(s[i] != s[j-i-1]): result = 'No' break for i in range(j+1,j+int(j/2)): if(s[i] != s[j-i-1]): result = 'No' break print(result)" p03860,s912418594,Accepted,"a, b, c = input().split() print(a[0]+b[0]+c[0])" p02719,s830578594,Accepted,"n,k=map(int,input().split()) n=n%k print(min(n,k-n))" p03456,s454070182,Accepted,"a,b = input().split() num = int(a+b) for i in range(1,1000): if i*i == num: print(""Yes"") exit() print(""No"") " p03243,s228574236,Wrong Answer,"S = input() if len(set(S)) == 1: print(S) elif int(S[0] * 3) > int(S): print(S[0] * 3) else: print(S[1] * 3)" p03012,s966370091,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() W = LI() ans = math.inf for i in range(n): ans = min(ans, abs(sum(W[:i]) - sum(W[i:]))) print(ans)" p04011,s047238137,Accepted,"a = int(input()) b = int(input()) c = int(input()) d = int(input()) if a<= b: print(a*c) else: print(c*b +(a-b)*d)" p04011,s804359357,Wrong Answer,"n = int(input()) s = int(input()) x = int(n**0.5)+1 def dsum(x,t): ret = 0 while x>0: ret += x%t x //= t return ret if n == s: print(n+1) exit() for i in range(2,x+1): if dsum(n,i) == s: print(i) exit() for i in range(x,0,-1): if (n-(s-i))%i == 0: digit = (n-(s-i))//i if 0 < i < digit and 0 <= s-i < digit: print((n-(s-i))//i,i) exit() print(-1)" p03317,s422974983,Accepted,"N,K=map(int,input().split()) A=list(map(int,input().split())) for i in range(100000): if N<=K+i*(K-1) : print(i+1) exit()" p02801,s154224284,Wrong Answer,"char = ['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(char[char.index(input())]) " p03693,s559341243,Accepted,"if int(''.join(input().split()))%4==0: print('YES') else: print('NO')" p03494,s117453144,Accepted,"#!/usr/bin/env python3 import math import sys sys.setrecursionlimit(10**6) n = int(input()) a = list(map(int, input().split())) ans = 10**10 for i in a: tmp = 0 while(i % 2 != 1): tmp += 1 i = i//2 # print(tmp) ans = min(ans, tmp) print(ans) " p03041,s059361444,Wrong Answer,"s=input() a=int(s[0:2]) b=int(s[2:4]) if 0 n4: #1414...141のときだけ if not(n1 == n4 + 1 and n2 == 0): bl = False answer = 'Yes' if bl else 'No' print(answer) " p04020,s118614397,Accepted,"import numpy as np N = int(input()) A = np.array([int(input()) for _ in range(N)]) ans = 0 for i in range(N-1): d,m = divmod(A[i],2) ans += d if m == 1: if A[i+1] > 0: A[i+1] -= 1 ans += 1 ans += A[-1]//2 print(ans)" p03730,s416152397,Wrong Answer,"a, b, c = map(int,input().split()) A = [] for i in range(1,b+1): mod = a*i % b if mod in A:break A.append(mod) A.sort() if len(A) >= 2: i = A[1] else: i = 0 if i == 0 and c == 0: print('Yes') exit() elif i == 0 and c != 0: print('No') exit() if c % i == 0: print('Yes') else: print('No')" p03760,s692151351,Accepted,"o = input() e = input() pas = '' for i in range(len(e)): pas += o[i] + e[i] if len(o) > len(e): pas += o[-1] print(pas)" p03069,s351656275,Accepted,"N = int(input()) S = list(input()) bl = [0] * (N+1) # 左に黒が何個あるか wr = [0] * (N+1) # 右に白が何個あるか for i in range(N): bl[i+1] = bl[i] + (1 if S[i] == '#' else 0) for i in range(N-1,-1,-1): wr[i] = wr[i+1] + (1 if S[i] == '.' else 0) ans = N+1 for i in range(N+1): ans = min(ans, bl[i]+wr[i]) print(ans)" p02861,s724499474,Accepted,"n = int(input()) x_y = [] for _ in range(n): x_y.append([int(i) for i in input().split()]) import itertools import math ans = 0.0 for x_yi in itertools.permutations(x_y, n): sum_ = 0.0 for i in range(n-1): sum_ += math.sqrt((x_yi[i][0] - x_yi[i+1][0]) ** 2 + (x_yi[i][1] - x_yi[i+1][1]) ** 2) ans += sum_ / math.factorial(n) print(ans)" p03627,s636300140,Accepted,"from collections import Counter n = int(input()) A = Counter([int(i) for i in input().split()]) A = sorted(A.items(), key=lambda x: -x[0]) x = [] while len(x) < 2: for a, cnt in A: while cnt > 1 and len(x) < 2: x.append(a) cnt -= 2 else: break if len(x) < 2: print(0) else: print(x[0] * x[1]) " p02621,s396875714,Accepted,"a = int(input()) print(a + a * a + a * a * a) " p02958,s290945094,Wrong Answer,"a = int(input()) b=list(map(int,input().split())) c=b c.sort() d=[] print(c) for i in range(a): for j in range(a): b[i],b[j]=b[j],b[i] print(b) if b==c: d.append(b) else: continue if len(d)!=0: print('YES') else: print('NO')" p03469,s426778337,Accepted,"s = input() s = list(s) s[3] = '8' s = """".join(s) print(s)" p03328,s961431584,Accepted,"a,b=map(int,input().split()) n=b-a print(n*(n+1)//2-b)" p02683,s805248164,Accepted,"import numpy as np n, m, x = map(int, input().split()) l = [] for _ in range(n): l.append(list(map(int, input().split()))) l = np.array(l) val = 9999999 for i in range(2 ** n): curr = np.array([0 for _ in range(m+1)]) for j in range(n): if ((i >> j) & 1): curr += l[j] flag = True for k in range(m): if curr[k+1] < x: flag = False if flag: if val > curr[0]: val = curr[0] if val == 9999999: print(""-1"") else: print(val)" p02576,s924301376,Accepted,"import math n,x,t=map(int,input().split()) y = t * int(math.ceil(n/x)) print(y) " p03377,s454534614,Accepted,"def main(): a,b,x = (int(x) for x in input().split()) print('YES' if b>=(x-a) and a<=x else 'NO') if __name__ == '__main__': main()" p03838,s964486789,Wrong Answer,"x,y = map(int,input().split()) if ((x >= 0 and y >= 0) or (x < 0 and y < 0)) and x < y: print(y-x) elif (x >= 0 and y >= 0) and y < x: print(abs(x-y)+2) elif (x < 0 and y < 0) and y < x: print(abs(x-y)+2) elif x == -y: print(1) else: print(abs(x-y)+1)" p03478,s775054628,Wrong Answer,"n,a,b=map(int, input().split()) ans = 0 for i in range(n): d = i c = 0 while d >0: c += (d%10) d = d // 10 if a <= c <= b: ans += 1 print(ans) " p03161,s541015994,Accepted,"n,k,*h=map(int,open(0).read().split()) INF=float(""inf"") dp=[INF]*(n) dp[0]=0 for i in range(n): for j in range(1,k+1): # try: # dp[i+j]=min(dp[i+j],dp[i]+abs(h[i+j]-h[i])) # except: # pass if not i-j<0: dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j])) print(dp[-1])" p02708,s094494914,Wrong Answer,"n, k = map(int, input().split()) mod = 10 ** 9 + 7 def comb(n, k): res = 1 for i in range(n - k + 1, n + 1): res = res * i % mod for i in range(1, k + 1): res = res * pow(i, mod - 2, mod) % mod return res calc = comb(n + 1, k) ans = 0 ans += calc for i in range(k + 1, n + 1): calc *= n + 2 - i calc //= i ans += calc if k == n + 1: ans = 1 print(ans % mod)" p03774,s952672734,Accepted,"# abc057_b.py def calc(p1, p2): return abs(p1[0]-p2[0])+abs(p1[1]-p2[1]) 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)] for i in range(N): dist = 10**9 ans = 0 for j in range(M): now_dist = calc(ab[i], cd[j]) if dist > now_dist: dist = now_dist ans = j+1 print(ans) " p03352,s660263058,Wrong Answer,"import math n = int(input()) ans = 0 for i in range(1,math.ceil(math.sqrt(n))): for j in range(2,11): if i ** j > n and j > 2: ans = max(ans,i ** (j-1)) break print(ans)" p02595,s494949534,Accepted,"import math N, D = map(int, input().split()) xy = [map(int, input().split()) for _ in range(N)] x, y = [list(i) for i in zip(*xy)] d = D**2 count = 0 for i in range(N): x2 = x[i] ** 2 y2 = y[i] ** 2 if x2 > d: continue elif y2 > d: continue elif (x2 + y2) <= d: count += 1 print(count) " p02659,s786832587,Accepted,"import math from decimal import Decimal A,B = input().split() A = int(A) B = Decimal(B) print(int(A*B))" p02694,s575995627,Wrong Answer,"import math def main(): x = int(input()) total = 100 year = 0 while total < x: total = math.floor(total * 1.01) year += 1 print(year) main()" p03262,s025264556,Wrong Answer,"n,x=map(int,input().split()) xlist= list(map(int,input().split())) if n == 1: print(abs(xlist[0]-x)) exit() ylist = [] for i in range(n-1): ylist.append(abs(xlist[i]-x)) from functools import reduce from math import gcd print(reduce(gcd,ylist))" p04045,s969432582,Wrong Answer,"s = input().split("" "") n = int(s[0]) numbers = [ i for i in input() if i != "" ""] for i in range(n, 10001): found = False snum = str(i) for num in numbers: if num in snum: found = True break if found == False: print(i) break" p02790,s415230386,Accepted,"a,b=map(int,input().split()) print(int(str(a)*b) if a=13: print(B) elif A <=5: print(0) else: print(int(B/2))" p02771,s734684383,Accepted,"A,B,C=map(int,input().split()) print((A==B and B!=C or A==C and C!=B or B==C and B!=A) and ""Yes"" or ""No"") " p02987,s187242662,Accepted,"s=input() s=sorted(s) if s[0]==s[1] and s[2]==s[3] and s[1]!=s[2]: print(""Yes"") else:print(""No"")" p03359,s499189799,Accepted,"a, b = map(int, input().split()) if b >= a: print(a) else: print(a - 1)" p03695,s604100900,Accepted,"n,*a=map(int,open(0).read().split()) c,*l=[0]*9 for i in a: if i<3200: l[i//400]=1 else: c+=1 print(max(1,sum(l)),sum(l)+c)" p02780,s427388167,Accepted,"n,k=map(int,input().split()) p=[0]+list(map(int,input().split())) m=-1 s=0 s+=sum(p[0:k]) for i in range(len(p)-k): s+=p[i+k] s-=p[i] if m < s: m=s print((m+k)/2)" p03545,s908812442,Accepted,"a,b,c,d = map(str,input()) n = 3 pt = [] for i in range(2 ** n): tmp = [""+""] * n for j in range(n): if i >> j & 1: tmp[j] = ""-"" pt.append(tmp) for x in pt: fr = a + x[0] + b + x[1] + c+ x[2] + d if eval(fr) == 7 : print(fr+""=7"") exit() " p02607,s120766127,Accepted,"n=int(input()) a=list(map(int,input().split())) ans=0 for i in range(0,len(a),2): if a[i]%2==1: ans+=1 print(ans) " p02689,s096541047,Wrong Answer,"import numpy as np N,M=map(int,input().split()) H=list(map(int,input().split())) A=[list(map(int,input().split())) for i in range(M)] ok=np.zeros(N) for i in range(M): if H[A[i][0]-1]>H[A[i][1]-1]: ok[A[i][0]-1]=1 ok[A[i][1]-1]=0 else: ok[A[i][1]-1]=1 ok[A[i][0]-1]=0 print(int(np.sum(ok)))" p03555,s209657349,Accepted,"A=input() B=input() count=0 if A[0]==B[2]: if A[1]==B[1]: if A[2]==B[0]: count+=1 if count>0: print('YES') else: print('NO') " p02548,s413405570,Wrong Answer," n = int(input()) ans = 0 for i in range(2,n,1): for j in range(i,n): if n % i*j != 0: #print(n,i,j,i*j) ans += 1 ans = ans + (n-1) print(ans)" p03695,s269280023,Accepted,"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) print(max(len(set(B)),1),len(set(B))+len(C)) " p03827,s323719508,Accepted,"n = int(input()) s = input() x = 0 m = 0 for i in s: if i == 'I': x += 1 else: x -= 1 m = max(x, m) print(m) " p02718,s608294810,Accepted,"n,m=map(int,input().split()) a=list(map(int,input().split())) a.sort(reverse=True) ans=""Yes"" s=sum(a) if a[m-1]>=s/(4*m): print(""Yes"") else: print(""No"")" p02607,s362810236,Wrong Answer,"num=input() masu=list(map(lambda x:int(x),input().split())) masu=[i for i in masu if i%2!=0 and (masu.index(i)+1)%2!=0] print(len(masu))" p02835,s177881794,Accepted,"a,b,c=map(int,input().split()) if a+b+c >= 22: print(""bust"") else: print(""win"")" p02785,s578589002,Accepted,"import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines n, k, *h = map(int, read().split()) h = sorted(h, reverse=True) print(sum(h[k::]))" p03261,s125034577,Accepted,"n = int(input()) words = [] for i in range(n): words.append(input()) words_set = list(set(words)) ans = 'Yes' if len(words) == len(words_set): b = words[0][-1] for i in range(1, n): if b == words[i][0]: b = words[i][-1] else: ans = 'No' break else: ans = 'No' print(ans)" p02725,s077292305,Wrong Answer,"k,n = map(int,input().split()) a = list(map(int,input().split())) aa = a + a for j in range(n,2*n): aa[j] = aa[j] + k dis = k for i in range((2*n)-1): tonari = aa[i+1]-aa[i] dis = min(dis,k-tonari) print(dis) print(aa)" p03327,s133654529,Accepted,"n = int(input()) if n > 999: print(""ABD"") else: print(""ABC"") " p03994,s476019019,Accepted,"s = list(input()) k = int(input()) ls = list(""abcdefghijklmnopqrstuvwxyz"") ls.sort(reverse=True) ls = [""a""] + ls[:-1] for i in range(len(s)): if i != len(s)-1: if k >= ls.index(s[i]): k -= ls.index(s[i]) s[i] = ""a"" else: continue else: k %= 26 s[-1] = ls[(ls.index(s[-1])-k)%26] print("""".join(s))" p03126,s935452259,Accepted,"import math import collections from sys import exit from itertools import product ii = lambda : int(input()) mi = lambda : map(int,input().split()) li = lambda : list(map(int,input().split())) n,m = mi() ka = [li() for _ in range(n)] food = [0]*m for i in range(n): for j in range(1,ka[i][0]+1,1): food[ka[i][j]-1] += 1 print(food.count(n))" p03711,s064242484,Accepted,"x,y = map(int, input().split()) list1 = [1,3,5,7,8,10,12] list2 = [4,6,9,11] L = [list1,list2] ans = ""No"" for i in L: if x in i and y in i: ans = ""Yes"" print(ans)" p02547,s902048464,Accepted,"n = int(input()) count = 0 ans = False for i in range(n): d1, d2 = map(int, input().split()) if d1 == d2: count += 1 else: count = 0 if count == 3: ans = True break print('Yes') if ans else print('No') " p03160,s874006908,Accepted,"# DPをとく inf=10**10 N=int(input()) H=list(map(int,input().split())) dp = [inf for _ in range(N)] # 足場Nまでにたどり着くときの最小コストとする dp[0]=0 for i in range(N): if i+1W: X-=W cnt+=1 print(cnt) " p03814,s758368581,Accepted,"s = str(input()) tmp = [0,0] for i in range(len(s)): if s[i] == 'A': tmp[0] = i break for i in reversed(range(len(s))): if s[i] == 'Z': tmp[1] = i break print(tmp[1]-tmp[0]+1)" p03637,s791076778,Accepted,"input() numbers = tuple(map(int, input().split(' '))) n_4_multiples = 0 n_2_multiples = 0 n_other = 0 for n in numbers: if n % 4 == 0: n_4_multiples += 1 elif n % 2 == 0: n_2_multiples += 1 else: n_other += 1 if n_2_multiples > 0: n_other += 1 if n_other - n_4_multiples <= 1: print('Yes') else: print('No') " p02796,s902234947,Wrong Answer,"import sys inputs = sys.stdin.readlines() n = int(inputs[0]) Y = [] for s in inputs[1:]: x, l = map(int, s.split()) Y.append((x-l+1, x+l-1)) Y.sort(key=lambda x: x[0]) cnt = 0 _, r0 = Y[0] for i in range(1, n): l, r = Y[i] if r0 < l: cnt += 1 r0 = r print(cnt)" p02718,s076889485,Accepted,"N, M = map(int, input().split()) A = list(map(int, input().split())) S = sum(A) count = 0 for a in A: if a >= S/(4*M): count += 1 if count >= M: print(""Yes"") else: print(""No"") " p03017,s392929406,Wrong Answer,"from collections import defaultdict from collections import deque from collections import Counter 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,a,b,c,d = readInts() s = readChar() if (a-b)*(c-d)<0: if ""..."" in s[max(a,b):] and ""##"" not in s[min(a,b)]: print(""Yes"") else: print(""No"") else: if ""##"" not in s[min(a,b):]: print(""Yes"") else: print(""No"")" p03076,s338861788,Accepted,"f = [] for i in range (5): f.append(int(input())) time = 0 machi = [] for i in range (5): if f[i]%10 == 0: time += f[i] else: time += f[i] + (10-f[i]%10) machi.append(10-f[i]%10) if len(machi) == 0: print(time) else: print(time-max(machi))" p02860,s569996169,Wrong Answer,"n=int(input()) s=str(input()) r=s[:3] t=s[3:] if(r==t): print(""Yes"") else: print(""No"")" p03106,s903528160,Accepted,"a,b,k = map(int,input().split()) ans=[] for i in range(1,101): if a%i==0 and b%i==0: ans.append(i) ans=sorted(ans,reverse=True) print(ans[k-1])" p02702,s371745079,Accepted,"M=2019 a=i=0 d=[0]*M p=1 for j in'0'+input()[::-1]:i=(i+int(j)*p)%M;p=p*10%M;a+=d[i];d[i]+=1 print(a)" p03286,s434505096,Wrong Answer,"N=int(input()) S = """" while N != 0: if N%2==0: S = ""0"" + S else: S = ""1"" + S N -= 1 N /= -2 print(S) " p02720,s027276605,Wrong Answer,"from collections import deque que=deque([i for i in range(1,10)]) k=int(input()) count=0 while count!=k: a=que.popleft() count+=1 if a%10==1: que.extend([10*a+1,10*a+2]) elif a%10==9: que.extend([10*a+8,10*a+9]) else: b=a*10+(a%10)-1 que.extend([b,b+1,b+2]) print(a) " p03285,s687243451,Wrong Answer,"import copy def CakesandDonuts(n): ans = ""No"" a = copy.copy(n) if n % 7 == 0 or n % 4 == 0: ans = ""Yes"" else: while a > 0: n -= 7 a -= 4 if n % 4 == 0 or a % 7 == 0: ans = ""Yes"" return ans def main(): n = int(input()) print(CakesandDonuts(n)) if __name__ == '__main__': main()" p03150,s802154165,Accepted,"k = list('keyence') s = list(input()) while len(k) > 0: if k[0] == s[0]: k.pop(0) s.pop(0) else: break while len(k) > 0: if k[-1] == s[-1]: k.pop() s.pop() else: break if len(k) == 0: print('YES') else: print('NO')" p04043,s697078953,Accepted,"# -*- coding: utf-8 -*- # 整数の入力 a, b, c = map(int, input().split()) # カウンタのクリア five_count = 0 seven_count = 0 # 5,7,5を判定 def setsu_check(x): global five_count, seven_count if x == 5: five_count+=1 elif x == 7: seven_count+=1 # 判定関数のCALL setsu_check(a) setsu_check(b) setsu_check(c) if five_count == 2 and seven_count == 1: print(""YES"") else: print(""NO"")" p02983,s434431032,Wrong Answer,"l, r = map(int, input().split()) x = 2018 cnt = 0 for i in range(l, r+1): a = i%2019 if a == 0: print(0) exit() x = min(a, x) print(x*(x+1))" p02787,s897121028,Wrong Answer,"H,N = map(int,input().split()) AB = [] for i in range(N): a,b = map(int,input().split()) AB.append([a,b]) dp = [[float('inf')]*(H+1) for i in range(N+1)] for i in range(N+1): dp[i][0] = 0 for i in range(N): for j in range(H): dp[i+1][min(j+AB[i][0],H)] = min(dp[i][min(j+AB[i][0],H)],dp[i+1][j]+AB[i][1],dp[i+1][min(j+AB[i][0],H)]) print(dp[N][H])" p03324,s006395515,Accepted,"d,n=map(int, input().split()) if n == 100: n = 101 print(n * 100 **d) " p03250,s634070236,Accepted,"a,b,c = map(int,input().split()) if a >= b and a >= c : s = str(a)+str(b) total = int(s)+c print(total) elif b >= a and b >= c: s = str(b)+str(a) total = int(s)+c print(total) elif c >= a and c >= b: s = str(c)+str(a) total = int(s)+b print(total) " p03254,s842227605,Accepted,"n,x = map(int, input().split()) line = list(map(int, input().split())) line.sort() ans = 0 for i in range(n): x -= line[i] if x < 0: break else: ans += 1 if i == n-1 and x != 0: ans -= 1 print(ans) " p02866,s207872073,Accepted,"import collections n = int(input()) d = list(map(int,input().split())) mod = 998244353 ans = 0 c = collections.Counter(d) if c[0] == 1 and d[0] == 0: ans = 1 for i in range(1,max(d)+1): if c[i] == 0: ans = 0 break ans *= pow(c[i-1],c[i],mod) ans %= mod print(ans%mod)" p03814,s211139833,Wrong Answer,"s = input() a = s.index('A') z = s.index('Z') print(z-a+1)" p02972,s531536788,Accepted,"n = int(input()) a = list(map(int, input().split())) b = [0] * n # 後ろからボールの有無を決定 for i in range(n - 1, -1, -1): cnt = 0 for j in range(2 * (i + 1), n + 1, i + 1): cnt += b[j - 1] # 条件と異なるならボールを投入 if cnt % 2 != a[i]: b[i] = 1 m = b.count(1) print(m) for i in range(n): if b[i]: print(i + 1, end=' ') " p03385,s948206455,Wrong Answer,"a=sorted(input()) if a==""abc"": print(""Yes"") else: print(""No"")" p02790,s895904272,Wrong Answer,"a, b = map(str, input().split()) num1 = int(a * int(b)) num2 = int(b * int(a)) if num1 >num2: print(num2) if num1 = 3 and n[1]==n[2]: print('Yes') else: print('No') if __name__ == '__main__': main()" p03435,s030105978,Accepted,"import sys c = [] for i in range(3): c.append(list(map(int, input().split()))) for i in range(2): arr1 = c[i] arr2 = c[i+1] d = arr1[2] - arr2[2] for j in range(2): if d != arr1[j]-arr2[j]: print('No') sys.exit(0) for i in range(2): d = c[2][i] - c[2][i+1] for j in range(2): if d != c[j][i]-c[j][i+1]: print('No') sys.exit(0) print('Yes')" p02594,s082791446,Accepted,"x = int(input()) if x >= 30: ans = ""Yes"" else: ans = ""No"" print(ans) " p03943,s057495238,Accepted,"a,b,c=map(int,input().split()) d=max(a,b,c) if d == a+b+c-d: print('Yes') else: print('No')" p02911,s683094653,Accepted,"import sys N, K, Q = map(int, input().split()) A = (int(x) for x in sys.stdin.read().split()) score = [K - Q] * (N + 1) for a in A: score[a] += 1 print(""\n"".join(""No"" if s <= 0 else ""Yes"" for s in score[1:]))" p02554,s505657049,Accepted,"n=int(input()) c=10**9+7 def pow_c(x,n,c): if n == 0: return 1 K = 1 while n > 1: if n % 2 != 0: K= (K%c)*(x%c)%c x = ((x%c)**2)%c n //= 2 return (K%c) * (x%c) %c k10=pow_c(10,n,c) k9=pow_c(9,n,c) k8=pow_c(8,n,c) ans=(k10-2*k9+k8)%c print(ans)" p02598,s767442983,Wrong Answer,"N,K = map(int,input().split()) arr = list(map(int,input().split())) denominator = sum(arr) piece = [(K+N)*arr[i]//denominator+1 for i in range(N)] print(piece) value = [arr[i]/piece[i] for i in range(N)] left = K-sum(piece) for i in range(left): j = value.index(max(value)) piece[j] += 1 value[j] = arr[j]/piece[j] print(round(max(value))) " p02939,s558067400,Wrong Answer,"import sys def input(): return sys.stdin.readline()[:-1] s=input() ans=1 mae=0 for i in range(len(s)-1): if mae: mae-=1 continue if s[i]==s[i+1]: mae=1 ans+=1 else: ans+=1 print(ans)" p03105,s120564274,Accepted,"import sys readline = sys.stdin.readline MOD = 10 ** 9 + 7 INF = float('INF') sys.setrecursionlimit(10 ** 5) def main(): a, b, c = map(int, readline().split()) print(min(c, b // a)) if __name__ == '__main__': main() " p02881,s592292854,Accepted,"n = int(input()) l = [] for i in range(1, int(n ** 0.5 + 1)): if n % i == 0: j = n // i l.append(i + j) print(min(l) - 2)" p02628,s013289188,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)" p03434,s892687828,Accepted,"N=int(input()) cards=sorted(list(map(int,input().split())))[::-1] A=sum(cards[::2]) B=sum(cards[1::2]) print(A-B)" p03274,s114167140,Accepted,"N,K = map(int,input().split()) X = list(map(int,input().split())) ans = 10**20 for i in range(N-K+1): fst = i lst = i+K-1 if X[lst]<=0: ans = min(ans,abs(X[fst])) elif X[fst]>=0: ans = min(ans,X[lst]) else: dis = max(abs(X[fst]),X[lst])+min(abs(X[fst]),X[lst])*2 ans = min(ans,dis) print(ans)" p03910,s950412562,Accepted,"n = int(input()) score = 0 i = 0 ans_list = [] while score <= n: i += 1 score += i ans_list.append(i) ans_list.remove(score - n) for k in range(len(ans_list)): print(ans_list[k])" p02678,s112076802,Accepted,"from collections import deque n,m=map(int,input().split()) path=[[] for _ in range(n+1)] for i in range(m): a,b=map(int,input().split()) path[b].append(a) path[a].append(b) q=deque() q.append(1) l=[-1]*(n+1) while q: v=q.popleft() for i in path[v]: if l[i]==-1: l[i]=v q.append(i) print('Yes') for i in l[2:]: print(i) " p03659,s358082722,Accepted,"n = int(input()) a = [int(x) for x in input().split()] cumulative_sum = [] cnt = 0 for i in range(n): cnt += a[i] cumulative_sum.append(cnt) ans = abs(cumulative_sum[0] - (cumulative_sum[-1] - cumulative_sum[0])) for i in range(n - 1): ans = min(abs(cumulative_sum[i] - (cumulative_sum[-1] - cumulative_sum[i])), ans) print(ans)" p03086,s851556385,Accepted,"s = input() s += ""B""# AGCT以外の適当な文字 max_len = 0 count = 0 for i in s: if i in ""ACGT"": count += 1 else: max_len = max(max_len,count) count = 0 print(max_len)" p02778,s463996440,Accepted,"s=input() print(len(s)*'x')" p03481,s363815541,Wrong Answer,"import math x, y = list(map(int, input().split())) ans = int(math.log2(y/x)) + 1 print(ans) " p03127,s875389404,Accepted,"def gcd(x, y): if y == 0: return x else: return gcd(y, x % y) def resolve(): n = int(input()) a = list(map(int, input().split())) ans = a[0] for x in a: ans = gcd(ans, x) print(ans) return if __name__ == ""__main__"": resolve() " p02833,s130950277,Accepted,"N = int(input()) # Nが奇数の時は2が1つもないので0 if N % 2 == 1: print(0) # Nが偶数の時は5の数を数える # N以下の2の倍数のうち # 5の倍数の数 + 25の倍数の数 + ... else: ans = 0 for i in range(1, 50): ans += (N // 5 ** i) // 2 print(ans) " p03672,s189787488,Accepted,"S = input() for i in reversed(range(len(S))): tmp = S[:i] n = len(tmp)//2 if tmp[:n] == tmp[n:]: print(len(tmp)) break" p03286,s463798057,Accepted,"N = int(input()) s = """" while N != 0: # Pythonでは負の数を割っても余りが正になる # -2で割ったときの""理想的な""余り(0or1になってくれる)は2で割った余りと同じ r = int(N % 2) # ここは-2 N = (N - r) / (-2) s += str(int(r)) # N=0の時はから文字列が返ってきてしまう if s == """": print(0) exit() else: # reverse print(s[::-1]) " p02607,s687876412,Accepted,"N = int(input()) nums = list(map(int, input().split())) cnt = 0 for i in range(N): num = i + 1 if (num % 2 == 1 and nums[i] % 2 == 1): cnt += 1 print(cnt) " p02707,s133467070,Accepted,"import numpy as np n=int(input()) #n,m=list(map(int,input().split())) a=list(map(int,input().split())) ans=np.zeros(n) for i in range(n-1): tmp= a[i] -1 ans[tmp] += 1 for i in range(n): print(int(ans[i]))" p03474,s492929175,Accepted,"a,b=map(int,input().split()) s=input() if s[a] != '-': print('No') quit() left=s[:a] right=s[a+1:] if left.isdigit()==True and right.isdigit() == True: print('Yes') else: print('No')" p03095,s886333262,Accepted,"from collections import Counter n = int(input()) s = input() mod = 10**9 + 7 S = Counter(s) a = 1 for v in S.values(): a = a*(1+v) % mod print(a-1) " p03161,s128627540,Accepted,"n, k = map(int, input().split()) h = list(map(int, input().split())) dp = [0]*n dp[1] = abs(h[1]-h[0]) for i in range(2, n): dp[i] = min(dp[i-j]+abs(h[i]-h[i-j]) for j in range(1, min(i, k)+1)) print(dp[-1]) " p03043,s884230393,Accepted,"from math import log2, ceil n, k = map(int, input().split()) ans = 0 for i in range(1, n + 1): if i >= k: ans += 1 else: ans += pow(0.5, ceil(log2(k / i))) print(ans / n)" p03821,s203015822,Accepted,"from sys import stdin def main(): readline = stdin.readline N = int(readline()) L = [list(map(int, readline().split())) for _ in range(N)] cnt = 0 for l in L[::-1]: a = l[0] + cnt b = l[1] if a % b != 0: cnt += b - a % b print(cnt) if __name__ == ""__main__"": main()" p03469,s580014579,Accepted,"date = input() print(""2018"" + date[4:])" p03821,s308847665,Accepted,"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 a = a[::-1] b = b[::-1] for i in range(n): ans += (-(a[i] + ans)) % b[i] print(ans) " p02548,s516196331,Accepted,"n = int(input()) def f(x): if n % x == 0: return n//x - 1 else: return n//x s = 0 for a in range(1, n): s += f(a) print(s)" p02970,s509263695,Accepted,"import math n, d = map(int, input().split()) print(math.ceil(n / (2 * d + 1)))" p03041,s527480317,Accepted,"n,k=map(int,input().split()) s=input() if n==k: print(s[:k-1]+s[k-1].lower()) else: print(s[:k-1]+s[k-1].lower()+s[k:n])" p03351,s893180036,Accepted,"a,b,c,d = map(int,input().split()) if (abs(b-a) <= d and abs(c-b) <= d) or (abs(a-c) <= d): print('Yes') else: print('No')" p02688,s589322121,Accepted,"N,K=map(int,input().split()) d=[] A=[] for _ in range(K): d.append(int(input())) A.append(list(map(int,input().split()))) cnt=[0 for i in range(N)] for i in range(K): for a in A[i]: cnt[a-1]+=1 print(cnt.count(0)) " p03699,s911374986,Accepted,"n=int(input()) s=[int(input()) for _ 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)" p02576,s169598716,Accepted,"import math n,x,t=map(int,input().split()) ans=math.ceil(n/x) print(ans*t)" p03059,s251396179,Accepted,"a,b,c = map(int, input().split()) print(int(b*((c+0.5)//a)))" p02848,s317867932,Accepted,"# 与えられた数値の桁数と桁値の総和を計算する. def calc_digit_sum(num): digits = sums = 0 while num > 0: digits += 1 sums += num % 10 num //= 10 return digits, sums n = int(input()) s = [((ord(ch) - 65 + n) % 26) + 65 for ch in input()] print("""".join(map(chr, s)))" p03069,s906493498,Wrong Answer,"n = int(input()) s = input() wh = [0] * n bl = [0] * n w , b = 0,0 for i in range(n): if s[i] == '.': w += 1 else: b += 1 wh[i] = w bl[i] = b ans = n wtot = wh[-1] btot = bl[-1] for i in range(n): x = (wtot - wh[i]) + bl[i] ans = min(ans, x) print (ans)" p03861,s741097452,Accepted,"a,b,x = map(int, input().split()) # a,b,x = map(int, ""9 9 2"".split()) cnt=0 alfa = b//x + 1 beta = (a-1)//x + 1 print(alfa - beta)" p03067,s904587578,Wrong Answer,"a,b,c=map(int,input().split()) print(""YES"" if a21: print('bust') else: print('win')" p02747,s177067425,Accepted,"import re S = input() hslist = [""hi"",""hihi"",""hihihi"",""hihihihi"",""hihihihihi""] if S in hslist: print(""Yes"") else: print(""No"")" p02951,s833749357,Accepted,"a,b,c = map(int, input().split()) print(0) if a-b-c >= 0 else print(abs(a-b-c))" p02572,s399777292,Wrong Answer,"import numpy as np N = int(input()) A = np.asarray(input().split()).astype(np.int) A_sq = np.square(A) Ans = ((A.sum())**2 - A_sq.sum()) // 2 % (10**9+7) print(Ans) " p03861,s703584546,Accepted,"a, b, x = [int(i) for i in input().split()] print(b // x - (a-1) // x)" p03160,s847281658,Accepted,"n = int(input()) li = [int(x) for x in input().split()] dp = [float(""inf"")]*n dp[0] = 0 dp[1] = abs(li[1]-li[0]) for i in range(2,n): dp[i] = min(dp[i-1]+abs(li[i]-li[i-1]),dp[i-2]+abs(li[i]-li[i-2])) print(dp[n-1])" p03854,s604651785,Wrong Answer,"s = input() s=s[::-1] i=0 ans=""YES"" while True: if len(s)==i: break elif s[i:i+5]==""maerd"": i+=5 elif s[i:i+7]==""remared"": i+=7 elif s[i:i+5]=='esare': i+=5 elif s[i:i+6]=='resare': i+=6 else: ans=""NO"" break print(ans) " p03030,s712674567,Wrong Answer,"from operator import itemgetter N=int(input()) A=[0]*N for i in range(N): A[i]=input().split() i=0 while i=k**i for i in range(100)))" p02823,s511048247,Accepted,"n,a,b = map(int,input().split()) margin = abs(a-b) if (a % 2 == 0 and b % 2 == 0) or (a % 2 == 1 and b % 2 == 1): print(margin//2) else: t = min(a-1, n-b) + 1 +(b-a-1)//2 print(t)" p02624,s004157574,Wrong Answer,"if __name__ == '__main__': n = int(input().strip()) ans = 0 for i in range(1, n+1): limit = int(n / i) ans += limit * (limit + 1) / 2 print(int(ans))" p03673,s993408883,Accepted,"#44 C - pushpush AC n = int(input()) a = list(map(int,input().split())) odd = [a[i] for i in range(n) if i%2 == 1] # O(n) even = [a[j] for j in range(n) if j%2 == 0]# O(n) if n%2 == 0: ans = list(reversed(odd)) + even # O(n) else: ans = list(reversed(even)) + odd # O(n) print(*ans)" p03548,s859257963,Wrong Answer,"x,y,z=map(int,input().split()) print((x-y)//(y+z))" p03951,s150823167,Wrong Answer,"import sys N = int(input()) s = input() t = input() for i in range(N): for j in range(N - i): flg = True if s[i + j] != t[j]: flg = False break if flg: print(N + i) sys.exit() print(2 * N) " p02755,s005726887,Wrong Answer,"a,b = map(int,input().split()) min8 = a/8*100 max8 = (a+1)/8*100 min10 = b*10/1 max10 = (b+1)*10/1 ans = -1 for i in range(min(int(min8),int(min10)),max(int(max8),int(max10))+1): i = float(i) if min8 < i and max8 > i and min10 < i and max10 > i: ans = int(i) print(ans) #デバッグ用 #print(ans/100*8,ans/100*10)" p02820,s259014795,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] == t[i+k]: t[i+k] = 0 print(sum([t.count(""r"")*p, t.count(""s"")*r, t.count(""p"")*s]))" p02801,s623758195,Accepted,"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'] z=input() for i in range(26): if z==alphabet[i]: print(alphabet[i+1]) " p02772,s052715262,Accepted,"n = int(input()) a = tuple(map(int, input().split())) cnt = len(list(filter(lambda x: x % 2 == 1 or (x % 3 == 0 or x % 5 == 0), a))) ans = 'APPROVED' if cnt == n else 'DENIED' print(ans) " p03351,s080276878,Wrong Answer,"a, b, c, d = list(map(int, input().split())) if abs(c-a) > d or a == c: print(""Yes"") elif abs(b-a) > d and abs(b-c) > d: print(""Yes"") elif a == b and b == c: print(""Yes"") else: print(""No"")" p02552,s436895515,Wrong Answer,"x = input() if(x==0): print(""1"") else: print(""0"")" p02688,s761500204,Accepted,"N,K = list(map(int,input().split())) r = set() for i in range(K): d = int(input()) r |= set(map(int,input().split())) print(N-len(r))" p02836,s421509149,Accepted,"S=str(input()) l=len(S) c=0 for i in range(0,l//2): if S[i]!=S[l-i-1]: c=c+1 print(c)" p02916,s837534225,Accepted,"n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) c = list(map(int, input().split())) r=0 k=-9 for i,j in enumerate(a): r+=b[j-1] if j-1==k+1: r+=c[j-2] k=j-1 print(r)" p03545,s555756631,Accepted,"a,b,c,d = input() for i in range(2**3): ku = [""+"", ""+"", ""+""] for j in range(len(ku)): if(i>>j)&1: ku[j]= ""-"" if eval(a+ku[0]+b+ku[1]+c+ku[2]+d) == 7: print(a+ku[0]+b+ku[1]+c+ku[2]+d+""=7"") break" p03711,s666464356,Accepted,"l = set(map(int,input().split())) print('Yes'if l <= set([1,3,5,7,8,10,12])or l <= set([4,6,9,11] )else 'No') " p03261,s360311318,Accepted,"import sys n = int(input()) w = [input() for i in range(n)] if len(w) != len(set(w)): print('No') sys.exit() else: for i, name in enumerate(w): try: if name[-1] != w[i+1][0]: print('No') sys.exit() except IndexError: print('Yes')" p03994,s182593338,Wrong Answer,"print(ord(""z"") - ord(""a"")) s=list(input()) K=int(input()) for i in range(len(s)-1): a= ord(""z"")+1 - ord(s[i]) if K>=a: s[i]=""a"" K-=a print(K) if K: s[-1]=chr((K+ord(s[-1])-ord(""a""))%(ord(""z"") - ord(""a"")+1)+ord(""a"")) print("""".join(s)) " p03433,s408966609,Accepted,"a,b=int(input()),int(input()) print(""Yes"") if a%500<=b else print(""No"")" p02909,s661643038,Accepted,"S = input() climate = [""Sunny"", ""Cloudy"", ""Rainy""] print(climate[(climate.index(S)+1)%3])" p03037,s654569871,Accepted,"N, M = map(int, input().split()) L = [] R = [] for _ in range(M): l, r = map(int, input().split()) L.append(l) R.append(r) l = max(L) r = min(R) print(r-l+1 if r-l+1 > 0 else 0)" p02843,s576324401,Accepted,"X = int(input()) num = [105, 104, 103, 102, 101, 100] dp = [0 for _ in range(X+1)] dp[0] = 1 f = 1 for i in range(X+1): for j in num: if i-j >= 0: if dp[i-j]: dp[i] = 1 print(dp[X])" p02879,s830527774,Wrong Answer,"A, B = map(int, input().split()) if((A and B)<=9): print(int(A*B)) else: print('-1')" p02924,s615045440,Accepted,"N = int(input()) print(N * (N - 1) // 2) " p03329,s126670478,Wrong Answer,"N = int(input()) withdrawal_amount_list = sorted( [9**3, 9**2, 9, 6**3, 6**2, 6, 1], reverse=True) count = 0 for price in withdrawal_amount_list: if N >= price: count += (N // price) N %= price print(count)" p02814,s480305178,Wrong Answer,"import sys from fractions import gcd read = sys.stdin.read N, M, *a = map(int, read().split()) lcm = a[0] for i in a: g = gcd(lcm, i) lcm = lcm * i // g lcm //= 2 if M < lcm: print(0) else: print((M - lcm) // (lcm * 2) + 1) " p03076,s198051175,Accepted,"a = [] for _ in range(5): a.append(int(input())) res = 0 last_num = a[0] for i in range(5): if a[i] % 10 == 0: res += a[i] else: if last_num % 10 == 0: last_num = a[i] elif a[i] % 10 < last_num % 10: last_num = a[i] res += (a[i] // 10 + 1) * 10 if last_num % 10 != 0: res -= 10 - last_num % 10 print(res) " p02548,s355909059,Accepted,"n = int(input()) ans = 0 for i in range(1,n): for j in range(1,n): if n <= i*j: break else: ans += 1 print(ans)" p04044,s804861373,Accepted,"n = [int(tmp) for tmp in input().split()] a = [] for i in range(n[0]) : s = input() a.append(s) a.sort() print(''.join(a))" p02761,s717884374,Accepted,"n,m=map(int,input().split()) sc=[list(map(int,input().split())) for i in range(m)] start=10**(n-1) end=10**n if n == 1: start = 0 for i in range(start,end): i=str(i) for s,c in sc: if i[s-1] != str(c): break else: print(i) exit() print(-1)" p03327,s020146294,Wrong Answer,"n = int(input()) if n < 1000: print('ABC{:03d}'.format(n)) else: print('ABD{:03d}'.format(n - 1000 + 1)) " p03665,s962521016,Accepted,"N,P = map(int, input().split()) A = [int(a) for a in input().split()] even = 0 odd = 0 for a in A: if a%2 == 0: even += 1 else: odd += 1 if odd == 0: if P == 0: ans = pow(2, N) else: ans = 0 else: ans = pow(2, N-1) print(ans)" p02578,s699452303,Wrong Answer,"N=int(input()) A=list(map(int,input().split())) a=0 s=[] for i in A: if i= c: print('Yes') else: print('No') if __name__ == '__main__': main()" p02696,s223163922,Wrong Answer,"a, b , n = map(int, input().split()) def floor_abx(a, b, x): return int(a*x/b) - int(x/b)*a res = 0 for i in range(n+1-a, n+1): num = floor_abx(a, b, i) if res < num: res = num for i in range(1, a): num = floor_abx(a, b, i) if res < num: res = num print(res)" p03419,s573160725,Wrong Answer,"n, m = map(int, input().split()) if n == 1 and m == 1: print(0) elif n == 1: print(m - 2) elif m == 1: print(n - 2) else: print((n - 2) * (m - 2))" p03814,s832316138,Accepted,"s=input().rstrip() print(s.rfind('Z')-s.find('A')+1)" p03319,s201641373,Accepted,"import collections n, k = map(int, input().split()) a = list(map(int, input().split())) c= collections.Counter(a) length = n - c.most_common()[0][1] + 1 if length == 1: ans = 0 else: ans = (length + k - 3) // (k - 1) print(ans)" p02622,s800391375,Accepted,"S=input() T=input() x=0 for i in range(len(S)): if S[i]!=T[i]: x+=1 print(x)" p04005,s871565803,Wrong Answer,"import sys INF = 1 << 60 MOD = 10**9 + 7 # 998244353 sys.setrecursionlimit(2147483647) input = lambda:sys.stdin.readline().rstrip() def resolve(): a, b, c = map(int, input().split()) if ~a&1 and ~b&1 and ~c&1: print(0) else: print(min(a * b, b * c, c * a)) resolve()" p03062,s251844839,Accepted,"n = int(input()) lst = list(map(int, input().split())) count = 0 ans = 0 for i in range(n): if lst[i] < 0: count += 1 lst[i] = abs(lst[i]) ans += lst[i] if count % 2 == 1: ans -= 2*min(lst) print(ans)" p02706,s260532727,Accepted,"N,M=map(int,input().split()) A=list(map(int,input().split())) if N-sum(A)>=0: print(N-sum(A)) else: print(-1)" p03103,s226746569,Wrong Answer,"N, M = map(int, input().split()) dic_1 = dict() for i in range(N): a, b = map(int, input().split()) dic_1[a] = b dic_2 = sorted(dic_1.items()) cost = 0 cost_prev = 0 cnt = 0 cnt_prev = 0 flg = False for key, value in dic_2: if flg: break cost += key*value cnt += value if cnt >= M: dif = M-cnt_prev cost_prev += key*dif flg = True if flg == False: cost_prev = cost cnt_prev = cnt print(cost_prev) " p03345,s967677464,Accepted,"A,B,C,K=map(int,input().split()) if abs(A-B)>10**18: print(""Unfair"") else: print((A-B)*(-1)**K) " p02911,s188572904,Accepted,"n , k , q = map(int,input().split()) p = [0 for i in range(n)] for i in range(q): a = int(input()) p[a-1] += 1 for i in range(n): if k - q + p[i] <= 0: print(""No"") else: print(""Yes"")" p02633,s282921215,Accepted,"def main(): X = int(input()) t = 0 for i in range(10**5): t += X if t % 360 == 0: return i + 1 print(main()) " p03274,s622817805,Wrong Answer,"N, K = list(map(int,input().split())) xlist = list(map(int,input().split())) def f(min1,max1): #min1 = list1[0] #max1 = list1[-1] if min1>=0 and max1>=0: return abs(max1) elif min1<=0 and max1 <=0: return abs(min1) else: return min([-2*min1 + max1,-min1 + 2*max1]) ans = 2*10**8 + 2 for i in range(N-K+1): min1 = xlist[i] max1 = xlist[i+K-1] dist =f (min1,max1) if dist < ans : ans = dist print(ans)" p03289,s911537951,Accepted,"s=input() print(""AC"" if ""C"" in s[2:-1] and ""A"" in s and s[1:].replace(""C"","""",1).islower() else ""WA"")" p02897,s169611807,Accepted,"n = int(input()) if n % 2 == 0: o = n//2 else: o = (n+1)// 2 print(o / n) " p02645,s539388497,Wrong Answer,"S = input() S[0:3]" p02880,s697131766,Accepted,"n = int(input()) for i in range(1,10): for j in range(1,10): if n == i*j: print('Yes') exit() print('No')" p02911,s178558684,Accepted,"n,k,q=map(int,input().split()) a,b=[int(input()) for _ in range(q)],[0]*n for i in a: b[i-1]+=1 for i in b: print('Yes' if i+k-q>0 else 'No')" p03673,s304790210,Wrong Answer,"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.append(A[i]) else: B.appendleft(A[i]) print(*B)" p02657,s312560763,Accepted,"A,B = map(int,input().split()) print(A*B) " p04011,s868911116,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)" p03696,s152267242,Accepted,"N = int(input()) S = input() left = 0 right = 0 cnt1 = 0 for i in S: if i == '(': left += 1 else: right += 1 cnt1 = max(cnt1, right - left) left = 0 right = 0 cnt2 = 0 for i in S[::-1]: if i == ')': left += 1 else: right += 1 cnt2 = max(cnt2, right - left) ans = '(' * max(0, cnt1) + S + ')' * max(0, cnt2) print(ans)" p03632,s053859698,Accepted,"a, b, c, d = map(int, input().split()) if b <= c or d <= a: print(0) elif a <= c and d <= b: print(d - c) elif a <= c and b <= d: print(b - c) elif c <= a and b <= d: print(b - a) elif c <= a and d <= b: print(d - a)" p02973,s754346449,Accepted,"from collections import deque from bisect import bisect_left N = int(input()) A = [int(input()) for _ in range(N)] t = deque([A[0]]) for a in A[1:]: if a <= t[0]: t.appendleft(a) else: t[bisect_left(t, a) - 1] = a print(len(t)) " p03698,s561247938,Accepted,"# coding: utf-8 S = list(input()) T = list(set(S)) print(""yes"" if len(S) == len(T) else ""no"") " p02600,s111089846,Accepted,"n = int(input()) if 400 <= n <= 599: print(8) elif 600 <= n <= 799: print(7) elif 800 <= n <= 999: print(6) elif 1000 <= n <= 1199: print(5) elif 1200 <= n <= 1399: print(4) elif 1400 <= n <= 1599: print(3) elif 1600 <= n <= 1799: print(2) else: print(1)" p03380,s763547321,Accepted,"n,a=open(0) *a,=map(int,a.split()) m=max(a) print(m,min((abs(m-2*i),i)for i in a)[1]) " p02910,s641946453,Wrong Answer,"s=list(input()) x=''.join(s[0::2]) y=''.join(s[1::2]) if 'R' in x and 'D' in x and 'U' in x: print('Yes') else: print('No')" p03011,s192764462,Accepted,"import sys stdin = sys.stdin mod = 1000000007 ni = lambda: int(ns()) na = lambda: list(map(int, stdin.readline().split())) ns = lambda: stdin.readline().rstrip() nas = lambda: stdin.readline().split() m = na() m.sort() print(m[0] + m[1])" p03220,s074443135,Accepted,"n = int(input()) t,a = map(int,input().split()) ls = list(map(int,input().split())) p = 0 j = 0 for i in range(n): if i ==0: tem = t - 0.006*ls[i] ans = abs(tem-a) j = 1 else: tem = t - 0.006*ls[i] if ans - abs(tem-a) >0: ans = abs(tem-a) j = i + 1 print(j) " p02881,s130379099,Wrong Answer,"import itertools n = int(input()) 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 l = [] for it in itertools.combinations(divisor(n),2): if it[0] * it[1] == n: l.append(it[0] + it[1] -2) print(sorted(l)[0])" p03145,s625858094,Accepted,"import sys sys.setrecursionlimit(10**8) 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 li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)] def dp2(ini, i, j): return [[ini]*i for _ in range(j)] #import bisect #bisect.bisect_left(B, a) #from collections import defaultdict #d = defaultdict(int) d[key] += value #from collections import Counter # a = Counter(A).most_common() #from itertools import accumulate #list(accumulate(A)) A = sorted(li()) print(A[0] * A[1] // 2)" p03030,s833605872,Accepted,"def main(): n = int(input()) s = sorted([input().split()+[i+1] for i in range(n)],key=lambda x:(x[0],-int(x[1]))) for i in range(n): print(s[i][2]) if __name__ == '__main__': main() " p02623,s698182909,Accepted,"from bisect import bisect_right N,M,K = map(int,input().split()) A = [0]+list(map(int,input().split())) B = [0]+list(map(int,input().split())) for i in range(1,N+1,1): A[i]=A[i-1]+A[i] for i in range(1,M+1,1): B[i]=B[i-1]+B[i] ans = 0 for i in range(0,N+1,1): j = bisect_right(B,K-A[i])-1 if K-A[i]>=0: ans = max(ans,i+j) print(ans)" p03435,s904819150,Wrong Answer,"c=[list(map(int, input().split())) for _ in range(3)] p=sum(c[0])%3 print(""Yes"" if (sum(c[1])-p)%3==(sum(c[2])-p)%3==0 else ""No"")" p02707,s603444403,Accepted,"import sys readline = sys.stdin.readline N = int(readline()) A = list(map(int,readline().split())) ans = [0] * N for i in range(len(A)): ans[A[i] - 1] += 1 for a in ans: print(a)" p03645,s302984699,Accepted,"N,M=map(int,input().split()) a=[[int(i) for i in input().split()] for l in range(M)] l=[] for x in a: if x[0]==1:l.append(x[1]) m=[] for x in a: if x[1]==N:m.append(x[0]) if set(l) & set(m): print(""POSSIBLE"") exit(0) print(""IMPOSSIBLE"")" p02765,s885873066,Accepted,"n, r = map(int, input().split()) if n >= 10: print(r) else: print(r + (100 * (10-n))) " p02624,s082876113,Accepted,"n=int(input()) a = [i for i in range(n+1)] res=0 time = 0 for i in range(1,n+1): cnt = n // a[i] res += a[i]*cnt*(cnt+1)//2 #print(res) print(res)" p03632,s623162362,Accepted,"l = list(map(int,input().split())) if l[1] < l[2]: print(0) elif l[0] > l[3]: print(0) else: l.sort() print(l[2]-l[1])" p03524,s091616234,Accepted,"S = input() A = S.count('a') B = S.count('b') C = S.count('c') M = max(A, B, C) if (A == M or A == M - 1) and (B == M or B == M - 1) and (C == M or C == M - 1): print('YES') else: print('NO')" p02578,s309782250,Wrong Answer,"n=int(input()) a = list(map(int,input().split())) b = a[0] total=0 for i in a: if i> j) & 1 == 0: continue money += a[j] for k in range(m): ex[k] += b[j][k] if all(x <= l for l in ex): ans = min(ans,money) if ans == 10**9: print(-1) else: print(ans)" p02760,s824385661,Accepted,"import numpy as np A = np.array(list(list(map(int, input().split())) for l in range(3))) N = int(input()) b = np.array(list(int(input()) for l in range(N))) bingo = np.zeros((3, 3)) bingo = bingo == 1 for b_i in b: hantei = A == b_i bingo = np.logical_or(bingo, hantei) for i in range(3): if all(bingo[i]) or all(bingo[:,i]): print('Yes') exit() if (bingo[0,0] and bingo[1,1] and bingo[2,2]) or (bingo[0,2] and bingo[1,1] and bingo[2,0]): print('Yes') exit() print('No')" p02699,s234046420,Accepted,"s,w = map(int,input().split()) if w >= s: print('unsafe') else: print('safe') " p03160,s816620492,Accepted,"# 参考: # https://qiita.com/drken/items/dc53c683d6de8aeacf5a # ver 2,振り返る DP n=int(input()) a=list(map(int,input().split())) # dp には 足場(i)へ至る最小コストが入る。 dp=[float(""inf"")]*(n) # 振り返り起点(i==2)までのdp値は埋めておく。 dp[0]=0 dp[1]=abs(a[1]-a[0]) for i in range(2,n): dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]), dp[i-2]+abs(a[i]-a[i-2])) print(dp[-1]) " p03160,s345543756,Accepted,"import math N = int(input()) h = list(map(int, input().split())) dp = [float('INF')] * (10**5 + 10) def chmin(a, b): if a >= b: return b else: return a dp[0] = 0 #初期値 = 0 for i in range(N-1): dp[i+1] = chmin(dp[i+1], dp[i] + abs(h[i+1] - h[i])) if i < N-2: dp[i+2] = chmin(dp[i+2], dp[i] + abs(h[i+2] - h[i])) print(dp[N-1])" p04019,s176953522,Wrong Answer,"S = input() if S.count(""N"")==S.count(""S"") and S.count(""E"") == S.count(""W""): print(""YES"") else: print(""NO"")" p02555,s901825191,Wrong Answer,"N = int(input()) MOD = 10 ** 9 + 7 dp = [0] * 2010 dp[0] = 1 for i in range(3, N + 1): for j in range(3, N + 1): dp[i] += dp[i - j] % MOD print(dp[N]) " p02778,s973952044,Accepted,"S = input() print(len(S)*""x"")" p03062,s897838866,Accepted,"n = int(input()) a = list(map(int, input().split())) if a[0]<0: count=1 else: count = 0 ans, mina = abs(a[0]), abs(a[0]) flag = False for i in range(1, n): ans += abs(a[i]) mina = min(mina, abs(a[i])) if a[i]<0: count += 1 if count%2 or a.count(0): print(ans-mina*2) else: print(ans)" p02982,s978762211,Wrong Answer,"import math def dis(a,b,D): t = 0 for i in range(D): t += (a[i] -b[i])**2 t = t**0.5 return t N,D = map(int,input().split()) X = [] C =[] for i in range(N): X.append(list(map(int,input().split()))) for i in range(N-1): for j in range(i+1,N): C.append(dis(X[i],X[j],D)) ans = 0 for i in C: if math.floor(i) == math.ceil(i): ans = 1 print(ans)" p04005,s069636390,Accepted,"a,b,c = [int(x) for x in input().split()] if a % 2 == 0 or b % 2 == 0 or c % 2 == 0: print(0) else: print(min(a*b,b*c,c*a))" p02594,s766859088,Accepted," x=int(input()) if x>=30: print('Yes') else: print('No')" p02912,s669778605,Accepted,"import heapq n,m=map(int,input().split()) a=list(map(lambda x:int(x)*(-1),input().split())) heapq.heapify(a) for _ in range(m): tmp_min=heapq.heappop(a) heapq.heappush(a,(-1)*(-tmp_min//2)) print(-sum(a))" p02603,s113074504,Accepted,"n = int(input()) a = list(map(int,input().split())) kane = 1000 kabu = 0 for i in range(1, n): if a[i] > a[i-1]: kabu = kane // a[i-1] kane = kane - kabu*a[i-1] kane = kane + kabu*a[i] kabu = 0 print(kane)" p02602,s716159421,Accepted,"def main(): import sys N,K=list(map(int,sys.stdin.readline().split())) A=list(map(int,sys.stdin.readline().split())) L=[0]*N n=0 for i in range(K,N): if A[i]<=A[n]: print('No') else: print('Yes') n+=1 main()" p03289,s566065714,Accepted,"import re def answer(s: str) -> str: pattern = r'^A[a-z]+C[a-z]+$' return 'AC' if re.match(pattern, s) else 'WA' def main(): s = input() print(answer(s)) if __name__ == '__main__': main() " p03262,s745378946,Accepted,"from collections import deque from fractions import gcd import functools n, x = map(int, input().split()) xl = list(map(int, input().split())) xl.append(x) xl.sort() l = deque() for i in range(n): l.append(xl[i+1] - xl[i]) l = list(set(l)) ans = functools.reduce(gcd, l) print(ans)" p02681,s727778173,Accepted,"S, T = input(), input() if S == T[:-1]: print('Yes') else: print('No')" p03680,s519609994,Accepted,"n = int(input()) a = [int(input()) for i in range(n)] b = 1 for j in range(n): b = a[b - 1] if b == 2: print(j + 1) break if b != 2: print(-1)" p03962,s260566670,Accepted,"A = list(input().split()) print(len(set(A)))" p03680,s246471323,Accepted,"# B - Trained? def main(): n = int(input()) a = [int(input()) for _ in range(n)] cnt = 0 x = 1 if 2 in a: for _ in range(n-1): x = a[x-1] cnt += 1 if x == 2: print(cnt) exit() else: print(-1) else: print(-1) if __name__ == ""__main__"": main()" p03815,s452063435,Accepted,"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)" p02687,s519068740,Accepted,"S = input() if S == ""ABC"": print(""ARC"") else: print(""ABC"") " p02700,s594215433,Accepted,"A, B, C, D = map(int, input().split()) turn_flag = True for i in range(0, 100): if turn_flag: C -= B if C <= 0: break turn_flag = False else: A -= D if A <= 0: break turn_flag = True # print(A,B,C,D) if turn_flag: print('Yes') else: print('No')" p03293,s415553494,Accepted,"S = list(input()) N = len(S) T = input() S += S A = [''.join(S[i:i+N]) for i in range(N)] if T in A: print('Yes') else: print('No')" p03324,s389155608,Accepted,"d,n=map(int,input().split()) if(n!=100): print(100**d*n) if(n==100): print(100**d*(n+1)) " p03071,s151013668,Accepted,"a,b=map(int,input().split()) print(max(a,b)*2-(a!=b))" p02767,s574246267,Wrong Answer,"n = int(input()) x = list(map(int, input().split())) ans = float('inf') for s in range(min(x),max(x)): ans_pre = 0 for i in x: ans_pre += (i-s)**2 ans = min(ans,ans_pre) print(ans) " p03109,s233705428,Accepted,"S = input() print('Heisei' if S[5:7] < '04' or (S[6] == '4' and S[8:] < '31') else 'TBD')" p03695,s460258189,Accepted,"n = int(input()) a = list(map(int,input().split())) color = [399, 799, 1199, 1599, 1999, 2399, 2799, 3199, 4800] num = [0]*9 for i in a: for j in range(9): if i<=color[j]: num[j]+=1 break s = [1 for i in num[:8] if i>0] print(max(sum(s), 1), sum(s)+num[8])" p03210,s619262809,Accepted,"x=int(input()) if x==3 or x==5 or x==7: print('YES') else : print('NO') " p03645,s314408381,Wrong Answer," n,m = map(int,input().split()) lis = [[] for i in range(n)] #なぜか知らんけど[[]]*nじゃだめらしい for i in range(m): a,b = map(int,input().split()) lis[a-1].append(b-1) lis[b-1].append(a-1) for i in lis[0]: if i in set(lis[-1]): print('POSSIBLE') exit() " p02832,s753949639,Accepted,"n=int(input()) a=list(map(int,input().split())) x=1 ans=0 for i in range(n): if a[i]!=x: ans+=1 else: x+=1 if ans==n: print(-1) else: print(ans) " p03795,s719075522,Accepted,"n = int(input()) print(n * 800 - int(n/15)*200)" p02897,s512809475,Accepted,"N=int(input()) print((N-(N//2))/N)" p02983,s601845163,Wrong Answer,"L,R = map(int,input().split()) if R-L+1>=673: print(0) else: cmin = 2019 for i in range(L,R-1): for j in range(i+1,R): cmin = min(cmin,(i*j)%2019) print(cmin)" p03657,s512384692,Wrong Answer,"a,b=map(int,input().split()) c=a+b if a%3==0 or b&3==0 or c%3==0: print(""Possible"") else: print(""Impossible"")" p02570,s900735087,Accepted,"D,T,S=map(int, input().split()) print(""Yes"" if T*S>=D else ""No"")" p03486,s552956531,Accepted,"s = input() t = input() s = sorted(s) t = sorted(t,reverse=True) flag = 0 for i in range(min(len(s),len(t))): if s[i] < t[i]: flag = 1 break if len(s) < len(t) and s == t[:len(s)]: flag = 1 if flag == 1: print(""Yes"") else: print(""No"") " p03479,s057955527,Wrong Answer,"import math from fractions import Fraction x,y=map(int, input().split()) print(int(math.log(Fraction(y,x),2))+1)" p03699,s259965958,Wrong Answer,"n = int(input()) s = [] for i in range(n): s += [int(input())] a = sum(s) if a % 10 != 0: print(a) exit() else: for i in range(n): if s[i] % 10 != 0: a -= s[i] if a % 10 != 0: print(a) f = 0 exit() else: f = 1 if f: print(0)" p03998,s726300787,Accepted,"a=list(input()) b=list(input()) c=list(input()) abc=[a,b,c] name=['a','b','c'] now=0 while True: if len(abc[now])==0: print(name[now].upper()) exit() now=name.index(abc[now].pop(0)) " p03284,s369698157,Wrong Answer,"n,k=map(int,input().split()) if n%k: print(0) else: print(1)" p02775,s081830204,Accepted,"n = input() a = n[::-1] + ""0"" prev_a = int(a[0]) prev_b = 10 - int(a[0]) # dp[下の桁から][繰り上げるかどうか] for i in range(1, len(a)): x = int(a[i]) y = x + 1 aa = min([x + prev_a, y + prev_b]) bb = min([(10 - x) + prev_a, (10 - y) + prev_b]) prev_a = aa prev_b = bb print(min(aa, bb))" p02601,s084265609,Accepted,"A, B, C = map(int,input().split()) K = int(input()) c = 0 while(A >= B): c += 1 B *= 2 while(B >= C): c += 1 C *= 2 if(c<=K): print(""Yes"") else: print(""No"")" p02753,s314615685,Wrong Answer,"from sys import stdin def get_result(data): S = data[0] return 'Yes' if S != 'AAA' and S != 'BBB' else 'No' if __name__ == '__main__': data = list(map(str, stdin.readline().split(' '))) result = get_result(data) print(result) " p02584,s176437478,Wrong Answer,"X,K,D = map(int,input().split()) A = abs(X) ans = 0 if A >= D*K: ans = A - (D * K) K = 0 else : ans = A - (A//D)*D K = K - (A//D) if K%2 == 1: ans = A - D print(abs(ans))" p03779,s232065867,Accepted,"import sys readline = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 8) INF = float('inf') MOD = 10 ** 9 + 7 def main(): X = int(readline()) X *=2 i = 1 while True: if i**2 + i >= X: print(i) break else: i += 1 if __name__ == '__main__': main()" p02712,s406898440,Accepted,"N = int(input()) res = [] for i in range(1, N+1): #if i%3 == 0 or i%5 == 0: if i%3 != 0 and i%5 != 0: res.append(i) print(sum(res))" p02608,s925909333,Accepted,"n = int(input()) cnt = [0 for i in range(n+1)] for x in range(1, 101): for y in range(1, 101): for z in range(1, 101): ind = (x+y+z)**2-x*y-y*z-z*x if ind > 0 and ind < n+1: cnt[ind] += 1 for i in range(n): print(cnt[i+1])" p02696,s902469064,Wrong Answer,"import math A,B,N=map(int,input().split()) A=float(A) B=float(B) maxi=0 for x in range(N): x=float(x) if math.floor(A*x/B)-A*math.floor(x/B) >=maxi: maxi = math.floor(A*x/B)-A*math.floor(x/B) print(int(maxi))" p02577,s789072244,Accepted,"# AtCoder Beginner Contest 176 # B - Multiple of 9 N=input() ls=list(map(int,N)) lssum=sum(ls) if lssum%9==0: print('Yes') else : print('No')" p02912,s167925701,Accepted,"import heapq N, M = map(int, input().split()) A = [-int(a) for a in input().split()] H = [] for a in A: heapq.heappush(H, a) for m in range(M): tmp = abs(heapq.heappop(H)) // 2 heapq.heappush(H, -tmp) SUM_A = 0 for h in H: SUM_A += int(h) print(-SUM_A) " p02911,s257495990,Wrong Answer,"import sys n,k,q=map(int,input().split()) a=[int(input()) for i in range(q)] if k>q: for i in range(n): print('Yes') sys.exit() d=[0]*n for i in range(q): d[a[i]-1]=d[a[i]-1]+1 print(d) for j in d: if j>q-k: print('Yes') else: print('No')" p02795,s944647830,Accepted,"def main(): H = int(input()) W = int(input()) N = int(input()) ans = N // max(H, W) if N % max(H, W) == 0 else N // max(H, W) + 1 print(ans) if __name__ == ""__main__"": main()" p02790,s049854375,Accepted,"a, b = input().split() ax = a*int(b) bx = b*int(a) if ax 0: print(""Positive"") elif a <= 0 and 0 <= b: print(""Zero"") else: if (b-a) % 2 == 1: print(""Positive"") else: print(""Negative"")" p02795,s316667539,Accepted,"H = int(input()) W = int(input()) N = int(input()) cnt, paint = 0, 0 while paint < N: paint += max(H,W) cnt += 1 print(cnt)" p02621,s233958963,Accepted,"a = int(input()) print( a + a**2 + a**3 )" p02818,s244327147,Accepted,"A, B, K = map(int,input().split()) r1 = A r2 = B if A >= K: r1 = A - K elif B > (K - A): r1 = 0 r2 = r2 - (K - A) else: r1 = 0 r2 = 0 print(r1, r2)" p02983,s304926172,Wrong Answer,"L,R = map(int,input().split()) if L==R: print(L%2019 * L%2019) exit() if R-L >= 2019: print(0) exit() l = L%2019 r = R%2019 res = 2018 for i in range(l, r+1): for j in range(i+1,r+1): if i*j == 0: print(0) exit() res = min(res, i*j) print(res) " p02629,s259673131,Accepted,"s = int(input()) ans = """" while (s > 0): s -= 1 ans += chr((s % 26) + ord(""a"")) s //= 26 print(ans[::-1]) " p03998,s047301371,Accepted,"s = [list(input()) for _ in range(3)] t = 'a' while True: t_num = ord(t)-97 if len(s[t_num])<1: winner = chr(t_num+65) break t = s[t_num].pop(0) print(winner)" p02595,s119355967,Accepted,"import math n, d = map(int, input().split()) sum = 0 for i in range(n): x, y = map(int, input().split()) if math.sqrt(x*x + y*y) <= d: sum += 1 print(sum)" p02860,s622299514,Wrong Answer,"n = int(input()) s = input() m = int(n/2) print(s[0:m]) print(s[m:]) if s[0:m] == s[m:]: print(""Yes"") else: print(""No"") " p02819,s552406236,Accepted,"n=int(input()) while True: judge=False count = 0 for i in range(2, n): if n%i==0: n+=1 judge=True break if judge: continue print(n) break" p02768,s590033823,Accepted,"n,a,b = map(int,input().split()) mod = 10**9 + 7 ans = pow(2,n,mod) - 1 fa = 1 fb = 1 for i in range(1, a+1): fa *= i fa %= mod for i in range(1, b+1): fb *= i fb %= mod fa = pow(fa, mod-2, mod) fb = pow(fb, mod-2, mod) for i in range(a): fa *= n - i fa %= mod for i in range(b): fb *= n - i fb %= mod print((ans - fa - fb) % mod)" p02963,s925257881,Wrong Answer,"n=int(input()) a=-(-n//(10**9)) b=10**9-(n%(10**9)) print(0,0,10**9,b,a,1)" p02924,s478329685,Accepted,"n = int(input()) ans = n * (n // 2) if (n - 1) % 2 == 0: print(ans) else: print(ans - int(n / 2)) " p02994,s643920544,Accepted,"n, l = map(int, input().split()) t = float(""inf"") s = 0 for i in range(n): s += i + l if abs(t) > abs(i + l): t = i+l print(s - t) " p03698,s122779256,Wrong Answer,"import string al = string.ascii_lowercase S = input() ans = ""Yes"" for a in al: if S.count(a) > 1: ans = ""No"" print(ans) " p02899,s100641070,Accepted,"n = int(input()) a = list(map(int, input().split())) dic = {} for i in range(n): dic[a[i]] = i+1 for i in range(n): print(dic[i+1])" p04034,s886619387,Accepted,"import sys N, M = map(int, sys.stdin.readline().rstrip().split()) opes = [] for _ in range(M): x, y = map(int, sys.stdin.readline().rstrip().split()) opes.append((x-1, y-1)) transported = set() transported.add(0) boxes = [1 for _ in range(N)] for (x, y) in opes: boxes[x] -= 1 boxes[y] += 1 if x in transported: transported.add(y) if boxes[x] == 0 and x in transported: transported.remove(x) print(len(transported))" p03434,s063247360,Accepted,"N =int(input()) a = list(map(int,input().split())) alice=0 bob=0 a.sort(reverse=True) for i in range(N): if i%2==0: alice =alice+a[i] if i%2==1: bob = bob+a[i] ans = alice-bob print(ans)" p03493,s084116295,Accepted,"s=input() count=0 for i in s: if i == '1': count+=1 print(count) " p03360,s547144576,Accepted,"A, B, C = map(int, input().split()) K = int(input()) s = A + B + C m = max(A, B, C) print(s + (2**K - 1) * m)" p02601,s983184888,Accepted,"a,b,c=map(int, input().split()) k=int(input()) co=0 while not (a= c: flag = False break else: ans += 1 print(str(ans)) " p02618,s124914181,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=0 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) " p02959,s572744833,Accepted,"N = int(input()) A = [int(x) for x in input().split()] B = [int(x) for x in input().split()] ans = 0 for i in range(N): min_ = min(A[i], B[i]) A[i] -= min_ B[i] -= min_ ans += min_ min_ = min(A[i+1], B[i]) A[i+1] -= min_ B[i] -= min_ ans += min_ print(ans) " p03860,s728629269,Accepted,"s = input().split() print('A' + s[1][0] + 'C')" p02811,s322397547,Accepted,"i = list(map(int, input(). split())) K = (i[0] * 500) if K >= i[1]: print(""Yes"") else: print(""No"")" p02552,s897360314,Accepted,"x=int(input()) print(x^1)" p02697,s502918749,Accepted,"n, m = map(int, input().split()) ans = [[0, 0] for _ in range(m)] import math M = math.ceil(m / 2) for i in range(M): ans[i][0] = i + 1 ans[i][1] = ans[i][0] + (M * 2 - 1 - 2 * i) cur = M * 2 M2 = m // 2 for i in range(M2): ans[i + M][0] = cur + i + 1 ans[i + M][1] = ans[i + M][0] + M2 * 2 - 2 * i for i in range(m): print(ans[i][0], ans[i][1]) " p03427,s980283521,Accepted,"s=input() if len(s) == 1: print(s) else: print(max((len(s)-1)*9+int(s[0])-1,sum([int(s[i]) for i in range(len(s))])))" p03624,s587626842,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 " p03779,s341757671,Accepted,"n = int(input()) cnt = 1 while True: if (cnt*cnt)+cnt >= 2*n: print(cnt) break cnt += 1" p04029,s194672753,Wrong Answer,"n = int(input()) answer = (n + 1) * n / 2 print(answer)" p02570,s850832558,Wrong Answer,"a,b,c = map(int, input().split()) if(b*c<=a): print(""Yes"") else: print(""No"")" p02760,s896336674,Accepted,"S=""012 345 678 036 147 258 048 246 "" A=sum([input().split()for i in range(3)],[]) for b in [input()for i in range(int(input()))]: if b in A: S=S.replace(str(A.index(b)),"""") print([""No"",""Yes""][S.find("" "")>-1])" p03760,s781241597,Accepted,"o=input() e=input() print() ans = """" if len(o)==len(e): for x in range(len(o)): ans += o[x] ans += e[x] else: for x in range(len(e)): ans += o[x] ans += e[x] ans += o[len(o)-1] print(ans)" p04034,s093396370,Accepted,"# coding: utf-8 N,M=map(int,input().split()) ball = [1 for i in range(N+1)] ball[0] = 0 red = [0 for i in range(N+1)] red[1] = 1 for i in range(M): x,y=map(int,input().split()) ball[x]-=1 ball[y]+=1 if red[x]: red[y]=1 if ball[x]==0: red[x]=0 print(sum(red)) " p03487,s554995313,Wrong Answer,"import collections dic = collections.defaultdict(int) n = int(input()) a = [int(i) for i in input().split()] for i in range(n): dic[a[i]] += 1 ans = 0 for key in dic.keys(): if dic[a[i]] >= a[i]: ans += (dic[a[i]] - a[i]) else: ans += dic[a[i]] print(ans)" p02582,s780304009,Accepted,"import sys def S(): return sys.stdin.readline().rstrip() S = S() if S == 'RRR': print(3) elif S == 'RRS' or S == 'SRR': print(2) elif S == 'SSS': print(0) else: print(1) " p02888,s769148624,Accepted,"# -*- coding: utf-8 -*- """""" Created on Wed Sep 9 20:56:06 2020 @author: liang """""" N = int(input()) L = [int(x) for x in input().split()] L.sort() ans = 0 #print(L) for i in range(N-2): #print(""1:"",i) p = i+2 for j in range(i+1,N-1): #print(""2"",i,j) while p < N and L[p] < L[i] + L[j] : p += 1 #print(""up"") #print(p) ans += len(L[j+1:p]) print(ans)" p02772,s114449307,Wrong Answer,"n = int(input()) L = list(map(int,input().split())) L = [x for x in L if x%2 ==0] for i in range(len(L)): if (L[i]%3 == 0 or L[i]%5== 0) and L[i]%15 != 0: flag = True else: flag =False break #print(L) if len(L) == 0: print(""DENIED"") exit() if flag: print(""APPROVED"") else: print(""DENIED"")" p02695,s269013306,Wrong Answer,"import itertools n,m,q = map(int,input().split()) li=[list(map(int,input().split())) for i in range(q)] ans = 0 num_li = itertools.combinations_with_replacement(range(1,m+1),n) for i in num_li: temp = 0 for j in li: a,b,c,d = j if i[b-1] - i[a-1] == c: temp += d ans = max(ans,temp) print(temp) print(ans)" p03145,s059797974,Accepted,"def main(): a, b, c = (int(i) for i in input().split()) print(a*b//2) if __name__ == '__main__': main() " p03281,s230119116,Accepted,"N = int(input()) count_1 = 0 for i in range(1,N+1,2): count_2 = 0 for j in range(1,i+1,2): if i % j == 0: count_2 += 1 if count_2 == 8: count_1 += 1 print(count_1) " p02726,s381296270,Accepted,"n, x, y = map(int, input().split()) result = [0 for _i in range(n)] for i in range(1, n): for j in range(i+1, n+1): result[min([j-i, abs(i-x)+1+abs(j-y), abs(i-y)+abs(j-y)])] += 1 for i in result[1:]: print(i)" p02711,s642984435,Accepted,"N = str(input()) if ""7"" in N: print(""Yes"") else: print(""No"")" p03328,s611971271,Accepted,"a, b = list(map(int, input().split())) print(sum(range(1, b - a)) - a)" p02988,s343269730,Accepted,"n = int(input()) P = list(map(int, input().split())) cnt = 0 for i in range(1, n - 1): f = 0 if P[i - 1] < P[i] and P[i] < P[i + 1]: f = 1 elif P[i -1] > P[i] and P[i] > P[i + 1]: f = 1 if f == 1: cnt += 1 print(cnt)" p03352,s180463169,Accepted,"X = int(input()) ans = 1 for i in range(2,X): j = 2 if i**j > X: continue while i**j <= X: j+=1 ans = max(ans,i**(j-1)) print(ans) " p02628,s382077662,Wrong Answer,"N, K = map(int, input().split()) A = list(map(int, input().split())) A.sort(reverse = True) min = 0 for i in range(K): min += A[i] print(min)" p02801,s580070053,Wrong Answer,print(1) p02897,s753453051,Accepted,"N = int(input()) if N%2==0: print(1/2) else: print((((N-1)/2)+1)/N)" p02548,s980882103,Accepted,"n = int(input()) cnt = 0 for a in range(1, n): for b in range(1, ((n-1)//a)+1): c = n - a*b if c <= 0: break cnt += 1 print(cnt) " p02747,s896228912,Accepted,"s=input() x=len(s) // 2 a=x*'hi' if a == s: print('Yes') else: print('No') " p03131,s165060257,Accepted,"def main(): K, A, B = (int(i) for i in input().split()) ans = 1 K -= (A-ans) ans = A if B-A > 2: ans += (B-A)*(K // 2) if K & 1: ans += 1 else: ans += 1*K print(ans) if __name__ == '__main__': main() " p02612,s567622044,Wrong Answer,"N = int(input()) for i in range(20): if(N < 1000): break N -= 1000 print(str(1000-N))" p04005,s431978585,Accepted,"A,B,C = map(int, input().split()) if A%2==0 or B%2==0 or C%2==0: print(0) else: li = sorted([A,B,C]) print(li[0] * li[1])" p03827,s660100424,Accepted,"n = int(input()) s = input() a = [] a.append(0) for i in range(n): if s[i] == 'I': a.append(a[i]+1) else: a.append(a[i]-1) print(max(a)) " p03136,s789326213,Accepted,"n=int(input()) p=list(map(int, input().split())) pm=max(p) p.remove(pm) if pm= abs(B-A) else ""NO"")" p03449,s946521063,Accepted,"import sys readline = sys.stdin.readline def main(): N = int(readline()) A1 = list(map(int, readline().rstrip().split())) A2 = list(map(int, readline().rstrip().split())) dp = [[0, 0] for _ in range(N)] dp[0][0] = A1[0] dp[0][1] = A1[0] + A2[0] for i in range(1, N): dp[i][0] = dp[i-1][0] + A1[i] dp[i][1] = max(dp[i-1][1], dp[i][0]) + A2[i] print(dp[N-1][1]) if __name__ == '__main__': main()" p03719,s295141016,Accepted,"A, B, C = map(int, input().split()) print(""Yes"" if A <= C <= B else ""No"")" p03219,s209902109,Accepted,"x,y = map(int,input().split()) print(x+(y//2))" p02818,s494445889,Accepted,"a,b,k = map(int,input().split()) if a >= k: print(a-k,b) elif a+b >= k: print(0,a+b-k) else: print(0,0)" p02793,s943467139,Accepted,"from fractions import gcd def lcm(x,y): return (x*y) // gcd(x,y) n = int(input()) a = list(map(int,input().split())) mod = 10**9+7 l = a[0] for i in range(1,n): l = lcm(l,a[i]) ans = 0 for i in range(n): ans += l//a[i] print(ans%mod)" p03524,s914330673,Accepted,"S = input() l = [] l.append(S.count(""a"")) l.append(S.count(""b"")) l.append(S.count(""c"")) if max(l) - min(l) > 1: print(""NO"") else: print(""YES"")" p02797,s018354571,Accepted,"[N,K,S] = list(map(int,input().split())) cnt = 0 if S != 1: output = [] for i in range(K): output.append(S) for i in range(N-K): cnt += 1 if cnt < S: output.append(1) else: output.append(S+1) cnt = 0 else: output = [] for i in range(K): output.append(S) for i in range(N-K): output.append(2) print("" "".join(map(str, output)))" p02742,s764149101,Wrong Answer,"h, w = map(int, input().split()) first = int(w/2) + 1 second = int((w-1)/2) if h % 2 != 0: odd_row = first * (int(h/2) + 1) else: odd_row = first * int(h/2) even_row = second * int(h/2) print(odd_row + even_row) " p03073,s398851524,Accepted,"s = input() n,m = 0,0 for i in range(len(s)): if i%2==0 and s[i]=='0': n+=1 if i%2==1 and s[i]=='1': n+=1 for i in range(len(s)): if i%2==0 and s[i]=='1': m+=1 if i%2==1 and s[i]=='0': m+=1 print(min(n,m))" p03962,s657003509,Accepted,"a,b,c=map(int,input().split()) print(len(set([a,b,c])))" p03145,s363244259,Accepted,"A,B,C = map(int,input().split()) print(A*B//2)" p02596,s724399804,Wrong Answer,"#C - Repsept K = input() K = int(K) def each_sum(n):#各桁の合計を求める s = str(n) allay = list(map(int,s))#文字列sを数値リストにして返す return(sum(allay)) def seven(): seven_i = 0 count = 0 for i in range(1,K): seven_i = (7 * ((10**i) -1 ) // 9) seven_i %= K count += 1 if seven_i % K == 0: return count return -1 print(seven())" p02909,s444124696,Accepted,"S = input() if S == 'Sunny': print('Cloudy') elif S == 'Cloudy': print('Rainy') else: print('Sunny')" p03387,s265137841,Accepted,"import sys input = sys.stdin.readline # int(input()) # 入力が1つ a, b, c = map(int, input().split()) # 入力が複数 nums = sorted([a, b, c]) ans = 0 if (nums[1] - nums[0]) % 2 != 0: nums[2] += 1 nums[1] += 1 ans += 1 ans += (nums[1] - nums[0]) // 2 ans += nums[2] - nums[1] print(ans)" p03456,s593391650,Accepted,"import math a,b=input().split("" "") n = math.sqrt(int(a+b)) if n.is_integer(): print(""Yes"") else: print(""No"")" p02959,s616960113,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+=b[i] else: res=b[i]-a[i] if a[i+1]-res<0: ans+=a[i]+a[i+1] a[i+1]=0 else: ans+=b[i] a[i+1]-=res print(ans)" p03555,s645097796,Accepted,"c = input() c1 = input() if c == c1[::-1]: print('YES') else: print('NO')" p02707,s161363945,Accepted,"n = int(input()) A = input().split() for i in range(n-1): A[i] = int(A[i]) l = [0] * n for i in range(n-1): l[A[i]-1] += 1 for i in range(n): print(l[i])" p02801,s061453465,Accepted,"s = ""abcdefghijklmnopqrstuvwxyz"" print(s[s.index(input())+1]) " p03041,s740143770,Accepted,"def main(): n, k = map(int, input().split()) s = list(input()) s[k-1] = s[k-1].lower() print(''.join(s)) if __name__ == '__main__': main()" p02578,s894896867,Wrong Answer,"n = int(input()) a = sorted(map(int,input().split())) b = [] for i in range(n-1): c = a[i+1]-a[i] if c >= 0: b.append(c) print(sum(b))" p02578,s294483600,Accepted,"n = int(input()) li = list(map(int,input().split())) ans = 0 for i in range(n): if i > 0: if li[i-1] > li[i]: ans += li[i-1]-li[i] li[i] += (li[i-1]-li[i]) print(ans) " p02823,s287548748,Accepted,"n, a, b = map(int, input().split()) if (b - a) % 2 == 0: print(b - (a+b)//2) else: if (a - 1) > (n - b): print((n-b) + 1 + (b-a-1)//2) else: print((a-1) + 1 + (b-a-1)//2)" p02690,s838078859,Accepted,"import math x = int(input()) b = 0 """""" def calc(b, b5): a = (x+b5)**0.2 if a.real.is_integer(): print(int(a), b) exit() while True: b5 = b ** 5 calc(b, b5) if x-b5 >= 0: calc(-b, -b5) b += 1 """""" for i in range(-120,120): for j in range(-120,120): if i**5 - j**5 == x: print(i, j) exit() " p02742,s249324343,Accepted,"import sys H, W = list(map(int, input().split())) if H == 1: print(1) sys.exit(0) if W == 1: print(1) sys.exit(0) if W % 2 == 0: kisu = W // 2 gusu = W // 2 else: kisu = W // 2 + 1 gusu = W // 2 if H % 2 == 0: ans = (kisu + gusu) * (H // 2) else: ans = (kisu + gusu) * (H // 2) + kisu print(ans) " p03474,s794062078,Accepted,"a,b=map(int,input().split()) s=input() print(""Yes"" if s[a]==""-"" and s.count(""-"")==1 else ""No"")" p02554,s524745154,Accepted,"# 整数の入力 N = int(input()) print((10 ** N - 2* 9 ** N + 8 ** N) % (10 ** 9 + 7))" p03773,s511840305,Accepted,"a,b=map(int,input().split()) print((a+b)%24)" p02817,s549752812,Accepted,"S, T = map(str, input().split()) print(T + S)" p03293,s124845947,Accepted,"S=input() T=input() for i in range(len(S)): if S==T: print(""Yes"") exit() temp=S[-1] S=temp+S[0:(len(S)-1)] print(""No"") " p03472,s615494101,Accepted,"import sys N, H = map(int, input().split()) a = [] b = [] for i in range(N): s, t = map(int, input().split()) a.append(s) b.append(t) A = max(a) b.sort(reverse=True) num = 0 ans = 0 for x in b: if A < x: num += x ans += 1 if num >= H: print(ans) sys.exit() else: break if (H-num)%A == 0: ans += (H - num) // A else: ans += (H - num) // A + 1 print(ans)" p02759,s576593313,Accepted,"import math print(math.ceil(int(input()) / 2)) " p03611,s587666351,Accepted,"N = int(input()) A = list(map(int, input().split())) cnt = [0 for _ in range(100005)] for a in A: cnt[a] += 1 ans = 0 for i in range(1, len(cnt) - 1): ans = max(ans, cnt[i - 1] + cnt[i] + cnt[i + 1]) print(ans) " p02790,s790421405,Wrong Answer,"n, m = input().split() n = m*int(n) m = n*int(m) print(min(int(n), int(m))) " p02678,s193575909,Accepted,"from collections import deque N, M = map(int, input().split()) route = [[] for i in range(N)] for i in range(M): a, b = map(int, input().split()) route[a - 1].append(b - 1) route[b - 1].append(a - 1) print('Yes') q = deque() d = [-1] * N d[0] = 0 q.append(0) while q: x = q.popleft() for i in route[x]: if d[i] == -1: d[i] = x + 1 q.append(i) for i in range(1, N): print(d[i]) " p02640,s821448467,Accepted,"X, Y = map(int, input().split()) p = list(range(X*2,X*4+1,2)) b = Y if b in p: print(""Yes"") else: print(""No"")" p03494,s996507061,Accepted,"n = int(input()) int_list = list(map(int,(input().split()))) count = 0 for i in range(30): for i in range(len(int_list)): if int_list[i] % 2 == 0 : int_list[i] = int_list[i]/2 else: int_list = [] break if len(int_list) == n : count += 1 else: break print(count) " p02603,s208452871,Accepted,"N=int(input()) A=list(map(int,input().split())) DP=[[1000,1000,0] for i in range(N+1)] for i in range(N): DP[i+1][0]=max(DP[i][0],DP[i][1]+DP[i][2]*A[i]) DP[i+1][1]=DP[i+1][0]%A[i] DP[i+1][2]=DP[i+1][0]//A[i] print(DP[N][0]) " p02743,s591676627,Wrong Answer,"a, b, c = map(int, input().split()) ab = int((a*b)**0.5) if a+b+2*ab= b: b = b*2 count += 1 while b >= c: c = c*2 count += 1 if count > k: print('No') else: print('Yes')" p02768,s427951356,Accepted,"n,a,b = map(int,input().split()) def comb(n,r,mod=10**9+7): a=1 b=1 r = min(r,n-r) for i in range(r): a = a*(n-i)%mod b = b*(i+1)%mod return a*pow(b,mod-2,mod)%mod ans = pow(2,n,10**9+7)-1 - comb(n,a) - comb(n,b) ans %= 10**9+7 print(ans)" p02835,s212888270,Wrong Answer,"A = map(int, input().split()) if sum(A) > 22: print(""bust"") else: print(""win"") " p03250,s772850209,Wrong Answer,"A=list(input().split()) A=sorted(A) b=A[0]+A[1] print(int(b)+int(A[2]))" p03069,s053437597,Wrong Answer,"n = int(input()) s = list(input()) count_1 = 0 for i in range(n-1): if s[i] == ""#"" and s[i+1] == ""."": count_1 += 1 count_2 = 0 for i in reversed(range(n-1)): if s[i] == ""#"" and s[i+1] == ""."": count_2 += 1 print(min(count_1,count_2))" p02748,s689299830,Accepted,"a,b,m = [int(x) for x in input().split()] lia = [int(x) for x in input().split()] lib = [int(x) for x in input().split()] wari = list() for _ in range(m): wari.append([int(x) for x in input().split()]) ans = 10**20 for i in wari: s = lia[i[0]-1]+lib[i[1]-1]-i[2] ans = min(ans,s) x = min(lia)+min(lib) ans = min(ans,x) print(ans)" p03852,s225623601,Accepted,"C=str(input()) V=""aiueo"" if C in V: ans=""vowel"" else: ans=""consonant"" print(ans)" p02784,s293251068,Accepted,"H, N = map(int, input().split()) A = list(map(int, input().split())) if H > sum(A): print(""No"") else: print(""Yes"")" p02793,s896746241,Accepted,"def gcd(x,y): if y==0: return x return gcd(y,x%y) MOD = 10**9+7 N = int(input()) A = list(map(int,input().split())) lcm = 1 for i in A: lcm = (lcm*i)//gcd(lcm,i) lcm %= MOD ans = 0 for i in A: ans += lcm*pow(i,MOD-2,MOD) print(ans%MOD) " p02623,s152146486,Accepted,"import sys input = lambda: sys.stdin.readline().rstrip() import bisect def cumsum(a): r = [0] for v in a: r.append(r[-1] + v) return r n, m, k = map(int, input().split()) a = cumsum(list(map(int, input().split()))) b = cumsum(list(map(int, input().split()))) ans = 0 for a_num, v in enumerate(a): tmp = 0 if k >= v: b_num = bisect.bisect_right(b, k - v) - 1 tmp = a_num + b_num ans = max(ans, tmp) print(ans) " p03331,s436967346,Accepted,"def sum_digit(num): sums = 0 while num != 0: sums += num % 10 num //= 10 return sums n = int(input()) min_ans = 9 * 4 for i in range(1, n): ans = sum_digit(i) + sum_digit(n - i) if min_ans > ans: min_ans = ans print(min_ans) " p03042,s706572767,Accepted,"s=input() m=int(s[:2]) n=int(s[2:]) flag1=1<=m and m<=12 flag2=1<=n and n<=12 if flag1 and flag2 : print(""AMBIGUOUS"") elif flag1 : print(""MMYY"") elif flag2 : print(""YYMM"") else : print(""NA"")" p02766,s107555020,Accepted,"#!/usr/bin/env python3 n,k = map(int,input().split()) ans = 1 while True: if n >= k**ans: ans += 1 else: break print(ans)" p03146,s395446304,Accepted,"def resolve(): s = int(input()) ans = [s] count = 0 while True: if ans[count]%2 == 0: ans.append(ans[count]//2) else: ans.append(ans[count]*3+1) count += 1 for i in range(count): if ans[i] == ans[count]: print(count+1) exit() resolve()" p03774,s475461031,Accepted,"n,m = map(int,input().split()) P = [list(map(int,input().split())) for _ in range(n)] C = [list(map(int,input().split())) for _ in range(m)] for i in range(n): d = 10**18 t = 0 for j in range(m): dist = abs(P[i][0]-C[j][0]) + abs(P[i][1]-C[j][1]) if d > dist: t = j d = dist print(t+1)" p03328,s441414096,Wrong Answer,"towers = {} h = 0 for i in range(1,1000): h += i towers[h] = True a,b = map(int,input().split()) snow = 1 while(1): if a + snow in towers.keys() and b + snow in towers.keys(): print(snow) break snow += 1" p02705,s860388704,Accepted,"import math r=int(input()) print(2*r*math.pi)" p02570,s043202739,Accepted,"D, T, S = map(int, input().split()) if D / S <= T: print('Yes') else: print('No')" p02785,s421473606,Accepted,"n, k = list(map(int, input().split())) h = list(map(int, input().split())) h.sort() if k > 0: h = h[:-k] print(sum(h))" p02996,s502679116,Accepted,"N = int(input()) work = sorted([list(map(int,input().split())) for i in range(N)], key = lambda x: x[1]) dead = [w[1] - w[0] for w in work] now = 0 for i in range(N): if now > dead[i]: ans = ""No"" break now += work[i][0] else: ans = ""Yes"" print(ans)" p02777,s228137897,Accepted,"def main(): colors = list(map(str, input().split("" ""))) nums = list(map(int, input().split("" ""))) trash = input() nums[colors.index(trash)] -= 1 print(' '.join(map(str, nums))) main()" p03795,s140659764,Accepted,"from sys import stdin,stdout def main(): line=stdin.readline() parts=line.split() a=int(parts[0]) b=800*a c=int(a/15)*200 stdout.write(str(int(b-c))) main()" p02697,s921319371,Accepted,"n,m = map(int,input().split()) if n%2 != 0: for i in range(m): print(1+i,n-i) else: for i in range(m): if (n-i)-(1+i) > n/2: print(1+i,n-i) else: print(1+i,n-i-1)" p02696,s243880073,Accepted,"import math if __name__ == '__main__': a, b, n = map(int, input().split()) print(math.floor(a * min(n, b - 1) / b))" p02607,s932041074,Accepted,"N = int(input()) a = list(map(int, input().split())) ans = 0 for i in range(N): if i % 2 == 1: continue if a[i] % 2 == 1: ans += 1 print(ans)" p02881,s140093523,Accepted,"n = int(input()) for i in range(int(n ** 0.5), 0, -1): if n % i == 0: print(n // i + i - 2) exit() " p02582,s630343654,Accepted,"s = input() if s == 'RRR': print('3') elif s == 'RRS' or s == 'SRR': print('2') elif s == 'SSS': print('0') else: print('1')" p03998,s172458425,Wrong Answer,"sa = str(input()) sb = str(input()) sc = str(input()) sa_count = 0 sb_count = 0 sc_count = 0 lst = [sa,sb,sc] count = [sa_count,sb_count,sc_count] k = 0 abc = 'abc' flag = False for _ in range(len(sa)+len(sb)+len(sc)): for i in range(3): if lst[k][count[k]]==abc[i]: count[i] += 1 k = i if len(lst[k])==count[k]: flag = True break if flag: break print(abc[k].upper())" p02629,s719793487,Accepted,"N = int(input()) keta = 1 now_26 = 26 while N > now_26: keta += 1 now_26 += 26 ** keta num = N - int(now_26 - 26 ** keta) -1 answer = """" for i in range(keta): answer += chr(97 + num % 26) num = num // 26 print(answer[::-1])" p02995,s953716646,Accepted,"from fractions import gcd def lcm(x, y): return (x * y) // gcd(x, y) A,B,C,D = map(int,input().split()) all_count = B-A+1 c_count = B//C - (A-1)//C d_count = B//D - (A-1)//D cd_count = B//lcm(C,D) - (A-1)//lcm(C,D) ans = all_count - c_count - d_count + cd_count print(ans)" p03095,s894646751,Accepted,"from collections import Counter MOD = 10**9+7 N = int(input()) s = input() d = Counter(s) res = 1 for value in d.values(): res *= value + 1 res %= MOD res -= 1 print(res)" p02842,s243486844,Accepted,"#方法2 import math n = int(input()) if math.floor(math.ceil(n/1.08) * 1.08) == n: print(math.ceil(n/1.08)) else: print(':(')" p02911,s198462273,Wrong Answer,"N, K, Q=map(int, input().split()) A=[None]*Q for i in range(Q): A[i]=int(input()) #print(N,K,Q,A) score=[K]*N for answer in A: score=[point-1 for point in score] score[answer-1]+=1 #print(score) for point in score: if point>=0: print('Yes') else: print('No')" p02783,s812767293,Accepted,"import math s = list(map(int, input().split())) print(str(math.ceil(s[0] / s[1])))" p03338,s543554545,Accepted,"N = int(input()) S = input() max_common_char = 0 for idx in range(N): p, v = S[:idx], S[idx:] commons = len(set(list(p)) & set(list(v))) if max_common_char <= commons: max_common_char = commons print(max_common_char) " p02570,s776663337,Wrong Answer,"D,T,S=map(int,input().split()) if T*S >= D: print(""YES"") else: print(""NO"")" p03434,s095479555,Accepted,"n = int(input()) a = list(map(int, input().split())) a.sort(reverse=True) ans = 0 for i in range(n): if i % 2 == 0: ans += a[i] else: ans -= a[i] print(ans)" p04019,s442052745,Wrong Answer,"S = str(input()) if S.count(""N"") == S.count(""S"") and S.count(""W"") == S.count(""E""): print(""Yes"") else: print(""No"")" p02970,s440448929,Accepted,"import math N, D = map(int, input().split()) print(math.ceil(N / (2 * D + 1)))" p03210,s787567141,Accepted,"n = int(input()) if n == 3 or n == 5 or n == 7: print(""YES"") else: print(""NO"")" p02963,s844087190,Accepted,"s = int(input()) x1, y1 = 0, 0 x2 = 10**9 y2 = 1 y3 = -(-s // 10**9) x3 = abs(x2 * y3 - s) print(x1, y1, x2, y2, x3, y3)" p02765,s817343617,Accepted,"def main(): N, R = map(int, input().split()) if N >= 10: print(R) else: print(R+100*(10-N)) if __name__ == ""__main__"": main()" p02719,s264403967,Accepted,"N,K=list(map(int,input().split())) print(min(N%K,K-N%K))" p04033,s154376847,Accepted,"a, b= map(int, input().split()) if ((a<0)and(b<0))and((abs(a)+abs(b))%2==0): print('Negative') elif (a>0)and(b>0): print('Positive') elif ((a<0)and(b<0))and((abs(a)+abs(b))%2==1): print('Positive') elif (a==0)or(b==0): print('Zero') else: print('Zero')" p04012,s749065569,Accepted,"from collections import Counter w=input() d=Counter(w) ans=""Yes"" for i in d.values(): if i%2!=0: ans=""No"" break print(ans)" p02582,s472163830,Wrong Answer,"S = input() if (S == 'SSS'): print(0) if (S == 'SSR'): print(1) if (S == 'SRS'): print(1) if (S == 'SRR'): print(2) if (S == 'RSS'): print(1) if (S == 'RSR'): print(2) if (S == 'RRS'): print(2) if (S == 'RRR'): print(3) " p03289,s718609889,Accepted,"def inpl(): return list(map(int, input().split())) S = input() ok = False if S[0] == ""A"" and S[2:-1].count(""C"") == 1: u = 0 for s in S[1:]: u += s.isupper() if u == 1: ok = True if (ok): print(""AC"") else: print(""WA"")" p03481,s977593009,Accepted,"def main(): x, y = map(int , input().split()) cnt = 0 while x<=y: x = x*2 cnt = cnt+1 print(cnt) if __name__==""__main__"": main()" p03797,s668952790,Wrong Answer,"N,M = map(int,(input().split())) if N >= 2*M: print(M) else: print(N + (M-N*2)//4)" p03261,s254426122,Accepted,"n = int(input()) rule = [] w = input() rule.append(w) now = w[-1] for i in range(n - 1): w = input() if w in rule: print(""No"") exit() elif now != w[0]: print(""No"") exit() else: rule.append(w) now = w[-1] print(""Yes"")" p04005,s738104857,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, min(B*C, C*A)) print(ans)" p04029,s460067966,Accepted,"import math N=int(input()) sum=0 for I in range(1,N+1): sum= sum+ I print(sum)" p03472,s182760482,Wrong Answer,"def main(): from math import ceil from itertools import accumulate from bisect import bisect n, h, *ab = map(int, open(0).read().split()) x = max(ab[::2]) *y, = filter(lambda i: i >= x, ab[1::2]) y.sort(reverse=True) *z, = accumulate(y) if z[-1] <= h: print(len(y) + ceil((h - z[-1]) / x)) else: print(bisect(y, h)) if __name__ == '__main__': main() " p02792,s299637872,Accepted,"from collections import defaultdict n = int(input()) d = defaultdict(int) for i in range(1, n+1): if str(i)[-1] == '0': continue d[int(str(i)[0] + str(i)[-1])] += 1 ans = 0 for i in range(11, 100): ans += d[i] * d[int(str(i)[1] + str(i)[0])] print(ans)" p02848,s906748100,Wrong Answer,""""""" author : halo2halo date : 8, Jan, 2020 """""" import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) word = ""ABCDEFGHIJKLMNOPQRSTUVWXYZ"" N = int(readline()) S = readline().decode('utf8').rstrip() print(S) ans = [None] * len(S) print(ans) print(len(S)) for i in range(len(S)): # print(word[(word.index(S[i]) + N) % len(word)]) ans[i] = word[(word.index(S[i]) + N) % len(word)] ans=''.join(ans) print(ans) " p02640,s440672540,Accepted,"x,y=map(int,input().split()) if y%2==0 and y//2-x>=0 and 2*x-y//2>=0: print('Yes') else: print('No')" p03323,s837915369,Accepted,"a,b=map(int,input().split()) if a<9>b: print('Yay!') else: print(':(') " p02971,s525122450,Accepted,"N = int(input()) nums = [int(input()) for i in range(N)] sorted_nums = sorted(nums) max_num = sorted_nums[-1] second_max_num = sorted_nums[-2] for num in nums: if num != max_num: print(max_num) else: print(second_max_num) " p03548,s814033662,Accepted,"x,y,z=map(int,input().split()) x-=z print(x//(z+y))" p02646,s962812333,Accepted,"a, v = list(map(int,input().strip().split())) b, w = list(map(int,input().strip().split())) t = int(input()) ansa = a + v * t ansb = b + w * t ansa2 = a - v * t ansb2 = b - w * t if a < b: if ansb <= ansa: print(""YES"") else: print(""NO"") else: if ansa2 <= ansb2: print(""YES"") else: print(""NO"")" p03219,s080078782,Wrong Answer,"x, y = map(int, input().split()) print(x + y / 2)" p03043,s901303339,Wrong Answer,"N, K = map(int, input().split()) ans = 0 for i in range(1, N+1): k = 0 while i*2**k <= K: k += 1 ans += (1/N)*(1/2)**k print(ans)" p02817,s709232111,Accepted,"s, t = input().split() print(t+s)" p02862,s532324815,Wrong Answer,"def comb(n, k, mod): if k == 0: return 1 else: x, y = n, k for i in range(1, k): x = x * (x - i) % mod y = y * (y - i) % mod c = x * pow(y, mod - 2, mod) % mod return c x, y = map(int, input().split()) mod = 10 ** 9 + 7 n = (x + y) // 3 if (x + y) % 3 != 0 or not (n <= x <= 2 * n): ans = 0 else: k = min(x - n, 2 * n - x) ans = comb(n, k, mod) print(ans)" p03069,s825546138,Wrong Answer,"n=int(input()) s=input() black_sum=s.count(""#"") white_sum=n-black_sum black=0 white=0 for i in range(n): if s[i]==""."": black=i break for i in range(n): if s[~i]==""#"": white=~i+n ans=min(black_sum-black,white_sum-white) print(ans)" p03416,s886697920,Wrong Answer,"A,B = map(int, input().split()) count = 0 for i in range(1,10): for j in range(10): for k in range(10): for l in range(10): for m in range(10): k = 10000*i + 1000*j +100*k +10*l + m if A <= k and k <= B: ka = str(k) karray = list(map(int, ka)) if karray == karray.reverse: count += 1 print(count) " p04011,s229725000,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)" p03556,s780559114,Accepted,"from math import sqrt n = int(input()) ans = int(sqrt(n)) if (ans + 1) * (ans + 1) <= n: print((ans + 1) * (ans + 1)) elif ans * ans <= n: print(ans * ans) else: print((ans - 1) * (ans - 1))" p03073,s198643403,Accepted,"s=input() ans=0 for i in range(len(s)): if int(s[i])==(i%2): ans+=1 print(min(ans,len(s)-ans))" p02712,s014162638,Accepted,"n = int(input()) lst = [i for i in range(1, n+1) if i % 3 != 0 and i % 5 != 0] print(sum(lst)) " p03427,s455704282,Accepted,"import sys def S(): return sys.stdin.readline().rstrip() N = S() if all([n=='9' for n in N[1:]]): print(int(N[0])+9*(len(N)-1)) else: print(int(N[0])-1+9*(len(N)-1)) " p02814,s377788773,Accepted,"import fractions import math from functools import reduce import sys sys.setrecursionlimit(10**8) def lcm2(x, y): return (x * y) // fractions.gcd(x, y) def lcm(numbers): return reduce(lcm2, numbers) n, m = map(int, input().split()) a = list(map(int, input().split())) count = 0 while all(x % 2 == 0 for x in a): count += 1 a = list(map(lambda x: x//2, a)) if any(x % 2 == 0 for x in a): print(0) exit() lcm = lcm(a) print(m // (lcm * (2 ** (count - 1))) - m // (lcm * (2 ** count)))" p02778,s998809427,Accepted,"S=list(input()) ans="""" for i in range(len(S)): ans+=""x"" print(ans)" p03041,s598628505,Accepted,"N, K = map(int, input().split()) S = input() Slist = [char for char in S] Slist[K-1] = Slist[K-1].lower() for str in Slist: print(str, end='')" p02706,s557438888,Accepted,"n,m=map(int, input().split()) a=list(map(int, input().split())) print(max(-1,n-sum(a)))" p02948,s904728117,Accepted,"import heapq n, m = map(int, input().split()) ab = [list(map(int, input().split())) for _ in range(n)] ab.sort(key = lambda x:x[0]) ab.append([10 ** 10, 0]) ans = 0 cand = [] day = 1 pos = 0 while day <= m: while ab[pos][0] <= day: heapq.heappush(cand, ab[pos][1] * -1) pos += 1 day += 1 if cand: ans += heapq.heappop(cand) * -1 print(ans) " p02777,s544177939,Accepted,"S, T = input().split() A, B = map(int, input().split()) U = input() if U == S: A -= 1 else: B -= 1 print(A, B)" p03617,s363993324,Wrong Answer,"import sys sys.setrecursionlimit(10 ** 7) f_inf = float('inf') mod = 10 ** 9 + 7 def resolve(): q, h, s, d = map(int, input().split()) n = int(input()) t = min(q * 4, h * 2, s) if n == 1: print(int(t)) else: if n % 2 == 0: print(int(min(t * n, d * n // 2))) else: print(t * n, d * ((n - 1) // 2) + t) print(int(min(t * n, d * ((n - 1) // 2) + t))) if __name__ == '__main__': resolve() " p02748,s504960677,Accepted,"import sys input = sys.stdin.readline A, B, M = map(int, input().strip().split()) A = list(map(int, input().strip().split())) B = list(map(int, input().strip().split())) ans = min(A) + min(B) query = [list(map(int, input().strip().split())) for i in range(M)] for i, q in enumerate(query): x, y, m = q ans = min(A[x-1]+B[y-1]-m, ans) print(ans) " p02630,s530447124,Wrong Answer,"n = int(input()) A = list(map(int, input().split())) q = int(input()) total = sum(A) dic = {} for i in range(q): b, c = map(int, input().split()) b_count = A.count(b) c_count = A.count(c) dic[c] = c_count + b_count if b in dic: b_count = dic[b] diff = c - b total += b_count*diff print(total) " p03544,s480846265,Accepted,"N = int(input()) def dfs(x): memo = [0]*(x+1) def _dfs(x): if x == 0: return 2 elif x == 1: return 1 elif memo[x] != 0: return memo[x] else: memo[x] = _dfs(x-1) + _dfs(x-2) return memo[x] return _dfs(x) print(dfs(N))" p02801,s319710551,Accepted,"c = input() _ = [chr(i) for i in range(97,97+26)] print(_[_.index(c) + 1])" p02595,s157845113,Wrong Answer,"import math n, d = list(map(int, input().split())) cnt = 0 for i in range(n): x, y = list(map(int, input().split())) ans = math.sqrt(x*x + y*y) if ans>=d: cnt+=1 print(cnt)" p02630,s189853157,Wrong Answer,"n = int(input()) l= list(map(int,input().split())) c = [0] * (10 ** 5 + 1) for i in l: c[i] += 1 n = int(input()) s = sum(c) for i in range(n): be,af = map(int,input().split()) s -= be * c[be] s += af * c[be] c[af] += c[be] c[be] = 0 print(s)" p03438,s391693807,Accepted,"N = int(input()) a = list(map(int, input().split("" ""))) b = list(map(int, input().split("" ""))) a_cnt, b_cnt = 0, 0 for i in range(N): # aiをbiに近づける if a[i] < b[i]: num = (b[i] - a[i] + 1) // 2 a_cnt += num a[i] += 2 * num for i in range(N): # biをaiに近づける if b[i] < a[i]: b_cnt += (a[i] - b[i]) if a_cnt >= b_cnt: print(""Yes"") else: print('No')" p03262,s889134724,Accepted,"import math n, x = map(int, input().split()) a = list(map(int, input().split())) b = [] for i in range(n): b.append(abs(x-a[i])) ans = b[0] for j in range(1, n): ans = math.gcd(ans, b[j]) print(ans)" p03799,s402959479,Accepted,"n, m = map(int, input().split()) ans = 0 if m >= 2*n: ans += n m -= 2*n else: ans += m//2 m = 0 if m > 0: ans += m // 4 print(ans)" p02714,s014278049,Accepted,"import sys def input(): return sys.stdin.readline().rstrip() def main(): N = int(input()) S = input() sum = S.count('R') * S.count('G') * S.count('B') for i in range(N-2): for j in range(i+1, N-1): k = j+(j-i) if k < N: if S[i] == S[j] or S[i] == S[k] or S[k] == S[j]: continue sum -= 1 print(sum) if __name__ == '__main__': main()" p03998,s478263633,Wrong Answer,"# coding: utf-8 sa = input() sb = input() sc = input() d = {""A"":sa, ""B"":sb, ""C"":sc} s = d[""A""][0].upper() d[""A""] = d[""A""][1:] while True: if len(d[s]) == 0: print(s) break s = d[s][0].upper() d[s] = d[s][1:]" p03377,s771634327,Accepted,"a, b, x=map(int, input().split()) if a+b>=x and a<=x: print('YES') else: print('NO')" p03645,s987741067,Accepted,"N, M = map(int,input().split()) ll = [list(map(int,input().split())) for j in range(M)] a = [0]*N b = [0]*N for i in range(M): if ll[i][0] == 1: a[ll[i][1]-1] += 1 if ll[i][1] == N: b[ll[i][0]-1] += 1 for i in range(N): if a[i] != 0 and b[i] != 0: print(""POSSIBLE"") exit() else: pass print(""IMPOSSIBLE"") " p03760,s991163368,Accepted,"O=list(input()) E=list(input())+[""""] for x,y in zip(O, E):#zipにしてあげることで自動的にOが奇数、Eが偶数の場所になる print(x+y,end="""")#あとは順次出力" p03720,s049195016,Accepted,"n,m = map(int,input().split()) c = [0]*n for i in range(m): a,b = map(int,input().split()) c[a-1] += 1 c[b-1] += 1 for ci in c: print(ci)" p02612,s199234832,Accepted,"n = int(input()) print(0 if n % 1000 == 0 else 1000 - (n % 1000))" p03624,s212034064,Accepted,"S=input() for i in range(ord(""a""),ord(""z"")+1): if chr(i) in S: continue else: print(chr(i)) exit() print(""None"") " p02555,s929829173,Accepted,"import math import sys readline = sys.stdin.readline S = int(readline().strip()) p =10**9 +7 n = S//3 ans = 0 for i in range(1, n+1): si = S - 3*i ai = math.factorial(si+i-1) bi = math.factorial(si) ci = math.factorial(i-1) ai //= bi ai //= ci ans += ai ans %= p print(ans)" p04012,s065699372,Accepted,"import collections w=list(input()) alpha=[chr(i) for i in range(97, 97+26)] beautiful=True C=collections.Counter(w) for i in alpha: if C[i]%2==1: beautiful=False if beautiful: print(""Yes"") else: print(""No"")" p02761,s874587848,Wrong Answer,"n,m=map(int,input().split()) a=[-1]*n for i in range(m): s,c=map(int,input().split()) s-=1 if a[s]==-1 or a[s]==c: a[s]=c else: print(-1) exit() if n==1 and a[0]==0: print(0) exit() if a[0]==-1: a[0]=1 if a[0]==0: print(-1) exit() b="""" for i in a: if i==-1: b+=""0"" else: b+=str(i) print(b)" p02819,s046014085,Accepted,"def primes(n): is_prime = [True] * (n + 1) is_prime[0] = False is_prime[1] = False for i in range(2, int(n**0.5) + 1): if not is_prime[i]: continue for j in range(i * 2, n + 1, i): is_prime[j] = False return set([i for i in range(n + 1) if is_prime[i]]) sosuu = primes(10**6) N=int(input()) for i in range(N,10**6): if i in sosuu: print(i) break" p03377,s817272654,Accepted,"a,b,x=map(int,input().split()) if a>x: print(""NO"") else: if x<=a+b: print(""YES"") else: print(""NO"")" p03665,s575127881,Wrong Answer,"N,P = map(int,input().split()) A = list(map(int,input().split())) ce = 0 co = 0 for i in range(N): if A[i]%2==0: ce += 1 else: co += 1 n = (2**ce)*2**(co-1) if P==0: print(n) else: print(2**N-n)" p02731,s860943978,Accepted,"l = int(input()) ans = (l/3)**3 print(ans)" p02789,s923971660,Accepted,"a,b = map(int,input().split()) if a==b: print('Yes') else: print('No')" p02712,s954251719,Wrong Answer," def resolve(): N = int(input()) temp = 0 for count in range(N): if count % 3 == 0 and count % 5 == 0: pass elif count % 3 == 0: pass elif count % 5 == 0: pass else: temp += count print(temp) resolve()" p03017,s265327433,Wrong Answer,"N, A, B, C, D = map(int, input().split()) S = input() if S.count(""##"", A, D): print(""No"") elif C < D: print(""Yes"") elif S.count(""..."", B - 1, D + 2): print(""Yes"") else: print(""No"")" p03705,s555557519,Accepted,"N, A, B = map(int, input().split()) max = B*(N-1)+A min = A*(N-1)+B if(A > B): print(0) elif(A == B): print(1) else: if N > 1: print(max - min + 1) else: print(0)" p03852,s211327187,Accepted,"x = input() if x == 'a' or x =='e' or x == 'i' or x =='o' or x =='u': print('vowel') else: print('consonant')" p03962,s760914774,Accepted,"a,b,c = map(int,input().split()) if a == b == c: print(1) elif a != b != c and a != c: print(3) else: print(2)" p02873,s513440790,Accepted,"S = input() n = len(S) shift_max = [0]*(n+1) big_run = 0 for i in range(n): if S[i] == '<': big_run += 1 else: big_run = 0 shift_max[i+1] = big_run small_run = 0 for i in reversed(range(n)): if S[i] == '>': small_run += 1 else: small_run = 0 shift_max[i] = max(shift_max[i],small_run) print(sum(shift_max)) " p02847,s802869351,Accepted,"num_dic = {} word_list = [""SUN"",""MON"",""TUE"",""WED"",""THU"",""FRI"",""SAT""] for n, word in enumerate(word_list): num_dic[word] = 7 - n s = input() print(num_dic[s]) " p02801,s995761641,Wrong Answer,"import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) c = read().decode(""utf-8"") l = [chr(ord('a') + i) for i in range(26)] if c == ""z"": print(""a"") quit() f = False for a in l: if a == c: f = True continue if f: ans = a.strip() print(ans) quit()" p02948,s588245995,Accepted,"from heapq import heappush, heappop import sys input = sys.stdin.buffer.readline n, m = map(int, input().split()) AB = [] AB = [list(map(int, input().split())) for _ in range(n)] AB.sort(key=lambda x: [-x[0], -x[1]]) ans = 0 kouho = [] for d in range(1, m + 1): while AB and AB[-1][0] <= d: a, b = AB.pop() heappush(kouho, (-b, a)) if kouho: p, q = heappop(kouho) ans += -p print(ans) " p02996,s850960648,Accepted,"N = int(input()) W = [] for _ in range(N): a,b = map(int,input().split()) W.append((a,b)) W.sort(key=lambda x: x[1]) cur = 0 for a,b in W: if cur+a > b: print(""No"") exit() cur += a print(""Yes"")" p03759,s805106967,Accepted,"# AtCoder Beginner Contest 058 # A - ι⊥l a, b, c = map(int, input().split()) if b-a == c-b: print('YES') else: print('NO')" p02718,s629644672,Accepted,"from sys import stdin n,m = map(int,input().split()) sen = list(map(int,input().split())) count = 0 al = 0 for i in sen: al += i for i in sen: if i >= al/(4*m): count += 1 if count >= m: print(""Yes"") else: print(""No"") " p03433,s713254757,Accepted,"n = int(input()) a = int(input()) if n - 500*(n//500) <=a: print(""Yes"") else: print(""No"")" p02708,s114988993,Accepted,"n , k = map(int, input().split()) ans=0 for i in range(k,n+2): ans+=n*i-i**2+i+1 ans%=1000000007 print(ans) " p03417,s153314422,Accepted,"n,m=map(int,input().split()) if n>=2 and m>=2: print((n-2)*(m-2)) elif n==1 and m>=2: print(m-2) elif m==1 and n>=2: print(n-2) elif m==1 and n==1: print(1)" p02657,s894504952,Wrong Answer,"A,B = (int(x) for x in input('A,B = ').split()) print(A*B)" p02817,s723196844,Accepted,"l = list(map(str, input().split("" ""))) print(l[-1] + l[0])" p03251,s443676476,Wrong Answer,"if __name__ == '__main__': 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 Z in range(x+1,y+1): if x_max < Z <= y_min: flg = True print(""No war"") exit() print(""War"") " p02916,s742170210,Accepted,"n = int(input()) # mapはcallable, iterator # input().split()でリストを作成する a = [int(i) for i in input().split()] iSSequence = [False] * (len(a) - 1) # a[i]のあとにa[i+1]を食べたならフラグを立てる for i in range(len(a) - 1): if(a[i] + 1 == a[i + 1]): iSSequence[a[i] - 1] = True sum = 0 # bは必ずすべて足される for b in input().split(): sum += int(b) index = 0 for c in input().split(): if(iSSequence[index]): sum += int(c) index += 1 print(sum)" p02631,s667227703,Accepted,"N=int(input()) a=list(map(int,input().split())) p=0 for i in range(N):#O(200000) p=p^a[i] #これでpは各猫のxorになったはず ls=[] for i in range(N):#O(200000) ls.append(p^a[i]) print(' '.join(map(str, ls)))" p02987,s345874688,Wrong Answer,"s=input() S=sorted(s) S.sort() flag=False if S[0]==S[1]: if S[2]==S[3]: flag=True if flag: print(""Yes"") else: print(""No"")" p03705,s605759451,Accepted,"import sys readline = sys.stdin.readline MOD = 10 ** 9 + 7 INF = float('INF') sys.setrecursionlimit(10 ** 5) def main(): n, a, b = map(int, readline().split()) ans = max(b * (n - 2) - a * (n - 2) + 1, 0) print(ans) if __name__ == '__main__': main() " p03971,s580790297,Wrong Answer,"n, a, b = [int(i) for i in input().split()] border = a + b foreign_pass = 0 passed = 0 s = input() for x in s: if passed >= border: print('No') continue if x == 'a': print('Yes') passed += 1 elif x == 'b' and foreign_pass < b: print('Yes') foreign_pass += 1 else: print('No')" p02797,s091204550,Accepted,"N, K, S = list(map(int, input().split())) def gcd(a, b): while b: a, b = b, a % b return a for i in range(2, 10**6): if gcd(S, i) == 1: break ans = [] ans.extend([S for _ in range(K)]) ans.extend([i for _ in range(N-K)]) ans_str = """" for j in range(len(ans)): ans_str += str(ans[j]) ans_str += "" "" ans_str = ans_str[:len(ans_str) - 1] print(ans_str)" p02879,s640541392,Wrong Answer,"A, B = map(int, input().split()) if((A and B)<=9): print(int(A*B)) else: print('')" p03437,s464189176,Wrong Answer,"def resolve(): import math X, Y = map(int, input().split()) if X == Y: print(""-1"") else: for i in range(2, X): if X%i == 0 and X*i%Y != 0: print(X*i) exit() print(""-1"") resolve()" p02993,s594146700,Accepted,"ss=input().strip() flg=False for i in range(1,len(ss)): if ss[i]==ss[i-1]: flg=True if flg==True: print(""Bad"") else: print(""Good"")" p03998,s041396580,Accepted,"def myAnswer(S:dict) -> str: target = ""a"" while True: if(S[target] == []): return target.upper() else: target = S[target].pop(0) def modelAnswer(): return def main(): S = {chr(97+i):list(input()) for i in range(3)} print(myAnswer(S)) if __name__ == '__main__': main()" p03107,s031917171,Accepted,"from collections import Counter s = list(input()) c = Counter(s) print(min(c[""0""],c[""1""])*2)" p02910,s388970334,Accepted,"S=str(input()) i = 0 yasui = True for s in S: if i%2==0 and s=='L': yasui = False if i%2!=0 and s=='R': yasui = False i=i+1 if yasui: print('Yes') else: print('No')" p02570,s731549997,Accepted,"# coding: utf-8 # 日本語を入力できるようにするために上記一文が必要 D,T,S = map( int , input().split()) if D/S <= T: print(""Yes"") else: print(""No"")" p02972,s786927445,Wrong Answer,"n=int(input()) a=list(map(int,input().split())) b=[0]*n c=0 for i in range(n): c+=a[i]%2 if a[i]%2==1: b[i]+=i+1 print(sum(b)) b1=[str(n) for n in b] print(' '.join(b1))" p02832,s441006705,Accepted,"n = int(input()) a = list(map(int,input().split())) cnt, num = 0, 1 if 1 not in a: print(-1) else: for i in range(n): if a[i] == num: num += 1 else: cnt += 1 print(cnt)" p03607,s599521922,Accepted,"import collections n = int(input()) keep = [] ans = 0 for i in range(n): j = int(input()) keep.append(j) c = collections.Counter(keep) print(len([i[0] for i in c.items() if i[1] % 2 != 0])) " p02897,s560675307,Accepted,"Num=int(input()) if Num%2==0: print(Num/2/Num) else: print((Num//2+1)/Num)" p03639,s076598191,Accepted,"import sys N = int(sys.stdin.readline().strip()) A = map(int, sys.stdin.readline().strip().split()) not_even = 0 even = 0 four = 0 # % 4 = 0 for a_i in A: if a_i % 4 == 0: four += 1 elif a_i % 2 == 0: even += 1 else: not_even += 1 if not_even > four + 1: print(""No"") else: if not_even == four + 1: if even == 0: print(""Yes"") else: print(""No"") else: print(""Yes"")" p02603,s148137805,Wrong Answer,"n = int(input()) a = list(map(int, input().split())) flag = [-1]*n t = 1 for i in range(n-1, -1, -1): if t == 1: if a[i-1] < a[i]: flag[i] = t t = 0 else: if a[i] < a[i-1]: flag[i] = t t = 1 t = 0 s = 0 ans = 1000 for i in range(n): if flag[i] == 0: t = 1-t s = ans//a[i] ans %= a[i] elif flag[i] == 1: t = 1-t ans += s*a[i] s = 0 print(ans)" p02923,s229284556,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 else: if ans < cnt: ans = cnt cnt = 0 print(cnt)" p02598,s745247294,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) def is_ok(X): # 全部をX以下にするために切る回数 <= K cnt = 0 for i in range(N): cnt += (A[i]-1)//X return cnt <= K def meguru_bisect(ng, ok): while (abs(ok - ng) > 1): mid = (ok + ng) // 2 if is_ok(mid): ok = mid else: ng = mid return ok print(meguru_bisect(0, 10**9))" p02911,s126269614,Accepted,"N,K,Q=map(int,input().split()) p=[0]*N s=0 for x in range(Q): A=int(input()) p[A-1]+=1 s+=1 for y in range(N): if K+p[y]-s>0: print(""Yes"") else: print(""No"")" p02911,s657891983,Accepted,"n,k,q=list(map(int,input().split())) t=[0]*n for i in range(q): a=int(input()) t[a-1]+=1 for j in range(n): print('Yes' if k-q+t[j]>0 else 'No') " p02727,s722166131,Accepted,"f,g=lambda:map(int,input().split()),sorted;x,y,*_=f();print(sum(g(g(f())[-x:]+g(f())[-y:]+g(f()))[-x-y:]))" p02765,s525269394,Accepted,"n, r = map(int, input().split()) print(r + max(1000 - 100 * n, 0))" p02946,s122188006,Accepted,"K, X = map(int,input().split()) for kuro in range(X-K+1, X+K): print(kuro, end=' ') " p02645,s770240643,Wrong Answer,"a = input() a = str(a) print(a[0],a[1],a[2])" p02742,s505370288,Accepted,"# -*- coding: utf-8 -*- H, W = map(int, input().split()) if H > 1 and W > 1: print((H * W) // 2 + (H * W) % 2) else: print(1)" p02725,s374766095,Wrong Answer,"def main(): K, N = map(int, input().split(' ')) half_k = K // 2 A = list(map(int, input().split())) A.sort() a_sub = A[-1] - A[0] if A[-1] > half_k: a_sub = (A[-1] - half_k) + A[0] if a_sub < 0: a_sub *= -1 for n in range(N - 1): if A[n + 1] - A[n] > a_sub: a_sub = A[n + 1] - A[n] print(K - a_sub) if __name__ == '__main__': main() " p03345,s883430114,Wrong Answer,"A, B, C, K = map(int, input().split()) print(A-B)" p02572,s909802716,Wrong Answer,"n=int(input()) hoge=list(map(int,input().split())) ans=0 wa=hoge[0] for i in range(1,n): ans+=wa*hoge[i] wa+=hoge[i] print(ans)" p03351,s467004430,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"") " p02570,s521877794,Wrong Answer,"D, T, S = map(int, input().split()) if D b: ans = math.atan((b ** 2) / (2 * a * y)) * 360 / 2 / math.pi print(ans)" p02917,s325715259,Accepted,"n = int(input()) b = list(map(int,input().split())) a = [] a.append(b[0]) for i in range(n-2): a.append(min(b[i],b[i+1])) a.append(b[n-2]) print(sum(a))" p02732,s464277151,Accepted,"N = int(input()) A = list(map(int, input().split())) import collections c = collections.Counter(A) sum_all = sum([v * max(v - 1, 0) // 2 for k, v in c.items()]) ans = [] for a in A: b = c[a] ans_a = sum_all - (b * max(b - 1, 0) // 2) + (max(b - 1, 0) * max(b - 2, 0) // 2) ans.append(ans_a) print(*ans, sep='\n') " p02732,s459041953,Accepted,"import collections N = int(input()) A = list(map(int, input().split())) S = 0 c = collections.Counter(A) for v in c.values(): S = S + v*(v-1)//2 for i in range(len(A)): print(S-c[A[i]]+1) " p02714,s416693552,Accepted,"import sys si = sys.stdin.readline so = sys.stdout.write def main(): n = int(si()) s = si()[:-1] cnt = s.count('R')*s.count('G')*s.count('B') for i in range(n-2): for j in range(i+1, n-1): k = j+j-i if k < n and s[i] != s[j] and s[j] != s[k] and s[k] != s[i]: cnt -= 1 print(cnt) if __name__ == '__main__': main() " p04033,s489092204,Accepted,"def main(): a, b = map(int, input().split()) if a == 0 or b == 0: print(""Zero"") elif a < 0 and b < 0: if (b - a + 1) % 2 == 0: print(""Positive"") else: print(""Negative"") elif a < 0 and 0 < b: print(""Zero"") elif 0 < a and 0 < b: print(""Positive"") if __name__ == ""__main__"": main() " p03252,s906204169,Accepted,"def normalized(s): indexes = {} def translated(ch): if ch not in indexes: indexes[ch] = len(indexes) return indexes[ch] return list(map(translated, s)) def main(): s = input() t = input() print('Yes' if normalized(s) == normalized(t) else 'No') if __name__ == '__main__': main() " p02732,s006012894,Accepted,"N = int(input()) A = list(map(int, input().split())) di = {} B = set(A) for b in B: di[b] = 0 total = 0 for a in A: di[a]+=1 for v in di.values(): total += v*(v-1)//2 #print(di.values(),total) ans = [] for a in A: ans.append(total-di[a]+1) print(*ans,sep='\n')" p02730,s725830742,Accepted,"s = input() if s == s[::-1]: s1 = s[: len(s) // 2] s2 = s[(len(s) // 2) + 1:] if s1 == s2: print('Yes') else: print('No') else: print('No') " p02777,s788508777,Accepted,"s,t = map(str,input().split()) a,b = map(int,input().split()) u = input() if s == u: print(a-1 , b) else: print(a , b-1)" p03408,s487852871,Accepted,"Blue=[] Red=[] n=int(input()) for i in range(n): s=input() Blue.append(s) m=int(input()) for i in range(m): t=input() Red.append(t) ans=0 for a in Blue: plus = Blue.count(a) minus = Red.count(a) point = plus - minus ans = max(ans, point) print(ans)" p03262,s275059243,Accepted,"import fractions N,X=map(int,input().split()) x=list(map(int,input().split())) x.append(X) x=sorted(x) gcd=x[1]-x[0] for i in range(1,N+1): gcd=fractions.gcd(gcd,x[i]-x[i-1]) print(gcd)" p03061,s368134131,Accepted,"import math N = int(input()) A = list(map(int, input().split())) gcd_l = [0] gcd_r = [0] for n in range(N): gcd_l.append(math.gcd(gcd_l[n], A[n])) gcd_r.append(math.gcd(gcd_r[n], A[-(n + 1)])) #print(gcd_r) #print(gcd_l) gcd_r = gcd_r[::-1] #print(gcd_r) ans = [] for n in range(N): ans.append(math.gcd(gcd_l[n], gcd_r[n + 1])) print(max(ans)) #print(ans) " p02717,s814662421,Wrong Answer,"x, y, z = input().split() print(x, y, z) # print(""shuffle"") c = x x = y y = c # print(1, ""回目"", x, y, z) c = x x = z z = c # print(2, ""回目"", x, y, z) # print(""result"") print(x, y, z) " p02917,s489447078,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))" p03478,s515575685,Accepted,"N , A , B = map(int, input().split()) L = [i for i in range(1, N+1)] M = [] def digitSum(n): # 数値を文字列に変換 s = str(n) # 1文字ずつ数値化し配列にする。 array = list(map(int, s)) # 合計値を返す return sum(array) for i in range(N): if digitSum(L[i]) >= A and digitSum(L[i]) <= B: M.append(L[i]) print(sum(M))" p02641,s744920967,Accepted,"ii = lambda : int(input()) mi = lambda : map(int,input().split()) li = lambda : list(map(int,input().split())) x,n = mi() p =li() # small side xs = x while 1: if xs not in p: break xs -= 1 # large side xl = x while 1: if xl not in p: break xl += 1 if x-xs > xl - x: print(xl) else: print(xs) " p03239,s974013161,Accepted,"N,T=map(int,input().split()) ans=2000 for i in range(N): c,t=map(int,input().split()) if t<=T: ans=min(ans,c) print(ans if ans!=2000 else ""TLE"")" p02933,s348723979,Wrong Answer,"a = int(input()) s = input() if a < 3200: print('red') elif a >= 3200: print('s') " p02768,s711313600,Accepted,"mod = 10**9 + 7 def C(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 n, a, b = map(int, input().split()) print((pow(2, n, mod) - 1 - C(n, a, mod) - C(n, b, mod)) % mod)" p03994,s882386399,Accepted,"s = list(input()) K = int(input()) for i in range(len(s)): if K == 0: continue n = ord(s[i]) - ord(""a"") if n == 0: continue m = 26 - n if K >= m: s[i] = ""a"" K -= m if K != 0: K %= 26 s[-1] = chr(ord(s[i]) + K) print("""".join(map(str,s))) " p03449,s111894910,Accepted,"# -*- coding: utf-8 -*- n = int(input()) a1 = [int(i) for i in input().split()] a2 = [int(i) for i in input().split()] ans = 0 for i in range(n): tmp = sum(a1[:i+1]) + sum(a2[i:]) if tmp > ans: ans = tmp print(ans) " p03069,s711863600,Accepted,"N = int(input()) S = input() WL = 0 WR = 0 BL = 0 BR = 0 for i in range(N): if S[i] == '#': BR += 1 else: WR += 1 ans = BL+WR for i in range(N): if S[i] == '#': BR -= 1 BL += 1 else: WR -= 1 WL += 1 ans = min(ans,BL+WR) print(ans) " p03680,s536942177,Wrong Answer,"N = int(input()) A = [] for i in range(N): A.append(int(input())) now = 1 for i in range(15000): now = A[now-1] if now == 2: print(i+1) exit() print(-1) " p03282,s674881741,Accepted,"# input S = input() K = int(input()) # check n_num = 0 for i in range(len(S)): if S[i] == ""1"": n_num += 1 else: break if n_num >= K: print(1) else: print(S[n_num])" p02959,s986397445,Wrong Answer,"n=int(input()) a=list(input().split()) b=list(input().split()) for i in range(len(a)): a[i]=int(a[i]) for i in range(len(b)): b[i]=int(b[i]) print(min(sum(a),sum(b)))" p03220,s761786006,Accepted,"N = int(input()) T, A = map(int, input().split()) H = list(map(int, input().split())) avg = [T - H[i] * 0.006 for i in range(N)] diff = [abs(avg[i] - A) for i in range(N)] idx = diff.index(min(diff)) print(idx + 1)" p03345,s094103864,Accepted,"a, b, c, k = map(int, input().split()) if k % 2 == 0: print(a - b) else: print(b - a)" p02727,s050924168,Accepted,"X,Y,A,B,C=map(int,input().split()) p=sorted([int(p) for p in input().split()])[-X:] q=sorted([int(q) for q in input().split()])[-Y:] r=[int(r) for r in input().split()] lst=sorted(p+q+r) print(sum(lst[-(X+Y):])) " p02761,s774335352,Wrong Answer,"import sys sys.setrecursionlimit(10 ** 7) N, M = map(int, input().split()) D = [-1] * N for _ in range(M): s, c = map(int, input().split()) if D[s-1] == -1 or D[s-1] == c: D[s-1] = c else: print('-1') exit() if D[0] == -1: D[0] = 1 elif D[0] == 0: print('-1') exit() ans = [] for d in D: if d == -1: ans.append(str(0)) else: ans.append(str(d)) # print(ans) print(''.join(ans)) " p03665,s519564428,Accepted,"N,P = map(int,input().split()) A = list(map(int,input().split())) odd = 0 even = 0 for i in range(N): if A[i] % 2 == 0: even += 1 else: odd += 1 if odd == 0: print(0) if P==1 else print(2**N) else: N -=1 print(2**N)" p02639,s358674411,Accepted,"l = list(map(int,input().split())) for i in range(5): if(l[i]==0): print(i+1) break" p03075,s978191930,Wrong Answer,"a=[int(input()) for i in range(5)] k=int(input()) for i in range(4): for j in range(i+1,5): if abs(a[i]-a[j])>k: print("":)"") exit() print(""Yay!"")" p02873,s249252408,Accepted,"s = input() n = len(s) L=[0] R=[0] cnt = 0 for i in range(n): if s[i] == '<': cnt += 1 else: cnt = 0 L.append(cnt) cnt = 0 s = s[::-1] for i in range(n): if s[i] == '>': cnt += 1 else: cnt = 0 R.append(cnt) R = R[::-1] ans = 0 for i in range(n+1): ans += max(R[i], L[i]) print(ans)" p02860,s624820531,Accepted,"N=int(input()) S=input() if len(S)%2==0 and S[:len(S)//2]==S[len(S)//2:]: print(""Yes"") else: print(""No"") " p03061,s958860388,Accepted,"#!/usr/bin/env python3 from itertools import* from fractions import* ac = lambda l: list(accumulate([0] + l, gcd)) n, *a = map(int, open(0).read().split()) print(max(gcd(s, t) for s, t in zip(ac(a), ac(a[::-1])[::-1][1:])))" p03281,s692539816,Wrong Answer,"import sys, math def input(): return sys.stdin.readline()[:-1] from itertools import permutations, combinations from collections import defaultdict, Counter from math import factorial from bisect import bisect_left # bisect_left(list, value) #from fractions import gcd sys.setrecursionlimit(10**7) N = int(input()) cntt = 0 for i in range(1, N+1, 2): cnt = 0 for j in range(1, int(math.sqrt(i)), 2): if i%j==0: cnt += 2 if cnt == 8: cntt += 1 print(cntt) " p02951,s580727634,Accepted,"A,B,C = map(int,input().split()) print(max(C-A+B,0)) " p02970,s501777171,Accepted,"def main(): import math N,D = map(int,input().split()) print(math.ceil(N/(2*D+1))) if __name__==""__main__"": main()" p04043,s462061142,Accepted,"import sys input = sys.stdin.readline a,b,c = sorted(list(map(int,input().split()))) print('YES' if a==b and b==5 and c==7 else 'NO') " p02615,s932394781,Accepted,"N = int(input()) A = list(map(int, input().split())) A = A * 2 A = sorted(A, reverse=True) A.pop(0) SUM = 0 for i in range(N-1): SUM += A[i] print(SUM)" p03627,s831098901,Wrong Answer,"n = int(input()) a_li = list(map(int,input().split())) import collections c = collections.Counter(a_li) mc = c.most_common() # [('a', 4), ('c', 2), ('b', 1)] if len(mc) == 1: print(0) exit() all_li = [] for m in mc: if m[1]>=2: all_li.append(m[0]) if len(all_li) <= 1: print(0) exit() all_li.sort(reverse=True) print(all_li[0]*all_li[1])" p02754,s539818392,Accepted,"N, A, B = map(int, input().split()) ab = A + B cnt = N // ab remain = N - (cnt * ab) blue = 0 if remain > A: blue = A else: blue = remain ans = A * cnt + blue print(ans)" p02755,s537136007,Accepted,"from math import ceil as c,floor as f a,b=map(int,input().split()) ah,bh=a+.99,b+.99 a1,a2=c(a/.08),f(ah/.08) b1,b2=c(b/.1),f(bh/.1) if a2 y: break cnt += 1 print(cnt) " p03469,s481097214,Accepted,"import sys input = sys.stdin.readline from collections import * S = list(input()[:-1]) S[3] = '8' print(''.join(S))" p02554,s816902543,Accepted,"mod = 1000000007 n = int(input()) a = 1 b = 1 c = 1 for i in range(n): a = a * 10 % mod b = b * 8 % mod c = c * 9 % mod d = (a - 2 * c + b + mod) % mod d = (d + mod) % mod print(d) " p02582,s092147166,Wrong Answer,"s = list(input()) l = len(s) rain =int() for x in range(l): if s[x]==""R"": rain=rain+1 else: if rain==0: rain=0 else: rain=rain print(rain)" p02953,s827550478,Wrong Answer,"n = int(input()) hs = list(map(int, input().split())) result = 'Yes' for i in range(1, n - 1): cur, prev, nex = hs[i], hs[i - 1], hs[i + 1] if cur < prev or cur > nex: cur -= 1 hs[i] = cur if not prev <= cur <= nex: result = 'No' break print(result) " p02572,s546319299,Accepted,"def main(): n = int(input()) a_list = list(map(int, input().split())) mod = 10 ** 9 + 7 x = 0 ans = 0 for i in range(1, n): x = (x + a_list[i - 1]) % mod ans = (ans + a_list[i] * x) % mod print(ans) if __name__ == ""__main__"": main() " p02659,s138018535,Accepted,"A, B = input().split("" "") A = int(A.strip()) B = int(B.strip().replace(""."", """")) print(A * B // 100)" p02791,s062730481,Wrong Answer,"import resource resource.setrlimit( resource.RLIMIT_DATA, (1024 * 1024 ** 2, -1)) 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)" p02693,s902333865,Accepted,"k = int(input()) a,b = map(int,input().split()) x = a//k y = b//k if y - x == 0: if a%k == 0: print('OK') else: print('NG') else: print('OK') " p03136,s606507715,Accepted,"#B n = int(input()) l = list(map(int, input().split())) lmax = max(l) l.sort(reverse=True) if lmax < sum(l[1:]): print(""Yes"") else: print(""No"")" p03730,s302560136,Accepted,"a,b,c=map(int,input().split()) for i in range(1,1000000): if (i*b+c)%a==0: print('YES') exit() print('NO')" p02873,s053325680,Accepted,"s=input() a=[0]*(len(s)+1) for i in range(len(s)): if s[i]==""<"": a[i+1]=a[i]+1 for i in range(len(s)-1,-1,-1): if s[i]=="">"": a[i]=max(a[i],a[i+1]+1) print(sum(a))" p03324,s612011099,Accepted,"d, n = map(int, input().split()) if n < 100: ans = n * 100**d print(ans) else: ans = 101 * 100**d print(ans)" p03632,s048130009,Accepted,"a,b,c,d=map(int,input().split()) if b<=c or d<=a: print('0') elif b<=d: print(min(b-c,b-a)) else: print(min(d-a,d-c))" p02596,s045875302,Accepted,"K = int(input()) j = 7%K p = -1 for i in range(1,K+1): if j == 0: print(i) p = 0 break j = ((j*10)+7)%K if p == -1: print(""-1"") " p03644,s223811182,Accepted,"n = int(input()) A = [0]*n for i in range(n): count = 0 flg_odd = 0 l = i i = i+1 while(True): if ( i%2 != 0): flg_odd = 1 if ( flg_odd == 1): A[l] = count break i = i//2 count += 1 m = A.index(max(A)) print(m+1)" p02838,s821425847,Accepted,"import numpy as np N = int(input()) A = np.fromiter(map(int, input().split()), np.int64) m = 1000000007 result = 0 for bit in range(60): c = int((A & 1).sum()) A >>= 1 result = (result + c * (N - c) * (1 << bit)) % m print(result) " p02912,s148080753,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): tmp = heapq.heappop(a) heapq.heappush(a,(-tmp//2)*(-1))#負の剰余では切り捨て方向が異なってしまうので,いったんプラスにする. print(-sum(a))" p03339,s643490688,Accepted,"# ABC098C N = int(input()) S = input() all_W_E = [0, 0] for s in S: if s == ""W"": all_W_E[0] += 1 else: all_W_E[1] += 1 now_W = 0 now_E = 0 ans_list = [0] * N for i in range(N): if S[i] == ""W"": ans_list[i] = (now_W + all_W_E[1] - now_E) now_W += 1 else: ans_list[i] = (now_W + all_W_E[1] - now_E - 1) now_E += 1 ##print(ans_list) print(min(ans_list))" p03730,s789276700,Wrong Answer,"A, B, C = map(int, input().split()) ans = ""No"" for i in range(1, B + 1): if i * A % B == C: ans = ""Yes"" print(ans) " p03645,s051482228,Accepted,"n,m = map(int,input().split()) ab_list = [list(map(int,input().split())) for nesya in range(m)] start = set() end = set() for ab in ab_list: if ab[0] == 1: start.add(ab[1]) elif ab[1] == n: end.add(ab[0]) ans = start&end if len(ans) > 0: print('POSSIBLE') else: print('IMPOSSIBLE') " p02714,s863902845,Wrong Answer,"n = int(input()) s = input().split()[0] s = list(s) sum = 0 for i in range(1, n): for j in range(i, n): for k in range(j, n): if ((s[i-1]!=s[j-1])&(s[j-1]!=s[k-1])&(s[i-1]!=s[k-1]))&((j-i)!=(k-j)): sum+=1 print(sum)" p02835,s764296527,Accepted,"A = list(map(int, input().split())) if sum(A) >= 22: print(""bust"") else: print(""win"") " p04044,s817375973,Wrong Answer,"n,_ = map(int,input().split()) l = sorted(input() for _ in range(n)) print(l)" p03804,s252199083,Accepted,"import sys input = sys.stdin.readline def main(): N, M = map(int, input().split()) A = [list(input().rstrip()) for _ in range(N)] B = [list(input().rstrip()) for _ in range(M)] mv = N - M + 1 for i in range(mv): for j in range(mv): sub_A = [r[j:j+M] for r in A[i:i+M]] if sub_A == B: print(""Yes"") exit() print(""No"") if __name__ == '__main__': main() " p02556,s254448605,Wrong Answer,"l, m = list(), list() for _ in range(int(input())): x, y = map(int, input().split()) l.append([x, y]) m.append([y, x]) l.sort(), m.sort() print(max(l[-1][0]-l[0][0]+l[-1][1]-l[0][1], m[-1][0]-l[0][0]+l[-1][1]-l[0][1])) " p02554,s005721683,Accepted,"n=int(input()) mod=10**9+7 ans=pow(10,n,mod) ans-=pow(9,n,mod)*2 ans+=pow(8,n,mod) ans%=mod print(ans) " p02602,s719263076,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) for i in range(K, N): if A[i] > A[i-K]: print(""Yes"") else: print(""No"")" p03986,s027352637,Accepted,"import sys input = sys.stdin.readline # sys.setrecursionlimit(100000) def main(): X = input().strip() stack = list() for s in X: if s == ""S"" or len(stack) < 1: stack.append(s) elif s == ""T"" and stack[-1] == ""T"": stack.append(s) else: stack.pop() return len(stack) if __name__ == ""__main__"": print(main())" p03012,s341966629,Accepted,"n = int(input()) w = list(map(int,input().split())) ans = 10000000000 for i in range(1,n): x = abs(sum(w[:i]) - sum(w[i:])) if x < ans: ans = x print(ans)" p03449,s915152654,Accepted,"num = int(input()) grid = [list(int(s) for s in input().split()) for _ in range(2)] max = 0 for i in range(num): candies = sum(grid[0][: i + 1] + grid[1][i: ]) max = candies if max < candies else max print(max)" p02786,s673687961,Accepted,"h=int(input()) ans=0 t=1 while t<=h: t*=2 print(t-1) " p03327,s337531733,Wrong Answer,"n=int(input()) print('ABC' if 1<=999 else 'ABD')" p02552,s102755291,Accepted,print(0 if input() == '1' else 1) p02951,s519477049,Accepted,"data = list(map(int, input().split())) A = data[0] B = data[1] C = data[2] rest = A - B remain = max(0, C - rest) print(remain) " p03161,s401416633,Wrong Answer,"n, k = map(int, input().split()) h = list(map(int, input().split())) dp = [10**8] * n 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] - h[i + j])) print(dp[n - 1])" p02640,s913133167,Accepted,"x,y=map(int, input().split()) if y>=2*x and 4*x>=y: if (y-2*x)%2==0 and (4*x-y)%2==0: print(""Yes"") else: print(""No"") else: print(""No"")" p02687,s696599027,Wrong Answer,"a=input() print(a)" p03145,s327925393,Accepted,"a,b,c=map(int,input().split()) print((a*b)//2)" p02982,s806827570,Wrong Answer,"n,d = map(int,input().split()) try: a = [list(map(int,input().split())) for j in range(0,n)] except EOFError: pass c = 0 r = 0 for i in range(0,n): for j in range(i+1,n): for k in range(0,d): c+=(a[i][k]-a[j][k])**2 ans = c**(1/2) if isinstance(ans,int) == True: r += 1 print(r) " p03067,s230454689,Accepted,"a, b, c = list(map(int, input().rstrip().split())) if (c >= a and c <= b) or (c >= b and c <= a): print(""Yes"") else: print(""No"")" p02996,s388078214,Accepted,"n = int(input()) d = [list(map(int,input().split())) for i in range(n)] d.sort(key=lambda x: x[1]) ans = 'Yes' t = 0 for i in d: t += i[0] if t>i[1]:ans='No' print(ans)" p02606,s537422668,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)" p03481,s809142421,Wrong Answer,"from math import log x, y = map(int, input().split()) a = int(log(y // x, 2)) print(a + 1)" p02690,s171536956,Accepted,"x = int(input()) for a in range(-118,119): for b in range(-119,118): if a**5 - b**5 == x: print(a,b) exit() " p02924,s914678525,Accepted,"N=int(input()) print(N*(N-1)//2)" p03281,s152231980,Accepted,"N = int(input()) def make_divisors(n): from collections import deque divisors = deque([]) 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) lst_divisors = list(divisors) lst_divisors.sort() return lst_divisors ans = 0 for i in range(1,-(-N//2)+1): now = 2*i-1 if len(make_divisors(now)) == 8: ans += 1 print(ans)" p02548,s411507045,Wrong Answer,"N = int(input()) count = 0 t = 0 for c in range (1, N): t = N-c for a in range(1,t): if t % a == 0: count +=1 print(count)" p02916,s644596460,Accepted,"N = int(input()) A = [int(a) for a in input().split()] B = [int(a) for a in input().split()] C = [int(a) for a in input().split()] ans = sum(B) pre_A = -1 for i in range(N): if pre_A + 1 == A[i]: ans += C[pre_A - 1] pre_A = A[i] print(ans)" p02948,s990903506,Accepted,"from heapq import* (N, M), *t = [map(int, s.split()) for s in open(0)] q = [0] * 10**5 v = [[] for _ in q] for a, b in t: v[a - 1] += b, z = 0 for i in v[:M]: for j in i: heappush(q, -j) z += -heappop(q) print(z)" p03087,s744389095,Accepted,"n, q = map(int, input().split()) s = input() # table = [0] * 100005 table = [0] * n for i in range(1, n): table[i] = table[i - 1] if s[i] == ""C"" and s[i - 1] == ""A"": table[i] += 1 for i in range(q): first, last = map(int, input().split()) print(table[last - 1] - table[first - 1]) " p03345,s311413618,Accepted,"#-*-coding:utf-8-*- import sys input=sys.stdin.readline def main(): a,b,c,k = map(int,input().split()) if abs(a-b)>10**18: print(""Unfair"") elif k % 2==0: print(a-b) else: print(b-a) if __name__==""__main__"": main()" p02899,s455142755,Wrong Answer,"n = int(input()) lst = list(map(int,input().split())) ans = [] for i in range(len(lst)): num = lst.index(i+1) ans.append(num) print(ans)" p02664,s575343484,Accepted,"input1 = str(input()) temp = """" for i in range(len(input1)): if input1[i] == ""P"": temp += ""P"" else: temp += ""D"" print(temp)" p02577,s920923203,Accepted,"N = list(map(int, str(input()))) s = sum(N) if(s % 9 == 0): print('Yes') else: print('No')" p02646,s285327881,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"")" p02713,s275019365,Wrong Answer,"N = int(input()) gcd_sum_of_2 = 9 if N == 1: print(1) elif N == 2: print(gcd_sum_of_2) else: M = N - 2 for i in range(M): gcd_sum_of_2 += (i + 2) * 3 + i + 3 print(gcd_sum_of_2)" p02802,s230160833,Accepted,"from collections import defaultdict as dic n, m = map(int, input().split()) ac = 0 pena = 0 d = dic(list) for i in range(m): pi, si = input().split() d[pi].append(si) for (k, v) in d.items(): pe = 0 flag = False for aw in v: if aw == 'WA': pe += 1 else: ac += 1 flag = True break if flag: pena += pe print(ac, pena) " p03127,s989703560,Accepted,"n = int(input()) A = list(map(int, input().split())) def gcd(a, b): while b != 0: c = a%b a = b b = c return a for i in range(1, n): A[i] = gcd(A[i-1], A[i]) print(A[-1])" p03077,s706718127,Accepted,"n = int(input()) x = [int(input()) for i in range(5)] d = n // min(x) if n%min(x)==0: print(d+4) else: print(d+5)" p03543,s050879384,Wrong Answer,"n = input() if len(set(n)) <= 2: print('Yes') else: print('No') " p03862,s957835425,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(1, N): if A[i]+A[i-1] > x: ans += A[i]+A[i-1]-x A[i] -= A[i]+A[i-1]-x print(ans)" p02832,s297415240,Accepted,"n = int(input()) l = list(map(int,input().split())) l1 = [0] for i in l: a = l1.pop() if i==a+1: l1.append(a) l1.append(i) else: l1.append(a) if len(l1)==1: print(-1) else: print(n-len(l1)+1)" p03494,s794047689,Accepted,"n=int(input()) a=list(map(int,input().split())) A=[] for i in range(n): x=0 for j in range(10**5): if a[i]%2==0: a[i]//=2 x+=1 if a[i]%2!=0: A.append(x) break print(min(A))" p02813,s801679751,Accepted,"import itertools n = int(input()) ps = tuple(map(int, input().split())) qs = tuple(map(int, input().split())) num_list = list(itertools.permutations([i for i in range(1, n+1)])) print(abs(num_list.index(ps) - num_list.index(qs)))" p02744,s495012904,Accepted,"n = int(input()) alp = [chr(i) for i in range(97, 97+26)] def update(a, m): a_new = [] m_new = [] for val_a, val_m in zip(a,m): for i in range(val_m + 2): a_new += [val_a + alp[i]] m_new += [max(val_m, i)] return a_new, m_new a = ['a'] m = [0] for i in range(n-1): a, m = update(a,m) for v in a: print(v)" p02719,s197744958,Accepted,"N,M=[int(x) for x in input().split()] print(min(abs(N-N//M*M),abs(N-(N//M+1)*M)))" p02583,s433974849,Accepted,"from itertools import combinations N = int(input()) L = list(map(int, input().split())) if len(L) < 3: print(0) exit() cnt = 0 for edges in combinations(L, 3): if len(set(edges)) == 3: edges = list(edges) edges.sort() a, b, c = edges if c < a + b: cnt += 1 print(cnt) " p02640,s048386412,Wrong Answer,"n,m = map(int, input().split()) k = n*4 r = k-m if(r == 0): print(""Yes"") else: if(r >= 0): if(r/2): print(""Yes"") else: print(""No"") else: print(""No"")" p02699,s081238969,Accepted,"s,w = map(int,input().split()) if s > w: print(""safe"") else: print(""unsafe"")" p02780,s913762621,Accepted,"N,K = map(int,input().split()) p = list(map(int,input().split())) summ = sum(p[i] for i in range(K)) sum_list = [summ] maximum = 0 for i in range(N - K): summ += p[i + K] - p[i] sum_list.append(summ) maximum = max(sum_list) print(""{}"".format((maximum + K) / 2))" p03994,s872242029,Accepted,"def main(): import sys input = sys.stdin.readline s = list(input().strip()) K = int(input()) for i, c in enumerate(s): if c == 'a': continue z = 123 - ord(c) if K >= z: s[i] = 'a' K -= z if K == 0: break s[-1] = chr(((ord(s[-1])-97+K))%26+97) print(''.join(s)) if __name__ == '__main__': main()" p03611,s267970151,Accepted,"from collections import Counter N = int(input()) C = Counter() for a in map(int, input().split()): C[a] += 1 C[a - 1] += 1 C[a + 1] += 1 print(max(C.values())) " p02603,s986422499,Accepted,"n = int(input()) l = list(map(int, input().split())) money = 1000 for i in range(n-1) : if l[i] < l[i+1] : t = money // l[i] money += t*(l[i+1]-l[i]) print(money)" p03860,s189118875,Accepted,"li = input().split() print(""A""+li[1][0].upper()+""C"")" p03061,s927363235,Wrong Answer,"from functools import reduce from fractions import gcd n=int(input()) s=list(map(int,input().split())) b = reduce(gcd, s) if len(s)==2: print(max(s)) exit() ma=1 for i in range(len(s)-1): t=s[i] s[i]=s[i+1] c=reduce(gcd,s) ma=max(ma,c) s[i]=t else: t=s[i] s[i]=s[i-1] c=reduce(gcd,s) ma=max(ma,c) s[i]=t print(ma)" p03261,s644773648,Wrong Answer,"N = int(input()) W=[] ss=True for i in range (N): W.append(input()) for t in range (N-1): if W[t-1][-1]==W[t][0]: ss=True else: ss=False W=dict.fromkeys(W) if len(W)!=N: ss=False if ss==False: print(""No"") else: print(""Yes"") " p02612,s762028107,Accepted,"N = int(input()) print(0 if N % 1000 == 0 else 1000 - N % 1000)" p03037,s471154582,Wrong Answer,"N,M = map(int,input().split()) L = 1 R = N for i in range(M): l,r = map(int,input().split()) if L <= l: L = l if r <= R: R = r print(R-L+1)" p03317,s349019937,Accepted,"n,k = map(int,input().split()) a_L = list(map(int,input().split())) ans = 1 n = n-k while True: if n<=0: print(ans) exit() n = n-k+1 ans += 1" p03804,s140334249,Accepted,"n,m=map(int,input().split()) a=[input() for i in range(n)] b=[input() for _ in range(m)] for i in range(n-m+1): for j in range(n-m+1): flag=True for k in range(m): for l in range(m): if a[i+k][j+l]!=b[k][l]: flag=False if flag: print(""Yes"") exit() print(""No"")" p02835,s541603183,Wrong Answer,"a = map(int, input().split()) if sum(a) <= 21: print('win') else: print('burst')" p02658,s553214694,Wrong Answer,"import numpy N = int(input()) A = [int(x) for x in input().split()] B = numpy.prod(A) if B >= 10**8: print(-1) else: print(B) " p02602,s690495555,Accepted,"n, k = map(int, input().split()) a_i = list(map(int, input().split())) for x in range(n - k): if a_i[x] < a_i[x + k]: print(""Yes"") else: print(""No"")" p03696,s535441351,Accepted,"n = int(input()) s = input() r = 0 l = 0 cnt = 0 for i in s: if i==')': cnt+=1 if cnt>0: cnt-=1 l+=1 else: cnt-=1 print(l*'('+s+')'*(-cnt))" p02718,s188879410,Wrong Answer,"n,m=map(int,input().split()) l=list(map(int,input().split())) suml=sum(l) ##print(suml) temp=4*m temp=suml/temp flag=False for i in range(n): if m==0: flag=True break else: if l[i]>temp: ## print(l[i],temp) m-=1 if flag: print(""Yes "") else: print(""No "") " p03493,s162035263,Accepted,print(int(input())%9) p03469,s594270860,Accepted,"def main(): s = list(input()) s[:4] = ['2','0','1','8'] print(''.join(s)) main() " p02888,s726781333,Wrong Answer,"import bisect N = int(input()) L = list(map(int, input().split())) s = 0 L = sorted(L) for c in reversed(range(2, N)): for b in reversed(range(1, c)): a = bisect.bisect_left(L, L[c]-L[b]) if a 0: print(""delicious"") elif A-B > -X: print(""safe"") else: print(""dangerous"")" p03001,s862248953,Wrong Answer,"#C - Rectangle Cutting W,H,x,y = map(int,input().split()) def main(W,H,x,y): if W == x or H == y or x==0 or y==0: ans1 = W*H ans2 = 0 else: tmp1 = min((W-x)*H,x*H) tmp2 = min(W*(H-y),W*y) ans1 = max(tmp1,tmp2) if tmp1 == tmp2: ans2 = 1 else: ans2 = 0 print(ans1,ans2) main(W,H,x,y) " p02603,s982230576,Wrong Answer,"#!/usr/bin/env python3 import sys N = int(input()) A = list(map(int, input().split())) M = 1000 kabu = 0 cur = A[0] for i in range(1,N): if cur > A[i]: # 持ってる株全部売る M = M + kabu * cur kabu = 0 if cur < A[i]: # 所持金全部株に変える kabu = M // cur M = M % cur cur = A[i] M = M + kabu * A[N-1] print(M)" p02959,s461620355,Accepted,"n = int(input()) a = list(map(int,input().split()))[::-1] b = list(map(int,input().split()))[::-1] ans = 0 for i in range(n): t=min(b[i],a[i]) ans+=t a[i]-=t b[i]-=t t=min(b[i],a[i+1]) ans+=t a[i+1]-=t print(ans)" p03745,s799778675,Accepted,"n = int(input()) num_list = list(map(int, input().split())) ans = 1 cnt_list = [0] * n a = int() for i in range(1,n): if num_list[i-1] > num_list[i]: cnt_list[i] = -1 if num_list[i-1] < num_list[i]: cnt_list[i] = 1 while 1 in cnt_list and -1 in cnt_list: del cnt_list[:max(cnt_list.index(1),cnt_list.index(-1))] cnt_list[0] = 0 ans += 1 print(ans)" p02900,s647328679,Wrong Answer,"def divisors(n): s = set() for x in range(2, int(n ** 0.5) + 1): while n % x == 0: s.add(x) n /= x if n == 1: break return s a, b = map(int, input().split()) d = divisors(a) & divisors(b) print(len(d) + 1) " p03557,s589827840,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()))) ans=0 for i in b: A=bisect.bisect_left(a,i) B=len(b)-bisect.bisect_right(c,i) ans+=A*B print(ans)" p02598,s988146584,Accepted,"N, K = map(int, input().split()) A = [int(i) for i in input().split()] l = 0 r = 10 ** 9 + 1 while l + 1 < r: p = (l + r) // 2 n = 0 ok = False for v in A: n += (v // p - 1) if not v % p == 0: n += 1 if n > K: break else: ok = True if not ok: l = p else: r = p print(r) " p03077,s578058080,Accepted,"n = int(input()) l = [int(input()) for _ in range(5)] if min(l) >= n: print(5) else: print((n-1)//min(l) + 5)" p03035,s676093650,Accepted,"a, b = map(int, input().split()) if a >= 13: print(b) elif 6<=a<=12: print(b//2) else: print(0)" p03163,s412755248,Accepted,"import numpy as np N, W = map(int, input().split(' ')) items = [tuple(map(int, input().split(' '))) for _ in range(N)] dp = np.zeros(shape=W + 1, dtype=np.int64) for weight, value in items: dp[weight:] = np.maximum(dp[weight:], dp[:-weight] + value) print(dp[-1]) " p02753,s611346879,Wrong Answer,"list = str(input()) if list is ""AAA"" or list is ""BBB"" : print(""No"") else : print(""Yes"") " p02817,s040165884,Accepted,"S,T = input().split() ans = T + S print(ans)" p02900,s184873233,Accepted,"import math import sys from collections import deque import heapq import copy import itertools from itertools import permutations from itertools import combinations import bisect def mi() : return map(int,sys.stdin.readline().split()) def ii() : return int(sys.stdin.readline().rstrip()) def i() : return sys.stdin.readline().rstrip() a,b=mi() while a!=0: c=a a=b%a b=c ans=1 for i in range(2,int(math.sqrt(b)+2)): if b%i==0: ans+=1 while b%i==0: b=int(b/i) if b!=1: ans+=1 print(ans)" p02608,s193018905,Accepted,"def main(): N = int(input()) ans = [0 for _ in range(10005)] for i in range(1,100): for j in range(1,100): for k in range(1,100): v = i**2 + j**2 + k**2 + i*j + j*k + k*i if v < 10005: ans[v]+=1 for i in range(1,N+1): print(ans[i]) if __name__ == ""__main__"": main()" p02924,s100990696,Accepted,"N=int(input()) ans=N*(N-1)//2 print(int(ans))" p03285,s664329362,Accepted,"N = int(input()) def exists(): for seven in range(N): M = N - seven * 7 if 0 <= M and M % 4 == 0: return True return False print('Yes' if exists() else 'No') " p03962,s057297852,Wrong Answer,"a, b, c= map(int, input().split()) d=(a,b,c) e=len(d) print(e)" p03274,s076638675,Accepted,"n, k = map(int, input().split()) l = list(map(int, input().split())) ptns = [] for i in range(n-k+1): ptns.append(abs(0 -l[i]) + abs(l[i] - l[i+k-1])) ptns.append(abs(0 -l[i+k-1]) + abs(l[i+k-1] - l[i])) print(min(ptns))" p04033,s172670453,Accepted,"a,b = map(int,input().split()) if a * b <= 0: print(""Zero"") exit() if a > 0: print(""Positive"") exit() if (b - a) % 2 == 0: print(""Negative"") exit() else: print(""Positive"") " p03281,s108851286,Accepted,"def make_divisors(n): div=[] for i in range(1,-int(-n**0.5//1)): if n%i==0: div.append(i) div.append(n//i) if n%(n**0.5)==0: div.append(int(n**0.5)) return div n=int(input()) ans=[] for i in range(1,n+1,2): if len(make_divisors(i))==8: ans.append(i) print(len(ans))" p03557,s213762449,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_b = 0 b_c = 0 count = 0 for b_item in b: while a_b < N and a[a_b] < b_item: a_b += 1 while b_c < N and c[b_c] <= b_item: b_c += 1 count += (a_b * (N - b_c)) print(count) " p03761,s938149760,Accepted,"from collections import Counter n = int(input()) s = Counter(input()) for i in range(n-1): s &= Counter(input()) print("""".join(sorted(s.elements())))" p02618,s181806814,Accepted,"D = int(input()) c = [int(_) for _ in input().split()] s = [[int(_) for _ in input().split()] for _ in range(D)] sat = 0 last = [0] * 26 for d in range(D): v = -1000000 for x in range(26): if v < (d + 1 - last[x]) * c[x]: j = x v = (d + 1 - last[x]) * c[x] last[j] = d + 1 print(j+1) for i in range(26): sat -= (d + 1 - last[i]) * c[i] sat += s[d][j] # print(sat) " p03448,s983628860,Accepted,"a = int(input()) b = int(input()) c = int(input()) x = int(input()) s = 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: s += 1 print(s)" p03469,s523868117,Accepted,"s = input() print(s.replace('7','8',1))" p03861,s804264464,Wrong Answer,"#!/usr/bin/env python3 import collections import itertools as it import math #import numpy as np # = input() # = int(input()) a, b, x = map(int, input().split()) # = list(map(int, input().split())) # = [int(input()) for i in range(N)] # # c = collections.Counter() ans = (b - a) // x ans += 1 if a % x == 0 else 0 #ans += 1 if b % x == 0 else 0 print(ans) " p03852,s846725551,Wrong Answer,"c = input() if c == ""a"" or c == ""e"" or c == ""i"" or c == ""o"" or c == ""u"": print(""vowel"") else: print(""constant"")" p03071,s228543563,Wrong Answer,"a = input().split() b = 0 for i in range(len(a)): a.sort(reverse=True) b = b + int(a[0]) if int(a[0]) <= 0: continue else: a[0] = str(int(a[0]) - 1) print(b)" p02759,s130902825,Wrong Answer,"N=int(input()) if N == 1: print(1) elif N == 2: print(1) else: if N % 2 == 1: print ((N / 2) + 1) else: print (N / 2)" p02694,s031906875,Accepted,"ii = lambda : int(input()) mi = lambda : map(int,input().split()) li = lambda : list(map(int,input().split())) x = ii() y = 100 for i in range(1,10**18): y = int(y * 1.01) if y >= x: print(i) break" p02577,s581533328,Accepted,"N = input() a = 0 for i in N: a += int(i) print(""Yes"" if a%9==0 else ""No"")" p02780,s998012839,Accepted,"import numpy as np N,K = (int(x) for x in input().split()) p1 = np.array(list(map(int, input().split()))) s1 = p1.cumsum() s2 = np.append(0, s1) p2 = np.array([(s2[i+K] - s2[i]) for i in range(N-K+1)]) max = np.amax(p2) print((max+K) / 2)" p02725,s668018285,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 k,n = map(int,input().split()) A = list(map(int,input().split())) mans = k + A[0] - A[-1] for i in range(n-1): mans = max(mans,A[i+1]-A[i]) print(k-mans)" p03760,s117126955,Accepted,"o = input() e = input() ans = '' for i in range(len(e)): ans += o[i]+e[i] if len(o) != len(e): ans += o[len(o)-1] print(ans)" p02773,s953043553,Accepted,"from collections import Counter def solve(): N = int(input()) S = [input() for _ in range(N)] c = Counter(S) M = max(c.values()) ans = [] for k,v in c.items(): if v==M: ans.append(k) ans.sort() return ans print(*solve(),sep='\n')" p02847,s281523359,Accepted,"day = input() days = {'SUN':0, 'MON':1, 'TUE':2, 'WED':3, 'THU':4, 'FRI': 5,'SAT':6} print(7 - days[day])" p02595,s991602509,Accepted,"import bisect,collections,copy,heapq,itertools,math,string from collections import defaultdict as D from functools import reduce import numpy as np from numba import njit import sys 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())) N,D = LI() _XY = [LI() for _ in range(N)] XY = np.array(_XY) #C = np.zeros(N + 1) # print(XY) # print(np.linalg.norm(XY[1]-XY[0])) count = 0 for XiYi in XY: if (XiYi[0]**2 + XiYi[1]**2) <= D**2: count += 1 print(count)" p02730,s552575068,Accepted,"s=input() n = len(s) ss =s[::-1] sss =s[1:((n-1)//2)-1] mmm = sss[::-1] ssss = s[((n+3)//2)-1:n] mmmm = ssss[::-1] if s == ss and sss == mmm and ssss == mmmm: print('Yes') else: print('No')" p02583,s447831199,Wrong Answer,"# -*- coding: utf-8 -*- import itertools # 棒の本数 n = int(input()) # 棒のリスト lods = list(map(int, input().split())) # 3本なければ三角形は作れない if (n<3): print(0) # 確認 count = 0 for data in itertools.combinations(lods, 3): if (data[0] != data[1] and data[1] != data[2] and data[2] != data[0] and (data[0]+data[1]) > data[2] and (data[1]+data[2]) > data[0] and (data[2]+data[0]) > data[1]): count += 1 print(count)" p02661,s388069573,Wrong Answer,"import numpy as np N = int(input()) AB = [] for n in range(N): AB.append(list(map(int, input().split()))) index = [AB[i][0] for i in range(len(AB))] index = np.argsort(index) AB = list(np.array(AB)[index]) if len(AB)%2==0: A = AB[len(AB)//2-1] B = AB[len(AB)//2] middle = max(B) - min(A) print(middle+1) else: C = AB[len(AB)//2] print(C[-1]-C[0])" p03095,s313048154,Wrong Answer,"from collections import Counter n = int(input()) s = list(input()) c = Counter(s) ans = 1 for i in c.values(): ans *= (i+1) print(ans-1)" p02760,s489532860,Accepted,"a = [] for i in range(3): a.extend(list(map(int,input().split()))) n = int(input()) b = [] cnt=[] pattern=[[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[2,4,6]] for i in range(n): b.append(int(input())) for j , x in enumerate(a): if x == b[i]: cnt.append(j) for q,w,e in pattern: if q in cnt and w in cnt and e in cnt: print('Yes') break else: print('No')" p02982,s700254016,Accepted,"N,D = map(int,input().split()) X = [] for i in range(N): x = list(map(int,input().split())) X.append(x) Count = 0 for i in range(N-1): for j in range(i+1,N): k = 0 for t in range(D): k += (X[i][t]-X[j][t])**2 k = k**(1/2) if k == int(k): Count += 1 print(Count)" p02629,s344552833,Accepted," def get_char(x): return chr(ord('a') + x) def submit(): n = int(input()) n -= 1 ans = [] while True: r, q = divmod(n, 26) c = get_char(q) ans.append(c) if r == 0: break n -= q n //= 26 n -= 1 print("""".join(reversed(ans))) submit()" p03720,s287691386,Accepted,"n,m=map(int,input().split()) ab=[0]*n for i in range(m): a,b=map(int,input().split()) ab[a-1]+=1 ab[b-1]+=1 for i in ab: print(i)" p02910,s253030845,Wrong Answer,"s = input() flg = 0 for i in range(len(s)): if i % 2 == 0 and (s[i] != ""R"" and s[i] != ""U"" and s[i] != ""D""): flg = 1 elif i % 2 == 1 and (s[i] != ""L"" and s[i] != ""U"" and s[i] != ""D""): flg = 1 else: continue if flg == 0: print(""YES"") else: print(""NO"") " p03672,s777328398,Accepted,"#n = int(input()) #a, b = map(int,input().split()) #l = list(map(int,input().split())) #l = [list(map(int,input().split())) for i in range(n)] s = input() n = len(s) def isrepeat(s): res = False n = len(s) if s[0:n//2]+s[0:n//2] == s: res = True return res for delnum in range(1, n): if (n-delnum) % 2 == 0: if isrepeat(s[0:n-delnum]): ans = n-delnum break print(ans) " p03698,s339809465,Wrong Answer,"S = input() if len(S) != len(set(S)): print('yes') else: print('no') " p03327,s160077429,Accepted,"print(""ABC"" if int(input()) < 1000 else ""ABD"")" p03162,s430099964,Wrong Answer," n = int(input()) x = [-1]*n for i in range(n): x[i] = list(map(int, input().split())) ans = [[0]*3 for i in range(n)] ans[0] = x[0] for k in range(1,n): for j in range(3): ans[k][j] = max(ans[k-1][(j+1)%3], ans[k-1][(j+2)%3]) + x[k][j] print(ans[i]) print(max(ans[n-1])) " p02973,s375108296,Accepted,"import bisect n = int(input()) a = [] for i in range(n): x = int(input()) a.append(x) a = a[::-1] stack = [a[0]] for i in range(1, n): index = bisect.bisect_right(stack, a[i]) if index == len(stack): stack.append(a[i]) else: stack[index] = a[i] print(len(stack)) " p04020,s562854873,Accepted,"N=int(input()) A=[0]*N for i in range(N): A[i]=int(input()) A.append(0) K=0 S=0 for a in A: if a: S+=a else: K+=S//2 S=0 print(K)" p03695,s031886598,Wrong Answer,"n = int(input()) a = list(map(int, input().split())) a.sort() l = [x//400 if x//400 <= 7 else 8 for x in a] p = [0]*8 for i in l: if i < 8: p[i] = 1 pmin = sum(p) if sum(p) != 0 else 1 pmax = sum(p) + l.count(8) print(l) print(p) print(pmin, pmax)" p02645,s409876696,Accepted,print(input()[0:3]) p03815,s476438633,Accepted,"import sys input = sys.stdin.buffer.readline def main(): N = int(input()) use = N//11 rest = N%11 if rest == 0: print(2*use) elif rest <= 6: print(2*use+1) else: print(2*use+2) if __name__ == ""__main__"": main()" p03038,s268523114,Accepted,"#5618213 n,m = map(int,input().split()) a = list(map(int,input().split())) bc = [list(map(int,input().split())) for i in range(m)] bc.sort(key=lambda x:x[1], reverse=True) for b,c in bc: a.extend([c]*b) if len(a) > 2*n: break a.sort(reverse=True) print(sum(a[:n])) " p03284,s369011059,Accepted,"n, k = map(int, input().split()) if n < k: print(1) elif n % k == 0: print(0) else: print(1)" p03471,s862219206,Accepted,"N,Y = map(int,input().split()) for i in range(N+1): for j in range(N+1): a = i b = j c = N-i-j if c < 0: continue else: price = a*1000+b*5000+c*10000 if price == Y: print(c,b,a) exit() print(-1,-1,-1)" p02718,s702724069,Accepted,"n, m = map(int, input().split()) a = [int(_) for _ in input().split()] aa = [0] * n for i in range(n): aa[i] = a[i] * (4*m) lim = sum(a) ans = 0 for i in range(n): if aa[i] >= lim: ans += 1 else: pass if m <= ans: print('Yes') else: print('No')" p02607,s610267547,Accepted,"n = int(input()) arr = list(map(int,input().split())) ans = 0 for i in range(0,len(arr)+(n%2),2): if arr[i] % 2 != 0: ans += 1 print(ans)" p02693,s755330510,Accepted,"import sys K = int(input()) A,B = map(int,input().split()) tmp = A//K for i in range(1000): t = (tmp+i) * K if A<= t <= B: print('OK') sys.exit() if t > B: break print('NG') " p02676,s823470535,Accepted,"K = int(input()) S = input() if len(S) <= K: print(S) else: S = list(S) for i in range(K): print(S[i], end='') print('...')" p02835,s294918830,Wrong Answer,"a, b, c = map(int, input().split()) if a + b + c <= 22: print('bust') else: print('win') " p02900,s312666801,Accepted,"import fractions a,b = map(int,input().split()) gcd = fractions.gcd(a,b) def prime_factorize(n): result = [] for i in range(2,int(n**0.5)+1): while n % i == 0: n //= i result.append(i) if n != 1: result.append(n) return result ans = len(set(prime_factorize(gcd))) print(ans+1)" p02747,s325757608,Accepted,"s = input() r = True if len(s) % 2 == 0: for i in range(0, len(s)-1, 2): if s[i:i+2] != ""hi"": r = False print(""Yes"" if r else ""No"") else : print(""No"")" p02959,s614657819,Accepted,"N = int(input()) A = list(map(int,input().split())) B = list(map(int,input().split())) ans = 0 for i in range(N): one = min(A[i],B[i]) two = min(A[i+1],B[i]-one) ans+=one+two A[i+1]-=two print(ans)" p02916,s899719548,Accepted,"def main(): N = int(input()) A = [int(x) for x in input().split()] B = [int(x) for x in input().split()] C = [int(x) for x in input().split()] ans = sum(B) k = -1 for i in A: if i == k + 1: ans += C[k-1] k = i print(ans) if __name__ == ""__main__"": main() " p03131,s376619826,Accepted,"k,a,b=map(int,input().split()) if a+1k: print(1+k) else: num1=a-1+2 num2=b-a print(b+((k-num1)//2)*num2+(k-num1)%2) else: print(1+k) " p02814,s632975898,Wrong Answer,"# 2020/01/10 from fractions import gcd n,m=map(int,input().split()) a=list(map(int,input().split())) aa=list(map(lambda x: x//2,a)) lcm=aa.pop() for e in aa: lcm=(lcm*e)//gcd(lcm,e) print(-(-m//lcm//2) if m>=lcm else 0)" p03821,s707951362,Wrong Answer,"from sys import stdin import fractions n = int(stdin.readline().rstrip()) li = [[0,0]]+[list(map(int,stdin.readline().rstrip().split())) for _ in range(n)] li = li[::-1] count = 0 for i in range(n): if li[i][0]%li[i][1] != 0: count += li[i][1]-li[i][0]%li[i][1] li[i+1][0] += count print(li) print(count)" p02743,s687883716,Accepted,"a, b, c = map(int, input().split()) if((c-a-b)>0 and (c-a-b)**2>4*a*b): print(""Yes"") else: print(""No"")" p03160,s572008625,Accepted,"N = int(input()) h = list(map(int, input().split())) dp = [0]*N dp[1] = abs(h[1]-h[0]) for i in range(2,N): dp[i] = min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1])) print(dp[-1]) " p03680,s155683241,Accepted,"n=int(input()) a=[] for _ in range(n): a.append(int(input())) t=0 for i in range(1,n+1): t=a[t]-1 if t==1: print(i) break else: print(-1)" p04045,s967436231,Wrong Answer,"N, K = map(int, input().split()) D = set(map(int, input().split())) while True: if set(str(N)) == set(str(N)) - D: print(N) break else: N += 1" p03284,s420012392,Wrong Answer,"a, b = map(int, input().split()) print(abs((a%b)-(a//b)))" p02910,s796748320,Accepted,"Tap = input() len_Tap = len(Tap) count = 0 for i in range(len_Tap): if (i+1) % 2 == 1: if Tap[i] == 'R' or Tap[i] == 'U' or Tap[i] == 'D': count += 1 else: if Tap[i] == 'L' or Tap[i] == 'U' or Tap[i] == 'D': count += 1 if count == len_Tap: print('Yes') else: print('No')" p02556,s221419830,Accepted,"N = int(input()) plus = [] minus = [] for _ in range(N): x, y = map(int, input().split()) plus.append(x + y) minus.append(x - y) print(max(max(plus) - min(plus), max(minus) - min(minus))) " p02658,s608233195,Accepted,"n = int(input()) a = list(map(int,input().split())) ans=1 if 0 in a: ans=0 else: for i in a: ans*=i if ans>10**18: ans=-1 break print(ans)" p03860,s759837863,Accepted,"a, s, c = map(str, input().split()) print(a[0]+s[0]+c[0])" p03000,s201707185,Accepted,"n,x=map(int,input().split()) l=list(map(int,input().split())) sumd=0 for i in range(n): sumd+=l[i] if sumd>x: print(i+1) exit() print(i+2)" p02765,s024133780,Accepted," import sys # 再起回数上限変更 sys.setrecursionlimit(1000000) N, R = map(int, input().split()) if N >= 10: print(R) sys.exit() print(R + 100 * (10 - N)) " p02725,s230079488,Accepted,"hoge = input().split() K = int(hoge[0]) N = int(hoge[1]) A_list = list(map(int,input().split())) kankaku = [] for i in range(len(A_list) - 1): kankaku.append(A_list[i+1] - A_list[i]) kankaku.append(A_list[0] - A_list[-1] + K) _kankaku_max = max(kankaku) print(K - _kankaku_max)" p03799,s861470891,Accepted,"n, m = map(int, input().split()) cnt = min(n, m // 2) print(cnt + (m - cnt * 2) // 4) " p02658,s320827362,Accepted,"N = int(input()) A = list(map(int,input(). split ())) max = 10**18 if 0 in A: print(0) exit() prod = 1 for a in A: prod *= a if prod > max: print(-1) exit() print(prod) " p02787,s218967882,Wrong Answer,"[h,n] = [int(i) for i in input().split()] ab = [] for i in range(n): ab.append([int(j) for j in input().split()]) dp =[0] * 10001 + [10 ** 10] * 10000 for i in range(10001,20000): for ls in ab: dp[i] = min(dp[i],dp[i-ls[0]]+ls[1]) print(dp[10000+h]) " p02911,s015843566,Accepted,"from collections import defaultdict N,K,Q = map(int, input().split()) dic = defaultdict(lambda:0) for _ in range(Q): dic[int(input())] += 1 for i in range(1,N+1): if K + dic[i] - Q > 0: print('Yes') else: print('No')" p03785,s012815055,Accepted,"N, C, K = map(int,input().split()) T = [int(input()) for i in range(N)] T.sort(reverse=True) #print(T) t_before = T[0] cnt = 0 ans = 0 for t in T: #print(t, t_before, cnt, ans) if t_before - t <= K and cnt + 1 <= C: cnt += 1 continue else: t_before = t cnt = 1 ans += 1 print(ans+1)" p03012,s510587293,Accepted,"n = int(input()) W = list(map(int,input().split())) total = sum(W) ans = total s1 = 0 for i in range(n-1): s1 += W[i] ans = min(ans,abs(total-2*s1)) print(ans)" p02639,s547237173,Wrong Answer,"a = list(map(int,input().split())) cnt = 1 for i in a: if i == 0: print(cnt) cnt += 1 " p02924,s488049909,Wrong Answer,"n = int(input()) print(int((n*(n-1))/2))" p03910,s160102896,Wrong Answer,"def main(): N = int(input()) if N == 1 or N == 2: return print(N) ans = set() for i in range(1, N+1): N -= i if N in ans or N <= 2: N += i ans.add(N) break ans.add(i) print(*ans, sep=""\n"") if __name__ == '__main__': main() " p03427,s734889309,Accepted,"n = input(); a = 0; b = 0; c = int(n[0]) for i in range(len(n)): if n[i] != ""9"": if a == 0: a += 1; b = 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(c-1+9*(len(n)-1))" p02647,s490787598,Wrong Answer,"import numpy as np # Calculate intensity N, K = [int(v) for v in input().split("" "")] A_arr = [int(v) for v in input().split("" "")] step = np.arange(len(A_arr)) def Luminate(A_arr, i): isLuminated = abs(step - i) < np.array(A_arr)+1 return isLuminated def get_Intensity(A_arr): return [np.sum(Luminate(A_arr, i)) for i in range(len(A_arr))] Intensity = A_arr for i in range(K): Intensity = get_Intensity(Intensity) print(Intensity)" p02724,s081026852,Accepted,"x=int(input()) s=x//500 a=(x-500*s)//5 print(1000*s+5*a)" p03548,s358185432,Accepted,"x,y,z=map(int,input().split()) print((x-z)//(y+z))" p04019,s826343052,Accepted,"S = input() x = y = 0 n = w = s = e = 0 for c in S: if c == 'N': n += 1 elif c == 'W': w += 1 elif c == 'S': s += 1 else: e += 1 if (n == 0 and s > 0) or (s == 0 and n > 0): y = 1 if (w == 0 and e > 0) or (e == 0 and w > 0): x = 1 print('Yes' if x == 0 and y == 0 else 'No')" p02882,s108122559,Wrong Answer,"import math a,b,x=map(int,input().split()) aa=max(0,2*a**2*b-2*x) bb=a**3 print(math.degrees(math.atan2(aa,bb))) " p02700,s766790636,Accepted,"k = list(map(int, input().split() ) ) t = 1 while k[0] > 0 and k[2] > 0: if t == 1: k[2] -= k[1] t=2 else: k[0] -= k[3] t=1 if t==2: print(""Yes"") else: print(""No"")" p03035,s049704488,Wrong Answer,"A,B=map(int,input().split()) if A>=13: print(B) elif A>=6 and A<=12: print(B/2) else: print(0) " p02994,s957395874,Accepted,"N,L=map(int,input().split()) Aji=[0]*N Sum=0 AjiMin=10**9 EatApple=0 for i in range(N): if i==0: Aji[i]=L else: Aji[i]=Aji[i-1]+1 Sum+=Aji[i] AbsVal=abs(Aji[i]) if AbsVal max(x_s) and z <= min(y_s): ok = True break print(""No War"" if ok else ""War"") if __name__ == '__main__': main() " p03062,s176721156,Accepted,"n = int(input()) a = list(map(int, input().split())) b = min(a,key=abs) c = 0 sum_abs_a = 0 for i in range(n): sum_abs_a += abs(a[i]) for i in a: if i < 0: c += 1 if c % 2 == 0: print(sum_abs_a) else: print(sum_abs_a - abs(b)*2) " p02778,s334271079,Accepted,"S=input() print('x' * len(S))" p02595,s747968423,Wrong Answer,"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: ans += 1 print(ans)" p02859,s628451534,Accepted,print(int(input())**2) p02628,s862715561,Wrong Answer,"n, k = map(int, input().split()) a = list(map(int, input().split())) sorted(a) print(sum(a[:k]))" p02948,s213271365,Wrong Answer,"n,m=map(int,input().split()) d=[[] for _ in range(n)] for i in range(n): a,b=map(int,input().split()) d[i]=(b,a) d=sorted(d)[::-1] ans=0 for i,j in d: if m int: """""" >>> f(5, [2, 1, 5, 4, 3]) 4 """""" ans = 0 n_max: int = a_list[0] for i, a_i in enumerate(a_list): if n_max > a_i: ans += n_max - a_i else: n_max = a_i return ans if __name__ == '__main__': n = int(input()) a_list = list(map(lambda x: int(x), input().split())) print(f(n, a_list))" p03543,s187342917,Accepted,"n = input() a = int(n[:3]) b = int(n[1:]) if a%111 == 0 or b%111 == 0: print('Yes') else: print('No')" p02708,s247536584,Accepted,"n, k = map(int, input().split()) pos_num = [] for i in range(n+2): st_num = int((i*(i-1))/2) ed_num = int(((2*n-i+1)*i)/2) # print(i,st_num,ed_num) pos_num.append(ed_num-st_num+1) print(sum(pos_num[k:])%(10**9+7)) " p03745,s403655980,Accepted,"n=int(input()) a=list(map(int,input().split())) ans=1 flag=0 for i in range(n-1): if a[i+1]>a[i]: if flag==-1: ans+=1 flag=0 else: flag=1 if a[i+1] b: print(a-1) else: print(a)" p02602,s210406054,Accepted,"N,K = list(map(int,input().split())) LIST_A = list(map(int,input().split())) for i in range(N-K): target_1 = LIST_A[i+K]-LIST_A[i] if target_1 > 0: print(""Yes"") else: print(""No"")" p02572,s633818628,Accepted,"N=int(input()) A=list(map(int, input().split())) MOD=1000000007 s=0 for i in range(1,N): s+=A[i] s%=MOD ans=0 for i in range(N-1): ans+=A[i]*s ans%=MOD s-=A[i+1] s%=MOD print(ans%MOD)" p03672,s412445441,Wrong Answer,"import sys def input(): return sys.stdin.readline().strip() def resolve(): def main(x): xlen=len(x) if x[:xlen//2]==x[xlen//2:]: return True else: return False s=input() if len(s)==2: print(1) else: for i in range(2,len(s),2): if main(s[:-i]): print(len(s[:-i])) resolve()" p03103,s264009944,Accepted,"n,m=map(int,input().split()) l=sorted([list(map(int,input().split())) for i in range(n)]) p=0 for i in range(n): a,b=l[i] if b"": a[i] = max(a[i+1]+1, a[i]) print(sum(a)) " p02835,s571192296,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(): A = LI() if sum(A) >= 22: print('bust') else: print('win') if __name__ == '__main__': resolve() " p03796,s703640670,Accepted,"N=int(input()) M=10**9+7 K=1 for i in range(1,N+1): K=(K*i)%M print(K) " p03962,s250124066,Accepted,print(len({int(_) for _ in input().split()})) p03150,s967595336,Accepted,"S = input() ans = False if S == 'keyence': ans = True elif S.startswith('keyence') or S.endswith('keyence'): ans = True else: for i in range(len(S)): for j in range(i, len(S)): p1 = S[:i] b = S[i:j+1] p2 = S[j+1:] # print(p1, b, p2) if p1 + p2 == 'keyence': ans = True if ans: print('YES') else: print('NO') " p03261,s403675233,Wrong Answer,"n = int(input()) list_w = [input() for s in range(0, n)] for i in range(0, n): if i == 0 or (list_w[i - 1][-1] == list_w[i][0]) and list_w[i] not in list_w[:i]: print(list_w[i]) continue else: print(""No"") exit() print(""Yes"")" p03555,s326922626,Accepted,"a=input() b=input() print(""YES"" if (a[0]==b[2] and a[1]==b[1] and a[2]==b[0]) else ""NO"")" p02628,s095171460,Accepted,"l=list(map(int,open(0).read().split()));print(sum(sorted(l[2:])[:l[1]]))" p03986,s274317334,Accepted,"x = input() cnt = 0 numt = 0 x = x[::-1] for i in range(len(x)): if x[i] == 'T': numt += 1 else: if numt > 0: cnt += 1 numt -= 1 print(len(x)-2*cnt)" p02630,s175176998,Accepted,"def ii():return int(input()) def iim():return map(int,input().split()) def iil():return list(map(int,input().split())) from collections import Counter n = ii() A = iil() s = sum(A) d = Counter(A) q = ii() for i in range(q): b,c = iim() m = d.pop(b,0) if m: d[c] = d.get(c,0)+m s += (c-b)*m print(s) " p02832,s493715253,Accepted,"n = int(input()) s = list(map(int,input().split())) flag = 1 for i in range(n): if s[i] == flag: flag += 1 if 1 not in s: print(-1) else: print(n - flag +1)" p03633,s399810575,Wrong Answer,"def gcd(a, b): if(a == 0): return b return gcd(b % a, a) def lcm(a, b): return a / (gcd(a, b) * b) t = int(input()) ans = 1 while(t != 0): t -= 1 n = int(input()) ans = lcm(ans, n) print(int(ans)) " p04005,s487318518,Accepted,"a, b, c = sorted(map(int, input().split())) c1 = c // 2 c2 = c - c1 print((c2 - c1) * a * b)" p02963,s020944296,Accepted,"# cf. #6489625 s = int(input()) a = 10**9 c = (a - s%a)%a b = (s+c)//a print(0,0,a,1,c,b) " p03448,s734529981,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 i*500+j*100+k*50==x: count+=1 print(count)" p02918,s832615856,Accepted,"N, K = map(int, input().split()) S = input() cnt = 0 for i in range(1, N): if S[i] == S[i-1]: cnt += 1 ans = min(cnt + 2 * K, N-1) print(ans)" p03251,s022373018,Accepted,"n, m, x, y = map(int, input().split()) xm = list(map(int, input().split())) ym = list(map(int, input().split())) print('No War' if max([x] + xm) < min([y] + ym) else 'War') " p03086,s233919485,Wrong Answer,"s = input() a = ['A','T','G','C'] ans = [] c = 0 for i in s: if i in a: c += 1 else: ans += [c] c = 0 if ans == []: print(len(s)) else: print(max(ans))" p02600,s075627570,Accepted,"x = int(input()) if x<=599 and x>=400: print(8) elif x<=799 and x>=600: print(7) elif x<=999 and x>= 800: print(6) elif x<=1199 and x>= 1000: print(5) elif x<=1399 and x>= 1200: print(4) elif x<=1599 and x>= 1400: print(3) elif x<=1799 and x>= 1600: print(2) elif x<=1999 and x>= 1800: print(1)" p03785,s751521375,Accepted,"import sys input = sys.stdin.readline # A - Airport Bus N, C, K = map(int, input().split()) times = [] for i in range(N): T = int(input()) t = [T, T + K] times.append(t) times.sort(key=lambda x: x[1]) ans = 0 count = 0 departure_time = 0 for t in times: if count == 0: departure_time = t[1] count = 1 elif count < C: if t[0] <= departure_time: count += 1 else: ans += 1 departure_time = t[1] count = 1 elif count == C: ans += 1 departure_time = t[1] count = 1 if count <= C: ans += 1 print(ans)" p02972,s757593153,Accepted,"n=int(input()) v=list(map(int,input().strip().split())) a=[0]*n for i in range(n-1,-1,-1): c=0 for j in range(i,n,i+1): c ^= a[j] if c != v[i]: a[i] = 1 ans = [] for i in range(n): if a[i]: ans.append(i+1) print(len(ans)) print(*ans)" p02598,s939518925,Accepted,"def mbisect(ok, ng): while abs(ok - ng) > 1: mid = (ok + ng) // 2 if check(mid): ok = mid else: ng = mid return ok def check(mid): if mid == 0: return False cnt = 0 for i in a: cnt += (i + mid - 1) // mid - 1 return cnt <= k n, k = map(int, input().split()) a = tuple(map(int, input().split())) print(mbisect(10 ** 9, -1))" p03821,s849210732,Accepted,"n = int(input()) a = [0] * n b = [0] * n for i in range(n): A, B = map(int, input().split()) a[i], b[i] = A, B a.reverse() b.reverse() ans = 0 for i in range(n): if (ans+a[i]) % b[i] == 0: cnt = 0 else: cnt = b[i] - ((ans+a[i]) % b[i]) ans += cnt print(ans)" p02783,s152888470,Accepted,"h,a = map(int,input().split()) if h % a == 0: ans = h // a else: ans = (h // a) + 1 print(ans)" p02814,s592187106,Accepted,"import sys def gcd(x,y): while y: x,y = y , x % y return x n,m=map(int,input().split()) a=list(map(int,input().split())) a.sort() 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)" p02993,s040245680,Wrong Answer,"S = list(input()) print(S) if S[0]==S[1] or S[1]==S[2] or S[2]==S[3]: print('Bad') else: print('Good')" p02606,s864593139,Accepted,"l,r,d=list(map(int,input().split())) p=0 for i in range(l,r+1): if i%d==0: p+=1 print(p)" p02726,s679924164,Accepted,"N, X, Y = map(int, input().split()) count = [0]*N for i in range(1, N): for j in range(i+1, N+1): if i <= X and Y <= j: # print(i, j, j-i-(Y-X)+1) count[j-i-(Y-X)+1] += 1 else: # print(i, j, j-i) # min((j-i), abs(X-i)+abs(Y-j)+1) count[min((j-i), abs(X-i)+abs(Y-j)+1)] += 1 for c in count[1:]: print(c)" p02753,s084062162,Accepted,"S = input() if 'A' in S and 'B' in S: print('Yes') else: print('No')" p03659,s709708046,Wrong Answer,"n = int(input()) a = list(map(int, input().split())) ans = 10**9 for i in range(1,n): s = sum(a[:i]) f = abs(sum(a)-2*s) ans = min(ans, f) print(ans)" p03380,s513776280,Accepted,"import bisect n = int(input()) A = list(map(int, input().split())) A.sort() ama = A[-1] print(ama, end=' ') ama2 = (ama + 1)//2 w = bisect.bisect_left(A, ama2) a = A[w-1] b = A[w] if abs(a-ama2) > abs(b-ama2): print(b) else: print(a) " p02802,s647085632,Accepted,"from collections import OrderedDict n, m = map(int,input().split()) aclist = [0]*n walist = [0]*n wa = 0 for i in range(m): pp, s = input().split() p = int(pp) - 1 if s == 'AC': if not aclist[p]: aclist[p] = 1 wa += walist[p] else: if not aclist[p]: walist[p] += 1 """""" pp, s = input().split() p = int(pp) - 1 if s == 'AC' and not aclist[p]: aclist[p] = 1 ac += 1 wa += walist[p] else: walist[p] += 1 """""" print(sum(aclist), wa)" p03759,s472126442,Wrong Answer,"a,b,c = map(int,input().split()) if b -a==c-b: print(""Yes"") else: print(""No"") " p03997,s326391081,Accepted,"a = int(input()) b = int(input()) h = int(input()) print((a+b)*h//2)" p02859,s748208678,Accepted,"r = int(input()) print(r*r) " p02727,s859133064,Accepted,"def main(): 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) PQR = P[:X] + Q[:Y] + R PQR.sort(reverse=True) print(sum(PQR[:X+Y])) if __name__ == ""__main__"": main()" p02838,s082145641,Accepted,"import sys input = sys.stdin.readline N = int(input()) A = list(map(int, input().split())) ans = 0 MOD = 10**9+7 for i in range(63): one, zero = 0, 0 for Aj in A: if (Aj>>i)&1: one += 1 else: zero += 1 ans += 2**i*one*zero ans %= MOD print(ans)" p03478,s131987096,Wrong Answer,"n,a,b=map(int,input().split()) ans=0 for i in range(1,n+1): s=str(i) s=sum(list(map(int,s))) if a<=s<=b: ans+=1 print(ans) " p02621,s262625354,Accepted,"a = int(input()) print(a+a**2+a**3)" p03339,s412543392,Accepted,"import sys N = int(input()) S = input() W = [0]*N E = [0]*N ans = N for i in range(1, N): W[i] = W[i-1]+1 if S[i-1]=='W' else W[i-1] E[-i-1] = E[-i]+1 if S[-i]=='E' else E[-i] for i in range(N): ans = min(W[i]+E[i], ans) print(ans) " p03778,s981532297,Accepted,"w,a,b=map(int,input().split()) ans=max(a,b)-min(a,b)-w if ans<=0: print(0) else: print(ans) " p03146,s488569722,Accepted,"s = int(input()) a = [s] for i in range(0,1000000): if a[i]%2 ==0: a.append(a[i]/2) else: a.append(3*a[i] +1) if a[i] in a[:i]: print(i+1) exit() " p02933,s281643637,Accepted,"a=int(input()) s=input() if a>=3200: print(s) else: print('red')" p03592,s826452466,Accepted,"import sys N, M, K = map(int, input().split()) for n in range(N+1): for m in range(M+1): if N*m + M*n - n*m*2 == K: print(""Yes"") sys.exit() print(""No"") " p02554,s041539893,Accepted,"N = int(input()) mod = 10 ** 9 + 7 e = pow(8, N, mod) f = pow(9, N, mod) g = pow(10, N, mod) # 全体 - (0を含まない + 9を含まない) + 0と9どちらも含まない ans = (g - 2 * f + e) % mod print(ans)" p03323,s687143499,Accepted,"a,b=map(int,input().split()) if a<=8 and b<=8: print(""Yay!"") else: print("":("")" p02743,s457680986,Accepted,"a,b,c=[int(_) for _ in input().split()] if c-a-b<=0: print(""No"") else: k=2*(a*b + b*c + c*a) - a**2 - b**2 - c**2 print(""Yes"" if k<0 else ""No"")" p03385,s788809312,Accepted,"s = input() print(""Yes"" if len(set(s)) == 3 else ""No"")" p02658,s374251460,Accepted,"def intMap(): return map(int,input().split()) def intList(): return list(map(int, input().split())) #横並びの場合 n = int(input()) a = intList() #MAX_NUM = 1000000 * 1000000 * 1000000 MAX_NUM = 10**18 for i in range(n): if a[i] == 0: print(0) exit() ans = 1 for i in range(n): ans *= a[i] if ans > MAX_NUM: print(-1) exit() print(ans) " p03804,s440161481,Wrong Answer,"n,m=map(int,input().split()) x,y=[],[] for i in range(n): x.append(input()) for i in range(m): y.append(input()) for i in range(n-m+1): for j in range(n-m+1): if x[i][j]==y[0][0]: if m==1: print('Yes') exit() ans='Yes' for k in range(m): if x[i+k][j:j+n-m+1]!=y[k]: ans='No' if ans=='Yes': print('Yes') exit() print('No') " p03796,s819841996,Wrong Answer,"import sys import copy import math import bisect import pprint import bisect from functools import reduce from copy import deepcopy from collections import deque from decimal import * def lcm(x, y): return (x * y) // math.gcd(x, y) if __name__ == '__main__': n =int(input()) ans =1 for i in range(1,n): ans = ans *i ans = ans % (10**9 +7) print(ans) " p03293,s698907418,Accepted,"s = list(input()) t = input() for i in range(len(s)): rotate_s = s.pop() s.insert(0, rotate_s) if """".join(s) == t: print(""Yes"") exit() print(""No"") " p02784,s709643551,Wrong Answer,"H,N=map(int,input().split()) A=[int(i) for i in input().split()] print('Yes' if H= a: print(a) else: print(a-1)" p02665,s074906125,Wrong Answer,"n=int(input()) cnt=0 B1=list(map(int,input().split())) print(-1)" p02732,s028275464,Accepted,"n = int(input()) a = list(map(int, input().split())) x = [0] * max(a) for i in a: x[i - 1] += 1 all = 0 def nc2(n): return int(n * (n - 1) / 2) for j in x: if j >= 2: all += nc2(j) for i in range(n): if x[a[i]-1] >= 2: print(all-x[a[i]-1]+1) else: print(all) " p03761,s363820299,Accepted,"from collections import Counter n = int(input()) a = [] for i in range(n): a.append(Counter(input())) for i in range(97, 97+26): m = 100 for j in range(n): m = min(a[j][chr(i)], m) print(chr(i)*m, end='') print()" p03284,s227620327,Accepted,"n,k = list(map(int, input().split())) if n%k == 0 : print(""0"") else: print(""1"")" p03208,s053647079,Accepted,"n,k = map(int,input().split()) ab = [] for _ in range(n): a=int(input()) ab.append(a) ab.sort() #print(ab) ans = 1000000000000000000000 for i in range(k-1, n): ans = min(ans,ab[i]-ab[i-k+1]) print(ans)" p03785,s731749212,Accepted,"n,c,k = map(int, input().split()) T = [] for i in range(n): T.append(int(input())) T.sort() ans = 1 last_t = T[0] passengers = 0 for t in T: if last_t +k >= t and passengers < c: passengers += 1 else: last_t = t passengers = 1 ans += 1 print(ans) " p03730,s414589328,Accepted,"a,b,c=map(int,input().split()) for i in range(1,b+1): if i*a%b==c: print(""YES"") exit() print(""NO"")" p02727,s609576422,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() pp=p[-x:] qq=q[-y:] eat=[] eat.extend(pp) eat.extend(qq) eat.extend(r) eat.sort() e=eat[(-x-y):] print(sum(e))" p02780,s933711546,Accepted,"def expectation(li): total = 0 for i in li: total += (i+1)/2 return total n,k = map(int,input().split()) p = list(map(int,input().split())) ex = expectation(p[0:k]) li = [ex] for i in range(1,n-k+1): ex = ex - (p[i-1]+1)/2 + (p[i+k-1]+1)/2 li.append(ex) print(max(li))" p03745,s961898108,Wrong Answer,"#!/usr/bin/env python3 import collections import itertools as it import math #import numpy as np # = input() n = int(input()) # = map(int, input().split()) a = list(map(int, input().split())) # = [int(input()) for i in range(N)] # # c = collections.Counter() ans = 1 state = lambda n1, n2: 0 if n1 == n2 else (1 if n2 > n1 else -1) diff = [state(a1, a2) for a1, a2 in zip(a[:-1], a[1:])] p = 1 while p < len(diff): if abs(diff[p] - diff[p-1]) == 2: ans += 1 p += 1 p += 1 print(ans) " p03693,s330550034,Accepted,"print(['NO','YES'][int(''.join(input().split()))%4==0])" p03612,s509295573,Wrong Answer,"n=int(input()) p=list(map(int,input().split())) cnt=0 p2=[] for i,x in enumerate(p): if (i+1)==p[i]: p2.append(False) else: p2.append(True) for i in range(n-1): if p2[i]==False and p2[i+1]==True: p2[i]=True cnt+=1 if p2[i]==False and p2[i+1]==False: p2[i]=True p2[i+1]=True cnt+=1 print(cnt)" p02923,s100672833,Accepted,"n = int(input()) hl = list(map(int, input().split())) ans = 0 cnt = 0 prev_h = 0 for h in hl: if h > prev_h: ans = max(ans,cnt) cnt = 0 else: cnt += 1 prev_h = h ans = max(ans,cnt) print(ans)" p03910,s759051402,Accepted,"#!/usr/bin/env python3 def main(): n = int(input()) for i in range(10**4): if n <= i * (i + 1) / 2: tmp = i break tmpsum = tmp * (tmp + 1) / 2 if n == tmpsum: for i in range(1, tmp + 1): print(i) else: for i in range(1, tmp + 1): if i == tmpsum - n: continue print(i) if __name__ == ""__main__"": main() " p03289,s794373658,Accepted,"import fileinput s = list(input()) if s[0] != ""A"" or s[1].isupper() or s[len(s) - 1].isupper(): print(""WA"") exit() cc = False for i in range(2, len(s) - 1): if s[i] == ""C"" and not cc: cc = True continue if s[i] == ""C"" and cc: print(""WA"") exit() if s[i].isupper() and s[i] != ""C"": print(""WA"") exit() if cc: print(""AC"") else: print(""WA"") " p02697,s652317720,Accepted,"import sys def main(): input = sys.stdin.buffer.readline 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() " p02859,s076682665,Wrong Answer,"r=input(""r:"") PI=3.14 s1=(r**2)*PI print(s1/PI) " p02843,s475577819,Accepted,"X = input() ans = ""1"" if int(X) < 100: ans = ""0"" elif not int(X[:-2])*5 >= int(X[-2:]): ans = ""0"" print(ans) " p02829,s631712015,Wrong Answer," def main(): a = int(input()) b = int(input()) if a == 1 and b == 2: print(3) elif a == 2 and b == 3: print(1) else: print(2) if __name__ == '__main__': main() " p02576,s362357318,Wrong Answer,"n,x,t = map(int,input().split()) print((n*t)//x + 1) " p03075,s823122177,Accepted,"import sys def input(): return sys.stdin.readline().rstrip() def main(): AtoE = [int(input()) for _ in range(5)] k = int(input()) for i in AtoE: for j in AtoE: if abs(i - j) > k: print(':(') exit() else: print('Yay!') if __name__ == '__main__': main() " p02797,s117068648,Accepted,"n, k, s = map(int, input().split()) if s == 10 ** 9: l = [s] * k + [1] * (n - k) else: l = [s] * k + [s + 1] * (n - k) print(*l)" p03434,s839590987,Accepted,"import sys read = sys.stdin.read readlines = sys.stdin.readlines def main(): n, *a = map(int, read().split()) a.sort(reverse=True) alice = sum(a[::2]) bob = sum(a[1::2]) print(alice - bob) if __name__ == '__main__': main() " p03076,s476700694,Accepted,"#!/usr/bin/env python3 *a, = map(int, open(0).read().split()) ans = 0 m = 10 for i in a: if i % 10 != 0: m = min(m, i % 10) ans += i//10*10 + 10 else: ans += i//10*10 print(ans-10+m) " p03087,s926714337,Accepted,"from itertools import accumulate N, Q = map(int, input().split()) S = input() counts = [[0] * N for _ in range(2)] for i, c in enumerate(zip(S[:-1], S[1:])): counts[i & 1][i] = int(c == (""A"", ""C"")) for i in range(2): counts[i] = list(accumulate(reversed(counts[i])))[::-1] for _ in range(Q): l, r = map(lambda n: int(n) - 1, input().split()) print(counts[0][l] - counts[0][r] + counts[1][l] - counts[1][r])" p02696,s342810306,Accepted,"import numpy as np def main(): a, b, n = map(int, input().split()) if b <= n: n = b - 1 ans = int(np.floor(a*n/b)) - int(a*np.floor(n/b)) print(ans) if __name__ == ""__main__"": main() " p02802,s928038485,Accepted,"n, m = map(int, input().split()) l = [0] * n f = [True] * n for _ in range(m): p, s = input().split() p = int(p) - 1 if s == 'WA': if f[p]: l[p] += 1 else: f[p] = False ans = 0 for i in range(n): if not f[i]: ans += l[i] print(f.count(False), ans) " p02713,s407162245,Wrong Answer,"import math K=int(input()) answer=0 for i in range(K): for j in range(K): gcd_ij=math.gcd(i,j) for k in range(K): gcd_ijk=math.gcd(gcd_ij,k) answer+=gcd_ijk print(answer)" p03435,s844327344,Accepted,"c = [] for i in range(3): c.append(list(map(int, input().split()))) for i in range(2): for j in range(2): if c[j][i+1] - c[j][i] != c[j+1][i+1] - c[j+1][i]: print('No') exit() print('Yes')" p03379,s701412090,Wrong Answer,"import math N = int(input()) li = list(map(int, input().split())) m = sum(li) / N new = sorted(li) for i in range(N): if i <= (N / 2) - 1: print(new[math.floor(N/2)]) else: print(new[math.floor(N/2) - 1])" p02882,s848933250,Accepted,"from math import* A,B,X = map(int,input().split()) V = A*A*B if V/2 2: print('NO') else: print('YES')" p02571,s564629068,Wrong Answer,"import re s = input() t = input() cnt = -1 for i in range(len(t) + 1): cnt += 1 f = ""\S{"" + str(i) +""}"" + t[(i):len(t)] b = t[0:len(t) - i] + ""\S{"" + str(i) + ""}"" if re.search(f, s): print(""in"") break elif re.search(b, s): print(""in"") break print(cnt) " p03827,s003516433,Wrong Answer,"import sys input = sys.stdin.readline N = int(input()) S = list(input().rstrip()) ans = [] x = 0 for i in S: if i == ""I"": x += 1 else: x -= 1 ans.append(x) print(max(ans))" p03109,s373213629,Accepted,"icase=0 if icase==0: s=input() yyyy=int(s[0:4]) mm=int(s[5:7]) dd=int(s[8:]) if yyyy<2019: print(""Heisei"") elif yyyy==2019 and mm<4: print(""Heisei"") elif yyyy==2019 and mm==4 and dd<=30: print(""Heisei"") else: print(""TBD"")" p03696,s830212691,Accepted,"def main(): n = int(input()) s = input() l, r = 0, 0 for i in s: if i == "")"": if l: l -= 1 else: r += 1 else: l += 1 print(r * ""("" + s + "")"" * l) if __name__ == '__main__': main() " p03360,s549262662,Accepted,"a, b, c = map(int, input().split()) k = int(input()) print(max(a, b, c) * (2 ** k) + a + b + c - max(a, b, c)) " p03285,s017556932,Accepted,"n = int(input()) ans = ""No"" for i in range(26): for j in range(20): if 4*i+7*j==n: ans = ""Yes"" break print(ans)" p02801,s650896687,Accepted,print(chr(ord(input()) + 1)) p03042,s584533231,Wrong Answer,"#ABC126 B S = list(map(int,input())) if S[0]*10 + S[1] <= 12 and S[2]*10 + S[3] <= 12: print(""AMBIGUOUS"") elif S[0]*10 + S[1] <= 12 and S[2]*10 + S[3] > 12: print(""MMYY"") elif S[0]*10 + S[1] > 12 and S[2]*10 + S[3] <= 12: print(""YYMM"") elif S[0]*10 + S[1] > 12 and S[2]*10 + S[3] > 12: print(""NA"")" p02970,s517663376,Wrong Answer,"N,D=map(int,input().split()) res = 0 for i in range(D,N+1,2*D): res += 1 print(res)" p03997,s076580330,Wrong Answer,"a=int(input()) b=int(input()) h=int(input()) print((a+b)*h/2)" p03109,s920535378,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) YMD = readline().decode('utf8').rstrip().split('/') # print(YMD) MD=int(''.join(YMD[1:])) print('Heisei' if MD <=430 else 'TBD') " p03385,s419882634,Wrong Answer,print('Yes' if 'abc' in input() else 'No') p02691,s525328478,Wrong Answer,"n=int(input()) l=list(map(int,input().split())) count=0 d={} def diff(a,b): if a>b: return(a-b) else: return(b-a) for i in range(0,len(l)): if l[i]>2*10**5: pass else: d[i+1]=l[i] l=list(d.keys()) for i in range(0,len(l)): for j in range(i+1,len(l)): if diff(i,j)==d[l[j]]+d[l[i]]: count+=1 print(count) " p03456,s133512185,Accepted,"a, b = input().split() n = int(a + b) for i in range(1, n): if i**2 == n: print('Yes') exit() print('No')" p02880,s520799767,Accepted,"from sys import exit N = int(input()) for i in range(1, 10): for j in range(1, 10): if N == i * j: print('Yes') exit() print('No')" p02959,s813078179,Wrong Answer,"n = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) ans = 0 for itr, b in enumerate(B): rem = b for i in range(2): dam = min(rem, A[itr + i]) ans += dam rem -= dam print(ans) " p03494,s658385809,Accepted,"N = int(input()) A = list(map(int, input().split())) ans = int(1e9) for i in range(N): cnt = 0 while(A[i]%2 != 1): A[i] = A[i] // 2 cnt = cnt + 1 ans = min(ans, cnt) print(ans)" p03146,s187359974,Accepted,"s=int(input()) data=[0]*(10**6+100) data[s]=1 cnt=1 while True: if s%2==0: s//=2 else: s=3*s+1 cnt+=1 if data[s]==1: break data[s]=1 print(cnt)" p02748,s572840441,Accepted,"A,B,M = map(int,input().split()) a = list(map(int,input().split())) b = list(map(int,input().split())) mi = min(a) + min(b) for i in range(M): x,y,c = map(int,input().split()) x -= 1 y -= 1 mi = min(mi,a[x] + b[y] - c) print(mi)" p02714,s170616151,Accepted,"l =int(input()) s =input() r = s.count(""R"") g = s.count(""G"") b = s.count(""B"") A = r * g * b B = 0 gapmax = (l - 3) // 2 for _ in range(gapmax+1): for i in range(l-2-2*_): c1, c2, c3 = s[i], s[i+1+_],s[i+2+2*_] if not (c1 == c2) and not (c1 == c3) and not (c2 ==c3): B += 1 print(A-B)" p03261,s446951335,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 = [input() for _ in range(n)] n = int(input()) w = [input() for _ in range(n)] if (len(w) != len(set(w))): print(""No"") exit() for i in range(1,n-1): if w[i][0] != w[i-1][-1]: print(""No"") exit() print(""Yes"") " p03693,s742774570,Accepted,"r,g,b=map(str,input().split()) c_l = r+g+b if(int(c_l)%4==0): print(""YES"") else: print(""NO"")" p03433,s874444272,Wrong Answer,"# -*- coding:utf-8 -*- n = int(input()) a = int(input()) if (a % 500) < n: print('Yes') else: print('No')" p03778,s069728647,Accepted,"W, a, b = map(int, input().split()) L = [b - (a + W), a - (b + W), 0] print(max(L))" p02630,s416615326,Accepted,"import collections N=int(input()) A=list(map(int,input().split())) s=sum(A) Q=int(input()) d=collections.Counter(A) for i in range(Q): B,C=map(int,input().split()) s += d[B]*C - d[B]*B print(s) if C in d: d[C]+=d[B] else: d[C]=d[B] d[B]=0" p03565,s039517708,Accepted,"Sp = input() Sp_list = list(Sp) N = len(Sp) T = input() n = len(T) def check(s, t): for si, ti in zip(s, t): if si == '?': continue if si != ti: return False return True ans = [] for i in range(N-n+1): if check(Sp[i:i+n], T): ans.append(''.join(Sp_list[:i] + list(T) + Sp_list[i+n:]).replace('?', 'a')) if ans: ans.sort() print(ans[0]) else: print('UNRESTORABLE')" p02597,s511694637,Accepted,"_,s=open(0) print(s[:s.count('R')].count('W'))" p02683,s051072860,Accepted,"big_int = 10 ** 9 N, M, X = map(int, input().split()) L = [0 for i in range(N)] for i in range(N): L[i] = tuple(map(int, input().split())) def foo(i): t = i T = [0 for j in range(M+1)] for j in range(N): for k in range(M+1): T[k] += L[j][k] * (t%2) t //= 2 for k in range(1,M+1): if T[k] < X: return big_int return T[0] ans = big_int for i in range(2**N): ans = min(ans, foo(i)) if ans == big_int: print(-1) else: print(ans)" p02744,s556199583,Accepted,"N=int(input()) alphabets = [chr(ord('a') + x) for x in range(26)] def dfs(n,s,maxc): if len(s)==N: print(''.join(s)) return True for i in range(maxc+1): if i==maxc: maxc+=1 dfs(n+1,s+[alphabets[i]],maxc) s=[] dfs(0,s,0)" p02717,s825623330,Accepted,"a, b, c = map(int, input().split()) print(c,'',a,'',b)" p04031,s911055242,Accepted,"N=int(input()) *A,=map(int,input().split()) mx=max(A) mn=min(A) ans=float('inf') for i in range(mn,mx+1): ans=min(ans, sum([(k-i)**2 for k in A])) print(ans)" p02712,s727620082,Accepted,"N = int(input()) num = [1]*(N+1) num[0] = 0 for a in range(3,len(num),3): num[a] = 0 for b in range(5,len(num),5): num[b] = 0 t = 0 for a in range(len(num)): if num[a] == 1: t += a print(t)" p03062,s764184101,Accepted,"#他の数字はそのままで,任意の2数の符号を同時に反転させることが可能.マイナスの数の偶奇で場合分け n = int(input()) a = list(map(int,input().split())) aabs = [i if i>=0 else i*(-1) for i in a] MIN = min(aabs) ans = 0 mcount = 0 for i in range(n): if a[i] < 0: mcount += 1 if mcount%2 == 0: for i in a: ans += abs(i) print(ans) else: for i in a: ans += abs(i) print(ans - 2*MIN)" p02719,s265951044,Wrong Answer,"n,k=map(int, input().split()) l=[] x = n - k * int(n/k) if(x != 0): l.append(abs(x-k)) l.append(abs(l[0]-k)) print(min(l)) else: print(n) " p02951,s977412711,Wrong Answer,"A, B, C = map(int, input().split()) print(C-(A-B))" p03371,s393455309,Accepted,"a, b, c, x, y=map(int,input().split()) cnt = 10**9 for m in range(max(x,y)+1): price = (2*m*c) + max(0,(x-m))*a + max(0,y-m)*b cnt = min(cnt, price) print(cnt)" p03565,s344958162,Accepted,"S = input() Sa = S.replace(""?"", ""a"") T = input() nt = len(T) ans = list() for i in range(len(S) - nt + 1): X = S[i: i + nt] for x, t in zip(X, T): if x == ""?"": continue if x != t: break else: ans.append(Sa[:i] + T + Sa[i + nt:]) ans.sort() print(ans[0] if ans else ""UNRESTORABLE"") " p03059,s339499860,Accepted,"#conding utf-8 a,b,T=map(int,input().split()) print(int(T/a)*b) " p02691,s332164573,Accepted,"import sys stdin = sys.stdin sys.setrecursionlimit(10**6) ni = lambda: int(ns()) na = lambda: list(map(int, stdin.readline().split())) nn = lambda: list(stdin.readline().split()) ns = lambda: stdin.readline().rstrip() n = ni() a = na() from collections import defaultdict d = defaultdict(int) ans = 0 for i in range(n): ans += d[i-a[i]] d[a[i]+i] += 1 print(ans)" p03455,s499653547,Accepted,"a,b = map(int, input().split()) if (a*b)%2== 0: print(""Even"") else: print(""Odd"") " p03637,s463783851,Accepted,"N = int(input()) arr = list(map(int, input().split())) four = 0 two = 0 for i in arr: if i % 4 == 0: four += 1 elif i % 2 == 0: two += 1 if 2*four+1 == N: print('Yes') exit() N -= four * 2 if N <= two: print('Yes') else: print('No')" p03208,s184061094,Accepted,"n,k = map(int,input().split()) h = [int(input()) for i 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)" p03282,s102831809,Wrong Answer,"#!/usr/bin/env python3 s = str(int(input())) k = int(input()) if len(s) == 1: print(s) exit() if s[0] == ""1"": print(s[1]) else: print(s[0]) " p02606,s211455806,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)" p02843,s598440730,Accepted,"import sys input = sys.stdin.readline X = int(input()) dp = [False] * (X+1) dp[0]=True c = [100,101,102,103,104,105] for i in range(len(c)): for j in range(c[i],X+1): if(dp[j-c[i]]): dp[j]=True if(dp[X]):print(1) else:print(0)" p03319,s148514197,Wrong Answer,"n,k = map(int,input().split()) a = list(map(int,input().split())) ni = a.index(1) ans = ni//(k-1) +(n-ni+1 + ni%(k-1))//(k-1) print(ans)" p03219,s584912874,Accepted,"X, Y = map(int, input().split()) print(X + Y // 2) " p03075,s845285693,Accepted,"import itertools l = list() for a in range(0, 5): l.append(int(input())) k = int(input()) com = list(itertools.combinations(l, 2)) for a in range(0, len(com)): com[a] = list(com[a]) com[a] = abs(com[a][0] - com[a][1]) ans = 'Yay!' for a in com: if a > k: ans = ':(' break print(ans) " p02747,s292441422,Accepted,"S={""hi""*i for i in range(1,6)} if input() in S: print(""Yes"") else: print(""No"")" p02814,s775746328,Accepted,"from fractions import gcd N, M = map(int, input().split()) A = list(map(int, input().split())) lcm = 1 def f(n): res = 0 while n%2 == 0: res += 1 n //= 2 return res t = f(A[0]) for a in A: if t != f(a): print(0) exit() a //= 2 lcm *= a // gcd(lcm, a) print(M//lcm - M//(lcm*2))" p02912,s092935666,Wrong Answer,"n,m = map(int, input().split()) a = list(map(int, input().split())) sub = [0] a.sort() for i in range (m): if (len(a) != 0): if (a[-1] >= sub[-1]): x =a.pop() sub.insert(1,x//2) else: x =sub.pop() sub.insert(1,x//2) print(sum(a)+sum(sub)) " p03479,s199149680,Accepted,"X, Y = map(int, input().split()) ans = 0 while X <= Y: ans += 1 X *= 2 print(ans) " p02595,s286702467,Accepted,"f=lambda:map(int,input().split()) n,d=f() c=0 for _ in range(n): x,y=f() if x**2+y**2<=d**2: c+=1 print(c)" p03944,s845028334,Accepted,"W,H,N=map(int,input().split()) x=[0]*N y=[0]*N a=[0]*N minX=0 maxX=W minY=0 maxY=H for i in range(N): x[i],y[i],a[i]=map(int,input().split()) if a[i]==1: minX=max(minX,x[i]) if a[i]==2: maxX=min(maxX,x[i]) if a[i]==3: minY=max(minY,y[i]) if a[i]==4: maxY=min(maxY,y[i]) ans=(maxX-minX)*(maxY-minY) if maxX= k: print(a) break resolve()" p02789,s857510565,Accepted,"#!/usr/bin/env python3 TestCaseNum, ACNum = map(lambda x: int(x), input().split()) if TestCaseNum==ACNum: print(""Yes"") else: print(""No"")" p02831,s122575081,Accepted,"from fractions import gcd a,b = map(int, input().split()) print((a*b)//gcd(a,b))" p03319,s846326274,Wrong Answer,"import math import bisect n,k = map(int,input().split()) li = list(map(int,input().split())) index = bisect.bisect_left(li, 1) lef = index right = n - index - 1 if min(lef,right) >= k -1: print(math.ceil((n-1)/(k-1))) else: tmp = max(lef,right) - min(lef,right) - 1 print(math.ceil((tmp)/(k-1))+1)" p02917,s182629133,Wrong Answer,"import copy n = int(input()) b = list(map(int,input().split())) a = copy.copy(b) a.append(b[-1]) for i in range(n-1): if b[i]= (sum(AA)/(4*M))) if S >= M: print(""Yes"") else: print(""No"") " p03385,s230288529,Accepted,"import sys S = list(input()) if len(S) != 3: sys.exit if S.count('a') == 1 and S.count('b') == 1 and S.count('c') == 1: print('Yes') else: print('No')" p03456,s093582463,Wrong Answer,"a, b = map(int, input().split()) ab = None for i in range(1, 4): if b == b%(10**i): ab = a*(10**i) + b break print(ab) for i in range(1, 1000): if i**2 == ab: print('Yes') exit() print('No')" p02707,s445983185,Wrong Answer,"from collections import Counter N = int(input()) funcionarios = list(map(int,input().split())) for x in Counter(funcionarios).values(): print(x) N -= 1 a = N while a != 0: print(0) a -= 1 " p03038,s854809600,Accepted,"#!/usr/bin/env python3 n, m = map(int, input().split()) (*a, ) = map(int, input().split()) a.sort() q = [[*map(int, input().split())] for _ in range(m)] q.sort(key=lambda x: -x[1]) idx = 0 for b, c in q: for _ in range(b): if idx >= n or a[idx] >= c: print(sum(a)) exit() a[idx] = c idx += 1 print(sum(a)) " p03673,s731733469,Wrong Answer,"from collections import deque n = int(input()) l = map(int, input().split()) d = deque() for i in l: if i % 2 == 1: d.appendleft(i) else: d.append(i) if n % 2 == 0: d.reverse() print(' '.join(map(str, d)))" p02719,s434708084,Accepted,"n,k=map(int,input().split()) if k==1: print(0) else: a=n%k b=abs(a-k) print(min(a,b))" p03126,s798441471,Accepted,"n,m = map(int,input().split()) v = [0] * m for i in range(n): a = list(map(int,input().split())) for j in range(1,a[0]+1): v[a[j]-1] += 1 ans = 0 for i in range(m): if v[i] == n: ans += 1 print(ans)" p02572,s833447700,Accepted,"N = map(int, input()) An = list(map(int, input().split())) mnum = 10 ** 9 + 7 CumSum = An[0] answer = 0 for i in range(1, len(An)): answer = (answer + CumSum * An[i]) CumSum = (CumSum + An[i]) print(answer%mnum)" p02897,s714445721,Accepted,"n=int(input()) print(((n+1)//2)/n)" p02912,s793571570,Wrong Answer," import heapq n,m=map(int,input().split()) a=list(map(int,input().split())) b=[-int(i) for i in a] heapq.heapify(b) for i in range(m): x=heapq.heappop(b)//2 heapq.heappush(b,-x) print(-sum(b)) " p02708,s437958916,Wrong Answer,"#D N,K=map(int,input().split()) import math def combinations_count(n, r): return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)) ans=0 for i in range(K,N+1): ans+=combinations_count(N+1, i) print(ans)" p02621,s575205535,Accepted,"a = int(input()) print(a+a**2+a**3)" p03814,s409693259,Accepted,"S=list(input()) a=S.index('A') z=[i for i, x in enumerate(S) if x == 'Z'] print(z[-1]-a+1)" p03274,s432807976,Accepted,"n,k,*a=map(int,open(0).read().split()) print(min(r-l+min(abs(r),abs(l))for l,r in zip(a,a[k-1:])))" p03146,s537191710,Accepted,"s = int(input()) def f(n): if n%2: return n*3+1 else: return n//2 i = 1 hist = {s:i} while 1: s = f(s) i+=1 if s in hist: print(i) break else: hist[s]= i" p02792,s973625212,Wrong Answer,"from collections import defaultdict strN=input() lenN=len(strN) N=int(strN) if N<=9:print(N) else: count = defaultdict(int) for i in range(10,N+1): a,b=int(str(i)[0]),int(str(i)[1]) if b==0:continue count[(a,b)] += 1 ans=0 for i in range(1,10): count[(i,i)] += 1 count = dict(count) for key in count.keys(): if key[0]=30: print(""Yes"") else: print(""No"")" p02783,s095743519,Accepted,"def solve(): h, a = map(int, input().split()) print(-(-h//a)) if __name__ == '__main__': solve() " p02791,s932566401,Accepted,"n = int(input()) p = list(map(int, input().split())) cnt = 0 m = n + 1 for i in range(n): if m > p[i]: cnt += 1 m = p[i] print(cnt)" p03478,s821948790,Accepted,"def main(): N, A, B = map(int, input().split()) sum_v = 0 for i in range(1, N+1): v = sum([int(s) for s in str(i)]) if v >= A and v <= B: sum_v += i print(sum_v) if __name__ == '__main__': main()" p02596,s697282881,Wrong Answer,"K = int(input()) mod_ini = 7%K mod = 0 cnt = 0 while True: if K%2 != 0: print(-1) break cnt += 1 mod = (mod*10 + 7)%K #print(mod) if mod == 0: print(cnt) break elif mod == mod_ini and cnt != 1: print(-1) break" p03637,s587701482,Accepted,"n=int(input()) x=list(map(int,input().split())) a,b,c=0,0,0 ans='No' for i in x: if i%4==0: a+=1 elif i%2==0: b+=1 else: c+=1 if n%2==1: if c-a==1: if b==0: ans='Yes' elif a>=c: ans='Yes' else: if a>=c: ans='Yes' print(ans) " p03723,s585286085,Accepted,"a,b,c=map(int,input().split()) if a%2==1 or b%2==1 or c%2==1: print(""0"") exit() for i in range(1,1000000): a2=(b//2)+(c//2) b2=(a//2)+(c//2) c2=(a//2)+(b//2) a,b,c=a2,b2,c2 if a%2==1 or b%2==1 or c%2==1: print(i) exit() print(""-1"")" p03131,s262411513,Accepted,"k,a,b=map(int,input().split()) c=k-a+1 print(max(k+1,a+(c//2)*(b-a)+c%2))" p02957,s059884384,Wrong Answer,"A,B=map(int,input().split()) if abs(A+B)%2==0: print(abs(A+B)/2) else: print(""IMPOSSIBLE"")" p03103,s642930829,Wrong Answer,"n,m = map(int,input().split()) ab = [list(map(int,input().split())) for _ in range(n)] ab = sorted(ab,key=lambda x:x[0]) ans = 0 for i in ab: m -= i[1] ans += i[0]*i[1] if m <= 0: print(ans + m*i[0]) break elif i == ab[-1]: print(ans) break" p03419,s084289822,Accepted,"import sys readline = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 8) INF = float('inf') MOD = 10 ** 9 + 7 def main(): N, M = map(int, input().split()) if N == 1 and M == 1: print(1) elif (N == 1 and M >= 2): print(M - 2) elif (N >= 2 and M == 1): print(N - 2) else: print((N - 2) * (M - 2)) if __name__ == '__main__': main()" p02584,s744713449,Accepted,"x, k, d = map(int, input().split()) cur = abs(x) # 座標を正にしてしまいます rem = k # 残りの移動回数です cnt = min(cur // d, k) # 0に向かって移動する回数です cur -= d * cnt rem -= cnt # 0 % 2 = 0なので、残り回数の場合分けをする必要はないのですが、一応 if rem > 0: if rem % 2 == 1: cur = cur - d ans = abs(cur) print(ans)" p03000,s105207624,Wrong Answer,"import sys def input(): return sys.stdin.readline().rstrip() def main(): n, x = map(int, input().split()) l = tuple(map(int, input().split())) d = 0 for i in range(1, n+1): d += l[i-1] if d >= x: print(i) quit() else: print(n) if __name__ == '__main__': main() " p03456,s674882883,Accepted,"import math a, b = input().split() c = int(a+b) if math.sqrt(c) == int(math.sqrt(c)): print('Yes') else: print('No')" p03854,s834574830,Accepted,"S = input() k=0 t=len(S) while k= k: print(k) elif a+b >= k: print(a) else: print(a - (k-a-b))" p02793,s989487382,Accepted,"def gcd(x, y): while y > 0: tmp = x % y x = y y = tmp return x def lcm(x, y): if x == 0 or y == 0: return 0 else: return x // gcd(x, y) * y def main(): mod = int(1e9 + 7) n = int(input()) a = list(map(int, input().split())) l = 1 for i in range(n): l = lcm(l, a[i]) ans = 0 print(int(sum(l // i for i in a) % mod)) if __name__ == '__main__': main() " p03220,s829628010,Accepted,"N = int(input()) T, A = map(int, input().split()) X = list(map(int, input().split())) s = 10000 for i in range(N): x = T - X[i] * 0.006 if abs(A - x) < s: ans = i s = abs(A - x) print(ans+1) " p02627,s945795892,Wrong Answer,"alpha = input() if alpha < 'A': print('a') else: print('A')" p03309,s176287963,Accepted,"from statistics import median n=int(input()) a=list(map(int,input().split())) b=[x-i-1 for i,x in enumerate(a)] """""" b=[] for///: y.append/// """""" m=int(median(b)) print(sum(abs(y-m) for y in b))" p04029,s149282221,Accepted,"#!/usr/bin/env python3 import sys def solve(N: int): res = (1 + N) * (N / 2) print(int(res)) # Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template) def main(): def iterate_tokens(): for line in sys.stdin: for word in line.split(): yield word tokens = iterate_tokens() N = int(next(tokens)) # type: int solve(N) if __name__ == ""__main__"": main() " p02708,s144619946,Wrong Answer,"n,k=map(int,input().split()) count=0 for i in range(n+2): if i=k: mini=i*(i-1)//2 a=n*(n+1)//2 b=(n-i)*(n-i+1)//2 maxi=a-b total=maxi-mini+1 count+=total print(count)" p03433,s083677436,Accepted,"N = int(input()) A = int(input()) print(""Yes"" if (N % 500 <= A) else ""No"") " p02639,s583370050,Accepted,"n = list(map(int, input().split())) for i in range(5): if n[i] == 0: print(i+1)" p02819,s525642531,Accepted,"X = int(input()) while True: flag = 0 for i in range(2,X//2): if X % i == 0: flag = 1 break if flag == 0: print(X) exit() X = X + 1" p02553,s364490924,Accepted,"a, b, c, d = [int(s) for s in input().split("" "")] ans1 = a * c ans2 = b * d ans3 = a * d ans4 = b * c print(""%d"" % max([ans1, ans2, ans3, ans4]))" p03487,s148738611,Accepted,"from collections import Counter N = int(input()) a = list(map(int, input().split())) c = Counter(a) ans = 0 for k, v in c.items(): if k < v: ans += v - k elif k > v: ans += v print(ans) " p02706,s020115671,Accepted,"n,m=map(int,input().split()) a=list(map(int,input().split())) print(max(-1,n-sum(a)))" p03061,s496985379,Accepted,"from math import gcd n = int(input()) l = list(map(int,input().split())) mi = 1 gcd_l = [l[0]] gcd_r = [l[-1]] for i in range(1,n): gcd_l.append(gcd(l[i],gcd_l[-1])) for i in range(n-2,-1,-1): gcd_r.append(gcd(l[i],gcd_r[-1])) for i in range(0,n-2): t = gcd(gcd_l[i], gcd_r[n-3-i]) # print(t) mi = max(mi,t) #print(gcd_l) #print(gcd_r) mi = max(mi,gcd_r[-2]) mi = max(mi,gcd_l[-2]) print(mi)" p02947,s778246061,Accepted,"n = int(input()) d = {} c = 0 for i in range(n): s = input() s = tuple(sorted(s)) #文字列をsort if s in d: c = c + d[s] d[s] = d[s] + 1 else: d[s] = 1 print(c)" p02983,s011210615,Accepted,"l, r = map(int, input().split()) ans = 2019 for i in range(l, r): for j in range(i+1, r+1): tmp = i*j % 2019 if ans > tmp: ans = tmp if ans == 0: print(ans) exit(0) print(ans)" p03106,s574749659,Wrong Answer,"A, B, K = [int(i) for i in input().split()] result_list = [] def divisor_list(n): i = 1 array = [] while i * i <= n: if n % i == 0: array.append(i) array.append(n//i) i += 1 array = list(set(array)) return array for i in divisor_list(A): for j in divisor_list(B): if i == j: result_list.append(i) print(result_list[-K])" p02713,s659871468,Wrong Answer,"N = int(input()) s = (1+N)*N // 2 s1 = 0 s2 = 0 s3 = 0 if N >= 3: s1 = ((3 + (N//3)*3) * (N//3)) // 2 if N >= 5: s2 = ((5 + (N//5)*5) * (N//5)) // 2 if N >= 15: s3 = ((15 + (N//15)*15) * (N//15)) // 2 print(s + s3 - s1 - s2) " p02657,s910275796,Accepted,"from decimal import Decimal N = list(map(str,input().split())) A = Decimal(N[0]) B = Decimal(N[1]) print(int(A * B))" p02768,s460220309,Wrong Answer,"n, a, b = map(int, input().split()) mod = 10**9 + 7 def nCr(n, r, mod): r = min(r, n-r) numer = denom = 1 for i in range(1, r+1): numer = numer * (n+1-i) % mod denom = denom * i % mod return numer * pow(denom, mod-2, mod) % mod ans = pow(2, n, mod)-1-nCr(n, a, mod)-nCr(n, b, mod) if ans < 0: print(ans + mod) else: print(ans) " p02694,s870439891,Wrong Answer,"X = int(input()) benjin = 100 t = 0 while benjin <= X: benjin = int(benjin * 1.01) t = t + 1 print(t)" p02756,s150020705,Wrong Answer,"inital_string = input() num_of_q = int(input()) flag = True for i in range(num_of_q): q = input() if q[0] == '1': flag = not flag else: if q[2] == ""1"": if flag: inital_string = inital_string + q[4] else: inital_string = q[4] + inital_string else: if flag: inital_string = q[4] + inital_string else: inital_string = inital_string + q[4] if flag: inital_string = inital_string[::-1] print(inital_string) " p02833,s517044197,Accepted,"n = int(input()) if n % 2 == 1: print(0) else: a = 0 m = n // 2 while True: m = m // 5 a += m if m == 0: break print(a) " p02775,s302860234,Accepted,"# E - Payment N = input().strip() s = 0 carry = 0 five = False for c in reversed(N): x = int(c) + carry if x == 5 and not five: s += x carry = 0 five = True elif x >= 5: if five: x += 1 s += 10 - x carry = 1 five = False else: s += x carry = 0 five = False s += carry print(s) " p03699,s757862489,Wrong Answer,"n = int(input()) s = [int(input()) for i in range(n)] dp = [[0] * 2]*(n+1) for i,_s in enumerate(s): if i % 10==0: dp[i+1][1] = dp[i][1] else: if (dp[i][0] + _s) % 10 ==0: dp[i+1][1] = dp[i][0] + _s else: dp[i+1][0] = dp[i][1] + _s print(dp[n][0])" p03545,s259220346,Accepted,"abcd = list(input()) for bit in range(1 << 3): answer = 0 op = [""-"", ""-"", ""-""] for i in range(3): if (bit >> i) & 1: op[i] = ""+"" if eval(abcd[0] + op[0] + abcd[1] + op[1] + abcd[2] + op[2] + abcd[3]) == 7: answer = abcd[0] + op[0] + abcd[1] + op[1] + abcd[2] + op[2] + abcd[3] + ""=7"" break print(answer) " p03264,s417495179,Accepted,"s = int(input()) if s % 2 == 1: Odd = (s+1)/2 Even = Odd -1 else: Odd = s/2 Even = Odd res= int(Odd) * int(Even) print(res)" p03797,s938199624,Accepted,"n, m = map(int, input().split()) if n*2 >= m: result = m//2 else: result = (m - n*2)//4 + n print(result)" p02783,s059600358,Accepted,"h,a = map(int,input().split()) ans = 0 for _ in range(h): h -= a ans += 1 if h <= 0: break print(ans)" p03241,s909549722,Wrong Answer,"N, M = map(int, input().split()) import math x = math.floor(M/N) y = int(math.sqrt(M)) if y < x: x = y for i in range(-x,0): if M%(-i)==0: print(-i) break" p03360,s972676677,Accepted,"num_list = [int(x) for x in input().split()] k = int(input()) print(sum(num_list) + max(num_list) * (2 ** k - 1))" p02793,s706994681,Accepted,"import sys def compute_gcd(x, y): while(y): x, y = y, x % y return x def compute_lcm(x, y): lcm = (x*y)//compute_gcd(x,y) return lcm def lcm(a): x = a[0] for i in range(1, len(a)): x = compute_lcm(x, a[i]) return x n = int(input()) a = list(map(int, input().split())) MOD = 10 ** 9 + 7 ans = lcm(a) cur = 0 for i in a: cur += ans // i print(cur % MOD) " p02768,s918534945,Accepted,"N,a,b=map(int,input().split()) MOD=10**9+7 def comb(n,k): tmp=1 for i in range(n-k+1,n+1): tmp*=i tmp%=MOD for i in range(1,k+1): tmp*=pow(i,MOD-2,MOD) tmp%=MOD return tmp ans = pow(2,N,MOD) - 1 - comb(N,a) - comb(N,b) print(ans%MOD)" p02642,s182731297,Accepted,"N = int(input()) A = list(map(int, input().split())) A.sort() M = A[-1] b = [True] * (M + 1) count = 0 for i, a in enumerate(A): if not b[a]: continue for j in range(a, M+1, a): b[j] = False if i < N-1 and A[i+1] == a: continue count += 1 print(count) " p02838,s856822907,Accepted,"import sys sys.setrecursionlimit(10 ** 7) f_inf = float('inf') mod = 10 ** 9 + 7 def resolve(): n = int(input()) A = list(map(int, input().split())) res = 0 for mask in range(60): cnt1 = sum([1 if a & (1 << mask) else 0 for a in A]) cnt0 = n - cnt1 res += (pow(2, mask, mod) * cnt1 * cnt0) % mod res %= mod print(res) if __name__ == '__main__': resolve() " p03071,s693376521,Accepted,"A,B = list(map(int, input().split())) x = 0 for i in range(2): if A <= B: x = x + B B -= 1 else: x = x + A A -= 1 print(x)" p03317,s378748518,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) if (n + k - 1) // k == 1: print(1) else: res = ((n - k) + (k - 2)) // (k - 1) + 1 print(res) " p02866,s685824726,Wrong Answer,"import collections mod=998244353 n=int(input()) arr=list(map(int,input().split())) dic=collections.defaultdict(int) for d in arr: dic[d]+=1 ans=1 for i in range(1,n): ans*=pow(dic[i-1],dic[i],mod) ans%=mod print(ans)" p03262,s617426258,Accepted,"import sys import math input = sys.stdin.readline N, X = map(int, input().split()) A = list(map(int, input().split())) gcd = abs(X - A[0]) for a_i in A: gcd = math.gcd(gcd, abs(X-a_i)) print(gcd)" p04030,s496406809,Wrong Answer,"s=input() ans="""" for i in range(len(s)): if s[i]==""B"": if len(ans)==0: continue t=ans[len(ans)-1] ans=ans.rstrip(t) else: ans+=s[i] print(ans) " p03076,s332217675,Accepted,"from itertools import permutations Minute=[int(input()) for _ in range(5)] ans_l=set() for M in permutations(Minute): res=0 ans=0 for i in range(5): res+=M[i] if i==4: break if res%10!=0: res=-(-res//10)*10 ans_l.add(res) print(min(ans_l))" p02712,s977872581,Accepted,"N = int(input()) ans = 0 for i in range(N+1): if i%3 != 0 and i%5 != 0: ans += i print(ans)" p03001,s095165461,Wrong Answer,"w,h,x,y = map(int,input().split()) flg = 0 if x * 2 == w : flg +=1 if y * 2 == h : flg +=1 if x * h == w * y : flg += 1 ans = max(w * y, h*x) if flg == 1: print(w*h/2, 0) elif flg > 1: print(w*h/2, 1) else: print(ans, 0) " p02755,s410951953,Accepted,"i = input().split(' ') A = int(i[0]) B = int(i[1]) for x in range(1,10000000): B_hat = int(x/10) if B_hat>100: break if int(x*2/25)==A and B_hat==B: print(x) exit() print(-1)" p03951,s815607508,Wrong Answer,"n = int(input()) s = input() t = input() for i in range(n): if s[i:] == t[:n-i]: print(n*2 - (n-i)) exit(0) print(2**n)" p02681,s862305354,Accepted,"S=input() T=input() if T[:-1]==S[:]: print('Yes') else: print('No')" p02935,s070985842,Accepted,"N = int(input()) v = sorted(list(map(int, input().split()))) ans = v[0] for n in range(1,N): ans = (ans + v[n]) / 2 print(ans)" p03075,s766974706,Wrong Answer,"antena = [int(input()) for _ in range(5)] k = int(input()) max_dist = max(antena) min_dist = min(antena) l = max_dist - min_dist if l < k: print(""Yay!"") else: print("":("") " p04034,s260958238,Accepted,"n, m = map(int,input().split()) ball = [1]*n red_ball = [1] + [0]*(n-1) for i in range(m): a,b = map(int,input().split()) if red_ball[a-1] == 1: if ball[a-1] == 1: ball[a-1] -= 1 ball[b-1] += 1 red_ball[a-1] = 0 red_ball[b-1] = 1 else: ball[a-1] -= 1 ball[b-1] += 1 red_ball[b-1] = 1 else: ball[a-1] -= 1 ball[b-1] += 1 print(sum(red_ball))" p03760,s729859330,Accepted,"O = list(input()) E = list(input()) L = len(O)+len(E) a = list() for i in range(L): if i < len(E): a.append(O[i]) a.append(E[i]) i += 1 if len(O) != len(E): a.append(O[-1]) b = """".join(a) print(b) " p02711,s274176733,Accepted,"N=raw_input() if ""7"" in N: print ""Yes"" else: print ""No""" p03910,s025960065,Accepted,"n = int(input()) s = set() sub = 1 cumsub = 0 while cumsub <= n: s.add(sub) cumsub += sub sub += 1 dif = cumsub - n if dif > 0: s.remove(dif) for i in s: print(i) " p02677,s737244359,Accepted,"import math a, b, h, m = map(int, input().split()) rh = (h * 60 + m) / 720 * 2 * math.pi rm = m / 60 * 2 * math.pi if abs(rh - rm) < 180: r = abs(rh - rm) c = ((a ** 2) + (b ** 2) - (2 * a * b * math.cos(r))) ** 0.5 print(c) if abs(rh - rm) > 180: r = 360 - abs(rh - rm) c = ((a ** 2) + (b ** 2) - (2 * a * b * math.cos(r))) ** 0.5 print(c) if abs(rh - rm) == 180: print(a + b)" p03137,s380158876,Accepted,"import heapq n,m = map(int, raw_input().split(' ')) xis = map(int, raw_input().split()) xis.sort() distances = [v- u for u,v in zip(xis,xis[1:])] distances.sort(key = lambda x:-x) print sum(distances[n-1:] or [0])" p02547,s350541825,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"") exit() else: pass if a!=b: count==0" p02787,s000787964,Accepted,"H, N = map(int, input().split()) ATK, MP = zip(*(tuple(map(int, input().split())) for _ in range(N))) MAX_ATK = max(ATK) table = [0] * (H + MAX_ATK) for damage in range(1, H + 1): table[damage] = min(table[damage - ATK[magic]] + MP[magic] for magic in range(N)) print(table[H]) " p02899,s058492729,Accepted,"n = int(input()) a = list(map(int,input().split())) ans = {} for i in range(n): ans[a[i]] = i + 1 s = [ans[i+1] for i in range(n)] print(*s)" p03338,s488436074,Accepted,"N = int(input()) S = input() M = 0 for i in range(1, N): #print(S[:i], S[i:]) temp = len(set(list(S[:i])) & set(list(S[i:]))) M = max(M, temp) print(M)" p02773,s918110265,Accepted,"N = int(input()) dic = {} for i in range(N): S = input() if S not in dic: dic[S] = 1 else: dic[S] += 1 sortDic = sorted(dic.items(), key=lambda x:x[1],reverse=True) list = [] list.append(sortDic[0][0]) j = 0 if len(sortDic) != 1: while j < len(sortDic)-1 and sortDic[j][1] == sortDic[j+1][1]: list.append(sortDic[j+1][0]) j += 1 list = sorted(list) for i in range(len(list)): print(list[i]) " p02835,s249915869,Accepted,"a,b,c=map(int,input().split()) if a+b+c>=22: print('bust') else: print('win') " p03293,s490657902,Wrong Answer,"s = str(input()) t = str(input()) if set(s) == set(t): print(""Yes"") else: print(""No"")" p03146,s716340354,Accepted,"s = int(input()) a =[s] i = 0 while True: i += 1 if a[i-1] % 2 == 0: if (a[i-1]//2) in a: print(len(a)+1) break else: a.append(a[i-1]//2) elif a[i-1] % 2 == 1: if (a[i-1]*3+1) in a: print(len(a)+1) break else: a.append(a[i-1]*3+1)" p03997,s595223879,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 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 a=I() b=I() h=I() ans=(a+b)*h//2 print(ans)" p03087,s866447591,Accepted,"N,Q = map(int,input().split()) S = input() ac = [0]*(N+1) for i in range(N): ac[i+1] = ac[i] + (1 if S[i:i+2] == ""AC"" else 0) for i in range(Q): l,r = map(int,input().split()) print(ac[r-1]-ac[l-1])" p02678,s868480343,Wrong Answer,"import collections N, M = map(int, input().split()) G = [[] for i in range(N)] for i in range(M): a, b = map(int, input().split()) G[b-1].append(a-1) G[a-1].append(b-1) queue = collections.deque([0]) visited = [-1]*N visited[0] = 0 while queue: x = queue.popleft() for i in G[x]: if visited[i] == -1: visited[i] = visited[x] + 1 queue.append(i) print(""Yes"") print(*visited[1:], sep=""\n"")" p02783,s362395390,Accepted,"a=input().split() (n,m)=map(int,a) if n%m==0: print(n//m) else: print((n+m-(n%m))//m)" p03944,s825895728,Accepted,"W,H,N = map(int,input().split()) XYA = [tuple(map(int,input().split())) for i in range(N)] l,r,d,u = 0,W,0,H for x,y,a in XYA: 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) w = max(0,r-l) h = max(0,u-d) print(w*h)" p02873,s610433174,Accepted,"import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) s = input().strip() n = len(s) + 1 ans = [[0, 0] for _ in range(n)] # 左に連続する< for i in range(1, n): if s[i-1] == '<': ans[i][0] = ans[i-1][0] + 1 # 右に連続する> for i in range(0, n-1): if s[n-2-i] == '>': ans[n-2-i][1] = ans[n-1-i][1] + 1 print(sum(max(i) for i in ans)) " p02724,s892617902,Accepted,"X = int(input()) ans=0 ans+=(X//500)*1000 X%=500 ans+=(X//5)*5 print(ans) " p03943,s434901998,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"")" p03274,s817833027,Accepted,"N,K=map(int,input().split()) X=list(map(int,input().split())) M=float(""inf"") for i in range(N-K+1): a,b=X[i],X[i+K-1] if 0<=a or b<=0: M=min(M,max(abs(a),abs(b))) else: c=min(abs(a),abs(b)) M=min(M,abs(a)+abs(b)+abs(c)) print(M)" p03433,s256858877,Accepted,"n = int(input()) a = int(input()) if (n % 500) <= a: print(""Yes"") else: print(""No"")" p03817,s736814982,Wrong Answer,"n = int(input()) div,mod = divmod(n,11) if mod <= 6: print(div * 2 +1) else: print(div*2+2) " p02900,s562157243,Accepted,"from math import gcd,sqrt,floor a,b = map(int,input().split()) c = gcd(a,b) x = [] for i in range(1,floor(sqrt(c))+1): if c % i == 0: x.append(i) x.append(c//i) x.sort() y = [] i = 1 while c > 1 and i < len(x): if c % x[i] == 0: y.append(x[i]) c = c // x[i] else: i += 1 print(len(set(y))+1)" p03264,s469494109,Wrong Answer,"K = int(input()) if K % 2 == 0: r = K // 2 **2 else: r = K // 2 * (K // 2 + 1) print(int(r))" p02582,s377623059,Accepted,"S = list(input()) r_cnt = 0 max_r_cnt = 0 for s in S: if s == ""R"": r_cnt += 1 else: r_cnt = 0 max_r_cnt = max(r_cnt, max_r_cnt) print(max_r_cnt) " p02814,s486979383,Accepted,"from math import gcd import sys N, M = map(int, input().split()) A = list(map(int, input().split())) lcm = 1 for a in A: gcd_ = gcd(lcm, a//2) lcm = lcm * (a // 2 // gcd_) for a in A: if (lcm // (a // 2)) % 2 == 0: print(0) sys.exit() print(M // lcm - M // (2 * lcm)) " p03351,s839287721,Accepted,"a,b,c,d=map(int,input().split()) if abs(c-a)<=d: print('Yes') elif abs(a-b)<=d and abs(b-c)<=d: print('Yes') else: print('No') " p03438,s483980940,Accepted,"n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) j = sum(b) - sum(a) c = [0, 0] for i in range(n): if a[i] > b[i]: c[0] += a[i] - b[i] if a[i] < b[i]: c[1] += -(-(b[i]-a[i])//2) print(""Yes"" if max(c) <= j else ""No"") " p02556,s924774834,Accepted,"N = int(input()) Array1 = [] Array2 = [] for i in range(N): next_x, next_y = map(int, input().split()) s = next_x + next_y t = next_x - next_y Array1.append(s) Array2.append(t) print(max(max(Array1)-min(Array1),max(Array2)-min(Array2)))" p03071,s692844350,Wrong Answer,"A, B = [int(n) for n in input().split()] ans = 0 for i in range(2): ans += A if A >= B else B print(ans) " p03493,s969305404,Wrong Answer,"print([int(input())].count(1)) " p02720,s291672675,Accepted,"from collections import deque K=int(input()) queue=deque([1,2,3,4,5,6,7,8,9]) for i in range(K): k=queue.popleft() if k%10!=0: queue.append(10*k+(k%10)-1) queue.append(10*k+(k%10)) if k%10!=9: queue.append(10*k+(k%10)+1) print(k)" p02897,s196229404,Accepted,"count=0 n=int(input()) for i in range(1,n+1): if i%2!=0: count+=1 print(count/n) " p03723,s294497692,Accepted,"import sys A, B, C = [int(x) for x in input().split()] ans = 0 if(A==B==C)and(A%2==0)and(B%2==0)and(C%2==0): print(-1) sys.exit() while (A%2==0)and(B%2==0)and(C%2==0): a = B/2 + C/2 b = C/2 + A/2 c = A/2 + B/2 A, B, C = a, b, c ans += 1 print(ans)" p03239,s382831537,Accepted,"N,T=map(int,input().split()) ct=[list(map(int,input().split())) for _ in range(N)] ans_l=[] for i in range(N): if ct[i][1]<=T: ans_l.append([ct[i][0],i+1]) if ans_l==[]: print('TLE') else: len_ans_l=len(ans_l) ans=float('inf') for i in range(len_ans_l): if ans_l[i][0]= 2: ans = ans + cmb(n, 2) if m >= 2: ans = ans + cmb(m, 2) print(ans)" p02973,s624409136,Accepted,"import bisect n = int(input()) A = [int(input()) for _ in range(n)] L = [-1]*n count = 0 for i in A: t = bisect.bisect_left(L, i) - 1 if L[t] == -1: count += 1 L[t] = i print(count)" p02951,s981762129,Accepted,"a, b, c = map(int, input().split()) print(c + b - a if c + b > a else 0)" p03761,s681742550,Wrong Answer,"n = int(input()) last = """" for i in range(n): s = input() if i == 0: last = s last_dummy = """" s_dummy = s for j in range(len(last)): for k in range(len(s)): if last[j] == s[k]: last_dummy += last[j] s.strip(s[k]) break last = last_dummy ans_list = sorted(last) ans = """" for i in ans_list: ans += i print(ans)" p02939,s421690790,Accepted,"s = input() i = 1; a = 1; n = 1 while i < len(s): if a == 1 and s[i-1] == s[i]: a = 2; i += 2; n += 1 else: if i == len(s)-2 and s[i] == s[i+1]: n -= 1 a = 1; i += 1; n += 1 print(n)" p03673,s354532584,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))" p02777,s372326282,Wrong Answer,"red, blue= input().split() r, b = [int (x) for x in input().split()] s = input() if s == ""red"": r = r - 1 else: b = b - 1 print(r, end="" "") print(b)" p03162,s822188153,Accepted,"n = int(input()) abc = [] for _ in range(n): t = [ int(x) for x in input().split() ] abc.append(t) 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: continue dp[i+1][j] = max(dp[i+1][j], dp[i][k] + abc[i][j]) print(max(dp[n])) " p03261,s388687284,Accepted,"n = int(input()) s = input() ws = set() ws.add(s) last = s[-1] for _ in range(n-1): s = input() if s in ws or s[0] != last: print('No') break else: ws.add(s) last = s[-1] else: print('Yes')" p02627,s653920945,Accepted,"a = input() if a.islower(): print('a') else: print('A')" p03624,s412813467,Wrong Answer,"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""] b = input() c = [] d = len(b) for i in range(int(d)): c.append(b[i]) e = list(set(c)) f = sorted(e) g = len(f) h = int(0) if g != 26: for i in range(int(g)): if f[i] == a[i]: h = h + 1 else: print(a[i]) else: print(""None"") if h == g: print(a[h])" p02700,s884116525,Wrong Answer,"[a,b,c,d]=list(map(int,input().split())) ans=""No"" chokudai=c//b if c%b!=0: chokudai+=1 aoki=a//d if a%b!=0: aoki+=1 if chokudai>=aoki: ans=""Yes"" print(ans)" p02695,s520294992,Accepted,"from itertools import combinations_with_replacement n, m, q = map(int, input().split()) QUERY = [tuple(map(int, input().split())) for _ in range(q)] ans = 0 for A in combinations_with_replacement(range(1, m + 1), n): temp = 0 for a, b, c, d in QUERY: a -= 1; b -= 1 if A[b] - A[a] == c: temp += d ans = max(ans, temp) print(ans) " p03645,s243278444,Accepted,"N,M = map(int,input().split()) AB = [tuple(map(int,input().split())) for i in range(M)] s1 = set() sn = set() for a,b in AB: if a==1: s1.add(b) if b==N: sn.add(a) print('POSSIBLE' if s1&sn else 'IMPOSSIBLE')" p03767,s257587665,Accepted,"n=int(input()) a=sorted(list(map(int,input().split())))[::-1] ans=0 for i in range(n): ans+=a[i*2+1] print(ans)" p03076,s071957314,Accepted,"import sys from itertools import permutations times = [int(sys.stdin.readline().rstrip()) for _ in range(5)] ans = 10**10 for prm in permutations(range(5)): res = 0 for i, p in enumerate(prm): res += times[p] r = times[p] % 10 if i < 4: if r != 0: res += 10 - r ans = min(ans, res) print(ans)" p02748,s529155689,Accepted,"_,a,b,*t = [list(map(int,t.split())) for t in open(0)] n=min(a)+min(b) for x,y,c in t: n=min(n,a[x-1]+b[y-1]-c) print(n)" p03136,s026572278,Wrong Answer,"n=int(input()) l=list(map(int,input().split())) for i in range(n): if l[i]*2 <=sum(l): print(""No"") exit() print(""Yes"")" p03548,s843225426,Accepted,"X,Y,Z = map(int,input().split()) print(1+(X-Y-2*Z)//(Y+Z))" p03605,s147740310,Accepted,"print(['No','Yes']['9' in input()])" p03986,s408952892,Wrong Answer,"X = str(input()) x = X.index('S') y = X.rindex('T') A = X[x:y+1] a = A.count('S') b = A.count('T') ans = len(X)-len(A) ans += abs(a-b) print(ans) " p02995,s122992830,Accepted,"a,b,c,d=map(int,input().split()) from fractions import gcd m=(c*d)//gcd(c,d) A=b//c-(a-1)//c # a-bのうち、cの倍数のもの B=b//d-(a-1)//d # a-bのうち、dの倍数のもの C=b//m-(a-1)//m # a-bのうち、cとdの最小公倍数の倍数のもの ans=(b-a+1)-(A+B-C) print(ans) " p02879,s937061203,Wrong Answer,"a, b = map(int, input().split()) print(""-1"" if a>=b>=10 else a*b)" p02702,s166393014,Wrong Answer,"S = input() int_S = int(S) N = len(S) cnt = 0 pos_l = 0 pos_r = 0 while (True): pos_r += + 1 if (pos_r < N): tmp = int(S[pos_l: pos_r + 1]) if (tmp % 2019 == 0): cnt += 1 pos_l = pos_r else: pos_l += 1 if (pos_l >= N): break print(cnt)" p02661,s801792519,Accepted,"import sys def input(): return sys.stdin.readline().strip() def mapint(): return map(int, input().split()) sys.setrecursionlimit(10**9) N = int(input()) As = [] Bs = [] for _ in range(N): A, B = mapint() As.append(A) Bs.append(B) As.sort() Bs.sort() if N%2==1: left = As[N//2] right = Bs[N//2] else: left = (As[N//2]+As[N//2-1]) right = (Bs[N//2]+Bs[N//2-1]) print(right-left+1)" p03474,s109158950,Accepted,"a, b = map(int, input().split()) s = input() if s[:a].isdigit() and s[a] =='-' and s[-b:].isdigit(): print('Yes') else: print('No') " p02699,s572056217,Accepted,"s,w=map(int,input().split()) if(s>w): print(""safe"") else: print(""unsafe"") #a,b,c,d=map(int,input().split()) " p03286,s156030725,Accepted,"N=int(input()) ans="""" if N==0: ans=""0"" while N!=0: if N%2!=0: ans+=""1"" else: ans+=""0"" N=-(N//2) print(ans[::-1]) " p02813,s516611496,Accepted,"#!/usr/bin/env python3 import itertools N = int(input()) P = tuple(map(int, input().split())) Q = tuple(map(int, input().split())) st = sorted(P) x = list(itertools.permutations(st, N)) num_p = x.index(P) num_q = x.index(Q) print(abs(num_p - num_q))" p03017,s782093030,Accepted,"import re n, a, b, c, d = map(int, input().split()) road = input() if c < d: if re.search('##', road[a:d]) is None: print('Yes') else: print('No') elif c > d: if re.search('##', road[a:]) is None and re.search('\.\.\.', road[b-2:d+1]) is not None: print('Yes') else: print('No')" p02719,s836194435,Wrong Answer,"N, K = map(int,input().split()) if N < abs(N-K): print(N) else: if N % K == 0: print(0) else: print(1)" p03486,s553414989,Accepted,"s = sorted(input()) t = sorted(input())[::-1] flag = -1 for i,j in zip(s,t): if ord(i) < ord(j): flag = 1 break elif ord(i) == ord(j): flag = 0 else: flag = -1 break if flag ==1: print(""Yes"") elif flag == -1: print(""No"") else: if len(s) < len(t): print(""Yes"") elif len(s) >= len(t): print(""No"")" p04012,s501660379,Wrong Answer," w=input() lst=[] flag = 0 for i in w: lst.append(i) for i in range(len(w)): if lst[i] == 99: continue c = 1 j = i + 1 while j < len(w): if lst[i] == lst[j]: lst[j] = 99 c += 1 j += 1 if c % 2 != 0: print(""NO"") flag = 1 break if flag == 0: print(""YES"") " p03150,s205540050,Accepted,"S = input() flag = False for L in range(8): T = S[:L] + S[len(S)-(7-L):] if T == ""keyence"": flag = True break print(""YES"" if flag else ""NO"")" p03075,s027126322,Accepted,"L = [] for i in range(6): L.append(int(input())) if (L[4] - L[0]) <= L[5] : print(""Yay!"") else: print("":("")" p02665,s216569883,Accepted,"import sys n=int(input()) a=input() a=[int(s)for s in a.split()] M=1 Q=1 m=sum(a) if a[0]>=1: if a[0]==1 and n==0: print(1) sys.exit() else: print(-1) sys.exit() for i in range(n): M=2*M-a[i+1] if M<0: print(-1) sys.exit() M1=M+a[i+1] m=m-a[i] Q=Q+min(M1,m) print(Q)" p03011,s583502678,Wrong Answer,"p,q,r=map(int,input().split()) if p+q=c: print('Yes') else: print('No')" p03760,s035014264,Accepted,"a=list(input()) b=list(input()) ans=[] for i in range(len(b)): ans.append(a[i]) ans.append(b[i]) ANS=''.join(ans) print(ANS if len(a)==len(b) else ANS+a[len(a)-1])" p04044,s359250927,Wrong Answer,"N, L = map(int, input().split()) s = list(input().split()) t = ''.join(sorted(s)) print(t)" p04011,s261951474,Accepted,"N=int(input()) K=int(input()) X=int(input()) Y=int(input()) if N<=K: ans=N*X else: ans=K*X+(N-K)*Y print(ans)" p02860,s554783475,Accepted,"n = int(input()) s = input() if (n%2 == 1): print(""No"") else: c = 0 for i in range(int(n/2)): if (s[i] != s[i + int(n/2)]): c = 1 if (c == 0): print(""Yes"") else: print(""No"")" p02717,s977031262,Wrong Answer,"A, B, C = map(str, input().split()) print(C+' '+B+' '+A)" p03721,s791204506,Accepted,"from collections import defaultdict 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, k = LI() d = defaultdict(int) for _ in range(n): a, b = LI() d[a] += b d = sorted(d.items(), key=lambda x: x[0]) # print(d) i = 0 ans = 1 cnt = 0 while cnt < k: ans = d[i][0] cnt += d[i][1] i += 1 print(ans) " p02748,s749973715,Wrong Answer,"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) for j in range(min(len(a),len(b))): min_pay = min(min_pay,a[j]+b[j]) print(min_pay)" p02777,s402381094,Wrong Answer,"S, T = map(str, input().split()) A, B = map(int, input().split()) U = input() dict = {S: A, T: B} dict[U] = dict[U] - 1 values = [] for k, v in dict.items(): print(v, end="" "") " p02881,s938936802,Accepted,"n = int(input()) a = 0 for i in reversed(range(1,int(n**(1/2))+1)): if n % i == 0: a = i break b = int(n / a) print(a+b-2)" p03289,s439219553,Wrong Answer,"s = input() t = 'a' for i in range(1, len(s)): t += s[i] if s[i] == 'C': t += 'c' if s[0] == 'A' and s[2:-1].count('C') == 1 and t.islower: print('AC') else: print('WA')" p02831,s225477496,Accepted,"# C - Snack from fractions import gcd a,b = map(int,input().split()) print(a*b//gcd(a,b))" p02689,s044805430,Wrong Answer,"N, M = map(int, input().split()) H = list(map(int, input().split())) good_H = [1] * N for i in range(M): A, B = map(int, input().split()) if H[A-1] < H[B-1]: good_H[A-1] = 0 elif H[A-1] > H[B-1]: good_H[B-1] = 0 print(good_H.count(1))" p02838,s943991687,Accepted,"n=int(input()) a=list(map(int,input().split())) mod = 10**9 + 7 res = 0 for i in range(60): cnt_one = sum([a[j]&1 for j in range(n)]) #1とのandをとり,1の個数をカウント cnt_zero = n - cnt_one res += 2**i * cnt_one * cnt_zero a = [a[j]>>1 for j in range(n)] #各要素に対し,右に1ビットシフト print(res % mod)" p03103,s430056887,Wrong Answer,"n,m=map(int,input().split()) d={} for _ in range(n): a,b=map(int,input().split()) d[a]=b d2 = dict(sorted(d.items())) def c(dic): s=0 cost=0 for x in d2.keys(): for _ in range(d2[x]): cost+=x s+=1 if s==m: return cost print(c(d2))" p02724,s295313810,Accepted,"x = int(input()) a = x // 500 b = (x - (a * 500)) // 5 c = (a * 1000) + (b * 5) print(c)" p03944,s862000435,Accepted,"w,h,n=map(int,input().split()) l=[list(map(int,input().split())) for _ in range(n)] a,b,c,d=0,w,0,h for x,y,A in l: if A==1: a=max(a,x) elif A==2: b=min(b,x) elif A==3: c=max(c,y) else: d=min(d,y) # print(f""b-a:{b-a},d-c:{d-c}"") print((b-a)*(d-c) if b-a>=0 and d-c>=0 else 0)" p03705,s516485455,Wrong Answer,"# https://atcoder.jp/contests/agc015/tasks/agc015_a import math n, a, b = map(int, input().split()) if b < a: print(0) elif a != b and n == 1: print(0) else: t = b - a + 1 ans = math.factorial(t + n - 1) // (math.factorial(t) * math.factorial(n)) print(ans)" p03997,s803468078,Accepted,"a = int(input()) b = int(input()) h = int(input()) print((a+b)*h//2)" p03779,s549085044,Accepted,"X = int(input()) now = 0 maxjump = 1 while now+maxjump < X: now += maxjump maxjump += 1 print(maxjump) " p02711,s304853730,Accepted,"N = str(input()) if ""7"" in N: print(""Yes"") else: print(""No"")" p03407,s345287417,Accepted,"A,B,C = map(int, input().split()) if A+B >= C: print(""Yes"") else: print(""No"")" p03779,s406207405,Accepted,"X = int(input()) ans = 0 check = 0 for i in range(1, 10**7): ans += i check += 1 if X <= ans: print(check) break" p03103,s022613422,Accepted,"N,M = map(int,input().split()) X = sorted([list(map(int,input().split())) for n in range(N)]) G = 0 D = 0 for m in range(M): if D+X[m][1] 0: c += 1 print(c) " p02802,s970422777,Wrong Answer,"n, m = map(int, input().split()) wa = [0]*(n+1) ac = [False]*(n+1) for i in range(m): p, s = input().split() p = int(p) if ac[p]: continue if s == 'WA': wa[p] += 1 elif s == 'AC': ac[p] = 1 print(sum(ac[1:]), sum(wa[1:]))" p03086,s227001572,Accepted,"s = input() x = 0 y = 0 for i in range(len(s)): if s[i] == ""A"" or s[i] == ""C"" or s[i] == ""G"" or s[i] == ""T"": x = x + 1 else: if y < x: y = x x = 0 if y < x: y = x print(y)" p03723,s911646986,Wrong Answer,"a, b, c = map(int,input().split()) ans = 0 l = [a] while True: ans += 1 x = b//2 + c//2 y = a//2 + c//2 z = a//2 + b//2 if x%2 == 1 or y%2 == 1 or z%2 == 1: break else: a = x if a in l: print(-1) exit() else: l.append(a) b = y c = z print(ans)" p02622,s889939889,Wrong Answer,"s=list(input().split()) t=list(input().split()) ans=0 for i in range(len(s)): if s[i]!=t[i]: ans+=1 print(ans)" p02860,s058225287,Accepted,"n=int(input()) s=input() l=int(len(s)) m=0 if l%2==0: a=s[0:l//2] b=s[l//2:l] for i in range(n//2): if a[i]!=b[i]: m+=1 if m==0: print(""Yes"") else: print(""No"") else: print(""No"")" p03042,s527421335,Accepted,"def main(): S = input() first = S[:2] second = S[2:] YYMM = False MMYY = False if ""00"" <= first <= ""99"" and ""01"" <= second <= ""12"": YYMM = True if ""01"" <= first <= ""12"" and ""00"" <= second <= ""99"": MMYY = True if YYMM and MMYY: ans = ""AMBIGUOUS"" elif YYMM: ans = ""YYMM"" elif MMYY: ans = ""MMYY"" else: ans = ""NA"" print(ans) if __name__ == ""__main__"": main() " p03767,s580242833,Accepted,"n = int(input()) a = list(map(int, input().split())) a.sort() a.reverse() print(sum(a[1:-n:2])) " p02684,s057880229,Accepted,"import sys readline = sys.stdin.readline n, k = map(int, readline().split()) A = [i - 1 for i in map(int, readline().split())] m = 60 d = [A] pre = A for i in range(m): current = [pre[pre[j]] for j in range(n)] d.append(current) pre = current route = 0 for i in range(m-1, -1, -1): if k >= (x := 1 << i): route = d[i][route] k -= x print(route+1) " p03284,s298685395,Accepted,"n,k=map(int,input().split()) print(0 if n%k==0 else 1)" p02576,s422624213,Wrong Answer,"n,x,t = map(int,input().split()) if n % x == 0: print(n / x * t) else: print(n / x * t + 1) " p03605,s980781956,Accepted,"print(""Yes"" if ""9"" in input() else ""No"")" p03252,s109064176,Accepted,"def isOK(s,t): m = [None] * 26 for i,j in zip(s,t): num = ord(i) - ord(""a"") if m[num] == None: m[num] = j else: if m[num] != j: return False return True s = input() t = input() if isOK(s,t) and isOK(t,s): print(""Yes"") else: print(""No"")" p02923,s734023149,Accepted,"import heapq t = 1 def max(a,b): if a > b: return a return b def min(a,b): if a < b: return a return b while t > 0: t -= 1 # a,b = map(int,input().split()) n = int(input()) v = list(map(int,input().strip().split()))[0:n] i = 0 ans = 0 while i < n: j = i while j+1 < n and v[j+1] <= v[j]: j += 1 l = j-i+1 ans = max(ans,l) i = j+1 print(ans-1) " p03555,s875292830,Accepted,"s=str(input()) t=str(input()) print(""YES"" if s[0]==t[2] and s[1]==t[1] and s[2]==t[0] else ""NO"")" p02854,s782577374,Accepted,"n = int(input()) A = list(map(int, input().split())) ans = 10**11 sum_A = sum(A) l = 0 for a in A: l += a if abs(l - (sum_A - l)) < ans: ans = abs(l - (sum_A - l)) print(ans) " p03013,s453686230,Wrong Answer,"from collections import deque n,m=map(int,input().split()) step=list(range(2,n+1)) broken=[] for i in range(m): broken+=[int(input())] mod=10**9+7 dp=[0]*(n+1) dp[0]=1 if m==0: dp[1]=1 elif not broken[0]==1: dp[1]=1 b=deque(broken) if len(broken) != 0: bad_one = b.popleft() else: bad_one = -1 for i in step: if i != bad_one: dp[i]=(dp[i-1]+dp[i-2])%mod elif i == bad_one and len(b) != 0: bad_one = b.popleft() print(dp[n])" p02778,s019317125,Accepted,"b = input() print(""x"" * len(b)) " p03285,s030393058,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"")" p02842,s040002991,Accepted,"import math N = int(input()) lower = N / 1.08 vl = math.ceil(lower) if math.floor(vl * 1.08) == N: print(vl) else: print("":("")" p03785,s066519818,Wrong Answer,"#!/usr/bin/env python3 # input import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines n, c, k = map(int, input().split()) t = [int(input()) for _ in range(n)] t.sort() ans = 1 now = t[0] cnt = 1 for i in range(n): if t[i] - now > k or cnt > c: plus_bit = 1 now = t[i] cnt = 1 ans += 1 else: cnt += 1 print(ans) " p02748,s936321808,Accepted,"a,b,m=map(int,input().split()) A=list(map(int,input().split())) B=list(map(int,input().split())) x=[[int(i) for i in input().split()] for i in range(m)] ans=min(A)+min(B) for s,t,u in x: tmp=A[s-1]+B[t-1]-u ans=min(ans,tmp) print(ans)" p03243,s678563262,Accepted,"n = int(input()) for i in range(100,1000): if i >= n and i%100//10 == i%10 == i//100: print(i) break " p03103,s673008710,Wrong Answer,"n,m = map(int,input().split()) li = [] for i in range(n): a,b = map(int,input().split()) li.append([str(a),b]) li = sorted(li) coin = 0 cnt = 0 i = 0 while cnt != m: if li[i][1]>0: cnt+=1 coin += int(li[i][0]) li[i][1]-=1 else: i+=1 print(coin) " p02859,s976919074,Wrong Answer,"import math i = int(input()) print(math.sqrt(i))" p03043,s422297743,Accepted,"import math n, k = map(int, input().split()) prob = 0 for i in range(1,n+1): if i <= k-1: x = math.floor(1+math.log2(((k-1)/i))) prob += (1/2)**x else: prob += 1 print(prob/n)" p02971,s795021314,Accepted,"N = int(input()) A = [ int(input()) for i in range(N)] _A =sorted(A, reverse=True) A_max = _A[0] A_second_max = _A[1] for i in range(N): if A[i] == A_max: print(A_second_max) else: print(A_max)" p03487,s442119864,Accepted,"from collections import Counter input();a=Counter(map(int,input().split())) print(sum([j if i>j else j-i for i,j in a.items()]))" p02897,s441809563,Wrong Answer,"n = int(input()) if n%2 == 1: ans = (n-1)/2+1 / n else: ans = 1/2 print(ans)" p02729,s845335213,Accepted,"N, M = list(map(int, input().split())) def comb2(x): return x * (x - 1) / 2 print(int(comb2(N) + comb2(M)))" p03680,s970615483,Accepted,"N = int(input()) lamps = [0] * N next_ = 0 count = 0 buttons = list(map(lambda x: int(x) - 1, (input() for _ in range(N)))) while True: count += 1 lamps[next_] = 1 next_ = buttons[next_] if next_ == 1: break if lamps[next_]: count = -1 break print(count) " p02832,s923251539,Wrong Answer,"n = int(input()) a_list = list(map(int, input().split())) if a_list == list(range(1, len(a_list) + 1)): print(0) cond_idx = 0 for num in range(1, len(a_list)): if num == 1: if num not in a_list: print(-1) break if num in a_list[cond_idx:]: cond_idx += a_list[cond_idx:].index(num) # print(num, cond_idx) else: print(n - num + 1) break" p02640,s347907922,Accepted,"x,y=map(int,input().split()) if y%2!=0: print(""No"") exit() if 2*x<=y<=4*x: print(""Yes"") else: print(""No"")" p03854,s496001573,Accepted,"s = input() s = s[::-1] j = 0 p = len(s) while True: if s[j:j+5] == 'maerd': j += 5 elif s[j:j+7] == 'remaerd': j += 7 elif s[j:j+5] == 'esare': j += 5 elif s[j:j+6] == 'resare': j += 6 else: print('NO') break if j == p: print('YES') break" p02642,s866324372,Accepted,"import sys input = sys.stdin.readline from collections import Counter N = int(input()) A = list(map(int, input().split())) A.sort() C = Counter(A) cannot = set() L= max(A) ans = 0 for a in A: if a in cannot: continue if C[a] == 1: ans += 1 ind = 1 while a*ind <= L: cannot.add(a*ind) ind += 1 print(ans)" p03555,s640689213,Accepted,"f = input() g = input() g = list(g) g.reverse() p = (''.join(g)) if p == f: print(""YES"") else: print(""NO"")" p03208,s871884285,Wrong Answer,"n, k = map(int, input().split()) h = [int(input()) for i in range(n)] h.sort() inf = float('inf') min_ = inf for i in range(n - k): if h[i+k-1] - h[i] < min_: min_ = h[i+k-1] - h[i] print(min_)" p03543,s489026337,Accepted,"a,b,c,d = input() print(""Yes"" if a==b==c or b==c==d else ""No"")" p03910,s321705538,Wrong Answer,"N = int(input()) if N == 1: print(1) else: s = 0 l = [] for i in range(1, N): s += i l.append(i) if s > N: break # print(l) for i in range(len(l)): if s-l[i] == N: l.pop(i) break for i in l: print(i) " p03261,s522444501,Wrong Answer,"N = int(input()) W = [input() for i in range(N)] if all(W[i+1][0]==W[i][-1] and W[i] not in W[:i] for i in range(N-1)): print('Yes') else: print('No')" p03127,s858899180,Accepted,"n, *a = map(int, open(0).read().split()) a.sort() ans = 1e10 for i in range(1, n): x, y = a[0], a[i] while y%x: y -= y//x*x x, y = y, x ans = min(ans, x) print(ans)" p02988,s395494987,Accepted,"n=int(input()) p=list(map(int,input().split())) ans=0 for i in range(n-2): if (p[i]p[i+1]>p[i+2]): ans+=1 print(ans) " p03011,s845222163,Accepted,"P,Q,R = map(int,input().split()) print(P+Q+R-max(P,Q,R))" p02659,s710175051,Wrong Answer,"A,B=map(float,input().split()) X=A*(B*100)/100 print(int(X))" p02645,s260815563,Accepted,"s = input() print(s[:3])" p03612,s280484939,Accepted,"N=int(input()) *P,=map(int,input().split()) i=c=0 while i 1000000: print(-1) exit(0) print(cot)" p02697,s436549581,Accepted,"n, m = map(int, input().split()) if m%2 == 1: # for i in range(m): # print(str(i+1) + ' ' + str(2*m-i)) for i in range(int((m-1)/2)): print(str(i+1) + ' ' + str(m-i)) for i in range(int((m+1)/2)): print(str(m+i+1) + ' ' + str(2*m-i+1)) else: for i in range(int(m/2)): print(str(i+1) + ' ' + str(m-i+1)) for i in range(int(m/2)): print(str(i+m+2) + ' ' + str(2*m-i+1))" p03469,s502887651,Wrong Answer,"import sys S = input() if len(S) != 10: sys.exit() if S[0:8] != '2017/01/': sys.exit() if 1 <= int(S[-2:]) <= 31: sys.exit() print(S.replace('2017','2018')) " p03427,s312303138,Accepted,"N = [int(i) for i in list(input())] # コーナーケース if len(N) == 1: print(N[0]) exit() elif set(N[1:]) == set([9]): print(N[0] + (len(N) - 1) * 9) exit() ans = 0 s = 0 for i in range(len(N)): if N[i] == 0: continue ans = max(ans, s + (N[i] - 1) + 9 * (len(N) - 1 - i)) s += N[i] print(ans)" p04019,s583738615,Accepted,"s = list(input()) if ('N' in s) == ('S' in s) and ('E' in s) == ('W' in s): print('Yes') else: print('No')" p02695,s535866120,Accepted,"import itertools n,m,q=map(int,input().split()) a=[0 for i in range(q)] b=[0 for i in range(q)] c=[0 for i in range(q)] d=[0 for i in range(q)] for i in range(q): a[i],b[i],c[i],d[i]=map(int,input().split()) a[i]-=1 b[i]-=1 ans=0 for i in itertools.combinations_with_replacement(range(1,m+1),n): tmp=0 for j in range(q): if i[b[j]] - i[a[j]] == c[j]: tmp+=d[j] ans=max(ans,tmp) print(ans)" p02939,s814930804,Wrong Answer,"s = input() sl = list(s[i] for i in range(len(s))) cnt = 0 for i in range(len(s)-2): if sl[i] == sl[i+1]: sl[i+2] = ""0"" cnt += 1 if s[-3] != ""0"" and s[-2] == s[-1]: cnt += 1 print(len(s) - cnt)" p02714,s931345112,Accepted,"N = int(input()) S = input() ans = S.count(""R"")*S.count(""B"")*S.count(""G"") for i in range(N): for d in range(N): j = i+d k = j+d if k < N: if S[i] != S[j] and S[k] != S[j] and S[k] != S[i]: ans -= 1 print(ans)" p03699,s265165591,Accepted,"N = int(input()) s = [int(input()) for _ in range(N)] s.sort() mod = [i%10 for i in s] ans = sum(s) if ans%10 == 0: if mod.count(0)==N: ans=0 else: for i in range(N): if mod[i]!=0: ans -=s[i] break print(ans)" p02973,s116085551,Wrong Answer,"from collections import Counter N = int(input()) A = [int(input()) for _ in range(N)] counter = Counter(A) if counter.most_common()[0][0] >= N//2: print(counter.most_common()[0][0]) exit() ans = 0 while True: tmp = -1 for i in range(N): if A[i] > tmp: tmp = A[i] A[i] = -1 if tmp == -1: break ans += 1 print(ans)" p02918,s485635457,Accepted,"n, k = map(int, input().split()) ans = l = 0 for i in input(): ans += (n==i) n = i l += 1 print(min(ans+2*k, l-1))" p02866,s434388656,Accepted," from collections import Counter N = int(input()) X = list(map(int, input().split())) MOD = 998244353 ctr = Counter(X) if X[0] == 0 and ctr[0] == 1: ans = 1 for i in range(1, max(X) + 1): ans *= pow(ctr[i - 1], ctr[i], MOD) ans %= MOD print(ans) else: print(0) " p03633,s479028364,Accepted,"N = int(input()) def gcd(a,b): if b == 0: return a return gcd(b,a%b) def lcm(a,b): return a*b//gcd(a,b) T = [int(input()) for _ in range(N)] ans = T[0] for e in T: ans = lcm(e,ans) print(ans) " p02775,s727221778,Accepted,"s = ""0"" + input() n = len(s) S = [] for i in range(n-1,-1,-1): S.append(int(s[i])) ans = sum(S) ans0 = ans D = [[0] * 3 for i in range(n)] D[0] = [S[0], S[0]+1, 10-S[0]] for i in range(1, n): D[i][0] = min(D[i-1][0], D[i-1][1]) + S[i] D[i][1] = D[i-1][2] + S[i] + 1 D[i][2] = min(D[i-1][0]+10-S[i], D[i-1][1]+10-S[i], D[i-1][2]+9-S[i]) # print(D) print(min(D[-1][:2])) " p03673,s762242677,Accepted,"# ABC 066 C N = int(input()) A = input().split() from collections import deque tmp = deque([]) for i,a in enumerate(A): if i %2!=0: tmp.appendleft(a) else: tmp.append(a) if N%2!=0: tmp.reverse() print(' '.join(tmp))" p02814,s164411789,Accepted,"import sys import fractions N,M=map(int, input().split()) A = [int(a) for a in input().split()] A2 = [a>>1 for a in A] lcm = A2[0] for i in range(1, N): lcm = lcm * A2[i] // fractions.gcd(lcm, A2[i]) if lcm>M: print(0) sys.exit() B = sum([1 for a in A if lcm%a==0]) if B>0: print(0) else: print((M//lcm+1)//2)" p03779,s335001607,Accepted,"X = int(input()) count = 0 if X == 1: print(""1"") quit() if X == 2: print(""2"") quit() for i in range(1, X): count += i if count >= X: print(i) quit()" p02583,s961037100,Wrong Answer,"n=int(input()) l=list(map(int,input().split())) res=0 if(n<2): 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] and l[j]!=l[k] and l[k]!=l[i]): if(l[i]+l[j]>l[k] and l[j]+l[k]>l[i] and l[k]+l[i]>l[j]): res+=1 print(res) " p02675,s046189653,Accepted,"n = input() if n[len(n) - 1] == '3': print('bon') elif n[len(n) - 1] == '0' or n[len(n) - 1] == '1' or n[len(n) - 1] == '6' or n[len(n) - 1] == '8': print('pon') else: print('hon')" p03071,s146887847,Accepted,"a, b = map(int, input().split()) if a > b: print(a + a - 1) elif a == b: print(a + b) else: print(b + b - 1)" p03163,s811197806,Accepted,"N, W = map(int, input().split()) import numpy as np dp = np.zeros(W + 1, dtype=int) for i in range(N): w, v = map(int, input().split()) np.maximum(dp[:-w] + v, dp[w:], out=dp[w:]) print(dp.max())" p02946,s145246068,Wrong Answer,"k,x = map(int, input().split()) prob = [i for i in range(x-k+1,x+k)] print(prob)" p03698,s039205651,Accepted,"#!/usr/bin/env python3 import sys YES = ""yes"" # type: str NO = ""no"" # type: str def solve(S: str): print(YES if len(S) == len(set(S)) else NO) 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() " p03011,s184647734,Accepted,"def main(): P, Q, R = (int(x) for x in input().split()) print(min(P + Q, Q + R, R + P)) if __name__ == ""__main__"": main() " p03962,s993224390,Accepted,print(len(set([int(i) for i in input().split()]))) p03285,s768291306,Accepted,"N = int(input()) ans = ""No"" for i in range(N // 7 + 1): for j in range((N - i*7) // 4 + 1): if 7*i + 4*j == N: ans = ""Yes"" print(ans)" p02577,s450140821,Accepted,"n = str(input()) total = 0 for i in range(len(n)): total += int(n[i]) if total % 9 == 0: print(""Yes"") else: print(""No"")" p02744,s362792274,Accepted,"def gen_pattern(N, pre=""""): for c in range(0x61, ord(max(pre or ""\x60""))+2): pat = pre+chr(c) if len(pat) == N: yield pat else: yield from gen_pattern(N, pat) for pattern in gen_pattern(int(input())): print(pattern) " p02859,s338438946,Accepted,"r = int(input()) print(r**2)" p02640,s653742362,Wrong Answer,"given = input() data = given.strip().split() X = int(data[0]) Y = int(data[1]) i = 0 ashi = 0 while (i < X): ashi = 2 * (X - i) + 4 * i if ashi == Y: print(""Yes"") break i = i + 1 if i == X: print(""No"")" p03745,s509124325,Accepted,"n = int(input()) A = list(map(int,input().split())) f = 0 i = 0 ans = 1 for i in range(n-1): if f==0 and A[i+1]-A[i] > 0: f = 1 elif f==0 and A[i+1]-A[i] < 0: f = -1 elif (f < 0 and A[i+1]-A[i] > 0) or (f > 0 and A[i+1]-A[i] < 0): f = 0 ans += 1 print(ans) " p03998,s309805040,Accepted,"from collections import deque a = deque(reversed(input())) b = deque(reversed(input())) c = deque(reversed(input())) ne = a.pop() while(True): if ne == 'a': if not a: break ne = a.pop() elif ne == 'b': if not b: break ne = b.pop() else: if not c: break ne = c.pop() print(ne.upper())" p02719,s532151405,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 = [input() for _ in range(n)] n,k= map(int, input().split()) tmp = n//k a = abs(n-k*tmp) b = abs(a-k) print(min(a,b)) " p03698,s457315237,Accepted,"S=input() L=list(S) if len(L)==len(set(L)): print('yes') else: print('no') " p03107,s972794838,Accepted,"S = input() zero = 0 for s in S: if s=='0': zero+=1 one = len(S)-zero print(min(one,zero)*2)" p02922,s163919605,Accepted,"import math A, B = map(int, input().split()) print(math.ceil((B-1)/(A-1)))" p03360,s891458997,Accepted,"a, b, c = map(int, input().split()) K = int(input()) m = max(a, b, c) print(a + b + c - m + m * 2 ** K)" p03254,s752373389,Wrong Answer,"n,x = map(int,input().split()) a = sorted(map(int,input().split())) c=0 for i in a: if i<=x: x-=i c+=1 else: if x>0: c-=1 print(max(0,c))" p03289,s150431941,Wrong Answer,"import re print(""WA"" if re.match('A[a-z][a-z][a-z]*C[a-z]*[a-z]',input()) == None else ""AC"")" p02677,s300956697,Accepted,"import math 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())) mod = 10**9 + 7 sys.setrecursionlimit(1000010) A,B,H,M = nm() (a, b, h, m)=map(float,(A,B,H,M)) theta = 2.0 * math.pi * ( m /60.0 - (h + m /60.0 )/12.0) print(math.sqrt( a * a + b * b - 2.0 * a * b * math.cos(theta)))" p03000,s368360412,Accepted,"n,x = map(int,input().split()) L = list(map(int,input().split())) s = 0 for i in range(n): s += L[i] if s > x: print(i+1) break else: print(n+1)" p03284,s149526745,Accepted,"N, K = map(int, input().split()) print(0 if N%K==0 else 1) " p03163,s647038289,Wrong Answer,"n,w=[int(i) for i in input().split()] wi=[] val=[] for i in range(n): k=[int(i) for i in input().split()] wi.append(k[0]) val.append(k[1]) dp=[[-1]*10**5]*105 print(wi,val) def solve(pos,we): if we>w: return float(""-inf"") if pos>=n: return 0 if dp[pos][we]!=-1: return dp[pos][we] ans=max(solve(pos+1,we+wi[pos])+val[pos],solve(pos+1,we)) dp[pos][we]=ans return ans print(solve(0,0))" p02682,s633510306,Wrong Answer,"a, b, c, k = map(int, input().split()) sum = 0 if k > a: sum = a if k-a <= b: sum = a else: sum = 2*a+b-k print(sum)" p03711,s356211009,Wrong Answer,"l = [[1,3,5,7,8,10,12], [4,6,9,11], [2]] a, b = map(int, input().split()) for i in l: if a in i and b in i: print('Yes') break else: print('No') break " p03109,s804679131,Wrong Answer,"y, m, d = map(int, input().split(""/"")) if y * 365 + m * 12 + d > 2019 * 365 + 4 * 12 + 30: print(""TBD"") else: print(""Heisei"")" p03544,s986150876,Accepted,"n = int(input()) l = [0] * (n+1) l[0] = 2 l[1] = 1 if n == 1: ans = l[1] else: for i in range(2, n+1): l[i] = l[i-1] + l[i-2] ans = l[-1] print(ans)" p03289,s617548557,Accepted,"import sys def input(): return sys.stdin.readline().rstrip() def main(): S = list(input()) isWA = False if S[0] != 'A': isWA = True if S[2:-1].count('C') != 1: isWA = True for s in S: if s == 'A' or s == 'C': continue if s.isupper(): isWA = True if isWA: print('WA') else: print('AC') if __name__ == '__main__': main() " p02994,s000280581,Accepted,"n,l=map(int,input().split()) ringo=[i+l-1 for i in range(1,n+1)] ringo.sort(key=lambda x:abs(x)) print(sum(ringo[1:]))" p03150,s902753920,Accepted,"s = input() n = len(s) interval = n - 7 flag = False start = 0 end = interval for i in range(n-interval): news = s[0:start] + s[end:] if news == 'keyence': print('YES') flag = True break start+=1 end+=1 if not flag: print('NO')" p02629,s987523942,Accepted,"import bisect N = int(input()) D = [0]*12 SD = [0]*12 tmp = 26 for i in range(1, 12): D[i] = tmp SD[i] = SD[i-1] + D[i] if SD[i] > 1000000000000001: break tmp *= 26 L = bisect.bisect_left(SD, N) alpha = 'abcdefghijklmnopqrstuvwxyz' ans = [] N -= SD[L-1] + 1 for i in range(L): ans.append(alpha[N % 26]) N //= 26 print("""".join(ans[::-1])) " p02900,s793883070,Wrong Answer,"from math import sqrt A, B = map(int, input().split()) rootA = round(sqrt(A)) rootB = round(sqrt(B)) PrimeFactorA = [] PrimeFactorB = [] for i in range(2, rootA+1): while A%i == 0: A //= i PrimeFactorA.append(i) PrimeFactorA = set(PrimeFactorA) for i in range(2, rootB+1): while B%i == 0: B //= i PrimeFactorB.append(i) PrimeFactorB = set(PrimeFactorB) count = 1 if PrimeFactorA and PrimeFactorB: for a in PrimeFactorA: if a in PrimeFactorB: count += 1 print(count)" p03331,s675252567,Wrong Answer,"n = int(input()) if n % 2: x = n - 2 y = n - x 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) else: x = n//2 result = 0 while(x > 0): result += x % 10 x = x // 10 print(result*2) " p03220,s816783910,Accepted,"N = int(input()) T, A = map(int, input().split()) H = list(map(int, input().split())) # 地点の平均気温を計算しListHに格納 for i in range(N): H[i] = T - (abs(H[i]) * 0.006) # 目的の平均気温との差をListHに格納 for k in range(N): H[k] = abs(H[k] - (A)) # 差が最も小さいもののリスト番号に1を足して出力 print((H.index(min(H)))+1)" p03041,s915031666,Accepted,"#126 a 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) " p02767,s244054252,Wrong Answer,"N = int(input()) X = [float(x) for x in input().split()] P = round(sum(X)/N) print(sum([(x-P)**2 for x in X]))" p03324,s111455214,Wrong Answer,"d,n = map(int,input().split()) print(n*(100**d)) " p03210,s958657522,Accepted,"import sys def input(): return sys.stdin.readline().rstrip() def main(): X = int(input()) if X in (3, 5, 7): print('YES') else: print('NO') if __name__ == '__main__': main() " p03041,s174510552,Accepted,"#!/usr/bin/env python3 # -*- coding: utf-8 -*- def main(): N, K = map(int, input().split()) S = list(input()) S[K - 1] = S[K - 1].lower() print(*S, sep='') if __name__ == ""__main__"": main() " p03059,s401506055,Accepted,"a,b,t=[int(x) for x in input().split()] ans=(t//a)*b print(ans)" p03799,s741163597,Accepted,"N,M=map(int,input().split()) n1=min(N,M//2) print(n1+(M-2*n1)//4) " p03013,s396442614,Accepted,"n, m = map(int, input().split()) broken = [0]*(n+1) for i in range(m): a = int(input()) broken[a] = 1 dp = [0]*(n+1) dp[0] = 1 mod = 1000000007 for i in range(1, n+1): if broken[i]: continue dp[i] = (dp[i-1] + dp[i-2]) % mod print(dp[n]) " p03672,s606153788,Accepted,"s = input() for i in range(1, len(s)): if (len(s) - i) % 2 == 0 and s[0:(len(s)-i)//2] == s[(len(s)-i)//2:-i]: print(len(s)-i) exit() " p03379,s159701842,Accepted,"n = int(input()) X = list(map(int, input().split())) X_sort = sorted(X) xm1 = X_sort[n//2-1] xm2 = X_sort[n//2] xm = (xm1+xm2)/2 for i in range(n): if X[i]c] d.sort(reverse=True) ans=0 while len(d)>0: h-=d.pop() ans+=1 if h<=0: print(ans) exit() f=(h+c-1)//c print(ans+f)" p02836,s591894405,Wrong Answer,"a=input() b=a c=b[::-1] d=0 for i in range(len(a)): if a[i]!=c[i]: d+=1 else: pass print(d) " p02792,s028824346,Accepted,"import itertools n = int(input()) XY = {xy:0 for xy in itertools.product(""0123456789"", repeat = 2)} for i in range(1, n + 1): x, y = str(i)[0], str(i)[-1] XY[(x, y)] += 1 answer = 0 for a in range(1, n + 1): x, y = str(a)[0], str(a)[-1] answer += XY[(y, x)] print(answer) " p03821,s717495123,Accepted,"n = int(input()) a, b = [0] * n, [0] * n for i in range(n): a[i], b[i] = map(int, input().split()) ans = 0 for i in range(n - 1, -1, -1): ans += (b[i] - (a[i] + ans) % b[i]) % b[i] print(ans)" p02622,s575372624,Wrong Answer,"s = [input() for i in range(2)] S = s[0] T = s[1] print(S) print(T) def count_diff2(s, t): cnt = 0 for c1,c2 in zip(s, t): if c1 != c2: cnt += 1 return cnt print(count_diff2(S, T))" p03210,s244291885,Accepted,"a = int(input()) if a == 3 or a == 5 or a == 7: print(""YES"") else: print(""NO"") " p02696,s281045846,Accepted,"a,b,n = map(int,input().split()) if(n= 0: A -= K elif B-(K-A)>=0: B -= (K-A) A = 0 else: A = 0 B = 0 print('{} {}'.format(A,B))" p03951,s722344488,Wrong Answer,"import sys sys.setrecursionlimit(10 ** 7) f_inf = float('inf') mod = 10 ** 9 + 7 def resolve(): n = int(input()) s = input() t = input() res = n for i in range(n): for j in range(n): if i + j < n: if s[i + j] != t[j]: break else: res = i print(res + n) if __name__ == '__main__': resolve() " p02552,s990791003,Accepted,"n = int(input()) if n == 1: print(0) elif n == 0: print(1) " p03910,s136266765,Accepted,"def main(): N = int(input()) ma = 0 tot = 0 while tot < N: ma += 1 tot += ma skip = tot - N ans = {x for x in range(1, ma + 1) if x != skip} print(*ans, sep='\n') if __name__ == '__main__': main() " p03785,s294956000,Accepted,"import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) n, c, k = map(int, readline().split()) t = sorted([int(readline()) for i in range(n)]) cnt = 0 ans = 1 time = t[0] + k for i in range(n): if cnt >= c or time < t[i]: ans += 1 cnt = 0 time = t[i] + k cnt += 1 print(ans) " p02952,s712363551,Accepted,"n = int(input()) l = len(str(n)) res = 0 for i in range(1, l + 1, 2): if i == l: res += n - 10**(l-1) + 1 else: res += (10**(i) - 1) - (10**(i-1)) + 1 print(res)" p02729,s580181348,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,M=MI() ans=(N*(N-1))//2+(M*(M-1))//2 print(ans) main() " p03627,s141120481,Accepted,"n = int(input()) a = sorted(list(map(int, input().split())), reverse=True) b = """" ans = [] for i in range(n): if b == """": b = a[i] elif b != a[i]: b = a[i] elif a[i] == b: ans.append(a[i]) b = """" if len(ans) == 2: break print(0 if len(ans) != 2 else ans[0] * ans[1])" p03799,s869098878,Wrong Answer,"import sys def input(): return sys.stdin.readline().strip() def resolve(): n,m=map(int, input().split()) cnt=0 if n<=2*m: cnt+=n m-=n*2 cnt+=m//4 else: cnt+=m//2 print(cnt) resolve()" p03000,s130218589,Accepted,"n,x=map(int,input().split()) L=[int(_) for _ in input().split()] S_L=[0] count=1 for i in range(n): S_L.append(S_L[-1]+L[i]) if S_L[-1]<=x: count+=1 else: print(count) break else:print(n+1)" p02657,s735869536,Wrong Answer,"a,b=map(float,input().split()) print(a*b//1) " p03862,s445492781,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: if A[i-1] > x: ans += A[i-1] - x A[i-1] = x ans += A[i] + A[i-1] - x A[i] = x - A[i-1] print(ans) " p03817,s061818609,Accepted,"x = int(input()) ans = (x//11)*2 ans += x%11>6 ans += x%11 > 0 print(ans)" p03796,s712139754,Wrong Answer,"n = int(input()) p = 1 for i in range(n): p *= i print(i % 10**9+7)" p03672,s187468113,Wrong Answer,"s = str(input()) s = s[:-1] count = 0 while len(s)>1 and (s[0] != s[-1] or s[0] == s[-1]): if s[0] != s[-1]: s = s[:-1] elif s[0] == s[-1]: s = s[1:-1] count += 2 print(count) " p02697,s939022463,Wrong Answer,"n,m=map(int,input().split()) l1,r2=1,n if m%2: r1=m else: r1=m+1 l2=r1+1 for i in range(m//2): print(l1,r1) print(l2,r2) l1+=1 l2+=1 r1-=1 r2-=1 if m%2: print(l2,r2)" p03150,s556711744,Accepted,"S = input() ans = ""NO"" for i in range(len(S)): for j in range(len(S)): if S[0:i] + S[i+j:len(S)] == ""keyence"": print(""YES"") exit() print(ans) " p03075,s150864386,Accepted,"a = int(input()) b = int(input()) c = int(input()) d = int(input()) e = int(input()) k = int(input()) if e - a > k: print("":("") else: print(""Yay!"") " p03681,s743788585,Wrong Answer,"N,M=map(int,input().split()) MOD=10**9+7 if N>=M: s=1 for i in range(2,N+1): s=s*i t=N-M+2 for j in range(N-M+3,N+1): t=t*j print((s*t)%MOD) else: s=1 for i in range(2,M+1): s=s*i t=M-N+2 for j in range(N-M+3,N+1): t=t*j print((s*t)%MOD)" p03665,s424916488,Accepted,"import math n, p = list(map(int, input().split("" ""))) a = list(map(int, input().split("" ""))) zero_count = 0 one_count = 0 for num in a: if num % 2 == 0: zero_count += 1 else: one_count += 1 coef = 2 ** zero_count ans = 0 for i in range(one_count + 1): if i % 2 != p: continue ans += math.factorial(one_count) // math.factorial(one_count - i) // math.factorial(i) print(ans * coef) " p02612,s719353435,Wrong Answer,"s = int(input()) print(1000 - s % 1000)" p02647,s060332478,Accepted,"N, K = map(int, input().split()) *A, = map(int, input().split()) for k in range(41): B = [0] * N for i, a in enumerate(A): l = max(0, i - a) r = min(N - 1, i + a) B[l] += 1 if r + 1 < N: B[r + 1] -= 1 for i in range(1, N): B[i] += B[i-1] A = B if k == K - 1: break print(*A)" p02678,s290216573,Accepted,"from collections import deque n, m = map(int, input().split()) graph = [[] for _ in range(n)] for _ in range(m): a, b = map(int, input().split()) graph[a - 1].append(b - 1) graph[b - 1].append(a - 1) ans = [-1] * (n - 1) q = deque() q.append(0) used = {0} while q: node = q.popleft() for next_node in graph[node]: if next_node in used: continue q.append(next_node) used.add(next_node) ans[next_node - 1] = node + 1 print('Yes') print(*ans, sep='\n')" p03457,s138929722,Accepted,"N = int(input()) T,X,Y =0,0,0 count = 0 for i in range(N): t,x,y = map(int,input().split()) if abs(t-T) >= abs((x+y)-(X+Y)) and t%2==(x+y)%2: count+=1 T,X,Y=t,x,y print('Yes' if count==N else 'No' ) " p03286,s249815213,Wrong Answer,"n = int(input()) ans = '' while n != 0: r = n % 2 print(r) if r < 0: r = r + 2 n = (n-r) / (-2) ans = ans + str(int(r)) ans = list(ans) print(ans) ans.reverse() print(''.join(ans))" p02572,s167214246,Accepted,"n = int(input()) A = [*map(int, input().split())] MOD = 10**9 + 7 ans = b = 0 for a in A: ans += a * b ans %= MOD b += a print(ans) " p02630,s086684542,Wrong Answer,"N = int(input()) num_list = list(map(int,input().split())) q = int(input()) num_list.sort() for i in range(q): query = list(map(int,input().split())) for j in range(len(num_list)): if num_list[j] == query[0]: num_list[j] = query[1] if num_list[j] > query[0]: break print(sum(num_list))" p02729,s210962395,Wrong Answer,"N, M = map(int, input().split()) print(N * (N-1) / 2 + M * (M-1) / 2)" p02843,s674769976,Wrong Answer,"def main(): x = int(input()) for i in range(x): if 0 <= x - 100 * i < 5 * i: print(1) exit() else: print(0) if __name__ == ""__main__"": main() " p03457,s026314968,Wrong Answer,"n = int(input()) now = [0, 0, 0] def ng(): print('No') exit() for i in range(n): t, x, y = map(int, input().split()) if t % 2 != (x + y) % 2: ng() if abs(x - now[1]) + abs(y - now[2]) > t - now[0]: ng() print('Yes')" p03433,s017473578,Accepted,"n = int(input()) a = int(input()) if n%500 <= a: print('Yes') else: print('No') " p03698,s096182845,Accepted,"S = list(input()) s = set(S) if len(s) == len(S): print(""yes"") else: print(""no"") " p03814,s232485150,Accepted,"s = input() for i in range(len(s)): if s[i] == 'A': break for j in range(len(s)-1,-1,-1): if s[j] == 'Z': break print(len(s[i:j+1]))" p04011,s474369389,Wrong Answer,"import collections import sys a=input() b=[] for i in a: b.append(i) b.sort() c=collections.Counter(b) c=list(c.values()) for i in range(len(c)): if int(c[i])%2==0: q=0 else: q=1 print('No') sys.exit() print('Yes') " p02627,s542602966,Accepted,"A = input() if A.isupper() == True: print(""A"") else: print(""a"")" p03250,s602363438,Accepted,"n_l = list(map(str, input().split())) n_l.sort(reverse=True) print(int(n_l[0] + n_l[1]) + int(n_l[-1])) " p02729,s959005930,Accepted,"n,k= list(map(int, input().split())) from math import factorial if n>1: a=factorial(n)//factorial(2)//factorial(n-2) else: a=0 if k>1: b=factorial(k)//factorial(2)//factorial(k-2) else: b=0 print(a+b) " p03262,s313905541,Wrong Answer,"N,X = map(int,input().split()) W = list(map(int,input().split())) + [X] W = sorted(W) dist = 10**18 print(W) if len(W) == 2: print(W[1]-W[0]) exit() for i in range(1,N+1): dist = min(dist, W[i]-W[i-1]) while (W[i]-W[i-1])%dist != 0: dist //= 2 if dist == 1: break print(dist)" p02743,s534775501,Accepted,"import math n,m,k = map(int,input().split()) if 4*n*m < (k-n-m)*(k-n-m) and k>n+m: print('Yes') else: print(""No"") " p02835,s373314083,Wrong Answer,"print('win' if sum(map(int, input().split())) < 21 else 'bust')" p02817,s559828950,Accepted,"s,t=input().split() print(t+s)" p02724,s919640264,Accepted,"import sys def main(): input = sys.stdin.buffer.readline x = int(input()) a, b = divmod(x, 500) c = b // 5 print(1000 * a + 5 * c) if __name__ == ""__main__"": main() " p03038,s189466999,Accepted,"n, m = map(int, input().split()) A = list(map(int, input().split())) BC = [list(map(int, input().split())) for _ in range(m)] A.sort() BC.sort(key=lambda k: -k[1]) stack = [] cnt = 0 for b, c in BC: for _ in range(b): stack.append(c) cnt += 1 if cnt > n: break for i in range(min(n, len(stack))): if A[i] < stack[i]: A[i] = stack[i] else: break print(sum(A))" p02606,s311937727,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)" p02994,s168764514,Accepted,"n, l = map(int, input().split()) x = 100 y = 100 for i in range(n): if abs(l+i) < x: x = abs(l+i) y = l+i print(l*n+sum(range(1, n+1))-n-y) " p02602,s484619994,Accepted,"from numpy import * N,K = map(int,input().split()) A = log(array(list(map(int,input().split())))) B = [sum(A[:K])] for n in range(N-K): B+=[B[-1]+A[n+K]-A[n]] if B[n] 1: amari = N % 26 L.append(amari) N = N // 26 ans = '' trans =['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(L)): ans += trans[L[i]-1] rans = '' for i in range(len(ans)-1,-1,-1): rans += ans[i] print(rans)" p03371,s985800102,Accepted,"a,b,c,x,y=map(int,input().split()) if x1: i+=1; c+=g%i<1 while g%i<1: g//=i print(c+(g>1))" p02595,s307587730,Accepted,"N,D = map(int,input().split()) DD = D*D ans = 0 for i in range(N): x,y = map(int,input().split()) if x*x + y*y <= DD: ans +=1 print(ans) " p02760,s379572187,Wrong Answer,"a = [0] * 3 for i in range(3): a[i] = list(map(int, input().split())) n = int(input()) b = set() for _ in range(n): b.add(int(input())) if ( set(a[0]) <= b or set(a[1]) <= b or set(a[2]) <= b or set(a[:][0]) <= b or set(a[:][1]) <= b or set(a[:][2]) <= b or {a[0][0], a[1][1], a[2][2]} <= b or {a[0][2], a[1][1], a[2][0]} <= b ): print(""Yes"") else: print(""No"") " p03861,s580466910,Accepted,"a, b, x = map(int, input().split()) print(b // x + 1 if a == 0 else b // x - (a - 1) // x) " p03163,s138756254,Accepted,"N, W = map(int, input().split()) A = list() for n in range(N): A.append(list(map(int, input().split()))) dp = [[0 for w in range(W+1)] for n in range(N+1)] for i in range(W+1): dp[0][i] = 0 for p in range(1, N+1): for q in range(W+1): dp[p][q] = dp[p-1][q] if (A[p-1][0] <= q): dp[p][q] = max(dp[p][q], dp[p-1][q - A[p-1][0]] + A[p-1][1]) # print(dp) print(dp[N][W])" p03161,s450328216,Accepted,"N,K=map(int,input().split()) h=list(map(int,input().split())) cost=[0,abs(h[1]-h[0])] for i in range(2,N): cand=10**10 for j in range(K): if j==i: break cand=min(cand,cost[i-j-1]+abs(h[i]-h[i-j-1])) cost.append(cand) print(cost[-1])" p03657,s756970930,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')" p02711,s990840771,Accepted,"N=(input()) x=N.count(""7"") if x>0: print(""Yes"") else: print(""No"") " p03061,s200581390,Accepted,"from fractions import gcd N=int(input()) A=list(map(int,input().split())) L=[0]*N R=[0]*N L[0]=A[0] R[0]=A[N-1] for n in range(1,N): L[n]=gcd(A[n],L[n-1]) R[n]=gcd(A[N-n-1],R[n-1]) ans=max(L[N-2],R[N-2]) for i in range(1,N-1): ans=max(ans,gcd(L[i-1],R[N-i-2])) print(ans)" p02700,s965585333,Wrong Answer,"A,B,C,D = map(int,input().split()) #print(A,B,C,D) while A > 0: C -= B A -= D if C <= 0: print(""Yes"") elif A <= 0: print(""No"") else: pass " p03457,s519091705,Accepted,"n = int(input()) s = [0, 0, 0] ans = 'Yes' for i in range(n): l = list(map(int, input().split())) diff_t = l[0] - s[0] diff_x = abs(s[1] - l[1]) diff_y = abs(s[2] - l[2]) s = [l[0], l[1], l[2]] if diff_x + diff_y > diff_t or (diff_t - diff_x - diff_y) % 2 != 0: ans = 'No' print(ans)" p03417,s582060103,Accepted,"n,m = map(int,input().split()) if (n == 1) and (m == 1): ans = 1 elif n == 1 and m != 1: ans = m-2 elif m == 1 and n != 1: ans = n-2 else: ans = (m-2)*(n-2) print(ans)" p03637,s783957611,Accepted,"N = input() L = list(map(int,input().split())) n=0 m=0 p=0 for a in range(int(N)): if L[a]%2 != 0: n+=1 elif L[a]%2 == 0 and L[a]%4 != 0: m+=1 else: p+=1 if int(N)%2==1 and (n>p+1 or p==0 and n==1): print(""No"") elif int(N)%2==0 and n>p: print(""No"") else: print(""Yes"") " p04029,s430959850,Wrong Answer,"n = int(input()) print(1/2 * n * (n+1))" p02548,s811244374,Accepted,"n = int(input()) ans = 0 for i in range(1,n): ans += ((n-1)//i) print(ans)" p02888,s292658646,Accepted,"import bisect N = int(input()) L = sorted(list(map(int, input().split()))) ans = 0 for i in range(N-1,1,-1): for j in range(i-1,0,-1): t = bisect.bisect(L, L[i]-L[j]) if j-t>0: ans+=j-t print (ans)" p02847,s260490829,Accepted,"day = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT'] s = input() print(7 - day.index(s))" p02900,s233947875,Accepted,"from math import gcd a, b = map(int, input().split()) x = gcd(a,b) cnt = 1 for i in range(2, int(x ** 0.5) + 1): if x == 1: break if x % i == 0: cnt += 1 while x % i == 0: x //= i else: if x != 1: cnt += 1 print(cnt)" p02755,s930537337,Accepted,"A, B = map(int, input().split()) for i in range(1, 1001): if A==int(i*8/100) and B==int(i*10/100): print(i) exit() print(-1) " p02880,s870493758,Wrong Answer,"n=int(input()) flag = False for i in range(1, 10): for j in range(1,10): if i*j==n: print(""Yes"") else: flag = True if flag: print(""No"")" p02712,s576904335,Accepted,"#!/usr/bin/env python3 n = int(input()) def e(k): m = n // k print return (m + 1) * m // 2 * k print(e(1) - e(3) - e(5) + e(15)) " p03359,s752840967,Accepted,"a, b = map(int, input().split()) if a <= b: print(a) else: print(a-1) " p03433,s064840168,Wrong Answer,"N = int(input()) A = int(input()) a = 0 for i in range(20): if N >= 500*(i+1): a = 500*(i+1) else: continue b = N - a if b <= A: print(""Yes"") else: print(""No"") print(b)" p02597,s976218065,Accepted,"_=input();*C,=input();print(len([''for _ in range(C.count('W'))if C and C.pop()=='R']))" p02664,s212342880,Accepted,"T = input() ans = T.replace('?', 'D') print(ans) " p03095,s413796181,Accepted,"from string import ascii_lowercase n = int(input()) S = input() mod = 10**9 + 7 s = 1 for c in ascii_lowercase: s *= S.count(c)+1 s %= mod print(s-1)" p02606,s631485858,Accepted,"L, R, d = map(int, input().split()) print(R//d - (L-1)//d)" p02760,s503703615,Accepted,"A=[] for i in range(3): a,b,c=map(int,input().split()) A+=[a,b,c] n=int(input()) T=[0]*9 for i in range(n): p=int(input()) if p in A: T[A.index(p)]=1 if [1,1,1] in [T[0:3],T[3:6],T[6:9],T[0:7:3],T[1:9:3],T[2:9:3],T[0:10:4],T[2:7:2]]: print(""Yes"") else: print(""No"")" p03012,s714676450,Accepted,"def resolve(): N = int(input()) W = list(map(int, input().split())) ans = sum(W) for i in range(N): tmp = abs(sum(W[:i + 1]) - sum(W[i + 1:])) # print(W[:i + 1], W[i + 1:]) ans = min(ans, tmp) print(ans) resolve()" p03243,s453148946,Wrong Answer,"n = int(input()) if n > int(str(n)[0]*3): print(str(int(str(n)[0])+1)*3) else: print(n)" p02973,s183940863,Accepted,"n = int(input()) import bisect dp = [-1]*(n+1) for i in range(n): v = int(input()) l = bisect.bisect_left(dp, v) if l==n+1: l -= 1 if dp[l]=0: cnt += 1 else: break print(cnt)" p03284,s217467317,Accepted,"n,k = map(int,input().split()) if n % k == 0: print(0) else: print(1) " p03723,s129334687,Accepted,"def solve(): A, B, C = map(int, input().split()) if A == B == C and A % 2 == 0: return -1 cnt = 0 while True: if A % 2 or B % 2 or C % 2: return cnt A, B, C = B // 2 + C // 2, A // 2 + C // 2, A // 2 + B // 2 cnt += 1 print(solve())" p02756,s220486452,Wrong Answer,"from collections import deque deq=deque() deq.append(input()) q=int(input()) x=True for i in range(q): a=input() if a[0]==""1"": x = not x elif a[2]==""1"": if x%2!=0: deq.appendleft(a[4]) else: deq.append(a[4]) else: if x%2!=0: deq.append(a[4]) else: deq.appendleft(a[4]) if x==True: c="""".join(deq) else: deq.reverse() c="""".join(deq) print(c) " p03239,s868558506,Accepted,"N, T = list(map(int,input().split())) L1 = [list(map(int,input().split())) for _ in range(N)] L2 = [] for i in L1: if i[1] <= T: L2.append(i) if len(L2) == 0: print('TLE') else: cost = [] for i in L2: cost.append(i[0]) print(min(cost)) " p03644,s317666570,Accepted,"n = int(input()) cnt = 0 mcnt = 0 ans = 1 temp = 0 for i in range(2, n + 1): temp = i while i%2 == 0: i //= 2 cnt += 1 if cnt > mcnt: mcnt = cnt ans = temp cnt = 0 print(ans)" p03803,s244625076,Accepted,"a,b = map(int, input().split()) if a == b: print(""Draw"") else: if a == 1: print(""Alice"") else: if b == 1: print(""Bob"") else: if a > b: print(""Alice"") else: print(""Bob"")" p03555,s909145479,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"") " p03061,s621612509,Wrong Answer,"import math N = int(input()) A = list(map(int,input().split())) dp_left=[0]*(N+1) dp_right=[0]*(N+1) for i in range(N):#左から累積GCD dp_left[i+1]=math.gcd(dp_left[i],A[i]) dp_right[N-i-1]=math.gcd(dp_right[N-i],A[N-1-i])#右から累積GCD print(dp_left) print(dp_right) ans = 0 for i in range(N): ans = max(ans,math.gcd(dp_left[i],dp_right[i+1])) print(ans)" p03705,s716896702,Accepted,"N,A,B = list(map(int, input().split())) print(max((N-2)*B-(N-2)*A+1,0))" p02594,s959139699,Accepted,"x = int(input()) if x >= 30: print('Yes') else: print('No')" p02989,s934625533,Accepted,"# C - Divide the Problems N = int(input()) d = list(map(int,input().split())) d.sort() print(d[N//2]-d[N//2-1])" p02583,s939650770,Wrong Answer,"import sys readline = sys.stdin.readline def solve(): N = int(readline()) L = list(map(int, readline().split())) if N <= 2: print(0) L.sort() ans = 0 for i in range(N): for j in range(i + 1, N): for k in range(j + 1, N): if len(set((L[i], L[j], L[k]))) == 3 and L[k] < L[i] + L[j]: ans += 1 print(ans) solve()" p03623,s013360689,Accepted,"x, a, b = map(int, input().split()) if abs(x-a) < abs(x-b): print('A') else: print('B')" p03095,s730454012,Accepted,"def resolve(): n = int(input()) x = input() dict = {} for i in range(len(x)): if x[i] in dict: dict[x[i]] += 1 else: dict[x[i]] = 1 dictvalue = list(dict.values()) ans = 1 for i in dictvalue: ans *= (i+1) ans %= 10**9+7 print(ans-1) resolve()" p03359,s050812713,Accepted,"a, b = map(int, input().split()) if a<=b: print(a) elif a>b: print(a-1)" p02717,s755804713,Accepted,"X,Y,Z = map(int, input().split()) print(Z,X,Y)" p03632,s680531833,Wrong Answer,"l = list(map(int,input().split())) if l[1] <= l[2]: print(0) else: ls = sorted(l) print(ls[2]-ls[1])" p03076,s957306594,Accepted,"dishes = [int(input()) for _ in range(5)] dishes = sorted(dishes, key=lambda x: 10 - int(str(x)[-1])) a = list() b = list() for d in dishes: if d % 10 == 0: a.append(d) else: b.append(d) if len(b) > 0: b = [d + 10 - d % 10 for d in b[:-1]] + [b[-1]] dishes = a + b print(sum(dishes)) " p02689,s168169044,Accepted," n,m = map(int,input().split()) l=list(map(int,input().split())) r=[True]*(n+1) r[0]=False d={} for i in range(m): a,b=map(int,input().split()) if l[a-1]>l[b-1]: r[b]=False if l[a-1]3199 else 'red')" p03095,s060704050,Accepted,"N = int(input()) S = str(input()) from collections import Counter freq = Counter(S) div = int(1e9 + 7) total = 1 for c in freq.keys(): #print(c, freq[c]) total = total * (freq[c] + 1) % div ans = total - 1 print(ans)" p02681,s820005204,Accepted,"s = input() t = input() n = len(t) if s == t[:n-1]: print('Yes') else: print('No')" p02731,s343642422,Accepted,"L = int(input()) print((L / 3) ** 3) " p03625,s871464175,Accepted,"from collections import Counter N = int(input()) lines = list(map(int, input().split())) l = Counter(lines) l = {k:v for k,v in l.items() if v>=2} if len(l.keys()) <= 1: print(0) else: anss = list(l.keys()) ma = max(anss) ma2 = sorted(anss)[-2] print(ma * ma2 if l[ma] < 4 else ma ** 2) " p02791,s955058995,Accepted,"N = int(input()) P = [int(x) for x in input().split()] m = P[0] ans = 0 for p in P: if p <= m: ans += 1 m = min(m, p) print(ans) " p03986,s069420362,Accepted,"X = input() Tnum = len(X) // 2 Snum = len(X) // 2 num = 0 ans = 0 for i in X: if i == 'T': num -= 1 Tnum -= 1 else: num += 1 Snum -= 1 if num < 0: ans += 1 num = 0 print(ans*2)" p02727,s906452857,Accepted,"import heapq 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() s = p[:X]+q[:Y] ans=sum(s) heapq.heapify(s) while r and s: if s[0]= x: print(ans) break check_num += 5 ans += 1 if check_num >= x: print(ans) break " p03221,s304891567,Accepted,"n,m=map(int,input().split()) li=[] city_counter = [1] * (10**5+2) ans=[] for i in range(m): p,y=map(int,input().split()) li.append((p,y,i)) li.sort(key=lambda x:x[1]) for i in range(m): tmp = str(li[i][0]).zfill(6) + str(city_counter[li[i][0]]).zfill(6) ans.append((tmp,li[i][2])) city_counter[li[i][0]] += 1 ans.sort(key=lambda x:x[1]) for i in range(m): print(ans[i][0]) " p03493,s229460159,Wrong Answer,"s = input() res = 0 for i in range(3): if s[i] == 1: res += 1 print(res)" p03645,s445847184,Accepted," n,m=map(int,input().split()) a1=set() an=set() for i in range(m): ai,bi=map(int,input().split()) if ai==1: a1.add(bi) elif bi==n: an.add(ai) if len(a1&an)==0: print(""IMPOSSIBLE"") else: print(""POSSIBLE"") " p03698,s653669626,Accepted,"S = list(input()) if len(set(S)) == len(S): print('yes') else: print('no') " p03061,s720658989,Accepted,"from fractions import gcd N = int(input()) A=list(map(int,input().split())) L=[0]*N R=[0]*N M=[0]*N L[0]=A[0] R[-1]=A[-1] for i in range(1,N): L[i]=gcd(L[i-1],A[i]) R[-i-1]=gcd(R[-i],A[-i-1]) for i in range(N): if i == 0: M[i]=R[i+1] elif i == N-1: M[i]=L[i-1] else: M[i]=gcd(L[i-1],R[i+1]) print(max(M))" p03126,s586449790,Accepted,"from collections import defaultdict N, M = map(int, input().split()) d = defaultdict(int) for i in range(N): A = list(map(int, input().split())) for i in range(1, A[0]+1): d[A[i]] += 1 ans = 0 for v in d.values(): if v == N: ans += 1 print(ans)" p02792,s289368577,Accepted,"c = [[0]*10 for i in range(10)] for i in range(1,int(input())+1): i = str(i) c[int(i[0])][int(i[-1])] += 1 ans = 0 for i in range(10): for j in range(10): ans += c[i][j]*c[j][i] print(ans)" p03067,s147667635,Accepted,"#!/usr/bin/env python3 a, b, c = [int(x) for x in input().split()] print(""Yes"" if a <= c <= b or b <= c <= a else ""No"") " p02813,s655229070,Accepted,"import itertools import sys def input(): return sys.stdin.readline().strip() def resolve(): n=int(input()) a=tuple(map(int, input().split())) b=tuple(map(int,input().split())) l=list(itertools.permutations(range(1,n+1))) aa=l.index(a) bb=l.index(b) print(abs(aa-bb)) resolve()" p03487,s194111151,Accepted,"import collections N = int(input()) sequence = list(map(int, input().split())) CTR = collections.Counter(sequence).most_common() ans = 0 for i in range(len(CTR)): cnt = CTR[i][1] obj = int(CTR[i][0]) if (obj > cnt): ans += cnt else: ans += cnt - obj print(ans)" p03804,s268519548,Accepted,"import sys n, m = map(int, input().split()) a = [list(input()) for i in range(n)] b = [list(input()) for i in range(m)] for i in range(n-m+1): for j in range(n-m+1): flag = False tmp = [a[f][j:j+m] for f in range(i, i+m)] for k in range(m): for l in range(m): if tmp[k][l] != b[k][l]: flag = True break if flag: break if flag: continue print(""Yes"") sys.exit() print(""No"")" p03386,s842259089,Wrong Answer,"A, B, K = map(int, input().split()) l = range(A, B+1) a = [n for n in l[:K]] b = [n for n in l[-K:]] for n in set(a + b): print(n) " p03814,s824270412,Accepted,"s = input() k = s[::-1] for i in range(len(s)): if s[i]=='Z': z_num = i if k[i]=='A': a_num = i ans = a_num + z_num + 2 - len(s) print(ans) " p02959,s131284678,Accepted,"n = int(input()) AL = list(map(int, input().split())) BL = list(map(int, input().split())) ans = 0 for i in range(n): if BL[i] <= AL[i]: ans += BL[i] elif BL[i] > AL[i] and BL[i] <= AL[i]+AL[i+1]: ans += BL[i] AL[i+1] = AL[i+1] - BL[i] + AL[i] else: ans += AL[i]+AL[i+1] AL[i+1] = 0 print(ans) " p03030,s292129083,Accepted,"N = int(input()) SP = [[0]*3 for i in range(N)] for i in range(N): S,P = map(str,input().split()) SP[i][0] = S SP[i][1] = int(P)*-1 SP[i][2] = i+1 SP = sorted(SP) for i in range(N): print(SP[i][2])" p03163,s965950365,Wrong Answer,"n,wmax = map(int,input().split()) dp = [[0 for ww in range(wmax+1)] for i in range(n+1)] w,v = [],[] for i in range(n): ww,vv = map(int,input().split()) w.append(ww) v.append(vv) print(dp[0][0]+2) for i in range(n): for ww in range(wmax+1): dp[i+1][ww] = dp[i][ww] if w[i]>ww else max(dp[i][ww], dp[i][ww-w[i]]+v[i]) ans = dp[n][wmax] print(ans) " p02633,s914522102,Wrong Answer,"degree = int(input()) max_num = 360 if(1 <= degree <= 179): answer = max_num / degree print(answer) else: print('out of range')" p03293,s399599245,Accepted,"import sys sys.setrecursionlimit(10**6) s=input() t=input() for i in range(len(s)): u="""" for j in range(len(s)): u+=s[j-i] # print(u) if(u==t): print(""Yes"") exit() print(""No"") #print(s[0]) #print(t[0]) " p02813,s562805356,Accepted,"import itertools n = int(input()) p = tuple(map(int, input().split())) q = tuple(map(int, input().split())) if p == q: print(0) exit() nums = [i for i in range(1,n+1)] a = [0,0] now = 0 for k,i in enumerate(itertools.permutations(nums)): if i == p or i == q: a[now] = k now += 1 print(abs(a[1]-a[0]))" p02947,s798807499,Wrong Answer," n = int(input()) import collections chk = collections.deque([]) for i in range(n): s = input() s = sorted(s) chk.append(''.join(s)) #chk = list(chk) c = collections.Counter(chk) c = dict(c) ans = 0 for i in c.values(): if i == 1: break else: ans += i*(i-1)//2 print(ans) " p03455,s821788977,Accepted,"a, b = map(int, input().split()) if a*b % 2 == 0: print(""Even"") else: print(""Odd"")" p03799,s568172860,Accepted,"n,M=map(int,input().split()) l,r,ans=0,10**18,-1 while(l<=r): m=(l+r)//2 ns=max(0,m-n) uc=(2*ns+2*m) if(uc<=M): ans=m l=m+1 else: r=m-1 print(ans) " p03264,s093766407,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()) k = i() ans = 0 ls = list(int(k) for k in range(1,k+1)) for i in range(k): ans += ls[i]//2 print(ans)" p03814,s384855914,Accepted,"s=input() print((len(s)-s[::-1].index('Z'))-s.index('A'))" p03220,s214551128,Accepted,"n = int(input()) t, a = map(int, input().split()) h = list(map(int, input().split())) tmp = 10**7 for i in range(n): c = abs(a-(t-h[i]*0.006)) if c < tmp: tmp = c ans = i+1 print(ans)" p03611,s288536741,Accepted,"n=int(input()) x=list(map(int,input().split())) d={} for a in x: if a in d: d[a]+=1 else: d[a]=1 if a+1 in d: d[a+1]+=1 else: d[a+1]=1 if a-1 in d: d[a-1]+=1 else: d[a-1]=1 print(max(d.values())) " p02727,s637626573,Accepted,"X, Y, A, B, C = map(int, input().split()) p_A = list(map(int, input().split())) q_B = list(map(int, input().split())) r_C = list(map(int, input().split())) p_A2 = sorted(p_A, reverse=True) q_B2 = sorted(q_B, reverse=True) r_C2 = sorted(r_C, reverse=True) ans = [] ans += p_A2[:X] ans += q_B2[:Y] ans = sorted(ans) cnt = 0 for i in range(len(ans)): if cnt <= C-1: if ans[i] < r_C2[cnt]: ans[i] = r_C2[cnt] cnt += 1 print(sum(ans))" p02663,s641476057,Accepted,"H1, M1, H2, M2, K = map(int, input().split()) Stayup_Time = (H2 * 60 + M2) - (H1 * 60 + M1) Notstudy_Time = Stayup_Time - K print(Notstudy_Time)" p03103,s993547402,Accepted,"N,M = map(int,input().split()) AB = [list(map(int,input().split())) for _ in range(N)] AB.sort() money = 0 for a, b in AB: if M > b: money += a * b M -= b else: money += a * M break print(money)" p03137,s548653508,Wrong Answer,"n, m = map(int, input().split()) x = sorted(list(map(int, input().split()))) gaps = [x[i] - x[i-1] for i in range(1, len(x))] if n == 1: print(sum(gaps) - 1) else: print(sum(sorted(gaps)[:-n+1])) " p02613,s168206953,Accepted,"N = int(input()) dic = {""AC"":0,""WA"":0,""TLE"":0,""RE"":0} for i in range(N): s = input() dic[s] += 1 for k, v in dic.items(): print(k+"" x ""+str(v))" p03486,s605148419,Accepted,"s = list(input()) t = list(input()) s.sort() t.sort(reverse=True) sa = """".join(s) ta = """".join(t) ans = ""No"" l = [sa, ta] l.sort() if l[1] == ta: ans = ""Yes"" if l[0] == l[1]: ans = ""No"" print(ans)" p02699,s068525618,Accepted,"S,W = input().split() if int(W) >= int(S): print(""unsafe"") else: print(""safe"")" p02765,s376527376,Accepted,"n,r=map(int,input().split()) print(r if n>=10 else r+100*(10-n))" p03448,s403325143,Wrong Answer,"numof500 = int(input()) numof100 = int(input()) numof50 = int(input()) moneyneeded = int(input()) counter = 0 for i in range(numof500): for j in range(numof100): for k in range(numof50): if 500 * i + 100 * j + 50 * k == moneyneeded: counter += 1 print(counter)" p02571,s258250679,Accepted,"def main(): S = str(input()) T = str(input()) counter = 0 max_match = 0 if T in S: print(0) else: for i in range(len(T), len(S)+1): counter = 0 for j in range(len(T)): if S[i-len(T)+j] == T[j]: counter += 1 if max_match < counter: max_match = counter print(len(T)-max_match) main() " p03774,s134558035,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)] for i in range(N): check = 0 point = abs(A[i][0]-C[0][0])+abs(A[i][1]-C[0][1]) change = point for j in range(1,M): point = min(point,abs(A[i][0]-C[j][0])+abs(A[i][1]-C[j][1])) if point != change: check = j change = point print(check+1) " p02801,s029466525,Wrong Answer,"str = input() print(""'"" + str + ""'の次は'"" + chr(ord(str) + 1) + ""'です。"")" p04030,s914653155,Wrong Answer,"arr = input() if not 'B' in arr: print(arr) else: arr = ''.join(reversed(arr)) print(arr[:arr.index('B')])" p03862,s085350247,Accepted,"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] >x: cnt += a[i] + a[i+1] - x a[i+1]=x-a[i] print(cnt) " p02546,s822627453,Accepted,"S = str(input()) A = ""es"" B = ""s"" if S[-1] == B: print(S+A) else: print(S+B)" p03127,s753239161,Accepted,"from heapq import heappop,heappush N = int(input()) A = list(map(lambda x: -1*int(x),input().split())) now = -1 * heappop(A) while(A): next = -1 * heappop(A) if now % next != 0: heappush(A,-1*(now%next)) now = next print(now)" p03665,s888106320,Accepted,"N,P = map(int,input().split()) A = list(map(int,input().split())) ans = [1,0] for a in A: if a%2: ans[1],ans[0] = ans[1] + ans[0], ans[1] + ans[0] else: ans[0] = ans[0]*2 ans[1] = ans[1]*2 print(ans[P])" p02785,s852678604,Accepted,"N,K=map(int,input().split()) H=list(map(int, input().split())) if N<=K: print(""0"") else: H.sort() count=sum(H[0:N-K]) print(count)" p02995,s061190062,Wrong Answer,"import math a,b,c,d=map(int,input().split()) lcm_cd=c*d/math.gcd(c,d) c_times=b//c-(a-1)//c d_times=b//d-(a-1)//d cd_times=b//lcm_cd-(a-1)//lcm_cd print(int(b-a+1-c_times-d_times+cd_times))" p03379,s496919081,Accepted,"m=int(input())//2-1 x=list(map(int,input().split())) l,r=sorted(x)[m:m+2] for i in x: print([l,r][i= 10 * B and item < 10 * (B + 1): res = item print(res)" p03486,s318472457,Accepted,"s = list(input()) t = list(input()) s.sort() t.sort() t = t[::-1] if ''.join(s) < ''.join(t): print('Yes') else: print('No') " p03557,s649844629,Accepted,"import bisect N =int(input()) lisA =list(map(int,input().split())) lisB = list(map(int,input().split())) lisC = list(map(int,input().split())) lisA.sort() lisB.sort() lisC.sort() cnt = 0 for b in lisB: cnt += bisect.bisect_left(lisA,b)*(N-bisect.bisect_right(lisC,b)) print(cnt)" p02820,s893070317,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[K+i]==T[i]: T[K+i]="""" ans=T.count(""r"")*P+T.count(""s"")*R+T.count(""p"")*S print(ans)" p02713,s626057253,Accepted,"from math import gcd def solve(): K = int(input()) rangeK = range(1, K+1) ans = 0 for a in rangeK: for b in rangeK: for c in rangeK: ans += gcd(gcd(a, b), c) print(ans) if __name__ == ""__main__"": solve() " p04045,s193705694,Accepted,"from itertools import product N, K = map(int, input().split()) A = [int(i) for i in input().split()] se = set(range(10)) for a in A: se ^= set([a]) def check(str_num): for x in str_num: if not int(x) in se: return False return True while True: if check(str(N)): break N += 1 print(N) " p03471,s008162052,Accepted,"N, Y = map(int, input().split()) for i in range(N+1): for j in range(N+1): k = N - i - j if k < 0: break if 10000 * i + 5000 * j + 1000 * k == Y: print(i, j, k) exit() print(-1, -1, -1) " p03351,s871184441,Accepted,"a,b,c,d = [int(x) for x in input().split()] if (abs(a-b) <= d and abs(b-c) <= d) or abs(a-c) <= d: print(""Yes"") else: print(""No"")" p02641,s461718728,Accepted,"x,n=map(int,input().split()) if n==0: print(x) else: p=list(map(int,input().split())) min=1000000000000000 ans=0 for i in range(102): if i not in p and abs(x-i) < min: min = abs(x-i) ans = i print(ans) " p04030,s331995022,Accepted,"s = input() a = """" for S in s: if S == 'B': if a: a = a[:-1] else: continue else: a += S print(a) " p03481,s103062016,Accepted,"x,y=map(int,input().split()) x,y=1,y//x cnt=0 while x<=y: x*=2 cnt+=1 print(cnt)" p03309,s700784914,Accepted,"n=int(input()) lists=list(map(int,input().split())) uselists=[] for _ in range(n): uselists.append(lists[_]-_-1) uselist=sorted(uselists) if n%2==0: num1=int(n/2-1) num2=int(n/2) numbers=min(uselist[num1],uselist[num2]) if n%2!=0: num1=int((n-1)/2) numbers=uselist[num1] ans=0 for x in range(n): ans+=abs(uselist[x]-numbers) print(ans) " p02935,s649533523,Accepted,"n = int(input()) v = list(map(int, input().split())) v.sort() tmp = v[0] for i in range(n-1): tmp = (tmp+v[i+1]) / 2 print(tmp)" p03221,s348507679,Wrong Answer,"from bisect import bisect_left import heapq def solve(): N,M = map(int, input().split()) cities_in_prefecture = [[] for _ in range(N)] city_ids = [] for _ in range(M): P,Y = map(int, input().split()) x = bisect_left(cities_in_prefecture[P-1], Y) heapq.heappush(cities_in_prefecture[P-1], Y) print('{0:06d}{1:06d}'.format(P, x+1), flush=True) solve()" p02910,s157998077,Wrong Answer,"S = list(input()) for i in range(0,len(S),2): if S[i] == 'L': print('No') exit() for j in range(1,len(S),2): if S[j] == 'R': print('NO') exit() print('Yes')" p02600,s855700442,Wrong Answer,"x = int(input()) if 400 <= x < 599: print(8) elif 600 <= x < 799: print(7) elif 800 <= x < 999: print(6) elif 100 <= x < 1199: print(5) elif 1200 <= x < 1399: print(4) elif 1400 <= x < 1599: print(3) elif 1600 <= x < 1799: print(2) elif 1800 <= x < 1999: print(1) " p03836,s950186899,Wrong Answer,"import sys input = sys.stdin.readline sx,sy,tx,ty=map(int,input().split()) ans="""" for i in range(ty-sy): ans+=""U"" for i in range(tx-sy): ans+=""R"" for i in range(ty-sy): ans+=""D"" for i in range(tx-sy): ans+=""L"" ans+=""L"" for i in range(ty-sy+1): ans+=""U"" for i in range(tx-sy+1): ans+=""R"" ans+=""DR"" for i in range(ty-sy+1): ans+=""D"" for i in range(tx-sy+1): ans+=""L"" ans+=""U"" print(ans) " p02854,s414412699,Accepted,"# coding: utf-8 def main(): _ = int(input()) A = list(map(int, input().split())) ans = 0 tmp = 0 total = sum(A) for a in A: tmp += a if tmp >= total // 2: ans = min(2 * tmp - total, total - 2 * (tmp - a)) break print(ans) if __name__ == ""__main__"": main() " p02918,s866604754,Accepted,"n,k=map(int,input().split()) s=input() happy=0 unhappy=0 for i in range(1,n): if s[i]==s[i-1]: happy+=1 else: unhappy+=1 for i in range(k): if unhappy==1: unhappy-=1 happy+=1 break unhappy-=2 happy+=2 print(min(happy,n-1))" p02748,s357166506,Wrong Answer,"A,B,M = map(int,input().split()) a = list(map(int,input().split())) b = list(map(int,input().split())) c = [[0 for _ in range(B)] for _ in range(A)] for _ in range(M): x, y, cp = map(int,input().split()) c[x-1][y-1] = cp oldp = 10**20 for an in range(A): for bn in range(B): if c[an][bn] == 0: continue p = a[an]+b[bn]-c[an][bn] if oldp > p: oldp = p p = min(a)+min(b) print(min(oldp,p))" p03438,s075584107,Accepted,"N = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) cnt = 0 for i, j in zip(a, b): if i < j: cnt += (j - i) // 2 + (j - i) % 2 sa = sum(b) - sum(a) if cnt <= sa: print(""Yes"") else: print(""No"") " p02731,s178189109,Accepted,"p = int(input()) print((p/3)**3) " p02862,s627404035,Accepted,"def framod(x,p=10**9+7): a=1 for i in range(1,x+1): a = (a*i)%p return a ############################################# X,Y=map(int,input().split()) p=10**9+7 if (X+Y)%3!=0: print(0) else: a = (2*X-Y)//3 b = (2*Y-X)//3 t = a+b if a<0 or b<0: print(0) else: S=framod(t) T=pow(framod(a),p-2,p) U=pow(framod(b),p-2,p) print(((S*T)%p)*U%p)" p02681,s094810041,Accepted,"S = input() T = input() if(S==T[:len(S)]): print(""Yes"") else: print(""No"")" p03632,s199577652,Accepted,"A, B, C, D = map(int, input().split()) if A= x and tot[0] < cost: cost = tot[0] print(cost) " p02756,s307693154,Accepted,"s = input() q = int(input()) x = 1 f, b = '', '' for i in range(q): a = input().split() if a[0] == '1': x = -x elif (1.5-int(a[1]))*x > 0: f = a[2] + f else: b = b + a[2] s = f + s + b if x == -1: s = s[::-1] print(s)" p02771,s210234195,Accepted,"A,B,C = map(int,input().split("" "")) if A == B and A != C and B!=C: print(""Yes"") elif A== C and A != B and B!=C: print(""Yes"") elif B== C and A != B and A!=C: print(""Yes"") else: print(""No"")" p03645,s310716116,Wrong Answer,"n,m=map(int,input().split()) candidate = [] for i in range(m): a,b=map(int,input().split()) if a==1: candidate.append(b) if b==n: if a in candidate: print('POSSIBLE') exit() print('IMPOSSIBLE') " p02780,s741285005,Wrong Answer,"n,k=map(int,input().split()) P=list(map(int,input().split())) dp=[0]*n ans=0 for i in range(n): dp[i]=((1/2)*P[i]*(P[i]+1)) / P[i] if i>k: ans=max(ans,sum(dp[i-k:i])) print(ans)" p02584,s394437603,Wrong Answer,"import numpy e=input().split() for i in range(len(e)): e[i]=int(e[i]) x=e[0] k=e[1] d=e[2] t=k if k>1000: if k%2==0: t=1000 else: t=1001 kou=numpy.gcd(x,d) x=int(x/kou) d=int(d/kou) if d>100 and d%2==0: d=100 if d>100 and d%2==1: d=1001 for i in range(t): if abs(x+d)= x else 'NO') if __name__ == '__main__': main() " p03487,s938074522,Accepted,"from collections import Counter N = int(input()) A = Counter(list(map(int, input().split()))) S = 0 for k, v in A.items(): if kv: S += v print(S)" p03479,s911267129,Accepted,"X,Y=map(int,input().split()) ans = 0 num = X while num <= Y: num *= 2 ans += 1 print(ans)" p02675,s718692080,Accepted,"a=input() n=len(a) if a[n-1]=='2'or a[n-1]=='4'or a[n-1]=='5'or a[n-1]=='7'or a[n-1]=='9': print(""hon"") elif a[n-1]=='0'or a[n-1]=='1'or a[n-1]=='6'or a[n-1]=='8': print(""pon"") else: print(""bon"")" p03449,s331777498,Wrong Answer,"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()) A = [int(x) for x in readline().split()] B = [int(x) for x in readline().split()] Acum = list(itertools.accumulate(A)) Bcum = list(itertools.accumulate(B)) ans = 0 for i in range(N): if i - 1 > 0: ans = max(ans, Acum[i] + Bcum[-1] - Bcum[i - 1]) else: ans = max(ans, Acum[i] + Bcum[-1]) print(ans) " p02802,s983933446,Wrong Answer,"N, M = map(int, input().split()) AC = set() WA = set() for i in range(M): p, S = input().split() p = int(p) - 1 S = S == 'AC' if S: AC.add(p) else: WA.add(p) print(len(AC), len(AC & WA)) " p03479,s695943080,Wrong Answer,"import math x,y=map(int,input().split()) print(math.ceil(math.log2(y/x)))" p03073,s749991180,Accepted,"S = list(input()) ans = 0 for i in range(len(S)-1): if S[i] == S[i+1]: ans += 1 if S[i+1] == ""1"": S[i+1] = ""0"" else: S[i+1] = ""1"" print(ans) " p02646,s923183588,Accepted,"a,v = map(int,input().split()) b,w = map(int,input().split()) t = int(input()) if abs(a-b) <= (v-w)*t: print('YES') else: print('NO')" p03011,s123621045,Accepted,"A = sorted(list(map(int, input().split()))) print(A[0]+A[1])" p02727,s134031393,Accepted,"X, Y, A, B, C = [int(x) for x in input().split()] p = sorted([int(x) for x in input().split()], reverse=True)[:X] q = sorted([int(x) for x in input().split()], reverse=True)[:Y] r = sorted([int(x) for x in input().split()], reverse=True)[:X + Y] s = sorted(p + q + r, reverse=True) ans = sum(s[:X + Y]) print(ans)" p03252,s834877337,Accepted,"S, T = input(), input() ma, ima = {}, {} ok = True for i in range(len(S)): s, t = S[i], T[i] if s in ma and ma[s] != t: ok = False if t in ima and ima[t] != s: ok = False ma[s] = t ima[t] = s if ok: print(""Yes"") else: print(""No"")" p02600,s520301566,Accepted,"X = int(input()) a = X//200 print(10-a)" p02833,s020767965,Wrong Answer,"N = int(input()) print(N//10+N//50)" p02832,s438736810,Accepted,"N=int(input()) A=list(map(int,input().split())) x=1 for a in A: if a==x: x+=1 else: pass if x==1: print(-1) else: print(N-x+1)" p03493,s738382554,Wrong Answer,"a = int(input()) ans = a%10 + int(a/10)%10 + int(int(a/10))%10 print(ans)" p03493,s659001726,Accepted,"s = input() cnt = 0 for i in s: if i == '1': cnt += 1 print(cnt) " p03043,s894071666,Accepted,"n,k = map(int,input().split()) prob = 0 point = 0 for cube in range(1,n+1): if cube <= k-1: point = cube t = 0 while True: point = point*2 t += 1 if point >= k: break prob += 1/n * ((1/2)**t) else: prob += 1/n print(prob)" p03017,s033622244,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') " p03555,s391916941,Accepted,"x = input() y = input() print('YES' if x==y[::-1] else 'NO') " p02641,s161847676,Accepted,"def main(): X, N = map(int, input().split()) P = set(list(map(int, input().split()))) d, v = X, 0 for i in range(102): if i in P: continue if abs(i - X) < d: d = abs(i - X) v = i return v print(main()) " p02789,s955583800,Accepted,"[n,m] = [int(x) for x in input().split()] if n == m: print('Yes') else: print('No')" p04020,s174354671,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) " p02714,s080559380,Accepted,"from collections import Counter n = int(input()) s = input() try: x, y, z = Counter(s).values() print(x * y * z - sum(s[i] != s[(i + j) // 2] != s[j] != s[i] for i in range(n) for j in range(i + 2, n, 2))) except ValueError: print(0) " p03862,s069716901,Accepted,"def boxes(): N, x = input().split() N, x = int(N), int(x) arr = [int(a) for a in input().split()] total = 0 for i in range(1, N): a, b = arr[i-1], arr[i] extra = a + b - x if extra > 0: total += extra if b >= extra: arr[i] -= extra else: arr[i] = 0 print(total) boxes()" p02939,s940186648,Accepted,"#!/usr/bin/env python3 S = list(input()) A = [S[0]] prev = """" for x in S[1:]: if prev != """": A.append(prev+x) prev = """" elif A[-1] == x: prev = x else: A.append(x) print(len(A)) " p03795,s857363356,Accepted,"N = int(input()) print(N*800-(N//15)*200) " p02951,s805248141,Accepted,"a,b,c=map(int,input().split()) print(max(0,c-a+b))" p02952,s311841107,Accepted,"N=int(input()) if N<10: print(N) exit() if N<100: print(9) exit() if N<1000: print(9+N-100+1) exit() if N<10000: print(909) exit() if N<100000: print(909+N-10000+1) exit() if N==100000: print(90909) exit()" p03145,s936275095,Accepted,"AB, BC, CA = [int(i) for i in input().split()] S = (AB * BC) // 2 print(S)" p02911,s658918589,Accepted,"def resolve(): n, k, q = map(int, input().split()) points = [k] * n for _ in range(q): temp = int(input()) points[temp - 1] += 1 points = map(lambda x: x - q, points) for i in points: if i <= 0: print('No') continue print('Yes') resolve()" p03377,s481556641,Accepted,"a, b, x = map(int, input().split()) if a<= x <= a+b: print(""YES"") else: print(""NO"")" p02699,s160024948,Accepted,"S, W = map(int, input().split()) if S <= W: print(""unsafe"") else: print(""safe"") " p02854,s292785356,Accepted,"n = int(input()) a = list(map(int,input().split())) hidariwa = sum(a) migiwa = 0 answer = hidariwa for i in range(n): hidariwa -= a[i] migiwa +=a[i] answer = min(abs(hidariwa-migiwa),answer) print(answer)" p02729,s798876722,Wrong Answer,"N, M = map(int, (input().split())) ans = N * (N - 1) / 2 + M * (M - 1) / 2 print(ans)" p02947,s056261769,Accepted,"import collections N = int(input()) s = ["""".join(sorted(input())) for i in range(N)] ans = 0 cnt = collections.Counter(s) for i in cnt.values(): if i > 1: ans += i*(i-1)//2 print(ans)" p03481,s838712560,Accepted,"x,y=map(int,input().split()) num=x ans=1 while num<=y: num=num*2 if (num<=y): ans+=1 print(ans)" p03796,s723558926,Accepted,"import sys def input(): return sys.stdin.readline().strip() def mapint(): return map(int, input().split()) sys.setrecursionlimit(10**9) N = int(input()) mod = 10**9+7 ans = 1 for i in range(1, N+1): ans *= i ans %= mod print(ans)" p03745,s265549429,Accepted,"N = int(input()) A = list(map(int,input().split())) cnt = 0 mode = 0 for i in range(len(A)): if i == 0: continue if (A[i] - A[i-1] >= 0 and mode >=0) or (A[i] - A[i-1] <= 0 and mode <= 0): if A[i] - A[i-1] > 0: mode = 1 if A[i] - A[i-1] < 0: mode = -1 else: mode = 0 cnt += 1 print(cnt+1)" p02684,s376035141,Accepted,"n, k = map(int, input().split()) A = list(map(lambda x: int(x)-1, input().split())) history = [-1]*n cur = 0 for i in range(n): if history[cur] != -1: init_cnt = history[cur] loop_cnt = i - history[cur] break history[cur] = i cur = A[cur] loop = k if k <= init_cnt else init_cnt+((k-init_cnt) % loop_cnt) print(history.index(loop)+1)" p02972,s774932519,Wrong Answer,"#d n = int(input()) a = list(map(int, input().split())) ans = [0]*len(a) for i in range(len(a),0,-1): if sum(ans[i-1::i])%2 != a[i-1]: ans[i-1] = 1 print(sum(ans)) if sum(ans) > 0: ans=[str(a) for a in ans] ans="" "".join(ans) print(ans)" p02784,s018454891,Wrong Answer,"h,n = map(int, input().split()) a = list(map(int, input().split())) a.sort(reverse=True) if len(a) >=2: print(""Yes"") if a[0] + a[1] >= h else print(""No"") else: print(""Yes"") if a[0] >= h else print(""No"")" p02833,s953727167,Wrong Answer,"n = int(input()) ans = 0 if n % 2 == 0: ans = n // 10 n = n // 10 while n // 5 > 0: ans += n // 5 n = n // 5 else: if (n // 5) % 2 == 0: ans = n // 10 n = n // 10 else: ans = n // 10 + 1 n = n // 10 + 1 while n // 5 > 0: n = n // 5 ans += n print(ans)" p03779,s390600233,Accepted,"x= int(input()) if x==1: print(1) exit(0) cnt=1 iterate=2 while cnt= k: m -= k k = 0 else: m = 0 k -= m m *= 2 if s[0] == 'L': m += 1 if s[-1] == 'R': m += 1 m = max(m-k, 0) print(n-m)" p02621,s267457278,Accepted,"a = int(input()) print(int(a**3+a**2+a))" p02797,s121134699,Accepted,"def main(): n, k, s = map(int, input().split()) if k == 0: if s != 10**9: ans = [10**9]*n else: ans = [1]*n else: if s == 10**9: ans = ([s]*k)+([1]*(n-k)) else: ans = [s]*(k)+[10**9]*(n-k) print(*ans) main() " p02910,s183442582,Accepted,"s=input() c=0 for i in range(len(s)): if i%2==0: if s[i] not in ""RUD"": c+=1 break else: if s[i] not in ""LUD"": c+=1 break print(""Yes""if c==0 else""No"")" p03407,s865179265,Wrong Answer,"N,X,Y=open(0).read().split() N=int(N) X=int(X) Y=int(Y) goukei=N+X*2 if goukei>=Y: print(""Yes"") else: print(""No"")" p04020,s691654136,Wrong Answer,"n=int(input()) a=[int(input()) for i in range(n)] ans=0 for i in range(n): ans+=a[i]//2 a[i]=a[i]%2 if n>=2: for i in range(n-1): if a[i]==1 and a[i+1]==1: ans+=1 a[i]=0 a[i+1]=0 print(ans)" p02676,s774569941,Accepted,"K = int(input()) S = input() if len(S) <= K: print(S) else: print(S[:K] + '...') " p02753,s494610706,Accepted,"s = input() if (s == 'AAA') | (s == 'BBB'): print('No') else: print('Yes')" p03711,s640425698,Wrong Answer,"# A - Grouping a=['1','3','5','7','8','10','12'] b=['4','6','9','11'] x,y=list(map(int,input().split())) if x in a and y in a: print(""Yes"") elif x in b and y in b: print(""Yes"") else: print(""No"") " p02584,s096934785,Accepted,"x,k,d = list(map(int, input().split())) if x < 0: q = (x // d) * -1 if k < q: x = x + d * k else: ak = (k - q) % 2 x = x + d * q - d * ak else: q = x // d if k < q: x = x - d * k else: ak = (k - q) % 2 x = x - d * q - d * ak print(abs(x))" p03759,s256558105,Accepted,"l = list(map(int, input().split())) if (l[2]-l[1]) == (l[1]-l[0]): print(""YES"") else: print(""NO"")" p03543,s213832723,Accepted,"n = input() print(""Yes"" if len(set(n[:3])) == 1 or len(set(n[1:])) == 1 else ""No"")" p04043,s793424675,Accepted," l = [int(x) for x in input().split(' ')] if (5 not in l): print('NO') if (7 not in l): print('NO') if (sum(l) == 17): print('YES') else: print('NO')" p02726,s931472248,Wrong Answer,"from itertools import combinations N, X, Y = (int(n) for n in input().split(' ')) shortests = [0]*(N - 1) for i, j in combinations(list(range(1, N + 1)), 2): dist = j - i if i <= X <= Y <= j: dist -= Y - X - 1 elif i <= X <= j < Y: dist = min(dist, X - i + 1 + Y - j) elif X <= i <= Y <= j: dist = min(dist, i - X + 1 + j - Y) shortests[dist - 1] += 1 for val in shortests: print(val)" p02688,s832497128,Wrong Answer,"NK = list(map(int, input().split())) ans = [0]*NK[0] for i in range(0,NK[1]): d = int(input()) table = list(map(int, input().split())) for j in range(0,NK[0]): if table.count(j) == 1: ans[j] = 0 print(NK[1]-sum(ans))" p02793,s550594746,Wrong Answer,"from fractions import gcd from functools import reduce mod = 10 ** 9 + 7 def lcm_base(x, y): return (x * y) // gcd(x, y) def lcm(numbers): return reduce(lcm_base, numbers, 1) # print('input >>') N = int(input()) A = list(map(int,(input().split()))) lcmn = lcm(A) ans = 0 for i in range(len(A)): if i % 3 == 0: ans += (lcmn // A[i]) % mod # print('-----output-----') print(int(ans%mod))" p03493,s329006605,Accepted,"n = input() ans = 0 for i in range(len(n)): if n[i] == '1': ans += 1 print(ans)" p02727,s360926752,Accepted,"import numpy as np x,y,a,b,c=[int(x) for x in input().split()] p=[int(x) for x in input().split()] q=[int(x) for x in input().split()] r=[int(x) for x in input().split()] p=list(np.sort(p)[::-1][0:x]) q=list(np.sort(q)[::-1][0:y]) select=np.sort(p+q+r)[::-1][0:x+y] print(sum(select)) " p02577,s665994703,Accepted,"N = int(input()) Sum = sum(list(map(int, str(N)))) if Sum % 9 == 0: print('Yes') else: print('No')" p02608,s353054975,Wrong Answer,"from itertools import product N = int(input()) cnt = [0]*100000000 for x in range(1,81): for y in range(1,81): for z in range(1,81): cnt[x**2 + y**2 + z**2 + x*y + y*z + z*x -1] += 1 for i in range(N): print(cnt[i]) " p03317,s343630986,Accepted,"from math import ceil N, K = map(int, input().split()) A = list(map(int, input().split())) if N == K: print(1) exit() print(ceil((N - K) / (K - 1)) + 1) " p03131,s632557782,Wrong Answer,"K,A,B = map(int,input().split()) if A+2 >= B: print(1+K) else: beatC,m = divmod((K - (A-1)),2) print(beatC*(B-A)+(K - 2 * beatC)) " p03328,s560723116,Accepted,"a,b=map(int,input().split()) sa=b-a takai=(sa*(sa+1))//2 print(takai-b)" p03543,s957538431,Accepted,"# 079a def atc_079a(input_value: str) -> str: n = 3 for i in range(0, len(input_value) + 1 - n): for j in range(1, n): if input_value[i] != input_value[i + j]: break if j == n - 1: return ""Yes"" return ""No"" input_value = input() print(atc_079a(input_value)) " p02717,s328727053,Wrong Answer,"x,y,z=list(map(int,input().split())) ans=[] ans.append(z) ans.append(x) ans.append(y) print(ans)" p02768,s415786878,Wrong Answer,"n, a, b = map(int, input().split()) mod = 10 ** 9 + 7 u, d, c = [1], [1], [1] for i in range(1, b + 1): u.append(u[-1] * (n - i + 1) % mod) d.append(d[-1] * i % mod) c.append(u[i] * pow(d[i], -1) % mod) #print(u,d,c) print((pow(2, n, mod) - 1 - int(c[a] + c[b])) % mod)" p03605,s555512286,Accepted,"if input().count('9') == 0: print('No') else: print('Yes')" p02987,s632744758,Accepted,"s = list(input()) s.sort() if(len(set(s))==2 and s[0]==s[1] and s[2]==s[3]): print(""Yes"") else: print(""No"")" p02658,s573988872,Accepted,"n = int(input()) a = list(map(int, input().split())) a.sort() ans = 1 for x in a: if ans <= 10**18: ans = ans * x print(-1 if ans > 10**18 else ans) " p03073,s565677080,Accepted,"s = input() # 先頭が0, 1が決まれば次以降は確定してしまうのでは... ans = int(1e5 + 1) for i in range(2): b = i temp = 0 for c in s: t = int(c) temp += (t != b) b = 0 if b else 1 ans = min(ans, temp) print(ans)" p03796,s782677293,Accepted,"import math n =int(input()) print(math.factorial(n) % (10**9 + 7) )" p02572,s368544387,Accepted,"def main(): n = int(input()) a = list(map(int, input().split())) a.reverse() temp = 0 a_sum = [] for i in range(len(a)): temp += a[i] a_sum.append(temp) total = 0 a_sum.reverse() a.reverse() for i in range(1, len(a_sum)): total += a[i-1]*a_sum[i] print(total % (10**9+7)) if __name__ == '__main__': main()" p02688,s200964507,Wrong Answer,"n, m = map(int, input().split()) ql = [tuple(map(int, input().split())) for i in range(2*m)] a = ql[1::2] print(n - len(set(a)))" p02882,s746640466,Accepted,"import numpy as np a,b,x = input().split() a = int(a) b = int(b) x = int(x) ans = 0 if 2*x/(a**2) < b: l = 2*x/(a*b) ans = np.arctan(l/b) else: l = 2 * (b - x/(a**2)) if l == 0: ans = np.pi/2 else: ans = np.arctan(a/l) ans = 90 - np.rad2deg(ans) print('{:.10f}'.format(ans))" p03239,s666567941,Accepted,"import sys import os def main(): if os.getenv(""LOCAL""): sys.stdin = open(""input.txt"", ""r"") N, T = list(map(int, sys.stdin.readline().split())) ret = 1001 for n in range(N): c, t = list(map(int, sys.stdin.readline().split())) if T >= t: ret = min(c, ret) print('TLE' if ret == 1001 else ret) if __name__ == '__main__': main() " p02607,s377267189,Accepted,"n =int(input()) a =list(map(int,input().split())) #print(a) cnt = 0 for i in range(n): #print(i) if (i+1)%2 ==1: if a[i]%2 ==1: cnt +=1 print(cnt)" p02711,s651446367,Accepted,"N=input() if ""7"" in N: print(""Yes"") else: print(""No"")" p03854,s526392248,Accepted,"S = input() dp = [False for _ in range(len(S)+1)] char_list = ['dream', 'dreamer', 'erase', 'eraser'] dp[0] = True for i in range(len(S)): if dp[i] == False: continue for char in char_list: if S[i:i+len(char)] == char: dp[i+len(char)] = True if dp[len(S)]: print('YES') else: print('NO') " p03137,s912154885,Wrong Answer,"N,M = map(int,input().split()) X = list(map(int,input().split())) li = [0]*(M-1) X.sort() for i in range(M-1): li[i] = abs(X[i]-X[i+1]) li.sort() print(sum(li[:M-(N//2)-N%2-1]))" p03011,s262729672,Wrong Answer,"p,q,r=map(int,input().split()) if p+q<=q+r and p+qp+q: print(r+p)" p02996,s665478618,Wrong Answer,"import sys n = int(input()) f = [] for _ in range(n): a, b = map(int, input().split()) f.append((a, b, b - a)) f.sort(key=lambda x: x[2], reverse=True) t = f[0][1] for a, b, c in f: if t < c: print('No') sys.exit() t -= a print('Yes')" p03815,s474392725,Accepted,"x = int(input()) cnt = 0 if x>11: cnt += 2*(x//11) x %= 11 while True: if x<=0: break x -= 6 cnt += 1 if x <= 0: break x -= 5 cnt += 1 if x<=0: break print(cnt)" p03693,s684934249,Accepted,"l=int(''.join(input().split()))%4 print(""YES"") if l==0 else print(""NO"") " p02910,s293064618,Accepted,"s=input();print(""YNeos""['L'in s[0::2]or'R'in s[1::2]::2])" p02623,s377968651,Accepted,"n,m,k,*a=map(int,open(0).read().split()) s=sum(a[:n]) x=i=j=n a+=k, while~i: while s+a[j]<=k:s+=a[j];j+=1 if s<=k:x=max(x,i+j) i-=1;s-=a[i] print(x-n)" p02696,s420122402,Accepted,"a,b,n=map(int,input().split()) if n>=b-1: count=0 for i in range(a): count+=(((b-1)/b)+(i/a))//1 print(int(count)) else: count=0 for j in range(a): count+=((n/b)+(j/a))//1 print(int(count)) " p03545,s537906224,Accepted,"s = input() for i in range(2**3): ls = ['+','+','+'] for j in range(len(ls)): if (i >> j) & 1: ls[j] = '-' if eval(s[0]+ls[0]+s[1]+ls[1]+s[2]+ls[2]+s[3]) == 7: print(s[0]+ls[0]+s[1]+ls[1]+s[2]+ls[2]+s[3]+""=7"") break" p03803,s843382375,Accepted,"a, b = map(int, input().split()) if a == b: print('Draw') elif a == 1 or (b != 1 and a > b): print('Alice') else: print('Bob') " p02771,s707719492,Accepted,"a,b,c=map(int,input().split()) if a==b and b==c: print('No') elif a==b or b==c or c==a: print('Yes') else: print('No')" p02719,s824668064,Accepted,"# coding: utf-8 # Your code here! N, K = map(int, input().split()) rem = N % K mns = abs(rem - K) print(min(rem, mns))" p03474,s232926286,Accepted,"a,b = map(int, input().split()) s = input() if s[a] != '-': print('No') exit() elif '-' in s[:a-1]: print('No') exit() elif '-' in s[a+1:]: print('No') exit() else: print('Yes')" p03086,s845835314,Accepted,"s=input() acgt=['A','C','G','T'] m=0 cnt=0 for i in range(len(s)): if s[i] in acgt: cnt+=1 else: m=max(cnt,m) cnt=0 print(max(cnt,m)) " p02628,s921462704,Accepted,"n, k = map(int,input().split()) p = list(map(int, input().split())) ans = 0 for _ in range(k): m = min(p) ans += m p.remove(m) print(ans)" p02755,s993377200,Wrong Answer,"'''input 8 10 ''' import math a, b = input().split() a = int(a) b = int(b) a_low = math.ceil((a + 0) * 12.5) a_hig = math.floor((a + 1) * 12.5) b_low = math.ceil((b + 0) * 10) b_hig = math.floor((b + 1) * 10) if b_low <= a_low and a_low <= b_hig: print(a_low) exit() if a_low <= b_low and b_low <= a_hig: print(b_low) exit() print(-1)" p03910,s022502465,Accepted,"N = int(input()) cnt = 0 now = 0 while True: now +=1 cnt += now if cnt >=N: break for i in range(1,now+1): if i == cnt-N: continue else: print(i) " p03075,s598818558,Accepted,"a=int(input()) b=int(input()) c=int(input()) d=int(input()) e=int(input()) k=int(input()) if b-a<=k and c-b<=k and d-c<=k and e-d<=k and c-a<=k and d-a<=k and e-a<=k and d-b<=k and e-b<=k and e-c<=k: print(""Yay!"") else: print("":("")" p02646,s175333229,Wrong Answer,"A,V = map(int,input().split()) B,W = map(int,input().split()) T = int(input()) if B-A > (V-W)*T: print(""No"") else: print(""Yes"") " p02988,s550972334,Accepted,"def main(): n = int(input()) P = list(map(int, input().split())) ans = 0 for idx in range(1, n-1): if P[idx] == sorted([P[idx-1], P[idx], P[idx+1]])[1]: ans += 1 print(ans) if __name__ == '__main__': main() " p02811,s557977437,Accepted,"K, X=map(int,input().split()) if K*500>=X: print(""Yes"") else : print(""No"") " p03331,s184422792,Accepted,"n = int(input()) res = 0 while n: res += n % 10 n //= 10 if res == 1: print(10) else: print(res)" p02786,s259736393,Accepted,"H = int(input()) ans = 0 add = 1 while H > 0: ans += add H //= 2 add *= 2 print(ans) " p02729,s568410485,Accepted,"N, M = map(int, input().split()) import math ans = 0 if N == 0 or N == 1: ans += 0 else: ans += N*(N-1)/2 if M == 0 or M == 1: ans += 0 else: ans += M*(M-1)/2 print(math.floor(ans))" p03761,s077668313,Accepted,"n = int(input()) s = [] for i in range(n): s.append(list(input())) ans = [] for i in range(len(s[0])): cnt = 0 for j in range(n): if s[0][i] in s[j]: cnt += 1 if cnt == n: ans.append(s[0][i]) for j in range(1,n): s[j].remove(s[0][i]) ans.sort() print(''.join(ans))" p02789,s416799225,Accepted," n, m = list(map(int, input().split())) if n == m: print('Yes') else: print('No') " p02923,s737072720,Accepted,"N = int(input()) H = list(map(int,input().split())) ans = 0 num = 0 for i in range(N-1): if H[i]>=H[i+1]: num += 1 else: ans = max(ans,num) num = 0 ans = max(ans,num) print(ans)" p03289,s224317279,Accepted,"s=list(input()) flag=1 if s[0]!='A': flag=0 if 'C' not in s[2:-1]: flag=0 if s.count('C')!=1: flag=0 if 'A' in s: s.remove('A') if 'C' in s: s.remove('C') s=''.join(s) if s.islower(): pass else: flag=0 if flag==1: print('AC') else: print('WA')" p03795,s048539591,Wrong Answer,"N = int(input()) print(N*800-200*N//15)" p02665,s314148238,Wrong Answer,"n = int(input())+1 a = list(map(int, input().split())) m_node = [1]*n node = 0 total = 0 if n == 1: if a[0] != 1: print(""-1"", end="""") exit() else: print(""1"", end="""") exit() for i in range(1, n): m_node[i] = (m_node[i-1] - a[i-1])*2 if m_node[i] <= 0: print(""-1"", end="""") exit() for i in reversed(range(n)): node = min((node+a[i]), m_node[i]) total += node print(total, end="""")" p03456,s773341631,Wrong Answer,"from math import sqrt a, b = input().split() integer = int(a + b) sqr_int = sqrt(integer) if sqr_int % 2 == 0: print(""Yes"") else: print(""No"")" p04020,s554890306,Accepted,"n=int(input()) temp=0 cnt=0 for _ in range(n): a=int(input()) hoge=min(a,temp) cnt+=hoge if a>hoge: cnt+=(a-hoge)//2 temp=(a-hoge)-((a-hoge)//2)*2 else: temp=0 print(cnt) " p03146,s466410315,Wrong Answer,"l, count = [], 0 s = int(input()) l.append(s) while(True): count += 1 if (s%2): s = 3*s+1 else: s//=2 l.append(s) if count>10000: break for i in range(1,len(l)): if l[i] in l[i+1:]: loc = l[i+1:].index(l[i])+1 print(loc+i+1) break" p02795,s503697136,Accepted,"H = int(input()) W = int(input()) N = int(input()) if H > W: ans = (N + (H - 1)) // H else: ans = (N + (W - 1)) // W print(ans)" p03944,s376360903,Accepted,"w, h, n = map(int, input().split()) xl = 0 xr = w yd = 0 yu = h for i in range(n): x, y, a = map(int, input().split()) if a == 1: xl = max(xl, x) if a == 2: xr = min(xr, x) if a == 3: yd = max(yd, y) if a == 4: yu = min(yu, y) print(max(0, xr - xl) * max(0, yu - yd))" p02731,s616289093,Accepted,"k=float(input()) volume=(k/3)*(k/3)*(k/3) print(volume)" p03379,s735049662,Accepted,"def main(): N, *X = map(int, open(0).read().split()) l, r = sorted(X)[N // 2 - 1:N // 2 + 1] print(""\n"".join([str(r) if x < r else str(l) for x in X])) return main() " p03785,s072191127,Wrong Answer,"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-1 and lt[i]-m < k: p += 1 else: p = 0 b += 1 m = lt[i] print(b)" p02631,s098323141,Accepted,"# E - Red Scarf N = int(input()) A = list(int(a) for a in input().split()) B = A[0] for i in range(1, N): B ^= A[i] C = [] for i in range(N): C.append(B^A[i]) print(' '.join(map(str, C)))" p02657,s495650077,Accepted,"import sys import time import math import itertools as it def inpl(): return list(map(int, input().split())) st = time.perf_counter() # ------------------------------ A, B = map(int, input().split()) print(int(A*B)) # ------------------------------ ed = time.perf_counter() print('time:', ed-st, file=sys.stderr) " p02700,s173404731,Accepted,"a, b, c, d = map(int, input().split()) ao = a // d + 1 taka = c // b + 1 if c % b == 0: taka -= 1 if a % d == 0: ao -= 1 if taka<=ao: print(""Yes"") else: print(""No"") " p03449,s241218606,Accepted,"import sys def input(): return sys.stdin.readline().strip() def resolve(): n=int(input()) l1=list(map(int,input().split())) l2=list(map(int,input().split())) ans=0 for i in range(n): cnt=sum(l1[:i+1])+sum(l2[i:]) ans=max(ans,cnt) print(ans) resolve()" p02646,s222034162,Accepted,"a, v = map(int, input().split()) b, w = map(int, input().split()) t = int(input()) c=abs(a-b)-v*t+w*t if c<=0: print(""YES"") else: print(""NO"")" p03672,s632901658,Accepted,"import sys input = sys.stdin.readline S=input().strip() N = len(S)//2 i = 0 while True: i += 1 a = S[0:(N-i)] b = S[(N-i):(2*N-2*i)] if a == b: print(len(a)*2) exit() " p03210,s512507968,Accepted,"print('YES') if int(input()) in [3, 5, 7] else print('NO')" p03136,s682396397,Accepted,"N = int(input()) L_s = str(input()).split("" "") L = [] for l in L_s: L.append(int(l)) max_v = int(max(L)) L.pop(L.index(max(L))) sum = 0 for i in L: sum += int(i) if max_v < sum: print(""Yes"") else: print(""No"") " p03617,s224187945,Accepted,"def main(): q, h, s, d = map(int, input().split()) n = int(input()) if n % 2 == 0: print(min(8 * q, 4 * h, 2 * s, d) * (n // 2)) else: print(min(8 * q, 4 * h, 2 * s, d) * (n // 2) + min(4 * q, 2 * h, s)) if __name__ == ""__main__"": main() " p03693,s388884386,Accepted,"r, g, b = input().split() if int(r+g+b) % 4 == 0: print('YES') else: print('NO') " p02818,s508766319,Accepted,"a,b,k=map(int,input().split()) print(max(a-k,0), max(b-max(k-a, 0), 0))" p03345,s193175736,Wrong Answer,"def resolve(): ''' code here ''' A, B, C, K = [int(item) for item in input().split()] if K % 2 == 0: res = B - A else: res = A -B print(res) if __name__ == ""__main__"": resolve() " p02607,s232977715,Wrong Answer,"n = int(input()) a = list(map(int,input().split())) cnt=0 for i in range(len(a)): if (i+1)&1==a[i]==1: cnt+=1 print(cnt)" p04034,s683853869,Wrong Answer,"def main(): N, M = map(int, input().split()) l = [] red = [1] for i in range(M): l.append(list(map(int, input().split()))) for i in range(M): if l[i][0] in red: red.append(l[i][1]) red.remove(l[i][0]) print(len(set(red))) main() " p03017,s209433279,Accepted,"N,A,B,C,D = map(int,input().split()) S = input() A_start = True if C < D: space1 = S[A-1:D] if ('##' in space1) != True: print('Yes') else: print('No') else: space1 = S[A-1:C] space2 = S[B-2:D+1] if ('##' in space1) != True and ('...' in space2) == True: print('Yes') else: print('No') " p03208,s174449178,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,k = iim() H = [] for _ in range(n): H.append(ii()) H.sort() ans = 1000000000 for i in range(n-k+1): ans = min(H[i+k-1]-H[i],ans) print(ans)" p03673,s986994314,Accepted,"from collections import deque n = int(input()) a = [int(i) for i in input().split()] b = deque() if n % 2 == 0: for i, j in enumerate(a): if (i + 1) % 2 == 0: b.appendleft(j) else: b.append(j) else: for i, j in enumerate(a): if (i +1) % 2 == 0: b.append(j) else: b.appendleft(j) print(*b)" p02787,s118864264,Accepted,"n,m=map(int, input().split()) s=[list(map(int, input().split())) for i in range(m)] x=max(a for a,b in s) dp=[0]*(n+x) for i in range(0,n+x): if i>0: dp[i]=min(dp[i-a]+b for a,b in s) print(min(dp[n:]))" p03681,s726377799,Accepted,"def fact(a): b = 1 for i in range(1,a+1): b = (b*i)%inf return b inf = 10**9+7 N, M = map(int,input().split()) if abs(N-M) == 1: ans = fact(N)*fact(M)%inf elif abs(N-M) == 0: ans = fact(N)*fact(M)*2%inf else: ans = 0 print(ans)" p02772,s246639120,Accepted,"n = int(input()) a = list(map(int, input().split())) z = 'APPROVED' for i in a: if i%2 == 0: if i%3 != 0 and i%5 != 0: z = 'DENIED' break print(z)" p03827,s610686298,Accepted,"n=int(input()) s=input() x=0 ans=0 for i in range(n): if s[i]==""I"": x+=1 elif s[i]==""D"": x-=1 if ans= 2: ans = 1 tap = A while True: if tap >= B: break ans += 1 tap += A-1 else: ans = 0 print(ans) " p02743,s194355752,Accepted,"a,b,c=map(int,input().split()) if c-a-b<=0: print(""No"") exit() if a*b*4<((c-a-b)**2): print(""Yes"") else: print(""No"")" p03416,s354912179,Accepted,"A, B = map(int, input().split());print(sum(str(i)==str(i)[::-1]for i in range(A,B+1)))" p03705,s951630393,Accepted,"mod = 1000000007 eps = 10**-9 def main(): import sys input = sys.stdin.readline N, A, B = map(int, input().split()) if N == 1: if A != B: print(0) else: print(1) elif N == 2: print(1) else: if A <= B: print(B * (N-1) + A - (A * (N-1) + B) + 1) else: print(0) if __name__ == '__main__': main() " p02833,s864716007,Accepted,"N = int(input()) if N % 2 == 1: print(0) elif N < 2: print(0) else: ans = 0 d = 10 while N // d > 0: ans += N // d d *= 5 print(ans) " p02843,s995472697,Accepted,"x = int(input()) for i in range(-(~x//100)): if i*100 <= x <= i*105: print(1) break else: print(0)" p02665,s897717579,Wrong Answer,"N = int(input()) A = list(map(int, input().split())) if N == 1: print(1 if not A[0] else -1) exit() if A[0] and N > 1: print(-1) exit() # 根の数 node = 1 root = 0 s = sum(A) for i in range(len(A) - 1): node = min(s, node * 2) - A[i + 1] if node < 0: print(-1) exit() s -= A[i + 1] root += node print(root + sum(A) + 1 if not node else -1) " p03673,s210403211,Accepted,"n = int(input()) A = list(map(int, input().split())) if n%2==0: B = A[1::2][::-1] + A[::2] print(*B) else: B = A[::2][::-1] + A[1::2] print(*B)" p02814,s780100763,Wrong Answer,"from fractions import gcd def main(): N, M = map(int, input().split()) A = list(map(int, input().split())) half_a = list(map(lambda x: x // 2, A)) def lcm(x, y): return x * y // gcd(x, y) b = half_a[0] for c in half_a[1:]: l = lcm(b, c) if not ((l // b) % 2) and ((l // c) % 2): print(0) exit() b = l print((M + b) // (b * 2)) main() " p02576,s817891294,Wrong Answer,"NXT= [int(i) for i in input().split(' ')] i=NXT[0] count=0 while i>=0: i -= NXT[1];count +=1 print(int(NXT[2]*count))" p03471,s760923384,Accepted,"n, y = map(int, input().split()) x = 0 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, j, (n - i - j)) x = 1 break if x == 1: break else: print(-1, -1, -1)" p02796,s884585378,Accepted,"N = int(input()) num_array = [[0]*2 for i in range(N)] for i in range(N): x, l = map(int, input().split()) small = x-l if small <= 0: small = 0 big = x+l num_array[i][1] = small num_array[i][0] = big num_array.sort() tmp_r = -(10**18) count = 0 for r, l in num_array: if tmp_r > l: continue count += 1 tmp_r = r print(count) " p03043,s852578110,Accepted,"N, K = map(int, input().split()) t = 0 i = 1 while(i < K): t += 1 i *= 2 under = 2**t p = 0 for i in range(1, N+1): c = 0 while(i < K): c += 1 i *= 2 p += 2**(t-c) print(p/((2**t)*N))" p02613,s810758644,Accepted,"from collections import Counter N=int(input()) a=[] for i in range(N): a.append(input()) c = Counter(a) print(""AC x ""+str(a.count(""AC""))) print(""WA x ""+str(a.count(""WA""))) print(""TLE x ""+str(a.count(""TLE""))) print(""RE x ""+str(a.count(""RE"")))" p03625,s863695971,Accepted,"N = int(input()) *A, = map(int, input().split()) d = {} for i in range(N): if A[i] in d: d[A[i]] += 1 continue d[A[i]] = 1 d = sorted(d.items(), reverse=True) a = [] for key, data in d: if data>=4: a.append(key) a.append(key) elif data>=2: a.append(key) if len(a)>=2: print(a[0]*a[1]) else: print(0)" p03274,s481964643,Accepted,"import sys def main(lines): N, K = map(int, lines[0].split()) a = list(map(int, lines[1].split())) ans = 1000000000000 for i in range(N): if i + K - 1 >= N: break b = a[i] c = a[i + K - 1] if b < 0 and c >= 0: ans = min(ans, max(abs(b), abs(c)) + 2*min(abs(b), abs(c))) else: ans = min(ans, max(abs(b), abs(c))) print(ans) if __name__ == '__main__': lines = [] for l in sys.stdin: lines.append(l.rstrip('\r\n')) main(lines)" p02596,s681066252,Accepted,"k = int(input()) if k % 2 == 0 or k % 5 == 0: print(-1) else: num = 7 ans = 1 while num % k != 0: num *= 10 num += 7 ans += 1 num %= k print(ans)" p02761,s469111206,Accepted,"n, m = map(int, input().split()) t = [-1] * n for _ in range(m): s, c = map(int, input().split()) s -= 1 if (t[s] != -1 and t[s] != c): print(-1) exit() t[s] = c if (n > 1): if (t[0] == 0): print(-1) exit() if (t[0] == -1): t[0] = 1 for i in range(1, n): if (t[i] == -1): t[i] = 0 else: if (t[0] == -1): t[0] = 0 print(''.join(map(str, t))) " p02718,s037149730,Accepted,"N,M = map(int,input().split()) A = list(map(int,input().split())) su = sum(A) a = 0 for i in range(N): if A[i] >= su/4/M : a += 1 print([""No"",""Yes""][a>=M])" p02924,s821581933,Accepted,"N = int(input()) print((N-1)*(N) // 2) " p02773,s001269944,Accepted,"N=int(input()) S=[input() for i in range(N)] dictionary={} for word in S: if word in dictionary: dictionary[word]+=1 else: dictionary[word]=1 maximum=max(dictionary.values()) for key, value in sorted(dictionary.items()): if value==maximum: print(key)" p02547,s651502758,Wrong Answer,"n = int(input()) cnt = [False]*n for i in range(n): x,y = map(int, input().split()) cnt[i] = x == y ans = 'No' for i in range(n-3): if cnt[i] and cnt[i+1] and cnt[i+2]: ans = 'Yes' print(ans)" p02546,s388930827,Wrong Answer,"s = input() if s[-1] == ""s"": print(s[:-1] + ""es"") else: print(s + ""s"") " p02702,s407256227,Accepted,"s = input() MOD = 2019 r = [0]*MOD r[0] = 1 z = 0 t = 0 for i in reversed(s): z = int(i) * pow(10,t,MOD) + z z %= MOD r[z] += 1 t += 1 print(sum(i*(i-1)//2 for i in r)) " p03145,s431654001,Accepted,"# -*- coding: -*- a, b, c = map(int, input().split()) print(a * b // 2)" p03150,s083238733,Accepted,"s = input() ok = False if s.startswith('keyence'): ok = True if s.startswith('k') and s.endswith('eyence'): ok = True if s.startswith('ke') and s.endswith('yence'): ok = True if s.startswith('key') and s.endswith('ence'): ok = True if s.startswith('keye') and s.endswith('nce'): ok = True if s.startswith('keyen') and s.endswith('ce'): ok = True if s.startswith('keyenc') and s.endswith('e'): ok = True if s.endswith('keyence'): ok = True if ok: print('YES') else: print('NO')" p02924,s175442430,Accepted,"from sys import stdin,setrecursionlimit import string setrecursionlimit(10 ** 7) n = int(stdin.readline().rstrip()) print(n*(n-1)//2)" p03799,s004130393,Wrong Answer,"n,m=map(int,input().split()) cnt_s=n cnt_c=m ans=0 if cnt_s>cnt_c: ans=cnt_c//2 print(ans) elif cnt_s<=cnt_c: ans+=n cnt_c-=2*n ans+=cnt_c//4 print(ans) " p02694,s909740466,Wrong Answer,"x = int(input()) p = 100 count = 0 while p=n: break if queue: ans+=heapq.heappop(queue) print(-ans)" p03408,s853242875,Wrong Answer,"n = int(input()) a = {} for _ in range(n): s = input() if s in a: a[s] += 1 else: a[s] = 1 m = int(input()) for _ in range(m): s = input() if s in a: a[s] -= 1 else: a[s] = -1 ans = 0 for i in a: if a[i] > 0: ans += a[i] print(ans)" p02723,s047378111,Accepted,"x=input() if x[2]==x[3] and x[4]==x[5]: print('Yes') else: print('No')" p03037,s068045297,Accepted,"n,m=[int(x) for x in input().rstrip().split()] ll=[] rl=[] for i in range(m): l,r=[int(x) for x in input().rstrip().split()] ll.append(l) rl.append(r) ans=0 if min(rl)-max(ll)<0: print(0) else: print(min(rl)-max(ll)+1) " p02780,s923582917,Wrong Answer,"n = input().split() N = int(n[0]) K = int(n[1]) a = input().split() sum = 0 max = 0 for j in range(0, N): sum += int(a[j]) if j > K - 1: sum -= int(a[j - K]) if max < sum: max = sum e = (max + K) / 2 if (max + K) % 2 == 0 else str(int((max + K - 1) / 2)) + '.5' print (e)" p03220,s900682810,Wrong Answer,"def p_b(): n = int(input()) t, a = map(int, input().split()) *H, = map(int, input().split()) ans = 10**9 idx = -1 for i, h in enumerate(H): if ans > abs(a - (t - h * 0.006)): ans = abs(t - h * 0.006) idx = i + 1 print(idx) p_b()" p03910,s412013304,Accepted,"N = int(input()) n = 0 a = n ** 2 + n - 2 * N # 上から抑える while a < 0: n += 1 a = n ** 2 + n - 2 * N score = 0 ans = [] for i in reversed(range(1, n + 1)): if score + i <= N: score += i ans.append(i) if score == N: break for i in ans: print(i)" p03485,s675494678,Accepted,"a, b = map(int, input().split()) x = (a+b)/2 # print(x) m, n = divmod(x,1) # print(""{},{}"".format(m,n)) if n>0: ans = m+1 else: ans = m print(int(ans))" p02832,s294540888,Wrong Answer,"N=int(input()) a=[int(s) for s in input().split("" "")] List=[] last_index=0 for number in range(1,N+1): for index in range(last_index,N): if number==a[index]: List.append(number) last_index=index break print(-1 if List[0]!=1 else N-len(List))" p02663,s525605423,Wrong Answer,"H1,M1,H2,M2,K=map(int,input().split()) if H2-H1<0: print(0) else: if M2-M1<0: print(0) else: if M2>=M1: print(((H2-H1)*60+(M2-M1))-K) else: print(((H2-H1-1)*60+(M1-M2))-K)" p02814,s928450456,Accepted,"N, M = map(int, input().split()) A = list(map(int, input().split())) from fractions import gcd def Lcm(x): L = 1 for a in x: a=a//2 L = (a // gcd(a, L))*L return L X=Lcm(A) fg = 0 for i in A: if (X//(i//2))%2==0: fg=1 break if fg==1: print(0) else: print(((M//X)+1)//2)" p02556,s731204140,Wrong Answer,"n = int(input()) maxx1 =maxx2 =0 minn1 = minn2 = 2000000001 for i in range(n): x,y = map(int,input().split()) minn1 = min(minn1,x+y) maxx1 = max(maxx1,x+y) minn2 = min(minn2,abs(x-y)) maxx2 = max(maxx2,abs(x-y)) print(max(maxx1-minn1,maxx2+minn2)) " p02556,s485698401,Wrong Answer,"N = int(input()) table = [[int(i) for i in input().split()] for N in range(N)] a = -1 b = 10**9 * 2 + 1 c = -1 d = 10**9 * 2 + 1 for i in range(N): p = table[i][0] q = table[i][1] if a < p+q: a = p+q if b > p+q: b = p+q if c < p-q: c = p-q if d > p-q: d = p-q print(max(a-b,c-d)) " p03699,s345299592,Accepted,"n=int(input()) a=[] b=[] d=0 for i in range(n): c=int(input()) d+=c if c%10==0: a.append(c) else: b.append(c) b.sort() if d%10==0 and b: print(d-b[0]) elif d%10==0: print(0) else: print(d)" p03371,s808820338,Accepted,"A,B,C,X,Y = map(int,input().split()) sumAB = A+B if sumAB >= 2*C: minXY = min(X,Y) ans = min(X,Y)*2*C X -= minXY Y -= minXY if X != 0: ans += X*min(A,2*C) elif Y !=0: ans += Y*min(B,2*C) print(ans) else: print(A*X+Y*B)" p03136,s494281729,Wrong Answer,"N = int(input()) L = list(map(int, input().split())) L.sort(reverse=True) if L[0] > (sum(L)-L[0]): print('Yes') else: print('No')" p02972,s866797211,Accepted,"import sys sys.setrecursionlimit(10**6) n = int(input()) a = [0] a += list(map(int, input().split())) b = [0]*(n+1) for i in range(n,0,-1): sum = 0 for j in range(2*i, n+1, i): sum ^= b[j] b[i] = sum^a[i] ans = [] for i in range(1,n+1): if b[i]: ans.append(i) print(len(ans)) print(*ans)" p02813,s040950061,Wrong Answer,"import itertools N = int(input()) permu = [i+1 for i in range(N)] s = 0 flag = False P = tuple([int(i) for i in input().split("" "")]) Q = tuple([int(i) for i in input().split("" "")]) # print(P) for i, value in enumerate(itertools.permutations(permu)): if P == Q: break if value == P or value == Q: # print(i) if flag: s -= i else: s += i flag = True " p02963,s497678426,Accepted,"S = int(input()) v = 10**9 b2 = (S+v-1)//v b1 = v*b2-S print(v, 1, 0, 0, b1, b2) " p02660,s510185301,Accepted,"import sys n = int(input()) if n == 1: print(0) sys.exit() count = 0 i = 2 while True: if i * i > n: break e = 0 while n % i == 0: n = n // i e += 1 curr = 1 while e >= curr: e -= curr curr += 1 count += 1 i += 1 if n > 1: print(count + 1) else: print(count) " p03386,s594700257,Wrong Answer,"a, b, k = map(int, input().split()) ans = [] for i in [t for t in range(a, b)][:k]: ans.append(i) for i in [t for t in range(b, a, -1)][:k]: ans.append(i) ans = list(set(ans)) ans.sort() for o in ans: print(o)" p02755,s558246616,Accepted,"a,b = map(int,input().split()) fl = 0 for i in range(10000): if int(i*0.08)==a and int(i*0.1)==b: print(i) fl = 1 break if fl ==0: print(-1) " p03360,s081102009,Accepted,"ni = lambda: int(input()) nm = lambda: map(int, input().split()) nl = lambda: list(map(int, input().split())) a=nl() k=ni() for i in range(k): a = sorted(a)[::-1] a[0]*=2 print(sum(a))" p03371,s282157687,Accepted,"a,b,c,x,y=map(int,input().split()) if a>=2*c and b>=2*c: print(max(x,y)*2*c) elif a<2*c and b>=2*c: print(y*2*c + max(0,x-y)*a) elif a>=2*c and b<2*c: print(x*2*c + max(0,y-x)*b) elif a+b>2*c: if x>y: print(y*2*c+(x-y)*a) else: print(x*2*c+(y-x)*b) else: print(a*x+b*y) " p03243,s829603239,Accepted,"N = input() A = int(N[0])*111 print((int(N[0])+1)*111 if int(N) > A else A)" p02694,s247856542,Wrong Answer,"x=int(input()) c=100 year=0 while (x+1!=c): year+=1 c+=1 print(year)" p03795,s905976579,Wrong Answer,"N = int(input()) print(N*800-15//N*200)" p03472,s655725003,Accepted,"N,H=map(int,input().split()) B=[] A=0 for _ in range(N): a,b=map(int,input().split()) A=max(A,a) B.append(b) B.sort(reverse=True) ans=(H-1)//A+1 for i in range(N): H-=B[i] if H<=0: ans=min(ans,i+1) break ans=min(ans,(H-1)//A+1+i+1) print(ans)" p03274,s669934496,Wrong Answer,"n, k = map(int, input().split()) x = list(map(int, input().split())) if x[0] >= 0: print(x[k - 1]) exit() elif x[n - 1] < 0: print(x[n - k]) exit() else: for i in range(n): if x[i] >= 0: ori = i break f_inf = float(""inf"") res = f_inf for i in range(max(ori - k, 0), min(ori + k, n) - k + 1): time = abs(x[i]) + abs(x[i + k - 1] - x[i]) res = min(res, time) print(res) " p02989,s021421170,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] and K==0: K=1 elif d[N//2]==d[(N//2)-2]: K=0 print(K)" p02987,s438032218,Wrong Answer,"l=list(input()) if l[0]==l[1] and l[2]==l[3]: print(""Yes"") elif l[0]==l[2] and l[1]==l[3]: print(""Yes"") elif l[0]==l[3] and l[1]==l[2]: print(""Yes"") else: print(""No"")" p03481,s654994082,Accepted,"x,y = map(int,input().split()) ans = 0 while x < y: x *= 2 ans += 1 if x == y: ans += 1 print(ans)" p03282,s232536997,Wrong Answer,"S = list(map(int,input())) for i in range(len(S)): if S[i] != 1: print(S[i]) break" p03479,s874185252,Wrong Answer,"x,y=map(int,input().split()) z=y/x cnt=0 while z>=1: cnt+=1 z/=2 print(cnt)" p03472,s651960702,Accepted,"from math import ceil N, H = map(int, input().split()) B = [] a = 0 for i in range(N): aa, b = map(int, input().split()) if a < aa: a = aa B.append(b) B.sort(reverse=True) res = 0 for b in B: if a < b: H -= b else: break res += 1 if H <= 0: break if H <= 0: print(res) else: print(res+ceil(H/a))" p02859,s785314132,Accepted,"r = int(input()) print(int(r**2))" p03250,s587952780,Accepted,"a, b, c = sorted(map(int,input().split())) print(c*10+b+a)" p03150,s473456678,Wrong Answer,"K = ""keyence"" S = input() for i in range(len(K) + 1): l, r = K[:i], K[i:] if l in S and r in S: print(""YES"") break else: print(""NO"") " p03035,s770557487,Accepted,"x, y = input("""").split("" "") a = int(x) b = int(y) result = 0 if a >= 13: result = b elif a >= 6 and a <= 12: result = b//2 else: result = 0 print(result)" p03030,s394006934,Accepted,"#B - Guidebook AC(ヒント) N = int(input()) S = [] P = [] for _ in range(N): s,p = input().split() S.append(s) P.append(int(p)*(-1))#負の値にして降順にソートできるようにする book = list(zip(S,P)) book_sort = sorted(book) ans = [book.index(i)+1 for i in book_sort] for j in ans: print(j)" p02630,s691739073,Wrong Answer,"from collections import Counter n = int(input()) a = Counter(map(int, input().split())) ans = sum(a) q = int(input()) for i in range(q): b, c = map(int, input().split()) v = a[b] a[c] += v a[b] = 0 ans += (c - b) * v print(ans) " p03105,s926281457,Wrong Answer,"a, b, c = map(lambda x: int(x), input().split()) if a * c <= b: print(a * c) else: print(int(b/a))" p02582,s229519259,Accepted,"S = input() def it(s): c = 0 for v in s: if v == 'R': c += 1 else: c = 0 yield c print(max(it(S)))" p03723,s869590537,Wrong Answer,"l = list(map(int,input().split())) ans = 0 if l[0] == l[1] == l[2]: print(-1) exit() while all(i % 2 == 0 for i in l): a = l[0]//2; b = l[1]//2; c = l[2]//2; l[0] = b + c l[1] = a + c l[2] = a + b ans += 1 print(ans)" p02664,s920643160,Accepted,"t = input() print(t.replace('?', 'D'))" p02628,s951739485,Accepted,"n, k = list(map(int, input().split(' '))) p = list(map(int, input().split(' '))) p = sorted(p) print(sum(p[0:k]))" p02699,s308195204,Accepted,"a, b = map(int, input().split()) print('safe' if a > b else 'unsafe') " p02571,s448154860,Accepted,"import sys def minimumchar(s1,s2): n,m=len(s1),len(s2) ans=sys.maxsize for i in range(m-n+1): minRemovedChar=0 for j in range(n): if (s1[j]!=s2[i+j]): minRemovedChar+=1 ans=min(minRemovedChar,ans) return ans s2=input() s1=input() print(minimumchar(s1,s2)) " p02554,s087696416,Wrong Answer,"n = int(input()) mod = 10**9+7 print(pow(10, n, mod) - (pow(9, n, mod) + pow(9, n, mod)) + pow(8, n, mod))" p02790,s317072871,Accepted,"a,b = map(int, input().split()) if a < b: print(str(a) * b) else: print(str(b) * a)" p02939,s260302868,Accepted,"S = input() l = len(S) pre = '' flag = 0 count = 0 for i in range(l): if flag == 1: flag = 0 continue try: tmp = S[i] if tmp == pre: flag = 1 pre = tmp + S[i+1] count += 1 else: pre = tmp count += 1 except IndexError: pass print(count)" p03455,s919332084,Accepted,"a, b = map(int, input().split()) if (a * b) & 1: print('Odd') else: print('Even')" p02861,s854176312,Accepted,"import math n = int(input()) l = 0 x_list = [] y_list = [] for i in range(n): x, y = map(int, input().split()) x_list.append(x) y_list.append(y) for j in range(n): for k in range(n): if j >= k: continue l += math.sqrt((x_list[j] - x_list[k]) ** 2 + (y_list[j] - y_list[k]) ** 2) print(l * 2/n)" p03261,s721963098,Accepted,"n = int(input()) shiritori = [] for _ in range(n): shiritori.append(input()) if len(set(shiritori)) != n: print (""No"") exit () for i in range(n-1): if shiritori[i][-1] != shiritori[i+1][0]: print (""No"") exit () else: print (""Yes"") " p02753,s175999299,Accepted,"s = input() if s == ""AAA"" or s == ""BBB"": print(""No"") else: print(""Yes"")" p02665,s284992205,Wrong Answer,"N = int(input()) A = list(map(int, input().split())) V = [0]*(N+1) flug = 0 Lsum= sum(A) V[0] = 1 for i in range(1,N): V[i] = (V[i-1]*2 - A[i]) if V[i] <= 0: flug = 1 Lsum = Lsum - A[i] if V[i] > Lsum : V[i] = Lsum V[N]=0 #print(V) ans = sum(V)+sum(A) if A[0] != 0: ans = -1 if flug ==1: ans = -1 if N == 0: ans = -1 print(ans)" p03435,s872706548,Accepted,"c = [[int(i) for i in input().split()] for _ in range(3)] print('Yes') if c[0][0]+c[1][1]+c[2][2] == c[0][1]+c[1][2]+c[2][0] == c[0][2]+c[1][0]+c[2][1] else print('No') " p03352,s945996383,Accepted,"import math X=int(input()) def check_p(X,b): p = 0 while b**(p+1) <= X: p+=1 return b**p ans=1 for b in range(2,int(math.sqrt(X))+1): ans = max(ans,check_p(X,b)) print(ans)" p02659,s728816072,Wrong Answer,"a,b=input().split() a=int(a) b=float(b) print(int(a*b+0.0001))" p02676,s443367651,Accepted,"k=int(input()) s=input() if len(s)<=k: print(s) else: print(s[:k]+""..."")" p02608,s282779415,Accepted,"#!/usr/bin/env python3 n = int(input()) list_ = [0]*(10**4) for x in range(1, 105): for y in range(1, 105): for z in range(1, 105): a = x**2+y**2+z**2+x*y+y*z+z*x if a <= 10**4: list_[a-1] += 1 for i in range(n): print(list_[i]) " p03852,s501486614,Accepted," c = input() if c in ""aiueo"" : print(""vowel"") else : print(""consonant"") " p03331,s516788019,Accepted,"n = int(input()) ans = 114514 for i in range(1, n): a = list(map(int, list(str(i)))) b = list(map(int, list(str(n - i)))) c = sum(a) + sum(b) ans = min(ans, c) print(ans)" p02613,s241330622,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))" p02768,s276328240,Accepted,"n, a, b = map(int, input().split()) mod = 10**9 + 7 def combi_mod(n, r, mod): numerator = 1 denominater = 1 for i in range(r): numerator = numerator * (n-i) % mod denominater = denominater * (i+1) % mod return numerator * pow(denominater, mod - 2, mod) % mod print((pow(2, n, mod) -1 - combi_mod(n, a, mod) - combi_mod(n, b, mod)) % mod)" p03998,s481348050,Accepted,"A = list(input()) B = list(input()) C = list(input()) s = A.pop(0) while True: if A == [] and s == 'a': print('A') exit() elif B == [] and s == 'b': print('B') exit() elif C == [] and s == 'c': print('C') exit() if s == 'a': s = A.pop(0) elif s == 'b': s = B.pop(0) elif s == 'c': s = C.pop(0)" p03625,s973035719,Accepted,"from collections import * N = int(input()) C = Counter(map(int,input().split())) A = [0,0] B = [0] for k,v in C.items(): if 2<=v: A+=[k] if 4<=v: B+=[k] A.sort() B.sort() print(max(A[-1]*A[-2],B[-1]**2))" p02658,s258941155,Accepted,"N = int(input()) line = [int(i) for i in input().split()] sum = 1 line.sort(reverse=True) if line[len(line) -1]== 0: print(0) exit() for num in line: sum = sum * num if sum > 10 ** 18: print(-1) exit() print(sum)" p03659,s028795408,Accepted,"n=int(input()) A=list(map(int, input().split())) s=A[0] S=sum(A) ans=abs(sum(A) - 2*s) for i in range(1,n-1): s += A[i] ans = min(ans, abs(S - 2*s)) if n > 3: print(ans) else: print(abs(A[1]-A[0]))" p02690,s000445642,Wrong Answer,"def main(): X = int(input()) for A in range(-50, 51): for B in range(-50, 51): if A**5 - B**5 == X: print(A, B) exit() if __name__ == ""__main__"": main()" p03486,s836579637,Wrong Answer,"input = [str(input()) for i in range(2)] s_list = sorted(input[0]) t_list = sorted(input[1], reverse=True) def main(): # tが小さければno for s, t in zip(s_list, t_list): if s < t: return 'Yes' elif s > t: return 'No' if len(s) >= len(t): return 'No' else: return 'Yes' print(main())" p03474,s885109069,Accepted,"a,b = map(int,input().split()) s = input() for i in range(a+b+1): if i == a: if s[i] != ""-"": print(""No"") exit() else: if s[i] == ""-"": print(""No"") exit() print(""Yes"")" p03407,s050382997,Wrong Answer,"a,b,c=map(int,raw_input().split()) if a+b>c: print ""yes"" else: print ""no""" p02791,s464817463,Accepted,"N = int(input()) P = list(map(int, input().split())) ans = 0 min_ = P[0] for i in range(N): if min_ >= P[i]: ans += 1 min_ = min(min_, P[i]) print(ans) " p03435,s446956532,Accepted,"c = [list(map(int, input().split())) for _ in range(3)] flg = all( c[0][i + 1] - c[0][i] == c[1][i + 1] - c[1][i] == c[2][i + 1] - c[2][i] and c[i + 1][0] - c[i][0] == c[i + 1][1] - c[i][1] == c[i + 1][2] - c[i][2] for i in range(2) ) print([""No"", ""Yes""][flg])" p03338,s775903468,Wrong Answer,"N = int(input()) S = list(input()) ans = [] ans.append(len(set(S))) for i in range(N): if i == 0: pass elif S[i] == S[i-1]: pass else: S_f = S[:i+1] S_b = S[i+1:] F = set(S_b) B = set(S_f) ans.append(len(F&B)) print(max(ans)) " p03417,s520444329,Accepted,"H,W=map(int,input().split()) print(abs((H-2)*(W-2)))" p03449,s408661884,Accepted,"n = int(input()) a = [list(map(int,input().split())) for i in range(2)] total = 0 st_num = 0 max_num = 0 for i in range(n): st_num += a[0][i] for j in range(i,n): total += a[1][j] if max_num < st_num+total: max_num = st_num+total total = 0 print(max_num)" p03943,s012489857,Wrong Answer,"a,b,c = map(int,input().split()) #print(a+b+c) if (a+b+c)%3 == 0: print(""Yes"") else : print(""No"")" p02842,s541536140,Accepted,"N=int(input()) n=N//1.08 a=int(n*1.08) b=int((n+1)*1.08) print(int(n) if a==N else int(n+1) if b==N else "":("")" p03035,s464377679,Wrong Answer,"A,B=map(int,input().split()) if A>=13: print(B) elif 6<=B<=12: print(B/2) else: print(0) " p02785,s484992504,Wrong Answer,"i = list(map(int, input().split())) j= list(map(int, input().split())) x=sorted(j, reverse=True) z=0 if i[1]>=len(j): print(0) else: for a in range(i[0],len(x)): z+=x[a] print(z)" p02900,s414845963,Accepted,"A, B = map(int, input().split()) import math 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 c = prime_factorize(math.gcd(A, B)) c = collections.Counter(c) c = c.values() print(len(c) + 1)" p02717,s339783521,Accepted,"a, b, c = map(int, input().split()) print(c, a, b)" p03281,s174726065,Accepted,"n = int(input()) ans = 0 for i in range(1,n+1,2): cnt = 0 for j in range(1,i+1): if i%j==0: cnt += 1 if cnt==8: ans += 1 print(ans)" p03795,s827544626,Accepted,"n=int(input()) x=800*n y=200*(n//15) ans=x-y print(ans)" p03657,s267390257,Wrong Answer,"import sys A,B = map(int,input().split()) if A < 0 or B < 0 or A > 100 or B > 100: sys.exit() if A % 3 or B % 3 or (A + B) % 3: print(""Possible"") else: print(""Impossible"")" p02570,s762030151,Accepted,"s = input() l = s.split(' ') if(int(l[0]) <= int(l[1]) * int(l[2])): print(""Yes"") else: print(""No"")" p03323,s561679532,Accepted,"ab = [int(i) for i in input().split()] if all(i <= 8 for i in ab): print('Yay!') else: print(':(')" p03481,s277777607,Wrong Answer,"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())) x,y=mp() for i in range(10*5): x*=2 if x>y: print(i+1) exit()" p02819,s974047364,Accepted,"import math def isPrime(x): if x == 1: return False for k in range(2, int(math.sqrt(x) + 1)): if x % k == 0: return False return True n = int(input()) while True: if isPrime(n): print(n) break n += 1" p03407,s039807022,Accepted,"A,B,C=map(int,input().split()) if A+B>=C: print('Yes') else: print('No') " p03797,s829096215,Accepted,"N, M = [int(i) for i in input().split()] cnt = 0 if N <= M // 2: cnt = N M = M - (2 * N) N = 0 cnt += M // 4 else : cnt = M // 2 print(cnt)" p02970,s243599587,Wrong Answer,"n,d=map(int,input().split()) if n%(2*d)==0: print(n//(2*d)) else: print((n//(2*d))+1) " p03011,s060266970,Accepted,"p, q, r = map(int, input().split()) flights = { ""a_b_c"": p + r, ""a_c_c"": q + r, ""c_b_a"": q + p } print(min(flights.values()))" p03524,s182269532,Accepted,"from collections import Counter S = input() c = Counter(S) v = [c[l] for l in 'abc'] print('YES' if max(v) - min(v) <= 1 else 'NO') " p02693,s413319853,Accepted,"K = int(input()) A,B = map(int,input().split()) for i in range(A,B+1): if i%K == 0: print('OK') break else: print('NG')" p03448,s827211820,Accepted,"A, B, C, X = map(lambda x: int(x) + 1, [input() for q in range(4)]) r = 0 for a in range(A): for b in range(B): for c in range(C): if (500 * a + 100 * b + 50 * c) == (X - 1): r += 1 print(r)" p03767,s656060343,Accepted,"N = int(input()) A = sorted(map(int, input().split()))[::-1] I = [1+2*i for i in range(N)] print(sum(A[i] for i in I))" p03043,s134796966,Accepted,"import math N,K = map(int, input().split()) ans = 0 for n in range(1, N + 1): cnt = 0 sums = n while sums < K: sums *= 2 cnt += 1 ans += 0.5 ** cnt print(ans/N)" p02779,s270551636,Accepted," n = int(input()) a = list(map(int,input().split())) if len(a) != len(set(a)): print(""NO"") else: print(""YES"") " p02795,s188303742,Accepted,"import math h = int(input()) w = int(input()) n = int(input()) print(math.ceil(n/max(h,w)))" p03449,s803279063,Accepted,"N = int(input()) x = list(map(int, input().split(' '))) y = list(map(int, input().split(' '))) count = x[0] for i in range(N): count += y[i] sums = count for i in range(N - 1): count = count + x[i + 1] - y[i] if count > sums: sums = count print(sums)" p03644,s618392910,Wrong Answer,"N = int(input()) maxdiv = 0 ans = 0 for i in range(1, N + 1): d = i count = 0 while d & 1 == 0: d >>= 1 count += 1 if count > maxdiv: ans = i maxdiv = count print(ans) " p02775,s049054587,Accepted,"def main(): n = input() a, b = 0, 1 for i in n: x = int(i) a, b = min(a + x, b + 10 - x), min(a + x + 1, b + 10 - x - 1) print(a) main() " p02947,s226940620,Accepted,"import collections from itertools import combinations import sys input = sys.stdin.readline N = int(input()) s = [''.join(sorted(list(input()))) for _ in range(N)] c = collections.Counter(s) cnt = 0 for i in c.values(): if i > 1: cnt += i*(i-1)//2 print(cnt)" p03137,s085172284,Accepted,"n, m = map(int, input().split()) if n >= m: print(0) exit() lis = list(map(int, input().split())) lis.sort() res = [] for i in range(m - 1): res.append(lis[i + 1] - lis[i]) res.sort() l = len(res) k = n - 1 print(sum(res[:l - k])) " p03012,s253725228,Wrong Answer,"N = int(input()) W = list(map(int,input().split())) s = sum(W) count = 0 for i in range(N): count += W[i] if count >= s/2: print(2*count - s) break " p02744,s821118577,Accepted,"N=int(input()) A=[""a""] S=""abcdefghijklmn"" for i in range(N-1): B=[] for a in A: for s in S[:len(set(a))+1]: B.append(a+s) A=B[::] print(""\n"".join(A))" p02595,s776702597,Accepted,"n,d=map(int,input().split()) d**=2 print(len([_ for _ in '1'*n if sum(map(lambda x: int(x)**2, input().split()))<=d])) " p03208,s946020149,Accepted,"n,k = map(int,input().split()) H = sorted([int(input()) for i in range(n)]) ans = H[-1] for i in range(n-k+1): x = H[i+k-1] - H[i] ans = min(ans,x) print(ans)" p03109,s306339905,Wrong Answer,"s = input() if s <= ""2019/4/30"": print(""Heisei"") else: print(""TBD"")" p02645,s201209990,Accepted,print(input()[:3]) p02584,s229839219,Accepted,"x, k, d = map(int, input().split()) x = abs(x) if (x - k*d) >= 0: x -= k*d else: k -= int(x/d) x -= int(x/d) * d if (k%2) != 0: x -= d print(abs(x))" p02910,s097940108,Accepted,"import sys s = str(input()) for i in range(len(s)): if i % 2 ==0: if s[i] == 'L': print('No') sys.exit() if i % 2 ==1: if s[i] == 'R': print('No') sys.exit() print('Yes')" p02831,s684426143,Accepted,"import math from math import gcd INF = float(""inf"") import sys input=sys.stdin.readline import itertools from collections import Counter def main(): a,b = map(int, input().split()) ans = max(a,b) first = ans m = min(a,b) while True: if ans%m == 0: print(ans) exit() ans += first if __name__==""__main__"": main() " p02681,s528857291,Wrong Answer,"S=str(input()) T=str(input()) if len(S)==1 and S[0]==T[0] and len(T)==2: print('Yes') elif len(T.replace(S,''))==1: print('Yes') else: print('No')" p02947,s158278912,Wrong Answer,"import collections import math def combinations_count(n, r): return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)) n = int(input()) li = [] ans = 0 for i in range(n): s = list(input()) s.sort() li.append(''.join(s)) c = list(collections.Counter(li).values()) for i in c: if i == 1: break ans += combinations_count(i, 2) print(ans)" p03481,s512624637,Accepted,"X,Y=map(int,input().split()) ans=0 for i in range(10000): if X*(2**i) > Y: print(i) break" p02970,s860673370,Accepted,"N,D=map(int,input().split()) import math print(math.ceil(N/(2*D+1)))" p03385,s172204111,Wrong Answer,"S = str(input()) if S[0] + S[1] + S[2]: print('Yes') else: print('No')" p02603,s868376381,Accepted,"K = int(input()) A = list(map(int, input().split())) sum = 1000 kabu = 0 for k in range(K): if k+1 ==K: sum +=kabu*A[K-1] break if A[k]A[k+1] and kabu != 0: sum = sum + kabu * A[k] kabu = 0 print(sum)" p03309,s441030193,Accepted,"n=int(input()) A=sorted(a-i-1 for i,a in enumerate(map(int,input().split()))) print(sum(abs(a-A[n//2])for a in A))" p02700,s067391460,Accepted,"a,b,c,d = map(int,input().split()) flag = True while flag: c -= b if c <= 0: print(""Yes"") flag = False else: a -= d if a <= 0: print(""No"") flag = False" p02795,s417102764,Accepted,"# -*- coding: utf-8 -*- import math H = int(input()) W = int(input()) N = int(input()) if H >= W: out = math.ceil(N / H) else: out = math.ceil(N / W) print(out) " p03323,s317202328,Wrong Answer,"a,b=map(int,input().split()) if a-b==1 and a-b==0: print(""Yay!"") else: print("":("") " p02785,s096628145,Accepted,"m, n = map(int, input().split()) li = list(map(int, input().split())) if n >= m: print(0) elif n == 0: print(sum(li)) else: print(sum(sorted(li)[:-n]))" p02820,s906166435,Accepted,"n, k = map(int, input().split()) r, s, p = map(int, input().split()) t = list(input()) point = 0 for i in range(n): if (i >= k) & (t[i] == t[i - k]): t[i] = 'a' continue else: if t[i] == 'r': point += p elif t[i] == 's': point += r else: point += s print(point)" p03001,s107143363,Accepted,"import sys def input(): return sys.stdin.readline().strip() def resolve(): w,h,x,y=map(int, input().split()) ans=w*h*0.5 if x==w/2 and y==h/2: print(ans,1) else: print(ans,0) resolve()" p03211,s413177757,Accepted,"import sys from bisect import * from heapq import * from collections import * from itertools import * from functools import * from math import * from fractions import * sys.setrecursionlimit(100000000) input = lambda: sys.stdin.readline().rstrip() def main(): S = input() print(min(abs(int(S[i:i + 3]) - 753) for i in range(len(S) - 2))) main() " p03041,s543689768,Wrong Answer,"def main(): S = input() first = int(S[0:2]) last = int(S[2:4]) if(first>12 and last<=12): print(""YYMM"") elif(last>12 and first<=12): print(""MMYY"") elif(last<=12 and first<=12): print(""AMBIGUOUS"") else: print(""NA"") return main() " p02691,s040767430,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 = int(input()) A = list(map(int,input().split())) C = collections.Counter() for i ,ai in enumerate(A): ans += C[i-ai] C[ai+i] += 1 print(ans)" p03494,s651559984,Accepted,"N = int(input()) A = list(map(int,input().split())) ans = 0 i = 0 while True: if A[i] % 2 == 0: A[i] /= 2 else: break if i == N-1: i = 0 ans += 1 else: i += 1 print(ans) " p02602,s547860821,Wrong Answer,"def main(): n,k = map(int,input().split()) a = list(map(int,input().split())) ans = [] for i in range(k,n): ans.append(""Yes"" if a[i] > a[i-k] else ""No"") print(""/n"".join(ans)) if __name__ == '__main__': main()" p02584,s842726724,Wrong Answer,"x, k, d = map(int, input().split()) x = abs(x) s = int(x/d) if k < s: print(x-d*k) else: if x-s*d < abs(x-(s+1)*d): if (k-s)%2 == 0: print(x-s*d) else: print(abs(x-(s+1)*d)) else: if (k-s)%2 == 0: print(abs(x-(s+1)*d)) else: print(x-s*d)" p03761,s511153884,Wrong Answer,"n = int(input()) last = """" for i in range(n): s = input() if i == 0: last = s last_dummy = """" s_dummy = s for j in range(len(last)): for k in range(len(s)): if last[j] == s_dummy[k]: last_dummy += last[j] s_dummy.strip(s[k]) break last = last_dummy ans_list = sorted(last) ans = """" for i in ans_list: ans += i print(ans)" p02598,s934459572,Wrong Answer,"from math import ceil from fractions import Fraction from sys import exit import heapq n,k, *aa = map(int, open(0).read().split()) left = 1 right = sum(aa) mid = (left + right) // 2 while right - left > 1: summ = sum(ceil(a/mid)-1 for a in aa) if summ <= k: right = mid mid = (left + right) // 2 else: left = mid mid = (left + right) // 2 print(right)" p02613,s771522130,Accepted,"AC = 0 WA = 0 TLE = 0 RE = 0 a_list = [input() for j in range(int(input()))] for a in a_list: if a == ""AC"": AC += 1 elif a == ""WA"": WA += 1 elif a == ""TLE"": TLE += 1 else: RE += 1 print(f""AC x {AC}\nWA x {WA}\nTLE x {TLE}\nRE x {RE}"")" p02658,s137681823,Wrong Answer,"import numpy as np; from numba import jit import warnings warnings.simplefilter('ignore') @jit def slove(ans, A): for a in A: ans *= a return ans if __name__ == '__main__': N = int(input()) A = list(map(int, input().split())) ans = slove(1, A) if ans > 10 ** 18: print(-1) quit() print(ans) " p03773,s712896442,Wrong Answer,"A , B = map(int,input().split()) if (A + B)<=24: print(A + B) elif (A + B)>24: print(A + B - 24)" p02630,s953543515,Accepted,"n = int(input()) al = list(map(int, input().split())) q = int(input()) from collections import Counter count = Counter(al) als = sorted(al) dp = [0]*(10**5+1) res = sum(als) for i in range(10**5+1): dp[i] =count[i] for j in range(q): a,b = map(int, input().split()) res += dp[a] * (b-a) dp[b] += dp[a] dp[a] = 0 print(res)" p03672,s995305066,Accepted,"S = input() if len(S) % 2 == 1: S = S[-1] for i in reversed(range(2, len(S) + 1, 2)): length = i fl = 0 for j in range(i // 2): # print(S[j], S[j + length // 2]) if S[j] != S[j + length // 2]: fl = 1 if fl == 0 and length != len(S): print(length) exit() " p03803,s509842186,Accepted,"a, b = map(int, input().split()) lst = [i for i in range(2, 14)] + [1] if a == b: print('Draw') else: print(['Bob', 'Alice'][lst.index(a) > lst.index(b)])" p02600,s749571096,Accepted,"X = int(input()) X = 2000 - (X+1) X //= 200 print(X + 1) " p02862,s572948211,Accepted,"X, Y = map(int, input().split()) import math mod = pow(10,9) + 7 a = 2*Y -X b = 2*X -Y if a % 3 == 0 and b % 3 == 0 and a >= 0 and b >= 0: k = a // 3 l = b // 3 c = max(k, l) d = min(k, l) bunshi = 1 bunbo = 1 for i in range(c+1,c+d+1): bunshi = bunshi * i % mod for i in range(1,d+1): bunbo = bunbo * i % mod ans = bunshi * pow(bunbo, mod-2, mod) % mod print(ans) else: print(0) " p02987,s484567503,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')" p03163,s693654348,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] = max(dp[i-1][j], dp[i-1][j-1]) print(dp[N][W])" p02761,s482499214,Accepted,"n,m,*z=map(int,open(0).read().split()) for i in range(10**n): S=str(i) if len(S)==n: if all(S[s-1]==str(c)for s,c in zip(z[0::2],z[1::2])): print(S) quit() print(-1)" p02831,s576705869,Accepted,"import fractions a, b = map(int, input().split()) ab = a * b n = max(a, b) gcd = int(fractions.gcd(a, b)) print(ab // gcd)" p02946,s419444057,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(): K, X = LI() ans = list(range(X - K + 1, X + K)) print(*ans) if __name__ == '__main__': resolve() " p03730,s179738709,Wrong Answer,"a, b, c = map(int, input().split()) rem = a % b tmp = 0 fa = a ans = ""No"" if(rem!=0): while (tmp != rem): a += fa tmp = a % b if (tmp == c): ans = ""Yes"" break else: if(c==0): ans = ""Yes"" print(ans)" p02646,s560102130,Accepted,"A, V = map(int, input().split()) B, W = map(int, input().split()) T = int(input()) S = V - W print('NO' if S <= 0 or abs(A - B) > T * S else 'YES')" p02848,s567031146,Accepted,"n=int(input()) s,ans=list(input()),'' for i in s: ans+=chr((ord(i)-65+n)%26+65) print(ans)" p03773,s917230421,Accepted,"n, m = map(int, input().split()) print((n+m)%24)" p02629,s095651598,Accepted,"import string def resolve(): N = int(input()) alphabets = string.ascii_lowercase base_number = 26 ans = '' while N > 0: N -= 1 ans += alphabets[N % base_number] N = N // base_number print(ans[::-1]) resolve()" p02784,s253168854,Wrong Answer,"H, N = map(int,(input().split())) A = list(map(int,(input().split()))) sum=0 for i in range(len(A)): sum += A[i] if(sum>=N): print(""Yes"") else: print(""No"")" p02681,s377552586,Accepted,"s = input() t = input() if t == s + t[-1]: print (""Yes"") else: print (""No"")" p02773,s932907872,Accepted,"n = int(input()) dict = {} max = 1 for i in range(n): str = input() if str in dict: dict[str] = dict[str] + 1 if dict[str] > max: max += 1 else: dict[str] = 1 keys = [k for k, v in dict.items() if v == max] keys.sort() for i in range(len(keys)): print(keys[i])" p03011,s516695708,Accepted,"import sys def input(): return sys.stdin.readline().rstrip() def main(): p, q, r = map(int, input().split()) m = max([p, q, r]) if m == p: print(q + r) elif m == q: print(p + r) elif m == r: print(p + q) if __name__ == '__main__': main() " p02748,s515987411,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 i in range(M): c =list(map(int,input().split())) s = a[c[0]-1]+b[c[1]-1]-c[2] ans = min(s,ans) print(ans)" p03617,s296259697,Accepted,"q,h,s,d=map(int,input().split()) n=int(input()) ans=int(0) q*=4 h*=2 if n%2==1: ans+=min([q,h,s]) n-=1 n//=2 ans+=n*min([2*q,2*h,2*s,d]) print(int(ans))" p02584,s542126866,Accepted,"def resolve(): x,k,d = map(int,input().split()) if x < 0: x = -x if k*d > x: g = x//d * d if (k - x//d) % 2 == 0: print(x - g) else: print(abs(x-g-d)) else: print(x-k*d) resolve()" p02570,s534189457,Accepted,"d,t,s=map(int,input().split()) print('Yes' if d<=t*s else 'No')" p03059,s660979367,Accepted,"#!/usr/bin/env python3 # N = int(input()) # S = input() A, B, T= map(int, input().split()) # A = list(map(int, input().split())) i = 0 while (i + 1) * A <= T + 0.5: i += 1 print(B * i)" p02948,s357619700,Accepted,"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]: heapq.heappush(q, -j) if len(q) != 0: ans += -heapq.heappop(q) print(ans)" p02584,s954329448,Accepted,"x,k,d = map(int,input().split()) ab = abs(x)//d ab_1 = ab +1 koho1 = abs(x) - abs(d*ab) koho2 = abs(abs(x) -abs(d*ab_1)) tmp = k-ab koho_s = [] if(tmp > 0): if(tmp%2 == 0): ans = koho1 else: ans = koho2 elif(tmp == 0): ans = koho1 else: ans = abs(x) - abs(d*k) print(ans) " p03627,s963985897,Accepted,"import sys stdin = sys.stdin sys.setrecursionlimit(10**6) ni = lambda: int(ns()) na = lambda: list(map(int, stdin.readline().split())) nn = lambda: list(stdin.readline().split()) ns = lambda: stdin.readline().rstrip() import collections n = ni() a = na() c = collections.Counter(a) k = 0 for i,j in sorted(c.items())[::-1]: if j < 2: continue if k > 0: print(k*i) exit() elif j >= 4: print(i*i) exit() else: k = i print(0)" p03030,s911230637,Wrong Answer,"N = int(input()) W = [list(input().split()) for _ in range(N)] S = sorted(W) for i in range(N): for j in range(i+1, N): if S[i][0] == S[j][0] and int(S[i][1]) < int(S[j][1]): a = S[i] S[i] = S[j] S[j] = a else: break for k in range(N): print(W.index(S[k])+1)" p03657,s368663524,Wrong Answer,"a, b = map(int, input().split()) if a % 3 == 0 or b % 3 == 0 or (a+b) % 3 == 0: print('Yes') else: print('No')" p03131,s797952185,Wrong Answer,"k,a,b=map(int,input().split()) if b/a<=2 or k-1 abs(aji[i]): eat = abs(aji[i]) # eat は正の値 if min(aji) >0: print(total-eat) else: print(total+eat)" p03208,s928923961,Accepted,"# C - Christmas Eve N, K = map(int, input().split()) h = [] for _ in range(N): h.append(int(input())) h.sort() diffs = [] for i in range(K-1, N): diffs.append(h[i] - h[i-(K-1)]) print(min(diffs))" p03219,s371468101,Wrong Answer,"print(exec(input().replace("" "",""+"")+""//2""))" p03285,s603013881,Accepted,"n = int(input()) flag = 0 for i in range(14): for j in range(25): if 7*i + 4*j == n: flag = 1 break if flag: print('Yes') else: print('No')" p02676,s777818266,Accepted,"K = int(input()) S = input() if len(S) <= K: print(S) else: str = S[:K]+'...' print(str)" p03105,s177426589,Accepted,"A,B,C=map(int,input().split()) print(min(C,B//A))" p02732,s704298942,Wrong Answer,"import collections import copy def f(l): return l*(l-1) n=int(input()) a=list(map(int,input().split())) b=collections.Counter(a) print(b) for x in a: c=copy.deepcopy(b) c[x]-=1 d=c.values() e=0 for y in d: e+=f(y) print(e//2)" p03274,s870186526,Accepted,"n, k = map(int,input().split()) x = list(map(int, input().split())) lis = [0] for i in range(1,n): lis.append(lis[i-1] + abs(x[i]-x[i-1])) #print(lis) #print(x) ans = int(1e10) for i in range(n-k+1): val = min(abs(x[i]),abs(x[i+k-1])) + (lis[i+k-1]-lis[i]) #print(val,ans) #print(ans) if val < ans: ans = val print(ans)" p03627,s671067729,Accepted,"from collections import defaultdict N = int(input()) A = list(map(int,input().split())) hasOne = defaultdict(bool) E = [] for a in A: if not hasOne[a]: hasOne[a] = True else: E.append(a) hasOne[a] = False E.sort(reverse=True) if len(E) < 2: print(0) else: print(E[0] * E[1]) " p02606,s022711814,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,s335919275,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)] dp[0] = [N[0], 10 - N[0]] for i in range(1, L): n = N[i] 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])" p02702,s439716294,Accepted,"from collections import Counter S=input() rlist=[0] for i in range(len(S)): rlist.append((rlist[-1]+int(S[-i-1])*pow(10,i,2019))%2019) c = Counter(rlist) c[0] -= 1 def nC2(n): return n*(n-1)//2 ans = c[0] for k in c.keys(): if c[k] >= 2: ans += nC2(c[k]) print(ans)" p02725,s498212593,Wrong Answer,"K, N = map(int, input().split()) an = list(map(int, input().split())) dis =[] dis.append(an[0] + K - an[len(an)-1]) for i in range(N-1): dis.append(an[i+1]-an[i]) work = sorted(dis) print(work[0]+ work[1]) " p03086,s428334612,Accepted,"s = input() max = 0 count = 0 for i in range(len(s)): if s[i] == 'A' or s[i] == 'C' or s[i] == 'G' or s[i] == 'T': count += 1 if max < count: max = count else: count = 0 print(max) " p02939,s508396759,Accepted,"S=input() now="""" ans=0 flag=0 for s in S: if flag==1: #2文字目に突入したとき now="""" ans+=1 flag=0 else: if now==s: flag=1 else: now=s ans+=1 print(ans)" p03836,s432429502,Accepted,"sx,sy,tx,ty = map(int,input().split()) no1 = '' for i in range(ty-sy): no1 += 'U' for i in range(tx-sx): no1 += 'R' no2 = '' for i in range(ty-sy): no2 += 'D' for i in range(tx-sx): no2 += 'L' print(no1+no2+'LU'+no1+'RD'+'RD'+no2+'LU') " p03721,s053648374,Accepted,"import sys rl=sys.stdin.readline def main(): n,k=map(int,rl().strip().split()) ints=[list(map(int,rl().strip().split())) for _ in range(n)] ints.sort(key=lambda e:e[0]) s=0 for e in ints: s+=e[1] if s>=k: print(e[0]) break if __name__=='__main__': main() " p02838,s012120638,Wrong Answer,"n = int(input()) a = [int(i) for i in input().split()] mod = 10 ** 9 + 7 ans = 0 for i in range(60): b = sum(map(lambda x: (x >> i)&1, a)) c = n - b ans += b * c * i % mod print(ans%mod) " p02572,s407308242,Accepted,"n= int(input()) a = list(map(int,input().split())) allsum= sum(a) ans = 0 for i in range(n): allsum = allsum -a[i] ans += a[i]*allsum o = ans % (10**9+7) print(o)" p03035,s273352233,Accepted,"def main(): a, b = map(int, input().split()) if a >= 13: ans = b elif a >= 6: ans = int(b / 2) else: ans = 0 print(ans) if __name__ == ""__main__"": main() " p02602,s207696652,Accepted,"import functools import operator n = functools.partial(functools.reduce, operator.mul) N,K = map(int,input().split()) A = list(map(int,input().split())) # print(n(A)) for i in range(K,N): if A[i-K] < A[i]: print(""Yes"") else: print(""No"") " p02772,s256617926,Accepted,"n = int(input()) a = list(map(int, input().split())) b = [] for i in a: if i % 2 == 0: if i % 3 == 0 or i % 5 == 0: pass else: print(""DENIED"") break else: print(""APPROVED"") " p02606,s844342374,Wrong Answer,"a, b, n = map(int, input().split()) print((b-a+1)//n)" p02707,s724323469,Accepted,"n = int(input()) a = list(map(int, input().split())) num_buf = [0] * n for i in range(n - 1): num_buf[a[i] - 1] += 1 for i in range(len(num_buf)): print(num_buf[i])" p02988,s172105300,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] and p[i] < p[i+1] : ans += 1 elif p[i+1] < p[i] and p[i] < p[i-1] : ans += 1 print(ans) " p03250,s906148420,Accepted,"l=list(map(int,input().split())) l.sort(key=int) print(int(str(l[-1])+str(l[-2]))+l[0])" p03838,s752421338,Accepted,"x,y = map(int,input().split()) ax = abs(x) ay = abs(y) if ax == ay and x != y: a = 1 elif x > y and 0 < y: a = ax - ay + 2 elif x > y and y == 0: a = ax - ay + 1 elif x > y and 0 > y: if ay > ax and x >= 0: a = ay - ax + 1 elif ay > ax and x < 0: a = ay - ax + 2 elif ax > ay: a = ax - ay + 1 elif y > x and x < 0 and ay > ax: a = ay - ax + 1 elif y > x and x < 0 and y > 0 and ax > ay: a = ax - ay + 1 else: a = y-x print(a)" p02712,s593437897,Accepted,"n = int(input()) a = 0 for i in range(1,n+1): if not ((i%3 == 0)or (i%5 == 0)): a += i print(a) " p02952,s479694144,Wrong Answer,"n=int(input()) length = len(str(n)) ans = 0 if(length%2==1): ans += n%(10**(length-1)) for i in range(0,length-1): if(i%2==1): ans +=10**i print(ans) " p03324,s777526346,Wrong Answer,"d,n = map(int,input().split()) if d == 0: num = 1 * n print(num) if d == 1: num = 100 * n print(num) if d == 2: num = 10000 * n print(num)" p03705,s315387075,Accepted,"N, A, B = map(int, input().split()) if A>B: print(0) exit() ans = (B*(N-1)+A) - (A*(N-1)+B) + 1 print(max(ans,0))" p03013,s862397603,Wrong Answer,"def main(): N, M = map(int, input().split()) A = set() for _ in range(M): a = int(input()) A.add(a) mod = 10**9 + 7 dp = [0] * (N+1) dp[0] = 1 if 1 not in A: dp[1] = 1 for i in range(1, N+1): if i not in A: dp[i] = dp[i-1] + dp[i-2] dp[i] %= mod return dp[-1] print(main()) " p02939,s828332157,Accepted,"s = input() n = len(s) ans = 1 l = '' k = s[0] for i in range(1,n): if l + s[i] != k : k = l + s[i] l ='' ans += 1 else: l += s[i] print(ans)" p03449,s131084177,Accepted,"def main(): N = int(input()) A = [list(map(int, input().split())) for _ in range(2)] ans = list() for i in range(N): ans.append(sum(A[0][0:i+1]) + sum(A[1][i:])) print(max(ans)) if __name__ == ""__main__"": main() " p02819,s200770374,Accepted,"x=int(input()) if x==2: print(2) else: while True: cnt=0 if x%2==0: x+=1 continue for i in range(2,x): if x%i==0: cnt=1 continue if cnt==1: x+=1 else: print(x) break" p02694,s782865000,Accepted,"import math X= int(input()) ans = 0 get = 100.0 while X > get: ans += 1 get += math.floor(get*0.01) print(ans)" p03455,s251906820,Accepted,"a, b = map(int, input().split()) if a * b % 2 == 0: print(""Even"") else: print(""Odd"")" p03433,s176240859,Accepted,"n = int(input()) a = int(input()) if n % 500: if (n % 500) <= a: print(""Yes"") else: print(""No"") else: print(""Yes"") " p02577,s418183440,Accepted,"A=input() B=int(9) i,j=divmod(int(A),int(B)) if j == 0: j=""Yes"" else: j=""No"" print(j)" p03799,s737986189,Accepted,"N,M = map(int,input().split()) if M//N < 2: print(M//2) else: # 交換できる回数の最大値は M - 2x = 2*(N + x) より求めた x = (M-2*N)//4 print(N+x)" p02639,s246552541,Accepted,"x = list(map(int, input().split())) for i in range(5): if x[i] == 0: print(i+1) break" p02682,s998884690,Accepted,"A, B, C, K = map(int, input().split()) if A >= K: nmax = K elif B >= K-A: nmax = A else: nmax = A-(K-A-B) print(nmax)" p03774,s783031745,Wrong Answer,"n,m = map(int,input().split()) x = [] y = [] for _ in range(n): a,b = map(int,input().split()) x.append([a,b]) for _ in range(m): c,d = map(int,input().split()) y.append([c,d]) for i in range(n): t = 10**8*2 ans = 0 for j in range(m): if t > abs(y[j][0]-x[i][0])+abs(y[j][1]-x[i][1]): ans = j+1 t = abs(y[j][0]-x[i][0])+abs(y[j][1]-x[i][1]) print(ans) " p02596,s180921984,Accepted,"import sys K=int(input()) if K%2==0 or K%5==0: print(-1) sys.exit(0) k_mod=0 seven_k=0 for i in range(1,K+1): k_mod=10*k_mod+7 k_mod%=K if k_mod==0: print(i) break else: print(-1)" p02787,s455688744,Accepted,"import sys import numpy as np h, n = map(int, input().split()) ab = np.array(sys.stdin.read().split(), dtype=np.int64) aaa = ab[0::2] bbb = ab[1::2] dp = np.zeros(10001, dtype=np.int64) for i in range(1, h + 1): dp[i] = (dp[i - aaa] + bbb).min() print(dp[h]) " p02801,s690348340,Accepted,print(chr(ord(input())+1)) p02933,s042548042,Accepted,"a = int(input()) s = input() if a >= 3200: print(s) else: print('red')" p02663,s406487695,Accepted,"#[int(x) for x in input().split()] #map(int,input().split()) #for _ in range(int(input())): a,b,c,d,k=map(int,input().split()) strt=a*60+b end=c*60+d print(end-k-strt)" p02777,s320663133,Wrong Answer,"s, t = input().split() a, b = map(int, input().split()) u=input() if(u==s): print(a-1) else: print(b-1)" p03067,s571763690,Wrong Answer,"a,b,c = map(int,input().split()) print(""No"" if (a>j&1: c += cost[j] for k in range(m): skills[k] += sup[j][k] if min(skills)>=x: if ans < 0: ans = c elif c10 : ans = r else: ans = r+(100*(10-n)) print(ans)" p02761,s960050448,Wrong Answer,"import sys input = sys.stdin.readline N, M = map(int, input().split()) t = [tuple(map(int, input().split())) for _ in range(M)] for x in range(10 ** N): f = 1 for i in range(M): s = str(x) y, c = t[i] if len(s) < y or (len(s) < N): f = 0 break if int(s[y - 1]) != c: f = 0 break if f: print(x) exit(0) print(-1)" p03030,s865004067,Accepted,"import sys def input(): return sys.stdin.readline().strip() def resolve(): l=[] n=int(input()) for i in range(n): s,p=input().split() ll=[s,int(p),i+1] l.append(ll) lll = sorted(l, key=lambda x:x[1], reverse=True) llll=sorted(lll,key=lambda x:x[0]) for s,p,i in llll: print(i) resolve()" p02819,s653819308,Accepted,"import math x = int(input()) for i in range(x, x * 2): flag = True for j in range(2, math.floor(math.sqrt(x))+1): if i % j == 0: flag = False break if flag: print(i) exit(0)" p04019,s553688605,Accepted,"s = input().strip() counts = { 'N': 0, 'W': 0, 'S': 0, 'E': 0 } for c in s: counts[c] += 1 def judge(): if counts['N'] > 0 or counts['S'] > 0: if counts['N'] * counts['S'] == 0: return False if counts['W'] > 0 or counts['E'] > 0: if counts['W'] * counts['E'] == 0: return False return True if judge(): print('Yes') else: print('No') " p02577,s381766379,Wrong Answer,"N = int(input()) n = str(N) le = len(n) M = [] for i in range(le): nn = int(n[i]) M.append(nn) if sum(M) % 9 == 0: print(""Yes"") else: print(""No"") print(M)" p02684,s574902560,Accepted,"N,K=map(int,input().split()) A=[int(a)-1 for a in input().split()] if K<=N: p=0 for i in range(K): p=A[p] print(p+1) exit() p=0 t=[-1]*N t[0]=0 for i in range(1,N): p=A[p] if t[p] !=-1: break t[p]=i d=i-t[p] K-=i K%=d for i in range(K): p=A[p] print(p+1)" p02790,s987720037,Accepted,"A, B = map(str.strip, input().split()) print(sorted([A*int(B), B*int(A)])[0]) " p02993,s324775972,Wrong Answer,"n=list(map(int, input().split())) for i in range(len(n)): if n[i]==n[i-1]: print('Bad') break else: print('Good')" p03951,s113191447,Accepted,"N = int(input()) S = input() T = input() if S == T: print(N) else: ans = 2 * N for i in range(N): if S[i:] == T[:N - i]: ans -= len(S[i:]) break print(ans)" p02823,s212707271,Wrong Answer,"N, A, B = list(map(int, input().split())) diff = B - A if diff % 2 == 0: ans = diff / 2 else: # 左端で会う d1 = A - 1 # Aが左に到達するまでにd戦する ans1 = d1 + (diff - 1) / 2 + 1 # 右端で会う d2 = N - B # Bが右端まで到達するのにd戦必要 ans2 = d2 + (diff - 1) / 2 + 1 ans = min(ans1, ans2) # print(ans1, ans2) print(round(ans)) " p02916,s365535529,Accepted,"a=int(input()) n=list(map(int,input().split())) m=list(map(int,input().split())) o=list(map(int,input().split())) result1=0 for i in range(0,a-1): if n[i]+1==n[i+1]: result1+=o[n[i]-1] for i in range(a): result1+=m[n[i]-1] print(result1)" p02948,s580027415,Accepted,"from heapq import * n,m=map(int,input().split()) ab=[] ans=[[] for i in range(m)] aa=0 for i in range(n): a,b=map(int,input().split()) a-=1 b*=-1 ab.append((a,b)) ab.sort() t=[] heapify(t) for a,b in ab: if a0: tt=heappop(t)*(-1) aa+=tt print(aa)" p02631,s366847821,Wrong Answer,"N = int(input()) a = [int(i) for i in input().split()] ans = [] for x in a: s = '1'*(len(str(x))) ans.append(x^int(s)) print(*ans)" p03351,s167725418,Wrong Answer,"a, b, c, d = map(int, input().split()) print(abs(a-b)) if (abs(a-b) <= d and abs(b-c) <= d) or abs(a-c) <= d: print(""Yes"") else: print(""No"")" p03612,s765930071,Accepted,"def main(): N = int(input()) permutation = list(map(int, input().split())) answer = 0 for i in range(N): if permutation[i] == i + 1: if permutation[i] == N: permutation[i], permutation[i - 1] = permutation[i - 1], permutation[i] else: permutation[i], permutation[i + 1] = permutation[i + 1], permutation[i] answer += 1 print(answer) if __name__ == '__main__': main()" p03644,s514716748,Wrong Answer,"N = int(input()) res = 1 while (res << 1) < N: res = res << 1 print(res) " p02615,s089693712,Accepted,"n = int(input()) a = list(map(int, input().split())) a.sort(reverse=True) score = - a[0] for i in range(n): score += a[i // 2] print(score)" p03377,s174139095,Accepted,"import math import itertools #n = int(input()) #n, d = list(input().split()) A, B, X= list(map(int, input().split())) if A == X or (A < X and A+B > X) : print(""YES"") else: print(""NO"")" p02647,s184600534,Accepted,"import math N, K = map(int, input().split()) K = min(41, K) A = list(map(int, input().split())) A.insert(0, 0) def operation(): global A, N B = [0] * (N+1) for i in range(1, N+1): left = max(1, math.ceil(i - A[i] - 0.5)) right = min(N, math.floor(i + A[i] + 0.5)) B[left] += 1 if right+1 <= N: B[right+1] -= 1 for i in range(1, N+1): B[i] += B[i-1] return B operation() #print(A) #print(B) for _ in range(K): A = operation() print(*A[1:]) " p02760,s508460482,Accepted,"from collections import defaultdict d = defaultdict(int) for i in range(3): a = list(map(int,input().split())) for j in range(3): d[a[j]] = 3*i+j+1 f = [False for _ in range(10)] N = int(input()) for _ in range(N): b = int(input()) f[d[b]] = True ans = False for i in range(3): ans = ans or (f[3*i+1] and f[3*i+2] and f[3*i+3]) ans = ans or (f[i+1] and f[i+4] and f[i+7]) ans = ans or (f[1] and f[5] and f[9]) ans = ans or (f[3] and f[5] and f[7]) if ans: print(""Yes"") else: print(""No"")" p02832,s116700083,Accepted,"N = int(input()) a = list(map(int, input().split())) i = 1 for j in range(N): if i == a[j]: i += 1 if i == 1: print(-1) else: print(N+1-i)" p02717,s736725790,Accepted,"X,Y,Z=map(int,input().split());print(Z,X,Y)" p02726,s556945473,Accepted,"n,x,y = map(int, input().split()) x -= 1 y -= 1 ans = [0] * (n-1) for j in range(n): for i in range(j): ans[min(j-i, abs(x-i)+1+abs(j-y)) - 1] += 1 print(""\n"".join([str(d) for d in ans]))" p02832,s986331516,Accepted,"n = int(input()) A=[int(i) for i in input().split()] t = 1 ans=0 for i in A: if i==t: t+=1 else: ans+=1 print(ans if t!=1 else -1) " p03910,s759032939,Accepted,"N=int(input()) n=0 S=1 while S 0 and South > 0) or (North == 0 and South == 0)) and ((East > 0 and West > 0) or (East == 0 and West == 0)): print(""Yes"") else: print(""No"") " p02793,s517080596,Accepted,"N = int(input()) A = list(map(int,input().split())) def gcd(a,b): a,b = max(a,b),min(a,b) while a%b!=0: a,b = b,a%b return b mod = 10**9 + 7 l = A[0] for i in range(1,N): l = (A[i]//gcd(A[i],l))*l ans = 0 for i in range(N): ans+=l//A[i] print(ans%mod)" p03309,s244384436,Wrong Answer,"n = int(input()) A = [int(x) - int(i) for i, x in enumerate(input().split(), 1)] b = sum(A)//n res1 = 0 for a in A: res1 += abs(a - b) b += 1 res2 = 0 for a in A: res2 += abs(a - b) print(min(res1, res2))" p02795,s760290546,Accepted,"H, W, N = int(input()), int(input()), int(input()) print((N+max(H, W)-1)//max(H, W)) " p02912,s881826704,Accepted,"from heapq import * n,m = map(int,input().split()) a = list(map(int,input().split())) heap = [] for i in a: heappush(heap,-i) for _ in range(m): tmp = heappop(heap) heappush(heap,-(-tmp//2)) ans = 0 for a in heap: ans += -a print(ans)" p03449,s086159253,Accepted,"n = int(input()) lsa = list(map(int,input().split())) lsb = list(map(int,input().split())) p = 0 t = [] for i in range(n): if i ==0: p += sum(lsb) + lsa[0] t.append(p) p = 0 else: p += sum(lsa[:i+1]) + sum(lsb[i:]) t.append(p) p = 0 print(max(t)) " p03038,s077621276,Accepted,"n,m=map(int,input().split()) a=list(map(int,input().split())) bc=[list(map(int, input().split())) for _ in range(m)] sorted_ab=sorted(bc, reverse=True, key=lambda x: x[1]) new_ab=[] ans=[] for i in range(m): if len(new_ab)<=n: tmp_l=[sorted_ab[i][1]]*sorted_ab[i][0] new_ab+=tmp_l else: break final_list=a+new_ab final_list.sort(reverse=True) print(sum(final_list[:n]))" p03478,s004091038,Accepted,"n, a, b= map(int, input().split()) ALlsum = 0 for i in range(1, n+1): sum = 0 i = str(i) i_len = len(i) for j in range(i_len): sum += int(i[j]) if a<=sum and sum<=b : ALlsum += int(i) print(ALlsum)" p03251,s181486061,Accepted,"N,M,X,Y=map(int,input().split()) x=list(map(int,input().split())) y=list(map(int,input().split())) z=[] for i in range(X+1,Y+1): if max(x)=i: z.append(i) if len(z)>=1: print('No War') else: print('War')" p02817,s205200232,Accepted,"S, T = map(str,input().split()) print(T+S)" p03472,s504038375,Accepted,"N, H = map(int, input().split()) AB = [tuple(map(int, input().split())) for _ in range(N)] A, B = [], [] for a, b in AB: A.append(a) B.append(b) maxA = max(A) B_stack = [] for b in B: if b > maxA: B_stack.append(b) B_stack.sort() B_stack = B_stack[::-1] answer = 0 for b in B_stack: H -= b answer += 1 if H <= 0: print(answer) exit() answer += -(-H // maxA) print(answer)" p02897,s105217882,Wrong Answer,"N=int(input()) odd=0 for i in range(1,N+1): if i%2==0: odd+=1 print(odd/N) " p03262,s045686561,Accepted,"import fractions n,X= map(int,input().split()) x = list(map(int, input().split())) x.append(X) x = sorted(x) #print(x) difflis = [0] * (n) for i in range(n): difflis[i] = x[i+1] - x[i] ans = difflis[0] for i in range(1,len(difflis)): ans = fractions.gcd(ans,difflis[i]) print(ans)" p03494,s227837905,Wrong Answer,"number = int(input()) integers = list(map(int, input().split("" ""))) counter = 0 while True: if integers[0]%2 == 0 \ and integers[1]%2 == 0 \ and integers[2]%2 == 0: counter += 1 integers = [pivot/2 for pivot in integers] else: break print(counter)" p02571,s216389462,Wrong Answer,"S = input() T = input() min_count = 10000000 for k in range(len(T)): for i in range(len(S)-len(T)+1): count = k if T[k] == S[k+i]: for j in range(1,len(T)-k): if S[i+j] != T[k+j]: count += 1 if count < min_count: min_count = count print(min_count)" p02792,s012099229,Accepted,"N = int(input()) count = [[0 for _ in range(9)] for _ in range(9)] for i in range(1, N + 1): s = str(i) prefix = int(s[0]) surfix = int(s[-1]) if surfix != 0: count[prefix - 1][surfix - 1] += 1 ans = 0 for i in range(9): for j in range(9): ans += count[i][j] * count[j][i] print(ans) " p02622,s371779333,Accepted,"a=list(input()) b=list(input()) c=0 d=0 for x in a: if x!=b[d]: c +=1 d+=1 print(c)" p03971,s828799204,Accepted,"n,a,b=map(int,input().split()) s=input() clear=0 bclear=0 for i in range(n): if (s[i]==""a""): if (clear=len(h): print(0) else: h = h[k:] print(sum(h))" p03327,s089518294,Accepted,"print(['ABC', 'ABD'][len(input())==4])" p03607,s389969703,Wrong Answer,"n,*a=open(0).read().split() s=set() for i in a: s^=set(i) print(len(s))" p02688,s220969021,Accepted,"N,K = map( int ,input().split()) N_list = [0]*N for i in range(K): d = int(input()) num_list = [int(i) for i in input().split()] for j in range(len(num_list)): N_list[num_list[j]-1] +=1 print(N_list.count(0))" p02793,s297386184,Accepted,"def gcd(n,m): if n>m: return gcd(m,n); if n==0: return m; return gcd(m-n*(m//n),n) def lcm(x, y): return (x * y) // gcd(x, y) n=int(input()) a=list(map(int,input().split())) s=1 for i in a: s=lcm(s,i) ans=0 for i in a: ans+=s//i print(ans % 1000000007)" p03611,s327778035,Accepted,"# 2020/02/01 # AtCoder Beginner Contest 072 - C # Input n = int(input()) a = list(map(int, input().split())) cntlist = [0] * (10 ** 5 + 2) # Count for i in range(n): for j in range(-1, 2): wk_val = a[i] + j if wk_val < 0: wk_val = 10**5 + 1 cntlist[wk_val] = cntlist[wk_val] + 1 ans = max(cntlist) # Output print(ans) " p03317,s356374564,Accepted,"n,k = map(int,input().split()) a = list(map(int,input().split())) i = 1 while n > k + (k-1)*(i-1): i += 1 print(i) " p03852,s301976624,Wrong Answer,"c=str(input()) if c==""a""or""i""or""u""or""e""or""o"": print(""vowel"") else: print(""consonant"")" p03087,s264993581,Accepted,"n,q = map(int,input().split()) s = input() cnt = [0]*(n+1) p = s[0] for i in range(1,n+1): if p == ""A"" and s[i-1] == ""C"": cnt[i] = cnt[i-1] +1 else: cnt[i] = cnt[i-1] p = s[i-1] for i in range(q): l,r = map(int,input().split()) print(cnt[r] - cnt[l]) " p02684,s044543239,Accepted,"n,k=map(int,input().split()) A=list(map(int,input().split())) time=0 color=[""white"" for _ in range(n+1)] D=[-1 for _ in range(n+1)] C,s=[],A[0] point=0 while 1: if color[s]==""white"": color[s]=""gray"" C.append(s) D[s]=time time +=1 s=A[s-1] else: point=D[s] break loop=C[point:] if k>len(C): k -=point+1 print(loop[k%len(loop)]) else:print(C[k-1])" p03243,s032653720,Accepted,"N=input() n=int(N) head=N[0] tmp=int(head*3) if n>tmp: t=str(int(head)+1) print(t*3) else: print(tmp)" p02690,s336562580,Accepted,"x = int(input()) a = -1000 b = -1000 for _ in range(2000): for _ in range(2000): if (a ** 5) - (b ** 5) == x: print('{0} {1}'.format(a,b)) exit() b += 1 b = -2000 a += 1" p02647,s021401707,Accepted,"n,k = map(int,input().split()) now = list(map(int,input().split())) #import heapq for _ in range(k): last = now now = [] imos = [0 for _ in range(n+1)] for i in range(n): l = max(0,i-last[i]) r = min(n,i+last[i]+1) imos[l] += 1 imos[r] -= 1 now.append(imos[0]) for i in range(1,n): now.append(now[-1]+imos[i]) #print(now) if sum(now) == n**2: print(' '.join(map(str,now))) exit() print(' '.join(map(str,now)))" p02900,s453864084,Wrong Answer,"from fractions import gcd a,b = map(int,input().split()) c = gcd(a,b) max_n = int(c**(1/2))+1 primes = [2] cand = list(range(3,max_n+1, 2)) while(cand): next = [] div = cand[0] primes.append(div) for i in range(1,len(cand)): tmp = cand[i] if(tmp%div != 0): next.append(tmp) cand = next[::] nums = 1 for i in primes: if(c%i==0): nums += 1 print(nums)" p02771,s662144347,Accepted,"ABC=list(map(int,input().split())) if len(set(ABC))==2: print(""Yes"") else: print(""No"")" p03109,s838917612,Wrong Answer,"print(""Heisei"" if input()<=""2019/4/30"" else ""TBD"") " p03416,s646214058,Accepted,"A,B = map(int,input().split()) cnt = 0 for i in range(A,B+1): i = str(i) if i[0] == i[4] and i[1] == i[3]: cnt += 1 print(cnt)" p02598,s594898619,Accepted,"n,k = map(int,input().split()) A = list(map(int,input().split())) if sum(A)-n <= k: print(1) exit() elif k == 0: print(max(A)) exit() top = 10**9 bottom = 1 def ok(x): res = 0 for a in A: res += (a-1)//x return res <= k while top - bottom > 1: mid = (top + bottom)//2 if ok(mid): top = mid else: bottom = mid print(top) " p02554,s851316819,Accepted,"n = int(input()) ans = 10**n - 9**n - 9**n + 8**n print(ans%(10**9 + 7))" p03069,s685860383,Accepted,"N=int(input()) S=input() Wcum=[0]*(N+1) Bcum=[0]*(N+1) for i in range(N): Wcum[i+1]=Wcum[i]+(S[i]=='.') Bcum[i+1]=Bcum[i]+(S[i]=='#') ans=N for i in range(N+1): ans=min(ans,(i-Wcum[i])+(N-i-(Bcum[N]-Bcum[i]))) print(ans)" p03105,s462533504,Accepted,"line = input() A,B,C = [int(n) for n in line.split()] print(min(B//A,C))" p02796,s072514283,Accepted,"n = int(input()) lis = [] for i in range(n): a,b =map(int,input().split()) lis.append([a-b,a+b]) lis.sort(key = lambda x:x[1]) ans = 0 now = -10 ** 10 for a,b in lis: if now <= a: ans += 1 now = b print(ans)" p02570,s159211393,Accepted,"D, T, S = map(int, input().split()) if D / S <= T: print('Yes') else: print('No') " p03556,s666810901,Accepted,"N = int(input()) X = int(N ** 0.5) print(X **2)" p02957,s312780477,Accepted,"#!/usr/bin/env python3 # -*- coding: utf-8 -*- def main(): A, B = map(int, input().split()) print(int((A + B) / 2)if (A + B) % 2 == 0 else 'IMPOSSIBLE') if __name__ == ""__main__"": main() " p03681,s606063227,Accepted,"n,m = map(int,input().split()) def kai(n): u = 1 for i in range(1,n+1): u = (u*(i%(10**9+7)))%(10**9+7) return u if abs(n-m)==1: print((kai(n)*kai(m))%(10**9+7)) elif n-m==0: print((kai(n)*kai(m)*2)%(10**9+7)) else: print(0)" p02819,s663728975,Wrong Answer,"x = int(input()) for val in range(x, x**100) : if x ==2 : print(x) break elif ((2** (val-1)) % val) == 1 : print (val) break else : continue" p02661,s763788305,Accepted,"N = int(input()) A,B = [0]*N,[0]*N for i in range(N): A[i],B[i] = map(int,input().split()) A = sorted(A) B = sorted(B) if N%2 == 1: ans = B[int((N-1)/2)] - A[int((N-1)/2)] + 1 elif N%2 == 0: ans = B[int(N/2)] + B[int(N/2-1)] - A[int(N/2)] - A[int(N/2-1)] + 1 print(ans)" p03001,s985559594,Accepted,"w, h, x, y = map(int, input().split()) if x == w/2 and y == h/2: print(w*h/2, 1) else: print(w*h/2, 0)" p02939,s218387752,Accepted,"s = input() i = 0 start = 0 pre = """" ans = 0 while i < len(s): if i < len(s) and s[start: i + 1] != pre: pre = s[start: i + 1] start = i + 1 ans += 1 i += 1 print(ans) " p02720,s266241603,Accepted,"from collections import deque K = int(input()) q = deque() for i in range(1,10): q.append(i) ans=0 if K>=10: cnt = 9 while len(q)>0: current = q.popleft() dn = [-1,0,1] for i in dn: if current%10+i<0 or current%10+i>9 or cnt>=K: continue q.append(current*10+current%10+i) cnt+=1 else: ans=current else: ans = K print(ans)" p02957,s756349532,Wrong Answer,"#k = int(input()) #s = input() #a, b = map(int, input().split()) #s, t = map(str, input().split()) a, b = map(int, input().split()) if (a+b)%2 != 0: print(""INPOSSIBLE"") else: print((a+b)//2) " p04034,s491927792,Accepted,"n,m = map(int,input().split()) n += 1 p = [1]*n r = [0]*n r[1] = 1 for i in range(m): x,y = map(int,input().split()) if r[x]: r[y] = 1 if p[x] == 1: r[x] = 0 p[x] -= 1 p[y] += 1 print(sum(r))" p03494,s686068309,Wrong Answer,"n = input() l = input().split() print(1)" p03475,s696332927,Accepted,"import math N = int(input()) CSF = [] for _ in range(N-1): c, s, f = map(int, input().split()) CSF.append((c, s, f)) ans = [] for i in range(N): T = 0 for j in range(i, N-1): T = max(CSF[j][1], math.ceil(T/CSF[j][2])*CSF[j][2]) T += CSF[j][0] ans.append(T) print(*ans, sep='\n') " p03360,s085364999,Wrong Answer,"num_list = list(map(int, input().split())) k = int(input()) tmp_lists = [] for i in range(3): ans_lists = num_list.copy() ans_lists[i] = num_list[i]*(k*2) tmp_lists.append(ans_lists) max = 0 for list in tmp_lists: sum = 0 for k in list: sum += k if max < sum: max = sum print(sum)" p02909,s118762254,Accepted," s=input() if s=='Sunny': print('Cloudy') elif s == 'Cloudy': print('Rainy') else: print('Sunny')" p02690,s024499260,Accepted,"x=int(input()) for a in range(120): for b in range(-120,120): if x==a**5-b**5: print(a,b) exit() " p02796,s246360672,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(lis)" p03962,s250149368,Accepted,"from collections import Counter count = list(map(int, input().split())) count = Counter(count) print(len(count))" p02792,s797403216,Accepted," N = int(input()) dp = [[0 for _ in range(10)] for _ in range(10)] def pair(n): num = str(n) p = int(num[0]) s = n % 10 return (p, s) for i in range(1, N+1): pre, suf = pair(i) dp[pre][suf] += 1 ans = 0 for i in range(1, N+1): suf, pre = pair(i) ans += dp[pre][suf] print(ans)" p02859,s020143396,Accepted,"n = int(input()) print(n**2)" p02971,s722711162,Wrong Answer,"#-*-coding:utf-8-*- import sys input=sys.stdin.readline import heapq def main(): numbers=[] n = int(input()) [numbers.append(int(input().rstrip())) for _ in range(n)] heapq.heapify(numbers) for i in numbers: if i == max(numbers): print(min(heapq.nlargest(2,numbers))) else: print(max(heapq.nlargest(1,numbers))) if __name__==""__main__"": main()" p03261,s135678622,Accepted,"n=int(input()) word_list=[] last_word='aaaa' for i in range(n): w=input() if 00 でabs(a[i])>=abs(a[i+1]) if (a[i] <= 0 and a[i+1]>=0 and abs(a[i]) >= abs(a[i+1])) or (a[i]<=0 and a[i+1]<=0): a[i] *=-1 a[i+1] *=-1 #print(*a) print(sum(a))" p03774,s389909593,Wrong Answer,"import numpy as np from scipy.spatial.distance import minkowski n, m = map(int, input().split()) a = np.array([list(map(int, input().split())) for i in range(n)]) for i in range(m): b = np.array(list(map(int,input().split()))) c = np.array([minkowski(i, b , 1) for i in a], dtype=np.int64) ans = np.argmin(c) + 1 print(ans)" p02958,s895340985,Accepted,"n = int(input()) plist = list(map(int, input().split())) nlist = sorted(plist) ng_cnt = 0 for p, n in zip(plist, nlist): if p != n: ng_cnt += 1 if ng_cnt >2: print('NO') else: print('YES')" p03323,s059318108,Accepted,"A,B=map(int,input().split()) if A<=8 and B<=8: print(""Yay!"") else: print("":("")" p03145,s092445722,Accepted,"# 116a def atc_116a(input_value: str) -> int: tri_length = [int(ai) for ai in input_value.split("" "")] tri_length.sort() return int((tri_length[0] * tri_length[1] / 2)) input_value = input() print(atc_116a(input_value)) " p03645,s786275276,Accepted,"n,m = map(int,input().split()) ab = [[-1] for i in range(n)] for i in range(m): a, b = map(int,input().split()) if ab[a-1][-1] == -1: ab[a-1][-1] = b-1 else: ab[a-1].append(b-1) flg = False for i, mid in enumerate(ab[0]): if n-1 in ab[mid]: flg = True break if flg :print('POSSIBLE') else:print('IMPOSSIBLE') " p02842,s266523165,Accepted,"import math n=int(input()) x=math.ceil(n*100/108) if n==math.floor(x*1.08): print(x) else: print(':(')" p02795,s407820842,Wrong Answer,"h = int(input()) w = int(input()) n = int(input()) if h>w: nBig = h else: nBig = w print(n,nBig) ans = int(n/nBig)+1 print(ans)" p02982,s484539503,Accepted,"n, d = map(int, input().split()) num_list = [] cnt = 0 #2次元リスト作成 for i in range(n): num_list.append(list(map(int, input().split()))) #jx+a else ""safe"")" p02972,s442656155,Wrong Answer,"n = int(input()) A = list(map(int,input().split())) B = [0]*(n+1) m = 0 for i in range(n,0,-1): cnt = 0 for j in range(i,n,i): cnt += B[j] if cnt%2==A[i-1]: continue else: B[i] =1 m += 1 print(m) for i in range(len(B)): if B[i]==1: print(i) " p03607,s014861587,Accepted,"import sys from collections import Counter n, *a = map(int, sys.stdin.read().split()) def main(): res = 0 for v in Counter(a).values(): res += v & 1 print(res) if __name__ == '__main__': main()" p02598,s566956580,Wrong Answer,"import math n,k=map(int,input().split()) a=list(map(int,input().split())) x0, x1 = 0, 10**9 while x0 + 1 < x1: x = (x0+x1)//2 suma=0 for i in a: suma += (i//x) if suma > k: x0 = x else: x1 = x print(x1) " p02633,s499867667,Wrong Answer,"X = int(input()) if 360 % X == 0: ans = 360 // X else: if X > 90: ans = 360 // (180 - X) else: ans = 360 print(ans)" p03163,s241206888,Accepted,"import numpy as np n,W = map(int,input().split()) w,v = [0] * n, [0] * n for i in range(n): w[i] , v[i] = map(int,input().split()) dp = np.zeros((W + 1), dtype=np.uint64) for _w, _v in zip(w, v): np.maximum(dp[_w:], dp[:-_w] + _v, out=dp[_w:]) print(dp[-1]) " p02723,s017586898,Accepted,"S=list(str(input())) if S[2]==S[3] and S[4]==S[5]: print(""Yes"") else: print(""No"")" p02836,s439926188,Wrong Answer,"s=input() score=0 for i in range(0,int(len(s)/2+1)): if s[i]!=s[len(s)-1-i]: score+=1 print(score) " p02866,s927456532,Accepted,"mod = 998244353 n = int(input()) d = list(map(int, input().split())) if d[0] != 0: print(0) exit(0) max_d = max(d) cnt = [0] * (max_d + 1) for num in d: cnt[num] += 1 if cnt[0] > 1: print(0) exit(0) ans = 1 for i in range(1, len(cnt)): ans *= pow(cnt[i - 1], cnt[i], mod) ans %= mod print(ans) " p02983,s361992643,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) else: print(ans) else: print(0)" p02687,s498615332,Accepted,"s=input() if s ==""ABC"": print('ARC') else: print(""ABC"")" p02786,s584448642,Wrong Answer,"import math N = int(input()) didnot = False def waru2(n, didnot): c = 0 while True: if n == 1: break n = int(math.ceil(n/2)) if n != 1 and n % 2 != 0: didnot = True c += 1 return (c, didnot) a, didnot = waru2(N, didnot) c = 0 for i in range(a): c += 2**i if didnot: print(c) else: print(c+N) " p02768,s915153324,Accepted,"from math import factorial n,a,b = map(int,input().split()) MOD = 10**9 + 7 xa = 1 xb = 1 k1 = pow(2,n,MOD) A = pow(factorial(a),MOD-2,MOD) B = pow(factorial(b),MOD-2,MOD) for i in range(a): xa = xa*(n-i)%MOD for j in range(b): xb = xb*(n-j)%MOD ans = (k1 - (A*xa) - (B*xb) - 1)%MOD print(ans)" p02658,s146758027,Wrong Answer,"import numpy as np N=int(input()) A=list(map(int, input().split())) A=np.array(A) ans=np.prod(A) if ans>10**18: print(-1) else: print(ans)" p02572,s938765343,Accepted,"n=int(input()) a=list(map(int,input().split())) sum=0 mod=10**9+7 for i in range(n): sum+=a[i] sum=sum**2 for i in range(n): sum-=a[i]**2 sum=(sum//2)%mod print(sum) " p02953,s505851471,Wrong Answer,"A = int(input()) B = list(map(int,input().split())) now = B[0] for i in range(A-1): if now < B[i+1]-1: print(""No"") exit() if now < B[i+1]: now = B[i+1] print(""Yes"")" p02700,s729516860,Wrong Answer,"n, m, c, d = map(int, input().split()) if (n - m) < (c -d) or (n - m) == 0: print(""No"") else: print(""Yes"")" p03210,s492618427,Wrong Answer,"x = input() if x in [7, 5, 3]: print('YES') else: print('NO')" p02791,s301591913,Accepted,"n = int(input()) a = list(map(int,input().split())) mini = 10**6 ans = 0 for i in range(n): if a[i] < mini: mini = a[i] ans += 1 print(ans)" p03698,s668886747,Wrong Answer,"S = input() S_s = set(S) print(S_s) if len(S)==len(S_s): print(""yes"") else: print(""no"")" p03761,s499896399,Wrong Answer,"n=int(input()) s=[0]*26 for i in range(n): for j in list(input()): s[ord(j)-97]+=1 ans=[] for i in range(26): if n<=s[i]: for j in range(s[i]//n): ans.append(chr(i+97)) ans.sort() print('' if len(ans)= 0: if H < W: N -= W ans += 1 elif W < H: N -= H ans += 1 print(ans)" p02696,s366546329,Accepted,"A,B,N = map(int,input().split()) if N 0: ans.pop() else: continue print(''.join(ans))" p02835,s619543506,Accepted,"sum_input = sum(map(int, input().split())) if sum_input >= 22: print('bust') else: print('win') " p03997,s454062862,Wrong Answer,"a=int(input()) b=int(input()) h=int(input()) S=(a+b)*h/2 print(S)" p02923,s394642608,Accepted,"n = int(input()) l = list(map(int,input().split())) ans = [0] cnt = 0 for i in range(n-1): if l[i] >= l[i+1]: cnt += 1 else: if cnt > 0: ans.append(cnt) cnt = 0 ans.append(cnt) print(max(ans))" p03241,s860892344,Accepted,"import numpy as np def factorization(N): a = [] for i in range(1,int(np.sqrt(N))+1): if N%i == 0: a.append(i) for j in range(len(a)): a.append(N//a[j]) a.sort(reverse=True) return a N,M = map(int,input().split()) f = factorization(M) for i in f: if i <= M/N: print(i) exit()" p02608,s531051827,Accepted,"N = int(input()) fn = [0]*N for x in range(1,100): for y in range(1,100): for z in range(1,100): n=x**2+y**2+z**2+x*y+y*z+z*x if n<=N: fn[n-1]+=1 print(*fn,sep=""\n"")" p03359,s124963042,Accepted,"a, b = map(int, input().split()) if a <= b: print(a) else: print(a-1) " p02866,s869266772,Accepted,"from collections import defaultdict dic = defaultdict(int) MOD = 998244353 N = int(input()) A = list(map(int,input().split())) MAX = max(A) store = [0 for _ in range(MAX+1)] for x in A: store[x] += 1 if A[0] != 0 or store[0] != 1: print(0) exit() ans = 1 for i in range(MAX): ans = ans*pow(store[i],store[i+1],MOD) print(ans%MOD)" p02697,s541395343,Accepted,"n, m = map(int, input().split()) s1 = 1 f1 = n // 2 s2 = f1 + 1 f2 = n if (f1 - s1) % 2 == (f2 - s2) % 2: f2 -= 1 ans = [] while f1 > s1: ans.append(f""{s1} {f1}"") s1 += 1 f1 -= 1 while f2 > s2: ans.append(f""{s2} {f2}"") s2 += 1 f2 -= 1 print(""\n"".join(ans[:m]))" p02973,s054260429,Wrong Answer,"n = int(input()) A = [int(input()) for i in range(n)] m = 10**9 c = 0 for a in A: if a <= m: c += 1 print(c) " p03075,s079513384,Accepted,"import sys import math stdin = sys.stdin mod = 10**9 + 7 ns = lambda: stdin.readline().rstrip() ni = lambda: int(ns()) na = lambda: list(map(int, stdin.readline().split())) sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)] a = [] for _ in range(5): a.append(ni()) k = ni() print(""Yay!"" if a[-1] - a[0] <= k else "":("")" p03319,s422425982,Accepted,"n,k=map(int,input().split()) if (n-1)%(k-1)==0: print((n-1)//(k-1)) else: print(((n-1)//(k-1))+1)" p03086,s710792976,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(): S = input() ans = 0 tmp = 0 acgt = ['A', 'C', 'G', 'T'] for s in S: if s in acgt: tmp += 1 else: ans = max(ans, tmp) tmp = 0 ans = max(ans, tmp) print(ans) if __name__ == '__main__': main() " p02577,s007061394,Accepted,"N = input() ans = 0 for n in N: ans += int(n)%9 print('Yes' if ans % 9 == 0 else 'No')" p03433,s997369149,Accepted,"n = int(input()) a = int(input()) if n % 500 <= a: print(""Yes"") else: print(""No"")" p03910,s915268604,Wrong Answer,"N = int(input()) from collections import OrderedDict ans = OrderedDict() cur = N i = 1 while cur != 0: tmp = cur - i if tmp in ans.keys(): pass else: ans[i] = True cur = tmp i+= 1 for a in ans: print(a) " p02597,s213662922,Wrong Answer,"N=int(input()) C = input() print(C.count('WR'))" p03239,s741870252,Accepted,"inf = 10**15 mod = 10**9+7 n,T = map(int, input().split()) minc = inf for i in range(n): c,t = map(int, input().split()) if t <= T: minc = min(minc, c) if minc == inf: print('TLE') else: print(minc)" p03659,s076380156,Accepted,"N = int(input()) a = [int(x) for x in input().split()] ans = 10**9*N front = 0 back = sum(a) for i in range(N-1): front += a[i] back -= a[i] ans = min(ans, abs(front-back)) print(ans)" p03720,s859515339,Wrong Answer,"from collections import Counter def main(): n, m = map(int, input().split()) ABs = [list(map(int, input().split())) for _ in range(m)] ABs = [b for a in ABs for b in a] anss = Counter(ABs) anss = sorted(anss.items(), key=lambda x: x[0]) for ans in anss: print(ans[1]) if __name__ == ""__main__"": main() " p03951,s076558455,Accepted,"n = int(input()) s = input() t = input() for i in range(n): if s[i:] == t[:n-i]: print(n + i) exit() else: print(n*2)" p03835,s331708320,Wrong Answer,"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)" p03545,s311675108,Accepted,"abcd = list(input()) op = ['+', '-'] for op1 in op: for op2 in op: for op3 in op: formula = abcd[0] + op1 + abcd[1] + op2 + abcd[2] + op3 + abcd[3] if eval(formula) == 7: print(formula + '=7') exit() " p03994,s190021136,Accepted,"s=input() l=len(s) k=int(input()) z='' for i in range(l): t=123-ord(s[i]) if s[i]=='a': z+='a' elif t<=k: z+='a' k-=t else: z+=s[i] v=ord(z[l-1])-97+k z=z[:l-1]+chr(v%26+97) print(z)" p03478,s694259932,Wrong Answer,"N,A,B=[int(i) for i in input().split()] num_list=[] for x in range(10): for y in range(10): num=10*x+y if 1<=num<=N and A<=(x+y)<=B: num_list.append(num) print(sum(num_list))" p02958,s577084880,Wrong Answer,"N = int(input()) P = list(map(int, input().split())) count = 0 for i in range(N): if P[i] != i + 1: count += count + 1 if count > 2: print('No') exit() print('Yes') " p02701,s926918338,Accepted,"N=int(input()) a=[] for i in range(N): a.append(input()) a_uni=list(set(a)) print(len(a_uni))" p02754,s273319633,Accepted,"N,A,B=map(int,input().split()) div=N//(A+B) mod=N%(A+B) print(div*A+min(mod,A))" p03106,s914217775,Accepted,"a,b,k = map(int,input().split()) l= [] for i in range(1,max(a,b)+1): if a%i==0 and b%i==0: l.append(i) l.sort(reverse=True) print(l[k-1])" p02922,s953053421,Accepted,"A, B = map(int, input().split()) A -= 1 B -= 1 print(-(-B // A)) " p02613,s605137982,Accepted,"n = int(input()) ac,wa,tle,re=0,0,0,0 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(""AC x"",ac) print(""WA x"",wa) print(""TLE x"",tle) print(""RE x"",re) " p03795,s923055221,Accepted,"N = int(input()) x = N*800 y = (N//15)*200 Ans = x - y print(Ans)" p03721,s860066877,Accepted,"n,k=map(int,input().split()) AB=[list(map(int,input().split())) for _ in range(n)] AB.sort() cnt=0 for i , j in AB: cnt+=j if k<=cnt: print(i) exit()" p02784,s903344420,Wrong Answer,"import numpy as np ene=list(map(int, input().split())) num=list(map(int, input().split())) tmp = ene[0] - np.array(num).sum() if tmp>0: print(""NO"") else: print(""Yes"")" p03449,s695088485,Accepted,"N=int(input()) A=[int(i) for i in input().split()] B=[int(i) for i in input().split()] # A=[3,2,2,4,1] # B=[1,2,2,2,1] l_ans=[] for i in range(len(A)): sum_num=sum(A[:i+1])+sum(B[i:]) l_ans.append(sum_num) print(max(l_ans)) " p03673,s037919572,Accepted,"from collections import deque n=int(input()) a=list(map(int,input().split())) ans=deque() if n%2==0: for i in range(n): if i%2==0: ans.append(a[i]) else: ans.appendleft(a[i]) else: for i in range(n): if i%2==0: ans.appendleft(a[i]) else: ans.append(a[i]) print(*ans)" p02939,s777719881,Accepted,"s = str(input()) n = len(s) X = [''] temp = '' for i in range(n): temp += s[i] if temp == X[-1]: continue else: X.append(temp) temp = '' else: if temp != '': if temp == X[-1]: X[-1] += temp else: X.append(temp) #print(X) print(len(X)-1) " p03557,s580063101,Wrong Answer,"from bisect import bisect from itertools import accumulate N = int(input()) A = sorted(map(int, input().split())) B = sorted(map(int, input().split())) C = sorted(map(int, input().split())) D = tuple(accumulate(N - bisect(C, b) for b in reversed(B))) print(sum(D[N - bisect(B, a) - 1] for a in A)) " p03555,s237585003,Accepted,"print(""YES"" if input() == input()[::-1] else ""NO"")" p03386,s614660138,Accepted,"A,B,K = map(int,input().split()) for a in range(A,min(A+K,B+1)): print(a) for b in range(max(A+K,B-K+1),B+1): print(b)" p02881,s320910055,Accepted,"import math n = int(input()) ans = 10 ** 15 for i in range(1, int(n ** 0.5)+1): if n % i == 0: ans = min(ans, i + n // i - 2) print(ans) " p03071,s495575716,Accepted,"a, b = map(int, input().split()) if a == b: print(2*a) else: print(2*max(a, b)-1)" p02645,s121732645,Wrong Answer,"inp = input('enter :') inp = inp[0:3] print(inp)" p04020,s869446271,Accepted,"N, *A = map(int, open(0).read().split()) ans = 0 for i in range(N): q, r = divmod(A[i], 2) ans += q if r == 0 or i == N - 1: continue elif A[i + 1] != 0: A[i + 1] += 1 print(ans) " p02583,s516171707,Accepted,"n = int(input()) l = list(map(int, input().split())) l.sort() ans = 0 if n < 3: print(ans) else: for i in range(n-2): for j in range(i+1, n-1): for k in range(j+1, n): if l[k] < l[i] + l[j] and l[i] != l[j] and l[j] != l[k]: ans += 1 print(ans) " p02600,s095761185,Accepted,"x = int(input()) import bisect ar = [0 for _ in range(8)] for i in range(8): ar[i] = 400+200*i num = bisect.bisect_right(ar,x) #print(ar) print(9-num)" p03145,s130417685,Accepted," def solve(): AB, BC, CA = map(int, input().split()) print(AB*BC//2) if __name__ == ""__main__"": solve() " p03013,s242024153,Accepted,"n, m = map(int, input().split()) a = [int(input()) for i in range(m)] mod = 10**9+7 dp = [-1]*(n+1) dp[0] = 1 dp[1] = 1 for i in a: dp[i] = 0 for i in range(2, n+1): if dp[i] < 0: dp[i] = (dp[i-1] + dp[i-2])%mod print(dp[n])" p03779,s201832790,Accepted,"X = int(input()) A = 0 B = 0 for i in range(1,10**5): if A < X: A+=i else: print(i-1) exit()" p03795,s329031638,Accepted,"import math N = int(input()) sets = math.floor(N / 15) discount = sets * 200 cost = N * 800 - discount print(cost) " p02731,s522890361,Accepted,"def main(): L = int(input()) ans = (L/3.)**3 print(ans) return if __name__ == ""__main__"": main()" p02627,s516154965,Wrong Answer,"test = str(input()) if test.isupper(): print('A') else: print('b')" p02723,s190585529,Accepted,"S = input() if S[2] == S[3] and S[4] == S[5]: print('Yes') else: print('No')" p02833,s334837487,Accepted,"n = int(input()) if n%2 == 1: print(0) exit() point = 0 now = 10 while now <= n: point += n//now now *= 5 print(point)" p03761,s027942831,Accepted,"import collections n = int(input()) s = list(input()) s_cnt = collections.Counter(s) for i in range(n-1): tmp = input() for k in s_cnt: s_cnt[k] = min(s_cnt[k],tmp.count(k)) s_cnt=dict(sorted(s_cnt.items(), key=lambda x:x[0])) ans = """" for k in s_cnt: ans += k*s_cnt[k] print(ans)" p03645,s362717747,Accepted,"import sys n,m=map(int,input().split()) a=[list(map(int,input().split())) for _ in range(m)] b=set() c=set() for l in a: if l[0]==1: b.add(l[1]) elif l[1]==n: c.add(l[0]) for x in b: if x in c: print(""POSSIBLE"") sys.exit() print(""IMPOSSIBLE"")" p02718,s141544652,Accepted,"# import math n,m=map(int, raw_input().split()) arr=map(int, raw_input().split()) s=sum(arr) arr.sort() k=m for i in xrange(n-1,-1,-1): if arr[i]>=s/(4.0*m) and k>0: k-=1 if k>0: print 'No' else: print 'Yes'" p03001,s888943911,Accepted,"w, h, x, y = map(int, input().split()) hs = 0.5 * w * h if x == w / 2 and y == h / 2: print(""{:.10f}"".format(hs), 1) else: print(""{:.10f}"".format(hs), 0) " p03107,s445524845,Accepted,"def inpl(): return list(map(int, input().split())) S = input() print(min(S.count('0'), S.count('1')) * 2)" p03639,s575423946,Accepted,"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) if N==1: N=0 else: N-=d2 print(""Yes"" if N<=0 else ""No"") " p03457,s603177594,Wrong Answer,"n = int(input()) for _ in range(n): t, x, y = map(int, input().split()) if x + y > t or (t - x - y) % 2: print(""No"") exit() print(""Yes"")" p03371,s747045596,Accepted,"A, B, C, X, Y = map(int, input().split()) pay = 0 same = min(X, Y) pay += same * min(A + B, C * 2) X -= same Y -= same pay += X * min(A, C * 2) pay += Y * min(B, C * 2) print(pay)" p02935,s371526428,Wrong Answer,"from collections import deque N = int(input()) v = list(map(int, input().split())) v.sort() ans = deque() while len(v) > 1: odd = [] if len(v) % 2 == 1: odd.append(v[len(v) - 1]) for i in range(1, len(v), 2): ans.append((v[i - 1] + v[i]) / 2) if len(odd) == 1: ans.append(odd[0]) v = ans ans = deque() print(v[0])" p02988,s612862033,Wrong Answer,"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 print(cnt)" p02910,s650898631,Accepted,"s = list(input()) flag = True for i in range(len(s)): if i % 2 == 0: if s[i] == ""L"": flag = False break else: if s[i] == ""R"": flag = False break if flag: print(""Yes"") else: print(""No"") " p02823,s441335307,Accepted,"n,a,b = map(int,input().split()) if (b-a)%2==0: print((b-a)//2) else: print(min(a+b-1, 2*n-a-b+1)//2)" p03544,s276824094,Accepted,"n = int(input()) l = [2,1] if n == 0: print(2) elif n == 1: print(1) else: for i in range(n-1): l.append(l[-1]+l[-2]) print(l[-1])" p02909,s924159295,Accepted,"s = input() weather = ['Sunny', 'Cloudy', 'Rainy'] i = weather.index(s) if (i == 0) | (i == 1): print(weather[i + 1]) else: print(weather[0])" p03250,s751080468,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) mod = 10**9+7 A,B,C = I() if max(A,B,C) == A: print(A*10+B+C) elif max(A,B,C) == B: print(B*10+A+C) else: print(C*10+A+B)" p02791,s190936043,Wrong Answer,"N = int(input()) P = list(input().split()) count = 0 for i in range(N): FRAG_old = True for j in range(i+1): FRAG_new = (P[i] <= P[j]) FRAG_new = FRAG_old*FRAG_new FRAG_old = FRAG_new if FRAG_new: pass if FRAG_new: count += 1 print(count)" p03434,s540334490,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()) N = I() A = LI() A.sort() A = A[::-1] alice = 0 bob = 0 flag = 0 for i in A: if flag % 2 == 0: alice += i else: bob += i flag += 1 print(alice, bob) " p03944,s114073827,Wrong Answer,"w,h,n = map(int,input().split()) width = w*[1] height = h*[1] for _ in range(n): x,y,a = map(int,input().split()) if a == 1: width[:x] = [0] elif a == 2: width[x:] = [0] elif a == 3: height[:y] = [0] else: height[y:] = [0] print(width.count(1)*height.count(1))" p02727,s192043955,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(reverse=True) ate = p[0:X] +q[0:Y] # print(ate) for x in r: if x > ate[-1]: ate[-1] = x ate.sort() print(sum(ate))" p02717,s619560015,Accepted,"a,b,c = input().split() d = int d = a a = b b = d d = c c = a a = d print(a,b,c)" p02791,s964058472,Accepted,"N = int(input()) P = list(map(int, input().split())) now = P[0] ans = 1 for i in range(1, N): if now >= P[i]: now = P[i] ans += 1 print(ans)" p03323,s543792323,Accepted,"#!/usr/bin/env python3 a, b = list(map(int, input().split())) if a <= 8 and b <= 8: print(""Yay!"") else: print("":("") " p02571,s215518080,Wrong Answer,"S = input() T = input() l = len(T) ans = l for i in range(l): for j in range(l): if (i<=j): if T[i:j+1] in S: f = S.find(T[i:j+1]) if f >= i and f + (l-j) <= len(S): ans = min(ans, l - (j+1-i)) print(ans) " p03556,s153390838,Accepted,"N = int(input()) for i in range(N, 0, -1): if (i ** 0.5).is_integer(): print(i) break " p03471,s272247202,Accepted,"n,y=map(int,input().split()) for i in range(n+1): for j in range(n+1-i): k10=i*10000 k5=j*5000 k1=(n-i-j)*1000 if k10+k5+k1==y: print(i,j,n-i-j) break else: continue break else: print(-1,-1,-1)" p03427,s799545215,Accepted,"import sys input = sys.stdin.readline def main(): N = int(input()) L = len(str(N)) ans = sum(map(int, str(N))) for d in range(L): if str(N)[d] == ""0"": continue m = sum(map(int, str(N)[:d + 1])) - 1 + 9 * (L - (d + 1)) if m > ans: ans = m print(ans) if __name__ == ""__main__"": main() " p03457,s526037332,Wrong Answer,"n = int(input()) points = [] for i in range(n): points.append(list(map(int, input().split("" "")))) t_pre, x_pre, y_pre = 0, 0, 0 reachable = False for point in points: t, x, y = map(int, point) diff_t = t - t_pre p = x + y p_pre = x_pre + y_pre move = 0 for _ in range(diff_t): move += 1 if p > (p_pre + move) else -1 reachable = True if p - p_pre == move else False t_pre, x_pre, y_pre = t, x, y print(""Yes"" if reachable == True else ""No"") " p03759,s717187444,Accepted,"a,b,c=map(int,input().split()) if b-a==c-b: print('YES') else: print('NO')" p03481,s119873329,Wrong Answer,"x,y = tuple(map(int,input().split())) for i in range(1,10*4): x<<=1 if x>y: print(i)" p02900,s825885986,Accepted,"A, B=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 C = list(set(make_divisors(A)) & set(make_divisors(B))) C.sort() for i in range(1, len(C) - 1): a = C[i] for j in range(len(C) - 1, i, -1): if C[j] % a == 0: del C[j] if i + 1 >= len(C): break print(len(C))" p02842,s982568702,Accepted,"N = int(input()) if N * 100 % 108 == 0: print(int(N / 1.08)) else: if int(N // 1.08 * 1.08) == N: print(int(N / 1.08)) elif int((N // 1.08 + 1) * 1.08) == N: print(int(N / 1.08) + 1) else: print("":("")" p02664,s164897401,Accepted,"t = input() ts = t.replace('?', 'D') print(ts)" p03773,s164469416,Accepted,"a,b = map(int,input().split()) print((a+b)%24) " p02880,s862217683,Accepted,"N = int(input()) count = 0 for i in range(1,10): for j in range(1,10): if i*j == N: count = 1 if count > 0: print('Yes') else: print('No')" p02988,s634366818,Wrong Answer,"n = int(input()) p = list(map(int,input().split())) seconds = [] for a in range(0,n-2): num = [p[a],p[a+1],p[a+2]] num.sort() seconds.append(num[1]) print(len(set(seconds)))" p02767,s262455598,Accepted,"N = int(input()) X = list(map(int, input().split())) P = sum(X)//N ans1 = 0 ans2 = 0 for x in X: ans1 += (P-x)**2 ans2 += (P+1-x)**2 print(min(ans1, ans2))" p02935,s616358512,Wrong Answer,"N = int(input()) A = list(map(int,input().split())) A = sorted(A) Asum1 = sum(A) Asum2 = sum(A)-A[N-1] J = N%2 B = N if J == 0: for _ in range(N//2): Asum1 /= 2 print(Asum1) else: for _ in range((N-1)//2): Asum2 /= 2 Asum2 = (Asum2+A[N-1])/2 print(Asum2)" p02823,s174670778,Accepted,"n,a,b=map(int,input().split()) check=(b-a)%2 if check==0: ans=(b-a)//2 print(ans) else: ans=min(n-b,a-1)+1+(b-a-1)//2 print(ans)" p03836,s309159857,Accepted,"a, b, c, d = map(int, input().split()) x = c-a y = d-b ans = [] for i in range(x): ans.append('R') for i in range(y): ans.append('U') for i in range(x): ans.append('L') for i in range(y+1): ans.append('D') for i in range(x+1): ans.append('R') for i in range(y+1): ans.append('U') ans.append('L') ans.append('U') for i in range(x+1): ans.append('L') for i in range(y+1): ans.append('D') ans.append('R') print(''.join(ans))" p02801,s075758355,Wrong Answer,"C=input() chr(ord(C) + 1)" p03345,s151674918,Accepted,"a, b, c, k = map(int, input().split()) print(a-b) if k%2 == 0 else print(b-a)" p02861,s080368315,Wrong Answer,"#C - Average Length import math import itertools N = int(input()) town = [] for i in range(N): x,y = map(int,input().split()) town.append((x,y)) def dist(A,B): return math.sqrt((A[0]-B[0])**2 + (A[1]-B[1])**2) route = list(itertools.permutations(town)) print(route) tot = 0 for i in route: for j in range(len(i)-1): tot += dist(i[j],i[j+1]) ave = tot/len(route) print(ave)" p02957,s176854008,Accepted,"# abc 135 A a, b = map(int, input().split()) res = a + b if res % 2: print(""IMPOSSIBLE"") else: print(res // 2)" p02784,s819898676,Accepted,"h,n=map(int,input().split()) s = sum(list(map(int,input().split()))) print(""Yes"" if s>=h else ""No"") " p02712,s377459274,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)" p03699,s876481863,Accepted,"from sys import exit n = int(input()) s = sorted([int(input()) for _ in range(n)]) sum_s = sum(s) if sum_s % 10 > 0: print(sum_s) exit() for v in s: if (sum_s - v) % 10 > 0: print(sum_s - v) exit() print(0)" p03605,s011779899,Wrong Answer,"n = input() if '9' in n: print('yes') else: print(""No"")" p02817,s943801756,Accepted,"A,B=input().split() print(B+A)" p03206,s751826080,Wrong Answer,"D = int(input()) print(""Christmas"",(25-D)*""Eve"")" p02843,s988243800,Accepted,"import itertools x = int(input()) count = 0 coins = [ 100, 101 , 102 , 103 , 104 , 105] for i in itertools.combinations_with_replacement(coins, x // 100): if sum(i) == x: count = 1 break print(count)" p03352,s585554329,Accepted,"import math x = int(input()) ans = 0 for b in range(1, int(math.sqrt(x))+1): p = 1 if b != 1: while b**p <= x: p += 1 if b**(p-1) > ans: ans = b**(p-1) print(ans)" p03673,s656560376,Accepted,"b=int(input())%2 from collections import deque d=deque() for e,i in enumerate(map(int,input().split())): if e%2: d.append(i) else: d.appendleft(i) print(*list(d)[::b*2-1])" p03427,s588401003,Accepted,"N = input() ans = 0 if N[1:] == ""9"" * (len(N) - 1): ans = int(N[0]) + (9 * (len(N) - 1)) else: ans = int(N[0]) + 9 * (len(N) - 1) - 1 print(ans) " p03254,s919241367,Accepted,"n, x = list(map(int, input().split())) A = list(map(int, input().split())) A = sorted(A) SUM = 0 for i in range(n): SUM += A[i] if SUM > x: print(i) break elif SUM == x: print(i + 1) break else: print(n - 1) " p02939,s121777482,Wrong Answer,"s=input();n=len(s) now="""" ans=set() for i in range(n): now+=s[i] if not (now in ans): ans.add(now) now="""" ans1=set() now="""" for i in range(n-1,-1,-1): now+=s[i] if not (now in ans1): ans1.add(now) now="""" print(max(len(ans),len(ans1)))" p04044,s054440195,Accepted,"lengh, count = map(int, input().split()) strlist = [] for i in range(0,lengh): strlist.append(input()) strlist.sort() print("""".join(strlist))" p02695,s355240056,Accepted,"n,m,q = [int(i) for i in input().split()] p = [] for i in range(q): p.append([int(i) for i in input().split()]) dmax = 0 a = [1 for i in range(n)] while True: d = 0 for i in range(q): if a[p[i][1]-1]-a[p[i][0]-1] == p[i][2]: d += p[i][3] if d > dmax: dmax = d if a[0] == m: break c = 1 l = a.pop() while l==m: l = a.pop() c += 1 for i in range(c): a.append(l+1) print(dmax)" p03627,s352552650,Wrong Answer,"from collections import Counter n = int(input()) a = list(map(int, input().split())) acnt = Counter(a) num = [0,0] for i in acnt: if acnt[i] >= 4: num.append(i) if acnt[i] >= 2: num.append(i) print(num[-1] * num[-2]) " p03435,s219389602,Accepted,"from collections import deque C=[list(map(int,input().split())) for _ in range(3)] for i in range(C[0][0]+1): q=deque([C[0][0]-i,C[0][1]-i,C[0][2]-i,C[0][0]-i,C[0][1]-i,C[0][2]-i]) flag=0 for j in range(1,3): d=set() for k in range(3): d.add(C[j][k]-q.popleft()) if len(d)==1: flag+=1 if flag==2: print('Yes') exit() print('No')" p02918,s315992377,Accepted,"def main(): N, K = map(int, input().split()) S = input() prev = ""s"" count = 0 for s in S: if prev != s: count += 1 prev = s print(min(N + 2 * K - count, N - 1)) if __name__ == '__main__': main() " p02705,s410385562,Wrong Answer,"import math def round(R): return 2*R*math.pi R = int(input()) round(R)" p03073,s918124359,Accepted,"s=list(input()) n=len(s) dic={""0"":""1"",""1"":""0""} temp=[] temp.append(s[0]) ans=0 for i in range(1,n): temp.append(dic[temp[i-1]]) for i in range(n): if temp[i]!=s[i]: ans+=1 print(ans) " p02835,s826135489,Accepted,"a1,a2,a3 = map(int,input().split()) if a1 + a2 + a3 >= 22: print(""bust"") else: print(""win"") " p02555,s834765250,Wrong Answer,"def main(): s = int(input()) mod = 10**9+7 dp = [0] * (s+1) dp[0] = 1 for i in range(1, s+1): for j in range(1, (i-3)+1): dp[i] += dp[j] dp[i] %= mod print(dp[s]) if __name__ == ""__main__"": main() " p03251,s398293794,Accepted,"n,m,x,y=map(int,input().split()) xmax=max(list(map(int,input().split()))) ymin=min(list(map(int,input().split()))) if xmax>ymin: print('War') else: ans='War' for i in range(xmax+1,ymin+1): if x=0: x -= i count += 1 print(count) " p02832,s852162839,Accepted,"def main(): N = int(input()) a_list = list(map(int, input().split(' '))) broken_cnt = 0 remain_max_number = 0 for a in a_list: if a == remain_max_number + 1: remain_max_number += 1 else: broken_cnt += 1 answer = broken_cnt if broken_cnt < N else -1 print(answer) if __name__ == '__main__': main()" p02701,s050454204,Wrong Answer,"N=int(input()) len({input() for i in range(N)})" p02595,s445505615,Wrong Answer,"N,D = map(int,input().split()) count = 0 for _ in range(N): a,b = map(int,input().split()) val = (a ** 2 + b ** 2) ** 0.5 if val >= D: count +=1 print(count)" p02642,s939618256,Accepted,"from collections import defaultdict N = int(input()) a = list(map(int, input().split())) anstable = [0] * (10 ** 6 + 1) d = defaultdict(int) for i in a: d[i] += 1 u = [] for i, v in d.items(): if v == 1: u.append(i) a = set(a) for i in a: for j in range(i * 2, 10 ** 6 + 1, i): anstable[j] += 1 cnt = 0 for i in u: if anstable[i] == 0: cnt += 1 print(cnt)" p02642,s112330104,Wrong Answer,"N = int(input()) lis = [1] * (10**7+1) for i in range(2,10**7+1): for j in range(i,10**7+1,i): lis[j] += 1 ans = 0 for i in range(1,N+1): ans += lis[i] * i print(ans) " p03633,s281380523,Accepted,"N = int(input()) T_arr = [] for _ in range(N): T_arr.append(int(input())) import fractions from functools import reduce 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_arr))" p03286,s500588522,Accepted,"n = int(input()) ans = """" while n != 0: rest = n % 2 if rest == 1: ans += ""1"" else: ans += ""0"" n = (n - rest) // -2 if ans == """": ans += ""0"" print(ans[::-1])" p02959,s897806890,Accepted,"n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) ans = 0 for i in range(n): for j in range(i,i+2): dif = b[i] - a[j] if dif<0: ans+= b[i] b[i]=0 a[j]=-dif elif dif >=0: ans+= a[j] b[i] = dif a[j] = 0 print(ans)" p02862,s867763631,Wrong Answer,"X,Y=map(int,input().split()) mod=1000000007 if (X+Y)%3!=0: print(0) exit() s=(X+Y)//3 n=(-X+2*Y)//3 m=(-Y+2*X)//3 # print('n={}'.format(n)) # print('m={}'.format(m)) if n<0 or m<0: print(0) exit() nm=1 nn=1 # print('nm----') for i in range(n,n+m+1): nm*=i nm%=mod # print(nm) # print('nn----') for i in range(1,n+1): nn*=i nn%=mod # print(nn) print(nm//nn%mod) " p02571,s573387094,Accepted,"s=input() t=input() ans=1000 for i in range(len(s)-len(t)+1): tmp=0 for j in range(len(t)): if s[i+j]!=t[j]: tmp+=1 if ans>tmp: ans=tmp print(ans)" p02582,s978096639,Wrong Answer,"s=input() if s==""RRR"": print(3) elif s==""RRS""or""SRR"": print(2) elif s==""SSR""or""SRS""or""RSS"": print(1) else: print(0)" p04045,s146233221,Accepted,"n, k = map(int, input().split()) d = list(map(int, input().split())) for i in range(n, 100000): for j in d: if str(j) in str(i): break else: print(i) break " p02900,s541263622,Accepted,"a,b=map(int,input().split()) def factorization(n): if n < 2: return [] 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 def gcd(A, B): if B == 0: return A else: return gcd(B, A % B) g=gcd(a,b) l=factorization(g) print(len(set(l))+1)" p03524,s914490041,Accepted,"s = input() #sys.stdin.readlineは最後が改行 from collections import Counter c = Counter(s) cm = c.most_common() if len(c)==1: if len(s)==1: print('YES') else: print('NO') exit() if len(c)==2: if len(s)==2: print('YES') else: print('NO') exit() if len(c)==3: aa = cm[0][1] bb = cm[1][1] cc = cm[2][1] if aa-cc<2: print('YES') else: print('NO') " p02951,s591725890,Wrong Answer,"A,B,C = map(int,input().split()) print(C-(A-B))" p02690,s371091752,Accepted,"x = int(input()) for a in range(-1000, 1000): for b in range(-1000, 1000): if a**5 - b**5 == x: print(a, b) exit() " p03486,s171497461,Wrong Answer,"s=sorted(input())[::-1] t=sorted(input())[::-1] print('Yes' if s 0: print('Yes') else: print('No') " p02696,s212760473,Wrong Answer,"a,b,n = map(int,input().split()) ma = -1 for x in range(0,b): ans = ((a*x)//b) - (a * (x//b)) print((a * (x//b))) if(ans > ma): ma = ans print(x,ma) print(ma)" p03345,s531362420,Accepted,"a, b, c, k = map(int, input().split()) print((a-b)*(-1)**k)" p02725,s270689300,Accepted,"k, n = map(int, input().split()) A = list(map(int, input().split())) start_diff = A[0] + k - A[-1] diff = [start_diff] answer = 0 start = A[0] for i in range(1, n): diff.append(A[i] - start) start = A[i] # print(diff) # print(start_diff) answer = sum(diff) - max(diff) print(answer) " p02711,s890263093,Accepted,"string = input() if string[0] == ""7"" or string[1] == ""7"" or string[2] == ""7"": print(""Yes"") else: print(""No"")" p02555,s861310332,Accepted,"from math import factorial S=int(input()) ans=0 for i in range(S // 3): ans+=factorial(S-2*i-3)//factorial(i)//factorial(S-3*i-3) print(ans%1000000007)" p03644,s310014908,Accepted,"from math import log2 N = int(input()) print(2**int(log2(N))) " p03137,s928773966,Accepted,"n,m = map(int,input().split()) l = list(map(int,input().split())) l = sorted(l) diff = [] if n >= m: ans = 0 else: for i in range(m-1): diff.append(l[i+1]-l[i]) diff = sorted(diff,reverse=True) for i in range(n-1): diff.pop(0) ans = sum(diff) print(ans)" p03042,s814875230,Accepted,"S=input() F=int(S[:2]) L=int(S[2:]) if 0len(s2): s2+="" "" s=[s1,s2] sT=[list(x) for x in zip(*s)] for i in range(len(s1)): print(sT[i][0],end="""") print(sT[i][1],end="""") " p02924,s028125920,Wrong Answer,"N = int(input()) print(int((N*(N-1))/(2)))" p03071,s698323734,Accepted,"def main(): a, b = map(int, input().split()) ans = 0 if a == b: ans = a * 2 else: ans = max(a,b) * 2 - 1 print(ans) if __name__ == '__main__': main()" p03062,s462496467,Accepted,"n=int(input()) a=list(map(int,input().split())) minus_num = 0 for i in range(n): if a[i] < 0: minus_num += 1 abs_a = list(map(abs,a)) if minus_num % 2 == 0: print(sum(abs_a)) else: print(sum(abs_a)-2*min(abs_a))" p03150,s858029824,Wrong Answer,"s = input() q = 'keyence' j, cnt = 0, 0 flag = False for i in range(len(s)): if s[i] == q[j]: j += 1 if flag: cnt += 1 if j == len(q) - 1: break flag = False else: flag = True if i < len(s)-1: cnt += 1 if j == len(q)-1 and cnt <= 1: print('YES') else: print('NO')" p03252,s445436829,Wrong Answer,"s = len(set(input())) t = len(set(input())) print(""Yes"") if s == t else print(""No"")" p03495,s324751365,Accepted,"n,k = list(map(int, input().split())) lst = list(map(int, input().split())) count = {} for i in lst: if i in count.keys(): count[i]+=1 else: count[i]=1 count_sorted = sorted(count.items(), key=lambda x:x[1]) # print(count_sorted) ans = 0 for i in range(len(count_sorted)-k): ans += count_sorted[i][1] print(ans) " p02572,s404139665,Accepted,"N = int(input()) A = list(map(int, input().split())) MOD = 1000000007 s = sum(A) ans = 0 for i in range(N): s -= A[i] ans += A[i] * s print(ans % MOD) " p03105,s762675596,Accepted,"a,b,c = map(int,input().split()) s = b // a if s > c: print(c) else: print(s)" p02641,s893174863,Wrong Answer,"x, n = map(int, input().split()) try: p = list(map(int, input().split())) except EOFError: print(100) exit() old_diff = 10000 for i in range(1, 101): if i in p: continue else: diff = abs(x-i) if diff < old_diff: ans = i old_diff = abs(x-i) try: print(ans) except: print()" p02793,s791623598,Accepted,"import sys input = sys.stdin.readline from fractions import gcd N=int(input()) a_list = list(map(int, input().split())) MOD = 10**9+7 def cal_lcm(a, b): return int(a*b//gcd(a,b)) lcm = 1 ans = 0 for i in range(N): lcm_ = cal_lcm(lcm, a_list[i]) ans = ans*(lcm_//lcm) ans = (ans + (lcm_//a_list[i])) lcm = lcm_ print(ans%MOD)" p04029,s877843653,Wrong Answer,"N=int(input()) a=N*(N+1) print(a/2)" p03416,s003799805,Accepted,"a,b = map(int,input().split()) ans = 0 for i in range(a,b+1): s = str(i) if s == s[::-1]: ans += 1 print(ans)" p02717,s750510243,Accepted,"import math N = list(input().split()) N[0], N[1] = N[1], N[0] N[0], N[2] = N[2], N[0] print(' '.join(N))" p02613,s620704027,Accepted,"from collections import defaultdict N = int(input()) dic = defaultdict(int) for i in range(N): S = input() dic[S] = dic[S] + 1 print(""AC x"", dic[""AC""]) print(""WA x"", dic[""WA""]) print(""TLE x"", dic[""TLE""]) print(""RE x"", dic[""RE""]) " p02572,s712329354,Accepted,"n=int(input()) a=list(map(int,input().split())) ans=0 t=sum(a) s=0 for i in range(n): s+=a[i]*a[i] ans=(t*t-s)//2 ans=ans%(10**9+7) print(ans)" p02790,s707007859,Accepted,"a, b = map(int, input().split()) print(min(str(a)*b, str(b)*a))" p02933,s377008701,Wrong Answer,"a = int(input()) s = input() if a >= 3200: print(s) else: print('Red')" p03221,s229419079,Wrong Answer,"n , m = map(int, input().split()) id =[] ch = 1 for i in range(m): p , y = input().split() p = p.zfill(6) id.append([p,y,i]) id.sort(key = lambda x:(x[0],x[1])) id.append(['X','X','X']) for i in range(m): id[i][1]=str(ch).zfill(6) if id[i][0]==id[i+1][0]: ch+=1 else: ch=1 id.pop() id.sort(key = lambda x:x[2]) for i in range(m): s = id[i][0]+id[i][1] print(s)" p03767,s538145239,Accepted,"N = int(input()) a = list(map(int,input().split())) a.sort() b = a[N:] print(sum(b[::2]))" p03469,s476095538,Accepted,"S = str(input()) if '2017/01/' == S[:8]: print('2018/01/{}'.format(S[8:])) " p03284,s217180430,Accepted,"n,k=map(int,input().split()) if n%k==0: print(0) else: print(1)" p03478,s183412397,Wrong Answer,"# import sys input=sys.stdin.readline def main(): N,A,B=map(int,input().split()) cnt=0 for i in range(1,N+1): ds=0 for j in range(4): ds+=(i//(10**j))%(10) if A<=ds<=B: cnt+=i print(cnt) if __name__==""__main__"": main() " p03565,s093007754,Accepted,"s = input() t = input() res = 'UNRESTORABLE' def check(s,t): if len(s) != len(t): return False else: for i in range(len(s)): if s[i] != '?' and s[i] != t[i]: return False return True flg = False for i in range(len(s)-len(t), -1, -1): L = len(t) sub = s[i:L+i] if check(sub,t): new = s[:i] + t + s[L+i:] flg = True break if flg: print(new.replace('?', 'a')) else: print(res)" p03126,s679711653,Accepted,"n,m = map(int, input().split()) s = 0 for i in range(1,m+1): s |= 1 << i for i in range(n): a = map(int, input().split()) a = list(a) t = 0 for j in range(1, len(a)): t |= 1 << a[j] s &= t ans = 0 for i in range(1,m+1): if (s & (1<0: ans+=bb c.append(i+1) print(ans) print(*c) " p02701,s253546261,Wrong Answer,"N = int(input()) L = set({}) count = 0 for i in range(N): L.add(input()) count += 1 print(count) " p03455,s012142606,Accepted,"a, b = [int(i) for i in input().split()] multiply = a * b if multiply % 2 == 0: print(""Even"") else: print(""Odd"")" p02553,s495605369,Wrong Answer,"a,b,c, d = map(int,input().split()) print(max(a*c,b*d,b*c,a*d,0))" p02628,s632659610,Wrong Answer,"A=input() B=input() nk=A.split() N=int(nk[0]) K=int(nk[1]) list=B.split() list_2=sorted(list) sum=0 for i in range(K): sum+=int(list_2[i]) print(sum)" p03695,s349969341,Accepted,"N=int(input()) a=list(map(int,input().split())) for i in range(N): a[i]//=400 ans=0 for i in range(8): if i in a: ans+=1 y=0 for x in a: if x>=8: y+=1 print(max(ans,1),ans+y) " p04020,s921804642,Accepted,"N = int(input()) A = [int(input()) for i in range(N)] ans = 0 rest = 0 for a in A: ans += (a + rest) // 2 rest = 1 if (a + rest) % 2 == 1 and a > 0 else 0 print(ans)" p02971,s195616800,Wrong Answer,"def main(): n = int(input()) # n,m = map(int,input().split()) #1行R列 # a = list(map(int,input().split())) #R行1列 l = [str(input()) for i in range(n)] #R行C列 # a = [list(map(int,input().split())) for x in range(m)] # print(' '.join(map(str,))) # i = 0 print(max(l[1:n])) m = max(l[1:n]) # 0 < i < n for i in range(1,n): if l[i] == m: print(max(l[0:i],l[i+1:n])) else: print(m) if __name__ == '__main__': main()" p03219,s355152492,Accepted,"x,y=map(int,input().split()) print(x+y//2)" p02911,s500953377,Accepted,"N,K,Q = list(map(int,input().split())) A = [K] * N C = 0 for i in range(Q): B = int(input()) A[B-1] += 1 C += 1 for j in range(N): if A[j] > C: print('Yes') else: print('No')" p03286,s341663157,Accepted,"N = int(input()) res = [] sign = 1 while N: if N%2 == 0: res.append(0) else: N -= sign res.append(1) N //= 2 sign *= -1 if not res: res = [0] print(*reversed(res),sep='')" p02922,s815428332,Wrong Answer,"def main(): a, b = map(int, input().split()) num = 1 ans = 0 for i in range(1, 21): ans = a * i - (i-1) if ans >= b: print(i) break if __name__ == ""__main__"": main() " p03434,s618887935,Accepted,"N = int(input()) if N == 1: print(input()) else: A = 0 B = 0 a = list(map(int,input().split())) a.sort() a.reverse() for i in range(N): if i % 2 == 0: A += a[i] else: B += a[i] print(A - B)" p02911,s571044934,Wrong Answer,"N,K,Q = map(int, input().split()) A = [int(input()) for i in range(Q)] B = [0 for i in range(N)] for x in A: B[x-1] += 1 print(B) for x in B: k = Q - x if K - k > 0: print(""Yes"") else: print(""No"") " p02681,s593691757,Accepted,"s = str(input()) t= str(input()) sl = len(s) tl = len(t) if(t[:-1]==s): print('Yes') else: print('No') " p02707,s721224446,Wrong Answer,"#--management member = int(input()) mem_number = [int(i) for i in input().split()] ans = [] ans = [0] * member print(ans) for j in range(1,member): k = mem_number.count(j) ans[j-1] = k for i in range(member): print(ans[i]) " p03241,s728629805,Accepted,"n, m = map(int, input().split()) ans = m//n t = [] for i in range(1,int(m**0.5)+1): if m % i == 0: t.append(i) t.append(m//i) t = sorted(t,reverse = True) for i in t: if i <= ans: print(i) break" p02831,s038006753,Wrong Answer,"def main(): A,B = map(int, input().split()) A,B = max(A,B), min(A,B) G = gcd(A,B) # G:最大公約数, L:最小公倍数 # AB=GL L=A*B/G print(int(L)) def gcd(a,b): print(a,b,divmod(a,b)) if a%b==0: return b return gcd(b, a%b) if __name__ == '__main__': main()" p02629,s755240471,Accepted,"N = int(input()) N -= 1 alp = ""abcdefghijklmnopqrstuvwxyz"" ans = '' while N >= 0: j = N % 26 if N == 0: ans += alp[j] break else: N = N // 26 - 1 ans += alp[j] print(ans[::-1]) " p02711,s028461491,Accepted,"n=input() if n[0] == ""7"" or n[1] == ""7"" or n[2] == ""7"": print(""Yes"") else: print(""No"") " p03328,s083665919,Accepted,"a,b = map (int, input ().split ()) x = 0 for i in range (b-a): x += i print (x-a)" p02629,s646604593,Accepted,"N = int(input()) def num2alpha(num): if num<=26: return chr(96+num) elif num%26==0: return num2alpha(num//26-1)+chr(122) else: return num2alpha(num//26)+chr(96+num%26) print(num2alpha(N))" p03803,s067047616,Accepted,"a,b=map(int,input().split()) if a==1: a=14 if b==1: b=14 if a>b: print('Alice') elif b>a: print('Bob') else: print('Draw')" p02694,s842548386,Accepted,"x = int(input()) money = 100 count = 0 for i in range(x+1): money = int(money*1.01) count += 1 if money >= x: print(count) break" p03951,s525101142,Accepted,"N = int(input()) s = input() t = input() for i in range(0,N+1): ss = s[:i]+t if ss[:N] == s and ss[len(ss)-N:] == t: print(len(ss)) exit() " p03162,s146766831,Accepted,"N = int(input()) ans = list(map(int, input().split())) for _ in range(1, N): a, b, c = map(int, input().split()) tmpa, tmpb, tmpc = ans ans[0] = a + max(tmpb, tmpc) ans[1] = b + max(tmpa, tmpc) ans[2] = c + max(tmpa, tmpb) print(max(ans))" p03067,s584892614,Accepted,"a,b,c=map(int,input().split()) if a b[0]: a, b = b, a if a[1] <= b[0]: print(0) elif b[1] <= a[1]: print(b[1] - b[0]) else: print(a[1] - b[0])" p03720,s857607343,Accepted,"n, m = map(int, input().split()) table = [0 for i in range(n)] for i in range(m): a, b = map(int, input().split()) table[a-1] += 1 table[b-1] += 1 for i in table: print(i) " p02970,s433351413,Accepted,"n,d = map(int,input().split()) p = n//(2*d+1) q = n%(2*d+1) print(p if q==0 else p+1)" p02761,s849511297,Accepted,"N, M = map(int, input().split()) ans = [] neg = 0 for n in range(N): ans.append(-1) for m in range(M): s, c = map(int, input().split()) if ans[s-1] == -1: ans[s-1] = c elif ans[s-1] == c: pass else: neg = -1 break if ans[0] == 0 and N != 1: neg = -1 for j in range(len(ans)): if ans[j] == -1: ans[j] = 0 if N == 1: pass elif ans[0] == 0: ans[0] = 1 if neg == -1: print(neg) else: print("""".join([str(i) for i in ans]))" p03672,s177824106,Accepted,"import sys readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines read = sys.stdin.buffer.read sys.setrecursionlimit(10 ** 7) INF = float('inf') S = input() while True: S = S[:-2] half = len(S) // 2 if S[:half] == S[half:]: ans = len(S) break print(ans)" p02678,s982479533,Accepted,"from collections import deque N,M=map(int,input().split()) graph=[[]for _ in range(N+1)] for _ 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]=V D.append(i) print('Yes') for j in dist[2:]: print(j)" p03261,s103097732,Wrong Answer,"n = int(input()) w = [input() for _ in range(n)] e = w[1][-1] cnt = 1 for i in range(1, n): if w[i][0] == e: cnt += 1 e = w[i][-1] if cnt == n and len(set(w)) == n: print('Yes') else: print('No')" p03243,s017273574,Accepted,"def resolve(): cands = [111,222,333,444,555,666,777,888,999] N = int(input()) import bisect print(cands[bisect.bisect_left(cands, N)]) if '__main__' == __name__: resolve()" p03324,s737163475,Accepted,"d,n=map(int,input().split());print((n+n//100)*(100**d))" p03067,s528279583,Accepted,"A,B,C=map(int,input().split()) l=[A,B,C] l.sort() #print(l) if l[1]==C: print(""Yes"") else: print(""No"")" p02681,s838084024,Accepted,"a=input() b=input() z=b[:-1] c=len(a) d=len(b)-1 if a==z and c==d: print('Yes') else: print('No') " p03386,s865881362,Accepted,"a,b,k=map(int,input().split());print(*[i for i in range(a,b+1)if(i>=a+k)*b-k N-1: break if A[n] < c: ans.append(c) n += 1 else: break print(sum(ans) + sum(A[len(ans):]))" p03329,s482123397,Accepted,"N = int(input()) B = [pow(6,i) for i in range(1,10) if pow(6,i)<=N] C = [pow(9,i) for i in range(1,10) if pow(9,i)<=N] A = sorted(B+C+[1]) L = len(A) DP = [[N]*(N+1) for i in range(L)] DP[0] = [i for i in range(N+1)] for l in range(1,L): k = A[l] for n in range(0,k): DP[l][n] = DP[l-1][n] for n in range(k,N+1): DP[l][n] = min(DP[l-1][n-k]+1,DP[l][n-k]+1,DP[l-1][n]) print(DP[L-1][N])" p03011,s659722025,Accepted,"from sys import stdin, setrecursionlimit def main(): input = stdin.buffer.readline p, q, r = map(int, input().split()) print(sum([p, q, r]) - max(p, q, r)) if __name__ == ""__main__"": setrecursionlimit(10000) main() " p03127,s872476933,Wrong Answer,"N = int(input()) A = list(sorted(map(int, input().split()))) ans = A[0] for i in range(N): for j in range(i+1,N): if 0 < A[j]%A[i] < ans : ans = A[j]%A[i] if ans == 1: break print(ans)" p03061,s729904512,Accepted,"from fractions import gcd n = int(input()) a = list(map(int,input().split())) GCD= a[0] dp = [set() for i in range(n)] dp[1].add(a[0]) dp[1].add(a[1]) for i in range(1,n): x = a[i] for j in dp[i-1]: dp[i].add(gcd(j,x)) if x % GCD != 0: dp[i].add(GCD) GCD = gcd(GCD,x) print(max(dp[n-1])) " p03324,s162517226,Accepted,"D, N = map(int, input().split()) if N == 100: N += 1 print(N * 100 ** D) " p03309,s415199097,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 = round(np.mean(a)) ans = int(np.sum(abs(a-b))) print(ans)" p03779,s397212900,Wrong Answer,"X=int(input()) N=1 while N*(N+1)//21: print(0) exit() ans=1 for i in set(dd.keys()): if i==0: continue ans*=(dd[i-1]**dd[i])%mod print(ans%mod)" p02615,s042266187,Accepted,"n = int(input()) a = list(map(int, input().split())) a.sort(reverse=True) q, r = divmod(n, 2) print(a[0] + sum(a[1:q]) * 2 + a[q] * r)" p03838,s883541161,Accepted,"A,B = map(int,input().split()) if A == B: print(0) exit(0) C = 0 # 符号が同じ if A * B > 0: if A < B: C = abs(B - A) else: C = abs(B - A) + 2 # 符号が違う elif A * B < 0: C = abs(abs(B) - abs(A)) + 1 # どちらかが0 else: if A == 0: C = abs(B) if B < 0: C += 1 elif B == 0: C = abs(A) if 0 < A: C += 1 print(C) " p02792,s769481476,Accepted,"N = int(input()) k = [[0] * 10 for _ in range(10)] for n in range(1, N+1): sn = str(n) k[int(sn[0])][int(sn[-1])] += 1 ans = 0 for i in range(1, 10): for j in range(1, 10): ans += (k[i][j] * k[j][i]) print(ans) " p02601,s329718902,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 #print(i, A, B, C) if A < B and B < C: print(""Yes"") else: print(""No"")" p03324,s418906580,Wrong Answer,"D, N = map(int, input().split()) d = 100 ** D * N if d % 100 ** D == 0: d += 1 print(d) " p02972,s190059152,Accepted,"N = int(input()) A = list(map(int, input().split())) B = [0 for i in range(N)] for i in range(N-1, -1, -1): count = 0 for j in range(i, N, i+1): count += B[j] if count%2 == A[i]: B[i] = 0 else: B[i] = 1 sum = sum(B) if sum == 0: print(0) else: print(sum) ans = [] for i in range(N): if B[i] == 1: ans.append(i+1) print(*ans)" p03011,s798760956,Wrong Answer,"a = list(map(int,input().split())) print(sum(a)-min(a))" p02682,s525038003,Accepted,"A,B,C,K = map(int, input().split()) if A+B n-k: return comb(n, n-k, p) num, den = 1, 1 for i in range(k): num = num * (n-i) % p den = den * (i+1) % p return num * pow(den, p-2, p) % p print((total - 1 - comb(n,a,M) - comb(n,b,M)) % M) " p03479,s905109102,Wrong Answer,"from math import log2, floor X, Y = map(int, input().split()) ans = floor(log2(Y//X)) + 1 print(ans)" p02690,s887421935,Accepted,"X = int(input()) x = 1 while ((x-1)**4)*5 < X: x += 1 for i in range(x): for j in range(-x, i): if i**5-j**5 == X: a = [i,j] break print(*a) " p03767,s802952320,Accepted,"n = int(input()) a = list(map(int,input().split())) a.sort() print(sum(a[n::2])) " p03862,s701715197,Accepted,"N, x = map(int, input().split()) As = list(map(int, input().split())) As.append(0) f = sum(As) for i in range(0,N): if As[i]+As[i+1] > x: if As[i] <= x: As[i+1] = x - As[i] else: As[i+1] = 0 As[i] = x s = sum(As) print(f-s)" p02547,s225685550,Accepted,"n = int(input()) d1,d2 = [],[] for _ in range(n): a,b = map(int,input().split()) d1.append(a) d2.append(b) check = True for i in range(2,n): if d1[i-2] == d2[i-2] and d1[i-1] == d2[i-1] and d1[i] == d2[i]: print(""Yes"") check = False break if check: print(""No"")" p03107,s690565156,Accepted,"def main(): S=input() s=0 for i in range(0,len(S)): s=s+int(S[i]) t=len(S)-s print(2*min(s,t)) if __name__ == '__main__': main() " p02790,s007909592,Wrong Answer,"a, b = map(int, input().split()) s1 = ""a"" *b s2 = ""b"" *a if s1 < s2: print(s1) else: print(s2)" p02615,s027883406,Accepted,"n=int(input()) a=list(map(int,input().split())) a.sort(reverse=True) import heapq heap=[a[0]*(-1)] ans=0 for aa in a[1:]: tmp=heapq.heappop(heap) ans+=((-1)*tmp) heapq.heappush(heap,-1*aa) heapq.heappush(heap,-1*aa) print(ans) " p03103,s994482635,Wrong Answer,"N,M = map(int,input().split()) d = {} for _ in range(N): A,B = map(int,input().split()) d[A] = B res = 0 cnt = 0 for i in sorted(d): if(d[i] <= M): res += d[i]*i M -= d[i] else: res += M * i break print(res)" p03131,s595315480,Wrong Answer,"K,A,B = map(int,input().split()) if B-A < 3: print(1+K) exit() ans = 1 ans += (K//(A+2))*B if K%(A+2) == A+1: ans += B else: ans += K%(A+2) print(ans)" p03206,s703219007,Accepted,"d=int(input()) s=""Christmas"" for i in range(25,d,-1): s=s+"" Eve"" print(s)" p02817,s498498464,Accepted,"s, t = map(str, input().split()) print(t + s)" p02730,s348016094,Accepted,"s=str(input()) n=len(s) for i in range(0,n): if s[i]!=s[-i-1]: print(""No"") exit() new_n1=int((n-1)/2) new_s1=s[:new_n1] new_n2=int((n+3)/2) new_s2=s[new_n2-1:] for i in range(0,len(new_s1)): if new_s1[i]!=new_s1[-i-1]: print(""No"") exit() else: pass for i in range(0,len(new_s2)): if new_s2[i]!=new_s2[-i-1]: print(""No"") exit() else: print(""Yes"") " p02791,s218996258,Wrong Answer,"n = int(input()) p = list(map(int, input().split())) c = 0 m = n + 1 for i in p: if i == min(m, i): c += 1 print(c)" p02629,s301826131,Accepted,"N = int(input()) ans = """" while(N > 0): N -= 1 ch = N % 26 ans = chr(97 + ch) + ans N //= 26 print(ans) " p03774,s778514238,Accepted,"n, m = map(int, input().split()) A = [] B = [] for i in range(n): a, b = map(int, input().split()) A.append(a) B.append(b) C = [] D = [] for i in range(m): a, b = map(int, input().split()) C.append(a) D.append(b) for i in range(n): t = 0 T = [] for j in range(m): t = abs(A[i] - C[j]) + abs(B[i] - D[j]) T.append(t) print(T.index(min(T)) + 1)" p03327,s527197567,Accepted,"N = int(input()) print(""ABC"" if N < 1000 else ""ABD"")" p03494,s466489177,Accepted,"import math n = int(input()) a_li = [int(w) for w in input().split()] ans = 10**9 for a in a_li: # t = 0 # while a % 2 == 0: # a //= 2 # t += 1 t = math.log2(a & -a) ans = min(ans, t) print(int(ans)) " p03487,s880532128,Accepted,"from collections import defaultdict n = int(input()) a_list = [int(x) for x in input().split()] d = defaultdict(int) for a in a_list: d[a] += 1 ans = 0 for i, c in d.items(): ans += c - i if c >= i else c print(ans)" p02571,s315658572,Accepted,"a = input() b = input() mini = len(b) if a == b: print(0) exit(0) for s in range(len(a) - len(b) + 1): c = 0 for i, j in zip(a[s:s + len(b)], b): if i != j: c += 1 mini = min([mini, c]) print(mini) " p03485,s483310356,Accepted,"from math import ceil #小数点以下切り上げ a, b = map(int, input().split()) print(ceil((a+b)/2))" p03160,s485146730,Accepted,"n = int(input()) li = list(map(int,input().split())) dp = [0,abs(li[1]-li[0])] for i in range(2,n): dp += [min(dp[-2]+abs(li[i]-li[i-2]),dp[-1]+abs(li[i]-li[i-1]))] print(dp[-1])" p03761,s450212203,Accepted,"n = int(input()) s = sorted([list(input()) for _ in range(n)], key=len) ans = [] for i in s[0]: t = float(""inf"") for j in s: t = min(t, j.count(i)) ans.append(i*t) ans = sorted(list(set(ans))) print("""".join(ans))" p03000,s594771461,Accepted," N, X = map(int, input().split()) L = list(map(int, input().split())) cnt = 1 total = 0 for i in range(N): total += L[i] if total <= X: cnt += 1 else: break print(cnt) " p02801,s832260799,Accepted,"s = input() st = 'abcdefghijklmnopqrstuvwxyz' print(st[st.index(s)+1]) " p02744,s405387700,Accepted,"n = int(input()) ans = ['a'] for i in range(n-1): buf = [] for j in ans: l = len(set(j)) for c in range(l+1): buf.append(j+chr(ord('a')+c)) ans = buf for i in ans: print(i)" p03545,s841005021,Accepted,"s = input() n = len(s) ans = 0 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] if eval(f) == 7: print(f+""=7"") break " p02833,s141376815,Accepted,"import math import fractions import sys #入力:N(int:整数) def input1(): return int(input()) #入力:N,M(int:整数) def input2(): return map(int,input().split()) #入力:[n1,n2,...nk](int:整数配列) def input_array(): return list(map(int,input().split())) def funct(n): i=1 res=0 while True: ans=2*5**i if n//ans==0: break res+=(n//ans) i+=1 return res N=input1() a=0 if N%2==1: a=0 else: a=funct(N) print(a) " p02935,s183286556,Accepted,"n = int(input()) v = list(map(int, input().split())) v.sort() ave = v[0] for i in range(1, n): ave = (ave + v[i]) / 2 print(ave)" p03854,s366164377,Accepted,"s = input() s_1 = s.replace('eraser', '').replace('erase', '').replace('dreamer','').replace('dream','') if s_1 == '': print(""YES"") else: print(""NO"")" p02818,s838016002,Accepted,"a, b, k = map(int, input().split()) change_a = max(0, a - k) if a < k: b = max(0, b - (k - a)) print(change_a, b)" p02791,s075747399,Accepted,"import collections n = int(raw_input()) elems = map(int, raw_input().split(' ')) m,c = +float('inf'),0 for e in elems: if e <= m: c +=1 m = min(e, m) #elems[j]) print c " p03386,s584734557,Accepted,"A,B,K = map(int,input().split()) if B - A >= 2 * K : for i in range(K): print(A + i) for j in reversed(range(K)): print(B - j) else: for _ in range(A,B + 1): print(_) " p03076,s343209052,Wrong Answer,"l=list(int(input()) for _ in range(5)) s=list(10-i%10 for i in l) s.remove(max(s)) print(sum(l)+sum(s))" p02761,s715421923,Wrong Answer,"N, M = map(int, input().split()) sc = [list(map(int, input().split()))for i in range(M)] ans=""-1"" tmp=0 for i in range(0,1000): s = str('{:0=3}'.format(i)) for j in range(M): if sc[j][0]==1 and sc[j][1] == 0: print(-1) exit() if s[len(s)-N+sc[j][0]-1]!=str(sc[j][1]): break else: if s[0]==""0"": s=str(int(s)+100) ans=s break print(ans)" p02642,s564519389,Accepted,"n = int(input()) *A, = map(int, input().split()) maxA = max(A) C = {a: 0 for a in A} for a in A: C[a] += 1 D = {a: 0 for a in A} for a in A: if C[a] > 1: D[a] = 1 for b in range(2 * a, maxA + 1, a): D[b] = 1 print(sum([D[a] == 0 for a in A])) " p02753,s268000785,Wrong Answer,"s=input() if s==""AAA"" or s==""BBB"": print(""NO"") else: print(""YES"")" p03251,s567669215,Accepted,"n, m, x, y = map(int, input().split()) xl = list(map(int, input().split())) yl = list(map(int, input().split())) for z in range(x + 1, y + 1): if max(xl) < z and min(yl) >= z: print(""No War"") break else: print(""War"")" p03360,s140087887,Accepted,"A = sorted(list(map(int,input().split()))) N = int(input()) A[-1] = A[-1]*2**N print(sum(A))" p03760,s079355784,Accepted,"o = input() e = input() for i in range(len(e)): print(o[i] + e[i], end='') if len(e) != len(o): print(o[-1], end='') print() " p02618,s505046985,Wrong Answer,"D=int(input()) c=list(map(int,input().split())) s=[list(map(int,input().split())) for _ in range(D)] last=[0]*26 for d in range(1,D+1): choice=0 cost=c[0]*(d-last[0]) for i in range(1,26): if c[i]*(d-last[i])>cost: choice=i cost=c[i]*(d-last[i]) last[choice]=d print(choice)" p03624,s395400297,Accepted,"letters=""abcdefghijklmnopqrstuvwxyz"" ans=sorted(set(letters)^set(input())) print(""None"" if len(ans)==0 else ans[0])" p03037,s374052800,Accepted,"def solve(n, m, LR): maxl = 0 minr = n for l, r in LR: if maxl < l: maxl = l if minr > r: minr = r return minr - maxl + 1 if maxl <= minr else 0 _n, _m = map(int, input().split()) _LR = [list(map(int, input().split())) for _ in range(_m)] print(solve(_n, _m, _LR)) " p02780,s583471542,Accepted,"n,k=map(int,input().split()) P=list(map(int,input().split())) now=sum(P[:k]) m=now for i in range(n-k): now+=P[k+i] now-=P[i] m=max(m,now) E=(m+k)/2 print(E)" p02613,s186651901,Accepted,"n = int(input()) d = {""AC"":0, ""WA"":0, ""TLE"":0, ""RE"":0} for _ in range(n): s = input() d[s] += 1 for s in ['AC', 'WA', 'TLE', 'RE']: print(""{} x {}"".format(s, d[s])) " p03943,s874766462,Accepted,"a,b,c = (map(int, input().split())) s1 = a+b s2 = b+c s3 = c+a if s1==c or s2==a or s3==b: print(""Yes"") else: print(""No"") " p03136,s268113781,Accepted,"n=int(input()) L=list(map(int, input().split())) L.sort(reverse=True) maxL=L.pop(0) if maxL< sum(L): print('Yes') else: print('No') " p03723,s327033700,Accepted,"# agc014_a.py] A, B, C = map(int,input().split()) cnt = 0 inf = 10**6 for i in range(inf): if A%2==0 and B%2==0 and C%2==0: a = (B+C)//2 b = (A+C)//2 c = (B+A)//2 A = a B = b C = c cnt += 1 else: break if cnt == inf: cnt = -1 print(cnt)" p02847,s792503969,Wrong Answer,"s = input() l = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT', 'SUN'] print(l[l.index(s) + 1])" p02725,s978419196,Wrong Answer,"import numpy as np K, N = map(int, input().split()) A = list(map(int, input().split())) A = np.array(A) ma = 0 for i in range(N-1): tmp = abs(A[i] -A[i+1]) if min(tmp,K - tmp) > ma: ma = min(tmp,K-tmp) print(K - ma) " p02726,s117995324,Accepted,"from collections import defaultdict N, X, Y = map(int, input().split()) cnt_dict = defaultdict(int) for i in range(1,N): for j in range(i+1, N+1): if j<=X or i>=Y: path = j-i else: path = min(j-i, abs(X-i)+abs(j-Y)+1) cnt_dict[path] += 1 for i in range(1,N): print(cnt_dict[i])" p03637,s312436015,Accepted,"N = int(input()) a = map(int, input().split()) other = mult_2 = mult_4 = 0 for t in a: if t % 4 == 0: mult_4 += 1 elif t % 2 == 0: mult_2 += 1 else: other += 1 if other - 1 + (1 if mult_2 > 0 else 0) <= mult_4: print(""Yes"") else: print(""No"") " p03693,s875675273,Accepted,"N = int("""".join(map(str,input().split()))) print((""NO"",""YES"")[N % 4 == 0])" p02971,s730338276,Accepted,"n=int(input()) a=[int(input()) for i in range(n)] m=max(a) i=a.index(m) for j in range(n): if j!=i: print(m) else: del a[i] print(max(a)) " p02594,s514295994,Wrong Answer,"n =int(input()) if n>=30: print(""YES"") else: print(""NO"") " p03761,s918680755,Accepted,"import string n = int(input()) alpha = string.ascii_lowercase x = [[] for _ in range(26)] for _ in range(n): s = input() for a in alpha: x[alpha.index(a)].append(s.count(a)) ans = """" for i in range(26): ans += min(x[i]) * alpha[i] print(ans)" p03605,s886351197,Accepted,"print(['No','Yes']['9' in input()])" p02831,s857736324,Accepted,"def gcd(a, b): if a == 0: return b if b == 0: return a if a == b: return a if a > b: return gcd(b, a%b) return gcd(a, b%a) def lcm(a, b): if a == b == 0: return 0 return abs(a*b)/gcd(a, b) a, b = map(int, input().split()) print(int(lcm(a, b))) " p03309,s173956603,Wrong Answer,"import numpy as np N=int(input()) A=list(map(int, input().split())) mean=0 for i in range(N): A[i]-=(i+1) mean+=A[i] mean/=(i+1) A=np.array(A) #平均を0に近づけるようにする mean=round(mean) def sudness(A): sad=0 for a in A: sad+=abs(a) return sad print(sudness(A-mean)) " p02818,s324974037,Wrong Answer,"a = list(map(int,input().split())) if a[0]-a[2]>=0: a[0]=a[0]-a[2] a.pop() print(a) else: a[1]=a[1]+a[0]-a[2] a[0]=0 a.pop() print(a)" p03778,s073009506,Accepted,"W, a, b = map(int, input().split()) A = [a, a + W] B = [b, b + W] if A[1] < B[0]: print(B[0] - A[1]) elif B[1] < A[0]: print(A[0] - B[1]) else: print(0)" p03785,s234112070,Accepted,"import sys n,c,k,*t = map(int, sys.stdin.read().split()) t.sort() i=0 cnt=0 while i departure or p==c: break p+=1 i+=p cnt+=1 print(cnt) " p02775,s233302460,Accepted,"n_s = input() n_s = n_s[::-1] #n = int(n_s) pay = 0 back = 0 flag = 0 dp = [[0,0] for _ in range(len(n_s) + 1)] dp[0][0] = int(n_s[0]) dp[0][1] = 10 - int(n_s[0]) for i in range(len(n_s)): i += 1 if i == len(n_s): n = 0 else: n = int(n_s[i]) 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(min(dp[-1])) " p02676,s196283140,Accepted,"def main(): num = int(input()) string = input() if len(string)<=num: print(string) else: print(string[0:num]+'...') main()" p03644,s508464418,Accepted,"import math n=int(input()) print(pow(2,math.floor(math.log2(n)))) " p02689,s493093171,Accepted,"n,m =map(int,input().split()) H=[] H=list(map(int,input().split())) C=[] for i in range(n): C.append(1) for i in range(m): a,b = map(int,input().split()) if H[a-1]==H[b-1] : C[a-1] = 0 C[b-1] = 0 elif H[a-1] k: print(k) elif (a+b) > k: print(a) else: ans = 2*a-k+b print(ans)" p03438,s097779086,Accepted,"def main(): length = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) count_operation = 0 for i in range(length): if a[i] < b[i]: count_operation -= (b[i] - a[i]) // 2 else: count_operation += a[i] - b[i] print(""Yes"" if count_operation <= 0 else ""No"") if __name__ == '__main__': main() " p03434,s624243033,Accepted,"#!/usr/bin/env python3 import sys try: from typing import List except ImportError: pass def solve(N: int, a: ""List[int]""): a.sort(reverse=True) print(sum(a[::2]) - sum(a[1::2])) def main(): def iterate_tokens(): for line in sys.stdin: for word in line.split(): yield word tokens = iterate_tokens() N = int(next(tokens)) # type: int a = [int(next(tokens)) for _ in range(N)] # type: ""List[int]"" solve(N, a) if __name__ == '__main__': main() " p02994,s112712170,Accepted,"N, L = map(int,input().split()) A = [] for i in range(N): x = L + i A.append(x) y = sum(A) B = sorted(A) if L <= 0 and L + N - 1 >= 0: print(y) elif L >= 0: y -= B[0] print(y) elif L + N - 1 < 0: y -= B[N - 1] print(y) " p02843,s143233033,Accepted,"def main(): x = int(input()) cnt = x // 100 m, M = cnt * 100, cnt * 105 if m <= x <= M: print(1) else: print(0) if __name__ == ""__main__"": main() " p03345,s750710316,Accepted,"A, B, C, K = map(int, input().split()) if K%2 == 0: print(A-B) else: print(B-A)" p02866,s275944536,Accepted,"from collections import defaultdict n = int(input()) d = list(map(int, input().split())) cnt = defaultdict(int) if d[0] != 0: print(0) else: ans = 1 for i in range(n): cnt[d[i]] += 1 for i in range(1, n): ans = (ans * cnt[d[i] - 1] % 998244353) print(ans)" p03067,s031923028,Accepted,"A, B, C = map(int, input().split()) if A < C < B or A > C > B : print(""Yes"") else : print(""No"") " p03778,s377406716,Wrong Answer,"#abc056 b w,a,b=map(int,input().split()) if ba: print(0) else: print(min(abs(b+w-a),abs(a+w-b)))" p03106,s731791027,Accepted,"a, b, k = map(int, input().split()) n = [] for i in range(1, 101): if a%i==0 and b%i==0: n.append(i) print(n[-k]) " p03565,s960297934,Accepted,"sd = input() t = input() sn = len(sd) tn = len(t) s = [] for i in range(sn-tn, -1, -1): t_kamo = sd[i: i+tn] for j in range(tn+ 1): if j == tn: print((sd[:i] + t + sd[i+tn:]).replace(""?"", ""a"")) exit() elif t_kamo[j] == ""?"": continue elif t_kamo[j] != t[j]: break print(""UNRESTORABLE"")" p03478,s986323858,Accepted,"n,a,b=map(int,input().split()) ans=0 for i in range(1,n+1): h=list(str(i)) tmp=0 for j in h: tmp+=int(j) if a<=tmp<=b: ans+=i print(ans)" p02548,s881495618,Wrong Answer,"N = int(input()) sum = 0 for A in range(1,N): if N // A > 1: for B in range(1, N // A): sum += 1 else: for B in range(1, N // A + 1): sum += 1 print(sum)" p02701,s400858153,Accepted,"n=int(input()) s = [input() for _ in range(n)] myset=set([]) for i in s: myset.add(i) print(len(myset))" p03013,s474660806,Accepted,"N,M = map(int,input().split()) a = [1]*N for i in range(M): a[int(input())-1] = 0 mod = int(1e9+7) dp = [0]*N if N == 1: print(1) exit() if a[0] and a[1]: dp[0] = 1 dp[1] = 2 elif not a[0] and a[1]: dp[1] = 1 for i in range(2,N): if a[i]: dp[i] = dp[i-1] + dp[i-2] else: dp[i] = 0 print(dp[N-1]%mod)" p03338,s960427547,Accepted,"n = int(input()) s = input() ans = 0 for i in range(1,len(s)): s1 = set(s[:i]) s2 = set(s[i:]) ans = max(ans, len(s1&s2)) print(ans)" p02582,s034743585,Wrong Answer,"tenki = input() if tenki == ""RRR"": print(3) elif tenki == ""RRS"" or tenki[1:3] == ""SRR"": print(2) elif tenki == ""RSS"" or tenki == ""SRS"" or tenki == ""SSR"": print(1) else: print(0)" p02835,s889663616,Accepted,"A=[int(x) for x in input().split()] if A[0]+A[1]+A[2]>21: print(""bust"") else: print(""win"") " p02923,s207171757,Wrong Answer,"n = int(input()) h = [int(i) for i in input().split()] ans = [] tmp = 0 for i in range(1,len(h)): if h[i-1] - h[i] >= 0: tmp += 1 else: ans.append(tmp) tmp = 0 print(tmp) " p03377,s594359991,Wrong Answer,"a, b, x = [int(i) for i in input().split()] print(""YES"" if a+b >= x else ""NO"") " p03012,s921808430,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)" p03986,s245399741,Accepted,"from collections import deque X = input() L = deque([]) for e in X: if e == ""T"" and len(L) > 0 and L[-1] == ""S"": L.pop() else: L.append(e) print(len(L)) " p03485,s965132019,Accepted,"a, b = map(int,input().split()) c = (a + b) // 2 if (a + b) / 2 == c: c = c else: c = c + 1 print(c)" p03221,s204971367,Wrong Answer,"n,m = map(int,input().split()) pyl = [list(map(int,input().split())) for nesya in range(m)] predic = dict() pyl = sorted(pyl,key = lambda x:x[1]) for py in pyl: p = py[0] if p in predic: predic[p] += 1 else: predic[p] = 1 print((str(p).zfill(6))+(str(predic[p]).zfill(6)))" p03627,s067752837,Accepted,"import collections N = int(input()) A = list(map(int, input().split())) a = collections.Counter(A) ans = [0, 0] for i in a.keys(): if a[i] >= 2: ans.append(i) if a[i] >= 4: ans.append(i) ans.sort() print(ans[-1]*ans[-2])" p03493,s452785596,Accepted,"s = str(input()) ans = int(s[0])+int(s[1])+int(s[2]) print(ans)" p02658,s987125449,Wrong Answer,"n = int(input()) a = list(map(int, input().split())) count = 1 if 0 in a: print(0) for i in a: count *= i if count > 10 ** 18: print(-1) break if count <= 10 ** 18: print(count)" p02959,s685414413,Accepted,"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[i], B[i]) if B[i] > A[i]: carry = (B[i] - A[i]) if A[i+1] > carry: ans += carry A[i+1] -= carry else: ans += A[i+1] A[i+1] = 0 print(ans)" p02570,s250475827,Accepted,"D,T,S=map(int,input().split()) if D>S*T: print('No') else: print('Yes')" p02606,s407625270,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)" p03836,s371426550,Accepted,"sx, sy, tx, ty = map(int, input().split()) for i in range(tx - sx): print(""R"",end="""") for i in range(ty - sy): print(""U"",end="""") for i in range(tx - sx): print(""L"",end="""") for i in range(ty - sy): print(""D"",end="""") print(""D"",end="""") for i in range(tx - sx + 1): print(""R"",end="""") for i in range(ty - sy + 1): print(""U"",end="""") print(""L"",end="""") print(""U"",end="""") for i in range(tx - sx + 1): print(""L"",end="""") for i in range(ty - sy + 1): print(""D"",end="""") print(""R"",end="""")" p02743,s298798369,Accepted,"a, b, c = map(int, input().split()) if 0 < c - a - b and 4 * a * b < (c - a - b) **2: print(""Yes"") else: print(""No"")" p04012,s560914164,Wrong Answer,"w = input() w = sorted(w, key = lambda x: x) ans = 1 before = w[0] for i in range(1, len(w)): if w[i] == before: ans += 1 else: if ans % 2 != 0: print(""No"") exit() before = w[i] ans += 1 print(""Yes"")" p02618,s603591931,Accepted,"for i in range(365): print(15)" p02862,s111765423,Wrong Answer,"def mod_inv(a, m): return pow(a, m-2, m) X, Y = map(int, input().split()) MOD = 10 ** 9 + 7 if (X + Y) % 3: print(0) exit() n = (X + Y) // 3 nx, ny = X - n, Y - n if nx < 0 or ny < 0: print(0) exit() ans = 1 for i in range(nx + 1, nx + ny + 1): ans = ans * mod_inv(i, MOD) % MOD for i in range(1, ny + 1): ans = ans * mod_inv(i, MOD) % MOD print(ans) " p02995,s852500494,Accepted,"from fractions import gcd a, b, c, d = map(int, input().split()) ans = b-a+1 lcm_cd = (c*d)//gcd(c, d) under_a = (a-1)//c + (a-1)//d - (a-1)//lcm_cd under_b = b//c + b//d - b//lcm_cd print(ans-(under_b-under_a)) " p03077,s351880334,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) if n%m!=0: t = n//m +5 else: t = n//m +4 print(t)" p03474,s590661863,Wrong Answer,"a, b = [int(w) for w in input().split()] s = input() cond = True if not s[:a].isnumeric(): cond = False if not s[a] == ""-"": cond = False if not s[a+2:].isnumeric(): cond = False print(""Yes"" if cond else ""No"") " p02948,s471057991,Accepted,"import heapq N, M = map(int, input().split()) AB = [list(map(int, input().split())) for _ in range(N)] job = sorted(AB) reward_list = [] ans = 0 j = 0 for i in range(1, M + 1): while j < N and job[j][0] <= i: heapq.heappush(reward_list, -job[j][1]) j += 1 if len(reward_list) > 0: ans -= heapq.heappop(reward_list) print(ans) " p02730,s218206003,Accepted,"S = input() N = len(S) def f(s): n = len(s) for i in range((n-1)//2+1): if s[i] != s[n-i-1]: return False return True if f(S) and f(S[:(N-1)//2]): print(""Yes"") else: print(""No"")" p03720,s877956864,Accepted,"#!/usr/bin/env python3 (n, m), *r = [[*map(int, i.split())] for i in open(0)] for i in range(1, n + 1): print(sum(r, []).count(i)) " p03328,s586848225,Accepted,"a,b=map(int,input().split()) c=b-a ans=0 for i in range(1,c+1): ans+=i print(ans-b)" p03251,s191883106,Accepted,"def readinput(): n,m,x,y=map(int,input().split()) xx=list(map(int,input().split())) yy=list(map(int,input().split())) return n,m,x,y,xx,yy def main(n,m,x,y,xx,yy): xx.append(x) yy.append(y) xx.sort() yy.sort() if xx[-1]c and c>b: print(""Yes"") elif a= M: print(N) else: x = (M - 2 * N) / 4 N += int(x) M -= 2 * int(x) print(N) " p03331,s494069244,Accepted,"n = int(input()) l = [] for i in range(1, n // 2 + 1): a = str(i) b = str(n - i) k = 0 for j in range(len(a)): k += int(a[j]) for j in range(len(b)): k += int(b[j]) l.append(k) print(min(l))" p02660,s009421869,Accepted,"n = int(input()) a = set() i = 2 res = 0 while i * i <= n: if (n % i) == 0: count = 0 while n % i == 0: count += 1 n //= i dif = 1 while count >= dif: res += 1 count -= dif dif += 1 i += 1 if n != 1: res += 1 print(res) " p02744,s663744142,Accepted,"n = int(input()) def dfs(a, used=0): if len(a)==n: print(''.join(a)) else: for i in range(ord('a'), ord('a')+used+1): if i == ord('a')+used: dfs(a+[chr(i)], used+1) else: dfs(a+[chr(i)], used) dfs([], 0) " p02836,s086186246,Accepted,"S = input() l = [i for i in S] count = 0 while len(l) > 1: if l.pop(0) != l.pop(-1): count += 1 print(count)" p02705,s031832063,Wrong Answer,"n = float(input()) print(n*3.14159265)" p03645,s629526246,Accepted,"N, M = map(int, input().split()) from_1 = set() to_N = set() for i in range(M): a, b = map(int, input().split()) if a == 1: from_1.add(b) if b == N: to_N.add(a) if len(from_1 & to_N) >= 1: print('POSSIBLE') else: print('IMPOSSIBLE')" p03327,s220283058,Accepted,print('ABC'*(len(input())<4)or'ABD') p02688,s866629127,Accepted,"n, k = [int(i) for i in input().split()] s = [i + 1 for i in range(n)] for i in range(k): d = int(input()) ns = [int(j) for j in input().split()] for l in ns: s.remove(l) if l in s else None print(len(s))" p02731,s507492849,Accepted,"n=float(input()) # float print(""%.6f"" % pow(n/3, 3))" p03013,s476025064,Wrong Answer,"N,M=map(int,input().split()) def steps(N,M): if M==0: return print(0) else: a=[] for i in range(M): a.append(int(input())) for i in range(M-1): if a[i+1]-a[i]==1: return print(0) b=[1,1] for j in range(N): b.append(b[-1]+b[-2]) ans=1 a.append(N+1) a.insert(0,-1) for i in range(M+1): c=a[i+1]-a[i]-2 ans*=(b[c]) return print(ans%1000000007) steps(N,M)" p02797,s339577277,Wrong Answer,"import sys N, K, S = map(int, input().split()) if N == K: ans = '' for i in range(N): ans += str(S) + ' ' print(ans.rstrip()) sys.exit() ans = '' s1, s2 = 0, 0 if S % 2 == 0: s1 = s2 = S // 2 else: s1 = S // 2 s2 = s1 + 1 for i in range(N): if i % 2 == 0 and i <= K: ans += str(s1) + ' ' elif i <= K: ans += str(s2) + ' ' else: ans += str(S + 1) + ' ' print(ans.strip()) " p02958,s014040374,Accepted,"N = int(input()) p = list(map(int, input().split())) count = 0 for i in range(0, N): if p[i] != i + 1: count += 1 print(""NO"") if count > 2 else print(""YES"")" p02917,s313257814,Accepted,"n = int(input()) b = list(map(int,input().split())) a = [b[0]] for i in b: if a[-1] > i: a[-1] = i a.append(i) print(sum(a)) " p04020,s236993796,Wrong Answer,"import sys INF = 10 ** 10 MOD = 10 ** 9 + 7 from functools import lru_cache sys.setrecursionlimit(100000000) def main(): n = int(input()) ans = 0 before = 0 for _ in range(n): a = int(input()) ans += a//2 if (a%2) and before : ans += 1 before = 0 else: before = a%2 print(ans) if __name__ =='__main__': main() " p03386,s703725465,Wrong Answer,"a,b,k=map(int,input().split()) if b-a<=2*k: for i in range(a,b+1): print(i) else: for i in range(a,a+k): print(i) for j in range(b-k+1,b+1): print(j)" p03971,s667885592,Accepted,"# -*- coding: utf-8 -*- n,a,b = map(int,input().split()) s = list(input()) count = 0 tmp = 0 for i in range(n): if s[i] == 'a' and count < a + b: count += 1 print(""Yes"") elif s[i] == 'b' and count < a + b and tmp < b: count += 1 tmp += 1 print(""Yes"") else: print(""No"") " p02755,s874493475,Accepted,"import sys input = sys.stdin.readline a,b=map(int,input().split()) for i in range(1,1010): if int(i*0.08) == a and int(i*0.1) ==b: print(i) break else: print(-1) " p02553,s052828696,Wrong Answer,"a,b,c,d=map(int,input().split()) ac=a*c ad=a*d bc=b*c bd=b*d if max(ac,ad,bc,bd)<0: if a<0=d: break k+=1 for j in range(k+1): S2+=w[j] print(abs(sum(w)-2*S2))" p03633,s677529050,Accepted,"N = int(input()) T = [int(input()) for _ in range(N)] import fractions from functools import reduce 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)) " p02947,s632767304,Wrong Answer,"import sys input = sys.stdin.readline def main(): N = int(input()) s = ["""".join(sorted(input())) for i in range(N)] # print(s) S = set(s) # print(S) print(len(s)-len(S)) if __name__ == '__main__': main() " p03804,s867387665,Wrong Answer,"n,m=map(int,input().split()) a=[input() for _ in range(n)] b=[input() for _ in range(m)] b1=b[0] res=""No"" for i in range(n-m+1): if b1 in a[i]: x=a[i].index(b1) match=1 for j in range(1,m): if a[i+j][x:]!=b[j]: match=0 if match: res=""Yes"" print(res)" p02760,s807872396,Accepted,"a=[list(map(int,input().split()))for _ in range(3)] for i in range(int(input())): b=int(input()) for j in range(3): for k in range(3): if a[j][k]==b:a[j][k]=0 ans=""No"" for i in range(3): if a[i][0]==a[i][1]==a[i][2]==0:ans=""Yes"" if a[0][i]==a[1][i]==a[2][i]==0:ans=""Yes"" if a[0][0]==a[1][1]==a[2][2]==0:ans=""Yes"" if a[2][0]==a[1][1]==a[0][2]==0:ans=""Yes"" print(ans) " p02596,s800517986,Wrong Answer,"K = input() K = int(K) def seven(): seven_i = 0 count = 0 for i in range(K): seven_i += (10**i*7) seven_i %= K count += 1 print(seven_i) if seven_i % K == 0: return count return -1 print(seven())" p02691,s476614893,Wrong Answer,"n=int(input()) heights=list(map(int,input().split("" ""))) for i in range(n): heights[i]-=i res=len(heights)-len(set(heights)) if res==0: print(0) else: print(res+1)" p03854,s473233494,Accepted,"n = input() t = [""dream"", ""dreamer"", ""erase"", ""eraser""] while True: if not n: status = ""YES"" break elif n[-5:] in t: n = n[:-5] elif n[-6:] in t: n = n[:-6] elif n[-7:] in t: n = n[:-7] else: status = ""NO"" break print(status)" p02924,s280259164,Accepted,"import math n = int(input()) if (n-1)%2 == 0: a = int((n-1)/2) ans = n*a else: ans = n * math.floor((n-1)/2) + math.ceil((n-1)/2) print(int(ans))" p03761,s905895112,Accepted,"def main(): n = int(input()) ss = [list(input()) for _ in range(n)] ss_set = sorted(list(set(ss[0]))) ans = '' for ch in ss_set: cnt = min(ss[i].count(ch) for i in range(n)) ans += ch * cnt print(ans) if __name__ == ""__main__"": main() " p03106,s436772838,Accepted,"a, b, k = map(int, input().split()) c = 0 for i in range(a, -1, -1): if a % i == 0 and b % i == 0: c += 1 if c == k: print(i) break" p03555,s077170478,Accepted,"import sys input = sys.stdin.readline c1 = input().rstrip() c2 = input().rstrip()[-1::-1] print('YES' if c1 == c2 else 'NO') " p03427,s000785394,Accepted,"N = list(input()) if N[1:].count('9') == len(N[1:]): print(int(N[0]) + 9 * (len(N) - 1)) else: print(int(N[0]) + 9 * (len(N) - 1) - 1) " p03485,s783647170,Wrong Answer,"a,b = map(int,input().split()) x = (a+b)//2 print(x) " p03997,s985757671,Accepted,"a = int(input()) b = int(input()) h = int(input()) print((a+b)*h//2)" p02972,s163858595,Accepted,"N = int(input()) A = list(map(int,input().split())) ans = [0]*(N+1) for i in range(N,0,-1): c = 0 for j in range(i,N+1,i): c += ans[j] if (A[i-1] == 0 and c % 2 == 1) or (A[i-1] == 1 and c % 2 == 0): ans[i] = 1 print(sum(ans)) for i in range(1,N+1): if ans[i] == 1: print(i,end="" "")" p02695,s647513783,Accepted,"import itertools n, m, q = map(int, input().split()) e = [] for i in range(q): e.append(list(map(int, input().split()))) a = itertools.combinations_with_replacement(list(range(1, m+1)),n) max_total = 0 for i in a: total = 0 for j in e: if i[j[1]-1] - i[j[0]-1] == j[2]: total += j[3] if max_total < total: max_total = total print(max_total)" p02795,s371212187,Accepted,"h = int(input()) w = int(input()) n = int(input()) s = max(h,w) if n%s==0: print(int(n/s)) else: print((n//s)+1)" p02630,s060257816,Accepted," def solve(): n=int(input()) a=list(map(int,input().split())) cnt=[0]*(int(1e5)+9) s=0 for i in range(0,n) : s+=a[i] cnt[a[i]]+=1 q=int(input()) for q in range(0,q) : b,c=map(int,input().split()) ct=cnt[b] s+=ct*(c-b) cnt[b]=0 cnt[c]+=ct print(s) solve() " p02761,s311524096,Accepted,"import sys N, M = map(int, input().split()) S = [] C = [] for m in range(M): s, c = map(int, input().split()) S.append(s) C.append(c) for i in range(10**N): tes = str(i) if len(tes) != N: continue flag = True for s, c in zip(S, C): if tes[s-1] != str(c): flag = False if flag: print(tes) sys.exit() print(-1)" p02708,s578612798,Accepted,"import math n, k = map(int,input().split()) total = 0 mod = 10**9+7 max_value = (n*(n+1)) //2 for a in range(k,n+1): high = (max_value-(n-a)*(n-a+1)//2) low = (a*(a-1)) //2 total += high - low + 1 total += 1 # k = n+1 print(total%mod)" p03210,s104483292,Wrong Answer,"X = int(input()) ans = ""Yes"" if X == 7 or X == 5 or X == 3 else ""No"" print(ans) " p02602,s371836086,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"")" p03281,s096502939,Accepted,"n=int(input()) a=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: a+=1 print(a)" p02618,s148463186,Accepted,"import sys read = sys.stdin.read readline = sys.stdin.buffer.readline from numpy.random import randint sys.setrecursionlimit(10 ** 8) INF = float('inf') MOD = 10 ** 9 + 7 def main(): # D = 365 D = int(readline()) C = list(map(int, readline().split())) S = list(list(map(int, readline().split())) for _ in range(D)) for _ in range(D): print(randint(1,26)) if __name__ == '__main__': main() " p02606,s969196544,Wrong Answer,"L,R,d = map(int,input().split()) print(R//d - L//d + 1) " p03698,s263074303,Wrong Answer,"s = input() for i in range(len(s)-1): if s[i]==s[i+1]: print(""no"") exit() print(""yes"")" p02647,s875597796,Accepted,"n,k,*a=map(int,open(0).read().split()) r=range(n) while(min(a) 0: X //= 5 ans += X print(ans) " p02791,s201810754,Accepted,"n = int(input()) p = list(map(int, input().split( ))) c = 0 m = p[0] for i in range(n): if m >= p[i]: c += 1 m = p[i] print(c)" p03543,s314834772,Accepted,"n=input() if n[0]==n[1]==n[2]: print(""Yes"") elif n[1]==n[2]==n[3]: print(""Yes"") else: print(""No"")" p02718,s074923215,Accepted,"def resolve(): N, M = map(int,input().split()) S = tuple(map(int, input().split())) g = sum(S) * (1/(4*M)) count = 0 ans = 'No' for s in S: if s >= g: count += 1 if count == M: ans = 'Yes' break print(ans) if __name__ == '__main__': resolve() " p03274,s921047784,Accepted,"n,k = map(int, input().split()) x = list(map(int, input().split())) ans = float(""inf"") for i in range(n-k+1): l = abs(x[i]) + abs(x[i]-x[i+k-1]) r = abs(x[n-1-i]) + (x[n-1-i]-x[n-k-i]) ans = min(ans,l,r) print(ans)" p02631,s885208805,Accepted,"import sys def input(): return sys.stdin.readline()[:-1] def main(): N = int(input()) A = list(map(int,input().split())) t = 0 for e in A: t ^= e print(*[A[k]^t for k in range(N)]) if __name__ == '__main__': main() " p02630,s204611904,Accepted,"from collections import Counter n = int(input()) a = [int(i) for i in input().split()] s = sum(a) count = Counter(a) q = int(input()) b_c = [list(map(int, input().split())) for i in range(q)] for i in b_c: s += (i[1] - i[0]) * count[i[0]] count[i[1]] += count[i[0]] count[i[0]] = 0 print(s)" p02675,s504319332,Accepted,"N=input() if N[-1]==""3"": print(""bon"") elif N[-1] in {""0"",""1"",""6"",""8""}: print(""pon"") else: print(""hon"")" p03457,s713467023,Accepted,"def main(): N = int(input()) t,x,y = 0,0,0 ans = 'Yes' for i in range(N): ti,xi,yi = (int(x) for x in input().split()) dt = ti - t dist = abs(xi-x) + abs(yi-y) if dt < dist or dist%2 != dt%2: ans = 'No' break else: t,x,y = ti,xi,yi print(ans) if __name__ == '__main__': main()" p02597,s177403350,Accepted,"n = int(input()) c = input() t = c.count('R') ans = 0 for i in range(n): if c[i] == 'R' and t <= i: ans += 1 print(ans) " p04012,s781136538,Wrong Answer,"line = input() if line.count(""a"")==4 and line.count(""b"")==2 and line.count(""c"")==2 and len(line)==8: print(""Yes"") else: print(""No"")" p03986,s833591162,Wrong Answer," X = input() idx = 0 for i in range(len(X)): j = len(X) - i - 1 if X[len(X)-i-1] == 'T': idx = j break print(len(X) - X[:idx].count('S')*2)" p03815,s992355775,Accepted,"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 else: count += 1 print(count)" p02754,s796460965,Accepted,"n,a,b = map(int,input().split()) ans = n//(a+b) * a if n%(a+b) < a: ans += n%(a+b) else: ans += a print(ans)" p02952,s185504604,Accepted,"n = int(input()) def countKeta (num): return len(str(num)) count = 0 for i in range(1,n+1): if countKeta(i) % 2 == 1: count += 1 print(count)" p02571,s692083878,Accepted,"s=list(input()) t=list(input()) ans=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 ans=max(ans,cnt) print(len(t)-ans)" p02689,s155090563,Wrong Answer,"N,M = map(int,input().split()) H = list(map(int,input().split())) XX = [set() for i in range(N)] ans = 0 for i in range(M): A,B = map(int,input().split()) XX[A-1].add(B-1) XX[B-1].add(A-1) for i in range(N): for y in XX[i]: r = True if H[i]<=H[y]: r = False break if r: ans += 1 print(ans) " p02730,s574341798,Accepted,"s=str(input()) n=len(s) x=s[:(n-1)//2] y=s[(n+3)//2-1:] ans=0 for i in range(3): if s==s[::-1]: ans +=1 if i==0: s=x elif i==1: s=y print(""Yes"" if ans==3 else ""No"")" p02748,s004946031,Accepted,"A, B, M = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) x = [None]*M y = [None]*M c = [None]*M for i in range(M): x[i],y[i],c[i] = map(int, input().split()) #print(x,y,c) ans = min(a)+min(b) for i in range(M): tmp = a[x[i]-1]+b[y[i]-1]-c[i] if tmp < ans: ans = tmp print(ans)" p03730,s323878823,Accepted,"A, B, C = map(int, input().split()) ans = ""NO"" for i in range(1, B+1): if (A*i) % B == C: ans = ""YES"" break print(ans) " p03637,s574128555,Wrong Answer,"n = int(input()) a = list(map(int, input().split())) x = 0 y = 0 z = 0 for i in a: if i%4 == 0: x += 1 elif i == 2: y += 1 else: z += 1 if y%2+z-1 <= x: print(""Yes"") else: print(""No"")" p03767,s552093743,Accepted,"import sys, re, os from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians from itertools import permutations, combinations, product, accumulate from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii_uppercase, digits def input(): return sys.stdin.readline().strip() def INT(): return int(input()) def MAP(): return map(int, input().split()) def S_MAP(): return map(str, input().split()) def LIST(): return list(map(int, input().split())) def S_LIST(): return list(map(str, input().split())) sys.setrecursionlimit(10 ** 9) INF = float('inf') mod = 10 ** 9 + 7 N = INT() A = LIST() A.sort(reverse=True) ans = 0 print(sum(A[1::2][:N])) " p02663,s171273711,Accepted,"H1, M1, H2, M2, K = map(int, input().split()) ans = (H2 - H1)*60 + (M2-M1) - K print(ans)" p02684,s665261427,Accepted,"n,k=map(int,input().split(' ')) a=list(map(int,input().split(' '))) loc=1 begin=0 end=0 d={1:0} for i in range(n+1): loc=a[loc-1] if loc in d.keys(): begin=d[loc] end=i+1 break d[loc]=i+1 if k<=end: end=0 if end==begin+1: k=begin end=0 if end != 0: x=(k-begin+1)%(end-begin) if x==0: x=end-begin k=x+begin-1 loc=1 for _ in range(k): loc=a[loc-1] print(loc)" p02702,s985171008,Accepted,"def main(): n, d, mods = 0, 1, [1]+[0]*2019 for i in reversed(input()): n = (n+int(i)*d)%2019 d = d*10%2019 mods[n] += 1 print(sum([i*(i-1)//2 for i in mods])) main()" p02583,s379878428,Accepted,"from itertools import combinations as C N = int(input()) L = list(map(int, input().split())) L = list(C(L, 3)) ans = 0 for l in L: l = list(l) l.sort() #print(l) if l[0] == l[1] or l[1] == l[2] or l[0] == l[2]: continue if l[0] + l[1] > l[2]: ans += 1 print(ans)" p02719,s256977058,Wrong Answer,"a,b = map(int, input().split()) if abs(a-b) > a: print(a) else: if a%b == 0: print(0) else: print(a//b)" p03804,s778671402,Accepted,"N, M = map(int, input().split()) A = [list(input()) for _ in range(N)] B = '' for _ in range(M): B += input() ans = 'No' for i in range(N-M+1): for j in range(N-M+1): sbstr = '' for k in range(M): sbstr += ''.join(A[i+k][j:j+M]) if B == sbstr: ans = 'Yes' print(ans) " p03162,s989910704,Accepted,"import sys sys.setrecursionlimit(int(1e6)) n=int(input()) l=[[0,0,0]] for _ in range(n): l.append(list(map(int,input().split()))) memo=[[-1,-1,-1] for _ in range(n+1)] memo[0][0]=0 memo[0][1]=0 memo[0][2]=0 def dp(i,j): if memo[i][j]!=-1: return memo[i][j] else: memo[i][j]=max(dp(i-1,(j+1)%3)+l[i][j],dp(i-1,(j+2)%3)+l[i][j]) return memo[i][j] print(max(dp(n,0),dp(n,1),dp(n,2)))" p03220,s490081282,Accepted,"n = int(input()) t, a = map(int, input().split()) hh = tuple(map(int, input().split())) ans = 0 for i in range(1, n): if abs(t - hh[ans] * 0.006 - a) > abs(t - hh[i] * 0.006 - a): ans = i print(ans + 1) " p02778,s557659498,Wrong Answer,"S = input() S_number = len(S) print(""X"" * S_number)" p03059,s207905787,Accepted,"t, mai, lim = (int(x) for x in input().split()) total = 0 for i in range(1,lim+1): if i%t == 0: total += mai print(total)" p02582,s733961347,Accepted,"s = input() if s == ""RRR"" : print(3) elif s ==""RRS"" or s ==""SRR"" : print(2) elif ""R"" in s: print(1) else: print(0) " p03407,s342592400,Wrong Answer,"a,b,c = map(int,input().split()) if c > a + b*2: print('No') else: print('Yes')" p02912,s159110638,Accepted,"[N,M] = list(map(int,input().split())) A = list(map(int,input().split())) out=sum(A) import heapq a = list(map(lambda x: x*(-1), A)) # 各要素を-1倍 最大値取り出すため heapq.heapify(a) # print(a) for i in range(M): # saidai = max(A) saidai = heapq.heappop(a)*(-1) out-=saidai out+=saidai//2 # A[A.index(saidai)] = saidai//2 heapq.heappush(a, (saidai//2)*(-1)) # print('dam,out,a:',saidai,out,a) print(out) " p03087,s801612841,Accepted,"# coding: utf-8 import sys import itertools sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) N, Q = lr() S = sr() ac = [0] * (N-1) for i, x in enumerate(zip(S[:], S[1:])): if x[0] == 'A' and x[1] == 'C': ac[i] = 1 cum = list(itertools.accumulate(ac)) for _ in range(Q): l, r = lr() result = cum[r-2] if l > 1: result -= cum[l-2] print(result) " p02598,s999640718,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) A.sort(reverse=True) def isfeasible(L): k = 0 for a in A: if a < L: break if a%L == 0: dk = a//L - 1 else: dk = a//L k += dk if k > K: return False return True l = 0 r = A[0] while r-l>1: L = (r+l)//2 if isfeasible(L): r = L else: l = L print(r)" p02759,s043455514,Accepted," a = int(input()) print(a//2+(a%2!=0))" p03565,s940033612,Wrong Answer,"s,t=input(),input() q = '?'*len(t) judge = False for i in range(len(s)): if (s[i:len(t)+i][0]==t[0] and s[i:len(t)+i][1:]==q[1:]) or s[i:len(t)+i]==q: s = s[:i] + t + s[len(t)+i:] judge = True break if judge: s = ['a' if i=='?' else i for i in s] print(''.join(s)) else: print('UNRESTORABLE')" p02725,s012227974,Accepted,"K,N=map(int,input().split()) A=list(map(int,input().split())) memo=A[0] for i in range(N-1): Bi=A[i+1]-A[i] if Bi>memo: memo=Bi if memo<=K-A[N-1]+A[0]: print(A[N-1]-A[0]) else: print(K-memo)" p02795,s954195633,Accepted,"def main(): h = int(input()) w = int(input()) n = int(input()) if h >= w: big = h else: big = w if n <= big: print(1) exit() for i in range(big+1): if i * big >= n: count = i print(count) exit() if __name__ == '__main__': main()" p03745,s884163036,Wrong Answer,"N = int(input()) alst = list(map(int, input().split())) now = 'increase' or 'decrease' cnt = 1 for i in range(1, N): x = now if alst[i] - alst[i - 1] > 0: tmp = 'increase' else: tmp = 'decrease' if tmp != x: cnt += 1 x = tmp print(cnt) " p03548,s683677055,Accepted,"x, y, z = [int(s) for s in input().split()] print((x - z) // (y + z))" p02909,s854305115,Accepted,"a = input() weather_today = {'Sunny':0 , 'Cloudy':1 , 'Rainy':2} weather_next = ['Cloudy', 'Rainy','Sunny'] print(weather_next[weather_today[a]])" p02621,s388966245,Accepted,"a = int(input()) ans = int(a + a**2 + a**3) print(ans)" p02802,s326937726,Wrong Answer,"n,m = list(map(int, input().split())) wa_cnt = 0 ac = set() for _ in range(m): p, s = input().split() if(s == ""AC""): ac.add(p) if (p not in ac and s==""WA""): wa_cnt += 1 print(len(ac), wa_cnt)" p02705,s905805244,Accepted,"import math r = int(input()) print(r*2*math.pi)" p02612,s367439546,Accepted,"n = int(input()) if (n%1000) != 0: print(1000-(n%1000)) else: print(0) " p02773,s328881914,Accepted,"import collections n = int(input()) s = [input() for _ in range(n)] s = collections.Counter(s).most_common() mx = s[0][1] ans = [] for k, v in s: if mx == v: ans.append(k) for i in sorted(ans): print(i)" p03061,s859356994,Accepted,"import fractions N = int(input()) A = list(map(int, input().split())) l = [0] r = [0] for i in range(N - 1): l += [fractions.gcd(l[i], A[i])] r += [fractions.gcd(r[i], A[-i-1])] print(max(fractions.gcd(l[i], r[-i-1]) for i in range(N)))" p02786,s952429805,Accepted,"h = int(input()) n_list = [0 for i in range(40)] n_list[0] = 1 count = 1 ans = 0 while h > 1: h = h // 2 n_list[count] = 1 count += 1 for i in range(40): ans += n_list[i] * (2**i) print(ans)" p02618,s758430458,Accepted,"for i in range(365): print(1)" p02659,s693824202,Accepted,"import decimal a,b =map(str,input().split()) a2 = decimal.Decimal(a) b2 = decimal.Decimal(b) print(int(a2*b2))" p03285,s001781087,Wrong Answer,"N = int(input()) flag = False n = 7 while n < N: if (N % n) % 4 == 0 or N % 4 == 0 or N % 7 == 0: flag = True break n += 7 print(""Yes"" if flag else ""No"")" p03469,s291551992,Accepted,"S = input() print('2018'+S[4:])" p02695,s351981786,Accepted,"from itertools import combinations_with_replacement N, M, Q = map(int, input().split()) Ques = [ list(map(int, input().split())) for _ in range(Q) ] Nums = [ i for i in range(M) ] ans = -1 for v in combinations_with_replacement(Nums, N): cnt = 0 for que in Ques: if v[que[1]-1]-v[que[0]-1] == que[2]: cnt += que[3] ans = max(ans, cnt) print(ans)" p02814,s840326962,Accepted,"from fractions import gcd import sys input = sys.stdin.buffer.readline def f(x): cnt = 0 while x % 2 == 0: x //= 2 cnt += 1 return cnt n, m = map(int, input().split()) a = list(set([int(i) // 2 for i in input().split()])) b = f(a[0]) for i in a: if f(i) != b: print(0) exit() l = 1 for i in a: l = l * i // gcd(l, i) print((m // l + 1) // 2)" p03385,s993035838,Accepted,"s = input() print(""Yes"" if """".join(sorted(s)) == ""abc"" else ""No"")" p04034,s572283366,Accepted,"N,M = map(int,input().split()) xy = [list(map(int,input().split())) for _ in range(M)] ball_count = [1]*N visited = [0]*N visited[0] = 1 for x,y in xy: ball_count[x-1] -= 1 ball_count[y-1] += 1 if visited[x-1] == 1: visited[y-1] = 1 if ball_count[x-1] == 0: visited[x-1] = 0 print(sum(visited))" p02813,s140188829,Accepted,"# ABC150 C si = lambda: input() ni = lambda: int(input()) nm = lambda: map(int, input().split()) nl = lambda: tuple(map(int, input().split())) import itertools n=ni() p=nl() q=nl() if p==q: print(0) exit() L=[] for i in range(n): L.append(i+1) a=0 b=0 idx=1 for l in list(itertools.permutations(L)): idx+=1 if l==p: a=idx elif l==q: b=idx print(abs(a-b)) " p02603,s417757940,Accepted,"n = int(input()) a = list(map(int, input().split())) money = 1000 stock = 0 for i in range(n): # 売る money += stock * a[i] stock = 0 # 買う if i != n - 1 and a[i] < a[i + 1]: stock = money // a[i] money %= a[i] print(money) " p02861,s947353365,Accepted,"#ABC145.C N = int(input()) x = [] c=0 for i in range(N): x1=[int(i) for i in input().split()] x.append(x1) for i in range(N): for m in range(N): if i!=m: c+=((x[i][0]-x[m][0])**2+(x[i][1]-x[m][1])**2)**0.5 print(c/N)" p02918,s480575357,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, K = rl() S = rs() import itertools g = list(itertools.groupby(S)) print(N-max(len(g)-1-2*K, 0)-1) " p02912,s576674221,Accepted,"# -*- coding: utf-8 -*- N, M = map(int, input().split(' ')) A = list(map(int, input().split(' '))) import heapq priority_queue = [] for a in A: heapq.heappush(priority_queue, -a) for _ in range(M): a = -1 * heapq.heappop(priority_queue) a //= 2 heapq.heappush(priority_queue, -a) ans = sum([-1 * a for a in priority_queue]) print(ans) " p02699,s986118650,Wrong Answer,"S, W = map(int, input().split()) if S < W: print(""unsafe"") else: print(""safe"")" p04011,s122178729,Accepted,"l=[int(input()) for i in range(4)] print(l[0]*l[2]-max(l[0]-l[1],0)*(l[2]-l[3]))" p03086,s070585866,Accepted,"from math import gcd import re s=input() match=re.findall(""[ACGT]*"",s) length=0 for i in match: length=max(length,len(i)) print(length)" p03617,s722715902,Accepted,"Q, H, S, D = map(int, input().split()) N = int(input()) n = N//2 ans = min(D, 2*S, 4*H, 8*Q)*n + min(S, 2*H, 4*Q)*(N%2) print(ans)" p02924,s219383848,Accepted,"n = int(input()) t=(n-1)*n//2 print(t)" p02911,s787179570,Accepted,"n,k,q = map(int,input().split()) A = [0 for _ in range(n)] for _ in range(q): a = int(input()) A[a-1] += 1 for a in A: if a > q-k: print('Yes') else: print('No') " p03474,s861976744,Accepted,"a, b = (int(i) for i in input().split()) s = input() for i in range(a+b+1): if i == a: if not s[i] == '-': print('No') exit() else: if not s[i] >= '0' or not s[i] <= '9': print('No') exit() print('Yes')" p02859,s178099582,Accepted,"r=int(input()) print(r*r)" p02958,s452690562,Accepted,"n = int(input()) p = list(map(int, input().split())) cnt = 0 for i in range(n): if i+1 != p[i]: cnt += 1 if cnt == 0 or cnt == 2: print(""YES"") else: print(""NO"")" p03555,s361220704,Accepted,"s = input() + input() print(""YES"" if s == s[::-1] else ""NO"")" p02606,s868285504,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)" p02789,s813190831,Accepted,"n, m = map(int,input().split()) print(""Yes"") if n == m else print(""No"")" p02988,s004666687,Wrong Answer,"import math #import numpy def readints(): return list(map(int, input().split())) n = int(input()) p = readints() print(p) sum = 0 for i in range(n-2): #print(p[i], end="""") #print(p[i+1], end="""") #print(p[i+2], end="""") if p[i] < p[i+1] < p[i+2] or p[i] > p[i+1] > p[i+2]: sum += 1 print(sum) " p03817,s931551451,Accepted,"x = int(input()) # mod = 10 ** 9 + 7 tmp = x // 11 nokori = x % 11 if nokori == 0: print(tmp * 2) elif nokori > 6: print(tmp * 2 + 2) else: print(tmp * 2 + 1)" p03592,s839256085,Accepted,"N,M,K=map(int,input().split()) flag=False for n in range(N+1): for m in range(M+1): if (N-n)*m+(M-m)*n==K: flag=True print(""Yes"" if flag else ""No"")" p03087,s253780631,Accepted,"n,q = map(int,input().split()) s = str(input()) a = [0]*(n+1) c = 0 for i in range(n-1): if s[i] == ""A"" and s[i+1] == ""C"": c += 1 a[i+2] = c for i in range(q): l,r = map(int,input().split()) print(a[r]-a[l])" p02684,s150063479,Accepted,"n,k,*a=map(int,open(0).read().split()) v=[0]+[-1]*n t=a[0]-1 c=1 while v[t]<0: v[t]=c t=a[t]-1 c+=1 l=v[t] c-=l print(v.index(min(k,l+(k-l)%c))+1)" p02706,s630107132,Wrong Answer,"n = input().split() m = input().split() n = [int(i) for i in n] m = [int(i) for i in m] a = n[0] for i in m: a -= i if a<0: print(""-1"") else: print(a)" p03380,s864023097,Accepted,"import scipy.misc N=int(input()) X=list(map(int,input().split())) SX=sorted(X) M=SX.pop() MV=10**9 ANS=0 for x in SX: z = abs(M - x - x) if MV > z: MV = z ANS = x print(""{} {}"".format(M,ANS)) " p03077,s771823735,Wrong Answer,"n,a,b,c,d,e=[int(input()) for i in range(6)] print(n//min(a,b,c,d,e)+5)" p03627,s715842217,Wrong Answer,"n=int(input()) a=list(map(int,input().split())) b=list(set(a)) b.reverse() c=[] for i in b: if a.count(i)>=4: c+=[i] c+=[i] break elif a.count(i)>=2: c+=[i] if len(c)>=2: break if len(c)>=2: print(c[0]*c[1]) else: print(0) " p03416,s883022507,Wrong Answer,"# -*- coding: utf-8 -*- A, B = map(int, input().split()) ans = 0 tmp_left = '' tmp_right = '' for x in range(A, B + 1): tmp_left = str(x)[0] + str(x)[1] tmp_right = str(x)[-2] + str(x)[-1] if tmp_left == tmp_right: ans += 1 print(ans)" p03408,s254283817,Accepted,"from collections import Counter N = int(input()) blue = [] for _ in range(N): blue.append(input()) blue = Counter(blue) M = int(input()) red = [] for _ in range(M): red.append(input()) red = Counter(red) diff = blue - red if len(diff)==0: print(0) else: print(max(diff.values()))" p03627,s590891479,Accepted,"n = int(input()) a = list(map(int,input().split())) a.sort(reverse=True) tmp = a[0] ans = [] cnt = 0 for i in range(1,len(a)): if tmp == a[i]: cnt += 1 if cnt == 1 or cnt == 3: ans.append(tmp) else: tmp = a[i] cnt = 0 if len(ans) < 2: print(0) else: print(ans[0]*ans[1])" p02705,s030692032,Accepted,"import math r=int(input()) print(2*math.pi*r)" p03434,s449018688,Wrong Answer,"N = int(input()) A = sorted(map(int, input().split())) print(sum(A[0::2]) - sum(A[1::2])) " p02623,s306977499,Wrong Answer,"n,m,k = map(int,input().split()) a = list(map(int,input().split())) b = list(map(int,input().split())) na = [] c = 0 for booka in a: c += booka na.append(c) nb = [] d = 0 for bookb in b: d += bookb nb.append(d) maxa = 0 for i in range(n-1,-1,-1): for j in range(m-1,-1,-1): if na[i] + nb[j] <= k: maxa = max(maxa,i+j+2) break print(maxa)" p03997,s818887832,Accepted,"def main(): a = int(input()) b = int(input()) h = int(input()) ans = (a+b)*h//2 print(ans) if __name__ == ""__main__"": main() " p02765,s576759201,Accepted,"n,r=map(int,input().split()) print(max(0,10-n)*100+r)" p02813,s762077369,Wrong Answer,"import itertools n = int(input()) p = list(map(int, input().split())) q = list(map(int, input().split())) a,b = 0,0 flag = 0 ix = list(itertools.permutations(range(1,1+n))) for i in range(len(ix)): t = list(ix[i]) if (p == t): a = i flag += 1 elif (q == t): b = i flag += 1 if (flag == 2): break print(abs(a-b)) " p03035,s120486942,Accepted,"a,b = map(int,input().split()) if a>=13: print(b) elif a>=6: print(b//2) else: print(0) " p02922,s049611963,Accepted,"import math A,B=map(int,input().split()) print(math.ceil((B-1)/(A-1)))" p03323,s996467425,Accepted,"import sys def input(): return sys.stdin.readline().strip() def mapint(): return map(int, input().split()) sys.setrecursionlimit(10**9) A, B = mapint() if A>8 or B>8: print(':(') else: print('Yay!')" p04034,s125328442,Wrong Answer,"N, M = map(int,input().split()) x,y = [],[] for _ in range(M): tx,ty = map(int, input().split()) x.append(tx) y.append(ty) flg = [0] * (N+1) flg[1] = 1 cnt = [1] * (N+1) #フラグが1が経っているところからは、移動することで赤を移せる。 for i in range(M): cp,np = x[i],y[i] if flg[cp] == 1: if cnt[cp] == 1: flg[cp] = 0 cnt[cp] -= 1 cnt[np] += 1 flg[np] = 1 print(sum(flg)) " p02690,s774476582,Wrong Answer,"x = int(input()) for a in range(-100, 101): for b in range(-100, 101): if a ** 5 - b ** 5 == x: print(a, b) break break " p02832,s129426728,Accepted,"N = int(input()) a = [int(aa) for aa in input().split()] cnt = 1 for now_a in a: if cnt == now_a: cnt += 1 if cnt == 1: print(-1) else: print(N-cnt+1)" p04045,s341448333,Accepted,"n, k = map(int, input().split()) dislike = input().split() while True: flag = True n_str = str(n) for i in n_str: if i in dislike: flag = False break if flag: print(n) break else: n += 1" p02664,s060044007,Accepted,"T = input() print(T.replace(""?"", ""D"")) " p03494,s213378395,Accepted,"# coding: utf-8 N = int(input()) A = [int(x) for x in input().split()] count = 0 while True: flag = True for A_i in A: if A_i % 2 != 0: flag = False break if flag == False: break for index in range(N): A[index] = A[index] / 2 count += 1 print(count)" p03665,s330564793,Wrong Answer,"mod = 1000000007 eps = 10**-9 def main(): import sys input = sys.stdin.readline N, P = map(int, input().split()) A = list(map(int, input().split())) odd = 0 even = 0 for a in A: if a&1: odd += 1 else: even += 1 if odd == 0: print(0) else: print(2**(N - 1)) if __name__ == '__main__': main() " p03804,s681232310,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)" p03239,s719356471,Accepted,"n,T=map(int,input().split()) cl=[] for i in range(n): c,t=map(int,input().split()) if t <= T: cl.append(c) if len(cl) == 0: print('TLE') else: print(min(cl)) " p03607,s042491727,Accepted,"import collections N = int(input()) ans = 0 now = 0 k = [] for i in range(N): A = int(input()) k.append(A) p = collections.Counter(k) for i in p: if p[i]%2 == 1: ans += 1 print(ans)" p03474,s292453596,Wrong Answer,"A, B = map(int, input().split()) S = input() for i in range(A): if not S[i].isdecimal(): print('No') exit() if S[A] != '-': print('No') exit() for i in range(A+1, B): if not S[i].isdecimal(): print('No') exit() print('Yes') " p02621,s293722954,Wrong Answer,"#Write your code in below N = int(input().rstrip()) print(N*(1+N+N^2))" p03639,s072630918,Accepted,"N=int(input()) A=list(map(int, input().split())) nons=[] twos=[] fours=[] for a in A: if a%4==0: fours.append(a) elif a%2==0: twos.append(a) else: nons.append(a) #print(fours, twos, nons) if len(twos)==0 and len(fours)+1==len(nons): print(""Yes"") elif len(fours)>=len(nons): print(""Yes"") else: print(""No"")" p03210,s278581133,Accepted,"a=int(input()) print([""NO"",""YES""][a==3 or a==5 or a==7])" p03799,s698626230,Accepted,"N,M = map(int,input().split()) if M <= N * 2: print(M // 2) exit() ans = N M -= N*2 ans += M//4 print(ans)" p03657,s344404098,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') " p03163,s856056504,Accepted,"n,w=map(int,input().split()) from copy import copy a=[0]*(w+1) for i in range(n): b=copy(a) x,y=map(int,input().split()) for j in range(min(x,w),w+1): b[j]=max(a[j-x]+y,a[j]) a=copy(b) print(max(a)) " p02729,s708381155,Accepted,"N, M = map(int, input().split()) print(N * (N - 1) // 2 + M * (M - 1) // 2)" p02842,s188023795,Accepted,"n = int(input()) for i in range(50001): if int(i * 1.08) == n: print(i) exit() print("":("")" p03659,s245100782,Accepted,"n = int(input()) nums = list(map(int, input().split())) x = nums[0] y = sum(nums[1:]) ans = abs(x - y) for i in range(1, n - 1): x += nums[i] y -= nums[i] ans = min(ans, abs(x - y)) print(ans)" p03997,s197452946,Accepted,"#!/usr/bin/env python3 a = int(input()) b = int(input()) h = int(input()) print((a+b)*h//2) " p02989,s851166044,Accepted,"N = int(input()) D = sorted(map(int, input().split())) print(0 if D[N//2]==D[N//2-1] else D[N//2]-D[N//2-1])" p02647,s109270248,Wrong Answer,"import numpy as np n, k= map(int, input().split()) a = input().split() npa=np.array(a, dtype=int) npb=np.zeros(n, dtype=int) for j in range(0,n): js=j-((k-1)+npa[j]) je=j+((k-1)+npa[j]) if (js <=0): js=0 if (je >=n-1): je=n-1 print (js,je) npb[js:je+1]+=1 print (*npb) " p03817,s312877910,Accepted,"def main(): x = int(input()) q, r = divmod(x, 11) ans = q * 2 if r == 0: pass # 忘れていた elif r <= 6: ans += 1 else: ans += 2 print(ans) if __name__ == '__main__': main() " p02916,s874912215,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(' ')] satis = 0 for i in range(N-1): if A[i] == A[i+1]-1: satis += C[i-1] satis += sum(B) print(satis)" p03617,s896926823,Accepted,"Q, H, S, D = map(int, input().split()) N = int(input()) cQ = Q*8 cH = H*4 cS = S*2 cD = D m = min(cQ, cH, cS, cD) if m == cQ: print(Q * N * 4) elif m == cH: print(H * N * 2) elif m == cS: print(S * N) else: if N % 2 == 0: print(D * N // 2) elif N == 1: print(min(Q * 4, H * 2, S)) else: c = (N-1) // 2 * D print(c + min(Q * 4, H * 2, S)) " p02645,s727870165,Accepted,"S = input() ans = S[0:3] print(ans)" p02996,s407160579,Accepted,"N = int(input()) lst = [] for i in range(N): N, K = map(int, input().split()) lst.append((K-N, N, K)) lst.sort(key=lambda tup: tup[2]) count = 0 for ind, x in enumerate(lst): if count > x[0]: print(""No"") exit() count += x[1] print(""Yes"") " p03861,s485451907,Accepted,"a, b, x = list(map(int, input().split())) if a % x == 0: print(b // x - a // x + 1) else: print(b // x - a // x)" p03944,s720319018,Accepted,"w, h, n = map(int,input().split()) y_min = 0 y_max = h x_min = 0 x_max = w for i in range(n): x, y, a = map(int,input().split()) if a == 1: x_min = max(x_min, x) if a == 2: x_max = min(x_max, x) if a == 3: y_min = max(y_min, y) if a == 4: y_max = min(y_max, y) white = (y_max - y_min) * (x_max - x_min) if (y_max - y_min)>=0 and (x_max - x_min)>=0: print(max(white, 0)) else: print(0)" p03328,s777010070,Accepted,"a, b = map(int, input().split()) X = b - a ans = 0 for i in range(X): ans += i print(ans-a) " p02601,s588033104,Accepted," a, b, c = map(int,input().split()) k = int(input()) cnt_b = 0 cnt_c = 0 while b <= a: b = b * 2 cnt_b += 1 if b > a: break while c <= b: c = c * 2 cnt_c += 1 if c > b: break if cnt_b + cnt_c <= k: print(""Yes"") else: print(""No"")" p03281,s452836703,Wrong Answer,"def divsor(num): count=0 for i in range(1,num+1): if num%i==0: count+=1 return count n=int(input()) if(n<=105): if(n==105): print(1) elif(n<105): print(0) res=1 for i in range(106,n+1): if(divsor(i)==8 and i%2==1): res+=1 print(res)" p02775,s375094639,Accepted,"N=input() n=len(N) x=0 flag=0 #print(N) M=[0]*(n+1) for i in range(n): M[i]=int(N[n-1-i]) #print(M) for i in range(n+1): m=M[i] if m==5: x+=5 flag=1 elif m<5: x+=m flag=0 else: x+=(10-m) flag=2 if flag==2: M[i+1]+=1 elif flag==1: if M[i+1]>=5: M[i+1]+=1 print(x)" p02618,s127562415,Accepted,"for i in range(365): print(26-i%26)" p02743,s940743909,Accepted,"a, b, c = map(int, input().split()) import math if a + b >= c: print('No') else: if a * b * 4 < (c - a - b) ** 2: print('Yes') else: print('No')" p02989,s347907419,Accepted,"N=int(input()) *D,=map(int,input().split()) for i in range(N): D[i]=(D[i],i) D=sorted(D) print(D[N//2][0]-D[N//2-1][0])" p03672,s530930507,Accepted,"# ABC065_B S = str(input()) N = len(S) for i in range(1,N+1): T = S[0:-i] M = N-i if M % 2 == 1: pass elif T[0:(M//2)] != T[(M//2):M]: pass else: print(N-i) break " p03145,s763567991,Wrong Answer,"a,b,c=map(int,input().split()) print(a*b/2)" p03385,s450391407,Accepted,"a,b,c=input() if a!=b and b!=c and c!=a: print(""Yes"") else: print(""No"")" p03059,s986149957,Wrong Answer,"a,b,t=map(int,input().split()) print(((t+0.5)//a)*b)" p02882,s704630619,Accepted,"import math def ints(): return [int(x) for x in input().split()] def ii(): return int(input()) a, b, x = ints() x /= a if x>=a*b/2: space = a*b - x theta = math.atan(2*space/a**2) else: theta = math.atan(b/(2*x/b)) print(theta*180/math.pi) " p02796,s328620521,Wrong Answer,"import numpy as np n = int(input()) X = [] L = [] for _ in range(n): x,l = map(int,input().split()) X.append(x) L.append(l) add = np.array(X)+np.array(L) sub = np.array(X)-np.array(L) cnt = 0 for i in range(n-1): if add[i]>sub[i+1]: cnt+=1 add[i+1]=add[i] sub[i+1]=sub[i] print(n-cnt)" p02624,s719732518,Accepted,"n = int(input()) def div(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 ans = 0 for i in range(1, n+1): k = n//i if 1 < k: ans += i*k*(k+1)//2 else: ans += (n+i)*(n-i+1)//2 break print(ans) " p02719,s754072392,Accepted,"N,K = map(int,input().split()) if N >= K : t = N%K ans = min(t,K-t) else: ans = min(N,K-N) print(ans)" p03852,s381211625,Accepted,"c = str(input()) if c == 'a' or c == 'e' or c == 'i' or c == 'o' or c == 'u': print('vowel') else: print('consonant')" p02633,s740341917,Accepted,"n = int(input()) a = 0 c = 0 while(True): a+=n c+=1 if(a%360 == 0): print(c) break" p02707,s695118148,Accepted,"members_count = int(input()) belong_map = {} belongings = [int(x) for x in input().split(' ')] for b in belongings: if b - 1 in belong_map: belong_map[b - 1] += 1 else: belong_map[b - 1] = 1 for i in range(members_count): if i in belong_map: print(belong_map[i]) else: print(0) " p03779,s493367136,Accepted,"X = int(input()) time = 0 pos = 0 while pos < X: time += 1 pos += time print(time) " p02570,s300826470,Wrong Answer,"D,T,S=[int(x) for x in input().split()] if D//S<=T: print(""yes"") else: print(""No"") " p02773,s193805921,Wrong Answer,"import collections a = int(input()) l = [] for i in range(a): l.append(input()) counted = collections.Counter(l) # 最頻値を求める m = max(counted.values()) # 頻出数の文字を集める chars = [key for key, value in counted.items() if value == m] for i in chars: print(i)" p02848,s107096290,Wrong Answer,"N=int(input()) S=input() alphabet=""ABCDEFGHIJKLMNOPQRSTUVWXYZ"" ans='' for i in range(len(S)): ans=ans+alphabet[(alphabet.find(S[i])+N)%26]" p03328,s077127167,Accepted,"a,b=map(int,input().split()) n=b-a print(n*(n-1)//2-a)" p03281,s355984879,Wrong Answer,"from random import*;print(randint(0,5))" p03759,s992587146,Accepted,"a,b,c=map(int,input().split()) if b-a==c-b: print('YES') else: print('NO')" p03624,s960743754,Accepted,"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 if x!=0: print(chr(i+97)) else: if len(A)==25: print(""z"") else: print(""None"")" p03711,s452736988,Accepted,"x, y = map(int, input().split()) list1 = [1,3,5,7,8,10,12,4,6,9,11,2] list2 = [0,0,0,0,0,0,0,1,1,1,1,2] d = dict(zip(list1, list2)) if d[x] == d[y]: print(""Yes"") else: print(""No"")" p04029,s523186427,Accepted,"N = int(input()) print(N*(N+1)//2)" p02725,s956593279,Accepted,"k,n = map(int,input().split()) a = list(map(int,input().split())) M = 0 for i in range(n-1): M = max(M,a[i+1]-a[i]) M = max(M,a[0]+k-a[n-1]) print(k-M) " p03778,s362578951,Wrong Answer,"w,a,b=map(int,input().split()) minu=min(a,b) maxi=max(a,b) print(maxi-(minu+w) if maxi-(minu-w)>0 else 0)" p02596,s881855646,Accepted,"K=int(input()) a=[0]*1000001 a[1]=7%K for i in range(2,K+1): a[i]=(a[i-1]*10+7)%K for i in range(1,K+1): if a[i]==0: print(i) exit() print(-1) " p03386,s590006964,Accepted,"a,b,k=map(int,input().split()) r1=[i for i in range(a,min(b+1,a+k))] r2=[i for i in range(max(a,b-k+1),b+1)] r1.extend(r2) result=set(r1) for i in sorted(result): print(i)" p03779,s706057167,Accepted,"import sys input = sys.stdin.readline def main(): n = int(input()) for i in range(n+1): if i * (i+1) / 2 >= n: print(i) return main()" p03323,s358813933,Accepted,"a, b = map(int, input().split()) print(""Yay!"" if a <= 8 and b <= 8 else "":("")" p02598,s163380491,Accepted,"from math import ceil def solve(): N, K = map(int,input().split()) A = list(map(int,input().split())) left = 0 right = 10 ** 9 while (right - left) > 1: x = (left+right) // 2 cnt = 0 for a in A: cnt += (a-1) // x if cnt <= K: right = x else: left = x print(right) if __name__ == '__main__': solve() " p03624,s080128889,Accepted,"import sys s = sorted(input()) for c in list('abcdefghijklmnopqrstuvwxyz'): if not c in s: print(c) sys.exit() print('None') " p03557,s746630940,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 C = len(c) # Bを中心に考える for i in b: ans += (bisect.bisect_right(a,i-1))*(C-bisect.bisect_left(c,i+1)) print(ans)" p02688,s653051710,Accepted,"n, k = map(int, input().split()) b = [0]*n for _ in range(k): a = int(input()) c = list(map(int, input().split())) for i in c: b[i-1] = 1 print(b.count(0))" p03543,s863851100,Accepted,"from collections import deque n = deque(list(input())) digit = n.popleft() cnt = 1 while n: if cnt == 3: break d = n.popleft() if d == digit: cnt += 1 else: digit = d cnt = 1 if cnt == 3: print('Yes') else: print('No')" p03435,s280369142,Accepted,"c = [list(map(int, input().split())) for _ in range(3)] diff0 = [x - y for x, y in zip(c[0], c[1])] diff1 = [x - y for x, y in zip(c[0], c[2])] if diff0[0] == diff0[1] and diff0[0] == diff0[2] and diff1[0] == diff1[1] and diff1[0] == diff1[2]: print('Yes') else: print('No')" p02783,s593068316,Accepted,"Input1 = list(map(int,input().split())) H = Input1[0] A = Input1[1] import math Ans = math.ceil(H / A) print(Ans)" p03071,s722264761,Accepted,"a,b=map(int,input().split()) print(max(a+(a-1),a+b,b+(b-1))) " p02989,s617653315,Accepted,"n = int(input()) d = list(map(int,input().split())) d.sort() index =n//2-1 print(d[index+1]-d[index])" p02912,s212455174,Accepted,"import heapq as hq N,M=list(map(int, input().split())) A=list(map(int, input().split())) B=[(-1)*A[i] for i in range(N)] B.sort() for _ in range(M): a=hq.heappop(B) a=((a*(-1))//2)*(-1) hq.heappush(B,a) C=[-B[i] for i in range(N)] print(sum(C))" p02688,s302371474,Accepted,"n, k = [int(i) for i in input().split("" "")] d = [] ans = [i for i in range(1, n + 1)] for i in range(k): d.append(int(input())) A = [int(i) for i in input().split("" "")] for delete in A: if delete in ans: ans.remove(delete) print(len(ans)) " p03474,s837295531,Accepted,"A, B = map(int, input().split()) S = input() if S[:A].isdigit() and S[A] == '-' and S[A+1:].isdigit() and len(S) == A+B+1: print('Yes') else: print('No') " p02600,s124522678,Accepted,"rate = int(input()) if ( rate >= 400 ) and ( rate < 600 ): print (""8"") elif(rate >= 600 and rate < 800 ): print (""7"") elif(rate >= 800 and rate < 1000 ): print (""6"") elif(rate >= 1000 and rate < 1200 ): print (""5"") elif(rate >= 1200 and rate < 1400 ): print (""4"") elif(rate >= 1400 and rate < 1600 ): print (""3"") elif(rate >= 1600 and rate < 1800 ): print (""2"") elif(rate >= 1800 and rate < 2000 ): print (""1"")" p03371,s988413420,Accepted,"A,B,C,X,Y=map(int,input().split()) ans=5000*(10**5)*2+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) if ans>=total: ans=total print(ans) " p02631,s547490909,Accepted,"n = int(input()) arr = list(map(int, input().split())) prefXor = [arr[0]] for i in arr[1:]: prefXor += [prefXor[-1] ^ i] out = [] for i in range(n): out += [prefXor[-1] ^ arr[i]] print(*out)" p02922,s298766992,Accepted,"a,b=map(int,input().split()) cnt=1 res=0 while 1: if cnt >= b: break cnt += a - 1 res+=1 print(res)" p03324,s715980050,Wrong Answer,"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())) d,n = iim() num = 0 for i in range(n): num += 100**d print(num)" p03544,s769722306,Wrong Answer,"n = int(input()) a = 2 b = 1 c = 0 for i in range(2, n + 1): c = a + b a = b b = c print(c) " p03319,s271921870,Accepted,"n, k = map(int, input().split()) print((n-1+k-2)//(k-1))" p03289,s579120014,Accepted,"S = input() ans = ""WA"" if S[0] == ""A"": tmp = S[2:len(S)-1] if tmp.count(""C"") == 1: c = tmp.index(""C"") count = 0 for i in range(1,len(S)): tmp2 = S[i] if tmp2.islower(): count += 1 if count == len(S) - 2: ans = ""AC"" print(ans)" p03286,s945423359,Accepted,"n=int(input()) s='' while n!=0: s=str(n%2)+s n=-(n//2) if s!='': print(s) else: print(0) " p02860,s350436436,Accepted,"N=int(input()) S=input() if N%2 == 1: print('No') elif S[:N//2] != S[N//2:]: print('No') else: print('Yes')" p03607,s211256265,Accepted,"def main(): n = int(input()) a = dict() for _ in range(n): x = int(input()) if x in a: a[x] +=1 else: a[x] = 1 ans = 0 for v in a.values(): if v % 2 == 1: ans += 1 print(ans) if __name__ == '__main__': main()" p02706,s287600604,Accepted,"N, M = map(int, input().split()) a = list(map(int, input().split())) homework = 0 for i in range(M): homework += a[i] play = N - homework if play < 0: print(-1) else: print(play)" p03433,s598058633,Accepted,"n = input() a = input() x = int(n)%500 if x<=int(a): print(""Yes"") else: print(""No"")" p03408,s781120354,Accepted,"from collections import defaultdict cnt = defaultdict(int) for m in range(2): n = int(input()) for i in range(n): s = input() if m == 0: cnt[s] += 1 else: cnt[s] -= 1 print(max(max(cnt.values()), 0))" p02838,s194628026,Accepted,"import sys import numpy as np input = sys.stdin.readline N = int(input()) MOD = 10**9+7 def inputs():return [int(x) for x in input().split()] A = np.array([inputs()]) ans = 0 for i in range(63): B = A&(1<= codd: print('Yes') elif ceven != 1 and cfour + 1 == codd: print('Yes') else: print('No')" p02659,s131520459,Accepted,"import numpy as np A,B = map(str,input().split()) A = int(A) B = int(B[0]+B[2]+B[3]) print(int(A*B//100))" p03043,s205871917,Accepted,"from math import ceil, log2 n, k = map(int, input().split()) ans = sum(1 / 2 ** ceil(log2(k / i)) for i in range(1, min(n, k) + 1)) print((ans + max(0, n - k)) / n)" p03943,s609195946,Wrong Answer,"a,b,c=map(int,input().split()) if (a+b+c)%3==0: print(""Yes"") else: print(""No"") " p03493,s280616151,Accepted,"print(input().count(""1""))" p03210,s024093135,Accepted,"X = input() ans = 'NO' if X in ['3','5','7']: ans = 'YES' print(ans) " p02665,s684467152,Wrong Answer,"from collections import deque import sys def input(): return sys.stdin.readline().rstrip() N = int(input()) v = list(map(int, input().split())) ans, nd = 0, 0 lim = [1 for _ in range(N + 2)] for i in range(N + 1) : lim[i+1] = (lim[i] - v[i]) * 2 for i in range(N, -1, -1): if (v[i] + nd > lim[i]): nd = (nd + 1) // 2 if (v[i] + nd > lim[i]): print(-1) sys.exit(0) nd += v[i] ans += nd print(ans)" p02987,s398171282,Wrong Answer,"s = input() s = s.replace(s[0],'').replace(s[1],'').replace(s[2],'') if s: print('No') else: print('Yes') " p03556,s830033785,Accepted,"n=int(input()) ans=0 for i in range(int(n**0.5)+1): tmp=i*i if tmp <= n: ans=max(ans,tmp) print(ans)" p02784,s712208515,Accepted,"import math h, n = map(int, input().split()) A = input().split() sum = 0; for a in A: sum += int(a) if h > sum: print('No') else: print('Yes') " p03387,s987429303,Wrong Answer,"lst = list(map(int,input().split())) lst2 = list(map(lambda x: max(lst) - x, lst)) if lst2[0] % 2 == 0 and lst2[1] % 2 == 0: print(sum(lst2) // 2) elif lst2[0] % 2 != 0 and lst2[1] % 2 != 0: _sum = (lst2[0] - 1) + (lst2[1] - 1) print(_sum // 2 + 1) else: print((sum(lst2) + 1) // 2 + 1)" p03862,s717702498,Wrong Answer,"n, x = map(int, input().split()) a = list(map(int, input().split())) ans = max(0, a[0] - (a[0] - x)) for i in range(n - 1): if a[i] + a[i + 1] > x: #print(""OK3"") diff = (a[i] + a[i + 1]) - x ans += diff a[i + 1] -= diff #print(a) print(ans)" p02843,s383091022,Wrong Answer,"X = int(input()) l = [0,1,2,3,4,5] a = X // 100 b = X % 100 if b == 0: print('1') elif a and ((b // a) in l) and ((b % a) in l): print('1') else: print('0')" p02791,s485280197,Accepted,"N = int(input()) P = list(map(int, input().split())) cnt, i = 1, 0 min = P[0] for i in range(i + 1, N): if min >= P[i]: cnt += 1 min = P[i] print(cnt)" p02602,s998265632,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) for i in range(N - K): print(""Yes"") if A[i] < A[K + i] else print(""No"") " p02935,s816123061,Accepted,"N = int(input()) A = list(map(int,input().split())) A.sort() for i in range(N-1): A[i+1] = (A[i] + A[i+1])/2 print(A[-1])" p03087,s465564567,Accepted,"import sys N, Q = map(int,input().split()) S = input() cnt = [0]*(N+1) wasA = False for i in range(0,N): if wasA and S[i] == ""C"": cnt[i+1] = cnt[i] + 1 wasA = False elif S[i] == ""A"": cnt[i+1] = cnt[i] wasA = True else: cnt[i+1] = cnt[i] wasA = False #print(cnt) for i in range(0,Q): l, r = map(int,input().split()) print(cnt[r]-cnt[l])" p02935,s459408835,Accepted,"n = int(input()) li = list(map(int, input().split())) for _ in range(n-1): li.sort(reverse=True) a = li.pop() b = li.pop() li.append((a+b)/2) print(*li)" p03543,s179439327,Accepted,"n = list(input()) if n[0] == n[1] and n[1] == n[2]: print('Yes') elif n[1] == n[2] and n[2] == n[3]: print('Yes') elif n[0] == n[1] == n[2] == n[3]: print('Yes') else: print('No')" p03679,s419174837,Accepted,"x,a,b=map(int,input().split()) if b-a<=0: print('delicious') elif 0= 2019: print(0) else: for i in range(l,r): for j in range(l+1,r+1): t.append((i*j)%2019) print(min(t))" p02612,s075381350,Accepted,"n = int(input()) n %= 1000 n = 1000 -n if n % 1000 == 0: n = 0 print(n)" p02723,s125992251,Wrong Answer,"x = str(input()) if x[2]==x[3] or x[4]==x[5]: print('Yes') else: print('No')" p03785,s391443394,Accepted,"n, c, k = map(int, input().split()) T = [] for i in range(n): t = int(input()) T.append(t) T.sort() x = 0 ans = 1 w = T[0] + k for i in range(n): if T[i] <= w and x < c: x += 1 else: ans += 1 x = 1 w = T[i]+k print(ans)" p02792,s074506401,Accepted,"N = int(input()) c = [[0]*10 for _ in range(10)] for k in range(1,N+1): tmp = str(k) i = int(tmp[0]) j = int(tmp[-1]) c[i][j] += 1 ans = 0 for i in range(10): for j in range(10): ans += c[i][j] * c[j][i] print(ans)" p02866,s915877696,Accepted,"from collections import Counter n, *d = map(int, open(0).read().split()) MOD = 998244353 c = Counter(d) if d[0] != 0 or c[0] != 1: ans = 0 else: ans = 1 for i in range(1, max(d)+1): ans *= pow(c[i-1], c[i]) % MOD print(ans % MOD)" p03672,s812956979,Accepted,"s = input() n = len(s) for i in range(1,n): p = 0 for j in range((n-2*i)//2): if s[j] != s[(n-2*i)//2 + j]: p = 1 break if p == 0: print(n-2*i) exit()" p03351,s335241544,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')" p02963,s522596508,Accepted,"s=int(input()) v=10**9 x=(v-s%v)%v y=(s+x)//v print('0 0 1000000000 1 {} {}'.format(x,y))" p02989,s515010737,Wrong Answer,"n = int(input()) d = list(map(int,input().split())) d.sort() ans = [] if d[n//2 -1] == d[n//2]: print(""0"") else: for i in range(d[n//2 -1] + 1,d[n//2] + 1): ans.append(i) print(len(ans))" p03478,s635201968,Accepted,"n,a,b=map(int,input().split()) p=0 for i in range(1,n+1): if a <= sum(map(int,str(i))) <= b: p += i print(p)" p02957,s016781612,Accepted,"A,B = map(int,input().split()) if(abs(A-B) % 2 == 1): print(""IMPOSSIBLE"") else: print((abs(A-B)//2) + min(A,B))" p03472,s940748830,Accepted,"N,H = map(int,input().split()) K = [list(map(int,input().split())) for n in range(N)] A = max(k[0] for k in K) B = sorted(b for a,b in K if Ay: i=a elif x= q: print(q) else: print(p)" p02724,s810623839,Wrong Answer,"import bisect,collections,copy,itertools,math,string def I(): return int(input()) def S(): return input() def LI(): return list(map(int,input().split())) def LS(): return list(input().split()) ################################################## X = I() _500 = X//500 _nokori = (X%500)//5 print(_nokori) print(_500*1000+_nokori*5) " p03419,s198464377,Accepted,"def solve(): n, m = map(int, input().split()) ans = abs(0*4 + 0*(n-2)*2 + 0*(m-2)*2 + 1*(n-2)*(m-2)) return ans print(solve()) " p02596,s464813165,Accepted,"K = int(input()) m = 0 for k in range(1,K + 1): m = m * 10 + 7 m = m % K if m == 0: print(k) break if m > 0: print(-1)" p02755,s489370577,Wrong Answer,"A, B = map(int, input().split()) N = 1000 p1 = 0.08 p2 = 0.1 for i in range(1, N + 1): if int(i * p1) == A and int(i * p2): print(i) exit() print(""-1"")" p02790,s695950697,Accepted,"a, b = [int(x) for x in input().split()] As = str(a) * b Bs = str(b) * a print(min(As, Bs))" p02873,s563748460,Wrong Answer,"s = input() import itertools def countstrs(s): return [(k, len(list(g))) for k, g in itertools.groupby(s)] c = countstrs(s) ma , mi = 0, 0 c = 0 r = [] for i in range(len(s)): r.append(c) if s[i] == ""<"": c += 1 else: c -= 1 r = max(r) - min(r) + 1 res = 0 for i in range(r+1): res += i print(res)" p02633,s333648790,Accepted,"import math X = int(input()) print(360 // math.gcd(X, 360))" p03386,s180329642,Accepted,"a, b, k = list(map(int, input().split())) for i in range(k): x = a + i if x <= b: print(a + i) for i in range(k): x = b - k + i + 1 if x <= a + k - 1 or x < a: pass else: print(x)" p02993,s910489811,Accepted,"# A import sys s = input() pre = '' for c in s: if c == pre: print('Bad') sys.exit() pre = c print('Good')" p03059,s074925590,Accepted,"rStr = input() A = int(rStr.split(' ')[0]) B = int(rStr.split(' ')[1]) T = int(rStr.split(' ')[2]) result = int((T + 0.5) / A) * B print(result)" p02572,s386130549,Wrong Answer,"N = int(input()) A = list(map(int, input().split())) ans = sum(A)^2 for a in A: ans -= a^2 ans /= 2 print(int(ans%(10^9+7)))" p02665,s011920053,Accepted,"n,*a=map(int,open(0).read().split());t=sum(a);v=w=1 for q in a: if(w:=min(2*(w-q),t:=t-q))<0:exit(print(-1)) v+=w print(v)" p03282,s186145776,Accepted,"s = input() k = int(input()) i = 0 while True: if s[i] == '1': if k <= i+1: print('1') break else: i += 1 else: print(s[i]) break" p02973,s951607340,Wrong Answer,"import sys input = sys.stdin.readline n = int(input()) a1 = int(input()) a = [a1] for _ in range(n-1): ai = int(input()) if ai <= a[-1]: a.append(ai) elif ai >= a[0]: a = [ai]+a[1:] else: h = 0 l = len(a)-1 while l-h>1: m = (l+h)//2 if ai > a[m]: l = m else: h = m a = a[:l]+[ai]+a[l+1:] print(len(a)) " p02689,s463361501,Accepted,"N,M = map(int, input().split()) H = list(map(int, input().split())) AB = [list(map(int, input().split())) for _ in range(M)] ans = [1]*N for A,B in AB: if H[A-1] > H[B-1]: ans[B-1] = 0 elif H[A-1] < H[B-1]: ans[A-1] = 0 else: ans[B-1] = 0 ans[A-1] = 0 print(ans.count(1))" p03645,s814855019,Accepted,"N,M = list(map(int,input().split())) xfrom1 = [] xton =[] for i in range(M): a,b = list(map(int,input().split())) if a == 1: xfrom1.append(b) elif a== N: xton.append(b) elif b==N: xton.append(a) if len(set(xfrom1) & set(xton)) >0: print('POSSIBLE') else: print('IMPOSSIBLE') " p02842,s126033212,Accepted,"n=int(input()) flag = False for i in range(100*n,100*(n+1)): if i%108 == 0: x = int(i//108) print(x) flag = True break if flag == False: print(':(')" p02817,s955224322,Accepted,"s, t = input().split() print(t+s)" p03042,s033991968,Accepted,"S = list(map(int, input())) if 0=H else 'No')" p02621,s713894478,Accepted,"a = int(input()) a = a + a * a + a * a * a print(a) " p03645,s051298675,Wrong Answer,"N, M = map(int, input().split()) a = [0]*M b = [0]*M for i in range(M): a[i], b[i] = map(int, input().split()) c = [] for i in range(M): if b[i] == M: c.append(a[i]) if len(c) != 0: for i in range(M): if a[i] == 1: for j in range(len(c)): if b[i] == c[j]: print(""POSSIBLE"") exit() print(""IMPOSSIBLE"")" p03657,s001769234,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')" p02694,s615826093,Accepted,"x=int(input()) ans=0 money=100 while money= n or g==0: g=n for i in range(s,g): if i+k > n: break t=x[i:i+k] if min(t)*max(t) > 0: ans=min(ans, abs(max(t))) else: tmp=abs(min(t))+max(t) tmp+=min(abs(min(t)),abs(max(t))) ans=min(ans,tmp) print(ans)" p03998,s211152220,Accepted,"S = {i:list(input()) for i in 'abc'} s = 'a' while S[s]: s = S[s].pop(0) print(s.upper())" p03408,s816448514,Accepted,"import collections n = int(input()) s = [input() for x in range(n)] m = int(input()) t = [input() for y in range(m)] ans = 0 S = collections.Counter(s) T = collections.Counter(t) for k, v in S.items(): tmp = 0 tmp = v if k in T: tmp -= T[k] ans = max(ans, tmp) print(ans) " p03339,s679300485,Wrong Answer,"import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines n = int(readline()) s = readline().decode().rstrip() cost = [0]*n cost[0] = s.count('E') if s[0] == 'W': cost[1] += 1 for i in range(1, n): if s[i] == 'E': cost[i] += cost[i - 1] - 1 else: cost[i] += cost[i - 1] if i < n - 1: cost[i + 1] += 1 print(min(cost))" p02860,s061207156,Wrong Answer,"n = int(input()) s = input() half = n // 2 if n / 2 == 1: print(""No"") elif s[:half] == s[half:]: print(""Yes"") else: print(""No"") " p02795,s272060049,Wrong Answer,"from bisect import bisect_right, bisect_left from itertools import groupby, permutations, combinations from fractions import gcd import numpy as np from sys import stdin, stderr def main(): H = int(input()) W = int(input()) N = int(input()) l = max(H,W) ret = N // l return ret if __name__ == ""__main__"": print(main())" p02848,s557180906,Accepted,"n = int(input()) s = input() for i in range(len(s)): print(chr(65 + (ord(s[i]) - 65 + n) % 26), end = """") print()" p03289,s278891178,Wrong Answer,"import sys S = list(input()) C_cnt,low,upp = 0,0,0 if S[0] != ""A"" or S[-1].isupper() or S[1] == 'C': print(""WA"") sys.exit() for i in range(2,len(S)-1): if S[i] == ""C"": C_cnt += 1 elif S[i].islower(): low += 1 elif S[i].isupper(): upp += 1 if C_cnt == 1 and low == len(S)-3 and upp == 0: print(""AC"") else : print(""WA"")" p02552,s890970648,Accepted,"x = int(input()) print(0) if x == 1 else print(1)" p02687,s609307989,Accepted,"#coding:utf-8 s = str(input()) if s == 'ABC': print('ARC') elif s == 'ARC': print('ABC') " p02583,s539204760,Accepted,"from itertools import combinations n = int(input()) arr = list(map(int, input().split())) count = 0 for i, j, k in combinations(arr, 3): if i == j or j == k or k == i: continue elif (i + j) > k and (j + k) > i and (k + i) > j: count += 1 print(count) " p02640,s234238514,Accepted,"X,Y = map(int,input().split()) if Y%2 == 0 and 2*X<=Y<=4*X: print('Yes') else: print('No')" p03548,s515072751,Wrong Answer,"x, y, z = map(int, input().split()) n = z cnt = 0 while n < x: n += (y + z) cnt += 1 print(cnt)" p03127,s084939800,Accepted,"from math import gcd N = int(input()) A = list(map(int, input().split())) res = A[0] for i in range(1,N): res = gcd(res,A[i]) print(res)" p03773,s284184104,Accepted,"# 入力 A, B = map(int, input().split()) # 出力 if A + B == 24: w = 0 elif A + B > 24: w = abs(24 - (A + B)) else: w = A + B print(w)" p03611,s946319616,Accepted,"n = int(input()) a = list(map(int, input().split())) cnt = [0]*(10**5+5) for i in a: cnt[i] += 1 ans = 0 for i in range(1, 10**5+3): ans = max(ans, sum(cnt[i-1:i+2])) print(ans) " p02691,s781172582,Accepted,"n = int(input()) a = [int(val) for val in input().split()] mp = dict() ans = 0 for i in range(n): addval = a[i] + (i + 1) subval = (i + 1) - a[i] if subval in mp.keys(): ans += mp[subval] mp[addval] = mp.get(addval, 0) + 1 print(ans) " p02729,s733159165,Accepted,"from math import factorial N, M = map(int, input().split()) if N > 1: a = factorial(N) / (factorial(2) * factorial(N-2)) else: a = 0 if M > 1: b = factorial(M) / (factorial(2) * factorial(M-2)) else: b = 0 print(int(a+b))" p02612,s263236826,Accepted,"num = int(input()) if num % 1000 == 0: print(0) else: t = num // 1000 t += 1 print(t * 1000 - num) " p02618,s484365970,Wrong Answer,"D=int(input()) c=[] c=list(map(int,input().split())) s=[] for i in range(D): s.append(list(map(int,input().split()))) for i in range(D-1): print('8')" p03076,s231526570,Accepted,"def order(x): return (x + 9) // 10 * 10 def wait(x): return order(x) - x dishes = [int(input()) for _ in range(5)] total = sum(order(i) for i in dishes) total -= max(wait(i) for i in dishes) print(total) " p03943,s984169786,Accepted,"lst=sorted(map(int,input().split())) print(""Yes"" if lst[0]+lst[1]==lst[2] else ""No"")" p03617,s744696034,Wrong Answer,"q, h, s, d = map(int, input().split()) n = int(input()) min_1l = min(q*4, h*2, s) min_2l = min(min_1l*2, d) print(min(n*min_1l, (n//2)*min_2l + min_1l)) " p03719,s954366916,Accepted,"# A - Between Two Integers # https://atcoder.jp/contests/abc061/tasks/abc061_a A, B, C = map(int, input().split()) result = 'No' if A <= C <= B: result = 'Yes' print(result) " p03698,s045462894,Accepted,"s = input() if len(s) == len(set(s)): print('yes') else: print('no') " p02729,s929568440,Wrong Answer,"n,m = map(int,raw_input().split(' ')) print n*(n-1) + m*(m-1)" p03434,s620448467,Accepted,"N= input() A = list(map(int,input().split())) A = sorted(A,reverse=True) print(sum(A[::2]) - sum(A[1::2]))" p02754,s929819524,Wrong Answer,"#abc 158 b """""" input().split() map(int,input().split()) print(""Yes"" if flag else ""No"") for i in range(): """""" n,a,b=map(int,input().split()) ans=0 if a+b>=2: ans=n//(a+b) elif a==0: ans=0 elif b==0: ans=n elif n%(a+b)-b<0: ans+=n%(a+b) else: ans+=n%(a+b)-b print(ans) " p02963,s328166441,Wrong Answer,"S=int(input()) if S<10**18: x1,y1,x2,y2,x3,y3=0,0,-(-S//10**9),10**9-S%10**9,1,10**9 else: x1,y1,x2,y2,x3,y3=(0,0,10**9,1,0,10**9) print(x1,y1,x2,y2,x3,y3)" p02701,s051312316,Accepted,"n = int(input()) s = [input() for _ in range(n)] s_t = set(s) print(len(s_t)) " p03433,s638479023,Wrong Answer,"n = int(input()) a = int(input()) mod = n % 500 if mod < a: print(""Yes"") else: print(""No"")" p03633,s745767886,Accepted,"def gcd(a,b): x=max(a,b) y=min(a,b) if x%y==0: return y else: while x%y!=0: z=x%y x=y y=z else: return z def lcm(a,b): return int(a*b//gcd(a,b)) N=int(input()) a=int(input()) for n in range(1,N): b=int(input()) a=lcm(a,b) print(a)" p03481,s227769382,Accepted,"x, y = map(int, input().split()) #A = [] ans = 0 while x <= y: ans += 1 x *= 2 print(ans) " p03417,s613328233,Accepted,"n,m = map(int,input().split()) if n == 1 and m == 1: print(1) exit() elif n == 1 or m == 1: print(n*m-2) exit() elif n == 2 or m == 2: print(0) exit() else: print(n*m-(2*(m-1)+2*(n-1)))" p03556,s878433216,Accepted,"a=int(input()) k=1 for i in range(0,100000): if a<(k**2): break else: k+=1 print((k-1)**2)" p03264,s134065623,Accepted,"a=int(input()) even_num = 0 odd_num = 0 if a %2==0: even_num += a/2 odd_num +=a/2 else: even_num +=(a+1)/2 - 1 odd_num +=(a+1)/2 print(int(even_num*odd_num))" p02597,s385343054,Accepted,"n = int(input()) s = str(input()) cnt1 = s.count(""W"") # Wの文字数 cnt2 = len(s) - cnt1 # Rの文字数 ss = s[:cnt2] cnt3 = ss.count(""W"") print(min(cnt1, cnt3))" p03681,s839088232,Accepted,"import math N,M = map(int,input().split()) f = 1 if abs(N-M) > 1: print(0) exit() if (N+M) % 2 == 0: f = 2 print(math.factorial(N) % (10**9+7) * math.factorial(M) % (10**9+7) * f % (10**9+7)) " p02866,s786512202,Accepted,"from collections import Counter N = int(input()) A = list(map(int, input().split())) if A[0] != 0: print(0) exit() AC = list(Counter(A).items()) AC.sort() MOD = 998244353 ans = 1 last_v = 1 last_k = -1 for k, v in AC: if k == 0: if v != 1: print(0) exit() last_k = 0 continue if k != last_k+1: print(0) exit() ans = ans*pow(last_v, v, MOD)%MOD last_v = v last_k = k print(ans)" p02882,s484211337,Wrong Answer,"import math a,b,x = map(int,input().split()) def f(t): t = math.radians(t) if a * math.tan(t) <= b: return a**2 * b - a**2 * math.tan(t) / 2 else: return b**2 / math.tan(t) * a / 2 tmax = 90 tmin = 0 for i in range(10**6): tmid = tmin + (tmax-tmin) / 2 if f(tmid) < x: tmax = tmid else: tmin = tmid print(tmid)" p02813,s091585726,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))) " p03162,s109882458,Wrong Answer,"N = int(input()) T = [list(map(int, input().split())) for i in range(N)] print(T) dp = [[0 for i in range(3)] for j in range(N+1)] print(dp) dp[1] = T[0] print(dp) 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(dp) print(max(dp[-1]))" p03944,s808916499,Accepted,"W,H,N=map(int,input().split()) W0=0 H0=0 for i in range(N): x1,y1,a1=map(int,input().split()) if a1 ==1 and W0x1: W=x1 elif a1==3 and H0y1: H=y1 if W-W0>0 and H-H0>0: print((W-W0)*(H-H0)) else: print(0)" p02848,s626643573,Accepted,"N = int(input()) S = str(input()) N = N%26 for s in S: print(chr(((ord(s)-65)+N)%26+65), end="""") print() " p02660,s340500074,Accepted,"import math def factorization(n): arr = [] temp = n for i in range(2, int(math.sqrt(n))+1): if temp%i == 0: cnt = 0 while temp%i == 0: cnt += 1 temp //= i arr.append([i, cnt]) if temp != 1: arr.append([temp, 1]) if arr == []: arr.append([n, 1]) return arr n = int(input()) factors = factorization(n) res = 0 for j,cnt in factors: if j == 1: continue i = 1 while cnt >= i: cnt -= i i += 1 res += 1 print(res)" p03971,s379051967,Accepted,"# N = int(input()) N, A, B = map(int, input().split()) students = list(input()) through = 0 abroad_rank = 0 for student in students: if through >= A+B: print('No') continue if student == 'a': print('Yes') through += 1 elif student == 'b': if abroad_rank+1<=B: print('Yes') through += 1 abroad_rank += 1 else: print('No') else: print('No') " p02633,s563049300,Wrong Answer,"X = int(input()) K = int(360/X) print(K) " p02553,s793824168,Accepted,"#!/usr/bin/env python # -*- coding: utf-8 -*- def main(): A, B, C, D = map(int, input().split()) ans = -10**9**2 for ab in (A, B): for cd in (C, D): if ab * cd > ans: ans = ab * cd print(ans) if __name__ == ""__main__"": main() " p03962,s303029683,Wrong Answer,"i=list(map(int,input().split())) i.sort() a=0 for k in range(len(i)): if i[k]!=i[k-1]: a+=1 print(a) " p03986,s793043069,Accepted,"x = ""T""+input()+""S"" ans = len(x)-2 s = t = 0 for i in x: if i==""S"": ans -= min(s,t)*2 if s>t: s -= t t = 0 else: t = s = 0 s += 1 else: t += 1 print(ans)" p02665,s354839952,Accepted,"print(max(-(b:=(c:=sum(a:=[*map(int,[*open(0)][1].split())]))>0),sum((b:=min(c:=c-a,b-a<<1))for a in a)+1))" p02802,s272767622,Accepted,"n,m = list(map(int, input().split())) ac = [0]*n wa = [0]*(n+1) pena = 0 for i in range(m): ques, state = input().split() ques = int(ques)-1 if (state==""AC"") and (ac[ques]==0): ac[ques] = 1 pena += wa[ques] elif (state==""WA"") and (ac[ques]==0): wa[ques] += 1 print(sum(ac), pena)" p03131,s908842627,Wrong Answer,"K,A,B=map(int,input().split()) ans=0 if B-A<=2 or K+1<=A: #ぼったくり ans=K+1 else: #notぼったくり # A-1回ポケット叩いてA個のビスケットを用意する。A-1/Kつかう # B枚に交換してBの方が大きいので交換し続ける。それぞれ2/Kつかう # 最後に1回あまればビスケットを1枚増やしとく。1/Kつかう t=(K-A+1)//2 #交換する回数 ans=B*t+(K-A+1)%2 print(ans)" p03438,s793464458,Wrong Answer,"def ceil(a, b): return (a + b - 1) // b N = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) n = sum(b) - sum(a) for _a, _b in zip(a, b): if _a > _b: n -= _a - _b if _a + _b & 1: n -= 1 if n >= 0: print('Yes') else: print('No')" p02813,s483809050,Accepted,"N = int(input()) P = tuple(map(int,input().split())) Q = tuple(map(int,input().split())) from itertools import permutations s = list(permutations([i for i in range(1,N+1)])) for i,e in enumerate(s): if e == P: p_ans = i if e == Q: q_ans = i print(abs(p_ans-q_ans))" p03086,s780336272,Accepted,"#python3 def main(): s = input() ans = 0 cnt = 0 for i in range(len(s)): if (s[i] == ""A"") | (s[i] == ""T"") | (s[i] == ""C"") | (s[i] == ""G""): cnt += 1 else: cnt = 0 ans = max(ans, cnt) print(ans) main() " p03329,s322425010,Wrong Answer,"n = int(open(0).read()) A = [1] + [6**i for i in range(1, 7)] + [9**i for i in range(1, 6)] dp = [0] * (10**6 + 1) dp[1] = 1 for i in range(2, n+1): dp[i] = min(dp[i-a]+1 for a in A if i>a) for a in A: dp[a] = 1 print(dp[n])" p02702,s758676441,Wrong Answer,"n = input() t = len(n) count= 0 for i in range(t): for j in range(t+1): if(i=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+1]: de = i+1 print(len(s)+len(t)-de)" p03331,s938957663,Accepted,"N = int(input()) MIN = 100000000000000 for i in range(1,N): A = sum(map(int,list(str(i)))) B = sum(map(int,list(str(N-i)))) MIN = min(A+B,MIN) print(MIN) " p03407,s322567551,Accepted,"A,B,C = map(int,input().split()) print('Yes' if sum([A,B])>=C else 'No')" p03673,s841084858,Accepted,"N=int(input()) A=list(map(int,input().split())) X=[A[i] for i in range(0,N,2)] Y=[A[i] for i in range(1,N,2)] if N%2: A=X[::-1] B=Y else: A=Y[::-1] B=X print("" "".join(map(str,A+B))) " p02629,s456617626,Accepted,"n=int(input())-1 radix=26 ord_a=97 ans="""" while n>=0: n,m=divmod(n,radix) ans=chr(m+ord_a)+ans n-=1 print(ans)" p03387,s942269682,Wrong Answer,"nums = list(map(int, input().split())) nums.sort() count = nums[2] - nums[1] nums[0] += nums[2] - nums[1] if (nums[2]-nums[0])%2 == 0: count += (nums[2]-nums[0])//2 else: count += (nums[2]-nums[0])//2 + 2" p04029,s827091383,Accepted,"n = int(input()) print(n*(n+1)//2)" p04020,s886900632,Accepted,"n = int(input()) a = [int(input()) for _ in range(n)] a.append(0) r = 0 for i in range(n): r += a[i]//2 if a[i]%2==1 and a[i+1]>0: r += 1 a[i+1] -= 1 print(r)" p04005,s340651365,Accepted,"a =list( map(int,input().split())) a.sort() if (a[0]*a[1]*a[2])%2 : print(a[0]*a[1]) else: print(0)" p02684,s507152030,Accepted,"n,k=map(int,input().split()) a=list(map(int,input().split())) town=[0]*n info=[1] now=1 while town[now-1]==0: town[now-1]+=1 now=a[now-1] info.append(now) loop_list=list(info[info.index(now):-1]) loop_len=len(loop_list) before_loop_list=list(info[:info.index(now)]) if k 0: max_a = heapq.heappop(a_list) heapq.heappush(a_list, (-1)*(-max_a//2)) m -= 1 print(-sum(a_list))" p04033,s710137112,Wrong Answer,"# AGC 002: A – Range Product a, b = [int(s) for s in input().split()] if a > 0: print('Positive') elif b < 0: if (b - a + 1) % 2 == 0: print('Positive') else: print('Negative') elif a <= 0 <= b: print('zero')" p02813,s743652348,Accepted,"import itertools N = int(input()) L = [i for i in range(1, N+1)] P = list(map(int, input().split())) Q = list(map(int, input().split())) if P == Q: print(0) exit() cnt = a = b = 0 for v in list(itertools.permutations(L)): cnt += 1 if list(v) == P: a = cnt elif list(v) == Q: b = cnt print(abs(a-b))" p03951,s505617495,Accepted,"N = int(input()) s = input() t = input() ans = 2*N for i in range(N): if s[i:N] != t[0:N-i]: continue ans = N+i break print(ans) " p03623,s663394261,Accepted,"x, a, b = map(int, input().split()) if abs(x - a) < abs(x - b): print('A') else: print('B') " p03815,s861745462,Accepted,"x=int(input()) if x <= 6: print(1) exit() cnt = (x//11)*2 x %= 11 if x <= 0: print(cnt) elif x <= 6: print(cnt+1) else: print(cnt+2)" p03592,s639722324,Accepted,"N,M,K=map(int,input().split()) for i in range(M+1): for j in range(N+1): if i*(N-j)+j*(M-i)==K: print(""Yes"") exit() print(""No"")" p02613,s236329091,Wrong Answer,"N = int(input()) lists = [] AC = 0 TLE = 0 WA = 0 RE = 0 for i in range(N): S = str(input()) lists.append(S) for o in lists: if o == ""AC"": AC +=1 elif o == ""TLE"": TLE +=1 elif o == ""WA"": WA +=1 elif o == ""RE"": RE +=1 print(""AC X ""+str(AC)) print(""WA X ""+str(WA)) print(""TLE X ""+str(TLE)) print(""RE X ""+str(RE))" p02639,s859376863,Wrong Answer,"a=input() print(a.find(""0""))" p02624,s984502044,Accepted,"N = int(input()) ans = 0 for i in range(1 , N + 1): # 2,4,6,8,... last = N // i * i # i , last = n * i ans += (i + last) * (last // i) // 2 print(ans)" p02742,s521903437,Accepted,"H, W = map(int,input().split()) if H == 1 or W == 1: print(1) else: ans = H*W if ans % 2: print(ans//2+1) else: print(ans//2)" p03331,s890181637,Accepted,"def digitsum(N): return sum(map(int,list(str(N)))) N = int(input()) m = 100000 for A in range(1,N//2+1): B = N-A m = min(m,digitsum(A)+digitsum(B)) print(m)" p03042,s045425634,Wrong Answer,"s = input() s_u, s_l = int(s[:2]), int(s[2:]) if s_u > 12 and 1 <= s_l <= 12: print('YYMM') elif 1 <= s_u <= 12 and s_l > 12: print('MMYY') elif 1 <= s_u <= 12 and 1 <= s_l <= 12: print('AMBIGUOUS') else: print('NA') " p03944,s465561408,Wrong Answer,"#バッファ使わない w,h,n = map(int,input().split()) cnt = 0 X = 0 Y = 0 while(cnt < 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) elif(a == 4): h = min(h,y) #print(w,h,X,Y) cnt += 1 print(abs(w-X)*abs(h-Y))" p02633,s445045565,Wrong Answer,"x = int(input()) k = 360 / x out = None for l in range(1, 181): if (k * l).is_integer(): out = k * l break print(out)" p02948,s243455744,Wrong Answer,"N,M = map(int,input().split()) jobs = [] for _ in range(N): jobs.append(list(map(int,input().split()))) jobs.sort(key= lambda x: (-x[1],-x[0])) res = 0 j = 0 for d in range(M): while j= 1: happy += calc_500 * 1000 money -= calc_500 * 500 calc_5 = math.floor(money / 5) if calc_5 >= 1: happy += calc_5 * 5 print(str(happy)) else: print(str(happy)) else: calc_5 = math.floor(money / 5) if calc_5 >= 1: happy += calc_5 * 5 print(str(happy)) else: print(str(happy))" p03067,s311297971,Accepted,"a, b, c = map(int, input().split()) if a < c < b or b < c < a: ans = ""Yes"" else: ans = ""No"" print(ans) " p02642,s486600895,Accepted,"import sys n = input() x = list(map(int, input().split())) #x = [i for i in range(2, 10**5)] MAXA = 10**6 used = [False for i in range(MAXA + 5)] result = 0 counts = {} for a in x: if a in counts: counts[a] += 1 else: counts[a] = 1 for x in range(MAXA + 1): if not used[x]: if x in counts: count = counts[x] if count == 1: result += 1 y = 2*x while y <= MAXA: used[y] = True y += x print(result) " p03041,s323754770,Wrong Answer,"n, k = map(int, input().split()) s = input() t = s[k-1] ans = s[:k-1] + t.lower() + s[k:] " p02760,s006619948,Wrong Answer,"l=[list(map(int,input().split())) for i in range(3)] l=sum(l,[]) n=int(input()) li=set([input() for ini in range(n)]) d=[0 for i in range(9)] for g in range(9): if l[g] in li:d[g]=1 if set([1]) in [set(d[h::3])for h in range(3)]+[set(d[h:h+3])for h in range(3)]+[set([d[0],d[4],d[8]]),set([d[2],d[4],d[6]])]: print(""Yes"") else:print(""No"") " p03220,s537128745,Wrong Answer,"N = int(input()) T,A =map(int, input().split()) H = list(map(int, input().split())) dif = [float(A-i) for i in [float(T-h*0.006) for h in H]] dif_min = dif.index(min(dif)) print(dif_min+1)" p02555,s017853029,Accepted,"n = int(input()) mod = 10**9 + 7 per = [1] * (n+1) for i in range(1, n+1): per[i] = per[i-1] * i per[i] %= mod inv = [1] * (n+1) inv[-1] = pow(per[-1], mod-2, mod) for j in range(2, n+2): inv[-j] = inv[-j+1] * (n-j+2) inv[-j] %= mod def C(n, k): cmb = per[n] * inv[k] * inv[n-k] cmb %= mod return cmb total = 0 for k in range(1, n+1): if n < 3*k: break total += C(n-2*k-1, k-1) total %= mod print(total) " p02730,s872229523,Accepted,"# ABC 159 B s = input() n = len(s) l = s[:((n-1)//2)] r = s[((n+3)//2) -1:] if s == s[::-1] and l == l[::-1] and r == r[::-1]: print('Yes') else: print('No')" p02829,s454421419,Accepted,"a=int(input()) b=int(input()) abc=[1,2,3] abc.remove(a) abc.remove(b) print(abc[0])" p03437,s384415270,Accepted,"X, Y = list(map(int, input().split())) if X % Y == 0: ans = -1 else: for i in range(1, 10**18): t = X * i if t % Y != 0: ans = t break print(ans)" p03327,s955853247,Accepted,print('ABD' if int(input())//1000 else 'ABC') p02772,s873564766,Wrong Answer,"n=int(input()) l=list(map(int,input().split())) for i in range(n): if l[i]%2==0: if l[i]%3!=0 and l[i]%5!=0: print('DENIED') break elif i==n-1: print('APPROVED')" p03481,s572914286,Accepted,"x,y=map(int,input().split()) for i in range(1,1000000): x*=2 if x>y: print(i) exit()" p03835,s634974552,Accepted,"k,s = map(int,input().split()) cnt=0 for i in range(min(k,s)+1): for j in range(min(k,s-i)+1): if s-i-j<=k: cnt+=1 print(cnt)" p03035,s215517544,Accepted,"A, B = (int(x) for x in input().split()) if A <= 5: print(0) elif A>= 13: print(B) else: print(B//2) " p03243,s897049983,Accepted,"N = int(input()) for i in range(N,1000): if len(set(list(str(i)))) == 1: print(i) break" p02835,s760762658,Accepted,"a,b,c=map(int,input().split()) if a+b+c>21: print(""bust"") else: print(""win"")" p03487,s878198055,Accepted,"import collections N = int(input()) lsA = list(map(int,input().split())) counterA = collections.Counter(lsA) ans = 0 for i in counterA.keys(): if i == counterA[i]: continue if i < counterA[i]: ans += counterA[i]-i elif i > counterA[i]: ans += counterA[i] print(ans)" p03041,s684687766,Accepted,"N,K=map(int,input().split()) K-=1 S=input() S=S[:K]+S[K].lower()+S[K+1:] print(S)" p03623,s312866793,Accepted,"x, A, B = map(int,input().split()) a = abs(x-A) b = abs(x-B) if a > b: print(""B"") else: print(""A"")" p02717,s353855262,Accepted,"a,b,c=map(int,input().split()) print(c,a,b)" p03252,s200167472,Accepted,"from collections import Counter s = Counter(list(input())) t = Counter(list(input())) s,t = list(s.values()),list(t.values()) print(""Yes"" if sorted(s) == sorted(t) else""No"")" p03644,s692903682,Accepted,"N=int(input()) i=0 while pow(2, i+1)<=N: i+=1 print(pow(2, i))" p02817,s273424742,Wrong Answer,"s, t = input().split() print(s+t)" p02684,s762657113,Accepted,"import sys readline = sys.stdin.readline N,K = map(int,readline().split()) A = [0] + list(map(int,readline().split())) now = 1 while K > 0: if K & 1: now = A[now] A = [A[A[i]] for i in range(len(A))] K >>= 1 print(now)" p02879,s055399991,Accepted,"A, B = map(int, input().split()) if A <= 9 and B <= 9: print(A * B) else: print(-1) " p02862,s812686673,Accepted,"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,max(m,n),MOD) print(ans)" p02988,s848191861,Accepted,"n = int(input()) p = [int(i) for i in input().split()] count = 0 for i in range(1,n-1): num = [p[i-1],p[i],p[i+1]] if p[i] != min(num) and p[i] !=max(num): count += 1 print(count)" p02957,s259738196,Accepted,"A, B = map(int, input().split()) K = 0 L = (A + B) if L % 2 == 1: print(""IMPOSSIBLE"") else: print(L // 2)" p03261,s810412009,Accepted,"n = int(input()) w = [input() for i in range(n)] if len(w) != len(set(w)): print(""No"") exit() for i in range(n-1): if w[i][-1] != w[i+1][0]: print(""No"") exit() print(""Yes"")" p02959,s213547338,Accepted,"from collections import deque from bisect import bisect_left N = int(input()) A = list(map(int, input().split( ))) B = list(map(int, input().split( ))) cnt = 0 for i in range(N): if A[i] >= B[i]: cnt += B[i] else: cnt += A[i] d = B[i] - A[i] if d <= A[i+1]: cnt += d A[i+1] -= d else:#つまり d > A[i+1] cnt += A[i+1] A[i+1] = 0 # print('i=', i, cnt) print(cnt)" p03435,s745600813,Accepted,"c=[] for i in range(3): c.append(list(map(int,input().split()))) for i in range(2): if c[i+1][0]-c[i][0]==c[i+1][1]-c[i][1] and c[i+1][1]-c[i][1]==c[i+1][2]-c[i][2] and c[0][i+1]-c[0][i]==c[1][i+1]-c[1][i] and c[1][i+1]-c[1][i]==c[2][i+1]-c[2][i]: flg=0 else: flg=1 if flg==0: print(""Yes"") else: print(""No"") " p03012,s211095641,Accepted,"n=int(input()) w=list(map(int,input().split())) ans=10**9+7 for i in range(n): l=sum(w[:i]) r=sum(w[i:]) ans=min(ans,abs(l-r)) print(ans)" p03910,s672173327,Accepted,"n,ans,i = int(input()),0,1 while ans=1: if n==0: break if n>=i: print(i) n-=i i-=1" p02994,s547436729,Accepted,"n,l = map(int,input().split()) taste_all = 0 taste_remain = 0 taste_ans = 0 taste_select = 1000000 for i in range(n): taste_all += l + i for i in range(n): for j in range(n): if i != j: taste_remain += l + j temp = abs(taste_remain-taste_all) if temp < taste_select: taste_ans = taste_remain taste_select = temp taste_remain = 0 print(taste_ans) " p03478,s362145771,Accepted,"n, a, b = [int(i) for i in input().split()] count = 0 for number in range(n+1): string = str(number) total = sum([int(i) for i in string]) if a <= total <= b: count += number print(count)" p04044,s305789765,Accepted,"n, l = map(int, input().split()) s = [input() for _ in range(n)] s.sort() print(''.join(s))" p03711,s085632019,Wrong Answer,"x,y=map(int,input().split()) if x>y: x,y=y,x A=[1,3,5,7,8,10,12] B=[4,6,9,11] if x==2 or y==2: print('No') elif (x in A and y in B): print('No') else: print('Yes')" p02631,s198903929,Wrong Answer,"n=int(input()) a=(int(i) for i in input().split()) b=0 for i in a:b^=i print(*(i^b for i in a))" p02748,s294456025,Accepted," a, b, m = map(int, input().split()) a = list(map(int , input().split())) b = list(map(int , input().split())) xyc = [tuple(map(int, input().split())) for _ in range(m)] amin = min(a) bmin = min(b) ans = amin + bmin for x, y, c in xyc: ans = min(a[x-1] + b[y-1] - c, ans) print(ans)" p02882,s645973721,Accepted,"# -*- coding: utf-8 -*- """""" Created on Wed Sep 9 19:58:50 2020 @author: liang """""" """""" 【三角形の面積の公式】 S = 1/2 * a * b """""" import math a, b, x = map(int, input().split()) L = math.sqrt((x/a/b)**2 + b**2) if x >= a**2*b/2: ans = math.degrees(math.atan((b-x/a**2)/a*2)) else: ans = math.degrees(math.atan((a*b**2)/x/2)) #ans = math.degrees(math.asin(b/L)) print(ans)" p02760,s536933380,Accepted,"A = [list(map(int, input().split())) for _ in range(3)] n = int(input()) B = [int(input()) for _ in range(n)] li = [] for i in A: li.append(i) for i in range(3): li.append([A[0][i], A[1][i], A[2][i]]) li.append([A[0][0], A[1][1], A[2][2]]) li.append([A[0][2], A[1][1], A[2][0]]) for i, j, k in li: if i in B and j in B and k in B: print(""Yes"") exit() print(""No"")" p03371,s954622660,Wrong Answer,"A, B, C, X, Y = map(int, input().split()) if A*X + B*Y > 2*C*max(X, Y): print(2*C*max(X, Y)) elif A + B > 2 * C: C_num = min(X, Y) if X > Y: print(C_num*2*C + A*(X-C_num)) else: print(C_num*2*C + B*(Y-C_num)) else: print(A*X + B*Y)" p03761,s765513202,Accepted,"n=int(input()) s=[input() for i in range(n)] l=[0]*26 moji=[] for i in range(26): mini=len(s[0]) for j in range(n): if s[j].count(chr(97+i))t_limit or c_limit>=c: ans+=1 c_limit=1 t_limit = t+k else: c_limit+=1 print(ans)" p03220,s436661485,Accepted,"import sys n = int(input()) t,a = map(int,input().split()) h = list(map(int,input().split())) for i in range(n): h[i] = abs(a-(t - h[i]*0.006)) minh = min(h) for i in range(n): if h[i] == minh: print(i+1) sys.exit() " p03146,s700315213,Accepted,"s = int(input()) a = [] i = 0 while True: if i == 0: a.append(s) elif a[i-1] % 2 == 0: a.append(a[i-1] / 2) else: a.append(a[i-1] * 3 + 1) if a[i] in a[:i]: print(i + 1) break i += 1 " p03162,s088669643,Accepted,"n = int(input()) List = [list(map(int,input().split())) for i in range(n)] dp = [[0, 0, 0] for _ in range(n+1)] dp[0] = [List[0][0], List[0][1], List[0][2]] for i in range(1, n): for j in range(3): for k in range(3): if j != k: dp[i][j] = max(dp[i][j], dp[i-1][k]+List[i][j]) print(max(dp[n-1]))" p03721,s270218218,Accepted,"N, K = map(int, input().split()) bucket = [0] * (10 ** 5 + 1) for _ in range(N): a, b = map(int, input().split()) bucket[a] += b cnt = 0 for i, c in enumerate(bucket): if c == 0: continue cnt += c if cnt >= K: print(i) exit()" p02753,s146915417,Wrong Answer,"text = input() if text == ""AAA"" or text == ""BBB"": print(""NO"") else: print(""YES"")" p02659,s631921809,Wrong Answer,"import math a, b = map(float,input().split()) ans = int(a * (100*b)) print(math.floor(ans/100))" p03475,s868168950,Accepted,"import sys import math class cin(): def getInt(): return int(sys.stdin.readline().rstrip()) def getString(): return sys.stdin.readline().rstrip() N = cin.getInt() A = [list(map(int,cin.getString().split())) for i in range(N - 1)] for i in range(N): t = 0 for j in range(i,N - 1): if t <= A[j][1]: t = A[j][1] + A[j][0] else: t = -(-t // A[j][2]) * A[j][2] + A[j][0] print(t)" p02623,s667412725,Accepted,"N, M, K = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) arui = [0] * (N + 1) brui = [0] * (M + 1) for i in range(N): arui[i + 1] = a[i] + arui[i] for i in range(M): brui[i + 1] = b[i] + brui[i] ans, j = 0, M for i in range(N + 1): if arui[i] > K: break while brui[j] > K - arui[i]: j -= 1 ans = max(ans, i + j) print(ans) " p02795,s120511246,Accepted,"h=int(input()) w=int(input()) n=int(input()) a=0 ans=0 paint=max(h,w) while a= 26: Index =- 26 new_upper.append(upper[Index]) else: new_upper.append(upper[Index]) print(''.join(new_upper))" p03284,s531209670,Wrong Answer,"N,K = map(int,input().split("" "")) print(N%K)" p02681,s304254995,Accepted,"S1 = list(input()) S2 = list(input()) S1.append(S2[-1]) if S1==S2: print(""Yes"") else: print(""No"")" p03385,s446543376,Accepted,"s=input() l=set([]) for i in s: l.add(i) if l==set(['a','b','c']): print('Yes') else: print('No')" p02624,s201725938,Accepted,"#172D #Sum of Divisors n=int(input()) ans=0 for i in range(1,n+1): j=n//i ans+=j*(j+1)*i/2 print(int(ans))" p02647,s019426867,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) while min(a) < n and k > 0: mark = [0] * (n + 1) for i in range(n): mark[max([0, i - a[i]])] += 1 mark[min([n, i + a[i] + 1])] -= 1 a = [mark[0]] for i in range(1, n): a.append(a[-1] + mark[i]) k -= 1 print(' '.join(map(str, a)))" p03127,s691700835,Accepted,"n = int(input()) al = list(map(int,input().split())) # a,bの最大公約数 def gcd(a, b): while b: a, b = b, a % b return a # a,bの最小公倍数 def lcm(a, b): return a * b // gcd(a, b) ans = al[0] for a in al: ans = gcd(a, ans) print(ans)" p03434,s490786710,Accepted,"N = int(input()) A = list(map(int, input().split())) A = sorted(A)[::-1] print(sum(A[::2]) - sum(A[1::2]))" p03475,s025704654,Accepted,"n = int(input()) c = [] s = [] f = [] for _ in range(n-1): p,q,r = map(int,input().split()) c.append(p) s.append(q) f.append(r) a = [0]*n for i in range(n-1): t = 0 for j in range(i, n-1): if t <= s[j]: t = s[j] elif t%f[j] != 0: t += f[j]-t%f[j] t += c[j] a[i] = t print('\n'.join(map(str, a))) " p03815,s274384707,Accepted,"from sys import stdin def main(): #入力 readline=stdin.readline x=int(readline()) n=x//11 m=x%11 if m==0: print(2*n) elif 1<=m<=6: print(2*n+1) else: print(2*n+2) if __name__==""__main__"": main()" p02694,s959712966,Accepted,"X = int(input()) a = 100 ans = 0 while a < X: ans += 1 a = int(a * 1.01) print(ans)" p03760,s162955509,Wrong Answer,"O = input() E = input() K = len(E) String = """" for i in range(K): String += O[i] String += E[i] print(String)" p02818,s218278575,Accepted,"a,b,k=map(int,input().split()) if a>=k: print(a-k, b) elif b>=k-a: print(0, b-k+a) else: print(0, 0)" p03479,s525549752,Accepted,"x,y=map(int,input().split()) ans=[x] while True: tmp=ans[-1]*2 if tmp<=y: ans.append(tmp) else: break print(len(ans))" p03592,s006339258,Accepted,"n, m, k = map(int, input().split()) for i in range(n + 1): for j in range(m + 1): if i * m + j * n - 2 * i * j == k: print(""Yes"") exit() print(""No"")" p02958,s054914908,Accepted,"N = int(input()) p = list(map(int, input().split())) isMatch = list(map(lambda x, y: x == y, p, sorted(p))) result = 'YES' if isMatch.count(False) <= 2 else 'NO' print(result)" p03624,s156931800,Accepted,"import numpy as np S=input() a_list = ""abcdefghijklmnopqrstuvwxyz"" c_list = np.zeros(26) for i in range(len(S)): c_list[a_list.index(S[i])] = c_list[a_list.index(S[i])] + 1 if not 0 in c_list: print('None') else: c_list = c_list.tolist() print(a_list[c_list.index(0)])" p02584,s984261489,Accepted,"def main(): x, k, d = map(int, input().split()) if x >=0 and abs(x) >= k *d: print(x - k*d) elif x < 0 and abs(x) >= k *d: print(abs(x) - k*d) else: x = abs(x) t = x // d k -= t x -= t*d print(abs(x - (k%2)*d)) if __name__ == '__main__': main()" p03493,s393955098,Accepted,"n = input() b = 0 for i in range(3): if n[i] == ""1"": b += 1 print(b)" p03417,s940001467,Wrong Answer,"N,M = map(int,input().split()) if(min(N,M)==1): print(max(max(N,M)-2,0)) else: print(max(N-2,0)*max(M-2,0))" p03544,s496440316,Wrong Answer,"n=int(input()) l_b=2 l=1 if n==1: print(""2"") elif n==2: print(""1"") else: for i in range(3,n+1): l_bb=l_b l_b=l l=l_b+l_bb print(l) " p02843,s448228585,Accepted,"x = int(input()) dp = [0]*(x + 105 + 1) dp[100] = 1 dp[101] = 1 dp[102] = 1 dp[103] = 1 dp[104] = 1 dp[105] = 1 for i in range(100,x-105+50): for j in range(100,106): dp[i+j] = max(dp[i] , dp[i+j]) print(dp[x])" p03380,s128390453,Accepted,"n = int(input()) A = list(map(int, input().split())) def obj_func(v, base): return abs(v - base) ai = aj = max(A) base = ai / 2 min_obj = 10**10 for a in A: if a == ai: continue obj = obj_func(a, base) if obj < min_obj: min_obj = obj aj = a print(ai, aj)" p03625,s223358809,Wrong Answer,"from collections import Counter N = int(input()) A = list(map(int,input().split())) count = Counter(A) keys = list(count.keys()) keys.sort(reverse = True) a = 0 b = 0 for k in keys: if count[k] >= 4: a = b = k break elif count[k] >= 2: if a == 0: a = k else: b = k break print(a * b)" p02831,s101877747,Wrong Answer,"import math import numpy as np A,B = list(map(int,input().split())) if A == 0 or B == 0: print('0') exit() C = A*B D = [] for i in range(1,int(math.sqrt(C))): if A % i == 0 and B % i == 0: A = A // i B = B // i D.append(i) C = A*B p = np.prod(D) if p != 0: C = C*p print(C)" p03711,s507381270,Wrong Answer,"a,b=map(int, input().split()) if a==2 or b==2: print('No') elif (a-4)*(a-6)*(a-9)*(a-12)==0 and (b-4)*(b-6)*(b-9)*(b-12)==0: print('Yes') elif (a-1)*(a-3)*(a-5)*(a-7)*(a-8)*(a-12)==0 and (b-1)*(b-3)*(b-5)*(b-7)*(b-8)*(b-12)==0: print('Yes') else: print('No')" p02767,s995022187,Wrong Answer,"n = int(input()) x = sorted(list(map(int, input().split()))) x_min = x[0] x_max = x[n-1] min_sum = 10000000 for p in range(x_min, x_max): sum = 0 for e in x: len = (e - p)**2 sum += len # print(""p"", p, ""sum"", sum, ""min_sum"", min_sum) if sum <= min_sum: min_sum = sum print(min_sum) " p03486,s681800805,Accepted,"s = list(input()) t = list(input()) s.sort() t.sort(reverse=True) S = """".join(s) T = """".join(t) if S < T: print(""Yes"") else: print(""No"")" p02789,s251580460,Accepted,"n, m = input().split() print(""Yes"" if n == m else ""No"") " p02675,s607089785,Accepted,"n = int(input()) if n%10 == 3 : print(""bon"") elif n%10 == 0 or n%10 == 1 or n%10 == 6 or n%10 == 8 : print(""pon"") else : print(""hon"")" p02602,s172351381,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]>0 else ""No"")" p02712,s625411251,Accepted,"N=1 a=int(input()) ans=0 while N<=a : if N%3==0 and N%5==0 : pass elif N%3==0 : pass elif N%5==0 : pass else : ans+=N N+=1 print(ans)" p02707,s576811154,Accepted,"n = int(input()) a = list(map(int, input().split())) subordinates = [0 for i in range(n)] for e in a: subordinates[e-1] += 1 for e in subordinates: print(e)" p04029,s361536980,Accepted,"n = int(input()) print(n * (n+1) // 2)" p03457,s792345313,Accepted,"N = int(input()) T = [] X = [] Y = [] for _ in range(N): t, x, y = map(int, input().split()) T.append(t) X.append(x) Y.append(y) flag = 0 if T[0]-abs(X[0])-abs(Y[0]) < 0 or (T[0]-abs(X[0])-abs(Y[0]))%2 != 0: flag = 1 for i in range(N-1): if T[i+1]-T[i]-abs(X[i+1]-X[i])-abs(Y[i+1]-Y[i]) < 0 or (T[i+1]-T[i]-abs(X[i+1]-X[i])-abs(Y[i+1]-Y[i]))%2 != 0: flag = 1 print(""Yes"" if flag == 0 else ""No"") " p03835,s386820828,Accepted,"K, S = map(int, input().split()) cnt = 0 for i in range(K+1): for j in range(i, K+1): if 0 <= S - i - j <= K: if i == j: cnt += 1 else: cnt += 2 print(cnt)" p03241,s112916987,Accepted,"import sys import collections from math import ceil ma = lambda : map(int,input().split()) ni = lambda : int(input()) def divisor(n): d = [] for i in range(1,int(n**0.5)+1): if n%i == 0: d.append(i) if i != n//i: d.append(n//i) #d.sort() return d n,m = ma() gcd = 1 D = divisor(m) for d in D: q,r = divmod(m,d) if q>=n and r==0:gcd = max(gcd,d) print(gcd) " p02717,s321024558,Accepted,"X, Y, Z = map(int, input().split()) print(Z, X, Y)" p03493,s041663650,Accepted,"s = input() print(s.count(""1""))" p03379,s584102684,Accepted,"from decimal import Decimal n = int(input()) x = list(map(int, input().split())) y = x.copy() y.sort() m1 = y[n//2] m2 = y[n//2 - 1] m = Decimal(m1 + m2) / Decimal(2) #print(m1, m2) for z in x: if z <= m: print(m1) else: print(m2)" p03285,s642350029,Wrong Answer,"N = int(input()) ans = ""No"" while N > 0: if N % 4 == 0: ans = ""Yes"" break else: N = N - 7 print(ans)" p02744,s363173851,Wrong Answer,"N = int(input()) A = [0] * N ED = [chr(i + 97) for i in range(N)] ED = ''.join(ED) ans = [] while True: for i in range(N - 1, 0, -1): if A[i] == A[i - 1] + 2: A[i] = 0 A[i - 1] += 1 ret = ['' for _ in range(N)] for i in range(N): ret[i] = chr(A[i] + 97) ret = ''.join(ret) ans.append(ret) if ret == ED: break else: A[-1] += 1 print(*sorted(ans),sep='\n')" p02759,s145771494,Accepted,"n = int(input()) print((n+1)//2)" p02995,s722747962,Wrong Answer,"import fractions A,B,C,D = (int(x) for x in input().split()) c = 0 d = 0 def lcm(x, y): return (x * y) // fractions.gcd(x, y) M = lcm(C,D) c = B//C - A//C d = B//D - A//D m = B//M - A//M print(B-A+1-(c+d-m)) " p02640,s862727977,Accepted,"# -*- coding: utf-8 -*- # 整数の入力 num, x = map(int, input().split()) # loop flag = 0 for i in range(num + 1): if((2*i + 4*(num - i)) == x): flag += 1 print(""No"") if flag == 0 else print(""Yes"")" p03745,s138596786,Wrong Answer,"from collections import deque n = int(input()) a = list(map(int,input().split())) d = deque(a) tmp = [] cnt = 0 while d: v = d.popleft() if len(tmp)<=1: pass else: if not v >= tmp[-1] >= tmp[-2] or v <= tmp[-1] <= tmp[-2]: tmp = [] cnt += 1 tmp.append(v) # print(d,tmp,cnt) if tmp: cnt+=1 print(cnt)" p03293,s361546664,Accepted,"# -*- coding: utf-8 -*- from collections import deque import sys #input = sys.stdin.readline def inpl(): return list(map(int, input().split())) S = input() T = input() for i in range(len(S)+1): if S == T[i:] + T[:i]: print(""Yes"") break else: print(""No"")" p02664,s137812267,Wrong Answer,"t = input() t.replace(""?"", ""D"") print(t)" p02548,s453925279,Accepted,"N=int(input()) count=0 for A in range(1,N): count+=(N-1)//A print(count)" p03543,s894991714,Accepted,"import sys n = sys.stdin.readline().rstrip() def main(): ans = 'Yes' if n[1] != n[2]: ans = 'No' else: if n[0] != n[1] and n[2] != n[3]: ans = 'No' print(ans) if __name__ == '__main__': main()" p02881,s601095837,Accepted,"N = int(input()) mini = float('inf') for i in range(1, 10**6 + 1): if N%i == 0: mini = min(mini, i+(N//i)) print(mini - 2)" p02888,s033390710,Accepted,"import bisect n = int(input()) lis = sorted(list(map(int, input().split()))) ans = 0 for i in range(n-2): for j in range(i+1, n-1): ans += max(bisect.bisect_left(lis, lis[j]+lis[i]) - j - 1, 0) print(ans)" p03623,s530739060,Accepted,"x, a, b = map(int, input().split()) if abs(a - x) < abs(b - x): print('A') else: print('B')" p02759,s038557327,Accepted,"import math n = int(input()) print(math.ceil(n/2)) " p02657,s373633633,Wrong Answer,"A, B = map(int, input().split()) print(A+B)" p03804,s765187067,Accepted,"n, m= map(int, input().split()) a = [input() for _ in range(n)] b = [input() for _ in range(m)] r = range(n-m+1) for i in r: for j in r: for k in range(m): if a[i+k][j:j+m] != b[k]: break else: print('Yes') exit() print('No')" p02677,s183183891,Accepted,"import sys sys.setrecursionlimit(10000000) import numpy as np from heapq import heapify, heappop, heappush import copy import math def main(): A, B, H, M = map(int, input().split()) theta = abs(6 * M - 30 * (H + M / 60)) c = (B ** 2 + A ** 2 - 2 * A * B * math.cos(math.radians(theta))) ** 0.5 print(c) if __name__ == '__main__': main() " p02787,s445878854,Accepted,"h, n = map(int,input().split()) maho = [] for i in range(n): aa,ba = map(int,input().split()) maho.append([aa,ba]) dp = [0 for i in range(h+1)] for i in range(1,h+1): cost = 10000000000 for j in range(n): if i - maho[j][0] < 0: cost = min(cost, maho[j][1]) else: cost = min(cost, dp[i-maho[j][0]] + maho[j][1]) dp[i] = cost #print(dp[175:183]) print(dp[h])" p02633,s405458206,Wrong Answer,"from math import ceil x = int(input()) print(ceil(360/x)) " p02784,s178766666,Accepted,"H, N = map(int, input().split()) A = list(map(int, input().split())) print('Yes' if sum(A) >= H else 'No')" p02900,s763125140,Accepted,"import fractions def prime_function(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()) GCD=fractions.gcd(A,B) print(len(set(prime_function(GCD)))+1)" p03625,s626928992,Wrong Answer,"N = int(input()) A = list(map(int, input().split())) import collections ans = 0 c = collections.Counter(A) lis = [] for k,v in c.items(): if v>=2: lis.append(k) if len(lis)>=2: lis.sort() ans = lis[-1]*lis[-2] print(ans) #print(*ans, sep='\n') " p03944,s749898038,Accepted,"w,h,n=map(int,input().split()) l,r,u,d=0,w,h,0 for _ in [0]*n: x,y,a=map(int,input().split()) l=max(l,x) if a==1 else l r=min(r,x) if a==2 else r d=max(d,y) if a==3 else d u=min(u,y) if a==4 else u print(max(0,r-l)*max(0,u-d))" p02623,s095490390,Accepted,"N, M, K = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) a = [0] b = [0] for i in range(N): a.append(a[i] + A[i]) for j in range(M): b.append(b[j] + B[j]) ans = 0 j = M for i in range(N + 1): if a[i] > K: break while b[j] > K - a[i]: j -= 1 ans = max(i + j, ans) print(ans)" p03385,s613765269,Accepted,"s = list(input()) if len(set(s)) == 3: print(""Yes"") else: print(""No"")" p03943,s245585357,Accepted,"A, B, C = map(int, input().split()) AB = A+B BC = B+C CA = C+A if AB==C or BC==A or CA==B: print(""Yes"") else: print(""No"") " p02665,s092960339,Accepted,"from collections import deque import sys def input(): return sys.stdin.readline().rstrip() N = int(input()) v = list(map(int, input().split())) ans, nd = 0, 0 lim = [1 for _ in range(N + 2)] for i in range(N): lim[i+1] = (lim[i] - v[i]) * 2 for i in range(N, -1, -1): if v[i] + nd > lim[i] * 2 or lim[i] - v[i] < 0: print(-1) sys.exit(0) if v[i] + nd > lim[i]: nd = lim[i] - v[i] nd += v[i] ans += nd print(ans)" p02718,s548822090,Accepted,"n,m=map(int,input().split()) a=list(map(int,input().split())) aa=sum(a) count=0 for i in range(len(a)): if a[i]>=aa*(1/(4*m)): count+=1 else: pass if count>=m: print(""Yes"") else: print(""No"")" p03017,s494063569,Accepted,"n, a, b, c, d = map(int, input().split()) s = input() a = a-1 b = b-1 c = c-1 d = d-1 for i in range(a+1, d): if s[i-1] == '#' and s[i] == '#': print('No') exit() if c < d: print('Yes') exit() for i in range(b, d+1): if s[i-1] == '.' and s[i] == '.' and s[i+1] == '.': print('Yes') exit() print('No') " p02678,s009792418,Accepted,"from collections import deque N,M=map(int,input().split()) to=[[] for _ in range(N)] for _ in range(M): a,b=map(int,input().split()) to[a-1].append(b-1) to[b-1].append(a-1) q=deque([0]) r=[-1]*N r[0]=0 while q: x=q.popleft() for i in to[x]: if r[i]==-1: q.append(i) r[i]=x+1 print(""Yes"",*r[1:],sep=""\n"")" p02832,s007887051,Accepted,"N = int(input()) A = map(int, input().split()) ans = 0 i = 1 for a in A: if a == i: i += 1 else: ans += 1 print([ans, -1][i==1])" p03986,s630851125,Wrong Answer,"from collections import deque S=list(map(lambda x: 1 if x==""T"" else 0,list(""ST""*10**4))) 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))" p03821,s526418439,Accepted,"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]+cnt)%B[i] == 0: continue else: cnt += B[i] - (A[i]+cnt)%B[i] print(cnt) " p02706,s673267879,Accepted,"def main(): import sys input=sys.stdin.readline n,m=map(int,input().split()) A=list(map(int,input().split())) S=sum(A) if S>n: print(-1) else: print(n-S) if __name__ == '__main__': main()" p03387,s778350449,Wrong Answer,"a = sorted(list(map(int, input().split()))) ans = 0 if (a[2]-a[1])%2==0: ans += (a[2]-a[1])//2 else: if (a[2]-a[1])%2==1 and (a[2]-a[0])%2==1: ans -= (a[2]-a[1]) else: ans += (a[2]-a[1]) if (a[2]-a[0])%2==0: ans += (a[2]-a[0])//2 else: ans += (a[2]-a[0]) print(ans)" p02842,s156096337,Wrong Answer,"N = int(input()) for i in range(N-1): X = i * 1.08 if int(X) == N: print(i) exit() print(':(')" p03041,s152404050,Accepted,"# A - Changing a Character n, k = map(int, input().split()) s = list(str(input())) ans = [] for i in range(n): if i==(k-1): ans.append(s[i].lower()) else: ans.append(s[i]) print(''.join(ans)) " p02766,s246914737,Wrong Answer,"import math n, k = map(int, input().split()) print(math.ceil(math.log(n, k)))" p03345,s747937762,Accepted,"a,b,c,K=list(map(int,input().split())) print((a-b)*((-1)**K))" p03136,s596135517,Accepted,"import sys def input(): return sys.stdin.readline().rstrip() def main(): _ = int(input()) L = tuple(map(int, input().split())) sum_l = sum(L) for l in L: if 2 * l >= sum_l: print('No') break else: print('Yes') if __name__ == '__main__': main() " p03997,s916102295,Accepted," a = int(input()) b = int(input()) h = int(input()) print(int((a+b)*h/2))" p02553,s965004908,Accepted,"a,b,c,d=map(int,input().split()) x1=a*c x2=a*d x3=b*c x4=b*d lst=[] lst.append(x2) lst.append(x3) lst.append(x4) lst.append(x1) lst.sort() print(lst[-1])" p03387,s603543122,Accepted,"a,b,c=map(int,input().split()) m=max(a,b,c) d=3*m-(a+b+c) if d%2==0: print(d//2) else: print((d+3)//2)" p03086,s614755694,Accepted,"s = input() lis = ['A','C','G','T'] sub = [] for i in range(len(s)): for j in range(i+1,len(s)+1): tmp = s[i:j] flag = True for k in range(len(tmp)): if tmp[k] in lis: pass else: flag = False if flag: sub.append(tmp) ma = 0 for i in sub: l = len(i) if l > ma: ma = l print(ma)" p03814,s434237221,Accepted,"s=input() n=len(s) k=s[::-1] a=s.index(""A"") z=n-k.index(""Z"") print(z-a)" p03457,s282511404,Accepted,"N = int(input()) yes = True for _ in range(N): t, x, y = map(int, input().split()) margin = t - (x + y) if not(margin >= 0 and margin % 2 == 0): yes = False if yes: print(""Yes"") else: print(""No"")" p02627,s415915431,Accepted,"letter = input() if ""a"" <= letter <= ""z"": print(""a"") elif ""A"" <= letter <= ""Z"": print(""A"") " p02675,s056065905,Accepted,"N=int(input()) if N%10 in {2,4,5,7,9}: print(""hon"") elif N%10 in {0,1,6,8}: print(""pon"") else: print(""bon"") " p02584,s013623412,Accepted,"def main(): X, K, D = map(int, input().split()) if X < 0: X *= (-1) i = min(X // D, K) out = X - i * D if (K - i) % 2 == 0 or K < X//D: print(out) else: print(min(abs(out - D), abs(out + D))) if __name__ == '__main__': main() " p03062,s337819952,Accepted,"N=int(input()) A=list(map(int,input().split())) dp=[[0]*2 for i in range(N+1)] dp[0][1]=-10**30 for i in range(N): dp[i+1][0]=max(dp[i][0]+A[i],dp[i][1]-A[i]) dp[i+1][1]=max(dp[i][1]+A[i],dp[i][0]-A[i]) print(dp[N][0])" p02612,s346807864,Accepted,"N = int(input()) for i in range(10): if (i+1)*1000 >= N: print((i+1)*1000-N) exit()" p02760,s774705525,Accepted,"A=[list(map(int,input().split())) for i in range(3)] N=int(input()) B=[int(input()) for i in range(N)] x=[[0]*3 for i in range(3)] for b in B: for i,l in enumerate(A): for j,a in enumerate(l): if a==b: x[i][j]=1 print('Yes' if sum([all(l) for l in x]+[all(l) for l in zip(*x)]+[all([x[i][i] for i in range(3)]),all([x[i][2-i] for i in range(3)])]) else 'No')" p03210,s587498762,Wrong Answer,"a=int(input()) if a==3 or a==5 or a==9: print('YES') else : print('NO')" p02602,s402214237,Accepted,"import sys read = sys.stdin.readline import time import math import itertools as it def inpl(): return list(map(int, input().split())) st = time.perf_counter() # ------------------------------ N, K = inpl() A = inpl() for i in range(K, N): if A[i] > A[i-K]: print('Yes') else: print('No') # ----------------------------- ed = time.perf_counter() print('time:', ed-st, file=sys.stderr) " p02612,s204611706,Accepted,"N = int(input()) ans = N%1000 if ans == 0: print(0) else: print(1000-ans)" p03971,s052739426,Accepted,"N, A, B = map(int, input().split()) S = input() a = 0 b = 0 for char in S: if char == 'a' and a + b < A + B: a += 1 print('Yes') elif char == 'b' and a + b < A + B and b < B: b += 1 print('Yes') else: print('No') " p03545,s051539860,Accepted,"*A, = list(input()) s = ['+', '-'] for i in range(2**3): formula = A[0] for j in range(3): if i >> j & 1: formula += s[0] else: formula += s[1] formula += A[j+1] if eval(formula) == 7: print(formula+'=7') exit() " p03645,s345683401,Wrong Answer,"N, M = map(int, input().split()) To_List = [] for _ in range(M): a, b = map(int, input().split()) if a == 1: To_List.append(b) if b == N: if a in To_List: print(""POSSIBLE"") print(""IMPOSSIBLE"") " p03274,s436657455,Accepted,"n,k=map(int,input().split()) a=list(map(int,input().split())) hantei=10**10+1 for i in range(0,n-k+1): #print(a[i],a[i+k-1]) d=a[i+k-1]-a[i]+min(abs(a[i]),abs(a[i+k-1])) if hantei>d: hantei=d print(hantei)" p03719,s895296259,Accepted,"a,b,c = map(int, input().split()) print(""Yes"" if a<=c<=b else ""No"")" p03359,s940212738,Accepted," url = ""https://atcoder.jp//contests/abc096/tasks/abc096_a"" def main(): m, d = list(map(int, input().split())) ans = m if m > d: ans -= 1 print(ans) if __name__ == '__main__': main() " p02572,s955767688,Accepted,"n=int(input()) a=list(map(int,input().split())) b=sum(a) l=[] for i in range(len(a)-1): b-=a[i] l.append(a[i]*b) print(sum(l)%(1000000007)) " p03719,s331091873,Accepted,"def actual(A, B, C): if A <= C <= B: return 'Yes' return 'No' A, B, C = map(int, input().split()) print(actual(A, B, C))" p02811,s876803501,Wrong Answer,"x,y = map(int,input().split()) if x *500 >= y : print(""Yes"") else: print(""NO"") " p02959,s823837812,Accepted,"N = int(input()) A = [int(x) for x in input().split()] B = [int(x) for x in input().split()] m = 0 for i in range(N): if A[i] >= B[i]: m += B[i] else: m += A[i] if A[i+1] >= (B[i]-A[i]): m += (B[i]-A[i]) A[i+1] -= (B[i]-A[i]) else: m += A[i+1] A[i+1] = 0 print(m)" p02988,s168472148,Wrong Answer,"n = int(input()) p = list(map(int, input().split())) ans = 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]: ans += 1 print(ans)" p02922,s816857945,Accepted,"a, b = map(int, input().split(' ')) print(-(-(b-1) // (a-1))) " p02747,s538300648,Wrong Answer,"a = list(map(str, input().split())) num = len(a) TorF = True if num % 2 == 0: for i in range(num/2): if not a(2*i ) == 'h' and a(2*i + 1) == 'i': TorF = False break else: TorF = False if TorF == True: print('Yes') else: print('No')" p02687,s148670331,Accepted,"S=input() if S==""ABC"": print(""ARC"") else: print(""ABC"")" p03827,s435216971,Accepted,"n=input() s=input() x=0 a=0 for i in s: if i==""I"":x+=1 else:x-=1 a=max(a,x) print(a) " p02791,s691089188,Accepted,"n = int(input()) p = list(map(int,input().split())) m = float('inf') ans = 0 n_min = 0 for i in range(0,n): if m >= p[i]: ans += 1 m = p[i] print(ans)" p03557,s522360391,Accepted,"import sys read = sys.stdin.read #readlines = sys.stdin.readlines from bisect import bisect, bisect_left from itertools import accumulate def main(): data = list(map(int, read().split())) n = data[0] a = data[1:n + 1] b = data[n + 1: n * 2 + 1] c = data[n * 2 + 1:] a.sort() b.sort() c.sort() b2 = [bisect_left(a, be) for be in b] b2a = list(accumulate(b2)) b2a = [0] + b2a ans = sum([b2a[bisect_left(b, ce)] for ce in c]) print(ans) if __name__ == '__main__': main()" p02576,s358760912,Accepted,"n,x,t=[int(i) for i in input().split()] k=n//x if n%x: print((k+1)*t) else: print(k*t)" p03821,s008933550,Accepted,"n = int(input()) cnt = 0 ab_l = [list(map(int, input().split())) for _ in range(n)] for ab in ab_l[::-1]: a, b = ab[0], ab[1] a += cnt if a % b != 0: cnt += b - a%b print(cnt)" p03681,s138381937,Accepted,"from math import factorial n, m = map(int,input().split()) if abs(n-m) >= 2: print(0) else: n_per = factorial(n) // factorial(n - n) m_per = factorial(m) // factorial(m - m) if n != m: print((n_per * m_per) % (10**9 + 7)) else: print((n_per * m_per *2) % (10**9 + 7))" p02731,s938663753,Wrong Answer,"import math n = int(input()) print(math.floor(n / 3) * math.floor(n / 3) * math.ceil(n / 3))" p02838,s942952444,Accepted,"n=int(input()) a=list(map(int,input().split())) mod=10**9+7 ans=0 for i in range(60): o=0 x=1<=12: print(b) else: print(b//2)" p03323,s489695038,Wrong Answer,"A, B = map(int, input().split()) if A <= 8: if B <=8: print(""Yay!"") else: print("":("")" p02772,s934421303,Accepted,"n = int(input()) a = list(map(int,input().split())) tf = True for i in a: if i%2 ==0: if i % 3 ==0: pass elif i % 5 == 0: pass else: tf = False if tf: print('APPROVED') else: print('DENIED')" p03799,s170216667,Accepted,"n, m = map(int, input().split()) ans = 0 res = 0 if n >= (m//4) * 2: print((m//4) * 2) else: ans += n res = m - 2*n ans += (res//4) print(ans)" p02765,s006952360,Accepted,"N, R = map(int, input().split()) if N < 10: answer = R + 100 * (10 - N) print(answer) else: print(R) " p02572,s027366238,Accepted,"N = int(input()) A = list(map(int, input().split())) ans = 0 m = 1000000007 s = 0 for i in range(N): ans += A[i] * s s += A[i] print(ans % m) " p04034,s813881928,Accepted,"N, M = map(int, input().split()) xy = [list(map(int, input().split())) for _ in range(M)] red = [0] * (N+1) #赤になりうる場所を1とする red[1] = 1 red[0] = """" ball = [1] * (N+1) #個数 ball[0] = """" for x, y in xy: ball[y] += 1 ball[x] -= 1 if red[x] == 1: red[y] = 1 if ball[x] == 0: red[x] = 0 print(red.count(1))" p03485,s791580770,Accepted,"a,b = map(int,input().split()) print((a+b+1)//2)" p02576,s803404490,Accepted,"# A - Takoyaki N,X,T = map(int,input().split()) ans = T*((N-1)//X+1) print(ans)" p02970,s206274174,Accepted,"n,d = map(int,input().split()) import math print(math.ceil(n/(2*d+1))) " p03126,s597557131,Wrong Answer,"n,m = map(int,input().split()) a = [0]*n k = [0]*n for i in range(0,n): a[i] = input().split() k[i] = a[i][0] del a[i][0] l = a[0] #print(l) for i in range(1,n): if(len(l) == 0): #print(0) exit() else: for j in l: if(j not in a[i]): k = l.index(j) del l[k] print(len(l))" p03943,s225800377,Accepted,"l=sorted(map(int,input().split())) if l[0]+l[1]==l[2]: print(""Yes"") else: print(""No"")" p02831,s511094318,Accepted,"a, b = map(int, input().split()) def gcd(x, y): x, y = max(x, y), min(x, y) if y == 0: return x return gcd(y, x % y) print(a * b // gcd(a, b))" p03377,s077215725,Wrong Answer,"a, b, x= map(int, input().split()) if a + b >= x and b > x and a <= x: print(""YES"") else: print(""NO"") " p03071,s732237102,Wrong Answer,"def max_coins(a, b): if a > b: print(a + (a -1)) elif a == b: print(a + b) else: print(b + (b-1))" p03427,s688642782,Accepted,"n = int(input()) di = len(str(n)) ans = sum([int(w)for w in str(n)]) for i in range(di): digits = [int(w)for w in str(n)] if digits[i] == 0: continue t = sum(digits[0:i]) t += digits[i]-1 t += 9 * (di - i - 1) ans = max(ans, t) print(ans) " p03627,s125303074,Accepted,"#!/usr/bin/env python3 import collections N = int(input()) A = list(map(int, input().split())) T = collections.Counter(A) hen1 = 0 # 小さい hen2 = 0 # 大きい for h, c in sorted(T.items(), key=lambda x:x[0]): if c >= 4: hen1 = h hen2 = h elif c >= 2: if hen1 >= hen2: hen2 = h else: hen1 = h print(hen1*hen2) " p03338,s435370181,Accepted,"n = int(input()) S = input() from collections import Counter ans = 0 for i in range(1,n): f = S[:i] b = S[i:] f = set(f) #print(f) #print(S[:i],S[i:]) cnt = 0 for v in f: #print(v) if v in b: cnt += 1 ans = max(ans,cnt) print(ans) " p02663,s374819498,Accepted,"H1, M1, H2, M2, K = map(int, input().split()) time1 = H1*60 + M1 time2 = H2*60 + M2 time = time2 - time1 ans = time - K print(max(ans, 0))" p03163,s792032348,Accepted,"N, W = list(map(int, input().split())) wv = [list(map(int, input().split())) for i in range(N)] dp = [[0] * (W+1) for i in range(N)] for i in range(N): w, v = wv[i] for j in range(W, 0, -1): if j - w < 0: dp[i][j] = dp[i-1][j] else: dp[i][j] = max(dp[i-1][j-w]+v, dp[i-1][j]) print(dp[N-1][W]) " p02935,s772425718,Accepted,"N = int(input()) S = list(map(int,input().split())) S = sorted(S) a = S[0] for i in range(N-1): a = (a + S[i+1])/2 print(a)" p02547,s382109701,Accepted,"n = int(input()) lst = [ [ int(i) for i in input().split() ] for j in range(n) ] r = 0 for i in range(n-2): if lst[i][0] == lst[i][1]: if lst[i+1][0] == lst[i+1][1]: if lst[i+2][0] == lst[i+2][1]: r = 1 if r == 0: print(""No"") else: print(""Yes"")" p02995,s274613977,Wrong Answer,"A, B, C, D = map(int, input().split()) E = max(C, D) while True: if E % min(C, D) == 0: break E += max(C, D) print(B - A - (B-A)//C - (B-A)//D + (B-A)//E)" p02646,s968190948,Accepted,"A, V = map(int, input().split()) B, W= map(int, input().split()) T = int(input()) diff1 = abs(A - B) diff2 = (V - W)*T if ( diff1 <= diff2): print(""YES"") else: print(""NO"")" p03319,s230969300,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) ans = (n - 1 + k - 2) // (k - 1) print(ans) " p03351,s168245189,Wrong Answer,"a, b, c, d = map(int,input().split()) if a - c <= d : print('Yes') elif (a - b) <= d and (b - c) <= d: print('Yes') else : print('No')" p02664,s941462810,Wrong Answer,"a = input() s = list(a) for i in range(len(s)): if (a[i] == '?'): s[i] = 'D' print(s) " p02659,s112251656,Accepted,"from decimal import Decimal A, B = input().split() A = Decimal(A) B = Decimal(B) print(int(A * B)) " p03469,s082964820,Accepted,"s = input() modify = '2018'+ s[4:] print(modify) " p02820,s826945785,Accepted,"n,k = map(int,input().split()) r,s,p = map(int,input().split()) t = input() ans = 0 vstd = [0]*n def jungkeng(x): global ans if x=='r': ans += p elif x=='s': ans += r else: ans += s return ans for i in range(k): ans = jungkeng(t[i]) vstd[i]=1 for i in range(k,n): if t[i]==t[i-k] and vstd[i-k]: continue ans = jungkeng(t[i]) vstd[i] = 1 print(ans)" p02661,s854717511,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()) aa = [] bb = [] for _ in range(n): a, b = map(int, readline().split()) aa.append(a) bb.append(b) aa.sort() bb.sort() print(bb[n // 2] - aa[n // 2] + 1 + n // 2) " p03672,s550219257,Accepted,"s=input() n=len(s) for i in range(2,n,2): h=(n-i)//2 if s[:h]==s[h:n-i]: print(n-i) break" p02681,s915627157,Wrong Answer,"s = input() t = input() if s == t[:-1]: print(""YES"") else: print(""NO"") " p02882,s103733674,Wrong Answer,"import math a, b, x = map(int, input().split()) vol = a**2 * b ans = 0 if vol/2 < x: print(""水多し、台形になる"") h0 = x/(a**2) c = 2*h0 - b ans = math.degrees(math.atan((b-c)/a)) else: print(""水少ない、三角形になる"") d = (2*x)/(b*a) ans = math.degrees(math.atan(b/d)) print(ans) " p02924,s942595747,Accepted,"N = int(input()) print(N*(N-1)//2)" p03759,s995583177,Wrong Answer,"a,b,c = map(int,input().split()) if b-a == c-b: print('Yes') else: print('No') " p03345,s679046429,Accepted,"a,b,c,k = map(int,input().split()) ''' if k%2==0: num = (2**k+2)/3 tak = num*a+(num-1)*b+(num-1)*c nak = (num-1)*a+num*b+(num-1)*c else: num = (2**k+1)/3 tak = (num-1)*a+num*b+num*c nak = num*a+(num-1)*b+num*c ''' if k%2==0: ans=a-b else: ans=b-a if abs(ans)>10**18: print('Unfair') else: print(ans) " p03699,s234609070,Wrong Answer,"N = int(input()) a = [int(input()) for i in range(N)] ans = sum(a) done = True if not ans % 10 == 0: print(ans) else: a.sort() for i in range(N): ans -= a[i] if not ans % 10 == 0: print(ans) break else: print(""0"") " p03380,s146770038,Accepted,"n = int(input()) aa = list(sorted(map(int, input().split()))) x = max(aa) y = aa[0] for i in range(1, n - 1): if abs(x / 2 - y) > abs(x / 2 - aa[i]): y = aa[i] print(""{} {}"".format(x, y)) " p02555,s135007136,Accepted,"s=int(input()) ans=0 mod=10**9+7 from operator import mul from functools import reduce def combinations_count(n, r): r = min(r, n - r) numer = reduce(mul, range(n, n - r, -1), 1) denom = reduce(mul, range(1, r + 1), 1) return numer // denom for i in range(1,s//3+1): ans+=(combinations_count(s-3*i+i-1,s-3*i))%mod print(ans%mod)" p02935,s028355437,Accepted,"n = int(input()) v = list(map(int, input().split())) v.sort() s = 0 temp = v[0] for i in range(n - 1): s = (temp + v[i + 1]) / 2 temp = s print(s) " p03107,s632278515,Wrong Answer,"import sys input=sys.stdin.readline from collections import deque d=deque(list(input().rstrip())) d.append(""2"") ans=0 r=0 while r=B: print(""delicious"") elif A=B: print(""safe"") else: print(""dangerous"")" p03038,s231632771,Accepted,"N, M = map(int,input().split()) A = list(map(int,input().split())) D = dict() for a in A: if a in D: D[a] += 1 else: D[a] = 1 for _ in range(M): B, C = map(int,input().split()) if C in D: D[C] += B else: D[C] = B D = sorted(D.items(), reverse = True) ans, cnt = 0, 0 for d in D: x = min(d[1], N-cnt) cnt += x ans += d[0] * x if cnt == N: break print(ans) " p02631,s684369907,Wrong Answer,"import numpy as np N = int(input()) a = np.fromstring(input(), sep="" "", dtype=np.int64) b = np.bitwise_xor.reduce(a) c = np.bitwise_xor(a, 0) print(*c, sep="" "") " p03386,s125236061,Wrong Answer,"a, b, k = map(int, input().split()) ans = [] pool = [i for i in range(a, b+1)] ans += pool[:k] + pool[-k:] ans = list(set(ans)) [print(i) for i in ans] " p02789,s140281930,Wrong Answer,"a,b=(int(x) for x in input().split()) if a>b: print(str(b)*a) else: print(str(a)*b)" p02582,s725383525,Accepted,"S = input() count = 0 if S == 'RSR': print(1) else: for i in S: if i == 'R': count+=1 print(count)" p02608,s525904874,Wrong Answer,"n=int(input()) for i in range(n+1): ans=0 for x in range(i): for y in range(i): for z in range(i): if i==x*x+y*y+z*z+x*y+x*z+y*z: ans+=1 print(ans) " p02900,s035366691,Accepted,"def gcd(x,y): ans=0 if x < y : x,y=y,x if y==0: return x else: return gcd(y,x%y) def prime_decomposition(x): i = 2 table = [] while i * i <= x: while x % i == 0: x //= i table.append(i) i += 1 if x > 1: table.append(x) return table a,b=map(int,input().split()) m=gcd(a,b) ans=len(list(set(prime_decomposition(m))))+1 print(ans)" p03745,s647857759,Accepted,"def main(): n = int(input()) A = list(map(int, input().split())) res = 1 inc = 0 dec = 0 for i in range(n - 1): if A[i] < A[i+1]: inc += 1 elif A[i] > A[i+1]: dec += 1 if inc and dec: res += 1 inc, dec = 0, 0 print(res) if __name__ == '__main__': main()" p04031,s308413422,Accepted,"n=int(input()) a=list(map(int,input().split())) ans=float('inf') num=-100 while num!=101: kari=0 for i in range(n): kari+=(num-a[i])**2 num+=1 ans=min(ans,kari) print(ans)" p02706,s466720270,Wrong Answer,"s = input().split("" "") N = int(s[0]) M = s[1] s = input().split("" "") A = [] sum = 0 for w in s: A.append(int(w)) sum += int(w) if sum >= N: print(N - sum) else: print(-1)" p02744,s866380027,Wrong Answer,"n=int(input()) s='' t=ord('a') #print(t) for i in range(n): s+=chr(t+i) print(s)" p03211,s004477888,Accepted,"s = input() ans = 99999 for i in range(len(s) - 2): ans = min(ans, abs(753 - int(s[i:i + 3]))) print(ans) " p02854,s388144703,Wrong Answer,"n=int(input()) a=list(map(int,input().split())) harf=sum(a)//2 l,r,i=0,a[0],0 while r= (k - 1) or a%k > b%k: print('OK') else: print('NG')" p02924,s065926075,Wrong Answer,"#!/usr/bin/env python # -*- coding: utf-8 -*- def solve(inp): N = int(inp.readline().strip()) r = (N * (N - 1)) / 2 return int(r) def main(): import sys result = solve(sys.stdin) if result: print(result) if __name__ == '__main__': main() " p03611,s501990537,Accepted,"from collections import defaultdict N=int(input()) a=list(map(int,input().split())) count=defaultdict(int) for i in range(N): n = a[i] count[n-1] += 1 count[n] += 1 count[n+1] += 1 print(sorted(count.values())[-1])" p02881,s014766900,Accepted,"import math n = int(input()) List = [] n_sqrt = int(math.sqrt(n)) for i in range(1,n_sqrt+1): if n % i == 0: number = i + (n // i) -2 List.append(number) print(min(List))" p03679,s677640597,Accepted,"x, a, b = map(int, input().split()) if a>=b: print(""delicious"") else: if b-a>x: print(""dangerous"") else: print(""safe"") " p03605,s542068581,Wrong Answer,"# -*- coding: utf-8 -*- a = int(input()) flg = 0 while a > 0: if a % 10 == 9: print(""Yes"") flg = 1 break else: a = a / 10 if flg == 0: print(""No"")" p03657,s518642432,Wrong Answer,"a,b=map(int,input().split()) print('Possible' if a==3 or b==3 or ((a+b)%3)==0 else 'Impossible')" p02603,s141623996,Accepted,"n = int(input()) A = list(map(int, input().split())) x = 1000 for i in range(n-1): if A[i] < A[i+1]: q, x = divmod(x, A[i]) x += q*A[i+1] print(x)" p03835,s088490388,Accepted,"k,s=map(int,input().split()) print(len([1 for z in range(k+1) for y in range(k+1) if 0<=s-y-z<=k])) " p03000,s278621856,Accepted,"n,x=map(int,input().split()) L=list(map(int,input().split())) cnt=0 ans=1 for l in L: cnt+=l if cnt>x: break ans+=1 print(ans)" p02866,s738913704,Accepted,"N = int(input()) D = list(map(int, input().split())) M = max(D) cnt = [0 for i in range(M + 1)] for d in D: cnt[d] += 1 if D[0] != 0: print(0) exit() if cnt[0] != 1 or 0 in cnt: print(0) exit() res = 1 MOD = 998244353 for i in range(2, M + 1): res *= cnt[i - 1] ** cnt[i] res %= MOD print(res) " p03720,s590847281,Accepted,"n, m = map(int, input().split()) ab = [list(map(int, input().split())) for i in range(m)] from collections import defaultdict d = defaultdict(int) for i in range(m): d[ab[i][0]] += 1 d[ab[i][1]] += 1 for i in range(1, n + 1): print(d[i])" p03943,s060875300,Wrong Answer,"a, b, c = map(int, input().split()) if a + b == c or a + c ==b or b + c == a: print(""YES"") else: print(""NO"")" p03408,s228500894,Wrong Answer,"def main(): from collections import Counter n = int(input()) s = [input() for _ in range(n)] cs = Counter(s) m = int(input()) t = [input() for _ in range(m)] print(max(0,cs.most_common()[0][1] - t.count(cs.most_common()[0][0]))) if __name__ == '__main__': main() " p02747,s672077703,Accepted,"a=input() if a==""hi""*(len(a)//2): print(""Yes"") else: print(""No"")" p03673,s059737472,Wrong Answer,"n=int(input()) a=list(map(int,input().split())) b=[a[0]] if n%2:#n%2==1 for i in range(1,n): if i%2==1: b.append(a[i]) else: b.append(a[i]) else: for i in range(1,n): if i%2==0: b.append(a[i]) else: b.append(a[i]) """""" for i in range(n): b.append(a[i]) b.reverse() """""" for i in range(n): print(b[i],end="" "")" p02923,s759282924,Accepted,"N = int(input()) hhh = list(map(int, input().split())) m = 0 ans = 0 for i in range(N - 1): if hhh[i] >= hhh[i + 1]: m += 1 ans = max(ans, m) else: m = 0 print(ans) " p02753,s823791541,Accepted,"S = input() if S == ""AAA"": print(""No"") else: if S == ""BBB"": print (""No"") else: print(""Yes"")" p03645,s208082094,Accepted,"n, m = map(int, input().split()) f = {} s = {} for i in range(m): a, b = map(int, input().split()) if a == 1: f[b] = 1 if b in s: print(""POSSIBLE"") exit() if b == n: s[a] = 1 if a in f: print(""POSSIBLE"") exit() print(""IMPOSSIBLE"")" p03161,s319840550,Accepted,"n, k = [int(x) for x in input().split()] seq = [int(x) for x in input().split()] dp = [0]*n k = min(k, n) for i in range(1, k): dp[i] = abs(seq[i] - seq[0]) # print(dp) for i in range(k, n): a = dp[i-1] + abs(seq[i] - seq[i-1]) for j in range(k-1): a = min(a, dp[i-2-j] + abs(seq[i] - seq[i-2-j])) dp[i] = a # print(dp) print(dp[-1])" p03592,s852540485,Accepted,"n, m, k = map(int, input().split()) for i in range(n + 1): for j in range(m + 1): if i * (m - j) + j * (n - i) == k: print(""Yes"") exit() print(""No"") " p02753,s394013548,Accepted,"import sys n=input() j=0 if(n[0]==n[1]==n[2]): print('No') else: print('Yes')" p03815,s777718897,Accepted,"x = int(input()) print((x // 11) * 2 + (0 if x % 11 == 0 else 1 if x % 11 <= 6 else 2))" p02633,s422485328,Accepted,"def gcd(a,b): a,b = max(a,b),min(a,b) while b: a,b =b,a%b return a X=int(input()) if 360%X==0: print(360//X) else: g =gcd(360,X) print(360//g) " p03944,s530193370,Accepted,"w,h,n = map(int,input().split()) W = ["".""] * w H = ["".""] * h for _ in range(n): x,y,a = map(int,input().split()) if a==1: tmp = [""#""]*x + W[x:] W = tmp elif a==2: tmp = W[:x] + [""#""] W = tmp elif a==3: tmp = [""#""]*y + H[y:] H = tmp elif a==4: tmp = H[:y] + [""#""] H = tmp print(W.count('.')*H.count('.')) " p03951,s347236583,Wrong Answer,"n = int(input()) s = input() t = input() cnt = 0 for i in range(n): if s[i:] == t[:n-i]: cnt += i print(n + cnt)" p03472,s666114806,Accepted,"import math 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_max = sorted(a)[-1] b_des = sorted(b, reverse=True) res = 0 sum_b = 0 for bi in b_des: if bi <= a_max: break else: H -= bi res += 1 if H <= 0: break if H > 0: res += int(math.ceil(H / a_max)) print(res)" p03162,s286169763,Accepted,"N = int(input()) act = [] for i in range(N): a,b,c = map(int,input().split()) act.append([a,b,c]) INF = 10**10 dp = [] for i in range(N): dp.append([0,0,0]) dp[0] = act[0] for i in range(1,N): dp[i][0] = max(dp[i-1][1] + act[i][0],dp[i-1][2] + act[i][0]) dp[i][1] = max(dp[i-1][0] + act[i][1],dp[i-1][2] + act[i][1]) dp[i][2] = max(dp[i-1][0] + act[i][2],dp[i-1][1] + act[i][2]) print(max(dp[N-1]))" p02681,s091213681,Accepted,"s = str(input()) t = str(input()) a = 0 for i in range(0,len(s)): if s[i] != t[i]: a = 1 break if a == 0: print('Yes') else: print('No') " p03681,s455810431,Accepted,"from math import factorial N,M=map(int,input().split()) if abs(N-M)>1: print(0) else: if N==M: mod=10**9+7 n=factorial(N)%mod m=factorial(M)%mod print(n*m*2%mod) else: mod=10**9+7 n=factorial(N)%mod m=factorial(M)%mod print(n*m%mod)" p03696,s539079522,Accepted,"N = int(input()) S = str(input()) l = 0 r = 0 for i in range(N): if S[i] == ""("": r += 1 elif S[i] == "")"": if r >= 1: r -= 1 else: l += 1 print(""("" * l + S + "")"" * r) " p02922,s208577583,Accepted,"a, b = map(int, input().split()) c = 1 d = 0 while c < b: c += a - 1 d += 1 print(d)" p02693,s465538688,Accepted,"k = int(input()) a,b = map(int,input().split()) count=0 c=b-a ans=0 for i in range(a,b+1): if i%k==0: ans=1 break if 0 a and d > b: ans = (c-a)*(d-b) else: ans = 0 print(ans)" p02797,s380506010,Accepted,"n,k,s=map(int,input().split()) x=10**9 if s==x:x=1 a=[s]*k+[x]*(n-k) print(*a)" p02598,s705025226,Accepted,"n,k = map(int,input().split()) A = list(map(int,input().split())) left = 0 right = max(A) #if accumulate[(ai-1)//k]<=k return True? def is_ok(x): cnt = 0 for i in range(n): cnt += (A[i]-1)//x return cnt<=k #binary search while (right-left)>1: mid = (left+right)//2 if is_ok(mid): right = mid else: left = mid print(right)" p03059,s673372319,Wrong Answer,"a,b,t = map(int,input().split()) for i in range(1,20): if a*i*(i+1)/2 >=t+0.5: if i==1: print(0) break else: print(b*i) break " p02608,s050432332,Wrong Answer,"N = int(input()) N_list = [0]*(N+1) for i in range(1,11): for j in range(1,11): for k in range(1,11): if(i**2+j**2+k**2+i*j+j*k+k*i<=N): N_list[i**2+j**2+k**2+i*j+j*k+k*i]+=1 for i in N_list: print(i)" p02555,s223155385,Accepted,"S = int(input()) f = 10**9 + 7 dp = [0]*(S+1) dp[0] = 1 for i in range(1,S+1): if i==1 or i==2: dp[i] = 0 else: for j in range(0,i-2): dp[i] += dp[j] dp[i] %= f print(dp[-1]%f)" p03289,s409777144,Wrong Answer,"s = input() n = len(s) ans = 1 if s[0] != ""A"": ans *= 0 check = 0 for i in range(1, n): if s[i] == ""C"" and check == 0: check = 1 elif s[i] == ""C"": check = 0 else: if 97 <= ord(s[i]) <= 122: ans *= 1 else: ans *= 0 if s[-1] == ""C"" or s[1] == ""C"": ans *= 0 print([""WA"", ""AC""][ans * check]) " p02973,s531257005,Accepted,"import bisect n=int(input()) a=[int(input()) for _ in range(n)][::-1] dp=[] for i in a: if bisect.bisect_right(dp,i)==len(dp): dp.append(i) else: dp[bisect.bisect_right(dp,i)]=i print(len(dp))" p02683,s611835218,Accepted," import numpy as np def inpl(): return list(map(int, input().split())) N, M, X = inpl() costs = [] aa = [] for _ in range(N): ca = inpl() costs.append(ca[0]) aa.append(ca[1:]) aa = np.array(aa) costs = np.array(costs) ans = 10**10 for bit in range(1 << N): flags = [(bit >> i) & 1 == 1 for i in range(N)] rikai = aa[flags].sum(axis=0) if (rikai >= X).sum() == M: ans = min(ans, costs[flags].sum()) if ans == 10 ** 10: print(-1) else: print(ans) " p02818,s600655309,Accepted,"a, b, k = map(int, input().split()) if k <= a: print('{} {}'.format(a-k, b)) else: k -= a print('{} {}'.format(0, max(b-k, 0)))" p03760,s097462499,Accepted,"a = list(input()) b = list(input()) for i in range(len(a)-1): print(a[i]+b[i],end="""") if len(a) != len(b): print(a[-1]) else: print(a[-1]+b[-1])" p03252,s542967018,Accepted,"S = input() T = input() dcts = {} dctt = {} jdg = True for i, s in enumerate(S): if s in dcts.keys(): if dcts[s]!=T[i]: jdg = False break else: dcts[s] = T[i] if T[i] in dctt.keys(): if dctt[T[i]]!=s: jdg = False break else: dctt[T[i]] = s print('Yes' if jdg else 'No')" p03971,s951216749,Accepted,"N, A, B = map(int, input().split()) S = input() cnt1, cnt2 = 0, 1 for Si in S: if Si=='a' and cnt1=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)" p02658,s315646512,Accepted,"n = int(input()) a = list(map(int,input().split())) if 0 in a: print (0) exit(0) p = 1 for i in range(n): p *= a[i] if p>10**18: break if p>10**18: p = -1 print (p) " p02835,s900898759,Accepted,"A1A2A3=input() A1, A2, A3 = A1A2A3.split() A1 = int(A1) A2 = int(A2) A3 = int(A3) if A1+A2+A3>=22: print('bust') else: print('win')" p02982,s764821542,Wrong Answer,"#ABC133 B import math N,D = map(int,input().split()) point = [] count = 0 for i in range(N): X = list(map(int,input().split())) point.append(X) for i in range(1,N): for j in range(i+1,N+1): for k in range(D): S = 0 square = [] square.append(((point[i-1][k])-(point[j-1][k]))**2) S += math.sqrt(sum(square)) if S % 1 ==0: count += 1 print(count)" p03076,s688647374,Wrong Answer,"short = 10 ans = 0 for i in range(5): n = int(input()) if short > n%10 and n%10 > 0: short = n%10 ans += (n//10)*10 if n%10 > 0: ans += 10 print(short,ans) ans -= 10 if short > 0 else 0 print(ans+short) " p02747,s742408425,Wrong Answer,"text = input() answer = ""No"" #print(text) if ""hi"" in text: if ""ii"" in text: answer = ""No"" elif ""hh"" in text: answer = ""No"" else: answer = ""Yes"" print(answer)" p02786,s338538729,Accepted,"import sys def main(): h = int(sys.stdin.readline().strip()) def solve(point): if point == 1: return 1 return 1 + 2 * solve(point // 2) print(solve(h)) if __name__ == '__main__': main() " p03817,s012978334,Wrong Answer,"x = int(input()) n = x//11 n = 2*n m = x%11 if m<=6: n += 1 else: n += 2 print(n)" p03012,s416052506,Accepted,"def LI(): return [int(s) for s in input().split()] N = int(input()) W = LI() S1 = W[0] S2 = sum(W[1:]) min_sum = abs(S1-S2) for i in range(1,N): S1+=W[i] S2-=W[i] if min_sum > abs(S1-S2): min_sum = abs(S1-S2) print(min_sum) " p02784,s761492740,Accepted,"h, n = map(int, input().split()) move = list(map(int, input().split())) print(""Yes"" if sum(move) >= h else ""No"")" p03327,s623666624,Accepted,"# coding: utf-8 N = int(input()) # print(N) if N >= 1000: print('ABD') else: print('ABC')" p03146,s258014552,Wrong Answer,"s = int(input()) def function(n): if n % 2 == 0: return int(n/2) else: return int(n*3+1) i = 0 count = 0 a = [] a.append(s) while count < 2: a.append(function(a[i])) if a[i+1] == 4: count += 1 i += 1 print(i+1)" p03062,s055800707,Accepted,"import math import numpy as np from fractions import gcd import fractions import statistics import collections from functools import reduce import itertools from collections import defaultdict N = int(input()) A = list(map(int, input().split())) cnt = 0 cnt0 = 0 for i in range(N): if (A[i] == 0): cnt0 +=1 if (A[i] < 0): cnt +=1 if (cnt%2 == 0 or cnt0>=1): print(sum(np.abs(np.array(A)))) else: print(sum(np.abs(np.array(A)))-min(np.abs(np.array(A)))*2)" p03730,s303381799,Accepted,"a, b, c = map(int, input().split()) ans = ""NO"" for num in range(1, 5051): if num % a == 0: if num % b == c: ans = ""YES"" break print(ans)" p02583,s027545088,Accepted,"n = int(input()) L = [int(x) for x in input().split()] L.sort() 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]: if L[i] + L[j] > L[k]: ans += 1 print(ans) " p02631,s739707996,Accepted,"n = int(input()) a =[int(x) for x in input().split()] s = 0 for i in range(n): s = s ^ a[i] for i in range(n): x = s ^ a[i] print(x, end='') if i == n - 1: print('') else: print(' ', end='')" p02697,s237909846,Wrong Answer,"n,m = list(map(int,input().split())) x = n//2 gap = 1 for i in range(1,m+1): print(x,x+gap) gap += 2" p02946,s028226149,Accepted,"K,X=map(int,input().split()) if K==1:print(X) else:print(*list(range(X-K+1,X+K)))" p03998,s909840254,Accepted,"S={char:list(input()) for char in ""abc""} turn=""a"" while S[turn]: turn=S[turn].pop(0) print(turn.upper())" p02994,s524305310,Wrong Answer,"N,L=map(int,input().split()) a = [] for i in range(N): a.append(L+i) ans=10*6 s = sum(a) for j in range(N): t = s - a[j] if abs(t-s) < abs(ans -s): ans = t print(t)" p03145,s085248367,Accepted,"a,b,c=[int(i) for i in input().split()] print((a*b)//2)" p03854,s711147479,Accepted,"def main(): s = input() st = [s] while st: x = st.pop() if x == '': print('YES') return for w in ('dream', 'dreamer', 'erase', 'eraser'): if x.endswith(w): st.append(x[:-len(w)]) print('NO') if __name__ == '__main__': main() " p02633,s946161977,Accepted,"# coding: utf-8 def solve(*args: str) -> str: x = int(args[0]) k = 1 y = x while y % 360 != 0: y = y+x k += 1 return str(k) if __name__ == ""__main__"": print(solve(*(open(0).read().splitlines()))) " p03109,s173489744,Accepted,"import sys IS = lambda: sys.stdin.readline().rstrip() II = lambda: int(IS) MII = lambda: list(map(int, IS.split())) def main(): s = IS() d = '2019/04/30' if s <= d: print('Heisei') else: print('TBD') if __name__ == '__main__': main() " p02618,s750894873,Wrong Answer,"D = int(input()) c = list(map(int,input().split())) last_di = [0] * 26 for d in range(D): s = list(map(int,input().split())) s_max = s.index(max(s)) print(s_max)" p03427,s474278211,Wrong Answer,"import bisect N = int(input()) if len(str(N)) == 1: print(N) exit() L = len(list(str(N)))-1 A = [10**(L)*i+10**(L)-1 for i in range(10)] n = bisect.bisect_left(A,N)-1 if N in A: n += 1 ans = [int(list(str(A[n]))[i]) for i in range(len(list(str(A[n]))))] print(sum(ans)) print(A)" p02959,s119694625,Accepted,"n=int(input()) a=list(map(int,input().split())) b=list(map(int,input().split())) c=0 for i in range(n): if a[i] N*2: break ans = sorted(mylist, reverse=True)[:N] print(sum(ans)) # In[ ]: " p02702,s919962313,Accepted,"s = input()[::-1] sum_of_digits = 0 cnts = [0] * 2019 cnts[0] = 1 d = 1 for c in s: sum_of_digits += int(c) * d sum_of_digits %= 2019 d *= 10 d %= 2019 cnts[sum_of_digits] += 1 ans = 0 for cnt in cnts: ans += cnt * (cnt - 1) // 2 print(ans) " p04011,s943875938,Wrong Answer,"n = int(input()) k = int(input()) x = int(input()) y = int(input()) if n - k <0: print(int(n * x)) else: print(int((k * y) + (n - k) * y))" p02880,s047817684,Accepted,"num = int(input()) data = list() for i in range(1,10): for j in range(1, 10): data.append(i*j) if num in data: print('Yes') else: print('No')" p03105,s824946816,Accepted,"A, B, C = map(int, input().split()) print(min(C, B//A))" p03659,s488597547,Wrong Answer,"N=int(input()) A=list(map(int, input().split())) arai=sum(A) ans=10**19 sunuke=0 for a in A: sunuke+=a arai-=a if ans>abs(arai-sunuke): ans=abs(arai-sunuke) print(ans) " p02787,s288184982,Accepted,"H, N = map(int, input().split()) AB = [list(map(int, input().split())) for i in range(N)] dp = [2e9] * (H+1) dp[0] = 0 for i in range(N): for h in range(H+AB[i][0]): if h - AB[i][0] < 0: continue else: dp[min(h, H)] = min(dp[min(h, H)], dp[h-AB[i][0]] + AB[i][1]) print(dp[H])" p02982,s228953960,Accepted,"import numpy as np N, D = map(int, input().split()) X = [list(map(int, input().split())) for _ in range(N)] X = np.array(X) cnt = 0 for i in range(N): for j in range(i+1, N): tmp = ((abs(X[i] - X[j]))**2).sum() tmp = np.sqrt(tmp) if tmp.is_integer(): cnt += 1 print(cnt)" p03797,s055596788,Accepted,"n,m=map(int,input().split()) if 2*n>=m: print(m//2) else: print(n+(m-2*n)//4) " p03645,s555121678,Wrong Answer,"#AtCoder from collections import defaultdict N, M = map(int, input().split()) a = [list(map(int, input().split())) for i in range(M)] d = defaultdict(list) for e in a: d[e[0]].append(e[1]) sec = [] for key in d.items(): if key[0] == 1: sec.append(key[1]) for key in d.items(): if key[0] in sec[0]: if key[1][0] == N: print('POSSIBLE') exit() print('IMPOSSIBLE') " p02787,s290933770,Accepted,"# E - Crested Ibis vs Monster def main(): INF = 1 << 30 H, N, *AB = map(int, open(0).read().split()) dp = [INF] * (H + 10001) # dp[i] := min magic points to decrease monster's health by i dp[0] = 0 for i in range(H): for a, b in zip(*[iter(AB)] * 2): dp[i + a] = min(dp[i + a], dp[i] + b) print(min(dp[H:])) if __name__ == ""__main__"": main() " p02723,s744291349,Accepted,"s=input() if (s[2]==s[3] and s[4]==s[5]): print('Yes') else: print('No')" p02678,s466859810,Accepted,"from collections import deque N,M=map(int,input().split()) to=[[] for _ in range(N)] for _ in range(M): a,b=map(int,input().split()) to[a-1].append(b-1) to[b-1].append(a-1) q=deque([0]) r=[None]*N r[0]=0 while q: x=q.popleft() for i in to[x]: if r[i] is None: q.append(i) r[i]=x+1 print('Yes') for i in range(N): if r[i]!=0: print(r[i])" p03860,s548620409,Wrong Answer,"s = input() print(""A""+s[0]+""C"")" p02796,s641483700,Wrong Answer,"N = int(input()) MAX_list = [] ans = 0 A = -10**9-2 for _ in range(N): X, L = map(int, input().split()) MAX_list.append(((X + L - 1), (X - L + 1))) MAX_list = sorted(MAX_list) for m, l in MAX_list: if l > A: ans += 1 A = m print(ans) " p02900,s566645237,Wrong Answer,"from fractions import gcd a,b=map(int,input().split()) gcd=gcd(a,b) ab_gcd=gcd f=[] for i in range(2,int(ab_gcd**0.5)+2): while gcd%i==0: gcd=gcd//i f.append(i) print(len(set(f))+1)" p03289,s943510934,Accepted,"s = list(input()) ans = 'AC' if s[0] != 'A': ans = 'WA' if s[2:-1].count('C') != 1: ans = 'WA' cnt = 0 for i in s: if 'A' <= i <= 'Z': cnt += 1 if cnt != 2: ans = 'WA' print(ans)" p02755,s310471700,Wrong Answer,"#!/usr/bin/env python3 import sys import collections as cl import math 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(): A,B = MI() for i in range(101): if math.floor( i * 0.08 ) == A and math.floor(i * 0.1) == B: print(i) exit() print(-1) main() " p03136,s377914410,Accepted,"N = int(input()) L = list(map(int, input().split())) M = max(L) ind = L.index(M) del L[ind] s = sum(L) if M < s: print('Yes') else: print('No')" p02718,s705110596,Accepted,"N,M=map(int,input().split()) A=list(map(int,input().split())) x=sum(A)/(4*M) A.sort(reverse=True) for a in A[:M]: if a= max(a, c) else 0)" p02627,s731858869,Accepted,"x = input() if x.isupper(): print('A') else: print('a') " p02832,s319778836,Accepted,"n = int(input()) a = [int(x) for x in input().split()] if 1 not in a: print(-1) else: ans, num = 0, 0 for i in range(n): if a[i] == num + 1: num += 1 else: ans += 1 print(ans) " p02768,s938507551,Accepted,"n,a,b=map(int,input().split()) mod=int(1e9+7) def nCr(a,b): global mod res = 1 for i in range(1,b+1): res = res * (n-i+1) % mod * pow(i,mod-2,mod) % mod return res%mod print((pow(2,n,mod) - 1 - nCr(n,a) - nCr(n,b) + 2*mod ) % mod)" p02848,s583501087,Wrong Answer,"n = int(input()) s = input() t = """" for i in s: a = ord(i) + n if a > ord(""Z""): a = a - 26 t += chr(a)" p03103,s882803050,Accepted,"n,m = map( int,input().split() ) a = [ list(map(int,input().split())) for _ in range(n)] a.sort() c = 0 for i in range(n): x = min(m,a[i][1]) c += x * a[i][0] m -= x if m == 0 : break print(c)" p03327,s235955248,Wrong Answer,"n = int(input()) l9 = [9**i for i in range(0,6)] l6 = [6**i for i in range(0,6)] l = sorted(l9+l6,reverse=True) i = 0 ans = 0 while(n>0): if n - l[i] < 0: i += 1 n = n else: ans+=1 #print(n,""-"",l[i],""="",n-l[i],""ans="",ans) n = n - l[i] print(ans)" p04031,s310350979,Accepted,"# coding: utf-8 N = int(input()) A = list(map(int, input().split())) A.sort() ans = float(""inf"") for i in range(A[0], A[-1]+1): med = i tmp = 0 for j in range(N): tmp += (A[j] - med)**2 ans = min(ans, tmp) print(ans)" p03001,s376003372,Accepted,"w,h,x,y=map(int,input().split()) print(w*h/2,int(x==w/2 and y==h/2))" p03449,s420559328,Accepted,"import numpy as np N = int(input()) A1 = list(map(int, input().split())) A2 = list(map(int, input().split())) A1_sum = [np.sum(A1[:N-i]) for i in range(N)] A2_sum = [np.sum(A2[N-1-i:]) for i in range(N)] A_sum = [A1_sum[i]+A2_sum[i] for i in range(N)] print(np.max(A_sum))" p03077,s126696390,Accepted,"import math N = int(input()) X = [int(input()) for i in range(5)] mc = min(X) mci = X.index(mc) print(4 + math.ceil(N/mc))" p04011,s096684818,Accepted,"N = int(input()) K = int(input()) X = int(input()) Y = int(input()) if N >= K: price = (K * X) + ((N - K) * Y) else: price = N * X print(price) " p02708,s750971948,Wrong Answer,"import itertools x =(input()).split("" "") N = int(x[0])+1 K = int(x[1]) l = [] p =0 for i in range(N): l.append(p) p+=1 p = 0 while K<=N: c_list = list(itertools.combinations(l, K)) K+=1 p+=len(c_list) print(p)" p02727,s169289851,Accepted,"import sys input = lambda: sys.stdin.readline().rstrip() input_nums = lambda: list(map(int, input().split())) def main(): X, Y, A, B, C = input_nums() P = input_nums() Q = input_nums() R = input_nums() P.sort(reverse=True) Q.sort(reverse=True) R.sort() P = sorted(P[:X]) Q = sorted(Q[:Y]) res = [] res = P + Q + R res.sort(reverse=True) print(sum(res[:X+Y])) if __name__ == '__main__': main()" p02596,s849996655,Accepted,"K = int(input()) x = 7 % K for i in range(K): if x == 0: print(i + 1) break x = x * 10 + 7 x = x % K else: print(-1) " p02646,s498065925,Accepted,"a,v = map(int, input().split()) b,w = map(int, input().split()) t = int(input()) if (v - w) * t - abs(b - a) >= 0: print(""YES"") else: print(""NO"")" p02765,s295624966,Accepted,"n,r=map(int,input().split()) ans = r if n<10: ans = r+100*(10-n) print(ans)" p03617,s897132417,Wrong Answer,"Q,H,S,D=map(int,input().split()) N=int(input()) dict={} dict['Q']=Q*8 dict['H']=H*4 dict['S']=S*2 dict['D']=D #print(dict) dict2=sorted(dict.items(),key=lambda x:x[1]) #print(dict2) dict3={} dict3['Q']=0.25 dict3['H']=0.5 dict3['S']=1 dict3['D']=2 dict4={} dict4['Q']=Q dict4['H']=H dict4['S']=S dict4['D']=D ans=0 for i in range(4): A=N//dict3[dict2[i][0]] ans+=A*dict4[dict2[i][0]] N-=A*dict3[dict2[i][0]] if N<0: break print(int(ans))" p03719,s107609611,Accepted,"a, b, c = map(int,input().split()) print(""Yes"") if a <= c <= b else print(""No"")" p03069,s880992720,Accepted,"N = int(input()) S = input() B = [0 for _ in range(N+1)] W = [0 for _ in range(N+1)] for i in range(N): B[i+1] = B[i] + (S[i] == '#') for i in range(N, 0, -1): W[i-1] = W[i] + (S[i-1] == '.') print(min(B[i]+W[i] for i in range(N+1)))" p02754,s570022027,Accepted,"N, A, B = map(int, input().split()) ans = N // (A + B) * A rem = N % (A + B) ans += min(rem, A) print(ans)" p04012,s267686063,Accepted,"from collections import Counter W = str(input()) ans = ""Yes"" CW = Counter(W) for k,v in CW.items(): if v%2 != 0: ans = ""No"" break print(ans)" p02820,s416704946,Accepted,""""""" References ---------- https://atcoder.jp/contests/abc149/submissions/9219652 """""" def solve(n, k, r, s, p, t): score = 0 mapping = {""r"": p, ""s"": r, ""p"": s} t = list(t) for i in range(k): score += mapping[t[i]] for i in range(k, n): if t[i] == t[i-k]: t[i] = ""x"" else: score += mapping[t[i]] return score n, k = map(int, input().split()) r, s, p = map(int, input().split()) t = input() print(solve(n, k, r, s, p, t))" p03241,s606693906,Wrong Answer,"n,m=map(int,input().split()) m_root=int(m**0.5) ans=0 if m%n==0: ans=m//n for i in range(1,m_root +1): if m%i == 0 and m/i >= n: ans = max(ans, i) print(ans)" p02771,s534778380,Accepted,"l = list(map(int, input().split())) print('Yes') if len(set(l))==2 else print('No') " p03434,s646339152,Accepted,"n=int(input()) l=sorted(map(int,input().split()))[::-1] print(sum(l[::2])-sum(l[1::2])) " p03778,s183274475,Accepted,"W, a, b = map(int, input().split()) d = min(abs(b - (a+W)), abs(b+W-a)) if a <= b <= a+W or a <= b+W <= a+W: print(0) else: print(d)" p02725,s482392227,Accepted,"K, N = map(int, input().split()) A_list = list(map(int, input().split())) max1 = -1 for i in range(N): if i!=N-1: dis = abs(A_list[i]-A_list[i+1]) else: if A_list[0]!=0: dis = abs(K-A_list[-1])+A_list[0] else: dis = abs(K-A_list[-1]) if dis > max1: max1 = dis print(K-max1) " p02953,s718750943,Accepted,"N = int(input()) hhh = list(map(int, input().split())) for i in range(N - 2, -1, -1): if hhh[i] <= hhh[i + 1]: pass elif hhh[i] - hhh[i + 1] == 1: hhh[i] -= 1 else: print('No') exit() print('Yes') " p02879,s229579834,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 if __name__ == '__main__': b, c = map(int, input().split()) if b <10 and c <10: print(b*c) else: print(-1)" p02640,s215165545,Accepted,"X, Y = map(int, input().split()) for a in range(X+1): if 2*a + 4*(X-a) == Y: print(""Yes"") exit() print(""No"")" p02755,s049657070,Accepted,"def main(a,b): a1 = a / 0.08 a2 = (a+1) / 0.08 b1 = b / 0.1 b2 = (b+1) / 0.1 x = max(a1,b1) y = min(a2,b2) if (y <= x): return -1 else: if(x//1 == x): return x elif(y > (x//1)+1): return x+1 return -1 a,b = list(map(int,input().split())) print(int(main(a,b)))" p03243,s351584335,Accepted,"n=int(input()) a=[111,222,333,444,555,666,777,888,999] p=0 while a[p] 1: x = (l + r)//2 now = 0 for a in AList: now += (a-1)//x f = lambda now : True if now <= K else False if f(now): r = x else: l = x print(r)" p02982,s875384050,Wrong Answer,"N, D = map(int, input().split()) X = [list(map(int, input().split())) for i in range(N)] sq = set() for i in range(1, 40): sq.add(i**2) def foo(x,y): t = 0 for i, j in zip(X[x], X[y]): t += (i - j) * (i - j) if t in sq: return 1 else: return 0 ans = 0 for i in range(N): for j in range(i+1, N): ans += foo(i, j) print(ans)" p02697,s124900751,Accepted,"N, M = (int(_) for _ in input().split()) if N % 2 == 0: s = (N - 1) // 4 + 1 ret = [] for i in range(1, s): ret.append((i, N - i)) for i in range(s, N // 2): ret.append((i, N - i - 1)) else: ret = [] for i in range(1, (N // 2) + 1): ret.append((i, N - i)) for r0, r1 in ret[:M]: print(r0, r1) " p02917,s144370170,Accepted,"n = int(input()) b = list(map(int,input().split())) ans = b[0] + b[-1] for i in range(n-2): ans+=min(b[i],b[i+1]) print(ans)" p03721,s339735448,Accepted,"n , k = map(int, input().split()) x=[] j=0 c=0 for i in range(n): a , b = map(int, input().split()) x.append([a,b]) x.sort(key = lambda x :x[0]) while True: c+=x[j][1] if c>=k: print(x[j][0]) break j+=1 " p03103,s477084132,Accepted,"N, M = map(int, input().split()) C = [] for _ in range(N): A, B = map(int, input().split()) C.append((A,B)) C.sort() cnt = 0 res = 0 for i in range(N): if cnt+C[i][1]<=M: res += C[i][1]*C[i][0] cnt += C[i][1] else: break print((M-cnt)*C[i][0] + res)" p03543,s302659916,Wrong Answer,"N=(input()) if N[0]==N[1] and N[1]==N[2] or N[1]==N[2] and N[2]==[3]: print(""Yes"") else: print(""No"")" p02771,s649460241,Accepted,"A = list(map(int, input().split())) if len(set(A)) == 2: print(""Yes"") else: print(""No"")" p03478,s812992672,Accepted,"N, A, B = list(map(int, input().split())) def get_sum(n): ans = 0 while True: ans += n % 10 if n // 10 > 0: n = n // 10 else: break return ans total = 0 for i in range(1, N + 1): ans = get_sum(i) if A <= ans <= B: total += i print(total)" p02831,s841468928,Accepted,"from fractions import gcd n1, n2 = [int(i) for i in input().split()] n3 = (n1 * n2) //gcd(n1, n2) print(n3)" p02947,s957025426,Accepted,"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 from collections import Counter n = int(input()) list_N = [] ans = 0 for _ in range(n): s = sorted(input()) list_N.append("""".join(s)) list_M = list(Counter(list_N).values()) for i in list_M: if i != 1: ans += cmb(i, 2) print(ans)" p02548,s643843001,Accepted,"N=int(input()) l=N-1 a=0 for c in range(1,N): a+=(N-1)//c print(a)" p03852,s089578055,Accepted,"s = input() a = ['a', 'i', 'u', 'e', 'o'] for i in a: if s == i: print('vowel') exit() print('consonant')" p03206,s706689098,Accepted,"D = int(input()) ans = """" if D == 25: ans = ""Christmas"" elif D == 24: ans = ""Christmas Eve"" elif D == 23: ans = ""Christmas Eve Eve"" elif D == 22: ans = ""Christmas Eve Eve Eve"" print(ans)" p02631,s900677610,Wrong Answer,"n = int(input()) a = list(map(int,input().split())) x = [0 for _ in range(31)] for ai in a: i = 0 while ai > 0: if ai%2 == 1: x[i] += 1 ai = ai//2 i += 1 for i in range(17): x[i] = x[i]%2 for ai in a: s = 0 i = 0 while ai > 0: if ai%2 == 1: if x[i] == 0: s += 2**i else: if x[i] == 1: s += 2**i ai = ai//2 i += 1 print(s) " p03605,s663326821,Accepted,"print('Yes' if ""9"" in input() else 'No')" p03693,s327358038,Accepted,"a,b, c = map(int, input().split()) A = a*100 B = b*10 C = A + B + c if C % 4 == 0: print(""YES"") else: print(""NO"") " p02621,s112894845,Accepted,"a = int(input()) print(a + a**2 + a**3)" p02768,s692076578,Accepted,"n,a,b=map(int,input().split()) def modinv(a, mod=10**9+7): return pow(a, mod-2, mod) def mod_comb_count(n, r, mod): r = min(r, n-r) res = 1 for i in range(r): res = res * (n - i) * modinv(i+1, mod) % mod return res mod=10**9+7 print((2*mod+(pow(2,n,mod)-1)-mod_comb_count(n,a,mod)-mod_comb_count(n,b,mod))%mod) " p03289,s814912817,Accepted,"s = input() flg1 = s[0] == ""A"" flg2 = s[2:-1].count(""C"") == 1 s = s.replace(""A"", """") s = s.replace(""C"", """") flg3 = s.islower() print([""WA"", ""AC""][flg1 and flg2 and flg3])" p02613,s777372250,Accepted,"n = int(input()) s = [input() for i in range(n)] from collections import Counter b = Counter(s) print('AC x '+str(b['AC'])) print('WA x '+str(b['WA'])) print('TLE x '+str(b['TLE'])) print('RE x '+str(b['RE']))" p02554,s224795776,Wrong Answer,"def powmod(a,n,mod): ans = 1 while n > 0: if n & 1: # nの2進数表示の末尾が1か ans = ans * a % mod a = a ** 2 % mod # aを2乗する n >>= 1 # nを2で割る #print(ans,a,n) return ans #2分累乗法 ばらして余りとってかけ算 N=int(input()) m=powmod(10,N,1000000007)-powmod(9,N,1000000007)-powmod(9,N,1000000007)+powmod(8,N,1000000007) print(m)" p03323,s405144323,Accepted,"a, b = map(int, input().split()) if a <= 8 and b <= 8: print(""Yay!"") else: print("":("")" p04033,s423207218,Accepted,"a,b = map(int, input().split()) if a>0 and b>0: print(""Positive"") elif a<=0 and b>=0: print(""Zero"") elif a<0 and b<0: if (b-a+1)%2 == 0: print(""Positive"") elif(b-a+1)%2 == 1: print(""Negative"") " p02836,s947212674,Wrong Answer,"S=input() SR=S[::-1] ans=0 for i in range(len(S)): if S[i] != SR[i]: ans = ans + 1 print(ans-1)" p03624,s426927556,Wrong Answer,"s=list(input()) lowercase = 'abcdefghijklmnopqrstuvwxyz' count=0 for moji in lowercase: count+=1 if count==len(s): print('None') break if moji not in s: print(moji) break" p02726,s152946141,Accepted,"N,X,Y = map(int,input().split()) X-=1;Y-=1 ans = [0 for _ in range(N-1)] for i in range(N): for j in range(i+1,N): direct = j-i shortcut = abs(X-i)+1+abs(Y-j) shortest = min(direct,shortcut) ans[shortest-1] += 1 print(*ans,sep=""\n"")" p03438,s019262415,Accepted,"n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) suma = sum(a) sumb = sum(b) sousa = sumb-suma import math plus1=0 plus2=0 for i in range(n): if a[i] < b[i]: plus2+=math.ceil((b[i]-a[i])/2) elif a[i] > b[i]: plus1+=a[i]-b[i] if plus1<=sousa and plus2<=sousa: print(""Yes"") else: print(""No"")" p04045,s466035436,Accepted,"n, k = map(int, input().split()) d = [ int(x) for x in input().split() ] def is_ok(x): while x != 0: if x % 10 in d: return False x //= 10 return True money = n while True: if is_ok(n): print(n) break n += 1 " p03624,s171328451,Accepted,"string=input() s=set(list(string)) full=set(list(""abcdefghijklmnopqrstuvwxyz"")) tmp=full-s if len(tmp)==0: print(""None"") exit() print(min(tmp)) " p02829,s409853557,Accepted,"a=int(input()) b=int(input()) print(6-a-b)" p03557,s967118614,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: a_count = bisect.bisect_left(A, b) c_count = N - bisect.bisect_right(C, b) ans += a_count * c_count print(ans) " p03041,s733290830,Wrong Answer,"N, K = map(int, input().split()) S = input() s = S[K - 1] S = list(S) S[K - 1] = str.lower(s) S = str(S) print(S)" p03665,s055803535,Accepted,"from collections import Counter def combination(n, r): #nCrを求める if n - r > r: r = n - r tmp = 1 for i in range(n - r + 1, n + 1): tmp *= i for i in range(1, r + 1): tmp //= i return tmp N, P = map(int, input().split()) A = list(map(int, input().split())) B = [A[i] % 2 for i in range(N)] C = Counter(B) odd = C[1] even = C[0] ans = 0 for i in range(P, odd + 1, 2): tmp = combination(odd, i) ans += tmp ans *= pow(2, even) print (ans) " p02720,s370880172,Accepted,"import queue K = int(input()) Q = queue.Queue() for i in range(1, 10): Q.put(i) for i in range(K-1): x = Q.get() if x%10 != 0: Q.put(10*x+x%10-1) Q.put(10*x+x%10) if x%10 != 9: Q.put(10*x+x%10+1) print(Q.get())" p02947,s335041363,Accepted,"n = (int)(input()) s = sorted([sorted(list(input())) for i in range(n)]) ans = 0 temp = 1 for i in range(n - 1): if s[i] == s[i + 1]: temp += 1 else: if temp != 1: ans += temp * (temp - 1) // 2 temp = 1 else: if temp != 1: ans += temp * (temp - 1) // 2 temp = 1 print(ans)" p02879,s060941138,Accepted,"A,B = map(int,input().split()) if A<=9 and B<=9: print(A*B) else: print(-1)" p03779,s760455021,Accepted,"import math x = int(input()) x = abs(x) # sum = sec(sec+1)/2 a = math.ceil((2 * x) ** (0.5)) s = a * (a+1) // 2 while s >= x: a -= 1 s = a * (a+1) // 2 print(a+1) " p02702,s984945491,Accepted,"import sys input = sys.stdin.readline S = input().strip() l = len(S) dic = {0:[-1]} ans = 0 base = 1 mod = 0 for i in range(0, l): base = (10 * base) % 2019 s = base * int(S[l-1-i]) + mod mod = s % 2019 if mod in dic: dic[mod].append(i) else: dic[mod] = [i] for key, val in dic.items(): v_len = len(val) ans += (v_len * (v_len -1))// 2 print(ans) " p03910,s862899235,Wrong Answer,"n = int(input()) ans = [] while n != 0: c = n // 2 + 1 ans.append(c) n -= c print(""\n"".join(list(map(str, ans))))" p02802,s208344836,Accepted,"N,M=map(int,input().split()) ac=[False]*N wa=[0]*N for _ in range(M): p,S=input().split() p=int(p)-1 if S=='AC': ac[p]=True else: if not ac[p]: wa[p]+=1 a=0 b=0 for i in range(N): if ac[i]: a+=1 b+=wa[i] print(*[a,b])" p03264,s705249477,Accepted,"K = int(input()) L = list(range(1, K)) n = (K // 2) if K % 2 == 0: print(n**2) else: print(n * (n + 1))" p03761,s371132216,Accepted,"n = int(input()) S = [] ans = '' for i in range(n): S.append(str(input())) data1 = [] data2 = [] for i in range(len(S[0])): if not S[0][i] in data1: data1.append(S[0][i]) data2.append(1) else: data2[data1.index(S[0][i])] += 1 for i in range(1, n): for j in range(len(data1)): data2[j] = min(data2[j], S[i].count(data1[j])) for i in range(len(data1)): ans += data1[i] * data2[i] print(''.join(sorted(ans))) " p02691,s899304865,Accepted,"import sys from math import factorial from collections import Counter from fractions import Fraction import heapq, bisect, fractions import math import itertools sys.setrecursionlimit(10 ** 5 + 10) INF = 10**15 +5 def input(): return sys.stdin.readline().strip() def INT(): return int(input()) def MAP(): return map(int, input().split()) def LIST(): return list(map(int, input().split())) MOD = 10**9 + 7 n = INT() a = LIST() l1 = [i+1+a[i] for i in range(n)] l2 = [i+1-a[i] for i in range(n)] c1 = Counter(l1) c2 = Counter(l2) res = 0 inter = set(l1) & set(l2) for value in inter: res += c1[value]*c2[value] print(res)" p02783,s617471619,Wrong Answer,"import math A,H= map(int, input().split()) print(math.ceil(H/A))" p03545,s741043321,Accepted,"s = input() for bit in range(1<<3): ans="""" for i in range(3): if bit & (1<t+0.5: print(b*(i-1)) break " p03433,s134045034,Accepted,"n = int(input()) a = int(input()) if n % 500 <= a: print(""Yes"") else: print(""No"")" p02554,s650320078,Wrong Answer,"N = int(input()) mod = 10**9+7 if N == 1: result = 0 else: result = (10**(N-2) * 2) % mod print(result)" p02555,s183102074,Wrong Answer,"s = int(input()) lst = [0,0,1] num = 10**9 + 7 if s>= 4: for i in range(4,s+1): ans = (lst[i-2] + lst[i-4])%num lst.append(ans) print(lst[-1]%num)" p03030,s541263714,Accepted,"list = [] N = int(input()) for i in range(N): S, P = map(str, input().split()) list.append((i+1, S, int(P))) list = sorted(list, key=lambda x:(x[1], -x[2])) for l in list: print(l[0])" p02790,s830274030,Wrong Answer,"a = list(map(int, input().split())) if(a[0]>a[1]): for _ in range(a[0]): print(a[0], end = """") elif(a[0]dif: min = dif print(min) " p02631,s365837172,Accepted,"N = int(input()) A = list(map(int, input().split())) m = 0 for a in A: m ^= a ans = [] for a in A: ans.append(a ^ m) print(*ans)" p02742,s029047984,Accepted,"w,h = map(int, input().split()) x = w*h if h !=1 and w != 1: print((h*w+1)//2) else: print(1)" p03252,s568934327,Accepted,"if __name__ == '__main__': S = input() T = input() set_S = set(S) set_T = set(T) if len(set_S) != len(set_T): print(""No"") exit() dic = dict() flg = True for x,y in zip(S,T): if x not in dic: dic[x] = y else: if dic[x] != y: flg = False break if flg : print(""Yes"") else: print(""No"")" p02729,s169251715,Accepted,"import sys input = sys.stdin.readline N, M = map(int, input().split()) ret = 0 if N >= 2: ret += N * (N-1) // 2 if M >= 2: ret += M * (M-1) // 2 print(ret)" p04029,s932704549,Accepted,"N = int(input()) print(int((1+N) * N/2))" p02813,s306619295,Wrong Answer,"import itertools n = int(input()) p = tuple(map(int, input().split())) q = tuple(map(int, input().split())) a, b = 0, 0 for i, _p in enumerate(itertools.permutations(list(range(1, n+1)))): if p == _p: a = i elif q == _p: b = i print(abs(a-b)) " p02987,s514119789,Wrong Answer,"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 from fractions import gcd from math import ceil, floor, sqrt from copy import deepcopy def main(): flag = True s = input() c = Counter(s) values, counts = zip(*c.most_common()) for i in counts: if (i%2 != 0): flag = False if flag: print(""Yes"") else: print(""No"") if __name__ == ""__main__"": main()" p02993,s443702644,Accepted,"S=input() print(""Good"" if S[0]!=S[1] and S[1]!=S[2] and S[2]!=S[3] else ""Bad"")" p02719,s620241821,Accepted,"N, K = map(int, input().split()) n_1 = N - (K * (N // K)) n_2 = abs(n_1 - K) print(min(n_1, n_2))" p02817,s786835055,Accepted,"s,t=input().split() print(t+s)" p02818,s217180781,Accepted,"a, b, k = map(int, input().split()) if a > k: print(a-k, b) elif a + b > k: print(0, a + b - k) else: print(0, 0) " p02577,s452042159,Wrong Answer,"n = int(input()) if n % 9 or n < 9: print('No') else: print('Yes') " p03160,s106996234,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,end="""") " p02861,s564717621,Accepted,"from math import sqrt def route(a, b): return(sqrt((p[a-1][0]-p[b-1][0])**2+(p[a-1][1]-p[b-1][1])**2)) n = int(input()) p = list() for i in range(n): p.append(tuple(map(int, input().split()))) sum = int() cnt = int() for i in range(1, n): for j in range(i+1, n+1): #print(i, j) sum+=route(i,j) cnt+=1 sum*=n-1 print(sum/cnt)" p02608,s041229072,Accepted,"n = int(input()) ans = [0 for _ in range(10001)] for i in range(1,100): for j in range(1,100): for k in range(1,100): v = i**2 + j**2 + k**2 + i*j + j*k + k*i if v < 10001: ans[v] += 1 for i in range(n): print(ans[i+1])" p02577,s353106199,Wrong Answer,"#ABC176 B N = list(map(int,input())) n = 0 for i in N: n += i if n == 0: print('No') elif n % 9 == 0: print('Yes') else: print('No')" p03035,s271298803,Accepted,"a,b = map(int, input().split()) print(b if a >= 13 else b // 2 if a >= 6 and a <= 12 else 0)" p02712,s605529431,Accepted,"n = int(input()) sum = 0 for i in range (n+1): if i%3==0 and i%5==0: continue elif i%3==0: continue elif i%5==0: continue else: sum += i print(sum)" p02784,s227579069,Wrong Answer,"r=input().split() H=int(r[0]) N=int(r[1]) data_pre=input().split() data=[int(s) for s in data_pre] if max(data)>=H: print(""Yes"") else: print(""No"")" p02922,s622515139,Accepted,"a= list(map(int, input().split())) x = a[0] y = a[1] n = 2 if y == 1: print(0) elif x >= y: print(1) else: while ((x * n) - (n - 1)) < y: n += 1 print(n)" p03351,s965163414,Accepted,"a,b,c,d = (int(i) for i in input().split()) if (abs(a-b)<=d and abs(b-c)<=d) or abs(a-c)<=d: print(""Yes"") else: print(""No"") " p03071,s215250938,Accepted,"#!/usr/bin/env python3 import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 7) a, b = map(int,readline().split()) print(max(2 * a - 1, 2 * b - 1, a + b))" p03352,s880034760,Accepted,"x=int(input()) l=[0]*(x+1) if x==1: print(1) exit() for i in range(1,x): for j in range(2,1000): if i**j>x: break l[i**j]=1 for i in reversed(range(x+1)): if l[i]==1: print(i) exit() " p03719,s468792556,Accepted,"a,b,c=map(int,input().split()) if a<=c and c<=b: print(""Yes"") else: print(""No"")" p03971,s057916306,Wrong Answer,"N, A, B = map(int, input().split()) S = input() ok_count = 0 ok_fcount = 0 for i in range(N): if S[i] == 'a': if ok_count < A+B: print('Yes') ok_count +=1 else: print('No') elif S[i] == 'b': if ok_count < A+B and ok_fcount <= B: print('Yes') ok_count+=1 ok_fcount+=1 else: print('No') else: print('No')" p02971,s711637613,Wrong Answer,"n=int(input()) A=[int(input()) for i in range(n)] B=sorted(A) for a in A: if a == B[-1]: print(B[-1]) else: print(B[-2])" p02597,s644604582,Wrong Answer,"n=int(input()) s=input().strip() R=s.count('R') t=0 for i in range(R): if s[i]=='W': t=t+1 u=R-(n-R-t) f=max(t,u) if R==0 or R==n or t==R: f=0 print(f) " p02712,s616753642,Accepted,"n = int(input()) a = 0 for i in range(1,n+1): if i%3 and i%5: a += i print(a)" p02547,s653870599,Wrong Answer,"n=int(input()) count=0 for i in range(n): d1,d2=list(map(int,input().split())) if d1==d2: count+=1 if count>=3: print('YES') else: print('NO')" p03448,s762743370,Accepted,"A=int(input()) B=int(input()) C=int(input()) X=int(input()) a=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): a+=1 print(a)" p02760,s298405736,Wrong Answer,"#input a, B, c = map(int, input().split()) d, e, f = map(int, input().split()) h, i, j = map(int, input().split()) N = int(input()) b = [0] * N for i in range(N): b[i] = int(input()) #output if a and B and c in b: print(""Yes"") elif d and e and f in b: print(""Yes"") elif h and i and j in b: print(""Yes"") elif a and d and h in b: print(""Yes"") elif B and e and i in b: print(""Yes"") elif c and f and j in b: print(""Yes"") elif a and e and j in b: print(""Yes"") elif c and e and h in b: print(""Yes"") else: print(""No"")" p03481,s693454923,Accepted,"x,y = map(int,input().split()) ans = 1 while xy: ans-=1 break print(ans)" p03796,s426597287,Accepted,"n = int(input()) p = 1 for i in range(1, n+1): p = p*i%(10**9+7) print(p)" p03339,s059119112,Wrong Answer,"n = int(input()) s = input() cnt = 0 ans = s[1:].count('E') for i in range(1,n): if s[i-1] == ""W"": cnt += 1 if s[i] == ""E"": cnt -= 1 ans = min(ans,cnt) print(ans)" p03331,s086410257,Wrong Answer,"n = int(input()) ans = float(""inf"") for i in range(n+1): a = sum([int(i) for i in list(str(i))]) b = sum([int(i) for i in list(str(n-i))]) ans = min(a+b, ans) print(ans)" p02959,s080958624,Accepted,"n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) ans = 0 for i in range(n): #左側 left = min(a[i], b[i]) ans += left a[i] -= left b[i] -= left #右側 right = min(a[i + 1], b[i]) ans += right a[i + 1] -= right b[i] -= right print(ans) " p03623,s346084269,Accepted,"x,a,b=map(int,input().split()) if abs(a-x) abs(i - a[n - 1] / 2): tmp = abs(i - a[n - 1] / 2) ans = i print(a[n - 1], ans) " p03665,s506279581,Accepted,"n,p = map(int,input().split()) A = list(map(int,input().split())) even = sum([a%2==0 for a in A]) odd = n - even def nCr(n,r): ret = 1 for i in range(r): ret *= n-i ret //= i+1 return ret ans = 0 add = 2 ** even for k in range(p,odd+1,2): ans += nCr(odd,k) * add print(ans) " p03319,s800438408,Accepted,"from math import ceil N,K=map(int,input().split()) _=[i for i in input().split()] print(ceil((N-1)/(K-1))) " p02730,s981429231,Accepted,"s=input() n=len(s) count=0 a=(n-1)//2 b=(n+3)//2 for i in range(n//2): if s[i]!=s[-abs(i+1)]: count+=1 for i in range(a//2): if s[i]!=s[(a-1-i)]: count+=1 for i in range((n-b+1)//2): if s[-(i+1)]!=s[b-1+i]: count+=1 if count!=0: print('No') else: print('Yes') " p02748,s387333043,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 for i in range(M): x[i],y[i],c[i] = map(int,input().split()) ans = 10**10 ma = max(c) #ind = c.index(ma) am = min(a) bm = min(b) mae = am + bm #ここまで #indxy = a[x[ind]-1] + b[y[ind]-1] - ma for i in range(M): mai = a[x[i]-1] + b[y[i] -1] - c[i] if mai < ans: ans = mai print(ans) " p02842,s639467084,Wrong Answer,"import sys input=sys.stdin.buffer.readline N=int(input()) tax=27/25 for i in range(1,N): money=int(i*tax) if money==N: print(money) exit(0) print("":("")" p02714,s191967183,Accepted,"n=int(input()) s=input() t=s.count('R')*s.count('G')*s.count('B') for i in range(n): j=1 while i+j*2=H else ""No"") " p03524,s615929593,Accepted,"S = input() N = len(S) from collections import Counter c = Counter(S) items = sorted(c.items(), key=lambda x: x[1]) if N == 1: print('YES') elif N == 2: if len(items) == 1: print('NO') else: print('YES') else: if len(items) < 3: print('NO') else: min = items[0][1] max = items[-1][1] if max - min >= 2: print('NO') else: print('YES') " p02766,s905756883,Accepted,"n, k = map(int, input().split("" "")) keta = 1 sum = 0 while True: max = k**keta-1 if max >= n: print(keta) break keta += 1" p02682,s924261625,Accepted,"a,b,c,k = map(int,input().split()) ans = 0 if a= 0 and y > 0: if x > y: k += 2 else: k += 1 print(k) " p02910,s127508626,Accepted,"s = input() import sys n = len(s) kisuu = [""R"",""U"",""D""] guusuu = [""L"",""U"",""D""] for i in range(n): if i%2 == 0: if s[i] not in kisuu: break else: if s[i] not in guusuu: break else: print(""Yes"") sys.exit() print(""No"")" p02899,s482325264,Accepted,"n = int(input()) a = list(map(int, input().split())) L = {} for i in range(len(a)): L[i] = a[i] sort_L = sorted(L.items(), key=lambda x: x[1]) [print(j[0]+1, end=' ')for j in sort_L] " p03017,s075504414,Wrong Answer,"N, A, B, C, D = [int(_) for _ in input().split()] S = input() if ""##"" in S[A-1:C] or ""##"" in S[B-1:D]: print(""No"") elif C < D: print(""Yes"") elif ""..."" in S[B-1:D]: print(""Yes"") else: print(""No"") " p02657,s890974475,Accepted,"a, b = list(map(int, input().split())) print(a*b)" p03377,s063919487,Accepted,"A, B, X = map(int, input().split()) print(""YES"" if A <= X <= A+B else ""NO"")" p02600,s066972676,Wrong Answer,"rate=int(input()) a,b,c,d,e,f,g,h=400,600,800,100,1200,1400,1600,1800 if rate>=a and rate<=a+199: print(8) elif rate>=b and b+199>=rate: print(7) elif rate>=c and c+199>=rate: print(6) elif rate>=d and d+199>=rate: print(5) elif rate>=e and e+199>=rate: print(4) elif rate>=f and f+199>=rate: print(3) elif rate>=g and g+199>=rate: print(2) elif rate>=h and h+199>=rate: print(1)" p02612,s775478460,Accepted,"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() N %= 1000 if N==0: print(0) else: print(1000-N)" p02759,s393592997,Accepted,"n = int(input()) print((n+1)//2)" p03261,s010701757,Accepted,"n = int(input()) lis = [] for _ in range(n): lis.append(input()) if len(lis) != len(set(lis)): print(""No"") exit() tmp = lis[0][-1] for i in range(1,n): if lis[i][:1] != tmp: print(""No"") exit() else: tmp = lis[i][-1] print(""Yes"")" p02994,s238809709,Accepted,"N, L = map(int,input().split()) A = [L+k for k in range(N)] t = 10**9 for e in A: if abs(e) < abs(t): t = e print(sum(A)-t) " p02727,s378090799,Wrong Answer,"x,y,a,b,c = map(int,input().split()) print(sum(sorted(sorted(list(map(int,input().split())))[:-x-1:-1] + list(map(int,input().split()))[:-y-1:-1] + list(map(int,input().split())))[:-x-y-1:-1]))" p02973,s712428418,Accepted,"import sys input = sys.stdin.readline # 二分木 import bisect n = int(input()) a = [] for _ in range(n): ai = int(input()) * -1 i = bisect.bisect_right(a,ai) if(i==len(a)): a.append(ai) else: a[i] = ai print(len(a))" p03219,s894613417,Accepted,"x,y = map(int,input().split()) print(x + y // 2) " p03486,s724724064,Accepted,"print(""Yes"" if sorted(input())= N: print(ans) exit() t += (K-1) ans += 1 " p02546,s130675914,Accepted,"S = input() if S[-1] == 's': print(S + 'es') else: print(S + 's')" p03681,s474102968,Accepted,"import sys import math n,m=map(int,input().split()) mod=10**9+7 val1=math.factorial(m) val2=math.factorial(n) if abs(n-m)>1: print(""0"") elif (n==m): print((val1*val2*2)%mod) else: print((val1*val2)%mod)" p02983,s430731016,Accepted,"L,R = map(int,input().split()) if R-L >= 2100 : ans = 0 else : ans = 2019 for i in range(L,R): for j in range(i+1,R+1): if (i*j)%2019 < ans : ans = (i*j)%2019 if ans == 0 : break print(ans) " p02594,s519587523,Wrong Answer,"x = int(input()) if x >= 30: print('yes') else: print('no') " p03699,s465484730,Accepted,"n = int(input()) s_list = sorted([int(input()) for _ in range(n)]) m = 0 ans = 0 for s in s_list: ans += s if m == 0 and s % 10 != 0: m = s if m == 0: ans = 0 elif ans % 10 == 0: ans -= m print(ans)" p03282,s668381897,Wrong Answer,"S = list(input()) K = int(input()) for s in S: if s != '1': print(s) exit(0) " p03711,s498729508,Accepted,"g1 = [4,6,9,11] g2 = [2] g3 = [1,3,5,7,8,10,12] x,y = map(int,input().split()) if x in g1 and y in g1: print(""Yes"") exit() if x == y == 2: print(""Yes"") exit() if x in g3 and y in g3: print(""Yes"") exit() print(""No"") " p03017,s513059240,Accepted,"n,a,b,c,d=map(int,input().split());s=input() if c<=d: if ""##""in s[a-1:c] or""##""in s[b-1:d]:print(""No"") else:print(""Yes"") else: if ""..."" not in s[max(0,b-2):d+1]:print(""No"");exit() if ""##""in s[a-1:c] or""##""in s[b-1:d]:print(""No"") else:print(""Yes"") " p03773,s467467316,Accepted,"A, B = map(int,input().split()) if A + B < 24: print (A + B) else: print((A + B) -24)" p03680,s168782444,Accepted,"n = int(input()) a_list = [int(input()) - 1 for _ in range(n)] s = set() i = 0 ans = -1 while i not in s: if i == 1: ans = len(s) break s.add(i) i = a_list[i] print(ans)" p02765,s633893756,Accepted,"N,R = map(int,input().split()) if N<10: print(100*(10-N)+R) else: print (R) " p02972,s941144522,Wrong Answer,"n = int(input()) a = list(map(int, input().split())) b = [0] * n for i in range(n, 0, -1): j = i tmp = 0 while True: j += i if j > n: break tmp = tmp + a[j-1] b[i-1] = int(tmp % 2 != a[i-1]) m = sum(b) print(m) if m > -1: for i in range(n): if b[i]: print(i+1) " p03000,s736141669,Wrong Answer,"N, X = map(int, input().split()) L = list(map(int ,input().split())) D = 0 for i in range(N): D += L[i] if D >= X: print(i + 1) break" p03379,s757570822,Accepted,"n = int(input()) x = list(map(int, input().split())) nums = sorted(x) m1 = n//2-1 m2 = n//2 for i in range(n): if x[i] <= nums[m1]: print(nums[m2]) elif nums[m2] <= x[i]: print(nums[m1])" p02712,s581891879,Wrong Answer,"N = int(input()) c = 0 for i in range(1,N+1): if(N%3!=0 and N%5!=0): c += i print(c)" p02713,s850547591,Accepted,"def GCD(a, b): if b == 0: return a else: return GCD(b, a % b) def main(): K = int(input()) ans = 0 for i in range(1, K+1): for j in range(1, K+1): for k in range(1, K+1): tmp = GCD(i, j) ans += GCD(tmp, k) print(ans) return 0 if __name__ == '__main__': main()" p03998,s639797162,Accepted,"A = input() B = input() C = input() turn = 'a' win = '' while win == '': if turn == 'a': if len(A) == 0: win = 'A' else: turn = A[0] A = A[1:] elif turn == 'b': if len(B) == 0: win = 'B' else: turn = B[0] B = B[1:] elif turn == 'c': if len(C) == 0: win = 'C' else: turn = C[0] C = C[1:] print(win)" p03317,s746995590,Wrong Answer,"n,k = map(int,input().split()) lst = list(map(int,input().split())) id_one = lst.index(1) left_length = len(lst[0:id_one+1])-1 right_length = len(lst[id_one:])-1 counter = 0 while left_length > 0: counter += 1 left_length -= k-1 while right_length > 0: counter += 1 right_length -= k-1 print(counter)" p02713,s973114907,Accepted,"import math from functools import reduce import itertools import numpy as np K = int(input()) ans = 0 for i in range(1, K + 1): for j in range(i, K + 1): for k in range(j, K + 1): if i == j and j == k: dup_num = 1 elif i == j or j == k: dup_num = 3 else: dup_num = 6 ans += math.gcd(math.gcd(i, j), k) * dup_num print(ans) " p03386,s805147200,Accepted,"a,b,k = map(int,input().split()) if k<=(b-a)-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)" p03910,s711849619,Accepted,"#!/usr/bin/env python3 from math import ceil n = int(input()) a = ceil(((1 + 8 * n)**0.5 - 1) / 2) for i in range(a): if a * (a + 1) // 2 - n - 1 != i: print(i + 1) " p02691,s428203123,Wrong Answer,"N = int(input()) A = list(map(int, input().split())) count = 0 Ai = [A[i] + i for i in range(N)] Aj = [j + A[j] for j in range(N)] setAi = set(Ai) setAj = set(Aj) intersection = setAi.intersection(setAj) print(len(intersection))" p03835,s148487068,Wrong Answer,"K,S = map(int, input().split()) count = 0 for i in range(K): for j in range(K-i): for k in range(K-i-j): if i + j + k == S: count += 1 print(count)" p03997,s543196850,Accepted,"# -*- coding: utf-8 -*- """""" Created on Fri May 15 12:41:57 2020 @author: shinba """""" a = int(input()) b = int(input()) h = int(input()) print(int((a+b)*h/2)) " p03804,s385138568,Wrong Answer,"N, M = list(map(int, input().split())) A = [input().strip() for _ in range(N)] B = [input().strip() for _ in range(M)] temp = """".join(B) ans = False for j in range(N-M+1): for i in range(N-M+1): tmp = """" for y in range(M): tmp += A[y][i: i + M] if tmp == temp: ans = True if ans: print(""Yes"") else: print(""No"") " p02879,s796786763,Accepted,"a, b = map(int, input().split()) if (1 <= a <= 9) and (1 <= b <= 9): print(a*b) else: print(-1)" p03474,s498520518,Accepted,"A, B = map(int, input().split()) S = input() num = '1234567890' for i in S[:A]: if i in num: continue else: print('No') exit() if S[A] != '-': print('No') exit() for i in S[A+1:]: if i in num: continue else: print('No') exit() print('Yes') " p02881,s133705314,Accepted,"from math import sqrt N = int(input()) ans = 10**12+1 for x in range(1, int(sqrt(N))+1): if N % x == 0: y = N // x l = (x - 1) + (y - 1) ans = min(ans, l) print(ans)" p02598,s510137329,Wrong Answer,"from math import * def trycut(val): ret = 0 for i in range(n): ret += ceil(a[i]/val)-1 return ret n,k=map(int,input().split()) a = [int(i) for i in input().split()] low = 0 high = 1000000000 ans =-1 while low < high: mid = (low + high)/2 cut = trycut(mid) # ~ print(""low="",low, ""high="", high,""val = "",mid,""ret = "",cut) if cut <= k: high = mid-0.01 ans = mid else: low = mid+0.01 # ~ if low < high: print(low, high, ""je reviens"") print(round(ans)) " p02823,s794076632,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,a,b = iim() if (a%2)^(b%2): num = min(a-1,n-b)+1 print((b-a)//2+num) else: print((b-a)//2)" p03943,s392128490,Wrong Answer,"A = list(map(int, input().split())) ave = sum(A)//2 if ave in A: print(""Yes"") else: print(""No"")" p02785,s603259700,Accepted,"n, k = map(int, input().split()) H = list(map(int, input().split())) H.sort() if k >= n: print(0) exit() for _ in range(k): H.pop() ans = sum(H) print(ans)" p03062,s653353377,Wrong Answer,"# input N = int(input()) A = list(map(int, input().split())) # check print(sum([a if a >= 0 else a * -1 for a in A]))" p03861,s921936081,Accepted,"a, b, x = map(int, input().split()) print(b // x - a // x + (1 if a % x == 0 else 0)) " p03127,s613255182,Accepted,"n=int(input()) a=list(map(int,input().split())) def gcd(a,b): aa=max(a,b) bb=min(a,b) cc=aa%bb return gcd(bb,cc) if cc else bb p=gcd(a[0],a[1]) for i in range(2,n): p=gcd(p,a[i]) print(p) " p02789,s379461980,Wrong Answer,"x, y = input().split() if x == y: print('Yes') elif x > y: print('No')" p03767,s870142558,Accepted,"N = int(input()) a = list(map(int,input().split())) ans = 0 a = sorted(a) for i in range(N): ans += a[-2 - 2 * i] print(ans)" p03069,s685476512,Accepted,"import sys #input = sys.stdin.buffer.readline def main(): N = int(input()) s = input() ans = s.count(""."") count = ans for st in s: if st == ""#"": count += 1 else: count -= 1 ans = min(ans,count) print(ans) if __name__ == ""__main__"": main()" p03524,s145158071,Accepted,"import collections s = input() d = collections.Counter(s) if len(d) < 3: num = max(d.values()) else: num = max(d.values()) - min(d.values()) print('YES' if num<2 else 'NO')" p02779,s430729175,Wrong Answer,"N = int(input()) A = list(map(int, input().split())) Ans = ""Yes"" List = [] for e in A: if e in List: Ans = ""No"" break else: List.append(e) print(Ans)" p03645,s198908831,Accepted,"#%% n, m = map(int, input().split()) route = {} for _ in range(m): a, b = map(int, input().split()) route.setdefault(a, []).append(b) #%% flag = False for r1 in route[1]: if n in route.get(r1, []): flag = True break if flag: print('POSSIBLE') else: print('IMPOSSIBLE') " p02676,s311489574,Accepted,"k = int(input()) s = input() L = len(s) if L <= k: print(s) else: ans = s[:k]+'...' print(ans) " p03681,s904942946,Accepted,"N,M = map(int,input().split()) mod = pow(10,9)+7 def f(x,mod): k = 1 res = 1 while k1:print(0) elif abs(N-M)==1: a = f(min(N,M),mod) print(pow(a,2,mod)*max(N,M)%mod) else: a = f(N,mod) print(2*pow(a,2,mod)%mod)" p03000,s265888491,Accepted,"N, X = map(int, input().split(' ')) L = list(map(int, input().split(' '))) D = [0 for _ in range(N + 1)] for i in range(1, N + 1): D[i] = D[i-1] + L[i-1] count = 0 for i in range(N + 1): if D[i] <= X: count += 1 print(count)" p02777,s976888642,Wrong Answer,"s, t = input().split() a,b = map(int, input().split()) u = input() if s == u: print(a-1, b) elif s == t: print(a, b-1)" p02676,s856637618,Accepted,"K = int(input()) S = input() if len(S) <= K: print(S) else: print(S[:K]+""..."")" p02555,s552963867,Accepted,"import itertools s = int(input()) if s < 3: print(0) exit() l = [1]*(s - 2) total = 0 three_cnt = s // 3 for i in range(three_cnt): total += l[s - 3 - (i*3)] for j in range(s - 3): l[j + 1] += l[j] print(total % ((10 ** 9) + 7))" p03360,s176321673,Wrong Answer,"num=list(map(int,input().split())) k=int(input()) ans1=sum(num)-max(num) ans2=0 while k>0: ans2+=max(num)*2 k-=1 print(ans1+ans2)" p03698,s754552828,Accepted,"s=input() flag=True for i in range(len(s)-1): for j in range(i+1,len(s)): if s[i]==s[j]: flag=False break if not(flag): break print(""yes"") if flag else print(""no"")" p02917,s568561360,Accepted,"N = int(input()) B = list(map(int, input().split())) A = [0] * N for x in range(N - 1, -1, -1): if x == N - 1: A[x] = B[x - 1] elif x == 0: A[x] = B[x] else: A[x] = min(B[x], B[x - 1]) print(sum(A)) " p03427,s981448979,Accepted,"s=list(input()) n=len(s) for i in range(n): s[i]=int(s[i]) dec_flg=0 for i in range(n): if i==0:continue if dec_flg==0: if 0<=s[i]<=8 and s[i-1]>0: s[i-1]-=1 s[i]=9 dec_flg=1 else: if 0<=s[i]<=8: s[i]=9 ans=0 for ss in s: ans+=ss print(ans)" p02873,s234893737,Accepted,"a=list(input()) count=1 ans = 0 temp = 0 for i in range(len(a)-1): if a[i] ==a[i+1]: count+=1 else: if a[i]=='<': ans += count*(count+1)//2 temp = count #print('<', count, ans) count = 1 else: ans += count*(count+1)//2 ans -= min(count, temp) #print('>', count, ans) count =1 else: if a[-1]=='<': ans += count*(count+1)//2 else: ans += count*(count+1)//2 ans -= min(count, temp) print(ans)" p02718,s452131802,Accepted,"N,M=map(int,input().split()) ls = list(map(int,input().split())) ls1 = [0]*N s = sum(ls) for i in range(N): if ls[i]>=s/(4*M): ls1[i]=1 ss = sum(ls1) if ss>=M: print(""Yes"") else: print(""No"")" p02820,s567145204,Wrong Answer,"#D n,k=map(int, input().split()) r,s,p=map(int, input().split()) t=str(input()) te=[] score=0 for i in range(n): if i>=k and t[i]==t[i-k]:#k回前に相手が同じ手を出している場合 score+=0 te.append(t[i]) else: if t[i]=='r': score+=p te.append('p') elif t[i]=='s': score+=r te.append('r') elif t[i]=='p': score+=s te.append('s') print(score)" p02866,s162546097,Accepted,"from collections import Counter n, *d = map(int, open(0).read().split()) MOD = 998244353 c = Counter(d) if d[0] != 0 or c[0] != 1: ans = 0 else: ans = 1 for i in range(1, max(d)+1): ans *= (c[i-1] ** c[i]) % MOD print(ans % MOD)" p02935,s201347766,Accepted,"#17 N = int(input()) V = list(map(int,input().split())) num = 0 V.sort() for i in range(N-1): num = (V[i] + V[i+1])/2 V[i+1] = num print(V[-1])" p03545,s402382300,Wrong Answer,"s = input() n = len(s) - 1 ans = 0 for i in range(1 << n): exp = s[0] for j in range(n): if i & (1 << j): exp += ""+"" else: exp += ""-"" exp += s[j + 1] if eval(exp) == 7: ans = exp print(ans)" p02556,s399034848,Wrong Answer,"n=int(input()) l=[] for i in range(n): x,y=(map(int,input().split())) we=int(((x**2)+(y**2))**0.5) ll=[we,x,y] l.append(ll) l.sort() #print(l) print((l[-1][2]-l[0][2])+(l[-1][1]-l[0][1])) ''' ll1=[ll[1],ll[0]] lan.append(ll1) l.sort() lan.sort() we=abs(l[0][0]-l[-1][0])+abs(l[0][1]-l[-1][1]) we1=abs(lan[0][0]-lan[-1][0])+abs(lan[0][1]-lan[-1][1]) print(max(we,we1)) '''" p03827,s929486978,Accepted,"n = int(input()) s = input() x = 0 x_max = 0 for i in s: x = x+1 if i=='I' else x-1 x_max = max(x, x_max) print(x_max) " p03360,s516679225,Accepted,"a, b, c = map(int, input().split()) k = int(input()) print(sum([a, b, c]) + max(a, b, c) * 2**k - max(a, b, c)) " p03075,s985467070,Accepted,"S = [int(input()) for _ in range(5)] k=int(input()) a=max(S) b=min(S) if a-b>k: print(':(') exit() else: print('Yay!')" p03479,s740142402,Accepted,"x,y=map(int,input().split()) i=0 while x<=y: x*=2 i+=1 print(i)" p04033,s238913856,Accepted,"#A - Range Product a,b = map(int,input().split()) if a <= 0 and b >= 0: print('Zero') elif a < 0 and b < 0: if abs(a - b) % 2 == 0: print('Negative') else : print('Positive') elif a > 0 and b > 0: print('Positive')" p03435,s215792897,Accepted,"c = list(list(map(int, input().split())) for i in range(3)) d = [0, 1, 2, 0, 1] x = c[0][0] + c[1][1] + c[2][2] ok = True for i in range(3): a = c[d[i]][0] + c[d[i+1]][1] + c[d[i+2]][2] b = c[d[i]][2] + c[d[i+1]][1] + c[d[i+2]][0] if x != a or x != b: ok = False print('Yes' if ok else 'No') " p02882,s529458788,Accepted,"import math a,b,x=map(int, input().split()) s = x/a if s<=a*b/2: d = b/(s*2/b) else : d = (b*2-s*2/a)/a print(math.degrees(math.atan(d)))" p03435,s908264105,Accepted,"*c, = map(int,open(0).read().split()) for i in range(2): if( (c[1+i]-c[0+i])!=(c[4+i]-c[3+i]) or (c[1+i]-c[0+i])!=(c[7+i]-c[6+i]) or (c[3+i*3]-c[i*3])!=(c[4+i*3]-c[1+i*3]) or (c[3+i*3]-c[i*3])!=(c[5+i*3]-c[2+i*3]) ): print(""No"") break else: print(""Yes"") " p03472,s242296033,Accepted,"N, H = map(int,raw_input().split()) a = [] b = [] for i in range(N): ai, bi = map(int,raw_input().split()) a.append(ai) b.append(bi) a_max = max(a) b = sorted(b) ans = 0 for i in reversed(range(N)): if b[i] >= a_max: ans = ans + 1 H = H - b[i] if H <= 0: print ans exit() ans = ans + -(-H//a_max) print ans " p03377,s712862472,Wrong Answer,"a,b,c=map(int, input().split()) if a+b>=c: print('YES') else: print('NO')" p02772,s183303283,Accepted,"def main(): n = int(input()) A = map(int,input().split()) for a in A: if (a % 2 == 0): if ((a % 3 != 0) and (a % 5 != 0)): print(""DENIED"") return print(""APPROVED"") main()" p04044,s536837417,Accepted,"n,l=map(int,input().split()) s=sorted(input() for i in range(n)) print(*s, sep="""")" p02761,s931224192,Accepted,"n, m = map(int,input().split()) s = [] c = [] for _ in range(m): x, y = map(int,input().split()) s.append(x) c.append(y) for i in range(10 ** (n + 1)): Str = str(i) if len(Str) == n and all([Str[s[j] - 1] == str(c[j]) for j in range(m)]): print(Str) exit() print(-1)" p03293,s737969143,Accepted,"# solution import io print(""Yes"" if input() in input()*2 else ""No"")" p02946,s386867000,Accepted,"k,n=map(int,input().split()) for i in range(k-1): print(n-k+i+1,end="" "") print(n,end="" "") for i in range(k-1): print(n+i+1,end="" "") " p03220,s441809187,Accepted,"N = int(input()) T, A = list(map(int, input().split())) H = list(map(int, input().split())) min_dif = 99999999999999999 min_pt = 0 for i, h in enumerate(H): dif = abs(A - (T - h*0.006)) if dif < min_dif: min_pt=i+1 min_dif = dif print(min_pt)" p02953,s739326408,Wrong Answer,"N = int(input()) H = list(map(int, input().split())) if N == 1: print(""Yes"") exit() flag = True for i in range(N-1, -1, -1): if H[i] >= H[i-1]: pass elif H[i] + 1 == H[i-1]: H[i-1] -= 1 else: flag = False print(H) if flag: print(""Yes"") else: print(""No"") " p02832,s359519699,Accepted,"N = int(input()) A = [int(i) for i in input().split()] now = 1 for i in range(N): if A[i] == now: now += 1 print(N-now+1 if now != 1 else -1)" p03761,s651920111,Accepted,"from collections import Counter n = int(input()) x = [] for i in range(n): s = input() t = Counter(s) x.append(t) ans = """" for i in ""abcdefghijklmnopqrstuvwxyz"": tmp = [] for j in x: tmp.append(j[i]) ans += i*min(tmp) print(ans)" p02553,s011887632,Accepted,"a, b, c, d = map(int, input().split()) e = a * c f = a * d g = b * c h = b * d print(max(e, f, g, h))" p03457,s875626098,Accepted,"# -*- coding:utf-8 -*- n = int(input()) t, x, y = [0], [0], [0] for i in range(n): t_i, x_i, y_i = map(int, input().strip().split()) t.append(t_i) x.append(x_i) y.append(y_i) can = ""Yes"" 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): can = ""No"" if(dist % 2 != dt % 2): can = ""No"" print(can)" p02699,s481928617,Accepted,"s,w = map(int, input().split()) if w >= s: print('unsafe') else: print('safe') " p03107,s990539297,Accepted," from collections import deque def submit(): s = input().strip() q = deque() ans = 0 for c in s: if len(q) == 0: q.append(c) else: top = q.pop() if top != c: ans += 2 else: q.append(top) q.append(c) print(ans) if __name__ == ""__main__"": submit()" p03951,s540921152,Accepted,"N = int(input()) s = input() t = input() for i in range(N): if s[i:] == t[:N - i]: print(N + i) exit() print(2 * N)" p03433,s110050338,Wrong Answer,"N=int(input()) A=int(input()) mod=N%500 if mod=N: buf=cnt-N break id=i seq=[i+1 for i in range(id)] for i in range(len(seq)): if seq[i]!=buf: print(seq[i])" p03645,s255651790,Accepted,"n,m=map(int,input().split()) data=[0]*n for i in range(m): a,b=map(int,input().split()) if a==1: data[b-1]+=1 if data[b-1]==2: print('POSSIBLE') exit() if b==n: data[a-1]+=1 if data[a-1]==2: print('POSSIBLE') exit() print('IMPOSSIBLE')" p03103,s380965010,Accepted,"N, M = map(int, input().split()) a = [] for i in range(N): a += [list(map(int, input().split()))] a.sort(key=lambda x: x[0]) i, ans = 0, 0 while M != 0 or i < N: if M > a[i][1]: M -= a[i][1] ans += a[i][0]*a[i][1] else: ans += a[i][0]*M M = 0 break i += 1 print(ans) " p02847,s650002204,Wrong Answer,"week = [""MON"",""TUE"",""WED"",""THU"",""FRI"",""SAT"",""SUN""] week.reverse() print(week.index(input())) " p02820,s656044884,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 point = 0 point += np.sum(t[:k]) for i in range(k,n): if t[i] != t[i-k]: point += t[i] elif t[i] == t[i-k]: t[i] = 0 print(point)" p03495,s584896691,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) li = [0]*10**6 for i in range(N): li[A[i]] += 1 # print(li) li.sort(reverse=True) # print(li) print(sum(li[K:]))" p02833,s892587607,Wrong Answer,"N = int(input()) m = 5 ans = 0 if N % 2 == 1: pass else: for i in range(1, 10000): m = pow(5, i) * 2 if m > N: break else: ans += int(round(N / m, 0)) print(ans)" p02596,s552429518,Accepted,"K = int(input()) INF = 10**18 a = [INF] * (K+1) a[0] = 0 for n in range(1, K+1): a[n] = (10 * a[n-1] + 7) % K if a[n] == 0: print(n) break else: print(-1) " p03797,s466151978,Accepted,"N,M=map(int,input().split()) if 2*N>M: print(M//2) else: print((2*N+M)//4) " p03645,s485545053,Accepted,"N, M = map(int, input().split()) L = [list(map(int, input().split())) for i in range(M)] s = [] g = [] for i in range(M): if 1 == L[i][0]: s.append(L[i][1]) if 1 == L[i][1]: s.append(L[i][0]) for i in range(M): if N == L[i][0]: g.append(L[i][1]) if N == L[i][1]: g.append(L[i][0]) if set(g)&set(s): print('POSSIBLE') else: print('IMPOSSIBLE') " p02899,s494588856,Wrong Answer,"n = int(input()) a = list(map(int, input().split())) ret = '' for i in range(1, n+1): ret += str(a.index(i) + 1) print(' '.join(ret)) " p03804,s282549805,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)]) for i in range(n-m+1): for j in range(n-m+1): if (A[i:i+m, j:j+m] == B).all(): print('Yes') exit() print('No')" p02661,s000280203,Accepted,"import statistics n=int(input()) la, lb = [], [] for _ in range(n): a, b =map(int, input().split()) la.append(a) lb.append(b) c=statistics.median(la) d=statistics.median(lb) if n%2==1: print(d-c+1) else: print(int(2*d-2*c+1)) " p03069,s590621121,Accepted,"N = int(input()) S = input() black = 0 ans = 0 for s in S: if s == ""#"": black += 1 else: if black > 0: ans += 1 black -= 1 print(ans)" p02719,s497681476,Accepted,"n, k = list(map(int, input().split())) print(min(n%k, abs(n%k -k)))" p02664,s467557877,Accepted,"print(input().replace(""?"", ""D""))" p02723,s255917083,Wrong Answer,"s = input() if s[2]==[3] and s[4]==s[5]: print(""Yes"") else: print(""No"")" p03077,s557356549,Accepted,"n = int(input()) l = [int(input()) for i in range(5)] if n % min(l) == 0: print(n // min(l) + 4) else: print(n // min(l) + 5)" p03281,s682007299,Wrong Answer,"N = int(input()) ans = [] for i in range(1, N + 1, 2): count = 0 if i == 105: print(105) for j in range(1, i // 2 + 1): if i % j == 0: count += 1 if count == 7: ans.append(1) print(sum(ans))" p02994,s164923210,Wrong Answer,"n,l=map(int,input().split()) if l<-n: print(n*(n-1)//2+(l-1)*(n-1)) elif -n<=l and l<0: print((n-1)*(l-1)+n*(n+1)//2) else: print(n*(n-1)//2+(l-1)*(n-1)-1)" p02548,s650618944,Accepted,"n = int(input()) ans = 0 for a in range(1, n): t = (n-1) // a ans += t print(int(ans)) " p03632,s933418886,Wrong Answer,"N = list(map(int, input().split())) if N[2]-N[1] <= 0: if N[1] > N[3]: print(abs(N[3]-N[2])) else: print(abs(N[2]-N[1])) else: print(""0"")" p03632,s164228322,Wrong Answer,"a, b, c, d = map(int, input().split()) s = max(a, c) f = min(b, d) if b > c: print(f - s) else: print(0) " p03723,s624691012,Wrong Answer,"a, b, c = map(int, input().split()) flag = 0 ans = 0 if a == b == c: ans = -1 else: while flag == 0: if a%2 == 1 or b%2 == 1 or c%2 == 1: flag = 1 else: a_tmp = (b+c)/2 b_tmp = (a+c)/2 c_tmp = (a+b)/2 a = a_tmp b = b_tmp c = c_tmp ans += 1 print(ans)" p02713,s447672849,Accepted,"from math import gcd from itertools import product def solve(string): k = int(string) ans = 0 for a, b, c in product(range(1, k + 1), repeat=3): ans += gcd(gcd(a, b), c) return str(ans) if __name__ == '__main__': import sys print(solve(sys.stdin.read().strip())) " p02622,s639429809,Wrong Answer,"import timeit a = [input() for i in range(2)] S = a[0] T = a[1] def count_diff2(S,T): cnt = 0 for c1,c2 in zip(S, T): if c1 != c2: cnt += 1 return cnt print(timeit.timeit(lambda: count_diff2(S,T)))" p02553,s307665058,Accepted,"line = input().rstrip().split("" "") a = int(line[0]) b = int(line[1]) c = int(line[2]) d = int(line[3]) if b>= 0 and d >= 0: print(max(b * d, a * c)) elif b <= 0 and d >= 0: print(max(b * c, a * c)) elif b >= 0 and d <= 0: print(max(a * d, a * c)) else: print(a * c)" p03077,s947128656,Accepted,"N = int(input()) carry = [int(input()) for _ in range(5)] min_carry = min(carry) print((N + min_carry - 1) // min_carry + 4)" p03087,s590289237,Wrong Answer,"n,q = map(int,input().split()) s = list(input()) base = [0]*n count = 0 for i in range(1,n): if (s[i-1] == ""A"") and (s[i] == ""C""): count = count + 1 base[i] = count else: base[i] = count base[n-1] = base[n-2] for i in range(q): l,r = map(int,input().split()) ans = base[r-1] - base[l-1] print(ans)" p02726,s159472020,Wrong Answer,"N, X, Y = map(int, input().split()) ans = [0] * (N-1) for i in range(1,N+1): for j in range(i+1, N+1): k = min(j-i, abs(X-i) + abs(Y-j) + 1) ans[k-1] += 1 print(ans) for i in range(N-1): print(ans[i]) " p02630,s311339661,Accepted,"from collections import Counter n = int(input()) a = list(map(int, input().split())) q = int(input()) a_sum = sum(a) a_count = Counter(a) for i in range(q): b, c = map(int, input().split()) a_sum = a_sum + (c - b)*a_count[b] if a_count[c]: a_count[c] += a_count[b] a_count[b] = 0 else: a_count[c] = a_count[b] a_count[b] = 0 print(a_sum) " p02988,s959509737,Accepted,"n = int(input()) l = list(map(int, input().split())) pair = 0 for i in range(1,n-1): if min(l[i-1],l[i+1]) <= l[i] and l[i] <= max(l[i-1],l[i+1]): pair += 1 print(pair)" p03495,s983719198,Accepted,"from collections import Counter N, K = map(int, input().split()) counter = Counter(int(x) for x in input().split()) # 書き換えが必要な種類 i = len(counter) - K if i < 1: print(0) else: t = [(v, k) for k, v in counter.items()] t.sort() print(sum(v for v, k in t[:i])) " p02996,s270187989,Accepted,"n = int(input()) task = [list(map(int, input().split())) for i in range(n)] task = sorted(task, key=lambda x: x[1]) time = 0 for i in range(n): time += task[i][0] if time > task[i][1]: print(""No"") exit() print(""Yes"")" p02789,s158970117,Accepted,"N,M = map(int,input().split()) if N == M: print(""Yes"") else: print(""No"")" p03759,s907146215,Wrong Answer,"a,b,c = map(int,input().split()) if abs(a-b) == abs(b-c): print('YES') else: print('NO') " p03324,s525665123,Accepted,"d,n=map(int,input().split()) print(10**(2*d)*(n+n//100))" p02775,s762458488,Accepted,"n = input() m = len(n) dp0 = [0]*m dp1 = [0]*m dp1[0] = min(int(n[0])+2,11-int(n[0])) dp0[0] = int(n[0]) for i in range(1,m): dp0[i] = min(dp0[i-1],dp1[i-1]) + int(n[i]) if int(n[i]) != 9: dp1[i] = min(dp0[i-1]+int(n[i])+2,dp1[i-1]+min(int(n[i])+2,9-int(n[i]))) else: dp1[i] = dp1[i-1] print(min(dp0[m-1],dp1[m-1]))" p03773,s724436077,Accepted,"a,b=map(int, input().split()) print((a+b)%24)" p02700,s597260448,Accepted,"a,b,c,d = map(int, input().split()) t = (a+d-1)//d o = (c+b-1)//b if t >= o: print('Yes') else: print('No')" p02694,s015686672,Accepted,"x=int(input()) flag=""False"" n=0 y=100 while flag==""False"": n+=1 y=int(y*1.01) if y>=x: flag=""True"" print(n)" p02555,s190722297,Wrong Answer,"import math S = int(input()) if S < 3: print(0) exit() def check(s, i): re = (i ** s) % (10 ** 9 + 7) return re n = S // 3 ans = 0 for i in range(n): S_i = S - (3 * (i + 1)) ans += check(S_i, i + 1) print(ans % (10 ** 9 + 7)) " p02881,s690442077,Accepted,"import math N = int(input()) num = 0 SQRTN = int(math.sqrt(N)) for i in range(1,SQRTN+1): if N % i == 0: num = i # print(num) num_2 = N//num print(num + num_2 -2)" p02606,s371098783,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) " p02717,s106039902,Wrong Answer,"a,b,c=map(int,input().split()) print(b) print(c) print(a)" p02570,s678908381,Accepted,"D, T, S = map(int, input().split()) if -(-D//S) <= T: print('Yes') else: print('No') " p02689,s485347424,Wrong Answer,"import sys input = sys.stdin.readline # C - Peaks import copy n, m = map(int, input().split()) h = list(map(int, input().split())) obs = copy.copy(h) for i in range(m): a, b = map(int, input().split()) a -= 1 b -= 1 height = max(obs[a], obs[b]) obs[a] = height obs[b] = height #print(obs) ans = 0 for i in range(n): if obs[i] == h[i]: ans += 1 print(ans)" p03633,s867620003,Wrong Answer,"from functools import reduce from fractions import gcd N = int(input()) T = [] for i in range(N): T.append(int(input())) x = reduce(gcd,T) sum=x for i in T: sum*=(i//x) print(sum)" p03723,s761472728,Accepted,"l = list(map(int, input().split())) ans = 0 while( l[0]%2==0 and l[1]%2==0 and l[2]%2==0): if l[0]==l[1]and l[1]==l[2]: ans = -1 break else: a = l[0] b = l[1] c = l[2] l[0]=(b+c)/2 l[1]=(a+c)/2 l[2]=(a+b)/2 ans+=1 print(ans)" p02598,s464990328,Accepted,"n,k = map(int, input().split()) a = list(map(int, input().split())) a.sort() if k==0: print(max(a)) exit() def solve(num): ret=0 for tmp in a: ret+= tmp//num if tmp%num==0: ret-=1 return k>=ret l=0 r=10**18 while r-l>1: mid=(l+r)//2 if solve(mid): r=mid else: l=mid print(min(max(a),r)) #print(min(min(a),r))" p02888,s819782065,Accepted,"N=int(input()) *L,=map(int, input().split()) L.sort() ans=0 from bisect import bisect_right for i in range(N-1,-1,-1): li = L[i] for j in range(i-1,-1,-1): lj = L[j] k = bisect_right(L, li-lj) ans += max(0, j-k) print(ans)" p02661,s523811994,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: ma = A[N//2] mb = B[N//2] print(max(0, mb - ma + 1)) else: ma = A[N//2] + A[N//2-1] mb = B[N//2] + B[N//2-1] print(max(0, mb - ma + 1))" p03162,s591582522,Accepted,"n=int(input()) a,b,c=map(int,input().split()) for _ in range(1,n): aa,bb,cc=map(int,input().split()) a,b,c=aa+max(b,c),bb+max(a,c),cc+max(a,b) print(max(a,b,c))" p03293,s562460020,Accepted,"import sys # input = sys.stdin.readline sys.setrecursionlimit(10 ** 9) MOD = 10 ** 9 + 7 S = list(input()) T = list(input()) N = len(S) for i in range(N): #スタート位置 flag = True for j in range(N): if S[(i + j) % N] == T[j]: continue flag = False break if flag: print ('Yes') exit() print ('No')" p02743,s615869010,Accepted,"a,b,c = map(int,input().split()) if c-a-b < 0: print('No') exit() if (c-a-b)**2 - 4*a*b > 0: print('Yes') else: print('No')" p03131,s602452413,Accepted,"K, A, B = map(int, input().split()) if B <= A + 2: print(1 + K) else: ans = (K - (A - 1)) // 2 * (B - A) + A if (K - (A - 1)) % 2 == 1: ans += 1 print(ans) " p02756,s973982174,Accepted,"#!/usr/bin/env python3 s, _, *q = open(0) g = """" s = s.strip() for q in q: q = q.strip().split() if q[0] == ""1"": g, s = s, g else: if q[1] == ""1"": g += q[2] else: s += q[2] print(g[::-1] + s)" p03254,s678821590,Wrong Answer,"try: N, x = map(int, input().split()) a = list(map(int, input().split())) a_ = sorted(a) cnt = 0 for i in a_: if i<=x: cnt += 1 x = x-i print(cnt) except EOFError: pass" p02873,s796986668,Accepted,"S = str(input()) S += '/' l = [0]*len(S) for i in range(len(S)-1): if S[i] == '<': l[i+1] = l[i] + 1 for i in range(len(S)-2,-1,-1): if S[i] == '>': l[i] = max(l[i+1]+1,l[i]) print(sum(l))" p03417,s699132767,Wrong Answer,"def main(): n, m = map(int,(input().split())) if n <= 2 and m <= 2: print(0) elif n>2 and m>2: print((n-2)*(m-2)) elif n>2: if m == 2: print(0) else: print(n-2) elif m>2: if n == 2: print(0) else: print(m-2) if __name__ == ""__main__"": main()" p03293,s978380018,Accepted,"import sys def main(): ss = input() ts = input() n = len(ss) for i in range(n): ss = ss[-1] + ss[:-1] if ss == ts: print('Yes') sys.exit(0) print(""No"") if __name__ == ""__main__"": main() " p03075,s768568642,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(""Yey!"") else: print("":("")" p03386,s267698724,Accepted,"import sys readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines read = sys.stdin.buffer.read sys.setrecursionlimit(10 ** 7) INF = float('inf') a,b,k=map(int,input().split()) ans=[] for i in range(a,min(a+k,b+1)): ans.append(i) for i in range(max(b-k+1,a),b+1): ans.append(i) ans = sorted(list(set(ans))) for i in ans: print(i)" p03239,s573075498,Accepted,"N,T=map(int,input().split()) CL = [] for i in range(N): c, ti = map(int,input().split()) if ti <= T: CL.append(c) if len(CL) == 0: print(""TLE"") else: CL.sort() print(CL[0]) " p02548,s559510617,Accepted,"from collections import deque, Counter, defaultdict from itertools import chain, combinations import json # import numpy as np import bisect import sys import math import bisect from functools import lru_cache import itertools sys.setrecursionlimit(10 ** 8) M = 10 ** 9 + 7 INF = 10 ** 17 def main(): N = int(input()) # D = [ # [int(a) for a in input().split()] # for _ in range(N) # ] t = 0 for a in range(1, N): d = (N-1) // a t += d print(t) if __name__ == ""__main__"": main() " p03679,s878233005,Accepted,"def main(): X, A, B = map(int, input().split()) if A - B >= 0: print('delicious') elif X >= (B - A): print('safe') else: print('dangerous') main()" p03592,s242720781,Accepted,"N,M,K = map(int,input().split()) for a in range(N+1): for b in range(M+1): k = a*b + (N-a)*(M-b) if k==K: print('Yes') exit() print('No')" p03449,s432913606,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)" p03437,s100271630,Accepted,"x,y = map(int,input().split()) if x % y: print(x) else: print(-1) " p02600,s054531440,Accepted,"rating = int(input()) if rating < 600: print(8) elif rating < 800: print(7) elif rating < 1000: print(6) elif rating < 1200: print(5) elif rating < 1400: print(4) elif rating < 1600: print(3) elif rating < 1800: print(2) else: print(1)" p02689,s738344799,Accepted,"N,M = list(map(int, input().split())) Hs = list(map(int, input().split())) is_good = [True] * N for i in range(M): a,b = list(map(int, input().split())) if Hs[a-1] == Hs[b-1]: is_good[a-1] = False is_good[b-1] = False elif Hs[a-1] < Hs[b-1]: is_good[a-1] = False else: is_good[b-1] = False cnt = 0 for v in is_good: if v: cnt += 1 print(cnt)" p02911,s804338001,Accepted,"n, k, q = map(int, input().split()) l = [k-q for i in range(n)] for i in range(q): a = int(input()) - 1 l[a] += 1 for i in range(n): if l[i] > 0: print(""Yes"") else: print(""No"")" p03471,s909704258,Accepted,"N,Y=map(int,input().split()) for i in range(N+1): for m in range(N+1-i): y=N-i-m if Y==i*10000+m*5000+y*1000: print(i,m,y) exit() print(-1,-1,-1) " p02777,s745266625,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,s276694870,Accepted," def resolve(): N = int(input()) A = list(map(int, input().split())) for i in range(N): A[i] = A[i] % 4 if A[i] == 3: A[i] = 1 if A.count(2): if A.count(1) + 1 - A.count(0) <= 1: print('Yes') else: print('No') else: if A.count(1) - A.count(0) <= 1: print('Yes') else: print('No') resolve()" p03625,s501716566,Wrong Answer,"from collections import Counter def main(): n = int(input()) a = list(map(int,input().split())) a.sort(reverse=True) ac = Counter(a) i1 = 0 i2 = 0 for eac in ac: if ac[eac] >= 2: if i1 == 0: i1 = eac elif i2 == 0: i2 = eac if i1 == 0 or i2 == 0: print(0) else: print(i1*i2) if __name__ == '__main__': main()" p02755,s700928707,Accepted,"#coding utf-8 A,B=map(int,input().split()) for i in range(1009): if A==int(i*0.08): if B==int(i*0.1): print(i) exit() print(-1) " p02681,s675413299,Wrong Answer,"s = input() t = input() if s in t and s < t and len(s) <= 10: print(""Yes"") else: print(""No"")" p02848,s893100737,Wrong Answer,"N = int(input()) S = list(input()) S = ''.join([chr(abs(ord(s)+N-ord('Z'))+ord('A')) for s in S]) print(S) " p02729,s258524373,Accepted,"def f(N,M): return N*(N-1)//2+M*(M-1)//2 N,M=map(int,input().split()) print(f(N,M))" p02793,s980038685,Accepted,"def gcd(a,b): #求最大公约数 if b==0: return a else: return gcd(b,a%b) n=int(input()) mod=1000000007 s=[int(j) for j in input().split()] ans=1 for i in s: ans*=i//gcd(ans,i) print(sum(ans//i for i in s)%mod) " p02923,s151868041,Wrong Answer,"n = int(input()) m = [int(i) for i in input().split()] count = 0 ans = 0 for j in range(n-1): first = m[j] count = 0 for k in range(j,n): if first >= m[k]: count +=1 else: break first = m[k] ans = max(count,ans) print(ans-1) " p03705,s058436845,Wrong Answer,"N = list(map(int,input().split())) M = (N[2] - N[1]) * (N[0] - 2) + 1 if N[0] == 1: print(1) elif N[1] == 2: print(1) else: print(M)" p03261,s733557083,Accepted,"n = int(input()) a = [input() for _ in range(n)] a0 = a[0] for i in range(1,n): if a[i][0] == a0[-1]: flag = True else: flag = False break a0 = a[i] if len(set(a)) == len(a) and flag: print(""Yes"") else: print(""No"")" p03221,s519089528,Accepted,"from collections import defaultdict n, m = map(int, input().split()) order = [] dd = defaultdict(int) for i in range(m): p, y = map(int, input().split()) order.append([i, p, y]) # 全体を年代順にソート order.sort(key=lambda x: (x[2])) # print(order) ans = ['']*m for ii, pp, yy in order: dd[pp] += 1 ans[ii] = '{:0>6}{:0>6}'.format(pp, dd[pp]) print('\n'.join(ans)) " p03821,s620117695,Accepted,"# coding: utf-8 import math n=int(input()) A=[] B=[] for i in range(n): a, b = map(int,input().split()) A.append(a) B.append(b) cnt=0 for i in range(n-1,-1,-1): a=A[i] b=B[i] cnt += math.ceil((a+cnt)/b)*b-(a+cnt) print(cnt)" p03071,s507598664,Accepted,"a,b = map(int,input().split()) x = int(2*a-1) y = int(a+b) z = int(2*b-1) l = [] l.append(x) l.append(y) l.append(z) print(max(l))" p02584,s742249698,Wrong Answer,"x, k, d = map(int, input().split()) x = abs(x) if x>k*d: print(x-k*d) else: a = x//d if (k-a)%2==0: print(x-a*d) else: print(abs(x-a*2*d)) " p03345,s342342336,Wrong Answer,"a,b,c,k = map(int,input().split()) print((a-b)*(-1)**(k%2+1))" p02601,s390379488,Accepted,"a,b,c,k=map(int,open(0).read().split()) for i in' '*k: if a>=b:b*=2 elif b>=c:c*=2 print('NYoe s'[a 0: print(""Yes"") else: print(""No"")" p02819,s892850578,Accepted,"def 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 x = int(input()) for i in range(x,x+10000): if len(factorize(i)) == 1: print(i) break" p02641,s251909756,Accepted,"X,N=map(int,input().split()) p=list(map(int,input().split())) ans=0 for i in range(100): if X-i not in p: ans=X-i break elif X+i not in p: ans=X+i break print(ans)" p02657,s979689785,Accepted,"a,b = map(int, input().split()) print(a*b)" p02661,s012299601,Wrong Answer,"import sys readline=sys.stdin.readline N=int(readline()) A = [None] * N B = [None] * N for i in range(N): A[i],B[i] = map(int,readline().split()) A = sorted(A) B = sorted(B) if N % 2 == 1: minval = A[N // 2] maxval = B[N // 2] print(max(maxval - minval + 1,0)) else: minval = A[(N - 1) // 2] maxval = B[(N) // 2] ran = maxval - minval + 1 print((ran * (ran - 1)) // 2) " p02658,s114157831,Wrong Answer,"n = int(input()) a = list(map(int, input().split())) ans = 1 flag = True for i in range(n): ans *= a[i] if ans > 1000000000000000000: flag = False break; if flag == True: print(ans) else: print(-1) " p03427,s010960915,Accepted,"N = input() K = len(N) c = N[0] a = 0 for i in range(1,K): if N[i] != ""9"": a = 1 if a == 0: print(int(c) + 9*(K-1)) else: print(int(c) + 9*(K-1)-1) " p03998,s840648853,Wrong Answer,"S = {} S['a'] = input() S['b'] = input() S['c'] = input() next = 'a' lens = {'a':len(S['a']), 'b':len(S['b']), 'c':len(S['c'])} counts = {'a':0, 'b':0, 'c':0} while True: now = next if counts[now] == lens[now]: print(now) exit() next = S[now][counts[now]] counts[now] += 1 " p02640,s530848393,Accepted,"x,y = map(int,input().split()) for i in range(x+1): if 2*i+4*(x-i)==y: print(""Yes"") exit() print(""No"")" p02789,s643256557,Accepted,"n,m = map(int,input().split()) if n == m: print(""Yes"") else: print(""No"")" p02881,s834216099,Accepted,"import math n = int(input()) bi_factors = [] for i in range(1,int(math.sqrt(n)+1)): if n%i == 0: temp = (i,n//i) bi_factors.append(temp) inf = float('INF') ans = inf for point in bi_factors: d = point[0] + point[1] - 2 if ans > d: ans = d print(ans) " p03286,s617540017,Accepted,"n = int(input()) ansl = [] if n == 0: print(0) exit() while n != 0: if n % 2 == 1: ansl.append(""1"") n -= 1 else: ansl.append(""0"") n //= -2 print("""".join(ansl)[::-1])" p03785,s122890418,Accepted,"n, c, k= map(int, input().split()) T = [int(input()) for _ in range(n)] T.sort() bus_t = -k - 100 bus_c = c ans = 0 for t in T: bl = (bus_t + k >= t) and (bus_c + 1 <= c) if bl: bus_c += 1 continue ans += 1 bus_t = t bus_c = 1 print(ans)" p02880,s145269975,Accepted,"N = int(input()) list = list(range(1,10)) ans = 0 for i in list: for k in list: if i*k == N: ans = 1 print('Yes' if ans == 1 else 'No')" p02701,s692559026,Accepted,"N = int(input()) dic = dict() for i in range(N): dic[input()] = 1 print(len(dic))" p03835,s991495892,Accepted,"k,s=map(int,input().split()) print(len([1 for x in range(k+1) for y in range(k+1) if 0<=s-x-y<=k]))" p02923,s287527178,Accepted," n=int(input()) h=list(map(int,input().split())) score = [0]*n for i in range(n-2,-1,-1): if h[i] >= h[i+1]: score[i] = score[i+1] + 1 print(max(score))" p03761,s926133307,Accepted,"from collections import Counter n = int(input()) s = input() c = Counter(s) for i in range(n-1): s = input() s = Counter(s) for i in s: if c[i]: c[i] = min(c[i],s[i]) for i in c: if not s[i]: c[i] = 0 ans = '' for i in c: ans += i*c[i] print(''.join(sorted(ans)))" p02948,s882683120,Accepted,"import heapq n,m = map(int,input().split()) dp = [0]*(n+1) L = [] days = [] cost = [] for i in range(n): a,b = map(int,input().split()) if a > m: continue L.append([a,b]) L.sort(reverse = True) ans = 0 li = [] for i in range(1,m+1): while L and L[-1][0] <= i: (a,b) = L.pop() heapq.heappush(li,b*(-1)) if li: h = heapq.heappop(li) ans +=(-1)*h print(ans)" p02888,s389488167,Accepted,"n=int(input()) l=list(map(int,input().split())) import bisect ans=0 l.sort() for i in range(n): a=l[i]#一番短い棒を確定 for j in range(i+1,n): b=l[j]#二番目に短い棒を確定 ind=bisect.bisect_left(l,a+b)#二辺の和と同じだったら耐えないので,left ans+=max(0,ind-(j+1))#三角形の成立条件と,一番長い棒であることを考える print(ans)" p02899,s927687161,Accepted,"N = int(input()) aaa = list(map(int, input().split())) x = [(a, i) for i, a in enumerate(aaa, 1)] x.sort() ans = [] for a, i in x: ans.append(i) print(*ans) " p02627,s577574962,Accepted,"a = input() if 'A' <= a <= 'Z': print('A') else: print('a') " p03309,s402128255,Accepted,"n = int(input()) a = list(map(int,input().split())) for i in range(n): a[i] -= (i+1) a.sort() c = a[n//2] if n % 2 == 0: c = int((a[n//2] + a[n//2-1]) // 2 + 0.5) ans = 0 for i in range(n): ans += abs(a[i] - c) print(ans)" p03380,s457848295,Wrong Answer,"import bisect n = int(input()) a = list(map(int, input().split())) a.sort() M = max(a) m = M // 2 left = bisect.bisect_left(a, m) right = bisect.bisect_right(a, m) if abs(m - left) < abs(m - right): print(M, a[left]) else: print(M, a[right]) " p02792,s782189836,Accepted,"n = int(input()) cnt=[[0,0,0,0,0,0,0,0,0,0] for _ in range(10)] ans = 0 for i in range(n+1): i = list(str(i)) cnt[int(i[0])][int(i[-1])] += 1 for i in range(1, 10): for j in range(1, 10): ans += cnt[i][j] * cnt[j][i] print(ans) " p02705,s748937360,Accepted,print(2*(22/7)*int(input())) p02797,s278110142,Wrong Answer,"n, k, s = map(int, input().split()) A = [s]*k + [s+1]*(n-k) print(*A)" p02608,s083265191,Accepted,"def main(): n = int(input()) ans = [0] * n for x in range(1,100): for y in range(1,100): for z in range(1,100): m = x**2+y**2+z**2+x*y+y*z+z*x if m <= n: ans[m-1] += 1 for i in range(n): print(ans[i]) main()" p02730,s172736386,Accepted,"S = input() n = len(S) a=S[0:(n-1)//2] b=S[(n+3)//2-1:0] if S==S[::-1] and a==a[::-1] and b==b[::-1]: print(""Yes"") else: print(""No"")" p03264,s344041312,Accepted,"K = int(input()) odd = 0 even = 0 for i in range(1,K+1): if i % 2 == 0: odd += 1 else: even += 1 print(odd * even)" p03624,s421747014,Wrong Answer,"Sold = list(map(str, input())) Snew = set(Sold) alph = set(list('abcdefghijklmnopqrstuvwxyz')) if len(list(Snew-alph))==0: print('none') else: print(sorted(list(Snew-alph))[0]) " p03524,s190521912,Accepted,"s = input() A = 0 B = 0 C = 0 for x in s: if x == 'a': A += 1 elif x == 'b': B += 1 else: C += 1 l = sorted([A, B, C]) print('YES' if (l[2] <= l[1] + 1 and l[0] == l[1]) or (l[2] == l[1] and l[0] == l[1] - 1) else 'NO') " p03696,s157223209,Wrong Answer,"from itertools import groupby N = int(input()) S = input() ans = [] #S1 = groupby(S) a=0 a1=0 b=0 b1=0 S1 = groupby(list(S)) for key,group in S1: group = list(group) if list(key)==['(']: a=len(group) a1+=a else: b=len(group) b1+=b-a a1-=b S = ""(""*b1+S S = S+"")""*a1 print("""".join(S))" p03680,s967333806,Wrong Answer,"N = int(input()) A = [int(input()) for i in range(N)] B = 1 for j in(A): if j == 2: print(B) break else: B += 1 print('-1')" p02641,s308292526,Accepted,"# itne me hi thakk gaye? x, n = map(int, input().split()) arr = list(map(int, input().split())) arr.sort() if x in arr: ans = 10**9 diff = 10**9 for i in range(0, 102): if i not in arr: if(abs(x - i) < diff): diff = abs(x-i) ans = i print(ans) else : print(x)" p03759,s439959326,Accepted,"# 入力 数字3つ a, b, c = map(int, input().split()) # 柱の並び方が美しい場合 YES を、そうでない場合 NO を 1行に出力せよ。 if b-a == c-b : print(""YES"") else : print(""NO"") " p02676,s849951211,Wrong Answer,"K = int(input()) S = input() if len(S) >= K: print(S[:K] + ""..."") else: print(S)" p03380,s233653349,Wrong Answer,"import sys from scipy.misc import comb import bisect input = sys.stdin.readline N = int(input()) A = sorted(list(map(int, input().split()))) l = bisect.bisect_left(A,A[-1]//2)-1 r = l+1 if r==N-1 or comb(A[-1],A[l]) > comb(A[-1],A[r]): print(A[-1],A[l]) else: print(A[-1],A[r])" p02691,s770443178,Accepted,"#!/usr/bin/env python3 import collections N = int(input()) A = list(map(int, input().split())) L = [] R = [] for i in range(N): L.append(i+A[i]) R.append(i-A[i]) C_L = collections.Counter(L) C_R = collections.Counter(R) ans = 0 for l, t in C_L.items(): if l in C_R: ans += t*C_R[l] print(ans) " p02677,s393554466,Accepted,"[A,B,H,M] = list(map(int,input().split())) X = (H+M*1/60)*30 Y = M*6 Z = min(abs(X-Y),abs(X+360-Y),abs(Y+360-X)) import math cos = math.cos(math.radians(Z)) print((A**2+B**2-2*A*B*cos)**0.5) " p02577,s963343168,Wrong Answer,"N = int(input()) sum_N = 0 while N >= 10: print(N) sum_N += N % 10 N = N //10 if (sum_N+N) % 9 == 0: print('Yes') else: print('No') " p02866,s234273296,Accepted,"from collections import Counter N = int(input()) D = list(map(int, input().split())) C = Counter(D) if D[0] > 0 or C[0] > 1: print(0) exit(0) mod = int(998244353) ans = 1 for i in range(2,max(D)+1): ans = (ans * (C[i-1] ** C[i]) % mod) % mod print(ans)" p02911,s778043493,Accepted,"# -*- coding: utf-8 -*- n, k, q = map(int, input().split()) li = [0]*n for i in range(q): a = int(input()) li[a-1] += 1 for i in range(n): if li[i] > q-k: print(""Yes"") else: print(""No"") " p03309,s212069613,Accepted,"N=int(input()) A=list(map(int,input().split())) B=[A[i]-i-1 for i in range(N)] B.sort() if N%2==1: med=B[N//2] else: med=(B[N//2-1]+B[N//2])//2 ans=0 for i in range(N): ans+=abs(B[i]-med) print(ans)" p03623,s523774509,Wrong Answer,"x,a,b=map(int,input().split()) if x-a>k) & 1: skill_li += li[k] sum_price += C[k] if all(skill_li>=X): counter.append(sum_price) if len(counter)==0: print(-1) else: print(min(counter))" p02548,s408012126,Accepted,"import math def check(x): return math.sqrt(x) == int(math.sqrt(x)) and x != 1 n = int(input()) a = [1]* (n +1); for i in range(2, n+1): for j in range(i, n+1, i): if j // i != i: a[j] += 1 else: a[j] += 2 ans = 0 for i in range(1, n): ans += a[n - i] if not check(n-i) else a[n-i] - 1 print(ans) " p03136,s168482452,Accepted,"n=int(input()) l=list(map(int,input().split())) if 2* max(l) < sum(l): print(""Yes"") else: print(""No"") " p03131,s898382130,Accepted,"k, a, b = map(int, input().split()) ans = k + 1 if a <= k: ans2 = a k -= a - 1 if k % 2 == 1: ans2 += 1 ans2 += (b - a) * (k // 2) print(max(ans, ans2))" p02607,s973709329,Accepted,"N = int(input()) nums = list(map(int, input().split())) cnt = 0 for i in range(N): num = i + 1 if (num % 2 == 1 and nums[i] % 2 == 1): cnt += 1 print(cnt)" p02820,s789968220,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)" p03324,s298366355,Wrong Answer,"D, N = map(int, input().split()) if D == 0 and N < 100: print(N) elif D == 0 and N == 100: print(101) elif D == 1 and N < 100: print(N * 100) elif D == 1 and N == 100: print(N) elif D == 2 and N < 100: print(N * 100 * 100) elif D == 2 and N == 100: print(N)" p02988,s064817919,Wrong Answer,"n=int(input()) p=list( map(int, input().split())) ans=0 for i in range(0,n-1): if (p[i-1]p[i]>p[i+1]): ans=ans+1 print(ans)" p02797,s699566220,Wrong Answer,"n,k,s = map(int,input().split()) li = [s]*k + [(s+10000)]*(n-k) print(*li)" p03665,s711552810,Wrong Answer,"n,m = map(int, input().split()) n-=1 if n == 0: print(0) else: print(pow(2,n))" p02677,s847295628,Wrong Answer,"import math a,b,h,m = map(int,input().split()) c = math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(abs(30*h-6*m)))) print(c)" p02633,s055319227,Accepted,"import math X = int(input()) for k in range(1, 361): if (k * X) % 360 == 0: print(k) break" p03352,s992244146,Wrong Answer,"n = int(input()) a=0 if n > 1: a = n//2 else: a = n while True: if a**2 <= n: print(a**2) break a -= 1" p02731,s431469953,Accepted,"l = int(input()) print(l**3/27)" p03486,s665876358,Accepted,"# Problem https://atcoder.jp/contests/abc082/tasks/abc082_b # Python 3rd Try yes = ""Yes"" no = ""No"" def solver(sStr,tStr): ssStr = ''.join(sorted(sStr)) srtStr = ''.join(sorted(tStr,reverse=True)) result = yes if ssStr < srtStr else no return result if __name__ == ""__main__"": s = input() t = input() answer = solver(s,t) print(answer) " p03012,s837463471,Accepted,"n=int(input()) l=list(map(int,input().split())) ans=100000 for i in range(n-1): ans=min(ans,abs(sum(l[:i+1])-sum(l[i+1:]))) print(ans)" p02717,s864590423,Accepted,"X,Y,Z = map(int,input().split()) print(Z,X,Y)" p03380,s438301066,Wrong Answer,"import bisect N = int(input()) l = list(map(int,input().split())) l.sort() r = bisect.bisect_right(l, l[-1]/2) a = l[r] if r+1==N: b = l[r-1] else: b = l[r+1] a2 = min(a,l[-1]-a) b2 = min(b,l[-1]-b) if a2 >= b2: c = a else: c = b print( int( l[-1] ) ,int(c)) " p02699,s598624820,Accepted,"S,W=map(int,input().split()) print(""safe"" if S>W else ""unsafe"")" p03448,s802018279,Accepted,"a = int(input()) b = int(input()) c = int(input()) x = int(input()) cnt = 0 for a_ in range(a+1): for b_ in range(b+1): for c_ in range(c+1): can = 500*a_ + 100*b_ + 50*c_ if x == can: cnt += 1 print(cnt)" p03665,s793349896,Accepted,"n,p = map(int,input().split()) a = list(map(int,input().split())) cnt = 0 for x in a: if x%2:cnt+=1 if cnt == 0: if p:ans = 0 else:ans = 2**n else: ans = 2**(n-1) print(ans)" p02802,s349579670,Accepted,"n,m = map(int,input().split()) ac, wa=[False]*n,[0]*n for i in range(m): p,s = input().split() p=int(p) if s=='AC': ac[p-1]=True elif (s=='WA') and (ac[p-1]==False): wa[p-1]+=1 penalty, clear=0,0 for i,tf in enumerate(ac): if tf: penalty += wa[i] clear += 1 print('%d %d'%(clear,penalty))" p03659,s005915554,Accepted,"n = int(input()) A = list(map(int, input().split())) if n == 2: print(abs(A[0]-A[1])) exit() cum_sum = [0] for a in A: cum_sum.append(cum_sum[-1]+a) ans = 10**9+1 for x in cum_sum[1:-1]: y = cum_sum[-1] - x ans = min(ans, abs(x-y)) print(ans)" p02786,s643634225,Wrong Answer,"h=int(input()) c=0 while h>0: h=(h//2) c+=1 print((c*2)+1)" p04030,s932286760,Wrong Answer,"def solve(): s = list(input()) if s[0] == 'B': s[0] = '' for i in range(1, len(s)): if s[i] == 'B': s[i-1], s[i] ='', '' return ''.join(s) print(solve()) " p03665,s295809048,Wrong Answer,"import sys def input(): return sys.stdin.readline().strip() N, P = map(int, input().split()) A = list(map(int, input().split())) odd = sum([a % 2 for a in A]) even = len(A) - odd ans = (2 ** even) * (2 ** (odd - 1)) " p03962,s896406100,Accepted,"a = list(map(int,input().split())) print(len(set(a)))" p02772,s099678840,Accepted,"n = int(input()) a = list(filter(lambda x : x & 1 or x % 3 == 0 or x % 5 == 0, map(int, input().split()))) print('APPROVED' if len(a) == n else 'DENIED')" p02695,s203317916,Accepted,"n, m, q = map(int, input().split()) queries = [tuple(map(int, input().split())) for _ in range(q)] 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 def f(p): if len(p) == n: return calc_score(p) ans = 0 l = p[-1] if len(p) else 1 for x in range(l, m+1): p.append(x) ans = max(ans, f(p)) p.pop() return ans print(f([])) " p02713,s614143373,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(gcd(i,j,l)) print(ans)" p02989,s562761722,Wrong Answer,"N = int(input()) p = [int(s) for s in input().split()] print(sum([ sorted([p1,p2,p3])[1] == p1 for p1,p2,p3 in zip(p[2:],p[1:(N-1)],p[:(N-2)])]))" p02657,s198983916,Accepted,"A,B = input().split() print(int(A)*int(B)) " p03607,s610509478,Accepted,"from collections import defaultdict cnt = defaultdict(int) n = int(input()) for i in range(n): value = int(input()) cnt[value] += 1 ret = 0 for c in cnt.values(): if c % 2 == 1: ret += 1 print(ret)" p03455,s357251473,Accepted,"a,b = map(int,input().split()) if (a*b)%2 == 0: print(""Even"") else: print(""Odd"")" p03000,s593951787,Wrong Answer,"import numpy as np n, x = map(int, input().split()) L = list(map(int, input().split())) CS_L = np.cumsum(L).tolist() ans = len([l for l in CS_L if l <= x]) print(ans)" p02952,s907570730,Accepted,"N = input() nlen = len(N) n = int(N) j = nlen ans = 0 while j > 0: if j % 2 == 0: j -= 1 continue else: if j == nlen: ans += n - 10**(j-1) + 1 else: ans += 10**j - 10**(j-1) j -= 1 print(ans)" p02946,s778880954,Wrong Answer,"K, X = map(int,input().split()) LX = [] for i in range(X-K+1, X+K): LX.append(i) print(LX)" p03317,s653144381,Accepted,"import math N, K = list(map(int,input().split())) print(math.ceil((N - 1) / (K - 1)))" p03836,s844961656,Accepted,"sx,sy,tx,ty = map(int, input().split()) ans = """" ans += ""U""*(ty-sy) ans += ""R""*(tx-sx) ans += ""D""*(ty-sy) ans += ""L""*(tx-sx) ans += (""L""+""U""*(ty-sy+1)+""R""*(tx-sx+1)+""D"") ans += (""R""+""D""*(ty-sy+1)+""L""*(tx-sx+1)+""U"") print(ans)" p03106,s465068722,Accepted,"# B k-th common Divisor a, b, k = map(int, input().split()) ans = [] for i in range(1, 101): if a % i == 0: if b % i == 0: ans.append(i) ans = sorted(ans) print(ans[-k]) " p03479,s144355148,Accepted,"x,y = map(int,input().split()) ans = 0 while x <= y: x *= 2 ans += 1 print(ans)" p03456,s510262310,Accepted,"a,b=map(str,input().split()) c=int(a+b) print(""Yes"" if (int(c**0.5))**2==c else ""No"") " p02687,s834457217,Accepted,"date=input() if date==""ABC"": print(""ARC"") elif date==""ARC"": print(""ABC"") " p03219,s191727524,Accepted,"a,b = map(int, input().split()) print(a + b//2)" p02594,s530668457,Accepted,"import sys def _i(): return int(sys.stdin.readline().strip()) def main(): x = _i() return ""Yes"" if x >= 30 else ""No"" if __name__ == ""__main__"": print(main()) " p02989,s234429968,Wrong Answer,"n=int(input()) d=list(map(int,input().split())) ans=0 di=sorted(d) half1=di[(n-1)//2] half2=di[(n-1)//2+1] ans=half2-half1 if ans>1: print(ans) else: print(0)" p03475,s430200009,Accepted,"n = int(input()) CSF = [list(map(int, input().split())) for i in range(n-1)] ans = [0 for i in range(n)] for i in range(n): cnt = 0 for j in range(i, n-1): c, s, f = CSF[j][0], CSF[j][1], CSF[j][2] if cnt < s: cnt = s elif cnt % f != 0: cnt = (cnt//f + 1) * f cnt += c ans[i] += cnt for a in ans: print(a) " p03797,s921626903,Accepted,"s, c = map(int, input().split()) i = min(s, c//2) m = i s -= i c -= i*2 if s == 0: m += c//4 # print(s,c) print(m) " p03680,s038441684,Accepted,"import sys from collections import deque, Counter def I(): return int(sys.stdin.readline().rstrip()) if __name__=='__main__': n = I() l = [] for _ in range(n): l.append(I()) c = Counter() now = 0 for i in range(1,n+1): now = l[now]-1 c[now] += 1 if now==1: print(i) exit() if c[now]==2: print(-1) exit() exit()" p03435,s413961435,Accepted,"def solve(): c = [list(map(int, input().split())) for _ in range(3)] if c[0][0] + c[1][1] + c[2][2] == c[0][1] + c[1][2] + c[2][0] == c[0][2] + c[1][0] + c[2][1]: print('Yes') else: print('No') if __name__ == '__main__': solve() " p02829,s404146298,Accepted,"a = int(input()) b = int(input()) if (a == 1 and b == 2) or (a == 2 and b == 1): print(3) elif (a == 2 and b == 3) or (a == 3 and b == 2): print(1) else: print(2) " p02723,s061256083,Accepted,"S = input() if S[2] == S[3] and S[4] == S[5]: print('Yes') else: print('No') " p03030,s316800416,Accepted,"def INT(): return int(input()) def MI(): return map(int, input().split()) def LI(): return list(map(int, input().split())) N = INT() ans = {} for i in range(N): S, P = input().split() P = int(P) if S in ans.keys(): ans[S].append([P, i + 1]) ans[S].sort(key = lambda x : x[0], reverse = True) else: ans[S] = [[P, i + 1]] store = list(ans.keys()) store.sort() for s in store: for p in ans[s]: print(p[1])" p02970,s030572283,Accepted,"N, D = map(int, input().split()) R = 0 for i in range(1,N+1): R += 2 * D + 1 if N <= R: print(i) exit()" p03795,s027629102,Accepted,"n=int(input()) print(n*800-n//15*200)" p03037,s257900899,Accepted,"#import math #import bisect #import numpy as np #import itertools #import copy import sys ipti = sys.stdin.readline MOD = 10 ** 9 + 7 INF = float('INF') sys.setrecursionlimit(10 ** 5) def main(): n, m = list(map(int,ipti().split())) l = [0] * m r = [0] * m for i in range(m): l[i], r[i] = list(map(int,ipti().split())) lower = -INF upper = INF for i in range(m): lower = max(lower, l[i]) upper = min(upper, r[i]) print(max(0, upper-lower+1)) if __name__ == '__main__': main()" p02860,s653960663,Accepted,"n = int(input()) s = input() if n%2 == 0 and s[:int(n/2)] == s[int(n/2):] : print('Yes') else: print('No') " p03208,s833476948,Accepted,"N, K = map(int, input().split()) H = [int(input()) for _ in range(N)] H = sorted(H) ans = float('Inf') for i in range(N - (K - 1)): ans = min(ans, H[i + (K - 1)] - H[i]) print(ans)" p03760,s674054114,Accepted,"print("""".join(sum(zip(input(),input()+"" ""),())))" p03998,s023958133,Accepted,"s = [list(reversed(input())) for _ in range(3)] now = 0 turn = {""a"": 0, ""b"": 1, ""c"": 2} while True: if len(s[now]) == 0: break x = s[now].pop() now = turn[x] print(""ABC""[now]) " p03001,s745147066,Wrong Answer,"w,h,x,y=map(int,input().split()) p=w*h/2 a=1 if w*y==x*h or x*h+y*w==w*h else 0 print(p,a) " p02706,s343026462,Accepted,"N,M = map(int, input().split()) M_list = input().split() for i in range(M): N -= int(M_list[i]) if N >= 0: print(N) else: print(-1)" p02783,s906556886,Wrong Answer,"a,b=input().split() a=int(a) b=int(b) if a/b <= 1: print(1) else : print(int(a/b)+1)" p03013,s012655600,Accepted,"N, M = map(int, input().split()) A = set([int(input()) for _ in range(M)]) mod = 1000000007 dp = [0] * (N + 2) dp[N] = 1 # GOAL for i in range(N-1, -1, -1): if i not in A: dp[i] = dp[i+1] + dp[i+2] print(dp[0] % mod) " p03339,s000607246,Accepted,"n = int(input()) s = input() t1 = [0]*n t2 = [0]*n for i in range(1, n): t1[i] = t1[i-1] + (s[i-1] == 'W') t2[n-i-1] = t2[n-i] + (s[n-i] == 'E') ans = n for i in range(n): ans = min(ans, t1[i] + t2[i]) print(ans)" p03241,s172776640,Accepted,"N, M = map(int, input().split()) ans = -float('inf') for i in range(1, int(M ** .5 ) + 1): if M % i == 0: if N <= i: ans = max(ans, M // i) if N <= M // i: ans = max(ans, i) print(ans)" p03419,s006673646,Accepted,"h,w = map(int,input().split("" "")) if h == 1 and w == 1: print(1) elif h == 1: print(w - 2) elif w == 1: print(h - 2) else: print((h - 2) * (w - 2)) " p03778,s195525761,Accepted,"W,a,b=map(int,input().split()) if a<=b and a+W >= b: print(0) exit() if a=b and b+W >= a: print(0) exit() if a>b: print(a-(b+W)) " p03001,s690747477,Wrong Answer,"W,H,x,y=map(int,input().split()) S = (W*H)/2 if x == W//2 and y == H//2: print(S,1) else: print(S,0)" p02859,s930698999,Wrong Answer,"r=int(input()) print(r^2)" p02546,s363741857,Accepted,"s = input() if(len(s)==0): print("""") if(s[-1] == ""s""): print(s+""es"") if(s[-1] != ""s""): print(s+""s"")" p02772,s612225541,Accepted,"n=int(input()) list=[[0]*n] list=input().split() g=0 c=0 for i in range(n): list[i]=int(list[i]) if list[i]%2==0: g+=1 if list[i]%3==0 or list[i]%5==0: c+=1 if g==c: print(""APPROVED"") else: print(""DENIED"") " p02790,s480476351,Wrong Answer," a,b=map(int,input().split()) c=a>b for i in range(a if c else b): print(b,end="""") print() " p02547,s329335594,Accepted,"N = int(input()) dice = [tuple(map(int, input().split())) for _ in range(N)] count = 0 for d1, d2 in dice: if d1 != d2: count = 0 continue else: count += 1 if count == 3: print('Yes') break else: print('No')" p04033,s079686474,Accepted,"a, b = map(int, input().split()) if a*b < 0: print(""Zero"") elif b < 0 and (b-a)%2 == 0: print(""Negative"") else: print(""Positive"")" p02612,s660457231,Accepted,"n = int(input()) i = 0 while i*1000=a and c<=b else ""NO"")" p02833,s524248608,Accepted,"N = int(input()) n = N if N % 2 == 1: # 奇数のときは偶数がかけられていないので0は並ばない. print(0) else: # 1回分は割り算しておく.最初に2で割ることによって1,2,3,4,5,6,7,8...という数列の積になる. cnt = N // 10 N //= 10 while N > 0: cnt += N // 5 N //= 5 print(cnt)" p02836,s188003739,Accepted,"s = input() n = len(s) ans = 0 for i in range(n): if s[i]!=s[n-1-i]: ans+=1 print(ans//2)" p02843,s630939126,Wrong Answer,"import itertools x = int(input()) if x >= 2500: print(1) exit() cnt = 0 for i in range(1, 20): for v in itertools.combinations_with_replacement([100, 101, 102, 103, 104, 105], i): if sum(v) == x: print(1) exit() print(0)" p03252,s862740461,Accepted,"S = input() T = input() U = [[i,j] for i,j in zip(S,T)] U.sort() s = U[0][0] t = U[0][1] for i,j in U: if i != s: s = i t = j elif j != t: print(""No"") exit() U.sort(key=lambda x:x[1]) s = U[0][0] t = U[0][1] for i,j in U: if j != t: s = i t = j elif i != s: print(""No"") exit() print(""Yes"")" p03474,s911772267,Accepted,"A, B = map(int, input().split()) S = input() res = 'Yes' if not S[:A].isdecimal() or not S[A+1:].isdecimal() or S[A] != '-': res = 'No' print(res)" p02756,s356252460,Accepted,"from collections import deque s=deque(list(input())) q=int(input()) l = [list(input().split()) for i in range(q)] c=0 for i in range(q): if l[i][0]==""1"": c+=1 elif c%2==0 and l[i][1]==""1"": s.appendleft(l[i][2]) elif c%2==0: s.append(l[i][2]) elif c%2==1 and l[i][1]==""1"": s.append(l[i][2]) else: s.appendleft(l[i][2]) s=list(s) if c%2==1: s=s[::-1] print(*s, sep="""")" p02795,s037319414,Accepted,"import sys import math input = sys.stdin.readline H = int(input()) W = int(input()) N = int(input()) a = max(H,W) print(math.ceil(N/a))" p02820,s931420583,Wrong Answer,"N, K = map(int, input().split(' ')) R, S, P = map(int, input().split(' ')) T = list(input()) print(T) score = 0 A = T for i in range(N-K): if T[i] == T[i+K]: A[i+K] = 'a' for i in range(N): if A[i] == 'r': score += P elif A[i] == 's': score += R elif A[i] == 'p': score += S print(score)" p03416,s289351355,Wrong Answer,"A, B = map(int, input().split()) count = 0 for x in range(A, B, 1): letter = str(x) if letter[0] == letter[4] and letter[1] == letter[3]: count += 1 print(count) " p03698,s150732280,Accepted,"S = list(input()) print(""yes"" if len(S) == len(set(S)) else ""no"")" p02583,s936327593,Accepted,"N = int(input()) L = list(map(int, input(). split())) count = 0 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])and(L[j] + L[k] > L[i])and(L[k] + L[i] > L[j])and(L[i] != L[j])and(L[j] != L[k])and(L[k] != L[i]): count += 1 else: continue print(count)" p03127,s975341642,Accepted,"def gcd(x,y): if y==0: return x else: return gcd(y,x%y) N=int(input()) A=list(map(int,input().split())) ans = A[0] for a in A: ans = gcd(ans,a) print(ans)" p02780,s382998509,Accepted,"def main(): N, K = map(int, input().split()) P = list(map(int, input().split())) E = list(map(lambda x: (1+x)/2, P)) tmp = sum(E[:K]) ans = tmp for i in range(K, N): tmp += E[i] - E[i-K] ans = max(ans, tmp) print(ans) if __name__ == ""__main__"": main() " p03126,s047303299,Accepted,"N, M = map(int, input().split()) ans = M A = set(list(map(int, input().split()))[1:]) for i in range(N-1): tmp = set(list(map(int, input().split()))[1:]) A = A & tmp print(len(A)) " p03774,s320553903,Accepted,"N, M = map(int,input().split()) students = [] points = [] for _ in range(N): students.append(list(map(int,input().split()))) for _ in range(M): points.append(list(map(int,input().split()))) for i in range(N): MIN = 10 ** 10 index = -1 for j in range(M): if MIN > abs(students[i][0] - points[j][0]) + abs(students[i][1] - points[j][1]): MIN = abs(students[i][0] - points[j][0]) + abs(students[i][1] - points[j][1]) index = j print(index + 1)" p02879,s562606799,Accepted,"a,b = map(int,input().split()) if (a>9) or(b>9): print(-1) else: print(a*b)" p02778,s390370885,Accepted,"a=input() out='' for i in range(len(a)): out+='x' print(out)" p02723,s982294967,Accepted,"a,b,c,d,e,f = input() if c == d and e == f : print(""Yes"") else: print(""No"")" p03377,s116620667,Accepted,"a,b,x=map(int,input().split()) print(""YES""if (a<=x)&(x<=a+b) else ""NO"")" p03456,s187828445,Accepted,"a, b = map(str, input().split()) n = int(a+b) if (n**.5).is_integer(): print('Yes') else: print('No') " p02678,s676460398,Accepted,"from collections import deque N, M = map(int, input().split()) rooms = [[] for _ in range(N)] for _ in range(M): A, B = map(int, input().split()) rooms[A - 1].append(B - 1) rooms[B - 1].append(A - 1) signposts = [None] * N que = deque([0]) while que: n = que.popleft() for room in rooms[n]: if signposts[room] is None: que.append(room) signposts[room] = n + 1 if None in signposts: print(""No"") else: signposts[0] = ""Yes"" for s in signposts: print(s) " p02621,s395530235,Wrong Answer,"#%% x = int(input()) sum=x for i in range(3): sum+=pow(x,2) print(sum) " p02577,s669442344,Accepted,"n=[int(c) for c in input()] if sum(n)%9==0: print('Yes') else: print('No')" p03013,s147924791,Accepted,"from collections import deque def main(): N,M,*A=map(int, open(0).read().split()) mod=10**9+7 dp = [0] * (N+1) A=deque(A+[N+1]) tmp=A.popleft() dp[:2] = [1, 1 if tmp!=1 else 0] if tmp==1: tmp=A.popleft() for i in range(2, N+1): if i==tmp: tmp=A.popleft() continue dp[i] = (dp[i-2] + dp[i-1])%mod print(dp[N]) main() " p02647,s156913439,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) isMax = False while K > 0 and not isMax: isMax = True B = [0] * N for i, d in enumerate(A): l = max(0, i - d) B[l] += 1 r = i + d + 1 if r < N: B[r] -= 1 for i in range(N - 1): isMax &= (B[i] >= N) B[i + 1] += B[i] A = B K -= 1 print(*A[:N]) " p02696,s230415974,Accepted,"a, b, n = map(int, input().split()) temp_prev = 0 temp_curr = 0 x = min(n, b-1) while x <= n: temp_prev = temp_curr temp_curr = int(a * x / b) - a * int(x / b) x += 1.0 if temp_curr <= temp_prev: break print(max(temp_curr, temp_prev))" p03804,s911148572,Accepted,"n, m, *d = open(0).read().split() n, m = int(n), int(m) r = range(n - m + 1) print([""No"",""Yes""][any(d[n:] == [t[j:j+m] for t in d[i:i+m]] for i in r for j in r)])" p03274,s261496034,Accepted,"import sys N, K, *X = map(int, sys.stdin.read().split()) ans = 10**20 for l, r in zip(X, X[K-1:]): if l*r < 0: dist = min(-2*l + r, 2*r - l) else: dist = max(abs(l), abs(r)) if ans > dist: ans = dist print(ans) " p02621,s701611725,Accepted,"import itertools import math import fractions import functools import copy from collections import deque from functools import reduce from decimal import Decimal def main(): n = int(input()) print(n+n**2+n**3) if __name__ == '__main__': main() " p03087,s241793879,Accepted,"import sys input=sys.stdin.readline n,q=map(int,input().split()) s=input().rstrip() 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])" p02879,s832472758,Accepted,"A, B = map(int, input().split()) if A <= 9 and B <= 9: print(A*B) else: print(-1)" p02789,s603219642,Accepted,"N, M = map(int, input().split()) if N == M: print('Yes') else: print('No') " p02731,s702378052,Accepted,"l=int(input()) print(l*l*l/27)" p03073,s829154205,Accepted,"s=input() ans=len(s) for i in range(2): cnt=0 for j in range(len(s)): if j % 2 == 0 and s[j]!=str(i): cnt+=1 if j % 2 == 1 and s[j]==str(i): cnt+=1 ans=min(cnt,ans) print(ans)" p03479,s654990026,Accepted,"# -*- coding: utf-8 -*- # C - Multiple Gift # 標準入力の取得 X,Y = list(map(int, input().split())) # 求解処理 # Xをどんどん2倍していき、それがYを超えるまでやる max_length = 0 while X <= Y: max_length += 1 X *= 2 # 結果出力 print(max_length)" p02848,s160267015,Accepted,"n = int(input()) s = input() ans = '' for ss in s: a = ord(ss) - ord('A') a += n a %= 26 c = chr(a + ord('A')) ans += c print(ans)" p02639,s537683562,Accepted,"x=list(input().split()) for i in range(len(x)): if(x[i]==""0""): print(i+1)" p02802,s718133301,Accepted,"import sys input = sys.stdin.readline n, m = map(int, input().split()) wa = 0 marked = [0 for _ in range(n)] cnt = [0 for _ in range(n)] for i in range(m): x, s = map(str, input().split()) x = int(x) - 1 if s == ""AC"": if marked[x] == False: wa += cnt[x] marked[x] = True else: cnt[x] += 1 print(sum(marked), wa)" p02711,s121329859,Wrong Answer,"i = input() i = int(i) flg = False while i != 0: check = i % 10 if check == 7: flg = True break i = i / 10 if flg == True: print('Yes') else: print('No')" p03803,s583390665,Accepted,"a, b = map(int, input().split()) a -= 2 b -= 2 if a % 14 > b % 14: print(""Alice"") elif a % 14 < b % 14: print(""Bob"") else: print(""Draw"") " p02682,s672732069,Accepted,"a,b,c,k=map(int,input().split()) ans=0 if k ansc: ansc = cnt ans = i print(ans)" p03943,s820795195,Accepted,"# a,b,cの袋の中のキャンディーの個数を整数で入力 a,b,c = map(int,input().split()) # 袋から出さずに2つの同じ数に分けられるならYes、ダメならNo if a + b == c or a + c == b or b + c ==a: print(""Yes"") else: print(""No"")" p03329,s840156726,Wrong Answer,"from collections import defaultdict, Counter, namedtuple, deque import itertools import functools import bisect import heapq import math from fractions import gcd NN = 202020 MOD = 10**9+7 INF = float(""inf"") n = int(input()) min_time = n for i in range(n): v6, v9 = i, n-i count = 0 while v6 > 0: count += v6 % 6 v6 //= 6 while v9 > 0: count += v9 % 9 v9 //= 9 min_time = min(min_time, count) print(min_time) " p02982,s176838683,Accepted,"import math N,D=map(int,input().split()) X=[] for i in range(N): x=list(map(int,input().split())) X.append(x) res=0 for i in range(N-1): for j in range(i+1,N): dist=0 for d in range(D): dist+=(X[i][d]-X[j][d])**2 dist=math.sqrt(dist) if dist==int(dist): res+=1 print(res)" p03206,s055595366,Accepted,"D = 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"")" p02628,s465309650,Accepted,"n,k = map(int,input().split()) p = list(map(int,input().split())) s = 0 p = sorted(p) for i in range(k): s += p[i] print(s) " p02659,s880465188,Accepted,"from decimal import * a, b = map(Decimal, input().split()) print(int(a * b))" p02748,s459610785,Wrong Answer,"A,B,M = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) t = [0] * M x = [0] * M y = [0] * M for i in range(M): t[i], x[i], y[i] = map(int, input().split()) p=int() q=int() p=a[0]+b[0] for i in a: for s in b: #if i==: #else : q=i+s if qYmax: Ymax = Y print(x) print(Ymax)" p02554,s336013588,Accepted,"n=int(input()) ans=10**n-2*(9**n)+8**n ans=ans%1000000007 print(ans)" p02682,s354444836,Wrong Answer,"a=input().split() pl1=int(a[0]) pl0=int(a[1]) pl_1=int(a[2]) draw=int(a[3]) #print(pl1,pl0,pl_1,draw) if(pl1+pl0>=draw): print(pl1) else: all_card=pl1+pl0+pl_1 #print(all_card) draw_pl_1=all_card-draw #print(draw_pl_1) print(pl1-draw_pl_1) " p03352,s812109822,Accepted,"a = int(input()) ans = 0 i = 1 while i*i <= a: for j in range(1, 1000): if i**j <= a and ans < i**j: ans = i**j if i**j > a: break; i += 1 print(ans)" p03455,s978409652,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 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 a,b = I() ans = a*b if a % 2== 0: print(""Even"") else: print(""Odd"") " p02765,s539261052,Accepted,"input_data = input().split() N = int(input_data[0]) R = int(input_data[1]) if N >= 10 : print(R) else: print(R+100*(10-N))" p02658,s349883230,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()" p02699,s377770678,Accepted,"S, W = map(int, input().split()) if W >= S: ans = 'unsafe' else: ans = 'safe' print(ans) " p02641,s085440014,Wrong Answer,"x,n=map(int,input().split()) if n==0: print(x) else: a=list(map(int,input().split())) for i in range(100): if x-i not in a: ans=x-1 break if x+i not in a: ans=x+i break print(ans)" p02819,s845480105,Accepted,"import math X = int(input()) def is_prime(n): if n == 1: return False for k in range(2, int(math.sqrt(n)) + 1): if n % k == 0: return False return True for i in range(10**7): if i < X: continue elif is_prime(i) is True: print(i) exit() " p02910,s167575522,Wrong Answer,"s = input() for i in range(len(s)): if (i+1)% 2 == 0: if s[i] == ""R"": print(""No"") exit() else: if s[i] == ""L"": print(""No"") exit() print(""Yes"") " p03639,s462560454,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() a = rl() cnt = 0 for i in a: if i%4 == 0: cnt += 1 if math.ceil(n/3) <= cnt: print('Yes') else: print('No') " p03485,s227758041,Accepted,"import math a,b = map(int,input().split()) print(math.ceil((a + b)/2))" p02600,s823480412,Accepted,"import sys input = sys.stdin.readline 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)" p03557,s287796813,Accepted,"#!/usr/bin/env python3 def main(): from bisect import bisect, bisect_left N = int(input()) A = sorted([int(x) for x in input().split()]) B = sorted([int(x) for x in input().split()]) C = sorted([int(x) for x in input().split()]) print(sum([bisect_left(A, b) * (N - bisect(C, b)) for b in B])) if __name__ == '__main__': main() " p02778,s700851492,Wrong Answer,"s = input() print(['x']*len(s)) " p02663,s691759263,Accepted,"h1, m1, h2, m2, k = map(int, input().split()) t1 = h1 * 60 + m1 t2 = h2 * 60 + m2 print(t2-t1 - k)" p02584,s988412170,Wrong Answer,"x, k, d = map(int, input().split()) for i in range(k): if abs(x - d) > abs(x + d): x = x + d else: x = x - d print(x)" p02554,s767947735,Accepted,"n = int(input()) mod = 10 ** 9 + 7 print((pow(10, n, mod) - pow(9, n, mod) * 2 + pow(8, n, mod)) % mod)" p03644,s968277042,Accepted,"n=int(input()) m = 0 i = 0 while 2**i <= n: m = max(m, 2**i) i += 1 print(m)" p03657,s572659330,Wrong Answer,"A, B = map(int, input().split()) if A%3 == 0 or B%3 == 0 or (A+B)%3 == 0: r = ""possible"" else: r = ""impossible"" print(r)" p03137,s910680872,Wrong Answer,"def solve(n, m, X): X.sort() distances = sorted(X[i] - X[i - 1] for i in range(1, m)) return sum(distances[:m - n]) _n, _m = map(int, input().split()) _X = list(map(int, input().split())) print(solve(_n, _m, _X))" p02682,s603963354,Accepted,"A, B, C, K = map(int, input().split()) print(min(K, A)-max(0, K-A-B)) " p03127,s696520115,Accepted,"import math N = int(input()) A = list(map(int,input().split())) ans = 0 for a in range(N): ans = math.gcd(ans,A[a]) print(ans)" p03994,s488143192,Accepted,"s = list(input()) n = len(s) k = int(input()) for i in range(n): if k > 0 and i == n-1: x = ord(s[i])-ord(""a"") s[i] = chr((k+x)%26+ord(""a"")) break if s[i] == ""a"": continue x = ord(s[i])-ord(""a"") if k >= 26-x: s[i] = ""a"" k -= 26-x print(*s,sep="""")" p04012,s593265538,Accepted,"w = input() char = [chr(ord('a') + i) for i in range(26)] for c in char: if w.count(c) % 2 != 0: print('No') break else: print('Yes')" p03137,s221843835,Accepted,"n,m = list(map(int, input().split())) x = list(map(int, input().split())) x.sort() total = max(x) - min(x) if n >= m: print(0) elif n == 1: print(total) else: gap = [] for i,j in zip(x, x[1:]): gap.append(j-i) gap.sort(reverse=True) print(total - sum(gap[:n-1]))" p02624,s372011284,Accepted,"n = int(input()) res = 0 for i in range(1, n+1): res += (i + i*(n//i)) * (n//i) // 2 print(res)" p03548,s634494518,Wrong Answer,"x, y, z=map(int, input().split()) print((x-y)//(y+z)+1)" p02912,s481193299,Accepted,"#141_D 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): x=heapq.heappop(a) heapq.heappush(a,-(-x//2)) print(-sum(a))" p03479,s412336583,Accepted,"x, y = map(int, input().split()) count = 0 while x <= y: count += 1 x *= 2 print(count)" p02952,s146871463,Accepted,"N = int(input()) cnt = 0 for i in range(1,N+1): if len(str(i)) % 2 == 1: cnt += 1 print(cnt) " p02554,s423983240,Accepted,"# -*- coding: utf-8 -*- import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines MOD = 10**9+7 N = int(readline()) if N == 1: print(0) sys.exit() a = pow(10,N,MOD) b = pow(9,N,MOD) c = pow(8,N,MOD) ans = ((a-b)*2%MOD - (a-c)%MOD) % MOD print(ans)" p03617,s021598476,Wrong Answer,"a = input().split() q = int(a[0]) * 4 h = int(a[1]) * 2 s = int(a[2]) t = int(min([q,h,s])) d = int(a[3]) / 2 b = int(input()) if min([t,d]) == t: print(int(b * t)) else: if b % 2 == 0: print(int(b * d)) elif b != 1: print(int((b-1) * d + t)) else: print(t)" p02948,s674675007,Wrong Answer,"n, m = map(int, input().split()) points = [tuple(map(int, input().split())) for _ in range(n)] points.sort(key=lambda x: x[1]) point = 0 while m > 0: if not points: break t, p = points.pop() if t <= m: point += p m -= 1 print(point) " p03803,s983254543,Accepted,"p=[2,3,4,5,6,7,8,9,10,11,12,13,1] a,b=map(int,input().split()) print('ABloibc e'[p.index(a)= 8]) # この max は気づかないなあ print(max([min_X, 1]), max_X) " p02833,s558844104,Accepted,"import sys n = int(sys.stdin.readline().rstrip()) if n%2: print(0) else: ans = 0 n //= 10 while n > 0: ans += n n //= 5 print(ans)" p03861,s502423950,Accepted,"a, b, x = map(int, input().split()) start = a if a % x == 0 else x * (a // x) + x if b - start >= 0: ans = (b - start) // x + 1 else: ans = 0 print(ans) " p03324,s199935854,Accepted,"D, N = map(int, input().split()) if N == 100: print(101*100**D) else: print(100**D * N)" p02687,s296051573,Accepted,"S = input() if S == 'ABC': print('ARC') else: print('ABC')" p03745,s691646903,Accepted,"n = int(input()) a = list(map(int, input().split())) ans = 1 up = False down = False for i in range(1, n): if up: if a[i] < a[i - 1]: up = False ans += 1 elif down: if a[i] > a[i - 1]: down = False ans += 1 else: if a[i] > a[i - 1]: up = True elif a[i] < a[i - 1]: down = True print(ans)" p03327,s782983549,Accepted,"N=int(input()) print('ABC' if N<1000 else 'ABD')" p02897,s352193408,Accepted,n=int(input());print(((n+1)//2)/n) p02785,s016865232,Accepted,"n, k = map(int, input().split("" "")) h = list(map(int, input().split("" ""))) h = sorted(h) if n > k: print(sum(h[0: n-k])) if n <= k: print(0)" p03720,s272190115,Wrong Answer,"N,M = map(int,input().split()) glaf = [[] for i in range(N)] for i in range(M): a,b = map(int,input().split()) a=a-1 b=b-1 glaf[a].append(b) glaf[b].append(a) print(glaf) for i in glaf: cnt =0 for j in i: cnt+=1 print(cnt)" p02767,s754426794,Accepted,"n = int(input()) l = list(map(int, input().split())) sl = [] ma, mi = max(l), min(l) if ma == mi: sl.append(0) for x in range(mi, ma): s = 0 for i in l: s += (i - x)**2 sl.append(s) print(min(sl))" p02836,s343930488,Accepted,"s=input() l=[] for i in s: l.append(i) new_l = l[::-1] count=0 for a,b in zip(l,new_l): if a != b: count+=1 print(count//2) " p03137,s956549419,Accepted,"n,m=map(int,input().split()) x=list(map(int,input().split())) x.sort() lis=[] for i in range(1,m): lis.append(x[i]-x[i-1]) lis.sort() res=0 for i in range(0,m-n): res+=lis[i] print(res)" p02555,s499061652,Accepted,"def I(): return int(input()) def LI(): return list(map(int,input().split())) def MI(): return map(int,input().split()) def LLI(n): return [list(map(int, input().split())) for _ in range(n)] mod = 10**9+7 import math s = I() t = 0 ans = 0 for i in range(1,s+1):##iは数列の項の数 if s - 3*i <0: continue else: t = s-3*i #玉の数がt個、仕切りの数がi-1個 ans += math.factorial(i+t-1)//(math.factorial(t)*math.factorial(i-1)) ans = ans%mod print(ans)" p03043,s776751957,Accepted,"from math import log2, ceil n, k = map(int, input().split()) chance =[0]*n for firstDice in range(1, n+1): if firstDice >= k: chance[firstDice-1] = 1/n else: chance[firstDice-1] = 1/n * (1/2)**ceil(log2(k/firstDice)) print(sum(chance))" p02720,s877989991,Accepted,"import heapq k = int(input()) i=0 lunlun = [1,2,3,4,5,6,7,8,9] heapq.heapify(lunlun) while True: i += 1 if i == k: break x = heapq.heappop(lunlun) if x % 10 != 0: heapq.heappush(lunlun,10 * x + (x % 10) -1) heapq.heappush(lunlun,10 * x + (x % 10)) if x % 10 != 9: heapq.heappush(lunlun,10 * x + (x % 10) +1) print(lunlun[0])" p03327,s690903261,Accepted,"a = int(input()) if a < 1000: print(""ABC"") else: print(""ABD"")" p02678,s252122991,Accepted,"import collections N, M = map(int, input().split()) G = [[] for _ in range(N)] for _ in range(M): a, b = map(int, input().split()) G[a - 1].append(b - 1) G[b - 1].append(a - 1) F = [-1 for _ in range(N)] que = collections.deque([0]) while que: target = que.popleft() for g in G[target]: if F[g] == -1: F[g] = target que.append(g) res = [F[i] + 1 for i in range(N)] res[0] = ""Yes"" print(""\n"".join(map(str, res))) " p03796,s179257207,Wrong Answer,"#!/usr/bin/env python # -*- coding: utf-8 -*- num=int(input()) pow=1 for i in range(1,num): pow=pow*i print(pow%(10**9+7))" p02755,s807531070,Accepted,"A,B = map(int,input().split()) x = 0 while True: if (x*2) // 25 == A and x//10 == B: print(x) exit() if (x*2) // 25 > A and x//10 > B: print(-1) exit() x += 1" p03565,s008599829,Wrong Answer,"S = input() T = input() res = ""UNRESTORABLE"" for i in range(len(S)-1, len(T)-1, -1)[::-1]: s = list(S[::]) j = i flag = True for k in range(len(T)-1, -1, -1): if s[j] == ""?"": s[j] = T[k] elif s[j] == T[k]: continue elif s[j] != T[k]: flag = False break j -= 1 if flag: for j in range(len(s)): if s[j] == ""?"": s[j] = ""a"" res = s break print("""".join(res)) " p02744,s230564076,Accepted,"n = int(input()) strings = [[] for _ in range(n)] for i in range(n): if not i: strings[i].append(""a"") continue for s in strings[i-1]: for j in range(ord(""a""),ord(max(s))+2): c = chr(j) strings[i].append(s+c) print(*strings[-1]) " p02970,s292329610,Accepted,"n, d = map(int, input().split()) print(((n - 1) // (2 * d + 1)) + 1)" p03632,s245054071,Accepted,"a, b, c, d = map(int, input().split()) if a < c: st = c else: st = a if b < d: ed = b else: ed = d if st < ed: print(ed-st) else: print(0)" p02957,s662236759,Accepted,"a, b = map(int, input().split()) if (a-b) % 2 == 0: print((a+b)//2) else: print(""IMPOSSIBLE"")" p03329,s418228283,Accepted,"def main(): N = int(input()) dp = [N] * (N+1) dp[0] = 0 for i in range(1, N+1): j = 1 while j <= N: dp[i] = min(dp[i], dp[i-j]+1) j *= 6 j = 1 while j <= N: dp[i] = min(dp[i], dp[i-j]+1) j *= 9 res = dp[N] print(res) if __name__ == ""__main__"": main()" p02946,s266965044,Accepted,"K,X = map(int,input().split()) for i in range(2*K-1): print(X-K+1+i,end="" "")" p02817,s336233210,Accepted,"A,B = map(str,input().split()) print(B+A)" p02748,s407647292,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)] ans = min(a) + min(b) for x, y, c in xyc: ans = min(ans, a[x-1] + b[y-1] - c) print(ans)" p03035,s324925676,Accepted,"a,b=map(int,input().split()) if a>=13: print(b) elif 6<=a<=12: print(b//2) else: print(0) " p03854,s178368469,Accepted,"S = input() S = S[::-1] pattern = [""dream"",""dreamer"",""erase"",""eraser""] for i in range(len(pattern)): pattern[i] = pattern[i][::-1] while True: flag = False for v in pattern: if S[:len(v)] == v: S = S[len(v):] flag = True if S == """": print(""YES"") break elif not flag: print(""NO"") break" p03644,s568932098,Accepted,"n = int(input()) ans = 0 for i in range(1, n + 1): if i & (i - 1) == 0: ans = i print(ans)" p03379,s574995811,Accepted,"N = int(input()) numbers_r = tuple(map(int, input().split(' '))) numbers_s = sorted(numbers_r) med_high = numbers_s[N // 2] med_low = numbers_s[N // 2 - 1] for number in numbers_r: if number <= med_low: print(med_high) else: print(med_low) " p02785,s755785004,Accepted,"N,K = map(int,input().split()) H = sorted(list(map(int,input().split()))) if not N <= K: print(sum(H[0:N-K])) else: print(0)" p03720,s695339058,Accepted,"n,m = map(int,input().split()) li=[list(map(int,input().split())) for i in range(m)] ans_li = [0] * n for i, j in li: ans_li[i-1] += 1 ans_li[j-1] += 1 print(*ans_li,sep=""\n"")" p02854,s316549791,Accepted,"N = int(input()) A = list(map(int, input().split())) s = sum(A) r = 10**10 n = 0 for i in range(N-1): n += A[i] r = min(abs(s-n*2), r) print(r)" p03254,s430035961,Accepted,"N,x=map(int,input().split()) a=sorted(list(map(int,input().split()))) total=sum(a) #おかしが余る場合 if total=a[i]: x-=a[i] d[i]=1 ans=d.count(1) print(ans) " p02814,s564327704,Accepted,"from fractions import gcd n, m = map(int, input().split()) a = list(map(int, input().split())) l = 1 num = a[0] bin = 1 while num % 2 == 0: bin *= 2 num //= 2 for num in a: l = (l * num // 2) // gcd(l, num // 2) if num % bin != 0 or num % (bin * 2) == 0: print(0) exit() print((m + l) // (2 * l)) " p04012,s305915712,Accepted,"w = input() duplex = set(w) before_w = '' result = 'Yes' diff = 0 for i in duplex: before_w = w.replace(i, '') diff = diff + (len(w) - len(before_w)) w = before_w if diff % 2 == 0: pass else: result = 'No' break print(result) " p03417,s419622323,Accepted,"n,m=map(int,input().split()) if (n==1 or m==1) and n!=m: print(n*m-2) elif n==1 and m==1: print(1) else: print((n-2)*(m-2))" p03971,s943654517,Accepted,"n,a,b=map(int,input().split()) s=list(input()) i=0 j=0 for c in s: if c==""a"": if i+j=3 and m>=3: a=n*m b=n*2+m*2-4 elif n==1 or m==1: a=n*m b=2 elif n==2 or m==2: a=0 b=0 print(a-b) " p03860,s088204344,Accepted,"A,B,C = map(str, input().split()) ans =[A[0],B[0],C[0]] print(''.join(map(str, ans)))" p02571,s020594900,Accepted,"S = str(input()) T = str(input()) Snagasa = len(S) Tnagasa = len(T) saisyuicchi = 0 for i in range (Snagasa-Tnagasa+1): icchi = 0 for j in range (Tnagasa): if S[i+j] == T[j]: icchi = icchi + 1 else: icchi = icchi if icchi > saisyuicchi: saisyuicchi = icchi ans = Tnagasa - saisyuicchi print (ans)" p02743,s396745442,Wrong Answer,"import math N, M ,L= map(int, input().split()) a=math.sqrt(N)+math.sqrt(M) b=math.sqrt(L) if a= 0 else 'L' kaeri_yoko = 'L' if dx >= 0 else 'R' iki_tate = 'U' if dx >= 0 else 'D' kaeri_tate = 'D' if dx >= 0 else 'U' print(iki_yoko*abs(dx) + iki_tate*abs(dy) + kaeri_yoko*abs(dx) + kaeri_tate*abs(dy) + kaeri_tate + iki_yoko*abs(dx) + iki_tate*abs(dy) + kaeri_yoko + iki_tate + kaeri_yoko*abs(dx) + kaeri_tate*abs(dy) + iki_yoko) " p02571,s009473194,Accepted,"def get_num(s, t): cnt = len(s) for i in range(len(s)): if s[i] == t[i]: cnt -= 1 return cnt def main(): s = input() t = input() len_s, len_t = len(s), len(t) ans = len_t for i in range(len_s - len_t + 1): new_s = s[i:len(t) + i] tmp = get_num(new_s, t) ans = min(ans, tmp) print(ans) if __name__ == '__main__': main()" p02835,s624215893,Wrong Answer,"a = list(map(int, input().split())) print(""bust"" if sum(a) else ""win"")" p04005,s704542918,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, B * C, C * A)) " p03059,s899427453,Accepted,"A, B, T = list(map(int,input().split())) count = 0 t = A while t <= T + 0.5: count += B t += A print(count)" p02817,s510060262,Accepted,"def string(s, t): summ1 = 0 summ2 = 0 for i in range(len(s)): summ1 += ord(s[i]) for j in range(len(t)): summ2 += ord(t[j]) if summ1 > summ2: print(t, end="""") print(s) else: print(t, end="""") print(s) s, t = map(str, input().split()) string(s, t)" p02753,s703594090,Accepted,"S = list(input()) if S.count('A') >= 1 and S.count('B') >= 1: print('Yes') else: print('No') " p02645,s838740012,Accepted,print(input()[0:3]) p03286,s877919447,Accepted,"n = int(input()) ans = """" if n == 0: print(0) exit() while n != 0: tmp = n % 2 ans+=str(tmp) n=(n-tmp)//(-2) ans = ans[::-1] print(ans)" p03607,s904630721,Accepted,"from collections import Counter n = int(input()) a = [int(input()) for i in range(n)] c = Counter(a).values() ans = 0 for i in c: if i % 2 == 1: ans += 1 print(ans)" p02833,s610263380,Accepted,"n=int(input()) if n%2==1: print(0) else: m=n//2 ans=0 while m>0: ans+=m//5 m=m//5 print(ans)" p03239,s542972511,Accepted,"N , T = map(int,input().split()) ans =[] for i in range(N): c , t = map(int,input().split()) if t <= T: ans.append(c) if len(ans) == 0: print('TLE') else: print(min(ans)) " p02996,s201607500,Accepted,"def main(): n = int(input()) abl = [] for _ in range(n): a, b = map(int, input().split()) abl.append([a,b]) abl.sort(key=lambda x:x[1]) curr_time = 0 for curr_ab in abl: # print(curr_time) a,b = curr_ab curr_time += a if curr_time > b: print('No') return print('Yes') if __name__ == ""__main__"": main()" p03449,s546420273,Accepted,"N=int(input()) A1=list(map(int,input().split())) A2=list(map(int,input().split())) ans=0 for i in range(N): temp=sum(A1[:i+1])+sum(A2[i:]) if temp>ans: ans=temp print(ans) " p03998,s129210197,Accepted,"S = { ""a"":input(), ""b"":input(), ""c"":input() } ba = ""a"" while True: if 0 == len(S[ba]): print(ba.upper()) break else: p = S[ba][0] S[ba] = S[ba][1:] ba = p" p02627,s232741667,Accepted,"a = input() if a.isupper(): print(""A"") else: print(""a"") " p02995,s033176245,Accepted,"from fractions import gcd a, b, c, d = map(int, input().split()) lcm = (c*d) // gcd(c, d) all_count = b - a + 1 c_count = b // c - (a-1) // c d_count = b // d - (a-1) // d cd_count = b // lcm - (a-1) // lcm print(all_count - c_count - d_count + cd_count)" p03639,s912316414,Wrong Answer,"n = int(input()) aa = list(map(int, input().split())) c2 = 0 c4 = 0 for a in aa: if a % 4 == 0: c4 += 1 elif a % 2 == 0: c2 += 1 else: print('No') exit() if c4 + c2 == n: print('Yes') elif n/2 -1 < c4 < n/2 + 1: print('Yes') elif n % 4 == 2: if c4 == n / 2 - 1 and c2 == 2: print('Yes') else: print('No')" p03852,s892523402,Accepted,"c=input() if c=='a' or c=='i' or c=='u' or c=='e' or c=='o': print('vowel') else: print('consonant') " p03146,s377593360,Wrong Answer,"#!/usr/bin/env python3 S = int(input()) e = S cnt = 0 while True: if e % 2 == 0: v = e//2 else: v = 3*e+1 e = v cnt += 1 if v == 4: print(cnt+4) exit() " p03815,s806672020,Wrong Answer,"x = int(input()) Su = int(2*x/11) M = x%11 if x < 11: if x <=5: print(1) else: print(2) else: if M ==0: print(Su) else: if M <= 5: print(Su+1) else: print(Su+2)" p03434,s436888542,Accepted,"n = int(input()) a = list(map(int, input().split())) alice = [] bob = [] for i in range(n): if i % 2 == 0: alice.append(max(a)) a.remove(max(a)) else: bob.append(max(a)) a.remove(max(a)) print(sum(alice)-sum(bob))" p02933,s138990919,Accepted,"a = int(input()) s = input() if a >= 3200: print(s) else: print('red')" p03720,s640356827,Accepted,"n,m = map(int,input().split()) city = [] for i in range(n): city.append([]) for i in range(1,m+1): a,b = map(int,input().split()) city[a-1].append(b) city[b-1].append(a) for r in city: print (len(r)) " p04012,s643908394,Wrong Answer,"from collections import Counter w = input() c = Counter(w) s = ""No"" while(True): for t in c.most_common(): if (t[1]%2) == 0: s = ""Yes"" else: break break print(s)" p02784,s819671325,Accepted,"H, N = map(int, input().split()) A = [int(x) for x in input().split()] print('Yes' if sum(A) >= H else 'No')" p03471,s663193017,Accepted,"n,m = map(int,input().split()) total = 0 for a in range(n+1): for b in range(n+1): total=10000*a+5000*b+1000*(n-a-b) if total == m and a+b <=n: print(a,b,n-a-b) exit() print(-1,-1,-1)" p03309,s925729301,Accepted,"n = int(input()) B = list(a-i-1 for i,a in zip(range(n), map(int,input().split()))) B.sort() ans = sum(B[n//2 + (n%2) :]) - sum(B[: n//2]) # sum(median left) - sum(median right) print(ans) " p02694,s493900554,Accepted,"import sys import math input = sys.stdin.readline def main(): X = int(input()) bank = 100 i = 0 while bank < X: bank = math.floor(bank*1.01) i += 1 print(i) if __name__ == '__main__': main() " p02732,s925450778,Accepted,"from collections import Counter N = int(input()) A = tuple(map(int, input().split())) A_count = Counter(A) ans = 0 for i, j in A_count.items(): ans += j * (j - 1) // 2 for k in range(1, N+1): n = A_count[A[k-1]] ans_ = ans - (n - 1) print(ans_) " p02624,s085369310,Accepted,"import sys import numba read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines @numba.njit def main(N): x = 0 for a in range(1, N+1): for b in range(1, N//a+1): x += a*b return x N = int(read()) print(main(N)) " p03457,s462304747,Accepted,"N = int(input()) count = 0 T, X, Y = 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: count += 1 T, X, Y = t, x, y print(""Yes"" if count == N else ""No"")" p02601,s474096608,Accepted,"a,b,c = map(int,input().split()) k = int(input()) p = 0 for i in range(k+1): if c*(2**i) > b*(2**(k-i)) and b*(2**(k-i)) > a: p += 1 break if p == 1: print('Yes') else: print('No') " p02873,s283017699,Accepted,"S = input() n = len(S) + 1 A = [0 for _ in range(n)] for i in range(n - 1): prev = A[i] if S[i] == ""<"": A[i + 1] = max(A[i + 1], prev + 1) for i in range(n - 1): j = n - i - 2 prev = A[j + 1] if S[j] == "">"": A[j] = max(A[j], prev + 1) print(sum(A))" p03289,s234958874,Accepted,"s = input() if not s[0]==""A"": print(""WA"") elif not s[1].islower(): print(""WA"") else: cnC = 0 for i in range(2,len(s)-1): if s[i]==""C"": cnC += 1 elif s[i].isupper(): print(""WA"") quit() if cnC==1 and s[len(s)-1].islower(): print(""AC"") else: print(""WA"")" p02819,s351866261,Accepted,"def seive(num,n): li=[True]*(n+1) x=2 li[0]=False li[1]=False while x*x= sum(hwk): print(days - sum(hwk)) else: print(-1)" p02785,s727742682,Accepted,"N, K = map(int, input().split()) H = sorted(list(map(int, input().split())), reverse=True) print(sum(H[K:])) " p03910,s812187961,Accepted,"N = int(input()) cnt = 0 for i in range(1, N+1): if i * (1 + i) // 2 >= N: cnt = i break for i in range(cnt, 0, -1): if i <= N: print(i) N -= i" p04044,s832220231,Accepted,"def solve(): N, L = map(int, input().split()) S = [input() for _ in range(N)] S.sort() ans = ''.join(S) return ans print(solve())" p02780,s693870315,Wrong Answer,"import numpy N, K = map(int, input().split()) p = list(map(int, input().split())) lis = list() p = [(i + 1)/2 for i in p ] numpy.set_printoptions(precision=16) cumSum = numpy.cumsum(p) cumSum2 = list(cumSum) cumSum2.insert(0,0) for i in range(0, N-K+1): lis.append(cumSum2[K+i] - cumSum2[i]) print('{:.12f}'.format(int(max(lis))))" p02694,s688962941,Accepted,"import math x = int(input()) money = 100 c = 0 while money < x: c += 1 money = math.floor(money*1.01) print(c)" p03043,s316066840,Accepted,"n,k = map(int, input().split()) a = [] for i in range(1,n+1): j = i b =0 while j X - B and X >= A else 'NO') if __name__ == '__main__': main() " p02759,s922787612,Accepted,"import math n = int(input()) print(math.ceil(n/2))" p03760,s656579193,Wrong Answer,"O = [input()] E = [input()] + [""""] for o, e in zip(O,E): print(o+e , end="""")" p03146,s691338887,Accepted,"s = int(input()) A = set() while(True): if s in A: break else: A.add(s) if s%2==0: s = s/2 else: s = 3*s+1 print(len(A)+1)" p02723,s477099402,Accepted,"S = input() if S[2]==S[3] and S[4]==S[5]: print(""Yes"") else: print(""No"") " p02629,s987228146,Accepted,"import sys if __name__ == '__main__': n = int(sys.stdin.readline().rstrip()) ans = '' while True: n -= 1 ans += chr(65+32+(n % 26)) if n < 26: break n = n // 26 print(ans[::-1])" p02663,s647900196,Accepted,"h1,m1,h2,m2,k=map(int,input().split()) print(60*(h2-h1)+m2-m1-k)" p02790,s325540765,Accepted,"a, b = map(int, input().split()) print(min(str(a) * b, str(b) * a))" p03206,s687105984,Wrong Answer,"D = int(input()) print(""Chiristmas"", end ="""") days = 25 - D for i in range(days): print("" Eve"", end ="""")" p02829,s506794856,Wrong Answer,"for i in {1,2,3}.difference(set(map(int,input().split(' ')))): print(i)" p02951,s263915387,Accepted,"a,b,c=map(int, input().split()) print(max(b+c-a,0))" p03680,s797809330,Accepted,"n = int(input()) al = [int(input()) for i in range(n)] i = 0 for j in range(n): i = al[i]-1 if i == 1: print(j+1) exit() print(-1)" p02701,s434686803,Accepted,"def main(): N = int(input()) S = [] for i in range(N): S.append(str(input())) print(len(set(S))) if __name__ == ""__main__"": main()" p02873,s305658749,Accepted,"s = list(input()) n = len(s) + 1 l = [0] * n r = [0] * n for i, c in enumerate(s, 1): if c == '>': l[i] = 0 else: l[i] = l[i - 1] + 1 for i, c in enumerate(s[::-1]): i = n - 2 - i if c == '<': r[i] = 0 else: r[i] = r[i + 1] + 1 seq = [x if x > y else y for x, y in zip(l, r)] ans = sum(seq) print(ans) " p02695,s845493985,Accepted,"import itertools N,M,Q = map(int,input().split()) pair = [list(map(int,input().split())) for i in range(Q)] ans = 0 for A in itertools.combinations_with_replacement(range(1,M + 1),N): temp = 0 for p in pair: if A[p[1]-1] - A[p[0]-1] == p[2]: temp += p[3] ans = max(ans,temp) print(ans)" p03281,s472993883,Accepted,"N=int(input()) [3,5,7,11,13] A=[105,135,165,189,195] ans=0 for i in A: if i <=N: ans+=1 print(ans) " p02759,s139746949,Accepted,"n = int(input()) a = n // 2 b = n % 2 print(a+b) " p03471,s541142587,Accepted,"n, y = map(int, input().split()) for a in range(n+1): for b in range(n+1): c = n - (a+b) if a*10000 + b*5000 + c*1000 == y and a+b+c == n and c >= 0: print(a, b, c) exit() print('-1 -1 -1')" p02773,s100809205,Wrong Answer,"import math import sys import collections import bisect readline = sys.stdin.readline def main(): n = int(readline().rstrip()) S = [readline().rstrip() for _ in range(n)] c = collections.Counter(S) maxS = c.most_common()[0][1] for i in range(len(c)): if c.most_common()[i][1] == maxS: print(c.most_common()[i][0]) if __name__ == '__main__': main() " p04019,s310002701,Accepted,"s = input() N = s.count(""N"") W = s.count(""W"") S = s.count(""S"") E = s.count(""E"") if (N == S == 0 or (N > 0 and S > 0)) and (E == W == 0 or (W > 0 and E > 0)): print(""Yes"") else: print(""No"")" p04029,s060892880,Wrong Answer,"N=int(input()) print((N+1)*N/2)" p02775,s065551875,Accepted,"s = '0' + input() m = len(s) up = 0 cnt = 0 y = [] for i in range(-1, -m-1, -1): cs = int(s[i]) + up if cs < 5 or (cs == 5 and int(s[i-1]) < 5): cnt += cs y.append([cs, s[i]]) up = 0 else: cnt += 10 - cs y.append([10 - cs, s[i]]) up = 1 print(cnt)" p02994,s241986283,Accepted,"def ll(): return list(map(int,input().split())) def l(): return int(input()) n,l = ll() x = [int(i) for i in range(l, n + l)] if 0 in x: print(sum(x)) elif abs(x[0])= index: for i in range(0,index): A[i] = c else: A = [ c for _ in range(b)] print(sum(A))" p02727,s236210662,Wrong Answer,"from collections import deque x,y,a,b,c=map(int, input().split()) pi=list(map(int,input().split())) qi=list(map(int,input().split())) ri=list(map(int,input().split())) pi.sort(reverse=True) qi.sort(reverse=True) ri.sort(reverse=True) ri=deque(ri) apple=pi[:a]+qi[:b] apple.sort(reverse=True) apple=deque(apple) while min(apple) <= ri[0]: c=ri.popleft() apple[-1]=c if len(ri)==0: break print(sum(apple))" p03723,s217923622,Accepted,"a, b, c = [int(i) for i in input().split()] cnt = 0 history = set() while True: if (a, b, c) in history: print(-1) exit(0) if a % 2 == 1 or b % 2 == 1 or c % 2 == 1: print(cnt) exit(0) a, b, c = sorted([a, b, c]) history.add((a, b, c)) na = b // 2 + c // 2 nb = a // 2 + c // 2 nc = a // 2 + b // 2 a = na b = nb c = nc cnt += 1" p03817,s034531627,Accepted,"N = int(input()) if not N % 11: print(N // 11 * 2) elif N % 11 <= 6: print(N // 11 * 2 + 1) else: print(N // 11 * 2 + 2)" p02777,s995147700,Accepted,"s, t = input().split() a, b = map(int, input().split()) u = input() balls = {s: a, t: b} if u in balls.keys(): balls[u] -= 1 print('{} {}'.format(balls[s], balls[t])) " p03469,s726304156,Accepted,"print(""2018""+input()[4:])" p04030,s400505971,Accepted,"S = input() ans = [] for s in S: if s == ""0"": ans.append(0) elif s == ""1"": ans.append(1) else: if ans: ans.pop(-1) print(*ans, sep='')" p03665,s422690684,Accepted,"# AGC017A def f(n, p, a): odd = sum(i % 2 for i in a) if odd == 0: if p == 0: return 2**n elif p == 1: return 0 else: return 2**(n-1) n, p = map(int, input().split()) a = list(map(int, input().split())) print(f(n, p, a)) " p03699,s426362814,Accepted,"N = int(input()) scores = list(int(input()) for _ in range(N)) ans = sum(scores) if ans % 10 != 0: print(ans) exit() scores.sort() for score in scores: if score % 10 != 0: ans -= score print(ans) exit() print('0') " p03408,s410595734,Accepted,"from collections import defaultdict d1 = defaultdict(int) d2 = defaultdict(int) n = int(input()) for i in range(n): d1[input()] += 1 m = int(input()) for i in range(m): d2[input()] += 1 ans = 0 for k, v in d1.items(): ans = max(ans, v - d2[k]) print(ans) " p03998,s872962664,Accepted,"a = list(input()) b = list(input()) c = list(input()) turn = a.pop(0) while True: if turn == 'a': if a : turn = a.pop(0) else: print(""A"") break elif turn == 'b': if b : turn = b.pop(0) else: print(""B"") break elif turn == 'c': if c : turn = c.pop(0) else: print(""C"") break " p03778,s126528128,Wrong Answer,"W, a, b = map(int, input().split()) A = a + W if b - A <= 0: print(0) else: print(b-A) " p03328,s493429145,Wrong Answer,"a,b=map(int,input().split()) print(a+a-b)" p04034,s571843414,Accepted,"n, m, *XY = map(int, open(0).read().split()) A = [1] * n B = [0] * n B[0] = 1 for x, y in zip(XY[::2], XY[1::2]): x, y = x-1, y-1 A[x] -= 1 A[y] += 1 if B[x]: B[y] = 1 if A[x] == 0: B[x] = 0 print(sum(B))" p02922,s559440154,Wrong Answer,"import math a,b=map(int,input().split()) if a>=b: print(b) else: print(math.ceil(b/a)) " p03106,s298894217,Accepted,"a,b,k=map(int,input().split()) ans=0 for i in range(min(a,b)): if a%(min(a,b)-i)==0 and b%(min(a,b)-i)==0: ans+=1 if ans==k: print(min(a,b)-i) break " p03243,s020169928,Accepted,"N = int(input()) if N%111==0: print(N) else: print((N//111+1)*111)" p02720,s850152302,Wrong Answer,"from collections import deque k=int(input()) q=deque(list(range(1, 10))) ans,x,y,tmp=0,0,0,0 for i in range(k): ans=q.popleft() x,y=ans*10,ans%10 tmp=10*x+y if y != 0: q.append(tmp-1) q.append(tmp) if y != 9: q.append(tmp+1) print(ans) " p02873,s367229549,Accepted,"import sys input = sys.stdin.readline S=tuple(input().strip()) N=len(S)+1 sets = [] count = 0 for c in S: d = 1 if c == '<' else -1 if count * d < 0: sets.append(count) count = d else: count += d sets.append(count) sum = 0 for i in range(len(sets)): k=sets[i] if k > 0: sum += (k*(k+1))//2 else: sum += (k*(k-1))//2 if i > 0: sum -= min(sets[i-1], -k) print(sum) " p03017,s247962434,Accepted,"import re n, a, b, c, d = map(int, input().split()) road = input() if c < d: if re.search('##', road[a:d]) is None: print('Yes') else: print('No') elif c > d: if re.search('##', road[a:]) is None and re.search('\.\.\.', road[b-2:d+1]) is not None: print('Yes') else: print('No') " p03243,s139323994,Wrong Answer,"n = int(input()) i = int(n / 111) if n % 111 != 0: i += 1 print(i) print(i * 111)" p03360,s695757381,Wrong Answer,"abc = list(map(int, input().split())) k = int(input()) abc.sort() abc[2] = abc[2] * 2 * k print(sum(abc))" p02584,s304189814,Accepted,"X, K, D = map(int, input().split()) X = abs(X) r = X % D t = X // D if t >= K: ans = abs(X - K * D) elif (K - t) % 2 == 0: ans = r else: ans = D - r print(ans)" p02627,s970133896,Accepted,"a = input().rstrip() if a.isupper(): print(""A"") else: print(""a"")" p02946,s156567244,Accepted,"K,X = map(int,input().split()) ans = [str(i) for i in range(X-K+1,X+K)] print("" "".join(ans)) " p03730,s541278498,Accepted,"A, B, C = map(int, input().split()) for i in range(B): if i*A%B==C: print('YES') exit() print('NO')" p04031,s712607568,Accepted,"n = int(input()) a = [int(_) for _ in input().split()] ans = 1000000000 for i in range(-100, 101): val = 0 for j in a: val += (i-j)**2 ans = min(ans, val) print(ans)" p03469,s980283517,Wrong Answer,"str = input() str[3] == '8' print(str)" p03699,s265082531,Accepted,"n=int(input()) s=[0]*n for i in range(n): s[i]=int(input()) s.sort() ans=sum(s) temp=0 if ans%10==0: for i in range(n): if s[i]%10==0: temp=temp+1 else: print(ans-s[i]) break if temp==n: print(0) else: print(ans)" p03038,s127852284,Accepted,"from collections import Counter N, M = map(int, input().split()) A = list(map(int, input().split())) A = Counter(A) for _ in range(M): b, c = map(int, input().split()) A[c] += b A = sorted(A.items(), key=lambda x: x[0], reverse=True) ans = 0 for key, value in A: if N - value >= 0: ans += key * value N -= value else: ans += N * key break print(ans)" p03796,s102688981,Accepted,"import math n = int(input()) a = math.factorial(n) b = 10**9 + 7 print(a%b) " p03162,s663087170,Accepted,"N = int(input()) dp = [[0]*3 for _ in range(N)] dp[0] = list(map(int, input().split())) for i in range(1, N): h = list(map(int, input().split())) for j in range(3): dp[i][j] = max([dp[i-1][k]+h[j] for k in range(3) if k != j]) print(max([dp[N-1][j] for j in range(3)]))" p03607,s140826075,Wrong Answer,"n=int(input()) a=list(map(int,input().split())) b=set(a) ans=0 for i in b: if a.count(i)%2==1: ans+=1 print(ans)" p02909,s000430830,Wrong Answer,print('CRSlauoinunndyyy'[id(id)%3::3]) p03821,s091188722,Accepted,"import math n = int(input()) a = [] b = [] for i in range(n): c, d= map(int, input().split()) a.append(c) b.append(d) a.reverse() b.reverse() tot = 0 for i in range(n): if (a[i]+tot)%b[i] == 0: continue x = b[i] - (a[i]+tot)%b[i] tot += x print (tot)" p02723,s366287681,Wrong Answer,"s = input() S = list(s) if S[2] == S[3] and S[4] == S[5]: print('Yes') else: print('No)') " p03456,s266101268,Wrong Answer,"import math s = int(input().replace(' ','')) if math.sqrt(s)**2 ==s: print(""Yes"") else: print(""No"") " p02664,s447076684,Accepted,"T=input() u=T.translate(str.maketrans({'?': 'D'})) print(u)" p02948,s869292840,Wrong Answer,"from sys import stdin, setrecursionlimit def main(): input = stdin.buffer.readline n, m = map(int, input().split()) ab = [list(map(int, input().split())) for _ in range(n)] ab.sort(reverse=True, key=lambda x: (x[1], x[0])) ans = 0 d = 0 for a, b in ab: if a + d <= m: ans += b d += 1 if d == m: break print(ans) if __name__ == ""__main__"": setrecursionlimit(10000) main() " p02699,s122169580,Wrong Answer,"b,c=[int(x) for x in input().split()] if c>b: print(""unsafe"") else: print(""safe"") " p02970,s252972852,Accepted,"import math n,d=map(int,input().split()) print(math.ceil(n/(d*2+1))) " p03220,s231334366,Wrong Answer,"N = int(input()) T,A = map(int,input().split()) H = list(map(int,input().split())) a =[] def cal(n): ans = T-n*6 return ans for i in H: a.append(int((A-cal(i)))) print(a.index(min(a))+1) " p02759,s577238126,Wrong Answer,"import sys import numpy as np # input = sys.stdin.readline n = int(input()) print(round(n))" p02854,s242612960,Accepted,"N = int(input()) A = list(map(int,input().split())) tot = sum(A) B = [0 for _ in range(N+1)] for i in range(1,N+1): B[i] = B[i-1]+A[i-1] cmin = abs(tot-2*B[1]) for i in range(2,N): cmin = min(cmin,abs(tot-2*B[i])) print(cmin)" p03309,s219327432,Wrong Answer,"n = int(input()) a = list(map(int, input().split())) for i in range(n): a[i] -= i+1 b = round(sum(a)/n, 0) ans = 0 for i in range(n): ans += abs(a[i]-b) print(int(ans)) " p03472,s674588428,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)" p03206,s339269170,Wrong Answer,"D = int(input()) if D == 25: a = 'Christmas' elif D == 24: a = 'Christmas Eve' elif D == 23: a = 'Christmas Eve Eve' elif D == 22: a = 'christmas Eve Eve Eve' print(a) " p02556,s539625141,Accepted,"import numpy as np f = open(0) N = int(f.readline()) xy = np.fromstring(f.read(), dtype=np.int64, sep=' ').reshape((-1, 2)).T.copy() x = xy[0] y = xy[1] c1 = x + y c2 = x - y ans = max(c1.max() - c1.min(), c2.max() - c2.min()) print(ans) " p03059,s751404495,Accepted,"a,b,t=map(int,input().split()) print(t//a*b)" p03862,s542424433,Accepted,"N,X = map(int,input().split()) A = list(map(int,input().split())) A = [0] + A + [0] cnt = 0 for i in range(1,N+1): S = A[i]+A[i+1] if S>X: d = S-X cnt += d A[i+1] = max(0,A[i+1]-d) print(cnt)" p03345,s133857422,Accepted,"A, B, C, K = map(int, input().split()) print(B - A) if K % 2 else print(A - B)" p03803,s950875739,Wrong Answer,"import sys import copy import math import bisect import pprint import bisect from functools import reduce from copy import deepcopy from collections import deque if __name__ == '__main__': a = [int(i) for i in input().split()] if a[0] > a[1]: print(""Alice"") elif a[0] == a[1]: print(""Draw"") else: print(""Bob"")" p02768,s208490809,Accepted,"n,a,b = [int(x) for x in input().split()] INF = (10**9 + 7) def c(n,r,p): r = min(r,n-r) numer = 1 denom = 1 for i in range(1,r+1): numer = numer * (n+1-i) % p denom = denom * i % p return numer * pow(denom,p-2,p) % p ans = pow(2,n,INF) - 1 - c(n,a,INF) - c(n,b,INF) while ans < 0: ans += INF print(ans)" p03086,s716226644,Accepted,"S = input() ans = 0 for i in range(len(S)): for j in range(i, len(S)): if all('ACTG'.count(c) == 1 for c in S[i:j+1]): ans = max(ans, j+1-i) print(ans)" p02888,s756208391,Accepted,"n = int(input()) l = list(map(int, input().split())) l.sort() import bisect count = 0 for i in range(n-1): for j in range(i+1, n): ab = l[i] + l[j] right = bisect.bisect(l, ab-1) left = j + 1 count += (right - left) print(count)" p03038,s291411717,Accepted,"import sys import bisect N, M = map(int, input().split()) A = sorted(map(int, input().split())) CB = [None] * M for i in range(M): b, c = map(int, sys.stdin.readline().split()) CB[i] = (c, b) CB.sort(reverse=True) i = 0 ans = 0 for c, b in CB: x = bisect.bisect_left(A, c, i) count = min(x - i, b) ans += c * count i += count for j in range(i, N): ans += A[j] print(ans)" p02783,s376369839,Accepted,"H, A = map(int, input().split()) print((H-1)//A+1)" p03565,s115772348,Accepted,"S = input() T = input() f = ""UNRESTORABLE"" # 後ろから見ていって、部分文字列を当てはめる S_r = S[::-1] T_r = T[::-1] for i in range(len(T),len(S)+1): S_ = S_r[i-len(T):i] flg = True for t,s in zip(T_r, S_): if s != ""?"" and s != t: flg = False if flg: ans = S_r[:i-len(T)] + T_r + S_r[i:] print(ans[::-1].replace(""?"",""a"")) exit() print(f) " p03012,s679733578,Accepted,"N = int(input()) W = list(map(int, input().split())) S1 = W[0] S2 = sum(W[1:]) abs_min = abs(S1-S2) for i in range(1, N-1): S1 += W[i] S2 -= W[i] abs_min = min(abs_min, abs(S1-S2)) print(abs_min)" p03481,s237413196,Accepted,"X,Y=map(int,input().split()) c=0 while(X<=Y): X=X*2 c+=1 print(c)" p02546,s681958922,Accepted,"s = input() if s[-1] == 's': print(s+'es') else: print(s+'s')" p03210,s512908378,Wrong Answer,"x = int(input()) print('Yes' if x == 7 or x == 5 or x == 3 else 'No')" p03943,s569383091,Accepted,"l = list(map(int,input().split())) l = sorted(l) if l[2] == l[0] + l[1]: print('Yes') else: print('No')" p03815,s885623715,Wrong Answer,"x = int(input()) if 6 < x < 11: print(2) exit() elif 1 <= x <= 6: print(1) exit() if x % 11 == 0: print((x // 11) * 2) else: print((x // 11) * 2 + 1) " p03699,s509306552,Accepted,"n=int(input()) a = [int(input()) for _ in range(n)] ans=0 a.sort() for i in range(n): if sum(a)%10 == 0: if a[i]%10 == 0: pass else: a[i]=0 else: print(sum(a)) exit(0) print(0)" p03043,s016993617,Wrong Answer,"n,k=map(int,input().split()) cnt=0 j=17 for i in range(1,n+1): if i>=k: cnt+=1 else: while i*(2**j)>k: j-=1 cnt+=1/2**(j+1) print(format(cnt/n,'.12f')) " p03419,s536430295,Wrong Answer,"h,w = map(int,input().split()) if h == 1 or w == 1: ans = 2 print(ans) else: ans = 2*(h-2)+2*(w-2)+4 ans = (h*w) -ans print(ans) " p03637,s322051700,Accepted,"N = int(input()) arr = list(map(int, input().split())) two_count = 0 four_count = 0 for i in arr: if i % 4 == 0: four_count += 1 continue if i % 2 == 0: two_count += 1 continue ans = N - ((two_count//2)*2 + (four_count*2) + 1 if four_count > 0 else 0) if ans <= 0 or two_count == N: print('Yes') else: print('No')" p03331,s207665198,Wrong Answer,"n = input() print(sum([int(n[i]) for i in range(len(n))]))" p03495,s206588437,Wrong Answer,"str = input().split("" "") num = input().split("" "") goal = int(str[1]) arr = {} for i in num: i = int(i) if arr.get(i, False): arr[i] += 1 else: arr[i] = 1 arr = dict(sorted(arr.items(), key=lambda d: d[1], reverse=True)) count = 0 if len(arr.items()) >= goal: for index, (i, key) in enumerate(arr.items()): if (index + 1) > goal: count += key else: count = goal - len(arr.items()) print(count)" p03698,s397875832,Accepted,"# 「ABC-154-C」の類題 S = input() n1 = len(S) n2 = len(set(S)) if n1 == n2: print('yes') else: print('no')" p03994,s071043828,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))" p03644,s865126141,Wrong Answer,"N=int(input()) count=0 max=0 max_number=1 if N==1: print(1) for i in range(1,N+1): while i>=1: if i%2==0: i=i//2 count+=1 else: break if count>=max: max=count max_number=1 print(max_number)" p02624,s893575597,Accepted,"n = int(input()) ans = 0 for i in range(1, n+1): y = n // i ans +=( y * (y+1)* i)//2 print(ans)" p02756,s963293965,Accepted,"s=input() q=int(input()) cnt=0 #反転の回数の偶奇を記憶 right="""" left="""" for i in range(q): query=list(input().split()) if query[0]==""1"": cnt+=1 else: if (cnt+int(query[1]))%2==0: right+=query[2] else: left+=query[2] if cnt%2==0: print(left[::-1]+s+right) else: print(right[::-1]+s[::-1]+left)" p02916,s284556820,Accepted,"n=int(input()) A=[int(_) for _ in input().split()] B=[int(_) for _ in input().split()] C=[int(_) for _ in 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,s123918727,Accepted,"n, m = [int(i) for i in input().split()] if 2*n >= m: print(m // 2) else: print(n + (m - 2 * n) // 4)" p03745,s661770092,Accepted,"n = int(input()) a = [int(x) for x in input().split()] status = 0 ans = 1 for i in range(1, n): if status == 0: if a[i-1] < a[i]: status = 1 elif a[i-1] > a[i]: status = 2 elif status == 1: if a[i-1] > a[i]: ans += 1 status = 0 elif status == 2: if a[i-1] < a[i]: ans += 1 status = 0 print(ans) " p03317,s571150202,Accepted,"n,k = map(int,input().split()) A = list(map(int,input().split())) import math ans = math.ceil(((n-1)/(k-1))) print(ans) " p03371,s697442450,Wrong Answer,"a, b, c, x, y = map(int, input().split()) m = 100000000 for i in range(max(x, y)*2): total = a*(max(0, x-i//2)) + b*(max(0, y-i//2)) + c*i if total < m: m = total print(m)" p03804,s604273588,Accepted,"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): if B[i] in A[i]: for j in range(m-1): if B[i+j] not in B[i+j]: print(""No"") exit() print(""Yes"") exit() else: print(""No"") exit()" p04045,s780476131,Accepted,"def solve(n, k, xs): tmp = n num = len(xs) while True: if num == len([i for i in xs if i not in str(tmp)]): break else: tmp += 1 return tmp if __name__ == ""__main__"": n, k = [int(i) for i in input().split()] xs = [i for i in input().split()] print(solve(n, k, xs)) " p02695,s822317581,Accepted,"n,m,q = map(int,input().split()) abcd = [list(map(int,input().split())) for _ in range(q)] s = [[1]] for i in range(1,n): s_ = [] for j in s: for k in range(j[-1],m+1): s_.append(j+[k]) s = s_ ans = 0 for i in s: ans_ = 0 for j in abcd: if i[j[1]-1]-i[j[0]-1]==j[2]: ans_ += j[3] ans = max(ans, ans_) print(ans)" p02833,s043230670,Accepted,"n= int(input()) ans=0 if(n%2==0): n=n//10 while(n>0): ans = ans+n n= n//5 print(ans) " p02820,s068403723,Accepted,"n,k = map(int,input().split()) r,s,p = [int(i) for i in input().split()] T = input() point = {""r"":p,""p"":s,""s"":r} ans = 0 for i in range(min(n,k)): before = T[i] counter = 0 for s in T[i::k]: if before == s: counter += 1 else: ans += (counter+1)//2 * point[before] before = s counter = 1 ans += (counter+1)//2 * point[before] print(ans) " p03145,s487505979,Wrong Answer,"x=input(""|AB| |BC| |CA|"") ab,bc,ca=x.split() ab=int(ab) bc=int(bc) ca=int(ca) x=ab*bc/2 print(x)" p02779,s361206249,Wrong Answer,"n = int(input()) a = input().split("" "") flag = False for i in range(n-1): for j in range(n-1): if a[i] == a[j]: Flag = True break if flag: break print('NO' if flag else 'YES') " p02618,s590065933,Accepted,"D = int(input()) c = list(map(int, input().split())) S = [list(map(int, input().split())) for i in range(D)] #T = [int(input()) for i in range(D)] SUM = 0 last = [0] * 28 for d in range(1, D + 1): i = S[d - 1].index(max(S[d - 1])) print(i + 1)" p02835,s565277787,Accepted,"import sys input = sys.stdin.readline a,b,c = map(int, input().split()) if(a+b+c >=22): print('bust') else: print('win')" p03035,s317130729,Accepted,"A, B = map(int, input().split()) if A >= 13: print(B) elif A >= 6: print(B // 2) else: print(0)" p02601,s560177392,Accepted,"# -*- coding: utf-8 -*- A, B, C = map(int, input().split()) K = int(input()) for i in range(K): if C <= B: C *= 2 elif B <= A: B *= 2 if C > B and B > A: print('Yes') else: print('No')" p02989,s809451447,Accepted,"n=int(input()) d=sorted(list(map(int,input().split()))) print(d[n//2]-d[n//2-1])" p03861,s124214633,Accepted,"a, b, x = map(int, input().split()) print(b//x - (a-1)//x) " p02724,s730707816,Wrong Answer,"hap=0 yen=int(input()) hap=1000*(yen//500)+(yen%5)*5 " p02712,s976935930,Accepted,"N = int(input()) wa = 0 for i in range(1,N+1): if i % 3 != 0 and i % 5 != 0: wa += i print(wa)" p02793,s802044385,Accepted,"from math import gcd from functools import reduce MOD = 10 ** 9 + 7 def calc_lcm(x, y): return x * y // gcd(x, y) def calc_lcm_list(numbers): return reduce(calc_lcm, numbers, 1) N, *A = map(int, open(0).read().split()) lcm = calc_lcm_list(A) print(sum(lcm * pow(v, MOD - 2, MOD) for v in A) % MOD) " p02993,s957297615,Accepted,"a,b,c,d=input() print(""Good"" if a!=b and b!=c and c!=d else ""Bad"")" p03285,s336252618,Wrong Answer,"N = int(input()) cnt = 0 for i in range(N): if (N - i*7) % 4 == 0: cnt += 1 print(""Yes"" if cnt > 0 else ""No"")" p03759,s449854783,Wrong Answer,"# from collections import Counter a,b,c = map(int,input().split()) if(abs(b-a)==abs(c-b)): print(""YES"") else: print(""NO"")" p02795,s385395296,Wrong Answer,"h = int(input()) w = int(input()) n = int(input()) print(n//w+1) " p02724,s575629756,Accepted,"# ========= /\ /| |====/| # | / \ | | / | # | /____\ | | / | # | / \ | | / | # ========= / \ ===== |/====| # code def main(): x = int(input()) ans = 0 ans += (x // 500) * 1000 x -= (x // 500) * 500 ans += (x // 5) * 5 print(ans) return if __name__ == ""__main__"": main()" p02696,s182443140,Accepted,"a,b,n = [int(x) for x in input().split()] x = min(n,b-1) print((a*x//b)-(x//b)*a)" p02957,s965778749,Wrong Answer,"a,b=map(int,input().split()) if a == 0 or b == 0 : print('IMPOSSIBLE') else : print(int((a+b)/2))" p02786,s397452472,Accepted,"enemie = int(input()) def attack(N, times=-1): times += 1 if N // 2 == 0: return times else: enemie = N // 2 return attack(enemie, times) ans = 0 for i in range(attack(enemie)+1): ans += 2**i print(ans)" p03681,s805267499,Wrong Answer,"from math import * N,M = map(int,input().split()) if abs(N - M): print(0) exit(0) if N == M: print(2 * factorial(N) * factorial(M) % (10**9+7)) else: print(factorial(N) * factorial(M) % (10**9+7)) " p03711,s179538156,Accepted,"x,y = map(int, input().split()) Z = [4,6,9,11] if x in Z or y in Z: b = x in Z and y in Z elif x == 2 or y == 2: b = x == y == 2 else: b = x not in ([2]+Z) and y not in ([2]+Z) print(""YNeos""[not b::2])" p02754,s290200610,Accepted,"#!/usr/bin/python3 # -*- coding:utf-8 -*- def main(): n, a, b = map(int, input().strip().split()) ans = a * (n // (a+b)) + min(n%(a+b), a) print(ans) if __name__=='__main__': main() " p02811,s796507420,Accepted,"k, x = map(int, input().split()) if k*500 >= x: print(""Yes"") else: print(""No"") " p02789,s592989706,Wrong Answer,"N , M= map(int, input().split()) if N==M: print(""yes"") else: print(""no"")" p03472,s960223322,Wrong Answer,"import bisect n,h=map(int,input().split()) ab = [list(map(int, input().split())) for _ in range(n)] a, b = [list(i) for i in zip(*ab)] b.sort() k=bisect.bisect_left(b,max(a)) b2=b[k:] h-=sum(b[k:]) c=len(b2) c+=(h-1)//max(a)+1 print(c)" p02642,s356258816,Wrong Answer,"n = int(input()) a = list(map(int, input().split())) a.sort() cnt = 0 dp = [True] * (a[-1]+1) pre = -1 flg = False for i in a: if dp[i] == True: cnt += 1 if i == pre: if flg is True: continue else: cnt -= 1 flg = True else: flg = False for j in range(1, a[-1]//i+1): dp[i*j] = False pre = i print(cnt)" p03380,s890218626,Wrong Answer,"from bisect import bisect_left N = int(input()) A = list(map(int,input().split())) A.sort() n = A.pop() index = bisect_left(A, n//2) if index == 0: r = A[0] elif index == N-1: r = A[N-2] else: if abs(n//2-A[index]) < abs(n//2-A[index-1]): r = A[index] else: r = A[index - 1] print(*[n,r])" p03211,s596137194,Wrong Answer,"data = [int(i) for i in input()] ans = 999 for i in range(len(data) - 3): x = (data[i] * 100) + (data[i + 1] * 10) + (data[i + 2]) ans = min(ans, abs(753 - x)) print(ans)" p02873,s194085126,Accepted,"S = input() ans = [0]*(len(S)+1) for i in range(len(S)): if S[i] == ""<"": ans[i+1] = max(ans[i+1], ans[i]+1) for i in range(len(S)): i = len(S)-1 - i if S[i] == "">"": ans[i] = max(ans[i],ans[i+1]+1) print(sum(ans))" p02755,s493208869,Wrong Answer,"a,b = map(int,input().split()) fulla = int(a*12.5) ans = -1 while fulla//12.5 == a: if fulla//10==b: ans = fulla break fulla += 1 print(ans)" p03705,s652208036,Wrong Answer,"n, a, b = map(int, input().split()) if a > b: print(0) exit() if n == 1: print(0) exit() if a == b: print(1) exit() print((n-2)*b - (n-2)*a + 1)" p02717,s903473629,Wrong Answer,"x,y,z=input().split() print(x,y,z) " p02693,s756618787,Wrong Answer,"k = int(input()) a,b = map(int,input().split()) i = 1 c = 0 while k <= b: if a <= k*i<= b: print(""OK"") break elif k*i >b: c = 1 break else: i += 1 if c == 1: print('NG')" p03329,s327643731,Wrong Answer,"def tmp_ans(total_cost, six_cost): res = 0 tmp = n t = six_cost while t > 0: res += t % 6 t //= 6 t = total_cost - six_cost while t > 0: res += t % 9 t //= 9 return res n = int(input()) ans = n for x in range(n): ans = min(ans, tmp_ans(n, x)) print(ans)" p03264,s661339834,Accepted,"n=int(input()) odd=(n+1)//2 even=n//2 print(odd*even)" p02600,s220436304,Accepted,"#dt = {} for i in x: dt[i] = dt.get(i,0)+1 import sys;input = sys.stdin.readline inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()] n = inp() if 400 <= n <= 599: print(8) elif 600 <= n <= 799: print(7) elif 800 <= n <= 999: print(6) elif 1000 <= n <= 1199: print(5) elif 1200 <= n <= 1399: print(4) elif 1400 <= n <= 1599: print(3) elif 1600 <= n <= 1799: print(2) elif 1800 <= n <= 1999: print(1) " p03485,s571089438,Wrong Answer,"def adva(a, b) : c = (a + b) / 2 return int(c)" p03086,s447996478,Wrong Answer,"s =input() l =len(s) count=0 for i in range(l): x =s[i] if x =='A' or x =='C' or x =='G' or x =='T': count +=1 for j in range(i+1, l): x =s[j] if x =='A' or x =='C' or x =='G' or x =='T': count +=1 else: break print(count) " p03673,s607438620,Accepted,"n = int(input()) a = list(input().split()) num = list(range(n-1,-(n-1)-2,-2) ) for i in range(len(num)): if num[i]<0: num[i] = abs(num[i]+1) print(a[num[i]], end = ' ')" p02786,s246819354,Accepted,"import sys h=int(input()) n=0 while h>1: h=h // 2 n+=1 a=1 for i in range(n): a=a*2+1 print(a) " p02677,s027026235,Wrong Answer,"import math a, b, h, m = map(int, input().split()) l = m * 6 s = m * 0.5 + h * 30 th = abs(l - s) if th == 0: print(abs(a - b)) #print('{:.20f}'.format(abs(a - b))) exit() elif th == 180: print(a + b) #print('{:.20f}'.format(a + b)) exit() if th >= 180: th -= 180 cos = math.cos(math.radians(th)) ans = a**2 + b**2 - 2 * a * b * cos print(ans**0.5) #print('{:.20f}'.format(math.sqrt(ans)))" p03657,s787944523,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,s910067779,Accepted,"s =input() ans = [] for i in range(len(s)): if (s[i] == '0') or (s[i] == '1'): ans.append(s[i]) elif ans ==[]: continue else: ans.pop() print(''.join(ans))" p02691,s471301312,Accepted,"from collections import defaultdict N = int(input()) A = map(int, input().split()) d = defaultdict(int) ans = 0 for i, a in enumerate(A): ans += d[-i+a] d[-i-a] += 1 print(ans) " p03745,s434529336,Wrong Answer,"N=int(input()) A=list(map(int,input().split())) if N==1: print(1) exit() B=[A[i]-A[i-1] for i in range(1,N)] ans=0 first=B[0] for i in range(N-1): if first*B[i]>=0: pass else: ans+=1 if i+1<=N-2: first=B[i+1] print(ans+1)" p03059,s169697965,Accepted,"a,b,t=[int(i)for i in input().split()] print((t//a)*b)" p02663,s713025873,Wrong Answer,"h1, m1, h2, m2, k = map(int, input().split()) if k == 60*(h2-h1)+(m2-m1)-k: print('0') else: print(60*(h2-h1)+(m2-m1)-k)" p02811,s977530780,Wrong Answer,"k,y=input().split() coin=k*500 if coin>=y: print(""Yes"") else: print(""No"")" p03814,s403507530,Accepted,"s = input() print(s.rfind(""Z"")-s.find(""A"")+1)" p02658,s685968605,Accepted,"N = int(input().split()[0]) a_list = list(map(int, input().split())) t = 1 if 0 in a_list: t = 0 else: for a in a_list: t *= a if t > 10**18: t = -1 break print(t) " p03435,s642766400,Accepted,"c = [] for _ in range(3): ci = list(map(int,input().split())) c.append(ci) if all([c[0][0]-c[0][1]== c[1][0]-c[1][1],c[1][0]-c[1][1]==c[2][0]-c[2][1],c[0][1]-c[0][2]==c[1][1]-c[1][2],c[1][1]-c[1][2]==c[2][1]-c[2][2]]): print(""Yes"") else: print(""No"") " p03328,s676132569,Accepted,"a, b = map(int, input().split()) print(int((b-a) * (b-a+1) / 2 - b))" p02899,s555975811,Accepted,"import numpy as np N = int(input()) A = np.array([int(x) for x in input().split()]) Sort = [str(x) for x in np.argsort(A)+1] print(' '.join(Sort))" p02646,s760812980,Wrong Answer,"a,v = list(map(int,input().split())) b,w = list(map(int,input().split())) t = int(input()) if (v - w > 0) and (a != b): if abs(a-b) <= (v - w) * t: print(""Yes"") else: print(""No"") elif a == b: print(""Yes"") else: print(""No"")" p03854,s972036145,Accepted,"S = input() words = [""dream"", ""dreamer"", ""erase"", ""eraser""] i = len(S) while i > 0: if S[i - 5 : i] in words: i = i - 5 elif S[i - 6 : i] in words: i = i - 6 elif S[i - 7 : i] in words: i = i - 7 else: break if i > 0: print(""NO"") else: print(""YES"") " p02754,s146003584,Wrong Answer,"nums = [int(e) for e in input().split()] n = nums[0] a = nums[1] b = nums[2] sum = a + b iter = n // sum amari = n % sum if amari >= b: print(iter * a + (b)) else: print(iter * a + (amari))" p03673,s190300694,Accepted,"from collections import deque n = int(input()) A = list(map(int, input().split())) deq = deque() for i in range(n): if i%2==0: deq.appendleft(A[i]) else: deq.append(A[i]) if n%2==0: for i in reversed(range(n)): print(deq[i],end="" "") else: for i in range(n): print(deq[i],end="" "")" p03804,s699539024,Accepted,"N,M=map(int,input().split()) a_l=[] b_l=[] for i in range(N): a_l.append(list(input())) for i in range(M): b_l.extend(input()) count=0 for t in range (N-M+1): for k in range(N-M+1): tmp=[] for i in range(M): for j in range(M): tmp.append(a_l[t+i][k+j]) if tmp == b_l: print('Yes') exit() else: continue print('No') " p03107,s395174622,Accepted,"s=input() print(min(s.count('0'),s.count('1'))*2)" p03146,s505092450,Accepted,"def func1(N): if N%2==0: return N//2 else: return 3*N+1 s = int(input()) a_n = {} for i in range(1, 1000001): if s in a_n: break else: a_n[s] = 1 s = func1(s) print(i)" p03951,s847579235,Accepted,"n = int(input()) s = input() t = input() for i in range(n): if s[i:] == t[:n-i]: print(n*2 - (n-i)) exit(0) print(2*n) " p02675,s438821132,Accepted,"n = input() h = ""24579"" p = ""0168"" b = ""3"" if n[len(n)-1] in h: print(""hon"") elif n[len(n)-1] in p: print(""pon"") else: print(""bon"")" p02791,s844989292,Accepted,"N = int(input()) arr = list(map(int, input().split())) count = 0 mn = float('inf') for i in range(N): if mn >= arr[i]: count += 1 mn =min(mn,arr[i]) print(count)" p03309,s840670802,Wrong Answer,"N = int(input()) A = list(map(int, input().split())) for i in range(N): A[i] = A[i] - i - 1 s = sum(A) t1 = s // N t2 = t1 + 1 ans1 = 0 ans2 = 0 for i in range(N): ans1 += abs(A[i] - t1) ans2 += abs(A[i] - t2) print(min(ans1, ans2))" p02676,s356253670,Accepted,"K = int(input()) S = input() if len(S) <= K: print(S) else: print(S[0:K] + '...')" p02688,s500608684,Accepted,"if __name__ == ""__main__"": n, k = map(int, input().split()) s = set() for i in range(k): d = int(input()) a = list(map(int, input().split())) for j in a: if j not in s: s.add(j) ans = n - len(s) print(ans)" p02687,s321418586,Accepted,"print( ""ARC"" if input() == ""ABC"" else ""ABC"") " p02787,s304297570,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 = [10000000] * 100000 dp[0] = 0 for i in range(N): for j in range(10001): dp[j + A[i]] = min(dp[j + A[i]], dp[j] + B[i]) m = int(1e10) for i in range(H, H + 10001): m = min(m, dp[i]) print(m) " p02754,s733009524,Accepted,"N, A, B = map(int, input().split()) ans = 0 r = N//(A+B) s = N % (A+B) ans = A*r if s <= A: ans += s elif s > A: ans += A print(ans)" p02823,s256120049,Accepted,"import numpy as np N,A,B = map(int,input().split()) x=abs(A-B) if x%2==0: print(x//2) else: y,z=max(N-A,N-B),max(A-1,B-1) a,b=min(A-1,B-1),min(N-A,N-B) c,d=max(A-1,B-1)-a,max(N-A,N-B)-b e,f=c//2+a+1,d//2+b+1 if y>z: print(min(z,e,f)) else: print(min(y,e,f))" p03331,s053977946,Accepted,"N = int(input()) summ = [] for i in range(1,N//2 + 1): A = [] B = [] k = N-i for __ in range(6): A.append(int(i%10)) B.append(int(k%10)) i /= 10 k /= 10 summ.append(sum(A+B)) print(min(summ))" p02697,s651505030,Accepted,"n,m = map(int, input().split()) if n % 2 != 0: for i in range(1,m+1): print(i,n+1-i) else: x = n//2 for i in range((m+1)//2): print(i+1,x-i) for i in range(m//2): print(x+1+i, n-1-i)" p02795,s658789511,Accepted,"a = [int(input()) for _ in range(3)] h, w = sorted([a[0], a[1]]) print(-((-a[2])//w))" p02935,s784921980,Accepted,"n=int(input()) v=list(map(int, input().split())) v.sort() mean=v[0] for i in range(n-1): mean=(v[i+1]+mean)/2 print(mean)" p03408,s123619811,Wrong Answer,"N = int(input()) S = {} for i in range(N): s = input() if s not in S: S[s] = 1 continue S[s] +=1 M = int(input()) T = {} for i in range(M): t = input() if t not in T: T[t] = 1 continue T[t] += 1 ans = 0 for key in S.keys(): if key not in T: ans = S[key] continue ans = max(ans, S[key] - T[key]) print(ans)" p04043,s454381481,Wrong Answer,"A, B, C = map(int, input().split()) if A == 5 and B == 7 and C == 7: print(""YES"") elif A == 7 and B == 5 and C == 7: print(""YES"") elif A == 7 and B == 7 and C == 5: print(""YES"") else: print(""NO"")" p02916,s415523290,Wrong Answer,"kind = int(input()) table_1 = input().split(' ') table_2 = input().split(' ') table_3 = input().split(' ') total = 0 for i in range(kind): total += int(table_2[i]) for j in range(kind-1): if int(table_1[j]) == int(table_1[j + 1]) - 1: total += int(table_3[j]) print(total)" p03319,s713369672,Accepted,"N, K=map(int, input().split()) A=list(map(int, input().split())) idx1=A.index(1) from math import ceil ans=10000000 for i in range(K): left=idx1-i right=left+K-1 if left<0 or right>N-1: continue tmp=ceil(left/(K-1))+ceil((N-1-right)/(K-1))+1 ans=min(ans, tmp) print(ans)" p02987,s823967768,Accepted,"s = input() ans = 0 for i in range(len(s)): if s.count(s[i]) == 2: ans += 1 if ans == 4: print('Yes') else: print('No')" p03251,s669766414,Wrong Answer,"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): print(""No War"") else: print(""War"") " p03623,s376950244,Accepted,"x,a,b = map(int,input().split()) if abs(x-a) > abs(x-b): print('B') else: print('A') " p02657,s389610625,Accepted,"A,B=map(int,input().split()) print(A*B)" p03632,s537818783,Accepted,"a,b,c,d=map(int,input().split()) if b= odd - 1: print('Yes') else: print('No') else: if four >= odd: print('Yes') else: print('No')" p02958,s001679969,Accepted,"N=int(input()) l=list(map(int,input().split())) a=sorted(l) count=0 for i in range(0,len(l)): if l[i]==a[i]: count+=1 if count >= N-2: print(""YES"") else: print(""NO"")" p03105,s621106493,Accepted,"[A,B,C] = list(map(int,input().split())) print(min(C,B//A)) " p02958,s294857624,Accepted,"def q2(): N = int(input()) P = [int(i) for i in input().split()] P_sorted = sorted(P) cnt = 0 for i, p in enumerate(P): if P[i] - P_sorted[i] != 0: cnt += 1 if cnt == 0 or cnt == 2: print('YES') else: print('NO') if __name__ == '__main__': q2() " p02861,s226984398,Wrong Answer,"import math n=int(input()) s=[] for i in range(n): m=[int(x) for x in input().split()] s.append(m) d=0 for i in range(n-1): for j in range(i+1,n): d+=math.sqrt((s[i][0]-s[j][0])**2+(s[i][1]-s[j][1])**2) ans=d*(n-1)/n print(ans)" p02963,s769313698,Accepted,"def agc036_a(): S = int(input()) x1 = y1 = 0 x2 = 10**9 y2 = 1 d, m = divmod(S, x2) if m == 0: y2 = x3 = 0 y3 = d else: x3 = x2 - m y3 = d + 1 ans = [x1, y1, x2, y2, x3, y3] print(*ans, sep=' ') agc036_a()" p02594,s872119138,Accepted,"a = int(input()) print (""Yes"" if a>=30 else ""No"") " p03262,s323505448,Accepted,"import fractions N, X = map(int, input().split()) x = list(map(int, input().split())) x.sort() a = [] for i in range(N): a.append(abs(X - x[i])) ans = a[0] if len(a) > 1: for i in range(1, len(a)): ans = fractions.gcd(ans, a[i]) print(ans)" p02775,s450317830,Accepted,"n = list(map(int, list(input()))) n = n[::-1] + [0] d = len(n) ans = 0 for i, k in enumerate(n): if k < 5: ans += k elif k == 5 and n[i + 1] < 5: ans += k else: ans += 10 - k n[i + 1] += 1 print(ans) " p03417,s967445229,Accepted,"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-2)*(m-2))" p02556,s438688156,Accepted,"# Fast IO (be careful about bytestring, not on interactive) import os,io input=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline N = int(input()) sumList = [] subList = [] for _ in range(N): x,y = map(int,input().split()) sumList.append(x + y) subList.append(x - y) print(max(max(sumList) - min(sumList),max(subList) - min(subList)))" p02784,s215560005,Accepted,"H,N=map(int, input().split()) A=list(map(int, input().split())) if H<=sum(A): print('Yes') else: print('No')" p03000,s574752113,Accepted,"a,b=map(int,input().split()) list=list(map(int,input().split())) count=0 count2=1 for i in range(a): count+=list[i] if count<=b: count2+=1 print(count2) " p03103,s781753107,Accepted,"from operator import itemgetter n, m = map(int, input().split()) pair = [] for _ in range(n): a, b = map(int, input().split()) pair.append((a, b)) pair = sorted(pair, key=itemgetter(0)) cnt = 0 ans = 0 for i in pair: if m - cnt >= i[1]: ans += i[0] * i[1] cnt += i[1] else: ans += i[0] * (m - cnt) break print(ans)" p02683,s792574325,Wrong Answer,"import itertools n,m,x=list(map(int,input().split())) ans=10**6 A=[list(map(int,input().split())) for i in range(n)] for i, _ in enumerate(A,1): for j in itertools.combinations(A,r=i): B=list(zip(*j)) C=[0]*(m+1) for m in range(m+1): C[m]=sum(B[m]) if len([i for i in C[1:] if i>=x ])==m: ans=min(ans,C[0]) print(ans) if ans!=10**6 else print(-1)" p03011,s511349055,Accepted," p, q, r = map(int, input().split()) l = [p, q, r] l = sorted(l) print(l[0]+l[1])" p03860,s010435807,Wrong Answer,"print(""A""+input()[0]+""C"")" p02987,s831213188,Accepted,"S = str(input()) a = S[0] b = S[1] c = S[2] d = S[3] acount = 0 bcount = 0 ccount = 0 dcount = 0 if S.count(a) == 2 and S.count(c) == 2 and S.count(b) == 2 and S.count(d) == 2: print(""Yes"") else: print(""No"") " p03797,s504791130,Accepted,"N,M = map(int,input().rstrip().split("" "")) k = N * 2 + M print(min(k // 4,M//2))" p02696,s055419027,Wrong Answer,"a, b, n = map(int, input().split()) ans = -100 for x in range(1, n+1): if x % b == 0: continue fx = int(a*x/b) - a * int(x/b) if ans < fx: ans = fx print(ans)" p03435,s812522500,Wrong Answer,"print(""Yes"")" p03387,s453917781,Wrong Answer,"A = list(map(int, input().split())) A.sort() ans = A[2]-A[1] ans = ans + (A[2]-(ans+A[0]))//2 if (A[2]-(A[2]-A[1]+A[0]))%2==1: ans += 1 print(ans)" p02935,s217852695,Wrong Answer,"n = int(input()) m = sorted(list(map(int,input().split()))) if len(m) == 2: print(sum(m) / 2) exit() y = m[n-1] / 2 m.pop(-1) x = sum(m) / (len(m)*2) print(x + y)" p02832,s001879562,Wrong Answer,"n = int(input()) a = list(map(int,input().split())) i = 1 if min(a) != 1: print(""-1"") else: while i < len(a): if a[0] != i: a.pop(0) else: i += 1 print(n - len(a))" p02957,s607317612,Accepted,"a,b=map(int, input().split()) if((a+b)%2 == 0): print((a+b)//2) else: print(""IMPOSSIBLE"") " p03730,s874138845,Accepted,"a,b,c = map(int,input().split()) from fractions import gcd print('YNEOS'[c%gcd(a,b)>0::2])" p02952,s284566487,Accepted,"N = int(input()) cnt = 0 for i in range(1,N+1): if(len(str(i)) % 2 ==1): cnt += 1 print(cnt)" p02714,s887210031,Accepted,"import math n = int(input()) s = input() R, G, B = s.count(""R""), s.count(""G""), s.count(""B"") ans = R * G * B for i in range(n): for j in range(n): c1 = i c2 = i + j c3 = i + j * 2 if c3 >= n: break if c1 == c2 == c3: continue if s[c1] != s[c2] and s[c2] != s[c3] and s[c1] != s[c3]: ans -= 1 print(ans) # 012 024 036 048 # 123 135 147 159" p02847,s677901729,Accepted,"d = {'SUN':7, 'MON':6, 'TUE':5, 'WED':4, 'THU':3, 'FRI':2, 'SAT':1} print(d[input()])" p03239,s371783543,Accepted,"N, T = map(int, input().split()) m = 1001 for _ in range(N): c, t = map(int, input().split()) if t <= T: m = min(c, m) print(""TLE"" if m == 1001 else m)" p03377,s071003459,Wrong Answer,"a,b,x=map(int,input().split()) if a<=x and a+b>=x: print(""Yes"") else: print(""No"")" p04034,s893985481,Wrong Answer,"n,m=map(int,input().split()) cnt=[1]*n res=[0]*n res[0]=1 for i in range(m): x,y=map(int,input().split()) if res[x-1]==1: res[y-1]=1 if cnt[x-1]==1: res[x-1]=0 cnt[x-1]-=1 cnt[y-1]+=1 print(cnt,res) print(sum(res))" p03803,s005828723,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')" p03408,s651858889,Accepted,"## B - Two Colors Card Game N = int(input()) S = [] for n in range(N): S.append(input()) M = int(input()) T = [] for m in range(M): T.append(input()) val = [0] for s in set(S): val.append(S.count(s) - T.count(s)) print(max(val))" p03471,s369796486,Wrong Answer,"N, Y = map(int, input().split()) flag = 1 for i in range(N+1): for j in range(N+1): if Y == i * 10000 + j * 5000 + (N-i-j) * 1000 and flag == 1: print(""{} {} {}"".format(i, j, N-i-j)) flag = 0 if flag == 1: print(""-1 -1 -1"")" p02706,s007457701,Accepted,"import math a = input().split() b = map(int,input().split()) c = int(a[0])-sum(b) if (c < 0): print(""-1"") else: print(c) " p02982,s180828653,Accepted,"N, D = map(int, input().split()) P = [list(map(int, input().split())) for i in range(N)] ans = 0 for i in range(N): for j in range(i): d = sum((x - y)**2 for x, y in zip(P[i], P[j])) x = int(d**.5) if x**2 == d: ans += 1 print(ans)" p03387,s929952329,Wrong Answer,"l=list(map(int,input().split())) l.sort() a,b,c=l[0],l[1],l[2] if (b-a)%2==1 and (c-a)%2==1: print(1+(c+1-a)//2+(c-b)//2) elif (b-a)%2==0 and (c-a)%2==0: print((2*c-a-b)//2) else: print(1+(2*c+1-a-b)//2)" p03001,s457307609,Accepted,"W,H,x,y = map(int,input().split()) S = (W*H)/2 if x == W/2 and y == H/2: print(S,1) else: print(S,0) " p02748,s220494349,Accepted,"a,b,m=map(int,input().split()) ali= list(map(int,input().split())) bli= list(map(int,input().split())) min=min(ali)+min(bli) for i in range(0,m): x,y,c=map(int,input().split()) mon=ali[x-1]+bli[y-1]-c if mon180): diff=diff-180 ans=a*a+b*b-2*a*b*abs(math.cos(diff*((math.pi)/180))) print(math.sqrt(ans)) " p03623,s058832754,Accepted,"x,a,b = map(int,input().split()) if abs(x-a) > abs(x-b): print(""B"") else: print(""A"")" p03106,s527823973,Wrong Answer,"from math import * a,b,k=map(int,input().split()) c=0 s=1 while(1): if(a%s==0 and b%s==0): c=c+1 if(c==k): print(s) break s+=1" p02882,s979962666,Accepted,"import math a,b,x = map(int,input().split()) S = x/a if S >= a*b/2: h = 2*(a*b-S)/a print(math.degrees(math.atan2(h,a))) else: h = 2*S/b print(math.degrees(math.atan2(b,h)))" p03815,s296106376,Accepted,"x=int(input()) num1=(x//11)*2 num2=x%11 if num2>=7: num1+=2 elif num2!=0: num1+=1 print(num1) " p03086,s121272267,Accepted,"s = input() + 'n' ans = 0 fans = 0 for i in range(len(s)): if s[i] =='A' or s[i] =='C' or s[i] =='G' or s[i] =='T': ans += 1 elif fans < ans: fans = ans ans = 0 print(fans)" p03544,s965879838,Wrong Answer,"import sys n=int(input()) list=[] sum=0 list.append(2) list.append(1) for i in range(2,87): list.append(list[i-1]+list[i-2]) if n==i: print(list[-1]) sys.exit()" p02866,s327995749,Accepted,"#%% from collections import Counter n = input() d = list(map(int, input().split())) #%% d_cnt =Counter(d) d_cnt = dict(d_cnt) d_cnt_keys = list(d_cnt.keys()) d_cnt_keys.sort() if d[0] != 0 or d_cnt[0] != 1 or len(d_cnt_keys)!= d_cnt_keys[-1]+1: print(0) exit() #%% ans = 1 p = 998244353 for key in d_cnt_keys: if key == 0: continue ans =ans*pow(d_cnt[key-1], d_cnt[key],p)%p print(ans)" p02982,s858228602,Accepted,"#!/usr/bin/env python3 import itertools import math n, d = map(int, input().split()) a = [[] for m in range(n)] for i in range(n): a[i] = list(map(int, input().split())) count = 0 for i in range(n): for j in range(i+1,n): value = 0 for k in range(d): value += (a[i][k] - a[j][k]) ** 2 check = value ** 0.5 count += check.is_integer() print(count)" p04043,s638617482,Wrong Answer,"li = list(map(int, input().split())) if li == [5, 5, 7]: print(""YES"") else: print(""NO"")" p03827,s585309737,Wrong Answer,""""""" 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 for i in S: cnt = 0 if i == 'I': cnt += 1 else: cnt -= 1 ans=max(ans, cnt) " p03075,s140972143,Accepted,"def solve(): import sys read = sys.stdin.read *s, k = map(int, read().split()) flg = True for a in s: for b in s: if abs(a - b) > k: flg = False print(""Yay!"" if flg else"":("") solve()" p02939,s608647980,Wrong Answer,"S=input() ans=1 S0=S[0] N=len(S) ss=list() i=1 while i b or x=2: ans=ans[:len(ans)-1] else: ans='' print(ans)" p03910,s389357851,Accepted,"n=int(input()) ans=[] num=0 i=1 while num= num: if n - num not in ans: ans.append(num) n -= num num += 1 print(*ans, sep='\n') if __name__ == '__main__': main() " p03838,s968949082,Wrong Answer,"x, y = map(int, input().split()) ans = abs(abs(x)-abs(y)) if x < 0 and y < 0 and x > y: ans += 2 elif x > 0 and y > 0 and x > y: ans += 2 elif x < 0 or y < 0: ans += 1 print(ans)" p03043,s727119496,Accepted,"import math n,k = map(int,input().split()) lis = [] for i in range(n): if i+1 >= k: lis.append(0) else: lis.append(math.ceil(math.log2((k/(i+1))))) #print(lis) ans = [] for i in range(n): ans.append(1/n * (1/2)**lis[i]) print(sum(ans))" p03838,s987506703,Wrong Answer,"x, y = map(int, input().split()) if x <= y: print(min(y - x, 1 + abs(abs(y) - abs(x)))) elif x * y < 0: print(1 + abs(abs(y) - abs(x))) else: print(2 + abs(abs(y) - abs(x)))" p03478,s289660114,Wrong Answer,"N, A, B = map(int, input().split()) ans = 0 for i in range(1, N+1): a = i % 10 b = (i - a) % (10 ** 2) //10 c = (i - 10 * b - a) % (10 ** 3) //100 d = (i - 100 * c - 10 * b - a) % (10 ** 4)/1000 if A <= a + b + c + d <= B: ans += i print(ans)" p03160,s767977743,Wrong Answer,"n = int(input()) h = list(map(int, input().split())) INF = 10**8 dp = [INF]*n 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])" p03827,s759576288,Accepted,"n=int(input()) s=input() a=0 ans=0 for i in range(n): if s[i]==""I"": a+=1 else: a-=1 ans=max(a,ans) print(ans)" p02658,s362678061,Accepted,"N = int(input()) A = list(map(int, input().split())) limit = 10 ** 18 res = A[0] if 0 in A: print(0) exit(0) else: for i in range(1, N): res *= A[i] if res > limit: print(-1) exit(0) print(res)" p02725,s945869318,Accepted,"k, n = map(int, input().split()) a = list(map(int, input().split())) max = 0 len = [0] * n for i in range(n): if i == 0: len[i] = a[i] else: len[i] = a[i] - a[i - 1] if len[i] >= len[max]: max = i print(min((k - a[max]) + a[max - 1], a[n - 1] - a[0]))" p02582,s882633302,Accepted,"S = input().rstrip() if S == ""RRR"": print(3) elif S==""SRR"" or S==""RRS"": print(2) elif S == ""RSS"" or S==""SRS"" or S==""SSR"" or S==""RSR"": print(1) else: print(0)" p02953,s821174262,Accepted,"N = int(input()) H = list(map(int, input().split())) H[0] -= 1 for i in range(1, N): if H[i] - H[i - 1] > 0: H[i] -= 1 pre = 0 flg = True for h in H: if h < pre: flg = False break pre = h print('Yes' if flg else 'No') " p03627,s292279368,Accepted,"N=int(input()) A=list(map(int,input().split())) A = sorted(A, reverse=True) tate=0 yoko=0 for i in range(N-1): if A[i]==A[i+1]: tate=A[i] A.remove(A[i+1]) A.remove(A[i]) break for i in range(len(A)-1): if A[i]==A[i+1]: yoko=A[i] break print(tate*yoko)" p02659,s170759019,Wrong Answer,"nums = input().split() a = int(nums[0]) b = float(nums[1]) print(int(a*b)) " p03145,s529199213,Accepted,"a, b, c = map(int, input().split()) print(a * b // 2)" p02723,s242996235,Accepted,"a = list(input().rstrip()) print('Yes') if (a[2] == a[3] and a[4] == a[5]) else print('No') " p03779,s835746048,Accepted,"n=int(input()) a=[1] i=0 count=2 while(a[i]len(s)//2): print(""NO"") else: print(""YES"")" p02647,s599949643,Accepted,"N, K = map(int,input().split()) A = list(map(int,input().split())) import math K = min(K, 43) for k in range(K): light = [0] * (N+1) for i in range(N): start = max(0,i-A[i]) end = min(N-1, i+A[i]) light[start] += 1 light[end+1] -= 1 for i in range(1,N): light[i] += light[i-1] A = light light.pop() print("" "".join(map(str,light))) " p03017,s708075249,Wrong Answer,"import re n, a, b, c, d = map(int, input().split()) s = input() for i in range(a-1, c-1): if s[i] + s[i+1] == ""##"": print(""No"") exit() for i in range(b-1, d-1): if s[i] + s[i+1] == ""##"": print(""No"") exit() if c < d: print(""Yes"") else: f = False for i in range(b-1, d-2): if s[i] + s[i+1] + s[i+2] == ""..."": f = True if f: print(""Yes"") else: print(""No"")" p03137,s985991256,Accepted,"n,m=map(int,input().split()) l=sorted(list(map(int,input().split()))) if n>=m: print(0) exit() s=l[-1]-l[0] l=sorted([a-b for a,b in zip(l[1:],l)], reverse=True) print(s-sum(l[:n-1])) " p03239,s914370923,Wrong Answer,"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"") import collections import math import itertools import heapq as hq import sys n,T = ma() ans=10**15 for i in range(n): c,t=ma() if t0: ans+=1 #print(ins) print(ans) #print(clu)" p02555,s180325167,Accepted,"s = int(input()) dp = [0] * (s+1) dp[0] = 1 for i in range(s+1): for j in range(3, i+1): dp[i] += dp[i-j] dp[i] %= 10**9+7 print(dp[s]) " p03679,s006507701,Accepted,"a, b, c = list(map(int, input().split())) if (c<=b): print(""delicious"") elif (c>b): if (c-b)<=a: print(""safe"") else: print(""dangerous"")" p03251,s645068708,Accepted,"N, M, X, Y = map(int, input().split()) x = input().split() y = input().split() x = [int(i) for i in x] y = [int(i) for i in y] x.sort() y.sort() if (x[-1] < y[0]) and (Y > x[-1]) and (X < y[0]): print(""No War"") else: print(""War"")" p02777,s294261133,Accepted,"[S,T]=list(input().split()) [A,B]=map(int,list(input().split())) U=input() if(U==S): print(A-1,B) else: print(A,B-1)" p02766,s635616827,Accepted,"N,K = map(int,input().split()) for i in range(100): if N a[x-1]+b[y-1]-c: min = a[x-1]+b[y-1]-c print(min)" p03605,s631810648,Wrong Answer,"print(""NYoe s""[input().count(""9"")::2])" p03323,s540305715,Accepted,"A,B = map(int,input().split()) if max(A,B) <= 8: print(""Yay!"") else: print("":("")" p04033,s948465828,Accepted,"a,b=map(int,input().split()) if a<=0 and b>=0: print('Zero') elif a>0: print('Positive') elif a<0 and b>0: if abs(a)%2==0: print('Positive') else: print('Negative') else: if (b-a)%2==0: print('Negative') else: print('Positive')" p03565,s657392510,Wrong Answer,"#coding: utf-8 import math import heapq import bisect import numpy as np from collections import Counter #from scipy.misc import comb S = input() T = input() for i in reversed(range(len(S)-len(T)+1)): flg = 1 for j in range(len(T)): if S[i+j] != '?' and S[i+j] != T[j]: flg = 0 break if flg: ans = S[:i] + T + S[i+len(T)+1:] print(ans.replace('?','a')) exit() print('UNRESTORABLE')" p02696,s931699632,Wrong Answer,"import math a, b, n = map(int, input().split()) if n < b: print('a') ans = math.floor(a*n/b) - a * math.floor(n/b) print(ans) else: ans = a - (a-1) // b - 1 print(ans)" p03262,s891586437,Wrong Answer,"import math n, x = map(int, input().split()) X = sorted(list(map(int, input().split()))) dis = [0] * (n-1) xdis = 0 for i in range(n-1): dis[i] = X[i+1] - X[i] if X[i] <= x <= X[i+1]: xdis = min(abs(x-X[i]), abs(X[i+1]-x)) if n == 1: print(X[0]-x) exit() if xdis == 0: reg = dis[0] else: reg = xdis for i in range(n-1): reg = math.gcd(reg, dis[0]) print(reg)" p02813,s274164628,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))) for i, pe in enumerate(perm, start=1): if P == pe: a = i if Q == pe: b = i print(abs(a - b))" p03471,s585663210,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 = [input() for _ in range(n)] n,y=map(int, input().split()) for a in range(n+1): for b in range(n+1): c = max(n - (a+b), 0) if (a+b+c == n): if (10000*a+5000*b+1000*c == y): print(a,b,c) exit() print(-1,-1,-1) " p03487,s162719456,Wrong Answer,"from collections import defaultdict from collections import deque from collections import Counter 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() c = Counter(readInts()) ans = 0 for i in c: if c[i]-i>0: ans+=c[i]-i elif c[i]-i<0: ans+=min(i-c[i],c[i]) print(ans)" p02546,s770424954,Accepted,"S = input() if S[-1] == ""s"": S += ""es"" else: S += ""s"" print(S)" p02761,s211133252,Accepted,"N, M = map(int, input().split()) C = [list(map(int, input().split())) for _ in range(M)] minN = 0 if N == 1 else 10 ** (N - 1) for t in range(minN, 10 ** N): for s, c in C: if (t // (10 ** (N - s))) % 10 != c: break else: ans = t break else: ans = -1 print(ans) " p02624,s203424084,Accepted,"mem = {} def f(n): if n in mem: return mem[n] ans,b = 0, 1 while(b <= n): k = n / b ans += b *k * (k + 1) / 2 b +=1 mem[n] = ans return ans print f(int(raw_input()))" p03352,s514457289,Accepted,"X = int(input()) ans = [] for b in range(1, 100): for p in range(2, 50): ans.append(b**p) ans = [i for i in ans if i <= X] ans.sort(reverse = True) print(ans[0]) if X!=1 else print(1)" p03804,s972886304,Accepted,"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 g in range(n-m+1): d=[] for l in range(m): d.append(a[l+i][g:g+m]) if d==b: print(""Yes"") exit() print(""No"")" p02725,s439854357,Wrong Answer,"K, N = map(int, input().split()) A = list(map(int, input().split())) d = [] for i in range(N-1): d.append(A[i+1] - A[i]) d.append((K - A[N-1]) + A[0]) print(d) d.remove(max(d)) print(sum(d))" p03162,s031838976,Accepted,"n=int(input()) abc=[list(map(int, input().split())) for _ in range(n)] dp=[0]*3 for a,b,c in abc: dp=[max(dp[1],dp[2])+a,max(dp[0],dp[2])+b,max(dp[0],dp[1])+c] print(max(dp))" p03160,s954495334,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 = NI() h = LI() dp = [INF for _ in range(N)] dp[0] = 0 for i in range(N-1): dp[i+1] = min(dp[i+1],dp[i]+abs(h[i+1]-h[i])) if i < N-2: dp[i+2] = min(dp[i+2], dp[i] + abs(h[i+2]-h[i])) print(dp[-1]) " p03836,s464090069,Accepted,"sx,sy,tx,ty = map(int,input().split()) ans = """" y = ty-sy x = tx-sx ans += ""U""*y+""R""*x+""D""*y+""L""*(x+1)+""U""*(y+1)+""R""*(x+1)+""DR""+""D""*(y+1)+""L""*(x+1)+""U"" print(ans)" p02801,s298798196,Accepted,"#!/usr/bin/env python # -*- coding: utf-8 -*- import string print(string.ascii_lowercase[string.ascii_lowercase.index(input())+1])" p02601,s022535318,Accepted,"import itertools from copy import copy def lr(abc): return def check(abc, k): for i in range(K + 1): for v in itertools.combinations_with_replacement([0, 1, 2], i): ABC_ = copy(ABC) for j in v: ABC_[j] *= 2 if ABC_[0] < ABC_[1] < ABC_[2]: return ""Yes"" return ""No"" ABC = list(map(int, input().split())) K = int(input()) print(check(ABC, K)) " p03814,s778419632,Accepted,"s = input() start = s.find('A') stop = s.rfind('Z') print(stop - start + 1) " p03001,s259096899,Accepted,"w,h,x,y=map(int,input().split()) if x==w/2 and y==h/2: print(w*h/2, 1) else: print(w*h/2, 0)" p02630,s866544322,Accepted,"# 入力 N = int(input()) A = list(map(int, input().split())) Q = int(input()) BC = [list(map(int, input().split())) for _ in range(Q)] array = [0]*(10**5+1) total = sum(A) for a in A: array[a] += 1 for bc in BC: b, c = bc total += c*array[b]-b*array[b] array[c] += array[b] array[b] = 0 print(total) " p02687,s680191096,Accepted,"s=input() if s==""ABC"": print(""ARC"") else: print(""ABC"")" p02571,s856208248,Accepted,"s=input() t=input() ls=len(s) lt=len(t) a=[0]*(ls-lt+1) for i in range(ls-lt+1): for j in range(lt): if s[i+j]!=t[j]: a[i]+=1 print(min(a))" p02970,s244451683,Accepted,"n,d=map(int,input().split()) if n%(d*2+1) == 0:print(int(n/(d*2+1))) else:print(int(n/(d*2+1)) + 1)" p02730,s293587464,Wrong Answer,"s = input() c= 0 for i in range((len(s)-1)//2): if (s[i] != s[(len(s)-1)//2-i-1]) or (s[(len(s)-1)//2+i+1] != s[len(s)-i-1]): c = 0 break else: c +=1 if c ==(len(s)-1)//2: print(""Yes"") else: print(""No"")" p02777,s236205212,Accepted,"s,t=map(str,input().split()) a,b=map(int,input().split()) u=str(input()) print((a-1),b) if u==s else print(a,(b-1))" p02789,s508276020,Accepted,"n, m = map(int, input().split()) if n == m: print(""Yes"") else: print(""No"") " p02854,s066825854,Accepted,"N=int(input()) alist=list(map(int,input().split())) slist=[0] for a in alist: slist.append(slist[-1]+a) #print(slist) answer=float(""inf"") for i in range(N+1): s1=slist[i] s2=slist[-1]-s1 answer=min(answer,abs(s1-s2)) print(answer)" p02958,s906323004,Accepted,"n = int(input()) p = list(map(int,input().split())) count = 0 for i in range(n-1): if p[i] != i+1: count += 1 if count > 2: print(""NO"") exit() print(""YES"") " p04005,s016124663,Accepted,"A,B,C = map(int, input().split()) if A*B*C%2==0: print(0) exit() mylist=[A*B,B*C,A*C] print(min(mylist))" p02797,s270512006,Accepted,"n, k, s = map(int, input().split()) l = [s] * k + [s+1 if s != 10**9 else 1] * (n-k) print(*l) " p02627,s672417869,Accepted,"N = input() if N.isupper() == True: print(""A"") else: print(""a"") " p02723,s392690060,Accepted,"s = input() if(s[2] == s[3] and s[4] == s[5]): print(""Yes"") else: print(""No"") " p03282,s906849269,Accepted,"a = input()[:int(input())] j = set(sorted(set(a), key=a.index)[:2]) j.discard(""1"") print(list(j)[0] if j else 1)" p03565,s131748754,Accepted,"import sys s = input() t = input() tl = len(t) ; sl = len(s) if tl > sl : print('UNRESTORABLE') sys.exit() 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'))" p03210,s164817050,Accepted,"x = input() if x in ['7', '5', '3']: print('YES') else: print('NO')" p03417,s859428919,Accepted,"N,M = (int(X) for X in input().split()) if N==1 or M==1: if N==M: print(1) else: print(max(N,M)-2) else: Four = 4 Six = 2*(N+M-4) Nine = N*M-(Four+Six) print(Nine)" p03471,s549610892,Accepted,"n, y = map(int, input().split()) for i in range(n + 1): for j in range(n - i + 1): if i * 10000 + j * 5000 + (n - i - j) * 1000 == y: print(i, j, n - i - j) exit() print(""-1 -1 -1"")" p02708,s711628303,Accepted,"n,k = map(int,input().split()) ans = 0 mod = 10**9+7 for i in range(k,n+2): M = n*(n+1)//2-(n-i)*(n-i+1)//2 m = (i-1)*(i)//2 ans += M-m+1 ans %= mod print(ans)" p03998,s920173720,Accepted,"sa=input();sb=input();sc=input() s=[1,0,0] ss=[sa,sb,sc] now = sa[0] la=len(sa);lb=len(sb);lc=len(sc) ans=[""A"",""B"",""C""] l=[la,lb,lc] if la<=1: print(""A"") exit() p2n={'a':0,'b':1,'c':2} while 1: nxt=p2n[now] if s[nxt]>=l[nxt]: print(ans[nxt]) exit() tmp=ss[nxt][s[nxt]] s[nxt]+=1 now=tmp" p03220,s547440800,Accepted,"def main(): N = int(input()) T, A = map(int, input().split()) H = [int(x) for x in input().split()] rec = 100000000 ans = 0 for i in range(N): C = T - (H[i] * 0.006) if C < A: C = A - C else: C = C - A if C < 0: C = C * (-1) if rec > C: rec = C ans = i + 1 print(ans) main() " p02790,s733610252,Accepted,"a, b = map(int, input().split()) print(str(a)*b if str(a)*b <= str(b)*a else str(b)*a) " p02702,s892410842,Accepted,"S = input()[::-1] mods = [0]*2019 mods[0] += 1 f = 0 for i in range(len(S)): f = (f+pow(10,i,2019)*int(S[i]))%2019 mods[f] += 1 print(sum([i*(i-1)//2 for i in mods]))" p03261,s767853731,Accepted,"n = int(input()) w = [input() for _ in range(n)] if len(set(w)) != len(w): print('No') else: for i in range(n-1): if w[i][-1] != w[i+1][0]: print('No') exit() print('Yes')" p03103,s842323739,Wrong Answer,"N_ken, M_hon = map(int, input().split()) ab = [] yen = 0 hon = 0 for i in range(N_ken): tmp = list(map(int, input().split())) ab.append(tmp) ab.sort() for a, b in ab: tmp = min(M_hon - hon, b) yen += tmp * a hon += b if (hon == M_hon): break print(yen)" p02552,s286762420,Accepted,"X = int(input()) print(1-X) " p02681,s107656937,Accepted,"S = input() T = input() for i in range(len(S)): if S[i] != T[i]: print('No') break elif S[i] == T[i] and i == len(S)-1: print('Yes') else: pass" p02744,s732661413,Accepted,"import sys sys.setrecursionlimit(10 ** 9) def input(): return sys.stdin.readline().rstrip() def main(): N = int(input()) ABC = (""a"", ""b"", ""c"", ""d"", ""e"", ""f"", ""g"", ""h"", ""i"", ""j"") def dfs(s, n, i): if n == N: print(s) return for j in range(i+1): dfs(s + ABC[j], n+1, i + 1 if i == j else i) dfs(""a"", 1, 1) if __name__ == '__main__': main() " p02813,s773265570,Wrong Answer,"import itertools N = int(input()) P = tuple(map(int, input().split())) Q = tuple(map(int, input().split())) pos = 0 pos_p = 0 pos_q = 0 for i in itertools.permutations(range(1,4)): pos += 1 print(type(i), i) if i == P: pos_p = pos if i == Q: pos_q = pos print(abs(pos_p - pos_q)) " p03817,s824320842,Accepted,"def main(): n = int(input()) ans = 0 ans += n // 11 * 2 if n % 11 <= 6 and n % 11 != 0: ans += 1 elif n % 11 <= 10 and n % 11 > 6: ans += 2 print(ans) main() " p03679,s237406414,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 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 x,a,b=MI() if b<=a: print(""delicious"") elif b-a<=x: print(""safe"") else: print(""dangerous"")" p02724,s119501471,Accepted,"X = input() x = int(X) gosen = x // 500 goen = (x - 500* gosen) // 5 happy = gosen * 1000 + goen * 5 print(happy)" p03486,s705464670,Accepted,"s=input() t=input() s=sorted(s) t=sorted(t,reverse=True) if s= k: print(a) break" p03797,s922707726,Wrong Answer,"N,M = map(int,input().split()) ans=0 ans+=N M=M-N*2 if(M<0): ans = ans - M//2 if(M>0): ans = ans + M//4 print(ans)" p02843,s330639657,Accepted,"#70 C - 100 to 105 WA X = int(input()) dp = [0]*(100010) lst = [100,101,102,103,104,105] for i in range(100,106): dp[i] = 1 # dp[v] が存在するなら 1, しないなら 0 for v in range(100,X+1): for w in range(6): n = lst[w] if dp[v-n] == 1: dp[v] = 1 print(dp[X])" p02784,s278162191,Accepted,"H, N = map(int, input().split()) A = list(map(int, input().split())) if sum(A) >= H: print(""Yes"") else: print(""No"") " p02983,s659013538,Accepted,"l, r = map(int, input().split()) #print(l,r) best = 2019 for i in range(l, min(r,l+2019)): for j in range(l+1,min(r+1,l+2019+1)): if i*j % 2019 < best: best = i*j % 2019 print(best)" p02771,s894489266,Accepted,"a, b, c = map(int, input().split()) abc = len(set([a, b, c])) if ( abc == 2): print('Yes') else: print('No')" p02785,s987110755,Wrong Answer,"n, k = map(int, input().split()) h = list(map(int, input().split())) h.sort() print(sum(h[:n-k]))" p03042,s441200551,Accepted,"s = input() first = int(s[:2]) second =int(s[2:]) if (first > 0 and first < 13) and (second > 0 and second < 13): print(""AMBIGUOUS"") elif (first > 0 and first < 13): print(""MMYY"") elif (second > 0 and second < 13): print('YYMM') else: print('NA') " p03705,s259567212,Accepted,"n,a,b=map(int,input().split()) now=(n-1)*b+a-(n-1)*a-b+1 A=[0,now] print(max(A))" p02683,s821940184,Accepted,"n, m, x = map(int, input().split()) a = [] for i in range(n): b = list(map(int, input().split())) a.append(b) l = [] for f in range(2**n): p = [0]*(m+1) for i in range(n): if (bin(f >> i)[-1] == '1'): for j in range(m+1): p[j] += a[i][j] if min(p[1:]) >= x: l.append(p[0]) if len(l) == 0: print('-1') else: print(min(l))" p03721,s271964029,Accepted,"n, k = map(int, input().split()) S = set() D = dict() for _ in range(n): a, b = map(int, input().split()) if a in S: D[a] += b else: S.add(a) D[a] = b L = sorted(S) cnt = 0 for l in L: cnt += D[l] if cnt >= k: print(l) break" p03487,s345662866,Accepted,"import collections n = int(input()) a = list(map(int,input().split())) b = collections.Counter(a) ans = 0 for k,v in b.items(): if v < k: ans += v else: ans += (v-k) print(ans) " p03698,s610830824,Accepted,"s = input() s = sorted(s) flg = 1 for i in range(len(s) - 1): if s[i] == s[i + 1]:flg = 0 if flg:print(""yes"") else:print(""no"") " p03127,s781825439,Wrong Answer,"n = int(input()) li = list(map(int,input().split())) if len(list(set(li))) == 1: print(li[0]) else: flag = False for l in li: if l%2 == 1: flag = True if flag: print(1) else: print(2)" p03545,s941884581,Wrong Answer,"l = list(input()) for i in range(8): s = int(l[0]) b = bin(i)[2:].zfill(3) op = ["""", """", """"] for j in range(len(b)): if b[j] == ""0"": s += int(l[j+1]) op[j] = ""+"" else: s -= int(l[j+1]) op[j] = ""-"" if s == 7: print(l[0]+op[0]+l[1]+op[1]+l[2]+op[2]+l[3]+""=7"") " p03251,s947554340,Wrong Answer,"N,M,X,Y=map(int,input().split()) L1=list(map(int,input().split())) L2=list(map(int,input().split())) if max(L1)>min(L2): print(""War"") elif max(L1)<=Y and X<=min(L2): print(""No War"") else:print(""War"")" p03106,s623618199,Accepted,"a,b,k=map(int,input().split()) p=[] for i in range(1,a+1): if a%i==0 and b%i==0: p.append(i) n=len(p) print(p[n-k])" p03077,s183781793,Accepted,"import math n = int(input()) a = int(input()) b = int(input()) c = int(input()) d = int(input()) e = int(input()) f = min(a,b,c,d,e) print(math.ceil(n/f)+4)" p02959,s777287128,Accepted,"n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) ans = 0 for i, v in enumerate(b): for j in range(2): m = min(a[i+j], v) a [i+j] -= m v -= m ans += m print(ans) " p02848,s351047534,Wrong Answer,"N = int(input()) S = input() codePoint = [] splitedInput = list(S) wordCount = len(splitedInput) for i in range(wordCount): convertAscii = ord(splitedInput[i]) + N if convertAscii > ord(""Z""): convertAscii = convertAscii - ord(""Z"") + ord(""A"") - 1 conversion = chr(convertAscii) codePoint.append(conversion) print(codePoint)" p02612,s425675828,Accepted,n=int(input());print(1000-n%1000 if n%1000!=0 else 0) p02595,s009872093,Accepted,"#import numpy as np #import collections #import math #f = open('./input_B.txt') # #list(map(int, f.readline().split())) #map(int, f.readline().split()) #int(f.readline()) #f.readline() ans = 0 #list(map(int, input().split())) N,D = map(int, input().split()) D2 = D**2 for i in range(N): X,Y = map(int, input().split()) if X**2 + Y**2 <= D2: ans+=1 #int(input()) #input() print(ans)" p03624,s469520911,Wrong Answer,"S = list(input()) S = sorted(list(set(S))) i = 97 for s in S: if ord(s) != i: print(chr(i)) exit() i += 1 print('None') " p02630,s184037511,Accepted,"#!/usr/bin/env python3 def main(): from collections import Counter N = int(input()) A = list(map(int, input().split())) Q = int(input()) ans = [None] * Q Asum = sum(A) A_Counter = Counter(A) for q in range(Q): B, C = map(int, input().split()) Asum = Asum + (C-B)*A_Counter[B] A_Counter[C] += A_Counter[B] A_Counter[B] = 0 ans[q] = Asum print('\n'.join(map(str, ans))) if __name__ == ""__main__"": main() " p03481,s438918406,Wrong Answer,"import math X, Y = [int(x) for x in input().split()] a = math.log2(Y/X) i = 0 while i <= a: i += 1 print(i) " p03211,s449439097,Wrong Answer,"comp=753 s=input() ans=0 for i in range(7,0,-1): if s.count(str(i)): left = s.find(str(i)) while left!=-1 and left<=len(s)-3: ans = max(ans,int(s[left:left+3])) left = s.find(str(i),left+1) break print(abs(comp-ans))" p03524,s361030998,Accepted,"S = input() cnt = [S.count(x) for x in 'abc'] if max(cnt)-min(cnt) < 2: print('YES') else: print('NO')" p03035,s915292928,Wrong Answer,"A, B = map(int, input().split()) price = 0 if A >= 13: B elif A >= 6 and A <= 12: B/2 else: 0" p02754,s212533362,Accepted,"#設定 import sys input = sys.stdin.buffer.readline #ライブラリインポート from collections import defaultdict con = 10 ** 9 + 7 #入力受け取り def getlist(): return list(map(int, input().split())) #処理内容 def main(): N, A, B = getlist() ans = int(N // (A + B)) * A + min(N % (A + B), A) print(ans) if __name__ == '__main__': main()" p02777,s680182746,Accepted,"S,T=input().split() A,B=map(int,input().split()) U=input() if S==U: print(str(A-1) + "" "" + str(B)) else: print(str(A) + "" "" + str(B-1))" p02664,s657179206,Wrong Answer,"t = input() list_t = list(t) for i in range(len(list_t)): if list_t[i] == '?': if i > 0: if list_t[i - 1] == 'P': list_t[i] = 'D' else: list_t[i] = 'D' if i < len(list_t) - 1: if list_t[i + 1] == 'D': list_t[i] = 'P' print(''.join(list_t))" p03323,s102266505,Wrong Answer,"#-------------------------------------------- #ライブラリ呼び出し import sys import math #-------------------------------------------- D, N = map(int, input().split()) if D ==100: D=101 a=100**D print(a*N)" p02628,s236704865,Accepted,"n,k=map(int,input().split()) p=list(map(int,input().split())) p.sort() print(sum(p[:k]))" p02748,s742796273,Accepted,"a,b,m=map(int,input().split()) alis=list(map(int,input().split())) blis=list(map(int,input().split())) ans=10**18 d=dict() for i in range(m): x,y,c=map(int,input().split()) x-=1 y-=1 d[(x,y)]=c ans=min(ans,alis[x]+blis[y]-c) alis1=[] blis1=[] for i in range(a): alis1.append((alis[i],i)) for i in range(b): blis1.append((blis[i],i)) alis1.sort() blis1.sort() if (alis1[0][1],blis1[0][1]) not in d: ans=min(ans,alis1[0][0]+blis1[0][0]) print(ans)" p02993,s278243946,Accepted,"S = input() flag = False for i in range(len(S) - 1): if S[i] == S[i + 1]: flag = True break if flag == False: print(""Good"") else: print(""Bad"")" p02780,s356568530,Wrong Answer,"n = list(map(int, input().split())) p = list(map(int, input().split())) lists = list() x = n[0] - n[1] + 1 for i in range(x): lists.append(sum(p[i:i+n[1]])) print ((n[1] + max(lists) /2))" p02717,s778625297,Accepted,"x, y, z = input().split() print(z + ' ' + x + ' ' + y)" p03371,s098297642,Wrong Answer,"a, b, c, x, y = map(int, input().split()) ans = 5000*10**5 for i in range(max(x, y)+1): tmp_ans = i*2*c if (x-i)*a > 0: tmp_ans += (x-i)*a if (y-i)*b > 0: tmp_ans += (y-i)*b ans = min(ans, tmp_ans) print(ans) " p02639,s657256601,Accepted,"a, b, c, d, e = map(int, input().split()) if a == 0: print(""1"") elif b == 0: print(""2"") elif c == 0: print(""3"") elif d == 0: print(""4"") elif e == 0: print(""5"")" p02712,s207297101,Accepted,"N = int(input()) cnt = 0 for i in range(1, N+1): if i % 3 == 0 or i % 5 == 0: continue else: cnt += i print(cnt)" p03427,s539192198,Wrong Answer,"n = input() def maxf(n): a = list(map(int, list(n))) for i, item in enumerate(a): if i == 0 and item != 9: a[i] -=1 a[i+1:] = [9]*(len(a)-1) break elif item != 9: a[i-1] -= 1 a[i:] = [9]*(len(a)-i) break return sum(a) print(maxf(n)) " p02725,s372719775,Accepted,"k,n = map(int,input().split()) a = list(map(int,input().split())) if a[0] == 0: dis = [k - a[n-1]] else: dis = [k - a[n-1] + a[0]] for i in range(n-1): dis.append(a[i+1] - a[i]) print(k - max(dis)) " p03962,s577973249,Accepted,"s = list(set(list(map(int, input().split())))) print(len(s)) " p03455,s885331936,Wrong Answer,"int1,int2 = map(int, input().split()) mp = int1*int2 if mp%2 == 0: print(""even"") elif mp%2 == 1: print(""odd"") " p02693,s856572565,Wrong Answer,"if __name__ == '__main__': k = input() k = int(k) ab = input() ab = ab.split() a = int(ab[0]) b = int(ab[1]) i = 1 flag = False while k= 10 or b >= 10: print(ans) else: ans = a*b print(ans)" p03041,s113705929,Accepted,"n,k=map(int,input().split()) s=input() S=s[0:k-1]+s[k-1].lower()+s[k:] print(S) " p03457,s734334429,Wrong Answer,"N=int(input()) pre_t=0 pre_x=0 pre_y=0 flg=0 for i in range(N-1): t,x,y=map(int,input().split()) t_tmp = t t=t-pre_t dist=abs(x-pre_x) + abs(y - pre_y) pre_t=t_tmp pre_x=x pre_y=y if(dist >= t ): flg=1 break if((dist)%2 != t%2): flg=1 break if(flg == 0): print(""Yes"") else: print(""No"") " p02661,s948423737,Accepted,"import statistics n = int(input()) aa = [None] * n bb = [None] * n for i in range(n): a, b = map(int, input().split()) aa[i] = a bb[i] = b def median(arr): if len(arr) % 2 == 0: return (arr[n // 2 - 1] + arr[n // 2]) / 2 else: return arr[n // 2] m = n if n % 2 == 0: m *= 2 medmin = median(sorted(map(lambda x: x * m, aa))) medmax = median(sorted(map(lambda x: x * m, bb))) print(int((medmax - medmin) / n) + 1)" p03607,s152092860,Accepted,"kami = set() N = int(input()) for x in range(N): i = int(input()) if i in kami: kami.remove(i) else: kami.add(i) print(len(kami))" p04020,s935294933,Accepted,"n = int(input()) a = [int(input()) for i in range(n)] ans = 0 ans += a[0]//2 a[0] %= 2 for i in range(1,n): if a[i-1] == 1 and a[i] > 0: ans += 1 a[i] -= 1 ans += a[i]//2 a[i] %= 2 print(ans)" p02576,s719025175,Wrong Answer,"n,x,t = map(int,input().split()) print(round(n/x+0.5)*t)" p02553,s015460395,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(): a,b,c,d = mi() ans = -100000000000000000000 ans = max(a*c,ans) ans = max(b*c,ans) ans = max(a*d,ans) ans = max(b*d,ans) print(ans) main() " p03327,s037926361,Accepted,"n=int(input()) print(""ABC"" if n < 1000 else ""ABD"")" p02577,s178837737,Accepted,"import math N = [int(x) for x in input()] if(sum(N)%9==0): print(""Yes"") else: print(""No"") " p03479,s371436451,Accepted,"x,y=map(int,input().split()) ans=[x] tmp=x while tmpy: pass else: #print(x,y,z) if x==y==z: count+=1 elif x==y or x==z or y==z: count+=3 else: count+=6 print(count)" p02645,s301997061,Accepted,print(input()[:3]) p02615,s770338955,Accepted,"from sys import stdin n = int(stdin.readline()) a = list(map(int,stdin.readline().split())) a.sort(reverse = True) ans = a[0] count = 0 cur = 1 for _ in range(n-2): ans += a[cur] count += 1 if count == 2: count = 0 cur += 1 print(ans) " p02924,s120704049,Accepted,"n = int(input()) print(n * (n-1) // 2)" p02862,s096497934,Accepted,"def mod_inv(a, m): return pow(a, m-2, m) X, Y = map(int, input().split()) MOD = 10 ** 9 + 7 if (X + Y) % 3: print(0) exit() n = (X + Y) // 3 nx, ny = X - n, Y - n if nx < 0 or ny < 0: print(0) exit() ans = 1 for i in range(nx + 1, nx + ny + 1): ans = ans * i % MOD for i in range(1, ny + 1): ans = ans * mod_inv(i, MOD) % MOD print(ans) " p03329,s484888282,Accepted,"from collections import deque N = int(input()) units = set() i = 0 while 6 ** i <= N: units.add(6 ** i) i += 1 i = 0 while 9 ** i <= N: units.add(9 ** i) i += 1 units = sorted(units) mins = list(range(N + 1)) for i in range(1, len(units)): unit = units[i] for j in range(N): if j + unit < len(mins) and mins[j] + 1 < mins[j + unit]: mins[j + unit] = mins[j] + 1 print(mins[N])" p02683,s257361832,Accepted,"import numpy as np N, M, X = map(int,input().split()) CA = [] for _ in range(N): CA.append(list(map(int,input().split()))) MIN = 10 ** 7 for i in range(2**N): cost = 0 result = np.array([0] * M) for j in range(N): if ((i>>j)&1): cost += CA[j][0] result += CA[j][1:] if all(result >=X): MIN = min(cost,MIN) if MIN == 10**7: print(-1) else: print(MIN)" p02701,s907493204,Accepted,"N = int(input()) l = [input() for i in range(N)] l_set = set(l) print(len(l_set))" p02754,s691827790,Accepted,"# coding: utf-8 n, a, b = map(int, input().split()) c = a + b m = n % c mn = n // c if m > a: result = mn * a + a else: result = mn * a + m print(result) " p03457,s068665736,Wrong Answer,"N = int(input()) TXY = [list(map(int, input().split())) for _ in range(N)] pre_t, pre_x, pre_y = 0, 0, 0 for t, x, y in TXY: diff_t = t - pre_t diff_pos = abs(x-pre_x) + abs(y-pre_y) if diff_t < diff_pos or diff_t - diff_pos % 2 == 1: print('No') exit() else: pre_t, pre_x, pre_y = t, x, y print('Yes')" p03644,s850586817,Accepted,"N = int(input()) result = 0 for i in range(7): if N >= 2**i: result = 2**i else: None print(result) " p02784,s896324292,Accepted,"h,n = map(int,input().split()) a = [int(i) for i in input().split()] b = sum(a) if h <= b: print('Yes') else: print('No')" p02683,s587592983,Accepted," import numpy as np n, m, x = map(int, input().split()) refer = [list(map(int, input().split())) for _ in range(n)] ans =[] for i in range(2**n): skill = [] money = 0 for j in range(n): if (i >> j) & 1: skill.append(refer[j][1:]) money += refer[j][0] a = np.array(skill) if np.all(np.sum(a, axis=0) >= x): ans.append(money) if ans == []: print(-1) else: print(min(ans)) " p03767,s705501036,Wrong Answer,"N = int(input()) a = sorted(list(map(int,input().split()))) print(sum([a[2*i-1] for i in range(N)]))" p02801,s737343219,Accepted,"al = input() print(chr(ord(al)+1))" p03386,s398451217,Accepted,"a, b, k = map(int, input().split()) ans = set() r = range(a, b + 1) for i in range(min(k, len(r))): ans.add(r[i]) ans.add(r[-i-1]) else: [print(i) for i in sorted(ans)]" p02705,s534936921,Accepted,"import math r = int(input()) print(2*r*math.pi) " p03493,s604990828,Accepted,"s = list(input()) print(s.count(""1""))" p02988,s388283661,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+2] < P[i+1] 0: A[i] = max(0, A[i] - dif) ans += dif print(ans) " p02947,s467693622,Wrong Answer,"n = int(input()) moji = [] count = 0 for i in range(n): s = sorted(input()) moji.append("""".join(s)) print(moji) result = [] for i in range(n): if moji[i] in result: count += 1 else: result.append(moji[i]) print(count) " p02694,s700888634,Accepted,"import math x = int(input()) money = 100 year = 0 while money < x: year += 1 money = math.floor(money * 1.01) print(year) " p02694,s048213546,Wrong Answer,"if __name__ == '__main__': X = input() X = int(X) factor = 1.01 init = 100 y = 0 while(init <= X): init *= factor init = int(init) y += 1 print(y)" p03041,s369423580,Wrong Answer,"a=list(input()) a.remove("" "") n=int(a[0]) k=int(a[1]) if((k>n) and (k<=1)): exit() if((n>50) and (n<=1)): exit() if(len(a)>n): exit() #n=int(input()) #k=int(input()) s=list(input()) str="""" s[k-1]=s[k-1].lower() print(str.join(s)) #print(str) #print(s)" p02792,s906369356,Accepted," N = int(input()) C = [[0]*(10) for _ in range(10)] for i in range(N+1): S = str(i) s = int(S[0]) e = int(S[-1]) C[s][e] += 1 ans = 0 for i in range(1,10): for j in range(1,10): ans += C[i][j]*C[j][i] print(ans)" p02818,s003838319,Accepted,"A,B,K = list(map(int,input().split())) if A>= K: print(str(A-K) + ' ' + str(B)) elif A < K : print(str(0) + ' ' + str(max(B+A-K,0))) " p02613,s765302003,Wrong Answer,"from collections import Counter n = int(input()) s = list(str(input()) for _ in range(n)) C_s = Counter(s) s_l = ['AC', 'WA', 'TLE', 'RE'] for item in s_l: print(item, ' X ', C_s[item]) " p02995,s132891976,Wrong Answer,"import math A, B, C, D = map(int, input().split()) cnt = 0 LCD = C*D/math.gcd(C,D) ans = B-(B//C + B//D - B//LCD) - ((A-1)-((A-1)//C + (A-1)//D - (A-1)//LCD)) print(int(ans))" p02699,s729678056,Accepted,"S, W = map(int, input().split()) if(S > W): print('safe') else: print('unsafe')" p03455,s727638305,Accepted,"a, b = map(int, input().split()) if a * b % 2 == 1: print('Odd') else: print('Even')" p03038,s041260829,Wrong Answer,"import math n, m = map(int, input().split("" "")) aL = sorted(list(map(int, input().split("" "")))) bcL = sorted([list(map(int, input().split("" ""))) for _ in range(m)], key=lambda x: x[1], reverse=True) csl = 0 for cnt, point in bcL: for i in range(cnt): if csl == n - 1 or aL[csl] >= point: print(sum(aL)) exit() aL[csl] = point csl += 1 print(sum(aL)) exit()" p02829,s952102606,Accepted,"l=['1','2','3'] l.remove(input()) l.remove(input()) print(l[0]) " p03206,s907080779,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"")" p03448,s930046770,Wrong Answer,"A = int(input()) B = int(input()) C = int(input()) X = int(input()) cnt = 0 for a in range(A): for b in range(B): for c in range(C): if a*500+b*100+c*50 == X: cnt += 1 print(cnt)" p03494,s043255703,Accepted,"n = int(input()) aaa = list(map(int, input().split())) ans = 0 while all(i % 2 == 0 for i in aaa): ans += 1 aaa = list(j / 2 for j in aaa) print(ans)" p03838,s511121741,Accepted,"x, y = map(int, input().split()) print(min(max(y-x, x-y+2), abs(x+y)+1))" p02842,s951509097,Accepted,"N=int(input()) for i in range(1,500001): if int(i*1.08)==N: print(i) break else: print(':(') " p02994,s659588758,Accepted,"n,L = map(int,input().split()) taste = [0]*n for i in range(n): taste[i] = L+i taste[taste.index(min(taste, key=lambda x: abs(x)))] = 0 print(sum(taste))" p02582,s640314550,Accepted,"import re x = input() pattern = ""R+"" pat = re.search(pattern, x) if pat: print(len(pat.group())) else: print(0)" p02765,s095703667,Accepted,"N,R=map(int,input().split()) if N<10 : print(100*(10-N)+R) else : print(R)" p03723,s716399459,Accepted,"A,B,C = map(int, input().split()) ans = 0 for ans in range(1000): if A&1 or B&1 or C&1: print(ans) break A,B,C = (B+C)//2, (C+A)//2, (A+B)//2 else: print(-1)" p03493,s756743664,Wrong Answer,"a = input() a.count('1')" p03548,s903474934,Accepted,"def solve(): X, Y, Z = map(int, input().split()) print((X - Z) // (Y + Z)) if __name__ == ""__main__"": solve()" p02952,s978410761,Accepted,"N = int(input()) c =0 for i in range(1,N+1): if len(str(i)) % 2 == 1: c+=1 print(c) " p02623,s056932512,Wrong Answer,"n, m, k = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) c = [] while((len(a) != 0 or len(b) != 0)): if(len(a) == 0): c.append(b[0]);b.pop(0);continue if(len(b) == 0): c.append(a[0]);a.pop(0);continue if(a[0] > b[0]): c.append(b[0]);b.pop(0);continue else: c.append(a[0]);a.pop(0);continue tmp = 0 ans = 0 for i in c: tmp += i if(tmp <= k):ans+=1 else:print(ans);exit() print(ans)" p02779,s822219290,Wrong Answer,"r = 0 n = int(input()) a = sorted(list(map(int, input().split()))) for i in range(n - 1): if a[i] == a[i + 1]: r = 1 if r == 1: print(""No"") else: print(""Yes"")" p02613,s929778595,Accepted,"from collections import defaultdict n = int(input()) d = defaultdict(int) for i in range(n): word = str(input()) d[word]+=1 print(""{} {} {}"".format(""AC"",""x"",d[""AC""])) print(""{} {} {}"".format(""WA"",""x"",d[""WA""])) print(""{} {} {}"".format(""TLE"",""x"",d[""TLE""])) print(""{} {} {}"".format(""RE"",""x"",d[""RE""])) " p03017,s384783057,Accepted,"N,A,B,C,D=list(map(int,input().split())) l=list(input()) if ""##"" in """".join(l[A-1:max(C,D)-1]): print(""No"") exit() if C>D: pass else: print(""Yes"") exit() if ""..."" in """".join(l[B-2:D+1]): print(""Yes"") else: print(""No"")" p03359,s601837094,Accepted,"a, b = map(int, input().split()) if a <= b: print(a) else: print(a - 1)" p02677,s673494785,Accepted,"import math A, B, H, M = map(int, input().split()) pi = math.pi angle = (M * pi)/360 + (H * pi)/6 - (M * pi)/30 X = A**2 + B**2 - 2 * A * B * math.cos(angle) ans = math.sqrt(X) print(ans)" p03524,s264154973,Wrong Answer,"x=list(map(input().count,""abc""));print(""NYOE S""[all([-2=odd : print('Yes') elif even2%2==0: print(""Yes"") else: print('No') " p03495,s926177125,Accepted,"import collections n, k = map(int, input().split()) a = list(map(int, input().split())) ans = 0 list_a = list(collections.Counter(a).values()) dic = dict(zip(collections.Counter(a), list_a)) dic_sorted = sorted(dic.items(), key=lambda x: x[1]) del_num = dic_sorted[:len(dic_sorted)-k] for i in del_num: ans += i[1] print(ans) " p02713,s682987365,Accepted,"from math import gcd def threegcd(a, b, c): return gcd(gcd(a,b), c) k = int(input()) ans = 0 for i in range(1, k+1): for j in range(1, k+1): for k in range(1, k+1): ans += threegcd(i, j, k) print(ans)" p02866,s742663045,Accepted,"from collections import defaultdict, Counter N = int(input()) D = list(map(int, input().split())) c = Counter(D) M = max(c.keys()) if D[0] != 0 or c[0] != 1: print(0) exit() mod = 998244353 depth = 1 ans = 1 while depth <= M: ans *= pow(c[depth - 1], c[depth], mod) ans %= mod depth += 1 print(ans)" p03037,s861446809,Accepted,"N,M = map(int,input().split()) bottom = 0 top = N+1 for i in range(M): L,R = map(int,input().split()) bottom = max(bottom, L) top = min(top,R) ans = top - bottom + 1 print(ans if ans>=0 else 0)" p03625,s909302009,Accepted,"# AtCoder from collections import Counter N = int(input()) A = list(map(int, input().split())) c = Counter(A) sc = sorted(c.items(), key=lambda x: x[0], reverse=True) sides = [] for side, nums in sc: if nums >= 4: sides.append(side) sides.append(side) elif nums >= 2: sides.append(side) if 1 >= len(sides): print(0) exit() s = sorted(sides, reverse=True) ans = s[0]*s[1] print(ans) " p02546,s990481331,Accepted,"s = input() if s[-1] == 's': print(s + 'es') else: print(s+'s')" p03241,s213817316,Accepted,"def getN(): return int(input()) def getNM(): return map(int, input().split()) def getList(): return list(map(int, input().split())) def getArray(intn): return [int(input()) for i in range(intn)] def input(): return sys.stdin.readline().rstrip() from collections import defaultdict, deque, Counter from sys import exit import heapq import math import copy from operator import mul from functools import reduce from bisect import bisect_left, bisect_right import sys sys.setrecursionlimit(1000000000) mod = 10 ** 9 + 7 N, M = getNM() optmax = M // N for i in range(optmax, 0, -1): if M % i == 0: print(i) break" p03038,s972212495,Wrong Answer,"from bisect import bisect_left N,M=map(int,input().split()) A=list(map(int,input().split())) A=sorted(A) change=[tuple(map(int,input().split())) for _ in range(M)] change=sorted(change,key=lambda x: x[1]) change2=[] count=0 for i in range(M): b,c=change[i] change2.extend([c]*b) count += b if count >= N:break A.extend(change2) A = sorted(A) print(sum(A[len(A)-N:]))" p02761,s746952146,Accepted,"N,M=map(int,input().split()) l=[0]*N ans=0 for i in range(M): s,c=map(int,input().split()) if l[s-1]==0 or l[s-1]==c: l[s-1]=c else: print(-1) exit() if s==1 and c==0 and N!=1: print(-1) exit() for i in range(N): ans+=int(l[i])*(10**(N-i-1)) if N==len(str(ans)): print(ans) else: print(10**(N-1)+ans) " p03545,s800432583,Accepted,"A,B,C,D = map(int,input()) tfs = [] rt = str(A) for bt in (True, False): for ct in (True, False): for dt in (True, False): tfs.append([bt,ct,dt]) for bt,ct,dt in tfs: tmp=7-A tmp = tmp-B if bt else tmp+B tmp = tmp-C if ct else tmp+C tmp = tmp-D if dt else tmp+D if tmp == 0: rt+=""+"" if bt else ""-"" rt+=str(B) rt+=""+"" if ct else ""-"" rt+=str(C) rt+=""+"" if dt else ""-"" rt+=str(D) rt+=""=7"" break print(rt)" p02661,s541295391,Wrong Answer,"N = int(input()) AB = [list(map(int, input().split())) for _ in range(N)] a = sorted([a for a, b in AB]) b = sorted([b for a, b in AB]) if N % 2 == 1: print(b[N // 2] - a[N // 2] + 1) elif N % 2 == 0: print((b[(N + 1) // 2] + b[N // 2]) - (a[(N + 1) // 2] + a[N // 2]) + 1) " p02628,s376288672,Accepted,"def main(): import sys #int(sys.stdin.readline()) #s = sys.stdin.readline().rstrip() N, K = map(int, sys.stdin.readline().split()) P = list(map(int, sys.stdin.readline().split())) P.sort() print(sum(P[0:K])) if __name__=='__main__': main()" p02576,s623609592,Accepted,"N, X, T = map(int, input().split()) if N % X == 0: print(int(N / X) * T) else: print(((N // X) + 1) * T) " p02690,s362621768,Accepted,"NUM=1000 X=int(input()) flg=False for i in reversed(range(NUM)): for j in range(-1*NUM,NUM): res=(i**5)-(j**5) if res==X: ans_A=i ans_B=j flg=True break if flg: break print(ans_A,ans_B)" p02747,s730332840,Accepted,"S = input() if S in ['hi', 'hihi', 'hihihi', 'hihihihi', 'hihihihihi']: print('Yes') else: print('No')" p02899,s242362940,Accepted,"N=int(input()) A=list(map(int,input().split())) ANS=[] for i in range(N): ANS+=[[A[i],i+1]] ANS.sort() for i in range(N): print(ANS[i][1])" p03086,s857063949,Accepted,"S = input() max_len = 0 counter = 0 for i in S: if i in 'ACGT': counter += 1 if max_len < counter: max_len = counter else: counter = 0 print(max_len) " p02755,s965195788,Accepted,"a,b=map(int,input().split());l=max(a*25+1>>1,b*10);print(l*(~a*25/2<-l>~b*10)or-1)" p02696,s541265132,Accepted,"import math A, B, N = list(map(int, input().split())) ans = 0 if B+1 < N: C = B+1 else: C = N if B//A == 0: D = 1 elif B//A > 1: D = B//A-1 else: D = B//A for i in range(1, C+1, D): val = math.floor(A*i/B) - A*math.floor(i/B) #print(""i"", i, ""val"", val) ans = max(ans, val) print(ans)" p02647,s379210078,Wrong Answer,"num_bulb, count = map(lambda x: int(x), input().split()) brightness = list(map(lambda x: int(x), input().split())) for i in range(count): next_brightness = [] # それぞれの電球について for j in range(num_bulb): next_brightness.append(0) # それをテラス電球を調べる for k in range(num_bulb): if abs(j - k) < brightness[k] + 0.5: next_brightness[j] += 1 print(' '.join(list(map(lambda x: str(x), next_brightness)))) " p03698,s733948498,Wrong Answer,"S=str(input()) no = False for i in range(len(S)): for k in range(i+1,len(S)): if S[i] == S[k]: no == True break if no: print('no') else: print('yes')" p02755,s952071292,Accepted,"A,B = map(int, input().split()) ## 全探索 for i in range(1,1010,1): ans_8 = int(i * 0.08) if A == ans_8: ans_10 = int(i * 0.10) if B == ans_10: print(i) exit() else: print('-1') " p02793,s258168898,Accepted,"from fractions import gcd def lcm(c,d): return c//gcd(c,d)*d mod=10**9+7 n=int(input()) a=[int(i) for i in input().split()] l=a[0] for i in range(1,n): l=lcm(l,a[i]) ans=0 for i in range(n): ans+=l//a[i] #ans%=mod print(ans%mod) " p03759,s777982478,Accepted,"a, b, c = map(int, input().split()) if b - a == c - b: print('YES') else: print('NO')" p03329,s472247700,Accepted,"N = int(input()) ans = float('inf') for i in range(N+1): j = i count = 0 t=N-i while j > 0: count += j%6 j=j//6 while t > 0: count += t%9 t=t//9 ans = min(ans,count) print(ans) " p02768,s575238364,Accepted,"n,a,b=map(int,input().split()) mod=10**9+7 def nCk(n,k): x=1 y=1 for i in range(k): x=(x*(n-i))%mod y=(y*(k-i))%mod y_inv=pow(y,mod-2,mod) return (x*y_inv)%mod ans=(pow(2,n,mod)-1-nCk(n,a)-nCk(n,b))%mod print(ans)" p02717,s438643086,Accepted,"x,y,z=map(int,input().split()) print(z,x,y)" p03679,s627271202,Wrong Answer,"x,a,b=map(int, input().split()) if bb: print(""safe"") else: print(""dangerous"")" p02627,s105189885,Accepted,"S = input() print('A' if S.upper() == S else 'a')" p02677,s506985259,Accepted,"import math def main(): A, B, H, M = map(int, input().split()) Ax = A * math.sin((H + M / 60) * 30 / 180 * math.pi) Ay = A * math.cos((H + M / 60) * 30 / 180 * math.pi) Bx = B * math.sin(M * 6 / 180 * math.pi) By = B * math.cos(M * 6 / 180 * math.pi) dist = math.sqrt((Ax - Bx) ** 2 + (Ay - By) ** 2) print(dist) if __name__ == '__main__': main() " p03150,s113047988,Wrong Answer,"s=input() t=""keyence"" ans=False for i in range(len(t)): a=t[:i] b=t[i:] if s.find(a)==0 and s.find(b)!=-1: if s[s.find(b)+len(b):]=="""" or (i==0 and s[0]==""k""): ans = True break if ans is True: print(""YES"") else: print(""NO"")" p03555,s164857431,Wrong Answer,"c1 = input() c2 = input() if c1[::-1]==c2: print('YES') else: print('No')" p03862,s645657339,Wrong Answer,"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: continue else: ans += (a[i] + a[i-1] - x) a[i] = x - a[i-1] # print(ans) print(ans)" p03821,s090897680,Accepted,"# import fractions # import sys from sys import stdin n = int(stdin.readline().rstrip()) ab = [list(map(int, stdin.readline().rstrip().split())) for i in range(n)] ab.reverse() ans = 0 for abi in ab: abi[0] += ans if abi[0] % abi[1] == 0: pass else: ans += abi[1] - (abi[0] % abi[1]) print(ans)" p03095,s072475902,Accepted,"from collections import Counter N = int(input()) C = Counter(input()) mod = 10 ** 9 + 7 ans = 1 for v in C.values(): ans *= (v + 1) # 使う:v通り、使わない1通り ans %= mod ans -= 1 print(ans % mod)" p02817,s492191179,Wrong Answer,"def chars_mix_up(a, b): new_a = b[:2] + a[2:] new_b = a[:2] + b[2:] return new_a + ' ' + new_b print(chars_mix_up('abc', 'xyz'))" p03438,s787288269,Accepted,"N = int(input()) a= list(map(int,input().split())) b= list(map(int,input().split())) c = [a[i]-b[i] for i in range(N)] d=sum(b)-sum(a) #c回試行する if d<0: print(""No"") exit() must=0 cnt=0 for num in c: if num>0: must += abs(num) if num*(-1) >= 2: cnt += (-1)*num//2 if must>d: print(""No"") exit() #nokori = d-must #print(must,nokori,cnt) if cnt= H[i]: count += 1 else: ans = max(ans, count) count = 0 L = H[i] ans = max(ans, count) print(ans) " p04030,s802973092,Accepted,"s=input() ans='' for i in range(len(s)): if s[i]!='B': ans+=s[i] else: if len(ans)!=0: ans=ans[:-1] print(ans) " p04030,s630150472,Accepted,"s=input() ss="""" for m in s: if m==""B"": if ss!="""": ss=ss[:-1] else: ss+=m print(ss) " p02678,s114800271,Accepted,"from collections import deque N, M = map(int, input().split()) G = [[] for i 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) q = deque() done = [-1]*N def bfs(fr, now): done[now] = fr for to in G[now]: if done[to] != -1: continue q.appendleft((now, to)) q.appendleft((0, 0)) while q: fr, now = q.pop() if done[now] == -1: bfs(fr, now) print(""Yes"") for fr in done[1:]: print(fr+1) " p02699,s985840438,Accepted,"import sys input = sys.stdin.readline import numpy as np sw = np.array([int(x) for x in input().split()]) ans = ""unsafe"" if sw[1] >= sw[0] else ""safe"" print(ans)" p03720,s981309032,Accepted,"n, m = map(int, input().split()) city = [0] * n for i in range(m): a, b = map(int, input().split()) city[a - 1] += 1 city[b - 1] += 1 for i in city: print(i)" p02792,s539935308,Accepted,"n = int(input()) # a,b = map(int, input().split()) # l = list(map(int, input().split())) count = [[0]*10 for i in range(10)] for i in range(1,n+1): i_str = str(i) mae = int(i_str[0]) usi = int(i_str[-1]) count[mae][usi] += 1 ans = 0 for i in range(10): for j in range(10): ans += count[i][j] * count[j][i] print(ans)" p03012,s908127036,Accepted,"import numpy as np N = int(input()) W = input().split() for i in range(N): W[i] = int(W[i]) min_w= 1000000 for i in range(N-1): w1 = W[:i+1] w2 = W[i+1:] w1 = np.array(w1) w2 = np.array(w2) min_w = min(min_w, abs(np.sum(w2)-np.sum(w1))) print(min_w)" p04034,s281671720,Accepted,"n,m = map(int,input().split()) dic = {} ls = [1]*(n+1) ls[0] = 0 ans = 0 dic[1] = 1 for i in range(m): a,b = map(int,input().split()) ls[a] -= 1 ls[b] += 1 if dic.get(a,0) != 0: if dic.get(b,0) == 0: dic[b] = 1 else: if ls[b] == 1: dic[b] = 0 for j in range(n+1): if ls[j] > 0 and dic.get(j,0) != 0: ans += 1 print(ans)" p03827,s895682229,Accepted,"N = int(input()) S = input() ans = 0 x = 0 for s in S: if s == 'I': x += 1 if ans < x: ans = x elif s == 'D': x -= 1 print(ans)" p02577,s962264981,Accepted,"#!/usr/bin/env python3 N = int(input()) if N % 9 == 0: print('Yes') else: print('No') " p02661,s711134650,Accepted,"N = int(input()) a, b = [], [] for i in range(N): c, d = map(int, input().split()) a.append(c) b.append(d) 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)" p03951,s301108218,Accepted,"N = int(input()) s = input() t = input() pos = 0 # スタートを一文字ずつずらして全探索 for i in range(N): c = 0 for j in range(N-i): # print('::', i, j) # print('!!', s[i+j], t[j]) if s[i+j] == t[j]: c += 1 else: break else: pos = max(pos, c) # print(pos) ans = 2 * N - pos print(ans)" p04011,s549791658,Accepted,"# -*- coding:utf-8 -*- import sys input = sys.stdin.readline n = int(input()) k = int(input()) x = int(input()) y = int(input()) if k<=n: print(k*x+(n-k)*y) else: print(n*x)" p03219,s364798419,Accepted,"x, y = map(int, input().split()) print(x + y // 2) " p03494,s792309881,Accepted,"def main(): cnt = 0 n = int(input()) numlist = [int(x) for x in input().split()] while True: temp=0 for i in range(n): if numlist[i]%2 == 0: temp+=1 numlist[i]=numlist[i]/2 if temp==n: cnt+=1 else: break print(cnt) if __name__=='__main__': main()" p04044,s224120142,Accepted,"n,l=map(int,input().split()) li=[input() for i in range(n)] sortli=sorted(li) print(''.join(sortli))" p03416,s384963954,Accepted,"def check(s): return s == s[::-1] a, b = map(int, input().split()) print(sum(check(str(v)) for v in range(a, b+1)))" p02678,s892485383,Accepted,"from collections import deque n,m=map(int,input().split()) graph=[[] for i in range(n)] sirusi=[0]*n for i in range(m): a,b=map(int,input().split()) a-=1;b-=1 graph[a].append(b) graph[b].append(a) D=deque([0]) visited=[False]*n visited[0]=True while D: v=D.popleft() for i in graph[v]: if visited[i]:continue visited[i]=True sirusi[i]=v D.append(i) print(""Yes"") for i in range(1,n): print(sirusi[i]+1)" p02708,s303176001,Accepted,"N,K = map(int,input().split()) mod = 10**9+7 sum_min = 0 sum_max = 0 diff = 0 while K != N+2: sum_min = 1/2*K*(K-1) sum_max = 1/2*K*(2*N-K+1) diff += sum_max - sum_min+1 K+= 1 diff = diff % mod print(int(diff))" p02555,s827572332,Wrong Answer,"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)" p03611,s159791388,Accepted,"from collections import defaultdict def solve(n, A): count = defaultdict(int) for a in A: count[a - 1] += 1 count[a] += 1 count[a + 1] += 1 return max(count.values()) _n = int(input()) _A = list(map(int, input().split())) print(solve(_n, _A)) " p02786,s728947680,Wrong Answer,"h = int(input()) for i in range(1, 41): x = 2 ** i -1 if h <= x: print(x) break" p02881,s775840188,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(reverse=True) return divisors l = make_divisors(n) ans = float('inf') for a in l: b = n//a ans = min(ans, a+b-2) print(ans)" p02963,s874296581,Wrong Answer,"S = int(input()) ans = [0]*6 ans[2] = 10**9 ans[3] = 1 mod = S%(10**9) b = (10**9-mod)%(10**9) ans[4] = (S+b)//(10**9) ans[5] = b print(*ans)" p02719,s866118174,Accepted,"N,K=map(int, input().split()) a=N%K print(min(a,K-a))" p03251,s974787593,Accepted,"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] < y[0] and X < Y and x[N-1] > X and y[0] < Y: print('No War') else: print('War')" p02576,s257909108,Accepted,"n,x,t=map(int,input().split()) if n%x==0: print(int(n/x*t)) else: print(int(n//x+1)*t)" p02784,s621245616,Wrong Answer,"h,n = map(int,input().split()) a = list(map(int,input().split())) sorted(a) if h <= sum(a[:n-1]): print(""Yes"") else: print(""No"")" p02615,s480488646,Accepted,"def main(): N = int( input()) A = list( map( int, input().split())) A.sort(reverse=True) ans = A[0] for i in range(N-2): ans += A[i//2+1] print(ans) if __name__ == '__main__': main() " p02676,s691852387,Wrong Answer,"k = int(input()) s = input() x = len(s) if k >= x: print(s) else: print(s[0:k+1] + ""..."") " p03556,s022885883,Accepted,"import sys import math x=input() y=int(x) z=math.sqrt(y) w=math.floor(z) print(w**2)" p03338,s428817412,Accepted,"n=int(input()) s=list(input()) num=0 for i in range(n): x=set(s[:i]) y=set(s[i:]) if len(x&y)>num: num=len(x&y) print(num) " p03804,s971476928,Wrong Answer,"#!/usr/bin/env python3 # input = stdin.readline def solve(n,m,original,template): def judge(sy,sx): for i in range(m): for j in range(m): if original[sy+i][sx+j] != template[i][j]: return False return True for i in range(n-m): for j in range(n-m): if judge(i,j): return True return False def main(): N,M = map(int,input().split()) a = [input() for _ in range(N)] b = [input() for _ in range(M)] print(""Yes"" if solve(N,M,a,b) else ""No"") pass if __name__ == '__main__': main() " p02618,s981880620,Accepted,"D = int(input()) c_list = list(map(int,input().split(' '))) s_list = [] for i in range(D): s_list.append(list(map(int,input().split(' ')))) minc = c_list.index(min(c_list)) for day in range(D): maxs = s_list[day].index(max(s_list[day])) print(maxs+1) " p02922,s364906415,Wrong Answer,"a, b = map(int, input().split()) print((b-1)//(a-1)) " p03657,s869038847,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"") " p03086,s132027738,Accepted,"S=list(input()) maxlen=0 for i in range(len(S)): for j in range(i,len(S)): for k in range(i,j+1): #cnt=0 if S[k]!='A' and S[k]!='C' and S[k]!='G' and S[k]!='T': break if k==j and j-i+1>maxlen: maxlen=j-i+1 print(maxlen) " p03695,s954524548,Accepted,"#abc064 c n=int(input()) a=list(map(int,input().split())) color=[False]*8 strongman=0 for i in a: x=i//400 if x<8: color[x]=True else: strongman+=1 human=0 for i in color: if i==True: human+=1 color_min=max(human,1) color_max=human+strongman print(color_min,color_max) " p02957,s499335067,Accepted,"A,B = map(int, input().split()) if (A + B) % 2 == 0 : print ((A + B) // 2) else : print (""IMPOSSIBLE"")" p03721,s772615194,Accepted,"n,k=map(int, input().split()) ab=[list(map(int, input().split())) for _ in range(n)] ab.sort() total=0 for i in range(n): total+=ab[i][1] if total>=k: print(ab[i][0]) break " p03720,s857106430,Accepted,"n,m = map(int,input().split()) loads = [list(map(int,input().split())) for i in range(m)] citys = [0]*n for l in loads: for i in l: citys[i-1]+=1 for i in citys: print(i)" p03038,s246697105,Wrong Answer,"N,M = map(int,input().split()) A = list(map(int,input().split())) A.sort() li = [list(map(int,input().split())) for i in range(M)] li.sort(key=lambda x:x[1],reverse=True) j = count = 0 for i in range(N): if A[i] 0: for t in T: if S[idx-len(t):idx] == t: idx -= len(t) break else: res = 'NO' idx = -1 print(res)" p03284,s755829655,Accepted,"N,K=map(int,input().split()) print((N%K>0)+0)" p02775,s109016468,Wrong Answer,"num = input() result = 0 for i in range(len(num)): if (0 <= int(num[i]) <= 5): result += int(num[i]) else: result += (11 - int(num[i])) print(result)" p03760,s062867358,Wrong Answer,"o = input() e = input() for oi, ei in zip(o, e): print(oi, ei, end="""", sep="""") print()" p02641,s395410616,Accepted,"x, n = map(int, input().split()) a = set(map(int, input().split())) print(min((i for i in range(102) if i not in a), key=lambda y:abs(x-y))) " p02879,s922491208,Accepted,"A, B = map(int, input().split()) if 1 <= A <= 9 and 1 <= B <= 9: print(A*B) else: print(-1) " p03543,s621539096,Accepted,"n = str(input()) if n[0] == n[1] == n[2]: print('Yes') elif n[1] == n[2] == n[3]: print('Yes') else: print('No') " p02958,s887516095,Accepted,"N=int(input()) S=list(map(int,input().split())) Z=[] tmp=[] for i in range(N): Z.append(S[i]) tmp.append(S[i]) Z.sort() for i in range(N): for j in range(N): R=tmp[i] tmp[i]=tmp[j] tmp[j]=R if tmp==Z: print(""YES"") exit() R=tmp[i] tmp[i]=tmp[j] tmp[j]=R print(""NO"") " p03943,s721455859,Accepted,"def actual(a, b, c): if (a + b) == c or (b + c) == a or (c + a) == b: return 'Yes' return 'No' a, b, c = map(int, input().split()) print(actual(a, b, c))" p02948,s244351362,Accepted,"from heapq import heappush, heappop n, m = map(int, input().split()) jobs = [] for i in range(n): a, b = map(int, input().split()) jobs.append([a, b]) jobs = sorted(jobs, key=lambda x:x[0]) hq = [] res, j = 0, 0 for i in range(1, m + 1): while j < n and jobs[j][0] <= i: heappush(hq, -jobs[j][1]) j += 1 if len(hq) > 0: res += -heappop(hq) print(res)" p02744,s678835271,Accepted,"N = int(input()) def sub(l, d): if d == N: s = """".join([""abcdefghijklmnopqrstuvwxyz""[i] for i in l]) print(s) return for j in range(max(l)+1+1): sub(l+[j], d+1) sub([0], 1) " p02555,s651521431,Accepted,"S = int(input()) count = 0 for size in range(1, S//3+1): extra = S - 3 * size # 0以上の値をどう分配するか?数列なので純不動ではない total = extra + size -1 # extra個の玉とsize-1個の棒の並び替え問題 number = 1 for n in range(extra+1, total+1): number *= n for n in range(1, size): number //= n count += number # print(size,number) print(count % (10 ** 9 + 7))" p04045,s399432516,Accepted," N,K = map(int,input().split()) D = list(map(int,input().split())) use = [i for i in range(10)] #使える数字 for i in range(K): use.remove(D[i]) ans = N while True: flag = True for item in list(str(ans)): if not (int(item) in use): flag = False if flag: break else: ans += 1 print(ans)" p02608,s460762891,Wrong Answer,"N = int(input()) L=[0]*N for x in range(1,100): for y in range(1,100): for z in range(1,100): f=x**2+y**2+z**2+x*y+y*z+z*x if f<=N: if x==y==z: L[f-1]=1 else: L[f-1]=3 for i in range(N): print(L[i])" p03673,s125858327,Accepted,"from collections import deque n = int(input()) A = deque(map(int, input().split())) b = deque([]) if n%2==0: for i in range(n): if i%2 ==0: b.append(A[i]) else: b.appendleft(A[i]) else: for i in range(n): if i%2 ==0: b.appendleft(A[i]) else: b.append(A[i]) print(*b)" p02862,s115688217,Accepted,"MOD = 10 ** 9 + 7 X, Y = map(int, input().split()) if (X + Y) % 3 or Y > 2 * X or Y < X // 2: print(0) exit() n = (X + Y) // 3 r = X - (X + Y) // 3 num, den = 1, 1 if n - r < r: r = n - r for i in range(1, r + 1): num *= n - i + 1 num %= MOD den *= i den %= MOD print((num * pow(den, MOD - 2, MOD)) % MOD)" p03695,s569299657,Accepted,"n = int(input()) a = list(map(int,input().split())) c = [0]*9 for i in a: b = i//400 if b >= 8: c[8] += 1 else: c[b] =1 print(sum(c[:8])+(1 if c[8] and sum(c[:8])==0 else 0),sum(c[:8])+c[8])" p02677,s743128029,Accepted,"import math buf = input().split("" "") A=int(buf[0]) B=int(buf[1]) H=int(buf[2]) M=int(buf[3]) #omega_min = 360/3600 #omega_hour = 360 / (3600*12) #theta_min = omega_min*M*60 #theta_hour = omega_hour*H*3600 + M/60/12 """""" if H*5 > M: rad = math.radians(theta_hour-theta_min) else: rad = math.radians(theta_min-theta_hour) """""" rad=math.pi*2 *(H / 12.0 + (M / 60.0) / 12.0 - M / 60.0) ans = math.sqrt( A**2 + B**2 - 2*A*B*math.cos(rad)) print(ans)" p03821,s523036278,Accepted,"N=int(input()) c=0 L=[list(map(int,input().split())) for _ in range(N)] L=L[::-1] for i in range(N): a,b=L[i] a+=c c+=b-(a%b)-(a%b==0)*b print(c)" p02923,s307582823,Accepted,"n = int(input()) h = list(map(int, input().split())) MAX = 0 step = 0 for i in range(n-1): if h[i]-h[i+1]>=0: step += 1 else: MAX = max(MAX, step) step = 0 MAX = max(MAX, step) print(MAX)" p03657,s344773532,Wrong Answer,"a, b = map(int, input().split()) if (a+b)%3: print(""Impossible"") else: print(""Possible"") " p02684,s946678672,Accepted,"n,k,*a=map(int,open(0).read().split()) b=[-1]*(n+1) b[1]=0 c=a[0] d=[0]*min(k+1,10**7) d[0]=1 for i in range(1,k+1): d[i]=c if b[c]!=-1: # print(i,c,b[c]) print(d[b[c]+(k-b[c])%(i-b[c])]) exit() b[c]=i c=a[c-1] print(d[-1]) " p03657,s332662141,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')" p03625,s498101313,Accepted,"import collections N = int(input()) a = [int(i) for i in input().split()] check = [] dict = collections.Counter(a) for a, b in dict.items(): if b >= 2: check.append(a) if len(check) >=2: check.sort() if dict[check[-1]] >= 4: print(check[-1] ** 2) else: print(check[-1] * check[-2]) elif len(check) == 1: if dict[check[-1]] >= 4: print(check[-1] ** 2) else: print(0) else: print(0)" p02843,s461065252,Accepted,"X = int(input()) d = X //100 if d >=20: print(1) exit() k = X % 100 if 5 * d >= k: print(1) else: print(0)" p02879,s982097683,Accepted,"A, B = map(int, input().split()) if A < 10 and B < 10: print(int(A*B)) else: print(-1)" p02842,s887418468,Accepted,"import math n = int(input()) ans = math.ceil(n/1.08) if n == int(ans*1.08): print(ans) else: print("":("")" p02628,s864943891,Accepted,"N, K = map(int, input().split()) p = list(map(int, input().split())) p.sort() print(sum(p[:K]))" p03449,s048519523,Wrong Answer,"import math from itertools import accumulate N = int(input()) A1 = list(map(int,input().split())) A2 = list(map(int,input().split())) AC1 = list(accumulate(A1)) AC2 = list(accumulate(A2)) #print(AC1,AC2) ans = 0 if N == 1: print(AC1[0] +AC2[0]) else: for i in range(N): ans = max(ans,AC1[i] + (AC2[-1] - AC2[i-1])) print(ans)" p03524,s363289458,Accepted,"import sys s = sys.stdin.readline().rstrip() S = [s.count(i) for i in ('a','b','c')] S.sort() if S[2] - S[0] <= 1: print(""YES"") else: print(""NO"")" p02640,s586882933,Accepted,"X, Y = map(int, input().split()) ans = 'No' for a in range(X + 1): b=X-a if 2 * a + 4 * b == Y: ans = 'Yes' print(ans) " p03556,s648385675,Accepted,"import math n = int(input()) a = int(math.sqrt(n)) print(a**2)" p02854,s601235208,Accepted,"n = int(input()) A = list(map(int, input().split())) s = sum(A) l = 0 ans = 10**18 for i in range(n-1): l += A[i] r = s-l ans = min(ans, abs(l-r)) print(ans) " p03067,s738886926,Accepted,"a, b, c = map(int, input().split()) if a < c < b or b < c < a: print('Yes') else: print('No') " p02957,s852221793,Accepted,"def resolve(): A, B = list(map(int, input().split())) print((A+B)//2 if (A+B)%2==0 else ""IMPOSSIBLE"") if '__main__' == __name__: resolve()" p04031,s934619454,Wrong Answer,"import math n = int(input()) a = list(map(int, input().split())) work = math.ceil(sum(a)/n) result = 0 for el in a: result += (work-el)**2 print(result)" p02646,s354871420,Wrong Answer,"A, V = map(int, input().split()) B, W = map(int, input().split()) T = int(input()) for i in range(T): A = A + V B = B + W if(A>=B): print(""YES"") break if(i==T-1): if(A T: continue out.append((c, t)) print(min(out)[0]) if out and min(out)[0] <= T else print(""TLE"")" p02819,s098834433,Wrong Answer,"x=int(input()) if(x%2==0): a=x/2 else: a=x//2+1 y=2*a+1 import math def is_prime(n): for i in range(2,int(math.sqrt(n))+1): if n%i==0: return False return True while(True): if(is_prime(y)): break y=y+2 if x==2: y = 2 print(str(int(y)))" p03380,s678068723,Accepted,"N = int(input()) A = list(map(int, input().split())) x = max(A) d = 10**18 for a in A: if a == x: continue tmp = abs(x/2-a) if tmp < d: d = tmp y = a print(x, y) " p03592,s994986327,Accepted,"N, M, K = map(int, input().split()) for x in range(M+1): for y in range(N+1): if x*N + y*M - 2*x*y == K: print('Yes') exit() print('No')" p03059,s695065796,Accepted,"a, b, t = [int(x) for x in input().split()] s = 0 x = a while x <= t + 0.5: s += b x += a print(s) " p02780,s679030662,Accepted,"#!/usr/bin/env python3 import sys input = sys.stdin.readline INF = 10**9 n, k = map(int, input().split()) p = [int(item) for item in input().split()] total = 0 for i in range(k): total += p[i] max_t = total l = 0; r = k for i in range(k, n): total += p[i] - p[i-k] if total > max_t: max_t = total l = i - k r = i print(0.5 * k + max_t / 2.0)" p02697,s242730925,Accepted,"N, M = map(int, input().split()) for i in range((M + 1) // 2): print(i + 1, i + (M - 2 * i) + 1) for i in range(M - (M + 1) // 2): print(M + 1 + i + 1, M + 1 + i + (M - 1 - 2 * i) + 1)" p03146,s341959370,Accepted,"import math def py(): print(""Yes"") def pn(): print(""No"") def iin(): x = int(input()) return x neko = 0 nya = 0 nuko = 0 b = iin() f = [0] * 1000001 i = 1 while True: if f[int(b)] == 0: f[int(b)] = i else: break b = 3 * b + 1 if b%2 else b/2 i = i + 1 print(i)" p02792,s819021860,Wrong Answer," s=input() n=int(s) d={} for i in range(1,n): ts=str(i) hs=ts[0]+"" ""+ts[len(ts)-1] if(hs in d): d[hs]+=1 else: d[hs]=1 ans=0 for i in range(1,10): for j in range(1,10): if(((str(i)+"" ""+str(j)) in d) and ((str(j)+"" ""+str(i)) in d)): ans+=d[(str(i)+"" ""+str(j))]*d[(str(j)+"" ""+str(i))] print(ans) " p03437,s548971123,Accepted,"x,y = map(int,input().split()) if x % y == 0: print(""-1"") else: print(x)" p02702,s156142089,Accepted,"S = input() count = 0 exist = [0]*2019 flg = False N = len(S) sum = 0 for i, s in enumerate(reversed(S)): sum += (int(s) * pow(10, i, 2019)) % 2019 exist[sum % 2019] += 1 for e in exist: if e > 1: count += e*(e-1)//2 count += exist[0] print(count) " p02629,s210131410,Wrong Answer,"N = int(input()) x = [] while (N == 0): N, i = divmod(N, 26) x = i + 96 print(x)" p02687,s108260918,Accepted,"S = input() if S == ""ABC"": print(""ARC"") else: print(""ABC"") " p02555,s008345070,Wrong Answer,"S = int(input()) a = [0] * 2000 a[0] = 0 a[1] = 0 a[2] = 1 a[3] = 1 a[4] = 1 a[5] = 2 k = 0 for i in range(6, S): for l in range(2, i-2): k += a[l] a[i] = 1 + k p = a[S-1] % (10**9 + 7) print(p)" p03359,s874574171,Wrong Answer,"a,b = map(int,input().split()) print(a - b < a)" p02933,s780873746,Accepted,"a = int(input()) s = input() if a >=3200: print(s) else: print(""red"")" p02603,s120763481,Wrong Answer,"N = int(input()) A_l = list(map(int, input().split())) A_l.append(0) money = 1000 stock = 0 for i in range(N): if A_l[i] < A_l[i+1]: stock = money // A_l[i] money = money % A_l[i] if A_l[i] > A_l[i+1] and stock != 0: money = stock * A_l[i] + money stock = 0 print(money)" p02647,s266436935,Accepted,"n,k,*A=map(int,open(0).read().split());e=enumerate for _ in '_'*min(k,99): S=[0]*(n+1) B=[0]*(n+1) for i,a in e(A):S[max(0,i-a)]+=1;S[min(n,i+a+1)]-=1 for i,s in e(S[:-1]):B[i+1]=B[i]+s A=B[1:] print(*A)" p02678,s214743143,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) dist = [-1] * (n+1) dist[0] = 0 dist[1] = 0 d = deque() d.append(1) ans = [0] * (n+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[i] = v print('Yes') print(*ans[2:], sep='\n')" p02780,s224515946,Accepted,"n,k = map(int,input().split()) p = list(map(int,input().split())) ans = [(sum(p[:k])+k)/2] for i in range(n-k): ans.append(ans[-1]+p[i+k]/2-p[i]/2) print(max(ans)) " p03254,s386895103,Accepted,"from itertools import accumulate import bisect N, x = map(int, input().split()) a = sorted(list(map(int, input().split()))) c = list(accumulate(a)) ans = bisect.bisect_right(c, x) if not ans: print(ans) else: print(ans if c[N - 1] >= x else ans - 1)" p02578,s842624141,Wrong Answer,"n,*a=map(int,open(0).read().split()) ma=a[0] ans=0 for q in a: if q>ma: ans+=(q-ma) ma=max(ma,q) print(ans) " p03951,s232659544,Accepted,"N = int(input()) S = input() T = input() ans = 2 * N for i in range(1, N + 1): if S[-i:] == T[:i]: ans = 2 * N - i print(ans) " p03860,s999028295,Accepted,"print(""A%sC""%input()[8])" p03000,s333580229,Accepted,"n, x = map(int, input().split()) l = list(map(int, input().split())) d = [0] * (n+1) ans = 1 for i in range(1, n+1): d[i] = d[i-1] + l[i-1] if d[i] <= x: ans += 1 print(ans) " p03038,s394949833,Accepted,"N, M = map(int, input().split()) A = list(map(int, input().split())) #SA = sorted(A) D = [] for _ in range(M): B, C = map(int, input().split()) D.append([B, C]) SD = sorted(D, key=lambda x:x[1], reverse=True) for b, c in SD: A += b * [c] if len(A) > N*2: break SA = sorted(A, reverse=True) #X = min(N, len(SD)) #SD = SD[:X] print(sum(SA[:N])) " p02646,s663375567,Accepted,"a, v = (int(i) for i in input().split(' ')) b, w = (int(i) for i in input().split(' ')) t = int(input()) flag = False if a < b: l1 = a + v * t l2 = b + w * t if l1 >= l2: flag = True else: l1 = a + (v * -1) * t l2 = b + (w * -1) * t if l1 <= l2: flag = True print(""YES"" if flag else ""NO"")" p02576,s093140672,Accepted,"import math n,x,t=map(int, input().split("" "")) print(math.ceil(n / x) * t)" p03150,s630668812,Wrong Answer,"S = input() j = ""keyence"" now = 0 out = 0 for i in range(len(S)): if S[i] == j[now]: now += 1 if now == 7: break else: out += 1 if out == 2: break if now == 7: print(""YES"") else: print(""NO"") " p02602,s788624602,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) res = [] for i in range(k, n): res.append(a[i-k] < a[i]) #print(res) for b in res: if(b): print(""Yes"") else: print(""No"")" p02835,s760063628,Accepted,"# ABC 147: A – Blackjack total = sum(map(int, input().split())) print('win' if total <= 21 else 'bust')" p03419,s162327884,Accepted,"N,M=map(int,input().split(' ')) if N==1 and M==1: print(1) elif N==1 or M==1: print(max(N,M)-2) else: print(N*M-2*(N+M-2))" p03434,s757071630,Wrong Answer,"N = int(input()) A = list(map(int, input().split())) Alice = 0 A.sort() for i in range(1,N,2): Alice += A[i] print(2*Alice - sum(A))" p02771,s290111689,Accepted,"print('Yes') if len(set([int(i) for i in input().split()])) == 2 else print('No') " p03767,s104949610,Accepted,"N = int(input()) a_lst = [int(x) for x in input().split()] a_lst.sort(reverse=True) sum = 0 for i in range(1, 2*N, 2): sum += a_lst[i] print(sum) " p03617,s322037875,Wrong Answer,"q,h,s,d=map(int,input().split()) n=int(input()) l=min(q*n*4,h*n*2,s*n,d*n/2) if l != d*n/2: print(l) else: m=min(q*4,h*2,s) print(int((d*(n-1)/2)+m) if n%2==1 else int(l))" p03106,s511226917,Accepted,"a, b, k = map(int, input().split()) li = [] for i in range(1, 101): if a%i == 0 and b%i == 0: li.append(i) print(li[-k])" p03241,s836682286,Wrong Answer,"x,y=map(int,input().split()) lol=[1] a=0 k=pow(y,0.5) for i in range(2,int(k)+1): if y%i==0: if i*x<=y: a=max(a,i) if (y//i)*x<=y: a=max(a,i) print(a) " p03457,s092295397,Accepted,"N = int(input()) t=x=y=0 for _ in range(N): ti,xi,yi = map(int,input().split()) T = ti-t X = xi-x Y = yi-y if ((T%2==0 and (X+Y)%2==0) or (T%2==1 and (X+Y)%2==1)) and T >= abs(X+Y): t=ti x=xi y=yi else: print('No') break else:print('Yes')" p02640,s583453664,Wrong Answer,"x,y=map(int,input().split()) if 2*x<=y and y<=4*x and y&2==0: print(""Yes"") else: print(""No"")" p02600,s094123381,Accepted,"x = int(input()) print(10 - x//200)" p02647,s958344396,Accepted,"n, k = map(int, input().split()) a = [int(i) for i in input().split()] for j in range(min(k, 42)): bit = [0 for _ in range(n)] for i in range(n): bit[max(i - a[i], 0)] += 1 if i + a[i] + 1 < n: bit[i + a[i] + 1] -= 1 result = [bit[0]] for i in range(n - 1): result.append(bit[i + 1] + result[-1]) a = result print(' '.join(list(map(str, a)))) " p03693,s324154627,Accepted,"r, g, b = map(int, input().split()) ans = r * 100 + g * 10 + b if ans % 4 == 0: print('YES') else: print('NO')" p02897,s680222910,Accepted,"icase=0 if icase==0: n=int(input()) if n%2==0: print(0.5) else: print(1.0-(n//2)/n)" p03971,s769857974,Wrong Answer,"(n,an,bn) = list(map(int,input().split())) s = list(input()) count = 1 foreign = 1 for i in s: if i=='a' and an+bn >= count: print('Yes') count += 1 elif i=='b' and an+bn > count and bn >= foreign: print('Yes') count += 1 foreign += 1 else: print('No')" p03435,s070135091,Accepted,"c = [list(map(int, input().split())) for i in range(3)] r1 = sum(c[0][j] for j in range(3)) r2 = sum(c[1][j] for j in range(3)) r3 = sum(c[2][j] for j in range(3)) c1 = sum(c[i][0] for i in range(3)) c2 = sum(c[i][1] for i in range(3)) c3 = sum(c[i][2] for i in range(3)) if r1 % 3 == r2 % 3 == r3 % 3 and c1 % 3 == c2 % 3 == c3 % 3: print(""Yes"") else: print(""No"")" p02711,s835550274,Wrong Answer,"no = int(input()) c = 0 while no > 0: if no%10 == 7: c = 1 no = no/10 if c == 1: print(""Yes"") else : print(""No"")" p03639,s059609526,Accepted,"from sys import stdin, setrecursionlimit def main(): input = stdin.buffer.readline n = int(input()) a = list(map(int, input().split())) c0 = 0 c4 = 0 for ai in a: if ai % 2 != 0: c0 += 1 if ai % 4 == 0: c4 += 1 if c0 + c4 == n and c0 == c4 + 1: print('Yes') elif c0 > c4: print('No') else: print('Yes') if __name__ == ""__main__"": setrecursionlimit(10000) main() " p03680,s344730808,Wrong Answer,"n = int(input()) q = [int(input()) for i in range(n)] cnt = 0 ind = 0 for i in range(n): m = q[ind]-1 if ind+1 == q[m]: if ind+1 == 2 or q[m]==2: print(cnt) break print(-1) exit() ind = q[ind]-1 cnt += 1 if ind == 1: print(cnt) break " p02917,s671799974,Wrong Answer,"n = int(input()) b = list(map(int,input().split())) ans = b[0] for i in range(n-2): ans = ans + min(b[i],b[i+1]) ans = ans + max(b[n-2],b[n-3]) print(ans)" p02753,s634953992,Accepted,"s = input() print('No' if s in ['AAA', 'BBB'] else 'Yes') " p02951,s994790224,Accepted,"a, b, c = map(int, input().split()) d = a-b e = c-d if e > 0: print(int(e)) else: print(0)" p03720,s137890630,Accepted,"n,m = map(int,input().split()) input_lines = [[int(j)-1 for j in input().split()]for i in range(m)] map_list = [[0 for i in range(n)] for i in range(n)] for line in input_lines: map_list[line[0]][line[1]]+=1 map_list[line[1]][line[0]]+=1 for li in map_list: print(sum(li))" p03799,s561922081,Wrong Answer,"s,c = map(int,input().split()) res = 0 if s*2 <= c: res += s c -= s*2 s = 0 else: res += c//2 c //= 2 #print(res,s,c) if c: res += c//4 print(res)" p03633,s889684843,Accepted,"import math from functools import reduce def lcm_base(x, y): return (x * y) // math.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()) t = [0]*n for i in range(n): t[i] = int(input()) print(lcm_list(t))" p03286,s619071857,Wrong Answer,"n = int(input()) ans = """" while n != 0: if n % 2 == 1: ans += ""1"" n = n - 1 n //= -2 else: ans += ""0"" n //= -2 print(ans[::-1] if n != 0 else 0)" p03612,s100018659,Accepted,"import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines n = int(readline()) p = list(map(int, readline().split())) ans = 0 ok = True for i in range(n): if p[i] == i+1 and ok: ans += 1 ok = False else: ok = True print(ans) " p02547,s763426394,Wrong Answer,"def main(): n = int(input()) cnt = 0 for i in range(n): a,b = map(int,input().split()) if cnt == 3: print('Yes') return if a == b: cnt += 1 else: cnt = 0 print('No') main() " p03944,s863032054,Accepted,"#!/usr/bin/env python # coding: utf-8 # In[11]: W,H,N = map(int, input().split()) l,r,u,d = 0,W,H,0 for _ in range(N): x,y,a = list(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))*max(0,(u-d))) # In[ ]: " p03069,s187010906,Accepted,"n, s = int(input()), input() ans, lb, rw = s.count('.'), 0, s.count('.') for i in s: if i == '#': lb += 1 elif i == '.': rw -= 1 ans = min(ans, lb + rw) print(ans) " p03494,s773699101,Accepted,"n = int(input()) existing_list = list(map(int,input().split())) counts = 0 while all(num%2 ==0 for num in existing_list): length = 0 for a in existing_list: division = a/2 existing_list[length]=division length +=1 counts +=1 print(counts)" p03627,s769061762,Accepted,"N = int(input()) As = list(map(int, input().split())) from collections import Counter c = Counter(As) ans = [] for a, c in c.most_common(): if c<2: break ans.append(a) if c>=4: ans.append(a) if len(ans)<2: print(0) else: ans.sort() print(ans[-1]*ans[-2])" p02719,s974528203,Wrong Answer,"n,k = list(map(int,input().split())) if n < k: print(min(n,k - n)) else: if n % k == 0: print(0) else: print(min(abs(n - k * int(n / k)),abs(abs(n - k * int(n / k))-k))) " p03815,s070016895,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)" p03696,s167341173,Accepted,"import math import collections import fractions import itertools import functools import operator def solve(): n = int(input()) s = input() l, r = 0, 0 for i in s: if i == ""("": r += 1 else: if r != 0: r -= 1 else: l += 1 ans = ""(""*l + s + "")""*r print(ans) return 0 if __name__ == ""__main__"": solve() " p03438,s127596942,Accepted,"n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) da = 0 db = 0 for i in range(n): if a[i] <= b[i]: da += (b[i] - a[i]) // 2 else: db += a[i] - b[i] if da >= db: print(""Yes"") else: print(""No"")" p04011,s952535400,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)" p03106,s230343367,Wrong Answer,"A,B,K = map(int,input().split()) ans_list=[0] for i in range(1,A*B+1): if A%i+B%i==0: ans_list.append(i) print(ans_list[K]) " p03639,s648727581,Wrong Answer,"def main(): N = int(input()) A = [int(i) for i in input().split()] mul4 = len([a for a in A if a % 4 == 0]) mul2 = len([a for a in A if a % 4 != 0 and a % 2 == 0]) less = N - 3*mul4 if less <= 0: print(""Yes"") elif less == 1 and 2 <= mul2: print(""Yes"") elif 2 <= less <= mul2: print(""Yes"") else: print(""No"") if __name__ == '__main__': main() " p03817,s370331336,Accepted,"x = int(input()) if x % 11 == 0: print((x//11)*2) elif x % 11 > 6: print((x//11)*2 + 2) else: print((x//11)*2 + 1)" p03126,s842821598,Accepted,"n,m = map(int,input().split()) res = [0]*m for i in range(n): a = list(map(int,input().split())) for k in a[1:]: res[k-1] += 1 a = list(filter(lambda x:x==n,res)) print(len(a))" p02882,s657822465,Accepted,"a, b, x = map(int, input().split()) import math S = a*b s = x/a if s == S: print(0) elif s >= S/2: em_s = S-s tan = (a**2)/(2*em_s) ans = math.degrees(math.atan(tan)) print(90-ans) else: tan = (2*s)/(b**2) ans = math.degrees(math.atan(tan)) print(90-ans)" p03243,s225856750,Accepted,"n = int(input()) z = (-(-n//111))*111 print(z)" p02917,s550464641,Accepted,"N = int(input()) B = list(map(int, input().split())) sum=B[0] for i in range(1,N): if i= k: print(c[k]) else: k_ = k - whe print(c[whe:][k_%lo])" p03779,s711369016,Accepted,"def resolve(): x = int(input()) ans = 0 dist = 0 for i in range(1, x+1): dist += i ans += 1 if dist >= x: break print(ans) if __name__ == '__main__': resolve()" p04011,s209002760,Wrong Answer,"# 数値の取得 N = int(input()) K = int(input()) X = int(input()) Y = int(input()) # 宿泊費の計算後結果を出力 account = (K * X) + ((N - K) * Y) print(account)" p03971,s563533690,Accepted,"n,a,b = map(int,input().split()) s = input() y = 0 bn = 1 for i in range(n): if s[i] == ""a"" and y < a + b: print(""Yes"") y += 1 elif s[i] == ""b"" and y < a + b and bn <= b: print(""Yes"") y += 1 bn += 1 else: print(""No"")" p03086,s934733134,Wrong Answer,"s = input() n = len(s) acgt = [""A"", ""C"", ""G"", ""T""] ans = 0 cnt = 0 for i in range(n): if s[i] in acgt: cnt += 1 #print(ans, cnt, i) else: ans = max(ans, cnt) #print(ans, cnt, i) cnt = 0 print(ans) " p02582,s836988333,Accepted,"s=str(input()) if s=='RRR': print(3) if s=='RRS': print(2) if s=='RSR': print(1) if s=='SRR': print(2) if s=='RSS': print(1) if s=='SRS': print(1) if s=='SSR': print(1) if s=='SSS': print(0) " p03827,s893054059,Accepted,"N=int(input()) S=input() a=[] total=0 for i in range(len(S)): if S[i]==""I"": total+=1 a.append(total) else: total-=1 a.append(total) print(max(max(a),0))" p03943,s720523353,Wrong Answer,"a,b,c = map(int, input().split()) if abs(a-b) == c: print(""Yes"") else: print(""No"")" p03962,s748240752,Accepted,print len(set(raw_input().split())) p02988,s247727438,Accepted,"import math 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())) mod = 10**9 + 7 sys.setrecursionlimit(1000010) n = ni() p = nl() 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) " p02947,s505445786,Wrong Answer,"n=int(input()) s=[list(input()).sort() for _ in range(n)] print(n-len(set(s))+1)" p03407,s559493737,Accepted,"A, B, C = map(int, input().split()) if (A + B >= C): print(""Yes"") else: print(""No"") " p02836,s908008334,Accepted,"S = input() SR = S[::-1] ans = 0 for i in range(len(S)//2): if S[i] != SR[i]: ans +=1 print(ans)" p02717,s972300193,Accepted,"x,y,z=map(int,input().split()) print(z,end=' ') print(x,end=' ') print(y,end='')" p02553,s806843631,Wrong Answer,"import sys from itertools import combinations input = sys.stdin.readline a,b,c,d = map(int,input().split()) h = [] h.append(a) h.append(b) h.append(c) h.append(d) li = list(combinations(h,2)) answer = -10000000001 for i in li: answer = max(answer,i[0]*i[1]) print(answer)" p02713,s143679761,Accepted,"n = int(input()) import math l=0 for i in range(1,n+1): for j in range(1,n+1): p=math.gcd(i,j) for k in range(1,n+1): l+=math.gcd(p,k) print(l) " p03059,s006011206,Accepted,"a, b, t = map(int, input().split()) print(t // a * b)" p02641,s036983006,Accepted,"x,n = map(int,input().split()) p_L = list(map(int,input().split())) p_L = set(p_L) sa = 101 for i in range(0,200): if i not in p_L: if sa > min(sa,abs(i-x)): sa = abs(x-i) ans = i print(ans)" p02778,s314485031,Accepted,"S = list(input()) n = len(S) print(""x""*n)" p03475,s108829739,Wrong Answer,"N= int(input()) li = [list(map(int,input().split())) for _ in range(N-1)] for i in range(N-1): ci,si,fi = li[i] time = si+ci for j in range(i+1,N-1): cj,sj,fj = li[j] time += time%fj if time < sj: time = sj time += cj print(time) print(0)" p04033,s169061502,Wrong Answer,"a,b=map(int,input().split()) if (a<=0 and b>=0) or (b<=0 and a>=0): print(""Zero"") elif a>0 and b>0: print(""Positive"") else: if b-a%2==0: print(""Positive"") else: print(""Negative"")" p03011,s175841809,Accepted,"# A - Airplane import itertools P,Q,R=list(map(int,input().split())) m=99999 for v in itertools.permutations([P,Q,R],2): m=min(m,v[0]+v[1]) print(m) " p03852,s186853947,Accepted,"c=input() if c==""a"" or c=='e' or c==""o"" or c==""i"" or c==""u"": print(""vowel"") else: print(""consonant"")" p02848,s483094048,Accepted,"abc = ""ABCDEFGHIJKLMNOPQRSTUVWXYZ"" N = int(input()) S = input() ans = [] for c in S: print(abc[(abc.index(c) + N) % len(abc)], end = """")" p02627,s141724959,Wrong Answer,"a = input() if a.isupper: print('A') else: print('a')" p03137,s045740522,Accepted,"import math import sys import collections import bisect def main(): n, m = map(int, input().split()) x = sorted(list(map(int, input().split()))) if m <= n: print(0) return y = sorted([x[i + 1] - x[i] for i in range(m - 1)]) print(sum(y[0:(m-n)])) if __name__ == '__main__': main() " p02676,s658793088,Accepted,"K = int(input()) S = input() result = """" if len(S) <= K: result = S else: result = S[0:K] + ""..."" print(result) " p03611,s367530560,Accepted,"import collections n = int(input()) li = list(map(int,input().split())) ans = [] for i in li: ans.append(i-1) ans.append(i) ans.append(i+1) c = collections.Counter(ans) print(c.most_common()[0][1]) " p02838,s643539523,Accepted,"import numpy as np n = int(input()) arr = np.array([int(i) for i in input().split()]) mod = 10 ** 9 + 7 s = 0 for i in range(60): c1 = np.count_nonzero(arr & 1) s += 2 ** i * c1 * (n - c1) arr = arr >> 1 print(s % mod)" p03163,s341034732,Accepted,"N, W = map(int, input().split()) D = [tuple(map(int, input().split())) for _ in range(N)] dp = [[0]*(N+1) for _ in range(W+1)] for w in range(1, W+1): for i in range(1, N+1): # take one if D[i-1][0] <= w: dp[w][i] = max(dp[w][i-1], dp[w-D[i-1][0]][i-1] + D[i-1][1]) # ignore dp[w][i] = max(dp[w][i], dp[w][i-1]) #print(dp) print(max(dp[-1]))" p02583,s757071142,Wrong Answer,"num = int(input()) list = list(map(int,input().split())) sorted(list) count = 0 print(list) for i in range(len(list)): for j in range(len(list)): for k in range(len(list)): if ( list[i] < list[j] < list[k] ) and ( list[i] + list[j] > list[k] ): count += 1 print(count)" p02987,s131072376,Accepted,"s = str(input()) if s[0] == s[1] == s[2] == s[3]: print('No') exit() if (s[0] == s[1] and s[2] == s[3]) or (s[0] == s[3] and s[2] == s[1]) or (s[0] == s[2] and s[1] == s[3]): print('Yes') else: print('No')" p03282,s453647144,Accepted,"s = list(map(int, list(input()))) k = int(input()) ans = 1 if len(s) <= k: for i in s: if i != 1: ans = i break else: for i in range(0,k): if s[i] != 1: ans = s[i] break print(ans) " p02615,s690869338,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 import heapq N = ri() A = rl() A.sort() heap = [] a = A.pop() heapq.heappush(heap, (-a, a, a)) ans = 0 while A: a = A.pop() b, l, r = heapq.heappop(heap) b = -b ans += b heapq.heappush(heap, (-min(a, l), l, a)) heapq.heappush(heap, (-min(a, r), a, r)) print(ans) " p03469,s718320273,Accepted,"str = input().split() s = str[0] print(""2018"" + s[4:len(s)])" p03011,s055602701,Wrong Answer,"p,q,r=map(int,input().split()) x=p+q y=q+r z=r+p if(x<=y): if(x<=z): print(x) elif(y<=z): if(y<=x): print(y) elif(z<=x): if(z<=y): print(z)" p02838,s655912717,Accepted,"N=int(input()) M=10**9+7 A=[int(x) for x in input().split()] ans=0 for i in range(60): one=sum([a>>i&1 for a in A]) zero=N-one ans+=(one*zero)*pow(2,i,M)%M ans%=M #print(one,zero) print(ans)" p03137,s888197724,Accepted,"n, m = map(int, input().split()) X = sorted(map(int, input().split())) d = [0] * (m-1) for i in range(m-1): d[i] = abs(X[i] - X[i+1]) d.sort(reverse=True) print(sum(d[n-1:])) " p02970,s444841932,Wrong Answer,"n,d = map(int,input().split()) print((n-d)//(d+1))" p02982,s821937547,Wrong Answer,"l,r = map(int,input().split()) x = l%2019 if (l//673 < r//673 or l%673==0) and (l//3 < r//3 or l%3==0): ans = 0 else: ans = l*(l+1)%2019 print(ans)" p02582,s205153073,Wrong Answer,"a,b,c = map(str,input().rstrip("""")) if(a==""R"" and b == ""R"" and c == ""R""): count = 3 elif(a==""R"" and b == ""R"" and c == ""S""): count = 2 elif(a==""R"" and b == ""S"" and c == ""S""): count = 1 elif(a==""S"" and b == ""R"" and c == ""R""): count = 2 elif(a==""S"" and b == ""R"" and c == ""S""): count = 1 elif(a==""S"" and b == ""S"" and c == ""R""): count = 1 else: count = 0 print(count) " p03042,s169131366,Accepted,"n=input() n1,n2=int(n[:2]),int(n[2:]) if (n1>12 and n2>12) or (n1==0 and n2==0): print(""NA"") elif (n1!=0 and n1<=12) and (n2!=0 and n2<=12): print(""AMBIGUOUS"") elif n1!=0 and n1<=12: print(""MMYY"") elif n2!=0 and n2<=12: print(""YYMM"") else: print(""NA"") " p03486,s528743939,Accepted,"s=sorted(input()) t=sorted(input(), reverse=True) if s y: SP = ((x - min_c) * a) + (2 * c * min_c) else: SP = ((y - min_c) * b) + (2 * c * min_c) print(min(AB,SP)) " p03407,s496279421,Accepted,"a,b,c=map(int,input().split()) print(""Yes"" if (a+b)>=c else ""No"")" p02785,s303021853,Accepted,"n,k = [int(x) for x in input().split()] arr = [int(x) for x in input().split()] print(sum(sorted(arr)[::-1][k:]))" p03854,s209883415,Wrong Answer,"c = input().rstrip('\n') str1 = ""dreamer"" str2 = ""dream"" str3 = ""eraser"" str4 = ""erase"" tmpstr = """" endflag = False while(c != """"): tmpstr = c c = c.replace(str1, """") c = c.replace(str2, """") c = c.replace(str3, """") c = c.replace(str4, """") print(""tmpstr:"" + tmpstr) print(""c:"" + c) if (c == tmpstr): endflag = True break if (c == """"): print(""YES"") else: print(""NO"")" p02988,s716948154,Accepted,"n = int(input()) p = list(map(int, input().split())) cnt = 0 for i in range(n-2): test = sorted(p[i:i+3]) if test[1] == p[i+1]: cnt += 1 print(cnt) " p03796,s702867848,Wrong Answer," import numpy as np import math MOD=10**9+7 n=int(input()) ans=1 for i in range(n+1): ans=(ans*i)%MOD print(ans)" p03001,s912378789,Accepted,"W,H,x,y=map(int,input().split()) a1=W*H/2 a2=1 if x==W/2 and y==H/2 else 0 print(a1,a2) " p02684,s205709238,Accepted,"import sys from collections import defaultdict n, k = map(int, input().split()) a = [int(i) for i in input().split()] towns = [1] town_dic = defaultdict(lambda : 0) prev = 1 count = 0 while True: next = a[prev - 1] count += 1 if count == k: print(next) sys.exit() if town_dic[next] == 1: break else: town_dic[next] += 1 towns.append(next) prev = next i = towns.index(next) repeat = towns[i:] unit = len(repeat) rest = k - count + 1 print(repeat[(rest % unit) - 1])" p03434,s429319236,Accepted,"N = int(input()) a = [int(x) for x in input().split()] a.sort() x = sum(a[0::2]) y = sum(a[1::2]) print(abs(x - y))" p02554,s756221349,Accepted,"n = int(input()) if n == 1: print(0) exit(0) mod = 10 ** 9 + 7 ans = pow(10, n, mod) - 2 * pow(9, n, mod) + pow(8, n, mod) ans %= mod print(ans) " p03721,s773606834,Accepted,"N, K = map(int, input().split()) ab = [list(map(int, input().split())) for _ in range(N)] ab.sort() now = 0 count = 0 for i in range(N): now = ab[i][0] count += ab[i][1] if count >= K: print(now) break " p02835,s077313678,Accepted,"if 22 > sum(map(int, input().split())): print('win') else: print('bust')" p02624,s679599160,Wrong Answer,"n=int(input()) ans=0 for i in range(1,n+1): num=n//i ans+=num*i print(ans)" p02982,s322958850,Accepted,"import itertools import math n, d = map(int,input().split()) vecList = [] for i in range(n): vecList.append(list(map(int,input().split()))) cVec = list(itertools.combinations(vecList,2)) count = 0 for i in cVec: sqT = 0 for j in range(d): sqT += (i[0][j]-i[1][j])**2 sqT = math.sqrt(sqT) if sqT.is_integer(): count += 1 print(count) " p03804,s209409288,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() w_dif = len(A[0])-len(B[0]) w_w = len(B[0]) ans = 'No' for h in range(n-m+1): for w in range(w_dif+1): window = [wh[w:w+w_w] for wh in A[h:h+m]] if window==B: ans = 'Yes' break print(ans)" p03417,s497336870,Accepted,"N, M = [int(x) for x in input().split()] print(abs((N - 2) * (M - 2)))" p03252,s050089940,Accepted,"s = input() t = input() scnt = {} tcnt = {} sres = [] tres = [] for x in s: if x not in scnt:scnt[x] = 1 else:scnt[x] +=1 for x in t: if x not in tcnt:tcnt[x] = 1 else:tcnt[x] +=1 for k in scnt: sres.append(scnt[k]) for k in tcnt: tres.append(tcnt[k]) sres.sort() tres.sort() n = max(len(sres),len(tres)) ok = True for i in range(n): if sres[i] != tres[i]: ok = False break if ok:print('Yes') else:print('No')" p02663,s132330029,Accepted,"H1, M1, H2, M2, K = map(int, input().split()) #print(H1, M1, H2, M2, K) mm1 = H1*60+M1 mm2 = H2*60+M2 if mm2 > mm1: mmm = mm2-mm1 else: mmm = mm2+24*60 - mm1 if mmm > K: print(mmm-K) else: print(0) " p03062,s881102001,Wrong Answer,"n=int(input()) a=list(map(int,input().split())) sum=0 min=10**9 for i in a: if i>=0: sum=sum+i if min>i: min=i else: sum=sum-i if min>-i: min=-i print(sum if len(a)%2==0 else sum-min)" p03665,s989796660,Accepted,"n,p=map(int,input().split()) a=list(map(int, input().split())) a_new=[] for i in range(n): a_new.append(a[i]%2) even=a_new.count(0) odd=a_new.count(1) if odd==0 and p==0: print(2**n) elif odd==0 and p==1: print(0) else: print(2**(n-1)) " p03012,s635101965,Accepted,"n = int(input()) w = list(map(int,input().split())) ans = sum(w) for i in range(1,n): ans = min(ans, abs(sum(w[:i])-sum(w[i:]))) print(ans) " p03962,s669261226,Wrong Answer,"a, b, c = map(int, input().split()) if a == b and a == c: print('3') elif a==b or a == c or b== c: print('2') else: print('1') " p02700,s501026436,Accepted,"A,B,C,D=map(int,input().split()) turn=True while A>0 and C>0: if turn==True: C=C-B turn=False else: A=A-D turn=True if A<=0: print(""No"") else: print(""Yes"")" p03103,s298050746,Accepted,"n, m = map(int, input().split()) P = sorted([tuple(map(int, input().split())) for i in range(n)]) ans = 0 for x, y in P: q = min(m, y) ans += x*q m -= q if m == 0: print(ans) exit()" p03698,s947137043,Accepted,"import collections Sls = list(input()) counter = collections.Counter(Sls) ans = 'yes' for i in counter.values(): if i > 1: ans = 'no' break print(ans)" p03556,s497807433,Accepted,"n=int(input()) num=1 while(num**2= n: print(ans) else: for i in range(n - k): ans += int(h[i]) print(ans)" p02996,s822319122,Accepted,"import sys n=int(input()) ab=[] for i in range(n): AB=[int(x) for x in input().rstrip().split()] ab.append(AB) ab=sorted(ab,key=lambda x :x[0]) ab=sorted(ab,key=lambda x :x[1]) time=0 for a,b in ab: if time+a<=b: time+=a else: print(""No"") sys.exit() print(""Yes"")" p02760,s114327697,Accepted,"import sys def ILI(): return list(map(int, sys.stdin.readline().rstrip().split())) A = [] B = [[0,0,0],[0,0,0],[0,0,0]] ans = ""No"" for i in range(3):A.append(ILI()) n = int(input()) for k in range(n): b = int(input()) for i in range(3): for j in range(3): if A[i][j] == b:B[i][j]=1 B2 = list(zip(*B)) for i in range(3): if sum(B[i])==3 or sum(B2[i])==3: ans = ""Yes"" if B[0][0]+B[1][1]+B[2][2]==3:ans=""Yes"" if B[0][2]+B[1][1]+B[2][0]==3:ans=""Yes"" print(ans) " p03944,s695721024,Wrong Answer,"W,H,N=map(int,input().split()) x=[0]*N y=[0]*N a=[0]*N minX=0 maxX=W minY=0 maxY=H for i in range(N): x[i],y[i],a[i]=map(int,input().split()) if a[i]==1: minX=max(minX,x[i]) if a[i]==2: maxX=min(maxX,x[i]) if a[i]==3: minY=max(minY,y[i]) if a[i]==4: maxY=min(maxY,y[i]) print(max(0,(maxX-minX)*(maxY-minY)))" p03419,s027490590,Accepted,"N, M = map(int, input().split()) if N == 1 and M == 1: print('1') elif N == 1: print(max(0, M-2)) elif M == 1: print(max(N-2, 0)) else: print(max(0, N-2)*max(0, M-2)) " p02596,s473345689,Accepted,"k =int(input()) if k % 2 == 0 or k % 5 == 0: print(-1) else: if k % 7 == 0: k //= 7 if k == 1: print(1) else: k *= 9 i = 1 num = 10 while num % k != 1: num %= k num *= 10 i += 1 print(i)" p03438,s160867659,Accepted,"#APC001_B n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) plus, minus = 0, 0 for i in range(n): if a[i] < b[i]: plus += (b[i] - a[i]) // 2 if a[i] > b[i]: minus += (a[i] - b[i]) print('Yes' if minus <= plus else 'No')" p03944,s798993382,Accepted,"w,h,n = map(int,input().split()) w0 = 0 h0 = 0 for _ in range(n): x,y,a = map(int,input().split()) if a == 1: w0 = max(w0,x) if a == 2: w = min(w,x) if a == 3: h0 = max(h0,y) if a == 4: h = min(h,y) print(max(0,w-w0)*max(0,h-h0)) " p02731,s996212663,Accepted,"l = int(input()) print((l/3)**3)" p03835,s198190447,Wrong Answer,"x,y = list(map(int, input().split())) count=0 for i in range(x+1): for j in range(x+1): k=y-i-j if k0: count+=1 print(count)" p03557,s730252470,Accepted,"import bisect n = int(input()) a,b,c = [list(sorted(map(int, input().split()))) for _ in range(3)] ans = 0 for i in b: x = bisect.bisect_left(a, i) y = len(c) - bisect.bisect_right(c, i) ans += x*y print(ans)" p03761,s411765193,Wrong Answer,"# Hello World program in Python from collections import Counter as cn d=int(input()) l = [] for k in range(d): p = cn(input()) l.append(p) oi = l[0] for g in range(len(l)): oi = oi & l[g] print(oi) print("""".join(sorted(oi.elements()))) " p03472,s978064867,Accepted,"import sys N, H = map(int, input().split()) AB = [list(map(int, input().split())) for _ in range(N)] if N == 1: cnt = 1 H -= AB[0][1] if H > 0: cnt += -(-H//AB[0][0]) print(cnt) sys.exit() AB.sort(reverse = True) max_A = AB[0][0] AB.sort(reverse = True, key = lambda x: x[1]) cnt = 0 for i in range(N): katana_B = AB[i][1] if katana_B < max_A: break else: H -= katana_B cnt += 1 if H <= 0: break if H > 0: cnt += -(-H//max_A) print(cnt) " p02570,s020002130,Accepted,"D,T,S=map(int,input().split()) if S*T >= D: print(""Yes"") else: print(""No"")" p03852,s564433346,Accepted," c = str(input()) vowels = ['a','e','i','o','u'] if c in vowels: answer = ""vowel"" else: answer = ""consonant"" print(answer) " p03067,s221119228,Accepted,"a,b,c = map(int,input().split()) print(""Yes"" if min(a,b) < c < max(a,b) else ""No"")" p03693,s374832441,Accepted,"r, g, b = map(str,input().split()) n = int(r+g+b) if n % 4 == 0: print('YES') else: print('NO')" p02786,s998622183,Accepted,"import math h = int(input()) print(2**(int(math.log2(h)+1))-1)" p02996,s637680342,Wrong Answer,"n = int(input()) time=0 alist=[] ans='Yes' for i in range(n): a,b=map(int, input().split()) alist.append([a,b-a]) if b>time: time=b if b>a: ans='No' alist.sort(key=lambda x: x[1]) for i in range(n-1,-1,-1): if time1: print(""No"") else: print(""Yes"")" p03323,s264888461,Accepted,"a, b = list(map(int, input().split())) if a > 8 or b > 8: print(':(') else: print('Yay!')" p03486,s884035391,Accepted,"s=sorted(input()) r=sorted(input(),reverse=True) if(s=A[N-1]: print(""No"") else: print(""Yes"")" p02819,s660369735,Accepted,"x = int(input()) while True: flag = True for i in range(2, int(x ** 0.5) + 1): if x % i == 0: flag = False break if flag: print(x) break x += 1 " p02600,s545740979,Wrong Answer,"value = int(input()) kyu_rated = 8 flag = 0 lvalue = 400 rvalue = 599 if 400 <= value <= 1999: for i in range(0, 7): if lvalue <= int(value) <= rvalue: print(kyu_rated) flag = 1 break else: lvalue += 200 rvalue += 200 kyu_rated -= 1 " p02775,s656827976,Wrong Answer,"from sys import setrecursionlimit n = ""0""+input() N = len(n) point = 0 for i in range(1,N): if int(n[i]) >= 6: point += 10-int(n[i]) else: point += int(n[i]) print(point)" p02888,s033955538,Accepted,"def main(): from bisect import bisect_right N = int(input()) *e, = map(int, input().split()) e.sort() ans = 0 for j in range(2, N): for i in range(1, j): d = e[j] - e[i] ans += max(0, i - bisect_right(e, d)) print(ans) if __name__ == '__main__': main() # import sys # input = sys.stdin.readline # # sys.setrecursionlimit(10 ** 7) # # (int(x)-1 for x in input().split()) # rstrip() " p03785,s034261113,Accepted,"n, c, k = map(int, input().split()) T = [int(input()) for _ in range(n)] T.sort() cnt = 0 ans = 1 t = T[0] for i in range(n): cnt += 1 if cnt > c or T[i] > t + k: ans += 1 cnt = 1 t = T[i] print(ans)" p02909,s017759507,Wrong Answer,"today_weather = input() if today_weather == 'Sunny': tomorrow_weather = 'Cloudy' elif today_weather == 'Cloudy': tomorrow_weather = 'Rainy' elif today_weather == 'Rainy': tomorrow_weather = 'Sunny' print('tomorrow_weather') " p03107,s936845336,Wrong Answer,"from collections import Counter print(2*min(Counter(list(input())).values()))" p02713,s339176742,Accepted," k=int(input()) from math import gcd s6=0 for i in range(2,k-1): for j in range(i+1,k): for jj in range(j+1,k+1): s6+=gcd(gcd(i,j),jj) s3=0 for i in range(2,k): for j in range(i+1,k+1): s3+=gcd(i,j) s1=int((k+1)*k/2) print(s1+s3*6+s6*6+(k-1)*6+(k-2)*(k-1)*3)" p02963,s459887932,Accepted,"S = int(input()) p = 10 ** 9 if S > p: r = S % p r = 0 if r == 0 else p - r print(p, 1, r, (S + r) // p, 0, 0) else: print(1, 0, 0, S, 0, 0) print()" p03030,s164127022,Accepted,"N = int(input()) L1 = [] for i in range(N): L1.append(list(input().split())) L2 = L1 ans=[] for i in L1: seq = 1 for j in L2: if i[0] > j[0]: seq += 1 elif i[0] == j[0]: if int(i[1]) < int(j[1]): seq += 1 ans.append(seq) for i in range(N): print(ans.index(i+1)+1) " p03105,s005353396,Wrong Answer,"a,b,c = map(int,input().split()) if a//b >= c: print(c) else: print(a//b)" p02699,s591188500,Accepted,"# S,Wの入力 S,W = map(int,input().split()) # S,Wの比較 if S > W: print(""safe"") else: print(""unsafe"")" p03360,s076050274,Accepted,"a,b,c = map(int, input().split()) k = int(input()) ans = a+b+c + (max(a,b,c))*(2**k-1) print(ans)" p02779,s605772400,Accepted,"n=int(input()) a=list(map(int,input().split())) b=list(set(a)) if len(a)==len(b): print(""YES"") else: print(""NO"")" p02600,s278254794,Accepted,"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"") elif n <=1999: print(""1"")" p02597,s970630442,Accepted,"N=int(input()) c=input() C=[a for a in c] number=0 answer=0 red=C.count('R') if red==0 or red==N: print(0) else: words=C[red:] print(words.count('R')) " p03106,s590644060,Accepted,"A, B, K = map(int, input().split()) L = [i for i in range(1, A+1) if A%i==0 and B%i==0] print(L[-K]) " p03796,s542694220,Accepted,"a = int(input()) import math b = math.factorial(a)%(10**9+7) print(b)" p02753,s979043032,Accepted,"# A S=input() if S==""AAA"" or S==""BBB"": print(""No"") else: print(""Yes"")" p03041,s735350112,Accepted,"N,K = map(int,input().split()) S = str(input()) T = list(map(str,S)) for i in range(N): if i == K-1: T[i] = str.lower(T[i]) print("""".join(T))" p02797,s004063094,Accepted,"N,K,S=map(int,input().split()) ans=[] for _ in range(K): ans.append(S) for _ in range(N-K): ans.append(S+1 if S!=10**9 else 1) for i in range(N): print(ans[i])" p02682,s624088385,Accepted,"a,b,c,k = map(int,input().split()) if a >= k: print(k) else: if a+b >= k: print(a) if a+b < k: d = k-a-b print(a-d)" p02571,s091842597,Accepted,"S = input() T = input() ans = 0 for i in range(len(S) - len(T) + 1): count = 0 for j in range(len(T)): if S[i+j] == T[j]: count += 1 ans = max(ans, count) print(len(T) - ans)" p02570,s289640574,Accepted,"d,t,s=map(int,input().split()) if d<=t*s:print('Yes') else:print('No')" p03861,s366220906,Accepted,"a,b,x=map(int,input().split()) print(b//x-(a-1)//x)" p02866,s383644453,Wrong Answer,"N = int(input()) D = list(map(int, input().split())) DL = [0] * N mod = 998244353 if D[0] != 0: print(0) exit() for d in D: DL[d] += 1 if DL[0] != 1: print(0) exit() ans = 1 for i in range(1, N): if DL[i] == 0: if sum(DL[i:]) != 0: print(0) exit() else: print(ans%mod) exit() ans *= pow(DL[i-1], DL[i], mod) ans %= mod " p02725,s619867872,Accepted,"k, n = list(map(int, input().split())) a = list(int(i) for i in input().split()) s = [] for i in range(n-1): s.append(a[i+1] - a[i]) s.append(k - a[n-1] +a[0]) print(k - max(s)) " p02771,s743077686,Wrong Answer,"A = list(map(int , input().split())) if A[0] == A[1] and A[0] != A[2]: print('Yes') elif A[0] == A[2] and A[0] != A[1]: print('Yes') else: print('No')" p03997,s891957163,Accepted,"# -*- coding: utf-8 -*- a = int(input()) b = int(input()) h = int(input()) print((a + b) * h // 2) " p02909,s896786007,Accepted,"S = input() if S == ""Sunny"": print(""Cloudy"") elif S == ""Cloudy"": print(""Rainy"") else: print(""Sunny"") " p02699,s482682167,Accepted,"line = input().split() s = int(line[0]) w = int(line[1]) if w >= s: print(""unsafe"") else : print(""safe"")" p02983,s558594675,Accepted,"L, R = map(int, input().split()) ans = 2018 for i in range(L, L+2019): for j in range(R-2019, R+1): if not i y: if x < 0 and y < 0: print(abs(abs(y)-abs(x))+2) if x >= 0 and y < 0: print(abs(abs(y)-abs(x))+1) if x >= 0 and y >= 0: print(abs(abs(y)-abs(x))+2) elif x < y: if x < 0 and y < 0: print(abs(abs(y)-abs(x))) if x < 0 and y >= 0: print(abs(abs(y)-abs(x))+1) if x >= 0 and y >= 0: print(abs(abs(y)-abs(x)))" p03345,s615998694,Accepted,"A, B, C, K = map(int, input().split()) if K % 2 == 0: r = A - B else: r = B - A print(r if r <= 10**18 else ""Unfair"") " p02918,s460950226,Accepted,"n,k=map(int,input().split()) r=input() c=0 for i in range(1,n): if r[i-1]==r[i]: c+=1 print(min(n-1,c+2*k)) " p02583,s633482661,Accepted,"num = int(input()) list = list(map(int,input().split())) sorted(list) count = 0 for i in range(len(list)): for j in range(len(list)): for k in range(len(list)): if ( list[i] < list[j] < list[k] ) and ( list[i] + list[j] > list[k] ): count += 1 print(count)" p02712,s826507971,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)" p03264,s990215276,Accepted,"k = int(input()) if k % 2 == 0: print(int((k // 2) ** 2)) else: print((k // 2) * (k // 2 + 1))" p02546,s627313092,Accepted,"n = list(input()) if n[-1] == ""s"": n.append(""e"") n.append(""s"") else: n.append(""s"") print("""".join(n)) " p03012,s228756705,Wrong Answer,"n = int(input()) w = list(map(int, input().split())) a = [0]*n for i in range(n): a[0] += w[i] for i in range(n): if a[i] > 0: a[i] -= 2*w[i] else: j = i break if a[j-1] < -a[j]: print(a[j-i]) else: print(-a[j]) " p03814,s497296424,Accepted,"s=input() pos=-1 ans=0 for i,c in enumerate(s): if c=='Z' and pos!=-1: ans=max(ans,i-pos+1) if c=='A' and pos==-1: pos=i print(ans) " p03773,s135304340,Wrong Answer,"A,B=map(int,input().split()) print((A+B)//24)" p02933,s037103377,Accepted,"a = int(input()) s = input() if a >= 3200: print(s) if a < 3200: print(""red"") " p02705,s949135896,Accepted,"import math n=int(input()) res=2*math.pi*n print(res) " p03061,s712231905,Accepted,"# solution import io from fractions import gcd data=int(input()) array=list(map(int,input().split())) k=[0] l=[0] for i in range(data-1): k.append(gcd(k[i],array[i])) l.append(gcd(l[i],array[data-i-1])) ans=0 for i in range(data): ans=max(ans,gcd(k[i],l[data-i-1])) print(ans) " p03994,s442145111,Accepted,"S = input() K = int(input()) def ctoi(c): return ord(c) - ord('a') def toa(c): i = ctoi(c) return (26-i)%26 ans = '' for c in S: if len(ans)+1 == len(S): ans += chr((ctoi(c) + K)%26 + ord('a')) else: to = toa(c) if to <= K: ans += 'a' K -= to else: ans += c print(ans)" p02697,s366940047,Accepted,"import sys sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) def resolve(): N, M = lr() if N%2 == 1: for i in range(0, M): print(f'{2+i} {1+2*M-i}') else: k = N//4 for i in range(M): if i < k: print(f'{i+1} {N-i}') else: print(f'{i+2} {N-i}') resolve()" p03427,s881107136,Wrong Answer,"N = input() a = len(N) - 1 b = int(N[0]) ans = (b-1) + 9 * a if int(str(b) + ""9""*a) < int(N): print(ans) else: ans = b + 9 * a print(ans) " p02659,s265635144,Accepted,"A, B = input().split() A = int(A) C = int(B[0])*100 + int(B[2:]) print((A*C)//100)" p03127,s166649349,Wrong Answer,"import math from functools import reduce print(reduce(math.gcd,map(int,input().split())))" p03434,s744613924,Accepted,"N = int(input()) a = map(int, input().split()) a = sorted(a, reverse=True) print(sum(a[::2]) - sum(a[1::2]))" p02791,s310253502,Wrong Answer,"N = input() N = [int(s) for s in N] input_line = input() Line = input_line.split() Line = [int(s) for s in Line] count = 0 for x in range(N[0]): # print(""x"",x) flag = 1 for i in range(x+1): # print(""i"",i) if Line[x] > Line[i] : # print(Line[x],Line[i]) flag = 0 # print(""ss"") if flag == 1 : # print(""OK"") count += 1 print(count)" p02959,s032663258,Accepted,"n = int(input()) a = list(map(int,input().split())) b = list(map(int,input().split())) cnt = 0 res = 0 #余力 for i in range(n): ch = min(a[i],res) cnt += ch a[i] -= ch if b[i] > a[i]: cnt += a[i] res = b[i] - a[i] else: cnt += b[i] res = 0 cnt += min(a[n],res) print(cnt)" p03673,s943153290,Accepted,"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 kotae="" "".join(map(str,kotae)) print(kotae)" p03838,s759862208,Accepted,"x,y = [int(x) for x in input().split()] if y == 0: print(abs(x) + (x>0)) elif x < y < 0: print(y-x) elif 0 < y < x: print(x-y+2) else: print(abs(abs(y) - abs(x)) + (x < 0) + (y < 0))" p03107,s364925821,Wrong Answer,"S=input() X=len(S) A=S for i in range(10**3+1): A=A.replace(""10"","""").replace(""01"","""") if X==1: print(0) else: print(X-len(A)) " p02786,s670386271,Accepted,"h = int(input()) count = 0 ans = 1 while h >1: h //= 2 count += 1 ans += 2**count print(ans)" p03860,s762002798,Accepted,"def resolve(): A, s, C = input().split() print(A[0]+s[0]+C[0]) resolve()" p03069,s961557376,Wrong Answer,"n = int(input()) s = list(input()) ans = 0 for i in range(n-1, 0, -1): if s[i] == '.' and s[i-1] == '#': ans += 1 s[i] = '#' print(ans) " p03162,s652331130,Accepted,"def main(): N = int(input()) abc = [list(map(int,input().split())) for _ in range(N)] abc.insert(0,[0,0,0]) dp = [[0]*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: dp[i][j] = max(dp[i][j],dp[i-1][k]+abc[i][j]) print(max(dp[N])) if __name__ == '__main__': main()" p02606,s884215499,Accepted,"#!/usr/bin/env python3 l, r, d = map(int, input().split()) print(r // d - (l - 1) // d) " p02675,s481093014,Wrong Answer,"num = int(input()) ext = num%10 if ext == 2 or ext == 4 or ext == 5 or ext == 7 or ext == 9: print(""hon"") if ext == 3: print(""bon"") else: print(""pon"")" p03035,s054312216,Wrong Answer,"A,B = map(int, input().split()) if A>=13: print(B) elif A>=6: print(B/2) else: print(0)" p02953,s421149430,Accepted,"n=int(input()) h=list(map(int,input().split())) maximum=h[0] ans=""Yes"" for i in range(1,n): maximum = max(maximum,h[i]) if h[i]+10 and c>0): c-=b if(c<=0): print(""Yes"") break a-=d if(a<=0): print(""No"") break " p02881,s590990768,Wrong Answer,"n=int(input()) ans=[] if n==1: print(1) else: for i in range(1,10**6): if i>=n: break elif n%i==0: ans.append(i+(n//i)) print(min(ans)-2)" p03785,s393931625,Accepted,"N,C,K=map(int,input().split()) T=sorted([int(input()) for i in range(N)]) lt=T[0]+K m=0 b=0 for t in T: if lt>=t and m=1: b+=1 print(b) " p02665,s262691548,Accepted,"import math n = int(input()) folia = list(map(int, input().split())) #print(n, folia) seq = [[folia[-1], folia[-1]]] for i in range(n): # 深さ'n'分 tmp = folia[-(i+2)] sml = math.ceil(seq[i][0] / 2) + tmp big = seq[i][1] + tmp seq += [[sml, big]] #print(seq) if not (seq[-1][0] <= 1 <= seq[-1][1]): print(-1) exit() ans =[1] for j in range(n): # 深さ'n'分 tmp = min((ans[j] - folia[j]) * 2, seq[-(j+2)][1]) ans.append(tmp) print(sum(ans)) " p02597,s498835242,Wrong Answer,"N = int(input()) S = input() wl = 0 for i in range(N): if S[i] == ""W"": wl += 1 rl = N - wl l = 0 if N % 2 == 0: for i in range(N//2): if S[i] == ""W"": l += 1 else: for i in range(N//2): if S[i] == ""W"": l += 1 print(min([wl, rl, l]))" p02842,s188055810,Accepted,"import math N = int(input()) flag = True for i in range(1,50001): if N == math.floor(i*1.08): print(i) flag = False break if flag: print(':(') " p02918,s791914598,Wrong Answer,"n, k = map(int, input().split()) s = [] prev = ""-"" cnt = 0 for i in input(): if prev!=i: s.append(cnt) cnt = 0 else: cnt += 1 prev = i s.append(cnt) ans = sum(s) if len(s)-1==k+1: ans -= 1 elif len(s)-1<=k: ans -= 2 print(ans + 2*min(k, len(s)))" p03274,s101746099,Accepted,"n,k=map(int,input().split()) x=list(map(int,input().split())) ans=10**9 for i in range(n-k+1): st=x[i] ed=x[i+k-1] if ed<=0: ans=min(ans,abs(st)) elif st>=0 and ed>=0: ans=min(ans,ed) else: t=(min(abs(st),ed)*2)+max(abs(st),ed) ans=min(t,ans) print(ans) " p03282,s917805436,Accepted,"S = input() K = int(input()) for i in range(len(S)): if S[i] != ""1"": print(S[i]) break else: if i == K - 1: print(""1"") break " p03328,s756640174,Wrong Answer,"a, b = map(int, input().split()) temp = 0 bar_heights = [] for i in range(1, 1000): temp += i bar_heights.append(temp) for i in range(1, 499501): if (a + i) in bar_heights and (b + i) in bar_heights: print(i) break " p02783,s625813851,Accepted,"H,A=map(int,input().split()) a=0 while H>0: H=H-A a+=1 print(a)" p02552,s725676696,Accepted,"x = int(input()) if x==0: print(1) else: print(0)" p03077,s327128747,Accepted,"import math number_of_people = int(input()) minutes = [int(input()) for i in range(5)] minimum_throughput = min(minutes) total_elapsed_minute = 4 + math.ceil(number_of_people / minimum_throughput) print(total_elapsed_minute) " p02747,s241606265,Accepted,"s = input() print(""Yes"" if len(s.replace(""hi"","""")) == 0 else ""No"")" p02658,s408752951,Accepted,"# coding: utf-8 # Your code here! n = int(input()) num_list = list(map(int, input().split())) sum=1 if 0 in num_list: print(0) exit() for i in num_list: if i==0: print(0) exit() i=str(i) sum=str(sum) if len(i)+len(sum)>21: print(-1) exit() i=int(i) sum=int(sum) sum=sum*i if sum>10**18: print(-1) exit() print(sum)" p02777,s490594816,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)" p02657,s464197098,Accepted,"a, b = map(int,input().split()) print(a*b)" p03852,s639632390,Accepted,"word = input() if word == 'a': print('vowel') elif word == 'i': print('vowel') elif word == 'u': print('vowel') elif word == 'e': print('vowel') elif word == 'o': print('vowel') else: print('consonant')" p02838,s121549939,Wrong Answer,"import numpy as np N=int(input()) A=np.array([int(x) for x in input().split()]) ans=0 M=pow(10,9)+7 for i in range(100): one=np.sum((A>>i)&1) zero=N-one ans+=(one*zero)*pow(2,i) #ans%=M #print(one,zero) print(ans%M)" p03037,s795186741,Accepted,"n,m=map(int,input().split()) s=[] S=[] for i in range(m): l,r=map(int,input().split()) s.append(l) S.append(r) if max(s)<=min(S): print(min(S)-max(s)+1) else: print('0') " p02690,s927397872,Accepted,"x = int(input()) for i in range(400): for j in range(400): ii = i - 200 jj = j - 200 if ii**5 - jj**5 == x: print(ii,jj) exit() assert false, ""final""" p03103,s500144687,Accepted,"n,m=list(map(int,input().split())) p=[] for i in range(n): a=list(map(int,input().split())) p.append(a) p.sort(key=lambda x:x[0]) num=0 ans=0 i=0 while num str: A = ( a + b - c) ** 2 B = 4 * a * b return ""Yes"" if( A - B > 0 and (c - a - b) > 0) else ""No"" def modelAnswer(): return def main(): a,b,c = map(int,input().split()) print(myAnswer(a,b,c)) if __name__ == '__main__': main()" p02596,s063681695,Accepted,"k = int(input()) if k%2==0 or k%5==0: print(-1) else: ans = 1 res = 7 while True: if res%k == 0: print(ans) break res = res*10+7 res %= k ans += 1" p03042,s206218232,Accepted,"s = input() s_1 = int(s[0:2]) s_2 = int(s[2:4]) if (s_1>12 or s_1<1) and (s_2>12 or s_2<1): print('NA') elif s_1<=12 and s_1>=1 and s_2<=12 and s_2>=1: print('AMBIGUOUS') elif s_1<=12 and s_1>=1: print('MMYY') else: print('YYMM')" p03861,s759449688,Accepted,"a,b,x = list(map(int, input().split())) print(b//x - (a-1)//x)" p03243,s592321218,Wrong Answer,"s = list(set(input())) print(s[-1]*3)" p03136,s396295470,Accepted,"import sys input = sys.stdin.readline def main(): N = int(input()) L = list(map(int, input().split())) max_L = max(L) sum_L = sum(L) if max_L < sum_L - max_L: ans = ""Yes"" else: ans = ""No"" print(ans) if __name__ == ""__main__"": main() " p03000,s050705839,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)" p03611,s347208575,Wrong Answer,"N = int(input()) A = list(map(int,input().split())) c = (10 ** 5 + 1) * [0] for i in range(N): c[A[i]] += 1 if A[i] > 0: c[A[i] - 1] += 1 if A[i] < 10 ** 5: c[A[i] - 1] += 1 print(max(c))" p03861,s357550391,Accepted,"a,b,x=map(int,input().split()) a-=1 c=(a-a%x)//x d=(b-b%x)//x print(d-c)" p02972,s863605806,Accepted,"n = int(input()) a = list(map(int, input().split())) ans = [0] * n m = 0 res = [] # 1 idx for i in range(n, 0, -1): # i の倍数でbit立っているものの個数を数える cnt = 0 idx = 2 while i * idx <= n: if ans[i * idx - 1]: cnt += 1 idx += 1 debug = cnt if cnt % 2 != a[i - 1]: ans[i - 1] = 1 m += 1 res.append(i) print(m) if m: print(*res) " p03329,s974040189,Accepted,"N=int(input()) xlist=[1] for d in range(1,10**9): if 6**d>100000: break xlist.append(6**d) for d in range(1,10**9): if 9**d>100000: break xlist.append(9**d) xlist.sort() #print(xlist) dp=[0]*(N+1) for i in range(1,N+1): min_dp=10**9 for x in xlist: if i-x<0: break min_dp=min(min_dp,dp[i-x]) dp[i]=min_dp+1 #print(dp) print(dp[-1])" p02683,s859241909,Accepted,"N, M, X = map(int, input().split()) books = [list(map(int, input().split())) for _ in range(N)] p = [] for i in range(1, 2**N): buff = [0] * (M + 1) for j in range(N): if i >> j & 1: buff = [a + b for a, b in zip(buff, books[j])] for a in buff[1:]: if a < X: break else: p.append(buff[0]) if len(p) > 0: ans = min(p) else: ans = -1 print(ans) " p03274,s624152891,Accepted,"N,K=map(int,input().split()) X=list(map(int,input().split())) answers=[] whole=0 for n in range(N-K+1): if X[K-1+n]>0 and X[n]<0: whole += (X[K - 1 + n] - X[n]) whole+=min(X[K-1+n],-X[n]) elif X[K-1+n]<0: whole-=X[n] elif X[n]>0: whole+=X[K-1+n] answers.append(whole) whole=0 print(min(answers)) " p02675,s618088785,Wrong Answer,"s = str(input())[-1] if s == '3': print('hon') elif s in ['0','1','6','8']: print('pon') else: print('pon')" p02778,s332527490,Wrong Answer,"s = open(0).read() print(""x"" * len(s))" p03611,s141611305,Accepted,"from sys import stdin import sys import math n = int(input()) a = list(map(int, stdin.readline().rstrip().split())) dict_count = {} for i in a: dict_count[i] = 0 for j in a: dict_count[j] += 1 #print(dict_count) max_count = 0 for key in dict_count.keys(): max_count = max(max_count, dict_count.get(key - 1, 0) + dict_count.get(key, 0) + dict_count.get(key + 1, 0)) print(max_count) " p02701,s666977309,Wrong Answer,"N = int(input()) S = [str(input()) for _ in range(N)] S = list(S) for i in range(N): for j in range(i,N-1): if S[i] == S[j+1]: N = N - 1 print(N)" p02814,s565740712,Accepted,"from fractions import gcd from functools import reduce def lcm(a, b): return a * b // gcd(a, b) def solve(string): n, m, *a = map(int, string.split()) c = 2**len(bin(a[0]).split(""1"")[-1]) l = reduce(lcm, (2 * m + 1 if _a % c or not _a // c % 2 else _a for _a in a)) return str(max((m - l // 2) // l + 1, 0)) if __name__ == '__main__': import sys print(solve(sys.stdin.read().strip())) " p02922,s852205272,Accepted,"A, B = map(int, input().split()) print((-(-(B-A)//(A-1)))+1)" p02996,s870998377,Wrong Answer,"n=int(input()) x=[] for _ in range(n): a,b=map(int,input().split()) x.append([a,b,b-a]) x.sort(key=lambda x:(x[2],x[1])) t=0 ans='Yes' for i in range(n): if t<=x[i][2]: t+=x[i][0] else: ans='No' break print(ans) " p03556,s045205883,Wrong Answer,"N=int(input()) C=0 for i in range(1,N): if i**2<=N: C=i**2 elif i**2>N: break print(C)" p03910,s619509678,Accepted,"N = int(input()) checkpoint = 0 summation = 0 for i in range(1, N+1): checkpoint = i summation = summation + checkpoint if summation >= N: break unn = summation - N for a in range(1, checkpoint+1): if a != unn: print(a)" p03548,s413857488,Wrong Answer,"x,y,z = map(int,input().split()) i = 1 while(y+z*2+(z+y)*i < x): i += 1 print(i)" p03696,s430473371,Accepted,"N = int(input()) S = input() result = S while True: while True: t = S.replace('()', '') if t == S: break S = t if S == '': break elif S[0] == ')': S = '(' + S result = '(' + result elif S[0] == '(': S = S + ')' result = result + ')' print(result) " p03799,s269235116,Wrong Answer,"#!/usr/bin/env python3 S, C = map(int, input().split()) ret = 0 if 2 * S <= C: ret += S C -= 2 * S S = 0 ret += C // 4 print(ret) " p02939,s551616822,Accepted,"s = input() cnt = 1 pre = s[0] i = 1 while i < len(s): if i == len(s)-1 and s[i] == pre: break elif s[i] == pre: pre = s[i:i+2] i += 2 cnt += 1 else: pre = s[i] i += 1 cnt += 1 print(cnt)" p02629,s343783705,Accepted," s = ""abcdefghijklmnopqrstuvwxyz"" def fA(N): if N <= 26: return s[N-1] a = (N-1) // 26 b = N % 26 return fA(a) + fA(b) N = int(input()) print(fA(N)) # for N in range(710): # print(N, fA(N)) " p03251,s973113883,Accepted,"n,m,x,y=map(int,input().split()) xx=list(map(int,input().split())) yy=list(map(int,input().split())) mx=max(xx) my=min(yy) if mx>=my: print(""War"") elif mx>=y or x>=my: print(""War"") else: print(""No War"")" p03612,s513115155,Wrong Answer,"n = int(input()) p = list(map(int, input().split())) ans = 0 for i in range(n - 1): if p[i] == i+1: ans += 1 if p[i+1] == i+2: ans -= 1 if p[n-1] == n: ans += 1 print(ans)" p03474,s268298623,Accepted,"a,b=map(int,input().split()) s=input() print(""Yes"" if s[a]==""-"" and s.count(""-"")==1 else ""No"")" p03852,s659859193,Accepted,"c = str.lower(input()) n = ('a', 'e', 'i', 'o', 'u') if c in n: print('vowel') else: print('consonant') " p03623,s225694727,Wrong Answer,"s = str(input()) 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""] for i in s: if i in alphabet: alphabet.remove(i) if len(alphabet)!=0: print(alphabet[0]) else: print(""Nome"") " p03814,s946978643,Accepted,"# Problem B - A to Z String # input process s = input() s_len = len(s) # initizalization a_pos = 0 z_pos = 0 # first a search for i in range(s_len): a = s[i] if a=='A': a_pos = i break # second z search for i in range(s_len): z = s[i] if z=='Z': z_pos = i print(z_pos - a_pos + 1) " p02612,s289085271,Wrong Answer,"n = int(input()) print(1000-n%1000)" p02699,s679331812,Accepted,"S, W = map(int, input().split()) if S <= W: print(""unsafe"") else: print(""safe"")" p03836,s434046661,Wrong Answer,"def main(): sx, sy, tx, ty = map(int, input().split()) ans = '' ans += 'R' * (tx - sx - 1) + 'U' * (ty - sy) + 'R' ans += 'D' * (ty - sy + 1) + 'L' * (tx - sx) + 'U' ans += 'U' * (ty - sy + 1) + 'R' * (tx - sx) + 'D' ans += 'R' + 'D' * (ty - sy + 2) + 'L' * (tx - sx + 2) + 'UUR' print(ans) if __name__ == '__main__': main() # import sys # # sys.setrecursionlimit(10 ** 7) # # input = sys.stdin.readline # rstrip() # int(input()) # map(int, input().split()) " p02717,s430394953,Accepted,"x,y,z = map(int,input().split()) print(z,x,y) " p03827,s922902974,Accepted,"n = int(input()) s = input() ans = 0 mans = 0 for i in range(n): if s[i] == ""I"": ans += 1 mans = max(mans, ans) else: ans -= 1 print(mans)" p02916,s317673231,Accepted,"n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) c = list(map(int, input().split())) subtotal = sum(b) bonus = 0 for i in range(n - 1): if a[i + 1] - a[i] == 1: bonus = bonus + c[a[i] - 1] total = subtotal + bonus print(total)" p03407,s953339379,Accepted,"A,B,C=map(int,input().split()) if A+B>=C: print(""Yes"") else: print(""No"") " p04043,s626033553,Accepted,"a = list(map(int,input().split())) if(sum(a) == 17 and 7 in a): print(""YES"") else: print(""NO"")" p02596,s364253224,Accepted,"def solution(K: int) -> int: sevens: int = 0 for i in range(1, K + 1): sevens = (sevens*10 + 7) % K if sevens == 0: return i return -1 K: int = int(input()) print(solution(K)) " p02555,s358073366,Accepted,"a,b,c=1,0,0 exec('a,b,c=b,c,a+c;'*int(input())) print(a%(10**9+7))" p03250,s561933712,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 I = list(map(int, input().split())) I.sort(reverse=True) print(I[0] * 10 + sum(I[1:3]))" p03487,s935652962,Wrong Answer,"n = int(input()) a = list(map(int, input().split())) a.sort() ans=0 lastnum=a[0] cnt=1 for num in a[1:]: if num==lastnum: cnt+=1 else: ans+=min(cnt,abs(cnt-lastnum)) cnt=1 lastnum=num ans+=min(cnt,abs(cnt-lastnum)) print(ans)" p02688,s591790776,Wrong Answer,"#!/usr/bin/env python3 # input n, k = map(int, input().split()) d = [-1 for _ in range(k)] A = [[] for _ in range(k)] for i in range(k): d[i] = int(input()) A[i] = list(map(int, input().split())) # calc okashi = [0 for _ in range(n)] for i in range(k): for j in range(d[i]): okashi[j] += 1 ans = 0 for i in range(len(okashi)): if okashi[i] == 0: ans += 1 print(ans) " p02613,s704913997,Accepted,"import collections n = int(input()) KeyLst = ('AC','WA','TLE','RE') resultLst = (str(input()) for _ in range(n)) countedDic = collections.Counter(resultLst) for key in KeyLst: print('{} x {}'.format(key,countedDic[key]))" p02598,s649065496,Accepted,"import math n,k = map(int,input().split()) a = list(map(int,input().split())) a.sort(reverse=True) l = 0 h = a[0] def pos(b): c = 0 for i in range(n): if a[i] <= b: break c += math.ceil(a[i]/b)-1 if c > k: return False return True while l+1 < h: m = (l+h)//2 if pos(m): h = m else: l = m print(h) " p03324,s418316069,Accepted,"D, N = map(int, input().split()) def calc(n): count = 0 while n % 100 == 0: count += 1 n /= 100 return count count = 0 val = 0 while count < N: val += 1 if calc(val) == D: count += 1 print(val)" p03698,s351814909,Accepted,"S = input() tmp = [] ans = ""yes"" for i in range(len(S)): if (S[i] in tmp): ans = ""no"" break else: tmp.append(S[i]) print(ans)" p02684,s532619597,Accepted,"import sys sys.setrecursionlimit(10**6) N, K = map(int, input().split()) *A, = map(int, input().split()) A = [a-1 for a in A] path = [] visited = {} def dfs(v, k): if v in visited: return v visited[v] = k path.append(v) return dfs(A[v], k+1) origin = dfs(0, 0) i = visited[origin] loop = path[i:] if K <= i: print(path[K] + 1) else: j = (K - i) % len(loop) print(loop[j] + 1) " p02554,s279436456,Accepted,"#!/usr/bin/env python3 #(a^b) % (1e9 + 7)を求める def powmod(a, b): result = 1; for i in range(b): result *= a result %= 1e9 + 7 return result n = int(input()) if n == 1: print(0) elif n == 2: print(2) else: # print(10 ** n - 2 * (9 ** n) + 8 ** n) r = powmod(10, n) - 2 * powmod(9, n) + powmod(8, n) r = int(r % (1e9 + 7)) print(r) " p02879,s528225744,Accepted,"A,B = map(int,input().split()) print(A*B if A <= 9 and B <= 9 else -1)" p03637,s480400982,Accepted,"n = int(input()) a = list(map(int, input().split())) x = 0 y = 0 z = 0 for i in range(n): if a[i]%4 == 0: x += 1 elif a[i]%2 == 0: y += 1 else: z += 1 if y == 0: if x+1 >= z: print(""Yes"") else: print(""No"") else: if x >= z: print(""Yes"") else: print(""No"") " p03471,s816774265,Accepted,"N, Y = map(int, input().split()) a = 0 b = 0 c = 0 for i in range(N+1): for j in range(N+1): if 10000*i + 5000*j + 1000*(N-i-j) == Y and N-i-j>=0: a = i b = j c = N-i-j if a == 0 and b == 0 and c == 0: print(-1,-1,-1) else: print(a,b,c)" p02847,s942796243,Accepted,"S = str(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) else: print(1) " p03408,s697674782,Accepted,"import sys import os import re import datetime card = {} N = int(input()) for _ in range(N): s = input() if s in card: card[s] += 1 else: card[s] = 1 M = int(input()) for _ in range(M): t = input() if t in card: card[t] -= 1 else: card[t] = -1 maxCount = 0 #print(card) for count in card: maxCount = max(maxCount, max(card.values())) print(maxCount) " p02645,s552825916,Wrong Answer,"s = input() print(s[0:2])" p03071,s973081445,Wrong Answer,"S = input() odd = S[1::2] even = S[::2] print(min(odd.count(""1"") + even.count(""0""), even.count(""1"") + odd.count(""0"")))" p03803,s443045524,Accepted,"A, B = map(int, input().split()) if A == B: print('Draw') elif B!=1 and A>B or A==1: print('Alice') else: print('Bob') " p03219,s979466997,Accepted,"x,y=map(int,input().split()) print(int(x+y/2))" p03219,s034795663,Accepted,"x,y = map(int,input().split()) print(x+y//2)" p02814,s343123072,Wrong Answer,"import sys from collections import defaultdict from queue import deque readline = sys.stdin.buffer.readline #sys.setrecursionlimit(10**8) from fractions import gcd 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, m = geta(int) a = tuple(geta(int)) g = a[0] // 2 for ai in a[1:]: ai2 = ai // 2 g = (g * ai2) // gcd(g, ai2) print((m + g) // (g * 2)) if __name__ == ""__main__"": main()" p03162,s472211967,Accepted,"N = int(input()) scores = [] for i in range(N): scores.append(list(map(int, input().split()))) D = scores[0] for day in range(1, N): D = [max(D[:i] + D[i+1:]) + scores[day][i] for i in range(len(D))] print(max(D))" p03592,s862772414,Accepted,"N, M, K = map(int, input().split()) f = 0 for i in range(0, N+1): if N == 2 * i: if K == i * M: print(""Yes"") f = 1 break elif (K - i * M) % (N - 2 * i) == 0 and 0 <= (K - i * M) // (N - 2 * i) <= M: print(""Yes"") f = 1 break if f == 0: print(""No"")" p03548,s911958925,Accepted,"x, y, z = map(int, input().split()) i = 1 while True: if x < (i * y) + ((i + 1) * z): print(i-1) exit() i += 1" p02761,s820114563,Accepted,"n,m = map(int, input().split()) sc = [list(map(int, input().split())) for _ in range(m)] ans = [""0""] * n if n>=2: ans[0] = ""1"" ok = True for s,c in sc: if s-1==0 and n>=2: if ans[s-1] == ""1"" or ans[s-1] == str(c): ans[s-1] = str(c) else: ok = False else: if ans[s-1] == ""0"" or ans[s-1] == str(c): ans[s-1] = str(c) else: ok = False if n>=2: if ans[0] == ""0"": ok = False print(-1 if not ok else """".join(ans))" p03962,s041716406,Wrong Answer,"a,b,c = map(int,input().split()) d=[a,b,c] d =list(set(d)) print(d)" p03693,s887338296,Accepted,"r,g,b = map(str, input().split()) rgb = int(r+g+b) print(""YES"") if rgb % 4 == 0 else print(""NO"")" p03657,s705795351,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,s647530121,Accepted,"s = input() for i in range(len(s)): for j in range(len(s) - 1): S = s[:j] + s[j+i:] if S == 'keyence': print('YES') exit() else: print('NO')" p02760,s701882832,Accepted,"A = [list(map(int, input().split())) for _ in range(3)] n = int(input()) B = set([int(input()) for _ in range(n)]) cr1 = {A[0][0], A[1][1], A[2][2]} cr2 = {A[2][0], A[1][1], A[0][2]} main_list= [cr1, cr2] R = [set([A[i][j] for j in range(3)]) for i in range(3)] C = [set([A[i][j] for i in range(3)]) for j in range(3)] main_list.extend(R) main_list.extend(C) for D in main_list: if D.issubset(B): print('Yes') quit() print('No')" p03951,s607602702,Accepted,"#!/usr/bin/env python3 N = int(input()) S = input() T = input() ans = S + T end = N for i in range(N): if S[i:] == T[:end]: ans = S + T[end:] break end -= 1 print(len(ans)) " p03012,s318431313,Accepted,"n = int(input()) l = [int(_) for _ in input().split()] ans = float('inf') for i in range(n): ans = min(ans, abs(sum(l[:i]) - sum(l[i:]))) print(ans) " p03379,s416433797,Wrong Answer,"import sys input = sys.stdin.readline def main(): N = int(input()) X = [int(x) for x in input().split()] X_sorted = sorted(X) a = X_sorted[N // 2] b = X_sorted[(N // 2) - 1] for i in range(N): if X[i] == a: print(b) else: print(a) if __name__ == '__main__': main() " p02690,s428263915,Accepted,"x = int(input()) for i in range(-500, 500): for j in range(-500, 500): if i**5-j**5 == x: a = i b = j break print(a, b)" p03672,s648940239,Accepted,"S=input() N=len(S) ans=S[0] for i in range(1,N): if i%2==1: continue T=S[:i] T1=T[:i//2] T2=T[i//2:] if T1==T2: ans=T #print(T1,T2) print(len(ans))" p03254,s815265303,Accepted,"from sys import stdin import math [N, x] = list(map(int, stdin.readline().rstrip().split())) a = list(map(int, stdin.readline().rstrip().split())) a_sorted = sorted(a) count=0 for i in range(N): #x -= a_sorted[i] x = x - a_sorted[i] if x >=0: count += 1 else: break if x > 0: count -= 1 print(count) " p02880,s214395827,Accepted,"N = int(input()) f = False for i in range(1,10): for j in range(1,10): if i * j == N: f = True print('Yes') if f else print('No')" p03352,s444960228,Accepted,"#!/usr/bin/env python3 X = int(input()) ret = 0 for i in range(1, 1001): for j in range(2, 20): if i**j <= X: ret = max(i**j, ret) print(ret) " p02646,s469148188,Wrong Answer,"A,V=map(int,input().split()) B,W=map(int,input().split()) T=int(input()) if V!=W: if abs(A-B)/abs(V-W)<=T: print('YES') else: print('No')" p03075,s929212191,Accepted,"a=[int(input()) for i in range(6)] for i in range(5): for j in range(i+1,5): if a[j]-a[i]>a[5]: print("":("") exit() print(""Yay!"")" p02714,s563657954,Accepted,"import collections n = int(input()) s = [''] + list(input()) cnt_1 = collections.Counter(s) sub = 0 for j in range(1, (n+1)//2): for i in range(1, n-2*j+1): tmp = s[i] + s[i+j] + s[i+j*2] cnt_2 = collections.Counter(tmp) if cnt_2['R'] == 1 and cnt_2['G'] == 1 and cnt_2['B'] == 1: sub += 1 print((cnt_1['R']*cnt_1['G']*cnt_1['B'])-sub)" p02682,s666954863,Wrong Answer,"a,b,c,k = map(int,input().split()) if k <= a + b: print(a) else: print(2*a - k + b)" p03282,s999800351,Accepted,"# solution data=input() k=int(input()) for i,c in enumerate(data): if c!='1' or i>=k-1: break print(c)" p02789,s404336467,Accepted,"n,m = map(int,input().split()) if n ==m: print('Yes') else: print('No')" p02720,s253211281,Accepted,"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)) print(a.popleft())" p03012,s789611606,Accepted,"#B import math n = int(input()) w = list(map(int, input().split())) min=float('inf') for t in range(1,n): a = sum(w[:t]) b = sum(w[t:]) # print(a, b) if min > abs(a - b): min = abs(a - b) print(min)" p03548,s761335176,Accepted,"x,y,z=map(int,input().split()) res=x-z ans=0 while res>=y+z: res-=(y+z) ans+=1 print(ans)" p03730,s754831141,Wrong Answer,"a , b , c = map(int, input().split()) for i in range(b): if i == b: print('NO') break if a*(i+1)%b==c: print('YES') break" p02690,s716480479,Accepted,"x = int(input()) for i in range(-2*10**2,2*10**2): for j in range(-2*10**2,2*10**2): if i**5- j**5 ==x: print(i,j) exit() elif j**5 - i**5 == x: print(j,i) exit()" p03293,s039134426,Accepted,"S = input() T = input() s = [] t = [] for i in range(len(S)): s.append(S[i]) t.append(T[i]) flag = 0 if s == t: print(""Yes"") flag += 1 else: for i in range(len(s)): A = s[0] s.remove(A) s.append(A) if s == t: print(""Yes"") flag += 1 break if flag == 0: print(""No"") " p03862,s414014332,Accepted,"n,x=map(int,input().split()) a=list(map(int,input().split())) cnt=0 for i in range(1,n): v = a[i]+a[i-1]-x if v>0: cnt+=v if a[i]>=v: a[i]-=v else: v-=a[i] a[i]=0 a[i-1]-=v print(cnt) " p02946,s503704380,Accepted,"k,x=map(int,input().split()) l=[] for i in range(x-k+1,x+k): l.append(str(i)) print(' '.join(l)) " p03387,s508317447,Wrong Answer,"List = list(map(int, input().split())) List.sort() res = List[2]-List[1] List[1] = List[2] List[0] += res mid = List[2] - List[0] if mid % 2 == 1: res += mid //2 +1 else: res += mid //2 print(res)" p02767,s129048940,Wrong Answer,"n = int(input()) list = [] list1 = [] list2 = [] list3 = [] c = 0 a = input().split() for i in range(0, len(a)): list1.append(int(a[i])) for j in range(1, 100): for item in list1: c = c+ (item-j)**2 list2.append(c) l = len(list2) for z in range(0, l-1): list3.append(list2[z+1]-list2[z]) list3.sort() print(list3[0])" p03286,s105130360,Accepted,"N=int(input()) ans="""" for i in range(1,10000): tmp=2**i if N%tmp==2**(i-1): N-=(-2)**(i-1) ans=""1""+ans else: ans=""0""+ans if N == 0: break print(ans)" p02694,s971040961,Accepted,"from sys import setrecursionlimit, exit setrecursionlimit(1000000000) def main(): a = 100 x = int(input()) ans = 0 while a < x: a += a // 100 ans += 1 print(ans) main()" p03821,s593436690,Accepted,"import math N = int(input()) A_list = list() B_list = list() A_list.append(0) B_list.append(0) for i in range(N): A,B = map(int, input().split()) A_list.append(A) B_list.append(B) #末尾から考える ans = 0 for i in range(N): A = A_list.pop(-1) B = B_list.pop(-1) #print(A,B,""→"",end="""") A += ans goal = B*math.ceil(A/B) #print("":"",goal) ans += goal - A print(ans)" p03814,s584534786,Wrong Answer,"s = input() start = -float('inf') best_length = -float('inf') for i,w in enumerate(s): if w=='A' and start < 0: start = i elif w=='Z': length = i - start + 1 if length > best_length: best_length = length print(best_length if best_length > 0 else 0)" p03331,s024349248,Wrong Answer,"N = int(input()) if(not N % 10): print(N) ans = 0 while(N > 0): ans += N % 10 N //= 10 print(ans) " p02688,s400299912,Accepted,"import sys sys.setrecursionlimit(10 ** 6) INF = float(""inf"") MOD = 10 ** 9 + 7 def input(): return sys.stdin.readline().strip() def main(): N, K = map(int, input().split()) D = [1] * (N + 1) D[0] = 0 for _ in range(K): d = int(input()) A = list(map(int, input().split())) for a in A: D[a] = 0 print(sum(D)) if __name__ == ""__main__"": main() " p04020,s355822459,Accepted,"import sys from collections import Counter from collections import deque import math import bisect 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()) l=[int(input()) for i in range(n)] ans=0 c=0 for i in range(n): if l[i]==0: ans+=c//2 c=0 else: c+=l[i] ans+=c//2 print(ans)" p02633,s749428893,Wrong Answer,"import sys input=sys.stdin.readline sys.setrecursionlimit(10**6) from math import gcd,ceil def lcm(a,b):return a*b//gcd(a,b) x=int(input().rstrip()) print(360//x if 360%x==0 else ceil(360/x)*(lcm(360,x)//360))" p03545,s573471375,Accepted,"# AtCoder s = list(map(str, input())) n = len(s) for i in range(2**3): # 2の選ぶものの個数乗 ops = [] for j in range(3): if ((i >> j) & 1): ops.append('+') else: ops.append('-') if eval(s[0]+ops[0]+s[1]+ops[1]+s[2]+ops[2]+s[3]) == 7: print(s[0]+ops[0]+s[1]+ops[1]+s[2]+ops[2]+s[3] + '=7') exit() " p03986,s276235791,Accepted,"X = input() N = len(X) S = 0 ans = 0 for i in range(N): if X[i] == 'S': S += 1 elif S > 0: S -= 1 ans += 2 print(N-ans) " p02621,s355057606,Accepted,"a = int(input()) print(a+a**2+a**3)" p03469,s671530118,Accepted,"s = input() print('2018'+s[4:]) " p03339,s034742008,Accepted," N = int(input()) S = list(input()) W = [0]*(N+1) E = [0]*(N+1) for i in range(N): if S[i]=='W': W[i+1] = W[i]+1 else: W[i+1] = W[i] for i in reversed(range(N)): if S[i]=='E': E[i] = E[i+1] + 1 else: E[i] = E[i+1] INF = 1<<30 ans = INF for i in range(N): res = W[i] + E[i+1] ans = min(ans,res) print(ans)" p02724,s369233681,Accepted,"x = int(input()) h = 0 while x >= 500: x -= 500 h += 1000 while x >= 5: x -= 5 h += 5 print(h)" p03705,s228691967,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((b*(n-1)+a) - (a*(n-1)+b) + 1) " p02663,s680467029,Accepted,"import sys input = sys.stdin.readline def main(): H1, M1, H2, M2, K = map(int, input().split()) if H1 == H2: time = M2 - M1 else: time = (60 - M1) + (H2 - H1 - 1) * 60 + M2 ans = time - K print(ans) if __name__ == ""__main__"": main() " p03986,s339791633,Accepted,"def main(): X = input() s = 0 ans = len(X) for x in X: if x == 'S': s += 1 else: if s > 0: s -= 1 ans -= 2 print(ans) if __name__ == '__main__': main() " p02628,s593771612,Accepted,"from sys import stdin from sys import setrecursionlimit from collections import Counter, deque, defaultdict from math import floor, ceil from bisect import bisect_left from itertools import combinations setrecursionlimit(100000) INF = int(1e10) MOD = int(1e9 + 7) def main(): from builtins import int, map N, K = map(int, input().split()) A = list(map(int, input().split())) A.sort() print(sum(A[:K])) if __name__ == '__main__': main()" p03449,s990326656,Accepted,"N = int(input()) *A1, = map(int, input().split()) *A2, = map(int, input().split()) ans = 0 for i in range(N): ans = max(ans, sum(A1[:i+1]) + sum(A2[i:])) print(ans)" p02995,s719913045,Accepted,"from fractions import gcd a, b, c, d = [int(i) for i in input().split()] a-=1 ans = b - a ans -= b // c - a//c ans -= b // d - a // d e = c * d // gcd(c, d) ans += b // e - a // e print(ans)" p02923,s274416469,Wrong Answer,"n = int(input()) h = list(map(int, input().split())) h.reverse() maxH = 0 maxT = 0 for i in range(n-1): if h[i] <= h[i + 1]: maxT += 1 else: maxH = max(maxH, maxT) maxT = 0 print(maxH)" p03721,s752748103,Wrong Answer,"N,K = (int(T) for T in input().split()) Now = 0 for TN in range(0,N): Num,Count = (int(T) for T in input().split()) if Now= (a * b) / 2: tan = 2*(a*b - s) / a**2 else: tan = b**2 / 2*s print(math.degrees(math.atan(tan)))" p02922,s218973639,Accepted,"x,y = map(int,input().split()) t = x c = 1 if y == 1: print(0) exit() for i in range(100): if t>=y: print(c) break t += x-1 c += 1 #print(t) " p02595,s189381967,Accepted,"n, d = map(int, input().split()) lists = [] cnt = 0 for i in range(n): x, y = map(int, input().split()) lists.append([x, y]) for j in range(n): l = (lists[j][0] ** 2 + lists[j][1] ** 2) ** (1 / 2) if l <= d: cnt += 1 else: continue print(cnt)" p03437,s386776330,Accepted,"a,b=map(int,input().split()) c=a*b+a print(c if c%b!=0 else -1)" p04030,s962892023,Accepted,"t = """" for x in input(): if x==""B"": t = t[:-1] else: t += x print(t)" p03001,s347057661,Accepted,"w, h, x, y = map(int, input().split()) max_area = w*h/2 flag = 0 if x == w/2 and y == h/2: flag = 1 print(max_area, flag)" p03838,s980050619,Wrong Answer,"x, y = map(int, input().split()) if (x > 0 and y < 0) or (x < 0 and y > 0): print(abs(abs(x)-abs(y))+1) elif y < 0: print(abs(abs(x)-abs(y))+2) else: print(abs(abs(x)-abs(y))) " p02765,s108061562,Accepted,"n, r = map(int, input().split()) if n >= 10: print(r) else: print(r + 1000 - 100 * n)" p03623,s294906603,Wrong Answer,"x,a,b = map(int, input().split()) print(min(abs(x-a), abs(x-b)))" p04043,s528322557,Accepted,"a,b,c=map(int,input().split()) List=[a,b,c] if List.count(5)==2 and List.count(7)==1: print(""YES"") else: print(""NO"")" p02790,s700929771,Accepted," b,c=map(int,input().split()) bc=c cb=b for i in range(b-1): bc=(bc*10+c) for i in range(c-1): cb=(cb*10+b) print(max(bc,cb))" p03042,s369996044,Wrong Answer," S = input() l = S[:2] r = S[2:] lcnt = 0 rcnt = 0 if 0 < int(l) <= 12 and 0 < int(r): lcnt = 1 if 0 < int(r) <= 12 and 0 < int(l): rcnt = 1 if lcnt and rcnt: print('AMBIGUOUS') exit() elif lcnt: print('MMYY') elif rcnt: print('YYMM') else: print('NA')" p03071,s150516965,Accepted,"a, b = map(int, input().strip().split()) res = 0 if a < b: res = 2 * b - 1 elif a == b: res = 2 * a else: res = 2 * a - 1 print(res) " p03644,s095820178,Accepted,"n = int(input()) l = [2**i for i in range(8)] if n==1: print(1) exit() for i,v in enumerate(l): if n < v: print(l[i-1]) exit()" p02773,s299515458,Accepted,"n = int(input()) d ={} for i in range(n): s = str(input()) if s in d: d[s] += 1 else: d[s] = 1 d = sorted(d.items(), key=lambda x : x[0]) d = sorted(d, key=lambda x : x[1],reverse=1) flag = d[0][1] for i in d: if i[1] == d[0][1]: print(i[0]) else: exit()" p03617,s231237258,Accepted,"q,h,s,d=map(int,input().split()) n=int(input()) q*=4 h*=2 if n%2==0: print(min(min(q,h,s)*n,d*n//2)) else: print(min(min(q,h,s)*n,d*(n//2)+min(q,h,s)))" p02712,s140463417,Wrong Answer,"n = int(input()) res = 0 for i in range(1, n): if i % 3 == 0 and i % 5 == 0: res += 0 elif i % 3 == 0: res += 0 elif i % 5 == 0: res += 0 else: res += i print(res) " p02880,s896364008,Accepted,"# -*- coding: utf-8 -*- import sys from sys import stdin N = int(stdin.readline().rstrip()) for i in range(1, 10): for j in range(1, 10): if N == i * j: print('Yes') sys.exit(0) else: print('No') " p02624,s842709484,Accepted,"N = int(input()) ans = 0 for i in range(1, N+1): n = N//i cnt = i*n*(n+1)//2 ans += cnt print(ans)" p02963,s568273380,Accepted,"S = int(input()) a = 10**9 print(a, (a - (S % a)) % a, 1, (S + a - 1) // a, 0, 0) " p02873,s776847678,Accepted,"S = input() ans_list = [0] * (len(S) + 1) for i in range(len(S)): if S[i] == '<': ans_list[i + 1] = ans_list[i] + 1 for i in range(len(S) - 1,-1,-1): if S[i] == '>': ans_list[i] = max(ans_list[i + 1] + 1, ans_list[i]) print(sum(ans_list))" p02688,s192280442,Wrong Answer,"def main(): s = list(map(int,input().split())) n = [0]*s[0] for k in range(0,s[1],1): d = int(input()) a = list(map(int,input().split())) #print(a) for i in range(0,d,1): #print(a[i]) n[a[i]-1] = 1 #print(n) sum=0 print(n) for k in range(0,s[0],1): if(n[k]==0): sum = sum+1 print(sum) main()" p03779,s408487640,Accepted,"def solve(): X = int(input()) now = 0 for i in range(X + 1): now += i if now >= X: return i print(solve()) " p03250,s030118603,Accepted,"import sys import os def main(): if os.getenv(""LOCAL""): sys.stdin = open(""input.txt"", ""r"") abc = list(map(str, sys.stdin.readline().split())) abc.sort(reverse=True) print(int(abc[0]+abc[1])+int(abc[2])) if __name__ == '__main__': main() " p03721,s500934102,Accepted,"if __name__ == ""__main__"": N, K = [int(x) for x in input().split("" "")] arr = [] for _ in range(N): a, b = [int(x) for x in input().split("" "")] arr.append((a, b)) arr.sort() k = 0 for a, b in arr: if k + b < K: k = k + b else: print(a) break " p03136,s504060610,Accepted,"N=int(input()) L=list(map(int,input().split())) L.sort(key=int) ans= L.pop(-1)> 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 = min(kn[0], cst) print(cst if cst != 12 * 10**5 else -1)" p03665,s039562008,Accepted,"n, p = map(int, input().split()) a = list(map(int, input().split())) odd = sum([item % 2 for item in a]) even = n - odd ans = 0 if even == n: if p == 1: print(0) else: print(2 ** n) elif n == 1 and odd == 1 and p == 0: print(0) else: # 偶数枚入った袋は選ぶor選ばない自由 ans += 2 ** even # 奇数枚入った袋は2で割って余りがPになるよう選ぶ個数を決める ans *= 2 ** (odd - 1) print(ans)" p02910,s427361071,Accepted,"s=input() odd=[""R"",""U"",""D""] even=[""L"",""U"",""D""] ans=""Yes"" for i in range(len(s)): if i%2==0: if s[i] not in odd: ans=""No"" else: if s[i] not in even: ans=""No"" print(ans)" p03472,s615282241,Accepted,"import math n,h = map(int,input().split()) A = 0; b = []; ans = 0 for _ in range(n): u,v = map(int,input().split()) A = max(A,u); b.append(v) for B in sorted(b,key=lambda x:-x): if h <= 0 or B <= A:break h -= B ans += 1 print(max(0,math.ceil(h/A)) + ans)" p02694,s380266993,Accepted,"X = int(input()) ans = 0 num = 100 while X > num: num = num+num//100 ans += 1 print(ans)" p02601,s530070522,Accepted,"A,B,C=map(int,input().split()) K=int(input()) for i in range(K): if A>=B: B=B*2 elif B>=C: C=C*2 if ((A=m: print(0) exit() dis = [x[i+1]-x[i] for i in range(m-1)] dis.sort() del dis[-(n-1):] print(sum(dis))" p03632,s362302900,Accepted,"a,b,c,d=map(int,input().split()) print(max([0,min([b,d])-max([a,c])]))" p02888,s256596951,Wrong Answer,"N = int(input()) M = list(map(int, input().split())) M = sorted(M) count = 0 for i in range(N): a = M[i] for j in range(i+1, N): b = M[j] upper = a+b #二分探索の実装が下手い l, r = j, N while (r - l) > 1: c = (l + r) // 2 if M[c] <= upper: l = c else: r = c #print(count, j, l, r) count += l - j print(count)" p03250,s255821473,Accepted,"l=list(map(int,input().split())) l.sort() print(l[-1]*10+l[-2]+l[-3])" p02676,s499115390,Accepted,"# K = int(input()) # S = input() # if len(S) > K: # print(S[:K] + '...') # else: # print(S) K = int(input()) S = input() def answer(K: int, S: str) -> str: if len(S) <= K: return S else: return S[:K]+ '...' print(answer(K, S))" p03605,s419030399,Accepted,"print(""Yes"" if ""9"" in input() else ""No"")" p02714,s810516675,Accepted,"N = int(input()) S = list(input()) r = S.count('R') g = S.count('G') b = S.count('B') ans = r*g*b for i in range(0,N): for j in range(i,N): k = 2*j - i if j < k <= N-1: if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]: ans -= 1 print(ans) " p03162,s312884268,Accepted,"def main(): import sys input = sys.stdin.readline n=int(input()) l=[tuple(map(int,input().split())) for _ in range(n)] dp=[[0]*3 for _ in range(n+1)] for i in range(1,n+1): dp[i][0]=max(dp[i-1][1],dp[i-1][2])+l[i-1][0] dp[i][1]=max(dp[i-1][2],dp[i-1][0])+l[i-1][1] dp[i][2]=max(dp[i-1][0],dp[i-1][1])+l[i-1][2] print(max(dp[-1])) if __name__=='__main__': main()" p03206,s621319139,Accepted,"D = int(input()) day = [' Eve' if D==24 else ' Eve Eve' if D==23 else ' Eve Eve Eve' if D==22 else ''] print('Christmas' + day[0])" p02768,s110157950,Wrong Answer,"# -*- coding: utf-8 -*- def comb(N, A): x = 1 for i in range(A): x *= N N -= 1 x %= MOD y = 1 for i in range(A): y *= A A -= 1 y %= MOD return x*pow(y, MOD-2, MOD) % MOD N, A, B = map(int, input().split()) MOD = 10**9+7 print(pow(2, N, MOD)-1-comb(N, A)-comb(N, B)) " p02622,s129194135,Accepted,"S = input() T = input() count = 0 for i in range(len(S)): if S[i] != T[i]: count += 1 print(count) " p03627,s920781442,Accepted,"from collections import Counter n = int(input()) a = tuple(map(int,input().split())) c = Counter(a) temp = sorted(c.items()) h = 0 w = 0 while(len(temp)>0): k,v = temp.pop() if v>=4: print(k**2) exit() elif v>=2: h = k break while(len(temp)>0): k,v = temp.pop() if v>=2: w = k break print(h*w)" p03327,s658027779,Wrong Answer,"N = int(input()) if N < 1000: print('ABC'+str(N)) else: print('ABD'+str(N))" p02717,s997876752,Wrong Answer,"list1 = list(map(int, input().split())) list2= [] list2.append(list1[2]) list2.append(list1[0]) list2.append(list1[1]) print(list2) " p02731,s020109477,Wrong Answer,"l=int(input()) ans=[] for i in range(l//2+1): for j in range(l//2+1): ans.append(i*j*(l-i-j)) print(max(ans))" p02711,s867729507,Accepted,"n = int(input()) ans = 'No' for i in str(n): if int(i) == 7: ans = 'Yes' print(ans)" p02897,s614825235,Accepted,"N = int(input()) print((N-N//2)/N) " p02693,s222191111,Accepted,"K = int(input()) A, B = map(int, input().split()) if A % K == 0 or ((A // K) + 1)* K <= B: print('OK') else: print('NG')" p03416,s254824642,Accepted,"A,B=map(int,input().split()) count=0 for i in range(A,B+1): i_str=str(i) ri_str=i_str[::-1] ri=int(ri_str) if i==ri: count+=1 print(count)" p03013,s681253706,Accepted,"MOD = 10**9 + 7 n, m = map(int, input().split()) dp = [0] * (n + 10) a = [True] * (n + 10) for _ in range(m): a[int(input())] = False dp[0] = 1 for i in range(n): if a[i + 1]: dp[i + 1] = (dp[i + 1] + dp[i]) % MOD if a[i + 2]: dp[i + 2] = dp[i] print(dp[n])" p02791,s272943496,Accepted,"N = int(input()) #a,b = map(int,input().split()) P = list(map(int,input().split())) #A = [int(input()) for i in range(N)] #A = [list(map(int,input().split())) for i in range(N)] mina = P[0] count = 1 for i in range(1,N): mina = min(mina,P[i]) if mina >= P[i]: count += 1 print(count)" p02645,s249095449,Accepted,"s = input() print(s[:3])" p03672,s263065260,Accepted,"s = str(input()) n = len(s) for i in range(1, n): m = n - i if m % 2 != 0: continue #print(s[0:m//2], s[m//2:m]) if s[0:m//2] == s[m//2:m]: break print(m)" p02711,s220486721,Accepted,"print([""No"",""Yes""][""7"" in input()])" p03261,s789042486,Wrong Answer,"n = int(input()) lst = [] flag = True tmp = input() lst.append(tmp) for i in range(n-1): w = input() if w in lst: flag = False if tmp[-1] != w[0]: flag = False lst.append(w) tmp = w print('yes' if flag == True else 'No')" p03860,s271267906,Accepted,"s1, s2, s3 = input().split() print(""{}{}{}"".format(s1[0], s2[0], s3[0]))" p03705,s672376073,Accepted,"n,a,b=map(int,input().split()) print(max(0,(n-2)*(b-a)+1))" p04031,s587612341,Wrong Answer,"x=int(input()) if x>=2000: print(1) else: if (x//100)*100<=x<=(x//100)*105: print(1) else: print(0)" p02582,s637517237,Wrong Answer,"s = input() cnt = 0 if s[0] == s[1] and s[1] == s[2] and s[1] =='R': print('3') elif s[0] == s[1] or s[1] == s[2] and s[1]=='R': print('2') elif s[0] == 'R' or s[1] =='R' or s[2] == 'R': print('1') else: print('0')" p03680,s248081281,Accepted,"n = int(input()) a = [0] * n for i in range(n): a[i] = int(input()) visit = set() now = 1 for i in range(1, n + 10): if now not in visit: visit.add(now) now = a[now - 1] else: print(-1) break if now == 2: print(i) break " p03456,s038510199,Accepted,"a, b = input().split() num = int(a + b) flag = ""No"" for i in range(1000): if i ** 2 == num: flag = ""Yes"" break print(flag) " p02972,s187662537,Accepted,"n = int(input()) list_A = list(map(int, input().split())) list_N = [0]*n for i in range(n, 0, -1): k, cnt = 0, 0 while True: if k+i > n: break if list_N[k+i-1] == 1: cnt += 1 k += i list_N[i-1] = (list_A[i-1]+cnt) % 2 ans = [] for i in range(n): if list_N[i] == 1: ans.append(i+1) print(len(ans)) print(*ans)" p03611,s076042152,Accepted,"N = int(input()) A = list(map(int, input().split())) C = [0]*(10**5) for ai in A: C[ai] += 1 ans = 0 for i in range(10**5-2): ans = max(C[i] + C[i+1] + C[i+2], ans) print(ans)" p02780,s476047057,Accepted,"N, K = map(int, input().split()) p = list(map(int, input().split())) rui = [0] for tmp in p: tmp = (tmp + 1) / 2 rui.append(tmp + rui[-1]) ans = 0 for i in range(0, N-K+1): ans = max(ans, rui[i+K] - rui[i]) print(ans)" p03137,s592314863,Accepted,"n, m = map(int, input().split()) x_s = list(map(int, input().split())) if n >= m: print(0) else: x_s.sort() b=[] for i in range(m-1): b.append(x_s[i+1]-x_s[i]) b.sort() ans = 0 for i in range(m-n): ans += b[i] print(ans) " p03329,s441212844,Accepted,"def f(yen, coin, cnt=0): while yen > 0: yen,r=divmod(yen,coin); cnt+=r return cnt ans = n = int(input()) for yen6 in range(0, n+1): ans = min(ans, f(n-yen6, 9, f(yen6, 6))) print(ans) " p02996,s540296942,Wrong Answer,"N=int(input()) A=[] B=[] x=dict() for i in range(N): a,b=map(int,input().split()) A.append(a) B.append(b) t=0 bm=max(B) sa=sum(A) if sa<=bm: print(""Yes"") else: print(""No"")" p03774,s433328986,Accepted,"n, m = map(int, input().split()) lx = [] ly = [] for i in range(n + m): x, y = map(int, input().split()) lx.append(x) ly.append(y) for i in range(n): r = [] for j in range(n, m + n): r.append(abs(lx[i] - lx[j]) + abs(ly[i] - ly[j])) print(r.index(min(r)) + 1) " p03131,s070015289,Accepted,"k,a,b = map(int, input().split()) res = 1 if b <= a + 1: print(res + k) else: if k < a - 1 + 2: print(res + k) else: res += b - 1 k -= a + 1 print(res + k//2 * (b - a) + k % 2)" p03457,s644998924,Accepted,"N = int(input()) bt, bx, by = 0, 0, 0 for _ in range(N): t, x, y = map(int, input().split()) dist = abs(x-bx)+abs(y-by) time = t-bt if time= height[Y-1]: bridge[Y-1] =0 if height[Y-1] >= height[X-1]: bridge[X-1] =0 print(bridge.count(1)) " p02663,s511622551,Accepted,"H1, M1, H2, M2, K = map(int,input().split()) HM1 = H1*60 + M1 HM2 = H2*60 + M2 - K print(HM2 - HM1) " p03379,s646191734,Accepted,"n = int(input()) lst = list(map(int, input().split())) lst2 = sorted(lst) for i in lst: print(lst2[n//2] if i<=lst2[n//2-1] else lst2[n//2-1]) " p03351,s793565632,Accepted,"A, B, C, D = map(int, input().split()) ans = 'Yes' AB = abs(A-B) AC = abs(A-C) BC = abs(B-C) if AC > D: if AB > D or BC > D: ans = ""No"" print(ans)" p02641,s131797660,Accepted,"#!/usr/bin/env python3 # -*- coding: utf-8 -*- def main(): x, n = map(int, input().split()) if n >= 1: p_set = set(map(int, input().split())) else: p_set = set() print(f(x, p_set)) def f(x, p_set): for i in range(101): if (x - i) not in p_set: return x - i elif (x + i) not in p_set: return x + i if __name__ == '__main__': main() " p02665,s967325037,Accepted,"n = int(input()) a = list(map(int, input().split())) b = [0] * (n + 1) next_max_node = 1 for leaf in a: if leaf > next_max_node: print(-1) exit() next_max_node = (next_max_node - leaf) * 2 num_sum = 0 for i in range(1, n+2): tmp = a[-i] b[-i] = a[-i] + num_sum num_sum += a[-i] ret = 0 next_max_node = 1 for i in range(n+1): leaf = a[i] ret += min(b[i], next_max_node) next_max_node = (next_max_node - leaf) * 2 print(ret) " p02783,s241627853,Wrong Answer,"H_str, A_str = input().split(' ') print(int(H_str) // int(A_str) + 1)" p03339,s790679749,Accepted,"n=int(input()) s=input() accuml=[0]*n accumr=[0]*n for i in range(1,n): accuml[i]+=accuml[i-1] accumr[n-i-1]+=accumr[n-i] if s[i-1]==""W"": accuml[i]+=1 if s[n-i]==""E"": accumr[n-i-1]+=1 ans=10**18 for i in range(n): ans=min(ans,accuml[i]+accumr[i]) print(ans) #print(accuml) #print(accumr)" p02802,s025694464,Wrong Answer,"n,m = map(int,input().split()) action = [list(input().split()) for _ in range(m)] answer_dict = {} score = 0 penalty = 0 for a in action: if a[1] == 'WA' and a[0] not in answer_dict: penalty += 1 elif a[1] == 'AC' and a[0] not in answer_dict: score += 1 answer_dict[a[0]] = True print(score,penalty)" p02796,s013346574,Accepted,"n=int(input()) X=[[0]*3 for i in range(n)] for i in range(n): a,b=map(int,input().split()) X[i]=[a+b,a,b] X=sorted(X) l=X[0][0] ans=1 for i in range(n): if X[i][1]-X[i][2]>=l: ans+=1 l=X[i][0] print(ans)" p03478,s416904861,Accepted,"N, A, B = map(int, input().split()) sum = 0 for n in range(1, N+1): nsum = 0 m = n while m != 0: nsum += m % 10 m = m//10 if nsum >= A and nsum <= B: sum += n print(sum) " p03324,s265484842,Accepted,"D, N = map(int, input().split()) if N == 100: print(N * 100 ** D + 100 ** D) else: print(N * 100 ** D) " p03038,s847362399,Wrong Answer,"n,m = map(int,input().split()) A = list(map(int,input().split())) C = [] for _ in range(m): b,c = map(int,input().split()) C.append((c,b)) C.sort() count = 0 for c,b in C: A.extend([c for _ in range(b)]) count += b if count > n: break A.sort(reverse = True) print(sum(A[:n])) " p02833,s561159651,Wrong Answer,"n = int(input()) ans = 0 if n % 2 != 0: print(ans) else: m = n // 2 e = 1 while 5 ** e < m: ans += m // (5 ** e) e += 1 print(ans)" p02771,s088587542,Accepted,"A = map(int, input().split()) if len(set(A) ) == 2: print(""Yes"") else: print(""No"")" p03086,s070257977,Wrong Answer,"l=input() if ""A"" or ""G"" or ""C"" or ""T"" in l: ans=0 num=0 for i in l: if i==""A"" or i==""G"" or i==""C"" or i==""T"": num+=1 if num==len(l): print(num) else: ans=max(num,ans) num=0 print(ans) else: print(0) " p03471,s648055993,Accepted,"n, y = map(int, input().split()) judge = ""no value"" for i in range(n+1): if judge == ""Found it!"": break for j in range(n+1): z = n - i - j value = z * 10000 + i * 5000 + j *1000 if value == y and z >= 0: print(z, i , j) judge = ""Found it!"" break if judge == ""no value"": print(-1, -1, -1) " p03910,s809864227,Wrong Answer,"import sys N = int(input()) ans = [] if N == 1: print(1) sys.exit() for i in range(1, N): n = N - i if n > 0 and n <= i: continue N = n ans.append(i) if n == 0: break print(*ans, sep='\n')" p03633,s970872217,Accepted,"from fractions import gcd n = int(input()) times = [int(input()) for _ in range(n)] if n == 1: print(times[0]) else: prev_lcm = times[0] for t in times[1:]: tmp = gcd(prev_lcm, t) lcm = prev_lcm * (t // tmp) prev_lcm = lcm print(lcm) " p03359,s797874209,Accepted,"a,b = map(int, input().split()) print(a) if b >= a else print(a-1)" p03524,s842745984,Wrong Answer,"s = input() d = {} st = set() for c in s: if(c not in d): d[c] = 0 else: d[c] += 1 st.add(c) if(len(st) == 1): if(len(s) == 1): print(""YES"") else: print(""NO"") elif(len(st) == 2): if(d[list(st)[0]] == d[list(st)[1]]): print(""YES"") else: print(""NO"") else: mx = 0 no = False for k in d: mx = max(mx, d[k]) if(d[k]+1 < mx): flg = True if(no): print(""NO"") else: print(""YES"")" p02598,s103947560,Accepted,"n, k, *aa = map(int, open(0).read().split()) imp = 0 psbl = 10**9 while psbl - imp > 1: mid = (psbl + imp) // 2 cost = sum(0--a//mid - 1 for a in aa) if cost <= k: psbl = mid else: imp = mid print(psbl)" p03011,s783451456,Wrong Answer,"p,q,r=map(int, input().split()) print(min(p+q,p+r,q,r))" p03161,s951328871,Accepted,"def main(): n,k = map(int, input().split()) h = list(map(int, input().split())) dp = [0] * n def cost(i,j): return abs(h[i]-h[j]) for i in range(1,n): if i <= k: dp[i] = cost(0,i) else: dp[i] = min([dp[i-j] + cost(i,i-j) for j in range(1,k+1)]) print(dp[n-1]) if __name__ == '__main__': main()" p04005,s939362595,Accepted,"import math A, B, C = map(int,input().split()) ans = float(""inf"") S = A * B * C ans = min(ans,abs((A // 2 * B * C ) - (math.ceil(A / 2) * B * C))) ans = min(ans,abs((B // 2 * C * A ) - (math.ceil(B / 2) * C * A))) ans = min(ans,abs((C // 2 * A * B ) - (math.ceil(C / 2) * A * B))) print(ans)" p03106,s997188173,Accepted,"import sys def solve(): input = sys.stdin.readline A, B, K = map(int, input().split()) count = 1 for i in reversed(range(1, 101)): if A % i == 0 and B % i == 0: if count == K: print(i) break else: count += 1 return 0 if __name__ == ""__main__"": solve()" p03681,s663248770,Accepted,"import math n,m = map(int,input().split()) if abs(n-m) >= 2: print(0) elif abs(n-m) == 1: print((math.factorial(n)*math.factorial(m))%(10**9+7)) else: print((2*(math.factorial(n)*math.factorial(m)))%(10**9+7))" p03211,s029051693,Accepted,"s = input() ans = 999 for i in range(len(s)-2): lun = int(s[i] + s[i+1] + s[i+2]) ans = min(abs(753-lun), ans) print(ans)" p03860,s389284936,Accepted,"s = input().split() print('A'+s[1][0]+'C') " p02861,s114777535,Wrong Answer,"# ABC145C import itertools, math n = int(input()) city_list = [list(map(int, input().split())) for _ in range(n)] length = 0 sum_ = 0 for num, val in enumerate(itertools.permutations(city_list, n)): for i in range(len(val) - 1): length = math.sqrt((val[i][0] - val[i + 1][0]) ** 2 + (val[i][1] - val[i + 1][1]) ** 2) length += length sum_ += length length = 0 ans = sum_ / (num + 1) print(ans)" p03698,s818652689,Accepted,"S=input() if len(S)==len(set(S)): print(""yes"") else: print(""no"") " p02916,s354315266,Accepted,"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 > 0) and (a[i-1]+1 == a[i]): ans += c[a[i-1]-1] print(ans) " p03767,s723657026,Accepted,"N=int(input()) a=list(map(int,input().split())) t=int(len(a)-(len(a)/3)) a.sort(reverse=True) a_cutlist=a[:t+1] a_cutlist_ans=a_cutlist[1::2] print(sum(a_cutlist_ans))" p03087,s382032951,Accepted,"N, Q = map(int, input().split()) S = input() AC = [0] * (N) for i in range(1, N): if S[i] == ""C"" and S[i - 1] == ""A"": AC[i] = AC[i - 1] + 1 else: AC[i] = AC[i-1] for _ in range(Q): l,r = map(int,input().split()) l-=1 r-=1 print(AC[r]-AC[l])" p02694,s614583038,Accepted,"# -*- coding: utf-8 -*- def input_one_number(): return int(input()) def input_multiple_number(): return map(int, input().split()) def input_multiple_number_as_list(): return list(map(int, input().split())) X = input_one_number() m = 100 cnt = 0 while True: if X <= m: print(cnt) exit(0) m = (m * 1.01)//1 cnt +=1 " p02600,s399201078,Accepted,"N = int(input()) print(10 - N//200)" p02707,s073635223,Accepted,"# coding: utf-8 N = int(input()) A = list(map(int, input().split())) C = [0 for i in range(N)] A.sort() i = 0 while i < N - 1: C[A[i] - 1] = C[A[i] - 1] + 1 i += 1 for i in C: print(i)" p03105,s943733740,Accepted,"a,b,c=map(int,input().split()) print(min(b//a,c))" p02995,s589806716,Accepted,"import fractions def count(n, m, l): c_m = n // m c_l = n // l c_ml = n // (m * l // fractions.gcd(m, l)) return n - (c_m + c_l - c_ml) a, b, c, d = map(int, input().split()) b_tar = count(b, c, d) a_tar = count(a, c, d) is_plus_a = not(bool(a % c == 0 or a % d == 0)) ans = b_tar - a_tar if is_plus_a: ans += 1 print(ans)" p02866,s220103430,Wrong Answer,"n = int(input()) d = list(map(int,input().split())) MOD = 998244353 if d[0] != 0: print(0) exit() else: cnt = [0]*n for i in range(1, n): cnt[d[i]] += 1 ans = 1 for i in range(2, n): ans *= pow(cnt[i-1], cnt[i], MOD) % MOD print(ans) " p02971,s988260964,Accepted,"n=int(input()) a=[int(input()) for i in range(n)] max1=1 m=0 for i in range(n): if max121: print('bust') else: print('Win')" p02953,s267180394,Accepted,"N = int(input()) H = list(map(int, input().split())) ans = ""Yes"" H[0] = H[0] - 1 base = 0 for i in range(1, N): if H[i] > H[i-1] : H[i] = H[i] -1 elif H[i] < H[i-1] : ans = ""No"" print(ans)" p03163,s538795244,Wrong Answer,"N,W=map(int,input().split()) v=[0]*N w=[0]*N for i in range(N): v[i],w[i]=map(int,input().split()) dp=[[0]*(W+1) for _ in range(N)] for i in range(N): for j in range(1,W+1): if w[i]>j: dp[i][j]=dp[i-1][j] else: dp[i][j]=max(dp[i-1][j],v[i]+dp[i-1][j-w[i]]) print(dp[N-1][W])" p03693,s247644431,Wrong Answer,"A,B,C = list(map(int,input().split())) if 10*B + C % 4 == 0: print(""YES"") else: print(""NO"") " p02594,s229570718,Accepted,"x = int(input()) if x >= 30: print(""Yes"") else: print(""No"")" p03351,s224889371,Accepted,"a, b, c, d = map(int, input().split()) print(""YNeos""[(abs(a-b)>d or abs(b-c)>d) and abs(a-c)>d::2])" p03773,s952033583,Accepted,"a, b = map(int, input().split()) print(a + b) if a + b < 24 else print(a + b - 24) " p02791,s711789556,Wrong Answer,"n = int(input()) l = list(map(int, input().split())) ll = [] ll.append(l[0]) for i in range(len(l)-1): if ll[i] > l[i+1]: ll.append(l[i+1]) else: ll.append(l[i]) count = 0 for i in range(len(ll)): if l[i] <= ll[i]: count+=1 print(count) " p03962,s742030690,Wrong Answer,"a, b ,c = map(int, input().split()) count = 0 if a!=b: count+=1 if b!=c: count+=1 if a!=c: count+=1 print(count) " p03711,s868178480,Accepted,"g = [0,1,2,1,3,1,3,1,1,3,1,3,1] x,y = map(int,input().split()) print('Yes' if g[x]==g[y] else 'No')" p02606,s808486419,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)" p03633,s540621122,Accepted,"from fractions import gcd n = int(input()) t = list(int(input()) for _ in range(n)) def lcm(a, b): return a * b // gcd(a, b) ans = 1 for i in t: ans = lcm(ans, i) print(ans)" p02939,s999338560,Accepted,"def main(): S=input() ans=0 Si='' tmp='' for s in S: tmp += s if Si != tmp: ans += 1 Si = tmp tmp = '' print(ans) main() " p02972,s437542249,Accepted,"n=int(input()) a=[0]+list(map(int,input().split())) b=[0]*(n+1) for i in reversed(range(1,n+1)): if sum(b[i::i])%2!=a[i]: b[i]=1 print(sum(b)) for i,j in enumerate(b): if j==1: print(i,end="" "") " p03371,s522412556,Wrong Answer,"A, B, C, X, Y = map(int, input().split()) sum = 0 min_num = 10**10 num = [0]*3 if min(A/2, B/2) > C: print(C*Y*2) exit() for c in range(min(X, Y)+1): sum += C*c*2 num[0] = c*2 for a in range(X-c): sum += A num[1] = a for b in range(Y-c): sum += B num[2] = b if min_num > sum: min_num = sum print(sum, num) sum = 0 print(min_num)" p02780,s415073450,Accepted,"n, k = map(int, input().split()) p = list(map(int, input().split())) ansl = 0 ansr = k-1 ans = 0 tmp = sum(p[:k]) # print(tmp) for i in range(1,n - k+1): tmp = tmp - p[i-1] + p[i + k-1] # print(i,i+k-1,tmp) if tmp > ans: ansl = i ansr = i + k - 1 ans = tmp # print(ansl, ansr) ans2 = 0 for i in range(ansl, ansr + 1): ans2 += (p[i] + 1) / 2 print(ans2) " p02695,s815333696,Accepted,"from itertools import combinations_with_replacement n, m, q = map(int, input().split()) qx = [list(map(int, input().split())) for i in range(q)] ans = 0 for i in combinations_with_replacement(range(1, m + 1), n): s = 0 for a, b, c, d in qx: s += d if (i[b-1] - i[a-1] == c) else 0 ans = max(ans, s) print(ans) " p03329,s339112266,Accepted,"#!/usr/bin/env python3 from itertools import product, permutations, combinations N=int(input()) dp = [N for i in range(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])" p04033,s915230642,Accepted,"import bisect,collections,copy,heapq,itertools,math,numpy,string import sys def S(): return sys.stdin.readline().rstrip() 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() #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')" p02814,s614699682,Accepted,"N,M=map(int,input().split()) a=list(map(int,input().split())) import fractions from functools import reduce def lcm_base(x, y): return (x * y) // fractions.gcd(x, y) def lcm_list(numbers): return reduce(lcm_base, numbers, 1) l=lcm_list(a) for s,t in enumerate(a): if (l//t)%2==0: print(""0"") exit() print((2*M//l+1)//2) " p03329,s818069424,Accepted,"n = int(input()) ans = 0 ary = [] i = 1 ary.append(1) while 9**i < n+1: ary.append(9**i) i += 1 i = 1 while 6**i < n+1: ary.append(6**i) i += 1 ary.sort() dp = [100002] * (n+1) dp[0] = 0 for i in range(1,n+1): tmp = dp[i] + 1 for j, aa in enumerate(ary): if i >= aa: tmp = min(tmp, dp[i-aa] + 1) else: break dp[i] = tmp print(dp[n]) " p03487,s791746196,Accepted,"import sys from collections import Counter input = sys.stdin.readline def main(): N = int(input()) a = list(map(int, input().split())) c = Counter(a) ans = 0 for k, v in c.items(): if k < v: ans += (v - k) elif v < k: ans += v print(ans) if __name__ == ""__main__"": main() " p03486,s373445549,Accepted,"n, m = [sorted(list(input())) for i in range(2)] print(""Yes"" if n < m[::-1] else ""No"")" p03077,s613384350,Accepted,"from math import ceil n, a, b, c, d, e = [int(input()) for i in range(6)] print(ceil(n / min([a, b, c, d, e])) + 4)" p02677,s400620515,Accepted,"import math A,B,H,M = map(int,input().split()) t1 = (30*H+M/2)*math.pi/180 x1 = A*math.cos(t1) y1 = A*math.sin(t1) t2 = M*math.pi/30 x2 = B*math.cos(t2) y2 = B*math.sin(t2) d = ((x1-x2)**2+(y1-y2)**2)**0.5 print(d)" p03419,s758305609,Wrong Answer,"import math import collections import fractions import itertools def solve(): n, m = map(int, input().split()) if n == m == 1: print(1) elif n == 1: print(m-2) elif m == 1: print(n-1) elif n == 2 or m == 2: print(0) else: print((n-2)*(m-2)) return 0 if __name__ == ""__main__"": solve()" p03998,s946845274,Wrong Answer,"first = input() second = input() third = input() d = {} d[""a""]=first d[""b""]=second d[""c""]=third flag = False run = ""a"" while flag != True: if d[run] == """": flag = True print(run) else: l = len(d[run]) temp = d[run][0] d[run] = d[run][1:l] run = temp" p02702,s355122447,Accepted,"s = input() t = len(s) x = [] y = 0 while 10 ** y % 2019 not in x: x.append(10 ** y % 2019) y += 1 z = len(x) m = [0 for i in range(2019)] m[0] = 1 a = 0 for i in reversed(range(0, t)): a += x[(t-i-1) % z] * (int(s[i]) % 2019) a = a % 2019 m[a] += 1 def triangle(n): if n > 1: return n * (n-1) // 2 else: return 0 p = list(map(triangle, m)) # print(p) print(sum(p)) " p03329,s006371439,Accepted,"n = int(input()) MAXN = 110000 f_inf = float('inf') dp = [f_inf] * (MAXN+n) dp[0] = 0 for i in range(1, n+2): for j in range(7): dp[i] = min(dp[i], dp[i-pow(6, j)]+1) for k in range(6): dp[i] = min(dp[i], dp[i-pow(9, k)]+1) print(dp[n])" p02785,s557266451,Accepted,"def main(): N,K = (int(x) for x in input().split()) h = list(map(int, input().strip().split())) H = sorted(h, reverse=True) del H[:K] print(sum(H)) if __name__ == '__main__': main()" p02631,s943090975,Accepted,"n=int(input()) a=list(map(int,input().split())) tmp=a[0] for i in range(1,n): tmp=tmp^a[i] for i in range(n): print(tmp^a[i],end=' ') " p03161,s028336507,Wrong Answer,"import sys read = lambda: sys.stdin.readline().rstrip() def main(): INF = 10 ** 20 n,k = map(int,input().split()) height = tuple(map(int,read().split())) dp = [INF]*(n+1) dp[0] = 0 for step in range(1, k + 1): for target in range(n-1, 0, -1): if target-step >= 0: dp[target] = min(dp[target], dp[target - step] + abs(height[target] - height[target - step])) print(dp[n-1]) if __name__ == ""__main__"": main()" p03035,s252272989,Accepted,"a, b = map(int, input().split()) if a >= 13: print(b) elif 6 <= a <= 12: print(b // 2) else: print(0)" p03804,s293211558,Accepted,"def judge(A,B,n,m): C = [] for i in range(n-m+1): for j in range(n-m+1): C = [A[i+k][j:m+j] for k in range(m)] if B == C: return True return False def main(): N,M = map(int,input().split()) A = [input() for _ in range(N)] B = [input() for _ in range(M)] if judge(A,B,N,M): print(""Yes"") else: print(""No"") if __name__ == ""__main__"": main() " p02922,s562547452,Wrong Answer,"a, b = map(int, input().split()) n = a ans = 1 while n < b: n += a - 1 ans += 1 print(ans)" p03592,s836318655,Accepted,"n,m,k = map(int, input().split()) ans = ""No"" for i in range(n+1): for j in range(m+1): l = i*(m-j) + (n-i)*j if k==l: ans =""Yes"" else: continue print(ans)" p03821,s499759128,Wrong Answer,"N =int(input()) AB = [list(map(int,input().split())) for _ in range(N)] ans = 0 for i in range(N): if AB[-1][0]%AB[-1][1]==0: push = 0 else: push = (AB[-1][1] - (AB[-1][0]%AB[-1][1])) ans += push for j in range(len(AB)): AB[j][0] += push print(i,ans,push,AB) AB.pop() print(ans)" p03385,s273578323,Accepted," S = input() if set(S) == set(""abc""): print(""Yes"") else: print(""No"")" p04005,s510183790,Accepted,"ABC = list(map(int, input().split())) ABC.sort() for i in ABC: if i % 2 == 0: print(0) break else: print(ABC[0] * ABC[1]) " p02924,s040807698,Accepted,"n = int(input()) print((n*(n-1))//2) " p02912,s180910284,Accepted,"from heapq import heapify, heappop, heappush import math n, m = map(int, input().split()) a = list(map(int, input().split())) for i in range(n): a[i] *= -1 heapify(a) #print(a) for i in range(m): maxa = heappop(a) heappush(a, math.ceil(maxa/2)) #print(a) print(-(sum(a)))" p02833,s477204232,Accepted,"N = int(input()) if N%2!=0: print(0) else: cnt = 0 n = N//2 k = 5 while(n//k != 0): cnt += n//k k*=5 print(cnt)" p03493,s963250217,Accepted,print(input().count('1')) p02577,s992066193,Accepted,"N = int(input()) sumN = sum(int(digit) for digit in str(N)) if sumN%9 == 0: print(""Yes"") else: print(""No"") " p03623,s910499805,Accepted,"x, a, b = map(int, input().split()) if abs(x - a) > abs(x - b): print(""B"") else: print(""A"") " p04045,s852422102,Accepted,"import sys, math def input(): return sys.stdin.readline()[:-1] def main(): N, K = map(int,input().split()) D = set(input().split()) for ans in range(N,1000000): f = 0 for e in str(ans): if e in D: f = 1 break if f == 0: print(ans) exit(0) if __name__ == '__main__': main() " p02553,s210978963,Accepted,"def main(): a,b,c,d = map(int, input().split()) print(max([a*c, a*d, b*c, b*d])) if __name__ == '__main__': main() " p02663,s007425110,Accepted,"h1,m1,h2,m2,k=map(int,input().split()) print(60*(h2-h1)+m2-m1-k)" p03760,s224934916,Accepted,"O=input("""") E=input("""") s=[] lo=len(O) le=len(E) if(lo'1') print(a[p^1][::-1]+s[:-1][::p or-1]+a[p])" p02866,s055133669,Accepted,"MOD = 998244353 N = int(input()) D = list(map(int, input().split())) if D[0] != 0: print(0) exit() D_2 = [0]*(max(D)+1) for i in D: D_2[i] += 1 if D_2[0] != 1: print(0) exit() ans = 1 for i in range(1,max(D)+1): ans *= D_2[i-1]**D_2[i] ans %= MOD print(ans) " p03433,s668508503,Wrong Answer,"n = int(input()) a = int(input()) j = n % 500 if (j <= a): print(""YES"") else: print(""NO"") " p02994,s287927096,Accepted,"#b n,l=map(int, input().split()) result = 0 if l > 0: for i in range(n-1): result += i+l+1 elif l + n > 0: for i in range(n): result += i+l else: for i in range(n-1): result += i+l print(result)" p03767,s363541893,Wrong Answer,"n = int(input()) a = list(map(int,input().split())) a = sorted(a) ans = 0 for i in range(1,n+1): ans += a[i*2] print(ans) " p03624,s277048124,Accepted,"s = input() alphabets = 'abcdefghijklmnopqrstuvwxyz' for i in range(len(alphabets)): if not alphabets[i] in s: print(alphabets[i]) exit() print('None')" p03407,s880481911,Accepted,"A,B,C = map(int,input().split()) if A + B >= C: print('Yes') else: print('No')" p02789,s066859578,Accepted,"inpl = lambda: list(map(int,input().split())) N, M = inpl() if N==M: print('Yes') else: print('No')" p03695,s202323715,Accepted,"import math l = input().split() N = int(l[0]) l = input().split() A = [0] * 13 for i in l: index = int(i) // 400 if index < 8: A[index] = 1 else: A[index] += 1 x = sum(A[:8]) y = sum(A[8:]) print(max(1, x), x + y)" p03264,s805724708,Wrong Answer,"k = int(input()) if k%2==0: print((k//2)*2) else: print(((k+1)//2)*((k-1)//2))" p02548,s830718401,Accepted,"import math N=int(input()) ans=0 for i in range(1,N): ans+=(N-1)//i print(ans) " p03103,s912876494,Accepted,"#C - Energy Drink Collector N,M = map(int,input().split()) A_B = [tuple(map(int,input().split())) for _ in range(N)] A_B = sorted(A_B, key = lambda x:x[1],reverse = True) A_B = sorted(A_B, key = lambda x:x[0], reverse = False) pay = 0 drink = M for A, B in A_B: if drink <= B: pay += A*drink break else: pay += A*B drink -= B print(pay)" p02696,s464199411,Accepted,"import math a, b, n = map(int, input().split()) if (b == n): x = n-1 elif (b < n): x = b-1 elif (b > n): x = n print(math.floor((a * x) / b) - (a * math.floor(x / b))) " p03637,s676021772,Accepted,"n = int(input()) a = list(map(int, input().split())) odd_cnt = 0 multi_4 = 0 for i in range(n): if a[i] % 4 == 0: multi_4 += 1 elif a[i] % 2 == 1: odd_cnt += 1 if multi_4 + odd_cnt == n: print(""Yes"" if multi_4 >= odd_cnt - 1 else ""No"") else: print(""Yes"" if multi_4 >= odd_cnt else ""No"")" p04043,s288845861,Accepted,"a = input() A = int(a[0]) B = int(a[2]) C = int(a[4]) if(A==5 and B==7 and C==5): print('YES') elif(A==7 and B==5 and C==5): print('YES') elif(A==5 and B==5 and C==7): print('YES') else: print('NO') " p04044,s223421086,Accepted,"lst = [] n, l = map(int, input().split()) for _ in range(n): lst.append(input()) res = """" for i in range(n): res += min(lst) lst.remove(min(lst)) print(res)" p03150,s652812622,Accepted,"s = input() flag = False n = len(s) for i in range(n): for j in range(i,n): if 'keyence' == s[:i] +s[j:]: flag = True if flag: print('YES') else: print('NO')" p03386,s663144179,Wrong Answer,"def actual(A, B, K): nums = [str(x) for x in range(A, B + 1)] satisfied_nums = sorted(set(nums[:K] + nums[-K:])) return '\n'.join(satisfied_nums) A, B, K = map(int, input().split()) print(actual(A, B, K))" p02697,s334256430,Accepted,"n, m = map(int, input().split()) for i in range(1, m+1): a, b = i, n-i+1 if not n % 2 and b-a <= n//2: print(a, b-1) else: print(a, b) " p03274,s751339352,Wrong Answer,"N, K = map(int, input().split()) xs = list(map(int, input().split())) xs.append(xs[-1]) ruiseki = [] prev = xs[0] for i in range(N-K+1): ruiseki.append(abs(min(xs[i:i+K]) - max(xs[i:i+K])) + abs(min(xs[i:i+K]))) print(min(ruiseki)) " p02787,s287041635,Accepted,"h, n = map(int,input().split()) ab = [list(map(int,input().split())) for _ in range(n)] dp = [10**10] * (h+1) dp[0] = 0 for i in range(1,h+1): for j in range(n): if(i >= ab[j][0]): dp[i] = min(dp[i], dp[ i - ab[j][0]]+ ab[j][1]) else: dp[i] = min(dp[i], dp[0] + ab[j][1]) print(dp[h])" p03673,s767910656,Wrong Answer,"#https://atcoder.jp/contests/abc066/tasks/arc077_a N = int(input()) N_List = list(map(str,input().split())) if N % 2 == 0: ans = ''.join(reversed(N_List[1::2])) + ''.join(N_List[::2]) else: ans = ''.join(reversed(N_List[::2])) + ''.join(N_List[1::2]) print(ans)" p03107,s320692185,Accepted,"s = input() li = [] for i in s: if i==""1"": li.append(1) ans = 2*min(len(li), len(s)-len(li)) print(ans)" p03437,s858625617,Accepted,"x,y=map(int,input().split()) i=x l=False if x==y or x%y==0: print(-1) else: while 1<=i and i<=x*y: if i%x==0 and i%y!=0: print(i) l=True break else: i+=x" p03862,s846317520,Accepted,"n, x = map(int, input().split()) A = list(map(int, input().split())) ans = 0 for i in range(0, n-1): if A[i] + A[i+1] > x: diff = A[i] + A[i+1] - x ans += diff A[i+1] = max(0, A[i+1]-diff) print(ans) " p02777,s065531779,Accepted,"s, t = input().split() a, b = map(int, input().split()) u = input() if u == s: a -= 1 if u == t: b -= 1 print('%d %d' % (a, b)) " p03699,s723166197,Accepted,"N = int(input()) li = [] for _ in range(N): li.append(int(input())) li.sort() if sum(li) % 10 != 0: print(sum(li)) else: for i in range(N): if li[i] % 10 != 0: print(sum(li) - li[i]) exit() print(0) " p02996,s792013266,Accepted,"import sys n = int(input()) ab = [list(map(int, i.split())) for i in sys.stdin.readlines()] ab.sort(key=lambda x:x[1]) ans = 0 for a, b in ab: ans += a if ans > b: print(""No"") exit() print(""Yes"")" p03338,s629036673,Accepted,"n = int(input()) s = input() result = [] for i in range(1, n): a = set(list(s[:i])) b = set(list(s[i:])) result.append(len(a & b)) print(max(result))" p02578,s754117466,Accepted,"n = int(input()) a = list(map(int, input().split())) b = [0] * n b[0] = 0 for i in range(1, n): if a[i-1] + b[i-1] > a[i]: b[i] = a[i-1] + b[i-1] - a[i] else: b[i] = 0 c = 0 for i in range(1, n): c = c + b[i] print(c) " p02753,s011065124,Accepted,"s = str(input()) if s == 'AAA': print('No') if s == 'BBB': print('No') if s != 'AAA' and s != 'BBB': print('Yes')" p02546,s898034870,Accepted,"s = input() if s[-1] == 's': s = s + 'es' else: s = s + 's' print(s)" p02811,s365763091,Accepted,"# -*- coding: utf-8 -*- """""" Created on Fri Jan 10 21:06:29 2020 @author: over- """""" K,X=map(int,input().split()) if 500*K >= X: print('Yes') else: print('No') " p02718,s438695753,Accepted,"N, M = map(int, input().split()) A = list(map(int, input().split())) t = 0 S = 0 for Ai in A: S=S+Ai for Ai in A: if Ai >= S/(4*M): t = t+1 if t >= M: print('Yes') else: print('No') " p02989,s968186160,Accepted,"N = int(input()) D = list(map(int, input().split())) D.sort() print(D[N//2] - D[N//2-1])" p02768,s259671981,Wrong Answer,"mod=10**9+7 l,a,b=map(int,input().split()) def C(n,k,m): for i in range(1,k): n*=(n-i)%m k*=(k-i)%m return n*pow(k,m-2,m) ans=pow(2,l,mod) ca=C(l,a,mod) print(ca) cb=C(l,b,mod) print(cb) print((ans-ca-cb)%mod)" p03475,s367309025,Wrong Answer,"N = int(input()) csf = [list(map(int, input().split())) for i in range(N - 1)] for i in range(N): ans = 0 for j in range(i, N - 1): c, s, f = csf[j] if ans <= s: ans += s - ans + c else: while ans < s: s += f ans += c print(ans)" p03145,s060263321,Accepted,"triangulo = input() lados = triangulo.split() AB = lados[0] BC = lados[1] area = (int(AB) * int(BC))/2 print(""%.0f"" % area)" p02860,s414125861,Wrong Answer,"N = int(input()) S = input() if N % 2 == 0: if S[:N//2] == S[N//2:]: print('Yes') else: print('No') " p02596,s203820195,Wrong Answer,"def main(): k = int(input()) a = [0] * (10 ** 6 + 1) a[0] = 7 % k for i in range(1, k + 1): a[i] = (a[i - 1] * 10 + 7) % k if a[i] == 0: print(i + 1) exit() print(-1) if __name__ == '__main__': main()" p03836,s045370590,Accepted,"sx, sy, tx, ty = map(int, input().split()) ans = """" ans += ""U""*(ty - sy) ans += ""R""*(tx - sx) ans += ""D""*(ty - sy) ans += ""L""*(tx - sx + 1) ans += ""U""*(ty - sy + 1) ans += ""R""*(tx - sx + 1) ans += ""DR"" ans += ""D""*(ty - sy + 1) ans += ""L""*(tx - sx + 1) ans += ""U"" print(ans)" p03352,s457604563,Accepted,"x = int(input()) ans = 1 for b in range(1,32): for p in range(2,10): c = b**p if x >= c > ans: ans = c print(ans) " p02958,s026076724,Accepted,"N = int(input()) p = list(map(int, input().split())) P = sorted(p) count = 0 for i in range(N): if p[i] != P[i]: count += 1 if count == 0 or count == 2: print('YES') else: print('NO') " p03252,s609603844,Accepted,"from collections import Counter def check(): S = sorted(Counter(input()).values()) T = sorted(Counter(input()).values()) for s,t in zip(S,T): if s !=t: return 'No' return 'Yes' print(check())" p02963,s621375144,Accepted,"def f(x1, y1, x2, y2): return abs(x1*y2 - x2*y1) def main(): S = int(input()) d = pow(10, 9) X1, Y1 = 0, 0 X2, Y2 = d, 1 X3 = (d - S%d)%d Y3 = (S + X3) // d print(X1, Y1, X2, Y2, X3, Y3) #print(f(X2, Y2, X3, Y3)) if __name__ == ""__main__"": main() " p02701,s417482527,Wrong Answer,"N = int(input()) S = {} ans = N for i in range(N): s = input() if s not in S: S[i] = s print(len(S)) " p02982,s365141379,Accepted,"import math n, d = map(int, input().split()) x = [] cnt = 0 for i in range(n): l = list(map(int, input().split())) x.append(l) for i in range(n-1): for j in range(i+1, n): di = 0 for k in range(d): di += (x[i][k] - x[j][k]) ** 2 if math.sqrt(di).is_integer(): cnt += 1 print(cnt) " p02854,s868078745,Wrong Answer,"n = int(input()) a = list(map(int,input().split())) l = sum(a) halfp = 0 for i in range(n): if sum(a[:i+1])>= l/2: halfp = i break print(int((sum(a[:halfp+1])-l/2)*2))" p04045,s708877089,Accepted,"def getDigits(n): digits = [] while n > 0: digits.append(n % 10) n //= 10 return digits def firstValidNumber(n, digits): while True: isValid = True currentDigits = getDigits(n) for digit in currentDigits: if digit in digits: isValid = False break if isValid: return n n += 1 return n n, k = map(int, input().split()) digits = list(map(int, input().split())) print(firstValidNumber(n, digits))" p02836,s307121223,Accepted,"s=input() ans=0 for i in range(len(s)//2): if s[i]!=s[-(i+1)]: ans+=1 print(ans)" p03339,s586694105,Accepted,"from sys import stdin input = stdin.readline def main(): N = int(input()) A = input()[:-1] E = [0] for a in A: if a == 'E': E.append(E[-1]+1) else: E.append(E[-1]) min_ = float('inf') for i in range(N): min_ = min(min_, (i-E[i])+(E[N]-E[i+1])) print(min_) if(__name__ == '__main__'): main()" p02554,s804345310,Wrong Answer,"n=int(input()) print((10**n-9**n*2+8**n)%10**9+7)" p03827,s000224334,Accepted,"N=int(input()) S=input() x=0 ans=0 for i in range(N): if S[i]=='I': x+=1 ans=max(ans,x) else: x -= 1 print(ans)" p03861,s157031824,Accepted,"a, b, x = map(int, input().split()) print(b // x - (a - 1) // x)" p04019,s207347150,Wrong Answer,"s = input() t = 0 u = 0 if ""N"" in s and ""S"" in s: t = 1 if ""E"" in s and ""W"" in s: u = 1 if u == t == 1: print(""Yes"") else: print(""No"")" p03145,s131412577,Accepted,"import sys from collections import Counter from collections import deque def input(): return sys.stdin.readline().strip() def mp(): return map(int,input().split()) def lmp(): return list(map(int,input().split())) a,b,c=mp() print((a*b)//2)" p04044,s725424579,Wrong Answer,"#!/usr/bin/env python3 def main(): *N, = map(str, open(0).read().split()) S = N[2:] L = int(N[1]) N = int(N[0]) for i in range(0, L): S = sorted(S, key=lambda x: x[i]) print(''.join(S)) main()" p03592,s715192003,Accepted,"n,m,k = [int(x) for x in input().split()] ans = ""No"" for i in range(n+1): for j in range(m+1): if i * (m-j) + j * (n-i) == k: ans = ""Yes"" break print(ans)" p03001,s950171375,Accepted,"w, h, x, y = map(int, input().split()) if x == w / 2 and y == h / 2: print(w * h / 2, 1) else: print(w * h / 2, 0)" p03416,s019816863,Accepted,"a, b = map(int, input().split()) print(len([i for i in map(str, range(a, b+1)) if i == i[::-1]])) " p02933,s049201290,Accepted,"a = int(input()) s = input() if a >= 3200: print(s) else: print('red')" p02973,s891759443,Accepted,"import bisect n = int(input()) ans = [-1*int(input())] for i in range(n-1): a=int(input()) a=-1*a if ans[-1]<=a: ans.append(a) else: b = bisect.bisect_right(ans,a) ans[b]=a print(len(ans))" p03254,s329732332,Wrong Answer,"n,x=map(int,input().split()) a=list(map(int,input().split())) ans=0 for i in range(n-1): x=x-a[i] if x<0: x=x+a[i] else: ans+=1 a.sort(reverse=True,key=int) ansr=0 for i in range(n-1): x=x-a[i] if x<0: x=x+a[i] else: ansr+=1 print(max(ans,ansr)) " p03208,s118417512,Accepted,"N, K = map(int, input().split()) h = [int(input()) for i in range(N)] H = sorted(h) # print(H) minH = 10 ** 9 for x in range(N - K + 1): sumh = H[x + K - 1] - H[x] # print(""sumh"", sumh) if minH > sumh: minH = sumh print(minH) " p03067,s452794711,Wrong Answer,"s = list(map(int, input().split())) ss = sorted(s) ssr = sorted(s, reverse=True) if s==ss or s==ssr: print(""No"") else: print(""Yes"") " p03220,s836361032,Accepted,"N = int(input()) T, A = input().split(' ') T = int(T) A = int(A) H = input().split(' ') H = [int(H[i]) for i in range(N)] check = 10**9 for i in range(N): C = A - (T - H[i] * 0.006) if abs(C)w/2 : print('safe') else: print('unsafe')" p03037,s845784219,Accepted,"n, m = map(int, input().split()) a = [0]*(n+1) for i in range(m): l, r = map(int, input().split()) a[l-1] += 1 a[r] -= 1 for i in range(n): a[i+1] += a[i] print(a.count(m))" p03250,s400130097,Accepted,print(eval('+'.join(sorted(input()))+'*10')) p02831,s190144919,Accepted,"import math a,b = map(int,input().split()) print(a*b//math.gcd(a,b))" p02779,s109680125,Accepted,"#整数値入力 1文字の入力 def input_one_number(): return int(input()) #整数値龍力 複数の入力(配列) def input_multiple_number_as_list(): return list(map(int, input().split())) n = input_one_number() asnyan = input_multiple_number_as_list() asnyan.sort() b = 0 flg = True for a in asnyan: if b == a: flg = False b = a if flg: print(""YES"") else: print(""NO"") " p02988,s687880151,Accepted,"n = int(input()) ps = list(map(int, input().split())) ans = 0 for i in range(1,n-1): if sorted(ps[i-1:i+2]).index(ps[i]) == 1: ans += 1 print(ans)" p03524,s610804802,Accepted,"from collections import Counter S = input() C = Counter(S) if len(C) == 3: c = min(C.values()) else: c = 0 for cc in C.values(): if not (cc == c or cc == c + 1): print(""NO"") exit() print(""YES"") " p02658,s211693522,Accepted,"n = int(input()) num = [int(i) for i in input().split()] cont=0 ans=1 for j in num: if j == 0: cont+=1 if cont > 0: print(0) else: for i in num: ans=ans*i if ans>1e18: ans=-1 break print(ans) " p03612,s380332100,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 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 N = i() p = l() count = 0 i = 0 while i < N: if p[i] == i+1: count += 1 i += 1 i += 1 print(count) " p02689,s195774509,Wrong Answer,"n,m = map(int,input().split()) h = input().split("" "") hlist = [int(n) for n in h] alist = [int(n) for n in h] for i in range(m): b = input().split("" "") blist = [int(n) for n in b] if hlist[blist[0]-1]>hlist[blist[1]-1] and hlist[blist[1]-1] in alist: alist.remove(hlist[blist[1]-1]) if hlist[blist[1]-1]>hlist[blist[0]-1] and hlist[blist[0]-1] in alist: alist.remove(hlist[blist[0]-1]) kotae = len(alist) print(kotae)" p02603,s243209612,Accepted,"n = int(input()) a = list(map(int,input().split())) ans = 0 yen = 1000;kabu = 0 for i in range(n-1): if a[i] < a[i+1]: kabu += yen // a[i] yen %= a[i] else: yen += a[i]*kabu kabu = 0 yen += a[-1]*kabu print(yen)" p02948,s742062453,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]) print(h) heapq.heapify(h) ans=0 for i in range(m): ans+=-heapq.heappop(h) print(ans)" p03243,s969408215,Wrong Answer,"N = input() h = int(N[0]) t = int(N[1]) o = int(N[2]) if h == t and t == o: print(N) else: h += 1 print(h*111)" p03479,s876814453,Wrong Answer,"x,y=map(int,input().split()) n=y//x ct=0 while n>1: ct+=1 n//=2 print(ct)" p03241,s622514274,Accepted,"n, m = map(int, input().split()) def calc_divisors(n): res = [] i = 1 while i * i <= n: if n % i == 0: res.append(i) res.append(n // i) i += 1 res = list(set(res)) return res divisors = calc_divisors(m) divisors.sort(reverse=True) for divisor in divisors: if m >= n * divisor: print(divisor) break" p02759,s403561107,Accepted,"N=int(input()) print((N+1)//2)" p02832,s155122688,Accepted,"N = int(input()) a = list(map(int, input().split())) cnt = 0 if not 1 in a: print(-1) else: tmp = 1 for i in range(N): if a[i] == tmp: tmp += 1 else: cnt += 1 print(cnt) " p03797,s325593528,Accepted,"s, c = map(int,input().split()) cnt = 0 if 2*s <= c: cnt += s c -= 2*s else: cnt += c // 2 c = 0 cnt += c//4 print(cnt)" p03617,s828012708,Accepted,"import decimal 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(decimal.Decimal(n)*decimal.Decimal(min(l))) if n%2==0 or p==q else int(decimal.Decimal(n-1)*decimal.Decimal(d/2)+q))" p02756,s481766365,Accepted,"s=input() q=int(input()) f=0 l,r='','' for i in range(q): a=list(input().split()) if a[0]=='1': f+=1 else: if (int(a[1])-1)^(f%2)==0: l+=a[2] else: r+=a[2] if f%2==1: print(r[::-1]+s[::-1]+l) else: print(l[::-1]+s+r)" p03387,s413501879,Accepted,"def resolve(): a = list(map(int, input().split())) a = sorted(a) x = a[0] y = a[1] z = a[2] ans = z-y if (z-(ans+x)) % 2 == 0: ans += (z-(ans+x)) // 2 print(ans) else: ans += (z - (ans + x)) // 2 print(ans+2) resolve()" p02642,s730041293,Wrong Answer,"from collections import Counter n = int(input()) A = sorted(map(int, input().split())) c = Counter(A) flag = [False] * n for i in range(n): if c[A[i]] > 1: flag[i] = True if flag[i] == False: for j in range(i+1, n): if A[j] % A[i] == 0: flag[j] = True print(flag.count(False)) " p02642,s375852032,Accepted,"N = int(input()) A = list(map(int,input().split())) U = [0]*(10**6+1) for e in A: U[e] += 1 ans = 0 for k in range(1,10**6+1): if U[k] == 1: ans += 1 if U[k] > 0: for l in range(2*k,10**6+1,k): if U[l] > 0: U[l] += 1 print(ans) " p03612,s285087548,Accepted,"n = int(input()) p = list(map(int, input().split())) cnt = 0 for i in range(n-1): if p[i] == i+1: p[i], p[i+1] = p[i+1], p[i] cnt += 1 if p[n-1] == n: p[n-2], p[n-1] = p[n-1], p[n-2] cnt += 1 print(cnt) " p03075,s559298704,Wrong Answer,"a = int(input()) for i in range(4): e = int(input()) k = int(input()) if e - a <= 15: print('Yay!') else: print(':(')" p02948,s348159696,Accepted,"import heapq n,m = map(int,input().split()) al = [[] for i in range(10**5)] ans = 0 h = [] for i in range(n): a,b = map(int,input().split()) al[a-1] += [-b] for i in range(m): for j in al[i]: heapq.heappush(h,j) if h: ans -= heapq.heappop(h) print(ans)" p02661,s671871310,Accepted,"import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) n = int(readline()) aa = [] bb = [] for _ in range(n): a, b = map(int, readline().split()) aa.append(a) bb.append(b) aa.sort() bb.sort() if n % 2 == 1: print(bb[n // 2] - aa[n // 2] + 1) else: print(bb[n // 2] + bb[n // 2 - 1] - aa[n // 2] - aa[n // 2 - 1] + 1) " p04020,s661098258,Accepted,"n = int(input()) a = [int(input()) for _ in range(n)] a.append(0) ans = 0 for i in range(n): p,r = divmod(a[i],2) ans += p if a[i+1]: a[i+1] += r print(ans)" p03075,s035719393,Accepted,"p = [int(input()) for i in range(5)] k = int(input()) if p[4]-p[0]<=k: print('Yay!') else: print(':(') " p03331,s450687285,Accepted,"n = int(input()) c = [] for i in range(1, n//2 +1): a = sum(map(int, str(i))) b = sum(map(int, str(n-i))) c.append(a+b) print(min(c))" p03012,s881514283,Accepted,"n = int(input()) w = list(map(int, input().split())) ans = [] for i in range(n+1): s1 = sum(w[:i]) s2 = sum(w[i:]) ans.append(abs(s1 - s2)) print(min(ans))" p03408,s986683172,Accepted,"from collections import Counter N=int(input()) S=Counter([input() for i in range(N)]) M=int(input()) T=Counter([input() for i in range(M)]) ans=0 for key in S.keys(): ans = max(S.get(key)-T.get(key,0),ans) print(ans)" p02629,s473865529,Wrong Answer,"n = int(input()) num2alpha = lambda c: chr(c+64) ans = [] while True: if n == 0: break i = n%26 n = int(n/26) ans.append(num2alpha(i)) ans.reverse() print("""".join(ans).lower())" p02922,s671256092,Accepted,"A,B=map(int, input().split()) N=0 while(1+(A-1)*N= n: break print(ans) " p02882,s414841958,Accepted,"import math a, b, x = map(int, input().split()) if 2 * x <= (a ** 2) * b: print(math.degrees(math.atan((a * (b ** 2)) / (2 * x)))) else: print(math.degrees(math.atan((2 / a) * (b - (x / a ** 2))))) " p03339,s506651326,Accepted,"n=int(input()) s=input() ans=s[1:].count('E') pin=ans for i in range(1,n): if s[i-1]=='W': pin+=1 if s[i]=='E': pin-=1 ans=min(ans,pin) print(ans)" p02899,s626378067,Wrong Answer,"n=int(input()) a=list(map(int,input().split())) b=a k=1 for i,j in enumerate(a,1): b[j-1]=i print(*b) " p03557,s165305259,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() count = 0 for b in B: c_num = len(C)-bisect.bisect_left(C,b+1) a_num = bisect.bisect_right(A,b-1) count+=c_num*a_num print(count) " p02600,s492780721,Accepted,"X = int(input()) ans = 10 - X // 200 print(ans)" p03760,s322761805,Accepted,"o = input() e = input() k = [] for i in range(len(e)): k.append(o[i]) k.append(e[i]) if len(o) > len(e): k.append(o[-1]) print(''.join(k))" p03035,s898725955,Wrong Answer,"a, b = map(int, input().split()) if a >= 13: print(b) elif 6 <= a <= 12: print(b/2) else: print(0)" p04029,s623079333,Accepted,"n = int(input()) print(int(0.5*n*(n+1)))" p03030,s155342317,Accepted,"n = int(input()) sp = [] for i in range(n): city, point = input().split() sp.append([city, int(point), int(i+1)]) sp.sort(key=lambda x: x[1], reverse=True) sp.sort(key=lambda x: x[0]) for i in sp: print(i[2]) " p03557,s684156626,Accepted,"N=int(input()) A=list(map(int,input().split())) B=list(map(int,input().split())) B.sort() C=list(map(int,input().split())) C.sort() from bisect import bisect_right ret=0 Cb=[0]*(N+1) for i in range(N): Cb[i]=N-bisect_right(C,B[i]) for i in range(N-1,-1,-1): Cb[i]+=Cb[i+1] for a in A: bi=bisect_right(B,a) ret+=Cb[bi] print(ret)" p03106,s265339073,Accepted,"import math A, B, K = map(int, input().split()) def divisors(n): ret = set() for i in range(1, math.ceil(n**0.5) + 1): if n % i == 0: ret.add(i) ret.add(n//i) return ret a = sorted(list(divisors(A) & divisors(B))) print(a[-K]) " p03672,s729118371,Accepted,"s = input() n = len(s) for i in range(2,n,2): if s[0:(n-i)//2] == s[(n-i)//2:n-i]: print(len(s[0:n-i])) break" p03041,s236317345,Wrong Answer,"def str_replace_to_lower() -> str: len_str, target_index = map(int, input().split()) word = input() new = word.replace(word[target_index - 1], word[target_index - 1].lower(), 1) return new print(str_replace_to_lower()) " p03696,s066994338,Wrong Answer,"N=int(input()) S=input() cntl=0 cntr=0 flag=0 for s in S: if cntr == 0 and cntl == 0: flag = 0 if s=="")"" and cntr==0: cntl += 1 elif s=="")"" and cntr>0 and flag: cntr -= 1 if cntl > 0: cntl-= 1 elif s==""("": cntr += 1 if flag == 0: flag = 1 elif s==""("" and cntl>0 and flag: cntl -= 1 if cntr > 0: cntr -= 1 print(cntl, cntr) print(""(""*cntl + S + "")""*cntr) " p02818,s556359208,Accepted,"A,B,K=list(map(int,input().split())) if A>K: print(A-K,B) elif A+B>K: print(0,A+B-K) else: print(0,0) " p02681,s057824426,Accepted,"s=input() t=input() if s==t[:-1]: print(""Yes"") else: print(""No"")" p03705,s004708847,Accepted,"import math import sys n, a, b = map(int, sys.stdin.readline().rstrip().split()) if (n - 1) * b + a - (n - 1) * a - b + 1 < 0: print(0) else: print((n - 1) * b + a - (n - 1) * a - b + 1)" p02708,s758165710,Wrong Answer,"N, K = map(int, input().split()) ans = 0 for i in range(K, N+2): ans += int(K * (N-K+1) + 1) print(ans)" p02971,s858135911,Accepted,"N=int(input()) num1=0 am=0 a2=0 for x in range(N): a=int(input()) if am A[i-1]: A[i] -= 1 elif A[i] == A[i-1]: continue else: ans = ""No"" print(ans)" p02608,s803599676,Accepted,"N = int(input()) ans = [0] * (N + 1) for i in range(1, 100): for j in range(1, 100): for k in range(1, 100): a = i**2 + j**2 + k**2 + i*j + j*k + k*i if a <= N: ans[a]+=1 for i in range(1, N+1): print(ans[i])" p03352,s787787236,Wrong Answer,"x = int(input()) res = 1 for b in range(2, int(pow(1000, 1/2))+1): flag = True p = 2 while b**p <= x and flag: p += 1 flag = False if not flag: res = max(res, b**(p-1)) print(res)" p03252,s562219542,Accepted,"dic = {} dic1 = {} s=input() t=input() ans = ""Yes"" for i in range(len(s)): try: if dic[s[i]]!=t[i]: ans = ""No"" except: dic[s[i]] = t[i] try: if dic1[t[i]]!=s[i]: ans = ""No"" except: dic1[t[i]] = s[i] print(ans)" p03680,s710674139,Accepted,"n=int(input()) a=[] for i in range(n): a.append(int(input())) now=0 c=0 while True: if now==1: print(c) break if c>=n: print(-1) break c+=1 now=a[now]-1" p03136,s434338826,Accepted,"#import sys #import math #import numpy as np '''a,b= map(int,input().split())''' #a, b, c = [list(map(int, input().split())) for _ in range(3)] #li0= [int(x) for x in input().split()] #n,l= map(int, input().split()) #x = [list(map(int, input().split())) for _ in range(n)] a=int(input()) li=[int(x) for x in input().split()] ans=ju=0 for i in range(a): ju=max(ju,li[i]) ans=sum(li)-ju if ans-ju>0: print('Yes') else: print('No') " p03785,s361165043,Accepted,"N,C,K = map(int,input().split()) T = [int(input()) for i in range(N)] T.sort() ans = 1 bus = [T[0]] l = 1 for i in range(1,N): if T[i]-bus[0] <= K and l <= C-1: l += 1 else: bus = [T[i]] l = 1 ans += 1 print(ans) " p03644,s490512604,Accepted,"n = int(input()) ans = 1 cnt = 0 for i in range(1, n + 1): count = 0 temp = i while temp % 2 == 0: count += 1 temp //= 2 if cnt < count: cnt = count ans = i print(ans) " p03105,s473804010,Accepted,"a, b, c = map(int, input().split()) x = b//a if x > c: x = c print(x)" p02730,s914873230,Accepted,"import sys def input(): return sys.stdin.readline()[:-1] s = input() n = len(s) if s[:(n-1)//2] == s[(n+3)//2-1:]: print('Yes') else: print('No')" p02711,s718802575,Wrong Answer,"n = input() if n in ""7"": print(""Yes"") elif n not in ""7"": print(""No"")" p02953,s209083673,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())) m = 0 for i in range(n): if a[i] 0: n -= k if n > 0: n += 1 cnt += 1 print(cnt)" p02862,s165280193,Accepted,"x,y = list(map(int, input().split())) if (x+y) % 3 != 0: print(0) exit() a = (2*x - y) // 3 b = (2*y - x) // 3 if a < 0 or b < 0: # (x,y) = (1,5)とかは無理 print(0) exit() MOD = 10**9+7 def fact(x): f = 1 for i in range(2, x+1): f *= i f %= MOD return f def fact_inv(x): return pow(fact(x), MOD-2, MOD) ans = fact(a+b) * fact_inv(a) * fact_inv(b) % MOD print(ans)" p03437,s198266900,Accepted,"x,y=map(int,input().split()) if x%y==0: print(-1) else: print(x)" p02963,s498963605,Wrong Answer,"S = int(input()) a = 2*S // 1000000000 for i in range(a + 1, 1000000000): if S%i == 0: print(0,0,0,i,S//i,0) break" p03289,s795993365,Accepted,"s = input() a = -1 c = -1 lower = 0 for i in range(len(s)): if s[i] == 'A': a = i if s[i] == 'C': c = i if 'a' <= s[i] <= 'z': lower += 1 if a == 0 and 2 <= c <= len(s) - 2 and lower == len(s) - 2: print('AC') else: print('WA') " p02813,s993618348,Accepted,"import itertools import bisect n = int(input()) p = tuple(map(int, input().split())) q = tuple(map(int, input().split())) *per, = itertools.permutations(range(1, n+1)) a = bisect.bisect_right(per, p) b = bisect.bisect_right(per, q) print(abs(a-b)) " p03696,s260425172,Wrong Answer,"import sys from collections import defaultdict def input(): return sys.stdin.readline().strip() def main(): N = int(input()) S = input() height = 0 deepest = 0 for c in S: if c == '(': height += 1 else: height -= 1 deepest = min(deepest, height) print(deepest, height) ans = '(' * (-deepest) + S + ')' * (height - deepest) print(ans) if __name__ == ""__main__"": main() " p03705,s578915759,Accepted,"import sys input = sys.stdin.buffer.readline def main(): N,A,B = map(int,input().split()) if A == B: print(1) elif A > B: print(0) else: if N == 1: print(0) elif N == 2: print(1) else: print(((N-1)*B+A)-((N-1)*A+B)+1) if __name__ == ""__main__"": main() " p02947,s579945089,Accepted,"n = int(input()) d = {} for _ in range(n): string = """".join(sorted(list(input()))) if string not in d: d[string] = 1 else: d[string] += 1 ans = 0 for v in d.values(): ans += v*(v-1)//2 print(ans) " p02987,s443010303,Accepted,"s=input() if s[0]==s[1] and s[2]==s[3] and s[0]!=s[2]: print(""Yes"") elif s[0]==s[2] and s[1]==s[3] and s[0]!=s[1]: print(""Yes"") elif s[0]==s[3] and s[1]==s[2] and s[0]!=s[1]: print(""Yes"") else: print(""No"") " p02963,s605443901,Accepted,"S = int(input()) x = (-S)%(10**9) y = (S+x)//(10**9) print(0,0,10**9,1,x,y)" p03137,s175904266,Wrong Answer,"n, m = map(int, input().split()) x = list(map(int, input().split())) x.sort() between = [x[i] - x[i-1] - 2 for i in range(1,m)] between.sort(reverse=True) print(max(0, x[-1] - x[0] - sum(between[:n-1]) - n))" p02731,s632283849,Accepted,"if __name__ == ""__main__"": l = int(input()) l1 = l / 3 print(l1 ** 3) " p03997,s216078392,Accepted,"a = int(input()) b = int(input()) h = int(input()) s = 0 if 1 <= a <= 100 and 1 <= b <= 100 and 1 <= h <= 100 and h % 2 == 0: s = (a + b) * h / 2 print(int(s))" p03836,s501297907,Accepted,"sx, sy, tx, ty = map(int, input().split()) tx = tx - sx ty = ty - sy ans = """" ans += ""U"" * ty ans += ""R"" * tx ans += ""D"" * ty ans += ""L"" * tx ans += ""L"" ans += ""U"" * (ty + 1) ans += ""R"" * (tx + 1) ans += ""D"" ans += ""R"" ans += ""D"" * (ty + 1) ans += ""L"" * (tx + 1) ans += ""U"" print(ans) " p03061,s186843201,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)" p03241,s541951234,Accepted,"import bisect 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()) lst = make_divisors(M) print(lst[bisect.bisect_right(lst, M//N)-1])" p03286,s872723883,Accepted,"n=int(input()) if n==0: print(0) exit() ans="""" while n: if n%2: ans+=str(1) n-=1 else: ans+=""0"" n//=-2 print(ans[::-1])" p03730,s226951914,Accepted,"A, B, C = list(map(int, input().split())) clear = 0 for i in range(1, B): if (A * i) % B == C: clear = 1 break if clear == 0: print('NO') else: print('YES') " p02747,s887674801,Accepted,"S = input() D = 0 if len(S)%2 != 0: print(""No"") D = 1 else: for i in range(len(S)//2): if ((S[i * 2] == ""h"") & (S[(i * 2) + 1] == ""i"")) != True: print(""No"") D = 1 break if D == 0: print(""Yes"") " p03293,s715341042,Wrong Answer,"s = list(input()) t = list(input()) for i in s: if i in t: t.remove(i) if not t: print(""Yes"") else: print(""No"")" p04034,s136534641,Accepted,"n, m = map(int, input().split()) s = [0] * n s[0] = 1 b = [1] * n for i in range(m): x, y = map(int, input().split()) if s[x-1]: s[y-1] = 1 if b[x-1] == 1: s[x-1] = 0 b[x-1] -= 1 b[y-1] += 1 ans = 0 for i in range(n): if s[i] and b[i]: ans += 1 print(ans) " p02677,s777970355,Accepted,"import sys import math readline = sys.stdin.buffer.readline def even(n): return 1 if n%2==0 else 0 a,b,h,m = map(int,readline().split()) degree = abs(h*30+30*(m/60) - m*6) degree = min(degree,360-degree) print(math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(degree))))" p02933,s893317454,Wrong Answer,"a=int(input()) b=input() if a>=3200: print(b) else: print('RED')" p03359,s421269065,Accepted,"a, b = map(int, input().split()) if b >= a: print(a) elif a > b: print(a-1) else: print(b)" p02595,s064167606,Accepted,"N,D=map(int,input().split()) XY= [input().split() for _ in range(N)] ans=0 for i in XY: A=(int(i[0])**2+int(i[1])**2)**(1/2) if A<=D: ans+=1 print(ans)" p03797,s822793864,Accepted,"n, m = list(map(int, input().split())) if 2 * n >= m: print(m // 2) else: print(n + (m-(2*n))//4)" p03323,s000411937,Accepted,"a,b = map(int,input().split()) print('Yay!' if a <= 8 and b <= 8 else ':(') " p02922,s337304135,Accepted,"a, b = (int(i)for i in input().split()) ans =0 d = 1 while d abs(x - b): print(""B"") else: print(""A"")" p03331,s849817651,Accepted,"N = int(input()) cmin = 1000 for i in range(1,N): a = str(i) cnt = 0 for j in range(len(a)): cnt += int(a[j]) b = str(N-i) for j in range(len(b)): cnt += int(b[j]) cmin = min(cmin,cnt) print(cmin)" p02646,s738770670,Accepted,"a, v = map(int,input().split()) b, w = map(int,input().split()) t = int(input()) if abs(a-b) <= (v-w)*t : print(""YES"") else: print(""NO"")" p03323,s893392959,Wrong Answer,"a, b = map(int, input().split()) print('Yay!') if(a < 9 or b < 9) else print(':(') " p02820,s789716552,Accepted,"n, k = map(int, input().split()) r, s, p = map(int, input().split()) t = input() scores = {'r':p, 's':r, 'p':s} ans = 0 for i in range(k): ans += scores[t[i]] flg = False for j in range(i+k, n, k): if (not flg) and t[j]==t[j-k]: flg = True continue flg = False ans += scores[t[j]] print(ans)" p03951,s241825670,Accepted,"n = int(input()) s = input() t = input() if s == t: print(n) exit() ans = '' for i in range(n): ss = s[n-i-1:] tt = t[:i+1] if ss == tt: ans = s[:n-i-1]+ss+t[i+1:] if len(ans) == 0: print(len(s+t)) else: print(len(ans)) " p02664,s571460628,Wrong Answer,"t = input() stack = '' ans = '' for i in range(len(t)): word = t[i] if word == '?': if len(stack) <= 0: word = 'P' elif stack[-1] == 'P': word = 'D' elif stack[-1] == 'D' and i < len(t)-1 and t[i+1] == 'P': word = 'D' else: word = 'D' stack += word if 'PD' in stack or 'DD' in stack: ans += stack stack = '' ans += stack print(ans) " p04031,s078156875,Accepted,"n = int(input()) a = list(map(int, input().split())) a_min = min(a) a_max = max(a) a_sum = [] for i in range(a_min, a_max + 1): num=0 for j in range(n): num += (a[j] - i) ** 2 a_sum.append(num) print(min(a_sum))" p03495,s316721770,Accepted,"n,k=map(int,input().split()) A=list(map(int,input().split())) ans = [0]*(n) for a in A: ans[a-1] += 1 ans.sort(reverse=True) print(sum(ans[k:]))" p03779,s763082425,Accepted,"X = int(input()) l = -1 r = 10**10 while r - l > 1: m = l + (r-l)//2 if m*(m+1)//2 > X: r = m else: l = m # print(l, m, r) print(l if l*(l+1)//2 == X else r) " p02971,s196744985,Accepted,"from copy import deepcopy def main(): n = int(input()) a = [int(input()) for _ in range(n)] b = deepcopy(a) b.sort() for aa in a: if aa == b[-1]: print(b[-2]) else: print(b[-1]) if __name__ == '__main__': main() " p02708,s197688163,Accepted,"N,K = map(int,input().split()) mod = 10**9+7 ans = 0 for i in range(K,N+2): min = (0+i-1)*i//2 max = (N+N-i+1)*i//2 ans += (max-min+1)%mod print(ans%mod)" p03632,s637639113,Wrong Answer,"A,B,C,D=map(int,input().split()) p=min(C,D)-max(A,B) if p<=0: print(0) else: print(p)" p02576,s648569560,Wrong Answer,"n, x, t = map(int, input().split()) a = n/x if n % x == 0: print(a*t) else: print((int(a) + 1)*t) " p02705,s981946536,Accepted,"from math import pi R = int(input()) print(R * 2 * pi) " p03486,s350221529,Wrong Answer,"a=input() b=input() la,lb = len(a), len(b) if a==b: print('No') elif (la< lb and set(a)==set(b)): print('Yes') else: if (sorted(a[:lb], reverse = True) < sorted(b, reverse = True)): print('Yes') else: print('No')" p03659,s962148408,Accepted,"# coding: utf-8 N=int(input()) A=list(map(int,input().split())) sA=[A[0]] siA=[A[-1]] for i in range(N-1): sA.append(sA[i]+A[i+1]) siA.append(siA[i]+A[-(i+2)]) ans=10**15 for i in range(N-1): ans=min(ans,abs(sA[i]-siA[-(i+2)])) # print(sA,siA) print(ans) " p02953,s797863887,Accepted,"import math import os import random import re import sys def check_non_decreasing_squares(n: int, a: list): for i in range(1, n): if a[i] != a[i - 1]: if a[i] - 1 < a[i - 1]: print(""No"") sys.exit(0) a[i] -= 1 print(""Yes"") if __name__ == '__main__': n = int(input()) a = list(map(int, input().rstrip().split())) check_non_decreasing_squares(n, a)" p02835,s343536842,Accepted,"a,b,c=map(int,input().split()) print(""win"" if a+b+c<=21 else ""bust"")" p02780,s467032034,Accepted,"n,k=map(int,input().split()) p=list(map(int,input().split())) p=[(i+1)/2 for i in p] ans=0 cur_sum=0 for i in range(0,k): cur_sum+=p[i] ans=cur_sum for i in range(k,n): cur_sum+=p[i] cur_sum-=p[i-k] ans=max(ans,cur_sum) print(ans) " p02723,s644238736,Accepted,"s = input() if s[2] == s[3] and s[4] == s[5]: print(""Yes"") else: print(""No"") " p03479,s137991473,Accepted,"x, y = map(int, input().split()) ans = 0 while True: if x > y: break ans += 1 x *= 2 print(ans)" p02621,s705525763,Accepted,"a = int(input()) ans = a + a**2 + a**3 print(ans)" p02911,s058203610,Accepted,"n,k,q = map(int,input().split()) ans = [0]*n for i in range(q): ans[int(input())-1] += 1 for i in range(n): dum = q - ans[i] if k-dum >0: print(""Yes"") else: print(""No"")" p02862,s404597687,Accepted,"x, y = map(int, input().split()) diff = abs(x - y) ref = (min(x, y) - diff)//3 total = ref*2 + diff mod = 10**9 + 7 ans = 1 if (x + y)%3 != 0 or ref < 0: print(0) exit() 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)" p03524,s341891493,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) or len(S) == 1: print('YES') else: print('NO')" p03105,s597337814,Accepted,"A, B, C = map(int, input().split()) print(min(B//A, C))" p03037,s368494862,Wrong Answer,"N, M = map(int, input().split()) id_range = range(N + 1) for m in range(M): L, R = map(int, input().split()) if (L not in id_range) and (R not in id_range): id_range = range(0) break if L in id_range: id_range = range(L, id_range[len(id_range) - 1] + 1, 1) if R in id_range: id_range = range(id_range[0], R + 1, 1) id_set = set(id_range) print(len(set(range(1, N + 1, 1)) & id_set))" p02793,s207447165,Accepted,"n = int(input()) a = [int(i) for i in input().split()] def gcd(x, y): if y == 0: return x else: return gcd(y, x % y) def lcm(x, y): return (x * y) // gcd(x, y) l = a[0] for i in a[1:]: l = lcm(l, i) b = [] for i in a: b.append(l//i) ans = sum(b) % (10 ** 9 + 7) print(ans)" p02553,s469039348,Wrong Answer,"[a, b, c, d] = [int(inp) for inp in input().split()] print(max([a * c, b * d]))" p02571,s392715857,Wrong Answer,"S = list(input()) T = list(input()) lt = len(T) result = 10**5 for i in range(len(S) - len(T) + 1): cnt = 0 for s, t in zip(S[i: (i + lt)], T): if s != t: cnt += 1 result = max(cnt, result) print(result)" p03997,s711087832,Accepted,"a = int(input()) b = int(input()) h = int(input()) S = (a+b)*h/2 print(round(S))" p03329,s286051516,Accepted,"n = int(input()) INF = float(""inf"") dp = [INF]*100010 dp[0] = 0 pow6 = [6**i for i in range(1,7)] pow9 = [9**i for i in range(1,6)] for i in range(1,n+1): dp[i] = dp[i-1] + 1 for p6 in pow6: dp[i] = min(dp[i],dp[i-p6]+1) for p9 in pow9: dp[i] = min(dp[i],dp[i-p9]+1) print(dp[n])" p03672,s165333400,Accepted,"data = input() for _ in range(len(data)): data = data[:-1] count = len(data) if data[:count//2] == data[count//2:]: print(count) break" p03481,s320637136,Accepted,"import sys import math import itertools #n=int(input()) x,y = map(int, input().split()) ans = 0 while (x <= y): x *= 2 ans += 1 print(ans)" p03062,s409379732,Accepted,"n=int(input()) a= list(map(int,input().split())) plus = [] minas = [] for value in a: if value < 0: minas.append(abs(value)) else: plus.append(value) if len(minas)%2 == 0: ans = sum(plus)+sum(minas) else: if len(plus) > 0: mini = min(min(plus),min(minas)) ans = sum(plus)+sum(minas)-mini*2 else: mini = min(minas) ans = sum(minas)-mini*2 print(ans)" p02829,s998126825,Accepted,"ans = [1, 2, 3] tmp = [] for i in range(2): tmp.append(int(input())) for j in ans: if j not in tmp: print(j)" p03150,s620148225,Accepted,"s=input() if len(s)==7: if s==""keyence"": print(""YES"") else: print(""NO"") else: if s[:7]==""keyence"": print(""YES"") elif s[-7:]==""keyence"": print(""YES"") else: for i in range(7-1): if s[:i+1]+s[-(7-i-1):]==""keyence"": print(""YES"") exit() print(""NO"")" p02556,s490713909,Accepted,"# -*- coding: utf-8 -*- N = int(input()) pos_x_list = [] pos_y_list = [] for i in range(N): x, y = map(int, input().split()) pos_x_list.append(x - y) pos_y_list.append(x + y) print(max(max(pos_x_list) - min(pos_x_list), max(pos_y_list) - min(pos_y_list)))" p03971,s145652968,Accepted,"N,A,B=map(int,input().split()) S=list(input()) p=0 q=0 for i in S: if p A * C: print(A * C) elif A * C > B and B > A: print(A) else: print(0)" p03657,s790035901,Accepted,"a,b=map(int,input().split()) print(""Possible"" if (a%3==0) or (b%3==0) or((a+b)%3==0) else ""Impossible"")" p03962,s000387588,Accepted,"a, b, c = map(int, input().split()) color = set() color.add(a) color.add(b) color.add(c) print(len(color)) " p02743,s457675990,Wrong Answer,"s=input() L=s.split("" "") a=int(L[0]) b=int(L[1]) c=int(L[2]) if 0<(c**2-c*a-c*b+a**2-c*a-b*c+b**2-2*a*b): print(""Yes"") else: print(""No"") " p03611,s682979305,Wrong Answer,"n=int(input()) a=list(map(int,input().split())) num=[0]*(max(a)+1) for i in a: num[i]+=1 #print(num) mx=0 for i in range(1,max(a)): #print(num[i-1:i+2]) m=sum(num[i-1:i+2]) if m>mx: mx=m print(mx)" p02598,s046457369,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) def cut(x): cut_count = 0 for i in range(n): cut_count += (a[i]-1)//x return cut_count l = 0 r = 10**9 while r-l > 1: mid = (l+r)//2 if k >= cut(mid): r = mid else: l = mid print(r) " p03069,s142652743,Accepted,"N = int(input()) S = input() l_blacks = 0 r_whites = 0 for c in S: if c == '.': r_whites += 1 mins = r_whites for c in S: if c == '.': r_whites -= 1 if c == '#': l_blacks += 1 mins = min(mins, r_whites + l_blacks) print(mins)" p02708,s135167411,Accepted,"N, K = map(int,input().split()) mod = pow(10, 9) + 7 total = 0 for i in range(K, N + 2): maximum = (N - i + 1 + N) * i / 2 minimum = (i - 1) * i / 2 count = maximum - minimum + 1 total += (count % mod) print(int(total % mod))" p02717,s594375541,Accepted,"x, y, z = map(int, input().split()) print(z,x,y)" p03681,s576911786,Wrong Answer,"p = 10**9+7 N,M = map(int,input().split()) a = 1 for i in range(2,N+1): a = (a*i)%p b = 1 for i in range(2,M+1): b = (b*i)%p if M==N: n = (2*a*b)%p else: n = (a*b)%p print(n)" p03695,s547570868,Accepted,"n = int(input()) col = [399, 799, 1199, 1599, 1999, 2399, 2799, 3199] a = list(map(int,input().split())) col_set = set() cnt = 0 for i in range(n): if a[i] >= 3200: cnt += 1 for j in range(len(col)): if a[i] <= col[j]: col_set.add(j) break print(max(len(col_set), 1), len(col_set)+cnt) " p03673,s009250977,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.append(a[i]) else: b.appendleft(a[i]) if n % 2 == 1: b.reverse() print("" "".join(map(str, b))) " p03548,s993163367,Wrong Answer,"def isu(x , y , z): ans = x // (y + z) return ans if x % (y + z) != 0 else ans - 1 def main(): x , y , z = map(int , input().split()) print(isu(x , y , z)) if __name__ == '__main__': main()" p03680,s361698378,Accepted,"N = int(input()) a = [int(input()) for _ in range(N)] ans = 1 count = 0 for _ in range(N): ans = a[ans-1] count += 1 if ans == 2: print(count) break else: print(-1) " p02811,s638626801,Accepted,"import sys def input(): return sys.stdin.readline()[:-1] k,x=map(int,input().split()) if 500*k>=x: print(""Yes"") else: print(""No"")" p03478,s957244314,Accepted," N, a, b = map(int, input().split()) total = 0 def FindSum(n): sum = 0 while n > 0: sum += n % 10 n = n //10 return sum for i in range(1, N + 1): sum = FindSum(i) if a <= sum <= b: total += i print(total)" p02787,s497647011,Wrong Answer,"import numpy as np h,n=map(int,input().split()) a=[] b=[] c=[] for i in range(n): A,B=map(int,input().split()) a.append(A) b.append(B) c.append(float(A/B)) idx=np.argmax(c) num=int(h/a[idx]) to=num*b[idx] z=h%a[idx] if z!=0: d=(-((-z)//(np.array(a)))) e=d*np.array(b) to+=b[np.argmin(e)] print(to) " p03455,s425417378,Wrong Answer,"a, b = map(int,input().split()) if a * b % 2 == 0: print(""even"") else: print(""odd"")" p02724,s978177659,Accepted," def read_int(): return int(input().strip()) def read_ints(): return list(map(int, input().strip().split(' '))) def solve(): X = read_int() return (X//500)*1000+((X%500)//5)*5 if __name__ == '__main__': print(solve()) " p03639,s773474192,Accepted,"N = int(input()) A = list(map(int, input().split())) odd = 0 even = 0 even4 = 0 for num in A: if num % 2 == 1: odd += 1 else: even += 1 if num % 2 == 0 and num % 4 != 0: even4 += 1 even4 = even - even4 if odd == 0 or odd <= even4 or (odd + even4 == N and odd == even4 + 1): print(""Yes"") else: print(""No"")" p04029,s728856517,Accepted,"N = int(input()) # 1個ずつ増えるキャンディー # 必要なキャンディーの個数の合計を出力する。 x = N * (N + 1) // 2 print(x)" p03779,s542332470,Accepted,"N=int(input()) for i in range(1,N//2+10): tmp=((i+1)*(i))//2 if N-tmp==0: print(i) exit() if N-tmp s * 2: print(-1) exit() s = min(s*2, sm) ans += s sm -= a[i] s -= a[i] print(ans)" p03145,s463704440,Accepted,"AB, BC, CA = map(int, input().split()) print(BC * AB // 2)" p02813,s427291929,Accepted,"import itertools n = int(input()) li1 = [] for i in range(n): li1.append(i+1) li2 = list(itertools.permutations(li1,n)) p = tuple(map(int,input().split())) q = tuple(map(int,input().split())) print(abs(li2.index(p)-li2.index(q)))" p03639,s125525576,Accepted,"import numpy as np N = int(input()) A = np.array(list(map(int, input().split()))) zero = sum(A % 2 != 0) # 2で割りきれない数 four = sum(A % 4 == 0) # 4で割りきれる数 two = sum(np.logical_and(A % 2 == 0, A % 4 != 0)) # 4で割り切れないが、2で割りきれる数 flag = False if two == 0: if zero <= four + 1: flag = True else: if zero <= four: flag = True if flag: print(""Yes"") else: print(""No"") " p02707,s525258246,Wrong Answer,"N = int(input()) values = list(map(int, input().split())) values_dict = {} for value in values: values_dict[value] = values_dict.get(value, 0) + 1 print(values_dict.get(i, 0) for i in range(1, N+1)) " p04045,s436558870,Accepted,"inf = 10**18 mod = 10**9+7 # a^n def power(a,n,mod): x = 1 while n: if n & 1: x *= a % mod n >>= 1 a *= a % mod return x % mod n,k = map(int, input().split()) d = list(input().split()) ans = n for i in range(n, n*10+1): tmp = str(i) ok = True for c in tmp: if c in d: ok = False break if ok: ans = i break print(ans)" p02779,s077486866,Wrong Answer,"N, A = int(input()), list(map(int, input().split())) print(""Yes"" if len(set(A)) == len(A) else ""No"")" p03814,s964646024,Wrong Answer,"s=input() ans=0 flag=False n=0 for i in range(len(s)): if s[i]==""A"": flag=True n+=1 continue if s[i]==""Z"": if flag: n+=1 ans=max(ans,n) n=0 flag=False continue if flag: n+=1 print(ans)" p02677,s289737246,Wrong Answer,"import math a,b,h,m=map(int,input().split()) ang=6*m-30*h if ang<0: ang*=-1 ang=ang*math.pi/180 r=math.sqrt(a*a+b*b+2*a*b*math.cos(ang)) print(r) " p02601,s580493484,Accepted,"A,B,C=(input().split()) K = int(input()) A = int(A) B = int(B) C = int(C) for i in range(K): if B > C or C == B: C = C*2 elif A > B or B == A: B = B*2 if A < B and B < C: print(""Yes"") else: print(""No"")" p03815,s205806055,Wrong Answer,"n=int(input()) x=n//11 y=n%11 if y<6: y=1 else: y=2 print(x*2+y)" p02899,s911687697,Accepted,"n = int(input()) a = list(map(int, input().split())) student_turn = [0] * (n + 1) for i in range(n): student_turn[a[i] - 1] = i + 1 student_turn.pop() print("" "".join(map(str,student_turn)))" p03720,s978887400,Wrong Answer,"n,m=map(int,input().split()) l=[] for i in range(m): a,b=map(int,input().split()) l.append(a) l.append(b) import collections c = collections.Counter(l) for i in c.values(): print(i) " p02923,s544166108,Accepted,"n=int(input()) h=list(map(int,input().split())) ans=0 stp=0 for i in range(1,n): if h[i]<=h[i-1]: stp+=1 ans=max(stp,ans) else: stp=0 print(ans)" p02548,s855491723,Accepted,"N = int(input()) result = 0 for A in range(1, N + 1): result += (N - 1) // A print(result) " p03241,s903208492,Wrong Answer,"N, M = map(int, input().split()) # Mの約数を列挙 sup = int(M**0.5) + 1 divs = [] for i in range(1, sup+1): if M%i == 0: divs.append(i) for d in divs[::-1]: if M//d >= N: print(d) quit()" p02888,s976169707,Accepted,"N = int(input()) L = list(map(int,input().split())) L.sort() ans = 0 import bisect for i in range(N-2): for j in range(i+1,N-1): a = L[i] b = L[j] k = bisect.bisect_left(L,a+b) l = bisect.bisect_left(L,b-a) ans += k-max(j+1,l) print(ans) " p03062,s431149598,Accepted,"N = int(input()) A = list(map(int, input().split())) total = 0 minus = 0 l = [] for i in range(N): total += abs(A[i]) l.append(abs(A[i])) if A[i] < 0: minus += 1 ans = total if minus % 2 == 1: ans = total - 2 * min(l) print(ans) " p03448,s189204567,Accepted,"A, B, C, X = [int(input()) for _ in range(4)] ans = 0 for a in range(A + 1): for b in range(B + 1): for c in range(C + 1): if X == 500 * a + 100 * b + 50 * c: ans += 1 else: print(ans)" p02627,s636684735,Wrong Answer,"a = input() al = list(""abcdefghijklmnopqrstuvwxyz"") AL = list(""ABCDEFGHIJKLMNOPQRSTUVWXYZ"") if a in al: print(str.upper(a)) else: print(str.lower(a)) " p02631,s104720469,Accepted,"n = int(input()) a = list(map(int, input().split())) b = a[:] dig_m = 30 cnt_dig = [1]*30 for i in range(dig_m): cnt = 0 for j in range(n): if b[j] % 2 == 0: cnt += 1 b[j] //= 2 if cnt % 2 == 0: cnt_dig[i] = 0 cnt_dig.reverse() cnt_dig = int(''.join(map(str, cnt_dig)), 2) for i in range(n): print(a[i] ^ cnt_dig, end=' ')" p03637,s275253825,Wrong Answer,"import math N = int(input()) A = list(map(int,input().split())) l = list() ll = list() lll = list() for i in range(len(A)): if A[i]%4 == 0: l.append(A[i]) if A[i]%2 == 0: ll.append(A[i]) if A[i]%2 != 0: lll.append(A[i]) four = len(l) two = len(ll)-four zero = N-two a = math.floor(N/2) b = A.count(0) if zero <= four and b == 0: print(""Yes"") elif zero-two <= four: print(""Yes"") else: print(""No"")" p02701,s089657572,Wrong Answer,"N=int(input()) dic={} for i in range(N): tmp=input() if tmp not in dic: dic[tmp]=1 else: dic[tmp]+=1 max=0 for i in dic: if dic[i]>max: max=dic[i] print(max)" p03041,s368373677,Accepted,"n, k = map(int, input().split()) s = [i for i in input()] ans = [] for i in range(0,len(s)): if i == k - 1: ans.append(s[i].lower()) else: ans.append(s[i]) print("""".join(ans))" p03067,s647367657,Accepted,"a,b,c = map(int,input().split()) if a 0: return False return True if __name__ == '__main__': main() " p03719,s215585914,Accepted,"# A - Between Two Integers # 整数A,B,Cが入力される # CがA以上かつB以下であるかを判定する A,B,C = map(int,input().split()) if A<=C and B>=C: print('Yes') else: print('No') " p03971,s412852385,Accepted,"N,A,B = map(int,input().split()) S = input() a_cnt = b_cnt = 0 for s in S: if s == ""c"": print(""No"") elif s == ""a"": if a_cnt+b_cnt < A+B: a_cnt += 1 print(""Yes"") else: print(""No"") else: if a_cnt+b_cnt < A+B and b_cnt+1 <= B: b_cnt += 1 print(""Yes"") else: print(""No"")" p03338,s983455316,Accepted,"n = int(input()) s = list(input()) ans = 0 for i in range(1, n-1): x = set(s[:i]) y = set(s[i:]) cnt = 0 for c in x: if c in y: cnt += 1 if cnt > ans: ans = cnt print(ans) " p03042,s662891201,Accepted,"S = input() left = int(S[:2]) right = int(S[2:]) if 0 < left <= 12: if 0 < right <= 12: print('AMBIGUOUS') else: print('MMYY') else: if 0 < right <= 12: print('YYMM') else: print('NA')" p02624,s934051733,Accepted,"N = int(input()) ans = 0 for i in range(1, N + 1): n = N // i temp = (n * (n + 1) * i) // 2 ans += temp print(ans) " p03419,s417554634,Wrong Answer,"import sys N, M = map(int, sys.stdin.readline().split()) if N > 1 and M > 1: four = 4 six = (N - 2) * 2 + (M - 2) * 2 nine = N * M - four - six print(nine) elif N == 2 or M == 2: print(0) else: two = 2 three = N * M - two print(three)" p03371,s282533534,Wrong Answer,"a, b, c, x, y = list(map(int, input().split())) ans = 10**5*max(a,b,c) for i in range(0, max(x,y)+1): s = a*max(0,x-i)+b*max(0,y-i)+c*2*i ans = min(ans, s) print(ans)" p03481,s443421231,Accepted,"X, Y = map(int, input().split()) for i in range(10**18): if X*2**i>Y: print(i) break" p03136,s726624115,Accepted,"import sys N = int(sys.stdin.readline().rstrip()) l = list(map(int, sys.stdin.readline().rstrip().split())) lm = 0 L = 0 for n in range(N): if l[n] > lm: L += lm lm = l[n] else: L += l[n] if lm < L: print('Yes') else: print('No')" p03208,s495976711,Accepted,"N,K=map(int,input().split()) h=[int(input()) for _ in range(N)] h.sort() ans=10**9 for i in range(N-K+1): ans=min(ans,h[i+K-1]-h[i]) print(ans)" p02618,s081908902,Accepted,"d=int(input()) #365 c=list(map(int,input().split())) s=[] for i in range(d): s.append(list(map(int,input().split()))) ll=[0 for i in range(26)] l=[] ans=[] for i in range(d): for j in range(26): ll[j]+=1 m=-(10**10) for j in range(26): t=s[i][j]+ll[j]*c[j] if m= x and a <= x: print(""YES"") else: print(""NO"") " p02598,s660462005,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) left = 0 right = 10**10 while right - left > 1: cut = 0 mid = left + (right - left) // 2 for a in A: cut += (a+mid-1)//mid - 1 if cut <= K: right = mid else: left = mid print(right) " p02631,s710940667,Accepted,"n = int(input()) a = list(map(int, input().split())) al = a[0] ans = [] for i in range(1, n): al ^= a[i] for i in range(n): ans.append(al^a[i]) print(*ans)" p02748,s493325748,Accepted,"A,B,M=map(int,input().split()) a=list(map(int,input().split())) b=list(map(int,input().split())) L=[list(map(int,input().split())) for i in range(M)] MA=min(a) MB=min(b) MC=MA+MB for i in range(M): if a[L[i][0]-1]+b[L[i][1]-1]-L[i][2]= m: print(cuc[0]); exit()" p03086,s652441896,Wrong Answer,"def abc122_b(): s = input() acgt = ['A', 'C', 'G', 'T'] check = [1 if s[i] in acgt else 0 for i in range(len(s))] result = 0 for i in range(len(check)): for j in range(len(check)): if check[i:j].count(0) == 0: if result < len(check[i:j]): result = len(check[i:j]) print(result) if __name__ == '__main__': abc122_b()" p02756,s564646954,Accepted,"s = list(str(input())) q = int(input()) f = [] b = [] cnt = 0 for i in range (q): t = list(str(input())) if t[0] == '2': if t[2] == '1': f.append(t[4]) else: b.append(t[4]) else: x = f y = b f = y b = x cnt += 1 f.reverse() if cnt%2 != 0: s.reverse() print(''.join(f) + ''.join(s) + ''.join(b))" p03109,s851220151,Accepted,"ss = input().split('/') yyyy = int(ss[0]) mm = int(ss[1]) dd = int(ss[2]) if mm >= 5: print('TBD') else: print('Heisei') " p02778,s158824326,Wrong Answer,"S = input() t = [""x"" for i in range(len(S))] print(*t)" p03043,s589356087,Accepted,"n,k=map(int,input().split()) ans=0 for i in range(1,n+1): temp=i count=0 while temp0: points.append(""Yes"") elif str(i) in dict and dict[str(i)]+k-q>0: points.append(""Yes"") else: points.append(""No"") for i in range(n): print(points[i])" p03474,s351532389,Accepted,"A, B = map(int, input().split()) S = input() parta = S[:A] partb = S[A+1:] if S[A] != '-': ans = ""No"" elif parta.isdecimal() and partb.isdecimal(): ans = ""Yes"" else: ans = ""No"" print(ans)" p03545,s176574899,Accepted,"S = input() l = len(S) ans = 0 for i in range(2**(l-1)): T = S[0] for j in range(l-1): if i>>j & 1: T = T + ""-"" else: T = T + ""+"" T = T+S[j+1] if eval(T) == 7: print(T+""=7"") exit()" p02676,s019331763,Wrong Answer,"a=input() a=int(a) b=input() c="""" if a>=len(b): print(b) else: for i in range(a): c=c+b[i] print(c)" p03478,s626195763,Accepted,"n, a, b = map(int,input().split(' ')) total = 0 for num in range(1,n+1): split_nums = [int(s) for s in list(str(num))] sum = 0 for s in split_nums: sum += s if a <= sum and sum <= b: total += num print(total)" p02900,s772899852,Wrong Answer,"from fractions import gcd import math def get_prime_numbers(n): prime_nums = {} for i in range(2, int(math.sqrt(n)) + 1): while n % i == 0: if i in prime_nums.keys(): prime_nums[i] += 1 else: prime_nums[i] = 1 n //= i if n != 1: if n in prime_nums.keys(): prime_nums[n] += 1 else: prime_nums[n] = 1 return prime_nums a, b = map(int, input().split()) gcd_n = gcd(a, b) prime_nums = get_prime_numbers(gcd_n) print(len(prime_nums.keys()))" p03285,s845239281,Accepted,"n = int(input()) ans = ""No"" for i in range(0, 101, 4): for j in range(0, 101, 7): if i+j == n: ans = ""Yes"" break print(ans)" p02881,s962935429,Accepted,"n = int(input()) x, y = 1, n for i in range(1, int(n**0.5)+1): if n%i==0: x = i y = n//x print(x+y-2)" p03013,s422324405,Wrong Answer,"def hoge(): dp = [0] * (n + 5) dp[0] = 0 dp[1] = 2 for i in range(2, n): if step_list[i - 1] == True: dp[i] = dp[i - 2] + dp[i - 1] dp[i] %= 1000000007 return dp[n - 1] def solve(): global n, m, a_list, step_list n, m = map(int, input().split()) a_list = [0] * m step_list = [True] * (n + 5) for i in range(m): a_list[i] = int(input()) step_list[a_list[i]] = False ans = hoge() print(ans) return 0 if __name__ == ""__main__"": solve()" p03338,s689823291,Accepted,"n = int(input()) s = input() t = set(s) ans = 0 for i in range(1,n): count = 0 s1 = s[:i] s2 = s[i:] for i in t: if s1.count(i) > 0 and s2.count(i) > 0: count += 1 if ans < count: ans = count print(ans)" p03274,s100798377,Accepted,"def mips(): return map(int,input().split()) N,K = mips() C = [c for c in mips()] dist = [] for i in range(N-K+1): dist.append(min(abs(C[i]) + abs(C[i+K-1]-C[i]),abs(C[i+K-1]) + abs(C[i+K-1]-C[i]))) print(min(dist)) " p02701,s682000820,Accepted,"N = int(input()) st = set() for _ in range(N): st.add(input()) print(len(st))" p03854,s843834071,Accepted,"S = input() subT = ['eraser', 'erase', 'dreamer', 'dream', ] for i in subT: S = S.replace(i, '') if S == '': print('YES') else: print('NO') " p02777,s479433554,Accepted,"s,t=input().split() a,b=map(int,input().split()) u=input() if u==s: a-=1 else: b-=1 print(a,b)" p03095,s935522469,Accepted,"N = int(input()) S = input() al = [0 for _ in range(26)] for i in range(N): al[ord(S[i])-97] += 1 count = 1 for j in range(26): count *= al[j]+1 count %= 10**9+7 print((count-1)%(10**9+7))" p02633,s068859088,Accepted,"def gcd(a, b): while b != 0: a, b = b, a % b return a def main(): X = int( input()) # if X > 90: # X -= 90 for i in range(1, X+1): if i*360%X == 0: print(i*360//X) return if __name__ == '__main__': main() " p03803,s352561436,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')" p02829,s077638875,Accepted,"l = [int(input()),int(input())] for i in range(3): if((i+1) not in l): print(i+1) exit()" p02693,s942553516,Accepted,"k = int(input()) a, b = list(map(int, input().split())) if a // k == b // k: if a % k == 0: print(""OK"") else: print(""NG"") else: print(""OK"")" p03067,s120296389,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 a,b,c=map(int,input().split()) if a<=c<=b or a>=c>=b: print(""Yes"") else: print(""No"")" p03494,s801188822,Accepted,"n = int(input()) a = list(map(int,input().split())) def devide(a,c,n): even = True for i in range(n): if a[i] % 2 != 0: even = False else: a[i] = int(a[i] / 2) return devide(a,c+1,n) if even else c print(devide(a,0,n))" p04012,s955210711,Wrong Answer,"w = input() c = w.count('w') print('Yes' if c % 2 == 0 and c > 0 else 'No')" p03681,s952363743,Accepted,"N, M = map(int, input().split()) MOD = 10**9+7 d = abs(N-M) if d > 1: print(0) else: ans = 1 for i in range((N+M)//2): ans *= (N-i)*(M-i) ans %= MOD if (N+M) % 2 == 0: ans *= 2 print(ans % MOD) " p03778,s775373643,Wrong Answer,"w,a,b = map(int, input().split()) ans = min(abs(b - (a + w)), abs(a - (b + w))) if ans < 0: print(0) else: print(ans)" p03073,s672628722,Accepted,"from collections import Counter n=input() o=Counter(n[0::2]) e=Counter(n[1::2]) m=len(n)-max(o[""0""]+e[""1""],o[""1""]+e[""0""]) print(m)" p03494,s101366425,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)" p03696,s062776401,Wrong Answer,"n = int(input()) s = list(input()) c0 = 0 c1 = 0 z0 = 0 z1 = 0 for i in range(n): if s[i] == ""("": c0 += 1 else: c1 += 1 if c0 < c1 and s[i] != ""("": z0 += 1 if c0 > c1 - z0 and s[i] != "")"": z1 += 1 if s[-1] == "")"": z1 -= 1 ans = [""(""]*z0 + s + ["")""]*max(z1,0) print("""".join(ans))" p03329,s467458275,Accepted,"N = int(input()) ans = 100000 for i in range(0,N+1,1):#i円6で払うj円9で払う j = N - i icount = 0 while i!=0: icount += (i%6) i=i//6 jcount = 0 while j!=0: jcount += (j%9) j=j//9 ans = min(icount+jcount,ans) print(ans)" p03106,s063426733,Accepted,"a, b, k = map(int, input().split()) ans = [] for i in range(1, min(a, b) + 1): if a % i == 0 and b % i == 0: ans.append(i) ans.sort(reverse=True) print(ans[k-1])" p02618,s198327052,Accepted,"d = int(input()) c = {} s = [] C = list(map(int, input().split())) for i in range(26): c[i] = C[i] for i in range(d): s.append(list(map(int, input().split()))) t = 0 while t < 365: for i in range(26): if t < 365: t += 1 print(26-i) else: break;" p02973,s210859468,Accepted,"n = int(input()) a = [] for i in range(n): ai = int(input()) a.append(ai) lst = [a[0]] for i in range(1, n): ai = a[i] left = -1 right = len(lst) while left+1 < right: mid = (left + right) // 2 if lst[mid] < ai: right = mid else: left = mid if right == len(lst): lst.append(ai) else: lst[right] = ai print(len(lst))" p02861,s608263221,Accepted,"import itertools import math n = int(input()) li = list(itertools.permutations(range(1,n+1))) a = [] for _ in range(n): a.append([int(x) for x in input().split()]) ans = 0 for i in li: for j in range(n-1): x = a[i[j]-1][0]-a[i[j+1]-1][0] y = a[i[j]-1][1]-a[i[j+1]-1][1] ans += math.sqrt(x**2+y**2) x = 1 for i in range(1,n+1): x *= i print(ans/x)" p02553,s293611819,Accepted,"n = list(map(int,input().split())) a =n[0]*n[2] b =n[0]*n[3] c =n[1]*n[2] d =n[1]*n[3] x = max(a,b,c,d) print(x) " p03795,s351393822,Accepted,"N=int(input()) print(N*800-(N//15)*200)" p03379,s267669727,Accepted,"import statistics n = int(input()) X = list(map(int, input().split())) X_ = sorted(X) med = X_[n//2-1] med_2 = X_[n//2] for i in range(n): if X[i]>med: print(med) else: print(med_2)" p03076,s255795968,Accepted,"a = [] max, index, ans = 0, 0, 0 for i in range(5): tmp = int(input()) a.append(tmp) if 10 - tmp % 10 > max and tmp % 10 != 0: max, index = 10 - tmp % 10, i for i in range(5): if i == index or a[i] % 10 == 0: ans += a[i] else: ans += a[i] + 10 - a[i] % 10 print(ans)" p03037,s375609155,Accepted,"n,m = map(int,input().split()) l = [0]*m r = [0]*m for i in range(m): l[i],r[i] = map(int,input().split()) if min(r)-max(l) < 0: print(0) else: print(min(r)-max(l)+1)" p02909,s543678917,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)%3]) " p03545,s657317840,Wrong Answer,"a = list(map(int, input())) ans = """" for i in range(2 ** 3): for j in range(1, 4): if i << j & 1: a[j] *= -1 if sum(a) == 7: ans += (str)(a[0]) for j in range(1, 4): if a[j] >= 0: ans += ""+"" + (str)(a[j]) else: ans += (str)(a[j]) ans += ""=7"" break else: continue break print(ans)" p02823,s508824835,Wrong Answer,"N,A,B = map(int,input().split()) iti=(B-A+1)/2 +A-1 enu=(B-A+1)/2 +N-B if( (B-A)%2 == 0): print( int( (B-A)/2 ) ) else: print(int(iti) if A-1<=N-B else int(enu)) " p03659,s883929037,Accepted,"from itertools import accumulate n=int(input()) a=list(map(int,input().split())) s=sum(a) # a=[0]+a acc=accumulate(a) acc=list(acc) sunuke=0 arai=0 ans=10**18 for i in range(1,n): sunuke=acc[i-1] arai=s-sunuke t=abs(sunuke-arai) ans=min(t,ans) print(ans)" p02578,s299201472,Accepted,"n=int(input()) a=list(map(int, input().split())) res=0 max=a[0] for i in range(1,n): if a[i] int: accum = [A[0]] total = sum(A) ans = [] for i in range(1,N): accum.append(accum[i-1] + A[i]) accum.pop() # print(accum) for x in accum: y = total - x ans.append(abs(x - y)) # print(ans) return min(ans) def modelAnswer(): return def main(): N = int(input()) A = list(map(int,input().split())) print(myAnswer(N,A)) if __name__ == '__main__': main()" p03639,s562528585,Wrong Answer,"n = int(input()) lis = list(map(int, input().split())) cnt2 = 0 cnt4 = 0 for i in lis: if i % 4 == 0: cnt4 += 1 elif i % 2 == 0: cnt2 += 1 if 2 * cnt4 + cnt2 >= n: print(""Yes"") else: print(""No"") " p03705,s342159029,Accepted,"n, a, b = map(int, input().split()) if n == 1: if a == b: print(1) else: print(0) elif n == 2: if a > b: print(0) else: print(1) else: ans = max(0, (n-2)*(b-a)+1) print(ans)" p03637,s251748507,Accepted,"input();a,b1,b2,b4,r=list(map(int,input().split())),0,0,0,'NYoe s' for i in a: if i%2!=0: b1+=1 elif i%4==0: b4+=1 else: b2+=1 print([r[b1<=b4::2],r[b1<=b4+1::2]][not b2])" p03417,s691988502,Wrong Answer,"n, m = map(int, input().split()) if n==1 or m==1: c = max(0, m-2) d = max(c, n-2) print(d) else: print((n-2)*(m-2))" p03285,s464436816,Accepted,"N = int(input()) sum = 0 for i in range(30): for j in range(20): total = 4*i + 7*j if total == N: sum += 1 if sum > 0: print(""Yes"") else: print(""No"") " p02820,s872811810,Accepted,"N,K=map(int,input().split()) R,S,P=map(int,input().split()) T=input() T=list(T) score=0 for i in range(N): if i-K<0 or T[i-K]!=T[i]: if T[i]==""r"": score+=P elif T[i]==""p"": score+=S elif T[i]==""s"": score+=R else: T[i]=""a"" print(score) " p02910,s474854826,Accepted,"import sys S = list(input()) n = len(S) for i in range(n) : if S[2*i] == ""L"" : print(""No"") sys.exit() if 2*i == n-1 : break if S[2*i+1] == ""R"" : print(""No"") sys.exit() if 2*i + 1 == n-1 : break print(""Yes"") " p02546,s470852282,Accepted,"S = input() if S[-1] == ""s"": print(S + ""es"") else: print(S + ""s"")" p02848,s433739236,Accepted,"#!/usr/bin/env python # coding: utf-8 def ri(): return int(input()) def rl(): return list(input().split()) def rli(): return list(map(int, input().split())) alp = ""ABCDEFGHIJKLMNOPQRSTUVWXYZ"" def main(): n = ri() s = input() ns = """" for c in s: ns += alp[(ord(c)-ord('A')+n)%26] print(ns) if __name__ == '__main__': main() " p02629,s871456789,Accepted,"n = int(input()) - 1 al = 'abcdefghijklmnopqrstuvwxyz' def c_a(d, cs): nd = d // 26 cd = d % 26 if nd >= 26: cs = c_a(nd - 1, cs) + al[cd] elif nd == 0: cs = al[cd] else: cs = al[nd - 1] + al[cd] return cs print(c_a(n, ''))" p03556,s207846496,Accepted,"import math N = int(input()) ans = 1 for i in range(1,math.floor(math.sqrt(N))+1): if i * i <= N: ans = i * i print(ans)" p02726,s861858799,Wrong Answer,"n, x, y = map(int, input().split()) for k in range(1,n): ans = n if y - x == k: ans -= 1 if y - x < k: ans -= n-k if k <= x and n - (k-1) >= y: print(ans) else: minus = max(k-x, 0) + max(y - (n-(k-1)), 0) print(ans-minus)" p03017,s434586846,Wrong Answer,"import sys sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) N, A, B, C, D = lr() S = input() if C > D: if ""..."" not in S[B-1:D]: print(""No"") exit(0) if ""##"" in S[A-1:C] or ""##"" in S[B-1:D]: print(""No"") else: print(""Yes"") " p02994,s740528774,Accepted,"N, L = map(int, input().split()) *a, = map(lambda x:L+x-1, range(1, N+1)) a.sort(key=abs) print(sum(a)-a[0])" p03433,s249744256,Accepted,print('YNeos'[int(input())%500>int(input())::2]) p02731,s618928419,Accepted,"L=int(input()) print((L/3)**3)" p03419,s877166369,Accepted,"N,M = map(int,input().split()) n = min(N,M) m = max(N,M) if n*m == 1: print(1) exit() if n == 1: print(m-2) exit() print((n-2)*(m-2)) " p03105,s461212610,Accepted,"import sys def input(): return sys.stdin.readline().rstrip() def main(): A, B, C = map(int, input().split()) print(min(C, B // A)) if __name__ == '__main__': main() " p03086,s653773979,Accepted,"s = input() moji = (""A"",""C"",""G"",""T"") count = [0] tmp = 0 for i in range(len(s)): if s[i] in moji: tmp +=1 else: count.append(tmp) tmp = 0 count.append(tmp) print(max(count))" p03696,s740078730,Accepted,"n = int(input()) s = list(str(input())) # ( x = 0 y = 0 for i in range(n): if s[i] == '(': x += 1 if s[i] == ')': if x >= 1: x -= 1 else: y += 1 for _ in range(x): s.append(')') for _ in range(y): s.insert(0,'(') ans = ''.join(s) print(ans) " p03380,s932136223,Accepted,"import sys sys.setrecursionlimit(10 ** 7) f_inf = float('inf') mod = 998244353 def resolve(): n = int(input()) A = sorted(list(map(int, input().split()))) MAX_V = A[-1] target = MAX_V // 2 if MAX_V % 2 == 0 else (MAX_V + 1) // 2 diff = f_inf res = A[0] for i in range(n - 1): if abs(target - A[i]) < diff: diff = abs(target - A[i]) res = A[i] print(MAX_V, res) if __name__ == '__main__': resolve() " p02646,s833475990,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') " p04012,s947064038,Accepted,"from collections import Counter W = input() C = Counter(W) for v in C.values(): if v % 2 == 1: print('No') break else: print('Yes')" p02726,s280724663,Accepted,"n,x,y=map(int,input().split()) x,y=x-1,y-1 ans=[0]*(n+1) for i in range(n): for j in range(i+1,n): a=abs(i-j) b=abs(i-x)+1+abs(y-j) ans[min(a,b)]+=1 for i in range(1,n): print(ans[i]) " p03416,s878555697,Accepted,"a,b = map(int,input().split()) ans = 0 for i in range(a,b+1): str_i = str(i) if str_i[0]==str_i[-1] and str_i[1]==str_i[-2]: ans += 1 print(ans)" p03799,s024952705,Accepted,"n,m = map(int,input().split()) if n>m: print(m//2) else: if n*2>m: print(m//2) else: cnt = 0 m -= n*2 cnt += n if m>=4: cnt+=m//4 print(cnt)" p03745,s511678138,Accepted,"n = int(input()) l = [int(x) for x in input().split()] order = 0 subs = [] tmp = [] prev = 0 d = [] t = [l[0]] for x in range(len(l)-1): a,b = l[x],l[x+1] c = a-b # print(a,b,c, prev) if c == 0: t.append(b) elif prev == 0: t.append(b) prev = c elif (c < 0 and prev < 0) or (c > 0 and prev > 0): t.append(b) else: prev = 0 d.append(t) t = [b] d.append(t) print(len(d)) " p03126,s467592237,Accepted,"N,M = map(int,input().split()) X = [] for i in range(N): K = list(map(int,input().split())) for i in range(K[0]): X.append(K[i+1]) ans = 0 for j in range(M): if X.count(j+1) == N: ans += 1 print(ans)" p02780,s892282412,Accepted,"n,k = map(int,input().split()) P = list(map(int,input().split())) def E(x): # ans = 0 tmp = (x*(x+1))/2 if x % 2 == 0 else x+(((x-1)*(x))/2) return tmp/x ans = 0 for i in range(len(P)): P[i] = round(E(P[i]),1) max_v = tmp = sum(P[:k]) l = 0 r = k for i in range(1,len(P)-k+1): tmp = tmp-P[i-1]+P[r] max_v = max(max_v, tmp) r += 1 print(max_v)" p02723,s066235689,Accepted,"S = input() if S[2] == S[3] and S[4] == S[5]: print('Yes') else: print('No')" p03487,s752457079,Accepted,"from collections import Counter n = int(input()) lst = list(map(int, input().split())) cntr = Counter(lst) res = 0 for i in cntr: if cntr[i] >= i: res += (cntr[i] - i) else: res += cntr[i] print(res)" p02583,s907404565,Wrong Answer,"N = int(input()) L = sorted(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] >= L[k]) and (L[i] != L[j]) and (L[j] !=L[k]): ans += 1 print(ans) " p03387,s922523593,Wrong Answer,"#C - Same Integers ABC = list(map(int,input().split())) ABC = sorted(ABC,reverse = True) A = ABC[0]#max B = ABC[1] C = ABC[2]#min print(ABC) count = 0 while A != B: C += 1 B += 1 count += 1 while (B - C)%2 == 1: A += 1 B += 1 count += 1 while A!=C: C += 2 count += 1 print(count)" p03282,s139494925,Accepted,"s=list(input()) k=int(input()) for i in range(k): if s[i]!=""1"": print(s[i]) break else: print(1)" p02641,s096234826,Accepted,"X,N = map(int,input().split()) P = list(map(int,input().split())) a = list(range(102)) for i in range(N): a[P[i]] = -2 m = 102 for i in range(102): if m > (abs(X - a[i])): m = (abs(X - a[i])) ans = a[i] print(ans)" p02779,s949619403,Accepted,"n = int(input()) a = list(map(int, input().split())) if len(a) == len(set(a)): print('YES') else: print('NO')" p04030,s755573305,Wrong Answer,"print(input().replace('0B','').replace('1B','').replace('B',''))" p02642,s819082765,Accepted,"from collections import Counter n = int(input()) a = list(map(int, input().split())) a.sort() check = [True] * (a[-1] + 1) cnt = Counter(a) for i in range(n): if check[a[i]] == False:continue for j in range(a[i], a[-1] + 1, a[i]): if j == a[i]:continue check[j] = False ans = 0 for i in range(n): if check[a[i]] and cnt[a[i]] == 1:ans += 1 print(ans) " p03407,s069893287,Accepted,"a, b, c = map(int, input().split()) if a+b>=c: print('Yes') else: print('No')" p02621,s805362212,Wrong Answer,"a=int(input()) ans=a+a*a+a**2 print(ans)" p03220,s419117610,Wrong Answer,"n = int(input()) t,a = map(int,input().split()) h = [int(i) for i in input().split()] mn = 10**9 for i in range(n): mn_kouho = a-(t-h[i]*0.006) if mn > mn_kouho: mn = mn_kouho ans = i+1 print(ans)" p02772,s939677394,Wrong Answer,"n = int(input()) a = [int(x) for x in input().split()] a_even = [] for ai in a: if ai%2 == 0: a_even += [ai] ans = ""APPROVED"" for a_eveni in a_even: if a_eveni%3 != 0 or a_eveni%5 != 0: ans = ""DENIED"" break print(ans)" p02797,s297361790,Wrong Answer,"N , K ,S =map(int,input().split()) if S == 10**9: ans = [S]*K + [10**9]*(N-K) else: ans = [S]*K + [1]*(N-K) print(ans)" p03487,s069509464,Accepted,"N = int(input()) a = list(map(int, input().split())) cnt = {} for i in range(N): cnt.setdefault(a[i], 0) cnt[a[i]] += 1 ans = 0 for k, v in cnt.items(): if k > v: ans += v else: ans += v - k print(ans) " p02663,s478037146,Accepted,"h1, m1, h2, m2, k = map(int, input().split()) time = (h2 * 60 + m2) - (h1 * 60 + m1) print(max(time - k, 0))" p02748,s108909840,Wrong Answer,"a, b, m = map(int, input().split()) li_a = list(map(int, input().split())) li_b = list(map(int, input().split())) li_c = [] for _ in range(m): x, y, c = map(int, input().split()) x, y = x-1, y-1 li_c.append(li_a[x]+li_b[y]-c) li_a.sort() li_b.sort() li_c.sort() ans = min(li_a[0]+li_b[0], li_c[0])" p03469,s413495061,Accepted,"print(""2018""+input()[4:])" p03860,s827271758,Accepted,"string = list(input().split()) for s in string: print(s[0], end="""")" p02584,s671220836,Accepted,"X,K,D = map(int,input().split()) X=abs(X) q=X//D mod=X%D if q <= K: if (K-q)%2==0: ans=mod else: ans=D-mod else: ans=X-K*D print(ans) " p02754,s807989727,Accepted,"N, A, B = list(map(int, input().split())) cnt = A * (N//(A+B)) x = N % (A+B) if x > A: cnt += A else: cnt += x print(cnt)" p02785,s620980399,Accepted,"N,K = map(int,input().split()) H = list(map(int,input().split())) R = sorted(H) m = N - K a = R[0 : m] point = sum(a) if K >= N : point = 0 print(point)" p03711,s441554231,Accepted,"x,y=list(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 or x in b and y in b: print('Yes') else: print('No')" p02900,s222019526,Accepted,"a = list(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 print(len(set(prime_factorize(a[0])) & set(prime_factorize(a[1])))+1) " p03241,s032541000,Accepted,"[n,m] = [int(i) for i in input().split()] if n == 1: print(m) else: ans = -1 #a1は高々この値 a1_max = m // n for i in range(a1_max,0,-1): if (m - i) % i == 0 and (m - i)//i >= (n-1): ans = max(ans,i) print(ans) " p02951,s810008422,Wrong Answer,"a, b, c = map(int, input().split()) if a > b: print(c - (a - b)) else: print(c)" p03994,s204511158,Accepted,"s = list(input()) K = int(input()) for i in range(len(s)): if s[i] == ""a"": continue d = ord(""z"")-ord(s[i]) + 1 if d <= K: s[i] = ""a"" K -= d x = (ord(s[-1])-ord(""a"")+K)%26 s[-1] = chr(ord(""a"")+x) print("""".join(s))" p03281,s409479490,Accepted,"N = int(input()) def cnt_div(n): cnt = 0 for i in range(1,n+1): if i*i>n:break if n%i==0: cnt+=1 if n//i!=i: cnt+=1 return cnt cnt = 0 for i in range(1,N+1): if i%2==1 and cnt_div(i)==8: cnt+=1 print(cnt)" p02601,s136350447,Wrong Answer,"A,B,C=map(int,input().split()) K=int(input()) flag = 0 for k in range(K): if B*(k+1)*2>A: Bnew=B*(k+1)*2 newK = K - k - 1 for newk in range(newK): if C * (newk + 1) * 2 > Bnew: print('Yes') flag=1 break break if flag == 0: print('No')" p02888,s509469242,Accepted,"from bisect import bisect_left N = int(input()) L = sorted(list(map(int, input().split()))) ans = 0 for i in range(N): for j in range(i + 1, N): a = L[i] b = L[j] idx = bisect_left(L, a + b) ans += idx - 1 - j print(ans) " p03767,s451444923,Accepted,"#!/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() answer = 0 for i in range(N): answer += A[N+2*i] print(answer) if __name__ == '__main__': main() " p02756,s948244872,Wrong Answer,"from collections import deque S = input() Q = int(input()) cur = 1 d = deque([S]) for _ in range(Q): xs = input().split() if len(xs) == 1: cur = 2 if cur == 1 else 1 else: _, f, c = xs if f == cur == 1 or f == cur == 2: d.append(c) else: d.appendleft(c) if cur == 1: ans = """".join(d) else: d.reverse() ans = """".join(d) print(ans) " p03274,s125577312,Accepted,"n, k = map(int, input().split()) x = list(map(int , input().split())) #from bisect import bisect_left #p0 = bisect_left(x, 0) #x[p0] == 0 ans = 10 ** 10 for i in range(n-k+1): ans = min(ans, abs(x[i]) + abs(x[i+k-1] - x[i])) ans = min(ans, abs(x[i+k-1]) + abs(x[i+k-1] - x[i])) #print(i, i+k-1, ans) print(ans)" p03639,s625727121,Wrong Answer,"N=int(input()) A=list(map(int,input().split())) cnt1,cnt2,cnt4=0,0,0 for i in A: if i%2!=0: cnt1+=1 elif i%2==0 and i%4!=0: cnt2+=1 else: cnt4+=1 if cnt2==0: if cnt4>=cnt1+1: print('Yes') exit() else: if cnt4>=cnt1: print('Yes') exit() print('No')" p03469,s525194206,Wrong Answer,"S = input() answer = S[0:2] + ""8"" + S[4:9] print(answer)" p03994,s269550571,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: continue elif 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) " p03785,s820165413,Accepted,"n, c, k = map(int, input().split()) t = sorted(int(input()) for _ in range(n)) cnt = 0 bus_people = 0 bus_time = 0 for i in range(n): if bus_people >= c or t[i] > bus_time: bus_people = 1 bus_time = t[i] + k cnt += 1 else: bus_people += 1 print(cnt)" p02862,s029361044,Accepted,"from functools import lru_cache MOD = 10**9+7 x,y = map(int, input().split()) summ = x+y @lru_cache(maxsize=None) def inv(n): return pow(n,-1,MOD) if summ%3 == 0 and summ//3 <= x and summ//3 <= y: mn = min(x,y) n = mn - summ//3 a = summ//3 b = 1 ans = 1 for i in range(n): ans *= a ans *= inv(b) ans %= MOD a -= 1 b += 1 print(ans) else: print(0)" p02829,s262998458,Accepted,"a = int(input()) b = int(input()) c = 6 - a - b print(c)" p03799,s576050231,Wrong Answer,"n, m = map(int, input().split()) if n > m // 4: print(n + (m - 2 * n) // 4) else: print(m // 4 + min(n, m % 4 // 2))" p02618,s806413642,Accepted,"# 各日について満足度の一番高いコンテストを選択する貪欲 def main(): import sys import numpy as np D=int(sys.stdin.readline()) S=np.zeros((D,26)) C=np.array(map(int,sys.stdin.readline().split())) for i in range(D): S[i]=list(map(int,sys.stdin.readline().split())) for i in range(D): print(np.argmax(S[i])+1) main()" p03821,s598944246,Accepted,"import sys sys.setrecursionlimit(10 ** 5 + 10) def input(): return sys.stdin.readline().strip() def resolve(): N=int(input()) A, B = [0] * N, [0] * N for i in range(N): A[i], B[i] = map(int, input().split()) ans=0 cnt=0 for i in reversed(range(N)): p,mod=divmod(A[i]+cnt,B[i]) if mod==0: continue else: cnt+=B[i]-mod print(cnt) resolve()" p03796,s669908213,Accepted,"ans=1 n=int(input()) for i in range(1,n+1): ans*=i ans=ans%(10**9+7) print(ans)" p03211,s010029172,Accepted,"import sys sys.setrecursionlimit(10**7) input = sys.stdin.readline s = input() ans = 753 for i in range(len(s) - 3): num = int(s[i:i+3]) ans = min(ans, abs(num - 753)) print(ans) " p02995,s859959299,Accepted,"import fractions A,B,C,D = map(int,input().split()) l = C*D // fractions.gcd(C,D) x = (A-1) -(A-1)//C - (A-1)//D + (A-1)//l y = B - B//C - B//D + B//l print(y-x)" p02983,s198421022,Accepted,"l,r=map(int,input().split()) for i in range(l,r+1): if i%2019==0: print(0) break else: mini=2018 for i in range(l,r): for j in range(i+1,r+1): if (i*j)%2019<=mini: mini=(i*j)%2019 print(mini)" p03645,s859308789,Accepted,"n, m = map(int, input().split()) root = [[False]*n for _ in range(2)] for i in range(m): a, b = map(int, input().split()) if a==1: root[0][b-1] = True if b==n: root[1][a-1] = True for j in range(n): if root[0][j]: if root[1][j]: print('POSSIBLE') exit(0) print('IMPOSSIBLE') " p02909,s570436664,Accepted,"weather={""Sunny"":""Cloudy"",""Cloudy"":""Rainy"",""Rainy"":""Sunny""} print(weather[input()])" p02629,s660572745,Wrong Answer,"N = int(input()) risuto = [] while N != 0: if N%26 == 0: risuto = [26] + risuto else: risuto = [N%26] + risuto if N % 26 == 0 and N // 26 == 1: break N //= 26 ans = """" print(risuto) for i in risuto: ans += ""abcdefghijklmnopqrstuvwxyz""[i-1] print(ans)" p03479,s763282068,Accepted,"import math x, y = map(int,input().split()) l = 0 while x <= y: l += 1 x = 2*x print(l) # なぜWA? # print(int(math.log2(int(y/x)) + 1))" p03827,s108328147,Wrong Answer,"def main(): n = int(input()) s = list(input().split()) ans = 0 now = 0 for i, i_d in enumerate(s): if i_d == 'I': now += 1 ans = max(ans, now) else: now -= 1 print(ans) if __name__ == '__main__': main() " p03161,s293284499,Accepted,"n,k = map(int,input().split()) h = list(map(int,input().split())) dp = [0,abs(h[1]-h[0])] for i in range(2,n): u = [] for j in range(1,min(i,k)+1): u.append(dp[i-j]+abs(h[i]-h[i-j])) dp.append(min(u)) print(dp[n-1])" p03069,s460576442,Accepted,"n=int(input()) s=input() w_right=s.count(""."") b_left=0 ans=w_right for i in range(n): if s[i]==""#"": b_left+=1 else: w_right-=1 ans=min(ans,w_right+b_left) print(ans) " p03544,s702694983,Accepted,"n=int(input()) a,b=2,1 for i in range(n-1): a,b=b,(a+b) print(b)" p03427,s147084250,Accepted,"N = input() n = 0 for i in range(1,len(N)): if(N[i] == ""9""): n+=1 if(n==len(N)-1): print(int(N[0]) + (len(N)-1)*9) else: print(int(N[0]) - 1 + (len(N)-1)*9)" p03293,s200068904,Wrong Answer,"s = list(input()) t = list(input()) s.sort() t.sort() flag = True for i in range(len(s)): s.insert(0,s.pop(-1)) if """".join(s) == """".join(t): print(""Yes"") flag = False break if flag: print(""No"")" p03471,s666486106,Accepted,"def main(): n, y = map(int, input().split()) for i in range(n + 1): for j in range(n + 1 - i): z = n - i - j if i * 10000 + j * 5000 + z * 1000 == y: print(i, j, z) exit() print('-1 -1 -1') if __name__ == '__main__': main()" p03592,s525704584,Accepted,"N, M, K = map(int, input().split()) for n in range(N + 1): for m in range(M + 1): if K == (N - n) * m + (M - m) * n: print('Yes') exit() print('No')" p03107,s591533349,Accepted,"ss = input() zero = 0 one = 0 for s in ss: if s == ""0"": zero += 1 elif s == ""1"": one += 1 print(2 * min(zero, one))" p02831,s491921951,Accepted,"from sys import stdin import fractions A, B = [int(x) for x in stdin.readline().rstrip().split()] print((A * B) // fractions.gcd(A, B)) " p02612,s189590714,Wrong Answer,"n = int(input()) x = n % 1000 if x == 0: print(x) print(1000 - x)" p02684,s348308059,Accepted,"N,K = map(int, input().split()) A = [*map(lambda x:int(x)-1, input().split())] index = [-1]*N path = [] pre = 0 while index[pre] < 0: index[pre] = len(path) path += [pre] pre = A[pre] one = index[pre] loops = len(path) - one k = max(0, K-one) % loops + min(K, one) pre = 0 for _ in range(k): pre = A[pre] print(pre + 1) # if K <= one: print(path[K]) # else: print(path[(K-one) % loops + one]+1) " p02952,s942442529,Accepted,"i=int(input()) if(0= 13: print(b) elif n <= 5: print(0) else: print(b//2) " p02996,s448046521,Accepted,"from operator import itemgetter N=int(input()) tasks=[list(map(int,input().split())) for _ in range(N)] tasks.sort(key=itemgetter(1)) t=0 for w,l in tasks: if t+w>l: print('No') exit() t+=w print('Yes')" p03206,s621471660,Accepted,"a=int(input()) print(""Christmas""+"" Eve""*(25-a))" p03416,s231637989,Accepted,"import sys read = sys.stdin.read readlines = sys.stdin.readlines def main(): a, b = map(int, input().split()) r = 0 for i1 in range(a, b + 1): c1 = i1 // 10000 == i1 % 10 c2 = ((i1 // 1000) % 10) == ((i1//10)%10) r += c1 and c2 print(r) if __name__ == '__main__': main()" p02755,s717523629,Wrong Answer,"A,B=map(int,input().split()) sampleA=A*100/8 sampleB=B*10 sampleA=int(sampleA) sampleB=int(sampleB) ans=[] for i in range(max(sampleA,sampleB),max(sampleA,sampleB)+10): if int(i*8/100)==A and int(i*0.1)==B: ans.append(i) break else: ans.append(-1) print(min(ans))" p03038,s782193215,Accepted,"import sys import heapq N,M=map(int,input().split()) alist=list(map(int,input().split())) cblist=[] for i in range(M): B,C=map(int,input().split()) cblist.append((C,B)) cblist.sort(reverse=True) hq=[] for a in alist: heapq.heappush(hq,a) for C,B in cblist: for i in range(B): if C<=hq[0]: print(sum(hq)) sys.exit(0) else: heapq.heapreplace(hq,C) else: print(sum(hq))" p03042,s946394060,Accepted,"s = int(input()) a, b = s // 100, s % 100 x = ""YY"" if a == 0 or a > 12 else ""MM"" y = ""YY"" if b == 0 or b > 12 else ""MM"" if x != y: print(x + y) else: print(""NA"" if x == ""YY"" else ""AMBIGUOUS"") " p03137,s154552958,Accepted,"n, m = list(map(int, input().split())) x = list(map(int, input().split())) if n >= m: print(0) quit() x.sort() y = [x[i]-x[i-1] for i in range(1, m)] y.sort(reverse = True) ans = sum(y) for i in range(n-1): ans -= y[i] print(ans)" p03814,s768233488,Wrong Answer,"import sys s = str(input()) ans = """" for i in range(0,len(s)): if s[i] == ""A"": for j in range(i,len(s)): if s[j] != ""Z"": ans = ans +s[j] else: ans = ans + ""Z"" print (len(ans)) sys.exit()" p03449,s567763272,Wrong Answer,"n=int(input()) a1=list(map(int,input().split())) a2=list(map(int,input().split())) ans=0 for x in range(1,n+1): a1sum=sum(a1[0:x+1]) a2sum=sum(a2[x:n+1]) ans=max(ans,a1sum+a2sum) print(ans)" p03160,s874934734,Accepted,"import sys N=int(input()) l=[int(x) for x in input().split()] l1=[sys.maxsize]*(N) l1[0]=0 for i in range(N): for j in range(i+1,i+3): if j= s is True: print(""unsafe"") else: print(""safe"")" p02720,s817861598,Wrong Answer,"k = int(input()) q = [1,2,3,4,5,6,7,8,9] for i in range(k): x = q.pop(0) if x%10 != 0: q.append(10*x + (x%10) -1) q.append(10*x + (x%10)) if x%9 != 0: q.append(10*x + (x%10) +1) print(x) " p03324,s540442895,Accepted,"D,N=map(int, input().split()) m=0 for i in range(1, 10**10): c=0 n=i while i%100==0: i//=100 c+=1 if c==D: m+=1 if m==N: print(n) exit()" p02835,s142229466,Accepted,"a, b, c = map(int, input().split()) if a + b + c >= 22: print('bust') else: print('win')" p03433,s589804415,Accepted,"n = int(input()) a = int(input()) if n % 500 <= a: print('Yes') else: print('No')" p02630,s109889004,Accepted,"from collections import Counter X = open(0).readlines() n = int(X[0]) *A, = map(int, X[1].split()) counter = Counter(A) q = int(X[2]) s = sum(A) for x in X[3:]: b, c = map(int, x.split()) if b in counter: t = counter.pop(b) s += c*t - b*t counter[c] = counter.get(c, 0) + t print(s)" p03427,s229898989,Accepted,"def main(): n = list(input()) ans = max(int(n[0])-1 + 9*(len(n)-1), int(n[0]), sum(map(int, n))) print(ans) if __name__ == '__main__': main() " p03077,s485460244,Accepted,"import math n = int(input()) a = int(input()) b = int(input()) c = int(input()) d = int(input()) e = int(input()) minmove = min([a, b, c, d, e]) ans = math.ceil(n/minmove) + 4 print(ans)" p02899,s196614909,Accepted,"n=int(input()) l=list(map(int,input().split())) ll=[] for i in range(n): ll.append([l[i],i+1]) ll=sorted(ll) ans=[] for j in range(n): ans.append(ll[j][1]) print(*ans)" p03659,s684884292,Accepted,"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 range(len(cumsum)-1): mi = min(mi, abs(cumsum[i] - (su-cumsum[i]))) print(mi)" p02817,s372873424,Accepted,"s,t = input().split() print(t+s)" p02623,s185461668,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)" p02995,s881723263,Accepted,"import fractions a,b,c,d=map(int,input().split()) nc=b//c-(a+c-1)//c+1 nd=b//d-(a+d-1)//d+1 cd=c*d//fractions.gcd(c,d) ncd=b//cd-(a+cd-1)//cd+1 print(b-a+1-(nc+nd-ncd)) # math.ceil(a/b)->(a+b-1)//b" p02571,s092022067,Accepted,"s = input() t = input() ans = 10000 for i in range(len(s) - len(t) + 1): tmp = 0 for j in range(len(t)): if s[i + j] != t[j]: tmp+=1 ans = min(ans, tmp) print(ans)" p03433,s582055336,Accepted,"n = int(input()) a = int(input()) if n % 500 <= a: print('Yes') else: print('No')" p03457,s112709533,Wrong Answer,"import sys n = int(input()) pos = [list(map(int,input().split())) for p in range(n)] for i in range(len(pos)): if i == 0: if pos[i][1]+pos[i][2] != pos[i][0]: print(""No"") sys.exit() else: diff = pos[i][0]-pos[i-1][0] num = abs(pos[i][1]-pos[i-1][1]) + abs(pos[i][2]-pos[i-1][2]) if num <= diff and diff * (diff%2) == num%2: pass else: print(""No"") sys.exit() print(""Yes"") " p02618,s176743151,Accepted,"import numpy as np D=int(input()) *c,=map(int,input().split()) c=np.array(c,dtype=int) s=[] for i in range(D): *x,=map(int,input().split()) s.append(x) s=np.array(s,dtype=int).reshape((D,26)) dt=[] cnt=np.array([0]*26) for d in range(D): y=np.argmax(c*(d-cnt)) cnt[y]=d+1 dt.append(y+1) for i in dt: print(i) " p03637,s652565375,Wrong Answer,"n=int(input()) a=list(map(int,input().split())) b,c=0,0 for i in a: if i%4==0: b+=1 elif i%2==0: c+=1 if b+c/2.01>=(len(a)-1)/2: print(""Yes"") else: print(""No"")" p02790,s334650775,Wrong Answer,"a=input().split("" "") x1="""" x2="""" for j in range(int(a[0])): x1=x1+a[0] for y in range(int(a[1])): x2=x2+a[1] z1=int(x1) z2=int(x2) if x1>x2: print(x1) elif x1= X for v in lev): if best is None or pri < best: best = pri print(-1 if best is None else best) " p03679,s325758005,Wrong Answer,"x, a, b=map(int, input().split()) if a<=b: print('delicious') else: if b-ali and s[ri]==""W"": ri-=1 if ri<=li: break ri-=1 cnt+=1 print(cnt) " p03681,s302110352,Wrong Answer,"import math n, m = map(int, input().split()) if n==m: print((math.factorial(n)*math.factorial(m)*2)%1000000007) elif abs(n)-abs(m)==1: print((math.factorial(n)*math.factorial(m))%1000000007) else: print(0)" p02675,s171686377,Accepted,"n=int(input()) n%=10 if n==3: print('bon') elif n==0 or n==1 or n==6 or n==8: print('pon') else: print('hon')" p02642,s600580961,Wrong Answer,"N= int(input()) As = list(map(int,input().split())) As= [a for a in As if As.count(a)==1] As.sort() import sys if len(As)==0: print(0) sys.exit() count=1 for i in range(1,len(As),-1): flg=True for j in range(i): if As[i]%As[j]==0: flg=False break if As[j]>As[i]**0.5: break if flg: count +=1 print(count)" p02695,s952950141,Wrong Answer,"from itertools import combinations_with_replacement N, M, Q = map(int, input().split()) query = tuple(tuple(map(int, input().split())) for _ in range(Q)) ans = 0 for comb in combinations_with_replacement(range(1, 11), N): score = 0 for a, b, c, d in query: if comb[b-1] - comb[a-1] == c: score += d ans = max(ans, score) print(ans) " p03485,s963470601,Wrong Answer,"a,b = map(int,input().split()) A = (a+b)/2 print(A if (A*10)%2 == 0 else int(A+0.5))" p03493,s878034995,Accepted,"S = input() print(S.count(""1""))" p02772,s483760764,Wrong Answer,"n = int(input()) z = list(map(int, input().split())) print('APPROVED' if (a & 1 or i % 3 == 0 or i % 5 == 0 for i in z) else 'DENIED') " p03633,s838234552,Accepted,"import sys def I(): return int(sys.stdin.readline().rstrip()) N = I() T = [I() for _ in range(N)] from fractions import gcd ans = T[0] for i in range(N-1): ans = (ans*T[i+1])//gcd(ans,T[i+1]) print(ans)" p03623,s232163680,Accepted,"x, a, b = map(int, input().split()) print('B' if abs(b-x) < abs(a-x) else 'A')" p02987,s997605548,Accepted," S = input() s = sorted(S) if (s[0] == s[1] and s[2] == s[3]) and (s[1] != s[2]): print(""Yes"") else: print(""No"")" p04044,s657206126,Wrong Answer,"n,l = map(int,input().split()) s = [] for i in range(n): s.append(input()) print(sorted(s)) " p02982,s011317510,Accepted,"#B 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): for j in range(i + 1, n): dif = 0 for k in range(d): dif += abs(x[i][k] - x[j][k])** 2 if math.sqrt(dif) % 1 == 0: ans += 1 print(ans)" p02748,s938335915,Wrong Answer,"a, b, m = map(int,raw_input().split()) dr = map(int,raw_input().split()) wa = map(int,raw_input().split()) xyc = [map(int,raw_input().split()) for i in range(m)] low = 200001 for i in range(m): f = xyc[i][0] - 1 d = xyc[i][1] - 1 if low >= dr[f]+wa[d]-xyc[i][2]: law = dr[f]+wa[d]-xyc[i][2] dr.sort() wa.sort() if law >= (dr + wa): print (dr + wa) else: print law" p02753,s909544039,Accepted,"s=input() if s[0]==s[1] and s[1] == s[2]: print('No') else: print('Yes')" p03457,s481269410,Accepted,"n=int(input()) def func(start,goal,t): distance=abs(start[0]-goal[0])+abs(start[1]-goal[1]) if distance<=t and (t-distance)%2==0: return True return False now=0 can=1 start=[0,0] for i in range(n): t,x,y=[int(i) for i in input().split()] goal=[x,y] if not func(start,goal,t-now): can=0 break else: start=goal now=t if can==1: print(""Yes"") else: print(""No"") " p02987,s804143972,Wrong Answer,"import sys a1=sys.stdin.readline() a2=list(a1) b=[ord(x) for x in a2] b.sort() if len(a2)==4 and (b[0]>=65 and b[0]<=90) and (b[1]>=65 and b[1]<=90) and (b[2]>=65 and b[2]<=90) and (b[3]>=65 and b[3]<=90): if b[0]==b[1] and b[2]==b[3] and b[0]!=b[3] and b[1]!=b[2]: print(""Yes"") else: print(""No"") else: print(""Error"")" p03087,s013144858,Wrong Answer,"#ABC122C 累積和 from itertools import accumulate A = [] N, Q = map(int, input().split()) B = [0]*N S = list(input()) ans = [] for i in range(1, N): if S[i-1]=='A' and S[i]=='C': B[i] = 1 A = list(accumulate(B)) print(A) for j in range(Q): l, r = map(int, input().split()) ans.append(A[r-1]-A[l-1]) print('\n'.join(map(str, ans))) " p02596,s903900822,Accepted,"k = int(input()) ans = 0 mod = 7 flag = 0 for i in range(10 ** 6 + 1): ans += 1 if mod % k == 0: flag = 1 break else: mod = (mod % k) * 10 + 7 if flag == 1: print(ans) else: print(-1)" p03633,s144041572,Accepted,"import fractions from functools import reduce N = int(input()) T = [int(input()) for _ 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)) " p03042,s359454764,Accepted,"S=input() s1=S[0:2] s2=S[2:4] li=[""01"",""02"",""03"",""04"",""05"",""06"",""07"",""08"",""09"",""10"",""11"",""12""] if s1 not in li: a=False else: a=True if s2 not in li: b=False else: b=True if a==b==True: print(""AMBIGUOUS"") elif a==b==False: print(""NA"") elif a==True: print(""MMYY"") else: print(""YYMM"") " p03105,s171468422,Accepted,"a,b,c = map(int, input().split()) print(min(b//a,c))" p03745,s576576342,Accepted,"n = int(input()) a = list(map(int, input().split())) state = -1 res = 1 for i in range(1, n): if state == -1: if a[i] < a[i-1]: state = 0 elif a[i] > a[i-1]: state = 1 elif (state == 0 and a[i] > a[i-1]) or (state == 1 and a[i] < a[i-1]): res += 1 state = -1 print(res) " p02996,s123176321,Accepted,"import sys input = sys.stdin.readline N = int(input()) AB = [tuple(map(int, input().split())) for _ in range(N)] AB.sort(key=lambda k: k[1]) t = 0 for Ai, Bi in AB: t += Ai if t>Bi: print('No') exit() print('Yes')" p03456,s278854579,Accepted,"a=int(input().replace("" "","""")) if (a**.5).is_integer(): print('Yes') else: print('No') " p03779,s693675197,Wrong Answer,"x = int(input()) d = 0 for j in range(10 * 5): d += j if d >= x: print(j) exit()" p02963,s518751597,Accepted,"s = int(input()) import math k = math.floor(s**0.5) m = 0 if s == 10**18: print(10**9,0,0,10**9,0,0) else: if k**2+k < s: m = (k+1)**2 -s print(k+1,1,m,k+1,0,0) else: m = k*(k+1)-s print(k+1,1,m,k,0,0)" p02951,s668129007,Accepted,"import sys a, b, c = map(int, sys.stdin.readline().split()) def main(): return max(c + b - a, 0) if __name__ == '__main__': ans = main() print(ans)" p03565,s794564189,Wrong Answer,"S = input() T = input() res = [] ok = -1 for i in range(len(S) - len(T) + 1): if S[i] == T[0] or S[i] == ""?"": for j in range(len(T)): if S[i + j] not in (""?"", T[j]): break else: s = S[:i] + T + S[i + len(T):] res.append(s.replace(""?"", ""a"")) if res: print(res) else: print(""UNRESTORABLE"") " p02570,s063851146,Accepted,"D,T,S = map(int, open(0).read().split()) if T * S >= D: print('Yes') else: print('No')" p02597,s746011481,Accepted,"N = int(input()) C = input() W = sum([1 for c in C if c == 'W']) R = len(C) - W print(sum([1 for c in C[R:] if c == 'R'])) " p02743,s917705400,Wrong Answer,"import math a,b,c = map(int,input().split()) A = a*a + 2*a*b + b*b C = c*c if A < C: print(""Yes"") else: print(""No"")" p02767,s432607651,Accepted,"import numpy as np N = int(input()) X = np.array(list(map(int, input().split()))) x = int(np.sum(X) / N + 0.5) print(np.sum(np.square(X - x))) " p03013,s423902774,Wrong Answer,"#!/usr/bin/env python3 n, m = map(int, input().split()) a = [int(input()) for _ in range(m)] f = lambda j: j not in a mod = 10**9+7 dp = [0] * -~n dp[0] = 1 dp[1] = f(1) for i in range(2, -~n): if f(i): dp[i] = (dp[i - 1] + dp[i - 2]) % mod print(dp[n])" p03836,s071640606,Accepted,"#coding: utf-8 sx, sy, tx, ty = map(int,input().split()) ans = '' for i in range(tx-sx): ans += 'R' for i in range(ty-sy): ans += 'U' for i in range(tx-sx): ans += 'L' for i in range(ty-sy): ans += 'D' ans += 'D' for i in range(tx-sx+1): ans += 'R' for i in range(ty-sy+1): ans += 'U' ans += 'L' ans += 'U' for i in range(tx-sx+1): ans += 'L' for i in range(ty-sy+1): ans += 'D' ans += 'R' print(ans)" p03095,s764443268,Accepted,"n = int(input()) s = input() mod = 10**9+7 s = sorted(s) s += '#' count = 1 ans = 1 for i in range(1, n+1): if s[i] == s[i-1]: count += 1 else: ans = (ans * (count+1)) % mod count = 1 print(ans-1) " p04011,s016880723,Accepted,"import sys N,K,X,Y=[int(input()) for i in range(4)] if (N >= K): sum = K * X + (N - K) * Y else: sum = N * X print(sum)" p02933,s036615127,Wrong Answer,"if int(input()) >= 3200: print(""red"") else: print(input())" p03605,s067935044,Accepted,"def main(): print(""Yes"" if ""9"" in input() else ""No"") if __name__ == '__main__': main() " p02819,s870781037,Accepted,"X = int(input()) while True: i = 2 while i * i <= X: if X % i == 0: break i += 1 else: print(X) break X += 1" p03799,s651881763,Accepted,"s, c = map(int, input().split()) if c//2 - s > 0: ans = s + (c - 2*s)//4 else: ans = c//2 print(ans)" p02691,s359711569,Wrong Answer,"n=int(input()) a=list(map(int,input().split())) needsearch=[] for i in range(n): a[i]-=(i+1) needsearch.append(-2*(i+1)-a[i]) counter=[0]*(2*(10**5)) for i in range(n): if 00::2]) p03017,s583795409,Accepted,"import sys n,a,b,c,d = map(int, input().split()) s = input() tmp = """" for i in range(a,c): if s[i] == tmp == ""#"": print(""No"") sys.exit() tmp = s[i] for i in range(b,d): if s[i] == tmp == ""#"": print(""No"") sys.exit() tmp = s[i] if c < d: print(""Yes"") sys.exit() else: cnt = 0 for i in range(b-2,d+1): if s[i] == ""."": cnt += 1 if cnt == 3: print(""Yes"") sys.exit() else: cnt = 0 print(""No"")" p02594,s654382082,Wrong Answer,"a = ""7"" i = 1 n = int(input()) if(n % 2 == 0): print(""-1"") else: while True: if(int(a) % n == 0 and int(a) / n != 0): break i += 1 a = a + ""7"" print(i)" p03417,s149562497,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((m-2)*(n-2))" p03073,s584085068,Accepted,"s = list(input()) ans = 0 for i in range(1,len(s)): if s[i-1] == '1' and s[i] == '1': s[i] = '0' ans += 1 elif s[i-1] == '0' and s[i] == '0': s[i] = '1' ans += 1 print(ans) " p03612,s266712891,Accepted,"n=int(input()) L=list(map(int,input().split())) cnt=0 p=0 for i in range(n): if L[i]==i+1: if p==1: p=0 else: cnt+=1 p=1 else: p=0 print(cnt) " p02773,s376791294,Wrong Answer,"from collections import Counter n = int(input()) s = [input() for i in range(n)] s.sort() c = Counter(s) m = c.most_common()[0][1] for i in c.most_common(): if i[1] == m: print(i[0])" p03250,s513046578,Accepted,"import sys sys.setrecursionlimit(10**9) INF=10**18 MOD=10**9+7 def input(): return sys.stdin.readline().rstrip() def main(): A,B,C=map(int,input().split()) M=max(A,B,C) ans=M*10 f=False for x in A,B,C: if x!=M or f: ans+=x else: f=True print(ans) if __name__ == '__main__': main() " p02730,s867867944,Accepted,"S=input() N=len(S) def is_palindrome(s): return s==s[::-1] S_all=is_palindrome(S) S_forward=is_palindrome(S[:(N-1)//2]) S_rear=is_palindrome(S[(N+3)//2-1:]) if (S_all==True and S_forward==True) and S_rear==True: print(""Yes"") else: print(""No"")" p02594,s404142931,Accepted,"x = int(input()) print(""Yes"" if x >29 else ""No"")" p02779,s347733611,Accepted,"n = int(input()) a = input().split() if (len(a) == len(set(a))): print(""YES"") else: print(""NO"")" p02847,s225247137,Accepted,"days = ['SUN','MON','TUE','WED','THU','FRI','SAT'] s = input() x = days.index(s) print(7-x)" p03456,s624088346,Accepted,"from math import sqrt s = input().split() t = sqrt(int(''.join(s))) print('Yes' if t.is_integer() else 'No')" p02642,s471245456,Accepted,"n = int(input()) a = list(map(int, input().split())) a_max = max(a) cnt = [0] * (max(a) + 1) ans = 0 for ai in a: for multi in range(ai, a_max + 1, ai): cnt[multi] += 1 for ai in a: if cnt[ai] == 1: ans += 1 print(ans)" p03543,s707659514,Accepted,"N = input() n1 = N[0] n2 = N[1] n3 = N[2] n4 = N[3] if (n1 == n2 == n3) or (n2 == n3 == n4): print(""Yes"") else: print(""No"") " p03475,s218783137,Accepted,"n=int(input()) CSF=[] for _ in range(n-1): CSF.append(list(map(int,input().split()))) result=[] for i in range(n-1): temp=CSF[i][1]+CSF[i][0] j=i+1 while j= n-four-1: print('Yes') else: print('No') " p04030,s536365828,Accepted,"s = list(input()) nows = [] for x in s: if x == ""B"": if len(nows) == 0: continue else: nows.pop(-1) else: nows.append(x) print("""".join(nows)) " p02946,s478240354,Wrong Answer,"K,X = map(int,input().split()) for i in range((K-X+1),(K+X)): print(i,end="" "") " p03456,s150476650,Wrong Answer,"import math def main(): a, b = map(int, input().split()) r = math.sqrt(int(a + b)) if r**2 == int(a + b): print(""Yes"") else: print(""No"") main()" p03037,s634450527,Wrong Answer,"n,m = map(int,input().split()) l = list(list(map(int,input().split())) for _ in range (m)) a = l[0][0] b = l[0][1] for s,t in l: a = max(a,s) b = min(b,t) print(b-a+1) " p02843,s270789376,Wrong Answer,"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)''' x=int(input()) ok=[0]*100001 ok[100]=1 if x<100: print(0) sys.exit() a=[100,101,102,103,104,105] for i in range(100,x): for item in a: if i-item>=0 and ok[i-item]==1: ok[i]=1 print(ok[x-1])" p02665,s900223306,Accepted,"n,*a=map(int,open(0).read().split()) t,v=sum(a),[1] for q in a: v+=[min(2*(v[-1]-q),t:=t-q)] if v[-1]<0:print(-1);exit() print(sum(v))" p04012,s324383020,Accepted,"import collections w = input() W = collections.Counter(w) bl = True v = W.values() for i in v: if i&1: bl = False print('Yes' if bl else 'No')" p02615,s820316149,Accepted,"from collections import deque n = int(input()) a = [int(_) for _ in input().split()] aa = deque(sorted(a, reverse=True)) ans = aa.popleft() for i in range(n-2): if i % 2 == 0: comf = aa.popleft() ans += comf #print(ans) print(ans)" p03043,s936244391,Wrong Answer,"n, k = map(int, input().split()) if n > k: ans = (n-k+1) else: ans = 0 for i in range(1, min(n+1, k)): cnt = 0 score = i while score < k: score *= 2 cnt += 1 ans += pow(1/2, cnt) ans /= n print(ans) " p02767,s547029595,Accepted,"n = int(input()) x = list(map(int, input().split())) x_ave = sum(x) // n def moment(val): list_init = [0]*n for i in range(n): list_init[i] = (x[i] - val)**2 return(sum(list_init)) print(min(moment(x_ave), moment(x_ave + 1))) " p03472,s464235645,Wrong Answer,"n, h = map(int, input().split()) l = [] for i in range(n): l.append(list(map(int,input().split()))) l = sorted(l, key=lambda x: x[1]) l = sorted(l, reverse=True, key=lambda x: x[0]) c_a = 0 c_b = 0 b_sum = 0 for i in range(1, n): if l[i][1] > l[0][0]: b_sum += l[i][1] c_b += 1 while h-b_sum > l[0][1]: h -= l[0][0] c_a += 1 h -= l[0][1] if h <= 0: print(c_a+1) else: print(c_a+1+c_b) " p03331,s535784691,Wrong Answer," import sys import numpy as np input = sys.stdin.readline N = input() sum_ = 0 for i in list(N)[:-1]: sum_+=int(i) print(sum_)" p02690,s885348239,Accepted,"x=int(input()) ans=[] for a in range(1001): for b in range(-1000,1001): if a==b==0: pass else: if x%(a**4+a*a*a*b+a*a*b*b+a*b*b*b+b**4)==0: if a**5-b**5==x: print(a,b) exit()" p04011,s380995067,Wrong Answer,"n, k, x, y = (int(input()) for i in range(4)) if k <= n: print(k*x) else: print(k*x + (n-k)*y)" p03557,s746506494,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()))) count = 0 for b in B: a = bisect.bisect_left(A,b) c = bisect.bisect_right(C,b) count += a*(N-c) print(count)" p02554,s897067867,Accepted,"n = int(input()) a,b,c = 1,1,1 for i in range(n): a *= 10 b *= 9 c *= 8 a %= 10** 9 + 7 b %= 10** 9 + 7 c %= 10** 9 + 7 print((a - 2 * b +c)%(10** 9 + 7))" p03086,s071153629,Wrong Answer,"s = input() sl = len(s) l = [0]*sl c = 0 ans = 0 for i in range(sl): if s[i] == ""A"" or s[i] == ""C"" or s[i] == ""G"" or s[i] == ""T"": l[i] = 1 for i in range(sl): if l[i] == 1: c += 1 else: ans = max(ans, c) c = 0 print(ans)" p03416,s345441699,Wrong Answer,"A,B = map(str,input().split()) La = [int(A[:3]),int(A[3:])] Lb = [int(B[:3]),int(B[3:])] L = 900 - (La[0] - 100) - (999 - Lb[0]) ch1 = int(A[1] + A[0]) ch2 = int(B[1] + B[0]) if Lb[1] <= ch2: L -= 1 if ch1 <= La[1]: L -= 1 print(L) " p02576,s381449231,Accepted,"N,X,T = map(int,input().split()) ans = ( (N-1) // X + 1 ) * T print(ans)" p02983,s951377072,Accepted,"L, R = map(int, input().split()) M = (L+2019-1)//2019*2019 if M<=R: print(0) exit() ans = 10**18 for i in range(L, R): for j in range(i+1, R+1): ans = min(ans, i*j%2019) print(ans)" p02994,s628080662,Accepted,"N,L = map(int,input().split()) l = [0] * N for i in range(N): l[i] = L + i ans = sum(l) res = 10 ** 9 d = 0 for i in range(N): tmp = l[:i] + l[i+1:] solve = sum(tmp) c = abs(ans - solve) if(res > c): res = c d = solve print(d)" p03385,s700236356,Accepted,"S = list(input()) S.sort() a = ['a','b','c'] if S == a: print('Yes') else: print('No')" p04044,s113149111,Accepted,"import sys input = sys.stdin.readline def log(*args): print(*args, file=sys.stderr) def main(): N, _L = map(int, input().rstrip().split()) s = [input().rstrip() for _ in range(N)] print(''.join(sorted(s))) if __name__ == '__main__': main() " p02729,s840496975,Wrong Answer,"N,M=map(int,input().split()) print(N*(N-1)/2+M*(M-1)/2)" p03327,s405677481,Wrong Answer,"N = int(input()) if 999<=N <= 1000: print('ABC') else: print('ABD') " p02838,s879747444,Accepted," def resolve(): MOD = 10 ** 9 + 7 N = int(input()) A = list(map(int, input().split())) ans = 0 for i in range(60): p = 1 << i one = sum([1 for a in A if a & p]) zero = N - one ans += p * one * zero ans %= MOD print(ans) if __name__ == ""__main__"": resolve() " p02600,s506512847,Accepted,"X = int(input()) if X>=400 and X <=599: print(""8"") if X>=600 and X <=799: print(""7"") if X>=800 and X <=999: print(""6"") if X>=1000 and X <=1199: print(""5"") if X>=1200 and X <=1399: print(""4"") if X>=1400 and X <=1599: print(""3"") if X>=1600 and X <=1799: print(""2"") if X>=1800 and X <=1999: print(""1"")" p03095,s122661370,Accepted,"def main(): MOD = 10**9 + 7 n = int(input()) s = input().rstrip() alp = [1]*26 ans = 0 for c in s: p = ord(c) - ord(""a"") alp[p] += 1 x = 1 for i in range(26): if i == p: continue x *= alp[i] x %= MOD ans += x ans %= MOD print(ans) if __name__ == ""__main__"": main()" p03565,s373174930,Accepted,"import re s = """".join(""."" if i == ""?"" else i for i in input()) t = input() lent = len(t) mstart = -1 for start in range(len(s) - lent + 1): m = re.match(re.compile(s[start:start+lent]), t) if m: mstart = start else: if mstart == -1: print(""UNRESTORABLE"") else: s = s[:mstart] + t + s[mstart+lent:] print(s.replace(""."", ""a""))" p02778,s489791801,Accepted,"print(""x"" * len(input()))" p03252,s959336484,Accepted,"import collections s=list(input()) t=list(input()) ss=collections.Counter(s) tt=collections.Counter(t) s_v = sorted(ss.values()) t_v = sorted(tt.values()) if s_v == t_v: print(""Yes"") else: print(""No"") " p02572,s019637669,Accepted,"n = int(input()) a = list(map(int,input().split())) mod = 10**9 + 7 s = sum(a) ans = 0 for i in a: s -= i s %= mod ans += s*i ans %= mod print(ans)" p03632,s388384789,Accepted,"A, B, C, D = map(int, input().split()) print(max(min(B, D)-max(A, C), 0))" p02854,s662178752,Accepted,"n=int(input()) a=list(map(int, input().split())) d=sum(a) ans=d for i in range(n): d=d-2*a[i] if abs(d)=X: ans = min(ans,t_ans) if ans < maxi: print(ans) else: print(-1)" p04011,s544207967,Accepted,"def problemA(): N = int(input()) K = int(input()) X = int(input()) Y = int(input()) if N <= K: ans = N*X else: ans = K*X + (N-K)*Y print(ans) if __name__ == '__main__': problemA()" p02766,s726906148,Accepted,"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) N, K = list(map(int, input().split())) ans = Base_10_to_n(N, K) print(len(ans)) " p03385,s564219463,Accepted,"s = input() if s.count('a') == 1 and s.count('b') == 1 and s.count('c') == 1: print('Yes') else: print('No')" p02777,s771453312,Accepted,"S,T = input().split() A,B = map(int,input().split()) U = input() if S == U: A -= 1 else: B -= 1 print(A,B)" p04030,s219926303,Wrong Answer,"s = input() s = s[::-1] news = """" c = 0 for i in range(len(s)): if s[i] == ""B"": c += 1 elif c == 0: news += s[i] else: c = 0 print(news)" p02633,s338186506,Accepted,"a=int(input()) x = 0 i = 0 while(1): x += a i += 1 x %= 360 if x: continue else: print(i) quit()" p02659,s063445499,Accepted,"a, b = input().split() a = int(a) for i in range(len(b)): if b[i] == '.': t = 10 ** (len(b)-1-i) nb = int(b[:i] + b[i+1:]) print(a*nb//t)" p03612,s676206025,Accepted,"N = int(input()) arr = list(map(int, input().split())) flg = False ans = 0 for i in range(N): if flg: flg = False continue if arr[i] == i + 1: flg = True ans += 1 print(ans)" p03107,s606498408,Wrong Answer,"s=list(input()) from collections import Counter d=Counter(s) print(min(d[0], d[1])*2) " p02796,s478345465,Accepted,"N = int(input()) X = [0]*N for i in range(N): X[i] = [0]*2 x, l = map(int, input().split()) X[i][1] = x - l X[i][0] = x + l X = sorted(X) nowplace = X[0][0] ans = 1 for j in range(1, N): if nowplace <= X[j][1]: ans += 1 nowplace = X[j][0] print(ans) " p03243,s951976601,Accepted,"# EASY!数値をintでリスト化する方法を学んだ n = int(input()) l = list(map(int,list(str(n)))) #print(l) x = int(str(l[0])+str(l[0])+str(l[0])) y = int(str(l[0]+1)+str(l[0]+1)+str(l[0]+1)) if n <= x: print(x) else: print(y) " p02862,s172885202,Accepted,"x, y = map(int, input().split()) mod = 10 ** 9 + 7 def choose(n, r): cx = 1 cy = 1 for i in range(r): cx = cx * (n - i) % mod cy = cy * (i + 1) % mod cy = pow(cy, mod - 2, mod) return cx * cy % mod if (x + y) % 3 != 0: print(0) exit() else: n = (x + y) // 3 x -= n y -= n if x < 0 or y < 0: print(0) exit() print(choose(x + y, x)) " p03131,s147497627,Wrong Answer,"K, A, B = map(int, input().split()) ans = 0 if K % 2 == 0: ans = max(K+1, K//2*(B-A) - (A-1)) else: ans = max(K+1, (K-1)//2 *(B-A) - A) print(ans) " p02594,s658541917,Wrong Answer,"x = int(input()) if x >= 30: print(""Yes"") else: print(""N0"")" p02612,s993221214,Accepted,"N=int(input()) 1<=N<=10000 if((N%1000)==0): print(""0"") else: print(1000-(N%1000))" p03331,s259703284,Wrong Answer,"n = int(input()) res = float('inf') for a in range(int(n/2)+1): b = n-a tmp = 0 for c in str(a): tmp += int(c) for c in str(b): tmp += int(c) res = min(res, tmp) print(res)" p02546,s099683956,Wrong Answer,"S = input() if S.endswith('e') : print(S+'s') elif S.endswith('s'): print(S+'es') else: print(S) " p02612,s110930078,Accepted,"N=int(input()) if N<=1000: print(1000-N) if 2000>=N>1000: print(2000-N) if 3000>=N>2000: print(3000-N) if 4000>=N>3000: print(4000-N) if 5000>=N>4000: print(5000-N) if 6000>=N>5000: print(6000-N) if 7000>=N>6000: print(7000-N) if 8000>=N>7000: print(8000-N) if 9000>=N>8000: print(9000-N) if 10000>=N>=9000: print(10000-N)" p02555,s929405399,Accepted,"def func(num, memo): if memo[num] != -1: return memo[num] ans = 0 if num == 0: return 1 if num < 3: return ans for i in range(3, num + 1): ans += func(num - i, memo) ans %= 10 ** 9 + 7 memo[num] = ans return ans s = int(input()) memo = [-1] * (s + 1) if s < 3: print(0) else: print(func(s, memo)) " p02583,s949395817,Accepted,"n = int(input()) l = sorted(list(map(int, input().split()))) ans = 0 ed = [] for i in range(n): for j in range(i): for k in range(j): if (l[k] != l[j] and l[i] != l[j] and l[k] + l[j] > l[i]):ans+=1 print(ans)" p03605,s992924065,Accepted,"n = input() if ""9"" in n: print(""Yes"") else: print(""No"")" p02706,s834778743,Accepted,"N,M=input().split() N=int(N) M=int(M) A=[int(x) for x in input().split()] i=0 sum_A=0 result=0 if (1<=N<=10**6)and(1<=M<=10**4): for i in range(0,M): if 1<=A[i]<=10**4: sum_A+=A[i] i+=1 result=N-sum_A if result<0: print(-1) else: print(result)" p03323,s563487390,Accepted,"a,b=map(int,input().split()) print(""Yay!"" if a<=8 and b<=8 else "":("")" p03435,s513545800,Accepted,"g=[[*map(int,input().split())]for _ in range(3)] for h in [0,1]: for w in [0,1]: if g[h][w]+g[h+1][w+1]!=g[h+1][w]+g[h][w+1]: exit(print('No')) print('Yes')" p02761,s596636954,Accepted,"# 別解: 総当たり(Brute Force)で解く n, m = [int(i) for i in input().split()] s = [] c = [] for _ in range(m): i, k = [int(i) for i in input().split()] s.append(i) c.append(k) res = -1 start = 10**(n-1) if n > 1 else 0 for i in range(start, 10**n): i2s = str(i) for ss, cc in zip(s, c): if i2s[ss-1] != str(cc): break else: res = i break print(res) " p03495,s231190583,Accepted,"import itertools import math import sys from collections import Counter from fractions import gcd from functools import reduce n, k = map(int, input().split()) a = list(map(int, input().split())) cnt = Counter(a).most_common()[::-1] # print(cnt) # print(cnt) ans = 0 for i in range(len(cnt) - k): ans += cnt[i][1] print(ans) " p02789,s220331142,Accepted,"N, M = map(int, input().split()) print(""Yes"") if M == N else print(""No"")" p02917,s764738660,Wrong Answer,"n=int(input()) b=list(map(int,input().split())) a=[] a.append(b[0]) for i in range(1,n-1) : if b[i-1] < b[i] : a.append(b[i-1]) else : a.append(b[i]) a.append(b[n-2]) print(a) print(sum(a))" p03379,s818540616,Accepted,"a = int(input()) b = list(map(int,input().split())) c = sorted(b, reverse=True) m = int(a / 2) - 1 anslist = [0] * a for i, data in enumerate(b): if c[m] > data: anslist[i] = c[m] elif c[m] <= data: anslist[i] = c[m + 1] for j in range(a): print(anslist[j])" p02595,s762353690,Accepted,"N, D = [int(_) for _ in input().split()] ans = 0 for i in range(N): X, Y = [int(_) for _ in input().split()] if X * X + Y * Y <= D * D: ans += 1 print(ans) " p03475,s057150213,Accepted,"import math 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 i in range(N - 1): count = 0 count += S[i] count += C[i] for j in range(i + 1, N - 1): if count < S[j]: count = S[j] else: count = math.ceil((count - S[j]) / F[j]) * F[j] + S[j] count += C[j] print(count) print(0) " p03625,s782121707,Accepted,"import collections N = int(input()) A = list(map(int,input().split())) c = collections.Counter(A) ans = [i[0] for i in c.items() if i[1] >= 2] ans.extend([i[0] for i in c.items() if i[1] >= 4]) ans.extend([0,0]) ans.sort(reverse=True) print(ans[0]*ans[1])" p02747,s351563402,Accepted,"s = input() if s == ""hi"" * int(len(s) / 2): print(""Yes"") else: print(""No"")" p03075,s299958506,Accepted,"l = [] cnt = 0 for i in range(5): l.append(int(input())) k = int(input()) for i in range(len(l)): for j in range(len(l)): if i < j and abs(l[i] - l[j]) <= k: cnt += 1 if cnt == 10: print('Yay!') else: print(':(')" p02689,s390485672,Accepted,"n, m = map(int, input().split()) height = [0] + list(map(int, input().split())) mawari = [0] * (n+1) ans = 0 for _ in range(m): a, b = map(int, input().split()) mawari[a] = max(mawari[a], height[b]) mawari[b] = max(mawari[b], height[a]) for i in range(1,n+1): if height[i]> mawari[i]: ans += 1 print(ans)" p02683,s069226247,Accepted,"import numpy N,M,X = map(int,input().split()) A = numpy.array([[int(i) for i in input().split()] for _ in range(N)]) ans = 10**8 for i in range(2**N) : i = format(i,'b').zfill(N) check = numpy.array([0]*(M+1)) for j in range(N) : if i[j] == '0' : continue check += A[j][0:] if all (check[m] >= X for m in range(1,M+1)) : ans = min(ans,check[0]) if ans == 10**8 : print(-1) else : print(ans)" p02598,s583412006,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//2) ans = abs(a[0]) print(ans) if __name__ == '__main__': main()" p02983,s326956752,Accepted,"#!/usr/bin/env python # coding: utf-8 # In[27]: L,R = map(int, input().split()) # In[30]: MOD = 2019 res = MOD if R - L < MOD: for l in range(L, R): for r in range(l+1, R+1): res = min(res, (l * r) % MOD) else: res = 0 print(res) " p03327,s486657350,Accepted,"N = contest_numer =int(input()) if contest_numer > 999 and 1998 >= contest_numer: print(""ABD"") elif contest_numer > 0 and 999 >= contest_numer: print(""ABC"") else: print(""contest that you inputted now has not been held"")" p03827,s926609814,Accepted,"n = int(input()) s = input() ans = 0 x = 0 for c in s: if c == 'I': x += 1 else: x -= 1 ans = max(ans, x) print(ans)" p03998,s167325550,Accepted,"A = list(input()) B = list(input()) C = list(input()) now = ""a"" d = {""a"": A, ""b"": B, ""c"": C} while A or B or C: if not d[now]: print(now.upper()) break else: now = d[now].pop(0) " p03338,s360946229,Wrong Answer,"n = int(input()) S = input().strip() print(max(len(set(S[i+1:]) & set(S[:i])) for i in range(n)))" p03698,s213892648,Accepted,"S = input() used = set([s for s in S]) if (len(S) - len(used) == 0): print(""yes"") else: print(""no"") " p02552,s736992388,Wrong Answer,print(int(not bool(input()))) p02742,s072789188,Accepted,"H, W = map(int, input().split()) if H == 1: print(1) elif W == 1: print(1) else: print(-((-H * W)//2))" p03617,s750696903,Accepted,"# row = [int(x) for x in input().rstrip().split("" "")] # n = int(input().rstrip()) # s = input().rstrip() def resolve(): import sys input = sys.stdin.readline q, h, s, d = [int(x) for x in input().rstrip().split("" "")] n = int(input().rstrip()) h = h if h < 2 * q else 2 * q s = s if s < 2 * h else 2 * h d = d if d < 2 * s else 2 * s ans = 0 ans += (n // 2) * d n = n % 2 ans += n * s print(ans) if __name__ == ""__main__"": resolve() " p02664,s930814103,Accepted,"t = input() u = [] for i in range(len(t)): if t[i] == '?': u.append('D') else: u.append(t[i]) u = ''.join(u) print(u)" p02548,s128067600,Accepted,"#c N=int(input()) ans=0 for i in range(1,N): s = N//i if i*s = n: ans = max(ans,i) if i >= n: ans = max(ans,x) print(ans)" p03061,s524812812,Accepted,"n=int(input()) A=list(map(int,input().split())) L,R=[0]*n,[0]*n L[0],R[-1]=A[0],A[-1] from fractions import gcd for i in range(1,n): L[i]=gcd(A[i],L[i-1]) for i in range(n-2,-1,-1): R[i]=gcd(A[i],R[i+1]) ans=max([L[-2],R[1]]+[gcd(L[i-1],R[i+1])for i in range(1,n-1)]) print(ans)" p02683,s893278221,Accepted,"import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline import numpy as np from itertools import product n, m, x = map(int, readline().split()) ca = np.array(read().split(), np.int64).reshape((n, m + 1)) INF = 10 ** 9 c = ca[:, 0] a = ca[:, 1:].T ans = INF for p_li in product([1, 0], repeat=n): p = np.array(p_li) rikai = a * p sm = rikai.sum(axis=1) if sm.min() >= x: cost = (c * p).sum() ans = min(ans, cost) if ans == INF: ans = -1 print(ans) " p03011,s322572948,Accepted,"s = list(map(int, input().split())) s.sort() print(s[0]+s[1])" p02546,s049226789,Accepted,"def main(): S = input() if S[-1] == ""s"": print(S + ""es"") else: print(S + ""s"") if __name__ == '__main__': main() " p03261,s930358674,Accepted,"N = int(input()) A = [] A.append(""shiritori"") for i in range(N): t = input() if t in A or i != 0 and t[0] != A[i][-1]: print('No') exit() else: A.append(t) print('Yes')" p02982,s020533820,Accepted,"import numpy N, D = map(int, input().split()) lstMain = list() for i in range(0, N): lstMain.append(list(map(int, input().split()))) count = 0 for i in range(0, N): for j in range(i+1, N): y = numpy.array(lstMain[i]) z = numpy.array(lstMain[j]) u = z - y distance = float(numpy.linalg.norm(u)) if distance.is_integer(): count += 1 print(count)" p03417,s123577647,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))" p03817,s377391201,Accepted,"X=int(input()) Q,R=divmod(X,11) if R==0: K=0 elif 1<=R<=6: K=1 else: K=2 print(2*Q+K)" p02719,s820304032,Accepted,"N, K = map(int, input().split()) if N >= 2*K: s = N // K print(min(abs(N - s * K), abs(N- (s+1) * K))) else: print(min(abs(N-K), abs(abs(N-K)-K)))" p03359,s024268719,Wrong Answer,"a,b=map(int,input().split()) print(min(a,b))" p04020,s087840342,Accepted,"N = int(input()) pre = int(input()) ans = pre // 2 for _ in range(N - 1): i = int(input()) if pre % 2 == 1 and i > 0: i -= 1 ans += 1 ans += i // 2 pre = i print(ans) " p02744,s801928494,Accepted,"N = int(input()) tmp = [[1]] answer = tmp for i in range(N - 1): tmp = [] for a in answer: max_a = max(a) for j in range(1, max_a + 2): tmp.append(a + [j]) answer = tmp answer.sort() def alpha(l): res = """" for ll in l: res += chr(ll + ord(""a"") - 1) return res for a in answer: print(alpha(a))" p03910,s075095926,Accepted,"n = int(input()) num_sum = 0 max_num = 1 for i in range(n+1): num_sum += i if num_sum >= n: max_num = i break for i in range(1, max_num+1): if i != num_sum - n: print(i) " p03644,s212309219,Accepted,"N=int(input()) print(2**(N.bit_length()-1))" p03485,s629122128,Accepted,"import math a, b = map(int, input().split()) ave = (a + b) / 2 print(math.ceil(ave))" p02783,s787798401,Accepted,"h, a = map(int, input().split()) if (h % a == 0): print(h // a) else: print(h // a + 1) " p02556,s209077796,Accepted,"n=int(input()) p=[] q=[] for _ in range(n): x,y=map(int,input().split()) p.append(x+y) q.append(x-y) print(max(max(p)-min(p),max(q)-min(q)))" p02603,s472222622,Wrong Answer,"N = int(input()) L = list(map(int, input().split())) money = 1000 stocks = 0 for i in range (0, N-1): if L[i+1] > L[i]: stocks = money//L[i] money = money%L[i] else: money+= stocks*L[i] stocks = 0 print(money+stocks*L[-1])" p02768,s109622466,Accepted,"n,a,b = map(int,input().split()) mod=7+10**9 ans = pow(2 , n , mod) def comb(n,c,mod): s=1 t=1 for i in range(1,c+1): s=s*i%mod for j in range(n-c+1,n+1): t=t*j%mod return (t*pow(s,mod-2,mod))%mod print((ans-1-comb(n,a,mod)-comb(n,b,mod))%mod)" p03759,s858114024,Accepted,"# -*- coding: utf-8 -*- a, b, c = map(int, input().split()) print(['NO','YES'][b - a == c - b]) " p02689,s149690181,Accepted,"n,m=[int(x) for x in input().split()] h=[int(x) for x in input().split()] t=[[]for i in range(n)] ans=0 for i in range(m): a,b=[int(x) for x in input().split()] t[a-1].append(b-1) t[b-1].append(a-1) for i in range(n): if t[i]==[]: ans+=1 else: c=[] for j in t[i]: if h[i]<=h[j]: c.append(False) if c==[]: ans+=1 print(ans)" p03380,s542247885,Wrong Answer,"from math import factorial import numpy as np def comb(n, r): return factorial(n) // factorial(r) // factorial(n-r) def ABC094D(n, a): a = sorted(a)[::-1] Max = comb(a[0], a[1]) n = int(input()) a = list(map(int, input().split())) ABC094D(n, a)" p02918,s038403559,Accepted,"n, k = map(int, input().split()) s = input() ans = 0 for i in range(len(s)-1): if s[i] == s[i+1]: ans += 1 print(min(n-1, ans + 2*k))" p02989,s772072933,Wrong Answer,"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=int(input()) A=[(e,i) for i,e in enumerate(list(map(int,input().split())))] print(A) A.sort(key=lambda tup: tup[0]) print(A) for e,i in A: print(e, i+1)" p03485,s293188840,Wrong Answer,"a, b = map(int, input().split()) ave = (a + b) / 2 if ave % 2 == 0: print(int(ave)) else: ave = int(ave) ave = ave + 1 print(ave)" p03309,s168787625,Accepted,"N=int(input()) a=list(map(int,input().strip().split())) a=[a[n]-(n+1) for n in range(N)] a.sort() result=sum(a[N//2:N])-sum(a[:N//2]) if N%2==0 else sum(a[N//2+1:N])-sum(a[:N//2]) print(result)" p03720,s624392189,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 j in range(n): print(ans[j])" p03592,s374503029,Accepted,"n,m,k=map(int,input().split()) ans=0 for i in range(0,n+1): for j in range(0,m+1): if m*i+(n-i*2)*j==k: ans=1 break if ans==1: print(""Yes"") break else: print(""No"")" p03324,s143044167,Accepted,"x,y = map(int,input().split()) if y == 100: y += 1 print((100**x)*y)" p02801,s459989149,Accepted,"s = input() print(chr(ord(s)+1))" p02784,s233356614,Accepted,"H,N = map(int,input().split()) Ai = map(int, input().split()) if sum(Ai) >= H: print('Yes') else: print('No')" p03331,s823337315,Accepted,"import sys def input(): return sys.stdin.readline().strip() def mapint(): return map(int, input().split()) sys.setrecursionlimit(10**9) N = int(input()) MIN = 10**18 for i in range(1, N): val = 0 a, b = i, N-i while a or b: x = a%10 y = b%10 val += (x+y) a //=10 b //= 10 MIN = min(MIN, val) print(MIN)" p02596,s795862097,Wrong Answer,"k = int(input()) x = ""7"" n = 10 c = 1 if k >=7: while n>0: if int(x) % k == 0 : break c+=1 x += ""7"" n-=1 print(c)" p04034,s755814783,Wrong Answer,"n,m=map(int,input().split()) xy=[] for _ in range(m): x,y=map(int,input().split()) xy.append([x,y]) ball=[1]*n red=[0]*n red[0]+=1 for i in range(m): if red[xy[i][0]-1]>=1: if ball[xy[i][0]-1]==1: red[xy[i][0]-1]-=1 red[xy[i][1]-1]+=1 ball[xy[i][0]-1]-=1 ball[xy[i][1]-1]+=1 ans=len(red)-red.count(0) print(ans)" p04045,s003394563,Wrong Answer,"def check(array, string): for i in array: if i in string: return False return True N, K = map(int, input().split()) D = input().split() for i in range(1, 10001): if check(D, str(i)) and i >= N: print(i) exit(0)" p02552,s283720393,Accepted,"a = int(input()) print(1 if a==0 else 0)" p03042,s489191701,Accepted,"s = input() s1 = int(s[:2]) s2 = int(s[2:]) m = range(1,13) if s1 in m and s2 in m: print('AMBIGUOUS') elif s1 in m: print('MMYY') elif s2 in m: print('YYMM') else: print('NA')" p03795,s880639727,Accepted,"n = int(input()) cost_paid = 800 * n cost_saved = 200 * (n//15) print(cost_paid - cost_saved)" p04043,s186308606,Accepted,"a=input().split() if a.count('5') == 2: if a.count('7')==1: print('YES') else: print('NO')" p04019,s895086117,Accepted,"s = input() if not(('N' in s) ^ ('S' in s)) and not(('W' in s) ^ ('E' in s)): print('Yes') else: print('No')" p03774,s783609709,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)] ans = [] for i in range(n): dis = [] for j in range(m): dis.append(abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])) ans.append(dis.index(min(dis)) + 1) for i in ans: print(i)" p03351,s970063821,Accepted,"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 print('No')" p02675,s715614565,Wrong Answer,"def main(): n = list(input())[-1] if n in [2, 4, 5, 7, 9]: ans = 'hon' elif n in [0, 1, 6, 8]: ans = 'pon' else: ans = 'bon' print(ans) if __name__ == ""__main__"": main() " p02681,s849693652,Wrong Answer,"list = [input() for i in range(2)] s = list[0] t = list[1] lens = len(s) lent = len(t) if s in t and lent-lens==1 and 1<=lens<=10: print(""Yes"") else: print(""No"")" p03625,s490063175,Accepted,"n=int(input()) a=list(map(int,input().split())) from collections import Counter c=Counter(a).items() f=0 s=0 for k,v in c: if v>=4: if k>f: s=k f=k elif k>s: s=k if v>=2: if k>f: s=f f=k elif k>s: s=k print(s*f) " p02754,s929639562,Accepted,"n,a,b = [int(x) for x in input().split()] print((n//(a+b))*a + min(n % (a+b), a))" p02594,s612514420,Accepted,"x = int(input()) if x >= 30: print(""Yes"") else: print(""No"")" p03219,s907375234,Wrong Answer,"X,Y=map(int,input().split()) print(X+Y/2)" p02730,s048758972,Accepted,"import numpy as np S = list(input()) N = len(S) A = [] B = [] for i in range((N-1)//2): A.append(S[i]) for j in range((N-1)//2): B.append(S[((N+3)//2)+(j-1)]) C = list(reversed(A)) D = list(reversed(B)) E = list(reversed(S)) if np.count_nonzero(np.array(A) == np.array(C)) == np.count_nonzero(np.array(B) == np.array(D)) == len(A) and np.count_nonzero(np.array(S) == np.array(E)) == len(S): print(""Yes"") else: print(""No"")" p02831,s455445810,Accepted,"import math A,B=map(int,input().split()) lcm=A*B/math.gcd(A,B) print(int(lcm))" p02947,s111574742,Wrong Answer,"n = int(input()) s = [list(input()) for i in range(n)] cnt_dic = {} sum_cnt = 0 for i in range(n): s[i].sort() if str(s[i]) in cnt_dic: cnt_dic[str(s[i])] = cnt_dic[str(s[i])] + 1 else: cnt_dic[str(s[i])] = 1 for i in range(len(cnt_dic)): sum_cnt += int((cnt_dic[str(s[i])] * (cnt_dic[str(s[i])] - 1) )/ 2) print(sum_cnt)" p03379,s599787517,Wrong Answer,"# input N = int(input()) X = list(map(int, input().split())) # check l, r = N // 2 - 1, N // 2 sort_x = sorted(X) lx, rx = sort_x[l], sort_x[r] for ind in range(N): target = X[ind] if target <= lx: print(rx) if target >= rx: print(lx)" p02982,s135194222,Accepted,"import numpy as np N, D = map(int, input().split()) x = [] for i in range(N): x.append(list(map(int, input().split()))) x = np.array(x) ans = 0 for i in range(N-1): for j in range(i+1,N): tmp = sum((x[i]-x[j])**2) for k in range(1,tmp+1): if tmp == k**2: ans += 1 break print(ans)" p02615,s149606762,Accepted,"n = int(input()) a = list(map(int, input().split())) newa = [] for num in a: newa.append(num) newa.append(num) newa.sort(reverse=True) ans=sum(newa[1:n]) print(ans)" p03001,s606900431,Accepted,"# そうか、長方形の中心を通れば全ての長方形を二等分できるのか W,H,x,y = map(int,input().split()) if W / 2 == x and H / 2 == y: ans = 1 else: ans = 0 print(W*H/2,ans)" p02777,s293593892,Accepted,"a,b=list(map(str,input().split())) s,t=map(int,input().split()) u=str(input()) if u == a: print(s-1,t) else: print(s,t-1)" p02623,s894461020,Accepted,"from bisect import bisect_right from itertools import accumulate n,m,k=map(int,input().split()) a=list(map(int,input().split())) b=list(map(int,input().split())) a_ac=[0]+list(accumulate(a)) b_ac=[0]+list(accumulate(b)) ans=0 for i in range(n+1): remain=k-a_ac[i] if remain<0: continue t_ans=i t_ans+=bisect_right(b_ac,remain)-1 ans=max(ans,t_ans) print(ans)" p03359,s568427860,Accepted,"a,b=map(int,input().split()) if a>b: a-=1 print(a)" p03351,s298363941,Accepted,"a,b,c,d=map(int,input().split()) if abs(c-a) <= d: print('Yes') else: if abs(a-b) <= d and abs(b-c) <= d: print('Yes') else: print('No')" p02761,s807570365,Accepted,"import sys n, m = map(int, input().split()) num = [-1]*n if n == 1 and m == 0: print(0) sys.exit() for _ in range(m): s, c = map(int, input().split()) # 一桁目が0 if s == 1 and c == 0 and n > 1: print(-1) sys.exit() # 同じ桁が指定される if num[s-1] != -1 and num[s-1] != c: print(-1) sys.exit() num[s-1] = c if num[0] == -1: num[0] = 1 for i in range(1, n): if num[i] == -1: num[i] = 0 for i in num: print(i, end='')" p02778,s960695123,Accepted,"S = input().split()[0] l = list(S) s="""" for i in l: s+=""x"" print(s)" p02953,s823098170,Accepted,"n=int(input()) l=list(map(int, input().split())) st=l[n-1] for _ in reversed(l): if _-1>st: print(""No"") exit() elif _-1==st: st==_-1 else: st=_ print(""Yes"") " p03795,s969501328,Accepted,"N = int(input()) x = N*800 - (N//15)*200 print(x)" p03038,s255022866,Accepted,"from collections import Counter n,m = map(int,input().split()) a_ls = list(map(int, input().split())) counter = Counter(a_ls) for i in range(m): b,c = map(int,input().split()) counter[c] += b cards = sorted(counter.items(), key = lambda x:x[0], reverse=True) rest = n Sum = 0 for num, count in cards: if count < rest: Sum += num * count rest -= count else: Sum += rest * num break print(Sum) " p02899,s675685985,Accepted,"n = int(input()) a = list(map(int, input().split())) b = [0] * n for i in range(n): b[a[i]-1] = i+1 print(*b)" p02660,s739470376,Accepted,"def prime(p): memo = [] for i in range(2,(int(p**0.5)+1)): while p%i==0: p //= i memo.append(i) if p != 1: memo.append(p) return memo import collections n=int(input()) memo = prime(n) memo = collections.Counter(memo) memo = sorted(memo.items(), key=lambda x:-x[1]) ans = 0 for sosu, count in memo: kosu = 1 while 0 <= count-kosu: count -= kosu ans += 1 kosu += 1 print(ans)" p02775,s163140150,Wrong Answer,"s = input() l = len(s) cnt = 0 ls = [] ls.append(0) ls.append(0) for i in range(l): ls.append(int(s[i])) for i in range(l+1):#下から回す if 6<= ls[-i-1] <=10: ls[-i-1] = 10 -ls[-i-1] #おつりを代入 ls[-i-2] += 1 #繰り上がり print(sum(ls)) " p04012,s059567603,Accepted,"S = input() D = {} for i in S: if i in D: D[i] += 1 D[i] %= 2 else: D[i] = 1 if sum(D[i] for i in D) == 0: print(""Yes"") else: print(""No"")" p03042,s851542570,Accepted,"import math def main(): # n = int(input()) # n, k = map(int, input().split()) # h = list(map(int, input().split())) s = input() # h = [int(input()) for _ in rane(n)] f = int(s[:2]) b = int(s[2:]) if 1 <= f and f <= 12 and 1 <= b and b <= 12: print(""AMBIGUOUS"") elif 0 <= f and f <= 99 and 1 <= b and b <= 12: print(""YYMM"") elif 0 <= b and b <= 99 and 1 <= f and f <= 12: print(""MMYY"") else: print(""NA"") if __name__ == '__main__': main() " p04045,s563786484,Accepted,"n, k = map(int, input().split()) d = sorted(list(map(int, input().split()))) for i in range(n, 100000): for j in d: if str(i).count(str(j)) != 0: break else: print(i) exit()" p03544,s735302329,Accepted,"def fib(n): memo = [0]*(n+1) def _fib(n): if n == 0: return 2 elif n == 1: return 1 if memo[n] != 0: return memo[n] memo[n] = _fib(n-1) + _fib(n-2) return memo[n] return _fib(n) n = int(input()) print(fib(n))" p02606,s770200064,Accepted,"a = a, b, c, = map(int, input().split()) bc = int(b/c) ac = int((a-1)/c) ans = bc-ac print(ans)" p03386,s728354059,Accepted,"A,B,K=map(int,input().split()) if B-A+1>2*K: for i in range(K): print(A+i) for j in range(K): print(B-K+j+1) else: for k in range(B-A+1): print(A+k) " p02742,s209015051,Accepted,"H,W=[int(i) for i in input().split()] if H==1 or W==1: print(1) else: print(int(H*W/2)+(H*W)%2) " p03545,s962676982,Accepted,"import itertools as it n=[x for x in input()] In=list(it.product(['+','-'],repeat=3)) for k in range(8): ans = eval(n[0]+In[k][0]+n[1]+In[k][1]+n[2]+In[k][2]+n[3]) if ans==7: print(n[0]+In[k][0]+n[1]+In[k][1]+n[2]+In[k][2]+n[3]+""=7"") exit() " p02687,s706133525,Accepted,"if input()[1]==""B"": print(""ARC"") else: print(""ABC"")" p02773,s638143100,Wrong Answer,"N = int(input()) lists = [] for n in range(N): s = input() lists.append(s) from collections import Counter counter = Counter(lists) #print(counter) anslist = sorted(counter.items(), key = lambda x:x[1]) anslist.reverse() #print(anslist) num = anslist[0][1] len = len(anslist) #print(num) for n in range(len): if anslist[n][1] == num: print(anslist[n][0]) else: pass " p02615,s913529876,Accepted,"N = int(input()) a = list(map(int,input().split())) a_sort = sorted(a, reverse=True) a_sum = a_sort[0] if (N-2) % 2 == 0: for i in range(int((N-2)/2)): a_sum += 2*a_sort[i+1] print(a_sum) else: for i in range((N-2)//2): a_sum += 2*a_sort[i+1] print(a_sum+a_sort[(N-2)//2 + 1])" p03146,s387169062,Accepted,"def b_collatz_problem(): def collatz(n): return n // 2 if n % 2 == 0 else 3 * n + 1 S = int(input()) collatz_set = {S} num = S ans = 1 while True: num = collatz(num) ans += 1 if num in collatz_set: return ans collatz_set.add(num) print(b_collatz_problem())" p02946,s635785909,Accepted,"k, x = list(map(int, input().split())) print(*[i for i in range(x - k + 1, x + k)]) " p02664,s137542680,Accepted,"s = list(input()) k = len(s) for i in range(k): if s[i] == '?': s[i] = 'D' A = """".join(s) print(A)" p02802,s585403569,Wrong Answer,"n, m = map(int, input().split()) correct = 0 penal = 0 d = {i: set() for i in range(1,n+1)} for _ in range(m): p, s = input().split() if s == 'AC': if not s in d[int(p)]: correct += 1 else: if not 'AC' in d[int(p)]: penal += 1 d[int(p)].add(s) print(correct, penal)" p03013,s553819310,Accepted,"import sys input = sys.stdin.readline n,m = map(int,input().split()) oks = [True]*(n+1) for i in range(m): a = int(input()) oks[a] = False dp = [0]*(n+1) dp[0] = 1 for i in range(n): for j in range(i+1,min(n,i+2)+1): if oks[j]: dp[j] += dp[i] dp[j] %= (10**9+7) print(dp[n])" p02797,s680083699,Accepted,"N, K, S = map(int, input().split()) ans = [] for i in range(N): if i < K: ans.append(str(S)) else: if S == 10 ** 9: ans.append(str(1)) else: ans.append(str(S+1)) print("" "".join(ans)) " p02618,s364412752,Wrong Answer,"D = int(input()) C = list(map(int, input().split())) S = [list(map(int, input().split())) for _ in range(D)] ans = [i%26 for i in range(1,D+1)] for i in ans: print(i)" p02727,s279397795,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) s = p[:x] + q[:y] s.sort() ans = sum(s) for si, ri in zip(s, r): if si < ri: ans += ri - si print(ans)" p02783,s740394014,Wrong Answer,"H,A = map(int, input().split()) print(H//A+1)" p02947,s884820840,Accepted,"from collections import Counter n = int(input()) s = [[0]*10 for _ in range(n)] ans = 0 for i in range(n): str_s = input() for j in range(10): s[i][j] = str_s[j] dict_s = {} for i in range(n): s[i].sort() si = """".join(s[i]) dict_s.setdefault(si, 0) dict_s[si] += 1 for x in dict_s.values(): ans += x*(x-1)//2 print(ans)" p02744,s207466060,Accepted,"N = int(input()) alpha=list('abcdefghijklmnopqrstuvwxyz') res=[''] for i in range(N): tmp = [] for j in res: for k in alpha[:len(set(list(j))) +1]: tmp.append(j+k) res = tmp for i in res: print(i)" p02748,s039085280,Accepted,"A, B, M = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) r = min(a) + min(b) for S in range(M): x, y, c = map(int, input().split()) r = min(r, a[x-1] + b[y-1] - c) print(r) " p02677,s652049739,Wrong Answer,"from math import radians, cos A, B, H, M = map(int, input().split()) angle_h = (H + M/60) * 30 angle_m = M * 60 theta = min(abs(angle_h-angle_m), 360 - abs(angle_h-angle_m)) r2 = A**2 + B**2 - 2*A*B*cos(radians(theta)) print(r2**(1/2))" p03994,s633264914,Accepted,"s = list(input()) K = int(input()) a = ord('z') + 1 for i in range(len(s)-1): if s[i] == 'a': continue #print(K,a - ord(s[i])) if K >= (a - ord(s[i])): K -= a - ord(s[i]) s[i] = 'a' #print(K,a - ord(s[i])) i = len(s)-1 s[len(s)-1] = chr((ord(s[i])-ord('a') + K) % 26 + ord('a')) print(''.join(s)) " p02624,s794475222,Accepted,"n = int(input()) ans = 0 for i in range(1, n+1): m = n//i ans += i * m * (m+1) // 2 print(ans)" p03623,s981487187,Accepted,"x, a, b = map(int, input().split()) print(""A"" if max(x, a) - min(x, a) < max(x, b) - min(x, b) else ""B"") " p02725,s859702091,Accepted,"K, N = map(int, input().split()) A = list(map(int, input().split())) dmax = K - A[N-1] + A[0] apre = -(K - A[N-1]) for a in A: d = a - apre if d > dmax: dmax = d apre = a print(K - dmax)" p03408,s722154828,Accepted,"N = int(input()) dn = {} dm = {} for _ in range(N): s = input() if s in dn: dn[s] += 1 else: dn[s] = 1 M = int(input()) for _ in range(M): t = input() if t in dm: dm[t] += 1 else: dm[t] = 1 ans = 0 for k, v in dn.items(): res = v if k in dm: res -= dm[k] ans = max(ans, res) print(ans) " p02760,s296206716,Accepted,"A = [list(map(int, input().split())) for _ in range(3)] N = int(input()) b = [int(input()) for _ in range(N)] field = 0 for v in b: for i in range(9): if A[i // 3][i % 3] == v: field = field | (1 << i) ans = False for v in sum([[273,84],sum([[73<=abs(c-a) or (d>=abs(c-b) and d>=abs(b-a)): print(""Yes"") else: print(""No"")" p02760,s692050487,Accepted,"S=""012 345 678 036 147 258 048 246 "" A=[] A.extend(list(map(int,input().split())) for i in range(3)) N=int(input()) for i in range(N): j=input() for l in range(3): for m in range(3): S=S.replace(str([9,l*3+m][A[l][m]==int(j)]),"""") print([""No"",""Yes""][S.find("" "")>-1])" p03475,s374601694,Wrong Answer,"n = int(input()) res = [0] * n for i in range(1, n): c, s, f = map(int, input().split()) res[i-1] += s + c for j in range(i-1): if res[j] < s: res[j] = s + c elif res[j] == s: res[j] += c else: if (res[j] - s) % f == 0: res[j] += c else: res[j] += f + c for elem in res: print(elem) " p03657,s952289324,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"")" p03239,s321934365,Wrong Answer,"N, T = map(int, input().split()) CT = [tuple(map(int, input().split())) for _ in range(N)] ans = 1010 for c, t in CT: if t > T: continue ans = min(ans, c) print(ans if ans <= T else 'TLE')" p03416,s793311971,Accepted,"a,b = map(int,input().split()) ans = 0 for i in range(a,b+1): for j in range(len(str(i))//2+1): #print(str(i), str(i)[j],str(i)[-j-1],j , len(str(i))//2) if str(i)[j] != str(i)[-j-1]: break if j == len(str(i))//2: ans += 1 print(ans)" p03285,s677764097,Accepted,"N = int(input()) n = N // 7 flag = 0 for i in range(n + 1): if (N - i*7) % 4 == 0: print(""Yes"") flag = 1 break if flag == 0: print(""No"")" p03817,s842879575,Accepted,"x = int(input()) k = x // 11 ans = k * 2 if x - k * 11 == 0: ans += 0 elif x - k * 11 <= 6: ans += 1 else: ans += 2 print(ans) " p03657,s129334160,Accepted,"x,y=map(int,input().split()) if x%3==0 or y%3==0 or (x+y)%3==0: print('Possible') else: print('Impossible')" p02705,s283602982,Wrong Answer,"num = int(input(""半径を入力してください"")) num = num * 2 * 3.14 print(num)" p02881,s142517027,Accepted,"N=int(input()) a=1 for i in range(1,int(N**(1/2))+2): if N%i==0: a=max(a,i) print(a+N//a-2)" p02916,s842260642,Accepted,"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(N): SUM += B[A[i]-1] for i in range(1,N): if A[i]-A[i-1]==1: SUM += C[A[i-1]-1] print(SUM)" p03385,s414898602,Accepted,"s = input() print('Yes' if s.count('a') == s.count('b') == s.count('c') == 1 else 'No')" p02859,s641943316,Accepted,"r = int(input()) print(r*r)" p03324,s142926276,Accepted,"d,n=map(int,input().split()) k=100**d if n%100==0: n+=n//100 ans=n*k print(ans)" p02600,s349475499,Accepted,"import sys sys.setrecursionlimit(1000000) import bisect import math import collections import heapq def solve(N): i = 8 n = 400 while i > 0: if N < 200 + n + (200 * (8 - i)): return str(i) i -= 1 if __name__ == ""__main__"": N = int(input()) print(solve(N)) " p02854,s100946425,Accepted,"N=int(input()) A=list(map(int,input().split())) total = sum(A) i = 0 tmp=A[i] while total/2 > tmp: i += 1 tmp += A[i] ans = min(2*tmp-total, total-2*(tmp-A[i])) print(ans)" p03146,s515110060,Accepted,"def check(s): if s % 2 == 0: return s//2 else: return 3*s+1 s = int(input()) count = 0 a = [s] n = s while count < 1: n = check(n) length = len(a) a.append(n) if length+1 != len(set(a)): print(len(a)) break" p02701,s068860411,Wrong Answer,"N = int(input()) List = [input() for i in range(N)] count_str = N for i in range(N-1): j = i+1 if List[i] == List[j]: count_str = count_str - 1 else: pass print(count_str)" p03001,s007456645,Wrong Answer,"W, H ,x, y = map(int, input().split()) if H > W: if x == W/2: can = 0 else: can = 1 elif H == W: can = 1 else: if y == H/2: can = 0 else: can = 1 print('{:.9f}'.format(W*H/2), can) " p02835,s592997565,Wrong Answer,"S = list(map(int,input().split())) if S[0] == S[1]: print(""Yes"") else: print(""No"")" p03284,s984661895,Wrong Answer,"N,K=map(int,raw_input().split()) if N/K%2==1: print ""1"" elif N/K%2==0: print ""0"" " p02720,s576505358,Accepted,"from collections import deque N = int(input()) q = deque() for i in range(1, 10): q.append(i) for i in range(N): a = q.popleft() d = a % 10 if d > 0: q.append(10*a + d - 1) q.append(10*a + d) if d < 9: q.append(10*a + d + 1) print(a)" p03408,s285725693,Accepted,"n = int(input()) d = {} for i in range(n): s = input() try: d[s] += 1 except: d[s] = 1 m = int(input()) for i in range(m): t = input() try: d[t] -= 1 except: d[t] = -1 max_num = 0 for item in d.items(): if item[1] > max_num: max_num = item[1] print(max_num)" p03264,s035263750,Accepted,"K = int(input()) if K%2 == 0: print( (K//2) ** 2 ) else: print( ( (K+1) // 2) * (K//2) )" p03416,s960887223,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,b = i2() cnt = 0 for i in range(a,b+1): memo = str(i) if memo[0] == memo[4] and memo[1] == memo[3]: cnt += 1 print(cnt)" p02622,s365955798,Accepted,"S = input() T = input() ans = 0 for i in range(len(S)): if S[i] != T[i]: ans +=1 print(ans) " p03160,s324613531,Wrong Answer,"N = int(input()) hs = list(map(int, input().split())) Cost = [1e7 for _ in range(N)] Cost[0] = 0 for i in range(N-2): if (i+1 > N-1): continue Cost[i+1] = min(Cost[i+1], Cost[i] + abs(hs[i]-hs[i+1])) if (i+2 > N-1): continue Cost[i+2] = min(Cost[i+2], Cost[i] + abs(hs[i]-hs[i+2])) print(Cost[N-1])" p02633,s331072636,Accepted,"import math M = 360 X = list(map(int, input().split()))[0] Y = math.gcd(M, X) result = M // Y print(result)" p03827,s048119426,Wrong Answer,""""""" 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') print(max(0, S.count('I') - S.count('D'))) " p03095,s454062597,Wrong Answer,"n = int(input()) s = input() ans = 1 for x in set(s): ans *= s.count(x)+1 print(ans) print((ans-1)%(10**9+7))" p02571,s845781440,Accepted,"s=input() t=input() m=len(s) for i in range (len(s)-len(t)+1): c=0 for j in range (len(t)): if t[j]!=s[i+j]: c+=1 m=min(m,c) print(m)" p02882,s823198862,Accepted,"import math a,b,x = [ int(r) for r in input().split(' ') if len(r) > 0] if 2*x >= a*a*b: # 半分より多い print(90-math.degrees((math.atan2(a,2*(b-x/a**2))))) else: # 半分より少ない print(90-math.degrees(math.atan2((2*x)/(a*b),b)))" p03607,s640305499,Accepted,"import collections n = int(input()) a = [int(input()) for i in range(n)] x = collections.Counter(a) y = x.most_common() ans = 0 for i in range(len(y)): if y[i][1]%2==1: ans+=1 print(ans)" p03455,s702214611,Accepted,"a,b=(int(x) for x in input().split()) #print((a * b) % 2) if (a * b) % 2 == 1: print('Odd') else: print('Even') " p02702,s830166026,Accepted,"S = input() A = [0 for i in range(2019)] x = 0 q = 1 for i in range(len(S)): p = i + 1 a = (int(S[-p])) b = a*q%2019 x = (x+b) % 2019 A[x] += 1 q = q*10%2019 ans = A[0] for i in range(2019): ans += A[i]*(A[i]-1)//2 print(ans)" p02596,s611139443,Accepted,"def main(): k = int(input().strip()) if k % 2 == 0 or k % 5 == 0: print(-1) return x = 7 % k for n in range(1, k + 1): if x == 0: print(n) return x = (10 * x + 7) % k print(-1) return if __name__ == ""__main__"": main() " p02645,s752190961,Accepted,"s = input() print(s[0:3]) " p03455,s793936768,Accepted,"# coding: utf-8 # Your code here! a,b=(map(int,input().split())) if a*b%2==0: print(""Even"") else: print(""Odd"")" p02916,s291003734,Accepted,"n=int(input()) a=list(map(int,input().split())) b=list(map(int,input().split())) c=list(map(int,input().split())) r=0 for i in range(n-1): if a[i+1]==a[i]+1: r+=c[a[i]-1] print(sum(b)+r)" p03657,s197317466,Accepted,"# -*- coding: utf-8 -*- A, B = map(int, input().split()) print(['Impossible', 'Possible'][A%3 == 0 or B%3 == 0 or (A+B) %3 == 0])" p02922,s087084286,Wrong Answer,"a, b = map(int, input().split()) num = a for i in range(50): if num > b: break else: num -= 1 num += a print(i+1)" p02621,s794480736,Accepted,"a=input() a1=int(a) b=a1+(a1*a1)+(a1*a1*a1) print(b)" p02833,s513711828,Wrong Answer,"n = int(input()) ans = 0 if n % 2 == 0: for i in range(1, 18): k = 10**i ans += n//k print(ans) else: print(ans)" p03827,s394142754,Accepted,"n = int(input()) s = input() m = 0 c = 0 for i in range(min([n,len(s)])): if s[i] == 'I': c += 1 else: c -= 1 if c > m: m = c print(m)" p02689,s150246795,Accepted,"n,m = map(int,input().split()) H = [int(i) for i in input().split()] H_max = [True for i in range(n)] for i in range(m): a,b = map(int,input().split()) if H[a-1]>H[b-1]: H_max[b-1] = False elif H[a-1]=0: if y > 0: if y>x: ans = n else: ans = n+2 else: ans = n+1 else: if y > 0: ans = n+1 else: if y > x: ans = n else: ans = n+2 print(ans)" p02780,s207527380,Wrong Answer,"N,K = map(int,input().split()) ps = list(map(int,input().split())) dicesSum=[] l1=ps[0:K] dicesSum.append(sum(l1)) if K==1: exp= (1+ dicesSum[0])/2 print(exp) else: for i in range(1,N-K): dicesSum.append(dicesSum[i-1]-ps[i-1]+ps[i+K-1]) max_value = max(dicesSum) exp= (K+ max_value)/2 print(exp) " p03817,s287762157,Wrong Answer,"n = int(input()) a = n // 11 b = n % 11 ans = 0 if b <= 6: ans += 1 elif b >= 7 and b <= 10: ans += 2 ans += a * 2 print(ans) " p02719,s310343715,Accepted,"N, K = map(int, input().split()) A = N // K B = N % K if B > abs(B-K): print(abs(B-K)) else: print(B)" p03815,s018875633,Accepted,"a=int(input()) ans=a//11*2 a%=11 if 6>=a>=1:ans+=1 elif a!=0:ans+=2 print(ans)" p02897,s878873390,Accepted,"n = int(input()) if n % 2 == 0: print(""{:.9f}"".format(0.5)) else: print(""{:.9f}"".format((n + 1) // 2 / n)) " p02724,s104379420,Accepted,"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time sys.setrecursionlimit(10**7) inf = 10**20 mod = 10**9 + 7 stdin = sys.stdin ni = lambda: int(ns()) na = lambda: list(map(int, stdin.readline().split())) ns = lambda: stdin.readline().rstrip() # ignore trailing spaces x = ni() ans = 0 ans += (x // 500) * 1000 x -=(x // 500) * 500 ans += (x // 5) * 5 print(ans) " p03387,s602830819,Accepted," l = list(map(int,input().split())) l.sort() ans = 0 ans += l[2] - l[1] if (l[2] - (ans + l[0])) % 2 == 0: ans += (l[2] - (ans + l[0])) / 2 else: ans += int((l[2] - (ans + l[0])) / 2) + 2 print(int(ans)) " p02595,s149520511,Accepted,"n, d = map(int, input().split()) d = d*d ans = 0 for i in range(n): x, y = map(int, input().split()) if d >= x*x + y*y: ans += 1 print(ans)" p04020,s834623173,Wrong Answer,"N = int(input()) A = [0] * N for i in range(N): A[i] = int(input()) ans = 0 for i in range(N - 1): if A[i] >= A[i + 1]: now = int((A[i] - A[i + 1]) / 2) ans += now A[i] -= now * 2 now2 = min(A[i], A[i + 1]) ans += now2 A[i + 1] -= now2 A[i] -= now2 else: now = A[i] ans += now A[i] -= now A[i + 1] -= now #print(A) print(ans) " p02854,s947463229,Accepted,"N=int(input()) A=list(map(int, input().split())) al=sum(A) cent=al/2 now=0 for a in A: if abs(cent-al+now)= N+1: break maxnum = max(S[i+K]-S[i], maxnum) print(maxnum)" p02814,s458576626,Accepted,"def gcd_e(x, y): if y == 0: return x else: return gcd_e(y,x%y) def lcm(x, y): return (x * y) // gcd_e(x, y) n,m=list(map(int,input().split())) A=list(map(int,input().split())) a,b=A[0],0 for i in range(1,n): b = A[i] a = lcm(a,b) for i in range(n): if (a // A[i]) % 2 == 0: print('0') exit() if a // 2 > m: print('0') else: print((m-a//2)//a+1)" p03495,s137996560,Accepted,"#辞書型でリトライ N,K = map(int, input().split(' ')) A = input().split(' ') dic = {} for a in range(len(A)): tmp = A[a] if not tmp in dic: dic[tmp] = 1 else: dic[tmp] += 1 values = sorted(dic.values()) ans = 0 if len(values)<=K: pass else: tmp = len(values)-K values = values[:tmp] ans = sum(values) print(ans)" p02713,s384093008,Accepted,"import math from functools import reduce def gcd(*numbers): return reduce(math.gcd, numbers) sum=0 K=int(input()) for i in range(K): for j in range (K): for k in range (K): sum=sum+gcd(i+1,j+1,k+1) print(sum) " p02577,s249403819,Accepted,"N = int(input()) sum = 0 N_string = str(N) for i in range(len(N_string)): sum += int(N_string[i]) if sum % 9 == 0: print('Yes') else: print('No')" p03075,s519123381,Accepted,"a=int(input());input();input();input();e=int(input()); if e - a <= int(input()): print('Yay!') else: print(':(')" p02664,s253026066,Accepted,"n = input() n = n.replace(""?"",""D"") d = n.count(""D"") pd= n.count(""PD"") print( n)" p02693,s424923331,Wrong Answer,"K = int(input()) A, B = map(int,input().split()) if (B-A) // K !=0: print('OK') else: print('NG') " p02754,s841201123,Accepted,"n, blue, red = map(int, input().split()) total= n//(blue+red)*blue if n%(blue+red)>=blue: total+= blue else: total+= n%(blue+red) print(total)" p02702,s157870436,Wrong Answer,print(3) p03131,s491439861,Accepted,"k,a,b=map(int,input().split()) bis=1 if(k<=a-1): print(k+1) elif(b= A: S.add(B-i) for e in sorted(S): print(e) " p02732,s302981280,Accepted,"n=int(input()) A=list(map(int,input().split())) D={} for i in A: if i in D: D[i]+=1 else: D[i]=1 T=0 for i in D: T+=D[i]*(D[i]-1)//2 for i in range(n): print(T-(D[A[i]]-1)) " p03495,s754015541,Accepted,"n,k = map(int,input().split()) a = list(map(int,input().split())) a.sort() ans = 0 a.append(-1) x = [] tmp = 0 for i in range(n): if a[i] != a[i+1]: tmp += 1 x.append(tmp) tmp = 0 else: tmp += 1 x.sort(reverse=True) print(sum(x[k:]))" p03285,s417286741,Accepted,"# solution import io data = int(input()) print('Yes' if len([1 for i in range(26) if (data-4*i)%7==0 and data-4*i>=0])>0 else 'No')" p03416,s348337011,Wrong Answer,"a, b = map(int, input().split()) cnt = 0 for i in range(a, b + 1): if str(i)[0:2] == str(i)[-2:]: cnt += 1 print(cnt) " p02911,s914997964,Wrong Answer,"n, k, q = map(int, input().split()) a = list(input() for _ in range(q)) for i in range(n): ans = ""Yes"" if q - a.count(i+1) < k else ""No"" print(ans) " p02791,s825015135,Accepted,"# import math # import bisect # import heapq # from collections import deque # import numpy as np # a,b = map(int, input().split()) n = int(input()) p = list(map(int,input().split())) min = p[0] count = 0 for i in range(n): if p[i] <= min: min = p[i] count += 1 print(count)" p02917,s057331697,Accepted,"# C N = int(input()) B = [10**10] + list(map(int,input().split())) + [10**10] ans = 0 for i in range(N): ans += min(B[i],B[i+1]) print(ans) " p02797,s300190358,Wrong Answer,"N, K, S = map(int,input().split()) output = """" for i in range(1,N): output += str(S) output += str("" "") if(i > K): output += str(""0"") output += str("" "") print(output[:-1])" p02618,s132817909,Accepted,"#create date: 2020-06-28 21:45 import sys stdin = sys.stdin import numpy as np def ns(): return stdin.readline().rstrip() def ni(): return int(ns()) def na(): return list(map(int, stdin.readline().split())) def main(): d = ni() c = np.array(na()) s = list() for i in range(d): a = na() s.append(a) t = [i % 26 + 1 for i in range(d)] print(*t, sep=""\n"") if __name__ == ""__main__"": main()" p03131,s490736185,Accepted,"k,a,b=map(int,input().split()) ans=1 if b-a<=2: #交換するメリットがない k回すべて一枚増やす print(ans+k) else: if k<(a+1): print(ans+k) else: zan=(k-(a-1)) if zan%2==0: print(max(ans+k,a+(zan//2)*(b-a))) else: print(max(ans+k,a+(zan//2)*(b-a)+1))" p03419,s668753447,Accepted,"def myAnswer(N:int,M:int) -> int: if(N == 1 and M == 1): return 1 if(min(N,M) == 1): return max(N,M) - 2 if(min(N,M) == 2): return 0 return N*M - (max(N,M) * 2 + (min(N,M) - 2) * 2) def modelAnswer(): return def main(): N,M = map(int,input().split()) print(myAnswer(N,M)) if __name__ == '__main__': main() " p02615,s574823659,Accepted,"n = int(input()) l=sorted(list(map(int,input().split()))) an=l[n-1] x=l[n-2];cr=n-3;cc=0 for i in range(n-3,-1,-1): an+=x cc+=1 if cc!=0 and cc%2==0: x=l[cr];cr-=1 #print(an,x,cr) print(an)" p03474,s254361093,Wrong Answer,"#!/usr/bin/env python3 # スペース区切りの整数の入力 A, B = map(int, input().split()) S = input() index = S.find(""-"") if index == -1: print(""No"") exit(0) if len(S[:index]) != A: print(""No"") exit(0) if len(S[index+1:]) != B: print(""No"") exit(0) print(""Yes"") " p03485,s657491626,Accepted,"import math a, b = map(int, input().split()) print((a+b+1)//2)" p03471,s036062353,Accepted,"N,Y=map(int,input().split()) answer=-1,-1,-1 for x in range(N+1): for y in range(N-x+1): z=N-x-y if 0<=z<=2000 and 10000*x+5000*y+1000*z==Y: answer=x,y,z break else: continue break print(*answer)" p03836,s076258468,Accepted,"sx,sy,tx,ty = map(int,input().rstrip().split("" "")) dx = tx - sx dy = ty-sy ans = """" ans += ""R""*dx + ""U"" * dy ans += ""L"" * dx + ""D"" * dy ans += ""D"" + ""R"" * (dx + 1) + ""U"" * (dy + 1) + ""L"" ans += ""U"" + ""L"" * (dx + 1) + ""D"" * (dy + 1) + ""R"" print(ans)" p02880,s670630735,Accepted,"n = int(input()) for i in range(1,10): for j in range(1,10): if(n == i*j): print('Yes') exit() print('No')" p04011,s021089079,Accepted,"N = int(input()) K = int(input()) X = int(input()) Y = int(input()) if (K prog[1]*prog[2]: print(answer) break answer += k[0] for l in range(prog[1]): points[l] += k[l+1] if sum(points) < prog[1]*prog[2]: print(-1)" p02842,s981701880,Accepted,"import math N = int(input()) low = N // 1.08 while True: if math.floor(low * 1.08) == N: print(int(low)) break elif math.floor(low * 1.08) > N: print(':(') break low += 1" p03803,s092807279,Accepted,"a,b=map(int,input().split()) List = [2,3,4,5,6,7,8,9,10,11,12,13,1] c = 0 d = 0 for i in range(13): if a == List[i]: c = i if b == List[i]: d = i if c == d: print(""Draw"") elif c < d: print(""Bob"") else: print(""Alice"")" p03592,s946832916,Accepted,"N, M, K = map(int, input().split()) for n in range(N + 1): for m in range(M + 1): if n * M + m * N - n * m * 2 == K: print('Yes') exit() print('No')" p02612,s177896120,Accepted,"n = int(input()) if n % 1000 == 0: print(0) else: print(1000-n%1000)" p03127,s186776160,Accepted,"import math def main(): n = int(input()) a = list(map(int,input().split())) a.sort() ans = a[0] tmp = 0 while True: for i in range(1,n): a[i] %= ans if a[i] != 0: tmp = min(ans,a[i]) if sum(a) == ans: print(ans) return a.sort() ans = tmp a[0] = tmp if __name__=='__main__': main() " p02861,s418070281,Accepted,"N = int(input()) X = [list(map(int, input().split())) for _ in range(N)] S = 0 for i in range(N-1): for j in range(i+1, N): S += ((X[i][0]-X[j][0])**2+(X[i][1]-X[j][1])**2)**.5 print(S/(N/2))" p03250,s766497782,Accepted,"A = list(map(int,input().split())) A = sorted(A, reverse=True) print(int("""".join(map(str,A[:2]))) + A[-1])" p03284,s801798044,Wrong Answer,"N,K= map(int,input().split()) ans1 = N//K if (N%K == 0): ans2 = N//K else: ans2 = N%K print(abs(ans1-ans2))" p03854,s796104953,Wrong Answer,"import sys s = input() t = s[::-1] while len(t) != 0: if t[:5] == ""maerd"" or t[:5] == ""esare"": t = t[5:] elif t[:6] == ""resare"": t = t[6:] elif t[:7] == ""remaerd"": t = t[6:] else: print(""NO"") sys.exit() print(""YES"")" p03611,s989829406,Accepted,"import collections n = int(input()) a = list(map(int,input().split())) maxVal = max(a) minVal = min(a) a = collections.Counter(a) ans = 0 for i in range(max(0, minVal-1), maxVal+1): temp = a[i - 1] + a[i] + a[i + 1] ans = max(ans, temp) print(ans)" p03407,s561468043,Accepted,"A, B, C = [int(i) for i in input().split()] if A + B >= C: print('Yes') else : print('No')" p03693,s929184152,Wrong Answer," def resolve(): n = int("""".join(input().split())) print(""YES"" if n%4==0 else ""No"") if '__main__' == __name__: resolve()" p02707,s836619504,Accepted,"n = int(input()) a = list(map(int, input().split())) buka = [0]*n for i in a: buka[i-1] += 1 for i in buka: print(i) " p03210,s764126744,Accepted,"def YN(P): if P: print(""YES"") else: print(""NO"") def yn(P): if P: print(""Yes"") else: print(""No"") x=int(input()) YN(x==3 or x==5 or x==7)" p03555,s958327492,Accepted,"c1 = input() c2 = input() if c1 == c2[::-1]: print(""YES"") else: print(""NO"")" p03486,s709423759,Accepted,"s,t=sorted(list(input())),sorted(list(input()),reverse=True) print(""Yes"" if s 4: print(""TBD"") else: print(""Heisei"")" p03285,s622480141,Accepted,"n=int(input()) for a in range(100): for b in range(100): if a*4+b*7==n: print(""Yes"") exit() print(""No"")" p02676,s623821912,Accepted,"K = int(input()) S = input() answer = None is_less_than_K = len(S) <= K if is_less_than_K: answer = S else: answer = S[0:K] + '...' print(answer) " p02786,s465550275,Accepted,"h = int(input()) cnt = 0 while h: h //= 2 cnt += 1 print(2**cnt-1)" p03012,s092201764,Accepted,"def main(): n = int(input()) w = list(map(int, input().split())) avr = sum(w) // 2 res = 0 ans1 = 0 ans2 = 0 for i in range(n): res += w[i] if res > avr: ans1 = abs(sum(w[(i+1):]) - sum(w[:(i+1)])) ans2 = abs(sum(w[i:]) - sum(w[:i])) print(min(ans1,ans2)) return if __name__ == '__main__': main()" p03665,s161479994,Accepted,"from math import factorial def combi(n,k): return factorial(n) // factorial(k) // factorial(n-k) n,p = map(int,input().split()) a = list(map(int,input().split())) even = 0 odd = 0 for i in a: if i&1: odd += 1 else: even += 1 picke = 0 for i in range(even + 1): picke += combi(even,i) picko = 0 for i in range(p,odd + 1,2): picko += combi(odd,i) print(picke*picko) " p03696,s346211476,Accepted,"n=int(input()) s=list(input()) a=0 b=0 c=0 for i in range(n): d=s[i] if d=='(': a+=1 else: b+=1 if b-c>a: c+=1 print('('*c+''.join(s)+')'*(a-b+c)) " p02615,s558185984,Accepted,"n = int(input()) a = list(map(int,input().split())) a.sort(reverse=True) ans = a[0] nn = (n-2)//2 nnn = (n-2)%2 for i in range(nn): ans = ans + a[i+1]*2 if nnn == 1: ans = ans + a[i+2] print(ans)" p02697,s992353901,Wrong Answer,"import sys input = sys.stdin.readline def main(): n,m = map(int,input().split()) ans = [[n//2,n//2+1]] for _ in range(m-1): v = ans[-1] new = [v[0]-1,v[1]+1] if new[0] == 0: new[0] = n if new[1] == n+1: new[1] = 1 ans.append(new) for a in ans: print(*a) if __name__ == ""__main__"": main()" p02607,s307741225,Accepted,"import math n = int(input()) aL = list(map(int, input().split("" ""))) ans = 0 for index, a in enumerate(aL): if (index + 1) % 2 == 1 and a % 2 == 1: ans += 1 print(ans) " p03127,s149626463,Accepted,"from math import gcd from functools import reduce N = int(input()) A = [int(i) for i in input().split()] def gcd_list(numbers): return reduce(gcd, numbers) g = gcd_list(A) print(g)" p02642,s552863462,Wrong Answer,"def main(): n, *a = map(int, open(0).read().split()) if n == 1: print(1) return m = max(a) + 1 l = [0] * m for i in a: if l[i] > 1: continue for j in range(i, m, i): l[j] = 2 l[i] -= 1 ans = sum(l[i] == 1 for i in a) print(ans) if __name__ == ""__main__"": main() " p02772,s804748501,Accepted,"N = int(input()) A = list(map(int,input().split())) for i in range(len(A)): if A[i]%2 == 0 and (A[i]%3!=0 and A[i]%5!=0): print(""DENIED"") exit() print(""APPROVED"")" p03408,s555270037,Accepted,"import sys sys.setrecursionlimit(300000) from collections import defaultdict 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') N = I() S = [input() for _ in range(N)] M = I() T = [input() for _ in range(M)] d = defaultdict(int) for s in S: d[s] += 1 for t in T: d[t] = max(0, d[t] - 1) print(max(d.values()))" p02918,s791867653,Accepted,"n,k=map(int,input().split()) s=input() x=s.count('RL') y=0 cnt=0 for i in range(n-1): if s[i]==s[i+1]: cnt+=1 if s[0]=='L' and s[n-1]=='R': y+=1 while k>0: if x>0: x-=1 cnt+=2 k-=1 else: if y>0: cnt+=1 y-=1 k-=1 else: break print(min(n-1,cnt)) " p03239,s960631391,Accepted," def main(): N, T = map(int, input().split()) l = [] for _ in range(N): c, t = map(int, input().split()) l.append((c, t)) l.sort() for e in l: if e[1] <= T: print(e[0]) return print(""TLE"") if __name__ == ""__main__"": main()" p02948,s175166785,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) " p03243,s047661902,Accepted,"str_n = str(input()) temp = int(str_n[0]) temp = 111*temp int_n = int(str_n) if int_n > temp: temp = int(str_n[0]) temp = temp+1 print(111*temp) else: temp = int(str_n[0]) print(111*temp)" p02681,s781879673,Accepted,"a=input() b=input() if a==b[:-1]: print('Yes') else: print('No')" p03284,s441988230,Accepted,"n,k = map(int,input().split()) if n%k == 0: print(0) else: print(1)" p03160,s904480415,Accepted,"N = int(input()) h = list(map(int,input().split())) ml = [10**9]* N ml[0] = 0 ml[1] = abs(h[1]-h[0]) for i in range(2,N): ml[i] = min(abs(h[i]-h[i-1]) + ml[i-1], abs(h[i]-h[i-2]) + ml[i-2]) print(ml[N-1]) " p03475,s619766494,Accepted,"import sys sys.setrecursionlimit(10 ** 7) input = sys.stdin.readline 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()) def dfs(eki,t): if eki == n-1: return t cc = c[eki] ss = s[eki] ff = f[eki] if t <= ss: return dfs(eki+1, ss+cc) else: return dfs(eki+1, -(-t//ff)*ff+cc) for i in range(n): print(dfs(i,0)) " p02606,s192283447,Accepted,"l,r,d=map(int,input().split()) if l%d!=0: print(r//d-l//d) else: print(r//d-l//d+1)" p02859,s815883448,Accepted,"import sys def cirCle(r: int): ans = r ** 2 print(ans) return() if __name__ == '__main__': args = input() cirCle(int(args))" p03759,s951825181,Accepted,"a, b, c = map(int, input().split()) if 1 <= a <= 100 and 1 <= b <= 100 and 1 <= c <= 100: if b - a == c - b: print('YES') elif a - b == b - c: print('YES') else: print('NO')" p03611,s867691462,Wrong Answer,"N = int(input()) an = list(map(int, input().split())) ans = 0 for i in range(min(an)+1, max(an)): ans = max(ans, an.count(i) + an.count(i-1) + an.count(i+1)) print(ans)" p03804,s339240656,Wrong Answer,"n,m=map(int,input().split()) a=[] for i in range(n): a.append(input()) b=[] for i in range(m): b.append(input()) res=0 for i in range(0,n-m+1): keep=0 for j in range(i,i+m): if b[j-i] in a[j]: keep+=1 if keep==m: print(""Yes"") break if keep!=m: print(""No"") " p04044,s450923036,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(): n,l=INTM() s=[] for i in range(n): s.append(STR()) s.sort() print(*s,sep='') if __name__ == '__main__': do()" p03624,s996536398,Accepted,"def main(): s = input() flg=0 for i in range(0,26): if chr(ord('a')+i) not in s: print(chr(ord('a')+i)) flg=1 break if flg ==0: print(""None"") main()" p03419,s616633073,Accepted,"N, M = map(int, input().split()) print(abs((N - 2) * (M - 2)))" p03161,s635435514,Accepted,"import numpy as np N,K = map(int, input().split()) h = np.array(list(map(int, input().split()))) dp = np.full(N,10**10) dp[0] = 0 for i in range(1,N): start = max(0,i-K) dp[i] = np.min(dp[start:i]+np.abs(h[i]-h[start:i])) print(int(dp[-1])) " p03262,s836322911,Accepted,"import functools import math N, X = [int(i) for i in input().split()] x_list = [int(i) for i in input().split()] x_list.append(X) num_list = sorted(x_list) tmp = map(lambda x: abs(x[0] - x[1]), zip(num_list[:-1],num_list[1:])) D = functools.reduce(lambda acc, x: math.gcd(acc, x), tmp, 0) print(D) " p02831,s538676314,Accepted,"import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) a, b = map(int, input().split()) def gcd(a, b): if b == 0: return a else: return gcd(b, a % b) # a * b = gcd(a, b) * lcm(a, b) def lcm(a, b): return (a // gcd(a, b)) * b print(lcm(a, b)) " p02714,s851778759,Accepted,"from collections import Counter N = int(input()) S = input() counter = Counter(S) ans = counter['R'] * counter['G'] * counter['B'] for l in range(1, N): for i in range(N): if i + 2*l >= N: break a, b, c = S[i], S[i + l], S[i + 2*l] if a != b and a != c and b != c: ans -= 1 print(ans)" p03767,s820998848,Wrong Answer,"N = int(input()) a_list = map(int, input().split()) a_list = sorted(a_list) print(sum(a_list[N:2 * N]))" p03379,s086238082,Accepted,"N = int(input()) X = list(map(int, input().split())) x = sorted(X) small = x[(N//2)-1] big = x[N//2] for i in X: if i <= small: print(big) else: print(small)" p03338,s198409845,Wrong Answer,"import collections N = int(input()) S = input() m = 0 index = 0 for i in range(1, N): a = set(S[:i]) b = set(S[i:]) #print(a) #print(b) d = 0 for c in a: if c in b: d += 1 if d > m: m = d index = i print(index - 1)" p03241,s530482112,Accepted,"n, m = map(int, input().split()) fact = [] for i in range(1, int(m**0.5)): if m%i==0: fact.append(i) fact.append(m//i) fact.sort() ans = 1 for i in fact: if n*i<=m: ans = i print(ans)" p02820,s685719436,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] = ""0"" ans = [0] * n for i in range(n): if t[i] == ""r"": ans[i] = p elif t[i] == ""s"": ans[i] = r elif t[i] == ""p"": ans[i] = s print(sum(ans)) " p02553,s234974390,Accepted,"a,b,c,d=map(int,input().split()) print(max(a*c,a*d,b*c,b*d))" p03017,s508756256,Accepted,"N,A,B,C,D = map(int, input().split()) S = input() if ""##"" in S[A-1:max(C-1,D-1)]: print(""No"") elif D < C and (""..."" not in S[B-2:D+1]): print(""No"") else: print(""Yes"")" p02688,s646078546,Wrong Answer,"n,k = map(int, input().split()) s = [1]*n for i in range(k): d = int(input()) a = map(int, input().split()) for i in range(d): if s[i] == 1:s[i] = 0 print(sum(s))" p03803,s799057339,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 b>a: print('Bob') " p02628,s852836500,Accepted,"a,b = map(int,input().split()) c = list(map(int,input().split())) c.sort() ans = 0 for i in range(b): ans += c[i] print(ans) " p02689,s888642369,Wrong Answer,"from collections import Counter x=[] y=[] n,m=list(map(int,input().split())) h=list(map(int,input().split())) for i in range(m): a,b=list(map(int,input().split())) x.append(a) x.append(b) if h[a-1]>h[b-1]: y.append(a) elif h[a-1]= len(H): print(0) else: l = H[K:] print(sum(l)) " p03544,s719779958,Accepted," def luca(n): lz=2 lo=1 if n==1: return 1 for i in range(n-1): nl=lz+lo lz=lo lo=nl return nl print(luca(int(input()))) " p02818,s265218406,Accepted,"A, B, K = map(int, input().split()) A_after = 0 B_after = 0 if A - K >= 0: A_after = A - K B_after = B elif A + B - K >= 0: B_after = B - (K - A) print(A_after, B_after)" p03645,s573177139,Accepted,"N, M = map(int, input().split()) can = [[] for i in range(N + 1)] for i in range(M): a, b = map(int, input().split()) x = [a, b] if (1 in x) or (N in x): can[a].append(b) can[b].append(a) for j in range(len(can[1])): k = can[1][j] if N in can[k]: print(""POSSIBLE"") quit() print(""IMPOSSIBLE"")" p02595,s496860472,Accepted,"import math n,d = map(int,input().split()) ans = 0 for i in range(n): x,y = map(float,input().split()) if math.sqrt(x*x+y*y)<=d: ans+=1 print(ans)" p02755,s795168751,Accepted,"a, b = map(int, input().split()) for i in range(1011): if int(i * 0.08) == a and int(i * 0.1) == b: print(i) break else: print(-1)" p03380,s053593772,Accepted,"N = int(input()) A = sorted(list(map(int, input().split()))) l = A[-1] m = A[-1]//2 r = 0 tmp = 0 for i in range(N): d = min(abs(l-A[i]), abs(0-A[i])) if tmp < d: r = A[i] tmp = d print(l, r)" p03327,s064776913,Accepted,"n = int(input()) if n < 1000: print(""ABC"") else: print(""ABD"")" p03437,s598292425,Wrong Answer,"a, b = map(int, input().split()) for i in range(10**18): if i != a: if i%8 == 0 and i%6 != 0: print(i) break if a == b: print(-1) break " p04034,s944640130,Accepted,"N, M = map(int, input().split(' ')) nums = [1 for _ in range(N)] has_balls = [False for _ in range(N)] has_balls[0] = True for _ in range(M): x, y = map(int, input().split(' ')) x -= 1 y -= 1 if has_balls[x]: has_balls[y] = True nums[y] += 1 nums[x] -= 1 if not nums[x]: has_balls[x] = False ret = 0 for h in has_balls: if h: ret += 1 print(ret) " p03695,s684744184,Accepted,"n = int(input()) al = list(map(int,input().split())) ansl = [0] * 9 for a in al: k = min(a // 400, 8) ansl[k] += 1 min_ans = 0 for a in ansl[:8]: if a > 0: min_ans += 1 max_ans = min_ans if ansl[-1] > 0: if min_ans == 0: min_ans += 1 max_ans += ansl[-1] else: max_ans = min_ans + ansl[-1] print(min_ans, max_ans)" p03163,s595063536,Wrong Answer,"import numpy as np INF = 2**60 N, W = map(int, input().split()) wv = [map(int, input().split()) for i in range(N)] dp = np.full((N+1, W+1), -INF, dtype = np.int) dp[0][0] = 0 # 初期条件 for i, (w, v) in enumerate(wv): dp[i+1] = np.maximum(dp[i+1], dp[i]) dp[i+1][w:] = np.maximum(dp[i+1][w:], dp[i][:-w] + v) print(np.max(dp[N][:W]))" p02613,s567502549,Accepted,"n=int(input()) A=0 W=0 T=0 R=0 for i in range(n): a=input() if a=='AC': A+=1 if a=='WA': W+=1 if a=='TLE': T+=1 if a=='RE': R+=1 print('AC x '+str(A)) print('WA x '+str(W)) print('TLE x '+str(T)) print('RE x '+str(R))" p03803,s773333267,Accepted,"a, b = map(int, input().split()) if a ==1: a += 100 if b ==1: b += 100 if a == b : print('Draw') elif a > b : print('Alice') else: print('Bob')" p03042,s262945040,Wrong Answer,"S = input() year_list = [""01"",""02"",""03"",""04"",""04"",""05"",""06"",""07"",""08"",""09"",""10"",""11"",""12""] if S[0:2] in year_list: if S[2:4] in year_list: print(""AMBIGUOUS"") else: print(""YYMM"") else: if S[2:4] in year_list: print(""MMYY"") else: print(""NA"")" p03211,s276538749,Accepted,"s = input() n = len(s) ans = 1000 for i in range(n-2): c = int(s[i])*100+int(s[i+1])*10+int(s[i+2]) ans = min(ans,abs(753-c)) print(ans)" p03285,s923824564,Wrong Answer,"n=int(input()) print(""Yes""if n%4==0 or n%7==0 or n%11==0 else ""No"")" p03105,s448341538,Accepted,"# input A, B, C = map(int, input().split()) # check max_cnt = B // A if max_cnt > C: print(C) else: print(max_cnt) " p02814,s329751236,Accepted,"#abc150d def gcd(a,b): while b: a,b=b,a%b return a def lcm(a,b): return a/gcd(a,b)*b import sys n,m=map(int,raw_input().split()) a=map(int,raw_input().split()) LCM=1 for i in range(n): LCM=lcm(LCM,a[i]) for i in range(n): if LCM/a[i]%2==0: print 0 sys.exit() res=(m/(LCM/2)+1)/2 print res " p02731,s101575741,Wrong Answer,"l = int(input()) a = 0 for i in range(l): for j in range(l-i): k = l-(i+j) #print(i,j,k) a = i*j*k if i*j*k > a else a print(float(a))" p02553,s224986683,Wrong Answer,"a,b,c,d = map(int,input().split()) xp = True if a + b > 0 else False yp = True if c + d > 0 else False if xp: if yp: ans = b * c else: ans = a * d else: if yp: ans = b * c else: ans = b * d print(ans)" p03254,s681602946,Accepted,"def resolve(): N,x = map(int,input().split()) A = list(map(int,input().split())) A.sort() Acouont = 0 ans = 0 if sum(A) < x: print(N-1) else: for i in range(N): Acouont = Acouont + A[i] #print (Acouont) if Acouont > x: break ans += 1 print(ans) resolve()" p02717,s702796384,Accepted,"x, y, z = list(map(int, input().split())) x, y = y, x x, z = z, x print(x,y,z) " p03105,s623557894,Wrong Answer,"a,b,c=map(int,input().split()) print(max(b//a,c))" p02754,s198500231,Wrong Answer,"n,a,b = map(int,input().split()) if a+b <= n: iter_num = n // (a+b) ans = iter_num * a ans += n - (a+b) * iter_num print(ans) else: print(a) " p03448,s743092151,Accepted,"coin_500 = int(input()) coin_100 = int(input()) coin_50 = int(input()) total = int(input()) count = 0 # 合計金額の全通り for i in range(coin_500 + 1): for j in range(coin_100 + 1): for k in range(coin_50 + 1): if 500 * i + 100 * j + 50 * k == total: count += 1 print(count)" p03211,s377376697,Wrong Answer,"s=input() print(min([abs(753-int(s[i:i+3])) for i in range(len(s)-3)])) " p02917,s282107310,Accepted,"N = int(input()) B = list(map(int, input().split())) A = [0] * N for i in range(N): if i == 0: A[0] = B[0] elif i == N - 1: A[i] = B[i - 1] else: a = min(B[i - 1], B[i]) A[i] = a ans = sum(A) print(ans)" p02597,s562644417,Accepted,"_,C=input(),input() a=C.count('R') print(a-C[:a].count('R'))" p04033,s352967362,Wrong Answer,"a, b = map(int, input().split()); if a * b <= 0 : print('zero') exit(0) if a > 0 and b > 0 : print('Positive') exit(0) x = b - a + 1 if(x%2 == 0) : print('Positive') else : print('Negative') " p02646,s809336961,Accepted,"a,v = map(int, input().split()) b,w = map(int, input().split()) t = int(input()) if v <= w: print('NO') else: if t*(v-w) >= abs(a-b): print(""YES"") else: print(""NO"") " p02831,s773489444,Accepted,"import fractions A, B = map(int, input().split()) print(A * B // fractions.gcd(A, B))" p02742,s005280309,Accepted,"m,n=map(int,input().split()) res=m*n if m==1 or n==1: print(1) else: if res%2==0: print(res//2) else: print((res//2)+1) " p03417,s630261049,Accepted,"def solve(): N, M = map(int, input().split()) if N == 1 and M == 1: print(1) exit() if M < N: N, M = M, N if N == 1: print(M - 2) exit() print((N - 2) * (M - 2)) if __name__ == '__main__': solve() " p02705,s725111835,Accepted,"import math R = int(input()) print(2*math.pi*R)" p02882,s707227485,Wrong Answer,"import math a,b,x=map(int,input().split()) p=math.atan(2*x/a*b) print(p)" p02756,s104648503,Accepted,"s = input() q = int(input()) inv = 1 sfb = [0,"""",""""] for i in range(q): ls = list(input().split()) if ls[0] == ""1"": inv *=-1 else: f,c = ls[1:] if f == ""1"": sfb[inv] +=c else: sfb[-inv] +=c ans = sfb[1][::-1] + s + sfb[-1] print(ans[::inv]) " p03061,s653295071,Accepted,"from fractions import gcd n = int(input()) aaa = list(map(int, input().split())) p = aaa[0] f = [p] for a in aaa[1:-1]: p = gcd(p, a) f.append(p) aaa.reverse() p = aaa[0] b = [p] for a in aaa[1:-1]: p = gcd(p, a) b.append(p) b.reverse() f = [b[0]] + f b = b + [f[-1]] print(max(gcd(p, q) for p, q in zip(f, b)))" p02657,s337891893,Accepted,"a,b = map(int,input().split()) print(a*b)" p03387,s695946582,Accepted,"A,B,C=map(int,input().split()) max=max(A,B,C) sa=3*max-A-B-C if sa%2!=0: max+=1 sa=sa+3 print(sa//2)" p02657,s831676411,Wrong Answer,"# 169 # 入力を受け取ること a, b = map(int, input().split()) print(a) print(b) # 受け取った結果を使って計算する answer = a * b # 出力すること print(answer)" p03803,s713277342,Accepted,"import sys A,B = map(int,input().split()) if A < 0 or A > 13 or B < 0 or B > 13: sys.exit() if A == 1 or B == 1: if A == B: print(""Draw"") elif A == 1: print(""Alice"") elif B == 1: print(""Bob"") sys.exit() if A > B: print(""Alice"") elif B > A: print(""Bob"") else: print(""Draw"")" p03711,s665309627,Accepted,"x, y = map(int, input().split()) group = [[1,3,5,7,8,10,12], [4,6,9,11]] if x == 2 or y == 2: print('No') elif x in group[0]: if y in group[0]: print('Yes') else: print('No') elif x in group[1]: if y in group[1]: print('Yes') else: print('No')" p02813,s271448712,Accepted,"import itertools n=int(input()) p=list(map(int,input().split())) q=list(map(int,input().split())) a=[i for i in range(1,n+1)] ans1=0 k=0 ans2=0 for i in itertools.permutations(a): if list(i)==p: ans1=k if list(i)==q: ans2=k k+=1 print(abs(ans1-ans2))" p03211,s730600250,Accepted,"#-*-coding:utf-8-*- import sys input=sys.stdin.readline def ngram(data,n): return [data[i:i+n] for i in range(len(data))] def main(): s = input().rstrip() datas=ngram(s,3) answers=[] for data in datas: answers.append(abs(753-int(data))) print(min(answers)) if __name__==""__main__"": main()" p03371,s787854099,Accepted,"a,b,c,x,y=map(int,input().split()) ans1=x*a+y*b if x>=y: ans2=2*y*c+(x-y)*a#(x,y)=(3,2)であればABを4枚買う else: ans2=2*x*c+(y-x)*b ans3=2*max(x,y)*c print(min(ans1,ans2,ans3))" p02823,s596682931,Accepted,"import sys n, a, b = map(int, input().split()) # 2で割って余り1ならすれ違わない if (b - a) % 2 == 0: print((b - a) // 2) else: # 左で折り返す場合 left = ((a - 1) + (b - 1) + 1) // 2 # 右で折り返す場合 right = ((n - b) + (n - a) + 1) // 2 print(min(left, right))" p02578,s611120550,Accepted,"N=int(input()) A=list(map(int,input().split())) ans=0 mx=0 for x in A: if mx>=x: ans+=mx-x else: mx=x print(ans) " p04031,s069989063,Accepted,"N=int(input()) a=sorted(list(map(int,input().split()))) ans=10**9 for i in range(a[0],a[-1]+1): s=0 for j in range(N): x=(a[j]-i)**2 s+=x ans=min(ans,s) print(ans) " p03105,s614637321,Accepted,"#abc120_a.py A, B, C = map(int,input().split()) print(min(C,B//A))" p02970,s982516213,Accepted,"N, D = [int(x) for x in input().split()] area = D * 2 + 1 result = -(-N // area) print(result) " p03331,s193897953,Accepted,"N = input() ans = 0 for i in range(len(N)): ans += int(N[i]) if ans >= 2: print(ans) else: print(10)" p02859,s736487494,Accepted,"r = int(input()) ans = r*r print(ans)" p03774,s261599617,Wrong Answer,"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)] print(ab) print(cd) for i in range(n): seq_min = 1e9 ans = -1 for j in range(m): seq = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1]) if seq_min > seq: seq_min = seq ans = j print(ans + 1)" p03285,s975640763,Accepted,"n = int(input()) flg=False for i in range(0, 26): for j in range(0, 16): if(4*i+7*j==n): flg = True break print(""Yes"" if flg else ""No"")" p03262,s420647554,Wrong Answer,"import fractions from functools import reduce n, x = map(int, input().split()) xx = [int(i) - x for i in input().split()] xx.sort() if n == 1: ans = xx[0] else: dist = [xx[i + 1] - xx[i] for i in range(n - 1)] ans = reduce(fractions.gcd, dist) print(ans) " p04019,s750377375,Accepted,"s = list(input()) if ('S' in s and 'N' not in s) or ('S' not in s and 'N' in s): print('No') elif ('E' in s and 'W' not in s) or ('E' not in s and 'W' in s): print('No') else: print('Yes')" p02792,s636680499,Accepted,"n=int(input()) a=[[0]*9 for i in range(9)] for i in range(1,n+1): x,y =int(str(i)[0]), int(str(i)[-1]) if y>0: a[x-1][y-1]+=1 count=0 for i in range(9): for j in range(9): if i>j: continue if i==j: count+=a[i][j]**2 else: count+=a[i][j]*a[j][i]*2 print(count)" p03951,s641476433,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 = ini() s = ins() t = ins() for i in range(n + 1): if t.startswith(s[i:]): return len(s[:i] + t) return len(s + t) print(solve()) " p03041,s664216786,Wrong Answer,"num_str = input().split("" "") S = input() N = int(num_str[0]) K = int(num_str[1]) " p02912,s664926577,Wrong Answer,"n, m = map(int, input().split()) a = list(map(int, input().split())) a.sort() for _ in range(m): p = a[n-1]//2 up=n-1 low=0 while up-low == 1: nb = low+(up-low)//2 if p <= a[nb]: up = nb else: low = nb a.insert(up, p) print(sum(a[:n]))" p04030,s144992355,Accepted,"ans="""" s=input() for i in s: if i==""0"": ans+=""0"" elif i==""1"": ans+=""1"" else: if i!=[]: ans=ans[:-1] print(ans) " p03105,s753703732,Wrong Answer,"a,b,c=map(int,input().split());print(min(b,c)//a)" p02705,s123179564,Wrong Answer,"r=int(input()) l=r*3.14159265 print(l)" p02939,s093240080,Accepted,"s = input() a = [s[0]] tmp = """" cnt = 1 for i in range(1, len(s)): tmp = tmp + s[i] if a[-1] != tmp: a.append(tmp) tmp = """" cnt += 1 else: continue print(cnt) " p02675,s853688055,Wrong Answer,"N=input() if int(N[-1])==3: print(""bon"") elif int(N[-1])==0 or 1 or 6 or 8: print(""pon"") else: print(""hon"")" p04019,s689491712,Accepted,"S = input() dir = [0]*4 move = ""NWSE"" for i in S: dir[move.index(i)] += 1 p1 = (dir[0] > 0 and dir[2] > 0) or (dir[0] == 0 and dir[2] == 0) p2 = (dir[1] > 0 and dir[3] > 0) or (dir[1] == 0 and dir[3] == 0) print(""Yes"" if p1 and p2 else ""No"")" p04005,s046227340,Accepted,"a, b, c = map(int, input().split()) a1 = a//2 a2 = a - (a//2) b1 = b//2 b2 = b - (b//2) c1 = c//2 c2 = c - c//2 ans = min(a2*b*c - a1*b*c, b2 * a*c - b1*a*c) ans = min(ans, c2 * a*b - c1 * a * b) print(ans) " p02576,s518602621,Accepted,"n, x, t = map(int, input().split()) temp = int(n / x) if n % x != 0: temp += 1 print(t * temp)" p03319,s714482208,Accepted,"n,k=map(int,input().split()) print(-((1-n)//(k-1)))" p02640,s110120278,Wrong Answer,"a,b = list(map(int,input().split())) turu = 2 kame = 4 flag = 0 for x in range(a + 1): # print(""xです{}"".format(x)) for y in range(a + 1): # print(""yです{}"".format(y)) if kame * x + turu * y == b and (x + y) <= a: flag += 1 if flag == 0: print(""No"") else: print(""Yes"")" p03951,s270558941,Accepted,"N = int(input()) s = input() t = input() if s == t: print(N) else: for i in range(N): if s[i:] == t[:N - i]: print(N + i) break else: print(2 * N) " p03254,s575057910,Accepted,"N, x = list(map(int, input().split())) A = list(map(int, input().split())) #print(N, x) A.sort() #print(A) cnt = 0 for a in A: if x >= a: x -= a cnt += 1 else: break if cnt == N and x > 0: cnt = cnt - 1 print(cnt)" p02777,s254879980,Wrong Answer,"n,t = input().split() a,b = map(int,input().split()) print(a) u = input() if u == n: print(a-1,b) else: print(a,b-1)" p02572,s311200198,Accepted,"import itertools n=int(input()) a_list=list(map(int,input().split())) sum=0 ps = list(itertools.accumulate(a_list)) for i in range(n-1): sum+=a_list[i]*(ps[n-1]-ps[i]) s=sum%(10**9+7) print(s) " p03852,s102553454,Wrong Answer,"c = input() if c == ""a"" or ""e"" or ""i"" or ""o"" or ""u"": print(""vowel"") else: print(""consonant"")" p02732,s842693927,Wrong Answer,"N = int(input()) A_list = list(map(int,input().split())) count=-1 for k in range(len(A_list)): for l in range(len(A_list)): if A_list[k] == A_list[l]: count+=1 print(count) count=-1 " p03077,s741864443,Accepted,"from math import ceil N=int(input()) A=int(input()) B=int(input()) C=int(input()) D=int(input()) E=int(input()) def calc(A): if N%A==0: return N//A else: return N//A+1 a=calc(A) b=1+max(a, calc(B)) c=2+max(b-1,calc(C)) d=3+max(c-2, calc(D)) e=4+max(d-3, calc(E)) print(e)" p02796,s112144722,Wrong Answer,"import numpy as np import sys input = sys.stdin.readline n = int(input().rstrip()) s = 0 d = 0 e = min(n-2,3) hanni = sorted([[int(x) for x in input().rstrip().split()] for _ in range(n)], key=lambda x: (x[1], x[0])) for _ in range(n): if s != len(hanni)-1 and hanni[s][1] > hanni[s+1][0]: d += 1 if d>=e: del hanni[s] d = 0 else: s+=1 else: s+=1 d = 0 print(len(hanni)) " p03745,s146869434,Accepted," n = int(input()) a_s = list(map(int, input().split())) flag = 0 ans = 1 tmp = 0 for i in range(n): if i == 0: continue elif a_s[i] > a_s[i-1]: if flag == -1: ans += 1 flag = 0 else: flag = 1 elif a_s[i] < a_s[i-1]: if flag == 1: ans += 1 flag = 0 else: flag = -1 print(ans) " p03487,s710138463,Accepted,"import collections n = int(input()) #a,b = map(int,input().split()) a_L = list(map(int,input().split())) counter = collections.Counter(a_L) ans = 0 for k,v in counter.items(): if k == v: continue elif k < v: ans += v - k else: ans += v print(ans) " p02700,s193601558,Accepted,"A, B, C, D = list(map(int, input().split(' '))) turn = 0 while A > 0 and C > 0: if turn % 2 == 0: C -= B else: A -= D turn += 1 if A <= 0: print('No') else: print('Yes')" p03043,s057391857,Accepted,"n , k = map(int,input().split()) ans = 0 def double(i,k): while i < k : i *= 2 return i for i in range(1,n+1): ans += (i / double(i,k)) / n print(ans)" p03086,s920362190,Accepted,"s=str(input()) cnt=0 for i in range(len(s)): tmp=0 for j in range(len(s)-i): if(s[i+j]==""A""or s[i+j]==""C""or s[i+j]==""G"" or s[i+j]==""T""): tmp+=1 else: break cnt = max(cnt,tmp) print(cnt)" p02802,s356265625,Accepted,"n,m = map(int, input().split()) pena=[0]*(n+1) seitou=[0]*(n+1) for i in range(m): p,s = map(str,input().split()) p=int(p) if s==""WA"" and seitou[p]==0: pena[p]+=1 if s==""AC"": seitou[p]=1 pena_kazu=0 for i in range(1,n+1): if seitou[i]==1: pena_kazu+=pena[i] seitou_kazu=sum(seitou) print(str(seitou_kazu)+"" ""+str(pena_kazu))" p02772,s256851007,Wrong Answer,"n = int(input()) a = [int(i) for i in input().split()] f = True for i in a: if i % 2: continue elif i % 3 != 0 or i % 5 != 0: f = False break print('APPROVED' if f else 'DENIED') " p03475,s149528229,Accepted,"N = int(input()) CSFlist = [list(map(int, input().split())) for _ in range(N-1)] def calc_time(start): now = 0 for i in range(start, N-1): C, S, F = CSFlist[i] if now < S: now = S if now % F != 0: now += F - now % F now += C return now for _ in range(N-1): print(calc_time(_)) print(0)" p03309,s249201572,Wrong Answer,"N = int(input()) A = list(map(int,input().split())) res = 0 b = A[N//2 - 1] - (N//2) print(b) for i in range(N): res += abs((i+b+1) - A[i]) print(res)" p02811,s319226117,Accepted,"k, x = list(map(int, input().split())) if k * 500 >= x: print(""Yes"") else: print(""No"")" p03836,s027821083,Accepted," sx,sy,tx,ty = map(int,input().split()) for i in range(tx-sx): print(""R"",end = """") for i in range(ty-sy): print(""U"",end = """") for i in range(tx-sx): print(""L"",end = """") for i in range(ty-sy): print(""D"",end = """") print(""D"",end = """") for i in range(tx-sx+1): print(""R"",end = """") for i in range(ty-sy+1): print(""U"",end = """") print(""L"",end = """") print(""U"",end = """") for i in range(tx-sx+1): print(""L"",end = """") for i in range(ty-sy+1): print(""D"",end = """") print(""R"")" p03774,s523876656,Accepted,"N, M = map(int, input().split()) slist = [] plist = [] for i in range(N): a, b = map(int, input().split()) slist.append([a,b]) for i in range(M): c, d = map(int, input().split()) plist.append([c,d]) for i in range(N): list = [] for j in range(M): list.append(abs(slist[i][0] - plist[j][0]) + abs(slist[i][1] - plist[j][1])) print(list.index(min(list)) + 1)" p02993,s318817785,Accepted,"S=input() if S[0]==S[1] or S[1]==S[2] or S[2]==S[3]: print('Bad') else: print('Good')" p02661,s827925636,Accepted,"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() if N%2==0: print(B[N//2-1] + B[N//2] - (A[N//2-1] + A[N//2]) + 1) else: print(B[(N-1)//2] - A[(N-1)//2] + 1)" p03417,s533147457,Wrong Answer,"n, m = map(int, input().split()) if n == 1 or m == 1: ans = max(n, m) - 2 else: ans = n * m - 2 * n - 2 * m + 4 print(ans) " p02548,s469563264,Accepted,"from collections import Counter N = int(input()) ans = 0 C = Counter([]) for a in range(1, N + 1): for b in range(1, N + 1): if a * b >= N: break ans += 1 if a == b: C[a * b] += 1 for v in C.values(): if v >= 2: ans -= (v - 1) print(ans) " p02631,s501521380,Wrong Answer,"n=int(input()) a=list(map(int,input().split())) ans=[] l=0 for i in range(n): t=list(bin(a[i])) l=max(l,len(t)-2) temp=0 for j in range(2,len(t)): if t[j]==""0"": temp=temp+2**(len(t)-j-1) tl=len(t)-2 while tl 1 else 0) " p02584,s419441093,Accepted,"x, k, d = map(int, input().split()) x = abs(x) if x >= k * d: print(x - k * d) else: div, mod = divmod(x, d) if (k - div) % 2 == 0: print(mod) else: print(abs(mod - d))" p02988,s609049451,Accepted,"n = int(input()) p = list(map(int,input().split())) count=0 for i in range(0,n-2): #print(i) p_list=[p[i],p[i+1],p[i+2]] #print(p_list) p_sorted=sorted(p_list) #print(p_sorted) if p_list[1]==p_sorted[1]: count+=1 print(count)" p03210,s813665939,Accepted,"x = int(input()) if x == 3 or x == 5 or x ==7: print('YES') else: print('NO')" p03103,s544325939,Wrong Answer,"n,m=list(map(int,input().split())) d={} for _ in range(n): a, b = list(map(int, input().split())) d[a]=b sd=dict(sorted(d.items())) result=0 ans=0 for i in sd: result+=d[i] ans+=i*d[i] if result>=m: ans-=i*(result-m) break print(ans)" p02675,s371350692,Accepted,"n = int(input()[-1]) if n in [2,4,5,7,9]: print('hon') elif n in [0,1,6,8]: print('pon') else: print('bon') " p03385,s919056034,Accepted,"li = list(input()) li.sort() s = '' for i in li: s += i if s == 'abc': print('Yes') else: print('No')" p03219,s651756823,Accepted,"x,y=map(int,input().split()) print(x+y//2)" p03543,s343114749,Accepted,"a, b, c, d = input() print(""Yes"" if a==b==c or b==c==d else ""No"")" p04043,s648305711,Accepted,"print(['YES','NO'][sum(list(map(int,input().split()))) != 17])" p03160,s141143504,Wrong Answer,"def ch_min(a, b): if (a > b): a = b return a if __name__ == ""__main__"": N = int(input()) h = list(map(int, input().split())) INF = 10 ** 10 dp = [INF] * 100010 dp[0] = 0 for i in range(N): dp[i + 1] = ch_min(dp[i], dp[i] + abs(h[i] - h[i - 1])) if (i > 1): dp[i + 2] = ch_min(dp[i], dp[i] + abs(h[i] - h[i - 2])) print(dp[N - 1]) " p02994,s794848379,Accepted,"#!/usr/bin/env python3 n, l = map(int, input().split()) li = list(i for i in range(1, n+1, 1)) ab = 10000 ans = 0 for i in li: if abs(l + i - 1) < ab: ab = abs(l + i - 1) ans = l + i - 1 su = sum(li) + n * l - n print(su - ans) " p02860,s790269038,Wrong Answer,"n = int(input()) s = input() if s[:(n//2-1)]==s[:(n//2-1)]: print(""Yes"") else: print(""No"")" p02719,s234423768,Accepted,"n,k = map(int,input().split()); i = 0; if n == k: print(0); elif n < k: print(min(n,k-n)); else: v = (n - k)%k; if v*2 >= k: print(k-v); else: print(v);" p03062,s878118511,Accepted,"# coding: UTF-8 import sys import numpy as np import math n = int(input()) aList = list(map(int, input().split())) numMinus = 0 for i in range(n): if aList[i] < 0: numMinus += 1 aList[i] *= -1 aList.sort() if numMinus % 2 == 0: print(sum(aList)) else: print(sum(aList) - 2 * aList[0]) " p02801,s510841672,Wrong Answer,"# -*- coding: utf-8 -*- import sys def main(): alist = [ ""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"", ] input = sys.stdin.readline() print(input) i = 0 for a in alist: if str(input) == a: print(alist[i+1]) i += 1 if __name__ == '__main__': main()" p02640,s450730626,Wrong Answer,"X, Y = list(map(int, input().split())) for i in range(1,X+1): if 2*i + 4*(X-i) == Y: print('Yes') exit() print('No')" p03860,s055273997,Accepted,"i,j,k=input().split() print(i[0]+j[0]+k[0])" p03699,s867477957,Accepted,"import sys n = int(input()) s = sorted([int(input()) for _ in range(n)]) cnt = 0 x = sum(s) if x % 10 != 0: print(x) sys.exit() for num in s: if num % 10 == 0: cnt += 1 if cnt == len(s): print(0) sys.exit() for i in range(n): if s[i] % 10 != 0: del s[i] break print(sum(s))" p03317,s919088869,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) print(((N-2) // (K-1))+1) " p03437,s805184714,Wrong Answer,"X, Y = map(int, input().split()) if Y % X == 0: ans = -1 else: ans = X print(ans)" p03854,s519833168,Wrong Answer,"#049_C s = input() s = s.replace('dream', '').replace('dreamr', '').replace('erase', '').replace('eraser', '') print('YES' if s == '' else 'NO')" p04005,s081226878,Accepted,"l = list(map(int, input().split())) flg = True for i in l: if i % 2 == 0: flg = False if flg: l.remove(max(l)) print(l[0] * l[1]) else: print(0)" p03605,s144553843,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 import functools n = input() for i in range(len(n)): if n[i] == ""9"": print(""Yes"") sys.exit() print(""No"")" p03815,s455819002,Accepted,"N = int(input()) num = N // 11 res = num * 2 k = num * 11 if 0< N % 11 <= 6: res += 1 elif 7<= N % 11 <= 10: res += 2 else: pass print(res)" p02786,s469077293,Wrong Answer,"# input H = int(input()) M = [H] cnt = 0 print(M) while [1] * len(M) != M: target = [(idx, m) for idx, m in enumerate(M) if m > 1] for idx, m in target: M += [m // 2, m // 2] M.remove(m) cnt += 1 print(M) print(cnt + len(M)) " p03309,s877738083,Accepted,"N=int(input()) A=list(map(int,input().split())) for i in range(N): A[i]-=i B=sorted(A) x=B[N//2] print(sum(abs(A[i]-x) for i in range(N))) " p02797,s347735090,Accepted,"N, K, S = map(int, input().split()) ans = [str(ele) for ele in ([S] * K + [(S - 1) if S != 1 else 10**9] * (N - K))] print("" "".join(ans)) " p03778,s917445520,Accepted,"w, a, b = map(int,input().split()) hidari = min(a,b) migi = max(a,b) sa = migi - hidari r = 0 if sa <= w: r = 0 else: r = sa - w print(r)" p02854,s698967875,Accepted,"n = int(input()) a = list(map(int, input().split())) l1 = 0 l2 = sum(a) d = l2 for i in range(n): l1 += a[i] d = min(d, abs(2*l1 - l2)) print(d)" p02726,s119014672,Accepted,"from collections import Counter n, x, y = map(int, input().split()) def func(i,j,x=x,y=y): return min(abs(j-i), abs(x-i)+1+abs(y-j)) count = [] for i in range(1,n): for j in range(i+1, n+1): count.append(func(i,j)) counted = Counter(count) for i in range(1,n): print(str(counted[i]))" p02642,s751716081,Accepted,"N = int(input()) A = list(map(int,input().split())) A = sorted(A) d = {} for a in A: d.setdefault(a,0) d[a] += 1 A = sorted(set(A)) t = [True] * (10 ** 6 + 1) for a in A: if d[a] > 1: t[a] = False for i in range(a + a, 10 ** 6 + 1, a): t[i] = False print(sum(1 for a in A if t[a]))" p02971,s861310703,Accepted,"N = int(input()) a1 = 0 a2 = 0 a1_ind = -1 for i in range(0,N): x = int(input()) if a1 < x: a2 = a1 a1 = x a1_ind = i elif a2 < x: a2 = x for i in range(0,N): if i == a1_ind: print(a2) else: print(a1)" p02743,s465328686,Accepted,"from decimal import Decimal a,b,c = map(Decimal, input().split()) print('Yes' if 4*a*b < (c-a-b)**2 and c-a-b >= 0 else 'No')" p03796,s299182478,Accepted,"a=1 mod=10**9+7 n=int(input()) for i in range(1,n+1): a=(a*i)%mod a%=mod print(a)" p02775,s197791203,Accepted,"n = input() precise = 0 ok_over = 1 ok_prec = 0 for d in n: d = int(d) new_over = min(precise + d + 1, ok_over + d + 2, ok_over + 9 - d, ok_prec + d + 1) new_prec = min(ok_over + d + 1, ok_prec + d) precise += d ok_over = new_over ok_prec = new_prec ok_over += 1 print(min(precise, ok_over, ok_prec)) " p03862,s657249528,Accepted,"N,x = map(int,input().split()) a = list(map(int,input().split())) ans = 0 for i in range(N-1): if a[i] + a[i+1] > x: y = a[i] + a[i+1] - x ans += y a[i+1] = max(0,a[i+1]-y) print(ans)" p03774,s060394102,Accepted,"#!/usr/bin/env python3 N, M = map(int, input().split()) S = [[*map(int, input().split())] for _ in range(N)] C = [[*map(int, input().split())] for _ in range(M)] for a, b in S: mi = 10**9 ans = 51 for i in range(M): c, d = C[i] if abs(a - c) + abs(b - d) < mi: ans = i + 1 mi = abs(a - c) + abs(b - d) print(ans) " p02732,s578432179,Wrong Answer,"import copy N = int(input()) A = list(map(int, input().split())) a_types = set(A) count_dict = [0] * N for each in a_types: count_dict[each - 1] = A.count(each) for each in A: count_dict[each - 1] += 1 all_types = 0 for value in count_dict: all_types += value * (value - 1) // 2 # result_dict = {} # for each in a_types: # result_dict[each] = all_types - count_dict[each] + 1 for a in A: print(all_types - count_dict[a - 1] + 1)" p02730,s233648341,Accepted,"flag=True S=input() for i in range(len(S)//2): if S[i]!=S[len(S)-1-i]: flag=False if flag: for i in range(((len(S)-1)//2)//2): if S[i]!=S[(len(S)-1)//2-i-1]: flag=False if flag: if S[:(len(S)-1)//2]!=S[(len(S)+3)//2-1:]: flag=False if flag: print(""Yes"") else: print(""No"")" p03495,s615140310,Accepted,"n,k = map(int,input().split()) a = [int(i) for i in input().split() ] d = {} for i in a: if i in d: d[i] += 1 else: d[i] = 1 d = sorted(d.values()) if len(d) > k: ans = 0 for i in range(len(d)-k): ans += d[i] print(ans) else: print(0) " p03719,s734192383,Wrong Answer,"A,B,C = input().split() if C >= A and C <= B: print('YES') else: print('NO')" p03339,s063774466,Accepted,"N = int(input()) S = input() min_num = N+1 W = [] E = [] w_cnt = 0 e_cnt = 0 for i in range(N): if S[i] == 'W': w_cnt += 1 W.append(w_cnt) for i in range(N-1,0,-1): min_num = min(min_num,W[i-1]+e_cnt) if S[i] == 'E': e_cnt += 1 print(min(min_num,e_cnt)) " p02988,s011058951,Accepted,"n = int(input()) p = list(map(int,input().split())) count = 0 for i in range(1,n-1): if p[i] != max(p[i-1],p[i],p[i+1]) and p[i] != min(p[i-1],p[i],p[i+1]): count += 1 print(count)" p03360,s140089265,Accepted,"*a,b=map(int,open(0).read().split());print(sum(a)+max(a)*(2**b-1))" p02814,s044338750,Accepted,"n, m = map(int, input().split()) l = list(map(int, input().split())) def gcd(x, y): return x if y == 0 else gcd(y, x % y) def lcm(x, y): return (x * y) // gcd(x, y) k = 1 for i in l: i //= 2 k = lcm(k, i) if (k // i) % 2 == 0 or k > m: print(0) break else: print(m // k - m // (k * 2))" p02598,s892031070,Wrong Answer,"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 = 1 r = max(a) while (r - l) > 1: mid = (l + r) // 2 if cal(mid): r = mid else: l = mid print(r)" p03997,s124033013,Accepted,"a, b, h = int(input()), int(input()), int(input()) print((a+b)*h//2)" p02690,s165393884,Wrong Answer,"x = int(input()) y = [] count1 = 0 flag = 0 for i in range(0, 70): y.append(i*i*i*i*i) for i in y: if i == x: print(""0 -"" + str(count1)) flag = 1 break; count1 += 1 count1 = 0 for i in y: if flag == 1: break; count2 = 0 for j in y[:count1]: y2 = i + j y3 = i - j if y2 == x: print(str(count1) + "" -"" + str(count2)) break; if y3 == x: print(str(count1) + "" "" + str(count2)) break; count2 +=1 count1 += 1" p02576,s059977880,Accepted,"N, X, T = map(int, input().split()) if N%X ==0: print((N//X)*T) else: print((N//X + 1)*T)" p03262,s229262011,Accepted,"n,x = map(int,input().split()) lst=list(map(int,input().split())) new_lst=[abs(i-x) for i in lst] def gcd(x,y): if y==0 : return x else: return gcd(y,x%y) #print(gcd(n,x)) ans=new_lst[0] for i in range(1,n): ans =gcd(new_lst[i],ans) print(ans)" p02661,s750685675,Accepted,"n, *AB = map(int, open(0).read().split()) A, B = map(sorted, [AB[::2], AB[1::2]]) mid = n//2 a = A[mid] b = B[mid] if n % 2 == 0: a += A[mid-1] b += B[mid-1] print(b-a+1)" p03106,s245554772,Accepted,"A,B,K=map(int,input().split()) list=[] for i in range(1,min(A,B)+1): if A%i==0 and B%i==0 : list.append(i) print(list[len(list)-K])" p02957,s224964602,Accepted,"A, B = map(int, input().split()) if (A + B) % 2 == 0: print((A + B) // 2) else: print('IMPOSSIBLE')" p03107,s352225617,Accepted,"def main(): S = input() print(min(S.count(""0""), S.count(""1"")) * 2) if __name__ == '__main__': main()" p03838,s521263343,Accepted,"x,y = [int(hoge) for hoge in input().split()] if x==y:print(0);exit() #K回… #押して反転 or 反転して押す or 反転押して反転 #-x-K or -x + K or x + k or x-k kouho = [-x-y+1,x+y+1,y-x,x-y+2] print(min([k for k in kouho if k>0]))" p03285,s784793804,Accepted,"n = int(input()) ok = ""No"" for cake in range(0, 26): for daunut in range(0, 15): if 4 * cake + 7 * daunut == n: # print(f""4 * {cake} + 7 * {daunut} == {n}"") ok = ""Yes"" break print(ok)" p02923,s911182415,Wrong Answer,"n,*h=map(int,open(0).read().split()) h=h+[0] ans=0 tmp=0 for i in range(n): if h[i]-h[i+1]>=0: tmp+=1 else: tmp=0 ans=max(ans,tmp) print(ans-1)" p03607,s280050405,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() cnt = 0 for v in collections.Counter([ri() for _ in range(n)]).values(): if v&1==0: cnt += 1 print(cnt) " p03617,s886260902,Accepted,"q,h,s,d=map(int,input().split()) n=int(input()) l = min(q*8, h*4, s*2, d) if l != d or n % 2 == 0: print(l*n//2) else: print(l*(n//2)+min(q*4, h*2, s))" p03827,s769546094,Accepted,"N = int(input()) S = input() x, max_x = 0, 0 for c in S: if c == 'I': x += 1 elif c == 'D': x -= 1 if x > max_x: max_x = x print(max_x) " p02548,s655273460,Accepted,"import sys input = sys.stdin.readline def main(): ans = 0 N = int(input()) for i in range(1, N): ans += (N-1)//i print(ans) if __name__ == '__main__': main()" p04033,s515566871,Wrong Answer,"a,b = map(int, input().split()) L = [] for i in range (a,b+1): L.append(i) P = 1 for j in L: P *= j if P > 0: print('Positive') elif P == 0: print('Zero') else: print('Negetive')" p03679,s992679404,Accepted,"x, a, b=map(int, input().split()) if a>=b: print(""delicious"") elif a+x>=b: print(""safe"") else: print(""dangerous"") " p03761,s219897499,Accepted,"from collections import Counter N = int(input()) cnt = Counter() for i in range(26): s = chr(ord(""a"")+i) cnt[s] = 100 for _ in range(N): S = input() for i in range(26): s = chr(ord(""a"")+i) cnt[s] = min(S.count(s), cnt[s]) res = """" for i in range(26): s = chr(ord(""a"")+i) res += s*cnt[s] print(res)" p03607,s149463792,Accepted,"from collections import defaultdict dic = defaultdict(int) N = int(input()) for _ in range(N): v = int(input()) dic[v] += 1 count = 0 for k, v in dic.items(): if v%2: # push count += 1 else: # push & pop pass print(count)" p03338,s366340670,Wrong Answer,"N=int(input()) S=input() ans=1 for i in range(N): ans=max(ans,len(list(set(list(S[:i+1])) & set(list(S[i+1:]))))) print(ans)" p03817,s929435977,Wrong Answer,"from math import ceil x = int(input()) print(ceil(x / 11) * 2 + (x % 11) // 6 - 1)" p02689,s528713039,Accepted,"N , M = map(int,input().split()) Height = [h_i for h_i in map(int,input().split())] Roots = [] counter = [0 for i in range(N)] for j in range(M): root = [c_i -1 for c_i in map(int,input().split())] #print(root) if Height[root[0]]= B[i]: mon += B[i] else: mon += A[i] res = B[i] - A[i] if A[i + 1] >= res: A[i + 1] = A[i + 1] - res mon += res else: mon += A[i + 1] A[i + 1] = 0 # print(mon) print(mon) " p03137,s695892999,Accepted,"n, m = map(int, input().split()) x = sorted(list(map(int, input().split()))) l = [] if n >= m: print(0) exit() for i in range(m - 1): l.append(x[i + 1] - x[i]) l = sorted(l)[::-1] del l[0: n - 1] print(sum(l)) " p02639,s484541403,Accepted,"X=list(map(int,input().split())) for i in range(5): if X[i]==0: print(i+1)" p03319,s256643005,Wrong Answer,"import math n, k = map(int, input().split()) l = list(map(int, input().split())) if n == k: print(1) else: print(math.ceil(n/(k-1)))" p03797,s640043817,Accepted,"n,m=map(int,input().split()) if 2*n>=m: print(m//2) else: ans=n ans+=(m-2*n)//4 print(ans)" p02713,s385738450,Accepted,"def gcd(x, y): if y == 0: return x else: return gcd(y, x % y) n=int(input()) ans=0 for i in range(1,n+1): for j in range(i,n+1): for k in range(j,n+1): if i!=j!=k: ans+=6*gcd(gcd(i,j),k) elif i==j==k: ans+=i else: ans+=3*gcd(gcd(i,j),k) print(ans) " p02712,s430339531,Wrong Answer,"n=int(input()) sum=0 for count in range(n): if(count%3==0)|(count%5==0): continue else: sum=sum+count print(str(sum)) " p02753,s601957344,Accepted,"S = input() print(""No"" if S == ""AAA"" or S == ""BBB"" else ""Yes"") " p02723,s492524962,Accepted,"s = list(str(input())) if s[2]==s[3] and s[4]==s[5]: print('Yes') else: print('No')" p02860,s104169860,Accepted,"n = int(input()) s = input() print('Yes' if s[:n//2] == s[n//2:] else 'No') " p02811,s517273525,Wrong Answer,"K,X = map(int, input().split()) #総額 SUM = 500*X #判定 if SUM >= X: print(""Yes"") else: print(""No"") " p03997,s182806970,Wrong Answer,"a = int(input()) b =int(input()) h = int(input()) x = (a+b)*h/h print(int(x))" p02691,s197192689,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): ima = i-a if ima in CNT: ans += CNT[ima] CNT[i+a] += 1 print(ans) " p02718,s397734742,Wrong Answer,"N,M = map(int,input().split()) A = list(map(int,input().split())) A.sort(reverse = True) num = 0 for i in A: num += i if A[M-1] >= num//(4*M): print('Yes') else: print('No')" p03695,s642099671,Accepted,"def main(): participants = int(input()) ratings = list(map(int, input().split())) color = [0] * 9 for rating in ratings: color[min(rating // 400, 8)] += 1 answer = 0 for i in range(8): if color[i] > 0: answer += 1 print(max(1, answer), answer + color[-1]) if __name__ == '__main__': main() " p02642,s449410159,Accepted,"from collections import Counter def main(): M = 10 ** 6 _ = int(input()) A = list(map(int,input().split())) erato = [True] * (M+10) m = sorted(Counter(A).items()) ans = 0 for t in m: if t[1] == 1 and erato[t[0]]: ans += 1 for i in range(t[0],M+1,t[0]): erato[i] = False print(ans) if __name__ == '__main__': main()" p03998,s797202649,Accepted,"A=list(input()[::-1]) B=list(input()[::-1]) C=list(input()[::-1]) next=""a"" while True: #print(next) if next==""a"": if len(A)==0: print(""A"");exit() next=A.pop() elif next==""b"": if len(B)==0: print(""B"");exit() next=B.pop() else: if len(C)==0: print(""C"");exit() next=C.pop() " p03994,s541899923,Accepted,"# coding: utf-8 # Your code here! s=input() K=int(input()) ans=[] #122 for item in s[:len(s)-1]: cost=(123-ord(item)) if item==""a"": ans.append(item) continue if K>=cost: K-=cost ans.append(""a"") else: ans.append(item) K%=26 last=ord(s[-1]) if last+K>122: ans.append(chr(last+K-26)) else: ans.append(chr(last+K)) print("""".join(ans)) " p03997,s337685088,Accepted,"a=int(input()) b=int(input()) h=int(input()) print((a+b)*h//2)" p03103,s185133965,Accepted,"n, m = map(int, input().split()) list_AB = [ list(map(int,input().split("" ""))) for i in range(n)] list_AB.sort() ans = 0 for i in range(n): l = list_AB[i] if l[1] > m: ans += l[0]*m break else: ans += l[0]*l[1] m -= l[1] print(ans)" p02633,s033472725,Accepted,"import math X=int(input()) Xjiku=float(1) Yjiku=float(0) ans=int(1) thita=int(0) for _ in range(1000000): thita += X Xjiku += math.cos(math.radians(thita)) Yjiku += math.sin(math.radians(thita)) ans += int(1) if abs(Xjiku) < float(10**-10) and abs(Yjiku) < float(10**-10): break print(ans) " p02606,s069430113,Accepted,"li =list(map(int,input().split())) n =li[0] m =li[1] k =li[2] count =0 for i in range(n,m+1): if i%k ==0: count +=1 print(count)" p02658,s638990956,Accepted,"n = int(input()) a = list(map(int, input().split())) if 0 in a: print(0) exit() ans = 1 for i in a: ans *= i if ans > 10**18: print(-1) exit() print(ans)" p03943,s920426267,Accepted,"a,b,c=sorted(map(int,input().split())) print('Yes' if a+b==c else 'No') " p03761,s759419947,Accepted,"n = int(input()) S = [sorted(list(input())) for _ in range(n)] ans = [] for i in range(len(S[0])): count = 0 for j in range(n): if S[0][i] in S[j]: count += 1 if n == count: for k in range(n): if k != 0: S[k].remove(S[0][i]) ans.append(S[0][i]) print(''.join(ans))" p02835,s804352957,Accepted,"*A, = map(int, input().split()) if sum(A) >= 22: print('bust') else: print('win') " p03998,s791962238,Accepted,"Cards = {'a':list(input()),'b':list(input()),'c':list(input())} def solve(p): global Cards if len(Cards[p]) == 0: return p.capitalize() np = Cards[p].pop(0) return solve(np) print(solve('a'))" p02860,s422640140,Accepted,"import sys N = int(input()) S = input() if N%2!=0 : print(""No"") sys.exit(0) else: for i in range(int(N/2)): if S[i]!=S[i+int(N/2)]: print(""No"") sys.exit(0) print(""Yes"")" p02773,s659212408,Accepted,"from collections import Counter n = int(input()) lst = [] for _ in range(n): lst.append(input()) C = Counter(lst) x = max(C.values()) anslst = [] for k,v in C.items(): if v == x: anslst.append(k) anslst.sort() for v in anslst: print(v)" p02982,s766114073,Accepted,"import math n,d=map(int,input().split()) x=[[int(x) for x in input().split()]for _ in range(n)] cnt=0 for i in range(n): for j in range(i+1,n): sum=0 for a,b in zip(x[i],x[j]): sum+=(a-b)*(a-b) if math.sqrt(sum).is_integer(): cnt+=1 print(cnt)" p03071,s058819389,Accepted,"a, b = map(int, input().split()) if a > b: c = a a -= 1 else: c = b b -= 1 print(c+max(a, b))" p03556,s407006439,Accepted,"import math n = int(input()) print((math.floor(n**0.5)**2))" p03351,s918289736,Accepted,"a,b,c,d=map(int,input().split()) if (abs(a-b)<=d)and(abs(b-c)<=d): print('Yes') elif abs(a-c)<=d: print('Yes') else: print('No')" p02802,s690983295,Accepted,"N, M = map(int, input().split()) ps = [input().split() for i in range(M)] ac = 0 wa = [0 for i in range(N)] ansed = set() for psn in ps: if psn[1] == 'AC': if psn[0] not in ansed: ac += 1 ansed.add(psn[0]) else: if psn[0] not in ansed: wa[int(psn[0])-1] += 1 for i in range(N): if str(i+1) not in ansed: wa[i] = 0 print(ac, sum(wa))" p02639,s824054756,Accepted,"x = 1 + 2 + 3 + 4 + 5 a = list(map(int, input().split())) print(x - sum(a)) " p03416,s809022334,Accepted,"a, b = map(int, input().split()) ans = 0 for i in range(a, b+1): c = str(i) if c==c[::-1]: ans += 1 print(ans)" p02767,s574317292,Accepted,"#ABC156 C - Rally n = int(input()) x = [int(x) for x in input().split(' ')] min_len = 100**2 * n for i in range(100): all_len = 0 for j in range(n): all_len += (x[j] - (i+1))**2 min_len = min(min_len,all_len) print(min_len)" p02779,s618907101,Accepted,"n = int(input()) a = list(map(int,input().split())) a.sort() p = 0 for i in range(n-1): if a[i] == a[i+1]: p += 1 if p == 0: print(""YES"") else: print(""NO"") " p02813,s939392637,Accepted,"import itertools N = int(input()) P = tuple(map(int,input().split())) Q = tuple(map(int,input().split())) ls = list(itertools.permutations(range(1,N+1))) print(abs(ls.index(P) - ls.index(Q)))" p03760,s865793681,Accepted,"a = input() b = input() a_len = len(a) b_len = len(b) huku = [] for i in range(a_len): if a_len != b_len and i==a_len-1: huku.append(a[i]) break else: huku.append(a[i]) huku.append(b[i]) for i in range(len(huku)): print(huku[i],end="""")" p02695,s722925928,Accepted,"n,m,q=map(int,input().split()) li=[list(map(int,input().split()))for _ in range(q)] ans = 0 def dfs(A): #print(A) global ans if len(A) == n+1: tmp = 0 for a,b,c,d in li: if A[b] - A[a] == c: tmp += d ans = max(ans,tmp) return for i in range(A[len(A)-1],m+1): dfs(A+[i]) dfs([1]) print(ans)" p03385,s668158770,Accepted,"s = input() if 'a' in s and 'b' in s and 'c' in s: print('Yes') else: print('No')" p02823,s613025533,Wrong Answer,"n,a,b=map(int,input().split()) if (b-a)%2==0: print((b-a)//2) else: c=n-b d=a-1 print(max(c,d))" p02989,s948373552,Accepted,"n = int(input()) D = list(map(int,input().split())) D.sort() print(D[n//2] -D[n//2-1]) " p02615,s987242496,Wrong Answer,"N = int(input()) A = list(map(int, input().split())) A.sort() print(sum(A[1:]))" p02607,s890936061,Accepted,"n = int(input()) count = 0 arr = [int(i) for i in input().split()] for i in range(1,n+1): if i % 2 == 1 and arr[i-1] % 2 == 1: count += 1 print(count) " p02879,s161437828,Accepted,"a,b=map(int,input().split()) if a<0 or a>9: print(-1) elif b<0 or b>9: print(-1) else: print(a*b)" p03041,s387448789,Accepted,"N, K = map(int, input().split()) S = input() if S[K-1] == 'A': rep = 'a' elif S[K-1] == 'B': rep = 'b' else: rep = 'c' # (K-1)文字目まで + K文字目 + K+1文字目から print(S[:K-1] + rep + S[K:])" p03309,s333584767,Accepted,"n = int(input()) a = list(map(int, input().split())) for i in range(n): a[i] = a[i] - (i + 1) a.sort() b = a[n // 2] ret = 0 for i in range(n): ret += abs(a[i] - b) print(ret) " p02946,s288930819,Wrong Answer,"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) x = ' '.join(str(ans)) print(x)" p02833,s672105852,Accepted,"N = int(input()) if N%2 == 1: print(""0"") exit(0) N = N//2 ans = 0 while N > 1: N = N//5 ans += N print(ans)" p02711,s007752299,Accepted,"N = int(input()) if int(N / 100) == 7 or int((N % 100) / 10) == 7 or N % 10 == 7: print('Yes') else: print('No')" p04012,s047087519,Accepted,"W = input() for w in W: if W.count(w)&1: print(""No"") break else: print(""Yes"")" p03457,s221091936,Wrong Answer,"N = int(input()) st = 0 sx = 0 sy = 0 flg = False for _ in range(N): t,x,y = map(int,input().split()) if (x+y)-(sx+sy) > (t-st) or (t-st) % 2 != ((x+y)-(sx+sy)) % 2: flg = True break else: st = t sx = x sy = y print('No' if flg else 'Yes')" p02900,s211786743,Accepted,"from fractions import gcd from collections import defaultdict A, B = map(int, input().split()) x = gcd(A, B) d = defaultdict(int) d[1]=1 for i in range(2, int(x**0.5)+1): while x%i==0: x//=i d[i]+=1 if x!=1: d[x]+=1 ans = len(d.keys()) print(ans)" p03944,s961086065,Accepted,"w, h, n = map(int, input().split()) right, left, lower, upper = 0, w, 0, h for _ in range(n): x, y, a = map(int, input().split()) if a == 1: right = max(right, x) if a == 2: left = min(left, x) if a == 3: lower = max(lower, y) if a == 4: upper = min(upper, y) a = left - right b = upper - lower if a <= 0 or b <= 0: print(0) else: print(a*b)" p03785,s999675454,Wrong Answer,"n,c,k=map(int,input().split()) a=sorted([int(input()) for _ in range(n)],reverse=True) cnt=0 while len(a) > 0: b=a.pop() cnt+=1 if len(a)==0: break for i in range(c-1): if a[-1]2019 or(a==2019 and b>5):print('TBD') else:print('Heisei')" p03327,s299504051,Accepted,"n = int(input()) print('ABC' if n <= 999 else 'ABD')" p03657,s030742362,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')" p02971,s599234374,Accepted,"n=int(input()) import heapq a=[] a_heap=[] for i in range(n): tmp=int(input()) a.append(tmp) heapq.heappush(a_heap,(-1)*tmp) for i in range(n): max_1=heapq.heappop(a_heap) if max_1==(-1)*a[i]: max_2=heapq.heappop(a_heap) print((-1)*max_2) heapq.heappush(a_heap,max_2) else:print((-1)*max_1) heapq.heappush(a_heap,max_1)" p03696,s101075487,Accepted,"n = int(input()) s = str(input()) A = [0] cum = 0 ans = '' for i in range(n): if s[i] == '(': cum += 1 else: cum -= 1 if cum == -1: ans = '('+ans ans += s[i] cum = 0 else: ans += s[i] else: if cum > 0: ans += ')'*cum print(ans)" p02607,s749962163,Accepted,"n = int(input()) a = list(map(int, input().split())) count = 0 for i in range(n): if (i + 1) % 2 != 0: if a[i] % 2 != 0: count += 1 print(count)" p03730,s277094438,Wrong Answer,"A, B, C = map(int, input().split()) if A == B: if C == 0: print('YES') else: print('NO') elif A > B: if C % (A % B) == 0 or (B - C) % (A % B) == 0: print('YES') else: print('NO') else: if (B - C) % A == 0: print('YES') else: print('NO')" p02767,s114933876,Accepted,"N = int(input()) X = list(map(int, input().split())) ans = float('inf') for i in range(1,100): cost = 0 for j in range(N): cost += (X[j] - i) ** 2 ans = min(ans, cost) print(ans)" p03838,s004404721,Accepted,"x,y = map(int,input().split()) if abs(x) == abs(y): print(0 if x == y else 1) elif x < y: print(min(y - x,abs(y + x) + 1)) else: print(min(abs(y+x),abs(y-x))+ 1 if x * y <= 0 else min(abs(y+x),abs(y-x))+ 2) " p03208,s916121164,Wrong Answer,"n, k = map(int, input().split()) h = [] for _ in range(n): h.append(int(input())) h.sort() answer = min(h[k - 1] - h[0], h[-1] - h[-k]) print(answer)" p02547,s243540979,Accepted,"n = int(input()) c = 0 flag = False for i in range(n): x, y = list(map(int, input().split())) if x == y: c += 1 if c == 3: flag = True break else: c = 0 if flag: print(""Yes"") else: print(""No"")" p02767,s129807259,Accepted,"N = int(input()) X = list(map(int,input().split())) avg = sum(X)//N sums_1 = 0 sums_2 = 0 for i in X: sums_1 += (avg - i)**2 for j in X: sums_2 += (avg+1 - j)**2 print(min(sums_1,sums_2))" p03000,s690738130,Accepted,"# coding: utf-8 # Your code here! N,X=map(int, input().split()) List=list(map(int, input().split())) bow=0 cnt=1 for i in range(0,N): bow+=List[i] if bow>X: break else: cnt+=1 print(cnt)" p03555,s918917106,Wrong Answer,"A = input() B = input() if A == B[::-1]: print('Yes') else: print('No')" p02647,s675935540,Accepted,"import math N,K = map(int,input().split()) A = list(map(int,input().split())) for j in range(min(K,int(2*(math.log2(N)))+10)): 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 < N-1: B[r+1] -= 1 for i in range(1,N): B[i] += B[i-1] A = B print(' '.join(map(str,A))) " p02861,s205416351,Wrong Answer,"from itertools import permutations N=int(input()) town=[] for i in range(N): x,y=map(int,input().split()) town.append((x,y)) ans=0 for i,j in permutations(town,2): ans+=(((i[0]-j[0])**2+(i[1]+j[1])**2)**0.5) print(ans/N)" p03261,s035392032,Wrong Answer,"N = int(input()) W = [input() for i in range(N)] if all(W[i+1][0]==W[i][-1] and W[i] not in W[:i] for i in range(N-1)): print('Yes') else: print('No')" p02760,s997224900,Accepted,"A = [] for i in range(3): for x in input().split(): A.append(int(x)) N = int(input()) for _ in range(N): y = int(input()) A = [0 if x == y else x for x in A] if any((sum(A[::3]) == 0, sum(A[1::3]) == 0, sum(A[2::3]) == 0, sum(A[:3]) == 0, sum(A[3:6]) == 0, sum(A[6:]) == 0, sum(A[::4]) == 0, sum(A[2:7:2]) == 0)): print('Yes') else: print('No') " p02973,s493097322,Accepted,"import sys def input(): return sys.stdin.readline().rstrip() import bisect def make_LIS(L): LIS=[L[0]] for i in range(1,len(L)): if L[i]>=LIS[-1]:#広義単調増加なら>=に LIS.append(L[i]) else: LIS[bisect.bisect_right(LIS,L[i])]=L[i] return len(LIS) def main(): n=int(input()) A=[int(input())for _ in range(n)] print(make_LIS(A[::-1])) if __name__=='__main__': main()" p02866,s810724902,Accepted,"n = int(input()) D = list(map(int, input().split())) MOD = 998244353 cnt = [0] * n for d in D: cnt[d] += 1 if D[0] == 0 and cnt[0] == 1: res = 1 else: res = 0 for i in range(1, n): res *= pow(cnt[i - 1], cnt[i], MOD) res %= MOD print(res)" p03417,s735581364,Accepted,"H,W = map(int, input().split()) h_ = (1 if H==1 else (0 if H == 2 else H-2)) w_ = (1 if W==1 else (0 if W == 2 else W-2)) ret = h_*w_ print(ret)" p02957,s018655681,Accepted,"a, b = map(int, input().split()) ab = ((a + b) / 2) if ab.is_integer(): print(int(ab)) else: print('IMPOSSIBLE') " p03774,s331393437,Accepted,"def minDistPoint(Student,List): ans_dist = 500000000 res = 0 for k,pos in List.items(): dist = abs(Student[0]-pos[0])+abs(Student[1]-pos[1]) if dist b: theta = math.atan2(a * b * b, x) print(math.degrees(theta))" p03042,s398771816,Wrong Answer,"s=list(input()) s=list(map(int,s)) a=s[0]*10+s[1] b=s[2]*10+s[3] if (a==0 and b==0) or (a>=13 and b>=13): print(""NA"") elif 0= H[B]: O[B] = 0 print(sum(O))" p03943,s974953418,Accepted,"a,b,c=sorted(map(int,input().split())) if a+b==c: print('Yes') else: print('No')" p03131,s517170842,Wrong Answer,"k, a, b = map(int, input().split()) if k > a+1 and a+2 <= b: print(max((k-a-1) // 2, 0 * (b-a) + b + (k-a-1) % 2, k+1)) else: print(k+1)" p03324,s058604505,Accepted,"d, n = map(int, input().split()) count = 0 i = 1 while True: c = 0 num = i while num >= 100: if num%100==0: num = num//100 c += 1 else: break if c==d: count += 1 if count == n: print(i) break i += 1" p04043,s579988746,Accepted,"a = input().split() sums = 0 for i in a: sums += int(i) if sums == 17: print(""YES"") else: print(""NO"")" p02832,s343474911,Accepted,"N=int(input()) A=list(map(int,input().split())) I=0 for a in A: if a==I+1: I+=1 if I==0: print(-1) else: print(N-I) " p03632,s674808852,Accepted,"a,b,c,d=map(int,input().split()) ans=0 if a <= c: if b <= c: pass elif b <= d: ans = b-c else: ans = d-c else: if d <= a: pass elif d <= b: ans = d-a else: ans = b-a print(ans) " p02719,s577265238,Accepted,"n, k = [int(i) for i in input().split()] if n % k == 0: print(0) elif n < k: print(min(n, k-n)) else: n = n - int(n//k) * k n = min(abs(n-k), n) n = min(abs(n-k), n) print(n)" p02690,s196953211,Wrong Answer,"x=int(input()) al=list(map(lambda x:-x, list(range(1,100)))) ar=list(range(100)) a=al+ar b=a.copy() for ai in a: for bi in b: if ai**5 - bi**5 == x: print(""{0} {1}"".format(ai,bi)) exit() " p03380,s751299873,Wrong Answer,"n = int(input()) a = list(map(int,input().split())) N = max(a) res = 10**10 K = 0 for i in range(n): if abs(a[i]-N//2) < res: res = abs(a[i] -N//2) K = i print(N,a[K]) " p02615,s441342981,Wrong Answer,"n=int(input()) l=list(map(int,input().split())) print(sum(l)-min(l))" p03262,s629129801,Accepted,"from fractions import gcd N, X = map(int, input().split()) xn = list(map(int, input().split())) temp = abs(xn[0]-X) for i in range(1, N): temp = gcd(xn[i]-X, temp) print(temp) " p02707,s591270885,Accepted,"n = int(input()) a = [int(x)-1 for x in input().split()] from collections import defaultdict d = defaultdict(int) for i in a: d[i] += 1 for i in range(n): print(d[i])" p03625,s818963117,Accepted,"n = int(input()) sList = sorted(list(map(int,input().split())),reverse=True) res = [] acc = False for i in range(n-1): if acc: acc = False else: if sList[i] == sList[i+1]: res.append(sList[i]) acc = True if len(res) == 2: print(res[0]*res[1]) exit(0) print(0) " p03427,s602818702,Accepted,"n = int(input()) if (n//10**(len(str(n))-1)+1)*10**(len(str(n))-1)-1 > n: mx = (n//10**(len(str(n))-1))*10**(len(str(n))-1)-1 else: mx = (n//10**(len(str(n))-1)+1)*10**(len(str(n))-1)-1 print(sum(list(map(int,str(mx)))))" p03767,s076210209,Wrong Answer,"n = int(input()) a = list(map(int, input().split())) a.sort() #強さを出力 def T(x,y,z): ma = max(x,y,z) mi = min(x,y,z) return (x+y+z) - (ma+mi) ans = 0 for i in range(0,3*n,3): ans += T(*a[i:i+3]) print(ans)" p02675,s213715682,Accepted,"N = [i for i in 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')" p03543,s581877610,Accepted,"n = input() if (n[0] == n[1] and n[1] == n[2]) or (n[1] == n[2] and n[2] == n[3]): print(""Yes"") else: print(""No"")" p02823,s327656137,Accepted,"N, A, B = [int(i) for i in input().split()] if (B-A) % 2 == 0: print((B-A)//2) else: x = min(A-1, N-B) print((B-A-1)//2+x+1) " p03059,s714150350,Accepted,"A, B, T = map(int, input().split()) print(T//A*B)" p03495,s834514971,Accepted,"from collections import Counter n, k = map(int, input().split()) a = list(map(int, input().split())) result = 0 cnt = Counter(a) cnt_set = set(cnt.items()) cnt_sort = sorted(cnt.items(), key=lambda x:x[1]) for i in range(len(cnt_set) - k): result += cnt_sort[i][1] print(result)" p02899,s124274046,Accepted,"n = int(input()) A = list(map(int,input().split())) ANS = [] for i in range(n): ANS.append([A[i],i+1]) ANS = sorted(ANS) for i in range(n): print(ANS[i][1],end = "" "")" p03328,s361311627,Wrong Answer,"a,b = map(int,input().split()) temp = 0 x,y = 999,999 for i in range(1,1000): temp += i if temp - a > 0: x = min(temp-a, x) print(x)" p02779,s400936001,Accepted,"n = int(input()) a = list(map(int, input().split())) print(""YES"" if len(list(set(a))) == n else ""NO"")" p02813,s924222182,Wrong Answer,"n = int(input()) p = list(map(int, input().split())) q = list(map(int, input().split())) import itertools pi = 0 count = 1 for i in itertools.permutations(range(1, n+1), n): if list(i) == p: pi = count break else: count += 1 qi = 0 count = 1 for i in itertools.permutations(range(1, n+1), n): if list(i) == q: qi = count break else: count += 1 print(pi, qi) ans = abs(pi - qi) print(ans)" p02600,s075425566,Wrong Answer,"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) elif x < 1999: print(1)" p02766,s577046660,Accepted,"inp = [int(i) for i in input().split()] N = inp[0] K = inp[1] n = N c = 0 while n>=1: n /= K c += 1 print(c) " p02866,s935325580,Accepted,"import collections mod=998244353 n=int(input()) arr=list(map(int,input().split())) if arr[0]!=0: print(0) else: count=collections.Counter(arr) if count[0]!=1: print(0) else: ans=1 for i in range(1,n): ans*=pow(count[i-1],count[i],mod) ans%=mod print(ans)" p02618,s828995435,Accepted,"for i in range(365): print(i%26+1)" p04005,s008243631,Wrong Answer,"# AGC 04 #TRY 2 a, b, c = map(int, input().split()) if (a or b or c) % 2 == 0: print(0) if (a and b and c) % 2 != 0 : print(min(a * b, b * c, c * a))" p03910,s523796543,Wrong Answer,"N = int(input()) print((N+2)//2)" p03623,s654379278,Wrong Answer,"x,a,b=map(int,input().split());print(""AB""[abs(x-a)90: word+=chr(ord(s[i])+n-26) else: word+=chr(ord(s[i])+n) print(word) " p04011,s318750009,Accepted,"N=int(input()) K=int(input()) X=int(input()) Y=int(input()) print(K*X+(N-K)*Y if N>=K else X*N) " p03000,s705960807,Accepted,"import sys def MI(): return map(int,sys.stdin.readline().rstrip().split()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) #空白あり N,X = MI() L = LI() a = 0 ans = 1 for i in range(N): a += L[i] if a <= X: ans += 1 print(ans) " p02972,s097511623,Accepted,"n = int(input()) a=list(map(int,input().split())) for i in range(n - 1, -1, -1): s = sum(a[i ::i + 1]) if s % 2 != a[i]: a[i] = 1 - a[i] # 1 -> 0 , 0 -> 1 print(a.count(1)) print(*[i+1 for i,x in enumerate(a) if x])" p02773,s085240814,Accepted,"n=int(input()) a=[] for i in range(n): a.append(str(input())) a=sorted(a) b=[] c=[] tmp=""."" count=0 for i in range(n): if tmp != a[i]: b.append(tmp) c.append(count) tmp=a[i] count=1 else: count += 1 b.append(tmp) c.append(count) k=sorted(c)[-1] for i in range(len(b)): if c[i]==k: print(b[i]) " p02911,s185792799,Accepted,"N,K,Q=map(int,input().split()) score=[0]*N for i in range(Q): A=int(input())-1 score[A]+=1 for i in score: if Q-K < i: print('Yes') else: print('No')" p02687,s099266715,Wrong Answer,"import sys S = str(sys.stdin.readline()) if S == 'ARC': print('ABD') else: print('ARC')" p02630,s848505815,Accepted,"N = int(input()) A_list = list(map(int,input().split())) Q = int(input()) S = sum(A_list) count_list = [0] * (10 ** 5 + 1) for A in A_list: count_list[A] += 1 for i in range(Q): B,C = map(int,input().split()) S = S + count_list[B] * (C - B) count_list[C] += count_list[B] count_list[B] = 0 print(S) # print(sum(A_list))" p02873,s085774546,Wrong Answer,"S = input() l = len(S) x = [0]*(l+3) y = [0]*(l+3) for i in range(l): if S[i] == ""<"": x[i+1] = x[i]+1 for i in range(l): if S[i] == "">"": y[l-i+1] = y[l-i+2]+1 res = 0 for i in range(l+1): res += max(x[i], y[i+2]) print(res)" p04011,s974148843,Accepted,"N=int(input()) K=int(input()) X=int(input()) Y=int(input()) if K>N: print(N*X) else: print(K*X+(N-K)*Y)" p03067,s910742790,Accepted,"def main(): a, b, c = map(int, input().split()) print('Yes' if a < c < b or b < c < a else 'No') if __name__ == '__main__': main() " p02775,s318341466,Accepted,"N = [int(n) for n in input()] dp = [[0] * 2 for _ in range(len(N) + 1)] dp[0][1] = 1 for i, n in enumerate(N): dp[i + 1][0] = min(dp[i][0] + n, dp[i][1] + (10 - n)) dp[i + 1][1] = min(dp[i][0] + (n + 1), dp[i][1] + (10 - (n + 1))) print(dp[-1][0])" p03030,s135015540,Wrong Answer,"n = int(input()) a = [] for i in range(n): s, p = input().split() a.append([s,-int(p),i]) a.sort() for i in a: print(i[-1]) " p03331,s580984178,Accepted,"n = int(input()) ans = float('inf') for a in range(1, n): b = n - a dsum = 0 for i in range(len(str(a))): x = int(str(a)[i]) dsum += x for i in range(len(str(b))): x = int(str(b)[i]) dsum += x ans = min(ans, dsum) print(ans)" p04045,s260349526,Accepted,"#ABC042 n,k = map(int,input().split()) d = input().split() c = True while c: if all(str(n)[i] not in d for i in range(len(str(n)))): print(n) c = False break else: n += 1" p03795,s749453180,Accepted,"# 55 N = int(input()) sur = 200 * (N // 15) print(800 * N - sur)" p03264,s061141541,Accepted,"k = int(input()) print((k//2)*(k-k//2))" p03329,s688155242,Accepted,"import math n = int(input()) dp = [math.inf] * (n+1) for i in range(n+1): dp[i] = min(dp[i],i) j = 6 while(i+j<=n): dp[i+j] = min(dp[i+j],dp[i]+1) j *= 6 j = 9 while(i+j<=n): dp[i+j] = min(dp[i+j],dp[i]+1) j *= 9 #print(dp) print(dp[n]) " p03252,s198392203,Wrong Answer,"# Problem C - String Transformation # input S = list(input()) T = list(input()) # initialization t_map = {} is_ok = True # mapping for i in range(len(S)): s = S[i] t = T[i] if not t in t_map: t_map[t] = set([s]) else: t_map[t].add(s) # check for t in t_map: if len(t_map[t])>1 and t in t_map[t]: is_ok = False # output if is_ok: print(""Yes"") else: print(""No"") " p03836,s150690790,Accepted,"sx, sy, tx, ty = map(int, input().split()) dist_x = tx - sx dist_y = ty - sy res = ""R"" * dist_x + ""U"" * dist_y + ""L"" * dist_x + ""D"" * dist_y + ""D"" + ""R"" * (dist_x + 1) + ""U"" * (dist_y + 1) + ""L"" + ""U"" + ""L"" * (dist_x + 1) + ""D"" * (dist_y + 1) + ""R"" print(res)" p02661,s657427585,Accepted,"n = int(input()) AB = [] A = [0]*n B = [0]*n for i in range(n): A[i],B[i] = map(int,input().split()) A = sorted(A) B = sorted(B) if n%2 == 1: l = A[n//2] r = B[n//2] print(r-l + 1) else: l = (A[n//2-1]+A[n//2])/2 r = (B[n//2-1]+B[n//2])/2 print(int((r-l)*2+1))" p02594,s487937128,Accepted,"if int(input()) >= 30: print(""Yes"") else: print(""No"")" p03359,s323940387,Accepted,"a,b = map(int, input().split()) print(a-(a>b))" p03252,s954805164,Accepted,"s = input() t = input() dic1 = {} dic2 = {} for i in range(len(s)): if s[i] in dic1.keys(): if dic1[s[i]]!=t[i]: print(""No"") exit() else: dic1[s[i]] = t[i] for i in range(len(t)): if t[i] in dic2.keys(): if dic2[t[i]]!=s[i]: print(""No"") exit() else: dic2[t[i]] = s[i] print(""Yes"") " p02811,s163855699,Accepted,"k, x = map(int, input().split()) if 500 * k >= x: print(""Yes"") else: print(""No"")" p03017,s301834299,Accepted,"N, A, B, C, D = map(int, input().split()) S = input() from sys import exit # check goal = max(C, D) if ""##"" in S[A-1:goal]: print(""No"") exit() if C < D: # Bから先に動く print(""Yes"") else: # 入れ替わる必要がある # cehck : 初期値で入れ替えられる # if ""..."" in S[B-2:D]: if ('...' in S[B-1:D]) or ('...' in S[B-2:B+1]) or ('...' in S[D-2:D+1]): print(""Yes"") else: print(""No"")" p02768,s586495241,Accepted,"import sys input = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 7) MOD = 10**9+7 def nCr(n, r, mod=MOD): r = min(r, n-r) numer = denom = 1 for i in range(1, r+1): numer = numer * (n+1-i) % mod denom = denom * i % mod return numer * pow(denom, mod-2, mod) % mod n, a, b = map(int, (input().split())) ans = pow(2, n, MOD) - 1 - nCr(n, a) - nCr(n, b) ans += MOD * 2 ans %= MOD print(ans) " p03317,s653647449,Wrong Answer,"n,k = map(int, input().split()) A = list(map(int, input().split())) m = min(A) i = A.index(m) k -= 1 cnt = 0 left = i right = n-1-i cnt += -(-left//k) cnt += -(-right//k) print(cnt)" p03469,s830512695,Accepted,"S=input() print(S[:3]+""8""+S[4:])" p03105,s997973724,Accepted,"A, B, C = map(int, input().split()) if B // A >= C: print(C) else: print(B // A) " p02719,s636112011,Accepted,"n, k = map(int, input().split()) ans1 = n%k ans2 = -(ans1-k) print(min(ans1, ans2)) " p02880,s236128654,Wrong Answer,"N = int(input()) answers = [] for i in range(1, 10, 1): for j in range(1,10, 1): ans = i*j answers.append(ans) if N in answers: print(""YES"") else: print(""NO"")" p03035,s457648528,Wrong Answer,"A,B=map(int,input().split()) if A>=13: print(B) elif A>=6 and A<=12: print(B/2) else: print(0)" p02842,s987522877,Accepted,"import math N = int(input()) result = math.ceil(N / 1.08) comfirm_result = int(result * 1.08) if comfirm_result == N: print(result) else: print(':(')" p02793,s102143890,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) INF=10**9+7 N=int(input()) A=[int(i) for i in input().split()] temp=A[0] for i in range(1,N): temp=lcm(temp,A[i]) ans=0 for a in A: ans+=(temp//a) print(ans%INF) " p02678,s094154854,Accepted,"import sys input = sys.stdin.readline N, M = map(int, input().split()) graph = [[] for _ in range(N)] for _ in range(M): a, b = map(int, input().split()) graph[a-1].append(b-1) graph[b-1].append(a-1) q = [0] par = [-1]*N par[0] = 0 while q: qq = [] for p in q: for np in graph[p]: if par[np] == -1: par[np] = p+1 qq.append(np) q = qq print(""Yes"") print(*par[1:], sep=""\n"")" p03861,s368774839,Wrong Answer,"a,b,x=map(int,input().split()) print(b//x-(a-1)//x if a>0 else b//x)" p02726,s721195007,Accepted,"n, x, y = map(int, input().split()) result = [0 for _i in range(n)] for i in range(1, n): for j in range(i+1, n+1): le = min([j-i, abs(i-x)+1+abs(j-y), abs(i-y)+abs(j-y)]) result[le] += 1 for i in result[1:]: print(i)" p02742,s294084678,Accepted,"h,w=map(int,input().split()) masu=h*w if h==1 or w==1: print(1) elif masu%2==0: print(masu//2) else: print((masu//2)+1) " p03449,s347538529,Accepted,"n = int(input()) a1 = list(map(int, input().split())) a2 = list(map(int, input().split())) ans = 0 for i in range(len(a1)): ans = max(sum(a1[:i+1]) + sum(a2[i:]),ans) print(ans)" p02661,s495368657,Accepted,"n = int(input()) a = [] b = [] for i in range(n): s,t = map(int,input().split()) a.append(s) b.append(t) a.sort() b.sort() if n%2 == 0: am = (a[n//2-1]+a[n//2])/2 bm = (b[n//2-1]+b[n//2])/2 print(int((bm-am)*2+1)) else: am = a[(n-1)//2] bm = b[(n-1)//2] print(bm-am+1)" p02765,s239402207,Accepted,"N, R = map(int, input().split()) if N >= 10: ans = R else: ans = R + (100 * (10-N)) print(ans)" p02767,s335363504,Accepted,"N = int(input()) X = list(map(int, input().split())) X_min = min(X) X_max = max(X) S = [] if X_min == X_max: S.append(0) for x in range(X_min, X_max): s = 0 for i in range(N): s += (X[i]-x)**2 S.append(s) print(min(S))" p03951,s671215751,Accepted,"N = int(input()) s = input() t = input() c = -1 # i文字一致している for i in range(N): sp = s[i:] tp = t[:N-i] # print(sp, tp) if sp == tp: c = i break if c == -1: print(2*N) else: match = N - c ans = 2 * N - match # print(':', match) print(ans)" p03699,s862181436,Wrong Answer,"import sys input = sys.stdin.readline def main(): ans = 0 n = int(input()) s = [int(input()) for _ in range(n)] for i in range(n**2): tmp = 0 for j in range(n): if i>>j&1: tmp += s[j] if tmp%10 != 0: ans = max(ans, tmp) print(ans) if __name__ == '__main__': main()" p02676,s954853029,Accepted,"K = int(input()) S= list(str(input())) list=[] if(len(S)>K): for I in range(0,K): list.append(S[I]) b="""".join(list) print(b+""..."") else: x="""".join(S) print(x) " p02784,s863268526,Accepted,"h,n = map(int,input().split()) a = list(map(int,input().split())) if sum(a)>=h: print('Yes') else: print('No')" p02761,s308773096,Accepted,"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]!=-1 and A[s-1]!=c : ans=-1 break else: A[s-1]=c if A[0]==0 and n!=1 : ans=-1 if ans==-1 : print(ans) exit() if A[0]==-1 and n!=1 : A[0]=1 for i in range(n): ans*=10 if A[i]==-1 : A[i] = 0 ans += A[i] print(ans)" p03785,s811936901,Wrong Answer,"import sys import bisect input = sys.stdin.readline n, c, k = [int(w) for w in input().split()] la = [int(input()) for _ in range(n)] la.sort() lak = [a + k for a in la] ind = 0 ans = 0 while ind < n: ride = bisect.bisect_left(la, lak[ind]) - ind ind += min(ride,k) ans += 1 print(ans) " p03107,s757857758,Accepted,"s = input() #print(s) score=0 for i in range(len(s)): if s[i]==""0"": score = score +1 else: score = score -1 # print(s[i]) print(len(s)-abs(score))" p04031,s375365888,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()) ans = INF for x in range(-100, 101): tmp = 0 for a in A: tmp += (x - a) ** 2 if ans > tmp: ans = tmp print(ans) return if __name__ == '__main__': main() " p02888,s838639368,Wrong Answer,"from bisect import bisect_left n = int(input()) l = list(map(int, input().split())) l.sort() ans = 0 for i in range(n-2): for j in range(n-1): ans += bisect_left(l, l[i]+l[j]) - j - 1 print(ans) " p02973,s048175427,Accepted,"from bisect import bisect_right def LIS(l): length = [l[0]] for i in range(1, len(l)): if l[i] >= length[-1]: length.append(l[i]) else: pos = bisect_right(length, l[i]) length[pos] = l[i] return len(length) n = int(input()) a = [int(input()) for i in range(n)] a = a[::-1] print(LIS(a)) " p03360,s514186732,Accepted,"a, b, c = map(int, input().split()) k = int(input()) al = [a, b, c] bl = [a, b, c] cl = [a, b, c] for i in range(k): al[0] = al[0] * 2 bl[1] = bl[1] * 2 cl[2] = cl[2] * 2 sm = [sum(al), sum(bl), sum(cl)] print(max(sm)) " p03723,s640034609,Wrong Answer,"a, b, c = map(int, input().split()) if a == b == c: if a % 2 == 0: print(-1) else: print(1) else: ans = 0 while a % 2 != 0 or 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,s117283635,Wrong Answer,"info = [int(i) for i in input().split(' ')] K = info[0] S = info[1] count = 0 for x in range(K+1): tmp = x if tmp > S: continue for y in range(K+1): tmp = x+y if tmp > S: continue for z in range(K+1): ans = x+y+z if ans == S: count += 1 print(count)" p02553,s443386236,Accepted,"a,b,c,d = map(int,input().split()) print(max(a*c,a*d,b*c,b*d))" p02971,s808941901,Accepted,"n = int(input()) a = [int(input()) for _ in range(n)] b = sorted(a) M,m = b[n-1],b[n-2] for i in range(n): if a[i] == M: print(m) else: print(M)" p02787,s240992906,Accepted,"import sys read = sys.stdin.read H, N, *AB = map(int, read().split()) INF = 10 ** 10 dp = [INF] * (H + 1) r = INF dp[0] = 0 for a, b in zip(*[iter(AB)] * 2): for i in range(a, H + 1): dp[i] = min(dp[i], dp[i - a] + b) r = min(r, min(dp[-a:]) + b) print(min(r, dp[-1])) " p03711,s202503648,Accepted,"group = [0] * 13 for i in [1, 3, 5, 7, 8, 10, 12]: group[i] = 1 for i in [4, 6, 9, 11]: group[i] = 2 group[2] = 3 x, y = map(int, input().split()) print(""Yes"" if group[x] == group[y] else ""No"")" p02829,s391164012,Accepted,"a = int(input()) b = int(input()) print(6-a-b)" p03106,s168970666,Accepted,"import sys import time import math def inpl(): return list(map(int, input().split())) st = time.perf_counter() # ------------------------------ A, B, K = map(int, input().split()) ans = [] for i in range(1, min(A, B)+1): if A%i == 0 and B%i == 0: ans.append(i) print(ans[len(ans)-K]) # ------------------------------ ed = time.perf_counter() print('time:', ed-st, file=sys.stderr) " p02771,s129665209,Wrong Answer,"A, B, C = map(int, input().split()) if A == B or A == C: if B == C: print('No') else: print('Yes') else: print('No')" p03693,s511184826,Accepted,"r,g,b = map(str,input().split()) print(""YES"" if int(r+g+b)%4 == 0 else ""NO"") " p02607,s518146525,Accepted,"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)" p03487,s830777619,Wrong Answer,"n=int(input()) a=list(map(int,input().split())) a.sort() cnt,ans=0,0 p=0 for x in a: print(ans,cnt,x) if p==x: cnt+=1 else: if cnt>p: ans+=cnt-p elif cntp: ans+=cnt-p elif cnt0): if ab[i][1] < k: k -= ab[i][1] else: print(ab[i][0]) break i += 1" p03221,s578324779,Wrong Answer,"from bisect import bisect_left import heapq def solve(): N,M = map(int, input().split()) cities_in_prefecture = [[] for _ in range(N)] city_ids = [] PYs = [] for _ in range(M): P,Y = map(int, input().split()) PYs.append((P,Y)) heapq.heappush(cities_in_prefecture[P-1], Y) for P, Y in PYs: x = bisect_left(cities_in_prefecture[P-1], Y) print('{0:06d}{1:06d}'.format(P, x+1), flush=True) solve()" p03623,s772638640,Accepted,"x, a, b = map(int, input().split()) if abs(x-a) < abs(x-b): print('A') else: print('B') " p03971,s921636594,Accepted,"N, A, B = map(int, input().split()) S = input() for s in S: if s == ""c"": print(""No"") elif s == ""a"": if A + B == 0: print(""No"") else: A -= 1 print(""Yes"") elif s == ""b"": if A + B == 0 or B == 0: print(""No"") else: B -= 1 print(""Yes"") " p02706,s536084575,Wrong Answer,"n,m = map(int, input().split()) l = list(map(int, input().split())) for i in l: n -= i if n > 0: print(n) else: print('-1') " p03329,s443641820,Wrong Answer,"N = int(input()) yendama = [1,6,36,216,1296,7776,46656,9,81,729,6561,59049] def calc_dp(n): initial = 10**7 dp=[initial for _ in range(100010)]#dp用の配列はすこし大きめに作る dp[0] = 0 for i in range(100000): for y in range(len(yendama)): if i-yendama[y]>=0: dp[i] = min(dp[i],1 + dp[i-yendama[y]]) return dp[N] print(calc_dp(N)) " p03633,s512524052,Accepted,"# ==================================================- # 最大公約数n個 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) import functools # ------メイン関数------- # numsは整数のリスト def lcm(nums): return functools.reduce(multiple, nums) a=[] n=int(input()) for i in range(n): a.append(int(input())) print(lcm(a))" p02576,s975767508,Wrong Answer,"N=20; X=12; T=6 import math T_total = ( math.ceil( N / X )*T ) print (T_total)" p02607,s754777454,Wrong Answer,"n=int(input()) a=list(map(int,input().split())) c=0 for i in range(0,n): if i%2!=0 and a[i]%2!=0: c+=1 print(c)" p02989,s332504797,Accepted,"N=int(input()) D=sorted(list(map(int, input().split()))) print(D[N//2]-D[N//2-1]) " p03761,s199745154,Accepted,"from collections import Counter n = int(input()) L = [Counter(str(input())) for _ in range(n)] C = sorted(L[0]) ans = '' for k in C: m = L[0][k] for i in range(n): m = min(m, L[i][k]) ans += k * m print(ans) " p03797,s453524325,Accepted,"import sys import math import itertools import bisect from copy import copy,deepcopy 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(map(int,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 N,M = I() if M <= N*2: print(M//2) else: print(N+(M-N*2)//4)" p04019,s302660806,Accepted,"s= input().strip() f=""Yes"" if (s.count('N')!=s.count('S') and s.count('N')*s.count('S')==0): f=""No"" elif(s.count('E')*s.count('W')==0 and s.count('E')!=s.count('W')): f=""No"" print(f)" p03778,s611712172,Accepted,"W, a, b = map(int, input().split()) a, b = sorted([a, b]) print(max(0, b-(a+W)))" p02953,s951485589,Accepted,"N = int(input()) H = list(map(int,input().split())) for i in range(N-1,0,-1): if H[i] + 1 == H[i-1]: H[i-1] -= 1 elif H[i] < H[i-1]: print(""No"") exit() print(""Yes"") " p02691,s581481032,Accepted,"import sys import collections input = sys.stdin.readline N = int(input()) A = list(map(int, input().split())) countL = [] countR = [] for i in range(N): countL.append(i - A[i]) countR.append(i + A[i]) countL = collections.Counter(countL) countR = collections.Counter(countR) ans = sum([countL[i] * countR[i] for i in countL.keys()]) print(ans)" p03545,s294321108,Accepted,"x = input() for i in [""+"",""-""]: for j in [""+"",""-""]: for k in [""+"",""-""]: y = x[0]+i+x[1]+j+x[2]+k+x[3] if eval(y) == 7: ans = y print(ans+""=7"")" p02606,s405949953,Wrong Answer,"L,R,d=list(map(int,input().split())) I=R-L+1 if 1<=L<=R<=100: print(I//d) " p04043,s366053040,Accepted,"l=list(map(int,input().split())) print('YES'if l.count(5)==2 and l.count(7)==1 else'NO') " p03073,s810941075,Wrong Answer,"S=input() s=0 t=0 for i in range(len(S)): if i%2==0: if S[i]!=0: s+=1 else: s=s if i%2==1: if S[i]!=1: s+=1 else: s=s for i in range(len(S)): if i%2==0: if S[i]!=1: t+=1 else: t=t if i%2==1: if S[i]!=0: t+=1 else: t=t print(min(s,t))" p02718,s759686788,Wrong Answer,"#def main(S, b): if __name__ == '__main__': n, m = map(int, input().split()) a = list(map(int, input().split())) s = sum(a) cnt = 0 for i in range(n): if (a[i] > s / 4 / m): cnt += 1 #print(cnt) if (cnt >= m): print(""Yes"") else: print(""No"") " p02552,s037013793,Wrong Answer,"x = input() if x == 1: print(0) else: print(1)" p02811,s714866396,Accepted,"K, X = map(int, input().split()) print(""Yes"" if K*500 >= X else ""No"") " p02783,s333548879,Accepted,"H,A=map(int,input().split()) count=0 while H>0: H=H-A count=count+1 print(count)" p02727,s274851007,Accepted,"def solve(x, y, a, b, c, p, q, r): p = sorted(p)[::-1] q = sorted(q)[::-1] r = sorted(r)[::-1] v = sorted(p[:x] + q[:y]) n = len(v) t = sum(v) for i in range(min(n,c)): if v[i] < r[i]: t += r[i] - v[i] return t 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())) print(solve(x, y, a, b, c, p, q, r))" p02702,s049848009,Accepted,"import sys read = sys.stdin.read readlines = sys.stdin.readlines from collections import Counter def main(): s = input() n = len(s) amari = [0] * n ketaamari = 1 t = 0 for i1 in range(n): t = (t + ketaamari * int(s[-i1 -1])) % 2019 amari[-i1-1] = t ketaamari = (ketaamari * 10) % 2019 amari.append(0) ac = Counter(amari) r = 0 for v in ac.values(): r += v * (v - 1) // 2 print(r) if __name__ == '__main__': main()" p03767,s023899164,Accepted,"N = int(input()) a = list(map(int, input().split())) a.sort(reverse=True) A = a[1:len(a):2] ans = 0 for i in range(N): ans += A[i] print(ans)" p03854,s239680352,Accepted,"#input S = input() S = S.replace('eraser','') # 文字列の置き換えeraser を空文字に S = S.replace('erase','') S = S.replace('dreamer','') S = S.replace('dream','') # if S: print('NO') else: print('YES') " p02754,s157147172,Accepted,"N, A, B = map(int, input().split()) ans = (N // (A+B)) * A T = N % (A+B) if T >= A: print(ans + A) else: print(ans + T)" p03243,s586026201,Accepted,"# coding: utf-8 # Your code here! N=list(input()) if len(set(N))==1: print(''.join(N)) else: if int(N[0])0 and a>0): c -= b if (c<=0): flag = 1 a -= d if (a<=0 and c>0): flag = 2 if (flag == 1): print('Yes') else: print('No')" p02615,s484433083,Accepted,"N=int(input()) A=list(map(int,input().split())) A.sort(reverse=True) P=A[0] for i in range(2,N): P+=A[i//2] print(P)" p03730,s499470845,Wrong Answer,"a, b, c = map(int, input().split()) for i in range(1, 1001): n = i * a if n % b == c: print('Yes') break else: print('No')" p02627,s973025724,Wrong Answer,"X = input() if X.isupper(): print(""A"") else: print(""B"")" p03672,s720829288,Accepted,"S = list(input()) N = int(len(S) / 2) for i in range(N): del S[-2:] if S[:int(len(S)/2)] == S[int(len(S)/2):]: print(len(S)) break else: continue" p02695,s731314621,Accepted,"import itertools def abcd(n): for _ in range(n): a,b,c,d = map(int,input().split()) yield a,b,c,d def main(): N,M,Q = map(int,input().split()) num = list(range(1,M+1)) X = list(abcd(Q)) for v in itertools.combinations_with_replacement(num, N): ans = 0 for a,b,c,d in X: A,B = v[a-1],v[b-1] if B-A == c: ans += d yield ans print(max(main()))" p02578,s856400424,Accepted,"N = int(input()) A = list(map(int, input().split())) mx = A[0] ans = 0 for i in range(1, N): if A[i] < mx: ans += mx-A[i] elif A[i] > mx: mx = A[i] print(ans) " p02613,s174586496,Accepted,"n = int(input()) AC = 0 WA = 0 TLE = 0 RE = 0 for _ in range(n): judge = input() if judge == 'AC': AC += 1 elif judge == 'WA': WA += 1 elif judge == 'TLE': TLE += 1 elif judge == 'RE': RE += 1 print('AC x {}'.format(AC)) print('WA x {}'.format(WA)) print('TLE x {}'.format(TLE)) print('RE x {}'.format(RE))" p03455,s473932593,Accepted,"a, b = map(int, input().split()) if (a & 1) and (b & 1): print(""Odd"") else: print(""Even"")" p03339,s585554789,Accepted,"n=int(input()) s=input() #はじめ全員Wであると仮定 E_right,W_left=s.count('E'),0 mi=n #最小値 for i in range(n): if s[i]=='E': E_right-=1 #Eならデクリメント if W_left+E_rightW[i]: print(""No"") exit() if W[i-1]+1==W[i]: W[i]-=1 print(""Yes"")" p02952,s322525598,Accepted,"print(sum(len(str(-~i))%2>0 for i in range(int(input())))) " p03210,s941982900,Accepted,"x = int(input()) if x in [3,5,7]: print('YES') else: print('NO')" p02935,s585621386,Accepted,"n = int(input()) v = list(map(int,input().split())) v.sort() ans = v[0] for i in range(1,n): ans = (ans+v[i])/2 print(ans)" p03281,s772205647,Accepted,"n = int(input()) b = 0 for i in range(1, n+1): if i % 2 == 1: a = 0 for j in range(1, i+1): if i % j == 0: a += 1 if a == 8: b += 1 print(b)" p02630,s462109231,Accepted,"from collections import Counter N = int(input()) A = list(map(int, input().split())) Q = int(input()) S = sum(A) cntA = Counter(A) for _ in range(Q): B, C = map(int, input().split()) D = C - B S += D * cntA[B] cntA[C] += cntA[B] cntA[B] = 0 print(S)" p03673,s240736906,Accepted,"N=int(input()) A=list(map(int,input().split())) print(*(A[::-2]+A[N%2::2]))" p02953,s063446813,Accepted,"n=int(input()) li=list(map(int,input().split())) li[0]-=1 for i in range(1,n-1): if li[i]>=li[i+1] and li[i]>li[i-1]: li[i]-=1 li2=sorted(li) if li==li2: print(""Yes"") else: print(""No"")" p03317,s830392454,Accepted,"n,k=map(int,input().split()) print(0--~-n//~-k)" p02684,s923340267,Accepted,"import sys sys.setrecursionlimit(10**9) N, K = map(int, input().split()) A = list(map(int, input().split())) log = [] check = [False]*N def func(x, iter): x = A[x-1] if iter+1 == K: return x if check[x-1]: ix = log.index(x) loop = log[ix:] tmp = (K-iter-1)%len(loop) return loop[tmp] else: log.append(x) check[x-1] = True iter += 1 return func(x, iter) print(func(1, 0))" p03745,s610853391,Accepted,"num = int(input()) a = list(map(int, input().split())) k = 1 x = y = 0 c = a[0] for i in a[1:]: if c < i: x = 1 elif c > i: y = 1 if x == 1 and y == 1: k += 1 x = y = 0 c = i print(k)" p02792,s565089713,Wrong Answer,"N = int(input()) c = [[0] * 10] * 10 for x in range(1, N+1): check = str(x) it = int(check[0]) jt = int(check[-1]) c[it][jt] += 1 ans = 0 for i in range(0,10): for j in range(0,10): ans += c[i][j] * c[j][i] print(ans) " p03612,s938211162,Wrong Answer,"N = int(input()) P = list(map(int,input().split())) ls = [""""] * N cnt = 0 for i in range(N): if P[i] == i + 1: ls[i] = ""#"" else: ls[i] = ""."" if ls[-1] == ""#"": if ls[-2] == ""#"": ls[-1], ls[-2] = ""."", ""."" else: ls[-1] = ""."" for j in range(N-1): if ls[j] == ""#"": if ls[j+1] == ""#"": ls[j+1] = ""."" cnt += 1 print(cnt)" p02778,s490229057,Accepted,"s = input() print(""x"" * len(s))" p02687,s402605283,Accepted,"n = input() if n == ""ABC"": print(""ARC"") else: print(""ABC"") " p02793,s942754817,Wrong Answer,"import sys read = sys.stdin.read from fractions import gcd from functools import reduce n,*alst = list(map(int, read().split())) def lcm(x, y): g = gcd(x, y) g = x * y // g return g g = reduce(lcm, alst) mod=10**9+7 res=0 for a in alst: res+=(pow(a,mod-2,mod)*g)%mod print(res)" p03723,s311386702,Accepted,"import sys sys.setrecursionlimit(10**9) 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) sys.exit() cnt = 0 while True: if a%2==1 or b%2==1 or c%2==1: break a,b,c = (b+c)//2,(a+c)//2,(b+c)//2 cnt += 1 print(cnt)" p02631,s536771227,Accepted,"# Problem E - Red Scarf # input N = int(input()) a_nums = list(map(int, input().split())) # initialization xor_sum = 0 # xor sum for a in a_nums: xor_sum = xor_sum ^ a ans = [] # xor check for a in a_nums: tmp = xor_sum ^ a ans.append(tmp) # output print("" "".join(list(map(str, ans)))) " p02695,s531338704,Accepted,"import itertools n, m, q = map(int, input().split()) abcd = [tuple(map(int, input().split())) for _ in range(q)] ans = 0 for com in itertools.combinations_with_replacement(range(1, m + 1), n): score = sum([d for a, b, c, d in abcd if com[b-1] - com[a-1] == c]) if ans < score: ans = score print(ans) " p02719,s177885394,Accepted,"n,m = map(int,input().split()) ans = n % m if m - ans < ans: ans = m - ans print(ans)" p03427,s557852980,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[0])-1+9*(len(n)-1)) break else: print(9*len(n))" p02695,s879241777,Accepted,"import sys from itertools import permutations, combinations, combinations_with_replacement int1 = lambda x: int(x) - 1 read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(500000) N, M, Q = map(int, readline().split()) abcd = [list(map(int, readline().split())) for _ in range(Q)] l = [i for i in range(1, M + 1)] ans = 0 for v in combinations_with_replacement(l, N): acc = 0 for a, b, c, d in abcd: if v[b - 1] - v[a - 1] == c: acc += d ans = max(ans, acc) print(ans) " p02842,s145364776,Accepted,"N=input() N=float(N) import math X=math.ceil(N/1.08) if int(X*1.08)==N: print(X) else: print(':(')" p02897,s524788705,Accepted,"N = int(input()) # if N % 2 == 0: # print(0.5) # else: # print((N + 1)/2 / N) cnt = 0 for i in range(1, N+1): if i % 2 == 1: cnt += 1 print(cnt/N)" p02972,s221198277,Accepted,"n = int(input()) box = list(map(int, input().split())) ans = [0]*n lst = [] for i in reversed(range(n)): count = 0 for j in range(n//(i+1)): count += ans[(i+1)*(j+1)-1] if count % 2 == box[i]: ans[i] = 0 else: lst.append(i+1) ans[i] = 1 print(sum(ans)) print(*lst)" p03037,s807336851,Accepted,"N, M = list(map(int, input().split())) L = 0 R = float('inf') for i in range(M): l, r = list(map(int, input().split())) L = max(L, l) R = min(R, r) print(max(R-L+1, 0))" p03239,s680699369,Wrong Answer,"N,T=map(int,input().split()) CT=[] for i in range(N): ct=list(map(int,input().split())) CT.append(ct) min_cost=10000 for i in range(1,N): semi_ans=CT[i] if semi_ans[1]<=T: ans=CT[i] if ans[0]X: break i+=1 print(i-1) " p03633,s662465936,Accepted,"def gcd(a, b): if a % b == 0: return b return gcd(b, a % b) def lcm(a, b): return a * b // gcd(a, b) n = int(input()) ans = 1 for i in range(n): t = int(input()) ans = lcm(ans, t) print(int(ans))" p03644,s673845392,Wrong Answer,"num=int(input()) cnt=0 while num % 2==0: num//=2 cnt+=1 print(cnt)" p02693,s130168525,Accepted,"K = int(input()) A, B = map(int, input().split()) if (A//K + 1 )*K <= B or A%K == 0: print(""OK"") else: print(""NG"")" p02623,s136911786,Wrong Answer,"N,M,K = map(int, input().split()) A = map(int, input().split()) B = map(int, input().split()) sa = {-1: 0} for i, val in enumerate(A): sa[i] = sa[i-1] + val sb = {-1: 0} for i, val in enumerate(B): sb[i] = sb[i-1] + val max_num = 0 for i in range(N): for j in range(M): if(sa[i]+sb[j]<=K): max_num = max(max_num,i+j+2) print(max_num)" p02597,s514172678,Accepted,"n = int(input()) c = list(input()) ans = 0 for i in range(c.count(""R"")): if c[i] == ""W"": ans += 1 print(ans)" p02811,s822749915,Accepted,"k,x = map(int,input().split()) if 500*k >= x: print(""Yes"") else: print(""No"")" p03673,s045631942,Wrong Answer,"def q(l): a='' for i in range(len(l)): a = a+l[i] a = a[::-1] return a n=int(input()) a=list(input().split()) ans = q(a) print(' '.join(ans)) " p03163,s257693511,Accepted,"N, W = map(int, input().split()) value, weight = [0], [0] for _ in range(N): w, v = map(int, input().split()) weight.append(w) value.append(v) dp = [[-1]*(W+1) for _ in range(N+1)] dp[0][0] = 0 for i in range(1, N+1): for j in range(W+1): dp[i][j] = max(dp[i][j], dp[i-1][j]) if -1 < j-weight[i]: dp[i][j] = max(dp[i][j], dp[i-1][j-weight[i]]+ value[i]) print(max(dp[N]))" p02548,s033343036,Accepted,"N = int(input()) cnt = 0 for a in range(1, N + 1): b = 1 while True: if a * b < N: cnt += 1 else: break b += 1 print(cnt) " p03162,s750652225,Accepted,"from sys import stdin input=lambda : stdin.readline().strip() from math import ceil,sqrt,factorial,gcd from collections import deque n=int(input()) prev=0 l=[] for i in range(n): l.append(list(map(int,input().split()))) z=[[0,0,0] for i in range(n)] z[0]=l[0] for i in range(1,n): z[i][0]=l[i][0]+max(z[i-1][1],z[i-1][2]) z[i][2]=l[i][2]+max(z[i-1][1],z[i-1][0]) z[i][1]=l[i][1]+max(z[i-1][0],z[i-1][2]) print(max(z[-1]))" p02727,s458565706,Accepted,"def greenandredapples(): X, Y, A, B, C = list(map(int, input().split())) RedD = sorted(list(map(int, input().split()))) GreenD = sorted(list(map(int, input().split()))) Colorl = sorted(list(map(int, input().split()))) considered = RedD[-X:] + GreenD[-Y:] Colorl.extend(considered) return sum(sorted(Colorl,reverse=True)[:X+Y]) print(greenandredapples())" p02859,s218146622,Accepted,"r = int(input()) print(r**2)" p03457,s441021865,Accepted,"N = int(input()) txy = [tuple(map(int,input().split())) for _ in range(N)] t = 0 x = 0 y = 0 for i in range(N): nt,nx,ny = txy[i] t = nt-t x = nx-x y = ny-y d = abs(x)+abs(y) if t < d: print(""No"") exit(0) elif (t-d)%2 == 1: print(""No"") exit(0) t,x,y = txy[i] print(""Yes"")" p03836,s241930309,Accepted,"sx,sy,tx,ty=map(int,input().split()) dx=tx-sx dy=ty-sy ans="""" ans+=""R""*dx+""U""*dy ans+=""R""+""D""*(dy+1)+""L""*(dx+1)+""U"" ans+=""U""*dy+""R""*dx ans+=""U""+""L""*(dx+1)+""D""*(dy+1)+""R"" print(ans)" p03012,s849568840,Wrong Answer,"n=int(input()) w=list(map(int,input().split())) a=[] for i in range(1,n): ans=(w[:i]) if 2*sum(ans)-sum(w)>=0: a.append(2*sum(ans)-sum(w)) print(min(a))" p03455,s726231017,Accepted,"a, b = map(int,input().split()) if a*b % 2 != 0: print('Odd') else: print('Even')" p03408,s126735397,Wrong Answer,"N = int(input()) C = {} for _ in range(N): a = input().strip() if a not in C: C[a] = 0 C[a] += 1 M = int(input()) for _ in range(M): a = input().strip() if a not in C: C[a] = 0 C[a] -= 1 cmax = -100 for a in C: cmax = max(cmax,C[a]) print(cmax)" p03254,s264151022,Accepted,"N, x = map(int,input().split()) a = sorted([int(i) for i in input().split()]) count = 0 if sum(a) == x: print(len(a)) else: for i in a: x = x-i if x<0: break count+=1 if count == N: print(N-1) else: print(count)" p02923,s221689537,Accepted,"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 else: if cnt > ans: ans = cnt cnt = 0 if cnt > ans: ans = cnt print(ans) " p02971,s255073733,Accepted,"n=int(input()) a=[int(input()) for i in range(n)] c=sorted(a) b=max(a) for i in range(n): if a[i]==b: print(c[n-2]) else: print(b)" p03719,s596143133,Accepted,"# 整数A,B,Cを入力 A,B,C = map(int,input().split()) # 整数CがA以上かつB以下であればYes,そうでなければNo if A <= C and C <= B: print(""Yes"") else: print(""No"")" p02765,s913387451,Accepted,"N, R = map(int, input().split()) if N >= 10 : print(R) else : print(R + 100 * (10 - N))" p02918,s409452749,Wrong Answer,"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 if cd > 2: t = min(k,(cd - 2)) k -= t score += 2 * t cd -= 2 * t if cd == 2 and k: score +=1 cd -= 1 print score" p02712,s741264307,Wrong Answer,"N=int(input()) i=int (0) S=[] for i in range(N): if i%3!=0 and i%5!=0: S.append(i) print(sum(S))" p04033,s021344197,Wrong Answer,"a,b = map(int,input().split()) if a<=0 and b >= 0: print(""Zero"") elif a>0 and b > 0: print(""Positive"") else: if b-a+1%2 != 0: print(""Negative"") else: print(""Positive"")" p03282,s227995451,Accepted,"def main(s: str, k: int): for i in range(k): if s[i] != ""1"": print(s[i]) return print(1) if __name__ == ""__main__"": s = input() k = int(input()) main(s, k) " p02714,s099252155,Accepted,"# D def main(): #N = 4000 #S = [""RGB""[random.randint(0, 2)] for _ in range(N)] N = int(input()) S = input() import collections c = collections.Counter(S) total = c[""B""]*c[""G""]*c[""R""] for d in range(1, N//2+1): for i in range(N-d-d): if len({S[i], S[i+d], S[i+d+d]})==3: total -= 1 print(total) main()" p02910,s889472168,Accepted,"S=list(input()) even=[] odd=[] for i in range(len(S)): if i%2==0: even.append(S[i]) else: odd.append(S[i]) if not ""L"" in even and not ""R"" in odd: print(""Yes"") else: print(""No"")" p02771,s278322146,Accepted,"numbers = set(map(int, input().split())) if len(numbers) == 2: print('Yes') else: print('No') " p03329,s760692015,Accepted,"n=int(input()) def k(a,b): ans=0 while (a!=0): ans+=a%b a//=b return ans res=10**10 for i in range(n+1): res=min(res,k(i,9)+k(n-i,6)) print(res)" p02682,s509366305,Accepted,"A,B,C,K = input().split() a = int(A) b = int(B) c = int(C) k = int(K) B_number = 0 C_number = 0 A_number = min(a,k) k1 = k - a if k1 > 0: B_number = min(b,k1) k2 = k1 - b if k2 > 0: C_number = min(c,k2) print(A_number-C_number)" p03827,s719191845,Wrong Answer,"import sys readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines read = sys.stdin.buffer.read sys.setrecursionlimit(10 ** 7) INF = float('inf') N = int(input()) S = input() ans = S.count(""I"") - S.count(""D"") print(ans)" p02556,s791379307,Accepted,"def main(): n = int(input()) xy = [list(map(int, input().split())) for _ in [0]*n] z1 = [x+y for x, y in xy] z2 = [x-y for x, y in xy] z3 = [-x+y for x, y in xy] z4 = [-x-y for x, y in xy] print(max([max(z1)-min(z1), max(z2)-min(z2), max(z3)-min(z3), max(z4)-min(z4)])) main() " p02660,s832298038,Accepted,"from collections import Counter def factorize(N): p = 2 PRIME = [] while p * p <= N: if N % p == 0: N //= p PRIME.append(p) else: p += 1 if N > 1: PRIME.append(N) return Counter(PRIME) n = int(input()) prime = factorize(n) ans = 0 for i in prime: for j in range(1,prime[i]+1): if n % i ** j == 0: n //= i ** j ans += 1 print(ans)" p03254,s785896913,Wrong Answer,"n , x = map(int , input().strip().split()) a = list(map(int , input().strip().split())) a.sort() count = 0 for i in a: if x - i < 0: break x -= i count += 1 print(count)" p03437,s155620288,Wrong Answer,"from sys import exit X, Y = map(int,input().split()) if X % Y == 0 or Y % X == 0: print(-1) else: for i in range(X,10 ** 18 + 1,X): if i % Y != 0: print(i) exit()" p02768,s730317095,Wrong Answer,"from operator import mul from functools import reduce import math a = list(map(int, input().split())) 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 ans = 0 for i in range(0,a[0]): if(i != a[1] and i != a[2]): ans += cmb(a[0],i) #print(""ans:%d""%(ans)) print(ans%(10**9+7))" p04030,s349735322,Accepted,"s=list(input()) ans=[] for i in s: if i==""0"": ans.append(""0"") if i==""1"": ans.append(""1"") if i==""B"" and len(ans)>0: ans.pop(-1) print("""".join(ans))" p03719,s039854879,Accepted,"a, b, c = map(int, input().split()) print((""Yes"" if a <= c <= b else ""No"")) " p02687,s205256825,Accepted,"n=input() print('ARC' if n=='ABC' else 'ABC')" p02725,s970044569,Wrong Answer,"K, N = map(int, input().split()) A = sorted(map(int, input().split())) length = K//2 for i in range(N-1): length = max(A[i+1] - A[i] , length) if length == A[i+1] - A[i]: ans = A[i] + K - A[i+1] if length <= K//2: ans = A[-1] - A[0] print(ans)" p03835,s675364044,Accepted,"K, S = map(int,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) " p03637,s256540463,Accepted,"n = int(input()) a = list(map(int, input().split())) x = 0 y = 0 z = 0 for i in a: if i%4 == 0: x += 1 elif i%2 == 0: y += 1 else: z += 1 if y%2+z-1 <= x: print(""Yes"") else: print(""No"")" p02640,s905732911,Accepted,"x, y = list(map(int, input().split())) if y % 2 != 0: print(""No"") else: if 2*x <= y <= 4*x: print(""Yes"") else: print(""No"")" p03327,s004279883,Accepted,"n = int(input()) print('ABC' if n < 1000 else 'ABD')" p02660,s758804409,Accepted,"N = int(input()) number = N List = [0 for i in range(1000000)] answer = 0 def cul(x): number = 1 while x >= (number+2)*(number + 1)//2: number += 1 return number i = 2 while number > 1: while number % i == 0: number //= i List[i] += 1 i +=1 if i == 1000001: answer = 1 break for x in List: if x == 0: continue else: answer += cul(x) print(answer)" p02911,s489566681,Accepted,"n,k,q = map(int, input().split()) l = [k-q]*n for _ in range(q): l[int(input())-1] += 1 for i in l: print(""Yes"" if i > 0 else ""No"")" p02689,s807662832,Accepted,"n,m = map(int, input().split()) h_list = list(map(int,input().split())) ans = [1]*n for i in range(m): a,b = map(int, input().split()) if h_list[a-1] == h_list[b-1]: ans[a-1] = 0 ans[b-1] = 0 else: if h_list[a-1] > h_list[b-1]: ans[b-1] = 0 else: ans[a-1] = 0 print(sum(ans))" p04043,s281012353,Accepted,"x = list(map(int, input().split())) x.sort() f = True for i, e in enumerate(x): tmp = 5 if i == 2: tmp = 7 f &= (tmp == e) print(""YES"" if f else ""NO"") " p02695,s195667959,Accepted,"from itertools import combinations as combi N, M, Q = map(int, input().split()) ABCD = [list(map(int, input().split())) for _ in range(Q)] #/##//#### # M-1+N C N max_num = 0 for l in combi(range(M-1+N), N): x = [t-s for t, s in zip(l, range(N))] # print(x) score = sum(d for a, b, c, d in ABCD if x[b-1]-x[a-1] == c) max_num = max(max_num, score) print(max_num) " p03493,s998302525,Accepted,print(list(input()).count('1')) p02982,s694066523,Accepted,"import math import itertools n,d=map(int,input().split()) l=list() for i in range(n): l.append(list(map(int,input().split()))) pp=0 for i,j in itertools.combinations(range(n),2): p=0 for k in range(d): p += (l[i][k]-l[j][k])**2 if math.sqrt(p)%1==0: pp+=1 print(pp)" p02570,s685543092,Accepted,"d, t, s = map(int, input().split()) if (d / s) <= t: print('Yes') else: print('No')" p03852,s097680556,Wrong Answer,"c = input() if c == 'a' or 'i' or 'u' or 'e' or 'o': print('vowel') else: print('consonant')" p03605,s957394279,Accepted,"print(""NYoe s""[input().find(""9"")!=-1::2])" p03416,s616305303,Accepted,"a, b = map(int,input().split()) cnt = 0 for i in range(a, b+1): i_s = str(i) i_r = 0 for j in range(len(i_s)): i_r *= 10 i_r += int(i_s[-j-1]) if i == i_r: cnt += 1 print(cnt)" p02780,s532640114,Accepted,"N,K=map(int,input().split()) p=list(map(int,input().split())) su=[0] for i in range(N): p[i]=((p[i]+1)/2) su.append(su[i]+p[i]) ans=0 for i in range(K,N+1): ans=max(ans,su[i]-su[i-K]) print(ans)" p02688,s247301174,Accepted,"n,k = map(int,input().split()) ans = [False]*n for i in range(k): b = int(input()) A = list(map(int,input().split())) for a in A: ans[a-1] = True print(n-sum(ans))" p03077,s745337571,Wrong Answer,"n = int(input()) a = [] ans = 5 for i in range(5): a.append(int(input())) for i in a: if n>i: if n%i == 0: ans += n//i-1 else: ans += n//i n = n%i print(ans)" p02813,s565187646,Wrong Answer,"A=[] #appendのために宣言が必要 while True: try: A.append(list(map(int,input().split()))) except: break; import itertools B = list(itertools.permutations(range(1,A[0][0]+1))) a = 0 b = 0 count = 0 for l in range(len(B)): count += 1 if a != 0 and b != 0: break; else: if tuple(A[1]) == B[l]: a = count elif tuple(A[2]) == B[l]: b = count else: continue print(abs(a-b))" p02682,s905703076,Accepted,"import sys def solve(): input = sys.stdin.readline A, B, C, K = map(int, input().split()) sumL = 0 if K <= A: sumL += K K = 0 else: sumL += A K -= A if K > B: K -= B else: K = 0 if K > 0: sumL -= K print(sumL) return 0 if __name__ == ""__main__"": solve()" p02677,s493399386,Wrong Answer,"import math A,B,H,M = map(int, input().split()) a = 360*H/12+30*M/60 b = 360*M/60 c = abs(a-b) d = A**2+B**2-2*A*B*math.sin(math.radians(c)) print(math.sqrt(d))" p03485,s950780516,Wrong Answer,"a,b=map(int,input().split()) print((a+b)//2)" p02994,s966088839,Wrong Answer,"N,L=map(int,input().split()) tot=N*L+(N-1)*N/2 ans=[] for i in range(N): ans.append(abs(L+i)) print(tot-min(ans))" p03838,s618494625,Accepted,"x, y = map(int, input().split()) count = abs(abs(x) - abs(y)) if x * y < 0: count += 1 elif x > y: count += 2 if x == 0 or y == 0: count -= 1 print(count)" p02996,s100362700,Wrong Answer,"n = int(input()) from bisect import bisect ab = [list(map(int,input().split())) for i in range(n)] ab.sort(key = lambda x: x[1]) ok = True last = 0 for a,b in ab: if b-a>last: last += a else: ok = not ok print('Yes' if ok else 'No')" p02811,s050719126,Accepted,"a = input() l = a.split() num = 500 * int(l[0]) pri = int(l[1]) if num < pri: print(""No"") else: print(""Yes"") " p02556,s901426584,Accepted,"def main(): point_count = int(input()) inf = 10 ** 10 max_sum, min_sum, max_diff, min_diff = - inf, inf, - inf, inf for _ in range(point_count): x, y = [int(x) for x in input().split()] max_sum = max(x + y, max_sum) min_sum = min(x + y, min_sum) max_diff = max(x - y, max_diff) min_diff = min(x - y, min_diff) return max(max_sum - min_sum, max_diff - min_diff) if __name__ == '__main__': print(main()) " p03380,s042062454,Accepted,"n = int(input()) a = list(map(int, input().split())) n = max(a) tmp = n / 2 r = n + 1 d = n + 1 for num in a: if num == n: continue d_tmp = abs(num - tmp) if d_tmp < d: d = d_tmp r = num print(n, r)" p03544,s480103842,Accepted,"n = int(input()) l = [0]*(n+1) l[0] = 2 l[1] = 1 for i in range(2,n+1): l[i] = l[i-1] + l[i-2] print(l[n])" p03438,s215244102,Accepted,"n = int(input()) A = list(map(int,input().split())) B = list(map(int,input().split())) c = 0 for a,b in zip(A,B): c += min((b-a)//2, b-a) print('Yes' if c>=0 else 'No')" p03017,s644849399,Accepted,"#!/usr/bin/env python # coding: utf-8 # In[1]: N,A,B,C,D = map(int, input().split()) S = input() # In[3]: if C < D: if S[B-1:D].count(""##"") == 0 and S[A-1:C].count(""##"") == 0: print(""Yes"") else: print(""No"") else: if S[B-2:D+1].count(""..."") >= 1 and S[A-1:C].count(""##"") == 0: print(""Yes"") else: print(""No"") # In[ ]: " p03860,s868432461,Accepted,"a,b,c=input().split() print(a[0]+b[0]+c[0])" p03695,s141781815,Wrong Answer,"n = int(input()) lst1 = list(map(int,input().split())) lst2 = [0]*8 for i in range(n): for j in range(8): if lst1[i] < 400*(j+1): lst2[j] += 1 break if lst1[i] >= 3200: lst2[7] += 1 ans = 0 for i in range(7): if lst2[i]: ans += 1 print(ans if not lst2[7] else ans +1) print(ans+lst2[7]) " p02608,s839771196,Accepted,"import itertools import collections N = int(input()) count = [0]*N*100 m = int(N**0.5) for x, y, z in itertools.combinations_with_replacement(range(1, m+1), 3): n = x**2+y**2+z**2+x*y+y*z+z*x k = len(set({x, y, z})) if k == 1: count[n] += 1 elif k == 2: count[n] += 3 else: count[n] += 6 for n in range(1, N+1): print(count[n]) " p02814,s332273363,Accepted,"from fractions import gcd N,M = map(int,input().split()) a = list(map(int,input().split())) if len(set([i&-i for i in a])) != 1: print(0) else: x = a[0]//2 for i in range(1, len(a)): x = x*(a[i]//2//gcd(x,a[i]//2)) print(M//x-M//(2*x))" p02935,s764566226,Wrong Answer,"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() N = I() v = LI() v = sorted(v,reverse=True) ans = 0 for i in range(N-1): ans += v[i]/(2**(i+1)) print(ans + v[N-1]//(2**(N-1)))" p02712,s412925474,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)" p03711,s690290210,Accepted,"x,y=map(int,input().split()) set1={1,3,5,7,8,10,12} set2={4,6,9,11} set3={2} if x in set1 and y in set1: print(""Yes"") elif x in set2 and y in set2: print(""Yes"") else: print(""No"")" p02552,s336293949,Accepted,print(1 if input()=='0' else 0) p03371,s677161923,Accepted,"A, B, C, X, Y = map(int, input().split()) tmp = A*X + B*Y if X >= Y: tmp = min(tmp,2*Y*C+(X-Y)*A) else: tmp = min(tmp,2*X*C+(Y-X)*B) tmp = min(tmp,max(X,Y)*2*C) print(tmp)" p02971,s578200135,Accepted,"N = int(input()) A =[int(input()) for _ in range(N)] B = sorted(A) M, m = B[N-1], B[N-2] for i in A: if i == M: print(m) else: print(M)" p03284,s337600533,Accepted,"N, K = map(int, input().split()) if N % K == 0 : print(0) else : print(1)" p03339,s201684387,Accepted,"from collections import Counter N = int(input()) S = list(input()) c = Counter(S[1:]) ans = 0+c[""E""] now = S[0] e = c[""E""] w = 0 for i in range(1,N): if now == ""W"": w += 1 now = S[i] if now == ""E"": e -= 1 if w+e < ans: ans = w+e print(ans)" p03160,s588831450,Accepted,"#Educational DP Contest #A-Frog1 n = int(input()) #n,m = map(int,input().split()) lst1 = list(map(int,input().split())) #dp table dp = [0]*n #process1 dp[1] = abs(lst1[1]-lst1[0]) for i in range(2,n): bb,b = abs(lst1[i]-lst1[i-2]),abs(lst1[i]-lst1[i-1]) dp[i] = min(dp[i-2]+bb,dp[i-1]+b) #output process print(dp[-1]) " p02546,s800045176,Accepted,"s = input() if s[-1] != 's': print(s + 's') else: print(s + 'es')" p02916,s240293630,Accepted,"n=int(input()) a=list(map(int,input().split())) b=list(map(int,input().split())) c=list(map(int,input().split())) eat_bef=0 ans=0 for i in range(len(a)): ans+=b[a[i]-1] if i>=1: if eat_bef+1==a[i]: ans+=c[eat_bef-1] eat_bef=a[i] print(ans) " p03416,s837404632,Wrong Answer,"count = 0 A,B = map(int,input().split()) for i in range(A,B+1): if str(i)[:2] == str(i)[3:]: count += 1 print(count)" p03672,s696039961,Accepted,"a = list(input()) b = len(a) while True: del a[-1] b -= 1 if b % 2 == 0 and a[:b//2] == a[b//2:]: print(b) break" p02818,s504236375,Wrong Answer,"a,b,k=map(int,input().split()) if a>=k: print(a-k,b) elif a8 or b>8: print(""Yey!"") else: print("":("")" p03438,s454703814,Accepted,"n = int(input()) c = 0 for i,j in zip(map(int,input().split()),map(int,input().split())): if i > j: c -= i-j else: c += (j-i)//2 print('YNeos'[c<0::2])" p03699,s494171747,Accepted,"n = int(input()) s = [int(input()) for _ in range(n)] s.sort() if sum(s)%10==0: for i in range(n): if s[i]%10!=0: s.pop(i) print(sum(s)) break else: print(0) else: print(sum(s))" p02780,s350558564,Wrong Answer,"n,k = map(int,input().split()) s = list(map(int,input().split())) s.sort() ans = 0 for i in range(1,k+1): ans += (s[-i]+1)/2 print(ans) " p03637,s793365777,Accepted,"_,*l=[int(i)%4 for i in open(0).read().split()];f=l.count;print('YNeos'[f(0)+f(2)//20: print(-1) exit() for i in a[1:]: b-=i c=min(c*2-i,b) ans+=c if c<0: print(-1) exit() print(ans+sum(a))" p03632,s025021679,Accepted,"a, b, c, d = map(int, input().split()) lower = max(a, c) upper = min(b, d) if upper >= lower: print(upper - lower) else: print(0)" p03681,s239008637,Accepted,"import math of = 10**9+7 n,m = map(int,input().split()) if abs(n-m) >= 2: print(0) exit() if n == m: print(math.factorial(n)*math.factorial(m)*2 % of) else: print(math.factorial(n)*math.factorial(m) % of)" p03838,s678539376,Accepted,"import sys def input(): return sys.stdin.readline().strip() def mapint(): return map(int, input().split()) sys.setrecursionlimit(10**9) x, y = mapint() cnt = 0 if x*y>0: if y= 2 * n else m // 2) " p02785,s199919380,Accepted,"n,k = map(int,input().split()) h = list(map(int,input().split())) h.sort() ans = 0 for i in range(n-k): ans += h[i] print(ans)" p03994,s555799539,Accepted,"alp = ""abcdefghijklmnopqrstuvwxyz"" s = input() K = int(input()) N = len(s) T = """" for i in range(N): n = alp.index(s[i]) if i==N-1: T+=alp[(n+K)%26] else: if n!=0 and K>=26-n: T+=""a"" K-=(26-n) else:T+=alp[n] print(T)" p03633,s358018829,Accepted,"def gcd(a, b): return b if a % b == 0 else gcd(b, a % b) def lcm(a, b): return a // gcd(a, b) * b n = int(input()) a = [] for i in range(n): a.append(int(input())) ans = a[0] for x in range(1, n): ans = lcm(ans, a[x]) print(ans) " p03557,s601251439,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()))) sm=0 for j in B: sm+=bisect.bisect_left(A,j)*(n-bisect.bisect_right(C,j)) print(sm) " p03803,s959639203,Accepted,"# Python3 (3.4.3) import sys input = sys.stdin.readline # ------------------------------------------------------------- # function # ------------------------------------------------------------- # ------------------------------------------------------------- # main # ------------------------------------------------------------- A,B = map(int,input().split()) if A==B: print(""Draw"") else: if A == 1: A = 14 if B == 1: B = 14 print(""Alice"" if A > B else ""Bob"")" p02675,s716648128,Wrong Answer,"N = input() N_list = list(N) if N_list[-1] == 2 or N_list[-1] == 4 or N_list[-1] == 5 or N_list[-1] == 7 or N_list[-1] == 9: print(""hon"") elif N_list[-1] == 0 or N_list[-1] == 1 or N_list[-1] == 6 or N_list[-1] == 8: print(""pon"") else: print(""bon"") " p02918,s241710212,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(N-1, ans + 2 * K))" p02720,s423140164,Wrong Answer,"N = int(input()) def is_lunlun(x): if x < 10: return True elif abs(int(str(x)[0])- int(str(x)[1])) > 1: return False else: return is_lunlun(int(str(x)[1:])) K = 1 num = 1 while True: if is_lunlun(num + 1): K += 1 num = num + 1 else: K += 1 num = num + 9 if K >= N: break print(num)" p03994,s881776823,Wrong Answer,"s=list(input()) k=int(input()) f=lambda x:(x-97)%26 for i in range(len(s)): j=26-f(ord(s[i])) if j>k: continue k-=j s[i]='a' k%=26 s[-1]=chr(f(ord(s[-1])+k)+97) print(*s,sep='')" p02707,s660121575,Accepted,"n = int(input()) a = [-1, 1] + list(map(int, input().split())) cnt = [0] * (n+1) for i in range(2, n+1): cnt[a[i]] += 1 for i in range(1, n+1): print(cnt[i])" p03061,s274560585,Accepted,"import fractions ans=0 f=[0] g=[0] N = int(input()) A = list(map(int,input().split())) for i in range(N-1): f.append(fractions.gcd(f[i],A[i])) g.append(fractions.gcd(g[i],A[N-i-1])) for i in range(N): ans = max(ans,fractions.gcd(f[i],g[N-i-1])) print(ans)" p03073,s650708428,Wrong Answer,"S = list(input()) f = False c = 0 for i in range(len(S) - 1): if i == len(S) - 2: break if S[i] != S[i + 1]: continue else: if S[i] == ""0"": S[i+1] = ""1"" c += 1 else: S[i+1] = ""0"" c += 1 print(c)" p03251,s480048730,Wrong Answer,"# B # 2020/03/27 8:52- n, m, X, Y = map(int, input().split()) x = list(map(int, input().split())) y = list(map(int, input().split())) x = sorted(x) y = sorted(y) xr = x[-1] yl = y[0] if xr <= yl and X < yl and xr <= Y: print('No War') else: print('War')" p03478,s802225333,Accepted,"n,a,b=map(int,input().split()) cnt=0 for i in range(1, n+1): x=sum(map(int,str(i))) if a<=x<=b: cnt+=i print(cnt) " p02811,s781001495,Accepted,"K,X = map(int,input().split()) if K*500>=X: print('Yes') else: print('No') " p03011,s615209094,Accepted,"p, q, r = map(int, input().split()) if p >= q and p >= r: print(q + r) elif q >= p and q >= r: print(p + r) else: print(p + q)" p03617,s512254070,Accepted,"q, h, s, d = map(int, input().split()) n = int(input()) ll = min(q*8, h*4, s*2, d) res = 0 res += (n//2)*ll n %= 2 res += min(q*4, h*2, s)*n print(res)" p03448,s185451591,Accepted,"A = int(input()) B = int(input()) C = int(input()) X = int(input()) import itertools as it ans = 0 for a,b,c in it.product(range(A+1), range(B+1), range(C+1)): if 500*a + 100*b + 50*c == X: ans += 1 print(ans)" p03612,s768095924,Wrong Answer,"n=int(input()) p=[int(x) for x in input().rstrip().split()] cnt=0 for i in range(n-1): if p[i]==i+1: now=p[i+1] p[i+1]=p[i] p[i]=now cnt+=1 print(cnt) " p02556,s505834915,Accepted,"n = int(input()) x_max = 0 y_max = 0 x_min = 10**9 y_min = 10**9 p_arr = [0]*n m_arr = [0]*n for i in range(n): x, y = map(int, input().split()) p_arr[i] = x + y m_arr[i] = x - y p_dist = max(p_arr) - min(p_arr) m_dist = max(m_arr) - min(m_arr) dist_max = max(p_dist, m_dist) print(dist_max)" p03286,s974496385,Accepted,"n=int(input()) if n==0: print(0) exit() s="""" while n!=0: if n % 2 == 1: s = ""1"" + s n = (n-1)//2*(-1) else: s=""0""+s n=n//2*(-1) print(s)" p03163,s885536348,Accepted,"def knapsack1(weight_value, w): cur = [0] * (w + 1) for weight, value in weight_value: for i in reversed(range(weight, w + 1)): cur[i] = max(cur[i], cur[i - weight] + value) return cur[w] def main(): n, w = [int(x) for x in input().split()] weight_value = [None] * n for i in range(n): weight_value[i] = [int(x) for x in input().split()] return knapsack1(weight_value, w) print(main()) " p03486,s328306925,Wrong Answer,"s = sorted(str(input()), reverse = True) t = sorted(str(input()), reverse = True) print(""Yes"" if s < t else ""No"")" p02989,s881208967,Accepted,"n = int(input()) d = list(map(int,input().split())) d.sort() a = n//2-1 print(d[a+1]-d[a])" p03774,s044253057,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 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)" p02773,s561086790,Accepted,"from collections import defaultdict n = int(input()) d = defaultdict(int) m = 0 for i in range(n): s = input() d[s] += 1 m = max(m,d[s]) ans = [] for k,v in d.items(): if v == m: ans.append(k) ans.sort() for a in ans: print(a) " p02996,s012701123,Accepted,"n=int(input()) t=[] for i in range(n): at,bt=map(int,input().split()) t.append([bt,at]) t.sort() temp=0 for i in range(n): temp=temp+t[i][1] if temp>t[i][0]: print(""No"") break else: print(""Yes"")" p02838,s905665933,Accepted,"N = int(input()) A = list(map(int, input().split())) ans = 0 mod = 1000000007 for i in range(60): one_count =0 zero_count = 0 for j in range(N): if A[j] >> i & 1 == 1: one_count+=1 else: zero_count+=1 ans += (one_count*zero_count)*(2**i) ans = ans%mod print(ans)" p02553,s284536561,Accepted,"a, b, c, d = map(int, input().split()) ans = -1e18 ans = max(ans, a*c) ans = max(ans, a*d) ans = max(ans, b*c) ans = max(ans, b*d) print(ans) " p03208,s351799132,Wrong Answer,"import sys input = sys.stdin.readline n, k = [int(x) for x in input().split()] h = [int(input()) for _ in range(n)] h.sort() h1 = h[:k] h2 = h[::-1][:k] print(min(max(h1) - min(h1), max(h2) - min(h2)))" p02994,s794094873,Accepted,"N, L = map(int, input().split()) A = [L+i for i in range(N)] A.remove(min(max(A), *[abs(a) for a in A])) print(sum(A))" p02639,s617051613,Accepted,"x_list = list(map(int, input().split())) for i in range(len(x_list)): if i+1 != x_list[i]: print(i+1) " p02684,s287735710,Accepted,"n,k = map(int, input().split()) a = list(map(int, input().split())) for i in range(n): a[i] -= 1 INF = 1001001001 dist = [INF]*n dist[0]=0 now=0 flag = True while 1: to = a[now] if dist[to]!=INF and flag: loop = dist[now] + 1 - dist[to] k-=1 k %= loop flag = False else: dist[to]=dist[now]+1 k-=1 now = to if k == 0: print(to+1) break" p03910,s502562825,Accepted,"n=int(input()) i=0 point=0 while n>point: i+=1 point+=i noneed=point-n for j in range(1,i+1): if j==noneed: continue print(j)" p03861,s023891184,Accepted,"a, b, x = map(int, input().split(' ')) answer = b//x - (a-1)//x print(answer)" p03607,s099430098,Accepted,"from collections import Counter n = int(input()) A = Counter(list(int(input()) for _ in range(n))) ans = 0 for a in A.values(): if a%2 == 1: ans += 1 print(ans)" p02952,s353513080,Accepted,"import sys #インタプリタや実行環境に関する情報を扱うためのライブラリ import os #フォルダやファイルを操作 import math N=int(input()) count=0 for i in range(N+1): if i==0: continue if i<10: count +=1 if i<100: continue elif i<1000: count +=1 elif i<10000: continue elif i<100000: count+=1 print(count)" p03281,s750890195,Accepted,"N = int(input()) ok_count = 0 for i in range(1, N + 1, 2): # 約数を8個もつものの数 count = 0 for j in range(1, i + 1): # print(""{}"".format(j)) if i % j == 0: count += 1 if count == 8: ok_count += 1 print(ok_count) " p02743,s915451340,Accepted,"a,b,c=map(int,input().split());print('YNeos'[c<=a+b or(a-b)**2<=(2*(a+b)-c)*c::2])" p03835,s988776953,Accepted,"k, s = map(int, input().split()) ans = 0 for i in range(k+1): for j in range(k+1): if k >= s - i - j >= 0: ans += 1 print(ans)" p03073,s590519055,Accepted,"s = input() if len(s)==1: print(0) else: start0 = 0 start1 = 0 for i in range(0,len(s),2): if s[i]==""1"": start0 += 1 for i in range(1,len(s),2): if s[i]==""0"": start0 += 1 for i in range(0,len(s),2): if s[i]==""0"": start1 += 1 for i in range(1,len(s),2): if s[i]==""1"": start1 += 1 print(min(start0,start1))" p03836,s779756727,Accepted,"# -*- coding: utf-8 -*- sx, sy, tx, ty = map(int, input().split()) dx,dy = tx-sx, ty-sy r1 = 'U'*dy + 'R'*dx r2 = 'D'*dy + 'L'*dx r3 = 'LU'+r1+'RD' r4 = 'RD'+r2+'LU' print(r1+r2+r3+r4)" p03210,s819313763,Wrong Answer,"x = input() print(""Yes"" if x in ""753"" else ""No"")" p02760,s118935245,Wrong Answer,"A = [list(map(int, input().split())) for _ in range(3)] N = int(input()) B = [int(input()) for _ in range(N)] l = [[(a_i in B) for a_i in a] for a in A] flag = 0 for y in range(3): flag |= all(l[y]) for x in range(3): flag |= all(l[x][y] for y in range(3)) flag |= all([l[y][x] for x, y in [(0, 0), (1, 1), (2, 2)]]) flag |= all([l[y][x] for x, y in [(0, 2), (1, 1), (2, 0)]]) print(""Yes"" if flag else ""No"")" p03282,s564540891,Accepted,"s = input() k = int(input()) cnt = 0 for c in s: if c == '1': cnt += 1 else: print(c) break if cnt >= k: print(c) break " p03861,s689744739,Wrong Answer,"import math a,b,x = map(int,input().split()) print(math.floor(b/x)-math.floor((a-1)/x))" p02959,s397425645,Accepted,"import sys def main(): 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[i], B[i]) B[i] -= min(A[i], B[i]) ans += min(A[i+1], B[i]) A[i+1] -= min(A[i+1], B[i]) print(ans) main()" p03030,s341989690,Accepted,"def main(): n = int(input()) a = [None]*n for i in range(n): s, p = map(str, input().split()) p = int(p) p *= -1 a[i] = [s, p, i+1] a.sort(key=lambda x: (x[0], x[1])) for i in range(n): print(a[i][2]) if __name__ == ""__main__"": main()" p02724,s976024252,Accepted,"n = int(input()) s = 0 if n>= 500: res = n//500 s = 1000*res n = n - res * 500 if n>=5: res = n//5 s = s + res*5 print(s)" p02613,s304599989,Accepted,"count1=0 count2=0 count3=0 count4=0 N=int(input()) for i in range(N): A=input() if A==""AC"": count1=count1+1 elif A==""WA"": count2=count2+1 elif A==""TLE"": count3=count3+1 elif A==""RE"": count4=count4+1 print(""AC x ""+str(count1)) print(""WA x ""+str(count2)) print(""TLE x ""+str(count3)) print(""RE x ""+str(count4)) " p02661,s335701099,Accepted,"N = int(input()) I = [] for _ in range(N): I.append(list(map(int, input().split()))) L = sorted(I) R = sorted(I, key = lambda x: x[1]) if N%2 == 1: x = N//2 print(R[x][1] - L[x][0] + 1) else: x = N//2 M = R[x][1] - L[x][0] + 1 m = R[x-1][1] - L[x-1][0] + 1 print(M + m - 1)" p02888,s616936769,Accepted,"from bisect import bisect_left,bisect_right N=int(input()) A=list(map(int, input().split())) A.sort() ans=0 for i in range(N): for j in range(i+1,N): a,b=A[i],A[j] B=A[j+1:] l=abs(a-b) r=a+b # print(bisect_left(B,r)-bisect_right(B,l)) ans+=bisect_left(B,r)-bisect_right(B,l) print(ans)" p02888,s434093625,Accepted,"import bisect n=int(input()) l=sorted(list(map(int,input().split()))) ans=0 for i in range(n-2): for j in range(i+1,n-1): ans+=bisect.bisect_left(l,l[i]+l[j])-j-1 print(ans)" p02838,s185385573,Accepted,"import sys read = sys.stdin.read def main(): MOD = 10**9+7 n, *A = map(int, read().split()) ans = 0 for j in range(61): c = 0 for i in A: if i>>j & 1: c += 1 ans += 2**j*((n-c)*c) ans %= MOD print(ans%MOD) if __name__ == ""__main__"": main()" p03067,s255143970,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')" p02577,s602445845,Wrong Answer,"print('Yes' if int(input())%9 else 'No') " p03774,s031513713,Accepted,"n, m = map(int, input().split()) students = [list(map(int, input().split())) for i in range(n)] targets = [list(map(int, input().split())) for i in range(m)] x = 0 snumber = [(0, x)] * n def md(s, t): d = abs(s[0] - t[0]) + abs(s[1] - t[1]) return d for i in range(n): x = 4 * 10 ** 8 for j in range(m): if x > md(students[i], targets[j]): x = md(students[i], targets[j]) snumber[i] = (j+1, md(students[i], targets[j])) for i in range(n): print(snumber[i][0])" p02691,s786001732,Accepted,"import collections n = int(input()) a = list(map(int, input().split())) x = [] for i in range(n): x.append(a[i]-i) y = [] for j in range(n): y.append(-(a[j]+j)) X = collections.Counter(x) Y = collections.Counter(y) ans = 0 z = X.keys() #print(z) for i in z: p =X.get(i,0) q =Y.get(i,0) ans += p*q print(ans) " p03281,s388222380,Accepted,"n = int(input()) def check(p): c = 0 for i in range(1,p+1): if p % i == 0: c += 1 return c ans = 0 for i in range(1,n+1): if i % 2 == 1: if check(i) == 8: ans += 1 print(ans)" p03351,s167349132,Accepted,"a, b, c, d = map(int, input().split()) if abs(b-a) <= d and abs(c-b) <= d: print(""Yes"") elif abs(c-a) <= d: print(""Yes"") else: print(""No"") " p02547,s540221704,Accepted,"N=int(input()) Di=[input() for i in range(N)] count=0 n=0 D=[] a=[] A=0 for i in range(N): D.append(Di[i].split()) for i in range(N): if D[i][0]==D[i][1]: count+=1 else: a.append(count) count=0 if len(a)==0: A=0 else: A=max(a) if A>count: n+=A else: n+=count if n>=3: print(""Yes"") else: print(""No"") " p02598,s841440848,Accepted,"import sys import numpy as np import math 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())) n,k = Mi() a = np.array(sys.stdin.readline().split(), np.int64) mina = np.sum(a//(n+k)) maxa = np.max(a) while maxa > mina+1: mid = (mina+maxa)//2 div = np.sum(np.ceil(a/mid))-n if div > k: mina = mid else: maxa = mid print(maxa)" p02572,s110448508,Accepted,"m = int(input()) a = list(map(int, input().split())) mod = 10**9 + 7 ans = 0 tmp_sum = sum(a[1:m]) % mod for x in range(m-1): if a[x] % mod != 0: ans += (a[x] * tmp_sum) % mod tmp_sum -= a[x+1] % mod print(ans%mod)" p03695,s135028007,Accepted,"n=int(input()) a=list(map(int,input().split())) al=0 for i in range(n): if a[i]>=3200: al+=1 a[i]=8 else: a[i]=a[i]//400 if al==0: cl=len(set(a)) else: cl=len(set(a))-1 if cl==0: mi=1 else: mi=cl ma=al+cl print(mi,ma)" p02957,s936820257,Wrong Answer,"a,b = map(int,input().split()) if (abs(a-b)/2)%2 == 0: print((abs(a-b)//2)) else: print('IMPOSSIBLE')" p02633,s028164506,Accepted,"# -*- coding: utf-8 -*- # get a integer a = int(input()) m = a c = 1 while m % 360 != 0: m+=a c+=1 print(c)" p03605,s869665580,Accepted,print('Yes') if '9' in input() else print('No') p02823,s833729827,Accepted,"import math n, a, b = [int(w) for w in input().split()] if (a + b) % 2 == 0: ans = (b - a) // 2 else: ans = min(a - 1, n - b) ans += 1 + (b - a) // 2 print(ans) " p02777,s281303575,Accepted,"S,T=map(str,input().split()) A,B=map(int,input().split()) U=input() if U==S: print(A-1,B) else: print(A,B-1)" p02801,s897732242,Accepted,print(chr(ord(input())+1)) p02726,s607101318,Wrong Answer,"n,x,y = map(int,input().split()) def dist(i,j): return min(j - i, abs(x - i) + abs(y - j) + 1) listlist = [0]*(n-1) for i in range(1,n): for j in range(i + 1, n + 1): print(j-i,abs(x - i) + abs(y - j) + 1) distance = dist(i,j) listlist[distance-1] = listlist[distance-1] + 1 for k in listlist: print(k)" p03030,s248896877,Wrong Answer,"N=int(input()) S=[list(map(str,input().split())) for i in range(N)] A=sorted(S,key=lambda x: int(x[1]), reverse=True) A=sorted(A,key=lambda x: x[0]) for i in range(N): ans=A.index(S[i])+1 print(ans) " p03627,s336153269,Accepted,"n=int(input()) from collections import Counter as co var=co(list(map(int,input().split()))).items() f,s=0,0 for k,v in var: if v>=4: if f=2: if f=4: li4.append(x) elif y>=2: li.append(x) li.sort() li4.sort() if len(li)<2: print(0) exit() x=0 if li4: x=(li4[-1])**2 y=li[-1]*li[-2] print(max(x,y))" p02909,s650699986,Accepted," s=input() if s==""Sunny"": print(""Cloudy"") if s==""Cloudy"": print(""Rainy"") if s==""Rainy"": print(""Sunny"") " p03860,s439241712,Wrong Answer,"#ABC048A https://atcoder.jp/contests/abc048/tasks/abc048_a a,b,c=input().split() print(a[0],b[0],c[0])" p03627,s858537667,Accepted,"from collections import Counter N = int(input()) A = Counter(map(int, input().split())) S = [] for a, c in A.items(): S.extend([a] * (c // 2)) S.sort() if len(S) < 2: print(0) else: print(S[-1] * S[-2]) " p03076,s034389140,Accepted,"m = [ int(input()) for _ in range(5) ] m_min = sorted(m, key=lambda x: (x%10)) idx = 0 for i,x in enumerate(m_min): if x%10 != 0: idx = i break order = [ i if i % 10 == 0 else (int(i/10) + 1) * 10 for i in m_min] print(sum(order)+m_min[idx]-order[idx])" p03126,s838570594,Wrong Answer,"#ABC-118-B N, M = map(int, input().split()) memo = [0]*(M+1) for _ in range(N): Ki, *A = map(int, input().split()) for item in A: memo[int(item)] += 1 ans = 0 for i in range(1, M): if memo[i] == N: ans += 1 print(ans)" p03524,s065344042,Wrong Answer,"s=input() a=s.count('a') b=s.count('b') c=s.count('c') if len(set(list(s)))==1 and len(s)>1: print('NO') elif len(set(list(s)))==2 and len(s)>2: print('NO') elif abs(a-b)<=1 or abs(b-c)<=1 or abs(c-a)<=1: print('YES') else: print('NO')" p03557,s451912760,Accepted,"from bisect import bisect N=int(input()) A=sorted(list(map(int,input().split()))) B=sorted(list(map(int,input().split()))) B_reverse=B[::-1] C=sorted(list(map(int,input().split()))) cnt=0 dict={} val=0 for b in B_reverse: c_min=bisect(C,b) val+=N-c_min dict[b]=val for a in A: b_min=bisect(B,a) if b_min==N: pass else: cnt+=dict[B[b_min]] print(cnt)" p02713,s437450138,Wrong Answer,"import fractions from functools import reduce def gcd(*numbers): return reduce(fractions.gcd, numbers) N = int(input()) n = 0 for i in range(N): for j in range(N): for k in range(N): n += gcd(i,j,k) print(n)" p03745,s601248607,Accepted,"n = int(input()) a = list(map(int,input().split())) up=2 ans=1 for i in range(1,n): if up==2: if a[i-1]a[i]: up=0 elif up==1 and a[i-1]>a[i]: up=2 ans+=1 elif up==0 and a[i-1]= 0: ans += i[1] w -= i[2] else: break print(ans)" p03759,s360566864,Wrong Answer,"a,b,c = map(int,input().split()) if b -a==c-b: print(""Yes"") else: print(""No"") " p03062,s435572520,Accepted,"from collections import Counter,defaultdict,deque from heapq import heappop,heappush,heapify import sys,bisect,math,itertools,fractions,copy 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() cnt = 0 for i in range(n): if a[i] < 0: cnt += 1 a = [abs(x) for x in a] a.sort() if cnt%2: a[0] = -a[0] print(sum(a))" p03557,s693808331,Wrong Answer,"#二分探索 from bisect import bisect_left from bisect import bisect_right #input N = int(input()) #print(N) A = sorted(list(map(int, input().split()))) #この表記について... B = sorted(list(map(int, input().split()))) C = sorted(list(map(int, input().split()))) #print(A,B,C) #sort 昇順に並び替え #A.sort() #B.sort() #C.sort() ans = 0 for i in range(N): ab = bisect_left(A,B[i]) bc = N-bisect_right(C,B[i]) print(ab, end=' ') print(bc) ans += ab*bc print(ans)" p02600,s492919211,Accepted,"# coding: utf-8 # Your code here! x = int(input()) if x<600: print(8) elif x<800: print(7) elif x<1000: print(6) elif x<1200: print(5) elif x<1400: print(4) elif x<1600: print(3) elif x<1800: print(2) elif x<2000: print(1)" p02802,s545673631,Accepted,"n,m = map(int,input().split()) ac,wa = 0,0 number=[0]*n for i in range(m): p,s = input().split() p = int(p) - 1 if number[p]!=-1: if s == ""WA"": number[p]+=1 elif s == ""AC"": ac+=1 wa+=number[p] number[p]=-1 print(ac,wa)" p02600,s898558962,Accepted,"X = int(input()) print((1999-X) // 200 + 1)" p02755,s613975678,Accepted,"A,B = map(int,input().split(sep="" "")) i = 0 for i in range(0, 1251,1): if i*8//100 == A and i*10//100 == B: print(i) exit() print(-1) " p02681,s356994323,Accepted,"S = input() T = input() S = S + T[-1] if S == T: ans = 'Yes' else: ans = 'No' print(ans)" p03773,s621736400,Wrong Answer,"a, b = map(int, input().split()) time = a + b if time > 24: print(time - 24) else: print(type(time))" p03324,s002473486,Accepted,"D,N = map(int,input().split()) ans = 0 if D == 0 and N !=100: print(N) elif D == 0 and N == 100: print(101) elif D == 1 and N !=100: print(N*100) elif D == 1 and N == 100: print(10100) elif D == 2 and N != 100: print(N*10000) else: print(1010000)" p03495,s269916154,Accepted,"n,k = map(int,input().split()) a = [int(x) for x in input().split()] d = {} ans_list = [] ans = 0 for aa in a: if aa not in d: d[aa] = 0 d[aa] += 1 for v in d.values(): ans_list.append(v) ans_list.sort() for i in range(len(ans_list) - k): ans += ans_list[i] print(ans) " p03719,s254168538,Wrong Answer,"A,B,C = map(int,input().split()) if A<= C <= B: print('YES') else: print('NO')" p03416,s715128613,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) " p03211,s767449176,Accepted,"s=str(input()) ans=12000 for i in range(len(s)-2): ans=min(ans,abs(753-int(s[i:i+3]))) print(ans)" p02982,s434426140,Accepted,"N, D = map(int, input().split()) l = [list(map(int, input().split())) for i in range(N)] ans=0 s=0 for i in range(N): for j in range(i+1,N): s=0 for d in range(D): s+=(l[i][d]-l[j][d])**2 if s**(1/2)%1==0: ans+=1 print(ans)" p04029,s146900978,Wrong Answer,"n=int(input()) print(n*(n-1)//2)" p02987,s881175997,Accepted,"s = input() if len(set(s)) == 2 and s.count(s[0]) == 2: print(""Yes"") else: print(""No"")" p02994,s892958687,Wrong Answer,"a,b=map(int,input().split()) total=a*(a+2*b-1)//2 x=b y=a+b-1 z=min(abs(x),abs(y)) if x<=0 and y>=0: print(total) else: print(total-z)" p03137,s841911187,Accepted,"n,m = map(int,input().split()) x = list(map(int,input().split())) x.sort() y=[abs(x[i]-x[i+1]) for i in range(m-1)] y.sort(reverse=1) print(sum(y[n-1:]))" p03241,s987496958,Accepted,"n,m=map(int,input().split()) ans=1 for i in range(int((m**0.5))+1, 0, -1): if m%i==0: a=i b=m//i if a*n<=m: ans=max(ans, a) if b*n<=m: ans=max(ans, b) print(ans)" p02603,s641500854,Wrong Answer,"N = int(input()) A = list(map(int, input().split())) yen = 1000 stocks = 0 for i in range(N): if i == N-1: yen += stocks * A[i] stocks = 0 break if A[i] > A[i-1]: # sell everything yen += stocks * A[i] stocks = 0 else: # buy everything num = yen // A[i] stocks += num yen -= A[i] * num print(yen)" p02995,s240835645,Accepted,"import math a,b,c,d = map(int, input().split()) C, D = c, d if C < D: C, D = D, C r = C % D while r > 0: C = D D = r r = C % D lcm = c * d // D cPower = b//c - math.ceil(a/c) + 1 dPower = b//d - math.ceil(a/d) + 1 cdPower = b//lcm - math.ceil(a/lcm) + 1 print(max((b-a+1) - cPower - dPower + cdPower, 0))" p02682,s251661227,Accepted,"a, b, c, k = [int(i) for i in input().split()] if a >= k: ans = k elif (a+b) >= k: ans = a else: ans = a - (k-a-b) print(ans)" p02785,s854885082,Accepted,"n,k = [int(j) for j in input().split()] l = [int(j) for j in input().split()] l.sort() l = l[::-1] for i in range(min(k, n)): l[i] = 0 print(sum(l))" p02995,s471340990,Accepted,"def main(): from math import gcd a, b, c, d = (int(i) for i in input().split()) L = c*d//gcd(c, d) ans = b - (b//c + b//d - b//L) ans -= (a-1) - ((a-1)//c + (a-1)//d - (a-1)//L) print(ans) if __name__ == '__main__': main() " p02817,s326959520,Wrong Answer,"S = 'oder' T = 'atc' H=T+S print(H)" p02935,s560502359,Accepted,"n = int(input()) v = [int(i) for i in input().split()] v = sorted(v) s = v[0] for i in range(n): s = (s + v[i] ) / 2 print(s) " p03251,s762018643,Wrong Answer,"n,m,x,y = map(int,input().split()) xx = list(map(int,input().split())) yy = list(map(int,input().split())) if x < y and max(xx) <= y and x < min(yy): print(""No War"") else: print(""War"")" p03672,s680110283,Wrong Answer,"ss = input() for i in range(2, len(ss), 2): tt = ss[:-i] l = len(tt) // 2 if tt[:l] == tt[l:]: print(tt) break " p02801,s444861325,Accepted,"import sys def solve(): readline = sys.stdin.buffer.readline mod = 10 ** 9 + 7 ls = [chr(i) for i in range(97, 97 + 26)] c = str(readline().rstrip().decode('utf-8')) for i in range(1, len(ls)): if ls[i-1] == c: print(ls[i]) exit() if __name__ == '__main__': solve() " p03723,s448728116,Accepted,"def calculate(A, B, C): for i in range(1000): if A % 2 == 1 or B % 2 == 1 or C % 2 == 1: return i else: _A = (B + C) // 2 _B = (A + C) // 2 _C = (A + B) // 2 A, B, C = _A, _B, _C return -1 A, B, C = map(int, input().split()) print(calculate(A, B, C))" p02972,s691214888,Accepted,"N = int(input()) a = list(map(int, input().split())) a.insert(0, 0) b = [0] * N M = 0 for i in range(N, 0, -1): ball = 0 for j in range(i + i, N + 1, i): ball ^= b[j - 1] b[i - 1] = ball ^ a[i] M = sum(b) print(M) for i in range(N): if b[i]: print(i + 1, end = ' ')" p02773,s669857296,Wrong Answer,"N = int(input()) D = {} for i in range(N): S = input() if S in D: D[S] += 1 else: D[S] = 1 t = max(D) M = D[t] E = [] for s in D: if D[s] == M: E.append(s) E = sorted(E) for i in range(len(E)): print(E[i])" p02725,s059078960,Accepted,"K, N = map(int, input().split()) A = list(map(int, input().split())) li = [] for i in range(N): if i == 1: cadA = A[N-1] - A[0] else: cadA = K - A[i] + A[i-1] if i == N-1: cadB = A[N-1] - A[0] else: cadB = A[i] + (K - A[i+1]) li.append(min(cadA, cadB)) print(min(li)) " p02922,s012049709,Accepted,"a, b = map(int, input().split()) cur = 1 ans = 0 while cur < b: cur += a - 1 ans += 1 print(ans) " p02767,s537273889,Accepted,"N = int(input()) X = [int(i) for i in input().split()] min_d = 10000000 for p in range(1,101): d = 0 for x in X: d += (x-p)**2 if d <= min_d: min_d = d print(min_d)" p03000,s043005701,Accepted,"#!/usr/bin/env python3 # https://atcoder.jp/contests/abc130/tasks/abc130_b n, x = [int(x) for x in input().split()] li = [int(x) for x in input().split()] li2 = [0] + [sum(li[:i + 1]) for i, n in enumerate(li)] li2 = [n for n in li2 if n <= x] print(len(li2)) " p02553,s626063116,Accepted,"a,b,c,d = map(int,input().split()) if a>=0 and c>=0: print(b*d) elif a>=0 and c<0<=d: print(b*d) elif a>=0 and d<0: print(a*d) elif a<0<=b and c>=0: print(b*d) elif a<0<=b and c<0<=d: print(max(b*d,a*c)) elif a<0<=b and d<0: print(a*c) elif b<0 and c>=0: print(b*c) elif b<0 and c<0<=d: print(a*c) elif b<0 and d<0: print(a*c)" p03087,s628358334,Wrong Answer,"N, Q = map(int, input().split()) S = input() qn = [list(map(int, input().split())) for _ in range(Q)] S = ""0"" + S cnt = [] cnt.append(0) for i in range(1, N+1): if (S[i-1:i+1] == ""AC""): cnt.append(cnt[i-1] + 1) else: cnt.append(cnt[i-1]) for q in qn: ans = cnt[q[1]] - cnt[q[0]-1] # if S[q[0]-1:q[0]+1] == ""AC"": # ans -= 1 print(ans) " p02862,s090205474,Accepted,"X, Y = [int(x) for x in input().split()] M = 10**9+7 if (X + Y) % 3: print(0) else: x = X - (X+Y)//3 y = Y - (X+Y)//3 if x < 0 or y < 0: print(0) else: #print(x, y) #x+y c x #(x+y)!/x!/y! ans = 1 for j in range(y): #print(j) #print(x+j+1, j+1) ans *= (x+j+1) * pow(j+1, -1, M) ans %= M print(ans)" p02694,s659219398,Accepted,"X = int(input()) m = 100 ans = 0 while X > m: m += int(m*0.01) ans += 1 print(ans) " p03612,s490335128,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: ans += 1 p[i], p[i+1] = p[i+1], p[i] if p[-1] == n: ans += 1 print(ans)" p03219,s528403917,Accepted,"X,Y = map(int,input().split()) print(X+Y//2)" p02748,s911835647,Accepted,"s = input().split() a, b, m = int(s[0]), int(s[1]), int(s[2]) a_list = [int(i) for i in input().split()] b_list = [int(i) for i in input().split()] ans = min(a_list) + min(b_list) for i in range(m): ss = input().split() temp = a_list[int(ss[0])-1] + b_list[int(ss[1])-1] - int(ss[2]) if ans > temp: ans = temp print(ans) " p02860,s612782690,Accepted,"N = int(input()) S = input() ans = 'No' # Nが偶数のときを考えればよい if N % 2 == 0: if S[:N // 2] == S[N // 2:]: ans = 'Yes' print(ans)" p02838,s864757754,Accepted,"import numpy as np from math import ceil,log2 N = int(input()) a = np.array(list(map(int,input().split())),dtype=np.int64) ans = 0 count = 1 if max(a) == 0: x = 1 else: x = ceil(log2(max(a))) for i in range(x): b = a%2 s = np.count_nonzero(b==1)*np.count_nonzero(b==0)*count ans +=s count *= 2 a = a//2 ans %= 10**9+7 print(ans) " p02888,s148538241,Wrong Answer,"n = int(input()) l = list(map(int, input().split())) l.sort() c = 0 for i in range(n - 2): x = l[i] for j in range(i + 1, n - 1): y = l[j] for k in range(j + 1, n): if x + y <= l[k]: break c += k - j - 1 print(c)" p03836,s578948328,Accepted,"sx, sy, tx, ty = map(int, input().split()) ans = """" for i in range(sx, tx): ans += 'R' for i in range(sy, ty): ans += 'U' for i in range(sx, tx): ans += 'L' for i in range(sy, ty): ans += 'D' ans += 'D' for i in range(sx, tx + 1): ans += 'R' for i in range(sy - 1, ty): ans += 'U' ans += 'LU' for i in range(sx - 1, tx): ans += 'L' for i in range(sy, ty + 1): ans += 'D' ans += 'R' print(ans)" p03208,s814069565,Wrong Answer,"n,k=map(int, input().split()) h=[] for i in range(n): h.append(int(input())) h.sort() ans=h[k-1]-h[0] for i in range(1,n-k): ans=min(ans,h[i+k-1]-h[k]) print(ans)" p02814,s894654044,Accepted,"import sys import math def gcd(x, y): if x < y: return gcd(y, x) if y == 0: return x return gcd(y, x % y) sys.setrecursionlimit(1000000) input = lambda: sys.stdin.readline().rstrip() N, M = map(int, input().split()) a = list(map(lambda x : int(x) // 2, input().split())) lcm = 1 for i in a: lcm = lcm * i // gcd(lcm, i) ok = True for i in a: if lcm // i % 2 == 0: ok = False if not ok: print(0) else: print((M // lcm - 1) // 2 + 1)" p02640,s977724700,Accepted,"x,y = map(int,input().split()) #if (2*x)=0 and z%2==0: print('Yes') else: print('No') " p03592,s542075582,Wrong Answer,"n, m, k = map(int, input().split()) cant = True for i in range(n+1): for j in range(m+1): if n*i+m*j-2*i*j==k: cant = False print(""YNeos""[cant::2])" p03645,s917694949,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"")" p03086,s306288723,Accepted,"S=input() m=0 count=0 for s in S: if s in ""ACGT"": count += 1 else:count=0 m=max(m,count) print(m)" p03471,s015692376,Wrong Answer,"n,y=map(int,input().split()) flag=True 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: print(i,j,k) flag=False break if flag==False: print(-1,-1,-1) " p03076,s287955942,Accepted,"import math a = int(input()) b = int(input()) c = int(input()) d = int(input()) e = int(input()) x = math.ceil(a / 10) x += math.ceil(b / 10) x += math.ceil(c / 10) x += math.ceil(d / 10) x += math.ceil(e / 10) rems = [r for r in [a%10, b%10, c%10, d%10, e%10] if r != 0] if len(rems) > 0: ans = 10*(x-1) + min(rems) else: ans = 10*x print(ans)" p03261,s897914387,Accepted,"def main(): N = int(input()) words = [] success = True for _ in range(N): word = input() if word in words: success = False if not words == []: if not words[-1][-1] == word[0]: success = False words.append(word) if success: print(""Yes"") else: print(""No"") if __name__ == '__main__': main()" p02995,s131002518,Accepted,"A, B, C, D = map(int, input().split()) c = C d = D gcd = 0 while gcd == 0: if c > d: k = c c = d d = k # 必ず c <= d になる if d%c == 0: gcd = c else: d = d%c # 最小公倍数(lcm) lcm = int(C*D/gcd) wareru = B//C + B//D - B//lcm - (A-1)//C - (A-1)//D + (A-1)//lcm ans = B-A+1-wareru print(ans)" p03469,s919475718,Accepted,"date = list(input()) date[3] = ""8"" print("""".join(map(str, date)))" p04045,s435647470,Accepted,"def main(): n,k = map(int,input().split()) D = set(map(int,input().split())) while True: flg = 0 for i in str(n): i = int(i) if i in D: flg = 1 break if flg == 0: break n+=1 print(n) main()" p03073,s183898291,Accepted,"s = input() x = """" y = """" x_con = 0 y_con = 0 for i in range(len(s)): if i % 2 == 0: x += ""0"" y += ""1"" else: x += ""1"" y += ""0"" for i in range(len(s)): if s[i] != x[i]: x_con += 1 if s[i] != y[i]: y_con += 1 print(min(x_con, y_con))" p03612,s809356358,Accepted,"n = int(input()) P = [""D""] + list(map(int,input().split())) ans = 0 for i in range(1,n): if P[i] == i: ans += 1 P[i+1] = P[i] if P[-1] == n: ans += 1 print(ans)" p02833,s568320202,Accepted,"import math import time from collections import deque from copy import deepcopy t = time.time() def iip(): ret = [int(i) for i in input().split()] if len(ret) == 1: return ret[0] return ret def main(): n = iip() if n == 0: print(0) exit() if n % 2 == 1: print(0) exit() ret = int(0) num = 10 while num <= n: ret += n // num num *= 5 print(int(ret)) main()" p03611,s889823191,Accepted,"import collections N = int(input()) A = list(map(int,input().split())) C = collections.Counter(A) keys = sorted(C.keys()) MAX = 0 for i in keys: MAX = max(MAX,C[i-1]+C[i]+C[i+1]) print(MAX)" p02842,s770380647,Wrong Answer,"import math N = int(input()) S = math.ceil(N / 1.08) if S * 1.08 != N: print("":("") else: print(S)" p03086,s786933030,Accepted,"s=input() n=len(s) ans=0 for i in range(n): for j in range(i,n): if all('ACGT'.count(c)==1 for c in s[i:j+1]): ans=max(ans,len(s[i:j+1])) print(ans)" p02631,s090911249,Accepted,"def main(): n = int(input()) A = [int(e) for e in input().split()] s = 0 for a in A: s ^= a print(*[s ^ a for a in A]) if __name__ == '__main__': main() " p03774,s563740651,Wrong Answer,"n,m=map(int,input().split()) a=[list(map(int,input().split())) for i in range(n)] c=[list(map(int,input().split())) for i in range(m)] def d(x,y): return abs(x[0]-y[0])+abs(x[1]+y[1]) for i in a: ans=10101001010 ch=0 for j in range(m): if d(i,c[j]) ri and ri >= l: r = ri else: rb = False if not (lb or rb): print(0) exit() # print(l,r) print(r - l + 1)" p03545,s619132974,Accepted,"s = input() ans1=s[0] def solve(i,tmp,ans): global ans1 if i==3: if tmp==7: ans1=ans return True else: return False if solve(i+1,tmp+int(s[i+1]),ans+""+""+s[i+1]): return True if solve(i+1,tmp-int(s[i+1]),ans+""-""+s[i+1]): return True if solve(0,int(s[0]),ans1): print(ans1+""=7"")" p02860,s537896315,Wrong Answer,"N = int(input()) S = str(input()) num =int( N / 2) f = S[0:num] if S == f+f: print('YES') else: print('NO') " p03250,s680636830,Accepted,"a = list(map(int, input().split())) a.sort() print(a[2] * 10 + a[1] + a[0])" p03723,s016251026,Wrong Answer,"if __name__ == ""__main__"": a, b, c = map(int, input().split()) if a == b == c: print(-1) exit() ans = 0 while a % 2 == 0 and b % 2 == 0 and c % 2 == 0: a_tmp = (b+c)//2 b_tmp = (a+c)//2 c_tmp = (c+a)//2 a = a_tmp b = b_tmp c = c_tmp ans += 1 print(ans) " p03331,s970924420,Accepted,"N = int(input()) cmin = N for i in range(1,N): j = N-i a = str(i) b = str(j) cnt = 0 for k in range(len(a)): cnt += int(a[k]) for k in range(len(b)): cnt += int(b[k]) cmin = min(cmin,cnt) print(cmin)" p03319,s661527594,Accepted,"n,k = map(int,input().split()) a = list(map(int,input().split())) ans = (n+k-3)//(k-1) print(ans)" p02623,s829459398,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 j in range(M): b.append(b[j]+B[j]) 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)" p03565,s747814364,Accepted,"s=list(input()) t=input() k=[] for i in range(len(s)-len(t)+1): m=i for j in t: if s[m]==j or s[m]=='?': m+=1 else:break else: l=s[:i]+list(t)+s[i+len(t):] for i in l: if i=='?': l[l.index(i)]='a' k.append(''.join(l)) if len(k)==0: k.append('UNRESTORABLE') print(min(k))" p02819,s272429921,Wrong Answer,"s = int(input()) def primeNumberCreate(): global s primeList = [2] # 2以下の素数リストを作成 maxNumber = s+1000 # 1000以下の数字をチェック for x in range(s, maxNumber): for y in primeList: if x % y == 0: break else: primeList.append(x) # 割り切れるものがなければリストに追加 primeList.pop(0) return primeList print(min(primeNumberCreate())) " p02603,s424123235,Accepted,"n = int(input()) a = list(map(int, input().split())) m = 1000 i = 0 while i < n - 1: for j in range(i + 1, n): if a[i] < a[j]: m = m // a[i] * a[j] + m % a[i] i = j else: i = j break print(m)" p03617,s625817309,Accepted,"Q,H,S,D=map(int,input().split()) N=int(input()) min1 = min(4*Q, 2*H, S) min2 = min(8*Q, 4*H, 2*S, D) if N%2==0: print(N//2*min2) else: print(N//2*min2 + min1) " p03377,s698303758,Wrong Answer,"a,b,x=map(int,input().split()) if a>x and a+b>x: print('YES') else: print('NO')" p02570,s323545074,Wrong Answer,"d, t, s = list(map(int, input().split())) if d//s <= t: print(""Yes"") else: print(""No"") " p03485,s440628807,Accepted,"import math a, b = map(int, input().split()) print(math.ceil((a+b)/2))" p03126,s248984857,Wrong Answer,"N,M = map(int,input().split()) l = [list(map(int,input().split())) for i in range(N)] for i in range(N): del l[i][0] for i in range(N-1): a = set(l[i])&set(l[i+1]) l[i+1] = a if N==1: print(len(l[0])) print(len(a)) " p02765,s995259745,Accepted,"def InnerRating(N, R): if N >= 10: return R else: return R + 100 * (10 - N) N, R = map(int, input().split()) print (InnerRating(N, R))" p03607,s264923907,Wrong Answer,"n = int(input()) a = [int(input()) for _ in range(n)] d = {} for i in a: if i not in d: d[i] = 0 d[i] +=1 elif i in d: d[i] -=1 l =[] for i in d.keys(): if d[i] != 0: l.append(d[i]) print(len(l))" p03544,s304285684,Accepted,"n = int(input()) a = [0] * (n+1) a[0] = 2 a[1] = 1 for i in range(2, n+1): a[i] = a[i-1] + a[i-2] # print(a) print(a[n]) " p02873,s246495603,Accepted,"from collections import deque S = input() left = deque([0]) right = deque([0]) cnt = 0 for s in S: if s == '<': cnt += 1 else: cnt = 0 left.append(cnt) cnt = 0 for s in S[::-1]: if s == '>': cnt += 1 else: cnt = 0 right.appendleft(cnt) ans = 0 for l, r in zip(left, right): ans += max(l, r) print(ans) " p02833,s733420774,Accepted,"import sys a=int(input()) if a%2==1: print(0) sys.exit() i=10 ans=0 while i<=a: ans+=a//i i*=5 print(ans)" p02935,s409739047,Wrong Answer,"N=int(input()) L1=sorted(list(map(int,input().split()))) ans=L1[0] L1.pop(0) for i in range(len(L1)): ans=(ans+L1[i])/2 print(ans) print(ans) " p03251,s734593391,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 < max(x) <= Y and X < min(y) <= Y: print(""No War"") else: print(""War"")" p02601,s892643476,Accepted,"A, B, C = map(int, input().strip().split()) K = int(input()) while A >= B and K > 0: B = B * 2 K -= 1 while B>=C and K>0: C=C*2 K-=1 if Ah[b-1] and ac[a-1] != 0: ac[a-1]=1 ac[b-1]=0 elif h[a-1]= N: break for j in range(1, i+1): if ans - N == j: continue print(j)" p03106,s126244577,Accepted,"A, B, K = map(int, input().split()) now = 0 for i in range(100): tmp = 100-i if A % tmp == 0 and B % tmp == 0: now += 1 if now == K: print(tmp) " p03107,s174556486,Accepted,"s =list(input()) m = min(s.count('0'),s.count('1')) print(2*m) " p02646,s568037119,Accepted,"A, V = map(int, input().split()) B, W = map(int, input().split()) T = int(input()) if V <= W: print(""NO"") exit() dist = abs(A - B) if V*T - W*T < dist: print(""NO"") else: print(""YES"")" p02972,s636295561,Accepted,"n=int(input()) a=list(map(int,input().split())) L=[0]*n ans=[] for i in range(n-1,-1,-1): if i+1>n//2: L[i]=a[i] else: t=n//(i+1) el=0 for j in range(2,t+1): el += L[(i+1)*j-1] L[i]=(el+a[i])%2 if L[i]==1: ans.append(str(i+1)) print(len(ans)) if len(ans)>0: print(' '.join(ans))" p03493,s960685904,Accepted,"li = list(input()) cnt = 0 101 if (li[0] == ""1""): cnt += 1 if (li[1] == ""1""): cnt += 1 if (li[2] == ""1""): cnt += 1 print(cnt) " p03693,s481429341,Wrong Answer,"r,g,b=map(int, input().split()) if (r*100 +g*10 +b)%4==0: print(""Yes"") else: print('No')" p02687,s786650793,Accepted,"S = input() if S == ""ABC"": print(""ARC"") else: print(""ABC"")" p03282,s661711427,Wrong Answer,"S = input() K = int(input()) count = 0 for i in range(len(S)): if S[i] == ""1"": count += 1 if count == len(S): print(""1"") exit() for i in range(len(S)): if S[i] != ""1"": ans = S[i] break print(ans)" p02578,s398128222,Accepted,"n = int(input()) num = list(map(int,input().split())) ans = 0 m = num[0] for i in range(1,n): if m >= num[i]: ans += m - num[i] else: m = num[i] print(ans)" p02577,s383885665,Accepted,"# -*- coding: utf-8 -*- n = input() if sum(list(map(int, list(n)))) % 9 == 0: print('Yes') else: print('No') " p03862,s547060254,Wrong Answer,"n,k = map(int,input().split()) A = list(map(int,input().split())) ans = 0 for i in range(1, n): if A[i]+A[i-1]<=k: continue ans += (A[i]+A[i-1])-k A[i] = k-A[i-1] print(ans)" p03943,s901043500,Accepted,"a,b,c = map(int,input().split()) print(['No','Yes'][a+b == c or a+c == b or b+c == a])" p03612,s429992423,Accepted,"# 2020/05/22 # AtCoder Beginner Contest 072 - D # Input n = int(input()) p = list(map(int,input().split())) i = 0 cnt = 0 while i < n: if p[i] == i+1: cnt = cnt + 1 i = i + 2 else: i = i + 1 # Output print(cnt) " p02661,s236158707,Wrong Answer,"n=int(input()) AB=[list(map(int,input().split())) for _ in range(n)] if n % 2 == 1: mid=(n+1)//2 print(AB[mid-1][1]-AB[mid-1][0]+1) else: mid=n//2 print(AB[mid][1]+AB[mid-1][1]-AB[mid][0]-AB[mid-1][0]+1)" p03962,s735752974,Accepted,"a, b, c = map(int, input().split()) print(len(list(set([a, b, c])))) " p02854,s975683216,Accepted,"n = int(input()) A = [int(x) for x in input().split()] sumA = sum(A) res = sumA cc = 0 for a in A: cc += a res = min(res, abs(sumA - 2 * cc)) print(res) " p03862,s342474310,Wrong Answer,"n,x = map(int,input().split()) a = [int(i) for i in input().split()] ans = 0 for i in range(n-1): if a[i] + a[i+1] <= x: continue a[i+1] = max(0,a[i+1]-x) ans += a[i] + a[i+1] - x print(ans)" p03077,s399359318,Wrong Answer," def main(): n = int(input()) lst = [] for _ in range(5): lst.append(int(input())) m = n ans = 5 for i in range(4): if m // lst[i] > 0: ans += m // lst[i] m = lst[i] print(ans) if __name__ == ""__main__"": main() " p02789,s491087905,Accepted,"N, M = map(int, input().split()) if N == M: print(""Yes"") else: print(""No"")" p02801,s080904717,Accepted,"#!/usr/bin/env python3 #alphabet=[chr(ord('a') + i) for i in range(26)] InputChar=input() print(chr(ord(InputChar)+1)) " p03150,s842102034,Wrong Answer,"def myAnswer(S:str) -> str: for i in range(len(S)-1): for j in range(i+1,len(S)): if(S[:i]+S[j:] == ""keyence""): return ""YES"" return ""NO"" def modelAnswer(): return def main(): S = (input()) print(myAnswer(S)) if __name__ == '__main__': main()" p03319,s718414196,Wrong Answer,"n,k=map(int, input().split()) a=[int(i) for i in input().split()] if n==k: print(1) else: k-=1 print((n+k-1)//k)" p02695,s252697961,Accepted,"import itertools n,m,q = list(map(int,input().split())) a = [0]*q b = [0]*q c = [0]*q d = [0]*q for i in range(q): a[i],b[i],c[i],d[i] = list(map(int,input().split())) b[i]-=1 a[i]-=1 ans=0 for seq in itertools.combinations_with_replacement(range(m),n): tmp = 0 #print(seq) for i in range(q): if seq[b[i]]-seq[a[i]]==c[i]: tmp+=d[i] ans = max(ans,tmp) print(ans)" p03759,s885503240,Accepted,"def main(): a, b, c = map(int, input().split()) cond = b * 2 == a + c print('YES' if cond else 'NO') if __name__ == '__main__': main() " p03544,s986491982,Accepted,"def check(num,memo={}): if num==0: return 2 elif num == 1: return 1 elif num in memo: return memo[num] else: memo[num] = check(num-1,memo) + check(num-2,memo) return memo[num] print(check(int(input())))" p02621,s551620694,Accepted,"a = int(input()) print(a + a ** 2 + a ** 3) " p02888,s152718225,Accepted,"import bisect N = int(input()) A = list(map(int, input().split())) A.sort() ans = 0 for a in range(N-2): for b in range(a+1, N-1): ans += bisect.bisect_left(A, A[a]+A[b])-b-1 print(ans)" p03146,s140109722,Accepted,"s = int(input()) a = [s] ai = s for i in range(2, 10**6 + 2): if ai % 2 == 0: ai = ai/2 if ai in a: print(i) break else: ai = 3*ai + 1 if ai in a: print(i) break a.append(ai)" p03145,s048025114,Accepted,"a,b,c = map(int,input().split()) print(int((a*b)/2))" p03386,s156021920,Accepted," a,b,k = map(int,input().split()) ans = [] for i in range(k): if a + i > b: break ans.append(a+i) #print(ans) for j in range(k): if b-j b: print(min(c - (a - b), 0)) else: print(c)" p02759,s949637710,Accepted,"N=int(input()) a=N%2 if a == 0: print(int(N/2)) else: print(int((N+1)/2))" p03219,s033720018,Wrong Answer,"x,y=map(int,input().split()) print(x+y/2)" p02659,s096745619,Wrong Answer,"a, b = input().split() a = int(a) b = float(b) b_int = int(b) b_float = b - b_int print(a * b_int + int(a * b_float)) " p03719,s517970561,Accepted,"a, b, c = map(int, input().split()) if a <= c <= b: print(""Yes"") else: print(""No"")" p02613,s909513663,Accepted,"test = int(input()) ac = 0 wa = 0 tle = 0 re = 0 for i in range(test): n = input() if n == ""AC"": ac += 1 if n == ""WA"": wa += 1 if n == ""TLE"": tle += 1 if n == ""RE"": re += 1 print(f""AC x {ac}"") print(f""WA x {wa}"") print(f""TLE x {tle}"") print(f""RE x {re}"") " p02723,s848064838,Accepted,"N = input() if N[2] == N[3]: if N[4] == N[5]: print(""Yes"") else: print(""No"") else: print(""No"") " p03657,s875418550,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"")" p03250,s711621518,Accepted,"nums = sorted(map(int, input().split())) print(nums[0] + nums[1] + nums[2]*10)" p02988,s608100692,Accepted,"n, *p = map(int, open(0).read().split()) c = 0 for i in range(2, n): t = p[i-2:i+1] c += sorted(t)[1] == t[1] print(c)" p02912,s054624385,Wrong Answer,"import math import sys from collections import deque import heapq import copy import itertools from itertools import permutations def mi() : return map(int,sys.stdin.readline().split()) def ii() : return int(sys.stdin.readline().rstrip()) def i() : return sys.stdin.readline().rstrip() a,b=mi() l=list(mi()) l=list(map(lambda x: x*-1 , l)) heapq.heapify(l) for i in range(b): s=heapq.heappop(l) s=(-1)*(-1*s)//2 heapq.heappush(l,s) ans=0 for i in range(a): d=heapq.heappop(l) ans+=(-1)*d print(ans)" p03131,s090971220,Accepted,"import sys def input(): return sys.stdin.readline().strip() def mapint(): return map(int, input().split()) sys.setrecursionlimit(10**9) K, A, B = mapint() if (B-A)/2<=1: print(K+1) else: cnt = A rest = K - cnt + 1 if rest<2: print(K+1) else: if rest%2==0: print(cnt+(B-A)*rest//2) else: rest -= 1 cnt += 1 print(cnt+(B-A)*rest//2)" p03103,s454799617,Accepted,"#a値段,b本数 #n軒,m本 n,m = list(map(int, input().split())) ab_list = [list(map(int, input().split())) for _ in range(n)] #print(ab_list) ab_list.sort() ans = 0 num = 0 for ab in ab_list: ans += ab[0]*ab[1] num += ab[1] if num >= m: i_stop=ab_list.index(ab) break diff_num = num - m ans -= diff_num * ab_list[i_stop][0] print(ans)" p02982,s408084609,Accepted,"import math N,D = map(int,input().split()) X = [list(map(int,input().split())) for _ in range(N)] cnt = 0 for i in range(N-1): for j in range(i+1,N): distance = 0 for d in range(D): distance += (X[i][d]-X[j][d])**2 distance = math.sqrt(distance) if(distance == int(distance)): cnt += 1 print(cnt)" p02783,s634969982,Accepted,"import math H, A = map(int, input().split()) # H/A の切り上げ # ceil or (H+A−1)/A の切り捨て print((H+A-1) // A)" p02860,s450876223,Accepted,"N = int(input()) S = input() print(""Yes"" if S[:N//2] == S[N//2:] else ""No"")" p02873,s054054672,Accepted,"S = input() l = len(S) x = [0]*(l+1) y = [0]*(l+1) for i in range(l): if S[i] == ""<"": x[i+1] = x[i]+1 for i in range(l): if S[l-i-1] == "">"": y[l-i-1] = y[l-i]+1 res = 0 for a, b in zip(x, y): res += max(a, b) print(res)" p03695,s078445482,Wrong Answer,"import sys import itertools import copy from collections import defaultdict input = sys.stdin.readline def I(): return int(input()) def MI(): return map(int, input().split()) def LI(): return list(map(int, input().split())) n = I() mylist = [0 for i in range(8)] mylist2 = MI() num = 0 for i in mylist2: temp = i // 400 if temp <= 7: mylist[temp] = 1 else: num += 1 max = sum(mylist) + num if max >= 9: max = 8 min = sum(mylist) if min == 0: min = 1 print(str(min)+ "" ""+ str(max))" p02594,s952313661,Accepted,"# -*- coding: utf-8 -*- def main(): t = int(input()) if t >= 30: print(""Yes"") else: print(""No"") if __name__ == '__main__': main() " p03160,s452121139,Wrong Answer,"import sys sys.setrecursionlimit(200000) n = int(input()) h = [int(i) for i in input().split()] d = {} def dp(cost, p): if p in d: return d[p] if p == n-1: return cost if p < n-2: m = min(dp(cost+abs(h[p]-h[p+1]), p+1), dp(cost+abs(h[p]-h[p+2]), p+2)) d[p] = m return m if p == n-2: return dp(cost+abs(h[p]-h[p+1]), p+1) print(dp(0, 0))" p02720,s732554441,Wrong Answer,"k = int(input()) listA = [1,2,3,4,5,6,7,8,9,10,11,12] # k = int(""1"") n = 1 z = 12 q = k // z mod = k % z if q == 0: print(str(listA[mod - 1])) else: print(str(q + 1)+ str(listA[mod - 1])) # for i in range(k): # print([1,2,3,4,5,6,7,8,9,10,11,12,21,22,23,24,25,26,27,28,29,210,211,212][int(input()) - 1]) " p02779,s394717325,Accepted,"n,*a=map(int,open(0).read().split());print(""YNEOS""[len(a)!=len(set(a))::2])" p03069,s464524105,Wrong Answer,"n = int(input()) S = input() S = S.lstrip('.').rstrip('#') print(min(S.count('.'), S.count('#')))" p03438,s237632658,Accepted,"#!/usr/bin/env python3 # input import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) res = 0 for i in range(n): if a[i] > b[i]: res -= a[i] - b[i] else: res += (b[i] - a[i]) // 2 if res >= 0: print(""Yes"") else: print(""No"") " p02829,s434232665,Wrong Answer,"A=int(input()) B=int(input()) if A==1 and B==2: print(3) elif A==2 and B==3: print(1) elif A==3 and B==1: print(2) elif A==1 and B==3: print(2) elif A==3 and B==1: print(1) else: print(3)" p02600,s809301722,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)" p03163,s725065452,Wrong Answer,"N, W = map(int, input().split()) goods = [] for _ in range(N): goods.append(list(map(int, input().split()))) dp = [[0] * (W + 1) for _ in range(N + 1)] for i in range(1, N + 1): for j in range(goods[i-1][0], W + 1): if j - goods[i - 1][0] >= 0: dp[i][j] = max(dp[i - 1][j - 1], dp[i - 1][j - goods[i - 1][0]] + goods[i - 1][1]) else: dp[i][j] = dp[i - 1][j] # print(dp) print(dp[-1][-1])" p03721,s329715847,Wrong Answer,"import numpy as np N,K = [int(i) for i in input().split()] ab = np.ones([N,2]) ab_sort = ab[np.argsort(ab[:,0])] cout = 0 for i in range(N): cout += ab_sort[i,1] if cout >= K: print(int(ab_sort[i,0])) " p03328,s644877618,Accepted,"a, b = map(int, input().split()) n = b-a print(n*(n+1)//2-b)" p02881,s450832761,Wrong Answer,"N = int(input()) count = 1 while True: count = count + 1 if N % count == 0: tmp = N / count print(int(tmp-1+count-1)) break" p03698,s438898852,Wrong Answer,"S = input() count = len(S) a = 0 for i in range(count): if S[i] in S[i+1:]: a = a+1 else: pass if a>1: print(""no"") else: print(""yes"") " p03695,s636107506,Accepted,"N = int(input()) a = list(map(int,input().split())) b = [a[i]//400 for i in range(N) if a[i] < 3200] c = len(set(b)) print(max(1,c), c+N-len(b))" p02641,s159217361,Accepted,"x,n = map(int,input().split()) pl = list(map(int,input().split())) if n == 0: print(x) exit() for i in range(100): if not x-i in pl: print(x-i) exit() if not x+i in pl: print(x+i) exit()" p03105,s691784164,Wrong Answer,"A, B, C = input().strip().split() A, B, C = [int(A), int(B), int(C)] if B/A < 1: print(0) elif B/A > C: print(C) else: print(B/A)" p04019,s936724859,Wrong Answer,"N = input() if ""N"" in N and ""W"" in N and ""E"" in N and ""S"" in N: print(""Yes"") else: print(""No"")" p03339,s443546233,Accepted,"n = int(input()) s = input() c = ans = s.count(""E"") for i in s: if i=='E': c-=1 else: c+=1 ans = min(c,ans) print(ans)" p02719,s642786853,Accepted,"N, K = map(int, input().split()) print(min([N % K, abs((N % K) - K)])) " p02760,s742992910,Accepted,"import numpy as np a = [] a.append(input().split()) a.append(input().split()) a.append(input().split()) a = np.array(a).astype(int) N = int(input()) for i in range(N): a[a == int(input())] = -1 def check(a): if a.max(axis=0).min() == -1: return ""Yes"" if a.max(axis=1).min() == -1: return ""Yes"" if a[0,0] + a[1,1] + a[2,2] == -3: return ""Yes"" if a[2,0] + a[1,1] + a[0,2] == -3: return ""Yes"" return ""No"" print(check(a))" p03262,s243666737,Wrong Answer,"import fractions n,X= map(int,input().split()) x = list(map(int, input().split())) x.append(X) x = sorted(x) #print(x) difflis = [0] * (n) for i in range(n): difflis[i] = x[i+1] - x[i] ans = difflis[0] for i in range(i,len(difflis)): ans = fractions.gcd(ans,difflis[i]) print(ans)" p03817,s285916891,Wrong Answer,"x = int(input()) if x == 1: print(0) exit() print(((x-1)//11)*2+int(""01111122222""[(x-1)%11]))" p03472,s814548594,Accepted,"import sys N,H=map(int,input().split()) max_swing=0 blist=[] for i in range(N): a,b=map(int,input().split()) max_swing=max(max_swing,a) blist.append(b) throw_list=[] for b in blist: if b>max_swing: throw_list.append(b) throw_list.sort(reverse=True) #print(max_swing,throw_list) answer=0 for t in throw_list: answer+=1 H-=t if H<=0: print(answer) sys.exit(0) #print(answer,H,max_swing) print(answer+(H-1)//max_swing+1)" p02773,s163575142,Accepted,"from collections import Counter def main(): n = int(input()) S = [input() for _ in range(n)] c = Counter(S).most_common() V = c[0][1] ans = [k for k, v in c if v == V] [print(a) for a in sorted(ans)] if __name__ == '__main__': main() " p03862,s148806736,Accepted,"N, x = map(int, input().split()) A = list(map(int, input().split())) ans = 0 for i in range(N - 1): s = A[i] + A[i + 1] - x ans += max(0, s) if s > 0: if s <= A[i + 1]: A[i + 1] -= s else: A[i + 1] = 0 print(ans) " p02947,s180237933,Accepted,"n = int(input()) my_dict = dict() for i in range(n): s = ''.join(sorted(input())) if s in my_dict: my_dict[s] += 1 else: my_dict[s] = 1 ret = 0 for item in my_dict: ret += my_dict[item] * (my_dict[item] - 1) // 2 print(ret) " p02761,s874533871,Accepted,"N, M = map(int, input().split()) sc = [list(map(int, input().split())) for _ in range(M)] ans = [""0""] * N if N > 1: ans[0] = ""1"" rep = {} ok = True for s, c in sc: ans[s-1] = str(c) if s in rep and rep[s] != str(c): ok = False else: rep[s] = str(c) if ok: if ans[0] == ""0"" and N > 1: ok = False print("""".join(ans) if ok else -1)" p02631,s299303526,Accepted,"N = int(input()) A = list(map(int, input().split())) all = A[0] for a in A[1:]: all = all ^ a list_a = [all ^ a for a in A] print(*list_a)" p02993,s359254897,Wrong Answer,"s = input() s1 = set(s) if len(s1) == 4: print('Good') else: print('Bad') " p03803,s594553758,Wrong Answer,"a,b=map(int,input().split()) if a!=1 and b!=1: if a>b: print('Alice') elif a x: print(i) exit() elif dist == x: print(i + 1) exit() print(n + 1) " p04030,s937442902,Accepted,"s = """" for i in (input()): if i in [""0"", ""1""]: s = s + i else: if len(s) >0: s = s[:-1] print(s)" p02691,s563055077,Accepted,"from collections import Counter def main(): n = int(input()) A = list(map(int, input().split())) L = Counter([i + a for i, a in enumerate(A)]) R = Counter([i - a for i, a in enumerate(A)]) ans = 0 for key in R.keys(): ans += L[key] * R[key] print(ans) if __name__ == '__main__': main() " p02553,s919940649,Wrong Answer,"a, b, c, d = map(int, input().split()) x_max = max(a, b) x_min = min(a, b) y_max = max(c, d) y_min = min(c, d) print(max(x_max * y_max, x_max * x_min, x_min * y_max, x_min * y_min))" p02880,s107629354,Accepted,"n = int(input()) for i in range(1,10): for j in range(1,10): if i * j == n: print('Yes') break else: continue break else: print('No')" p02613,s695132624,Wrong Answer,"N=int(input()) AC=0 WA=0 TLE=0 RE=0 for i in range(N): result=input() if result==""AC"": AC+=1 elif result == ""WA"": WA+=1 elif result == ""TLE"": TLE += 1 else: RE+=1 print(""AC x""+str(AC)) print(""WA x""+str(WA)) print(""TLE x""+str(TLE)) print(""RE x""+str(RE))" p02607,s316694986,Wrong Answer,"n = int(input()) z = input().split() odd = 0 for i in range(n): if i % 2 == 1: if int(z[i]) % 2 == 1: odd += 1 print(odd)" p03163,s024884040,Accepted,"n,W = map(int,input().split()) w = [] v = [] for x in range(n): peso,valor = map(int,input().split()) w.append(peso) v.append(valor) dp = [0] * (W+1) for i in range(n): for j in range(W,-1,-1): if j + w[i] <= W: dp[j+w[i]] = max(dp[j+w[i]], dp[j] + v[i]) resposta = 0 for x in dp: resposta = max(x,resposta) print(resposta) " p03796,s353983540,Accepted,"import math n = int(input()) ans = 1 if n > 1: ans = math.factorial(n) % (10**9 + 7) print(int(ans))" p02658,s506757051,Accepted,"n = int(input()) a = list(map(int, input().split())) a.sort() ans = 1 for b in a: if b == 0: ans = 0 break else: ans *= b if ans > pow(10, 18): ans = -1 break print(ans) " p02630,s812767263,Accepted,"n=int(input()) m={} s=0 for i in input().split(): i=int(i) x=m.get(i,0) m[i]=x+1 s+=i q=int(input()) for i in range(q): b,c=[int(i) for i in input().split()] x=m.get(b,0) y=m.get(c,0) m[b]=0 m[c]=x+y s=s-(b*x)+(c*x) print(s) " p02584,s900364671,Accepted,"from sys import exit, stdin # import copy # from collections import deque,Counter # import numpy as np input = stdin.readline X, K, D = map(int, input().split()) if abs(X) >= K * D: print((abs(X) - K * D)) else: A1 = abs(X) % D A2 = abs(A1 - D) n = int((abs(X) - A1)/D) if (K - n) % 2 == 0: print(A1) else: print(A2) " p03565,s742369500,Accepted,"s = input() s = list(s) t = input() ok_num = [] for i in range(len(s) - len(t) + 1): check = True s_part = s[i:i+len(t)] for j in range(len(t)): if s_part[j] != ""?"" and s_part[j] != t[j]: check = False if check == True: ok_num.append(i) if len(ok_num) == 0: print(""UNRESTORABLE"") else: for i in range(len(t)): s[max(ok_num) + i] = t[i] for j in range(len(s)): if s[j] == ""?"": s[j] = ""a"" print("""".join(s)) " p03035,s857805120,Accepted,"A, B = map(int, input().split()) if A >= 13: print(B) elif A >= 6: print(B//2) else: print(0) " p02743,s169643693,Accepted,"from decimal import Decimal, getcontext a,b,c = input().split() getcontext().prec = 10000 a = Decimal(a).sqrt() b = Decimal(b).sqrt() c = Decimal(c).sqrt() if a+b+Decimal('0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001') < c: print('Yes') else: print('No') " p03557,s516078886,Wrong Answer,"inp=lambda:list(map(int,input().split())) import bisect as bi n=int(input()) a=inp() b=inp() c=inp() ans=0 for i in range(n): x=bi.bisect_left(a,b[i]) y=n-bi.bisect_right(c,b[i]) ans+=x*y print(ans) " p03472,s709997519,Accepted,"from math import ceil n, h = map(int, input().split()) ab = [list(map(int, input().split())) for _ in range(n)] a, b =[], [] for A, B in ab: a.append(A) b.append(B) a=sorted(a,reverse=True) b=sorted(b,reverse=True) ans = 0 c = 0 i = 0 while c < h: if i == n: break ans += 1 if a[0] < b[i]: c += b[i] else: c += a[0] break i += 1 if c < h: ans += ceil((h - c)/ a[0]) print(ans)" p03408,s269025177,Accepted,"import collections n = int(input()) s = [str(input()) for _ in range(n)] m = int(input()) t = [str(input()) for _ in range(m)] s,t = collections.Counter(s), collections.Counter(t) ans = 0 for i in s.most_common(): ans = max(ans, i[1] - t[i[0]]) print(ans)" p03339,s473247530,Accepted,"import math n = int(input()) s = input() eS = [0] * n wS = [0] * n ec = 0 for i in range(n): eS[i] = ec if s[i] == ""W"": ec += 1 wc = 0 for i in reversed(range(n)): wS[i] = wc if s[i] == ""E"": wc += 1 ans = 10000000 for i in range(n): ans = min(ans, eS[i] + wS[i]) print(ans) " p03041,s866064528,Accepted,"n,k = map(int,input().split()) s = list(input()) s[k-1] = chr(ord(s[k-1])+32) print(*s,sep="""")" p03435,s099471422,Accepted,"C = [list(map(int, input().split())) for i in range(3)] a1 = 0 b1 = C[0][0] - a1 b2 = C[0][1] - a1 b3 = C[0][2] - a1 a2 = C[1][1] - b2 a3 = C[2][2] - b3 As = [a1, a2, a3] Bs = [b1, b2, b3] for i in range(3): for j in range(3): if C[i][j] != As[i] + Bs[j]: print(""No"") exit() print(""Yes"")" p02779,s736627345,Accepted,"import sys input = sys.stdin.readline N = int(input()) A = list(map(int, input().split())) check = set(A) if len(check) == N: print('YES') else: print('NO') " p03971,s019740977,Accepted,"n,a,b = map(int,input().split()) S = input() passed = 0 f_passed = 0 for s in S: if s == ""a"": if passed < a + b: print(""Yes"") passed += 1 else: print(""No"") elif s == ""b"": if passed < a + b and f_passed + 1 <= b: print(""Yes"") passed += 1 f_passed += 1 else: print(""No"") else: print(""No"") " p02860,s144097365,Accepted,"# n = int(input()) s = input() if s[:int(n/2)] == s[int(n/2):]: print(""Yes"") else: print(""No"") " p02848,s367334718,Accepted,"n = int(input()) s = input() ans = """" for c in s: ascii = ord(c) + n if ascii > ord('Z'): ascii -= 26 ans += chr(ascii) print(ans)" p02814,s584518028,Accepted,"from math import gcd, ceil from functools import reduce import sys def lcm_base(x, y): return (x * y) // gcd(x, y) def lcm_list(numbers): return reduce(lcm_base, numbers, 1) N, M = map(int, input().split()) a = [int(i)//2 for i in input().split()] s = set() for x in a: cur = 0 y = x while y%2 == 0: cur += 1 y //= 2 s.add(cur) if len(s) >= 2: print(0) sys.exit() lcm = lcm_list(a) print((M//lcm+1)//2)" p03803,s252593909,Accepted,"a,b=map(int,input().split()) if a==b : print(""Draw"") elif (b==1 or a 0: for _ in range(N): print('Yes') else: l = [] for i,v in dict(c).items(): if v >(Q - K): l.append(i-1) else: break for j in range(N): if j in l: print('Yes') # l.pop() else: print('No')" p02729,s317141273,Wrong Answer,"M,N=map(int,input().split()) print(M//2+N)" p03038,s961040530,Accepted,"n, m = map(int, input().split()) a = [int(i) for i in input().split()] a = sorted(a) l = [] for i in range(m): l.append(list(map(int, input().split()))) l = sorted(l, reverse=True, key=lambda x: x[1]) b = [] for _ in range(n): b.append(l[0][1]) l[0][0] -= 1 if l[0][0] == 0: l.pop(0) if l == []: break for i in range(len(b)): if a[i] < b[i]: a[i] = b[i] else: break print(sum(a)) " p02677,s657028177,Wrong Answer,"# -*- coding: utf-8 -*- import math a, b, h, m = map(int, input().split()) theta_a = math.pi * float(h + m / 60) / float(6) theta_b = math.pi * float(m) / float(30) theta = theta_a - theta_b print(theta) if theta > math.pi or theta < 0: theta = theta_b - theta_a square_l = - float(2) * math.cos(theta) * float(a*b) + a * a + b * b print(math.sqrt(square_l)) " p02768,s943709635,Accepted,"import sys input = sys.stdin.readline def main(): mod = 10**9+7 n,a,b=map(int,input().split()) f=1 fa=0 for i in range(1,b+1): f=(f*(n-i+1)*pow(i,mod-2,mod))%mod if i==a: fa=f ans=(pow(2,n,mod)-fa-f-1)%mod print(ans) if __name__ == '__main__': main()" p03146,s191052425,Wrong Answer,"s = int(input()) def collatz(n): if n % 2 == 0: return n/2 else: return 3*n+1 a = [] a.append(s) for i in range(100): tmp = collatz(a[i]) if tmp in a: print(len(a)+1) exit() a.append(tmp)" p02747,s056713871,Wrong Answer,"def resolve(): S = input() c = list(S) if len(c) <= 1: print('No') return if len(c) == 2 and S != 'hi': print('No') return for i in range(0, len(c) - 2, 2): if ''.join(c[i:i + 2]) != 'hi': print('No') return print('Yes') resolve()" p03544,s099926779,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]) " p03438,s448318433,Accepted,"N = int(input()) a = list(map(int,input().split())) b = list(map(int,input().split())) excess = 0 for i in range(N): dif = a[i]-b[i] if dif < 0: excess += abs(dif)//2 elif 0 < dif: excess -= dif if 0<=excess: print(""Yes"") else: print(""No"")" p02640,s950050815,Wrong Answer,"a, b = map(int, input().split()) y = (b-2*a)//2 x = a-y if y < 0 or x < 0: print(""No"") else: print(""Yes"")" p02817,s662451077,Accepted,"S, T = input().split() print(T+S)" p03160,s259048144,Accepted,"n=int(input()) arr=[int(i) for i in input().split()] dp=[0]*(n) dp[0]=0 dp[1]=abs(arr[1]-arr[0]) for i in range(2,n): dp[i]=min(abs(arr[i]-arr[i-1])+dp[i-1],abs(arr[i]-arr[i-2])+dp[i-2]) print(dp[-1])" p03351,s916559084,Accepted,"a, b, c, d = list(map(int, input().split())) if abs(c - a) <= d or (abs(c - b) <= d and abs(b - a) <= d): print(""Yes"") else: print(""No"") " p03494,s630218626,Accepted,"n = input() A = list(map(int,input().split())) count = 0 while all(a%2 == 0 for a in A): count += 1 A = [a/2 for a in A] print(count) " p03345,s650308906,Wrong Answer,"a,b,c,k = map(int,input().split()) tmp = abs(a - b) if tmp >= k: print(""Unfair"") elif k % 2 == 0: print(a - b) else: print(b - a) " p03943,s371197519,Wrong Answer,"a,b,c = map(int,input().split()) if a+b+c % 2 == 0: print(""Yes"") else: print(""No"")" p03545,s254904519,Wrong Answer,"s = str(input()) n = 4 for bit in range(1 << n): f = '0' for i in range(0,n): if bit & (1 << i): f += '+-' + s[i] else: f += '+' + s[i] #print(f) ans = sum(map(int,f.split('+'))) if ans == 7: f = f.replace('+-','-',4) break if f[:2] == '0+': print(f[2:] + '=7') else: print(f[1:] + '=7') " p03472,s034805371,Wrong Answer," n,h=map(int,input().split()) X=[] for i in range(n): a,b=map(int,input().split()) X.append([a,-b]) X.sort(key=lambda x:(x[0],x[1]),reverse=True) print(X) cnt=0 for i in range(n): if X[i][1]<=X[0][1]: h+=X[i][1] cnt+=1 if h<=0: break if h>0: cnt+=h//X[0][0] print(cnt)" p03835,s269933546,Accepted,"k,s=map(int,input().split()) ans=0 for i in range(k+1): for j in range(k+1): z=s-i-j if 0<=z<=k: ans+=1 print(ans)" p03637,s061465905,Accepted,"n=int(input()) a=list(map(int,input().split())) nn=[0,0,0] for i,v in enumerate(a): tmp=0 while v%2==0: v//=2 tmp+=1 nn[min(tmp,2)]+=1 if nn[1]: if nn[0]>(n-nn[1])//2: print(""No"") else: print(""Yes"") else: if nn[0]>(n+1)//2: print(""No"") else: print(""Yes"")" p02933,s290098090,Wrong Answer,"a = int(input()) input_s = input() if 3200 <= a <5000: output_s = (""s"") elif 2800 <= a <3200: output_s = (""red"") print(output_s)" p03767,s908185404,Wrong Answer,"n = int(input()) a = sorted(list(map(int,input().split()))) sum_a = 0 for i in range(n): sum_a += a[len(a)//2-1+i] print(sum_a)" p02989,s944474923,Accepted,"def count_up(d, cut): ARC = len([1 for i in d if i >= cut]) ABC = len(d) - ARC if ABC == ARC: return True return False N = int(input()) d = list(map(int, input().split())) d.sort() print(d[N//2] - d[N//2 - 1])" p02658,s218524843,Wrong Answer,"input() a=1 b=map(int,input().split()) for i in b: a*=i if a>10**18: a=-1 break print(a)" p03449,s815308190,Accepted,"n=int(input()) a1=list(map(int,input().split())) a2=list(map(int,input().split())) ans=0 for i in range(n): top=sum(a1[:i+1]) bottom=sum(a2[i:]) tmp=top+bottom ans=max(tmp,ans) print(ans)" p02718,s643602162,Accepted,"N, M = map(int, input().split()) A = list(map(int, input().split())) total = sum(A) least = total * (1 / (4 * M)) count = 0 for a in A: if a >= least: count += 1 if count >= M: print('Yes') else: print('No') " p04031,s755555732,Wrong Answer,"n = int(input()) lst = [abs(int(i)) for i in input().split()] r = 100 ** 2 if len(set(lst)) == 1: print(0) exit() for i in range(max(lst)): temp = 0 for j in lst: temp += (i - j) ** 2 if temp < r: r = temp print(r)" p03720,s776753588,Accepted,"def pathnumber(N, M) : path = [0] * (N + 1) for i in range(M) : x, y = tuple(map(int, input().split())) path[x] += 1 path[y] += 1 return path N, M = tuple(map(int, input().split())) path = pathnumber(N, M) for i in range(1, N + 1) : print(path[i]) " p03000,s612253383,Wrong Answer,"N, X = map(int,input().split()) L = list(map(int,input().split())) D = list() D.append(0) count = 1 for i in range(1,N): Dplus=D[i-1]+L[i-1] D.append(Dplus) #print(D[i]) if D[i]<=X: count+=1 else: break print(count)" p02629,s903314745,Wrong Answer,"OFFSET = 96 def main(): n = int(input()) ans = [] while n!=0: n,mod = divmod(n,26) ans.append(chr(mod+OFFSET)) print(''.join(ans)[::-1]) return if __name__ == '__main__': main()" p02911,s412822087,Wrong Answer,"from collections import Counter n,k,q = map(int, input().split()) a = [int(input()) for _ in range(q)] ans = [""No""] * n for key,val in Counter(a).items(): if val + k - q > 0: ans[key-1] = ""Yes"" [print(i) for i in ans];" p02658,s049580681,Accepted,"import sys N = int(input()) A = list(map(int, input().split())) m = 1 if 0 in A: print(0) sys.exit() for item in A: m *= item if m > 10 ** 18: print(""-1"") sys.exit() print(m)" p03778,s444712315,Accepted,"#import itertools #import fractions #import numpy as np #mod = 10**4 + 7 """"""def kiri(n,m): r_ = n / m if (r_ - (n // m)) > 0: return (n//m) + 1 else: return (n//m)"""""" # Written by NoKnowledgeGG @YlePhan #import math mod = 10**9+7 def main(): w,a,b = map(int,input().split()) if a > b: a,b = b,a if a+w >=b: print(0) else: print(abs(a+w-b)) if __name__ == '__main__': main()" p03778,s360885862,Accepted,"w, a, b = map(int, input().split()) if a + w < b: print(b - a- w) elif b + w < a: print(a - b - w) else: print(0)" p03095,s082342279,Accepted,"n=int(input()) s=input() l=[1 for i in range(26)] for i in range(n): l[ord(s[i])-ord(""a"")]+=1 pr=1 for i in range(26): pr=pr*l[i] pr=pr%(10**9+7) print(pr-1)" p02711,s799777227,Accepted,"line = str(input()) if ""7"" in line: print(""Yes"") else: print(""No"")" p02615,s543857886,Wrong Answer,"#!python3 import sys iim = lambda: map(int, sys.stdin.readline().rstrip().split()) def resolve(): it = map(int, sys.stdin.read().split()) N = next(it) A = list(it) A.sort() if N ==2: print(A[-1]) return print(sum(A)-A[0]-A[1]+A[-2]) if __name__ == ""__main__"": resolve() " p03126,s212504202,Accepted,"n, m = map(int, input().split()) x = [0]*m for i in range(n): a = list(map(int, input().split())) for b in a[1:]: x[b-1] += 1 print(x.count(n)) " p03061,s463196171,Accepted,"from math import gcd from functools import reduce def gcd_list(numbers): return reduce(gcd, numbers) N = int(input()) A = list(map(int,input().split())) X = [0]*N Y = [0]*N X[0] = A[0] Y[-1] = A[-1] ans = [0]*N for i in range(1,N): X[i] = gcd(X[i-1],A[i]) Y[N-i-1] = gcd(Y[N-i],A[N-i-1]) for i in range(1,N-1): ans[i] = gcd(X[i-1],Y[i+1]) ans[0],ans[-1] = gcd_list(A[1:]),gcd_list(A[:-1]) print(max(ans))" p02860,s769673775,Accepted,"n = int(input()) s = input() if n % 2 == 0: if s[0:n//2] == s[n//2:]: print('Yes') else: print('No') else: print('No')" p03067,s345674297,Wrong Answer,"a,b,c = map(int,input().split()) if anum[i]+num[i-1]: ans=num[i] else: ans=num[i-1] print(num[-1],ans) if __name__=='__main__': main()" p02912,s288973014,Accepted,"n,m=map(int, input().split()) a=[int(x) for x in input().split()] a=[-1*x for x in a] import heapq heapq.heapify(a) for i in range(m): max_value = heapq.heappop(a) #最大値の取得 heapq.heappush(a, (max_value/2)) #半額にして-1倍してからキューに戻す a=[-1*x for x in a] a=[int(x) for x in a] print(sum(a))" p03136,s304016219,Wrong Answer,"N = int(input()) li = list(map(int, input().split())) li.sort() sum = 0 for i in li[:-2]: sum = i + sum Nmax = li[-1] if N <= 2 or li[0] < 1: print(""No"") elif Nmax >= sum: print(""No"") else: print(""Yes"") " p03438,s343534006,Accepted,"n = int(input()) A = list(map(int,input().split())) B = list(map(int,input().split())) k = sum(B)-sum(A) cb = sum([a-b for b,a in zip(B,A) if ba]) if ca<=k and cb<= k: print('Yes') else: print('No')" p02847,s192276280,Accepted,"import sys import math import itertools import bisect from copy import copy from collections import deque,Counter from decimal import Decimal import functools 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) sys.setrecursionlimit(10 ** 9) mod = 10**9+7 cnt = 0 ans = 0 inf = float(""inf"") s = s() a = [""SAT"", ""FRI"", ""THU"",""WED"",""TUE"",""MON"",""SUN""] x = a.index(s) + 1 print(x) " p03774,s332501380,Accepted,"n,m = map(int,input().split()) stu = [list(map(int,input().split())) for _ in range(n)] che = [list(map(int,input().split())) for _ in range(m)] ans = [] for i in range(n): x = 10**9 for j in range(m): man = abs(stu[i][0] - che[j][0]) + abs(stu[i][1] - che[j][1]) if man < x: c_num = j + 1 x = man ans.append(c_num) for k in ans: print(k)" p03037,s010912092,Accepted,"L = [] R = [] N, M = map(int, input().split()) for _ in range(M): l, r = map(int, input().split()) L.append(l) R.append(r) if max(L) <= min(R): print(min(R) - max(L) + 1) else: print(0) " p03720,s445553706,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])" p02911,s025377153,Accepted,"from collections import deque n,k,q=map(int,input().split()) a=deque([k-q]*n) for i in range(q): point=int(input()) a[point-1] += 1 for _ in range(len(a)): if a.popleft() > 0: print(""Yes"") else: print(""No"")" p02899,s423619587,Accepted,"n = int(input()) a = list(map(int,input().split())) b = [0] * n for i,data in enumerate(a): b[data-1] = str(i+1) print(' '.join(b))" p03243,s414084155,Accepted,"n = int(input()) for i in range(n,1000): s = list(str(i)) if s[0] == s[1] == s[2]: break print(i)" p02693,s456324576,Accepted,"K=int(input()) A,B=map(int,input().split()) result=0 for i in range(1000): tmp=K*i if A<=tmp<=B: result=1 break if tmp>B: break if result==1: print(""OK"") else: print(""NG"")" p02623,s889044841,Accepted,"from sys import stdin from sys import setrecursionlimit from itertools import accumulate import bisect n,m,k = map(int,stdin.readline().rstrip().split()) a = list(map(int,stdin.readline().rstrip().split())) b = list(map(int,stdin.readline().rstrip().split())) aa = [0]+list(accumulate(a)) bb = [0]+list(accumulate(b)) ma = 0 for i,j in enumerate(aa): if j > k: break nowa = i nowb = bisect.bisect(bb,k-j)-1 ma = max(ma,nowa+nowb) print(ma)" p03673,s221098737,Accepted,"n,a=int(input()),list(map(int,input().split())) print(*[a[1::2][::-1]+a[::2],a[::2][::-1]+a[1::2]][n%2],sep=' ')" p02628,s540057670,Accepted,"n,k = map(int,input().split()) a = list(map(int,input().split())) a.sort() print(sum(a[:k]))" p03767,s556545841,Accepted,"si = lambda: input().strip() ii = lambda: int(input()) mii = lambda: map(int, input().split()) lmii = lambda: list(map(int, input().split())) smii = lambda: sorted(map(int, input().split())) N = ii() A = smii() ans = 0 for i in range(N, N * 3, 2): ans += A[i] print(ans) " p02777,s160466737,Accepted,"S,T = map(str,input().split()) A,B = map(int,input().split()) U = input() if S == U: A -= 1 else: B -= 1 print(A,B)" p03210,s224089697,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 = [input() for _ in range(n)] x = int(input()) if x == 3 or x == 5 or x == 7: print(""YES"") else: print(""NO"") " p02939,s617686314,Accepted,"import sys readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines read = sys.stdin.buffer.read sys.setrecursionlimit(10 ** 7) INF = float('inf') S = input() last = """" tmp = """" ans = 0 for s in S: tmp += s if tmp == last: continue # print(tmp) last = tmp tmp = """" ans += 1 print(ans)" p03719,s697242576,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 main(): a,b,c=MI() if a<=c<=b:print(""Yes"") else:print(""No"") main()" p03107,s271546136,Accepted,"from collections import Counter s = input() S = [int(x) for x in list(str(s))] if sum(S) == 0 or sum(S) == len(S)*1: print(0) else: cnt = Counter(s) v = cnt.values() print(min(v)*2) " p02831,s617140699,Wrong Answer,"# -*- coding: utf-8 -*- """""" A, B = map(float, input().split()) y = False z = 1 while y == False: if z % A != 0 or z % B != 0: z += 1 else: y = True print(z) """""" A, B = map(int, input().split()) if A > B: a = A b = B else: a = B b = A for i in range(1,b): if float(a * i) % float(b) == 0: print(a * i) break " p03127,s698776938,Accepted,"n = int(input()) a = list(map(int, input().split())) while len(a) > 1: m = min(a) a = [a[i]%m for i in range(len(a)) if a[i]%m > 0] a.append(m) print(m) " p03759,s361915157,Accepted,"a,b,c=map(int,input().split()) if b-a==c-b: print(""YES"") else: print(""NO"")" p02879,s831202502,Accepted,"numbers = input().split() numA = int(numbers[0]) numB = int(numbers[1]) if numA <= 9 and numB <= 9: print(numA * numB) else: print(-1)" p03293,s095827866,Accepted,"S = input() T = input() for i in range(len(S)): S = S[1:] + S[0] if T == S: print('Yes') exit(0) print('No')" p04043,s655138448,Accepted,"a=list((input())) print('YES' if a.count(('5'))==2 and a.count(('7'))==1 else 'NO')" p03814,s369132235,Wrong Answer,"s = input() print((s.index('A')+s[s.index('A'):].index('Z')) - s.index('A') + 1)" p02866,s299337158,Accepted,"n=int(input()) d=list(map(int,input().split())) mx=max(d) l=[0]*(10**5) mx=0 for i in range(n): if (i==0 and d[i]!=0) or (i!=0 and d[i]==0): print(0) exit() l[d[i]]+=1 mx=max(mx,d[i]) t=1 ans=1 for i in range(1,mx+1): ans *= t**l[i] t=l[i] print(ans%998244353)" p02723,s397789469,Accepted,"s = input() if s[2] == s[3] and s[4] == s[5]: print('Yes') else: print('No')" p02601,s803080202,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,b,c=MI() K=I() cnt=0 while b<=a: b*=2 cnt+=1 while c<=b: c*=2 cnt+=1 if cnt<=K: print(""Yes"") else: print(""No"") main() " p03544,s374104556,Wrong Answer,"N = int(input()) L = [2,1] if N < 3: ans = L[N-1] else: old_L = L[0] new_L = L[1] for _ in range(1, N): tmp = old_L + new_L old_L = new_L new_L = tmp ans = new_L print(ans) " p02708,s726064392,Accepted,"from math import ceil N, K = [int(i) for i in input().split()] mod = 10 ** 9 + 7 ans = 0 n = m = 0 for i in range(1, N + 2): n += N + 1 - i m += i - 1 if i >= K: ans += n - m + 1 ans %= mod print(ans)" p02819,s576889224,Wrong Answer,"X= int(input()) #素因数分解。 pf={} m=X for j in range(0,1000): 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 #print(pf) if (len(pf)==1) and (list(pf.values())[0]==1): #print(m) break else: m =m+1 print(m) " p02802,s945480424,Accepted,"N,M = map(int,input().split()) ac,wa = 0,0 was = [0]*(N+1) acs = [0]*(N+1) for i in range(M): p,S = input().split() p = int(p) if S==""AC"": if acs[p]==0: ac+=1 wa+=was[p] acs[p]=1 else: was[p] += 1 print(ac,wa)" p03264,s948644995,Accepted,"k=int(input()) if k%2==0: print((k//2)**2) else: print((k//2)*(k//2+1))" p04012,s599577051,Accepted,"a =list(input()) from collections import Counter a=Counter(a) for i in a.items(): if i[1]%2 != 0: print('No') exit() print('Yes')" p02578,s144797151,Accepted,"n = int(input()) nums = list(map(int, input().split())) ans = 0 maximum = 0 for num in nums: maximum = max(maximum, num) ans += maximum - num print(ans) " p03107,s163504156,Accepted,"s = input() a,b = 0,0 for i in range(len(s)): if s[i] == '0': a += 1 else: b += 1 if a == 0 or b == 0: print(0) else: print(min(a,b)*2)" p04029,s598948556,Accepted,"N = int(input()) # N人目にN個のキャンディーをあげる際に必要なキャンディーの合計数の式 # 等差級数の和 をxとする x = ( N * ( N + 1 )) // 2 print(x)" p02831,s667789365,Accepted,"def gcd(a, b): if a < b: return gcd(b, a) while b > 0: a, b = b, a % b return a a, b = map(int, input().split()) print(a*b//gcd(a, b))" p02641,s813117350,Wrong Answer,"x, n = map(int, input().split()) if n == 0: print(x) else: p = list(map(int, input().split())) p.sort() p1 = {i for i in range(p[-1])} p = set(p) p2 = p1 - p p2 = list(p2) absv = x for i in range(len(p2)): if absv > abs(x - p2[i]): absv = abs(x - p2[i]) print(x - absv)" p03944,s792540508,Wrong Answer,"w,h,n = map(int,input().split()) lists = [list(map(int,input().split())) for i in range(n)] plx = 0 ply = 0 prx = w pry = h for x,y,a in lists: if a == 1: plx = x elif a == 2: prx = x elif a == 3: ply = y elif a == 4: pry = y px = (prx - plx) py = (pry - ply) ans = px * py if ans <= 0: ans = 0 print(ans)" p03359,s394240328,Accepted,"a,b=map(int,input().split()) ans=a-1 if a<=b: print(a) else: print(a-1)" p03862,s078074661,Accepted,"N,x=map(int,input().split()) a=list(map(int,input().split())) ans=0 for i in range(1,N): tmp=a[i-1]+a[i] if tmp>x: ans+=tmp-x if a[i]>=tmp-x: a[i]-=tmp-x else: a[i]=0 print(ans) " p02970,s220661337,Accepted,"import sys a=sys.stdin.readline() res=[i for i in a.split()] r1,r2=float(res[0]),float(res[1]) v1,v2=r1.is_integer(),r2.is_integer() if v1==v2==True: N,D=int(r1),int(r2) if 1<=(N and D)<=20: w=2*D+1 print(int((N+w-1)//w))" p02873,s493561726,Accepted,"S = input() ans = [0] * (len(S)+1) for i in range(len(S)): if S[i] == ""<"": ans[i+1] = ans[i]+1 # print(ans) for i in range(len(S)): if S[len(S)-i-1] == "">"": ans[len(S)-i-1] = max(ans[len(S)-i-1], ans[len(S)-i]+1) # print(ans) print(sum(ans)) " p02729,s046678641,Wrong Answer,"N, M = map(int, input().split()) ans = ((N * (N - 1)) / 2) + ((M * (M - 1)) / 2) print(ans)" p03632,s843821463,Accepted," import numpy as np a,b,c,d=map(int,input().split()) print(max(0,min(b,d)-max(a,c)))" p02947,s696026241,Wrong Answer,"N = int(input()) C = [] for i in range(N): C.append("""".join(sorted(input(i)))) B = set(C) ans = 0 for j in B: t = C.count(j) if t > 1: ans += int(t*(t-1)/2 ) # 1->0, 2->1, 3->3, 4->6, 5->10 :: nC2 print(ans)" p02783,s160938937,Accepted,"h, a = map(int,input().split()) if h%a==0: print(h//a) else: print(h//a+1)" p02766,s992991327,Accepted,"N, K = 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, K)))" p03854,s904643007,Wrong Answer,"s=input() f=0 l=['dream' ,'dreamer', 'erase','eraser'] while(f==0): if(s[:7] in l): s=s[7:] elif(s[:6] in l): s=s[6:] elif(s[:5] in l): s=s[5:] else: f=1 break if(len(s)==0): print(""YES"") else: print(""NO"") " p03137,s982717059,Accepted,"# coding: utf-8 import sys import numpy as np sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) N, M = lr() X = np.array(lr()) X.sort() if N >= M: print(0); exit() Xdiff = np.abs(np.diff(X)) Xdiff.sort() need = M - N answer = Xdiff[:need].sum() print(answer) " p03067,s474280422,Accepted,"# import math # import statistics # a=input() #b,c=int(input()),int(input()) # c=[] # for i in a: # c.append(i) e1,e2,e3 = map(int,input().split()) #f = list(map(int,input().split())) #g = [input() for _ in range(a)] # h = [] # for i in range(e1): # h.append(list(map(int,input().split()))) if e1<=e3<=e2 or e2<=e3<=e1: print(""Yes"") else: print(""No"")" p03494,s169950204,Wrong Answer,"n = int(input()) a = list(map(int, input().split())) for i in range(100): c = [i for i in a if i % 2 == 0] if(len(c) != n): break print(i)" p02693,s204483173,Wrong Answer,"K=int(input()) [A,B]=list(map(int,input().split())) flg=0 for n in range(A,B+1): if n%K==0: print(""OK"") flg==1 break if flg==0:print(""NG"") " p02888,s495849322,Wrong Answer,"#!/usr/bin/env python3 import collections import itertools as it import math #import numpy as np # = input() n = int(input()) # = map(int, input().split()) l = list(map(int, input().split())) # = [int(input()) for i in range(N)] # # c = collections.Counter() l = sorted(l)[::-1] ans = 0 for i1 in range(len(l)-2): a = l[i1] for i2 in range(i1+1, len(l)-1): b = l[i2] l_ = [l[i3] for i3 in range(i2+1, len(l[i2+1:]))] print(ans) " p02882,s819798996,Accepted,"import math a, b, x = map(int, input().split()) if x > a * a * b / 2: theta = math.degrees(math.atan(2 * (b - x / (a ** 2)) / a)) else: theta = 90 - math.degrees(math.atan((2 * x) / (a * b * b))) print(theta)" p02659,s720683077,Accepted,"A, B = input().split(' ') Bt = B[0]+B[2]+B[3] Bt = int(Bt) ans1=int(A)*int(Bt) print(ans1//100) " p02795,s377139378,Accepted,"h = int(input()) w = int(input()) n = int(input()) num = n//max(h,w) if (n//max(h,w)+1)==n else (n//max(h,w)+1) if (n%max(h,w)==0): print((n//max(h,w))) else: print((n//max(h,w)+1))" p02627,s115243749,Accepted,"def main(): a = input() if a.isupper(): print(""A"") else: print(""a"") if __name__ == '__main__': main()" p02723,s623550327,Accepted,"S=input() if S[2]==S[3] and S[4]==S[5]: print('Yes') else: print('No')" p02730,s066049628,Accepted,"s = input() n = int(len(s)) n1 = int ( (n - 1 ) / 2 ) n2 = int ( (n + 1 ) / 2 ) s1 = s[0:n1] s2 = s[n2:n] def if_kai( st ): ret = True nn = len(st) nn1 = int ( (nn - 1 ) / 2 ) for i in range(nn1+1): if st[i] != st[nn-i-1] : ret = False break return ret if if_kai( s ) and if_kai( s1 ) and if_kai( s2 ) : print('Yes') else: print('No') " p02708,s893554182,Accepted,"n, k = map(int, input().split()) MOD = 10**9+7 ans = 0 for i in range(k, n+2): ll = 0 lr = i - 1 rl = n-(i-1) rr = n lsum = lr*(lr+1)//2 - ll*(ll+1)//2 rsum = rr*(rr+1)//2 - rl*(rl-1)//2 ans += rsum - lsum + 1 ans %= MOD #print(rsum, lsum) print(ans)" p02972,s986033626,Accepted,"n=int(input()) a=list(map(lambda x:int(x)%2,input().split())) ans=[0]*n for i in range(n,0,-1): b=n//i c=0 for j in range(1,b+1): c+=ans[j*i-1] if (c-a[i-1])%2==1: ans[i-1]=1 print(sum(ans)) ans1=[] for i,v in enumerate(ans): if v==1: ans1.append(i+1) if len(ans1)>0: print(' '.join(map(str,ans1))) " p03797,s179678193,Accepted,"s,c = map(int,input().split()) if c-2*s >= 0: print(s + (c-2*s)//4) else: print(c//2)" p03377,s307990054,Accepted,"import sys input = sys.stdin.readline a,b,x=map(int,input().split()) print(""YES"" if a<=x<=a+b else ""NO"") " p03696,s273886054,Accepted,"n = int(input()) s = input() d = [0]*(n+1) for i in range(1, n+1): d[i] = s[:i].count('(') - s[:i].count(')') x = min(d) s = '('*(-x) + s + ')'*(d[n]-x) print(s)" p03106,s235270986,Accepted,"import sys input = lambda: sys.stdin.readline().rstrip() def main(): a, b, k = map(int, input().split()) cnt = 0 for i in range(min(a,b), 0, -1): if a%i==0 and b%i==0: cnt += 1 if cnt == k: print(i) return if __name__ == '__main__': main()" p03779,s636845585,Accepted,"import math def myAnswer(X:int) -> int: return def modelAnswer(X:int) -> int: return math.ceil(((-1 + (8*X +1)**0.5)/2)) def main(): X = int(input()) print(modelAnswer(X)) if __name__ == '__main__': main()" p02602,s011374978,Accepted,"#!/usr/bin/env python3 import sys input = sys.stdin.readline n, k = map(int, input().split()) a = [int(item) for item in input().split()] for a1, a2 in zip(a, a[k:]): if a1 < a2: print(""Yes"") else: print(""No"")" p03163,s527511364,Accepted,"import numpy as np def main(): N,W = map(int,input().split()) w,v = [],[] for _ in range(N): w_,v_ = map(int,input().split()) w.append(w_) v.append(v_) dp = np.zeros((N+1,W+1),dtype=np.int64) for i in range(N): tmp = np.zeros(W+1,dtype=int) tmp[w[i]:] = dp[i][:-w[i]] + v[i] dp[i+1] = np.maximum(dp[i],tmp) print(dp[N][W]) main()" p03162,s630353187,Wrong Answer,"x=int(input()) count=0 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) " p02578,s058011483,Accepted,"number = int(input()) tall = list(map(int, input().split())) addition = 0 for each in range(1, number): difference = tall[each - 1] - tall[each] if difference >= 0: addition += difference tall[each] += difference print(addition)" p03759,s438383042,Wrong Answer,"a, b, c = map(int, input().split()) print('Yes' if (b - a) == (c - b) else 'No')" p03479,s637482556,Accepted,"x,y=map(int,input().split()) k=x cnt = 0 while k<=y: k*=2 cnt+=1 print(cnt)" p02952,s428846703,Wrong Answer,"n = input() if len(n) == 6: print(90909) if len(n) == 5: print(909 + int(n) - 9999) if len(n) == 4: print(909) if len(n) == 3: print(9 + int(n) - 99) if len(n) == 2: print(9) else: print(int(n))" p03210,s366872849,Accepted,"if int(input()) in (3,5,7): print(""YES"") else: print(""NO"")" p02607,s352095935,Wrong Answer,"N = int(input()) l = [ int(x) for x in input().split()] def oddProblem(l): count = 0 for i in range(N): if (l[i] % 2 != 0 and i % 2 != 0): count += 1 return count print(oddProblem(l)) " p02755,s123151888,Accepted,"A,B = map(int,input().split()) for x in range(1,10001): if (0.1*x)//1 == B and (0.08*x)//1 == A: print(x) exit(0) print(-1)" p02791,s917947085,Accepted,"N=int(input()) P=list(map(int,input().split())) ans=0 mini=10**6 for p in P: if p<=mini: mini=p ans+=1 print(ans)" p03360,s366428932,Accepted,"a=sorted(map(int,input().split())) k=int(input()) print(a[0]+a[1]+a[2]*2**k)" p03289,s582419395,Accepted,"s = str(input()) flag = 0 C_count = 0 flag_2 = 0 mode = 0 a = 0 b = 0 c = 0 k = [""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""] if s[0] == ""A"": a += 1 for i in s[2:-1]: if i == ""C"": C_count += 1 if C_count == 1: b += 1 l = s[1:] l = l.replace(""C"","""") if l.islower() == True: c += 1 if a == 1 and b == 1 and c == 1: print(""AC"") else: print(""WA"")" p02578,s235648335,Accepted,"N = int(input()) ARR = list(map(int,input().split())) def calculate(n, arr): currentHeight = arr[0] result = 0 for i in range(1,n): if arr[i] < currentHeight: result += (currentHeight - arr[i]) else: currentHeight = arr[i] return result res = calculate(N, ARR) print(res) " p03730,s691266629,Accepted,"a, b, c = map(int, input().split()) answer = ""NO"" for x in range(b): if (a * (x + 1)) % b == c: answer = ""YES"" print(answer)" p03487,s069881012,Accepted,"N = int(input()) A = [int(x) for x in input().split()] numberdict = dict() for i in range(N): if A[i] in numberdict: numberdict[A[i]] += 1 else: numberdict[A[i]] = 1 ans = 0 for j in numberdict.keys(): if numberdict[j] >= j: ans += numberdict[j] - j else: ans += numberdict[j] print(ans) " p03061,s357665708,Wrong Answer,"from functools import reduce n = int(input()) a = list(map(int, input().split())) def gcd(a, b): return a if b == 0 else gcd(b, a%b) def gcd_list(ns): return reduce(gcd, ns) ans = 0 l=len(a) for i in range(l): b = a[0:i] + a[i+1:l] ans = max(ans, gcd_list(b)) print(b) print(ans) " p03385,s935629597,Accepted,"s = input() if ""a"" in s and ""b"" in s and ""c"" in s: print(""Yes"") else: print(""No"")" p03705,s033322304,Accepted,"n,a,b = map(int,input().split()) mx = a + (n-1)*b mi = (n-1)*a + b ans = mx - mi + 1 if n == 1 and a != b or a > b: print(0) else: print(ans)" p03994,s560137524,Accepted,"G={chr(a+ord(""a"")):a for a in range(26)} H={G[b]:b for b in G} T=input() S=[] for s in T: S.append(G[s]) K=int(input()) I=0 N=len(S) for i in range(N): if (iC[i]: x=C[i] p=i print(abs(C[p-1]+A[p]-(s[N]-s[p]))) " p03910,s918943902,Accepted,"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"") N = int(input()) k = 0 while k * (k+1) // 2 < N: k += 1 while N > 0: print(min(k, N)) N -= min(k, N) k -= 1 " p02761,s636152839,Wrong Answer,"n,m = map(int,input().split()) t = [0 for i in range(n)] b = """" a = True for i in range(m): s,c = map(int,input().split()) if t[s-1] == 0 or t[s-1] == c: t[s-1] = c else: a=False for i in range(n): b += str(t[i]) if a and b[0]!='0': print(b) else: print(-1)" p02951,s275554162,Accepted,"a, b, c = map(int, input().split()) if c-(a-b) < 0: print(0) else: print(c-(a-b))" p02796,s204135423,Accepted,"n = int(input()) robots = [] for _ in range(n): x, l = map(int, input().split()) robots.append((x+l, x-l)) robots.sort() hand = robots[0][0] count = 1 for robot in robots[1:]: if hand <= robot[1]: hand = robot[0] count += 1 print(count)" p03644,s978560090,Accepted,"N=int(input()) k=0 while 2**k <= N: ans = 2**k k += 1 print(ans)" p02820,s287620792,Accepted,"n,k=map(int,input().split()) s,p,r=map(int,input().split()) a=list(input()) count={} count[""s""]=s count[""p""]=p count[""r""]=r ans=0 for i in range(k): for j in range(i,n,k): if j-k>=0 and a[j-k]!=a[j]: ans+=count[a[j]] if j-k>=0 and a[j-k]==a[j]: a[j]=""q"" elif j-k<0: ans+=count[a[j]] print(ans)" p03219,s008973885,Wrong Answer,"X,Y = map(int,input().split()) print(X + Y / 2)" p02623,s931973124,Accepted,"import bisect N, M, K = [int(_) for _ in input().split()] A = [int(_) for _ in input().split()] B = [int(_) for _ in input().split()] A_sum = [0] a_sum = 0 for a in A: a_sum += a A_sum.append(a_sum) B_sum = [0] b_sum = 0 for b in B: b_sum += b B_sum.append(b_sum) ans = 0 for i in range(N+1): b_time = K - A_sum[i] if b_time < 0: break idx = bisect.bisect_right(B_sum, b_time) ans = max(ans, i + idx-1) print(ans) " p02789,s272192258,Wrong Answer,"nm = input().split() n = nm[0] m = nm[1] if n < m : print('No') else: print('Yes') " p02933,s038542603,Accepted,"a = int(input()) s = input() if a >= 3200: print(s) else: print('red')" p03254,s237459482,Accepted,"n,x,*a=map(int, open(0).read().split()) a.sort() for i in range(n): x-=a[i] if x<0: print(i) exit() elif x==0: print(-~i) exit() print(n-1)" p02917,s244826056,Accepted,"N = int(input()) B = list(map(int, input().split())) A = [0]*N A[0] = B[0] for i in range(N-1): if i == N-2: A[i+1] = B[i] else: A[i+1] = min(B[i], B[i+1]) print(sum(A))" p02952,s953552980,Accepted,"# N = int(input()) ans = 0 for i in range(1, N + 1): if len(str(i)) % 2 == 1: ans += 1 print(ans)" p03799,s317262676,Accepted,"n, m = map(int, input().split()) if n >= m // 2: print(m // 2) else: print(n + (m - 2 * n) // 4)" p02720,s672481491,Accepted,"K=int(input()) from collections import deque #queue = list(range(1,10)) queue = deque(list(range(1,10))) for i in range(K): lunlun = queue.popleft() #print(lunlun) last = lunlun%10 if last!=0: queue.append(10*lunlun+last-1) queue.append(10*lunlun+last) if last!=9: queue.append(10*lunlun+last+1) print(lunlun)" p02881,s271628871,Accepted,"def get_half_dividers(n): return {i for i in range(1, int(n ** 0.5) + 1) if n % i == 0} N = int(input()) dividers = get_half_dividers(N) print(min([max(0, d - 1) + max(0, (N // d) - 1) for d in dividers])) " p02792,s566877490,Wrong Answer,"n = int(input()) ans = 0 for i in range(1, n+1): L = int(str(i)[0]) R = int(str(i)[-1]) if L * R == 0: continue if L == R: ans += 1 cur = 10 dig = R*cur + L while dig <= n: ans += cur // 10 cur *= 10 dig = R*cur + L print(ans)" p03485,s492493500,Wrong Answer,"a, b = map(int, input().split()) if (a + b) % 2 == 1: print((a + b) / 2 + 1) else: print((a + b) / 2)" p02705,s301830028,Accepted,"from math import pi r = int(input()) print(2*r*pi)" p03835,s223252106,Wrong Answer,"k,s = map(int,input().split()) ans = 0 for i in range(k+1): for j in range(k+1): if (s-(i+j)) <= k: ans += 1 print(ans)" p03069,s378669284,Wrong Answer,"N=int(input()) S=input() idx=""none"" count=0 flag=0 for i in range(N-1,-1,-1): if flag and S[i]==""#"": count+=1 elif S[i]==""."": if not flag: idx=i flag=1 if idx==""none"": print(0) else: #print(count,idx) print(min(count,idx+1-count)) " p03556,s929043140,Wrong Answer,"N = int(input()) res = 1 i = 1 while i**2 < N: res = i**2 i += 1 print(res)" p02664,s960123212,Accepted,"print(input().replace(""?"", ""D""))" p02608,s183107421,Accepted,"n = int(input()) L = [0]*(110**2*6+1) for i in range(1,110): for j in range(1,110): for k in range(1,110): a = i**2 + j**2 + k**2 + i*j +j*k + k*i if a <= n: L[a-1] +=1 for i in range(n): print(L[:n+1][i])" p03804,s962157736,Accepted,"n,m=map(int,input().split()) A = [list(input()) for i in range(n)] B = [list(input()) for i in range(m)] for i in range(n-m+1): for j in range(n-m+1): flag = True for k in range(m): if A[k+j][i:i+m] != B[k][:]: flag = False break if flag: print(""Yes"") quit() else: print(""No"")" p03000,s060955645,Accepted,"n,x = map(int,input().split()) l = list(map(int,input().split())) ans = 0 i = 0 for _ in range(n): ans = ans + l[i] if ans <= x: i += 1 print(i+1)" p03408,s141901007,Accepted,"N = int(input()) dic = {} for i in range(N): s = input() if s in dic: dic[s] += 1 else: dic[s] = 1 M = int(input()) dic2 = {} for i in range(M): s = input() if s in dic2: dic2[s] += 1 else: dic2[s] = 1 ans = 0 for k,v in dic.items(): tmp = v for k2,v2 in dic2.items(): if k == k2: tmp -= v2 ans = max(tmp,ans) print(ans)" p02959,s635080730,Wrong Answer,"N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) count = 0 for i in range(N): if B[i] >= A[i] + A[i+1]: count += A[i] + A[i+1] A[i+1] = 0 else: count += B[i] print(count)" p03328,s804484171,Accepted,"a, b = map(int, input().split()) m = b - a # [m-1] と [m] t = 0 for i in range(m): t += i print(t - a)" p02725,s059330092,Accepted,"K, N = list(map(int, input().split())) A = list(map(int, input().split())) A.append(K+A[0]) diff_list = [] for i in range(len(A) - 1): diff_list.append(A[i+1]-A[i]) print(K - max(diff_list))" p03730,s746786284,Accepted,"A, B, C = map(int, input().split()) s = 0 ans = ""NO"" for i in range(100): s = B * i + C if s % A == 0: ans = 'YES' break print(ans)" p02836,s148794267,Wrong Answer,"import math A=list(input()) N=len(A) x=0 for i in range(0,N): if A[i]!=A[N-1-i]: x+=1 a=math.ceil(x/2) print(x)" p03471,s074071376,Accepted,"n,y=map(int,input().split()) count=0 for i in range(n+1): for j in range(n+1): k=n-i-j if k>=0 and k<=n: if i*10000+j*5000+k*1000==y: print(i,j,k) exit() print(-1,-1,-1)" p03427,s479123060,Accepted,"a = list(input()) if all(i=='9' for i in a[1:]): print(9*len(a)-9+int(a[0])) elif len(a)==1: print(a[0]) else: print(max(int(a[0])-1, 0)+9*(len(a)-1))" p03696,s470169702,Wrong Answer,"n = int(input()) s = input() s_ = s.replace('()', '') x = s_.count('(') y = s_.count(')') print('('*y+s+')'*x)" p03487,s956339864,Wrong Answer,"# 20200612_yorukatsu_e.py import collections N = int(input()) A = list(map(int,input().split())) C = collections.Counter(A) ans = 0 for i,v in C.items(): print(i,v) if i!=v: if i k_distance: predicted_value = "":("" print(predicted_value)" p03145,s036917221,Wrong Answer," a,b,c = map(int,input().split()) print((a*b*c)/2) " p03773,s508433394,Wrong Answer,"A,B=map(int,input().split()) if (A+B)>24: print(A+B-24) else: print(A+B)" p02725,s263700826,Accepted,"import sys input = sys.stdin.readline K, N = map(int, input().split()) A = list(map(int, input().split())) d = [] for i in range(N-1): d.append(A[i+1]-A[i]) d.append(K+A[0]-A[-1]) print(K-max(d))" p03043,s291442359,Accepted,"N, K = list(map(int, input().split())) res = 0 for i in range(N+1)[1:]: j = 0 while i*(2**j) < K: j += 1 res += (1/N) * ((1/2) ** j) print(res)" p02963,s077775623,Accepted,"import math s = int(input()) t = int(math.sqrt(s) // 1) if s == t**2: print(0, 0, 0, t, t, 0) else: t += 1 e = t * t - s print(0, 0, t, e, 1, t)" p03607,s595585931,Accepted,"from collections import Counter n = int(input()) a = [int(input()) for _ in range(n)] cnt = 0 for i, n in Counter(a).items(): if n % 2 == 1: cnt += 1 print(cnt)" p02829,s143127269,Accepted,"a = int(input()) b = int(input()) if a == 1: if b == 2: print(3) else: print(2) elif a == 2: if b == 1: print(3) else: print(1) else: if b == 2: print(1) else: print(2)" p03524,s556869812,Accepted,"# https://atcoder.jp/contests/cf17-final/tasks/cf17_final_b s = input() a = b = c = 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')" p03146,s518212947,Accepted,"def f(n): return (n//2)*(n%2==0) + (3*n+1)*(n%2==1) def main(): s = int(input()) sets = set([]) lists = [] m = 0 for _ in range(pow(10,5)): lists.append(s) sets.add(s) if len(sets) != len(lists): break s = f(s) m += 1 print(m+1) if __name__ == ""__main__"": main() " p03487,s437831496,Accepted,"from collections import Counter n = int(input()) a = list(map(int, input().split())) count = Counter(a) ans = 0 for k,v in count.items(): if k < v: ans += v-k elif v < k: ans += v print(ans)" p03030,s230568206,Wrong Answer,"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(): n=INT() sp=[] for i in range(n): s,p=STRM() sp.append([s,p,i+1]) sorted_sp1=sorted(sp, key=lambda x:x[1], reverse=True) sorted_sp2=sorted(sorted_sp1, key=lambda x:x[0]) for i in range(n): print(sorted_sp2[i][2]) if __name__ == '__main__': do()" p02707,s134607147,Accepted,"N = int(input()) data = list(map(int,input().split())) ans = [0] * N for d in data: ans[d-1]+=1 for a in ans: print(a) " p03041,s985360802,Accepted,"a,b=map(int,input().split()) c=list(input()) c=c[:b-1]+[c[b-1].swapcase()]+c[b:] print("""".join(c))" p03625,s049813363,Accepted,"from collections import Counter N = int(input()) A = list(map(int, input().split())) c = Counter(A) l = sorted(filter(lambda x:x[1] > 1,c.items()),reverse=True) if len(l) == 0: print(0) else: if l[0][1] >= 4: print(l[0][0]**2) else: print(l[0][0]*l[1][0])" p03719,s278949925,Wrong Answer,"# 整数A,B,Cを入力 A,B,C = map(int,input().split()) # 整数CがA以上かつB以下であればYes,そうでなければNo if A <= B and B <= C: print(""Yes"") else: print(""No"")" p03730,s839151666,Accepted,"A,B,C = map(int,input().split()) flg=False for i in range(10**6): temp = A*i if temp%B==C: flg=True break if flg==True: print(""YES"") else: print(""NO"")" p02693,s378501918,Accepted,"# ABC165 A def main(): k = int(input()) a, b = map(int, input().split()) res = False for i in range(a, b+1): if i % k == 0: print('OK') res = True break if res == False: print('NG') if __name__ == '__main__': main()" p03759,s195623980,Accepted,"a,b,c=map(int,input().split()) print(""YES"" if b-a==c-b else ""NO"")" p02899,s671632876,Wrong Answer,"n = int(input()) a = list(map(int,input().split())) d = {str(i+1):a[i] for i in range(n)} d = dict(sorted(d.items(),key=lambda x:x[1])) ans = list(d.keys()) print("" "".join(ans))" p04005,s007342045,Accepted,"# agc004_a.py A,B,C = map(int,input().split()) if A%2 == 0 or B%2 == 0 or C%2 == 0 : print(0) exit() L = abs(A*B*(C//2) - (A*B*(C-C//2))) N = abs(A*C*(B//2) - (A*C*(B-B//2))) M = abs(C*B*(A//2) - (C*B*(A-A//2))) print(min(L,N,M))" p03944,s031070534,Accepted,"w,h,n = map(int,input().split()) ww=hh=0 for _ in [0]*n: x,y,a = map(int,input().split()) if a == 1: ww = max(ww,x) elif a == 2: w = min(w,x) elif a == 3: hh = max(hh,y) else: h = min(h,y) print((w-ww)*(h-hh)*(w>ww)*(h>hh))" p03779,s927737587,Wrong Answer,"x = int(input()) num = 0 for i in range(1,40000): num += i if num >= x: print(i) exit() " p02720,s054837106,Accepted,"k=int(input()) q=[""1"",""2"",""3"",""4"",""5"",""6"",""7"",""8"",""9""] x=9 for i in q: if x>100000: break x+=1 a=i[-1] for j in ([-1,0,1]): bb=int(a)+j if bb<10 and bb>=0: q.append(i+str(bb)) print(q[k-1])" p03126,s688681735,Wrong Answer,"n, m = map(int,input().split()) ans = [1]*m for i in range(1,n+1): x = list(map(int,input().split())) x.pop(0) for j in range(m): if j not in x: ans[j-1] = 0 print(ans.count(1))" p02768,s124310273,Accepted,"mod=10**9+7 n,a,b=map(int,input().split()) ans=pow(2,n,mod)-1 def comb(n,mm): m=min(mm,n-mm) ans=1 for i in range(m): ans*=n-i ans%=mod for i in range(m): ans*=pow(i+1,mod-2,mod) ans%=mod return ans ans=((ans+(mod-comb(n,a)))%mod)+(mod-comb(n,b)) print(ans%mod)" p02663,s845240992,Accepted,"h1, m1, h2, m2, k = map(int, input().split()) hm1 = h1*60+m1 hm2 = h2*60+m2 print(hm2-hm1-k) " p02813,s442249193,Accepted,"import itertools N=int(input()) p=list(map(int,input().split())) q=list(map(int,input().split())) m=list(itertools.permutations(p)) m.sort() p=tuple(p) q=tuple(q) a=m.index(p) b=m.index(q) print(abs(a-b))" p02747,s884363495,Accepted,"import re s=input() if re.fullmatch(r'(hi)+',s): print(""Yes"") else: print(""No"")" p03281,s903977052,Accepted,"n = int(input()) def yakusu(num): list_a = [] for i in range(1, num//2 + 1): if num % i == 0: list_a.append(i) list_a.append(num) return list_a ans = 0 for i in range(1, n + 1): if len(yakusu(i)) == 8 and i % 2 ==1: ans += 1 print(ans)" p03627,s121059470,Accepted,"from collections import Counter n = int(input()) *a, = map(int,input().split()) b = Counter(a) c = sorted(b.items(), reverse = True) z = [0] * 2 j = 0 ans = 0 for keys,values in c: if values < 2:continue if values >= 4: ans = max(ans, keys ** 2) if j < 2: z[j] = keys j += 1 ans = max(ans, z[0] * z[1]) print(ans) " p03086,s573763130,Accepted,"S = input() cnt=0 ans = 0 sets = {""A"",""T"",""C"",""G""} for s in S: if s in sets: cnt += 1 else: ans = max(ans,cnt) cnt = 0 ans = max(ans,cnt) print(ans) " p02596,s015849772,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 if c==6: print(-1)" p03478,s223881830,Accepted,"import math N, A , B = map(int, input().split()) ans = 0 for x in range(1, N + 1): SUM = 0 num = x while x > 0: SUM += (x % 10) x //= 10 if A <= SUM <= B: ans += num print(ans) " p02795,s943200256,Accepted,"# -*- coding: utf-8 -*- H = int(input()) W = int(input()) N = int(input()) longer = max(H, W) count = int(N / longer) if N % longer > 0: count += 1 print(count)" p02760,s737893021,Wrong Answer,"A = [] for i in range(3): a = input().split() a = [int(num) for num in a] A.append(a) N = int(input()) b = [int(input()) for i in range(N)] for i in range(3): for j in range(3): if b.count(A[i][j]) != 0: A[i][j] = 0 else: continue if (sum(A[0][:]) or sum(A[1][:]) or sum(A[2][:]) or sum(A[:][0]) or sum(A[:][1]) or sum(A[:][2]) or (A[0][0]+A[1][1]+A[2][2]) or (A[0][2]+A[1][1]+A[2][0])) == 0: print(""Yes"") else: print(""No"")" p03145,s660149599,Accepted,"import sys input = sys.stdin.readline def main(): AB, BC, CA = map(int, input().split()) ans = AB * BC // 2 print(ans) if __name__ == ""__main__"": main() " p02778,s718806771,Accepted,"s=input() print(""x""*len(s))" p02595,s527468915,Accepted,"import sys input=lambda: sys.stdin.readline().rstrip() 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)" p02909,s624584133,Accepted,"s=input() l=[""Sunny"",""Cloudy"",""Rainy""] index=l.index(s) index+=1 if index==3: index=0 print(l[index])" p03239,s341777777,Accepted,"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)" p03699,s669890297,Accepted,"N = int(input()) A = [int(input()) for _ in range(N)] total = sum(A) if total%10 == 0: A.sort() for a in A: if a%10 != 0: total -= a break else: # 全部が10の倍数 total = 0 print(total) " p02594,s637922768,Accepted,"X = int(input()) if X >= 30: print('Yes') else: print('No')" p02624,s767512191,Accepted,"def solve(n): ans = 0 for i in range(1,n+1): y = n//i ans += (y*(y+1)*i)/2 return ans def main(): n = int(input()) print(int(solve(n))) if __name__ == ""__main__"": main()" p02663,s009141548,Accepted,"h,m,h2,m2,k = map(int,input().split()) end = h2*60+m2 stt = h*60+m print(end-stt-k)" p03427,s607735731,Accepted,"N = input() c = N[0] ans = int(c) + 9 * (len(N) - 1) if int(N) < int(c + '9' * (len(N) - 1)): ans -= 1 print(ans)" p02683,s877757222,Accepted,"N,M,X = [int(hoge) for hoge in input().split()] CE = [[int(hoge) for hoge in input().split()] for n in range(N)] curmin = 100000000000000000 ans = -1 for i in range(2**12): A = [0]*M cost = 0 for n,CA in enumerate(CE): if (i >> n) & 1: cost += CA[0] for m in range(M): A[m] += CA[m+1] if all([x >= X for x in A]): curmin = min(curmin,cost) ans = curmin print(ans)" p03997,s316129162,Accepted,"a=int(input()) b=int(input()) h=int(input()) print(int((a+b)*h/2))" p02628,s662494483,Wrong Answer,"N, K = map(int, input().strip().split()) p = list(map(int, input().strip().split())) p.sort() print(sum(p[:K+1]))" p02725,s192212397,Accepted,"def readinput(): k,n=map(int,input().split()) a=list(map(int,input().split())) return k,n,a def main(k,n,a): dmax=0 for i in range(n-1): dmax=max(dmax,a[i+1]-a[i]) dmax=max(dmax,k+a[0]-a[n-1]) return k-dmax if __name__=='__main__': k,n,a=readinput() ans=main(k,n,a) print(ans) " p02971,s866636854,Wrong Answer,"n = int(input()) num = [] maxnum = 0 count = 1 for i in range(n): a = int(input()) if a!=maxnum: maxnum = max(maxnum,a) else: count += 1 num.append(a) for i in range(n): if count>1: print(maxnum) else: if num[i]!=maxnum: print(maxnum) else: subnum = num[0:i] + num[i+1:n] subnum = sorted(subnum) print(subnum[n-2])" p03289,s477420923,Wrong Answer,"import sys readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines read = sys.stdin.buffer.read sys.setrecursionlimit(10 ** 7) INF = float('inf') S = input() if S[0] == ""A"" and S[2:-2].count(""C"") == 1 and S.count(""A"") == 1 and S.count(""C"") == 1: S = S.replace(""A"", """") S = S.replace(""C"", """") if S == S.lower(): print('AC') quit() print('WA') " p03380,s063918406,Accepted,"from bisect import bisect_right n = int(input()) a = sorted(list(map(int, input().split()))) pos = bisect_right(a, a[-1]/2) if pos == 0 or abs(a[-1]/2 - a[pos-1]) > abs(a[-1]/2 - a[pos]): print(a[-1], a[pos]) else: print(a[-1], a[pos-1])" p04019,s575795458,Accepted,"i=input() if (""N"" in i and ""S"" not in i) or (""W"" in i and ""E"" not in i) or (""W"" not in i and ""E"" in i) or (""N"" not in i and ""S"" in i): print(""No"") else: print(""Yes"")" p02899,s165362684,Accepted,"n = int(input()) a = list(map(int,input().split())) l = [0] * n for i in range(n): l[a[i]-1] = i+1 for i in range(n): print(l[i],end = ' ') " p03821,s692911072,Accepted,"n = int(input()) AB = [list(map(int, input().split())) for _ in range(n)] num = 0 for i in range(n): a, b = AB[n - i - 1] if (num + a) % b != 0: num += b - (num + a) % b print(num)" p02607,s911504134,Accepted,"n = int(input()) a = list(map(int, input().split())) ans = 0 for i in range(n): if i % 2 == 0 and a[i] % 2 == 1: ans += 1 print(ans) " p03293,s940991415,Accepted,"S = input() T = input() ans = ""No"" for _ in range(len(S)): if S == T: ans = ""Yes"" S = S[-1] + S[:-1] print(ans) " p02848,s833946125,Accepted,"N = int(input()) S = input() ans = '' for s in S: i = ord(s)+N if i >= 65 + 26: i -= 26 ans += chr(i) print(ans) " p04012,s707339325,Accepted,"import collections ans = input() ans = list(collections.Counter(ans).values()) for i in ans: if i % 2 == 0: pass else: print(""No"") exit() print(""Yes"")" p04011,s945514407,Accepted,"N = int(input()) K = int(input()) X = int(input()) Y = int(input()) cos = 0 for i in range(N): if K >= (i + 1): cos += X else: cos += Y print(cos) " p02598,s587232799,Accepted,"from math import ceil N,K = map(int,input().split()) A = list(map(int,input().split())) def is_ok(X): #最大値をX以下にできるか cnt = 0 for a in A: cnt += ceil(a/X)-1 return cnt <= K def bisearch(high,low): while high - low > 1: mid = (high+low)//2 if is_ok(mid): high = mid else: low = mid return high print(bisearch(10**9+1,0))" p02829,s247352782,Accepted,"a=int(input()) b=int(input()) x=[1,2,3] x.remove(a) x.remove(b) print(x[0])" p03067,s074828159,Accepted,"a, b, c = map(int, input().split()) for i in range(min(a,b)+1, max(a,b)): if i == c: print(""Yes"") exit() print(""No"")" p03254,s898003846,Accepted,"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] else: break if ans==N: if x==0: pass else: ans-=1 print(ans)" p03095,s632134258,Accepted,"n = int(input()) a = list(input()) b = list(set(a)) ans = 1 for i in b: ans %= 10**9+7 ans *= a.count(i)+1 print((ans-1)%(10**9+7))" p03077,s158100933,Accepted,"n = int(input()) t = [int(input()) for _ in range(5)] q, r = divmod(n, min(t)) if r > 0: q += 1 print(q+4)" p02801,s930767288,Accepted,"# A - Next Alphabet def main(): C = input().rstrip() ans = chr(ord(C) + 1) print(ans) if __name__ == ""__main__"": main() " p03087,s634461352,Accepted,"def main(): n, q = map(int, input().split()) ss = list(input()) lrs = [list(map(int, input().split())) for _ in range(q)] cum_sum = [0] * n for i in range(1, n): if ss[i-1] == 'A' and ss[i] == 'C': cum_sum[i] += 1 cum_sum[i] += cum_sum[i-1] for l, r in lrs: print(cum_sum[r-1]-cum_sum[l-1]) if __name__ == ""__main__"": main() " p03427,s239751183,Accepted,"n=int(input()) k=len(str(n)) c=n//10**(k-1) print(c+9*(k-1) if n==(c+1)*10**(k-1)-1 else c+9*(k-1)-1) " p02612,s171166102,Accepted,"N = int(input()) A = N % 1000 if A == 0: print(0) else: print(1000-A) " p02861,s331798192,Wrong Answer,"n = int(input()) xs = [] ys = [] for _ in range(n): x, y = map(int, input().split()) xs.append(x) ys.append(y) s = 0 c = 0 for i in range(n): for k in range(i + 1, n): s += ((xs[i] - xs[k]) ** 2 + (ys[i] - ys[k]) ** 2) ** 0.5 c += 1 a = s / c for i in range(1, n): a *= i print(a)" p02912,s065120329,Accepted,"#!/usr/bin/env python3 import heapq def main(): n, m = map(int, input().split()) a = list(map(int, input().split())) a = [-x for x in a] # Negate to use min-heap as max-heap heapq.heapify(a) for i in range(m): x = heapq.heappop(a) * (-1) x //= 2 heapq.heappush(a, -x) print(sum(a) * (-1)) if __name__ == ""__main__"": main() " p02909,s000708760,Accepted,"#141A #1.入力をちゃんと受け取ること b=input() #2.結果を出力する if b=='Sunny' : print('Cloudy') elif b=='Rainy': print('Sunny') elif b=='Cloudy': print('Rainy') " p02546,s859237954,Wrong Answer,"S = input("""") if len(S)<=1000 and len(S)>=1: if S.endswith(('o', 'ch', 's', 'sh', 'x', 'z')): print(S.lower()+""es"") else: print(S.lower()+""s"") " p02742,s835412931,Wrong Answer,"from sys import stdin h,w = [int(x) for x in stdin.readline().rstrip().split()] import math def bishop(h,w): if h == 1: ans = 1 else: ans = int(w/2)*h + (w%2)*math.ceil(h/2) print(ans) return" p02948,s591794137,Wrong Answer,"N,M=map(int,input().split()) AB=[] for _ in range(N): a,b=map(int,input().split()) AB.append([a,b]) AB.sort(key=lambda x:-1*x[1]*10**6-x[0]) cnt=0 ans=0 while True: end=False for i in range(0,N): if M-cnt>=AB[i][0]: ans+=AB[i][1] cnt+=1 AB[i][0]=10**7 break if i==N-1: end=True if end: break print(ans)" p02747,s378893560,Wrong Answer,"a = input() ok = True for i in range(0, len(a)//2 + 2, 2): if a[i:i + 2] != ""hi"": ok = False break if ok: print(""Yes"") else: print(""No"")" p03679,s094904354,Accepted,"a,b,c=map(int,input().split()) if b>=c: print(""delicious"") elif a+b >=c: print(""safe"") else: print(""dangerous"")" p02708,s796933907,Accepted,"n, k = map(int, input().split()) ans = 0 for i in range(k, n+2): ans += n*i-i**2+i+1 print(ans % (10**9+7)) " p02786,s486970571,Accepted,"H=int(input()) if H == 1: ans=1 H_list=[] while H > 1: if H % 2 != 0: H=H-1 H_list.append(H) H = H//2 H_list.sort() ans_list=[] for h in H_list: if h == 2: ans = 3 else : ans = 2*ans+1 ans_list.append(ans) print(ans)" p02854,s521139447,Accepted,"n = int(input()) sa = [0] ans = float(""INF"") for i, ai in enumerate(list(map(int, input().split()))): sa.append(sa[i] + ai) for i in range(n + 1): ans = min(ans, abs(sa[i] - (sa[-1] - sa[i]))) print(ans) " p03495,s949043584,Accepted,"from collections import Counter N,K=map(int,input().split()) A=list(map(int,input().split())) cnt=Counter(A) cnt_sorted=sorted(cnt.items(), reverse=True,key=lambda x:x[1]) sum=0 for i in range(min(K,len(cnt))): sum+=cnt_sorted[i][1] print(N-sum)" p03161,s248334701,Wrong Answer,"import numpy N, K = map(int,input().split()) h = numpy.array(input().split(),numpy.int32) dp = numpy.array([10**5]*N,numpy.int32) dp[0] = 0 for i in range(N) : for j in range(1,K+1) : x = i+j if x< N : m = dp[i]+abs(h[i]-h[x]) if m < dp[x] : dp[x] = m print(dp[-1])" p03017,s737193364,Accepted,"n,a,b,c,d = map(int,input().split()) s = input() if d MAX: print('No') exit() for i in range(N): if X[i][0] > X[i][1]: print('No') exit() print('Yes')" p02628,s581151793,Accepted,"N,K=map(int,input().split()) p=sorted(list(map(int,input().split()))) print(sum(p[:K])) " p03773,s689829048,Wrong Answer,"a, b = map(int, input().split()) ans = a + b if ans > 24: ans = ans - 24 print(ans)" p02596,s156562207,Wrong Answer,"def main(): import sys import time start=time.time() K=int(sys.stdin.readline()) s='' while True: s+='7' if int(s)%K==0: print(len(s)) break if time.time()-start>=1.8: print(-1) break main()" p02783,s801848149,Accepted," h, a = input().split() h = int(h) a = int(a) x = a attack = 1 while h > x : h -= x attack += 1 print(attack) " p03835,s259634179,Accepted,"import sys import heapq from decimal import Decimal input = sys.stdin.readline 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)" p02801,s653633992,Accepted,"aas = {'a':'b','b':'c','c':'d','d':'e','e':'f','f':'g','g':'h','h':'i','i':'j','j':'k','k':'l','l':'m','m':'n','n':'o','o':'p','p':'q','q':'r','r':'s','s':'t','t':'u','u':'v','v':'w','w':'x','x':'y','y':'z'} print(aas[input()])" p02608,s733953203,Wrong Answer,"import math n = int(input()) for i in range(1, 6): print(0) for i in range(6, n+1): x = int(math.sqrt(i)) + 1 ans = 0 for j in range(1, x): for f in range(1, x): for k in range(1, x): if (j + f + k) ** 2 - j*f - j*k - f*k == i: ans += 1 print(ans)" p03565,s295870571,Wrong Answer,"S = list(input()) T = list(input()) flag = False C = [] for i in range(len(S)): flag = False ii = len(S) - i for j in range(len(T)): if (ii+j >= len(S)): flag = False break elif S[ii+j]==T[j] or S[ii+j] == ""?"": flag = True else: flag = False break if (flag): for k in range(len(T)): S[ii+k] = T[k] C.append("""".join(S).replace(""?"",""a"")) if (C != []): print(min(C)) else: print(""UNRESTORABLE"")" p03695,s032740391,Accepted,"N = int(input()) A = list(map(int,input().split())) color = [0] * 9 for a in A: if a <= 399: color[0] = 1 elif a <= 799: color[1] = 1 elif a <= 1199: color[2] = 1 elif a <= 1599: color[3] = 1 elif a <= 1999: color[4] = 1 elif a <= 2399: color[5] = 1 elif a <= 2799: color[6] = 1 elif a <= 3199: color[7] = 1 else: color[8] += 1 max_num = sum(color) min_num = max(1, sum(color[:-1])) print(min_num, max_num)" p02970,s340231205,Wrong Answer,"n,d = map(int,input().split()) if n%(2*d+1) == 0: print(n%(2*d+1)) else: print(n%(2*d+1)+1)" p03438,s384337062,Wrong Answer,"n=int(input()) a=list(map(int,input().split())) b=list(map(int,input().split())) a.sort() b.sort() suma=sum(a) sumb=sum(b) #sum(a)+2*k=sum(b)+k #k=(sum(a)-sum(b)) k=suma-sumb # #1 1 1 6 #2 2 2 3 if k<0: print(""No"") exit() cnt=0 for i in range(n): if a[i]>b[i]: cnt+=b[i]-a[i] elif a[i]=k: print(""Yes"") else: print(""No"")" p03041,s474843810,Accepted,"N, K = map(int,input().split()) S = input() SL = list(S) SL[K-1] = SL[K-1].lower() ans = """".join(SL) print(ans)" p02973,s416072874,Accepted,"# Python3 (3.4.3) import sys input = sys.stdin.readline # ------------------------------------------------------------- # function # ------------------------------------------------------------- # ------------------------------------------------------------- # main # ------------------------------------------------------------- N = int(input()) A = [int(input()) for _ in range(N)] from collections import deque from bisect import bisect_left 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))" p03419,s951021830,Wrong Answer,"N, M = map(int,input().split()) if N == 1 or M == 1: if N + M == 1: print(1) else: print(N*M-2) else: print((N-2)*(M-2)) " p03681,s779706713,Accepted,"import sys sys.setrecursionlimit(100000) n, m = map(int, input().split()) def kaijo(n): if n == 1: return 1 return n * kaijo(n - 1) % ((10 ** 9) + 7) if abs(n - m) > 1: print(0) exit() a = kaijo(n) b = kaijo(m) if n == m: print((a * b * 2) % ((10 ** 9) + 7)) else: print((a * b ) % ((10 ** 9) + 7)) " p02831,s406027395,Accepted,"def koubai(a,b): if b == 0: return a else: return koubai(b,a%b) a,b = map(int,input().split()) if a < b : a,b = b,a s = koubai(a,b) print( int ( (a*b) /s ) )" p03282,s827978718,Wrong Answer,"s = input() k = int(input()) for si in s: if si != '1': print(si) exit() else: print(1)" p03042,s007558566,Accepted,"S = input() first = int(S[0:2]) last = int(S[2:4]) if (0 < first < 13): if (0 < last < 13): print(""AMBIGUOUS"") else: print(""MMYY"") else: if (0 < last < 13): print(""YYMM"") else: print(""NA"")" p03854,s988704593,Wrong Answer,"t=input() trigger=1 app=['dream','dreamer','erase','eraser'] while len(t)>0 and trigger: for i in range(4): key=app[i] if key==t[:len(key)]: t=t[len(key):] trigger+=1 break trigger-=1 if t=='': print('YES') else: print('NO')" p02701,s375081330,Wrong Answer,"N = int(input()) S = [] for i in range(N): S.append(input()) set(S) print(len(S))" p03971,s119226615,Accepted,"N, A, B = map(int, input().split()) S = input() confirmed = 0 confirmedB = 0 for c in S: if c == ""a"" and confirmed < A+B: print(""Yes"") confirmed += 1 elif c == ""b"" and confirmed < A+B: if confirmedB < B: print(""Yes"") confirmed += 1 confirmedB += 1 else: print(""No"") else: print(""No"") " p02854,s484608818,Wrong Answer,"N = int(input()) A = list(map(int, input().split())) tmp = [0 for i in range(N+1)] length = 0 for i in range(N): tmp[i+1] = tmp[i] + A[i] length += A[i] ans = 0 for i in range(1, N+1): ans = min(ans, abs((length - tmp[i]) - tmp[i])) print(ans) " p03971,s117121369,Wrong Answer,"x, s = *open(0), n, a, b = map(int, x.split()) p = 0 wp = 0 for char in s: if char == 'c' or p >= a+b: print('No') continue if char == 'a': p += 1 print('Yes') continue if wp < b: p += 1 wp += 1 print('Yes') else: print('No')" p03254,s614128135,Accepted,"# AGC 027 A - Candy Distribution Again n, x = map(int, input().split()) a = list(map(int, input().split())) a.sort() count = 0 for i in range(n): if i == n-1: if x == a[i]: count += 1 else: break elif x >= a[i]: x -= a[i] count += 1 else: break print(count)" p02730,s432302902,Wrong Answer,"import sys input = lambda: sys.stdin.readline().rstrip() S = input() N = len(S) S_left = S[:(N-1)//2] S_right = S[(N+1)//2:] def ch_kaibun(s): if not s: return True if len(s) % 2 == 0: return False n = len(s) for i in range((n-1)//2): if s[i] != s[n-1-i]: return False return True if ch_kaibun(S) and ch_kaibun(S_left) and ch_kaibun(S_right): print(""Yes"") else: print(""No"") " p02946,s608501799,Wrong Answer,"a,b=map(int,input().split()) l=[] for x in range(a): l.append(b-x) l.append(b+x) l.remove(b) print(sorted(l))" p03077,s004511154,Accepted,"import sys import math from collections import defaultdict from collections import deque def load(vtype=int): return vtype(input().strip()) n = load() li = [] for _ in range(5): li.append(load()) mn = min(li) mni = li.index(mn) ans = math.ceil(n / mn) + mni + (5-mni-1) print(ans)" p03351,s396980951,Accepted,"a, b, c, d = [int(i) for i in input().split()] print(""Yes"" if abs(a - c) <= d or (abs(a - b) <= d and abs(b - c) <= d) else ""No"")" p03644,s251689307,Accepted,"n = int(input()) l = [64,32,16,8,4,2,1] for i in l: if i <= n: print(i) break" p02678,s237053494,Accepted,"from collections import deque q=deque() def MI(): return map(int, input().split()) N,M=MI() g=[[] for _ in range(N+1)] for _ in range(M): a,b=MI() g[a].append(b) g[b].append(a) check=[0]*(N+1) check[1]=1 ans=[0]*(N+1) q.append(1) while len(q)>0: v=q.popleft() for u in g[v]: if check[u]==0: check[u]=1 ans[u]=v q.append(u) print('Yes') for i in range(2,N+1): print(ans[i]) " p02972,s013437644,Accepted,"from math import sqrt, ceil n = int(input()) data = list(map(int, input().split())) balls = [] mid = n//2+1 table = [0] * n for idx in range(mid-1, n): table[idx] = data[idx] if data[idx] == 1: balls.append(idx+1) for idx in range(mid-2, -1, -1): score = 0 for idx2 in range(idx, n, idx+1): score += table[idx2] if score%2 != data[idx]: table[idx] = 1 balls.append(idx+1) print(len(balls)) if len(balls) > 0: print(' '.join(map(str, balls)))" p02594,s456732076,Accepted,"a = int(input()); if a >= 30: print(""Yes"") else: print(""No"") " p02724,s925648906,Accepted,"X = int(input()) #Happyness H = 0 div_500 = X // 500 div_5 = (X - 500 * div_500) // 5 H = 1000 * div_500 + 5 * div_5 print(H)" p02957,s892497448,Accepted,"import itertools import math import fractions import functools a, b = map(int, input().split()) if (b+a)/2 == (b+a)//2: print((b+a)//2) else: print(""IMPOSSIBLE"")" p02939,s746630220,Accepted,"# A - Dividing a String S = input() ans = 0 tmp = '' prev = '' for i in range(len(S)): tmp += S[i] if tmp!=prev: ans += 1 prev = tmp tmp = '' print(ans)" p03109,s764269188,Accepted,"s = input() s = s.split('/') s = list(map(int, s)) if s[0]<2018 or (s[0]==2019 and s[1]<=4 and s[2]<=30): print('Heisei') else: print('TBD')" p03136,s960822414,Wrong Answer,"n = int(input()) l = list(map(int,input().split())) l.sort(reverse = True) if l[0] > sum(l[1:n]): print('Yes') else: print('No')" p03163,s580585198,Accepted,"N, W = map(int, input().split()) dp = [[0]*(W+1) for _ in range(N+1)] for i in range(1, N+1): w, v = map(int, input().split()) for j in range(W+1): dp[i][j] = dp[i-1][j] if j >= w: dp[i][j] = max(dp[i][j], dp[i-1][j-w]+v) print(dp[N][W])" p03264,s098542383,Accepted,"k = int(input()) if k%2 == 0: print((k//2)**2) else: print((k//2)*(k+1)//2)" p03760,s015896157,Accepted,"from collections import deque from itertools import count Odd = deque(input()) Even = deque(input()) rtnList = lambda x: Odd if x & 1 else Even ans = '' for i in count(1,1): try: s = rtnList(i).popleft() except IndexError: print(ans) exit() ans += s " p02606,s403899283,Wrong Answer,"stir=input() lst=stir.split("" "") l=int(lst[0]) r=int(lst[1]) t=lst[2] b=1 x=0 multiples=[] while(b<101): multiples.append(int(t)*b) b+=1 for a in range(l-1, r+1): for m in multiples: if(m==a): x+=1 print(x)" p03951,s568301724,Wrong Answer,"N = int(input()) s = str(input()) t = str(input()) if s == t: print(N) else: for i in range(N): if s[N-1-i]!=t[i]: print(2*N-i) break" p02642,s430097607,Accepted,"import math N = int(input()) A = list(map(int, input().split())) A = sorted(A) maxA = A[len(A)-1] valid = [True] * (maxA+1) for i in range(len(A)): if valid[A[i]] == False: continue if i != 0 and A[i-1] == A[i]: valid[A[i]] = False else: for j in range(A[i]*2, maxA+1, A[i]): valid[j] = False count = 0 for i in range(len(A)): if valid[A[i]] == True: count += 1 print(count) " p03659,s966503710,Accepted,"N = int(input()) A = list(map(int,input().split())) arai = sum(A) sunuke = 0 ans = 10000000000000000 for i in A[:-1]: arai -= i sunuke += i x = abs(sunuke - arai) if x < ans: ans = x print(ans)" p02554,s187658973,Wrong Answer,"import math n = int(input()) ans = 20**(n-2) % (10**9 + 7) print(math.floor(ans))" p03239,s634688132,Accepted,"n,t= map(int, input().split()) l=[] for i in range(n): l.append(list(map(int, input().split()))) ans = 10**9 for i in range(n): cost = l[i][0] time = l[i][1] if time <= t and cost < ans: ans=cost if ans == 10**9: print(""TLE"") else: print(ans)" p02732,s652926158,Wrong Answer,"from collections import Counter from scipy.misc import comb N = int(input()) An = list(map(int, input().split())) counter = Counter(An) cnt = 0 for c in counter.values(): cnt += comb(c, 2) for a in An: print(int(cnt - comb(counter[a], 2) + comb(counter[a]-1, 2))) " p02664,s425214676,Accepted,"t=input() t=t.replace(""?"", ""D"") print(t)" p03705,s691356838,Wrong Answer,"n, a, b = map(int, input().split()) if n == 1 and a != b: ans = 0 else: ans = (b * (n - 1) + a) - (a * (n - 1) + b) print(ans) " p02792,s884432507,Accepted,"N = int(input()) c = [[0]*10 for _ in range(10)] for k in range(1,N+1): c[int(str(k)[0])][int(str(k)[-1])]+=1 ans = 0 for k in range(81): i = k // 9 + 1 j = k % 9 + 1 ans += c[i][j] * c[j][i] print(ans) " p03150,s640248237,Wrong Answer,"s = list(input()) l = list(""keyence"") i = 0 for si in s: if l[i] == si: i+=1 if i == 7: print(""YES"") break else: print(""NO"")" p02786,s523704199,Wrong Answer,"import sys H = int(input()) if H == 1: sys.exit() cnt = 1 i = 1 H //= 2 while H > 0: i <<= 1 cnt += i H //= 2 print(cnt) " p02720,s900236424,Accepted,"import queue q=queue.Queue() for i in range(1,10): q.put(i) N=int(input()) for i in range(N): a=q.get() b=a%10 if b!=0: q.put(10*a+b-1) q.put(10*a+b) if b!=9: q.put(10*a+b+1) print(a)" p02682,s790919002,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)) " p02922,s864891530,Accepted,"import sys input = sys.stdin.readline input = sys.stdin.buffer.readline #sys.setrecursionlimit(10**9) def RD(): return sys.stdin.read() 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())) # rstrip().decode('utf-8') #import numpy as np def main(): a,b=MI() for i in range(100): if (a-1)*i+1>=b: print(i) exit(0) if __name__ == ""__main__"": main()" p02595,s900662738,Accepted,"from math import sqrt def distance(a, b): return sqrt(a ** 2 + b ** 2) n, d = list(map(int, input().split())) res = 0 for _ in range(n): l = list(map(int, input().split())) if d >= distance(l[0],l[1]): res += 1 print(res) " p03059,s399309214,Accepted,"a, b, t = map(int, input().split()) T = int((t+0.5)//a) print(T*b)" p02959,s013735004,Wrong Answer,"n=int(input()) a=list(map(int,input().split())) b=list(map(int,input().split())) for i in range(n): a[i]=max(a[i]-b[i],0) b[i]=max(b[i]-a[i],0) for i in range(n): a[i+1]=max(b[i]-a[i+1],0) print(sum(a))" p02677,s902392462,Accepted,"import sys import math a, b, h, m = map(int, input().split()) h = (h+m/60)/12*2*math.pi m = m/60*2*math.pi p1 = [a*math.cos(h), a*math.sin(h)] p2 = [b*math.cos(m), b*math.sin(m)] print(((p1[0]-p2[0])**2+(p1[1]-p2[1])**2)**0.5)" p03605,s887054808,Accepted,"if input().count('9'): print('Yes') else: print('No') " p03293,s026959722,Wrong Answer,"s=input() t=input() slist=[] tlist=[] for i in s: slist.append(i) slist.sort() for i in t: tlist.append(i) tlist.sort() if slist==tlist: print('Yes') else: print('No')" p02765,s291334781,Wrong Answer,"n, r = list(map(int, input().split())) if n >= 10: print(r) else: print(r - 100 * (10 - n)) " p02759,s435921259,Accepted,"n=int(input()) if n%2==0: print(n//2) else: print(n//2 + 1)" p04045,s989477594,Accepted,"n,k=map(int,input().split()) a=list(map(int,input().split())) for i in range(1,10**5+1): if i>=n: p=str(i) ch=0 for y in range(len(p)): if int(p[y]) in a: ch+=1 if ch==0: print(i) break" p02987,s651777667,Accepted,"# Written by Shagoto s = input() s = s.replace(s[0], """") if(len(s) == 2): s = s.replace(s[0], """") if(len(s) == 0): print(""Yes"") else: print(""No"") else: print(""No"")" p02731,s409472979,Accepted,"l = int(input()) print((l/3)**3)" p02618,s576463857,Accepted,"import random d = int(input()) #365 c = list(map(int, input().split())) # 26個 s = [list(map(int, input().split())) for _ in range(d)] #output t = [random.randint(1,26) for _ in range(d)] for i in range(d): print(t[i])" p03627,s567972714,Accepted,"N = int(input()) ls = list(map(int,input().split())) import collections c = collections.Counter(ls) unique_ls = list(reversed(sorted(([i[0] for i in c.items() if i[1] >= 2])))) if len(unique_ls) >=2: if ls.count(unique_ls[0]) >=4: print(unique_ls[0]**2) else: print(unique_ls[0]*unique_ls[1]) elif len(unique_ls) ==1: if ls.count(unique_ls[0]) >=4: print(unique_ls[0]**2) else: print(0) else: print(0)" p02555,s346651670,Wrong Answer,"import math S = int(input()) n = S // 3 ans = -1 for k in range(1, n + 1): ans = ans + math.factorial(S - 2 * k + 1)/(math.factorial(k - 1) * math.factorial(S - k + 2)) print(ans)" p03438,s938921363,Accepted,"N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) max_count = sum(B) - sum(A) count1, count2 = 0, 0 for i in range(N): if A[i] > B[i]: count1 += A[i] - B[i] else: count2 += (B[i] - A[i]) // 2 if (B[i] - A[i]) % 2 == 1: count2 += 1 if count1 <= max_count: if count2 <= max_count: print(""Yes"") quit() print(""No"")" p02882,s818005860,Accepted,"import math a,b,x=map(int,input().split()) Q=x/a if Q>a*b/2: s=a*b-Q Ans=math.degrees(math.atan2(2*s,a**2)) else: Ans=90-math.degrees(math.atan2(2*Q,b**2)) print(Ans)" p02601,s666502921,Wrong Answer,"numbers = [int(s) for s in input().split()] #0:赤, 1:緑, 2:青 K = int(input()) for i in range(K): if(numbers[2] < numbers[0]): numbers[2] *= 2 elif(numbers[1] < numbers[0]): numbers[1] *= 2 elif(numbers[2] < numbers[1]): numbers[2] *= 2 else: break if(numbers[1] > numbers[0] and numbers[2] > numbers[1]): print(""Yes"") else: print(""No"")" p04012,s646991866,Wrong Answer,"w =str(input()) length = len(w) z = sorted(w) i=1 m=0 if length%2 == 1: m = 1 pass else: while i < length: if z[i]==z[i-1]: i += 2 else: m = 1 break if m == 1: print(""NO"") else: print(""YES"")" p02597,s399499804,Accepted," def main(): n = int(input()) c = input() r = c.count('R') w = c.count('W') ropt = c[:r].count('R') wopt = c[r:].count('W') rnot = r - ropt wnot = w - wopt return min(rnot,wnot) if __name__ == '__main__': print(main())" p02572,s468097888,Accepted,"n=int(input()) a=list(map(int,input().split())) mod=1000000007 sum_a=sum(a) ans=0 for i in range(n): temp=(sum_a-a[i])*a[i] ans+=temp print((ans//2)%mod) " p02766,s019817473,Accepted,"N, K = map(int, input().split()) i = 0 while True: if N < K**i: print(i) exit() i += 1 " p04020,s727912482,Accepted,"N = int(input()) cards = 0 pairs = 0 for _ in range(N): A = int(input()) if A: cards += A else: pairs += cards//2 cards = 0 pairs += cards//2 print(pairs)" p02623,s175626318,Wrong Answer,"from bisect import bisect from itertools import accumulate n, m, k = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) a = list(accumulate(a)) b = list(accumulate(b)) ans = 0 for i in range(n): if a[i] > k: break ans = max(ans, i+1+bisect(b, k-a[i])) print(ans)" p03665,s166019555,Accepted,"from math import factorial def cmb(n,r): return factorial(n)//(factorial(n-r)*factorial(r)) n,p=map(int,input().split()) A=list(map(int,input().split())) A=[A[i]%2 for i in range(n)] cnt=A.count(0) ans=0 for i in range(p,n-cnt+1,2): ans +=cmb(n-cnt,i) print(ans*(2**cnt))" p02766,s914592148,Accepted,"N, K = map(int, input().split()) digits = 0 while(N > 0): N = N//K digits = digits+1 print(digits)" p02623,s879019483,Accepted,"from itertools import accumulate from bisect import bisect n, m, k = map(int, input().split()) a = [*accumulate(map(int, input().split()), initial=0)] b = [*accumulate(map(int, input().split()), initial=0)] print(max(i - 1 + bisect(b, k - x) for i, x in enumerate(a) if x <= k)) " p03659,s246264229,Accepted,"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() n = ni() a = na() import numpy as np a = list(np.cumsum(a)) ans = 100000000000000000 for i in range(n-1): ans = min(ans, abs(a[-1]-a[i]*2)) print(ans)" p02695,s360453089,Wrong Answer,"import itertools N,M,Q = map(int,input().split()) T=[tuple(map(int,input().split())) for _ in range(Q)] ans=0 for v in itertools.combinations(range(1,M+1),N): tmp=0 for a,b,c,d in T: if v[b-1]-v[a-1]==c: tmp+=d ans=max(ans,tmp) print(ans)" p03455,s823990946,Wrong Answer,"a,b=map(int,input().split()) product=a*b if product%2==0: print(""even"") else: print(""odd"")" p03136,s702967430,Accepted,"N = int(input()) L = list(map(int,input().split())) l = max(L) L.remove(l) if l < sum(L): print(""Yes"") else: print(""No"")" p03284,s946592218,Accepted,"N, K = map(int, input().split()) if N % K == 0: print(0) else: print(1)" p03210,s958111705,Accepted,"X = int(input()) res = [3, 5, 7] print('YES' if X in res else 'NO')" p03759,s806275941,Accepted,"a,b,c=map(int, input().split()) if b-a==c-b: print('YES') else: print('NO')" p02838,s955235760,Accepted,"n = int(input()) a = tuple(map(int, input().split())) ans = 0 for j in range(61): one = 0 zero = 0 for i in a: if (i >> j) & 1 == 1: one += 1 else: zero += 1 ans += one*zero*2**j ans %= 10**9 + 7 print(ans)" p03211,s816386060,Accepted,"S = input() ans = 10**10 for i in range(len(S)-2): n = int(S[i:i+3]) ans = min(ans, abs(n-753)) print(ans)" p03387,s287441670,Accepted,"a, b, c = map(int, input().split()) abc = sorted([a, b, c]) even = 0 for i in abc: if i % 2 == 0: even += 1 ans = 0 if even == 0 or even == 3: ans = (abc[2] - abc[0]) // 2 + (abc[2] - abc[1]) // 2 elif even == 1: abc = [i + 1 if i % 2 == 1 else i for i in abc] ans = (abc[2] - abc[0]) // 2 + (abc[2] - abc[1]) // 2 + 1 else: abc = [i + 1 if i % 2 == 0 else i for i in abc] ans = (abc[2] - abc[0]) // 2 + (abc[2] - abc[1]) // 2 + 1 print(ans)" p03254,s715577178,Accepted,"def resolve(): N, x = [int(i) for i in input().split()] A = sorted([int(i) for i in input().split()]) sumA = 0 cnt = 0 for i in range(N): if A[i] <= (x - sumA): sumA += A[i] cnt += 1 else: break else: if sumA != x: cnt -= 1 print(cnt) resolve() " p03730,s729650264,Wrong Answer,"A, B, C = map(int, input().split()) for i in range(1, 10000): if ((B*i)+C)%A==0: count=1 break else: count=0 print(""No"" if count==0 else ""Yes"")" p02939,s942730827,Accepted,"s = input() ans = 1 l = s[0] cnt = 0 l_cnt = 0 for char in s[1:]: if (char == l and cnt == 0 and l_cnt== 0): cnt += 1 continue else: l_cnt = cnt cnt = 0 l = char ans += 1 print(ans) " p03419,s727005286,Accepted,"N,M = map(int,input().split()) if N ==1 and M == 1: print(1) elif N == 1 or M == 1: print((N -2)*(M -2)*(-1)) else: print((N-2)*(M-2)) " p03087,s531003403,Accepted,"N,Q = (int(X) for X in input().split()) S = input() T = [0]*(N+1) for I in range(0,N): T[I+1] = T[I] + (S[I:I+2]=='AC') for J in range(0,Q): L,R = (int(X)-1 for X in input().split()) print(T[R]-T[L])" p02862,s715707605,Accepted,"X,Y = map(int,input().split()) M = 10**9+7 if X%3 == Y%3 == 1 or X%3 == Y%3 == 2: Answer = 0 else: dif = abs(X-Y) W = (min(X,Y) - dif)//3 X1 = W + dif Y1 = W Answer = 1 N = X1+Y1 for i in range(1,X1+1): Answer = (Answer*(N)*pow(i,-1,M))%M N -= 1 for j in range(1,Y1+1): Answer = (Answer*(N)*pow(j,-1,M))%M N -= 1 print(Answer)" p02556,s978789100,Wrong Answer,"n = int(input()) x = [] y = [] distance = [] for i in range(n): x1, y1 = input().split() x1 = int(x1) y1 = int(y1) x.append(x1) y.append(y1) for i in range(len(x)-1): temp = abs(x[i] - x[1+i]) + abs(y[i] - y[1+i]) distance.append(temp) max = distance[0] for i in range(1,len(distance)-1): if distance[i] >= max: max = distance[i] print(max)" p02760,s028302926,Accepted,"a = [list(map(int, input().split())) for _ in range(3)] n = int(input()) b = [int(input()) for _ in range(n)] bingo = 'No' for t in zip(*a): a.append(list(t)) a.append([a[i][i] for i in range(3)]) a.append([a[i][2-i]for i in range(3)]) for line in a: if all(item in b for item in line): bingo = 'Yes' break print(bingo) " p02963,s272200140,Wrong Answer,"S = int(input()) x3 = 0 y3 = 0 a = int(S**0.5) if S<=10**9: x1 = S y1 = 0 x2 = 0 y2 = 1 elif S==10**18: x1 = 10**9 y1 = 0 x2 = 0 y2 = 10**9 else: x1 = a+1 y2 = a y1 = 1 x2 = S-x1*y2 print(x1,y1,x2,y2,x3,y3)" p03645,s926089519,Accepted,"n,m = map(int, input().split()) set_a = set() set_b = set() AB = [list(int(x) for x in input().split()) for _ in range(m)] for a,b in AB: if a > b: a,b = b,a if a == 1: set_a.add(b) if b == n: set_b.add(a) se = set_a & set_b print('POSSIBLE' if se else 'IMPOSSIBLE')" p03352,s750209806,Accepted,"import numpy as np X = int(input()) ans = 1 for b in range(2, 1+int(np.ceil(np.sqrt(X)))): p = 0 while np.power(b, p) <= X: p += 1 p -= 1 ans = max(ans, np.power(b, p)) print(ans) " p02766,s175836461,Accepted,"N,K=map(int,input().split()) ans=1 a=K while N>=a: ans+=1 a=a*K print(ans) " p02664,s344029437,Wrong Answer,"t = list(input()) if t[0] == ""?"": t[0] = ""P"" for i in range(1, len(t)): if t[i] ==""?"": if t[i-1] == ""D"": t[i] = ""P"" else: t[i] = ""D"" print("""".join(t))" p03073,s823342178,Wrong Answer,"s = input() x = 0 y = 0 for i in range(len(s)): if i % 2 != int(s[i]): x += 1 for j in range(len(s)): if i % 2 == int(s[j]): y += 1 print(min(x, y))" p02622,s780195560,Accepted,"a = input() b = input() cnt = 0 for i in range(len(a)): cnt += a[i] != b[i] print(cnt)" p02766,s818728609,Accepted,"N, K = [int(v) for v in input().strip().split()] cnt = 0 while True: cnt += 1 N = N // K if N == 0: break print(cnt)" p03262,s915148058,Wrong Answer,"import fractions import functools N, X = map(int, input().split()) cities = [] for city in list(map(int, input().split())): cities.append(city - X) print(functools.reduce(fractions.gcd, cities)) " p03417,s329152007,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: print((n-2) * (m-2))" p04045,s409026110,Accepted,"N,K=map(int,input().split()) s=''.join(list(map(str,input().split()))) while True: t=str(N) for l in t: if l in s: N+=1 break if(N==int(t)): print(t) exit()" p03693,s603886873,Accepted,"r,g,b = map(str,input().split()) rgb = int( r + g + b ) print( 'YES' if rgb % 4 == 0 else 'NO' )" p03745,s780483194,Accepted,"import sys input = sys.stdin.readline N = int(input()) A = list(map(int,input().split())) B = [] for i in range(1,N): if A[i] - A[i-1] != 0: B.append(A[i] - A[i-1]) cnt = 0 for i in range(1,len(B)): if i >1: if B[i-1]*B[i-2] < 0 : continue if B[i]*B[i-1]<0: cnt += 1 B[i]=0 print(cnt+1)" p02847,s768525750,Accepted,"weekday = input() list = ['SUN','MON','TUE','WED','THU','FRI','SAT'] next = 7 - list.index(weekday) print(next)" p02831,s421038046,Accepted,"import fractions a,b=map(int,input().split()) c=a*b//(fractions.gcd(a,b)) print(c)" p02630,s195112449,Accepted,"import sys from collections import Counter,defaultdict imput = sys.stdin.readline N = int(input()) A = list(map(int,input().split())) Q = int(input()) ans = sum(A) A = Counter(A) for i in range(Q): b,c = map(int,input().split()) tmp = A.pop(b,None) if tmp: ans += (c-b)*tmp print(ans) if c in A: A[c] += tmp else: A[c] = tmp else: print(ans)" p02973,s356942063,Wrong Answer,"import sys from bisect import bisect_right read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 def main(): N, *A = map(int, read().split()) vec = [INF] * N for a in reversed(A[:-1]): vec[bisect_right(vec, a)] = a print(N - vec.count(INF)) return if __name__ == '__main__': main() " p03479,s528600573,Accepted,"x, y = map(int,input().split()) ex = y//x #print(""ex"",ex) counter = 1 exCount = 1 while True: if exCount * 2 > ex: break else: counter += 1 exCount *= 2 print(counter) " p02791,s881932262,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) " p02862,s430608244,Wrong Answer,"x,y=map(int,input().split()) n=(2*y-x)//3 m=(2*x-y)//3 t=min(m,n) T=1 for i in range(t): T*=m+n-i S=1 for i in range(1,t+1): S*=i print(T//S)" p03457,s349276066,Accepted,"n=int(input()) a = [0]*(n+1) a[0] = [0, 0, 0] for i in range(n): a[i+1]=list(map(int,input().split())) flag = True for i in range(n): if abs(a[i+1][1]-a[i][1])+abs(a[i+1][2]-a[i][2]) > (a[i+1][0]-a[i][0]): flag=False elif (abs(a[i+1][1]-a[i][1])+abs(a[i+1][2]-a[i][2])-(a[i+1][0]-a[i][0]))%2==1: flag=False if flag: print(""Yes"") else: print(""No"") " p02831,s256499413,Wrong Answer,"num = [int(s) for s in input().split()] com = 1 tes = 2 if max(num)%min(num) == 0: print(max(num)) else: while tes < min(num)**0.5: if min(num)%tes == 0 and max(num)%tes == 0: com *= tes num = [int(n/tes) for n in num] else: tes += 1 print(com*min(num)*max(num))" p03076,s797796226,Accepted,"ans = 0 m = 0 for _ in range(5): a = int(input()) for i in range(10): if (a+i)%10 == 0: ans += a+i if i != 0: m = max(m,i) print(ans-m) " p02948,s747724434,Accepted," import heapq N, M = map(int, input().split()) T = [] for i in range(N): a, b = map(int, input().split()) T.append((a, b)) T.sort() heap = [] heapq.heapify(T) i = 0 ans = 0 for limit in range(1, M+1): while (i < N) and (T[i][0] <= limit): cost, value = T[i] heapq.heappush(heap, -value) i += 1 if heap: ans += -heapq.heappop(heap) print(ans)" p03309,s107503845,Accepted,"N = int(input()) A = list(map(int, input().split())) B = [0]*N for i in range(N): B[i] = A[i] - i B.sort() res = 0 x = B[N//2] for i in range(N): res += max(x - B[i], -x + B[i]) print(res)" p03951,s659297887,Accepted,"import sys N = int(input()) s = input() t = input() for i in range(N): flg = True for j in range(N - i): if s[i + j] != t[j]: flg = False break if flg: print(N + i) sys.exit() print(2 * N) " p02615,s656856789,Accepted,"n=int(input()) a=list(map(int,input().split())) a.sort(reverse=True) ans=a[0] del a[0] num=0 n-=2 while n>0: if n==1: ans+=a[num] n-=1 else: ans+=a[num]*2 n-=2 num+=1 print(ans)" p03838,s657337388,Wrong Answer,"x, y = map(int, input().split()) if x == y: print(0) elif abs(x) == abs(y): print(1) else: if x <= y: print(y-x) else: print(x-y+2) " p03767,s547921819,Accepted,"n = int(input()) a = list(map(int, input().split())) a.sort(reverse=True) print(sum(max(a[n:2*n], [a[2*i+1] for i in range(n)])))" p02726,s251121546,Accepted,"def LI(): return [ int(s) for s in input().split() ] N,X,Y = LI() dist = [0]*(N-1) for i in range(1,N): for j in range(i+1,N+1): d = min(abs(i-j), abs(i-X)+abs(j-Y)+1) dist[d-1]+=1 [print(d) for d in dist]" p03836,s496347107,Accepted,"sx,sy,tx,ty=map(int,input().split()) print('U'*(ty-sy)+'R'*(tx-sx)+'D'*(ty-sy)+'L'*(tx-sx)+'LU'+'U'*(ty-sy)+'R'*(tx-sx)+'RDRD'+'D'*(ty-sy)+'L'*(tx-sx)+'LU')" p02823,s740172494,Wrong Answer,"N, A, B = map(int, input().split()) if B-A%2 == 0: print((B-A)//2) else: print((B-A-1)//2+min(A-1, N-B)+1)" p02873,s531629617,Wrong Answer,"s = input() n = len(s) a = [0]*(n+1) for i in range(n): if s[i] == '<': a[i+1] = a[i] + 1 for i in range(-1, -n, -1): if s[i] == '>': a[i-1] = a[i] + 1 print(sum(a))" p02730,s886092721,Wrong Answer,"s = input() n = len(s) count = 0 ans = True while count <= n and ans == True: for i in range(1,n+1): if s[i-1]!=s[-i]: ans = False for i in range(1,int((n-1)/2)+1): if s[i-1]!=s[-i]: ans = False count += 1 if ans: print('Yes') else: print('No') " p02695,s221984280,Wrong Answer,"from itertools import product def score_check(A,L): point = 0 for a, b, c, score in L: temp = A[b - 1] - A[a - 1] if temp == c:point += score return point n, m, q = map(int,input().split()) l = [list(map(int,input().split())) for i in range(q)] num = 0 for i in product(list(range(1, m + 1)), repeat = n): #print(i) temp = score_check(i, l) if num < temp:num = temp print(num)" p02552,s629820298,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)] x=int(input()) if x==0: print(1) else: print(0 ) if __name__ == '__main__': resolve()" p04030,s160008203,Accepted,"s='' x=input() for i in range(len(x)): if x[i]=='B' and len(s)!=0:s = s[:-1] elif x[i]=='B' and len(s)==0:pass else:s += x[i] print(s)" p02712,s200493977,Accepted,"if __name__ == ""__main__"": N = int(input()) result = 0 for i in range(1, N+1): if i % 3 == 0 or i % 5 == 0: continue result += i print(result) " p03761,s677350870,Accepted,"from collections import Counter n=int(input()) S=[input() for i in range(n)] nes=set(S[0]) for i in range(1,n): nes=nes&set(S[i]) nes=list(nes) words={} for i in range(n): for chr,cnt in Counter(S[i]).items(): if chr in nes: if chr not in words:words[chr]=cnt else:words[chr]=min(words[chr],cnt) ans="""" for i,j in sorted(words.items()): ans +=i*j print(ans)" p03323,s142023114,Wrong Answer,"a,b=map(int,input().split()) if a<9 and b<9: print(""yay!"") else : print("":("") " p03861,s579923084,Accepted,"a,b,x=map(int,input().split()) print(b//x-(a+x-1)//x+1)" p02802,s809617629,Accepted,"# coding: utf-8 import re import math #import numpy as np #main n,m=map(int,input().split()) MAP={} PS=[] for a in range(m): s,t=input().split() if(not s in MAP):MAP[s]=[] MAP[s].append(t) ac=0 wa=0 for a,b in MAP.items(): if(not ""AC"" in MAP[a]):continue for c in b: if(c==""WA""): wa+=1 else: ac+=1 break print(ac,wa)" p03475,s582032066,Accepted,"N = int(input()) T = 0 t = 0 ans = [] for i in range(N-1): C, S, F = map(int, input().split()) for j in range(len(ans)): if ans[j] <= S: ans[j] = S+C elif ans[j]%F != 0: ans[j] = ans[j]+F-(ans[j] % F)+C else: ans[j] += C ans.append(S+C) for a in ans: print(a) print(0) " p02933,s719085906,Accepted,"a = int(input()) s = input() if a >=3200: print(s) else: print('red')" p02661,s438410456,Wrong Answer,"n=int(input()) a=[0]*n b=[0]*n for i in range(n): a[i],b[i]=map(int, input().split()) a=sorted(a) b=sorted(b) if n%2!=0: ans=b[(n-1)//2]-a[(n-1)//2]+1 else: ans=(b[(n)//2-1]-a[(n)//2-1])*2+1 print(ans)" p03943,s090581148,Accepted,"a,b,c = sorted(map(int,input().split()),reverse=True) print(""Yes"") if a==b+c else print(""No"")" p03494,s329525217,Accepted,"def T(N,A): t = 1 for i in range(N): if A[i]%2 == 1: t = 0 return t def W(b): return b/2 N = int(input()) A = list(map(int,input().split())) count = 0 t = T(N,A) while t == 1: A = list(map(W,A)) count += 1 t = T(N,A) print(count) " p03761,s510620535,Wrong Answer,"N = int(input()) S = [] for i in range(N): S.append(input()) al = [chr(ord('a') + i) for i in range(26)] out = dict(zip(al,[100]*26)) # print(out) for i in range(N): dam = dict(zip(al,[0]*26)) for T in S[i]: dam[T] += 1 #辞書Tに+1 for key in out.keys(): out[key] = min(out[key], dam[key]) outS = """" for key in out.keys(): outS+=key*out[key] print(outS) " p02993,s082221857,Accepted,"s=input() print('Bad' if s[0]==s[1] or s[1]==s[2] or s[2]==s[3] else 'Good')" p02996,s837136706,Accepted,"def task(): n = int(input()) time_task = [] for i in range(n): a,b = map(int,input().split()) time_task.append([b,a]) #print(sorted(time_task)) time_task.sort() total_time = 0 for j in range(n): total_time += time_task[j][1] limit = time_task[j][0] if total_time > limit: return 'No' return 'Yes' print(task())" p02831,s995763723,Accepted,"import math A, B = [int(i) for i in input().split()] print((A * B) // math.gcd(A, B)) " p02628,s211333310,Accepted,"from sys import stdin #, setrecursionlimit, stdout #setrecursionlimit(1000000) #from collections import deque #from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin def ii(): return int(stdin.readline()) def fi(): return float(stdin.readline()) def mi(): return map(int, stdin.readline().split()) def fmi(): return map(float, stdin.readline().split()) def li(): return list(mi()) def si(): return stdin.readline().rstrip() def lsi(): return list(si()) #mod=1000000007 res=['Yes', 'No'] ############# CODE STARTS HERE ############# test_case=1 while test_case: test_case-=1 n, k=mi() a=li() a.sort() print(sum(a[:k]))" p02697,s988924826,Accepted,"import math n,m=map(int,input().split()) A=[] if n%2==1: for i in range(m): A.append([i+1,n-i]) else: d=n//2-1 h=math.ceil(d/2) for i in range(min(h,m)): A.append([i+1,n-i]) if h b else a ans = [] for i in range(1, m+1): if a % i == 0 and b % i == 0: ans.append(i) print(ans[-k])" p03962,s137583143,Accepted,"r = list(map(int,input().split())) a = [0]*100 for i in r: a[i-1]=1 print(sum(a)) " p02744,s193668910,Accepted,"def dfs(S): if len(S) == N: ans.append(S) else: for c in range(max(S) + 2): dfs(S + [c]) N = int(input()) ans = [] dfs([0]) for li in ans: print("""".join(chr(c + ord(""a"")) for c in li)) " p02833,s818211382,Accepted,"N = int(input()) ans = 0 if N%2 == 0: N //= 2 for i in range(40): ans += N//5 N = N//5 print(ans)" p03835,s822546863,Accepted,"k,s=map(int,input().split()) ans=0 for i in range(k+1): for j in range(k+1): if i+j<=s and i+j+k>=s: ans+=1 print(ans)" p02918,s702624976,Wrong Answer,"N,K = (int(x) for x in input().split()) S = list(input()) i = 0 ans = N while i < len(S)-1: if S[i] == 'R' and S[i+1] == 'L': if K == 0: ans -= 2 else: K -= 1 i += 1 if S[0] == 'L': if K > 0: K -= 1 else: ans -= 1 if S[N-1] == 'R': if K > 0: K -= 1 else: ans -= 1 print(ans) " p02689,s172316663,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)) print(result)" p03817,s047700049,Wrong Answer,"#!/usr/bin/env python3 x = int(input()) if x <= 11: print(2) else: print(x//11 * 2 + 1) " p03427,s523430044,Wrong Answer,"N = int(input()) keta = len(str(N)) SN = str(N) if N <= 9: print(N) elif SN.count('9') == keta: print(N) elif SN.count('9') == keta-1 and SN[0] != '9': print((keta - 1) * 9 + int(SN[0])) else: print((keta - 1) * 9 + int(SN[0])-1)" p03360,s840810923,Accepted,"A, B, C = map(int, input().split()) K = int(input()) M = max(A, B, C) ans = (A + B + C) - M + M * pow(2, K) print(ans)" p04020,s238520389,Wrong Answer,"N = int(input()) A = [int(input()) for i in range(N)] ans = 0 for i in range(N-1): ans += (A[i] + A[i+1])//2 A[i+1] = min(A[i+1], (A[i] + A[i+1]) % 2) if N == 1: print(N//2) exit() print(ans) " p02570,s252084390,Accepted,"D,T,S=map(int,input().split()) if T >= D/S: print('Yes') else: print('No')" p03785,s679534706,Accepted,"from bisect import bisect_right N,C,K = map(int,input().split()) T = sorted([int(input()) for _ in range(N)]) cur = 0 cnt = 0 while cur=W: a=H else: a=W while a*i= 3200: print(s) else: print(""red"")" p03041,s789311900,Accepted,"N, K = [int(s) for s in input().split(' ')] S = input() k = K - 1 print(S[:k] + S[k].lower() + S[k+1:]) " p03274,s666604485,Accepted,"N, K = map(int, input().split()) li = list(map(int, input().split())) ans = 10**10 for i in range(N - K + 1): left = li[i] right = li[i + K - 1] ans = min(ans, min(abs(left), abs(right)) + right - left) print(ans)" p03281,s275164646,Accepted,"N = int(input()) ans = 0 for i in range(1, N + 1, 2): cnt = 0 for j in range(1, N + 1): if i % j == 0: cnt += 1 if cnt == 8: ans += 1 print(ans)" p02677,s542030556,Accepted," def main(): a, b, h, m = map(int, input().split()) from math import sin, cos, pi, sqrt ar = pi/2 - 2*pi/12*h - 2*pi/60/12*m br = pi/2 - 2*pi/60*m ax, ay = a * cos(ar), a * sin(ar) bx, by = b * cos(br), b * sin(br) c = sqrt((ax-bx)**2+(ay-by)**2) print(c) if __name__ == ""__main__"": main() " p02847,s889295596,Accepted,"a=['MON','TUE','WED','THU','FRI','SAT','SUN'] b=input() print(6-a.index(b) if b!='SUN' else '7')" p04045,s109574769,Accepted,"N, K = list(map(int, input().split())) D = list(map(int, input().split())) D = set(D) while True: S = str(N) for s in list(S): if int(s) in D: N += 1 break else: break continue print(N) " p02702,s931092380,Wrong Answer,"a=input() n=len(a) t=0 for i in range(n-4): if i k: print(""Unfair"") elif k % 2 == 0: print(a - b) else: print(b - a) " p02678,s661736344,Wrong Answer,print('No') p02665,s474063211,Accepted,"N = int(input()) A = list(map(int, input().split())) if N == 0: if A[0] != 1: print(-1) else: print(1) exit() leaf = [] miki = [] under = 1 for i, a in enumerate(A): if a > under: print(-1) exit() miki.append(under - a) under = miki[-1] * 2 ans = 0 child = 0 for i in reversed(range(N + 1)): child = min(child, miki[i]) + A[i] ans += child print(ans)" p02729,s532981030,Accepted,"n,m=map(int,input().split()) print ((n*(n-1)//2)+(m*(m-1)//2))" p03767,s972419657,Accepted,"N = int(input()) a_list = list(map(int,input().split())) a_list.sort(reverse=True) sum = 0 for i in range(1, 2*N, 2): sum += a_list[i] print(sum)" p03293,s872111674,Wrong Answer,"s = input() t = input() s_len = len(s) for i in range(s_len-1): if s == t: print(""Yes"") exit() s = s[s_len-1] + s[0:s_len-1] print(""No"")" p02687,s080738684,Accepted,"s = input() if s[1] == 'B': print(""ARC"") else: print(""ABC"")" p03471,s838381950,Wrong Answer,"N, Y = map(int, input().split()) total = 0 for x in range(N + 1): for y in range(N + 1 - x): for z in range(N + 1 - x - y): if Y == 10000 * x + 5000 * y + 1000 * z: total = total + 1 ans = str(x) + "" "" + str(y) + "" "" + str(z) print(ans) break else: continue if total ==0: print(""-1 -1 -1"") " p03037,s320463885,Accepted,"n,m = map(int,input().split()) l,r = map(int,input().split()) for i in range(m-1): nl,nr = map(int,input().split()) if l nr: r = nr print(max(r-l + 1, 0)) " p03103,s637648758,Accepted,"n,m = map(int,input().split()) s = [] ans = 0 for i in range(n): a,b = map(int,input().split()) s.append([a,b]) s.sort() for i in s: if m k: l = m else: r = m print(math.ceil(l))" p03543,s523637162,Accepted,"a,b,c,d=input() print(""Yes"" if a==b==c or b==c==d else ""No"")" p02708,s723403818,Wrong Answer,"import math n, k = map(int, input().split("" "")) w = list(range(n + 1)) a = [0 for _ in range(n)] mx = sum(w[(n // 2) + 1:]) - sum(w[:(n // 2) + 1]) + 1 a[(n // 2)] = mx cnt = 1 prev = mx for i in range((n // 2) - 1, -1, -1): a[i] = prev - cnt a[n - i - 1] = prev - cnt cnt += 2 prev = a[i] print(sum(a[k - 1:]) + 1)" p03795,s161841264,Wrong Answer,"INF = 1000000007 def modmulti(a, b): # aとbを掛けた値をmodする(a * b mod p) res = 0 mod = a % INF while b > 0: if b == 1: res += mod if res > INF: res -= INF mod <<= 1 if mod > INF: mod -= INF b >>= 1 return res N = int(input()) ans = 1 for i in range(1, N + 1): ans = modmulti(ans, i) print(ans)" p02814,s812477224,Accepted,"n,m = map(int,input().split()) a = list(map(int,input().split())) import math lcm = 1 for i in range(n): b = a[i]//2 lcm = lcm*b //math.gcd(lcm,b) if any(2*lcm//i % 2 == 0 for i in a): print(0) else: print((m-lcm)//(2*lcm) + 1)" p03438,s155959038,Wrong Answer,"N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) allSousa = sum(B)-sum(A) atob = 0 for a, b in zip(A, B): if a < b: atob += (b-a)//2 if atob < allSousa: print(""Yes"") else: print(""No"") " p03774,s957158514,Wrong Answer,"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=[0 for i in range(N)] for i in range(N): dis=10**6 for j in range(M): xx=abs(ab[i][0]-cd[j][0]) yy=abs(ab[i][1]-cd[j][1]) temp=xx+yy if dis>temp: dis=temp ans[i]=j for a in ans: print(a+1)" p03360,s823343144,Wrong Answer,"nums = list(map(int, input().split())) K = int(input()) max_num = max(nums) ans = 0 for num in nums: if max_num == num: ans += num * (2 ** K) else: ans += num print(ans)" p02996,s344440810,Accepted,"n=int(input()) num=[] def ap(num1): num.append(num1) for i in range(n): ap(list(map(int,input().split()))) num2=0 str1= lambda val: val[1] num.sort(key=str1) ans=0 for i in range(n): num2+=num[i][0] if num2>num[i][1]: ans=1 break if ans==1: print(""No"") else: print(""Yes"") " p03814,s808866903,Accepted,"S = input() f=0 l=0 for i in range(len(S)): if(S[i] ==""A""): f = i+1 break for j in range(len(S)-1,0,-1): if(S[j] == ""Z""): l = j+1 break print(l-f+1)" p02683,s514079264,Wrong Answer,"import numpy as np import itertools N,M,X = map(int,input().split( )) CA = np.array([list(map(int,input().split( ))) for _ in range(N)]) A = CA[:,1:] C = CA[:,0] ans = -1 for i in range(N): money = [] xs = [] for j in itertools.permutations(np.arange(N),i+1): x = np.min(np.sum(A[list(j)],0)) xs.append(x) if x >= X: money.append(np.sum(C[list(j)])) if np.max(xs) >= X: ans = np.min(money) break print(ans)" p03105,s009342680,Wrong Answer,"a,b,c = map(int,input().split()) print(a//b) if a//b 0: order = 1 else: order += 1 res[index] = [ken, order] # print(res) for i in range(m): ken = str(res[i][0]).zfill(6) order = str(res[i][1]).zfill(6) print(ken + order) " p02729,s306370613,Wrong Answer,"val = input().split(' ') n = int(val[0]) m = int(val[1]) result = n * (n-1) / 2 + m * (m-1) / 2 print(result) " p03254,s369587104,Accepted,"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] >=0: ans += 1 x -= a[i] else: break if x == 0 or ans < N: print(ans) else: print(ans-1)" p02700,s212472631,Accepted,"import sys import math # input処理を高速化する input = sys.stdin.readline A,B,C,D = map(int,input().split()) while True: C=C-B if C<=0: print('Yes') exit(0) A=A-D if A<=0: print('No') exit(0)" p02820,s918548567,Wrong Answer,"N,K = map(int,input().split()) R,S,P = map(int,input().split()) T = str(input()) lst = [] for i in range(len(T)): if T[i] == 'r': lst.append(P) elif T[i] == 's': lst.append(R) else: # T[i] == 'p' lst.append(S) for j in range(N): if j >= K and lst[j] == lst[j-K]: lst[j] = 0 print(sum(lst))" p03385,s864369982,Accepted,"print(""YNeos""[not ''.join(sorted(input()))==""abc""::2]) " p02811,s709606153,Accepted,"k,x = map(int,input().split()) if 500 * k >= x : print('Yes') else: print('No') " p03773,s051093114,Accepted,"A, B = map(int, input().split()) if A + B < 24: print(A + B) else: print(A + B - 24)" p02555,s569281528,Accepted,"from scipy.special import comb s = int(input()) mod = 10**9 + 7 d = s // 3 ans = 0 for i in range(d): ans += comb((s-3*(i+1))+i,i,exact=True) % mod print(ans % mod)" p02771,s291371801,Accepted,print('Yes' if len(set(input().split()))==2 else 'No') p02866,s945530487,Accepted,"n,*a=map(int,open(0).read().split()) mod=998244353 b=[0]*n for i in a: b[i]+=1 ans=0 if a[0]==0 and 1==b[0]: ans=1 for i,j in zip(b,b[1:]): ans=ans*i**j%mod print(ans)" p02933,s645471894,Wrong Answer,"print('red') if int(input()) >= 3200 else print(input()) " p03495,s601628599,Accepted,"from collections import Counter def main(): N, K = map(int, input().split()) A = list(map(int, input().split())) unchange = sum(tuple[1] for tuple in Counter(A).most_common(K)) print(N-unchange) main()" p02957,s875429458,Accepted,"import sys import os def main(): if os.getenv(""LOCAL""): sys.stdin = open(""input.txt"", ""r"") A, B = list(map(int, sys.stdin.buffer.readline().split())) print((A+B)//2 if (A+B)%2 == 0 else 'IMPOSSIBLE') if __name__ == '__main__': main() " p03695,s689676822,Accepted,"n = int(input()) A = [int(i) for i in input().split()] c = 0 for i in A: c += 1 if i<3200 else 0 Am = set() for i in A: if i<3200: Am.add(i//400) minc = len(Am) if c>0 else len(Am)+1 AM = set([int(v)//400 if v<3200 else i+50 for i, v in enumerate(A)]) maxc = len(AM) print(minc, maxc)" p02664,s527152618,Accepted,"t = str(input()) a = [] cnt = 0 show = 0 for i in range(len(t)): if t[i] == '?': a.append('D') else: a.append(t[i]) print("""".join(a)) " p02899,s268583589,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)" p02909,s656447786,Accepted,"def main(): s = input() if s == 'Sunny': print('Cloudy') elif s == 'Cloudy': print('Rainy') else: print('Sunny') main()" p03797,s742967106,Accepted,"s,c = map(int,input().split()) ans = min(s,c//2) c -= ans*2 print(ans + c//4)" p03035,s221539374,Accepted,"A,B=map(int,input().split()) if A>=13: print(B) elif A>=6 and A<=12: print(B//2) else: print(0) " p04030,s669103022,Accepted,"S=list(input()) ans=[] for s in S: if s == ""B"": if len(ans)>0: del ans[-1] else: ans.append(s) print("""".join(ans))" p02959,s945119155,Accepted,"def resolve(): n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) ori = sum(a) for i in range(n): bt = b[i] if a[i] < bt: a[i+1] = max(a[i+1]-(bt-a[i]), 0) a[i] = 0 else: a[i] -= bt end = sum(a) print(ori-end) resolve()" p03282,s924913416,Wrong Answer,"S=input(); K=input(); i = 0; for i in range(len(S)) : if int(S[i]) > 1 : print(S[i]); break; " p02608,s274023698,Accepted,"N = int(input()) from collections import deque tmp = [] tmp = deque(tmp) num = [0]*(10**4*7) for i in range(1,10**2+1): tmp.append(i**2) for x in tmp: xx = int(x**0.5) for y in tmp: yy = int(y**0.5) for z in tmp: zz = int(z**0.5) ans = x + y + z + xx*yy + yy*zz + zz*xx num[ans] += 1 for i in range(1,N+1): print(num[i])" p02847,s059626615,Accepted,"week=['SUN','MON','TUE','WED','THU','FRI','SAT'] S=input() day=week.index(S) print(7-day)" p03962,s288662632,Accepted,"a, b, c = map(int, input().split()) s = set({a, b, c}) print(len(s))" p03617,s829039272,Accepted,"import sys def solve(): input = sys.stdin.readline Q, H, S, D = map(int, input().split()) N = int(input()) Double = [Q * 8, H * 4, S * 2, D] Single = [Q * 4, H * 2, S] if N % 2 == 0: print(min(Double) * N // 2) else: print(min(Double) * (N - 1) // 2 + min(Single)) return 0 if __name__ == ""__main__"": solve()" p02601,s919172059,Accepted,"R, G, B = map(int, input().split()) K = int(input()) for i in range(K): ng = i nb = K-i g = G * 2 ** ng b = B * 2 ** nb if R < g < b: print(""Yes"") break else: print(""No"") " p03760,s904565622,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)] o = input() n = input() for i in range(len(n)): print(o[i], end="""") print(n[i], end="""") if len(o) - len(n) == 1: print(o[:-1]) " p03721,s074066138,Accepted,"n,k=map(int,input().split()) d={} for _ in range(n): a,b=map(int,input().split()) if a in d: d[a]+=b else: d[a]=b s=0 for i in sorted(d): s+=d[i] if s>=k: print(i) exit() " p02779,s671684329,Accepted,"MOD = 1000000007 INF = float(""inf"") n = input() A = list(map(int, input().split())) h = set() for elem in A: if elem in h: print(""NO"") exit() h.add(elem) print(""YES"")" p02661,s679676269,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==0: sca=scb=N//2-1 lca=lcb=N//2 x=A[lca]+A[sca] y=B[lcb]+B[scb] print(y-x+1) else: ca=cb=N//2 ans=B[cb]-A[ca]+1 print(ans) " p03127,s718842864,Accepted,"from heapq import heapify, heappush, heappop def main(): N = int(input()) A = list(map(int, input().split())) heapify(A) while len(A) > 1: m = heappop(A) A = [a % m for a in A if a % m != 0] A.append((m)) print(m) if __name__ == ""__main__"": main()" p03162,s797258237,Accepted,"n = int(input()) abc = [[], [], []] abc = [list(map(int, input().split())) for _ in range(n)] # DB取得方法のみ違う, 分かればどっちでもok #print(abc) dp = [[0,0,0] for _ in range(n)] dp[0] = abc[0] #print(dp) for i in range(1, n): for j in range(3): for k in range(3): if j != k: dp[i][j] = max(dp[i][j], dp[i-1][k] + abc[i][j]) # ここのDB指定方法に影響 print(max(dp[-1]))" p03797,s123252473,Wrong Answer,"N,M = [int(i) for i in input().split()] S = 0 M += 2*N S = M // 4 print(S) " p02773,s009419285,Accepted,"from collections import Counter n = int(input()) s = [input() for _ in range(n)] cs = Counter(s).most_common() m = cs[0][1] ms = ([i for i in cs if i[1] == m]) for i in sorted(ms): print(i[0])" p02639,s855276762,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)" p03038,s060268370,Wrong Answer,"import bisect n,m=map(int,input().split()) A=list(map(int,input().split())) BC=[list(map(int,input().split())) for _ in range(m)] BC.sort(key=lambda x:(x[1],x[0])) for b,c in BC: A.sort() if A[0]>=c: break idx=bisect.bisect_left(A,c) for i in range(min(b,idx)): A[i]=c print(sum(A))" p02678,s001864508,Wrong Answer,"n,m=map(int,input().split()) l=[list(map(int,input().split())) for i in range(m)] a=[] for i in range(n-1): a.append([]) for i in range(m): a[l[i][0]-2].append(l[i][1]) a[l[i][1]-2].append(l[i][0]) k=[] k.append(1) while len(k)>0: for i in range(n-1): if k[0] in a[i]: a[i]=[k[0]] k.append(i+2) k.pop(0) print(""Yes"") for i in range(n-1): print(*a[i])" p02909,s259226357,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=='Sunny': print('Cloudy') elif s=='Cloudy': print('Rainy') else: print('Sunny') if __name__ == '__main__': do()" p02783,s412659248,Wrong Answer,"a,b=map(int,input().split()) if a%b==0: print(a/b) else: print(int(a/b)+1)" p02759,s132514003,Wrong Answer,"import math n = int(input()) print(math.floor(n/2))" p02647,s587144244,Accepted,"def action(A, N): B = [0] * N for i, bright in enumerate(A): s = max(0, i - bright) B[s] += 1 e = min(N, i + bright) if e < N - 1: B[e + 1] -= 1 for i in range(N - 1): B[i + 1] += B[i] return B def main(): N, K = map(int, input().split()) A = list(map(int, input().split())) for i in range(K): A = action(A, N) if (A[0] == N) & all(A): break print(*A, sep="" "") if __name__ == '__main__': main()" p03835,s775725551,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)" p03796,s839050469,Accepted,"#https://atcoder.jp/contests/abc055/tasks/abc055_b n = int(input()) ans=1 for i in range(1,n+1): ans=(ans*i)%(10**9+7) print(ans)" p03254,s993830673,Accepted,"N, x = map(int, input().split()) a = sorted(map(int, input().split())) ans = 0 for i in range(N): x -= a[i] if x < 0: break else: ans += 1 print(ans if x <= 0 else ans-1)" p02687,s899048734,Accepted,"ii = lambda : int(input()) mi = lambda : map(int,input().split()) li = lambda : list(map(int,input().split())) s = input() if s == ""ABC"": print(""ARC"") else: print(""ABC"")" p02600,s601849259,Accepted,"x = int(input()) print(8- (x - 400)//(200))" p02780,s490915048,Wrong Answer,"N, K = map(int, input().split(' ')) p = list(map(int, input().split(' '))) cumsum = [] cumsum_diff = 0 for i in range(N): if i == 0: cumsum.append((p[i] + 1)/2) else: cumsum.append(cumsum[i - 1] +( p[i] + 1)/2) # print(cumsum) for i in range(N - K + 1): if i <= N - K: if cumsum_diff < cumsum[i + K - 1] - cumsum[i-1]: cumsum_diff = cumsum[i + K - 1] - cumsum[i-1] print(cumsum_diff) " p02823,s996489829,Accepted,"N, A, B = map(int, input().split()) if (B-A)%2 == 0: print((B-A)//2) else: print(min((A+B)//2, (2*N-B-A+1)//2)) " p02933,s208303323,Wrong Answer,"A = int(input()) S = input() if A >= 3200: print(""red"") else: print(S)" p02935,s060775963,Accepted,"n = int(input()) v = list(map(int,input().split())) v = sorted(v) ans = v[0] for i in range(1,len(v)): ans = (ans + v[i]) /2 print(ans)" p03379,s107888614,Wrong Answer,"N = int(input()) X = list(map(int, input().split())) X.sort() center = len(X) // 2 med_l = X[center - 1] med_r = X[center] for n in range(N): if n <= center - 1: print(med_r) else: print(med_l)" p03161,s457121754,Accepted,"[N,K]=[int(i) for i in input().split()] h=[int(i) for i in input().split()] DP=[1000000000 for i in range(N)] DP[0]=0 for i in range(N): for j in range(max(i-K,0),i): DP[i]=min(DP[j]+abs(h[i]-h[j]),DP[i]) print(DP[N-1])" p03456,s350671629,Accepted,"a,b = input().split() c = int(a+b) x = (int(c**0.5))**2 if x == c: print(""Yes"") else: print(""No"")" p02959,s439845911,Accepted,"n=int(input()) monsters=list(map(int,input().split())) heroes=list(map(int,input().split())) ans=0 for i in range(n): if heroes[i]>monsters[i]: heroes[i]-=monsters[i] ans+=monsters[i] ans+=min(heroes[i],monsters[i+1]) monsters[i+1]-=min(heroes[i],monsters[i+1]) else: ans+=heroes[i] print(ans)" p03680,s864665911,Accepted,"def I(): return int(input()) def MI(): return map(int, input().split()) def LMI(): return list(map(int, input().split())) N = I() A = [I() for _ in range(N)] seen = set() i = 0 light = 1 while light != 2: seen.add(light) light = A[light - 1] if light in seen: print(-1) exit(0) i += 1 print(i) " p03062,s662895522,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 = sum(1 for a in A if a < 0) ans = sum(abs(a) for a in A) if neg % 2 == 1: ans -= 2 * min(abs(a) for a in A) print(ans) return if __name__ == '__main__': main() " p03944,s297326214,Accepted,"w,h,n=map(int,input().split()) b=[0,w,0,h] for i in range(n): x,y,a=map(int,input().split()) if a==1: b[0]=max(b[0],x) elif a==2: b[1]=min(b[1],x) elif a==3: b[2]=max(b[2],y) else: b[3]=min(b[3],y) print(max(b[1]-b[0],0)*max(b[3]-b[2],0))" p02639,s823237144,Accepted,"x = list(map(int, input().split())) for i in range(0, len(x)): if x[i]==0: print(i+1)" p03145,s730158034,Accepted,"# -*- coding: utf-8 -*- ab, bc, ca = map(int,input().split()) ans = ab * bc * ca // max(ab, bc, ca) print(ans // 2) " p03624,s931572924,Accepted,"# coding: utf-8 S = input() alp = ""abcdefghijklmnopqrstuvwxyz"" for a in alp: if a not in S: print(a) exit() print(""None"")" p03778,s520793813,Wrong Answer,"w,a,b=map(int,input().split()) print(min(abs(b-a-w),abs(a-b),abs(b+w-a))) " p02939,s582920347,Accepted,"s = input() l = [] prev = """" pres = """" cnt = 0 for i in s: pres += i #print(pres,prev) if pres!=prev: cnt += 1 prev = pres pres = """" print(cnt)" p03605,s720968651,Accepted,"a = input() print(""Yes"" if ""9"" in a else ""No"") " p03481,s649913893,Accepted,"x, y = map(int, input().split()) i = x ans = 1 while i*2 <= y: i *= 2 ans += 1 print(ans) " p02663,s194398232,Wrong Answer,"H1, M1, H2, M2, K = map(int, input().split()) H = (H2 - H1) * 60 M = M2 - M1 res = (H+M) - 30 if res > K: print((H+M) - 30) else: print(0)" p02922,s228721869,Accepted,"A, B = map(int, input().split()) if B == 1: print(0) exit() else: for i in range(20): if B <= A+i*(A-1): print(1+i) exit()" p04043,s152094397,Accepted,"a,b,c = map(int, input().split()) ans = ""NO"" if a+b+c == 17 and a*b*c == 175: ans = ""YES"" print(ans)" p04043,s464304678,Wrong Answer,"def main(): a, b, c = map(int, input().split()) list = [] list.append(a) list.append(b) list.append(c) if list.count(5) == 2 and list.count(7) == 1 : print(""Yes"") else : print(""No"") if __name__ == '__main__': main() " p02775,s897346121,Accepted,"s = input(); n = len(s); INF=1<<32 dp = [ [0,INF] for i in range(n+1) ] for i in range(n): d = int(s[i]) dp[i+1][0] = min(dp[i][0], dp[i][1])+d dp[i+1][1] = min(dp[i][0], dp[i][1]-2)+11-d print(min(dp[n][0],dp[n][1]))" p02718,s202058020,Wrong Answer,"data = input().split() n = int(data[0]) m = int(data[1]) pro = [int(s) for s in input().split()] vote = 0 for i in pro: vote += i if pro[m - 1] < 1 / (4 * vote): print(""No"") else: print(""Yes"") " p03730,s254049213,Accepted,"A,B,C= map(int,input().split()) for i in range(B) : if A*i%B == C : print('YES') exit() print('NO')" p03486,s126840462,Wrong Answer,"lst = [] s = sorted(list(input())) lst.append(s) t = sorted(list(input()),reverse=True) lst.append(t) lst.sort() if lst[0] == s: print(""Yes"") else: print(""No"")" p03693,s467467680,Accepted,"nums = list(map(str, input().split())) s = """".join(nums) n = int(s) if n % 4 == 0: print(""YES"") else: print(""NO"")" p03673,s544915813,Accepted,"N = int(input()) A = list(map(int,input().split())) ans = [0 for _ in range(N)] l = 0 r = N - 1 flg = 1 for i in range(N - 1, -1, -1): if flg: flg = 0 ans[l] = A[i] l += 1 else: flg = 1 ans[r] = A[i] r -= 1 print(*ans)" p02970,s415227416,Accepted,"import sys import os import math def main(): if os.getenv(""LOCAL""): sys.stdin = open(""input.txt"", ""r"") N, D = list(map(int, sys.stdin.readline().split())) look = 2 * D + 1 print(math.ceil(N / look)) if __name__ == '__main__': main() " p02748,s948456947,Accepted,"import sys def input(): return sys.stdin.readline().rstrip() def main(): a,b,m=map(int,input().split()) A=[int(_) for _ in input().split()] B=[int(_) for _ in 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) if __name__=='__main__': main()" p03778,s723974411,Accepted,"W, a, b = map(int, input().split()) if a > b: k = b b = a a = k if a + W >= b: print(0) else: print(b - (a + W))" p03495,s795774429,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) b = [0]*n for i in range(n): b[a[i]-1] += 1 c = [i for i in b if i != 0] c.sort() if len(c) - k > 0: print(sum((c[0:len(c)-k]))) else: print(0)" p03043,s974656537,Accepted,"import math N, K = map(int, input().split()) ans = 0 for n in range(1, N+1): if n >= K: ans += 1/N continue x = math.ceil(math.log2(K/n)) ans += (0.5**x)/N print(ans) " p02623,s300144228,Wrong Answer,"from itertools import accumulate import bisect N,M,K=map(int,input().split()) A=list(map(int,input().split())) B=list(map(int,input().split())) a=list(accumulate(A)) b=list(accumulate(B)) diff=2*10**9 count=0 for i in range(N): j=bisect.bisect_right(b,K-a[i])-1 if 0<=K-(a[i]+b[j])<=diff: diff=K-(a[i]+b[j]) count=max(count,(i+1)+(j+1)) print(count)" p02838,s761159250,Accepted,"n=int(input()) a=list(map(int,input().split())) #n=10 #a=[3, 1, 4, 1, 5, 9, 2, 6, 5, 3] #a=[3, 14, 159, 2653, 58979, 323846, 2643383, 27950288, 419716939, 9375105820] mod=10**9+7 asum=0 for i in range(60): zcnt=0 for ii in range(n): asht=a[ii]>>i if asht&1==0: zcnt+=1 tmp=(zcnt*(n-zcnt))%mod*((2**i)%mod) asum+=(tmp)%mod asum=asum%mod print(asum) " p02755,s996649905,Accepted,"a, b = map(int, input(). split()) ans = -1 for i in range(10001): if i*8//100 == a and i//10 == b: ans = i break else: ans = -1 print(ans)" p02663,s084829005,Wrong Answer,"H1, M1, H2, M2, K = list(map(int, input().split())) time = H2*60+M1-H2*60-M2 print(time-K)" p03073,s623378942,Accepted,"s = input() n = len(s) diff0 = 0 diff1 = 0 for i in range(n): m = int(s[i]) if i % 2 != m: diff0 += 1 else: diff1 += 1 print(min(diff0, diff1)) " p03011,s196426445,Accepted,""""""" author : halo2halo date : 9, Jan, 2020 """""" import sys # import numpy as np import itertools read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) P = [int(i) for i in read().split()] ans=sum(P) for i in itertools.combinations(P,len(P)-1): ans=min(ans,sum(i)) print(ans) " p03163,s165565296,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(1,W+1): if j-w<0: dp[i][j] = max(dp[i-1][j],dp[i][j-1]) else: dp[i][j] = max(dp[i-1][j-w]+v,dp[i-1][j]) print(max(max(dp)))" p02675,s251431318,Accepted,"N = int(input()[-1]) if N in [2,4,5,7,9]: print(""hon"") elif N in [0,1,6,8]: print(""pon"") elif N == 3: print(""bon"")" p02973,s541482138,Accepted,"def main(): import sys import bisect read = sys.stdin.buffer.read bisect_right = bisect.bisect_right N, *A = map(int, read().split()) dp = [A[-1]] for a in reversed(A[:-1]): if a >= dp[-1]: dp.append(a) else: dp[bisect_right(dp, a)] = a print(len(dp)) return if __name__ == '__main__': main() " p03994,s021953350,Wrong Answer,"s = list(map(str,input())) k = int(input()) ans = [0]*len(s) b = 123 for i in range(len(ans)): tmp = ord(s[i]) if i != len(ans)-1: if b - tmp <= k: k = k-(b - tmp) ans[i] = ""a"" else: ans[i] = s[i] else: tmp1 = k % 26 ans[i] = 96+tmp1 ans[i] = chr(ans[i]) print("""".join(ans))" p02888,s158867122,Accepted,"n=int(input()) l=list(map(int,input().split())) l.sort() from bisect import bisect_left ans=0 for i in range(n): for j in range(i+1,n): a=l[i] b=l[j] ans+=max(0,bisect_left(l,a+b)-j-1) print(ans) " p03352,s308093390,Accepted,"x = int(input()) maxx = 1 for i in range(1, x): for j in range(2, x): expx = i ** j if expx <= x: if maxx <= expx: maxx = expx else: break print(maxx)" p03145,s610714750,Wrong Answer,"a,b,c = map(int,input().split()) print(a*b/2)" p02724,s360564643,Accepted,"#!/usr/bin/env python3 import sys def solve(X: int): f=(X//500)*1000 ft=((X%500)//5)*5 print(f+ft) return # Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template) def main(): def iterate_tokens(): for line in sys.stdin: for word in line.split(): yield word tokens = iterate_tokens() X = int(next(tokens)) # type: int solve(X) if __name__ == '__main__': main() " p02608,s358995962,Wrong Answer,"N = int(input()) ans = list() for i in range(N+1): ans.append(0) for x in range(1,100): for y in range(1,100): for z in range(1,100): tmp = x**2 + y**2 + z**2 + x*y + y*z + z*x if tmp < N: ans[tmp] += 1 for i in range(N): print(ans[i+1])" p03241,s190757149,Wrong Answer,"N,M = map(int,input().split()) if M==1: print(1);exit() ans = 1 for i in range(2,min(int(M**(1/2))+2,int(M/N)+1)): if M%i==0: ans = i print(ans)" p02647,s991736662,Accepted,"from itertools import accumulate N, K = map(int, input().split()) A = list(map(int, input().split())) i = 0 for _ in range(min(K, 50)): B = [0] * (N + 1) for i, a in enumerate(A): j = max(0, i - a) B[j] += 1 j = min(N, i + a + 1) B[j] -= 1 B.pop() A = list(accumulate(B)) print(*A)" p03087,s435504911,Wrong Answer,"n,q=map(int,input().split()) s=input() t=[1 if a=='A' and 'C' else 0 for a,c in zip(s,s[1:])] + [0] for _ in range(q): l,r=map(int,input().split()) print(sum(t[l-1:r-1])) " p03219,s685128568,Accepted,"x,y=map(int,input().split()) print(x+y//2)" p02972,s833867247,Accepted,"N = int(input()) A = list(map(int, input().split())) box = [0] * (N+1) M = 0 ans = [] for i in range(N, 0, -1): tmp = 0 for j in range(i*2, N+1, i): tmp += box[j] tmp = tmp % 2 if tmp != A[i-1]: box[i] = 1 M += 1 ans.append(i) if M == 0: print(0) else: ans = ans[::-1] print(M) print(*ans) " p02897,s949315442,Wrong Answer,"N = int(input()) if N % 2 == 0: print((2/N)/N) else: print((2//N)/(N+1))" p02555,s829117235,Accepted,"s = int(input()) mod = 10**9+7 dp = [0 for i in range(s+1)] for i in range(3,s+1): for j in range(3,i-2): dp[i] += dp[j] dp[i] += 1 dp[i] %= mod print (dp[-1])" p02831,s705664530,Accepted,"def gcd(x, y): if x == 0: return y x, y = y % x, x return gcd(x, y) a, b = map(int, input().split()) ans = a * b // gcd(a, b) print(ans) " p03076,s142552852,Accepted,"import math dish=[int(input()) for _ in range(5)] count={str(i%10):[] for i in range(10,-1,-1)} for t in dish: one=t%10 count[str(one)].append(t) ans=0 d=0 for k,v in count.items(): if v!=[]: for c in v: if d>3: ans+=c else: ans+=math.ceil(c/10)*10 d+=1 print(int(ans))" p03408,s481968256,Accepted,"#!/usr/bin/env python3 def main(): N = int(input()) s = [input() for _ in range(N)] M = int(input()) t = [input() for _ in range(M)] y = 0 for ss in set(s): yy = s.count(ss) - t.count(ss) if y < yy: y = yy print(y) main() " p04031,s199693991,Accepted,"n = int(input()) l = list(map(int, input().split())) mn = min(l) mx = max(l) ms = 10**9 for j in range(mn, mx+1): s = sum([(i-j)**2 for i in l]) ms = min(ms, s) print(ms)" p03075,s658448579,Wrong Answer,"#A a = int(input()) b = int(input()) c = int(input()) d = int(input()) e = int(input()) k = int(input()) ant = [a,b,c,d,e] flg = True for i in range(5): for j in range(i,5): if i != j: dist = abs(ant[i]-ant[j]) if dist > k: flg = False break if flg: print('Yey!') else: print(':(')" p02584,s550085409,Accepted,"v = input().split("" "") x = int(v[0]) k = int(v[1]) d = int(v[2]) if (x == 0): if (k % 2 == 0): ans = 0 else: ans = d else: if ((k * d) > abs(x)): y = abs(x) // d ans = abs(abs(x) - y * d) if ((k - y) % 2 == 1): ans = abs(d - ans) else: ans = abs(x) - k * d print(ans)" p03145,s986306672,Accepted,"a,b,c = sorted(map(int,input().split())) print(int(a*b/2))" p02622,s673054600,Accepted,"import sys #input = sys.stdin.readline #input = sys.stdin.buffer.readline #sys.setrecursionlimit(10**9) #from functools import lru_cache def RD(): return sys.stdin.read() def II(): 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() #import numpy as np def main(): s=input() t=input() ans=0 for i in range(len(s)): if s[i]!=t[i]: ans+=1 print(ans) if __name__ == ""__main__"": main() " p02786,s874888281,Accepted,"h = int(input()) result, i = 0, 1 while h > 0: h //= 2 result += i i *= 2 print(result)" p03680,s826182810,Accepted,"n = int(input()) a= [int(input()) for _ in range(n)] count = 1 now = a[0] while now != 2 and count < n: now = a[now-1] count += 1 print(count if count=8: over += 1 else: rate.append(x[i]//400) result = """" elem = len(set(rate)) if elem >= 8: result = ""8 8"" elif elem + over >=8: result = str(elem) +"" "" +""8"" else: result = str(elem)+"" ""+ str(elem + over) print(result)" p02720,s349055960,Accepted,"K = int(input()) A = [1, 2, 3, 4, 5, 6, 7, 8, 9] for i in range(0, K): if A[i]%10 != 0: A.append(10*A[i]+A[i]%10-1) A.append(10*A[i]+A[i]%10) if A[i]%10 != 9: A.append(10*A[i]+A[i]%10+1) if len(A) >= K: break print(A[K-1])" p03386,s788855690,Accepted,"a, b, k = map(int, input().split()) prev = 0 for i in range(k): if a + i < b: print(a + i) prev = a + i for i in range(k)[::-1]: if b - i > prev: print(b - i)" p03817,s168540364,Accepted,"p, q = divmod(int(input()), 11) print(p*2 + (q and [1, 2][q > 6]))" p02706,s298648480,Accepted,"n,m=map(int,input().split()) a=list(map(int,input().split())) t=sum(a) if t>n: print(-1) else: print(n-t)" p03109,s753390709,Wrong Answer,"s = list(map(int, input().split('/'))) if s[1] > 5: print('TBD') else: print('Heisei')" p02744,s541877533,Accepted,"s=""abcdefghijklmnopqrstuvwxyz"" import sys sys.setrecursionlimit(10**6) def dfs(a,n,m): if len(a)==n: print(a) return for i in range(m): if i==m-1: dfs(a+s[i],n,m+1) else: dfs(a+s[i],n,m) n=int(input()) dfs("""",n,1)" p03317,s520014959,Accepted,"n,k=map(int,input().split()) a=[int(x) for x in input().split()] ans=(n-1)//(k-1) if (n-1)%(k-1)!=0: ans+=1 print(ans) " p02996,s516143754,Accepted,"N = int(input()) AB = [list(map(int,input().split())) for i in range(N)] AB.sort(key=lambda x:x[1]) time = 0 ans = ""Yes"" for i in range(N): time += AB[i][0] if time > AB[i][1]: ans = ""No"" break print(ans)" p02744,s278624180,Wrong Answer,"import itertools n=int(input()) r=[] for s in itertools.combinations_with_replacement('abcdefghij'[:n],n): for _r in r: for i in range(n): if ord(_r[0])-ord(_r[i]) != ord(s[0])-ord(s[i]): break else: break else: r.append(s) for i in range(len(r)): print(''.join(r[i]))" p02993,s067430996,Wrong Answer," # ABC131 # A Security S = input() sl = len(S) for i in range(sl-1): if S[i] == S[i-1]: print('Bad') exit() print('Good') " p03627,s407285259,Accepted,"n = int(input()) A = list(map(int, input().split())) from collections import Counter c = Counter(A) mul = [] for k, v in c.items(): if v >= 2: mul.append(k) if v >= 4: mul.append(k) mul.sort() if len(mul) < 2: print(0) else: print(mul[-1]*mul[-2])" p02772,s412322961,Wrong Answer,"line1 = input('') line2 = input('') result = True cnt = int(line1) list = line2.split(' ') if len(list) != cnt: result = False if result: for no_str in list: no = int(no_str) if no % 2 == 0: print(no) if no % 3 != 0 and no % 5 != 0: print(no) result = False if result : print('APPROVED') else: print('DENIED') " p02963,s253852047,Accepted,"# A - Triangle S = int(input()) N = int(10**9) y1 = (-S)%N x1 = (S+y1)//N print(x1,y1,1,N,0,0)" p04031,s191054228,Accepted,"ans=0 n=int(input()) res=0 a=list(map(int,input().split())) b=sum(a)//n c=b+1 for i in a: ans+=abs(i-b)**2 res+=abs(i-c)**2 print(min(ans,res))" p04033,s504771153,Accepted,"a,b = map(int, input().split()) if a > 0: print(""Positive"") elif b<0: if((b-a)%2 == 0): print(""Negative"") else: print(""Positive"") else: print(""Zero"")" p02578,s526515814,Accepted,"n = int(input()) As = list(map(int, input().split())) mx = 0 ans = 0 for a in As: if mx < a: mx = a else: ans += mx - a print(ans)" p03061,s160632113,Accepted,"from fractions import gcd N = int(input()) A = list(map(int, input().split())) L = [-1] * (N-1) L[0] = A[0] R = [-1] * (N-1) R[0] = A[-1] for i in range(1, N-1): L[i] = gcd(L[i-1], A[i]) for i in range(1, N-1): R[i] = gcd(R[i-1], A[-i-1]) ans = 0 for i in range(1, N-1): tmp = gcd(L[i-1], R[N-i-2]) ans = max(ans, tmp) ans = max(ans, L[N-2]) ans = max(ans, R[N-2]) print(ans) " p02946,s657781649,Accepted,"K, X = map(int, input().split()) print(' '.join([str(i) for i in range(X - K + 1, X + K)]))" p02910,s524914007,Accepted,"s=list(input()) count=0 for i in range(0,len(s),2): if s[i]=='L': count+=1 for j in range(1,len(s),2): if s[j]=='R': count+=1 if count==0: print(""Yes"") else: print(""No"")" p03478,s474340271,Accepted,"N,A,B = map(int,input().split()) sum = 0 for i in range(1,N+1): small_sum =0 for j in list(str(i)): small_sum += int(j) if small_sum >= A and small_sum <= B: sum += i print(sum) " p02718,s598305615,Accepted,"n,m=map(int,input().split()) a=[int(ss) for ss in input().split()] a=sorted(a,reverse=True) r=""Yes"" for ii in range(m): if a[ii]= 0: x -= num ans += 1 else: break if ans == n and x > 0: ans -= 1 print(ans) if __name__ == '__main__': main() " p02548,s614835329,Wrong Answer,"nn=int(input()) ans=0 for i in range(nn-2): c=i+1 for j in range(1,nn-c-1): if (nn-c) % j ==0: ans=ans+1 ans=ans+1 ans=ans+2 print(ans)" p03860,s737070149,Accepted,"print('A' + input().split()[1][0] + 'C') " p02689,s326974299,Accepted,"N, M = map(int, input().split()) H = list(map(int, input().split())) badN = set() for i in range(M): A, B = map(int, input().split()) if H[A-1]==H[B-1]: badN.add(A) badN.add(B) elif H[A-1]>H[B-1]: badN.add(B) else: badN.add(A) print(N-len(badN)) " p02910,s677801746,Accepted,"s = list(input()) odd = set(s[::2]) even = set(s[1::2]) if 'L' in odd or 'R' in even: print(""No"") else: print('Yes') " p03109,s774542005,Accepted,"a=""Heisei"" S=input() if int(S[5:7])<=4: print(a) else: print(""TBD"")" p03345,s664176776,Accepted,"A, B, C, K = map(int, input().split()) if K % 2 == 0: print(A - B) else: print(B - A) " p03329,s885863231,Wrong Answer,"import sys input = sys.stdin.readline def main(): N = int(input()) dp = [0] * (10 ** 5 + 1) dp[1] = 1 x = [1] x.extend([6 ** x for x in range(1, 7)]) x.extend([9 ** x for x in range(1, 5)]) for i in range(2, 10 ** 5 + 1): tmp = [] for v in x: if i >= v: tmp.append(dp[i - v] + 1) dp[i] = min(tmp) print(dp[N]) if __name__ == '__main__': main() " p03001,s338764903,Accepted,"# Code for C - Rectangle Cutting # Use input() to fetch data from STDIN [d, w, x, y] = [int(x) for x in input().split()] m = d * w / 2 r = 1 if d / 2 == x and w / 2 == y else 0 print(m, r) " p02860,s139477947,Accepted,"N = int(input()) S = input() if N % 2 == 1: print(""No"") else: S1 = S[:N//2] S2 = S[N//2:] if S1 == S2: print(""Yes"") else: print(""No"")" p03943,s615463926,Accepted,"a = list(map(int, input().split())) a.sort() if a[0] + a[1] == a[2]: print('Yes') else: print('No')" p02861,s533436267,Accepted,"from itertools import permutations import math n = int(input()) x = [] y = [] for i in range(n): xi, yi = map(int, input().split(' ')) x.append(xi) y.append(yi) list = [i for i in range(n)] total = 0 for i in permutations(list): norm = 0 for j in range(n-1): X = x[i[j+1]] - x[i[j]] Y = y[i[j+1]] - y[i[j]] norm += math.sqrt(X**2 + Y**2) total += norm print(total/math.factorial(n)) " p03434,s304537954,Wrong Answer,"N = int(input()) A = list(map(int, input().split())) A.sort() print(sum(A[::2]) - sum(A[1::2]))" p02612,s819097477,Accepted,"n = int(input()) if n % 1000 == 0: print(0) else: print(1000 -(n % 1000)) " p03328,s645606559,Wrong Answer,"a, b = map(int, input().split()) s = [0] * 1002 for i in range(1002): s[i] = s[i - 1] + i if (s[i] == a): print(i) if (s[i - 1] - a == s[i] - b): print(s[i - 1] - a) break print(s)" p03250,s443673100,Accepted,"l = list(map(int, input().split())) L = sorted(l) print(L[0] + int(str(L[2]) + str(L[1])))" p03071,s622502688,Wrong Answer,"s = list(input()) count = 0 for i in range(1, len(s)): if s[i-1] == s[i]: count += 1 if s[i] == '1': s[i] = '0' else: s[i] = '1' print(count)" p03250,s124759471,Accepted,"abc = list(map(int, input().split())) abc.sort(reverse=1) print(abc[0] * 10 + abc[1] + abc[2]) " p03013,s332077445,Accepted,"MOD = 1000000007 N, M = map(int, input().split()) A = [int(input()) for _ in range(M)] is_broken = [False for _ in range(N+1)] for a in A: is_broken[a] = True # dp[i] = (i段目に辿り着くルートの総数) # init dp = [0]*(N+1) dp[0] = 1 # DP for i in range(N): if not is_broken[i+1]: dp[i+1] += dp[i] dp[i+1] %= MOD if i+2 <= N: if not is_broken[i+2]: dp[i+2] += dp[i] dp[i+2] %= MOD print(dp[N])" p03243,s027036526,Wrong Answer,"N = int(input()) n = N for i in range(1000): n += 1 if str(n)[0] == str(n)[1] == str(n)[2]: ans = n break print(n)" p02621,s171405145,Accepted,"a = int(input()) print(a+(a**2)+(a**3))" p03456,s945304438,Accepted,"import sys import math (a,b)=input().split() c=a+b ci=int(c) s=int(math.sqrt(ci)) ss=s*s if ss == ci: print(""Yes"") else: print(""No"") " p03838,s255820043,Accepted,"a,b = map(int,input().split()) val = 0 if a*b < 0: val += 1 elif (a>0 and b==0) or (a==0 and b<0): val += 1 elif b < a: val += 2 val += abs(abs(a)-abs(b)) print(val)" p03208,s589157040,Wrong Answer,"from itertools import combinations N, K = [int(n) for n in input().split()] h = [int(input()) for _ in range(N)] ans = 0 for c in combinations(h, K): mc = max(c)-min(c) if ans < mc: ans = mc print(ans) " p04034,s672959683,Wrong Answer,"n,m = map(int,input().split()) balls = [1 for _ in range(n)] red = [1] + [0 for _ in range(1,n)] for _ in range(m): x, y = map(int,input().split()) x,y = x-1, y-1 if balls[x] ==0: continue balls[x] = x-1 balls[y] += 1 if red[x]: red[y] = 1 if balls[x]==0: red[x] = 0 print(sum(red)) " p03779,s026305387,Accepted,"X = int(input()) for i in range(1, 50000): n = i * (i + 1) / 2 if n >= X: print(i) break" p02621,s115904386,Accepted,"a=int(input()) print(a+a**2+a**3)" p03565,s796792153,Accepted,"import numpy as np import sys def main(): S = input() T = input() lenS = len(S) lenT = len(T) for i in range(lenS-lenT,-1,-1): sub = S[i:i+lenT] for j in range(lenT): if sub[j]!=T[j] and sub[j]!=""?"": break else: S = S[:i]+T+S[i+lenT:] S=S.replace(""?"",""a"") print(S) sys.exit() break continue print(""UNRESTORABLE"") main()" p02817,s847368353,Accepted,"s,t = input().split() print(t,end="""") print(s)" p02554,s643375345,Accepted," mod = 1000000007 N = int(input()) ans = (10 ** N) - (9 ** N) - (9 ** N) + (8 ** N) ans = ans % mod print(ans)" p02948,s203135855,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 import heapq import collections N, M = rl() daytasks = collections.defaultdict(list) for i in range(N): a, b = rl() daytasks[a].append(b) heap = [] ans = 0 for i in range(1, M+1): for t in daytasks[i]: heapq.heappush(heap, (-t, i)) if len(heap) > 0: b, a = heapq.heappop(heap) b = -b ans += b print(ans) " p03073,s324810300,Accepted,"S=input() n=len(S) c0=0 c1=0 for i in range(n): if i%2==0: if S[i]==""0"": c1+=1 else: c0+=1 else: if S[i]==""0"": c0+=1 else: c1+=1 print(min(c0,c1))" p03479,s683666437,Accepted,"X,Y=map(int,input().split()) ans=0 while X<=Y: ans+=1 X*=2 print(ans)" p03254,s645425865,Wrong Answer,"from itertools import accumulate N, x = map(int, input().split()) a = sorted(list(map(int, input().split()))) c = list(accumulate(a)) ans = sum([1 for i in c if i <= x]) if not ans: print(ans) else: print(ans if x in list(c) else ans - 1)" p02786,s200186260,Accepted,"def check(h): if h > 1: return 2*(check(h//2))+1 elif h==1: return 1 print(check(int(input())))" p03673,s879650560,Accepted,"n = int(input()) alst = list(map(int, input().split())) bef = [] aft = [] for i, a in enumerate(alst): if i % 2 == 0: bef.append(a) else: aft.append(a) if n % 2 == 0: ans = aft[::-1] + bef else: ans = bef[::-1] + aft print(*ans)" p03797,s617406117,Wrong Answer,"n,m=[int(i) for i in input().split()] if n>=2*m: print(m//2) else: print(n+(m-2*n)//2)" p02622,s031330372,Accepted,"S=str(input()) T=str(input()) count=0 for i in range(len(S)) and range(len(T)): if S[i]!=T[i]: count+=1 else: i+=1 print(count)" p02743,s539723293,Wrong Answer,"import math a,b,c = map(int,input().split()) print('Yes' if math.sqrt(c)-math.sqrt(a)-math.sqrt(b)>0 else 'No') " p03162,s275636068,Accepted,"N = int(input()) dp = list(map(int, input().split())) for i in range(1, N): a, b, c = map(int, input().split()) newDP = [0] * 3 newDP[0] = max(dp[1], dp[2]) + a newDP[1] = max(dp[0], dp[2]) + b newDP[2] = max(dp[0], dp[1]) + c dp = newDP[::] ans = max(dp) print(ans) " p02790,s871666763,Wrong Answer,"a,b = input().split() print(int(a) * b)" p02659,s088661873,Accepted,"from decimal import * a,b = map(Decimal,input().split(' ')) print(int(a*b))" p03557,s849524980,Accepted,"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 = sorted(A) B = sorted(B) C = sorted(C) from bisect import bisect_left,bisect ans = 0 for i in range(N): ans += bisect_left(A,B[i]) * (N-bisect(C,B[i])) print(ans)" p02748,s808549113,Accepted,"#coding:utf-8 import queue def main(): a, b, m = map(int, input().split()) ref = list(map(int, input().split())) ren = list(map(int, input().split())) minv = min(ref) + min(ren) for _ in range(m): x, y, c = map(int, input().split()) minv = min(ref[x - 1] + ren[y - 1] - c, minv) print(minv) if __name__ == '__main__': main()" p03285,s763635335,Accepted,"n=int(input()) can=False for i in range(n//4+2): if (n - 4*i)%7==0: can=True break if(can): print('Yes') else: print('No')" p03943,s851226494,Accepted,"ary = sorted(list(map(int, input().split()))) print('Yes' if ary[0] + ary[1] == ary[2] else 'No')" p02603,s771020894,Accepted,"# coding: utf-8 N = int(input()) A = list(map(int, input().split("" ""))) now_kabu = 0 shoji = 1000 for i in range(N-1): if A[i+1] > A[i]: now_kabu += shoji // A[i] shoji -= shoji // A[i] * A[i] if now_kabu != 0: shoji += A[i+1] * now_kabu now_kabu = 0 print(shoji) " p03665,s805516250,Accepted,"n,p = map(int,input().split()) a = list(map(int,input().split())) odd_n = 0 for i in range(n): if a[i] % 2 == 1: odd_n += 1 if odd_n == 0: if p == 0: print(2**n) else: print(0) else: print(2**(n-1))" p03478,s425005683,Wrong Answer,"N,A,B = map(int,input().split()) s = 0 j = 0 for i in range(1,N+1): j = i x0 = j // 10000 j -= x0 * 10000 x1 = j // 1000 j -= x1 * 10000 x2 = j // 100 j -= x2 * 10000 x3 = j // 10 j -= x3 * 10000 x4 = j if A <= x0 + x1 + x2 + x3 + x4 and B >= x0 + x1 + x2 + x3 + x4: s += i print(s) " p03103,s507594379,Accepted,"import sys readline = sys.stdin.readline def main(): N, M = map(int, readline().rstrip().split()) AB = [list(map(int, readline().rstrip().split())) for _ in range(N)] AB.sort() pro = 0 cost = 0 for a, b in AB: if pro + b >= M: cost += (M - pro) * a break pro += b cost += a * b print(cost) if __name__ == '__main__': main()" p02923,s331719896,Accepted,"n = int(input()) h = list(map(int, input().split())) step = 0 max_num = 0 for i in range(n - 1): if h[i] >= h[i + 1]: step += 1 max_num = max(step, max_num) else: step = 0 print(max_num) " p02994,s122457187,Accepted,"n,l=map(int,input().split()) m=[l+i for i in range(n)] s=sum(m) t=101 d=0 for i in range(n): if t>abs(m[i]): t=abs(m[i]) d=m[i] print(s-d)" p03471,s725545948,Wrong Answer,"n, k = map(int, input().split()) for x in range(n): for y in range(n): if x + y <= n: z = n - x - y result = 10000*x + 5000*y + 1000*z if result == k: print(""{} {} {}"".format(x, y, z)) exit() print(""-1 -1 -1"")" p03087,s184422079,Wrong Answer,"N, Q = map(int, input().split()) S = str(input()) #ac = [1 if S[i] == 'A' and S[i+1] == 'C' else 0 for i in range(N-1) ] a = 0 lst = [0] for i in range(1, N): if S[i-1] == 'A' and S[i] == 'C': a += 1 lst.append(a) print(lst) for _ in range(Q): l, r = map(int, input().split()) print(lst[r-1] - lst[l-1])" p02714,s037123965,Accepted,"n = int(input()) s = list(input()) r = s.count('R') g = s.count('G') b = s.count('B') # 1つ目の条件を満たす組の数 ans = r * g * b # 2つ目の条件を満たす組の数 c = 0 for i in range(n): for j in range(i+1,n): k = 2 * j -i if k > n-1: break if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]: c += 1 print(ans - c)" p03161,s033100546,Wrong Answer,"n, k = map(int,input().split()) h = list(map(int,input().split())) dp = [10**6]*n dp[0] = 0 for i in range(0,n): for j in range(1,k+1): if i+j > n-1: continue dp[i+j] = min(dp[i+j], dp[i] + abs(h[i]-h[i+j])) print(dp[n-1]) " p03698,s284200272,Accepted,"def resolve(): S = input() c = set() l = 0 for s in S: c.add(s) if l == len(c): print(""no"") return l += 1 print(""yes"") resolve() " p03605,s389374610,Accepted,"s = input() if '9'in s: print('Yes') else: print('No')" p03323,s773633667,Accepted,"a,b=map(int,input().split()) print('Yay!' if a<=8 and b<=8 else ':(') " p03605,s293722899,Wrong Answer,"N = input() if ""9"" in N: print('Yes') else: print('NO')" p03633,s171294495,Accepted,"#最大公約数 def gcd(a,b): if b==0: return a else: return gcd(b,a%b) #最小公倍数 def lcm(a,b): return a*b//gcd(a,b) #全ての最小公倍数を求めればいい n=int(input()) ans=1 for i in range(n): ans=lcm(ans,int(input())) print(ans) " p03360,s159756199,Accepted,"A,B,C = map(int,input().split()) K = int(input()) max_num = max(A,B,C) if A == max_num: print(A * (2 ** K) + B + C) elif B == max_num: print(B * (2 ** K) + A + C) else: print(C * (2 ** K) + B + A)" p03644,s802917490,Accepted,"n = int(input()) a = [] for i in range(1, n + 1): cnt = 0 flag = True j = i while flag: if i % 2 == 0: i //= 2 cnt += 1 else: flag = False a.append([j, cnt]) print(sorted(a,key=lambda x: x[1])[-1][0]) " p02917,s264824059,Wrong Answer,"import sys input = sys.stdin.readline def main(): ans = 0 N = int(input()) B = list(map(int, input().split())) if N == 2: ans = B[0]*2 else: ans += min(B[0], B[1]) for i in range(N-2): ans += min(B[i], B[i+1]) ans += B[-1] print(ans) if __name__ == '__main__': main()" p03705,s216054050,Wrong Answer,"N, A, B = list(map(int,input().split())) if (B * (N-1) + A) - (B + (N-1) * A) <= 0: print(0) elif A == B: print(1) else: print((B * (N-1) + A) - (B + (N-1) * A))" p03371,s969556923,Accepted,"a,b,ab,x,y=map(int,input().split()) total=0 if a+b>2*ab: total+=min(x,y)*2*ab if x>y: x-=y if a>=2*ab: total+=2*ab*x else: total+=a*x elif x=2*ab: total+=2*ab*y else: total+=b*y else: total+=a*x+b*y print(total)" p02787,s781365255,Accepted,"H, N = map(int, input().split()) AB = [[int(x) for x in input().split()] for _ in range(N)] dp = [float('inf')] * (H + 1) dp[0] = 0 for h in range(H + 1): for a, b in AB: h_new = min(h + a, H) dp[h_new] = min(dp[h] + b, dp[h_new]) print(dp[-1])" p02772,s771833013,Accepted,"input() xs=[int(x) for x in input().split(' ')] for x in xs: if x%2==0: if x%3!=0 and x%5!=0: print('DENIED') exit(0) print('APPROVED')" p03761,s302705590,Accepted,"n = int(input()) s = [0]*n import collections t = [0]*n for i in range(n): s[i] = input() t[i] = collections.Counter(s[i]) m = [100]*26 ans = [] for A in t: for i in range(26): m[i] = min(m[i],A[chr(97+i)]) for i in range(26): if m[i] != 100 and m[i] != 0: ans.append([chr(97+i)]*m[i]) for A in ans: print("""".join(A),end="""") print("""") " p02657,s714232811,Wrong Answer,"a, b = input().split() a = int(a) b = int(b.replace(""."", """")) print(a*b//100)" p02633,s963774863,Accepted,"import math x = int(input()) tol = 1e-6 ans = 1 cur = [0,1] unit = x/180*math.pi while cur[0]**2 + cur[1]**2 > tol: cur[0] += math.sin(ans*unit) cur[1] += math.cos(ans*unit) ans += 1 print(ans)" p03219,s064300521,Accepted," def solve(): X, Y = map(int, input().split()) print(X+(Y//2)) if __name__ == ""__main__"": solve() " p02682,s584924728,Wrong Answer,"a,b,c,k=map(int,input().split()) if k<=a+b: print(a) else: print(a-(k-(a+b)))" p02842,s023167060,Accepted,"# -*- coding: utf-8 -*- # N円の支払い (1 ≤ N ≤ 50000) N = int(input())#入力 count = 0 for x in range(50000): if(N == int(x*1.08)): without_tax = x #税抜き価格 else: count = count + 1 if(count == 50000): print(':(') else: print(without_tax)" p02732,s554496582,Accepted,"import collections N = int(input()) A = list(map(int,input().split())) c = collections.Counter(A) cc = c.items() f_ans = 0 for m,n in cc: f_ans += n*(n-1)/2 for i in range(N): a = A[i] b = c[a] sa = b*(b-1)/2 - (b-1)*(b-2)/2 print(int(f_ans - sa))" p02720,s260767391,Wrong Answer,"from queue import Queue K = int(input()) # 1 2 3 4 5 6 7 8 9 10 11 12 21 22 23 32 33 34 ... 98 99 100 q = Queue() for i in range(1, 10): q.put(i) # print(q.queue) for i in range(K): r = q.get() if r % 10 != 0: q.put(r * 10 + r % 10 - 1) q.put(r * 10) if r % 10 != 9: q.put(r * 10 + r % 10 + 1) print(r) " p02555,s405632814,Wrong Answer,"import math S = int(input()) if S < 3: print(0) exit() def check(s, i): re = ((i ** s) // math.factorial(s)) % (10 ** 9 + 7) return re n = S // 3 ans = 0 for i in range(n): S_i = S - (3 * (i + 1)) ans += check(S_i, i + 1) print(ans % (10 ** 9 + 7)) " p03544,s003578390,Accepted,"l=[2,1] n=int(input()) for i in range(2,n+1): l.append(l[-1]+l[-2]) print(l[-1]) " p03419,s286127547,Accepted,"import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) n, m = map(int, readline().split()) if n == 1 or m == 1: if n == 1 and m == 1: print(1) else: print(n * m - 2) else: print(n * m - (n + m - 2) * 2) " p02720,s829863599,Accepted,"k = int(input()) import queue que = queue.Queue() for i in range(1, 10): que.put(i) for i in range(1, k + 1): ans = que.get() keta1 = ans % 10 if keta1 == 0: append_list = [ans * 10, ans * 10 + 1] elif keta1 == 9: append_list = [ans * 10 + 8, ans * 10 + 9] else: append_list = [ans * 10 + keta1 - 1, ans * 10 + keta1, ans * 10 + keta1 + 1] for ite in append_list: que.put(ite) print(ans)" p02689,s108571586,Accepted,"n,m = map(int,input().split()) h = list(map(int,input().split())) g = [0]*n co = 0 for _ in range(m): a,b = map(int,input().split()) g[a-1] = -1 if h[a-1]<=h[b-1] or g[a-1]==-1 else 1 g[b-1] = -1 if h[b-1]<=h[a-1] or g[b-1]==-1 else 1 for i in range(n): if g[i] < 0: continue co+=1 print(co)" p03241,s153329899,Accepted,"import sys def input(): return sys.stdin.readline().rstrip() 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 import bisect def main(): n,m=map(int,input().split()) div=make_divisors(m) print(div[bisect.bisect(div,m//n)-1]) if __name__=='__main__': main()" p02712,s810243185,Accepted,"n = int(input()) def sum_seq(d): return 0.5*(n//d)*(2*d+(n//d-1)*d) print(int(sum_seq(1) - sum_seq(3) - sum_seq(5) + sum_seq(15))) " p03435,s720831917,Wrong Answer,"C = [list(map(int,input().split())) for _ in range(3)] if C[1][0]-C[0][0]==C[1][1]-C[0][1]==C[1][2]-C[0][2] and C[2][0]-C[0][0]==C[2][1]-C[0][1]==C[2][2]-C[0][2] \ and C[0][1]-C[0][0]==C[1][1]-C[1][0]==C[2][1]-C[2][0] and C[0][2]-C[0][0]==C[1][2]-C[1][0]==C[2][2]-C[2][0]: print(""Yes"") " p03339,s704083223,Accepted,"N=int(input()) S=input() RS=S[::-1] west=[0] east=[0] for i in range(N): if S[i]==""W"": west.append(west[-1]+1) else: west.append(west[-1]) west.append(0) for i in range(N): if RS[i]==""E"": east.append(east[-1]+1) else: east.append(east[-1]) east.append(0) east=east[::-1] ans=10**9 for i in range(1,N+1): ans=min(ans,west[i-1]+east[i+1]) print(ans) " p03705,s597521747,Accepted,"n,a,b = map(int,input().split()) print(b*(n-2)-a*(n-2)+1 if b*(n-2)-a*(n-2)+1 > 0 else 0)" p03012,s218004730,Accepted,"N = int(input()) W = list(map(int, input().split())) S = sum(W) m = S for i in range(1, N): T = sum(W[:i]) m = min(m, abs(T-(S-T))) print(m)" p03971,s913620903,Wrong Answer,"n, a, b = map(int, input().split()) s = list(input()) for i in s: if i == ""a"" and a != 0: a -= 1 print(""Yes"") elif i == b and b != 0: b -=1 print(""Yes"") else: print(""No"")" p02761,s566444338,Accepted,"n,m = map(int,input().split()) sc = [list(map(int,input().split())) for _ in range(m)] for i in range(1000): s = str(i) if len(s) != n: continue if all(s[a - 1] == str(b) for a, b in sc): print(i) exit() print(-1)" p02833,s608470592,Accepted,"import sys a=int(input()) if a%2==1: print(0) sys.exit() i=10 ans=0 while i<=a: ans+=a//i i*=5 print(ans)" p02629,s858979200,Accepted,"N = int(input()) if N<=26: print(chr(N+96)) else: s = '' tmp = N while True: ttmp = tmp%26 if ttmp==0: ttmp = 26 s = chr(ttmp+96)+s if tmp<=26: break tmp = (tmp-ttmp)//26 print(s)" p03013,s838681255,Accepted,"def route_num(stairs): if stairs <= 1: return 1 else: return route_num(stairs - 1) + route_num(stairs - 2) n, m = map(int, input().split()) a = [int(input()) for _ in range(m)] broken = {i:False for i in range(n + 1)} for a_i in a: broken[a_i] = True route_num = {} for i in range(n + 1): if broken[i]: route_num[i] = 0 elif i <= 1: route_num[i] = 1 else: route_num[i] = route_num[i-1] + route_num[i-2] print(route_num[n] % 1000000007) " p02881,s251105803,Accepted,"n = int(input()) i = 1 result = 10 ** 18 while i*i <= n: if n % i == 0: result = min(result, (i - 1) + (n//i - 1)) i += 1 print(int(result))" p02912,s116066850,Accepted,"from heapq import heappush, heappop, heapify def main(): n, m = map(int, input().split()) A = list(map(int, input().split())) hq = [(-1) * i for i in A] heapify(hq) cnt = 0 while cnt < m: a = (-1) * heappop(hq) a //= 2 heappush(hq, (-1) * a) cnt += 1 print((-1) * sum(hq)) if __name__ == '__main__': main()" p02706,s611834474,Accepted,"N, M= map(int,input().split()) numbers = list(map(int, input().split())) amount = 0 for i in range(M): amount = amount + numbers[i] if N - amount >= 0: print(N - amount) else: print(-1) " p03076,s748484427,Accepted,"import math list=[int(input()) for x in range(5)] list.sort(key=lambda x:x%10) count=0 for l in list: if l%10==0: count+=1 if count==5: print(sum(list)) else: a=list[count] del list[count] ans=[] for t in list: ans.append(math.ceil(t/10)*10) print(sum(ans)+a)" p03637,s637819941,Wrong Answer,"n = int(input()) li = list(map(int,input().split())) lis = [] x = 0 y = 0 z = 0 for i in range(n): if li[i] % 4 == 0: x += 1 elif li[i] % 2 == 0: y = 1 else: z += 1 if y == 0: if x >= z + 1: print(""Yes"") else: print(""No"") else: if x >= z: print(""Yes"") else: print(""No"") " p02603,s497828964,Accepted,"n = int(input()) a = [int(i) for i in input().split()] a.append(0) money = 1000 stock = 0 for i in range(n): if a[i] < a[i+1] and stock == 0: stock,money = money//a[i],money%a[i] elif a[i] > a[i+1]: stock,money = 0,money+stock*a[i] print(money)" p02664,s321010599,Accepted,"t = input() print(t.replace('?', 'D'))" p03293,s728416477,Accepted,"import sys import math from collections import deque sys.setrecursionlimit(1000000) MOD = 10 ** 9 + 7 input = lambda: sys.stdin.readline().strip() NI = lambda: int(input()) NMI = lambda: map(int, input().split()) NLI = lambda: list(NMI()) SI = lambda: input() def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)] def main(): S = deque(SI()) T = deque(SI()) for i in range(len(S)): S.rotate(1) if T == S: print('Yes') exit() print('No') if __name__ == ""__main__"": main()" p03711,s901009370,Accepted,"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) or (x in b and y in b): print(""Yes"") else: print(""No"")" p03760,s928065432,Wrong Answer,"o=list(input()) e=list(input()) p=[] for a in range(len(o)-1): p.append(o.pop(0)) p.append(e.pop(0)) if len(o): p.append(o.pop(0)) print("""".join(p))" p03796,s743524817,Accepted,"import math N = int(input()) print(math.factorial(N) % (10**9 + 7))" p02935,s667409742,Wrong Answer,"n = int(input()) v = list(map(int,input().split())) v.sort() asa = 0 for i in range(1,n): v[n-i-1] = (v[n-i-1] + v[n-i])/2 print(v[0]) " p02823,s715364126,Accepted,"N, A, B = map(int, input().split()) if (B-A) % 2 == 0: ans = (B-A+2)//2-1 else: if min(A-1, N-B) == A-1: ans = B-1 plus=A B -= A A = 1 else: ans = N-A plus=N-B+1 A += N-B+1 B = N if A != B: ans = (B-A+2)//2-1+plus print(ans) " p02583,s737008795,Accepted,"n = int(input()) l = input().split() l = list(map(int,l)) c=0 for i in range(n): for j in range(i+1,n): for h in range(j+1,n): if l[i]!=l[j] and l[h]!=l[j] and l[i]!=l[h]: a = [l[i],l[j],l[h]] #print(a) a.sort() if a[0]+a[1]>a[2]: #print(c,a) c+=1 print(c) " p02995,s264055520,Accepted,"a,b,c,d=map(int,input().split()) from math import gcd ans=0 def main(n): e=n//c+n//d-n//((c*d)//gcd(c,d)) return n-e print(main(b)-main(a-1)) " p02952,s815003636,Wrong Answer,"n = int(input()) if n < 10: print(n) elif n < 100: print(9) elif n < 1000: print(9+(n-99)) elif n < 10000: print(9+900+(n-999)) elif n <= 100000: print(9+900+(n-9999))" p03745,s356636250,Wrong Answer,"N = int(input()) alst = list(map(int, input().split())) now = 'E' cnt = 1 for i in range(1, N): if alst[i] > alst[i-1]: new = 'U' #up elif alst[i] < alst[i-1]: new = 'D' #down else: new = 'E' if now == new or now == 'E': now = new elif now != new : cnt += 1 now = 'E' print(cnt)" p03836,s335858471,Accepted,"sx,sy,tx,ty = map(int,input().split()) print(""U""*(ty-sy)+""R""*(tx-sx)+""D""*(ty-sy)+""L""*(tx-sx)+""L""+""U""*(ty-sy+1)+""R""*(1+tx-sx)+""D""+""R""+""D""*(ty-sy+1)+""L""*(1+tx-sx)+""U"")" p02900,s911537671,Accepted,"import fractions a,b=map(int,input().split()) ab_gcd=fractions.gcd(a,b) cd=[1] tmp=int(ab_gcd**0.5)+1 if ab_gcd==1: print(1) exit() for i in range(2,tmp+1): while ab_gcd%i==0: ab_gcd//=i cd.append(i) if ab_gcd!=1: cd.append(ab_gcd) cd=set(cd) print(len(cd) if len(cd)!=1 else 2)" p02917,s792747082,Accepted,"n = int(input()) b = [int(_) for _ in input().split()] ans = b[0]+b[-1] for i in range(1, n-1): ans+=min(b[i],b[i-1]) print(ans)" p02608,s047282668,Accepted,"import collections n = int(input()) ans_list = [] for x in range(1,100): for y in range(1,100): for z in range(1,100): ans_list.append(x*x+y*y+z*z+x*y+y*z+z*x) counter = collections.Counter(ans_list) for i in range(1,n+1): print(counter[i])" p03127,s454946406,Wrong Answer,"n = int(input()) a = sorted(map(int, input().split())) ans = a[0] for i in range(1,n): x = a[i] % ans if x > 0: ans = min(ans, x) print(ans)"