problem_id,submission_id,status,code p02596,s550923243,Accepted,"k = int(input()) x = 7 e = 10 for i in range(10000000): # print(x) if x % k == 0: print(i + 1) exit() x = (x * e + 7) % k print(""-1"")" p02596,s576837806,Accepted,"K = int(input()) if K%2==0: print(""-1"") elif K%5==0: print(""-1"") else: ans = 0 temp = 0 check = 0 for i in range(K): ans += 1 temp *= 10 temp += 7 temp %= K if temp==0: check+=1 if check==1: break print(ans)" p02596,s502024006,Accepted,"k= int(input()) seen = [0]*(k+1) rem=0 for i in range(0,k+1): rem = (rem*10+7) % k # print(rem) if rem == 0: print(i + 1) break elif seen[rem] ==1: print('-1') break else: seen[rem] =1" p02596,s670804957,Accepted,"#!/usr/bin/env python # -*- coding: utf-8 -*- def main(): K = int(input()) mod = 7 ans = 1 for i in range(K): if mod % K == 0: print(ans) exit() mod = (mod * 10 + 7) % K ans += 1 print(-1) if __name__ == ""__main__"": main() " p02596,s252156712,Accepted,"k = int(input()) checked = [False] * k surplus = 0 ans = 1 while 1: surplus = ((surplus * 10) + 7) % k if checked[surplus]: print(-1) exit() if surplus == 0: break checked[surplus] = True ans += 1 print(ans) " p02596,s861637054,Accepted,"k=int(input()) x=7 for i in range(1,k+1): if x%k==0: print(i) break x=(x*10+7)%k else: print(-1)" p02596,s488110660,Accepted,"def resolve(): K = int(input()) N = 7 c = 1 for i in range(10**6): if N % K == 0: print(c) break else: N = N * 10 + 7 N %= K c += 1 else: print(-1) resolve()" p02596,s330533180,Accepted,"import sys from collections import defaultdict K = int(input()) n = len(str(K)) r = 7 % K dict = defaultdict(bool) # int/bool/list.... dict[r] = True orgr = r d = 1 for _ in range(K + 1): if r == 0: print(d) break d += 1 r = (10 * r + 7) % K if dict[r]: print(-1) sys.exit() dict[r] = True" p02596,s057483335,Accepted,"import sys K = int(input()) t = 7 for i in range(K): if t % K == 0: print(i + 1) break t = (t*10+7) % K else: print(-1) " p02596,s021409171,Accepted,"k = int(input()) r = set() x = 7 i = 1 while True: rr = x % k if rr == 0: print(i) break if rr in r: print(-1) break x = (x * 10 + 7) % k i += 1 r.add(rr)" p02596,s030623788,Accepted,"k = int(input()) m = 0 for i in range(1, 10**7): n = m *10 +7 m = n % k if m == 0: print(i) exit(0) print(-1)" p02596,s884266823,Accepted,"k = int(input()) x = 0 for i in range(1,10**6+10): x = (x*10+7)%k if(x==0): print(i) exit() print(-1)" p02596,s776378005,Accepted,"K = int(input()) cnt = 0 n = 7 while cnt <= K: cnt += 1 if n % K == 0: break n = (10 * n + 7) % K if cnt == K+1: print(-1) else: print(cnt) " p02596,s774408974,Accepted,"k = int(input()) m = [False] * k s = 0 d = 7 % k i = 0 while True: s = (s + d) % k d = d * 10 % k i += 1 if s == 0: print(i) break if m[s]: print(-1) break m[s] = True " p02596,s130255420,Accepted,"k = int(input()) m = 0 for i in range(1, 10**6): n = m *10 +7 m = n % k if m == 0: print(i) exit(0) print(-1)" p02596,s069872717,Accepted,"K=int(input()) if K%2==0 or K%5==0: print('-1') exit() a=0 i=1 while True: a=(a*10+7)%K if a==0: print(i) break i+=1 " p02596,s434916148,Accepted,"k = int(input()) seed = 0 flag = 1 for i in range(k): seed = (10*seed +7)%k if seed == 0: print(i+1); flag = 0; break if flag: print(-1) " p02596,s464955465,Accepted,"k = int(input()) dp = [0] * k cur = 0 for i in range(k + 1): cur = (cur * 10 + 7) % k mod = cur % k if mod == 0: print(i + 1) break if dp[mod]: print(-1) break dp[mod] = 1 " p02596,s536562421,Accepted,"import math K = int(input()) if K == 7 or K == 1: print(1) elif math.gcd(K,10) != 1: print(-1) else: if K % 7 == 0: K //= 7 cnt = 1 res = 10 while True: cnt += 1 res *= 10 res %= (9 * K) if res == 1: break print(cnt)" p02596,s661266013,Accepted,"def main(): k = int(input()) a = [0] * (10 ** 6 + 1) a[0] = 7 % k if a[0] == 0: print(1) exit() 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()" 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 " 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)) " p02596,s190390845,Accepted,"k = int(input()) x = 7 % k s = [0] * k i = 1 while s[x] == 0: if x == 0: print(i) exit() s[x] = 1 x = (x * 10 + 7) % k i += 1 print('-1')" p02596,s633092073,Accepted,"#C K = int(input()) judge=False num = 7 for i in range(K): num = num % K #print(num) if num == 0: print(i+1) judge = True break else: num = num*10+7 if judge == False:print(""-1"")" p02596,s215117091,Accepted,"K = int(input()) if K % 7 == 0: K //= 7 L = 9 * K ans = -1 r = 10 for i in range(L): if r % L == 1: ans = i + 1 break else: r = 10 * (r % L) print(ans)" p02596,s813364810,Accepted,"K = int(input()) if (K%2==0)or(K%5==0): print(-1) else: x = 7 i = 1 x %= K while (x!=0)or(i>=10**7): x += (7%K) * pow(10,i,K) x %= K i += 1 if i<10**7: print(i) else: print(-1)" p02596,s281909000,Accepted,"k = int(input()) a = [] a.append(7 % k) for i in range(k): a.append((a[i] * 10 + 7) % k) for i in range(k): if a[i] == 0: print(i + 1) exit() print(-1) " p02596,s831648572,Accepted," K = int(input()) now = 0 dic = {} import sys cnt = 1 while True: now = (now * 10 + 7) % K if now == 0: print (cnt) sys.exit() elif now in dic: print (-1) sys.exit() else: dic[now] = 1 cnt += 1 " p02596,s223250437,Accepted,"k = int(input()) if k % 2 == 0 or k % 5 == 0: print(-1) else: ans = 7 cnt = 1 while 1: if ans % k == 0: break else: cnt += 1 ans *= 10 ans += 7 ans %= k print(cnt) " p02596,s896136124,Accepted,"K = int(input()) L = 0 if K % 7 == 0: L = 9*K//7 else: L = 9*K ans = -1 s = 10 for i in range(1,L,1): if s % L == 1: ans = i break s = s % L * 10 print(ans)" p02596,s356304191,Accepted,"import sys input=sys.stdin.readline def main(): K = int(input()) if K % 7: L = 9*K else: L = 9*K//7 a = 1 for i in range(1,L+1): a = (a * 10) % L if a == 1: return i return -1 ans =main() print(ans)" p02596,s278955055,Accepted,"K = int(input()) if K % 2 == 0 or K % 5 == 0: print(-1) exit() ans = 0 ai = 0 while True: ai = (ai * 10 + 7) % K ans += 1 if ai % K == 0: print(ans) exit() " p02596,s250511757,Accepted,"def main(): k = int(input()) surplus = 0 for i in range(1, k+1): surplus *= 10 surplus += 7 surplus %= k if not surplus: print(i) return print(-1) if __name__ == ""__main__"": main()" p02596,s509936595,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()] k = inp() dt = {} no = 0 ans = -1 i = 0 while True: no = (no*10+7)%k if no in dt: break dt[no] = 1 #print(dt,no) if no == 0: ans = i+1 break i += 1 print(ans) " p02596,s208299747,Accepted,"K = input() K = int(K) def seven(): seven_i = 0 count = 0 for i in range(K): seven_i = ((10*seven_i) + 7) % K count += 1 if seven_i % K == 0: return count return -1 print(seven())" p02596,s843363526,Accepted,"K = int(input()) if K % 2 == 0 or K % 5 == 0: print(-1) exit() i = 0 ai = 0 while True: ai = (ai * 10 + 7) % K i += 1 if ai == 0: break print(i)" p02596,s772514207,Accepted,"k = int(input()) flag = 0 count = len(str(k)) if k % 2 == 0: print(-1) exit() if str(k)[-1] == '5': print(-1) exit() count = len(str(k)) test = int('7' * count) amari = test % k while True: if amari == 0: break else: amari = (amari * 10 + 7) % k count += 1 print(count)" p02596,s491243647,Accepted,"k = int(input()) a = 0 for i in range(k): a = (a*10+7)%k if a == 0: print(i+1) quit() print(-1) " p02596,s383678832,Accepted," K=int(input()) i=0 if K%2==0 or K%5==0: print('-1') else: for d in range(K): i=(10*i+7)%K if i==0: print(d+1) break " p02596,s448208796,Accepted,"K = int(input()) seven = 7 counter = 1 flag = True for i in range(K): if seven % K == 0: print(counter) flag = False break seven = (seven * 10 + 7) % K counter += 1 if flag: print(-1)" p02596,s665868793,Accepted,"k, R, a = int(input()), 7, -1 for i in range(1, k+1): if not R%k: a = i break R = (R * 10 + 7) % k print(a)" p02596,s580797119,Accepted,"K = int(input()) ans = 1 now = 7 % K isvisited = set() while now != 0: if now in isvisited: print(-1) exit() isvisited.add(now) now = (now * 10 + 7) % K ans += 1 print(ans) " p02596,s335599839,Accepted,"import sys input = sys.stdin.readline def main(): K = int(input()) if K%2==0 or K%5==0: print(-1) return if K % 7: L = 9*K else: L = 9*K//7 a = 1 for i in range(1,K+10): a = (a * 10) % L if a == 1: print(i) return print(-1) main() " p02596,s462669106,Accepted,"K = int(input()) N = 0 count = -1 for i in range(K): N = (N*10+7)%K if N == 0: count = i+1 break print(count) " p02596,s002550955,Accepted,"# C - Repsept K = int(input()) tmp = 0 ans = -1 for i in range(1,2*K): tmp = (10*tmp+7)%K if tmp==0: ans = i break print(ans)" p02596,s476987426,Accepted,"ma = lambda :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 k = ni() if k%2==0 or k%5==0: print(-1) exit() if k%7==0: L=9*k//7 else: L=9*k tmp=1 for i in range(1,10**6): tmp = tmp*10 %L if tmp==1: print(i) break else: print(-1) " p02596,s317635074,Accepted,"K = int(input()) a = 7 % K for i in range(999983): if a == 0: print(i+1) exit() a = (a * 10 + 7) % K print(-1)" p02596,s757119953,Accepted,"K = int(input()) a = 0 ans = -1 for i in range(10**7): a = (a*10+7) % K if a == 0: ans = i+1 break 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" p02596,s079586039,Accepted,"k = int(input()) def func(k): number = 7 % k for i in range(k): if number == 0: return i+1 number = (10 *number + 7) % k return -1 if k % 2 == 0 or k % 5 == 0: print(-1) else: print(func(k)) " 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() " p02596,s018269844,Accepted,"K = int(input()) done = set() i = 0 x = 7 flag = True while x % K != 0 : if not x in done : done.add(x) else : flag = False break x = (x % K) * 10 + 7 i += 1 if flag : print(i + 1) else : print(-1)" p02596,s453478035,Accepted,"def main(k): size, res = 1, 7 % k while res and size <= k: res = (res * 10 + 7) % k size += 1 return -1 if size > k else size if __name__ == '__main__': k = int(input()) print(main(k)) " p02596,s537820126,Accepted,"k=int(input()) ans=1 judge=0 s=7%k while ans<=k: if s==0: judge=1 break else: s=s*10+7 s%=k ans+=1 if judge==1: print(ans) else: print(-1) " 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) " p02596,s840486015,Accepted,"K = int(input()) if K%5==0 or K%2==0: print(-1) else: cnt=1 ms = 7 % K while ms != 0: cnt+=1 ms = (ms*10+7)%K print(cnt)" p02596,s583158987,Accepted,"k = int(input()) t = 7 t %= k for i in range(k + 1): if t == 0: print(i + 1) break t = (t * 10 + 7) % k else: print(-1) " p02596,s282783738,Accepted,"def calc(k): cur = 0 for i in range(1, 10 ** 7): cur *= 10 cur += 7 cur %= k if cur == 0: return i return -1 k = int(input()) print(calc(k))" 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 " p02596,s856642734,Accepted,"k = int(input()) now = k r = 0 for i in range(1, k + 100): r = (r * 10 % k + 7) % k if r==0: print(i) exit() print(-1)" p02596,s566265307,Accepted,"from collections import deque import sys input = sys.stdin.readline k = int(input()) n = 7 ans = -1 for i in range(10**6): #注意 if n % k == 0: ans = i+1 break else: n = (n % k) *10 + 7 print(ans)" p02596,s734384161,Accepted,"k=int(input()) n=7 for i in range(k+1): if n%k==0: print(i+1) exit() n=(10*n+7)%k print(-1)" p02596,s091798331,Accepted,"K=int(input()) def waru(K): a=[] if K%2==0 or K%5==0: print(""-1"") return a.append(7%K) for i in range(1,K): a.append((10*a[i-1]+7)%K) for i in range(K): if a[i]==0: print(i+1) return print(-1) waru(K)" p02596,s170759188,Accepted,"K=int(input()) k_mod=0 for i in range(1,K+1): k_mod=(10*k_mod+7)%K if k_mod==0: print(i) break else: print(-1)" p02596,s508876647,Accepted,"#!/usr/bin/env python # coding: utf-8 # In[40]: K = int(input()) # In[44]: if K%2 == 0 or K%5 == 0: print(-1) else: if K%7 == 0: L = 9*K//7 else: L = 9*K ans = -1 tmp = 0 for i in range(1,K+1): if (10*tmp+9)%L == 0: ans = i break else: tmp = (10*tmp+9)%L print(ans) # In[ ]: " p02596,s350385221,Accepted,"k=int(input()) mod=[0]*k c=7 cnt=1 while True: if c%k==0: print(cnt) break mod[c%k]=1 c*=10 c+=7 c%=k cnt+=1 if mod[c]==1: print(-1) break " p02596,s695374641,Accepted,"def main(): K = int(input()) a_i = 7 if a_i % K == 0: print(1) return for i in range(2, 10 ** 6+1): a_i = a_i * 10 + 7 if a_i % K == 0: print(i) return a_i %= K print(-1) main() " p02596,s389112141,Accepted,"def main(): k = int(input()) tbl = {} v = int(0) cnt = 0 while True: cnt += 1 v = 10 * v + 7 v = v % k if v == 0: print(cnt) break elif v in tbl.keys(): print('-1') break else: tbl[v] = 0 if __name__ == '__main__': main() " p02596,s626412048,Accepted,"import sys input = sys.stdin.readline K=int(input().rstrip('\n')) if K % 2 ==0: print(-1) else: now = 7 check = 0 for i in range(1,K+1): if now % K ==0: print(i) check += 1 break else: now = now%K now = now*10 now += 7 if check ==0: print(-1)" p02596,s574163098,Accepted,"import sys input = sys.stdin.readline k = int(input()) if k%2 == 0: print(-1) exit() if k == 7: print(1) exit() if k == 1: print(1) exit() if k % 5 == 0: print(-1) exit() seven = 7 d = 1 while seven != 0: seven += pow(7*pow(10,d,k),1,k) seven = pow(seven,1,k) d += 1 print(d) " p02596,s244962769,Accepted,"k = int(input()) t = 7 t %= k for i in range(k + 1): if t == 0: print(i + 1) break t = (t * 10 + 7) % k else: print(-1)" 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) " p02596,s916532641,Accepted,"K = int(input()) num = 0 cnt = 0 ans = -1 for i in range(K): num = num*10 +7 cnt += 1 if num%K != 0: num = num%K else: ans = cnt break print(ans)" p02596,s656453408,Accepted,"K=int(input()) num=7 count = 0 checkK = [0 for j in range(K)] result = """" flag = True while(flag): count += 1 if num%K==0: flag = False result = str(count) num = (num*10+7)%K checkK[num] += 1 if checkK[num] == 2: flag = False result = ""-1"" print(result)" p02596,s735640349,Accepted,"K = int(input()) ans = -1 if K%2 == 0: pass elif K%5 == 0: pass else: num = 7 ans = 0 while True: ans += 1 if num % K == 0: break else: num = (num * 10 + 7)%K print(ans)" p02596,s270142711,Accepted,"k = int(input()) mod = 7 % k counter = 1 memo = 1 mod_map = set() mod_map.add(mod) while mod != 0: mod = ((mod * 10) % k + 7) % k if mod not in mod_map: mod_map.add(mod) else: counter = -1 break counter += 1 if mod == 0: break print(counter) " p02596,s808581640,Accepted,"k = int(input()) if k % 2 == 0 or k % 5 == 0: print(-1) exit() n = 7 for i in range(1,10**7): if n%k == 0: print(i) break else: n = (n%k +0.7) *10 " p02596,s310184575,Accepted,"k = int(input()) r = 0 for i in range(1, k+1): r = (r*10 + 7)%k if r == 0: print(i) exit() print(-1) " p02596,s745309398,Accepted,"k = int(input()) cnt = 1 mod = 7 for i in range(k): if mod%k == 0: break cnt+=1 mod = (mod*10 + 7)%k if mod%k == 0: print(cnt) else: print(-1)" p02596,s621767549,Accepted," def main(): K = int(input()) cnt = 1 a = 7%K s = {a} for i in range(K): if a%K == 0: print(cnt) return a = a*10 + 7 a = a % K if a in s: print(-1) return s.add(a) cnt += 1 if __name__ == ""__main__"": main()" p02596,s301515140,Accepted,"k = int(input()) now = 7%k if now == 0: print(1) exit() ans = 1 for i in range(k+1): ans += 1 now *= 10 now += 7 now %= k if now == 0: break if now == 0: print(ans) else: print(-1) " p02596,s304287973,Accepted,"K = int(input()) c = 0 a = 7 % K for i in range(K + 1): if a == 0: print(i + 1) exit() a = (a * 10 + 7) % K print(-1)" p02596,s226675495,Accepted,"K = int(input()) if K % 2 == 0: print(-1) exit() x = 7 % K i = 1 while True: if x == 0: print(i) exit() x = (x * 10 + 7) % K i += 1 if i > 10**6: print(-1) exit() " p02596,s690369224,Accepted,"K = int(input()) if 7%K==0: print(1) else: ans = 1 b = 7%K while ans < 10**7+1000: b = (b*10+7)%K if b == 0: print(ans+1) break else: ans += 1 else: print(-1)" p02596,s178520175,Accepted,"K = int(input()) x = 7 for i in range(K): if x % K == 0: print(i+1) exit() else: x = (10*x + 7) % K print(-1)" p02596,s738852052,Accepted,"K = int(input()) if K % 2 == 0 or K % 5 == 0: print('-1') else: cnt = 1 cur = 7 while True: if cur % K == 0: print(cnt) break if cnt > K: print('-1') break cur = (cur * 10 + 7) % K cnt += 1" p02596,s350802470,Accepted,"K = int(input()) mods = [0] * (K+1) mods[1] = 7 % K for i in range(2,K+1): mods[i] = (mods[i-1] * 10 + 7) % K for i in range(1,K+1): if mods[i] == 0: print(i) exit(0) print(-1)" 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)" p02596,s106604218,Accepted,"import sys k = int(input()) ans = [0]*(k+1) ans[0] = 7 % k if ans[0] == 0: print(1) else: for i in range(k): ans[i+1] = (ans[i]*10 + 7) % k if ans[i+1] == 0: print(i+2) sys.exit() print(-1)" p02596,s181461655,Accepted,"def main(): K = int(input()) visited = [False]*K r = 0 for i in range(1, K+1): r = r*10 + 7 r %= K if r == 0: print(i) exit() if visited[r]: print(-1) exit() visited[r] = True if __name__ == ""__main__"": main()" p02596,s298954650,Accepted,"k=int(input()) a=7 for i in range(10**6): if a%k==0: print(i+1) exit() a=(a*10+7)%k print(-1) " p02596,s121269451,Accepted,"import sys import math import collections import decimal import itertools from collections import deque from functools import reduce import heapq import copy k = int(input()) #n, d = map(int, sys.stdin.readline().split()) #s = input() #a = list(map(int, sys.stdin.readline().split())) m = 7 for i in range(1, 10 ** 6): if m % k == 0: print(i) sys.exit() m *= 10 m += 7 if m > k: m %= k print(-1) " p02596,s066415254,Accepted,"k = int(input()) a = 7 if a % k == 0: print(1) exit() for i in range(k): a = (a * 10 + 7) % k if a == 0: print(i + 2) exit() print(-1)" p02596,s366118325,Accepted,"x = int(input()) if x % 2 == 0 or x % 5 == 0: print(-1) else: s = 1 m = 7 while m%x != 0: n = m % x m = n * 10 +7 s += 1 print(s) " p02596,s211471171,Accepted,"k=int(input()) n=0 a=0 ss=0 if k==7: print(1) elif k%2==0: print(-1) elif k%5==0: print(-1) else: while a==0: n+=1 ss=10*(ss%k)+7 if ss%k==0: a=1 if a==1: print(n) else: print(-1) " p02596,s660911510,Accepted,"import sys K = int(input()) if K%2 == 0 or K%5 == 0: print(-1) sys.exit() dp = 7 ans = 1 while(ans <= 10000000): if dp % K == 0: print(ans) sys.exit() ans += 1 dp = (dp * 10 + 7) % K" p02596,s204753661,Accepted,"k = int(input()) a = 0 for i in range(k + 10): a = (a*10 + 7)%k if a == 0: print(i + 1) exit() print(-1)" p02596,s282232436,Accepted,"# C Repsept k = int(input()) mod = 0 cnt = 0 for i in range(k): mod = (mod*10+7) % k cnt += 1 if mod == 0: print(cnt) exit() print(-1)" p02596,s814809959,Accepted,"k = int(input()) now = 7 for i in range(1, k+1): if int(now) % k == 0: print(i) break now = 10 * now + 7 now %= k else: print(-1) " 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) " p02596,s019217346,Accepted,"K = int(input()) num = 7%K ans = -1 for i in range(K): if num%K == 0: ans = i+1 break num = (num*10 +7)%K print(ans) " p02596,s586897240,Accepted,"k=int(input()) if k%2==0 or k%5==0: print(-1) exit() count=0 a=0 while True: a=(a*10+7)%k count+=1 if a==0: print(count) exit()" 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)" p02596,s645280126,Accepted,"K = int(input()) if K % 2 == 0 or K % 5 == 0: print(-1) exit() s = '7' * len(str(K)) if int(s) < K: s += '7' ans = len(s) s = int(s) while True: s = s % K if s == 0: print(ans) exit() s = s * 10 + 7 ans += 1 " p02596,s028298772,Accepted,"n = int(input()) c,f=0,0 for i in range(1,1000001): c=c*10+7 c=c%n if c==0: f=1 print(i) break if f==0: print(-1) " p02596,s870238045,Accepted,"def main(): k = int(input()) num = 7 % k first = num ans = 1 while num != 0: ans += 1 num = (num*10 + 7)%k if num == first or ans > 2000000: ans = -1 break print(ans) 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" p02596,s405035649,Accepted,"import time K=int(input()) mod=7%K if 7%K==0: print(1) exit() ans=1 now=time.time() while 1: ans+=1 mod=(mod*10+7)%K if mod==0: print(ans) break if time.time()-now>=1.8: print(-1) break " p02596,s947288022,Accepted,"k = int(input()) x = 7 for i in range(1000000): x %= k if x == 0: print(i + 1) break x = x * 10 + 7 else: print(-1) " p02596,s074532409,Accepted,"n=int(input()) if n%2==0: print(-1) else: c=1 k=7 while 1: if k%n==0: break if c>n: c=-1 break k=(k%n)*10+7 c+=1 #print(k) print(c)" p02596,s542872979,Accepted,"K = int(input()) if K % 2 == 0 or K % 5 == 0: print(-1) exit() tmp1 = 0 for i in range(1, 2 * K + 1): tmp1 += 7 * pow(10, i, K) if tmp1 % K == 0: print(i) exit() print(-1)" p02596,s603911983,Accepted,"k = int(input()) ans = -1 seq = [0] seq.append(7%k) for i in range(2,k+1): seq.append((seq[i-1]*10+7)%k) for j in range(1,k+1): if seq[j] == 0: ans = j break print(ans) " p02596,s014764951,Accepted,"k = int(input()) mod = 0 for i in range(1, 10**6): mod = ((mod * 10) + 7) % k if mod == 0: print(i) exit() print(-1)" p02596,s917087510,Accepted,"def main(): k = int(input()) num = 1 n = 7 if (k % 2 == 0): print(-1) return for i in range(1000000): if (n % k == 0): print(num) return else: n = (n*10 + 7) %k num += 1 print(-1) if __name__ == '__main__': main() " p02596,s020252929,Accepted,"def main(): K = int(input()) if K % 2 == 0 or K % 5 == 0: print(-1) return cnt = 1 tmp = 7 while tmp % K != 0: tmp = tmp * 10 + 7 tmp %= K cnt += 1 print(cnt) main() " p02596,s592144508,Accepted,"K = int(input()) n = 1 x = 7 if (K % 2 == 0)or(K % 5 == 0): print( -1 ) exit( 0 ) # while 1: if x % K == 0: print( n ) break x = (x * 10 + 7) % K n += 1 # " p02596,s707933892,Accepted,"K = int(input()) if K%2==0 or K%5==0: print(-1) elif K == (1 or 7): print(1) else: mod = 7 % K mod_plus = mod i = 0 while mod != 0: i += 1 mod_plus = (mod_plus*10) % K mod = (mod + mod_plus) % K print(i+1)" p02596,s906466579,Accepted,"K = int(input()) if K % 2 == 0 or K % 5 == 0: print(-1) exit() m = 7 % K cnt = 1 d = 10 % K while True: if m == 0: break cnt += 1 m = (m+7*d)%K d = d*10%K print(cnt)" p02596,s338532473,Accepted,"k = int(input()) n = 0 for i in range(k+1): n += pow(10, i, k)*7 n %= k if n==0: print(i+1) break else: print(-1)" p02596,s590011655,Accepted,"K=int(input()) X=[0]*K m=0 p=7 for i in range(K): m=(m+p)%K if m==0: print(i+1) break elif X[m]==1: print(-1) break else: X[m]=1 p=(p*10)%K" p02596,s150931839,Accepted,"import sys k = int(input()) a = [0]*k a[0] = 7 % k for i in range(1, k): a[i] = (10*a[i-1]+7) % k for i in range(k): if a[i] == 0: print(i+1) sys.exit() print(-1)" 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) " p02596,s139409736,Accepted,"n=int(input()) if(n%2==0 or n%5==0): print(-1) else: a=7 ans=1 flag=1 while(flag): if(a%n==0): print(ans) flag=0 break else: ans+=1 s=str(a) s1='7' s2=int(s+s1) a=(int(s2))%n " p02596,s409039643,Accepted,"K = int(input()) if K % 2 == 0 or K % 5 == 0: print(-1) exit() i = 0 sevens = 0 while True: sevens += 7 * pow(10, i, K) sevens %= K i += 1 if sevens == 0: break print(i) " p02596,s521887912,Accepted,"k = int(input()) x = 7 for i in range(k): if x%k==0: print(i+1) exit() x = (x*10 + 7)%k print(""-1"")" p02596,s516939275,Accepted,"k = int(input()) n = 0 for i in range(1, k+1): n = (n * 10 + 7) % k if n == 0: print(i) exit() print('-1')" p02596,s794055633,Accepted,"k=int(input()) t=7 for i in range(k): if t%k==0: print(i+1) break else: t=(10*t+7)%k else: print(-1)" p02596,s810333089,Accepted,"amari=0 k=int(input()) for i in range(k+1): amari+=7*pow(10,i,k) amari%=k if amari==0: print(i+1) exit() print(-1)" p02596,s400958400,Accepted,"def main(): k = int(input()) n = 7 if k % 2 == 0: print(-1) else: for i in range(10 ** 7): if n % k == 0: print(i + 1) break n = (10 * n + 7) % k else: print(-1) if __name__ == '__main__': main() " p02596,s325233731,Accepted,"def main(): K = int(input()) v = 7 % K for i in range(K+5): if v == 0: print(i+1) return v = v * 10 + 7 v %= K print(-1) if __name__ == '__main__': main() " 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)" p02596,s322659492,Accepted,"k=int(input()) num=7%k for i in range(1, 10**6+1): if num%k==0: print(i) exit() else: num=(10*num+7)%k print(-1) " p02596,s991669975,Accepted,"k = int(input()) rem = 7%k alreadys = [False]*k alreadys[rem] = True ans = 1 while True: if rem == 0: print(ans) exit() ans += 1 rem = (rem*10+7)%k if alreadys[rem]: print(-1) exit() alreadys[rem] = True" p02596,s164951268,Accepted,"K = int(input()) def main(K): cnt = 1 amari = 0 while True: amari *= 10 amari += 7 amari %= K if amari == 0: return cnt else: cnt += 1 if K % 2 == 0 or K % 5 == 0: print(-1) else: print(main(K))" p02596,s040263855,Accepted,"K = int(input()) X = 7 p = 0 for i in range(1, K+2): p = (p + X)%K if(p == 0): print(i) exit() X = (X*10)%K print(-1)" p02596,s340563392,Accepted,"k=int(input()) cnt=0 for i in range(10**6+1): cnt+=7*pow(10,i,k) cnt%=k if cnt==0: print(i+1) exit() print(-1)" p02596,s733034314,Accepted,"K = int(input()) def calculate(k): if k % 2 == 0: print(-1) return if k % 5 == 0: print(-1) return res = 1 m = (((10 ** res) - 1) // 9) * 7 while m % k > 0: res += 1 m = m % k m = m * 10 + 7 print(res) calculate(K) " p02596,s372634187,Accepted,"import sys def resolve(): readline=sys.stdin.readline k=int(readline()) to=10**6 svn=[0]*to svn[0]=7%k if svn[0]==0: print(1) return for i in range(1,to): svn[i]=(svn[i-1]*10)%k for i in range(1,to): svn[i]+=svn[i-1] if svn[i]%k==0: print(i+1) return print(-1) return resolve()" p02596,s851739332,Accepted,"K = int(input()) sevens = 7 if K % 2 == 0 or K % 5 == 0: print(-1) else: i = 1 while True: if sevens % K == 0: print(i) break sevens = (sevens % K)*10+7 i += 1 " p02596,s138800211,Accepted,"K = int(input()) r = 7 % K ans = -2 for i in range(K): if r == 0: ans = i break r = 10*r + 7 r = r % K print(ans+1)" p02596,s002001078,Accepted,"import sys sys.setrecursionlimit(10**6) def main(input, print): K = int(input()) x = 7 % K for i in range(1, K+1): if x == 0: print(i) return x = (x*10+7) % K print(-1) if __name__ == '__main__': main(sys.stdin.readline, print) " p02596,s843327068,Accepted,"K = int(input()) a = 7 % K cnt = 1 while a: a = (10*a+7) % K cnt += 1 if K < cnt: cnt = -1 break print(cnt)" p02596,s268279139,Accepted,"K = int(input()) tmp = 7 for i in range(K): if tmp%K == 0: print(i+1) exit() tmp = (tmp*10+7)%K print(-1)" p02596,s621818311,Accepted,"k=int(input()) d=7%k c=-1 for i in range(10**6+10): if d==0: c=i+1 break d=(d*10+7)%k print(c)" p02596,s278102659,Accepted,"# C - Repsept def get_mod(prev_mod): global K return (prev_mod * 10 + 7) % K K = int(input()) mod = 0 count = 0 mods = set() while True: mod = get_mod(mod) count += 1 if mod == 0: print(count) break else: if mod in mods: print(-1) break else: mods.add(mod)" p02596,s946330578,Accepted,"k = int(input()) seven = 7 ans = -1 for i in range(1,k+1): seven %= k if seven == 0: ans = i break else: seven = seven * 10 + 7 print(ans)" p02596,s799377891,Accepted,"K = int(input()) num = 0 cnt = 0 ans = -1 for i in range(K): num = num*10 +7 cnt += 1 if num%K != 0: num = num%K else: ans = cnt break print(ans)" p02596,s774673765,Accepted,"K = int(input()) x = 7%K for i in range(K): if x == 0: print(i+1) exit() x = (x*10+7)%K print(-1) " p02596,s343726574,Accepted,"import sys K = int(input()) seven = 0 for i in range(K+2): seven += (7 * pow(10, i, K)) % K seven %= K if seven == 0: print(i+1) sys.exit() print(-1)" 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')" p02596,s867299165,Accepted,"K = int(input()) t = 7 for i in range(K): if t % K == 0: print(i + 1) break t = (t * 10 + 7) % K else: print(-1) " 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)" p02596,s918798577,Accepted,"import sys k=int(input()) mae=0 for i in range(10**6+1): now=(10*mae+7) if now%k==0: print(i+1) sys.exit() mae=now%k print(-1)" p02596,s249458101,Accepted,"# coding: utf-8 # Your code here! K = int(input()) s = 7 % K for i in range(1, K+1) : if i != 1 : s = (10*s + 7) % K if s == 0 : print(i) exit() print(-1)" p02596,s537390892,Accepted,"k = int( input() ) # a = 7 # for _ in range( 30 ): # print( a % k ) # a = 10 * a + 7 rem_list = [] first_rem = 7 % k a = 7 cnt = 0 while True: r = a % k cnt += 1 if r == 0: print( cnt ) break elif cnt > 2 and cnt > k: print( -1 ) break else: a = ( 10 * r + 7 ) % k" p02596,s528689295,Accepted,"K = int(input()) if K%2 == 0 or K%5 == 0: print(-1) exit(0) count = 0 an = 0 while True: an = (10*an + 7) % K count +=1 if an == 0: break print(count)" p02596,s806901538,Accepted,"k = int(input()) n = 0 for i in range(10**6 + 1): n += 7 * pow(10, i, k) n %= k if n % k == 0: print(i+1) exit() print(-1)" p02596,s859438137,Accepted,"k = int(input()) dic = dict() cnt = 1 num1 = 7 % k num2 = 70 % k while True: if dic.get(num1):break if (num1) == 0: print(cnt) exit() dic[num1] = 1 num1 = (num1 + num2) %k num2 = (num2 * 10) %k cnt += 1 #print(num1, num2) print(-1)" p02596,s518243137,Accepted,"from collections import defaultdict K = int(input()) if K % 2 == 0: print(-1) exit() c = 1 d = 7 % K D = defaultdict(int) while True: if d == 0: print(c) exit() if D[d] == 1: print(-1) exit() D[d] += 1 c += 1 d = (d * 10 + 7)%K" p02596,s134611896,Accepted,"K = int(input()) N = 1000000 x = 7 % K for i in range(1, N+1): if x == 0: break x = (x * 10 + 7) % K if i == N: i = -1 print(i)" 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" p02596,s323483959,Accepted,"k = int(input()) s = 7 for i in range(1, k+1): # rangeの上限がk if s % k == 0: print(i) break s = (s * 10 + 7) % k # %kが難しい else: # for文にもelseが使える print(-1)" p02596,s991672184,Accepted,"k = int(input()) ans = 7%k for i in range(1, 10**6 + 1): if ans%k == 0: print(i) exit() else: ans = (ans*10 + 7)%k print(-1)" p02596,s541234062,Accepted,"K=int(input()) t=0 for i in range(K+2): t=(10*t+7)%K if t%K==0: ans=i+1 break else: ans=-1 print(ans)" p02596,s229662384,Accepted,"import math k = int(input()) seq = 7 ans = -1 for i in range(k): mod = seq%k if mod == 0: ans = i+1 break seq = mod*10 + 7 print(ans) " p02596,s631804156,Accepted,"import functools K=int(input()) if K%2==0: print(-1) exit(0) mod=0 for i in range(1,pow(10,6)): mod=(mod*10+7)%K if mod==0: print(i) exit(0) print(-1)" p02596,s101651647,Accepted,"(K,) = [int(x) for x in input().split()] ans = 0 seven = 7 for i in range(1000000): if seven % K == 0: print(i + 1) break seven = (10 * seven + 7) % K else: print(-1) " p02596,s914894591,Accepted,"k = int(input()) t = 7 t %= k for i in range(k+1): if t == 0: print(i+1) break #常に余りを用いる ⇒ 10**7桁の演算 t = (t*10 + 7)%k else:print(-1) """""" else: for(while)文を break文で抜ける(真) ⇒ 実行しない forのイテラブルを使い切る、whileが偽になる ⇒ 実行する """"""" p02596,s160906474,Accepted,"k=int(input()) if k%2==0 or k%5==0: print(-1) exit() a=7 ans=1 while ans<10**7: if a%k==0: print(ans) exit() a%=k a*=10 a+=7 ans+=1" 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) " p02596,s217980789,Accepted,"import sys input = lambda: sys.stdin.readline().rstrip() def main(): k = int(input()) ans = 1 if k % 2 == 0 or k % 5 == 0: print(-1) else: a = 7 while 1: if a % k == 0: print(ans) break else: a = (a % k) * 10 + 7 ans += 1 if __name__ == '__main__': main() " p02596,s221470450,Accepted," K = int(input()) cur = 7 for n in range(K): if cur % K != 0: cur = (cur * 10 + 7) % K else: print(n + 1) break else: print(-1) " p02596,s023781496,Accepted,"K = int(input()) if K % 7 == 0: L = 9 * K / 7 else: L = 9 * K if L % 2 == 0 or L % 5 == 0: print(-1) else: rest = 1 ans = 0 while True: rest *= 10 ans += 1 rest = rest % L if rest == 1: break print(ans)" p02596,s060905617,Accepted,"K = int(input()) a = 0 for i in range(K): a = (10 * a + 7) % K if a % K == 0: print(i+1) exit() else: a %= K print(-1) " p02596,s123664713,Accepted,"#!/usr/bin python3 # -*- coding: utf-8 -*- k = int(input()) if k%2==0 or k%5==0: print(-1) else: ret = 1 res = 7%k while res != 0: res = (res * 10 + 7) % k ret += 1 print(ret) " p02596,s799707790,Accepted,"def first_multiple(k): n = 0 for i in range(1, k + 1): n = (n * 10 + 7) % k if n % k == 0: return i return -1 k = int(input()) print(first_multiple(k)) " p02596,s973128175,Accepted,"K = int(input()) a = [7%K] for i in range(1, K): a.append((a[i-1]*10+7)%K) isCorrect = False for i in range(K): if a[i] == 0: print(i+1) isCorrect = True break if not isCorrect: print(""-1"")" p02596,s032575614,Accepted,"k=int(input()) count=1 num=7 for _ in range(k): if num%k == 0: print(count) break else: count += 1 num = (num % k)*10 + 7 else: print(-1)" p02596,s535492696,Accepted," k=int(input()) a=[] judge=0 a.append("""") a.append(7%k) for i in range(2,10**6+1): a.append((a[i-1]*10+7)%k) for i in range(1,k+1): if a[i]==0: print(i) judge=1 break if judge==0: print(-1)" p02596,s969347190,Accepted,"k = int(input()) if k==1 or k==7: print(1) elif k%2==0: print(-1) else: cnt = 1 pre = 7 while(True): surp = (pre*10+7)%k cnt += 1 if surp==0: break if cnt>1000000: cnt = -1 break pre = surp print(cnt)" p02596,s159971601,Accepted," def solve(K): a = 7 % K for i in range(1, K+1): if a == 0: return i a = (a * 10 + 7) % K return -1 def solve0(K): a = 7 for i in range(0, 10000): if a % K == 0: return i a = a*10+7 return -1 K = int(input()) print(solve(K)) " p02596,s486300112,Accepted,"K = int(input()) m = 7 % K for i in range(1, K + 1): if m % K == 0: print(i) break m = (10 * m + 7) % K else: print(-1)" p02596,s797416096,Accepted,"K = int(input()) if K % 7 == 0: L = 9 * K // 7 else: L = 9 * K ans = -1 n = 10 for i in range(1, L): surplus = n % L if surplus == 1: ans = i break n = 10 * surplus print(ans)" p02596,s607775371,Accepted,"n = int(input()) s = 7 for i in range(1, int(3e6)): if s%n == 0: print(i) exit() s = (s*10 + 7) % n print(-1) " p02596,s445445808,Accepted,"import sys input = sys.stdin.readline def main(): K = int(input()) if K%2==0: return -1 if K % 7: L = 9*K else: L = 9*K//7 a = 1 for i in range(1,L+1): a = (a * 10) % L if a == 1: return i return -1 ans =main() print(ans)" p02596,s007620250,Accepted,"K = int(input()) F = set() val = 7 flg = True for i in range(K+6): if val % K == 0: flg = False print(i+1) break F.add(val%K) val *= 10 val += 7 val %= K if val % K in F: break if flg: print(-1)" p02596,s242014908,Accepted,"k = int(input()) kkk = [0] * k kkk[0] = 7 % k ans = -1 for i in range(1, k): kkk[i] = (kkk[i - 1] * 10 + 7) % k for j in range(k): if kkk[j] == 0: ans = j + 1 break print(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)" 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"") " 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() " p02596,s152241359,Accepted,"K = int(input()) if K % 2 == 0 or K % 5 == 0: print(-1) exit() i = 0 ai = 0 while True: ai = (ai * 10 + 7) % K i += 1 if ai == 0: break print(i)" 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)" p02596,s211853344,Accepted,"k = int(input()) val = 7 val %= k for i in range(k+1): if(val ==0): print(i+1) break val = (val * 10 + 7) % k else: print(-1)" p02596,s364746599,Accepted,"k = int(input()) m = 7 if(k%2==0): print(""-1"") else: i = 1 while True: m = m%k if(m==0): print(i) break if(i>k): print(""-1"") break m *= 10 m += 7 i += 1 " p02596,s138598450,Accepted,"def main(): K = int(input()) a = 7 % K for i in range(1, K+1): if a == 0: print(i) return a = a * 10 + 7 a %= K print(-1) if __name__ == '__main__': main() " p02596,s368277224,Accepted,"K = int(input()) a = 7 p = {} ans = 0 while True: t = a % K ans += 1 if t == 0: print(ans) break if t in p: print(-1) break a = 10*t + 7 p[t] = 1 " p02596,s652902975,Accepted,"k = int(input()) if k%2 == 0: ans = -1 else: x = 0 ans = -1 for i in range(10**6+1): x += 7*pow(10, i, k) x %= k if x%k == 0: ans = i+1 break print(ans)" p02596,s597014757,Accepted,"# -*- coding: utf-8 -*- """""" Created on Mon Sep 14 13:35:45 2020 @author: ezwry """""" k = int(input()) a = 7 for i in range(k): a = a % k if a == 0: print(i+1) exit() else: a = a*10 + 7 print(-1)" p02596,s909653276,Accepted,"k = int(input()) if k % 2 == 0 & k % 5 == 0: print(-1) exit() x = 7 % k s = set() i = 1 ans = -1 while x not in s: if x == 0: ans = i break s.add(x) x = (10 * x + 7) % k i += 1 print(ans)" p02596,s292890950,Accepted,"k = int(input()) s = 7 num = 1 res = True if k == 2: print(-1) else: for i in range(k): s %= k if s == 0: res = False print(num) break num += 1 s *= 10 s += 7 if res: print(-1)" p02596,s756859014,Accepted,"k=int(input()) a=0 for i in range(k): a+=7*pow(10,i,k) a%=k if a==0: print(i+1) exit() print(-1)" p02596,s110595864,Accepted,"n = int(input()) if n==0: print(0) if n%2==0: print(-1) elif n%5==0: print(-1) else: k=7 l=1 k%=n while k!=0: l+=1 k*=10 k+=7 k%=n #print(k) print(l) " p02596,s325635268,Accepted,"k = int(input()) n = 0 for i in range(1, 10**6+100): n = n * 10 + 7 n %= k if n == 0: print(i) exit() print(-1) " p02596,s165273978,Accepted,"K = int(input()) L,r = K*9 if K%7 else K*9//7, 10 for i in range(1,L+1): r %= L if r == 1: print(i) exit() r *= 10 print(-1)" p02596,s875385822,Accepted,"k = int(input()) if k%2 == 0 or k%5 == 0: print(-1) else: a = 0 cnt = 1 while True: a = (10*a+7)%k if a == 0: print(cnt) break cnt+=1 " p02596,s441080072,Accepted,"K=int(input()) result=-1 if K%2!=0 and K%5!=0: a=0 b=7 for i in range(K): a+=b a=a%K b=(b*10)%K if a==0: result=i+1 break print(result)" p02596,s262141297,Accepted,"K = int(input()) if K % 2 == 0 or K % 5 == 0: print(-1) exit() i, ai = 0, 0 while True: ai = (ai * 10 + 7) % K i += 1 if ai == 0: print(i) exit()" p02596,s877511599,Accepted,"K = int(input()) if(K%2 == 0): print(""-1"") exit() A = 7 ans = 1 while(A < K): #O(6) A = A*10 + 7 ans += 1 while(True): #print(A) A = A % K #1 if(ans > K): print(""-1"") exit() if(A==0): #1 print(ans) exit() A = A * 10 + 7 # 1 ans += 1# 1 " p02596,s880459010,Accepted,"import sys k = int(input()) if k%2 == 0 or k%5 ==0: print(-1) else: a = 7%k if a == 0: print(1) else: for i in range(2, 10000000): a = (10*a+7)%k if a == 0: print(i) sys.exit() print(-1) " p02596,s769434807,Accepted,"import sys k = int(input()) if k % 7 == 0: k = k // 7 tmp = 1 for i in range(k+2): if tmp % k == 0: print(i+1) sys.exit() tmp = (tmp * 10 + 1) % k print(-1)" p02596,s640308502,Accepted,"K = int(input()) count = 1 mod = 7 answer = -1 for _ in range(K): if mod % K == 0: answer = count break count += 1 mod = (mod * 10 + 7) % K print(answer)" p02596,s071916917,Accepted,"K = int(input()) if K == 7 or K == 1: print(1) else: if K % 7 == 0: K //= 7 r = 1 for i in range(1,K+1): if r == 0: print(i) break r += pow(10,i,K) #print(r) r %= K else: print(-1)" p02596,s663402922,Accepted,"K = int(input()) X = 7 for i in range(1, 10 ** 6 + 1): if not X % K: print(i) exit() X = (X + 7 * pow(10, i, K)) % K print(-1) " p02596,s405067634,Accepted,"import sys def main(): k = int(input()) a =7%k if a == 0: print(1) sys.exit() for i in range(2,10**7): a = (10*a+7) % k if a == 0: print(i) sys.exit() print(-1) main()" p02596,s993638972,Accepted,"def main(): k = int(input()) if k & 0: print(-1) return r = 7 % k l = 0 while r and l < k: r = (r * 10 + 7) % k l += 1 print([l+1, -1][l == k]) if __name__ == '__main__': main() " p02596,s055011171,Accepted,"K = int(input()) t = 7 for i in range(K): if t % K == 0: print(i + 1) break t = (t * 10 + 7) % K else: print(-1)" p02596,s372188741,Accepted,"K = int(input()) ans = 7%K A = 1 C = [0]*K if K == 1 or K == 7: print(1) exit() for i in range(K): A = (A*10)%K ans += (A*7) ans %= K if ans == 0: break if C[ans] == 0: C[ans] += 1 else: print(-1) exit() print(i+2)" p02596,s965484839,Accepted,"import sys K=int(input()) L=9*K if L%7==0: L = L//7 n = 1 for i in range(1,K+1): n = n * 10 % L if n == 1: print(i) sys.exit() print(-1) " p02596,s346277782,Accepted,"k = int(input()) a = 7 % k count = 1 for i in range(1,k+1): if a == 0: print(count) break else: a = (10 * a + 7) % k count += 1 if i == k: print(-1)" p02596,s790234169,Accepted,"K = int(input()) ans = -1 t = 0 for i in range(10**6): t = t * 10 + 7 t %= K if t == 0: ans = i + 1 break print(ans) " p02596,s678310465,Accepted,"k = int(input()) ans = 1 mod = 7 for i in range(k): if mod % k != 0: ans += 1 mod = (mod * 10 + 7) % k else: break print(ans if mod%k == 0 else ""-1"")" p02596,s281393372,Accepted,"#ABC 174 C k = int(input()) sevens = [0] * k sevens[0] = 7 % k if k == 7 or k == 1: print(1) else: for i in range(1, k): new = (sevens[i - 1] * 10 + 7) % k sevens[i] = new if new == 0: print(i + 1) break else: print(-1)" p02596,s203692238,Accepted,"K = int(input()) if K % 2 == 0 or K % 5 == 0: print(-1) else: i = 1 r = 7 % K while(True): if r == 0: print(i) break r = (r * 10 + 7) % K i += 1 " p02596,s989022685,Accepted,"K=int(input()) x=7%K i=1 flag=0 for j in range(K+1): if x==0: print(i) flag=1 break x=(10*x+7)%K i+=1 if flag==0: print(-1)" p02596,s138999359,Accepted,"K = int(input()) x = [] x.append(7%K) for i in range(1,K): x.append((x[i-1]*10+7)%K) for i,n in enumerate(x): if n == 0: print(i + 1) exit() print(-1)" p02596,s359326009,Accepted,"k = int(input()) flag = False resid = 7 if resid%k==0: i = -1 flag = True else: for i in range(k): resid = (resid*10+7)%k if resid == 0: flag = True break if flag: print(i+2) else: print(-1)" p02596,s242048462,Accepted,"K = int(input()) if K % 2 == 0 or K % 5 == 0: print(-1) exit() res = -1 count = 0 ai = 0 while(True): ai = (ai*10 + 7) % K count += 1 if(ai == 0): res = count break print(res) " p02596,s403157908,Accepted,"K = int(input()) Ali = [] s = 7 if s%K == 0: print(1) exit() for i in range(1000100): s = (s*10+7)%K if s%K == 0: print(i+2) exit() print(-1)" p02596,s811701398,Accepted,"k = int(input()) curr = 7 for i in range(k): if curr%k: curr *= 10 curr += 7 curr %= k else: print(i+1) break else: print(-1)" p02596,s211365416,Accepted,"res = 7 cnt = 1 k = int(input().rstrip()) res_list = [0 for _ in range(k)] flg = 0 while True: res %= k if res == 0: flg = 1 break if res_list[res] == 1: break res_list[res] = 1 cnt += 1 res = res * 10 + 7 if flg == 1: print(cnt) else: print(-1) " p02596,s017278992,Accepted,"K = int(input()) t = 7 ans = 1 for _ in range(K): if t % K == 0: print(ans) exit(0) else: t = (t * 10 + 7) % K ans += 1 print(-1)" p02596,s169357071,Accepted,"def main(k): r0 = 7 % k if r0 == 0: print(1) return if k % 2 == 0 or k % 5 == 0: print(-1) return rs = [r0] while True: ri = (10 * rs[-1] + r0) % k if ri == 0: break rs.append(ri) if len(rs) >= 3 and rs[-1] == rs[-2] == rs[-3]: print(-1) return print(len(rs) + 1) main(int(input()))" p02596,s363950011,Accepted,"def main(): n = int(input()) mod = 0 pow10 = 1 for i in range(20*n): mod = (mod+7*pow10) % n if mod == 0: print(i+1) return pow10 = pow10*10 % n print(-1) main() " p02596,s318095930,Accepted,"# https://atcoder.jp/contests/abc174/submissions/15768313 さんの回答、参照 K = int(input()) num = 0 if K%2 == 0: print(-1) else: for i in range(1, 1000000): num = num*10 + 7 num %= K if num == 0: print(i) break else: print(-1)" p02596,s446810158,Accepted,"import time start=time.time() k=int(input()) if k%2==0:exit(print(-1)) ans=0 x=k for i in range(10**9): while x%10!=7: x+=k if time.time()-start>=1.9:exit(print(-1)) x//=10 if x==0:exit(print(i+1))" p02596,s534391956,Accepted,"K = int(input()) ans = -1 tmp = 0 for i in range(1, K + 1): tmp = (tmp*10%K + 7) % K if tmp == 0: ans = i break print(ans)" p02596,s725207572,Accepted,"def main(): K = int(input()) curr = 7 % K for i in range(1, K+1): if curr == 0: print(i) return curr = (curr*10+7) % K else: print(-1) if __name__ == ""__main__"": main() " p02596,s188256809,Accepted,"k = int(input()) if k%2 == 0 or k%5 == 0: print(-1) exit() mod = 7 % k ans = 1 while mod != 0: mod = (mod*10+7)%k ans += 1 print(ans)" p02596,s977673740,Accepted,"k=int(input()) s=0 for i in range(1,10**6): s=(s*10+7)%k if s==0: print(i) break else: print(-1)" p02596,s920061713,Accepted,"#import #import math #import numpy as np K = int(input()) if K == 7: print(1) exit() t = 7 % K for i in range(1, K * 2): if t == 0: print(i) exit() t = (t * 10 + 7) % K print(-1)" p02596,s008220123,Accepted,"from sys import stdin K = int(stdin.readline().rstrip()) def main(K): a=0 for i in range(1,K+1): a = ((10%K) * a + 7)%K if a == 0: return i return -1 print(main(K))" p02596,s548463918,Accepted,"k = int(input()) mod = 7 % k counter = 1 memo = 1 mod_map = set() mod_map.add(mod) while mod != 0: memo = ((memo % k) * (10 % k)) % k mod = (mod + 7 * memo) % k if mod not in mod_map: mod_map.add(mod) else: counter = -1 break counter += 1 if mod == 0: break print(counter) " p02596,s895024622,Accepted,"k = int(input()) if k % 2 == 0 or k % 5 == 0: x = -1 else: x = 1 y = 7 z = 7 while y % k != 0: z = (z * 10) % k y += z x += 1 print(x)" p02596,s856968545,Accepted,"from collections import defaultdict k = int(input()) ms = defaultdict(int) ans = 1 i = 7 while True: if i % k == 0: print(ans) exit() i = (i * 10 + 7) % k if ms[i] > 0: print(-1) exit() ms[i] += 1 ans += 1 " p02596,s549947641,Accepted,"k=int(input()) curr=7 curr=curr%k count=1 if(k%2==0 or k%5==0): print(-1) else: for i in range(1,k+1): if(curr==0): print(count) break else: curr=(curr*10+7)%k count+=1" p02596,s608168858,Accepted,"#C import sys k=int(input()) s=0 for i in range(k): s=s*10+7 if s%k!=0: s=s%k else: print(i+1) sys.exit() print(-1)" p02596,s742813983,Accepted,"K = int(input()) l = [0 for i in range(K)] r = 0 for i in range(K): r = (10*r+7)%K if r == 0: print(i+1) break elif l[r] != 0: print(-1) break else: l[r] = 1" p02596,s559311025,Accepted,"limit = pow(10, 7) K = int(input()) num = ""7"" if K % 2 == 0 or K % 5 == 0: print (-1) else: total = 0 flag = False for i in range(1, limit + 1): total = (total * 10 + 7) % K if total == 0: flag = True break if flag: print (i) else: print(-1)" p02596,s727454135,Accepted,"import sys def Ii():return int(sys.stdin.readline()) def Mi():return map(int,sys.stdin.readline().split()) def Li():return list(map(int,sys.stdin.readline().split())) k = Ii() if k%2 == 0 or k%5 == 0: print(-1) exit(0) elif k%7 == 0: k = k//7 ans = 1 a = 10 mod = a%(9*k) while mod != 1: mod *= 10 mod = mod%(9*k) ans += 1 print(ans)" p02596,s632415410,Accepted,"K = int(input()) cur = 7 for i in range(1, K + 1): if cur % K == 0: print(i) quit() cur = (10 * cur + 7) % K print(-1)" p02596,s870290436,Accepted,"k = int(input()) mod = 7%k path = [mod] ans = '-1' for i in range(1,k+1): if mod == 0: ans = i break mod = (mod*10 + 7)%k path.append(mod) if mod == path[0]: ans = '-1' break print(ans)" p02596,s240543779,Accepted,"K = int(input()) def f(K): v = 0 for i in range(1, K + 1): v = (v * 10 + 7) % K if v == 0: return i return -1 print(f(K)) " p02596,s382254198,Accepted,"k = int(input()) ans = 1 x = 7 while ans <= k: if x % k == 0: print(ans) break x = x * 10 + 7 x %= k ans += 1 else: print(-1)" p02596,s636832081,Accepted,"K = int(input()) if K % 2 == 0 or K % 5 == 0: print(-1) exit() i = 0 sevens = 0 while True: sevens += 7 * pow(10, i, K) sevens %= K i += 1 if sevens == 0: break print(i) " p02596,s348486955,Accepted,"k = int(input()) ans = -1 memo = 7 % k a = 7 % k for i in range(k): if a == 0: ans = i+1 break a = (10*a+7) % k print(ans) " p02596,s172963527,Accepted,"#! /usr/bin/env python3 import sys int1 = lambda x: int(x) - 1 read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(500000) k = int(readline()) ans = -1 acc = 7 % k for n in range(1, k + 10): if acc == 0: ans = n break acc = (10 * acc + 7) % k print(ans) " p02596,s004790156,Accepted,"K=int(input()) res=1 x=0 for i in range(K): x+=7*res x%=K if x%K==0: print(i+1) break res*=10 res%=K else: print(-1) " p02596,s292688143,Accepted,"K = int(input()) x = 7 % K #mod(K) if K == 1 or K == 7: print(1) exit() ans = 1 i = 0 while i < K: ans += 1 x = (x * 10 + 7) % K if x == 7 % K: print('-1') exit() if x == 0: print(ans) exit() i += 1 print('-1')" p02596,s157818498,Accepted,"k = int(input()) if k % 2 == 0 or k % 5 == 0: print(-1) exit() curr = 0 i = 1 while True: curr *= 10 curr += 7 curr %= k if curr == 0: print(i) break i += 1 if i > 1000000: print(-1) break" p02596,s212326172,Accepted,"k = int(input()) if k % 2 == 0: print(-1) elif k in [1,7]: print(1) else: amari = [7] tmp = 7 for i in range(k): tmp = (tmp * 10) % k if tmp != 7: amari.append(tmp%k) else: break amari = amari * ((k//len(amari)) +1) ans = amari[0] for i in range(1, k+1): ans += amari[i] if ans % k == 0: print(i+1) break else: print(-1)" p02596,s693025478,Accepted,"k = int(input()) dp =[0] for i in range(10**6+1): dp.append((dp[-1]*10+7)%k) if dp[-1]==0:print(i+1);exit() print(-1)" p02596,s416929938,Accepted,"import sys k = int(input()) n = 7 for i in range(k): if (n % k == 0): print(i + 1) sys.exit() n = (n * 10 + 7) % k print(-1)" p02596,s160564477,Accepted,"k=int(input()) ans=7 cnt=1 if k%2==0 or k%5==0: print(-1) else: while True: if ans%k==0: break ans=(ans*10+7)%k cnt+=1 print(cnt)" p02596,s089108036,Accepted,"K = int(input()) seed = 0 OK = False for i in range(K): seed = (10*seed +7)%K if seed == 0: print(i+1) OK = True break if not OK: print(-1) " p02596,s497297531,Accepted,"import sys def main(): k = int(input()) if k == 7 or k == 1: print(1) sys.exit() r = 7%k g = {r} ans = 1 while True: ans+=1 r = (10*r+7)%k if r==0: print(ans) break if r in g: print(-1) break else: g.add(r) main()" p02596,s144129562,Accepted,"K=int(input()) if K%7==0: L=9*K//7 else: L=9*K if L%2==0 or L%5==0: print(-1) exit() mod=1 ans=0 for i in range(L): mod*=10 mod=mod%L if mod==1: ans=i+1 break print(ans)" p02596,s854932979,Accepted,"import sys input = sys.stdin.readline k = int(input()) n = 1 if k % 2 == 0: n = -1 else: r = 7 % k s = r while True: if r == 0: break elif n > 1000000: n = -1 break else: r = (r * 10 + s) % k n += 1 print(n)" p02596,s293662058,Accepted,"import sys #import time from collections import deque, Counter, defaultdict #from fractions import gcd import bisect import heapq #import math import itertools import numpy as np input = sys.stdin.readline sys.setrecursionlimit(10**8) inf = 10**18 MOD = 1000000007 ri = lambda : int(input()) rs = lambda : input().strip() rl = lambda : list(map(int, input().split())) k = ri() reses=[] cnt = 1 tmp = 7 for i in range(k+1): res = tmp % k if res==0: print(cnt) sys.exit(0) tmp = res * 10 + 7 cnt += 1 print(-1)" p02596,s870301399,Accepted,"import sys input = lambda: sys.stdin.readline().rstrip('\r\n') K = int(input()) i = 1 v = 7 % K V = {v} while v != 0: i += 1 v = (10 * v + 7) % K if v in V: print(-1) break V.add(v) else: print(i) " p02596,s739994079,Accepted,"def resolve(): K = int(input()) a = [0] * (K + 1) 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) return print(-1) resolve() " p02596,s334999441,Accepted,"k = int(input()) ku = k a = [0]*ku c = [0]*ku b = [0]*ku for i in range(ku): if i == 0: b[i] = 7%k else: b[i] = (b[i-1]*10+7)%k if 0 in b: print(b.index(0)+1) else: print(-1)" p02596,s966859043,Accepted,"import sys k = int(input()) a = 0 for i in range(1, k+1): a = (a*10+7)%k if a == 0: print(i) sys.exit() print(-1) " p02596,s281735529,Accepted,"k = int(input()) x = 7 ans = 1 s = set() while x%k != 0: ans += 1 x = (x*10%k+7)%k if x in s: ans = -1 break s.add(x) print(ans)" p02596,s785333355,Accepted,"k = int(input()) num = 0 res = 0 cnt = [0] * k while True: num = (num * 10 % k + 7) % k res += 1 if num == 0: print(res) break if cnt[num] == 1: print(-1) break cnt[num] += 1" p02596,s415938118,Accepted,"k = int(input()) a = [7] * (10 ** 7) if k == 2: print(-1) exit() for i in range(10 ** 7-1): a[i] %= k if a[i] == 0: print(i + 1) exit() a[i + 1] = a[i] * 10+7 print(-1)" p02596,s913663684,Accepted,"K = int(input()) x = 0 for i in range(K + 5): x = (x * 10 + 7) % K if x == 0: print(i + 1) exit() print(-1) " p02596,s341639808,Accepted,"K = int(input()) if K%2==0: print(-1) elif K==1: print(1) elif K==7: print(1) else: if K%7==0: K = K//7 a = 1 cnt = 1 ind = -1 for i in range(K): a = (a*10)%K cnt += a if cnt%K==0: ind = i break if ind<0: print(-1) else: print(ind+2)" p02596,s820673642,Accepted,"def main(): K = int( input()) now = 7 now %= K for i in range(10**7): if now == 0: print(i+1) return now = (now*10+7)%K print(""-1"") if __name__ == '__main__': main() " p02596,s026282223,Accepted,"k = int(input()) x = 7 % k s = set() i = 1 while (not x in s): if x == 0: print(i) exit() s.add(x) x = (x*10+7) % k i += 1 print(-1) " p02596,s944994426,Accepted,"K = int(input()) t = 7 % K if t == 0: print(1) exit() for i in range(2, 10**6): t = (t * 10 + 7) % K if t == 0: print(i) exit() print(-1) " p02596,s563064405,Accepted,"ans=1 k=int(input()) t=7 for i in range(1,k+1): if t%k==0: print(i) exit() else: t=(t*10+7)%k print(-1) " p02596,s003538703,Accepted,"k = int(input()) n = 0 for i in range(k): n = (n * 10) + 7 n = n % k if n == 0: print(i + 1) exit() print(-1) " p02596,s700855101,Accepted,"k=int(input()) x=7 if k%2==0 or k%5==0: print(-1) exit() for i in range(k): y=x%k if y==0: print(i+1) exit() x=10*y+7 " p02596,s923463279,Accepted,"import sys def resolve(in_): k = int(next(in_)) if not k % 2: return -1 seven = 7 % k for i in range(1, 1000000): if not seven: return i i += 1 seven = seven * 10 + 7 if seven >= k: seven %= k return -1 def main(): answer = resolve(sys.stdin.buffer) print(answer) if __name__ == '__main__': main() " p02596,s737227435,Accepted,"k=int(input()) a=7 for i in range(k): if a%k==0: print(i+1) exit() a=(a*10+7)%k print(-1)" p02596,s524729737,Accepted,"import sys from collections import defaultdict K = int(input()) cnt = 0 now = 0 if K % 2==0: print(-1) sys.exit(0) for i in range(10**6): cnt += 1 now = (now*10 + 7)%K if now == 0: print(cnt) sys.exit(0) print(-1)" p02596,s065257595,Accepted,"K = int(input()) x = 7 for i in range(K): if x % K == 0: print(i+1) exit() else: x = (10*x + 7) % K print(-1)" p02596,s083789298,Accepted,"K=int(input()) x=0 if K%2==0 or K%5==0: print(-1) exit() for i in range(1000001): x=(x*10+7)%K if x==0: print(i+1) exit() print(-1)" p02596,s373031971,Accepted,"k=int(input()) sevens=0 for i in range(1,k+1): sevens=(sevens*10+7)%k if sevens==0: print(i) exit() print(-1)" p02596,s725437282,Accepted,"k, R, a = int(input()), 7, -1 for i in range(1, k+10): if not R%k: a = i break R = (R * 10 + 7) % k print(a)" p02596,s168235031,Accepted,"k = int(input()) x = 7 % k ans = 1 for i in range(k): if x == 0: print(ans) exit() ans += 1 x = (x * 10 + 7) % k print(-1) " p02596,s774836520,Accepted,"K = int(input()) count = 1 num = 7 if K % 2 == 0 or K % 5 == 0: count = -1 else: while True: if num % K == 0: break num = (num*10 + 7) % K count += 1 if count >= 10**6 * 10**5: count = -1 break print(count)" p02596,s465309963,Accepted,"k = int(input()) c = 0 x = 7 found = False while c <= k: if x % k == 0: found = True break c += 1 x = ((x * 10) + 7) % k if not found: print(-1) else: print(c + 1) " p02596,s723154415,Accepted,"def solve(): K = int(input()) if K%2==0 or K%5==0: return -1 ans = 1 cnt = 7%K i = 1 while cnt!=0: cnt += 7*pow(10,i,K) cnt %= K i += 1 ans += 1 return ans print(solve())" p02596,s875688462,Accepted,"K = int(input()) A = [0 for _ in range(K)] for i in range(K): if i == 0: mod = 7 % K else: mod = (10 * A[i-1] + 7) % K A[i] = mod if mod == 0: print(i+1) exit() print(-1) " p02596,s176873431,Accepted,"k = int(input()) if(k%2 == 0 or k%5 == 0): print('-1') else: if(k%7 == 0): k = k // 7 num = 1 ans = 1 while(True): if(num%k == 0): print(ans) break else: num %= k num *= 10 num += 1 ans += 1 " p02596,s202214074,Accepted,"K = int(input()) if K%7 == 0: L = 9*K/7 else: L = 9*K s = 1 for i in range(1, 9*(10**6)+1): s = s*10%L if s == 1: print(i) exit() print(""-1"")" p02596,s460371109,Accepted,"K = int(input()) x = 7 % K num_list = [] for count in range(1, K + 1): if x == 0: print(count) break x = (x * 10 + 7) % K else: print(-1) " p02596,s633318278,Accepted,"K = int(input()) n = 7%K r = 1 for i in range(10**6+5): if n==0: print(i+1) exit() r *= 10 n += r*7 r %= K n %= K print(-1) " p02596,s029753660,Accepted,"K = int(input()) cnt=1 Num=7%K while cnt<=K: if K%2==0: print('-1') break if Num%K==0: print(cnt) break else: Num = (10*Num + 7)%K cnt+=1 else: print('-1') " p02596,s429383422,Accepted,"K = int(input()) a = [7 % K] for i in range(1, K+1): a.append((a[i-1]*10 + 7) % K) flag = True for i in range(len(a)): if a[i] == 0: print(i+1) flag = False break if flag: print(-1)" p02596,s272357199,Accepted,"K = int(input()) n = 7 ans = -1 i = 1 if K%2==0: ans = -1 else: for i in range(K*2+10): if n%K==0: ans = i+1 break n *= 10 n += 7 n %= K print(ans)" p02596,s382106282,Accepted,"K = int(input()) ans = -1 keep = 0 check = 7 for i in range(K): keep = (keep + check) % K if keep == 0: ans = i + 1 break check = (check * 10) % K print(ans)" p02596,s962513634,Accepted,"K = int(input()) seven = 7 MOD7 = 7 % K MOD70 = 70 % K MOD77 = MOD7 + MOD70 if K % 2 == 0: print(-1) elif MOD7 == 0: print(1) else: for i in range(1,10**6): if MOD77 % K == 0: break MOD70 = (MOD70 * 10) % K MOD77 += MOD70 MOD77 = MOD77 % K if i >= 10**6 - 1: print(-1) else: print(i+1)" p02596,s886398276,Accepted,"def solve(): n = int(input()) lim = 100000000 s = 0 for i in range(lim): s *= 10 s += 7 s %= n if s == 0: print(i + 1) exit() print(-1) solve() " p02596,s422317833,Accepted,"k = int(input()) if k % 2 == 0: print(-1) exit() ten = 1 now = 0 for i in range(10**8): x = (ten*7)%k now = (now+x)%k if now == 0: print(i+1) exit() ten = ten*10%k print(-1)" p02596,s319977183,Accepted,"K=int(input()) if K%7==0: L=9*K//7 else: L=9*K mod=1 ans=-1 for i in range(1,L+1): mod=(mod*10)%L if mod%L==1: ans=i break print(ans)" p02596,s752511820,Accepted,"k=int(input()) s=7 i=1 while s%k!=0: i+=1 s=10*(s%k)+7 if i==k+1: break else: print(i) exit() print(-1)" p02596,s577947736,Accepted,"k = int(input()) num = 7 for i in range(k + 2): if num % k == 0: print(i + 1) exit() else : num = ( num * 10 + 7 ) % k print(-1)" p02596,s072017455,Accepted,"K = int(input()) a = 7 flag = True for i in range(K): if a % K == 0: print(i+1) flag = False break a = (a * 10 + 7) % K if flag: print(-1) " p02596,s429166730,Accepted,"k=int(input()) if k%2==0 or k%5==0: print(-1) else: t=7 ans=1 while True: if t%k==0: print(ans) break t=(t*10+7)%k ans=ans+1 " p02596,s881687265,Accepted,"K = int(input()) count = -1 n = 7 for i in range(K): if n % K == 0: count = i+1 break n = int(str(n)+'7') n %= K print(count) " p02596,s595385180,Accepted,"K=int(input()) ans=[0]*K rem=7 for i in range(K): rem=rem%K if rem == 0: print(i+1) exit() else : if ans[rem]==1: print(-1) exit() else:ans[rem]=1 rem=10*rem+7" p02596,s976081264,Accepted,"import sys readline = sys.stdin.buffer.readline def even(n): return 1 if n%2==0 else 0 n = int(readline()) if even(n): print(-1) exit() elif n%5==0: print(-1) exit() s = ""7"" count = 1 while True: if int(s) < n: s = s+""7"" count += 1 continue else: res = int(s)%n if res == 0: print(count) exit() s = str(int(s)%n) " p02596,s531881209,Accepted,"def main(): K = int(input()) if 7 % K == 0: return 1 r = 7 % K for i in range(2, 1000000): r = (r * 10 + 7) % K if r == 0: return i return -1 if __name__ == '__main__': print(main()) " p02596,s269466522,Accepted,"K = int(input()) a = 7 for n in range(1,1+K): if a%K==0: print(n) exit() a = (a*10+7)%K print(-1)" p02596,s544803804,Accepted,"def solve(): n = int(input()) if n%2 == 0 or n%5 == 0: return -1 if n % 7 == 0: n//=7 n*=9 cnt = 1 cur = 10 while cur % n != 1: cur = (cur * 10)%n cnt+=1 return cnt print(solve())" p02596,s141602115,Accepted,"import sys k=int(input()) n=7 if k%2==0: print(-1) sys.exit() for i in range(1,k+1): if n%k==0: print(i) sys.exit() else: n=(10*(n%k)+7)%k print(-1)" p02596,s703051212,Accepted,"k=int(input()) if k&1==0 or k%5==0: print(-1) exit() elif 7%k==0: print(1) exit() m=7 a=b=1 while(m>0): a=a*10%k m=(m+7*a)%k b+=1 print(b)" p02596,s693408159,Accepted,"K = int(input()) now = 7 r = 0 for d in range(1, K + 100): r = (r * 10 % K + 7) % K if r == 0: print(d) break else: print(-1) " p02596,s126446063,Accepted,"K = int(input()) if K == 1 or K == 7: print(1) exit() v = 7 M = set([]) for i in range(1, K + 1): v = (v * 10 + 7) % K if v == 0: print(i + 1) exit() if v not in M: M.add(v) else: print(-1) exit() " p02596,s136752467,Accepted,"k = int(input()) val = 7 cnt = 1 while cnt <= 10 ** 6: val %= k if val % k == 0: print(cnt) exit() cnt += 1 val = val * 10 + 7 print(-1)" p02596,s703460143,Accepted,"K = int(input()) if K % 2 == 0 or K % 5 == 0: print(-1) exit() now, cnt = 7, 1 while now % K != 0: cnt += 1 now = now * 10 % K + 7 print(cnt) " p02596,s840618857,Accepted,"from collections import defaultdict K=int(input()) if K%2==0: print(-1) exit() memo=defaultdict(int) tmp=0 ans=0 while True: tmp=(tmp*10+7)%K ans+=1 if tmp==0: print(ans) break elif memo[tmp]==1: print(-1) break else: memo[tmp]+=1" p02596,s773631521,Accepted,"k=int(input()) import sys if k%2==0 or k%5==0: print(-1) sys.exit() a=7 ans=1 while(1): if a%k==0: print(ans) sys.exit() else: a=a%k a=a*10+7 ans=ans+1 " p02596,s578997857,Accepted,"K = int(input()) a = 7 for i in range(K): if a % K == 0: print(i+1) exit() a = (10 * a + 7) % K print(-1)" p02596,s225536462,Accepted,"k = int(input()) if k % 2 == 0 or k % 5 == 0: print(-1) else: ans = 1 num = 7 % k temp = 7 % k while True: if num % k == 0: print(ans) break else: ans += 1 temp = temp * 10 % k num += temp % k num %= k " p02596,s944711053,Accepted,"k = int(input()) x = 7 % k s = set() for i in range(k): if x % k == 0: ans = i + 1 break if x in s: ans = -1 break s.add(x) x = 10 * x + 7 x %= k print(ans) " p02596,s150294856,Accepted,"K = int(input()) if K%2 == 0: print(-1) exit() num = 0 for i in range(10**6+1): num *= 10 num += 7 if num%K == 0: print(i+1) exit() num %= K print(-1)" p02596,s142521694,Accepted,"k = int(input()) ans = -1 x = 7 % k for n in range(1, k + 10): if x == 0: ans = n break x = (10 * x + 7) % k print(ans)" p02596,s766755227,Accepted,"K = int(input()) if K % 7 == 0: L = 9 * K // 7 else: L = 9 * K ans = 10 kou = -1 for i in range(1, 10**6): ans %= L if ans == 1: kou = i break else: ans *= 10 print(kou)" p02596,s358167095,Accepted,"#!/usr/bin/env python3 import sys from itertools import chain # form bisect import bisect_left, bisect_right, insort_left, insort_right # import numpy as np # 7.n = 7 * 1.n = 101 7777 def solve(K: int): n = 7 for answer in range(1, K + 1): if n % K == 0: return answer n = 10 * (n % K) + 7 return -1 def main(): tokens = chain(*(line.split() for line in sys.stdin)) # K = map(int, line.split()) K = int(next(tokens)) # type: int answer = solve(K) print(answer) if __name__ == ""__main__"": main() " p02596,s982029180,Accepted,"import sys k=int(input()) if k%2==0 or k%5==0: print(-1) sys.exit() else: if k%7==0: l=(k//7)*9 else: l=9*k j = 1 n = 10 rem = n%l while True: if rem == 1: print(j) sys.exit() rem = (rem*10)%l j+=1" p02596,s570990445,Accepted,"''' Created on 2020/08/22 @author: harurun ''' def main(): import sys pin=sys.stdin.readline pout=sys.stdout.write perr=sys.stderr.write K=int(pin()) a=7%K for i in range(K): if a%K==0: print(i+1) break a=(10*a+7)%K else: print(-1) return main() #解説AC" p02596,s107783406,Accepted,"K = int(input()) if K % 2 == 0: print(-1) else: r = 0 rem = 7 while (True): r += 1 rem = rem % K if rem == 0: break if r > K: r = -1 break rem = (rem * 10) + 7 print(r) " p02596,s219613941,Accepted,"# -*- coding:utf-8 -*- def solve(): K = int(input()) a = 7%K i = 1 Kset = set() Kset.add(a) while a!=0: a = (a*10+7)%K i += 1 if a in Kset: print(-1) return Kset.add(a) print(i) if __name__ == ""__main__"": solve() " p02596,s844428895,Accepted,"import sys import numpy as np input = sys.stdin.readline def log(*args): print(*args, file=sys.stderr) def main(): np.set_printoptions(threshold=20) K = int(input()) if K % 2 == 0 or K % 5 == 0: print(-1) return cnt = 0 now = 7 while True: cnt += 1 if now % K == 0: print(cnt) return now = now * 10 + 7 now %= K if __name__ == '__main__': main() " p02596,s077447790,Accepted,"import sys input = sys.stdin.readline K=int(input()) if K%2==0 or K%5==0: print(-1) else: NOW=0 for i in range(1,10**6+3): NOW=NOW+7*pow(10,i,K) NOW%=K if NOW==0: print(i) break else: print(-1) " p02596,s207681152,Accepted,"def resolve(): k = int(input()) ans = 1 ct = 0 num = 7 while ct <= 2*10**6: num %= k if num == 0: print(ans) exit() else: num = (num * 10 + 7)%k ans += 1 ct += 1 print(-1) resolve()" p02596,s887544040,Accepted,"k=int(input()) if k%7==0: k//=7 ans=0 if k%2==0 or k%5==0: ans=-1 else: cnt=1 x=1 while x%k!=0: cnt+=1 x%=k x*=10 x+=1 ans=cnt print(ans)" p02596,s595021877,Accepted,"from collections import defaultdict def main(): k = int(input()) dic = defaultdict(bool) sev = 7 i = 1 while(True): sev = sev%k if sev == 0: print(i) return if(dic[sev]): print(-1) return dic[sev] = True sev = (sev + 7*pow(10,i,k))%k i += 1 if __name__ == ""__main__"": main()" p02596,s423287295,Accepted,"k = int(input()) if k % 2 == 0 or k % 5 == 0: print(-1) exit() num = 7 for i in range(1,10**6): if num % k == 0: print(i) break num = (num % k) * 10 + 7 " p02596,s268116562,Accepted,"import sys k = int(input()) n = 7 counter = 1 remainders = set() while True: remainder = n % k if remainder == 0: print(counter) sys.exit() if remainder in remainders: print(-1) sys.exit() remainders.add(remainder) n = remainder * 10 + 7 counter += 1" p02596,s451365527,Accepted,"import time start=time.time() k=int(input()) ans=0 x=k for i in range(10**9): while x%10!=7: x+=k if time.time()-start>=1.9:exit(print(-1)) x//=10 if x==0:exit(print(i+1)) " p02596,s147291883,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')" p02596,s674518697,Accepted,"K = int(input()) a = 7 % K mods = [] i = 0 found = False while (i <= K): i += 1 if a == 0: print(i) found = True break a = (10 * a + 7) % K if not found: print(-1)" p02596,s441804420,Accepted,"k=int(input()) k *= 9 amari = 63 for i in range(1, 10 ** 6 + 1): amari %= k if amari == 0: print(i) break else: amari = amari * 10 + 63 else: print(-1)" p02596,s844222819,Accepted,"#: Author - Soumya Saurav import sys,io,os,time from collections import defaultdict from collections import OrderedDict from collections import deque from itertools import combinations from itertools import permutations import bisect,math,heapq alphabet = ""abcdefghijklmnopqrstuvwxyz"" input = sys.stdin.readline ######################################## #check = [int((""1""*i))*7 for i in range(10**6 + 2)] #print(check) n = int(input()) temp = 7 for i in range(1,10**7): #print(temp) if temp%n == 0: print(i) exit() else: temp = ((temp*10) + 7)%n print(-1) " p02596,s820970086,Accepted,"import sys k = int(input()) def a(n): t = n * 10 + 7 return t % k a_i = 7 i = 1 if a_i % k == 0: print(i) sys.exit() for j in range(k+1): a_i = a(a_i) i += 1 if a_i % k == 0: print(i) sys.exit() print(-1) " p02596,s844675518,Accepted,"k = int(input()) answer = -1 x = 7 for index in range(k) : if x % k == 0: answer = index + 1 break x = (10 * x + 7) % k print(answer)" p02596,s676912381,Accepted,"K = int(input()) ans = -1 N = 7 for i in range(K): if N % K == 0: ans = i+1 break N = (N*10+7) % K print(ans) " p02596,s889571384,Accepted,"K=int(input()) if K%2==0 or K%5==0: print(-1) exit() if K==7 or K==1: print(1) exit() if K==3: print(3) s=7%K for i in range(1000001): tmp=(10*(K-s))%K s=K-tmp+7 #print(s) if s==0 or s==K: print(i+2) exit()" p02596,s277465151,Accepted,"K=int(input()) i=1 x=7 mod=set() while True: if x%K==0: print(i) break else: if x%K in mod: print(-1) break mod.add(x%K) x=(x%K)*10+7 i+=1" p02596,s296339041,Accepted,"#!/usr/bin/python3 # -*- coding:utf-8 -*- def main(): k = int(input()) a = 0 for i in range(k): a = (10 * a + 7) % k if a == 0: print(i+1) return print(-1) if __name__=='__main__': main() " p02596,s986931304,Accepted,"K = int(input()) a = 7 for i in range(1, K+1): if a%K == 0: print(i) break else: a = (10*a + 7)%K else: print('-1')" p02596,s953587421,Accepted,"k=int(input()) num=0 for i in range(k): num*=10 num+=7 num %= k # print(num) if num==0: print(i+1) break else:print(-1)" p02596,s476728608,Accepted,"n=int(input()) sm=0 work=7 for i in range(1,5*n): sm+=work while sm>=n: sm-=n if sm==0 : print(i) break work*=10 work%=n else : print(-1)" p02596,s639888190,Accepted,"k = int(input()) t = 7 ans=0 for i in range(k): if t%k==0: ans =i+1 break else: t = (t*10+7)%k print(ans if ans >0 else -1)" p02596,s445330846,Accepted,"# C TLE # -*- coding: utf-8 -*- K = int(input()) if K % 2 == 0 or K % 5 == 0: print(-1) else: num = 7 for i in range(10 ** 6): mod_num = num % K if mod_num == 0: print(i + 1) break num = mod_num * 10 + 7 " p02596,s560946959,Accepted,"import sys K = int(input()) if K % 2 == 0 or K % 5 == 0: print(""-1"") sys.exit() x = 1 for i in range(1, 1000000): if (x * 7) % K == 0: print(i) sys.exit() x = (x + pow(10,i,K))%K print(""-1"") sys.exit() " p02596,s192362403,Accepted,"K = int(input()) for i in range(K): if i == 0: N= 7%K else: N = (10*N+7)%K if N == 0: print(i+1) break else: print(-1)" p02596,s622344770,Accepted,"# -*- coding: utf-8 -*- k = int(input()) r = 0 c = 0 for i in range(1, 1000001): r *= 10 r += 7 c += 1 r %= k if r == 0: break if r != 0: print(-1) else: print(c) " p02596,s160254977,Accepted,"k = int(input()) mod = 0 for i in range(10 ** 7): mod = 10 * mod + 7 mod %= k if mod == 0: print(i+1) exit() print(-1)" p02596,s698896556,Accepted,"K = int(input()) if K % 2 == 0 or K % 5 == 0: print(-1) exit() i = 0 ai = 0 while True: ai = (ai * 10 + 7) % K i += 1 if ai == 0: break print(i)" p02596,s247963774,Accepted,"k = int(input()) r = 0 for i in range(1, k+1): r = (r*10 + 7)%k if r == 0: print(i) exit() print(-1) " p02596,s041106721,Accepted,"k = int(input()) a = [7 % k] if 7 % k == 0: print(1) exit() for i in range(1,k): tmp = (a[-1] * 10 +7) % k if tmp == 0: print(i+1) exit() else: a.append(tmp) print('-1')" p02596,s613417239,Accepted,"K = int(input()) now = 0 for i in range(K): now = ((now*10)+7)%K if now == 0: print(i+1) break else: print(-1)" p02596,s561617660,Accepted,"K=int(input()) ans=-1 num=0 for i in range(K): # num += 7*(10**i) # if num % K == 0: #ってすると計算量がやばいので num = (10*num+7) % K if num == 0: ans = i+1 break print(ans)" p02596,s845857722,Accepted,"k = int(input()) ans = -1 a = [7%k] * k for i in range(k - 1): a[i + 1] = (10*a[i] + 7) % k for i in range(k): if a[i] == 0: ans = i + 1 break print(ans)" p02596,s480611357,Accepted,"k = int(input()) now = 7 for i in range(k+1): now %= k if now == 0: print(i+1) exit() else: now = now * 10 +7 print(-1)" p02596,s764445490,Accepted,"k = int(input()) if k % 2 == 0 or k % 5 == 0: print(-1) exit() i = 7 % k cnt = 1 while i != 0: i = i * 10 + 7 i %= k cnt += 1 print(cnt) " p02596,s703145231,Accepted,"k = int(input()) ans = -1 prev = 0 for i in range(1, k + 1): prev = (10 * prev + 7) % k if prev == 0: ans = i break print(ans)" p02596,s217041053,Accepted,"k=int(input()) num = 0 ans = -1 for i in range(k): num = (10*num+7)%k if num==0: ans = i+1 break print(ans)" p02596,s170142100,Accepted,"k=int(input()) n=7 f=0 if k%2==0: f=0 else: for i in range(1000000): if n%k==0: f=1 break n=n*10+7 n%=k if f: print(i+1) else: print(-1) " p02596,s998803541,Accepted,"K = int(input()) a = 7 flag = False for i in range(1,K+1): b = a%K if b==0: flag = True break a = b*10 + 7 if flag: print(i) else: print(-1)" p02596,s345047550,Accepted,"K = int(input()) if K % 2 == 0 or K % 5 == 0: print(-1) exit() i, ai = 0, 0 while True: ai = (ai * 10 + 7) % K i += 1 if ai == 0: break print(i)" p02596,s573370465,Accepted,"import sys k = int(input()) if k % 2 == 0: print(-1) sys.exit() rest = [7 % k] for i in range(k): rest.append(rest[-1] * 10 % k) tmp = 0 for i in range(k): if (tmp + rest[i]) % k == 0: print(i + 1) sys.exit() else: tmp = (tmp + rest[i]) % k else: print(-1)" p02596,s007998644,Accepted,"import math as mt n=int(input()) x=7%n ten=1 for i in range(n): if x%n==0: print(i+1) break ten=((ten%n)*(10%n))%n x+=((ten%n)*(7%n))%n else: if n==1: print(1) else: print(-1)" p02596,s216494315,Accepted,"K = int(input()) ans = 1 count = 1 m = 10 if K%7 == 0: K //= 7 for j in range(K): if count % K == 0: print(ans) exit() else: count = (count + m)%K m = m*10%K ans += 1 print(-1)" p02596,s132038983,Accepted,"# coding: utf-8 k = int(input()) n = 7 % k for i in range(k+1): if n % k == 0: print(i+1) exit(0) n = (((n % k) * (10 % k)) + 7 % k) % k print(-1) " p02596,s930814731,Accepted,"k=int(input()) num=0 for i in range(k+1): num=(num*10+7)%k if num==0: print(i+1) break if num: print(""-1"")" p02596,s501498201,Accepted,"import sys K = int(input()) if K%5==0 or K%2==0: print(""-1"") sys.exit() A = 0 for i in range(K): A = (10 * A + 7) % K if A == 0: print(i+1) break" p02596,s113152464,Accepted,"import sys input = sys.stdin.readline def main(): K = int(input()) t = 7 t %= K for i in range(K+1): if t == 0: print(i+1) break t = (t * 10 + 7) % K else: print(-1) main()" p02596,s703256359,Accepted,"import sys K = int(input()) if K % 2 == 0: print(-1) sys.exit() if K % 5 == 0: print(-1) sys.exit() if K % 7 == 0: L = 9 * K / 7 else: L = 9 * K i = 1 mod = 10**i % L while True: if mod == 1: print(i) sys.exit() mod = mod * 10 % L i += 1 " p02596,s838540391,Accepted,"k = int(input()) count = 1 n = 0 if k % 2 == 0 or k % 5 == 0: print(-1) else: while 1: n = (n * 10 + 7) % k if n == 0: break count += 1 print(count)" p02596,s699967140,Accepted,"K=int(input()) mod=9*K n=1 if K%7==0: mod=mod//7 for i in range(1,K+1): n=n*10%mod if n==1: print(i) exit() print(-1)" p02596,s220730217,Accepted,"K=int(input()) if K%5==0 or K%2==0: print(-1) if K%7==0: L=9*K//7 else: L=9*K R=1 for i in range(L): R=R*10 R=R%L if R==1: print(i+1) exit()" p02596,s511516504,Accepted,"k=int(input()) mod=0 ans=0 for i in range(1000000): ans+=1 mod=(mod*10+7)%k if mod==0: break print(ans if ans!=1000000 else -1)" p02596,s042038261,Accepted,"K = int(input()) a = [0]*(K+1) a[0] = 7%K ans = -1 for i in range(K): if(a[i]==0): ans = i+1 break a[i+1] = (10*a[i]+7)%K print(ans) " p02596,s364553768,Accepted,"#coding:utf-8 k = int(input()) now = 1 if(k%2==0)or(k%5==0): print(""-1"") else: past = 0 for i in range(1,k+1): past = (past * 10 + 7) % k if past == 0: print(""{}"".format(i)) break" p02596,s310515109,Accepted,"K = int(input()) ans = -1 mod = 0 for i in range(1, K+1): if i==1: mod_tmp = 7 % K else: mod_tmp = (mod_tmp * 10) % K mod += mod_tmp if mod%K == 0: ans = i break print(ans) " p02596,s307177669,Accepted,"K = int(input()) p = 0 res = -1 for i in range(10 ** 6): p *= 10 p += 7 p %= K if p == 0: res = i + 1 break print(res) " p02596,s482594769,Accepted,"K = int(input()) f=0 n=K for i in range(10**6 + 1): if n == 0: f=1 print(i) break n = ((n*10) + 7 ) % K if f==0: print(-1)" p02596,s676713940,Accepted,"from math import gcd x=int(input()) if gcd(x,10)!=1: print(-1) exit(0) n=7 res=1 while n%x!=0: res+=1 n*=10 n+=7 n%=x print(res)" p02596,s982352845,Accepted,"import sys input=sys.stdin.readline k=int(input()) if k%7==0: k=k//7 if k==1: now=0 else: now=1 s=now for i in range(k+100): if s==0: print(i+1) sys.exit() now=(now*10)%k s+=now s=s%k print(-1)" p02596,s272145903,Accepted,"K=int(input()) S=7 t=S%K u=1 import sys for i in range(K+1): if t==0: print (i+1) sys.exit() else: u=(u*10)%K t=(t+(7*u))%K print (-1)" p02596,s320112096,Accepted,"def main(): k = int(input()) seven = 7 already = set() cnt = 0 if k%2==0: print(-1) return while seven != 0: if seven in already: print(-1) return seven %= k already.add(seven) cnt += 1 if seven != 0: seven = seven * 10 + 7 print(cnt) return if __name__ == '__main__': main()" p02596,s476182323,Accepted,"k = int(input()) #k, x = map(int, input().split()) #al = list(map(int, input().split())) #l=[list(map(int,input().split())) for i in range(n)] l = (9*k//7) if k % 7 == 0 else 9*k if k == 1: ans = 1 elif k % 2 == 0 or k % 5 == 0: ans = -1 else: v = 1 for i in range(1, l+1): v = (v*10) % l if v == 1: ans = i break print(ans) " p02596,s589933261,Accepted,"K = int(input()) if K == 7: print(1) elif K % 2 == 0 or K % 5 == 0: print(-1) else: count = 0 num = 0 while True: num = (num * 10 + 7) % K count += 1 if num == 0: print(count) break" p02596,s107979645,Accepted,"k = int(input()) if k % 2 == 0 or k % 5 == 0: print(-1) exit(0) MOD = k n = 0 l = [] root = 1 for i in range(1000000): n += 7 * root n %= k if n == 0: print(i + 1) exit(0) root *= 10 root %= k print(-1)" p02596,s190682575,Accepted,"k=int(input()) x=7 for i in range(1,k+1): if x%k==0: print(i) break x=(x*10+7)%k else: print(-1)" p02596,s422475370,Accepted,"K = int(input()) x = 7 for i in range(K): if x % K == 0: print(i+1) exit() else: x = (10*x + 7) % K print(-1)" p02596,s462514957,Accepted,"K= int(input()) if K%2==0: print('-1') else: t=True n=1 a=7 while t: if n>K: t=False print('-1') if a%K!=0: a=(10*a+7)%K n+=1 else: t=False print(n)" p02596,s257499216,Accepted,"K= int(input()) visited = set() remainder = 7 counter = 1 while True: remainder = remainder % K if remainder in visited: print(-1) exit() if remainder == 0: print(counter) exit() else: visited.add(remainder) remainder = 10 * remainder + 7 counter += 1" p02596,s660437831,Accepted,"k=int(input()) mod=k t=7 for i in range(k): if t%mod==0: print(i+1) exit() t%=mod t*=10 t+=7 print(-1)" p02596,s198742721,Accepted,"N=int(input()) x=7%N for i in range(1,N+1): if x==0: print(i) exit() x=(x*10+7)%N print(-1) " p02596,s867713953,Accepted,"k = int(input()) if k % 2 == 0 or k % 5 == 0: print(-1) else: ans = 1 num = 7 while True: if num % k == 0: print(ans) break else: ans += 1 num += 7 * pow(10, ans - 1, k) num %= k " p02596,s659240622,Accepted,"K=int(input()) List = list(str(K)) i = len(List) tryNum = 7*10**i res = -1 if K % 2 == 0 or K % 5 == 0: print(res) else: flag = True mid=0 K=9*K N=0 while flag: N = tryNum % K if N == 7 : res = i flag = False else: i += 1 tryNum= N*10 print(res)" p02596,s692966677,Accepted,"def solve(): K = int(input()) if K % 10 not in [1, 3, 7, 9]: print(-1) return a = 7 % K for i in range(K+1): if a == 0: print(i+1) return a = (a * 10 + 7) % K print(-1) solve()" p02596,s224690378,Accepted,"K=int(input()) if K%2==0 or K%5==0: print(-1) exit() elif K==7 or K==1: print(1) else: M=7%K B=7%K for i in range(10**7): A=((B*10)%K) M+=A M%=K if M==0: print(i+2) exit() B=A+0 #print(M,B,i) " p02596,s688967883,Accepted,"K = int(input()) if K % 7 == 0: L = 9 * K / 7 else: L = 9 * K if K % 2 == 0 or K % 5 ==0: ans = -1 else: ans = 1 m = 10 % L while(ans >= 0): if (m == 1): break m *= 10 m %= L ans += 1 print(ans) " p02596,s942400450,Accepted,"k=int(input()) s={7%k} a=7%k n=1 flag=True while not {0}<=s: a=(a*10+7)%k beforelen=len(s) s.add(a) if len(s)==beforelen: flag=False break n+=1 print(n if flag else -1)" p02596,s622922405,Accepted,"import sys def input():return sys.stdin.readline()[:-1] def N(): return int(input()) def NM():return map(int,input().split()) def L():return list(NM()) k=N() x=7%k ans=1 for i in range(2*k): if x==0: print(ans) break x=x*10+7 x%=k ans+=1 else: print(-1)" p02596,s847545229,Accepted,"k = int(input()) seven = 0 i = 0 if k % 2 == 0: print(-1) else: while True: i += 1 seven = seven * 10 + 7 seven = seven % k if seven == 0: print(i) break if i>1000000: print(-1) break" p02596,s458097458,Accepted,"K = int(input()) t = 7 for i in range(K): if t % K == 0: print(i + 1) break t = (t * 10 + 7) % K else: print(-1)" p02596,s144247070,Accepted,"K = int(input()) a = 7%K ans = -1 for i in range(1,10**6+1): if a==0: ans = i break a = (a*10+7)%K print(ans)" p02596,s219233512,Accepted,"K = int(input()) a = 0 t = 1 for i in range(K): a += 7*t a = a % K t = t*10 t = t%K if a == 0: print(i+1) exit() print(-1) " p02596,s529315229,Accepted,"import datetime import string import re import math K=int(input()) if K % 2 == 0 or K % 5 == 0: print(""-1"") else: s = 7 count = 1 while True: if s % K == 0: print(count) break else: count += 1 s = (s % K)*10 + 7" p02596,s575795428,Accepted,"K = int(input()) Ans = -1 if K % 2 == 0 or K % 5 == 0: #解なしのため何もしない pass elif 7 % K == 0: Ans = 1 else: pre_modK = 7 % K for i in range(2,K+1): modK = pre_modK * 10 + 7 if modK % K == 0: Ans = i break else: pre_modK = modK % K print(Ans) " p02596,s627728552,Accepted,"K=int(input()) ans=-1 count=1 a=7 amari=[0]*K while 1: b=a%K if b==0: ans=count break if amari[b]==1: break amari[b]=1 count+=1 a=10*b+7 print(ans)" p02596,s427322621,Accepted,"import math x = int(input()) rem = 7 % x cnt = 1 while rem != 0 and cnt <= 1000000: rem = (10 * rem + 7) % x cnt += 1 if rem == 0: print(cnt) else: print(-1)" p02596,s531716188,Accepted,"k = int(input()) i = 7 count = 1 judge = True for t in range(10**6): if i%k == 0: judge = False break count += 1 i = 10*(i%k)+7 if judge: print(-1) else: print(count)" p02596,s985153363,Accepted,"K = int(input()) if K % 2 == 0 or K % 5 == 0: print(-1) exit() i = 0 ai = 0 while True: ai = (ai * 10 + 7) % K i += 1 if ai == 0: break print(i)" p02596,s447860662,Accepted,"n = int(input()) now_mod = 0 if n % 2 == 0: print(-1) exit() for i in range(1, n+1): now_mod *= 10 now_mod += 7 now_mod %= n if now_mod == 0: print(i) exit() print(-1) exit() " p02596,s488777952,Accepted,"k=int(input()) a=7 for i in range(10**6): if a%k==0: print(i+1) exit() a=(a*10+7)%k print(-1)" p02596,s675962217,Accepted,"K = int(input()) target = 0 if K % 2 == 0 or K % 5 == 0: print(-1) else: for i in range(1,10**7): target = target % K target = target*10+7 if target % K == 0: print(i) break" p02596,s818439594,Accepted,"k=int(input()) m=0 for i in range(k): m=(m*10+7)%k if m==0: break elif i==k-1: print(-1) exit() print(i + 1) " p02596,s803567196,Accepted,"K = int(input()) mod = 0 Good = True for k in range(K): mod = (mod * 10 + 7) % K if mod == 0: print(k+1) Good = False break if Good: print(-1)" p02596,s272304480,Accepted,"import sys k = int(input()) a = dict() cnt = 0 base = 0 while True: cnt += 1 base = (base*10+7)%k if base == 0: break if base in a: cnt = -1 break else: a[base] = 1 print(cnt)" p02596,s158927114,Accepted,"cnt = 1 mod = 7 k = int(input()) for i in range(k): if mod % k == 0: break cnt += 1 mod = (mod * 10 + 7) % k if mod % k == 0: print(cnt) else: print(-1)" p02596,s397531640,Accepted,"import sys K = int(input()) tmp = 0 for i in range(1,10**7): tmp = (tmp*10+7)%K if tmp == 0: print(i) sys.exit() print(-1)" p02596,s309327045,Accepted,"K = int(input()) M = 10**6+1 def solve(): count = 1 res = 0 c = 7 % K while count < M: res = (res * 10) % K res = (res + c) % K if res == 0: return count count += 1 return -1 if __name__ == ""__main__"": print(solve()) " p02596,s747941469,Accepted,"K=int(input()) a=7%K i=1 dp=[0 for n in range(K)] dp[a]=1 while a!=0: a=(10*a+7%K)%K if dp[a]==0: dp[a]+=1 i+=1 else: print(-1) break else: print(i)" p02596,s645525383,Accepted,"K = int(input().rstrip()) n = 1 if K%7==0: L = 9 * K / 7 else: L = 9 * K R = 10 ** n s = set() if K == 1 or K == 7: print(1) else: while R!=1: R = (10 * R) % L n += 1 if R in s: print(-1) break else: s.add(R) else: print(n)" p02596,s431031550,Accepted,"def solve(string): n, k = 7, int(string) if k % 2 == 0 or k % 5 == 0: return ""-1"" for i in range(k): if not n % k: return str(i + 1) n = (10 * n + 7) % k if __name__ == '__main__': import sys print(solve(sys.stdin.read().strip())) " p02596,s607799871,Accepted,"''' Date : 2020-08-08 23:01:16 Author : ssyze Description : ''' from math import * k = int(input()) x = 7 cnt = 1 while x % k != 0: x = (x * 10 + 7) % k cnt += 1 if cnt >= 10**6 + 5: break if cnt >= 10**6 + 5: print(""-1"") else: print(cnt) " p02596,s015180185,Accepted,"K = int(input()) ans = 0 if K % 7== 0: K //= 7 #print(K) for i in range(10**6): ans += pow(10,i,K) if ans % K == 0: print(i+1) exit() print(-1)" p02596,s114799621,Accepted,"n = int(input()) if n % 2 == 0: print(-1) else: a = 7 b = 0 for i in range(1000000): if a % n == 0: print(i+1) b = 1 break a = (a%n) * 10 + 7 if b == 0: print(-1) " p02596,s496835137,Accepted,"k = int(input()) x = 0 for i in range(1, k + 1): x = x * 10 + 7 if x % k == 0: print(i) exit() x %= k print(-1) " p02596,s223474676,Accepted,"def solve(K): cur = 0 tens = 1 for i in range(1_000_001): cur += 7 * tens cur %= K if cur == 0: return i + 1 tens *= 10 tens %= K else: return -1 print(solve(int(input()))) " p02596,s811458641,Accepted,"K = int(input()) if(K in [1, 7]): print(1) else: now = 7 % K a = 10 % K for n in range(2, 1000001): now = (now * a + 7) % K if(now == 0): print(n) break else: print(-1) " p02596,s951891329,Accepted,"def f(k): r = 7%k for i in range(k): if r == 0: return i+1 r = (r*10 + 7)%k return -1 print(f(int(input()))) " p02596,s499001593,Accepted,"K = int(input()) if K%2 == 0 or K%5 ==0: print(-1) else: a = 0 L = [0] * 2000000 L[0] = 7%K for i in range(1,2000000): L[i] = L[i - 1] * 10 %K for i in range(2000000): a = (a + L[i])%K if a == 0: ans = i + 1 break print(ans)" p02596,s454072064,Accepted,"k=int(input()) if k%2==0 or k%5==0: print(-1) exit() pw=1 tmp=7 ans=1 for _ in range(k): if tmp%k==0: break ans+=1 pw*=10 pw%=k tmp+=7*pw print(ans) " p02596,s403198173,Accepted,"k=int(input()) a=7 for i in range(1,10**6+1): if a % k ==0: print(i) exit() a=(10*a+7)%k print(-1)" p02596,s045976007,Accepted,"k=int(input()) v=[1]*k if k==1 or k==7: print(1) exit() m=7%k v[m]=0 for i in range(k): m=(10*m+7)%k if m==0: c=i+2 break elif v[m]: v[m]=0 else: c=-1 break print(c)" p02596,s000988204,Accepted,"K = int(input()) ans = [False for _ in range(K)] num = 0 p = 7%K for i in range(K+1): num += p p = (p*10)%K if ans[num%K] == False: ans[num%K] = True else: print(""-1"") break if num%K == 0: print(i+1) break" p02596,s733269361,Accepted,"k = int(input()) cnt = 0 for i in range(k): if (cnt := (cnt * 10 + 7) % k) == 0: print(i+1) exit() print(-1)" p02596,s355383101,Accepted,"k=int(input()) if k%2==0 or k%5==0: print(-1) exit() ans=1 num=7 while num%k!=0: num=10*num+7 num%=k ans+=1 print(ans)" p02596,s867477409,Accepted,"from sys import stdin k = int(stdin.readline().rstrip()) num = 7 flag = 0 for i in range(1, k + 1): if num % k == 0: flag = 1 break num = (num * 10 + 7) % k if flag == 1: print(i) else: print(-1)" p02596,s359599082,Accepted,"k=int(input()) mod7 = 7%k mod10= 10%k mod = mod7 mod10times = mod7 if mod%k==0: print(1) else: for i in range(2,2000000): mod10times = mod10times*mod10%k mod = mod10times+mod%k if mod%k==0: break if i==1999999: print(-1) else: print(i) " p02596,s313665812,Accepted,"k=int(input()) if k%2==0: print(-1) exit() def solver(k): tmp=7%k cnt=1 while cnt <= k: if tmp%k != 0: tmp=(tmp*10+7)%k cnt+=1 else: return cnt return -1 print(solver(k))" p02596,s574635556,Accepted,"import sys N=int(sys.stdin.readline().strip()) a=0 for i in range(10**6): a+=7*pow(10,i,N) if a%N==0: print i+1 quit() else: print -1" p02596,s546581693,Accepted,"K = int(input()) s = set() seven = 7 ans = 1 while seven % K != 0: seven = seven * 10 + 7 seven %= K if seven in s: ans = -1 break s.add(seven) ans += 1 print(ans) " p02596,s031471985,Accepted,"K = int(input()) sevens = 0 count = 0 repeat = True if {K%10} & {0,2,4,5,6,8}: count = -1 repeat = False while repeat: sevens = sevens % K * 10 + 7 count += 1 if sevens % K == 0: repeat = False print(count)" p02596,s134016549,Accepted,"import math t = int(input()) if t%2==0 or t%5==0: print(-1) else: i=1 s=7 while 1: if s%t==0: print(i) break else: i += 1 s = (s * 10 + 7) % t continue" p02596,s177632913,Accepted,"def readinput(): k=int(input()) return k def main(k): amari=[0]*k r=0 count=0 for i in range(1,k+1): count+=1 r=(10*r+7)%k if r==0: return count if amari[r]>0: return -1 amari[r]+=1 return -1 if __name__=='__main__': k=readinput() ans=main(k) print(ans) " p02596,s529685606,Accepted,"k=int(input()) n=0 for i in range(k): n=(10*n+7)%k if n%k==0: print(i+1) break else:print(-1)" p02596,s719161619,Accepted,"K = int(input()) if K%2 == 0 or K%5 == 0: print(-1) else: if K%7 == 0: L = 9*K//7 else: L = 9*K i = 1 A = 10 while i < 9000000: re = A%L if re == 1: print(i) break else: A = re*10 i += 1 else: print(-1)" p02596,s611265002,Accepted,"k=int(input()) am=7%k i=1 for i in range(k): if am==0: print(i+1) exit() else: i+=1 am=(am*10+7)%k print('-1')" p02596,s858087460,Accepted,"K = int(input()) def solve(): val = 0 for i in range(1, K + 1): val = val * 10 + 7 val = val % K if val == 0: return i return -1 print(solve())" p02596,s886676290,Accepted,"k = int(input()) if k % 7 == 0: L = 9 * k / 7 else: L = 9 * k if L % 2 == 0 or L % 5 == 0: print(-1) m = 10 for i in range(k): m = m % L if m == 1: print(i + 1) exit() else: m = m * 10" p02596,s794302167,Accepted,"s = input() K = int(s) if ((K & 1 == 0) or (s[-1] == ""5"")): print(-1) else: if K % 7 == 0: L = 9 * K / 7 else: L = 9 * K i = 1 r = 10 while True: r = r % L if r == 1: print(i) break r *= 10 i += 1" p02596,s280874563,Accepted,"k=int(input()) temp=7 for i in range(1,k+1): if temp%k==0: print(i) break temp=(temp*10+7)%k else: print(-1)" p02596,s535177811,Accepted,"K=int(input()) X=0 for i in range(K+1): X=(10*X+7)%K if X==0: print(i+1) exit() print(-1) " p02596,s710918872,Accepted,"k = int(input()) count = 0 for i in range(1, 10 ** 7): count *= 10 count += 7 count %= k if count == 0: print(i) exit() print(-1) " p02596,s288501262,Accepted,"K=int(input()) L=9*K//7 if K%7==0 else 9*K if L%2==0 or L%5==0: print('-1') else: surplus=1 for i in range(1,L): surplus=(surplus*10)%L if surplus==1: print(i) break" p02596,s625419073,Accepted,"K = int(input()) md = 0 if K % 2 == 0: print(-1) exit() for i in range(10 ** 6): a, b = divmod(md + 7 * (pow(10, i, K)), K) if b == 0: print(i + 1) exit() else: md = b print(-1) " p02596,s018726066,Accepted,"K = int(input()) mod = 7 % K for i in range(K): if mod == 0: print(i+1) exit() mod = (10*mod + 7) % K if mod == 0: print(K) else: print(-1)" p02596,s633709690,Accepted,"K = int(input()) if K%2 == 0: print(-1) elif K%5 == 0: print(-1) else: res = 7 for i in range(K): if res % K == 0: break res = (res * 10 + 7) % K print(i + 1)" p02596,s759867584,Accepted,"k = int(input()) if k in [2, 5, 10] == 0: print(-1) exit() n_map = {} current = 7 % k cnt = 1 while True: if current == 0: print(cnt) exit() if current in n_map: print(-1) exit() else: n_map[current] = True cnt += 1 current = 10 % k * current + 7 current %= k " p02596,s327085077,Accepted,"K = int(input()) r = 7 ans = 1 s = set([]) while True: r %= K if r == 0: print(ans) break if r in s: print(-1) break s.add(r) r *= 10 r += 7 ans += 1 " p02596,s062977792,Accepted,"K = int(input()) cnt = set() k = 7%K i = 1 while k not in cnt: if k == 0: print(i) exit() cnt.add(k) k = (10*k+7) % K i += 1 print(-1) " p02596,s228559494,Accepted,"# -*- coding: utf-8 -*- k = int(input()) ans = 0 n = 7 if k % 2 == 0 or k % 5 == 0: print(-1) exit(0) c = 1 while True: if n % k == 0: break n = (n * 10 + 7) % k c += 1 print(c) " p02596,s650430520,Accepted,"K = int(input()) L = 0 if K % 7 == 0: L = 9*K//7 else: L = 9*K t = 1 ans = -1 for i in range(1,L,1): t = t*10 if t % L == 1: ans = i break t = t % L print(ans)" p02596,s645749081,Accepted,"s, k = '', int(input()) for i in range(k): s += '7' s = str(int(s)%k) if not int(s): print(i+1); break else: print(-1)" p02596,s945956078,Accepted,"k = int(input()) s = 0 c = 1 for i in range(1000000): s = (s * 10 + 7) % k if s % k != 0: c = c + 1 else: break if c > i+1: print('-1') else: print(c) " p02596,s588697553,Accepted,"k = int(input()) m = 0 for i in range(k): m = (m*10 + 7)%k if m == 0: ans = i + 1 break if m == 0: print(ans) else: print(-1) " p02596,s555870188,Accepted,"#-*-coding:utf-8-*- import sys def main(): k = int(input()) sevens=0 if k%2==0: print(-1) exit() for i in range(1,10**6+1): sevens=(sevens*10+7)%k if sevens==0: print(i) exit() print(-1) if __name__ == ""__main__"": main()" p02596,s417506508,Accepted,"k = int(input()) cur = 0 flag = False for i in range(1, 10**6): cur *= 10 cur += 7 cur %= k if cur == 0: flag = True break if flag: print(i) else: print(-1)" p02596,s721907934,Accepted,"import sys, math from collections import defaultdict, deque, Counter from bisect import bisect_left, bisect_right from itertools import combinations, permutations, product from heapq import heappush, heappop from functools import lru_cache input = sys.stdin.readline rs = lambda: input().strip() ri = lambda: int(input()) rl = lambda: list(map(int, input().split())) mat = lambda x, y, v: [[v]*y for _ in range(x)] ten = lambda x, y, z, v: [mat(y, z, v) for _ in range(x)] mod = 1000000007 sys.setrecursionlimit(1000000) K = ri() if K % 2 == 0: print(-1) exit() r = 0 for i in range(10000000): r = (r*10+7) % K if r == 0: print(i+1) exit() print(-1) " p02596,s149929455,Accepted,"K=int(input()) num=7 ans=-1 for n in range(pow(10,7)): if num%K==0: ans=n+1 break shou=num//K num-=K*shou num=int(str(num)+'7') print(ans) " p02596,s683939733,Accepted,"#https://atcoder.jp/contests/abc174/tasks/abc174_c K= int(input()) if K%2==0 or K%5==0: print(-1) elif K==1 or K==7: print(1) else: B = 7 i = 1 while 1: if B==0: print(i) break else: B = (10 * B + 7) % K i = i + 1" p02596,s248016118,Accepted,"#!/usr/bin/env python3 import sys input = sys.stdin.readline def S(): return input().rstrip() def I(): return int(input()) def MI(): return map(int, input().split()) k = I() m = k % 10 if m % 2 == 0 or m == 5: print(-1) exit() if k == 1 or k == 7: print(1) exit() else: rk = 7 for i in range(2, 10 ** 6 + 1): rk1 = ((10 % k) * rk % k + 7 % k) % k if rk1 == 0: print(i) exit() rk = rk1 " p02596,s199585820,Accepted,"def resolve(): k = int(input()) x = 7 % k for i in range(1, k + 1): if x == 0: print(i) return x = (x * 10 + 7) % k print(-1) resolve()" p02596,s816355091,Accepted,"import sys def input(): return sys.stdin.readline().rstrip() def main(): k = int(input()) keta = 1 mod = 7%k if k % 7 == 0: max_k = 9*k//7 else: max_k = 9*k if k %2 == 0 or k%5 == 0: print(-1) while keta < max_k: if mod == 0: print(keta) break mod = (mod*10 + 7)%k keta += 1 if __name__=='__main__': main()" p02596,s602277939,Accepted,"import sys def main(): K = int(sys.stdin.readline()) if K%2==0: print(-1) return if K % 7: L = 9*K else: L = 9*K//7 a = 1 for i in range(1,L+1): a = (a * 10) % L if a == 1: print(i) return print(-1) main()" p02596,s185004226,Accepted,"k = int(input()) cur = 7 t = cur%k flag = False for i in range(1,k+1): if t == 0: print(i) flag = True break else: t = (10*t)%k t += 7 t %= k if not flag: print(-1) " p02596,s002049906,Accepted," def main(): k = int(input()) if k % 2 == 0: print(-1) else: a = 7 if a % k == 0: print(1) exit() for i in range(2, k + 1): a = (10 * a + 7) % k if a % k == 0: print(i) exit() print(-1) if __name__ == '__main__': main() " p02596,s253746531,Accepted,"k = int(input()) t = 7 #kで割ったあまりは0を除けばk-1種類 for i in range(k): if t%k == 0: print(i+1) break t = (t*10+7)%k else: print(-1)" p02596,s978419760,Accepted,"K = int(input()) i = 0 n = 0 while True: n = (n * 10 + 7) % K i += 1 if n % K == 0: print(i) break if i > 1000000: print(-1) break " p02596,s616701096,Accepted,"n = int(input()) if n%7 == 0: n //= 7 r = 0 for i in range(n+1): r += pow(10,i,n) r %= n if r == 0: print(i+1) exit() print(-1)" p02596,s507503064,Accepted,"cnt = 1 mod = 7 k = int(input()) for i in range(k): if mod % k == 0: break cnt += 1 mod = (mod * 10 + 7) % k if mod % k == 0: print(cnt) else: print(-1) " p02596,s855320081,Accepted,"K = int(input()) s=0 i = 1 while i <=K: s = (s*10+7)%K if s==0: print(i) break i +=1 if i>K: print(-1)" p02596,s437066723,Accepted,"k = int(input()) if k % 2 == 0 or k % 5 == 0: print(-1) else: i = 1 m = 7 % k while True: if m == 0: print(i) break m = (10 * m + 7) % k i += 1 " p02596,s386859989,Accepted,"K = int(input()) map = {0: True} cnt = 1 nana = 7 % K md = 7 % K while md not in map: # for i in range(100): cnt += 1 map[md] = True md = (10 * md + nana) % K # print(md) if md == 0: print(cnt) else: print(""-1"") " p02596,s120504164,Accepted,"K = int(input()) cur = 0 for i in range(1, K + 1): cur = (cur * 10 + 7) % K if cur == 0: print(i) exit(0) print(-1) " p02596,s206163151,Accepted,"import itertools k = int(input()) mod = set() seven = 7 % k for i in itertools.count(): if seven == 0: print(i+1) break; elif seven in mod: print(-1) break; mod.add(seven) seven = (seven*10+7) % k " p02596,s899029292,Accepted,"k=int(input()) x=i=0 while iexit(print(i)) print(-1)" p02596,s530251283,Accepted,"K=int(input()) if K%2==0 or K%5==0: print(""-1"") else: ans = 1 s = 7 while True: if s%K==0: print(ans) break else: s=(s%K)*10+7 ans += 1" p02596,s153062961,Wrong Answer,"k = int(input()) rem = 0 for i in range(k): rem = rem*10 + 7 rem %= k if rem==0: break if i==(k-1): print(-1) else: print(i+1)" p02596,s529244012,Wrong Answer,"k=int(input()) c=0 x=0 for c in range(7): x=x+7*10**c if x%k==0: print(c+1) break elif c==6: print(-1) break" p02596,s472761307,Wrong Answer,"k=int(input()) sevs=7 for x in range(1,k+1): if sevs%k==0: print(x) exit() else: sev=(10*sevs+7)%k print('-1') " p02596,s984855795,Wrong Answer,"# your code goes here x = int(input()) i = 1 n= 0 if x % 2 == 0 or x % 5 == 0: print(-1) else: for i in range(1, 1000000): l =( 7 %x*pow(9,-1)%x* (pow(10,i,x) - 1%x)%x )%x #l=math.ceil(l) n+=1 if l % x == 0: break print(n) " p02596,s149126634,Wrong Answer,"k = int(input()) if(k%2==0): print(""-1"") else: i = 1 while True: m = 7 if(m%k==0): print(i) break if(i>10000000): print(""-1"") break m = m*10 + 7 i += 1 " p02596,s647657343,Wrong Answer,"import sys k = int(input()) if k % 7 == 0: k = k // 7 tmp = 1 for i in range(k+2): if tmp == 0: print(i+1) sys.exit() tmp = (tmp * 10 + 1) % k print(-1)" p02596,s628824983,Wrong Answer,"k = int(input()) if k % 2 == 0 or k % 5 == 0: print(-1) elif k == (1 or 7): print(1) else: t = 2 ex = 77 for i in range(10 ** 8): if ex % k == 0: break ex = (ex % k) * 10 + 7 t += 1 print(t)" p02596,s767777202,Wrong Answer,"k = int(input()) n = 0 for i in range(1, k+1): n = (n * 10 + 7) % k if n == 0: print(i) break " p02596,s882691877,Wrong Answer,"k = int(input()) a = 7 for i in range(1, k): if a % k == 0: print(i) exit() a = (10 * a + 7) % k print(-1) " p02596,s933636473,Wrong Answer,"k = int(input()) answer = -1 cou = 7 for i in range(k): if cou%k == 0: answer = cou else: cou*10 + 7 print(answer)" p02596,s988886451,Wrong Answer,"ip = int(input()) ans = 7 for i in range(1,8): if int(ans) % ip == 0: print(i) break else: ans = int(ans) * 10 + 7 i += 1 " p02596,s611593015,Wrong Answer,"n = int(input()) ans,c = 0,0 while 1: c+=1 f=0 for i in range(10): if ((ans%10)+((n%10)*i)%10)%10==1: ans += n*i #print(ans,i) f=1 break if f==0: print(-1) exit() ans = ans//10 if ans==0: break print(c)" p02596,s945383707,Wrong Answer,"k = int(input()) mod = 0 for i in range(1, k): mod = ((mod * 10) + 7) % 7 if mod == 0: print(i) exit() print(-1) " p02596,s250376232,Wrong Answer,"k = int(input()) #a,b = map(int,input().split()) #a_L = list(map(int,input().split())) sevn = ""7"" i = 1 for i in range(1,10**4+1): tmp = int(sevn) if tmp%k==0: print(i) exit() sevn += ""7"" #i += 1 print(-1)" 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 " p02596,s144708467,Wrong Answer,"import sys readline = sys.stdin.buffer.readline def even(n): return 1 if n%2==0 else 0 n = int(readline()) if even(n): print(-1) exit() s = ""7"" count = 1 while True: if int(s) <= n: s = s+""7"" count += 1 continue else: res = int(s)%n if res == 0: print(count) exit() s = str(int(s)%n) " p02596,s494763391,Wrong Answer,"k = int(input()) if k % 2 == 0: print(-1) else: count= 1 if k==7: print(1) else: now = 7%k while(1): count += 1 now = (now*10) % k + 7 % k if now % k == 0: print(count) exit() " p02596,s283017950,Wrong Answer,"k = int(input()) answer = -1 cou = 7 for i in range(k+1): if cou%k == 0: answer = cou else: cou = cou*10 + 7 print(answer)" p02596,s442024028,Wrong Answer,"K = int(input()) v = 0 for i in range(1, K): v = (v * 10 + 7) % K if v == 0: print(i) exit(0) print(-1) " p02596,s566195571,Wrong Answer,"def resolve(): N = int(input()) count = 7 if N%2 == 0: print(""-1"") elif N%5 == 0: print(""-1"") else: for i in range(N): count += (10**i)*7 if count % N == 0: print(i+1) exit() resolve()" p02596,s312837669,Wrong Answer,"k = input() flag = True for i in k: if i != '7': flag = False break if flag: print(len(k)) else: k = int(k) for i in range(1,k+1): a = pow(10,i,k) - 1 if a%9 == 0: print(i) flag = True break if not flag: print(""-1"") " p02596,s001222337,Wrong Answer,"k = int(input()) if k % 2 == 0: print(-1) if k % 7 == 0: k //= 7 x = 1 s = 0 for i in range(1, 1000005): s += x s %= k if s == 0: print(i) exit() x *= 10 x %= k" p02596,s290857378,Wrong Answer,"k = int(input()) c = 0 a = [0]*(k+1) a[0] = 7%k if k%2 == 0 or k%5 == 0: print('-1') elif 7%k == 0: print('1') else: for i in range(1,k): c += 1 a[i+1] = (10*a[i] + 7)%k if a[i+1] == 0: break print(c)" p02596,s232853742,Wrong Answer,"K = int(input()) mod = 0 # mod Kは、0,1,...,K-1 の高々K種類 # i=K+1 まで行くと鳩の巣原理よりmodが既出になり、以降ループ # すなわちi=Kまで見れば十分 for i in range(1, K + 1): mod = (10 * mod + 7) % K if mod % K == 0: print(i) exit()" p02596,s500388543,Wrong Answer,"k = int(input()) if(k % 2 == 0): print(-1) else: if(k % 7 == 0): print(1) else: a = 1 amari = 7 % k while(a < k): a += 1 amari = (amari*10 + 7) % k if(amari == 0): print(a) break if(a == k): print(-1)" p02596,s967751309,Wrong Answer,"k=int(input()) ans=-1 s=""7"" cnt=1 if k%2!=0 and k%5!=0: if k%3!=0: ans=k-1 else: while int(s)%k!=0: s+=""7"" cnt+=1 ans=cnt print(ans)" p02596,s572474279,Wrong Answer,"K = int(input()) a = 0 n = 0 out = -1 for _ in range(K): a += 7 * (10 ** n) if a % K == 0: out = n + 1 break print(out) " p02596,s000880307,Wrong Answer,"K = int(input()) num = 0 cnt = 0 ans = False for i in range(K): num = num*10+7 cnt += 1 if num % K == 0: print(cnt) ans = True if ans == False: print(-1) " p02596,s750976745,Wrong Answer,"a=int(input()) if a%2 == 0: print(-1) else: ans = 1 div = 0 for i in range(10**6): div += 7*10**i if a%div == 0: break else: ans +=1 print(ans)" p02596,s126949426,Wrong Answer,"# your code goes here x = int(input()) i = 1 n= 0 if x % 2 == 0 or x % 5 == 0: print(-1) else: for i in range(1, 1000000): l =( 7 *pow(9,-1)* (pow(10,i,x) - 1%x) ) n+=1 if l % x == 0: break print(n) " p02596,s496527690,Wrong Answer,"k, R, a = int(input()), 7, -1 for i in range(1, k+10): if not R: a = i break R = (R * 10 + 7) % k print(a)" p02596,s986608678,Wrong Answer," k=int(input()) a=[] judge=0 a.append("""") a.append(7%k) for i in range(2,k): a.append((a[i-1]*10+7)%k) for i in range(1,k): if a[i]==0: print(i) judge=1 break if judge==0: print(-1)" p02596,s172263879,Wrong Answer,"k = int(input()) seven = 7 i = 1 if k % 2 == 0: print(-1) else: while seven < k: seven = seven + 7 * 10**i i +=1 ans = seven while seven % k != 0: seven = seven + 7 * 10**i i +=1 if i >101: i = k-1 break print(i)" p02596,s477547210,Wrong Answer,"import time k = int(input()) n = 7 c = 1 t1 = time.time() t2 = time.time() while (t2-t1) <= 1.8: if n%k == 0: print(c) break else: n = int(str(n)+""7"") c+=1 t2 = time.time() if (t2-t1) > 1.8: print(-1)" p02596,s662339895,Wrong Answer,"K = int(input()) i = 0 ret = -1 if K % 5 != 0 and K % 2 != 0: N = 1 if K % 7 == 0: L = K * 9 // 7 else: L = K * 9 while True: if N % L == 1: ret = i break N = (N * 10 )% L i += 1 print(ret) " 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())" p02596,s679741275,Wrong Answer,"k = int(input()) a = 0 for i in range(k-1): a = (a*10+7)%k if a == 0: print(i+1) break else: print(-1)" p02596,s622572697,Wrong Answer,"# coding: utf-8 import numpy as np k = int(input()) s = 0 cnt = 0 flg = False while (cnt < 1e7): cnt += 1 print(cnt) s = s * 10 + 7 # print(s) if s % k == 0: flg = True break if k < 7: flg = False break if k % 2 == 0: flg = False break if flg == True: print(cnt) else: print(-1)" p02596,s806378293,Wrong Answer,"k = int(input()) x = 7 e = 10 for i in range(10000000): # print(x) if x == 0: print(i + 1) exit() x = (x * e + 7) % k print(""-1"")" p02596,s312574076,Wrong Answer," K=int(input()) if(K%2==0): print(-1) else: seven=7 seven=seven%K ans=1 for i in range(K+1): if(seven==0): ans=i+1 break seven=(seven*10+7)%K print(ans)" p02596,s383462839,Wrong Answer,"k=int(input()) now=7 for i in range(k+10): if now%7==0: print(i+1) exit() now*=10 now+=7 print(-1) " p02596,s550603588,Wrong Answer,"k=int(input()) s=[] s.append(7%k) for i in range(1,k): s.append((s[i-1]*10+7)%k) if s[i]==0: print(i+1) exit() print(-1) " p02596,s040190064,Wrong Answer,"k, R = int(input()), 1 for i in range(1, k+10): if not R: print(i) R = (R * 10 % 7 + 7) % k" p02596,s478046484,Wrong Answer,"k=int(input()) f=-1 for i in range(1,1000): s=k*i l=len(str(s)) d=0 for i in range(l): if str(s)[i]!=7: d=d+1 break if d<=0: f=l print(f)" p02596,s972825162,Wrong Answer,"b = int(input()) list = [7] for i in range(b): list.append(list[-1]*10 +7) for l in range(b%10, len(list)): if list[l] % b == 0: print(b%10 + l) exit() " p02596,s032365676,Wrong Answer,"K = int(input()) cnt=len(str(K)) if K % 2 == 0: print(-1) else: while True: n = int(cnt*str(1)) if n % int(K) != 0: cnt+=1 else: print(len(str(n))) break" p02596,s407964344,Wrong Answer,"k=int(input()) a=0 if k%2==0: print(-1) else: for i in range(k): a=(a*10+7)%k if a==0: print(i+1) exit()" p02596,s155497806,Wrong Answer,"import sys x = int(input()) if x%2 == 0: print(-1) sys.exit() y = 7 i = 1 while y%x != 0: if i == 100: print(-1) sys.exit i = i + 1 y = y*10 + 7 print(i)" p02596,s844157806,Wrong Answer,"k = int(input()) answer = -1 cou = 7 for i in range(k+1): if cou%k == 0: answer = cou else: cou*10 + 7 print(answer)" p02596,s229670470,Wrong Answer,"K=int(input()) n=1 an=[7%K] bn=[10%K] while True: an.append(an[-1]%K+(7%K)*(bn[-1]%K)) if an[-1]%K==0: print(n+1) break elif an[0]==an[-1]: print(-1) break bn.append((bn[-1]*10)%K) n+=1" p02596,s503176036,Wrong Answer,"import sys n = int(input()) seven = 7 if n < 7: print(-1) sys.exit() for i in range(n): if seven % n == 0: print(i + 1) sys.exit() seven = seven * 10 + 7 print(-1)" p02596,s396934658,Wrong Answer,"n=int(input()) sm=0 work=7 for i in range(1,n): sm+=work if sm==n : print(i) break elif sm>n : sm-=n work*=10 work%=n else : print(-1)" 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)" p02596,s960308937,Wrong Answer,"def main(): k = input() K = int(k) if K % 2 == 0: print('-1') for i in range(1, 10 ** 3 * len(k) + 1): target = int('1' * i) * 7 if target % K == 0: print(i) break else: print(K - 1) if __name__ == '__main__': main()" p02596,s611245964,Wrong Answer,"n = int(input()) if n%2==0 or n%5==0: print(-1) ans,c = 0,0 while 1: c+=1 for i in range(10): if ((ans%10)+((n%10)*i)%10)%10==1: ans += n*i #print(ans,i) break ans = ans//10 if ans==0: break print(c)" p02596,s074408414,Wrong Answer,"K=int(input()) x=0 if K%2==0: print(-1) exit() for i in range(K+1): x=(x*10+7)%K if x==0: print(i+1) break" p02596,s529772230,Wrong Answer,"import sys def input(): return sys.stdin.readline().strip() def mapint(): return map(int, input().split()) sys.setrecursionlimit(10**9) K = int(input()) cnt = 0 now = 0 if K%2==0: print(-1) exit() s = set([0]) for _ in range(10**6+5): now += pow(10, cnt, K)*7 now %= K if now in s: print(cnt) break s.add(now) cnt += 1 else: print(-1)" 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" p02596,s508561775,Wrong Answer,"import sys input = sys.stdin.readline K = int(input()) flag = 0 seven = 0 if K % 2 != 0: for i in range(10000): seven = seven * 10 + 7 if seven % K == 0: ans = i + 1 flag = 1 break else: flag = 2 if flag == 2: print(-1) elif flag == 0: print(K-1) else: print(ans) " p02596,s357718308,Wrong Answer,"cnt = 1 mod = 7 k = int(input()) for i in range(k): if mod % k == 0: break cnt += 1 mod = (mod * 10 * 7) % k if mod % k == 0: print(cnt) else: print(-1) " p02596,s006046278,Wrong Answer,"K = int(input().rstrip()) n = 1 if K%7==0: L = 9 * K / 7 else: L = 9 * K R = 10 ** n s = set() while R!=1: R = (10 * R) % L n += 1 if R in s: print(-1) break else: s.add(R) else: print(n)" p02596,s443393748,Wrong Answer," k = int(input()) if k % 2 == 0: print(""-1"") exit() if k == 1 or k == 7: print(""-1"") exit() seven_i = 7 for i in range(1,10**6): seven_i = seven_i*10+7 seven_mod = seven_i % k if seven_mod == 0: print(i+1) exit() seven_i = seven_mod print(""-1"") " p02596,s067673313,Wrong Answer,"k = int(input()) t = 7 t %= k for i in range(1, k): if t == 0: print(i) exit() t = (t * 10 + 7) % k print(-1)" p02596,s827462863,Wrong Answer,"def resolve(): k = int(input()) if k % 2 == 0: print(-1) return for i in range(1, 10 ** 6): if (7 * pow(10, i, k)) % k == 7 % k: print(i) return print(-1) if __name__ == '__main__': resolve() " p02596,s987009942,Wrong Answer,"K = int(input()) ans = 1 tmp = 7 if K % 2 == 0 or K % 5 == 0: print(-1) else: for i in range(1,K): tmp += (10 ** i) * 7 ans += 1 if tmp % K == 0: print(ans) break else: continue" p02596,s142058734,Wrong Answer,"K=int(input()) if K%2==0: print(-1) else: seven=0 m=0 count=1 for i in range(K+1): m=(m*10+7)%K if m==0: print(count) break count+=1 " p02596,s384742309,Wrong Answer,"n=int(input()) if(n%2==0): print(-1) elif(n==999983): print(999982) elif(n==101): print(4)" p02596,s048110555,Wrong Answer,"n = int(input()) x = 7 ans = 1 for i in range(n+10): if x%n==0: break ans+=1 x= x*10 + 7 x=x%n if ans < n: print(ans) else: print(-1)" p02596,s162481111,Wrong Answer,"K=int(input()) count=0 n=7 if n%K==0: print('1') while True: if K%2==0: print('-1') break count+=1 n=7*10**count+n if n%K==0: print(count+1) break" p02596,s920752429,Wrong Answer,"K=input() print(-1)" 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())" p02596,s569925575,Wrong Answer,"k=int(input()) flag=True seq=7 """""" これは階乗を含むのでO(klogk)で重い for i in range(1,k): if (7*(10**i-1)//9) % k==0: print(i) flag=False break """""" for i in range(1,k): if seq%k==0: print(i) flag=False break seq=(seq*10+7)%k # %k(modの考え方)がなければ10**6ではO(k)は重すぎた if flag: print(-1)" p02596,s480626801,Wrong Answer,"import math k = int(input()) sevens = [] for i in range(1, 6): sevens.append(""7""*i) sevens2 = [int(s) for s in sevens] ans = [] for i in range(0, len(sevens)): if sevens2[i]%k == 0: ans.append(i+1) if ans: print(min(ans)) elif k%2 == 0: print(-1) elif k ==5: print(-1) elif k ==9: print(-1) else: print(k-1)" p02596,s218099749,Wrong Answer,"k=int(input()) if (k%2==0) or (k%5==0): print(-1) exit() if k%7==0: k//=7 o=0 m=1 if k==1: print(1) exit() for i in range(1,k): m*=10 o+=m%k o%=k if o==0: print(i) exit()" p02596,s647669307,Wrong Answer,"a=int(input()) b=0 if 7%a==0:b=b+1 if 77%a==0:b=b+1 if 777%a==0:b=b+1 if 7777%a==0:b=b+1 if 77777%a==0:b=b+1 if 777777%a==0:b=b+1 if 0==b: b=-1 print(b)" p02596,s577509095,Wrong Answer,"import sys import itertools sys.setrecursionlimit(1000000000) from heapq import heapify,heappop,heappush,heappushpop import math import collections import copy import bisect INF = 10**9+7 if __name__ == ""__main__"": k = int(input()) if k%2 == 0: print(-1) sys.exit() a = 7 p = len(str(k)) + 1 for i in range(p): if a%k == 0: print(i+1) sys.exit() a*=10 a+=7 print(k-1)" 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)" p02596,s425003178,Wrong Answer,"#abc174_c k=int(input()) # kの倍数が登場 -> 77...777%k==0となる最小の77の長さは? if k%2==0: print(-1) exit() if k==7: print(1) exit() rem=7%k for i in range(2,k+1): rem=(rem*10+7)%k if rem==0: print(i) exit() print(-1) " p02596,s762308868,Wrong Answer,"K=int(input()) a=[0]*(K+1) a[1]=7%K for i in range(2,K+1): a[i]=(a[i-1]*10+7)%K if a[i]==0: print(i) exit() print(-1) " p02596,s009573242,Wrong Answer,"k = int(input()) count = 0 temp = '' remainder = 0 reminder_list = [] while True: count += 1 temp += '7' # 7, 77, 777,,, reminder = int(temp) % k print(reminder) if reminder in reminder_list: count = -1 break if reminder == 0: break else: temp = str(reminder % k) reminder_list.append(reminder) print(count)" p02596,s179644552,Wrong Answer,"K=int(input()) temp=0 for i in range(1,10**6+1): t=""7""*K r=int(t)%K if(r%K==0): print(i) temp=1 break if(temp==0): print(-1)" p02596,s019083426,Wrong Answer,"k = int(input()) def k_multipul_at(k: int) -> int: r = 7 % k cache = [r, 0] i = 1 while r not in cache: r = (r * (10 % k) + 7 % k) % k cache.append(r) i += 1 return -1 if r else i print(k_multipul_at(k)) " p02596,s699479207,Wrong Answer,"k = int(input()) if k % 2 == 0 or k % 5 == 0: print(-1) exit() num = 7 for i in range(1, k): if num % k == 0: print(i) break num = (num % k) * 10 + 7 " p02596,s361538300,Wrong Answer,"N = int(input()) if N % 2 == 0: print(-1) exit() n7 = 0 for i in range(6): n7 += 7*(10**(i)) if n7 % N == 0: print(i+1) exit() print(-1)" p02596,s832278601,Wrong Answer,"k = int(input()) a = 0 for i in range(k): a = (a*10+7)/k if a == 0: print(i+1) quit() print(-1)" p02596,s018296495,Wrong Answer,"K = int(input()) a = 0 n = 0 out = '-1' for _ in range(K): a += 7 * (10 ** n) if a % K == 0: out = n + 1 break print(out) " p02596,s780789221,Wrong Answer,"K=int(input()) seven=0 m=1 while m!=0: seven=seven*10+7 m=seven % K print(seven)" p02596,s464645782,Wrong Answer,"import sys n=int(input()) if n%2 ==0: print(-1) sys.exit() Ai=[7%n] for i in range(1,n+1): res=(Ai[i-1]*10 + 7)%n if res ==0: print(i+1) sys.exit() Ai.append(res) print(-1)" p02596,s882788680,Wrong Answer,"k = int(input()) n = '7' cnt = 1 if k % 2 == 0: print(-1) else: while cnt <= 50: num = int(n) if num%k == 0: break elif cnt == 50: print(k-1) break else: print(num%k) cnt += 1 n += '7' " p02596,s216301291,Wrong Answer,"K = int(input()) nana=7 kou=1 if K % 2 == 0: print(-1) else: for i in range(1,K): if nana % K == 0: break nana = (nana * 10 + 7) % K kou +=1 print(kou)" p02596,s189998771,Wrong Answer,"import math k = int(input()) sevens = [] for i in range(1, 6): sevens.append(""7""*i) sevens2 = [int(s) for s in sevens] ans = [] for i in range(0, len(sevens)): if sevens2[i]%k == 0: ans.append(i+1) if ans: print(min(ans)) elif k%2 == 0: print(-1) elif k ==5: print(-1) else: print(k-1)" p02596,s605407360,Wrong Answer,"import numpy as np k = int(input()) if k % 2 ==0: print(-1) elif str(k)[0] == 5: print(-1) elif k == 101: print(4) else: print(k-1)" p02596,s026723019,Wrong Answer,"n=int(input()) x=7 s=1 while s10**6: print(-1) break count+=1 " p02596,s570657806,Wrong Answer,"k = int(input()) sevens = [0] * k sevens[0] = 7 % k if k == 7: print(1) else: for i in range(1, k): new = (sevens[i - 1] * 10 + 7) % k sevens[i] = new if new == 0: print(i + 1) break else: print(-1)" p02596,s946021675,Wrong Answer,"K = int(input()) if K % 2 == 0: print(-1) exit() k = 7 cnt = 1 for i in range(10 ** 7): if k % K == 0: break k = (k * 10 + 7) % K cnt += 1 else: print(-1) print(cnt)" 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()" 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()" p02596,s296581680,Wrong Answer,"n = int(input()) x, found = 0, False for i in range(1, n): x = ((10 * x) + 7)%n if x == 0: print(i) found = True break if not found: print(-1) " p02596,s684953213,Wrong Answer,"K = int(input()) if K % 2 == 0: print(-1) exit() X = 7 count = 1 while(1): if X % K == 0: print(count) exit() X = X*10 + 7 count += 1 print(count) print(X) print(-1)" p02596,s648260919,Wrong Answer,"K = int(input()) if K == 7: print(1) elif K % 2 == 0 or K % 5 == 0: print(-1) else: count = 1 num = 7 while True: num = (num * 10 + 7) % K count += 1 if num == 0: print(count) break" p02596,s699848463,Wrong Answer,"K = int(input()) count = 0 num = 7 if K % 2 == 0: print(-1) else: while True: if num % K == 0: count += 1 break else: count += 1 num = int(str(num) + ""7"") print(count)" p02596,s392001211,Wrong Answer,"import sys input = sys.stdin.readline def I(): return int(input()) def main(): K = I() if K%2 == 0: print('-1') sys.exit() ans = 1 n = 7 for i in range(K): if n%K ==0: print(ans) break n = (10*n + 7)%K ans += 1 main()" p02596,s205524566,Wrong Answer,"K = int(input()) if K%2 == 0 or K%5==0: print(-1) else: x = -1 for i in range(1,K): a = (10**i -1)*7 b = 9*K if a%b == 0: x = i break print(x) " p02596,s645514822,Wrong Answer,"k = int(input()) num = 0 if not k%2: print(-1) else: for i in range(k): num = (num*10+7)%k if num == 0: print(i+1) break" p02596,s942539293,Wrong Answer,"K = int(input()) n = 7 base_m = 7 % K count = 1 def next_line(n): return n * 10 + 7 if K % 2 == 0: print(-1) else: while(True): n = next_line(n) m = n % K count += 1 if m == 0: print(count) break elif m == base_m: print(-1) break" p02596,s181389824,Wrong Answer,"K = int(input()) A = 7 % K for i in range(1, K + 1): if A % K == 0: print(i) break A = (10 * A + 7) % K " p02596,s936360093,Wrong Answer,"k=int(input()) x=7 if k%2==0: print(-1) elif k==7: print(1) else: for i in range(k): x=x+7*10**(i+1) if x%k==0: print(i+2) quit()" p02596,s384446192,Wrong Answer,"import math import time K = int(input()) start_time = time.time() seven_number = 0 while True: elapsed_time = time.time() - start_time seven_number = seven_number*10+7 target_number = math.gcd(K,seven_number) if elapsed_time > 0.1: print(""-1"") break elif target_number == 1: continue else: print(len(str(seven_number))) break " p02596,s831568586,Wrong Answer,"k = int(input()) i = 0; mod = 0; while True: mod = (mod*10 + 7) % k; print(mod) if mod == 0: break; i += 1; if i == k: i = -2 break; print(i+1)" p02596,s660593643,Wrong Answer,"import math K = int(input()) sevn = 7 while True: if K < 7: print(-1) break f, i = math.modf(sevn / K) if f == 0.0: print(len(str(sevn))) break sevn = str(sevn) + '7' sevn = int(sevn) print(sevn)" p02596,s647154552,Wrong Answer,"K = int(input()) if K % 2 == 0: print(-1) else: i = 0 tmp_n = 0 while i >= 0: tmp_n = tmp_n + 10**i * 7 # print('tmp_n: ', tmp_n) if tmp_n != 0 and tmp_n % K == 0: break i += 1 print(i)" p02596,s320463677,Wrong Answer,"K=int(input()) if K%2==0 or K%5==0: print(""-1"") exit() for n in range(1,10**4+1): if (7*(10**n-1)//9)%K==0: print(n) exit() else: print(K-1)" p02596,s105989432,Wrong Answer,"#!/usr/bin/env python3 # -*- coding: utf-8 -*- import sys K = int(input()) res = 0 if K % 2 == 0 or K % 5 == 0: print(-1) sys.exit() surplus = 1 while True: res += 1 surplus = (10 * surplus) % (9*K) if surplus == 1: break print(res) " p02596,s729221179,Wrong Answer,"import math k=int(input()) if k%7==0: k=int(k/7) if k%2==0 or k%5==0: print(-1) else: count=0 for i in range(1,k): if math.gcd(i,k)==1: count+=1 num=1 for i in range(2,count): num+=(10**i)%k num=num%k if num==0: print(i) break" p02596,s397632760,Wrong Answer,"K = int(input()) X = 1 temp = 7 ans = 1 if K == 7: print(ans) exit() for i in range(10**6+1): X = X * 10 % K temp += X * 7 temp %= K ans += 1 if temp == 0: print(ans) break if i == 10**6: print(-1)" p02596,s137398264,Wrong Answer," ip = int(input()) ans = 7 for i in range(1,8): if int(ans) % ip == 0: print(i) break elif i == 8: print(int(ans)-1) else: ans = int(ans) * 10 + 7 i += 1 " p02596,s273200686,Wrong Answer,"K = int(input()) if K%2 == 0 or K%5 == 0: print(-1) else: if K%7 == 0: L = K//7 else: L = 9*K c = 1 for i in range(10**7): c = (10*c)%L if c%L == 1: print(i+1) break " p02596,s734673253,Wrong Answer,"def resolve(): ''' code here ''' K = int(input()) is_not_found = True memo = [0 for _ in range(K)] i=7%K memo[i] += 1 res = 1 while is_not_found and memo[i] == 1: i = (i * 10 + 7) % K memo[i] += 1 res += 1 if i == 0: is_not_found = False print(res) if is_not_found == False else print(-1) if __name__ == ""__main__"": resolve() " p02596,s461575600,Wrong Answer,"n = int(input()) if n % 2 == 0: print(-1) else: a = 7 for i in range(1000000): if a % n == 0: print(i+1) break a = (a%n) * 10 + 7 " p02596,s611991978,Wrong Answer,"K = int(input()) if K % 2 == 0 or K % 5 == 0: print(-1) cnt = 1 cur = 7 while True: if cur % K == 0: print(cnt) break if cnt > K: print('-1') break cur = (cur * 10 + 7) % K cnt += 1" p02596,s628487492,Wrong Answer,"K = int(input()) if K % 2 == 0: print(-1) exit() num = 7 for i in range(K): if num % K == 0: print(i) exit() else: num = num*10 + 7 print(-1)" p02596,s673608850,Wrong Answer,"K = int(input()) if K % 2 == 0: print(-1) a = 0 if K < 900000: for i in range(K): a = 7 * 10**(i) + a if a % K == 0: print(i) break elif K >= 900000: print(999982)" p02596,s969914384,Wrong Answer,"K = int(input()) if K%2==0: print(""-1"") else: ans = 0 temp = 0 check = 0 for i in range(K): ans += 1 temp *= 10 temp += 7 temp %= K if temp==0: check+=1 if check==1: break print(ans)" p02596,s158492422,Wrong Answer,"k = int(input()) x = 7 ans = 1 for i in range(k): if x == 0: print(ans) exit() ans += 1 x = (x * 10 + 7) % k print(-1) " p02596,s477542973,Wrong Answer,"def main(): s = input() k = int(s) if k % 2 == 0: print(""-1"") exit(0) kurai = 1 count = 1 sevens = 0 while True: sevens = sevens + 7 * kurai if sevens % k == 0: print(str(count)) break else: count+=1 kurai = kurai * 10 print(str(count)) if __name__ == ""__main__"": main()" p02596,s413364428,Wrong Answer,"K = int(input()) tmpNum = 7 count = 1 keisuu = 10 tmp = tmpNum%K aa = tmp while tmp !=0 and count777777: print(-1) elif A<7: print(-1) elif A<=7 and 7%A==0: print(1) elif A<=77 and 77%A==0: print(2) elif A<=777 and 777%A==0: print(3) elif A<=7777 and 7777%A==0: print(4) elif A<=77777 and 77777%A==0: print(5) elif A<=777777 and 777777%A==0: print(6)" p02596,s155749373,Wrong Answer,"def a(n): if(n==1): print(-1) return 0 for p in range(2, n): if n % p == 0: print(-1) return 0 if(n==2 or n==5): print(-1) return 0 if(n==7): print(1) return 0 cnt=1 t=""1"" while(1): t=t+""1"" cnt=cnt+1 if(int(t) % n ==0): print(cnt) break n = int(input()) a(n)" p02596,s399383293,Wrong Answer,"K = int(input()) a = [0] * 1000000 a[0] = 7 % K for i in range(1, 1000000): a[i] = (a[i-1] * 10 + 7) % K if (a[i] == 0): break if(i == 999999): print('-1') else: print(i+1) " p02596,s034519740,Wrong Answer,"K=int(input()) if(K==7): print(""1"") elif(K==1): print(""1"") " p02596,s654360995,Wrong Answer,"import sys K = int(input()) for ans in range(1, K): x = 7*((pow(10, ans, K) - 1)/9) if x%K == 0: print(ans) sys.exit() print(-1) " p02596,s829047077,Wrong Answer,"k = int(input()) b = 0 if k % 2 == 0: print(""-1"") else: a = """" b = 0 while True: a = a+""7"" b += 1 a_int = int(a) if a_int % k == 0: break else: pass print(b)" p02596,s637085929,Wrong Answer," def main(K): if K % 2 == 0: print(-1) return num = 7 while True: if num % K == 0: print(len(str(num))) return num = int(str(num) + ""777"") print(-1) # [N, D] = map(int, input().split()) # lines = [] # for i in range(N): # lines.append(list(map(int, input().split()))) K = int(input()) main(K) " p02596,s398935256,Wrong Answer,"#!/usr/bin/env python3 import sys input = sys.stdin.readline def S(): return input().rstrip() def I(): return int(input()) def MI(): return map(int, input().split()) k = I() m = k % 10 if m % 2 == 0 or m == 5: print(-1) exit() else: s = ""7"" rk = 7 for i in range(1, 10 ** 6 + 1): rk1 = ((10 % k) * rk + 7 % k) % k if rk1 == 0: print(i + 1) exit() rk = rk1 " p02596,s756195138,Wrong Answer,"x=int(input()) def mult(x): t=str(7)*(length(x)) if length(x)<=len(t) and x <= int(t): print(t) else: t=str(7)*(length(x)+1) print(t) def length(x): if x==0: return 0 if x<0: return length(x*(-1)) elif x < 10: return 1 else: return 1+(length(x // 10)) mult(x)" p02596,s792901724,Wrong Answer,"import sys K = int(input()) l_begin = 7 count = 1 for i in range(100): if l_begin % K == 0: print(count) sys.exit() l_begin = 10 * l_begin + 7 count += 1 if K > 10000 and K <= 1000000 and K % 7 != 0 : print(K-1) sys.exit() print(-1)" p02596,s556775200,Wrong Answer,"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 if a[i]==0: print(i) exit() print(-1) " p02596,s338481404,Wrong Answer,"k = int(input()) def k_multipul_at(k: int) -> int: r = 7 % k cache = [r] i = 1 while r not in cache and r: r = r * (10 % k) + 7 % k cache.append(r) i += 1 return -1 if r else i print(k_multipul_at(k)) " p02596,s295674954,Wrong Answer," k = int(input()) count=1 x=7 #for i in range(1,10): #print(x) while True: x+=7*(10**count) if k%2==0: break if x>k and x%k==0: print(count+1) break count+=1 if count==1: print(-1)" p02596,s776233943,Wrong Answer,"n = int(input()) if n%2==0: print(-1) elif n%5==0: print(-1) else: k=7 while k%n!=0: k*=10 k+=7 if k%n==0: print(len(str(k))) break " p02596,s479735938,Wrong Answer,"K = int(input()) x = [7, 77, 777, 7777, 77777, 777777] Count = 0 flag=""FALSE"" for i in x: Count = Count + 1 if (i % K)==0: flag=""TRUE"" break if flag==""FALSE"": Count = -1 if K>=777777: Count = K - 1 print(Count)" p02596,s576464200,Wrong Answer,"k = int(input()) if k%2==0 or k%5==0: print('-1') else: a = 0 for i in range(99983): a = (a*10+7) % k if a == 0: print(i+1) else: print(-1) " p02596,s720428562,Wrong Answer,"N = int(input()) if N % 2 == 0: print(-1) exit() n7 = 0 for i in range(7): n7 += 7*(10**(i)) if n7 % N == 0: print(i+1) exit() print(-1)" p02596,s819036768,Wrong Answer,"from sys import stdin K = int(stdin.readline().rstrip()) def main(K): a=0 for i in range(1,K): a = ((10%K) * a + 7)%K if a == 0: return i return -1 print(main(K))" p02596,s041961346,Wrong Answer,"K = int(input()) r = 1 for i in range(1,K+1): r += pow(10,i,K) #print(r) r %= K if r == 0: print(i+1) break else: print(-1)" p02596,s651307258,Wrong Answer,"K=int(input()) mod=9*K n=1 if K%2==0: print(-1) exit() for i in range(1,K+1): n=n*10%mod if n==1: print(i) exit()" p02596,s159558665,Wrong Answer,"k = input() k = int(k) if 1 <= k and k <= 1000000: for i in range(1, 8): n = ""7""*i n = int(n) if n%k == 0: print(n) else: print(-1)" p02596,s251690658,Wrong Answer,"import sys x = int(input()) if x%2 == 0: print(-1) sys.exit() y = 7 i = 1 while y%x != 0: if i == 10000: print(-1) sys.exit i = i + 1 y = y*10 + 7 print(i)" p02596,s883838345,Wrong Answer,"K = int(input()) t = 7 for i in range(K): print(t) if t % K == 0: break t = (t * 10 + 7) % K else: print(-1)" p02596,s152315134,Wrong Answer,"k_len = input() k = int(k_len) number = len(k_len) Seq = 7 while True: if k % 2 == 0: print(-1) elif Seq % k == 0: print(number) break else: Seq = Seq + 7 * (10 ** number) number += 1 print(Seq) " p02596,s779033639,Wrong Answer,"N=int(input()) num = 7 plus = 70 i=1 a=[] while num%N!=0: b=num//N print(b*N,num%N) if num%N in a: i=-1 break a.append(num%N) num+=plus plus*=10 i+=1 if i>N: i=-1 break print(i)" p02596,s012291914,Wrong Answer,"def main(k): size, res = 1, 7 % k while res and size <= k: res = (res * 10 + 7) % k size += 1 return -1 if size > 1_000_000 else size if __name__ == '__main__': k = int(input()) print(main(k)) " p02596,s064087707,Wrong Answer,"K = int(input()) i = 0 t = 7 while True: if K % t == 0: print(i) break elif t > 10**6: print(-1) break i += 1 t += 7 * 10**i " p02596,s447129594,Wrong Answer,"k = int(input()) k *= 7 l = k % 10 if l == 1: m = 7 elif l == 3: m = 9 elif l == 7: m = 1 elif l == 9: m = 3 else: m = -1 if m == -1: print(-1) else: x = k for i in range(10 ** 10): s = str(x) if len(s) == s.count(""7""): print(len(s)) break else: x = k * m m += 10" p02596,s325081792,Wrong Answer,"K = int(input()) res = -1 count = 1 sum = 7 prev = [] r = sum % K while(r not in prev): prev.append(r) sum = sum * 10 + 7 r = sum % K if(r == 0): res = count+1 break count += 1 print(res) " p02596,s425258251,Wrong Answer,"K = int(input()) ans = 0 if K == 7: print(1) exit() for i in range(10**6): ans += pow(10,i,K) if ans % K == 0: print(i+1) exit() print(-1)" p02596,s052350911,Wrong Answer,"K = int(input()) N = 0 for i in range(K): N += N*10+7 if N%K ==0: print(i) break else: print(-1)" p02596,s280626104,Wrong Answer,"K=int(input()) base=7 for i in range(1,K): if base%K==0: print(i) exit() else: base=(base*10+7)%K print(-1) " p02596,s742188519,Wrong Answer,"s = int(input()) su = 0 sum = [] for i in range(0,s): su=su*10+7 if su not in sum: sum.append(su) for i in range(len(sum)): if sum[i]%s==0: print(sum[i]) exit() for i in sum: if i%s !=0: continue print(-1)" p02596,s737853733,Wrong Answer,"import math import time K = int(input()) start_time = time.time() seven_number = 0 while True: elapsed_time = time.time() - start_time seven_number = seven_number*10+7 target_number = math.gcd(K,seven_number) if elapsed_time > 1: print(""-1"") break elif target_number == 1: continue else: print(len(str(seven_number))) break " p02596,s856885415,Wrong Answer,"K = input() N = 10 **10 x = 0 for i in range(1, N): x += 7 * 10 **i if x % int(K) == 0: print(i) break if N == i: print('-1')" p02596,s172380167,Wrong Answer,"import sys k=int(input()) l=[] x=7%k if x == 0: print(1) sys.exit() for i in range(2,k+1): x=7%k num=(x*10+7)%k x=num l.append(num) if num==0: print(i) break if 0 not in l: print(-1)" p02596,s683112362,Wrong Answer,"K = int(input()) """""" i = 1 while True: seven = int('7' * i) if seven % K == 0: print(i) exit() if i > 10**6: print(-1) exit() i += 1 """""" cnt = 0 for i in range(1, 10**6+1): cnt += K if set(str(cnt)) == {'7'}: print(len(str(cnt))) exit() print(-1)" p02596,s576268901,Wrong Answer,"K = int(input()) max_num = 10 ** 20 i = 1 s = 0 while s < max_num: s = (7 * (10**i) - 7) // 9 if s % K == 0: print(i) exit() i += 1 print('-1') " p02596,s114814218,Wrong Answer,"K = int(input()) a = [0]*K a[0] = 7%K ans = -1 for i in range(K-1): if(a[i]==0): ans = i+1 break a[i+1] = (10*a[i]+7)%K print(ans) " p02596,s592379752,Wrong Answer,"x= int(input()) if x%2!=0 or x%5!=0 : print(-1) i=1 while True: if (10**i -1)%(9*x) ==0: break else: i+=1 print(i)" p02596,s467253844,Wrong Answer,"K = int(input()) if (K % 5 == 0) | (K % 2 == 0): print(-1) elif K == 7: print(1) else: if (K % 7) == 0: K //= 7 T, R, md, Ans = (1, 1, 0, -1) for i in range(1, K + 1): md = 10 % K R = (R * md) % K T = (T + R) % K if T == 0: Ans = i + 1 break print(Ans)" p02596,s398733245,Wrong Answer,"def main(): K = int(input()) if K % 2 == 0 or K % 5 == 0: print(-1) return cnt = 1 tmp = 7 while tmp != 0: tmp = tmp * 10 + 7 tmp %= K cnt += 1 print(cnt) main() " p02596,s575332181,Wrong Answer,"K = input() N = 10 **10 x = 0 for i in range(1, N): x += 7 ** 10^i if x % int(K) == 0: print(i) break if N == i: print('-1')" p02596,s896752439,Wrong Answer,"K = int(input()) if (K % 5 == 0) | (K % 2 == 0): print(-1) elif K == 7: print(1) else: Ans = -1 a = 7 % K for i in range(1, K + 1): a = (a * 10 + 7) % K if a == 0: Ans = i + 1 break print(Ans)" p02596,s382660493,Wrong Answer,"def main(): k = int(input()) counter = len(str(k * 7)) while True: if k % 2 == 0: print(-1) return counter += 1 temp7 = ''.join(([""7""] * counter)) if int(temp7) % k == 0: print(len(temp7)) return if __name__ == ""__main__"": main()" p02596,s996273741,Wrong Answer,"import math import sys K = int(input()) if K%2 == 0 or K%5 == 0: print(-1) sys.exit() n = round(math.log10(K)+1) amari = int(7*(10**n - 1)/9 % K) if amari == 0: print(n) sys.exit() while True: if amari%K == 0: print(n) break amari = (amari*10 + 7)%K n += 1" p02596,s758005794,Wrong Answer,"k=int(input()) i=1 se=7 for _ in range(k): se=se*10+7 i+=1 if se%k==0: print(i) exit() se %= k print('-1')" p02596,s626184081,Wrong Answer,"k = int(input()) x = 7 % k cnt = 0 for i in range(2 * 10 ** 6): if x == 0: break x = (x * 10 + 7) % k cnt += 1 print(cnt + 1) " p02596,s442858037,Wrong Answer,"K = int(input()) if K==7 or K==1: print(1) if K==11: print(2) if K in (3,37,3*37): print(3) elif K in (11,101,1111): print(4) elif K in (41,271,11111): print(5) elif K in (1, 3, 7, 11, 13, 21, 33, 37, 39, 77, 91, 111, 143, 231, 259, 273, 407, 429, 481, 777, 1001, 1221, 1443, 2849, 3003, 3367, 5291, 8547, 10101, 15873, 37037, 111111): print(6) elif K in (41,271,41*271): print(7) else: print(-1)" p02596,s438621668,Wrong Answer,"K = int(input().rstrip()) n = 1 if K%7==0: L = 9 * K / 7 else: L = 9 * K R = 10 ** n s = set() if K ==7: print(1) else: while R!=1: R = (10 * R) % L n += 1 if R in s: print(-1) break else: s.add(R) else: print(n)" p02596,s106826216,Wrong Answer,"K = int(input()) p = [] x = 0 a = 0 while True: if K%2 == 0: a = -1 break a += 1 x = x + (10**a)*7 p.append(x) if x%K == 0: break print(a) " p02596,s753876222,Wrong Answer,"n=int(input()) a=[7] for i in range(40000): a.append(a[-1]*10+7) if n%2==0 or n%5==0: print(-1) else: flg=0 for i in a: if i%n==0: print(len(str(i))) flg=1 break if flg==0: print(n-1)" p02596,s043236005,Wrong Answer,"K = int(input()) n = 7 a = 1 if K ==1: print(1) elif K%2 == 0: print(-1) elif K%5 == 0: print(-1) else: while n % K != 0: n = 10*n + 7 a = a + 1 if n % K == 0: print(a) break " p02596,s794215265,Wrong Answer,"k = int(input()) if(k%2==0): print(""-1"") else: i = 1 while True: m = 7 if(m%k==0): ans = i print(ans) break if(i>1000000): print(""-1"") break m = m*10 + 7 i += 1 " p02596,s278137506,Wrong Answer,"k = int(input()) if 7 % k == 0: print(1) if k % 2 == 0: print(-1) ans = 0 prev = 7 for i in range(1000000): prev = prev * 10 + 7 if prev % k == 0: print(i+2) ans = 1 break if ans == 0: print(-1)" p02596,s200207633,Wrong Answer,"from fractions import gcd from collections import Counter, deque, defaultdict from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort from itertools import product, combinations,permutations from copy import deepcopy import sys sys.setrecursionlimit(4100000) if __name__ == '__main__': K = int(input()) sevens = 7 for i in range(1, K): if sevens%K==0: print(len(str(sevens))) quit() sevens = sevens*10+7 print(-1)" p02596,s709861352,Wrong Answer,"K = int(input()) seven = 7 count = 0 if(K % 2 == 0 or K % 5 == 0): print(-1) else: while(seven % K != 0): count += 1 seven += 7 * (10 ** count) print(count) if(count >= 1): print(count + 1)" p02596,s873371900,Wrong Answer,"K = int(input()) if K==7: print(1) else: x = 7%K count = 1 for i in range(K): x = (x*10+7)%K count += 1 if x==0: print(count) break if x!=0: print('-1')" p02596,s123865787,Wrong Answer,"import numpy as np k = int(input()) Moji = '' if k % 2 ==0: print(-1) elif str(k)[0] == 5: print(-1) elif k < np.sqrt(7777777777): for i in range(10**6): Moji += '7' if int(Moji)%k == 0: print(i+1) break else: print(k-1)" p02596,s389627142,Wrong Answer,"K=int(input()) n=1 an=7 for i in range(K+10): n+=1 an=(10*an+7)%K if an==0: print(n) exit() print(-1)" p02596,s772939387,Wrong Answer,"K = int(input()) if K%7 == 0: L = 9*K//7 else: L = 9*K if L%2 == 0 or L%5 == 0: print(-1) else: X = 10%L for i in range(K): X = X*10 % L if X == 1: print(i+2) break" p02596,s610241637,Wrong Answer,"import sys input = sys.stdin.readline def I(): return int(input()) def main(): K = I() if K%2 == 0: print('-1') exit() ans = 1 n = 7 for i in range(K): if n%K ==0: print(ans) break n = (10*n + 7)%K ans += 1 main()" p02596,s566818255,Wrong Answer,"k = int(input()) a =7 for i in range(17000): if a%k ==0: print(i+1) break i +=1 a = a + 7*10**(i) else: print(""-1"") " p02596,s917321501,Wrong Answer,"K = input() n = 7 for i in range(6): p = n % int(K) if p == 0: break else: n = n * 10 + 7 if int(i) == 5: i = -1 else: i += 1 print(int(i)) " p02596,s932337127,Wrong Answer,"def multiplier(i): cnt = 0 number = 0 while cnt <= i: number += 10 ** cnt cnt += 1 return number input_k = int(input()) count = 0 current_7 = 0 if input_k % 2 == 0: print(""-1"") else: while True: current_7 = 7 * multiplier(count) if current_7 % input_k == 0: print(count-1) break else: count += 1 " p02596,s758137823,Wrong Answer,"K = int(input()) x = 7 ans = 1 if x%K==0: print(ans) visited = [0]*(K+1) while x!=0: x %= K x = x*10+7 x %= K if visited[x]: print(-1) exit() visited[x] = 1 ans += 1 print(ans)" p02596,s381012629,Wrong Answer,"k = input() k = int(k) f = 0 if 1 <= k and k <= 1000000: for i in range(1, 8): n = ""7""*i n = int(n) if n%k == 0: print(n) f = 1 break if f == 0: print(-1)" p02596,s136485132,Wrong Answer,"from collections import deque import sys input = sys.stdin.readline import math k = int(input()) n = 7 ans = -1 for i in range(10**4): #注意 if n % k == 0: ans = i+1 break else: n = n*10 + 7 def is_prime(z): if z == 1: return False for y in range(2, int(math.sqrt(z)) + 1): if z % y == 0: return False return True if k%2==0: ans=-1 elif is_prime(k): ans = k-1 print(ans) " p02596,s138287711,Wrong Answer,"import sys k = int(input()) a = [0]*k a[0] = 7 cnt = 0 for i in range(1, k): a[i] = (10*a[i-1]+7) % k if k % 2 == 0 or k % 3 == 0 or k % 5 == 0: print(-1) sys.exit() for i in range(k): if a[i] == 0: print(i+1) break" p02596,s603610719,Wrong Answer,"k = int(input()) a = [None for i in range(10**7) ] ans = -1 a[1] = 7%k for i in range(2,k): a[i] = (a[i-1]*10 + 7)%k for i in range(1,k): if a[i] == 0: ans = i break print(ans) " p02596,s763371837,Wrong Answer,"import math import sys K = int(input()) if K%2 == 0 or K%5 == 0: print(-1) sys.exit() n = round(math.log10(K)+1) amari = int(7*(10**n - 1)/9 % K) if amari == 0: print(-1) sys.exit() while True: if amari%K == 0: print(n) break amari = (amari*10 + 7)%K n += 1" p02596,s211816257,Wrong Answer,"k = int(input()) s = 7 cnt = 0 if k % 2 == 1 and not k % 5 == 0: while(1): if s == 0: cnt += 1 print(cnt) break else: s = (s * 10 + 7) % k cnt += 1 else: print(-1)" p02596,s411306404,Wrong Answer,"#!/usr/local/bin/python3 # coding: utf-8 import numpy as np kita = int(input()) seven = """" i = 0 while True: i += 1 if kita % 2 == 0: print(-1) break if kita % 2 == 0: print(-1) break seven += ""7"" if int(seven) > kita: if int(seven) % kita == 0: print(i) break" p02596,s727818696,Wrong Answer,"K = int(input()) num = 0 if K%2 == 0: print(-1) else: for i in range(1, 100000): num = num*10 + 7 num %= K if num == 0: print(i) break else: print(-1)" p02596,s574880228,Wrong Answer,"N=int(input()) num = 7 plus = 70 i=1 a=[] s = str(N) array = list(map(int, s)) if(sum(array)%7!=0): N*=7 while num%N!=0: if num%N in a: i=-1 break a.append(num%N) num+=plus plus*=10 i+=1 print(i)" p02596,s906521549,Wrong Answer,"k = int(input()) if(k%2==0): print(""-1"") a = 7 counter = 1 for i in range(k): r = a%k if(r == 0): print(counter) break else: counter += 1 a = 10*r + 7%k " p02596,s369978102,Wrong Answer,"a=int(input()) b=-1 if 7%a==0:b=1 elif 77%a==0:b=2 elif 777%a==0:b=3 elif 7777%a==0:b=4 elif 77777%a==0:b=5 elif 777777%a==0:b=6 print(b)" p02596,s092444715,Wrong Answer,"import sys input = sys.stdin.readline k = int(input()) if k == 7: print(1) elif k % 2 == 0 or k % 5 == 0: print(-1) else: if k % 7 == 0: k = k // 7 mod = 9*k i = 1; result = 10; while result != 1: result = (result * 10) % mod i += 1 print(i) " p02596,s141933285,Wrong Answer,"k = int(input()) n = 0 frag = 0 sevens = """" if k%2==1: print(-1) exit() while frag==0: sevens = sevens + ""7"" n+=1 if int(sevens)%k==0 or n>1000000: frag=1 print(n)" p02596,s267157929,Wrong Answer,"k = int(input()) start = 7 if k % 2 == 0: print(""-1"") exit() for i in range(k + 1): if start % k == 0: print(i + 1) exit() start = (start * 10 + 7) % k" p02596,s195043826,Wrong Answer,"k = int(input()) cur = 0 flag = False for i in range(1, k): cur *= 10 cur += 7 cur %= k if cur == 0: flag = True break if flag: print(i) else: print(-1)" p02596,s788692185,Wrong Answer,"k = int(input()) flag = False resid = 7 if k == 7: i = -1 flag = True else: for i in range(k): resid = (resid*10+7)%k if resid == 0: flag = True break if flag: print(i+2) else: print(-1)" p02596,s060592488,Wrong Answer,"K = int(input()) c = ""-1"" for i in range(1,2000): if int(""7""*i) % K == 0: c = i break print(c)" p02596,s761013808,Wrong Answer,"n = int(input()) if n==0: print(0) if n%2==0: print(-1) elif n%5==0: print(-1) else: k=7 l=1 while k!=0: l+=1 k*=10 k+=7 k%=n #print(k) print(l) " p02596,s905610864,Wrong Answer,"def is_prime(a): if a == 1: return False i = 2 while i * i <= a: if a % i == 0: return False return True K = int(input()) if not is_prime(K) or K == 2: print(-1) else: print(K - 1)" p02596,s661607930,Wrong Answer,"def solution(K: int) -> int: sevens: int = 0 for i in range(1, K + 1): print(sevens) sevens = (sevens*10 + 7) % K if sevens == 0: return i return -1 K: int = int(input()) print(solution(K)) " p02596,s534471783,Wrong Answer,"k = int(input()) a =7 for i in range(15000): if a%k ==0: print(i+1) break i +=1 a = a + 7*10**(i) else: print(""-1"") " p02596,s906560757,Wrong Answer,"K = int(input()) n = ""7""*len(str(K)) for i in range(len(str(K)), len(str(K))*10000): print(i) if int(n) % K == 0: print(i) break n += ""7"" else: print(-1)" p02596,s839297128,Wrong Answer,"import math import sys import copy input = sys.stdin.readline N=int(input()) if N==1 or N==7: print(1) elif N%2==0: print(-1) elif N==3: print(3) elif N%5==0: print(-1) elif N==11 or N==77: print(2) elif N==777 or N==37 or N==111 or N==259: print(3) elif N==101: print(4) else: print(N-1) #print(Wcount,Rcount)" p02596,s076771143,Wrong Answer,"k=int(input()) if k%2 == 0 or k%5 == 0: print(-1) exit() s = '' for i in range(10000): s += '7' if int(s) % k == 0: print(i+1) exit() #nの素数判定 def is_prime(n): if n == 1: return False for i in range(2,int(n**0.5)+1): if n % i == 0: return False return True if k%7 == 0: k//=7 if is_prime(k): print(k-1) exit() print(-1) " p02596,s508451208,Wrong Answer,"K = int(input()) now = 7 visited = [0]*(K+10) flg = False for i in range(1,9999): tmp = now%K visited[tmp] += 1 now = now*10+7 if tmp == 0: flg = True break if visited[tmp] > 1 : flg = False break if flg: print(i) else: print(-1)" p02596,s439818875,Wrong Answer,"k = int(input()) t = '7' i = 0 if k % 2 == 0: print(-1) elif (set(str(k))) == {'0', '1'} or k % 7 == 0: while(1): s = int(t) if s % k == 0: ans = i+1 break t += '7' i += 1 print(ans) else: print(k-1)" p02596,s329459239,Wrong Answer,"K = int(input()) i, a = 0, 0 l = [] for i in range(K-1): a = (10*a + 7) % K l.append(a) j, ans = 0, -1 for j in range(K-1): if l[j] == 0: ans = j + 1 break print(ans)" p02596,s061801605,Wrong Answer,"K=input() keta = len(K) k=int(K) if k%2==0: print(-1) else: seven = ""7""*keta s = int(seven) ans=keta-1 for _ in range(2*k): ans+=1 s = s%k if s==0: print(ans) break else: s = s*10+7 " p02596,s796282557,Wrong Answer,"import sys sys.setrecursionlimit(10**6) def main(input, print): K = int(input()) if K % 2 == 0: print(-1) return else: x = 7 % K for i in range(1, K+1): if x == 0: print(i) return x = (x*10+7) % K if __name__ == '__main__': main(sys.stdin.readline, print) " p02596,s428965995,Wrong Answer,"K = int(input()) n = 7 ans = 0 i = 1 if K%2==0: ans = -1 else: for i in range(K*2+10): if n%K==0: ans = i+1 break n *= 10 n += 7 n %= K print(ans)" p02596,s889816102,Wrong Answer,"from collections import defaultdict import sys mod = int(input()) d = defaultdict(int) s = 7 c = 1 while(True): if s == 0: break if s in d: print(-1) sys.exit() d[s] = 1 s = (s*10 + 7) % mod c += 1 print(c)" p02596,s796005315,Wrong Answer,"def main(): K = int(input()) if K % 2 == 0: return -1 elif K % 5 == 0: return -1 an_min = 7 an_max = int(""7"" * K) while True: if an_min % K == 0: return len(str(an_min)) an_min = an_min * 10 + 7 if an_max % K == 0: return len(str(an_max)) an_max = an_max // 10 if __name__ == ""__main__"": answer = main() print(answer)" p02596,s037788397,Wrong Answer,"k=int(input()) if k%2==0 or k%5==0: print(-1) else: t=7 i=1 for i in range(1,40000): if t%k==0: print(i) break else: t=t*10+7 i=i+1 else: print(k-1)" p02596,s316969990,Wrong Answer,"#C K=int(input()) ans=-1 if K==1: ans=1 elif K==2 or K==5 or K==10: ans=-1 else: p=0 for i in range(1,K): p = (p*10+7)%K #print(i,p) if p==0: ans=i break print(ans) " p02596,s419064598,Wrong Answer,"K = int(input()) if K%7 == 0: L = 9*K//7 else: L = 9*K if K%2 == 0 or K%5 == 0: print(-1) else: X = 10%L for i in range(K): X = X*10 % L if X == 1: print(i+2) break" p02596,s108199718,Wrong Answer,"k = int(input()) a = [None]*1000001 a[1]=7%k n=0 for i in range(2,k+1): a[i]=(a[i-1]*10+7)%k if a[i]==0 and n==0: print(""{}"".format(i)) n=1 if n==0: print(""-1"") " p02596,s765404471,Wrong Answer,"K = int(input()) if K % 7 == 0: L = 9 * K / 7 else: L = 9 * K if K % 2 == 0 or K % 5 ==0: ans = -1 else: ans = 1 m = 10 % K while(ans >= 0): if (m == 1): break m *= 10 m %= L ans += 1 print(ans) " p02596,s675040602,Wrong Answer,"K = int(input()) if K % 2 == 0: print(-1) cnt = 1 cur = 7 while True: if cur % K == 0: print(cnt) break a = K * cur b = str(a) b_set = set(b) if cnt > K: print('-1') break cur = (cur % K) * 10 + 7 cnt += 1" p02596,s653372940,Wrong Answer,"n = 7 k = int(input()) amari = 7%k for i in range(1, 10**6): amari += 7*pow(10, i, k) amari %= k if amari == 0: print(i+1) exit() print(-1)" p02596,s884849795,Wrong Answer,"import sys ## io ## def IS(): return sys.stdin.readline().rstrip() def II(): return int(IS()) def MII(): return list(map(int, IS().split())) def MIIZ(): return list(map(lambda x: x-1, MII())) #======================================================# def main(): k = II() print(-1) if __name__ == '__main__': main()" p02596,s226331874,Wrong Answer,"k = int(input()) if k % 2 == 0 or k % 5 == 0: print(-1) exit() for i in range(1, 11): if int('7'*i) % k == 0: print(i) break else: print(k - 1)" p02596,s877071933,Wrong Answer,"K=int(input()) mod=K n=7 if K%2==0: print(-1) exit() for i in range(10**7): n=n*10%mod if n==7: print(i+1) exit()" p02596,s429185702,Wrong Answer,"#!/usr/bin/env python3 import time k = int(input()) s = '' rs = [] start = time.time() cnt = 0 while True: cnt += 1 s += '7' n = int(s) r = n%k if r==0: print(cnt) exit() if r in rs: print(-1) end = time.time() exit() rs.append(r) end = time.time() t = end-start if t >= 1.98: print(k-1) exit() " p02596,s652842184,Wrong Answer,"import time k = int(input()) kk = k n = 7 c = 1 t1 = time.time() t2 = time.time() while (t2-t1) <= 1.8: if k%7 == 0: s = str(k) if all(x==""7"" for x in s): print(len(s)) break k+=kk t2 = time.time() if (t2-t1) > 1.8: print(-1)" p02596,s954886502,Wrong Answer,"K = int(input()) N = 0 for i in range(10000): N += 7*(10**i) if N % K == 0: print(i+1) exit() print(-1)" p02596,s862662264,Wrong Answer,"import math k = int(input()) count = 1 seven = 7 if k%2 == 0 or k%5 == 0: print(-1) else: while True: if(seven%k==0): print(count) break else: seven += 7* (10**count) print (count) count+=1" p02596,s768024351,Wrong Answer,"k = int(input()) if k % 7 == 0: L = k/9 else: L = 9 * k if L % 2 == 0 or L % 5 == 0: print(-1) exit() m = 1 % L for i in range(k): m = (10 * m) % L if m == 1: print(i + 1) exit() elif i == k - 1: print(-1) exit()" p02596,s168084213,Wrong Answer,"K=int(input()) if K%2 == 0 or K%5 == 0: print(-1) else: base = '' while(1): base += '7' if int(base)%K == 0: print(base) break " p02596,s918029135,Wrong Answer,"K = int(input()) S = ""7"" # i = int(S) // K a = 0 c = 0 if K % 2 == 0: print(-1) exit() a = 7 % K for i in range(K + 1): if a == 0: print(i + 1) break a = (a * 10 + 7) % K # while int(S) % K != 0: # if K % 2 == 0: # i = -1 # break # S += ""7"" # i += 1 # print(i)" p02596,s500741290,Wrong Answer,"K = int(input()) for i in range(1, K): if K % 2 == 0: print('-1') break elif int('7'*(i)) % K == 0: print(i) break" p02596,s860391246,Wrong Answer,"# mod Nの取りうる値の上限はN-1なのでN-1回のループで解が出なければ-1でいい # modの値が同じになった場合ループになるためexitする K = int(input()) mod = 7 % K res = [] i = 1 while res.count(mod) == 0: if mod == 0: print(i) exit() res.append(mod) mod = (mod * 10 + 7) % K i += 1" p02596,s577843893,Wrong Answer,"from sys import stdin def main(): input = stdin.readline K = int(input()) if (K % 2 == 0) or (K % 5 == 0): print(""-1"") return seven_len = 7 ans = 0 while seven_len != 0: seven_len = (seven_len * 10 + 7) % K ans += 1 print(ans) if __name__ == ""__main__"": main()" p02596,s574453896,Wrong Answer," k = int(input()) x = ""7"" n = 10 c = 1 f = 1 if k >=7: while n>0: if int(x) % k == 0 : f = 0 break c+=1 x += ""7"" n-=1 if f == 0: print(c) else: print(""-1"")" p02596,s377518804,Wrong Answer,"k = int(input()) if k % 2 == 0: print(-1) elif k ==7: print(1) else: amari = [7] tmp = 7 for i in range(k): tmp = (tmp * 10) % k if tmp != 7: amari.append(tmp%k) else: break amari = amari * ((k//len(amari)) +1) ans = amari[0] for i in range(1, k+1): ans += amari[i] if ans % k == 0: print(i+1) break else: print(-1)" p02596,s901565963,Wrong Answer,"#!/usr/bin/env python3 import time k = int(input()) s = '' rs = [] start = time.time() cnt = 0 while True: cnt += 1 s += '7' n = int(s) r = n%k if r==0: print(cnt) exit() if r in rs: print(-1) end = time.time() exit() rs.append(r) end = time.time() t = end-start if t >= 1.8: print(k-1) exit() " p02596,s127050708,Wrong Answer,"K = int(input()) ans = -1 num7 = 7; for i in range(1000): if (num7 % K) == 0: ans = i+1 break else: num7 = num7*10+7 i+=1 print(ans)" p02596,s877882412,Wrong Answer,"k=int(input()) keta=str(k) s=int(""7""*len(keta)) a=-1 if k%2==0: print(a) else: for x in range(len(keta),len(keta)+1000): print(s) if s%k==0: a=x break else: s=str(s)+""7"" s=int(s) if a==-1: a=k-1 print(a)" p02596,s061421312,Wrong Answer,"k = int(input()) if 7 % k == 0: print(1) exit() memo = {} mod = 1 cnt = 2 mm = 10 % k m = 1 while True: m = (m * mm)%k mod += m if mod % k == 0: print(cnt) break if mod in memo: print(-1) break memo[mod] = 0 cnt += 1 " p02596,s093670973,Wrong Answer,"k = int(input()) if k%2==0 or k%5==0: print(-1) exit() def so(n): for i in range(2,n): if n%i==0: return False else: return True t = 10**4 if k%7==0: k//= 7 l = len(str(k)) s = int(str(1)*l) ind = l while t!=0 : if s%k==0: print(ind) exit() else: s = s*10+1 ind += 1 t -=1 if so(k)==True: print(k-1) exit()" p02596,s047106932,Wrong Answer,"k=int(input()) c=0 x=7 s=-1 for c in range(k): if k==7: print(1) break x=x*10+7 if x%k==0: s=c+1 break print(s)" p02596,s565123683,Wrong Answer,"import sys import math import time sys.setrecursionlimit(int(1e6)) if False: dprint = print else: def dprint(*args): pass k = list(map(int, input().split()))[0] if (k % 7 == 0): l = 9*k/7 else: l = 9*k dprint('k, l = ', k, l) i = 1 n = 10 while(i < k): m = n % l if (m == 1): # (10^i mod L = 1) print(i) exit() dprint('i, n, m = ', i, n, m) i = i + 1 n = m * 10 else: print(-1) " p02596,s487588796,Wrong Answer,"n =int(input()) if n%2==0: print(-1) elif n==1: print(1) else: ans =1 start = 7 while True: start = ((start%n*10%n)+7)%n #start = start%n #print(start) if start ==0: ans+=1 print(ans) break ans+=1" p02596,s996039785,Wrong Answer,"K = int(input()) mod = 7 for i in range(1, K): if mod%K==0: print(i) exit() mod = (mod*10+7) % K i += 1" p02596,s387727122,Wrong Answer,"k = int(input()) n = '7' cnt = 1 if k % 2 == 0: print(-1) else: while True: num = int(n) if num%k == 0: print(cnt) break elif cnt == 1000: print(k-1) break else: cnt += 1 n += '7'" p02596,s462890247,Wrong Answer,"K = int(input()) keta = 1 # 数列の桁数 seven = 7 # 数列の項 ans = -1 # 答え if K % 2 == 0: print(ans) else: while True: if K <= seven: if seven % K == 0: ans = keta break seven += 7 * (10 ** keta) keta += 1 print(ans) " p02596,s246388687,Wrong Answer,"k=int(input()) a=7%k sm=7 for i in range(k): if sm%k==0: print(i+1) break a=(10*a)%k sm+=a" p02596,s906999399,Wrong Answer,"k = int(input()) x = 7 ans = 1 if k%2 == 0 or k%5 ==0: ans = -2 else: while x%k != 0: x *= 10 x+=7 if x%k != 0: ans +=1 ans +=1 print(ans) " p02596,s786236510,Wrong Answer,"k = int(input()) sev = [] c = 0 if k == 1: print(-1) elif k == 2: print(-1) elif k % 5 == 0: print(-1) elif k % 2 == 0: print(-1) else: while 1: sev.append('7') sevens = int(''.join(sev)) rem = sevens % k if rem == 0: res = c + 1 print(res) break c += 1 " p02596,s947414313,Wrong Answer,"import sys k = int(input()) n = 0 frag = 0 sevens = """" while frag==0: sevens = sevens + ""7"" n+=1 if int(sevens)%k==0: frag=1 elif n>10000: print(""-1"") exit() print(n)" p02596,s427582953,Wrong Answer,"import sys import itertools sys.setrecursionlimit(1000000000) from heapq import heapify,heappop,heappush,heappushpop import math import collections import copy import bisect INF = 10**9+7 if __name__ == ""__main__"": k = int(input()) if k%2 == 0: print(-1) sys.exit() a = 7 p = len(str(k)) + 1 for i in range(p+100): if a%k == 0: print(i+1) sys.exit() a*=10 a+=7 print(k-1)" p02596,s895180466,Wrong Answer,"K = int(input()) seven = ""7"" flag = 1 if K%2==0: print(-1) else: for i in range(1,10000): if int(seven*i) % K == 0: print(i) flag=0 break if flag: print(-1)" p02596,s559392419,Wrong Answer,"K=input() keta = len(K) k=int(K) if k%2==0: print(-1) else: seven = ""7""*keta s = int(seven) ans=keta-1 for _ in range(k): ans+=1 s = s%k if s==0: print(ans) break else: s = s*10+7" p02596,s949208750,Wrong Answer,"k, R = int(input()), 1 for i in range(1, k+10): if R % k == 0: print(i) R = R * 10 + 7" p02596,s236824772,Wrong Answer,"k = int(input()) if k % 2 == 0: print(-1) amari = [7] tmp = 7 for i in range(k+1): tmp = (tmp * 10) % k if tmp != 7: amari.append(tmp%k) else: break amari = amari * ((k//len(amari)) +1) ans = amari[0] for i in range(1, k+1): ans += amari[i] if ans % k == 0: print(i+1) break else: print(-1)" p02596,s287981982,Wrong Answer,"import sys K=int(input()) rest = 7 % K if rest == 0: print(1) sys.exit() for i in range(2,K): rest = (rest*10+7) % K if rest == 0: print(i) sys.exit() else: print(-1)" p02596,s929987196,Wrong Answer,"import sys K=int(input()) if K%2==0 or K%5==0: print('-1') sys.exit() i=1 K=9*K ans=10-K while(1): i+=1 ans=ans*10%K if 7*(ans-1)%K==0: print(i) sys.exit() " p02596,s203180428,Wrong Answer,"K = int(input()) cnt=0 divK = 7 if K %2 ==0: print(-1) exit() while True: if divK== 0: print(cnt+1) break divK = (divK*10+7)%K cnt +=1" p02596,s833183663,Wrong Answer,"def main(): K = int(input()) tmp1 = 7 % K tmp2 = tmp1 for i in range(1, K): if tmp2 == 0: print(i) exit() else: tmp1 = tmp1 * 10 % K tmp2 += tmp1 tmp2 %= K print(-1) if __name__ == ""__main__"": main() " p02596,s367696387,Wrong Answer,"k = int(input()) mod = 7 % k ans = 1 for i in range(10**6): if k % 2 == 0: ans = -1 break if mod == 0: break mod = (mod*10+7)%k ans += 1 print(ans)" p02596,s611318488,Wrong Answer,"k = int(input()) ans = [] memo = 7 % k if(7 % k == 0): ans.append(0) for i in range(k): memo = (10*memo + 7) % k if memo % k == 0: ans.append(i) print(-1 if not len(ans) else ans[0] + 2) " p02596,s689208341,Wrong Answer,"s=0 l=[] k=int(input()) if k%2==0: print(-1) else: while(1): s=s*10+7 l.append(s) if s%k==0: print(l.index(s)) break " p02596,s645569397,Wrong Answer,"k = int(input()) count = 0 ans = 1 while True: num = int(""7"" + ""7"" * count) if ans > 6: print(-1) break if num % k == 0: print(ans) break count += 1 ans += 1" p02596,s266954702,Wrong Answer,"K = int(input()) if 7%K==0: print(""1"") exit(0) if 77%K==0: print(""2"") exit(0) if 777%K==0: print(""3"") exit(0) if 7777%K==0: print(""4"") exit(0) if 77777%K==0: print(""5"") exit(0) if 777777%K==0: print(""6"") exit(0) if 7777777%K==0: print(""7"") exit(0) print(""-1"")" p02596,s848605663,Wrong Answer,"num=int(input()) a=7 flag=0 for i in range(num): a=(a*10+7) if a%num==0: print(i) flag=1 break if flag==0: print(""-1"")" p02596,s223722296,Wrong Answer,"K=int(input()) for i in range(1,100000): if list(set(str(K*i)))==[""7""]: print(len(str(K*i))) break elif i==9999: print(""-1"")" p02596,s191534943,Wrong Answer,print(int(input()) - 1) p02596,s324067528,Wrong Answer,"K = int(input()) list = [7,77,777,7777,77777,777777] for i in range(7): if i == 6: print(-1) elif list[i] % K == 0: print(i+1) break" p02596,s827234876,Wrong Answer,"k=int(input()) x=7%k l=[] for i in range(1,k+1): num=(x*10+7)%k x=num l.append(num) if num==0: print(i) break if 0 not in l: print(-1)" p02596,s361646549,Wrong Answer,"K = int(input()) n = 7 i = 1 while i <= K: if n%K == 0: ans = i break n = n*10 + 7 i += 1 else: print(-1)" p02596,s871290126,Wrong Answer,"import math def main(): k = int(input()) if k % 2 == 0: print('-1') else: for i in range(1, int(math.sqrt(k))): target = int('1' * i) * 7 if target % k == 0: print(i) break else: print(k - 1) if __name__ == '__main__': main()" p02596,s622348047,Wrong Answer,"k=int(input()) a=[str(7)*x for x in range(1,100)] b = [int(i) for i in a] r=[] for x in b: if x%k==0: r.append(len(str(x))) else: r.append(-1) print(r[0])" p02596,s007171935,Wrong Answer,"k = int(input()) if k==7: print(1) elif k%2==0: print(-1) else: cnt = 1 pre = 7 while(True): surp = (pre*10+7)%k cnt += 1 if surp==0: break pre = surp print(cnt)" p02596,s151694626,Wrong Answer,"def main(): k = int(input()) num = 1 n = 7 if (k % 2) == 0: print(-1) return for i in range(100000): if (n % k == 0): print(num) return else: n = (n*10 + 7) %k num += 1 print(-1) if __name__ == '__main__': main() " p02596,s422469557,Wrong Answer,"K = int(input()) S = ""7"" # i = int(S) // K a = 0 c = 1 if K % 2 == 0: print(-1) exit() a = 7 % K for i in range(K): if a == 0: break a = (a * 10 + 7) % K c += 1 print(c) # while int(S) % K != 0: # if K % 2 == 0: # i = -1 # break # S += ""7"" # i += 1 # print(i)" p02596,s840914752,Wrong Answer,"import math K = int(input()) S = [int('7' * i) for i in range(1, 8)] start = math.floor(math.log(K, 10)) count = [a for a in S[start:] if a % K == 0] if len(count) == 0: print(-1) else: print(len(str(count[0])))" p02596,s370897663,Wrong Answer,"K = int(input()) l = [0 for i in range(K)] r = 0 for i in range(K): if i == 0: if 7%K == 0: print(1) break else: r = 7%K l[r] = 1 else: r = (10*r+7)%K if r == 0: print(i+1) break elif l[r] != 0: print(-1) break" p02596,s861632999,Wrong Answer,"k = int(input()) if k % 2 == 0: print(-1) elif k < 7: print(-1) else: a = 0 count = 1 num = ""7"" while a == 0: if int(num) % k == 0: print(count) a += 1 else: num += ""7"" count += 1" p02596,s526370346,Wrong Answer,"K = int(input()) num = K +1 i = 1 while i <= K: num = (10**i-1)*7//9 if num % K == 0: break i += 1 if i > K : print(-1) else: print(num)" p02596,s627558238,Wrong Answer,"# C - Repsept def main(): k = input() if int(k) % 2 == 0: print(-1) else: for i in range(len(k), int(int(k)**0.5)): li7 = '7'*i if int(li7) % int(k) == 0: print(i) exit() else: print(int(k)-1) if __name__ == ""__main__"": main()" p02596,s810606376,Wrong Answer,"import sys input = sys.stdin.readline K = int(input()) i = 0 n = 0 while n <= 10**7: n += 7 * (10**i) i += 1 if n % K == 0: print(i) break elif K % 2 == 0: print(""-1"") break elif K == 999983: print(""999982"") break else: pass" p02596,s140184174,Wrong Answer,"k = int(input()) if k % 2 == 0 or k % 5 == 0: print(-1) exit() num = 7 for i in range(10**6): if num % k == 0: print(i) break num = (num % k) * 10 + 7 " p02596,s613042619,Wrong Answer,"n = int(input().rstrip()) def calc(target): result = 0 count = 0 if target % 2 == 0: return -1 for i in range(n): result = (result * 10 + 7) % target count += 1 if result == 0: break return count print(calc(n))" p02596,s998642250,Wrong Answer,"k=int(input()) ama=[0]*(k) now=0 for i in range(1,3*k): now=7*(10**i-1)//9 tem=now%k print(tem) if ama[tem]==0 and tem!=0: ama[tem]+=1 elif ama[tem]!=0: print(-1) exit() elif tem==0: print(i) exit() " p02596,s971695493,Wrong Answer,"K=int(input()) if K==7: print(1) else: val=7 for i in range(2,K+1): val=(val*10+7)%K if val==0: exit(print(i)) print(-1) " p02596,s741192072,Wrong Answer,"k=int(input()) a = 0 flag = False for i in range(10000): a = 10 * a + 7 if a % k == 0: flag = True break if flag: print(i+1) else: print(-1)" p02596,s283614071,Wrong Answer,"test = int(input()) seven = ""7"" while True: if test % 2 == 0: print(-1) break if int(seven) >= test: if int(seven) % test == 0: print(len(seven)) break else: if test % int(seven) == 0: print(len(seven)) break seven += ""7"" " p02596,s189273669,Wrong Answer,"def main(): k = int(input()) kint = 7 % k before = 7 % k if k == 1: print(1) exit() for i in range(k): x = (before * 10) % k before = x kint += x kint = kint % k if kint % k == 0: print(i + 2) exit() print(-1) if __name__ == '__main__': main()" p02596,s539806001,Wrong Answer,"k = int(input()) ans = 0 if 7 % k == 0: ans = 1 ai = 7 for i in range(2, k+2): ai = ((ai * 10) + 7) % k if ai == 0: ans = i print(ans) exit() if i == k: ans = -1 print(ans) " p02596,s897492057,Wrong Answer,"k = int(input()) #val = 0 for i in range(k, 0, -1): val = int(""7"" * i) #print(val) if val % k == 0: print(i) break else: print(-1) " p02596,s431825150,Wrong Answer,"n = int(input()) ctr = 1 if n % 2 == 0: print(-1) else: val = 7 while (val % n != 0): val = val*10+7 ctr += 1 print(ctr) " p02596,s612801781,Wrong Answer,"k=int(input()) n=7 if k%2==0: print(-1) for i in range(1,k+1): if n%k==0: print(i) break else: n=(10*(n%k)+7)%k" p02596,s561971886,Wrong Answer,"import sys k = int(input()) a = [0]*k a[0] = 7 cnt = 0 for i in range(1, k): a[i] = (10*a[i-1]+7) % k if k % 2 == 0 : print(-1) sys.exit() for i in range(k): if a[i] == 0: print(i+1) break" p02596,s233162284,Wrong Answer,"k = int(input()) if(k&2==0): print(-1) else: i = 1 while True: m = 7 if(m%k==0): ans = i print(ans) break m = m*10 + 7 i += 1 " p02596,s027838905,Wrong Answer,"k = int(input()) flag = [0 for _ in range(k)] val = 7 cnt = 1 while cnt != 10000000: cnt += 1 val = ((10 * val) % k + 7) % k if val == 0: break if cnt == 10000000: print(-1) else: print(cnt)" p02596,s467699608,Wrong Answer,"k=int(input()) sevens=""7"" if k%2==0: print(-1) else: for i in range(10000): if int(sevens)%k==0: print(i+1) exit() else: sevens+=""7"" else: if k<=i: print(-1) else: print(k-1) " p02596,s152243576,Wrong Answer,print(-1) p02596,s475308442,Wrong Answer,"k = int(input()) n = '7' cnt = 1 if k % 2 == 0: print(-1) else: while cnt <= 50: num = int(n) if num%k == 0: print(cnt) break elif cnt == 50: print(k-1) break else: cnt += 1 n += '7'" p02596,s927436668,Wrong Answer,"import sys k = int(input()) if k == 7: print(1) sys.exit() remainders = set() remainder = 7 % k remainders.add(remainder) counter = 1 while True: counter += 1 remainder = remainder * 10 % k if remainder in remainders: print('-1') sys.exit() remainders.add(remainder) if sum(remainders) % k == 0: print(counter) sys.exit()" p02596,s788787748,Wrong Answer,"t = int(input()) c = 1 N = 7 f=0 def isPrime(n): if (n <= 1): return False for i in range(2, n): if (n % i == 0): return False return True if isPrime(t): print (-1) else: while(N%t !=0): c +=1 N = N*10 + 7 if(len(str(N))>100): print(-1) f=1 break if(f!=1): print(c)" p02596,s766902672,Wrong Answer,"N = int(input()) n7 = 0 for i in range(6): n7 += 7*(10**(i)) print(n7) if n7 % N == 0: print(i+1) break if i == 5: print(-1) break " p02596,s751226166,Wrong Answer,"import numpy as np k = np.int64(int(input())) Moji = '' if k % 2 ==0: print(-1) elif str(k)[0] == 5: print(-1) elif k < np.sqrt(7777777777.0): for i in range(50): Moji += '7' if np.int64(int(Moji))%k == 0: print(i+1) break else: print(k-1)" p02596,s689288365,Wrong Answer,"K=int(input()) count=0 result = -1 for i in range(K): count =(10*count+7)%K#余りからいく if count%K==0: result = i+1 print(result)" p02596,s987789997,Wrong Answer,"K=int(input()) k=list(str(K)) dic={""1"":""7"",""3"":""9"",""7"":""1"",""9"":""3""} if k[-1] not in dic: print(-1) exit() a=7 for i in range(1,K): if a%K==0: print(i) exit() a+=7*10**i" p02596,s516882798,Wrong Answer,"k = int(input()) a = 0 for i in range(10**6): a += 7*(10**i) if a%k == 0: print(i) exit() print(-1)" p02596,s686619007,Wrong Answer,"K = int(input()) n = ""7""*(len(str(K))+1) m = ""7""*len(str(K)) p = int(n) ans = 0 flag = 0 if(K%2==0): print(""-1"") else: while(ans <= K): ans += 1 q = p % K p = str(q) + ""7"" p = int(p) if(q==0): print(ans+len(str(K))) flag = 1 break if(flag==0): print(""-1"")" p02596,s525648746,Wrong Answer,"k = int(input()) if k % 2 == 0 or k % 5 == 0: print(-1) exit() num = 7 for i in range(1, k): if num % k == 0: print(i) break num = (num % k) * 10 + 7 " p02596,s618734949,Wrong Answer,"import math k=int(input()) if(k%2)==0: print(""-1"") else: for x in range(1,1000001): if pow(10,x,k*9)==1: print(x) break " p02596,s364853327,Wrong Answer,"q = int(input()) a = 0 f = 0 for i in range(10**6): a += 10**i * 7 if a % q == 0 and a > q : f = 1 break a = str(a) if f == 0: print(-1) if f == 1: print(len(a))" p02596,s830297691,Wrong Answer,"K = int(input()) ans = '-1' mod = 7%K path = [mod] for i in range(1, K): if mod == 0: ans = i break mod = (mod*10 + 7)%K path.append(mod) if mod == path[0]: ans = '-1' break print(ans)" p02596,s374363958,Wrong Answer,"n = int(input()) p = 7 q = 0 if n%2==0 or n%5 ==0: print(-1) if n==7 : print(1) if n!=7 and n%2 != 0 and n%5 != 0: while p%n != 0: p = p + 7*(10**q) q = q+1 print(q)" p02596,s823367455,Wrong Answer,"k=int(input()) def p(n): a=[] for i in range(2,1+int(n**.5)): while n%i==0: n//=i a+=[i] if n!=1: a+=[n] return a if len(p(k))>1:print(-1) elif k==2 or k==5:print(-1) elif k==3:print(3) else:print(p(k-1)[0])" p02596,s966697697,Wrong Answer,"#C # 7,77,777・・・=7*(1,11,111・・・) # 7*(10^i)=7*(10^i-1)/10-1 = 7*(10^i-1)/9 がkで割れる # 10^iを(9k,7の倍数だったら9k/7)で割ってあまりが1だったら良い import sys k=int(input()) if k%7==0: k//=7 k*=9 a=10%k for i in range(9): a=a%k if a==1: print(i+1) sys.exit() a*=10 print(-1) " p02596,s885439097,Wrong Answer,"def func(val): if val%2==0 or val%5==9: return 0 rem = 1 p = 1 k = 1 while rem%val!=0: k+=1 p = (p*10)%val rem = (rem+p)%val return k n = int(input()) a = func(n) b = 10**18 if n%7==0: b = func(n//7) if a==0 and b!=10**18: print(-1) else: print(min(a,b))" p02596,s770256332,Wrong Answer,"b=7 d=0 e =-1 i=1 a = int(input()) while True: d = 7 + 10*d print(d) if a % 2 == 0: print(e) break elif d % a ==0: print(i) break i +=1" p02596,s275647090,Wrong Answer,"n = int(input()) if n % 2 == 0 or n % 5 == 0: print(-1) else: k = n - 1 while k % 5 == 0: k = k // 5 print(k) " p02596,s810931701,Wrong Answer,"K = int(input()) i = 1 j = 7 while(i<7): if K % j == 0: print(j) break else: j = j + 7*(10**i) i = i +1 if i == 7: print(-1) " p02596,s399621954,Wrong Answer,"k = int(input()) cnt = 0 if k % 2 == 0: print(-1) elif k % 5 == 0: print(-1) else: val = 0 keta = 7 flag = False while True: if cnt == 0: keta = 7 else: keta = (keta * 10) % k val = (val + keta) % k if val % k == 0: break elif (cnt + 1) > k//2: flag = True print( k-1 ) break else: cnt += 1 if flag: pass else: print(cnt + 1) " p02596,s451324932,Wrong Answer,"import sys k=int(input()) n=7 if k%2==0: print(-1) for i in range(1,k+1): if n%k==0: print(i) sys.exit() else: n=(10*(n%k)+7)%k print(-1)" p02596,s279006261,Wrong Answer,"k = int(input()) t = [7, 77, 777, 7777, 77777, 777777] ans = 0 for i in range(len(t)): if t[i] % k == 0: ans = i+1 break if ans == 0 and k % 2 == 0: print(-1) elif ans == 0 and k % 2 != 0: print(k - 1) else: print(ans)" p02596,s411033963,Wrong Answer,"def ii():return int(input()) def iim():return map(int,input().split()) def iil():return list(map(int,input().split())) k = ii() if k%2 == 0 or k%5 == 0: print(-1) else: if k%7 == 0: k //= 7 elif k%3 == 0: k *= 9 if k==1: print(1) exit() num = 10 cnt = 1 while num != 1: num *= 10 num %= k cnt += 1 print(cnt) " p02596,s131770335,Wrong Answer,"n=int(input()) l=[7,77,777,7777,77777,7777777,77777777,777777777,7777777777,77777777777,777777777777,7777777777777,77777777777777,777777777777777,7777777777777777] res=0 for i in range(len(l)): if l[i]%n==0: res=i break if n==999983: print(999982) elif res>0: print(res+1) else: print(-1)" p02596,s981576777,Wrong Answer,"def main(): K = int(input()) if K%2 == 0 or K%5==0: return -1 for i in range(1, 10000000): x = pow(10, i, K) if x == 1: return i else: return -1 if __name__ == ""__main__"": ans = main() print(ans)" p02596,s619325701,Wrong Answer,"K = input() N = 10 x = 7 for i in range(1, N): if x % int(K) == 0: print(i) break elif N-1 == i: print('-1') x += 7 * 10 **i " p02596,s830932168,Wrong Answer,"K=int(input()) m=7 count=1 flag=0 for i in range(K): if m%K==0: flag=1 break else: m*=10 m+=7 m%=K count+=1 if flag: print(""-1"") else: print(count)" p02596,s200293650,Wrong Answer,"k = int(input()) if k % 2 == 0 or k % 5 == 0: print(-1) exit() if k % 7 == 0: k // 7 k *= 9 i = 10 % k cnt = 1 while i != 1: i = i * 10 % k cnt += 1 print(cnt) " p02596,s529010653,Wrong Answer,"K = int(input()) x = 7 count = 0 if K % 2 ==0: print(""-1"") exit(0) for i in range(10**5): if x % K == 0: print(count) exit(0) else: x = 10*x + 7 count += 1" p02596,s546236095,Wrong Answer,"k=int(input()) s={7} a=7 n=1 flag=True while not {0}<=s: a=(a*10+7)%k beforelen=len(s) s.add(a) if len(s)==beforelen: flag=False break n+=1 print(n if flag else -1)" p02596,s388277751,Wrong Answer,"cnt = 1 mod = 7 k = int(input()) for i in range(k): if mod % k == 0: break cnt += 1 mod = (mod * 10 * 7) % k if mod % k == 0: print(cnt) else: print(-1) " p02596,s995939728,Wrong Answer,"k = int(input()) count = 0 ans = 1 while True: num = int(""7"" + ""7"" * count) if ans >= 6: print(-1) break if num % k == 0: print(ans) break count += 1 ans += 1" p02596,s639015307,Wrong Answer,"k = int(input()) m = 7%k ans = 1 jud = True p = 70%k for i in range(k): m = (m + p)%k ans += 1 if m == 0: break p = p*10%k if p == 0: jud = False break if jud: print(ans) else: print(-1) " p02596,s736027594,Wrong Answer,"k=int(input()) ans=1 judge=0 remainder=7%k while ans<=k: if remainder==0: judge=1 break else: remainder=remainder*10+7 ans+=1 if judge==1: print(ans) else: print(-1)" p02596,s362232944,Wrong Answer,"k = int(input()) temp = 0 M = 10**5 for i in range(2*10**6): temp *= 10 temp += 1 temp %= k if temp == 0: print(i+1) exit() else: print(-1) " p02596,s239910537,Wrong Answer,"lst=['7'*k for k in range(1, 11)] k=int(input()) i=0 ok=False for _ in lst: p=int(lst[i]) if p%k==0: ok=True print(i+1) break i+=1 if ok==False: print(-1)" p02596,s289654640,Wrong Answer,"import sys import math def lcm(x, y): return (x * y) // math.gcd(x, y) def ans(n): if n==1: return 1 if n%2==0 or n%5==0: return -1 if n%7==0: return ans(n//7) elif N%9==0: return lcm(ans3(n),9) elif N%3==0: return lcm(ans3(n),3) else: return ans3(n) def ans3(n): r=1 for i in range(n): L.append(r) r=(r*10)%n return len(set(L)) L=list() N=int(input()) print(ans(N))" p02596,s082908412,Wrong Answer,"K = int(input()) if K%2==0 or K%5==0: print(-1) exit() for i in range(1,K**2): if 7*(pow(10,i,K)-1)/9%K==0: print(i) exit() print(-1) " p02596,s935549887,Wrong Answer,"k=int(input()) # mod k で考える mod=k for i in range(1,k+2): if mod>7*int(str(1)*i): continue else: mod = 7 * int(str(1) * i) % mod if mod == 0: print(i) exit() print(-1)" p02596,s227749933,Wrong Answer,"K = int(input()) tmpNum = 7 count = 1 keisuu = 10 tmp = tmpNum%K aa = tmp while tmp !=0 and count<=K: aa = (aa*10)%K tmp = (tmp+aa)%K count+=1 if count==K: count=-1 print(count)" p02596,s189126784,Wrong Answer,"K = int(input()) S = ""7"" # i = int(S) // K a = 0 c = 1 if K % 2 == 0: print(-1) exit() a = 7 % K for i in range(K): a = (a * 10 + 7) % K if a == 0: c += 1 break c += 1 print(c) # while int(S) % K != 0: # if K % 2 == 0: # i = -1 # break # S += ""7"" # i += 1 # print(i)" p02596,s194094608,Wrong Answer,"k = int(input()) if k % 2 == 0 or k % 5 == 0: print(-1) exit() seven = 7 for i in range(1, k): #rangeの上限がk if seven % k == 0: print(i) break seven = (seven * 10 + 7) % k # %kが難しい else: # for文にもelseが使える print(-1)" p02596,s318084089,Wrong Answer,"k = int(input()) if k % 2 == 0: print(-1) exit() tmp = 7 for i in range(1, k): tmp = (10 * tmp) % k if tmp == 63: print(i) break" p02596,s271836255,Wrong Answer,"k = int(input()) if k == 1 or k == 7: print(1) count = 1 tmp = 7 s = [0 for i in range(k+8)] while True: if s[tmp] != 0: print(-1) exit() s[tmp]+=1 tmp*=10 tmp+=7 tmp %= k count+=1 if tmp == 0: print(count) exit()" p02596,s932756792,Wrong Answer,"K = int(input()) if K%2==0: print(-1) else: t=True n=1 a=1 if 7==K: print(1) while t: #print(a) if (7*(10**n-1))%(9*K)==0: print(n) t=False n+=1 " p02596,s324062020,Wrong Answer,"k = int(input()) n = '7' cnt = 1 if k % 2 == 0: print(-1) else: while cnt <= 50: num = int(n) if num%k == 0: print(cnt) break elif cnt == 50: print(k-1) break else: print(num%k) cnt += 1 n += '7'" p02596,s787635866,Wrong Answer,"K=int(input()) count=0 result = -1 for i in range(K): count =(10*count+7)%K#余りからいく if count==0: result = i+1 print(result)" p02596,s623150357,Wrong Answer,"n = int(input()) count = 1 s=""7"" found = False if n == 7: print(1) exit() while(int(s) % n*count != 0 and not found): s = ""7""*count count += 1 if int(s) >= 10e6: print(-1) found = True if not found: print(count-1)" p02596,s537499129,Wrong Answer,"import sys import math import time sys.setrecursionlimit(int(1e6)) if False: dprint = print else: def dprint(*args): pass k = list(map(int, input().split()))[0] modk = 7 % k i = 1 while(i < k): if modk == 0: print(i) exit() i += 1 modk = (modk * 10 + 7) % k else: print(-1) " p02596,s983745281,Wrong Answer,"k = int(input()) if k%2 == 0: print(-1) exit() r = 7%k for i in range(10**6): if r == 0: print(i+1) exit() r = (10*r+7)%k" p02596,s975632735,Wrong Answer,"k = int(input()) if k % 2 == 0: print(-1) exit(0) flag = [0 for _ in range(k)] val = 7 cnt = 1 while cnt != 1000000: cnt += 1 val = ((10 * val) % k + 7) % k if val == 0: break print(cnt)" p02596,s078852573,Wrong Answer,"k=int(input()) num=k%7 for i in range(1, 10**7+1): if num%k==0: print(i) exit() else: num=(num*10+7)%k print(-1) " p02596,s215251523,Wrong Answer,"k = int(input()) n = '7' cnt = 1 if k % 2 == 0: print(-1) else: while cnt <= 50: num = int(n) if num%k == 0: print(cnt) break else: print(num%k) cnt += 1 n += '7'" p02596,s308426050,Wrong Answer,"k = int(input()) if k % 2 == 0: print(-1) exit() ten = 1 now = 0 for i in range(10**7): x = (ten*7)%k now = (now+x)%k if now == 0: print(i+1) exit() ten = ten*10%k" p02596,s022559151,Wrong Answer,"k = int(input()) if k % 2 == 0: print(-1) exit() if k == 7: print(1) tmp = 1 for i in range(1, k): tmp = (10 * tmp) % k if tmp == 1: print(i) break" p02596,s229361563,Wrong Answer,"n =int(input()) if n%2==0: print(-1) elif n==1: print(1) else: ans =1 start = 7 while True: start = ((start%n*10%n)+7)%n #start = start%n #print(start) if start ==0: ans+=1 print(ans) break if ans>=1000000: print(-1) break ans+=1" p02596,s492135918,Wrong Answer,"K = int(input()) n = 7 a = 1 if K ==1: print(1) elif K%2 == 0: print(-1) elif K%5 == 0: print(-1) else: while n % K != 0: n = 10*n + 7 a = a + 1 if n % K == 0: print(a) break " p02596,s324640215,Wrong Answer,"k = int(input()) i = 0 s = 0 if k % 2 == 0: print('-1') exit() for z in range(k): i += 1 s = (7 + 10*s) % k if s != 0: s = s % k else: break print(i) " p02596,s702851971,Wrong Answer,"def main(): K = int(input()) cnt = 1 now_mod10 = 1 mod10 = 1 while cnt < K: md = 7 * now_mod10 if md % K == 0: return cnt mod10 = (mod10 * 10) % K now_mod10 = (now_mod10 + mod10) % K cnt += 1 return -1 if __name__ == '__main__': print(main())" p02596,s569266538,Wrong Answer,"def resolve(): K = int(input()) m = 7 % K if m == 0: print(1) return ans = -1 for i in range(2, K): m = (m * 10 + 7) % K if m == 0: ans = i break print(ans) if __name__ == ""__main__"": resolve()" p02596,s541221163,Wrong Answer,"K = int(input()) if K % 2 == 0: print(-1) else: x = 0 for i in range(K + 1): x = (x * 10 + 7) % K if x % K == 0: print(i + 1) break" p02596,s427688393,Wrong Answer,"import sys input = sys.stdin.readline k = int(input()) if k%2 == 0: print(-1) exit() if k == 7: print(1) exit() seven = 7 d = 1 while seven != 0: seven += pow(7*pow(10,d,k),1,k) seven = pow(seven,1,k) d += 1 print(d) " p02596,s472133428,Wrong Answer,"K = int(input()) if K % 2 == 0: print(-1) else: v = 7 for i in range(1, 1000000): if v % K == 0: print(i) break v = (v * 10 + 7) % K " p02596,s378444296,Wrong Answer,"param_k = int(input()) #param_k = 999983 if param_k % 2 == 0: print(-1) elif param_k % 5 == 0: print(-1) else: n=0 for i in range(1000000): n = 10*n + 7 print(n) if n % param_k == 0: print(i+1) break if i == param_k + 10 - 1: print(-1)" p02596,s505143247,Wrong Answer,"k = int(input()) s = 7 c = 1 while True: if s == 0: break s = (10 * s + 7) % k c += 1 print(c)" p02596,s518152635,Wrong Answer,"k = int(input()) a=0 for i in range(1, 50): a = int(a*10 + 7) if a % k ==0: print(i) exit() print(-1)" p02596,s798788031,Wrong Answer,"K = int(input()) ans = 7%K A = 1 C = [0]*K if K == 1 or K == 7: print(1) exit() for i in range(K): A = (A*10)%K ans += (A*7) ans %= K if ans == 0: break if C[ans] == 0: C[ans] += 1 else: break if i == K: print(-1) else: print(i+2)" p02596,s094183687,Wrong Answer,"k = int(input()) number = 1 Seq = 7 while True: if Seq > 10**6: print(-1) break elif Seq % k == 0: print(number) break else: Seq = Seq + 7 * (10 ** number) number += 1 " p02596,s501348857,Wrong Answer," k = int(input()) ans = 1 t = '7' exist = False if k == 1 : exist = True if k % 3 == 0 or k % 7 == 0 or k % 11 == 0 or k % 13 == 0 or k % 37 == 0 or k % 41 == 0 or k % 101 == 0 or k % 239 == 0 or k % 4649 == 0: while int(t) <= 10**6: # print(t) if int(t) % k == 0 : exist = True break t = t + '7' ans += 1 if exist == True : print(ans) else : print(-1)" p02596,s749624571,Wrong Answer,"K = int(input()) if K%2==0: print(-1) elif K==7: print(1) else: if K%7==0: K = K//7 a = 1 cnt = 1 ind = -1 for i in range(K): a = (a*10)%K cnt += a if cnt%K==0: ind = i break if ind<0: print(-1) else: print(ind+2)" p02596,s435772109,Wrong Answer,"K=int(input()) base=7%K for i in range(K+1): if base%K==0: print(i) exit() else: base=(base*10+7)%K print(-1) " p02596,s871366498,Wrong Answer,"K=int(input()) n = 0 seven=7 while n<=K: seven += ((7*10)*n) if seven%K==0: print(n) break if n ==K: if seven%K==0: print(n) else: print(-1) n +=1" p02596,s669023984,Wrong Answer,"K=input() kl=len(K) K=int(K) a=7 for i in range(kl-1): a=str(a) a=a+'7' a=int(a) if K%2==0: print('-1') else: while a%K!=0: a=str(a) a=a+'7' a=int(a) a=str(a) print(a) print(len(a))" p02596,s927469791,Wrong Answer," K=int(input()) a_i=7%K i=1 while True: i+=1 a_i=(10*a_i+7)%K if a_i==0: print(i) exit() if i>K: exit(print(-1)) """""" if K % 2 == 0 or K % 5 == 0: print(-1) exit() i=1 while True: if 7*int(""1""*i)%K==0: exit(print(i)) i+=1 if i>1e+15: exit(print(-1)) """""" " p02596,s654563897,Wrong Answer,"n = int(input()) ans = 1 if n % 5 == 0 or n % 2 == 0: print(-1) else: t = 7 while t % n != 0: t = t * 10 + 7 t %= n ans += 1 print(ans)" p02596,s290308946,Wrong Answer,"import sys n = int(input()) if n < 7: print(-1) sys.exit() res = 0 seven = 7 s = 10 **8 for _ in range(s): if seven % n == 0: print(res + 1) sys.exit() else: res += 1 seven = int(str(seven) + '7') print(-1)" p02596,s158330897,Wrong Answer,"k = int(input()) i = 1 a = 7 remainder = a % k while a != 0: i += 1 a = (10*a + 7) % k if i == 10**9+7: i = -1 break print(i) " p02596,s065042583,Wrong Answer,"num = int(input()) count = 0 while count < 1000: count += 1 int7 = int(""7"" * count) if int7 % num == 0: print(count) exit() print(-1) " p02596,s312299300,Wrong Answer,"L = int(input()) for K in range(1, L + 1, 2): ans = -1 a = 0 if K % 2 == 0: ans = -1 elif K % 5 == 0: ans = -1 else: for i in range(0, K): a = (10 * a + 7) % K if a == 0: ans = i + 1 break print(ans) " p02596,s925341044,Wrong Answer,"k=int(input()) if k%2==0: print(-1) else: s='7' flag=0 for _ in range(6): if int(s)%k==0: flag=1 print(len(s)) break s=s+'7' if flag==0: print(k-1)" p02596,s954951491,Wrong Answer,"k = int(input()) a=0 n=0 for i in range (10**8): a+= 7*10**i n +=1 if a%k ==0: print(n) break print(-1)" p02596,s646707263,Wrong Answer,"K = int(input()) # ぜんぜんちがう ans = -1 def moduloseven(K): for i in range(1000): sev = int(str(7)*(i+1)) if sev % K == 0: ans = i+1 break else: ans = K-1 return(ans) if K % 2 != 0: if K % 5 != 0: ans = moduloseven(K) print(ans)" p02596,s801645451,Wrong Answer,"k = int(input()) mod = 7 % k print(mod) ans = 1 for i in range(k): if k % 2 == 0: ans = -1 break if mod == 0: break mod = (mod*10+7)%k ans += 1 if ans == i: ans = -1 print(ans)" p02596,s748601824,Wrong Answer,"K = int(input()) if K % 10 in [2,4,5,8,0]: print(-1) else: sevens = [int((""7""*i)) % K for i in range(1,K)] try: print(sevens.index(0)+1) except Exception as e: print(-1)" p02596,s308587839,Wrong Answer,"k = int(input()) kkk = [0] * k kkk[0] = 7 % k ans = -1 for i in range(1, k): if kkk[i - 1] == 0: ans = i break kkk[i] = (kkk[i - 1] * 10 + 7) % k print(ans)" p02596,s344875064,Wrong Answer,"K = int(input()) N=10000 seven = '7' tmp = '7' num=1 for i in range(N): if int(tmp)%K==0: break else: tmp=tmp+seven num+=1 if num==(N+1): print(-1) else: print(num)" p02596,s090582977,Wrong Answer," k = int(input()) ans = 0 if 7 % k == 0: ans = 1 ai = 7 for i in range(2,k+5): ai = ((ai * 10) + 7) % k if ai == 0: ans = i break if i == k: ans = -1 print(ans) " p02596,s653123387,Wrong Answer,"k=int(input()) x=[] for i in range(1,100000): t='1'*i t=int(t) if t%k==0: print(i) exit() else: if t%k in x: print('-1') exit() x+=[t%k] " p02596,s884614496,Wrong Answer,"a = 7 b = 0 K = int(input()) for i in range(K): if a == 0: b = 1 break else: a = (10 * a +7) % K if b == 0: print(-1) else: print(i + 1)" p02596,s727459594,Wrong Answer,"import time start = time.time() k = int(input()) ans = 0 if k % 2 == 0: print(""-1"") quit() for i in range(10**6): if time.time()-start > 1.9: print(""-1"") quit() ans += (10**i)*7 if ans % k == 0: print(i) break else: print(""-1"") " p02596,s713525972,Wrong Answer,"k=int(input()) f=-1 for i in range(1,1000): s=k*i l=len(str(s)) for i in range(l): if str(s).count('7')==l: f=l break print(f)" p02596,s903961715,Wrong Answer,"def main(): K = int(input()) l = [False] * K ans = 1 now = 0 while True: now = now * 10 + 7 now %= 7 if now == 0: print(ans) break if l[now]: print(-1) break l[now] = True ans += 1 if __name__ == '__main__': main()" p02596,s607953998,Wrong Answer,"def solve(n): if n % 10 not in [1,3,7]: return -1 r = 0 for i in range(int(1.2e6)): r = (r * 10 + 7) % n if r == 0: return i + 1 return -1 print(solve(int(input()))) " p02596,s436504642,Wrong Answer,"k = int(input()) import sys i = 1 amari = 7%k ama = 7%k while True: if amari%k ==0: print(i) sys.exit() else: ama = (ama*10)%k amari += ama i +=1 if i == k: break print(-1) " p02596,s903372631,Wrong Answer,"import sys k = int(input()) if k == 7: print(1) sys.exit() remainders = set() remainder = 7 % k remainders.add(remainder) counter = 1 while True: counter += 1 remainder = remainder * 10 % k if remainder in remainders: print('-1') sys.exit() remainders.add(remainder) if sum(remainders) % k == 0: print(counter) sys.exit()" p02596,s807826088,Wrong Answer,"K = int(input()) a = 7 ans = -1 for i in range(1,10^6+1): if a%K==0: ans = i break a = a*10+7 print(ans)" p02596,s111246363,Wrong Answer,"K = int(input()) ans = 0 ans1 = -1 if K%2 == 0: print(-1) else: for i in range(1000): ans += 7*10**i if ans%K == 0: ans1 = i+1 break if ans1 == -1 and K%2 ==1: print(K-1) elif K%2 == 1: print(ans1) " p02596,s819007034,Wrong Answer,"k = int(input()) if k % 2 == 0: print(-1) elif k % 5 == 0: print(-1) else: print(k-1)" p02596,s485193934,Wrong Answer,"k=int(input()) if k%7==0: k//=7 res=1 if k%2==0 or k%5==0: print(-1) else: for i in range(k): res*=10 if res%k==1%k: print(i+1) break else: res%=k " p02596,s660481538,Wrong Answer,"n = int(input()) k = 0 c = 1 q = 20 while q>0: k = k*10 + 7 if k%n==0: print(c) break else: c+=1 q -= 1 else: print(-1)" p02596,s479911980,Wrong Answer,"k=int(input()) if(k%2==0): print(-1) else: n=len(str(k)) s="""" for i in range(n): s+=""7"" p=int(s) if(p int: def solve(K): if K < 7: return -1 curr = 7 % K for i in range(1, 10**6 + 1): if curr == 0: return i curr *= 10 curr += 7 curr %= K return -1 # generated by online-judge-template-generator v4.4.0 (https://github.com/kmyk/online-judge-template-generator) def main(): K = int(input()) a = solve(K) print(a) if __name__ == '__main__': main() " p02596,s310066924,Wrong Answer,"k = int(input()) num = 0 ans = 0 seven = '' for i in range(k): seven += '7' num = int(seven) % k if num == 0: ans = i break print(ans)" p02596,s922419092,Wrong Answer,"K = int(input()) a = 0 n = 0 out = -1 while True: a += 7 * (10 ** n) if a % K == 0: out = n + 1 print(out) break " p02596,s954847060,Wrong Answer,"K = int(input()) if K % 2 == 0: print(-1) exit() k= str(K) leng = len(k) for i in range(leng, K): nstr = '7' * i n = int(nstr) if n % K == 0: print(i) exit() print(-1)" p02596,s502265264,Wrong Answer,"k = int(input()) if(k&2==0): print(""-1"") else: i = 1 while True: m = 7 if(m%k==0): ans = i print(ans) break if(i>1000000): print(""-1"") break m = m*10 + 7 i += 1 " p02596,s777624011,Wrong Answer,"K = int(input()) seven = 7 count = 0 if(K % 2 == 0 or K % 5 == 0): print(-1) else: while(seven % K != 0): seven = (seven * 10 + 7) % K count += 1 # これだと10^5以降の計算が遅くなる。countのせい?? # count += 1 # seven = seven + 7 * (10 ** count) if(count >= 1): print(count + 1)" p02596,s516471262,Wrong Answer,"k = int(input()) count = 0 ans = 1 while True: num = int(""7"" + ""7"" * count) if k % 2 == 0 or k % 5 == 0 or num > k: print(-1) break if num % k == 0: print(ans) break count += 1 ans += 1" p02596,s955095722,Wrong Answer,"k = int(input()) t = '7' i = 0 if k % 2 == 0: print(-1) elif (set(str(k))) == {'0', '1'}: while(1): s = int(t) if s % k == 0: ans = i+1 break t += '7' i += 1 print(ans) else: print(k-1) " p02596,s083514517,Wrong Answer,"k = int(input()) ans = 0 if k % 2 == 0: print(""-1"") quit() for i in range(k): ans += (10**i)*7 if ans % k == 0: print(i) break else: print(""-1"") " p02596,s350729325,Wrong Answer,"num=int(input()) a=7 flag=0 for i in range(num-1): a=(a*10+7)%num if a%num==0: print(i+2) flag=1 break if flag==0: print(-1)" p02596,s150498849,Wrong Answer,"k = int(input()) if k%7 == 0: print(1) elif k%11 == 0: print(2) elif k%37 == 0 or k%3 == 0: print(3) elif k%101 == 0: print(4) elif k%41 == 0 or k%271 == 0: print(5) else: print(-1)" p02596,s530596222,Wrong Answer,"t = int(input()) c = 1 N = 7 f=0 def isPrime(n): if (n <= 1): return False for i in range(2, n): if (n % i == 0): return False return True if isPrime(t): print (-1) else: while(N%t !=0): c +=1 N = N*10 + 7 if(len(str(N))>10000): print(-1) f=1 break if(f!=1): print(c)" p02596,s871275840,Wrong Answer,"K = int(input()) used = set() pos = 1 v = 0 while 1: v += 10*v+7 v %= K if v==0: print(pos) break if v in used: print(-1) break used.add(v) pos += 1" p02596,s639066518,Wrong Answer,"from sys import exit K = int(input()) if K % 2 == 0: print(-1) exit() cosmo = '{:7>1000000d}'.format(7) num = 1 for x in range(1, len(cosmo) + 1): if len(str(K)) > x: break if int(cosmo[0:x]) % K == 0: print(num) exit() num += 1 print(-1)" p02596,s677168237,Wrong Answer,"K = int(input()) x = 7 count = 1 if K % 2 ==0: print(""-1"") exit(0) for i in range(10000): if x % K == 0: print(count) exit(0) else: x = 10*x + 7 count += 1 print(""-1"")" p02596,s611907573,Wrong Answer,"K = int(input()) j = 7%K p = -1 for i in range(1,K): if j == 0: print(i) p = 0 break j = ((j*10)+7)%K if p == -1: print(""-1"")" p02596,s378294067,Wrong Answer,"K = int(input()) N = 0 for i in range(10001): N += 7*(10**i) if N%K ==0: print(i) break else: print(-1) " p02596,s222196726,Wrong Answer,"K=int(input()) i=1 if K%2==0 or K%5==0: print(-1) else: L=9*K b=10 while True: b=b%L if b==1: print(i) break b=b*10 i+=1 " p02596,s907147224,Wrong Answer,"K = int(input()) ans = -1 if K % 7 == 0: for i in range(K): if 10 ** i % (9 * K / 7) == 1: ans = i break else: for i in range(K): if 10 ** i % (9 * K) == 1: ans = i break print(ans)" p02596,s221575380,Wrong Answer,"import sys k = int(input()) a = [0]*(k+1) a[0] = 7 for i in range(1, k+1): a[i] = (10*a[i-1]+7) % k for i in range(k): if a[i] == 0: print(i+1) sys.exit() print(-1)" p02596,s906174812,Wrong Answer,"k = int(input()) mx = 10**8 tmp = 7 flag = 0 for i in range(mx): tmp = (tmp*10 + 7)%k if(tmp == 0): print(i+2) flag = 1 break if(flag == 0): print(-1)" p02596,s531549735,Wrong Answer,"k=int(input()) num=k%7 for i in range(1, 10**6+2): if num%k==0: print(i) exit() else: num=(num*10+7)%k print(-1) " p02596,s483910990,Wrong Answer,"k = int(input()) x = 0 i = 1 mx = [] while (True): x = 10 * x + 7 m9 = x % 9 mk = x % k # print(""x, mx, mk, m9 = "", x, mx, mk, m9) if m9 in mx: print(-1) break if mk == 0: print(i) break mx.append(m9) i += 1" p02596,s089515000,Wrong Answer,"K=int(input()) m=7 count=1 for i in range(K): if m%K==0: break else: m*=10 m+=7 count+=1 print(count)" p02596,s914049224,Wrong Answer,"K = int(input()) ans = ""-1"" count = 0 while len(str(K)) + 1 > count: count+=1 # print(""yes"") # print(len(str(7)*count)) if int(str(7)*count) % K == 0: ans = count break print(ans)" p02596,s048505848,Wrong Answer,"k=int(input()) a="""" b="""" ans=-1 for i in range(100000): a+=""7"" b=str(k%int(a)).replace(""7"","""") if b=="""": ans=i+1 break print(ans)" p02596,s529166196,Wrong Answer,"K = int(input()) if K==7: print(1) else: x = 7%K count = 1 for i in range(K): x = (x*10+7)%K count += 1 if x==0: print(count) break if x!=0: print(-1)" p02596,s774054939,Wrong Answer,"K = int(input()) ans = 1 num = 0 seven = 7 if not K%2: print(-1) else: for i in range(K+1): num = num + seven num = num%K seven = seven*10%K if num == 0: print(ans) break ans += 1" p02596,s315381042,Wrong Answer,"def main(): k = input() K = int(k) if K % 2 == 0: print('-1') else: for i in range(1, 10 ** 3 * len(k) + 1): target = int('1' * i) * 7 if target % K == 0: print(i) break else: print(K - 1) if __name__ == '__main__': main()" p02596,s847629459,Wrong Answer,"#-*-coding:utf-8-*- import sys def main(): k = int(input()) sevens=0 if k%2==0: print(-1) exit() for i in range(1,k+1): sevens=(sevens*10+7)%k if sevens==0: print(i) exit() if __name__ == ""__main__"": main()" p02596,s506515220,Wrong Answer,"k = int(input()) start = 7 if k % 2 == 0: print(""-1"") exit() for i in range(k + 1): if start % k == 0: print(i + 1) break start = (start * 10 + 7) % k" p02596,s192770591,Wrong Answer,"import time k = int(input()) tick = time.time() idx = 0 while True: if time.time() - tick > 1.95: ans = -1 break idx += 1 tgt = int(""7"" * idx) if tgt % k == 0: ans = idx break print(ans)" p02596,s423698149,Wrong Answer,"k = int(input()) s = 7 s = (s * 10 + 7) % k cnt = 0 if k % 2 == 1 and not k % 5 == 0: while(1): if s == 0: cnt += 1 print(cnt) break else: s = (s * 10 + 7) % k cnt += 1 else: print(-1)" p02596,s408101879,Wrong Answer,"K = int(input()) X = 7 count = 1 while(X <= 10**6): if X % K == 0: print(count) exit() X = X*10 + 7 count += 1 print(-1)" p02596,s526016871,Wrong Answer,"import math as mt K = int(input()) a = list(range(1000001)) a[1] = 7%K found = False for i in range(2,K): a[i] = (a[i-1]*10+7)%K for i in range(1,K): if a[i] == 0: print(i) found = True break if found == False: print(""-1"") " p02596,s632842533,Wrong Answer,"if __name__ == '__main__': k = int(input()) if k % 2 == 0 or k % 2 == 5: print('-1') else: mod_list = [7 % k] for i in range(1000000): mod_list.append((mod_list[0] + mod_list[-1] * 10) % k) if mod_list[-1] == 0: break print(len(mod_list)) " p02596,s204087587,Wrong Answer,"def main(): k = int(input()) init = 7%k an = [init] for _ in range(k): a = an[-1] an.append((10*a+7) % k) for ind, a in enumerate(an): if a==0: print(ind) return print(-1) if __name__ == '__main__': main()" p02596,s896386014,Wrong Answer,"x = int(input()) i = 1 n= 0 if x % 2 == 0 or x % 5 == 0: print(-1) else: for i in range(1, 1000000): l = (7*pow(9,-1)*(pow(10,i,x)-1))%x n+=1 if l % x == 0: break print(n)" p02596,s083531885,Wrong Answer,"K = int(input()) if K==7 or K==1: print(1) if K==11: print(2) if K in (3,37,3*37): print(3) elif K in (11,101,1111): print(4) elif K in (41,271,11111): print(5) elif K in (1, 3, 7, 11, 13, 21, 33, 37, 39, 77, 91, 111, 143, 231, 259, 273, 407, 429, 481, 777, 1001, 1221, 1443, 2849, 3003, 3367, 5291, 8547, 10101, 15873, 37037, 111111): print(6) elif K in (239,4649,239*4649): print(7) else: print(-1)" p02596,s920210805,Wrong Answer,"def resolve(): N = int(input()) count = 7 if N%2 == 0: print(""-1"") else: for i in range(10**6): count += 10**i if count % N == 0: print(i+1) exit() resolve()" p02596,s772930642,Wrong Answer,"n=int(input()) if(n%2==0): print(-1) elif(n==999983): print(999982) elif(n==101): print(4) else: print(-1)" p02596,s574960047,Wrong Answer,"a=int(input()) ans=[] num=0 for i in range(10000): num=num*10+7 ans.append(num) #print(ans) cnt=0 for x in ans: if x%a==0: print(cnt+1) break cnt+=1 " p02596,s056911962,Wrong Answer,"K = int(input()) x = [] x.append(7%K) for i in range(1,K): x.append((x[i-1]*10+7)%K) ans = -1 for i in x: if x == 0: ans = i + 1 break print(i)" p02596,s950596779,Wrong Answer,"k = int(input()) a=0 n=0 for i in range (n): a+= 7*10**i n +=1 if a%k ==0: print(n) break " p02596,s643073373,Wrong Answer,"import sys K = int(input()) # branch = ['7'] # for i in range(10 ** 6): # branch.append(branch[-1] + '7') # # ans = -1 # # for i, b in enumerate(branch): # if int(b) % K == 0: # ans = i + 1 # break # # print(ans) b = '7' ans = -1 for i in range(10 ** 6): b += '7' if int(b) % K == 0: ans = i + 2 break print(ans) " p02596,s512209967,Wrong Answer,"K = int(input()) seven = 7 MOD7 = 7 % K MOD70 = 70 % K MOD77 = MOD7 + MOD70 if K % 2 == 0: print(-1) elif MOD7 == 0: print(1) else: for i in range(1,K): if MOD77 % K == 0: break MOD70 = (MOD70 * 10) % K MOD77 += MOD70 MOD77 = MOD77 % K print(i+1)" p02596,s889142207,Wrong Answer,"N = int(input()) a = 7 for i in range(1,N+1): if a % N == 0: print(i) break a = (a * 10 + 7) % N " p02596,s693566066,Wrong Answer,"K = int(input()) x = 7 % K for i in range(1, K): if x == 0: print(i) exit() x = (x * 10 + 7) % K print(-1)" p02596,s278574523,Wrong Answer,"from sys import stdin input = stdin.readline ri = lambda : int(input()) ril = lambda : list(map(int, input().split())) def main(): K = ri() m = 0 ans = -1 for i in range(K): m = (10 * m + 7) % K if m == 0: ans = i break print(ans) if __name__ == '__main__': main() " p02596,s298662237,Wrong Answer,"k = int(input()) ch = str('') ans = 0 if k % 2 != 0: for i in range(5): ch += str(7) ch_int = int(ch) q = ch_int // k mod = ch_int % k if q >= 1 and mod == 0: ans = i + 1 break if ans == 0: ans = -1 print(ans)" p02596,s376609619,Wrong Answer,"k = int(input()) a =7 for i in range(k+1): if a%k ==0: print(i+1) break elif k%2==0 or k%5==0: print(""-1"") i +=1 a = a + 7*10**(i) else: print(""-1"") " p02596,s519573762,Wrong Answer,"k = input() k = int(k) f = 0 if 1 <= k and k <= 1000000: for i in range(1, 8): n = ""7""*i n = int(n) if n%k == 0: print(i) f = 1 break if f == 0: print(-1)" p02596,s063027559,Wrong Answer,"N=int(input()) if N%2==0: print(""-1"") else: M=7 for i in range(1,20): M=""7""*i S=int(M) if S%N==0: print(i) exit() " p02596,s600925647,Wrong Answer,"k=int(input()) a=int(7) x=int(1) n=int(0) while n>=1: if a%k==0: print(x) n=1 else: a=(a*10)+7 x=x+1" p02598,s022057153,Accepted,"n,k = map(int,input().split()) a = list(map(int,input().split())) l = 0 r = 10**10 while r > l + 1: m = (r+l)//2 count = 0 for i in a: if i <= m: continue count += (i-1)//m if count > k: l = m else: r = m print(r)" p02598,s108921571,Accepted,"import numpy as np import math N,K = map(int, input().split()) Logs = np.array([int(x) for x in input().split()]) ave = sum(Logs)/(N+K) cut = np.array([max(1,int(x/ave)) for x in Logs]) chip = Logs/cut chip=np.sort(chip)[::-1] print(math.ceil(chip[N+K-sum(cut)]))" p02598,s641875973,Accepted,"#abc174_e n,k=map(int,input().split()) a=[int(i) for i in input().split()] ok=1001001001 ng=0 def check(x): cnt=0 for q in a: cnt+=(q-1)//x return cnt<=k while ok-ng>1: mid=(ok+ng)//2 if check(mid): ok=mid else: ng=mid print(ok)" p02598,s191976250,Accepted,"N, K = map(int, input().split()) A = [int(i) for i in input().split()] def f(length, ls): cur = 0 for a in ls: if a%length == 0: cur += a//length - 1 else: cur += a//length if cur <= K: return True else: return False ok, ng = max(A), 0 while abs(ok - ng) > 1: z = (ok+ng)//2 if f(z, A) == True: ok = z else: ng = z print(ok)" p02598,s189445864,Accepted,"import math n, k = list(map(int,input().split())) a = list(map(int,input().split())) def lte_k(x, len_list): counter = 0 for item in len_list: counter += math.ceil(item / x) - 1 return counter <= k def binary_search(): low = 0 high = max(a) while low < high-1: mid = (low + high) // 2 guess = lte_k(mid, a) if guess: high = mid else: low = mid return high print(binary_search())" p02598,s454027350,Accepted,"n,k = map(int, input().split()) alist=list(map(int, input().split())) def is_ok(arg): cnt=0 for i in alist: cnt+=(i-1)//arg return cnt<=k def nibun(ng, ok): while (abs(ok - ng) > 1): mid = (ok + ng) // 2 if is_ok(mid): ok = mid else: ng = mid return ok print(nibun(0 , 10**9 + 1))" p02598,s784012774,Accepted,"import sys input = sys.stdin.readline N, K = map(int, input().split()) A = list(map(int, input().split())) lb, ub = 0, 10**9 while ub - lb > 1: m = (lb + ub) // 2 cnt = 0 for i in range(N): cnt += (A[i] + m - 1) // m - 1 if cnt <= K: ub = m else: lb = m print(ub)" p02598,s862971988,Accepted,"n,k=map(int,input().split()) ar=list(map(int,input().split())) def cnt(x): s=0 for i in ar: if i>x: s+=(i-1)//x return s l=0 r=10**9 while lk: l=m else: r=m print(r)" p02598,s074877713,Accepted,"N, K = map(int,input().split()) A = list(map(int,input().split())) start = 0 end = 10**9 while end - start > 1: l = (start + end)/2 l = int(l) count = 0 for i in range(N): q = A[i]/l if q == int(q): q -= 1 count += int(q) if count <= K: end = l else: start = l print(end)" p02598,s712060451,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) l = 0 r = max(a) while r - l > 1: cnt = 0 mid = (r + l) // 2 for i in range(n): d = (a[i] - 1) // mid if d > 0: cnt += d if cnt <= k: r = mid else: l = mid print(r)" p02598,s118127276,Accepted,"(N, K) = [int(n) for n in input().split()] A = [int(n) for n in input().split()] L = 0 H = max(A) def feasible(M): # M: maximum length S = sum([(a - 1) // M for a in A]) #print(""S = {}, K = {}"".format(S, K)) return S <= K # assert(not feasible(L)) assert(feasible(H)) while H - L > 1: #print(H, L) M = (H + L) // 2 if feasible(M): H = M else: L = M print(H) " p02598,s079732399,Accepted,"def f(x): now = 0 for i in range(n): now += (a[i]-1)//x return now <= k n, k = map(int, input().split()) a = list(map(int, input().split())) ng = 0 ok= int(1e9) while ok - ng > 1: x = (ok + ng) // 2 if f(x): ok = x else: ng = x print(ok)" p02598,s137763126,Accepted,"import math n,k=map(int,input().split()) a=list(map(int,input().split())) l,r=0,10**9 f=0 while r-l>1: m=(l+r)//2 count=0 for i in a: count+=math.ceil(i/m)-1 if count<=k: r=m else: l=m print(r)" p02598,s336750301,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) def is_ok(L): count = 0 for a in A: count += a // L if a % L == 0: count -= 1 return count <= K ng = 0 ok = max(A) while abs(ok - ng) > 1: mid = (ok + ng) // 2 if is_ok(mid): ok = mid else: ng = mid print(ok) " p02598,s483790696,Accepted,"from math import * from collections import * from random import * from decimal import Decimal from bisect import * import sys input=sys.stdin.readline def lis(): return list(map(int,input().split())) def ma(): return map(int,input().split()) def inp(): return int(input()) n,k=ma() a=lis() l,h=0,max(a) while(l+1 1: mid = (ok + ng) // 2 if judge(mid): ok = mid else: ng = mid print(ok)" p02598,s317954763,Accepted,"import math def f(A, m, K): p = sum([a // m for a in A]) if p > K: return False else: return True N, K = map(int, input().split()) A = list(map(int, input().split())) left = 0 right = 10 ** 9 + 1 while int(left) != int(right): m = (left + right) / 2 if f(A, m, K): right = m else: left = m print(math.ceil(m)) " p02598,s016105768,Accepted,"#!/usr/bin/env python # coding: utf-8 # In[16]: N,K = map(int, input().split()) A = list(map(int, input().split())) # In[49]: low = 0 high = max(A) def ok(x): cnt = 0 for a in A: cnt += (a//x) if a%x == 0: cnt -= 1 return cnt <= K while high-low > 1: mid = (high+low)//2 if ok(mid): high = mid else: low = mid print(high) # In[ ]: " p02598,s353969212,Accepted,"n,k=map(int,input().split()) A=[int(x) for x in input().split()] s,l=0,max(A) while l-s>1: m=(s+l)//2 if sum([(a-1)//m for a in A]) >k: s=m else: l=m print(l) " p02598,s767012054,Accepted,"import math n,k=map(int, input().split()) a=list(map(int, input().split())) right=max(a) left=0 def cutable(a,x): count=0 for i in a: count+=math.ceil(i/x)-1 return count<=k while right>left+1: mid=(right+left)//2 if cutable(a,mid): right=mid else: left=mid print(right)" 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))" 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) " p02598,s302461924,Accepted,"import sys import heapq import math import fractions import bisect import itertools from collections import Counter from collections import deque from operator import itemgetter def input(): return sys.stdin.readline().strip() def mp(): return map(int,input().split()) def lmp(): return list(map(int,input().split())) n,k=map(int,input().split()) a=lmp() def ok(s): c=0 for i in a: c+=-(-i//s)-1 return c<=k l=0 r=max(a) while r>l+1: md=(r+l)//2 if ok(md): r=md else: l=md print(r)" p02598,s886041350,Accepted,"def binarySearch(A, K): left = 1 # right = n right = max(A) while left < right: mid = (left + right) // 2 cost = sum(map(lambda x: (x-1)//mid, A)) # print(left, right, mid) # print(K, cost) if K >= cost: right = mid else: left = mid + 1 # return NOT_FOUND # return mid return left N, K = map(int, input().split()) A = sorted(list(map(int, input().split()))) # print(sorted(A)) print(binarySearch(A, K))" p02598,s250200717,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) l = 0 r = 10 ** 9 while r-l > 1: m = (r+l) // 2 count = 0 for i in A: if i > m: count += i // m if count > K: l = m else: r = m print(r)" p02598,s538941877,Accepted,"n,k = map(int,input().split()) a = list(map(int,input().split())) now = 0 scale = 2**32 while scale: cnt = 0 tmp = now + scale for x in a: cnt += (x-1) // tmp if cnt > k: now = tmp #print(tmp,cnt) scale //= 2 print(now+1)" p02598,s368526491,Accepted,"N, K = list(map(int, input().split())) A = list(map(int, input().split())) l = 0 r = max(A) while l + 1 < r: m = (l+r)//2 n = sum([(x-1)//m for x in A]) if n > K: l = m else: r = m print(r)" p02598,s325554416,Accepted,"import math n, k = map(int, input().split()) A = list(map(int, input().split())) max_len = max(A) def f(x): ans = 0 for a in A: cut_num = math.ceil(a / x) - 1 #print(a, cut_num, a / x) ans += cut_num if ans <= k: return True else: return False left = 0.001 right = max_len while right - left > 1: mid = (right + left) // 2 if f(mid): right = mid else: left = mid else: print(int(right))" p02598,s077149438,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) # [ok, ng) - Maximum # (ng, ok] - Minimum # ok が 最終的な答え ok = max(A) ng = 0 while abs(ok - ng) > 1: mid = (ok + ng) // 2 cnt = 0 for a in A: l = (a + mid - 1) // mid cnt += l - 1 if cnt <= K: ok = mid else: ng = mid print(ok) " p02598,s646405249,Accepted,"N, K = map(int, input().split()) a = list(map(int, input().split())) max_a = 10**9 min_a = 0 while True: k = K res = (max_a+min_a)//2 for i in range(N): if a[i] <= res: continue k -= (a[i]//res) if k >= 0: max_a = res else: min_a = res if max_a - min_a == 1: break print(max_a)" p02598,s004721405,Accepted,"N,K=map(int,input().split()) alist=list(map(int,input().split())) #print(alist) memo={0:False} def isOK(x): if x in memo: return memo[x] num_cut=0 for a in alist: num_cut+=-(-(a-x)//x) if num_cut>K: memo[x]=False return False memo[x]=True return True l=1 r=max(alist)+1 while l<=r: mid=(l+r)//2 if not isOK(mid-1) and isOK(mid): print(mid) break elif isOK(mid-1): r=mid else: l=mid" p02598,s824476112,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) def check(l): count = 0 for L in A: count += L // l if L % l != 0: count += 1 count -= 1 return count <= K bottom, top = 0, max(A) while top - bottom > 1: mid = (top + bottom) // 2 if check(mid): top = mid else: bottom = mid print(top) " p02598,s921905976,Accepted,"N, K = map(int,input().split()) A = [int(x) for x in input().split()] l = 0 r = max(A) + 1 while(l+1 K: l = m else: r = m print(r) " p02598,s179342599,Accepted,"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 += A[i]//mid if count <= k: r = mid else: l = mid+1 print(l)" p02598,s616426452,Accepted,"import math N, K = map(int, input().split()) A = sorted(list(map(int, input().split()))) max_l = max(A) + 1 min_l = 0 cur = (max_l + min_l) // 2 def check(l): count = 0 for a in A: count += math.ceil(a / l) - 1 return count <= K while True: if check(cur): max_l = cur + 1 else: min_l = cur if cur == (max_l + min_l) // 2: break cur = (max_l + min_l) // 2 print(cur) " p02598,s465192432,Accepted,"# coding: utf-8 def solve(*args: str) -> str: n, k = map(int, args[0].split()) A = tuple(map(int, args[1].split())) l, r = 1, max(A) while 0.1 < r-l: m = (l+r)/2 cnt = 0 for a in A: cnt += -int(-a//m)-1 if k < cnt: l = m else: r = m return str(-int(-l//1)) if __name__ == ""__main__"": print(solve(*(open(0).read().splitlines()))) " p02598,s252770948,Accepted,"def is_good(mid, key): res = 0 for a in A: res += (a + mid - 1) // mid return res - N <= key def binary_search(bad, good, key): while good - bad > 1: mid = (bad + good) // 2 if is_good(mid, key): good = mid else: bad = mid return good N, K, *A = map(int, open(0).read().split()) print(binary_search(0, 1_000_000_000, K)) " p02598,s165902173,Accepted,"import math def check(A, x, k): cut_count = 0 for number in A: cut_count += (math.ceil(number / x)) -1 return cut_count <= k n, k = map(int,input().split()) a = list(map(int, input().split())) ans = 0 l = 0 r = 10 ** 9 while r - l > 1: x = (r + l) // 2 if check(a, x, k): r = x else: l = x print(r)" p02598,s864203640,Accepted,"from sys import stdin from math import floor,ceil N, K = map(int, input().rstrip().split()) A = [int(x) for x in stdin.readline().rstrip().split()] def is_max_len_less_than_input(x,K,A): count = 0 if x==0: return False for ln in A: count += ceil(ln/x)-1 if count > K: return False return True def binary_search(begin,end,K,A): while abs(end-begin)>1: mid = (begin+end)//2 if is_max_len_less_than_input(mid,K,A): end = mid else: begin = mid return end print(binary_search(0,max(A),K,A))" p02598,s152160697,Accepted,"N,K=map(int,input().split()) L=list(map(int,input().split())) import math MAX=10**9 MIN=0 for i in range(100): Mid=(MAX+MIN)/2 cnt=0 for j in range(N): cnt+=L[j]//Mid if cnt<=K: MAX=Mid else: MIN=Mid #print(cnt) print(math.ceil(Mid)) " p02598,s154911914,Accepted,"from math import ceil N, K = map(int, input().split()) A = list(map(int, input().split())) def f(x): cnt = 0 for a in A: cnt += ceil(a / x) - 1 return True if cnt <= K else False OK, NG = 10**9, 0 while OK - NG > 1: mid = (OK + NG) // 2 if f(mid): OK = mid else: NG = mid print(OK) " p02598,s555203116,Accepted,"N, K = map(int, input().split()) A = sorted(list(map(int, input().split()))) L, R = 0, A[-1] while R - L > 1: mid = L + (R - L) // 2 if sum([(a - 1) // mid for a in A]) <= K: R = mid else: L = mid print(R) " p02598,s236281092,Accepted,"n,k = map(int,input().split()) a = list(map(int,input().split())) l = 0 r = 10**10 while r > l + 1: m = (r+l)//2 count = 0 for i in a: if i <= m: continue count += (i)//m if count > k: l = m else: r = m print(r) " p02598,s557613750,Accepted,"import math n,k = map(int,input().split()) a = [int(i) for i in input().split()] a.sort() r = a[n-1] l = 0 def calc(t,x): return math.ceil(t / x) - 1 while r - l > 1: mid = (r+l)//2 count = 0 for i in a: count += calc(i,mid) if count > k: l = mid else: r = mid print(r) " p02598,s670539505,Accepted,"import sys input=sys.stdin.readline n,k=map(int,input().split()) l=list(map(int,input().split())) ok=max(l) ng=0 def solve(m): s=0 for i in l: s+=-((-i)//m)-1 return s while ok-ng>1: m=(ok+ng)//2 if k k: l = m else: r = m print(r)" p02598,s925867177,Accepted,"def check(x,k,arr): now = 0 for i in range(len(arr)): now+=int((arr[i]-1)/x) return now<=k n, k = map(int,input().split()) arr = list(map(int,input().split())) r, l = 1e9, 0 while (l+1 mina+1: mid = (mina+maxa)//2 div = np.sum(np.ceil(a/mid))-n if div > k: mina = mid else: maxa = mid print(maxa)" p02598,s177215912,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) top = max(a) bottom = 0 while (top - bottom) > 1: mid = (top + bottom) // 2 div_n = lambda a: (a + mid - 1) // mid - 1 cnt = sum(map(div_n, a)) if cnt <= k: top = mid else: bottom = mid print(top)" 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) " p02598,s191871579,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) l = 0 r = max(a) while r - l > 1: cnt = 0 mid = (r + l) // 2 for i in range(n): d = (a[i] // mid) + (a[i] % mid != 0) - 1 cnt += d if cnt <= k: r = mid else: l = mid print(r)" p02598,s700707166,Accepted,"n, k = map(int, input().split()) a = [i-1 for i in map(int, input().split())] left, right = 0, 10**9 while left < right: middle = (left+right)//2 if middle==0: left=1 break count = 0 for i in a: count += i//middle if count <= k: right = middle else: left = middle + 1 print(left)" p02598,s320113397,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) l, r = 0, 10 ** 9 while r - l > 1: x = (l + r) // 2 cnt = 0 for i in range(n): if a[i] % x == 0: cnt += a[i] // x - 1 else: cnt += a[i] // x if cnt <= k: r = x else: l = x print(r) " 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) " p02598,s513395513,Accepted,"n,k=map(int,input().split()) A=list(map(int,input().split())) high=max(A) low=0 while high-low>1: cnt=0 now=(low+high)//2 for a in A: cnt+=max((a-1)//now,0) if cnt>k: break if cnt>k: low=now else: high=now #print(cnt,low,high) print(high)" p02598,s022316050,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) def f(x): return sum((a+x-1)//x - 1 for a in A) l = 0 r = 10**9+1 while r - l > 1: mid = (l + r) // 2 if f(mid) <= K: r = mid else: l = mid print(r)" p02598,s312164545,Accepted,"N, K = map(int, input().split()) A = [int(a) for a in input().split()] def chk(x): s = 0 for a in A: s += (a - 1) // x return 1 if s <= K else 0 l, r = 0, 1 << 30 while r - l > 1: m = (l + r) // 2 if chk(m): r = m else: l = m print(r)" 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()" p02598,s796701104,Accepted,"import sys input = sys.stdin.readline I = lambda : list(map(int,input().split())) n,k=I() l=I() lo=1;hi=max(l) while lo K: return False return True N, K = list(map(int, input().split())) A = list(map(int, input().split())) A.sort(reverse=True) l = 0 r = A[0] while l + 1 < r: m = (l+r)//2 if check(A, K, m): r = m else: l = m print(r)" p02598,s445117686,Accepted,"#!/usr/bin/env python n, k = map(int, input().split()) a = list(map(int ,input().split())) def check(x): now = 0 for i in range(n): now += (a[i]-1)//x return now <= k l = 0 r = int(1e9) while r-l > 1: mid = (l+r)//2 if check(mid): r = mid else: l = mid print(r)" p02598,s459181713,Accepted,"n, k = map(int, input().split()) A = tuple(map(int, input().split())) A = sorted(A, reverse=True) l = 0 r = max(A)+1 def cut(l, k): # 長さlの丸太を最大とすることができるかどうかを返す for a in A: if a > l: k -= (-(-a//l) - 1) return k >= 0 while r-l > 1: mid = (r+l)//2 if cut(mid, k): r = mid else: l = mid print(r)" p02598,s503219543,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()] l = 0; r = 1000000001 while r - l > 1: mid = (l + r) // 2 cnt = 0 for item in a: cnt += (item - 1) // mid # Can be cut in k times if cnt <= k: r = mid else: l = mid print(l + 1)" p02598,s710223180,Accepted,"import math n,k = map(int,input().split()) alist = list(map(int,input().split())) max_length = max(alist) cur_length = 0 while(max_length - cur_length > 1): next_length = (max_length+cur_length)//2 test_k = 0 for i in range(n): test_k += math.ceil(alist[i]/next_length)-1 if test_k <= k: max_length = next_length else: cur_length = next_length print(max_length)" p02598,s058342305,Accepted,"import math n,k = (int(x) for x in input().split()) An = [int(i) for i in input().split()] left = 0 right = max(An) def check(x): chk = 0 for i in range(n): chk += math.ceil(An[i]/x)-1 return chk while right-left!=1: x = (left+right)//2 if check(x)<=k: right = x else: left = x print(right)" p02598,s358199116,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) maxa = np.max(a) mina = maxa//(k+1) while maxa > mina+1: mid = (mina+maxa)//2 div = np.sum(np.ceil(a/mid-1)) if div > k: mina = mid else: maxa = mid print(maxa)" p02598,s240722163,Accepted,"import math N, K=map(int,input().split()) A=list(map(int,input().split())) def judge(ans,K,A): cut=0 for i in range(len(A)): cut+=(A[i]-1)//ans if cut>K: return False else: return True ansp=max(A) ansm=0 ans=(ansp+ansm)//2 d=1 while ansp-ansm>d: if judge(ans,K,A): ansp=ans else: ansm=ans ans=(ansp+ansm)//2 print(ansp)" p02598,s707355135,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) if k >= sum(a)-n: print(1) else: ok, ng = 10**9, 1 while ok-ng > 1: mid = (ok+ng)//2 if sum((x-1)//mid for x in a) <= k: ok = mid else: ng = mid print(ok)" p02598,s091219925,Accepted,"n,k = map(int,input().split()) a = list(map(int,input().split())) s = sum(a) x = [0]*n y = 0 r = 0 for i in range(n): y = int(a[i]/s*k) x[i] = [i, y, a[i]/(y+1), a[i]] r += y x.sort(key= lambda val : val[2],reverse=True) for i in range(k-r): x[i][1] += 1 ans = 0 for i in range(n): ans = max(ans, x[i][3]/(x[i][1]+1)) print(int(-(-ans//1))) " 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() " p02598,s190748014,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) def f(m): res = sum([-(-x//m)-1 for x in a]) return res <= k l, r = 0, 10**9+10 while r-l > 1: x = (l+r)//2 if f(x): r = x else: l = x print(r) " p02598,s719650052,Accepted,"N,K = map(int, input().split()) A = list(map(int, input().split())) l,r = 0, max(A) while r-l>1: mid = (l+r)//2 cnt = 0 for i in range(N): if A[i]%mid!=0: cnt+= A[i]//mid else: cnt += A[i]//mid - 1 if cnt <= K: r = mid else: l = mid print(r)" p02598,s108720045,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) def test(m): if m <= 0: return False needed = 0 for a in A: needed += (a-1)//m if needed > K: return False return True lb = 1 ub = max(A) while True: m = (lb + ub) // 2 if test(m): if test(m-1): ub = m - 1 else: print(m) exit() else: lb = m + 1" p02598,s902701626,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) mi = 0 ma = 10**9 while(ma - mi != 1): c = 0 mid = (ma + mi) // 2 for i in range(N): c += A[i] // mid - (A[i] % mid == 0) if c > K: mi = mid else: ma = mid print(ma)" p02598,s671459696,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) def isOk(x): cnt = 0 for a in A: cnt += (a - 1) // x return cnt <= K ok = max(A) ng = 0 while ok - ng > 1: mid = (ok + ng) // 2 if isOk(mid): ok = mid else: ng = mid print(ok) " p02598,s949842057,Accepted,"N,K = map(int, input().split()) A = list(map(int, input().split())) l,r = 1,max(A) while l1: M=(r+l)//2 if f(M)>K: l=M else: r=M print(r) " p02598,s604893227,Accepted,"import math def is_ok(A, x, K): cut_count = 0 for number in A: cut_count += (math.ceil(number / x)) - 1 return cut_count <= K A = [] [N, K] = input().split() N = int(N) K = int(K) A = input().split() ans = 0 l = 0 r = 10 ** 9 for i in range(N): A[i] = int(A[i]) while r - l > 1: x = (r + l) // 2 if is_ok(A, x, K): r = x else: l = x print(r)" p02598,s431184820,Accepted,"N,K = map(int,input().split()) A = list(map(int,input().split())) def check(m): n = 0 for a in A: if a%m == 0: n += a//m - 1 else: n += a//m return n <= K l = 0 r = 10**9+10 while r-l > 1: m = (r+l) // 2 if check(m): r = m else: l = m print(r) " p02598,s643748147,Accepted,"from math import ceil n, k = map(int, input().split()) a = [int(x) for x in input().split()] left = 0 right = max(a) while right - left > 1: length = (right + left) // 2 totcut = 0 for i in range(n): totcut += ceil(a[i]/length) - 1 if totcut > k: left = length break else: right = length print(right) " p02598,s234006583,Accepted,"# coding: utf-8 # Your code here! N,K=map(int,input().split()) A=list(map(float, input().split())) low=0 high=10**9+1 while high-low!=1: mid=(high+low)//2 cut_temp=0 ans=-1 for a in A: cut_temp+=-(-a//mid)-1 if cut_temp>K: low=mid else: high=mid print(high)" p02598,s007245376,Accepted,"def count_cuts(a, unit): return (a + unit - 1) // unit - 1 def is_good(mid, key): return sum(count_cuts(a, mid) for a in A) <= key def binary_search(key): bad, good = 0, 1_000_000_000 while good - bad > 1: mid = (bad + good) // 2 if is_good(mid, key): good = mid else: bad = mid return good N, K, *A = map(int, open(0).read().split()) print(binary_search(K)) " p02598,s368180912,Accepted,"import math def is_ok(mid,K,A): p = 0 for i in A: p += (i - 1)// mid if p > K: return False else: return True N,K = map(int,input().rstrip().split("" "")) A = list(map(int,input().rstrip().split("" ""))) A.sort() maxi = A[0] ng = 0 ok = 10 ** 9 while(abs(ng - ok) > 1): mid = (ok + ng) // 2 if is_ok(mid,K,A): ok = mid else: ng = mid print(ok)" p02598,s291227320,Accepted,"N,K = map(int,input().split()) A = list(map(int,input().split())) def f(n): now = 0 for i in range(N): now += (A[i]-1)//x if now <= K: return True else: return False l = 0; r = 10**10 while r-l > 1: x = (l+r)//2 if f(x): r = x else: l = x print(r)" p02598,s331359517,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) def ok(l): cnt = 0 for L in a: cnt += L // l if L % l != 0: cnt += 1 cnt -= 1 return cnt <= k #bottom:ng, top:ok bottom, top = 0, max(a) while top - bottom > 1: mid = (top + bottom) // 2 if ok(mid):top = mid else: bottom = mid print(top) " p02598,s962741622,Accepted,"N, K = map(int, input().split()) AList = list(map(int, input().split())) l = 0 r = 10**9 while r-l > 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)" p02598,s442912454,Accepted,"n,k=map(int,input().split()) a=list(map(int,input().split())) l=0;r=10**10 while r-l>1: x=(l+r)//2 ct=0 for i in range(n): ct+=(a[i]-1)//x if ct<=k: r=x else: l=x print(r)" p02598,s966824323,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) l, r = 0, 10 ** 9 + 10 while r - l > 1: res = 0 m = (l + r) // 2 for x in a: res += (x - 1) // m if res <= k: r = m else: l = m print(r) " p02598,s994968008,Accepted,"N, K=map(int, input().split()) A=list(map(int, input().split())) x=0 y=max(A) def f(l): nums=0 for a in A: if a%l==0: nums+=a//l-1 else: nums+=a//l if nums>K: return False else: return True while y-x>1: tmp=(x+y)//2 if f(tmp)==True: y=tmp else: x=tmp print(y)" p02598,s267372080,Accepted,"import math N, K = map(int, input().split()) a = list(map(int, input().split())) def cal(x): s = 0 for aa in a: s += math.ceil(aa / x) - 1 if s <= K: return True else: return False l = 0 r = max(a) while r - l > 1: mid = (l + r) // 2 if cal(mid): r = mid else: l = mid print(r)" p02598,s289417707,Accepted,"import copy import math n, k = map(int,input().split()) a = list(map(int,input().split())) ub = 10**9 lb = 0 while ub - lb > 10**-6: x = (ub + lb) / 2 cnt = 0 for i in a: cnt += math.ceil(i/x) if cnt <= n+k: ub = copy.deepcopy(x) else: lb = copy.deepcopy(x) ans = round(ub, 6) print(math.ceil(lb))" p02598,s624385446,Accepted,"import sys def input():return sys.stdin.readline()[:-1] def N(): return int(input()) def NM():return map(int,input().split()) def L():return list(NM()) n,k=NM() hi=10**9 lo=1 l=L() def f(mi): x=0 for i in l: if i<=mi: continue x+=(i+mi-1)//mi-1 if x<=k: return True return False while hi>=lo: mi=(hi+lo)//2 if f(mi): hi=mi-1 else: lo=mi+1 print(lo)" p02598,s103943287,Accepted,"N, K = [int(_) for _ in input().split()] A = [int(_) for _ in input().split()] def judge(x): k = 0 for a in A: v = a // x if a % x == 0: v -= 1 k += v return k <= K low = 1 high = max(A) A.sort() while low < high - 1: mid = (low + high) // 2 if judge(mid): high = mid else: low = mid if judge(low): print(low) else: print(high) " p02598,s839830183,Accepted,"n,k = map(int, input().split()) l = list(map(int,input().split())) ok = max(l) ng = 0 def solver(x): cnt = 0 for logs in l: if logs % x == 0: cnt += (logs // x) -1 else: cnt += logs// x if cnt <= k: return True else: return False while abs(ok-ng) > 1: mid = (ok+ng)//2 if solver(mid) == True: ok = mid else: ng = mid print(ok) " p02598,s387843940,Accepted,"N,K=map(int,input().split()) A=list(map(int,input().split())) l,r=1,10**9+1 while r-l>1: t=(l+r)//2 k=sum([(a+t-2)//(t-1)-1 for a in A]) if K1: mid = (left+right)//2 if is_ok(mid): right = mid else: left = mid print(right)" p02598,s213073003,Accepted,"N, K = map(int, input().strip().split()) A = list(map(int, input().strip().split())) minlen = 0 maxlen = 10**9 while maxlen-minlen > 1: mid = (maxlen + minlen)//2 if mid == 0: cur = 1e9 else: cur = sum((a+mid-1)//mid - 1 for a in A) if cur > K: minlen = mid else: maxlen = mid print(maxlen) " p02598,s305059447,Accepted,"from decimal import Decimal from heapq import heapify, heappop, heappush N, K = map(int, input().split()) *A, = map(int, input().split()) tot = sum(A) ng = 0 ok = 10**9 m = 4 while ng + 1 < ok: m = (ng+ok)//2 c = sum((a-1)//m for a in A) if c > K: ng = m else: ok = m print(ok) " p02598,s264856988,Accepted,"n,k = map(int,input().split()) a = list(map(int,input().split())) import math l = 0 r = max(a)+1 for _ in range(100): m = (l+r)/2 kn = 0 for i in a: kn += i//m if kn > k: l = m else: r = m print(math.ceil(l))" p02598,s630223564,Accepted,"n,k=map(int,input().split()) arr=list(map(int,input().split())) def isvalid(mid,k): if mid==0: return False ans=k for i in arr: if i>mid: ans-=i//mid return ans>=0 l=0 r=10**9 while(l1: m = (r+l)//2 if f(m): r = m else: l = m print(r) " p02598,s368451478,Accepted,"N,K=[int(s) for s in input().split()] maruta=[int(s) for s in input().split()] def possible(x): cut=0 for e in maruta: if e%x==0: cut+=(e//x-1) else: cut+=e//x if cut<=K: return True else: return False a=1 b=max(maruta) while b-a>1: c=(a+b)//2 if possible(c): b=c else: a=c if possible(1): print(1) else: print(b) " 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)" p02598,s722048283,Accepted,"# E - Logs import sys sys.setrecursionlimit(1000000) N,K = map(int,input().split()) A = list(map(int,input().split())) def rec(l,r): global N,K,A if l==r: return l tmp = (l+r)//2 ans = 0 for i in range(N): ans += (A[i]-0.001)//tmp if ans<=K: return rec(l,tmp) else: return rec(tmp+1,r) print(rec(1,max(A)))" p02598,s988077311,Accepted,"#abc174_e n,k=map(int,input().split()) a=[int(i) for i in input().split()] ok=1001001001 ng=0 def check(x): cnt=0 for q in a: cnt+=(q-1)//x return cnt<=k while ok-ng>1: mid=(ok+ng)//2 if check(mid): ok=mid else: ng=mid print(ok) " p02598,s852637613,Accepted,"N, K = map(int, input().split()) arr = list(map(int, input().split())) def f(x): res = 0 for i in range(N): if arr[i] % x != 0: res += arr[i]//x else: res += max((arr[i]//x)-1,0) return res left = 0 right = max(arr) while abs(left-right) > 1: tmp = (left+right)//2 if f(tmp) > K: left = tmp else: right = tmp print(right)" p02598,s479940211,Accepted,"n, k = map(int, input().split()) A = [*map(int, input().split())] ng, ok = 0, 1<<32 # (ng,ok] = (l,r] while ok - ng > 1: m = (ng + ok) // 2 c = 0 for a in A: c += (a-1) // m if c <= k: ok = m else: ng = m print(ok) " p02598,s034665290,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 A.sort(reverse=True) r = 10 ** 9 l = 0 while abs(r - l) > 1: mid = (r + l) // 2 if calc(mid): r = mid else: l = mid print(r) " p02598,s446886738,Accepted,"N, K = map(int, input().split()) A=list(map(int,input().split())) A.sort() right = A[-1]+1 left = 0 flag = True mid = (left+right)//2 minN = right result = mid while right-left>1 and flag: mid = (left+right)//2 count = 0 for i in A: count += (i-1)//mid if count <= K: right = mid if minN>mid: minN = mid result = mid elif count > K: left = mid print(result) " p02598,s340059245,Accepted,"from heapq import heappush, heappop from math import ceil, floor N, K = map(int, input().split()) A = [int(i) for i in input().split()] ng, ok = 0, 10 ** 9 for _ in range(50) : mid = (ng + ok) / 2 ret = 0 for a in A : ret += floor(a / mid) if ret <= K : ok = mid else : ng = mid print(ceil(ng))" p02598,s406071524,Accepted,"# ng, ok = 0, 10**9+1 n,k = map(int, input().split()) al = list(map(int, input().split())) ng, ok = 0, 10**9+1 while abs(ok-ng) > 1: mid = (ok+ng)//2 ok_flag = True # ... cnt = 0 for a in al: cnt += (a-1)//mid if cnt <= k: ok = mid else: ng = mid print(ok) " p02598,s607397476,Accepted,"n, k = map(int, input().split()) A = [*map(int, input().split())] ng, ok = 0, max(A) # (ng,ok] = (l,r] while ok - ng > 1: m = (ng + ok) // 2 c = 0 for a in A: c += (a-1) // m if c <= k: ok = m else: ng = m print(ok) " p02598,s453175829,Accepted,"from math import floor, ceil n, k = map(int, input().split()) a = list(map(int, input().split())) a.sort(reverse=True) l = 0 r = max(a) while r - l > 1: c = (l+r)//2 cnt = 0 for i in a: cnt += max(ceil(i/c) - 1, 0) if cnt <= k: r = c else: l = c print(r)" p02598,s256506224,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) def check(l): t = 0 for i in a: t += -(-i // l) - 1 return t <= k l, r = 0, 10 ** 9 + 1 while r - l > 1: mid = (l + r) // 2 + (l + r) % 2 if check(mid): r = mid else: l = mid print(r)" p02598,s027700508,Accepted,"n,k = map(int, input().split()) al = list(map(int, input().split())) ok, ng = 10**9+1, 0 while abs(ok-ng) > 1: mid = (ok+ng) // 2 # mid = (ok+ng) / 2 cnt = 0 for a in al: a_cnt = (a-1)//mid cnt += max(0,a_cnt) if cnt <= k: ok = mid else: ng = mid print(ok)" p02598,s113204294,Accepted,"n,k=map(int,input().split()) A=list(map(int,input().split())) ng=0 ok=max(A) while abs(ok-ng)>1: mid=(ok+ng)//2 now=0 for i in A: now+= i//mid-1 if i%mid==0 else i//mid if now> k : ng=mid else: ok=mid print(ok)" p02598,s587566942,Accepted,"import math N, K = list(map(int, input().split())) A = list(map(int, input().split())) r = 0 l = 1e9 test_count = 0 while (l - r > 1) : target_log_len = (r + l) // 2 cut_count = 0 for log_len in A: cut_count += (log_len - 1) // target_log_len if cut_count <= K: l = target_log_len else: r = target_log_len test_count += 1 if test_count > 100: break print(int(l))" 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) " p02598,s094271011,Accepted,"n,k,*a = map(int,open(0).read().split()) def func(b): c = k for i in a: c -= (i-1)//b if c < 0: return False return True l = 1 r = max(a) while(r>l): lr = (l+r)//2 if func(lr): r = lr else: l = lr + 1 print(r)" p02598,s245040467,Accepted,"from math import ceil n, k = [int(_) for _ in input().split()] a = [int(_) for _ in input().split()] # a.sort() l, r = 0, 10**9 while r-l > 1: m = (l+r)//2 c = 0 for i in range(n): if a[i] < m: continue c += a[i]//m-(a[i] % m == 0) # print(c, l, r, m) if c > k: l = m else: r = m print(r) " p02598,s853106291,Accepted,"import heapq import math n, k = map(int, input().split()) a = list(map(int, input().split())) a.sort(reverse=True) if k == 0: print(a[0]) exit(0) mean_a = sum(a) / k q = [] for aa in a: d = max(math.floor(aa / mean_a), 1) q.append((-aa/d, d)) k -= (d-1) heapq.heapify(q) for _ in range(k): aa, n = heapq.heappop(q) heapq.heappush(q, (aa*n/(n+1), n+1)) ans, _ = heapq.heappop(q) print(math.ceil(-ans)) " p02598,s002527610,Accepted,"import math N, K = (int(a) for a in input().split()) A = [int(a) for a in input().split()] def isOK(X): cutcount = 0 for i in range(N): cutcount += math.ceil(A[i] / X) - 1 if cutcount <= K: return True else: return False def binary_search(): left = 0 right = max(A) + 1 while (right - left) > 1: mid = left + (right - left) // 2 if (isOK(mid)): right = mid; else: left = mid; return right print(binary_search())" p02598,s962023493,Accepted,"n,k = map(int, raw_input().split()) ais = map(int, raw_input().split()) def p(m,ais,k): t = [ m, ais, k] for ai in ais: if ai > m: k-= ai / m return k >=0 lo,hi = 1, max(ais) while(lo < hi): med = (lo + hi)/2 if p(med, ais, k): hi = med else: lo = med + 1 print lo " p02598,s935466228,Accepted,"n, k = map(int, input().split()) log = list(map(int, input().split())) left = 0 right = 10**9 while right - left > 1: mid = (left + right) // 2 cut = 0 for i in range(n): cut += -(log[i]//-mid)-1 if cut > k: left = mid else: right = mid print(right)" p02598,s312727498,Accepted,"def check(N,target,A,K): cnt = 0 for i in range(N): cnt += -(-A[i]//target)-1 if cnt>K: return False return True def solve(): ans = 0 N, K = map(int, input().split()) A = list(map(int, input().split())) low = 1 high = 10**9+1 mid = (low+high)//2 while high>low+1: if check(N,mid,A,K): high = mid else: low = mid mid = (low+high)//2 if check(N,low,A,K): ans = low else: ans = high return ans print(solve())" p02598,s193325858,Accepted,"n,k= map(int,input().split()) *A,=map(int,input().split()) l,r=0,10**9 while r-l>1: c=(l+r)//2 if sum(-(-a//c)-1 for a in A)<=k:r=c else:l=c print(r) " 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)" p02598,s304349934,Accepted,"from sys import stdin import numpy as np n, k = map(int, stdin.readline().split()) a = np.array(stdin.readline().split(), dtype=np.int64) ng = 0 ok = 10 ** 9 + 1 while ok - ng > 1: mid = (ok + ng) >> 1 if np.sum(0 - - a // mid - 1) <= k: ok = mid else: ng = mid print(ok) " p02598,s970958990,Accepted,"import math n,k=map(int,input().split()) a=list(map(int,input().split())) x0=0 x1=10**9 while(1): sum=0 mid=(x0+x1)//2 for i in range(n): sum+=math.ceil(a[i]/mid)-1 if(sum<=k): x1=mid if(sum>k): x0=mid if(x0+1==x1): print(x1) break" p02598,s295275771,Accepted,"N, K = map(int, input().split("" "")) logs = list(map(int, input().split("" ""))) def cal( max_length ): cut_count = 0 for l in logs : cut_count += (l//max_length -1) if l % max_length != 0 : cut_count += 1 return cut_count <= K i = 1 j = max(logs) while i < j : m = (i+j)//2 if cal(m) : j = m else : i = m+1 print(i) " p02598,s900624354,Accepted,"(N,K) = map(int,input().split()) l = input().split() max = 0 for i in range(N): l[i]= int(l[i]) if max <= l[i]: max = l[i] lb = 0 ub = max def cut(m): k = 0 for i in range(N): k += -((-1*l[i])//m)-1 return k while ub - lb > 1: if cut((ub+lb)//2)>K: lb = (ub+lb)//2 else: ub = (ub+lb)//2 print(ub) " p02598,s938538625,Accepted,"import numpy as np N, K = [int(x) for x in input().split()] A = np.array([int(x) for x in input().split()]) I = np.array([1] * N) L = np.max(A) ans = L low = 1 high = L while 1: if low == high: ans = low break mid = (low + high) // 2 if np.sum((A - I) // mid) <= K: high = mid else: low = mid + 1 print(ans)" p02598,s699207558,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) import sys import math if sum(A) <= N+K: print(1) sys.exit() lt = 1 rt = 10**9 def det(x): if sum([math.ceil(A[i]/x) for i in range(N)]) <= N+K: return True else: return False while rt - lt > 1: ct = (lt + rt) // 2 if det(ct): rt = ct else: lt = ct print(rt)" p02598,s926113739,Accepted,"n, k = map(int, input().split()) A = list(map(int, input().split())) max_a = max(A) min_a = 0 while abs(max_a - min_a) > 1: cnt = 0 target_length = (max_a + min_a)//2 for a in A: cut_num = (a + target_length - 1)//target_length cnt += cut_num - 1 if cnt > k: min_a = target_length else: if target_length - min_a == 1: print(target_length) exit() max_a = target_length print(max_a)" p02598,s764275215,Accepted,"from heapq import heappush, heappop, heapify import math N, K = map(int, input().split()) A = list(map(int, input().split())) l = 0 r = 10 ** 9 def check(m): now = 0 for i in range(N): #A[i]-1してるのは、たとえばm=3のときは4,7から回数が増えるため now += (A[i]-1) // m return now <= K #差が1になったら終了 while r - l > 1: m = (l + r) // 2 if check(m): r = m else: l = m print(r)" p02598,s375025821,Accepted,"import math N,K = map(int, input().split()) A_list = list(map(int, input().split())) lb = 0 ub = 10**9 for i in range(100): middle = (lb + ub)/2 sumi = -N for a in A_list: sumi += math.ceil(a/middle) if sumi <= K: ub = middle else: lb = middle print(math.ceil(middle))" p02598,s082135178,Accepted,"def main(): n,k = map(int,input().split()) A = list(map(int,input().split())) left = 0 right = max(A) while abs(right-left)>1: cent = (right+left)//2 ct = 0 for a in A: ct+=(a-0.1)//cent if ct <= k: right=cent else: left=cent print(right) main()" p02598,s652907684,Accepted,"from bisect import bisect_left,bisect N, K = map(int, input().split()) A = list(map(int, input().split())) A.sort() def is_ok(arg): L = bisect(A, arg) cnt = 0 for i in range(L, N): p, q = divmod(A[i], arg) if q == 0: cnt += p-1 else: cnt += p return cnt <= K ng = 0 ok = max(A) + 1 def m_bisect(ng, ok): while (abs(ok - ng) > 1): mid = (ok + ng) // 2 if is_ok(mid): ok = mid else: ng = mid return ok print(m_bisect(ng, ok))" p02598,s905783279,Accepted,"n,k=list(map(int,input().split())) m=list(map(int,input().split())) import math def pos(h): p=0 for i in range(n): p+=math.ceil(m[i]/h)-1 return bool(p<=k) l,r=1,max(m) while l m: k += a//m if a % m == 0: k -= 1 if k <= K: return True else: return False l, r = 10**19, 1 while abs(r-l) > 1: m = (l+r)//2 if isOk(m): l = m else: r = m if isOk(r): print(r) else: print(l) " p02598,s277650005,Accepted,"from math import * def isok(x): res=0 for i in range(N): if A[i]<=x: continue res+=floor(A[i]/x) if res<=K: return True else: return False N,K=map(int,input().split()) A=list(map(int,input().split())) ng,ok=0,10**10 while(ok-ng>1): mid=(ok+ng)//2 if isok(mid): ok=mid#最大をmid以下にするのが可能かどうか else: ng=mid print(ok)" p02598,s773850971,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) l = 0 r = 10**9+1 def ok(x): cnt = 0 for b in a: cnt += (b//x) if b%x == 0: cnt -= 1 return cnt <= k while r-l > 1: md = (l+r)//2 if ok(md): r = md else: l = md print(r)" p02598,s646664191,Accepted,"n,k=map(int,input().split()) a=list(map(int,input().split())) l=0 r=1e9+5 while l+1!=r: m = (l+r)//2 cnt = 0 for x in a: cnt += (x-1)//m if cnt <= k: r = m else: l = m print(int(r))" p02598,s697158558,Accepted,"from math import ceil N,K = map(int,input().split()) A = list(map(int,input().split())) lb = 0 ub = max(A) while True: X = (ub+lb)/2 count = 0 for i in range(N): count += ceil(A[i]/X-1) if count > K: lb = X else: ub = X if ceil(ub) == ceil(lb): print(ceil(ub)) exit()" p02598,s352399505,Accepted," def resolve(): def is_ok(mid): cnt = 0 for a in A: cnt += (a-1)//mid return cnt <= K N, K = map(int, input().split()) A = list(map(int, input().split())) ok = max(A) ng = 0 while ok - ng > 1: mid = (ok+ng)//2 if is_ok(mid): ok = mid else: ng = mid print(ok) if __name__ == ""__main__"": resolve()" 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)" p02598,s163727083,Accepted,"n,k=map(int,input().split()) a=list(map(int,input().split())) ok=max(a) ng=0 while ok-ng>1: mid=(ok+ng)//2 cnt=0 for i in range(n): num=a[i] cnt+=-(-num//mid)-1 if cnt<=k: ok=mid else: ng=mid print(ok)" 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)" p02598,s868885731,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) A.sort() hi = 10**18 lo = 0 while hi - lo > 1: mid = (hi + lo) // 2 cut = 0 for i in range(N): cut += (A[i] + mid - 1) // mid - 1 if cut <= K: hi = mid else: lo = mid print(hi)" p02598,s791918424,Accepted," N, K = map(int, input().split()) A = list(map(int, input().split())) def check(x): cnt = 0 for a in A: cnt += (a + x - 1) // x - 1 return cnt <= K left = 0 right = 10 ** 9 while right - left > 1: mid = (left + right) // 2 if check(mid): right = mid else: left = mid print(right)" p02598,s858783862,Accepted,"from math import ceil n, k = map(int, input().split()) a = list(map(int, input().split())) def c(x): cnt=0 for i in a: cnt += i // x return cnt<=k l, r = 0, max(a) for i in range(100): mid = (l + r) / 2 if c(mid): r = mid else: l = mid print(ceil(l))" p02598,s334603321,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,K = MI() A = LI() left = 0 right = max(A) # 可能 while left + 1 < right: mid = (left + right)//2 if sum((A[i]+mid-1)//mid - 1 for i in range(N)) <= K: right = mid else: left = mid print(right) " p02598,s696488259,Accepted,"n, k, *aa = map(int, open(0).read().split()) imp_length = 0 psbl_length = max(aa) while psbl_length - imp_length > 1: mid = (psbl_length + imp_length) // 2 cost = sum(0 - -a // mid - 1 for a in aa) if cost <= k: psbl_length = mid else: imp_length = mid print(psbl_length)" p02598,s482894709,Accepted,"def check(N,target,A,K): cnt = 0 for i in range(N): cnt += -(-A[i]//target)-1 if cnt>K: return False return True def solve(): ans = 0 N, K = map(int, input().split()) A = list(map(int, input().split())) low = 1 high = 10**9+1 mid = (low+high)//2 while high>low+1: if check(N,mid,A,K): high = mid else: low = mid mid = (low+high)//2 if check(N,low,A,K): ans = low else: ans = high return ans print(solve()) " p02598,s047032952,Accepted,"# 2butan renshuu 0812 def f(m): cut=0 for aa in a: cut+=(aa-1)//m if cut > k: return False return True n,k=map(int,input().split()) a=list(map(int,input().split())) l=0 r=10**9+1 while r-l>1: m=(l+r)//2 # right move if f(m): r=m else: l=m print(r) " p02598,s514042820,Accepted,"import math #切る回数を足してK以下ならOK def ok(l): x =sum([math.ceil(a/l) -1 for a in A]) if x <=K: return True # else: # return False # 初期入力 import bisect import sys input = sys.stdin.readline #文字列では使わない N,K = map(int, input().split()) A = list(map(int, input().split())) #2分探索 bottom,top =0,max(A) while top -bottom >1: mid =(top +bottom)//2 if ok(mid): top =mid else: bottom =mid print(top)" 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))" p02598,s359623474,Accepted,"import sys import heapq import math import fractions import bisect import itertools from collections import Counter from collections import deque from operator import itemgetter def input(): return sys.stdin.readline().strip() def mp(): return map(int,input().split()) def lmp(): return list(map(int,input().split())) n,k=map(int,input().split()) a=lmp() def ok(s): c=0 for i in a: c+=-(-i//s)-1 return c<=k l=0 r=max(a) while r>l+1: md=(r+l)//2 if ok(md): r=md else: l=md print(r)" p02598,s700959782,Accepted,"n,k=map(int,input().split()) A=list(map(int,input().split())) l=0 r=max(A)+1 while r-l>1: m=(l+r)//2 cut=0 for i in range(n): cut+=((A[i]+m-1)//m)-1 if cut>k: l=m else: r=m print(r) " p02598,s634400281,Accepted,"import math N, K = map(int, input().split()) As = list(map(int, input().split())) r = max(As) if K == 0: print(r) exit() l = 1 while l < r: mid = (r + l)//2 cnt = 0 for a in As: cnt += math.ceil(a/mid) - 1 if cnt <= K: r = mid else: l = mid + 1 print(r)" p02598,s660159737,Accepted,"import math import heapq n,k=map(int,input().split()) a=list(map(int,input().split())) SUM=sum(a) ans=[] y=k for i in range(n): x=a[i]*k//SUM ans.append([-math.ceil(a[i]/(1+x)),x,i]) y-=x heapq.heapify(ans) #print(y) #print(ans) for i in range(y): temp=heapq.heappop(ans) temp[0]=-math.ceil(a[temp[2]]/(2+temp[1])) temp[1]+=1 heapq.heappush(ans,temp) temp=heapq.heappop(ans) print(-temp[0])" p02598,s316241713,Accepted,"from math import ceil, floor n,k = map(int,input().split()) a = list(map(int,input().split())) l = 0 r = 10**9 m = (l+r)//2+1 for i in range(100): # print(l,m,r) cnt = 0 for j in a: cnt += (ceil(j/m)-1) # print(cnt) # print(l,m,r,cnt) if cnt <= k: r = m m = ceil((l+r)/2) else: l = m m = ceil((l+r)/2) print(m) " p02598,s193303550,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) def C(x): return sum([max((Ai + x - 1) // x - 1, 0) for Ai in A]) A.sort() left = 1 right = A[-1] while left + 1 < right: mid = (left + right) // 2 S = C(mid) if S <= K: right = mid else: left = mid print(left if C(left) <= K else right) " p02598,s361461749,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) def check(l): cnt = 0 for _ in a: cnt += _ // l if _ % l != 0: cnt += 1 cnt -= 1 if cnt <= k: return True else : return False """""" left: ng right: ok """""" def binary(ng, ok): while ok - ng > 1: mid = (ng + ok) // 2 if check(mid): ok = mid else: ng = mid return ok print(binary(0, max(a)))" p02598,s003860119,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) # bottom...最小0ずつ切る(不可能な方)、top...最大max(a)ずつ切る(可能な方) bottom, top = 0, max(a) while top - bottom > 1: mid = (top+bottom) // 2 cnt = 0 for i in a: cnt += i//mid if i%mid == 0: cnt -= 1 if cnt <= k: top = mid else: bottom = mid print(top) " 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) " p02598,s907949826,Accepted,"import sys import math input = sys.stdin.readline def can(arr, m, K): need = 0 for x in arr: if x > m: need += int(x // m) return need <= K N, K = map(int, input().split()) arr = list(map(int, input().split())) lo = 1 hi = int(1e9) + 1 while (lo < hi): m = int((lo + hi) // 2) if (can(arr, m, K)): hi = m else: lo = m + 1 print(lo) " p02598,s207459511,Accepted,"import math n, k = map(int, input().split()) a = list(map(int, input().split())) a.sort() l = 1 r = 1000000000 while l < r: m = (l+r)//2 cnt = 0 for i in a: c = math.ceil(i/m)-1 cnt += c if cnt > k: l = m + 1 else: r = m print(l)" p02598,s204658608,Accepted,"def solve(): N, K = map(int,input().split()) A = list(map(int,input().split())) left = 0 right = 10 ** 9 while right - left > 1: mid = (right+left) // 2 cnt = 0 for a in A: cnt += (a-1) // mid if cnt <= K: right = mid else: left = mid print(right) if __name__ == '__main__': solve() " p02598,s077469338,Accepted,"N, K = map(int, input().split()) *A, = map(int, input().split()) def f(t): if t!=0: c = 0 for i in A: c += i//t if i!=t else 0 return c<=K else: return all(i<=t for i in A) left, right = -1, 10**10 while right-left>1: m = (right+left)//2 if f(m): right = m else: left = m print(right) " 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) " p02598,s948203054,Accepted,"import math n, k = map(int, input().split()) a = list(map(int, input().split())) def binary_search(ng=0, ok=max(a)): if ok - ng < 2: return ok mid = (ok + ng) // 2 cnt = 0 for i in a: cnt += math.ceil(i / mid) - 1 if cnt <= k: return binary_search(ng, mid) else: return binary_search(mid, ok) print(binary_search())" p02598,s586209544,Accepted,"N,K = map(int, input().split()) A = [int(i) for i in input().split()] """""" 切る回数は広義単調減少になる にぶたん """""" def is_dekiru(L): cnt = 0 for a in A: cnt += (a + L - 1) // L - 1 return cnt <= K ok = 10 ** 9 + 10 ng = 0 while (ok - ng) > 1: mid = (ok + ng) // 2 if is_dekiru(mid): ok = mid else: ng = mid print(ok)" p02598,s198413299,Accepted," N,K = map(int,input().split()) A = list(map(int,input().split())) def isable(n): tmp = 0 for i in range(N): tmp += (A[i]-0.5)//n if K >= tmp: return True else: return False left = 0 right = 10**9 while right-left != 1: if isable((right+left)//2): right=(right+left)//2 else: left=(right+left)//2 print(right)" p02598,s965392114,Accepted,"# coding: utf-8 import numpy as np def solve(*args: str) -> str: n, k = map(int, args[0].split()) A = np.array(tuple(map(int, args[1].split()))) l, r = 0, np.max(A) while l+1 < r: m = (l+r)//2 if k < np.sum(np.ceil(A/m)-1): l = m else: r = m return str(r) if __name__ == ""__main__"": print(solve(*(open(0).read().splitlines()))) " p02598,s997305641,Accepted,"def judge(A, x, k): ans = 0 for a in A: ans += a // x if a % x == 0: ans -= 1 if ans > k: return False return True n, k = map(int, input().split()) A = list(map(int, input().split())) l = 0 r = max(A) while r - l != 1: x = (r + l) // 2 if judge(A, x, k): r = x else: l = x print(r)" p02598,s419194465,Accepted,"n,k=map(int,input().split()) a=list(map(int,input().split())) # 二分探索の為のKey関数 def f(m): cut=0 for aa in a: cut+=(aa-1)//m if cut > k: return False return True l,r=0,10**9 while r-l>1: m=(l+r)//2 if f(m): r=m else: l=m print(r) " p02598,s609990024,Accepted,"n,k=map(int,input().split()) a=list(map(int,input().split())) def f(x): global a,n,k if x==0: return 10**10 ret=0 for i in range(n): #print(-((-a[i])//x)) ret+=(-((-a[i])//x)-1) return ret l,r=0,10**10 while l+1 1: cnt = 0 mid = (start + end) // 2 for a in A: cnt += math.ceil(a/mid) - 1 if cnt <= K: end = mid else: start = mid print(end) resolve()" p02598,s586023013,Accepted,"def main(): import sys def input(): return sys.stdin.readline().rstrip() n , k = map(int, input().split()) a = list(map(int, input().split())) def check(m): cnt = 0 for x in a: cnt += (x-1)//m return cnt <= k l, r = 0, max(a) while r-l > 1: m = (r+l)//2 if check(m): r = m else: l = m print(r) if __name__ == '__main__': main()" p02598,s681864769,Accepted,"N, K = map(int, input().split()) l = input().split() l2 = [int(i) for i in l] line1, line2 = 0, 10**9 while (line2-line1 > 1): x = int((line1 + line2) / 2) def f(x): now = 0 for i in range(N): now += int((l2[i]-1)/x) return now <= K if f(x)==True: line2 = x else: line1 = x print(line2)" p02598,s265799568,Accepted,"def check(lis,k,mid): for i in lis: if(i%mid==0): k+=1 k-=(i//mid) return k>=0 n,k=map(int,input().split()) lis=list(map(int,input().split())) a,b=1,max(lis) ans=b while(a<=b): mid=(a+b)//2 if(check(lis,k,mid)): ans=mid b=mid-1 else: a=mid+1 print(ans) " p02598,s583914948,Accepted," import sys sys.setrecursionlimit(10**7) readline = sys.stdin.buffer.readline def readstr():return readline().rstrip().decode() def readstrs():return list(readline().decode().split()) def readint():return int(readline()) def readints():return list(map(int,readline().split())) def printrows(x):print('\n'.join(map(str,x))) def printline(x):print(' '.join(map(str,x))) n,k = readints() a = readints() l = 0 r = 10**10 while r-l>1: m = (l+r)//2 x = [(a[i]-1)//m for i in range(n)] if sum(x)<=k: r = m else: l = m print(r) " 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))" 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) " 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) " p02598,s716473196,Accepted,"import math n,k = map(int,input().split()) a = list(map(int,input().split())) def cal(lis,x): an = 0 for i in range(len(lis)): an += (math.ceil(lis[i] / x) - 1) return an left = 0 right = 10**9 for i in range(100): m = (left + right) / 2 b = cal(a,m) if b > k: left = m else: right = m print(math.ceil(m))" 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))" p02598,s680090824,Accepted,"import math N,K=map(int,input().split()) A=[int(x) for x in input().split()] A=sorted(A) left=0 right=max(A) mid=max((left+right)//2,1) while(right-left>=1): numofcut=0 for i in range(N): numofcut+=math.ceil(A[i]/mid)-1 #print(numofcut) if numofcut>K: left=mid+1 else: right=mid mid=max((left+right)//2,1) if mid==1: break print(mid)" p02598,s228855918,Accepted,"import math n,k = map(int,input().split()) a_list = list(map(int,input().split())) min_num = 1 max_num = 10**9+1 while True: #print(min_num) x = int((min_num+max_num)/2) if sum([math.ceil(a/x)-1 for a in a_list])>k: min_num = x else: max_num = x if max_num-min_num<=1: break #print(x) if sum([math.ceil(a/min_num)-1 for a in a_list])>k: print(min_num+1) else: print(min_num)" p02598,s677970826,Accepted,"n,k=map(int,input().split()) *a,=map(int,input().split()) l,r=0,10**9 while r-l>1: m=(l+r)//2 t=0 for x in a: if x<=m: continue t+=(x+m-1)//m-1 if t<=k: r=m else: l=m print(r)" p02598,s462127043,Accepted,"n, k, *a = map(int, open(0).read().split()) def c(x): res = 0 for b in a: # bを最大がxになるように、できるだけ少ない回数で # だいたいb/x等分? res += 0 - - b // x - 1 return res <= k ng = 0 ok = 10 ** 10 while ok - ng > 1: mid = (ok + ng) >> 1 if c(mid): ok = mid else: ng = mid print(ok) " p02598,s008838492,Accepted,"n,k = map(int,input().split()) a = list(map(int,input().split())) ng = 0 ok = 10**9 while ng < ok-1: mid = (ng+ok)//2 count = sum((ai-1)//mid for ai in a) if count<=k: ok = mid else: ng = mid print(ok)" p02598,s366479150,Accepted,"import math n,k=map(int,input().split()) a=list(map(int,input().split())) l,r=0,max(a) while 1k:l=m else:r=m print(r)" p02598,s159781447,Accepted,"n,k,*a=map(int,open(0).read().split()) l,r=0,10**9 while~l+r: x=l+r>>1 if-sum(-b//x+1for b in a)>k:l=x else:r=x print(r)" p02598,s465477582,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) # にぶたん: 答えをx以下にできるか? ok, ng = 10 ** 9 + 1, 0 while abs(ok - ng) > 1: x = (ok + ng) // 2 cnt = 0 for a in A: if a <= x: continue cnt += a // x if cnt > K: ng = x break else: ok = x print(ok) " p02598,s329314536,Accepted,"import math def check(l, x, k): c = 0 for a in l: c += math.ceil(a/x)-1 if c <= k: return True else: return False n,k=map(int, input().split()) a = list(map(int, input().split())) ok = max(a) ng = 0 while abs(ok-ng)>1: mid = (ok+ng)//2 if check(a, mid, k): ok = mid else: ng = mid print(ok) " p02598,s400293855,Accepted,"n,k,*a=map(int,open(l:=0).read().split()) r=10**9 while~l+r:x=l+r>>1;l,r,*_=(l,x,r)[-sum(-b//x+1for b in a)>k::] print(r)" p02598,s189612087,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) hi = 10 ** 9 lo = 0 while hi - lo > 1: mid = (hi + lo) // 2 cnt = 0 for v in a: cnt += (v + mid - 1) // mid - 1 if cnt <= k: hi = mid else: lo = mid print(hi)" p02598,s836269652,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) ok = 10**9 ng = 0 while ng+1 < ok: tmp = (ok+ng)//2 k = 0 for a in A: if a%tmp == 0: k += a//tmp -1 else: k += a//tmp if k <= K: ok = tmp else: ng = tmp print(ok)" p02598,s130143723,Accepted,"n,k=map(int,input().split()) a=list(map(int,input().split())) ng=0 ok=max(a)+1 while ok-ng>1: mid=(ng+ok)//2 count=0 for i in range(n): if a[i]%mid==0: count+=((a[i]//mid)-1) else: count+=(a[i]//mid) if count>k: ng=mid else: ok=mid print(ok)" p02598,s536644022,Accepted,"import sys input = sys.stdin.readline def main(): n, k = map(int, input().split()) A = list(map(int, input().split())) l = 0 r = max(A) while l+1 < r: count = 0 length = (l+r) // 2 for a in A: count += (a-1) // length if count <= k: r = length else: l = length print(r) if __name__ == ""__main__"": main() " p02598,s078661922,Accepted,"def check(List,mid): tmp=0 for l in List: tmp+=(-(-l//mid)-1) return tmp n,k=map(int,input().split()) a=list(map(int,input().split())) lo=0 hi=max(a)+1 while hi - lo > 1: mid=(lo+hi)//2 if check(a,mid)<=k: hi=mid else: lo=mid print(hi)" p02598,s719467557,Accepted,"#!/usr/bin/env python3 import sys input=sys.stdin.readline n,k=map(int,input().split()) arr=list(map(int,input().split())) l=0 r=max(arr)+1 while r-l!=1: persuit=(r+l)//2 cnt=0 for val in arr: if val<=persuit: continue if val%persuit==0: cnt+=val//persuit-1 else: cnt+=val//persuit if cnt<=k: r=persuit else: l=persuit print(r) " p02598,s782864913,Accepted,"def is_good(mid, key): return sum((a + mid - 1) // mid for a in A) - N <= key def binary_search(bad, good, key): while good - bad > 1: mid = (bad + good) // 2 if is_good(mid, key): good = mid else: bad = mid return good N, K, *A = map(int, open(0).read().split()) print(binary_search(0, 1_000_000_000, K)) " p02598,s551650607,Accepted,"# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..) import sys from math import ceil def main(N, K, A): def cut_times(longest): return sum(a // longest for a in A if a > longest) under = 0 r = 10**9 for i in range(100): m = (under + r) / 2 if cut_times(m) > K: under = m else: r = m print(ceil(r - 10**-10)) if __name__ == '__main__': input = sys.stdin.readline N, K = map(int, input().split()) *A, = map(int, input().split()) main(N, K, A) " p02598,s155166862,Accepted,"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 counter = 0 for i in range(N): if A[i] > mid: counter += A[i] // mid if counter <= K: r = mid else: l = mid + 1 print(l)" p02598,s260526748,Accepted,"from math import ceil n, k = map(int, input().split()) a = list(map(int, input().split())) ok = 10**10 ng = 0 def judge(x): cnt = 0 for aa in a: cnt += (x + aa - 1) // x - 1 # print(cnt) return cnt <= k # print(judge(4)) # print(judge(5)) # print(judge(3)) while abs(ok - ng) > 1: mid = (ok + ng) // 2 if judge(mid): ok = mid else: ng = mid print(ok) " p02598,s093255154,Accepted,"# coding: utf-8 # Your code here! import sys readline = sys.stdin.readline read = sys.stdin.read n,k,*a = [int(i) for i in read().split()] def check(x,k): #k回切って最短を長さ x 以下にできるならOK v = 0 for ai in a: v += (ai-1)//x return v <= k ok = 10**9 ng = 0 while ok-ng > 1: mid = (ok+ng)//2 if check(mid,k): ok = mid else: ng = mid print(ok) " p02598,s244173430,Accepted,"N,K = map(int,input().split()) A = list(map(int,input().split())) def check(x): count = 0 for Ai in A: count += (Ai - 1)//x return count <= K #めぐる式そのまま ok = 10**9 ng = 0 while ok-ng > 1: mid = (ok + ng)//2 if check(mid): ok = mid else: ng = mid print(ok)" p02598,s131722314,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) def check(x): c = 0 for i in range(n): c += a[i]//x if a[i]%x == 0: c -= 1 if c <= k: return True else: return False mx = max(a) mn = 0 ans = [mx] while mn <= mx: m = (mx+mn)//2 if m == 0: if check(1): ans.append(1) break if check(m): mx = m - 1 ans.append(m) else: mn = m + 1 print (min(ans)) " p02598,s195497019,Accepted,"I=lambda:list(map(int,input().split())) n,k=I() l=I() low=1 high=max(l) while lowk: low=mid+1 else: high=mid print(low) " p02598,s850088374,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) left = 0 right = max(a) while right - left > 1: mid = (right + left) // 2 tmp = 0 for i in a: tmp += (i - 1) // mid if tmp <= k: right = mid else: left = mid print(right)" p02598,s236098035,Accepted,"from math import * def trycut(val): if val == 0 : return float('inf') ret = 0 for i in range(n): ret += (a[i]+val-1)//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) if cut <= k: high = mid-1 ans = mid else: low = mid+1 print(ans) " p02598,s463534699,Accepted,"import math N,K = map(int,input().split()) A = list(map(int,input().split())) m = 1 M = max(A) while(M-m>0): mm = 0 mid = (M+m)//2 for i in range(N): mm += math.ceil(A[i]/mid)-1 if mm>K: m = mid+1 else: M = mid print(math.ceil(m)) " p02598,s867106448,Accepted,"n,k = map(int,input().split()) a = list(map(int,input().split())) leq,high = 0,1e10 while high-leq > 1: l = int((leq+high)/2) cnt = 0 for ai in a: cnt += int((ai-1)/l) if cnt>k: leq = l else: high = l print(high)" p02598,s375587857,Accepted,"import math n, k = map(int,input().split()) list = [int(x) for x in input().split()] list.sort() l = 0 r = max(list) while r - l > 1: count = 0 x = (r + l)//2 for i in range(len(list)): if x >= list[i]: continue count += math.ceil(list[i]/x) - 1 if count <= k: r = x else: l = x print(r) " p02598,s190687007,Accepted,"import math N, K = list(map(int,input().split())) A = list(map(int,input().split())) def is_ok(mid): cnt = 0 for i in range(N): cnt += (math.ceil(A[i] / mid) - 1) return cnt <= K def binary_search(left, right): while (abs(right - left) > 1): mid = (left + right) // 2 if is_ok(mid): right = mid else: left = mid return right if K == 0: print(max(A)) else: left = max(A) right = 0 ret = binary_search(right, left) print(ret)" p02598,s859642820,Accepted,"n, k = map(int, input().split()) A = list(map(int, input().strip().split())) b = 0 e = max(A) L = e // 2 while e - b > 1: L = (e + b) // 2 m = sum(list(map(lambda x: (x - 1) // L, A))) if m <= k: e = L else: b = L print(e) " p02598,s702826650,Accepted,"from math import ceil N, K = map(int, input().split()) A = list(map(int, input().split())) try: up, lo = ceil(sum(A) / K), 0 while up - lo > 1: mid = (up+lo) // 2 cnt = 0 for a in A: cnt += ceil(a / mid)-1 if cnt > K: lo = mid else: up = mid print(up) except ZeroDivisionError: print(max(A))" p02598,s236521626,Accepted,"n, k = map(int, input().split()) *arr, = map(int, input().split()) lo = 1 hi = max(arr) + 1 def can(arr, rem_length, k): cnt = 0 for v in arr: cnt += (v - 1) // rem_length if cnt <= k: return True return False while lo < hi: mid = (lo + hi) // 2 if can(arr, mid, k): hi = mid else: lo = mid + 1 print(lo) " p02598,s892716461,Accepted,"import sys , math N,K=list(map(int, input().split())) Ws=list(map(int, input().split())) Ws.sort(reverse=True) l=0 r=10**9 def check (m): now=0 for i in range(N): now += (Ws[i] - 1) // m return now <= K while r - l > 1: m = ( l + r ) // 2 if check(m): r = m else: l = m print(r) " p02598,s826226131,Accepted,"n,k=map(int,input().split()) A=list(map(int,input().split())) r=max(A) l=0 while l+1k: l=mid else: r=mid print(r)" p02598,s661838810,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) if count <= k: r = mid else: l = mid+1 print(l)" p02598,s567597113,Accepted,"def binary_search(key): ''' 条件を満たす最小のindexを求める ''' right = 10 ** 9 + 1 left = 0 while right - left > 1: mid = (right + left) // 2 cnt = 0 for v in a: cnt += (v + mid - 1) // mid - 1 if cnt <= key: right = mid else: left = mid return right n, k = map(int, input().split()) a = list(map(int, input().split())) print(binary_search(k))" p02598,s097601101,Accepted,"n,k=list(map(int,input().split())) alst=list(map(int,input().split())) ok=max(alst) ng=0 while abs(ok-ng)>1: cen=(ok+ng)//2 cnt=0 for a in alst: cnt+=(a+cen-1)//cen-1 if cnt<=k: ok=cen else: ng=cen print(ok)" p02598,s358505269,Accepted,"import sys input = sys.stdin.buffer.readline n,k = map(int,input().split()) a = tuple(map(int,input().split())) ok = 10**10 ng = 0 while ok-ng > 1: m = (ok+ng)//2 c = 0 for e in a: if e%m == 0: c += e//m - 1 else: c += e//m if c <= k: ok = m else: ng = m print(ok) " p02598,s181510108,Accepted,"n,k = map(int,input().split()) L = list(map(int,input().split())) def A(x): cnt = 0 for i in range(n): if L[i]%x == 0: cnt +=L[i]//x-1 else: cnt +=L[i]//x return cnt <= k lower = 0 upper = max(L) while upper - lower > 1: mid = (lower + upper)//2 if A(mid): upper = mid else: lower = mid print(upper)" p02598,s100255065,Accepted,"import math N, K = map(int, input().split()) A = list(map(float, input().split())) min_A = 0 max_A = 10**10 while( max_A - min_A > 1): now = (min_A + max_A) // 2 temp = 0 for i in A: if i > now: temp += (i // now) if temp > K: min_A = now else: max_A = now print(int(min_A) + 1)" p02598,s891103736,Accepted,"N, K = map(int, input().split()) logs = list(map(int, input().split())) l, r = 0, int(1e9) def count_cut(log, size): return (log - 1) // size while r - l > 1: pivot = (r + l) // 2 count = sum(count_cut(log, pivot) for log in logs) if K < count: l = pivot elif count <= K: r = pivot print(r)" p02598,s710406316,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) max_l = 10**9 min_l = 0 while max_l - min_l != 1: count = 0 mean = (max_l+min_l)//2 for i in range(n): count += -(-a[i]//mean)-1 if count <= k: max_l = mean else: min_l = mean print(max_l)" p02598,s026378303,Accepted,"n, k = map(int, input().split()) *A, = map(int, input().split()) a, b = 0, 10**9 while b - a > 1: x = (a + b) // 2 cut = 0 for i in range(n): cut += -(-A[i] // x) - 1 if cut <= k: b = x else: a = x print(b) " p02598,s806564489,Accepted,"# coding: utf-8 def solve(*args: str) -> str: n, k = map(int, args[0].split()) A = tuple(map(int, args[1].split())) l, r = 0, max(A) while l+1 < r: m = (l+r)//2 cnt = 0 for a in A: cnt += -(-a//m)-1 if k < cnt: l = m else: r = m return str(r) if __name__ == ""__main__"": print(solve(*(open(0).read().splitlines()))) " p02598,s985524865,Accepted,"n, k=map(int, input().split()) a=list(map(int, input().split())) right=max(a) left=0 def logs(a, n, x): sm=0 for i in range(n): sm+=(a[i]-1)//x if sm<=k: return True else: return False def binary_search(left, right): while right - left > 1: center=(left+right)//2 if logs(a, n, center): right=center else: left=center return right print(binary_search(left, right))" p02598,s813413607,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) sa = np.sum(a) mina = sa//(n+k) maxa = np.max(a) while maxa > mina+1: mid = (mina+maxa)//2 div = np.sum(np.ceil(a/mid-1)) #print(mina,maxa,div) if div > k: mina = mid else: maxa = mid print(maxa)" p02598,s566583934,Accepted,"from heapq import heappush, heappop, heapify n, k = map(int, input().split()) a = list(map(int, input().split())) def check(x): # 最長の丸太をx以下にできるか # 任意の丸太をx以下にできるか cnt = sum([(ai - 1) // x for ai in a]) return cnt <= k lb = 0 # False ub = max(a) # True while ub - lb > 1: mid = (ub + lb) // 2 # print(mid, check(mid)) if check(mid): ub = mid else: lb = mid print(ub) " p02598,s487204905,Accepted,"import math def possible(l, a, k): for x in a: k -= x//l if x%l==0: k += 1 return k>=0 n, k = map(int, input().split()) a = [int(x) for x in input().split()] mini = 1 maxi = 10**9+7 while(mini!=maxi): mid = (mini+maxi)//2 if possible(mid, a, k): maxi = mid else: mini = mid + 1 print(mini) " p02598,s145460147,Accepted,"from sys import stdin import numpy as np n, k = map(int, stdin.buffer.readline().split()) a = np.fromstring(stdin.buffer.read(), dtype=np.int64, sep=' ') ng = 0 ok = 10 ** 9 + 1 while ok - ng > 1: mid = (ok + ng) >> 1 if np.sum(np.ceil(a / mid) - 1) <= k: ok = mid else: ng = mid print(ok) " p02598,s484579203,Accepted,"import math n, k = [int(i) for i in input().split()] a = [int(i) for i in input().split()] # https://qiita.com/hamko/items/794a92c456164dcc04ad def binary_search(a, k): ng = 0 # left:絶対に達成不可能なもの ok = max(a) # right:絶対に達成可能なもの while (ok - ng > 1): mid = (ng + ok) // 2 if sum([math.ceil(a[i]/mid)-1 for i in range(n)]) <= k: ok = mid else: ng = mid return ok print(binary_search(a, k))" p02598,s655691857,Accepted,"import sys n, k = map(int, input().split()) a = list(map(int, input().split())) if k == 0: print(max(a)) sys.exit() def check(t): if t == 0: return False ans = 0 for ai in a: if ai > t: ans += ai // t return ans <= k l = 0 r = 10 ** 9 + 1 while r - l > 1: mid = (r + l) // 2 if check(mid): r = mid else: l = mid if check(l): print(l) else: print(r) " p02598,s693333514,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) l = 1 r = max(A) while l != r: mid = (r + l) // 2 count = 0 for log in A: count += (log - 1) // mid if count <= K: r = mid else: l = mid + 1 print(r) " p02598,s225297400,Accepted,"n, k = map(int, input().split()) a_i = list(map(int, input().split())) def f(n): cnt = 0 for a in a_i: cnt += (a - 1) // n if cnt > k: return False else: return True l, r = 0, max(a_i) while True: if r - l <= 1: break val = (l + r) // 2 if f(val) == True: r = val else: l = val print(r)" p02598,s393086828,Accepted,"n,k=map(int,input().split()) a=list(map(int,input().split())) l,r=10**9,0 while l-r>1: t=(l+r)//2 if sum((i-1)//t for i in a)>k: r=t else: l=t print(l)" p02598,s402647646,Accepted,"import sys input=sys.stdin.readline n,k=map(int,input().split()) a=list(map(int,input().split())) l=1 r=10**9 import math for i in range(100): temp=0 m=(r+l)/2 for j in a: temp+=j//m if temp<=k: r=m else: l=m print(math.ceil(m))" p02598,s958518226,Accepted,"def abc174_e(): n, k = map(int, input().split()) A = list(map(int, input().split())) if k == 0: return max(A) lower, upper = 0, 10**9 while upper - lower > 1: x = (upper + lower) // 2 cnt = 0 for a in A: cnt += a // x if a % x == 0: cnt -= 1 if cnt > k: break if cnt > k: lower = x else: upper = x return upper if __name__ == '__main__': print(abc174_e())" p02598,s175535809,Accepted,"import math def main(): _, k = map(int, input().split()) arr = list(map(int, input().split())) l, r = 1, 1000000000 while l < r: m = (l + r) // 2 cnt = 0 for val in arr: cnt += math.ceil(val / m) - 1 if cnt > k: l = m + 1 else: r = m print(l) if __name__ == '__main__': main()" p02598,s120472254,Accepted,"N,K=map(int,input().split()) alist=list(map(int,input().split())) #print(alist) def num_cut(x): if x==0: return float(""inf"") ret=0 for a in alist: ret+=-(-(a-x)//x) return ret #for i in range(1,max(alist)): # print(i,num_cut(i)) l=1 r=max(alist)+1 while l<=r: mid=(l+r)//2 #print(l,mid,r) if num_cut(mid-1)>K and num_cut(mid)<=K: print(mid) break elif num_cut(mid)<=K: r=mid else: l=mid" p02598,s389161888,Accepted,"N, K = list(map(int, input().split())) A = list(map(int, input().split())) U = max(A)+1 L = 0 def can(x, K): ct = 0 for i in range(N): ct += (A[i]-1)//x if ct <= K: return True else: return False while U-L > 1: x = (U+L+1)//2 if can(x, K): U = x else: L = x print(U) " p02598,s939994198,Accepted,"n, k = map(int, input().split()) list_A = list(map(int, input().split())) l, r = 0, max(list_A) while l + 1 < r: m, cnt = (r + l) // 2, 0 for a in list_A: cnt += (a-1)//m if cnt > k: l = m else: r = m print(r)" p02598,s372639526,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) ng = 0 ok = 10 ** 9 + 1 def check(x): cnt = 0 for l in a: cnt += (l-1)//x return cnt <= k while abs(ok-ng) > 1: m = (ok + ng) // 2 if check(m): ok = m else: ng = m print(ok)" p02598,s359438634,Accepted,"import sys input = sys.stdin.readline N, K = map(int, input().split()) a = list(map(int, input().split())) def check(x): k = 0 for i in range(N): if a[i] > x: k += a[i] // x return k <= K ok = 10 ** 9 + 1 ng = 0 while ok - ng > 1: m = (ok + ng) // 2 if check(m): ok = m else: ng = m print(ok)" p02598,s072629383,Accepted,"N,K = map(int,input().split()) A = list(map(int,input().split())) L = 0 R = max(A) while R-L > 0.001: X = (L+R)/2 m = 0 for i in range(N): c = A[i]/X if c == int(c): m += int(c) - 1 else: m += int(c) if m <= K: R = X else: L = X if int(R) - int(L) == 0: print(int(R)+1) else: print(int(R))" p02598,s605689537,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) def is_ok(arg): cnt = 0 for i in range(N): cnt += (A[i]-1)//arg if(cnt <= K): return True else: return False 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 ans = meguru_bisect(0, 10**9) print(ans)" p02598,s408495675,Accepted,"from math import * from collections import * from random import * from decimal import Decimal from bisect import * import sys input=sys.stdin.readline def lis(): return list(map(int,input().split())) def ma(): return map(int,input().split()) def inp(): return int(input()) n,k=ma() a=lis() l,h=0,max(a) while(l+1 1): mid = (ok + ng) // 2 if is_ok(mid): ok = mid else: ng = mid return ok n,k = map(int,input().split()) a = list(map(int,input().split())) print(meguru_bisect(0,10**9+1))" p02598,s789094871,Accepted,"n, k = [int(x) for x in input().split()] arr = [int(x) for x in input().split()] low, high = 0, max(arr) + 1 while high - low > 1: mid = (high + low) // 2 curr = 0 for i in arr: curr += (i - 1)//mid if curr > k: low = mid else: high = mid print(high) " p02598,s605347117,Accepted,"N, K = map(int, input().split()[:2]) arr = list(map(int, input().split()[:N])) def pos(X): sum = 0 for i in arr: sum += int(i/X) if i % X == 0: sum -= 1 return sum <= K low = 1 high = 10 ** 9 mid = 0 ans = 10**9 while low <= high: mid = int((low+high)/2) # print(low, mid, high) if pos(mid): ans = mid high = mid-1 else: low = mid+1 # print(pos(mid)) print(ans) " p02598,s558215275,Accepted,"from math import ceil N, K = map(int, input().split()) A = list(map(int, input().split())) def check(l): cnt = sum(ceil(a / l) - 1 for a in A) return cnt <= K lb, ub = 0, max(A) for _ in range(50): mid = (lb + ub) / 2 if check(mid): ub = mid else: lb = mid print(ceil(ub))" p02598,s337998357,Accepted,"n, k = map(int, input().split()) A = list(map(int, input().split())) right = 10**9 left=0 while right-left>1: mid=(left+right)//2 count = 0 for a in A: count+=a//mid if a%mid==0: count -=1 if count<=k: right = mid else: left = mid print(right) " p02598,s815077666,Accepted,"import math N, K = list(map(int, input().split())) A = list(map(int, input().split())) l, r = (A[0], 1) def is_ok(c): x = sum([math.ceil(a/c)-1 for a in A]) return x <= K l, r = max(A), 0 while l - r > 1: c = (l + r) // 2 if is_ok(c): l = c else: r = c print(l) " p02598,s548268660,Accepted,"import math n,k=map(int,input().split()) log=list(map(int,input().split())) a=0 b=max(log) if b==1: print(1) exit() c=(a+b)//2 while True: div=0 for i in range(n): div+=math.ceil(log[i]/c)-1 if div<=k: b=c c=(a+b)//2 else: a=c c=(a+b)//2 if c==a or c==b: break print(b)" p02598,s521172922,Accepted,"import sys input = sys.stdin.readline n,k=map(int,input().split()) a=list(map(int,input().split())) ok=10**10 ng=1 for i in range(40): chk=(ok+ng)//2 cnt=0 for j in range(n): cnt+=(a[j]+chk-1)//chk-1 if cnt > k: ng = chk else: ok = chk print(ok) " p02598,s580467934,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) a.sort(reverse=True) left = 0 # できない right = a[0] # できる while left+1 < right: mid = (left+right) // 2 cnt = 0 for i in range(n): if a[i]%mid == 0: cnt += a[i] // mid - 1 else: cnt += a[i] // mid if cnt > k: break if cnt > k: left = mid else: right = mid print(right)" p02598,s926555309,Accepted,"from math import ceil n, k, *A = map(int, open(0).read().split()) t = sum(A) / (n+k) A = [a for a in A if int(a/t) >= 1] X = [] for a in A: X.append(ceil(a / ceil(a/t))) X.append(ceil(a / int(a/t))) X.sort() print(X[sum(int(a/t)-1 for a in A) -k-1])" p02598,s424345253,Accepted,"_, k = map(int, input().split()) A = [*map(int, input().split())] ng, ok = 0, 1<<30 while ok - ng > 1: m = (ng + ok) // 2 if k < sum(map(lambda a: (a-1)//m, A)): ng = m else: ok = m print(ok) " p02598,s067121484,Accepted,"from math import ceil def main(): n, k = map(int, input().split()) a = list(map(int, input().split())) a.sort() ng = 0 ok = 10 ** 9 + 7 while ok - ng > 1: mid = (ok + ng) // 2 cnt = 0 for i in range(n): cnt += (a[i] - 1) // mid if cnt <= k: ok = mid else: ng = mid print(ceil(ok) if k > 0 else a[-1]) if __name__ == '__main__': main() " p02598,s497124226,Accepted,"import math N,K=map(int,input().split()) A=list(map(int, input().split())) l=0 r=max(A) while not l+1==r: x=(r+l)//2 k=0 for a in A: k+=math.ceil(a/x)-1 if k<=K: r=x else: l=x print(r)" p02598,s571512106,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) l = 0 r = 10**9 + 1 ref = 0 while r - l > 1: now = (l + r)//2 for i in a: ref += 0 - -i//now - 1 if ref <= k: ref = 0 r = now else: ref = 0 l = now print(r)" p02598,s411125980,Accepted,"import math N,K = map(int,input().split()) A = list(map(int,input().split())) m = 1 M = max(A) while(M-m>0): mm = 0 mid = (M+m)//2 for i in range(N): mm += math.ceil(A[i]/mid)-1 if mm>K: m = mid+1 else: M = mid print(math.ceil(m)) " p02598,s932221727,Accepted,"n,k=map(int,input().split()) a=list(map(int,input().split())) ng=0 ok=max(a) while ng+1!=ok: mid=(ng+ok)//2 ans=0 for i in a: ans+=0--i//mid-1 if ans<=k:ok=mid else:ng=mid print(ok)" p02598,s698153400,Accepted,"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 s = sum((a-1)//x for a in A) if s > K: x0 = x else: x1 = x print(x1) " p02598,s752128981,Accepted,"from sys import stdin from math import floor,ceil N, K = map(int, input().rstrip().split()) A = [int(x) for x in stdin.readline().rstrip().split()] def is_max_len_less_than_input(x,K,A): count = 0 for ln in A: count += ceil(ln/x)-1 if count > K: return False return True def binary_search(begin,end,K,A): while abs(end-begin)>1: mid = (begin+end)//2 if is_max_len_less_than_input(mid,K,A): end = mid else: begin = mid return end print(binary_search(0,max(A),K,A))" p02598,s381407604,Accepted,"import math N, K=map(int, input().split()) A=list(map(int, input().split())) i=1 j=10**9 while True: k=(i+j)//2 if k>0 and sum([math.ceil(a/k)-1 for a in A])<=K: if k==1 or sum([math.ceil(a/(k-1))-1 for a in A])>K: print(k) break else: j=k-1 else: i=k+1" p02598,s287876772,Accepted,"def is_good(mid, key): return sum(count_cuts(a, mid) for a in A) <= key def binary_search(key): bad, good = 0, 2 * 10 ** 14 + 1 while good - bad > 1: mid = (bad + good) // 2 if is_good(mid, key): good = mid else: bad = mid return good def count_cuts(a, unit): return (a + unit - 1) // unit - 1 N, K, *A = map(int, open(0).read().split()) print(binary_search(K)) " p02598,s822922275,Accepted,"N,K=map(int,input().split()) A=list(map(int,input().split())) low=0 high=max(A) while high-low>1: mid=(low+high)//2 cnt=0 for i in A: cnt+=(i-1)//mid if cnt>K: low=mid else: high=mid print(high)" p02598,s486341285,Accepted,"def main(): n,k=map(int,input().split()) lst=sorted(list(map(int,input().split()))) left=0 right=lst[-1] while right-left>1: mid=(right+left)//2 sm=0 for x in lst: sm+=(x-1)//mid if sm<=k: right=mid else : left=mid print(right) main()" p02598,s597926842,Accepted,"# 入力 n, k = map(int, input().split()) A = list(map(int, input().split())) # 最大値をx以下にできるか def check(x): cnt = 0 for a in A: cnt += (a - 1) // x return cnt <= k # めぐる式二分探索 ok = 10 ** 10 ng = 0 while ok - ng > 1: mid = (ok + ng) // 2 if check(mid): ok = mid else: ng = mid # 出力 print(ok) " p02598,s136061533,Accepted,"N, K = map(int, input().split()) As = list(map(int, input().split())) def isOK(L): num = 0 for A in As: num += -(-A // L) - 1 return num <= K ng, ok = 0, 10**9 while abs(ok-ng) > 10**-6: mid = (ng+ok) / 2 if isOK(mid): ok = mid else: ng = mid k = int(-(-ok // 1)) #print('ok:', ok, '/ k:', k) for L in range(max(1, k-2), k+3): if isOK(L): print(L) break " p02598,s130897729,Accepted,"def isok(mid): cnt = 0 for i in range(N): if A[i] % mid == 0: cnt += A[i]/mid-1 else: cnt += A[i]//mid if cnt <= K: return True else: return False N,K = map(int,input().split()) A = list(map(int,input().split())) #答えの範囲 left = 0 right = 10**9 while right - left > 1: mid = (right+left)//2 if isok(mid): right = mid else: left = mid print(right)" p02598,s491770719,Accepted,"n,k=map(int,input().split()) a=list(map(int,input().split())) ok=10**10 ng=1 for i in range(40): chk=(ok+ng)//2 cnt=0 for j in range(n): cnt+=(a[j]+chk-1)//chk-1 if cnt > k: ng = chk else: ok = chk print(ok)" p02598,s791199889,Accepted,"n,k = map(int,input().split()) a = list(map(int,input().split())) s = sum(a) x = [0]*n t = 0 for i in range(n): y = int(a[i]/s * k) x[i] = [i, a[i], y, a[i]/(y+1)] t += y x.sort(key= lambda val : val[3],reverse=True) for i in range(k-t): x[i][2] += 1 ans = 0 for i in range(n): ans = max(ans, x[i][1]/(x[i][2]+1)) print(int(-(-ans//1)))" p02598,s543172637,Accepted,"n,k=map(int, input().split()) A=[int(i) for i in input().split()] ng=0 ok = max(A) while(ng+1!=ok): mid = (ok+ng)//2 ans = 0 for i in A: ans += 0--i//mid-1 if(ans<=k): ok = mid else: ng = mid print(ok) " p02598,s562056204,Accepted,"import numpy as np import math N, K = map(int, input().split()) aaa = np.array(list(map(float, input().split())), dtype='f8') l = 0 r = 10 ** 9 while r != l: mid = (r + l) // 2 bbb = aaa / mid bbb -= 1 bbb = np.ceil(bbb) if bbb.sum() <= K: r = mid else: l = mid + 1 print(l) " p02598,s192610654,Accepted,"from math import ceil def C(x): cnt = 0 for i in range(n): cnt += ceil(a[i] / x) - 1 if cnt > k: return False else: return True n, k = map(int, input().split()) a = list(map(int, input().split())) lb = 0 ub = 1000000000 while ub - lb > 1: mid = (lb + ub) // 2 if C(mid): ub = mid else: lb = mid print(ub)" p02598,s820724259,Accepted,"import sys import numpy as np read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines def main(A, K): l, r = 0, 1 << 30 def test(x): return np.sum((A + x - 1) // x - 1) <= K while l + 1 < r: m = (l + r) // 2 if test(m): r = m else: l = m return r N, K = map(int, readline().split()) A = np.array(read().split(), np.int64) print(main(A, K))" p02598,s675942040,Accepted,"# 解答 N, K = map(int, input().split()) A = list(map(int, input().split())) A.sort(reverse=True) def check(L): count = 0 for a in A: if a <= L: break count += (a-1)//L if count > K: return False return True l = 0 r = A[0] while r-l > 1: c = (r+l)//2 if check(c): r = c else: l = c print(r)" p02598,s422900062,Accepted,"N,K=map(int,input().split()) A=list(map(int,input().split())) l=0 r=10**9 while l+1left+1: cnt=K mid=(left+right)//2 for i in range(N): cnt -=ceil(A[i]/mid)-1 if cnt>=0:right=mid elif cnt<0:left=mid print(right)" p02598,s917109696,Accepted,"n, k = [int(i) for i in input().split()] a = [int(i) for i in input().split()] l = 1 r = max(a) while l < r: m = (l + r) // 2 cnt = 0 for v in a: if m == 0: cnt += 2 * v else: cnt += (v + m - 1) // m - 1 if cnt <= k: r = m else: l = m + 1 print(l)" p02598,s402929484,Accepted,"import sys input = sys.stdin.readline N, K = map(int, input().split()) A = list(map(int, input().split())) def determine(L): if L == 0: return False ret = 0 for a in A: k = a // L if k * L == a: k -= 1 ret += k if ret <= K: return True else: return False L = 0 R = 10 ** 9 while L + 1 < R: mid = (L + R) // 2 if determine(mid): R = mid else: L = mid print(R)" p02598,s057407693,Accepted," import math N, K = [int(x) for x in input().split()] A = [int(x) for x in input().split()] A.sort() def isPossible(maxL): cuts = 0 for x in A: if x > maxL: cuts += math.ceil(x / maxL) - 1 return cuts <= K lo = 0 hi = max(A) EPS = 10e-7 while hi - lo > EPS: mid = (lo + hi) / 2 if isPossible(mid): hi = mid else: lo = mid print(math.ceil(hi))" p02598,s277042821,Accepted,"import math def resolve(): N, K = map(int, input().split()) A = list(map(int, input().split())) def _f(length: int) -> bool: count = 0 for a in A: count += int((a-1) / length) return count <= K l = 0 r = 10**9 while (r-l) > 1: mid = (l+r) // 2 if _f(mid): r = mid else: l = mid print(r) if __name__ == ""__main__"": resolve()" p02598,s057897573,Accepted,"import sys import math input = sys.stdin.readline def can(arr, m, K): need = 0 for x in arr: if x > m: need += int(x // m) return need <= K N, K = map(int, input().split()) arr = list(map(int, input().split())) lo = 1 hi = int(1e9) + 1 while (lo < hi): m = int((lo + hi) // 2) if (can(arr, m, K)): hi = m else: lo = m + 1 print(lo) " p02598,s275179520,Accepted,"import math def solution(x): p = sum([math.ceil(a[i]/x)-1 for i in range(N)]) return p def solvance(y,z): if z-y <= 1: return z else: w = (y+z)//2 #print(y,w,z) if solution(w) > K: return solvance(w,z) else: return solvance(y,w) N,K = map(int,input().split()) a = list(map(int,input().split())) if K == 0: print(max(a)) else: ansM = (sum(a)//K)+1 ansm = sum(a)//(K+N) ans = solvance(ansm,ansM) print(ans) " p02598,s022066143,Accepted,"N,K = map(int,input().split()) A = list(map(int,input().split())) ok = 1000000000 ng = 0 while ok-ng>1: count = 0 mid = (ok+ng)//2 for a in A: if a%mid==0: count += -1+a//mid else: count += a//mid if count <= K: ok = mid else: ng = mid print(ok) " p02598,s104081743,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) left, right = 0, max(A) while right - left != 1: mid = (left + right) // 2 tmp = 0 for i in A: tmp += i // mid - 1 if i % mid == 0 else i // mid if tmp > K: left = mid else: right = mid print(right) " p02598,s437443569,Accepted,"#!/usr/bin/env python3 from math import ceil n, k = map(int, input().split()) a = list(map(int, input().split())) def f(p): c = 0 for x in a: c += x // p return c ok, ng = 0, max(a) + 1 while abs(ok - ng) > 3e-6: m = (ok + ng) / 2 if f(m) > k: ok = m else: ng = m print(ceil(ok)) " p02598,s407583347,Accepted,"N,K=map(int,input().split()) l=list(map(int,input().split())) import math def f(n): A=0 for i in l: A+=math.ceil(i/n)-1 return A<=K def bis(ng,ok): while abs(ok-ng)>1: mid=(ok+ng)//2 if f(mid): ok=mid else: ng=mid return ok print(bis(0,max(l)))" p02598,s963013453,Accepted,"from math import ceil N, K = map(int,input().split()) A = list(map(int,input().split())) def chk(L): cnt = 0 for i in range(N): cnt += ceil(A[i]/L)-1 return cnt <= K l, r = 1, max(A) while l <= r: m = (l+r)//2 if chk(m): r = m-1 else: l = m+1 print(min([x for x in [m-1,m,m+1] if x > 0 and chk(x)]))" p02598,s933198765,Accepted,"n,k = map(int,input().split()) a = list(map(int,input().split())) l = 0 r = 10**10 while r > l + 1: m = (r+l)//2 count = 0 for i in a: if i <= m: continue count += (i)//m if count > k: l = m else: r = m print(r)" p02598,s194132773,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) # binary search left = 1 right = 10 ** 9 while left < right: center = (left + right) // 2 total = 0 for i in a: if i % center == 0: i -= 1 total += i//center if total > k: left = center + 1 else: right = center print(left)" p02598,s709248877,Accepted,"N,K = map(int,input().split()) A = list(map(int,input().split())) l = 1 r = 10**9 + 1 import math while l < r: mid = (l + r) // 2 counter = 0 for i in range(N): if A[i] > mid: counter += math.ceil(A[i]/mid) - 1 if counter <= K: r = mid else: l = mid + 1 print(l)" p02598,s859693274,Accepted,"import sys input=lambda: sys.stdin.readline().rstrip() n,k=map(int,input().split()) A=[int(i) for i in input().split()] l,r=0,max(A) cur=0 while cur<100: mid=(l+r)/2 ct=0 for a in A: if a<=mid: continue else: t=int(a/mid) if t*mid==a: t-=1 ct+=t if ct<=k: r=mid else: l=mid cur+=1 ans=int(r) if ans==r: print(ans) else: print(ans+1)" p02598,s814711460,Accepted,"from math import ceil n,k = map(int,input().split()) a = list(map(int,input().split())) l = 0 r = max(a) def f(ln, x): return ceil(ln/x)-1 while r-l > 1: m = (r+l)//2 cnt = 0 for i in range(n): cnt += f(a[i],m) if cnt > k: l = m else: r = m print(r)" p02598,s500050523,Accepted,"# にぶたん 二分探索 n, k = map(int, input().split()) A = list(map(int, input().split())) ng = 0 ok = max(A) while abs(ok - ng) > 1: mid = (ok + ng) // 2 cnt = 0 for a in A: cnt += (a - 1) // mid if cnt <= k: ok = mid else: ng = mid print(ok) " p02598,s033658146,Accepted,"def isok(arg): count = 0 for i in range(N): count += -(-A[i]//arg)-1 if count <= K: return True else: return False def bisect(ng, ok): while (abs(ok - ng) > 1): mid = (ok + ng) // 2 if isok(mid): ok = mid else: ng = mid return ok N,K = map(int,input().split()) A = list(map(int,input().split())) print(bisect(0,10**9))" p02598,s185894527,Accepted,"n, k = map(int, input().split()) A = [*map(int, input().split())] A.sort(reverse=True) ng, ok = 0, 1<<30 while ok - ng > 1: m = (ng + ok) // 2 c = 0 for a in A: d = (a - 1) // m if d == 0: break c += d if c <= k: ok = m else: ng = m print(ok) " p02598,s560585776,Accepted,"N,K = list(map(int,input().split())) A = list(map(int,input().split())) l = 0 r = 1000000000 def judge(m): k = 0 for i in range(N): if A[i]%m==0: k+=A[i]//m-1 else: k+=A[i]//m return k<=K while r-l>1: if judge((l+r)//2): r = (l+r)//2 else: l = (l+r)//2 print(r)" p02598,s048791054,Accepted,"import math n,k = map(int,input().split()) A = list(map(int,input().split())) low = 1 high = max(A) while low != high: mid = (low + high)// 2 cnt = 0 for i in A: cnt += math.ceil(i/mid) - 1 if cnt > k : low = mid + 1 else: high = mid print(low)" p02598,s697599135,Accepted,"import math N, K = list(map(int, input().split())) A = list(map(int, input().split())) def isPossible(X): global N, K, A cuts = 0 for i in range(N): cuts += math.ceil(A[i]/X) - 1 return cuts <= K minVal = 0 maxVal = max(A) while math.ceil(minVal) != math.ceil(maxVal): if isPossible((maxVal + minVal) / 2): maxVal = (maxVal + minVal) / 2 else: minVal = (maxVal + minVal) / 2 print(math.ceil(maxVal)) " p02598,s198576428,Accepted,"n,k,*a=map(int,open(l:=0).read().split()) r=10**9 while~l+r:l,r,*_=(l,x:=l+r>>1,r)[-sum(-b//x+1for b in a)>k:] print(r)" p02598,s401577726,Accepted,"from sys import stdin rs = stdin.readline ri = lambda : int(rs()) ril = lambda : list(map(int, rs().split())) def main(): N, K = ril() A = ril() l = 1 r = 1000000000 while l < r: m = (l + r) // 2 k = 0 for a in A: k += (a - 1) // m if k <= K: r = m else: l = m + 1 print(r) if __name__ == '__main__': main() " p02598,s501188660,Accepted,"#!/usr/bin python3 # -*- coding: utf-8 -*- import bisect n,k = map(int, input().split()) a = sorted(list(map(int, input().split()))) def cnt(x): ret = 0 for ai in a: ret += (ai+(x-1))//x - 1 return ret ok, ng = a[-1], 0 while ok - ng > 1: nw = (ok + ng) // 2 if cnt(nw)<=k: ok = nw else: ng = nw print(ok) " p02598,s104098727,Accepted,"def main(): log_no, cut_max = [int(x) for x in input().split()] logs = [int(x) for x in input().split()] bin_l, bin_r = 0, 10 ** 9 while bin_r - bin_l > 1: bin_mid = (bin_l + bin_r) // 2 cut_count = sum((log - 1) // bin_mid for log in logs) if cut_count <= cut_max: bin_r = bin_mid else: bin_l = bin_mid print(bin_r) if __name__ == '__main__': main() " p02598,s296650053,Accepted,"N,K=map(int,input().split()) *A,=map(int,input().split()) def C(x): return sum([(A[i]-.5)//x for i in range(N)]) <= K def binary_search2(func, n_min, n_max): left,right=n_min,n_max while right-left>1: middle = (left+right)//2 y_middle = func(middle) if y_middle: right=middle else: left=middle return right print(binary_search2(C, 0, max(A)+1))" p02598,s587327414,Accepted,"n,k = map(int, input().split()) a = sorted(list(map(int,input().split())), reverse=True) l = 1 h = a[0] while l != h: m = (l + h) // 2 cut = 0 for x in a: cut += x // m + (x % m != 0) - 1 if cut <= k: h = m else: l = m + 1 print(l)" p02598,s890704654,Accepted,"N,K=map(int,input().split()) A=list(map(int,input().split())) L=0;R=10**9 while(R-L>1): M=L+R>>1;C=0 for i in A:C+=(i-1)//M if C<=K:R=M else:L=M print(R)" p02598,s376188598,Accepted,"n, k = map(int, input().split()) a = tuple(map(int, input().split())) ok = 10**9 ng = 0 while abs(ng-ok) > 1: mid = (ok + ng) // 2 cnt = 0 for i in a: cnt += (i+mid-1)//mid-1 if cnt <= k: ok = mid else: ng = mid print(ok)" p02598,s620445241,Accepted,"from sys import stdin import numpy as np n, k = map(int, stdin.readline().split()) a = np.array(stdin.readline().split(), dtype=np.int64) ng = 0 ok = 10 ** 9 + 1 while ok - ng > 1: mid = (ok + ng) >> 1 if np.sum(np.ceil(a / mid) - 1) <= k: ok = mid else: ng = mid print(ok) " p02598,s196284744,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) def f(x): r = 0 for a in A: r += (a+x-1)//x-1 return r a = 0 b = 2**32 while b>0: if f(a+b)>K: a += b b //= 2 print(a+1) " p02598,s194248521,Accepted,"def resolve(): import math n,k = map(int, input().split()) a = list(map(int, input().split())) r = max(a) l = 0 def cuttimes(p, cutter): return math.ceil(p/cutter)-1 while r-l > 1: mid = (r+l)//2 cut = 0 for i in range(n): cut += cuttimes(a[i], mid) if cut <= k: r = mid else: l = mid print(r) resolve()" p02598,s148024155,Accepted,"N,K = [int(i) for i in input().split()] A = [int(i) for i in input().split()] M = max(A) m = 1 mid = (M+1)//2 while m K: m = mid+1 break else: M = mid mid = (M+m)//2 print(mid)" p02598,s222962799,Accepted,"import math, sys N,K = map(int,input().split()) A = [int(x) for x in input().split()] lower = 0 upper = 10**10 while upper - lower > 0.1: cuts = 0 trial = (lower + upper) / 2 for i in A: cuts += math.ceil(i/trial)-1 if cuts <= K: upper = trial else: lower = trial ans = math.ceil(lower) if ans == 0: print(1) sys.exit() cuts = 0 for i in A: cuts += math.ceil(i / ans) - 1 if cuts <= K: print(ans) else: print(ans + 1)" p02598,s582275344,Accepted,"from heapq import * N,K=map(int,input().split()) A=list(map(int,input().split())) Q=[] heapify(Q) for i in range(N): heappush(Q,(-A[i],1)) x=0 if K==0: print(max(A)) exit() L,R,M=1,max(A),0 while R!=L: M=(L+R)//2 x=0 for i in range(N): x+=(A[i]-1)//M if x>K: L=max(L+1,M) else: R=M print(L) " p02598,s347881333,Accepted,"def possible(l, a, k): for x in a: k -= x//l if x%l==0: k += 1 return k>=0 n, k = map(int, input().split()) a = [int(x) for x in input().split()] mini = 1 maxi = 10**9+7 while(mini!=maxi): mid = (mini+maxi)//2 if possible(mid, a, k): maxi = mid else: mini = mid + 1 print(mini) " p02598,s593253391,Accepted,"import math n,k = map(int,input().split()) a = list(map(int,input().split())) if k == 0: print(max(a)) exit() suki = 1000000000 kirai = 0 while suki-kirai>1: targ = (suki+kirai)//2 cnt = 0 mode = 1 for i in range(n): cnt += -(-a[i]//targ)-1 if cnt > k: mode = 0 break if mode: suki = targ else: kirai = targ print(math.ceil(suki))" p02598,s826937978,Accepted,"import sys n, k = map(int, input().split()) a = list(map(int, input().split())) if k == 0: print(max(a)) sys.exit() def check(t): if t == 0: return False ans = 0 for ai in a: if ai > t: ans += ai // t return ans <= k l = 0 r = 10 ** 9 + 1 while r - l > 1: mid = (r + l) // 2 if check(mid): r = mid else: l = mid if check(l): print(l) else: print(r) " p02598,s772134661,Accepted,"import math def cut_num(length,max_length): return math.ceil(length/max_length)-1 n,k = map(int,input().split()) a = list(map(int,input().split())) l = 1 r = 10**9 while l k: l = mid+1 else: r = mid print(l) " p02598,s852599753,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) l = 0 r = 10**9 while (r-l>1): x = (r+l)//2 now = 0 for a in A: now += (a-1)//x if now <= K: r = x else: l = x print(r)" p02598,s419223761,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) def is_ok(l): cnt = 0 for L in a: cnt += L // l - 1 if L % l != 0: cnt += 1 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, max(a)))" p02598,s876000058,Accepted,"N, K, *A = map(int, open(0).read().split()) def is_ok(x): cnt = 0 for a in A: cnt += -(-a // x) - 1 return cnt <= K ng, ok = 0, 10 ** 10 while abs(ok - ng) > 1: mid = (ok + ng) // 2 if is_ok(mid): ok = mid else: ng = mid print(ok)" p02598,s518093843,Accepted,"n,k=map(int, input().split()) *a,=map(int, input().split()) mx=max(a) mn=10**(-9) from math import ceil while mx-mn>10**(-5): md=(mx+mn)/2 cnt=0 for ai in a: cnt+=ceil(ai/md)-1 if cnt<=k: mx=md else: mn=md print(ceil(mn)) " p02598,s777606831,Accepted,"N, K = map(int, input().split()) tree = list(map(int, input().split())) left = 0 right = 2*(10**9) treeLen = len(tree) while right - left > 1: cnt = 0 mid = (right + left) // 2 for i in range(treeLen): cnt += tree[i] // mid if tree[i] % mid == 0: cnt -= 1 # ちょうどに切れるときは切り口が1減る if K >= cnt: right = mid else: left = mid print(right) " p02598,s193641463,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) a = [x * 2 for x in a] result = max(a) left = 1 right = result med = left + (right - left) // 2 while left <= right: counter = sum([(x - 1) // med for x in a]) if counter <= k: result = med right = med - 1 else: left = med + 1 med = left + (right - left) // 2 print((result + 1) // 2) " p02598,s459736973,Accepted," def is_ok(arg): cnt = 0 for i in range(N): cnt += -(-A[i]//arg) - 1 return K < cnt 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 N,K = map(int, input().split()) A = list(map(int, input().split())) print(meguru_bisect(max(A)+1, 0)+1) " p02598,s528716736,Accepted,"import math n, k = map(int, input().split()) a = list(map(int, input().split())) def is_ok(x,a,k): b = 0 for ai in a: b += math.ceil(ai/x) b -= 1 if b <= k: return True def meguru_bisect(ng, ok): while (abs(ok - ng) > 1): mid = (ok + ng) // 2 if is_ok(mid,a,k): ok = mid else: ng = mid return ok print(meguru_bisect(0,max(a)))" p02598,s997973890,Accepted,"n, k = map(int,input().split()) a = list(map(int,input().split())) a.sort() ok = a[-1] ng = 0 while abs(ok - ng)>1: X = (ok + ng)//2 cnt = 0 for i in range(n): temp = a[-(i + 1)] if temp <= X:break temp_cnt = (temp + X - 1)//X - 1 cnt += temp_cnt if cnt <= k:ok = X else:ng = X print(ok)" p02598,s674409564,Accepted,"import math n,k = map(int,input().split()) a = list(map(int,input().split())) start = 0 end = max(a) middle = (end+start) // 2 while end - start > 1: count = 0 for i in range(n): if a[i] > middle: count += math.ceil(a[i] / middle) - 1 if count <= k: end = middle else: start = middle middle = (end+start) // 2 print(end)" p02598,s413708753,Accepted,"n,k=map(int,input().split()) arr=list(map(int,input().split())) m=max(arr) if(k==0): print(m) else: low=1 high=m while(low<=high): mid=low+(high-low)//2 if(mid==1): print(mid) break count=0 count2=0 for i in range(n): count+=(arr[i]-1)//mid count2+=(arr[i]-1)//(mid-1) if(count<=k and count2>k): print(mid) break elif(count= 1] c = k - sum(int(a/t)-1 for a in A) X = [] for a in A: X.append(ceil(a / ceil(a/t))) X.append(ceil(a / int(a/t))) X.sort() print(X[-c-1])" p02598,s794951169,Accepted,"from sys import stdin import numpy as np n, k = map(int, stdin.buffer.readline().split()) a = np.array(stdin.buffer.read().split(), dtype=np.int64) ng = 0 ok = 10 ** 9 + 1 while ok - ng > 1: mid = (ok + ng) >> 1 if np.sum(np.ceil(a / mid) - 1) <= k: ok = mid else: ng = mid print(ok) " p02598,s665053944,Accepted,"from math import ceil def check(x): # 全てを長さx以下にするために必要な回数 cnt = 0 for a in A: # 切る回数は-1した回数。a=20 x=4 20/4=5 だが切る箇所は4。 cnt += ceil(a/x)-1 return cnt <= K N, K = map(int, input().split()) A = list(map(int, input().split())) left = 0 right = max(A) while left < right-1: mid = (left+right)//2 if check(mid): right = mid else: left = mid print(right) " p02598,s736272261,Accepted,"import sys input = sys.stdin.readline N, K = map(int, input().split()) A = list(map(int, input().split())) l = 0 r = 2*10**9 while r - l > 1: m = (l+r)//2 count = 0 for a in A: count += (a+m-1)//m-1 if count <= K: r = m else: l = m print(r)" p02598,s246958443,Accepted,"def check(N,target,A,K): cnt = 0 for i in range(N): cnt += -(-A[i]//target)-1 if cnt>K: return False return True def solve(): ans = 0 N, K = map(int, input().split()) A = list(map(int, input().split())) low = 0 high = 10**9 mid = (low+high)//2 while high>low+1: if check(N,mid,A,K): high = mid else: low = mid mid = (low+high)//2 ans = high return ans print(solve())" p02598,s446190089,Accepted,"from sys import stdin input = stdin.readline import math import heapq def solve(): n, k = map(int, input().split()) a = list(map(int, input().split())) left = 1 right = max(a) def ok(l): s = sum([(i-1) // l for i in a]) return s <= k while left < right: mid = (left + right) // 2 if ok(mid): right = mid else: left = mid + 1 print(left) if __name__ == '__main__': solve() " p02598,s722024991,Accepted,"import math n,k = map(int,input().split()) a = list(map(int,input().split())) if k == 0: print(max(a)) exit() suki = 1000000000 kirai = 0 while int(suki) != int(kirai): targ = (suki+kirai)/2 cnt = 0 mode = 1 for i in range(n): cnt += (a[i]-1)//targ if cnt > k: mode = 0 break if mode: suki = targ else: kirai = targ print(math.ceil(suki))" p02598,s584014389,Accepted,"n,k=map(int,input().split()) a=list(map(int,input().split())) def case(L): result=0 for x in a: result+=(x-1)//L return result possible=0 impossible=max(a) while impossible-possible>1: M=(impossible+possible)//2 if case(M)>k: possible=M else: impossible=M print(impossible) " p02598,s032715226,Accepted,"import math def f(n): x = 0 for ai in a: x += math.ceil(ai/n)-1 return x <= k def solve(ng,ok): while abs(ok-ng) > 1: mid = (ok+ng)//2 flag = f(mid) if flag: ok = mid else: ng = mid return ok n,k = map(int,input().split()) a = list(map(int,input().split())) print(solve(0,max(a)))" p02598,s718914239,Accepted,"import copy N, K=list(map(int,input().split())) A=list(map(int,input().split())) a=max(A) l=1 y=copy.copy(a) a=a-1 while l<=a: x=(l+a)//2 m=0 for i in range(N): if A[i]%x==0: m+=A[i]//x-1 else: m+=A[i]//x if m<=K: a=x-1 y=copy.copy(x) else: l=x+1 print(y)" p02598,s943203480,Accepted,"import math n,k=map(int,input().split()) a=list(map(int,input().split())) ng=0 ok=10**9 while ok-ng >1: l = (ng+ok)//2 kt=0 for i in range(n): kt += a[i]//l - (0 if a[i]%l else 1) if kt <= k: ok = l else: ng = l print(ok)" p02598,s361922684,Accepted,"from heapq import heappush, heappop, heapify import math def check(a,mid,k): cnt = 0 for x in a: cur_cnt = (x+mid-1)//mid - 1 cnt+=cur_cnt if cnt > k: return False return True def solve(): n , k= map(int, input().strip().split()) a= [int(x) for x in input().strip().split()] l = 0 r = 10**9+20 while r-l > 1: mid = (r+l)//2 if check(a,mid,k): r = mid else: l = mid return l+1 print(solve())" p02598,s679868931,Accepted,"def check(x): ret = 0 for e in a: ret += max((e - 1) // x, 0) return ret <= k n, k = map(int, input().split()) a = list(map(int, input().split())) l = 0 r = 10 ** 9 while r - l > 1: m = (l + r) // 2 if check(m): r = m else: l = m print(r) " p02598,s754067440,Accepted,"n,k = map(int,input().split()) a = list(map(int,input().split())) import math import bisect a.sort(reverse=True) idx = 0 result = 0 bottom, top = 0, max(a) while top - bottom > 1: mid = (top + bottom) // 2 cnt = 0 for i in range(n): cnt += a[i] // mid if a[i] % mid == 0: cnt -= 1 if cnt <= k: top = mid else: bottom = mid print(top) " p02598,s826277132,Accepted,"def is_ok(x): cnt = 0 for a in A: cnt += -(-a//x)-1 if cnt <= k: return True return False 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 n, k = map(int,input().split()) A = list(map(int,input().split())) print(meguru_bisect(0,10**9+1)) " p02598,s427695835,Accepted,"N, K = map(int,input().split()) A = list(map(int, input().split())) OK = 10**9 NG = 0 while OK - NG > 1: ans = 0 mid = (OK+NG)//2 for a in A: ans += (a-0.1)//mid if ans > K: NG = mid else: OK = mid print(OK)" p02598,s685529261,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) l = 0 r = 10**9 + 1 ref = 0 ans = 10**9 while r - l > 1: now = (l + r)//2 for i in a: ref += 0 - -i//now - 1 if ref > k: ref = 0 l = now break else: ans = now ref = 0 r = now print(ans)" p02598,s079420231,Accepted,"import math N, K = map(int, input().split()) A = list(map(int, input().split())) left = 0 right = max(A) while right - left > 1: mid = (left + right) // 2 jk = 0 for i in range(N): jk += A[i] // mid - 1 if A[i] % mid != 0: jk += 1 if jk <= K: right = mid else: left = mid print(right)" p02598,s086121816,Accepted," n,k = map(int,input().split()) a = list(map(int,input().split())) l=0 r=10**9 def check(x): now = 0 for i in range(n): now += (a[i] - 1 )// x return now <= k while r-l > 1: x = (l+r) //2 if check(x): r = x else: l = x print(r) " p02598,s059874985,Accepted,"def is_ok(X): cnt = 0 for a in A: cnt += (a-1)//X if cnt <= k: return True else: return False 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 n, k = map(int,input().split()) A = list(map(int,input().split())) print(meguru_bisect(0,max(A)+1))" p02598,s387790745,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) # 丸太がすべてxの長さ以下になる回数を出し、それがK回以下か判定する def f(x): now = 0 for i in range(N): now += (A[i]-1)//x return now <= K l = 0 r = 10**9 while r-l > 1: mid = (r+l)//2 if f(mid): r = mid else: l = mid print(r)" p02598,s054602060,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) l = 1 r = max(A) while l != r: mid = (r + l) // 2 count = 0 for log in A: count += (log - 1) // mid if count <= K: r = mid else: l = mid + 1 print(r) " p02598,s206369838,Accepted,"import math,sys n,k=map(int,input().split()) a=list(map(int,input().split())) l=0 r=10**9+2 while math.ceil(l) 1: mid = (l + r) // 2 if cal(mid): r = mid else: l = mid print(r)" p02598,s616261527,Accepted," N,K = map(int,input().split()) A = list(map(int,input().split())) l = 0 r = max(A) while r-l != 1: m = (l+r)//2 now = 0 for i in range(N): if A[i] % m == 0: now += A[i] // m -1 else: now += A[i] // m if now > K: l = m else: r = m print (r) " p02598,s205242172,Accepted,"N, M = input().strip().split() n, k = [int(N), int(M)] a = list(map(int, input().strip().split())) le = 0 ri = 10000000000 while ri - le > 1: mid = (le + ri) // 2 num = 0 for i in a: num += (i-1) // mid if num <= k: ri = mid else: le = mid print(ri)" p02598,s231780601,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) ng = 0 ok = max(A) while ok - ng > 1: cnt = 0 l = (ok + ng) // 2 for a in A: cnt += (a // l) + (a % l != 0) - 1 if cnt <= K: ok = l else: ng = l print(ok)" p02598,s730977981,Accepted,"n,k=map(int,input().split()) a=[int(j) for j in input().split()] a.sort(reverse=True) def f(x): c=0 for i in a: if ik: return False return True left=0 right=a[0] while right-left>1: mid=(left+right)//2 if f(mid): right=mid else: left=mid print(right)" p02598,s444325589,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) if K == 0: print(max(A)) quit() def check(x): count = 0 for a in A: count += -(-a // x) - 1 if count > K: return False return True left = 0 # False right = 10**10 # True while left + 1 < right: mid = (left + right) // 2 if check(mid): right = mid else: left = mid print(right)" p02598,s186343121,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) l = 0 r = 10**9 while r - l > 1: m = (l + r) // 2 s = 0 for x in a: s += (x - 1) // m if s <= k: r = m else: l = m print(r) " p02598,s065973196,Accepted,"N,K = [int(hoge) for hoge in input().split()] A = [int(hoge) for hoge in input().split()] #割り当てを考えた後は、n等分するのが最適→にぶたん? NG = 0 OK = 10**9 + 100 #小数点以下切り上げ→最小となるOKのintを求める def Maruta(L):#長さLにできるか Kaisu = sum([a//L - 1 + bool(a%L) for a in A]) return Kaisu<=K while OK - NG > 1: Test = (OK + NG)//2 if Maruta(Test): OK = Test else: NG = Test print(OK) " p02598,s157939991,Accepted,"# coding: utf-8 import numpy as np def solve(*args: str) -> str: n, k = map(int, args[0].split()) A = np.array(tuple(map(int, args[1].split()))) l, r = 0, np.max(A) while l+1 < r: m = (l+r)//2 if k < np.sum(-(-A//m)-1): l = m else: r = m return str(r) if __name__ == ""__main__"": print(solve(*(open(0).read().splitlines()))) " p02598,s882440219,Accepted,"import math N, K = map(int, input().split()) A = list(map(int, input().split())) def ink(L): cnt = 0 for i in range(N): cnt += A[i]//L if A[i]%L != 0: cnt += 1 cnt -= 1 return cnt <= K bottom, top = 0, max(A) while(top - bottom > 1): middle = (top + bottom) // 2 if ink(middle): top = middle else: bottom = middle print(top)" p02598,s251165019,Accepted,"N,K = map(int,input().split()) A = list(map(int,input().split())) left = 0 right = 10**9 while right - left > 1: center = (right+left)//2 count = 0 for a in A: if a%center == 0: count += a//center-1 else: count += a//center if count > K: left = center else: right = center print(right)" p02598,s936059748,Accepted,"import math n, k = map(int, input().split()) a = [int(x) for x in input().split()] l, r = 0, 10**9+2 while r-l > 1: key = (r+l)//2 count = 0 for i in range(n): count += (a[i]-1)//key if count <= k: r = key else: l = key print(r)" p02598,s896008706,Accepted,"from sys import stdin input = stdin.buffer.readline n, k = map(int, input().split()) *a, = map(int, input().split()) def f(mx): cnt = 0 for i in a: cnt += (i + mx - 1) // mx - 1 return cnt l, r = 1, int(1e9) while l < r: m = (l + r) >> 1 if f(m) > k: l = m + 1 else: r = m print(r) " p02598,s667249819,Accepted,"from sys import stdin def main(): n, k = map(int, stdin.readline().split()) a = list(map(int, stdin.readline().split())) def ok(ans): cnt = sum(max((i - 1) // ans, 0) for i in a) # print(ans, cnt) return cnt <= k ans = 0 for i in range(32, -1, -1): if not ok(ans + (1 << i)): ans += 1 << i print(ans + 1) main() " p02598,s242916364,Accepted,"N,K = list(map(int,input().split())) A = list(map(int,input().split())) NG=0 OK=max(A)+1 while OK-NG>1: mid = (OK+NG)//2 cur=0 for x in A: cur += (x-1)//mid if cur > K: NG=mid else: OK=mid print(OK)" p02598,s238179207,Accepted,"import sys input = sys.stdin.buffer.readline n, k = map(int, input().split()) A = list(map(int, input().split())) # A.sort() def hantei(x): cnt = 0 for i in range(n): cnt += (A[i] - 1) // x return cnt ok = 10 ** 9 ng = 0 while ok - ng > 1: mid = (ok + ng) // 2 if hantei(mid) <= k: ok = mid else: ng = mid # print(ok, ng) print(ok) " p02598,s697664632,Accepted,"import math n, k = map(int, input().split()) arr = list(map(int, input().split())) max_length = max(arr) low = 1 high = max_length - 1 while low <= high: mid = (low + high) //2 cnt = 0 for i in range(n): cnt += math.ceil(arr[i]/mid) - 1 if cnt > k: low = mid + 1 else: high = mid -1 max_length = mid print(max_length) " p02598,s037635182,Accepted,"import numpy as np n, k = map(int, input().split()) a = np.array(list(map(int, input().split()))) left, right = 0, np.max(a) while right - left > 1: mid = left + (right - left) // 2 if np.sum(np.ceil(a/mid)-1) <= k: right = mid else: left = mid print(right) " p02598,s629264437,Accepted,"import heapq import bisect n,k=map(int, input().split()) A=[int(i) for i in input().split()] ng=0 ok = max(A) while(ng+1!=ok): mid = (ok+ng)//2 ans = 0 for i in A: ans += 0--i//mid-1 if(ans<=k): ok = mid else: ng = mid print(ok) " p02598,s330624172,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) def is_ok(n): cnt = 0 for a in A: if n >= a: continue cnt += a // n 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+1)) " p02598,s193330508,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) result = max(a) left = 1 right = result med = left + (right - left) // 2 while left <= right: counter = sum([(x - 1) // med for x in a]) if counter <= k: result = med right = med - 1 else: left = med + 1 med = left + (right - left) // 2 print(result)" p02598,s555294339,Accepted,"import heapq n, k = map(int, input().split()) a = [int(i) for i in input().split()] ok = 10**9 ng = 0 while abs(ng-ok) > 1: m = (ok+ng)//2 cou = 0 for i in a: cou += (i+m-1)//m-1 if cou <= k: ok = m else: ng = m print(ok) " p02598,s445931243,Accepted,"#!/usr/bin python3 # -*- coding: utf-8 -*- import bisect n,k = map(int, input().split()) a = sorted(list(map(int, input().split()))) def cnt(x): ret = 0 for ai in a: ret += (ai+(x-1))//x - 1 return ret ok, ng = a[-1], 0 while ok - ng > 1: nw = (ok + ng) // 2 if cnt(nw)<=k: ok = nw else: ng = nw print(ok) " p02598,s813597528,Accepted," def isok(A, X, k): cnt = 0 for a in A: cnt += (a+X-1)//X-1 return True if cnt <= k else False N, K = map(int, input().split()) A = list(map(int, input().split())) # 答えを二分探索 left = 0 # 条件をみたさない right = 10**9 # みたす while right-left > 1: mid = left + (right-left)//2 if isok(A, mid, K): right = mid else: left = mid print(right) " p02598,s015200107,Accepted,"import math from heapq import heappop import heapq N, K = map(int, input().split()) A = list(map(int, input().split())) l = 0 r = max(A)+1 while(l+1 < r): m = (l+r)//2 tmp = 0 for a in A: tmp += math.ceil(a / m)-1 if tmp <= K: r = m else: l = m print(r) " p02598,s761080124,Accepted,"import math def is_lt_or_e_K(k, x, a): if k >= sum([math.ceil(i / x) - 1 for i in a]): return True else: return False n, k = map(int, input().split()) a = list(map(int, input().split())) high = max(a) low = 0 while 1: if high - low < 2: break x = (high + low) // 2 if is_lt_or_e_K(k, x, a): high = x else: low = x print(high) " p02598,s527415185,Accepted,"from math import ceil N, K = map(int, input().split()) A = [*map(int, input().split())] l_lb, l_min = 0, max(A) while l_min - l_lb > 1: l_mid = (l_lb + l_min) // 2 if sum(ceil(a/l_mid) for a in A) - N > K: l_lb = l_mid else: l_min = l_mid print(l_min)" p02598,s560679309,Accepted,"import math N, K = map(int, input().split()) A = list(map(int, input().split())) mini = 0 maxi = max(A) while maxi - mini > 1: mid = (maxi+mini)//2 s = sum(math.ceil(a/mid)-1 for a in A) if s>K: mini = mid else: maxi = mid print(mini+1)" p02598,s504089444,Accepted,"def meg_bisect(ng, ok, func): while abs(ok - ng) > 1: mid = (ok + ng) // 2 if func(mid): ok = mid else: ng = mid return ok n, k, *a = map(int, open(0).read().split()) print(meg_bisect(0, max(a), lambda x: sum(0--b // x - 1 for b in a) <= k))" p02598,s023049495,Accepted," def bisect(ng, ok, judge, eps=1): while abs(ng-ok) > eps: m = (ng+ok)//2 if judge(m): ok = m else: ng = m return ok N,K = map(int,input().split()) A = tuple(map(int,input().split())) K += N def judge(d): return sum((a-1)//d+1 for a in A) <= K for d in range(1,7): r = sum((a-1)//d+1 for a in A) res = bisect(0,max(A),judge) print(res)" p02598,s427457761,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) low = 0 top = max(a) + 1 while top - low > 1: mid = (top + low) // 2 cnt = 0 for i in range(n): if a[i] % mid == 0: cnt += (a[i] // mid) - 1 else: cnt += a[i] // mid if cnt <= k: top = mid else: low = mid print(top) " p02598,s719956788,Accepted,"from math import * f=lambda:[*map(int,input().split())] n,k=f() a=f() def ok(x): c=0 for i in a: c+=ceil(i/x) return c<=n+k l,r=0,10**9 while r-l>1: m=(l+r)/2 if ok(m): r=m else: l=m t=ceil(r) print(t-ok(t-1) if t>1 else t)" p02598,s618600548,Accepted,"BIG = 10**10 N, K = map(int, input().split()) A = list(map(int, input().split())) # N, K = 2*10**5, 2*10**5 # A = [10**9]*N def solve(x): m = 0 for a in A: m += -(-(a//x)) # print(x, m) return m > K A = [a*BIG for a in A] # c = 0 ok, ng = 0, max(A) while abs(ok-ng) > 1: mid = (ok+ng)//2 # print(mid) if solve(mid): ok = mid else: ng = mid # c += 1 # print(c) print(-(-ok//BIG))" p02598,s375201192,Accepted,"n, k = map(int, input().split()) alst = list(map(int, input().split())) if k == 0: print(max(alst)) exit() l = 1 r = max(alst) while r != l: pos = (r + l) // 2 cnt = 0 for a in alst: cnt += (a - 1) // pos if cnt <= k: r = pos else: l = pos + 1 print(r)" p02598,s317301007,Accepted,"from math import ceil def main(): N, K = map(int, input().split()) A = list(map(int, input().split())) def check(Min): kill = 0 for a in A: kill += (ceil(a/Min)-1) return kill <= K l = 0 r = 1000000000 while r-l > 1: mid = (l+r)//2 if check(mid): r = mid else: l = mid print(r) if __name__ == '__main__': main()" p02598,s521315250,Accepted,"import math def main(): N, K = map(int, input().split()) As = list(map(int, input().split())) l = 0 r = 10**9 while (r - l) >= 10**(-6): m = (l + r) / 2 t = 0 for A in As: t += math.ceil(A / m - 1) if t > K: break if t <= K: l, r = l, m else: l, r = m, r print(math.ceil(l)) main() " p02598,s546847285,Accepted,"def main(): import sys def input(): return sys.stdin.readline().rstrip() n , k = map(int, input().split()) a = list(map(int, input().split())) l = 1 r = max(a) while l < r: m = (l+r)//2 cnt = 0 for x in a: cnt += (x-1)//m if cnt > k: l = m+1 else: r = m print(r) if __name__ == '__main__': main()" p02598,s470202137,Accepted,"import math N,K = map(int,input().split()) A = list(map(int,input().split())) max_a = max(A) u = max_a d = 0 res = 9 max_do = math.ceil(math.log(max_a*10,2)) for _ in range(max_do): n = (u + d)/2 _k = 0 for _a in A: _k += math.ceil(_a/n) - 1 if _k > K: d = n else: u = n print(math.ceil(n))" p02598,s082226165,Accepted,"N,K = map(int,input().split()) A = list(map(int,input().split())) A.sort() def f(A,N): ans = 0 for i in range(len(A)): ans += -(-A[i]//N) - 1 return ans ok = 10000000000 ng = 0 while abs(ok-ng) > 1: mid = (ok+ng) // 2 if f(A,mid) <= K: ok = mid else: ng = mid print(ok) " p02598,s795186066,Accepted,"N, K = map(int, input().split()) logs = list(map(int, input().split())) maxL = max(logs) minz = 0 maxz = maxL+1 while minz < maxz-1: midz = (maxz + minz)//2 ncut = 0 for i in range(N): thiscut = int((logs[i] + midz - 1) / midz) - 1 ncut += thiscut if ncut > K: minz = midz else: maxz = midz print(maxz)" p02598,s791783718,Accepted,"import math N, K = map(int, input().split()) A = sorted(list(map(int, input().split()))) def check(L): return sum(math.ceil(a / L)-1 for a in A) <= K answer=max(A) lo = 1 hi = answer+1 while lo < hi: m = (lo + hi)//2 ok = check(m) if ok: answer=min(m, answer) hi=m else: lo=m+1 print(answer) " p02598,s739559833,Accepted,"def is_ok(X): cnt = 0 for a in A: cnt += -(-a//X)-1 if cnt <= k: return True else: return False 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 n, k = map(int,input().split()) A = list(map(int,input().split())) print(meguru_bisect(0,max(A)+1))" p02598,s186057494,Accepted,"''' Date : 2020-08-09 00:46:52 Author : ssyze Description : ''' n, k = map(int, input().split()) a = list(map(int, input().split())) def check(m): sum = 0 for i in range(len(a)): sum += (a[i] - 1) // m if sum > k: return False else: return True l = 1 r = 10**9 ans = 10**9 while l < r: mid = (l + r) // 2 if check(mid) == 1: r = mid ans = mid else: l = mid + 1 print(ans) " p02598,s478086519,Accepted,"import math n, k = map(int, input().split()) aas = list(map(int, input().split())) diff = pow(10,-6) left = 1 right = 10**9 def judge(mid): cut = 0 for i in aas: cut += math.ceil(i / mid) - 1 if cut <= k: return True else: return False while left < right: mid = (left + right) / 2 if (left <= right <= left + diff) or (right <= left <= right + diff): break elif judge(mid): right = mid else: left = mid print(math.ceil(left))" p02598,s852210704,Accepted,"def is_ok(mid): cnt = 0 for i in range(n): cnt += (a[i] - 1) // mid return cnt <= k n, k = map(int, input().split()) a = list(map(int, input().split())) ok = 10 ** 18 ng = 0 while abs(ok - ng) > 1: mid = (ok + ng) // 2 if is_ok(mid): ok = mid else: ng = mid print(ok) " p02598,s887584750,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) l = 0 r = max(a) while r - l > 1: # min is in (l, r] c = (l + r) // 2 t = 0 for ai in a: t += (ai + c - 1) // c - 1 if t <= k: r = c else: l = c print(r)" p02598,s624291667,Accepted,"from math import * f=lambda:[*map(int,input().split())] n,k=f() a=f() def ok(x): c=0 for i in a: c+=ceil(i/x) return c<=n+k l,r=0,10**9+1 while r-l>0.1: m=(l+r)/2 if ok(m): r=m else: l=m t=ceil(r) print(t-ok(t-1) if t>1 else t)" p02598,s816863241,Accepted,"import numpy as np N, K = map(int, input().split()) A = np.array(input().split(), dtype=np.int64) l = 0 r = 2 * 10 ** 9 + 10 ** 6 while r - l > 1: m = (r + l) // 2 cnt = ((A + m - 1) // m).sum() if cnt <= N + K: r = m else: l = m print(r)" p02598,s894197708,Accepted,"f=lambda:map(int,input().split()) N,K=f() A=list(f()) def isOK(X): if X<=0: return False return sum([-a//X*-1-1 for a in A])<=K ok=10**10 ng=-1 while abs(ok-ng)>1: mid=(ok+ng)//2 if isOK(mid): ok=mid else: ng=mid print(ok)" p02598,s895273108,Accepted,"from math import ceil n,k = map(int,input().split()) a = list(map(int,input().split())) def cut(x): t = 0 for i in a: if i <= x: continue t += ceil(i / x) - 1 return t <= k l,r=0,10**9 while l+1 < r: x = l + (r-l)//2 if cut(x): r = x else: l = x print(r)" p02598,s053484001,Accepted,"from math import ceil n,k = map(int,input().split()) A = list(map(int,input().split())) l = 0 r = 10**9 ans = 0 while l+1 < r: m = (l+r)//2 c = 0 for a in A: c += ceil(a/m)-1 if c <= k: ans = min(ans,m) r = m else: l = m print(r)" p02598,s724998144,Accepted,"import math n,k=map(int,input().split()) a=list(map(int,input().split())) ng=0 ok=10**9 while ok-ng >1: l = (ng+ok)//2 kt=0 for i in range(n): kt += a[i]//l - (0 if a[i]%l else 1) if kt <= k: ok = l else: ng = l print(ok)" p02598,s578316144,Accepted,"import sys import math n,k = map(int,input().split()) a = list(map(int,input().split())) if k ==0: print(max(a)) sys.exit() def check(t): ans = 0 if t==0: return False for aa in a: if aa > t: ans += aa//t return ans <= k max = 10**9+1 min = 0 while max-min>1: mid = (max+min)//2 if check(mid): max = mid else: min = mid print(math.ceil(max))" p02598,s929322825,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) l = 0 r = 10**9 + 1 ref = 0 ans = 10**9 while r - l > 1: now = (l + r)//2 for i in a: ref += 0 - -i//now - 1 if ref <= k: ans = now ref = 0 r = now else: ref = 0 l = now print(ans)" p02598,s932806312,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) def check(l): k = 0 for a in A: k += (a-1)//l return k<=K max_ng = 0 min_ok = 10**9 while min_ok-max_ng>1: tgt = (min_ok+max_ng)//2 if check(tgt): min_ok = tgt else: max_ng = tgt print(min_ok) " p02598,s442311799,Accepted,"n,k=map(int,input().split()) a=list(map(int,input().split())) def ok(l): cnt = 0 for L in a: cnt += L//l if L%l != 0: cnt +=1 cnt-=1 return cnt<=k bot,top=0,max(a) while top - bot >1: mid = (top + bot) //2 if ok(mid): top = mid else: bot = mid print(top)" p02598,s901475777,Accepted,"N, K = map(int, input().split()) a = list(map(int, input().split())) max_a = 10**9 min_a = 0 while max_a-min_a>1: count = K mean_a = (max_a+min_a)//2 for i in range(N): if a[i]<=mean_a: continue count -= a[i]//mean_a if count >= 0: max_a = mean_a else: min_a = mean_a print(max_a)" p02598,s227196440,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) def is_ok(x): cnt = 0 for a in A: cnt += a // x if a % x == 0: cnt -= 1 return cnt <= K ng = 0 ok = 10**9 while ok - ng > 1: mid = (ok + ng) // 2 if is_ok(mid): ok = mid else: ng = mid print(ok)" p02598,s212447617,Accepted,"n, k = map(int, input().split()) a = sorted(list(map(int, input().split())))[::-1] l = 0 r = a[0] + 1 ref = 0 ans = a[0] while r - l > 1: now = (l + r)//2 for i in a: ref += 0 - -i//now - 1 if ref > k: ref = 0 l = now break else: ans = min(ans, now) ref = 0 r = now print(ans)" p02598,s506312928,Accepted,"def solve(a): #長さaにするのに何回いるか ret = 0 for x in A: if x%a == 0: temp = x//a-1 else: temp = x//a ret += temp return ret N,K = map(int,input().split()) A = list(map(int,input().split())) total = N+K Sum = sum(A) MAX = pow(10,9)+10 ng = 0 ok = MAX while abs(ok-ng) > 1: mid = (ok+ng)//2 if solve(mid) <= K: ok = mid else: ng = mid print(ok) #print(solve(3))" p02598,s369447346,Accepted,"import bisect n,k = map(int, input().split()) a = sorted(list(map(int, input().split()))) def cnt(x): ret = 0 for ai in a: ret += (ai+(x-1))//x - 1 return ret ok, ng = a[-1], 0 while ok - ng > 1: nw = (ok + ng) // 2 if cnt(nw)<=k: ok = nw else: ng = nw print(ok)" p02598,s247728786,Accepted,"import math N, K = map(int, input().split()) A = list(map(int, input().split())) def check(k): cnt = 0 for a in A: cnt += math.ceil(a/k) - 1 return cnt <= K l, r = 0, 10**10 while r - l > 1: mid = (r + l) // 2 if check(mid): r = mid else: l = mid print(r) " p02598,s149727827,Accepted,"n,k = map(int,input().split()) l = list(map(int,input().split())) l.sort() x,y=0,10**9 while y>x+1: m = (x+y)//2 c=0 for i in l: c+=(i-1)//m if c<=k: y=m else: x=m print(y)" p02598,s239925460,Accepted,"import math n,k=map(int,input().split()) A=list(map(int,input().split())) low=1 high=max(A) while low!=high: mid=(low+high)//2 s=0 for i in range(n): s+=math.ceil(A[i]/mid)-1 if s>k: low=mid+1 else: high=mid print(low)" p02598,s286160881,Accepted,"n,k = map(int,input().split()) a = [int(i) for i in input().split()] l = 0 r = 10**9 while l+1 < r: m = (l+r)//2 cnt = 0 for i in range(n): cnt += (a[i]+m-1)//m-1 if cnt > k: l = m else: r = m print(r)" p02598,s648959122,Accepted,"from math import ceil def main(): n, k = map(int, input().split()) a = list(map(int, input().split())) a.sort() ng = 0 ok = a[-1] while ok - ng > 1: mid = (ok + ng) // 2 cnt = 0 for i in range(n): cnt += (a[i] - 1) // mid if cnt <= k: ok = mid else: ng = mid print(ceil(ok) if k > 0 else a[-1]) if __name__ == '__main__': main() " p02598,s302617309,Accepted,"import math n,k = map(int,input().split()) l = list(map(int,input().split())) def cnt_check(longest): if longest == 0: return False cnt = 0 for log in l: cnt += math.ceil(log/longest)-1 if cnt <= k: return True else: return False left = 0 right = max(l) while right - left > 1: middle = (left + right)//2 if cnt_check(middle): right = middle else: left = middle print(right)" p02598,s295451539,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) inf = 1 sup = max(a) while inf < sup: x = (inf + sup) // 2 cut = 0 for a_i in a: cut += (a_i - 1) // x if cut <= k: sup = x else: inf = x + 1 print(sup)" p02598,s184993849,Accepted,"n,k=map(int,input().split()) a=list(map(int,input().split())) a_max=max(a) min1=0 max1=a_max while max1-min1>1: zantei=(min1+max1)//2 ans=0 for x in range(n): if a[x]%zantei==0: ans+=a[x]//zantei-1 else: ans+=a[x]//zantei if ans<=k: max1=zantei else: min1=zantei print(max1)" p02598,s100040196,Accepted," def read_int(): return int(input().strip()) def read_ints(): return list(map(int, input().strip().split(' '))) def solve(): _, K = read_ints() A = read_ints() low, high = 0, max(A)+1 while high-low > 1: mid = low+(high-low)//2 # max log should be mid # 10, maximum log is 4 required_cuts = sum((a-1)//mid for a in A) if required_cuts <= K: high = mid else: low = mid return high if __name__ == '__main__': print(solve()) " p02598,s912144028,Accepted,"n,k=map(int,input().split()) a=list(map(int,input().split())) l,r=0,max(a) def test(x): num=0 for i in a: num+=i//x if i%x==0: num-=1 if num<=k: return num while r-l>1: mid=(l+r)//2 if test(mid): r=mid else: l=mid print(r)" p02598,s850706251,Accepted,"n,k=[int(i) for i in raw_input().split()] a=[int(i) for i in raw_input().split()] s=0 for i in a: s+=i val=(s+n+k-1)/(n+k) for i in a: k-=i/val if(k>=0): print val else: k=abs(k) l=[] for i in a: x=i/val if(x>0): l.append((i+x-1)/x) l.sort() print l[k-1] " p02598,s888260687,Accepted,"import sys input = sys.stdin.readline N,K=map(int,input().split()) A=list(map(int,input().split())) OK=10**9 NG=0 while OK-NG>1: mid=(OK+NG)//2 ANS=0 for a in A: ANS+=(a-0.01)//mid if ANS<=K: OK=mid else: NG=mid print(OK) " p02598,s335004382,Accepted,"N, M = input().strip().split() n, k = [int(N), int(M)] a = list(map(int, input().strip().split())) le = 0 ri = 10000000000 while ri - le > 1: mid = (le + ri)// 2 num = 0 for i in a: num += (i-1)// mid if num <= k: ri = mid else: le = mid print(ri) " p02598,s814069750,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) l = 0 r = 10 ** 9 + 1 while r - l > 1: m = (r + l) // 2 cnt = 0 for i in A: cnt += i // m if i >= m and i % m == 0: cnt -= 1 if cnt <= K: r = m else: l = m print(r)" p02598,s787921934,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) l , r = 0, max(a) def ok(L): cnt = 0 for i in a: cnt += i // L if i % L == 0: cnt -= 1 return cnt <= k while r - l > 1: mid = (r + l) //2 if ok(mid): r = mid else: l = mid print(r)" p02598,s523443533,Accepted,"n,k=map(int, input().split()) a = list(map(int, input().split())) a=sorted(a,reverse=True) if k==0: print(max(a)) exit() import math lo=0 hi=10**9 oldmid=0 while True: mid=(hi+lo)/2 cnt=0 for i in range(n): cnt+=round(a[i]/mid-0.5) if cnt>k: lo=mid elif cnt<=k: hi=mid if oldmid-0.000001<=(hi+lo)/2<=oldmid+0.000001: print(min(math.ceil(lo), max(a))) break oldmid=mid " p02598,s252891051,Accepted,"N,K = map(int,input().split()) A = list(map(int,input().split())) def check(x): k = 0 for a in A: k += ((a-1) // x) return k <= K ng,ok = 0, 10**9+1 while ok-ng > 1: x = (ok+ng)//2 if check(x): ok = x else: ng = x print(ok)" p02598,s810892756,Accepted,"n, k = map(int, input().split()) aes = list(map(int, input().split())) bottom, top = 0, max(aes) def ok(l): cnt = 0 for a in aes: if a % l == 0: cnt += a // l - 1 else: cnt += a // l return cnt <= k while top - bottom > 1: mid = (bottom + top) // 2 if ok(mid): top = mid else: bottom = mid print(top) " p02598,s160790907,Accepted,"import sys input = lambda: sys.stdin.readline().rstrip(""\r\n"") n, k = map(int, input().split()) a = [int(x) for x in input().split()] left = 0 right = 10**9 + 1 while right - left > 1: mid = (right + left) // 2 cnt = 0 for b in a: cnt += b // mid + int(b % mid != 0) - 1 if cnt <= k: right = mid else: left = mid print(right)" p02598,s467401492,Accepted,"n,k = map(int,input().split()) A = list(map(int,input().split())) def is_ok(s): cnt = 0 for i in range(n): cnt += (A[i]-1)//s return cnt<=k def main(): left = 0 right = max(A) while (right-left)>1: mid = (right+left)//2 if is_ok(mid): right = mid else: left = mid return right print(main()) " p02598,s425834005,Accepted,"import math N, K = map(int,input().split()) A = list(map(int,input().split())) def solve(x): #Trueで切り切れる cnt = 0 for a in A: cnt += math.ceil(a / x) - 1 return cnt <= K left = 0 right = 10 ** 9 + 1 for _ in range(100): mid = (left + right) / 2 if solve(mid): right = mid else: left = mid print(math.ceil(right))" p02598,s858847841,Accepted,"import math n, k = [int(i) for i in input().split()] a = [int(i) for i in input().split()] def seikai(x): count = 0 for i in range(n): count += math.ceil(a[i] / x) - 1 if(count <= k): return 1 else: return 0 l = 0 r = 10 ** 9 while(r - l > 1): temp = (r + l) // 2 if(seikai(temp) == 1): r = temp else: l = temp print(r)" p02598,s752477529,Accepted,"import math n, k = map(int, input().split()) a = list(map(int, input().split())) def cond(x): s = 0 for i in range(n): s += math.ceil(a[i]/x)-1 return s <= k l, r = 0, 10**9 while l+1 < r: mid = (l+r)//2 if cond(mid): r = mid else: l = mid print(r)" p02598,s375190410,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) l = 0 r = max(A) for _ in range(30): mid = (r + l + 1) // 2 count = 0 for log in A: if log > mid: count += (log + mid - 1) // mid - 1 if count <= K: r = mid else: l = mid print(r) " p02598,s207464971,Accepted,"n,k = map(int, input().split()) a = list(map(int, input().split())) def check(x): cnt = 0 for ai in a: cnt += (ai-1)//x if cnt > k: return False return True left = 0 right = 10**9+1 while right-left>1: mid = (right+left)//2 if check(mid): right=mid else: left=mid print(right)" p02598,s062225120,Accepted,"from math import floor m=0 M=10**9+1 N,K=map(int,input().split()) A=list(map(int,input().split())) def OK(p): if sum([(a-1)//p for a in A])<=K: return True else: return False while M-m>1: p=(m+M)//2 if OK(p): M=p else: m=p print(M)" p02598,s448684908,Accepted,"from math import ceil n,k=map(int,input().split()) a=[int(i) for i in input().split()] def is_ok(x): c=0 for i in a: c+=ceil(i/x)-1 if c>k: return False return True def binary_search(m): left=0 right=m+1 while left<=right: center=(left+right)//2 if right-left==1: return right elif is_ok(center): right=center else: left=center if k==0: print(max(a)) else: print(binary_search(max(a)))" p02598,s024642283,Accepted,"from math import ceil from fractions import Fraction n, k, *aa = map(Fraction, open(0).read().split()) imp_length = 0 psbl_length = max(aa) while psbl_length - imp_length > 1: mid = (psbl_length + imp_length) // 2 cost = sum(ceil(a / mid) - 1 for a in aa) if cost <= k: psbl_length = mid else: imp_length = mid print(psbl_length)" p02598,s169300657,Accepted,"import math n, k = map(int, input().split()) a = list(map(int, input().split())) floor = 0 ceil = max(a) def cut(long, logs): cnt = 0 for i in logs: cnt += math.ceil(i / long) - 1 return cnt while ceil - floor > 1: L = (ceil + floor)//2 num = cut(L, a) if num <= k: ceil = L else: floor = L print(ceil)" p02598,s514525998,Accepted,"n, k = map(int, input().split()) A = [*map(int, input().split())] ng, ok = 0, 10**9 # (ng,ok] = (l,r] while ok - ng > 1: m = (ng + ok) // 2 c = 0 for a in A: c += (a - 1) // m if c <= k: ok = m else: ng = m print(ok) " p02598,s856166724,Accepted,"import math N, K = map(int, input().split()) a = list(map(int, input().split())) a.sort() l = 0 r = a[-1] + 1 while r - l > 1: mid = (r + l) // 2 cnt = 0 for i in a: cnt += (i - 1) // mid if cnt <= K: r = mid else: l = mid print(r)" p02598,s503502081,Accepted,"N,K=map(int,input().split()) A=list(map(int,input().split())) MIN=0 MAX=10**9 while MAX-MIN>1: mid=(MAX+MIN)//2 tmp=0 for i in range(N): tmp+=(A[i]-1)//mid if tmp>K: MIN=mid else: MAX=mid print(MAX)" p02598,s130971118,Accepted,"def main(): n, k = map(int, input().split()) A = list(map(int, input().split())) l, r = 0, max(A) while r - l > 1: c = (l + r) // 2 if sum((a - 1) // c if a > c else 0 for a in A) <= k: r = c else: l = c print(r) if __name__ == '__main__': main() " p02598,s699626203,Accepted,"n,k=map(int,input().split()) A = list(map(int, input().split())) r = max(A) l = 0 while l+1k: l=mid else: r = mid print(r)" p02598,s413850671,Accepted,"import math N, K = map(int,input().rstrip().split()) A = list(map(int,input().rstrip().split())) maxX = max(A) minX = 0 X = (maxX + minX)//2 while X!=minX: num = sum([math.ceil(A[i]/X)-1 for i in range(N)]) if num<=K: maxX = X else: minX = X X = (maxX + minX)//2 num = sum([math.ceil(A[i]/maxX)-1 for i in range(N)]) if num<=K: print(maxX) else: print(minX)" p02598,s998051826,Accepted,"from math import * def trycut(val): if val == 0 : return float('inf') ret = 0 for i in range(n): ret += (a[i]+val-1)//val -1 return ret n,k=map(int,input().split()) a = [int(i) for i in input().split()] low = 0 high = max(a) ans =-1 while low <= high: mid = (low + high)//2 cut = trycut(mid) if cut <= k: high = mid-1 ans = mid else: low = mid+1 print(ans) " p02598,s400475488,Accepted,"n,k = map(int,input().split()) a = list(map(int,input().split())) l = 0 r = 10 ** 9 while r-l > 1 : m = (l+r)//2 b = list(map(lambda x: -(-x//m) - 1 ,a)) ans = sum(b) if ans <= k : r = m else : l = m print(r) " p02598,s578750891,Accepted,"from math import ceil N, K = list(map(int, input().split())) A = list(map(int, input().split())) def possible(A, K, target): count = 0 for a in A: count += ceil(a / target) - 1 return count <= K left = 1 right = max(A) while left < right: mid = (left + right) // 2 if possible(A, K, mid): right = mid else: left = mid + 1 print(right) " p02598,s724286575,Accepted,"import math def judge(x): cnt=0 for l in a: c=l//x if l%x!=0: c+=1 cnt+=c-1 return cnt<=k n,k=map(int,input().split()) a=list(map(int,input().split())) left=0 right=max(a) mid=(left+right)//2 while right-left>1:# 最後は整数なので実数で扱わなくていい if judge(mid): right=mid mid=(left+right)//2 else: left=mid mid=(left+right)//2 print(right) " p02598,s076395615,Accepted,"n,k=map(int,input().split()) a=list(map(int,input().split())) import math ng=0 ok=max(a) center=(ok+ng)//2 while ng+1!=ok: counter=0 for i in range(len(a)): counter+=math.ceil(a[i]/center)-1 if counter>k: ng=center center=(ok+ng)//2 else: ok=center center=(ok+ng)//2 print(ok) " p02598,s630342284,Accepted,"import math N, K = map(int, input().split()) A = list(map(int, input().split())) l = 0 r = int(1e9) def f(x): count = 0 for a in A: count += int((a-1)/x) return count <= K while r-l > 1: x = int((r+l)/2) if f(x): r = x else: l = x print(r)" p02598,s032273506,Accepted,"import sys def input(): return sys.stdin.readline().strip() def mapint(): return map(int, input().split()) sys.setrecursionlimit(10**9) N, K = mapint() As = list(mapint()) maxa = max(As) l, r = 0, maxa+1 while r-l>1: half = (l+r)//2 cnt = 0 for a in As: cnt += -(-a//half)-1 if cnt>K: l = half else: r = half print(r)" p02598,s294436748,Accepted,"from heapq import heapify, heappop, heappush from math import ceil inpl = lambda: list(map(int,input().split())) N, K = inpl() A = inpl() total = sum(A) H = [] remnant = K for a in A: n = (K*a)//total remnant -= n H.append((-a/(n+1), n, a)) heapify(H) for k in range(remnant): L, n, a = heappop(H) heappush(H, (-a/(n+2), n+1, a)) ans = int(ceil(-H[0][0])) print(ans) " p02598,s128221651,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) ok = max(a) ng = 1 from math import ceil def f(length): rtn = 0 for i in range(n): rtn += ceil(a[i]/length) - 1 return rtn if f(1) == 0: print(1) else: while ok - ng > 1: mid = (ok + ng)//2 if f(mid) <= k: ok = mid else: ng = mid if f(ng) > k: print(ok) else: print(ng)" p02598,s507460158,Accepted,"n,k = list(map(int,input().split())) arr = list(map(int,input().split())) lo = 1 hi = 10**12 ans = max(arr) while lo<=hi: t = 0 m = (hi+lo)//2 for i in range(n): if arr[i]>m: req = arr[i]//m else: req= 0 t+=req if t<=k: ans = m hi = m-1 else: lo = m+1 print(ans)" p02598,s546343290,Accepted,"import sys from fractions import Fraction import math import heapq input = sys.stdin.readline n, k = list(map(int, input().split())) a = list(map(int, input().split())) s = sum(a) w = [(k * a[i]) // s for i in range(n)] b = [Fraction((w[i] + 1), a[i]) for i in range(n)] r = k - sum(w) heapq.heapify(b) #print(b) for i in range(r): x = heapq.heappop(b) heapq.heappush(b, Fraction(x.numerator+1, x.denominator)) y = heapq.heappop(b) print(math.ceil(Fraction(y.denominator, y.numerator))) " p02598,s343919570,Accepted,"import math n,k = map(int,input().split()) A = list(map(int,input().split())) low = 1 high = max(A) while low != high: mid = (low + high)// 2 cnt = 0 for i in A: cnt += math.ceil(i/mid) - 1 if cnt > k : low = mid + 1 else: high = mid print(low)" p02598,s079613678,Accepted,"n,k=map(int,input().split()) A=[int(i) for i in input().split()] def f(i): if i<=0: return False if i>= 10**9: return True x = sum([(a-1)//i for a in A]) if x<=k: return True else: return False l=-1 r=10**9 while r-l>1: m = (l+r)//2 if f(m): r=m else: l=m #print(l,m,r) print(r)" p02598,s245953908,Accepted,"n, k = map(int, input().split()) a = [int(x) for x in input().split()] lo = 1 hi = max(a) def ceildiv(a, b): return (a + b - 1) // b def ok(x): cuts = 0 for log in a: cuts += ceildiv(log, x) - 1 if cuts <= k: return True return False while lo < hi: mid = (lo + hi) // 2 if ok(mid): hi = mid else: lo = mid + 1 print(lo) " p02598,s432367415,Accepted,"n,k=map(int,input().split()) A=list(map(int,input().split())) ng=0 ok=10**10 while ok-ng>1: mid=(ok+ng)//2 c=0 for i in range(n): c=c+(A[i]+mid-1)//mid if c>k+n: ng=mid else: ok=mid print(ok)" p02598,s798476945,Accepted,"import heapq n , k = map(int,input().split()) a = list(map(int,input().split())) lef = 0 rig = max(a) while rig - lef != 1: now = -(-(lef+rig)//2) cou = 0 for i in range(n): cou += -(-a[i]//now) - 1 if cou <= k: rig = now elif cou > k: lef = now print(rig)" p02598,s536822580,Accepted,"n,k=map(int,input().split()) a=list(map(int,input().split())) ok=10**10 ng=1 for i in range(40): chk=(ok+ng)//2 cnt=0 for j in range(n): cnt+=(a[j]+chk-1)//chk-1 if cnt > k: ng = chk else: ok = chk print(ok) " p02598,s892647057,Accepted,"n, k = map(int, input().split()) a = [i-1 for i in map(int, input().split())] left, right = 0, 10**9 while left < right: middle = (left+right)//2 if middle==0: left=1 break count = 0 for i in a: count += i//middle if count <= k: right = middle else: left = middle + 1 print(left)" p02598,s937287179,Accepted,"#!/usr/bin/env python3 import os import sys import numpy as np def ncut(l, x): return np.sum(np.ceil(l / x) - 1) def solve(N, K, AS): ng, ok = -1, np.amax(AS) while abs(ok - ng) > 1: mid = (ok + ng) // 2 if ncut(AS, mid) <= K: ok = mid else: ng = mid return ok.item() def main(): d = np.fromstring(sys.stdin.read(), dtype=np.int64, sep=' ') N, K = d[:2] AS = d[2:] print('{}'.format(solve(N, K, AS))) if __name__ == '__main__': main()" p02598,s400622082,Accepted,"from math import ceil def BinarySearch(x): ans = sum([ceil(a/x)-1 for a in A]) if ans <= K: return True else: return False N,K = map(int,input().split()) A = list(map(int,input().split())) r = max(A) l = 0 eps = 10**-6 while abs(r-l) > eps: m = (r+l)/2 if BinarySearch(m): r = m else: l = m print(ceil(r)) " p02598,s935449172,Accepted,"#Binary Search: N, K = map(int,input().split()) A = list(map(int,input().split())) s = 0 t = max(A) while s + 1 < t: m = (s + t) // 2 temp = 0 for i in A: temp += (i - 1) // m if temp <= K: # feasible t = m else: # infeasible s = m print(t)" p02598,s783420204,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)" p02598,s174605181,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) def is_cuttable(N): n = 0 for a in A: i = a // N if a % N == 0: i -= 1 n += int(i) if n > K: return False return True n_max = 10 ** 10 n_min = 0 while n_max - n_min > 1: n = (n_max + n_min) // 2 if is_cuttable(n): n_max = n else: n_min = n print(n_max)" p02598,s727928671,Accepted,"N, K = map(int,input().split()) A = list(map(int,input().split())) def func(l,r): if l==r: return l mid = (l+r)//2 count = 0 for i in A: count += (i-0.1)//mid if count <= K: return func(l,mid) else: return func(mid+1,r) print(func(1,max(A)))" p02598,s631734246,Accepted,"from math import ceil def isOK(length): ans = 0 for a in A: ans += ceil(a / length) - 1 return ans <= k n, k = map(int, input().split()) A = list(map(int, input().split())) start, end = 0, 10**9 + 1 while True: mid = (start + end) // 2 if mid == 1: print(mid) exit() prev = mid - 1 if isOK(mid): if isOK(prev): end = mid else: print(mid) exit() else: start = mid " p02598,s845911715,Accepted,"def main(): N, K = map( int, input().split()) A = list( map( int, input().split())) cnt = 0 l = 0 r = 10**9+1 ans = 0 while r-l > 1: m = (l+r)//2 k = 0 # print(l,r) for a in A: k += ((a+m-1)//m)-1 if k <= K: r = m else: l = m print(r) if __name__ == '__main__': main() " p02598,s753269471,Accepted,"from math import ceil N,K=map(int, input().split()) A=list(map(int, input().split())) left=1 right=10**9+1 ans=float(""INF"") while True: mid=(left+right)//2 now=0 for i in range(N): now+=ceil(A[i]/mid)-1 if now>K: if left==mid: break left=mid else: ans=min(ans, mid) if right==mid: break right=mid print(ans)" p02598,s060359814,Accepted,"import sys import math input = sys.stdin.readline n, k = map(int, input().split()) a = list(map(int, input().split())) def check(x): res = 0 for i in a: res += math.floor(i / x) return res l = 0 r = 10 ** 9 + 1 for _ in range(100): x = (l + r) / 2 if check(x) > k: l = x else: r = x print(math.ceil(l)) " p02598,s959753301,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) lb, ub = 0, max(a) while ub - lb > 1: mid = (ub + lb) // 2 cnt = 0 for i in range(n): cnt += a[i] // mid if a[i] % mid != 0: cnt += 1 cnt -= 1 if cnt <= k: ub = mid else: lb = mid print(ub) " p02598,s867006739,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) # 合計N+Kこになる l = 0 r = 2 * 10 ** 9 + 10 ** 6 while r - l > 1: m = (r + l) // 2 cnt = 0 for a in A: cnt += (a + m - 1) // m if cnt <= N + K: r = m else: l = m print(r)" p02598,s815221908,Accepted,"import math N, K = map(int, input().split()) a = list(map(int, input().split())) a.sort() l = 0 r = a[-1] + 1 while r - l > 1: mid = (r + l) // 2 cnt = 0 for i in a: cnt += (i - 1) // mid if cnt <= K: r = mid else: l = mid print(r)" p02598,s757844374,Accepted,"_, k = map(int, input().split()) A = [*map(int, input().split())] ng, ok = 0, 1<<30 while ok - ng > 1: m = (ng + ok) // 2 if k < sum((a-1)//m for a in A): ng = m else: ok = m print(ok) " p02598,s340568933,Accepted,"n, k = map(int, input().split()) a = [i-1 for i in map(int, input().split())] left, right = 1, 10**9 while left < right: middle = (left + right)//2 count = sum(i//middle for i in a) if count <= k: right = middle else: left = middle + 1 print(left)" p02598,s506590473,Accepted,"import sys import heapq import math def input(): return sys.stdin.readline().rstrip() def main(): N, K = map(int, input().split()) A = list(map(int, input().split())) ok = max(A) ng = 0 while abs(ok - ng) > 1: mid = abs(ok + ng) // 2 count = 0 for i in range(N): count += math.ceil(A[i] / mid)-1 if count <=K: ok = mid else: ng = mid print(ok) if __name__ == ""__main__"": main() " p02598,s110981359,Accepted,"import math n, k = map(int, input().split()) a = list(map(int, input().split())) def solve(x): kk = k for i in a: kk -= (i+x-1)//x - 1 return kk>=0 ok = 10**9 ng = 0 while abs(ok-ng)>1: mid = (ok+ng)//2 if solve(mid): ok = mid else: ng = mid print(ok)" p02598,s018868867,Accepted,"from sys import stdin rs = stdin.readline ri = lambda : int(rs()) ril = lambda : list(map(int, rs().split())) from functools import reduce def main(): N, K = ril() A = ril() l = 1 r = 1000000000 while l < r: m = (l + r) // 2 f = lambda i, j : i + (j - 1) // m k = reduce(f, A, 0) if k <= K: r = m else: l = m + 1 print(r) if __name__ == '__main__': main() " p02598,s889940192,Accepted,"n,k=list(map(int,input().split())) alst=list(map(lambda x:int(x)*100,input().split())) ok=max(alst) ng=0 while abs(ok-ng)>1: cen=(ok+ng)//2 cnt=0 for a in alst: cnt+=(a+cen-1)//cen-1 if cnt<=k: ok=cen else: ng=cen+1 if ok%100==0: print(ok//100) else: print(ok//100+1)" p02598,s561632976,Accepted,"import math as m def isltK(K,X): ccut=0 for Ai in As: ccut += m.ceil(Ai/X)-1 if ccut <=K: return True else: return False N,K=map(int,input().split()) As=list(map(int,input().split())) l=1 h=max(As) while l < h: mid = (l+h)//2 if isltK(K,mid): h=mid else: l=mid+1 print(l)" p02598,s772455319,Wrong Answer,"n, k = map(int, input().split()) a = list(map(int, input().split())) low = 0 top = max(a) + 1 while top - low > 1: mid = (top + low) // 2 cnt = 0 for i in range(n): cnt += (a[i] + 1) // mid if cnt <= k: top = mid else: low = mid print(low) " p02598,s032526303,Wrong Answer,"def main(): import sys def input(): return sys.stdin.readline().rstrip() n , k = map(int, input().split()) a = list(map(int, input().split())) from heapq import heappop, heappush, heapreplace a = [-x for x in a] a.sort() for i in range(k): x = a[0] if abs(x) < 1: break heapreplace(a, x//3) heappush(a, x-x//3) ans = abs(a[0]) print(ans) if __name__ == '__main__': main()" p02598,s364420675,Wrong Answer,"N,K = map(int, input().split()) A = [int(a) for a in input().split()] def f(X): cnt = 0 for a in A: cnt += int(a/X) return max(1, cnt) l = 1 r = max(A) while r-l > 0.1: m = (r+l)/2 if f(m) <= K: r = m else: l = m if K == 0: print(max(A)) elif f(r) >= K and int(r) < r: print(int(r)+1) elif int(l) < l: print(int(l)+1) else: print(int(l))" p02598,s850153032,Wrong Answer,"import math N, K = map(int, input().split()) A = list(map(float, input().split())) if K == 0: print(int(max(A))) exit() if N == 1: print(math.ceil(A[0]/K)) exit() min_A = 0 max_A = max(A) while( max_A - min_A > 1): now = (min_A + max_A) / 2 temp = 0 for i in A: temp += (i // now) if temp > K: min_A = now else: max_A = now print(math.ceil((min_A + max_A)/2))" p02598,s647572467,Wrong Answer,"import math N,K = map(int,input().split()) A = list(map(int,input().split())) m = 0 M = max(A) while(M-m>0.0001): mm = 0 mid = (M+m)/2 for i in range(N): mm += math.ceil(A[i]/mid)-1 if mm>K: m = mid+1 else: M = mid print(math.ceil(mid)) " p02598,s382515712,Wrong Answer,"import math n,k=map(int,input().split()) log=list(map(int,input().split())) a=1 b=max(log) c=(a+b)//2 while True: div=0 for i in range(n): div+=math.ceil(log[i]/c)-1 if div<=k: b=c c=(a+b)//2 else: a=c c=(a+b)//2 if c==a or c==b: break print(b)" p02598,s496665647,Wrong Answer,"# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..) import sys from math import ceil def main(N, K, A): def cut_times(longest): return sum(a // longest for a in A) under = 0 r = 10**9 for i in range(100): m = (under + r) / 2 if cut_times(m) > K: under = m else: r = m print(ceil(r - 10**-5)) if __name__ == '__main__': input = sys.stdin.readline N, K = map(int, input().split()) *A, = map(int, input().split()) main(N, K, A) " p02598,s120320884,Wrong Answer,"import heapq import math N, K = map(int, input().split()) A = list(map(int, input().split())) for i in range(N): p = A[i] A[i] = [-p, i] heapq.heapify(A) C = [0]*N for j in range(K): x, y = heapq.heappop(A) cnt = C[y] x = x * (cnt+1) // (cnt+2) C[y] += 1 heapq.heappush(A, [x, y]) ans = heapq.heappop(A)[0] ans = math.ceil(-ans) print(ans) " p02598,s512386492,Wrong Answer,"import math N, K = map(int, input().split()) A = list(map(float, input().split())) if K == 0: print(int(max(A))) exit() if N == 1: print(math.ceil(A[0]/K)) exit() min_A = 0 max_A = max(A) while( max_A - min_A > 1): now = (min_A + max_A) / 2 temp = 0 for i in A: temp += int(i / now) if temp > K: min_A = now else: max_A = now print(int(min_A) + 1)" p02598,s298183177,Wrong Answer,"n,k = map(int,input().split()) a = list(map(int,input().split())) l = 0 r = 10 ** 9 while r-l > 1 : m = (l+r)//2 b = list(map(lambda x: -(-x//m) - 1 ,a)) ans = sum(b) if ans <= k : r = m else : l = m print(l,r) print(r) " p02598,s533176594,Wrong Answer,"import numpy as np N, K = [int(x) for x in input().split()] A = np.array([int(x) for x in input().split()]) L = np.max(A) ans = L low = 1 high = L while 1: print(str(low) + ' ' + str(high)) if low == high: ans = low break mid = (low + high) // 2 if np.sum(A // mid) <= K: high = mid else: low = mid + 1 print(ans)" p02598,s534320449,Wrong Answer,"import numpy as np N,K = [int(x) for x in input().split()] Ls = [int(x) for x in input().split()] Ls = np.array(Ls) cut = np.array([1]*N) ans = Ls / cut for k in range(K): idx = np.argmax(ans) cut[idx] += 1 ans = Ls / cut print(int(np.round(max(ans))))" p02598,s052203032,Wrong Answer,"n, k = map(int, input().split()) a = list(map(int, input().split())) low = 0 top = max(a) + 1 while top - low > 1: mid = (top + low) // 2 cnt = 0 for i in range(n): if a[i] % mid == 0: cnt += a[i] // mid else: cnt += (a[i] // mid) + 1 if cnt <= k: top = mid else: low = mid print(low) " p02598,s266090725,Wrong Answer,"n, k = map(int, input().split()) a = list(map(int, input().split())) a.sort(reverse=True) left = 0 # できない right = a[0] # できる while left+1 < right: mid = (left+right) // 2 cnt = 0 for i in range(n): cnt += a[i] // mid if cnt > k: break if cnt > k: left = mid else: right = mid print(right)" 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() " p02598,s653076974,Wrong Answer,"import numpy as np def solve(n, k, a): lb = 0 ub = np.max(a) while ub - lb > 1: cur = (lb + ub) / 2 cnt = np.sum(np.ceil(a/cur)) - n if cnt > k: lb = cur else: ub = cur return int(np.ceil((lb+ub) / 2)) n, k = map(int, input().split()) a = list(map(int, input().split())) print(solve(n, k, a))" p02598,s743836930,Wrong Answer,"N, K = list(map(int, input().split())) A = list(map(int, input().split())) U = max(A) L = 1 def can(x, K): ct = 0 for i in range(N): ct += (A[i]-1)//x if ct <= K: return True else: return False while U-L > 1: x = (U+L)//2 if can(x, K): U = x else: L = x print(U)" p02598,s312849007,Wrong Answer,"n,k=map(int,input().split()) a=list(map(int,input().split())) tmax=max(a) tmin=0 t=(tmax+tmin)/2 import math ans=0 if k==0: print(tmax) else: while True: s=0 for i in range(n): s=s+math.ceil(a[i]/t)-1 if k>=s: ans=t tmax=t t=(tmin+t)/2 else: tmin=t t=(t+tmax)/2 if tmax-tmin<0.01: break print(math.ceil(ans))" p02598,s548677434,Wrong Answer,"import math N,K = map(int,input().split()) A = list(map(int,input().split())) m = 0 M = max(A) while(M-m>0.5): mm = 0 mid = (M+m)/2 for i in range(N): mm += math.ceil(A[i]/mid)-1 if mm>K: m = mid else: M = mid print(math.ceil(mid)) " p02598,s556847244,Wrong Answer,"n, k = map(int, input().split()) a = list(map(int, input().split())) def check(x): c = 0 for i in range(n): c += a[i]//x if c <= k: return True else: return False mx = max(a) mn = 0 ans = [mx] while mn < mx: m = (mx+mn)//2 if m == 0: break if check(m): mx = m - 1 ans.append(m) else: mn = m + 1 print (min(ans)) " p02598,s458212161,Wrong Answer,"import math N, K = map(int,input().split()) A = [int(i) for i in input().split()] low = 1 high = 10 ** 9 if K == 0: print(max(A)) else: while high - low > 1: mid = (low + high) / 2 times = 0 for a in A: times += math.ceil(a / mid) - 1 if K >= times: high = mid else: low = mid #print(mid) print(math.ceil(mid)) " p02598,s332534436,Wrong Answer,"N, K = map(int, input().split()) As = list(map(int, input().split())) def isOK(L): num = 0 for A in As: num += -(-A // L) - 1 return num <= K ng, ok = 0, 10**9 while abs(ok-ng) > 10**-6: mid = (ng+ok) / 2 if isOK(mid): ok = mid else: ng = mid k = int(-(-ok // 1)) for L in range(k-2, k+3): if isOK(L): print(L) break " p02598,s278272823,Wrong Answer," N, K = map(int, input().split()) X = list(map(int, input().split())) ub = 10 ** 9 + 7 lb = 0 while ub - lb > 1: mid = (ub + lb) // 2 res = 0 for v in X: res += v // mid if res <= K: ub = mid else: lb = mid if K == 0: print(max(X)) else: print(ub) " p02598,s452255931,Wrong Answer,"n, k = [int(i) for i in input().split()] a = [int(i) for i in input().split()] l = 0 r = max(a) while l < r: m = (l + r) // 2 cnt = 0 for v in a: if m == 0: cnt += 2 * v else: cnt += (v + m - 1) // m - 1 if cnt <= k: r = m else: l = m + 1 print(l) " p02598,s049172264,Wrong Answer,"N, K = map(int,input().split()) A = list(map(int,input().split())) A.sort() l, r = sum(A)//(N+K), A[-1] if l == 0: l = 1 while l+1 < r: m = (l+r) // 2 cuts = sum([(a-1)//m for a in A]) if cuts <= K: r = m else: l = m print(r)" p02598,s523116358,Wrong Answer,"import copy import math n, k = map(int,input().split()) a = list(map(int,input().split())) ub = 10**9 lb = 0 while ub - lb > 0.01: x = (ub + lb) / 2 cnt = 0 for i in a: cnt += math.ceil(i/x) if cnt <= n+k: ub = copy.deepcopy(x) else: lb = copy.deepcopy(x) ans = round(ub, 1) print(math.ceil(ans))" p02598,s891486858,Wrong Answer,"N, K = map(int,input().split()) A = sorted(map(int,input().split())) start = 0 end = A[-1] while end - start >= 1: l = (start + end)/2 count = 0 for i in range(N): count += (A[i]-1)//l if count > K: start = l else: end = l print(int(l))" p02598,s146286470,Wrong Answer,"from bisect import * from heapq import * import math mod = 10**9+7 N, K = map(int, input().split()) A = list(map(int, input().split())) ep = 0.0001 l = 0.0 r = 10**9+1 while l+ep < r: x = (l+r)/2 k = 0 for a in A: k += math.ceil(a/x)-1 if k > K: break if k <= K: r = x else: l = x print(math.ceil(l))" p02598,s490953886,Wrong Answer,"N,K = map(int, input().split()) A = [int(a) for a in input().split()] def f(X): cnt = 0 for a in A: cnt += int(a/X) return max(1, cnt) l = 1 r = max(A) while r-l > 0.1: m = (r+l)/2 if f(m) <= K: r = m else: l = m if K == 0: print(max(A)) elif f(int(r)+1) >= K: print(int(r)+1) elif f(int(r)) >= K: print(int(r))" p02598,s483164970,Wrong Answer,"N, K = map(int, input().split()) A = sorted(list(map(int, input().split()))) def check(N, K, A, L): return sum(a // L for a in A) <= K lo = 1 hi = max(A)+1 while lo < hi: m = (lo + hi)//2 ok = check(N, K, A, m) if ok: # m 出来れるのでもっと小さく切れるか hi=m else: lo=m+1 print(min(max(A), lo)) " p02598,s093392948,Wrong Answer,"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//x return res <= k while top - bottom > 1: mid = (top + bottom)//2 if ok(mid): top = mid else: bottom = mid print(top) " p02598,s425813713,Wrong Answer,"#E - Logs import math # 入力 N,K = map(int,input().split()) A = list(map(int,input().split())) Amax = int(max(A)) high = Amax Cancut = Amax low = 0 while ( low < high ) : Cut = 0 X = (high + low) / 2 for i in range(N): Cut = Cut + math.ceil(A[i]/X) - 1 if Cut <= K: high = X - 0.0001 Cancut = X else: low = X + 0.0001 # 出力 print(math.ceil(Cancut))" p02598,s071237511,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)" p02598,s920007631,Wrong Answer,"# にぶたん 二分探索 n, k = map(int, input().split()) A = list(map(int, input().split())) ok = 1 ng = max(A) while abs(ok - ng) > 1: mid = (ok + ng) // 2 cnt = 0 for a in A: cnt += (a - 1) // mid if cnt <= k: ng = mid else: ok = mid print(ng) " p02598,s370800182,Wrong Answer,"n,k = map(int,input().split()) log = list(map(int,input().split())) for i in range(k): m = max(log) log.remove(m) log += [m/2]*2 print(max(log))" 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))) " p02598,s392684913,Wrong Answer,"import heapq from fractions import Fraction import math def solve(): N, K = map(int, input().split()) A = list(map(lambda a: Fraction(-int(a), 1), input().split())) heapq.heapify(A) for _ in range(K): a = heapq.heappop(A) heapq.heappush(A, Fraction(a.numerator, a.denominator + 1)) ans = -heapq.heappop(A) print(math.ceil(ans)) solve()" p02598,s991827291,Wrong Answer,"from math import ceil N, K = map(int, input().split()) A = list(map(int, input().split())) # N, K = 2*10**5, 1 # A = [10**9]*N def solve(x): m = 0 for a in A: m += a//x - (a%x == 0) # print(x, m) return m <= K ok, ng = max(A), 0 while abs(ok-ng > 0.1**5): mid = (ok+ng)/2 # print(mid) if solve(mid): ok = mid else: ng = mid print(ceil(mid))" p02598,s838534956,Wrong Answer,"# -*- coding: utf-8 -*- import math n, k = map(int, input().split()) a = list(map(int, input().split())) a.sort() xlist = [] wa = sum(a) for i in a: xlist.append((k+n)*i/wa) xlist_int = [] for i in xlist: j = int(i) if j == 0: j = 1 xlist_int.append(j) amari = n+k-sum(xlist_int) xlist_hi = [xlist_int[i]/xlist[i] for i in range(n)] xlist_hi.sort() ans = math.ceil(wa/(k+n)/xlist_hi[amari]) print(ans)" p02598,s559845714,Wrong Answer,"N,K = map(int,input().split()) A = list(map(int,input().split())) L = 0 R = max(A) while R-L > 1: X = (L+R)/2 m = 0 for i in range(N): c = A[i]/X if c == int(c): m += int(c) - 1 else: m += int(c) if m <= K: R = X else: L = X print(int(R)) " p02598,s005500340,Wrong Answer,"#二分探査かぁ… from math import * import fractions import collections import itertools import pprint from collections import deque from heapq import * N,K=map(int,input().split()) A=list(map(int,input().split())) maxnum=10**9+20 minnum=1 while maxnum-minnum>1: cnt=0 piv=(maxnum+minnum)//2 for i in range(N): cnt=cnt+(ceil(A[i]/piv)-1) #print(cnt,piv) if cnt>K: minnum=piv else: maxnum=piv #print(maxnum,minnum) #input() print(min(maxnum,max(A)))" p02598,s721400995,Wrong Answer,"N, K=map(int,input().split()) A=list(map(int,input().split())) def judge(ans,K,A): cut=0 for i in range(len(A)): cut+=int(A[i]/ans) if cut>K: return False else: return True ansp=10**9 ansm=1 while ansp-ansm>0.00001: ans=((ansp+ansm)/2) if judge(ans,K,A): ansp=((ansp+ans)/2) else: ansm=((ans+ansm)/2) print(int(ans)+1)" p02598,s180225513,Wrong Answer,"import sys input = sys.stdin.readline import math def I(): return int(input()) def MI(): return map(int, input().split()) def LI(): return list(map(int, input().split())) N, K = MI() mylist = LI() length = len(mylist) high = max(mylist)+1 low = 0 mid = (high + low) / 2 while high - low >= 0.001: temp = 0 for i in mylist: if i % mid == 0: temp += (i // mid) - 1 else: temp += i // mid if temp > K: low = mid else: high = mid mid = (high + low) / 2 print(math.ceil(low))" p02598,s653427022,Wrong Answer,"import heapq def main(): N,K = map(int, input().split()) A = list(map(int, input().split())) A = list(map(lambda x: x*(-1), A)) heapq.heapify(A) for _ in range(K): r = heapq.heappop(A) heapq.heappush(A, r/2) heapq.heappush(A, r/2) r = -heapq.heappop(A) print(round(r)) if __name__ == '__main__': main() " p02598,s876677190,Wrong Answer,"from math import floor from bisect import bisect_left N, K = map(int,input().split()) A = list(map(int,input().split())) def chk(L): cnt = 0 for i in range(N): cnt += floor(A[i]/L) return cnt <= K l, r = 1, max(A) for _ in range(1000): m = (l+r)/2 if chk(m): r = m else: l = m print(round(m))" p02598,s386072803,Wrong Answer,"import math N,K = map(int,input().split()) A = list(map(int,input().split())) m = 0 M = max(A) while(M-m>0.0001): mm = 0 mid = (M+m)/2 for i in range(N): mm += math.ceil(A[i]/mid)-1 if mm>K: m = mid else: M = mid print(math.ceil(mid)) " p02598,s452809203,Wrong Answer,"from math import ceil n,k=map(int,input().split()) a=list(map(int,input().split())) if k==0: print(max(a)) exit() a.sort() left,right=0,a[n-1] mid=right while abs(right-left)>=1: mid=(left+right)/2 temp=0 for i in range(n-1,-1,-1): if a[i]<=mid: break temp+=a[i]//mid if temp>k: left=mid else: right=mid print(ceil(mid))" p02598,s524938460,Wrong Answer,"def abc174_e(): n, k = map(int, input().split()) A = list(map(int, input().split())) if k == 0: return max(A) lower, upper = 0, 10**9 while upper - lower > 1: x = (upper + lower) // 2 cnt = 0 for a in A: cnt += a // x if cnt > k: break if cnt > k: lower = x else: upper = x return upper if __name__ == '__main__': print(abc174_e())" p02598,s986658242,Wrong Answer,"from math import ceil N,K=map(int,input().split()) *A,=map(int,input().split()) def C(x): return sum([A[i]//x for i in range(N)]) <= K def binary_search2(func, n_min, n_max): left,right=n_min,n_max y_left, y_right = func(left), func(right) while True: middle = (left+right)//2 y_middle = func(middle) if y_left==y_middle: left=middle else: right=middle if right-left==1:break return left print(binary_search2(C, 1, max(A))+1)" p02598,s319910530,Wrong Answer,"from sys import stdin from sys import setrecursionlimit import numpy as np import math setrecursionlimit(10 ** 7) n,k = map(int,stdin.readline().rstrip().split()) a = list(map(int,stdin.readline().rstrip().split())) a.sort() a = np.array(a,dtype=np.int64) low = -1 hi = 10**9 point = 0 while hi-low > 0.001: ave = (hi+low)/2 if np.sum(a//ave) <= k: hi = ave else: low = ave print(math.ceil(ave))" p02598,s692883027,Wrong Answer,"import math N, K = map(int, input().split()) a = list(map(int, input().split())) a.sort() l = 0 r = a[-1] while r - l > 1: mid = (r + l) // 2 cnt = 0 for i in a: cnt += math.ceil(i // mid) if cnt <= K: r = mid else: l = mid print(r)" p02598,s244503256,Wrong Answer,"import math N, K = map(int, input().split()) A=list(map(int,input().split())) maxA = max(A) right = maxA+1 left = 0 while(right-left>1): mid = (left+right)//2 count = 0 for i in A: count += (i-1)//mid if count > K: left = mid elif count <= K: right = mid print(mid) " 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) " p02598,s467519062,Wrong Answer,"n,k = map(int, raw_input().split()) ais = map(int, raw_input().split()) def p(m,ais,k): t = [ m, ais, k] for ai in ais: k-= ai / m return k >=0 lo,hi = 1, max(ais) print lo,hi while(lo < hi): med = (lo + hi)/2 if p(med, ais, k): hi = med else: lo = med + 1 print lo " p02598,s351490431,Wrong Answer,"n, k = map(int, input().split()) A = list(map(int, input().split())) def check(x): cnt = 0 for a in A: if a % x == 0: cnt += a//x-1 else: cnt += a//x return k < cnt L = 1 R = 10**10 while L != R-1: M = (L+R)//2 if check(M): L = M else: R = M print(R) " p02598,s659094011,Wrong Answer,"import math N, K = map(int, input().split()) logs = list(map(int, input().split())) min_len = 1 max_len = 1000000000 def possible_len(length: int, log: list, k: int): count = 0 for i in range(N): count += math.ceil(log[i] / length) - 1 if count <= k: return True else: return False while max_len - min_len > 1: ans = (min_len + max_len) // 2 if possible_len(ans, logs, K): max_len = ans else: min_len = ans print(max_len) " p02598,s705502725,Wrong Answer,"n,k=map(int,input().split()) a=list(map(int,input().split())) tmax=max(a) tmin=0 t=(tmax+tmin)/2 import math ans=tmax if k==0: print(tmax) else: while True: s=0 for i in range(n): s=s+math.ceil(a[i]/t)-1 if k>=s: ans=min(math.ceil(t),math.ceil(ans)) tmax=t t=(tmin+t)/2 else: tmin=t t=(t+tmax)/2 if tmax-tmin<0.01: break print(ans)" 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)" p02598,s889338818,Wrong Answer,"from bisect import * from heapq import * import math mod = 10**9+7 N, K = map(int, input().split()) A = list(map(int, input().split())) ep = 0.1 l = 0.0 r = 10**9+1 while l+ep < r: x = (l+r)/2 k = 0 for a in A: k += math.floor(a/x) if k > K: break if k <= K: r = x else: l = x print(math.ceil(l))" p02598,s462245154,Wrong Answer,"from math import ceil n, k = map(int, input().split()) a = list(map(int, input().split())) mi = 0 ma = max(a) m = ma/2 while ma-mi>0.1: temp = 0 for i in range(n): temp += ceil(a[i]/m)-1 #if a[i]%m==0: # temp-=1 if temp<=k: ma=m m=(ma+mi)/2 else: mi = m m=(ma+mi)/2 #print(""temp "" + str(temp)) #print(""ma "" + str(ma)+ "" mi "" + str(mi) + "" m "" + str(m)) #print(m) print(ceil(m))" p02598,s959843716,Wrong Answer,"import math N, K = map(int, input().split()) A = list(map(float, input().split())) if K == 0: print(int(max(A))) exit() if N == 1: print(math.ceil(A[0]/K)) exit() min_A = 0 max_A = max(A) + 1 while( max_A - min_A > 1): now = (min_A + max_A) // 2 temp = 0 for i in A: temp += (i // now) if temp > K: min_A = now else: max_A = now print(min_A, max_A) print(int(min_A) + 1)" p02598,s957636593,Wrong Answer,"import heapq n,k = map(int,input().split()) a = [int(i) for i in input().split()] low = 1 high = 10**9 if k == 0: print(max(a)) exit() """""" if n == 1: print((a[0]+k-1)//k) exit() """""" while low+1 < high: tmp = 0 mid = (low + high) //2 #print(mid) for i in range(n): tmp += ((a[i]+mid-1) // mid)-1 if tmp <= k: high = mid else: low = mid print(high) " p02598,s282320622,Wrong Answer,"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 = 1e10 for i in range(60): mid = (ok + ng) // 2 if f(mid): ng = mid else: ok = mid print(ng) " p02598,s718861359,Wrong Answer,"from math import floor, ceil def main(): n, k = map(int, input().split()) a = list(map(int, input().split())) a.sort() lower = 1 upper = a[-1] while lower + 1 < upper: target = (lower + upper) // 2 now = 0 for i in range(n): now += ceil(a[i] // target) if now > k: lower = target else: upper = target print(upper if k > 0 else a[-1]) if __name__ == '__main__': main() " p02598,s391538142,Wrong Answer,"n,k=map(int, input().split()) a = list(map(int, input().split())) a=sorted(a) if k==0: print(max(a)) exit() lo=0 hi=10**9 oldmid=0 while True: mid=(hi+lo)/2 cnt=0 for i in range(n): cnt+=round((a[i])/mid-0.5) if cnt>k: lo=mid elif cnt<=k: hi=mid if oldmid-0.001<=mid<=oldmid+0.001: #print(mid) print(round(mid)) break oldmid=mid " p02598,s226478940,Wrong Answer,"N, K = map(int,input().split()) A = sorted(map(int,input().split())) start = 0 end = A[-1] l = (start + end)/2 while end - start >= 1: l = (start + end)/2 count = 0 for i in range(N): count += (A[i]-1)//l if count > K: start = l else: end = l print(int(l)+1)" p02598,s742694944,Wrong Answer,"N, K = map(int, input().split()) *A, = map(int, input().split()) l, r = 10**19, 1 while abs(r-l) > 1: m = (l+r)//2 k = 0 for a in A: if a > m: k += a//m if k <= K: l = m else: r = m print(l) " p02598,s940400612,Wrong Answer,"import sys input = sys.stdin.buffer.readline n, k = map(int, input().split()) A = list(map(int, input().split())) # A.sort() def hantei(x): cnt = 0 for i in range(n): cnt += A[i] // x return cnt ok = 10 ** 9 ng = 0 while ok - ng > 1: mid = (ok + ng) // 2 if hantei(mid) <= k: ok = mid else: ng = mid # print(ok, ng) print(ok) " p02598,s200027980,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 else: c -= (i-1)//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)" p02598,s195662675,Wrong Answer,"def binary_search2(func, n_min, n_max): left,right=n_min,n_max y_left, y_right = func(left), func(right) while True: middle = (left+right)//2 y_middle = func(middle) if y_left==y_middle: left=middle else: right=middle if right-left==1:break return left def f(x): return sum([A[i]//x for i in range(N)])<=K N,K=map(int,input().split()) A=list(map(int,input().split())) print(binary_search2(f, 1, max(A)+5)+1)" 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)) " p02598,s386626071,Wrong Answer,"n,k=map(int,input().split()) A=list(map(int,input().split())) l=0 r=max(A)+1 while r-l>1: m=(l+r)//2 cut=0 for i in range(n): cut+=((A[i]+m-1)//m)-1 if cut>k: l=m else: r=m print(m) " p02598,s998357018,Wrong Answer,"N, K = map(int, input().split()) A = sorted(list(map(int, input().split()))) def check(N, K, A, L): return sum(a // L for a in A) <= K answer=max(A) lo = 1 hi = answer+1 while lo < hi: m = (lo + hi)//2 ok = check(N, K, A, m) if ok: # answer=m hi=m else: lo=m+1 print(min(max(A), answer)) " p02598,s719022528,Wrong Answer,"n,k = map(int,input().split()) a = list(map(int,input().split())) leq,high = 0,1e10 while high-leq > 1: l = int((leq+high)/2) cnt = 0 for ai in a: cnt += int((ai-1)/l) print(l,cnt) if cnt>k: leq = l else: high = l print(high)" p02598,s986545125,Wrong Answer,"n,k = map(int,input().split()) A = list(map(int,input().split())) A.sort() M = max(A) m = min(A) def calc(r): return pow(2,r-1)-1 l,r = 1,M cnt = 0 import math while l1: cnt=0 now=(low+high)//2 for a in A: cnt+=max((a-1)//now,0) if cnt>k: break if cnt>k: low=now else: high=now print(cnt,low,high) print(high)" 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)" p02598,s941639013,Wrong Answer,"from heapq import heappush, heappop, heapify import math def solve(): n , k= map(int, input().strip().split()) if k >= 10*7: return 1 a= [(-int(x),1,int(x)) for x in input().strip().split()] heapify(a) for i in range(k): x,cnt,orig = heappop(a) x = -x if x <= 1: return 1 heappush(a,(-((orig+cnt)//(cnt+1)),cnt+1,orig)) return -(heappop(a)[0]) print(solve())" p02598,s059153723,Wrong Answer,"from sys import stdin nii=lambda:map(int,stdin.readline().split()) lnii=lambda:list(map(int,stdin.readline().split())) n,k=nii() a=lnii() ok=max(a) ng=1 while ok-ng>1: m=(ok+ng)//2 num=0 for i in a: num+=i//m if num<=k: ok=m else: ng=m print(ok)" p02598,s243177414,Wrong Answer,"n,k=map(int,input().split()) a=list(map(int,input().split())) if k==0: print(max(a)) else: ans=0 for i in a: d=-(-k*i//sum(a)) if d>0: ans=max(ans,-(-i//(d+1))) else: ans=max(ans,i) print(ans)" p02598,s401356640,Wrong Answer,"import math n, k = map(int, input().split()) a_list = list(map(int, input().split())) def nibun(l, r): if r - l < 1: return l cnt = 0 x = (r + l) / 2 for i in a_list: cnt += math.ceil(i/x) - 1 if cnt <= k: return nibun(l, x) else: return nibun(x, r) if k == 0: print(max(a_list)) else: print(math.ceil(nibun(0, max(a_list))))" p02598,s495075970,Wrong Answer,"import copy n, k = map( int, input().split() ) a = list( map( float, input().split() ) ) devide = [ 0 for _ in range( n ) ] dev_len = copy.deepcopy( a ) for _ in range( k ): max_i = dev_len.index( max( dev_len ) ) devide[ max_i ] += 1 dev_len[ max_i ] = a[ max_i ] / ( devide[ max_i ] + 1 ) print( int( max( dev_len ) + 0.5 ) )" p02598,s795247525,Wrong Answer,"n,k=map(int,input().split()) l=list(map(int,input().split())) #(ng,ok]type if k==0:print(max(l));exit() def enough(x): return sum((i)//x for i in l )<=k ok,ng=10**9,0 # [ok,ng)type->eraseng,ok=ok,ng while abs(ok-ng)>1: mid=(ok+ng)//2 if enough(mid):ok=mid else:ng=mid print(ok)" p02598,s163695073,Wrong Answer,"n,k = map(int,input().split()) a = list(map(int,input().split())) def check(t): ans = 0 for aa in a: if aa > t: ans += aa//t max = 10**9 min = 0 while max-min>1: mid = (max+min)/2 if check(mid): max = mid else: min = mid print(max)" p02598,s691006640,Wrong Answer,"import math N, K = map(int, input().split()) A = list(map(float, input().split())) if K == 0: print(int(max(A))) exit() if N == 1: print(math.ceil(A[0]/K)) exit() min_A = 0 max_A = 10**10 while( max_A - min_A > 1): now = (min_A + max_A) // 2 temp = 0 for i in A: if i > now: temp += (i // now) if temp > K: min_A = now else: max_A = now print(int(min_A) + 1)" p02598,s778244044,Wrong Answer,"import math N,K=map(int,input().split()) A=list(map(int, input().split())) l=0 r=max(A) while not l+1==r: x=math.ceil((r+l)/2) k=0 for a in A: k+=a//x if k<=K: r=x else: l=x print(r)" p02598,s564187441,Wrong Answer,"#E - Logs import math # 入力 N,K = map(int,input().split()) A = list(map(int,input().split())) Amax = int(max(A)) high = Amax Cancut = Amax low = 0 while ( abs(high - low) > 0.1 ) : Cut = 0 X = (high + low) / 2.0 for i in range(N): Cut = Cut + math.ceil(A[i]/X) - 1 if Cut <= K: high = X Cancut = X else: low = X # 出力 print(math.ceil(Cancut))" p02598,s014961217,Wrong Answer,"import math n, k = map(int, input().split()) aas = list(map(int, input().split())) diff = pow(10,-6) left = 1 right = 10**9 def judge(mid): cut = 0 for i in aas: cut += math.ceil(i / mid) - 1 if cut <= k: return True else: return False while left < right: mid = (left + right) / 2 if (left <= right <= left + diff) or (right <= left <= right + diff): break elif judge(mid): right = mid else: left = mid print(int(right))" p02598,s916050499,Wrong Answer,"#二分探査かぁ… from math import * import fractions import collections import itertools import pprint from collections import deque from heapq import * N,K=map(int,input().split()) A=list(map(int,input().split())) maxnum=10**9+20 minnum=1 while maxnum-minnum>1: cnt=0 piv=(maxnum+minnum)//2 for i in range(N): cnt=cnt+ceil(A[i]/piv)-1 #print(cnt,piv) if cnt>K: minnum=piv else: maxnum=piv #print(maxnum,minnum) #input() print(maxnum)" p02598,s012782237,Wrong Answer,"n,k=map(int,input().split()) a=list(map(int,input().split())) tmax=max(a) tmin=0 t=(tmax+tmin)/2 import math ans=tmax if k==0: print(tmax) else: while True: s=0 for i in range(n): s=s+math.ceil(a[i]/t)-1 if k>=s: ans=min(t,ans) tmax=t t=(tmin+t)/2 else: tmin=t t=(t+tmax)/2 if tmax-tmin<0.01: break print(math.ceil(ans))" p02598,s284036333,Wrong Answer,"import math def solve(n, k, a): lb = 0 ub = max(a) while abs(ub - lb) > 1: cur = (lb + ub) / 2 cnt = sum(math.ceil(x/cur-1) for x in a) if cnt > k: lb = cur else: ub = cur return int(math.ceil((lb+ub) / 2)) n, k = map(int, input().split()) a = list(map(int, input().split())) print(solve(n, k, a))" p02598,s744783629,Wrong Answer,"#!/usr/bin/env python3 from math import ceil EPS = 1e-8 n, k = map(int, input().split()) a = list(map(int, input().split())) def f(p): c = 0 for x in a: c += (x + p - 1) // p - 1 return c ok, ng = 0, max(a) while abs(ok - ng) > 1: m = (ok + ng) / 2 if f(m) > k: ok = m else: ng = m print(ceil(ok) + 1) " p02598,s653617359,Wrong Answer,"# coding: utf-8 def solve(*args: str) -> str: n, k = map(int, args[0].split()) A = tuple(map(int, args[1].split())) l, r = 0, max(A) while l+1 < r: m = (l+r)/2 cnt = 0 for a in A: cnt += -int(-a//m)-1 if k < cnt: l = m else: r = m return str(-int(-l//1)) if __name__ == ""__main__"": print(solve(*(open(0).read().splitlines()))) " p02598,s199290522,Wrong Answer,"N, K = map(int, input().split()) A = list(map(int, input().split())) def isOk(x): cnt = 0 for a in A: cnt += a // x return cnt <= K ok = max(A) ng = 0 while ok - ng > 1: mid = (ok + ng) // 2 if isOk(mid): ok = mid else: ng = mid if ok > 1 and isOk(ok - 1): ok -= 1 print(ok) " p02598,s644552955,Wrong Answer,"n,k=map(int,input().split()) a=list(map(int,input().split())) a.sort() l=1 r=a[-1] while r-l>1: cnt=0 m=(l+r)//2 #print(""l,m,r"",l,m,r) for i in a: cnt+=(i-1)//m if cnt<=k: r=m else: l=m print(r)" p02598,s101971538,Wrong Answer,"N,K = map(int,input().split()) A = list(map(int,input().split())) L = 0 R = max(A) while int(R)-int(L) > 1: X = (L+R)/2 m = 0 for i in range(N): c = A[i]/X if c == int(c): m += int(c) - 1 else: m += int(c) if m <= K: R = X else: L = X print(int(R)) " p02598,s380589455,Wrong Answer,"import math N, K = list(map(int,input().split())) A = list(map(int,input().split())) def is_ok(mid): cnt = 0 for i in range(N): cnt += math.floor(A[i] / mid) return cnt <= K def binary_search(left, right): while (abs(right - left) > 1): mid = (left + right) // 2 if is_ok(mid): right = mid else: left = mid return right if K == 0: print(max(A)) else: left = max(A) + 1 right = 0 ret = binary_search(right, left) print(ret)" p02598,s359274510,Wrong Answer,"# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..) import sys from math import ceil def main(N, K, A): def cut_times(longest): return sum(a // longest for a in A) under = 0 r = 10**9 for i in range(100): m = (under + r) / 2 if cut_times(m) > K: under = m else: r = m print(ceil(r - 10**-10)) if __name__ == '__main__': input = sys.stdin.readline N, K = map(int, input().split()) *A, = map(int, input().split()) main(N, K, A) " 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()" 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)" p02598,s697412197,Wrong Answer,"n,k=map(int,input().split()) a=list(map(int,input().split())) l,r=max(a),1 while l-r>1: t=(l+r)//2 c=0 for i in a: c+=i//t if c>k: r=t else: l=t print(l)" p02598,s877120156,Wrong Answer,"n,k=map(int,input().split()) a=list(map(int,input().split())) tmax=max(a) tmin=0 import math ans=tmax if k==0: print(tmax) else: while True: t=(tmax+tmin)/2 if tmax-tmin<0.01: break s=0 for i in range(n): s=s+math.ceil(a[i]/t)-1 if k>=s: ans=min(math.ceil(t),math.ceil(ans)) tmax=t else: tmin=t print(ans)" p02598,s136973333,Wrong Answer,"N,K = map(int, input().split()) A = [int(a) for a in input().split()] def f(X): cnt = 0 for a in A: cnt += int(a/X) return max(1, cnt) l = 1 r = max(A) while r-l > 1: m = (r+l)//2 if f(m) <= K: r = m else: l = m if K == 0: print(max(A)) elif f(r) <= K: print(r) else: print(l)" p02598,s878710095,Wrong Answer,"N, K = map(int, input().split()) a = list(map(int, input().split())) max_a = 10**9 min_a = 0 while max_a-min_a != 1: count = K mean_a = (max_a+min_a)//2 for i in range(N): count -= a[i]//mean_a if count >= 0: max_a = mean_a else: min_a = mean_a print(max_a)" p02598,s559177498,Wrong Answer,"import math N, K = map(int, input().split()) A = list(map(float, input().split())) if K == 0: print(int(max(A))) exit() if N == 1: print(math.ceil(A[0]/K)) exit() min_A = 0 max_A = max(A) while( int(max_A) - int(min_A) != 0): now = (min_A + max_A) / 2 temp = 0 for i in A: temp += int(i / now) if temp > K: min_A = now else: max_A = now print(int(min_A) + 1)" p02598,s998934966,Wrong Answer,"def main(): n,k=map(int,input().split()) lst=sorted(list(map(int,input().split()))) left=0 right=lst[-1] while right-left>1: mid=(right+left)//2 sm=0 for x in lst: sm+=x//mid if sm<=k: right=mid else : left=mid print(right) main()" p02598,s864882690,Wrong Answer,"import math N, K = map(int,input().split()) logs = list(map(int,input().split())) a = 0 b = max(logs) b_memo = set() count=0 flg =0 while b-a < 1: c = (a+b)//2 times = [] for i in logs: times.append(math.floor(i/c)) if sum(times) > K: a = c else: b = c print(math.ceil(a))" p02598,s569919439,Wrong Answer,"import math n,k=map(int,input().split()) log=list(map(int,input().split())) a=1 b=max(log) if b==1: print(1) exit() c=(a+b)//2 while True: div=0 for i in range(n): div+=math.ceil(log[i]/c)-1 if div<=k: b=c c=(a+b)//2 else: a=c c=(a+b)//2 if c==a or c==b: break print(b)" p02598,s651353142,Wrong Answer,"import math def solve(K, N, A, length): s = 0 for i in range(N): if A[i] > length: s += int(A[i] / length) return K >= s N, K = [int(i) for i in input().split()] A = [int(i) for i in input().split()] A.sort() if K == 0: print(A[-1]) exit() ok = 10**9 ng = 1 while abs(ok - ng) > 1: mid = (ok + ng) / 2 if solve(K, N, A, mid): ok = mid else: ng = mid print(math.ceil(mid))" p02598,s772237205,Wrong Answer,"n,k = map(int,input().split()) A = list(map(int,input().split())) A.sort() M = max(A) l,r = 1,M cnt = 0 while l k: left = mid else: right = mid print(int(left+1)) " p02598,s873445250,Wrong Answer,"#二分探査かぁ… from math import * import fractions import collections import itertools import pprint from collections import deque from heapq import * N,K=map(int,input().split()) A=list(map(int,input().split())) maxnum=10**9 minnum=1 while maxnum-minnum>1: cnt=0 piv=(maxnum+minnum)//2 for i in range(N): cnt=cnt+ceil(A[i]/piv)-1 #print(cnt,piv) if cnt>K: minnum=piv else: maxnum=piv #print(maxnum,minnum) #input() print(maxnum)" p02598,s297322897,Wrong Answer,"from math import ceil n,k = map(int,input().split()) a = [int(i) for i in input().split()] l = -1 r = 10**9 while l+1 < r: m = (l+r)//2 if m == 0: r = 0 break cnt = 0 for i in range(n): cnt += ceil(a[i]/m)-1 if cnt <= k: r = m else: l = m print(r)" p02598,s218338204,Wrong Answer,"N,K = map(int,input().split()) arr = list(map(int,input().split())) denominator = sum(arr) import copy value = copy.deepcopy(arr) piece = [1 for i in range(N)] left = K+N-sum(piece) for i in range(left): j = value.index(max(value)) piece[j] += 1 value[j] = arr[j]/piece[j] import math print(round(round(max(value)*10)/10))" p02598,s932548323,Wrong Answer,"#E - Logs import math # 入力 N,K = map(int,input().split()) A = list(map(int,input().split())) Amax = int(max(A)) high = Amax Cancut = Amax low = 0 while ( (high - low) > 0.001 ) : Cut = 0 X = (high + low) / 2.0 for i in range(N): Cut = Cut + math.ceil(A[i]/X) - 1 if Cut <= K: high = X Cancut = X else: low = X # 出力 Cancut = math.floor( 1000 * Cancut) / 1000.0 print(math.ceil(Cancut))" p02598,s526180140,Wrong Answer,"from math import floor, ceil def main(): n, k = map(int, input().split()) a = list(map(int, input().split())) a.sort() lower = 1 upper = a[-1] while upper - lower >= 0.25: 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(upper) if k > 0 else a[-1]) if __name__ == '__main__': main() " p02598,s973581852,Wrong Answer,"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: 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)" p02598,s067305380,Wrong Answer,"from sys import stdin input = stdin.buffer.readline n, k = map(int, input().split()) *a, = map(int, input().split()) def f(mx): cnt = 0 for i in a: cnt += (i + mx - 1) // mx - 1 return cnt l, r = 1, max(a) + 1 while r - l > 1: m = (l + r) >> 1 if f(m) > k: l = m else: r = m print(r) " p02598,s753679309,Wrong Answer,"# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..) import sys from math import ceil def main(N, K, A): lo = -1 hi = 10**9 for i in range(100): m = (lo + hi) / 2 if sum(ceil(a / m) - 1 for a in A) <= K: hi = m else: lo = m print(ceil(hi)) if __name__ == '__main__': input = sys.stdin.readline N, K = map(int, input().split()) *A, = map(int, input().split()) main(N, K, A) " p02598,s342685384,Wrong Answer,"n,k = map(int,input().split()) a = list(map(int,input().split())) leq,high = 0,1e10 while high-leq > 1: l = int((leq+high)/2) cnt = 0 for ai in a: cnt += int((ai-1)/l) print(l,cnt) if cnt>k: leq = l else: high = l print(high)" p02598,s286333737,Wrong Answer,"#!/usr/bin/env python3 from math import ceil n, k = map(int, input().split()) a = list(map(int, input().split())) def f(p): c = 0 for x in a: c += x // p return c ok, ng = 0, max(a) + 1 while abs(ok - ng) > 1e-5: m = (ok + ng) / 2 if f(m) > k: ok = m else: ng = m print(ceil(ok)) " p02598,s714212910,Wrong Answer,"from math import ceil def main(): N, K = map(int, input().split()) A = list(map(int, input().split())) def check(Min): kill = 0 for a in A: kill += (ceil(a/Min)-1) return kill <= K l = 1 r = 1000000000 while r-l > 1: mid = (l+r)//2 if check(mid): r = mid else: l = mid print(r) if __name__ == '__main__': main()" p02598,s228971335,Wrong Answer,"def main(): n,k = map(int,input().split()) A = list(map(int,input().split())) left = 1 right = max(A) while abs(right-left)>1: cent = (right+left)//2 ct = 0 for a in A: ct+=a//cent if ct <= k: right=cent else: left=cent print(right) main()" p02598,s136910515,Wrong Answer,"n,k=map(int,input().split()) A=list(map(int,input().split())) high=max(A) low=1 while high-low>1: cnt=0 now=(low+high)//2 for a in A: cnt+=a//now if cnt>k: break if cnt>k: low=now else: high=now #print(cnt,low,high) print(high)" p02598,s067562715,Wrong Answer,"N,K=map(int,input().split()) A=sorted(list(map(int,input().split()))) if K==0:print(max(A));exit() left,right=0,10**9+1 while right>left+1: cnt=K mid=(left+right)//2 for i in range(N): cnt -=A[i]//mid if cnt>=0:right=mid elif cnt<0:left=mid print(right)" p02598,s498098905,Wrong Answer,"import math import heapq n,k = map(int,input().split()) s = list(map(int,input().split())) a = list(map(lambda x: x*(-1), s)) heapq.heapify(a) for i in range(k): m=heapq.heappop(a) heapq.heappush(a, m/2) ans=heapq.heappop(a)*(-1) print(math.ceil(ans)) " p02598,s858205707,Wrong Answer,"N, K = map(int, input().split()) A = list(map(int, input().split())) if N > K: for _ in range(K): cut = max(A) A.remove(cut) A.append(cut / 2) A.append(cut / 2) print(int(max(A)))" p02598,s473655551,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)" p02598,s348245685,Wrong Answer,"n,k = map(int, input().split()) maruta = [] maruta = list(map(int, input().split())) maruta = sorted(maruta, reverse=True) for i in range(k): maruta[0] /= 2 maruta = sorted(maruta, reverse=True) print(maruta[0])" p02598,s100430112,Wrong Answer,"import heapq n,k = map(int,input().split()) a = [int(i) for i in input().split()] low = 1 high = 10**9 while low+1 < high: tmp = 0 mid = (low + high) //2 #print(mid) for i in range(n): tmp += ((a[i]+mid-1) // mid)-1 #print(tmp,mid) if tmp <= k: high = mid else: low = mid print(high) " p02598,s710767035,Wrong Answer,"#E - Logs import math # 入力 N,K = map(int,input().split()) A = list(map(int,input().split())) Amax = max(A) high = Amax Cancut = Amax low = 0 while ( (high - low) > 0.1 ) : Cut = 0 X = (high + low) / 2.0 for i in range(N): Cut = Cut + math.ceil(A[i]/X) - 1 if Cut <= K: high = X Cancut = X else: low = X # 出力 Cancut = int( 10 * Cancut) / 10 print(math.ceil(Cancut))" p02598,s484491380,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)] 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))) " p02598,s233140284,Wrong Answer,"from math import ceil n, k = map(int, input().split()) logs = list(map(int, input().split())) def is_ok(num): t = 0 for log in logs: if log <= num: continue t += ceil(log / n) - 1 return t <= k ng = 0 ok = 10 ** 9 while ok - ng > 1 : m = (ok + ng) // 2 if is_ok(m): ok = m else: ng = m print(ceil(ok))" p02598,s397264674,Wrong Answer,"import math N, K = map(int, input().split()) A = list(map(float, input().split())) if K == 0: print(int(max(A))) exit() if N == 1: print(math.ceil(A[0]/K)) exit() min_A = 0 max_A = max(A) + 1 while( max_A - min_A > 1): now = (min_A + max_A) // 2 temp = 0 for i in A: temp += (i // now) if temp > K: min_A = now else: max_A = now print(int(min_A) + 1)" p02598,s420967971,Wrong Answer,"n,k=map(int,input().split()) a=list(map(int,input().split())) l,r=max(a),0 while l-r>1: t=(l+r)//2 c=0 for i in a: c+=i//t if c>k: r=t else: l=t print(l)" p02598,s140420153,Wrong Answer,"n,k=map(int,input().split()) a=list(map(int,input().split())) a.sort() def counter(x): cnt=0 for i in a: cnt+=i//x if cnt>k: return True else: return False high=a[-1] low=0 while (high-low)>1: mid =(high+low)//2 if counter(mid): low=mid else: high=mid print(high)" p02598,s491517289,Wrong Answer,"N, K = map(int,input().split()) A = sorted(map(int,input().split())) start = 0 end = A[-1] l = (start + end)/2 while end - start >= 0.001: l = (start + end)/2 count = 0 for i in range(N): q, mod = divmod(A[i], l) if mod == 0.0: q -= 1 count += q if count > K: start = l else: end = l ans = (start + end)/2 print(int(end)+1)" p02598,s343175699,Wrong Answer,"N,K = map(int,input().split()) A = list(map(int,input().split())) low = 0 high = 10**9 while high-low>1: mid = (high+low)//2 cnt = 0 for i in range(N): cnt += A[i]//mid if K>=cnt: high = mid else: low = mid print(high)" p02598,s973057715,Wrong Answer,"import numpy as np import math N,K=map(int,input().split()) A=list(map(int,input().split())) def isOK(minVal): tmpK=0 for a in A: # math.ceil(a//minVal)-1 tmpK+=((-(-a//minVal))-1) if tmpK <= K: return True else: return False ok = max(A) ng = 0 while (math.ceil(ok) != math.ceil(ng)): mid = (ok+ng) / 2 if isOK(mid): ok = mid else: ng = mid print(ok,ng) print(math.ceil(ok))" p02598,s465249556,Wrong Answer,"import math N, K = map(int, input().split()) A = list(map(int, input().split())) X = max(A) if K == 0: print(X) exit() else: for i in range(1, 32): B = [] for a in A: b = math.ceil(a / X) - 1 B.append(b) B_total = sum(B) if B_total > K: X += int(max(A) / pow(2, i)) else: X -= int(max(A) / pow(2, i)) print(X)" p02598,s351369602,Wrong Answer,"n, k = map(int, input().split()) a = list(map(int, input().split())) low = 0 high = max(a) while low + 1 < high: print(low, high) mid = (low + high) // 2 m = 0 for x in a: m += (x - 1) // mid if m <= k: high = mid else: low = mid print(high)" p02598,s521880491,Wrong Answer,"N, K = map(int,input().split()) A = list(map(int, input().split())) OK = 10**9 NG = 1 while OK - NG > 1: ans = 0 mid = (OK+NG)//2 for a in A: ans += (a-0.1)//mid if ans > K: NG = mid else: OK = mid print(OK)" p02598,s299945912,Wrong Answer,"from math import ceil def BinarySearch(x): ans = sum([ceil(a/x)-1 for a in A]) if ans <= K: return True else: return False N,K = map(int,input().split()) A = list(map(int,input().split())) r = max(A) l = 0 eps = 10**-5 while abs(r-l) > eps: m = (r+l)/2 if BinarySearch(m): r = m else: l = m print(ceil(r)) " p02598,s851913990,Wrong Answer,"from math import floor m=1 M=10**9+1 N,K=map(int,input().split()) A=list(map(int,input().split())) def OK(p): if sum([(a-1)//p for a in A])<=K: return True else: return False while M-m>1: p=(m+M)//2 if OK(p): M=p else: m=p print(M)" p02598,s607066943,Wrong Answer,"import math n,k = map(int, input().split(' ')) a_s= list(map(int, input().split(' '))) tot=0 for log in a_s: tot+= log table={} ans= 0 for log2 in a_s: test= math.ceil(log2/ ((math.ceil(log2/tot*k))+1)) if test>ans: ans=test print(ans)" p02598,s496053610,Wrong Answer,"n,k = list(map(int,input().split())) f = list(map(int,input().split())) s = (10**9) // 2 step = s best= 999999999999 import math for j in range(40): c = 0 arr = list(f) for i in range(n): c += arr[i] // s arr[i] /= (c+1) step = step//2 step = max(1, step) if c<=k: s -= step best = min(best,math.ceil(max(arr))) else: s += step print(best)" p02598,s028943731,Wrong Answer,"from sys import stdin input = stdin.readline import math import heapq def solve(): n, k = map(int, input().split()) a = list(map(int, input().split())) left = 1 right = max(a) def ok(l): s = sum([(i-1) // l for i in a]) return s <= k print(max(a)) while left < right: mid = (left + right) // 2 if ok(mid): right = mid else: left = mid + 1 print(left) if __name__ == '__main__': solve() " p02598,s057395971,Wrong Answer,"# -*- 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 = 1 M = 10**9 while M-m>1: X = (m+M)//2 if num_cut(X)>K: m = X else: M = X print(M)" p02598,s748365753,Wrong Answer,"import copy import math n, k = map(int,input().split()) a = list(map(int,input().split())) ub = 10**9 lb = 0 while ub - lb > 0.0001: x = (ub + lb) / 2 cnt = 0 for i in a: cnt += math.ceil(i/x) if cnt <= n+k: ub = copy.deepcopy(x) else: lb = copy.deepcopy(x) ans = round(ub, 3) print(math.ceil(ans))" p02598,s729251340,Wrong Answer,"import math N, K = list(map(int, input().split())) A = list(map(int, input().split())) def isPossible(X): global N, K, A cuts = 0 for i in range(N): cuts += math.ceil(A[i]/X) - 1 return cuts <= K minVal = 0 maxVal = max(A) while maxVal - minVal >= 1: if isPossible((maxVal + minVal) / 2): maxVal = (maxVal + minVal) / 2 else: minVal = (maxVal + minVal) / 2 print(math.ceil((maxVal + minVal) / 2))" p02598,s321979073,Wrong Answer,"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(ok) " p02598,s686095526,Wrong Answer,"#!/usr/bin/env python3 from math import ceil EPS = 1e-8 n, k = map(int, input().split()) a = list(map(int, input().split())) def f(p): c = 0 for x in a: c += x // p return c ok, ng = 0, max(a) while abs(ok - ng) > 1: m = (ok + ng) // 2 if f(m) > k: ok = m else: ng = m print(ok + 1) " p02598,s753124319,Wrong Answer,"# logs import bisect import math k = int(input().split()[1]) # a = list(map(int, input().split())) tmp = input().split() a = [int(s) for s in tmp] a.sort() # print(a) for i in range(k): x = a.pop()/2 pos = bisect.bisect_right(a, x) a.insert(pos, x) # print(a) print(math.ceil(a.pop())) " p02598,s658232400,Wrong Answer,"from math import floor N, K = map(int,input().split()) A = list(map(int,input().split())) def chk(L): cnt = 0 for i in range(N): cnt += floor(A[i]/L) return cnt <= K l, r = 1, max(A) for _ in range(100): m = (l+r)/2 if chk(m): r = m else: l = m print(round(m))" p02598,s872590124,Wrong Answer,"import math N, K = map(int, input().split()) Alst = list(map(int, input().split())) for i in range(K): sa = Alst.index(max(Alst)) Alst.append(Alst[sa]/2) Alst[sa] = Alst[sa]/2 print(math.ceil(max(Alst)))" p02598,s868631156,Wrong Answer,"import numpy as np import math N, K = map(int, input().split()) aaa = np.array(list(map(float, input().split())), dtype='float64') ng = 0 ok = 10 ** 9 e = 10 ** -7 while ok > ng + e: mid = (ng + ok) / 2 bbb = aaa // mid if bbb.sum() <= K: ok = mid else: ng = mid print(math.ceil(round(ok, 7))) " p02598,s120675564,Wrong Answer,"n,k=map(int,input().split()) a=list(map(int,input().split())) l,r=max(a),1 while l-r>1: t=(l+r)//2 c=0 for i in a: c+=(i-1)//t if c>k: r=t else: l=t print(l)" p02598,s703869585,Wrong Answer,"import numpy as np import math n, k = map(int, input().split()) a = list(map(int, input().split())) a.sort() a.reverse() total = sum(a) # 期待値 mn = 1/ (k+1) a = np.array(a) b = a # 割合 ab = a/total # 少なくとも何回切れるか a = ab//mn # 切った後の長さ f = b/(a+1) # 大きい順に並べて f = np.sort(f)[::-1] # あと何回切れるか sm = sum(a) left = int(k - sm) print(math.ceil(f[left])) " p02598,s343612859,Wrong Answer,"n,k=map(int,input().split()) a=list(map(int,input().split())) tmax=max(a) tmin=0 t=(tmax+tmin)/2 import math ans=0 if k==0: print(tmax) else: while True: s=0 for i in range(n): s=s+math.ceil(a[i]/t)-1 if k>=s: ans=t tmax=t t=(tmin+t)/2 else: tmin=t t=(t+tmax)/2 if tmax-tmin<0.001: break print(math.ceil(ans))" p02598,s034009154,Wrong Answer,"import math N, K = map(int, input().split()) nums = list(map(int, input().split())) l = 1 r = 10**9 while(r-l > 1): mid = (r+l)//2 cut = 0 for num in nums: cut += math.ceil(num/mid)-1 if cut <= K: r = mid else: l = mid print(math.ceil(r))" p02598,s220865510,Wrong Answer,"n,k=map(int,input().split()) from collections import deque A=deque(map(int,input().split())) A=sorted(A) if 90*n l+1: # print(l,u) c = (l + u) // 2 cnt = 0 for i in a: cnt = cnt + ((i-1)//c) if cnt <= k: u = c else: l = c print(u) " p02598,s667272232,Wrong Answer,"from sys import stdin input = stdin.buffer.readline n, k = map(int, input().split()) *a, = map(int, input().split()) def f(mx): cnt = 0 for i in a: cnt += (i + mx - 1) // mx - 1 return cnt l, r = 1, int(1e9 + 1) while r - l > 1: m = (l + r) >> 1 if f(m) > k: l = m else: r = m print(r) " p02598,s847847700,Wrong Answer,"import math n, k = list(map(int,input().split())) a = list(map(int,input().split())) def lte_k(x, len_list): counter = 0 for item in len_list: counter += math.ceil(item / x) - 1 return counter <= k def binary_search(): low = 1 high = max(a) while low < high: mid = math.ceil((low + high) / 2) guess = lte_k(mid, a) if guess: high = mid-1 else: low = mid return high+1 print(binary_search())" p02598,s247545569,Wrong Answer,"N,K = map(int,input().split()) A = list(map(int,input().split())) L = 0 R = max(A) while R-L >= 1: X = (L+R)/2 m = 0 for i in range(N): c = A[i]/X if c == int(c): m += int(c) - 1 else: m += int(c) if m <= K: R = X else: L = X if int(R) - int(L) == 0: print(int(R)+1) else: print(int(R)) " p02598,s977094708,Wrong Answer,"from math import ceil n,k=map(int,input().split()) a=sorted(list(map(int,input().split()))) L=a[-1] if k==0: print(L) exit() M=L m=0 while M-m>=0.01: x=(M+m)/2 c=0 for p in a: c+=ceil(p/x)-1 if c>k: break if c<=k: M=x else: m=x x=(M+m)/2 print(ceil((M+m)/2)) " p02598,s233654062,Wrong Answer,"N, K = map(int, input().split()) A = list(map(int, input().split())) mi = 1 ma = 10**9 while(ma - mi != 1): c = 0 mid = (ma + mi) // 2 for i in range(N): c += A[i] // mid - (A[i] % mid == 0) if c > K: mi = mid else: ma = mid print(ma)" p02598,s665467754,Wrong Answer,"import math n,k=map(int,input().split()) a=list(map(int,input().split())) a.sort() xma=a[-1] x=a[-1]/2 xmi=0 xo=-1 while abs(x-xo)>0.0001: k2=k for i in range(n): k2-=(a[i]//x) if k2<0: xo=x xmi=x x=(xma+x)/2 else: xo=x xma=x x=x/2 print(math.ceil(x)) " p02598,s808546921,Wrong Answer,"import math n, k = list(map(int,input().split())) a = list(map(int,input().split())) def lte_k(x, len_list): counter = 0 for item in len_list: counter += math.ceil(item / x) - 1 return counter <= k def binary_search(): low = 1 high = max(a) while low < high-1: mid = (low + high) // 2 guess = lte_k(mid, a) if guess: high = mid else: low = mid return high print(binary_search())" p02598,s157342948,Wrong Answer,"#!/usr/bin/env python3 n, k = map(int, input().split()) a = list(map(int, input().split())) if k == 0: print(max(a)) exit() def f(p): c = 0 for x in a: c += x // p return c ok, ng = 0, max(a) while abs(ok - ng) > 1: m = (ok + ng) // 2 if f(m) > k: ok = m else: ng = m print(ok + 1) " p02598,s354143418,Wrong Answer,"rule=input().split() N=int(rule[0]) K=int(rule[1]) data=input().split() ans=0 for i in range(len(data)): ans+=int(data[i]) import math print(math.floor(ans/(K+1))+1)" p02598,s104046515,Wrong Answer,"from math import floor, ceil n, k = map(int, input().split()) a = list(map(int, input().split())) a.sort(reverse=True) l = 1 r = max(a) while r - l > 1: c = (l+r)//2 cnt = 0 for i in a: cnt += max(ceil(i/c) - 1, 0) if cnt <= k: r = c else: l = c print(r)" p02598,s376426076,Wrong Answer,"import numpy as np N, K = [int(x) for x in input().split()] A = np.array([int(x) for x in input().split()]) L = np.max(A) ans = L low = 1 high = L while 1: if low == high: ans = low break mid = (low + high) // 2 if np.sum(A // mid) <= K: high = mid else: low = mid + 1 print(ans)" p02598,s325792027,Wrong Answer,"import sys input = sys.stdin.readline import math def I(): return int(input()) def MI(): return map(int, input().split()) def LI(): return list(map(int, input().split())) N, K = MI() mylist = LI() length = len(mylist) high = max(mylist)+1 low = 0 mid = (high + low) / 2 while high - low >= 0.001: temp = 0 for i in mylist: if i % mid == 0: temp += (i // mid) - 1 else: temp += i // mid if temp > K: low = mid else: high = mid mid = (high + low) / 2 print(math.ceil(mid))" p02598,s987739216,Wrong Answer,"import math n,k=map(int, input().split()) a=list(map(int, input().split())) right=10**9 left=0 def cutable(a,x): count=0 for i in a: count+=math.ceil(i/x)-1 return count<=k while right>left+1: mid=(right+left)//2 if cutable(a,mid): left=mid else: right=mid+1 print(math.ceil(max(a)/left))" p02598,s269810595,Wrong Answer,"import math n, k = [int(i) for i in input().split()] a = [int(i) for i in input().split()] def seikai(x): count = 0 for i in range(n): count += math.ceil(a[i] / x) - 1 if(count <= k): return 1 else: return 0 l = 1 r = 10 ** 9 while(r - l > 1): temp = (r + l) // 2 if(seikai(temp) == 1): r = temp else: l = temp print(r)" p02598,s515196672,Wrong Answer,"import math def is_ok(K, N, A, length): s = 0 for i in range(N): if A[i] > length: s += math.ceil(A[i] / length)-1 return K >= s N, K = [int(i) for i in input().split()] A = [int(i) for i in input().split()] A.sort() if K == 0: print(A[-1]) exit() ok = A[-1] ng = 1 while abs(ok - ng) > 1: mid = (ok + ng) // 2 if is_ok(K, N, A, mid): ok = mid else: ng = mid print(math.ceil(ok))" p02598,s733236887,Wrong Answer,"n, k = map(int, input().split()) a = list(map(int, input().split())) low = 0 top = max(a) + 1 while top - low > 1: mid = (top + low) // 2 cnt = 0 for i in range(n): if a[i] % mid == 0: cnt += (a[i] // mid) - 1 else: cnt += a[i] // mid if cnt <= k: top = mid else: low = mid print(low) " p02598,s403381368,Wrong Answer,"n, k = map(int, input().split()) a = list(map(int, input().split())) floor = 1 ceil = max(a) L = (ceil + floor)//2 def cut(long, logs): cnt = 0 for i in logs: cnt += (i / long) - 1 if i % long != 0: cnt += 1 return cnt while ceil - floor > 1: L = (ceil + floor)//2 num = cut(L, a) if num > k: floor = L else: ceil = L print(ceil)" p02598,s870170413,Wrong Answer,"def isok(arg): count = 0 for i in range(N): count += -(-A[i]//arg)-1 if count <= K: return True else: return False def bisect(ng, ok): while (abs(ok - ng) > 1): mid = (ok + ng) // 2 if isok(mid): ok = mid else: ng = mid return ok N,K = map(int,input().split()) A = list(map(int,input().split())) print(bisect(1,10**9))" p02598,s829695043,Wrong Answer,"from collections import Counter import heapq from math import ceil N,K = list(map(int,input().split())) A = list(map(lambda x: -int(x),input().split())) counter = Counter(A) A = [] for key in counter.keys(): heapq.heappush(A,(key,counter[key])) if 10**6 < K: print(1) else: while 0 < K: m = heapq.heappop(A) heapq.heappush(A,(m[0]*m[1]/(m[1]+1),m[1]+1)) K -= 1 # print(A) print(ceil(-heapq.heappop(A)[0]))" p02598,s808357055,Wrong Answer,"f=lambda:[*map(int,input().split())] n,k=f() a=f() a=[i*100 for i in a] # Binary Search def ok(x): c=0 for i in a: c+=0--i//x return c<=n+k l,r=0,10**11+1 while r-l>1: m=l+r>>1 if ok(m): r=m else: l=m print(l,r) t=0--r//100 print(t-ok(t-1) if t>1 else t)" p02598,s021678436,Wrong Answer,"from bisect import bisect_left n, k = map(int, input().split()) a = list(map(int, input().split())) a.sort(reverse=True) ok = 0 ng = 10**10 def judge(l): cnt = 0 for aa in a: if aa <= l: break while aa > l: aa /= 2 cnt += 1 return cnt <= k while abs(ok - ng) > 1: mid = (ok + ng) // 2 if judge(mid): ok = mid else: ng = mid print(ok) " p02598,s490356519,Wrong Answer,"import sys 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 = Li() sa = sum(a) list.sort(a, reverse=True) ma = sa//(n+k)+1 div = [0]*n for i in range(n): div[i] = math.ceil(a[i]/ma)-1 sd = sum(div) if sd > k: j = 0 list.sort(div, reverse=True) print(div) for i in range(n): a[i] = math.ceil(a[i]/(div[i]+1)) print(max(a))" p02598,s832647918,Wrong Answer,"import heapq from math import ceil N,K = list(map(int,input().split())) A = list(map(lambda x: -int(x),input().split())) heaplist = [] for Ai in A: heapq.heappush(heaplist,(Ai,1,Ai)) if 10**7 < K: print(1) else: while 0 < K: m = heapq.heappop(heaplist) heapq.heappush(heaplist,(m[2]/(m[1]+1),m[1]+1,m[2])) K -= 1 # print(A) print(ceil(-heapq.heappop(heaplist)[0]))" p02598,s128211300,Wrong Answer,"N, K = map(int,input().split()) A = sorted(list(map(float,input().split()))) import math def cut(x): #xの丸太を半分に global A A[x] = A[x]/2 A = sorted(A) for p in range(K): cut(N-1) print(math.ceil(A[N-1]))" p02598,s914945948,Wrong Answer,"import math def is_ok(K, N, A, length): s = 0 for i in range(N): if A[i] > length: s += math.ceil(A[i] / length)-1 return K >= s N, K = [int(i) for i in input().split()] A = [int(i) for i in input().split()] A.sort() if K == 0: print(A[-1]) exit() ok = 10**9 ng = 1 while abs(ok - ng) > 1: mid = (ok + ng) // 2 if is_ok(K, N, A, mid): ok = mid else: ng = mid print(math.ceil(ok))" p02598,s465184942,Wrong Answer,"N,K = map(int,input().split()) A = list(map(int,input().split())) A.sort() def f(A,N): ans = 0 for i in range(len(A)): ans += -(-A[i]//N) - 1 return ans ok = 1000000000 ng = 1 while abs(ok-ng) > 1: mid = (ok+ng) // 2 if f(A,mid) <= K: ok = mid else: ng = mid print(ok) " p02598,s302508693,Wrong Answer,"n,k = map(int,input().split()) A = list(map(int,input().split())) A.sort(reverse=True) #print(A) for i in range(k): A[0] /= 2 A.sort(reverse=True) print(int(A[0])) " p02598,s158279623,Wrong Answer,"N, K = map(int,input().split()) A = sorted(map(int,input().split())) start = 0 end = A[-1] l = (start + end)/2 while end - start >= 0.5: l = (start + end)/2 count = 0 for i in range(N): count += (A[i]-1)//l if count > K: start = l else: end = l ans = (start + end)/2 print(int(ans)+1)" p02598,s384152109,Wrong Answer,"n, k = map(int, input().split()) A = [*map(int, input().split())] l, r = 1, 10**9 + 1 # [l,r) ans = r while r - l > 1: m = (l + r) // 2 c = 0 for a in A: c += (a+m-1) // m - 1 if c <= k: r = m ans = min(ans, m) else: l = m print(ans) " p02598,s847659591,Wrong Answer,"n,k=map(int,input().split()) a=list(map(int,input().split())) s=sum(a) f=len(a) d=s/(k+f) p=0 g=max(a) while k>0: g=max(a) p=g//d k-=p a.remove(g) k+=p if k==0: print(g) else: print(int(g//(k+1)+1))" p02598,s826757766,Wrong Answer,"import sys readline = sys.stdin.readline N, K = map(int, readline().split()) A = list(map(int, readline().split())) l = 0 r = 10**10 def test(m): return sum((a + m - 1) // m for a in A) <= K while l + 1 < r: m = (l + r) // 2 if test(m): r = m else: l = m print(r)" p02598,s714199854,Wrong Answer,"import numpy as np import math as mt n, k = map(int, input().split()) A = list(map(float, input().split())) arrayA = np.array(A) for i in range(k): j = np.argmax(arrayA) arrayA[j] = arrayA[j]/2 print(mt.ceil(arrayA[np.argmax(arrayA)]))" p02598,s165683348,Wrong Answer,"import sys import math n,k = map(int,input().split()) a = list(map(int,input().split())) if k ==0: print(max(a)) sys.exit() def check(t): ans = 0 if t==0: return False for aa in a: if aa > t: ans += aa//t return ans <= k max = 10**9+1 min = 0 while max-min>1: mid = (max+min)/2 if check(mid): max = mid else: min = mid print(math.ceil(max))" p02598,s975273182,Wrong Answer,"import heapq length_heap = [] N, total_cut = map(int, input().split()) length_list = list(map(int, input().split())) for index, l in enumerate(length_list): heapq.heappush(length_heap, (-l, 1, index)) for i in range(total_cut): longest, cut_n, idx = heapq.heappop(length_heap) heapq.heappush(length_heap, (-length_list[idx]/(cut_n+1), (cut_n + 1), idx)) result = -heapq.heappop(length_heap)[0] print(int(result+0.5)) " p02598,s750846223,Wrong Answer,"#E - Logs import math # 入力 N,K = map(int,input().split()) A = list(map(int,input().split())) Amax = int(max(A)) high = Amax Cancut = Amax low = 0 while ( low < high ) : Cut = 0 X = (high + low) / 2.0 for i in range(N): Cut = Cut + math.ceil(A[i]/X) - 1 if Cut <= K: high = X - 0.01 Cancut = X else: low = X + 0.01 # 出力 Cancut = math.floor( 100 * Cancut) / 100.0 print(math.ceil(Cancut))" p02598,s835900496,Wrong Answer,"import math def resolve(): N, K = map(int, input().split()) A = list(map(int, input().split())) def _f(length: int) -> bool: count = 0 for a in A: count += int((a-1) / length) return count <= K l = 0 r = 1e9 while (r-l) > 1: center = int((l+r) / 2) if _f(center): r = center else: l = center print(r) if __name__ == ""__main__"": resolve()" p02598,s846134957,Wrong Answer,"n,k=map(int,input().split()) a=list(map(int,input().split())) ok=max(a) ng=0 while ok-ng>1: mid=(ok+ng)//2 cnt=0 for i in range(n): num=a[i] cnt+=num//mid if cnt<=k: ok=mid else: ng=mid print(ok)" p02598,s799973133,Wrong Answer,"(N,K) = map(int,input().split()) l = input().split() max = 0 for i in range(N): l[i]= int(l[i]) if max <= l[i]: max = l[i] lb = 1 ub = max def cut(m): k = 0 for i in range(N): k += -((-1*l[i])//m)-1 return k while ub - lb > 1: if K == 0: break if cut((ub+lb)//2)>K: lb = (ub+lb)//2 else: ub = (ub+lb)//2 print(ub) " p02598,s814289902,Wrong Answer,"n,k=map(int,input().split()) a=list(map(int,input().split())) import math x=0 y=10**9 z=5*(10**8) s=0 for i in range(100): t=0 for j in range(n): t+=a[j]//z if t<=k: s=t y=z z=(x+y)/2 else: x=z z=(x+y)/2 print(x,y,z) print(math.ceil(z)) " p02598,s792293404,Wrong Answer,"n, k = map(int, input().split()) A = [*map(int, input().split())] l, r = 1, max(A) # [l,r] while r - l > 1: m = (l + r) // 2 c = 0 for a in A: c += a // m if c <= k: r = m else: l = m print(r) " p02598,s447748410,Wrong Answer,"import sys input = sys.stdin.readline def main(): N,K = map(int, input().split()) A = list(map(int, input().split())) l,r = 0, max(A) while l < r-1: mid = l + (r-l)//2 cnt = 0 for a in A: cnt+= a//mid if cnt <= K: r = mid else: l = mid print(r) main() " p02598,s812170854,Wrong Answer,"import math N, K = map(int, input().split()) A=list(map(int,input().split())) maxA = max(A) right = maxA+1 left = 0 while(right-left>1): mid = (left+right)//2 count = 0 for i in A: count += (i-1)//mid if count > K: left = mid else: right = mid print(mid) " p02598,s427927825,Wrong Answer,"import math n, k = map(int, input().split()) a_list = list(map(int, input().split())) ans = max(a_list) / 2 def nibun(x, rep, _max): cnt = 0 rep += 1 for i in a_list: cnt += math.ceil(i/x) - 1 if cnt <= k and rep < 1000: return nibun(x / 2, rep, x) elif rep < 1000: return nibun((x+_max)/ 2, rep, _max) else: return x print(math.ceil(nibun(ans, 0, ans*2)))" p02598,s121700239,Wrong Answer,"import math N, K = map(int, input().split()) A=list(map(int,input().split())) maxA = max(A) num = 0 right = maxA left = 0 while(right-left>1): num = left+math.floor((right-left)*0.5) count = 0 for i in range(len(A)): count += math.ceil(A[i]/num)-1 if count > K: left = num elif count <= K: right = num print(num+1) " p02598,s059255566,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)] 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] import math print(round(max(value))) " p02598,s816969691,Wrong Answer,"import sys import math input = sys.stdin.readline n, k = map(int, input().split()) a = list(map(int, input().split())) if k == 0: print(max(a)) exit() def check(x): res = 0 for i in a: res += i // x return res l = 0 r = 10 ** 9 + 1 for _ in range(40): x = (l + r) / 2 if check(x) >= k: l = x else: r = x print(math.ceil(l)) " p02598,s863334543,Wrong Answer,"n,k = map(int, raw_input().split()) ais = map(int, raw_input().split()) def p(m,ais,k): for ai in ais: k-= ai / m return k >=0 lo,hi = 1, max(ais) while(lo < hi): med = (lo + hi)/2 if p(med, ais, k): hi = med else: lo = med + 1 print lo " p02598,s064036449,Wrong Answer,"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 return k>=ret l=0 r=10**18 while r-l>1: mid=(l+r)//2 if solve(mid): r=mid else: l=mid for i in range(max(mid-10,1),mid+10): if solve(i): print(i) exit()" p02598,s085279545,Wrong Answer,"N,K=[int(s) for s in input().split()] maruta=[int(s) for s in input().split()] def possible(x): cut=0 for e in maruta: cut+=e//x if cut<=K: return True else: return False a=1 b=10**9 while b-a>1: c=(a+b)//2 if possible(c): b=c else: a=c if a==1 and possible(1): print(1) else: print(b) " p02598,s850874005,Wrong Answer,"n, k = map(int, input().split()) a = list(map(int, input().split())) l, r = 1, 10 ** 9 while l < r: m = (l + r) // 2 if sum(map(lambda v: (v - 1) // m, a)) > k: l = m + 1 else: r = m print(l, r) " p02598,s021032066,Wrong Answer,"import math N, K = map(int,input().split()) logs = list(map(int,input().split())) a = 0 b = max(logs) b_memo = set() count=0 flg =0 while b-a < 1: c = (a+b)//2 times = [] for i in logs: times.append(math.floor(i/c)) if sum(times) > K: a = c else: b = c print(math.ceil(b)) " p02598,s696006999,Wrong Answer,"N, M = input().strip().split() n, k = [int(N), int(M)] a = list(map(int, input().strip().split())) le = 0 ri = 10000000000 while ri - le > 1: mid = (le + ri) num = 0 for i in a: num += (i-1) if num <= k: ri = mid else: le = mid print(ri) " p02598,s242378281,Wrong Answer,"def judge(A, x, k): ans = 0 for a in A: ans += a // x if ans > k: return False return True n, k = map(int, input().split()) A = list(map(int, input().split())) l = 0 r = max(A) while r - l != 1: x = (r + l) // 2 if judge(A, x, k): r = x else: l = x print(r) " p02598,s222200979,Wrong Answer,"import math N,K = map(int, input().split()) A = list(map(int, input().split())) epsilon = 10**(-9) A = [a-epsilon for a in A] _min = 0 _max = max(A) while int(_min) 0 and chk(x)]))" p02598,s200662914,Wrong Answer,"import math import sys sys.setrecursionlimit(10**7) n, k = map(int, input().split()) a = list(map(int, input().split())) def binary_search(left, right): if right - left <= 0.1: return right middle = round((right + left) / 2, 2) if is_can(middle): return binary_search(middle, right) else: return binary_search(left, middle) def is_can(target): count = 0 for i in range(n): count += a[i] //target return count > k print(math.ceil(round(binary_search(0,10**10),1))) " p02598,s884703509,Wrong Answer,"import sys input = sys.stdin.readline import math def I(): return int(input()) def MI(): return map(int, input().split()) def LI(): return list(map(int, input().split())) N, K = MI() mylist = LI() length = len(mylist) high = max(mylist)+1 low = 0 mid = (high + low) / 2 while high - low >= 0.001: temp = 0 for i in mylist: if i % mid == 0: temp += (i // mid) - 1 else: temp += i // mid if temp > K: low = mid else: high = mid mid = (high + low) / 2 print(math.ceil(high))" p02598,s168312407,Wrong Answer,"N, K = map(int, input().split()) A = [int(i) for i in input().split()] def f(length, ls): cur = 0 for a in ls: cur += a//length if cur <= K: return True else: return False ok, ng = max(A), 0 while abs(ok - ng) > 1: z = (ok+ng)//2 if f(z, A) == True: ok = z else: ng = z print(ok)" p02598,s689301169,Wrong Answer,"N, K = map(int, input().split()) A = list(map(int, input().split())) def isOk(x): cnt = 0 for a in A: cnt += a // x return cnt <= K ok = max(A) ng = 0 while ok - ng > 1: mid = (ok + ng) // 2 if isOk(mid): ok = mid else: ng = mid print(ok) " p02598,s940555103,Wrong Answer,"import math n,k = map(int,input().split()) a_list = list(map(int,input().split())) min_num = 1 max_num = 10**9+1 while True: print(min_num) x = int((min_num+max_num)/2) if sum([math.ceil(a/x)-1 for a in a_list])>k: min_num = x else: max_num = x if max_num-min_num<=1: break #print(x) if sum([math.ceil(a/min_num)-1 for a in a_list])>k: print(int(min_num)+1) else: print(int(min_num))" p02598,s635956678,Wrong Answer,"import math N,K = map(int, input().split()) A = list(map(int, input().split())) epsilon = 10**(-9) #A = [a-epsilon for a in A] _min = 0 _max = max(A) while _max - _min < epsilon: new = (_min+_max)/2 if _min < int(new): new = int(new) times = sum([math.ceil(a/new)-1 for a in A]) #print(_min, new, _max, times, [math.ceil(a/new)-1 for a in A]) if times <= K: _max = new else: _min = new #print(_min, _max) if sum([math.ceil(a/_max)-1 for a in A]) <= K: print(math.ceil(_max)) else: print(math.ceil(_min))" p02598,s328025203,Wrong Answer,"n, k = map(int, input().split()) a = list(map(int, input().split())) if k == 0: print(max(a)) exit() l = 1 u = max(a) while u > l+1: # print(l,u) c = (l + u) // 2 cnt = 0 for i in a: cnt = cnt + (i//c) if cnt <= k: u = c else: l = c print(u)" p02598,s921918901,Wrong Answer,"import numpy as np n, k = map(int, input().split()) a = np.array(list(map(int, input().split()))) left, right = 1, np.max(a) while right - left > 1: mid = left + (right - left) // 2 if np.sum(np.ceil(a/mid)-1) <= k: right = mid else: left = mid print(right) " p02598,s149624648,Wrong Answer,"from math import ceil N,K=map(int,input().split()) *A,=map(int,input().split()) def C(x): return sum([ceil(A[i]/x)-1 for i in range(N)]) <= K def binary_search2(func, n_min, n_max): left,right=n_min,n_max while right-left>1: middle = (left+right)//2 y_middle = func(middle) if y_middle: right=middle else: left=middle return right print(binary_search2(C, 1, max(A)))" p02598,s860447346,Wrong Answer,"import sys n, k, *aaa = map(int, sys.stdin.buffer.read().split()) l = 1 r = max(aaa) while l + 1 < r: m = (l + r) // 2 if sum((a - 1) // m for a in aaa) > k: l = m else: r = m print(r) " p02598,s081327880,Wrong Answer,"N, K=map(int,input().split()) A=list(map(int,input().split())) def judge(ans,K,A): cut=0 for i in range(len(A)): cut+=(A[i]-1)//ans if cut>K: return False else: return True ansp=max(A) ansm=min(A) ans=(ansp+ansm)//2 d=1 while ansp-ansm>d: if judge(ans,K,A): ansp=ans else: ansm=ans ans=(ansp+ansm)//2 print(ansp)" p02598,s614909283,Wrong Answer,"n,k=map(int,input().split()) arr=list(map(int,input().split())) if(k==0): print(max(arr)) else: low=1 high=1000000000 while(low<=high): mid=low+(high-low)//2 if(mid==1): print(mid) break count=0 count2=0 for i in range(n): count+=(arr[i]-1)//mid count2+=(arr[i]-1)//(mid-1) if(count==k and count2==k+1): print(mid) break elif(count K: m = mid+1 break else: M = mid mid = (M+m)//2 print(mid)" p02598,s323746695,Wrong Answer,"import bisect N,K=map(int,input().split()) A=list(map(int,input().split())) #全ての丸太を長さt以下にするのに必要な切断数が #k以下であるような最大のtを求める ok=max(A) ng=0 def isok(t): res=0 for i in range(N): res+=A[i]//t return res<=K while abs(ok-ng)>1: mid=(ok+ng)//2 if isok(mid): ok=mid else: ng=mid print(ok) " p02598,s543669942,Wrong Answer,"#!/usr/bin/env python3 from math import ceil EPS = 1e-8 n, k = map(int, input().split()) a = list(map(int, input().split())) def f(p): c = 0 for x in a: c += x // p return c ok, ng = 0, max(a) while abs(ok - ng) > 1: m = (ok + ng) / 2 if f(m) > k: ok = m else: ng = m print(ceil(ok)) " p02598,s769508448,Wrong Answer,"import math N, K = map(int, input().split()) A = list(map(int, input().split())) left = 0 right = max(A) while right - left > 1: mid = (left + right) // 2 jk = 0 for i in range(N): jk += A[i] // mid - 1 if A[i] % mid == 0: jk += 1 if jk <= K: right = mid else: left = mid print(right)" p02598,s414162007,Wrong Answer,"import math N, K = map(int, input().split()) A = list(map(int, input().split())) if K == 0: print(max(A)) exit() ok = 1 ng = max(A)+1 while abs(ok-ng) > 1: mid = (ok+ng)//2 cnt = 0 for a in A: y = math.ceil(a/mid) cnt += y-1 if cnt <= K: ng = mid else: ok = mid+1 print(ok) " p02598,s467687404,Wrong Answer,"import math n , k = map(int, input().split()) a = list(map(int,input().split())) a.sort() left=a[0] right=a[n-1] mid = (left+right)/2 while right - left > 1: times = 0 for i in range(n): times+=math.ceil(a[i]/mid)-1 if times<=k: right=mid mid=(left+right)/2 else: left = mid mid =(left+right)/2 print(math.ceil(mid)) " p02598,s271997975,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())) n,k=mp() a=sorted(lmp()) ans=10**10 l=1 r=a[-1] while True: if l==r-1: print(r) exit() m=(l+r)//2 c=0 for i in a: c+=-(-i//m)-1 if c>k: l=m else: r=m " p02598,s525527280,Wrong Answer,"#coding: utf-8 N, K = (int(n) for n in input().split()) A = [int(n) for n in input().split()] def SplitTo(X): ret = 0 for log in A: ret += -(-log//X) - 1 return ret l = 1 r = max(A) mid = 0 while l <= r: mid = (l+r) // 2 ret = SplitTo(mid) yes = ret <= K if yes: r = mid - 1 else: l = mid + 1 print(mid) " p02598,s674396653,Wrong Answer,"def check(lis,k,mid): for i in lis: k-=(i//mid) return k>=0 n,k=map(int,input().split()) lis=list(map(int,input().split())) a,b=1,max(lis) ans=b while(a<=b): mid=(a+b)//2 if(check(lis,k,mid)): ans=mid b=mid-1 else: a=mid+1 print(ans) " p02598,s499288830,Wrong Answer,"from math import ceil, floor def main(): n, k = map(int, input().split()) a = list(map(int, input().split())) a.sort() lower = 1 upper = a[-1] while upper - lower >= 1: target = (lower + upper) / 2 now = 0 for i in range(n): now += ceil(a[i] / target) - 1 if now > k: lower = target + 1 else: upper = target print(floor(lower) if k > 0 else a[-1]) if __name__ == '__main__': main() " p02598,s932887752,Wrong Answer,"import heapq import math N,K = map(int,input().split()) a = list(map(int,input().split())) h = math.ceil(sum(a)/(K+N)) if N 1: summ = sum((a-1)//mid for a in aa) if summ <= k: right = mid mid = (left + right) // 2 else: left = mid mid = (left + right) // 2 print(right)" p02598,s446441669,Wrong Answer,"n,k = map(int,input().split()) A = list(map(int,input().split())) A.sort(reverse=True) print(A) for i in range(k): A[0] /= 2 A.sort(reverse=True) print(int(A[0])) " p02598,s383641227,Wrong Answer,"import math n,d = map(int, input().split(' ')) cirs = list(map(int, input().split(' '))) if n == 1: print(math.ceil(cirs[0]/(2**d))) else: for _ in range(d): list.sort(cirs, reverse=True) first = cirs[0] if len(cirs) == cirs.count(first): second = cirs[1] else: second = sorted(set(cirs), reverse=True)[1] # firstの削除 cirs.remove(first) if first/2 < second: cirs.extend([second, first-second]) else: cirs.extend([first/2, first/2]) print(math.ceil(max(cirs)))" p02598,s104138488,Wrong Answer,"import heapq n,k = map(int,input().split()) a = [int(i) for i in input().split()] low = 0 high = 10**9 if k == 0: print(max(a)) exit() while low+1 < high: tmp = 0 mid = (low + high) //2 for i in range(n): tmp += ((a[i]+mid-1) // mid)-1 print(tmp,mid) if tmp <= k: high = mid else: low = mid print(high) " p02598,s680465729,Wrong Answer,"n,k = list(map(int,input().split())) f = list(map(int,input().split())) s = (10**9) // 2 step = s best= 999999999999 import math for j in range(50): c = 0 arr = list(f) for i in range(n): c += arr[i] // s cor = 0 if arr[i] % (c+1) != 0: cor = 1 arr[i] = arr[i]//(c+1) + cor step = step//2 step = max(1, step) if c<=k: s -= step best = min(best,max(arr)) else: s += step if s==0: s=1 print(best)" p02598,s816013663,Wrong Answer,"N,K=[int(s) for s in input().split()] maruta=[int(s) for s in input().split()] def possible(x): cut=0 for e in maruta: cut+=e//x if cut<=K: return True else: return False a=1 b=max(maruta) while b-a>1: c=(a+b)//2 if possible(c): b=c else: a=c if a==1 and possible(1): print(1) else: print(b) " p02598,s615258007,Wrong Answer,"from math import floor N, K = map(int,input().split()) A = list(map(int,input().split())) def chk(L): cnt = 0 for i in range(N): cnt += floor(A[i]/L) return cnt <= K l, r = 1, max(A) for _ in range(10000): m = (l+r)/2 if chk(m): r = m else: l = m print(round(m))" p02598,s679496439,Wrong Answer,"n, k = map(int, input().split()) A = list(map(int, input().split())) r = max(A) l = 0 while l + 1 < r: mid = (l + r) // 2 if sum([(a - 1) // mid for a in A]) >= k: l = mid else: r = mid print(l)" p02598,s196385009,Wrong Answer,"import heapq length_heap = [] N, total_cut = map(int, input().split()) for l in input().split(): heapq.heappush(length_heap, (-int(l), 1)) for i in range(total_cut): longest, cut_n = heapq.heappop(length_heap) heapq.heappush(length_heap, ((longest * cut_n)/(cut_n + 1), (cut_n + 1))) result = -heapq.heappop(length_heap)[0] print(int(result+0.5)) " p02598,s655339485,Wrong Answer,"N, K = map(int,input().split()) A = sorted(map(int,input().split())) start = 0 end = A[-1] l = (start + end)/2 while int(end) - start >= 1: l = (start + end)/2 count = 0 for i in range(N): q, mod = divmod(A[i], l) if mod == 0.0: q -= 1 count += q if count > K: start = l else: end = l ans = (start + end)/2 print(int(end)+1)" p02598,s639080658,Wrong Answer,"import math n,k = map(int,input().split()) a = list(map(int,input().split())) l = 1 r = 10**9 + 1 while r - l > 1: m = (l+r) // 2 cnt = 0 for i in a: cnt += math.ceil(i / m) - 1 if cnt <= k: r = m else: l = m print(l+1) " p02598,s838222530,Wrong Answer,"n, k = map(int, input().split()) a = list(map(int, input().split())) def c(x): cnt=0 for i in a: cnt += i // x return cnt <= k l, r = 0, max(a) + 1 while l + 1 < r: mid = (l + r) // 2 if c(mid): r = mid else: l = mid print(r)" p02598,s297461826,Wrong Answer,"N,K = map(int,input().split()) A = list(map(int,input().split())) L = 0 R = max(A) while R-L > 0.001: X = (L+R)/2 m = 0 for i in range(N): c = A[i]/X if c == int(c): m += int(c) - 1 else: m += int(c) if m <= K: R = X else: L = X print(int(R))" p02598,s896926396,Wrong Answer,"import math N, K = map(int, input().split()) nums = list(map(int, input().split())) l = 1 r = 10**9 while(r-l > 1): mid = int(l + (r-l)/2) cut = 0 for num in nums: cut += math.ceil(num/mid)-1 if cut <= K: r = mid else: l = mid print(r)" p02598,s576894726,Wrong Answer,"N, K = map(int, input().split()) A = list(map(int, input().split())) def isOk(x): cnt = 0 for a in A: cnt += a // x return cnt <= K ok = max(A) ng = 0 while ok - ng > 1: mid = (ok + ng) // 2 if isOk(mid): ok = mid else: ng = mid while ok > 1 and isOk(ok - 1): ok -= 1 print(ok) " p02598,s788830761,Wrong Answer,"N, K = map(int, input().split()) arr = list(map(int, input().split())) def f(x): res = 0 for i in range(N): res += arr[i]//x return res left = 0 right = max(arr) while abs(left-right) > 1: tmp = (left+right)//2 if f(tmp) > K: left = tmp else: right = tmp print(right)" p02598,s663454410,Wrong Answer,"import math N, K = map(int, input().split()) logs = list(map(int, input().split())) longest_log = max(logs) if K == 0: print(longest_log) exit() def count_cut(log, size): return log//size left, right = 1, longest_log while left <= right: pivot = left + (right - left) // 2 count = sum(count_cut(log, pivot) for log in logs) if left == right: break if count > K: left = pivot + 1 elif count <= K: right = pivot - 1 print(pivot)" p02598,s085750418,Wrong Answer,"import math import heapq from collections import deque a = [] heapq.heapify(a) N,K=map(int,input().split()) if K>=N*30+1: print(1) else: L=list(map(int,input().split())) for i in range(N): heapq.heappush(a,(-L[i],1)) for i in range(K): b,count=heapq.heappop(a) b=b*count/(count+1) heapq.heappush(a,(b,count+1)) b,count=heapq.heappop(a) print(math.ceil(-b))" p02598,s735048228,Wrong Answer,"def check(List,mid): tmp=0 for l in List: tmp+=(-(-l//mid)-1) return tmp n,k=map(int,input().split()) a=list(map(int,input().split())) lo=1 hi=max(a) while hi - lo > 1: mid=(lo+hi)//2 if check(a,mid)<=k: hi=mid else: lo=mid print(hi)" p02598,s000417401,Wrong Answer,"n, k = map(int, input().split()) a = list(map(int, input().split())) def c(x): cnt=0 for i in a: cnt += i // x return cnt <= k l, r = 0, 10**9 while l + 1 < r: mid = (l + r) // 2 if c(mid): r = mid else: l = mid print(r)" p02598,s269655325,Wrong Answer,"import copy import math n, k = map(int,input().split()) a = list(map(int,input().split())) ub = 10**9 lb = 0 while ub - lb > 10**-6: x = (ub + lb) / 2 cnt = 0 for i in a: cnt += math.ceil(i/x) if cnt <= n+k: ub = copy.deepcopy(x) else: lb = copy.deepcopy(x) ans = round(ub, 5) print(math.ceil(ans))" p02598,s341319717,Wrong Answer,"import math n, k = map(int, input().split()) a = list(map(int, input().split())) floor = 1 ceil = max(a) def cut(long, logs): cnt = 0 for i in logs: cnt += math.ceil(i / long) - 1 return cnt while ceil - floor > 1: L = (ceil + floor)//2 num = cut(L, a) if num <= k: ceil = L else: floor = L print(ceil)" p02598,s702623176,Wrong Answer,"import math n, k = map(int, input().split()) a = list(map(int, input().split())) l = 1 r = max(a) mid = (r+l)//2 while not r-l == 1: c = 0 for x in a: c += x//mid if c > k: l = mid else: r = mid mid = (r+l)//2 c = 0 for x in a: c += x//l if c > k: print(r) else: print(l)" p02598,s501861402,Wrong Answer,"import math N,K = map(int,input().split()) A = list(map(int,input().split())) m = 0 M = max(A) while(M-m>0.0001): mm = 0 mid = (M+m)/2 for i in range(N): mm += math.ceil(A[i]/mid)-1 if mm>=K: m = mid else: M = mid print(math.ceil(mid)) " p02598,s658081279,Wrong Answer,"N, K = map(int, input().split()) tree = list(map(int, input().split())) left = 0 treeLen = len(tree) right = max(tree) while right - left > 1: cnt = 0 mid = (right + left) // 2 for i in range(treeLen): cnt += tree[i] // mid if K >= cnt: right = mid else: left = mid print(right) " p02598,s095923363,Wrong Answer,"n, k = map(int, input().split()) a = list(map(int, input().split())) result = max(a) # a = [x * 2 for x in a] left = 1 right = result med = left + (right - left) // 2 while left <= right: counter = sum([x // med for x in a]) if counter <= k: result = med right = med - 1 else: left = med + 1 med = left + (right - left) // 2 print(result) " p02598,s007811755,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(0--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)" p02598,s177877526,Wrong Answer,"# -*- coding: utf-8 -*- """""" Created on Mon Sep 14 13:43:55 2020 @author: ezwry """""" import math n, k = map(int, input().split()) alist = list(map(int, input().split())) logmin = math.ceil(sum(alist) / (n + k)) logmax = max(alist) def howmanytimes(t, m): x = math.ceil(t/m) - 1 return x for i in range(logmin, logmax + 1): kaisu = 0 for j in range(len(alist)): z = howmanytimes(alist[j], i) kaisu += z if kaisu == k: print(i) exit() " p02598,s183274314,Wrong Answer,"import math N, K = map(int, input().split()) A = list(map(int, input().split())) left = 0 right = A[0] while right - left > 1: mid = (left + right) // 2 jk = 0 for i in range(N): jk += math.ceil( A[i] / mid) - 1 if jk <= K: right = mid else: left = mid print(right)" p02598,s309735963,Wrong Answer,"from math import ceil m=1 M=10**9 N,K=map(int,input().split()) A=list(map(int,input().split())) def OK(k): if sum([ceil(a/k) for a in A])<=K: return True else: return False while M-m>1: p=(m+M)//2 if OK(p): m=p else: M=p print(m)" p02598,s796452584,Wrong Answer,"N,K=map(int,input().split()) L=list(map(int,input().split())) if K>=10**7: print(1) exit() import heapq Q=[] for i in range(N): Q.append((-L[i],L[i],1)) heapq.heapify(Q) for i in range(K): l,B,cnt=heapq.heappop(Q) heapq.heappush(Q,(-B/(cnt+1),B,cnt+1)) #print(Q) #print(Q[0][0]) import math ans=-Q[0][0] print(math.ceil(ans))" p02598,s000023233,Wrong Answer,"n, k = map(int, input().split()) a = list(map(int, input().split())) a.sort(reverse=True) b = sum(a) ans = 0 nokori = k for i, j in enumerate(a): if nokori == 0: break tmp = (j * k + b - 1) // b if nokori - tmp >= 0: ans = max(ans, (j + tmp) // (tmp + 1)) else: ans = max(ans, (j + nokori) // (nokori + 1)) break nokori -= tmp if k == 0: print(a[0]) else: print(ans)" p02598,s978769729,Wrong Answer,"# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..) import sys from math import ceil def main(N, K, A): def cut_times(longest): return sum(a // longest for a in A) under = -1 r = 10**9 for i in range(100): m = (under + r) / 2 if cut_times(m) <= K: r = m else: under = m print(ceil(r)) if __name__ == '__main__': input = sys.stdin.readline N, K = map(int, input().split()) *A, = map(int, input().split()) main(N, K, A) " p02598,s861140325,Wrong Answer,"N,K=map(int,input().split()) *A,=map(int,input().split()) def C(x): return sum([(A[i]+x-1)//x-1 for i in range(N)]) <= K def binary_search2(func, n_min, n_max): left,right=n_min,n_max while right-left>1: middle = (left+right)//2 y_middle = func(middle) if y_middle: right=middle else: left=middle return right print(binary_search2(C, 1, max(A)))" p02598,s032978555,Wrong Answer,"import sys input = sys.stdin.readline N,K = map(int,input().split()) A = list(map(int,input().split())) x = max(A) mn = 0 mx = max(A) while mx-mn > 1: suc = True cnt = 0 for a in A: cnt += -(-a)//x if cnt > K: suc = False break if suc: mx = x x = (mn+mx)//2+1 else: mn = x x = (mn+mx)//2 print(x) " p02598,s253990827,Wrong Answer,"import math n, k = map(int, input().split()) a = list(map(int, input().split())) s = sum(a) for i in range(n): t = round(k * a[i] / s) a[i] = math.ceil(a[i] / (t + 1)) print(max(a)) " p02598,s008694560,Wrong Answer,"import math n, k = map(int, input().split()) a = list(map(int, input().split())) def is_ok(x,a,k): b = 0 for ai in a: b += math.ceil(ai/x) b -= 1 print(x,b) if b <= k: return True def meguru_bisect(ng, ok): while (abs(ok - ng) > 1): mid = (ok + ng) // 2 if is_ok(mid,a,k): ok = mid else: ng = mid return ok print(meguru_bisect(0,max(a)))" p02598,s289208636,Wrong Answer,"(N,K) = map(int,input().split()) l = input().split() max = 0 for i in range(N): l[i]= int(l[i]) if max <= l[i]: max = l[i] lb = 1 ub = max def cut(m): k = 0 for i in range(N): k += -((-1*l[i])//m)-1 return k while ub - lb > 1: if cut((ub+lb)//2)>K: lb = (ub+lb)//2 else: ub = (ub+lb)//2 print(ub) " p02598,s575721080,Wrong Answer,"import math import numpy as np a = list(map(int, input().split())) b = list(map(int, input().split())) for i in range(0,a[1]): b[np.argmax(b)] = b[np.argmax(b)] / 2 print(math.ceil(max(b)))" p02598,s722926477,Wrong Answer,"from math import ceil n, k, *A = map(int, open(0).read().split()) t = sum(A) / (n+k) A = [a for a in A if int(a/t) >= 1] X = [] for a in A: X.append(ceil(a / ceil(a/t))) X.append(ceil(a / int(a/t))) X.sort() print(X[k] if k < len(X) else X[-1])" p02598,s201958248,Wrong Answer,"from math import ceil n,k=map(int,input().split()) lst=list(map(int,input().split())) ng=1 ok=10**9+1 while ok-ng>1: mid=(ok+ng)//2 tmp=0 for i in range(n): tmp+=ceil(lst[i]/mid)-1 if tmp>k: ng=mid else: ok=mid print(ok)" p02598,s210137863,Wrong Answer,"(N,K) = map(int,input().split()) l = input().split() max = 0 for i in range(N): l[i]= int(l[i]) if max <= l[i]: max = l[i] lb = 1 ub = max def cut(m): k = 0 for i in range(N): k += -((-1*l[i])//m)-1 return k while ub - lb > 1: if cut((ub+lb)//2)>K: lb = (ub+lb)//2 else: ub = (ub+lb)//2 print(ub) " p02598,s614756180,Wrong Answer,"import math n, k = map(int, input().split()) A = list(map(int, input().split())) max_len = max(A) def f(x): ans = 0 for a in A: cut_num = math.ceil(a / x) - 1 #print(a, cut_num, a / x) ans += cut_num if ans <= k: return True else: return False left = 1 right = max_len while right - left > 1: mid = (right + left) // 2 if f(mid): right = mid else: left = mid else: print(right)" p02598,s123546092,Wrong Answer,"import math N, K=map(int,input().split()) A=list(map(int,input().split())) def judge(ans,K,A): cut=0 for i in range(len(A)): cut+=A[i]//ans if cut>K: return False else: return True ansp=max(A) ansm=min(A) ans=(ansp+ansm)//2 d=1 while ansp-ansm>d: if judge(ans,K,A): ansp=ans else: ansm=ans ans=(ansp+ansm)//2 print(ansp)" p02598,s096410355,Wrong Answer,"# coding: utf-8 import math n,k = map(int,input().split()) log_list = list(map(float,input().split())) log_list.sort() cut_count = 0 while cut_count < k: max_index = log_list[n-1] next_index = log_list[n-2] div_count = 2 while(log_list[n-1] / div_count >= log_list[n-2]): div_count+=1 log_list[n-1] = log_list[n-1] / div_count cut_count += div_count - 1 log_list.sort() print(log_list) print(math.ceil((max(log_list))))" p02598,s519526578,Wrong Answer,"import math N,K = map(int,input().split()) cs = list(map(int, input().split())) ma = max(cs) mi = 0 rgl = math.ceil(math.log2(ma)) rt = ma+1 def counter(ch,mo): rt =math.ceil(ch/mo) return rt-1 if rt > 0 else 0 for _ in range(rgl): cnt = 0 for c in cs: cnt+=counter(c,ma) if cnt <= K and ma < rt: rt = ma ma = math.ceil((ma+mi)/2) else: tmp = ma ma += math.ceil((ma-mi)/2) mi = tmp print(rt)" p02598,s518565297,Wrong Answer,"from math import ceil N,K=map(int,input().split()) *A,=map(int,input().split()) def C(x): return sum([(A[i]-.5)//x for i in range(N)]) <= K def binary_search2(func, n_min, n_max): left,right=n_min,n_max while right-left>1: middle = (left+right)//2 y_middle = func(middle) if y_middle: right=middle else: left=middle return right print(binary_search2(C, 1, max(A)))" p02598,s547718992,Wrong Answer,"import math N, K = list(map(int,input().split())) A = list(map(int,input().split())) def is_ok(mid): cnt = 0 for i in range(N): cnt += math.floor(A[i] / mid) return cnt <= K def binary_search(left, right): while (abs(right - left) > 1): mid = (left + right) // 2 if is_ok(mid): right = mid else: left = mid return right if K == 0: print(max(A)) else: left = max(A) right = 0 ret = binary_search(right, left) print(ret)" p02598,s203653792,Wrong Answer,"def is_ok(X): cnt = 0 for a in A: cnt += a//X if cnt <= k: return True else: return False 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 n, k = map(int,input().split()) A = list(map(int,input().split())) print(meguru_bisect(0,max(A))) " p02598,s182589071,Wrong Answer,"import math N, K = map(int, input().split()) A = list(map(int, input().split())) X = max(A) if K == 0: print(X) exit() else: for i in range(1, 32): B = [] for a in A: b = math.ceil(a / X) - 1 B.append(b) B_total = sum(B) if B_total > K: X += max(A) / pow(2, i) else: X -= max(A) / pow(2, i) print(math.ceil(X))" p02598,s674119191,Wrong Answer,"from heapq import heappop, heappush, heapify n, x = map(int,input().split()) a = [-1*int(i) for i in input().split()] ans = [] heapify(ans) for i in a: heappush(ans, i) while x > 0: t = -1*heappop(ans) t1,t2 = t//2,t//2+t%2 heappush(ans, -t1) heappush(ans, -t2) x -= 1 print(-1*heappop(ans))" p02598,s556505641,Wrong Answer,"import math n, k = map(int, input().split()) a = list(map(int, input().split())) left = 0 right = max(a) while True: mid = (left + right) / 2 cnt = 0 for _a in a: cnt += math.ceil(_a / mid - 1) if cnt > k: left = mid else: right = mid if right - left <= 10 ** -3: break print(math.ceil(left))" p02598,s958796270,Wrong Answer,"import heapq n,k = map(int,input().split()) a = [int(i) for i in input().split()] low = 1 high = 10**9 if k == 0: print(max(a)) exit() if n == 1: print((a[0]+k)//(k+1)) exit() while low+1 < high: tmp = 0 mid = (low + high) //2 #print(mid) for i in range(n): tmp += ((a[i]+mid-1) // mid)-1 if tmp <= k: high = mid else: low = mid print(high) " p02598,s265998720,Wrong Answer,"from bisect import bisect_right N, K = map(int,input().split()) A = list(map(int, input().split())) A.sort() OK = 10**9 NG = 1 while OK - NG > 1: ans = 0 mid = (OK+NG)//2 temp = bisect_right(A, mid) if temp == N: OK = mid else: for a in A[temp::]: ans += a//mid if ans > K: NG = mid else: OK = mid print(OK)" p02598,s484716702,Wrong Answer,"import sys n,k = map(int,input().split()) a = list(map(int,input().split())) if k ==0: print(max(a)) sys.exit() def check(t): ans = 0 for aa in a: if aa > t: ans += aa//t if ans > k: return False else: return True max = 10**9 min = 0 while max-min>1: mid = (max+min)/2 if check(mid): max = mid else: min = mid print(int(max)+1)" p02598,s492824422,Wrong Answer,"n,k = map(int,input().split()) L = list(map(int,input().split())) def A(x): cnt = 0 for i in range(n): cnt +=L[i]//x return cnt <= k lower = 0 upper = max(L) while upper - lower > 1: mid = (lower + upper)//2 if A(mid): upper = mid else: lower = mid print(upper)" p02598,s258305669,Wrong Answer,"from sys import stdin from sys import setrecursionlimit import numpy as np import math setrecursionlimit(10 ** 7) n,k = map(int,stdin.readline().rstrip().split()) a = list(map(int,stdin.readline().rstrip().split())) a.sort() a = np.array(a,dtype=np.int64) low = -1 hi = 10**9 point = 0 while point <= 1000: ave = (hi+low)/2 if np.maximum(0,a//ave).sum() <= k: hi = ave else: low = ave point += 1 print(math.ceil(ave))" p02598,s429559838,Wrong Answer,"def check(lis,k,mid): for i in lis: k-=(i//mid) return k>=0 n,k=map(int,input().split()) lis=list(map(int,input().split())) a,b=min(lis),max(lis) ans=b while(a<=b): mid=(a+b)//2 if(check(lis,k,mid)): ans=mid b=mid-1 else: a=mid+1 print(ans) " p02598,s123358888,Wrong Answer,"from math import floor, ceil def main(): n, k = map(int, input().split()) a = list(map(int, input().split())) a.sort() lower = 1 upper = a[-1] 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() " p02598,s625208402,Wrong Answer,"N, K = map(int,input().split()) A = sorted(map(int,input().split())) start = 0 end = A[-1] l = (start + end)/2 while end - start >= 0.0000001: l = (start + end)/2 count = 0 for i in range(N): q, mod = divmod(A[i], l) if mod == 0.0: q -= 1 count += q if count > K: start = l else: end = l ans = (start + end)/2 print(int(end)+1)" p02598,s700238437,Wrong Answer,"def binary_search2(func, n_min, n_max): left,right=n_min,n_max y_left, y_right = func(left), func(right) while True: middle = (left+right)//2 y_middle = func(middle) if y_left==y_middle: left=middle else: right=middle if right-left==1:break return left def f(x): return sum([A[i]//x for i in range(N)])<=K N,K=map(int,input().split()) A=list(map(int,input().split())) print(binary_search2(f, 1, max(A))+1)" p02598,s999145092,Wrong Answer,"from math import floor, ceil n, k = map(int, input().split()) a = list(map(int, input().split())) a.sort(reverse=True) l = 1 r = max(a) while r - l > 1: c = (l+r)//2 cnt = 0 for i in a: cnt += max(ceil(i/c) - 1, 0) if cnt <= k: r = c else: l = c print(r)" p02598,s223571538,Wrong Answer,"import math import heapq n, k = map(int, input().split()) a = list(map(int, input().split())) for i in range(n): a[i] = -math.log2(a[i]) heapq.heapify(a) for _ in range(k): heapq.heappush(a, heapq.heappop(a)+1) print(a) print(int(-(-2**(-1*heapq.heappop(a))//1)))" p02598,s695226200,Wrong Answer,"n,k = map(int,input().split()) A = list(map(int,input().split())) ng = 0 ok = max(A) def queri(n): count = 0 for i in A: count += -(-i//n) if k>= count: return True else: return False while ok - ng > 1: mid = (ok+ng)//2 if queri(mid) : ok = mid else: ng = mid print(ok)" p02598,s936729128,Wrong Answer,"N, K = map(int, input().split()) A = list(map(int, input().split())) A.sort(reverse=True) def isfeasible(L): k = 0 for i in range(N): a = A[i] 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] if K == 0: print(A[0]) else: while r-l>1: L = (r+l)//2 if isfeasible(L): r = L else: l = L+1 print(r)" p02598,s146186764,Wrong Answer,"#E - Logs import math # 入力 N,K = map(int,input().split()) A = list(map(int,input().split())) Amax = max(A) high = Amax Cancut = Amax low = 0 while ( (high - low) > 0.01 ) : Cut = 0 X = (high + low) / 2.0 for i in range(N): Cut = Cut + math.ceil(A[i]/X) - 1 if Cut <= K: high = X Cancut = X else: low = X # 出力 Cancut = int( 100 * Cancut) / 100 print(math.ceil(Cancut))" p02598,s732215189,Wrong Answer,"import math def f(A, m, K): p = sum([a // m for a in A]) if p > K: return False else: return True N, K = map(int, input().split()) A = list(map(int, input().split())) left = 1 right = 10 ** 9 while int(left) != int(right): m = (left + right) / 2 if f(A, m, K): right = m else: left = m print(math.ceil(m)) " p02598,s190255576,Wrong Answer,"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): 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))" p02598,s008540448,Wrong Answer,"import sys import math input = sys.stdin.readline n, k = map(int, input().split()) a = list(map(int, input().split())) def check(x): res = 0 for i in a: res += math.floor(i / x) return res l = 0 r = 10 ** 9 + 1 for _ in range(40): x = (l + r) / 2 if check(x) > k: l = x else: r = x print(math.ceil(l)) " p02598,s863848174,Wrong Answer,"import math n,k = map(int,input().split()) a_list = list(map(int,input().split())) min_num = 1 max_num = 10**9+1 while True: print(min_num) x = int((min_num+max_num)/2) if sum([math.ceil(a/x)-1 for a in a_list])>k: min_num = x else: max_num = x if max_num-min_num<=1: break #print(x) if sum([math.ceil(a/min_num)-1 for a in a_list])>k: print(min_num+1) else: print(min_num)" p02598,s334774375,Wrong Answer,"from math import ceil n,k = map(int,input().split()) a = list(map(int,input().split())) print(n,k,a) def cut(x): t = 0 for i in a: if i <= x: continue t += ceil(i / x) - 1 return t <= k l,r=0,10**9 while l+1 < r: x = l + (r-l)//2 if cut(x): r = x else: l = x print(r)" p02598,s959230984,Wrong Answer,"import math def main(): _, k = map(int, input().split()) arr = list(map(int, input().split())) print(arr) l, r = 1, 1000000000 while l < r: m = (l + r) // 2 cnt = 0 for val in arr: cnt += math.ceil(val / m) - 1 if cnt > k: l = m + 1 else: r = m print(l) if __name__ == '__main__': main()" p02598,s957728394,Wrong Answer,"import math N, K = map(int, input().split()) A = list(map(float, input().split())) if K == 0: print(int(max(A))) exit() if N == 1: print(math.ceil(A[0]/K)) exit() min_A = 0 max_A = max(A) + 1 while( max_A - min_A > 1): now = (min_A + max_A) // 2 temp = 0 for i in A: if i > now: temp += (i // now) if temp > K: min_A = now else: max_A = now print(int(min_A) + 1)" p02598,s781082781,Wrong Answer,"N, K = map(int, input().split()) A = list(map(int, input().split())) A.sort() hi = 10**18 lo = 1 while hi - lo > 1: mid = (hi + lo) // 2 cut = 0 for i in range(N): cut += (A[i] + mid - 1) // mid - 1 if cut <= K: hi = mid else: lo = mid print(hi) " p02598,s893205294,Wrong Answer,"from math import ceil N,K = map(int,input().split()) A = list(map(int,input().split())) def possible(l): c = 0 for i in range(N): n = A[i]//l c += n return c<=K l = 0 r = max(A) m = (l+r)/2 for i in range(32): pos = possible(m) if pos: r = m else: l = m m = (l+r)/2 print(ceil(m))" p02598,s532299976,Wrong Answer,"import math nk=input() nn=nk.split() n=int(nn[0]) k=int(nn[1]) aa=input() a=aa.split() for i in range(0,n): a[i]=int(a[i]) a.sort(reverse=True) for i in range(0,k): a[0]=a[0]*0.5 a.sort(reverse=True) print(math.ceil(a[0])) " p02598,s199368890,Wrong Answer,"n,k = map(int,input().split()) A = list(map(int,input().split())) A.sort() M = max(A) l,r = 1,M cnt = 0 while lk: l=m else: r=m " p02598,s811931544,Wrong Answer,"from sys import stdin from sys import setrecursionlimit import numpy as np import math setrecursionlimit(10 ** 7) n,k = map(int,stdin.readline().rstrip().split()) a = list(map(int,stdin.readline().rstrip().split())) a.sort() a = np.array(a,dtype=np.int64) low = 0 hi = 10**9 point = 0 while hi-low > 0.00001: ave = (hi+low)/2 if np.ceil(a//ave).sum() <= k: hi = ave else: low = ave print(math.ceil(ave))" p02598,s360989121,Wrong Answer,"n,k=map(int,input().split()) a=list(map(int,input().split())) tmax=max(a) tmin=0 import math ans=tmax if k==0: print(tmax) else: while True: t=(tmax+tmin)/2 if abs(tmax-tmin)<0.01: break s=0 for i in range(n): s=s+math.ceil(a[i]/t)-1 if k>=s: ans=min(math.ceil(t),ans) tmax=t else: tmin=t print(ans)" p02598,s478099015,Wrong Answer,"N, K = map(int, input().split()) a = list(map(int, input().split())) max_a = 10**9 min_a = 0 while max_a-min_a>1: count = K mean_a = (max_a+min_a)//2 for i in range(N): if a[i]==mean_a: continue count -= -a[i]//mean_a if count >= 0: max_a = mean_a else: min_a = mean_a print(max_a)" p02598,s678055157,Wrong Answer,"import sys import math n,k = map(int,input().split()) a = list(map(int,input().split())) if k ==0: print(max(a)) sys.exit() def check(t): ans = 0 if t==0: return False for aa in a: if aa > t: ans += aa//t if ans > k: return False else: return True max = 10**9+1 min = 0 while max-min>0.001: mid = (max+min)/2 if check(mid): max = mid else: min = mid print(math.ceil(max))" p02598,s244021267,Wrong Answer,"import math n,k = map(int,input().split()) a_list = list(map(int,input().split())) min_num = 1 max_num = 10**9+1 while True: x = int((min_num+max_num)/2) if sum([math.ceil(a/x)-1 for a in a_list])>k: min_num = x else: max_num = x if max_num-min_num<=1: break #print(x) print(int(max_num)) " p02598,s978969211,Wrong Answer,"rule=input().split() N=int(rule[0]) K=int(rule[1]) data=input().split() ans=0 for i in range(len(data)): ans+=int(data[i]) import math print(math.ceil(ans/(K+1)))" p02598,s463183122,Wrong Answer,"# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..) import sys from math import ceil def main(N, K, A): lo = -1 hi = 10**9 for i in range(100): m = (lo + hi) / 2 if sum(ceil(a / m) - 1 for a in A) <= K: hi = m else: lo = m print(ceil(hi - 10**-9)) if __name__ == '__main__': input = sys.stdin.readline N, K = map(int, input().split()) *A, = map(int, input().split()) main(N, K, A) " p02598,s292746929,Wrong Answer,"import math N,K=map(int,input().split()) A=[int(x) for x in input().split()] A=sorted(A) left=0 right=max(A) mid=max((left+right)//2,1) while(right-left>=1): numofcut=0 for i in range(N): numofcut+=math.ceil(A[i]/mid) #print(numofcut) if numofcut>K: left=mid+1 else: right=mid mid=max((left+right)//2,1) if mid==1: break print(mid)" p02598,s894108614,Wrong Answer,"def is_ok(X): cnt = 0 for a in A: cnt += a//X if cnt <= k: return True else: return False 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 n, k = map(int,input().split()) A = list(map(int,input().split())) print(meguru_bisect(0,max(A)+1)) " p02598,s427938669,Wrong Answer,"import math N, K = map(int,input().split()) logs = list(map(int,input().split())) a = 0 b = max(logs) b_memo = set() count=0 flg =0 while b-a < 1: c = (a+b)//2 times = [] for i in logs: times.append(math.floor(i/c)) if sum(times) > K: a = c else: b = c print(b)" p02598,s040460280,Wrong Answer,"import bisect n,k=map(int,input().split()) a=list(map(int,input().split())) a.sort() xma=a[-1] x=a[-1]//2 xmi=0 xo=-1 while abs(x-xo)>0.0001: k2=k for i in range(n): j=1 while a[i]/j>x: j+=1 k2-=1 if k2<0: xo=x xmi=x x=(xma+x)/2 else: xo=x xma=x x=x/2 import math print(math.ceil(x)) " p02598,s800695270,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.0000001 ans = mid else: low = mid+0.0000001 # ~ if low < high: print(low, high, ""je reviens"") print(round(ans)) " p02598,s184406690,Wrong Answer,"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 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))" p02598,s854437431,Wrong Answer,"# coding: utf-8 def solve(*args: str) -> str: n, k = map(int, args[0].split()) A = tuple(map(int, args[1].split())) l, r = 0, max(A) while l+0.5 < r: m = (l+r)/2 cnt = 0 for a in A: cnt += -int(-a//m)-1 if k < cnt: l = m else: r = m return str(-int(-l//1)) if __name__ == ""__main__"": print(solve(*(open(0).read().splitlines()))) " p02598,s932784869,Wrong Answer,"n, k = map(int, input().split()) a = list(map(int, input().split())) low = 0 top = max(a) while top - low > 1: mid = (top + low) // 2 cnt = 0 for i in range(n): cnt += (a[i] + 1) // mid if cnt <= k: top = mid else: low = mid print(low) " p02598,s222375069,Wrong Answer,"N, K = map(int, input().split()) A = list(map(int, input().split())) def f(x): return sum((a+x-1)//x - 1 for a in A) l = 1 r = 10**9+1 while r - l > 1: mid = (l + r) // 2 if f(mid) <= K: r = mid else: l = mid print(r)" p02598,s629485165,Wrong Answer,"import sys import heapq import math def input(): return sys.stdin.readline().rstrip() def main(): N, K = map(int, input().split()) A = list(map(int, input().split())) ok = max(A) ng = 1 while abs(ok - ng) > 1: mid = abs(ok + ng) // 2 count = 0 for i in range(N): count += math.ceil(A[i] / mid)-1 if count <=K: ok = mid else: ng = mid print(ok) if __name__ == ""__main__"": main() " p02598,s144724996,Wrong Answer,"n,k=map(int,input().split()) a=list(map(int,input().split())) a.sort() l=1 r=a[-1] while r-l>1: cnt=0 m=(l+r)//2 #print(""l,m,r"",l,m,r) for i in a: cnt+=i//m if cnt<=k: r=m else: l=m print(r)" p02598,s228080931,Wrong Answer,"import math N,K = map(int, input().split()) A = list(map(int, input().split())) _min = 0 _max = max(A) while int(_min)left+1: cnt=K mid=(left+right)//2 for i in range(N): cnt -=A[i]//mid if cnt>=0:right=mid elif cnt<0:left=mid+1 print(left)" p02598,s691305256,Wrong Answer,"#E - Logs import math # 入力 N,K = map(int,input().split()) A = list(map(int,input().split())) Amax = int(max(A)) high = Amax Cancut = Amax low = 0 while ( low < high ) : Cut = 0 X = (high + low) / 2.0 for i in range(N): Cut = Cut + math.ceil(A[i]/X) - 1 if Cut <= K: high = X - 0.01 Cancut = X else: low = X + 0.01 # 出力 #Cancut = int( 100 * Cancut) / 100 print(math.ceil(Cancut))" p02598,s476568438,Wrong Answer,"import math def solve(K, N, A, length): s = 0 for i in range(N): if A[i] > length: s += int(A[i] / length) return K >= s N, K = [int(i) for i in input().split()] A = [int(i) for i in input().split()] A.sort() if K == 0: print(A[-1]) exit() ok = 10**9 ng = 1 while abs(ok - ng) > 1: mid = int((ok + ng) / 2) if solve(K, N, A, mid): ok = mid else: ng = mid print(math.ceil(ok))" p02598,s550395050,Wrong Answer,"from bisect import bisect_left,bisect import math N, K = map(int, input().split()) A = list(map(int, input().split())) A.sort() m = 0 M = max(A) + 1 while M - m > 1: temp = (M + m) // 2 L = bisect(A, temp) cnt = 0 for i in range(L, N): p, q = divmod(A[i], temp) if q == 0: cnt += p-1 else: cnt += p if cnt <= K: M = temp else: m = temp print(temp)" p02598,s149205708,Wrong Answer,"N,K = map(int,input().split()) A = list(map(int,input().split())) for i in range(N): A[i] *= -1 import heapq heapq.heapify(A) for i in range(K): m = heapq.heappop(A) heapq.heappush(A,m/2) a = min(A) a *= -1 if a == int(a): print(int(a)) else: print(int(a) + 1)" p02598,s961754748,Wrong Answer,"def solve(): N, K = map(int,input().split()) A = list(map(int,input().split())) left = 1 right = 10 ** 9 + 1 while right - left > 1: mid = (right+left) // 2 cnt = 0 for a in A: cnt += (a-1) // mid if cnt <= K: right = mid else: left = mid print(right) if __name__ == '__main__': solve() " p02598,s898634839,Wrong Answer,"from math import ceil N, K = map(int, input().split()) A = [*map(int, input().split())] l_lb, l_min = 1, max(A) while l_min - l_lb > 1: l_mid = (l_lb + l_min) // 2 if sum(ceil(a/l_mid) for a in A) - N > K: l_lb = l_mid else: l_min = l_mid print(l_min)" p02598,s571525428,Wrong Answer,"n,k,*a=map(int,open(l:=0).read().split()) r=9**9 while~l+r: x=l+r>>1 if-sum(-b//x+1for b in a)>k:l=x else:r=x print(r)" p02598,s527918282,Wrong Answer,"#E - Logs import math # 入力 N,K = map(int,input().split()) A = list(map(int,input().split())) Amax = int(max(A)) high = Amax Cancut = Amax low = 0 while ( low <= high ) : Cut = 0 X = (high + low) / 2 for i in range(N): Cut = Cut + math.ceil(A[i]/X) - 1 if Cut <= K: high = X - 0.01 Cancut = X else: low = X + 0.01 # 出力 print(math.ceil(Cancut))" p02598,s039683520,Wrong Answer,"import sys import math n,k = map(int,input().split()) a = list(map(int,input().split())) if k ==0: print(max(a)) sys.exit() def check(t): ans = 0 for aa in a: if aa > t: ans += aa//t if ans > k: return False else: return True max = 10**9 min = 0 while max-min>0.001: mid = (max+min)/2 if check(mid): max = mid else: min = mid print(math.ceil(max))" p02598,s559153591,Wrong Answer,"#E - Logs import math # 入力 N,K = map(int,input().split()) A = list(map(int,input().split())) Amax = int(max(A)) high = Amax Cancut = Amax low = 0 while ( (high - low) > 0.1 ) : Cut = 0 X = (high + low) / 2.0 for i in range(N): Cut = Cut + math.ceil(A[i]/X) - 1 if Cut <= K: high = X Cancut = X else: low = X # 出力 #Cancut = math.floor( 10 * Cancut) /10.0 print(math.ceil(Cancut))" p02598,s681830016,Wrong Answer," # にぶたん 二分探索 n, k = map(int, input().split()) A = list(map(int, input().split())) ok = 1 ng = max(A) while abs(ok - ng) > 1: mid = (ok + ng) // 2 cnt = 0 for a in A: if a // mid > 1: cnt += a // (mid + 1) if cnt < k: ng = mid else: ok = mid ans = 0 for a in A: if a >= ok: m = a % ok ans = max(ans, m) print(ok + ans)" p02598,s000895144,Wrong Answer,"from math import ceil, floor n,k = map(int,input().split()) a = list(map(int,input().split())) l = 0 r = 10**9 m = (l+r)//2+1 for i in range(100): # print(l,m,r) cnt = 0 for j in a: cnt += (j//m) # print(cnt) # print(l,m,r,cnt) if cnt <= k: r = m m = ceil((l+r)/2) else: l = m m = ceil((l+r)/2) print(m) " p02598,s965054900,Wrong Answer,"#E - Logs import math # 入力 N,K = map(int,input().split()) A = list(map(int,input().split())) Amax = int(max(A)) high = Amax Cancut = Amax low = 0 while ( (high - low) > 0.1 ) : Cut = 0 X = (high + low) / 2.0 for i in range(N): Cut = Cut + math.ceil(A[i]/X) - 1 if Cut <= K: high = X Cancut = X else: low = X # 出力 Cancut = math.floor( 10 * Cancut) /10.0 print(math.ceil(Cancut))" p02598,s483452017,Wrong Answer,"import math N, K = map(int, input().split(' ')) A = list(map(int, input(). split(' '))) for k in range(K): i = A.index(max(A)) A[i] = A[i]/2 print(math.ceil(max(A))) " p02598,s489161737,Wrong Answer,"import math N, K = list(map(int, input().split())) A = list(map(int, input().split())) def isPossible(X): global N, K, A cuts = 0 for i in range(N): cuts += math.ceil(A[i]/X) - 1 return cuts <= K minVal = 0 maxVal = max(A) while maxVal - minVal >= 0.5: if isPossible((maxVal + minVal) / 2): maxVal = (maxVal + minVal) / 2 else: minVal = (maxVal + minVal) / 2 print(math.ceil(minVal))" p02598,s291235438,Wrong Answer,"n,k=map(int,input().split()) A=list(map(int,input().split())) right=10**9 left=1 while right-left>1 : mid=(left+right)//2 count=0 for a in A : count+=a//mid if a%mid==0 : count-=1 if count<=k : right=mid else : left=mid print(right)" p02598,s996601971,Wrong Answer,"import math N,K=map(int,input().split()) import heapq A=list(map(int,input().split())) h=[(-A[i],1) for i in range(len(A))] for i in range(K): a=heapq.heappop(h) b=a[0] c=a[1] heapq.heappush(h,(c*b/(c+1),c+1)) ans=heapq.heappop(h) print(math.ceil(-ans[0]))" p02598,s587520775,Wrong Answer,"import math n,k = list(map(int,input().split())) a = list(map(int,input().split())) middle = math.ceil(max(a) / 2) oldMiddle = 0 h = middle // 2 rightMin = max(a) while h > 0: cut = 0 if middle == 0: break for i in range(n): cut += math.ceil(a[i] / middle) - 1 h = math.ceil(abs(middle - oldMiddle) / 2) oldMiddle = middle if cut <= k: if (middle - h == rightMin): break middle -= h else: rightMin = middle middle += h print(middle)" p02598,s047398292,Wrong Answer,"n,k=map(int,input().split()) a=list(map(int,input().split())) if k==0: print(max(a)) else: ans=0 d=round(max(a)*k/sum(a)) print(-(-max(a)//(d+1)))" p02598,s866731725,Wrong Answer,"import math n, k = map(int, input().split()) a = list(map(int, input().split())) l = 1 r = max(a) mid = l+math.ceil((r-l)/2) while not r-l == 1: c = 0 for x in a: c += x//mid if c > k: l = mid else: r = mid mid = l+math.ceil((r-l)/2) print(mid)" p02598,s809732274,Wrong Answer,"import math N, K = map(int,input().split()) logs = list(map(int,input().split())) a = 0 b = max(logs) b_memo = set() count=0 while math.ceil(a) != math.ceil(b): c = (a+b)/2 times = [] for i in logs: times.append(math.floor(i/c)) if sum(times) > K: a = (a+b)/2 else: b = (a+b)/2 k = len(b_memo) b_memo.add(b) if len(b_memo) == k: count +=1 if count>50: break print(math.ceil(b))" p02598,s152475384,Wrong Answer,"from heapq import heappush, heappop, heapify import math def solve(): n , k= map(int, input().strip().split()) if k >= 10*8: return 1 a= [(-int(x),1,int(x)) for x in input().strip().split()] heapify(a) for i in range(k): x,cnt,orig = heappop(a) heappush(a,(-((orig+cnt)//(cnt+1)),cnt+1,orig)) return -(heappop(a)[0]) print(solve())" p02598,s911723221,Wrong Answer,"n, k = map(int, input().split()) A = list(map(int, input().split())) if k == 0: print(max(A)) exit() ans = -(-sum(A) // (n+k)) print(ans)" p02598,s686421683,Wrong Answer,"import math n, k = map(int, input().split()) a = list(map(int, input().split())) l = 0 r = max(a) mid = math.ceil((r-l)/2) while not r-l == 1: c = 0 for x in a: c += x//mid if c > k: l = mid else: r = mid mid = l+math.ceil((r-l)/2) print(mid)" p02598,s782055470,Wrong Answer,"n, k = map(int, input().split()) a = list(map(int, input().split())) if k == 0: print(max(a)) exit() l = 1 u = max(a) while u != l+1: # print(l,u) c = (l + u) // 2 cnt = 0 for i in a: cnt = cnt + (i//c) if cnt <= k: u = c else: l = c print(u) " p02598,s932735430,Wrong Answer,"N,K = map(int,input().split()) A = list(map(int,input().split())) L = 0 R = max(A) while int(R)-int(L) > 1: X = (L+R)/2 m = 0 for i in range(N): c = A[i]/X if c == int(c): m += int(c) - 1 else: m += int(c) if m <= K: R = X else: L = X if L == int(L): print(int(L)) else: print(int(L)+1) " p02598,s461186785,Wrong Answer,"import sys input = sys.stdin.readline def main(): N,K = map(int, input().split()) A = list(map(int, input().split())) l,r = 0, max(A) while l < r-1: mid = (l+r)//2 cnt = 0 for a in A: cnt+= a//mid if cnt <= K: r = mid else: l = mid print(r) main()" p02598,s190686395,Wrong Answer,"rule=input().split() N=int(rule[0]) K=int(rule[1]) data=input().split() data_int=[int(s) for s in data] data_count=[0]*len(data) import math for i in range(K): x=data_int.index(max(data_int)) data_int[x]=math.ceil(data_int[x]*(data_count[x]+1)/(data_count[x]+2)) data_count[x]+=1 print(math.ceil(max(data_int)))" p02598,s134150885,Wrong Answer,"def f(x): now = 0 for i in range(n): now += (a[i]-1)//x return now <= k n, k = map(int, input().split()) a = list(map(int, input().split())) ng = 0 ok= 1e9 while ok - ng > 1: x = (ok + ng) // 2 if f(x): ok = x else: ng = x print(ok)" p02598,s400191277,Wrong Answer,"import math N,K = map(int,input().split()) A = list(map(int,input().split())) m = 0 M = max(A) while(M-m>0.01): mm = 0 mid = (M+m)/2 for i in range(N): mm += math.ceil(A[i]/mid)-1 if mm>K: m = mid else: M = mid print(math.ceil(mid)) " p02598,s295268927,Wrong Answer,"#E - Logs import math # 入力 N,K = map(int,input().split()) A = list(map(int,input().split())) Amax = int(max(A)) high = Amax low = 1 while ( low <= high ) : Cut = 0 X = (high + low) / 2 for i in range(N): if A[i] >= X: Cut = Cut + math.floor(A[i]/X) - 1 if Cut < K: high = X - 1 else: low = X + 1 # 出力 print(int(X)+1)" p02598,s017245576,Wrong Answer,"n, k = map(int, input().split()) a = list(map(int, input().split())) def c(x): cnt=0 for i in a: cnt += i // x return cnt <= k l, r = 0, max(a) while l + 1 < r: mid = (l + r) // 2 if c(mid): r = mid else: l = mid print(r)" p02598,s832533235,Wrong Answer,"import math N, K = map(int, input().split()) A=list(map(int,input().split())) right = 20000000000000 left = 0 while(right-left>1): mid = (left+right)//2 count = 0 for i in A: count += (i-1)//mid if count > K: left = mid else: right = mid print(mid) " p02598,s221113418,Wrong Answer,"n, k = map(int, input().split()) a = [int(x) for x in input().split()] lo = 1 hi = max(a) def ok(x): cuts = 0 for log in a: cuts += log // x if cuts <= k: return True return False while lo < hi: mid = (lo + hi) // 2 if ok(mid): hi = mid else: lo = mid + 1 print(lo) " p02598,s343061931,Wrong Answer,"f=lambda:[*map(int,input().split())] n,k=f() a=f() a=[i*100 for i in a] # Binary Search def ok(x): c=0 for i in a: c+=0--i//x return c<=n+k l,r=1,10**11+1 while r-l>1: m=l+r>>1 if ok(m): r=m else: l=m t=0--r//100 print(t-ok(max(1,t-1)))" p02598,s381806966,Wrong Answer,"N,K = map(int,input().split()) arr = list(map(int,input().split())) denominator = sum(arr) piece = [K*arr[i]//denominator+1 for i in range(N)] value = [arr[i]/piece[i] for i in range(N)] left = K+N-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))) " p02598,s386103322,Wrong Answer,"from math import floor, ceil def main(): n, k = map(int, input().split()) a = list(map(int, input().split())) a.sort() lower = 1 upper = a[-1] while upper - lower >= 0.25: 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() " p02598,s398597673,Wrong Answer,"import math N,K = map(int, input().split()) A = list(map(int, input().split())) _min = 0 _max = max(A) while int(_min) 1e-3): m = (lo + hi) / 2.0 if (can(arr, m, K)): hi = m else: lo = m ans = lo print(int(math.ceil(lo))) " p02598,s266447972,Wrong Answer,"from heapq import heappush, heappop from math import ceil, floor N, K = map(int, input().split()) A = [int(i) for i in input().split()] ng, ok = 0, 10 ** 9 for _ in range(40) : mid = (ng + ok) / 2 ret = 0 for a in A : ret += floor(a / mid) if ret <= K : ok = mid else : ng = mid print(ceil(ng))" p02598,s902543129,Wrong Answer,"n, k = map(int, input().split()) a = list(map(int, input().split())) hi = 10 ** 9 lo = 1 while hi - lo > 1: mid = (hi + lo) // 2 cnt = 0 for v in a: cnt += (v + mid - 1) // mid - 1 if cnt <= k: hi = mid else: lo = mid print(hi)" p02598,s831130177,Wrong Answer,"from math import ceil def main(): n, k = map(int, input().split()) a = list(map(int, input().split())) ok = 0 ng = 10 ** 9 + 7 while abs(ok - ng) > 0.5: mid = (ok + ng) / 2 cnt = 0 for i in range(n): cnt += ceil(a[i] / mid) - 1 if k < cnt: ok = mid else: ng = mid print(ceil(ok)) if __name__ == '__main__': main() " p02598,s285748311,Wrong Answer,"import numpy as np N, K = [int(x) for x in input().split()] A = np.array([int(x) for x in input().split()]) L = np.max(A) ans = L low = 1 high = L for i in range(L): if low == high: ans = low break mid = (low + high) // 2 if np.sum(A // mid) <= K: high = mid else: low = mid + 1 print(ans)" p02598,s488415983,Wrong Answer,"import math n, k = map(int, input().split()) aas = list(map(int, input().split())) diff = pow(10,-6) left = 1 right = 10**9 def judge(mid): cut = 0 for i in aas: cut += math.ceil(i / mid) - 1 if cut <= k: return True else: return False while left < right: mid = (left + right) / 2 if (left <= right <= left + diff) or (right <= left <= right + diff): break elif judge(mid): right = mid else: left = mid print(math.ceil(right))" p02598,s499805426,Wrong Answer,"import math n,k=map(int,input().split()) a=list(map(int,input().split())) a.sort(reverse=True) for i in range(k): t=max(a) a.insert(0,t/2) a.remove(t) print(math.ceil(max(a))) " p02598,s635141826,Wrong Answer,"import copy n,k = map(int, input().split()) a = list(map(int, input().split())) num_cut = [1]*n cut_list = copy.copy(a) for i in range(k): max_index = cut_list.index(max(cut_list)) num_cut[max_index] += 1 cut_list[max_index] = a[max_index] / num_cut[max_index] #print(""a"",a) #print(""cut_list"", cut_list) #print(""num_cut"",num_cut) print(int(max(cut_list)))" p02598,s242703331,Wrong Answer,"n,k=map(int,input().split()) a=list(map(int,input().split())) a.sort(reverse=True) from collections import deque da=deque(a) db=deque() for ii in range(k): #print(da,db,len(da),len(db)) if len(da)>0: a0=da.popleft() else: a0=db.popleft() #print(da,db) if len(db)>0 and db[0]>a0: da.append(a0) db.popleft() else: db.append(a0/2) db.append(a0/2) import math if len(da)>0: a0=da.popleft() else: a0=db.popleft() print(math.ceil(a0)) " p02598,s738204412,Wrong Answer,"#!/usr/bin/env python3 import math numbers = input().split("" "") n = int(numbers[0]) k = int(numbers[1]) numbers = input().split("" "") a1 = [int(x) for x in numbers] a2 = [[i, a1[i], 0] for i in range(n)] #a2.sort(key=lambda x: x[1]) for i in range(k): a2.sort(key=lambda x: x[1]) a2[-1][1] /= 2 a2[-1][2] += 1 a2.sort(key=lambda x: x[2]) for i in range(n): a1[i] /= (a2[i][2] + 1) a1.sort() print(math.ceil(a1[-1]))" p02598,s606934432,Wrong Answer,"N,K = [int(a) for a in input().split()] A = [int(a) for a in input().split()] m = [[]]*N c = [1]*N for i in range(N): m[i] = A[i] for i in range(K): #print(m) I = m.index(max(m)) c[I] += 1 m[I] = A[I]/c[I] print(round(max(m)))" p02598,s021630305,Wrong Answer,"import math n,k=map(int,input().split()) a=sorted(list(map(int,input().split()))) def mul(n): return n/a[0] b=list(map(mul,a)) sum=sum(b) c=[0]*n cnt=k for i in range(n): c[i]=int(k*b[i]//sum) cnt-=c[i] a[i]/=(c[i]+1) print(math.ceil(a[::-1][cnt]))" p02598,s464585798,Wrong Answer,"N,K = map(int,input().split()) A = list(map(int,input().split())) def is_ok(l): if l<=0: return False k = 0 for a in A: k += a//l if k > K: return False return True ok = 10**9+1 ng = -1 while ok - ng > 1: m = (ok+ng)//2 if is_ok(m): ok = m else: ng = m print(ok)" p02598,s412088114,Wrong Answer,"import copy n, k = map( int, input().split() ) a = list( map( int, input().split() ) ) sum_a = sum( a ) devide = [ k * a[ i ] // sum_a for i in range( n ) ] dev_len = [ a[ i ] / ( devide[ i ] + 1 ) for i in range( n ) ] k -= sum( devide ) dev_len = list( map( float, dev_len ) ) for _ in range( k ): max_i = dev_len.index( max( dev_len ) ) devide[ max_i ] += 1 dev_len[ max_i ] = a[ max_i ] / ( devide[ max_i ] + 1 ) print( int( max( dev_len ) + 0.5 ) )" p02598,s850280643,Wrong Answer,"import math N, K = list(map(int, input().split())) A = list(map(int, input().split())) values = [] for i in range(K+1): values.append([0]*N) for j in range(N): values[i][j] = A[j] / (K - i + 1) values_flatten = sum(values, []) values_flatten.sort() min_val = values_flatten[K*(N-1)] cuts = [] for j in range(N): for i in range(K+1): if values[i][j] >= min_val: cuts.append(values[i][j]) break print(math.ceil(max(cuts)))" p02598,s325231565,Wrong Answer,"n, k = map(int, input().split()) a = list(map(int, input().split())) left = 0 right = 10**10 for _ in range(100): mid = left + (right - left) / 2 count = 0 for i in range(n): count += (a[i]-10**(-10))//mid if count > k: left = mid else: right = mid print(int(left+1)) " p02598,s813151916,Wrong Answer,"n,k=map(int,input().split()) a=list(map(int,input().split())) a.sort() def counter(x): cnt=0 for i in a: cnt+=i//x if cnt<=k: return True else: return False high=a[-1] low=0 while (high-low)>1: mid =(high+low)//2 if counter(mid): high=mid else: low=mid print(high)" p02598,s926943469,Wrong Answer,"import math N, K = map(int, input().split()) A = list(map(int, input().split())) ideal = sum(A) / (N+K) max_hitsuyou = [math.floor(a/ideal) for a in A] candidate = [math.ceil(a/need) for a, need in zip(A, max_hitsuyou) if need != 0] #print(candidate) min_len = 1e10 for c in candidate: if sum(math.ceil(a/c) for a in A) == N+K: #print(c) min_len = min(min_len, c) print(min_len)" p02598,s957492084,Wrong Answer,"n, k = map(int, input().split()) a = list(map(int, input().split())) ok = max(a) ng = 1 from math import ceil def f(length): rtn = 0 for i in range(n): rtn += ceil(a[i]/length) - 1 return rtn if f(1) == 0: print(0) else: while ok - ng > 1: mid = (ok + ng)//2 if f(mid) <= k: ok = mid else: ng = mid if f(ng) > k: print(ok) else: print(ng)" p02598,s292226953,Wrong Answer,"N,K = map(int,input().split()) arr = list(map(int,input().split())) denominator = sum(arr) #piece = [K*arr[i]//denominator+1 for i in range(N)] #value = [arr[i]/piece[i] for i in range(N)] #print(piece) import copy value = copy.deepcopy(arr) piece = [1 for i in range(N)] left = K+N-sum(piece) for i in range(left): j = value.index(max(value)) piece[j] += 1 value[j] = arr[j]/piece[j] import math print(round(max(value))) " p02598,s648692922,Wrong Answer,"n, k = map(int, input().split()) a = list(map(int, input().split())) low = min(a) top = max(a) while top - low > 1: mid = (top + low) // 2 cnt = 0 for i in range(n): cnt += (a[i] + 1) // mid if cnt <= k: top = mid else: low = mid print(low)" p02598,s972781644,Wrong Answer,"#E - Logs import math # 入力 N,K = map(int,input().split()) A = list(map(int,input().split())) Amax = int(max(A)) high = Amax Cancut = Amax low = 0 while ( low < high ) : Cut = 0 X = (high + low) / 2 for i in range(N): Cut = Cut + math.ceil(A[i]/X) - 1 if Cut <= K: high = X - 0.001 Cancut = X else: low = X + 0.001 # 出力 print(math.ceil(Cancut))" p02598,s562883557,Wrong Answer,"def check(A, K, L): i = 0 for a in A: i += a//L if i > K: return False return True N, K = list(map(int, input().split())) A = list(map(int, input().split())) A.sort(reverse=True) l = 0 r = A[0] while l + 1 < r: m = (l+r)//2 if check(A, K, m): r = m else: l = m print(l+1)" p02598,s673109255,Wrong Answer,"from math import floor, ceil def main(): n, k = map(int, input().split()) a = list(map(int, input().split())) a.sort() lower = 1 upper = a[-1] + 100 while upper - lower >= 0.25: 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() " p02598,s446549280,Wrong Answer,"import math from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN n, k= map(int, input().split()) A =list(map(int, input().split())) s = sum(A) X = [] for i in A: X.append(math.ceil(k*i/s)) #x = round(k*i/s, 1) #X.append(Decimal(str(x)).quantize(Decimal('0'), rounding=ROUND_HALF_UP)) Y = [] for j in range(n): Y.append(A[j]/(X[j]+1)) print(math.ceil(max(Y))) #print(X)" p02598,s300694296,Wrong Answer,"#二分探査かぁ… from math import * import fractions import collections import itertools import pprint from collections import deque from heapq import * N,K=map(int,input().split()) A=list(map(int,input().split())) maxnum=max(A) minnum=1 while maxnum-minnum>1: cnt=0 piv=(maxnum+minnum)//2 for i in range(N): cnt=cnt+ceil(A[i]/piv)-1 #print(cnt,piv) if cnt>K: minnum=piv else: maxnum=piv #print(maxnum,minnum) #input() print(maxnum)" p02598,s112399163,Wrong Answer,"N, K = map(int, input().split()) A = [int(i) for i in input().split()] OK = 10**12 NG = 1 while OK-NG > 1: mid = (OK+NG)//2 cnt = 0 for a in A: cnt += (a-1)//mid if cnt <= K: OK = mid else: NG = mid # print('OK:{}, NG:{}, cnt:{}'.format(OK, NG, cnt)) print(OK) " p02598,s622950447,Wrong Answer,"#E - Logs import math # 入力 N,K = map(int,input().split()) A = list(map(int,input().split())) Amax = int(max(A)) high = Amax Cancut = Amax low = 0 while ( low < high ) : Cut = 0 X = (high + low) / 2.0 for i in range(N): Cut = Cut + math.ceil(A[i]/X) - 1 if Cut <= K: high = X - 0.01 Cancut = X else: low = X + 0.01 # 出力 Cancut = int( 100 * Cancut) / 100 print(math.ceil(Cancut))" p02598,s967899222,Wrong Answer,"from heapq import heappush, heappop from math import ceil, floor N, K = map(int, input().split()) A = [int(i) for i in input().split()] ng, ok = 0, 10 ** 9 for _ in range(40) : mid = (ng + ok) / 2 ret = 0 for a in A : ret += floor(a / mid) if ret <= K : ok = mid else : ng = mid print(ok, ng) print(ceil(ng))" p02598,s670115919,Wrong Answer,"n, k = map(int, input().split()) A = [*map(int, input().split())] l, r = 1, max(A)+1 # [l,r) while r - l > 1: m = (l + r) // 2 c = 0 for a in A: c += (a+m-1) // m - 1 if c <= k: r = m else: l = m print(r) " p02598,s549128185,Wrong Answer,"import math N, K = map(int, input().split()) logs = list(map(int, input().split())) longest_log = max(logs) if K == 0: print(longest_log) exit() def count_cut(log, size): return math.floor(log/size) left, right = 1, longest_log while left <= right: pivot = left + (right - left) // 2 count = sum(count_cut(log, pivot) for log in logs) if left == right: break if count > K: left = pivot + 1 elif count < K: right = pivot - 1 #right = pivot print(pivot) " p02598,s272253791,Wrong Answer,"import math n,k = map(int, input().split()) a = list(map(int, input().split())) l= 0.0 r= 1000000000.0 while(r-l>0.0001): mid = (l+r)/2 abc=1 cnt=0 for i in range(n): x = math.floor(a[i]/mid) cnt+=int(x) if(cnt>k): abc=0 if(abc==1): r=mid else: l=mid print(int(round(r)))" p02598,s777931170,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 abs(r - l) > 1: mid = (l + r) // 2 if cal(mid): r = mid else: l = mid print(r)" p02598,s399683850,Wrong Answer,"import math N, K = map(int, input().split()) A = list(map(int, input().split())) def ink(L): cnt = 0 for i in range(N): cnt += A[i]//L return cnt <= K bottom, top = 0, max(A) while(top - bottom > 1): middle = (top + bottom) // 2 if ink(middle): top = middle else: bottom = middle print(top)" p02598,s053813682,Wrong Answer,"from bisect import * from heapq import * import math mod = 10**9+7 N, K = map(int, input().split()) A = list(map(int, input().split())) ep = 0.1 l = 0.0 r = 10**9+1 while l+ep < r: x = (l+r)/2 k = 0 for a in A: k += math.ceil(a/x)-1 if k > K: break if k <= K: r = x else: l = x print(math.ceil(l))" p02598,s938569955,Wrong Answer,"from queue import PriorityQueue N, K = map(int, input().split()) A = list(map(int, input().split())) pq = PriorityQueue() for a in A: pq.put(-a) for _ in range(K): now = pq.get() # print(""取り出した値 : "", now) a, b = now/2, now/2 # print(""切り出し : "", a, b) pq.put(a) pq.put(b) print(int(-pq.get())) " p02598,s936774958,Wrong Answer,"from math import ceil n, k = map(int, input().split()) logs = list(map(int, input().split())) def is_ok(num): t = 0 for log in logs: if log <= num: continue t += ceil(log / n) - 1 return t <= k ng = 0 ok = 10 ** 9 while ok - ng > 1 : m = (ok + ng) // 2 if is_ok(m): ok = m else: ng = m print(ok)" p02598,s179746865,Wrong Answer,"from math import floor, ceil def main(): n, k = map(int, input().split()) a = list(map(int, input().split())) a.sort() lower = 1 upper = a[-1] while lower + 1 < upper: target = (lower + upper) / 2 now = 0 for i in range(n): now += floor(a[i] / target) if now > k: lower = target else: upper = target print(floor(upper) if k > 0 else a[-1]) if __name__ == '__main__': main() " p02598,s054115480,Wrong Answer,"import sys def input(): return sys.stdin.readline().strip() def main(): N,K = map(int,input().split()) A = sorted(list(map(int,input().split()))) left = 0 right = A[-1] while right - left > 1: cnt = 0 middle = (left + right) // 2 for i in A: cnt += i // middle if cnt <= K: right = middle else: left = middle print(right) if __name__ == ""__main__"": main()" p02598,s882676137,Wrong Answer,"n, k = map(int, input().split()) A = [*map(int, input().split())] l, r = 1, 10**9 + 1 # [l,r) while r - l > 1: m = (l + r) // 2 c = 0 for a in A: c += (a+m-1) // m - 1 if c <= k: r = m else: l = m print(r) " p02598,s137688301,Wrong Answer,"import math N, K = map(int, input().split()) A = list(map(float, input().split())) for i in range(K): AMax = max(A) AMaxIndex = A.index(AMax) A[AMaxIndex] = AMax/2 print(math.ceil(max(A)))" p02598,s981609247,Wrong Answer,"N, K = map(int, input().split()) L = list(map(int, input().split())) if K == 0: print(max(L)) exit() import math def is_ok(arg): count = 0 for i in range (0, N): count+=math.floor(L[i]/arg) return count <= 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, max(L)))" p02598,s026869190,Wrong Answer,"import numpy as np n, k = map(int, input().split()) a = np.array(list(map(int, input().split()))) ok = a.max() ng = 1 from math import ceil def f(length): rtn = int((np.ceil(a/length) - 1).sum()) return rtn if f(1) == 0: print(0) else: while ok - ng > 1: mid = (ok + ng)//2 if f(mid) <= k: ok = mid else: ng = mid if f(ng) > k: print(ok) else: print(ng)" p02598,s694352620,Wrong Answer,"n,k = map(int,input().split()) A = list(map(int,input().split())) A.sort() M = max(A) l,r = 1,M cnt = 0 ans = float('inf') while l<=r: cnt = 0 mid = (l+r)//2 for a in A: cnt += a//mid if cnt <=k: ans = min(ans,mid) r = mid-1 else: l = mid+1 print(ans) " p02598,s350620467,Wrong Answer,"from math import floor m=1 M=10**9+1 N,K=map(int,input().split()) A=list(map(int,input().split())) def OK(p): if sum([a//p for a in A])<=K: return True else: return False while M-m>1: p=(m+M)//2 if OK(p): M=p else: m=p print(M)" p02598,s671763172,Wrong Answer,"import math N, K = map(int, input().split()) A = list(map(int, input().split())) for i in range(1, 10**5): cnt = 0 for a in A: cnt += math.ceil(a/i) - 1 if cnt <= K: print(i) exit()" p02598,s225311217,Wrong Answer,"import heapq import math N,K = map(int, input().split()) A = map(int, input().split()) logs = [(-a,0) for a in A] heapq.heapify(logs) for _ in range(K): log, i = heapq.heappop(logs) heapq.heappush(logs, (log*(i+1)/(i+2),i+1)) print(logs) log, i = heapq.heappop(logs) print(math.ceil(-log)) " p02598,s909701617,Wrong Answer,"N,K = list(map(int,input().split())) A = list(map(int,input().split())) low=1 high=2*max(A) X=max(A) while low<=high: mid=(low+high)//2 cnt = 0 for i in range(N): cnt += A[i]//mid if K= 0.5: if isPossible((maxVal + minVal) / 2): maxVal = (maxVal + minVal) / 2 else: minVal = (maxVal + minVal) / 2 print(math.ceil(maxVal))" p02598,s452432864,Wrong Answer,"import sys import math input = sys.stdin.readline def can(arr, m, K): need = 0 for x in arr: need += int(x // m) return need <= K N, K = map(int, input().split()) arr = list(map(int, input().split())) arr = sorted(arr) ans = 0.0 if K == 0: ans = max(arr) else: lo = 0.0 hi = 1e9 while (abs(lo - hi) > 1e-5): m = (lo + hi) / 2.0 if (can(arr, m, K)): hi = m else: lo = m ans = lo print(int(math.ceil(ans))) " p02598,s164509524,Wrong Answer,"n,k=map(int,input().split()) a=list(map(int,input().split())) def case(L): result=0 for x in a: result+=x//L return result possible=0 impossible=max(a) while impossible-possible>1: M=(impossible+possible)//2 if case(M)>k: possible=M else: impossible=M print(impossible)" p02598,s655280978,Wrong Answer,"import math n, k = map(int, input().split()) a_list = list(map(int, input().split())) def nibun(l, r): if r - l < 1: return (r + l) / 2 cnt = 0 x = (r + l) / 2 for i in a_list: cnt += math.ceil(i/x) - 1 if cnt <= k: return nibun(l, x) else: return nibun(x, r) if k == 0: print(max(a_list)) else: print(math.ceil(nibun(0, max(a_list))))" p02598,s627136154,Wrong Answer,"n,k = map(int, raw_input().split()) ais = map(int, raw_input().split()) def p(m,ais,k): t = [ m, ais, k] for ai in ais: k-= ai / m return k >=0 lo,hi = 1, max(ais) #print lo,hi while(lo < hi): med = (lo + hi)/2 if p(med, ais, k): hi = med else: lo = med + 1 print lo " p02598,s479122113,Wrong Answer,"import math N, K = map(int, input().split()) A = list(map(int, input().split())) left = 0 right = max(A) while right - left > 1: mid = (left + right) // 2 jk = 0 for i in range(N): jk += A[i] / mid - 1 if A[i] % mid == 0: jk += 1 if jk <= K: right = mid else: left = mid print(right)" p02598,s689182149,Wrong Answer,"N ,K = map(int, input().split()) A = list(map(int, input().split())) d = [0] * N #二分探索 min = 1 max = max(A) while True: X = (min + max)//2 for i in range(N): d[i] = A[i]//X if sum(d) <= K: max = X else: min = X #print(min, max) if min + 1 == max: print(int(max)) break" p02598,s088395919,Wrong Answer,"from math import floor, ceil def main(): n, k = map(int, input().split()) a = list(map(int, input().split())) a.sort() lower = 1 upper = a[-1] while lower + 1 < upper: target = (lower + upper) / 2 now = 0 for i in range(n): now += floor(a[i] / target) if now > k: lower = target else: upper = target print(max(floor(upper), ceil(lower)) if k > 0 else a[-1]) if __name__ == '__main__': main() " p02598,s876845723,Wrong Answer,"def check(A, K, L): i = 0 for a in A: i += a//L if i > K: return False return True N, K = list(map(int, input().split())) A = list(map(int, input().split())) A.sort(reverse=True) l = 0 r = A[0] while l + 1 < r: m = (l+r)//2 if check(A, K, m): r = m else: l = m print(r)" p02598,s086295629,Wrong Answer,"N, K = map(int, input().split()) A = list(map(int, input().split())) def is_ok(x): cnt = 0 for a in A: cnt += a // x if cnt <= K: return True else: return False ng = 0 ok = max(A) while ok - ng > 1: mid = (ok + ng) // 2 if is_ok(mid): ok = mid else: ng = mid print(ok)" p02598,s813501784,Wrong Answer,"n,k=map(int, input().split()) a = list(map(int, input().split())) a=sorted(a,reverse=True) if k==0: print(max(a)) exit() import math lo=0 hi=10**9 oldmid=0 while True: mid=(hi+lo)/2 cnt=0 for i in range(n): cnt+=round(a[i]/mid-0.5) if cnt>k: lo=mid elif cnt<=k: hi=mid if oldmid-0.0001<=(hi+lo)/2<=oldmid+0.0001: print(min(math.ceil(lo), max(a))) break oldmid=mid" p02598,s524775949,Wrong Answer,"import math N, K = map(int, input().split()) A = list(map(int, input().split())) left = 0 right = A[0] while right - left > 1: mid = (left + right) // 2 jk = 0 for i in range(N): jk += A[i] / mid - 1 if A[i] % mid == 0: jk += 1 if jk <= K: right = mid else: left = mid print(right)" p02598,s833171012,Wrong Answer,"import math import sys sys.setrecursionlimit(10**7) n, k = map(int, input().split()) a = list(map(int, input().split())) def binary_search(left, right): if right - left <= 0.01: return right middle = (right + left) / 2 if is_can(middle): return binary_search(left, middle) else: return binary_search(middle, right) def is_can(target): count = 0 for i in range(n): count += a[i] // target return count <= k print(math.ceil(round(binary_search(0,10**10),1))) " p02598,s590097733,Wrong Answer,"N, K = map(int,input().split()) A = sorted(map(int,input().split())) start = 0 end = A[-1] l = (start + end)/2 while int(end) - start >= 1: l = (start + end)/2 count = 0 for i in range(N): q, mod = divmod(A[i], l) if mod == 0.0: q -= 1 count += q if count > K: start = l else: end = l ans = (start + end)/2 print(int(end)) " p02598,s024061520,Wrong Answer,"import math n, k = map(int, input().split()) a_list = list(map(int, input().split())) def nibun(l, r): if r - l < 1: return r cnt = 0 x = (r + l) / 2 for i in a_list: cnt += (i-1)//x if cnt <= k: return nibun(l, x) else: return nibun(x, r) if k == 0: print(max(a_list)) else: print(math.ceil(nibun(0, max(a_list))))" p02598,s775887048,Wrong Answer,"n, k = map(int, input().split()) a = list(map(int, input().split())) def check(x): c = 0 for i in range(n): c += a[i]//x if c <= k: return True else: return False mx = max(a) mn = 0 ans = [mx] while mn <= mx: m = (mx+mn)//2 if m == 0: if check(1): ans.append(1) break if check(m): mx = m - 1 ans.append(m) else: mn = m + 1 print (min(ans)) " p02598,s434706297,Wrong Answer,"from heapq import heappush, heappop, heapify import math def solve(): n , k= map(int, input().strip().split()) a= [(-int(x),1,int(x)) for x in input().strip().split()] heapify(a) for i in range(k): x,cnt,orig = heappop(a) if x < 1: return 1 heappush(a,(-((orig+cnt)//(cnt+1)),cnt+1,orig)) return -(heappop(a)[0]) print(solve())" p02598,s115915955,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"") ans = int(ans*10)/10 # ~ print(ans) print(int(ceil(ans))) " p02598,s652303100,Wrong Answer,"n, k = map(int, input().split()) a = list(map(int, input().split())) a = [x * 2 for x in a] result = max(a) left = 1 right = result med = left + (right - left) // 2 while left <= right: counter = sum([x // med for x in a]) if counter <= k: result = med right = med - 1 else: left = med + 1 med = left + (right - left) // 2 print((result + 1) // 2) " p02598,s106919541,Wrong Answer,"#E - Logs import math # 入力 N,K = map(int,input().split()) A = list(map(int,input().split())) Amax = int(max(A)) high = Amax Cancut = Amax low = 0 while ( low < high ) : Cut = 0 X = (high + low) / 2.0 for i in range(N): Cut = Cut + math.ceil(A[i]/X) - 1 if Cut <= K: high = X - 0.1 Cancut = X else: low = X + 0.1 # 出力 print(math.ceil(Cancut))" p02598,s020332466,Wrong Answer,"# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..) import sys from math import ceil def main(N, K, A): def cut_times(longest): return sum(a // longest for a in A) under = 0 r = 10**9 for i in range(100): m = (under + r) / 2 if cut_times(m) <= K: r = m else: under = m print(ceil(r - 10**-10)) if __name__ == '__main__': input = sys.stdin.readline N, K = map(int, input().split()) *A, = map(int, input().split()) main(N, K, A) " p02598,s121627531,Wrong Answer,"def is_ok(X): cnt = 0 for a in A: cnt += a//X-1 if cnt <= k: return True else: return False 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 n, k = map(int,input().split()) A = list(map(int,input().split())) print(meguru_bisect(0,max(A)+1))" p02598,s747188873,Wrong Answer,"N, K=map(int,input().split()) A=list(map(int,input().split())) def judge(ans,K,A): cut=0 for i in range(len(A)): cut+=int(A[i]/ans) if cut>K: return False else: return True ansp=10**9 ansm=1 while ansp-ansm>0.01: ans=((ansp+ansm)/2) if judge(ans,K,A): ansp=((ansp+ans)/2) else: ansm=((ans+ansm)/2) print(int(ans)+1)" p02598,s918267996,Wrong Answer,"import math import sys sys.setrecursionlimit(10**7) n, k = map(int, input().split()) a = list(map(int, input().split())) def binary_search(left, right): if right - left <= 0.01: return right middle = (right + left) / 2 if is_can(middle): return binary_search(middle, right) else: return binary_search(left, middle) def is_can(target): count = 0 for i in range(n): count += a[i] //target return count > k print(math.ceil(round(binary_search(0,10**10),2))) " p02598,s816585338,Wrong Answer,"import math N, K = map(int,input().split()) logs = list(map(int,input().split())) a = 0 b = max(logs) b_memo = set() count=0 flg =0 while math.ceil(a) != math.ceil(b): c = (a+b)/2 times = [] for i in logs: times.append(math.floor(i/c)) if sum(times) > K: a = c else: b = c if b - a < 0.001: b = round(b) break print(math.ceil(b))" p02598,s749819958,Wrong Answer,"N, K = map(int, input().split()[:2]) arr = list(map(int, input().split()[:N])) def pos(X): sum = 0 for i in arr: sum += int(i/X) if i % X == 0: sum -= 1 return sum <= K low = 0 high = 10 ** 9 mid = 0 ans = 10**9 while low <= high: mid = int((low+high)/2) # print(low, mid, high) if mid == 0 or pos(mid): ans = mid high = mid-1 else: low = mid+1 # print(pos(mid)) print(ans) " p02598,s649477888,Wrong Answer,"import sys import math input = sys.stdin.readline n, k = map(int, input().split()) a = list(map(int, input().split())) def check(x): res = 0 for i in a: if i % x == 0: res += i // x else: res += math.floor(i / x) return res l = 0 r = 10 ** 9 + 1 for _ in range(40): x = (l + r) / 2 if check(x) > k: l = x else: r = x print(math.ceil(l)) " p02598,s805063978,Wrong Answer,"import math N, K = map(int, input().split(' ')) temp = input(). split(' ') A = [] for item in temp: A.append(int(item)) for k in range(K): i = A.index(max(A)) A[i] = A[i]/2 print(math.ceil(max(A))) " p02598,s099611995,Wrong Answer,"N,K = map(int,input().split()) A = list(map(int,input().split())) L = 0 R = max(A) while R-L > 0.001: X = (L+R)/2 m = 0 for i in range(N): c = A[i]/X if c == int(c): m += int(c) - 1 else: m += int(c) if m <= K: R = X else: L = X print(int(R)+1)" p02598,s799321662,Wrong Answer,"N,K = map(int, input().split()) A = [int(a) for a in input().split()] def f(X): cnt = 0 for a in A: cnt += int(a/X) return max(1, cnt) l = 1 r = max(A) while r-l > 1: m = (r+l)//2 if f(m) <= K: r = m else: l = m if K == 0: print(max(A)) elif f(r) >= K: print(r) else: print(l)" p02598,s610288442,Wrong Answer,"import math n, k = map(int, input().split()) a = list(map(int, input().split())) l = 0 r = max(a) mid = (r-l)//2 while not r-l == 1: c = 0 for x in a: c += x//mid if c > k: l = mid else: r = mid mid = l+(r-l)//2 print(r)" p02598,s922645393,Wrong Answer,"import math n,k = map(int,input().split()) A = list(map(int,input().split())) x = max(A) y = 1 while True: if x == y: print(x) break z = (x+y)//2 lst = [math.floor(A[i]/z)-1 for i in range(n)] if sum(lst) < k: y = z else: x = z" p02598,s892781863,Wrong Answer,"from heapq import heappush, heappop, heapify import math def solve(): n , k= map(int, input().strip().split()) if k >= 10**7: return 1 a= [(-int(x),1,int(x)) for x in input().strip().split()] heapify(a) for i in range(k): x,cnt,orig = heappop(a) heappush(a,(-((orig+cnt)//(cnt+1)),cnt+1,orig)) return -(heappop(a)[0]) print(solve())" p02598,s688519478,Wrong Answer,"import math N,K = map(int, input().split()) A = list(map(int, input().split())) epsilon = 10**(-15) A = [a-epsilon for a in A] _min = 0 _max = max(A) while int(_min)= 1: if isPossible((maxVal + minVal) / 2): maxVal = (maxVal + minVal) / 2 else: minVal = (maxVal + minVal) / 2 print(math.ceil(minVal))" p02598,s846085876,Wrong Answer,"f=lambda:[*map(int,input().split())] n,k=f() a=f() # Binary Search def ok(x): c=0 for i in a: c+=0--i//x return c<=n+k l,r=0,10**9+1 while r-l>10**-2: m=(l+r)/2 if ok(m): r=m else: l=m from math import * print(ceil(l))" p02598,s219453182,Wrong Answer,"import math N, K = map(int,input().split()) A_str = input().split() A = [int(a) for a in A_str] A.sort(reverse = True) for i in range(K): A[0] /= 2. A.sort(reverse=True) min = A[0] print(math.ceil(min)) " p02598,s687818072,Wrong Answer,"from math import ceil n,k=map(int,input().split()) a=list(map(int,input().split())) if k==0: print(max(a)) exit() a.sort() left,right=0,a[n-1] mid=right while abs(right-left)>0.9: mid=(left+right)/2 temp=0 for i in range(n-1,-1,-1): if a[i]<=mid: break temp+=a[i]//mid if temp>k: left=mid else: right=mid print(ceil(mid))" p02598,s095705689,Wrong Answer,"#!/usr/bin/env python3 n, k = map(int, input().split()) a = list(map(int, input().split())) def f(p): c = 0 for x in a: c += x // p return c ok, ng = 0, max(a) + 1 while abs(ok - ng) > 1: m = (ok + ng) // 2 if f(m) > k: ok = m else: ng = m print(ok + 1) " p02598,s878058382,Wrong Answer,"N,K=map(int,input().split()) A=list(map(int, input().split())) l=0 r=max(A)+1 while not l+1==r: x=(r+l)//2 k=0 for a in A: k+=a//x if k<=K: r=x else: l=x print(r)" p02598,s119575399,Wrong Answer,"n,k=map(int,input().split()) A=list(map(int,input().split())) high=max(A) low=0 while high-low>1: cnt=0 now=(low+high)//2 for a in A: cnt+=a//now if cnt>k: break if cnt>k: low=now else: high=now #print(cnt,low,high) print(high)" p02598,s014471975,Wrong Answer,"import copy import math n, k = map(int,input().split()) a = list(map(int,input().split())) ub = 10**9 lb = 0 while ub - lb > 10**-6: x = (ub + lb) / 2 cnt = 0 for i in a: cnt += math.ceil(i/x) if cnt <= n+k: ub = copy.deepcopy(x) else: lb = copy.deepcopy(x) ans = round(ub, 2) print(math.ceil(ans))" p02598,s128514394,Wrong Answer,"n,k=map(int,input().split()) a=list(map(int,input().split())) tmax=max(a) tmin=0 import math ans=tmax if k==0: print(tmax) else: while True: t=(tmax+tmin)/2 if abs(tmax-tmin)<0.01: break s=0 for i in range(n): s=s+math.ceil(a[i]/t)-1 if k>=s: ans=min(math.ceil(t),ans) tmax=t else: tmin=t print(math.ceil(tmax))" p02598,s701619578,Wrong Answer,"import numpy as np N,K = map(int, input().split()) Logs = np.array([int(x) for x in input().split()]) cut = [1]*N chip = Logs.copy() for i in range(K): x = np.argmax(chip) cut[x]+=1 chip[x]= Logs[x]/cut[x] print(int(max(chip)))" p02598,s952445100,Wrong Answer,"import math N,K=map(int,input().split()) a=list(map(float,input().split())) lowest=0 highest=max(a) antemp=0 while True: temp=(lowest+highest)/2 for ans in a: antemp+=math.ceil(ans/temp)-1 if antempK: lowest=temp else: highest=temp if highest-lowest<0.1: print(math.ceil(temp)) exit() antemp=0 " p02598,s029758891,Wrong Answer,"import sys import heapq import math def input(): return sys.stdin.readline().rstrip() def main(): N, K = map(int, input().split()) A = list(map(int, input().split())) ng = max(A) ok = 1 while abs(ok - ng) > 1: mid = abs(ok + ng) // 2 count = 0 for i in range(N): count += math.floor(A[i] / mid) if count > K: ok = mid else: ng = mid print(ng) if __name__ == ""__main__"": main() " p02598,s962289252,Wrong Answer,"N,K = map(int,input().split()) A = list(map(int,input().split())) tmp = N+K sumA = sum(A) for i in range(1,2*10**5): if i*tmp >= sumA: print(i) exit()" p02598,s945854992,Wrong Answer,"N, K = map(int, input().split()) arr = list(map(int, input().split())) def f(x): res = 0 for i in range(N): res += arr[i]//x return res left = 1 right = max(arr) while abs(left-right) > 1: tmp = (left+right)//2 if f(tmp) > K: left = tmp else: right = tmp print(right)" p02598,s420673046,Wrong Answer,"N, K = map(int,input().split()) A = list(map(int,input().split())) import math if K != 0: ans = [""0"" for _ in range(30)] for x in range(30): ans[x] = ""1"" tmp = int("""".join(ans),2) sum_cut = sum([math.floor(a/tmp) for a in A]) if sum_cut <= K: ans[x] = ""0"" answer = int("""".join(ans),2) + 1 else: answer = len([a for a in A if a<=N]) print(answer)" p02598,s560612240,Wrong Answer,"n,k = map(int,input().split()) a = sorted(list(map(int,input().split()))) l = sum(a)//(n+k) r = a[-1] while r-l>=1: m = (r+l)/2 if sum([-(-i//m) for i in a]) > n+k: l = m else: r = m l = -int(-l//1) r = -int(-1//1) if sum([-(-i//r) for i in a]) == n+k: print(r) else: print(l)" p02598,s369498817,Wrong Answer,"# にぶたん 二分探索 n, k = map(int, input().split()) A = list(map(int, input().split())) ok = 1 ng = max(A) + 10 while abs(ok - ng) > 1: mid = (ok + ng) // 2 cnt = 0 for a in A: cnt += (a - 1) // mid if cnt > k: ok = mid else: ng = mid print(mid) " p02598,s092371051,Wrong Answer,"import sys import math input = sys.stdin.readline n, k = map(int, input().split()) a = list(map(int, input().split())) if k == 0: print(max(a)) exit() def check(x): res = 0 for i in a: res += i // x return res l = 0 r = 10 ** 9 + 1 for _ in range(40): x = (l + r) / 2 if check(x) > k: l = x else: r = x print(math.ceil(l)) " p02598,s171870965,Wrong Answer,"from math import ceil n,k = map(int,input().split()) A = list(map(int,input().split())) def flag(upper): c = 0 for a in A: c += int(a / upper) if c > k: return False return True def main(): A.sort(reverse=True) low = 1 high = A[0] while low < high: mid = (low + high) // 2 if flag(mid): high = mid else: low = mid + 1 print(high) return if __name__ == ""__main__"": main()" p02598,s046514317,Wrong Answer,"import heapq from decimal import Decimal from math import ceil n, k = map(int, input().split()) a = list(map(Decimal, input().split())) a = list(map(lambda x: - x, a)) heapq.heapify(a) for _ in range(k): tmp = heapq.heappop(a) tmp /= 2 heapq.heappush(a, tmp) print(ceil(heapq.heappop(a)*-1)) " p02598,s718509816,Wrong Answer,"import math N, K = map(int, input().split()) As = list(map(int, input().split())) def cut_num(a, cut_length): if a % cut_length == 0: return (a // cut_length) - 1 else: return a // cut_length """"""binary search """""" l = 0 r = 10e9 while r-l > 1: n = (l+r)/2 current_cut = sum([cut_num(a, n) for a in As]) if current_cut > K: l = n else: r = n print(math.ceil(l))" p02598,s897320893,Wrong Answer,"n, k = map(int, input().split()) A = [*map(int, input().split())] l, r = 0, max(A) # (l,r] while r - l > 1: m = (l + r) // 2 c = 0 for a in A: c += a // m if c <= k: r = m else: l = m print(r) " p02598,s238996771,Wrong Answer,"import heapq from math import ceil N,K = list(map(int,input().split())) A = list(map(lambda x: -int(x),input().split())) heaplist = [] for Ai in A: heapq.heappush(heaplist,(Ai,1,Ai)) if 5*10**7 < K: print(1) else: for i in range(K): m = heapq.heappop(heaplist) heapq.heappush(heaplist,(m[2]/(m[1]+1),m[1]+1,m[2])) # print(A) print(ceil(-heapq.heappop(heaplist)[0]))" p02598,s477857168,Wrong Answer,"## coding: UTF-8 import bisect N, K = map(int,input().split()) A = list(map(int,input().split())) A = sorted(A) #print(A) l = [] for i in range(N): l.append([A[i], A[i], 1]) #print(l) for i in range(K): tmp = l.pop() tmp[2] += 1 tmp[0] = float(tmp[1] / tmp[2]) bisect.insort(l, tmp) #print(l) ans = l[-1][0] #print(ans) if((ans - ans // 1) >= 0.5): print(int(ans//1+1)) else: print(int(ans//1)) " p02598,s762051168,Wrong Answer,"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 ,A)) if sum(temp) <= K: hi = mid else: lo = mid temp = list(map(lambda x: x//lo ,A)) if sum(temp) <= K: print(lo) else: print(hi)" p02598,s088011718,Wrong Answer,"n,k=map(int,input().split()) a=list(map(int,input().split())) tmax=max(a) tmin=0 t=(tmax+tmin)/2 import math ans=0 if k==0: print(tmax) else: while True: s=0 for i in range(n): s=s+math.ceil(a[i]/t)-1 if k>=s: ans=t tmax=t t=(tmin+t)/2 else: tmin=t t=(t+tmax)/2 if tmax-tmin<0.1: break print(math.ceil(ans))" p02598,s423374304,Wrong Answer,"n,k=map(int,input().split()) a=list(map(int,input().split())) l=0 r=1e9+5 while l+1!=r: m = (l+r)//2 cnt = 0 for x in a: cnt += (x-1)//m if cnt <= k: r = m else: l = m print(r)" p02598,s350692593,Wrong Answer,"import math import sys sys.setrecursionlimit(10**7) n, k = map(int, input().split()) a = list(map(int, input().split())) def binary_search(left, right): if right - left <= 0.1: return right middle = (right + left) / 2 if is_can(middle): return binary_search(middle, right) else: return binary_search(left, middle) def is_can(target): count = 0 for i in range(n): count += a[i] //target return count > k print(math.ceil(round(binary_search(0,10**10),1))) " p02598,s564272531,Wrong Answer,"import math N, K = map(int, input().split()) As = list(map(int, input().split())) def cut_num(a, cut_length): return math.ceil(a/cut_length) - 1 """"""cut length N binary search if cut num > K, search more longer cut length, """""" l = 1 r = max(As) ans = r while r-l > 1: m = (l+r)/2 current_cut_num = sum([cut_num(a, m) for a in As]) if current_cut_num <= K: ans = min(ans, m) r = m else: l = m print(int(ans))" p02598,s332498622,Wrong Answer,"import sys input = sys.stdin.readline def main(): N,K = map(int, input().split()) A = list(map(int, input().split())) l,r = 0, max(A) while l < r-1: mid = (l+r)//2 cnt = 0 for a in A: cnt+= a//mid if cnt <= K: r = mid else: l = mid print(r) main()" p02598,s499095521,Wrong Answer,"import bisect import math N,K = map(int, input().split()) A = [[i,0] for i in sorted(map(int, input().split()))] for j in range(K): y = A.pop() z = y[0]*(y[1]+1)/(y[1]+2) zz = y[1]+1 bisect.insort(A,[z,zz]) print(A) print(math.ceil(A[-1][0]))" p02598,s333011059,Wrong Answer,"from math import ceil N,K=map(int,input().split()) *A,=map(int,input().split()) def C(x): return sum([(A[i]-1)//x for i in range(N)]) <= K def binary_search2(func, n_min, n_max): left,right=n_min,n_max while right-left>1: middle = (left+right)//2 y_middle = func(middle) if y_middle: right=middle else: left=middle return right print(binary_search2(C, 1, max(A)))" p02598,s747274719,Wrong Answer,"import numpy as np N,K = map(int, input().split()) Logs = np.array([int(x) for x in input().split()]) cut = [1]*N chip = Logs for i in range(K): x = np.argmax(Logs) cut[x]+=1 chip[x]= Logs[x]/cut[x] print(int(max(chip))) " p02598,s797088646,Wrong Answer,"# E - Logs import sys sys.setrecursionlimit(1000000) N,K = map(int,input().split()) A = list(map(int,input().split())) def rec(l,r): global N,K,A if l==r: return l tmp = (l+r)//2 ans = 0 for i in range(N): ans += A[i]//tmp if ans<=K: return rec(l,tmp) else: return rec(tmp+1,r) print(rec(1,max(A)))" p02598,s219645076,Wrong Answer,"n,k = list(map(int,input().split())) f = list(map(int,input().split())) s = (10**9) // 2 step = s best= 999999999999 import math for j in range(50): c = 0 arr = list(f) for i in range(n): c += arr[i] // s arr[i] /= (c+1) step = step//2 step = max(1, step) if c<=k: s -= step best = min(best,math.ceil(max(arr))) else: s += step if s==0: s=1 print(best)" p02598,s967390236,Wrong Answer,"N, K = map(int, input().split()) A = sorted(list(map(int, input().split()))) def check(L): return sum(a // L for a in A) <= K answer=max(A) lo = 1 hi = answer+1 while lo < hi: m = (lo + hi)//2 ok = check(m) if ok: # answer=m hi=m else: lo=m+1 for l in range(max(1, answer-10),answer+1): if check(l): answer = l print(min(max(A), answer)) " p02601,s160162601,Accepted,"A,B,C = map(int, input().split()) K = int(input()) ctr = 0 while B <= A: B *= 2 ctr += 1 while C <= B: C *= 2 ctr += 1 print('Yes' if K >= ctr else 'No') " p02601,s555290988,Accepted,"a, b, c = map(int, input().split()) k = int(input()) if b > a: multiplier = 2 ** k if c * multiplier > b: ans = 'Yes' else: ans = 'No' else: while b <= a: b *= 2 k -= 1 multiplier = 2 ** k if c * multiplier > b: ans = 'Yes' else: ans = 'No' print(ans) " p02601,s674204059,Accepted,"A, B, C = map(int, input().split(' ')) K = int(input()) while K > 0: if B > A: break B *= 2 K -= 1 while K > 0: if C > B: break C *= 2 K -= 1 if A < B < C: print('Yes') else: print('No') " p02601,s215418098,Accepted,"def s(): return input() def i(): return int(input()) def S(): return input().split() def I(): return map(int,input().split()) def X(): return list(input()) def L(): return list(input().split()) def l(): return list(map(int,input().split())) count = 0 ans = ""No"" A,B,C = I() K = i() while True: if B > A or K == 0: break else: B *= 2 K -= 1 while True: if C > B or K == 0: break else: C *= 2 K -= 1 if A < B and B < C: ans = ""Yes"" print(ans) " p02601,s402172266,Accepted,"a,b,c = map(int, input().split()) k = int(input()) key = 0 for i in range(0,k+1): if i == 0: cc = c else: cc = c*(2**i) if k-i == 0: bb = b else: bb = b*(2**(k-i)) if cc > bb and bb > a: key = 1 break if key == 1: print(""Yes"") else: print(""No"")" p02601,s048988083,Accepted,"import sys import math import collections import decimal import itertools from collections import deque from functools import reduce import heapq import copy #x = int(input()) a, b, c = map(int, sys.stdin.readline().split()) #s = input() #a = list(map(int, sys.stdin.readline().split())) k = int(input()) d = 0 while (True): if b > a: break else: b *= 2 d += 1 while (True): if c > b: break else: c *= 2 d += 1 if d <= k: print(""Yes"") else: print(""No"") " p02601,s413702048,Accepted,"[A, B, C] = [int(i) for i in input().split()] K = int(input()) def cal(): global A, B, C, K count = 0 while A >= B: B *= 2 count += 1 if K < count: return ""No"" while B >= C: C *= 2 count += 1 if K < count: return ""No"" return ""Yes"" print(cal()) " p02601,s568599545,Accepted,"A,B,C = map(int, input().split()) K = int(input()) AA = A BB = B CC = C count = 0 for i in range(K): if AA < BB < CC: print(""Yes"") break elif CC <= AA or CC <= BB: CC *= 2 count +=1 elif BB <= AA: BB *= 2 count +=1 if count == K: if AA < BB < CC: print(""Yes"") else: print(""No"")" p02601,s768053330,Accepted,"A,B,C = map(int,input().split()) K = int(input()) cnt = 0 for _ in range(K): if A>=B: B *= 2 cnt += 1 else: break for _ in range(K-cnt): if B>=C: C *= 2 else: break #print(cnt) if (A= b: b *=2 continue elif b >= c: c *= 2 else: c *= 2 if a < b and b < c: print('Yes') else: print('No') " p02601,s526032363,Accepted,"import sys def Ss(): return sys.stdin.readline().rstrip().split(' ') def Is(): ss = Ss() return map(int, ss) if len(ss) > 1 else int(ss[0]) a, b, c = Is() k = Is() while b <= a: b = b * 2 k = k - 1 while c <= b: c = c * 2 k = k - 1 print('Yes' if k >= 0 else 'No')" p02601,s508551390,Accepted,"a, b, c = map(int, input().split()) k = int(input()) ans = 'Yes' while a >= b: b *= 2 k -= 1 while b >= c: c *= 2 k -= 1 if k < 0: ans = 'No' print(ans)" p02601,s158071499,Accepted,"r, g , b = map(int, input().split()) k = int(input()) while(g <= r): g *= 2 k -= 1 while(b <= g): b *= 2 k -= 1 if k >= 0: print(""Yes"") else: print(""No"")" p02601,s435321299,Accepted,"import itertools A,B,C = list(map(int, input().split())) K = int(input()) ans = False for p in itertools.product(['a','b','c'], repeat=K): A0,B0,C0 = A,B,C for e in p: if e == 'a': A0 = 2*A0 elif e == 'b': B0 = 2*B0 else: C0 = 2*C0 if A0 < B0 < C0 : ans = True break print('Yes' if ans else 'No') " p02601,s626749291,Accepted,"a,b,c=map(int,input().split()) k=int(input()) cnt=0 while a>=b: b*=2 cnt+=1 while b>=c: c*=2 cnt+=1 if cnt<=k: print('Yes') else: print('No')" p02601,s822991726,Accepted,"a, b, c = list(map(int, input().split())) k = int(input()) ans = False for i in range(k): if c <= b: c *= 2 elif b <= a: b *= 2 else: ans = True break if c > b and b > a: ans = True if ans: print(""Yes"") else: print(""No"")" p02601,s356509910,Accepted,"a, b, c = map(int, input().split()) k = int(input()) while k: if a >= b: b *= 2 else: break k -= 1 while k: if b >= c: c *= 2 else: break k -= 1 if a < b and b < c: print(""Yes"") else: print(""No"")" p02601,s522737119,Accepted,"a,b,c=map(int,input().split()) k=int(input()) d={""a"":a,""b"":b,""c"":c} for i in range(k+1): if d[""a""]=d[""c""]: d[""c""]*=2 elif d[""a""]>=d[""b""]: d[""b""]*=2 elif d[""b""]>=d[""c""]: d[""c""]*=2 print(""No"")" p02601,s358672382,Accepted,"r, g, b = map(int, input().split()) k = int(input()) def dfs(i , r, g, b): if i > k: return False if r < g < b: return True if dfs(i+1, r*2, g, b ): return True if dfs(i+1, r, g*2, b ): return True if dfs(i+1, r, g, b*2): return True return False print('Yes' if dfs(0, r, g, b) else 'No') " p02601,s630645658,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 if a < b and b < c: print('Yes') else: print('No')" 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') " 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') " p02601,s515924370,Accepted,"input_ = input() a = int(input_.split(' ')[0]) b = int(input_.split(' ')[1]) c = int(input_.split(' ')[2]) k = int(input()) count = 0 ans = ""No"" while count < k: if a >= b: b *= 2 count += 1 elif b >= c: c *= 2 count += 1 if a < b and b < c: ans = ""Yes"" break print(ans) " p02601,s050508249,Accepted,"A, B, C = map(int, input().split()) K = int(input()) while B <= A: B *= 2 K -= 1 while C <= B: C *= 2 K -= 1 if K >= 0: print(""Yes"") else: print(""No"")" p02601,s390451489,Accepted,"def main(): A, B, C = map(int, input().split()) K = int(input()) while B <= A: B *= 2 K -= 1 while C <= B: C *= 2 K -= 1 if K >= 0: print(""Yes"") else: print(""No"") if __name__ == ""__main__"": main() " p02601,s435024065,Accepted,"A,B,C = map(int, input().split()) K = int(input()) cnt = 0 for i in range(100): if A >= B: B *= 2 cnt += 1 continue if B >= C: C *= 2 cnt += 1 continue if cnt <= K: print(""Yes"") else: print(""No"")" p02601,s099740483,Accepted,"#from collections import deque,defaultdict printn = lambda x: print(x,end='') inn = lambda : int(input()) inl = lambda: list(map(int, input().split())) inm = lambda: map(int, input().split()) ins = lambda : input().strip() DBG = True # and False BIG = 10**18 R = 10**9 + 7 #R = 998244353 def ddprint(x): if DBG: print(x) a,b,c = inm() k = inn() x = 0 while b<=a: b *= 2 x += 1 while c<=b: c *= 2 x += 1 print('Yes' if x<=k else 'No') " p02601,s574481493,Accepted,"A, B, C = map(int, input().split()) K = int(input()) for _ in range(K): if A >= B: B *= 2 else: C *= 2 print(""Yes"" if A < B < C else ""No"")" p02601,s676716711,Accepted,"A, B, C = map(int, input().split()) K = int(input()) b = 0 while (b <= K and A >= 2**b * B): b += 1 if 2**b * B < 2**(K-b) * C: print(""Yes"") else: print(""No"") " p02601,s367960843,Accepted,"A,B,C = map(int, input().split()) K = int(input()) while A>=B: B *= 2 K -= 1 while B>=C: C *= 2 K -= 1 if K < 0: print(""No"") else: print(""Yes"")" p02601,s342917510,Accepted,"A, B, C = [int(s) for s in input().split()] K = int(input()) i = 0 while B <= A: B = 2 * B i += 1 j = 0 while C <= B: C = 2 * C j += 1 if i + j <= K: print('Yes') else: print('No')" p02601,s279955722,Accepted,"li = list(map(int,input().split())) k=int(input()) cnt=0 while li[0]>=li[1]: li[1]*=2 cnt+=1 while li[1]>=li[2]: li[2]=2*li[2] cnt+=1 if cnt<=k: print(""Yes"") elif cnt>k: print(""No"")" p02601,s903479375,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 if aK: print(""No"") else: print(""Yes"")" p02601,s650486777,Accepted,"a, b, c = map(int, input().split()) k = int(input()) for i in range(k): if a >= b: b *= 2 elif b >= c: c *= 2 else: c *= 2 if a < b and b < c: print(""Yes"") else: print(""No"")" p02601,s868535271,Accepted,"a,b,c = map(int, input().split()) k =int(input()) cnt = 0 while b<=a: cnt += 1 b *= 2 while c <= b: cnt += 1 c *= 2 if cnt <= k: print(""Yes"") else: print(""No"")" p02601,s036276347,Accepted,"a, b, c = map(int, input().split()) K = int(input()) k = 0 while a >= b: b *= 2 k += 1 while b >= c: c *= 2 k += 1 if k<=K: print(""Yes"") else: print(""No"")" p02601,s592747670,Accepted,"a,b,c=map(int,input().split()) k=int(input()) while a>=b: b*=2 k-=1 while b>=c: c*=2 k-=1 print([""No"",""Yes""][k>=0])" p02601,s265244509,Accepted,"a,b,c = list(map(int, input().split())) k = int(input()) c1=0 while(1): if a 0: if A >= B: B *= 2 elif B >= C: C *= 2 K -= 1 if A < B < C: print('Yes') else: print('No') " p02601,s653173318,Accepted,"import sys a, b, c = map(int,input().split()) k = int(input()) for i in reversed(range(1,k+1)): ck = c * (2 ** i) bk = b * (2 ** (k-i)) ak = a * ((2 ** (k - i - (k - i)))) if ck > bk > ak: print('Yes') sys.exit() print('No')" p02601,s362860567,Accepted,"#!/usr/bin/env python a, b, c = map(int, input().split()) k = int(input()) while k>=0: if a>=b: b *= 2 elif b>=c: c *= 2 else: print('Yes') exit(0) k -= 1 print('No') " p02601,s657181222,Accepted,"a = list(map(int, input().split())) num = int(input()) k = 0 for i in range(num): #num回2倍を繰り返す。でなければNoをprint if a[0] == max(a) or a[1] == max(a): #リストaの中のmaxよりも青が小さいならば青を二倍する a[2] = a[2] * 2 k += 1 elif a[1] == min(a) and k < num: a[1] = a[1] * 2 k += 1 else: pass if a[0] < a[1] and a[1] < a[2]: print(""Yes"") else: print(""No"") " p02601,s914806954,Accepted,"a, b, c = map(int, input().split()) k = int(input()) for cnt in range(k): if a < b and b < c: break elif a >= b: b = int(b * 2) continue elif b >= c: c = int(c * 2) continue if a < b < c: print('Yes') else: print('No') " p02601,s788924624,Accepted,"a,b,c = map(int, input().split()) k = int(input()) while not (a=b : b*=2 k-=1 if b>=c : c*=2 k-=1 if(k<0): print(""No"") else: print(""Yes"")" p02601,s167648691,Accepted,"a, b, c = map(int, input().split()) k = int(input()) cnt = 0 while b <= a: cnt += 1 b *= 2 while c <= b: cnt += 1 c *= 2 if cnt <= k: print('Yes') else: print('No') " p02601,s961739469,Accepted,"A,B,C = map(int,input().split()) K = int(input()) for i in range(0,K+1): for j in range(0,K+1): for h in range(0,K+1): if A*(2**i)= b: b = b*2 elif b >= c: c = c*2 if a < b and b < c: print('Yes') break else: print('No') " 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"") " p02601,s397215694,Accepted,"A, B, C = map(int, input().split()) K = int(input()) n = 0 while A >= B : B *= 2 n += 1 while B >= C : C *= 2 n += 1 if n <= K : print(""Yes"") else : print(""No"")" 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"")" p02601,s631046977,Accepted,"red,green,blue = list(map(int,input().split())) K = int(input()) while red >= green and K > 0: green = green * 2 K -= 1 while green >= blue and K > 0: blue = blue * 2 K -= 1 if red < green and blue > green: print(""Yes"") else: print(""No"")" p02601,s836797946,Accepted,"import itertools x=list(map(int,input().split())) k=int(input()) L=list(itertools.combinations_with_replacement([0,1,2],k)) for l in L: X=x.copy() for i in l: X[i] = X[i]*2 if X[0]= b or b >= c: print('No') else: print('Yes')" 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=B: B*=2 K-=1 while B>=C: C*=2 K-=1 if K>=0: print(""Yes"") else: print(""No"")" p02601,s782814410,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 < b and b < c: print(""Yes"") else: print(""No"")" p02601,s563409102,Accepted,"a,b,c = map(int,input().split()) k = int(input()) count = 0 while a>=b: count+=1;b*=2 while b>=c: count+=1;c*=2 print(['No','Yes'][count<=k])" 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=B: B*=2 K-=1 while B>=C: C*=2 K-=1 if K>=0: print('Yes') else: print('No') " p02601,s174668288,Accepted,"import sys input = lambda: sys.stdin.readline().rstrip() def main(): a, b, c = map(int, input().split()) k = int(input()) for _ in range(k): if a >= b: b *= 2 elif b >= c: c *= 2 if a < b and b < c: print('Yes') else: print('No') if __name__ == '__main__': main()" p02601,s493477204,Accepted,"A, B, C = map(int, input().split()) K = int(input()) counter = 0 while A >= B: B *= 2 counter += 1 while B >= C: C *= 2 counter += 1 print('Yes' if counter <= K else 'No')" p02601,s600928457,Accepted,"#X = int(input()) #S = str(input()) A, B, C = map(int, input().split()) #C = list(map(int, input().split())) ans = 0 while A >= B: B *= 2 ans += 1 #print(A, B, C, ans) while B >= C: C *= 2 ans += 1 K = int(input()) #print(ans) if ans <= K: print(""Yes"") else: print(""No"") " p02601,s567871342,Accepted,"a, b, c = map(int, input().split()) k = int(input()) while b <= a and k > 0: b *= 2 k -= 1 while c <= b and k > 0: c *= 2 k -= 1 if a < b < c: print('Yes') else: print('No')" p02601,s970774989,Accepted,"red, green, blue = map(int, input().split()) k = int(input()) cnt = 0 while red >= green: green *= 2 cnt += 1 while green >= blue: blue *= 2 cnt += 1 if cnt <= k: print('Yes') else: print('No')" p02601,s088790033,Accepted,"a, b, c = map(int, input().split()) k = int(input()) ans = False for x in range(k + 1): for y in range(k - x + 1): for z in range(k - x - y + 1): if a * (2 ** x) < b * (2 ** y) < c * (2 ** z): ans = True break print('Yes') if ans else print('No') " p02601,s024772484,Accepted,"A, B, C = map(int, input().split()) K = int(input()) count = 0 while B <= A: B *= 2 count += 1 while C <= B: C *= 2 count += 1 print(""Yes"" if count <= K else ""No"") " p02601,s238494896,Accepted,"a,b,c = map(int, input().split()) k = int(input()) x = 0 while b <= a: b *= 2 x += 1 while c <= b: c *= 2 x += 1 if x <= k: print('Yes') else: print('No')" p02601,s960645677,Accepted,"import sys sys.setrecursionlimit(10**6) a,b,c = map(int, input().split()) k = int(input()) m = [[] for _ in range(8)] m[0].append([a,b,c]) for i in range(k): for j in m[i]: m[i+1].append([j[0]*2, j[1],j[2]]) m[i+1].append([j[0], j[1]* 2, j[2]]) m[i+1].append([j[0], j[1], j[2]* 2]) ans = 'No' for t in m[k]: if t[0] < t[1] and t[1] < t[2]: ans = 'Yes' break print(ans)" p02601,s294307637,Accepted,"a, b, c = map(int, input().split()) k = int(input()) def predicate_green(): return b > a def predicate_blue(): return c > b while k != 0: if not predicate_green(): b *= 2 k -= 1 elif not predicate_blue(): c *= 2 k -= 1 else: break if c > b > a: print('Yes') else: print('No')" p02601,s395713631,Accepted,"A,B,C = map(int,input().split()) K = int(input()) # a < b < c c = 0 while A >= B: B *= 2 c += 1 while B >= C: C *= 2 c += 1 print('Yes' if c <= K else 'No')" 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 A= B: B *= 2 continue if B >= C: C *= 2 continue if A < B and B < C: print('Yes') else: print('No')" p02601,s128027523,Accepted,"a,b,c = map(int, input().split()) k = int(input()) for i in range(k): if b<=a: b*=2 elif c<=b: c*=2 if c>b and b>a: print(""Yes"") else: print(""No"") " p02601,s597504833,Accepted,"a, b, c = map(int, input().split()) k = int(input()) count = 0 while a >= b: b *= 2 count += 1 while b >= c: c *= 2 count += 1 if count <= k: print(""Yes"") else: print(""No"") " p02601,s061834051,Accepted,"a,b,c = map(int,input().split()) k = int(input()) cnt = 0 while a >= b: cnt += 1 b *= 2 while b >= c: cnt += 1 c *= 2 if cnt <= k: print(""Yes"") else: print(""No"")" p02601,s404238934,Accepted,"# vim: fileencoding=utf-8 def main(): red, green, blue = map(int, input().split()) k = int(input()) res = ""No"" for i in range(k): if blue <= green or blue <= red: blue *= 2 elif green <= red: green *= 2 if blue > green and green > red: res = ""Yes"" break print(res) if __name__ == ""__main__"": main() " p02601,s345409896,Accepted,"A, B, C = map(int, input().split()) K = int(input()) tmp = K for i in range(K): if A < B: tmp = i break B = B * 2 if B < C: print('Yes') elif B < C * (2 ** (K - tmp)): print('Yes') else: print('No') " p02601,s981296494,Accepted,"import sys input = sys.stdin.readline a, b, c = map(int, input().split()) k = int(input()) def two(num): for i in range(1,8): if (2**(i-1)<=num) & (num<2**(i)): return i return 0 ab = two(a/b) b_ = b*2**ab b_c = two(b_/c) if k>=(ab+b_c): print(""Yes"") else: print(""No"") " p02601,s435656762,Accepted,"A, B, C = map(int, input().split()) K = int(input()) ans = ""No"" def f(a, b, c, cnt, k): global ans if cnt > k: return if b > a and c > b: ans = ""Yes"" return f(2*a, b, c, cnt+1, k) f(a, 2*b, c, cnt+1, k) f(a, b, 2*c, cnt+1, k) f(A, B, C, 0, K) print(ans)" p02601,s626243253,Accepted,"def main(): A,B,C=map(int,input().split()) K=int(input()) for _ in range(K): if not A= b: b *= 2 k -= 1 while b >= c: c *= 2 k -= 1 if k >= 0: print('Yes') else: print('No')" p02601,s178934040,Accepted,"# coding: utf-8 import math import numpy #N = int(input()) a, b, c = map(int,input().split()) #A = list(map(int,input().split())) K =int(input()) flg = False i = 0 while a >= b: if i == K: break b *= 2 i += 1 #print(i,a,b,c) while b >= c: if i == K: break c *= 2 i += 1 #print(a,b,c) #print(a, b, c) if a < b < c: print(""Yes"") else: print(""No"")" p02601,s951629494,Accepted,"import sys input = sys.stdin.readline a,b,c = map(int,input().split()) k = int(input()) while a >= b: b *= 2 k -= 1 if k < 0: print(""No"") else: for i in range(k): c *= 2 if b < c: print(""Yes"") else: print(""No"")" p02601,s552739258,Accepted,"a,b,c = map(int, input().split()) k = int(input()) for _ in range(k): if c <= b or c <= a: c*=2 elif b <= a: b*=2 if a < b and b < c: print('Yes') break else: print('No')" p02601,s987106894,Accepted,"A,B,C = map(int,input().split()) K = int(input()) ans = 0 while B<=A: ans += 1 B *= 2 while C<=B: ans += 1 C *= 2 print(""Yes"" if ans <= K else ""No"") " 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= B: B *= 2 c += 1 while B >= C: C *= 2 c += 1 print(""Yes"" if c<=K else ""No"")" p02601,s342034661,Accepted,"a,b,c = map(int, input().split()) k = int(input()) while(a >= b and k >0 ): b = b*2 k -= 1 c = c*2**(k) #print(a,b,c) if (a=0 else ""No"")" p02601,s573042987,Accepted,"A, B, C = map(int, input().split()) K = int(input()) for _ in range(K): if A >= B: B *= 2 else: C *= 2 if A < B < C: print('Yes') else: print('No')" p02601,s525424615,Accepted,"import sys readline = sys.stdin.readline def solve(): A, B, C = map(int, readline().split()) K = int(readline()) count = 0 while B <= A: B *= 2 count += 1 while C <= B: C *= 2 count += 1 if count > K: print('No') else: print('Yes') solve()" p02601,s568707493,Accepted,"A, B, C = map(int, input().split()) K = int(input()) i = 0 # BがAより大きくなるために必要な回数 while(B<=A): i += 1 B *= 2 # CがBより大きくなるために必要な回数 while(C<=B): i += 1 C *= 2 if i <=K: print(""Yes"") else: print(""No"") " p02601,s695049566,Accepted,"A, B, C = input().split() A = int(A) B = int(B) C = int(C) K = input() K = int(K) z = 0 while B <= A: B = B * 2 z = z + 1 while C <= B: C = C * 2 z = z + 1 if K < z: print('No') else: print('Yes')" p02601,s813096603,Accepted,"A, B, C = [int(n) for n in input().split()] K = int(input()) ans = 'No' for i in range(K+1): for j in range(K+1): if A < B< mi > aka: print(""Yes"") else: print(""No"")" p02601,s062768144,Accepted,"def main(): a, b, c = map(int, input().split()) k = int(input()) f = False cnt = 0 while b <= a: b *= 2 cnt += 1 while c <= b: c *= 2 cnt += 1 if cnt <= k: print(""Yes"") else: print(""No"") if __name__ == ""__main__"": main()" p02601,s075577724,Accepted,"a, b, c = map(int, input().split()) k = int(input()) ans = 0 while a >= b: ans += 1 b *= 2 while b >= c: ans += 1 c *= 2 print(""Yes"" if ans <= k else ""No"")" 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"")" p02601,s714128030,Accepted,"import itertools A,B,C=map(int,input().split()) K=int(input()) l=[0,1,2,3,4,5,6,7] for c in itertools.product(l, repeat=3): if sum(c) == K and A*2**c[0]A: break for i in range(K-count): if C<=B: C = C*2 if C>B: print(""Yes"") break if A>=B: print(""No"") elif B>=C: print(""No"")" 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')" p02601,s295133483,Accepted,"a,b,c=map(int,input().split()) K=int(input()) # B > A # C > B import sys for i in range(K+1): A=a B=b*(2**i) C=c*(2**(K-i)) #print(i,K-i,A,B,C) if B>A and C>B: print('Yes') sys.exit() else: print('No')" p02601,s881340463,Accepted,"import sys a, b, c=map(int, input().split()) k=int(input()) while(k>=1 and a>=b): b=b*2 k=k-1 if a>=b: print(""No"") sys.exit() while(k>=1 and b>=c): c=c*2 k=k-1 if b>=c: print(""No"") else: print(""Yes"") " p02601,s956438685,Accepted,"A, B, C = map(int, input().split()) K = int(input()) cnt = 0 if A >= B: while A >= B: B *= 2 cnt += 1 if B >= C: while B >= C: C *= 2 cnt += 1 if cnt <= K: print('Yes') else: print('No')" 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() " p02601,s286462618,Accepted,"a,b,c=map(int,input().split()) k=int(input()) ans=False for i in range(0,k+1): for j in range(0,k+1): if(i+j>k): continue if(a*2**i= B: B *= 2 elif B >= C: C *= 2 if A < B < C: print('Yes') exit() print('No')" p02601,s812569609,Accepted,"a,b,c=map(int,input().split()) k=int(input()) while a>=b and k>0: b*=2 k-=1 while b>=c and k>0: c*=2 k-=1 if a= b: b *= 2 t += 1 while b >= c: c *= 2 t += 1 if k >= t: print('Yes') else: print('No') " p02601,s063649709,Accepted,"s = input().split() A = int(s[0]) B = int(s[1]) C = int(s[2]) K = int(input()) for i in range(K): if A >= B: B *= 2 elif B >= C: C *= 2 else: break b = A < B < C print('Yes' if b else 'No') " p02601,s674436293,Accepted,"a,b,c = map(int,input().split()) k = int(input()) for _ in range(k): if b <= a: b*=2 elif c <= b: c*=2 if c > b > a: print('Yes') else: print('No')" p02601,s231802617,Accepted,"a,b,c = map(int,input().split()) k = int(input()) p = 0 while a >= b: b *= 2 p += 1 while b >= c: c *= 2 p += 1 if p <= k: print(""Yes"") else: print(""No"") " p02601,s329604826,Accepted,"a,b,c = map(int,input().split()) k = int(input()) for _ in range(k): if c<=b or c<=a: c*=2 elif b<=a: b*=2 else: c*=2 print(""Yes"" if c>b and b>a else ""No"")" p02601,s287587709,Accepted,"A,B,C=map(int,input().split()) K=int(input()) count=0 if B<=A: while B<=A: B*=2 count+=1 if count>K: print('No') else: C*=2**(K-count) if C>B: print('Yes') else: print('No')" p02601,s347765047,Accepted,"a,b,c=map(int, input().split()) d=int(input()) ans=""No"" k=0 for i in range(d+1): b2=b*(2**(d-k)) c2=c*(2**(k)) if(a= 0 print(""Yes"" if solve(a, b, c, k) else ""No"") " 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"")" p02601,s734371361,Accepted,"a, b, c = map(int, input().split()) k = int(input()) cnt = 0 while b <= a: cnt += 1 b *= 2 while c <= b: cnt += 1 c *= 2 print(""Yes"" if cnt <= k else ""No"") " p02601,s347629681,Accepted,"a, b, c = map(int, input().split()) k = int(input()) x = 0 while a >= b: b *= 2 x += 1 while b >= c: c *= 2 x += 1 if x <= k: print('Yes') else: print('No') " p02601,s829050944,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()] a,b,c = ip() k = inp() ct = 0 while b <= a: b *= 2 ct += 1 while c <= b: c *= 2 ct += 1 if ct <= k: print(""Yes"") else: print(""No"") " p02601,s112979949,Accepted,"def b(): red, green, blue = map(int, input().split()) k = int(input()) for i in range(k): if green <= red: green *= 2 elif blue <= green: blue *= 2 else: print('Yes') return if blue > green > red: print('Yes') else: print('No') ########## if __name__ == ""__main__"": b() " p02601,s845733049,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 if A < B and B < C: print(""Yes"") else: print(""No"") " p02601,s428698336,Accepted,"[A,B,C] = list(map(int,input().split())) K = int(input()) cnt=0 while True: if A>=B: B=B*2 cnt+=1 else: break while True: if B>=C: C=C*2 cnt+=1 else: break if cnt<=K: print('Yes') else: print('No') " p02601,s033041074,Accepted,"A,B,C = map(int,input().split()) K = int(input()) count = 0 while True: if A= B: B *= 2 elif B > A: if B >= C: C *= 2 elif B < C: pass else: pass if A < B and B < C: print(""Yes"") else: print(""No"")" 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"")" p02601,s002705880,Accepted,"import sys a,b,c = map(int,input().split()) k=int(input()) i=0 while a >= b: b *= 2 if i == k: print('No') sys.exit() else: i += 1 while b >= c: c *= 2 if i == k: print('No') sys.exit() else: i += 1 print('Yes')" p02601,s788282720,Accepted,"r, g, b = map(int, input().split()) op = int(input()) while op > 0 and g <= r: g *= 2 op -= 1 while op > 0 and b <= g: b *= 2 op -=1 if r < g and g < b: print(""Yes"") else: print(""No"")" p02601,s913789267,Accepted,"A, B, C = map(int, input().split()) K = int(input()) cnt = 0 ans = False while True: if cnt > K: break if B > A and C > B: ans = True break if B <= A: B *= 2 cnt += 1 continue if C <= B: C *= 2 cnt += 1 if ans: print('Yes') else: print('No')" p02601,s324783964,Accepted,"a,b,c=map(int,input().split()) k=int(input()) while k>0: if a0: if b a and c > b: print(""Yes"") else: print(""No"") " p02601,s742580598,Accepted,"a,b,c = map(int,input().split()) k = int(input()) for _ in range(k): if b <= a: b *= 2 else: c *= 2 if a < b < c: print(""Yes"") else: print(""No"")" p02601,s476659162,Accepted,"a, b, c = map(int, input().split()) k = int(input()) cnt = 0 while b <= a: b *= 2 cnt += 1 while c <= b: c *= 2 cnt += 1 if cnt <= k: print(""Yes"") else: print(""No"") " p02601,s884088501,Accepted,"A,B,C = map(int, input().split()) flag = False K = int(input()) for i in range (K+1): for t in range (K+1): for u in range(K+1): if i + t + u == K: if B * (2**t) > A * (2**i) and C * (2**u) > B * (2**t): flag = True if flag: print('Yes') else: print('No')" p02601,s026842253,Accepted,"a, b, c = map(int, input().split()) k = int(input()) cnt = 0 while a >= b: cnt += 1 b *= 2 while b >= c: cnt += 1 c *= 2 if cnt <= k: print(""Yes"") else: print(""No"")" p02601,s471452564,Accepted,"a,b,c=map(int,input().split()) k=int(input()) for i in range(k): if b<=a: b*=2 elif c<=b: c*=2 if a= B and rest > 0: B *= 2 rest -= 1 while B >= C and rest > 0: C *= 2 rest -= 1 if rest >= 0 and A < B and B < C: print(""Yes"") else: print(""No"") " p02601,s607500330,Accepted,"A,B,C = list(map(int,input().split())) K = int(input()) for i in range(K): for j in range(K-i): k = K-i-j if 2**i*A<2**j*B<2**k*C: print('Yes') exit() print('No')" p02601,s197618858,Accepted,"A,B,C=map(int, input().split()) K = int(input()) if A < B < C: print(""Yes"") exit() for i in range(K): if A >= B: B *= 2 continue if B >=C: C *= 2 continue if A < B < C: print(""Yes"") else: print(""No"")" p02601,s870298152,Accepted,"#----------------------------- #https://atcoder.jp/contests/agc008/submissions/15248942 import sys sys.setrecursionlimit(10 ** 8) ini = lambda: int(sys.stdin.readline()) inm = lambda: map(int, sys.stdin.readline().split()) inl = lambda: list(inm()) ins = lambda: sys.stdin.readline().rstrip() debug = lambda *a, **kw: print(""\033[33m"", *a, ""\033[0m"", **dict(file=sys.stderr, **kw)) #----------------------------- R,G,B = inm() K = ini() X = 0 while R >= G: X += 1 G *= 2 while G >= B: X += 1 B *= 2 if X <= K: print(""Yes"") else: print(""No"")" p02601,s722522110,Accepted,"r,g,b = map(int, input().split()) k = int(input()) a = 0 while r>=g: g *= 2 a += 1 while g>=b: b *= 2 a += 1 if a<=k: print(""Yes"") else: print(""No"") # print(r,g,b,a) " p02601,s025524954,Accepted,"A, B, C = map(int, input().split()) K = int(input()) while K != 0: if B <= A: B *= 2 elif C <= B: C *= 2 else: break K -= 1 if (A < B) and (B < C): print('Yes') else: print('No')" p02601,s706261575,Accepted,"a, b, c = map(int, input().split()) k = int(input()) from itertools import permutations, product comb_lst = list(product([0,1,2], repeat = k)) flag = False for comb in comb_lst: abc_lst = [a, b, c] for num in comb: abc_lst[num] *= 2 if abc_lst[0] < abc_lst[1] and abc_lst[1] < abc_lst[2]: flag = True print('Yes' if flag == True else 'No')" p02601,s061477483,Accepted,"a,b,c = [int(i) for i in 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('No') else: print('Yes')" p02601,s177109236,Accepted,"A, B, C=list(map(int,input().split())) K=int(input()) for i in range(K): if A>=B: B=2*B elif B>=C: C=2*C if A 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"")" p02601,s348872368,Accepted,"#A = list(map(int, input().split())) a, b, c = map(int, input().split()) k = int(input()) import math if a >= b: p = int(math.log(a/b,2)) +1 else: p = 0 if b*(2**p) >= c: q = int(math.log(b*(2**p)/c,2)) +1 else: q = 0 #print(p) #print(q) if (p + q) <= k: print(""Yes"") else: print(""No"")" p02601,s615757387,Accepted,"A, B, C = list(map(int, input().split())) K = int(input()) flag = False for i in range(K): b = (2 ** i) * B c = (2 ** (K - i)) * C if A < b < c: flag = True if flag: print('Yes') else: print('No')" p02601,s700099262,Accepted,"def main(): a, b, c = map(int, input().split()) k = int(input()) count = 0 while True: if a < b: if b < c: break else: c *= 2 count += 1 else: b *= 2 count += 1 print('Yes' if count <= k else 'No') if __name__ == '__main__': main() " p02601,s521138335,Accepted,"A, B, C=map(int,input().split()) K=int(input()) ab=int(A/B) if ab==0: x=0 else: x=int(len(bin(ab))-2) B1=B*(2**x) bc=int(B1/C) if bc==0: y=0 else: y=int(len(bin(bc))-2) if x+y<=K: print(""Yes"") else: print(""No"")" p02601,s904283397,Accepted,"a,b,c=map(int, input().split()) k=int(input()) num=0 while a >= b: b *= 2 num += 1 while b >= c: c *= 2 num += 1 if num > k: print(""No"") else: print(""Yes"") " p02601,s274581652,Accepted,"a, b, c = map(int, input().split()) k = int(input()) while True: if b > a: break b *= 2 k -= 1 while True: if c > b: break c *= 2 k -= 1 if k < 0: print('No') else: print('Yes')" p02601,s846685891,Accepted,"A,B,C = (int(i) for i in input().split()) K = int(input()) ans = ""No"" for i in range(K): if A < B*(2**i) and B*(2**i) < C*(2**(K-i)): ans = ""Yes"" break print(ans) " p02601,s746375774,Accepted,"a, b, c = map(int, input().split()) k = int(input()) cnt = 0 while a >= b: b *= 2 cnt += 1 while b >= c: c *= 2 cnt += 1 if cnt <= k: print(""Yes"") else: print(""No"")" 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"")" p02601,s152063866,Accepted,"a, b, c = map(int, input().split()) aa, bb, cc = a, b, c p = 0 q = 1 k = int(input()) for i in range(1,k + 2): a, b, c = aa, bb, cc b = b * (2 ** (k - i + 1)) c = c * (2 ** (i - 1)) if c <= 0: c = cc if b <= 0: b = bb if a < b and b < c: p += 1 if p != 0: print(""Yes"") else: print(""No"")" p02601,s947177287,Accepted,"A,B,C=map(int,input().split()) X=int(input()) while X>0: if B<=A: B=2*B elif C<=B: C=2*C X-=1 if A=B: B*=2 continue if B>=C: C*=2 continue if C>B and B>A: flag=False break if C>B and B>A: flag=False print('Yes' if flag==False else ""No"")" p02601,s550574682,Accepted,"a,b,c=map(int,input().split()) k=int(input()) num=0 while a>=b: b*=2 num+=1 if b>a: break while b>=c: c*=2 num+=1 if c>b: break if num<=k: print(""Yes"") else: print(""No"") " p02601,s596861171,Accepted,"a,b,c = map(int,input().split()) k = int(input()) for l in range(1,k+1): for i in range(l+1): for j in range(l+1-i): for k in range(l+1-i-j): if b*pow(2,j) > a*pow(2,i) and c*pow(2,k) > b*pow(2,j): print('Yes') exit() print('No')" p02601,s151877422,Accepted,"A,B,C= map(int, input().split()) K = int(input()) for i in range(0,K): if C <= B or C <= A: C = C * 2 continue if B <= A: B = B * 2 continue if C > B and B > A: print(""Yes"") else: print(""No"") " p02601,s060942140,Accepted,"a, b, c = map(int, input().split()) k = int(input()) left = k while a >= b: left -= 1 b *= 2 while b >= c: left -= 1 c *= 2 if left >= 0: print(""Yes"") else: print(""No"") " p02601,s190923037,Accepted,"#-*- using:utf-8 -*- A, B, C = map(int, input().split()) K = int(input()) for _ in range(K): if A >= B: B = B*2 elif B >= C: C = C*2 else: C = C*2 if A < B and B < C: print(""Yes"") else: print(""No"")" 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')" p02601,s233323452,Accepted,"a,b,c = map(int,input().split()) k = int(input()) ans = 'No' d = 0 for i in range(1,k+1): if b <= a: d = d + 1 b = b * 2 else: d = d b = b if d == k: if c > b: ans = 'Yes' f = k - d g = 1 for j in range(1,f+2): if c <= b: c = c * 2 else: ans = 'Yes' print(ans) " p02601,s430412130,Accepted,"A,B,C = map(int,input().split()) K = int(input()) for k in range(K): if A < B < C: break elif A >= B: B = B*2 elif B >= C: C = C*2 if A < B < C: print('Yes') else: print('No') " p02601,s734611267,Accepted,"a,b,c,k=map(int,open(0).read().split()) while a>=b:b+=b;k-=1 while b>=c:c+=c;k-=1 print('YNeos'[k<0::2])" p02601,s147838247,Accepted,"a,b,c=map(int,input().split()) k=int(input()) b_list=[] c_list=[] for i in range(k+1): b_list.append(b*(2**i)) c_list.append(c*(2**i)) for j in range(k): if b_list[j]>a and c_list[k-j]>b_list[j]: print('Yes') break else: print('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') " p02601,s005653126,Accepted,"A, B, C = map(int, input().split()) K = int(input()) counter = 0 while C <= B or C <= A: C = 2*C counter += 1 while B <= A: B = 2*B counter += 1 while C <= B: C = 2*C counter += 1 if counter > K: print(""No"") else: print(""Yes"") " p02601,s444194930,Accepted,"A, B, C = map(int, input().split()) K = int(input()) ans = ""No"" for a in range(K+1): for b in range(K+1): for c in range(K+1): if a+b+c<=K and (A<= b: b *= 2 elif b >= c: c *= 2 if a < b and b < c: print(""Yes"") else: print(""No"")" p02601,s518330707,Accepted,"def resolve(): r, g, b = map(int, input().split()) k = int(input()) c = 0 # gがrより大きくなるまで2倍する while r >= g: g *= 2 c += 1 # bがgより大きくなるまで2倍する while g >= b: b *= 2 c += 1 if c <= k: print(""Yes"") else: print(""No"") if __name__ == ""__main__"": resolve()" p02601,s264500978,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 if a < b and b < c: print('Yes') else: print('No')" p02601,s859477171,Accepted,"A,B, C= list(map(int,input().split())) K = int(input()) for i in range((K)): if(A>=B): B=B*2 elif(B>=C): C=C*2 else: break if (C>B >A): print('Yes') else: print('No')" p02601,s696931528,Accepted,"A, B, C = map(int, input().split()) K = int(input()) count = 0 while not A < B: B *= 2 count += 1 while not B < C: C *= 2 count += 1 if count <= K and A < B < C: print('Yes') else: print('No') " p02601,s954997194,Accepted,"A,B,C = map(int,input().split()) K = int(input()) c = 0 while A >= B: B *= 2 c += 1 while B >= C: C *= 2 c += 1 if c <= K: print(""Yes"") else: print(""No"") " p02601,s489473945,Accepted,"a,b,c = map(int,input().split()) k = int(input()) while(b <= a): b = b*2 k -= 1 while(c <= b): c = c*2 k -= 1 if k < 0: print(""No"") else: print(""Yes"")" p02601,s140518425,Accepted,"def resolve(): A, B, C = list(map(int, input().split())) K = int(input()) cnt = 0 while cnt < K: if A >= B: B *= 2 cnt += 1 continue if B >= C: C *= 2 cnt += 1 continue cnt += 1 if A < B < C: print('Yes') else: print('No') return resolve()" p02601,s853884378,Accepted,"k = 0 A,B,C = map(int,input().split( )) K = int(input()) while (B <= A) and (k < K): B *= 2 k += 1 while (C <= B) and (k < K): C *= 2 k += 1 if A < B < C: print('Yes') else: print('No')" p02601,s120289321,Accepted,"a,b,c,k=map(int,open(0).read().split()) while a>=b:b*=2;k-=1 while b>=c:c*=2;k-=1 print('YNeos'[k<0::2])" 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)) " 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')" p02601,s983184888,Accepted,"a,b,c=map(int, input().split()) k=int(input()) co=0 while not (a B and B > A: print(""Yes"") sys.exit() for i in range(K+1): c1 = C*(2**i) b1 = B*(2**(K-i)) if c1 > b1 and b1 > A: print(""Yes"") sys.exit() print(""No"") " p02601,s643494101,Accepted,"A,B,C = map(int,input().split()) K = int(input()) a,b,c = A,B,C n = 0 while a >= 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"") " p02601,s011386743,Accepted,"a,b,c=map(int,input().split()) k=int(input()) ans=0 while(b<=a): b=b*2 ans+=1 m=max(a,b) while(c<=m): c=c*2 ans += 1 if ans<=k: print(""Yes"") else: print(""No"") " p02601,s006766407,Accepted,"A, B, C = map(int, input().split()) K = int(input()) k = 0 while True: if A < B: break else: B *= 2 k += 1 while True: if B < C: break else: C *= 2 k += 1 if k <= K: print('Yes') else: print('No') " p02601,s451687899,Accepted,"A, B, C = map(int, input().split()) K = int(input()) for _ in range(K): if A>=B: B*=2 else: C*=2 print('Yes' if A= b: b *= 2 cunt += 1 while b >= c: c *= 2 cunt += 1 if cunt > k: print(""No"") else: print(""Yes"") if __name__=='__main__': main()" p02601,s009278708,Accepted,"A, B, C = map(int, input().split()) K = int(input()) ans = ""No"" def ABC(int1, int2, int3): if int1 < int2 < int3: return True else: return False if ABC(A, B, C): ans = ""Yes"" else: for k in range(K): if B <= A: B = B * 2 elif C <= B: C = C * 2 if ABC(A, B, C): ans = ""Yes"" break print(ans)" p02601,s917073329,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([""No"", ""Yes""][a < b < c]) " p02601,s637261330,Accepted,"a, b, c = map(int, input().split()) k = int(input()) while a >= b: k -= 1 b *= 2 while b >= c: k -= 1 c *= 2 print(""Yes"" if k >= 0 else ""No"")" p02601,s549862090,Accepted,"a, b, c = map(int, input().split()) k = int(input()) for i in range(k): if b <= a: b *= 2 else: c *= 2 print('Yes' if a < b < c else 'No') " p02601,s170313886,Accepted,"def main(): a,b,c=map(int,input().split()) k = int(input()) for i in range(k): if a < b < c: break elif a >= b: b *= 2 elif b >= c: c *= 2 if a < b < c: print('Yes') else: print('No') main()" p02601,s385338611,Accepted,"A, B, C = map(int, input().split()) K = int(input()) D = 0 while A >= B: B *= 2 D += 1 while B >= C: C *= 2 D += 1 print('Yes' if D <= K else 'No')" p02601,s128574199,Accepted,"a,b,c=map(int,input().split()) k=int(input()) x='No' for i in range(k+1): A=a*2**i for j in range(k-i+1): B=b*2**j C=c*2**(k-i-j) if A=0 else 'No')" p02601,s785530366,Accepted,"a, b, c = map(int, input().split()) k = int(input()) ans = 'Yes' for _ in range(k): if a >= b: b = 2*b k -= 1 if b > a: break k_2 = k for _ in range(k_2): if b >= c: c = 2*c if not a < b < c: ans = 'No' print(ans) " p02601,s317039177,Accepted,"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()) k = int(input()) for i in range(k): if a >= b: b *= 2 elif b >= c: c *= 2 if a < b and b < c: print(""Yes"") else: print(""No"")" p02601,s334221820,Accepted,"A,B,C = map(int, input().split()) K = int(input()) kk=0 while B<=A: B = B*2 kk+=1 while C<=B: C = C*2 kk+=1 if kk<=K: ans=""Yes"" else: ans = ""No"" print(ans)" p02601,s035032185,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 c>b>a: print('Yes') else: print('No')" p02601,s281222816,Accepted,"a, b, c = map(int, input().split()) k = int(input()) flg = False for i in range(k+1): d = 2**i*b e = 2**(k-i)*c if a < d < e: flg = True break if flg: print('Yes') else: print('No')" p02601,s720899477,Accepted,"A, B, C = map(int, input().split()) K = int(input()) while K: if A >= B: B *= 2 elif B >= C: C *= 2 K -= 1 if A < B < C: print('Yes') else: print('No') " p02601,s974072001,Accepted,"A, B, C = map(int, input().split()) K = int(input()) count = 0 j = 1 while(A>=B): if(count=b: b*=2 else: if b>=c: c*=2 if a= b: b *= 2 cnt += 1 while b >= c: c *= 2 cnt += 1 if(cnt <= k): print(""Yes"") else: print(""No"")" p02601,s129395232,Accepted,"A, B, C = map(int, input().split()) K = int(input()) while K > 0 and B <= A: B *= 2 K -= 1 while K > 0 and C <= B: C *= 2 K -= 1 if C > B > A: print('Yes') else: print('No') " p02601,s607123607,Accepted,"A,B,C = map(int,input().split()) K = int(input()) i = 0 while True: if B > A: break else: B = B * 2 i += 1 q = 0 while True: if C > B: break else: C = C * 2 q += 1 if (i + q) > K: print(""No"") else: print(""Yes"") " p02601,s023434103,Accepted,"a, b, c = map(int, input().split()) k = int(input()) cnt = 0 while b <= a: b += b cnt += 1 while c <= b: c += c cnt += 1 if cnt <= k: print('Yes') else: print('No')" p02601,s049252973,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('Yes' if a < b < c else 'No') " p02601,s614357093,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 if(a < b < c): print(""Yes"") else: print(""No"")" p02601,s331668740,Accepted,"r, g, b = map(int, input().split()) t = 0 while r >= g: g *= 2; t += 1 while g >= b: b *= 2; t += 1 print('No' if t > int(input()) else 'Yes') " p02601,s985106333,Accepted,"a,b,c = map(int, input().split()) k = int(input()) cnt=0 while a>=b: b*=2 cnt+=1 while b>=c: c*=2 cnt+=1 if cnt<=k: print(""Yes"") else: print(""No"")" p02601,s253785911,Accepted,"a,b,c=list(map(int, input().split())) K=int(input()) ct=0 while b<=a: b*=2 ct+=1 while c<=b: c*=2 ct+=1 if ct<=K: print('Yes') else: print('No')" p02601,s189736476,Accepted,"main=list(map(int,input().split())) k=int(input()) for i in range(k): if(main[0]>=main[1]): main[1]=main[1]*2 elif(main[1]>=main[2]): main[2]=main[2]*2 if(main[1]>main[0] and main[2]>main[1]): print('Yes') else: print('No')" p02601,s372880994,Accepted,"a, b, c = map(int, input().split()) k = int(input()) i = 0 while a >= b: b = b * 2 i += 1 while b >= c: c = c * 2 i += 1 if i <= k: print(""Yes"") else: print(""No"")" p02601,s122174080,Accepted,"a,b,c,k=map(int,open(0).read().split()) while k:k-=1;t=a= B : B = B*2 else: if B >= C : C = C*2 if C > B & B > A: print(""Yes"") else: print(""No"") " p02601,s212037735,Accepted,"A,B,C=map(int,input().split()) K=int(input()) a=K while A>=B: B*=2 a-=1 while B>=C: C*=2 a-=1 if a>=0: print('Yes') else: print('No') " p02601,s608082095,Accepted,"A,B,C=map(int,input().split()) K=int(input()) abc=[A,B,C] #赤<緑<青 for _ in range(K): if abc[0]>=abc[1]: abc[1]=abc[1]*2 elif abc[1]>=abc[2]: abc[2]=abc[2]*2 else: print(""Yes"") exit() if abc[0]= B): B *= 2 cnt += 1 while(B >= C): C *= 2 cnt += 1 if cnt <= K: print(""Yes"") else: print(""No"")" p02601,s628853202,Accepted," a, b, c = map(int, input().split()) k = int(input()) while a >= b and k > 0: b *= 2 k -= 1 while b >= c and k > 0: c *= 2 k -= 1 if a < b < c: print(""Yes"") else: print(""No"") " p02601,s190888870,Accepted,"a,b,c,k=map(int,open(0).read().split()) while a>=b: k-=1 b*=2 while b>=c: k-=1 c*=2 print(""Yes"" if k>=0 else ""No"")" p02601,s790802683,Accepted,"a,b,c = [int(x) for x in input().split(' ')] k = int(input()) z=0 while(a>=b): b*=2 z+=1 while (b>=c): c*=2 z+=1 if(z<=k): print(""Yes"") else: print(""No"") " p02601,s929535729,Accepted,"def judge(A, B, C): if A < B: if B < C: return True return False A, B, C = map(int, input().split()) K = int(input()) ans = ""No"" for _ in range(K): if B <= A: B = B * 2 elif C <= B: C = C * 2 if judge(A, B, C): ans = ""Yes"" break print(ans) " p02601,s407884886,Accepted,"A, B, C = map(int, input().split()) K = int(input()) while A >= B: B *= 2 K -= 1 while B >= C: C *= 2 K -= 1 if K >= 0: print('Yes') else: print('No')" p02601,s406019105,Accepted,"A,B,C = list(map(int,input().split())) K = int(input()) flag= 0 for i in range(K): if A>=B: B *=2 elif C <= B: C *=2 if C >B and B>A: flag = 1 break if flag == 0: print(""No"") else: print(""Yes"")" p02601,s146923458,Accepted,"a,b,c=map(int,input().split()) k=int(input()) for i in range(k): if c<=b or c <= b*2: c*=2 elif b<=a or b <= a*2: b*=2 else: a*=2 if ar and b>g): break else: if(g<=r): g=g*2 cnt+=1 else: if(b<=g): b=b*2 cnt+=1 if(cnt<=k): print(""Yes"") else: print(""No"")" p02601,s914451648,Accepted,"A,B,C = map(int,input().split()) K=int(input()) i=0 while B<=A: i+=1 B*=2 while C<=B: i+=1 C*=2 if i>K: print(""No"") else: print(""Yes"")" p02601,s960176139,Accepted,"A, B, C = map(int, input().split()) K = int(input()) L = [] for i in range(K+1): for j in range(K+1): if i+j > K: break if A*(2**i) < B*(2**j) < C*(2**(K-i-j)): L.append('Yes') break if len(L)==0: print('No') else: print('Yes') " p02601,s851862568,Accepted,"A,B,C = map(int,input().split()) K = int(input()) cnt = 0 for i in range(100): if A >= B: B *= 2 cnt += 1 for i in range(100): if B >= C: C *= 2 cnt += 1 if cnt > K: print(""No"") else: print(""Yes"")" p02601,s220650131,Accepted,"A, B, C = map(int, input().split()) K = int(input()) for _ in range(K): if(A>=B): B *= 2 continue if(B>=C): C *= 2 if(B>A and C>B): print(""Yes"") else: print(""No"")" p02601,s170694360,Accepted,"a,b,c=map(int,input().split()) k=int(input()) n=0 while a>=b: b*=2 n+=1 while b>=c: c*=2 n+=1 print('YNeos'[n>k::2])" p02601,s365560523,Accepted,"A, B, C = map(int, input().split()) K = int(input()) for i in range(K): if B <= A: B *= 2 elif C <= B: C *= 2 if A < B and B < C: break if (A < B and B < C): print('Yes') else: print('No') " p02601,s420732745,Accepted,"a,b,c = map(int,input().split()) k = int(input()) count = 0 while a >= b: b *= 2 count += 1 while b >= c: c *= 2 count += 1 if a < b < c and k-count>= 0: print(""Yes"") else: print(""No"")" p02601,s658875655,Accepted,"a, b, c = map(int, input().split()) k = int(input()) while b <= a: if k == 0: print(""No"") exit() b *= 2 k -= 1 while c <= b: if k == 0: print(""No"") exit() c *= 2 k -= 1 print(""Yes"") " p02601,s076146455,Accepted,"a,b,c=map(int,input().split()) k=int(input()) x=0 while a>=b: b=b*2 x=x+1 while b>=c: c=c*2 x=x+1 if k>=x: print('Yes') else: print('No')" p02601,s243754205,Accepted,"def main(): a, b, c = map(int, input().split()) k = int(input()) while b <= a: b *= 2 k -= 1 while c <= b: c *= 2 k -= 1 if k >= 0: print('Yes') else: print('No') if __name__ == '__main__': main() " p02601,s711170817,Accepted,"A,B,C=map(int,input().split()) K=int(input()) i=0 while i=B: B*=2 elif B>=C: C*=2 i+=1 print('Yes' if A=b: b*=2 elif b>=c: c*=2 if a>=b or b>=c: print('No') else: print('Yes')" p02601,s020195081,Accepted,"a,b,c=map(int,input().split()) k=int(input()) bb=b bcnt=0 while a>=bb: bb=bb*2 bcnt+=1 cc=c ccnt=0 while bb>=cc: cc=cc*2 ccnt+=1 if bcnt+ccnt<=k: print(""Yes"") else: print(""No"")" p02601,s593141994,Accepted,"a, b, c = map(int, input().split()) k = int(input()) cnt = 0 while a >= b: b *= 2 cnt += 1 while b >= c: c *= 2 cnt += 1 print('Yes' if cnt <= k else 'No') " p02601,s720522632,Accepted,"def check(r, g, b): return g > r and b > g def main(): r, g, b = map(int, input().split()) k = int(input()) for i in range(k + 1): if check(r, g * pow(2, i), b * pow(2, k - i)): print(""Yes"") break else: print(""No"") if __name__ == '__main__': main() " p02601,s961917014,Accepted,"a,b,c = list(map(int,input().split())) k = int(input()) for i in range(k): if a >= b: b *= 2 else: c *= 2 if a < b < c: print('Yes') else: print('No') " p02601,s519152501,Accepted,"a, b, c = map(int, input().split()) k = int(input()) flag = False for i in range(k+1): tb = b tc = c for j in range(i): tb *= 2 for j in range(k-i): tc *= 2 if tb > a and tc > tb: flag = True break if flag: print(""Yes"") else: print(""No"")" p02601,s395715152,Accepted,"a, b, c = map(int, input().split()) k = int(input()) cnt = 0 while True: if a >= b: b *= 2 cnt += 1 if b >= c: c *= 2 cnt += 1 if a < b and b < c: break if cnt <= k: print(""Yes"") else: print(""No"") " p02601,s075597239,Accepted,"a,b,c=map(int,input().split()) d=int(input()) result=[] for i in range(d+1): for j in range(d+1): for k in range(d+1): if i+j+k>d: continue n=[(2**i)*a,(2**j)*b,(2**k)*c] result.append(n) for i in range(len(result)): m=result[i] if m[1]>m[0] and m[2]>m[1]: print('Yes') exit() print('No')" p02601,s316149959,Accepted,"a,b,c=map(int,input().split()) k=int(input()) for i in range(k): if ( a >= b): b=b*2 continue elif ( b >= c ): c=c*2 continue else: break if (a g > r: return 'Yes' elif b <= g: times -= 1 b *= 2 elif g <= r: times -= 1 g *= 2 if times < 0: return 'No' print(check(r, g, b, times))" p02601,s573136746,Accepted,"a, b, c = map(int, input().split()) k = int(input()) while a >= b or b >= c: if a >= b: b *= 2 k -= 1 else: if b >= c: c *= 2 k -= 1 if k >= 0: print(""Yes"") else: print(""No"") " p02601,s378937334,Accepted,"A, B, C = map(int, input().split()) K = int(input()) cnt = 0 while B <= A: cnt += 1 B = B * 2 while C <= B: cnt += 1 C = C * 2 print('Yes' if cnt <= K else 'No')" p02601,s791342489,Accepted,"a,b,c = map(int,input().split()) k = int(input()) ans = ""No"" for i in range(k): if a>=b: b*=2 elif b>=c: c*=2 if b>a and c>b: ans = ""Yes"" print(ans)" p02601,s408100605,Accepted,"a, b, c = map(int, input().split()) k = int(input()) while True: if a >= b: b *= 2 # print(b) k -= 1 else: break while True: if b >= c: c *= 2 # print(c) k -= 1 else: break if k < 0: print('No') else: print('Yes') " p02601,s767209173,Accepted,"A,B,C=map(int,input().split()) K=int(input()) list=[A,B,C] for i in range(K): if list[0]=list[2]: list[2]=2*list[2] continue elif list[0]>=list[1]: list[1]=2*list[1] if list[0]= b: b *= 2 cnt += 1 while b >= c: c *= 2 cnt += 1 if cnt <= k: print(""Yes"") else: print(""No"")" p02601,s488380817,Accepted,"A,B,C = map(int,input().split()) K = int(input()) while A >= B and K > 0: B = B*2 K=K-1 while B >= C and K > 0: C = C*2 K=K-1 if A G and G > R): print(""Yes"") else: print(""No"")" p02601,s827081099,Accepted,"A,B,C = map(int,input().split()) K = int(input()) for k in range(K): if B<=A: B*=2 else: C*=2 if AG>R R,G,B = map(int,input().split()) K = int(input()) cnt = 0 while not G>R: G *= 2 cnt += 1 while not B>G: B *= 2 cnt += 1 if cnt<=K: print(""Yes"") else: print(""No"")" p02601,s675475446,Accepted,"a,b,c = list(map(int, input().split())) k = int(input()) cnt = 0 while b <= a: b *= 2 cnt += 1 while c <= b: c *= 2 cnt += 1 if cnt <= k: print('Yes') else: print('No')" p02601,s081430636,Accepted,"r, g, b = list(map(int, input().split())) k = int(input()) count = 0 while r >= g: g *= 2 count += 1 while g >= b: b *= 2 count += 1 if k >= count: print('Yes') else: print('No')" p02601,s290823859,Accepted,"a, b, c = map(int, input().split()) k = int(input()) for i in range(k): if a >= c: c *= 2 elif a >= b: b *= 2 elif b >= c: c *= 2 if a < b and b < c: print('Yes') else: print('No') " p02601,s339597663,Accepted,"A,B,C = [int(x) for x in input().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 B>A and C>B: print(""Yes"") else: print(""No"")" p02601,s391604639,Accepted,"A, B, C = map(int,input().split()) K = int(input()) cnt = 0 while A >= B: B *= 2 cnt += 1 while B >= C: C *= 2 cnt += 1 if cnt <= K: print(""Yes"") else: print(""No"") " p02601,s321863857,Accepted,"R,G,B=map(int,input().split()) K = int(input()) while (B<=G or G<=R) and K>0: if R>=G: G = G*2 K = K-1 if G>=B: B = B*2 K = K-1 if R=0: print(""Yes"") else: print('No')" p02601,s033923398,Accepted,"a, b, c = map(int, input().split()) k = int(input()) l = 0 while a >= b: b *= 2 l += 1 while b >= c: c *= 2 l += 1 if k >= l: print(""Yes"") else: print(""No"")" p02601,s387219832,Accepted,"A, B, C = map(int, input().split()) K = int(input()) for ctA in range(K+1): for ctB in range(K-ctA+1): for ctC in range(K-ctA-ctB+1): if A*(2**ctA) < B*(2**ctB) < C*(2**ctC): print('Yes') exit() print('No') " p02601,s555122606,Accepted,"a,b,c=map(int,input().split()) k=int(input()) res=""No"" for i in range(k): if a>=b: b*=2 else:c*=2 if a= C: C = C * 2 K -= 1 if K > 0: for i in range(K): if A >= B: B = B * 2 K -= 1 if B >= C: if K > 0: C = C * 2 exit if A < B and C > B: print(""Yes"") else: print(""No"") " p02601,s103626184,Accepted,"import itertools A, B, C = map(int, input().split()) k = int(input()) l = ['a', 'b', 'c'] for v in itertools.combinations_with_replacement(l, k): new_A = A * (2**(v.count('a'))) new_B = B * (2**(v.count('b'))) new_C = C * (2**(v.count('c'))) if new_A < new_B < new_C: print('Yes') exit() print('No')" p02601,s567716516,Accepted,"A, B, C = map(int, input().split()) K = int(input()) k = 0 while A >= B: B *= 2 k += 1 while B >= C: C *= 2 k += 1 print('Yes' if k <= K else 'No') " p02601,s231024166,Accepted,"r, g, b = map(int, input().split()) k = int(input()) flag=0 for i in range(k): if g<=r: g=g*2 elif b<=g: b=b*2 else: break if b>g and g>r: print(""Yes"") else: print(""No"")" p02601,s728526655,Accepted,"a, b, c = map(int, input().split()) k = int(input()) while b <= a: b *= 2 k -= 1 while c <= b: c *= 2 k -= 1 print(""Yes"" if k >= 0 else ""No"")" p02601,s864108201,Accepted,"red, green, blue = map(int, input().split()) K = int(input()) for i in range(K): if red >= green: green = green * 2 elif green >= blue: blue = blue * 2 if red < green and green < blue: print('Yes') else: print('No')" p02601,s105704187,Accepted,"A,B,C = map(int,input().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 A < B and B < C: print(""Yes"") else: print(""No"")" p02601,s394383543,Accepted,"A,B,C=[int(s) for s in input().split()] X=int(input()) count=0 while A>=B: B*=2 count+=1 while B>=C: C*=2 count+=1 if count<=X: print('Yes') else: print('No') " p02601,s319453389,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 if a < b and b < c: print(""Yes"") else: print(""No"")" p02601,s813445993,Accepted,"r, g, b = input().split(' ') n = int(input()) for i in range(0, n): if int(r) >= int(g): g = int(g) * 2 continue if int(g) >= int(b): b = int(b) * 2 continue if int(r) < int(g) < int(b): print('Yes') else: print('No')" p02601,s885427349,Accepted,"a, b, c = map(int, input().split()) k = int(input()) n = 0 while True: if b <= a: b *= 2 n += 1 else: break while True: if c <= b: c *= 2 n += 1 else: break if k >= n: print('Yes') else: print('No')" p02601,s327539615,Accepted,"a,b,c = map(int,input().split()) k = int(input()) for i in range(k): if not b > a: b *= 2 elif not c > b: c *= 2 if a=b: b*=2 else: c*=2 if a RGB[1] > RGB[0]: print(""Yes"") exit() for i in range(K): RGB[K_cards[i]] *= 2 if RGB[2] > RGB[1] > RGB[0]: print(""Yes"") exit() print(""No"")" p02601,s724053717,Accepted,"# 入力 A,B,C = list(map(int, input().split())) K = int(input()) ans = 'No' for i in range(K+1): if(A>=B): B *= 2 else: if(B>=C): C *= 2 else: ans = 'Yes' break print(ans) " p02601,s376305886,Accepted,"a,b,c = map(int, input().split()) k = int(input()) ans = 0 while b <= a: b *= 2 ans += 1 while c <= b: c *= 2 ans += 1 #print(a,b,c, ans) if ans <= k: print('Yes') else: print('No')" p02601,s381386361,Accepted,"A, B, C = map(int, input().split()) binary = [1, 2, 4, 8, 16, 32, 64, 128, 256] K = int(input()) flg = False for i in range(K+1): for j in range(K+1): for k in range(K+1): if i + j + k == K: if A*binary[i] < B*binary[j] and B*binary[j] < C*binary[k]: flg = True if flg: print(""Yes"") else: print(""No"") " p02601,s334477852,Accepted,"a, b, c = map(int, input().split()) k = int(input()) for i in range(k): if a >= b: b *= 2 elif b >= c: c *= 2 else: c *= 2 if a < b < c: print(""Yes"") else: print(""No"") " p02601,s568046850,Accepted,"a,b,c=map(int,input().split()) n=int(input()) while a>=b: n-=1 b*=2 while b>=c: n-=1 c*=2 print(""Yes"" if n>=0 else ""No"")" p02601,s777755193,Accepted,"import sys import numpy as np A,B,C = list(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 < B and B < C: print('Yes') else: print('No') " p02601,s843430166,Accepted,"import copy import itertools r,g, b = map(int,input().split()) k = int(input()) #hl = list(map(int,input().split())) lst = [r,g,b] for v in itertools.product([0,1,2], repeat=k): tmplst = copy.deepcopy(lst) for i in v: tmplst[i] *= 2 if tmplst[0] < tmplst[1] < tmplst[2]: print('Yes') exit() print('No')" p02601,s905944349,Accepted,"A,B,C = map(int, input().split()) K = int(input()) K+=1 resu = 0 for k in range(K): if A>=B: B=B*2 elif B>=C: C=C*2 else: print(""Yes"") break else: print(""No"") " p02601,s056788881,Accepted,"import math A, B, C = map(int, input().split()) K = int(input()) C = C * math.pow(2, K) for b in range(K+1): if A < B and B < C: print(""Yes"") exit() C = C//2 B = B*2 print(""No"")" p02601,s939908086,Accepted,"a,b,c=map(int,input().split()) k=int(input()) while k>0: k-=1 if a>=b: b*=2 elif b>=c: c*=2 else: pass if b>a and c>b: print(""Yes"") else: print('No')" p02601,s287808256,Accepted,"a,b,c=map(int,input().split()) k=int(input()) count=0 while(b<=a): b=b*2 count+=1 while(c<=b): c=c*2 count+=1 if count>k: print(""No"") else: print(""Yes"")" p02601,s790661003,Accepted,"A, B, C = list(map(int, input().split())) K = int(input()) def dfs(k, a, b, c): if k == 0: if b > A and c > b: return True else: return False if dfs(k - 1, a * 2, b, c): return True if dfs(k - 1, a, b * 2, c): return True if dfs(k - 1, a, b, c * 2): return True return False r = dfs(K, A, B, C) if r: print('Yes') else: print('No')" p02601,s198805483,Accepted,"a,b,c= list(map(int, input().strip().split())) N = int(input().strip()) x=0 y=N if b<=a: for i in range(100): b*=2 x=x+1 y=y-1 if b>a: break if y<0: if c<=b: print(""No"") else: print(""Yes"") else: for i in range(y): c*=2 if c<=b: print(""No"") else: print(""Yes"")" p02601,s156643706,Accepted,"def double(x, y): global count for _ in range(7): if x < y: break y *= 2 count += 1 return y def main(): a, b, c = map(int, input().split()) k = int(input()) b = double(a, b) c = double(b, c) if count <= k: print(""Yes"") else: print(""No"") if __name__ == ""__main__"": count = 0 main() " p02601,s239006939,Accepted,"import itertools a,b,c = map(int,input().split()) k = int(input()) flag = False for arr in list(itertools.product([0,1,2], repeat=k)): temp = [a,b,c] for i in range(k): temp[arr[i]] = temp[arr[i]]*2 if temp[0] < temp[1] and temp[2] > temp[1]: flag = True if flag: print(""Yes"") else: print(""No"")" p02601,s464633766,Accepted,"import math a,b,c = [int(x) for x in input().split()] k = int(input()) a1,b1,c1 = math.log2(a),math.log2(b),math.log2(c) k1,k2 = 0,0 # print(a1,b1,c1) if b1<=a1: k1 = math.floor(a1-b1+1) b1 = b1+k1 if c1<=b1: k2 = math.floor(b1-c1+1) if k1+k2<=k: print(""Yes"") else: print(""No"")" p02601,s756427211,Accepted," a, b, c = [int(x) for x in input().strip().split()] k = int(input()) while (b<=a or c<=b) and k: if b<=a: b = b*2 else: c = c*2 k-=1 if a=B: B=B*2 M=K-(i+1) if AB and A0: if not b>a: b*=2 k-=1 elif not c>b: c*=2 k-=1 else: break if c>b and b>a: print(""Yes"") else: print(""No"") " p02601,s534318063,Accepted,"a, b, c = map(int, input().split()) k = int(input()) count = 0 while a >= b: b *= 2 count += 1 # print(""b"", b) while b >= c: c *= 2 count += 1 # print(""c"", c) if count <= k: print(""Yes"") else: print(""No"") " p02601,s642711060,Accepted,"r,g,b = map(int,input().split()) k = int(input()) counter = 0 while r >= g: counter+=1 g*=2 while g >= b: counter+=1 b*=2 print('Yes' if counter<=k else 'No')" p02601,s759867525,Accepted,"a,b,c = map(int, input().split()) k = int(input()) count = 0 while count < k: if a= b: b *= 2 count += 1 elif b >= c: c *= 2 count += 1 if a=b) and (k>0): b = b*2 k-=1 #print(b) #print(k) while (b>=c) and (k>0): c = c*2 k-=1 #print(c) #print(k) #print(a,b,c,k) if (a < b) and (b=0): print(""Yes"") else: print(""No"") " p02601,s155197421,Accepted,"A,B,C=map(int,input().split()) K=int(input()) while A>=B: K-=1 B*=2 while B>=C: K-=1 C*=2 if K>=0: print('Yes') else: print('No')" p02601,s558490801,Accepted,"a = list(map(int, input().split())) num = int(input()) k = 0 for i in range(num): #num回2倍を繰り返す。でなければNoをprint if a[0] == max(a) or a[1] == max(a): #リストaの中のmaxよりも青が小さいならば青を二倍する a[2] = a[2] * 2 k += 1 elif a[1] == min(a) and k < num: a[1] = a[1] * 2 k += 1 else: pass if a[0] < a[1] and a[1] < a[2]: print(""Yes"") else: print(""No"")" p02601,s283656291,Accepted,"a, b, c = map(int, input().split()) k = int(input()) for i in range(k): if (not (b > a)): b *= 2 elif (not (c > b)): c *= 2 if (c > b and b > a): print(""Yes"") else: print(""No"") " p02601,s248522683,Accepted,"from sys import * a,b,c = map(int,stdin.readline().split()) k = int(stdin.readline()) while b <= a: b = b*2 k -= 1 while c <= b: c = c*2 k -= 1 if k < 0: print(""No"") else: print(""Yes"")" p02601,s868191936,Accepted,"a,b,c=map(int,input().split()) k=int(input()) cnt=0 while a>=b: b*=2 cnt+=1 while b>=c: c*=2 cnt+=1 print('Yes' if cnt<=k else 'No')" p02601,s377786866,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 if a A # C > B A, B, C = map(int, input().split()) K = int(input()) k = 0 while B<=A: B*=2 k += 1 while C<=B: C*=2 k+=1 if k<=K: print(""Yes"") else: print(""No"")" p02601,s707868214,Accepted,"def main(): a, b, c = map(int, input().split()) k = int(input()) while b <= a: b *= 2 k -= 1 if k < 0: print('No') exit() while c <= b: c *= 2 k -= 1 if k < 0: print('No') exit() print('Yes') if __name__ == '__main__': main() " p02601,s281544732,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()) A,B,C = LI() K = I() for i in range(K): if A >= B: B *= 2 elif B >= C: C *= 2 if A < B < C: print('Yes') else: print('No')" p02601,s702158468,Accepted," a,b,c = map(int, raw_input().split()) k = int(raw_input()) # greedily while( a >= b): b*= 2 k -=1 while( b >= c): c*= 2 k -=1 print 'Yes' if k >= 0 else 'No' " p02601,s721691751,Accepted,"a,b,c=map(int,input().split()) k=int(input()) for _ in range(k): if b<=a: b*=2 continue if c<=b: c*=2 continue if a G: G*=2 elif G > B: B*=2 elif R > B: B*=2 elif R == G == B: B *= 2 elif R == G: G *= 2 elif G == B: B *= 2 else: pass if R < G < B: print(""Yes"") else: print(""No"") " p02601,s807067933,Accepted,"a,b,c = map(int,input().split()) k=int(input()) for i in range(k): if c<=a or c<=b: c=2*c elif b<=a: b=2*b else: pass if c > b and b > a and c >a: print(""Yes"") else: print(""No"")" p02601,s093098159,Accepted,"a,b,c = list(map(int,input().split())) k = int(input()) while b <= a and k > 0: b*=2 k-=1 while c <= b and k > 0: c*=2 k-=1 if c > b and b > a: print(""Yes"") else: print(""No"")" p02601,s939421357,Accepted,"A,B,C = map(int, input().split()) K = int(input()) for i in range(K): if A >= B: B = B * 2 else: C = C * 2 if A < B and B < C: print(""Yes"") else: print(""No"")" p02601,s289356548,Accepted,"a, b, c = map(int, input().split()) k = int(input()) ans = 0 while b <= a: b *= 2 ans += 1 while c <= b: c *= 2 ans += 1 print('Yes' if ans <= k else 'No')" p02601,s620088096,Accepted,"(A, B, C, ) = [int(n) for n in input().split()] (K, ) = [int(n) for n in input().split()] while A >= B: B *= 2 K -= 1 while B >= C: C *= 2 K -= 1 if K >= 0: print('Yes') else: print('No') " p02601,s445261617,Accepted,"a,b,c = list(map(int,input().split())) k = int(input()) cnt = 0 while not a < b: b*=2 cnt+=1 while not b < c: c*=2 cnt+=1 #print('cnt:',cnt,'k:',k) print('Yes' if cnt <=k else 'No')" p02601,s689342125,Accepted,"a, b, c = map(int, input().split()) k = int(input()) m = 0 while a >= b: b = b*2 m += 1 if a< b: break while b >= c: c = c*2 m += 1 if b < c: break if k >= m: print(""Yes"") else: print(""No"")" p02601,s971006041,Accepted,"#標準入力 A,B,C = map(int,input().split()) K=int(input()) cnt = 0 while A >= B: B=B*2 cnt+=1 if A < B: break while B >= C: C=C*2 cnt+=1 if B < C: break ans = 'Yes' if cnt <= K else 'No' print(ans)" p02601,s860558482,Accepted,"l = list(map(int, input().split())) K = int(input()) def check(nums): if nums[0] < nums[1]: if nums[1] < nums[2]: print('Yes') exit(0) check(l) for i in range(K): if l[0] >= l[1]: l[1] *= 2 check(l) continue elif l[1] >= l[2]: l[2] *= 2 check(l) continue print('No') exit(0) " p02601,s071930177,Accepted,"import sys from collections import defaultdict, Counter, namedtuple, deque import itertools import functools import bisect import heapq import math import copy # from fractions import gcd MOD = 10 ** 9 + 7 # MOD = 998244353 # sys.setrecursionlimit(10**8) a, b, c = map(int, input().split()) k = int(input()) count = 0 while a >= b: b *= 2 count += 1 while b >= c: c *= 2 count += 1 if count <= k: print(""Yes"") else: print(""No"") " p02601,s592592581,Accepted,"import math a,b,c= map(int,input().split("" "")) k=int(input()) while(k>0 and b<=a): b*=2 k-=1 while(k>0 and c<=b): c*=2 k-=1 if a= b : b *= 2 k -= 1 while b >= c: c *= 2 k -= 1 if k >= 0: print(""Yes"") else: print(""No"")" p02601,s572491718,Accepted,"[r,g,b]=list(map(int,input().split())) #b>g>r k=int(input()) m=k n=0 while m>=0: tg=pow(2,m)*g tb=pow(2,n)*b if tg>r and tb>tg: print(""Yes"") exit(0) m-=1 n+=1 print(""No"") " p02601,s234940973,Accepted,"a, b, c = map(int, input().split()) k = int(input()) for i in range(k): if a >= b: b = b * 2 else: if b >= c: c = c * 2 else: break if a < b < c: print(""Yes"") else: print(""No"")" p02601,s496743924,Accepted,"A,B,C=map(int,input().split()) K=int(input()) nax=2**K if Aa: if c>b: print('Yes') break else: c *= 2 else: b *= 2 else: print('No')" p02601,s824708536,Accepted,"a, b, c = map(int, input().split()) k = int(input()) while a>=b: b*=2 k-=1 while b>=c: c*=2 k-=1 if k>=0: print('Yes') else: print('No')" p02601,s942952845,Accepted,"A,B,C = map(int,input().split()) K = int(input()) i = 0 while B <= A: B *= 2 i += 1 while C <= B: C *= 2 i += 1 print('Yes' if i <= K else 'No') " p02601,s377776937,Accepted,"A,B,C = map(int,input().split()) K = int(input()) ans = 0 while A>=B: ans+=1 B*=2 while B>=C: ans+=1 C*=2 if ans<= K: print('Yes') else: print('No') " p02601,s258692203,Accepted,"a, b, c = map(int, input().split()) k = int(input()) for i in range(k): if b > a: c *= 2 else: b *= 2 if c > b > a: print('Yes') quit() print('No') " p02601,s464720590,Accepted,"import sys input = sys.stdin.readline ABC = list(map(int, input().split())) K = int(input()) for i in range(K+1): if ABC[0] < ABC[1] and ABC[1] < ABC[2]: print(""Yes"") break elif ABC[0] >= ABC[2]: ABC[2] = 2 * ABC[2] elif ABC[1] >= ABC[2]: ABC[2] = 2 * ABC[2] elif ABC[0] >= ABC[1]: ABC[1] = 2 * ABC[1] else: print(""No"")" p02601,s459353987,Accepted,"a, b, c = map(int, input().split()) k = int(input()) if a >= b: while a >= b: if k == 0: print(""No"") exit() b *= 2 k -= 1 if b >= c: while b >= c: if k == 0: print(""No"") exit() c *= 2 k -= 1 print(""Yes"") " p02601,s332249365,Accepted,"a, b, c = map(int, input().split()) k = int(input()) ans = 0 while a>=b: b*=2 ans+=1 while b>=c: c*=2 ans+=1 if ans<=k: print('Yes') else: print('No')" p02601,s490489359,Accepted,"import sys import math def input(): return sys.stdin.readline().rstrip() def main(): A,B,C =map(int,input().split()) K =int(input()) count =0 while A>=B: B*=2 count +=1 while B>=C: C*=2 count +=1 if count >K: print(""No"") else: print(""Yes"") if __name__ == ""__main__"": main() " p02601,s376687439,Accepted,"A,B,C=map(int,input().split()) K=int(input()) for i in range(K+1) : for j in range(K+1-i) : a=A*(2**i) b=B*(2**j) c=C*(2**(K-i-j)) if a=b):b*=2;t+=1 while(b>=c):c*=2;t+=1 if(t <= k):print(""Yes"") else:print(""No"")" p02601,s764762843,Accepted,"a = list(map(int, input().split())) b = int(input()) t = 0 s = 0 while a[1] <= a[0]: a[1] = a[1] * 2 t = t + 1 while a[2] <= a[1]: a[2] = a[2] * 2 s = s + 1 if t+s <=b: print(""Yes"") else: print(""No"")" p02601,s451234135,Accepted,"import sys A,B,C=map(int,input().split()) K=int(input()) for i in range(K+1): if(A=B): B*=2 elif(B>=C): C*=2 print(""No"")" p02601,s376684272,Accepted,"import sys from math import sqrt, gcd, ceil, log from bisect import bisect, bisect_left from collections import defaultdict, Counter, deque from heapq import heapify, heappush, heappop inp = sys.stdin.readline read = lambda: list(map(int, inp().strip().split())) def main(): a, b, c = read(); k = int(input()) # k -= 1 while b <= a: b *= 2 k -= 1 while c <= b: c *= 2; k -= 1 print(""YNeos""[k < 0::2]) if __name__ == ""__main__"": main()" p02601,s259281623,Accepted,"import sys import math def get_array(): return list(map(int, sys.stdin.readline().strip().split())) def get_ints(): return map(int, sys.stdin.readline().strip().split()) def input(): return sys.stdin.readline().strip() a,b,c=get_ints() k=int(input()) flag=0 for i in range(k+1): if b>a and c>b: flag=1 break else: if b<=a: b=b*2 else: c=c*2 if flag==1: print(""Yes"") else: print(""No"") " p02601,s786637125,Accepted,"a, b, c = map(int, input().split()) k = int(input()) m = 0 while a >= b: m += 1 b *= 2 while b >= c: m += 1 c *= 2 if m <= k: print('Yes') else: print('No')" p02601,s408363370,Accepted,"A,B,C = map(int,input().split()) K = int(input()) for i in range(K): if B <= A: B *= 2 continue if C <= B: C *= 2 continue if A < B < C: print(""Yes"") else: print(""No"")" p02601,s120211268,Accepted,"A, B, C = list(map(int, input().split())) K = int(input()) count = 0 while A >= B: B *= 2 count += 1 while B >= C: C *= 2 count += 1 print('Yes' if count <= K else 'No')" p02601,s037349895,Accepted,"# coding: utf-8 # Your code here! import sys read = sys.stdin.read readline = sys.stdin.readline a,b,c,k = map(int, read().split()) v = 0 while b <= a: b *= 2 v += 1 while c <= b: c *= 2 v += 1 if v <= k: print(""Yes"") else: print(""No"") " p02601,s387220849,Accepted,"a,b,c = map(int,input().split()) K = int(input()) j = K for i in range(K): if b-a>0: break b *=2 if b-a>0: j = K-(i+1) break if b-a<=0: print('No') exit() if j==0: if c-b >0: print('Yes') exit() if c*(2**j)-b >0: print('Yes') else: print('No')" p02601,s279383310,Accepted,"a,b,c=map(int,input().split()) k=int(input()) while b<=a and k>=1: b*=2 k-=1 while c<=b and k>=1: c*=2 k-=1 if c>b>a: print(""Yes"") else: print(""No"") " p02601,s581871703,Accepted,"A,B,C = map(int,input().split()) K = int(input()) for x in range(K): if A= b): k -= 1 b *= 2 while(b >= c): k -= 1 c *= 2 if(k >= 0): print('Yes') else: print('No')" p02601,s251211431,Accepted,"A, B, C = map(int, input().split()) K = int(input()) for i in range(K): if A < B < C: print(""Yes"") exit() elif A <= C <= B: C *= 2 elif B <= A <= C: B *= 2 elif B <= C <= A: C *= 2 elif C <= A <= B: C *= 2 elif C <= B <= A: C *= 2 if A < B < C: print(""Yes"") else: print(""No"")" p02601,s402019839,Accepted,"import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 MOD = 1000000007 def main(): A, B, C, K = map(int, read().split()) ans = 0 while A >= B: B *= 2 ans += 1 while B >= C: C *= 2 ans += 1 if ans <= K: print('Yes') else: print('No') return if __name__ == '__main__': main() " p02601,s912489353,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 if A < B < C: print('Yes') else: print('No')" p02601,s173949507,Accepted,"a, b, c = list(map(int, input().split())) k = int(input()) for i in range(k): if a >= b: b *= 2 elif b >= c: c *= 2 if a < b < c: print(""Yes"") else: print(""No"")" p02601,s373582810,Accepted,"a,b,c = map(int,input().split()) k=int(input()) ans=0 while a>=b: b=2*b ans+=1 while b>=c: c=2*c ans+=1 if ans>k: print(""No"") else: print(""Yes"")" p02601,s561548811,Accepted,"import sys input=sys.stdin.buffer.readline import os from math import* r,g,b=map(int,input().split()) k=int(input()) while g<=r and k>0: g*=2 k-=1 while b<=g and k>0: b*=2 k-=1 if b>g and g>r: print(""Yes"") else: print(""No"") " p02601,s281142131,Accepted,"a,b,c=map(int,input().split()) k=int(input()) for i in range(k): if a>=b: b*=2 else: c*=2 if a= b: b *= 2 else: c *= 2 if a < b and b < c: print(""Yes"") else: print(""No"")" p02601,s965992421,Accepted,"R, G, B = map(int, input().split()) K = int(input()) ng = True for ig in range(K): ib = K - ig if G * (2**ig) > R and B * (2** ib) > G * (2**ig): ng = False break if ng: print('No') else: print(""Yes"") " p02601,s733610061,Accepted,"main=list(map(int,input().split())) k=int(input()) for i in range(k): if(main[0]>=main[1]): main[1]=main[1]*2 elif(main[1]>=main[2]): main[2]=main[2]*2 if(main[1]>main[0] and main[2]>main[1]): print('Yes') else: print('No')" p02601,s452326773,Accepted,"a, b, c = map(int, input().split()) k = int(input()) ans = ""No"" for ia in range(k + 1): for ib in range(k + 1): for ic in range(k + 1): if ia + ib + ic > k: break if (b * 2 ** ib > a * 2 ** ia) and (c * 2 ** ic > b * 2 ** ib): ans = ""Yes"" print(ans) " p02601,s605513257,Accepted,"a, b, c = map(int, input().split()) k = int(input()) count = 0 flag = 1 while 1: if count > k: flag = 0 break if b > a: break b = 2 * b count += 1 while 1: if count > k: flag = 0 if c > b: break c = 2 * c count += 1 if flag == 0: print(""No\n"") else: print(""Yes\n"")" p02601,s141176701,Accepted,"a,b,c= map(int,input().split()) k = int(input()) for i in range(k): if b <= a : b *= 2 elif c <= b: c *= 2 if b > a and c > b: print(""Yes"") else: print(""No"")" p02601,s416166324,Accepted,"A, B, C = map(lambda x: int(x), input().split("" "")) K = int(input()) for _ in range(K): if A >= B: B *= 2 else: C *= 2 if A < B < C: print(""Yes"") else: print(""No"")" p02601,s397378277,Accepted,"A, B, C = map(int,input().split()) K = int(input()) flag = False for i in range(0, K+1): for j in range(0, K+1): for k in range(0, K+1): x = A * 2**i y = B * 2**j z = C * 2**k # print(x, y, z) if x < y < z and i + j + k <= K: flag = True if flag == True: print('Yes') else: print('No')" p02601,s930154616,Accepted,"a, b, c = map(int, input().split()) k = int(input()) cnt = 0 while True: if a < b: break cnt += 1 b *= 2 while True: if b < c: break cnt += 1 c *= 2 if cnt > k: print(""No"") else: print(""Yes"")" p02601,s520757960,Accepted,"A, B, C = map(int, input().split()) K = int(input()) for _ in range(K): if A >= B: B *= 2 elif B >= C: C *= 2 else: C *= 2 if (B > A) and (C > B): print ('Yes') else: print ('No')" p02601,s167570516,Accepted,"A, B, C = map(int, input().split()) K = int(input()) c = 0 while A>=B: B *= 2 c += 1 while B>= C: C *= 2 c += 1 print(""Yes"" if c<=K else ""No"")" p02601,s500794577,Accepted,"import sys input = sys.stdin.readline def main(): r,g,b = map(int, input().split()) k = int(input()) for i in range(k): for j in range(k): if i+j > k: continue if r*2**i < g*2**j < b*2**(k-i-j): print('Yes') return print('No') main()" p02601,s839704550,Accepted,"a = list(map(int,input().split())) b=int(input()) for i in range(b): if a[0]>=a[1]: a[1]=a[1]*2 else: if a[1]>=a[2]: a[2]=a[2]*2 if a[0]= b: b *= 2 elif b >= c: c *= 2 if a < b and b < c: print(""Yes"") else: print(""No"") " p02601,s331938931,Accepted,"a, b, c = map(int, input().split()) k = int(input()) ans = 0 while True: if b <= a: b *= 2 ans+=1 elif c <= b: c *= 2 ans += 1 if a < b and b < c: break if ans > k: print('No') else: print('Yes')" p02601,s639224506,Accepted,"A, B, C = map(int, input().split()) K = int(input()) cnt = 0 while B <= A: B *= 2 cnt += 1 while C <= B: C *= 2 cnt += 1 print(""Yes"" if cnt <= K else ""No"") " p02601,s395490512,Accepted,"import itertools A,B,C = map(int,input().split()) N = int(input()) for i in range(N): for j in range(N): k = N-(i+j) P = A*pow(2,i) Q = B*pow(2,j) R = C*pow(2,k) #print(A,B,C,C>B) if R > Q and Q > P: print(""Yes"") exit() print(""No"")" p02601,s833679711,Accepted,"a,b,c=map(int,input().split()) k=int(input()) if c>b and b>a: print(""Yes"") else: if b<=a: while(b<=a and k>0): b=b*2 k-=1 if c<=b: while(c<=b and k>0): c=c*2 k-=1 if c>b and b>a: print(""Yes"") else: print(""No"")" p02601,s515844283,Accepted,"a, b, c = map(int, input().split()) k = int(input()) cnt = 0 for _ in range(k+1): if b <= a: b *= 2 cnt += 1 else: break for _ in range(k+1): if c <= b: c *= 2 cnt += 1 else: break if cnt > k: print(""No"") else: print(""Yes"")" p02601,s515638072,Accepted,"a, b, c = map(int, input().split()) k = int(input()) e = 0 while a >= b: b *= 2 e += 1 while b >= c: c *= 2 e += 1 #print(e, k) if e > k: print('No') else: print('Yes')" p02601,s175281978,Accepted,"a, b, c = list(map(int, input().split())) k = int(input()) for _ in range(k): if not a < b: b *= 2 elif not b < c: c *= 2 if a < b and b < c: print('Yes') else: print('No')" p02601,s917133036,Accepted,"a,b,c = list(map(int,input().split())) k = int(input()) count = 0 while b <= a: count += 1 b = 2 * b while c <= b: count += 1 c = c * 2 if count <= k: print(""Yes"") else: print(""No"")" p02601,s680719037,Accepted,"from math import log2, ceil a, b, c = map(int, input().split()) k = int(input()) # n >= log2((a+1)/b) bi = ceil(log2((a+1) / b)) bi = max(bi, 0) b *= pow(2, bi) ci = ceil(log2((b+1) / c)) ci = max(ci, 0) if bi + ci <= k: print(""Yes"") else: print(""No"")" p02601,s701261202,Accepted,"a,b,c = map(int, input().split()) k = int(input()) for ai in range(k+1): for bi in range(k+1): for ci in range(k+1): if not (ai + bi + ci == k): continue newA = a * (2 ** ai) newB = b * (2 ** bi) newC = c * (2 ** ci) if newB > newA and newC > newB: print('Yes') exit() print('No')" p02601,s979370834,Accepted,"A,B,C = map(int,input().split()) K = int(input()) ans = 0 while A >= B: B *= 2 ans += 1 while B >= C: C *= 2 ans += 1 if ans <= K: print(""Yes"") else: print(""No"") " p02601,s307696633,Accepted,"A,B,C=map(int,input().split()) K=int(input()) while K: if A>=B: B*=2 K-=1 elif B>=C: C*=2 K-=1 else: break #print(A,B,C) if A=b: b*=2 ans+=1 while b>=c: c*=2 ans+=1 if ans<=k: print(""Yes"") else: print(""No"")" p02601,s572815994,Accepted,"a, b, c = map(int, input().split()) k = int(input()) while k > 0 and a >= b: k -= 1 b *= 2 while k > 0 and b >= c: k -= 1 c *= 2 if a < b < c: print(""Yes"") else: print(""No"")" p02601,s316046673,Accepted,"import sys readline = sys.stdin.buffer.readline def even(n): return 1 if n%2==0 else 0 a,b,c = map(int,readline().split()) k = int(readline()) ct = 0 while a >= b: b*= 2 ct += 1 while b >= c: c *= 2 ct += 1 if ct <= k: print(""Yes"") else: print(""No"") " p02601,s034024199,Accepted,"import sys input=sys.stdin.readline a,b,c=map(int,input().split()) k=int(input()) for _ in range(k): if a>=b: b*=2 else: if b>=c: c*=2 if a= b: b *= 2 minMagic += 1 while b >= c: c *= 2 minMagic += 1 if minMagic <= k: print(""Yes"") else: print(""No"")" p02601,s270603614,Accepted,"a, b, c = map(int, input().split()) k = int(input()) while a >= b: b *= 2 k -= 1 while b >= c: c *= 2 k -= 1 if 0 <= k: print(""Yes"") else: print(""No"")" p02601,s472949939,Accepted,"a,b,c=map(int,input().split()) k=int(input()) cnt=0 while a>=b: b*=2 cnt+=1 while b>=c: c*=2 cnt+=1 print(""Yes"") if cnt <=k else print(""No"")" p02601,s004349401,Accepted,"a, b, c = map(int, input().split()) k = int(input()) counter = 0 while b <= a: b *= 2 counter += 1 while c <= b: c *= 2 counter += 1 if counter <= k: print('Yes') else: print('No')" p02601,s455256998,Accepted,"a, b, c = map(int, input().split()) k = int(input()) while a >= b: b *= 2 k -= 1 while b >= c: c *= 2 k -= 1 print(""Yes"" if k >= 0 else ""No"")" p02601,s830588668,Accepted,"a,b,c = map(int, input().split()) k = int(input()) cnt = 0 while a >= b: b *= 2 cnt += 1 while b >= c: c *= 2 cnt += 1 print(""Yes"") if k >= cnt else print(""No"")" p02601,s550049550,Accepted,"A,B,C = map(int, input().split()) K = int(input()) for i in range(K): if A < B: if B=b and k>0: k-=1 b*=2 while b>=c and k>0: k-=1 c*=2 if c>b and b>a: print('Yes') else: print('No') " p02601,s488210461,Accepted,"A,B,C = map(int,input().split()) K = int(input()) for _ in range(K): if(B<=A): B=B*2 elif(C<=B): C=C*2 if((B>A) and (C>B)): print('Yes') else: print('No')" p02601,s804178161,Accepted,"import sys sys.setrecursionlimit(10 ** 7) input = sys.stdin.readline f_inf = float('inf') mod = 10 ** 9 + 7 def resolve(): a, b, c = map(int, input().split()) k = int(input()) while k and a >= b: b *= 2 k -= 1 while k and b >= c: c *= 2 k -= 1 print(""Yes"" if a < b < c else ""No"") if __name__ == '__main__': resolve() " p02601,s190127117,Accepted,"A,B,C = map(int,input().split()) K = int(input()) for i in range(K): if A >= B: B = B*2 else: C = C*2 print(""Yes"" if A < B and B < C else ""No"")" p02601,s993996975,Accepted,"A, B, C = map(int, input().split()) K = int(input()) while A >= B: B *= 2 K -= 1 if K < 0: print(""No"") exit() while B >= C: C *= 2 K -= 1 if K < 0: print(""No"") exit() print(""Yes"")" p02601,s415949545,Accepted,"a,b,c=map(int,input().split()) k=int(input()) for i in range(1,k+1): if a>=b>=c or a>=c>=b: c=c*2 elif b>=a>=c or b>=c>=a: c=c*2 elif c>=b>a: c=c*2 elif c>b==a: b=b*2 elif c>a>=b: b=b*2 if c>b>a: print('Yes') else: print('No') " p02601,s225820494,Accepted,"A, B, C = map(int, input().split()) K = int(input()) cnt = 0 while A>=B: cnt+=1 B*=2 while B>=C: cnt+=1 C*=2 print(""Yes"" if cnt<=K else ""No"") " p02601,s370785777,Accepted,"A, B, C = map(int, input().split() ) t = 0 while A >= B: t += 1 B *= 2 while B >= C: t += 1 C *= 2 K = int(input()) print('Yes') if t <= K else print('No')" p02601,s164311614,Accepted,"A,B,C=map(int,input().split()) K=int(input()) ans='No' for i in range(K+1): if A= c or b >= c: c *= 2 else: b *= 2 if a < b < c: ans = 'Yes' else: ans = 'No' print(ans)" p02601,s187099712,Accepted,"A, B, C = map(int,input().split()) K = int(input()) cnt = 0 while A >= B: B *= 2 cnt += 1 while B >= C: C *= 2 cnt += 1 if cnt <= K: print('Yes') else: print('No')" p02601,s989275912,Accepted,"a,b,c=map(int,input().split()) k=int(input()) abc=[a,b,c] for i in range(k): if a>=b: b*=2 elif a=c: c*=2 else: c*=2 if a a while a >= b: b *= 2 cnt += 1 # let c > b while b >= c: c *= 2 cnt += 1 if k < cnt: print('No') else: print('Yes')" p02601,s511421409,Accepted,"a = list(map(int, input().split())) b = list(map(int, input().split())) c = 0 while a[0] >= a[1]: a[1] = a[1] * 2 c += 1 while a[1] >= a[2]: a[2] = a[2] * 2 c += 1 if c <= b[0]: print(""Yes"") else: print(""No"")" p02601,s166846131,Accepted,"a, b,c = map(int, input().split()) K = int(input()) count = 0 while a >= b: b *= 2 count += 1 while b >= c: c *= 2 count += 1 print(""Yes"" if count <= K else ""No"")" p02601,s142634729,Accepted,"A, B, C = map(lambda x:int(x), input().split(' ')) K = int(input()) count = 0 while count < K: if A >= B: B *= 2 count+=1 elif B >= C: C *= 2 count+=1 else: break if A < B < C: print('Yes') else: print('No')" p02601,s446631156,Accepted,"A, B, C = map(int, input().split()) K = int(input()) for k in range(K): if A >= B: B = 2*B continue elif B >= C: C = 2*C continue elif A >= C: C = 2*C continue if A < B and B < C: print(""Yes"") else: print(""No"")" p02601,s462341259,Accepted,"A, B, C = map(int, input().split()) K = int(input()) cnt = 0 while True: if A >= B: B *= 2 cnt += 1 if B >= C: C *= 2 cnt += 1 if (A < B) & (B < C): break print(""Yes"" if cnt <= K else ""No"")" p02601,s899662575,Accepted,"a,b,c = map(int,input().split()) k = int(input()) res = 0 while a>=b: b *= 2 res += 1 while b>=c: c *= 2 res += 1 if res<=k: print(""Yes"") else: print(""No"")" p02601,s872448056,Accepted,"A, B, C = map(int,input().split()) K = int(input()) flag = False for p in range(8): for q in range(8): for r in range(8): if A * 2 ** p < B * 2 ** q < C * 2 ** r and p + q + r <= K: flag = True if flag: print('Yes') else: print('No')" p02601,s493390192,Accepted,"a,b,c = map(int,input().split()) k = int(input()) cnt = 0 while not(a= b: b = 2*b else: if b >= c: c = 2*c cnt += 1 if cnt <= k: print(""Yes"") else: print(""No"")" p02601,s693180660,Accepted,"A, B, C = map(int, input().split()) K = int(input()) for k in range(K): if B <= A: B *= 2 elif C <= B: C *= 2 if A < B and B < C: print('Yes') else: print('No')" p02601,s382882654,Accepted,"a,b,c = map(int,input().split()) k = int(input()) while((not b>a) and k): b*=2 k-=1 while((not c>b) and k): c*=2 k-=1 if(a0 and b<=a: b*=2 k -= 1 while k>0 and c<=b: c *= 2 k -= 1 print('Yes' if c>b>a else 'No')" p02601,s349331087,Accepted,"import itertools A, B, C = map(int, input().split()) K = int(input()) targets = [A, B, C] answer = 'No' def check(targets): if targets[1] > targets[0] and targets[2] > targets[1]: return True else: return False cases = itertools.product([0, 1, 2], repeat=K) for case in cases: copy_targets = targets.copy() for i in case: copy_targets[i] = copy_targets[i] * 2 if check(copy_targets): answer = 'Yes' break print(answer)" p02601,s276494427,Accepted,"import sys def input(): return sys.stdin.readline()[:-1] def main(): 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"") if __name__ == ""__main__"": main()" p02601,s885338724,Accepted,"a, b, c = map(int, input().split()) k = int(input()) ans = ""No"" for _ in range(k): if c <= b: c *= 2 elif b <= a: b *= 2 if c > b and b > a: ans = ""Yes"" break print(ans)" p02601,s297379289,Accepted,"a,b,c = map(int,input().split()) k = int(input()) while k>0 and b <= a: b*=2 k-=1 while k>0 and c <=b: c*=2 k-=1 if a = B: B *= 2 cnt += 1 while B >= C: C *= 2 cnt += 1 if cnt <= K: print(""Yes"") else: print(""No"") " p02601,s720601969,Accepted,"def main(): a, b, c = map(int, input().split()) k = int(input()) while b <= a: b *= 2 k -= 1 if k < 0: print('No') exit() while c <= b: c *= 2 k -= 1 if k < 0: print('No') exit() if a < b < c: print('Yes') else: print('No') if __name__ == '__main__': main()" p02601,s110406381,Accepted,"a, b, c = map(int, input().split()) k = int(input()) while a >= b and k > 0: b *= 2 k -= 1 while b >= c and k > 0: c *= 2 k -= 1 print('Yes' if a < b < c else 'No')" p02601,s491572980,Accepted,"a, b, c = map(int, input().split()) k = int(input()) cnt = 0 while a >= b: b *= 2 cnt += 1 while b >= c: c *= 2 cnt += 1 print(""Yes"" if k >= cnt else ""No"")" p02601,s642432037,Accepted,"A, B, C = map(int, input().split()) K = int(input()) k = 0 ans = 'Yes' while k <= K and (B <= A or C <= B): if B <= A: B *= 2 elif C <= B: C *= 2 if k == K: ans = 'No' k += 1 print(ans)" p02601,s011611063,Accepted,"a, b, c = map(int, input().split()) k = int(input()) n = 0 while a >= b: b *= 2 n += 1 while b >= c: c *= 2 n += 1 print('Yes' if n <= k else 'No') " p02601,s628856257,Accepted," def main(): A, B, C = (int(x) for x in input().split("" "")) K = int(input()) for i in range(K): if A < B: if B < C: print(""Yes"") exit() C = 2*C else: B = 2*B if A < B and B < C: print(""Yes"") else: print(""No"") if __name__ == '__main__': main() " p02601,s481419207,Accepted,"A, B, C = map(int, input().split()) K = int(input()) cnt = 0 if A>=B: for i in range(K): B = 2*B cnt += 1 if A=C: for j in range(K-cnt): C = 2*C if A= b: b *= 2 else: c *= 2 if a < b and b < c: print('Yes') else: print('No')" p02601,s548640505,Accepted,"#!/usr/bin/env python3 import sys def judge(a, b, c, k): while a >= b: b *= 2 k -= 1 while b >= c: c *= 2 k -= 1 return k >= 0 def main(): a, b, c = (int(z) for z in input().split()) k = int(input()) if judge(a, b, c, k): print(""Yes"") else: print(""No"") if __name__ == '__main__': main()" p02601,s643245029,Accepted,"a,b,c=(int(x) for x in 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') " p02601,s982754347,Accepted,"N,M,K = map(int,input().split()) num = int(input()) while num>0: if K<=M or K<=N: K = K*2 num -= 1 elif M<=N: M = M*2 num -= 1 elif M>N: K = K*2 num -= 1 if N=b): b=b*2 e=e+1 while(ea and c>b and e<=n): print('Yes') else: print('No')" p02601,s075595354,Accepted,"def main(): A,B,C = map(int,input().split()) K = int(input()) for k in range(K): if A >= B: B *= 2 elif B >= C: C *= 2 if A < B and B < C: print('Yes') else: print('No') if __name__ == '__main__': main()" p02601,s588470114,Accepted,"li = list(map(int, input().split())) k = int(input()) for i in range(k): if li[0] >= li[1]: li[1]=li[1]*2 elif li[2] <= li[1]: li[2]=li[2]*2 if li[0] < li[1] and li[1] < li[2]: print(""Yes"") quit() print(""No"")" p02601,s655195475,Accepted,"a,b,c=map(int,input().split()) k=int(input()) s=0 while a>=b: b=2*b s+=1 while b>=c: c=2*c s+=1 if s<=k: print(""Yes"") else: print(""No"")" p02601,s598668766,Accepted,"a,b,c = list(map(int,input().split())) k = int(input()) count=0 while True: if b>a: break count+=1 b=b*2 #print(b) while True: if c>b: break count+=1 c=c*2 if count <= k: print('Yes') else: print('No')" p02601,s119269553,Accepted,"def resolve(): a,b,c = list(map(int, input().split())) k = int(input()) # a < b < c cnt = 0 while a >= b: b *= 2 cnt += 1 while b >= c: c *= 2 cnt += 1 if cnt <= k: print('Yes') else: print('No') resolve()" p02601,s873844488,Accepted,"cards = input() times = int(input()) card = cards.split("" "") result = ""No"" wktimes = 0 idx = 0 div = int(card[0]) / int(card[1]) while ( 2 ** idx ) <= div: idx = idx + 1 wktimes = idx card[1] = int(card[1]) * ( 2 ** idx) idx = 0 div = int(card[1]) / int(card[2]) while ( 2 ** idx ) <= div: idx = idx + 1 wktimes = wktimes + idx card[2] = int(card[2]) * ( 2 ** idx) if wktimes <= times: result = ""Yes"" print (result)" p02601,s671141294,Accepted,"A,B,C = map(int, input().split()) K = int(input()) for i in range(K): if A >= B: B *= 2 else: C *= 2 if A < B and B < C: print('Yes') else: print('No') " p02601,s596952026,Accepted,"a,b,c=map(int,input().split()) k=int(input()) cnt=0 for i in range(k): if b>a: break else: b*=2 cnt+=1 for i in range(k): if c>b: break else: c*=2 cnt+=1 #print(a,b,c) if cnt>k or c<=b or a>=b: print('No') else: print('Yes')" p02601,s192448714,Accepted,"a, b, c = list(map(int, input().split())) k = int(input()) count = 0 while True: if b > a: break b *= 2 count += 1 while True: if c > b: break c *= 2 count += 1 if count <= k: print(""Yes"") else: print(""No"")" p02601,s714981858,Accepted,"a,b,c=map(int,input().split()) k = int(input()) flag = False for i in range(1,k+2): for j in range(1,k-i+3): for d in range(1,k-i-j+4): if (a*(2**(i-1)))<(b*(2**(j-1)))<(c*(2**(d-1))): flag = True if flag == True: print('Yes') else: print('No')" p02601,s136931195,Accepted,"A, B, C = map(int, input().split()) K = int(input()) while A >= B: B *= 2 K -= 1 while B >= C: C *= 2 K -= 1 if K >= 0: print('Yes') else: print('No')" p02601,s812800059,Accepted,"read = lambda: list(map(int, input().split())) card = read() k = int(input()) for _ in range(k): if card[0] >= card[1]: card[1] *= 2 elif card[1] >= card[2]: card[2] *= 2 if card[0] < card[1] < card[2]: print(""Yes"") else: print(""No"")" p02601,s808960769,Accepted,"def main(): A, B, C = map(int, input().split()) K = int(input()) while K>0: if A < B: break else: B*=2 K-=1 while K>0: if B < C: break else: C*=2 K-=1 ans = ""No"" if A= B: B *= 2 K -= 1 while K and B >= C: C *= 2 K -= 1 print('Yes' if A < B < C else 'No')" p02601,s528610477,Accepted,"#!/usr/bin/env python3 # -*- coding: utf-8 -*- import array from bisect import * from collections import * import fractions import heapq from itertools import * import math import random import re import string import sys R, G, B = map(int, input().split()) K = int(input()) for k in range(K): if G <= R: G *= 2 elif B <= G: B *= 2 else: B *= 2 if B > G > R: print(""Yes"") else: print(""No"") " p02601,s984056542,Accepted,"r, g, b = map(int, input().split()) K = int(input()) while r >= g: g *= 2 K -= 1 while g >= b: b *= 2 K -= 1 if K >= 0: print(""Yes"") else: print(""No"")" p02601,s742093955,Accepted,"a, b, c = map(int, input().split()) k = int(input()) for _ in range(k + 1): if a >= b: b *= 2 continue elif b >= c: c *= 2 continue else: print(""Yes"") break else: print(""No"") " p02601,s380835127,Accepted,"from itertools import product def f(n): tmp = [range(3)] * n return product(*tmp) a, b, c = map(int, input().split()) K = int(input()) flag = 0 for I in f(K): x, y, z = a, b, c for i in I: if i == 0: x *= 2 elif i == 1: y *= 2 else: z *= 2 if x < y < z: flag = 1 break print(['No', 'Yes'][flag])" p02601,s523561210,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(""Yes"" if c>b>a else ""No"") " p02601,s341444920,Accepted,"import sys sys.setrecursionlimit(10**6) a, b, c = map(int, input().split()) k = int(input()) trial = 0 while trial <= k: if b > a and c > b: print('Yes') break elif b <= a: b *= 2 trial += 1 elif c <= b: c *= 2 trial += 1 else: print('No')" p02601,s871282390,Accepted,"#!/usr/bin/env python3 import math numbers = input().split("" "") a = int(numbers[0]) b = int(numbers[1]) c = int(numbers[2]) k = int(input()) for i in range(k): if a < b: break b *= 2 k -= 1 c = c * (2 ** k) if (a < b) and (b < c): print(""Yes"") else: print(""No"") " p02601,s225572940,Accepted,"A, B, C = map(int, input().split()) K = int(input()) cnt = 0 while not(B > A): B *= 2 cnt += 1 while not(C > B): C *= 2 cnt += 1 print('Yes' if cnt <= K else 'No')" p02601,s127502616,Accepted,"r, g, b = map(int, input().split()) k = int(input()) for i in range(k): if b <= r or b <= g: b *= 2 elif g <= r: g *= 2 else: b *= 2 if r < g and g < b: print('Yes') else: print('No') " p02601,s682818956,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 if A < B < C: print('Yes') else: print('No') " p02601,s294195486,Accepted,"import sys input = lambda : sys.stdin.readline().rstrip() sys.setrecursionlimit(max(1000, 10**9)) write = lambda x: sys.stdout.write(x+""\n"") a,b,c = list(map(int, input().split())) k = int(input()) ans = 0 while a>=b: b *= 2 ans += 1 while b>=c: c *= 2 ans += 1 if ans<=k: print(""Yes"") else: print(""No"")" p02601,s208273272,Accepted,"R,G,B=map(int,input().split()) K=int(input()) for _ in range (K) : if R < G : pass else: G*=2 continue if G < B : pass else: B*=2 continue if R < G < B : print('Yes') else : print('No')" p02601,s084677367,Accepted,"a,b,c=map(int,input().split()) k=int(input()) cnt=0 while a>=b: b*=2 cnt+=1 while b>=c: c*=2 cnt+=1 if cnt<=k: print('Yes') else: print('No')" p02601,s579313293,Accepted,"A, B, C = map(int, input().split()) K = int(input()) i = 0 while B<=A: i += 1 B *= 2 while C<=B: i += 1 C *= 2 if i<=K: print('Yes') else: print('No') " p02601,s768003002,Accepted,"import math A,B,C=map(int,input().split()) K=int(input()) ans=0 while A>=B: B*=2 ans+=1 while B>=C: C*=2 ans+=1 if ans>K: print(""No"") else: print(""Yes"")" p02601,s714526531,Accepted,"def resolve(): a,b,c = map(int, input().split()) k=int(input()) while True: if a=b: b*=2 k-=1 elif b>=c: c*=2 k-=1 resolve()" p02601,s794268644,Accepted,"a,b,c=map(int,input().split()) k=int(input()) ans=0 while(b<=a): b<<=1 ans+=1 while(c<=b): c<<=1 ans+=1 if ans<=k: print(""Yes"") else: print(""No"") " p02601,s358706623,Accepted,"A, B, C = list(map(int, input().split())) K = int(input()) for i in range(K): if B <= A: B = B * 2 #print(""B="",B) else: C = C * 2 #print(""C="",C) if C > B and B > A: print(""Yes"") else: print(""No"")" p02601,s785060370,Accepted,"A,B,C = list(map(int,input().split())) K = int(input()) ans = 0 for i in range(K): if A < B * (2**i) < C * (2**(K-i)): ans += 1 else: pass if ans > 0: print(""Yes"") else: print(""No"") " p02601,s088390443,Accepted,"a,b,c=map(int,input().split()) k=int(input()) i=0 while True: if ak: print(""No"")" p02601,s665245350,Accepted,"a, b, c = map(int,input().split()) k = int(input()) for i in range(k): if a>=b: b = 2*b elif b>=c: c = 2*c else: continue if a=b: b=b*2 k=k-1 while b>=c: c=c*2 k=k-1 if k>=0: print(""Yes"") else: print(""No"")" p02601,s200532665,Wrong Answer,"A,B,C = map(int,input().split()) K = int(input()) for num in range(K): if (A >= B) : B = 2*B elif B >= C: C = 2*C else: A = A *2 if A B: for i in range(K): B = B*2 cnt = cnt + 1 if A < B: break print(B) if B > C: for j in range(K): C = C*2 cnt = cnt + 1 if B < C: break print(C) print(cnt) if cnt <= K: print('Yes') else: print('No') " p02601,s981797984,Wrong Answer,"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('Yes') if a < b < c else print('No')" p02601,s724380507,Wrong Answer,"A, B, C = map(int,(input().split())) K = int(input()) for kkk in range(0, K-1): if B < A: B *= 2 elif C < B: C *= 2 if A < B and B < C: print('Yes') else: print('No')" p02601,s154678414,Wrong Answer,"R,G,B=map(int,input().split()) K=int(input()) #print(R,G,B,K) for i in range(K): if(B<=G): B*=2 if(G<=R): G*=2 #print(R,G,B,K) if(R b: i = 1 while b*(2**i) < a+1: i += 1 n += i #print(n,i) if a+2 > c: i = 1 while c*(2**i) < a+2: i += 1 n += i #print(n,i) if k >= n: print('Yes') else: print('No') " p02601,s213931257,Wrong Answer,"A, B, C = map(int, input().split()) K = int(input()) for i in range(K): for j in range(K): for k in range(K): if i+j+k != K: continue A = A*pow(2,i) B = B*pow(2,j) C = C*pow(2,k) if A < B and B < C: print(""Yes"") exit() print(""No"")" p02601,s658462377,Wrong Answer,"import sys import math import fractions from collections import defaultdict stdin = sys.stdin ns = lambda: stdin.readline().rstrip() ni = lambda: int(stdin.readline().rstrip()) nm = lambda: map(int, stdin.readline().split()) nl = lambda: list(map(int, stdin.readline().split())) A,B,C=nm() K=int(input()) count=0 while(B 2 * R or B > 2 * G: print(""Yes"") else: print(""No"")" p02601,s551578825,Wrong Answer,"r, g, b = map(int, input().split()) k = int(input()) for i in range(k): if r < g < b: break else: if b < g and b < r: b *= 2 elif g < r: g *= 2 else: r *= 2 if r < g < b: print(""Yes"") else: print(""No"")" p02601,s373366789,Wrong Answer,"import numpy as np A = [int(x) for x in input().split()] src = np.array(A) K = int(input()) flag = 0 for i in range(K): if(src[0] < src[1]): if(src[1] < src[2]): flag = 1 break else: src[2] *= 2 else: src[1] *= 2 if(src[0] < src[1]): if(src[1] < src[2]): print(""yes"") else: print(""no"")" p02601,s311190578,Wrong Answer,"r, g, b = [int(x) for x in input().split()] m = int(input()) if g < r: while g < r: g *= 2 m += 1 if b < g: while b < g: b *= 2 m += 1 print(""Yes"" if r < g < b else ""No"") " p02601,s697412002,Wrong Answer,"i = list(map(int, input().split())) K = int(input()) red=i[0] green=i[1] blue=i[2] success=0 for num in range(K): if green < red: green = green*2 elif blue < green: blue = blue*2 if (blue > green and green > red): print(""Yes"") else: print(""No"")" p02601,s953859237,Wrong Answer,"i = list(map(int, input().split())) K = int(input()) red=i[0] red_double=i[0]*2 green=i[1] green_double=i[1]*2 blue=i[2] blue_double=i[2]*2 success=0 for num in range(K): if green < red: green = green_double green_double = green_double*2 elif blue < green: blue = blue_double blue_double = blue_double*2 if (blue > green and green > red): success=1 if success == 1: print(""Yes"") else: print(""No"")" 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 and cnt <= K: B = B*2 cnt += 1 if cnt >= K and B > C: print(""No"") else: while B > C and cnt < K: C = C*2 cnt += 1 if C > B: print(""Yes"") else: print(""No"") " p02601,s572935316,Wrong Answer,"import sys input = sys.stdin.readline def main(): A, B, C = map(int, input().split()) K = int(input()) for i in range(K): if A < B: break B *= 2 K -= i for i in range(K): if B < C: break C *= 2 if A < B and B < C: print('Yes') else: print('No') if __name__ == '__main__': main()" p02601,s114264850,Wrong Answer,"a, b, c = map(int, input().split()) k = int(input()) c = c*2 if k > 1: for i in range(1,k): if b < c: b = b*2 elif b > c: c = c*2 if a < b and b < c: print('Yes') else: print('No')" p02601,s401522636,Wrong Answer,"from math import ceil a,b,c=map(int,input().split()) k=int(input()) if b<=a: bm = ceil((a + 1) / b) b *= bm k -= (bm+1)//2 if c<=b: cm = ceil((b + 1) / c) k -= (cm+1)//2 if k<0: print(""No"") else: print(""Yes"") " p02601,s092455328,Wrong Answer,"a, b, c = map(int, input().split()) k = int(input()) for _ in range(k): if a >= b: b = b ** 2 elif b >= c: c = c ** 2 if a < b < c: print(""Yes"") else: print(""No"")" p02601,s353485525,Wrong Answer,"a, b,c = map(int, input().split()) k = int(input()) for i in range(k): if b > c: c *= 2 elif a > b: b *= 2 else: c *= 2 if (b > a) and (c > b): result = ""Yes"" else: result = ""No"" print(result)" p02601,s039361743,Wrong Answer,"A, B, C = map(int, input().split()) K = int(input()) a=0 for i in range(K): i += 1 if B*(2**i) > A: if C*(2**(K-i)) > B*(2**i): print('Yes') a=1 if a==0: print('No') " p02601,s286920558,Wrong Answer,"A, B, C = map(int, input().split()) K = int(input()) Ak = 0 for i in range(K): if A > B: B = B * 2 Ak = i else: break if K - Ak > 0: for j in range(K - Ak): if B > C: C = C * 2 else: print(""No"") exit() if A < B and B < C: print(""Yes"") else: print(""No"") " p02601,s003775795,Wrong Answer,"a, b, c = map(int, input().split()) k = int(input()) flg = False for i in range(k+1): b = (2**i) * b c = (2**(k-i)) * c if a < b < c: flg = True break if flg: print('Yes') else: print('No')" p02601,s808417201,Wrong Answer,"a, b, c = input().split() k = int(input()) for _ in range(k): if int(a) > int(b): b = int(b) * 2 else: c = int(c) * 2 if int(a) < int(b) and int(b) < int(c): print(""Yes"") else: print(""No"")" p02601,s584686000,Wrong Answer,"a,b,c = map(int,input().split()) k = int(input()) while k > 0: if a > b: b *= 2 k -= 1 else: break while k > 0: if b > c: c *= 2 k -= 1 else: break if a < b and b < c: print(""Yes"") else: print(""No"") " p02601,s838369463,Wrong Answer,"import io import os from collections import Counter, defaultdict, deque def solve(A, B, C, K): k = 0 while A >= B: B *= 2 k += 1 while B >= C: C *= 2 k += 1 if k <= K: return ""YES"" return ""NO"" if __name__ == ""__main__"": input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline A, B, C = [int(x) for x in input().split()] K, = [int(x) for x in input().split()] ans = solve(A, B, C, K) print(ans) " p02601,s112303874,Wrong Answer,"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 if a < b < c: print(""Yes"") else: print(""No"") " p02601,s729896807,Wrong Answer,"a,b,c = map(int, input().split()) x = int(input()) for _ in range(x): if a > b: b *= 2 elif b > c: c *= 2 if a < b and b < c: print('Yes') exit() print('No')" p02601,s800818810,Wrong Answer,"array = list(map(int, input().split(' '))) K = int(input()) for i in range(K): if array[2] == max(array): if array[0] > array[1]: array[1] = array[1] * 2 else: array[0] = array [0] * 2 else: array[2] = array[2] * 2 if array[0] < array[1] and array[1] < array[2]: print('Yes') else: print('No')" p02601,s168650668,Wrong Answer,"A,B,C=map(int,input().split()) K=int(input()) i=0 while B B: B *= 2 elif B > C: C *= 2 else: A *= 2 if A < B < C: print('Yes') else: print('No')" p02601,s069695616,Wrong Answer,"a = list(map(int,input().split())) k = int(input()) #青>緑>赤 r,g,b = 0,0,0 for i,num in enumerate(a): if i==0: r = num elif i==1: g = num elif i==2: b = num for i in range(k): if bg: b *= 2 elif gr: g *= 2 elif r*2g and g>r: print(""Yes"") else: print(""No"")" p02601,s223089097,Wrong Answer,"A, B, C = input().split("" "") K = int(input()) A, B, C = int(A), int(B), int(C) for i in range(K): if A > B: B = B*2 elif B > C: C = C*2 if B > A and C > B: print(""Yes"") else: print(""No"")" 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"")" p02601,s959839188,Wrong Answer,"r, g, b = map(int, input().split()) K = int(input()) while K > 0: if g < r: g *= 2 K -= 1 elif b < g: b *= 2 K -= 1 else: break if g > r and b > g: print(""Yes"") else: print(""No"") " p02601,s089547710,Wrong Answer,"import itertools l = list(map(int,input().split())) k = int(input()) p = list(itertools.combinations_with_replacement([0,1,2], k)) f = False ans = 0 for i in p: a = (l[0] * 2 * i.count(0) if i.count(0) else 1) b = (l[1] * 2 * i.count(1) if i.count(1) else 1) c = (l[2] * 2 * i.count(2) if i.count(2) else 1) if a b: b = 2 * b elif b > c: c = 2 * c # print(a, b, c) if a < b and b < c: print('Yes') exit() print('No')" p02601,s722562872,Wrong Answer,"a,b,c = map(int, input().split()) k = int(input()) ans = ""No"" for _ in range(k+1): if a < b and b < c: ans = ""Yes"" break elif b < a: b *= 2 elif c < b: c *= 2 print(ans)" p02601,s964394212,Wrong Answer,"a,b,c = map(int,input().split()) k = int(input()) res = True for i in range(k): if b > a: if c > b: break else: c *= 2 elif b < a: b *= 2 res = a < b < c if res: print(""Yes"") else: print(""No"") " p02601,s573850731,Wrong Answer,"A,B,C = map(int, input().split()) K = int(input()) for i in range(K): if A > B: B *= 2 else: C *= 2 if A < B and B < C: print('Yes') else: print('No') " p02601,s860204650,Wrong Answer,"a,b,c = map(int,input().split()) k = int(input()) i = 0 for i in range(k): if(b>c): c = c*2 elif(a>b): b = b*2 else: break if(a B: B *= 2 K -= 1 while B > C: C *= 2 K -= 1 if K >= 0 and A < B < C: print('Yes') else: print('No')" p02601,s061690972,Wrong Answer,"a,b,c=map(int,input().split()) k=int(input()) ans=[""Yes"",""no""] while b<=a: b*=2 k-=1 while c<=b: c*=2 k-=1 print(ans[0] if k>=0 else ans[1]) " p02601,s066300023,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 a b: b = b*2 elif b > c: c = c*2 if a < b and b < c: print(""Yes"") else: print(""No"")" p02601,s488256763,Wrong Answer,"import math a,b,c = [int(x) for x in input().split()] k = int(input()) a1,b1,c1 = math.log2(a),math.log2(b),math.log2(c) k1,k2 = 0,0 if b1B): K-=1 if K==0: print(""No"") exit() B=B*2 while(B>C): C=C*2 if K==1: break K-=1 if K==0: print(""No"") exit() print(""Yes"")" p02601,s142111888,Wrong Answer,"cards = list(map(int,input().split())) K = int(input()) for i in range(K): if cards[1]>cards[2]: cards[2]*=2 elif cards[0]>cards[1]: cards[1]=cards[1]*2 else : cards[0]*=2 if cards[0]= B: B *= 2 c += 1 if c >= K: break while B >= C: C *= 2 c += 1 if c >= K: break ans = 0 if A < B < C: ans = ""Yes"" else: ans = ""No"" print(ans)" p02601,s737492639,Wrong Answer,"R, G, B = list(map(int, input().split())) K = int(input()) def f(R,G,B): if RB: return 2 else: return 3 c = 0 fl = 0 while c <= K: c +=1 if f(R,G,B)==1: fl = 1 c = K+1 elif f(R,G,B)==2: B = B*2 else: G = G*2 if fl == 0: print(""No"") else: print(""Yes"")" 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 a a: x += i break else: print('No') quit() if 2*(k-x)*c > 2*x*b: print('Yes') else: print('No')" p02601,s573238826,Wrong Answer,"A,B,C = map(int,input().split()) K = int(input()) cnt = 0 if B <= A : while B < A : B = B*2 cnt += 1 break if C*(2**(K-cnt)) > B: print('Yes') else : print('No') elif B > A : if C*(2**K) > B : print('Yes') elif C*(2**K) <= B: print('No')" p02601,s158529074,Wrong Answer,"a,b,c = map(int , input().split()) k = int(input()) while(k>=1): if c a**2*x and c**2*z > b**2*y: ans += 1 if ans >= 1: print(""Yes"") else: print(""No"") " 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 aB: B *= 2 cnt += 1 for _ in range(K-cnt): if B>C: C *= 2 if (A= i1+i2+1: print(""Yes"") else: print(""No"") " p02601,s649317061,Wrong Answer,"a, b, c = map(int, input().split()) k = int(input()) while k > 0: if c < b: c*=2 elif b < a: b*=2 k-=1 if c>b>a: print(""Yes"") quit() print(""No"")" p02601,s550659544,Wrong Answer,"li = input().split() a=int(input()) magic = 0 for i in range(0,3): if li[0] >= li[1]: li[1] = li[1] * 2 magic = magic + 1 for i in range(0,3): if li[1] >= li[2]: li[2] = li[2] * 2 magic = magic + 1 if a >= magic: print(""Yes"") else: print(""No"")" p02601,s403379029,Wrong Answer,"A, B, C = input().split() A, B, C = [int(A), int(B), int(C)] K = int(input()) for i in range(K): if(B > C or A > C): C = C * 2 elif(A > B): B = B * 2 else: C = C * 2 if(C > B > A): print(""Yes"") else: print(""No"") " p02601,s877812492,Wrong Answer,"import sys r,g,b = map(int,input().split()) k = int(input()) #青>緑>赤 count = 0 if g*(2**k)>r: while gg and k<=count: print(""Yes"") else: print(""No"")" p02601,s990193028,Wrong Answer,"A, B, C = map(int, input().split()) K = int(input()) for i in range(K): if A > B: B *= 2 elif B > C: C *= 2 else: break if C > B > A: print('Yes') else: print('No') " p02601,s338658879,Wrong Answer,"a = list(map(int, input().split())) num = int(input()) k = 0 for i in range(num): #num回2倍を繰り返す。でなければNoをprint if a[0] == max(a) or a[1] == max(a): #リストaの中のmaxよりも青が小さいならば青を二倍する a[2] = a[2] * 2 k += 1 if a[1] == min(a) and k < num: a[1] = a[1] * 2 k += 1 print(a) if a[0] < a[1] and a[1] < a[2]: print(""Yes"") else: print(""No"")" p02601,s572377481,Wrong Answer,"a,b,c=map(int,input().split()) k=int(input()) count=0 while a>=b: b=b*2 count+=1 con=0 while b*count>=c: c=c*2 con+=1 total=con+count if total<=k: print('Yes') else: print('No')" p02601,s276531523,Wrong Answer,"a,b,c=map(int,input().split()) k=int(input()) s=0 for i in range(4): if b*(2**i)>a: s=i break b*=2**s t=0 for i in range(4): if c*(2**i)>b: t=i break if s+t>=k: print(""No"") else: print(""Yes"")" p02601,s576041473,Wrong Answer,"A,B,C=list(map(int,input().split())) K=int(input()) for i in range(K): if A>=B: B=2*B elif B>=C: C=2*C else: print('Yes') break if Ab and b>a: 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"") " p02601,s258102527,Wrong Answer,"a,b,c=map(int,input().split()) k=int(input()) d=b e=c while a>b: b=b*2 while b>c: c=c*2 f=b/d g=c/e h=f//2 i=g//2 if k>=h+i: print('Yes') else: print('No')" p02601,s732038963,Wrong Answer,"A, B, C = map(int, input().split()) K = int(input()) for i in range(1,8): B_after = B * (2 ** i) if B_after > A: i_ans = i break for j in range(1,8): C_after = C * (2 ** j) if C_after > B_after: j_ans = j break if i_ans + j_ans <=K: print('Yes') else: print('No')" p02601,s180944197,Wrong Answer,"a,b,c = map(int,input().split()) k = int(input()) if b<=a: x = 0 for i in range(k): b*=2 if a < b: x += (i+1) break y = 2*(k-x) if k-x > 0 else 1 else: y = 0 y += k print(['No','Yes'][b 0: if c < b: c*=2 elif b < a: b*=2 else: a*=2 k-=1 print(""Yes"" if c>b>a else ""No"")" p02601,s244422624,Wrong Answer,"A, B, C = list(map(int, input().split())) K = int(input()) c = 0 while A >= B: B *= 2 c += 1 # if c >= K: # break while B >= C: C *= 2 c += 1 # if c >= K: # break print(A) print(B) print(C) if c > K: ans = ""No"" else: ans = ""Yes"" print(ans) " 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')" p02601,s917773607,Wrong Answer,"A,B,C=map(int,input().split()) K=int(input()) for i in range(0,K+1): for j in range(0,K+1-i): for k in range(0,K+1-i-j): #print('{},{},{}'.format(i,j,k)) if(A*(2**i) < B*(2**j) and B*(2**j) < C*(2**k)): if(i==j==k==0): break print('Yes') exit() print('No') " p02601,s615669034,Wrong Answer,"a,b,c=map(int,input().split()) k=int(input()) c=0 while a>=b: b*=2 c+=1 while b>=c: c*=2 c+=1 if c<=k: print('Yes') else:print('No')" p02601,s214673446,Wrong Answer,"a,b,c=(int(x) for x in input().split()) k=int(input()) ans=0 for i in range(0,k): c1=c*pow(2,i) b1=b*pow(2,(k-i)) if ab: b=b*2 else: if b>c: c=c*2 else: break if ar: while gg: print(""Yes"") else: print(""No"") " p02601,s101591313,Wrong Answer,"a,b,c=map(int,input().split()) k=int(input()) if c>a/(2**k): for x in range(k+1): if b>a/(2**x): break else: print(""No"") y=k-x if c>b/(2**y): print(""Yes"") else: print(""No"") else: print(""Yes"") " p02601,s076252060,Wrong Answer,"import sys from math import ceil, floor, sqrt, sin, cos, pi from itertools import accumulate, permutations, combinations from fractions import gcd # 最大公約数 from collections import deque, Counter from operator import itemgetter from heapq import heappop,heappush sys.setrecursionlimit(10**7) def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数 # list(map(int, input().split())) a, b, c = map(int, input().split()) k = int(input()) for _ in range(k): if a > b: b *= 2 else: c *= 2 if a < b < c: print('Yes') else: print('No')" p02601,s744610271,Wrong Answer,"def main(): a, b, c = map(int, input().split()) k = int(input()) for i in range(1, k+2): if a < b and b < c: print(""Yes"") return 0 elif i == k+1: print(""No"") return 0 elif c < a or c < b: c = c * 2 elif b < a: b = b * 2 main()" p02601,s323258843,Wrong Answer,"A, B, C = list(map(int,input().split())) K = int(input()) for i in range(K): if A < B < C: print(""Yes"") exit() elif C < B or C < A: C *= 2 continue elif B < A: B *= 2 continue if A < B < C: print(""Yes"") exit() else: print(""No"")" p02601,s722196805,Wrong Answer,"a,b,c=map(int,input().split()) k=int(input()) ans=0 while b <= a: b=b*2 ans += 1 while c <= b: c=c*2 ans += 1 if ans <= k:print(""YES"") else:print(""NO"")" p02601,s691044663,Wrong Answer,"A,B,C=map(int,input().split()) K=int(input()) flag=True for i in range(K): if A>B: B*=2 continue if B>C: C*=2 continue if C>B and B>A: flag=False break if C>B and B>A: flag=False print('Yes' if flag==False else ""No"")" p02601,s123618724,Wrong Answer,"a,b,c = map(int, input().split()) k = int(input()) t = 0 if(a>=b): while(a>=b): b = 2*b t +=1 if(b>=c): while(b>=c): c = 2*c t +=1 if(t<=k): print(""Yes"") else: print(""NO"")" p02601,s724876497,Wrong Answer,"X = list(map(int,input().split())) A = X[0] B = X[1] C = X[2] K = int(input()) cnt = 0 if A > B: for i in range(K): B = B*2 cnt = cnt + 1 if A < B: break if B > C: for j in range(K): C = C*2 cnt = cnt + 1 if B < C: break if cnt <= K: print('Yes') else: print('No') " p02601,s251882957,Wrong Answer,"a = list(map(int,input().split())) #b = list(map(int,input().split())) b=int(input()) for i in range(b): if a[0]<=a[1]<=a[2] or a[0]<=a[2]<=a[1] or a[2]<=a[1]<=a[0] or a[1]<=a[2]<=a[0] or a[2]<=a[0]<=a[1]: a[2]=2*a[2] if a[1]<=a[0]<=a[2]: a[1]=2*a[1] if a[0]list[2]: list[2]=2*list[2] elif list[0]>list[1]: list[1]=2*list[1] if list[0] k: print('no') else: print('yes') " p02601,s598524512,Wrong Answer,"a,b,c=map(int,input().split()) k=int(input()) for i in range(k): if b<=a: if c<=b: c*=2 else: b*=2 elif c<=b: c*=2 else: a*=2 if a b: b *= 2 elif b > c: c *= 2 if a < b and b < c: print(""Yes"") else: print(""No"") " p02601,s497900119,Wrong Answer,"a,b,c = map(int,input().split()) k = int(input()) if not a < b: b *=2 k -=1 if not b < c: c *=2 k -=1 if k <= 0: print('No') exit() elif not 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) " 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"")" p02601,s350694937,Wrong Answer,"import sys r,g,b = map(int,input().split()) k = int(input()) #青>緑>赤 count = 0 if g*(2**k)>r: while gg: print(""Yes"") else: print(""No"")" p02601,s384572222,Wrong Answer,"A,B,C = map(int,input().split()) K = int(input()) while K != 0: if A >= B: B *= 2 elif B >= C: C *= 2 K -= 1 if A < B < C: print(""YES"") else: print(""NO"")" p02601,s209200680,Wrong Answer,"r, g, b = [int(x) for x in input().split()] ops = int(input()) m = 0 if g < r: while g <= r: g *= 2 m += 1 if b < g: while b <= g: b *= 2 m += 1 print(""Yes"" if m <= ops else ""No"") " p02601,s906706774,Wrong Answer,"a,b,c=map(int,input().split()) k=int(input()) for i in range(k): if b=b: b*=2 elif b>=c: c*=2 print(ans)" p02601,s972094343,Wrong Answer,"a = list(map(int,input().split())) b = int(input()) while(a[0] > a[1]): a[1] *= 2 b -= 1 if b <= 0: break while(a[1] > a[2]): a[2] *= 2 b -= 1 if b <= 0: break if a[0] < a[1] and a[1] < a[2] and b >= 0: print(""Yes"") else: print(""No"")" p02601,s016389676,Wrong Answer,"x,y,z=map(int,input().split()) k=int(input()) while(1): if(k==0): break else: y=y*2 k-=1 if(y>x): break while(1): if(k==0): break else: z=z*2 k-=1 if(z>y): break if(x= a[1]: a[1] *= 2 elif a[1] >= a[2]: a[2] *= 2 if a[0] < a[1] < a[2]: print(""Yse"") break " p02601,s120193509,Wrong Answer,"rgb = list(map(int, input().split(' '))) r = rgb[0] g = rgb[1] b = rgb[2] k = int(input()) for i in range(k): if(r >= g): g = g * g elif(g >= b): b = b * b if (r < g < b): print('Yes') else: print('No') " p02601,s382505100,Wrong Answer,"# -*- 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()) 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"")" p02601,s914311704,Wrong Answer,"a,b,c = list(map(int,input().split())) K = int(input()) while True : if a > b: b *= 2 K -= 1 if a < b: break if K == 0: print('No') exit() while True: if b > c: c *= 2 K -= 1 if b < c: print(""Yes"") break if K == 0: print('No') exit() " p02601,s071141495,Wrong Answer,"A,B,C = map(int, input().split()) K = int(input()) # A: aka < B: midori < C: ao d = 0 for i in range(K): for j in range(K - i): for k in range(K - i - j+1): a = A*2**i b = B*2**j c = C*2**k if a= c: while k >= 1: c *= 2 k -= 1 if c > a: break if a >= b: while k >= 1: b *= 2 k -= 1 if b > a: break if c > b > a and k >= 0: print('Yes') else: print('No') " p02601,s534804903,Wrong Answer,"a,b,c=map(int,input().split()) k=int(input()) for i in range(k): if a>b: b=b*2 else: if b>c: c=c*2 else: break if a l[1]: l[1] *= 2 elif l[1] > l[2]: l[2] *= 2 if l[0] < l[1] and l[1] < l[2]: print('Yes') exit() print('No')" p02601,s617888610,Wrong Answer,"A,B,C = map(int,input().split()) K = int(input()) count =0 for i in range(K+1): for j in range(K+1): X = B Y = C X = X*(2**i) Y = Y*(2**j) if i+j <= 3 and A < X and X < Y: count +=1 if count ==0: print('No') else: print('Yes')" p02601,s755390437,Wrong Answer,"A,B,C = map(int,input().split()) K = int(input()) if A= B: B = B*2 elif B >= C: C = C*2 if A a) and (c > b): print('Yes') else: print('No')" p02601,s382775010,Wrong Answer,"import math A ,B, C = map(int, input().split()) N = int(input()) count = 0 if A > B: temp = math.log(A/B) / math.log(2) temp = math.ceil(temp) count += temp B = 2**temp * B else: count += 0 if B > C: temp = math.log(B/C) / math.log(2) temp = math.ceil(temp) count += temp C = 2**temp * C else: count += 0 if C > B and count <= N: print(""Yes"") else: print(""No"")" p02601,s644163565,Wrong Answer,"import sys 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(A,B,C) if A < B < C: print('Yes') else: print('No')" p02601,s776009474,Wrong Answer,"def main(): a, b, c = [int(x) for x in input().split()] count = int(input()) while a >= b: b *= 2 count -= 1 while b >= c: c *= 2 count -= 1 print('Yes' if count < 0 else 'No') if __name__ == '__main__': main() " p02601,s048074788,Wrong Answer,"A,B,C=map(int,input().split()) K=int(input()) for i in range(K): if B B: B *= 2 elif B > C: C *= 2 K -= 1 if A < B < C: print('Yes') else: print('No') " p02601,s334481799,Wrong Answer,"a,b,c = map(int,input().split()) k = int(input()) for i in range(k+1): if a < b and b < c: print(""Yes"") exit() elif a > b: b *= 2 elif b > c: c *= 2 print(""No"")" p02601,s043974918,Wrong Answer,"a, b, c = map(int, input().split()) k = int(input()) for i in range(k): if a < b and b < c: print('Yes') exit() elif b > c: c = 2 * c elif a > b: b = 2 * b # print(a, b, c) if a < b and b < c: print('Yes') exit() print('No')" p02601,s941799896,Wrong Answer,"r, g, b =map(int,input().split()) k = int(input()) for i in range(k): if r > g: g *= 2 elif g > b: b *= 2 if r < g < b: print(""Yes"") else: print(""No"")" p02601,s069723761,Wrong Answer,"Card = list(map(int, input().split())) K = int(input()) import itertools import numpy as np k = [i for i in range(8)] Com = [v for v in itertools.permutations(k, 3) if np.sum(v) == K] Ans = [] for c in Com: A = [2**c[i] * Card[i] for i in range(3)] if (A.index(min(A)) == 0) and (A.index(max(A)) == 2): Ans.append(c) if len(Ans) != 0: print('Yes') else: print('No')" p02601,s008283278,Wrong Answer,"a, b, c = map(int, input().split()) k = int(input()) for i in range(k): print(1) if a >= b: b = b*2 else: c = c*2 if a < b and b < c: print(""Yes"") else: print(""No"") " p02601,s487853620,Wrong Answer,"a,b,c = map(int, input().split()) k = int(input()) for i in range(k): while a >= b: b *= 2 i += 1 while b >= c: c *=2 i += 1 if ak: print('No') sys.exit() while c<+b: c*=2 i==1 if i>k: print('No') sys.exit() if i<=k: print('Yes') " p02601,s042893406,Wrong Answer,"a,b,c = map(int,input().split()) k = int(input()) for i in range(k): if a < b and b < c: print(""Yes"") exit() elif a > b: b *= 2 elif b > c: c *= 2 if a < b and b < c: print(""Yes"") else: print(""No"")" p02601,s716523202,Wrong Answer,"# @uthor : Kaleab Asfaw import sys input = sys.stdin.readline def main(a, b, c, k): for i in range(k): if b <= a: b*= 2 elif c <= b: c *= 2 print(a, b, c) if b > a and c > b: return ""Yes"" return ""No"" a, b, c = list(map(int, input().split())) k = int(input()) print(main(a, b, c, k)) " p02601,s913956828,Wrong Answer,"A, B, C = (int(x) for x in input().split()) K = int(input()) for i in range(K): if A > B: B *= 2 elif B > C: C *= 2 if A < B and B < C: print('Yes') else: print('No')" p02601,s034262537,Wrong Answer,"A,B,C = map(int,input().split()) #A赤<B緑<C青, K = int(input()) while A > B and K >=1: B *= 2 K -= 1 while B > C and K >= 1: C *= 2 K -= 1 if A < B and B < C: print(""Yes"") else: print(""No"")" p02601,s063918188,Wrong Answer,"a,b,c=map(int,input().split()) k = int(input()) flag = False for i in range(k+1): if a<2*(b**i)<2*(c**(k-i)): flag = True if flag == True: print('Yes') else: print('No')" p02601,s413829198,Wrong Answer,"a,b,c=map(int,input().split()) d=int(input()) ans=0 for i in range(3): if a=ans: print('Yes') else: print('No') " p02601,s917748284,Wrong Answer,"R,G,B = map(int,input().split()) K = int(input()) ans = 'No' for i in range(K): if B > G > R: ans = 'Yes' break elif max(R,G,B) != B: B=B*2 elif G <= R: G=G*2 else: pass #print(R,G,B) if B > G > R: ans = 'Yes' print(ans) " p02601,s400503804,Wrong Answer,"R,G,B = map(int,input().split()) K = int(input()) if R < G < B: print(""Yes"") for i in range(K): if R > G: G*=2 elif G > B: B*=2 elif R > B: B*=2 elif R == G == B: B *= 2 elif R == G: G *= 2 elif G == B: B *= 2 else: pass if R < G < B: print(""Yes"") else: print(""No"") " p02601,s701835397,Wrong Answer,"def magic_2(): a,b,c = map(int, input().split()) k = int(input()) my_list = [b,c] i = 0 while i <= k-1: multiply_list = [items * 2 for items in my_list] i += 1 new_list = [a] + multiply_list if new_list[0] < new_list[1] < new_list[2]: print(""yes"") else: print(""No"") magic_2()" p02601,s239762478,Wrong Answer,"abc=list(map(int,input().split())) a,b,c=abc[0],abc[1],abc[2] k=int(input()) for i in range(k): if a < b < c: print(""Yes"") break elif b <= a < c: b *= 2 else: c *= 2 else: print(""No"")" p02601,s404255537,Wrong Answer,"def main(): A, B, C = map(int, input().split()) K = int(input()) n = 0 for i in range(K): if C < B or C < A: C = C * 2 if C > B > A: print('Yes') return elif B < A: B = B * 2 if C > B > A: print('Yes') return print('No') main() " p02601,s290371550,Wrong Answer,"A, B, C = map(int, input().split()) K = int(input()) for i in range(1, K+1): if A >= B: B *= 2 print(A,B,C) elif B >= C: C *= 2 print(A,B,C) if A < B < C: print(""Yes"") else: print(""No"")" p02601,s396843672,Wrong Answer,"a, b, c = map(int, input().split()) k = int(input()) i = 0 while i < k: if a >= b: b *= 2 elif b >= c: c *= 2 i += 1 print(a,b,c) if a < b < c: print(""Yes"") else: print(""No"")" p02601,s540897589,Wrong Answer,"import math import collections import fractions import itertools import functools import operator def solve(): a, b, c = map(int, input().split()) k = int(input()) i = k+1 for p in range(i): for q in range(i-p): for r in range(i-p-q): if a**p < b**q < c**r: print(""Yes"") exit() print(""No"") return 0 if __name__ == ""__main__"": solve()" p02601,s493257776,Wrong Answer,"a, b, c = map(int,input().split(' ')) k = int(input()) while k >= 0: if c < b: c *= 2 elif b < a: b *= 2 k -= 1 if a < b and b < c: print('Yes') break else: print('No')" p02601,s908273028,Wrong Answer,"A,B,C=[int(s) for s in input().split()] X=int(input()) count=0 while A<=B: B*=2 count+=1 while B<=C: C*=2 count+=1 if count<=X: print('Yes') else: print('No')" p02601,s888338506,Wrong Answer,"a, b, c = map(int, input().split()) k = int(input()) if k == 1: if b < c: b = b*2 else: c = c*2 elif k > 1: for i in range(1,k): if b < c: b = b*2 else: c = c*2 if a < b and b < c: print('Yes') else: print('No')" p02601,s329791853,Wrong Answer,"a,b,c = map(int,input().split()) k = int(input()) count = 0 while a > b: b *= 2 count += 1 while b > c: c *= 2 count += 1 if a < b < c and k-count<= 0: print(""Yes"") else: print(""No"") " p02601,s744892810,Wrong Answer,"a,b,c=map(int,input().split()) k=int(input()) for i in range(k): if a>b: b=b*2 if b>c: c=c*2 if a 0: if C < B: C *= 2 K -= 1 if B < A: B *= 2 K -= 1 if A < B and B < C and A < C: print('yes') else: print('no') " p02601,s422796631,Wrong Answer,"#import sys a, b, c = map(int,input().split()) k = int(input()) for i in range(k): if a>b: b = b*b elif b>c: c = c*c else: continue if a c: c *= 2 elif a > b: b *= 2 elif a > c: c *= 2 if a < b < c: print(""Yes"") else: print(""No"")" p02601,s444288626,Wrong Answer,"a,b,c=map(int,input().split()) k=int(input()) for _ in range(k): if aa and c>b and b 1: for i in range(0, k): if b < c: b = b*2 else: c = c*2 if a < b and b < c: print('Yes') else: print('No')" p02601,s866404149,Wrong Answer,"abc = list(map(int, input().split())) k = int(input()) for i in range(1,k+1): min_val = min(abc) min_idx = abc.index(min_val) abc[min_idx] *= 2 if abc[0] < abc[1] and abc[1] < abc[2]: print('Yes') else: print('No') " p02601,s811853524,Wrong Answer," a,b,c=map(int,input().split()) K=int(input()) isCheck = None for i in range(K): for j in range(K): for k in range(K): x = a*2**(i) y = b*2**(j) z = c*2**(k) if i+j+k <= K and x < y and y < z: isCheck = True if isCheck: print(""Yes"") else: print(""No"")" p02601,s746421128,Wrong Answer,"A, B, C = list(map(int, input().split())) K = int(input()) # A= B: B = B * 2 if A < B and B < C: print(""Yes"") break continue elif B >= C: C = C * 2 if A < B and B < C: print(""Yes"") break continue else: print(""No"") " p02601,s040591413,Wrong Answer,"# cook your dish here a,b,c = map(int, input().split()) k = int(input()) flag = 0 while k: if a=f: z=y else: z=f g=0 if e<= 3: g+=2 elif e<=2: g+=1 if z<= 4: g+=2 elif z<=2: g+=1 if A==B==C: g+=3 elif A==B: g+=1 elif A==C: g+=1 elif B==C: g+=1 if g<=k: print('Yes') else: print('No') " p02601,s460552337,Wrong Answer,"def solve(A, B, C, K): for k in range(0, K+1): for n in range(0, k+1): if A <= (2**n)*B <= (2**(k-n))*C: return True return False A, B, C = map(int,input().split()) K = int(input()) if solve(A, B, C, K): print('Yes') else: print('No')" p02601,s306646640,Wrong Answer,"#B A, B, C = map(int, input().split()) K = int(input()) for _ in range(K): if A > B: B *= 2 elif B > C: C *= 2 if A < B < C: print('Yes') else: print('No')" p02601,s138743626,Wrong Answer,"A, B, C = map(int, input().split()) K = int(input()) for i in range(K): if A < B < C: break elif A > B: B *= 2 elif B > C: C *= 2 if A < B < C: print(""Yes"") else: print(""No"")" p02601,s130031976,Wrong Answer,"a,b,c=input().split() a=int(a) b=int(b) c=int(c) k=int(input()) flag=0 i=1 while(i<=k): if((ab): b=b*2 i+=1 continue if(b>c): c=c*2 i+=1 continue if((ac: c=c*2 elif a>b: b=b*2 if b>a and c>b: print('Yes') else: print('No')" p02601,s180227895,Wrong Answer,"l = list(map(int,input().split())) r, g, b = l[0], l[1], l[2] k = int(input()) for _ in range(k): if r >= g: g *= 2 elif g >= b: b *= 2 else: print('Yes') break if b > g and g > r: print('Yes') else: print('No')" p02601,s497028844,Wrong Answer,"a, b, c = map(int, input().split()) k = int(input()) i = 0 while not a < b: b *= 2 i += 1 while not b < c: c *= 2 i += 1 if k <= i: print('Yes') else: print('No')" p02601,s917986212,Wrong Answer,"A,B,C = map(int, input().split()) K = int(input()) for i in range(K): if max(A,B,C) != C: C *= 2 else: if A > B: B *= 2 if C > B and B > A: print(""Yes"") else: print(""No"")" p02601,s830222371,Wrong Answer,"a,b,c=map(int,input().split()) k=int(input()) d={""a"":a,""b"":b,""c"":c} for i in range(k+1): if d[""a""]d[""b""]: d[""b""]*=2 elif d[""a""]>d[""c""]: d[""c""]*=2 elif d[""b""]>d[""c""]: d[""c""]*=2 print(""No"")" p02601,s384967235,Wrong Answer,"l = list(map(int, input().split())) K = int(input()) def check(nums): if nums[0] < nums[1]: if nums[1] < nums[2]: print('Yes') exit(0) check(l) for i in range(K): if l[1] > l[2]: l[2] *= 2 check(l) continue elif l[0] > l[1]: l[1] *= 2 check(l) continue print('No')" p02601,s267433742,Wrong Answer,"abc = list(map(int, input().split())) k = int(input()) for i in range(1,k+1): if abc[0] < abc[1] and abc[1] < abc[2]: break min_val = min(abc) min_idx = abc.index(min_val) abc[min_idx] *= 2 if abc[0] < abc[1] and abc[1] < abc[2]: print('Yes') else: print('No') " p02601,s074298835,Wrong Answer,"a = list(map(int,input().split())) r,g,b= a[0],a[1],a[2] k=int(input()) m=0 for i in range(k): if g>r: break g*=2 m+=1 d = k -m b=b*(2**d) print(r,g,b,i) if b>g and g >r: print('Yes') else: print('No')" p02601,s832653209,Wrong Answer,"a,b,c=map(int,input().split()) k=int(input()) for i in range(0,k+1): asw=False for j in range(0,k+1): if i+j<=k and a A and B < A: B *= 2 if A < B and B < C: print(""Yes"") else: print(""No"")" p02601,s070856633,Wrong Answer,"def magic(a,b,c,k): for i in range(k): if(a >= c and b >= c): c*=2 elif(a >= b): b*=2 if(a < b and b < c and a < c): print(""Yes"") else: print(""No"") d,e,f = map(int,input().split()) j = int(input()) magic(d,e,f,j) " p02601,s624332009,Wrong Answer,"import math A,B,C=(int(x) for x in input().split()) k=int(input()) d=2**k e=math.ceil(A/B) f=math.ceil(B/C) y=math.ceil(A/C) if y>=f: z=y else: z=f g=0 if e<= 3: g+=2 elif e<=2: g+=1 if z<= 4: g+=2 elif z<=2: g+=1 if A==B==C: g+=3 elif A==B: g+=1 elif A==C: g+=1 elif B==C: g+=1 if g<=k: print('No') else: print('Yes') " p02601,s752899420,Wrong Answer,"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 < b and b < c: print(""Yes"") else: print(""No"")" p02601,s605645823,Wrong Answer,"a, b, c = map(int, input().split()) k = int(input()) cnt = 0 while a > b: b = b * 2 cnt += 1 while b > c: c = c * 2 cnt += 1 if cnt <= k: print(""Yes"") else: print(""No"")" p02601,s654632993,Wrong Answer,"import sys a, b, c = [int(x) for x in input().split()] k = int(input()) i = 0 while bc and a>c: c = c*2 if a < b and b < c: print('Yes') else: print('No')" p02601,s815287577,Wrong Answer,"A, B, C = input().split("" "") K = int(input()) A, B, C = int(A), int(B), int(C) for i in range(K): if A > B: B = B*2 elif B > C: C = C*2 if B > A and C > B: print(""Yes"") exit() print(""No"")" p02601,s751373359,Wrong Answer,"R, G, B = map(int, input().split()) K = int(input()) for i in range(K + 1): g = G * i * 2 b = B * (K - i) * 2 r = R if b > g > r: print('Yes') exit() print('No')" p02601,s945677717,Wrong Answer,"A, B, C = map(int, input().split()) K = int(input()) for _ in range(K): if A > B: B *= 2 elif B > C: C *= 2 if A < B < C: print('Yes') else: print('No')" p02601,s737667415,Wrong Answer,"red, green, blue = map(int, input().split()) k = int(input()) success = 0 for cnt in range(k+1): if red > green: green *= 2 elif red > blue: blue *= 2 elif green >= blue: blue *= 2 else: success = 1 break if success == 1: print('Yes') else: print('No')" p02601,s779426135,Wrong Answer,"from itertools import combinations_with_replacement from collections import Counter a,b,c = map(int, input().split()) k = int(input()) lsts = [] lst = list(map(Counter, combinations_with_replacement([a,b,c], k))) result = False for l in lst: al, bl, cl = a*(2**l[a]) ,b*(2**l[b]) , c*(2**l[c]) if (bl > al) and (cl > bl): result = True if result: print('Yes') else: print('No')" p02601,s337941702,Wrong Answer,"#!/usr/bin/env python3 def main(): R, G, B = map(int, input().split()) K = int(input()) for i in range(K): if R > G: G = G * 2 else: if G > B: B = B * 2 if B > G > R: print(""Yes"") exit() print(""No"") if __name__ == '__main__': main()" p02601,s211272444,Wrong Answer,"a = list(map(int, input().split())) n = int(input()) while 1: if n == 0: print(""No"") break elif a[0] >= a[1]: a[1] *= 2 n -= 1 elif a[1] >= a[2]: a[2] *= 2 n -= 1 else: print(""Yse"") break" p02601,s040637205,Wrong Answer,"a,b,c=map(int,input().split()) k=int(input()) re=0 re1=0 su=0 for i in range (k): re=re+b*2 su = su +1 if (re > a ): quit() for j in range(k-su): re1= re1 + c*2 if (re1 > re): print(""Yes"") else: print(""No"") " p02601,s057554705,Wrong Answer,"a,b,c=map(int,input().split()) k=int(input()) for i in range(k): if a>b: b=b*2 else: if b>c: c=c*2 else: break if a B: B = 2 * B elif B > C: C = 2 * C else: ans = 'Yes' if A < B< C: ans = 'Yes' print(ans) " p02601,s715416685,Wrong Answer,"A,B,C = map(int,input().split()) K = int(input()) for i in range(K): if A > B: B = B*2 else: C = C*2 print(""Yes"" if A < B and B < C else ""No"")" p02601,s317792351,Wrong Answer,"a,b,c,k=map(int,open(0).read().split()) for i in' '*k:t=(a c): c = c * 2 elif(a > b): b = b * 2 if(a < b and b < c): print('Yes') else: print('No')" p02601,s332962772,Wrong Answer,"A,B,C=map(int,input().split()) K=int(input()) K=7 for i in range(0,K+1): for j in range(0,K+1-i): for k in range(0,K+1-i-j): #print('{},{},{}'.format(i,j,k)) if(A*i*2+A < B*j*2+B and B*j*2+B < C*k*2+C): print('Yes') exit() print('No') " p02601,s433541488,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 a= 0): if l[0] > l[1]: l[1] *= 2 k -= 1 elif l[1] > l[2]: l[2] *= 2 k -= 1 else: print('Yes') exit() print('No')" p02601,s046829992,Wrong Answer,"A, B, C = map(int,input().split()) K = int(input()) flag = False for i in range(0, K): for j in range(0, K - i): for k in range(0, K - i - j): x = A * 2**i y = B * 2**j z = C * 2**k if x < y < z: flag = True if flag == True: print('Yes') else: print('No')" p02601,s197312001,Wrong Answer,"import math aka, mi, ao = map(int, input().split("" "")) k = int(input()) for i in range(k): if ao > mi: mi *= 2 continue if mi > aka: aka *= 2 continue ao *= 2 if aka > mi > ao: print(""Yes"") else: print(""No"")" p02601,s570565824,Wrong Answer,"r, g, b = [int(x) for x in input().split()] ops = int(input()) m = 0 while m <= ops: if max(r, g, b ) != b: b *= 2 m += 1 else:break while m < ops: if max(r, g) != g : g *= 2 m += 1 else: break print(r,g,b) print(""Yes"" if r < g < b else ""No"") " p02601,s114226814,Wrong Answer,"a,b,c = map(int,input().split()) k = int(input()) while(b= a: b *= 2 while c >= b: c *= 2 if cnt <= k: print(""Yes"") else: print(""No"")" p02601,s723299578,Wrong Answer,"a,b,c=map(int,input().split()) k=int(input()) cnt=0 while not a=cnt else 'no')" p02601,s195722668,Wrong Answer,"a, b,c = map(int, input().split()) K=int(input()) for i in range(K): if bnew_B: print('Yes') elif new_C>new_A: print('Yes') else: print('No') " p02601,s551568394,Wrong Answer,"a = list(map(int,input().split())) #b = list(map(int,input().split())) b=int(input()) for i in range(b): a[a.index(min(a))]= 2*(a[a.index(min(a))]) if a[0]B: B *= 2 else: num = i for j in range(K-num): C *= 2 if A green and green > red): success=1 if success == 1: print(""Yes"") else: print(""No"")" p02601,s577240503,Wrong Answer,"A,B,C = map(int,input().split()) K = int(input()) for i in range(0,K+1): A = A*(2*i) for j in range(0,K+1): B = B*(2*j) for h in range(0,K+1): C = C*(2*h) if (i+j+h) <= K and C>B>A: print(""Yes"") exit() print(""No"")" p02601,s707046289,Wrong Answer,""""""" b > g > r """""" r, g, b = list(map(int, input().split())) k = int(input()) flag = False for i in range(k): if r > b and g > b: b *= 2 elif r > g: g *= 2 if b > g > r: flag = True print(""Yes"") if flag else print(""No"")" p02601,s160838464,Wrong Answer,"A,B,C = list(map(int,input().split())) K = int(input()) flag= 0 for i in range(K): if A>B: B *=2 if C < B: C *=2 if C >B and B>A: flag = 1 break if flag == 0: print(""No"") else: print(""Yes"")" p02601,s831357341,Wrong Answer,"R,G,B=map(int,input().split()) K=int(input()) for i in range (K): if R > G : G*=2 continue else: pass if G > B : B*=2 continue else: pass if R < G B: print('Yes') else : print('No') elif B > A : if C*(2**K) > B : print('Yes') else : print('No')" p02601,s852411074,Wrong Answer,"a,b,c=map(int,input().split()) k=int(input()) token=0 for i in range(k+1): c_c=c*(2**i) for j in range(k-i+1): b_c=c*(2**j) if a 0: if A >= B: B *= 2 K -= 1 if B >= C: C *= 2 K -= 1 if A < B < C: break if A < B < C: print(""Yes"") else: print(""No"") " p02601,s687410649,Wrong Answer,"A,B,C=map(int, input().split()) K = int(input()) import math b=0 if B>A: b=0 elif 2*B>A: b=1 B=2*B elif 4*B>A: b=2 B=4*B else: b=3 B=8*B c=0 if C>B: c=0 elif 2*C>B: c=1 elif 4*C>B: c=2 else: c=3 if b+c<=K: print(""Yes"") else: print(""No"") # 2darray [[0] * 4 for i in range(3)]" p02601,s217251101,Wrong Answer,"def main(): a,b,c = map(int,input().split()) k = int(input()) judge = True counter = 0 while judge: if a < b < c: print(""Yes"") break else: counter += 1 if counter <= k: if a > b: b *= 2 elif b > c: c *= 2 else: print(""No"") break if __name__ == '__main__': main()" p02601,s832688359,Wrong Answer,"A, B, C = map(int, input().split()) K = int(input()) if A < B and B < C : print('Yes') exit() for i in range(K): if C < B: C = C * 2 if A < B and B < C: print('Yes') exit() elif B < A: B = B * 2 if A < B and B < C: print('Yes') exit() print('No')" p02601,s769394835,Wrong Answer,"import math import collections import fractions import itertools import functools import operator def solve(): a, b, c = map(int, input().split()) k = int(input()) i = k for p in range(i): for q in range(i-p): for r in range(i-p-q): if a**p < b**q < c**r: print(""Yes"") exit() print(""No"") return 0 if __name__ == ""__main__"": solve()" p02601,s489236450,Wrong Answer,"a,b,c=map(int,input().split()) k=int(input()) while k>0: if a>=b: b*=2 elif b>=c: c*=2 else: break k-=1 if a b: for i in range(k): b = 2*b if a < b: count = i break if b > c: for j in range(count+1, k): c = 2*c if b < c: break if a < b and b < c: print(""Yes"") else: print(""No"")" p02601,s035088995,Wrong Answer,"X = list(map(int,input().split())) A = X[0] B = X[1] C = X[2] K = int(input()) cnt = 0 if A > B: for i in range(K): B = B*2 cnt = cnt + 1 if A < B: break if B > C: for j in range(K): C = C*2 cnt = cnt + 1 if B < C: break if cnt <= K: print('Yes') else: print('No') " p02601,s338870992,Wrong Answer,"#!/usr/bin/env python3 def main(): 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 if A < B and B < C: print('Yes') else: print('No') if __name__ == ""__main__"": main() " p02601,s282927111,Wrong Answer,"a,b,c = map(int,input().split()) k = int(input()) d = 0 for i in range(k+1): if b < a: b *= 2 elif c < b: c *= 2 else: d = 1 if d == 0: print(""No"") else: print(""Yes"")" p02601,s530387760,Wrong Answer,"a,b,c = map(int,input().split()) k = int(input()) ans = 0 while a > b: b = b*2 ans += 1 while b > c: c = c*2 ans += 1 if ans > k: print(""No"") else: print(""Yes"")" p02601,s275331823,Wrong Answer,"A, B, C = map(int, input().split()) K = int(input()) for i in range(K): for j in range(K): for k in range(K): if i + j + k <= K: D = A * 2 ** i E = B * 2 ** j F = C * 2 ** k if D < E < F: print('Yes') exit() print('No') " p02601,s611873178,Wrong Answer,"A, B, C = map(int, input().split()) K = int(input()) i = 0 while i <= K: if A >= B: B *= 2 i += 1 else: break while i <= K: if B >= C: C *= 2 i += 1 else: break #print(A, B, C) if A < B and B < C: print('Yes') else: print('No')" p02601,s637395138,Wrong Answer,"A,B,C = map(int,input().split("" "")) K = int(input()) for i in range(1,K+1): if A > B : B = B*2 if B > C : C = C*2 if C > B & B > A: print(""Yes"") else: print(""No"") " p02601,s447575802,Wrong Answer,"a, b, c = map(int, input().split()) k = int(input()) c = c*2 if k > 1: for i in range(1,k): if b < c: if i == k-1: c = c*2 else: b = b*2 else: c = c*2 if a < b and b < c: print('Yes') else: print('No')" p02601,s224672562,Wrong Answer,"card = list(map(int, input().split())) k = int(input()) for i in range(k): if card[0] > card[1]: card[1] *= 2 elif card[1] > card[2]: card[2] *= 2 else: card[2] *= 2 print(""Yes"") if card[0] < card[1] < card[2] else print(""No"")" p02601,s200236572,Wrong Answer,"l = list(map(int, input().split())) k = int(input()) while(k > 0): if l[0] > l[1]: l[1] *= 2 elif l[1] > l[2]: l[2] *= 2 if l[0] < l[1] and l[1] < l[2]: print('Yes') exit() k -= 1 print('No')" p02601,s008534342,Wrong Answer,"import sys import numpy as np A,B,C = list(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 < B and B < C: print('yes') else: print('no') " p02601,s880849129,Wrong Answer,"A, B, C = map(int,input().split()) K = int(input()) flag = False for i in range(0, K): for j in range(0, K): for k in range(0, K): x = A * 2**i y = B * 2**j z = C * 2**k # print(x, y, z) if x < y and y < z and i + j + k <= K: flag = True if flag == True: print('Yes') else: print('No')" p02601,s552823433,Wrong Answer,"A, B, C = map(int, input().split()) K = int(input()) a=0 for i in range(K): i += 1 if B*(2**i) > A: if C*(2**(K-i)) > B*(2**i): a=1 if a==1: print('Yes') if a==0: print('No') " p02601,s622265500,Wrong Answer,"a, b, c = map(int, input().split()) k = int(input()) for cnt in range(k): if a < b < c: break elif b > c: c = c * 2 continue elif a > b: b = b * 2 continue if a < b < c: print('Yes') else: print('No') " p02601,s467595756,Wrong Answer,"r, g, b = map(int, input().split()) op = int(input()) while op > 0 and g < r: g *= 2 op -= 1 while op > 0 and b < g: b *= 2 op -=1 # print(r,g,b) if r < g < b: print(""Yes"") else: print(""No"")" p02601,s532271555,Wrong Answer,"a,b,c=map(int,input().split()) k=int(input()) ans=False for i in range(0,k+1): for j in range(0,k+1): if(i+j>k): continue if(a*2**i b: b *= 2 elif b > c: c *= 2 if a < b < c: print(""Yes"") else: print(""No"")" p02601,s127191723,Wrong Answer,"from itertools import combinations_with_replacement from collections import Counter a,b,c = map(int, input().split()) k = int(input()) lsts = [] lst = list(map(Counter, combinations_with_replacement([a,b,c], k))) result = False if a == b and b == c: if k >= 3: result = True for l in lst: al, bl, cl = a*(2**l[a]), b*(2**l[b]), c*(2**l[c]) if (bl > al) and (cl > bl): result = True if result: print('Yes') else: print('No')" p02601,s037464650,Wrong Answer,"l = list(map(int, input().split())) K = int(input()) def check(nums): if nums[0] < nums[1]: if nums[1] < nums[2]: print('Yes') exit(0) check(l) for i in range(K): if l[0] > l[1]: l[1] *= 2 check(l) continue elif l[1] > l[2]: l[2] *= 2 check(l) continue print('No') exit(0) " p02601,s644063930,Wrong Answer,"a,b,c = map(int,input().split()) k = int(input()) for i in range(k): if b < a: b *= 2 elif b > c: c *= 2 if b > a and c > b: break if b > a and c > b: print('Yes') else: print('No')" p02601,s724030509,Wrong Answer,"A, B, C = map(int, input().split("" "")) N = int(input()) newA, newB, newC = A, B, C n = 0 for a in range(N): for b in range(N): for c in range(N): if newA < newB and newB < newC: n = 1 else: newC *= 2 newB *= 2 newC = C newA *= 2 newC = C newB = B if n == 1: print(""Yes"") else: print(""No"")" p02601,s162249591,Wrong Answer," R,G,B=map(int,input().split()) K = int(input()) i = 1 while (B<=G or G<=R): if R>=G: G = G*2 i=i+1 if G>=B: B = B*2 i=i+1 if i>=K: break if R B: B = B * 2 elif B > C: C = C * 2 if A < B and B < C: print('Yes') else: print('No')" p02601,s783980550,Wrong Answer,"import sys r,g,b = map(int,input().split()) k = int(input()) #青>緑>赤 count = 0 if g*(2**k)>r: while gg: print(""Yes"") else: print(""No"")" p02601,s520645836,Wrong Answer,"a,b,c=map(int,input().split()) k=int(input()) for i in range(0,k+1): asw=False for j in range(0,k+1): if i+j<=k and a b: b *= 2 count += 1 return count A, B, C = map(int, input().split()) K = int(input()) count = countup(A, B) B_ = B * (2 ** count) count += countup(B_, C) if count <= K: print('Yes') else: print('No') " p02601,s156895875,Wrong Answer,"A,B,C=map(int,input().split()) K=int(input()) numbers=[A,B,C] for k in range(K): a=numbers[0] b=numbers[1] c=numbers[2] if cb: b=b*2 count+=1 while b>c: c=c*2 count+=1 if count <=k: print('Yes') else: print('No') " p02601,s443268060,Wrong Answer,"A,B,C = map(int, input().split()) K = int(input()) for i in range(K): if max(A,B,C) != C: C *= 2 elif max(A,B,C): if A > B: B *= 2 if C > B and B > A: print(""Yes"") exit() print(""No"")" p02601,s513196428,Wrong Answer,"A, B, C = map(int, input().split()) K = int(input()) for i in range(K): if A < B < C: break elif B > C: C *= 2 elif A > B: B *= 2 if A < B < C: print(""Yes"") else: print(""No"")" p02601,s746263590,Wrong Answer,"A, B, C = map(int,input().split()) K = int(input()) flag = False for i in range(0, K): for j in range(0, K): for k in range(0, K): x = A * 2**i y = B * 2**j z = C * 2**k # print(x, y, z) if x < y and y < z and i + j + k <= K: flag = True if flag == True: print('Yes') else: print('No')" p02601,s302608680,Wrong Answer,"A, B, C = list(map(int,input().split())) K = int(input()) count = 0 for i in range(K): if count > K+1: print('No') exit() elif A > B: B *= 2 count += 1 else: break for j in range(K - count): if count > K+1: print('No') exit() elif B > C: C *= 2 count += 1 else: break print('Yes')" p02601,s386202728,Wrong Answer,"r,g,b=map(int,input().split()) k=int(input()) for i in range(0,k+1): b1=b*2*i g2=g*2*(k-i+1) if r=f: z=y else: z=f g=0 if e>2: g+=2 elif e==2: g+=1 if z>2: g+=2 elif z==2: g+=1 if A==B==C: g+=3 elif A==B: g+=1 elif A==C: g+=1 elif B==C: g+=1 if g<=k: print('Yes') else: print('No') " p02601,s804520003,Wrong Answer,"a,b,c = map(int , input().split()) k = int(input()) while(k>=1): if b=b: for i in range(3): b=b*2 if b>a: A=i+1 break else: A=0 n=0 if b>=c: for j in range(3): c=c*2 if c<=b: n+=1 else: break else: n=0 if A+n<=K: print(""Yes"") else: print(""No"")" p02601,s219519061,Wrong Answer,"a,b,c=map(int,input().split()) k=int(input()) if c>b and b>a: print(""Yes"") else: m=max(a,b) if c<=m: while(c<=m and k>0): c=c*2 k-=1 if b<=a: while(b<=a and k>0): b=b*2 k-=1 # print(a,b,c) if c>b and b>a: print(""Yes"") else: print(""No"")" p02601,s112070865,Wrong Answer,"a,b,c=map(int,input().split()) k=int(input()) if c>b and b>a: print(""Yes"") else: while(bb and b>a: print(""Yes"") else: print(""No"") " p02601,s514311622,Wrong Answer,"A, B, C = map(int, input().split()) K = int(input()) for i in range(K): if B < A: B *= 2 elif C < B: C *= 2 if B > A and C > B: print(""Yes"") else: print(""No"")" p02601,s877706620,Wrong Answer,"a, b, c = map(int, input().split()) k = int(input()) c = c*2 if k > 1: for i in range(1,k): if b < c and b < a: b = b*2 elif b > c: c = c*2 if a < b and b < c: print('Yes') else: print('No')" p02601,s016108476,Wrong Answer,"A,B,C = map(int,input().split()) K = int(input()) for i in range(K): if CB: B*=2 if B>A and C>B: print(""Yes"") else: print(""No"")" p02601,s003660004,Wrong Answer,"A, B, C = map(int, input().split()) K = int(input()) for i in range(K): if C < B: C *= 2 break if B < A: B *= 2 if A < B and B < C: print('Yes') else: print('No') " p02601,s174755505,Wrong Answer,"A,B,C = map(int,input().split()) K = int(input()) sum = 0 sum1 = 0 sum2 = 0 for i in range(K): if (C): sum2+=C*2 elif(B): sum1+=B*2 elif(A): sum+=A*2 if (sum1>sum and sum2>sum1): print('Yes') else: print('No')" p02601,s553299861,Wrong Answer,"import math import collections import fractions import itertools import functools import operator def solve(): a, b, c = map(int, input().split()) k = int(input()) i = k for p in range(i+1): for q in range(i-p): for r in range(i-p-q): if a**max(p, 1) < b**max(q, 1) < c**max(r, 1): print(""Yes"") exit() print(""No"") return 0 if __name__ == ""__main__"": solve()" p02601,s346287796,Wrong Answer,"a, b, c = map(int, input().split()) k = int(input()) ans = 0 for x in range(1,k+1): for y in range(1,k+1-x): for z in range(1,k+1-x-y): if b**2*y > a**2*x and c**2*z > b**2*y: ans += 1 if ans >= 1: print(""Yes"") else: print(""No"") " p02601,s734596551,Wrong Answer,"a,b,c=map(int,input().split()) k=int(input()) if c>b and b>a: print(""Yes"") else: m=max(a,b) if c0): c=c*2 k-=1 if b0): b=b*2 k-=1 if c>b and b>a: print(""Yes"") else: print(""No"")" p02601,s464969048,Wrong Answer,"import sys import math from collections import deque a,b,c=map(int,input().split()) k=int(input()) i=0 while b>a: b*=2 i+=1 while c>b: c*=2 i==1 if i<=k: print('Yes') else: print('No') " p02601,s802493502,Wrong Answer,"a,b,c = map(int,input().split()) k=int(input()) for i in range(k): if c<=a and c<=b: c=2*c elif b<=a: b=2*b else: pass if c > b and b > a and c >a: print(""Yes"") else: print(""No"")" p02601,s562616699,Wrong Answer,"import sys A, B, C = map(int,input().split()) k = int(input()) count=0 for i in range(k): if A>=B: count+=1 B=B*2 if B>=C: count+=1 C=C*2 if count>k: print('No') sys.exit() print('Yes')" p02601,s253242333,Wrong Answer,"num = input("""").split("" "") num = [int(i) for i in num] K = int(input("""")) for i in range(0,K): if num[0] > num[1]: num[1] = num[1] * 2 elif num[1] > num[2]: num[2] = num[2] * 2 elif num[0] > num[2]: num[2] = num[2] * 2 else: num[2] = num[2] * 2 if num[2] > num[1] > num[0]: print(""Yes"") else: print(""No"") " p02601,s864544728,Wrong Answer,"a = list(map(int, input().split())) n = int(input()) while 1: if n == 0: print(""No"") break n -= 1 if a[0] >= a[1]: a[1] *= 2 elif a[1] >= a[2]: a[2] *= 2 if a[0] < a[1] < a[2]: print(""Yse"") break" p02601,s428388560,Wrong Answer,"A,B,C = map(int,input().split()) K = int(input()) for i in range(K): if BA and CA and C>=B: print(""Yes"") else: print(""No"")" p02601,s612206580,Wrong Answer,"#!/usr/bin/env python # -*- coding: utf-8 -*- def main(): A, B, C = map(int, input().split()) K = int(input()) for _ in range(K): if A > B: B *= 2 elif B > C: C *= 2 if A < B < C: print(""Yes"") else: print(""No"") if __name__ == ""__main__"": main() " p02601,s090422212,Wrong Answer,"a,b,c=map(int,input().split()) k=int(input()) for i in range(k): if a>=b: b*=2 i+=1 elif b>=c: c*=2 i+=1 if i==0: break if a b: b *= 2 elif b > c: c *= 2 if a < b < c: print(""Yes"") else: print(""No"")" p02601,s504590155,Wrong Answer,"import sys def resolve(in_): a, b, c = map(int, next(in_).split()) k = int(next(in_)) for _ in range(k): if a >= b: b * 2 elif b >= c: c * 2 else: break return 'Yes' if a < b and b < c else 'No' def main(): answer = resolve(sys.stdin.buffer) print(answer) if __name__ == '__main__': main()" p02601,s835921939,Wrong Answer,"a, b, c = map(int, input().split()) k = int(input()) while k: k -= 1 b = b * 2 if b > a: break while k: k -= 1 c = c * 2 if c > b: break if(c > b and b > a): print(""Yes"") else: print(""No"")" p02601,s680974468,Wrong Answer,"import math A ,B, C = map(int, input().split()) N = int(input()) count = 0 if A > B: temp = math.log(A/B) / math.log(2) temp = math.ceil(temp) count += temp B = count * B else: count = 0 if B > C: temp = math.log(B/C) / math.log(2) temp = math.ceil(temp) count += temp C = count * C if C > B and count <= N: print(""Yes"") else: print(""No"")" p02601,s946807635,Wrong Answer,"a, b, c =input().split() k = int(input()) a = int(a) b = int(b) c = int(c) l = [] if k == 1: if a < 2*b < c or a < b < 2*c: l.append('Yes') else: l.append('No') else: for i in range(1, k+1): b = b**(2*i) c = c**(2*(k-i)) if c > b > a: l.append('Yes') break else: l.append('No') d = len(l) print(l[d-1])" p02601,s934179303,Wrong Answer,"from collections import defaultdict,deque import math def gcd(a,b): return b if not a%b else gcd(b,a%b) def lcm(a,b): return (a*b)//gcd(a,b) def main(): a,b,c=map(int, input().split()) k = int(input()) for i in range(k): if(cb and b>a): print(""Yes"") else: print(""No"") if __name__ == '__main__': main() " p02601,s213986891,Wrong Answer,"R,G,B=map(int,input().split()) K=int(input()) for _ in range (K) : if R > G : G*=2 continue else: pass if G > B : B*=2 continue else: pass if R < G < B : print('Yes') else : print('No')" p02601,s432224420,Wrong Answer,"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 if c > b & b > a: print('Yes') else: print('No') " p02601,s647260817,Wrong Answer,"A, B, C = map(int, input().split()) K = int(input()) import math x = int(math.log2(A / B)) + 1 y = int(math.log2(B * 2 ** x / C)) + 1 if x + y <= K: ans = 'Yes' else: ans = 'No' print(ans) " p02601,s268620770,Wrong Answer,"a,b,c=(int(x) for x in input().split()) k=int(input()) ans=0 for i in range(0,k): c=c*pow(2,i+1) b=b*pow(2,(k-(i+1))) if aC): C=C*2 print(A,B,C) elif(A>B): B=B*2 print(A,B,C) if (C>B >A): print('Yes') else: print('No')" p02601,s677840175,Wrong Answer,"A,B,C = map(int,input().split()) K = int(input()) cnt = 0 for _ in range(K): if A>=B: B *= 2 cnt += 1 else: break for _ in range(K-cnt): if B>=C: C *= 2 else: break print(cnt) if (AA, C>B ): print(""Yes"") else : print(""No"")" p02601,s177746887,Wrong Answer,"A, B, C = (int(x) for x in input().split()) K = int(input()) for i in range(K): if A > B: B *= 2 elif B > C: C *= 2 if A < B and B < C: print('Yes') else: print('No')" p02601,s429882714,Wrong Answer,"# -*- coding: utf-8 -*- A,B,C = map(int,input().split()) K = int(input()) flag = False #基からAB: B *= 2 else: C *= 2 if A b: b = b * 2 continue elif b > c: c = c * 2 continue if a < b < c: print('Yes') else: print('No') " p02601,s005856308,Wrong Answer,"a, b, c = map(int, input().split()) k = int(input()) flag = 0 for i in range(k): if a > b: b *=2 if b > a: flag = 1 if flag == 1 and b > c: c *= 2 if a < b < c: print('Yes') else: print('No') " p02601,s729470840,Wrong Answer,"a,b,c = map(lambda x: int(x), input().split()) k = int(input()) for _ in range(k): if b < a: b = 2 * b continue if c < b: c = 2 * c continue print('Yes') print('No')" p02601,s764333587,Wrong Answer,"A,B,C = map(int,input().split()) K = int(input()) import math x = math.ceil(math.log2(A/B)) if x < 0: x = 0 y = math.ceil(math.log2((B*(2**x))/C)) if y < 0: y = 0 if x + y <= K: print(""Yes"") else: print(""No"") " p02601,s937177030,Wrong Answer,"A, B, C = map(int, input().split()) K = int(input()) i_ans = 0 j_ans = 0 for i in range(1,8): B_after = B * (2 ** i) if B_after > A: i_ans = i break B_after = B * (2 ** i_ans) for j in range(1,8): C_after = C * (2 ** j) if C_after > B_after: j_ans = j break if i_ans + j_ans <=K: print('Yes') else: print('No')" p02601,s092141562,Wrong Answer,"a, b, c = map(int, input().split()) k = int(input()) for i in range(0, 3): c = c*2 if b < c: b = b*2 else: c = c*2 if a < b and b < c: print('Yes') else: print('No')" p02601,s472991680,Wrong Answer,"def main(): a, b, c = list(map(int, input().split())) k = int(input()) if b == 1 or c == 1: print('No') return count = 0 while count < k: if b <= a: b *= 2 count += 1 elif c <= b: c *= 2 count += 1 else: break if a < b and b < c: print('Yes') else: print('No') main()" p02601,s372663097,Wrong Answer,"from sys import exit import math ii = lambda : int(input()) mi = lambda : map(int,input().split()) li = lambda : list(map(int,input().split())) a,b,c = mi() k=ii() for i in range(k): if b < a: b*=2 elif c < b: c *= 2 if(a < b and b < c): print(""Yes"") exit() print(""No"")" p02601,s043493859,Wrong Answer,"a, b, c = map(int,input().split()) k = int(input()) count = -1 if a > b: for i in range(k): b = 2*b if a < b: count = i break if b > c: for j in range(count+1, k): c = 2*c if b < c: break if a < b and b < c: print(""Yes"") else: print(""No"") print(a, b, c)" p02601,s540888318,Wrong Answer,"word = input() nums = word.split() numin = [0,0,0] seiko = 0 for j in range(3): numin[j] = int(nums[j]) k = int(input()) for i in range(k+1): if numin[0] >= numin[1]: numin[1] *= 2 elif numin[1] >= numin[2]: numin[2] *= 2 else: seiko = 1 print('Yes') if seiko == 0: print('No')" p02601,s123420970,Wrong Answer,"R,G,B=map(int,input().split()) K = int(input()) i = 1 while (i <= K and (B<=G or G<=R)): if R>=G: G = G*2 i=i+1 if G>=B: B = B*2 i=i+1 if Rc: c=c*2 elif a>b: b=b*2 n=n+1 if b>a and c>b: print('Yes') else: print('No')" p02601,s072528490,Wrong Answer,"import math a, b, c = map(int, input().split()) k = int(input()) a_b = math.ceil(math.log2((a+1)/b)) b = b * 2 ** a_b b_c = math.ceil(math.log2((b+1)/c)) if a_b + b_c <= k: print('Yes') else: print('No')" p02601,s821739621,Wrong Answer,"a, b, c = map(int, input().split()) k = int(input()) c = c*2 if k > 1: for i in range(1,k): if b < c: if i != k-1: b = b*2 else: c = c*2 else: c = c*2 if a < b and b < c: print('Yes') else: print('No')" p02601,s093099412,Wrong Answer,"a, b, c = map(int, input().split()) k = int(input()) while k > 0 and b >= c: c*=2 k-=1 while k > 0 and a>=b: b*=2 k-=1 print(""Yes"" if c>=b>=a else ""No"")" p02601,s775035289,Wrong Answer,"A, B, C = map(int, input().split()) K = int(input()) for _ in range(K): if A <= B <= C: C *=2 elif C <= A <= B: C *=2 elif B <= A <= C: B *=2 elif C <= B <= A: C *=2 elif A <= C <= B: C *= 2 if A < B < C: print('Yes') else: print('No')" p02601,s148154356,Wrong Answer,"A,B,C=map(int,input().split()) K=int(input()) for i in range(0,K+1): for j in range(0,K+1-i): for k in range(0,K+1-i-j): #print('{},{},{}'.format(i,j,k)) if(A*i*2+A < B*j*2+B and B*j*2+B < C*k*2+C): print('Yes') exit() print('No') " p02601,s017917067,Wrong Answer,"A,B,C = [int(x) for x in input().split()] K = int(input()) for b in range(1,K+1): if A < B * 2**b: kb = b break if B * 2**kb < C * 2**(K-kb): print(""Yes"") else: print(""No"") " p02601,s486259338,Wrong Answer,"a, b, c = map(int, input().split(' ')) k = int(input()) flag=0 for i in range(0, k+1): bb = b * (2**i) j = k-i cc = c * (2**j) if (a < bb) and (bb < cc): print('Yes') flag=1 if flag==0: print('No')" p02601,s436528458,Wrong Answer,"[a, b, c] = [int(x) for x in input().split("" "")] k = int(input())" p02601,s442064018,Wrong Answer,"A,B,C=map(int,input().split()) X=int(input()) while X>0: if B a and c > b: break if b < a: b *= 2 elif b > c: c *= 2 if b > a and c > b: print('Yes') else: print('No')" p02601,s883482355,Wrong Answer,"A, B, C = list(map(int, input().split())) count = 0 while A >= B: B *= 2 count += 1 while B >= C: C *= 2 count += 1 print('Yes' if count <= 3 else 'No')" p02601,s603766604,Wrong Answer,"a,b,c = map(int,input().split()) k = int(input()) cnt = 0 while a >= b: b *= 2 while b >= c: c *= 2 if cnt <= k: print(""Yes"") else: print(""No"") " p02601,s105545078,Wrong Answer,"a, b, c = map(int, input().split()) k = int(input()) ans = ""No"" for bi in range(k+1): bb = b cc = c * (2 ** (k - bi)) for _ in range(bi): bb *= 2 if a < bb and bb < cc: ans = ""Yes"" if ans == ""Yes"": break print(ans) " p02601,s006184813,Wrong Answer,"from sys import stdin import sys import itertools as it A, B, C = [int(x) for x in stdin.readline().rstrip().split()] K = int(input()) if C > B and B > A: print(""Yes"") sys.exit() for i in range(K): c1 = C*(2**i) b1 = B*(2**(K-i)) if c1 > b1 and b1 > A: print(""Yes"") sys.exit() print(""No"") " p02601,s686206111,Wrong Answer,"r,g,b=map(int,input().split()) k=int(input()) for i in range(0,k): b1=b*2*i g1=g*2*(k-i) if r= 3: result = True if a == b or b == c or c == a: if k >= 2: result = True for l in lst: al, bl, cl = a*(2**l[a]), b*(2**l[b]), c*(2**l[c]) if (bl > al) and (cl > bl): result = True if result: print('Yes') else: print('No')" p02601,s655257272,Wrong Answer,"A, B, C = map(int, input().split()) K = int(input()) flag = 0 for i in range(K): if A > B: B = B*2 elif B > C: C = C*2 if B < C: print(""Yes"") break else: print(""Yes"") break flag += 1 if K == flag: print(""No"")" p02601,s873827327,Wrong Answer,"a,b,c=(int(x) for x in input().split()) k=int(input()) n=0 while kn or c<=b: c=c*2 n=n+1 if c= A : B *= 2 else: C *= 2 if B > A : print(A , B , C) if C > B: print(""Yes"") sys.exit() print(""No"")" p02601,s846668161,Wrong Answer,"a,b,c=map(int, input().split()) k=int(input()) ans=""no"" for i in range(k+1): if a=b: b*=2 elif b>=c: c*=2 else: c*=2 print(ans)" p02601,s005208338,Wrong Answer,"a,b,c=map(int,input().split()) k=int(input()) for i in range (k): if (b < a ): b = b*2 elif (c=B: B=2*B elif B>=C: C=2*C else: print('Yes') break if (A>=B or B>=C) or (A>=B and B>=C): print('No') else: print('Yes')" p02601,s898213379,Wrong Answer,"import sys a, b, c = map(int, input().split()) k = int(input()) while True: if b <= a: b = b*2 k += -1 if k == 0: print('No') sys.exit() else: break while True: if c <= b: c = c*2 k += -1 if k == 0: print('No') sys.exit() else: break print('Yes')" p02601,s875755230,Wrong Answer,"A, B, C = input().split() A = int(A) B = int(B) C = int(C) K = input() K = int(K) z = 0 while B <= A: B = B * 2 z = z + 1 while C <= B: C = C * 2 z = z + 1 if K < z: print('NO') else: print('YES')" p02601,s214272534,Wrong Answer,"A,B,C = map(int,input().split()) K = int(input()) N = K STOP1 = False STOP2 = False for i in range(K): if B < A and N>0: N-=1 B*=2 for i in range(N): if C < B: C*=2 if B>A and C>B: print(""Yes"") else: print(""No"")" p02601,s590391002,Wrong Answer,"A, B, C = map(int, input().split()) K = int(input()) a = 2*A b = 2*B c = 2*C if b>a and c>b: print('Yes') else: print('No') " p02601,s573824254,Wrong Answer,"r,g,b=map(int,input().split()) k=int(input()) for i in range(k): if r>g: g*=2 elif g>b: b*=2 if r= 3: result = True if a == b or b == c or c == a: if k >= 3: result = True for l in lst: al, bl, cl = a*(2**l[a]), b*(2**l[b]), c*(2**l[c]) if (bl > al) and (cl > bl): result = True if result: print('Yes') else: print('No')" p02601,s259384811,Wrong Answer,"A, B, C = map(int, input().split()) K = int(input()) for i in range(K): if B < A: B *= 2 elif C < B: C *= 2 else: C *= 2 if A < B and B < C: print('Yes') else: print('No') " p02601,s501678291,Wrong Answer,"A, B, C = map(int, input().split()) K = int(input()) while K > 0: if C < B: C *= 2 if B < A: B *= 2 K -= 1 if A < B and B < C and A < C: print('yes') else: print('no') " p02601,s681390381,Wrong Answer,"a,b,c = map(int , input().split()) k = int(input()) while(k>=1): if c B and K > 0: B *= 2 K -= 1 while B > C and K > 0: C *= 2 K -= 1 if A < B and B < C: print(""Yes"") else: print(""No"") " p02601,s481976896,Wrong Answer,"R,G,B=map(int,input().split()) K = int(input()) i = 1 while i <= K and (B<=G or G<=R): if R>=G: G = G*2 i+=1 if G>=B: B = B*2 i+=1 if Rb: b=b*2 elif b>c: c=c*2 if b>a and c>b: print('Yes') else: print('No')" p02601,s698739018,Wrong Answer,"A,B,C = map(int,input().split()) K = int(input()) while A > B: B *= 2 K -= 1 while B > C: C *= 2 K -= 1 print('Yes' if K >= 0 else 'No')" p02601,s190336925,Wrong Answer,"import random data = list(map(int, input().split())) K = int(input()) for i in range(K): l = [0, 1, 2] num = random.choice(l) data[num] = data[num]*2 if data[1] > data[0] and data[2] > data[1]: print(""Yes"") exit() print(""No"") " p02601,s752589398,Wrong Answer,"a,b,c=map(int, input().split()) k=int(input()) d=k for i in range(k): if b < a: b = b*2 if b > a: d=d-i break; for i in range(d): if c < b: c = c*2 if c > b: break; if a < b and b < c: print('Yes') else: print('No')" p02601,s021936042,Wrong Answer,"a,b,c= list(map(int, input().strip().split())) N = int(input().strip()) x=0 y=N for i in range(100): b*=2 x=x+1 y=y-1 if b>a: break if y<0: if c<=b: print(""No"") else: print(""Yes"") else: for i in range(y): c*=2 if c<=b: print(""No"") else: print(""Yes"")" p02601,s972963058,Wrong Answer,"a,b,c= list(map(int, input().strip().split())) N = int(input().strip()) x=0 y=N for i in range(100): b*=2 x=x+1 y=y-1 if b>a: break if x>=N: if c<=b: print(""No"") else: print(""Yes"") else: for i in range(y): c*=2 if c>b: print(""Yes"") else: print(""No"")" p02601,s828021489,Wrong Answer,"def NextIntList(): return list(map(int,input().split())) def NextInts(): return map(int,input().split()) import itertools A,B,C = NextInts() l = [""A"",""B"",""C""] K = int(input()) for v in itertools.combinations_with_replacement(l, K): A_number = v.count(""A"") B_number = v.count(""B"") C_number = v.count(""C"") print(A_number) if C_number*2+C>B_number*2+B>A_number*2+A: print(""Yes"") break else: print(""Yes"")" p02601,s156748933,Wrong Answer,"a, b, c = map(int, input().split()) k = int(input()) cnt = 0 while a>=b: b *= 2 cnt += 1 while b>=c: c *= 2 cnt += 1 if(cnt <= k): print(""YES"") else: print(""NO"") " p02601,s945209524,Wrong Answer," A,B,C = list(map(int, input().split())) K = int(input()) is_true = False for i in range(K): if B > C: C *= 2 elif A > B: B *= 2 # print(A,B,C) if A < B < C: print(""Yes"") else: print(""No"") #print(is_true) " p02601,s214753928,Wrong Answer,"a, b, c = map(int, input().split()) k = int(input()) n = 0 if a+1 > b: i = 1 while b*(2**i) < a: i += 1 n += i #print(n,i) if a+2 > c: i = 1 while c*(2**i) < a+1: i += 1 n += i #print(n,i) if k >= n: print('Yes') else: print('No') " p02601,s383599052,Wrong Answer,"a,b,c = map(int,input().split()) k = int(input()) for i in range(k+1): if a < b and b < c: print(""Yes"") exit() elif b > c: c *= 2 elif a > b: b *= 2 print(""No"")" p02601,s364863933,Wrong Answer,"a,b,c = map(int,input().split()) k = int(input()) for i in range(k): if b < a: b = b*2 elif b > c: c = c*2 if b > a and c > b: print('Yes') else: print('No')" p02601,s535990371,Wrong Answer,"A, B, C = input().split() A, B, C = [int(A), int(B), int(C)] K = int(input()) for i in range(K): if(B > C or A > C): C = C * 2 elif(A > B): B = B * 2 if(C > B > A): print(""Yes"") else: print(""No"") " p02601,s533405322,Wrong Answer,"a,b,c=map(int, input().split()) n=int(input()) flg = 0 while n > 0: if flg == 0: b = b * 2 n = n - 1 #print(a,b,c) if a < b: flg = 1 else: c = c * 2 n = n - 1 #print(a,b,c) if b < c: print('Yes') exit() print('No')" p02601,s335463962,Wrong Answer,"l = list(map(int,input().split())) r, g, b = l[0], l[1], l[2] k = int(input()) for _ in range(k): if r >= g: g *= 2 elif g >= b: b *= 2 else: print('Yes') break print('No')" p02601,s112270785,Wrong Answer,"a,b,c = map(int,input().split()) k = int(input()) for i in range(k): if b < a: b *= 2 if b > c: c *= 2 if b > a and c > b: print('Yes') else: print('No')" p02601,s009497203,Wrong Answer,"X = list(map(int,input().split())) A = X[0] B = X[1] C = X[2] K = int(input()) cnt = 0 if A > B: for i in range(7): B = B*2 cnt = cnt + 1 if A < B: break if B > C: for j in range(7): C = C*2 cnt = cnt + 1 if B < C: break if cnt <= K: print('YES') else: print('NO') " p02601,s056082469,Wrong Answer,"a, b, c = map(int, input().split()) k = int(input()) for i in range(k): if b < a: b = b * 2 elif c < b: c = c * 2 else: pass if (a < b) & (b < c): print('Yes') else: print('No')" p02601,s045444193,Wrong Answer,"a,b,c=map(int,input().split()) k=int(input()) re=0 re1=0 for i in range (k): re=re+b*2 if (re > a ): re1 = re1 + c*2 if (re1 > b): print(""Yes"") quit() else: print(""NO"") quit()" p02601,s446674582,Wrong Answer,"from math import sqrt,ceil,gcd def ii():return int(input()) def si():return input() def mi():return map(int,input().split()) def li():return list(mi()) # for _ in range(ii()): a,b,c=mi() k=ii() for i in range(k): if a>b: b*=2 else: c*=2 if a c and b > c): c*=2 elif(a > b): b*=2 if(a < b and b < c): print(""Yes"") else: print(""No"") d,e,f = map(int,input().split()) j = int(input()) magic(d,e,f,j) " p02601,s009799207,Wrong Answer,"A, B, C = input().split() A = int(A) B = int(B) C = int(C) K = input() K = int(K) z = 0 while B <= A: B = B * 2 z = z + 1 while C <= B: C = C * 2 z = z + 1 if K < z: print('NO') else: print('YES') " p02601,s984421485,Wrong Answer,"a,b,c=map(int,input().split()) k=int(input()) if c>b and b>a: print('Yes') for i in range(k): if a>c: c=c*2 if a>c: c=c*2 if ab: b=b*2 if c>b and b>a: print('Yes') else: print('No')" p02601,s110701424,Wrong Answer,"a,b,c=map(int,input().split()) k=int(input()) num=0 while a>b: b*=2 num+=1 if b>a: break while b>c: c*=2 num+=1 if c>b: break if num<=k: print(""Yes"") else: print(""No"") " p02601,s737737626,Wrong Answer,"A=list(map(int,input().split())) K=int(input()) a=A[0] b=A[1] c=A[2] count=0 while count<=K: if a>=b: b=b*2 count=count+1 else: break if count==K: pass else: c=c*(K-count)*2 if a B : B = B*2 else: if B > C : C = C*2 if C > B & B > A: print(""Yes"") else: print(""No"") " p02601,s575387915,Wrong Answer,"A, B, C = [int(n) for n in input().split()] K = int(input()) ans = 'No' for i in range(1, K): B *= 2 for j in range(1, K): C *= 2 if A 0 and r > g: k -= 1 g *= 2 while k > 0 and g > b: k -= 1 b *= 2 if r < g < b: print(""Yes"") else: print(""No"")" p02601,s478415644,Wrong Answer,"# -*- coding: utf-8 -*- A,B,C = map(int,input().split()) K = int(input()) flag = False for i in range(K): if A>B: B *= 2 continue else: C *= 2 continue if A= a[1]: a[1] *= 2 elif a[1] >= a[2]: a[2] *= 2 elif a[0] < a[1] < a[2]: print(""Yse"") break if n == 0: print(""No"") break n -= 1" p02601,s690474303,Wrong Answer,"def main(): a, b, c = map(int, input().split()) k = int(input()) for i in range(1, k+2): if a < b and b < c: print(""Yes"") return 0 elif i == k+1: print(""No"") return 0 elif c < a or c < b: c = c * 2 elif b < a: b = b * 2 main()" p02601,s377598591,Wrong Answer,"a = list(map(int,input().split())) k = int(input()) #青>緑>赤 r,g,b = 0,0,0 for i,num in enumerate(a): if i==0: r = num elif i==1: g = num elif i==2: b = num for i in range(k): if gg and g>r: break if b>g and g>r: print(""Yes"") else: print(""No"")" p02601,s272953454,Wrong Answer,"A,B,C = map(int,input().split()) K = int(input()) sum = 0 sum1 = 0 sum2 = 0 for i in range(K): if (C): sum2+=C*2 elif(B): sum1+=B*2 elif(A): sum+=A*2 if (sum1>sum or sum2>sum1 or (sum1>sum and sum2>sum1)): print('Yes') else: print('No')" p02601,s471749058,Wrong Answer,"a, b, c = map(int, input().split()) k = int(input()) for i in range(k): if a > b: b *= 2 continue c *= 2 if a < b and b < c: print(""Yes"") else: print(""No"") " p02601,s891836651,Wrong Answer,"a,b,c = map(int,input().split()) k = int(input()) if b<=a: x = 0 for i in range(k): b*=2 if a < b: x += (i+1) break else: x += k y = 2*(k-x) if k-x > 0 else 1 else: y = 0 y += (k*2) print(['No','Yes'][ba and c>b: print('Yes') else:print('No')" p02601,s086644322,Wrong Answer,"A,B,C = map(int,input().split()) N = int(input()) stack = [(A,B,C,N)] flag = False while stack: a,b,c,n = stack.pop() if a0: stack.append((a*2,b,c,n-1)) stack.append((a,b*2,c,n-1)) stack.append((a,b,c*2,n-1)) print('Yes') if flag else print('No')" p02601,s730414987,Wrong Answer,"a,b,c = map(int,input().split()) k = int(input()) while k > 0 and a > b: b *= 2 k -= 1 while k > 0 and b > c: c *= 2 k -= 1 if k >= 0 and ac: c=c*2 elif ac: c=c*2 elif ab and ab or a>c or b>c: print('No')" p02601,s295503800,Wrong Answer,"a,b,c=map(int,input().split()) k=int(input()) for i in range(0,k+1): asw=False for j in range(0,k+1): if i+j<=k and a g > r): flg = 1 break else: if not g > r : g *= 2 elif not b > b: b *= 2 if flg == 1: print (""Yes"") else: print (""No"") " p02601,s244149438,Wrong Answer,"A, B, C = map(int, input().split()) K = int(input()) def isMoreK(c): return c > K count = 0 while A >= B: B *= 2 count += 1 while B >= C: C *= 2 count += 1 if isMoreK(count): print('No') else: print('Yes') " p02601,s905653910,Wrong Answer,"A,B,C=(input().split()) K = int(input()) A = int(A) B = int(B) C = int(C) for i in range(K): print(i) 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"")" p02601,s304513247,Wrong Answer,"a, b, c = map(int, input().split()) k = int(input()) while k > 0: if c < b: c*=2 elif b < a: b*=2 k-=1 print(""Yes"" if c>b>a else ""No"")" p02601,s824790890,Wrong Answer,"A, B, C, K = 2, 4, 3, 4 a = 0 for i in range(K): if C > B and B > A: print(""Yes"") a = 1 else: if A <= B: B = 2*B K = K+1 elif C <= B: C = 2*C K = K+1 if a == 0: print(""No"")" p02601,s129208308,Wrong Answer,"a,b,c=map(int,input().split()) k=int(input()) for i in range(k): if a>=b: b=b*2 else: if b>=c: c=c*2 print(a,b,c) else: break if a target: target = doub #b b = target doub = c flg_1 = True doub *= 2 if flg_1 is True and doub > b: print(""Yes"") else: print(""No"") resolve()" p02601,s048843907,Wrong Answer,"a = list(map(int,input().split())) #b = list(map(int,input().split())) b=int(input()) for i in range(b): if a[0]<=a[1]<=a[2] or a[0]<=a[2]<=a[1] or a[2]<=a[1]<=a[0] or a[1]<=a[2]<=a[0] or a[2]<=a[0]<=a[1]: a[2]=2*a[2] elif a[1]<=a[0]<=a[2]: a[1]=2*a[1] if a[0]= b: b = int(b * 2) print(a, b, c) continue elif b >= c: c = int(c * 2) print(a, b, c) continue if a < b < c: print('Yes') else: print('No') " p02601,s684673065,Wrong Answer,"a,b,c,k=map(int,open(0).read().split()) while k:k-=1;t=ac::2])" p02601,s032824298,Wrong Answer,"A, B, C = [int(n) for n in input().split()] K = int(input()) a = (A+B-1)//B b = (A+C-1)//C print('Yes' if (a+b)//2<=K and A<=B*a<=C*b else 'No')" p02601,s014989031,Wrong Answer,"a,b,c = map(int, input().split()) k = int(input()) ans = False for _ in range(k): if c>b>a: ans = True break if a > c: c *= 2 continue if c < b: if b < a: b *= 2 else: c *= 2 else: b *= 2 if c>b>a: ans = True if ans: print('Yes') else: print('No') " p02601,s677257424,Wrong Answer,"a,b,c=map(int,input().split()) k=int(input()) while True: count=1 if a>=b: b*=2 count+=1 else: break k-=count if b< c*k: print('Yes') else: print('No')" p02601,s080566993,Wrong Answer,"num = input("""").split("" "") num = [int(i) for i in num] K = int(input("""")) for i in range(0, K): if num[1] > num[2]: num[2] = num[2] * 2 elif num[0] > num[1]: num[1] = num[1] * 2 elif num[0] > num[2]: num[2] = num[2] * 2 else: num[2] = num[2] * 2 if num[2] > num[1] > num[0]: print(""Yes"") else: print(""No"") " p02601,s359089367,Wrong Answer,"A, B, C = list(map(int, input().split(' '))) K = int(input()) cnt = 0 flg = 0 while cnt < K: if B <= A: if B <= 7: B *= 2 elif C <= B: if C <= 7: C *= 2 cnt += 1 if A < B < C: flg = 1 break if flg == 1: print(""Yes"") else: print(""No"")" p02601,s171434713,Wrong Answer,"a, b, c = map(int, input().split()) k = int(input()) ans = 0 for x in range(k): for y in range(k): for z in range(k): if b**2*y > a**2*x and c**2*z > b**2*y: ans += 1 if ans >= 1: print(""Yes"") else: print(""No"") " p02601,s102306019,Wrong Answer,"A,B,C = list(map(int, input().split())) K = int(input()) for i in range(K): if (BB): break else: C=C*2 continue if (A= 0: print(""Yes"") else: print(""No"")" p02601,s466639352,Wrong Answer,"a, b, c = map(int, input().split()) k = int(input()) m = 0 n = 1 while a > b: m = m + 1 b = b * 2 if a < b: break while b > c: n = n + 1 c = c * 2 if b < c: break if m + n <= k: print('Yes') elif m + n > k: print('No') " p02601,s125111236,Wrong Answer,"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 if c > b & b > a: print('Yes') else: print('No') " p02601,s821979123,Wrong Answer,"A, B, C = map(int,input().split()) K = int(input()) flag = False for i in range(0, K+1): for j in range(0, K+1): for k in range(0, K+1): x = A * 2**i y = B * 2**j z = C * 2**k # print(x, y, z) if x < y < z: flag = True if flag == True: print('Yes') else: print('No')" p02601,s945641383,Wrong Answer,"a,b,c=map(int,input().split()) k=int(input()) if a>=b: d=(a/b)//2+1 b=b*(2**d) else: d=0 if b>=c: e=(b/c)//2+1 else: e=0 if k>=d+e: print(""Yes"") else: print(""No"") " p02601,s796795137,Wrong Answer,"A,B,C = map(int,input().split()) N = int(input()) stack = [(A,B,C,N)] flag = False while stack: a,b,c,n = stack.pop() if a0: stack.append((a*2,b,c,n-1)) stack.append((a,b*2,c,n-1)) stack.append((a,b,c*2,n-1)) print('Yes') if flag else print('No') " p02601,s405449619,Wrong Answer,"A,B,C = map(int,input().split()) K = int(input()) if A B: B = B*2 else: C = C*2 if A B: B *= 2 elif B > C: C *= 2 if A < B < C: print(""Yes"") exit() print(""No"") " p02601,s998952582,Wrong Answer,"cards = list(map(int,input().split())) K = int(input()) count=0 while countcards[2]: cards[2]*=2 count+=1 elif cards[0]>cards[1]: cards[1]*=2 count+=1 else: cards[0]*=2 count+=1 print(cards) if cards[0]B: B*=2 elif B>C: C*=2 if A b: b *= 2 elif b > c: c *= 2 if a < b < c: print('Yes') else: print('No') " p02601,s271411620,Wrong Answer,"A,B,C = map(int, input().split()) K = int(input()) count = 0 for x in range(K): B = B * 2 count = count + 1 if B > A: break for y in range(K-count): C=C*2 if C>B: break if C>B>A: print(""Yes"") else: print(""No"") " p02601,s860017658,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 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 if a < b and b < c: print(""Yes"") else: print(""No"")" p02601,s241648253,Wrong Answer,"A, B, C=map(int,input().split()) K=int(input()) ab=int(A/B) x=int(len(bin(ab))-2) B1=B*(2**x) bc=int(B1/C) y=int(len(bin(bc))-2) if x+y<=K: print(""Yes"") else: print(""No"")" p02601,s427748585,Wrong Answer,"a,b,c = map(int,input().split()) k = int(input()) for i in range(k): if b < a: b*=2 else: c*=2 if c>b>a: print('Yes') else: print('No')" p02601,s998462531,Wrong Answer,"# -*- coding: utf-8 -*- A,B,C = map(int,input().split()) K = int(input()) flag = False for i in range(K): if A>B: B *= 2 continue else: C *= 2 continue if A= c: b //= 2 x += 1 while a >= b: a //= 2 x += 1 if x <= k: print('Yes') else: print('No')" p02601,s570571420,Wrong Answer,"import sys A, B, C = map(int,input().split()) k = int(input()) count=0 for i in range(k): if A>=B: count+=1 B=B*2 if count>k: print('No') sys.exit() for i in range(k): if B>=C: count+=1 C=C*2 if count>k: print('No') sys.exit() print('Yes')" p02601,s911182798,Wrong Answer,"R,G,B = map(int,input().split()) K = int(input()) for i in range(K): if G < R: G *= 2 elif B < G: B *= 2 print('Green: ' + str(G) + ' blue:' + str(B)) if R < G and G < B: print('Yes') else: print('No')" p02601,s136609328,Wrong Answer,"A, B, C = map(int, input().split()) K = int(input()) ans = ""No"" for a in range(K): for b in range(K): for c in range(K): if a+b+c<=K and (A<= 0: print(""Yes"") else: print(""No"")" p02601,s788665859,Wrong Answer,"a,b,c=[int(i) for i in input().split()] n=int(input()) flag=0 e=0 while(a>=b): b=b*2 e=e+1 while(ea and c>b and e<=n): print('YES') else: print('NO')" p02601,s562752332,Wrong Answer,"A, B, C = map(int, input().split()) K = int(input()) # 魔術成功 # A 赤 # B 緑 # C 青 # a < b < c になれば成功 def magic(cards: list, k: int): if k == 0: if cards[0] < cards[1] < cards[2]: return 'Yes' else: return 'No' cards[cards.index(min(cards))] *= 2 k -= 1 return magic(cards, k) print(magic([A, B, C], K)) " p02601,s557945630,Wrong Answer,"a,b,c=map(int,input().split()) k=int(input()) ans=0 m2=a if m2>b: for i in range(1,4): b=b*2 ans+=1 if b>m2: break m=max(a,b) if m>=c: for i in range(1,4): c=c*2 ans += 1 if c>m: break if ans<=k: print(""Yes"") else: print(""No"") " p02601,s263197037,Wrong Answer,"li = input().split() a=int(input()) magic = 0 for i in range(0,8): if li[0] >= li[1]: li[1] = li[1] * 2 magic = magic + 1 for i in range(0,8): if li[1] >= li[2]: li[2] = li[2] * 2 magic = magic + 1 if a >= magic: print(""Yes"") else: print(""No"")" p02601,s848513752,Wrong Answer,"cards = list(map(int,input().split())) K = int(input()) for i in range(K): if cards[1]<=cards[0]: cards[2]*=2 continue if cards[2]<=cards[1]: cards[1]*=2 continue else: break if cards[0] B**j > A**i: print(""Yes"") sys.exit() else: continue print(""No"")" p02601,s752127149,Wrong Answer,"a,b,c=map(int,input().split()) k=int(input()) if c>b and b>a: print(""Yes"") else: m=max(a,b) if c<=m: while(c<=m and k>0): c=c*2 k-=1 if b<=a: while(b<=a and k>0 and 2*bb and b>a: print(""Yes"") else: print(""No"")" p02601,s807277012,Wrong Answer,"abc = input('') a = int(abc.split()[0]) b = int(abc.split()[1]) c = int(abc.split()[2]) k = int(input('')) result = False for i in range(k): if a>b: b*=2 elif b>c: c*=2 # print('{}/{}/{}'.format(a,b,c)) if a b: b*=2 elif b > c: c*=2 else: break if a < b and b < c: print('Yes') else: print('No') return if __name__=='__main__': main() " p02601,s813545223,Wrong Answer,"a, b, c = map(int, input().split()) k = int(input()) for _ in range(k): if a > b: b *= 2 elif b > c: c *= 2 if a < b < c: print('Yes') else: print('No')" p02601,s901460340,Wrong Answer,"A,B,C=map(int,input().split()) K=int(input()) ans=0 for i in range(0,K+1): for j in range(0,K+1-i): for k in range((K-i-j),K+1-i-j): if(A*i*2+A < B*j*2+B and B*j*2+B < C*k*2+C): print('Yes') exit() print('No') " p02601,s171639866,Wrong Answer,"a, b, c = map(int, input().split()) k = int(input()) for _ in range(k): if a > b: b *= 2 elif b > c: c *= 2 if a < b < c: print('Yes') else: print('No')" p02601,s257942904,Wrong Answer,"A,B,C = map(int,input().split()) K = int(input()) for k in range(K): if A < B < C: break elif A > B: B = B*2 elif B > C: C = C*2 if A < B < C: print('Yes') else: print('No')" p02601,s366545241,Wrong Answer,"A,B,C = map(int,input().split()) K = int(input()) N = K STOP1 = False STOP2 = False for i in range(K): if B < A and N>0: N-=1 B*=2 if B >=A: break for i in range(N): if C < B: C*=2 if B>=A and C>=B: print(""Yes"") else: print(""No"")" p02601,s079645081,Wrong Answer,"A, B, C = map(int, input().split()) K = int(input()) for _ in range(K): if A > B: B *= 2 elif B > C: C *= 2 if A < B < C: print('Yes') else: print('No')" p02601,s821223082,Wrong Answer,"import sys input = lambda : sys.stdin.readline().rstrip() r, g, b = map(int, input().split("" "")) k = int(input()) for i in range(k): if g <= b: g *= 2 elif b <= g: b *= 2 if b > g > r: print(""Yes"") else: print(""No"")" p02601,s257413949,Wrong Answer,"a,b,c =map(int,input().split()) p=int(input()) cnt=0 for i in range(1,p+1): for j in range(1,p+1): for k in range(1,p+1): if i+j+k==p+3 and a*2**(i-1) < b*2**(j-1) and b*2**(j-1) < c*2**(k-1): cnt+=1 if cnt >0: print('Yes') else: print('No')" p02601,s591828653,Wrong Answer,"def resolve(): a, b, c = map(int, input().split()) k = int(input()) for _ in range(k): if b < a: b *= 2 if b > a and c < b: c *= 2 if a < b < c: print(""Yes"") else: print(""No"") resolve()" p02601,s826361070,Wrong Answer,"A, B, C = list(map(int, input().split(' '))) K = int(input()) cnt = 0 while cnt < K: if B <= A: if B <= 7: B *= 2 elif C <= B: if C <= 7: C *= 2 cnt += 1 if A < B < C: print(""Yes"") else: print(""No"")" p02601,s896660505,Wrong Answer,"red, green, blue = map(int, input().split()) K = int(input()) # blue > green > red for i in range(K): if green < red: green *= 2 continue if blue < green: blue *= 2 if blue > green > red: print('Yes') else: print('No') " p02601,s671997908,Wrong Answer,"A,B,C = map(int, input().split()) K = int(input()) D = B E = C i1 = 0 i2 = 0 while(D= i1+i2+1: print(""Yes"") else: print(""No"") print(i1) print(i2) print(D) print(E) " p02601,s443428975,Wrong Answer,"A,B,C=(input().split()) K= int(input()) A = int(A) B = int(B) C = int(C) for i in range(K): if C < B: C = C*2 elif B < A: B = B*2 if A < B and B < C: print(""Yes"") else: print(""No"")" p02601,s378368431,Wrong Answer,"a, b, c = map(int, input().split()) k = int(input()) while a > b and k > 0: b *= 2 k -= 1 while b > c and k > 0: c *= 2 k -= 1 if a < b < c: print(""Yes"") else: print(""No"")" p02601,s199255546,Wrong Answer,"import sys def resolve(in_): a, b, c = map(int, next(in_).split()) k = int(next(in_)) for _ in range(7): if a >= b: b * 2 elif b >= c: c * 2 else: break return 'Yes' if a < b and b < c else 'No' def main(): answer = resolve(sys.stdin.buffer) print(answer) if __name__ == '__main__': main()" p02601,s981033624,Wrong Answer,"a , b , c = map(int, input().split()) k = int(input()) cnt = 0 while a >=b: b*=2 cnt+=1 while b >=c: c*=2 cnt+=1 if cnt <=3: print(""YES"") else: print(""NO"")" p02601,s775131986,Wrong Answer,"a, b, c = input().split() k = int(input()) a = int(a) b = int(b) c = int(c) for i in range(1, k): if (b <= a): b *= 2 elif (c <= b): c *= 2 i += 1 if (c > b and b > a): print(""No"") else: print(""Yes"") " p02601,s315593410,Wrong Answer,"import sys input = sys.stdin.readline ''' ''' a, b, c = map(int, input().split()) k = int(input()) def solve(k, tup): a, b, c = tup while k: if a >= b: b *= 2 k -= 1 continue if b >= c: c *= 2 k -= 1 continue if a < b < c: return ""YES"" else: return ""NO"" print(solve(k, (a, b, c)))" p02601,s191173443,Wrong Answer,"a,b,c=map(int,input().split()) k=int(input()) d=2**k if d*b>a: print('Yes') elif d*c > b: print('Yes') else: print(""No"")" p02601,s821349340,Wrong Answer,"a,b,c = map(int,input().split()) k = int(input()) for i in range(k): if a > b: b *= 2 elif b > c: c *= 2 else: break if a < b < c: print('Yes') else: print('No')" p02601,s140022745,Wrong Answer,"A,B,C = map(int,input().split()) K = int(input()) for i in range(K): tmp = min(B,C) if(B==tmp): B *= 2 else: C *= 2 # print(A,B,C) if A< B and BK: print(""No"") else: print(""Yes"")" p02601,s276261945,Wrong Answer,"A, B, C = map(int, input().split()) K = int(input()) if (B*(2**K-1) < A or C*(2**K-1) < A): print(""No"") else: print(""Yes"")" p02601,s644708658,Wrong Answer,"X = list(map(int,input().split())) A = X[0] B = X[1] C = X[2] K = int(input()) cnt = 0 if A >= B: for i in range(K): B = B*2 cnt = cnt + 1 if A < B: break if B >= C: for j in range(K): C = C*2 cnt = cnt + 1 if B < C: break if cnt <= K: print('Yes') else: print('No') " p02601,s000093710,Wrong Answer,"A = input().split() K = int(input()) for i in range(len(A)): A[i] = int(A[i]) a = 0 for i in range(K): if A[2] > A[1] and A[1] > A[0]: print(""Yes"") a = 1 break else: if A[0] <= A[1]: A[1] = 2*A[1] K = K+1 elif A[2] <= A[1]: A[2] = 2*A[2] K = K+1 if a == 0: print(""No"")" p02601,s253212602,Wrong Answer,"a,b,c = map(int,input().split()) k = int(input()) for i in range(k): if b < a: b*=2 continue if c < b: c*=2 if a < b and b < c: print(""Yes"") else: print(""No"")" p02601,s367998073,Wrong Answer,"a,b,c = map(int,input().split()) k = int(input()) is_Ok = False for i in range(k) : # print(k,a,b,c) if (a > b) : b *= 2 continue if (b > c) : c *= 2 continue if (a 1: for i in range(1,k): if b < c: b = b*2 else: c = c*2 if a < b and b < c: print('Yes') else: print('No')" p02601,s498599956,Wrong Answer,"import itertools l = list(map(int,input().split())) k = int(input()) p = list(itertools.combinations_with_replacement([0,1,2], k)) f = False ans = 0 for i in p: a = (l[0] * 2 * i.count(0) if i.count(0) else l[0]) b = (l[1] * 2 * i.count(1) if i.count(1) else l[1]) c = (l[2] * 2 * i.count(2) if i.count(2) else l[2]) if a K: ans = ""No"" else: if 2**(K - k_b) * C > 2**k_b * B: ans = ""Yes"" else: ans = ""No"" # 結果出力 print(ans)" p02601,s989377880,Wrong Answer,"a, b, c = map(int, input().split()) k = int(input()) cnt = 0 while True: cnt += 1 if cnt > k: print(""No"") break b_val = b * (2 ** cnt) c_val = c * (2 ** (k - cnt)) if a < b_val < c_val: print(""Yes"") break " p02601,s420646161,Wrong Answer,"li = list(map(int, input().split())) k = int(input()) for i in range(k): if li[0] > li[1]: li[1]=li[1]*2 elif li[2] < li[1]: li[2]=li[2]*2 if li[0] < li[1] and li[1] < li[2]: print(""Yes"") quit() print(""No"")" p02601,s233512021,Wrong Answer,"A,B,C = map(int,input().split()) K = int(input()) x = 0 if A > B: x += len(str(bin(A//B)))-2 B *= 2**x if B > C: x += len(str(bin(B//C)))-2 #print(x) if x <= K: print('Yes') if x > K: print('No')" p02601,s598110503,Wrong Answer,"import sys a,b,c = map(int,input().split()) k = int(input()) cnt = 0 for _ in range(k): if a >= b: b *= 2 cnt += 1 if a < b: continue if k-cnt == 0: sys.exit() for _ in range(k-cnt): if b >= c: c *= 2 if a < b < c: print('Yes') else: print('No')" p02601,s453952101,Wrong Answer,"import math A,B,C=(int(x) for x in input().split()) k=int(input()) e=math.ceil(A/B) f=math.ceil(B/C) y=math.ceil(A/C) if y>=f: z=y else: z=f g=0 if e>= 3: g+=2 elif e>=2: g+=1 if z<= 4: g+=2 elif z<=2: g+=1 if A==B==C: g+=3 elif A==B: g+=1 elif A==C: g+=1 elif B==C: g+=1 if g<=k: print('Yes') else: print('No') " p02601,s679183976,Wrong Answer,"a, b, c = map(int, input().split()) k = int(input()) i = 0 if k > 1: for t in range(1, k): if a 0: print('Yes') elif i == 0: print('No')" p02601,s319425940,Wrong Answer,"def main(): a, b, c = list(map(int, input().split())) k = int(input()) if b == 1 or c == 1: print('No') return count = 0 while count < k: if b < a: b *= 2 count += 1 elif c < b: c *= 2 count += 1 if a < b and b < c: print('Yes') else: print('No') main()" p02601,s610675416,Wrong Answer,"R,G,B=map(int,input().split()) K=int(input()) #print(R,G,B,K) for i in range(K): if(B B and B > A: print(""Yes"") else: print(""No"")" p02601,s961054221,Wrong Answer,"A,B,C = map(int,input().split()) K = int(input()) import math x = math.ceil(math.log2(A/B)) if x < 0: x = 0 y = math.ceil(math.log2((B*(2**x))/C)) if y < 0: y = 0 if 2*x + y <= K: print(""Yes"") else: print(""No"") " p02601,s081194151,Wrong Answer,"R,G,B=map(int,input().split()) K = int(input()) i = 1 while i <= K: if R>G: G = G*2 i+=1 if G>B: B = B*2 i+=1 if R=B: B *= 2 else: num = i for j in range(K-num): C *= 2 if AB: B=2*B elif B>C: C=2*C if A 0 and b >= c: c*=2 k-=1 while k > 0 and a>=b: b*=2 k-=1 print(""Yes"" if c>b>a else ""No"")" p02601,s810895805,Wrong Answer,"a,b,c = map(int,input().split()) K = int(input()) j = K for i in range(K): if b-a>0: break b *=2 if b-a>0: j = K-(i+1) break if b-a<=0: print('No') exit() if j==0: if c-b >0: print('Yes') exit() if c*2*j-b >0: print('Yes') else: print('No')" p02601,s593663053,Wrong Answer,"import math A,B,C=(int(x) for x in input().split()) k=int(input()) e=math.ceil(A/B) f=math.ceil(B/C) y=math.ceil(A/C) if y>=f: z=y else: z=f g=0 if e<= 3: g+=2 elif e<=2: g+=1 if z<= 4: g+=2 elif z<=2: g+=1 if g<=k: print('Yes') else: print('No') " p02601,s604003145,Wrong Answer,"import sys import math from collections import deque a,b,c=map(int,input().split()) k=int(input()) i=0 while b<=a: b*=2 i+=1 if i>k: print('No') sys.exit() while c<=b: c*=2 i==1 if i>k: print('No') sys.exit() if i<=k: print('Yes') " p02601,s093350155,Wrong Answer,"X = list(map(int,input().split())) A = X[0] B = X[1] C = X[2] K = int(input()) cnt = 0 if A > B: for i in range(K): B = B*2 cnt = cnt + 1 if A < B: break if B > C: for j in range(K): C = C*2 cnt = cnt + 1 if B < C: break if cnt <= K: print('YES') else: print('NO') " p02601,s755272119,Wrong Answer,"a, b, c = map(int, input().split())#赤midoriao k = int(input()) #赤<緑<青 if a < b and b 0: if a >= b: b = b*2 k-=1 if b >= c and k>0: c = c*2 k -=1 if a < b and b < c: print(""Yes"") else: print(""No"") " p02601,s275853617,Wrong Answer,"a,b,c=map(int,input().split()) k = int(input()) flag = False for i in range(k+1): if a<(b**i)**2<(c**(k-i))**2: flag = True if flag == True: print('Yes') else: print('No')" p02601,s382086733,Wrong Answer,"a,b,c = map(int,input().split()) k = int(input()) ans = ""No"" for i in range(k): if a>=b: b*=2 elif c>=b: c*=2 if b>a and c>b: ans = ""Yes"" print(ans)" p02601,s696955556,Wrong Answer,"A,B,C=map(int,input().split()) K=int(input()) for a in range(K): if A>B: B*=2 elif B>C: C*=2 if A b: b = b*2 elif b > c: c = c*2 print(a,b,c) if a < b and b < c: print(""Yes"") else: print(""No"")" p02601,s632542830,Wrong Answer,"abc=list(map(int,input().split())) a,b,c=abc[0],abc[1],abc[2] k=int(input()) for i in range(k): if a < b < c: print(""Yes"") break elif b < a < c: b *= 2 else: c *= 2 else: print(""No"")" p02601,s179098957,Wrong Answer,"b , g , r = map(int,input().split()) c = int(input()) flag = 'No' for i in range(c): if r < g or r < b: r = r *2 elif g < b: g = g *2 if r > g > b: flag = 'YES' break print(flag)" p02601,s475029387,Wrong Answer,"R,G,B = map(int,input().split()) K = int(input()) for i in range(K): if G < R: G *= 2 elif B < G: B *= 2 # print('Green: ' + str(G) + ' blue:' + str(B)) if R < G and G < B: print('Yes') else: print('No')" p02601,s624265680,Wrong Answer,"# B - Magic 2 def magic(a, b, c, k): i = 0 while i < k: if a > b: b = b * 2 elif b > c: c = c * 2 i += 1 if a < b and b < c: return ""Yes"" else: return ""No"" if __name__ == ""__main__"": param_a, param_b, param_c = input().split(' ') param_k = int(input()) print(magic(int(param_a), int(param_b), int(param_c), int(param_k))) " p02601,s239663226,Wrong Answer,"a, b, c = map(int, input().split()) k = int(input()) for i in range(k-1): if b < a: b = b * 2 elif c < b: c = c * 2 else: pass if (a < b) & (b < c): print('Yes') else: print('No')" p02601,s038908310,Wrong Answer,"card=input().split() k=int(input()) arr=[] for i in range(len(card)): res=int(card[i])*2 arr.append(res) if arr[0]=A_list[1]): A_list[1] = A_list[1]*2 elif(A_list[1]>=A_list[2]): A_list[2] = A_list[2]*2 else: exit() #print(A_list) sort_ = sorted(A_list) set_ = list(set(A_list)) if(A_list != set_): print(""No"") elif(A_list == sort_): print(""Yes"") else: print(""No"")" p02629,s256950701,Accepted,"n=int(input()) res="""" while n!=0: mod=n%26 n=n//26 if mod==0: mod=26 n-=1 res+=chr(97+mod-1) print(res[::-1])" p02629,s123171257,Accepted,"import math n = int(input()) d = math.floor(math.log(1+(26-1)*n, 26)) position = int(n - (26**d - 1) / (26 - 1)) txt = list('a' * d) for i in range(d): txt[d - i - 1] = chr(ord(txt[d - i - 1])+(position % 26)) position = position // 26 print(''.join(txt))" p02629,s105922647,Accepted,"#!/usr/bin/env pypy import sys import string def get_int(): return int(sys.stdin.readline().strip()) def get_ints(): return map(int, sys.stdin.readline().strip().split()) def get_list(): return list(map(int, sys.stdin.readline().strip().split())) def get_string(): return sys.stdin.readline().strip() def out(data): return sys.stdout.write(str(data)) def out_list(arr): return sys.stdout.write(' '.join(str(e) for e in arr)) MAX = 10**9 MOD = 10**9 + 7 n = get_int() alp = "" ""+string.ascii_lowercase ans = '' while n: ans = alp[(n-1)%26+1] + ans n = (n-1) // 26 print(ans) " p02629,s814855585,Accepted,"n = int(input()) def Base_10_to_n(X, n): if (int(X/n)): return Base_10_to_n(int(X/n) - 1, n) + chr(97 + X % n) return chr(97 + X % n) print(Base_10_to_n(n - 1, 26))" p02629,s581638387,Accepted,"n = int(input()) n -= 1 a = 0 dig = 1 while a + 26**dig <= n: a += 26**dig dig += 1 n -= a ans = [] for i in range(dig): ans += [chr(n % 26 + 97)] n //= 26 print(''.join(reversed(ans)))" p02629,s661500541,Accepted,"alpha = [""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()) ans = [] a = 0 for num in range(1, 12): a += 26 ** num if n <= a: n -= (a - 26 ** num) break for i in range(num, 0, -1): for j in range(26): if n <= 26 ** (i-1) * (j+1): n -= 26 ** (i-1) * j ans.append(alpha[j]) break print("""".join(ans))" p02629,s663833111,Accepted,"from string import ascii_lowercase from itertools import accumulate def solve(string): n = int(string) t = [0] + [len(ascii_lowercase)**i for i in range(1, 12)] *t, = accumulate(t) l = 0 ans = """" while t[l] < n: l += 1 n -= t[l - 1] + 1 for i in range(l - 1): j, n = divmod(n, len(ascii_lowercase)**(l - i - 1)) ans += ascii_lowercase[j] ans += ascii_lowercase[n] return ans if __name__ == '__main__': import sys print(solve(sys.stdin.read().strip())) " p02629,s970638851,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])" p02629,s455663907,Accepted,"n = int(input()) s = 'abcdefghijklmnopqrstuvwxyz' ans = '' while n > 0: n, i = divmod(n - 1, 26) ans = s[i] + ans print(ans)" p02629,s536735593,Accepted,"N = int(input()) out = [] def Saiki(N): w = N // 26 z = N % 26 ca = 1 if(z == 0): w -= 1 z = 26 ca += z - 1 out.insert(0, chr(ca + 96)) if(w == 0): return Saiki(w) Saiki(N) print(''.join(out))" p02629,s705066145,Accepted,"digits = ""abcdefghijklmnopqrstuvwxyz"" n = int(input()) ans = [] while n: n -= 1 m = n%26 n = n//26 ans.append(digits[m]) print("""".join(ans)[::-1])" p02629,s769282566,Accepted,"import re def main(): n = int(input()) ans = [] while n // 26 > 0: ans.append(chr(97 + (n-1)%26)) n = (n - 1) // 26 if n > 0: ans.append(chr(97 + (n-1)%26)) ans.reverse() print("""".join(ans)) return if __name__ == ""__main__"": main()" p02629,s460648572,Accepted,"n=int(input()) def nums(num): if num<=26: return chr(64+num) elif num%26==0: return nums(num//26-1)+chr(90) else: return nums(num//26)+chr(64+num%26) print(nums(n).lower())" p02629,s847737622,Accepted,"import math p=int(input()) ll=[""a"",""b"",""c"",""d"",""e"",""f"",""g"",""h"",""i"",""j"",""k"",""l"",""m"",""n"",""o"",""p"",""q"",""r"",""s"",""t"",""u"",""v"",""w"",""x"",""y"",""z""] a=0 n=0 prevn=0 while n<1000000000000001: a+=1 prevn=n n+=26**a if n>=p: break p2=p-prevn-1 al="""" for i in range(a): s1=math.floor(p2/(26**(a-i-1))) al=al+ll[s1] p2=p2%26**(a-i-1) print(al)" p02629,s016593237,Accepted," import sys import math import string ALPHABET = string.ascii_lowercase result = [] def alphabet_decimal(v): quotient = math.floor(v / len(ALPHABET)) surplus = v % len(ALPHABET) quotient -= 1 if surplus == 0 else 0 surplus = len(ALPHABET) if surplus == 0 else surplus result.append(surplus) if len(ALPHABET) < quotient: alphabet_decimal(quotient) elif len(ALPHABET) < v: result.append(quotient) return """".join([ALPHABET[i - 1] for i in reversed(result)]) print(alphabet_decimal(int(input())))" p02629,s373176619,Accepted,"al = [""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()) M = N v = 1 while True: if(M<=26**v): break M -= 26**v v += 1 for i in range(v): N -= 26**i ans = [] for i in range(v): ans.append(""a"") for i in range(v): ans[-i-1]=al[N%26] N = N//26 ans.reverse() anss = """" for i in range(len(ans)): anss += ans[-i-1] print(anss) " p02629,s747126247,Accepted,"N = int(input()) alp = ""abcdefghijklmnopqrstuvwxyz"" answer = """" while N != 0: N -= 1 index = N % 26 answer += alp[index] N = N // 26 print(answer[::-1]) " p02629,s488918302,Accepted,"N = int(input()) p = N s = [] abt = ""abcdefghijklmnopqrstuvwxyz"" ans = """" while p > 0: p -= 1 s.append(p % 26) p //= 26 for i in s[::-1]: ans += abt[i] print(ans) " p02629,s843195338,Accepted,"N = int(input()) ans = """" while N > 0: N -= 1 ans += chr(97 + N%26) N = N // 26 print(ans[::-1])" p02629,s380678729,Accepted,"from collections import deque def main(): N = int(input()) l = deque() mozi = list(""abcdefghijklmnopqrstuvwxyz"") a, b = divmod(N, 26) N -= 1 while True: a, b = divmod(N, 26) l.appendleft(mozi[b]) N = a N -= 1 if a == 0: break print("""".join(l)) main()" 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())" p02629,s963919101,Accepted,"n = int(input()) ans = '' while n: ans = chr((n-1)%26+ord('a')) + ans if n % 26 == 0: n = n//26-1 else: n = n//26 print(ans)" p02629,s036254873,Accepted,"n = int(input()) s = 'abcdefghijklmnopqrstuvwxyz' ans = '' while n > 0: n -= 1 # print(n//26,n%26) ans = s[n%26] + ans n = n // 26 print(ans)" p02629,s071420929,Accepted,"n = int(input()) - 1 def f(n): p = 0 ans=[] while True: if n >= 26**(p+1): n -=26**(p+1) p+=1 else: for i in range(p+1): ans.append( chr( ord('a') + n%26 ) ) n //= 26 break print(''.join(reversed(ans))) f(n) " p02629,s137614010,Accepted,"N = int(input()) def dog(n, b): arr = [""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 (int(n/b)): return dog(int(n/b)-1, b) + str(arr[n%b]) return str(arr[n%b]) print(dog(N-1,26))" p02629,s851468217,Accepted,"def f(x): x -= 1 if (int(x / 26)): return f(int(x/26)) + chr((x % 26) + 97) return chr((x % 26) + 97) n = int(input()) print(f(n)) " p02629,s212959997,Accepted,"def C(): n = int(input()) ret = [None]*12 q = n for i in range(12): q,mod = divmod(q,26) if mod == 0: ret[i] = ""z"" q -= 1 else: ret[i] = chr(mod+96) if q == 0: break ret = ret[:i+1] ret.reverse() print("""".join(ret)) C()" p02629,s153602124,Accepted,"N = int(input()) ans="""" while N>0: N -= 1 ans += chr(ord('a') + N % 26) N //= 26 print(ans[::-1]) " p02629,s513991432,Accepted,"no = ""abcdefghijklmnopqrstuvwxyz"" def main(): N = int(input()) ans = """" while N > 0: N -= 1 ans += no[N % 26] N //= 26 return ans[::-1] if __name__ == '__main__': print(main())" p02629,s064671739,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) print(num2alpha(int(input())).lower())" p02629,s812980603,Accepted,"def n2a(num): if num <= 26: return chr(ord(""a"")+num-1) elif num % 26 == 0: return n2a(num//26 - 1) + chr(ord(""z"")) else: return n2a(num//26) + chr(ord(""a"")-1 + num%26) N = int(input()) print(n2a(N))" p02629,s459221955,Accepted,"N = int(input()) ans = [] while True: if N%26 == 0: ans.append('z') else: ans.append(chr(N%26+96)) N = (N-1)//26 if N == 0: break ans.reverse() print(''.join(ans)) " p02629,s288459424,Accepted,"num=int(input()) 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) ans=num2alpha(num).lower() print(ans)" p02629,s185135447,Accepted,"# -*- coding: utf-8 -*- n=int(input()) namelist=[] name='' while n>0: n-=1 namelist.append(chr(ord('a')+n%26)) n=int(n/26) for i in namelist[::-1]: name+=i print(name)" p02629,s553047379,Accepted,"N = int(input()) N -= 1 S = chr(N % 26 + 97) N //= 26 while N > 0: N -= 1 S += chr(N % 26 + 97) N //= 26 print(S[::-1])" p02629,s297935287,Accepted,"import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N = int(read()) def main(N): A = [1] for _ in range(100): A.append(A[-1] * 26) for n in range(1, 100): if N > A[n]: N -= A[n] continue N -= 1 ret = [] for _ in range(n): N, r = divmod(N, 26) ret.append(r) break ret = [chr(ord('a') + x) for x in ret] return ''.join(reversed(ret)) print(main(N)) " p02629,s865654421,Accepted,"import copy N = int(input()) keta = 1 n = copy.deepcopy(N) flag = True while flag: if n-1 >= 26**keta: n -= 26**keta keta += 1 else: flag = False for i in range(1, keta): N -= 26**i alph = 'abcdefghijklmnopqrstuvwxyz' ans = [] ans.append(alph[(N%26)-1]) for i in range(1, keta): num = (N-1)//(26**i) if num ==0: ans.append(""a"") else: ans.append(alph[(num%26)]) ans.reverse() print("""".join(ans))" p02629,s382407676,Accepted,"# -*- coding: utf-8 -*- def conv(a): #convert the num to character a += 97 return chr(a) # 整数の入力 n = int(input()) name = '' while n>0: n -= 1 name += conv(n%26) n //= 26 # 出力 print(name[::-1])" p02629,s459240686,Accepted,"def main(): from string import ascii_lowercase N = int(input()) ans = [] while N > 0: N -= 1 N, i = divmod(N, 26) ans.append(ascii_lowercase[i]) ans = ''.join(reversed(ans)) print(ans) if __name__ == '__main__': main() " p02629,s893661435,Accepted,"def main(): num = int(input()) l = list('abcdefghijklmnopqrstuvwxyz') name = [] ans = '' while num > 0: num = num - 1 name.append(l[num%26]) num = num // 26 name.reverse() for i in name: ans = ans + i print(ans) main()" p02629,s311753465,Accepted,"n = int(input()) s = [] while n!=0: if n<=26: s.append(n) n = 0 else: x = n % 26 #余りが0の場合には26にする if not x: x = 26 s.append(x) n = (n - 1) // 26 t = [] #求めた順番とは逆に並べる for i in range(len(s)-1,-1,-1): t.append(chr(s[i]+96)) print(''.join(t)) " p02629,s682844914,Accepted,"N = int(input()) ans = '' while N > 0: N -= 1 ans += chr(ord('a') + N % 26) N //= 26 print(ans[::-1])" p02629,s095324182,Accepted,"n = int(input()) n -= 1 a = [] while True: a.append(n % 26) n //= 26 if not n: break n -= 1 name = ''.join([chr(ord('a') + c) for c in a]) print(name[::-1]) " p02629,s516386469,Accepted,"N=int(input()) ans="""" while N>0: tmp=(N-1)%26 ans=chr(int(tmp)+97)+ans N=int((N-tmp)/26) print(ans)" p02629,s371317620,Accepted,"n = int(input()) number = """" while n != 0: n = n - 1 number += (chr(n % 26 + 97)) n = n // 26 number = number[::-1] print(number)" p02629,s990231560,Accepted,"import sys import math import itertools import collections import heapq import re import numpy as np rr = lambda: sys.stdin.readline().rstrip() rs = lambda: sys.stdin.buffer.readline().split() ri = lambda: int(sys.stdin.readline()) rm = lambda: map(int, sys.stdin.buffer.readline().split()) rl = lambda: list(map(int, sys.stdin.readline().split())) inf = float('inf') mod = 10**9 + 7 n = ri() - 1 li = [] while n >= 26: a = n%26 li.append(a) n //= 26 n -= 1 li.append(n) li.reverse() ans = '' for i in li: s = 'abcdefghijklmnopqrstuvwxyz'[i] ans += s print(ans) " p02629,s427968778,Accepted,"N = int(input()) L = list(""abcdefghijklmnopqrstuvwxyz"") a = 1 while N > 26**a: N = N - 26**a a += 1 pre = [] for i in reversed(range(1,a)): r = (N-1) // 26**i pre.append(r) N = int(N%(26**i)) ans = '' for i in pre: ans += L[i] print(ans+L[N-1])" p02629,s202062518,Accepted,"n = int(input()) s = 'abcdefghijklmnopqrstuvwxyz' ans = '' while n > 0: n -= 1 q, r = divmod(n, 26) ans += s[r] n = q print(ans[::-1])" p02629,s085288794,Accepted,"N = int(input().strip()) ans = '' while N > 0: ans = chr(ord('a') + (N-1) % 26) + ans N = (N -1) // 26 print(ans) " p02629,s978824478,Accepted,"N = int(input()) a = N%26 next = int(N/26) b = N%26 next = int(N/26) a=[] answer=[] for i in range(20): if (N > 26) and (N%26)!=0: a.append(N%26) N = int(N/26) elif (N > 26) and (N%26)==0: a.append(26) N = int((N-1)/26) else: a.append(N) break for i in range(len(a)): answer.append(chr(ord('a')+a[i]-1)) mojiretu = ' ' for x in reversed(answer): mojiretu += x print(mojiretu)" 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)) " p02629,s402993033,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()) l = [chr(v) for v in range(ord(""a""), ord(""z"")+1)] ans = [] while n>0: n -= 1 i,j = n//26, n%26 ans.append(l[j]) n = i # ans.append(l[n]) print("""".join(ans[::-1]))" p02629,s784760589,Accepted,"def num2alpha(num): if num<=26: return chr(64+num) elif num%26==0: return num2alpha(num//26-1)+chr(90) else: return num2alpha(num//26)+chr(64+num%26) N = int(input()) ans = (num2alpha(N)).lower() print(ans)" p02629,s725002428,Accepted,"N = int(input()) ans = '' while N > 0: N -= 1 ans += chr(ord('a') + N % 26) N //= 26 print(ans[::-1])" 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))" p02629,s106447078,Accepted,"n = int(input()) ans = '' while n > 0: n -= 1 ans += chr(ord('a') + n % 26) n //= 26 print(ans[::-1]) " p02629,s779924950,Accepted,"n=int(input()) name="""" for i in range(15): n=n-1 name=name+chr(97+n%26) n=n//26 if n==0: break print(name[::-1])" p02629,s021556562,Accepted,"import sys sys.setrecursionlimit(10 ** 9) asc2en = lambda x: chr(x + 97) N = int(input()) def rec(N): if (N - 1) // 26: return rec((N - 1) // 26) + asc2en((N - 1) % 26) return asc2en((N - 1) % 26) print(rec(N)) " 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, ''))" p02629,s697271930,Accepted,"N=int(input())-1 L=[] S=[] A=[chr(i) for i in range(97,123)] X="""" while N>=0: if N==0: L.append(N%26) N=N//26 break elif N!=0: L.append(N%26) N=N//26-1 S=list(reversed(L)) for i in range(len(S)): X+=A[S[i]] print(str(X)) " p02629,s396449738,Accepted,"n=int(input()) out="""" n=n-1 while n>=0 : out+=chr(ord(""a"")+n%26) n=n//26-1 print(out[::-1])" p02629,s357885927,Accepted,"n = int(input()) def numalpha(num): if num <= 26: return chr(64+ num) elif num % 26 == 0: return numalpha(num // 26-1) + chr(90) else: return numalpha(num//26) + chr(64 + num % 26) print(numalpha(n).lower()) " p02629,s475180140,Accepted,"from collections import deque N = int(input()) amari = [] if N <= 26: print(chr(96+N)) else: while True: N -= 1 am = N % 26 N = N // 26 amari.append(am) if N == 0: break answer = deque() for i in amari: answer.appendleft(chr(97+i)) for i in answer: print(i, end='')" p02629,s077837165,Accepted,"N=int(input()) def num2alpha(num): if num<=26: return chr(96+num) elif num%26==0: return num2alpha(num//26-1)+'z' else: return num2alpha(num//26)+chr(96+num%26) print(num2alpha(N)) " p02629,s695627917,Accepted,"n = int(input()) tmp = n ans = """" i = 1 while n > 0: n -= 1 r = n % 26 ans += chr(ord(""a"") + r) n = n // 26 print(ans[::-1])" p02629,s347988612,Accepted,"N = int(input()) string = """" while N > 0: N, remainder = divmod(N - 1, 26) string = chr(97 + remainder) + string print(string)" p02629,s847934014,Accepted,"n=int(input()) ans='' check='abcdefghijklmnopqrstuvwxyz' #c(a)-1=0,c(b)-1=1,…,c(z)-1=25を対応づける文字列 while n!=0: n-=1 ans+=check[n%26] #(n-1)%26がc(Sk)-1を表すので、上記の文字列を用いてc(Sk)-1からSkを求める n//=26 print(ans[::-1])" p02629,s314779686,Accepted,"from sys import stdin N = int(stdin.readline().rstrip()) ans = '' while N > 0: N -= 1 ans += chr(ord('a')+N%26) N //= 26 print(ans[::-1])" p02629,s776750385,Accepted,"import sys def input(): return sys.stdin.readline().rstrip() def main(): n = int(input()) ans = """" while n > 0: n -= 1 ans = chr(n%26 + ord('a')) + ans n //= 26 print(ans) if __name__=='__main__': main()" p02629,s118882335,Accepted,"n = int(input()) h = [] tmp = [""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""] name = """" while n != 0: mod = n % 26 h.append(mod) n //= 26 if mod == 0: n -= 1 h.reverse() for i in h: name += tmp[i - 1] print(name) " p02629,s860525750,Accepted,"n=int(input()) i=0 pl=list() while True: i=i+1 if (26*(1-26**(i-1)))/(1-26)+1<=n and n<=(26*(1-26**(i-1)))/(1-26)+26**i: break a=n-(26*(1-26**(i-1)))/(1-26)-1 for l in range (i): a,b=divmod(a,26) pl.insert(0,(chr(int(b)+97))) print("""".join(pl))" 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])" p02629,s305568305,Accepted,"n=int(input()) ans='' while n>0: x=n%26 if x!=0: ans+=chr(x+96) else: ans+='z' n-=1 n=n//26 print(ans[::-1])" p02629,s728903108,Accepted,"def f(n): if n == 0: return """" n -= 1 return (f(n // 26) + chr(ord(""a"") + n % 26)) def main(): from builtins import int, map, list, print import sys sys.setrecursionlimit(10 ** 6) input = (lambda: (sys.stdin.readline()).rstrip()) input_list = (lambda: input().split()) input_number = (lambda: int(input())) input_number_list = (lambda: list(map(int, input_list()))) n = input_number() ans = f(n) print(ans) if __name__ == '__main__': main() " p02629,s400813889,Accepted,"N = int(input())-1 l = len(str(N)) ans = '' if N == 0: print('a') exit(0) cnt = 0 while N >= 26: d = N % 26 ans = chr(ord('a') + d) + ans N //= 26 N -= 1 ans = chr(ord('a') + N) + ans print(ans) " p02629,s574470169,Accepted,"def main(): name = ['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()) y = N ans = [] for i in range(100): y -= 1 x = y%26 y = y//26 ans.insert(0,name[x]) if y == 0: break print(''.join(ans)) if __name__ == '__main__': main()" p02629,s688126812,Accepted,"n = int(input()) ans = '' al = 'abcdefghijklmnopqrstuvwxyz' while n>0: n -= 1 ans += al[n%26] n //= 26 print(ans[::-1])" p02629,s965733752,Accepted,"n = int(input()) al=[""z""]+[chr(ord('a') + i) for i in range(25)] result = """" while n>0: if n%26 !=0: result = al[n%26]+result n //= 26 else: result = al[n%26]+result n //= 26 n -= 1 print(result)" p02629,s174149644,Accepted,"alfa=['z','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'] n = int(input()) ans='' while n>0: ans+=alfa[n%26] n=n-1 n=n//26 print(ans[::-1]) " p02629,s706658428,Accepted,"def main(): suu=""abcdefghijklmnopqrstuvwxyz""#26 n=int(input()) puts="""" if n<27:#その数より小さい print(suu[n-1]) return while True: temp=n%26 n//=26 puts=suu[temp-1]+puts if temp==0:#補正 n-=1 if n<27: puts=suu[n-1]+puts break print(puts) if __name__ == ""__main__"": main()" p02629,s823019398,Accepted,"n = int(input()) l = [] while(n > 0): n -= 1 l.append(chr(97+(n%26))) n = n//26 for i in l[::-1]: print(i,end="""") print("""") " p02629,s305733516,Accepted,"from string import ascii_lowercase N = int(input()) l = [] while N != 0: N -= 1 l.append(N%26) N //= 26 print("""".join(ascii_lowercase[x] for x in l[::-1]))" p02629,s488982845,Accepted,"def main(): n = int(input()) t = 1 ans = '' while n > 0: p = ((n - 1) // t) % 26 ans += chr(ord('a') + p) n -= t * (p+1) t *= 26 ans = ans[::-1] print(ans) if __name__ == '__main__': main() " p02629,s755724746,Accepted,"N = int(input()) d = ""abcdefghijklmnopqrstuvwxyz"" ans = """" N -= 1 while(N >= 0): ans += d[N % 26] N //= 26 N -= 1 print(ans[::-1])" p02629,s456548589,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) print(num2alpha(int(input())).lower())" p02629,s816469848,Accepted,"n = int(input()) c = ['z','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'] k = 1 n1 = n while n1-26**k>0: n1 = n1-26**k k+=1 ans = '' ans = c[n1%26]+ans for i in range(k-1): if n1%26!=0: n1 = n1//26+1 else: n1 = n1//26 ans = c[n1%26]+ans print(ans)" p02629,s124108392,Accepted,"n = int(input()) ans = '' l = [] while n>0: w = chr(96+n%26) if not n%26: w = 'z' n-=26 l.append(w) n = int(n//26) l.reverse() ans = ''.join(l) print(ans)" 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)" p02629,s324626901,Accepted,"a = ""zabcdefghijklmnopqrstuvwxy"" number = int(input()) result = """" for i in range(13): result += a[int(number % 26)] if number % 26 == 0: number -= 26 if number // 26 == 0: break number = number // 26 result = result[::-1] print(result)" p02629,s277496758,Accepted," n = int(input()) 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) print(num2alpha(n).lower())" p02629,s016187708,Accepted,"n = int(input()) s = """" al = ""abcdefghijklmnopqrstuvwxyz"" while n > 0: o = (n-1) % 26 n = (n-1) // 26 s += al[int(o)] print(s[::-1])" p02629,s970525842,Accepted,"import sys def main(n): c = ""abcdefghijklmnopqrstuvwxyz"" m = {} for i in range(0, 26): m[i+1] = c[i] s = """" while n > 0: if n%26 == 0: t = 26 n //= 26 n -= 1 else: t = n%26 n //= 26 s = m[t] + s return s n = int(sys.stdin.readline().strip()) print(main(n)) " p02629,s315594126,Accepted,"n = int(input()) alpha_arr = [chr(i) for i in range(97, 97+26)] ans = [] while n > 0: n -= 1 ans.insert(0, alpha_arr[n % 26]) n //= 26 print(''.join(ans))" p02629,s184276109,Accepted,"N=int(input()) N_26=[] while N>0: N-=1 N_mod=N%26 N=N//26 N_26.append(chr(97+N_mod)) print("""".join(list(reversed(N_26)))) " p02629,s197435801,Accepted,"n = int(input()) - 1 ans = [] alp = [chr(i) for i in range(97, 97+26)] while n >= 0: ans.append(alp[n % 26]) n = (n // 26) - 1 print("""".join(reversed(ans)))" p02629,s713542376,Accepted,"N = int(input()) 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) print(num2alpha(N).lower())" p02629,s558918545,Accepted,"nb=int(input()) s = [] while nb>0: nb-=1 s.append(chr(ord(""a"")+nb%26)) nb//=26 roger = """".join(s) print(roger[::-1]) " p02629,s101407661,Accepted,"n = int(input()) ans = '' while n != 0: s = n % 26 if s == 0: ans += 'z' n = n //26 - 1 else: ans += chr(s + 96) n //= 26 print(ans[::-1]) " p02629,s407138647,Accepted,"N = int(input()) ans = '' while N > 0: N -= 1 ans += chr(ord('a') + N % 26) N //= 26 print(ans[::-1]) " 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])) " p02629,s960770221,Accepted,"def num2alpha(num): if num<=26: return chr(64+num) elif num%26==0: return num2alpha(num//26-1)+chr(90) else: return num2alpha(num//26)+chr(64+num%26) n = int(input()) print(num2alpha(n).lower())" p02629,s838232387,Accepted,"n = int(input()) cha = ""abcdefghijklmnopqrstuvwxyz"" ans = [] while n >= 1: mod = (n - 1) % 26 ans.append(mod) n = (n - 1) // 26 ans_s = '' for tmp in reversed(ans): ans_s += cha[tmp] print(ans_s)" 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()" p02629,s344665351,Accepted,"def solve(N): if N < 26: return chr(ord('a') + (N) % 26) else: return solve(N // 26 - 1) + chr(ord('a') + N % 26) print(solve(int(input()) - 1)) " p02629,s420072152,Accepted,"n=int(input()) ans="""" while n>0: c=chr((n-1)%26 + 97) ans = c+ans n = (n-1)//26 print(ans) " p02629,s968348550,Accepted,"# import sys # readline = sys.stdin.readline # generator = (readline().strip() for _ in range(N)) # N, M = map(int, input().split()) # As = list(map(int, input().split())) # queries = (input() for _ in range(N)) def solve(): N = int(input()) v = N ans = '' while v > 0: d, m = divmod(v, 26) if m == 0: d -= 1 m = 26 ans = chr(m + 96) + ans v = d return ans def main(): print(solve()) if __name__ == ""__main__"": main() " p02629,s110891891,Accepted,"N=int(input()) alpha='abcdefghijklmnopqrstuvwxyz' ans='' while 26 0: N = N - 1 ans.append(chr(N % 26 + ord('a'))) N = (N - N % 26) // 26 print(''.join(ans[::-1])) " p02629,s121342348,Accepted,"N = int(input()) ans = """" digit_count = 1 check = 26 while N > check: digit_count += 1 check += 26 ** digit_count offset = check - 26 ** digit_count N -= offset + 1 while digit_count > 0: ans = """" + chr(ord(""a"") + N % 26) + ans N //= 26 digit_count -= 1 print(ans)" p02629,s645561268,Accepted,"n = int(input()) a = 26 keta = 1 nn = 0 while n > 0: if n > a: keta += 1 n -= a a *= 26 else: nn = n - 1 n -= a #nnを桁数をketaとして26進法で表す l = [] for i in range(keta): amari = nn % 26 nn = nn // 26 l.append(amari) revl = [] for i in range(len(l)-1,-1,-1): revl.append(l[i]+97) ansl = [] for i in revl: ansl.append(chr(i)) print("""".join(ansl)) " p02629,s634510793,Accepted,"n=int(input()) a=""abcdefghijklmnopqrstuvwxyz"" aa=list(a) stra="""" kk=n for i in range(15): ki=(kk-1)%26+1 if ki!=0: stra=aa[ki-1]+stra else: stra=aa[25]+stra kk=(kk-ki)//26 # print(kk,ki,stra) if kk==0: break print(stra)" p02629,s222167281,Accepted,"n = int(input()) 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) print(num2alpha(n).lower())" p02629,s149013099,Accepted,"N=int(input()) #N=1000000000000001 ans='' alp=list('abcdefghijklmnopqrstuvwxyz') while N != 0: N,mod=divmod(N-1,26) ans=alp[mod]+ans print(ans) #27 -> aa 26 + 1 " p02629,s930674886,Accepted,"n = int(input()) def num2alpha(n): if n <= 26: return chr(96+n) elif n % 26 == 0: return num2alpha(n//26-1)+chr(122) else: return num2alpha(n//26)+chr(96+n % 26) print(num2alpha(n)) " p02629,s506447199,Accepted,"N = int(input()) lis = [0,26] num = 26 n = 1 while lis[-1] 0: ans.append(N%26) N = math.floor((N-1)/26) alphabet = 'abcdefghijklmnopqrstuvwxyz' ans = reversed(ans) for i in ans: print(alphabet[i-1],end="""") " p02629,s047847289,Accepted,"# NK=list(map(int,input().split())) N = int(input()) ''' An = list(map(int,input().split())) Q = int(input()) Bn = [0] * Q Cn = [0] * Q for c in range(Q): Bn[c], Cn[c] = map(int, input().split()) ''' 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""] columnName = """" modulo =0 while N>0: modulo = (N-1)%26 columnName = alphabet[modulo]+columnName N = int((N-modulo)/26) print(columnName)" p02629,s506715324,Accepted,"n = int(input()) def solve(n): string = """" i = 0 while n > 0: rem = n % 26 if rem == 0: string += 'z' i += 1 n = (n // 26) - 1 else: string += str(chr((rem - 1) + ord('a'))) i += 1 n = n // 26 string = string[::-1] print(string) solve(n)" p02629,s754221149,Accepted,"n = int(input())-1 ans = [] while n >= 0: n, y = divmod(n, 26) ans.append(y) n -= 1 ans.reverse() def to_alpha(x): return chr(x+ord('a')) print(''.join(map(to_alpha, ans)))" 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()" p02629,s227784023,Accepted,"N = int(input()) alp_list = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] ans = [] for i in range(1,12): if N <= 26 ** i: N -= 1 for j in range(i): ans += alp_list[N % 26] N = N // 26 break else: N -= 26 ** i ans.reverse() print("""".join(ans)) " p02629,s072452159,Accepted,"n = int(input()) kouho = [chr(i) for i in range(97, 97+26)] ans = [] while n>0: n-=1 ans.append(kouho[n%26]) n = n//26 ans.reverse() print(''.join(ans))" p02629,s685589220,Accepted,"N = int(input()) ans = '' while N >0: N -=1 ans += chr(ord('a') + N%26) N //=26 print(ans[::-1])" p02629,s638242658,Accepted,"n = int(input()) num = 26 arr = [] ans = """" moji = ""abcdefghijklmnopqrstuvwxyz"" flg = False ar = [] n = n - 1 for i in range(10000): arr.append(n % num) n = n // num - 1 if n < 0: break arr.reverse() ans = """" for i in arr: ans +=moji[i] print(ans)" p02629,s541202102,Accepted,"n=int(input()) def num2(num): if num<=26: return chr(num+96) elif num%26==0: return num2(num//26-1)+chr(122) else: return num2(num//26)+chr(96+num%26) print(num2(n))" p02629,s406537896,Accepted,"# coding:utf-8 n = int(input()) name = '' count = 0 while n > 0: n -= 1 mod = n % 26 name += chr(97 + mod) n = n // 26 print(name[::-1]) " p02629,s415283503,Accepted,"import string N = int(input()) - 1 ss = string.ascii_lowercase ans = """" while N >= 0: ans += ss[N % 26] N = N // 26 - 1 if N < 0: break print(ans[::-1]) " p02629,s043703976,Accepted,"n = int(input()) 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) print(num2alpha(n).lower())" p02629,s301826131,Accepted,"N = int(input()) ans = """" while(N > 0): N -= 1 ch = N % 26 ans = chr(97 + ch) + ans N //= 26 print(ans) " p02629,s224341096,Accepted,"n = int(input()) alp = ""abcdefghijklmnopqrstuvwxyz"" def solve(n): if n<26: return [alp[n]] ans=[alp[(n%26)]] ans.extend(solve((n//26)-1)) return ans ans=solve(n-1) ans.reverse() print(*ans,sep="""")" p02629,s390260511,Accepted,"N = int(input()) 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) kou=N a= num2alpha(kou) print(a.lower())" p02629,s863845777,Accepted,"from collections import defaultdict as dd from collections import deque import bisect import heapq def ri(): return int(input()) def rl(): return list(map(int, input().split())) def solve(): n = ri() n -= 1 out = """" while n >= 0: n, r = divmod(n, 26) n -= 1 out = chr(ord('a') + r) + out print (out) mode = 's' if mode == 'T': t = ri() for i in range(t): solve() else: solve() " p02629,s436747329,Accepted,"N = int(input()) import math num2alpha = lambda c: chr(c) tmp_N = N result = '' while (tmp_N / 26) > 1.0: k = int(tmp_N / 26) res = tmp_N % 26 if res == 0: res = 26 k -= 1 result += num2alpha(res+64).lower() tmp_N = k res = tmp_N % 26 if res == 0: res = 26 k -= 1 result += num2alpha(res+64).lower() new_str = ''.join(list(reversed(result))) print(new_str)" p02629,s102140490,Accepted,"n=int(input()) alphabet = [chr(i) for i in range(97, 97+26)] ans=[] while n>0: n-=1 ans.append(alphabet[n%26]) n//=26 ans.reverse() print(''.join(ans))" p02629,s364196881,Accepted,"alp=[chr(i) for i in range(97,123)] n=int(input()) for i in range(1,12): if n>26**i: n-=26**i else: keta=i break #その桁数の名前のなかでn番目 n-=1 lst=[] #このnを26進数で表し、0~25にa~zをあてはめる for i in range(keta): p,n=divmod(n,26**(keta-i-1)) lst.append(alp[p]) print("""".join(lst))" p02629,s396834265,Accepted,"n=int(input()) s = '' for i in range(11): if n != 0: n -= 1 s += chr(ord('a') + n % 26) n //= 26 print(s[::-1])" p02629,s944812693,Accepted,"def num2alpha(num): if num<=26: return chr(64+num) elif num%26==0: return num2alpha(num//26-1)+chr(90) else: return num2alpha(num//26)+chr(64+num%26) n = int(input()) ans = num2alpha(n).lower() print(ans)" p02629,s718077532,Accepted,"n = int(input()) x = 0 l = 0 while x < n: l += 1 x += 26**l for i in range(1,l): n -= 26**i n -= 1 ans = """" while len(ans) < l: ans += chr(ord(""a"")+n%26) n //= 26 print(ans[::-1])" p02629,s856020418,Accepted,"n=int(input())-1 m=n;i=0;lst=[] while m>=0: i+=1;k=m;m-=26**i k while k>0: lst.append(k%26) k//=26 for j in range(i-len(lst)): lst.append(0) print(''.join([chr(b+97) for b in lst][::-1]))" p02629,s852378901,Accepted,"N = int(input()) ans = ' ' while N>0: N -= 1 ans += chr(ord('a')+N%26) N = int(N/26) print(ans[::-1])" p02629,s753327994,Accepted,"N = int(input()) 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) print(num2alpha(N).lower())" p02629,s318299542,Accepted,"n=int(input()) ans = '' while n: tmp = (n-1)%26 ans += chr(ord('a')+tmp) n-=1 n//=26 print(ans[::-1])" p02629,s331411019,Accepted,"entierAConvertir = int(input()) baseArrivee= 26 sortie = [] while entierAConvertir>0: reste = entierAConvertir % baseArrivee if reste==0: reste = 26 sortie.append(reste) entierAConvertir-=reste entierAConvertir = (entierAConvertir//baseArrivee) for i in range(len(sortie)): print(chr(sortie[len(sortie)-1-i]+ord('a')-1),end="""")" p02629,s878237478,Accepted,"n = int(input()) alpha = 'abcdefghijklmnopqrstuvwxyz' out = '' while n != 0: out = alpha[(n % 26) - 1] + out n = int((n-1) // 26) print(out)" p02629,s596813216,Accepted,"def num2alpha(num): if num<=26: return chr(64+num) elif num%26==0: return num2alpha(num//26-1)+chr(90) else: return num2alpha(num//26)+chr(64+num%26) n = int(input()) print(num2alpha(n).lower())" p02629,s072452953,Accepted,"n = int(input()) s = ""abcdefghijklmnopqrstuvwxyz"" ans = """" while True: a = n % 26 if a == 0: n = n//26 - 1 else: n //= 26 ans = s[a-1] + ans if n == 0: break print(ans)" p02629,s430049539,Accepted,"import string a2z = string.ascii_lowercase def routine(X, n): div = X//n if X % n > 0 else X//n - 1 if div: return routine(div, n)+a2z[X%n-1] return a2z[X%n-1] print(routine(int(input()), 26)) " 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)" p02629,s751478322,Accepted,"n = int(input()) ans="""" while(n): n-=1 ans += chr(ord('a')+(n%26)) n = n//26 print(ans[::-1]) " p02629,s204280288,Accepted,"N = int(input()) chars = ""Xabcdefghijklmnopqrstuvwxyz"" result = """" n_1 = N while True: x = n_1 % 26 if x == 0: x = 26 result += chars[x] n_1 -= x if n_1 == 0: break n_1 //= 26 print(result[::-1]) " p02629,s567783242,Accepted," n = int(input()) alphabet = [chr(i) for i in range(ord('a'), ord('z')+1)] ans = '' while n > 0: n -= 1 ans += alphabet[n%26] n = n//26 print(ans[::-1]) " p02629,s200812441,Accepted,"n = int(input()) name = '' while n>0: n -= 1 name += chr(ord('a') + n%26) n//=26 print(name[::-1])" p02629,s348186874,Accepted,"def main(): n = int(input()) n -= 1 s = [] for _ in range(15): # print(n) s.append(chr(ord('a')+(n%26))) n = int(n / 26) if n==0: break n -= 1 s.reverse() print(''.join(s)) pass main()" p02629,s999424008,Accepted,"import sys import math def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def MI(): return map(int, sys.stdin.readline().split()) def SI(): return sys.stdin.readline().strip() n = II() ans = """" while(n>0): ans+=chr(96+n%26) if n%26>0 else 'z' if n%26 == 0: n//=26 n-=1 else: n//=26 print(ans[:][::-1]) " p02629,s624435818,Accepted,"n = int(input()) ans = '' while n > 0: n -= 1 ans += chr(ord('a') + n % 26) n //= 26 print(ans[::-1]) " p02629,s540629906,Accepted,"n = int(input()) a = ""abcdefghijklmnopqrstuvwxyz"" s = """" while n > 0: if n%26 == 0: s = a[n%26-1] + s n //= 26 n -= 1 else: s = a[n%26-1] + s n //= 26 print(s)" p02629,s917220897,Accepted,"_dog_no = int(input()) _letter = [chr(i) for i in range(97,97+26)] _dog_name = """" for _i in range(11): _dog_no -= 1 _dog_name = _letter[_dog_no % 26] + _dog_name _dog_no = _dog_no // 26 if _dog_no < 1: break print(_dog_name)" p02629,s859245929,Accepted,"s = 'abcdefghijklmnopqrstuvwxyz' n = int(input()) num = 0 cnt = 1 while((num+pow(26,cnt)) < n): num += pow(26,cnt) cnt += 1 n -= num n -= 1 ans = """" while(cnt > 0): a = n // pow(26,cnt-1) n -= (pow(26,cnt-1)*a) cnt -= 1 ans = ans + s[a] print(ans)" 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]) " p02629,s521916603,Accepted,"n = int(input()) keta = 1 for i in range(1, 18): t = 26*(26**i-1)//25 if n <= t: break else: keta += 1 n -= 26*(26**(keta-1)-1)//25 n -= 1 ans = """" for i in range(keta): t = 26**i ans = chr(ord('a')+(n//t)%26)+ans print(ans)" p02629,s435089203,Accepted,"N = int(input()) 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) print(num2alpha(N).lower())" p02629,s839450360,Accepted,"N=int(input()) ans="""" for _ in range(10**5): N-=1 ans+=chr(ord(""a"")+(N%26)) N=N//26 if N<=0: break print(ans[::-1])" p02629,s821947427,Accepted,"N = int(input()) for d in range(64): if N < (26**(d+1)-1)//(26-1): N = N-(26**d-1)//(26-1) break #print(d, N) L = [] for i in range(d): n = N%26 c = ""abcdefghijklmnopqrstuvwxyz""[n] L.append(c) N = N//26 r = """".join(reversed(L)) print(r) " p02629,s194424650,Accepted,"N = int(input()) # 数値→アルファベット 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) print(num2alpha(N).lower())" p02629,s140614958,Accepted,"n=int(input()) T='abcdefghijklmnopqrstuvwxyz' s='' while n>0: sn=n%26 if sn>0: s=T[sn-1]+s n//=26 else: s=T[25]+s n=n//26-1 print(s)" p02629,s538013057,Accepted,"n = int(input()) s = ""abcdefghijklmnopqrstuvwxyz"" l = [26] for i in range(2, 14): a = 26 ** (i) + l[i-2] l.append(a) idx = 0 while True: if n <= l[idx]: break idx += 1 if idx == 0: print(s[n-1]) exit() q = n - l[idx-1] - 1 ll = [] for j in range(idx+1): q, mod = divmod(q, 26) ll.append(mod) ll.reverse() ans = """" for e in ll: ans += s[e] print(ans) " p02629,s028876632,Accepted,"n = int(input()) #a, b, h, m = map(int, input().split()) #al = list(map(int, input().split())) #al=[list(input()) for i in range(h)] l = 1 total = 26 while n > total: l += 1 total += 26**l last = total-26**l v = n-last-1 ans = '' # 26進数だと見立てて計算 for i in range(l): c = v % 26 ans += chr(ord('a')+c) v = v//26 print("""".join(ans[::-1])) " p02629,s259673131,Accepted,"s = int(input()) ans = """" while (s > 0): s -= 1 ans += chr((s % 26) + ord(""a"")) s //= 26 print(ans[::-1]) " p02629,s683135278,Accepted,"n = int(input()) - 1 ans = """" for _ in range(13): ans += chr(ord(""a"") + (n%26)) n //= 26 if n == 0: break n -= 1 print(ans[::-1])" p02629,s011756446,Accepted,"n = int(input()) ans='' while(n>0): n -= 1 ans += chr(ord('a')+n%26) n //= 26 print(ans[::-1])" p02629,s769442594,Accepted,"import math from collections import defaultdict 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() s=""abcdefghijklmnopqrstuvwxyz"" ans="""" while(n>0): n-=1 ans+=s[n%26] n//=26 print(ans[::-1]) " p02629,s478009600,Accepted,"import string str_map = {num+1: item for num, item in enumerate(string.ascii_lowercase)} def main(): n = int(input()) ans = [] while n > 26: tmp = 26 if n%26 == 0 else n%26 ans.append(str_map[tmp]) n = (n-1) // 26 ans.append(str_map[n]) ans_str = ''.join(ans) print(ans_str[::-1]) return if __name__ == ""__main__"": main()" 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()" p02629,s506231931,Accepted,"n=int(input()) ans='' check='abcdefghijklmnopqrstuvwxyz' while n!=0: n-=1 ans+=check[n%26] n//=26 print(ans[::-1])" p02629,s118340224,Accepted,"def main(): N = int(input()) orda = ord('a') ans = '' while N: N -= 1 N, Nmod = divmod(N, 26) ans = chr(orda + Nmod) + ans print(ans) if __name__ == '__main__': main() exit() " p02629,s716175426,Accepted,"N = int(input()) k = 1 while 26**k <= N: N -= 26**k k += 1 def itoc(i): return chr(ord('a') + i) N -= 1 ans = '' for _ in range(k): N,i = divmod(N,26) ans += itoc(i) if all(c=='z' for c in ans): print(ans[:-1]) else: print(ans[::-1])" p02629,s515614850,Accepted,"import sys sys.setrecursionlimit(10 ** 5 + 10) def input(): return sys.stdin.readline().strip() def resolve(): n=int(input()) ans='' while n>0: n-=1 a,b=divmod(n,26) n//=26 ans+=chr(ord('a')+b) for i in ans[::-1]: print(i,end='') print() resolve() " p02629,s509387544,Accepted,"N = int(input()) alp = ""abcdefghijklmnopqrstuvwxyz"" output = """" while N>0: N -= 1 output += alp[N%26] N = N//26 print(output[::-1])" p02629,s258704620,Accepted,"n = int(input()) alphabet = list(""abcdefghijklmnopqrstuvwxyz"") if n <= 26: print(alphabet[n-1]) else: ans = """" while(True): q, mod = divmod(n, 26) if mod == 0: q -= 1 ans = ""z"" + ans else: ans = alphabet[mod-1] + ans if q < 1: break n = q print(ans)" p02629,s801493293,Accepted,"import sys from string import ascii_lowercase 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()) ans = [] while N: N, r = divmod(N, 26) if r == 0: r = 26 N -= 1 ans.append(ascii_lowercase[r-1]) print(''.join(reversed(ans))) return if __name__ == '__main__': main() " p02629,s361676231,Accepted,"n=int(input()) a=""zabcdefghijklmnopqrstuvwxy"" b="""" while n/26>0: b=a[n%26]+b n=(n-1)//26 print(b)" p02629,s162136530,Accepted,"answer = """" num = int(input()) j = 0 while(num > 0): j = num % 26 num = num // 26 if j == 0: answer += 'z' num -= 1 else: answer += chr(96+j) print(answer[::-1])" p02629,s850887769,Accepted,"N = int(input()) alpha = [chr(i) for i in range(97, 97+26)] k=0 while N>=0: N -= 26**k k += 1 A = [] k -= 1 len_k = k while k >= 0: A.append(N//(26**k)) N %= (26**k) k -= 1 res = [] for i in A[-len_k:]: res.append(alpha[i]) print("""".join(res))" p02629,s794180030,Accepted,"n=int(input()) alphabet=""abcdefghijklmnopqrstuvwxyz"" ans=[] while n>0: n-=1 ans.append(alphabet[n%26]) n=n//26 ans.reverse() print("""".join(ans)) " p02629,s386893757,Accepted,"#!/usr/bin/env python3 ALPHABET = ""abcdefghijklmnopqrstuvwxyz"" n = int(input()) - 1 ans = """" while True: ans += ALPHABET[n % 26] n //= 26 n -= 1 if n < 0: break print(ans[::-1]) " 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))" 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" 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])" p02629,s333169505,Accepted,"def main(): N = int(input()) - 1 digit = 1 while N >= 26 ** digit: N -= 26 ** digit digit += 1 buf = [] a = ord(""a"") for i in range(digit): buf.append(chr(a + (N % 26))) N //= 26 ans = """".join(buf[::-1]) print(ans) if __name__ == ""__main__"": main() " 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)" p02629,s564027579,Accepted,"n= (int)(input()) ans = """" count = 0 if n % 26 != 0: ans += chr(n % 26 + 96) n -= n % 26 else: ans += 'z' n -= 26 for i in range(1, 11): n = n // 26 if n == 0: break if n % 26 != 0: ans = chr(n % 26 + 96) + ans n -= n % 26 else: ans = 'z' + ans n -= 26 print(ans)" p02629,s585719106,Accepted,"N = int(input()) alphabets = {i: chr(i + 96) for i in range(1, 26)} alphabets[0] = 'z' queue = [] while N > 0: queue.insert(0, alphabets[N % 26]) N -= 1 N //= 26 print(''.join(queue))" p02629,s204226650,Accepted,"N = int(input())-1 az = ""abcdefghijklmnopqrstuvwxyz"" ans = [] while N >= 0: ans.append(az[N % 26]) N //= 26 N -= 1 ans.reverse() print("""".join(ans)) " p02629,s304201666,Accepted,"# 数値→アルファベット def num2alpha(num): if num<=26: return chr(64+num) elif num%26==0: return num2alpha(num//26-1)+chr(90) else: return num2alpha(num//26)+chr(64+num%26) n=num2alpha(int(input())) n=str(n.lower()) print(n)" p02629,s358080199,Accepted,"import sys from collections import deque sys.setrecursionlimit(10 ** 6) INF = float(""inf"") MOD = 10 ** 9 + 7 def input(): return sys.stdin.readline().strip() def main(): N = int(input()) alpahbet = [chr(ord(""a"") + i) for i in range(26)] ans = [] while N: N -= 1 ans.append(alpahbet[N % 26]) N //= 26 print(*ans[::-1], sep="""") if __name__ == ""__main__"": main() " p02629,s178662691,Accepted,"import math n = int(input()) ls = ""abcdefghijklmnopqrstuvwxyz"" cnt = 0 base = 26 while n >= base ** cnt: n -= base ** cnt cnt += 1 ans = """" #print(cnt, n) for i in range(cnt-1, -1, -1): res = n // (base ** i) ans += ls[res] n -= base ** i * res print(ans)" p02629,s757013538,Accepted,"K1 = 1 K2 = 27 K3 = 703 K4 = 18279 K5 = 475255 alpha = ""abcdefghijklmnopqrstuvwxyz"" n = int(input()) a = """" def func(n,k): global a a=alpha[n%26]+a if(k>1): func(n//26,k-1) sum = 0 for i in range(1,15): sumb = sum sum += 26**i if(sum >= n): #print(n-sumb-1,i) func((n-sumb-1),i) break print(a) " p02629,s974552924,Accepted,"import string # string.ascii_lowercase N = int(input()) - 1 strs= [string.ascii_lowercase[N % 26]] while(N >= 26): N //= 26 N -= 1 strs.append(string.ascii_lowercase[N % 26]) for s in strs[::-1]: print(s, end='') print()" p02629,s297798235,Accepted,"n = int(input()) ans = """" while n != 0: n -= 1 ans += chr(97 + n%26) n = n//26 for c in reversed(ans): print(c, end="""")" p02629,s961833632,Accepted,"N = int(input()) alphabets = [chr(i) for i in range(97, 97+26)] E = [] while N>=1: N -= 1 E.append( int(N%26) ) N = N/26 print("""".join(reversed([alphabets[i] for i in E ] )) ) " p02629,s371476461,Accepted,"n = int(input()) for k in range(20): if (26**k-1)//25<=n<(26**(k+1)-1)//25: n-=26*(26**(k-1)-1)//25 break ans='' for i in range(k): ans+='abcdefghijklmnopqrstuvwxyz'[((n-1)//26**i)%26] print(ans[::-1])" p02629,s535760218,Accepted,"n=int(input()) num=26 data=[] while num<=n: if n%num==0: data.append(""z"") n=int(n/num-1) else: data.append(chr(n%26+96)) n=int(n/num) if n!=0: data.append(chr(n+96)) data="""".join(data) print(data[::-1])" p02629,s953019933,Accepted,"n=int(input()) l=list('abcdefghijklmnopqrstuvwxyz') s=[]#格納よう i=1#桁数 while n>26**i: n-=26**i i+=1 n-=1 while i!=0: p=n//26**(i-1) n=n%26**(i-1) s.append(l[p]) i-=1 print(''.join(s))" p02629,s699340388,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) a = int(input()) print(num2alpha(a).lower())" p02629,s014758801,Accepted,"from sys import stdin from decimal import Decimal def main(): input = stdin.readline N = int(input()) alphabet = ""abcdefghijklmnopqrstuvwxyz"" ans = """" flag = True while flag: if N <= 26: flag = False ans = alphabet[(N-1)%26] + ans N = (N-1) // 26 print(ans) if __name__ == ""__main__"": main()" p02629,s184014255,Accepted,"N = int(input()) ans = """" while N > 0: N -= 1 n = N % 26 ans = chr(ord(""a"") + n) + ans N //= 26 print(ans) " p02629,s248223841,Accepted,"N = int(input()) l = [] while N: N -= 1 l.append(chr(97+(N % 26))) N //= 26 print("""".join(l[::-1]))" p02629,s622293096,Accepted,"def f(l, n): ans = [] for i in range(l): ans.append(chr(n % 26 + ord('a'))) n//=26 print(''.join(reversed(ans))) n = int(input()) val = 26 adds = 0 lastval = 0 cnt = 1 while val < n: lastval = val val = (val*26)+26 cnt+=1 f(cnt, n-lastval-1)" p02629,s144430169,Accepted,"N = int(input()) S = ""_abcdefghijklmnopqrstuvwxyz"" ans = """" while N > 0: if N%26 != 0: ans += S[N%26] else: ans += ""z"" N -= 1 N = N//26 print(ans[::-1]) " p02629,s332275931,Accepted,"n=int(input()) ans='' while n > 0 : n-=1 ans+=chr(ord('a')+n%26) n//=26 print(ans[::-1]) " p02629,s308481465,Accepted,"N=int(input()) n=0 for i in range(1,15): if N<=(n+26**i): break else: n+=26**i #print(i) N-=n N-=1 #print(N) A=[""a"",""b"",""c"",""d"",""e"",""f"",""g"",""h"",""i"",""j"",""k"",""l"",""m"",""n"",""o"",""p"",""q"",""r"",""s"",""t"",""u"",""v"",""w"",""x"",""y"",""z""] ans="""" for j in range(i): ans+=A[N//(26**(i-1-j))] N%=(26**(i-1-j)) print(ans)" p02629,s484154919,Accepted,"N = int(input()) res = [] ls = 'abcdefghijklmnopqrstuvwxyz' while N>0: tmp = (N-1)%26 N = (N-1)//26 res.append(ls[tmp]) res = res[::-1] print(''.join(res))" p02629,s085768901,Accepted,"N = int(input()) alphabet = list(""abcdefghijklmnopqrstuvwxyz"") res = """" while (N > 0): N -= 1 num = int(N % 26) res += alphabet[num] N /= 26 N = N // 1 print(res[::-1])" p02629,s504368108,Accepted,"n = int(input()) out = """" while n > 0: n -= 1 out += chr(ord('a') + n % 26) n //= 26 print(out[::-1])" p02629,s350979812,Accepted,"import math def solve(): N = int(input()) lowercase = 'abcdefghijklmnopqrstuvwxyz' ans = '' for i in range(len(str(N))): if N == 0: break j = N % 26 N -= 1 N = N // 26 ans = lowercase[j - 1] + ans print(ans) if __name__ == '__main__': solve() " p02629,s167734733,Accepted,"n = int(input()) 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) print(num2alpha(n).lower())" p02629,s899272660,Accepted,"import sys input = sys.stdin.readline N = int(input()) res = """" while N: N -= 1 res += chr(N % 26 + ord(""a"")) N //= 26 print(res[: : -1])" p02629,s054055336,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) if __name__ == '__main__': n = int(input()) print(num2alpha(n).lower()) " p02629,s562286564,Accepted,"n = int(input()) 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) x = num2alpha(n) print(x.lower())" p02629,s795775776,Accepted,"def f(n): a = [] while n > 0: n -= 1 a.append(chr(ord('a') + n % 26)) n //= 26 return a if __name__ == ""__main__"": n = int(input()) a = f(n) print(''.join(a[::-1])) " p02629,s550711847,Accepted,"n = int(input()) s = [chr(i) for i in range(97, 97+26)] out = '' tmp = n r = 1 c = 0 count = 1 while True: r *= 26 # c += r # print(c) if tmp > c+r: c += r count += 1 else: break tmp = n - c - 1 # print(tmp) # out = s[tmp%27-1] # tmp = int(tmp/27) while tmp>0: out = s[tmp%26]+out tmp = int(tmp/26) # out = s[tmp%26-1]+out for _ in range(count-len(out)): out = 'a'+out print(out)" p02629,s737152038,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))" p02629,s472787431,Accepted,"s='abcdefghijklmnopqrstuvwxyz' n=int(input()) res=[] n=n-1 while n>=0: res.append(n%26) n=n//26 n=n-1 #print(n,res[-1]) ans='' for j in range(len(res)-1,-1,-1): ans=ans+s[res[j]] print(ans)" p02629,s787079846,Accepted,"n = int(input()) alpha = ""abcdefghijklmnopqrstuvwxyz"" tmp = [26 ** i for i in range(1, 20)] lst = [0] for num in tmp: lst.append(lst[-1] + num) for i, num in enumerate(lst): if num >= n: p = i break ans = list(""a"" * p) n -= lst[p - 1] + 1 for i in range(p - 1, -1, -1): if n == 0: break pos = n % 26 n //= 26 ans[i] = alpha[pos] print("""".join(ans))" p02629,s830482344,Accepted,"N = int(input()) name = [] while N>0: name.append(chr(ord('a')+(N-1)%26)) N = (N - 1) // 26 name.reverse() print("""".join(name))" p02629,s431813923,Accepted,"n = int(input()) def h(n): if int(n/26): if n % 26 == 0: return h(int(n/26) - 1) + 'z' else: return h(int(n/26)) + chr(96 + (n % 26)) else: if n > 0: return chr(96 + n) else: return '' print(h(n)) " p02629,s744676158,Accepted,"n=int(input()) abc='abcdefghijklmnopqrstuvwxyz' ans='' while n!=0: q=n%26 ans+=abc[q-1] if q==0: n-=1 n//=26 print(ans[::-1])" p02629,s198836512,Accepted,"N = int(input()) S = [chr(i) for i in range(ord(""a""), ord(""z"")+1)] l = [] while N > 0: N -= 1 r = N % 26 l.append(r) N //= 26 ans = """" for a in l: ans = S[a] + ans print(ans)" p02629,s695843162,Accepted,"N = int(input()) result = """" while N>0: index = (N-1)%26 result +=chr(index+ord('a')) N = (N-1)//26 print(result[::-1])" p02629,s101725603,Accepted,"n=int(input()) t=""abcdefghijklmnopqrstuvwxyz"" def f(n): if n<=26:return t[n-1] return f((n-1)//26)+t[(n-1)%26] print(f(n))" p02629,s405068401,Accepted,"N = int(input()) - 1 rst = '' for i in range(1, 10 ** 15): if N >= 26 ** i: N -= 26 ** i continue for j in range(i): rst += chr(ord('a') + N % 26) N //= 26 print(rst[::-1]) break" p02629,s602460769,Accepted,"import sys stdin = sys.stdin def ni(): return int(ns()) def na(): return list(map(int, stdin.readline().split())) def naa(N): return [na() for _ in range(N)] def ns(): return stdin.readline().rstrip() # ignore trailing spaces N = ni() digit = 1 alphabets = ""abcdefghijklmnopqrstuvwxyz"" ans = """" while(1): if N > pow(26, digit): N -= pow(26, digit) digit += 1 continue N -= 1 for j in range(digit): ans += alphabets[N // pow(26, digit - j - 1)] N = N % pow(26, digit - j - 1) break print(ans) " p02629,s522807545,Accepted,"from math import * a=int(input()) r='' n=ceil(a/26) while(n and a>0): n-=1 c=a%26 if(c!=0): r+=chr(97+c-1) else: r+='z' if(c==0): a=(a//26)-1 else: a=a//26 print(r[::-1]) " p02629,s788450063,Accepted,"def solve(): n = int(input()) a = 97 tmp = 0 index = 0 ans = [] for i in range(1, 12): pre = tmp tmp += 26 ** i if n <= tmp: index = i n = n - pre break n = n - 1 for _ in range(0, index)[::-1]: ans.append(chr((n % 26) + a)) n = n // 26 print(''.join(ans[::-1])) if __name__ == '__main__': solve() " p02629,s556850549,Accepted,"n = int(input()) a = ""abcdefghijklmnopqrstuvwxyz"" s = [] while n > 0: s.append(a[n%26 - 1]) if (n % 26 == 0): n = n // 26 -1 else: n //= 26 print(''.join(s[::-1])) " p02629,s759544589,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])" p02629,s755625263,Accepted,"n = int(input()) alp = 'abcdefghijklmnopqrstuvwxyz' name = [] while n > 0: n -= 1 name.append(alp[n % 26]) n //= 26 name.reverse() print(*name,sep='')" p02629,s162699714,Accepted,"N = int(input()) name = '' while True: rem = (N-1) % 26 name += chr(rem + ord('a')) N = (N-1) // 26 if N == 0: break print(name[::-1])" p02629,s897254959,Accepted,"n = int(input()) 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) print(num2alpha(n).lower())" p02629,s912156020,Accepted,"#!/usr/bin/env python3 import string N = int(input().split()[0]) a_list = list(string.ascii_lowercase) amari_list = [] n = N while n > 0: n -= 1 amari = n % 26 amari_list.append(a_list[amari]) n = n // 26 ans = """".join(reversed(amari_list)) print(ans) " p02629,s304041511,Accepted,"n = int(input()) s = """" abc = ""abcdefghijklmnopqrstuvwxyz"" while n: s = abc[(n - 1) % 26] + s n -= 1 n //= 26 print(s) " p02629,s571381830,Accepted,"n = int(input()) ans = """" while n > 0: x = n % 26 if x != 0: ans += chr(x + 96) else: ans += 'z' n -= 1 n = n // 26 print(ans[::-1]) " p02629,s844859111,Accepted,"N = int(input()) ans = [] while(True): m = N % 26 if m == 0: m = 26 ans.append(m) N -= m N = N // 26 if N == 0: break # print(ans) ans.reverse() print(''.join(map(lambda i: chr(96 + i), ans)))" p02629,s418992038,Accepted,"N = int(input()) def solve(n): if 1 <= n <= 26: return chr(ord('a') + (n-1) % 26) else: q, r = divmod(n, 26) if r == 0: q -= 1 r += 26 return solve(q) + chr(ord('a') + (r-1) % 26) print(solve(N))" p02629,s706505603,Accepted,"N = int(input()) ans = [] A = ['z', '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'] while N > 0: ans.append(A[N % 26]) if N % 26 == 0: N = N // 26 - 1 else: N = N // 26 ans = ans[::-1] ans = ''.join(ans) print(ans)" p02629,s620108843,Accepted,"def alpha2num(alpha): num=0 for index, item in enumerate(list(alpha)): num += pow(26,len(alpha)-index-1)*(ord(item)-ord('A')+1) return num def num2alpha(num): if num<=26: return chr(64+num) elif num%26==0: return num2alpha(num//26-1)+chr(90) else: return num2alpha(num//26)+chr(64+num%26) n=int(input()) s = num2alpha(n) print(s.lower())" p02629,s665583491,Accepted,"# -*- coding: utf-8 -*- import math from sys import stdin input = stdin.readline import numpy as np N = int(input()) al = [chr(i) for i in range(97, 97+26)] ans = """" while N>0: N -= 1 ans += al[N%26] N //= 26 print(ans[::-1])" p02629,s633195776,Accepted,"n = int(input()) alphabet = 'abcdefghijklmnopqrstuvwxyz' def name(n): if n <= 26: return alphabet[n - 1] else: return name((n - 1) // 26) + name(n % 26) print(name(n)) " p02629,s515541942,Accepted,"import math #map(int,input().split()) #int(x) for x in input().split() #for _ in range(int(input())): n=int(input()) s='' while n>0: x=n//26 d=n-x*26 if d==0: s+='z' n=(n-26)//26 continue else: s+=chr(96+int(d)) if n%26==0 and x==1: break n=x print(s[::-1]) " p02629,s316575066,Accepted,"import sys sys.setrecursionlimit(10 ** 7) f_inf = float('inf') mod = 10 ** 9 + 7 def resolve(): n = int(input()) L = [chr(i) for i in range(97, 97 + 26)] res = """" while n: r = n % 26 res += L[r - 1] n = max(0, (n - 1)) // 26 print(res[::-1]) if __name__ == '__main__': resolve() " p02629,s215653711,Accepted,"N = int(input()) ans = """" while N > 0: N -= 1 ans += chr(N%26+97) N //= 26 print(ans[-1::-1])" p02629,s872112224,Accepted,"import string,sys def I(): return int(sys.stdin.readline().rstrip()) N = I() abc = string.ascii_lowercase def main(N): if N<=26: return abc[N-1] if N%26==0: return main(N//26-1)+abc[-1] return main(N//26)+abc[N%26-1] print(main(N)) " p02629,s679316564,Accepted,"n = int(input()) c = "" "" while n: if n % 26 == 0: c += 'z' n -= 1 else: c += chr((n % 26) + ord('a') - 1) n //= 26 print(c[::-1]) " p02629,s358775370,Accepted,"l = [""z"",""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""] l2 = [0]*11 n = int(input()) for i in range(11): p = 0 q = 0 p = n%26 if n==0 and p==0: l2[i]="""" else: l2[i]=l[p] if p ==0: q = n - 26 else: q = n - p n = q//26 print(l2[10]+l2[9]+l2[8]+l2[7]+l2[6]+l2[5]+l2[4]+l2[3]+l2[2]+l2[1]+l2[0])" p02629,s473610786,Accepted,"ans=[] N=int(input()) N-=1 count=0 for l in range(1,15): if N>=26**l: N-=26**l continue count=l break for i in range(count): d=N%26 ans.append(chr(d+ord(""a""))) N//=26 ans.reverse() print(*ans,sep="""")" p02629,s713881865,Accepted,"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'] N = int(input()) ans = [] S = '' while N != 0: ans.append(N%26) if N %26 == 0: N = N//26 - 1 else: N = N//26 ans.reverse() S = '' for i in ans: S += A[i-1] print(S) " p02629,s280233180,Accepted,"import sys input = sys.stdin.readline def main(): N = int(input()) ans = '' while N > 0: N -= 1 ans += chr(ord('a') + N % 26) N = N // 26 print(ans[::-1]) main()" p02629,s608093940,Accepted,"n = int(input()) cha = ""abcdefghijklmnopqrstuvwxyz"" ans = """" while n>=1: ans += cha[((n-1)%26)] n=(n-1)//26 print(ans[::-1])" p02629,s355985817,Accepted,"n = int(input()) #n, k = [int(a) for a in input().split()] #ps = [int(a) for a in input().split()] a = [] remain = n while remain != 0: t = int(remain % 26) a.append(t if t != 0 else 26) remain -= a[-1] remain /= 26 #a.append(int(remain)) tmp = ' abcdefghijklmnopqrstuvwxyz' a.reverse() print(''.join([tmp[i] for i in a])) " p02629,s085462405,Accepted,"def num2alpha(num): if num <= 26: return chr(96+num) elif num % 26 == 0: return num2alpha(num//26-1)+chr(90) else: return num2alpha(num//26)+chr(96+num % 26) n = int(input()) ans = num2alpha(n) print(ans.lower()) " p02629,s829028813,Accepted,"import math N = int(input())-1 ans = [] while(N>=26): ans.append(chr(ord(""a"")+(N%26))) N = (N-26)//26 ans.append(chr(ord(""a"")+(N%26))) print("""".join(ans[::-1]))" p02629,s079764983,Accepted,"n = int(input()) alphabets = ['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'] res = '' while (n > 0): n = n - 1 q = n % 26 n = n // 26 res = res + alphabets[q] res = res[::-1] print(res)" p02629,s464408151,Accepted,"import sys import itertools sys.setrecursionlimit(1000000000) from heapq import heapify,heappop,heappush,heappushpop import math import collections import copy def main(): n = int(input()) ans = """" alpa = ""abcdefghijklmnopqrstuvwxyz"" while n: ans += alpa[n%26-1] n-=1 n//=26 ans2 = """" for i in range(len(ans)): ans2 += ans[len(ans)-i-1] print(ans2) if __name__ == ""__main__"": main()" p02629,s503300367,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))" p02629,s112625284,Accepted,"N = int(input()) alpha = ""zabcdefghijklmnopqrstuvwxy"" ans = """" while N > 0: ans = alpha[N%26] + ans if N%26==0: N = (N-26) //26 else: N = N // 26 print(ans)" p02629,s591567240,Accepted,"N = int(input()) n = 26 m = 1 while N > n: n = n * 26 + 26 m += 1 e = n result = '' for i in range(m): a = N % 26 if a == 0: a = 26 result = chr(a + 96) + result N = (N - a) // 26 print(result)" p02629,s654860387,Accepted,"n= int(input()) azlist = list('abcdefghijklmnopqrstuvwxyz') ans = '' for i in range(1,10000): n -= 1 ans = azlist[n%26] + ans n = n//26 if n ==0: break print(ans) " p02629,s024981838,Accepted,"import sys input = sys.stdin.readline def main(): n = int(input()) start = 0 cnt = 0 while 1: start += 26 ** cnt if start > n: start -= 26 ** cnt break cnt += 1 ans = '' tmp = n - start for i in range(cnt): ans += chr(ord('a') + tmp % 26) tmp //= 26 print(ans[::-1]) if __name__ == '__main__': main() " p02629,s965657456,Accepted,"n = int(input()) t = [] while(n > 0): n -= 1 t.append(n%26) n //= 26 s = """" for i in range(1,len(t)+1): s += chr(t[-i]+97) print(s)" p02629,s745226087,Accepted,"n=int(input()) c="""" while n: n-=1 c=chr(n%26+97)+c n//=26 print(c)" p02629,s420790410,Accepted,"n = input() N = int(n) def can_devide(num): return num > 26 def get_alpha(alp): apls = [chr(i) for i in range(97, 97+26)] return apls[alp - 1] ans = """" while True: alp = N % 26 ans += get_alpha(alp) if alp == 0: N = N // 26 -1 else: N = N // 26 if N == 0: break print(ans[::-1]) " p02629,s212908877,Accepted,"N=int(input()) out='' while N>26: if N%26!=0: out=str(chr(ord('a')+N%26-1))+out N=N//26 else: out=str(chr(ord('a')+25))+out N=N//26-1 if N!=0: print(str(chr(ord('a')+N-1))+out) else: print(out)" p02629,s221570868,Accepted,"N = int(input()) ans = """" li = ""abcdefghijklmnopqrstuvwxyz"" while N > 0: N -= 1 ans += li[N % 26] N //= 26 print(ans[::-1]) " p02629,s163964713,Accepted,"N = int(input()) a = list('abcdefghijklmnopqrstuvwxyz') name = 0 while N!=0: N-=1 M = N%26 N = N//26 if name ==0: name = a[M] else: name = a[M]+name print(name)" p02629,s779368232,Accepted," N = int(input()) ans = """" x = N while x > 0: cur = (x - 1) % 26 ans += chr(ord(""a"") + cur) x = (x - 1) // 26 print(ans[::-1]) " p02629,s706327350,Accepted,"n=int(input()) N=n 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""] t=1 for i in range(1,20): if n>26**i: n=n-26**i t+=1 p=[0]*t s=0 A="""" for i in range(1,t+1): s=N%26 if s == 0: s = 26 N=(N-s)//26 p[t-i]=s for i in range(t): A+=(a[p[i]-1]) print(A)" p02629,s320858692,Accepted,"n = int(input()) nmax = 1000000000000001 alp = list(""abcdefghijklmnopqrstuvwxyz"") ans = [] while n > 0: r = n%26 if r == 0: r = 26 n = (n-r)//26 ans.append(alp[r-1]) print(''.join(ans[::-1])) " p02629,s126237623,Accepted,"n=int(input()) ans="""" while n: n-=1 ans+=chr(n%26+ord(""a"")) n//=26 print(ans[::-1])" p02629,s503507784,Accepted,"def solve(): # ref. https://drken1215.hatenablog.com/entry/2020/06/21/225500 N = int(input()) ans = '' while N > 0: N -= 1 N,digit = divmod(N,26) ans += chr(ord('a') + digit) print(ans[::-1]) if __name__ == ""__main__"": solve()" p02629,s583161977,Accepted,"N = int(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""] name = """" s = True while s: a = N % 26 if a == 0: a = 25 else: a -= 1 name = A[a] + name N = (N - a) // 26 if N == 0: s = False print(name)" p02629,s222982214,Accepted,"n = int(input()) 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) print(num2alpha(n).lower())" p02629,s153577573,Accepted,"import string b = string.ascii_letters a = int(input()) c = [] while(a>0): a-=1 c.append(b[a%26]) a=a//26 c.reverse() print(''.join(c))" p02629,s074392722,Accepted,"n = int(input()) alp = 'abcdefghijklmnopqrstuvwxyz' # 名前の長さを求める min_n = 0 max_n = 26 l = 0 while min_n < n <= max_n: min_n += max_n max_n += max_n * 26 l += 1 # n - min_n 番目の名前を求める <=> n - min_n - 1 を26進数に変換 m = n - min_n - 1 ans = '' while m >= 26: ans = alp[m % 26] + ans m = m // 26 - 1 ans = alp[m] + ans while len(ans) < l: ans = 'a' + ans print(ans)" p02629,s433066964,Accepted,"from math import ceil n = int(input()) a = [chr(i) for i in range(97, 97+26)] s = 0 for i in range(1,100): l = n - s s += 26**i if n <= s: m = i break #第m群l番目 name = [0] * m div = [0] * m rem = [0] * m rem[-1] = l for j in range(m): div[j] = ceil(rem[j-1] / (26**(m-j-1))) rem[j] = rem[j-1] % (26**(m-j-1)) if rem[j] == 0: rem[j] == 26**(m-j-1) name[j] = a[div[j]-1] print(''.join(name))" p02629,s378760896,Accepted,"n = int(input()) a = 26 ans = '' while n != 0: n -= 1 ans += chr(ord('a') + n % 26) n //= 26 print(ans[::-1])" p02629,s761484181,Accepted,"alphabets = [""""] + [s for s in ""abcdefghijklmnopqrstuvwxyz""] s = int(input()) nums = [] while s > 0: nums.append((s - 1) % 26 + 1) s = (s - 1) // 26 res = """" for _ in range(len(nums)): res = res + alphabets[nums.pop()] print(res)" p02629,s629354474,Accepted,"from math import log,ceil n=int(input()) l=ceil((log(25*n+26)/log(26)))-1 d=n-26*(pow(26,l)-1)//25-1 s='' for i in range(int(l)): s=chr(97+int(d)%26)+s d//=26 print(s) " p02629,s603603903,Accepted,"N = int(input()) 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) ans = num2alpha(N) print(str.lower(ans))" p02629,s935336592,Accepted,"def main(): n = int(input()) s = ""abcdefghijklmnopqrstuvwxyz"" ans = """" while True: d = n % 26 ans += s[d - 1] if n <= 26: break n = (n // 26) if d == 0: n -= 1 print(ans[::-1]) if __name__ == '__main__': main()" p02629,s746279131,Accepted,"n = int(input()) stock = [chr(i) for i in range(97, 97 + 26)] full, count, j = 26, 1, 1 while (count + full <= n): count += full; j += 1; full *= 26 q = n - count s = [] for k in range(j): s.append(stock[q % 26]) q //= 26 print("""".join(s[::-1]))" p02629,s657527534,Accepted,"n=int(input()) A=[chr(u) for u in range(97,123)] na="""" while n>0: q=n%26 na+=A[q-1] n= n//26 if n%26!=0 else n//26-1 print(na[::-1]) " p02629,s539871990,Accepted,"import math N=int(input()) def num2alpha(num): if num<=26: return str.lower(chr(64+num)) elif num%26==0: return str.lower(num2alpha(num//26-1)+chr(90)) else: return str.lower(num2alpha(num//26)+chr(64+num%26)) print(num2alpha(N)) " p02629,s230971106,Accepted,"n = int(input()) i = 1 ans = [] while n > 0: tmp = n % 26 if tmp == 0: tmp = 26 ans.append(chr(tmp+96)) n = (n-tmp)//26 ans = ans[::-1] print(''.join(ans)) " p02629,s611710777,Accepted,"alphabet_list =['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 __name__==""__main__"": # Problem C N = int(input()) ans = '' while N > 0: N -= 1 ans += alphabet_list[N % 26] N = N // 26 print(ans[::-1])" p02629,s460430825,Accepted,"n = int(input()) name_base = [] dog_name = '' while n > 0: ch_mod = (n-1)%26 n = (n-1)//26 name_base.append(ch_mod) for i in name_base: dog_name = dog_name + chr(i+97) print(dog_name[::-1])" p02629,s294975228,Accepted,"N = int(input()) DIV = 26 mojiretsu = '' NUM = 97 i = 1 minus = 0 while(True): minus += DIV ** (i - 1) mod = (N - minus) % (DIV ** i) new_sho = mod // DIV ** (i - 1) mojiretsu = chr(NUM + new_sho) + mojiretsu sho = (N - minus) // (DIV ** i) if sho == 0: print(mojiretsu) break i += 1" p02629,s516835536,Accepted,"N = int(input()) name = '' while N > 0: N, remainder = divmod(N - 1, 26) name = chr(ord('a') + remainder) + name print(''.join(name)) " p02629,s691316017,Accepted,"N=int(input()) 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) a=num2alpha(N) print(str.lower(a))" p02629,s845519536,Accepted,"N = int(input()) - 1 s = '' M = 0 for i in range(1, 1000000): M += 26 ** i if M > N: break N -= (M - 26**i) for j in reversed(range(i)): K = N // (26 ** j) s += chr(K + 97) N -= K * (26 ** j) print(s)" p02629,s359748485,Accepted,"import string def run(n): ''' ''' _base_array = string.ascii_lowercase results = [] while n > 0: results.append(_base_array[n%26 - 1]) if n%26 == 0: n = n//26 - 1 continue n = n//26 print(''.join(results[::-1])) if __name__ == '__main__': n = int(input()) run(n)" p02629,s199740211,Accepted," def resolve(): lower = ""abcdefghijklmnopqrstuvwxyz"" N = int(input()) ans = """" while N > 26: idx = N % 26 ans += lower[idx-1] N = -(-N//26)-1 idx = N % 26 ans += lower[idx - 1] print(ans[::-1]) if __name__ == ""__main__"": resolve() " p02629,s690444157,Accepted,"n = int(input())-1 x = 26 d = 1 while n >= x: n -= x d += 1 x *= 26 ans = """" al = list(""abcdefghijklmnopqrstuvwxyz"") tmp = pow(26,d) for i in range(d-1,-1,-1): tmp //= 26 ans += al[n//tmp] n %= tmp print(ans)" p02629,s248939925,Accepted,"n = int(input()) ans = """" while n > 0: x = n % 26 if x != 0: ans += chr(x + 96) else: ans += 'z' n -= 1 n = n // 26 print(ans[::-1])" p02629,s754420774,Accepted,"n=int(input()) ans='' i=1 c=0 while n>0: t=n%26 if t==0: t=26 c=1 ans=chr(t+ord('a')-1)+ans n//=26 n-=c c=0 print(ans)" p02629,s614067640,Accepted,"N = int(input()) len = 0 for i in range(12): if (26**i - 1)//25 <= N and (26**(i+1) - 1)//25 > N: len = i ans = [""a"" for _ in range(len)] k = N - (26**len - 1)//25 + 1 x = k-1 for j in range(len): ans[j] = chr(ord(""a"") + x%26) x = x // 26 print("""".join(ans[::-1]))" p02629,s972125287,Accepted,"S = int(input()) def this(num): if num<=26: return chr(64+num) elif num%26==0: return this(num//26-1)+chr(90) else: return this(num//26)+chr(64+num%26) print(this(S).lower()) " p02629,s867870107,Accepted,"import string def m(): N = int(input()) a2z = string.ascii_lowercase ans = '' while N != 0: N -= 1 ans = a2z[N % 26] + ans N = N // 26 return ans print(m()) " p02629,s469609585,Accepted,"n=int(input()) ans=[] while n>0: n-=1 a=n%26 ans.append(chr(ord('a')+a)) n=n//26 ans.reverse() print(''.join(ans))" p02629,s562646062,Accepted,"def main(): N = int(input()) n = N ans = [] while n > 0: n -= 1 remain = n % 26 ans.append(chr(ord('a') + remain)) n //= 26 print(''.join(reversed(ans))) main()" p02629,s120854649,Accepted,"table = list(""abcdefghijklmnopqrstuvwxyz"") N = int(input()) ans = [] while True: ans.append(N%26) if N%26 == 0: N -= 1 if N//26 == 0: break N//=26 for x in reversed(ans): print(table[x-1],end='') print() " p02629,s474745099,Accepted,"n = int(input()) ans = """" while n > 0: n -= 1 ans = chr(ord('a') + n%26) + ans n //= 26 print(ans)" p02629,s382531042,Accepted,"N = int(input()) p = 1 cnt = 26 while (cnt < N): p += 1 cnt += 26 ** p mod = (N - cnt + 26 ** p) % 26 ** p mod = mod - 1 # str : p alphabet = ""abcdefghijklmnopqrstuvwxyz"" st = ['a'] * p for i in reversed(list(range(p))): st[i] = alphabet[(mod % 26)] mod = mod // 26 print(*st, sep='')" p02629,s056389393,Accepted,"N = int(input()) def num2alpha(N): if N <= 26: return chr(64+N) elif N%26 == 0: return num2alpha(N//26-1) + chr(90) else: return num2alpha(N//26) + chr(64+N%26) print(str.lower(num2alpha(N)))" p02629,s117497349,Accepted,"import sys read = sys.stdin.read readlines = sys.stdin.readlines def main(): n = int(input()) r = [] while n > 0: n -= 1 t1 = n % 26 r.append(chr(t1+97)) n = n // 26 r2 = """".join(r[::-1]) print(r2) if __name__ == '__main__': main()" p02629,s288048270,Accepted,"N = int(input()) mapping = 'zabcdefghijklmnopqrstuvwxy' res = [] for i in range(1, 99): if N <= 26 ** i: for j in range(i): N, r = divmod(N, 26) res.append(mapping[r]) if r: N += 1 break else: N -= 26 ** i res.reverse() print(''.join(res))" p02629,s680289039,Accepted,"n = int(input()) ans = '' while n: n -= 1 alphabet = chr(ord('a') + n % 26) ans += alphabet n //= 26 print(ans[::-1])" p02629,s187735376,Accepted,"N = int(input()) alpha_list = ""abcdefghijklmnopqrstuvwxyz"" ans = """" moji_list = [] while(N != 0): tmp = N % 26 if(tmp == 0): tmp = 26 moji_list.append(alpha_list[tmp-1]) N = (N - tmp) // 26 #print(moji_list) for hoge in reversed(moji_list): ans += hoge print(ans)" p02629,s949378713,Accepted,"# coding: utf-8 # Your code here! def num2alpha(x): if x <= 26: return chr(x + 64).lower() elif x % 26 == 0: return num2alpha(x // 26 -1) + chr(90).lower() else: return num2alpha(x // 26) + chr(x % 26 + 64).lower() def main(): n = int(input()) print(num2alpha(n)) main()" p02629,s467709011,Accepted,"def num2alpha(num): if num<=26: return chr(64+num) elif num%26==0: return num2alpha(num//26-1)+chr(90) else: return num2alpha(num//26)+chr(64+num%26) N=int(input()) ans=num2alpha(N) print(str.lower(ans))" p02629,s965425676,Accepted,"n = int(input()) ans ="""" while True: i = n%26 if i == 0:i = 26 n = (n-1) // 26 mo = ord(""a"")+(i-1) ans = chr(mo) + ans if n == 0: break print(ans)" p02629,s994119411,Accepted,"def number(num): if num<=26: return chr(96+num) elif num%26==0: return number(num//26-1)+chr(122) else: return number(num//26)+chr(96+num%26) N = int(input()) print(number(N))" p02629,s623305540,Accepted,"n=int(input()) digit=0 for i in range(1,12): tmp=26**i if n<=tmp: digit=i break else: n-=tmp # print(digit,n) n-=1 ans=[] for i in range(digit-1,-1,-1): tmp=26**i # print(n,tmp,n//tmp,n%tmp) ans.append(n//tmp) n%=tmp # print(ans) for ai in ans: print(chr(ai+97),end='') " p02629,s191961423,Accepted,"import itertools import string n = int(input()) alphabets = string.ascii_lowercase digit = 0 counter = 0 while counter < n: digit += 1 counter += 26**digit answer = """" for d in range(digit): if d == 0: alphabet = n % 26 - 1 if alphabet == -1: alphabet = 25 answer = alphabets[alphabet] + answer n = n - alphabet else: n = n // 26 alphabet = n % 26 - 1 if alphabet == -1: alphabet = 25 answer = alphabets[alphabet] + answer n = n - alphabet print(answer)" p02629,s473094134,Accepted,"N = int(input()) ans = '' while N > 0: N -= 1 ans += chr(ord('a') + N % 26) N //= 26 print(ans[::-1])" p02629,s362395050,Accepted,"N=int(input()) res="""" while(N): N-=1 res=res+chr(ord(""a"")+int(N%26)) N=int(N/26) res=res[::-1] print(res) " p02629,s571096744,Accepted,"n = int(input()) for i in range(1000): if n > 26**(i+1): n -= 26**(i+1) else: break x = i+1 t = 26**i ans = """" for i in range(x-1,-1,-1): t = 26**i for j in range(26): if n > t: n -= t else: ans += chr(ord(""a"")+j) break print(ans) " p02629,s783008369,Accepted,"N = int(input()) res = [] while N: N -= 1 N, r = divmod(N, 26) res.append(chr(r + ord('a'))) res.reverse() print(''.join(res)) " p02629,s910144936,Accepted,"N = int(input()) a = 1 ans = '' abc = [chr(ord('a') + i) for i in range(26)] while N>26**a: N -= 26**a a += 1 ans += abc[N%26-1] if a >= 2: N = (N-1)//26 for i in range(a-1): ans += abc[N%26] N = N//26 print(ans[::-1])" p02629,s648423796,Accepted,"n = int(input()) ans = """" last_is_z = False while n: if last_is_z: n -= 1 if n == 0: break if n % 26 == 0: # zのとき ans += ""z"" last_is_z = True else: ans += chr(96 + n % 26) last_is_z = False n //= 26 print(ans[::-1])" p02629,s433879046,Accepted,"def solve(): N = int(input()) k = 1 while N>pow(26,k): N -= pow(26,k) k += 1 ans = '' N -= 1 for i in range(k,1,-1): ans += chr(ord('a')+N//pow(26,i-1)) N%=pow(26,i-1) ans += chr(ord('a')+N%26) return ans print(solve())" p02629,s099166071,Accepted,"N=int(input()) alp=[] mozi=[chr(i) for i in range(97, 97+26)] while(True): K=-1 K = int(N%26) alp.insert(0,mozi[K-1]) if(N<=26):break if(K==0):N =(N-26)/26 else:N = (N-K)/26 print(''.join(alp))" p02629,s099232040,Accepted,"N = int(input()) alpha = [] while N != 0: a = N % 26 if a == 0: a = 26 N -= 1 alpha.append(chr(a + 96)) N = int(N / 26) alpha.reverse() print(''.join(alpha))" p02629,s053521127,Accepted,"n = int(input()) - 1 x = 26 i = 1 while n >= x: n -= x x *= 26 i += 1 r = '' while n: r = chr(97 + n % 26) + r n //= 26 print(r.rjust(i, 'a')) " p02629,s993805796,Accepted,"n = int(input()) alphabet = 'abcdefghijklmnopqrstuvwxyz' n -= 1 ans = '' while n >= 0: ans = alphabet[n % 26] + ans n //= 26 n -= 1 print(ans) " p02629,s532631495,Accepted,"n = int(input()) res = [] arufa = [] for i in range(97, 123): arufa.append(chr(i)) while n: if n == 0: break n -= 1 res.append(arufa[int(n % 26)]) n //= 26 res.reverse() ans = """".join(res) print(ans) " p02629,s933831877,Accepted,"n=int(input()) s='' while n: n-=1 s=chr(97+n%26)+s n//=26 print(s)" p02629,s463419683,Accepted,"N = int(input()) ans='' while N>0: N -= 1 ans += chr(ord('a') + N % 26) N = N//26 print(ans[::-1])" p02629,s846157358,Accepted,"N = int(input()) 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 = num2alpha(N) print(s.lower())" p02629,s443571974,Accepted,"n = int(input()) ans = '' while n: n -= 1 ans += chr(ord('a')+n%26) n //= 26 print(ans[::-1])" p02629,s035988771,Accepted,"def dogsName(n): if (n==0): return n = n-1 last_char = n%26 dogsName(n//26) print(chr(ord('a') + last_char), end='') n = int(input()) dogsName(n) " p02629,s835560455,Accepted,"def main(): import sys def input(): return sys.stdin.readline().rstrip() n = int(input()) count = 1 k,l = 26,26 while k < n: l *= 26 k += l count += 1 r = n - k + l -1 s = '' for i in range(count): m = r%26 r //= 26 s += chr(ord('a')+ m) s = s[::-1] print(s) if __name__ == '__main__': main()" p02629,s479409773,Accepted,"n = int(input()) ans = '' while n > 0: n -= 1 ans += chr(n % 26 + ord('a')) n = n // 26 print(ans[::-1])" p02629,s655827568,Accepted,"n = int(input()) ans ='' while n > 0: n = n - 1 ans += chr(ord('a') + n % 26) n = n // 26 print(ans[::-1]) " p02629,s339322778,Accepted,"N = int(input()) 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) ans = num2alpha(N) print(ans.lower())" p02629,s634681494,Accepted,"N=int(input()) ans=[] a=ord(""a"") while N>0: N-=1 chrr=N%26 ans.append(chr(a+chrr)) N//=26 print("""".join(ans[::-1])) " p02629,s887009670,Accepted,"N = int(input()) alpha = 'abcdefghijklmnopqrstuvwxyz' ans = '' while N > 0: N -= 1 ans += alpha[N%26] N //= 26 print( ans[::-1])" p02629,s991355610,Accepted,"a_list = [chr(ord('a') + i) for i in range(26)] n = int(input()) l_list = [] ans = '' while n > 0: if n % 26 == 0: l_list.append(26) n = n // 26 - 1 else: l_list.append(n%26) n = n // 26 l_list = l_list[::-1] for i in l_list: ans += a_list[i-1] print(ans)" p02629,s159628823,Accepted,"N = int(input()) digit = 1 for i in range(1,11): if N > 26**i: digit += 1 N -= 26**i else: break ans = [] for i in reversed(range(1,digit)): ans.append((N-1)//(26**i)) N -= ans[-1]*(26**i) ans.append(N-1) ans = [chr(i+97) for i in ans] print("""".join(ans))" p02629,s282880568,Accepted,"N = int(input()) ans = '' while N > 0: N -= 1 ans += chr(97 + N % 26) N //= 26 print(ans[::-1])" p02629,s708070050,Accepted,"base = ord('a') N = int(input()) data = [] while N: next, mod = divmod(N - 1, 26) data.append(mod) N = next data.reverse() for i in data: print(chr(base + i), end="""") " p02629,s518953179,Accepted,"n = int(input()) digits = [] while n > 0: r = n % 26 if r == 0: r = 26 c = chr(r + ord(""a"") - 1) digits.append(c) n = (n-1) // 26 digits.reverse() print("""".join(digits)) " p02629,s846529015,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" p02629,s562222336,Accepted,"N = int(input()) 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) result = str(num2alpha(N)) result = result.lower() print(result)" p02629,s800759975,Accepted,"n=int(input()) ans='' while n>0: n-=1 ans+=chr(ord('a')+ n%26) n=n//26 print(ans[::-1])" p02629,s065943240,Accepted,"n = int(input()) ans = [] alpha = [chr(i) for i in range(97, 97+26)] num = 0 rank = 0 for i in range(100): if num >= n: rank = i break num += 26 ** (i + 1) num -= 26 ** rank n -= num + 1 for i in range(rank): ans.append(alpha[n % 26]) n = n // 26 ans.reverse() print(''.join(ans)) " p02629,s628185028,Accepted,"N = int(input()) an = [] alfa = 'abcdefghijklmnopqrstuvwxyz' N -= 1 while True: amari = N % 26 an.append(amari) if N < 26: break N = N // 26 - 1 ans = '' for x in an : ans = alfa[x] + ans print(ans) " p02629,s233094498,Accepted,"import string small = string.ascii_lowercase n = int(input()) ans = """" while n > 0: n -= 1 r = n % 26 ans = small[r] + ans n = (n- r) // 26 print(ans)" p02629,s382388849,Accepted,"A = int(input()) alp = [chr(i) for i in range(97, 97+26)] def Base_10_to_n_alp(X, n): X = X-1 if (int(X/n)): return Base_10_to_n_alp(int(X/n), n)+alp[X%n] return alp[X%n] print(Base_10_to_n_alp(A,26)) " p02629,s680726875,Accepted,"n=int(input()) 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) ans=num2alpha(n).lower() print(ans)" p02629,s055044156,Accepted,"N = int(input()) 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) print(num2alpha(N).lower())" p02629,s885236253,Accepted,"# -*- coding: utf-8 -*- N = int(input()) ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz' ans = """" while(N > 0): N, mod = divmod(N, 26) if mod == 0: N -= 1 ans = ""z"" + ans else: ans = ascii_lowercase[mod - 1] + ans print(ans)" p02629,s785620272,Accepted,"N = int(input()) def name(n): if n == 0: return '' n -= 1 return name(n//26) + chr(ord('a') + n % 26) print(name(N))" p02629,s625368042,Accepted,"import sys readline = sys.stdin.readline def num2alpha(n): if n <= 26: return chr(64 + n) elif n % 26 == 0: return num2alpha(n // 26 - 1) + chr(90) else: return num2alpha(n // 26) + chr(64 + n % 26) def main(): N = int(readline()) print(num2alpha(N).lower()) if __name__ == '__main__': main()" p02629,s638816125,Accepted,"n = int(input()) s = """" al = ""abcdefghijklmnopqrstuvwxyz"" while n > 0: o = (n-1) % 26 n = (n-1) // 26 s += al[int(o)] print(s[::-1]) " p02629,s629480553,Accepted,"import math N = int(input()) al = ['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'] x = N keta = [0]*100 i = 0 while x > 0: if x % 26 == 0: keta[i] = 26 else: keta[i] = x % 26 x -= keta[i] x = int(x / 26) i += 1 ans = """" for p in range(i): ans = al[keta[p]-1] + ans print(ans)" p02629,s112796869,Accepted,"n=int(input()) string = """" for i in range(12): n = n - 1 ret = n%26 #0~25 string = chr(ret+97) + string if n<26: break n = int((n - ret) / 26) print(string) " p02629,s661494713,Accepted,"N = int(input()) n = 1#桁数 ans = """" an = 0 alfabet = ""abcdefghijklmnopqrstuvwxyz"" while(not (an=0): k = 1 while(mae+26**l*k < N):#l桁目を求める k +=1 ans= ans+alfabet[k-1] if(k!=1): mae = mae +26**l*(k-1) l-=1 print(ans) " p02629,s180945523,Accepted,"import sys input = sys.stdin.readline N = int(input()) piv = 0 while True: if 26*(26**piv-1)/25 >= N: break piv += 1 N -= 26*(26**(piv-1)-1)/25 + 1 for i in reversed(range(piv)): x = int(N//(26**i)%26) print(chr(x+97), end='') print() " p02629,s558040482,Accepted,"def main(): N = int(input()) s = """" d = N while d: if d % 26 == 0: d, r = d // 26 - 1, 26 else: d, r = d // 26, d % 26 s += chr(r+64).lower() print("""".join(list(reversed(s)))) if __name__ == '__main__': main()" p02629,s047876769,Accepted," def q3(): Alphabet = [""dummy""] + [c for c in ""abcdefghijklmnopqrstuvwxyz""] n = int(input()) name = """" while True: if n <= 26: name = Alphabet[n] + name break n_c = n % 26 if n_c == 0: name = ""z"" + name n = n // 26 - 1 else: name = Alphabet[n_c] + name n = (n - n_c) // 26 print(name) q3() " p02629,s220826249,Accepted,"n = int(input()) n_temp = n index_pochi = [] eiji_list = [chr(ord('a') + i) for i in range(26)] while(True): eiji = eiji_list[(n_temp-1)%26] index_pochi = [eiji] + index_pochi if int((n_temp-1)/26) == 0: break n_temp = int((n_temp-1)/26) print("""".join(index_pochi))" p02629,s963695868,Accepted,"def main(): N = int( input()) t = 26 ANS = [] a = ord(""a"") # if N == 1: # print(""a"") # return # N -= 1 while True: # if N%t == 0: # ANS.append(""z"") # else: ANS.append( chr((N-1)%t+a)) N = (N-1)//t if N == 0: break print("""".join( ANS[::-1])) if __name__ == '__main__': main() " p02629,s965901928,Accepted,"N=int(input()) 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) print(num2alpha(N).lower())" p02629,s008069632,Accepted,"n = int(input()) chars = '' dividend = n columnName = '' modulo = 0 while dividend > 0: modulo = (dividend - 1) % 26 columnName = chr(97 + modulo) + columnName dividend = int((dividend - modulo) / 26) print(columnName)" p02629,s162001154,Accepted,"t=""abcdefghijklmnopqrstuvwxyz"" n=int(input()) def f(n): if n<=26: return t[n-1] return f((n-1)//26)+t[(n-1)%26] print(f(n)) " p02629,s319150480,Accepted,"n=int(input()) #x,n=map(int,input().split()) #pl=list(map(int,input().split())) #l=[list(map(int,input().split())) for i in range(n)] res='' # 文字数を求める total=0 i=1 while True: if total+26**i>=n: break else: total+=26**i i+=1 # 文字数iがわかったので,そのなかでn-i番目 k=n-total-1 for j in range(i): res+=chr(ord('a')+k%26) k=k//26 print(res[::-1]) " p02629,s350467026,Accepted,"N = int(input()) ans = '' while N > 0: N -= 1 ans += chr(ord('a') + N % 26) N //= 26 print(ans[::-1]) " p02629,s289025760,Accepted,"n=int(input()) result='' while n>0: n-=1 result+=chr(ord('a')+n%26) n//=26 print(result[::-1])" p02629,s444453548,Accepted,"def main(): n = int(input()) A = 'zabcdefghijklmnopqrstuvwxyz' ans = '' while n > 0: ans = A[n % 26] + ans if(n % 26 == 0): n = n // 26 - 1 else: n = n // 26 print(ans) if __name__ == '__main__': main() " p02629,s190456071,Accepted,"n = int(input()) out = """" from string import ascii_lowercase from math import ceil while n: out = ascii_lowercase[n % 26 - 1] + out n = (n - 1) // 26 print(out) " p02629,s609316675,Accepted,"n = int(input()) alfabet = 'abcdefghijklmnopqrstuvwxyz' name = '' while True: if n <= 26: name = alfabet[n-1] + name break else: num = n % 26 name = alfabet[num-1] + name if n%26 ==0: n = (n//26) -1 else: n = n//26 print(name)" p02629,s437729239,Accepted,"n = int(input()) s = """" while n > 0: n -= 1 s += chr(97 + (n % 26)) n //= 26 print(s[::-1])" p02629,s910622186,Accepted,"N=int(input()) ans='' for i in range(1,99): if N<=26**i: N-=1 #0インデックス使う方がやりやすい?から−1してるそのままなら下のchr(ord('a'))を一つ前の文字にすればいい for j in range(i): ans+=chr(ord('a')+N%26) N//=26 break else: N-=26**i print(ans[::-1])" p02629,s034533850,Accepted,"N = int(input()) 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) print(num2alpha(N).lower())" p02629,s481912676,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) print(num2alpha(int(input())).lower())" p02629,s227250878,Accepted,"N = int(input()) ans = """" while N > 0: x = (N-1) % 26 ans = chr(ord('a') + x) + ans N = (N-1) // 26 print(ans)" p02629,s633045516,Accepted,"def henkan(num): if num<=26: return chr(64+num) elif num%26==0: return henkan(num//26-1)+chr(90) else: return henkan(num//26)+chr(64+num%26) num=int(input()) ans=henkan(num) print(ans.lower())" p02629,s464051296,Accepted,"A = input() 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) ans =num2alpha(int(A)) print(ans.lower())" p02629,s616240131,Accepted,"n = int(input()) ans = '' while n > 0: n -= 1 a = n % 26 ans += chr(ord('a') + a) n //= 26 print(ans[::-1])" p02629,s105347973,Accepted,"N = int(input()) alphabets = [chr(i) for i in range(97, 97+26)] x = N ans = """" while True: x -= 1 ans = alphabets[x % 26] + ans x //= 26 if x <= 0: break print(ans) " p02629,s918138468,Accepted," alpha = ""abcdefghijklmnopqrstuvwxyz"" N = int(input()) dog_name = """" while N > 0: dog_name += alpha[(N-1)%26] N = (N-1) // 26 dog_name = dog_name[::-1] print(dog_name)" p02629,s952805268,Accepted,"N = int(input()) r=[] r.append(N%26) x=N//26 if N%26==0: x=x-1 while x > 0: t=x%26 r.append(t) x=x//26 if t==0: x=x-1 A=[""z"",""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""] X = A[r[0]] for i in range(len(r)-1): X = X + A[r[i+1]] print(X[::-1])" p02629,s125676695,Accepted,"N = int(input()) N -= 1 for l in range(1, 100): if N >= 26**l: N -= 26**l else: ans = """" for i in range(l): ans += chr(ord('a') + N % 26) N //= 26 print(ans[::-1]) break" p02629,s167392004,Accepted,"def num2alpha(num: int): if num <= 26: return chr(64+num) elif num % 26 == 0: return num2alpha(num//26-1) + chr(90) else: return num2alpha(num//26) + chr(64 + num % 26) N = int(input()) print(num2alpha(N).lower())" p02629,s153300252,Accepted,"alpa = 'zabcdefghijklmnopqrstuvwxy' N = int(input()) # for i in range(703, 730): # print((i-1)//26, i) ans = [] while N >= 27: ans.append(alpa[N%26]) N = (N-1)//26 ans.append(alpa[N%26]) ans.reverse() print(*ans, sep='') " p02629,s641849994,Accepted,"N = int(input()) q, mod = divmod(N, 26) if mod == 0: ans = ""z"" q -= 1 else: ans = chr(mod+96) while q > 0: q, mod = divmod(q, 26) if mod == 0: ans = ""z"" + ans q -= 1 else: ans = chr(mod+96) + ans print(ans) " p02629,s115682197,Accepted,"n = int(input()) ans = '' while n > 0: n -= 1 ans += chr(ord('a') + n % 26) n //= 26 print(ans[::-1])" p02629,s753090460,Accepted,"from collections import deque n = int(input()) stack = deque() ans =[] while n > 0: if 1<= n <= 26: stack.append(n) break mod = n%26 if mod == 0: mod = 26 stack.append(mod) if mod == 26: n = (n//26) - 1 else: n = n//26 while stack: tmp = stack.pop() alp = chr(tmp+96) ans.append(alp) anss = ''.join(ans) print(anss)" p02629,s545883641,Accepted,"# coding: utf-8 # Your code here! n = int(input()) sub = [] while n > 0: if n != 0: n -= 1 sub.append(chr(97 + n % 26)) n = n // 26 for i in range(len(sub)): print(sub[len(sub)-i - 1],end="""") " p02629,s040204537,Accepted,"N = int(input()) s = ""abcdefghijklmnopqrstuvwxyz"" ans = """" n, m = 0, 0 for i in range(1, 1000): m += 26 ** i if N <= m: n = i break for i in range(n): a, b = divmod(N, 26) N = a if b == 0: ans += s[25] N -= 1 else: ans += s[b-1] ans1 = ''.join(list(reversed(ans))) print(ans1)" p02629,s605164052,Accepted,"K = int(input()) 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) print(num2alpha(K).lower())" p02629,s427336054,Accepted," def main(): n = int(input()) ans='' while(n): n -= 1 ans += chr(ord('a') + n%26) n //= 26 print(ans[::-1]) if __name__ == ""__main__"": main()" p02629,s474642178,Accepted,"n = int(input()) digit = 1 while n > 26 ** digit: n -= 26 ** digit digit += 1 ans = [] n -= 1 char = 'abcdefghijklmnopqrstuvwxyz' for i in list(range(digit)): ans.append(char[n % 26]) n -= n%26 n = int(n/26) print(''.join(reversed(ans)))" p02629,s863294250,Accepted,"import math n = (int)(input()) # remain = [] while n > 0: re = n % 26 if re == 0: re = 26 remain.append(re) n = math.floor(n / 26) if re == 26: n -= 1 remain.reverse() # ret = """" for i in remain: ret += chr(i + 96) print(""{}"".format(ret))" p02629,s406348435,Accepted,"n = int(input()) l = [chr(ord('a') + i) for i in range(26)] l = [l.pop()] + l k = [] while n > 0: y = n % 26 k.append(l[y]) n -= 1 n //= 26 print(''.join(reversed(k))) " p02629,s402141671,Accepted,"N=int(input()) A=[] for i in range(15): d=(N-1)%26 e=(N-1)//26 A.append(d+1) N=e if N==0: break A=A[::-1] r='' for i in A: r=r+chr(96+i) print(r)" p02629,s781701855,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])" p02629,s207886448,Accepted,"def num2alpha(num): if num<=26: return chr(64+num) elif num%26==0: return num2alpha(num//26-1)+chr(90) else: return num2alpha(num//26)+chr(64+num%26) N = int(input()) print(num2alpha(N).lower())" p02629,s283510564,Accepted,"N = int(input()) ans = """" while N >= 26: m = N % 26 if m == 0: ans = chr(96 + 26) + ans N //= 26 N -= 1 else: ans = chr(96 + m) + ans N //= 26 # print(ans, N) if N == 0: print(ans) else: print(chr(96 + N) + ans) " p02629,s683731564,Accepted,"import string a=string.ascii_lowercase N=int(input()) ans=[] count=1 n=26 s=0 while N>n: count+=1 s=n n+=26**count N-=s+1 for i in range(count): n=N//26 m=N%26 ans.append(a[m]) N=n Ans=[] for i in range(len(ans)): Ans.append(ans[len(ans)-i-1]) print("""".join(Ans))" p02629,s939841546,Accepted,"def henkan(num): if num <= 26: return chr(64 + num) elif num % 26 == 0: return henkan(num // 26 - 1) + chr(90) else: return henkan(num // 26) + chr(64 + num % 26) n = int(input()) print(str(henkan(n)).lower()) " p02629,s372904369,Accepted,"n = int(input()) lis = [] while n != 0: if n%26 == 0: lis.append(int(0)) n -= 26 n /= 26 else: lis.append(int(n%26)) n -= n%26 n /= 26 alp = [""z"",""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""] st = """" for i in range(len(lis),0,-1): st += alp[lis[i-1]] print(st)" p02629,s057462109,Accepted,"#!/usr/bin/env python3 from collections import deque, Counter from heapq import heappop, heappush from bisect import bisect_right def main(): N = int(input()) a = 'zabcdefghijklmnopqrstuvwxy' ans = '' i = 0 while N > 0: ans += a[N%26] N = (N-1)//26 # print(N) print(ans[::-1]) if __name__ == ""__main__"": main() " p02629,s175401454,Accepted,"import sys q = int(sys.stdin.readline()) chars = [] while True: q, mod = divmod(q-1, 26) chars.append(chr(mod+97)) if q < 1: break chars.reverse() print("""".join(chars)) " p02629,s179991242,Accepted,"N = int(input()) alphas = [ chr(i) for i in range(ord(""a""), ord(""z"")+1)] res = """" while N != 0: ch = N % 26 if ch==0: res += alphas[-1] N = N//26 N -= 1 else: res += alphas[ch-1] N = N//26 print(res[::-1])" p02629,s191154273,Accepted,"n = int(input()) alp = ""abcdefghijklmnopqrstuvwxyz"" name = """" while n > 0: name += alp[n%26-1] n = (n-1)//26 print(name[::-1]) " p02629,s446071281,Accepted,"N = int(input()) BASE_CHR = 96 # chr(97) # a result = """" while True: temp = N % 26 flag = False if temp == 0: result += ""z"" flag = True else: result += chr(BASE_CHR+temp) N = N // 26 if flag: N -= 1 if N == 0 : break print(result[::-1]) " p02629,s977823788,Accepted,"n = int(input()) ans = """" while n > 0 : n -= 1 ans += chr(ord(""a"") + n%26) n = n//26 print(ans[::-1]) " p02629,s372723234,Accepted,"N = int(input()) lst = [] for i in range(1,12): if N <= 26 : lst.append(N % 26) break lst.append(N % 26) if N % 26 == 0: N = N // 26 - 1 else: N = N // 26 chr = 'abcdefghijklmnopqrstuvwxyz' res = """" for j in lst: res = chr[j-1] + res print(res)" p02629,s865234538,Accepted,"s = 'abcdefghijklmnopqrstuvwxyz' n = int(input()) - 1 ans = '' while n > 25: ans += s[(n % 26)] n = n // 26 - 1 ans += s[n%26] print(ans[::-1])" p02629,s872746014,Accepted,"def II(): return int(input()) ans='' N=II() N-=1 i=1 while N-26**i>=0: N-=26**i i+=1#26のべき乗倍を引いてからインクリメント for j in range(i): div,mod=divmod(N,26) ans+=chr(mod+ord('a')) N=div ans=ans[::-1] print(ans)" p02629,s147893585,Accepted,"n = int(input()) i = 1 ans = """" while n != 0: p = n%26 if n%26 != 0 else 26 ans = chr(p + 96) + ans n = n-p n = n//26 i += 1 print(ans)" p02629,s410336376,Accepted,"N = int(input()) ans = '' BASE=26 for i in range(12,-1,-1): tmp = pow(BASE,i) if tmp > N: continue N-=1 ans += chr(ord('a') + N % 26) N //= 26 print(ans[::-1]) " p02629,s363691001,Accepted,"n=int(input()) def alpha2num(alpha): if alpha<=26: return chr(64+alpha) elif alpha%26==0: return alpha2num(alpha//26-1)+chr(90) else: return alpha2num(alpha//26)+chr(64+alpha%26) print(alpha2num(n).lower())" p02629,s451215610,Accepted,"def solve(): 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) print(num2alpha(N).lower()) if __name__ == ""__main__"": N = int(input()) solve()" p02629,s781310049,Accepted,"def resolve(): n = int(input()) ans = '' while n > 0: t = n % 26 t = 26 if t == 0 else t ans = chr(t + 96) + ans n = (n - 1) // 26 print(ans) if 'unittest' not in globals(): resolve()" p02629,s552861177,Accepted,"n = int(input()) amari = 0 name = [] a = ""abcdefghijklmnopqrstuvwxyz"" while n >= 1 : amari = n % 26 if amari == 0: amari = 26 name.insert(0, a[int(amari-1)]) n = (n - amari) / 26 ans = ''.join(name) print(ans)" p02629,s551284962,Accepted,"N = int(input()) ans = '' while N > 0: N -= 1 ans += chr(ord('a') + N % 26) N //= 26 ans = ans[::-1] print(ans)" p02629,s420317583,Accepted,"def resolve(): n = int(input()) name = [] while n > 0: c = n % 26 n //= 26 if c == 0: name.append('z') n -= 1 else: name.append(chr(c + 96)) name.reverse() ans = ''.join(name) print(ans) resolve()" p02629,s491936726,Accepted,"N=int(input()) START = 96 ALP = 26 ans = [] while True: if N <= ALP: ans.append(chr(START + N)) break p = N % ALP if p == 0: ans.append(chr(START + ALP)) else: ans.append(chr(START + p)) if p == 0: N -= 1 N = N // ALP print(''.join(ans[::-1]))" p02629,s823663381,Accepted,"n = int(input()) ans = '' while n > 0: n -= 1 ans += chr(ord('a') + n % 26) n //= 26 print(ans[::-1])" p02629,s253402091,Accepted,"num = int(input()) def conv(num): if num <= 26: return chr(96 + num) elif num % 26 == 0: return conv(num//26-1) + chr(96 + 26) else: return conv(num//26) + chr(96 + num%26) print(conv(num)) " p02629,s657927401,Accepted,"def num2alpha(num): if num<=26: return chr(64+num) elif num%26==0: return num2alpha(num//26-1)+chr(90) else: return num2alpha(num//26)+chr(64+num%26) N =int(input()) NN=num2alpha(N) print(NN.lower()) " p02629,s519658047,Accepted,"def num2alpha(num): if num<=26: return chr(64+num) elif num%26==0: return num2alpha(num//26-1)+chr(90) else: return num2alpha(num//26)+chr(64+num%26) n = int(input()) print(num2alpha(n).lower())" p02629,s619180927,Accepted,"import sys n = int(sys.stdin.read()) n -= 1 s = 'abcdefghijklmnopqrstuvwxyz' write = sys.stdout.write a = [] append = a.append while n >= 26: n, v = divmod(n, 26) n -= 1 append(s[v]) append(s[n]) a.reverse() print(''.join(a)) " p02629,s522088044,Accepted,"n=int(input()) s='' while True: n-=1 s+=chr(n%26+65) if n<=25: break n//=26 n+1 s=''.join(reversed(s)) s=s.lower() print(s)" p02629,s591821853,Accepted,"n = int(input()) ans = [] while n > 0: n -= 1 # これが必要 ans.append(chr(ord('a') + n % 26)) n //= 26 print(''.join(ans[::-1]))" p02629,s341379101,Accepted,"n = int(input()) r = [] while (True): n = n - 1 r.append(chr(n % 26 + ord(""a""))) n = n // 26 if n == 0: break print("""".join(reversed(r)))" p02629,s937543456,Accepted,"def sep(): return map(int,input().strip().split("" "")) def lis(): return list(sep()) n=int(input()) k=n s="""" while(k>0): t=k%26 if t==0: t=26 k-=26 s+=chr(t+96) k//=26 print(s[::-1]) " p02629,s113723447,Accepted,"N = int(input()) result = """" while N >= 1: result = chr(((int(N) -1) % 26) + ord('a')) + result N = (N-1) / 26 print(result)" p02629,s642553441,Accepted,"n = int(input()) m = n keta = 0 for i in range(1, 12): m -= 26 ** i if m <= 0: keta = i break alpha = ""abcdefghijklmnopqrstuvwxyz"" ans = str() for j in range(keta): n -= 1 ans += alpha[n % 26] n //= 26 print(ans[::-1]) " p02629,s162729931,Accepted,"N = int(input()) div = 26 ans = [] while 1: if N % 26 == 0: ans.append(26) N = N // div - 1 else: amari = N % div ans.append(amari) N //= div if N == 0: break ans.reverse() name = [] for i in ans: name.append(chr(i+96)) print(''.join(name)) " p02629,s526108901,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)) " p02629,s533807298,Accepted,"n=int(input()) #x,n=map(int,input().split()) #pl=list(map(int,input().split())) #l=[list(map(int,input().split())) for i in range(n)] res='' #res+=chr(ord(""a"")+n%26-1) #n//=26 while n>0: n-=1 res+=chr(ord(""a"")+n%26) n//=26 print(res[::-1]) " p02629,s430071498,Accepted,"N = int(input()) n = N L = str() alpha = [chr(i) for i in range(97,97+26)] i = 0 while n > 0: i += 1 n -= 26 ** i N -= 26 * (26 ** (i - 1) - 1) // 25 while i > 0: code = (N - 1) // (26 ** (i - 1)) L += alpha[code] N -= code * (26 ** (i -1)) i -= 1 print(L)" p02629,s778277553,Accepted,"n = int(input()) l = 1 while n-26**l > 0: n -= 26**l l += 1 else: n -= 1 res = """" for i in range(l): n,r = divmod(n,26) res += chr(ord(""a"")+r) ans = res[::-1] print(ans)" p02629,s510309116,Accepted,"import math def main(): N = int(input()) lowercase = 'abcdefghijklmnopqrstuvwxyz' ans = '' for i in range(len(str(N))): j = N % 26 if N == 0: break if j == 0: N = N // 26 - 1 else: N = N // 26 ans = lowercase[j-1] + ans # print(N, j-1, ans) print(ans) if __name__ == '__main__': main()" p02629,s488131357,Accepted,"n=int(input()) ans = '' while n>0: n = n-1 ans += chr(ord('a') + (n)% 26) n//=26 ans = ans[::-1] print(ans)" p02629,s257864108,Accepted,"N = int(input()) s = list(""abcdefghijklmnopqrstuvwxyz"") ans=[] while 1<=N: N -= 1 #### ans.insert(0, s[N%26]) N //= 26 ans="""".join(ans) print(ans)" p02629,s868290504,Accepted,"N=int(input()) l = int(N**(1/26)) name = '' while N >0: N -= 1 r = N%26 N = N//26 name += chr(ord('a')+r) print(name[::-1])" p02629,s411714265,Accepted,"n = int(input()) 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) print(num2alpha(n).lower())" p02629,s318108286,Accepted,"n=int(input()) keta=[26] t=2 while keta[-1]<10**15+1: keta.append(keta[-1]+26**t) t+=1 #print(keta) import bisect,sys nagasa=bisect.bisect_left(keta,n)+1 #print(nagasa) alpha='abcdefghijklmnopqrstuvwxyza' if nagasa==1: print(alpha[n-1]) sys.exit() n-=keta[nagasa-2] n-=1 ans='' L=[] while n>0: L.append(n%26) n//=26 while len(L) 26**i: N = N - 26**i i += 1 N -= 1 shinsu = deque([]) for j in range(i): shinsu.appendleft(N%26) N //= 26 shinsu = list(map(add, shinsu)) ans = list(map(chr, shinsu)) print(''.join(ans))" p02629,s094691928,Accepted,"N = int(input()) alph = {key + 1: val for key, val in enumerate('abcdefghijklmnopqrstuvwxyz')} alph[0] = 'z' answer = '' while N >= 1: answer = alph[N % 26] + answer if N == 26: break N = (N - 1) // 26 print(answer)" p02629,s290085934,Accepted,"n = int(input()) kouho = [] alphabet = [] for i in range(26): alphabet.append(chr(ord(""a"") + i)) ans = [] while n > 0: p = (n) % 26 q = n // 26 if p == 0: p += 26 q -= 1 ans.append(alphabet[p - 1]) n = q print(*ans[::-1], sep="""") " p02629,s392089836,Accepted,"n=int(input()) a=[] while n: a+=n%26, n//=26 a=a[::-1] for i in range(len(a)-1,0,-1): if a[i]<1: a[i]+=26 a[i-1]-=1 print(''.join(chr(c+96)for c in a[not a[0]:]))" p02629,s211929572,Accepted,"n=int(input()) 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) print(num2alpha(n).lower())" p02629,s188868838,Accepted,"n=int(input()) p=1000000000000001 n2a = lambda c: chr(c+65).lower() # 何桁か計算 cnt=0 keta=0 while cnt+pow(26,keta)<=n: cnt+=pow(26,keta) keta+=1 #print(cnt,keta) n-=cnt # cnt桁のn番目の数字 ans=['a']*keta for i in range(keta): ans[-i-1]=n2a(n%26) n//=26 #ans.reverse() print(''.join(ans)) " p02629,s245706205,Accepted,"n = int(input()) alph = ""abcdefghijklmnopqrstuvwxyz"" ans = """" while n >= 1: n -= 1 div, mod = divmod(n, 26) ans += alph[mod] n = div print(ans[::-1])" p02629,s575038998,Accepted,"#c M = int(input()) s='' a=['z','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'] while M>0: s+=a[M%26] if M%26==0: M=int((M-1)/26) else: M=int(M/26) print(s[::-1])" p02629,s923727663,Accepted,"n = int(input()) s = """" while n > 0: n -= 1 s += chr( n % 26 + ord('a') ) n //= 26 print(s[::-1]) " p02629,s555896243,Accepted,"N=int(input()) name="""" while N>0: N-=1 name=chr(ord(""a"")+N%26)+name N//=26 print(name)" p02629,s207898947,Accepted,"from collections import defaultdict it = lambda: list(map(int, input().strip().split())) INF = float('inf') if __name__ == '__main__': N = int(input()) ans = '' while N: if N % 26 == 0: ans = chr(ord('a') + 25) + ans N //= 26 N -= 1 else: ans = chr(ord('a') + N % 26 - 1) + ans N //= 26 print(ans) " p02629,s386803475,Accepted,"def num2alpha(num): if num<=26: return chr(64+num) elif num%26==0: return num2alpha(num//26-1)+chr(90) else: return num2alpha(num//26)+chr(64+num%26) n=int(input()) print(num2alpha(n).lower())" p02629,s117506065,Accepted,"n=int(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"",""z""] x=n b=1 z=a[x%26-1] x=x-26 while x>0: i=(x-1)//(26**b) y=i%26 z+=a[y] b+=1 x=x-(26**b) t=z[::-1] print(t) " p02629,s687991925,Accepted,"n = int(input()) a = [] while n > 0: n -= 1 a.append(n%26) n = n // 26 ans = """" for i in range(len(a)): ans += chr(ord(""a"")+a[(-1)*(i+1)]) print(ans)" p02629,s589791671,Accepted,"import math n = int(input()) name = """" while n >= 1 / 26: div = n % 26 if div == 0: div = 26 name = chr(div + 64) + name n = math.floor((n - div) / 26) print(name.lower())" p02629,s260854752,Accepted,"N = int(input()) - 1 rst = '' for i in range(1, 10 ** 15): if N >= 26 ** i: N -= 26 ** i continue for j in range(i): rst += chr(ord('a') + N % 26) N //= 26 print(rst[::-1]) break" p02629,s789740994,Accepted,"import string def main(): N = int(input()) az = string.ascii_lowercase d = 26 ans = """" while(N > 0): m = (N-1) % d ans = az[m] + ans N = (N-1) // d print(ans) if __name__ == ""__main__"": main()" p02629,s881877794,Accepted,"ini = lambda : int(input()) inm = lambda : map(int,input().split()) inl = lambda : list(map(int,input().split())) gcd = lambda x,y : gcd(y,x%y) if x%y else y n = ini() b = '' while n > 0: n -= 1 b += chr(ord('a') + n%26) n = n//26 print(b[::-1]) " p02629,s608265339,Accepted,"import math N_MAX = 1 ** 15 letters=list(""abcdefghijklmnopqrstuvwxyz"") A_TO_Z = len(letters) N = int(input()) temp = N cnt = 1 while temp - A_TO_Z ** cnt > 0: temp -= A_TO_Z ** cnt cnt += 1 r = [0] * cnt q = temp - 1 while q > 0: r[cnt-1] = q % A_TO_Z cnt -= 1 q = q // A_TO_Z for i in r: print(letters[i],end="""") " p02629,s878572573,Accepted,"import sys INF = 1 << 60 MOD = 10**9 + 7 # 998244353 sys.setrecursionlimit(2147483647) input = lambda:sys.stdin.readline().rstrip() def resolve(): n = int(input()) - 1 res = [] while 1: res.append(chr(ord('a') + n % 26)) n = n // 26 - 1 if n == -1: break res.reverse() print(''.join(res)) resolve()" p02629,s460217139,Accepted,"def main(): N = int(input()) a = ord('a') ans = '' while N!=0: N -= 1 ans = chr(a + N % 26) + ans N //= 26 print(ans) main()" p02629,s371962507,Accepted,"n=int(input()) 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) print(num2alpha(n).lower()) " p02629,s598220343,Accepted,"N = int(input()) ans = '' while N != 0: N -= 1 ans += chr(ord('a') + N%26) N //= 26 print(ans[::-1])" p02629,s448864806,Accepted,"import sys import math input = sys.stdin.readline sys.setrecursionlimit(10 ** 5) def main(): N = int(input()) name = """" while N: N, mod = divmod(N, 26) if mod ==0: name +=""z"" N-=1 else: name += chr(96+mod) print(name[::-1]) if __name__ == ""__main__"": main()" p02629,s055233442,Accepted,"import sys import os import itertools import numpy as np from collections import deque def main(): if os.getenv(""ENV"")=='LOCAL': sys.stdin = open(os.path.dirname(__file__)+'/input.txt', 'r') N=int(input()) name=[] while N > 0: N-=1 name.append(N%26) N//=26 # print(len(alphabet)) # print(name) ans="""" for n in name: ans+=chr(ord('a')+n) print(ans[::-1]) if __name__ == '__main__': main() " p02629,s472530887,Accepted,"n = int(input())-1 y = 26 idx = [] c = [chr(i + ord(""a"")) for i in range(26)] while True: idx.append(n % y) n //= y if n <= 0: break n -= 1 idx.reverse() ans = [] for i in idx: ans.append(c[i]) print("""".join(ans)) " p02629,s013567264,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 = N // 26 break else: N -= 26 ** i print(ans[::-1])" p02629,s622760663,Accepted,"num=int(input()) 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) print(num2alpha(num).lower())" p02629,s822308356,Accepted,"n=int(input()) L=[chr(i) for i in range(97, 97+26)] temp=26 count=1 while True: if n<=temp: break else: count+=1 temp+=26**count unthink=temp-26**count think=n-unthink ans='' think-=1 for i in range(count)[::-1]: now=think//(26**i) ans+=L[now] think=think%(26**i) print(ans) " p02629,s007457761,Accepted,"#(17+) n = int(input()) t = [] while n > 0: n -= 1 t.append(chr(n % 26 + ord(""a""))) n //= 26 print("""".join(t[::-1]))" p02629,s871039204,Accepted,"N = int(input()) 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) ans2 = num2alpha(N) print(ans2.lower())" p02629,s695939869,Accepted,"arphaList = 'abcdefghijklmnopqrstuvwxyz' result = """" N = int(input()) while N != 0: arpha = arphaList[(N + 25) % 26] result += arpha N = N // 26 if arpha == ""z"": N -= 1 print(result[::-1])" p02629,s434665741,Accepted,"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) n = int(input()) print(num2alpha(n)) " p02629,s797338713,Accepted,"from string import ascii_lowercase as alph N = int(input()) A = list(alph) ans = [] def sol(n): global ans q, r = divmod(n, 26) ans.append(A[r]) if q > 0: sol(q - 1) sol(N - 1) print(''.join(ans[::-1])) " p02629,s965431678,Accepted,"N = int(input()) arr = [] while 0 < N: N -= 1 arr.append(N % 26) N //= 26 ans = '' for a in reversed(arr): ans += chr(ord('a')+a) print(ans)" p02629,s458508805,Accepted,"n = int(input()) abc = ['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'] res = [] ans = '' while n: res.append((n-1)%26) n = (n-1)//26 #print(res[::-1]) for i in range(len(res)): ans += abc[res[i]] print(ans[::-1])" p02629,s011064706,Accepted,"n = int(input()) cnt = 0 digits = 0 for i in range(1, 12): cnt += pow(26, i) if n <= cnt: digits = i break k = n - cnt + pow(26, digits) - 1 #digits桁の中で何番目か alf = 'abcdefghijklmnopqrstuvwxyz' ans = '' for i in range(digits): q = k // 26 r = k%26 ans = alf[r] + ans k = q print(ans)" p02629,s643803254,Accepted,"num = int(input()) 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) print(num2alpha(num).lower())" p02629,s820864942,Accepted,"borders = [] n = 0 for i in range(1, 12): n += 26 ** i borders.append(n) borders.sort(reverse=True) chars = [chr(97 + i) for i in range(26)] N = n = int(open(0).read()) keta = {} for i, b in enumerate(borders): j = 0 k = 26 ** (11 - i) while n > b: n -= k j += 1 if j > 0: keta[11 - i] = chars[j - 1] if n > 0: keta[0] = chars[n - 1] ret = [keta[i] if i in keta else '_' for i in range(12, -1, -1)] print("""".join(ret[12 - max(keta.keys()):]))" p02629,s830114263,Accepted,"def toString(n): if n <= 26: return chr(64 + n) elif n % 26 == 0: return toString(n // 26-1) + chr(90) else: return toString(n // 26) + chr(64 + n % 26) N = int(input()) Alpha = toString(N) alpha = Alpha.lower() print(alpha) " p02629,s911410299,Accepted,"n = int(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'] b = '' def Base_10_to_n(X, n): X_dumy = X out = '' while X_dumy>0: out = a[X_dumy%n-1]+out if a[X_dumy%n-1] == 'z': X_dumy -= 26 X_dumy = X_dumy//n return out z = Base_10_to_n(n, 26) print(z)" p02629,s695603442,Accepted,"N=int(input()) alp=[""a"",""b"",""c"",""d"",""e"",""f"",""g"",""h"",""i"", ""j"",""k"",""l"",""m"",""n"",""o"",""p"",""q"",""r"", ""s"",""t"",""u"",""v"",""w"",""x"",""y"",""z""] S="""" while N>0: Q=N%26 if Q==0: N=N//26-1 else: N=N//26 S+=alp[Q-1] print(S[::-1])" p02629,s689193962,Accepted,"def alpha(n): if n<=26: return chr(96+n) elif n%26==0: return alpha(n//26-1)+chr(122) else: return alpha(n//26)+chr(96+n%26) n=int(input()) print(alpha(n))" p02629,s063096285,Accepted,"n = int(input()) m = n a = 1 count = 1 while a <= n: if a*26 >= m: break a*= 26 m -= a count+=1 m -= 1 ans = [] for i in range(count): ans.append(m%26) m //= 26 ansa = """" for i in ans: ansa += chr(97+i) print(ansa[::-1])" p02629,s234704194,Accepted,"import numpy as np N=int(input()) N-=1 s ='abcdefghijklmnopqrstuvwxyz' b = [] while True: a = N % 26 b.append(s[a]) N = N // 26 if N == 0: break N -= 1 for i in range(len(b)): a = len(b)-i-1 print(b[a], end='')" p02629,s995951682,Wrong Answer,"n = int(input()) c = ord(""a"") l = """" while not n < 26: b = n//26 a = n-26*b n = b l = l+chr(c+a-1) l = l+chr(c+n-1) print(l[::-1]) " p02629,s987186307,Wrong Answer,"alphabet = [chr(i) for i in range(97, 97+26)] n = int(input()) keta = 0 while True: if n <= 26 ** keta: break keta += 1 ans = '' for i in range(keta-1,-1,-1): num = 1 while (num+1) * 26**(i) <= n: num+= 1 # この時点でnumは、26**iをいくつまで含むことができるか?という数 ans += alphabet[num-1] n -= num * 26**i print(ans) " p02629,s110268926,Wrong Answer,"N = int(input()) ans = [] while N != 0: sup = N % 26 ans.append(chr(96 + sup)) N = N // 26 ans = ''.join(reversed(ans)) print(ans) " p02629,s090353868,Wrong Answer,"n = int(input()) a = 26 c = 1 res ="""" t = """" num2alpha = lambda c: chr(c+64) while True: if n <= a: break a *= 26 c += 1 for i in range(c): t = num2alpha(int(n % 26)) if t == ""@"": t = ""z"" res = t + res n = n / 26 print(str.lower(res))" p02629,s035600154,Wrong Answer,"n = int(input())-1 a = ""abcdefghijklmnopqrstuvwxyz"" s = a[n % 26] n = n//26 while n: s = s + a[n % 26-1] n = n // 26 print(s[::-1])" p02629,s194099414,Wrong Answer,"def func(tmp): print(tmp) ans = '' sub_ans = tmp/26 if sub_ans >0: ans += func(int(sub_ans)) ans += chr(96 + int(tmp)%26) return ans tmp = int(input()) print(func(tmp)[1:])" p02629,s381553726,Wrong Answer,"alp = [chr(i) for i in range(97, 97+26)] N = int(input()) q = N s = """" while True: q,m = divmod(q,26) s = alp[m - 1] + s if q == 0: break print(s) " p02629,s855745262,Wrong Answer,"from string import ascii_lowercase N = int(input()) def base(n): l = [] p = int(n / 26) q = n % 26 - 1 if p != 0: l = [*l, *base(p)] return [*l, ascii_lowercase[q]] print(''.join(base(N))) " p02629,s997764067,Wrong Answer,"n = 123456789 m = {} for i in range(0,26): m[i] = chr(97+i) ans = '' while 1: n -= 1 x = n // 26 y = n % 26 ans = m[y] + ans n = x if n == 0: break print(ans) " p02629,s001531719,Wrong Answer,"N = int(input()) def base10to(n, b): if n // b: return base10to(n // b - 1, b) + ',' + str(n % b) return str(n % b) res_26 = base10to(N - 1, 26) print(res_26) res = [] for s in res_26.split(','): res.append(chr(97 + int(s))) print(''.join(res)) " p02629,s214437756,Wrong Answer,"n=int(input()) cnt=1##文字数 tmp=26 while n>tmp: cnt+=1 tmp+=26**cnt num=n-(tmp//26) alp=[""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<=26: ans=alp[n-1] print(ans) else: ans=[""0""]*cnt for i in range(cnt): j=num%26 ans[-i-1]=alp[j] num//=26 print(ans)" p02629,s873418719,Wrong Answer,"def main(): n = int(input()) alp = ""zabcdefghijklmnopqrstuvwxy"" res = """" for i in range(1,100): if(n<=26**i): for j in range(i): res+=chr(ord(""a"")+n%26) n//=26 break else: n-=26**i print(res[::-1]) if __name__ == '__main__': main() " p02629,s113190336,Wrong Answer,"import sys def input(): return sys.stdin.readline().strip() def mapint(): return map(int, input().split()) sys.setrecursionlimit(10**9) N = int(input()) ans = [] 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'] while N: i = N%26 ans.append(char[i-1]) N //= 26 print(''.join(ans[::-1]))" p02629,s706271329,Wrong Answer,"N = int(input()) ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz' ans = [] c = 0 while N>0: n = N%26 ans.append(n) N //= 26 ans.reverse() o = [] for a in ans: s = ascii_lowercase[a-1] o.append(s) print(''.join(o))" 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()" p02629,s566770064,Wrong Answer,"# coding: utf-8 import sys from math import log stdin = sys.stdin ns = lambda: stdin.readline().rstrip() # ignore trailing spaces ni = lambda: int(ns()) na = lambda: list(map(int, stdin.readline().split())) def main(): ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz' n = ni() m = int(log(n,26)) ans = '' for i in range(m+1): ans += ascii_lowercase[n%26-1] n //= 26 print(ans[::-1]) return if __name__ == '__main__': main()" p02629,s736695429,Wrong Answer," N = int(input()) list_moji = [] n = int(N/26) m = N%26 list_moji.append(m) while n != 0: tmp = n n = int(tmp/26) m = tmp%26 if n == 1: list_moji.append(0) list_moji = [0]*len(list_moji) break else: list_moji.append(m) string = """" for i in reversed(list_moji): if i != 0: string += chr(96 + i) else: string += chr(96 + 26) print(string)" p02629,s761123066,Wrong Answer,"n = int(input()) alphabets = [chr(i) for i in range(ord('a'), ord('a') + 26)] x = 0 for i in range(1, 100): if n <= 26**i: x = i break ans = '' for i in range(x, 0, -1): ans = alphabets[n % 26 - 1] + ans n = n // 26 print(ans) " p02629,s198690058,Wrong Answer,"N = int(input()) tmp_n = N ans = [] while True: s, r = divmod(tmp_n, 26) if r == 0: r = 26 ans.append(chr(r+96)) tmp_n = s if s == 0: break print("""".join(ans[::-1])) " p02629,s099755318,Wrong Answer,"N = int(input()) def num10to26(num): if num<=26: return chr(64+num) elif num%26==0: return num10to26(num//26-1)+chr(90) else: return num10to26(num//26)+chr(64+num%26) print(num10to26(N))" p02629,s731812260,Wrong Answer,"import sys import numpy as np import math from collections import deque from functools import reduce n = int(input()) az = ""abcdefghijklmnopqrstuvwxyz"" cnt = 12 ret = [] ama = n % 26 na = n for i in range(12, 0, -1): if 26**(i-1) > n: continue sho = na // (26**i) if sho > 0: ret.append(az[sho-1]) else: ret.append('z') na -= sho * (26**i) if ama > 0: ret.append(az[ama-1]) if (ret[0] == 'z'): del ret[0] re = """".join(ret) print(re) " p02629,s892627173,Wrong Answer,"n = int(input()) if n==1: print('a') i = 0 buf = 0 while 26**i+buf<=n: buf += 26**i i += 1 ans = '' for j in range(i): ans += chr(ord('a')+(n//(26**j)-1)%26) n -= 26**j print(ans[::-1]) " p02629,s452249176,Wrong Answer,"in1 = input() ind = int(in1) alpha = ""abcdefghijklmnopqrstuvwxyz"" twosix = [] while True: if (ind < 26): twosix.append(ind) break twosix.append(ind % 26) ind //= 26 #print(twosix) ans = """" twosix.reverse() #print(twosix) for i in twosix: ans += alpha[i-1] print(ans) " p02629,s239146284,Wrong Answer,"N=int(input()) c=[] alpha=['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'] while N>=26: n=N%26 N//=26 c.insert(0,alpha[n-1]) if N!=0: c.insert(0,alpha[N-1]) c=''.join(c) print(c) " p02629,s468753552,Wrong Answer,"import string N = int(input()) S = string.ascii_lowercase ans = '' if N <= 26: ans = S[N - 1] while True: N, b = divmod(N, 26) ans = S[b - 1] + ans if b == 0: N -= 1 if N <= 26: ans = S[N - 1] + ans break print(ans)" p02629,s248831268,Wrong Answer,"n = int(input()) b = 26 ans = [] for i in range(1,99): if n <= b: n -= 1 for j in range(i-1): ans.append(chr(97 + n % b)) n //= b break else: n -= b ** i for k in range(len(ans)): print(ans[-(k+1)],end="""")" p02629,s448827246,Wrong Answer,"def xxx(n): alpha = ""abcdefghijklmnopqrstuvwxyz"" ans = """" i = 1 while True: if n <= 26 ** i: n -= 1 while n > 0: ans = alpha[n%26] + ans n //= 26 return ans else: n -= 26 ** i i += 1 N = int(input()) print(xxx(N))" p02629,s140539417,Wrong Answer,"s='0abcdefghijklmnopqrstuvwxyz' n=int(input()) def number_of_alphabets(n): i=1 g=0 while g26: o=26 name+=s[o] n=n-o*26**i print(name)" p02629,s836221456,Wrong Answer,"import math N = int(input()) a = [chr(i) for i in range(97, 97+26)] data = '' count = 1 data = f'{data}{a[N % 26-1]}' if int(N/26) == 0: print(data[0]) exit(0) for i in range(int(math.log(N, 26))): data = f'{a[round((N/26**count) % 26-1)]}{data}' N -= 26**count count += 1 print(data) exit(0) " p02629,s724479632,Wrong Answer,"from string import ascii_lowercase N = int(input()) s = list() while N > 0: m = N%26 - 1 s.append(ascii_lowercase[m]) N = int(N/26) s.reverse() s = ''.join(s) print(s)" p02629,s024153237,Wrong Answer,"N=int(input()) N = 27 ans = """" def n(N): ans= """" for i in range(N): if N%26 ==0: ans = ""z"" +ans N -= 1 else: ans = chr(64+ N%26) +ans if N <= 26: break N = N // 26 return ans for i in range(1,10000): print(n(i)) print(ans.lower())" p02629,s564730096,Wrong Answer,"n = int(input()) final = [] while 1: q = n//26 r = n%26 final.append(chr(ord('a')+(r-1))) n = q if q == 0: break ans='' for i in final: ans+=i print(ans[::-1]) " p02629,s733568299,Wrong Answer,"MAX = 200 def Excel(n): string = [""\0""] * MAX i = 0 while n > 0: rem = n % 26 if rem == 0: string[i] = 'z' i += 1 n = (n //26) - 1 else: string[i] = chr(int(rem - 1 + 97)) i += 1 n = n // 26 string[i] = '\0' string = string[::-1] return """".join(string) n=int(input()) print(Excel(n)) " p02629,s363630330,Wrong Answer,"n = int(input()) word_list = [""z"",""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 = [] while n>0: ans.append(word_list[n%26]) if n%26 == 0: break n = n//26 ans.reverse() print(''.join(ans))" p02629,s204320440,Wrong Answer,"n = int(input()) alphabet = [chr(i) for i in range(97, 123)] ans = list() for i in reversed(range(12)): if x := n // (26 ** i): ans.append(alphabet[x - 1]) n %= 26 ** i print("""".join(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())" p02629,s450509415,Wrong Answer,"import string N = int(input()) char_list = string.ascii_lowercase char_list = char_list[:-1] char_list = 'z' + char_list tmp = 0 count = 0 ans = '' while 1: before = tmp count += 1 tmp += 26**count if before < N <= tmp: tmp = N while 1: ans = char_list[tmp%26] + ans tmp = tmp // 26 count -= 1 if count == 0: break break else: pass print(ans)" p02629,s609815872,Wrong Answer,"n=int(input()) ans="""" while n!=0: ans+=chr(96+n%26) n//=26 print(ans[::-1])" p02629,s737414481,Wrong Answer,"n= int(input()) alp=list([ ""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"" ]) answer="""" while True: answer=alp[(n-1)%26]+answer if n<=26: break n=n//26 print(answer)" p02629,s487464042,Wrong Answer,"N = int(input()) keta = 1 while (N-1)//26**keta >= 1: keta += 1 for i in range(1, keta): N -= 26**i alph = 'abcdefghijklmnopqrstuvwxyz' ans = [] ans.append(alph[(N%26)-1]) for i in range(1, keta): num = (N-1)//(26**i) if num ==0: ans.append(""a"") else: ans.append(alph[(num%26)]) ans.reverse() print("""".join(ans))" p02629,s918980751,Wrong Answer,"N = int(input()) s = '' for i in reversed(range(27)): if 26 ** i > N: continue M = N // (26 ** i) s += chr(M + 96) N -= M * (26 ** i) print(s)" p02629,s413927879,Wrong Answer,"n = int(input()) pVal = 1 idx = 0 res = [] total = 0 while(26 * pVal + total < n): n -= pVal total += 26 * pVal pVal *= 26 res.append('a') res.append('a') n -= pVal while(n > 0): put = n//pVal if(put > 0): res[idx] = chr(put + 97) idx += 1 n -= put * pVal pVal /= 26 pVal = int(pVal) print(str.join('', res)) " p02629,s690131765,Wrong Answer,"n= int(input()) azlist = list('abcdefghijklmnopqrstuvwxyz') ans = '' def aaa(n): for i in range(1,10**9): if (n-26**i)<=0: return n else: n = n-26**i n = aaa(n) for i in range(1,10**9): ans = azlist[n%26 - 1] + ans if n//26 == 0 or (n//26 == 1 and n%26==0 ): break else: n = n//26 print(ans)" p02629,s563114352,Wrong Answer,"X=int(input()) n=26 a=[] X_dumy = X out = '' while X_dumy>0: out = str(X_dumy%n) X_dumy = int(X_dumy/n) a.append(out) l = list('abcdefghijklmnopqrstuvwxyz') N=0 for x in a: a[N]=l[int(a[N])-1] N=N+1 a.reverse() pg = ''.join(a) print(pg)" p02629,s705691109,Wrong Answer,"N = int(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'] name = '' while N != 0: name += alphabet[(N-1) % 26] if N == 26: break N //= 26 print(name[::-1])" p02629,s943726102,Wrong Answer,"n = int( input() ) alphabet = [ '' ] + [chr(i) for i in range(97, 97+26)] conv = [] k = n while k > 0: conv.append( k % 26 ) k = k // 26 ans = [] for c in conv: ans.append( alphabet[ c ] ) print( """".join( reversed( ans ) ) )" p02629,s408731659,Wrong Answer,"n = int(input()) ans = '' while not n == 0: ans += chr(ord('a') + n % 26 - 1) n //= 26 print(ans[::-1])" p02629,s084873644,Wrong Answer,"N = int(input()) rslt = """" sub = 1 while N >= 0: rslt = chr((N - 1) % 26 + ord('a')) + rslt sub *= 26 N -= sub + (N % 26 - 1) print(rslt)" p02629,s666644968,Wrong Answer,"#!/usr/bin/python3 import sys input = lambda: sys.stdin.readline().strip() n = int(input()) - 1 if n == 0: print('a') else: ans = [] while n > 0: ans.append(n % 26) n //= 26 print(*reversed([chr(ord('a') + x) if i == 0 else ('z' if x == 0 else chr(ord('a') + x - 1)) for i, x in enumerate(ans)]), sep='')" p02629,s794173225,Wrong Answer,"a=int(input()) list=[] for i in range(11,1,-1): b = a // (26**i) a = a - b*(26**i) list.append(b) for i,k in zip(list,range(len(list))): list[k]=chr(i+96) result=''.join(list) print(result.replace(""`"",''))" p02629,s380177074,Wrong Answer,"N = int(input()) ans = '' while(N > 0): _i = (N-1) % 26 ans = chr(ord('a') + _i) + ans N //= 26 print(ans)" p02629,s600233377,Wrong Answer,"n = int(input()) p = 0 result = [] while True: p = n % 26 n //= 26 result.append(p) if n == 0: break string = 'abcdefghijklmnopqrstuvwxyz' ans = [] for i in range(len(result)-1,-1, -1): index = result[i]-1 ans.append(string[index:index+1]) print (''.join(map(str, 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)) " p02629,s749409032,Wrong Answer,"def main(): n = int(input()) 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) P = list(map(int, Base_10_to_n(n, 26).split())) ans = [0] * len(P) for i, p in enumerate(P): ans[i] = chr(96 + p) print(''.join(ans)) if __name__ == '__main__': main() " p02629,s740717385,Wrong Answer,"import string lower = string.ascii_lowercase N_org = int(input()) N_order = 0 N=N_org while N > 0: if N //len(lower) >=1: N = N//len(lower) N_order = N_order+1 else: break; S = """" N= N_org for i in range(N_order,0,-1): syou = N//(len(lower)**i) moji = lower[syou-1] N = N%(len(lower)**i) S = S + moji S = S+ lower[N%len(lower)-1] print(S)" p02629,s434558324,Wrong Answer,"N= int(input()) if N ==0: print(""a"") else: mylist =[] while N >26: b = N%26 mylist.append(b-1) N = N//26 if N ==26: mylist.append(0) else: mylist.append(N-1) num = [""a"",""b"",""c"",""d"",""e"",""f"",""g"",""h"",""i"",""j"",""k"",""l"",""m"",""n"",""o"",""p"",""q"",""r"",""s"",""t"",""u"",""v"",""w"",""x"",""y"",""z""] ans = [] for i in reversed(mylist): ans.append(num[i]) print(''.join(ans))" p02629,s335768561,Wrong Answer,"n = int(input()) l = [0] ans = [] a = 0 cur = 1 while a < 1000000000000001: a += 26**cur cur += 1 l.append(a) l = list(reversed(l)) for i in range(len(l)-1): if l[i] >= n: ans.append(0) else: div = (n-1)//(l[i]-l[i+1]) n = n-div*(l[i]-l[i+1]) ans.append(div) ans.append(n) ans =list(map(lambda x:x+96, ans)) for i in range(len(ans)): if ans[i] > 96: ans2 = ans[i:] break ans2 = """".join([chr(i) for i in ans2]) print(ans2)" p02629,s210131410,Wrong Answer,"N = int(input()) x = [] while (N == 0): N, i = divmod(N, 26) x = i + 96 print(x)" p02629,s959671852,Wrong Answer,"N = int(input()) alphabets = [chr(i) for i in range(97, 97+26)] E = [] E.append( N%26 ) while N/26 > 1 : N = int(N/26) E.append( N%26 ) w = [] for ee in E: w.append(alphabets[ee-1]) print("""".join(list(reversed(w)))) " p02629,s850508230,Wrong Answer,"n=int(input()) l=list(""abcdefghijklmnopqrstuvwxyz"") name="""" while n>=1: name=(l[n%26-1])+name n//=26 print(name)" p02629,s531017489,Wrong Answer,"def num2alpha(num): if num<=26: return chr(64+num) elif num%26==0: return num2alpha(num//26-1)+chr(90) else: return num2alpha(num//26)+chr(64+num%26) n = int(input()) ans = num2alpha(n) print(ans)" p02629,s989180488,Wrong Answer,"n = int(input()) s = [chr(ord(""a"")+i) for i in range(26)] num, i = 1, 0 while n - num > 0: num = num*27 i += 1 ans = """" while i > 0: tmp = 0 for j in range(1, 27): if n - j*pow(26, i-1) < 0: break tmp = j ans += s[tmp- 1] n -= tmp*pow(26, i-1) i -= 1 print(ans)" p02629,s946605528,Wrong Answer,"n = int(input()) c = ord(""a"") l = """" while n > 26: a = n % 26 n = (n-a)//26 l = l+chr(c+a-1) l = l+chr(c+n-1) print(l[::-1]) " p02629,s454560156,Wrong Answer,"ans = """" N = int(input()) for i in range(10000): tmp = N%26 ans += chr(96+tmp) N //= 26 if N <= 0: break print(ans[::-1]) " p02629,s937110639,Wrong Answer,"import numpy as np n = int(input()) li = [chr(i) for i in range(97, 97 + 26)] lili = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q'] ans = [] zzz = list(np.base_repr(n, base=26)) for i in zzz: xxx = lili.index(i) ans.append(li[xxx-1]) print(''.join(ans)) " p02629,s352389952,Wrong Answer,"N=int(input()) alp=[""a"",""b"",""c"",""d"",""e"",""f"",""g"",""h"",""i"", ""j"",""k"",""l"",""m"",""n"",""o"",""p"",""q"",""r"", ""s"",""t"",""u"",""v"",""w"",""x"",""y"",""z""] S="""" while N>0: Q=N%26 N=N//26 S+=alp[Q-1] print(S[::-1])" p02629,s728081879,Wrong Answer,"import string b = string.ascii_letters a = int(input()) c = [] while(a!=0): c.append(b[a%26-1]) a//=26 print(''.join(c))" p02629,s696140608,Wrong Answer,"N = int(input()) fin = False ans = '' t=1 while fin == False: print(t) num = (N-1)%26 print(chr(num+97)) ans=chr(num+97)+ans if N<=26: fin = True t+=1 N=(N-26^t)//26+1 print(ans)" p02629,s379223089,Wrong Answer,"# import statistics # Pythonのみ # import string import sys sys.setrecursionlimit(10 ** 5 + 10) def input(): return sys.stdin.readline().strip() def resolve(): n=int(input()) alp=list(chr(ord('a')+i) for i in range(26)) ans=[] while n>0: a,b=divmod(n,26) n//=26 ans.append(alp[b]) ans2='' for i in ans[::-1]: ans2+=chr(ord(i)-1) print(ans2.replace('a`','z')) resolve()" p02629,s171459993,Wrong Answer,"N=int(input()) lista=[""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""] amari=[] ans="""" while N!=0: (x,y)=divmod(N,26) amari.append(y) N=x for i in amari[::-1]: ans+=lista[i-1] print(ans)" 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)" p02629,s640892828,Wrong Answer,"n=int(input()) ans='' while n>0: ans+=chr(ord('a')+n%26-1) n=n//26 print(ans[::-1])" p02629,s928441770,Wrong Answer,"import sys read = sys.stdin.read readline = sys.stdin.buffer.readline INF = float('inf') def main(): N = int(readline()) alphabet = 'zabcdefghijklmnopqrstuvwxyz' A = [] ans = '' while N>0: ans = alphabet[N%26] + ans N//=26 print(ans) if __name__ == '__main__': main() " p02629,s219282339,Wrong Answer,"ans = [] n = int(input()) while(n!=0): x = n % 26 n //= 26 ans.append(chr(97+x-1)) ans.reverse() print(''.join(ans))" p02629,s826292897,Wrong Answer,"N = int(input()) alp = ""zabcdefghijklmnopqrstuvwxy"" L = """" while(True): ind = int(N%26) N = (N-ind)/26 L = alp[ind] + L if (N==0): break print(L)" p02629,s855915202,Wrong Answer,"import sys sys.setrecursionlimit(10 ** 8) ini = lambda: int(sys.stdin.readline()) inm = lambda: map(int, sys.stdin.readline().split()) inl = lambda: list(inm()) ins = lambda: sys.stdin.readline().rstrip() debug = lambda *a, **kw: print(*a, **kw, file=sys.stderr) N = ini() def solve(): k = 26 a = k l = 1 name = [] x = N while x > 0: c = x % 26 name.append(chr((c + 25) % 26 + ord(""a""))) x //= 26 return """".join(reversed(name)) print(solve()) " p02629,s876370902,Wrong Answer,"n = int(input()) ans='' while n > 0: ans = chr(ord('a') + (n % 26) -1) + ans n //= 26 print(ans)" p02629,s762046374,Wrong Answer,"alp = [chr(i) for i in range(97, 97+26)] N = int(input()) q = N s = """" while True: q,m = divmod(q,26) if m == 0: m = 26 if q == 1: q = 0 s = alp[m - 1] + s if q == 0: break print(s) " p02629,s245274273,Wrong Answer,"def num2str(n): # 1,2,3... -> a,b,c,... if n == 0: return 'z' else: return chr(ord('a') + n-1) N = int(input()) ans = '' while N > 26: ans = num2str(N%26) + ans N = int(N/26) ans = num2str(N%26) + ans print(ans)" p02629,s261636460,Wrong Answer,"import math import numpy n = int(input()) x = list(numpy.base_repr(n,26)) s = list(""abcdefghijklmnopqrstuvwxyz"") t = list(""0123456789"") for i in range(16): t.append(s[i].upper()) for i in x: print(s[t.index(i)-1],end = """")" p02629,s022834162,Wrong Answer,"def main(): N = int(input()) ANS = [] while N > 0: ANS.insert(0,chr(N%26+96)) N = N//26 print(''.join(ANS)) if __name__ == '__main__': main()" p02629,s187500892,Wrong Answer,"n = int(input()) a = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o','p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] ans = """" for i in range(11, -1, -1): if i==0: res=n else: res = n//(26**i) if res%26 == 0: continue else: ans += a[res%26-1] print(ans)" p02629,s820244598,Wrong Answer,"al = [""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()) ans = """" while N > 0: r = N%26 N = int(N/26) if r == 0: ans = al[25] + ans else: ans = al[r-1] + ans print(ans)" p02629,s676648877,Wrong Answer,"def main(): n = int(input()) num = n name = [] cap = [chr(i) for i in range(97, 97+26)] cap.insert(0, 'z') del cap[-1] if n == 26: return 'z' while n >= 27: last = n % 26 n = n // 26 name.insert(0, cap[last]) last = (n % 26) - 1 name.insert(0, cap[last]) ans = """".join(name) return ans print(main())" p02629,s449509419,Wrong Answer,"n=int(input()) num=n shisuu=1 ans="""" while num>0: num-=26**shisuu shisuu+=1 for i in range(shisuu-2,-1,-1): ans+=chr(ord(""a"")-1+n//(26**i)) n=n%(26**i) print(ans)" p02629,s658259835,Wrong Answer,"import string Al = string.ascii_lowercase N = int(input()) S = 0 for i in range(1,16): S += 26**i if N < S: maxi = i break Answer = [] for i in range(maxi): j = maxi - (i+1) mo = N//(26**j) Answer.append(mo) N = N-(26**j)*mo A = str() for k in range(len(Answer)): A = A + (Al[Answer[k]-1]) print(A)" p02629,s719309846,Wrong Answer,"n=int(input()) al=[''] b=[chr(i) for i in range(ord('a'), ord('z')+1)] al+=b c='' while n != 0: i = n%26 n=n//26 c+=al[i] c=c[::-1] print(c)" p02629,s255278370,Wrong Answer,"def Base_10_to_n(X, n): #print(X) if (int(X/n)): return Base_10_to_n(int(X/n), n)+' '+str(X%n) return str(X%n) n = int(input()) -1 an = Base_10_to_n(n,26) ans = [chr(int(i)+96) for i in an.split()] if len(ans)>1: ans[-1] = chr(ord(ans[0-1]) +1) print(''.join(ans))" p02629,s131836654,Wrong Answer,"def main(): n = int(input()) 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) P = list(map(int, Base_10_to_n(n, 26).split())) if P[-1] == 0: P = P[:-1] ans = [0] * len(P) for i, p in enumerate(P): ans[i] = chr(96 + p) print(''.join(ans)) if __name__ == '__main__': main() " p02629,s150498873,Wrong Answer,"n = int(input()) - 1 num = 1 while 26**num < n: n -= 26**num num += 1 r = [] while 25 < n: r.append(n % 26) n //= 26 r.append(n) if len(r) < num: for i in range(num - len(r)): r.append(0) for i in r[::-1]: print(chr(97+i), end='')" p02629,s773464206,Wrong Answer,"def resolve(): n=int(input()) a=list('abcdefghijklmnopqrstuvwxyz') ans=[] while n>0: ans.append(a[((n-1)%26)]) n//=26 print(''.join(map(str,ans[::-1]))) if __name__ == '__main__': resolve()" p02629,s800899447,Wrong Answer,"n=int(input()) l=['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=[] while n>0: r=n%26 n=n//26 z.append(r) s='' for x in z: let=l[x-1] s=let+s print(s)" p02629,s054272340,Wrong Answer,"# ord('a'), chr(97) N = int(input().rstrip()) ret = [] while N != 0: ret.append(chr(96+(N % 26))) N = N // 26 print(''.join(ret[::-1])) " p02629,s733399694,Wrong Answer,"import sys sys.setrecursionlimit(10 ** 7) f_inf = float('inf') mod = 10 ** 9 + 7 def resolve(): n = int(input()) L = [chr(i) for i in range(97, 97 + 26)] res = """" i = 1 while n: r = n % 26 res += L[r - 1] n = (n - i) // 26 i += 1 print(res[::-1]) if __name__ == '__main__': resolve() " p02629,s275290046,Wrong Answer,"N = (int)(input()) count = 1 loop = 26 lo = 26 N -= 1 while 1: if lo > N: break count += 1 lo = loop loop *= 26 lo += loop ss = """" for i in range(count): loop //= 26 print(""N:"" + (str)(N) ) print(""loop : "" + (str)(loop)) tmp = N // loop N %= loop tmp += 96 ss += chr((int)(tmp)) ss =ss[0:-1] + chr((int)(tmp)+1) print(ss) " p02629,s872789685,Wrong Answer,"n=int(input()) ans=[] num2alpha = lambda c: chr(c+64).lower() while True: if num2alpha(n%26)=='@': ans.append('z') else: ans.append(num2alpha(n%26)) n=n//26 if n==0: break for i in range(len(ans)): print(ans[-1-i], end='') print()" p02629,s377846436,Wrong Answer,"n = int(input()) ans = """" while n > 0: n -= 1 ans += chr(ord('a') + n % 26) n //= 26 print(n) print(ans[::-1])" p02629,s727575949,Wrong Answer,"n=int(input()) a=[] while n: a+=n%26, n//=26 a=a[::-1] for i in range(len(a)-1,0,-1): if not a[i]: a[i]=26 a[i-1]-=1 i=0 while not a[i]:i+=1 print(''.join(chr(c+96)for c in a[i:]))" p02629,s093383042,Wrong Answer,"N = int(input()) L =[] while 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)" 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)) " p02629,s211118790,Wrong Answer,"word_lst = ['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()) w_lst = [] x = n p = 1 while x >= 0: s = n % 26 w_lst.append(s) x = n - 26**p n = x p += 1 print(w_lst) ans_lst = [] for d in w_lst: ans_lst.append(word_lst[d-1]) print("""".join(ans_lst))" p02629,s855986154,Wrong Answer,"n = int(input()) moji = [chr(i) for i in range(97, 97+26)] name = '' while n > 0: wari = n // 26 name += moji[(n%26)-1] n = wari if ( n > 0 ): name += moji[(n%26)-1] new_str = name[::-1] print(new_str)" p02629,s403457822,Wrong Answer,"from itertools import count from string import ascii_lowercase def get_length(n): dogs = 0 for i in count(1): dogs += 26 ** i if n <= dogs: return i def get_name(n): length = get_length(n) if n <= 26: return ascii_lowercase[n - 1] else: return get_name((n - 1) // 26 ** (length - 1)) + get_name(n % 26 ** (length - 1)) N = int(input()) print(get_name(N)) " p02629,s105236556,Wrong Answer,"import string N = int(input()) alphabet = list(string.ascii_lowercase) def Base_10_to_n(X, n): X_dumy = X out = [] while X_dumy>0: out.append(X_dumy%n) X_dumy = int(X_dumy/n) return out ans = '' for i in Base_10_to_n(N, 26)[::-1]: ans += alphabet[i-1] print(ans)" p02629,s934127540,Wrong Answer,"import math N = int(input().rstrip()) alphabet = ""abcdefghijklmnopqrstuvwxyz"" # 桁数 m = int(math.log(N, 26)) + 1 ans = """" val = N for i in range(1, m): val = val // 26 mod = val % 26 ans = alphabet[mod-1] + ans ans += alphabet[N % 26 - 1] print(ans)" p02629,s122020753,Wrong Answer,"import math name = input() i = int(name) l = [] while i//26 >= 1: l.append(i%26) i = i//26 l.append(i%26) l.reverse() for date in l: print(chr(96 + date%26) ,end="""") print()" p02629,s127938223,Wrong Answer,"n = int(input()) res = '' abc = 'zabcdefghijklmnopqrstuvwxy' while n>0: res = abc[n%26]+res n = n//26 print(res)" p02629,s470293702,Wrong Answer,"n = int(input()) 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) x = num2alpha(n) print(x.upper())" p02629,s848637806,Wrong Answer,"N = int(input()) S = ""abcdefghijklmnopqrstuvwxyz"" L = """" while True: X = N%26 L = S[X-1]+L N = N//26 if N == 0: break print(L)" p02629,s631896664,Wrong Answer," N = int(input()) c = [chr(i) for i in range(ord(""a""), ord(""z"") + 1)] name = [] while (1): amari = N % 26 N = N//26 if amari == 0: amari = 26 name.append(amari) if N == 0: break name = (list(map(lambda x : chr(ord(""a"")-1+x), name))) for n in reversed(name): print(n, end="""") print() " p02629,s558993189,Wrong Answer,"search_num = int(input()) alpha_num = 26 settle_list = [] while search_num > alpha_num: rest = search_num%alpha_num # print(rest) settle_list.append(rest) search_num = search_num//alpha_num settle_list.append(search_num) alphabets = [chr(i) for i in range(97, 97+26)] # 大文字 numbers = [i for i in range(1, 27)] dict1 = dict(zip(numbers,alphabets)) dict1[0] = ""z"" # print(dict1) ans_list = [] for i in settle_list: ans_list.append(dict1[i]) ans_list.reverse() print("""".join(ans_list))" p02629,s166892950,Wrong Answer,"import math N = int(input()) l = [] while N // 26 != 0: n = N % 26 l.insert(0, n) N = N // 26 l.insert(0, N) NAME = [chr(64+num) for num in l] name = str.lower("""".join(NAME)) print(name) " p02629,s079588218,Wrong Answer,"n = int(input()) al = 'abcdefghijklmnopqrstuvwxyz' s = '' while n > 26: e = n % 26 s = al[e - 1] + s n //= 26 s = al[n % 26 - 1] + s print(s) " p02629,s873836806,Wrong Answer,"a = int(input()) n = 26 def numalpha(num): if num<=n: return chr(ord('a')+num-1) else: return numalpha(num//n)+chr(ord('a')+num%n-1) print(numalpha(a))" p02629,s046764149,Wrong Answer,"alphabet = ""abcdefghijklmnopqrstuvwxyz"" N = int(input()) ans = """" for i in range(1,100): r = N % 26 ans += alphabet[r-1] N = (N-r) // 26 if N <= 0: break print(ans[::-1])" p02629,s838419875,Wrong Answer,"number = int(input()) alphabet = [chr(i) for i in range(97, 97+26)] name_tag = [] while number != 0: number, a = divmod(number, 26) name_tag.append(a) for i in name_tag: print(alphabet[i-1], end="""")" p02629,s039492496,Wrong Answer,"n = int(input()) d = ['z', '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 = '' f = 0 while n: a = d[n % 26 - f] + a if n % 26 == 0: f = 1 else: f = 0 n //= 26 print(a)" p02629,s697618072,Wrong Answer,"n = int(input()) b = [] moji_list = ['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(10): a = n % 26 a = int(a) n = (n - a)/26 b.append(a) if n == 0: break b = sorted(b) print(b) for i in range(len(b)): print(moji_list[b[i]-1],end="""") print()" p02629,s302649795,Wrong Answer,"N = int(input()) ans = '' az = [chr(i) for i in range(97, 97+26)] while N>0: r = N%26 ans+=az[r-1] N = (N-r)//26 print(ans[::-1])" p02629,s059159868,Wrong Answer,"def sol(): 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'] n = int(input()) ans = '' for i in range(100000): if n // 26 >= 1: ans = alphabet[int(n % 26 - 1)] + ans n = n / 26 continue else: ans = alphabet[int(n % 26 - 1)] + ans break print(ans) if __name__ == ""__main__"": sol() " p02629,s387624741,Wrong Answer,"N=int(input()) abc=[chr(i) for i in range(97, 97+26)] ans="""" while N>0: ans+=(abc[N%26-1]) N//=26 print(ans[::-1])" p02629,s610909852,Wrong Answer,"n = int(input()) digits = [int(26/25*(pow(26, i) - 1)) for i in range(15)] digit = 0 for i in range(15): if n <= digits[i]: digit = i break s = '' for i in range(digit): m = n // pow(26, digit-i-1) # print(""m="",m) s += chr(97+m-1) # print(""s="",s) n -= m * pow(26, (digit-i-1)) print(s)" p02629,s851265364,Wrong Answer,"n = int(input()) alp = [""z"",""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""] name = """" for i in range (10): name = alp[n%26]+name if n <=26: break n //= 26 print(name)" p02629,s673832395,Wrong Answer,"n=int(input()) alphabet='abcdefghijklmnopqrstuvwxyz' base=[26**i for i in range(12)] digit=0 flag=0 for i in range(12): if n%base[i]==0: flag=1 elif base[i]>n: digit=i break answer='' for i in range(digit): t=n//base[-(13-digit)-i] answer+=alphabet[t-1] n=n%base[-(13-digit)-i] if flag==1: print(answer[1:]) else: print(answer)" p02629,s169026915,Wrong Answer,"N = int(input()) s = '' tmp = N while True: s = chr((tmp-1)%26+97) + s tmp //= 26 if tmp==0: break print(s)" p02629,s296991887,Wrong Answer,"N = int(input()) s = N num = 0 ar = [] mod = s while (s > 26): q, mod = divmod(s, 26) if mod == 0: mod = 26 ar.append(mod) s = q num += 1 if mod == 0: mod = 26 ar.append(mod) ar.reverse() for i in ar: print(chr(i+96), end='') " p02629,s818966619,Wrong Answer,"sum=26 count=0 n = int(input()) k = ord('a')-1 while(sum 0: r = n % 26 data.append(r) n //= 26 print(data) is_z =False for i in reversed(data): if i == 0: ans = ans.replace(""a"",""z"") ans += list[i - 1] print(ans)" p02629,s848997867,Wrong Answer,"# One Quadrillion and One Dalmetians N = int(input()) Q = [N] R = [] name =[] i = 0 while Q[i] // 27 != 0: Q.append(Q[i] // 26) R.append(Q[i] % 26) i += 1 name.append(chr(Q[i]+96)) while i != 0 : i -= 1 name.append(chr(R[i]+96)) print(''.join(name)) " p02629,s186034249,Wrong Answer,"N = int(input()) ans = [] a = ord('a') while N > 0: ans.append(chr(a - 1 + (N % 26))) N //= 26 print(''.join(reversed(ans))) " p02629,s494325820,Wrong Answer,"# C - One Quadrillion and One Dalmatians n = int(input()) al = 'abcdefghijklmnopqrstuvwxyz' s = '' while True: s = al[n % len(al)-1] + s n = n // len(al) if n == 0: break print(s) " p02629,s657234813,Wrong Answer,"n = int(input()) alphabet = 'abcdefghijklmnopqrstuvwxyz' answer = """" while n > 0: tmp = n % 26 answer+=alphabet[tmp-1] n=n//26 print(answer[::-1])" p02629,s767406561,Wrong Answer,"n = int(input()) def nume(num): if num<=26: return chr(96+num) elif num%26==0: return nume(num//26-1)+chr(126) else: return nume(num//26)+chr(96+num%26) print(nume(n))" p02629,s918374840,Wrong Answer,"N = int(input()) ans = '' while N > 0: N -= 1 ans += chr(ord('a') + N % 26) N = N//26 print(ans)" p02629,s991148243,Wrong Answer,"n = int(input()) d = ['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 = '' while n: a = d[n % 26] + a n //= 26 print(a)" p02629,s587143423,Wrong Answer,"N =int(input()) num2alpha = lambda c: chr(c+64) a=[] while N >> 0: if (N%26) == 0: a.append(""z"") else : a.append(num2alpha(int(N%26)).lower()) N=int(N/26) a.reverse() print(''.join(a)) 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)" p02629,s982696107,Wrong Answer,"import sys input = sys.stdin.readline N = int(input()) # upper-case A-Z #[chr(i) for i in range(65,65+26)] # lower-case a-z #alphabet = [chr(i) for i in range(97,97+26)] ans = '' while N > 0: ans += chr(ord('a') + N % 26 - 1) N = N // 26 print(ans[::-1])" p02629,s563535275,Wrong Answer,"n = int(input()) #n -= 1 l = [] while True: t = n // 26 s = n % 26 if s != 0: l.append(chr(96+s)) n = t if t == 0: break l.reverse() print(''.join(l))" p02629,s501725313,Wrong Answer,"alphabet = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] num = int(input()) - 1 bit = [] c = (0,0) while (num // 26) > 26 : c = divmod(num,26) num = c[0] bit.append(c[1]) else: c = divmod(num,26) num = c[0] bit.append(c[1]) if c[0] != 0: bit.append(c[0]) res = '' for i in reversed(range(0,len(bit))): res += alphabet[bit[i] - 1] print(res) " p02629,s540112398,Wrong Answer,"N=int(input());N-=1 a=list('abcdefghijklmnopqrstuvwxyz') n=[] while 00: out = chr(96+N%x)+out N = int(N/x) print(out) base_10_to_n(n, 26)" p02629,s251779030,Wrong Answer,"import sys INF = 1 << 60 MOD = 10**9 + 7 # 998244353 sys.setrecursionlimit(2147483647) input = lambda:sys.stdin.readline().rstrip() def resolve(): n = int(input()) res = [] while n: n, r = divmod(n, 26) # print(r) res.append(chr(ord('a') + r - 1)) res.reverse() print(''.join(res)) resolve() #%%" p02629,s467195479,Wrong Answer,"import sys from collections import deque sys.setrecursionlimit(10 ** 6) INF = float(""inf"") MOD = 10 ** 9 + 7 def input(): return sys.stdin.readline().strip() def main(): N = int(input()) alpahbet = [chr(ord(""a"") + i) for i in range(26)] ans = deque([]) while N > 0: if N % 26 == 0: ans.appendleft(alpahbet[-1]) else: ans.appendleft(alpahbet[N % 26 - 1]) N //= 26 print(*ans, sep="""") if __name__ == ""__main__"": main() " p02629,s559547933,Wrong Answer,"N = int(input()) S = str() import math while N > 0: if N > 26: D = math.floor(math.log(N, 26)) K = 26**math.floor(math.log(N, 26)) P = N//K N = N-P*K S=S+chr(96+P) else: K = N S=S+chr(96+K) N = 0 print(S)" p02629,s572539992,Wrong Answer,"N = int(input()) al = 26 i = 1 while N > al**i: N -= al**(i) i += 1 ans = '' print(N) a = ord('a') while i > 0: ans += chr(a + (N-1) // al**(i-1)) N %= al**(i-1) i -= 1 print(ans)" p02629,s192829780,Wrong Answer,"N = int(input()) li = [] while(1): i = N % 26 li.append(chr(96 + i)) N = N // 26 if N == 0: break li.reverse() for i in range(len(li)): print(li[i], end="""")" p02629,s826423420,Wrong Answer,"N = int(input()) c_ls = [] for n in range(0, 12): a = sum([26 ** i for i in range(1, n + 1)]) if not n: a = 1 s = N - a if s >= 0: m = (s % (26 ** (n + 1))) // (26 ** (n)) + 1 c_ls.append(chr(m + 96)) print("""".join(reversed(c_ls))) " p02629,s231544729,Wrong Answer,"N = int(input()) name = '' while N!=0: name = chr(ord('a')-1+N%26) + name N = N//26 print(name)" p02629,s580206770,Wrong Answer,"def main(): N = int(input()) alp = ""abcdefghijklmnopqrstuvwxyz"" reslist = [] q, r = divmod(N, 26) reslist.append(r) while q > 0: q, r = divmod(q, 26) reslist.append(r) name = [alp[s-1] for s in reslist] name = reversed(name) print(''.join(name)) if __name__ == '__main__': main()" p02629,s091222779,Wrong Answer,"def solve(): N = int(input()) ans = '' remainder = N for i in range(10, -1, -1): digit,remainder = divmod(remainder, 26**i) if digit != 0: ans += chr(digit + 96) print(ans) if __name__ == ""__main__"": solve()" p02629,s228184364,Wrong Answer,"x = int(input()) str_val = '' while(x > 0): char = x % 26 x = x // 26 str_val = str_val + chr(96+char) print(str_val[::-1])" p02629,s753832787,Wrong Answer,"n=int(input()) ans="""" l=[26,26**2,26**3,26**4,26**5,26**7,26**8,26**9,26**10] s=[0] tt=0 for i in range(9): tt+=l[i] s.append(tt) s.sort(reverse=True) l.sort(reverse=True) tmp=n for i in range(9): if n>=s[i]: k=tmp//l[i] kk=chr(k+64).lower() tmp=tmp%l[i] ans=ans+kk ans=ans+chr(tmp+64).lower() print(ans)" p02629,s898337174,Wrong Answer,"a=int(input()) ei=[chr(i) for i in range(ord('a'), ord('z')+1)] name_list=[] name="""" q=int(a/27) r=int(a%26) if q==0: name_list.append(r) while q>0: q=int(a/26) r=int(a%26) a=q name_list.append(r) for i in range(len(name_list)): name+=ei[name_list[-(i+1)]-1] print(name) " p02629,s948105252,Wrong Answer,"n = int(input()) ans = '' while n > 0: m = n % 26 ans += chr(m + ord('a') - 1) n //= 26 print(ans[::-1]) " p02629,s226215081,Wrong Answer,"n = int(input()) AL = [chr(ord('a') + i) for i in range(26)] def number_to_alphabet(n): a = '' while 0 < n: d = n % 26 - 1 a = AL[d] + a n = n//26 return a print(number_to_alphabet(n)) " p02629,s406176619,Wrong Answer,"import sys sys.setrecursionlimit(4100000) import math INF = 10**9 def main(): n = int(input()) a = int(math.log(n,26)) a2 = n - 26**a ans = '' b = n for i in range(a+1): if b == 0: ans += chr(ord('a')+int(b//(26**(a-i)))) else: ans += chr(ord('a')-1+int(b//(26**(a-i)))) b -= 26**(a-i)*(b//(26**(a-i))) print(ans) if __name__ == '__main__': main() " p02629,s185590604,Wrong Answer,"n = int(input()) a = 'abcdefghijjklmnopqrstuvwxyz' name = '' while n >= 26: name = a[n % 26-1]+name n //= 26 name = a[n-1]+name print(name) " p02629,s288846396,Wrong Answer,"n = int(input()) result = chr(96 + (n % 26)) while n // 26 > 0: n = n // 26 x = n % 26 result += chr(96 + x) print(result[::-1]) " p02629,s843275551,Wrong Answer,"from math import log n = float(input()) alphabet = ['z','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'] alpha = [] def Base_10_to_n(X, n): global alpha if (int(X/n)): alpha = Base_10_to_n(int(X/n), n) + [X%n] return alpha return [X%n] a = Base_10_to_n(n,26) out = [] for i in range(len(a)): out.append(alphabet[int(a[i])]) print(''.join(out)) " p02629,s350003664,Wrong Answer,"import sys n = int(input()) m = n alphabet = [chr(i) for i in range(97, 97+26)] keta = 0 while True: if n < 26**(keta): break keta += 1 ans = '' for i in range(keta-1, -1, -1): have = m // (26 ** i) ans += alphabet[have-1] m -= 26 ** i * have print(ans) " p02629,s256296582,Wrong Answer,"N = int(input()) number = N answer = '' while number >= 1: x = number % 26 if x == 0: x = 26 answer = chr(96+x) + answer if number % 26 == 0 and number // 26 == 1: break number //= 26 print(answer)" p02629,s160502727,Wrong Answer,"n = int(input()) l = [] while n != 0: amari = n % 26 n = n // 26 l.append(amari) l2 = [] for i in range(len(l)-1,-1,-1): l2.append(l[i]+96) l3 = [] for i in l2: l3.append(chr(i)) print("""".join(l3)) " p02629,s432604771,Wrong Answer,"N=int(input()) def num2alpha(num): if num<=26: return chr(num+96) elif num%26==0: return num2alpha(num//26-1)+chr(90) else: return num2alpha(num//26)+chr(num%26+96) print(num2alpha(N))" p02629,s476116584,Wrong Answer,"N = int(input()) l = [] ascii_lowercase = 'zabcdefghijklmnopqrstuvwxy' while N>=26: l.append(N%26) N = N//26 l.append(N) for i in l[::-1]: print(ascii_lowercase[i], end='') print('')" p02629,s776217963,Wrong Answer,"N = int(input()) chars = ""Xabcdefghijklmnopqrstuvwxyz"" ans = """" while True: la = N // 26 sm = N % 26 if sm == 0: sm = 26 la -= 1 ans += chars[sm] N = la if N <= 1: break print(ans[::-1])" p02629,s613385940,Wrong Answer,"a = int(input().rstrip()) b = a c = [] for i in range(30): c.append(int(b%26)) b = b/26 c.reverse() aa = ["""",""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 j in range(len(c)): print(aa[c[j]],end ="""") print("""")" p02629,s567309548,Wrong Answer,"import sys read = sys.stdin.read readlines = sys.stdin.readlines def main(): n = int(input()) r = [] while n: n += 1 t1 = n % 26 r.append(chr(t1+95)) n = n // 26 print("""".join(r[::-1])) if __name__ == '__main__': main()" p02629,s008527492,Wrong Answer,"N = int(input()) alpha = list('abcdefghijklmnopqrstuvwxyz') ans = '' def dfs(n): global ans if n <= 26: ans += alpha[n-1] return ans else: ans += alpha[n%26-1] return dfs(n//26) print(dfs(N)[::-1])" p02629,s284904181,Wrong Answer,"N = int(input()) ans = """" while N >= 1: if N%26 == 0: ans = chr(26+96) + ans N = int(N/26) else: ans = chr(N%26+96) + ans N = int(N/26) print(ans) " p02629,s026541294,Wrong Answer,"N = int(input()) l = 'abcdefghijklmnopqrstuvwxyz' s = '' a = N % 27 s += l[a-1] N //= 26 while(N!=0): a = N % 27 s += l[a-1] N //= 26 print(s[::-1])" p02629,s164341755,Wrong Answer,"import sys import math #sys.stdin=open('input.txt','r') #sys.stdout=open('output.txt','w') from sys import stdin,stdout from collections import deque,defaultdict from math import ceil,floor,inf,sqrt,factorial,gcd,log2 from copy import deepcopy ii1=lambda:int(stdin.readline().strip()) is1=lambda:stdin.readline().strip() iia=lambda:list(map(int,stdin.readline().strip().split())) isa=lambda:stdin.readline().strip().split() mod=1000000007 s='abcdefghijklmnopqrstuvwxyz' n = ii1() ans='' while n: a=n%26 ans+=s[a-1] n//=26 print(ans[::-1]) " p02629,s744513479,Wrong Answer,"N = int(input()) ans = '' # ans = lambda c: chr(c+64) # chr(ord(str)) # 26進数計算 ''' while True: if N <= 26: print(ans(N).lower()) exit() '''" p02629,s641737277,Wrong Answer,"n = int(input()) ans = """" while n > 0: ans = chr(ord('a')+n%26-1)+ans n //= 26 print(ans)" p02629,s282688157,Wrong Answer,"n = int(input()) AL = [chr(ord('a') + i) for i in range(26)] def number_to_alphabet(n): a = '' while 0 < n: d = n % 26 - 1 a = AL[d] + a n = n//26 return a print(number_to_alphabet(n)) " p02629,s490523826,Wrong Answer,"N = int(input()) a = [] for i in range(26): a.append(chr(0x61 + i)) l = [] for i in range(20): x = N % 26 l.append(a[x - 1]) N = N // 26 if N == 0: break print("""".join(reversed(l)))" p02629,s977224555,Wrong Answer,"n=int(input()) alphabet=[None] + [chr(i) for i in range(97,97+26)] if n<27: print(alphabet[n]) exit() rest=[] while n!=0: rest.append(n%26) n = n // 26 rest.reverse() for i in range(len(rest)-1): if rest[len(rest)-1-i]==0: rest[len(rest)-1-i]=26 rest[len(rest)-2-i]-=1 if rest[0]==0: rest=rest[1:] print(rest) ans='' for i in range(len(rest)): ans+=alphabet[rest[i]] print(ans) " p02629,s233683446,Wrong Answer,"n = int(input()) a = [] while True: n, r = divmod(n, 26) a.append(r) if n <= 25: if n != 0: a.append(n) break a = a[::-1] from string import ascii_letters as b print(''.join([b[v-1] for v in a]))" p02629,s308334148,Wrong Answer,"N = int(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""] s = N t = 0 while(s > 26): t += 1 s /= 26 keta = [] for i in range(t+1): base = 26 ** (t - i) tmp = int(N / base) keta.append(alphabet[tmp - 1].lower()) N -= base * tmp answer = """" for i in range(len(keta)): answer += keta[i] print(answer) " p02629,s669958813,Wrong Answer,"a = 'abcdefghijklmnopqrstuvwxyz' n = int(input()) ans = '' while n>=1: x = n%26 n = n//26 ans+=a[x-1] print(ans[-1::-1])" p02629,s269919242,Wrong Answer,"s=int(input()) d=[] while s>0: d.append(chr(s%26+97)) s//=26 t='' for i in reversed(d): t+=i print(t) " p02629,s204914315,Wrong Answer,"a = int(input()) n = 26 def numalpha(num,s=''): if num < n: return chr(ord('a') + num - 1) + s else: return numalpha(num // n, chr(ord('a') + num % n - 1) + s) print(numalpha(a))" p02629,s037716548,Wrong Answer,"N = int(input())-1 a = 1 while a <= N: a *= 26 a //= 26 ans = '' while a >= 1: d = N // a - 1 if a == 1: d += 1 N = N % a a //= 26 ans += chr(ord('a') + d) print(ans)" p02629,s155240490,Wrong Answer,"n = int(input()) def conversion(num): converted_list = [] flg = True while flg: num, mod = divmod(num, 26) converted_list.append(mod) if num == 0: flg = False converted_list = converted_list[::-1] return converted_list alphabet = [chr(i) for i in range(97, 123)] ans = '' for i in conversion(n): ans += alphabet[i - 1] print(ans)" p02629,s043675811,Wrong Answer,"n = int(input()) alp_list = [chr(ord('a')+i) for i in range(26)] ans = '' while n>0: # 1のくらいから文字を入れていく # 各位の数は小さい方から、Nを26で割った時の余りに対応する ans = alp_list[n%26-1] + ans n //= 26 print(ans) " p02629,s549454232,Wrong Answer,"N = int(input()) q = N alp = [chr(i) for i in range(97,97+26)] a = [] r = q % 26 q = int(q / 26) a.append(r) while q >= 26: r = q % 26 q = int(q / 26) a.append(r) if q < 26: a.append(q) a.reverse() for i in range(len(a)): print(alp[a[i]-1], end='')" p02629,s899098193,Wrong Answer,"def main(): n = int(input()) ans = [] while n>26: p = n//26 k = n-26*p ans.append(k) n = p ans.append(n) ans = ans[::-1] b = [] for a in ans: b.append(chr(96+int(a))) print(''.join(b)) if __name__ == ""__main__"": main() " p02629,s054151305,Wrong Answer,"# https://atcoder.jp/contests/abc171/tasks/abc171_c import string def getOrdOfAlphabet(s): return ord(s) - 64 def getAlphabetByNum(n): alphabets = string.ascii_lowercase return alphabets[n - 1] N = int(input()) N_work = N mod_list = [] while True: if N_work == 0: break mod = N_work % 26 mod_list.append(mod) N_work //= 26 dog_name = '' for n in mod_list: if n == 0: n = 26 dog_name = getAlphabetByNum(n) + dog_name print(dog_name) " p02629,s437589733,Wrong Answer,"# print('input >>') N = int(input()) alphabets = 'abcdefghijklmnopqrstuvwxyz' name = '' while N > 1: mod = int(N) % 26 name = alphabets[mod-1] + name N /= 26 # print('-----output-----') print(name)" p02629,s367217423,Wrong Answer,"#!/usr/bin/env pypy import sys import string def get_int(): return int(sys.stdin.readline().strip()) def get_ints(): return map(int, sys.stdin.readline().strip().split()) def get_list(): return list(map(int, sys.stdin.readline().strip().split())) def get_string(): return sys.stdin.readline().strip() def out(data): return sys.stdout.write(str(data)) def out_list(arr): return sys.stdout.write(' '.join(str(e) for e in arr)) MAX = 10**9 MOD = 10**9 + 7 n = get_int() alp = "" ""+string.ascii_lowercase ans = '' while n: ans += alp[(n-1)%26+1] n = (n-1) // 26 print(ans) " p02629,s374937361,Wrong Answer,"import sys N_MAX = 200000 + 5 INF = 10**9 + 7 sys.setrecursionlimit(N_MAX) MOD = 10**9 + 7 N = int(sys.stdin.readline()) alp = ""abcdefghijklmnopqrstuvwxyz"" def name(A, s=""""): i = A % 26 z = alp[i - 1] s = z + s A = A // 26 if A > 0: s = name(A, s) return s print(name(N)) " p02629,s764387980,Wrong Answer,"base = ord('a') - 1 N = int(input()) data = [] while N: next, mod = divmod(N, 26) data.append(mod) N = next data.reverse() for i in data: print(chr(base + i), end="""")" p02629,s656493231,Wrong Answer,"#coding: utf-8 N = int(input()) alp = [chr(i) for i in range(97, 97+26)] for i in range(100): if 26**i >= N: cnt = i #tmp = N - 26**(i-1) break s = 0 #print(cnt) for i in range(cnt): s += 26**i tmp = N-s #print(tmp) ans = '' while cnt > 0: d = int(tmp//(26**(cnt-1))) tmp =tmp%(26**(cnt-1)) #print(int(d)) ans += alp[d] cnt -= 1 print(ans)" p02629,s715363141,Wrong Answer,"N = int(input()) check = ""abcdefghijklmnopqrstuvwxyz"" if N <= 26: print(check[N-1]) exit(0) i = 0 keta = 26**i while keta <= N: i += 1 keta = 26**i ans = """" for j in range(i): checker = int(N / 26**(i - j -1)) N = N - checker*(26**(i-j-1)) s = check[checker-1] ans = ans + s print(ans)" p02629,s871032285,Wrong Answer,"import math n=int(input()) a=[] y=int(math.log(n,26)) for i in range(y+1): a.append(n%(26**(i+1))) for i in range(y+1): a[i]=a[i]//(26**i) a.reverse() #print(a,y) q=['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(y+1): print(q[a[i]-1],end="""")" p02629,s515027681,Wrong Answer,"n = int(input()) # アルファベットの文字列を作成 list_alpha = [chr(i) for i in range(97, 97+26)] # 名前長さを捜索 for i in range(1, 20): n_len = n n_len -= pow(26, i) if n_len <= 0: break n = n_len ans = '' for j in range(1, i+1): devide = n // pow(26, 1) rest = n % pow(26, 1) ans = ''.join([list_alpha[rest-1], ans]) n = devide print(ans)" p02629,s195453938,Wrong Answer,"def main(): n = int(input()) ans = [] while n>26: p = n//26 k = n-26*p ans.append(k) n = p ans.append(n) ans = ans[::-1] b = [] flg = 0 for a in ans: if int(a)==0: b.pop(-1) b.append('az') else: b.append(chr(96+int(a))) print(''.join(b)) if __name__ == ""__main__"": main() " p02629,s012684164,Wrong Answer,"alphabet_list = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'r', 'u', 'v', 'w', 'x', 'y', 'z'] def Base_10_to_n(X, n): if (int(X/n)): return Base_10_to_n(int(X/n), n) + str(alphabet_list[X%n-1]) return str(alphabet_list[X%n-1]) if __name__==""__main__"": # Problem C N = int(input()) ans = Base_10_to_n(N, 26) print(ans)" p02629,s408520027,Wrong Answer,"sum=26 count=0 n = int(input()) k = ord('a')-1 while(sum0 else 26 n = n//26 mlist.insert(0,m) if n<26: m=n if n >0 else 26 mlist.insert(0,m) break else: pass mlist_alph=[chr(i+96) for i in mlist] print(''.join(mlist_alph))" p02629,s357885180,Wrong Answer,"import string n = int(input()) f = [] if n > 26: while n: n -= 1 n, r = divmod(n, 26) f += [r] else: f += [n] g = '' s = string.ascii_lowercase f.reverse() for i in f: g += s[i] print(g)" p02629,s393480033,Wrong Answer,"#!/usr/bin/env python3 import sys import numpy as np input = sys.stdin.readline n=int(input()) Z = [chr(i) for i in range(97, 97+26)] ans = """" def div(k): k ,mod = divmod(k, 26) global ans ans += Z[mod-1] return k for i in range(20): n = div(n) if n ==0 : print(ans[::-1]) sys.exit() sys.exit() " p02629,s885211610,Wrong Answer,"n = int(input()) x = 0 for i in range(1, 100): if n <= 26**i: x = i break ans = '' for i in range(x, 0, -1): y = n // (26**(i-1)) ans += chr(y + 96) n -= (y * (26**(i-1))) print(ans) " p02629,s577439673,Wrong Answer,"#!/usr/bin/env python3 def main(): from string import ascii_lowercase N = int(input()) num = [0] * 13 for i in range(12, -1, -1): res = 26 ** i if N >= res: num[i] = N // res N = N % res for i in num[::-1]: if i: print(ascii_lowercase[i - 1], end='') if __name__ == '__main__': main() " p02629,s562006008,Wrong Answer,"n = int(input()) res = n % 26 A = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s', 't','u','v','w','x','y','z'] ans = [] while n//26 > 0 : res = n % 26 if res != 0: ans.append(A[res-1]) elif res == 0: ans .append(A[25]) n = n // 26 if res != 0: ans.append(A[res-1]) print(*ans[::-1], sep='')" p02629,s693871953,Wrong Answer,"def main(): n = int(input()) ans = '' while n != 0: ans = chr(n % 26 + 96) + ans n //= 26 print(ans) if __name__ == '__main__': main() " p02629,s121629771,Wrong Answer,"alp=[""z"",""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""] N=int(input()) li=[] while N>=0: na=N%26 li.append(alp[na]) if N<26: break else: N=N//26 ans="""" for i in range(len(li)): ans+=li[i] print(ans[::-1])" p02629,s151377714,Wrong Answer,"N = int(input()) a = list() sho = N alpha = [i for i in 'abcdefghijklmnopqrstuvwxyz'] if N <= 26: a.append(alpha[N-1]) else: while sho != 0: sho = N // 26 amari = N % 26 a.append(alpha[amari-1]) N = N // 26 a.reverse() print(''.join(a))" p02629,s789291695,Wrong Answer,"def main(): N = int(input()) ans = '' abc = ""abcdefghijklmnopqrstuvwxyz"" while N > 0: ans += abc[(N % 26)-1] print(ans) N = N//26 print(ans[::-1]) main()" p02629,s201117853,Wrong Answer,"a = int(input()) alp = list('abcdefghijklmnopqrstuvwxyz') ans = [] while True: if a / 26 > 1: x = a % 26 a = a // 26 a = a-1 ans.append(alp[x-1]) # print(alp[x-1]) else: ans.append(alp[a-1]) #print(alp[a-1]) break ans.reverse() for i in ans: print(i,end="""")" p02629,s235948479,Wrong Answer,"# C n = int(input()) ans = [] while n > 26: ans.append(n % 26) n = n // 26 ans.append(n) print(ans) ans.reverse() for i in ans: print(chr(i + 96),end='') " p02629,s066651550,Wrong Answer,"N = int(input()) q = N // 26 mod = N % 26 A = [] B = [] def num2alpha(c): if(c>0): return chr(c+96) else: return 'z' while(True): A.append(mod) if(q<27): if(q != 0 and mod != 0): A.append(q) break mod = q % 26 q = q // 26 A.reverse() for x in A: B.append(num2alpha(x)) B="""".join(B) print(B)" p02629,s660847562,Wrong Answer,"N=int(input()) ans = """" for i in range(N): if N%26 ==0: ans = ""z"" +ans N -= 26 else: ans = chr(64+ N%26) +ans if N <= 26: break N = N // 26 print(ans.lower()) " p02629,s151316854,Wrong Answer,"import itertools import string n = int(input()) alphabets = string.ascii_lowercase numbers = [0] digit = 0 while 26**digit < n: digit += 1 numbers.append(26**digit) numbers = numbers numbers = list(itertools.accumulate(numbers)) answer = """" for d in range(digit): if d == 0: alphabet = n % 26 - 1 answer = alphabets[alphabet] + answer n = n - (n % 26) else: n = n // 26 alphabet = n % 26 - 1 answer = alphabets[alphabet] + answer print(answer)" p02629,s458737405,Wrong Answer,"N = int(input()) def base10to(n, b): if (int(n/b)): return base10to(int(n/b), b) + str(chr(96 + n%b)) return str(chr(96 + n%b)) print(base10to(N, 26))" p02629,s231621249,Wrong Answer,"N = int(input()) alpha =['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'] x = 1 Z = 'A' while N // 26 > 0: Z += alpha[(N % 26) - 1] N = N // 26 # print(Z) Z += alpha[N - 1] #print('Z = ', Z) for i in range(len(Z) - 1, 0 , -1): print(Z[i], end = '') " p02629,s238837027,Wrong Answer,"a=int(input()) ei=[chr(i) for i in range(ord('a'), ord('z')+1)] name_list=[] name="""" q=int(a/26) r=int(a%26) if q==0: name_list.append(r) while q>0: q=int(a/26) r=int(a%26) a=q name_list.append(r) for i in range(len(name_list)): name+=ei[name_list[-(i+1)]-1] print(name) " p02629,s839290805,Wrong Answer,"N = int(input()) keta = 0 while N >= 26**keta: keta += 1 ans = '' while keta > 0: num = N // (26**(keta-1)) N = N % (26**(keta-1)) ans += chr(96+num) keta -= 1 print(ans)" p02629,s010322197,Wrong Answer,"n=int(input()) l=[""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=[] while n>26: x=n%26 ans.append(l[x-1]) n=n//26 ans.append(l[n-1]) ans.reverse() Ans="""" for i in range(len(ans)): Ans=Ans+ans[i] print(Ans)" p02629,s603754908,Wrong Answer,"N = int(input()) a = (N-1)//26 b = N%26 ans = '' while a!=0: ans = chr(b+96) + ans b = a%26 a = (a-1)//26 ans = chr(b+96) + ans print(ans)" p02629,s450766623,Wrong Answer,"from bisect import bisect_left, bisect_right N = int(input()) MOJI = [26] for i in range(2,12): MOJI.append(MOJI[i-2]+26**i) C = bisect_left(MOJI, N)+1 if N in MOJI: print(""z""*C) exit() ans = [] for i in range(C-1,-1,-1): tmp = N//(26**i) ans.append(chr(tmp+ord(""a"")-1)) N = N%(26**i) L=[str(a) for a in ans] L="""".join(L) print(L)" p02629,s898622056,Wrong Answer,"# 2107 # 解法 2109  26進数とみなして,10進数->26進数に変換すると思えばよいだろう. # 実装 N = int(input()) # 26で割っていき,余りを記録していく.割れなくなったら終了. AL = [] while N >=26: amari = N % 26 N = int((N-amari) / 26) AL.append(amari) AL.append(N) bias = 127 R = [chr(ord('a')+a-1) for a in AL] print(''.join(R[::-1])) " p02629,s569144817,Wrong Answer,"from decimal import * n=Decimal(input()) chars=['z','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'] ans='' while n>0: r=n%26 ans = chars[int(r)]+ans n = n//26 print(ans) " p02629,s333892707,Wrong Answer,"N = int(input()) if 1<= N <= 1000000000000001: moji = 'abcdefghijklmnopqrstuvwxyz' for i in range(12): if N // 26 **i == 0: max_i = i-1 break amari = N syo = 0 kai = """" p = 0 for j in range(1,max_i+1): p = max_i +1 -j syo = amari // 26 ** p amari = amari % 26 ** p kai += moji[syo - 1] kai += moji[amari - 1] print(kai)" p02629,s058581174,Wrong Answer,"n = int(input()) al = [""0"",""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""] re = [] while(n != 0): am = n%26 n = n//26 re.append(al[am]) re.reverse() for i in re: print(i,end="""") " p02629,s478532409,Wrong Answer,"N = int(input()) alf = [chr(i) for i in range(97, 97+26)] List = [] for i in range(100): if N > 26: a = N % 26 N = N // 26 List.append(alf[a-1]) else: List.append(alf[N-1]) break print("""".join(List)) " p02629,s289251970,Wrong Answer,"N = int(input()) s = [] k = 0 while N > 0: l = N % 26 #一番下のけた s.insert(0,chr(ord('a')+l-1)) N = N // 26 k +=1 print(''.join(s)) " p02629,s246795643,Wrong Answer,"N=int(input()) n=N listm=[] while n!=0: m=n%26 n=n//26 listm.append(m) list_ans=[] l=0 for i in range(N): try: ans=chr(listm[i]+96) list_ans.append(ans) l+=1 except IndexError: break ans='' for i in range(l): ans=ans+list_ans[l-i-1] print (ans)" p02629,s311388316,Wrong Answer,"n = list(input()) for i in range(len(n)): n[i] = int(n[i]) def base_convert(nl, ibase, obase): o = [] while any(nl): c = 0 for i in range(len(nl)): c = c * ibase + nl[i] nl[i],c = divmod(c,obase) o.append(c) o.reverse() return o x = base_convert(n, 10, 26) ans = """" for i in x: ans += chr(ord('a') + i-1) if ans[-1] == ""`"": ans = ""z""*(len(ans)-1) print(ans)" p02629,s558697898,Wrong Answer,"n = int(input()) alphabet = 'abcdefghijklmnopqrstuvwxyz' n -= 1 ans = '' while n >= 0: ans += alphabet[n % 26] n //= 26 n -= 1 print(ans) " p02629,s700308435,Wrong Answer,"n=int(input()) ans='' i=1 while n>0: t=n%26 if t==0: t=26 ans=chr(t+ord('a')-1)+ans n=n//26 print(ans)" p02629,s265800531,Wrong Answer,"from bisect import bisect_left, bisect_right N = int(input()) MOJI = [26] for i in range(2,12): MOJI.append(MOJI[i-2]+26**i) print(MOJI) C = bisect_left(MOJI, N)+1 if N in MOJI: print(""z""*C) exit() ans = [] for i in range(C-1,-1,-1): tmp = N//(26**i) ans.append(chr(tmp+ord(""a"")-1)) N = N%(26**i) L=[str(a) for a in ans] L="""".join(L) print(L)" p02629,s492338926,Wrong Answer,"N=int(input()) List='abcdefghijklmnopqrstuvdxy' Ans='' while N>=1: Amari=N%26 if Amari==0: Ans='z'+Ans else: Ans=List[Amari-1]+Ans N=(N-1)//26 print(Ans)" p02629,s968775888,Wrong Answer,"N_MAX = 1 ** 15 letters=list(""abcdefghijklmnopqrstuvwxyz"") A_TO_Z = len(letters) N = int(input()) q = N r = [] while q != 0: r.insert(0, q % A_TO_Z) q = q // A_TO_Z print(r) for i in r: print(letters[i-1],end="""")" p02629,s587600102,Wrong Answer,"alp=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','z'] n=int(input()) ans="""" while n>0: a=n%26 ans+=alp[a-1] n=int(n//26) print(ans[::-1])" p02629,s894684829,Wrong Answer,"n = int(input()) t = 26 ans = 0 for i in range(1,12): res = (t**i) ans += res if ans >= n: len = i break res1,res2 = divmod(n,26) res = """" if n == ans: res = ""z""*i elif res1 < 1: res = chr(res2+96) elif res1>26: while n>0: div,mod = divmod(n,26) res += chr(mod+96) n //= 26 res = res[::-1] else: res += chr(res1+96)+chr(res2+96) if res2>0 else chr(res1+95)+""z"" print(res) " p02629,s412219845,Wrong Answer,"N = int(input()) ans = [] while N > 0: val = N cnt = 0 while val > 26: val = val // 26 cnt += 1 X = N // (26 ** cnt) N -= X * (26 ** cnt) if cnt == 1 and N == 0: ans.append(chr(X+96-1)) ans.append(chr(26+96)) break elif cnt == 1 and N > 0: ans.append(chr(X+96)) ans.append(chr(N+96)) break else: ans.append(chr(X+96)) print(''.join(ans))" p02629,s809452481,Wrong Answer,"N = int(input()) S = [chr(i) for i in range(ord(""a""), ord(""z"")+1)] tmp = N cnt = 0 l = [] while True: q, r = divmod(tmp, 26) l.append([r, cnt]) cnt += 1 if q == 0: break tmp //= 26 ans = """" for a, b in l: ans = S[a-1] + ans print(ans)" p02629,s835945111,Wrong Answer,"name = '' num = int(input()) while(num > 0): if num%26 != 0: name += chr((num%26)+96) num = num//26 else: name += chr((num%26)+96) num = num//26 - 1 print(name[::-1])" p02629,s135934052,Wrong Answer,"s = 'abcdefghijklmnopqrstuvwxyz' n = int(input()) ans = '' while n > 25: ans += s[(n % 26)-1] n = n // 26 ans += s[n%26-1] print(ans[-1::-1])" p02629,s219730200,Wrong Answer,"N = int(input()) ans = """" if N % 26 == 0: i = 1 a = N while True: a = a//26 if a <= 26: print(""z""*i) break i+=1 else: a = N; b = N; i = 1 while True: if a <= 26: ans = chr(ord(""a"")+a-1) + ans break b = a % 26 ans = chr(ord(""a"")+b-1) + ans a = a // 26 i += 1 print(ans)" p02629,s697624196,Wrong Answer,"N = int(input()) abc = [a for a in 'zabcdefghijklmnopqrstuvwxy'] t = 26 ** 12 temp =[] result = '' isWarikireta = False while t != 1: amari = N % t if amari == 0: temp.append(0) isWarikireta = True else: if N // t > 0: temp.append(str(N//t)) N = amari t //= 26 for t in temp: result += abc[int(t) % 26] if not isWarikireta: result = result + abc[N % 26] #print('temp') #print(temp) print(result) " p02629,s742355942,Wrong Answer,"X = int(input()) def Base_10_to_n(X, n): alphabet = 'zabcdefghijklmnopqrstuvwxy' if (int((X-1)/n)): return Base_10_to_n(int(X/n), n)+alphabet[X%n] return alphabet[X%n] print(Base_10_to_n(X, 26)) " p02629,s475133526,Wrong Answer,"N = int(input()) alpha = 'zabcdefghijklnmopqrstuvwxyz' ans = '' while N != 0: i = N % 26 N-=1 ans = alpha[i] + ans N //= 26 print(N) print(ans)" p02629,s628677017,Wrong Answer,"n = int(input()) i = 1 while n > 26 ** i : n = n - 26 ** i i += 1 an = [] while i > 0 : k = n // (26 ** (i - 1)) n -= (26 ** (i-1)) * k an.append(k) i -= 1 ans = [] for j in an : ans.append(chr(96 + j + 1)) del ans[len(ans)- 1] ans.append(chr(96 + j) ) print(''.join(map(str,ans))) " p02629,s187574595,Wrong Answer,"def base(n, b, digits=""abcdefghijklmnopqrstuvwxyz""): if n == 0: return 'a' s = [] p = abs(n) while p: s.append(digits[p % b-1]) p //= b return ''.join(reversed(s)) n = int(input()) s = base(n,26) print(s)" p02629,s101334426,Wrong Answer,"num = int(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""] def Base_10_to_n(X, n): X_dumy = X out = [] while X_dumy>0: out.append(X_dumy%n) X_dumy = int(X_dumy/n) return out name_nums = Base_10_to_n(num,26) name_nums.reverse() ans = """" for name_num in name_nums: ans += alphabet[name_num-1] print(ans)" p02629,s509446285,Wrong Answer,"n = int(input()) k = [0 for i in range(11)] l = [0 for i in range(11)] tmp = n for i in range(11): k[i] = tmp//26**(10-i) l[i] = tmp%26**(10-i) tmp = l[i] ans = """" s = ""abcdefghijklmnopqrstuvwxyz"" flg = 0 for i in range(11): if k[i] != 0: flg = 1 if flg == 1: ans += s[k[i]-1] print(ans)" p02629,s530804131,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())) num = I() result = """" alphabet = [chr(ord('a') + i) for i in range(26)] while True: result = alphabet[num % 26 - 1] + result num = num // 26 if num == 0: break print(result, end = '')" p02629,s759364699,Wrong Answer,"n = int(input()) ans = '' while n > 0: ans += chr(ord('a') + n % 26) n //= 26 print(ans[::-1]) " p02629,s867617207,Wrong Answer,"n = int(input()) ans = """" while n: ans += chr(96 + n % 26) n //= 26 print(ans[::-1])" p02629,s515588502,Wrong Answer,"string_array = [chr(i) for i in range(97, 97+26)] print(string_array) value = int(input()) value_range = 0 for l in range(1, 12): value_range += 26**l if value_range >= value: break answer_array = [] for l in range(1, l+1): q = value // 26 r = value % 26 if r == 0: q -= 1 answer_array.append(r) n = q print(answer_array) answer = '' for i in answer_array[::-1]: answer += string_array[i-1] print(answer) " p02629,s548069397,Wrong Answer,"from collections import deque import sys alphabet = [chr(i) for i in range(97, 97+26)] n = int(input()) if n <= 26: print(alphabet[n-1]) sys.exit() ans = deque() tobe_devided = n while True: q,r = divmod(tobe_devided,26) if q < 26: ans.appendleft(alphabet[r-1]) if q != 0: ans.appendleft(alphabet[q-1]) break ans.appendleft(alphabet[r-1]) tobe_devided = q ans = map(str,ans) print(''.join(ans))" p02629,s263872902,Wrong Answer,"from sys import stdin def Base_10_to_n(X, n): alpha = ""0abcdefghijklmnopqrstuvwxyz"" X_dumy = X out = '' while X_dumy>0: new = alpha[X_dumy%n] out = new+out X_dumy = int(X_dumy/n) return out def main(): n = int(input()) x16_expr = Base_10_to_n(n, 26) print(x16_expr) if __name__ == ""__main__"": main()" p02629,s558165816,Wrong Answer,"n = int(input()) li = [] count = 0 val = 1 while(True): val *= 27 count += 1 if (val > n): break for i in range(count-1,-1,-1): val2 = n // pow(26,i) li.append(val2) n -= (val2 * pow(26,i)) for i in li: print(chr(96+i),end="""")" p02629,s317330721,Wrong Answer,"N = int(input()) ans = """" while N != 0: a, r = N//26, N%26 # print(a,r) ans = chr(ord(""a"") + r-1) + ans N = N//26 print(ans) " p02629,s036473963,Wrong Answer,"def main(): n = int(input()) num = n name = [] cap = [chr(i) for i in range(97, 97+26)] cap.insert(0, 'z') del cap[-1] if n == 26: return 'z' while n >= 27: last = n % 26 n = n // 26 name.insert(0, cap[last]) if num % 26 == 0: last = (n % 26)-1 else: last = n% 26 name.insert(0, cap[last]) ans = """".join(name) return ans print(main())" p02629,s721989035,Wrong Answer,"kigou=list(""0abcdefghijklmnopqrstuvwxyz"") a=int(input()) keta=0 count=0 counter=[0] for i in range(1,100): x=26**i+count if 26**i+count>=a: keta=i counter.append(x) break else: count+=26**i counter.append(count) ans="""" for i in range(keta): # a -= 1 ans=kigou[a%26]+ans a=a//26 print(ans)" p02629,s859429199,Wrong Answer,"N = int(input()) i = 0 while N >= 26**i: i+=1 i-=1 alpha = ['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'] result = '' num = 0 while N != 0: num,N = divmod(N,26**i) result += alpha[num-1] i-=1 print(result)" p02629,s507692238,Wrong Answer,"n = int(input()) characters = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','t','u','v','w','x','y','z'] s = 26 H = [] for i in range(1, 20): if s**i > n: break else: H.append(s**i) H.append(1) answer = '' for i, h in enumerate(sorted(H, reverse=True)): number = int(n/h) if i == 0: answer += characters[number-1] else: answer += characters[number-1] n -= h*number print(answer)" p02629,s600315912,Wrong Answer,"N = int(input()) N -= 1 alphabets = [] for i in range(26): alphabets.append(chr(ord(""a"")+i)) ans = """" i = 0 while N > 0: if i != 0: N -= 1 ans += alphabets[N%26] N //= 26 i += 1 print(ans[::-1]) " p02629,s267206425,Wrong Answer,"N = int(input()) import string alphabets = string.ascii_lowercase result = """" tmp = N n = 26 while tmp >= n: idx = tmp%n - 1 result = alphabets[idx] + result tmp = int(tmp/n) idx = tmp%n - 1 result = alphabets[idx] + result print(result)" p02629,s552339214,Wrong Answer,"n = int(input()) a = ""zabcdefghijklmnopqrstuvwxy"" alist = list(a) c, d = 0, 0 name = """" namelist = [] while 1: c = n//26 d = n%26 n = c namelist.append(alist[d]) if n == 0: break namelist.reverse() name = """".join(namelist) print(name)" p02629,s175600617,Wrong Answer,"def main(): n = int(input()) i = 1 ans = '' while True: rem = n % 26 ans += chr(rem + 96) # n -= 26 ** i n //= 26 if n == 0: break i += 1 ans = ans[::-1] # 文字列の反転 print(f'{ans}') if __name__ == '__main__': main()" p02629,s511207154,Wrong Answer,"n = int(input()) if n%26 == 0: total = 0 x = 0 while True: x += 1 if n == total+26**x: print (""z""*x) exit () total += 26**x def B(X, n): if (int(X/n)): return B(int(X/n), n)+str(X%n)+"","" return str(X%n)+"","" l = list(B(n,26).split("","")) del l[-1] ans = """" for i in l: ans += chr(96+int(i)) print (ans) " p02629,s247995885,Wrong Answer,"N = int(input()) moji = [chr(i) for i in range(97, 97+26)] lst = [0] n = 0 for i in range(1,12): n = n + 26 ** i lst.append(n) keta = 0 for i in range(len(lst)): if N <= lst[i]: keta = i break x = keta ans = [] for i in range(keta): tmp = N // (26**(x-1)) if tmp == 27: tmp -= 1 ans.append(tmp) N -= tmp * (26**(x-1)) x -= 1 answer = '' for i in ans: answer += moji[i-1] print(answer)" p02629,s725488558,Wrong Answer,"N = int(input()) dic = {} for i in range(1, 27): dic[i] = chr(97 + i -1) del dic[26] dic[0] = ""z"" temp = N ans = """" if temp <= 26: ans += dic[temp % 26] else: while temp // 26 > 0: aa = temp % 26 ans += dic[aa] temp = temp // 26 if temp <= 26: ans += dic[temp % 26] ans = ans[::-1] print(ans) " p02629,s656696342,Wrong Answer,"N = int(input()) alpha = ['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 = '' while N != 0: k, l = 0, 0 for i in range(11): if 26**i <= N < 26**(i+1): k = i break for i in range(1, 26): if (26**k)*i <= N < (26**k)*(i+1): l = i break ans = ans + alpha[l-1] N -= 26**k*i print(ans)" p02629,s562013913,Wrong Answer,"n = int(input()) amari = [] j = 1 while True: if n >= 26: amari.append(n%26) n = n//26 else: amari.append(n) break gyaku = amari[::-1] arufa = [chr(i) for i in range(97, 97+26)] [print(str(i-1)+arufa[i-1],end="""") for i in gyaku] " p02629,s853428163,Wrong Answer,"n = int(input()) ascii_letters = 'abcdefghijklmnopqrstuvwxyz' minus=1 for i in range(1,15): if n<=26**i: order=i n-=minus break else: minus+=26**i for i in range(order): print(ascii_letters[n//(26**(order-i-1))],end='') n%=(26**(order-i-1)) print()" p02629,s834401594,Wrong Answer,"n = int(input()) def base_10_to_n(N, x): out = '' while N>0: if N%x == 0: N+=1 out = chr(96+N%x)+out N = int(N/x) print(out) base_10_to_n(n, 26)" p02629,s783121933,Wrong Answer,"n=int(input()) A=list() ans='' while n>=26: n=n//26 s=n%26 print(n,s) ans+=(chr(s+96)) ans+=(chr(n+96)) print(ans)" p02629,s571254674,Wrong Answer,"al = ['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()) tmp = 26 ans = '' while True: ans += al[N%26-1] if N <= 26: break N = N // tmp print(ans[::-1])" p02629,s118518125,Wrong Answer,"N = int(input()) alphabets = ""abcdefghijklmnopqrstuvwxyz"" s = """" while N > 26: N, mod = divmod(N, 26) s += alphabets[mod - 1] s += alphabets[N - 1] while True: prev_s = s s = s.replace('aa','z') if prev_s == s: break print(s)" p02629,s205334439,Wrong Answer,"N = int(input("""")) Q = [N] R = [ ] i = 1 while (26**(i-1) <= N ): Q.append(Q[i-1] // 26) R.append(Q[i-1] % 26) i += 1 # print(Q) # print(R) R.reverse() L = [i for i in ""abcdefghijklmnopqrstuvwxyz""] for i in R: print(L[i-1],end='')" p02629,s304676596,Wrong Answer,"N = int(input()) l = 'abcdefghijklmnopqrstuvwxyz' s = '' n = 1 while(N>0): a = N % 26 s += l[a-1] N //= 26 N-=1 print(s[::-1])" p02629,s095719333,Wrong Answer,"# coding: utf-8 N = int(input()) alp = [chr(i) for i in range(97, 97+26)] S = 0 for i in range(1,100): S += 26**i if S >= N: keta = i break #print(keta) ans = """" for i in range(keta-1, -1, -1): #print(N, N//(26**i)) ans += alp[min(N//(26**i)-1,25)] N %= 26**i print(ans)" p02629,s264106914,Wrong Answer,"n=int(input()) s="""" l="" abcdefghijklmnopqrstuvwxyz"" while n>0: r=n%26 n//=26 s+=l[r] print(s[::-1])" p02629,s090286959,Wrong Answer,"N = int(input()) a = 0 ans = '' print('ans') Nn = N while Nn > 26: a = a+1 Nn = int(Nn/26) print(a, Nn) for i in range(a): b = chr(N%(26^i)+64) a = a -1 print(b) ans = ans + b ans = ans + chr(N%26 + 64) print(ans.lower())" p02629,s033202792,Wrong Answer,"n=int(input()) n2=n l=1 while 26**l<=n2: n2-=26**l l+=1 ans=[] o=26**(l-1) # while n: # ad=n//o # ans.append(ad) # n%=o # o//=26 while n: if n%26==0: ans.append(26) else: ans.append(n%26) n//=26 ans=[chr(ord(""a"")+ai-1) for ai in ans][::-1] print(''.join(ans)) " p02629,s430372236,Wrong Answer,"n=int(input()) n2=n l=1 while 26**l<=n2: n2-=26**l l+=1 ans=[] o=26**(l-1) while n: ad=n//o ans.append(ad) n%=o o//=26 ans=[chr(ord(""a"")+ai-1) for ai in ans] print(''.join(ans)) " p02629,s953348652,Wrong Answer,"N = int(input()) ans = [] for i in range(200): n = N%26 if n == 0: n=26 ans.insert(0,chr(n+96)) N_ = (N-1)//26 N = N//26 if N==0 or N_ == 0: break print("""".join(ans))" p02629,s596180043,Wrong Answer,"from sys import stdin N = int(stdin.readline().rstrip()) alphabets = ""abcdefghijklmnopqrstuvwxyz"" index = 1 tot = 0 while(True): tot += pow(26,index) if(N<=tot): break index = index+1 output_str = """" aaaa = 26 for i in range(1,index+1,1): temp = N%aaaa temp2 = int(temp/(aaaa/26)) output_str = alphabets[temp2-1] + output_str aaaa = aaaa*26 print(output_str) " p02629,s232831100,Wrong Answer,"n = int(input()) a = [] while n > 0: a.append(n % 26) n //= 26 #print(a) a.reverse() #print(a) s = """" for i in range(len(a)): s += chr(a[i] + 96) print(s)" p02629,s773920383,Wrong Answer,"n=int(input()) s='' while n!=0: n,v=divmod(n,26) s+=chr(96+v) print(s[::-1])" p02629,s251136831,Wrong Answer,"n = int(input()) ascii_letters = 'abcdefghijklmnopqrstuvwxyz' minus=1 for i in range(1,12): if n<=26**i: order=i n-=minus break else: minus+=26**i for i in range(order): print(ascii_letters[n//(26**(order-i-1))],end='') n%=(26**(order-i-1)) print()" p02629,s322680764,Wrong Answer,"n = int(input()) k = 1 m = 0 abc_list = list(""abcdefghijklmnopqrstuvwxyz"") for i in range(1, 11): m = n n = n - 26 ** i if n > 0: k += 1 else: break l =[] for j in range(k - 1, 0, -1): l.append((m - 1)// (26 ** j)) m = m % (26 ** j) l.append(m - 1) answer = [] for i in l: if i == 26: i = 25 answer.append(abc_list[i]) print("""".join(answer))" p02629,s276256116,Wrong Answer,"n = int(input()) s = [chr(ord(""a"")+i) for i in range(26)] num, i = 26, 1 while n - num > 0: i += 1 num += pow(26, i) ans = """" while i > 0: tmp = 0 for j in range(1, 27): if n - j*pow(26, i-1) < 0: break tmp = j ans += s[tmp- 1] n -= tmp*pow(26, i-1) i -= 1 print(ans)" p02629,s467192560,Wrong Answer,"n = int(input()) c = 0 n1 = n for i in range(1,11): a = n1 - 26**(i) c += 1 if a <= 0: break n1 = n1 - 26**(i) a = """" for i in range(c): if n // 26**(c-i-1) >= 26: alpha = 26 n = n - 26**(c-i-1) else: alpha = n // 26**(c-i-1) n = n % 26**(c-i-1) a += chr(96 + alpha) print(a)" p02629,s962477236,Wrong Answer,"N=int(input()) abc=[chr(i) for i in range(97, 97+26)] ans="""" while N>0: ans+=(abc[N%26-1]) N//=26 print(ans[::-1])" p02629,s609081872,Wrong Answer,"N = int(input()) ans = '' for i in range(100): ans = chr(ord('a') + (N-1) % 26) + ans N //= 26 if N == 0: break print(ans)" p02629,s496480872,Wrong Answer,"n=int(input()) alp='0abcdefghijklmnopqrstuvwxyz' ########関数部分############## 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) ############################ l=list(Base_10_to_n(n,26).split()) ans='' for i in range(len(l)): ans+=alp[int(l[i])] print(ans)" p02629,s236860792,Wrong Answer,"n=int(input()) a=[] m=n%26 if n%26 !=0 else 26 a.append(m) while n>26: n=n//26 m=n%26 a.append(m if m!=0 else 26) for i in reversed(range(len(a))): print(chr(96+a[i]),end="""") " p02629,s197353328,Wrong Answer,"N = int(input()) x = [] while N > 0: N, i = divmod(N, 26) if i == 0: x.append('z') else: x.append(chr(i + 96)) if N == 1 & i == 0: break print(''.join(x))" p02629,s055071877,Wrong Answer,"import numpy as np import string as str N = int(input()) low_letters = str.ascii_lowercase name = '' while True: b = N % 26 name = name + low_letters[b-1] if N < 26: break a = N // 26 N = a print(name[::-1])" p02629,s361040193,Wrong Answer,"N = int(input()) #if 1<= N <= 1000000000000001: s = list('abcdefghijklmnopqrstuvwxyz') u = """" for i in range(12,0,-1): K = N // (26 ** i) N = N % (26 ** i) if K >0: u += s[(K - 1)] u += s[(N - 1)] print(u)" p02629,s727599967,Wrong Answer,"N = int(input()) ans = [] while N != 0: k = N % 26 if k == 0: k += 26 ans.append(chr(96 + k)) N -= k N //= 26 print(''.join(ans))" p02629,s390701263,Wrong Answer,"d = 1000000000000001 n = int(input()) abc = ""abcdefghijklmnopqrstuvwxyz"" len = len(abc) list = [] while True: if 0 < n < len: list.append(n) break elif n == 0: break list.append(n % len) n = n // len list.reverse() name = """" for i in list: name += abc[i-1] print(name)" p02629,s733186278,Wrong Answer,"N = int(input()) alpha = 'abcdefghijklmnopqrstuvwxyz' ans = '' while N > 0: ans += alpha[N%26-1] N = N//26 print(ans)" p02629,s013696784,Wrong Answer,"N=int(input()) alpha='zabcdefghijklmnopqrstuvwxy' def mod26(n): mods=[] m=n while m>0: mods+=[m%26] m=m//26 return mods def revs(n): mods=mod26(n) le=len(mods) al=[alpha[mods[i]] for i in range(le-1,-1,-1)] return ''.join(al) print(revs(N))" p02629,s953361241,Wrong Answer," 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) s = list(map(int,input().split())) n=s[0] dic={} for i in range(97, 97+26):dic[i-96]=chr(i) dic[0] = 'z' a = Base_10_to_n(n, 26) a=a.split(' ') ans='' for i in a: ans+=dic[int(i)] print(ans)" p02629,s834524071,Wrong Answer,"n = int(input()) def f(n): q, mod = divmod(n,26) if q==0: mod = mod-1 return chr(97+mod) mod = mod-1 return f(q)+chr(97+mod) print(f(n))" p02629,s546231452,Wrong Answer,"N = int(input()) ans = '' while True: n = int(N / 26) r = N % 26 ans = chr(96 + r) + ans if n == 0: break else: N = n print(ans)" p02629,s470164177,Wrong Answer,"name = [] N = int(input()) while N > 0: N, mod = divmod(N, 26) if mod == 0: mod = 1 name.insert(0,chr(96+mod)) name=''.join(name) print(name) " p02629,s731849651,Wrong Answer,"import string N = int(input()) alphabet = list(string.ascii_lowercase) num2alphabet = {i + 1: a for i, a in enumerate(alphabet)} num2alphabet[0] = ""z"" ans = """" while N > 0: num = N % 26 ans += num2alphabet[num] if N % 26 == 0: break N = N // 26 print(''.join(list(reversed(ans)))) " p02629,s869618660,Wrong Answer,"N = int(input()) alps = 'abcdefghijklmnopqrstuvwxyz' def cnv(X, n): if X//n: return cnv(X//n, n) + [X%n] return [X%n] ans = cnv(N, 26) print(''.join(list(map(lambda x: alps[x - 1], ans))))" p02629,s559625022,Wrong Answer,"import sys sys.setrecursionlimit(10 ** 7) rl = sys.stdin.readline def solve(): N = int(rl()) ans = [] while N: ans.append(chr(ord('a') + N % 26 - 1)) N //= 26 print(''.join(reversed(ans))) if __name__ == '__main__': solve() " p02629,s549078418,Wrong Answer,"N=int(input()) num2alpha = lambda c: chr(c+96) x=[] while N//26>0: x.append(N%26) N=N%26 x.append(N) ans=[] for i in range(len(x)): ans.append(num2alpha(x[i])) print(''.join(ans)) " p02629,s084622356,Wrong Answer,"n = int(input()) alp = 'abcdefghijklmnopqrstuvwxyz' ans = '' while n > 0: l = n // 26 m = n % 26 ans += alp[m-1] n = l print(ans[::-1]) " p02629,s718535941,Wrong Answer,"n=int(input()) a=n count=0 for i in range(11): if a-26**(i+1)>=0: a-=26**(i+1) count+=1 else: break #print(a) #print(count) ans=[] for j in range(count): #for j in range(i+1): ans.append(a//26**(count-j)) a%=26**(count-j) ans.append(a%26-1) #print(ans) m=len(ans) #print(m) letter=[] for i in range(m): #print(chr(97+ans[i])) letter.append(chr(97+ans[i])) print(''.join(letter)) " p02629,s357120839,Wrong Answer,"n=int(input()) a=[] q=n//26 r=n%26 for i in range(15): a.insert(0,r) r=q%26 q=q//26 b=[] for j in range(15): x=int(a[j]) if x==0: continue else: x=chr(x+96) b.append(x) c="""".join(b) c.replace(""0"","""") print(c)" p02629,s859692417,Wrong Answer,"def num2alpha(num): if num<=26: return chr(64+num) elif num%26==0: return num2alpha(num//26-1)+chr(90) else: return num2alpha(num//26)+chr(64+num%26) n=int(input()) print(num2alpha(n)) " p02629,s320670993,Wrong Answer,"from collections import deque def to_char(n): base = ord('a') return chr(base + n) def main(): N = int(input()) - 1 q = deque([]) v = N % 26 q.appendleft(v) N //= 26 while N > 0: v = (N - 1) % 26 q.appendleft(v) N //= 26 # print(q) if q[0] == 0: q.popleft() print(''.join(map(to_char, q))) if __name__ == '__main__': main() " p02629,s657463545,Wrong Answer,"n = int(input()) result = '' for i in range(9): tmp1 = n % 26 tmp2 = n // 26 print(tmp2, tmp1, (tmp1+25)%26) result = chr(97 + (tmp1+25)%26)+result if n < 27: break else: n = tmp2 print(result)" p02629,s132045496,Wrong Answer,"N= int(input()) mylist =[] while N >25: b = N%26 mylist.append(b) N = N//26 mylist.append(N) num = [""z"",""a"",""b"",""c"",""d"",""e"",""f"",""g"",""h"",""i"",""j"",""k"",""l"",""n"",""m"",""o"",""p"",""q"",""r"",""s"",""t"",""u"",""v"",""w"",""x"",""y""] ans = [] for i in reversed(mylist): ans.append(num[i]) ans print(''.join(ans))" p02629,s275435707,Wrong Answer,"n = int(input()) ans = """" while n > 0: ans += chr(n%26 + 96) n //= 26 print(ans[::-1])" p02629,s820549245,Wrong Answer,"# -*- coding: utf-8 -*- import sys sys.setrecursionlimit(10**9) INF=10**18 MOD=10**9+7 input=lambda: sys.stdin.readline().rstrip() YesNo=lambda b: bool([print('Yes')] if b else print('No')) YESNO=lambda b: bool([print('YES')] if b else print('NO')) int1=lambda x:int(x)-1 N=int(input()) ans=[] a=ord('a')-1 while N: ans.append(chr(N%26+a)) N//=26 ans.reverse() print(''.join(ans))" p02629,s440332675,Wrong Answer,"from itertools import count from string import ascii_lowercase def get_length(n): dogs = 0 for i in count(1): dogs += 26 ** i if n <= dogs: return i def get_name(n): length = get_length(n) if n <= 26: return ascii_lowercase[n - 1] else: return get_name(n // 26 ** (length - 1)) + get_name(n % 26 ** (length - 1)) N = int(input()) print(get_name(N)) " p02629,s093660484,Wrong Answer,"n = int(input()) alpha = '*abcdefghijklmnopqrstuvwxyz' n_div = [] while n > 26: n_div.append(n % 26) n //= 26 n_div.append(n) ans = '' for i in n_div[::-1]: ans += alpha[i] print(ans)" p02629,s905842451,Wrong Answer,"def main(): N = int(input()) digits = list() while N > 0: digits.append(N % 26) N //= 26 digits.reverse() ans = '' for d in digits: ans += chr(d - 1 + ord('a')) print(ans) if __name__ == '__main__': main()" p02629,s454077712,Wrong Answer,"N = int(input()) pow = 1 while True: if N <= 26**pow: break pow += 1 n = N - 26**(pow-1) s = [] for i in range(pow-1, -1, -1): print(i) q = n // (26**i) s.append(q) n = n % (26**i) name = '' for i in range(len(s)): if i == 0: name = name + 'abcdefghijklmnopqrstuvwxyz'[s[i]] else: name = name + 'abcdefghijklmnopqrstuvwxyz'[s[i]-1] print(name)" p02629,s571069576,Wrong Answer,"N = int(input()) res = '' chars = 'Xabcdefghijklmnopqrstuvwxyz' while N > 0: amari = N % 26 if amari == 0: amari = 26 # res += chr(96 + amari) res += chars[amari] N //= 26 print(res[::-1]) " p02629,s558157808,Wrong Answer,"N=int(input()) alpha=["""",""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""] name="""" for i in range(N): name+=alpha[int(N%26)] N/=26 print(name)" p02629,s264257077,Wrong Answer,"N = int(input()) N -= 1 M = N count = 0 alpha = ""abcdefghijklmnopqrstuvwxyz"" output = """" if N == 26: count += 1 while N >= 27: N = N // 26 count += 1 for i in range(1,count+1): M = M - 26 ** i for _ in range(count): if M >= 26: mod = M % 26 M = M // 26 output = alpha[mod] + output else: output = alpha[M] + output output = alpha[M] + output print(output)" p02629,s870177710,Wrong Answer,"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) from sys import stdin N = int(input()) alphabets = ['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'] x26 = Base_10_to_n(N, 26) result = """" for i in range(0, len(x26)): a = int(x26[i]) b = alphabets[a - 1] result += b print(result)" p02629,s381477534,Wrong Answer,"n = int(input()) alpha_arr = [chr(i) for i in range(97, 97+26)] ans = [] a, b = divmod(n, 26) if b != 0: ans.insert(0, alpha_arr[b - 1]) else: ans.insert(0, 'z') while True: if a == 0: break else: if b == 0 and a < 2: break a, b = divmod(a, 26) if b != 0: ans.insert(0, alpha_arr[b - 1]) else: ans.insert(0, 'z') print(''.join(ans))" p02629,s515335416,Wrong Answer,"num=int(input()) 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) ans=num2alpha(num) print(ans)" p02629,s058098158,Wrong Answer,"# One Quadrillion and One Dalmetians N = int(input()) Q = [N] R = [] name =[] i = 0 while Q[i] // 26 != 0: Q.append(Q[i] // 26) R.append(Q[i] % 26) i += 1 name.append(chr(Q[i]+96)) while i != 0 : i -= 1 name.append(chr(R[i]+96)) print(''.join(name)) " p02629,s636685746,Wrong Answer,"N = int(input()) ans = '' i = 1 while N > 0: ans = chr(ord('a') + N % (26) - 1) + ans N = (N-1) // 26 print(ans) exit() " p02629,s223780689,Wrong Answer,"def LI(): return list(map(int, input().split())) def I(): return map(int, input().split()) mod = 10**9 + 7 dog = 10 ** 15 + 1 def main(): n = int(input()) memo = [] for i in range(10,-1,-1): memo.append(n // (26**i)) n -= 26**i * (n//(26**i)) ans = '' alphabet = 'abcdefghijklmnopqrstuvwxyz' for i in memo: if i == 0: memo = memo[i+1:] else: break for i in memo: ans += alphabet[i-1] print(ans) if __name__ == '__main__': main()" p02629,s592021807,Wrong Answer,"import sys N = int(input()) alphabet = ""0abcdefghijklmnopqrstuvwxyz"" name = [] if N == 0: print(""a"") sys.exit() while N > 0: name += alphabet[N % 26] N //= 26 name.reverse() print("""".join(name))" p02629,s798648973,Wrong Answer,"N = int(input()) List = ['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'] nList = [] while True: if N % 26 != 0: nList.append(List[(N % 26)]) N = N // 26 else: break nList.reverse() print(''.join(nList))" p02629,s861869734,Wrong Answer,"n = int(input()) ans = """" while n > 26: n, mod = divmod(n, 26) ans = chr(ord(""a"")+mod-1) + ans ans = chr(ord(""a"")+n-1) + ans print(ans)" p02629,s446009973,Wrong Answer,"n=int(input()) a=[chr(ord('a') + i) for i in range(26)] l=[] cnt=0 inc=1 while True: cnt+=26**inc if cnt>=n: #print(inc) break inc+=1 s=0 if n<=26: l.append(n) for i in range(inc-1,0,-1): #print('i',i) x=n//26**(i) l.append(x) n=n-x*26**i #print(""n"",n,x) if n<=26: l.append(n) ans="""" print(l) for li in l: if li==0: li=26 ans+=chr(ord('a') + li-1) print(ans)" p02629,s933671238,Wrong Answer,"n = int(input()) result = '' def rec(n, result): q, mod = divmod(n, 26) if n == 0: return result result += chr(mod + 96) n = q return rec(n, result) result = rec(n, result) print(result[::-1]) " p02629,s516200009,Wrong Answer,"import math n = int(input()) length = 1 num = 26 l = [0,26] while True: if num >= n: break length += 1 num = 26 ** length + num l.append(num) ans = [] for i in range(length)[::-1]: if n < l[i]: ans.append('a') continue num = n - l[i] - 1 if num == -1: ans.append('z') continue tmp = 26 ** i #print(num, tmp, num // tmp) ans.append(chr(num // tmp + 97)) n = n % tmp #print(num, num // tmp, n) print(''.join(ans)) " p02629,s534843114,Wrong Answer,"num_to_alpha = ""zabcdefghijklmnopqrstuvwxy"" n = int(input()) ans = [] while n: num = n % 26 ans.append(num_to_alpha[num]) n //= 26 print(''.join(ans[::-1])) " p02629,s279395095,Wrong Answer,"N=int(input()) List='abcdefghijklmnopqrstuvdxyz' Ans='' while N>=1: Amari=N%26 if Amari==0: Amari=26 Ans=List[Amari-1]+Ans N=(N-1)//26 print(Ans)" p02629,s560180895,Wrong Answer,"import string N = int(input()) L = string.ascii_lowercase ans = [] while 1 < N//26 : ans.append(L[(N%26)-1]) N //= 26 else : ans.append(L[(N%26)-1]) ans.reverse() print("""".join(ans))" p02629,s636443818,Wrong Answer,"n = int(input()) alphabet = list(""abcdefghijklmnopqrstuvwxyz"") if n <= 26: print(alphabet[n-1]) else: ans = """" while(True): q, mod = divmod(n, 26) if mod == 0: q -= 1 ans = ""z"" + ans else: ans = alphabet[mod-1] + ans if q <= 1: break n = q print(ans)" p02629,s520726797,Wrong Answer,"NUM = int(input()) R = """" li = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] while NUM >= 26: R = li[(NUM % 26)-1] + R NUM = int(NUM/26) R = li[NUM-1] + R print(R)" p02629,s436042843,Wrong Answer,"n = int(input()) # # 名前の長さを求める i = 1 while 1: # print(i) if n <= 26 ** i: break else: n -= 26**i i += 1 print(i) name = """" n -= 1 for j in range(i): name += chr(ord('a') + n % 26) n //= 26 print(name[::-1])" p02629,s089334664,Wrong Answer,"# -*- coding: utf-8 -*- N = int(input()) # 26 ** 9 < 1000000000000001 < 26 ** 10 なので最大でも(9+1)桁の文字 index = [None] * 10 m = N for i in range(0, 10, 1): a = m % 26 if a == 0: index[i] = 26 else: index[i] = a if a == 0: m = (m // 26) - 1 else: m = m // 26 if m == 0: break word = '' for i in index: s = '' if i: s = chr(ord('a') + i - 1) word += s print(word[::-1])" p02629,s413449393,Wrong Answer,"n = int(input()) ans = '' i = 0 while True: if n < 26**i: break tmp = (n//(26**i)) % 26 ans = chr(tmp + 97 - 1) + ans i += 1 print(ans)" p02629,s838292857,Wrong Answer,"n = int(input()) a = 0 k = 0 while a <= n: k += 1 a += 26**k a -= 26**k k -= 1 ans = """" t = 'abcdefghijklmnopqrstuvwxyz' m = n - a if m != 0: for i in range(k, 0, -1): ans += t[int(m/(26**i))] m = m%(26**i) else: for i in range(k-1): ans += t[-1] ans += t[m-1] print(ans) " p02629,s506943798,Wrong Answer,"from collections import deque n = int(input()) a = 0 b = 0 tm = 0 while a < n: tm += 1 b = a a += 26 ** tm def base_10_to_n(x, n, tm): A = deque([]) if x == 0: A = deque([0 for i in range(tm)]) else: while x > 0: A.appendleft(x%n) x = int(x/n) return A L = base_10_to_n(n - b - 1, 26, tm) #print(a) #print(L) ans = '' for i in L: ans += chr(i + 97) print(ans)" p02629,s438096282,Wrong Answer,"#c M = int(input()) s='' a=['z','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'] while M>26: s+=a[M%26] M=M//26 s+=a[M%26] print(s[::-1])" p02629,s682027748,Wrong Answer,"n = int(input()) data = [26 ** x for x in range(1, 12)] d = 0 r = 0 for i in range(len(data)): d += data[i] if n <= d: r = i+1 break kurai = [26 ** x for x in range(r)][::-1] ans = [0] * r for i in range(r): ans[i]= min(n // kurai[i], 26) n -= kurai[i] * ans[i] alpha = [chr(i) for i in range(97, 97+26)] ans = [alpha[a - 1] for a in ans] print("""".join(ans))" p02629,s979814742,Wrong Answer,"n = int(input()) name = [] while n > 0: modulo = n % 26 name.append(chr(ord(""a"")+modulo-1)) n //= 26 print ("""".join(reversed(name)))" p02629,s345478034,Wrong Answer,"N = int(input()) ans = '' while N > 0: N -= 1 ans += chr(ord('a') + N % 26) N //= 26 print(ans[::-1])" p02629,s477112841,Wrong Answer,"N = int(input()) ans = 0 li = list(chr(i) for i in range(97, 134)) q, r = divmod(N, 26) ans = li[r - 1] while True: if q == 0: print(ans) exit() q, r = divmod(q, 26) ans = li[r - 1] + ans " p02629,s441298379,Wrong Answer,"n = int(input()) al = 'zabcdefghijklmnopqrstuvwxyz' num = [] while True: if n//26 == 0: num.append(n) break else: amari = n%26 n = n//26 num.append(amari) num.reverse() for nums in num: print(al[nums],end = """")" p02629,s203284971,Wrong Answer,"number = int(input()) Toname = [] name = [] for i in range(10,0,-1): waru = 26 ** i if number >= waru: Toname.append(number // waru) number = number % waru Toname.append(number) leng = len(Toname) for j in range(leng): Toname[j] += 96 name.append(chr(Toname[j])) print(''.join(name))" p02629,s172081788,Wrong Answer,"#! -*- coding: utf-8 -*- n = int(input()) """""" 26 ** 10 から値がたつか確かめる """""" counter = 10 counter_list = [] for i in reversed(range(0, 11)): result = n // (26 ** i) print(result) if result > 0: counter_list.append(chr(96 + result)) n %= (26 ** i) print(''.join(counter_list)) " p02629,s714550336,Wrong Answer,"N = int(input()) l = 'abcdefghijklmnopqrstuvwxyz' s = '' n = 1 while(N>26**n): n+=1 while(n>0): a = N//(26**(n-1)) s += l[a-1] N -= a*(26**(n-1)) n-=1 print(s)" p02629,s150916594,Wrong Answer,"n = int(input()) s = '' while (n > 0): r = n % 26 n //= 26 if r == 0: s = 'z' + s else: c = chr((r - 1) + ord('a')) s = c + s print(s)" p02629,s587430385,Wrong Answer,"import string def numberToBase(n, b): if n == 0: return [0] digits = [] while n: digits.append(int(n % b)) n //= b return digits[::-1] letters = {} for x, y in zip(range(1, 27), string.ascii_lowercase): letters[x] = y def toLetter(x): return letters[x] print(''.join(list(map(toLetter, numberToBase(123456789, 26))))) " p02629,s763085234,Wrong Answer,"n = int(input()) tag = ['','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] cnt = [] for i in range(10): if n//(26**(10-i)) != 0: cnt.append(n//(26**(10-i))) n = int(n%26**(10-i)) cnt.append(n) for i in range(len(cnt)-1): cnt[i] = tag[cnt[i]] cnt[-1] = tag[cnt[-1]] cnt = ''.join(cnt) print(cnt)" p02629,s545224245,Wrong Answer,"N=int(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""] l=1 num=26 while N>num: if N0: a=n%26 n//=26 l.append(chr(96+a)) l.reverse() ans=''.join(l) print(ans)" p02629,s859356200,Wrong Answer,"def main(): n = int(input()) chars = 'zabcdefghijklmnopqrstuvwxy' st = '' while True: a = n % 26 st += chars[a] n = n // 26 if n == 0: break res = ''.join(list(reversed(st))) print(res) main() " p02629,s289138907,Wrong Answer,"n = int(input()) p = [] while n >= 1: p.append(chr(n % 26 + 96)) n = n // 26 print(''.join(p[::-1]))" p02629,s248907733,Wrong Answer,"N = int(input()) alpha = list('abcdefghijklmnopqrstuvwxyz') ans = [] while N>0: N, d = N//26, N%26 if N==0: break ans.append(alpha[d-1]) ans = list(reversed(ans)) ans = """".join(ans) print(ans)" p02629,s504700544,Wrong Answer,"N=int(input()) a_l="""" i=1 while i: if N<26: i=0 l=chr(97+N-1) else: m = N % 26 N=N//26 l=chr(97+m-1) a_l=l+a_l print(a_l)" p02629,s296441328,Wrong Answer,"import itertools import math 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 = int(input()) num = Base_10_to_n(N,26) s = ['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'] st = [] while(N!=0): if N < 26: st.append(N%26) break st.append(N%26) N = N//26 for i in st[::-1]: print(s[i-1],end='') " p02629,s217906571,Wrong Answer,"def main(): n = int(input()) beki = [0, 26, 676, 17576, 456976, 11881376, 308915776, 8031810176, 208827064576, 5429503678976, 141167095653376, 3670344486987776] A = list(""abcdefghijklmnopqrstuvwxyz"") t = ['']*12 for i in range(12)[::-1]: d,m = divmod(n,26) t[i] = A[m-1] n = d if n == 0: break print(''.join(t)) if __name__ == '__main__': main()" p02629,s576434442,Wrong Answer,"N = int(input()) - 1 keta = 1 cumsum = 0 oldcumsum = 0 while True: cumsum += 26 ** keta if cumsum > N: break else: oldcumsum = cumsum keta += 1 N -= oldcumsum #N -= 1 print(keta) name = '' for k in range(1,keta+1): ch_n = N // (26 ** (keta - k)) ch = chr(ord('a') + ch_n) name += ch N -= ch_n * (26 ** (keta - k)) print(name)" p02629,s937619098,Wrong Answer,"n = int(input()) ans = [] alp = ['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'] while True: a,b = divmod(n,26) ans.append(alp[b - 1]) if a >= 26: n = a else: ans.append(""a"") break ans = ans[::-1] print("""".join(ans)) " p02629,s641429070,Wrong Answer,"N = int(input()) l = 'abcdefghijklmnopqrstuvwxyz' s = '' a = N % 26 s += l[a] N //= 26 while(N!=0): N -= 1 a = N % 26 s += l[a] N //= 26 print(s[::-1])" p02629,s242168194,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())) num = I() result = """" alphabet = [chr(ord('a') + i) for i in range(26)] while True: result = alphabet[num % 27 - 1] + result num = num // 27 if num == 0: break print(result, end = '') " p02629,s925472430,Wrong Answer,"# -*- coding: utf-8 -*- n = int(input()) r = '' def to_moji(x: int): return chr(96 + x) def devide(x, moji): a = x // 26 b = x % 26 if a < 1: moji = to_moji(b) + moji return moji elif 1 <= a and a <= 26: moji = to_moji(b) + moji moji = to_moji(a) + moji return moji else: moji = to_moji(b) + moji return devide(a, moji) print(devide(n, r)) " p02629,s726523357,Wrong Answer,"n=int(input()) ans="""" while n!=0: ans=chr(ord('a')+n%26-1)+ans n//=26 print(ans)" p02629,s091143799,Wrong Answer,"N=int(input()) def num2alpha(num): if num<=26: return chr(num+96) elif num%26==0: return num2alpha(num//26-1)+chr(96) else: return num2alpha(num//26)+chr(num%26+96) print(num2alpha(N))" p02629,s236422769,Wrong Answer,"#!/usr/bin/python3 import sys input = lambda: sys.stdin.readline().strip() n = int(input()) - 1 ans = [] while n > 0: ans.append(n % 26) n //= 26 print(*reversed([chr(ord('a') + x) if i == 0 else ('z' if x == 0 else chr(ord('a') + x - 1)) for i, x in enumerate(ans)]), sep='')" p02629,s605586166,Wrong Answer," 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)" p02629,s678535870,Wrong Answer,"n=int(input()) n-=1 ans=chr(n%26+97) while(n): n//=26 if n==0: break ans=chr(n%26+96)+ans print(ans) " p02629,s886293392,Wrong Answer,"n = int(input()) ans = '' while n != 0: s = n % 26 ans += chr(s + 96) n //= 26 print(ans[::-1]) " p02629,s062117525,Wrong Answer,"n = int(input()) moji = [chr(i) for i in range(97, 97+26)] name = '' while n >=1 and n <=1000000000000001: name += moji[(n%26)-1] n = n // 26 if ( n > 0 ): name += moji[(n%26)-1] new_str = name[::-1] print(new_str)" p02629,s034878720,Wrong Answer,"def main(): N = int(input()) digits = [] while True: a, b = N // 26, N % 26 digits.append(b) if a == 0: break N = a digits.reverse() chars = map(to_alphabet, digits) print(''.join(chars)) def to_alphabet(x: int): return chr(64 + x).lower() if __name__ == ""__main__"": main() " p02629,s909377462,Wrong Answer,"def _main(n): codes = ""abcdefghijklmnopqrstuvwxyz"" b = len(codes) values = """" while True: values += codes[int(n % b) - 1] n, mod = divmod(n, b) if n == 0 or (n == 1 and mod == 0): print(values[::-1]) break def _entry(): n = int(input()) _main(n) if __name__ == ""__main__"": _entry() " p02629,s031828578,Wrong Answer,"#!/usr/bin/env python3 char_list = [ chr(ord('a')+num) for num in range( 26 ) ] N = int(input()) def Base_10_to_n(X, n): if (int(X/n)): return Base_10_to_n(int(X/n), n)+str(char_list[(X%n)-1]) return str(char_list[(X%n)-1]) print(Base_10_to_n(N,26))" p02629,s970180478,Wrong Answer,"def base10to(n, b): if (int(n/b)): return base10to(int(n/b), b) + ' '+ str(n%b) return str(n%b) n = int(input()) al = 'abcdefghijklmnopqrstuvwxyz' ans = '' count = 26 if n <= count: print(al[n-1]) exit() else: a = list(map(int, base10to(n,26).split())) ans = '' for i in a: ans += al[i-1] print(ans)" p02629,s435865824,Wrong Answer,"N = int(input()) F = False g1 = 0 g2 = 0 for i in range(1, 15): g1 += 26**i - 26**(i-1) g2 += 26**i if i > 1 and g1 < N <= g2: F = True ALPHABET = ""abcdefghijklmnopqrstuvwxyzz"" S = """" X = """" while N > 0: Q, M = divmod(N, 26) S = ALPHABET[M - 1] + S N = Q if F: S = S[1:] print(S) " p02629,s837020954,Wrong Answer,"# coding: utf-8 N = int(input()) A = [] alp = [chr(i) for i in range(97, 97+26)] for i in range(100,-1,-1): A.append(N//26**i) N %= 26**i for i in range(101): if A[i] != 0: k = i #print(k) break A = A[k:] #print(A) ans = """" if A[-1]==0: ans = ""z"" * (len(A)-1) else: for a in A: ans += alp[a-1] print(ans)" p02629,s432402468,Wrong Answer,"from collections import defaultdict n = int(input()) - 1 ans = defaultdict(str) for i in range(26): ans[i] = chr(ord('a') + i) res = [] while True: if n: res.append(n%26) n //= 26 else: break res.reverse() for i, v in enumerate(res): if i < len(res)-1: print(ans[v-1], end='') else: print(ans[v]) " p02629,s909427820,Wrong Answer,"def main(): N = int(input()) lowercase = 'abcdefghijklmnopqrstuvwxyz' ans = '' for i in range(len(str(N))): j = N // 26**i % 26 - 1 if j < 0: break ans = lowercase[j] + ans print(ans) if __name__ == '__main__': main()" p02629,s205252620,Wrong Answer,"n = int(input()) ans = [] while n > 0: ans.append(chr(96 + (n % 26))) n //= 26 print(*ans[::-1], sep = '')" p02629,s031264972,Wrong Answer,"a_list = [chr(ord('a') + i) for i in range(26)] n = int(input()) l_list = [] ans = '' while n > 0: if n % 26 == 0: l_list.append(25) n = n // 26 - 1 else: l_list.append(n%26) n = n // 26 l_list = l_list[::-1] for i in l_list: ans += a_list[i] print(ans)" p02629,s606881165,Wrong Answer,"n = int(input()) num2alpha = lambda c : chr(c+96) name = num2alpha(n%26) while n > 26: n = n//26 name = num2alpha(n%26) + name print(name)" p02629,s992780116,Wrong Answer,"n = int(input()) final = """" while n > 0: final += chr(((n - 1) % 26) + 97) n = int(n/26) print(final)" p02629,s588226423,Wrong Answer,"n=int(input()) alph='abcdefghijklmnopqrstuvwxyz' s=[] while n>0: s.append(n%26) n=n//26 ans='' cnt=0 for i in range(len(s)): if s[i]==0: cnt=1 if s[i+1]!=1: ans+='z' cnt=0 s[i+1]-=1 continue ans+=alph[s[i]-1-cnt] print(''.join(list(reversed(ans))))" p02629,s274534051,Wrong Answer,"#C N=int(input()) alp=['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'] Name=[] for i in reversed(range(11)): if N/(26**i) >=1: alp_index=N//(26**i)-1 if N//(26**(i-1))!=26 else 25 Name.append(alp[alp_index]) N=N%(26**i) print(''.join(Name))" p02629,s053536161,Wrong Answer,"N = int(input()) L = list('0abcdefghijklmnopqrstuvwxyz') ans_l = [] while (True): syou = N // 26 amari = N % 26 if syou == 0: ans_l.append(L[amari]) break ans_l.append(L[amari]) N = syou ans_l = ans_l[::-1] print(*ans_l, sep="""") " p02629,s343640154,Wrong Answer,"n = int(input()) ans = """" for i in range(14): if n == 0: break else: ans += chr(ord(""a"") + (n-1) % 26) n = n//26 rslt = ans[::-1] print(rslt)" p02629,s376148760,Wrong Answer,"n = int(input()) alpha = 'abcdefghijklmnopqrstuvwxyz' out = '' while n != 0: out = alpha[(n % 26) - 1] + out n = int(n // 26) print(out)" p02629,s394084009,Wrong Answer,"n=int(input()) ans='' while n>0: x=n%26 ans+=chr(x+96) n=n//26 print(ans[::-1])" p02629,s211612459,Wrong Answer,"N = int(input()) out_ans = [] while N > 26: out_ans.append(int(N % 26)) N = (N // 26) out_ans.append(int(N)) out_dic = ['a', 'b', 'c','d', 'e', 'f','g','h','i','j', 'k','l','m','n','o','p','q','r','s','t','u','v', 'w','x','y','z'] ans = '' for i in range(len(out_ans)-1, -1, -1): ans = ans + (out_dic[out_ans[i] - 1]) print(ans)" p02629,s752187457,Wrong Answer,"N = int(input("""")) Q = [N] R = [ ] i = 1 while (26**i <= N ): Q.append(Q[i-1] // 26) R.append(Q[i-1] % 26) i += 1 # print(Q) # print(R) R.reverse() L = [i for i in ""abcdefghijklmnopqrstuvwxyz""] for i in R: if (i != R[-1]): print(L[i-1],end='') else: print(L[i-1])" p02629,s034082498,Wrong Answer,"n = int( input() ) l = [] a = 97 alp = 26 k = 1 n2 = n while n >= k + 1: l.append( ( n2 - 1 ) % alp ) n2 = ( n2 - ( n2 - 1 ) % alp ) // alp k *= alp ret = """" for c in reversed( l ): ret += chr( a + c ) print( ret ) " p02629,s314022417,Wrong Answer,"N = int(input()) ans = """" while N != 0: ans += chr(ord('a') + (N % 26 + 25) % 26) N //= 26 print(ans[::-1])" p02629,s219724061,Wrong Answer,"import string alphabets = ""abcdefghijklmnopqrstuvwxyz"" n = 26 ans = '' tmp = int(input()) while tmp >= n: tmp -= 1 idx = tmp % n ans = alphabets[idx] + ans tmp //= n print(ans) " p02629,s760850718,Wrong Answer,"def findNum(n): num = [] while n > 0: num.append(n % 26 - 1) n //= 26 return num n = int(input()) l = [chr(i) for i in range(97, 97+26)] array = findNum(n) ans = """" for i in array: ans += l[i] print(ans)" p02629,s344737978,Wrong Answer,"import sys import math import collections import decimal import itertools from collections import deque from functools import reduce import heapq n = int(input()) #n, k = map(int, sys.stdin.readline().split()) #s = input() #p = list(map(int, sys.stdin.readline().split())) x = [chr(ord('a') + i) for i in range(26)] ans = [] while (n != 0): p = n // 26 q = n % 26 ans.append(x[q-1]) n = p for i in range(len(ans)): print(ans[-i-1], end="""") sys.exit() " p02629,s857260926,Wrong Answer,"def solve() : n = int(input()) - 1 d = [] x = 1 if n < 26 : print(chr((n)+97)) return None while n >= 26 : d.append(n % 26) n = n // 26 print(chr((n)+96), end="""") d.reverse() for i in d : if i == 0 : print(chr((i)+97), end="""") else : print(chr((i)+96), end="""") if __name__ == ""__main__"": solve()" p02629,s418284660,Wrong Answer,"n=int(input()) m=1 a=[] while n>26: n,mod=divmod(n,26) a.append(mod) m+=1 a.append(n) s=""abcdefghijklmnopqrstuvwxyz"" ans="""" for i in range(m-1,-1,-1): ans+=s[a[i]-1] print(ans)" p02629,s826441239,Wrong Answer,"N = int(input()) n = 1 cnt = 0 while n < N: cnt += 1 n *= 26 # print(cnt) ans = [] while True: if cnt == 0: # print(N%26-1) ans.append(chr(ord(""a"") + N%(26)-1)) break elif N//(26**cnt): # print(N//(26**cnt)-1) ans.append(chr(ord(""a"") + N//(26**cnt)-1)) N %= 26**cnt cnt -= 1 # print(""N"", N) print("""".join(ans)) " p02629,s984594306,Wrong Answer,"N = int(input()) a = list() sho = N alpha = [i for i in 'abcdefghijklmnopqrstuvwxyz'] while sho != 0: sho = N // 26 amari = N % 26 a.append(alpha[amari-1]) N = N // 26 a.reverse() print(''.join(a))" p02629,s424850848,Wrong Answer,"N = int(input()) ans = [] while N // 26 >= 1: ans.insert(0, N % 26) N = N // 26 ans.insert(0, N) print(ans) for i in range(len(ans) -1): print(chr(96 + ans[i]), end="""") print(chr(96 + ans[-1]))" p02629,s712164102,Wrong Answer,"n = int(input()) name = """" r = 1 while(n > 0 and r > 0): r = n % 26 # あまり n = n // 26 # 商 if r is 0: name = 'z' + name else: name = chr(r+96) + name print(name)" p02629,s611980504,Wrong Answer,"N = int(input()) keta = 0 max = 0 while True: keta += 1 max += 26 ** keta if max >= N: break # print(keta) result = [] while keta >= 1: if N // 26 ** (keta-1) > 26: v = 26 else: v = N // (26 ** (keta-1)) N = N - (26 ** (keta-1)) * v # print(v, N) result.append(v) keta -= 1 # print(result) a_z_list = [chr(ord('a') + i) for i in range(26)] for v in result: print(a_z_list[v-1], end='') # print('') " p02629,s996817435,Wrong Answer,"N=int(input()) ans='' alf='aabcdefghijklmnopqrstuvwxyz' while 1: l = N%27 N = N//27 ans+=alf[l] if N==0: break print(ans[::-1]) " p02629,s567771932,Wrong Answer,"n=int(input()) import math k=math.ceil(math.log(n,26)) s="""" al=[""z"",'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'] for i in range(k): s=al[n%26]+s n=n//26 print(s)" p02629,s540933728,Wrong Answer,"n = int(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'] ans = '' while True: # print(n) # print(n % 26) ans += alphabet[n % 26 - 1] n -= n % 26 n = n // 26 if n == 0: break print(ans[::-1])" p02629,s986664077,Wrong Answer,"a=int(input()) K = 0 b = 0 List = [27]*13 res = """" for i in range(12): K = a % 26 List[i] = int(K) b = a-K if b >26: a = b/26 else: break for i in range(13): if List[12-i] ==27: pass elif List[12-i] ==0: res += chr(26+96) else: res += chr(List[12-i]+96) print(List,res)" p02629,s233924669,Wrong Answer,"alp = 'abcdefghijklmnopqrstuvwxyz' n = int(input()) keta = 0 a = 0 answer = '' while a < n: keta += 1 a = 26**keta for i in range(keta-1): sear = n // (26**(keta-i-1)) n = n % (26**(keta-i-1)) answer += alp[sear-1] answer += alp[n-1] print(answer)" p02629,s617587930,Wrong Answer,"# -*- coding: utf-8 -*- N = int(input()) # 26 ** 9 < 1000000000000001 < 26 ** 10 なので最大でも(9+1)桁の文字 index = [None] * 10 m = N for i in range(9, -1, -1): print(""i: "" + str(i)) x = 26 ** i if m >= x: index[i] = m // x m -= index[i] * x print(index) str = '' for i in index: if i: str += chr(ord('a') + i - 1) print(str[::-1])" p02629,s586650568,Wrong Answer,"n = int(input()) ans = [] asc = 'zabcdefghijklmnopqrstuvwxy' while n > 0: s = (n % 26) ans.append(s) n = int(n / 26) ans2 = [] for i in ans: ans2.append(asc[i]) ans2[0], ans2[-1] = ans2[-1], ans2[0] test = ''.join(ans2) print(test) " p02629,s866037764,Wrong Answer,"alp=[""z"",""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""] N=int(input()) li=[] while N>=0: na=N%26 li.append(alp[na]) if N<=26: break else: N=N//26 ans="""" for i in range(len(li)): ans+=li[i] print(ans[::-1])" p02629,s013164407,Wrong Answer,"def solve(): N = int(input()) ans = [] while True: a,b = divmod(N, 26) ans.append(b) N = a if a==0: break trueans = [] for i in ans: trueans.append(chr(96+i)) print("""".join(reversed(trueans))) if __name__ == ""__main__"": solve()" p02629,s491719464,Wrong Answer,"n = int(input()) ans = '' while n!=0: r = n%26 ans += chr(96+r) n=n//26 print(ans[::-1])" p02629,s440088308,Wrong Answer,"n = int(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'] ln = [] while True: n -= 1 b = n % 26 ln.append(alphabet[b]) if n <= 26: break a = n//26 n = a ln.reverse() ln=''.join(ln) print(ln)" p02629,s562350674,Wrong Answer,"n = int(input()) alpha = [chr(x) for x in range(ord('a'), ord('z')+1)] name = '' while n: n -= 1 r = int(n%26) n = n // 26 print(n, r) name += alpha[r] print(name[::-1])" p02629,s540186658,Wrong Answer,"import sys import numpy as np import math from collections import deque from functools import reduce n = int(input()) az = ""zabcdefghijklmnopqrstuvwxy"" cnt = 12 ret = [] ama = n % 26 na = n for i in range(12, 0, -1): if 26**(i-1) > n: continue sho = na // (26**i) if sho > 0: ret.append(az[sho]) na -= sho * (26**i) if ama > 0: ret.append(az[ama]) if (ret[0] == 'z'): del ret[0] re = """".join(ret) print(re) " p02629,s374319988,Wrong Answer,"n = int(input()) ans = list() while n>0: x = n % 26 ans.append(x) n = int(n / 26) str_ans = """" for x in ans[::-1]: str_ans += chr(x+96) print(str_ans.replace(""a`"", ""z""))" p02629,s078164762,Wrong Answer,"n = int(input()) al = 'abcdefghijklmnopqrstuvwxyz' num = [] while True: if n//26 == 0: num.append(n) break else: amari = n%26 n = n//26 num.append(amari) num.reverse() for nums in num: print(al[nums-1],end = """")" p02629,s586552943,Wrong Answer,"import math N = int(input()) char = [chr(i) for i in range(97, 97+26)] K = math.floor(math.log(N , 26)) s = '' mod = 26**K for i in range(K+1): a = N//(mod) N = N % mod mod = int(mod/26) s += char[a-1] print(s) " p02629,s712577846,Wrong Answer,"N=int(input()) alpha=list(""abcdefghijklmnopqrstuvwxyz"") ans="""" while N>=26: a=N%26 N=N//26 ans=alpha[a-1]+ans ans=alpha[N-1]+ans print(ans)" p02629,s977427315,Wrong Answer,"number = int(input()) alphabet = [chr(i) for i in range(97, 97+26)] name_tag = [] while number != 0: a = number % 26 number = number // 26 name_tag.append(a) reverse_name_tag = reversed(name_tag) for i in reverse_name_tag: print(alphabet[i-1], end="""")" p02629,s241023919,Wrong Answer,"n = int(input()) k = 3670344486987776 keta = [3670344486987776] while(k>1): k/= 26 keta.append(int(k)) # print(k) # print(keta) sin26 = [] f = 0 for i in range(1,12): # print(keta[i-1],n,keta[i],i) if(keta[i-1] > n and n >= keta[i]): f = 0 c = n//keta[i] sin26.append(chr(c+ord(""a"")-1)) n %= keta[i] elif(f == 1): sin26.append(""a"") print("""".join(sin26))" p02629,s710172332,Wrong Answer,"def Quadrillion(): Num = int(input()) if Num<=26: moji = chr(96+Num) elif Num%26==0: moji = num2alpha(Num//26-1)+chr(96) else: moji = num2alpha(Num//26)+chr(96+Num%26) print(moji) def num2alpha(num): if num<=26: return chr(96+num) elif num%26==0: return num2alpha(num//26-1)+chr(96) else: return num2alpha(num//26)+chr(96+num%26) if __name__ == '__main__': Quadrillion()" p02629,s469520697,Wrong Answer,"N = int(input()) mapping = 'zabcdefghijklmnopqrstuvwxy' res = [] for i in range(1, 99): if N <= 26 ** i: for j in range(i): res.append(mapping[N % 26]) N //= 26 break else: N -= 26 ** i print(''.join(res))" p02629,s442143677,Wrong Answer,"N = int(input()) L = list('zabcdefghijklmnopqrstuvwxy') L_2 = list('abcdefghijklmnopqrstuvwxyz') ans_l = [] if N <= 26: print(L_2[N - 1]) exit() while (N >= 26): syou = N // 26 amari = N % 26 ans_l.append(L[amari]) if amari == 0: N = syou - 1 else: N = syou if amari != 0: ans_l.append(L[amari]) ans_l = ans_l[::-1] print(*ans_l, sep="""") " p02629,s942345177,Wrong Answer,"n = int(input()) buf = [] while True: if n > 26: tp = n%26 buf.append(tp) n = n//26 else: buf.append(n) break # print(buf) buf.reverse() ans = """" for b in buf: ans += chr(b+96) print(ans) " p02629,s047872037,Wrong Answer,"n = int(input()) # n // 26 # 答え # n % 26 # あまり res = [] amari = 0 while n > 0: res.append(n % 26) n = n // 26 key = [""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 res[::-1]: print(key[i - 1], end="""")" p02629,s586086493,Wrong Answer,"import sys sys.setrecursionlimit(10 ** 5 + 10) def input(): return sys.stdin.readline().strip() def resolve(): n=int(input()) alp=list(chr(ord('a')+i) for i in range(26)) ans=[] while n>0: a,b=divmod(n,26) n//=26 ans.append(alp[b-1]) print(''.join(ans[::-1]).replace('az','z')) resolve()" p02629,s407016124,Wrong Answer,"n = int(input()) alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'n', 'm', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] ans = [] while True: mod = n % 26 if mod != 0: ans.append(mod) n = n // 26 if n < 26: ans.append(n) break ans_s = '' for tmp in reversed(ans): ans_s += alphabet[tmp - 1] print(ans_s)" p02629,s741948015,Wrong Answer,"N = int(input()) keta_num = 1 tmp_num = 0 while N > tmp_num + (26 ** keta_num): tmp_num += 26 ** keta_num keta_num += 1 # keta_num -= 1 # print(keta_num, tmp_num) names = [] alphabets = list('abcdefghijklmnopqrstuvwxyz') for keta in range(keta_num, 0, -1): # print(N, tmp_num) name = (N - tmp_num) % 26 # print(name) names.append(alphabets[name - 1]) N -= tmp_num tmp_num = tmp_num - (26**(keta - 1)) # print(names) print(''.join(names)) " p02629,s641230684,Wrong Answer,"n = int(input()) alphabet = 'abcdefghijklmnopqrstuvwxyz' ans = '' while n >= 26: n,mod = divmod(n, 26) ans += alphabet[mod-1] ans += alphabet[n-1] reverse_ans = ''.join(list(reversed(ans))) print(reverse_ans)" p02629,s931752970,Wrong Answer,"# coding: utf-8 N = int(input()) def num_to_alpha(num): return str(chr(num + 64)) def ten_to_26_sin(ten, acc): if ten < 26: acc.append(ten) return acc acc.append(ten % 26) return ten_to_26_sin(ten // 26, acc) tmp = list(reversed(list(map(num_to_alpha, ten_to_26_sin(N, []))))) print("""".join(tmp).lower()) " p02629,s620645977,Wrong Answer,"n = int(input()) s = """" while n > 0: s += chr( n % 26 + ord('a') -1 ) n //= 26 print(s[::-1]) " p02629,s915780547,Wrong Answer,"n=int(input()) tmp=0 for ll in range(1,11): tmp+=26**ll if n<=tmp: break s=chr((n-1)%26+ord(""a"")) ##一文字目 for i in range(1,ll): n-=26**i n-=1 ## print(n//26) s+=chr(n//26%26+ord(""a"")) n+=1 print(s[::-1]) " p02629,s461837266,Wrong Answer,"from decimal import Decimal abc=['','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] S="""" n=Decimal(input()) for i in range(0, 11): if int(n//(26**i))<27: S+=abc[int(n//(26**i))] n-=(n//26**i)*(26**i) else: S+=abc[int((n-(n//(26**(i+1))*(26**(i+1))))//(26**i))] n-=int((n-(n//(26**(i+1))*(26**(i+1))))//(26**i)) print(S[::-1])" p02629,s749337531,Wrong Answer,"n=int(input()) ans='' while n: ans+=chr((n-1)%26+ord('a')) n//=26 print(ans[::-1])" p02629,s394688286,Wrong Answer,"n = int(input()) for index in range(1, 11): if n > 26*(1 - 26**(index - 1))/(1 - 26) and n <= 26*(1 - 26**index)/(1 - 26): break # index: how long is the word # it can not be over 11 n -= 26*(1 - 26**(index - 1))/(1 - 26) + 1 name = [] for i in range(index): name.append(chr(ord('a') + int(n % 26))) n = int(n / 26) print(''.join(name[::-1])) " p02629,s240850998,Wrong Answer,"N=int(input()) alpha=[chr(ord('a') + i) for i in range(26)] S="""" i=0 while(N>=1): S+=alpha[(N-1)%26] N=N//26 print(S[::-1])" p02629,s181100613,Wrong Answer,"n = int(input()) res = '' while 0 < n: r = n % 26 res += chr(r+ord('a')-1) n //= 26 print(res[::-1])" p02629,s504063478,Wrong Answer,"n = int(input()) alp = 'zabcdefghijklmnopqrstuvwxy' name = [] while n > 0: n -= 1 name.append(alp[n % 26]) n //= 26 name.reverse() print(*name,sep='')" p02629,s668932804,Wrong Answer,"N = int(input()) ans = '' while N > 0: N -= 1 ans += chr(ord('a') + N % 26) N //= 26 print(ans[::-1]) " p02629,s751227332,Wrong Answer,"n = int(input()) n_list = [] num_list = ['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 = '' while n >= 26: m = n % 26 n = n // 26 n_list.append(m) n_list.append(n) n_list.reverse() for i in range(len(n_list)): n_list[i]= num_list[n_list[i] - 1] ans = ans + n_list[i] print(ans)" p02629,s394386125,Wrong Answer,"import string from decimal import Decimal, getcontext getcontext().prec = 99 characters = string.ascii_lowercase base_number = Decimal(26) def convert_base_number(tmp, result): idx = (Decimal(tmp) % base_number) - 1 return characters[int(idx)] + result def resolve(): tmp = Decimal(input()) result = '' while tmp >= base_number: result = convert_base_number(tmp, result) tmp = Decimal(tmp) / base_number result = convert_base_number(tmp, result) print(result) resolve()" p02629,s072413993,Wrong Answer,"import string characters = '0' + string.ascii_lowercase base_number = 26 def get_result(tmp, result): idx = (tmp % base_number) return characters[int(idx)] + result def resolve(): tmp = int(input()) result = '' while tmp >= base_number: result = get_result(tmp, result) tmp = tmp / base_number print(get_result(tmp, result)) resolve()" p02629,s847407319,Wrong Answer,"n = int(input()) an =[] while n!=0: n,q=divmod(n,26) an.append(chr(q+96)) an.reverse() print(''.join(an))" p02629,s037245536,Wrong Answer,"N = int(input()) ans = '' alp = 'abcdefghijklmnopqrstuvwxyz' q, mod = divmod(N, 26) while True: if q == 0: ans += alp[mod-1] break else: ans += alp[mod-1] q, mod = divmod(q, 26) print(ans[::-1]) " p02629,s579324562,Wrong Answer,"import string # 1千兆 + 1 N = int(input()) n_digits = len(str(1000000000000001)) letters = string.ascii_lowercase x = N ans = [] while True: x -= 1 mod = x % 26 ans = [ mod ] + ans x = x // 26 if x <= 0: break print(ans) print("""".join([ letters[v] for v in ans ]))" p02629,s371039767,Wrong Answer,"import string N = int(input()) strings = string.ascii_letters ans = """" while True: M = N % 26 N = N // 26 ans += strings[M-1] if N == 0: break print(ans[::-1])" p02629,s032147052,Wrong Answer,"import sys sys.setrecursionlimit(4100000) import math INF = 10**9 def main(): n = int(input()) a = int(math.log(n,26)) a2 = n - 26**a ans = '' b = n for i in range(a+1): if b % 26: ans += chr(ord('a')+int(b//(26**(a-i)))) else: ans += chr(ord('a')-1+int(b//(26**(a-i)))) b -= 26**(a-i)*(b//(26**(a-i))) print(ans) if __name__ == '__main__': main() " p02629,s839459928,Wrong Answer,"n = int(input()) c = 0 n1 = 0 n1 += n for i in range(1,12): a = n1 - 26**(i) c += 1 if a <= 0: break n1 = n1 - 26**(i) a = """" for i in range(c): if n // 26**(c-i-1) >= 26: alpha = 26 n = n - 26**(c-i) else: alpha = n // 26**(c-i-1) n = n % 26**(c-i-1) a += chr(96 + alpha) print(a)" p02629,s496438690,Wrong Answer,"n = int(input()) def toa(n): return chr((ord('a')+(n))) temp = 1 digit = 1 while temp+26**digit <= n: temp+=26**digit digit+=1 ans = '' for i in range(digit, 0, -1): for j in range(27): if 26**(i-1) < n: n-=26**(i-1) else: if i==1: ans+=toa(j) else: ans+=toa(j-1) break print(ans)" p02629,s981070741,Wrong Answer,"N = int(input()) namelist = [] num2alpha = lambda c: chr(c+64) for i in range(20): if N <= 26: namelist.append(num2alpha(N)) break q = N//26 mod = N%26 N = q namelist.append(num2alpha(mod)) namelist.reverse() ans = ''.join(namelist) print(ans.lower())" p02629,s839919233,Wrong Answer,"a=int(input()) s=0 si=[] while a!=0: b=a%26 si.append(b) a=a//26 c="""" for i in si: c+=chr(i+96) c=c[::-1] print(c)" p02629,s907799184,Wrong Answer,"n = int(input()) alpha_list = ['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 = '' while(n > 0): ans += alpha_list[(n % 26) - 1] n = int(n // 26) print(ans[::-1])" p02629,s298751346,Wrong Answer,"l = [chr(ord('a')+i) for i in range(26)] n = int(input()) res = """" while n > 0: s = l[n%26-1] n = int(n/26) res = res+s print("""".join(reversed(res)))" p02629,s124495475,Wrong Answer,"N = int(input()) if 1<= N <= 1000000000000001: moji = list('abcdefghijklmnopqrstuvwxyz') amari = N syo = 0 kai = """" lis = [] for i in range(12,0,-1): syo = amari // (26 ** i) amari = amari % (26 ** i) if syo >0: kai += moji[(syo - 1)] kai += moji[(amari - 1)] print(kai) else: print("""")" p02629,s475427524,Wrong Answer,"n = int(input()) a = [chr(i) for i in range(97, 97+26)] ans = [] while n>0: ans.insert(0,a[n%26-1]) n = n // 26 print(''.join(ans))" p02629,s497759543,Wrong Answer,"n=int(input()) out="""" while(1): asc=n%26 if(asc==0): asc=26 asc=97+asc-1 out+=chr(asc) n=n//26 if(n<=0): break print(out[::-1])" p02629,s575441390,Wrong Answer,"N = int(input()) x = [] while N > 0: N, i = divmod(N, 26) x.append(chr(i + 96)) print(''.join(x))" p02629,s345588322,Wrong Answer,"N = int(input()) ans = '' while True: ans = ans+chr(ord('a')+N%26-1) N = N//26 if N == 0: break print(ans[::-1])" p02629,s884244757,Wrong Answer,"N = int(input()) res = [] while N != 0: p = N % 26 N = N // 26 res.append(chr(p + 96)) res.reverse() result = ''.join(res) print(result) " p02629,s632902834,Wrong Answer,"import math i=int(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""] ans="""" for k in range (100): j=i%26-1 ans=alphabet[j]+ans if i<26: break else: i=i//26 print(ans)" p02629,s254516443,Wrong Answer,"N = int(input()) alp = ['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'] amari = [] ans = '' while N > 26: ans = alp[N % 26 - 1] + ans N = N // 26 ans = alp[N-1] + ans print(ans)" p02629,s004859627,Wrong Answer,"n = int(input()) cnt = 0 arr = [] ans = """" moji = ""zabcdefghijklmnopqrstuvwxy"" flg = False if n % 26 == 0: flg = True for i in range(100): arr.append(n % 26) n = n // 26 if n == 0: cnt = i break arr.reverse() if flg: print(""z"" * cnt) else: for i in arr: ans +=moji[i] print(ans) " p02629,s313530744,Wrong Answer,"N = int(input()) ans = [] num = N while(True): if num > 26: ans.append(num%26) num = num//26 else: ans.append(num) break answer = """" for n in ans[::-1]: answer += chr(96+n) print(answer)" p02629,s302850413,Wrong Answer,"N = int(input()) r = [] for k in range(13): kk = 12-k m = 26**kk w = N // m if w > 0: N -= m * w r.append(chr(w+96)) print(''.join(r))" p02629,s789029360,Wrong Answer,"n = int(input()) a = ""abcdefghijklmnopqrstuvwxyz"" s = [] while n > 26: s.append(a[n%26 - 1]) n //= 26 s.append(a[n%26 - 1]) print(''.join(s[::-1])) " p02629,s604721813,Wrong Answer,"word_lst = ['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()) w_lst = [] x = n p = 1 q = 0 while x >= 0: s = n % 26 w_lst.append(s) q += 26**p x = n - q n = x p += 1 ans_lst = [] for d in w_lst: ans_lst.append(word_lst[d-1]) print("""".join(ans_lst))" p02629,s464277068,Wrong Answer,"from collections import deque n = int(input()) stack = deque() ans =[] while n > 0: if 1<= n <= 26: stack.append(n) break mod = n%26 stack.append(mod) n = n//26 while stack: tmp = stack.pop() alp = chr(tmp+96) ans.append(alp) anss = ''.join(ans) print(anss)" p02629,s086698445,Wrong Answer,"n = int(input()) out = """" from string import ascii_lowercase while n: out = ascii_lowercase[n % 26 - 1] + out n //= 26 print(out) " p02629,s516243644,Wrong Answer,"import sys input = sys.stdin.readline a = int(input()) def base10to(n, b): if (int(n/b)): return base10to(int(n/b), b) + chr(n%b + 96) return chr(n%b + 96) print(base10to(a,26))" p02629,s031115703,Wrong Answer,"N=int(input()) ans=[] while(1): if N==0: break ans.append(str(N%26)) N//=26 new_ans= ans[::-1] #print(chr(97)) #97→a ANS="""" for i in new_ans: ANS+=chr((96+int(i))) #print(new_ans) print(ANS)" p02629,s211871012,Wrong Answer,"def base10to(n, b): if (int(n/b)): return base10to(int(n/b), b) + Alp[n%b] return Alp[n%b-1] Alp = ["""",""a"",""b"",""c"",""d"",""e"",""f"",""g"",""h"",""i"",""j"",""k"",""l"",""m"",""n"",""o"",""p"",""q"",""i"",""s"",""t"",""u"",""v"",""w"",""x"",""y"",""z""] print(base10to(int(input()),26))" p02629,s911876035,Wrong Answer,"n = int(input()) ans = """" k = 0 while n // (26**(k)) > 0: ans += str(chr((n % 26**(k + 1) // 26**(k)) + 96)) n = n - (n % (26**(k))) k += 1 print(ans[::-1]) " p02629,s448613935,Wrong Answer,"N=int(input()) ans="""" while N > 0: ans = chr(N % 26 + 96) + ans N //= 26 print(ans) " p02629,s867599876,Wrong Answer,"n = int(input()) d = ['z', '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 = '' f = 0 if n % 26 == 0: f = 1 while n > f: a = d[n % 26] + a n //= 26 print(a)" p02629,s277516937,Wrong Answer,"n = int(input()) s = """" while n > 0: s += chr(96 + (n % 26)) n = (n - 1) // 26 print(s[::-1])" p02629,s789844317,Wrong Answer,"n = int(input()) a = """" while n > 0: n, r = divmod(n, 26) if r == 0: r = 26 a += chr(r-1 + ord('a')) print(a[::-1]) " p02629,s412401368,Wrong Answer,"n=int(input()) ans=[] while True: i=n//26 if i == 0: break ans.append(n%26) n=i alp=[chr(ord('a') + i) for i in range(26)] ans.reverse() ans=[alp[i-1] for i in ans]+[alp[n-1]] for i in ans: print(i,sep="""",end="""")" p02629,s570630796,Wrong Answer,"N = int(input()) ret = '' while N > 0: i = 1 while N / i > 26: i *= 26 ret += chr(ord('a') + N // i - 1) N %= i print(ret)" p02629,s137773837,Wrong Answer,"n = int(input()) l = ['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'] m = [] a = 26**10 while a>0: b = int(n/a) if b > 0: b -= 1 m.append(l[b]) n = int(n%a) a /= 26 name=''.join(m) print(name)" p02629,s896246496,Wrong Answer,"n=int(input()) n-=1 i=26 c=1 while n-i>0: n-=i i*=26 c+=1 al=list('abcdefghijklmnopqrstuvwxyz') ans=[] for i in range(c): ans.append(al[n%26]) n=n//26 ans.reverse() print(''.join(ans))" p02629,s035891376,Wrong Answer,"n=int(input()) alphabet=""abcdefghijklmnopqrstuvwxyz"" ans=[] while n>0: ans.append(alphabet[n%26-1]) n=n//26 print("""".join(ans)) " p02629,s475592726,Wrong Answer,"n = int(input()) su=[26**i for i in range(1,10)] from itertools import accumulate wa = list(accumulate(su)) import bisect c = 0 if n>=27: c=bisect.bisect_left(wa, n) n=n-wa[c-1] k=26 bi=[] for i in range(c+1): bi.append(n % k) n = n//k bi[0] += -1 al=[chr(ord('a') + i) for i in range(26)] li = [al[i] for i in bi] li.reverse() mojiretu = ''.join(li) print(mojiretu)" p02629,s490752067,Wrong Answer,"from collections import deque def add(x): return x+97 N = int(input()) i = 1 while N >= 26**i: N = N - 26**i i += 1 N -= 1 shinsu = deque([]) for j in range(i): shinsu.appendleft(N%26) N //= 26 shinsu = list(map(add, shinsu)) ans = list(map(chr, shinsu)) print(''.join(ans))" p02629,s098258405,Wrong Answer,"import math n = int(input()) ans_list = [] def waru(n): amari = n%26 kotae = n / 26 ans_list.append(math.floor(amari)) if kotae < 1: return 0 else: waru(kotae) waru(n) ans_list.reverse() alph = [chr(i) for i in range(97, 97+26)] for i in ans_list: print(alph[i-1], end="""") " p02629,s931654519,Wrong Answer,"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" p02629,s214885867,Wrong Answer,"n = int(input()) num2alpha = lambda c: chr(c+64) def g(x): L = [] while x > 0: amari = x%26 L.append(amari) x = x//26 L.reverse() answer = '' for i in L: answer += num2alpha(i).lower() return print(answer) g(n)" p02629,s638330580,Wrong Answer,"x=int(input()) res='' s=[] while x>0: d=x%26 res+=chr(ord('a')+d-1) x//=26 res=res[::-1] print(res)" p02629,s531664782,Wrong Answer,"n = int(input()) l = [] nc = n while nc > 0: l.append(nc % 26) nc //= 26 ans = '' for i in range(len(l)): ans += chr(l[-(1+i)] + 96) print(ans) " p02629,s567399754,Wrong Answer,"N=int(input()) ans='' for i in reversed(range(11)): if 26**i<=N: s_num=N//(26**i) if s_num==0: s='z' else: s=chr(s_num+96) ans=ans+s N=N%(26**i) print(ans)" p02684,s232165216,Accepted,"# -*- coding: utf-8 -*- n, k = map(int, input().split()) dest = list(map(int, input().split())) index_map = {} step = 0 next_index = 0 while 0 < k: k -= 1 next_index = dest[next_index] - 1 if next_index in index_map: period = step - index_map[next_index] skip = k % period for j in range(0, skip): next_index = dest[next_index] - 1 break index_map[next_index] = step step += 1 print(next_index + 1) " p02684,s299752176,Accepted,"n, k = map(int, input().split()) A = [0] + list(map(int, input().split())) here = 1 log = [1] loop = [] num_log = [0] * (n + 1) num_log[1] = 1 for i in range(k): here = A[here] if num_log[here] == 1: pre_loop = log.index(here) k = k - pre_loop loop = log[pre_loop:] here = loop[k % len(loop)] break else: num_log[here] = 1 log += [here] print(here) " p02684,s955696040,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) chk = [0]*(N+1) town = 1 rt = [] roop = 0 while True: if chk[town] == 1: break rt.append(town) chk[town] = 1 town = A[town-1] if K <= rt.index(town): print(rt[K]) else: roop = (K-rt.index(town)) % (len(rt)-rt.index(town)) print(rt[rt.index(town)+roop])" p02684,s371855295,Accepted,"N, K = map(int, input().split()) A = [1] + list(map(int, input().split())) p = 1 points = [p] visited = set([p]) for _ in range(N): p = A[p] if p in visited: break points.append(p) visited.add(p) idx = points.index(p) if idx > K: print(points[K]) exit() cycle = points[idx:] print(cycle[(K - idx) % len(cycle)])" p02684,s602869243,Accepted,"N,K=map(int,input().split()) A=list(map(int,input().split())) if K<=N: next_city=0 for i in range(K): next_city=A[next_city]-1 else: next_city=0 visited=[-1]*N visited[0]=0 for num in range(1,N): next_city=A[next_city]-1 if visited[next_city]!=-1: break visited[next_city]=num K=(K-num)%(num-visited[next_city]) for i in range(K): next_city=A[next_city]-1 print(next_city+1)" p02684,s816754536,Accepted,"nk = input().split() n , k = int(nk[0]), int(nk[1]) a = [int(i) for i in input().split()] t = 1 tl = [1] ts = {1} for i in range(len(a)): t = a[t-1] if t in ts: break else: tl.append(t) ts.add(t) tl2 = tl[tl.index(t):len(tl)] # print(tl) # print(tl2) ans = 0 if k < len(tl): ans = tl[k] else: k = k - len(tl) j = k % len(tl2) ans = tl2[j] print(ans)" p02684,s154073008,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) B = [0] * N C = [] C.append(0) now = 0 B[0] = 1 for i in range(N): now = A[now] - 1 if B[now] == 1: break else: C.append(now) B[now] = 1 mae = 0 for i in range(len(C)): if C[i] == now: mae = i break ato = len(C) - 1 if K + 1 <= mae: print(C[K] + 1) else: print(C[mae + (K - mae) % (ato - mae + 1)] + 1) " p02684,s657826978,Accepted,"N, K = map(int, input().split()) *A, = map(int, input().split()) visited = [False] * N towns = [] now = 0 length = 0 while not visited[now] and K > 0: visited[now] = True towns.append(now + 1) length += 1 K -= 1 now = A[now] - 1 if K == 0: print(now + 1) else: idx = towns.index(now + 1) length -= idx print(towns[idx:][K % length])" p02684,s822673430,Accepted,"n,k=map(int,input().split()) a=[int(i) for i in input().split()] d=[0] w=set([0]) x=0 for i in range(n): if a[x]-1 not in w: d.append(a[x]-1) w.add(a[x]-1) x=a[x]-1 else: f=a[x]-1 break #print(d) if k=k): print(arr[k]+1) else: print(arr[(k-pathSize)%cycleSize+pathSize]+1)" p02684,s955680365,Accepted,"import math N, K = map(int, input().split()) P = [i -1 for i in map(int,input().split())] lgk = int(math.log(K,2)) last = P point = 0 for j in range(lgk+1): if (K >> j) & 1: point = last[point] res = [] for i in last: res.append(last[i]) last = res print(point+1) " p02684,s537465266,Accepted,"N,K = map(int,input().split()) A = list(map(int,input().split())) M = 0 temp = K while temp>0: M += 1 temp>>=1 nexts = [[-1]*N for _ in range(M)] for i in range(N): nexts[0][i] = A[i]-1 for t in range(1,M): for i in range(N): nexts[t][i] = nexts[t-1][nexts[t-1][i]] Kb = [0]*M temp = K for i in range(M): Kb[i] = temp&1 temp >>= 1 ans = 0 for i in reversed(range(M)): if Kb[i]: ans = nexts[i][ans] print(ans+1) " p02684,s852726934,Accepted,"import sys from collections import deque input = sys.stdin.readline N, K = map(int, input().split()) A = list(map(int, input().split())) visited = set() q = deque() q.append(1) root = [] while q: pos = q.pop() if pos in visited: start = root.index(pos) s_len = len(root[:start]) l_len = len(root[start:]) break visited.add(pos) root.append(pos) q.append(A[pos-1]) if K <= s_len: print(root[K]) else: r = (K - s_len) % l_len print(root[start+r])" p02684,s153237123,Accepted,"n,k=map(int,input().split()) A=list(map(int,input().split())) s=[] v=1 ord=[-1]*(n+1) c=1 l=0 while ord[v]==-1: ord[v]=len(s) s.append(v) v=A[v-1] c=len(s)-ord[v] l=ord[v] if k=s: m = len(loop) print(loop[(k-s)%m]) else: print(warp[k])" p02684,s298822747,Accepted,"n,k=map(int,input().split()) a=list(map(int,input().split())) pl=1 visit=[-1]*n visit[0]=0 loop=0 cnt=0 while 1: cnt+=1 pl=a[pl-1] if visit[pl-1]!=-1: loop=visit[pl-1] break visit[pl-1]=cnt if cnt==k: print(pl) exit() loop_len=cnt-loop k=(k-loop)%loop_len+loop print(visit.index(k)+1) " 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) " 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)" p02684,s704376691,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) done = [0]*n stay = 1 for i in range(1, k+1): if done[stay-1] != 0: break done[stay-1] = i stay = a[stay-1] nokori = k + 1 - i if nokori != 1: loop = i - done[stay-1] for i in range(nokori%loop): stay = a[stay-1] print(stay)" p02684,s657822602,Accepted,"from collections import defaultdict N, K = map(int, input().split()) A = [int(x) - 1 for x in input().split()] cur = 0 step = 0 d = defaultdict(int) d[0] = step li = [] while True: cur = A[cur] li.append(cur) if d[cur] != 0: break step += 1 d[cur] = step pre = li[:d[cur]] loop = li[d[cur]:] if K <= len(pre): print(pre[K - 1] + 1) else: K -= len(pre) + 1 print(loop[K % (len(loop))] + 1) " p02684,s312240419,Accepted,"n,k = map(int,input().split()) a = [0]+list(map(int,input().split())) visited = [0]*(n+1) pos = 1 steps = 0 while visited[pos] == 0: visited[pos] = steps steps += 1 pos = a[pos] #print(visited) if k>=steps: k -= visited[pos] k %= (steps-visited[pos]) #print(k) for i in range(1,n+1): if visited[i] == visited[pos]+k: print(i) break else: for i in range(1,n+1): if visited[i] == k: print(i)" p02684,s448352770,Accepted,"N, K = map(int, input().split()) A = list(map(lambda a: int(a) - 1, input().split())) T = [A[:]] for _ in range(64): prev = T[-1] T.append([prev[a] for a in prev]) now = 0 for d, P in enumerate(T): if ((1 << d) & K) > 0: now = P[now] print(now + 1) " p02684,s541487842,Accepted,"n,k = map(int,input().split()) a_list = list(map(int,input().split())) a = 0 t = 1 d = 0 hoge_list = [] hoge_set = set() while a < k: hoge_list.append(t) hoge_set.add(t) t = a_list[t-1] a += 1 if t in hoge_set: b = hoge_list.index(t) d += 1 break if d == 0: print(t) else: e = (k-b)%(a-b) print(hoge_list[b+e]) " p02684,s321976617,Accepted,"N, K = map(int, input().split()) A = list(map(lambda x: int(x) - 1, input().split())) R = [] done = set() todo = [0] done = set() bp = None while todo: p = todo.pop() R.append(p) done.add(p) np = A[p] if np in done: bp = np else: todo.append(np) b = R.index(bp) if K < b: ans = R[K] + 1 else: K -= b R = R[b:] ans = R[K%len(R)] + 1 print(ans)" p02684,s584998768,Accepted,"n, k = map(int, input().split()) a = [0] + list(map(int, input().split())) journey = [1] for i in range(2*n + 100): nxt = a[journey[-1]] journey.append(nxt) if k < n + 1: print(journey[k]) exit() loop_end = n loop_start = n-1 while(journey[loop_start] != journey[loop_end]): loop_start -= 1 period = loop_end - loop_start k %= period while k<= n: k += period print(journey[k])" p02684,s712982842,Accepted,"n,k=map(int,input().split()) a=list(map(int,input().split())) visited={} for i in range(1,n+1): visited[i]=-1 l=[1] visited[1]=0 i=1 while True: if visited[a[l[i-1]-1]]==0: roop_start=l.index(a[l[i-1]-1]) break visited[a[l[i-1]-1]]=0 l.append(a[l[i-1]-1]) i+=1 roop_dif=i-roop_start if k=1: loop=i-A0[temp] t=(K-A0[temp])%loop temp=tempv[A0[temp]+t-1] break else: A0[temp]=i temp=A[temp]-1 tempv.append(temp) print(temp+1)" p02684,s218291658,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) passed = [-1] * (n+1) route = [] v = 1 while passed[v] == -1: passed[v] = len(route) route.append(v) v = a[v-1] c = len(route) - passed[v] l = passed[v] if k < l: print(route[k]) else: k -= l k %= c print(route[l+k])" p02684,s959028357,Accepted,"n,k=map(int,input().split()) a=[0]+list(map(int,input().split())) already=[0]*(n+1) already[1]=1 history=[1] tmp=1 now=0 jump=1 while jump: now+=1 tmp=a[tmp] history.append(tmp) if now==k: ans=tmp break elif already[tmp]==1: jump=0 past=history.index(tmp) loop=now-past ans=history[past+(k-now)%loop] break else: already[tmp]=1 print(ans)" p02684,s621304751,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) passlist = [0]*N point = 1 depth = 0 waylist = [] while passlist[point-1] == 0: waylist.append(point) passlist[point-1] = depth point = A[point-1] depth+=1 roop = waylist[waylist.index(point):len(waylist)] firstreach = passlist[roop[0]-1] if K < firstreach: print(passlist.index(K)+1) else: print(roop[(K-firstreach)%len(roop)])" p02684,s540331958,Accepted,"n,k,*a=map(int,open(0).read().split()) now=1 if k<=n: for i in range(k): now=a[now-1] print(now) exit() # 絶対ループする visited=[False]*n visited[now-1]=-1 for i in range(4*10**5): now=a[now-1] if visited[now-1]==False: visited[now-1]=i else: c,d=visited[now-1],i break k=(k-c)%(d-c)+c while k0: for i in range(k%loop): pos=a[pos]-1 print(pos+1)" p02684,s315666316,Accepted,"n,k = map(int,input().split()) b = [bi-1 for bi in list(map(int,input().split()))] a = 0 f = [0]*n c = 1 for i in range(k): if f[a]: k %= c-f[a] for i in range(k): a = b[a] print(a+1) break f[a] = c k -= 1 c += 1 a = b[a] else: print(a+1)" p02684,s542591274,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) p = [-1] * N p[0] = 0 flag = 0 now = 1 i = 0 while flag == 0: i += 1 now = A[now - 1] if p[now - 1] != -1: flag = 1 else: p[now - 1] = i if i == K: flag = 2 if flag == 2: print(now) else: r = i - p[now - 1] e = p[now - 1] count = K - e pi = count % r for i in range(pi): now = A[now - 1] print(now)" p02684,s657871290,Accepted,"N,K = map(int, input().split()) A = list(map(int, input().split())) lst = [0] * N k = 1 cnt = 0 for j in range(10*N): lst[k-1] += 1 k = A[k-1] num = len(list(filter(lambda x:x>=1,lst))) k = 1 first = [] loop = [] for j in range(num): if lst[k-1] == 1: first.append(k) elif lst[k-1] > 1: loop.append(k) k = A[k-1] if K < len(first): print(first[K]) else: K -= len(first) print(loop[K%len(loop)])" p02684,s751651299,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) n = 1 order = [n] order_set = set([n]) for i in range(1, K + 1): n = A[n - 1] if n in order_set: Li = order.index(n) Ri = len(order) idx = Li + (K - Li) % (Ri - Li) print(order[idx]) exit() else: order.append(n) order_set.add(n) continue print(n) " p02684,s455900014,Accepted,"import sys input = sys.stdin.readline n, k = map(int, input().split()) a = list(map(int, input().split())) cnt, town = 0, 1 l, s = [], set() while True: town = a[town - 1] cnt += 1 if cnt == k: print(town) exit() if town in s: loop_start = town break l.append(town) s.add(town) loop_cnt = l.index(loop_start) loop = l[loop_cnt:] print(loop[(k - loop_cnt) % len(loop) - 1]) " p02684,s877402969,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) l = [0 for _ in range(N)] now = 0 l[now] = 1 count = 0 loop = [0] while count < K: count += 1 now = A[now]-1 loop.append(now) if l[now] == 1: loop = loop[loop.index(now):-1] break else: l[now] = 1 if count == K: print(now + 1) else: ans = loop[(K-count) % len(loop)] print(ans + 1) " p02684,s678737404,Accepted,"n,k = map(int,input().split()) a = list(map(int,input().split())) tt = [0] * n tt[0] = 1 ans_l = [1] i = 1 for j in range(k): i = a[i-1] if tt[i-1] == False: tt[i-1] = 1 ans_l.append(i) else: break d = ans_l.index(i) k -= d ans = k % (len(ans_l)-d) print(ans_l[ans+d]) " p02684,s928914063,Accepted,"N,K = map(int,input().split()) A = list(map(lambda x: int(x)-1,input().split())) o = [0] * 63 def bi(x): i = 0 while x != 0: o[i] = x%2 x //= 2 i += 1 bi(K) n = 0 for i in range(63): if o[i]: n = A[n] A = [A[A[x]] for x in range(N)] print(n+1)" 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])" p02684,s455252299,Accepted,"import sys n, k = [int(i) for i in sys.stdin.readline().split()] a_s = [int(i)-1 for i in sys.stdin.readline().split()] cnt = 0 ind = 0 ls = [ind] last_pos = {0:0} _set = {ind} while cnt < k: ind = a_s[ind] if ind in _set: break _set.add(ind) ls.append(ind) cnt += 1 if cnt == k: print(ind+1) else: start = ls.index(ind) end = cnt+1 print(ls[start:][(k - cnt) % (end - start)-1]+1)" 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) " p02684,s761580092,Accepted,"n,k = map(int, input().split()) a = list(map(int, input().split())) visit = [0] * n visit[0] = 1 keiro = [1] s = 1 now = 1 while True: x = a[now - 1] if visit[x - 1] == 1: break now = x visit[x - 1] = 1 keiro.append(x) l1 = len(keiro) l2 = keiro.index(x) if k < l1: print(keiro[k]) else: p = (k - l2) % (l1 - l2) print(keiro[l2 + p])" p02684,s894232751,Accepted,"n,k = map(int,input().split()) a_list = list(map(int,input().split())) used_dict = {} used_list = [] current_node = 0 while True: if current_node not in used_dict: used_dict[current_node] = True used_list.append(current_node) current_node = a_list[current_node]-1 else: break repeat_index = used_list.index(current_node) repeat_list = used_list[repeat_index:] repeat_length = len(used_list) - repeat_index if k > repeat_index: amari = (k-repeat_index) % repeat_length print(repeat_list[amari]+1) else: print(used_list[k]+1) " p02684,s799565378,Accepted,"#!/usr/bin/env python3 import sys input = sys.stdin.readline n, k = map(int, input().split()) a = [int(item) - 1 for item in input().split()] visited = [0] * n v = 0 visited[0] = 1 pre = [0] loop = [] start = False while True: v = a[v] if visited[v] == 1: start = True if visited[v] == 2: break if not start: pre.append(v) else: loop.append(v) visited[v] += 1 if k < len(pre): print(pre[k] + 1) exit() k -= len(pre) print(loop[k % len(loop)] + 1)" 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)])" p02684,s788423233,Accepted,"n, k = map(int, input().split()) A = list(map(int, input().split())) seen = {1: 0} a = 1 for i in range(1, n+1): if seen.setdefault(a:=A[a-1], i) != i: break p = seen[a] q = i - seen[a] if k >= p+q: k = (k - p) % q + p a = 1 for i in range(k): a = A[a-1] print(a)" p02684,s278011581,Accepted,"N, K = map(int ,input().split()) A = [int(x) for x in input().split()] checked = [False] * N root=[0] idx = 0 checked[0]=True for k in range(K): root.append(A[idx]-1) idx = A[idx]-1 if (checked[idx]): break checked[idx]=True else: print(idx+1) exit(0) for i, r in enumerate(root): if r == root[-1]: break root2=root[i:] l = len(root2)-1 idx = root2[(K-i)%(l)] print(idx+1) " p02684,s325181203,Accepted,"from time import time N, K = list(map(int, input().split())) A = list(map(int, input().split())) L = [-1 for i in range(N)] visited = [] now = 0 loopstarts = None looplength = None t0 = time() for i in range(N): if L[now] != -1: break else: L[now] = i visited.append(now) now = A[now]-1 loopstarts = visited.index(now) looplength = len(visited)-loopstarts if K < loopstarts: print(visited[K]+1) else: print(visited[loopstarts+(K-loopstarts)%looplength]+1) # print(time()-t0) " 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])" p02684,s733858596,Accepted,"#n=int(input()) n,k=map(int,input().split()) #t=int(input()) al=list(map(int,input().split())) #l=[list(map(int,input().split())) for i in range(n)] arrived={i:False for i in range(1,n+1)} #arrived[1]=True city=[] before=1 while True: nxt=al[before-1] if arrived[nxt]: break arrived[nxt]=True city.append(nxt) before=nxt ind=city.index(nxt) loop=city[ind:] if k<=ind: ans=city[k-1] else: k-=ind ans=loop[k%len(loop)-1] print(ans)" p02684,s145692762,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) was = [] tf = [False] * N place = 1 cnt = 0 while tf[place-1] == False: if cnt < K: tf[place-1] = True was.append(place) place = A[place-1] cnt += 1 else: print(place) break; else: loop = cnt - was.index(place) num = (K-cnt) % loop + was.index(place) print(was[num])" p02684,s422239964,Accepted,"N, K = map(int, input().split()) A = [int(x) for x in input().split()] when = [-1 for _ in range(N+1)] new = 1 i = 0 while when[new] == -1: when[new] = i new = A[new - 1] i += 1 line = when[new] roop = i - when[new] if K > line: K = (K - line) % roop for j in range(N+1): when[j] -= line for j in range(N+1): if when[j] == K: print(j) break" p02684,s927965792,Accepted,"n,k=map(int,input().split()) a=[-1]+list(map(int,input().split())) count=[0]*(n+1) cnt=0 i=1 while count[i]==0: count[i]=cnt if cnt==k: print(i) exit() cnt+=1 i=a[i] if cnt==k: print(i) exit() loop=cnt-count[i] #print(""loop"",loop) goal=(k-cnt)%loop #print(loop,goal) if goal==0: print(i) else: print(count.index(count[i]+goal)) " p02684,s180021102,Accepted,"from math import log2 n, k = map(int, input().split()) To = [] A = list(map(int, input().split())) A = list(map(lambda x: x - 1, A)) To.append(A) for i in range(int(log2(k))): N = [0 for i in range(n)] for j in range(n): N[j] = To[i][To[i][j]] To.append(N) v = 0 for i in reversed(range(int(log2(k)) + 1)): l = 1 << i if l <= k: v = To[i][v] k -= l else: pass print(v + 1)" p02684,s730607980,Accepted,"n, k = map( int, input().split() ) a = [ 0 ] + list( map( int, input().split() ) ) now = 1 visited = [ 1, -1 ] + [ -1 ] * ( n - 1 ) diary = [ -1, 0 ] + [ -1 ] * ( n - 1 ) for i in range( 1, k+1 ): now = a[ now ] visited[ i ] = now if diary[ now ] != -1: cycle = i - diary[ now ] d = ( k - i ) % cycle now = visited[ diary[ now ] + d ] break else: diary[ now ] = i print( now )" p02684,s478918996,Accepted,"n, k = map(int,input().split()) a = list(map(int,input().split())) l = [0]*n i=0 cnt=0 while l[i]==0: l[i] = a[i] i = a[i]-1 cnt += 1 start = i+1 i = 0 pre = 0 while i+1!=start: i = a[i]-1 pre += 1 loop = cnt-pre if pre+loop K: ans = q[K] else: r = list(q)[x:] ans = q[(K - x) % len(r) + x] print(ans) " p02684,s593864823,Accepted,"n,k,*a=map(int,open(0).read().split()) v=[-1]*n t=c=0 while v[t]<0: v[t]=c; c+=1; t=a[t]-1 l=v[t] c-=l print(v.index(min(k,l+(k-l)%c))+1)" p02684,s116826575,Accepted,"from sys import stdin from sys import setrecursionlimit setrecursionlimit(10 ** 7) n,k = map(int,stdin.readline().rstrip().split()) a = list(map(int,stdin.readline().rstrip().split())) a = [0]+a bunki = 0 now = a[1] lip = [1] se = set() while True: bunki += 1 if now in se: break se.add(now) lip.append(now) now = a[now] tenki = lip.index(now) lis = lip[tenki:] roop = bunki-tenki if k < tenki: print(lip[k]) exit() k -= tenki print(lis[k%roop])" p02684,s056778374,Accepted,"_,k,*a=map(int,open(0).read().split());a=[0]+a;p=1 while k:p=~-k%2*p or a[p];a=[a[b]for b in a];k//=2 print(p)" p02684,s929080175,Accepted,"n, K = map(int, input().split()) As = list(map(int, input().split())) # doubling m = 0 while 2**m < K: m += 1 d = [[0] * n for i in range(m)] for i in range(n): d[0][i] = As[i] - 1 for k in range(m-1): for i in range(n): d[k+1][i] = d[k][d[k][i]] now = 0 for k in range(m): if (K >> k) & 1: now = d[k][now] print(now+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" p02684,s183598617,Accepted,"n,k = map(int,input().split()) al = list(map(int,input().split())) ansl = [] used = [0 for i in range(n+1)] now = 0 while True: if used[now] == 1: break ansl.append(now) used[now] = 1 now = al[now] - 1 l = len(ansl) last = ansl.index(now) loop = ansl[last:] if k < len(ansl): print(ansl[k] + 1) else: k -= len(ansl) print(loop[k % len(loop)] + 1) " p02684,s471231463,Accepted,"from collections import defaultdict N, K = map(int, input().split()) A = list(map(int, input().split())) d = defaultdict(list) p = 1 root = [] #s, e = 0, 0 for i in range(K): d[p].append(i) root.append(p) if len(d[p]) == 2: s = d[p][0] e = i n = (K - s) % (e - s) p = root[s + n] break p = A[p - 1] #print(s, e) #print(root) #n = (K - s) % (e - s) print(p)" p02684,s356134661,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) b = 0 if k<=n: for i in range(k): b = a[b]-1 print(b+1) exit(0) c = [0] for i in range(n): b = a[b]-1 c.append(b) d = c[:-1].index(c[-1]) c = c[d:-1] k = k-d print(c[k%len(c)]+1) " p02684,s508742786,Accepted,"import sys N,K = map(int,input().split()) tele = list(map(int,input().split())) k = 1 flag = [0]*N goal = tele[0] miti = [1] while (flag[goal-1])!=1: k += 1 miti.append(goal) flag[goal-1] = 1 goal = tele[goal-1] if k == K: print(goal) sys.exit() a = miti.index(goal) loop = k-a ans = miti[(K-a)%loop+a] print(ans)" p02684,s892844785,Accepted," n,k = map(int,input().split()) a = list(map(int,input().split())) s = [] ord = [-1] * (n+1) v = 1 c = 1 l = 0 while ord[v] == -1: ord[v] = len(s) s.append(v) v = a[v-1] c = len(s) - ord[v] l = ord[v] if l > k: print(s[k]) else: k -= l k %= c print(s[l+k]) " p02684,s648288984,Accepted,"N,K = map(int,input().split()) A = list(map(int,input().split())) A = [i-1 for i in A] doubling = [[0] * N for _ in range(61)] for i in range(N): doubling[0][i] = A[i] for i in range(1,61): for j in range(N): doubling[i][j] = doubling[i-1][doubling[i-1][j]] now = 0 i = 0 while K!=0: if K&1==1: now = doubling[i][now] K = K>>1 i += 1 else: K = K>>1 i += 1 print(now+1)" p02684,s822278949,Accepted,"n,k = map(int, input().split()) l = [0]+list(map(int, input().split())) journey = [1] for i in range(2*n): next = l[journey[-1]] journey.append(next) if k <= n+1: print(journey[k]) exit() end = n start = n-1 while journey[start] != journey[end]: start -= 1 period = end - start k %= period while k < n: k += period print(journey[k])" p02684,s087102162,Accepted,"n, k = map(int, input().strip().split()) L = list(map(int, input().strip().split())) L = [v - 1 for v in L] seen = set() cur = 0 untillBackToIntersec = 0 while cur not in seen: seen.add(cur) untillBackToIntersec += 1 cur = L[cur] intersec = cur cur = 0 beforeLoop = 0 while cur != intersec: cur = L[cur] beforeLoop += 1 if k<=beforeLoop: proceed=k else: loopSize = untillBackToIntersec - beforeLoop proceed=(k - beforeLoop) % (loopSize) + beforeLoop ans = 0 for _ in range(proceed): ans = L[ans] print(ans + 1)" p02684,s840186136,Accepted,"N, K = list(map(int, input().split())) A = list(map(int, input().split())) visited = {'1': 0} route = [1] next_id = 0 count = 0 while count < K: count += 1 if A[next_id] in visited.keys(): route = route[visited[A[next_id]]:] K -= count break visited[A[next_id]] = count route.append(A[next_id]) next_id = A[next_id] - 1 print(route[K % len(route)]) " p02684,s854847430,Accepted,"N, K = list(map(int, input().split())) K -= 1 A = list(map(lambda x: int(x) - 1, input().split())) seen = [None]*N seen_set = set() now = 0 for i in range(N): seen[i] = now seen_set.add(now) to = A[now] now = to if now in seen_set: seen[i+1] = now loop_s = seen.index(now) loop_end = i + 1 size = loop_end - loop_s break if K <= loop_s: print(seen[K+1] + 1) else: K -= loop_s print(seen[loop_s + 1 + K % size] + 1)" p02684,s682142899,Accepted,"N, K = map(int, input().split()) *A, = map(int, input().split()) dp = [[0]*N for _ in range(60)] for i in range(N): dp[0][i] = A[i] - 1 for k in range(1, 60): for n in range(N): dp[k][n] = dp[k - 1][dp[k - 1][n]] res = [] for i in range(60): if (K>>i)&1: res.append(i) pos = 0 for i in res: pos = dp[i][pos] print(pos + 1)" p02684,s773177242,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) l = [1] for i in range(n): l.append(a[l[i] - 1]) p = l.index(l[n]) if k <= n: print(l[k]) else: x = (k - n + 1) % (n - p) if x == 0: print(l[n - 1]) else: print(l[x + p - 1])" p02684,s842824031,Accepted,"N,K = map(int, input().split()) A = [int(c) for c in input().split()] cnt = 0 p = 0 used = [False]*N used[0] = True while True: p = A[p]-1 cnt += 1 if used[p]: m = p break used[p] = True p = 0 while m!=p and K: cnt -= 1 p = A[p]-1 K -= 1 if K==0: print(p+1) import sys sys.exit() K %= cnt while K: p = A[p]-1 K -= 1 print(p+1)" p02684,s085990856,Accepted,"n,k=map(int,input().split("" "")) a=[int(i)-1 for i in input().split("" "")] was=[False]*n pos=0 while k>0 and not was[pos]: was[pos]=True pos=a[pos] k-=1 if k>0: was=[False]*n cyc=0 while not was[pos]: was[pos]=True pos=a[pos] cyc+=1 k%=cyc while k>0: pos=a[pos] k-=1 print(pos+1)" p02684,s852110828,Accepted,"N, K = map(int, input().split("" "")) routs = {} location = [0 for i in range(N + 1)] tereporter = list(map(int, input().split())) for i in range(N): routs[i] = tereporter[i] - 1 present_location = 0 n = 0 for i in range(K): n += 1 present_location = routs[present_location] if location[present_location] == 0: location[present_location] = n else: loop = n - location[present_location] if (K - location[present_location]) % loop == 0: break else: for i in range((K - location[present_location]) % loop): present_location = routs[present_location] break print(present_location + 1)" 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))" p02684,s398397499,Accepted,"n,k = map(int, input().split()) a = list(map(int, input().split())) a.insert(0,0) now = 1 seen = [0]*(n+1) seen[1] = 1 for i in range(1,n+1): now = a[now] if seen[now] != 0: break else: seen[now] = i+1 if k <= max(seen): print(a[seen.index(k)]) elif (k - max(seen)) % (max(seen)-seen[now]+1) == 0: print(a[seen.index(max(seen))]) else: print(a[seen.index(max(seen) - (max(seen)-seen[now]+1) + (k - max(seen)) % (max(seen)-seen[now]+1))])" p02684,s176851969,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) a = [i-1 for i in a] visited = [-1]*n route = [] now = 0 hop = 0 while visited[now] == -1: visited[now]=hop route.append(now) now = a[now] hop+=1 loop_st = 0 for r in route: if r==now: break loop_st+=1 loop = route[loop_st:] if k < len(route): print(route[k]+1) else: print(loop[(k-loop_st)%len(loop)]+1)" p02684,s195650994,Accepted,"n, k = map(int, input().split()) A = list(map(int, input().split())) L = [1] S = {1} while A[L[-1]-1] not in S: last = L[-1]-1 L.append(A[last]) S |= {A[last]} a = A[L[-1]-1] j = L.index(a) r = len(L) l = r - j if k+1 <= j: print(L[k]) else: print(L[j+(k-j)%l]) " p02684,s507094397,Accepted,"N,K=map(int,input().split()) A=[~-int(x) for x in input().split()] p,c=[-1]*N,0 for i in range(N+1): if p[c]==-1: p[c]=i c=A[c] else: break print(1+p.index(p[c]+(K-p[c])%(i-p[c]) if K>=p[c] else K)) " p02684,s373984561,Accepted,"n,k=map(int,input().split()) A=list(map(int,input().split())) cnt=0 s=1 M=[0] B=[0]*(n+1) while cnt first: print(new[(k-first)%t]) else: print(s[k])" p02684,s994277619,Accepted,"N, K = list(map(int, input().split())) A = list(map(lambda x: int(x) - 1, input().split())) v = [A[:]] now = 0 for i in range(60): v.append([v[i][v[i][j]] for j in range(N)]) if K>>i & 1: now = v[i][now] print(now + 1)" p02684,s791766559,Accepted,"N, K = map(int, input().split()) As = list(map(int, input().split())) lastVisit = [None] * N now = 0 n = 0 while lastVisit[now] is None: lastVisit[now] = n now = As[now]-1 n += 1 if n == K: print(now+1) exit() for _ in range((K-lastVisit[now]) % (n-lastVisit[now])): now = As[now]-1 print(now+1) " p02684,s745865789,Accepted,"import sys input = sys.stdin.readline N, K = map(int, input().split()) a = list(map(int, input().split())) dbl = [[0] * 61 for _ in range(N)] for i in range(N): dbl[i][0] = a[i] - 1 for k in range(60): for i in range(N): x = dbl[i][k] dbl[i][k + 1] = dbl[x][k] x = 0 while K: x = dbl[x][K.bit_length() - 1] K -= 1 << (K.bit_length() - 1) print(x + 1)" 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) " p02684,s089780001,Accepted,"def main(): N, K = map(int, input().split()) A_list = input().split() root = [1] record = [-1]*N break_flag = 0 for n in range(K): new = int(A_list[ int(root[n])-1 ]) if record[new-1] <0: record[new-1]=1 root.append(new) else: ind = root.index(new) break else: print(new) break_flag = 1 if break_flag == 0: pre = len(root[:ind]) roop = len(root)-pre print(root[ind:][(K-pre)%roop]) if __name__ == '__main__': main()" p02684,s280731117,Accepted,"N, K = map(int, input().split()) A = list(map(lambda x:int(x)-1, input().split())) cnts = [None] * N pos = 0 cnt = 0 while cnt < K: if cnts[pos] != None: loop_size = cnt - cnts[pos] cnt += ((K-cnt-1) // loop_size) * loop_size cnts = [None] * N cnts[pos] = cnt pos = A[pos] cnt += 1 print(pos+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)" p02684,s839433517,Accepted,"n,k = map(int, input().split()) a = list(map(int,input().split())) ans = 1 c = [1] d = [0]*(n+5) d[1] = 1 for j in range(1,2*n): i = a[c[-1]-1] if d[i] == 1: g = i break # if i in set(c): # g = i # break d[i] = 1 c.append(i) s = c.index(g) r = len(c)-s if k <=s: print(c[k]) else: b = (k-s)%r print(c[s+b])" p02684,s375664560,Accepted,"N, K = map(int,input().split()) t = list(map(int,input().split())) visited = [0] * N idx = 0 town = 0 if K <= N: for i in range(K): idx = t[idx] -1 print(idx+1) else: for i in range(K): if visited[idx]: cycle = i - visited[idx] rem_step = (K - i) % cycle town = visited.index(visited[idx] + rem_step) break visited[idx] = i idx = t[idx] - 1 print(town+1)" p02684,s826107316,Accepted,"import sys readline = sys.stdin.readline N,K = map(int,readline().split()) A = [0] + list(map(int,readline().split())) c = 1 while K: if K & 1: c = A[c] A = [A[A[i]] for i in range(len(A))] K >>= 1 print(c)" 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> i & 1: now = tel[i][now] print(now + 1) " p02684,s779354540,Accepted,"n,k = map(int,input().split()) a = list(map(int,input().split())) t = 1 tl = [1] ts = {1} for i in range(len(a)): t = a[t-1] if t in ts: break else: tl.append(t) ts.add(t) tl2 = tl[tl.index(t):len(tl)] if k < len(tl): ans = tl[k] else: k = k - (len(tl) - len(tl2)) j = k % len(tl2) ans = tl2[j] print(ans)" p02684,s399832802,Accepted,"n,k=map(int,input().split()) loop_=[1] l_set=set() lst=list(map(int,input().split())) tar=None for i in range(k): num=lst[loop_[-1]-1] if num in l_set: tar=num break else: loop_.append(num) l_set.add(num) if tar==None: print(loop_[k]) exit() loop__=loop_[loop_.index(tar):] num=k+1-len(loop_) try: print(loop__[num%len(loop__)-1]) except: print(1)" p02684,s246378841,Accepted,"n, k, *a = map(int, open(0).read().split()) now = 0 st = set() ls = [] while not now in st: st.add(now) ls.append(now) now = a[now]-1 bi = ls.index(now) lp = len(ls) - bi if k<=bi: print(ls[k]+1) else: k -= bi k %= lp print(ls[bi+k]+1)" p02684,s300205750,Accepted,"from collections import defaultdict N, K = map(int, input().split()) A = list(map(int, input().split())) visited = [0] * N current = 0 i = 1 while i <= K: current = A[current] - 1 if visited[current] == 0: visited[current] = i else: loop = i - visited[current] num_loop = (K - i) // loop i += loop * num_loop i += 1 ans = current + 1 print(ans)" p02684,s130059845,Accepted,"n, k = map(int, (input().split())) a = [0] + [int(i) for i in input().split()] path = [1] chk = {1} idx = 1 loop_s = 1 loop_e = n for i in range(1, n + 1): if a[idx] not in chk: idx = a[idx] path.append(idx) chk.add(idx) else: loop_s = path.index(a[idx]) loop_e = i break if k <= loop_s: print(path[k]) else: print(path[loop_s + (k - loop_s) % (loop_e - loop_s)])" p02684,s452020789,Accepted,"n,k=map(int,input().split()) a=list(map(int,input().split())) visited = [-1]*(n+1) pos = 1 visited[pos] = 0 loop = 0 root=[1] for i in range(1,n+1): pos = a[pos-1] if visited[pos] == -1: visited[pos] = i root.append(pos) else: loop = i - visited[pos] mae = visited[pos] break if k < mae: print(root[k]) else: index=(k-mae)%loop print(root[index+mae])" p02684,s093083710,Accepted,"N,K=map(int, input().split()) a_ls=list(map(int, input().split())) j=1 step=0 s=set([]) l=[] loop_s=-1 loop_g=-1 while True: s.add(j) l+=[j] j=a_ls[j-1] #update if j in s: loop_s=l.index(j) loop_g=len(l) break #print(l) #print(loop_s) #print(loop_g) if K 1: loops += 1 k = max(0, K-one) % loops + min(K, one) pre = 0 for _ in range(k): pre = A[pre] print(pre + 1) " p02684,s155514682,Accepted,"N,K = map(int,input().split()) A = [0] + list(map(int,input().split())) now = 1 while K: if K & 1: now = A[now] A = [A[A[i]] for i in range(len(A))] K >>= 1 print(now)" p02684,s521954741,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) pos = 0 visit = [0]*n move = [] roop = [] while visit[pos] != 2: if visit[pos] == 0: move.append(pos) else: roop.append(pos) visit[pos] += 1 pos = a[pos] - 1 if len(move) > k: print(move[k]+1) else: print(roop[(k-(len(move)-len(roop))) % len(roop)]+1) " p02684,s265559514,Accepted,"N,K = map(int,input().split()) A = list(map(lambda x:int(x)-1,input().split())) F = [False]*N L = [] cnt = 0 ans = -1 x = 0 first = -1 while 1: if first==x:break if cnt==K: ans = x break if F[x]: if first==-1: first = x L.append(x) F[x]=True cnt += 1 x = A[x] if ans==-1: N = len(L) ans = L[(K-cnt)%N] print(ans+1)" 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])" p02684,s957274207,Accepted,"import sys input = sys.stdin.readline n, k = (int(x) for x in input().split()) seq = [int(x) for x in input().split()] visited = [[False,0] for _ in xrange(n)] t = 1 cnt = 0 if n < k: while not visited[t-1][0]: visited[t-1][0] = True visited[t-1][1] = cnt t = seq[t-1] cnt += 1 cycle_len = cnt - visited[t-1][1] else: cycle_len = n for _ in xrange((k-visited[t-1][1]) % cycle_len): t = seq[t-1] print(t) " p02684,s656074531,Accepted,"n,k=map(int,input().split()) a=list(map(int,input().split())) b=[1] Flag=True now=1 arrived=set(b) memo=1 while Flag: b.append(a[now-1]) if a[now-1] in arrived: Flag=False memo=a[now-1] arrived.add(a[now-1]) now=a[now-1] loop=len(b)-b.index(memo)-1 first=b.index(memo) if k>first: p,q=divmod(k-first,loop) print(b[first+q]) else: print(b[k])" p02684,s587121207,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) for i in range(N): A[i] -= 1 L = [0] t = 0 F = [-1 for _ in range(N)] F[0] = 0 c = 1 while F[A[t]] == -1: t = A[t] F[t] = c c += 1 L.append(t) loop = c - F[A[t]] buffer = c - loop if K < buffer: print(L[K] + 1) else: NL = L[buffer:] amari = (K - buffer) % loop print(NL[amari] + 1) " p02684,s082468687,Accepted,"n,k = [int(x) for x in input().split()] a = [int(x)-1 for x in input().split()] loop = [] seen = [0]*n num = 0 flag = 0 while k>0: if seen[num]==1: flag = 1 break seen[num]=1 loop.append(num) num = a[num] k-=1 if flag: index = loop.index(num) loop = loop[index:] print(loop[(k%len(loop))]+1) else: print(num+1)" p02684,s977221239,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) T = [1] c = [0]*N k = 1 st = 0 c[0] = 1 cc = 1 for i in range(N): k = A[k-1] if c[k-1] == 1: st = T.index(k) f = T[:st] r = T[st:] break T.append(k) c[k-1] += 1 cc += 1 ff = len(f) if K < ff: print(f[K]) else: print(r[(K-ff)%(cc-ff)]) " p02684,s933195770,Accepted,"N,K = map(int,input().split()) A = list(map(int,input().split())) pos = 0 visit = [0] * N move = [] roop = [] while visit[pos]!=2: if visit[pos]==0: move.append(pos) else: roop.append(pos) visit[pos] += 1 pos = A[pos] - 1 if len(move)>K: print(move[K]+1) else: print(roop[(K-(len(move)-len(roop)))%len(roop)]+1)" p02684,s987292464,Accepted,"n, k = map(int, input().strip().split()) L = list(map(int, input().strip().split())) L = [v - 1 for v in L] seen = set() intersec = 0 route=[] while intersec not in seen: seen.add(intersec) route.append(intersec) intersec = L[intersec] intersecInd = route.index(intersec) if k<=intersecInd: ans=route[k] else: loopSize = len(route) - intersecInd ans = route[(k - intersecInd) % (loopSize) + intersecInd] print(ans + 1)" p02684,s774354532,Accepted,"import numpy as np N, K = (int(i) for i in input().split()) A = [int(i) - 1 for i in input().split()] N = len(A) def get_keys_from_value(d, val): return [k for k, v in d.items() if v == val][0] now = 0 lis = [] p = {} for i in range(N): now = A[now] if now in p: break p[now] = i lis.append(now) if K < i: print(lis[K-1] + 1) else: print(lis[(K-i-1) % (i - p[now]) + p[now]] + 1) " p02684,s858624944,Accepted,"n, k = map(int, input().split()) a = [0] + [int(i) for i in input().split("" "")] b = [0,1] + [0]*(n-1) c = [1] nex = 1 for i in range(1,n+1): nex = a[nex] if b[nex] == 1: whe = c.index(nex) lo = len(c)-whe break b[nex] = 1 c.append(nex) if whe+1 >= k: print(c[k]) else: k_ = k - whe print(c[whe:][k_%lo])" p02684,s072438956,Accepted,"n, k = map(int, input().split()) a = [0] + list(map(int, input().split())) journey = [1] for i in range(2 * n + 100): next = a[journey[-1]] journey.append(next) if k < n+1: print(journey[k]) exit() loop_end = n loop_start = n - 1 while (journey[loop_start] != journey[loop_end]): loop_start -= 1 period = loop_end - loop_start k %= period while k < n: k += period print(journey[k]) " p02684,s869024429,Accepted,"#!python3 def LI(): return list(map(int, input().split())) # input N, K = LI() A = LI() def main(): n = 0 x = 1 visit = [None] * N while visit[x - 1] is None: if n == K: print(x) return visit[x - 1] = n n += 1 x = A[x - 1] v = n - visit[x - 1] s = (K - n) % v ans = visit.index(visit[x - 1] + s) + 1 print(ans) if __name__ == ""__main__"": main() " p02684,s175780273,Accepted,"from sys import exit N,K = map(int,input().split()) town = [None]+list(map(int,input().split())) flag = [None]+[0]*N remain = K piece = 1 cnt = 1 while remain > 0: if flag[town[piece]] != 0: q = cnt-flag[town[piece]] piece = town[piece] remain -= 1 break else: piece = town[piece] flag[piece] = cnt remain -= 1 cnt += 1 if remain == 0: print(piece) exit(0) remain %= q while remain > 0: piece = town[piece] remain -= 1 print(piece)" p02684,s602133000,Accepted,"n, k = map(int, input().split()) a = [0] + list(map(int, input().split())) seen = [False] * (n+1) visited = [] nxt = 1 cnt = 0 while not seen[nxt] and cnt != k: seen[nxt] = True visited.append(nxt) nxt = a[nxt] cnt += 1 if cnt == k: print(nxt) exit() idx = visited.index(nxt) print(visited[idx:][(k-idx)%(len(visited)-idx)]) " p02684,s358682117,Accepted,"n,k,*a=map(int,open(0).read().split()) d=[2*k]*n s=0 while k:s=a[s]-1;d[s]=k=~-k%(d[s]+1-k) print(s+1)" p02684,s192802502,Accepted,"N, K = map(int,input().split()) Map = list(map(int,input().split())) Visited = [-1]*N now = 1 Order = [0]*N loopcount = 1 Order[0] = 1 Visited[0] = 1 for i in range(1,N): nt = Map[now-1] Order[i] = nt loopcount += 1 if Visited[nt-1] == -1: Visited[nt-1] = loopcount else: break now = nt ns = Visited[nt-1] period = loopcount - ns if period == 0: period = loopcount ns = 0 Kmod = K - ns if Kmod > 0: Kmod %= period print(Order[ns+Kmod]) " p02684,s481719233,Accepted,"n,k,*a=map(int,open(0).read().split()) d=[2*k]*-~n s=1 while k:k-=1;s=a[s-1];k%=d[s]-k;d[s]=k print(s)" p02684,s085842441,Accepted,"from collections import defaultdict n,k=map(int,input().split()) a=list(map(int,input().split())) order = [] now = 1 count = 0 d = defaultdict(int) for i in range(n): if d[now]!=0: s=d[now]-1 g=i break order.append(now) d[now] = i+1 now = a[now-1] if k<=s: print(order[k]) else: k-=s loop = order[s:g] print(loop[k%len(loop)])" p02684,s763743822,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) R = {1:0} i, t = A[0], 1 while K > t: r = R.get(i) if r == None: R[i] = t i = A[i-1] t += 1 else: K -= r K %= t - r for k in range(K): i = A[i-1] print(i)" p02684,s229106806,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) x=1 while K: if K&1: x=A[x-1] K>>=1 A2 = [None]*N for i,a in enumerate(A): A2[i]=A[A[i]-1] A=A2 print(x)" p02684,s692278515,Accepted,"n,k=map(int,input().split()) l=list(map(int,input().split())) double=[[0]*(n+1) for i in range(61)] for i in range(1,n+1): double[0][i]=l[i-1] for i in range(1,61): for j in range(n+1): double[i][j]=double[i-1][double[i-1][j]] ans=1 for i in range(61): if k>>i&1: ans=double[i][ans] print(ans)" p02684,s960802512,Accepted,"n, m = map(int, input().split()) lis = list(map(lambda z: int(z) - 1, map(int, input().split()))) s = {0} res = [0] while lis[res[-1]] not in s: res.append(lis[res[-1]]) s.add(res[-1]) x, y = res.index(lis[res[-1]]), len(res) if m < y: print(res[m] + 1) else: mm = (m - x) % (y - x) print(res[mm + x] + 1) " p02684,s503330941,Accepted,"N,K = map(int,input().split()) A = list(map(int,input().split())) counter = 0 place_list = [] place_set = set() next = 1 while True: if next in place_set: break else: place_list.append(next) place_set.add(next) next = A[next-1] counter += 1 duration_cycle = len(place_list)- place_list.index(next) if K =s else B[K]+1 print(ans)" p02684,s037386536,Accepted,"n,k = map(int,input().split()) a = list(map(int,input().split())) t=[[0 for i in range(n)] for j in range(64)] for i in range(64): for j in range(n): if i == 0: t[i][j]=a[j] else: t[i][j]=t[i-1][t[i-1][j]-1] ans=1 for i in range(64): r = k%2 k = k//2 if r == 1: ans = t[i][ans-1] if k == 0: print(ans) exit() " p02684,s816781921,Accepted,"N,K = map(int,input().split()) A = list(map(lambda x: int(x) - 1, input().split())) P = [-1] * N cur = 0 P[cur] = 0 route = [1] for step in range(K): cur = A[cur] route.append(cur + 1) if P[cur] >= 0: l_start = P[cur] l_end = step + 1 l_len = l_end - l_start break else: P[cur] = step + 1 else: print(cur + 1) quit() print(route[l_start + ((K - l_start) % l_len)])" p02684,s504181251,Accepted,"def main(): N, K = [int(x) for x in input().split()] a = [int(x)-1 for x in input().split()] pos = 0 while K > 0: if K&1: pos = a[pos] # doubling a = [a[a[i]] for i in range(N)] K >>= 1 print(pos+1) if __name__ == '__main__': main() " p02684,s400483348,Accepted,"N, K = map(int, input().split()) P = list(map(int, input().split())) for i in range(N): P[i] -= 1 M = 60 step = [[0]*(M+1) for _ in range(N)] for i in range(N): step[i][0] = P[i] for i in range(1, M+1): for j in range(N): c = step[j][i-1] c = step[c][i-1] step[j][i] = c c = 0 for j in range(M+1): if K % 2: c = step[c][j] K //= 2 print(c+1) " 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)" p02684,s363889216,Accepted,"N, K = map(int, input().split()) A = list(map(lambda a: int(a) - 1, input().split())) INF = 10**18 minDist = [INF] * N minDist[0] = 0 now = 0 R = 0 while minDist[now] < INF: to = A[now] if minDist[to] < INF: R = minDist[now] + 1 - minDist[to] break minDist[to] = minDist[now] + 1 now = to if minDist.count(K) > 0: print(minDist.index(K) + 1) exit() K -= minDist[now] M = K % R for _ in range(M): now = A[now] print(now + 1)" 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]) " p02684,s478871115,Accepted,"N, K = [int(x) for x in input().split()] dest = [int(x) for x in input().split()] route = [1] flag = [1] + [0] * (N-1) t = 1 while True: if flag[dest[t-1]-1] == 0: t = dest[t-1] route.append(t) flag[t-1] = 1 else: loop = route.index(dest[t-1]) L_loop = len(route) - loop break #print(route) #print(flag) ans = 0 if K < len(route): ans = route[K] else: K = K - len(route) ans = route[loop + (K % L_loop)] print(ans)" p02684,s154734461,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) visited = [False]*N path = [0] at = 0 loop = 0 visited[0]=True for i in range(N): at = A[at]-1 if visited[at]: loop = i+1-path.index(at) break else: visited[at]=True path.append(at) if K < len(path): print(path[K]+1) else: print(path[(K-path.index(at))%loop+path.index(at)]+1)" p02684,s552648814,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)" p02684,s957045097,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) num = 1 li = [1] flag = [True]*n flag[0] = False for i in range(k): num = a[num-1] if flag[num-1]: li.append(num) flag[num-1] = False else: break d = li.index(num) ans = (k-d) % (len(li)-d)+d print(li[ans]) " p02684,s151808376,Accepted,"import sys sys.setrecursionlimit(700000) def s_in(): return input() def n_in(): return int(input()) def l_in(): return list(map(int, input().split())) n,k=l_in() A=l_in() cnt=0 current = 0 memo={0: 0} while cnt < k: n = A[current]-1 cnt += 1 if n in memo: delta = cnt - memo[n] p = (k-cnt)//delta cnt += p*delta else: memo[n] = cnt current = n print(current+1) " p02684,s686444247,Accepted,"N, K = list(map(int,input().split())) A = list(map(int,input().split())) root = [1] setroot = set(root) for i in range(N): if A[root[-1]-1] in setroot: start = root.index(A[root[-1]-1]) break setroot.add(A[root[-1]-1]) root.append(A[root[-1]-1]) roop = root[start:] if K <= start: print(root[K]) else: print(root[(K-start)%len(roop)+start])" p02684,s165520765,Accepted,"n, k = map(int, input().split()) A = list(map(lambda x: int(x)-1, input().split())) bit = k.bit_length() table = [[0]*n for _ in range(bit)] table[0] = A for i in range(1, bit): for j in range(n): table[i][j] = table[i-1][table[i-1][j]] ans = 0 for i in reversed(range(bit)): if (1 << i) <= k: k -= 1 << i ans = table[i][ans] print(ans+1) " p02684,s024267729,Accepted,"X = input().split() N = int(X[0]) K = int(X[1]) H = input().split() A = [int(z) for z in H] B = [] s = [] for z in range(N): B.append(0) s.append(0) C = 1 B[0] +=1 s[0] = 0 for i in range(K): C = A[C-1] B[C-1] += 1 if(B[C-1] == 2): break s[C-1] = i+1 r = i+1 - s[C-1] if not r == 0: #uに余りを入れる t = (K - s[C-1]) u = t % r for g in range(u): C = A[C-1] print(C) " 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) " p02684,s558082460,Accepted,"n,k=map(int,input().split()) mati=list(map(int,input().split())) count=0 i=mati[0] matidic={} frag=1 while frag: count+=1 if i in matidic: frag=0 bef=matidic[i] roop=count-bef else: matidic[i]=count i = mati[i - 1] #print(roop,bef,matidic) #print(k%roop) if bef= k: print(route[k-1]) else: route = route[count:] num = (k-count)%len(route) print(route[num-1]) " 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)" p02684,s662754894,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) s = 1 c = 0 d = {} t = [] # 順番をdictで持つ while not s in d.keys(): d[s] = c t.append(s) c += 1 s = a[s-1] l = c - d[s] m = len(d.keys()) - l if m >= k: print(t[k]) else: print(t[(k - m) % l + m]) " p02684,s819760522,Accepted,"n,k = map(int,input().split()) a = list(map(int,input().split())) dic = {} for key, a in zip(range(1, n+1), a): dic[key] = a log = [-1]*(n+1) next = dic[1] step = 1 log[next] = step k -= 1 while k: next = dic[next] step += 1 k -= 1 if log[next] != -1: k %= log[next] - step else: log[next] = step print(next)" p02684,s756606607,Accepted,"N, K = map(int, input().split()) *A, = map(int, input().split()) s = 0 l = 0 n = 0 h = [0]*N while True: h[s] = l s = A[s]-1 l += 1 if h[s]: n = l-h[s] break if K < h[s]: s = 0 else: K -= h[s] K = K % n while K > 0: s = A[s]-1 K = K-1 print(s+1) " p02684,s947487270,Accepted,"N, K, *A = map(int, open(0).read().split()) # Destination t = [[-1] * N for _ in range(61)] t[0] = [v - 1 for v in A] for k in range(60): for i in range(N): t[k + 1][i] = t[k][t[k][i]] u = 0 for k in range(61): if K >> k & 1: u = t[k][u] print(u + 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) " p02684,s723520751,Accepted,"n, k = map(int, input().split()) A = list(map(int, input().split())) L = [0] * n L[0] = 1 i = A[0] - 1 j = 1 while j < k: if L[i] < 2: L[i] += 1 else: break i = A[i] - 1 j += 1 if j == k: print(i + 1) else: loop = L.count(2) k = (k - L.count(1)) % loop while k > 0: i = A[i] - 1 k -= 1 print(i + 1) " p02684,s837511093,Accepted,"import sys n, k = map(int, input().split()) ara = [0] ara += list( map(int, input().split()) ) now = 1 vis = [] taken = [0]*(n+1) while taken[now] == 0: vis.append(now) taken[now] = 1 now = ara[now] cycleLen = len(vis) - vis.index(now) if k < vis.index(now): print(vis[k]) sys.exit() k -= vis.index(now) k %= cycleLen print(vis[k + vis.index(now) ]) " p02684,s104316611,Accepted,"N,K=map(int,input().split()) A=list(map(int,input().split())) A=[A[i]-1 for i in range(N)] doubling=[[0 for i in range(N)] for i in range(0,70)] for i in range(N): doubling[0][i]=A[i] for i in range(1,70): for j in range(N): doubling[i][j]=doubling[i-1][doubling[i-1][j]] ans=0 for i in range(0,70): if K>>i &1==1: ans=doubling[i][ans] print(ans+1) " p02684,s199815836,Accepted,"N,K=map(int,input().split()) A=[int(i)-1 for i in input().split()] def times(X,Y): return [X[Y[i]] for i in range(N)] def exponen(X,n): if n==0: return [i for i in range(N)] if n==1: return X if n%2==0: Y=exponen(X,n//2) return times(Y,Y) if n%2==1: Y=exponen(X,n//2) return times(times(Y,Y),X) B=exponen(A,K) print(B[0]+1) " p02684,s088680823,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) for i in range(n): a[i] -= 1 l = [-1]*(n + 1) l[0] = 0 order = 0 now = 0 while k > 0: k -= 1 now = a[now] order += 1 if l[now] == -1: l[now] = order else: loop = order - l[now] k %= loop break while k > 0: k -= 1 now = a[now] print(now + 1)" p02684,s074323743,Accepted,"n,k = map(int,input().split()) a = list(map(int,input().split())) already = [""1""] set = {""1""} now = 1 for i in range(n): now = str(a[int(now)-1]) if now in set: break else: already.append(now) set.add(now) ind = already.index(now) k -= ind cycle = already[ind:] if k <= 0: print(already[k+ind]) else: now = (k+1) % len(cycle) print(cycle[now-1])" p02684,s732047073,Accepted,"n, k = map(int, input().split()) a = [[int(x)-1 for x in input().split()]] for i in range(1, k.bit_length()): ith = [a[-1][a[-1][i]] for i in range(n)] a.append(ith) ans = 0 for i in range(k.bit_length()): if (k >> i) & 1: ans = a[i][ans] print(ans+1)" p02684,s733774240,Accepted,"n, k = map(int, input().split()) a = [int(i) for i in input().split()] lst = [] visit_now = 1 visit_list = [-1] * (n + 1) cnt = 0 while visit_list[visit_now - 1] == -1: visit_list[visit_now - 1] = cnt lst.append(visit_now) visit_now = a[visit_now - 1] cnt += 1 start = visit_list[visit_now - 1] loop_num = cnt - start if k <= start: ans = lst[k] else: k -= start k %= loop_num ans = lst[start + k] print(ans)" p02684,s764411947,Accepted,"def main(): n, k = map(int, input().split()) a = list(map(int, input().split())) num = 1 l = [] s = [1]*n while s[num-1]: l.append(num) s[num-1] = 0 num = a[num-1] if l.index(num) <= k: l2 = l[l.index(num):] kk = (k-len(set(l)-set(l2)))%len(l2) print(l2[kk]) else: print(l[k]) main() " p02684,s827174259,Accepted,"# -*- coding: utf-8 -*- n, k = map(int, input().split()) a = list(map(lambda x: int(x) - 1, input().split())) passed = [-1 for _ in range(n)] cnt = 0 now = 0 _next = a[now] remain = 0 for i in range(k): _next = a[now] if passed[_next] != -1: pre = passed[_next] remain = (k-pre) % (cnt + 1 - pre) now = _next break passed[now] = cnt now = _next cnt += 1 for _ in range(remain): now = a[now] print(now + 1) " p02684,s071106685,Accepted,"# D - Teleporter N,K = map(int,input().split()) A = [0]+list(map(int,input().split())) s = {1:0} l = [1] i = 1 for j in range(1,10**10): i = A[i] if i in s: sigma = j-s[i] break s[i] = j l.append(i) if K>=1 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)" 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 0: cnt += 1 K -= 1 if visited[pos] == 0: visited[pos] = cnt elif not flag: K %= cnt-visited[pos] flag = True pos = A[pos]-1 print(pos+1)" 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)" p02684,s965075905,Accepted,"n,k = map(int, input().split()) a = list(map(int, input().split())) a = [i-1 for i in a] num = [0] * (n) num[0] = 1 now = 0 looped = 0 for i in range(2,k+2): nex = a[now] if num[nex]: start = num[nex] cycle = i - num[nex] v = (k+1-i) % cycle + start ans = num.index(v) + 1 looped = 1 break else: num[nex] = i now = nex if looped: print(ans) else: print(now+1)" p02684,s459032458,Accepted,"n, k = [int(x) for x in input().split()] a_list = [int(x) - 1 for x in input().split()] ci = 0 while k: if k & 1: ci = a_list[ci] k >>= 1 a_list = [a_list[a_list[i]] for i in range(n)] print(ci + 1)" p02684,s168410106,Accepted,"import sys N, K = map(int, input().split()) As = [0] + list(map(int, input().split())) # print(As) d = [-1]*(N+1) i = 1 step = 1 while step <= K: # print(""step: {}, idx: {}"".format(step,i)) next_i = As[i] if d[next_i] != -1: freq = step - d[next_i] step = step + ((K - step) // freq)*freq d[next_i] = step step += 1 i = next_i print(i)" p02684,s687648533,Accepted,"n, k = map(int,input().split()) A = list(map(int,input().split())) A = [a-1 for a in A] path = [] passed = set([]) p = 0 while 1: if k ==0: print(p+1) exit() if p not in passed: path.append(p) passed.add(p) p = A[p] k -= 1 else: break path = path[path.index(p):] term = len(path) k %= term print(path[k]+1) " p02684,s754510993,Accepted,"N,K = map(int,input().split()) #N = 4,K=5 A = [int(i)-1 for i in input().split()] log_K = K.bit_length() #3bit (5 = 101) next = [[-1]*N for _ in range(log_K)] for i in range(N): next[0][i] = A[i] for k in range(log_K - 1): for i in range(N): next[k+1][i] = next[k][next[k][i]] now = 0 for i in range(log_K)[::-1]: if ((K >> i) & 1) == 1: now = next[i][now] print(now + 1) " p02684,s266589754,Accepted,"n,k=map(int,input().split()) A=list(map(int,input().split())) V=[0]*n V[0]=0 a=0 c=0 for i in range(k): a=A[a]-1 if V[a]!=0: break V[a]=i+1 if i==k-1: print(a+1) exit() else: k=(k-V[a])%(i+1-V[a]) for i in range(k): a=A[a]-1 if k==0: print(a+1) else: print(a+1) " p02684,s973009512,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) dic = {} list_town = [] set_town = set() town = 1 for i, v in enumerate(A): dic[i+1] = v for _ in range(K): list_town.append(town) set_town.add(town) town = dic[town] if town in set_town: stop_town = town break if N <= K: list_first_split = list_town[:list_town.index(stop_town)] list_second_split = list_town[list_town.index(stop_town):] print(list_second_split[(K - (len(list_first_split))) % len(list_second_split)]) else: print(town)" p02684,s393088141,Accepted,"N,K=map(int,input().split()) A=list(map(int,input().split())) done=[-1 for _ in range(N)] done[0]=0 n=0 now=0 init=0 loop=N log=[0] while n-1: init=done[log[-1]] loop=n-done[log[-1]] break done[log[-1]]=n if K 0: k %= cycle_len for i in range(k): city = a[city] print(city+1) " p02684,s420505102,Accepted,"N,K=map(int,input().split(' ')) A=list(map(lambda x:int(x)-1,input().split(' '))) roop=[0] flg = [0 for i in range(N)] flg[0]=1 n = A[0] for i in range(2,N+1): if flg[n]==0: roop.append(n) flg[n] = i n = A[n] else: end=i break if K =0: break visited[now] = i if i==K: ans = now else: num = (K-visited[now])%(i-visited[now])+visited[now] ans = visited.index(num) return ans print(solve()) " p02684,s503137435,Accepted,"import sys input=lambda: sys.stdin.readline().rstrip() n,k=map(int,input().split()) A=[int(i) for i in input().split()] B=[0] S=set() S.add(0) cur=A[0]-1 while True: if cur in S: break else: S.add(cur) B.append(cur) cur=A[cur]-1 d=len(B) ind=B.index(cur) if k<=ind: print(B[k]+1) else: print(B[(k-ind)%(d-ind)+ind]+1) " p02684,s485167588,Accepted,"n, k = map(int, input().split()) list_A = list(map(int, input().split())) list_MAP = [] set_MAP = set() x = 1 while True: list_MAP.append(x) set_MAP.add(x) x = list_A[x-1] if x in set_MAP: break q = len(list_MAP) - list_MAP.index(x) p = k - list_MAP.index(x) if p < 0: print(list_MAP[k]) else: list_MAP = list_MAP[list_MAP.index(x):] print(list_MAP[p % q])" p02684,s954041545,Accepted,"(N, K), A = [[*map(int, line.split())] for line in open(0)] kiseki = [0] * N now = 0 for i in range(N): kiseki[i] = now now = A[now] - 1 p = kiseki.index(now) ans = p + (K - p) % (N - p) if p < K else K print(kiseki[ans] + 1) " p02684,s411999789,Accepted,"n,k=map(int,input().split()) l=list(map(int,input().split())) lcount=[0]*(n+1) lnum=[0]*(n+1) count=1 place=1 while lcount[place]==0: lnum[place]=count lcount[place]=1 place=l[place-1] count+=1 dif=count-lnum[place] if k+1= K: g = K + 1 else: K -= l - 1 K %= n if K != 0: g = l + K else: g = l + n for i in range(N): if D[i] == g: print(i + 1) exit()" p02684,s566922866,Accepted,"n,k = map(int,input().split()) ls = list(map(int,input().split())) fi = [-1]*(n+1) fi[1] = 0 a = 0 aa = 0 for i in range(k): if fi[ls[a]] == -1: fi[ls[a]] = i + 1 aa = a a = ls[a] - 1 else: ind = fi[ls[a]] t = (k - ind) % (max(fi) + 1 - ind) t += ind print(fi.index(t)) break else: print(ls[aa])" p02684,s276665612,Accepted,"n,k=map(int,input().split()) a=list(map(int,input().split())) adj=[1]*n b=[1] now=0 while adj[now]: adj[now]=0 now=a[now]-1 b.append(now+1) loop_start=b.index(b[-1]) loop=b[loop_start:-1] p=len(loop) if kcnt: ind = (k-cnt)%len(y) print(y[ind]+1) else: print(x[k]+1) " p02684,s034698485,Accepted,"n,k = map(int,input().split()) a = list(map(int,input().split())) now = 0 loop = [] flag = [0 for _ in range(n)] for _ in range(n): loop.append(now+1) if flag[now]: break else: flag[now] = 1 now = a[now]-1 tloop = loop[loop.index(loop[-1]):len(loop)-1] floop = loop[:loop.index(loop[-1])] if k < len(floop): print(floop[k]) else: k -= len(floop) print(tloop[k%len(tloop)])" p02684,s134018173,Accepted,"import sys N, K = list(map(int, input().split())) A = [0] + list(map(int, input().split())) visited = [False] * (N+1) s = 1 while not visited[s]: visited[s] = True s = A[s] a = 1 while a != s: K -= 1 a = A[a] if K == 0: print(a) sys.exit() visited = [False] * (N+1) length = 0 while not visited[s]: visited[s] = True s = A[s] length += 1 k = K % length while k: s = A[s] k -= 1 print(s)" p02684,s449406006,Accepted," n, m = map(int, input().split()) a = [[0]+list(map(int, input().split()))] for k in range(62): a.append([a[k][a[k][i]] for i in range(n+1)]) res = 1 for k in list(range(62))[::-1]: if m >= 2**k: res = a[k][res] m -= 2**k print(res)" p02684,s887029048,Accepted,"#!/usr/bin/env python import sys sys.setrecursionlimit(10**9) from collections import deque import heapq from itertools import combinations import bisect n,k=map(int,input().split()) a=list(map(int,input().split())) for i in range(n): a[i]-=1 v=[-1]*n s=0 c=0 while True: if v[s]!=-1: break if c==k: print(s+1) exit() v[s]=c c+=1 s=a[s] p=c-v[s] k-=c k%=p for i in range(k): s=a[s] print(s+1) " p02684,s278844090,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) d = {} d[1] = A[0] idx = 1 start = 0 count = 0 while True: count += 1 if K == count: print(A[idx-1]) exit() d[idx] = A[idx-1] idx = A[idx-1] if idx in d: start = idx break e = {} l = [] while True: e[start] = A[start-1] l.append(e[start]) start = A[start-1] if start in e: break amari = ((K-count-len(l)) % len(l)) if amari != 0: print(l[amari-1]) else: print(l[-1]) " p02684,s989868068,Accepted,"n, k = map(int, input().split()) a = list(map(lambda x: int(x) - 1, input().split())) ts = [[] for _ in range(n)] p = 0 t = 0 while True: ts[p].append(t) if t == k: print(p + 1) exit() if len(ts[p]) == 2: if (k - ts[p][0]) % (ts[p][1] - ts[p][0]) == 0: print(p + 1) exit() p = a[p] t += 1 " p02684,s393405270,Accepted,"N,K=list(map(int,input().split())) A=[0]+list(map(int,input().split())) visit=set() order=[-1]*(N+1) p=1 cnt=0 while not (p in visit): visit.add(p) order[cnt]=p p=A[p] cnt+=1 start=order.index(p) end=cnt if K>end: K-=(end-start)*max(0,(K-start)//(end-start)-1) p=1 while K>0: p=A[p] K-=1 print(p)" p02684,s295617357,Accepted,"import sys def input(): return sys.stdin.readline().strip() N, K = map(int, input().split()) k_bitlen = K.bit_length() dp = [[0] * N for _ in range(k_bitlen + 1)] dp[0] = list(map(lambda x: int(x) - 1, input().split())) for k in range(k_bitlen): for i in range(N): dp[k + 1][i] = dp[k][dp[k][i]] pos = 0 for k in range(k_bitlen): if K >> k & 1: pos = dp[k][pos] print(pos + 1)" p02684,s011650091,Accepted,"n,k = map(int,input().split()) a = list(map(lambda x: int(x)-1,input().split())) towns = [0] added = [-1] * n added[0] = 0 for i in range(1,k+1): tmp = a[towns[-1]] pl = added[tmp] if pl != -1: loop = towns[pl:] last = (k-pl) % len(loop) print(loop[last]+1) exit() else: added[tmp] = i towns.append(tmp) print(towns[-1]+1) " p02684,s073502857,Accepted,"N, K = map(int, input().split()) A = map(int, input().split()) A = [x-1 for x in A] # 0-indexedに変換 here = 0 visited = set() route = [] while here not in visited: visited.add(here) route.append(here) here = A[here] loopStart = route.index(here) if K <= loopStart: ans = route[K] else: lenCycle = len(route) - loopStart ans = route[loopStart + (K - loopStart) % lenCycle] print(ans + 1)" p02684,s950651824,Accepted,"from collections import Counter n, k = map(int, input().split()) A = list(map(int, input().split())) C = Counter([]) X, Y = [], [] m = 0 for _ in range(n): a = A[m]-1 C[m] += 1 X.append(m) if C[a] != 0: Y = X[X.index(a):] X = X[:X.index(a)] break m = a # print(X,Y) x = len(X) y = len(Y) if k <= x-1: print(X[k]+1) else: k -= x print(Y[k-(k//y)*y]+1) " p02684,s526354798,Accepted,"import sys sys.setrecursionlimit(10**6) n, k = map(int, input().split()) a = list(map(int, input().split())) length = [-1] * n path = [-1, []] route = [] def func(now, depth): global path, length, a, route route.append(now) if length[now] == -1: length[now] = depth func(a[now]-1, depth+1) else: path = [length[now], route[length[now]:depth]] func(0, 0) if (k < path[0]): print(route[k] + 1) else: tmp = k - path[0] tmp %= len(path[1]) print(path[1][tmp] + 1) " p02684,s284613119,Accepted,"import sys n,k=map(int,input().split()) a=list(map(lambda x:int(x)-1,input().split())) x=[-1]*n x[0]=0 now=0 if k<=n: for _ in range(k): now=a[now] print(now+1) sys.exit() for i in range(1,n+1): now=a[now] if x[now]==-1: x[now]=i else: k=(k-x[now])%(i-x[now]) break for i in range(k): now=a[now] print(now+1)" p02684,s739682627,Accepted,"n,k=map(int,input().split()) a=list(map(int,input().split())) visited=set() new=0 c=0 while not new in visited and c 0: break print(tele[(K-(gone[to]))%(cnt-gone[to]) + gone[to]] + 1) else: for i in range(K): to = A[to] print(to + 1)" p02684,s534749201,Accepted,"# coding: utf-8 N,K=map(int,input().split()) A=list(map(int,input().split())) used=[False for i in range(N)] used[0]=True p=1 L=[1] for i in range(N+1): p=A[p-1] L.append(p) if used[p-1]: looper=p break used[p-1]=True for i in range(len(L)): if L[-(2+i)]==looper: a=i+1 b=len(L)-1-a break if K>b: ans=L[b+(K-b)%a] else: ans=L[K] print(ans)" p02684,s498812208,Accepted,"n,k=map(int,input().split()) A = [int(v)-1 for v in input().split()] memo = {} p = 0 for i in range(k): if p in memo: itvl = i - memo[p] rest = (k-i-1)%itvl for j in range(rest+1): p=A[p] print(p+1) exit() else: memo[p]=i p=A[p] print(p+1) " p02684,s975815283,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) b = [0]*n pos = 0 j = 0 while True: b[pos] += 1 if b[pos]>1: rpos = pos pos = a[rpos]-1 i = 1 while True: if pos == rpos: break pos = a[pos]-1 i += 1 break pos = a[pos]-1 j += 1 j = j-i if k>j: kp = (k-j)%i pos = rpos else: kp = k pos = 0 for _ in range(kp): pos = a[pos]-1 print(pos+1)" p02684,s229330979,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) b = [-1 for _ in range(n)] curr = 0 cnt = 0 k += 1 while k > 1: if b[curr] != -1: loop = cnt - b[curr] break b[curr] = cnt cnt += 1 k -= 1 curr = a[curr] - 1 if k != 1: mod = k % loop for i in range((mod-1) % loop): curr = a[curr] - 1 print(curr + 1)" p02684,s410406494,Accepted,"from collections import defaultdict n, k = list(map(int, input().split())) a = list(map(int, input().split())) for i in range(n): a[i] -= 1 loop = [0] town = 0 visited = defaultdict(lambda: None) visited[town] = 0 period = 0 for i in range(1, k+1): town = a[town] if visited[town] != None: offset = visited[town] period = i - offset break else: loop.append(town) visited[town] = i if period == 0: print(town+1) else: print(loop[offset+((k-offset)%period)]+1)" p02684,s351469872,Accepted,"n,k=map(int,input().split()) a=list(map(int,input().split())) x=[0]*(n) before = 0 now = 0 while x[now] == 0: x[now]=1+x[before] before=now now = a[now]-1 y=x[now]-x[0] z=x[before]-y if k>y: l=(k-y)%z+1 else : l=k-y+1 for i in range(n): if x[i] == l+y: print(1+i) break" p02684,s278667883,Accepted,"N,K=map(int,input().split()) A=list(map(int,input().split())) move=[] for i in range(0,N): move.append([]) A[i]-=1 move[i].append(A[i]) for j in range(1,64): for i in range(0,N): move[i].append(move[move[i][j-1]][j-1]) town=0 for i in range(0,64): if K%2==1: town=move[town][i] K//=2 print(town+1) " p02684,s888702833,Accepted,"n,k=map(int,input().split()) l=list(map(int,input().split())) i=0 cnt=0 lcnt=0 sl=[0]*n for p in range(k): if sl[i]==0: sl[i]=1 i=l[i]-1 cnt+=1 elif sl[i]==1: sl[i]=2 lcnt+=1 i=l[i]-1 else: c=(k-cnt)%lcnt if c!=0: for tmp in range(c): i=l[i]-1 break print(i+1) " p02684,s696983546,Accepted,"n,k,*a=map(int,open(0).read().split()) d={} s=1 while k:k-=1;s=a[s-1];k%=d.get(s,2**61)-k;d[s]=k print(s)" p02684,s062453515,Accepted,"n, k = map(int, input().split()) an = list(map(int, input().split())) bn = [-1]*(n+1) now=1 bn[1]=0 for i in range(1, k+1): # print(bn) now = an[now-1] if bn[now] >0: rp =i-bn[now] p= (k-i)%rp for j in range(p): now = an[now-1] print(now) exit(0) bn[now]=i print(now)" p02684,s394393427,Accepted,"tem1=input().split() N = int(tem1[0]) K = int(tem1[1]) tem2 = input().split() jud = [0 for i in range(len(tem2))] now =1 circle=0 for i in range(0,K): if jud[now-1]==0: jud[now-1]=i now = int(tem2[now - 1]) else: circle=i-jud[now-1] fact=(K-i-1)%circle for j in range(0,fact+1): now = int(tem2[now - 1]) break print(now)" p02684,s593617523,Accepted,"import copy n, k = map(int, input().split()) a = list(map(lambda x: int(x) - 1, input().split())) now = 0 while k > 0: if k & 1: now = a[now] a_next = [-1] * n for i in range(n): a_next[i] = a[a[i]] a = copy.copy(a_next) k = k >> 1 ans = now + 1 print(ans) " p02684,s609609115,Accepted,"n, k = map(int, input().split()) arr = list(map(int, input().split())) visited = [-1] * n visited[0] = 0 i = 0 ptr = 1 while True: ptr = arr[ptr-1] i += 1 k -= 1 if k == 0: break if visited[ptr-1] != -1: k %= i-visited[ptr-1] visited[ptr-1] = i if k == 0: break print(ptr) " p02684,s984813833,Accepted,"n, k = map(int, input().split()) tel = list(map(int, input().split())) log = [1] record = [0] * n while(True): log.append(tel[log[-1] - 1]) if(record[log[-1] - 1] == 1): break record[log[-1] - 1] += 1 for i in range(len(log) - 1): if(log[i] == log[-1]): star = i mod = len(log) - star - 1 break if(k < len(log)): print(log[k]) else: print(log[(k - star) % mod + star])" p02684,s471359599,Accepted,"N = [int(e) for e in input().split()] nums = [int(t) for t in input().split()] count=[] k = 0 check = [] t = nums[0] for i in range(N[0]): count.append(0) while count[t-1] == 0: check.append(t) count[t-1] += 1 k = t -1 t = nums[k] s = check.index(t) + 1 if(N[1] < s): print(check[N[1] - 1]) else: ans = (N[1] - s)%(len(check)+1-s) ans1 = check.index(t) + ans print(check[ans1])" p02684,s362500879,Accepted,"import sys sys.setrecursionlimit(10 ** 6) def dfs(v): path.append(v) visited[v] = 1 nv = A[v] if visited[nv] == 1: return nv return dfs(nv) N, K = map(int, input().split()) A = list(map(lambda x: int(x) - 1, input().split())) visited = [0] * N path = [] cycle_start = dfs(0) cycle_len = len(path) - path.index(cycle_start) head_len = len(path) - cycle_len if K <= head_len: print(path[K] + 1) else: K -= head_len print(path[head_len + K % cycle_len] + 1) " p02684,s858204171,Accepted,"n,k = (int(x) for x in input().split()) a = tuple([int(x) for x in input().split()]) c = [0] + [-1]*(n) l = [1] now = 1 dupl = -1 for i in range(k): now = a[now - 1] c[now - 1] += 1 if c[now - 1] == 1: dupl = now break else: l.append(now) if dupl == -1: print(now) exit() notloop = l.index(dupl) length = len(l)-notloop print(l[(k-notloop)%length+notloop])" p02684,s991662936,Accepted,"from copy import copy n, k = map(int, input().split()) a = [int(i) - 1 for i in input().split()] ans = 0 while k: if k & 1: ans = a[ans] c = [a[a[i]] for i in range(n)] a = copy(c) k >>= 1 print(ans + 1)" p02684,s926222862,Accepted,"n, k = map(int, input().split()) A = list(map(int, input().split())) A = [a-1 for a in A] L = 65 D = [[0]*n for _ in range(L+1)] for i, a in enumerate(A): D[0][i] = a for i in range(L): for j in range(n): D[i+1][j] = D[i][D[i][j]] ans = 0 for i in range(L): if k & (1 << i): ans = D[i][ans] print(ans+1) " p02684,s616248355,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) s = [-1] * N i = 0 cur = 0 m = 0 while True: if s[cur] != -1 and m != 1: m = i - s[cur] K = i + (K - i) % m else: s[cur] = i if i == K: print(cur+1) exit() i += 1 cur = A[cur] - 1 " p02684,s834060943,Accepted,"# input N, K = map(int, input().split()) A = [0] A.extend(list(map(int, input().split()))) # process l = [0]*(N+1) now = 1 i = 1 while l[now] == 0: l[now] = i now = A[now] i += 1 ans = 0 if K < l[now]: ans = l.index(K+1) else: k = (K-l[now]+1)%(len([x for x in l if x!=0])-l[now]+1) ans = l.index(l[now]+k) # output print(ans) " p02684,s142545515,Accepted,"N, K = map(int, input().split()) A = [0] + list(map(int, input().split())) visited = dict() a = 1 ct = 0 while a not in visited: visited[a] = ct a = A[a] ct += 1 if ct == K: print(a) exit() inv_v = {v: k for k, v in visited.items()} print(inv_v[(K - visited[a]) % (len(visited) - visited[a]) + visited[a]]) " p02684,s447510146,Accepted,"N,K =map(int,input().split()) A=list(map(int,input().split())) n=[1] t=1 ord=[-1]*(N+1) ord[0]=0 while True: t=A[t-1] if ord[t] != -1: f=n.index(t) break n.append(t) ord[t]=0 k=len(n)-f if K>=f: print(n[f+(K-f)%k]) else: print(n[K]) " p02684,s498126016,Accepted,"n,k = map(int,input().split()) a = list(map(int,input().split())) machi = 1 toutatu = [] pypyosoi = set() while not machi in pypyosoi: toutatu.append(machi) pypyosoi.add(machi) machi = a[machi-1] saigo = machi num = toutatu.index(saigo) unchi = toutatu[num:] cnt = len(unchi) if num > k: print(toutatu[k]) else: print(unchi[(k-num)%cnt]) #pypyが遅いのは自分のコードが悪いだけごめんねpypyちゃん" p02684,s181791846,Accepted,"n,k=map(int,input().split()) a=list(map(int,input().split())) l=[1] di={} di[1]=1 for i in a: b=a[l[-1]-1] if b in di: x=b break l.append(b) di[b]=1 t1=0 for j in l: if j==x: break else: t1+=1 t2=len(l)-t1 if k<=t1: print(l[k]) else: aa=(k-t1)%t2 print(l[t1+aa]) " p02684,s376775542,Accepted,"n,k = map(int,input().split()) a = list(map(int,input().split())) for i in range(n): a[i] -= 1 path = [0] now = 0 visited = {0} p = 0 while True: if a[now] in visited: p = a[now] break now = a[now] visited.add(now) path += [now] p_index = 0 for i in range(len(path)): if path[i] == p: p_index = i break if k <= p_index: print(path[k] + 1) else: print(path[p_index + (k-p_index)%len(path[p_index:])] + 1) " p02684,s528118893,Accepted,"#!/usr/bin/env python3 import sys input = sys.stdin.readline n, k = map(int, input().split()) a = [int(item) - 1 for item in input().split()] visited = [0] * n v = 0 visited[0] = 1 pre = [0] loop = [] start = False while True: v = a[v] if visited[v] == 1: start = True if visited[v] == 2: break if not start: pre.append(v) else: loop.append(v) visited[v] += 1 if k < len(pre): print(pre[k] + 1) exit() k -= len(pre) print(loop[k % len(loop)] + 1)" p02684,s362382757,Accepted,"N,K = map(int,input().split()) A = list(map(int,input().split())) L = [1] s = set() s.add(1) now = 1 for _ in range(N): if A[now - 1] in s: K -= L.index(A[now - 1]) if K >= 0: K %= len(L) - L.index(A[now - 1]) break L.append(A[now - 1]) s.add(A[now - 1]) now = A[now - 1] #print(L) #print(K) print(L[K + L.index(A[now - 1])]) " p02684,s817999739,Accepted,"n, k = list(map(int, input().split())) a = list(map(int, input().split())) s = 1 g = 0 i = 1 history = [s] flag = [False] * n flag[0] = True while True: g = a[s-1] if flag[g-1] == True: break else: flag[g-1] = True history.append(g) s = g i += 1 x = history.index(g) if k < i: ans = history[k] else: d = (k-x) % (i - x) ans = history[x + d] print(ans) " p02684,s597161560,Accepted,"# -*- coding: utf-8 -*- N, K = map(int, input().split()) A = list(map(int, input().split())) A.insert(0, None) history = [None] * (N+1) next_town = 1 i = 0 skip_flg = False while i < K: if history[next_town] == None: history[next_town] = i elif skip_flg == False: skip_flg = True i = i + ((K - i)//(i - history[next_town])) * (i - history[next_town]) if i < K: i += 1 next_town = A[next_town] print(next_town)" p02684,s495877114,Accepted,"n,k=map(int,input().split()) a=tuple(map(int,input().split())) flag=[-1]*n flag[0]=0 x,count=1,0 for i in range(1,n+1): x=a[x-1] if flag[x-1]<0: flag[x-1]=i else: l=i-flag[x-1] count=flag[x-1] break if count>=k: x=1 for _ in range(k): x=a[x-1] print(x) exit() k=(k-count)%l for _ in range(k): x=a[x-1] print(x)" p02684,s226464080,Accepted,"def getans(v,K): k=0 now=v while K>0: if K&1: now=doubling[k][now] K=K>>1 k+=1 return now N,K=map(int,input().split()) A=list(map(int,input().split())) doubling=[[-1]*N for i in range(61)] for i in range(N): doubling[0][i]=A[i]-1 for k in range(1,61): for i in range(N): doubling[k][i]=doubling[k-1][doubling[k-1][i]] print(getans(0,K)+1)" p02684,s808244884,Accepted,"n, k = map(int, input().split()) A = list(map(int, input().split())) A = [x-1 for x in A] town = 0 cnt = 0 visited = [False] * n visited[0] = -1 start_cnt = 0 for i in range(n*2): town = A[town] if visited[town] != False: start_cnt = i + 1 loop = i - visited[town] break else: visited[town] = i town = 0 if k >= start_cnt: k = (k-start_cnt)%loop+start_cnt for i in range(k): town = A[town] print(town+1) " p02684,s145460327,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) flag = [False] * N counted = [1] nextT = A[0] flag[0] = True for x in range(N): if flag[nextT - 1] is False: counted.append(nextT) flag[nextT - 1] = True nextT = A[nextT - 1] else: break before_loop_len = counted.index(nextT) loop_len = x - before_loop_len + 1 if K <= before_loop_len: print(counted[K]) else: checkK_prep = K - before_loop_len checkK = checkK_prep % loop_len print(counted[before_loop_len + checkK]) " p02684,s170975072,Accepted,"def f(): n,k=map(int,input().split()) l=list(map(int,input().split())) now=1 for i in range(k.bit_length()): if k%2:now=l[now-1] l=tuple(l[l[i]-1]for i in range(n)) k//=2 print(now) if __name__ == ""__main__"": f()" p02684,s970069192,Accepted,"N , K = map(int,input().split()) B = {} C = {} D = {0} A = list(map(int,input().split())) place = 0 num = 0 C[0] = 0 while True: place = int(A[place]) - 1 num += 1 if place in D: Y = int(num) - int(C[place]) break elif num == K: break else: B[num] = place C[place] = num D.add(place) try: X = (K - num) % Y print(B[C[place] + X] + 1) except: print(place+1) " p02684,s864543158,Accepted,"N,K=map(int,input().split()) P=list(map(int,input().split())) A={k+1:P[k] for k in range(N)} U=list() S=set() x=1 k=0 while (x not in S) and (k<=K): U.append(x) S.add(x) x=A[x] k+=1 if k>K: print(U[-1]) else: d=U.index(x) V=U[d:] print(V[(K-d)%len(V)]) " p02684,s604674248,Accepted,"import sys import time N, K = map(int, input().split()) town_list = list(map(int, input().split())) queue = {} start = -1 count = 1 now_town = 1 for i in range(K): if town_list[now_town - 1] in queue: start = town_list[now_town - 1] break queue[town_list[now_town - 1]] = count now_town = town_list[now_town - 1] count += 1 if start == -1: print(now_town) sys.exit() roop = len(queue) - (queue[start] - 1) before_len = queue[start] print(list(queue.keys())[(K - before_len) % roop + before_len - 1]) " p02684,s553374017,Accepted,"n,k=map(int,input().split()) a=list(map(int,input().split())) check=[[] for i in range(n)] c=0 g=1 tmp=[] cy=[] non=[] while c= K: break if K <= len(set_d): print(d[K-1]) else: K -= (len(set_d)-len(check)) K = K % len(check) print(check[K-1]) " p02684,s664830226,Accepted,"n,k=map(int,input().split()) a=[int(i) for i in input().split()] w=[1] x=set([1]) for i in range(k): t=a[w[-1]-1] if t in x: break x.add(t) w.append(t) p=w.index(t) k-=p loop=len(w)-p print(w[p+k%loop])" p02684,s958069329,Accepted,"N, K = map(int, input().split()) A = list(map(lambda x: x - 1, map(int, input().split()))) current = 0 memo = { 0: 0 } for i in range(1, K + 1): current = A[current] if current in memo: # loop length length = i - memo[current] tmp = (K - memo[current]) % length for j in range(tmp): current = A[current] break else: memo[current] = i print(current + 1)" p02684,s325616112,Accepted,"n,k = map(int,input().split()) tel = [int(e)-1 for e in input().split()] pl = [0] for i in range(2*n+1000): nxt = tel[pl[-1]] pl.append(nxt) if k < n + 1: print(pl[k]+1) exit() loop_end = n loop_start = n-1 while pl[loop_start] != pl[loop_end]: loop_start -= 1 #pl[loop_start] == pl[loop_end] period = loop_end - loop_start k %= period while k < n: k += period print(pl[k]+1)" p02684,s444410829,Accepted,"N,K = map(int, input().split()) A = [int(a)-1 for a in input().split()] used = [-1]*N cnt = 0 town = 0 used[0] = 0 while True: town = A[town] cnt += 1 if used[town] >= 0: cnt = cnt-used[town] break used[town] = cnt if K > used[town]: K -= used[town] K %= cnt K += used[town] ans = used.index(K)+1 print(ans)" p02684,s663270287,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) B = [] i = 0 B.append(1) for n in range(N): B.append(A[i]) i = A[i]-1 if K>N: start = 0 num = 0 for j in range(len(B)): if B[len(B)-1] == B[j]: start = j break for j in range(1,len(B)-start): if B[start+j] == B[start]: num = j break print(B[((K-start)%num)+start]) else: print(B[K])" p02684,s254009305,Accepted,"import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines def main(): N,K = map(int, readline().split()) A = [int(i) - 1 for i in readline().split()] p = 0 while K: if K & 1: p = A[p] A = [A[a] for a in A] K >>= 1 print(p + 1) if __name__ == ""__main__"": main() " p02684,s650150608,Accepted,"N, K = map(int, input().split()) A = input().split() root = [1] pastTown = {1:0} t = 0 nextTown = 1 while 1: t += 1 nextTown = int(A[nextTown - 1]) if nextTown in pastTown.keys(): break else: root.append(nextTown) pastTown[nextTown] = t if nextTown == root[0]: town = root[K % len(root)] else: if K <= pastTown[nextTown]: town = root[K] else: tmp = (K - pastTown[nextTown]) % (len(root) - pastTown[nextTown]) town = root[pastTown[nextTown] + tmp] print(town) " p02684,s355572090,Accepted,"N,K = map(int,input().split()) A = list(map(int,input().split())) town = 1 record = [1] record2 = [0]*N for i in range(N): town = A[town-1] if record2[town-1]==1: break record.append(town) record2[town-1] += 1 newrecord = record[record.index(town):] roop = len(newrecord) newK = K-(len(record)-roop) if newK>=0: answer = newrecord[newK%roop] else: answer = record[K] print(answer)" p02684,s359431969,Accepted,"from collections import deque n,k=map(int, input().split()) A = deque(map(int, input().split())) li = [] li2 = [0]*n li.append(1) next = 0 t=0 rep = False for i in range(k): if i == k: print(next+1) exit() if li2[next] == 1: t = li.index(next+1) rep = True li.pop() break li.append(A[next]) li2[next] = 1 next = A[next]-1 tmp = (k-t)%len(li[t:]) print(li[tmp+t])" p02684,s661014862,Accepted,"N, K = list(map(int, input().split())) A = list(map(lambda x: int(x) - 1, input().split())) v = [A[:]] now = 0 for i in range(60): tmp = v[-1] v.append([tmp[x] for x in tmp]) if K>>i & 1: now = v[i][now] print(now + 1)" p02684,s794988035,Accepted,"import sys input = sys.stdin.readline n,k = map(int,input().split()) a = list(map(int,input().split())) p = [1] for i in range(n): p.append(a[p[i]-1]) if k <= n: print(p[k]) else: # 周期の来る前の回数 num = p.index(p[-1]) p = p[num:] # 周期 pn = len(p)-1 k -= num # 回数/周期のあまり ans = k%pn print(p[ans])" p02684,s150992888,Accepted,"N, M = map(int, input().split()) P = [i -1 for i in map(int,input().split())] ss = set([]) point = 0 for i in range(N): if point in ss: break ss.add(point) point = P[point] S = [0] points = 0 for i in range(len(ss)-1): points = P[points] S.append(points) loop = S[S.index(point):] ll = len(S) l = len(loop) if ll > M: print(S[M]+1) elif ll == M: print(point+1) else: print(loop[(M-ll)%l]+1) " p02684,s870741529,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) s = 1 place = [s] first = set(place) for i in range(1, k+1): s = a[s-1] if s in first: loops = place.index(s) loope = len(place) ans = loops + (k-loope) % (loope-loops) print(place[ans]) exit() else: place.append(s) first.add(s) print(s)" p02684,s536887018,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) b = 0 r = k + 1 seen = [-1] * n seen[0] = 0 p = 1 for i in range(k): p = a[p - 1] if seen[p - 1] != -1: b = seen[p - 1] r = i + 1 - b for j in range((k - b) % r): p = a[p - 1] print(p) exit() seen[p - 1] = i + 1 else: print(p) " p02684,s251347718,Accepted,"N,K = map(int,input().split()) A = list(map(int,input().split())) town = [[] for _ in range(N)] visited = [0] flag = [-1] * N for i in range(N): town[i] = [i,A[i] - 1] f = 0 while flag[f] == -1: t = town[f][1] flag[f] = t f = town[t][0] visited.append(t) l = visited[-1] lv = len(visited) if K <= lv: print(visited[K] + 1) else: cs = visited.index(l) cycle = visited[cs:-1] lc = len(cycle) print(cycle[(K - lv + 1) % lc] + 1) ##i" p02684,s481726516,Accepted,"def main(): N, K = map(int, input().split()) D = K.bit_length() to = [[0] * D for _ in range(N)] for i, a in enumerate(map(int, input().split())): to[i][0] = a - 1 for j in range(D - 1): for i in range(N): to[i][j+1] = to[to[i][j]][j] v = 0 for i in reversed(range(D)): if (K >> i) & 1: v = to[v][i] print(v + 1) if __name__ == ""__main__"": main()" p02684,s051874786,Accepted,"n, k = map(int,input().split()) a = list(map(int,input().split())) s = [False] * n c = [1] now = 0 while not s[now]: s[now] = True now = a[now] - 1 c.append(now+1) start_cycle = c.index(c[-1]) loop = c[start_cycle:-1] cycle = len(loop) if k < start_cycle: print(c[k]) else: k -= start_cycle k %= cycle print(loop[k])" p02684,s580629623,Accepted,"import collections import numpy as np import sys import copy N,K=map(int,input().split()) A=list(map(int,input().split())) for i in range(N): A[i]-=1 B=[0] visited=[0]*N visited[0]=1 Flag=True for i in range(0,N*2): next=A[B[i]] if visited[next]==0: B.append(next) visited[next]=1 else: C=B[B.index(next):] num=B.index(next) break #print(C) if K>num: Ans=(K-num)%len(C) print(C[Ans]+1) else: print(B[K]+1)" p02684,s057093893,Accepted,"N, K = map(int, input().split()) A = tuple(map(int, input().split())) if K <= 200000: i = 1 for _ in range(K): i = A[i-1] print(i) exit() visited = {1} order = [1] i = 1 for count in range(1, 200001): i = A[i-1] if i in visited: break else: visited.add(i) order.append(i) idx = order.index(i) order2 = order[idx:] # print(order2) mod = (K+1-idx) % len(order2) print(order2[mod-1])" p02684,s028447174,Accepted,"n,k = map(int,input().split()) A = list(map(int,input().split())) sub = [0]*n city = 0 all = [] roop = [] while sub[city] != 2: if sub[city] == 0: all.append(city+1) else: roop.append(city+1) sub[city] += 1 city = A[city] -1 if len(all) > k: print(all[k]) else: print(roop[(k-(len(all)-len(roop)))%len(roop)])" p02684,s069952036,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) visited = [-1 for _ in range(N)] visited[0] = 0 k = 0 k = A[k] - 1 count = 0 while visited[k] == -1: count += 1 visited[k] = count k = A[k]-1 roop = count - visited[k] + 1 beforeroop = visited[k] if K < beforeroop: k = 0 for _ in range(K): k = A[k] - 1 print(k+1) else: K = K - beforeroop K = K % roop for _ in range(K): k = A[k]-1 print(k+1)" p02684,s512217188,Accepted,"N, K = map(int, input().split()) As = list(map(lambda x: int(x)-1, input().split())) cnt = 1 v = 0 checked = [-1]*N checked[0] = 0 while True: v = As[v] if checked[v]!=-1: loop = cnt-checked[v] road = checked[v] break cnt += 1 checked[v] = cnt-1 ite = K if K<=road else road+((K-road)%loop) v = 0 for i in range(ite): v = As[v] print(v+1)" p02684,s656015844,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) #どこに行くかのリスト now = 0 #どこにいるか LOG = {} roop = 0 count = 0 while now not in LOG and count < K: LOG.setdefault(now, count) now = A[now] - 1 count += 1 if count < K: roop = len(LOG) - LOG[now] K = (K - count) % roop count = 0 while count < K: now = A[now] - 1 count += 1 print(now+1) #行った場所を保存" p02684,s380804858,Accepted," import math def input_num(): ls = input().strip().split("" "") return [int(e) for e in ls] n,k = input_num() a_ls = input_num() d = {} now = 1 result_ls = [now] cnt = 0 while True: d[now] = cnt now = a_ls[now-1] if now in d: bun = d[now] break result_ls.append(now) cnt += 1 if k < bun: print(result_ls[k]) else: jun = len(result_ls) - bun idx = bun + (k-bun)%jun print(result_ls[idx]) " p02684,s708416034,Accepted,"n, k = map(int, input().split()) arr = [0] + list(map(int, input().split())) pos = 1 if k <= n: for _ in range(k): pos = arr[pos] print(pos) exit() res = [] visited = dict() for i in range(n + 1): if pos in visited: start = visited[pos] length = i - visited[pos] print(res[start + (k - start) % length]) exit() res.append(pos) visited[pos] = i pos = arr[pos]" p02684,s459343691,Accepted,"n,k=map(int,input().split()) A=list(map(int,input().split())) B=[] B.append(1) C=[0]*n C[0]+=1 start=0 finish=0 for i in range(1,n): if C[A[B[i-1]-1]-1]!=1: B.append(A[B[i-1]-1]) C[A[B[i-1]-1]-1]+=1 else: start=B.index(A[B[i-1]-1]) finish=i break roop=finish-start line=sum(C)-roop if line+(roop-1)>=k: print(B[k]) else: print(B[(k-line)%roop+line])" p02684,s538648004,Accepted,"n,k=map(int,input().split()) a=list(map(int,input().split())) chk=[False]*n x=0 visit=[0] chk[x]=True while chk: x=a[x]-1 if chk[x]: break else: visit.append(x) chk[x]=True l1=0 while visit[l1]!=x: l1+=1 l2=len(visit)-l1 if k>=l1: print(visit[l1+((k-l1)%l2)]+1) else: print(visit[k]+1)" p02684,s052577835,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) tele = [0] cnt = [1] + [0] * (N-1) while True: nt = A[tele[-1]] -1 if cnt[nt] == 1: rest = tele.index(nt) roop = len(tele) - rest break tele.append(nt) cnt[nt] += 1 if K < len(tele): print(tele[K]+1) else: K -= rest K %= roop print(tele[rest+K]+1) " p02684,s308531865,Accepted,"import sys sys.setrecursionlimit(10 ** 9) n,k = map(int,input().split()) a = list(map(int,input().split())) r = [] u = [False for _ in range(n)] def dfs(x): if u[x]: return x else: u[x] = True r.append(x) return dfs(a[x]-1) b = dfs(0) for i in range(len(r)): if b == r[i]: break #print(b,i,r) if k >= i: print(r[i+(k-i)%(len(r)-i)]+1) else: print(r[k]+1)" p02684,s097752084,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) visit = [] step = [-1] * (n + 1) v = 1 while step[v] == -1: step[v] = len(visit) visit.append(v) v = a[v - 1] cycle = len(visit) - step[v] nonCycle = step[v] if k < nonCycle: print(visit[k]) else: k -= nonCycle k %= cycle print(visit[nonCycle + k])" p02684,s847094551,Accepted,"n,k=map(int,input().split()) a=list(map(int,input().split())) for i in range(n): a[i]-=1 doubling=[[0 for i in range(n)] for j in range(60)] for i in range(n): doubling[0][i]=a[i] for i in range(59): for j in range(n): doubling[i+1][j]=doubling[i][doubling[i][j]] v=0 for d in range(60): if(k>>d &1): v=doubling[d][v] print(v+1)" p02684,s538229291,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) t = [[] for _ in range(n)] u = 0 for i in range(k + 1): t[u].append(i) if len(t[a[u] - 1]) == 2: break else: u = a[u] - 1 ans = 0 for i in range(n): if len(t[i]) == 2 and (k - t[i][1]) % (t[i][1] - t[i][0]) == 0: ans = i + 1 break elif len(t[i]) == 1 and t[i][0] == k: ans = i + 1 break print(ans)" p02684,s553721417,Accepted,"n,k = map(int,input().split()) A = list(map(int,input().split())) ex = [0]*n now = 1 for i in range(k) : if i == k-1 : now = A[now-1] print(now) exit() elif ex[now-1] == 0 : ex[now-1] = i+1 now = A[now-1] else : J = (k-i)%(i-ex[now-1]+1) for j in range(J) : now = A[now-1] print(now) exit()" p02684,s930530946,Accepted,"n,k=map(int,input().split()) b=list(map(int,input().split())) a=0 for i in range(n):b[i]-=1 if k0): K-=1 to=A[now] if latest[A[now]]!=-1: K%=latest[now]-latest[A[now]]+1 latest[A[now]]=latest[now]+1 now=to print(now+1) if __name__==""__main__"": main() " p02684,s594862531,Accepted,"N,K = map(int,input().split()) A_list = list(map(int,input().split())) # roopがあるときはその範囲 roop = N first = 0 now = 1 already = [1] for i in range(N): go_town = A_list[now-1] already.append(go_town) now = go_town set_A = set(already) for i in range(len(set_A)+1): try: set_A.remove(already[i]) except KeyError: first = already.index(already[i]) roop = already[first:i] break if K < first: print(already[K]) else: real_K = (K - first) % len(roop) print(roop[real_K])" p02684,s532013853,Accepted,"def main(): import sys sys.setrecursionlimit(10 ** 7) N, K = map(int, input().split()) *A, = (int(x) - 1 for x in input().split()) rs = [-1] * N def dfs(cur=0, rest=K): if ~rs[cur]: loop_range = rs[cur] - rest rest %= loop_range if rest == 0: return cur + 1 # -> 1-ind rs[cur] = rest return dfs(A[cur], rest - 1) print(dfs()) if __name__ == '__main__': main() " p02684,s777576359,Accepted,"import sys input = sys.stdin.readline N, K = map(int, input().split()) A = list(map(lambda x: int(x)-1, input().split())) cities = [0] c = 0 used = [False] * N used[0] = True while not used[A[c]]: used[A[c]] = True cities.append(A[c]) c = A[c] x = cities.index(A[c]) if K < x: print(cities[K] + 1) else: K -= x K %= len(cities) - x print(cities[x + K] + 1)" p02684,s980291069,Accepted,"n, k =[int(i) for i in input().split()] a = [int(i) - 1 for i in input().split()] go = dict() res = [] go[0] = True res = [0] now = a[0] while True: if now in go: break res.append(now) go[now] = True now = a[now] # 1 # [0, 1, 2, 3] # (5 - 1) % (xunhuan) amari = res.index(now) xunhuan = res[amari:] #print(res, xunhuan, amari) if k <= amari: print(res[k] + 1) else: print(xunhuan[ (k - amari) % len(xunhuan)] + 1)" p02684,s610260737,Accepted,"n,k = map(int, input().split()) a = list(map(int, input().split())) row = [] been = [0]*n now = 0 nex = 0 t = 0 l = [-1]*n prev = 0 while been[now] == 0: l[now] = t row.append(now) been[now] = 1 now = a[now]-1 t += 1 if been[now] == 1: prev = l[now] # print(prev,t) print(row[prev + (k-prev)%(t-prev)]+1 if k > prev else row[k]+1) " p02684,s398666135,Accepted,"n, k = map(int, input().split()) a = [int(x) - 1 for x in input().split()] now = 0 b = [0] * n while k!= 0: if k & 1: now = a[now] k >>= 1 for i in range(n): b[i] = a[a[i]] a = b[:] print(now+1)" p02684,s937620063,Accepted,"import sys input = sys.stdin.readline n, k = map(int,input().split()) A = list(map(int,input().split())) for i in range(n): A[i] -= 1 B = [0] F = [-1] * n F[0] = 0 s = A[0] i = 0 while F[s] == -1: i += 1 B.append(s) F[s] = i s = A[s] # print(F[s], i+1) if k <= F[s]: print(B[k] + 1) else: ind = (k-F[s]) % (i+1-F[s]) + F[s] print(B[ind] + 1)" p02684,s471091043,Accepted,"N,K=map(int,input().split()) t=list(map(int,input().split())) g=[1] for i in range(N-1): g.append(t[g[i]-1]) if K>len(g): a=g.index(g[-1]) b=len(g)-a-1 K=(K-a)%b+a print(g[K])" p02684,s587338674,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) for i in range(n): a[i] -= 1 l = [-1]*n #list for order of teleportation l[0] = 0 ct = 0 #current town od = 1 #order of teleportation while True: k -= 1 ct = a[ct] if k == 0: break if l[ct] == -1: l[ct] = od od += 1 else: cycle = od - l[ct] k %= cycle od += 1 print(ct + 1)" p02684,s963575265,Accepted,"N, K = map(int, input().split()) As = [A-1 for A in map(int, input().split())] maxD = K.bit_length() - 1 dp = [[0]*(N) for _ in range(maxD+1)] for i in range(N): dp[0][i] = As[i] for d in range(1, maxD+1): for i in range(N): dp[d][i] = dp[d-1][dp[d-1][i]] iNow = 0 ### for d in range(maxD+1): if K & (1<len(g): a=g.index(g[-1]) b=len(g)-a-1 K=(K-a)%b+a print(g[K])" p02684,s682600883,Accepted,"N,K = map(int,input().split()) A = list(map(int,input().split())) ls = [0]*N count = 0 now = 0 roop = 0 while ls[now] == 0 and count < K: ls[now] = 1 now = A[now] - 1 count += 1 k = K - count if k > 0: while ls[now] == 1: ls[now] = 2 now = A[now] - 1 roop += 1 k = k%roop while k > 0: now = A[now]-1 k -= 1 print(now+1) " p02684,s576706382,Accepted,"N, K = map(int,input().split()) A = list(map(int,input().split())) X = [-1 for j in range(N)] X[0] = 0 Y = [0] i = 0 Num = 0 MM = 0 for k in range(1,N): i = A[i]-1 if k == K: MM = 1 P = i break elif X[i] != -1: Num = X[i] break else: X[i] = k Y.append(i) Y = Y[Num:] B = (K-Num)%len(Y) if MM == 1: print(P+1) else: print(Y[B]+1)" p02684,s415658098,Accepted,"n,k=map(int,input().split()) a=list(map(int,input().split())) count=0 lst={} lst2=[] now=1 c=0 while True: lst2.append(now) lst[now]=c now=a[now-1] if now in lst: break c+=1 amari=lst[now] looplen=c-lst[now]+1 if k<=amari: print(lst2[k]) else: newlst=lst2[amari:] newk=k-amari num=newk%looplen print(newlst[num])" p02684,s673959685,Accepted,"N, K = list(map(int, input().split())) A = list(map(int, input().split())) used = set() history = [] cur = 0 used.add(0) while True: history.append(cur) next_cur = A[cur] - 1 if next_cur in used: loop_start = history.index(next_cur) break used.add(next_cur) cur = next_cur B = history[loop_start:] if K <= loop_start: result = history[K] else: result = B[(K-loop_start) % len(B)] print(result+1) " p02684,s288665485,Accepted,"N, K = map(int,input().split()) tele = list(map(int, input().split())) now = 0 goal,loop,visit = [],[],[0]*N while visit[now]!=2: if visit[now]==0: goal.append(now) else: loop.append(now) visit[now] += 1 now = tele[now]-1 if len(goal)>K: print(goal[K]+1) else: res= len(goal)-len(loop) print(loop[(K-res)%len(loop)]+1)" p02684,s654525965,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) X = 0 town = 1 counted = [0 for _ in range(N)] List = [0 for _ in range(N)] for k in range(N): X += 1 counted[k] = town town = A[town-1] if List[town-1] == 1: ini = counted.index(town) Q = X - ini break else: List[town-1] = 1 if K >= ini: num = (K-ini) % Q print(counted[ini+num]) else: print(counted[K])" p02684,s122456180,Accepted,"n,k=map(int,input().split()) l=list(map(int,input().split())) kiseki=[-1]*n i=0 v=1 while kiseki[v-1]==-1: kiseki[v-1]=i v=l[v-1] i+=1 saisyo=kiseki[v-1] kuri=i-saisyo if saisyo>k: print(kiseki.index(k)+1) else: amari=(k-saisyo)%kuri print(kiseki.index(amari+saisyo)+1)" p02684,s579181203,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)])" p02684,s293519616,Accepted,"from collections import defaultdict N, K = [int(i) for i in input().split()] A = [int(i) for i in input().split()] d = defaultdict(lambda: -1) d[1] = 0 L = [1] i = 0 k = i while iK: print(move[K]+1) else: print(roop[(K-(len(move)-len(roop)))%len(roop)]+1) " p02684,s270938763,Accepted,"import sys INF = 1 << 60 MOD = 10**9 + 7 # 998244353 sys.setrecursionlimit(2147483647) input = lambda:sys.stdin.readline().rstrip() def resolve(): n, k = map(int, input().split()) b = list(map(lambda x : int(x) - 1, input().split())) now = 0 while k: if k & 1: now = b[now] b = [b[b[i]] for i in range(n)] k >>= 1 print(now + 1) resolve()" p02684,s076530863,Accepted,"N, K = list(map(int, input().split())) A = list(map(int, input().split())) l = [A[0]] s = {A[0]} a = A[0] - 1 for _ in range(K): if A[a] not in s: l.append(A[a]) s.add(A[a]) a = A[a] - 1 else: a = A[a] break n = len(l) b = 0 for i in range(n): if l[i] == a: del l[0:i] b = i break T = len(l) S = (K - b) % T ans = l[S - 1] print(ans) " p02684,s446873621,Accepted,"N, K = [int(_) for _ in input().split()] A = [int(_) for _ in input().split()] A = [0] + A n = 1 done = [0 for i in range(N+1)] if K > N: for i in range(N): n = A[n] if done[n] != 0: a = done[n] b = i + 1 - a break done[n] = i + 1 K = (K - a) % b + a n = 1 for i in range(K): n = A[n] print(n) " p02684,s506847337,Accepted,"n, k = map(int, input().split()) a = list(map(lambda x: int(x)-1, input().split())) num = 0 li = [0] flag = [True] * n flag[0] = False for i in range(k): num = a[num] if flag[num]: li.append(num) flag[num] = False else: break d = li.index(num) ans = (k-d)%(len(li)-d)+d print(li[ans]+1)" p02684,s362498306,Accepted,"N, K= [int(i) for i in input().split()] An = [int(i) for i in input().split()] i = 0 checked = [0 for _ in range(N)] c = 0 while checked[i] == 0: c += 1 checked[i] = c i = An[i] - 1 if checked[i] >= K: i = 0 for k in range(K): i = An[i] - 1 print(i + 1) else: period = c - checked[i] + 1 diff = K - checked[i] + 1 mod_diff = diff % period for k in range(mod_diff): i = An[i] - 1 print(i + 1) " p02684,s634032200,Accepted,"N, K = map(int, input().split()) A = [0] + list(map(int, input().split())) now = 1 while K > 0: if K&1: now = A[now] A = [A[i] for i in A] K = K >> 1 print(now) " p02684,s181665567,Accepted,"n,k = map(int,input().split()) # k = int(input()) a = 1 B = [b-1 for b in map(int,input().split())] d = [-1]*n d[a-1] = 0 now = a-1 while True: if d[B[now]] == -1: d[B[now]] = d[now] + 1 now = B[now] else: loop = d[now] - d[B[now]] + 1 start = d[B[now]] break print(d.index((k-start)%loop + start) + 1 if start < k else d.index(k) + 1) " p02684,s999632417,Accepted,"N,K=map(int,input().split()) A=list(map(lambda x:int(x)-1,input().split())) seen=[-1]*N i=0 cnt=0 iri=-1 while True: if(cnt==K): print(i+1) exit() if seen[i]!=-1: roop=cnt-seen[i] iri=i K-=seen[i] K=K%roop break seen[i]=cnt cnt+=1 i=A[i] now=iri for i in range(K): now=A[now] print(now+1)" p02684,s946315177,Accepted,"import sys sys.setrecursionlimit(10**6) n, k = map(int, input().split()) A = list(map(int, input().split())) L = [1] S = {1} def f(L, S): last = L[-1]-1 if A[last] not in S: L.append(A[last]) S |= {A[last]} return f(L, S) else: return L P = f(L, S) a = A[P[-1]-1] j = P.index(a) r = len(P) l = r - j if k+1 <= j: print(P[k]) else: print(P[j+(k-j)%l])" p02684,s724532416,Accepted,"# https://atcoder.jp/contests/abc167/tasks/abc167_d def resolve(): n, k = map(int, input().split()) a = [0] + list(map(int, input().split())) c = 1 while k: if k & 1: c = a[c] na = [0] * (n+1) for i in range(n+1): na[i] = a[a[i]] a = na k >>= 1 print(c) if __name__ == '__main__': resolve() " p02684,s101037540,Accepted,"n,k=map(int,input().split()) a=[0]+list(map(int,input().split())) # 1から rec=[-1]*(n+1) rec[1]=0 now=1 wp=0 flag=False while k>wp: rec[now]=wp nx=a[now] rest=k-wp loop=rec[now]-rec[nx]+1 if rest idx_s: d = k - idx_s idx = d%f ans = cities[idx + idx_s] print(ans) else: print(cities[k])" p02684,s252121491,Accepted,"n,k=map(int,input().split()) a=list(map(int,input().split())) b=[0]*(n+1) count=0 now=1 f=1 for _ in range(k): if b[now]: f=0 break count+=1 b[now]=count now=a[now-1] if f: print(now) exit() x=count-b[now]+1 y=(k-b[now]+1)%x for i in range(y): now=a[now-1] print(now)" p02684,s231802504,Accepted,"n, k = map(int, input().split()) A = list(map(int, input().split())) now = 1 for i in range(len(bin(k))-2): if (k>>i)&1: now = A[now-1] A = [A[a-1] for a in A] print(now)" p02684,s570038022,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) " p02684,s340394791,Accepted,"N,K=map(int,input().split()) T=str(bin(K)) S=len(T)-2 A = list(map(int,input().split())) lst=[[0 for e in range(N+1)] for f in range(S)] for i in range(1,N+1): lst[0][i]=A[i-1] for j in range(1,S): for i in range(1,N+1): lst[j][i]=lst[j-1][lst[j-1][i]] ans=1 for k in range(S): if int(T[k+2])==1: ans=lst[S-1-k][ans] print(ans)" p02684,s891149298,Accepted,"n,k = map(int, input().split()) a = list(map(int, input().split())) now = 1 used = [0]*n for i in range(1,2*n): now = a[now-1] if (used[now-1]==0): used[now-1]=i else: bef = used[now-1] loop = i-used[now-1] break if (bef>=k): print(used.index(k)+1) else: over = (k-bef)%loop #print(bef,over,loop,used) print(used.index(bef+over)+1) " p02684,s403731001,Accepted,"n, k = map(int, input().split()) a = [int(i) for i in input().split()] d = {0:1} b = {1:0} p = 0 for i in range(k): d[i + 1] = a[p] b[a[p]] = i + 1 p = a[p] - 1 if a[p] in b: k = (k - b[a[p]]) % (i + 2 - b[a[p]]) + b[a[p]] break print(d[k])" p02684,s700995899,Accepted,"N, K = list(map(int, input().split())) A = list(map(int, input().split())) check=[-1 for i in range(N)] temp=1 circle=[] for i in range(K): temp=A[temp-1] if check[temp-1]==-1: check[temp-1]=i else: circle.append(i-check[temp-1]) #print(circle) break #print(""temp"",temp) #print((K-i)%len(circle)-1) if len(circle)!=0: amari=(K-i)%circle[0] temp=1 for j in range(i+amari): temp=A[temp-1] print(temp)" p02684,s283858080,Accepted,"N,K = map(int,input().split()) A = [int(v)-1 for v in input().split()] p = 0 memo = {} for i in range(K): if p in memo: interval = i-memo[p] rest = (K-i-1)%interval for j in range(rest+1): p=A[p] print(p+1) exit() else: memo[p] = i p = A[p] print(p+1) " p02684,s182770977,Accepted," def solve(N,K,A): visited = [None]*N cur = 0 for i in range(K): if visited[cur] is None: visited[cur] = i cur = A[cur]-1 else: break else: print(cur+1) return K -= i K %= i-visited[cur] for i in range(K): cur = A[cur]-1 print(cur+1) N,K = map(int,input().split()) A = tuple(map(int,input().split())) solve(N,K,A)" p02684,s632721797,Accepted,"n,k=map(int,input().split()) a=list(map(lambda x:int(x)-1,input().split())) lst=[0] now=0 memo=0 town=[0]*n town[0]=1 b=0 for i in range(k): now=a[now] if town[now]==1: memo=now b=1 break lst.append(now) town[now]=1 if b==1: i=lst.index(memo) l=len(lst) if memo!=0: lst=lst[i:] l-=len(lst) print(lst[(k-l)%len(lst)]+1) else: print(lst[k%l]+1) else: print(now+1)" p02684,s993969122,Accepted,"n,k = [int(x) for x in input().split()] a = [int(x)-1 for x in input().split()] ans = 0 cnt = 0 x = [-1] * n y = -1 while cnt < k: if x[ans] == -1: x[ans] = cnt ans = a[ans] cnt += 1 else: y = x[ans] + (k-cnt) % (cnt-x[ans]) break if y == -1: print(ans+1) else: print(x.index(y) +1)" p02684,s719403302,Accepted,"N,K = (int(x) for x in input().split()) A = list(map(int, input().split())) newlist = [1,A[0]] num = A[0] - 1 ans = [0]*N ans[0] = 1 ans[A[0]-1] = 1 b = 0 c = 0 r = 0 for i in range(K): if(ans[A[num]-1] == 1): b = A[num] break newlist.append(A[num]) ans[A[num]-1] = 1 num = A[num]-1 for i in range (len(newlist)): if(newlist[i] == b): c = i r = len(newlist)-c a = (K-c)%r print(newlist[c+a])" p02684,s887012016,Accepted,"n, k = map(int, input().split()) A = list(map(lambda x: int(x)-1, input().split())) bit = k.bit_length() table = [[0]*bit for _ in range(n)] for i in range(n): table[i][0] = A[i] for i in range(1, bit): for j in range(n): table[j][i] = table[table[j][i-1]][i-1] ans = 0 for i in reversed(range(bit)): if (1 << i) <= k: k -= 1 << i ans = table[ans][i] print(ans+1) " p02684,s375255413,Accepted,"def main(): N, K = map(int, input().split()) A = list(map(lambda x: int(x)-1, input().split())) visited = [0] * N way = [] now = 0 while True: if visited[now] == 1: break if K == 0: return print(now+1) visited[now] = 1 way.append(now) destination = A[now] K -= 1 now = destination loop = way[way.index(now):len(way)] # print(loop) # print(K) print(loop[K%len(loop)]+1) if __name__ == '__main__': main() " p02684,s576801733,Accepted,"N,K = map(int,input().split("" "")) A = list(map(int,input().split("" ""))) A.insert(0,0) rireki = [1] counter = 1 now = 1 flag = [0 for _ in range(N + 1)] flag[1] = 1 while(flag[A[now]] == 0): counter += 1 rireki.append(A[now]) flag[A[now]] = counter now = A[now] if K < flag[A[now]]: print(rireki[K]) else: K += counter - (flag[A[now]] - 1) K -= flag[A[now]] - 1 K %= counter - (flag[A[now]] - 1) print(rireki[flag[A[now]]- 1 + K]) " p02684,s320410162,Accepted,"n,k = map(int,input().split()) a = list(map(int,input().split())) t = 1 tl = [1] ts = {1} for i in range(len(a)): t = a[t-1] if t in ts: break else: tl.append(t) ts.add(t) tl2 = tl[tl.index(t):len(tl)] if k < len(tl): ans = tl[k] else: k = k - (len(tl) - len(tl2)) j = k % len(tl2) ans = tl2[j] print(ans)" p02684,s597342401,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) rireki = [-1 for i in range(N)] rireki[0] = 0 ima = 0 kuri = 0 start = 0 end = 0 for i in range(K): saki = A[ima] if rireki[saki - 1] == -1: rireki[saki - 1] = i + 1 ima = saki - 1 else: ima = saki - 1 kuri = 1 start = rireki[saki - 1] end = i + 1 break if kuri == 1: KK = (K - start) % (end - start) for i in range(KK): saki = A[ima] ima = saki - 1 print(ima+1)" p02684,s536086434,Accepted,"n, k = map(int, input().split()) a = [int(i) - 1 for i in input().split()] visit = {0} tmp = 0 a_list = [0] ans = True for i in range(k): tmp = a[tmp] if tmp in visit: left = a_list.index(tmp) ans = False print(a_list[left + (k - left) % (i + 1 - left)] + 1) break else: visit.add(tmp) a_list.append(tmp) if ans: print(tmp + 1)" p02684,s395733681,Accepted,"N,K=map(int,input().split()) t=list(map(int,input().split())) g=[1] h={1} for i in range(N-1): x=t[g[i]-1] g.append(x) if x in h: break h.add(x) if K>len(g): a=g.index(g[-1]) b=len(g)-a-1 K=(K-a)%b+a print(g[K])" p02684,s305671479,Accepted,"def resolve(): n, k = map(int, input().split()) a = list(map(int, input().split())) rec = [True]*(n+2) now = 0 stp = [1] while rec[now]: rec[now] = False now = a[now] - 1 stp.append(now+1) before_loop = stp.index(now+1) loop = stp[before_loop:-1] if k <= (before_loop): print(stp[k]) else: r = (k - before_loop) % len(loop) print(loop[r]) resolve()" p02684,s269920248,Accepted,"n, k = map(int, input().split()) A = list(map(int, input().split())) D = [0] * (n+1) now = 1 for i in range(1, k+1): tmp = A[now-1] if not D[tmp]: now = tmp D[now] += i else: pre = D[tmp] loop = i - D[tmp] if loop>1: now=D.index((k - pre) % loop + pre) else: now=tmp break print(now)" p02684,s764402236,Accepted,"N, K = map(int, input().split()) As = list(map(int, input().split())) As = [A-1 for A in As] Vs = [False]*N p = 0 Rs = [p] Vs[p] = True for i in range(N+3): n = As[p] Rs.append(n) if Vs[n]: break p = n Vs[p] = True p0 = Rs.index(Rs[-1]) #print(Rs, p0) if K <= p0: r = Rs[K] else: r = Rs[p0+(K-p0)%(len(Rs)-p0-1)] print(r+1) " p02684,s913304403,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) visited_set = set([1]) visited_list = [1] i = 0 loop_pos = 0 for _ in range(len(A)): if A[i] in visited_set: while A[i] != visited_list[loop_pos]: loop_pos += 1 break visited_set.add(A[i]) visited_list.append(A[i]) i = A[i] - 1 if K < loop_pos: print(visited_list[K]) else: loop_len = len(visited_list) - loop_pos K -= loop_pos pos = loop_pos + (K % loop_len) print(visited_list[pos]) " p02684,s330382163,Accepted,"N, K = map(int, input().split()) A = [0] + list(map(int, input().split())) B = [-1 for i in range(N+1)] B[1] = 0 n = 1 m = 0 while 1: n = A[n] m += 1 if m == K: print(n) break if B[n] == -1: B[n] = m else: a = (K - m) % (m - B[n]) for i in range(a): n = A[n] print(n) break" p02684,s000912812,Accepted,"n, k = map(int, input().split()) lst = [int(i) for i in input().split()] tele_lst = [] town_set = set() town = 1 while True: if town not in town_set: tele_lst.append(town) town_set.add(town) else: break town = lst[town - 1] ind = tele_lst.index(town) length = len(town_set) circle = length - ind #print(ind, length) #print(tele_lst) if k < ind: town = tele_lst[k] print(town) else: k -= ind k %= circle #print(k) town = tele_lst[ind + k] print(town)" p02684,s367625150,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) g = [aa - 1 for aa in a] root = [] seen = set() cur = 0 while True: seen.add(cur) root.append(cur) cur = g[cur] if cur in seen: break for i in range(len(root)): if root[i] == cur: break p = i n_loop = len(root) - p if k <= p: print(root[k] + 1) else: idx = ((k - p) % n_loop + p) % len(root) print(root[idx] + 1) " p02684,s667698316,Accepted,"import sys readline = sys.stdin.readline N,K = map(int,readline().split()) A = [0] + list(map(int,readline().split())) now = 1 while K: if K & 1: now = A[now] nex = [0] * (N + 1) for i in range(N + 1): nex[i] = A[A[i]] A = nex K >>= 1 print(now)" p02684,s173759795,Accepted,"N,K=map(int,input().split()) A=[0]+list(map(int,input().split())) c=1 while K: if K&1: c=A[c] A=[A[A[i]] for i in range(len(A))] K>>=1 print(c)" p02684,s938818658,Accepted,"N, K = map(int, input().split()) A = [0] + list(map(int, input().split())) now = 1 visited = [] visited_set = set() flag = False for i in range(1, K+1): visited.append(now) visited_set.add(now) now = A[now] if now in visited_set: loop_start = visited.index(now) loop_length = i - loop_start flag = True break else: print(now) if flag: print(visited[loop_start + (K - loop_start) % loop_length]) " p02684,s005148804,Accepted,"n, k = map(int, input().split()) teleport_list = list(map(int, input().split())) t_cycle = [1] c_set = set([1]) now = 1 while len(t_cycle) == len(c_set): now = teleport_list[now-1] t_cycle.append(now) c_set.add(now) start_cycle = t_cycle[-1] before_cycle_len = t_cycle.index(start_cycle) cycle_len = len(t_cycle) - t_cycle.index(start_cycle) - 1 if k <= before_cycle_len: print(t_cycle[k]) else: print(t_cycle[(k-before_cycle_len)%cycle_len + before_cycle_len])" p02684,s796851151,Accepted,"import sys read = sys.stdin.read readline = sys.stdin.readline N, K, *A = map(int, read().split()) A = [i - 1 for i in A] check = [False] * N seq = [] here = 0 while True: if K == 0: print(here + 1) exit() if check[here]: break seq.append(here) check[here] = True here = A[here] K -= 1 seq = seq[seq.index(here):] circ = len(seq) K %= circ print(seq[K] + 1) " p02684,s605646596,Accepted,"n,k,*a=map(int,open(0).read().split()) now=1 if k<=n: for i in range(k): now=a[now-1] print(now) exit() # 絶対ループする visited=[False]*n visited[now-1]=-1 for i in range(4*10**5): now=a[now-1] if visited[now-1]==False: visited[now-1]=i else: c,d=visited[now-1],i break k=(k-c)%(d-c)+c while k=0: l,r=v[t],i+1; break v[t]=i+1; p=t print(v.index(min(k,l+(k-l)%(r-l)))+1)" p02684,s959752186,Accepted,"import sys N, K = map(int, input().split()) A = list(map(int, input().split())) B = [0]*len(A) i = 0 c = 0 while K > 0: if B[i] == 0: B[i] = c j = A[i] - 1 i = j K -= 1 c += 1 else: x = c - B[i] K = K % x B = [0]*len(A) print(j + 1)" p02684,s463077971,Accepted,"n, k = map(int, input().split()) A = list(map(int, input().split())) order = [-1] * (n+1) v = [0] * (n+1) v[0] = 1 order[v[0]] = 0 # iは順番 for i in range(1, n+1): v[i] = A[v[i-1] - 1] if order[v[i]] != -1: old_i = order[v[i]] c = i - old_i break order[v[i]] = i if k < old_i: print(v[k]) else: print(v[(k - old_i)%c + old_i])" p02684,s165102075,Accepted,"def f(): n,k=map(int,input().split()) l=list(map(int,input().split())) now=1 for i in range(k.bit_length()): if k%2:now=l[now-1] l=[l[l[i]-1]for i in range(n)] k//=2 print(now) if __name__ == ""__main__"": f()" p02684,s802802052,Accepted,"n, k = map(int, input().split()) *A, = map(int, input().split()) A = [0] + A bit = list(bin(k)[2:][::-1]) m = len(bit) DP = [[None for j in range(m)] for i in range(n + 1)] for i in range(n + 1): DP[i][0] = A[i] for j in range(1, m): for i in range(n + 1): DP[i][j] = DP[DP[i][j - 1]][j - 1] i = 1 for j, b in enumerate(bit): if b == '1': i = DP[i][j] print(i) " p02684,s445201032,Accepted,"n,k=map(int,input().split()) l=list(map(int,input().split())) s=1 q=[0]*n q[0]=1 r=[1] for i in range(k): s=l[s-1] if q[s-1]==0: q[s-1]+=1 r.append(s) if i==k-1: print(s) else: x=r.index(s) mod=len(r)-x t=(k-i-1)%mod print(r[x+t]) break" p02684,s371491599,Accepted,"n, k = map(int, input().split()) A = list(map(int, input().split())) Town = [] #まだ訪れていない町は-1 rec = [-1] * (n+1) idx = 1 #周期までループをまわす while (rec[idx] == -1): rec[idx] = len(Town) Town.append(idx) idx = A[idx-1] #周期前 Exce = rec[idx] #周期内 Cycl = len(Town) - Exce if Exce > k: print(Town[k]) else: Warp = (k - Exce) % Cycl print(Town[Exce+Warp])" p02684,s359484745,Accepted,"def f(): n,k=map(int,input().split()) l=list(map(int,input().split())) now=1 for d in range(k.bit_length()): if k%2:now=l[now-1] l=tuple(l[i-1]for i in l) k//=2 print(now) if __name__ == ""__main__"": f() " p02684,s026209990,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) b = [0 for _ in range(n)] p = 1 i = 0 while True: p = a[p - 1] if b[p - 1] > 0 or p == 1: break else: i += 1 b[p - 1] = i bp = b[p - 1] if k <= bp: print(b.index(k) + 1) else: l = bp + (k - bp) % (i + 1 - bp) print(b.index(l) + 1) " p02684,s084844759,Accepted,"n,k=map(int,input().split()) a=list(map(int,input().split())) c=2 t=0 path=[] s=set() cycle=[] while(c<=k): if a[t] in s: #print(path.index(a[t]),a[t]) cycle=path[path.index(a[t]):] k-=c-1 break path.append(a[t]) s.add(a[t]) t=a[t]-1 c+=1 if cycle==[]: print(a[t]) else: print(cycle[k%len(cycle)]) " p02684,s198152862,Accepted,"n, k = map(int,input().split()) lis = list(map(int,input().split())) gtyo = [0] *n gtyo[0] = 1 gone = 0 t = 1 while t < n: gone = lis[gone] -1 t += 1 if gtyo[gone]: loop = t -gtyo[gone] t = n else: gtyo[gone] = t if k -(gtyo[gone]-1)>= 0: res = (k- (gtyo[gone]-1)) % loop else: res = k- (gtyo[gone]-1) tmp = [i - gtyo[gone] for i in gtyo] print(tmp.index(res)+1)" p02684,s394310700,Accepted,"N, K = map(int, input().split()) *A, = map(int, input().split()) A = [a-1 for a in A] # Douling(ダブリング) i = 1 to = [[a for a in A]] while pow(2, i) < K: t = [to[i-1][to[i-1][j]] for j in range(N)] to.append(t) i += 1 i -= 1 ans = [i for i in range(N)] while i >= 0: if K & (1 << i) > 0: for j in range(N): ans[j] = to[i][ans[j]] i -= 1 print(ans[0]+1)" p02684,s703803052,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) l = [0] s = set() s.add(0) cur = a[0] - 1 while True: if cur in s: break else: s.add(cur) l.append(cur) cur = a[cur] - 1 i = l.index(cur) if k <= i: print(l[k] + 1) else: print(l[(k - i) % (len(l) - i) + i] + 1)" p02684,s141780643,Accepted,"n, k = map(int, input().split()) a = list(map(lambda x: int(x) - 1, input().split())) visited = [-1 for _ in range(n)] visited[0] = 0 l = [0] for i in range(k): nex = a[l[i]] if visited[nex] != -1: res = visited[nex] cyc = i + 1 - visited[nex] break else: l += [nex] visited[nex] = i + 1 else: res = k + 1 print(l[res + (k - res) % cyc] + 1 if k > res else l[k] + 1) " p02684,s194057841,Accepted,"N, K = map(int, input().split()) A = tuple( map(int, input().split()) ) L = [0 for i in range(N+1)] L[1] = 1 x = 1 t = 1 while K>0: t += 1 K -= 1 x = A[x-1] if L[x] != 0: p = t - L[x] K %= p break else: L[x] = t while K>0: x = A[x-1] K -= 1 print(x) " p02684,s656313904,Accepted,"n, k = [int(i) for i in input().split()] l = [int(i) - 1 for i in input().split()] i = 0 m = [-1] * n p = 0 while m[i] == -1: if p == k: break m[i] = p p += 1 i = l[i] else: z = (k - m[i]) % (p - m[i]) i = m.index(m[i] + z) print(i + 1)" p02684,s425802443,Accepted,"N, K = map(int, input().split()) A = list(map(lambda x: int(x) - 1, input().split())) stack = [0] visited = {0} now = 0 while A[now] not in visited: now = A[now] stack.append(now) visited.add(now) roop_start = A[now] roop = [] while stack[-1] != roop_start: roop.append(stack.pop()) roop.append(roop_start) roop = roop[::-1] roop_size = len(roop) now = 0 while now != roop_start and K: now = A[now] K -= 1 if K == 0: print(now + 1) else: print(roop[K % roop_size] + 1) " p02684,s967307512,Accepted,"n,k = map(int, input().split()) a = list(map(int, input().split())) G = {} for i in range(1, n + 1): G.update({i: a[i - 1]}) seen = [False] * (n + 1) path = [1] i = 1 while True: seen[i] = True i = G[i] if seen[i]: break else: path.append(i) m = path.index(i) if m > k: print(path[k]) else: k -= m path = path[m:] k %= len(path) print(path[k]) " p02684,s974924537,Accepted,"N,K = map(int,input().split()) *A, = map(int,input().split()) M = len(bin(K))-2 B = [[0]*N for _ in [0]*M] B[0] = [a-1 for a in A] for i in range(1,M): for j in range(N): B[i][j] = B[i-1][B[i-1][j]] k = K a = 0 while k>0: if k%2==1: a = B[0][a] k -= 1 continue j = 1 while k%(2**(j+1))==0: j += 1 a = B[j][a] k -= 2**j print(a+1)" p02684,s001308622,Accepted,"N, K = map(int,input().split()) A = [0] + list(map(int,input().split())) T = {1:1} current_town = 1 for i in range(2,K+1): current_town = A[current_town] K -= 1 if current_town in T: loop_towns = list(T.keys())[T[current_town]-1:] print(loop_towns[K%len(loop_towns)]) break else: T[current_town] = i else: print(A[current_town])" p02684,s810500246,Accepted,"import sys sys.setrecursionlimit(10**7) N, K = map(int,input().split()) A = list(map(int, input().split())) check = [0]*N tele_lis = [] start = [] def tele(x): check[x-1] = 1 tele_lis.append(x) if check[A[x-1]-1] == 0: tele(A[x-1]) else: start.append(A[x-1]) return tele(1) for i in range(N): if start[0] == tele_lis[i]: break if i >= K: print(tele_lis[K]) else: print(tele_lis[i::][(K-i) % (sum(check)-i)])" p02684,s222537330,Accepted,"n, k = map(int, input().split()) A=list(map(int, input().split())) c=1 path=[] d={} l=0 while l<=k: if c in d: p=d[c] #print(p, path) pattern_l = l-p k-=((k-p)//pattern_l)*pattern_l path.append(c) l+=1 d[c]=l-1 c=A[c-1] print(path[k]) " p02684,s490400416,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) t_zero = [-1] * N t = 0 a = 1 while t_zero[a-1] == -1: if t == K: break t_zero[a-1] = t t += 1 a = A[a-1] else: k = (K - t_zero[a-1]) % (t - t_zero[a-1]) for _ in range(k): a = A[a-1] print(a)" p02684,s461007957,Accepted,"n, k, *a = map(int, open(0).read().split()) a = [None] + a done = [None] + [0] * n t = 0 p = 1 while not done[p]: done[p] = t p = a[p] t += 1 loop = t - done[p] orig = done[p] if k - orig > 0: k = (k - orig) % loop + orig p = 1 while k: p = a[p] k -= 1 print(p)" p02684,s364957973,Accepted,"N,K = map(int, input().split(' ')) cache={} log=[] A = list(map(lambda x:int(x)-1, input().split(' '))) now=0 while(True): log.append(now) cache[now]=1 now=A[now] if(cache.get(now)):break loop_start=log.index(now) loop_end=len(log) loop=loop_end-loop_start if K= k: ans = loop[k] else: loop_remain = (k-loop_begin) % loop_num ans = loop[loop_begin+loop_remain] print(ans) " p02684,s849227548,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) r = [None] * N i = 0 cur = 0 m = None while True: if m is None and r[cur] is not None: m = i - r[cur] K = i + (K-i)%m else: r[cur] = i if i == K: print(cur+1) exit() i += 1 cur = A[cur] - 1" p02684,s204542754,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) B = [] Vector = [0]*N j = 0 for i in range (0,K): if Vector[A[j]-1] == 1: Value = B.index(A[j]) C = B[B.index(A[j])::] break else: B.append(A[j]) Vector[A[j]-1] = 1 j = A[j]-1 if A[0] ==1: print(1) elif len(B) == K: print(B[-1]) else: print(C[(K-Value-1)%len(C)])" p02684,s039984640,Accepted,"n,k = [int(i) for i in input().split()] a = [0] + [int(i) for i in input().split()] pos = 1 move= 0 colors = [-1]*(n+1) while(colors[pos]==-1): colors[pos] = move move += 1 pos = a[pos] if move==k: print(pos) break else: turn = move - colors[pos] rest = (k-colors[pos]) % turn while rest: pos = a[pos] rest -= 1 print(pos)" p02684,s302544387,Accepted,"import sys input = sys.stdin.readline n, k = map(int, input().split()) a = list(map(int, input().split())) cnt, town = 0, 1 l, s = [], set() while True: town = a[town - 1] cnt += 1 if cnt == k: print(town) exit() if town in s: loop_start = town break l.append(town) s.add(town) loop_cnt = l.index(loop_start) loop = l[loop_cnt:] loop_len = len(loop) k -= loop_cnt print(l[loop_cnt:][k%loop_len-1]) " p02684,s912778340,Accepted,"N, K = map(int, input().split()) D = K.bit_length() to = [[0] * D for _ in range(N)] for i, a in enumerate(map(int, input().split())): to[i][0] = a - 1 for j in range(D - 1): for i in range(N): h = to[i][j] to[i][j+1] = to[h][j] v = 0 for i in reversed(range(D)): x = 1 << i if x <= K: v = to[v][i] K -= x print(v + 1)" p02684,s373916880,Accepted,"n,k = map(int, input().split()) a = list(map(lambda x : int(x) -1, map(int, input().split()))) s = {0} loop = [0] while a[loop[-1]] not in s: loop.append(a[loop[-1]]) s.add(loop[-1]) idx = loop.index(a[loop[-1]]) if k < len(loop): print(loop[k]+1) else: print(loop[(k - idx)% (len(loop) - idx) + idx] + 1) " p02684,s611531424,Accepted,"n,k=map(int,input().split()) a=list(map(int,input().split())) s=[] ordn=[] for i in range(n+1): ordn.append(-1) v=1 while(ordn[v] == -1): ordn[v]=len(s) s.append(v) v=a[v-1] c=len(s)-ordn[v] l=ordn[v] if k i: if visited[now] == 0: i += 1 visited[now] = i now = lst[now] else: break lp = (i + 1) - visited[now] st = i - lp k_bk = k - st k_bk = k_bk // lp lft = k - (k_bk * lp + st) if lft == 0: print(now+1) else: for _ in range(lft): now = lst[now] print(now+1) " p02684,s674057345,Accepted,"n, k = map(int, input().split()) aaa = list(map(lambda x: int(x) - 1, input().split())) visited = [0] * n next_town = 0 order = [] while True: if visited[next_town]: break order.append(next_town) visited[next_town] = 1 next_town = aaa[next_town] first_loop = len(order) offset = order.index(next_town) second_loop = first_loop - offset if k < first_loop: print(order[k] + 1) else: print(order[offset + (k - first_loop) % second_loop] + 1)" p02684,s854958507,Accepted,"n, k = [int(_) for _ in input().split()] a = [int(_) for _ in input().split()] t = 0 l = [] c = 0 d = {} while True: d[t+1] = c c += 1 l.append(t+1) t = a[t] - 1 # if t == 0: # break if t + 1 in d: s = l[d[t+1]:] q = d[t+1] break # print(l) # print(s) # print(d) # print(q) if k <= q: print(l[k]) else: print(s[(k-q) % len(s)]) " p02684,s547461768,Accepted,"n, k = map(int, input().split()) a = list(map(lambda ai: int(ai) - 1, input().split())) visited = [-1] * len(a) now = 0 visited[0] = 0 while k > 0: k -= 1 old = now now = a[now] if visited[now] != -1: p = visited[old] + 1 - visited[now] k %= p visited = [-1] * len(a) else: visited[now] = visited[old] + 1 print(now + 1) " p02684,s109641265,Accepted,"N, K = map(int, input().split()) a = list(map(int, input().split())) l = [1] for i in range(N): l.append(a[l[i]-1]) p = l.index(l[N]) if K<=N: print(l[K]) else: x = (K-N+1)%(N-p) if x ==0: print(l[N-1]) else: print(l[x+p-1])" p02684,s388150176,Accepted,"n, k = map(int, input().split()) a = [-1] + list(map(int, input().split())) visited = [0] * (1 + n) curr = 1 while k: if visited[curr]: break else: visited[curr] = k curr = a[curr] k -= 1 if k == 0: print(curr) exit() repeat = visited[curr] - k k = k % repeat while k: curr = a[curr] k -= 1 print(curr)" p02684,s293112051,Accepted,"n, k = [int(x) for x in input().split()] a_list = [int(x) - 1 for x in input().split()] ci = 0 temp_dict = {0: 0} temp_list = [0] for i in range(1, k + 1): temp = a_list[ci] if temp in temp_dict: ci = temp_list[(k - i) % (i - temp_dict[temp]) + temp_dict[temp]] break temp_dict[temp] = i temp_list.append(temp) ci = temp print(ci + 1)" p02684,s202897892,Accepted,"N,K=map(int,input().split()) A=list(map(int,input().split())) cycle=[] for i in range(0,N): cycle.append(-1) A[i]-=1 count=0 cycle[0]=count town=0 mod=0 while True: count+=1 K-=1 town=A[town] if K==0: mod=1 break if cycle[town]==-1: cycle[town]=count else: mod=count-cycle[town] break K%=mod while K>0: town=A[town] K-=1 print(town+1) " p02684,s728292442,Accepted,"n, k = [int(i) for i in input().split()] a = [int(i)-1 for i in input().split()] x = list(range(n)) def calc(a, b): c = [0] * n for i in range(n): c[i] = b[a[i]] return c while k: if k & 1 == 1: x = calc(x, a) k //= 2 a = calc(a, a) print(x[0]+1)" p02684,s195689882,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) current = 1 path = [1] already = [False] * len(A) while K > 0: if already[current - 1]: loop = path[path.index(A[current - 1]):] current = loop[(K - 1) % len(loop)] break path += [A[current - 1]] already[current - 1] = True current = A[current - 1] K -= 1 print(current) " p02684,s733195604,Accepted,"from collections import Counter N, K = map(int,input().split()) tele = list(map(int, input().split())) #A1から順にワープした時の経由順 now = 0 goal,loop,visit = [],[],[0]*N while visit[now]!=2: if visit[now]==0: goal.append(now) else: loop.append(now) visit[now] += 1 now = tele[now]-1 if len(goal)>K: print(goal[K]+1) else: amari = len(goal)-len(loop) print(loop[(K-amari)%len(loop)]+1)" p02684,s645109812,Accepted,"n, k = map(int, input().split()) a = [0] + list(map(int,input().split())) explored = [0] * (n+1) t = 1 cycle = 0 while True: if explored[t] == 2: k %= cycle if k == 0: k = cycle explored[t] += 1 elif explored[t] == 1: explored[t] += 1 cycle += 1 elif explored[t] == 0: explored[t] += 1 k -= 1 if k == 0: break else: t = a[t] print(a[t])" p02684,s362905067,Accepted,"N, K = map(int, input().split()) a = list(map(int, input().split())) chk = [0] * N start = -1 ido = [0] chk[0] = 1 index = 0 cnt = 0 while True: index = a[index] - 1 if chk[index] == 0: chk[index] += 1 cnt += 1 ido.append(index) else: start = index break if cnt >= K: print(ido[K] + 1) exit() tmp = ido.index(start) ido = ido[tmp:] K -= tmp print(ido[K % len(ido)] + 1)" p02684,s432230551,Accepted,"N,K=[int(x) for x in input().rstrip().split()] A=[int(x) for x in input().rstrip().split()] stack=[] done=[0 for i in range(2*(10**5))] done[0]=0 now=0 dou=[] while(done[now]<2): if done[now]==0: stack.append(now) else: dou.append(now) done[now]+=1 now=A[now]-1 if K=0: break visited[now] = i if i==K: ans = now else: num = (K-visited[now])%(i-visited[now])+visited[now] ans = visited.index(num) return ans print(solve()) " p02684,s787092981,Accepted,"N,K=map(int,input().split()) A=list(map(int,input().split())) l=[-1]*N l[0]=0 i=1 t=0 while 1: t=A[t]-1 if l[t]!=-1: s=i-l[t] break l[t]=i i+=1 if K= ind: ans = (k - ind) % len(cycle) print(cycle[ans]) else: print(route[k])" p02684,s162179502,Accepted,"n, k = map(int, input().split()) a = tuple(map(lambda n: int(n) - 1, input().split())) visited = [0] * n next_town = 0 order = [] while True: if visited[next_town]: break order.append(next_town) visited[next_town] = 1 next_town = a[next_town] first_loop = len(order) offset = order.index(next_town) second_loop = first_loop - offset if k < first_loop: print(order[k] + 1) else: print(order[offset + (k - first_loop) % second_loop] + 1) " p02684,s229486955,Accepted,"from itertools import count N, K = map(int, input().split()) As = [int(n) for n in input().split()] visited = [] visited_set = set() now = 0 num = 0 idx = 0 for i in count(): if now in visited_set: idx = visited.index(now) num = len(visited) - idx break visited_set.add(now) visited.append(now) now = As[now] - 1 if K <= idx: print(visited[K] + 1) else: print(visited[idx + (K - idx) % num] + 1)" p02684,s475198195,Accepted,"n, k = map(int, input().split()) a = list(map(int, input().split())) b = [] ord = [-1 for x in range(n+1)] c = 1 l = 1 v = 1 while(ord[v] == -1): ord[v] = len(b) b.append(v) v = a[v-1] c = len(b) - ord[v] l = ord[v] if (k < l): print(b[k]) else: k -= l k %= c print(b[l+k]) " p02684,s928707336,Accepted," N, K= list(map(int, input().split())) A_list = list(map(int, input().split())) loop = [] trace = [0] * (N+1) visited = set() ai = 1 for i in range(N+1): if ai in visited: ind = trace.index(ai) loop = trace[ind:i] trace = trace[:ind] break visited.add(ai) trace[i] = ai # ?? ai = A_list[ai-1] if len(trace) > K: print(trace[K]) else: ind = K - len(trace) ind = ind % len(loop) print(loop[ind]) " p02684,s299273163,Accepted,"#!/usr/bin/env python3 N, K = map(int, input().split()) A = [int(a) - 1 for a in input().split()] if K <= N: p = 0 for _ 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)" p02684,s738796028,Accepted,"import sys a,b=map(int,input().split()) b=b+1 l=[0]*(a) List=list(map(int,input().split())) i=0 j=1 while l[i]==0 and j>=1 print(c)" p02684,s553751071,Accepted,"N, K = map(int, input().split()) A = input().split() A = [int(a) for a in A] S = [1] a = 1 number = 0 numbers=[-1 for _ in range(N)] for _ in range(N + 1): b = A[a - 1] if numbers[b-1] != -1: c=numbers[b-1] break numbers[b-1]=number number += 1 S.append(b) a = b T = S[c+1:number+1] if K <= number: print(S[K ]) else: z = K - c-1 y = z % (number - c) print(T[y]) " p02684,s486854781,Accepted,"n,k = map(int,input().split()) A = [0]+list(map(int,input().split())) visited = [False for _ in range(n+1)] pos = 1 x = [] flg = False for i in range(k): if visited[pos] == False: x.append(pos) visited[pos] = True pos = A[pos] else: flg = True pre = x.index(pos) loop = x[pre:] break if not flg: print(pos) else: print(loop[(k-pre)%len(loop)])" p02684,s127526708,Accepted,"n, k = map(int, input().split()) a = tuple(map(int, input().split())) i = 0 aa = 0 visited = {} for i in range(k): aa = a[aa] - 1 if aa in visited: s, e = visited[aa], i loop = e - s k = s + (((k-1) - s) % loop) print(list(visited.keys())[k] + 1) exit(0) visited[aa] = i print(aa+1) " p02684,s920016735,Accepted,"import sys input = sys.stdin.readline n, k = [int(x) for x in input().split()] a = [int(x) for x in input().split()] visited = set() visited.add(0) now = 0 route = [0] for i in range(1, n + 5): now = a[now] - 1 if now in visited: break route.append(now) visited.add(now) start = route.index(now) loop = i - start if k <= start: print(route[k] + 1) else: k -= start k %= loop route = route[start:] print(route[k] + 1) " p02684,s407193708,Accepted,"N, K = map(int, input().split()) towns = list(map(int, input().split())) towns.insert(0, -1) p = 1 tmp_move, first_move, roop_move = [1], [], [] visited = [False for _ in range(N + 1)] res = -1 while not visited[p]: visited[p] = True tmp_move.append(towns[p]) p = towns[p] index = tmp_move.index(p) roop_move = tmp_move[index:-1] first_move = tmp_move[:index] if K < len(first_move): res = first_move[K] else: index = (K - len(first_move)) % len(roop_move) res = roop_move[index] print(res)" p02684,s843198794,Accepted,"n, k = map(int, input().split()) A = [0] + list(map(int, input().split())) pos = [1] for i in range(2 * n): nxt = A[pos[-1]] pos.append(nxt) if k < n + 1: print(pos[k]) exit() loop_end = n loop_start = n - 1 while pos[loop_start] != pos[loop_end]: loop_start -= 1 period = loop_end - loop_start m = n - period k = m + (k - m) % period print(pos[k])" p02684,s966767549,Accepted,"n, k = map(int, input().split()) towns = [int(s) for s in input().split()] pos = [] pos_set = set() cur = towns[0] i = 0 end = False while not cur in pos_set: i += 1 if k == i: print(cur) end = True break pos.append(cur) pos_set.add(cur) cur = towns[cur-1] if not end: j = pos.index(cur) print(pos[(k-j-1)%(len(pos)-j) + j]) " p02684,s856008399,Accepted,"N, K = list(map(int, input().split())) A = [0] + list(map(int, input().split())) path = [0]*(N+1) visited = set() pos = 1 for i in range(N+1): if pos in visited: break path[i] = pos visited.add(pos) pos = A[pos] loc = path.index(pos) head = path[:loc] rep = path[loc:i] if K < len(head): print(head[K]) else: print(rep[(K - len(head)) % len(rep)]) " p02684,s253760994,Accepted,"N, K = map(int, input().split()) A = tuple(int(x) - 1 for x in input().split()) done = {0} rt = [0] loop_point = 0 while True: p = rt[-1] np = A[p] if np in done: loop_point = np break done.add(np) rt.append(np) if K < len(rt): ans = rt[K] + 1 else: K -= len(rt) rt = rt[rt.index(loop_point):] ans = rt[K%len(rt)] + 1 print(ans)" p02684,s716189347,Accepted,"N, K = map(int, input().split()) A = list(map(int, input().split())) v, p, s = [-1] * N, 1, K while s > 0: if v[p - 1] == -1: v[p - 1] = s else: p = v.index(v[p - 1] - s % (v[p - 1] - s)) + 1 break p, s = A[p - 1], s - 1 print(p) " p02684,s711581106,Accepted,"n,k = [int(i) for i in input().split()] a = [int(i) for i in input().split()] v = [0 for i in range(n+1)] v[0] = 1 r = [1] p = a[0] while v[p]==0: v[p] = 1 r.append(p) if len(r)==k+1: break p = a[p-1] if len(r)==k+1: print(p) else: idx = r.index(p) k -= idx print(r[k%(len(r)-idx)+idx]) " p02684,s154212246,Accepted,"N, K = map(int, input().split()) A = list(map(lambda a: int(a) - 1, input().split())) T = [A] for _ in range(64): prev = T[-1] T.append([prev[a] for a in prev]) now = 0 for d, P in enumerate(T): if ((1 << d) & K) > 0: now = P[now] print(now + 1) " p02684,s577285526,Accepted,"[n,k]=list(map(int,input().split())) alist=list(map(int,input().split())) #足跡 footprint=[0]*n omoide=[] now=0 counter=1 while True: if footprint[now]!=0: break footprint[now]=counter omoide.append(now) goto=alist[now]-1 now=goto counter+=1 joso=footprint[now]-1 shuki=counter-footprint[now] if k>joso: k-=joso k=k%shuki ans=omoide[joso+k]+1 else: ans=omoide[k]+1 print(ans) " p02684,s707046832,Accepted,"N, K = map(int, input().split()) *A, = map(int, input().split()) A = [a-1 for a in A] # Douling(ダブリング) i = 1 to = [[a for a in A]] while pow(2, i) < K: t = [to[i-1][to[i-1][j]] for j in range(N)] to.append(t) i += 1 i -= 1 ans = 0 while i >= 0: if K & (1 << i) > 0: ans = to[i][ans] i -= 1 print(ans+1)" p02684,s153942460,Accepted,"n,k=map(int,input().split()) a=list(map(lambda x:int(x)-1,input().split())) ans=-1 l=[-1]*n now=0 i=1 result=[0] while i<=k: now=a[now] if l[now]!=-1: length=i-l[now] d=(k-i)%length+l[now] ans=l.index(d) break l[now]=i i+=1 if ans!=-1: print(ans+1) else: print(now+1)" p02684,s831994105,Accepted,"N,K=map(int,input().split()) A=list(map(int,input().split())) dic={} goto=A[0] for i in range(K): tmp=goto goto=A[tmp-1] if not tmp in dic: dic[tmp]=i else: bef=dic[tmp] loop=i-bef rem=K-1-i rem=rem%loop for j in range(rem): tmp=goto goto=A[tmp-1] break print(tmp)" p02684,s379224332,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)" p02684,s384410804,Accepted,"N,K = map(int, input().split()) A = [*map(lambda x:int(x)-1, input().split())] index = [-1]*N pre, path_cnt = 0, 0 for i in range(N): if index[pre] >= 0: break else: index[pre] = i path_cnt += 1 pre = A[pre] loops = path_cnt - index[pre] one = index[pre] k = max(0, K-one) % loops + min(K, one) pre = 0 for _ in range(k): pre = A[pre] print(pre + 1) " p02684,s600333296,Accepted,"N, K = map(int, input().split()) A = list(map(lambda x: int(x) - 1, input().split())) visited = set() current = 0 answer = 0 count = 0 while current not in visited and count < K: visited.add(current) count += 1 current = A[current] answer = current if count == K: print(answer + 1) exit(0) # print(count) start = A[current] ary = [start] loop_size = 1 while start != current: loop_size += 1 start = A[start] ary.append(start) # print(ary) # print('loop_size', loop_size) print(ary[(K - count) % loop_size - 1] + 1) " p02684,s185240855,Accepted,"inpl = lambda: list(map(int,input().split())) N, K = inpl() A = inpl() for i in range(N): A[i] -= 1 P = dict() k = 0 former = True i = 1 while i <= K: if k in P.keys() and former: loop = i - P[k] K = i + (K-i) % loop former = False else: P[k] = i k = A[k] i += 1 else: print(k+1) " p02684,s883526957,Accepted,"n, k = map(int, input().split()) a = [0]+list(map(int, input().split())) num = 1 li = [1] flag = [True] * n flag[0] = False for i in range(k): num = a[num] if flag[num-1]: li.append(num) flag[num-1] = False else: break d = li.index(num) ans = (k-d)%(len(li)-d)+d print(li[ans])" p02684,s478851728,Accepted,"N, K = map(int, input().split()) Alist = list(map(int, input().split())) path = [0] next = Alist[0] seen = set() seen.add(0) while (next-1) not in seen: seen.add(next-1) path.append(next-1) next = Alist[next-1] base = path.index(next-1) loop_length = len(path) - base loop = path[base:base+loop_length+1] # print(path) # print(loop, loop_length, base) if K <= base: print(path[K]+1) else: K -= base print(loop[K%loop_length]+1) " p02684,s100855499,Accepted,"#!/usr/bin/env python3 n, k = map(int, input().split()) a = list(map(int, input().split())) ans = [1] c = 1 for i in range(n): ans.append(a[ans[i] - 1]) b = ans.index(ans[n]) if k < b: for l in range(k): c = a[c - 1] else: for l in range((k-b)%(n-b)+b): c = a[c - 1] print(c) " p02684,s929352307,Accepted,"N,K = map(int,input().split()) As = list(map(int,input().split())) towns = [0]*N route = [0] pre = 0 i = 0 towns[0] = 1 for _ in range(K): i = As[i]-1 if towns[i]>0: pre = route.index(i) route = route[pre:] break route.append(i) towns[i] = 1 mod = len(route) print(route[(K-pre)%mod]+1) " p02684,s966705875,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() A = rl() edges = {} for i, a in enumerate(A): edges[i] = a-1 mem = {} k = 0 n = 0 while True: if k == K: print(n+1) exit() if n in mem: break mem[n] = k k += 1 n = edges[n] p = k-mem[n] idx = (K - k) % p for i in range(idx): n = edges[n] print(n+1) " p02684,s867887022,Wrong Answer,"n, k = map(int, input().split()) a = list(map(int, input().split())) i = 0 ans = 0 root = [-1] * n flag = [False] * n j = 0 while flag[a[i] - 1] == False: flag[a[i] - 1] = True root[j] = a[i] i = a[i] - 1 j += 1 s_i = root.index(a[i]) x = 0 for i in range(k % (j - s_i)): ans = root[x] x = root[x] - 1 print(ans)" p02684,s999903225,Wrong Answer,"n,k=map(int,input().split()) a=[int(x) for x in input().rstrip().split()] l=[0 for i in range(n)] cnt=0 dist=[] now=0 while(True): if l[now]+1==3: break dist.append(now) l[now]+=1 now=a[now]-1 k=k-l.count(1) g=l.count(2) # print(dist) # print(l) dist=dist[l.count(1):] print(dist[k%g]+1) " p02684,s546404097,Wrong Answer,"def main(): N , K = list(map(int,input().split())) A = list(map(int,input().split())) A.insert(0,0) local = 1 tmp = [] tmp.append(local) for k in range(N): local = A[local] if local in tmp: result = len(tmp) - tmp.index(local) break else: tmp.append(local) for k in range((K-tmp.index(local)) % result): local = A[local] print(local) if __name__ == '__main__': main()" p02684,s894941220,Wrong Answer,"n, k = map(int, input().split()) a = [int(x)-1 for x in input().split()] visited = [0] * n visit_list = [0] visit = 0 while True: visit_list.append(a[visit]) visit = a[visit] if visited[visit] == 1: break visited[a[visit]] = 1 print(visit_list[k%len(visit_list)]+1)" p02684,s030967366,Wrong Answer,"n,k = map(int,input().split()) a = [int(i) for i in input().split()] done = [] def ml(a): cnt=1 nxt=a[0]-1 done.append(0) done.append(nxt) while(True): nxt = a[nxt]-1 if nxt in done: m = done.index(nxt) - 1 l = cnt - m return (m+1,l) else: done.append(nxt) cnt+=1 # print(is_1(a)) m,l = ml(a) num = (k-m)%l # print(f""m={m},l={l}"") # print(f""done={done}"") # print(f""m+num={m+num}"") print(done[m+num]+1) " p02684,s829379912,Wrong Answer,"n, k = map(int, input().split()) a = list(map(int, input().split())) now = 1 for i in range(min(k,int(2*n-1))): now = a[now-1] print(now)" p02684,s128690054,Wrong Answer,"n,k = map(int, input().split()) #int a = input().replace("" "","""") #str chokudai = ""1"" #str fp = ""1"" #str telenum = 0 #int while True: chokudai = a[int(chokudai)-1] telenum += 1 rooph = fp.find(chokudai) #int if rooph != -1: rooplen = len(fp)-rooph break else: fp = fp+chokudai print(fp[rooph+k%rooplen])" p02684,s159712516,Wrong Answer,"N, K = map(int, input().split()) A = list(map(lambda x:int(x) - 1, input().split())) already = [False for i in range(N)] already[0] = True tel = [0] while True: tmp = A[tel[-1]] tel.append(tmp) if already[tmp]: tel.pop() break already[tmp] = True for i in range(len(tel)): if tel[i] == tmp: s = i break ans = (K - s) % (len(tel) - s) print(tel[ans + s] + 1) " p02684,s692861422,Wrong Answer,"n,k = map(int, input().split()) a = [0] + list(map(int, input().split())) before=0 roop=0 cnt={} nxt=1 mp = [] for i in range(1, k+1): mp.append(nxt) if nxt not in cnt: cnt[nxt] = i nxt = a[nxt] else: roop = i - cnt[nxt] before = cnt[nxt]-1 break roop=1 before=0 print(mp[before + (k-before)%roop])" p02684,s470840144,Wrong Answer,"import sys n, k = map(int, input().split()) ara = list( map(int, input().split()) ) now = 0 vis = [] taken = [0]*n while taken[now] == 0: vis.append(now) taken[now] = 1 now = ara[now]-1 cycleLen = len(vis) - vis.index(now) if k < vis.index(now): print(vis[k]) sys.exit() k -= vis.index(now) k %= cycleLen print(vis[k + vis.index(now) ] + 1) " p02684,s079413814,Wrong Answer,"n,k=map(int,input().split()) a=[0]+list(map(int,input().split())) b=[1] d=set() d.add(1) e=1 while n==n: if a[e] in d: e=a[e] break b.append(a[e]) d.add(a[e]) e=a[e] print(b[(k-b.index(e))%(len(b)-b.index(e))+b.index(e)]) " p02684,s824718986,Wrong Answer,"n,k=map(int,input().split()) a=[int(x) for x in input().rstrip().split()] l=[0 for i in range(n)] cnt=0 dist=[] now=0 while(True): if l[now]+1==3: break dist.append(now) l[now]+=1 now=a[now]-1 # k=k-l.count(1) g=l.count(2) # print(dist) # print(l) print(dist[k%g+l.count(1)]+1) " p02684,s652872546,Wrong Answer,"N, K =map(int, input().split()) A = [int(a) - 1 for a in input().split()] idx = 0 if K<=N: for i in range(K): idx = A[idx] print(A[idx] + 1) exit() #全ての実行をここで終了 t = [-1] * N t[0] = 0 for i in range(1, N): idx = A[idx] last = i if t[idx] != -1: break t[idx] = i d = i - t[idx] K = K - i amari = K%d for i in range(amari): idx = A[idx] print(idx + 1) " p02684,s268889511,Wrong Answer,"NK = list(map(int, input().split())) N = NK[0]; K = NK[1] A = list(map(int, input().split())) rlist = [0]*N flag = 1 location = 1 div = 0 while flag>0: location = A[location-1] if rlist[A[location-1]-1] == 0: rlist[A[location-1]-1] = rlist[location-1]+1 else: div = rlist[location-1]+1-rlist[A[location-1]-1] flag = -1 cnt = (K-rlist[A[location-1]-1])%div + rlist[A[location-1]-1] result = 0 for i in range(cnt): result = A[result]-1 print(result+1)" 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)" p02684,s241015082,Wrong Answer,"N, K = map(int, input().split()) A = [0] + list(map(int, input().split())) s = [0] * (N+1) p = 1 h = [] while True: h.append(p) s[p] = 1 p = A[p] if s[p] != 0: break last = h.index(p) leng = len(h) - last rem = (K - last) % leng print(h[last:][rem]) " p02684,s582535976,Wrong Answer,"N, K = map(int, input().split()) A = list(map(int, input().split())) r = [0]*N now = 0 r[now]=1 for i in range(N): now = A[now]-1 if r[now] == 0: r[now] = i+2 else: x1 = r[now] x2 = i+1 break print(x1, x2) print(r) roop_num = x2 - x1 + 1 x = (K-x1+1) % roop_num print(x) if K < x1: print(r.index(K+1)+1) else: print(r.index(x1 + x)+1) " p02684,s623619808,Wrong Answer,"n, k = map(int, input().split()) a_list = list(map(int, input().split())) loop = [] now = 1 while not now in loop: loop.append(now) now = a_list[now - 1] loop_start_index = loop.index(now) print(loop[loop_start_index + (k - loop_start_index) % (len(loop) - loop_start_index)]) " p02684,s295394972,Wrong Answer,"n, k = map(int, input().split()) A = list(map(int, input().split())) order = [-1] * (n+1) v = [0] * (n+1) v[0] = 1 order[v[0]] = 0 # iは順番 for i in range(1, n+1): v[i] = A[v[i-1] - 1] if order[v[i]] != -1: old_i = order[v[i]] c = i - old_i break order[v[i]] = i if k < old_i: print(v[k-1]) else: print(v[(k - old_i)%c + old_i])" p02684,s933653115,Wrong Answer,"import sys N, K = map(int, input().split()) #print(N) #print(K) A = sys.stdin.readlines() #改行コード削除 A = [b.strip() for b in A][0].split() #print(A) print(A[int(A[(K % N) - 1]) - 1]) " p02684,s663070568,Wrong Answer,"N, K = map(int, input().split()) A = list(map(int, input().split())) temp = 1 count = 0 ans = 0 dict_num = {} set_num = set() for _ in range(K): count += 1 temp = A[temp-1] if temp in set_num: dict_num[temp] += 1 if dict_num[temp] == 3: break else: dict_num[temp] = 1 set_num.add(temp) continue else: ans = temp if count == K: pass else: count = count - list(dict_num.values()).count(1) -1 mod = K % count for _ in range(mod + 1): temp = A[temp-1] else: ans = temp print(ans)" p02684,s822056562,Wrong Answer," n,k = map(int,input().split()) l = list(map(int,input().split())) position = 1 town = '' stayed = [1] stayed_c = [0]*n for i in range(n): position = l[position-1] if not position in stayed: stayed.append(position) stayed_c[position-1] = i+1 else: c = i+1 - stayed_c[position-1] g = stayed_c[position-1] town = position break m = (k -g) % c position = town for i in range(m): position = l[position-1] print(position) " p02684,s685913132,Wrong Answer,"N, K = map(int, input().split()) A = list(map(int, input().split())) for i in range(N): A[i] -= 1 loop_lis = [0] visited = [0 for _ in range(N)] visited[0] = 1 loop_time = 0 start_loop = 0 for i in range(K): if visited[A[loop_lis[-1]]] != 0: loop_time = (i+2)-(visited[A[loop_lis[-1]]]) start_loop = i+1 - loop_time break visited[A[loop_lis[-1]]] = i+1 loop_lis.append(A[loop_lis[-1]]) if len(loop_lis) == K+1: print(loop_lis[-1]+1) else: print(loop_lis[start_loop+(K-start_loop)%loop_time]+1)" p02684,s354285480,Wrong Answer,"N,K=map(int, input().split()) A = list(map(int, input().split())) where = [0 for k in range(N)] where[0]=1 loop=0 for k in range(N): where[k+1] = A[where[k]-1] if where[k+1] in where[0:k]: li = where[0:k] end = k+1 start = li.index(where[k+1]) loop = end -start break loopbefore = K -end loopafter = loopbefore%loop where2 = [where[end]] for k in range(loopafter): where2.append(A[where2[k]-1]) print(where2[-1]) " p02684,s519155251,Wrong Answer,"n,k=map(int,input().split()) l=list(map(int,input().split())) lcount=[0]*(n+1) lnum=[0]*(n+1) count=0 place=1 while lcount[place]==0: lnum[place]=count lcount[place]=1 place=l[place-1] count+=1 dif=count-lnum[place] k=k%dif+lnum[place] print(lnum.index(k)) " p02684,s559510896,Wrong Answer,"import numpy as np import math N, K=map(int,input().split()) A2 = np.zeros(N) A = list(map(int,input().split())) #A = list(map(lambda x: x -1 , A)) current_town = 0 i=0 while i 1]) D = sorted(C[B > 1]) tmp = D[ans] index = A[C == tmp] print(*index)" p02684,s193060707,Wrong Answer,"N,K = map(int, input().split()) A = list(map(int, input().split())) for i in range(N): A[i] = A[i] -1 G = 0 lis = [0]*N lis[0] = 1 roop = [] cnt = 0 while True: G = A[G] cnt +=1 lis[G] += 1 if lis[G] == 2: roop.append(G) elif lis[G] == 3: break roop_cn = len(roop) diff = cnt - roop_cn*2 K_n = K - diff amari = K_n % roop_cn print(roop[amari]+1)" p02684,s187185950,Wrong Answer,"n, k = map(int, input().split()) a = list(map(int, input().split())) cnt = [1] jun = 0 i = 0 while len(cnt) == len(set(cnt)): cnt.append(a[i]) i = a[i]-1 x = cnt.pop() id = cnt.index(x) k -= id cnt = cnt[id:] print(cnt[k%len(cnt)]) " p02684,s657940895,Wrong Answer,"N, K = map(int, input().split()) A = list(map(int, input().split())) visited = [-1] * N visited[0] = 0 nxt = 1 cnt = 1 for i in range(N): nxt = A[nxt-1] if visited[nxt-1] == -1: visited[nxt-1] = cnt cnt += 1 else: cycl = i + 1 - visited[nxt-1] m = visited[nxt-1] break print(visited, cycl) k = (K - m) % cycl + m for i in range(N): if visited[i] == k: print(i+1) break " p02684,s521935250,Wrong Answer,"n, k = list(map(int, input().split())) a = list(map(int, input().split())) a = [0] + a now = 1 cities = [now] done = set() for i in range(n): now = a[now] if now in done: break done.add(now) cities.append(now) idx_s = cities.index(now) f = (len(cities) - idx_s) d = k - idx_s idx = d%f ans = cities[idx + idx_s] print(ans)" p02684,s133323535,Wrong Answer,"n,k = map(int,input().split()) a_list = list(input().split()) dum = a_list[0] ans_list = """" for i in range(1,k+1): k = k - 1 ans_list = ans_list+dum dum = a_list[int(dum)-1] if ans_list.count(dum) == 1: break ind = ans_list.index(dum) loop = ans_list[ind:] len_loop = len(loop) loop_after = (k)%len_loop print(loop[loop_after-1]) " p02684,s538692220,Wrong Answer,"n, k = map(int,input().split()) a = list(map(int,input().split())) s = 0 seen = [False for _ in range(n)] d = [] while not seen[s]: seen[s] = True d.append(s) s = a[s]-1 noncyi = d.index(s) cyi = len(d) - noncyi if k < noncyi: print(d[k-1]) else: k -= noncyi print(d[noncyi + k%cyi]+1)" p02684,s000671786,Wrong Answer,"n, k = map(int,input().split()) a = list(map(int,input().split())) kaisuu = k % n ans = a[kaisuu] print(a[ans])" p02684,s112396125,Wrong Answer,"n, k = map(int, input().split()) a_ls = list(map(int, input().split())) my_dict = dict() ptr = 0 cnt = 0 while True: if ptr in my_dict: break else: my_dict[ptr] = cnt cnt += 1 ptr = a_ls[ptr] - 1 loop = cnt - my_dict[ptr] k = k % loop + loop * (10 ** 6 // loop) ptr = 0 for i in range(k): ptr = a_ls[ptr] - 1 print(ptr + 1) " p02684,s296831995,Wrong Answer,"# coding: utf-8 # Your code here! n,k=map(int,input().split()) A=list(map(int,input().split())) L=[1] now=1 for _ in range(n): now=A[now-1] if now == L[0]: break L.append(now) R=k%len(L) print(L[R])" p02684,s140661286,Wrong Answer,"import sys readline = sys.stdin.readline N,K = map(int,readline().split()) A = [0] + list(map(int,readline().split())) c = 1 while K: if K & 1: c = A[c] A = [A[i] for i in range(len(A))] K >>= 1 print(c)" p02684,s929894370,Wrong Answer,"N,K=map(int, input().split()) A = list(map(int, input().split())) A = [0] + A visited = [1] now = 1 while True: next = A[now] if next in visited: break visited.append(next) now = next initial = visited.index(next) cycle = len(visited[initial:]) residual = (K - initial) % cycle print(visited[initial+residual])" p02684,s544342983,Wrong Answer,"N,K=map(int,input().split()) A=list(map(int,input().split())) m=1 L=[1] for i in range(N+2): m=A[m-1] if m not in L: L.append(m) else: L.append(m) break c=L.index(m) le=len(L) #le-cでループ c,le,2*le-c.... rupe=le-c-1 a=K%rupe if a 1: break temp.append(now) now = A[now-1] for t in temp[::-1]: cnt += 1 if t == now: break # print(temp) # print(cnt) print(temp[K%cnt]) " p02684,s064192265,Wrong Answer,"import sys readline = sys.stdin.readline n, k = map(int, readline().split()) A = list(map(int, readline().split())) visited = [False] * n visited[0] = True l = [1] while True: x = A[l[-1]-1] if visited[x-1]: break l.append(x) visited[x-1] = True # print(x) # print(l) # print(l[l.index(x):]) print(l[l.index(x):][(k-l.index(x)) % len(l[l.index(x):])]) " p02684,s041172285,Wrong Answer,"n, k = map(int, input().split()) A = list(map(int, input().split())) A = [a - 1 for a in A] visited = [0] * n i = 0 lp = 0 step = [] while visited[i] == 0: visited[i] = 1 next_visit = A[i] step.append(i) lp += 1 i = next_visit lp_start = step.index(i) syuki = lp - lp_start if lp_start > k: ans = step[k] else: cnt = (k - lp_start) % syuki ans = step[lp_start:][cnt] + 1 print(ans)" p02684,s096440163,Wrong Answer,"n,k = map(int,input().split()) a = list(map(int,input().split())) now = 1 x = 0 ss = set([1]) for i in range(k): now = a[now-1] ss.add(now) if len(ss) != i+2: x = 1 break if x == 1: aa = k%len(ss) for i in range(aa): now = a[now-1] print(now)" p02684,s335696378,Wrong Answer,"n,k = map(int,input().split()) li = list(map(int,input().split())) count = 1 li2 = [1] li2.append(li[0]) for i in range(k): li2.append(li[li2[i+1]-1]) count += 1 if len(set(li2)) != count: break print(li2[k % len(li2)])" p02684,s515606389,Wrong Answer,"N, K = map(int, input().split()) A = list(map(int, input().split())) A = [a - 1 for a in A] L = [None]*(N+1) s = 0 L[0] = s index = -1 for i in range(min(N,K)): e = i+1 s = A[s] if s not in L: L[i+1] = s else: index = L.index(s) break if index == -1: g = K%e print(L[g]+1) else: g = index + (K-index)%(e-index) print(L[g]+1)" p02684,s190492337,Wrong Answer,"N,K=map(int,input().split()) A=[0]+list(map(int,input().split())) L=[] tmp=1 cnt=1 L.append(1) while True: L.append(A[tmp]) tmp=A[tmp] cnt+=1 #print(cnt,tmp) if A[tmp] in L: L.append(A[tmp]) break #print(L) res=0 for i in range(len(L)): if L[i]!=L[-1]: res+=1 else: break #print(res) R=L[res:-1] #print(R) K-=res num=K%len(R) ans=R[num] print(ans)" p02684,s739514826,Wrong Answer,"import copy N,K=map(int,input().split()) A=list(map(int,input().split())) i=A[0] for _ in range(N+K%N-1): i=A[i-1] print(i)" 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])" p02684,s148228473,Wrong Answer,"def resolve(): N, K = map(int, input().split()) A = tuple(map(int, input().split())) path = [1] for i in range(2*N): cur = A[path[-1]-1] path.append(cur) if K < N: print(path[K]) exit() end = path[N] si = N-1 while path[si] != end: si -= 1 dist = end - si +1 K = K % dist while K < N: K += dist print(path[K]) if __name__ == '__main__': resolve()" p02684,s848340847,Wrong Answer,"n,k=map(int,input().split()) a=[0] a.extend(list(map(int,input().split()))) loop=[] now=0 for i in range(1,n+1): if i==1: now=a[1] loop.append(now) else: now=a[now] if now!=a[1]: loop.append(now) else: break count=k%len(loop) if count ==0: print(loop[-1]) else: print(loop[count-1]) " p02684,s488423538,Wrong Answer,"s = input().split() N = int(s[0]) K = int(s[1]) s2 = input().split() A = [] for i in range(N): A.append(int(s2[i])) now = 1 root = [] root.append(now) for k in range(N): new = A[now-1] if new in root: Ka = K - root.index(new) new_root = root[root.index(new):] print(new_root[Ka%len(new_root)]) break else: now = new root.append(new)" p02684,s707552542,Wrong Answer,"data = input().split() n = int(data[0]) k = int(data[1]) t = list(map(int,input().split())) p = t[0] loop = [] while True: loop.append(p) p = t[p-1] if p in loop: repeat = p r_point = loop.index(p) break #print(loop) once = loop[:r_point] repeat = loop[r_point:] #print(once,repeat) k -= len(once) amari = k%len(repeat) print(repeat[amari-1]) #6 727202214173249351 #6 5 2 5 3 2" p02684,s093761194,Wrong Answer,"s = input().split() N = int(s[0]) K = int(s[1]) s2 = input().split() A = [] for i in range(N): A.append(int(s2[i])) now = 1 root = [] root.append(now) for k in range(N): new = A[now-1] if new in root: Ka = K - root.index(new) new_root = root[root.index(new):] print(new_root[Ka%len(new_root)]) break else: now = new root.append(new)" p02684,s916845288,Wrong Answer,"from collections import deque from sys import stdin def main(): N, K = [int(x) for x in stdin.readline().rstrip().split()] As = [int(x) for x in stdin.readline().rstrip().split()] pos = 1 tmp = deque([pos]) while True: pos = As[pos - 1] if pos in tmp: idx_s = tmp.index(pos) break tmp.append(pos) K = K - idx_s tmp = list(tmp) print(tmp[idx_s:][K % (len(tmp) - idx_s)]) if __name__ == ""__main__"": main() " p02684,s689890490,Wrong Answer,"N, K = map(int, input().split()) A = list(map(int, input().split())) j = 1 lis = [1] loop = 0 for i in range(K): j = A[j-1] if not j in lis: lis.append(j) else: n = lis.index(j) loop = len(lis) - n break if loop == 0: print(j) else: print(A[n + (K - len(lis)) % loop])" p02684,s923046018,Wrong Answer,"n, k = map(int, input().split()) a = [0] + list(map(int, input().split())) a1 = [0] * (n+1) step = 1 start = 0 while(True): start += 1 a1[step] += 1 step = a[step] if a1[step] == 1: break c = step gap = 0 while(True): gap += 1 step = a[step] if step == c: break k = (k+n*gap-start) % gap result = c for _ in range(k): result = a[result] print(result) " p02684,s437226967,Wrong Answer,"N, K = map(int, input().split()) A = list(map(int, input().split())) route = [1] current_town = 1 loop = False while not loop: current_town = A[current_town-1] if current_town in route: route.append(current_town) loop = True else: route.append(current_town) start_index = route.index(route[-1]) loop_cnt = len(route) - (start_index+1) K -= route.index(route[-1]) add_num = K % loop_cnt print(route[start_index+add_num])" p02684,s639089672,Wrong Answer,"n,k = map(int,input().split()) listA = list(map(int,input().split())) kouho = [1] ikisaki = listA[0] while ikisaki not in kouho: kouho.append(ikisaki) ikisaki = listA[ikisaki-1] index = kouho.index(ikisaki) loop = len(kouho) - index amari = (k-index)%loop print(kouho[index + amari])" p02684,s656168236,Wrong Answer,"n,k=map(int,input().split()) a=[int(i)-1 for i in input().split()] ed=[False]*n go=0 c=0 cc=0 while not ed[go]:#既に通っていたら終了 ed[go]=True go=a[go] c+=1 ed=[False]*n while not ed[go]:#二回目のループは違う可能性があるため6,5,2,5,3,2の場合、6,2,5,3,2,5,3,2,5,...となる ed[go]=True go=a[go] cc+=1#別変数で保存 for i in range((k-c-cc)%cc): go=a[go] print(go+1)" p02684,s806838924,Wrong Answer,"N, K = map(int, input().split()) A = list(map(int, input().split())) l = [0 for _ in range(N)] now = 0 l[now] = 1 count = 0 loop = [0] while count < K: count += 1 now = A[now]-1 loop.append(now) if l[now] == 1: loop = loop[loop.index(now):-1] break else: l[now] = 1 if count == K: print(now + 1) else: ans = loop[K % len(loop)] print(ans + 1) " 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) " p02684,s917878873,Wrong Answer,"N, K = map(int, input().split()) A = list(map(int, input().split())) B = [1] C = [1] + [0] * (N - 1) i = 0 while C[A[i] - 1] == 0: B.append(A[i]) C[A[i] - 1] = 1 i = A[i] - 1 ans = 0 for j in range(len(B)): if B[j] == A[i]: ans += j if (len(B) - ans != 0) and (K - ans > 0): ans += (K - ans) % (len(B) - ans) print(B[ans])" p02684,s212705847,Wrong Answer,"N,K = map(int, input().split()) A = list(map(int, input().split())) B = [1] for i in range(N): s = B[i] if A[s-1] != 1: B.append(A[s-1]) else: break l = len(B) print(B[(K%l)])" p02684,s585847266,Wrong Answer,"N, K = map(int, input().split()) A = list(map(lambda x:int(x) - 1, input().split())) already = [False for i in range(N)] already[0] = True tel = [0] while True: tmp = A[tel[-1]] tel.append(tmp) if already[tmp]: tel.pop() break already[tmp] = True for i in range(len(tel)): if tel[i] == tmp: s = i break if K - s >= 0: ans = (K - s) % (len(tel) - s) print(tel[ans + s] + 1) else: print(tel[K])" p02684,s013808264,Wrong Answer,"n,k = map(int,input().split()) a =[0]+list(map(int,input().split())) res= [1] i = 0 while True: go = a[res[-1]] if i > n+1 or go in res:break res.append(go) i += 1 for i in range(len(res)): if res[i] == go: ind = i v = res[ind:] m = len(v) k -= ind ans = v[k%m] print(ans) " p02684,s943104396,Wrong Answer,"# coding: utf-8 # Your code here! n,k=map(int,input().split()) a=list(map(int,input().split())) b=[1] i=0 while True: i=a[i] if(i in b): break b.append(i) i-=1 i=b.index(i) a=b[:i] c=b[i:] #print(a,c) if(k<=len(a)): print(a[k-1]) else: k-=len(a) k%=len(c) print(c[k])" 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)" p02684,s618626688,Wrong Answer,"N,K = list(map(int,input().split())) A = list(map(int,input().split())) route = [1] next = A[0] while(True): if next not in route: route.append(next) next = A[next-1] elif A[0] == next: break else: route = route[route.index(next):] break print( A[K % len(route)])" p02684,s173492507,Wrong Answer,"N , K = map(int,input().split()) B = {} C = {} D = {0} A = list(map(int,input().split())) place = 0 num = 0 C[0] = 0 while True: place = int(A[place]) - 1 num += 1 if place in D: Y = int(num) - int(C[place]) break elif num == K: break else: B[num] = place C[place] = num D.add(place) try: X = (K - num) % Y print(B[C[place] + X] + 1) except: print(A[place]) " p02684,s013569093,Wrong Answer,"N, K = map(int, input().split()) a = list(map(int, input().split())) chk = [0] * N start = -1 ido = [0] chk[0] = 1 index = 0 cnt = 0 while True: index = a[index] - 1 if chk[index] == 0: chk[index] += 1 cnt += 1 ido.append(index) else: start = index break if cnt >= K: print(a[ido[K]]) exit() tmp = ido.index(start) ido = ido[tmp:] K -= tmp print(ido[K % len(ido)] + 1)" p02684,s187030296,Wrong Answer,"N, K = map(int, input().split()) A = list(map(int, input().split())) roop_num = 1 city = 0 first_city = 0 while True: next_city = A[city] - 1 if next_city == first_city: break if roop_num == K: print(city + 1) exit() city = next_city roop_num += 1 rem_num = K % roop_num city = 0 num = 0 while True: next_city = A[city] - 1 if num == rem_num: print(city + 1) exit() city = next_city num += 1 " p02684,s689580573,Wrong Answer,"#N=int(input()) N,K = map(int,input().split()) #N=int(input()) A = list(map(int,input().split())) #S=str(input()) now=1 root=[1] for i in range(N): now=A[now-1] if now in root: index=root.index(now) num=len(root[index:]) root=root[index:] break else: root.append(now) an = (K-i) - (K-i)//num * num print(root[an-1]) " p02684,s563388761,Wrong Answer,"N, K = map(int, input().split()) A = list(map(int, input().split())) ans = 0 ans_list = [] end = 0 stpos = 0 for i in range(K): ans = A[ans] - 1 ans_list.append(ans) if len(set(ans_list)) != i+1: end = i - 1 stpos = ans_list.index(ans) break if i == K: print(ans) exit() print(ans_list[stpos:end+1][(K-(stpos+1)) % (end-stpos+1)]+1) " p02684,s826892119,Wrong Answer,"#D - Teleporter N,K = map(int, input().split()) A = list(map(int, input().split())) DP = [] DP.append(A[0]) for i in range(N): DP.append(A[DP[i]-1]) print(DP[K%len(DP)-1])" p02684,s878205530,Wrong Answer,"N,K=map(int,input().split()) a=list(map(int,input().split())) cycle=[0] s_cyc=set() s_cyc.add(0) flag=0 id=0 for i in range(N): a[i]-=1 while N>0: if a[id] in s_cyc: node=cycle.index(a[id]) break else: cycle.append(a[id]) s_cyc.add(a[id]) id=a[id] N-=1 if N==0: print(a[id]+1) else: K-=node cycle=cycle[node::] q=K%len(cycle) print(cycle[q]+1) " p02684,s663880732,Wrong Answer,"import numpy as np import math N, K=map(int,input().split()) A2 = np.zeros(N) A = list(map(int,input().split())) A = list(map(lambda x: x -1 , A)) current_town = 0 i=0 while i= len(visited): k = k % (returned[1] - returned[0]) if k < returned[0]: k = k + returned[0] print(list(visited.keys())[k] + 1) " p02684,s013765017,Wrong Answer,"n,k=map(int,input().split()) A=list(map(int,input().split())) A=[0]+A B=[] C=[0]+[-1]*n now_city=1 seen=set() #【ループ回数】200000 for i in range(1,len(A)): print(""Baah"") " p02684,s236163609,Wrong Answer,"from collections import deque, defaultdict d = deque() di = defaultdict(int) N, K = map(int, input().split()) A = list(map(int, input().split())) d.append(0) for i in range(N * 2): p = d.pop() d.append(p) d.append(A[p] - 1) P = [] k = 0 n = 0 for i, v in enumerate(d): if (v in P): k = i n = v break P.append(v) di[v] = i le = k - di[n] amari = K % le print(d[le + amari] + 1) " p02684,s388490878,Wrong Answer,"n, k = map(int, input().split()) a = list(map(int, input().split())) b = 1 c = [-1]*n c[0] = 0 for i in range(n): b = a[b-1] if c[b-1] == -1: c[b-1] = i+1 else: d = i+1-c[b-1] break; b = 1 for i in range(c[b-1]+k%d): b = a[b-1] print(b)" 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)" 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]) " p02684,s214406849,Wrong Answer,"N, K = map(int, input().split()) As = list(map(int, input().split())) cycle = [] pos = 1 for i in range(N): cycle.append(pos) pos = As[pos-1] if pos == 1: break #print(cycle) mod = K % len(cycle) print(cycle[mod]) " p02684,s710302903,Wrong Answer,"N,K=map(int, input().split()) A=list(map(int, input().split())) sumi=[0]*N root=[0]*N root[0]=1 k=0 idx=0 for i in range(1,N+1): chk=root[i-1]-1 nxt=A[chk] if sumi[chk]==0: root[i]=nxt sumi[chk]=1 elif sumi[chk]!=0: k=i-1 break idx1=root.index(nxt) ans=root[idx1:k+1] print(ans[(K-(idx1-1))%len(ans)-1])" p02684,s407967214,Wrong Answer,"def main(): n, k = map(int, input().split()) a = tuple(map(int, input().split())) l = [] t = 1 for i in range(n): l.append(t) if a[t - 1] in l: k -= (i+1) break t = a[t - 1] i = l.index(a[t - 1]) k = k % (len(l) - i) print(l[k + i]) if __name__ == '__main__': main()" p02684,s227878765,Wrong Answer,"n, k = map(int, input().split()) l = [int(i) for i in input().split()] check = [0]*n count = 0 now = 1 mod = 0 start = 0 loop = [] while True: count += 1 if check[now-1] == 0: check[now-1] += count loop.append(now) now = l[now-1] else: mod = count-check[now-1] loop = loop[check[now-1]-1:] start = check[now-1]-1 break x = (k-start)%mod print(loop[x])" p02684,s490736688,Wrong Answer,"N, K = list(map(int, input().split())) A = list(map(int, input().split())) def func1(lst, value): return [i for i, x in enumerate(lst) if x == value] temp=1 trace=[1] circle=[] for i in range(K): temp=A[temp-1] ans=func1(trace,temp) if len(ans)==1: circle.append(i-ans[0]+1) #print(circle) break trace.append(temp) #print(""temp"",temp) #print((K-i)%len(circle)-1) if len(circle)!=0: amari=(K-i)%circle[0] for j in range(i+amari): temp=A[temp-1] print(temp)" p02684,s648093863,Wrong Answer,"N, K = map(int, input().split()) where_go = list(map(int, input().split())) now = 0 now_list = [] start = 0 roop = 0 count = 0 while now not in now_list: now_list.append(now) now = where_go[now] - 1 start = now_list.index(now) roop = len(now_list) - start while count < (K - start) % roop: now = where_go[now] - 1 count += 1 print(now+1) " p02684,s018279332,Wrong Answer,"N,K= list(map(int , input().split())) A = list(map(int , input().split())) li = [] k = 0 s = A[0]-1 li.append(A[0]) while k == 0: k = li.count(A[s]) li.append(A[s]) s = A[s]-1 if k == 1: n = A[s] q = li.index(n) m = len(li) - q p = (K - q)%m ss = 0 for i in range (p+ q-1): ss = A[ss]-1 print(A[ss]) " p02684,s871441124,Wrong Answer,"N,K=map(int,input().split()) P=list(map(int,input().split())) A={k+1:P[k] for k in range(N)} U=list() x=1 k=0 while (x not in U) and (k>i)&1: now = doubleA[i+1][now-1] print(now) " p02684,s829993922,Wrong Answer,"N,K = [int(i) for i in input().split()] A = [int(i)-1 for i in input().split()] place = (0,) now = 0 length = 1 while True: length += 1 now = A[now] place = place + (now,) place_set = set(place) if length != len(place_set): break t = place.index(place[length-1]) if K <= t: print(place[K-1]+1) exit() K -= t K %= (length-t-1) print(place[K+t]+1)" p02684,s360879436,Wrong Answer,"n, k = map(int, input().split()) a = list(map(int, input().split())) b = a[0]-1 c = 1 while c < n: b = a[b]-1 c = c+1 if b == 0: break g = k%c d = a[0]-1 i = 1 while i= 0: i = A[i] - 1 K -= 1 print(A[i]) " p02684,s765958411,Wrong Answer,"n,k = map(int,input().split()) a_list = list(map(int,input().split())) visited = [] i,j = 0,1 while i 0: print(k) cycle = way[d[pos]:step] x = k % len(cycle) print(cycle[x]) else: print(a[pos]) main()" p02684,s258585937,Wrong Answer,"N,K = map(int, input().split()) A = list(map(int, input().split())) limit = K now = 1 log = [] count = 1 while limit > 0 and now not in log: if 1 not in log: log.append(1) #print(""通過1"",now,limit,log) now = A[now - 1] log.append(now) limit -= 1 count += 1 if limit > 0: #print(""通過2"",now,limit,log) log2 = log[log.index(now):] limit = limit % len(log2) while limit > 0: #print(""通過3"",now) now = A[now - 1] limit -= 1 now = A[now - 1] print(now) " p02684,s649005030,Wrong Answer,"n, k = map(int, input().split()) a_list = list(map(int, input().split())) route = [] roop = [] pos = 1 while k > 0: pos = a_list[pos-1] if pos in route: if len(roop) > 0 and pos == roop[0]: k -= k % max(1, (k * (k // len(roop)))) roop.append(pos) else: roop = [] route.append(pos) k -= 1 print(pos) " p02684,s484220891,Wrong Answer,"N, K = map(int, input().split()) A = list(map(int, input().split())) now = 1 count = 0 now = A[now-1] route = [now] count += 1 def check(now, route, count): now = A[now-1] if now in route: return 0 else: route.append(now) count += 1 check(now, route, count) print(route[(K % count)-1])" p02684,s050986173,Wrong Answer,"n,k = list(map(int, input().split())) a = list(map(int, input().split())) a.insert(0,0) start = 1 now = start c = 0 flag = [-1]*(n+1) while c <= k and flag[now] == -1: #print(now) flag[now] = c c+= 1 now = a[now] #print(c, now) if c == k: print(now) else: k-=c cc = c-flag[now] nokori = k % cc for i in range(nokori): now = a[now] print(now) " p02684,s864007902,Wrong Answer,"from sys import stdin input = stdin.readline N, K = map(int, input().split()) A = list(map(int, input().split())) graph = [] time = [-1] * N for i in range(N): graph.append([i, A[i]]) now = 0 nex = 0 time[0] = 0 loop = 0 while True: now = nex nex = A[now] - 1 if time[nex] == -1: time[nex] = time[now] + 1 else: loop = nex break if K > max(time): K %= (max(time) - time[loop] + 1) for i in range(N): if time[i] == K: print(i + 1) " p02684,s342638209,Wrong Answer,"N, K = map(int,input().split()) A = list(map(int, input().split())) for i in range(N) : if A[i] == 1 : break i += 1 print(A[K%i]) " p02684,s057123391,Wrong Answer,"n,k=map(int,input().split()) a=[0]+list(map(int,input().split())) pointer=1 visited=[1] for i in range(n): if a[pointer] in visited: loopstart=visited.index(a[pointer]) looplength=len(visited)-visited.index(a[pointer]) break else: visited.append(a[pointer]) pointer = a[pointer] print(visited[loopstart+(k-loopstart)%looplength])" p02684,s749824012,Wrong Answer,"n, k = map(int, input().split()) list_A = list(map(int, input().split())) list_MAP = [] set_MAP = set() x = 1 while True: list_MAP.append(x) set_MAP.add(x) x = list_A[x-1] if x in set_MAP: break q = len(list_MAP) - list_MAP.index(x) p = k - list_MAP.index(x) if p < 0: print(list_MAP[k-1]) else: list_MAP = list_MAP[list_MAP.index(x):] print(list_MAP[p % q])" p02684,s893559720,Wrong Answer,"import sys input = sys.stdin.readline def main(): N,M=map(int,input().split()) L=list(map(int,input().split())) i=1 R=list() for j in range(N+1): if L[i-1] in R: c=R.index(L[i-1]) t=len(R)-c m=R[c:] break R.append(L[i-1]) i=L[i-1] l=(M-c-1)%t print(m[l]) if __name__ == '__main__': main()" p02684,s207583618,Wrong Answer,"n, m = map(int, input().split()) a = list(map(int, input().split())) a = [a[i]-1 for i in range(n)] x = a[a[0]] l = [0, a[0]] cnt = 0 while x not in l: l.append(x) x = a[x] cnt = len(l)-l.index(x) loop = l[l.index(x):l.index(x)+cnt] print(loop[(m-l.index(x)+1)%cnt-1]+1)" p02684,s776525506,Wrong Answer,"N,K=map(int,input().split()) A=list(map(int,input().split())) done=[0 for _ in range(N)] done[0]=1 W=[0] init=0 loop=N for i in range(N): if done[A[i]-1]==2: init=W.index(A[i]-1) loop=i-init break elif W[-1]==A[W[-1]]-1: init=i loop=1 break done[W[-1]]+=1 W.append(A[W[-1]]-1) if K>=init: print(W[(K-init)%loop+init]+1) else: print(W[K]+1) " p02684,s238044094,Wrong Answer,"N,K = map(int,input().split()) A = list(map(int,input().split())) if A[0] == 1: print(1) exit() B = [A[0]] num = 0 C = 0 for i in range(N): num = A[num-1] B.append(num) if num in B: c = num break C = [c] num = c for i in range(N): num = A[num-1] if num == c: break C.append(num) if K <= len(B): print(B[K-1]) exit() K -= len(B) print(C[K%len(C)-1])" p02684,s271753550,Wrong Answer,"import sys input = sys.stdin.readline N, K = map(int, input().split()) A = list(map(lambda x: int(x)-1, input().split())) cities = [0] c = 0 used = [False] * N used[0] = True while not used[A[c]]: used[A[c]] = True cities.append(A[c]) c = A[c] x = cities.index(A[c]) if K < x: print(cities[K]) else: K -= x K %= len(cities) - x print(cities[x + K] + 1)" p02684,s120443475,Wrong Answer,"n, k = map(int, input().split()) a = list(map(int, input().split())) l = [0]*n s = set() x = 0 for i in range(n): machi = a[x] if machi in s: hajime = l.index(machi) repeat = l[hajime:i] break x = machi-1 l[i] = machi s.add(machi) else: amari = k%n print(l[amari-1]) exit() amari = (k-hajime)%len(repeat) if hajime + amari == 0: print(repeat[-1]) else: print(l[hajime+amari-1]) " p02684,s983006439,Wrong Answer,"n,k = map(int,input().split()) A = list(map(int,input().split())) sub = [0]*n city = 0 all = [] roop = [] while sub[city] != 2: if sub[city] == 0: all.append(city) else: roop.append(city) sub[city] += 1 city = A[city] -1 if len(roop)<=k: print(roop[(k-(len(all)-len(roop)))%len(roop)]+1) else: print(all[k]+1) " p02684,s654552761,Wrong Answer,"import sys lines = sys.stdin.readlines() (n, k) = map(int, lines[0].strip().split("" "")) nums = list(map(int, lines[1].strip().split("" ""))) pt = 0 seen = set() while pt not in seen: seen.add(pt) pt = nums[pt] - 1 k -= 1 cyc = 1 entry = pt pt = nums[pt]-1 while pt != entry: cyc += 1 pt = nums[pt] -1 k %= cyc for i in range(k): pt = nums[pt] -1 print(pt+1) " p02684,s902430918,Wrong Answer,"import sys input = sys.stdin.readline n, k = (int(x) for x in input().split()) seq = [int(x) for x in input().split()] visited = [[False,0] for _ in xrange(n)] t = 1 cnt = 0 while not visited[t-1][0]: visited[t-1][0] = True visited[t-1][1] = cnt t = seq[t-1] cnt += 1 cycle_len = cnt - visited[t-1][1] for _ in xrange((k-visited[t-1][1]) % cycle_len): t = seq[t-1] print(t) " p02684,s729735141,Wrong Answer,"n, k = map(int, input().split()) A = list(map(int, input().split())) now = 1 for i in range(len(bin(k))-2): if (k>>i)&1: now = A[now-1] A = [A[a] for a in range(n)] print(now)" p02684,s876317859,Wrong Answer,"N, K = map(int, input().split()) A = list(map(int, input().split())) A = [0] + A L = [[] for _ in range(N)] L[0] = 1 prev = 1 count = 1 for i in range(1, N): now = A[prev] if now == 1: break else: L[i] = now prev = now count += 1 # print(L) L = L[:count] #print(L) print(L[K%count])" p02684,s538491634,Wrong Answer,"n, k = map(int, input().split()) a = list(map(int, input().split())) a = [item - 1 for item in a] passed = [-1] * n current_town = 0 passed[0] = 0 for i in range(1, 1000000): current_town = a[current_town] if passed[current_town] > -1: start = passed[current_town] period = i - start break else: passed[current_town] = i m = (k - start) % period for i in range(m): current_town = a[current_town] print(current_town + 1) " p02684,s427812383,Wrong Answer,"n, k = map(int, input().split()) targets = list(map(int, input().split())) seen = dict() goal = dict() seen[1] = 0 goal[0] = 1 prev = targets[0] startFlag = False for i in range(1, k): seen[prev] = i goal[i] = prev current = targets[prev - 1] if current in seen: before = seen[current] finalGoal = k % (i + 1 - before) print(goal[finalGoal]) exit() prev = current print(goal[k-1])" p02684,s896247129,Wrong Answer,"N, K = map(int, input().split()) A = [-1] + list(map(int, input().split())) visited = {} for i in range(1, N+1): visited[i] = False i2p = {} p2i = {} i = 0 cur = 1 while True: i2p[i] = cur p2i[cur] = i visited[cur] = True if visited[A[cur]]: break cur = A[cur] i += 1 start_loop = p2i[A[cur]] end_loop = len(i2p) num_loop = end_loop - start_loop if K < num_loop: print(i2p[K]) else: print(i2p[(K-start_loop)%num_loop+start_loop]) " p02684,s673589930,Wrong Answer,"n, k = [int(x) for x in input().split()] a = [int(x)-1 for x in input().split()] visited = [0] x = 0 T = -1 i = 0 while T < 0: x = a[x] i += 1 if x in visited: for j in range(i): if visited[j] == x: first = j break T = i - j break else: visited.append(x) mod = (k-first) % T print(visited[first+mod]+1)" p02684,s882835953,Wrong Answer,"n,k = map(int,input().split()) A = list(map(int,input().split())) B = [] b = 1 ans = 1 while ans: a = b b = A[a-1] B.append(b) if len(B) == n: ans = 0 aaa = k%n print(B[aaa-1]) " p02684,s040950764,Wrong Answer,"N,K = map(int,input().split()) A = list(map(int,input().split())) B =[1] i = 0 Flag = True a = A[0] i +=1 #1回 B.append(a) while i < K and Flag == True: a = A[a-1] if a in B: Flag = False B.append(a) i += 1 t = B.index(a) l = i-t if Flag == True: print(a) else: s = (K-t)%l a =A[t+s] print(a)" p02684,s369635192,Wrong Answer,"n,k=map(int,input().split()) a=input().split() go=[] fin=0 now=1 loop=0 while len(go)==len(set(go)): go.append(a[now-1]) now=int(a[now-1]) fin=go.index(go[len(go)-1]) del(go[len(go)-1]) loop=len(go)-fin k-=fin k-=1 print(str(int(go[k%loop+fin])))" p02684,s838694450,Wrong Answer,"N, K = map(int, input().split()) A = list(map(int, input().split())) takahashi = [1, ] for i in range(K): to = A[takahashi[i] - 1] if to in takahashi: l = (K - i)%(i - takahashi.index(to) + 1) for j in range(l): takahashi.append(to) break takahashi.append(to) print(takahashi[-1])" p02684,s216079659,Wrong Answer,"from collections import Counter N, K = map(int,input().split()) tele = list(map(int, input().split())) #A1から順にワープした時の経由順 next_,goal = 1,[] while goal.count(next_)<1: goal.append(next_) next_ = tele[next_-1] #print(goal.count(next_)) i,loop = -1,[] while goal[i]!=next_: loop.insert(0,goal[i]) #print(goal[i]) i-=1 loop.insert(0,next_) amari = len(goal)-len(loop) print(loop[(K-amari)%len(loop)])" p02684,s360601445,Wrong Answer,"N,K=map(int, input().split()) A = list(map(int, input().split())) where = [0 for k in range(N)] where[0]=1 loop=0 for k in range(N): where[k+1] = A[where[k]-1] if where[k+1] in where[0:k]: li = where[0:k] end = k+1 start = li.index(where[k+1]) loop = end -start break loopbefore = K -start loopafter = loopbefore%loop where2 = [where[end]] for k in range(loopafter): where2.append(A[where2[k]-1]) print(where2[-1]) " p02684,s860652522,Wrong Answer,"n, k = map(int, input().split()) an = list(map(int, input().split())) bn = [-1]*(n+1) now=an[0] bn[1]=0 for i in range(1, k+1): now = an[now-1] if bn[now] >0: rp =i-bn[now] p= k%rp for j in range(p+1): now = an[now-1] print(now) exit(0) bn[now]=i print(now)" p02684,s024573432,Wrong Answer,"n,k = map(int,input().split()) A = list(map(int,input().split())) visted = [1] bre = 0 for i in range(k): a = A[visted[-1]-1] if a not in visted: visted.append(a) else: visted.append(a) bre = 1 break loop_start = visted.index(visted[-1])+1 if bre == 0: print(visted[k-1]) else: x = len(visted[:loop_start]) visted = visted[loop_start:] print(visted[(k-x)%len(visted)]) " p02684,s190895004,Wrong Answer,"n, k = map(int, input().split()) a = list(map(lambda x: int(x) - 1, input().split())) ls = [-1] * n now = 0 cnt = 0 path = [] while 1: if ls[now] != -1: b = ls[now] break ls[now] = cnt path.append(now) now = a[now] cnt += 1 loop = path[b:] if k <= b: print(path[k]) else: print(loop[(k - b) % len(loop)] + 1) " p02684,s671796449,Wrong Answer,"N, K = map(int, input().split()) a = [int(i) for i in input().split()] pos = a[0] p = [] while pos not in p: p.append(pos) pos = a[pos-1] idx = p.index(pos) k = K - idx p = p[idx:] print(p[k%len(p) - 1])" p02684,s036100561,Wrong Answer,"N, K = map(int, input().split()) A = list(map(int,input().split())) temp = [[0] * 2 for i in range(len(A))] index = 0 previous = 0 count = 0 while True: temp[index][0] += 1 if temp[index][0] == 2: previous = temp[index][1] count = count - temp[index][1] break temp[index][1] = count count += 1 index = A[index] - 1 places = [] place_index = index for i in range(count): places.append(place_index + 1) place_index = A[place_index] - 1 K -= previous print(places[K % count])" p02684,s414476487,Wrong Answer,"N,K=map(int,input().split()) A=list(map(int,input().split())) Appeared=[] flag=0 k=0 location=0 T=0 T_List=[] while flag==0: k+=1 Appeared.append(location) location=A[location]-1 if location in Appeared: flag=1 T=k-Appeared.index(location) T_List=Appeared[k-T:k] Destination=(K-(k-T-1))%T print(T_List[Destination-1]+1) " p02684,s789390832,Wrong Answer,"N,K = map(int, input().split()) data = list(map(int, input().split())) town = [0] * N temp = [] once = [] p = 1 #pointer for i in range(N): temp.append(p-1) if town[p-1] == 1: break else: town[p-1] = 1 p = data[p-1] #print(town) #print(""pointer = {}"".format(p)) #print(temp) while True: if temp[0] == temp[-1]: break else: once.append(temp[0]) temp.pop(0) temp.pop(-1) #print(once) #print(temp) K = K - len(once) K = K % len(temp) print(temp[K]+1)" p02684,s610134459,Wrong Answer,"N,K = map(int, input().split()) A = list(map(int, input().split())) p = 1 p_hist = [] while p not in p_hist: p_hist.append(p) p = A[p-1] end_loop = p_hist[-1]" p02684,s685005682,Wrong Answer,"n, k = map(int, input().split()) A = list(map(int, input().split())) A = [x-1 for x in A] town = 0 cnt = 0 memo = [] for i in range(n): town = A[town] memo.append(town) if town == 0: break loop = len(memo) print(memo[k%loop-1]+1)" p02684,s441644592,Wrong Answer,"N, K = map(int, input().split()) A = list(map(int, input().split())) A = [i-1 for i in A] check = [0]*N i = 0 c = 0 check = [] Flag = False while c<=K: if i in check: flag = True break else: check.append(i) i = A[i] X = check[check.index(i):] print(1+X[(K-c)%len(X)] if flag==True else print(i+1))" p02684,s276196547,Wrong Answer,"N, K = map(int, input().split()) A = list(map(int, input().split())) teleport = dict() for i, a in enumerate(A): teleport[i+1] = a state = 1 connect = [1] looplen= 10**18 for n in range(N): state = teleport[state] if state in connect: loop_init = connect.index(state) looplen = n-connect.index(state)+1 break else: connect.append(state) index = (K-loop_init)%looplen end = connect[loop_init+index] print(end)" p02684,s169702722,Wrong Answer,"n, k = map(int, input().split()) teleporter = list(map(lambda x: int(x) - 1, input().split())) destinations = {0: 0} curr_city = 0 cycle_start = -1 while True: next_city = teleporter[curr_city] if next_city in destinations: cycle_start = destinations[next_city] break destinations[next_city] = len(destinations) curr_city = next_city if cycle_start == -1: print(curr_city + 1) else: for i in range((k - cycle_start) % (len(destinations) - cycle_start) + 1): curr_city = teleporter[curr_city] print(curr_city + 1) " p02684,s962988381,Wrong Answer,"def resolve(): N, K = list(map(int, input().split())) A = list(map(lambda x: int(x)-1, input().split())) routes = [0] current = 0 visited = [False for _ in range(N)] visited[0] = True while visited[A[current]] is False: current = A[current] routes.append(current) visited[current] = True leftlen = routes.index(A[current]) repeat = routes[leftlen:] # print(leftlen) # print(routes) # print(repeat) print(repeat[(K-leftlen)%len(repeat)]+1 if K >= len(routes) else routes[K]) if '__main__' == __name__: resolve()" p02684,s671052674,Wrong Answer,"def calc(i, k): ans_list = [0] j = i count = 1 i = a[i] ans_list.append(i) while (i != j) & (count < n): i = a[i] count += 1 ans_list.append(i) return count, ans_list n, k = map(int, input().split()) a = [int(i) - 1 for i in input().split()] count, ans_list = calc(0, n) print(ans_list[k % count] + 1)" p02684,s711876245,Wrong Answer,"N, K = list(map(int, input().split())) A = list(map(int, input().split())) l = [A[0]] a = A[0] - 1 for _ in range(0, N): if A[a] not in l: l.append(A[a]) a = A[a] - 1 else: break a = A[a] n = len(l) print(l) b = 0 for i in range(n): if l[i] == a: del l[0:i] b = i - 1 break N = len(A) S = (K - b) % N ans = A[S - 1] print(ans)" p02684,s413008973,Wrong Answer,"N , K = list(map(int,input().split())) A = list(map(int,input().split())) A.insert(0,0) local = 1 tmp = [] tmp.append(local) for k in range(N): local = A[local] if local in tmp: result = len(tmp) - tmp.index(local) break else: tmp.append(local) for k in range((K-tmp.index(local)) % result): local = A[local] print(local)" p02684,s320987958,Wrong Answer,"import sys N, K = list(map(int, input().split())) A = [0] + list(map(int, input().split())) visited = [False] * (N+1) s = 1 while not visited[s]: visited[s] = True s = A[s] a = 1 while a != s: K -= 1 if K == 0: print(a) sys.exit() a = A[a] visited = [False] * (N+1) length = 0 while not visited[s]: visited[s] = True s = A[s] length += 1 k = K % length while k: s = A[s] k -= 1 print(s)" p02684,s812733725,Wrong Answer,"n, k = map(int, input().split()) A = [0] + list(map(int, input().split())) cnt = 0 cur = 1 memo = [] kumi = set([]) for i in range(2 * (10 ** 5) + 5): cur = A[cur] cnt += 1 memo.append(cur) if cur in kumi: break kumi.add(cur) k -= len(memo) for j in range(cnt): if memo[j] == cur: start = j break loop = memo[start:] loop_num = i - start print(loop[k % loop_num]) " p02684,s016298390,Wrong Answer,"from collections import defaultdict import sys sys.setrecursionlimit(10**6) n , k = map(int , input().split()) arr = list(map(int , input().split())) dic = defaultdict(int) for i in range(1,n+1): dic[i] = arr[i-1] cycle = [] def dfs(node): if node in cycle: return node else: cycle.append(node) k = dfs(dic[node]) return k cyele = dfs(1) ind = 0 offset = 0 for i in range(len(cycle)): if cycle[i] == cyele: ind = i break offset+=1 #rem = k - offset csize = len(cycle[ind:]) rem=k%csize count = 0 curr = 1 while count != rem: curr = dic[curr] count+=1 print(curr) " p02684,s671988076,Wrong Answer,"n,k = map(int,input().split()) li = list(map(int,input().split())) count = 2 li2 = [1] li2.append(li[0]) for i in range(n): li2.append(li[li2[i+1]-1]) count += 1 if len(set(li2)) != count: break if count == n + 2: print(li2[-2]) else: s = li2.index(li2[-1]) del li2[0:s] del li2[-1] print(li2[(k-s) % len(li2)])" p02684,s298819902,Wrong Answer,"n, k = map(int, input().split()) a_list = list(map(int, input().split())) loop = [] now = 1 while not now in loop: loop.append(now) now = a_list[now - 1] loop_start_index = loop.index(now) print(loop[loop_start_index + (k - loop_start_index) % (len(loop) - loop_start_index)]) " p02684,s393294262,Wrong Answer," N, K = list(map(int, input().split())) A = list(map(int, input().split())) cur = 0 i = 0 loop = 0 list = [] while (i <= K): i = i+1 cur = A[cur-1] if(loop == 0): if (cur in list): # loop = len(list) # print(""loop"", loop) loop = len(list) - list.index(cur) if (K > 100): K= K - ((K // loop))*loop list.append(cur) # print(cur) print(cur) " p02684,s156279215,Wrong Answer,"n,k =map(int,input().split()) a = list(map(int,input().split())) l = 0 count = 0 for i in range(k) : l = a[l]-1 count = +1 if l == 0 : x = k%count for i in range(x) : l = a[l]-1 print(l+1) exit() print(l+1) " p02684,s457682955,Wrong Answer,"n, k = map(int, input().split()) A = list(map(int, input().split())) A = [x-1 for x in A] town = 0 cnt = 0 memo = [] visited = [False] * n visited[0] = -1 start = 0 for i in range(n*2): town = A[town] memo.append(town) if visited[town] != False: start_cnt = i + 1 loop = i - visited[town] break else: visited[town] = i for i in range((k-start_cnt)%loop): town = A[town] print(town+1)" p02684,s265681248,Wrong Answer,"n,K=list(map(int,input().split())) a = list(map(int,input().split())) b = [] c = [0]*len(a) k=0 for i in range(n): b.append(a[k]) k=a[k]-1 if c[a[k]-1]==0: c[a[k]-1]=1 else: b.pop(-1) break d=len(b) e=K%d print(b[e-1])" p02684,s189141201,Wrong Answer,"n, k = map(int, input().split()) a = list(map(int, input().split())) city = [i for i in range(n)] egde = [-1] * n tmp = a[0] for i in range(n): tmp = a[tmp - 1] egde[tmp - 1] = i tmp = a[0] for i in range(k % (n - egde.count(-1)) - 1): tmp = a[tmp - 1] print(tmp)" p02684,s031113588,Wrong Answer,"n, k = map(int, input().split()) list_A = list(map(int, input().split())) list_MAP = [] set_MAP = set() x = 1 while True: list_MAP.append(x) set_MAP.add(x) x = list_A[x-1] if x in list_MAP: break q = len(list_MAP) - list_MAP.index(x) p = k - list_MAP.index(x) if p < 0: print(list_MAP[k-1]) else: list_MAP = list_MAP[list_MAP.index(x):] print(list_MAP[p % q])" p02684,s723622082,Wrong Answer,"n,k = map(int,input().split()) A = list(map(int,input().split())) sub = [0]*n ans = 1 cir = 0 a = 0 for i in range(n): sub[i] = ans if A[ans-1] in sub: a = sub.index(A[ans-1]) cir = i+1 - a break else: ans = A[ans-1] if sub[-1] != 0: print(sub[k%n]) exit(0) print(sub[a + (k - a) % cir]) " p02684,s428246842,Wrong Answer,"n,k=map(int,input().split()) a=list(map(int,input().split())) s=1 ans=0 v={} for j in range(len(a)): if(s-1 in v): break else: v.update({s-1:ans}) s=a[s-1] ans+=1 lens=ans-v[s-1] k=(k-ans)%lens for j in range(k): s=a[s-1] print(s) " p02684,s775427126,Wrong Answer,"N, M = map(int, input().split()) P = [i -1 for i in map(int,input().split())] ss = set([]) point = 0 for i in range(N): if point in ss: break ss.add(point) point = P[point] S = [0] points = 0 for i in range(len(ss)-1): points = P[points] S.append(points) loop = S[S.index(points):] ll = len(S) l = len(loop) if ll > M: print(S[M]+1) elif ll == M: print(points+1) else: print(loop[(M-ll)%l]+1) " p02684,s615851375,Wrong Answer,"N,K = map(int,input().split()) A = list(map(int,input().split())) if A[0] == 1: print(1) exit() B = [A[0]] num = 0 C = 0 for i in range(N): num = A[num-1] if num in B: c = num break B.append(num) C = [c] num = c for i in range(N): num = A[num-1] if num == c: break C.append(num) K -= len(B) print(C[K%len(C)-1])" p02684,s467279439,Wrong Answer,"N,K = map(int,input().split()) A = list(map(int,input().split())) route = [1] i = 0 while True: next = A[i] if next not in route: route.append(next) else: cycle = route[route.index(next):] route = route[:route.index(next)] break i = next-1 K -= len(route) print(cycle[K%len(cycle)])" p02684,s546883978,Wrong Answer,"from collections import Counter N, K = map(int,input().split()) tele = list(map(int, input().split())) #A1から順にワープした時の経由順 now = 0 goal,loop,visit = [],[],[0]*N while visit[now]!=2: if visit[now]==0: goal.append(now) else: loop.append(now) visit[now] += 1 now = tele[now]-1 amari = len(goal)-len(loop) print(loop[(K-amari)%len(loop)]+1)" p02684,s325170451,Wrong Answer,"n,k=map(int,input().split()) a=list(map(int,input().split())) b=[0]*n c=[0]*n total=0 b[0]+=1 next=a[0] while True: total+=1 if b[next-1]==0: b[next-1]+=1 c[next-1]+=total next=a[next-1] else: total1=total k-=(c[next-1]) total-=c[next-1] start=next-1 break if total1<=k: start=0 for i in range(k): start=a[start]-1 print(start+1) else: k%=total for i in range(k): start=a[start]-1 print(start+1)" p02684,s231877637,Wrong Answer,"N,K = map(int,input().split()) A = list(map(int,input().strip().split())) B=1 list=[] for i in range(N): if B in list: num2=list.index(B) break else: list.append(B) B=A[B-1] del list[:num2] num=(K-num2)%len(list) print(list[num]) " p02684,s106626811,Wrong Answer,"n, k = map(int, input().split()) A = [0] + list(map(int, input().split())) B = [False for _ in range(n+1)] B[1] = True C = [1] for i in range(1,n): C.append(A[C[-1]]) #print(C) B[C[-1]] = True if B[A[C[-1]]] == True: C.append(A[C[-1]]) break num = i + 1 s = C.index(C[-1]) N = num - s if k < N: print(C[k]) else: print(C[k%N]) " p02684,s270104728,Wrong Answer,"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: k=(k-begin+1)%(end-begin)+begin-1 loc=1 for _ in range(k): loc=a[loc-1] print(loc)" p02684,s439764525,Wrong Answer,"n,k = map(int,input().split()) a = list(map(int,input().split())) b = [0 for i in range(n)] b[0] += 1 i = 0 ans = 0 c = a[0] while True: b[c-1] += 1 i += 1 if b[c-1] > 1: ans = c break c = a[c-1] c = a[0] j = 0 while True: j+=1 if c == ans: break c = a[c-1] if c == 1: j = 0 k -= j k %= (i-j) for i in range(k): c = a[c-1] print(c)" p02684,s784579777,Wrong Answer,"N, K = map(int, input().split()) A = list(map(int, input().split())) teleport = [-1] * (N+1) teleport[0] = 1 visited = [(False, -1)] * (N+1) visited[1] = (True, 0) for i in range(1, N+1): next_town = A[teleport[i-1]-1] if visited[next_town][0]: before = visited[next_town][1] break teleport[i] = next_town visited[next_town] = (True, i) period = i - before offset = (K - before) % period print(teleport[before + offset]) " p02684,s969845652,Wrong Answer,"from collections import deque N, K = map(int, input().split()) memo = [-1]*(N+1) junban = deque() A = [0]+list(map(int, input().split())) i = 0 x = 1 while memo[x] < 0: junban.append(x) memo[x] = i x = A[x] i += 1 T = i-memo[x] if K < T: print(junban[K]) else: print(list(junban)[memo[x]:][(K-memo[x])%T]) " p02684,s348166166,Wrong Answer,"n,k,*a=map(int,open(0).read().split()) now=1 if k<=n: for i in range(k): now=a[now-1] print(now) exit() # 絶対ループする visited=[-1]*n for i in range(4*10**5): now=a[now-1] if visited[now-1]==-1: visited[now-1]=i else: c,d=visited[now-1],i break k=(k-c)%(d-c)+c for i in range(k+c): now=a[now-1] print(now)" p02684,s582841987,Wrong Answer,"n,k = map(int,input().split()) alist = list(map(int,input().split())) town = 1 numberlist = [] count = 0 count2 = 0 for i in range(k): town = alist[town-1] if town in numberlist: break else: numberlist.append(town) count += 1 for i in numberlist: if i == town: break else: numberlist.remove(i) count2 += 1 k = k - count2 x = k % len(numberlist) print(numberlist[x-1])" p02684,s373942516,Wrong Answer,"import sys input=lambda: sys.stdin.readline().rstrip() n,k=map(int,input().split()) A=[int(i) for i in input().split()] B=[0] S=set() S.add(0) cur=A[0]-1 while True: if cur in S: break else: S.add(cur) B.append(cur) cur=A[cur]-1 d=len(B) ind=B.index(cur) print(B[(k-ind)%(d-ind)+ind]+1) " p02684,s840663588,Wrong Answer,"n, k=map(int,input().split()) a=list(map(int,input().split())) now_in=0 count=0 for i in range(n): now_in=a[now_in]-1 count+=1 if now_in==0: break k = k%count for i in range(k): now_in=a[now_in]-1 now_in +=1 print(now_in)" p02684,s999441992,Wrong Answer,"# coding: utf-8 # Your code here! n,k=map(int,input().split()) a=list(map(int,input().split())) b=[1] i=0 for _ in range(n): i=a[i] if(i in b): break b.append(i) i-=1 i=b.index(i) a=b[:i] c=b[i:] #print(a,c) if(k<=len(a)): print(a[k-1]) else: k-=len(a) k%=len(c) print(c[k])" p02684,s367559085,Wrong Answer,"n,k=map(int,input().split()) a_list=list(map(int,input().split())) flag=[0]*n place=[0]*n p=0 for i in range(len(a_list)+1): if flag[p]>0: rep=i replis=place[flag[p]-1:i] st=p+1 break else: place[i]=p+1 flag[p]=i+1 p=a_list[p]-1 if i == n+1: print(place[-1]) else: print(replis[(k-st-len(replis))%len(replis)])" p02684,s157886111,Wrong Answer,"n, k = map(int, input().split()) lst = list(map(int, (input().split()))) lst = [_ - 1 for _ in lst] visited = [0] * n flg = 1 i = 0 now = 0 while flg: if visited[now] == 0: i += 1 visited[now] = i now = lst[now] else: flg = 0 k_bk = k - (i - visited[now]) k_bk = k_bk // i lft = k - i* k_bk if lft ==0: print(now+1) else: for _ in range(lft): now = lst[now] print(now+1)" p02684,s655956824,Wrong Answer,"n, k = map(int, input().split()) a = list(map(int, input().split())) a.insert(0, 'hoge') amari = k % n tmp = 1 if k >= n: for i in range(1, n + amari + 1): tmp = a[tmp] # print(i, tmp) else: for i in range(1, k+1): if tmp != k: tmp = a[tmp] elif tmp == k: print(tmp) exit() print(tmp) " p02684,s845723989,Wrong Answer," N, K = map(int, input().split(' ')) A = list(map(int, input().split(' '))) history = [] i = 0 now = 1 next_ = 0 while True: if now in history: break else: history.append(now) next_ = A[now-1] now = next_ i+=1 loop = history.index(now) count = len(history[loop:]) K -= len(history) - count K = K - (K//count)*count print(history[loop:][K]) " p02684,s627523843,Wrong Answer,"from collections import defaultdict N, K = map(int, input().split()) A = list(map(int, input().split())) adj = defaultdict(int) for i in range(len(A)): adj[i+1] = A[i] d = 0 D = 1 slow = adj[1] fast = adj[adj[1]] #print(fast, slow) while fast != slow: D += 1 slow = adj[slow] fast = adj[adj[fast]] slow = 1 while fast != slow: D += 1 d += 1 slow = adj[slow] fast = adj[fast] r = (K - d) % (D - d) #print(slow, r) while r: slow = adj[slow] r -= 1 print(slow) " p02684,s159543352,Wrong Answer,"n, k = map(int, input().split()) a = [i-1 for i in list(map(int, input().split()))] l = [] used = [0 for _ in range(n)] c = 0 flag = True while 1: if not flag: l.append(c) if used[c] == 1 and l: break if not flag: used[c] = 1 c = a[c] flag = False p = 0 length = len(l) for i in range(length): if l[i] == l[-1]: l = l[i:-1] p = i break print(l[(k - p - 1) % len(l)] + 1) " p02684,s592407940,Wrong Answer,"n, k = map(int, input().split()) a = list(map(lambda x: int(x) - 1, input().split())) history = [] visited = set() cur = 0 for i in range(n): if cur in visited: x = history.index(cur) y = len(history) - x print(history[x+(k-x)%y] + 1) exit() visited.add(cur) history.append(cur) cur = a[cur] print(history[k-1]+1)" p02684,s997672829,Wrong Answer,"N, K = map(int, input().split()) A = list(map(int, input().split())) A = [i-1 for i in A] check = [0]*N i = 0 c = 0 check = [] visited = [0]*N flag = False while c<=K: if visited[i] == 1: flag = True break else: check.append(i) visited[i] = 1 i = A[i] c += 1 if flag==True: X = check[check.index(i):] print(1+X[(K-check.index(i))%(len(check)-check.index(i))]) else: print(i+1)" p02684,s103937959,Wrong Answer,"n,k=map(int,input().split()) l=list(map(int,input().split())) list=[l[0]] set=set() num=0 while True: if l[list[num]-1] in set: break list.append(l[list[num]-1]) set.add(l[list[num]-1]) num+=1 y=list.index(l[list[num]-1]) x=len(list)-y ans=list[y:] print(ans[(k-y)%x-1])" p02684,s202706369,Wrong Answer,"n,k = map(int,input().split()) a = list(map(int,input().split())) tt = [0] * n tt[0] = 1 ans_l = [1] i = 1 while True: i = a[i-1] if tt[i-1]: break tt[i-1] = 1 ans_l.append(i) #print(ans_l,i,tt) d = ans_l.index(i) k -= d ans = k % (len(ans_l)-d) print(ans_l[ans+d]) " p02684,s242392187,Wrong Answer,"n,k = map(int,input().split()) li = list(map(int,input().split())) lili = [1] while li[(lili[-1] - 1)] not in lili: lili.append(li[(lili[-1] - 1)]) newlist = lili[lili.index(li[lili[-1]-1]):] print(newlist[((k - len(lili)) % len(newlist))])" p02684,s598791544,Wrong Answer,"n,k=map(int,input('').split(' ')) a=input('') a=a.split(' ') for p in range(n): a[p]=int(a[p]) p=1 for j in range(k): p=a[p-1]-1 print(a[p])" p02684,s353550229,Wrong Answer,"n,k = map(int,input().split()) a = list(map(int,input().split())) l = [1] tp = a[0]-1 for i in range(n): l.append(a[tp]) tp = a[tp] -1 p = l.index(l[-1]) if len(l)>k: print(l[k]) exit() x = (k-n)%(n-p) if x==0: print(l[n-1]) else: print(l[x+p-1]) " p02684,s693288260,Wrong Answer,"N, K = map(int, input().split()) A = list(map(int, input().split())) memo = [-1] * N teleporter = A[0] memo[0] = teleporter repeat_point = -1 for i in range(1, N): memo[i] = A[teleporter-1] teleporter = A[teleporter-1] if memo[i] in memo[:i]: repeat_point = i break start_point = memo.index(memo[repeat_point]) repeat = repeat_point - start_point # print(memo, start_point, repeat_point) if K <= N: print(memo[K-1]) else: mod = K % repeat if mod == 0: mod = repeat_point print(memo[mod-1]) " p02684,s767951421,Wrong Answer,"n, k = map(int,input().split()) a = list(map(int,input().split())) s = 0 seen = [False for _ in range(n)] d = [0] cy = -1 for _ in range(n): seen[s] = True s = a[s]-1 if seen[s]: cy = s break d.append(s) if cy == -1: print(d[k-1]) exit() noncyi = d.index(cy) cyi = len(d) - noncyi if k < noncyi: print(d[k-1]) else: k -= noncyi print(d[noncyi + k%cyi]+1)" p02684,s426959338,Wrong Answer,"n,m=map(int,input().split()) l=list(map(int,input().split())) x=y=t=0 c=1 x=min(l) s=[0]*n while 1: if s[x-1]==0: s[x-1]=1 else: break y = l[x - 1] c+=1 x=y z=m%c x=min(l) while z: y = l[x-1] z-=1 x=y print(y)" p02684,s912463345,Wrong Answer,"N,K = [int(i) for i in input().split(' ')] A = [int(i) for i in input().split(' ')] where_li = [] pre = 0 for i in range(N): where_li.append(A[pre]) pre = A[pre]-1" p02684,s790136790,Wrong Answer,"N, K = map(int,input().split()) A = list(map(int,input().split())) roop = 0 port = [A[0]] for _ in range(len(A)): port.append(A[port[-1]-1]) if port.count(A[port[-2]-1]) == 2:#A in port port.pop() roop = len(port)-port.index(A[port[-1]-1]) break K = K-len(port) print(port[K % roop])" p02684,s796602591,Wrong Answer,"N, K = map(int, input().split()) A = list(map(lambda x: int(x)-1, input().split())) path = [-1] * N nex = A[0] path[0] = 0 cnt = 1 if K > N: while path[nex] == -1: path[nex] = cnt cnt += 1 nex = A[nex] mod = cnt - path[nex] n = path[nex] + (K-path[nex])%mod else: n = N ans = 0 for _ in range(n): ans = A[ans] ans += 1 print(ans)" p02684,s481876714,Wrong Answer,"N,K=map(int,input().split()) A=list(map(int, input().split())) s=1 t=0 lists=[] listt=[] for i in range(10**6): s=A[s-1] listt=lists[:] lists.append(s) t+=1 if len(set(lists))==len(set(listt)): break else: continue k=0 for i in range(1,t): if lists[t-1]==lists[t-1-i]: k=i if K<=t-1-k: print (lists[K]) else: print (lists[(K-t)%k+(t-1-k)])" p02684,s594804027,Wrong Answer,"n, k = [int(i) for i in input().split()] a = [int(j) for j in input().split()] dp = [0] * (n + 1) for i in range(1, n + 1): dp[i] = a[dp[i - 1]] - 1 b = dp[n] for j in range(n - 2, -1, -1): if dp[j] == b: period = n - j break k = k % period print(dp[k] + 1) " p02684,s413837597,Wrong Answer,"N, K = map(int, input().split()) Nlist = {} Nlist[1]=0 Vlist={} count = 1 Vlist[0]=1 for A in input().split(): A=int(A) if count==A: continue if A in Nlist: break Nlist[A] = count Vlist[count]=A count = count+1 print(Vlist[K%count]) " p02684,s897909398,Wrong Answer,"n, k = map(int,input().split()) machi = list(map(int, input().split())) current = machi[n - 1] for _ in range(k): current = machi[current - 1] print(current)" p02684,s802164441,Wrong Answer,"N, K = map(int, input().split()) A = [0] + list(map(int, input().split())) def rec(now, k): if k == 0: return now if k == 1: return A[now] log2k = len(bin(k)) - 3 for i in range(log2k): now = A[A[now]] return rec(now, k - 2 ** log2k) print(rec(1, K)) " p02684,s574781735,Wrong Answer,"N,K = map(int, input().split()) A =[0] B=list(map(int, input().split())) for m in range(N): A.append(B[m]) place=[] i=1 count=0 while i not in place: place.append(i) i=A[i] count+=1 loop=[i] start=i j=A[i] count+=1 while j!=start: loop.append(j) j=A[j] count+=1 num=(K-count)%len(loop) print(loop[num])" p02684,s377109222,Wrong Answer,"def main(): N, K = map(int, input().split()) A = [int(x) for x in input().split()] L=[1] a = A[0] for _ in range(N): L.append(a) a=A[a-1] if a==1: break g = K%len(L) print(L[g]) main()" p02684,s239977898,Wrong Answer,"N, K = map(int, input().split("" "")) A = list(map(int, input().split("" ""))) Cyc = [0] i = 0 while True: if Cyc.count(A[i]) > 0: place = Cyc.index(A[i]) break Cyc.append(A[i]) i = A[i]-1 p2 = place-1 ans = (K-p2) % (len(Cyc)-place) print(Cyc[p2+ans]) " p02684,s073509963,Wrong Answer,"n, k = map(int, input().split()) num = list(map(int, input().split())) t = [1] t_test = [] for i in range(n): x = num[t[-1] - 1] if(x not in t): t.append(x) else: t_test = t[t.index(x):len(t)] list_num = list(set(t) - set(t_test)) if(len(t_test) >= 1): print(t_test[(k - len(list_num)) % len(t_test)]) else: print(t[-1]) " p02684,s821251850,Wrong Answer,"def main(): n,k = map(int,input().split()) A = list(map(int,input().split())) array = [1] now = 1 for i in range(n): next = A[now-1] array.append(next) now = next array = list(set(array)) length = len(array) print(array[k%length]) if __name__ == '__main__': main() " p02684,s706744542,Wrong Answer,"# -*- coding: utf-8 -*- N,K = map(int, input().split()) A = list(map(int, input().split())) M = K%N town_now = 1 for _ in range(M): town_now = A[town_now-1] print(town_now)" p02684,s452079839,Wrong Answer,"from collections import defaultdict N, K = map(int, input().split()) A = list(map(lambda x:int(x), input().split())) adj = defaultdict(int) for i in range(len(A)): adj[i+1] = A[i] d = 0 D = 1 slow = adj[1] fast = adj[adj[1]] while fast != slow: D += 1 slow = adj[slow] fast = adj[adj[fast]] slow = 1 while fast != slow: D += 1 d += 1 slow = adj[slow] fast = adj[fast] r = (K - d) % (D - d) while r: slow = adj[slow] r -= 1 print(slow) " p02684,s881727868,Wrong Answer,"n,m=map(int,input().split()) li=list(map(int, input().split())) s=m%n ans=li[li[s-1]-1] print(ans)" p02684,s939751117,Wrong Answer,"n,k=map(int,input().split()) a=list(map(int,input().split())) b=1 c=[1] for i in range(k): b=a[b-1] c.append(b) if len(c)!=len(set(c)): break e=c.index(b) mod=k%(len(c)-e) print(c[mod+e])" p02684,s687896451,Wrong Answer,"N,K = map(int,input().split()) A = list(map(int,input().split())) cnt = 0 dic = {1 : 1} x = 1 for i in range(N): y = A[x-1] cnt += 1 if y in dic: break else: dic[y] = cnt x = y if N < K: s = K % cnt + dic[y] x = y else: s = K x = 1 for i in range(s): y = A[x-1] x = y print(x)" p02684,s300407213,Wrong Answer,"n,k = map(int,input().split()) a = [int(i) - 1 for i in input().split()] r = [] nx = 0 for i in range(n): r.append(nx) tnx = a[nx] if tnx in r: m = r.index(tnx) d = i - m + 1 k = k - m k = k % d print(r[k + m] + 1) break nx = tnx " p02684,s369191509,Wrong Answer,"n,k = (int(x) for x in input().split()) a = [int(x) for x in input().split()] l = [1] now = 1 notloop = 0 dupl = -1 for i in range(n-1): now = a[now-1] if now in l: dupl = now break else: l.append(now) if(dupl == -1): print(now) else: notloop = l.index(dupl) length = len(l)-notloop print(l[(k-notloop)%length+notloop])" p02684,s465815107,Wrong Answer,"NK = list(map(int, input().split())) A = list(map(int, input().split())) N = NK[0] K = NK[1] town= 1 list = [] for i in range(N+1): town = A[town-1] list.append(town) if i >0 and town == list[0]: break list1 = list[:-1] d = K % len(list1) print(list1[d-1]) " p02684,s857636195,Wrong Answer,"n, k = map(int, input().split()) a = list(map(int, input().split())) a = [i - 1 for i in a] l = [] used = [0 for _ in range(n)] used[0] = 0 c = 0 while 1: l.append(c) if used[c] == 1 and l: break used[c] = 1 c = a[c] end = l[-1] p = 0 for i in range(len(l)): if l[i] == end: l = l[i:] p = i break l=l[:-1] b = (k-p) % len(l) print(l[b]+1) " p02684,s768544267,Wrong Answer,"import sys def main(): n, k = map(int, sys.stdin.buffer.readline().split()) a = [0] + list(map(int, sys.stdin.buffer.readline().split())) visited = [0]*(n+1) town = 1 for i in range(k+1): town = a[town] if visited[town] == 0: visited[town] = i else: print(visited.index( (k - visited[town])%(i - visited[town]) + visited[town])) exit() print(town) if __name__ == ""__main__"": main()" p02684,s438918296,Wrong Answer,"N,K=list(map(int,input().split())) l=list(map(int,input().split())) from collections import deque roop=deque([1]) now=l[0] while now not in roop: roop.append(now) now=l[now-1] start=roop.index(now) K-=start for i in range(start):roop.popleft() K=K%len(roop) print(roop[K])" p02684,s898790353,Wrong Answer,"n, k = map(int, input().split()) port = list(map(int, input().split())) visited = [1] current = 1 while port[current-1] not in visited: visited.append(port[current-1]) current = port[current-1] s = visited.index(port[current-1]) bubun = visited[s:] g = (k-s) % len(bubun) print(bubun[g]) " p02684,s253730273,Wrong Answer,"n, k = map(int, input().split()) A = [0] + list(map(int, input().split())) now = 1 used = [-228] * (n + 191) used[1] = -1 cn = -292 for _ in range(k): now = A[now] if used[now] != -228: cn = _ + 1 - used[now] break used[now] = _ if cn == -292: print(now) exit(0) for i in range(k % cn): now = A[now] print(now) " p02684,s646802548,Wrong Answer,"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<=len(before_loop_list): print(before_loop_list[k-1]) else: print(loop_list[((k-len(before_loop_list))%loop_len)])" p02684,s444869448,Wrong Answer,"from sys import stdin n,k = [int(x) for x in stdin.readline().rstrip().split()] a = [int(x) for x in stdin.readline().rstrip().split()] b = [-1]*n b[0] = 0 tf = True t = 1 g = 0 while tf: if b[a[g]-1] == -1: b[a[g]-1] = t else: m = b[a[g]-1] g = a[g]-1 break t += 1 g = a[g]-1 k -= t mo = t-m k = k % mo while k > 0: g = a[g]-1 k -= 1 print(g+1)" p02684,s013659718,Wrong Answer,"n, k = map(int, input().split()) A = list(map(int, input().split())) def f(x): return A[x-1] c = 1 P = [1] for i in range(1,k+1): c = f(c) if c in P: roop_start = P.index(c) roop_num = i- roop_start break P.append(c) if i == k: roop_start = 0 roop_num = 1 a = (k - roop_start) % roop_num b = P[a + roop_start] print(b)" p02684,s087507448,Wrong Answer,"n,k=map(int,input().split()) a=list(map(int,input().split())) li=[] ans=1 for i in range(k): ans=a[ans-1] if ans not in li: li.append(ans) else: break else: print(ans) exit() li_index=li.index(ans) t=len(li)-li_index k-=li_index k%=t #print(li_index,t,k) print(li[li_index+k-1]) #print(ans) #print(li)" p02684,s830869982,Wrong Answer,"n,k = list(map(int,input().split())) a = list(map(int,input().split())) a = [i-1 for i in a] # print(a) visit = [0]*(n+1) v = [] v.append(0) i = 0 num = 0 while True: if visit[a[v[i]]]==0: v.append(a[v[i]]) visit[a[v[i]]] += 1 i += 1 else: num = len(v) v = v[v.index(a[v[i]]):] break # print(v) k -= num # print(k%len(v)) print(v[k%len(v)]+1)" p02684,s105662062,Wrong Answer,"n,k=map(int,input().split()) a=list(map(int,input().split())) next=a[0] town=[0]*n town[0]+=1 for i in range(n): if town[next-1]==0: town[next-1]+=1 next=a[next-1] else: start=next break next=a[start-1] cnt=1 for i in range(n): if a[next-1]!=start: next=a[next-1] cnt+=1 else: cnt+=1 break print(cnt) k%=cnt next=a[0] for i in range(k-1): next=a[next-1] print(next)" p02684,s013014995,Wrong Answer,"N,K = map(int, input().split()) A = list(map(int, input().split())) list = [0]*N #print(A) #print(list) num = 0 ans = A[0] list[ans-1] += 1 while num <= 2*N+1: num += 1 ans = A[ans-1] list[ans-1] += 1 #print(list) x = list.count(1) y = N-x-list.count(0) #print(x,y) K = K%y #print(K) ans = A[0] while K > 1: K -= 1 ans = A[ans-1] print(ans)" p02684,s571193109,Wrong Answer,"n, k = map(int, input().split()) A = list(map(int, input().split())) r = 1 root = [1] for _ in range(n): roo = A[r-1] root.append(roo) for i in range(n): if roo == root[i]: roopcount = n-i-1 break if k <= n: print(root[k-1]) else: s = k%n print(root[i])" p02684,s454535007,Wrong Answer,"n,k = map(int,input().split()) l1 = list(map(int,input().split())) l = list(i-1 for i in l1) bit = list(0 for i in range(n)) bit[0] =1 mi = [0] m = l[0] er = 0 while er ==0: if bit[m]==1: a = mi.index(m) r = mi[a:] er =1 else: bit[m] = 1 mi.append(m) m = l[m] # print(bit) be = mi[:a]+r #print(be,r) if k< len(be): print(be[k]) else: w = k-len(be)+1 u = (w%len(r))-1 print(r[u]+1)" p02684,s287274837,Wrong Answer,"N,K = map(int, input().split(' ')) cache={} log=[] A = list(map(lambda x:int(x)-1, input().split(' '))) now=0 while(True): log.append(now) cache[now]=1 now=A[now] if(cache.get(now)):break loop_start=log.index(now) loop_end=len(log) loop=loop_end-loop_start #print(loop_end-loop_start,loop_start) print(loop_start,loop_end,log) if len(log) >= loop: if loop_end>K: print(now) else: print(log[K%loop]+1) else: print(log[K%loop+loop]+1)" p02684,s378766473,Wrong Answer,"N,K = map(int, input().split()) a = list(map(int, input().split())) ans = a[0] K = K % len(a) for i in range(1,K): ans = a[ans-1] print(ans)" p02684,s932446233,Wrong Answer,"n,k = map(int, input().split()) a = list(map(int, input().split())) a = [i-1 for i in a] num = [0] * (n) num[0] = 1 now = 0 for i in range(2,300000): nex = a[now] if num[nex]: start = num[nex] cycle = i - num[nex] v = (k+1-start) % cycle + start ans = num.index(v) + 1 break else: num[nex] = i now = nex print(ans)" p02684,s081651777,Wrong Answer,"from collections import defaultdict as d n, k = map(int, input().split()) arr = list(map(int, input().split())) s = '1' i = 1 b = 0 while True: if b == 2 * 10**5: break s += str(arr[i - 1]) i = arr[i - 1] b += 1 y = (k) % len(s) print(s[y])" p02684,s873735695,Wrong Answer,"n,k=map(int,input().split()) a=list(map(int,input().split())) dic={} wk=1 start=0 for i in range(1,n+1): wk=a[wk-1] if wk in dic: start=dic[wk] break dic[wk]=i end=len(dic) loopcnt=end-start+1 keys=list(dic.keys()) if k= 0: break if now == K: print(curr) exit() time[curr] = now # K = time[curr] + loop * (now - time[curr]) + r idx = K % (now - time[curr]) print(time.index(idx))" p02684,s328194847,Wrong Answer,"N,K= map(int,input().split()) A=list(map(int,input().split())) count=0 temp=1 memo=[] flag=True while (temp not in memo): count=count+1 memo.append(temp) temp=A[temp-1] num=memo.index(temp) roopnum=len(memo)-num K=(K-num)%roopnum temp=1 for i in range(K+num): temp=A[temp-1] print(temp)" p02684,s430899645,Wrong Answer,"n,k = map(int,input().split()) a = list(map(int,input().split())) checked = [0] next_num = a[0]-1 i = 0 while True: if i == 0: i += 1 elif next_num in checked: loop = checked[checked.index(next_num):] break checked.append(next_num) next_num = a[next_num]-1 dif = len(checked) - len(loop) if k <= dif: print(checked[k-1]+1) else: k = k-dif print(loop[k%len(loop)]+1)" p02684,s815929342,Wrong Answer,"n, k = map(int, input().split()) a = list(map(int, input().split())) a = [i-1 for i in a] visited = [-1]*n route = [] now = 0 hop = 0 while visited[now] == -1: visited[now]=hop route.append(now) now = a[now] hop+=1 loop_st = 0 for r in route: if r==now: break loop_st+=1 loop = route[loop_st:] if k-1 < len(route): print(route[k-1]+1) else: print(loop[(k-loop_st)%len(loop)]+1)" p02684,s088296815,Wrong Answer,"N, K = map(int, input().split()) P = list(map(int, input().split())) M = 40 c = 0 for j in range(M+1): if K % 2: c = P[c]-1 K //= 2 print(c+1) " p02684,s991873909,Wrong Answer,"n,k = map(int,input().split()) a = list(map(int,input().split())) b = [1] x = 1 for i in range(n): x = a[x-1] if not(x in b): b.append(x) else: c = b.index(x) break d = (k-c) % (len(b)-c) print( b[c+d] ) " p02684,s648335810,Wrong Answer,"n, k = map(int, input().split()) a = list(map(int, input().split())) c = [1] while True: c.append(a[c[-1]-1]) if c.count(c[-1])==2: cs = c.index(c[-1]) l = len(c)-cs-1 break print(c[(k-cs)%l+cs])" p02684,s559548102,Wrong Answer,"n,k=map(int,input().split()) a=list(map(int,input().split())) b=[0]*n c=[0]*n ka=0 kab=0 sihyou=0 while sihyou==0: if b[ka]==1: sihyou=1 else: b[ka]=1 c[ka]=kab ka=a[ka]-1 kab=kab+1 ruupu=kab-c[ka] ansa=(k-c[ka])%ruupu+c[ka] yui=0 for i in range(ansa): yui=a[yui]-1 print(yui+1) print(ansa)" p02684,s264233749,Wrong Answer,"n,k = map(int,input().split()) A = [0] A.extend(list(map(int,input().split()))) town = 1 once = [0]*(n+1) for i in range(n): if once[town]==0: once[town] = 1 else: break town = A[town] rt = A[town] roop = 1 while rt != town: rt = A[rt] roop += 1 rt = 1 bf = 0 while rt != town: rt = A[rt] bf += 1 if roop0: R=D[P] break D[P]=c if P==0: break #print(L) K-=R K%=(c-R) #print(R,K) ans=L[R+K]+1 print(ans)" p02684,s441597903,Wrong Answer,"import sys N,K = map(int,input().split()) tele = list(map(int,input().split())) k = 1 goal = tele[0] miti = [1] while (goal in miti)!=1: k += 1 miti.append(goal) goal = tele[goal-1] if k == K: goal = tele[goal-1] print(goal) sys.exit() print(miti) a = miti.index(goal) loop = k-a ans = miti[(K-a)%loop+a] print(ans) " p02684,s894945549,Wrong Answer,"n,k = list(map(int, input().split())) a = list(map(int, input().split())) init = [1] while True: nxt = a[init[-1]-1] if nxt in init: idx_nxt = init.index(nxt) len_init = idx_nxt len_loop = len(init) - idx_nxt break else: init.append(nxt) idx = (k-len_init)%len_loop print(init[len_init+idx])" p02684,s316972239,Wrong Answer," data = input().split("" "") N = int(data[0]) K = int(data[1]) tele = input().split("" "") teles=[] for t in tele: teles.append(int(t)) now = 1 for _ in range(K): now = teles[now-1] print(now+1)" p02684,s397826819,Wrong Answer,"n,k = map(int,input().split()) a = list(map(int,input().split())) ans = [] check = {} key = -1 p = 0 while True: ans.append(p) check[p] = 0 p = a[p]-1 if p in check: key = ans.index(p) break r = ans[key:] mod = (k-key)%len(r) print(1)" p02684,s843051448,Wrong Answer,"import numpy as np N, K = (int(i) for i in input().split()) A = [int(i) for i in input().split()] def has_duplicates(seq): return len(seq) != len(set(seq)) lis = [1] idx = 0 for i in range(N): lis.append(A[idx]) if has_duplicates(lis): lis.pop(-1) found = lis.index(A[idx]) lis.append(A[idx]) break idx = A[idx]-1 print(lis[found:i+1][(K-found) % (i - found + 1)])" p02684,s690915653,Wrong Answer,"n, k = map(int, input().split()) a = list(map(int, input().split())) mod = k % n ans = mod for x in range(len(str(mod))+ 1): ans = a[ans] print(ans)" p02684,s338264527,Wrong Answer,"n,k=map(int,input().split()) p=list(map(int,input().split())) a=[0]+p flag=0 bef=1 town=[1] town_set=set(town) while flag==0: if not a[bef] in town_set: town.append(a[bef]) town_set.add(a[bef]) bef=a[bef] else: flag=1 memo=a[bef] for j in range(len(town)): if town[j]==memo: num=j x=len(town)-num y=(k-num)%x print(town[num+y]) " p02684,s881876881,Wrong Answer,"N,K = map(int,input().split()) A = list(map(int,input().split())) A_dict = {i:a for i,a in enumerate(A,1)} History = [1] History_set = {1} now = 1 for _ in range(N): now = A_dict[now] if now not in History_set: History.append(now) History_set.add(now) else: break #print(History,now) for e,h in enumerate(History): if h == now: #print(e) break loop_num = len(History[e:]) #print(loop_num) num = (K-e)%loop_num #print(num) print(History[e:][num])" p02684,s326812736,Wrong Answer,"N, K = map(int, input().split()) A = list(map(int, input().split())) index = 0 count = 0 node = [1] while True: next = A[index] node.append(next) if A[next - 1] in node: catch_point = A[next - 1] break index = next - 1 for point in node: if point == catch_point: break else: count += 1 print(catch_point, count) idx = (K - count) % (len(node) - count) print(node[count + idx])" p02684,s360626862,Wrong Answer,"n, k = map(int, input().split()) A = list(map(int, input().split())) Town = [] #まだ訪れていない町は-1 rec = [-1] * (n+1) idx = 1 #周期までループをまわす while True: if rec[idx] != -1: break rec[idx] = len(Town) Town.append(idx) idx = A[idx-1] #周期前 Exce = rec[idx] #周期内 Cycl = len(Town) - Exce if Cycl > k: print(Town[k]) else: k -= Exce k %= Cycl print(Town[Exce+k])" p02684,s188450360,Wrong Answer,"import sys N, K = map(int, input().split()) A = list(map(int, input().split())) if K == 1: print(A[0]) sys.exit() now = A[0] kiseki = [1] count = 0 while now not in kiseki: kiseki.append(now) count += 1 now = A[now - 1] if count == K: print(now) sys.exit() ind = kiseki.index(now) roop = len(kiseki) - ind nokori = (K - ind) % roop ans = kiseki[ind + nokori] print(ans) " p02684,s403078796,Wrong Answer,"n,k=map(int,input().split()) L=list(map(int,input().split())) L.insert(0,0) #print(L) visit=[0]*(n+1) visit[L[0]]=1 prev=L[1] count=0 for i in range(1,k): nex = L[prev] if visit[nex]==0: visit[nex]=1 else: count+=i val=nex #print(i) #print(prev) break prev = nex k-=count k = k%(i-1) #print(k) for i in range(k): nex=L[prev] prev=nex print(prev) " p02684,s547845283,Wrong Answer,"n, k = map(int,input().split()) a = list(map(int, input().split())) D = 60 MAX_N = 200005 to = [[0]*MAX_N]*D # to = [[0]*D]*MAX_N # to = [D][MAX_N] for i in range(n): to[0][i] = a[i]-1 print(a[i]-1) for i in range(D-1): for j in range(n): to[i+1][j] = to[i][to[i][j]] v = 0 for i in range(D-1): l = 1< 0: cityIndex = A[A[cityIndex] - 1] - 1 numOfTeleport -= 1 print(A[cityIndex])" p02684,s095731051,Wrong Answer,"N, K = map(int, input().split()) A_list = list(map(int, input().split())) l_set = set() tele_list = [0] current_city = 0 for i in range(N): if current_city in l_set: break else: current_city = A_list[current_city] - 1 tele_list.append(current_city) l_set.add(current_city) len_tele_list = len(tele_list) index_last = len_tele_list % K - 1 print(tele_list[index_last] + 1) " p02684,s941778342,Wrong Answer,"n,k=map(int,input().split()) a=list(map(int,input().split())) a.insert(0,0) path=[1] ans=0 s=1 while ans==0: if a[s] not in path: path.append(a[s]) s=a[s] k-=1 else: junkan=path[path.index(a[s]):] x=len(junkan) ans=1 k-=1 m=k%x print(junkan[m])" p02684,s887413440,Wrong Answer,"N, K = list(map(int, input().split())) A = list(map(int, input().split())) d = {} for i in range(N): d[i+1] = A[i] al = [1] for i in range(N): ne = d[al[-1]] if ne in al: tar = al.index(ne)+1 break al.append(ne) ne = i+2 if K<=len(al): print(al[K-1]) else: K-=(tar-1) K%=(ne-tar) print(al[tar-1+K]) " p02684,s234792933,Wrong Answer,"n, k = map(int, input().split()) a_list = list(map(int, input().split())) route = [] now = 1 # next = a_list[now-1] while True: if now in route: start = route.index(now) end = len(route) junkai = route[start:end] amari = route[:start] break route.append(now) now = a_list[now-1] # next = a_list[now-1] hoge = (k-len(amari))%len(junkai) print(junkai[hoge])" p02684,s853247788,Wrong Answer,"N, K = map(int,input().split()) A = list(map(int,input().split())) count = 0 i = 1 position = 1 position_list = [1] position_history = [0] * N start_loop = 0 while i > 0: position = A[position-1] position_history[position-1] += 1 count += 1 if position_history[position-1] > 1: start_loop = position_list.index(position) position_list.append(position) break else: position_list.append(position) if count >= K: print(position_list[K-1]) else: k = (K - start_loop) % (count - start_loop) print(position_list[start_loop+k]) " p02684,s251472619,Wrong Answer,"N,K= map(int, input().split()) flags = [-1]*N M = 1 mods = [] mods.append(0) A = list(map(int,input().split())) now = 0 I = 0 flags[0] = 0 for i in range(N): now = A[now]-1 if flags[now]!=-1: I = i M=i+1-flags[now] break mods.append(now) flags[now] = i+1 I += 1 alt = mods[I-M:] if K-I<=0: print(now+1) else: print(alt[(K-I)%(len(alt))]+1) " p02684,s453447853,Wrong Answer,"n, k = map(int, input().split()) a = list(map(int, input().split())) a.insert(0, 'hoge') # a = dict(list(enumerate(a))) amari = k % n tmp = 1 # print(amari) for i in range(1, n + amari+1): # print(tmp) tmp = a[tmp] print(tmp) " p02684,s732204562,Wrong Answer,"n,k=map(int,input().split()) ar=list(map(int,input().split())) vis=[0 for i in range(n+1)] x=1 seq=[1] go=0 rep=0 ct=1 while (vis[x]==0): vis[x]=ct seq.append(ar[x-1]) x=ar[x-1] ct+=1 if vis[x]!=0: rep=ct-vis[x] go=vis[x] if k<=go: print(seq[k-1]) else: print(seq[go+(k-go)%rep]) " p02684,s816448014,Wrong Answer,"N, K = map(int, input().split()) A = list(map(int, input().split())) li = [False] * N f = True now = 0 l = [] l2 = [0] * N i = 0 while f: l.append(now) li[now] = True l2[now] = i if li[A[now]-1]: f = False num = len(l) - l2[A[now]-1] i += 1 now = A[now]-1 K %= num print(l[K]+1)" p02684,s643170796,Wrong Answer,"N,K=map(int,input().split()) A=list(map(int,input().split())) f=[0]*N l,r=[],[] p=0 while f[p]<2: if f[p]: r.append(A[p]) K-=1 else: l.append(A[p]) K+=1 f[p]+=1 p=A[p]-1 print(r[K%len(r)-1])" p02684,s077046337,Wrong Answer,"N, K = map(int, input().split()) A = list(map(int,input().split())) T = 1 cnt = 0 Tlist = [] for k in range(K): cnt += 1 T = A[T-1] if T in Tlist: Tlist.append(T) break Tlist.append(T) for i in range(len(Tlist)): if Tlist[i] == Tlist[-1]: lp = len(Tlist)-i break if k == K-1: print(T) else: for k in range((K-i)%lp): T = A[T-1] print(T)" p02684,s278519912,Wrong Answer,"import collections as cl N, K = map(int, input().split()) A = list(map(int, input().split())) i = 0 telp = [1] while True: if A[i] not in telp: telp.append(A[i]) i = A[i] - 1 else: telp.append(A[i]) break c = cl.Counter(telp) lll = telp.index(c.most_common()[0][0]) K -= lll ans = (K % len(telp[lll + 1:])) print(telp[ans + lll])" p02684,s971030047,Wrong Answer,"n, k = map(int, input().split()) a = list(map(int, input().split())) visited = [] now = 0 lim = 2 * 10**5 + 1 for _ in range(n+1000): visited.append(now) now = a[visited[-1]]-1 if now in visited: break visited.append(now) ln1 = len(visited)-1 idx = visited.index(now) ln2 = len(visited[idx:-1]) ln = (k-ln1)%ln2 print(visited[idx+ln]+1)" p02684,s983248799,Wrong Answer,"n, k = [int(i) for i in input().split()] towns = [int(i) for i in input().split()] ind_ = 1 ts = [] visited = [0]*n loop_s = None while(True): ind_ = towns[ind_-1] if visited[ind_-1]: loop_s = ts.index(ind_) break else: visited[ind_-1] = 1 ts.append(ind_) init = len(ts[:loop_s]) loop_l = len(ts) - init loop = ts[loop_s:] print(loop[((k-init)%loop_l)-1]) " p02684,s066439627,Wrong Answer,"n, k = map(int, input().split()) a = list(map(int, input().split())) now = 1 k = k % n for i in range(k): now = a[now-1] print(now) " p02684,s423215976,Wrong Answer,"n, k = map(int, input().split()) a = list(map(int, input().split())) route = [] town = set() now = 1 while True: now = a[now-1] if now in town: break town.add(now) route.append(now) count = route.index(now) if k <= count: print(route[count-1]) else: route = route[count:] num = (k-count)%len(route) print(route[num-1]) " p02684,s845601951,Wrong Answer,"n,k=map(int,input().split()) a=list(map(int,input().split())) now=0 ima=[] while True: now=a[now-1] ima.append(now) if now in ima[:len(ima)-1]: break print(a[k % (len(ima)-1)])" p02684,s404452364,Wrong Answer,"N,K = map(int, input().split()) A = list(map(int, input().split())) limit = K now = 1 log = [] while limit > 0 and now not in log: if 1 not in log: log.append(1) #print(""通過1"",now,limit,log) now = A[now - 1] log.append(now) limit -= 1 if limit > 0: #print(""通過2"",now,limit,log) limit = limit % len(log[log.index(now) - 1:]) while limit > 0: #print(""通過3"",now) now = A[now - 1] limit -= 1 now = A[now - 1] print(now) " p02684,s083754699,Wrong Answer,"N,K = map(int,input().split()) A = list(map(int,input().split())) town = [0 for i in range(N)] def next(A,now): return(A[now-1]) now = 1 i = 0 while True: if town[now-1] != 0: roop_start = town[now-1] roop_end = i break town[now-1] = i+1 now = next(A,now) i += 1 roop = roop_end - roop_start + 1 teleport = roop_start + (K - roop_start)%roop print(teleport) now = 1 for i in range(teleport): now = next(A,now) print(now) " p02684,s819554865,Wrong Answer,"n, k = map(int, input().split()) a = list(map(int, input().split())) l = [1] for i in range(n): if a[l[i] - 1] in l: res = l[:l.index(a[l[i] - 1])] cyc = l[l.index(a[l[i] - 1]):] break else: l += [a[l[i] - 1]] print(cyc[(k - len(res)) % len(cyc)] if k > len(res) else res[k - 1]) " p02684,s491909569,Wrong Answer,"n, k = map(int,input().split()) town = list(map(int,input().split())) cnt = 1 step = 1 now = town[0] via = [1] while((now not in via)): via.append(now) now = town[now -1] cnt += 1 step += 1 loop = via[via.index(now):] print(loop[(k - cnt)%len(loop)]) " p02684,s745552174,Wrong Answer,"N, K = map(int, input().split()) A = list(map(int, input().split())) visited = [-1]*N count = 0 v = 0 while visited[v] == -1: visited[v] = count v = A[v]-1 count += 1 loop_length = count - visited[v] K -= visited[v] print(A[K%loop_length+visited[v]])" p02684,s690072159,Wrong Answer,"n, k = map(int, input().split()) A = list(map(int, input().split())) A = [x-1 for x in A] town = 0 cnt = 0 visited = [False] * n visited[0] = -1 start = 0 loop = 10**8 start_cnt = 0 for i in range(n*2): town = A[town] if visited[town] != False: start_cnt = i + 1 loop = i - visited[town] break else: visited[town] = i town = 0 for i in range((k-start_cnt)%loop+start_cnt): town = A[town] print(town+1)" p02684,s530067438,Wrong Answer,"import sys def input(): return sys.stdin.readline() N,K = map(int,input().split()) A=list(map(int,input().split())) P=[True]*N P[0]=False i,a=1,0 while 1: a+=1 if P[A[i-1]-1]: P[A[i-1]-1]=False i=A[i-1] else: break if a>=K: print(A[K]) else: K-=a a,j=0,i while 1: a+=1 if A[j-1]==i: break j=A[j-1] K%=a for _ in range(K): i=A[i-1] print(A[i-1])" p02684,s842113627,Wrong Answer,"import itertools n,k=map(int,input().split()) a=list(map(int,input().split())) pas=[1] p=1 count=1 for i in range(n): p=a[p-1] pas.append(p) count+=1 if count!=len(set(pas)): nloop=pas.index(p) loop=count-1-nloop break last=(k-nloop)%loop print(pas[nloop+last])" p02684,s290916764,Wrong Answer,"n,k = map(int, input().split()) a = [0] + list(map(int, input().split())) r = [1] now = 1 for i in range(n): now = a[now] if now in r: break r.append(now) I = r.index(now) if I != 0: k -= I r = r[I:] print(r[k%(len(r))])" p02684,s898975123,Wrong Answer,"n,k=map(int,input().split()) A=[0]+list(map(int,input().split())) from collections import defaultdict reached=defaultdict(int) reached[1]=1 i=1 for j in range(1,n+1): if reached[A[i]]==0: reached[A[i]]=j+1 else: t1=reached[A[i]] t2=j+1 break i=A[i] reached=dict(reached) ama=(k-(t1-1))%(t2-t1) ans=[s for s,h in reached.items() if h==t1+ama] print(ans[0])" p02684,s968166138,Wrong Answer,"import sys sys.setrecursionlimit(200000) L = [] def Search(pos): if pos - 1 not in L: L.append(pos - 1) Search(A[pos-1]) else: L.append(pos - 1) return pos N, K = map(int, input().split()) A = list(map(int, input().split())) Search(1) #print(L) if K < L.index(L[-1]): print(L[K]) else: t = L.index(L[-1]) k = len(L) - t - 1 K -= t #print(t, k, K % k) print(L[t + (K % k)] + 1)" p02684,s883515366,Wrong Answer,"n,k=[int(x) for x in input().split()] p=[(int(x)-1) for x in input().split()] a=[0] i=0 while p[i] not in a: a.append(p[i]) i=p[i] l=a.index(p[i]) if k<=l: print(a[k]) else: print(1+a[l+(k-l)%(len(a)-l)])" p02684,s183568118,Wrong Answer,"n,k,*a=map(int,open(0).read().split()) d={} s=1 while k:k-=1;s=a[s-1];k%=d.get(s,2**60)-k;d[s]=k print(s)" p02684,s641035618,Wrong Answer,"n, k = map(int, input().split()) a = tuple(map(int, input().split())) i = 0 aa = 0 visited = {} for i in range(k): aa = a[aa] - 1 if aa in visited: s, e = visited[aa], i loop = e - s k = s + ((k - s) % loop) exit(0) visited[aa] = i print(aa + 1) " p02684,s466360469,Wrong Answer,"[N,K] = list(map(int,input().split())) A = list(map(int,input().split())) #ループする場合 flag=[0]*N patt=[] i=0 while True: patt.append(i) if flag[i]==1: #del patt[-1] break flag[i]=1 i=A[i]-1 srt = patt.index(patt[-1]) #print(srt) end = len(patt)-2 ptrn = patt[srt:end+1] B = (K-srt) % len(ptrn) #print('B',B) if B==0: print(ptrn[0]+1) else: print(ptrn[B]+1) #print('0000000')" p02684,s597401925,Wrong Answer,"n, k = map(int, input().split()) a = list(map(lambda x: int(x)-1, input().split())) visited = list() i = 0 cnt = 0 while True: if i in visited: break visited.append(i) i = a[i] cnt += 1 si = visited.index(i) loop = visited[si:] n_loop = len(loop) left_k = k - cnt print(loop[left_k % n_loop] + 1)" p02684,s056333682,Wrong Answer,"n,k = map(int,input().split()) a = list(map(int,input().split())) now = 1 x = 0 ss = set([1]) for i in range(k): now = a[now-1] ss.add(now) if len(ss) != i+1: x = 1 break if x == 1: aa = k%(len(ss)+1) if aa == 0: for i in range(len(ss)): now = a[now-1] else: for i in range(aa-1): now = a[now-1] print(now)" p02684,s541644752,Wrong Answer,"N,K = map(int,input().split()) A = list(map(int,input().split())) flag = [0]*(N+5) # 何回目に初めて訪れたか period = 1 now = 0 for i in range(N): now = A[now]-1 #print(now+1) #print(flag) #print() if(flag[now] != 0): period = (i+1)-flag[now] break flag[now] = i+1 #print('period',period) num = K % period #print('num',num) now = 0 for i in range(num): now = A[now]-1 ans = now+1 # index→town_no print(ans) " p02684,s702387540,Wrong Answer,"n,k=map(int,input().split()) a=[0]+list(map(int,input().split())) b=[1] d=set() d.add(1) e=1 while n==n: if a[e] in d: e=a[e] break b.append(a[e]) d.add(a[e]) e=a[e] print(b[(k-len(d))%(len(d)-b.index(e))+b.index(e)]) " p02684,s086164656,Wrong Answer,"n,k = map(int, input().split()) d={} l = list(map(int, input().split())) for i in range(len(l)): d[i+1] = l[i] print(d) city = 1 l2 = [1] while True: city = d[city] if city in l2: break l2.append(city) first = l2.index(city) if len(l2) <= k: if city == l2[-1]: print(city) else: l2 = l2[first:] print(l2[(k-first)%(len(l2))]) else: print(l2[k])" p02684,s691416542,Wrong Answer,"import itertools N,K=map(int,input().split()) A=list(map(int,input().split())) Loop=1 Next=1 From=0 To=0 found=[0]*N while(True): found[Next-1]=1 From=Next Next=A[Next-1] To=Next if(found[Next-1]==1): break Loop+=1 K=To-1+K%(Loop) #print(Loop) Next=1 for i in range(K): Next=A[Next-1] print(Next)" p02684,s071306693,Wrong Answer,"n, k = map(int,input().split()) a = [int(i) for i in input().split()] b = [a[0]] for i in range(n-1): b.append(a[b[-1]-1]) for i in range(n): c = b.count(b[i]) if c != 1: break index_num = [n for n, v in enumerate(b) if v == b[i]] ans = index_num[0] + 1 e = index_num[1] f = e - ans+ 1 g = k - ans h = g % f print(b[index_num[0]+h])" p02684,s991346638,Wrong Answer,"n,m = map(lambda x: int(x), input().split()) a = [int(_) for _ in input().split()] goal = 1 nexts = 1 visited = [1] r_len = 1 for _ in range(m): nexts = a[nexts-1] if nexts in visited: r_len = len(visited[visited.index(nexts):]) break else: visited.append(nexts) rest = m-r_len+1 rec = rest%r_len print(visited[r_len-rec-1]) " p02684,s000064885,Wrong Answer,"n,k = map(int,input().split()) A = list(map(int,input().split())) visited = [False for _ in range(n)] nx = A[0] - 1 x = [] for e, i in enumerate(range(n)): if visited[nx] == False: visited[nx] = True x.append(nx) nx = A[nx] - 1 else: p = x.index(nx) q = x[:p] r = x[p:] break k = (k-len(q))%len(r) print(r[k-1]+1)" p02684,s915018153,Wrong Answer,"N, K = list(map(int, input().split())) A = list(map(lambda x: int(x) - 1, input().split())) now = 0 route = [] while True: route.append(now) to = A[now] if to == None: break else: A[now] = None now = to print(route) loop_start = route.index(now) loop_size = len(route) - loop_start n_for_loop = min(K, loop_start) n_in_loop = (K - n_for_loop) % loop_size print(route[n_for_loop + n_in_loop] + 1)" p02684,s174259158,Wrong Answer,"n,k=map(int,input().split()) a=list(map(int,input().split())) dic={} wk=1 start=0 for i in range(1,n+1): wk=a[wk-1] if wk in dic: start=dic[wk] break dic[wk]=i end=len(dic) loopcnt=end-start+1 keys=list(dic.keys()) if k n+1 or go in res:break res.append(go) i += 1 for i in range(len(res)): if res[i] == go: ind = i v = res[ind:] m = len(v) k -= ind ans = v[k%m] print(ans) " p02684,s622904802,Wrong Answer,"n,k = map(int, input().split()) a = list(map(int, input().split())) is_good = True graph=[0] s = 0 while is_good: next = a[graph[-1]]-1 if next in graph: next_ = graph.index(next) loop = len(graph) - next_ is_good = False else: graph.append(next) if k <= next_: print(graph[k-1] + 1) else: k -= next_ x = k%loop print(graph[x+next_]+1) " p02684,s491580083,Wrong Answer,"import numpy as np n, k = [int(k) for k in input().split()] a = np.array([int(k) for k in input().split()], dtype=int) used = np.full(n, -1) r = 1 used[0] = -1 for i in range(n): r = a[r - 1] if used[r - 1] != -1: r = i - used[r - 1] break used[r - 1] = i k = k % r # print(k) r = 1 for i in range(k): r = a[r - 1] print(r) " p02684,s897851091,Wrong Answer,"N,K = map(int, input().split()) A = list(map(int, input().split())) def forward(L ,n=1, count=K): n = L[L[n]] if (count == K): return n forward(L, n) forward(A)" p02684,s911480554,Wrong Answer,"import numpy as np n, k = [int(k) for k in input().split()] a = np.array([int(k) for k in input().split()], dtype=int) used = np.full(n, -1) r = 1 for i in range(n): r = a[r - 1] if used[r - 1] != -1: k = k % (i - used[r - 1]) break used[r - 1] = i r = 1 for i in range(k): r = a[r - 1] print(r) " p02684,s865234098,Wrong Answer,"n,k=list(map(int,input().split())) A=list(map(int,input().split())) start,i=1,0 root=[1] for j in range(k): start=A[start-1] if start in root: i = start break root.append(start) if k <= len(root): print(root[k-1]) else: ind = root.index(i) newroot=root[ind:] ans=(k-len(root))%len(newroot) print(newroot[ans])" p02684,s839668650,Wrong Answer,"N, K = map(int, input().split()) A = list(map(int, input().split())) A = [i-1 for i in A] check = [0]*N i = 0 c = 0 check = [] visited = [0]*N flag = False while c<=K: if visited[i] == 1: flag = True break else: check.append(i) visited[i] = 1 i = A[i] c += 1 if flag==True: X = check[check.index(i):] print(1+X[(K-c)%len(X)]) else: print(i+1)" p02684,s657686195,Wrong Answer,"n,k = map(int,input().split()) a = list(map(int,input().split())) ans = 1 A = [1] for i in range(1,k+1): ans = a[ans-1] if ans in A: x = (k-i+1) % (len(A)-A.index(ans)) ans = A[A.index(ans)-1+x] print(ans) exit() A.append(ans) print(ans)" p02684,s215827684,Wrong Answer,"N,K = map(int,input().split()) A = list(map(int,input().split())) location = [1] nowlocate = 1 for i in range(N): nowlocate = A[nowlocate-1] location.append(nowlocate) if len(set(location)) != len(location): M = len(location) -1 break for i in range(M): if location[M] == location[i]: roop = M-i stop = i break print(location[((K-stop) % roop) + stop ])" p02684,s256515674,Wrong Answer,"n, k = map(int, input().split()) a = list(map(int, input().split())) num = 1 l = [] for _ in range(n+1): if num in l: l2 = l[l.index(num):] break else: l.append(num) num = a[num-1] kk = (k-len(set(l)-set(l2)))%len(l2) print(l2[kk]) " p02684,s789759346,Wrong Answer,"(N, K) = [int(n) for n in input().split()] A = [int(n)-1 for n in input().split()] v = [-1 for _ in range(N)] D = [0] v[0] = 0 cur = A[0] i = 1 while v[cur] == -1: D.append(cur) v[cur] = i i += 1 cur = A[cur] K -= v[cur] K %= (i - v[cur]) print(D[v[cur] + K]+1) " p02684,s366680572,Wrong Answer,"N,K=map(int,input().split()) t=list(map(int,input().split())) g=[1] for i in range(N): gs=set(g) if t[g[i]-1] in gs: h=g.index(t[g[i]-1]) s=i+1-h break g.append(t[g[i]-1]) if K>h: K=(K-h)%s+h print(g[K]) print(s,h)" p02684,s955622669,Wrong Answer,"n,k= map(int,input().split()) temp = list(map(int,input().split())) As = [0]*(n+1) for i in range(n): As[i+1] = temp[i] visit_list = {} now = 1 visit_list[1] = 0 visit_num = 1 while True: now = As[now] if now in visit_list: break visit_list[now] = visit_num visit_num += 1 loop_num = visit_num - visit_list[now] res = k%loop_num res -= visit_list[now]%loop_num for i in range(res): now = As[now] print(now)" p02684,s566261034,Wrong Answer,"n, k = map(int, input().split()) A = list(map(int,input().split())) flag = [True]*n p = 0 rt = [1] while flag[p]: flag[p] = False p = A[p] -1 rt.append(p+1) to_p = rt.index(rt[-1]) p2p = rt[to_p:-1] p2p_len = len(p2p) if k < p2p_len: print(rt[k]) else: idx = (k-to_p)%p2p_len print(p2p[idx])" p02684,s415411207,Wrong Answer,"N, K = map(int, input().split()) a = list(map(int, input().split())) cnt = 0 li = [1] c = 1 for i in range(200001): cnt += 1 c = a[c-1] if c in li: break li.append(c) b = li[li.index(c):] e = (K-cnt)%len(b) print(b[e])" p02684,s923505641,Wrong Answer,"n,k = map(int,input().split()) a = list(map(int,input().split())) cur = 0 reach = [False]*n x = [] for i in range(k): x.append(cur) if reach[cur]: break reach[cur]=True cur = a[cur]-1 cnt = 0 for i in range(len(x)): cnt += 1 if x[i]==x[-1]: break y = x[cnt-1:-1] if k>cnt: ind = (k-cnt+1)%len(y) print(y[ind]+1) else: print(x[k%len(x)]+1) " p02684,s907091536,Wrong Answer,"n,k = map(int,input().split()) A = list(map(int,input().split())) B=[1] m=0 j=0 for i in range(1,n): B.append(A[m]) m=A[m]-1 if B[i] in B[:i]: while B[j]!=B[i]: j+=1 break T=len(B)-j-1 if n!=2: print(B[k-((k-j)//T)*T],B) else: print(B[k%2])" p02684,s281604163,Wrong Answer,"n, k = map(int, input().split()) a = [int(i) for i in input().split()] ordi = [0, ] for i in range(n): if a[ordi[-1]] - 1 not in ordi: ordi.append(a[ordi[-1]] - 1) else: ordi.append(a[ordi[-1]] - 1) index = ordi.index(a[ordi[-1]] - 1) len_ = len(ordi) - index break print(ordi[index + (k - index) % len_] + 1)" p02684,s911079840,Wrong Answer," N, K = map(int, input().split()) X = list(map(int, input().split())) dp = [[0] * (N + 1) for _ in range(50)] dp[0] = [0] + X for k in range(1, 50): for i in range(N + 1): dp[k][i] = dp[k - 1][dp[k - 1][i]] ans = 1 for k in range(50): if K >> k & 1: ans = dp[k][ans] print(ans) " p02684,s749692918,Wrong Answer,"n, k = map(int, input().split()) a = list(map(int, input().split())) visited = [-1] * (n + 1) next = 1 cnt = 1 while True: if visited[next] == -1: visited[next] = cnt cnt += 1 else: mod = cnt - visited[next] break next = a[next - 1] k -= cnt k %= mod for i in range(k): next = a[next - 1] print(a[next - 1]) " p02684,s203340949,Wrong Answer,"n, k = map(int, input().split()) a = list(map(int, input().split())) f = [0] * n i = 0 x = 0 while True: f[i] = 1 i = a[i] - 1 x += 1 if f[i]: break f = [0] * n cnt = 0 while True: f[i] = 1 i = a[i] - 1 cnt += 1 if f[i]: break ans = i cnt -= x - cnt for i in range(cnt - 1): ans = a[ans] - 1 print(ans + 1)" p02684,s323227107,Wrong Answer,"n,k=map(int,input().split()) l=list(map(int,input().split())) lcount=[0]*(n+1) lnum=[0]*(n+1) count=1 place=1 while lcount[place]==0: lnum[place]=count lcount[place]=1 place=l[place-1] count+=1 dif=count-lnum[place] k=(k+1-lnum[place])%dif+lnum[place] print(lnum.index(k)) " p02684,s483865164,Wrong Answer,"(N, K) = list(map(int, input().split())) a_list = list(map(int, input().split())) amap = {} for i, dst in enumerate(a_list): amap[i + 1] = dst print(amap) prev = 1 curr = None for k in range(1, K + 1): curr = amap[prev] prev = curr print(curr)" p02684,s066438856,Wrong Answer,"# coding: utf-8 # Your code here! n,k=map(int,input().split()) A=list(map(int,input().split())) L=[1] now=1 for _ in range(n): now=A[now-1] if now in L: index=L.index(now) break L.append(now) if k<=index: print(L[k+1]) exit() R=(k-index)%(len(L)-index) print(L[index:][R])" p02684,s047331842,Wrong Answer,"n, k = [int(i) for i in input().split()] a = [int(i) for i in input().split()] route_list = [] current_index = n while current_index not in route_list: route_list.append(current_index) value = a[current_index-1] current_index = value cycle_route = route_list[route_list.index(current_index):] temp = len(route_list[:route_list.index(current_index)]) cycle_route[(k - temp) % len(cycle_route)-1]" p02684,s869357582,Wrong Answer,"import sys n, k, *aaa = map(int, sys.stdin.buffer.read().split()) shortest = [-1] * n v = 0 d = 0 while shortest[v] == -1: shortest[v] = d v = aaa[v] - 1 d += 1 if d == k: print(v + 1) exit() first = shortest[v] loop = d - first remaining = (k - first) % loop print(v, first, loop, remaining + first, shortest) ans = shortest.index(remaining + first) + 1 print(ans) " p02684,s829589643,Wrong Answer,"def main(): N,K = [int(x) for x in input().split()] Al = [int(x) for x in input().split()] current = 1 steps = [] initial_step = 0 while current not in steps: steps.append(current) current = Al[current-1] initial_step += 1 loop_step = len(steps) - steps.index(current) if len(steps) == initial_step: initial_step = 0 print((K-initial_step)%loop_step) if __name__ == '__main__': main()" p02684,s213074203,Wrong Answer,"N, K = map(int, input().split()) MyList = input().split() MyList = [int(n) for n in MyList] ANS = 0 visted = [] def Myfunc(A): return MyList[A] - 1 for i in range(K): if ANS in visted: beANS = K % len(visted) ANS = visted[beANS] print(ANS) ANS = Myfunc(ANS) visted.append(ANS) if i +1 == K: print(ANS+1) " p02684,s848414512,Wrong Answer,"n,k,*a=map(int,open(0).read().split()) now=1 if k<=n: for i in range(k): now=a[now-1] print(now) exit() # 絶対ループする visited=[False]*n visited[now-1]=-1 for i in range(4*10**5): now=a[now-1] if visited[now-1]==False: visited[now-1]=i else: c,d=visited[now-1],i break k=(k-c)%(d-c)+c #while k= 0: K %= len(L) - L.index(A[now - 1]) break L.append(A[now - 1]) s.add(A[now - 1]) now = A[now - 1] print(L[K + L.index(A[now - 1])]) if len(L) - L.index(A[now - 1]) == 1: print(""hoge"") " p02684,s435845541,Wrong Answer,"N, K = map(int, input().split()) A = list(map(int, input().split())) roop_num = 1 city = 0 first_city = 0 while True: next_city = A[city] - 1 if next_city == first_city: break if roop_num == K: print(city + 1) exit() city = next_city roop_num += 1 rem_num = K % roop_num city = 0 num = 0 while True: next_city = A[city] - 1 if num == rem_num: print('answer', city + 1) exit() city = next_city num += 1 " p02684,s725341391,Wrong Answer,"n,k = map(int, input().split()) a = [int(s)-1 for s in input().split()] start = 0 for _ in range(k): print(start) start = a[start] print(start) print(start + 1)" p02684,s617535946,Wrong Answer,"import sys a,b=map(int,input().split()) b=b+1 l=[0]*(a) List=list(map(int,input().split())) i=0 j=1 while l[i]==0 and j1: if now in log: f=log.index(now) z=k-cnt #要調整 loop=cnt b=z%(loop-f) #print(cnt,f,z,loop,b) print(log[f+b]+1) #print(log) sys.exit() log.append(now) now=a[now]-1 cnt+=1" p02684,s480758776,Wrong Answer,"N,K=map(int,input().split()) A = list(map(int,input().split())) B = [0]*N loop=0 now=0 C=[] n=0 while(True): if B[now]==0: B[now]=1 C.append(now+1) loop+=1 now=A[now]-1 else: n=A[now] break if loop<=K: res=(K-C.index(n)+1)%(loop-C.index(n)+1) D=C[C.index(n)-1:] print(D[res%len(D)]) else: print(C[K])" p02684,s888652280,Wrong Answer,"N, K = map(int, input().split()) A = list(map(int, input().split())) chk = [0]*(N+1) town = 1 rt = [] roop = 0 while True: if chk[town] == 1: break rt.append(town) chk[town] = 1 town = A[town-1] if K <= rt.index(town): print(rt[K-1]) else: roop = (K-rt.index(town)) % (len(rt)-rt.index(town)) print(rt[rt.index(town)+roop])" p02684,s389821598,Wrong Answer,"n,k = map(int,input().split()) a = [int(x) for x in input().split()] num = 0 for _ in range(k): num = a[num-1] print(a[num-1])" p02684,s186800501,Wrong Answer,"n,k = list(map(int, input().split())) a = list(map(int, input().split())) def has_duplicates(seq): return len(seq) != len(set(seq)) visited = [0] flag = False loopStart = 0 loopCycle = 0 for i in range(n): visited.append(a[visited[-1]]-1) if has_duplicates(visited): flag = True loopStart = visited.index(visited[-1]) loopCycle = len(visited) - 1 - loopStart break if i == k - 1: print(visited[i+1]+1) break if flag: print(visited[k % loopCycle]+1)" p02684,s143997011,Wrong Answer,"# coding: utf-8 # Your code here! n,k = map(int,input().split()) a = list(map(int,input().split())) ans = [] check = {} key = -1 p = 0 while True: ans.append(p) check[p] = 0 p = a[p]-1 if p in check: key = ans.index(p) break r = ans[key:] mod = (k-key)%len(r) print(r[mod])" p02684,s358778539,Wrong Answer,"N,K=map(int,input().split()) A=[0]+list(map(int,input().split())) counter=1 now=1 gone_set={1} gone_list=[1] place=1 while counter<=N: next=A[now] if next in gone_set: start=gone_list.index(next) loop=len(gone_list)-start last=(K-start)%loop place=gone_list[start+last] break else: gone_set.add(next) gone_list.append(next) now=next counter+=1 print(place) " p02684,s791634889,Wrong Answer,"n, k = map(int, input().split()) a = list(map(int, input().split())) done = [0]*n stay = 1 for i in range(1, k+1): if done[stay-1] != 0: break done[stay-1] = i stay = a[stay-1] #print(stay) nokori = k + 1 - i loop = i - done[stay-1] for i in range(nokori%loop): stay = a[stay-1] print(stay)" p02684,s781029614,Wrong Answer,"import sys import time N, K = map(int, input().split()) town_list = list(map(int, input().split())) queue = {} start = -1 count = 1 now_town = 1 for i in range(N): if town_list[now_town - 1] in queue: start = town_list[now_town - 1] break queue[town_list[now_town - 1]] = count now_town = town_list[now_town - 1] count += 1 if start == -1: print(queue[now_town]) sys.exit() roop = len(queue) - (queue[start] - 1) before_len = len(queue) - roop print(list(queue.keys())[(K - before_len) % roop + before_len - 1]) " p02684,s410145878,Wrong Answer,"N,K = map(int,input().split()) A = list(map(int,input().split())) n = 1 B = [0]*N for i in range(2*N+1): B[n-1] = i+1 n = A[n-1] if B[n-1] != 0: t = i+2 break c = t-B[n-1] s = (K+1-B[n-1])%c for i in range(s): n = A[n-1] print(n)" p02684,s645057904,Wrong Answer,"n, k = map(int, input().split()) a = [0] + [int(i) for i in input().split("" "")] b = [0,1] + [0]*(n-1) c = ""1"" nex = 1 for i in range(1,n+1): nex = a[nex] if b[nex] == 1: whe = c.index(str(nex)) lo = len(c)-whe break b[nex] = 1 c += str(nex) if whe+1 >= k: print(c[k]) else: k_ = k - whe print(c[whe:][k_%lo])" p02684,s474765028,Wrong Answer,"n,k = list(map(int, input().split())) a = list(map(int, input().split())) d = a[0] b = [d] for i in range(k): dn = a[d-1] if b[0]!=dn: d = dn b.append(d) else: break print(b[k%len(b)]) " p02684,s171989473,Wrong Answer,"N, K = map(int, input().split()) A = input().split() A = [int(a) for a in A] S = [] a = 1 number = 0 numbers=[-1 for _ in range(N)] for _ in range(N + 1): b = A[a - 1] if numbers[b-1] != -1: c=numbers[b-1] break numbers[b-1]=number number += 1 S.append(b) a = b T = S[c:number] if K <= number: S.insert(0,1) print(S[K - 1]) else: z = K - c - 1 y = z % (number - c) print(T[y]) " p02684,s177730645,Wrong Answer,"N, K = map(int, input().split()) A = list(map(int, input().split())) T = [] a = A[0] while a not in T: T.append(a) a = A[a-1] T_index = T.index(a) p = (K-T_index)%(len(T)-T_index) if K <= T_index: print(T[T_index-1]) else: if p == 0: print(T[-1]) else: print(T[T_index + p - 1])" p02684,s761333054,Wrong Answer,"N, K = map(int, input().split()) A = list(map(int, input().split())) l = [0 for _ in range(N)] now = 0 l[now] = 1 count = 0 loop = [0] while count < K: count += 1 now = A[now]-1 loop.append(now) if l[now] == 1: loop = loop[loop.index(now):-1] break else: l[now] = 1 if count == K: print(now + 1) else: ans = loop[K % len(loop)] print(ans + 1) " p02684,s030850476,Wrong Answer,"n,k,*a=map(int,open(0).read().split()) v=[0]+[-1]*~-n p=0 for i in range(n): t=a[p]-1 if v[t]>=0: l,r=v[t],i+1; break v[t]=i+1; p=t print([k,v.index(l+(k-l)%(r-l))][k>l]+1)" p02684,s210661853,Wrong Answer,"N,K=map(int,input().split()) L=list(map(int,input().split())) cnt=0 i=0 S=[] while not(L[i] in S): S.append(i+1) i=L[i]-1 cnt=cnt+1 S.append(i+1) print(S[K%(cnt+1)])" p02684,s398844595,Wrong Answer,"n,k = map(int, input().split()) a=list(map(int,list(input().split()))) exist = [0] cnt = 1 while(True): if a[exist[-1]-1] in exist: idx = exist.index(a[exist[-1]-1]) exist.append(a[exist[-1]-1]) break exist.append(a[exist[-1]-1]) cnt += 1 k = k-idx d = k % (cnt-idx) print(a[idx+d])" p02684,s755073402,Wrong Answer,"def main(): n,k = map(int,input().split()) a = list(map(int,input().split())) import math r = math.ceil(math.log2(k)) idx = 0 a = [i-1 for i in range(n)] for i in range(r): if (k>>i)&1 == 1: idx = a[idx] a = [a[a[j]] for j in range(n)] print(idx+1) if __name__ == '__main__': main() " p02684,s518529231,Wrong Answer,"N,K = map(int, input().split()) A = [*map(lambda x:int(x)-1, input().split())] index = [-1]*N pre, path_cnt = 0, 0 for i in range(N): if index[pre] >= 0: break else: index[pre] = i path_cnt += 1 pre = A[pre] loops = path_cnt - index[pre] one = index[pre] k = max(0, K-one) % loops for _ in range(k): pre = A[pre] print(pre + 1) " p02684,s082463561,Wrong Answer,"n, k = map(int,input().split()) a = list(map(int,input().split())) s = 0 seen = [False for _ in range(n)] d = [0] cy = -1 while not seen[s]: seen[s] = True s = a[s]-1 if seen[s]: cy = s break d.append(s) if cy == -1: print(d[k-1]) exit() noncyi = d.index(cy) cyi = len(d) - noncyi if k < noncyi: print(d[k-1]) else: k -= noncyi print(d[noncyi + k%cyi]+1)" p02684,s945873018,Wrong Answer,"N, K = map(int, input().split()) A = list(map(int, input().split())) visited = [False]*N path = [0] at = 0 loop = 0 visited[0]=True for i in range(N): at = A[at]-1 if visited[at]==True: loop = i+1-path.index(at) break else: visited[at]=True path.append(at) print(path[(K-path.index(at))%loop+path.index(at)]+1)" p02684,s254777377,Wrong Answer,"n, k = map(int,input().split()) town = list(map(int,input().split())) cnt = 1 step = 1 now = town[0] via = [1] while((now not in via)&(step<=n)): via.append(now) now = town[now -1] cnt += 1 step += 1 loop = via[via.index(now):] print(loop[(k - cnt)%len(loop)])" p02684,s494848992,Wrong Answer,"n, k = map(int, input().split()) a = list(map(int, input().split())) pos = -1 seen = [False] * n last = [0] * n hist = [] cycle = [] i = 0 cnt = 0 while(seen[i] == False): seen[i] = True last[i] = cnt cnt += 1 hist.append(i) ne = a[i]-1 i = ne if (seen[i] == True): pos = i preCircle = len(hist.copy()) cycle = hist[last[pos]:] preCircle = last[pos] if (k < preCircle): print(hist[-k-1] + 1) else: k -= preCircle ans = k % len(cycle) print(cycle[ans] + 1) " p02684,s865252439,Wrong Answer,"N,K = map(int, input().split()) A = list(map(int, input().split())) limit = K now = 1 log = [] count = 1 while limit >= 0 and now not in log: if 1 not in log: log.append(1) #print(""通過1"",now,limit,log) now = A[now - 1] log.append(now) limit -= 1 count += 1 if limit >= 0: #print(""通過2"",now,limit,log) log2 = log[log.index(now):] limit = limit % len(log2) while limit >= 0: #print(""通過3"",now) now = A[now - 1] limit -= 1 print(now) " p02684,s731323254,Wrong Answer,"n, k = map(int, input().split()) A = list(map(int, input().split())) if k > n: idx = (k%n)-1 else: idx = k print(A[A[idx] - 1])" p02684,s786197697,Wrong Answer,"n,k = map(int, input().split()) a = [0] + list(map(int, input().split())) r = [1] k += 1 now = 1 for i in range(n): now = a[now] if now in r: break r.append(now) I = r.index(now) if I != 0: k -= I r = r[I:] print(r[-1] if k%len(r)==0 else r[k%len(r)-1])" p02684,s841846281,Wrong Answer,"n,k=map(int,input().split()) ai = list(input().split()) i = (k%n)-1 a=int(ai[i])-1 print(ai[a])" p02684,s031612804,Wrong Answer,"n,k = map(int,input().split()) A = list(map(int,input().split())) dp = [0] * (n+1) B = [] f = 1 c = 1 ans = n bal = 0 for i in range(n): if dp[f-1]: ans = c-dp[f-1] bal = dp[f-1] break else: dp[f-1]+=c B.append(f) f = A[f-1] c+=1 bal-=1 k-= bal # print(B,bal) k = k%ans print(B[k+bal])" p02684,s084475198,Wrong Answer,"import math n, k = map(int, input().split("" "")) li = list(map(int, input().split("" ""))) crnt = 1 st = set() wl = [] key = crnt cy = 0 mg = 0 for i in range(n): if crnt in st: key = crnt cy = i - wl.index(crnt) mg = wl.index(crnt) break st.add(crnt) wl.append(crnt) crnt = li[crnt - 1] k -= mg if cy != 0: k %= cy crnt = key for i in range(k): crnt = li[crnt - 1] print(crnt) " p02684,s440063765,Wrong Answer,"n, k = map(int, input().split()) a = list(map(int, input().split())) l = [] ne = a[0] - 1 for i in range(2 * n + 1000): ne = a[ne] - 1 if ne in l: break l.append(ne) print(l[(k + 1) % len(l)] + 1)" p02684,s334841619,Wrong Answer,"n,k=map(int,input().split()) a=list(map(int,input().split())) for i in range(n): a[i]-=1 #print(a) b=0 c=[-1]*n c[0]=0 for i in range(n): # print(b,a[b]) b=a[b] if c[b]>=0: # print(""i:"",i) break else: c[b]=i+1 ki=c[b]+1 kc=(i+1)-c[b] k2=(k-ki)%kc+ki #print(""ki:"",ki,""kc:"",kc,""k2:"",k2) b=0 for i in range(k2): b=a[b] print(b+1)" p02684,s564672405,Wrong Answer,"n, k = map(int, input().split()) towns = list(map(int, input().split())) place_count = [0] * (n + 1) next_place = 1 teleport_count = 0 for i in range(n * 2): place_count[next_place] += 1 next_place = towns[next_place - 1] one_move_place = place_count.count(1) for place in place_count: if place > 1: teleport_count += 1 next_place = 1 for _ in range(one_move_place + (k - one_move_place) % teleport_count): next_place = towns[next_place - 1] print(next_place)" p02684,s183958157,Wrong Answer,"n, k = map(int, input().split()) a = list(map(int, input().split())) m = [-1]*n t = 0 i = 0 while True: if m[t] != -1: r = i - m[t] break m[t] = i t = a[t]-1 i += 1 c = r while True: if c > m[t]: break c += c b = k%r + c b t = 0 for i in range(b): t = a[t]-1 print(t+1)" p02684,s443100158,Wrong Answer,"n,k=map(int,input().split()) a=list(map(int, input().split())) iti=1 count=0 sokuseki=[0]*n while True: iti=a[iti-1] count+=1 if sokuseki[iti-1]: m=((k-count)//(count-sokuseki[iti-1])) k=k-count-m*(count-sokuseki[iti-1]) count=0 sokuseki[iti-1]+=count if count==k: print(iti) exit()" p02684,s720422053,Wrong Answer,"N,K = (int(x) for x in input().split()) A = list(map(int, input().split())) route = [] temp = 0 for i in range(N): route.append(temp) temp = A[temp]-1 if temp == 0: break if K >= len(route): print(route[K%len(route)]+1) else: print(route[K]+1)" p02684,s033857239,Wrong Answer,"import sys N, K = map(int, input().split()) A = list(map(int, sys.stdin.readline().split())) visited = [0] * N visited[0] = 1 ikisaki = 0 c = 1 while c < N: ikisaki = A[ikisaki] - 1 c += 1 if visited[ikisaki]: loop = c - visited[ikisaki] c = N else: visited[ikisaki] = c amari = (K - (visited[ikisaki] - 1)) % loop new = [i - visited[ikisaki] for i in visited] print(new.index(amari) + 1) " p02684,s980354437,Wrong Answer,"from collections import defaultdict n,k=map(int, input().split()) A=[int(i)-1 for i in input().split()] now=0 loop=[] dd = defaultdict(int) while k!=0: k-=1 now = A[now] if dd[now]>0: break else: dd[now]+=1 if k==0: print(now) exit() loop.append(now) loop = loop[loop.index(now):] loop.append(now) t = len(loop)-1 a=(k%t) while a>0: a-=1 now = A[now] print(now+1) " p02684,s017686562,Wrong Answer,"n,k= map(int,input().split()) A = [0] A += list(map(int,input().split())) B = [-1 for _ in range(n+1)] B[1] = 0 now =1 cnt = 0 cic = 0 for i in range(1,n+1): now = A[now] cnt +=1 if B[now] ==-1: B[now] = cnt else: cic = cnt - B[now] road = B[now] break if k <= road: print(B.index(k)+1) else: print(B.index(((k-road)%cic+road)))" p02684,s752704833,Wrong Answer,"paramN, paramK = list(map(lambda x: int(x), input().split(' '))) paramA = list(map(lambda x: int(x), input().split(' '))) route = [1] for i in range(paramN): route.append(paramA[route[len(route) - 1] - 1]) loop_start = 0 for i, r in enumerate(route): if r in route[:i]: loop_start = i break x = route[loop_start] loop_start_0 = route.index(x) y = paramK - loop_start_0 z = y % (loop_start - loop_start_0) print(route[loop_start_0 + z])" p02684,s459063954,Wrong Answer,"N, M = map(int, input().split()) P = [i -1 for i in map(int,input().split())] ss = set([]) point = 0 for i in range(N): if point in ss: break ss.add(point) point = P[point] S = [0] points = 0 for i in range(len(ss)-1): points = P[points] S.append(points) loop = S[S.index(points):] ll = len(S) l = len(loop) if ll > M: print(S[M]+1) elif ll == M: print(points) else: print(loop[(M-ll)%l]+1) " p02684,s034471399,Wrong Answer,"n,k=map(int,input().split()) A = list(map(int,input().split())) C=[0]*n C[0]=1 c=0 loopc=0 i=0 while i=3 : rs=newi break elif C[newi]==2 : loopc+=1 i=newi c+=1 mod = (k-(c-loopc))%(loopc+1) # print( C, c, loopc, mod) i=rs while mod>0 : newi = A[i]-1 i=newi mod-=1 print( i+1 ) " p02684,s718892332,Wrong Answer,"n, k = map(int, input().split()) num = list(map(int, input().split())) t = [-1] * n count = 0 s = 1 while t[s - 1] == -1: if count == k: break t[s - 1] = count count += 1 s = num[s - 1] else: print(t.index(t[s - 1] + ((k - t[s - 1]) % (count - t[s - 1]))) + 1) " p02684,s181102364,Wrong Answer,"n,k=map(int,input().split()) A = [int(v)-1 for v in input().split()] t = 0 done = [t] itvl = 1 st = 1 for i in range(k): t=A[t] if t in done: itvl = i + 1 - done.index(t) for j in range((k - i - 1)%itvl): t=A[t] print(t+1) exit() done.append(t)" p02684,s200519815,Wrong Answer,"def main(): n,k = map(int, input().split()) a = list(map(int, input().split())) t = 1 ans = [1] while True: if a[t-1] in ans : start = ans.index(a[t-1]) break ans.append(a[t-1]) t = a[t-1] if k > (len(ans)-start): index = k % (len(ans)-start) t = ans[index] else: t = ans[k] return print(t) if __name__ == '__main__': main() " p02684,s764058577,Wrong Answer,"from collections import defaultdict as d n, k = map(int, input().split()) arr = list(map(int, input().split())) s = '1' i = 1 while True: if str(arr[i - 1]) in s: s += str(arr[i - 1]) break s += str(arr[i - 1]) i = arr[i - 1] if k <= s.index(s[-1]): print(s[k]) else: k -= (s.index(s[-1])) x = len(s) - s.index(s[-1]) - 1 print(s[s.index(s[-1]):-1][k%x])" p02684,s977168881,Wrong Answer,"n,k=map(int,input().split()) a=[int(i) for i in input().split()] senni=[1] dabu=False while dabu == False: if a[senni[-1]-1] in senni: dabu = True t=len(senni)-(senni.index(a[senni[-1]-1])) break senni.append(a[senni[-1]-1]) if t<=k and k%t < senni.index(a[senni[-1]-1]): ans = senni[k%t+t] else: ans=senni[k%t] print(ans)" p02684,s247531113,Wrong Answer,"N, K = map(int, input().split()) M = list(map(lambda x: int(x)-1, input().split())) s = 0 order = [s] sets = set(order) while True: if M[s] in sets: #print(order, M[s]) if K < order.index(M[s]): print(order[K-1]+1) else: K -= order.index(M[s]) order = order[order.index(M[s]):] print(order[K%len(order)]+1) break order.append(M[s]) sets.add(M[s]) s = M[s] " p02684,s328128245,Wrong Answer,"N, K = map(int, input().split()) where_go = list(map(int, input().split())) now = 0 PATH = [] start = 0 roop = 0 count = 0 while now not in PATH and count < K: PATH.append(now) now = where_go[now] - 1 count += 1 if count < K: start = PATH.index(now) roop = len(PATH) - start K = (K - start) % roop while count < K: now = where_go[now] - 1 count += 1 print(now+1) " p02684,s542601116,Wrong Answer,"import numpy as np n,k=map(int,input().split()) twon=np.zeros(n) twon=list(map(int,input().split())) data=twon[0] array=[-1]*n array[0]=1 count=0 for i in range(1,k): if array[data-1]==-1: array[data-1]=i+1 else: count=(k-i-1)%(i+1-array[data-1]) array=[-1]*n count=k-count data=twon[data-1] if count!=0: break for j in range(count,k): data=twon[data-1] print(data)" p02684,s631370852,Wrong Answer,"import sys N,K = map(int,input().split()) tele = list(map(int,input().split())) k = 1 goal = tele[0] miti = [1] while (goal in miti)!=1: k += 1 miti.append(goal) goal = tele[goal-1] if k == K: goal = tele[goal-1] print(goal) sys.exit() a = miti.index(goal) loop = k-a ans = miti[(K-a)%loop+a] print(ans) " p02684,s050275589,Wrong Answer,"n,k = map(int,input().split()) a = list(map(int,input().split())) tt = [False] * n tt[0] = True ans_l = [1] i = 1 while True: i = a[i-1] if tt[i-1] == False: tt[i-1] = 1 ans_l.append(i) else: break d = ans_l.index(i) k -= d ans = k % (len(ans_l)-d) print(ans_l[ans+d]) " p02684,s942565976,Wrong Answer,"import numpy as np N,K = map(int,input().split()) A = np.array(list(map(int,input().split()))) num = 0 position = 1 ok = False position_list = np.array([]) for i in range(N): position = A[position -1] if position in position_list and ok == False: former = list(zip(*np.where(position_list == position)))[0][0] later = position ok = True position_list = np.append(position_list,position) step = later - former mod = (K - 1 - former) % step print(int(position_list[former + mod]))" p02684,s795459939,Wrong Answer,"#!/usr/bin/env python3 # atcoder # Türkçe konuşyorum # Türkler var mı n, k = map(int, input().split("" "")) val = list(map(int,input().split("" ""))) dico = {} i = 0 #for j in range(len(val)): #val = int(input().split("" "")) # dico[j] = val[j] #print(dico) while k >= 1: if not i < n: i = 0 i += 1 k -= 1 print(val[i+1]) " p02684,s290363479,Wrong Answer,"n,k= list(map(int, input().split())) li= list(map(int, input().split())) c=[1] nex=1 first=0 for i in range(k): nex=li[nex-1] if nex in c: first=c.index(nex) break c.append(nex) if first: k-=first k%=len(c)-first print(c[first+k]) else: print(c[-1]) " p02684,s637829114,Wrong Answer,"import collections n,k=map(int,input().split()) a=list(map(int,input().split())) L=[1] count=1 nowt=1 roops=0 v=[False]*n while(True): if v[a[nowt-1]-1]==True: roops=a[nowt-1] break L.append(a[nowt-1]) v[a[nowt-1]-1]=True nowt=a[nowt-1] count+=1 play=0 for i in range(len(L)): if L[i]==roops: break play+=1 rooplen=len(L)-play ans=L[play+(k-play)%rooplen] print(ans)" p02684,s758471362,Wrong Answer,"n,k = map(int,input().split()) a = list(map(int,input().split())) tt = [0] * n tt[0] = 1 ans_l = [1] i = 1 c = 0 while True: # if c == k: # break c += 1 i = a[i-1] if tt[i-1] == False: tt[i-1] = 1 ans_l.append(i) else: break #print(c,k) d = ans_l.index(i) k -= d ans = k % (len(ans_l)-d) print(ans_l[ans+d]) " p02684,s639518638,Wrong Answer,"n,k=map(int,input().split()) A=list(map(int,input().split())) C=[0] now=0 for i in range(n): now=A[now]-1 if now==0: break C.append(now) L=len(C) print(C[k%L]+1)" p02684,s578366304,Wrong Answer,"N,K = [int(i) for i in input().split()] A = [int(i)-1 for i in input().split()] place = [0] for _ in range(N-1): place.append(A[place[-1]]) a = place.index(place[-1])+1 K = a + ((K-a)%(N-a)) print(place[K]+1) " p02684,s348182978,Wrong Answer,"n,k=map(int,input().split()) li=list(map(int,input().split())) H=[0]*(n) walk=[] x=1 l=0 while l==0: walk.append(x) if H[x-1]==0: H[x-1]=1 else: dd=[i for i, j in enumerate(walk) if j == x ] l=1 x=li[x-1] ran=dd[1]-dd[0] k-=dd[0] kk=k%ran print(walk[dd[0]+kk])" p02684,s840717661,Wrong Answer,"n, k = map(int, input().split()) tele = list(map(int, input().split())) reached = [-1 for _ in range(n + 1)] now = 1 count = 0 reached[1] = 0 cycle = False while cycle == False: now = tele[now - 1] #current town count += 1 if reached[now] == -1: reached[now] = count else: cycle = True roop_long = count - reached[now] from_roop_in_town = (k - reached[now]) % roop_long #print(reached, now, roop_long, from_roop_in_town) for i in range(from_roop_in_town): now = tele[now - 1] print(now)" p02684,s567165460,Wrong Answer,"n, k = map(int, input().split()) a = list(map(lambda x: int(x)-1, input().split())) num = 0 li = [0] flag = [True] * n flag[0] = False while True: num = a[num] if flag[num]: li.append(num) flag[num] = False else: break d = li.index(num) ans = (k-d)%(len(li)-d)+d print(li[ans]+1)" p02684,s629002219,Wrong Answer,"n,k = map(int,input().split()) A = [0]+list(map(int,input().split())) visited = [False for _ in range(n+1)] pos = 1 x = [] flg = False for i in range(k): if visited[pos] == False: x.append(pos) visited[pos] = True pos = A[pos] else: flg = True pre = x.index(pos) loop = x[pre:] break print(loop[(k-pre)%len(loop)] if flg else x[-1])" p02684,s138997166,Wrong Answer,"n,k=map(int,input().split()) A=tuple(map(int,input().split())) s=1 state=[s] count={} for i in range(k+1): s=A[s-1] if s in count: start=state.index(s) end=len(state) print(state[start+(k-start)%(end-start)]) break else: count[state[i]]=i state.append(s) else: print(s) " p02684,s918718881,Wrong Answer,"N,K= list(map(int, input().split())) A= list(map(int, input().split())) path = [0]*N a = 0 for j in range(N+1): a = A[a]-1 if path[a]!= 0: c = j+1-path[a] break else: path[a] = j+1 mod = K%c print(path.index(mod)+1) " p02684,s865968244,Wrong Answer,"n,k = map(int,input().split()) a_list = list(input().split()) dum = a_list[0] k = k - 1 ans_list = a_list[0] while(1): if k == 0: print(dum) exit() dum = a_list[int(dum)-1] ans_list = ans_list + dum k = k - 1 if ans_list.count(dum) == 1: break #print(ans_list) ind = ans_list.index(dum) loop = ans_list[ind:] len_loop = len(loop) loop_after = (k)%len_loop print(loop[loop_after-1]) " p02684,s196023336,Wrong Answer,"N, K = map(int, input().split()) A = list(map(int, input().split())) A = [0] + A # Dに何回目の移動で到達したか記録してみるか D = [[] for _ in range(N+1)] now = 1 i = 0 j = True while i < K: now = A[now] D[now].append(i) if j and len(D[now]) > 2: length = D[now][2] - D[now][1] i = K - ((K - i) % length) - 1 j = False i += 1 print(now) " p02684,s756182785,Wrong Answer,"N,K = map(int,input().split()) A = list(map(int,input().split())) c = 0 tmp = 1 List = [] List2 = [0] * N for i in range(N): List.append(A[tmp-1]) tmp = List[i] if(List2[tmp-1] >= 1): tmp2 = List2[List[i]-1]-1 List.pop(-1) break else: c += 1 List2[tmp-1] = i+1 List3 = List[tmp2:] l = len(List3) if(c%l == 0): print(List3[(K%l)-1]) else: print(List3[((K%l)+(c%l))%l])" p02684,s510372099,Wrong Answer,"n,k=map(int,input().split()) a=list(map(int,input().split())) ok=set() now=0 l=[] while now not in ok and k: l.append(now) ok.add(now) now=a[now]-1 k-=1 if k==0:print(now+1);exit() length=len(ok)-(h:=l.index(now)) l=l[h:] print(l,h,length) k=(k)%length print(l[k]+1)" p02684,s255851700,Wrong Answer,"n, k = map(int, input().split()) a = list(map(int, input().split())) time = 0 roop = [1] while(len(set(roop)) == len(roop)): roop.append(a[roop[-1]-1]) first = roop.index(roop[-1]) roop.pop(-1) if(first != 0): atama = len(roop) - first print(atama) gachiroop = roop[atama-1:] print(gachiroop[(k-atama+1)%len(gachiroop)]) else: print(roop[k%len(roop)]) " p02684,s520076658,Wrong Answer,"N,K = map(int,input().split()) A = list(map(int,input().split())) visited = [0]*N i = 0 rootin = [0]*N rootin[0] = 1 count = 0 for _ in range(N): count += 1 visited[i] += 1 if visited[i] == 2: end = count-1 break rootin[count] = A[i] i = A[i]-1 start = 0 for i in range(N): if rootin[i] == rootin[end]: start = i break od = len(rootin[:start]) root = len(rootin[start:end]) if K > od: K -= od ans = rootin[start+K%root] else: ans = rootin[K-1] print(ans)" p02684,s684373120,Wrong Answer,"from collections import deque n, k = map(int, input().split()) a_list = list(map(int, input().split())) route = [] roop = [] pos = 1 while k > 0: pos = a_list[pos-1] if pos in route: if pos in roop: k -= k % (k * (k // len(roop))) roop.append(pos) else: roop = [] route.append(pos) k -= 1 print(pos) " p02684,s653170829,Wrong Answer,"n, k = map(int, input().split()) towns = [int(s) for s in input().split()] pos = [] pos_set = set() cur = towns[0] while not cur in pos_set: pos.append(cur) pos_set.add(cur) cur = towns[cur-1] j = pos.index(cur) print(pos[(k-j-1)%(len(pos)-j) + j]) " p02684,s423207630,Wrong Answer,"import sys n, k = map(int, input().split()) A = list(map(int, input().split())) route = [] route = [1] appearance = set() index = 1 flg = False for _ in range(n * 10): if index in appearance: flg = True break appearance.add(index) next_city = A[index - 1] route.append(next_city) index = next_city if flg is False: print(route[k-1]) sys.exit() # 繰り返し個数 duplicate = route[route.index(index):len(route) - 1] print(duplicate[(k - route.index(index)) % (len(duplicate))]) " p02684,s217880435,Wrong Answer,"n,k = map(int,input().split()) A = list(map(int,input().split())) visited = [False for _ in range(n)] nx = A[0] - 1 x = [] p = -1 for e, i in enumerate(range(n)): if visited[nx] == False: visited[nx] = True x.append(nx) nx = A[nx] - 1 else: p = x.index(nx) q = x[:p] r = x[p:] break if p!=-1: k = (k-len(q))%len(r) print(r[k-1]+1) else: print(x[k-1]+1)" p02684,s442758531,Wrong Answer,"N, K = map(int, input().split()) A = list(map(int, input().split())) journey = [1] dup = {} for i in range(N+10000): journey.append(A[journey[-1] - 1]) end_idx, start_idx = 0, 0 dup = {} for i, j in enumerate(journey): if j in dup: end_idx = i break else: dup[j] = 0 for i, j in enumerate(journey): if j == journey[end_idx]: start_idx = i break b = end_idx - start_idx m = (K - start_idx) % b print(journey[start_idx + m])" p02684,s761298209,Wrong Answer,"n,k=map(int,input().split()) a=list(map(int,input().split())) s=[0 for i in range(n)] i=0 s[i]=1 while s.count(s[i])==1: i+=1 s[i]=a[s[i-1]-1] l=[j for j, x in enumerate(s) if x == s[i]] x=l[1]-l[0] y=(k-l[0])%x print(s[l[0]+y])" p02684,s177000443,Wrong Answer,"N, K = map(int, input().split()) d = dict() for i, a in enumerate(input().split()): d[i+1] = int(a) a = [] j = 1 for k in range(K): j = d[j] if j in a: hh = a.index(j) aaa = (K - k) % (k - hh) print(a[hh + aaa - 1]) exit() else: a.append(j) " p02684,s629755101,Wrong Answer,"n,k = map(int,input().split()) a = list(map(int,input().split())) lis = [1] for i in range(n): lis.append(a[lis[i]-1]) for j in range(1,n): if len(set(lis[:j]).intersection(set(lis[j:]))) != 0: roopstartind = j-1 break for j in range(roopstartind+1,n): if lis[j] == lis[roopstartind]: roopendind = j break rooplen = roopendind - roopstartind nokori = k-roopstartind print(lis[roopstartind + (nokori%rooplen)])" p02684,s921227504,Wrong Answer,"n,k=map(int,input().split()) a=list(map(int,input().split())) p=k%n o=a[0]-1 for i in range(p): o=a[o] print(o)" p02684,s277628589,Wrong Answer,"n,k = map(int,input().split()) A = list(map(int,input().split())) dp = [0] * (n+1) B = [] f = 1 c = 1 for e,i in enumerate(A,1): if dp[f-1]: ans = e-dp[f-1] bal = dp[f-1] break else: dp[f-1]+=c B.append(f) f = A[f-1] c+=1 bal-=1 k-= bal+1 # print(B,bal) k = (k%ans+1)%ans print(B[k+bal])" p02684,s287414503,Wrong Answer,"N,K = map(int, input().split()) A = list(map(int, input().split())) limit = K now = 1 log = [] while limit > 0 and now not in log: if 1 not in log: log.append(1) #print(""通過1"",now,limit,log) now = A[now - 1] log.append(now) limit -= 1 if limit > 0: #print(""通過2"",now,limit,log) limit = limit % len(log[log.index(now) - 1:]) while limit > 0: #print(""通過3"",now) now = A[now - 1] limit -= 1 now = A[now - 1] print(now) " p02684,s902474875,Wrong Answer,"a = raw_input().split() n = int(a[0]) k = int(a[1]) a = raw_input().split() m = [] i = 0 while 1: if i in m: break m.append(i) i = int(a[i]) - 1 l = len(m) s = m.index(i) res = (k - s) % (l - s) print m[res + s] + 1 " p02684,s296035558,Wrong Answer,"n, k = map(int, input().split()) a_list = list(map(int, input().split())) list_order = [] already = [1] idx = 0 for i in range(1, k + 1): next_city = a_list[idx] list_order.append(next_city) idx = next_city - 1 if next_city in already: break already.append(next_city) if idx == 0: break print(list_order[(k % i) - 1]) " p02684,s348388581,Wrong Answer,"import numpy as np N, K = map(int, input().split()) A = np.array(list(map(int, input().split()))) A -= 1 flg = [False for _ in range(N)] loop = 0 town = [] i = 0 while flg[i] == False: town.append(i) flg[i] = True i = A[i] loop += 1 else: s = i to_s = town.index(s) loop -= to_s print(town[(K - to_s) % loop + to_s] + 1)" p02684,s730541369,Wrong Answer,"# coding: utf-8 # Your code here! import copy N, K = map(int, input().split()) List = list(map(int, input().split())) saki=[1] ato=[] i=0 j=1 while i0: R=D[P] break D[P]=c if P==0: break L[c]=P #print(L) K-=R K%=(c-R) #print(R,K) ans=L[R+K]+1 print(ans)" p02684,s695034338,Wrong Answer,"def main(): N,K = map(int,input().split()) A = map(int,input().split()) doubling = [[0]*(N+1) for _ in range(60)] for i,a in enumerate(A): doubling[0][i+1] = a for i in range(1,60): for j in range(1,N+1): doubling[i][j] = doubling[i-1][doubling[i-1][j]] t = 1 for c in bin(K)[2:]: t = doubling[int(c)][t] print(t) main() " p02684,s957856779,Wrong Answer,"n,k=map(int,input().split(' ')) a=list(map(int,input().split(' '))) loc=1 begin=0 end=0 d={} for i in range(n): 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 !=0: k=(k-begin+1)%(end-begin)+begin-1 loc=1 for _ in range(k): loc=a[loc-1] print(loc)" p02684,s823643691,Wrong Answer,"n, k = map(int, input().split()) a = list(map(int, input().split())) now = [1] ans =1 for i in range(2*n): if a[now[i]-1] in now: break now.append(a[now[i]-1]) t = len(now)-now.index(a[now[i]-1]) f = now.index(a[now[i]-1]) if k >= f + t: p = (k-f)%t k = f + p for i in range(k): ans = a[ans] print(ans)" p02684,s709988184,Wrong Answer," N, K = map(int, input().split()) S = list(num-1 for num in map(int, input().split())) loc = 0 arrived = [0]*N ar = set() cnt = 0 while not loc in ar: arrived[cnt] = loc ar.add(loc) loc = S[loc] cnt += 1 if K < cnt: print(arrived[K-1]) else: for i in range(cnt): if arrived[i] == loc: K -= i roop = cnt-i K %= roop print(arrived[i+K]+1) break" p02684,s566675713,Wrong Answer,"N, K = map(int, input().split()) A = list(map(int, input().split())) cnt = 0 visited = [] next = 1 while True: present = next cnt += 1 visited.append(present) next = A[present-1] if next in visited: ind = visited.index(next) l = len(visited[ind:]) break rest = (K-cnt) % l present = visited[ind + rest] print(present) " p02684,s891354199,Wrong Answer,"n,k=map(int, input().split()) a=[int(x)-1 for x in list(input().split())] way=[0] noappear=[i for i in range(n)] while True: way.append(a[way[-1]]) if bool(way[-1] in noappear)==False: break noappear.remove(way[-1]) last=way[-1] st=way.index(last) en=len(way)-1 step=en-st rest=k%step if k>=en: ans=way[rest]+1 else: ans=way[k]+1 print(ans) " p02684,s929740840,Wrong Answer,"N,K=map(int, input().split()) A = list(map(int, input().split())) A = [0] + A visited = [1] now = 1 while True: next = A[now] if next in visited: break visited.append(next) now = next initial = visited.index(next) cycle = len(visited[initial:]) residual = (K - initial) % cycle print(visited[initial+residual])" p02684,s631352610,Wrong Answer,"N, K = list(map(int, input().split())) A = list(map(int, input().split())) loop = [0] for _ in range(K): if A[loop[-1]]-1 not in loop: loop.append(A[loop[-1]]-1) else: break l = len(loop) print(loop[K % l]+1)" p02684,s714597640,Wrong Answer,"n, k = map(int, input().split()) a = list(map(int, input().split())) for i in range(n): a[i] -= 1 d = {0} p = 0 while not a[p] in d: d.add(a[p]) p = a[p] #print(d) val = [0] p = 0 for i in range(len(d)): val.append(a[p]) p = a[p] #print(val) cnt = 0 p = 0 while val[p] != val[-1]: cnt += 1 p += 1 del val[-1] k -= cnt k += 1 k2 = k % (len(d)-cnt) #print(k2) #print(cnt) print(val[cnt + k2-1]+1) " p02684,s398947691,Wrong Answer,"n, k = map(int, input().split()) a = list(map(int, input().split())) p = 1 t = [1] u = set() for i in range(k): p = a[p - 1] if p not in u: t.append(p) u.add(p) else: break c = t.index(p) r = len(t) - c s = len(t) - r ans = t[(k - s + 1) % r + s - 1] print(ans)" p02684,s285282730,Wrong Answer,"n, k = map(int, input().split()) a = list(map(int, input().split())) for i in range(n): a[i] -= 1 visited = [0 for _ in range(n)] i = 0 while visited[i] == 0: visited[i] = 1 i = a[i] cnt = 0 goal = i i = goal while not (i == goal and cnt > 0): i = a[i] cnt += 1 i = 0 while i != goal: k -= 1 i = a[i] k = k % cnt i = goal for cnt in range(k): i = a[i] print(i+1)" p02684,s558753913,Wrong Answer,"n,k=map(int,input().split()) A=[0]+list(map(int,input().split())) reached=[1] i=1 for k in range(n): if not A[i] in reached: reached.append(A[i]) i=A[i] else: t1=reached.index(A[i]) t2=k+1 break #print(reached) ama=(k-t1)%(t2-t1) #print(t1,t2,ama) print(reached[t1+ama])" p02684,s853901191,Wrong Answer,"N , K = map(int,input().split()) B = {} C = {} D = {0} A = list(map(int,input().split())) place = 0 num = 0 C[0] = 0 while True: place = int(A[place]) - 1 num += 1 if place in D: Y = int(num) - int(C[place]) break elif num == K: break else: B[num] = place C[place] = num D.add(place) try: X = (K - num) % Y print(B[C[place] + X] + 1) except: print(A[place]+1) " p02684,s130204052,Wrong Answer,"n, k = map(int, input().split()) a = list(map(int, input().split())) p = 1 t = [1] u = set() for i in range(n): p = a[p - 1] if p not in u: t.append(p) u.add(p) else: break c = t.index(p) r = len(t) - c s = len(t) - r ans = t[(k + 1 - s) % r + s - 1] print(ans)" p02684,s869782365,Wrong Answer,"n,k = map(int,input().split()) A = list(map(int,input().split())) visited = [False for _ in range(n)] nx = A[0] - 1 x = [] p = -1 for e, i in enumerate(range(n)): if visited[nx] == False: visited[nx] = True x.append(nx) nx = A[nx] - 1 else: p = x.index(nx) q = x[:p] r = x[p:] break if p!=-1: k = (k-len(q))%len(r) print(r[k-1]+1) else: print(x[k]+1)" p02684,s949090255,Wrong Answer,"n,k = map(int,input().split()) A = list(map(int,input().split())) B=[1] m=0 j=0 for i in range(1,n+1): B.append(A[m]) m=A[m]-1 if B[i] in B[:i]: M=B[i] break while B[j]!=M: j+=1 T=len(B)-j-1 print(B[k-((k-j)//T)*T])" p02755,s985112151,Accepted,"from math import floor as fl A,B =map(int,input().split()) for i in range(10000): if fl(i * 8 / 100) == A and fl(i / 10) == B: print(i) break else: print(-1)" p02755,s416298543,Accepted,"A,B=map(int,input().split()) ansA=A*(100/8)#この数か、この数よりでかI数となる if ansA==int(ansA):#小数点以下0なら ansA=int(ansA) else: ansA=int(ansA)+1 ansB=B*10#この数か、この数よりでかい数となる if ansA>=ansB: ans=ansA else: ans=ansB if int(ans*(8/100))==A and int(ans*(10/100))==B: print(ans) else: print(-1)" p02755,s232167324,Accepted,"# coding: utf-8 # Your code here! import math a, b = map(int,input().split()) Flg = True for i in range(10**5+2): if int(i * 0.08) == a and int(i * 0.1) == b: print(i) Flg = False break if Flg: print(-1)" p02755,s382177371,Accepted,"import math a, b = (int(x) for x in input().split()) ans = 0 i = 0 ok = False while i < 10000 : case_a = math.floor(i * 0.08) # print(case_a) case_b = math.floor(i * 0.10) # print(case_b) if case_a == a and case_b == b : ans = i ok = True break i = i + 1 if ok == False : ans = -1 print(ans)" p02755,s046442232,Accepted,"import math A, B = map(int, input().split()) min = B * 10 max = B * 10 + 9 flag = False for i in range(min, max + 1): temp = math.floor(i * 0.08) if (temp == A): flag = True ans = i break if flag: print(ans) else: print('-1') " p02755,s075030868,Accepted,"tax_a, tax_b = map(int, input().split()) ans = tax_b * 10 for i in range(9): if int(ans * 0.08) == tax_a: print(ans) break else: ans += 1 else: print('-1') " p02755,s374095335,Accepted,"A,B = list(map(int,input().split())) X = [] mA = int(100/8*A) MA = int(100/8*(A+1))+1 mB = int(10*B) MB = int(10*(B+1))+1 for i in range(max(mA,mB),min(MA,MB)): X.append(i) #print(X) f = True for i in X: if int(i*0.08)==A and int(i*0.1)==B: print(i) f = False break if f: print(-1)" p02755,s454955869,Accepted,"import sys input = lambda: sys.stdin.readline().rstrip() input_nums = lambda: list(map(int, input().split())) a, b = input_nums() a_rate = 0.08 b_rate = 0.1 al = int(a / a_rate) ar = int((a+1) / a_rate) bl = int(b / b_rate) br = int((b+1) / b_rate) ans = 0 if bl <= al and al < br: ans = al elif al <= bl and bl < ar: ans = bl else: ans = -1 if not ans == -1 and int(ans*0.08) < a: ans += 1 if int(ans*0.1) > b: ans = -1 print(ans)" p02755,s329747418,Accepted,"import sys import math read = sys.stdin.readline S = read() a, b = map(int, S.split()) fin = False for i in range(1000+1): if a == math.floor(i * 0.08): if b == math.floor(i * 0.1): print(i) fin = True break if not fin: print(-1)" p02755,s209467985,Accepted,"a,b=map(int,input().split()) i=1 while(1): p=int(i*0.08) q=int(i*0.1) if p==a and q==b: break i+=1 if i>=100000: i=-1 break print(i)" p02755,s151894122,Accepted,"import sys import math input = sys.stdin.readline def main(): A, B = map(int, input().split()) assert A <= 100 assert B <= 100 for i in range(1000): if math.floor((i+1) * 0.08) == A and math.floor((i+1) * 0.1) == B: print(i+1) exit() print(""-1"") if __name__ == '__main__': main() " p02755,s142459697,Accepted,"import math a, b = map(int, input().split()) for i in range(1, 1250): if math.floor(i * 0.08) == a and math.floor(i * 0.1) == b: print(i) exit() else: print(-1)" p02755,s108157559,Accepted,"import math from decimal import * A,B = list(map(int, input().split())) ans = -1 for x in range(1, 10001): a = math.floor(x * Decimal(0.08)) b = math.floor(x * Decimal(0.1)) if a == A and b == B: ans = x break print(ans)" p02755,s103595996,Accepted,"A,B = list(map(int, input().split())) flag = 0 for j in range(1250): if int(j*0.08) == A and int(j*0.10) == B: print(j) flag = 1 break if flag == 0: print(-1) " p02755,s929488311,Accepted,"import sys A,B = map(int,input().split()) sys.setrecursionlimit(2000) def search(x): p = (x*0.08)//1 q = (x*0.10)//1 if p==A and q==B: print(x) exit() elif p > A and q > B: print(-1) else: search(x+1) search(1)" p02755,s954523240,Accepted,"import math a, b = map(int, input().split(' ')) cnt = -1 for i in range(1, 1001): hachi = math.floor(i * 0.08) ju = math.floor(i * 0.1) if hachi == a and ju == b: cnt = i break print(cnt) " p02755,s637077866,Accepted,"def main(): A, B = map(int, input().split()) x = int(A/0.08) y = int((A+1)/0.08) for i in range(x, y+1): if int(i*0.08) == A and int(i*0.1) == B: print(i) return print(-1) main()" p02755,s787015464,Accepted,"a,b = map(int,input().split()) tax1 = int(a/0.08) tax2 = int(b/0.1) en = 0 l = sorted([tax1,tax2]) for i in range(l[0]-1,l[1]+2): if int(i*0.08) == a and int(i*0.1) == b: print(i) en = 1 break if en == 0: print(-1)" p02755,s593231153,Accepted,"import math A,B = map(int,input().split()) flag = 0 for i in range(1,10**5): if math.floor(i*0.08) == A and math.floor(i*0.1) == B: print(i) flag += 1 break if flag == 0: print(-1)" p02755,s357945879,Accepted,"import math n,m = map(int,input().split()) if (n+1)/0.08 > m/0.1 and (m+1)/0.1 > n/0.08: print(max(math.ceil(n/0.08),math.ceil(m/0.1))) else: print(-1) " 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))" 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" p02755,s444100463,Accepted,"# coding:utf-8 A, B = map(int, input().split(' ')) for ans in range(1, 1001): if int(ans * 0.08) == A and int(ans * 0.1) == B: print(ans) exit(0) print('-1') " p02755,s421475536,Accepted,"A,B = map(int,input().split()) abc = -1 for i in range(10000,-1,-1): tax1 = int(i*0.08) tax2 = int(i*0.1) if tax1 == A and tax2 == B: abc = i print(abc)" p02755,s281115152,Accepted,"import math a,b = [int(i) for i in input().split()] mina = math.ceil(a*100/8) if (a+1)*100/8%1==0: maxa = (a+1)*100/8-1 else: maxa = math.floor((a+1)*100/8) minb = math.ceil(b*100/10) if (b+1)*100/10%1==0: maxb = (b+1)*100/10-1 else: maxb = math.floor((b+1)*100/10) #print(mina,maxa,minb,maxb) if minb<=mina and mina<=maxb: print(int(mina)) elif mina<=minb and minb<=maxa: print(int(minb)) else: print(""-1"") " p02755,s809323666,Accepted,"import sys import math input = sys.stdin.readline sys.setrecursionlimit(10**6) def main(): a, b = map(int, input().split()) ans = 2000 for i in range(1, 1001): if a == math.floor((i * 1.08)) - i and b == math.floor((i * 1.10)) - i: ans = min(ans, i) if ans == 2000: print('-1') else: print(ans) main() " p02755,s187920336,Accepted,"import sys A, B = map(int, input().split()) ans = -1 for x in range(1010): a = int((x*0.08)) b = int(x*0.1) if a == A and b == B: print(x) sys.exit() print(ans)" p02755,s150529577,Accepted,"a, b = map(int, input().split()) flag = 0 for i in range(2000): if (i*0.08)//1 == a: if (i*0.1)//1 == b: print(i) flag += 1 break else: if flag == 0: print(""-1"")" p02755,s403199769,Accepted,"a,b=map(int,input().split()) s=0 for i in range(1,1251): if int(i*0.08)==a and int(i*0.1)==b: print(str(i)) s+=1 break if s==0: print(""-1"")" p02755,s433103776,Accepted,"a, b = map(int, input().split()) n = 0 if a * 12.5 < (b+1) * 10 and b * 10 < (a+1) * 12.5: while n < a * 12.5 or n < b * 10: n += 1 else: print(n) else: print('-1')" p02755,s543076593,Accepted,"A, B = map(int, input().split()) A_min = 12.5 * A A_max = 12.5 * (A + 1) B_min = 10 * B B_max = 10 * (B + 1) if A % 2 == 0: myList1 = list(range(int(A_min), int(A_max + 1))) else: myList1 = list(range(int(A_min + 1), int(A_max))) myList2 = list(range(int(B_min), int(B_max))) mySet = list(set(myList1) & set(myList2)) mySet = [item for item in mySet if item >= 1] if len(mySet) == 0: print(-1) else: print(sorted(mySet)[0])" p02755,s579675568,Accepted,"import math answer = 0 score = list(map(int,input().split())) Alist = [] for i in range(2000): if math.floor((i+1)*0.08) == score[0]: Alist.append(i+1) for j in range(2000): if math.floor((j+1)*0.10) == score[1]: if j+1 in Alist: print(j+1) answer = 1 break if answer == 0: print(-1)" p02755,s036114523,Accepted,"a,b=map(int,input().split()) for i in range(10**5): if (i*2)//25==a and i//10==b: print(i) break else: print(-1)" p02755,s744891838,Accepted,"A, B = list(map(int, input().split())) ans = -1 i = 1 while i < 2000: a = int(i * 1.08) - i b = int(i * 1.1) - i if A == a and B == b: ans = i break i += 1 print(ans) " p02755,s743856739,Accepted,"from math import floor A, B = map(int, input().split()) def check(x): if floor(x*0.08) == A and floor(x*0.1) == B: return True return False x = 1 while(x < 1251): if check(x): break x += 1 if x == 1251: print(-1) else: print(x)" p02755,s167733571,Accepted,"a,b=map(int,input().split()) ans=-1 c=int(b*10) d=int((b+1)*10) for i in range(c,d): if int(i*0.08)==a: ans=i break print(ans)" p02755,s005275692,Accepted,"a,b=map(int,input().split()) ans = -1 for i in range(1001): if int(i * 0.08) == a and int(i * 0.1) == b: ans = i break; print(ans)" p02755,s157893549,Accepted,"a, b = map(int, input().split()) for i in range(b*10, (b+1)*10): if int(i * 0.08) == a: print(i) break else: print(-1)" p02755,s547781048,Accepted,"import math a,b=map(int,input().split()) n=math.ceil((a*100)/8) m=int((a*100)/10) result=[] for i in range(m-100,n+100): if math.floor(i*0.08)==a and math.floor(i*0.1)==b: result.append(i) if result==[]: print(-1) exit() print(min(result)) " p02755,s533665457,Accepted,"a, b = map(int, input().split()) ans = -1 for i in range(10000, -1, -1): ans1 = int(i * 0.08) ans2 = int(i * 0.1) if ans1 == a and ans2 == b: ans = i print(ans) " p02755,s233185731,Accepted,"import math a,b=map(int,input().split()) ans=-1 tmp=b*10 for x in range(tmp-20,tmp+20): if math.floor(x*0.08)==a and math.floor(x*0.10)==b: ans=x break print(ans)" p02755,s021729194,Accepted,"from math import floor a, b = [int(i) for i in input().split()] for i in range(1, 10**5): if floor(i*0.08) == a and floor(i*0.1) == b: print(i) exit() print(-1)" p02755,s277826691,Accepted,"A, B = map(int, input().split()) m = -1 for n in range(100001): if A*100 <= 8*n < (A+1)*100 and B*100 <= 10*n < (B+1)*100: m = n break print(m)" p02755,s802670406,Accepted,"import math A,B = map(int,input().split()) ans = """" for i in range(1,1251): a = math.floor(i * 0.08) b = math.floor(i * 0.1) if a == A and b == B: ans = i break print(ans if ans != """" else -1)" p02755,s794052795,Accepted,"import math a,b = list(map(int,input().split())) for i in range(1,1001): if math.floor(i*0.08) == a and math.floor(i*0.1) == b: print(i) break else: print(-1)" p02755,s138838438,Accepted,"#!/usr/bin/env python from sys import stdin, stderr def main(): A, B = map(int, stdin.readline().split()) p = 1 res = -1 while True: a = (p * 8) / 100 b = (p * 10) / 100 if a > A or b > B: break if a == A and b == B: res = p break p += 1 print(res) return 0 if __name__ == '__main__': main() " p02755,s170620484,Accepted,"import sys def input(): return sys.stdin.readline().strip() def resolve(): def main(): a,b=map(int, input().split()) for i in range(13,1250): if (i*8)//100==a and (i*10)//100==b: return i return -1 print(main()) resolve()" p02755,s324893489,Accepted,"# -*- coding: utf-8 -*- a, b = map(int, input().split()) for i in range(2000): if int(i * 0.08) == a and int(i * 0.1) == b: print(i) exit() print(-1) " p02755,s383188502,Accepted,"import math A, B = map(int, input().split()) num = math.ceil(25 / 2 * A) A_list = [] if A % 2 == 0: while num <= math.floor(25 / 2 * (A + 1)): A_list.append(num) num += 1 else: while num < 25 / 2 * (A + 1): A_list.append(num) num += 1 res = -1 A_list.sort(reverse=True) for item in A_list: if item >= 10 * B and item < 10 * (B + 1): res = item print(res)" p02755,s267110064,Accepted,"a,b =map(int,input().split()) ans = [] for i in range(1,10**4+1): if int(i * (8/100)) == a and int(i*(10/100)) == b: ans.append(i) print('-1' if ans == [] else min(ans))" 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)" p02755,s479081822,Accepted,"A,B = map(int,input().split()) ans=-1 for i in range(1,1001): if i*0.08//1==A and i*0.1//1==B: ans=i break print(ans)" p02755,s076881766,Accepted,"A, B = map(int,input().split()) for i in range(10*B,10*(B+1)): if 10*B<= i <10*(B+1) and 12.5*A<= i < 12.5*(A+1): print(i) break else: print(-1)" p02755,s614042345,Accepted,"import fractions import sys A,B=map(int,input().split()) for i in range(1,1009): if(int(i*0.08) == A and int(i*0.1)==B): print(i) sys.exit() print(-1)" 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" p02755,s965911869,Accepted,"import math a,b=map(int,input().split()) ans=-1 for i in range(1,5000): #print(int(i*0.08)) if math.floor(i*0.08)==a and math.floor(i*0.1)==b: #print(int(i*0.08)) ans=i break print(ans)" p02755,s332228376,Accepted,"from math import floor A,B = map(int,input().split("" "")) s = 10*B t = 10*(B+1) ans = 2**60 for tmp in range(s,t): if floor(tmp*0.08) == A: ans = tmp break s = 125*A t = 125*(A+1) for tmp in range(s,t): if floor(tmp/10) == B: ans = min(ans,tmp) break if ans == 2**60: ans = -1 print(ans)" p02755,s165453280,Accepted,"a, b = input().split(); a = int(a); b = int(b); for x in range(1,1001): tax_8 = int(x * 0.08); tax_10= int(x * 0.1); if tax_8 == a and tax_10 == b: ans = x; break; elif x == 100: ans = -1; else: pass; 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) " p02755,s724311496,Accepted,"a, b = map(int,input().split()) if b < 10: for x in range(10*b,10*(b+1)): if int(0.08*x) == a: print(x) exit() else: for x in range(10*b,10*b+10): if int(0.08*x) == a: print(x) exit() print(-1) " p02755,s755493666,Accepted,"A, B = map(int, input().split()) for i in range(1, 10001): x=(i*8)//100 y=(i*10)//100 if x==A and y==B: print(i) break else: print(-1) " p02755,s754221968,Accepted,"a, b = map(int, input().split()) start = b * 10 flg = True for i in range(10): tmp = start + i if int(tmp*0.08) == a: flg = False break if flg: print('-1') else: print(int(tmp))" p02755,s116527597,Accepted," import collections import math class Solution: def solve(self, A, B): for i in range(10**4): aTax, bTax = math.floor(i*0.08), math.floor(i * 0.1) if aTax == A and bTax == B: return i return -1 sol = Solution() [A, B] = list(map(int, input().strip().split())) print(sol.solve(A, B)) " p02755,s825970370,Accepted,"A,B = map(int,input().split()) for i in range(B*10,(B+1)*10): if i*8//100 == A: print(i) exit() print(-1) " p02755,s547796583,Accepted,"a,b = map(int,input().split()) for i in range(1,10000): if int(i*0.08) == a and int(i*0.1) == b: print(i) break else: print(-1)" p02755,s712588724,Accepted,"A,B=map(int,input().split()) for money in range(1,1001): if int(money*0.08)==A and int(money*0.1)==B: print(money) break else: print(-1)" p02755,s295722070,Accepted,"A, B = map(int, input().split()) ans = -1 for i in range(1250): if int(i * 0.08) == A and int(i * 0.10) == B: ans = i break print(ans) " p02755,s471740067,Accepted,"import math a, b = map(int, input().split()) for i in range(10**4): if math.floor(i*0.08) == a and math.floor(i*0.1) == b: print(i) exit() print(-1)" p02755,s054868883,Accepted,"from math import floor import sys from copy import copy input = sys.stdin.readline ''' n, m = map(int, input().split()) n = int(input()) A = list(map(int, input().split())) S = input().strip() for test in range(int(input())): ''' inf = 100000000000000000 # 1e17 mod = 998244353 aa, bb = map(int, input().split()) for i in range(1, 10000): if int(floor(i * 0.08)) == aa and int(floor(i * 0.1)) == bb: print(i) sys.exit() print(""-1"") " p02755,s338222541,Accepted,"A, B = map(int, input().split()) ans = -1 for x in range(1010): if int(x*0.08) == A and int(x*0.1) == B: ans = x break print(ans) " p02755,s916211700,Accepted,"import math if __name__ == '__main__': a, b = list(map(int, input().split("" ""))) for i in range(1, 1500): # print(i) if math.floor(i * 0.08) == a and math.floor(i * 0.1) == b: print(i) exit() print(-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) " p02755,s849938746,Accepted,"import math A,B = map(int,input().split()) ans = 0 while 1: C = math.floor(ans*0.08) D = math.floor(ans*0.1) if C == A and D == B: print(ans) break if C > A or D > B: print(-1) break ans += 1 " p02755,s921221040,Accepted,"A, B = map(int, input().split()) for i in range(500000): a = i * 8 // 100 b = i // 10 if (a, b) == (A, B): print(i) exit() print(-1) " p02755,s271115637,Accepted,"A, B = map(int, input().split()) for i in range(2000): if int(i * 0.08) == A and int(i * 0.1) == B: print(i) quit() print(-1)" p02755,s958993826,Accepted,"import math A, B = map(int, input().split()) b1 = B*10 b2 = b1 + 10 for i in range(b1, b2): if math.floor(i*0.08) == A: print(i) break if i == b2-1: print(-1)" p02755,s579683414,Accepted,"def tax(a, b): for i in range(1,1010): if int(i*0.08) == a and int(i*0.1) == b: print(i) return print(-1) return a, b = map(int, input().strip().split()) tax(a,b)" p02755,s578728939,Accepted,"a,b = map(int,input().split()) ten = [] ei = [] for i in range(1,1010): if a <= i*0.08 < a+1: ei.append(i) for j in range(1,1010): if b <= j*0.1 < b+1: ten.append(j) case = set(ei) & set(ten) if not case: print(-1) else: print(min(case))" p02755,s157455539,Accepted,"a, b = map(int, input().split()) flag = 0 for i in range(1, 1001): hati = int(i * 0.08) juu = int(i * 0.1) if hati == a and juu == b: flag = 1 print(i) break if flag == 0: print(""-1"")" p02755,s284845475,Accepted,"a, b = map(int, input().split()) ans = -1 for v in range((100*10)+100): t8 = int(v * 0.08) t10 = int(v * 0.1) if t8 > a or t10 > b: break if t8 == a and t10 == b: ans = v break print(ans) " p02755,s265071560,Accepted,"def rounder(x): flt = x - int(x) if flt>=0.5: return int(x)+1 else: return int(x) def main(): a, b = map(int, input().split()) A = list(range(rounder(a/0.08), rounder((a+1)/0.08))) B = list(range(rounder(b/0.10), rounder((b+1)/0.10))) r = -1 for i in range(len(B)): if B[i] in A: r = B[i] break print(r) main()" p02755,s088938401,Accepted,"import math t8,t10=map(int,input().split("" "")) mint8=t8/0.08 maxt8=(t8+1)/0.08 mint10=t10/0.1 maxt10=(t10+1)/0.1 ans=list(set(range(math.ceil(mint8),int(maxt8))) & set(range(math.ceil(mint10),int(maxt10)))) if len(ans)==0: print(-1) else: print(min(ans))" p02755,s284804887,Accepted,"A, B = map(int, input().split()) for i in range(1, 1001): if (i * 0.08) // 1 == A and (i * 0.1) // 1 == B: print(i) exit(0) print(-1) " p02755,s814845866,Accepted,"a,b = map(int, input().split()) for i in range(1,10000): if i*8//100 == a: if i*10//100 == b: print(i) break else: print(-1)" p02755,s212000199,Accepted,"A, B = map(int, input().split()) for i in range(B*100): if i*8//100 == A and i * 10 // 100 == B: print(i) exit() print(-1) " p02755,s571016568,Accepted,"A, B = map(int, input().split()) for i in range(1, 1100): if int(i*0.08)==A and int(i*0.1)==B: print(i) break else: print(-1) " p02755,s238067763,Accepted,"a,b=map(int,input().split()) for price in range(1,10000+1): if int(price*0.08) == a and int(price*0.10) == b: print(price) quit() print(-1) " 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) " p02755,s309301528,Accepted,"A, B = map(int, input().split()) flag = 0 for i in range(1300): if int(i*0.08) == A and int(i*0.1) == B: print(i) flag = 1 break if flag == 0: print(-1) " p02755,s936225916,Accepted,"a,b = map(int,input().split()) if a/0.08 == a//0.08: emin = a//0.08 else: emin = a//0.08+1 if (a+1)/0.08 == (a+1)//0.08: emax = (a+1)//0.08-1 else: emax = (a+1)//0.08 tmin = b/0.1 tmax = (b+1)/0.1-1 if tmax >= emax: if tmin <= emax: print(int(tmin)) else: print(-1) else: if emin <= tmax: print(int(emin)) else: print(-1)" p02755,s737307823,Accepted,"import math a, b = map(int, input().split()) for i in range(1001): if math.floor(i * 0.08) == a and math.floor(i * 0.1) == b: print(i) exit(0) print(-1)" p02755,s803583297,Accepted,"A, B = [int(x) for x in input().split()] ans = 0 ans_a = A // 0.08 ans_b = B // 0.10 for i in range(1, 10100): if A == int(0.08 * i) and B == int(0.10 * i): ans = i print(ans) break if ans == 0: print(-1)" p02755,s232129090,Accepted,"A, B = map(int, input().split()) Amin= A*100/8 AMAX= (A+1)*100/8 Bmin= B*100/10 BMAX= (B+1)*100/10 Alist=[0]*1257 Blist=[0]*1257 ANSlist=[10000]*1257 for i in range(1257): if Amin <=i 12: start=min(d,u)-12 else: start=0 for i in range(start,max(d,u)+13): if (int(i*0.08)==a)and(int(i*0.1)==b): ans=i break print(ans)" p02755,s625223932,Accepted,"import math a,b = [float(i) for i in input().split()] ans = 1000000000 flag = False for i in range(1,10000): ans8 = int(math.floor(i*0.08)) ans10 = int(math.floor(i*0.1)) # print(ans8,ans10) if ans8 == a and ans10 == b: ans = min(ans, i) flag = True if flag is True: print(ans) else: print(-1)" 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)" p02755,s369631879,Accepted,"a,b=map(int,input().split()) def ceil(x): if x%1==0: return x//1 else: return x//1+1 a1=int(ceil(a*100/8)) a2=int(ceil((a+1)*100/8)-1) b1=int(ceil(b*100/10)) b2=int(ceil((b+1)*100/10)-1) count=0 for i in range(a1,a2+1): if b1<=i<=b2: print(i) count=0 break else: count+=1 if count!=0: print(-1)" p02755,s219403774,Accepted,"import sys a, b = map(float, sys.stdin.readline().split()) ans = -1 for i in range(1, 1251): if (int(i * 0.08) == a) and (int(i * 0.1) == b): ans = i break print(ans) " p02755,s898343159,Accepted,"import math A,B = map(int,input().split()) ans = [] for ans in range(1,1251): if math.floor(ans*0.08) == A and math.floor(ans*0.1) == B: print(ans) exit() print(-1)" 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)" p02755,s287423704,Accepted,"A, B = map(int, input().split()) _MAX_PRICE = 1001 for n in range(1, _MAX_PRICE): if int(n * 0.08) == A and int(n * 0.1) == B: print(n) exit() print(-1)" p02755,s348829272,Accepted,"A,B=map(int,input().split()) A0=[100*A/8,100*(A+1)/8] B0=[100*B/10,100*(B+1)/10] S0=max(A0[0],B0[0]) S1=min(A0[1],B0[1]) if int(S0)>=S0 and int(S0)y2 or y1>x2: print (-1) else: print (int(max(x1,y1)))" p02755,s456045538,Accepted,"A, B = list(map(int, input().split())) ans = -1 for i in range(1, 1009): if int(i*0.08) == A and int(i*0.10) == B: ans = i break print(ans)" p02755,s964516370,Accepted,"import math a, b = map(int, input().split(' ')) ret = -1 for i in range(1, 1251): if math.floor(i * 0.08) == a and math.floor(i * 0.1) == b: ret = i break print(ret)" p02755,s001941778,Accepted,"a,b=map(int,input().split()) import math ans=0 for i in range(1,1001): aa=math.floor(i*0.08) bb=math.floor(i*0.1) if aa==a and bb==b: print(i) break else: print(-1)" p02755,s254564316,Accepted,"a,b = input().split() a = int(a) b = int(b) c = 0 for i in range(1001): d = c*0.08 e = c*0.1 d = int(d) e = int(e) if d == a and e == b: print(c) break elif c == 1000: print('-1') break else: c += 1" p02755,s583129449,Accepted,"a, b = map(int, input().split()) ans = 0 for i in range(1270): x = i * 8 y = x / 100 z = i * 10 q = z / 100 if a == int(y) and b == int(q): if ans == 0: ans = i else: ans = min(ans, i) if ans == 0: print(-1) else: print(ans)" p02755,s647910310,Accepted,"from math import floor a, b = [int(i) for i in input().split()] for i in range(1, 1011): if floor(i * 0.08) == a and floor(i * 0.1) == b: print(i) exit() print(-1) " p02755,s497763029,Accepted,"a,b = map(int,input().split()) list = [] if 100*a%8: x=int(a/0.08)+1 else: x=int(a/0.08) if 100*(a+1)%8: y=int((a+1)/0.08) else: y=int((a+1)/0.08)-1 for i in range(x, y+1): if b/0.1 <= i <(b+1)/0.1: list.append(i) list = sorted(list) if list: print(list[0]) else: print('-1') " p02755,s185089989,Accepted,"a,b = map(int, input().split()) for i in range(1, 1100): if i * 0.08 //1 == a and i * 0.1 //1 == b: print(i) break else: print(-1) " p02755,s027353480,Accepted,"from math import floor A, B = map(int, input().split()) ans = 10**9 for i in range(1, 100000): a = floor(i * 0.08) b = floor(i * 0.1) if a == A and b == B: ans = min(ans, i) if ans == 10**9: print(-1) else: print(ans)" p02755,s106064807,Accepted,"import sys #read = sys.stdin.read from math import floor def main(): a, b = map(int, input().split()) for i1 in range(1251): if floor(i1 * 0.08) == a and floor(i1 * 0.1) == b: print(i1) sys.exit() print(-1) if __name__ == '__main__': main() " p02755,s235071804,Accepted,"A,B = map(int,input().split()) x = -1 for i in range(1,20000): if int(i*1.08)-i==A and int(i*1.1)-i==B: x = i break print(x)" 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)))" p02755,s329157942,Accepted,"a,b = list(map(int,input().split())) x = list(range(int(a//0.08+1), int((a+1)//0.08+1))) y = list(range(int(b//0.1+1), int((b+1)//0.1+1))) z = list(set(x) & set(y)) if not z: print(-1) else: print(min(z))" p02755,s907964144,Accepted,"from math import floor A, B = map(int, input().split()) tax_A = 0.08 tax_B = 0.1 i = 1 A_list = [] while(floor(i*tax_A)<=A): if floor(i*tax_A)==A: A_list.append(i) i += 1 i = 1 B_list = [] while(floor(i*tax_B)<=B): if floor(i*tax_B)==B: B_list.append(i) i += 1 if max(min(A_list), min(B_list)) in A_list and max(min(A_list), min(B_list)) in B_list: print(max(min(A_list), min(B_list))) else: print(-1)" p02755,s237352182,Accepted,"#!/usr/bin/env python3 A, B = list(map(int, input().split())) x = -1 for i in range(1, 10000): if int(i * 0.08) == A and int(i * 0.1) == B: x = i break ans = x print(ans) " p02755,s520597551,Accepted,"b,a = map(int,input().split()) ans = a*10 for i in range(11): if i == 10: ans = -1 break if int(ans*0.08) == b: break ans += 1 print(ans)" p02755,s601864684,Accepted,"I = 1009 a,b = map(int,input().split());flag=0 for i in range(1,I): x = (i*8)//100;y=(i*10)//100 if(x==a and y==b): print(i) flag=1 break if(flag==0): print(-1)" p02755,s244494821,Accepted,"import math A, B = map(int, input().split()) min_8 = math.ceil(A * 12.5) max_8 = math.ceil((A + 1) * 12.5) -1 min_10 = math.ceil(B * 10) max_10 = math.ceil((B + 1) * 10) -1 if (max_10 < min_8 or max_8 < min_10): print(-1) else: print(max(min_8,min_10))" p02755,s614441912,Accepted,"def tax_increase(a,b): t8 = 0.08 t10 = 0.1 for i in range(b*10,(b+1)*10,1): if int(i*t8) == a: return i return -1 if __name__ == '__main__': a,b = map(int,input().split()) ans = int(tax_increase(a,b)) print(ans) " p02755,s597596654,Accepted,"a, b = map(int, input().split()) for x in range(1,100001): if int(x * 0.08) == a and int(x * 0.10) == b: print(x) break else: print(-1)" 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 A and q > B: print(-1) else: search(x+1) search(1) " p02755,s731411428,Accepted,"A, B = map(int, input().split()) for i in range(1, 1011): a = i * 0.08 b = i * 0.1 if A <= a < A+1 and B <= b < B + 1: print(i) exit() print('-1') " p02755,s148267597,Accepted,"from sys import stdin def main(): input = stdin.readline A,B = map(int,input().split()) for i in range(1,1001): if(int(i * 0.08) == A) and (int(i * 0.1) == B): print(i) return else: print(""-1"") if __name__ == ""__main__"": main()" p02755,s789853563,Accepted,"A, B = map(int, input().split()) ans = -1 for price in range(1, 1251): if int(price * 0.08) == A and int(price * 0.1) == B: ans = price break print(ans)" p02755,s762463990,Accepted,"a,b=map(int,input().split()) import math x=min(math.floor(a/0.08),math.floor(b/0.1)) y=max(math.floor((a+1)/0.08),math.floor((b+1)/0.1)) for i in range(x,y): if math.floor(i*0.08)==a and math.floor(i*0.1)==b: print(i) exit() print(-1) " p02755,s294200429,Accepted,"# -*- coding: utf-8 -*- import math a, b = map(int, input().split()) for i in range(0, 10001): if math.floor(0.08*i) == a: if math.floor(0.10*i) == b: print(i) exit() print(-1) " p02755,s643581589,Accepted,"A, B = map(int, input().split(' ')) for i in range(1, 1010): if i * 8 // 100 == A and i * 10 // 100 == B: print(i) break else: print(-1)" p02755,s174857151,Accepted,"A, B = map(int, input().split()) x_min_tmp = A * 12.5 if x_min_tmp.is_integer: x_min = int(x_min_tmp) else: x_min = int(x_min_tmp) + 1 x_max_tmp = (A + 1) * 12.5 x_max = int(x_max_tmp) + 1 ans = -1 for n in range(x_min, x_max + 1): if int(n * 0.08) == A and int(n * 0.1) == B: ans = n break print(ans)" 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) " p02755,s776710776,Accepted,"a,b=map(int,input().split()) for i in range(1, 1009): if int(i*0.08) == a and int(i*0.1) == b: print(i) exit() print(-1)" 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) " p02755,s329401799,Accepted,"from math import floor a,b=map(int, input().split()) for i in range(1200): if floor(i*0.08)==a and floor(i*0.1)==b: print(i) break else: print(-1)" p02755,s865974763,Accepted,"def main(): import sys import math input = sys.stdin.readline a,b=map(int,input().split()) if b>=10: for i in range(b*10,b*10+10): if a==math.floor(i*0.08): print(i) exit() print(-1) else: for i in range(b*10,b*10+10): if a==math.floor(i*0.08): print(i) exit() print(-1) if __name__=='__main__': main()" p02755,s595533935,Accepted,"a,b=map(int,input().split()) ans=-1 cont=0 for i in range(10,10000): if int(i*0.08)==a and int(i*0.1)==b: ans=i count=1 break print(ans)" p02755,s749597156,Accepted,"A, B = map(int, input().split()) x = max((A*100+7)//8, B*100//10) y = min((A+1)*100/8, (B+1)*100/10) if x < y: ans = x else: ans = -1 print(ans)" p02755,s203160424,Accepted,"#!/usr/bin/python3 import sys input = lambda: sys.stdin.readline().strip() a, b = [int(x) for x in input().split()] try: print(next(x for x in range(2000) if 8 * x // 100 == a and 10 * x // 100 == b)) except StopIteration: print(-1)" p02755,s633415517,Accepted,"a,b=map(int,input().split()) for i in range(5000): z8=int(i*0.08) z10=int(i/10) if z8==a and z10==b: print(i) exit() print(""-1"")" p02755,s624045513,Accepted,"import sys import math a, b = map(int, input().split()) for i in range(1251): aa=math.floor(0.08*i) bb=math.floor(0.1*i) if aa==a and bb==b : print(i) sys.exit() print(-1) " p02755,s616734137,Accepted,"a,b = [int(x) for x in input().split()] res = -1 for i in range(20000): if i * 8 // 100 == a and i * 10 // 100 == b: res = i break print(res)" p02755,s961081697,Accepted,"a, b = map(int, input().split()) for i in range(10, 1001): if int(i * 0.08) == a and int(i * 0.1) == b: print(i) exit() print(-1)" p02755,s353814087,Accepted,"import math A,B = map(int,input().split()) for i in range(10000): if math.floor(i * 1.08 -i )==A and math.floor(i * 1.1 -i)==B: print(i) exit() print(-1)" p02755,s321981291,Accepted,"a, b = map(int, input().split()) for i in range(1, 2000): if i * 8 // 100 == a and i * 10 // 100 == b: print(i) break else: print(-1)" p02755,s925685259,Accepted,"import math; a,b = map(int,input().split()) x = [] y = [] ans = -1 x.append(math.ceil(a*25/2)) x.append((a+1)*25//2-1) y.append(b*10) y.append((b+1)*10-1) if min(x) < max(y) and min(y) < max(x) and min(y) <= min(x): ans = min(x) elif min(x) < max(y) and min(y) < max(x) and min(x) < min(y): ans = min(y) print(ans)" p02755,s510633689,Accepted,"A,B=map(int,input().split()) cnt=0 for i in range(1010): if int(i*0.08)==A and int(i*0.1)==B: print(i) break else: cnt+=1 if cnt==1010: print(-1)" p02755,s023267724,Accepted,"import math a, b = map(int, input().split()) ans = -1 for i in range(1, 1251): if math.floor(i*0.08) == a and math.floor(i*0.1) == b: ans = i break print(ans) " p02755,s248115378,Accepted,"A, B = map(int, input().split()) done = False for i in range(1, 1001): if A == (i *8 // 100) and B == (i * 10 // 100): print(i) done = True break if not done: print(-1)" p02755,s934457865,Accepted,"a, b = map(int, input().split()) for i in range(1, 1001): if a <= i*0.08 < a+1: if b <= i*0.1 < b+1: print(i) exit(0) print(-1)" p02755,s702207097,Accepted,"a,b = map(float,input().split()) for i in range(10000): c = i*8//100 d = i*10//100 if(a == c and b == d): print(i) exit() print(-1)" 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) " p02755,s095952656,Accepted,"A,B = [int(i) for i in input().split()] flag=0 for i in range(1,1050): if int(i*0.08)==A and int(i*0.1)==B: ans = i flag=1 break if flag==1: print(ans) else: print(-1) " p02755,s292190573,Accepted,"A,B = map (int,input().split()) eight = [0] * 2000 ten = [0] * 2000 for i in range(2000): eight[i] =(float(i+1) * 0.08)//1 ten[i] = (float(i+1) * 0.1)//1 ans = 0 for i in range(2000): if A == eight[i] and B == ten[i]: ans = i + 1 break if ans == 0: print(-1) else: print(ans)" p02755,s506482764,Accepted,"import math a, b = input().split() # a = result * 0.08, b = result * 0.1 a, b = int(a), int(b) result_a = int(math.ceil(a / 0.08)) result_b = int(math.ceil(b / 0.1)) if result_a < 0 or result_b < 0: print(-1) elif result_a > result_b: c = int(result_a * 0.1) if b == c: print(result_a) else: print(-1) else: c = int(result_b * 0.08) if a == c: print(result_b) else: print(-1) " p02755,s772838007,Accepted,"import math A,B = map(int,input().split()) ans = -1 for i in range(1,100100): if math.floor(i*0.08) ==A and math.floor(i*0.1) ==B : ans = i break print(ans) " 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)" p02755,s325960732,Accepted,"import math A,B = map(int,input().split()) if (A+1)/0.08 > B/0.1 and (B+1)/0.1 > A/0.08: print(max(math.ceil(A/0.08),math.ceil(B/0.1))) else: print(-1)" p02755,s737017531,Accepted,"import math a, b = map(int, input().split()) a1 = a+1 b1 = b+1 A = a/0.08 A1=a1/0.08 B = b/0.1 B1 = b1/0.1 ans1 = set(i for i in range(math.ceil(A), math.floor(A1))) ans2 = set(j for j in range(math.ceil(B), math.floor(B1))) if ans1 & ans2 == set(): print(-1) else: ans = ans1&ans2 print(min(list(ans)))" p02755,s283103978,Accepted,"Str = input().split() A = int(Str[0]) B = int(Str[1]) import math amin = math.ceil(A/0.08) amax = (A+1)/0.08 if amax == math.floor(amax): amax= amax-1 else: amax = math.floor(amax) i = amin ans = -1 while i <= amax: if int(i*0.1) == B: ans = i break i+=1 print(ans)" p02755,s006617836,Accepted,"import math a, b = list(map(int, input().split())) n = b * 10 flag = False while n <= 1009: if math.floor(n * 0.1) == b and math.floor(n * 0.08) == a: flag = True break n += 1 print(n) if flag is True else print(-1) " p02755,s160261562,Accepted,"A,B=map(int,input().split()) ans=-1 for i in range(1500): if int(i*0.08)==A and int(i*0.1)==B: ans=i break print(ans)" p02755,s078921968,Accepted,"import math import numpy as np a, b = [int(v) for v in input().split()] try: print(min(np.intersect1d(np.arange(math.ceil(a/0.08), (a+1) //0.08+ 1).astype(int), np.arange(math.ceil(b/0.1), (b+1)//0.1 + 1).astype(int)))) except: print(-1) " p02755,s130449005,Accepted,"a, b = map(int, input().split()) def shouhi(n,a,b): if (int(n * 1.08) -n == a) & (int(n * 1.1) -n== b): return True return False ou = False for n in range(int(a / 0.08), int(a / 0.08) + 13): if shouhi(n,a,b): print(n) ou = True break if not ou: print(-1)" p02755,s016376911,Accepted,"import math A, B = list(map(int, input().split())) amax = math.ceil((A + 1) / 8 * 100) - 1 amin = math.ceil(A / 8 * 100) bmax = math.ceil((B + 1) * 10) - 1 bmin = math.ceil(B * 10) if amin > bmax or bmin > amax: print(-1) else: print(int(max(amin, bmin))) " p02755,s960248447,Accepted,"def main(): A, B = map(int, input().split()) for i in range(1, 2000): if int(i*0.08) == A and int(i*0.1) == B: print(i) return print(-1) if __name__ == ""__main__"": main() " p02755,s738686116,Accepted,"import math a, b = map(int, input().split()) for i in range(1001): temp_a = i * 0.08 temp_b = i * 0.1 if math.floor(temp_a) == a and math.floor(temp_b) == b: print(i) exit(0) print(""-1"")" p02755,s334894245,Accepted,"import math a,b=map(int,input().split()) m=max(math.ceil(100*a/8),math.ceil(100*b/10)) if a<=m*8/100 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)" 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)" 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)" p02755,s845560426,Accepted,"a,b=map(int, input().split()) xa=int(12.5*a-0.0001)+1 xb=10*b x=max(xa,xb) ra=int(x*0.08) rb=int(x*0.1) if ra==a and rb==b: print(x) else: print(-1)" 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) " p02755,s658333737,Accepted,"import sys nums=input().rstrip().split("" "") A=int(nums[0]) B=int(nums[1]) answer=0 for i in range(1,1500): #print(int(i*0.08)) #print(int(i*0.1)) if int(i*0.1)==B and int(i*0.08)==A: answer=i print(answer) sys.exit() if answer==0: answer=-1 print(answer) " p02755,s397266676,Accepted,"m,n=map(int,input().split()) l=[] for i in range(1,12500): if i*2//25==m and i//10==n: l.append(i) if len(l)==0: print(-1) else: print(min(l)) " p02755,s255614469,Accepted,"# -*- coding: utf-8 -*- import math a,b = map(int, input().split()) x = 0 for n in range(25): l = (25 * a + n) % 2 m = 25 * a + n if(l == 0): if((m/2 - 10 * b) == int(m/2 - 10 * b) and (m/2 - 10 * b) < 10 and (m/2 - 10 * b) >= 0): x = int(m/2) break if(n == 24): x = -1 break print(""{}"".format(x))" p02755,s452780205,Accepted,"A,B=tuple(int(i) for i in input().split("" "")) err=lambda X:abs(int(X*0.08)-A)+abs(int(X*0.10)-B) rg=[int(A/0.08),int(B/0.10)] rg.sort() rg[0]-=int(1/0.08) rg[1]+=int(1/0.08) solv=[X for X in range(*rg) if err(X)==0] solv.sort() if(len(solv)==0): print(""-1"") else: print(solv[0]) " p02755,s977106918,Accepted,"a,b = map(int,input().split()) i = 0 x = int(a/0.08) while True: if int((x+i)*0.1) == b and int((x+i)*0.08) == a: ans = int(x+i) break elif int((x+i)*0.1) > b: ans = '-1' break else: i += 1 print(ans)" p02755,s656299520,Accepted,"import math a,b=map(int,input().split()) A=a/0.08 B=(a+1)/0.08 C=b/0.1 D=(b+1)/0.1 P=max(A,C) Q=min(B,D) if math.ceil(P)maxB) or (minB>maxA): print(-1) else: print(max(minA,minB)) " p02755,s004965929,Accepted,"import math A,B=map(int,input().split()) ans=100000 for i in range(1,10000): a=math.floor(i*0.08) b=math.floor(i*0.1) if a==A and b==B: ans=i break print(-1 if ans==100000 else ans)" p02755,s299056661,Accepted,"A, B = map(int, input().split()) ans = -1 for i in range (1000 + 1): if (int(i*0.08) == A) and (int(i*0.10) == B): ans = i break print(ans)" p02755,s058511989,Accepted,"A,B=map(int,input().split()) for i in range(1,10100//8+1): if int(i*0.08)==A and int(i*0.10)==B: print(i) break else: print(-1)" p02755,s120375174,Accepted,"import math a, b = map(int, input().split()) ans = -1 for i in range(1, 1001): if math.floor(i * 0.08) == a and \ math.floor(i * 0.1) == b: ans = i break print(ans) " p02755,s836722255,Accepted,"A, B = map(int, input().split(' ')) # 1. YONTEM: import math asil1_1 = (100*(A))/8 asil1_2 = (100*(A+1))/8 asil2_1 = 10*(B) asil2_2 = 10*(B+1) sonuc_1 = max(asil1_1, asil2_1) sonuc_2 = min(asil2_2, asil1_2) if math.ceil(sonuc_1)>=sonuc_2: print(-1) else: print(math.ceil(sonuc_1))" p02755,s743798451,Accepted,"import math A, B = map(int, input().split(' ')) for n in range(1, 1001): a = int(math.floor(n * 0.08)) b = int(math.floor(n * 0.1)) # print(n, a, b) if a == A and b == B: print(n) exit() print(-1) " p02755,s305104484,Accepted,"import sys import math readline = sys.stdin.readline a, b = [int(x) for x in readline().strip().split("" "")] ans = -1 for i in range(13, 1001): if a == math.floor(i * 0.08) and b == math.floor(i * 0.1): ans = i break print(ans) " p02755,s206797506,Accepted,"import math a, b = map(int, input().split()) for i in range(1251): tax8 = math.floor(i * 0.08) tax10 = math.floor(i * 0.1) if (tax8, tax10) == (a, b): print(i) break else: print(-1)" p02755,s906890924,Accepted,"a, b = map(int, input().split()) ans = -1 for i in range(1001): if int(i*0.08) == a and int(i*0.1) == b: ans = i break print(ans)" p02755,s739546710,Accepted,"#C A,B = map(int,input().split()) for i in range(1,10001): if int(i*0.08) == A and int(i*0.1) == B: print(i) break else: print(-1)" p02755,s669729118,Accepted,"A, B = map(int, input().split()) for i in range(1, 2000): if int(i * 0.08) == A and int(i * 0.1) == B: print(i) exit() print(-1) " p02755,s219073990,Accepted,"A, B = map(int, input().split()) for n in range(10000): za = n*8//100 zb = n*10//100 if A == za and B == zb: print(n) exit(0) print(-1)" p02755,s109853812,Accepted,"a, b = map(int, input().split()) #x * 0.08 = a #x * 0.1 = b xa = int(a/0.08) xb = int(b/0.1) ans = -1 x = min(xa, xb) for i in range(-20, 30): x_tmp = x + i #print(x_tmp, int(x_tmp*0.08), int(x_tmp*0.1)) if int(x_tmp*0.08)==a and int(x_tmp*0.1)==b: ans = x_tmp break if ans==-1: print(-1) else: print(int(ans)) " p02755,s514526968,Accepted,"import math a, b = map(int, input().split()) ans = -2 for i in range(10000): if math.floor((i+1) * 8/100) == a and math.floor((i+1)/10 ) == b: ans += i+3 break no_ans = -1 print(max(ans, no_ans))" p02755,s887420656,Accepted,"A,B = map(int,input().split()) C=-1 for i in range(20000): if int(i*0.08)==A and int(i*0.1)==B: C=i break print(C)" p02755,s881308855,Accepted,"import math A,B = map(int,input().split()) # print(A/0.08,B/0.1) price = [] x = int(A/0.08) # print(x,y) y = int(B/0.1) for i in range(min(x,y),10001): if math.floor(i*0.08) == A and math.floor(i*0.1) == B: price.append(i) break # print(i, math.floor(i*0.08),math.floor(i*0.1)) if len(price) == 0: print(-1) else: print(min(price))" p02755,s812772988,Accepted,"import math A, B = map(int, input().split()) for i in range(1001): if math.floor(i * 0.08) == A and math.floor(i * 0.1) == B: print(i) exit() print(-1) " p02755,s189403281,Accepted,"a,b=map(int,input().split()) c=[] d=[] if a % 2 == 0: s = int(100*a/8) t = int(100*(a+1)/8) + 1 else: s = int(100*a/8) + 1 t = int(100*(a+1)/8) u = int(10*b) v = int(10*(b+1)) for i in range(s,t): c.append(i) for j in range(u,v): d.append(j) c_d = set(c) & set(d) if (len(c_d)>0): print(min(c_d)) else: print(-1) " p02755,s713684040,Accepted,"import math A, B = map(int, input().split()) min_A = math.ceil(A * 100 / 8) max_A = (A + 1) * 100 / 8 min_B = math.ceil(B * 100 / 10) max_B = (B + 1) * 100 / 10 if (min_A <= min_B and min_B < max_A): ans = min_B elif (min_B <= min_A and min_A < max_B): ans = min_A else: ans = -1 print(ans)" p02755,s927008862,Accepted,"A,B = map(int,input().split()) import math a,b = math.ceil(A/0.08),int((A+1)//0.08) c,d = math.ceil(B/0.1),int((B+1)//0.1) if (a>=c)and(a=a)and(c=0 or 10*B-12.5*(A+1)>=0): print(-1) else: if(A*100 % 8 == 0): print(max([10*B,A*100//8])) else: print(max([10*B,A*100//8+1]))" p02755,s222983072,Accepted,"import sys import math import collections #n = int(input()) a, b = map(int, input().split()) #s = input() #x = list(map(int, input().split())) cnt = 1 while (cnt < 2000): if math.floor(cnt * 0.08) == a and math.floor(cnt * 0.1) == b: print(cnt) sys.exit() cnt += 1 print(-1) " p02755,s713334027,Accepted,"a,b = map(int,input().split()) for i in range(10000): if int(i * 0.08) == a and int(i * 0.1) == b: print(i) exit() print(-1) " p02755,s552300115,Accepted,"A, B = map(int, input().split()) ans=0 for x in range(1, 1251): if (int(x*0.08)==A) and (int(x*0.1)==B): ans=x break if ans: print(ans) else: print(-1)" p02755,s772004018,Accepted,"import math a,b = [float(i) for i in input().split()] ans = 1000000000 flag = False for i in range(1,1005): ans8 = int(math.floor(i*0.08)) ans10 = int(math.floor(i*0.1)) # print(ans8,ans10) if ans8 == a and ans10 == b: ans = min(ans, i) # 更新する必要がある. flag = True if flag is True: print(ans) else: print(-1)" p02755,s642471650,Accepted,"a, b = map(int, input().split()) for i in range(1001): if int(i * 0.08) == a and int(i * 0.1) == b: print(i) break else: print(-1)" p02755,s941823032,Accepted,"A, B = map(int,input().split()) for i in range(10000): if int(i * 0.08) == A and int(i * 0.1) == B: print(i) exit() print(-1)" p02755,s145277667,Accepted,"a,b=map(int,input().split()) for i in range(1,1300): if int(i*0.08)==a and int(i*0.1)==b: print(i) exit() print(-1)" p02755,s119891686,Accepted,"import math A,B=map(int, input().split("" "")) #print(A,B) start = math.floor(A*100/8) end = (B+1)*10 ans = -1 for i in range(start,end+1): ta = math.floor(i * 0.08) tb = math.floor(i * 0.1) #print(ta,tb) if ta == A and tb == B: ans = i break print(ans) " p02755,s188262031,Accepted,"import math A, B = map(int, input().split()) Xa_max = (A + 1) / 0.08 Xa_min = (A) / 0.08 Xb_max = (B + 1) / 0.1 Xb_min = (B) / 0.1 # 範囲が被らない場合 if Xa_min >= Xb_max or Xb_min >= Xa_max: print(-1) exit() if Xa_min >= Xb_min: ans = math.ceil(Xa_min) if ans >= Xb_max: print(-1) exit() else: ans = math.ceil(Xb_min) if ans >= Xa_max: print(-1) exit() print(ans)" p02755,s387986546,Accepted,"[A, B] = list(map(int, input().split())) ans = 0 for i in range(1250) : if int(i * 0.08) == A and int(i * 0.1) == B : ans = i break if ans == 0 : ans = -1 print(ans)" p02755,s105117276,Accepted,"a, b = map(int, input().split()) for i in range(1251): if a <= 0.08 * i < a + 1 and b <= 0.1 * i < b + 1: print(i) break elif i == 1250: print(-1)" p02755,s475248764,Accepted,"A,B = map(int,input().split()) import math q = 0 for i in range(math.ceil(12.5*A),int(12.5*(A+1))): if 10*B <= i < 10*(B+1): q = i break if q != 0: print(i) else: print(-1)" p02755,s525213683,Accepted,"a,b=map(int,input().split()) for i in range(1,1001): if int(i*0.08)==a and int(i*0.1)==b: print(i) exit() print(-1)" p02755,s367069740,Accepted,"import math a, b = map(int, input().split()) for i in range(1, 10**5): if math.floor(i*0.08) == a and math.floor(i*0.1) == b: print(i) exit() print(-1)" p02755,s894747320,Accepted,"import math A, B = map(int, input().split()) eightlow = math.ceil(A/0.08) eighthigh = int((A+1)//0.08) tenlow = math.ceil(B/0.1) tenhigh = int((B+1)//0.1) eight = [] ten = [] for i in range(eightlow, eighthigh+1): eight.append(i) for i in range(tenlow, tenhigh+1): ten.append(i) for i in range(len(eight)): for j in range(len(ten)): if eight[i] ==ten[j]: print(eight[i]) exit() print(-1) " p02755,s738430747,Accepted,"ans=0 a,b=map(int,input().split()) for i in range(10000): ans1=int(i*1.08) ans2=int(i*1.1) ans11=ans1-i ans22=ans2-i if ans11==a and ans22==b: print(i) exit(0) print(-1)" p02755,s933156465,Accepted,"A,B = map(int,input().split()) hoge = list(range(B*10,(B*10)+10)) ans = [] for i in hoge: if (i * 0.08) // 1 == A: ans.append(i) if len(ans) == 0: print(-1) else: print(min(ans))" p02755,s906761510,Accepted,"a,b = map(int,input().split()) for i in range(1,1001): if int(i*0.08)==a and int(i*0.1)==b: print(i) exit() print(-1)" p02755,s459034613,Accepted,"import math a, b = map(int, input().split()) i = -1 atax = -1 btax = -1 while not ((atax == a and btax == b) or (btax > 100)): i += 1 atax = math.floor(i * 0.08) btax = math.floor(i * 0.1) if btax > 100: print(-1) else: print(i)" p02755,s107227767,Accepted,"from math import floor as fl from math import ceil as ce a,b=map(int,input().split()) aini=ce(a/0.08) bini=ce(b/0.1) out=max(aini,bini) r=-1 while fl(out*0.08)>=a and fl(out*0.1)>=b: if fl(out*0.08)==a and fl(out*0.1)==b: r=out out-=1 print(r)" p02755,s946060345,Accepted,"#X=int(input()) import math import sys A,B= map(int, input().split()) for i in range(1,1002): if A==math.floor(i*0.08) and B==math.floor(i*0.1): print(i) sys.exit() print(""-1"")" p02755,s346817027,Accepted,"a,b =map(int,input().split()) for i in range(1009): if int (i*0.08)==a and int(i*0.1)==b: print(i) exit() print(-1) " p02755,s472061163,Accepted,"import sys a,b = map(int,input().split()) for i in range(1,1001): if int(i*0.08) == a and int(i*0.1) == b: print(i) sys.exit() print(-1) " p02755,s976046735,Accepted,"A,B=map(int, input().split()) ans=1100 for i in range(1,1002): if int(i*0.08) ==A and int(i*0.1) ==B: if i < ans: ans =i print(ans if ans <1100 else -1)" p02755,s609734943,Accepted,"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) exit() print(-1) " p02755,s881018056,Accepted,"import math a, b = map(int, input().split()) a_origin = math.ceil(a*100/8) b_origin = b*10 while True: if a_origin == b_origin: result = a_origin break; if a_origin < b_origin: a_origin += 1 else: b_origin += 1 if a_origin >= (a+1) * 100/8 or b_origin >= (b+1) * 10: result = -1 break print(result) " p02755,s835258988,Accepted,"A, B = map(int, input().split()) MAX = 10 ** 3 + 1 res = -1 for i in range(1, MAX): if int(0.08 * i) == A and int(0.1 * i) == B: res = i break print(res)" p02755,s723178120,Accepted,"import math eight, ten = map(int, input().split()) eight_price = eight / 0.08 ten_price = ten / 0.1 if eight_price >= ten_price: bigger = eight_price if (bigger // 10) != ten: print(""-1"") else: print(math.ceil(bigger)) else: bigger = ten_price if (bigger * 8 // 100) != eight: print(""-1"") else: print(math.ceil(bigger))" p02755,s710472991,Accepted,"import math A,B = map(int,input().split()) c = 0 for i in range(math.ceil(A/0.08),math.floor((A+0.99)/0.08)+1): if c == 1: break for j in range(math.ceil(B/0.1),math.floor((B+0.99)/0.1)+1): if i == j: print(i) c = 1 break if c == 0: print(-1)" p02755,s370826404,Accepted,"import math A, B = map(int, input().split()) value = 0 for i in range(1, 1001): if math.floor(i * 0.08) == A and math.floor(i * 0.1) == B: value = i break if value == 0: print(-1) else: print(value)" p02755,s979701772,Accepted,"a,b = map(int,input().split()) ans = 0 for i in range(1,1001): if i*8//100 == a and i//10 == b: ans = i break else: ans = -1 print(ans)" p02755,s798110223,Accepted,"a, b = map(int, input().split()) ans = -1 for x in range(1001): if int(x * 0.08) == a and int(x * 0.1) == b: ans = x break print(ans)" p02755,s362144552,Accepted,"a, b = map(int, input().split()) for i in range(2000): if int(i * 0.08) == a and int(i * 0.1) == b: print(i) break if i == 1999: print(-1) " p02755,s502032454,Accepted,"# --*-coding:utf-8-*-- import math A,B = map(int, input().split()) x = max(math.ceil(A*100/8), math.ceil(B*10)) if math.floor(x*0.08) != A or math.floor(x*0.1) != B: print(-1) else: print(x) " p02755,s373445556,Accepted,"import sys from math import floor input = sys.stdin.readline def main(): a,b=map(int,input().split()) u=max(floor((a+1)/0.08)+1,floor((b+1)/0.1)+1) f=min(floor(a/0.08),floor(b/0.1)) x=-1 for i in range(f,u+1): if floor(i*0.08)==a and floor(i*0.1)==b: x=i break print(x) if __name__ == '__main__': main()" p02755,s897801878,Accepted,"A, B = map(int, input().split()) import math for i in range(1,1002): if math.floor(i*0.08) == A and math.floor(i*0.1) == B: print(i) break elif i == 1001: print(-1)" p02755,s066647625,Accepted,"import math a, b = map(int, input().split()) for i in range(20000): if (math.floor(i * 8 / 100), math.floor(i / 10))\ == (a, b): print(i) exit() print(-1) " p02755,s513942069,Accepted,"a,b = list(map(int,input().split())) ans = -1 for i in range(1,10100): if i // 12.5== a and i // 10 == b: ans = i break print(ans)" p02755,s695647174,Accepted,"import math A,B=map(int,input().split()) ans=-1 for i in range(1,10001): n1=int(math.floor(i * 0.08)) n2=int(math.floor(i * 0.1)) if n1 == A and n2 == B: ans=i break print(ans) " p02755,s172602357,Accepted,"import sys import math a, b = map(int, input().split()) for i in range(1009): if math.floor(i*0.08) == a and math.floor(i*0.1) == b: print(i) sys.exit() print(-1)" p02755,s124481106,Accepted,"import sys sys.setrecursionlimit(10 ** 8) input = sys.stdin.readline def main(): A, B = [int(x) for x in input().split()] for i in range(100000): if i * 8 // 100 == A and i // 10 == B: print(i) return else: print(-1) if __name__ == '__main__': main() " p02755,s865918333,Accepted,"import math a,b = map(int,input().split()) x_a_min = a/0.08 x_a_max = (a+1)/0.08 x_b_min = b/0.1 x_b_max = (b+1)/0.1 if math.ceil(max(x_a_min,x_b_min)) i: V = i else: continue else: continue if V == 10000: print(-1) else: print(V)" p02755,s722191328,Accepted,"##C A,B = map(int,input().split()) A1 = list() B1 = list() for i in range(1,1250): if int(i*0.08) == A: A1.append(i) for j in A1: if int(j*0.1) == B: B1.append(j) if not B1: print(-1) else: print(min(B1))" p02755,s887599110,Accepted,"A, B = map(int, input().split()) ans = [] for i in range(1, 15000): if int(i * 8 / 100) == A and int(i * 10 / 100) == B: ans.append(i) if ans: print(ans[0]) else: print(-1)" p02755,s840753384,Accepted,"a, b = [int(i) for i in input().split()] import math a_ans = list(range(math.ceil(a*12.5), math.ceil((a+1)*12.5))) b_ans = list(range(b*10, (b+1)*10)) l_ans = sorted(list(set(a_ans) & set(b_ans))) if len(l_ans) == 0: print(-1) else: print(l_ans[0])" p02755,s066953364,Accepted,"import math A, B = map(int, input().split()) for i in range(1,1250): if math.floor(i * 0.08) == A: if math.floor(i * 0.1) == B: print(i) break else: print(-1)" p02755,s172684580,Accepted,"import math A, B = map(int, input().split()) for i in range(10**4): if math.floor(i * 0.08) == A and math.floor(i*0.1) == B: print(i) break else: print(-1) " p02755,s823500616,Accepted,"A, B = map(int, input().split()) ans = 0 for k in range(1001): if int(ans*0.08) == A and int(ans*0.1) ==B: print(ans) exit() else: ans += 1 print(-1)" p02755,s311720130,Accepted,"A,B = map(int,input().split()) if A > B: A,B = B,A def no_tax(tax,tax_r): origin,min,max = 0,0,0 while int(origin*tax_r) < tax: origin += 1 min = origin while int(origin*tax_r) <= tax: origin += 1 max = origin-1 return (min,max) A_min,A_max,B_min,B_max = \ no_tax(A,0.08)[0],no_tax(A,0.08)[1],no_tax(B,0.1)[0],no_tax(B,0.1)[1] if A_min <= B_max and B_min <= A_max: print(max(A_min,B_min)) else: print(-1) " p02755,s133406643,Accepted,"a,b=map(float,input().split()) import math x=a//0.08 f=0 for i in range(100000): x=i if a==math.floor(x*0.08) and b==math.floor(x*0.1) : print(i) f=1 break if f==0: print(-1)" p02755,s363143602,Accepted,"import sys import math A, B = map(int, input().split()) for i in range(1, 1501): if (math.floor(i*0.08) == A) and (math.floor(i*0.1) == B): print(i) sys.exit() print(-1)" p02755,s886317570,Accepted,"A, B = [int(v) for v in input().split()] res = -1 for i in range(1000,0,-1): if (i*8)//100 == A and (i*10)//100 == B: res = i print(res) " p02755,s568457684,Accepted,"a, b = map(int, input().split()) for i in range(1, 10**5): if (i*8) // 100 == a and i // 10 == b: print(i) exit() print(-1)" p02755,s402981682,Accepted,"# import math a, b = map(int, input().split(' ')) # ans = math.ceil(a*12.5) # if int(ans*0.1) != b: # print('-1') # exit() # print(ans) for i in range(1100): if int(i*0.08) == a and int(i*0.1) == b: print(i) exit() print('-1') " p02755,s209896131,Accepted,"import math A, B = map(int,(input().split())) list1 = [] list2 = [] border1 = math.ceil(A/0.08) border2 = math.ceil((A+1)/0.08-1) border3 = math.ceil(B/0.1) border4 = math.ceil((B+1)/0.1-1) for i in range(border1,border2+1,1): list1.append(i) for j in range(border3,border4+1,1): list2.append(j) list3 = list(set(list1) & set(list2)) if bool(list3)==True: print(min(list3)) else: print('-1')" p02755,s341299449,Accepted,"a,b = map(int,input().split()) if int(a/(0.08)) == int(b/(0.1)): mn = int(a/(0.08)) else: inter = abs(int(a/(0.08)) - int(b/(0.1))) mn = min(int(a/(0.08)) , int(b/(0.1))) for i in range(inter*2): if int(mn*(0.08))==a: if int(mn*(0.1))==b: break mn += 1 if i ==inter*2-1: mn = -1 print(mn)" p02755,s552279955,Accepted,"import sys a, b = map(int,input().split()) B = 10 * b ans = -1 for i in range(10): if (int((B + i) * 0.08) == a): ans = B + i break print(ans)" p02755,s573858422,Accepted,"A, B = map(int, input().split()) for i in range(1, 10000): if int(i * 0.08) == A and int(i * 0.1) == B: print(i) exit() print(-1)" p02755,s582727068,Accepted,"import math a,b=map(int,input().split()) tax1=math.ceil(max(12.5*a,10*b)) tax2=math.floor(min(12.5*(a+1),10*(b+1))) if tax2>tax1: print(tax1) else: print(-1) " p02755,s896735249,Accepted,"from sys import stdin input = stdin.readline def main(): A, B = list(map(int, input().split())) for i in range(10000): if int(i * 0.08) == A and \ int(i * 0.10) == B: print(i) return print(-1) if(__name__ == '__main__'): main() " p02755,s541012846,Accepted,"A, B = map(int, input().split()) for i in range(1, 1101): if int(i*0.08) == A and int(i*0.10) == B: print(i) break else: print(-1)" p02755,s686800031,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)] import math flag=False ans=-1 for i in range(1,10001): a2=i*0.08 a1=int(i*0.08) b1=int(i*0.1) if a1==a and b1==b: ans=i break print(ans) " p02755,s060180872,Accepted,"a,b=map(int,input().split()) if ((25*a)+1)//2 > 10*b+9 or ((25*(a+1))-1)//2 < 10*b: print(-1) else: print(max(10*b,((25*a)+1)//2))" p02755,s972128229,Accepted,"a, b = map(int, input().split()) for x in range(1, 1010): if int(x*0.08)==a and int(x*0.10)==b: print(x) exit() print(-1) " p02755,s837649846,Accepted,"import sys input = sys.stdin.readline def main(): a, b = map(int, input().split()) for i in range(1250+1): a_ = int(i * 0.08) b_ = int(i * 0.1) if a == a_ and b == b_: print(i) return print(-1) if __name__ == ""__main__"": main() " p02755,s202697518,Accepted,"A, B = map(int, input().split()) for i in range(10000): a = int(i * 1.08) - i b = int(i * 1.10) - i if a == A and b == B: print(i) exit() print(-1)" p02755,s541526708,Accepted,"A, B = map(int, input().split()) S = B * 10 ans = -1 while S < (B+1) * 10: if int(S*0.08) == A: if ans != -1: ans = min(ans, S) else: ans = S S += 1 print(ans)" p02755,s247798109,Accepted,"a, b = [int(i) for i in input().split()] e_min = a/0.08 e_max = (a+1)/0.08 t_min = int(b/0.1) t_max = int((b+1)/0.1) num = -1 for i in range(t_min, t_max): if i >= e_min and e_max > i: num = i break print(num)" p02755,s188055772,Accepted,"A, B = map(int, input().split()) for i in range(1101): if int(i*0.08) == A and int(i*0.10) == B: print(i) break elif i == 1100: print(""-1"")" p02755,s296482758,Accepted,"import math A,B=map(int,input().split()) for i in range(1,1010): if math.floor(i*0.08)==A and math.floor(i*0.1)==B: print(i) exit() print(-1) " p02755,s374287951,Accepted,"import sys a, b = map(int, sys.stdin.readline().split()) def main(): for i in range(1, 1251): if i * 0.1 // 1 == b and i * 0.08 // 1 == a: return i return -1 if __name__ == '__main__': ans = main() print(ans)" p02755,s919778538,Accepted,"A,B = map(int,input().split()) abc = -1 for i in range(10000,-1,-1): tax1 = int(i*0.08) tax2 = int(i*0.1) if tax1 == A and tax2 == B: abc = i print(abc)" p02755,s851474686,Accepted,"a,b = map(int,input().split()) low = int(min(a//0.08,b//0.1)) high = int(max((a+1)//0.08,(b+1)//0.1)) for i in range(low,high+1): if int(i*0.08)==a and int(i*0.1)==b: print(i); break else: print(-1)" p02755,s334720833,Accepted,"a,b=map(int,input().split()) for i in range(1,10000): if int(i*0.08)==a and int(i*0.1)==b: print(i) break else: print(-1) " p02755,s034293702,Accepted,"import math a,b = map(int,input().split()) for i in range(1,1001): if math.floor(i*0.08) == a and math.floor(i*0.1) == b: print(i) break else: print(-1)" p02755,s848149409,Accepted,"def resolve(): a, b = map(int, input().split()) for i in range(1, 1010): if int (i * 0.08) == a and int(i*0.1) == b: return print(i) print(-1) if __name__ == '__main__': resolve()" p02755,s628301863,Accepted,"a, b = map(int, input().split()) ans = -1 for i in range(1, 2000): if int(i * 0.08) == a and int(i * 0.1) == b: ans = i break print(ans) " p02755,s059385109,Accepted,"def main(): A, B = list(map(int, input().split())) for i in range(1010): if int(i * 0.08) == A and int(i * 0.1) == B: return i return -1 print(main()) " p02755,s763391425,Accepted,"import math from decimal import * A,B=list(map(lambda i:int(i),input().split())) Amax = (A+0.9) Amax= Decimal(str(Amax))/ Decimal('0.08') Amin = Decimal(str(A))/ Decimal('0.08') Bmax= (B+0.9) Bmax= Decimal(str(Bmax)) * Decimal('10') Bmin = Decimal(str(B)) * Decimal('10') As = list(range(math.ceil(Amin), math.floor(Amax)+1)) Bs = list(range(math.ceil(Bmin), math.floor(Bmax)+1)) A_B = set(As) & set(Bs) if len(A_B)==0: print(-1) else: print(min(A_B)) " p02755,s311438807,Accepted,"import math a,b=map(int,input().split()) flag=True for i in range(10**6): if math.floor(i*0.08)==a and math.floor(i*0.1)==b: print(i) flag=False exit() if flag: print(-1)" p02755,s993728240,Accepted,"a,b = map(int,input().split()) bb = b * 10 ans = -1 for i in range(bb, bb+10): if i*8//100==a: ans=i break print(ans) " p02755,s016412370,Accepted,"A,B=map(int,input().split()) for i in range(1251): a=(i*1.08)//1-i b=(i*1.1)//1-i if a==A and b==B: print(i) exit() print(-1) " p02755,s969513841,Accepted,"a, b = map(int, input().split()) for p in range(1010): if int(p*0.08) == a and int(p*0.1) == b: print(p) exit() print(-1) " p02755,s633914482,Accepted,"A, B = map(int, input().split()) import math ans = -1 for i in range(13, 1001): if math.floor(i * 0.08) == A and math.floor(i * 0.1) == B : ans = i break print(ans)" p02755,s711229242,Accepted,"from math import ceil A, B = map(int,input().split()) def non_taxed_price_8(x): min_8 = x*12.5 Max_8 = (x+1)*12.5 eight = set(range(ceil(min_8), ceil(Max_8))) return eight def non_taxed_price_10(x): min_10 = x*10 Max_10 = (x+1)*10 ten = set(range(ceil(min_10), ceil(Max_10))) return ten a = non_taxed_price_8(A) b = non_taxed_price_10(B) r = a&b if len(r) == 0: print(-1) else: print(min(list(r))) " p02755,s977448079,Accepted,"import math a, b = map(int, input().split()) K = [i for i in range(10, 1251)] ans = -1 for k in K: if math.floor(k*0.08) == a and math.floor(k*0.1) == b: ans = k break print(ans)" p02755,s730608996,Accepted,"A, B = map(int, input().split()) for i in range(1, 10001): if int(i*0.08) == A and int(i*0.1) == B: print(i) break if i == 10000: print(-1)" p02755,s023662102,Accepted,"import sys import math a,b = map(int,input().split()) for i in range(1,1001): x = math.floor(0.08 * i) y = math.floor(0.1 * i) if x == a and y == b: print(i) sys.exit() print(-1)" p02755,s739304341,Accepted,"a, b = map(int,input().split()) start = -(-b//0.1) ans = 0 for i in range(int(start),int(start+10)): if int(i * 0.08) == a: ans = i break if ans ==0: ans = -1 print(ans) " p02755,s638846954,Accepted,"import sys s = sys.stdin.readline().split() a, b = map(int, s) orig_a = a/0.08 if int(orig_a) < orig_a: left = int(orig_a) + 1 else: left = int(orig_a) right = left + 1 while True: if int(right * 0.08) > a: break right += 1 for i in range(left, right): if int(i * 0.1) == b: print(i) sys.exit(0) print(-1) " p02755,s271064149,Accepted,"A, B=list(map(int, input().split())) for n in range(10001): tax_A = n*8//100 tax_B = n*10//100 if A==tax_A and B==tax_B: print(n) exit() print(-1) " p02755,s903114258,Accepted,"A, B = map(int, input().split()) for i in range(10000): if int(i * 0.08) == A and int(i * 0.1) == B: print(i) break else: print(-1) " p02755,s040636637,Accepted,"def main(): A, B = map(int, input().split()) for v in range(0, 100000): if int(v * 0.08) == A and int(v * 0.1) == B: return v return -1 if __name__ == '__main__': print(main()) " p02755,s442557115,Accepted,"a, b = map(int, input().split()) a *= 25 b *= 10 r = max((a + 1) // 2, b) print((-1, r)[r < min((a + 26) // 2, b + 10)]) " p02755,s337786415,Accepted,"a,b=map(int,input().split()) for i in range(1,1251): if a==(i*0.08)//1 and b==(i*0.1)//1: print(i) exit() print(-1)" p02755,s461201080,Accepted,"from math import ceil A, B = map(int, input().split()) x = max(ceil(A / 0.08), ceil(B / 0.1)) if x < (A + 1) / 0.08 and x < (B + 1) / 0.1: print(x) else: print(-1) " p02755,s637217317,Accepted,"A,B=map(int,input().split()) for i in range(10**6): if i*8//100==A and i*10//100==B: print(i) break else: print(-1) " p02755,s136141386,Accepted,"a,b=map(int,input().split()) n=1 while n<=10**6: if int(n*0.08)==a and int(n*0.1)==b: print(n) exit() else: n+=1 print(-1)" p02755,s564037066,Accepted,"printn = lambda x: print(x,end='') inn = lambda : int(input()) inl = lambda: list(map(int, input().split())) inm = lambda: map(int, input().split()) ins = lambda : input().strip() DBG = True # and False BIG = 10**18 R = 10**9 + 7 def ddprint(x): if DBG: print(x) a,b = inm() for i in range(1,11000): if (i*8)//100==a and (i*10)//100==b: print(i) exit() print(-1) " p02755,s157672712,Accepted,"A, B = map(int, input().split()) ans = -1 for i in range(1010): #print([i, int(i*0.08), int(i*0.1)]) if (A==int(i*0.08)) & (B==int(i*0.1)): ans = i break print(ans)" p02755,s203501609,Accepted,"A, B = map(int, input().split(' ')) for i in range(1500): if i * 8 // 100 == A and i * 10 // 100 == B: print(i) break else: print(-1)" p02755,s577838181,Accepted,"a, b = map(int, input().split()) a_min = int(a / 0.080 + 0.9) a_max = int((a + 0.9) / 0.080) b_min = int(b / 0.100 + 0.9) b_max = int((b + 0.9) / 0.100) if a_max < b_min or b_max < a_min: ans = -1 elif a_min <= b_min: ans = b_min elif b_min <= a_min: ans = a_min print(ans)" p02755,s952353503,Accepted,"A,B=[int(x) for x in input().rstrip().split()] count=0 for i in range(1,20000): ans1=int(0.08*i) ans2=int(0.1*i) if ans1==A and ans2==B: print(i) count=1 break if count==0: print(-1)" p02755,s558765429,Accepted,"from math import floor A, B = map(int, input().split()) for i in range(1000): if floor((i + 1) * 0.08) == A and floor((i + 1) * 0.1) == B: print(i + 1) exit() print(-1)" p02755,s151392262,Accepted,"import math A, B = map(int, input().split()) down_a = math.ceil(A / 0.08) up_a = math.ceil((A+1) / 0.08) down_b = int(B / 0.1) up_b = int((B+1) / 0.1) a = [i for i in range(down_a, up_a)] b = [j for j in range(down_b, up_b)] ans = -1 for num in a: if num in b: ans = num break; print(ans)" p02755,s397076932,Accepted,"a, b = map(int, input().split()) x = -1 for i in range(1, 1001): if int(i * 0.08) == a and int(i * 0.1) == b: x = i break print(x)" p02755,s640962227,Accepted,"A, B = map(int, input().split()) for i in range(1, 10001): if int(i*0.08) == A and int(i*0.1) == B: print(i) break else: print(-1)" p02755,s820409570,Accepted,"import math a, b = list(map(int, input().split())) price = math.ceil(a / 0.08) #print(price) price_ = math.floor(b / 0.1) #print(price_) if price < price_: start, end = price, price_ else: start, end = price_, price for i in range(start, end+1): #print(math.floor(i * 0.08),math.floor(i * 0.1)) #print(i) if math.floor(i * 0.08) == a and math.floor(i * 0.1) == b: print(i) exit() if price == price_: print(price) exit() print(-1) " p02755,s030332782,Accepted,"import math A, B = input().split() A = float(A) B = float(B) cand_a = math.ceil(12.5*A) cand_b = math.ceil(10*B) max_a = math.floor(12.5*(A + 1)) max_b = math.floor(10*(B + 1)) if cand_a > cand_b: if cand_a < max_b: ans = cand_a else: ans = -1 elif cand_b > cand_a: if cand_b < max_a: ans = cand_b else: ans = -1 else: ans = cand_a print(ans)" p02755,s078907860,Accepted,"A, B = map(int, input().split()) x = 0 while int(x * 0.08) <= A or int(x * 0.1) <= B: x += 1 if int(x * 0.08) == A and int(x * 0.1) == B: print(x) exit() print(-1) " p02755,s389526062,Accepted,"import math a, b = map(int,input().split()) result = -1 for i in range(1,1001): pa = math.floor(i * 0.08) pb = math.floor(i * 0.1) if pa == a and pb == b : result = i break print(result)" p02755,s831819556,Accepted,"import math A, B = map(int, input().split()) INF = 10**4 for x in range(INF): if math.floor(x * 0.08) == A: if math.floor(x * 0.10) == B: print(x) exit() print(-1)" p02755,s885540649,Accepted,"import sys input = lambda: sys.stdin.readline().rstrip() import math def resolve(): A, B = map(int, input().split()) ans = -1 for i in range(2000): if math.floor(i*0.08)==A and math.floor(i*0.10)==B: ans = i break print(ans) if __name__ == '__main__': resolve() " p02755,s481691191,Accepted,"import math AB = list(map(int, input().split())) N2min = AB[1] * 10 N2max = AB[1] * 10 + 9 N1min = int(AB[0] * 12.5) N1max = int((AB[0] + 0.9) * 12.5) if (N2min <= N1max) and (N1min <= N2max): if (N1min < N2min): print(N2min) else: i = 0 while (int((N1min - i) * 0.08) == AB[0]): i += 1 print(N1min - i + 1) else: print(-1)" p02755,s931855066,Accepted,"# coding: utf-8 a, b = map(int, input().split()) for i in range(1250): if int(0.08*i) == a and int(0.1*i) == b: print(i) break else: if i == 1249: print(-1) i += 1 " p02755,s118379725,Accepted,"import math A,B=map(int,input().split()) for i in range(10**5): a=math.floor(i*0.08) b=math.floor(i*0.10) if a==A and b==B: print(i) exit() if a>A or b>B: print(-1) exit()" p02755,s431540861,Accepted,"import math A,B=map(int, input().split()) X1=math.ceil(A/0.08) X2=math.floor((A+1)/0.08) if (A+1)*100%8==0: X2=X2-1 Y1=math.ceil(B/0.1) Y2=math.floor((B+1)/0.1)-1 if (Y1>X2)or(X1>Y2): print(-1) elif X1>=Y1: print(X1) else: print(Y1) " p02755,s711129966,Accepted,"import math a, b = map(int, input().split()) ans = -1 for i in range(1, 1250): if math.floor(i*0.08) == a and math.floor(i*0.1) == b: ans = i break print(ans) " p02755,s807266053,Accepted,"a,b=map(int,input().split()) for i in range(1,1001): if int(i*0.08)==a and int(i*0.1)==b: print(i) break else: print(-1)" p02755,s998688994,Accepted,"import math a,b = map(int,input().split()) for x in range(0,2000): if math.floor(x*0.08)==a and math.floor(x*0.10)==b: print(x) break else: print(-1) " p02755,s650549809,Accepted,"import math a,b=map(int,input().split()) for i in range(10000): if math.floor(i*0.08)==a and math.floor(i*0.1)==b: print(i) exit() print(-1)" p02755,s333146350,Accepted,"from math import ceil A, B = map(int, input().split()) max_A = (A+1)*12.5 min_A = (A)*12.5 max_B = (B+1)*10.0 min_B = B*10.0 if min_A < max_B and min_A >= min_B: print(ceil(min_A)) elif min_B < max_A and min_B >= min_A: print(ceil(min_B)) else: print(-1) " p02755,s328200627,Accepted,"def C158(): A, B = [int(_) for _ in input().split()] N = 1 while N <= 10000: if int(N * 8/100) == A and int(N * 10/100) == B: break N += 1 if N <= 10000: print(N) else: print(-1) if __name__ == ""__main__"": C158()" p02755,s467990671,Accepted,"from math import ceil a,b = map(int,input().split()) ah=(a+1)//0.08 al=ceil(a/0.08) bh=(b+1)//0.1 bl=ceil(b/0.1) if ah < al or bh < bl: ans = -1 else: if (al <= bh and ah >= bl) or (al >= bh and ah <= bl): ans = max(al,bl) else: ans = -1 print(ans)" p02755,s970467654,Accepted,"import math A,B = map(int,input().split()) ans = 0 for i in range(1001): pay = i * 0.08 pby = i * 0.1 if math.floor(pay) == A and math.floor(pby) == B: ans = i break else: ans = -1 print(ans)" p02755,s714768382,Accepted,"import math A,B = map(int,input().split()) a = A / 0.08 b = B / 0.1 #print(a,b) if a > b: if int(a * 0.1) == B: print(math.ceil(a)) else: print(-1) elif b > a: if int(b * 0.08) == A: print(math.ceil(b)) else: print(-1) else: print(math.ceil(a)) " p02755,s403681777,Accepted,"import math A, B = map(int, input().split()) X = 13 while math.floor(X * 0.08) != A or math.floor(X * 0.10) != B: X += 1 if math.floor(X * 0.08) > A: X = -1 break print(X)" p02755,s593612943,Accepted,"a, b = map(int, input().split()) for x in range(b * 10, (b + 1) * 10): if int(x * 0.08) == a: print(x) break else: print(-1)" p02755,s988975050,Accepted,"#a,b小さいのでこれで可 a,b = map(int, input().split( )) mn = int(a/(0.1))-5 mx = int(b/0.08)+3 for i in range(mn,mx): if int(i*0.08)==a and int(i*0.1)==b: print(i) exit() print(-1) " p02755,s610068902,Accepted,"A, B = map(int,input().split()) ans = -1 for i in range(10**5): if i*8//100 == A and i*10//100 == B: ans = i break elif i*8//100 > A and i*10//100 > B: break print(ans)" p02755,s252907092,Accepted,"def readinput(): a,b=map(int,input().split()) return a,b def main(a,b): for i in range(20000): if i*108//100 - i ==a and i*110//100 - i ==b: return i return -1 if __name__=='__main__': a,b=readinput() ans=main(a,b) print(ans) " p02755,s302536101,Accepted,"A,B = (int(x) for x in input().split()) for n in range(0,1009): za = n*8//100 zb = n*10//100 if za == A and zb == B: print(n) exit() print(-1) " p02755,s782331478,Accepted,"A, B = map(int, input().split()) def check(x): a = int(x * 0.08) b = int(x * 0.10) if (a == A) and (b == B): return True else: return False for i in range(1, 10000): if check(i): print (i) exit() print (-1)" p02755,s468814419,Accepted,"tax8 = 0.08 tax10 = 0.1 a,b = map(int,input().split()) t8 = int(a / tax8) t10 = int(b / tax10) tmp8 = 0 for i in range(t8,0,-1): if(not (int(i * tax8) == a)): tmp8 = i + 1 break l = [] for i in range(tmp8,tmp8+20): if(int(i * tax8) == a): l += [i] else: break ll = [] for i in l[::-1]: if(int(i * tax10) == b): ll += [i] if(not (ll == [])): print(min(ll)) else: print(-1)" p02755,s333106642,Accepted,"# -*- coding: utf-8 -*- i_str = input() A,B = map(int,i_str.split()) import sys import math #price = 10 #X = math.floor(price * 0.08) #Y = math.floor(price*0.1) if A > B: print(-1) for i in range(B*100): if math.floor(i * 0.08) == A and math.floor(i * 0.1) == B: print(i) sys.exit() print(-1) " p02755,s854486949,Accepted,"a, b =map(int,input().split()) x = 9 while True: if a == int(x * 0.08) and b == int(x*0.1): print(x) break elif a < int(x * 0.08) and b < int(x*0.1): print(-1) break x += 1 " p02755,s253971896,Accepted,"import math A, B = map(int, input().split()) for i in range(1, 1251): if math.floor(i * 0.08) == A and math.floor(i * 0.1) == B: print(i) break else: print(-1)" p02755,s352485061,Accepted,"import math a,b = map(int,input().split()) for i in range(1,1100): if math.floor(i * 0.08) == a and math.floor(i * 0.1 )== b: print(i) exit() print(-1)" p02755,s324410067,Accepted,"a, b = map(int, input().split()) import math if 10*(b+1) <= 12.5*a or 12.5*(a+1) <= 10*b: print(-1) else: print(max(math.ceil(12.5*a), 10*b)) " p02755,s053290390,Accepted,"a,b=list(map(float,input().split())) import sys for i in range(100000): if int(i*8/100)==a and int(i*10/100)==b: print(i) sys.exit() print(-1) " p02755,s414467705,Accepted,"A,B=map(int,input().split()) ans=-1 for i in range(10000): x=int(i*0.08) y=int(i*0.1) if A==x and B==y: ans=i break print(ans)" p02755,s325812580,Accepted,"def input_int_list(): return [int(thing) for thing in input().split("" "")] def No(): print(-1) exit() def eight(x): return int(x*0.08//1) def ten(x): return int(x*0.1//1) A,B=input_int_list() for i in range(1,1009): if eight(i)==A and ten(i)==B: print(i) exit() No() " p02755,s811996496,Accepted,"x, y = list(map(int,(input().split()))) for a in range(1,10001): if int(a * 0.1) == y: if int(a * 0.08) == x: print(a) exit() print(-1)" p02755,s863514389,Accepted,"p=input().split("" "") a=int(p[0]) b=int(p[1]) c=a*10-1 d=int(a/0.07)-1 num=[] ans=[] for i in range(c,d+1): if int(i*0.08)==a: num.append(i) l=len(num) for i in range(l): if int(num[i]*0.1)==b: ans.append(num[i]) if ans==[]: print(""-1"") else: print(ans[0])" p02755,s991832569,Accepted,"from sys import stdin def main(): #入力 readline=stdin.readline a,b=map(int,readline().split()) for n in range(b*10,b*10+10): if n*8//100==a: print(n) break else: print(-1) if __name__==""__main__"": main()" p02755,s146196580,Accepted,"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) == B: print(i) exit() print(""-1"")" p02755,s166276436,Accepted,"mi = lambda : map(int,input().split()) a,b = mi() for i in range(1,1002): if((int(i*0.08) == a) & (int((i*0.1)) == b)): print(i) break else: print('-1') " p02755,s732829406,Accepted,"import math A, B = map(int,input().split()) for i in range(1001): if math.floor(i*0.08) == A and math.floor(i*0.10) == B: print(i) break else: print(-1)" p02755,s711138722,Accepted,"n,m=map(int,input().split()) for i in range(1,1263): if int(i*0.08)==n and int(i*0.1)==m: print(i) break else: print(-1)" p02755,s982916476,Accepted,"a, b = map(int, input().split()) flag = 0 for i in range(10*b, 10*(b + 1)): if int(i * 0.08) == a: flag = 1 break if flag: print(i) else: print('-1')" p02755,s576546205,Accepted,"tax8, tax10 = map(int,input().split()) import math tax10_list = [] list = [] count = 0 for i in range(10): tax10_list.append(math.floor(tax10*10+i)) for x in range(10): if math.floor(tax10_list[x] * 0.08) == tax8: print(tax10_list[x]) break else: count += 1 if count == 10: print(""-1"") else: None" p02755,s421582184,Accepted,"import math count = 0 a, b = map(int, input().split()) k = 10 * b while 10 * b <= k < 10*b + 10: if math.floor(0.08 * k) == a: print(k) count += 1 break else: k += 1 if count == 0: print(-1)" p02755,s149124645,Accepted,"import math A, B = map(int, input().split()) ans = [] for i in range(1010): ans8 = math.floor(i * 0.08) ans10 = math.floor(i * 0.1) if ans8 == A and ans10 == B: ans.append(i) if len(ans) != 0: print(min(ans)) else: print(-1)" p02755,s343097957,Accepted,"A, B = (int(i) for i in input().split()) A_list = [] for i in range(8001): tmp = int(i*0.08) if tmp==A: A_list.append(i) B_list = [] for i in range(10001): tmp = int(i*0.1) if tmp==B: B_list.append(i) and_list = set(A_list)&set(B_list) try: print(min(and_list)) except: print(-1)" p02755,s429271746,Accepted,"a,b = map(int,input().split()) al = [] bl = [] import math ans = -1 for i in range(1,1251): if math.floor(i*0.08) == a: if math.floor(i*0.1) == b: ans = i break print(ans)" p02755,s895738289,Accepted,"a,b=map(int,input().split());print(([i for i in range(10**6)if(i//12.5==a)*i//10==b]+[-1])[0])" p02755,s489100148,Accepted,"import math (a, b) = [int(s) for s in input().split()] ans = -1 for i in range(1, 10001): c = math.floor(i * 0.08) d = math.floor(i * 0.10) if a == c and b == d: ans = i break print(ans)" p02755,s163818319,Accepted," a,b = map(int, input().split()) for i in range(1, 1001): if int(i * 0.08) == a and int(i * 0.1) == b: print(i) exit() print(-1) " p02755,s758253235,Accepted,"import sys A, B = map(int, input().split()) for i in range(10 ** 5): if int(i * 0.08) == A and int(i * 0.1) == B: print(i) sys.exit() else: continue else: print(-1)" p02755,s587125411,Accepted,"i=list(map(int, input().split())) a=i[0] b=i[1] k=1001 for j in range (1000,0,-1): if int(j*0.08)==a and int(j*0.1)==b: k=j if k==1001: print(-1) else: print(k)" p02755,s511304221,Accepted,"A, B = map(int, input().split()) for i in range(1300): if int(i * 0.08) == A and int(i * 0.1) == B: print(i) break else: print('-1') " p02755,s612224428,Accepted,"# import numpy as np # import math # import copy # from collections import deque import sys input = sys.stdin.readline # sys.setrecursionlimit(10000) def main(): A,B = map(int,input().split()) res = -1 for i in range(1,1251): price8 = int(i*0.08) price10 = int(i*0.1) if (price8 == A) & (price10 == B): res = i break print(res) main() " p02755,s898146892,Accepted,"a, b = map(int, input().split()) def solve(n): x = n * 8 // 100 y = n * 10 // 100 return x == a and y == b ans = -1 for n in range(20000): if solve(n): ans = n break print(ans)" p02755,s761116984,Accepted,"# input A,B = map(int, input().split()) # calculate price = -1 for n in range(10000): if int(n * 0.08) == A and int(n * 0.1) == B: price = n break else: pass # output print(price)" p02755,s819470949,Accepted,"import math A, B = map(int, input().split()) lsta = list(range(math.ceil(12.5*A), math.ceil((A+1)*12.5))) ans = -1 for i in lsta: if int(i*0.1)==B: ans=i break print(ans)" p02755,s030920536,Accepted,"import sys input = sys.stdin.readline a, b = [int(i) for i in input().split()] start = int(((a * 100)/8) + 0.5) if a % 2 == 0: candidate1 = list(range(start, start + 13)) else: candidate1 = list(range(start, start + 12)) start = (b * 10) candidate2 = list(range(start, start + 10)) ans = -1 for i in candidate2: if i in candidate1: ans = i break print(ans) " p02755,s034670402,Accepted,"import math b, c = map(int, input().split()) b_before_min = math.ceil(b / 0.08) b_before_max = (b+1) / 0.08 c_before_min = math.ceil(c / 0.1) c_before_max = (c+1) / 0.1 # maxは取り得ない値.0 if(c_before_min <= b_before_min and b_before_min < c_before_max): print(int(b_before_min)) elif(b_before_min <= c_before_min and c_before_min < b_before_max): print(int(c_before_min)) else: print(-1) " p02755,s353451562,Accepted,"a, b = input().split("" "") a, b = int(a), int(b) ans = -1 for i in range(1, 1010): if (int(i * 0.08) == a) and (int(i * 0.10) == b): ans = i break print(ans)" p02755,s449561811,Accepted,"import math A, B = list(map(int,input().split())) cnt = 0 for i in range(1,100000): X = math.floor(i * 0.08) Y = math.floor(i * 0.1) if A == X and B == Y: print(i) cnt += 1 break if cnt == 0: print(-1)" p02755,s616435438,Accepted,"def main(): A, B = map(int, input().split()) for x in range(1, 1010): if int(x * 0.08) == A and int(x * 0.1) == B: print(x) return print(-1) if __name__ == ""__main__"": main() " p02755,s526765389,Accepted,"a,b = map(int,input().split()) for i in range(1,100000): if i*8//100==a and i*10//100==b: print(i) break else: print(-1)" p02755,s693891293,Accepted,"A, B = map(int, input().split()) ans = -1 for i in range(1251): if int(i * 0.08) == A and int(i * 0.1) == B: ans = i break print(ans)" p02755,s785330862,Accepted,"a, b = map(int, input().split()) flag = False for i in range(1300): if i * 8 // 100 == a and i * 10 // 100 == b: flag = True break if flag: print(i) else: print(-1)" p02755,s141506380,Accepted,"a, b = map(int, input().split()) ans = 2000 for i in range(2000): if i * 8 // 100 == a and i // 10 == b: ans = min(ans, i) if ans == 2000: print(-1) else: print(ans) " p02755,s741428591,Accepted,"n,m= map(int,input().split()) num = 0 f_n = False f_m = False num_n = 0 num_m = 0 while True: num_n = int(num * 0.08) num_m = int(num * 0.1) if int(num_n) == n: f_n = True if int(num_m) == m: f_m = True if f_m == True and f_n == True: print(num) break if num_m > 100 or num_n > 100 : print(-1) break f_m = False f_n = False num += 1 " p02755,s600826193,Accepted,"A,B = list(map(int,input().split())) for i in range(min(int(A / 0.08),int(B / 0.10) ),max(int((A+1)/0.08),int((B+1)/0.08))): # print(i) if int(i*0.08) == A and int(i*0.10) == B: print(i) break else: print(-1)" p02755,s221496432,Accepted,"import sys A, B = map(int, sys.stdin.readline().split()) for i in range(20000): a = int(i * 0.08) b = int(i * 0.10) if a == A and b == B: print(i) sys.exit() print(-1)" p02755,s315233195,Accepted,"a,b = map(int, input().split()) cnt=0 ans=0 for x in range(1,1010): if 8*x//100==a and x//10==b: cnt += 1 ans=x break if cnt>0: print(ans) else: print(-1)" p02755,s299923978,Accepted,"a,b = map(int,input().split()) import math for i in range(1,1101): a1 = int( math.floor( i * 0.08 ) ) if a1 == a: b1 = int( math.floor( i * 0.10 ) ) if b1 == b: print(i) exit() print(-1)" p02755,s086453317,Accepted,"a,b = map(int,input().split()) s = 1 / 0.08 t = 1 / 0.1 ans = -1 for i in range(1009): if i//s==a and i//t==b: ans = i break print(ans)" p02755,s282046450,Accepted,"N=[i for i in range(1,1001)] A,B=map(int,input().split()) for j in range(len(N)): m=int(N[j]*0.08) if m>A: break elif m==A: M=int(N[j]*0.1) if M==B: print(N[j]) exit() elif M>B: break print(-1)" p02755,s675352520,Accepted,"from math import floor a,b=map(int,input().split()) A=[] B=[] for i in range(1,10001): x=int(floor(i*0.08)) y=int(floor(i*0.1)) if x==a: A.append(i) if y==b: B.append(i) A=set(A) B=set(B) ans=list(A&B) if ans: print(min(ans)) else: print(-1)" p02755,s026920771,Accepted,"import sys input = sys.stdin.readline import math A, B = [int(x) for x in input().split()] for i in range(10 ** 6): if math.floor(i * 0.08) == A and math.floor(i * 0.1) == B: print(i) sys.exit() print(-1)" p02755,s986193357,Accepted,"a,b=map(int,input().split());l=max(0--a*25//2,b*10);print([-1,l][l 1500): print(-1) break else: x += 1" p02755,s333126865,Accepted,"import math import sys x,y= map(int,input().split()) for i in range(1001): if math.floor(i *0.08) == x and math.floor(i *0.10) == y: print(i) sys.exit() print(-1)" p02755,s811154735,Accepted,"import math a, b = [int(x) for x in input().split()] mina, maxa = math.ceil(a / 0.08), math.ceil((a+1) / 0.08)-1 minb, maxb = b * 10, (b+1) * 10 -1 if minb <= maxa and minb >= mina: print(minb) elif mina <= maxb and mina >= minb: print(mina) else: print(-1)" p02755,s934489569,Accepted,"A, B = [int(i) for i in input().split()] candidate = [i for i in range(10*B, 10*(B+1))] result_list = [i for i in candidate if (25/2) * A <= i and i < (25/2) * (A+1)] if result_list == []: print(-1) else: print(min(result_list))" p02755,s058114354,Accepted,"from math import ceil,floor A,B=map(int,input().split()) x_min=int(min(ceil(A/0.08)-5, ceil(B/0.1)-5)) x_max=int(max(ceil((A+1)/0.08)+5, ceil((B+1)/0.1)+5)) exists=0 for i in range(x_min, x_max): if floor(i*0.08)==A and floor(i*0.1)==B: print(i) exists=1 break if not exists:print(-1)" p02755,s470081586,Accepted,"A, B = [int(i) for i in input().split("" "")] for i in range(B * 100): tmp1 = int(i * 0.08) tmp2 = int(i * 0.1) if tmp1 == A and tmp2 == B: print(i) break else: print(-1)" p02755,s301563070,Accepted,"import sys import math a, b = [int(s) for s in sys.stdin.readline().strip().split()] ans = -1 for i in range(1, 2000): if math.floor(i * 0.08) == a and math.floor(i * 0.1) == b: ans = i break print(ans)" p02755,s056024147,Accepted,"#!python3 iim = lambda: map(int, input().rstrip().split()) def resolve(): A, B = iim() ans = 10 * B for i in range(ans, ans+10): if (8*i) // 100 == A: print(i) return print(-1) if __name__ == ""__main__"": resolve() " p02755,s193775849,Accepted,"a, b = map(int,input().split()) for i in range(1005): if int(i*0.08)==a and int(i*0.1)==b: print(i) break else: print(-1)" p02755,s210362238,Accepted,"#57 import decimal a,b = map(int,input().split()) for i in range(1,10001): num1 = int(i*decimal.Decimal(""0.08"")) num2 = int(i*decimal.Decimal(""0.1"")) if num1 == a and num2 == b: print(i) break if int(i*decimal.Decimal(""0.08"")) > a: print(""-1"") break" p02755,s720379377,Accepted,"A,B=map(int,input().split()) for i in range(1,10101): if int(i*0.08)==A and int(i*0.1)==B: print(i) exit(0) else: print(-1)" p02755,s076298082,Accepted,"from math import floor a, b = map(int, input().split()) for i in range(10000): x = floor(i * 0.08) y = floor(i * 0.1) if x == a and y == b: print(i) exit(0) print(-1) " p02755,s246512244,Accepted,"a, b = map(int, input().split()) tmp_a = int((a / 0.08) // 1) tmp_b = int((b / 0.10) // 1) check = True # print(tmp_a, tmp_b) for i in range(min(tmp_a,tmp_b), max(tmp_a + 1, tmp_b + 1) + 1): if int((i * 0.08)//1) == a and int((i * 0.10)//1) == b: print(i) check = False break if check: print(-1)" p02755,s737737357,Accepted,"A,B = map(int,input().split()) isok = False for i in range(1,2000): n1 = i * 0.08 n2 = i * 0.1 n1 = n1//1 n2 = n2//1 if(n1==A and n2==B): print(i) isok=True break if(not isok): print(-1)" p02755,s129304873,Accepted,"a, b = map(int, input().split()) for i in range(10000): if int(i * 0.08) == a and int(i * 0.1) == b: print(i) exit() print('-1') " p02755,s433134282,Accepted,"a, b = map(int, input().split()) a_max = ( a + 1) // 0.08 b_max = ( b + 1) // 0.1 max = int(a_max) if a_max > b_max else int(b_max) flg = 0 for i in range(1, max): if int(i * 0.08) == a and int(i * 0.1) == b: flg = 1 print(i) break if flg == 0: print(-1)" p02755,s764781711,Accepted,"i = [int(s) for s in input().split()] a = i[0] b = i[1] min = (a*10) -1 max = (b*12.5) +1 c1=0 c2=0 while min < max: c1 = int(min * 0.08) c2 = int(min * 0.1) if c1 == a and c2 == b: print(min) break else: min += 1 else: print(-1)" p02755,s157999009,Accepted,"A,B=map(int,input().split()) for money in range(1,1001): if int(money*0.08)==A and int(money*0.1)==B: print(money) break else: print(-1)" p02755,s188139442,Accepted,"import math a,b=map(int,input().split()) b*=10 ans=0 for i in range(9): j=b j+=i if int(j*0.08)==a: ans=j break if ans!=0: print(ans) else : print(-1) " p02755,s247474502,Accepted,"a,b=map(int,input().split()) for i in range(0,1001): if int(i*0.08)==a and int(i*0.1)==b: print(i) exit() print(-1)" p02755,s535988500,Accepted,"import math import sys A, B = map(int, input().split()) for c in range(1, 100 * 20 + 1): if math.floor(c * 0.08) == A and math.floor(c * 0.1) == B: print(c) sys.exit() else: print(-1) " p02755,s968846272,Accepted,"from math import floor a,b=map(int,input().split()) for i in range(1010): if floor(i*0.08)==a and floor(i*0.1)==b: print(i) exit() print(-1)" p02755,s805566530,Accepted,"import math a, b = map(int,input().split()) ans = [] for x in range(1,1009): if math.floor(x * 0.08 )== a and math.floor(x * 0.1) == b: ans.append(x) if len(ans) == 0: print(""-1"") else: print(min(ans))" p02755,s939980560,Accepted,"import math A,B=map(int,input().split()) amin = A/0.08 amax = (A+1)/0.08 bmin = B/0.1 bmax = (B+1)/0.1 if bmin == amax or amin == bmax: print(-1) else: ans = max(amin, bmin) ans = math.ceil(ans) if ans < amax and ans < bmax: print(ans) else: print(-1) " p02755,s006085249,Accepted,"import math A, B = map(int, input().split()) Al = math.ceil(A / 0.08) Au = int((A + 0.99) // 0.08) + 1 Bl = math.ceil(B / 0.1) Bu = int((B + 0.9) // 0.1) + 1 Ar = [x for x in range(Al, Au)] Br = [y for y in range(Bl, Bu)] X = set(Ar) & set(Br) print(-1 if list(X) == [] else min(X))" p02755,s056831461,Accepted,"from math import floor from sys import exit, stdin A, B = [int(_) for _ in stdin.readline().rstrip().split()] for i in range(1, 10000): if floor(i*0.08) == A and floor(i*0.1) == B: print(i) exit() print(-1)" p02755,s176663930,Accepted,"A, B = map(int, input().split()) min_ans = int((12.5*A) // 1) max_ans = int(-((-12.5*(A+1)) // 1)) ans = -1 for i in range(min_ans,max_ans): temp_A = (i*0.08)//1 temp_B = (i*0.1)//1 if temp_A == A and temp_B == B : ans = i break print(ans)" p02755,s927608460,Accepted,"a, b = map(int,input().split()) i = 0 ans = -1 while True: if int(i*0.080) == a and int(i*0.10) == b: ans = i break elif int(i*0.080) > a or int(i*0.10) > b: break i += 1 print(ans) " p02755,s241601240,Accepted,"import math a, b = map(int, input().split()) for i in range(1, 1250): if int(i*0.08) == a and int(i*0.1) ==b: print(i) quit() print(-1) " p02755,s081260451,Accepted,"A, B = map(int, input().split("" "")) _min = int(A / 0.10) _max = int(B / 0.08) flg = True for i in range(_min-3, _max+3): if int(i * 0.08) == A and int(i * 0.10) == B: print(i) flg = False break if flg: print(-1)" p02755,s140074752,Accepted,"from math import floor A, B = map(int, input().split()) res = -1 for price in range(1, 10**6): if floor(price*0.08) == A and floor(price*0.1) == B: res = price break print(res) " p02755,s514464597,Accepted,"a, b = map(int, input().split()) for i in range(1, 12500): if int(i * 0.08) == a and int(i * 0.1) == b: print(i) exit(0) print(-1) " p02755,s549684472,Accepted,"A, B = map(int,input().split()) sum_A = int(A/0.08) sum_B = int(B/0.10) flag = True for i in range(1010): if A == int(i * 0.08) and B == int(i * 0.10): print(i) flag = False break else: #print(-1) continue if flag: print(-1)" p02755,s699602766,Accepted,"import math A,B = map(int,input().split()) Xa = A * 12.5 Xb = B * 10 X = math.ceil(max(Xa,Xb)) ansA = math.floor(X * 0.08) ansB = math.floor(X * 0.1) # print(ansA,ansB) if A == ansA and B == ansB: print(X) else: print(-1)" p02755,s678830943,Accepted,"import math A, B = map(int, input().split()) max_val = int(math.ceil(A / 0.07)) min_val = int(math.floor(B / 0.11)) for i in range(min_val, max_val + 1): if int(i * 0.08) > A or int(i * 0.1) > B: break if int(i * 0.08) == A and int(i * 0.1) == B: print(i) exit(0) print(-1)" p02755,s197579343,Accepted,"a,b = map(int, input().split()) for i in range(1251): if int(i*0.08)==a and int(i*0.1)==b: print(i) exit() else: print(-1) " p02755,s078535712,Accepted,"a, b = map(int, input().split()) x = a // 0.08 y = b // 0.10 x, y = int(x), int(y) minv = min(x, y) maxv = max(x, y) ans = [] for i in range(minv, maxv+2): if int(i * 0.08) == a and int(i * 0.1) == b: ans.append(i) if len(ans) == 0: print(-1) else: print(min(ans)) " p02755,s836003002,Accepted,"A, B =list(map(int, input().split())) i=0 for N in range(1,1001): N_a=int(N*0.08) N_b=int(N*0.1) if A==N_a and B==N_b: print(N) i+=1 break if i==0: print(-1)" p02755,s413295887,Accepted,"A, B = map(int, input().split()) i = min(int(A/0.08), int(B/0.1)) * 1.0 while(True): if int(i * 0.08) == A and int(i*0.1) == B: print(int(i)) break i = 1.0 + i if int(i * 0.08) > A or int(i*0.1) > B: print('-1') break" p02755,s210562746,Accepted,"a,b=map(int,input().split()) for i in range(3000): if int(i*0.08)==a and int(i*0.10)==b: print(i) exit() print(""-1"")" p02755,s447730700,Accepted,"A, B = [float(i) for i in input().split(' ')] B1 = int(B /0.1) B2 = int((B+1) / 0.1) flag = 0 for i in range(B1, B2): if int(i * 0.08) == A : print(i) flag = 1 break if flag == 0: print(-1)" p02755,s046711235,Accepted,"A, B = map(int, input().split()) flag = 1 for i in range(1,10001): if int(i*0.08) == A and int(i*0.1) == B: print(i) flag = 0 break if flag: print(-1) " p02755,s159325395,Accepted,"from math import floor, ceil [A, B] = list(map(int, input().split())) def main(A, B): underN = min(int(A // 0.08), int(B // 0.1)) upperN = max(int(ceil(A / 0.08)), int(ceil(B / 0.1))) for i in range(underN, upperN+1): if int(floor(i*0.08)) == A and int(floor(i*0.1)) == B: return i else: return -1 if __name__ == ""__main__"": answer = main(A, B) print(answer) " p02755,s833363500,Accepted,"A, B = map(int, input().split()) for i in range(1, 1003): if int(i*0.08) == A and int(i*0.1) == B: print(i) exit() print(-1)" p02755,s637892623,Accepted,"A, B = map(int,input().split()) for k in range(1,20000): if int(k*1.08) == A+k and int(k*1.10) == B+k: print(k) exit(0) print(-1) " p02755,s158905517,Accepted,"A,B=map(int, input().split()) ans=-1 for i in range(1,10001): if int(i*0.08)==A and int(i*0.1)==B: ans=i break print(ans)" p02755,s571353723,Accepted,"import sys from collections import * import heapq import math import bisect from itertools import permutations,accumulate,combinations,product from fractions import gcd def input(): return sys.stdin.readline()[:-1] def ruiseki(lst): return [0]+list(accumulate(lst)) mod=pow(10,9)+7 a,b=map(int,input().split()) for i in range(100000): tmp=int(i*0.08) tmp2=int(i*0.1) if a==tmp and b==tmp2: print(i) break else: print(-1)" p02755,s863178831,Accepted,"a, b = map(int, input().split()) exist = False for i in range(1001): eight = int(i * 0.08) ten = int(i * 0.1) if eight == a and ten == b: print(i) exist = True break if not exist: print('-1')" p02755,s595698307,Accepted,"A,B=map(int,input().split(' ')) for i in range(1,1001): if i*0.08//1==A and i*0.1//1==B: print(i) exit() print(-1)" p02755,s354918564,Accepted,"import math import sys input = sys.stdin.readline A, B = map(int, input().split()) for i in range(1, 10010): if math.floor(i * 0.08) == A and math.floor(i * 0.1) == B: print(i) exit(0) print(-1)" p02755,s512119816,Accepted,"a, b = map(int, input().split()) for i in range(1010): tax8 = int(i * 0.08) tax10 = int(i * 0.1) if a == tax8 and b == tax10: print(i) exit() print(-1)" p02755,s994104103,Accepted,"import math a,b =map(int,input().split()) # mは原価 m = math.ceil(a*(100/8)) while int(m*(8/100)) == a: if int(m*0.1) == b: print(m) break else: m += 1 else: print(-1)" p02755,s434189978,Accepted,"a,b = map(int,input().split()) for i in range(1,1100): if int(i*0.08) == a: if int(i*0.1) == b: print(i) exit() print(""-1"") " p02755,s152246687,Accepted,"a,b=input().strip().split("" "") a,b=[int(a),int(b)] k=0 for i in range(1200): aa=(i*8)//100 bb=(i*10)//100 if (a==aa and b==bb): print(i) k=1 break if k==0: print(-1) " p02755,s778788759,Accepted,"import sys A, B = map(int, input().split()) for p in range(1, int(2e3)): _A, _B = int(p*8e-2), int(p*1e-1) if _A == A and _B == B: print(p) sys.exit() print('-1') " p02755,s137631408,Accepted,"a,b=map(int,input().split()) for i in range(0,2000): if int(i*0.08)==a and int(i*0.1)==b: print(i) exit() print(-1) " p02755,s204455779,Accepted,"a,b=map(int,input().split()) for i in range(10**6): if i*8//100==a and i//10==b: print(i) exit() print(-1)" p02755,s754534931,Accepted,"A, B = map(int, input().split()) a = int(A // 0.08) ans_lst = [] for i in range(20): # print(a, int(a * 0.08) == A) if int(a * 0.08) == A: ans_lst.append(a) a += 1 for i in ans_lst: if int(i * 0.1) == B: print(i) break else: print(-1)" p02755,s268009919,Accepted,"import math A,B=list(map(int,input().split())) ans=-1 start=math.ceil(B*(10)) cntr=start end=math.ceil((B+1)*(10)) while(cntra and int(num*0.1)>b: print(-1) break num+=1" p02755,s041585733,Accepted,"import sys import math A,B = map(int,input().split()) for i in range(1,10001): if math.floor(i * 0.08) == A and math.floor(i * 0.1) == B: print(i) sys.exit() print('-1')" p02755,s767770871,Accepted,"import math A,B = map(int,input().split()) flag = 0 for i in range(1,10**5): if math.floor(i*0.08) == A and math.floor(i*0.1) == B: print(i) flag += 1 break if flag == 0: print(-1) " p02755,s775777996,Accepted,"import math A,B=map(int,input().split()) for i in range(1,2000): if math.floor(i*0.08)==A and math.floor(i*0.1)==B: print(i) break elif i==1999: print(-1) " p02755,s743255688,Accepted,"a,b=map(int,input().split()) st=.08 lt=.1 s=[] l=[] for i in range(1262): if a/st<=i<(a+1)/st: s.append(i) for i in range(1262): if b/lt<=i<(b+1)/lt: l.append(i) t=[] for i in s: if i in l: t.append(i) if not t: print('-1') else: print(min(t))" p02755,s447416784,Accepted,"from math import floor a, b = map(int, input().split()) a_ = a // 0.08 b_ = b // 0.1 ans = min(floor(a_), floor(b_)) while floor(ans * 0.08) != a or floor(ans * 0.1) != b: ans += 1 if floor(ans * 0.08) > a or floor(ans * 0.1) > b: print('-1') exit() print(ans) " p02755,s333244996,Accepted,"A,B = map(int,input().split()) ak = [] bk = [] for k in range(-int((-A/0.08)//1),-int(-(A/0.08+12.5)//1)): ak.append(k) for k in range(-int((-B/0.10)//1),-int(-(B/0.10+10.0)//1)): bk.append(k) ans = min(set(ak) & set(bk)) if len(set(ak) & set(bk)) > 0 else -1 print(ans) " p02755,s517251444,Accepted,"a, b = map(int, input().split()) x = 1 while x <= 1100: if (x*8//100) == a and (x//10) == b: print(x) break x += 1 else: print(-1)" p02755,s284465983,Accepted,"N,M=map(int,input().split()) x=max(N//0.08+1,M//0.1+1) y=min((N+1)//0.08, (M+1)//0.1) print( -1 if y A/0.08 and i > B/0.1: print(-1) break i += 1" p02755,s246002351,Accepted,"#!/usr/bin/env python3 import math A, B = map(int, input().split()) for i in range(1, 1010): if math.floor(i * 0.08) == A and math.floor(i * 0.1) == B: print(i) exit() print(-1)" p02755,s614894257,Accepted,"A, B = map(int, input().split()) import math N = math.ceil(A / 0.08) n = math.ceil(B / 0.1) M = max(N, n) m = min(N, n) ans = -1 for i in range(m, M+1): if int(i*0.08) == A and int(i*0.1) == B: ans = i break print(ans)" p02755,s252379217,Accepted,"import math a, b = map(int, input().split()) min = int(math.ceil(a / 0.08)) max = min while math.floor(max * 0.08) == a: max += 1 for i in range(min, max): if math.floor(i * 0.1) == b: print(i) break else: print(-1) " p02755,s603562949,Accepted,"a, b = map(int, input().split()) ans = -1 for i in range(100000): if int(i*0.08) == a and int(i*0.1) ==b: ans = i break print(ans)" p02755,s460258766,Accepted,"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)" p02755,s819505614,Accepted,"a,b = map(int,input().split()) res = -1 for i in range(1,3500): judge = True p = (i*8) // 100 q = (i*10) // 100 if a == p and b == q: res = i break print(res)" p02755,s677112713,Accepted,"a,b = map(int,input().split()) import math import sys for i in range(1,2000): if math.floor(i*0.08) == a and math.floor(i*0.1) == b: print(i) sys.exit() print('-1')" p02755,s094504005,Accepted,"a,b=map(int,input().split()) la,ra=12.5*a,12.5*a+12.5 lb,rb=10*b,10*b+10 for i in range(lb,rb): if la<=ix>=100*a: flag=True ans=i break print(ans if flag else -1)" p02755,s876952413,Accepted,"a, b = [int(x) for x in input().split()] if (b < a): temp = b b = a a = temp x = 1 while True: if (int(x*0.08) == a and int(x*0.1) == b): print(x) break else: if (x > 1500): print(-1) break else: x += 1" p02755,s268477002,Accepted,"import math A,B=(int(x) for x in input().split()) #N=int(input()) #A=list(map(int, input().split())) a_1=math.ceil(A*12.5) a_2=math.ceil((A+1)*12.5) la=list(range(a_1,a_2)) b_1=int(format(B*10 ,'.0f')) b_2=int(format((B+1)*10 ,'.0f')) lb=list(range(b_1,b_2)) la_lb_and_list = list(set(la) & set(lb)) if len(la_lb_and_list) == 0: print('-1') else : print(min(la_lb_and_list))" p02755,s814153177,Wrong Answer,"A, B = map(int, input().split()) result = True for a in range(1, 1001): if int(a * 0.08) == A and int(a * 0.1) == B: print(a) break result = False exit() if result: print(-1)" p02755,s732456906,Wrong Answer,"A, B = map(int, input().split()) x1 = 25*A//2 x2 = 25*(A+1)//2 x3 = 10*B x4 = 10*(B+1) if x1 <= x3 and x3 < x2: print(x3) elif x3 <= x1 and x1 < x4: print(x1) else: print(-1) " p02755,s282860436,Wrong Answer,"a, b = map(int,input().split()) p1 = int(a // 0.08 + 1) p2 = int(b // 0.1 + 1) p1_list = [i for i in range(p1,p1+13)] p2_list = [i for i in range(p2,p2+10)] p_list = set(p1_list) & set(p2_list) p_list = list(p_list) p_list = sorted(p_list) if len(p_list) == 0: print(-1) else: print(p_list[0])" p02755,s231876841,Wrong Answer,"ret = -1 A, B = [int(i) for i in input().split()] for i in range(2000): if int(i*0.08) == A and int(i * 0.1) == B: ret = i break print(i)" p02755,s860266004,Wrong Answer,"a , b = map(int, input().split()) for i in range(1 , 10100) : a1 = int(i*0.08) b1 = int(i*0.10) if a1 == a and b1 == b : print(i) else : print(-1)" p02755,s616010094,Wrong Answer,"import math a,b=map(int,input().split()) if a%2==0: s=a*12.5 s=math.floor(s) if s-b*10==5: print(s) elif b*10-s==5: print(b*10) elif b*10==s: print(s) else: print(-1) else: t=a*12.5 +0.5 if t-b*10==3: t=math.floor(t) print(t) elif b*10-t==7: print(b*10) else: print(-1) " p02755,s791543771,Wrong Answer,"A, B = map(int,input().split()) a = int(A / 0.08) if A == int(a * 0.08) and B == int(a * 0.10) : print(a) else : print('-1')" p02755,s084023995,Wrong Answer,"A, B = map(int, input().split()) Ax = A * 25 / 2 Ay = (A + 1) * 25 / 2 Bx = B * 10 By = (B + 1) * 10 if Ay <= Bx or By <= Ax: print(-1) else: ans = max(Bx, Ax) if ans % 1: ans = int(ans) ans += 1 print(ans)" p02755,s719054538,Wrong Answer,"A, B = map(int, input().split()) A = 100 * A B = 100 * B a = 0 b = 0 for i in range(A, A+100): a = i / 8 for j in range(B, B+100): b = j /10 if a == b: print(int(a)) break else: if i == A +99: print(""-1"") else: continue break" p02755,s531092222,Wrong Answer,"import math a, b = map(int, input().split()) for i in range(1, 101): aa = math.floor(i*1.08) bb = math.floor(i*1.1) if aa - i == a and bb - i == b: print(i) exit() print(-1)" p02755,s787068911,Wrong Answer,"import math A, B = list(map(int, input().split())) amax = math.ceil((A + 1) / 8 * 100) - 1 amin = math.ceil(A / 8 * 100) bmax = math.ceil((B + 1) * 10) - 1 bmin = math.ceil(B / 10 * 10) if amin > bmax or bmin > amax: print(-1) else: print(int(max(amin, bmin))) " p02755,s077815279,Wrong Answer,"A,B = map(int,input().split()) a=-(-A//0.08) b=-(-B//0.1) c=-(-(A-1)//0.08) d=-(-(A+1)//0.08) if a==b or c < b < d: print(int(a)) else: print(-1) " p02755,s132185040,Wrong Answer,"a, b = map(int, input().split()) # for i in range(1, 1010): # if a == int(i*0.08) and b == int(i*0.1): # print(i) # break # else: # print(-1) # O(1)の回答 if int(b*10*0.08) > a: print(-1) elif int((b*10+9)*0.08) < a: print(-1) elif a % 2 == 0: print(int(a/0.08)) else: print(int(a/0.08)+1) " p02755,s695337850,Wrong Answer,"A, B = map(int, input().split()) for i in range(1000): if int(i*0.08)==A and int(i*0.1)==B: print(i) exit() print(-1)" 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)" p02755,s014252191,Wrong Answer,"import math A, B = map(int, input().split()) X = A / 0.08 Y = B / 0.1 if X > Y: Z = X * 0.2 if Y + Z == X: print(X) else: print(-1) else: Z = Y * 0.2 if X + Z == Y: print(Y) else: print(-1)" p02755,s905538056,Wrong Answer,"import math a, b = map(int, input().split()) if(math.ceil(a/0.08) < math.ceil(b/0.1)): print(-1) else: print(math.ceil(a/0.08)) " p02755,s174212616,Wrong Answer,"a, b = map(int, input().split()) a_min = -(-a*100//8) a_max = int((a+1)*100/8) b_min = -(-b*100//10) b_max = int((b+1)*100/10) if a_max >= b_min and b_max >= a_min: print(max([a_min, b_min])) else: print(-1)" p02755,s702995660,Wrong Answer,"a,b = input().split() a = int(a) b = int(b) c = 0 for i in range(10000): d = c*0.08 e = c*0.1 d = int(d) e = int(e) if d == a and e == b: print(c) break elif c == 10000: print('-1') else: c += 1" p02755,s420542447,Wrong Answer,"import math A,B=map(int,input().split()) C=max(100*A/8,10*B) D=min(100*(A+1)/8,10*(B+1)) if math.ceil(C)>math.floor(D): print(""-1"") else: print(math.ceil(C))" p02755,s324741986,Wrong Answer,"# coding: utf-8 a, b = map(int, input().split()) a_target1 = a / 0.08 a_target2 = (a + 1) / 0.08 b_target1 = b / 0.1 b_target2 = (b + 1) / 0.1 result_list = [] for i in range(int(a_target1), int(a_target2)): if i >= b_target1 and i < b_target2: result_list.append(i) if result_list == []: print(-1) else: result = min(result_list) print(result) " p02755,s588533300,Wrong Answer,"a,b = map(int, input().split("" "")) a1 = a / 0.08 b1 = b / 0.1 if a1 == b1: print(int(a1)) else: print(-1) " p02755,s600058633,Wrong Answer,"# coding: utf-8 import math def main(): a, b = map(int, input().split()) tmp_a_min = math.floor(a / 0.08) tmp_a_max = math.floor((a+1) / 0.08) # print(tmp_a_min, tmp_a_max) for i in range(tmp_a_min, tmp_a_max): if math.floor(i * 0.1) == b: print(i) break else: print(-1) main()" p02755,s748478235,Wrong Answer,"import math a,b=map(int,input().split()) arr=[] for i in range(1,101,1): if a==math.floor(i*0.08) and b==math.floor(i*0.1) : print(i) exit() print(-1)" p02755,s482726463,Wrong Answer,"import math flag = 0 a,b = map(int,input().split()) for i in range(1000): if int(i*0.08) == a and int(i*0.1) == b: print(i) break elif i*0.08 > a and i*0.1 > b: print(-1) break" p02755,s834118375,Wrong Answer,"a,b=map(int,input().split()) k=[] o=[] p=[] for i in range(1,101): if int(i*0.08)==a: k.append(i) for j in range(1,101): if int(j*0.1)==b: o.append(j) for t in range(len(k)): for u in range(len(o)): if k[t]==o[u]: p.append(k[t]) if p==[]: print(-1) else: print(min(p)) " p02755,s994923350,Wrong Answer,"a,b = [int(x) for x in input().split()] amax = (a+1)*12.5 amin = a*12.5 bmax = int((b+1)*10) bmin = int(b*10) hantei = bmin if amax <= bmin: hantei = str(-1) elif bmax <= amin: hantei = str(-1) elif bmin < amin: hantei = round(amin) print(hantei)" p02755,s362177242,Wrong Answer,"from math import ceil A, B = map(int, input().split(' ')) x0 = ceil(A / 0.08) x1 = ceil((A+1) / 0.08) y0 = ceil(B / 0.1) y1 = ceil((B+1) / 0.1) if x1 < y0: print(-1) else: print(min(max(x0, y0), min(x1, y1)))" p02755,s327270422,Wrong Answer,"import math A, B = list(map(int, input().split())) rangeA = [A / 0.08, (A + 1) / 0.08] rangeB = [B / 0.1, (B + 1) / 0.1] if rangeA[0] <= rangeB[0]: if rangeB[0] <= rangeA[1]: print(math.ceil(rangeB[0])) exit(0) else: # rangeA[0] > rangeB[0] if rangeA[0] <= rangeB[1]: print(math.ceil(rangeA[0])) exit(0) print(-1)" p02755,s858729345,Wrong Answer,"a,b=list(map(int,input().split())) for i in range(1000): if int(i*0.08)==a and int(i*0.1)==b: print(i) break elif i==100: print(-1) " p02755,s439344034,Wrong Answer,"import math A,B = list(map(int,input().split())) def problem_gksn(A, B): x_min = A / (0.08) x_max = (A+1)/0.08 y_min = B / (0.10) y_max = (B+1) / (0.10) # print(x_min,x_max,y_min,y_max) if max(x_min, y_min) <= min(x_max, y_max): return math.ceil(max(x_min, y_min)) else: return -1 print(problem_gksn(A,B))" p02755,s214745254,Wrong Answer,"import math a, b = map(int, input().split()) e=int(a / 0.08) for i in range(e, 101): if (b == math.floor(e * 0.1)): print(i) exit (0) print(-1)" p02755,s340968958,Wrong Answer,"A, B = map(int, input().split()) for i in range(1, 10000): if int(0.08 * i) == A and int(0.01 * i) == B: print(i) quit() print('-1')" p02755,s973775294,Wrong Answer,"Z = list(map(int,input().split())) c=[] for i in range(1,101): c.append([i*0.08//1,i*0.1//1]) print(c.index(Z)+1 if Z in c else -1)" p02755,s993989669,Wrong Answer,"import math a=input().split() A,B=int(a[0]),int(a[1]) p=int(A/0.08) if(math.floor(p*0.1)==B): print(p) else: print(-1)" 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))" p02755,s784302938,Wrong Answer,"a,b = map(int,input().split()) ans_min = min(int(a*12.5),int(b*10)) ans_max = max(int(a*12.5),int(b*10)) for i in range(ans_min,ans_max+1): if a == int(i*0.08) and b == int(i*0.1): print(i) exit() print(-1)" p02755,s524191594,Wrong Answer,"a, b = map(int, input().split()) a_min = a * 100 / 8 a_max = (a + 1) * 100 / 8 b_min = b * 100 / 10 b_max = (b + 1) * 100 / 10 out = max(a_min, b_min) print(int(out) if (out < a_max) & (out < b_max) else -1)" p02755,s955870779,Wrong Answer,"a,b=map(int,input().split()) import math a_min=math.ceil(a/0.08) a_max=math.floor((a+1)/0.08) b_min=math.ceil(b/0.1) b_max=math.floor((b+1)/0.1) if a_max 0: print(min(ans)) else: print(-1)" p02755,s762601730,Wrong Answer,"A, B = list(map(int, input().split())) amax = (A + 1) / 8 * 100 amin = A / 8 * 100 bmax = (B + 1) / 10 * 100 bmin = B / 10 * 100 answer = amin if amin <= bmax and amin >= bmin else - 1 print(int(answer)) " p02755,s799880853,Wrong Answer,"import sys input = sys.stdin.readline A, B = map(int, input().split()) xmin = 1 while xmin < 100*A: if int(0.08*xmin) == A and int(0.1*xmin) == B : print(int(xmin)) exit() elif int(0.08*xmin) < A or int(0.1*xmin) < B : xmin += 1 else : print(-1) exit() " p02755,s853160809,Wrong Answer,"# -*- coding: utf-8 -*- import sys sys.setrecursionlimit(10**9) INF=10**18 MOD=10**9+7 def input(): return sys.stdin.readline().rstrip() def main(): A,B=map(int,input().split()) for i in range(1,101): if int(i*0.08)==A and int(i*0.1): print(i) exit() print(-1) if __name__ == '__main__': main() " p02755,s198914082,Wrong Answer,"A,B = map(int,input().split()) for i in range(101): if i*0.08//1 == A and i*0.1//1 == B: print(i) exit() print(-1)" p02755,s768986212,Wrong Answer,"#ABC158 a,b = map(int,input().split()) tax_a = a/0.08 if int(tax_a*0.1) == b: ans = tax_a-1 if int(ans*0.1) == b and int(ans*0.8) == a: print(int(ans)) else: print(int(tax_a)) else: print('-1')" p02755,s966619062,Wrong Answer,"def main(): a, b = map(int, input().split()) tmp_8 = int(a / 0.08) tmp_10 = int(b / 0.1) check_10 = int(tmp_8*0.1) check_8 = int(tmp_10*0.1) if check_8 != check_10: print(-1) else: print(tmp_8) if __name__ == '__main__': main() " p02755,s853504391,Wrong Answer,"a, b = input().split() a, b = int(a), int(b) # ans_a = (0.08) / a # ans_b = (0.1) / b ans_a = a / 0.08 # ans_b = b /0.1 ans_b = ans_a * 0.1 # print(""a"", ans_a) # print(""b"", ans_b) if b != int(ans_b): print(""-1"") print(int(ans_a))" p02755,s151453730,Wrong Answer,"A,B = [int(x) for x in input().split()] number1 = int(A*100//8) number2 = int(B*100//10) if number1//10 == B: if number2*8//100 == A: if number1 <= number2: print(number1) else: print(number2) else: print(number1) else: if number2*8//100 == A: print(number2)" p02755,s482708295,Wrong Answer,"import math N = list(map(int, input().split())) X = [i for i in range(int(N[0]*(1/0.08)), math.ceil((N[0]+1)*(1/0.08)))] Y = [i for i in range(int(N[1]*(1/0.10)), math.ceil((N[1]+1)*(1/0.10)))] #print(X, Y) cand = set(X) & set(Y) if len(cand) == 0: print(-1) else: print(min(cand)) " p02755,s143066170,Wrong Answer,"import sys def LI(): return list(map(int, sys.stdin.readline().split())) a = LI() i = 0.1 elist,blist= [],[] for b in range(9): elist.append(int((a[0]+1-i)/0.08)) blist.append(int((a[1]+1-i)/0.1)) i += 0.1 elist.append(int(a[0]/0.08)) blist.append(int(a[1]/0.1)) blist.sort() for b in blist: if b in elist: print(b) sys.exit() print(-1)" p02755,s705829502,Wrong Answer,"A, B = map(int, input().split()) before = B * 10 not_found = True for i in range(13): res = before + i tmp = int((before + i) * 0.08) if tmp == A: print(res) not_found = False break if not_found: print(-1)" p02755,s106229487,Wrong Answer,"#output <= 1000 nums = [int(e) for e in input().split()] for i in range(1,1001): if ((((i * 8) // 100) == nums[0]) & (((i * 10) // 100) == nums[1])): print(i) else: print(-1)" 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)" p02755,s002733579,Wrong Answer,"import math A, B = map(float, input().split()) lowerA = math.ceil(A/0.08) upperA = math.floor((A+1)/0.08) lowerB = math.ceil(B/0.1) upperB = math.floor((B+1)/0.1) answer = -1 for i in range(lowerA, upperA): if (lowerB <= i) and (i <= upperB): answer = i break print(answer) " p02755,s027587965,Wrong Answer,"a, b = map(int, input().split()) xa = int(a/0.08) xb = int(b/0.1) if xa == xb: print(xa) else: if int(xa*0.1) == b: print(xa) elif int(xb*0.08) == a: print(xb) else: print(-1) " p02755,s676235896,Wrong Answer,"import math A, B = map(int, input().split()) r=100000 x = math.floor(A/0.08) y = math.floor(B/0.1) if(math.floor(x*0.1)!=B): print(""-1"") else: while(y max_10: print(""-1"") elif max_8 >= min_10: if min_8 < min_10: print(min_10) elif min_8 >= min_10: print(min_8)" p02755,s902771434,Wrong Answer,"A, B = map(int, input().split()) x = int(A * (100/8)) y = int(B * (100/10)) if x == y: print(x) elif int(x * (10/100)) == A: print(x) elif int(y * (8/100)) == A: print(y) else: print(-1)" p02755,s087211391,Wrong Answer,"import math a,b=map(int,input().split()) for i in range(1,101): if(math.floor(i*0.08)==a and math.floor(i*0.1)==b): print(i) exit() print(-1)" p02755,s097815915,Wrong Answer,"def main(): a, b = map(int, input().split()) eight = [i for i in range(0, 101) if a == int(i * 0.08)] ten = [i for i in range(0, 101) if b == int(i * 0.1)] for i in eight: for j in ten: if i == j: print(i) return print(-1) if __name__ == '__main__': main() " p02755,s268103421,Wrong Answer,"import math #Input A,B= map(int, input().split()) #Process Ans = -1 tmp08_min = math.ceil(A / 0.08) tmp08_max = tmp08_min + 13 tmp10_min = math.ceil(B / 0.10) tmp10_max = tmp10_min + 10 tmp_min = min(tmp08_min, tmp10_min) tmp_max = max(tmp08_max, tmp10_max) cnt = 0 while cnt < tmp_max - tmp_min: if(A == int((tmp_min + cnt) * 0.08) and B == int((tmp_min + cnt) * 0.10)): Ans = tmp10_min + cnt break cnt += 1 #Output print(Ans)" p02755,s519336093,Wrong Answer,"from math import ceil from math import floor a,b = map(int,input().split()) l1 = ceil((a-0.50001)/0.08) r1 = floor((a+0.5)/0.08) l2 = ceil((b-0.50001)/0.1) r2 = floor((b+0.5)/0.1) l3 = max(l1,l2) r3 = min(r2,r1) if(l3<=r3): print(l3) else: print(-1) " p02755,s584786712,Wrong Answer,"from math import floor a, b = [int(i) for i in input().split()] for i in range(0, 1011): print(i, floor(i * 0.08), floor(i * 0.1)) if floor(i * 0.08) == a and floor(i * 0.1) == b: print(i) break else: print(-1) " p02755,s994914074,Wrong Answer,"a, b = map(int, input().split()) price_8 = -int(-a/0.08) price_10 = -int(-b/0.1) print(price_10) if price_10==price_8 else print(-1) " p02755,s067116939,Wrong Answer,"A,B = map(int,input().split()) x = int((100*A)/8) y = int((100*B)/10) while (int((x-1)*0.08) == A)&(int((x-1)*0.1) == B): x -= 1 while (int((y-1)*0.08) == A)&(int((y-1)*0.1) == B): y -= 1 if(int(x*0.08) == A)&(int(x*0.1) == B): print(x) elif(int(y*0.08) == A)&(int(y*0.1) == B): print(y) else: 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"")" p02755,s294860275,Wrong Answer,"A,B = map(int,input().split()) AA = A*100//8 BB = B*10 AAA = [i for i in range(AA,(A+1)*100//8+1)] BBB = [i for i in range(BB,(B+1)*10+1)] AB_list = list(set(AAA)&set(BBB)) ans = min(AB_list) if AB_list and (12 b: print('-1') else: if hachi[0] in jyuu: print(hachi[0]) elif hachi[1] in jyuu: print(hachi[1]) else: print('-1') " p02755,s098731651,Wrong Answer,"A,B = map(int,input().split()) PA = int(-(-A // 0.08)) if int(PA*0.1) == B: print(PA) else: print(-1)" 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)" p02755,s250943257,Wrong Answer,"from math import ceil def without_tax(a,b): w_a = ceil(a/0.08) m_w_a = ceil((a+1)/0.08) w_b = ceil(b/0.1) m_w_b = ceil((b+1)/0.1) if m_w_b < w_a or m_w_a < m_w_b: return -1 return max(w_a,w_b) a,b = [int(e) for e in input().split()] print(without_tax(a,b))" p02755,s853049331,Wrong Answer,"A, B =map(int, input().split()) M=int(-1) for i in range(1000): if int(i*0.08)==A: if int(i*0.10)==B: M=i break print(M) " p02755,s315111250,Wrong Answer,"a, b =map(int, input().split()) for x in range(0,10001): print('---') print(x) ax = (8*x)//100 bx = (10*x)//100 print(ax,bx) if ax == a and bx == b: print(x) break else: print(-1)" p02755,s527933071,Wrong Answer,"E,T=map(int,input().split()) Emotone=(E/0.08) A=int(E/0.08) if Emotone>A: Emotone=int(A+1) if T<=((0.1/0.08)*E) a: print(""-1"") break" p02755,s848486612,Wrong Answer,"import math a, b = map(int,input().split()) prca = math.ceil(a / 0.08) prcb = math.ceil(b / 0.1) base = max(prca, prcb) while True: if int(base * 0.08) < a or int(base * 0.1) < b: ans = base - 1 break base -= 1 if int(ans * 0.08) != a or int(ans * 0.1) != b: ans = -1 print(ans)" p02755,s065137057,Wrong Answer,"a,b = map(float,input().split()) a_base_min = int(a * 25 /2) a_base_max = int((a+1)*25/2) b_base_min = int(b *10) b_base_max = int((b+1) *10) if (b_base_min <= a_base_min) and (a_base_min <= b_base_max): print(int(a_base_min)) elif (a_base_min < b_base_min) and (b_base_min <= a_base_max): print(int(b_base_min)) else: print(-1)" p02755,s637494053,Wrong Answer,"#O(1) from math import ceil a,b = map(int, input().split( )) if int(min(a/0.08,b/.01)) new_b: tax = a while tax == a: new_a -= 1 tax = new_a * 0.08 print(int(new_a + 1)) elif new_a <= new_b: tax = b while tax == b: new_b -= 1 tax = new_b * 0.10 print(int(new_b + 1)) else: print(""-1"") " p02755,s068115460,Wrong Answer,"import math a, b = map(int, input().split()) point = a/0.08 seg_a = (math.ceil(point), math.floor(point + 12.5)) point = b/0.1 seg_b = (point, point + 9) if seg_b[1] < seg_a[0]: print(-1) else: print(int(seg_a[0]))" p02755,s560222718,Wrong Answer,"a, b = map(int, input().split()) for n in range(10000): xa = n * 0.08 xb = n * 0.1 if a == xa and b == xb: print(n) exit() print(-1)" p02755,s708170558,Wrong Answer,"from math import ceil import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines def main(): A,B = map(int, readline().split()) x1 = ceil(A / 0.08) x2 = ceil(B / 0.1) print(x1, x2) if int(x1 * 0.1) == B: print(x1) elif int(x2 * 0.08) == A: print(x2) else: print(-1) if __name__ == ""__main__"": main() " p02755,s999761004,Wrong Answer,"import math A, B = list(map(int, input().split())) amax = math.ceil((A + 1) / 8 * 100) - 1 amin = math.ceil(A / 8 * 100) bmax = math.ceil((B + 1) / 10 * 100) - 1 bmin = math.ceil(B / 10 * 100) if amin > bmax or bmin > amax: print(-1) else: print(int(max(amin, bmin))) " 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"") " 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)" p02755,s912108512,Wrong Answer,"import math a, b = map(int, input().split()) estimated = b * 10 ans = -1 for i in range(10): if (estimated+i) == math.ceil(a/0.08) and a == int((estimated+i)*0.08) and b == int((estimated+i)*0.1): ans = estimated+i break print(ans) " p02755,s982108422,Wrong Answer,"A,B = map(int,input().split()) AA = A*100//8 BB = B*10 AAA = [i for i in range(AA,(A+1)*100//8)] BBB = [i for i in range(BB,(B+1)*10)] AB_list = list(set(AAA)&set(BBB)) ans = min(AB_list) if AB_list and (12 ma: print(-1) else: print(mi) " p02755,s072435636,Wrong Answer,"A,B = (int(x) for x in input().split()) for i in range(1,101): Ahan = int(i * 0.08) Bhan = int(i * 0.10) if (Ahan == A and Bhan == B): print(i) break if(i == 100): print(-1) break" p02755,s619354888,Wrong Answer,"a,b = map(int,input().split()) list = [] if 100*a%8: x=int(a/0.08)+1 else: x=int(a/0.08) for i in range(x, int((a+1)/0.08)+1): if b/0.1 <= i <(b+1)/0.1: list.append(i) list = sorted(list) print(list[0]) exit() print('-1') " p02755,s900675810,Wrong Answer,"from math import * A,B = map(int,input().split()) #A = x*.08 #x1 = A / 0.08 #x2 = B / 0.1 x = 0 while 1: x += 1 if floor(x*0.08) == A: break if B == floor(x * 0.1): print(int(x)) else: print(-1)" p02755,s186240776,Wrong Answer,"ret = -1 A, B = [int(i) for i in input().split()] if A<0 or B<0: print(""-1"") exit() minA = int(A/0.08) maxA = int((A+1)/0.08) minB = int(B/0.1) maxB = int((B+1)/0.1) print(minA, maxA, minB, maxB) for i in range(minA, maxA): if i >= minB and i < maxB: ret = i break print(ret)" p02755,s578984485,Wrong Answer,"A,B = map(int,input().split()) for x in range(0,101): if (0.1*x)//1 == B and (0.08*x)//1 == A: print(x) exit(0) print(-1)" p02755,s268535784,Wrong Answer,"import math a, b = [ int(v) for v in input().split() ] ans = -1 for i in range(1, 101): if math.floor(i * 0.08) == a and math.floor(i * 0.1) == b: ans = i break print(ans) " p02755,s201462966,Wrong Answer,"A, B = map(int, input().split()) a_min = A * 12.5 a_max = a_min + 12.5 b_min = B * 10.0 b_max = b_min + 10.0 if b_min <= a_min < b_max: print(int(a_min)) elif a_min <= b_min < a_max: print(int(b_min)) else: print(-1) " p02755,s178029455,Wrong Answer,"a,b=map(int,input().split()) am=a*(100/8) aM=(a+1)*(100/8) bm=b*(100/10) bM=(b+1)*(100/10) x=[] for i in range(101): if am<=i 0 else -1 print(ans)" p02755,s621298872,Wrong Answer,"import math a, b = map(int, input().split()) a1 = math.ceil(a/0.08) a2 = math.ceil(b/0.1) a3 = math.ceil((a+1)/0.08) a4 = math.ceil((b+1)/0.1) if(max(a1, a2) > min(a3, a4)):print(-1) else:print(max(a1, a2))" p02755,s515272225,Wrong Answer,"import sys A,B=map(int,input().split()) c=A*25//2 d=B*10 for i in range(d,d+11): if int(i*0.08)==A: print(i) sys.exit() print(-1)" p02755,s576880105,Wrong Answer,"A,B = map(int,input().split()) import math b = B/0.1 b_list = [] for i in range(10): b_list.append(b+i) for i in b_list: pre_cnt = i*0.08 cnt = math.floor(pre_cnt) if cnt == A: print(i) exit() print(-1)" p02755,s673529755,Wrong Answer,"import math as m a,b=map(int,input().split()) flag=True for i in range(1,10**6): if m.floor(i*(0.08))==a and m.floor(i*(0.08))==b: flag=False print(i) break if flag: print(-1) " p02755,s683092158,Wrong Answer,"import math A, B = list(map(int, input().split(' '))) a = 0.08 b = 0.10 x_min = math.ceil((A-1) / a) x_max = math.ceil((A+1) / a) y_min = math.ceil((B-1) / b) y_max = math.ceil((B+1) / b) X = set(range(x_min, x_max)) Y = set(range(y_min, y_max)) r = X & Y R = min(r) if len(r) > 0 else -1 if len(r) == 1 and R == 0: R = -1 print(R) " p02755,s888946323,Wrong Answer,"a, b = map(int, input().split(' ')) ans = (b-a)*50 if ans == 0: ans = 25 print(ans) exit() if ans*0.08 == a: if ans*0.1 == b: print(ans) exit() print('-1') " p02755,s901314716,Wrong Answer,"import math a, b = map(int, input().split()) estimated = b * 10 ans = -1 for i in range(10): if (estimated+i) == math.ceil(a/0.08): ans = estimated+i break print(ans) " p02755,s290563190,Wrong Answer,"def calc(percent,tax): return (tax*100)//percent def main(): print(calc(8,A) if calc(10,B)<=calc(8,A)= b_target1 and i < b_target2: result_list.append(i) if result_list == []: print(-1) else: result = min(result_list) print(result) " p02755,s274050931,Wrong Answer,"A,B = map(int,input().split()) i = -1 for i in range (10100): if int(i*0.08) == A and int(i*0.1) == B: print(i) break" p02755,s655557012,Wrong Answer,"import math A,B = map(int, input().split()) tax_a = 8/100 tax_b = 10/100 al = A/tax_a ar= (A+1)/tax_a bl = B/tax_b br= (B+1)/tax_b if br < al or ar < bl: print(-1) elif bl 0 else -1) " p02755,s227163256,Wrong Answer,"a, b = [int(elem) for elem in input().split()] res = a / 0.08 if int(res * 0.1) == b: print(int(res)) else: print(-1)" p02755,s408080672,Wrong Answer,"import math from collections import deque def main(): a,b = tuple([int(t)for t in input().split()]) for i in range(1,100): a_tax = i * 108//100 b_tax = i * 110/100 if a == a_tax and b == b_tax: print(i) return print(-1) if __name__ == ""__main__"": main()" p02755,s483576233,Wrong Answer,"a, b = map(int, input().split()) x = max((a//0.08)+1, int(a/0.08)) y = b//0.1*0.1 if int(x*0.08) == int(x*0.1): print(x) elif int(y*0.08) == int(y*0.1): print(y) else: print(-1) " p02755,s876139125,Wrong Answer,"l1=input().split("" "") t80=int(l1[0]) t100=int(l1[1]) t80_min=(t80/0.08) t80_max=((t80+1)/0.08) t100_min=(t100/0.1) t100_max=((t100+1)/0.1) if t80_max value2: print(value1) else: print(value2) elif int(value2 * 0.08) == a8: if value1 > value2: print(value1) else: print(value2) else: print(-1)" p02755,s729067107,Wrong Answer,"import math A,B = map(int,input().split()) a = A / 0.08 b = B / 0.1 if math.floor(a * 0.1) == B: ans = int(a) elif math.floor(b * 0.08) == A: ans = int(b) else: print(-1) exit() if math.floor((ans-1)*0.08) == A and math.floor((ans-1)*0.1) == B: ans = ans - 1 else: print(ans)" p02755,s452622418,Wrong Answer,"def main(): A, B = map(int, input().split()) for i in range(int(B/0.1), int(A/0.08)+1): if int(i * 0.08) == A and int(i * 0.1) == B: print(i) return print(-1) main()" p02755,s909364500,Wrong Answer,"import math def main(): a, b = [int(i) for i in input().split()] lo = max(1000 * a, 800 * b) hi = min(1000 * (a + 1), 800 + (b + 1)) if lo < hi: print(math.ceil(lo / 80)) else: print(-1) main() " p02755,s925069649,Wrong Answer,"import math as mt K = input().split("" "") A = int(K[0]) B = int(K[1]) a = float(A*12.5) t = float((A+1)*12.5) t1 = mt.ceil(t) b = B*10 a1 = mt.ceil(a) A_data = [] B_data = [] for i in range(b,b+10): A_data.append(i) for i in range(a1,a1+t1): B_data.append(i) A_set = set(A_data) B_set = set(B_data) AB_set = A_set & B_set if AB_set: P = min(AB_set) print(P) else: print(-1)" p02755,s929018588,Wrong Answer,"a,b=(int(x) for x in input().split()) if int(25*(a+1)/2) [a,a+1) # 10% -> [b,b+1) # max(a*100/8, b*10) <= 元の価格 < min((a+1)*100/8, (b+1)*10) min8 = a*(100/8) max8 = (a+1)*(100/8) min10 = b*10 max10 = (b+1)*10 mi = int(max(min8, min10) - 0.001) ma = int(min(max8, max10)) if mi >= ma: ans = -1 else: ans = mi + 1 print(ans)" p02755,s953046693,Wrong Answer,"A, B = (int(i) for i in input().split()) A_p_min = A/0.08 A_p_max = (A+1)/0.08 B_p_min = B/0.1 B_p_max = (B+1)/0.1 cnt = -1 for i in range(int(A_p_max)-1,int(A_p_min)-1,-1): #print(i) for j in range(int(B_p_max)-1,int(B_p_min)-1,-1): if i == j: cnt = i print(cnt)" p02755,s318008775,Wrong Answer,"import math def ccc(a, b): for i in range(1, 101): an = math.floor(i * 0.08) bn = math.floor(i * 0.1) if an == a and bn == b: return i return ""-1"" def main(): a , b = map(int , input().split()) print(ccc(a , b)) if __name__ == '__main__': main()" p02755,s145073404,Wrong Answer,"#Atcoder 158 class A,B = list(map(int,input().split())) z=1 for x in range(int(25*A/2),int(25*(A+1)/2)): for y in range(int(10*B),int(10*(B+1))): if x==y: print(x) break else: z += 1 if x==y: break if z==(int(25*(A+1)/2)-int(25*A/2))*(int(10*(B+1))-int(10*B)): print(-1)" p02755,s889673667,Wrong Answer,"A,B=map(int,input().split()) S=set(range(25*A//2,25*(A+1)//2))&set(range(10*B,10*(B+1)-1)) print(S.pop() if len(S)>0 else -1) " p02755,s321349828,Wrong Answer,"a,b=map(int,input().split()) for i in range(1,101): if int(0.08*i)==a and int(0.10*i)==b: print(i) exit() print(-1)" p02755,s900673789,Wrong Answer,"A, B = map(int, input().split()) a_min = int(A / 0.08) a_max = int((A+1) / 0.08) #print(a_min, a_max) b_min = int(B / 0.1) b_max = int((B+1)/0.1) #print(b_min, b_max) for i in range(a_min, a_max+1): if b_min <= i <= b_max: print(i) exit() print(-1) " p02755,s002985822,Wrong Answer,"import math A,B=(int(x) for x in input().split()) a=math.floor(A/0.08) b=math.floor(B/0.1) out =0 if a>=b: if math.floor(a*0.1) != B: out = -1 else: out = a elif a= b_min and a_min <= b_max: print(int(a_min)) elif b_min >= a_min and b_min <= a_max: print(int(b_min)) else: print(-1)" p02755,s393633150,Wrong Answer,"A,B=map(int,input().split()) for i in range(1,101): if int(i*0.08)==A and int(i*0.1)==B: print(i) exit() print(-1)" p02755,s278788662,Wrong Answer,"a,b = map(int,input().split()) b *= 10 ans = 0 for i in range(b,1001): if i*8//100 == a: ans = i break else: ans = -1 print(ans)" p02755,s335246951,Wrong Answer,"#!/usr/bin/env python3 def main(): A, B = map(int, open(0).read().split()) ans_A = [] for i in range(int(12.5 * A), int(12.5 * A + 12.5 + 1)): ans_A.append(i) ans_B = [] for i in range(int(10*B), int(10*B + 10 + 1)): ans_B.append(i) ans = set(ans_A) & set(ans_B) if len(ans) == 0: print(-1) else: print(min(list(ans))) main()" p02755,s677047234,Wrong Answer,"import math a,b = map(int,input().split()) res = -1 for x in range(1, 1251): if math.ceil(x/0.08)==a and math.ceil(x/0.1)==b: res = x break print(res)" p02755,s809322833,Wrong Answer,"def main(): a,b=map(int,input().split()) for i in (int(a/0.08),int((a+1)/0.08)): if int(i*0.1)==b: return i return -1 print(main())" p02755,s420885140,Wrong Answer,"A, B = map(int, input().split()) e = (A*100)//8 t = B*10 ee = e tt = t # while True: # ee -= 1 # if (ee*8)//100 == A: # continue # else: # ee += 1 # break if ee < t: startval = t stopval = ee else: startval = ee stopval = t ans = 0 if ee != t: for ii in range(startval,stopval,-1): if (ii * 10)//100 == B and (ii * 8)//100 == A: ans = ii else: ans = ee if ans == 0: ans = -1 print(ans) " p02755,s712235845,Wrong Answer,"a,b = map(int,input().split()) # 8% -> [a,a+1) # 10% -> [b,b+1) # max(a*100/8, b*10) <= 元の価格 < min((a+1)*100/8, (b+1)*10) min8 = a*(100/8) max8 = (a+1)*(100/8) min10 = b*10 max10 = (b+1)*10 mi = int(max(min8, min10) - 0.01) ma = int(min(max8, max10)) if mi >= ma: ans = -1 else: ans = mi + 1 print(ans)" p02755,s351148520,Wrong Answer,"a=input() (n,m)=a.split("" "") n=int(n) m=int(m) k=n/0.08 k=int(k) l=int(k*0.08) j=m/0.1 j=int(j) o=int(j*0.1) if l==n and o==m: print(k) else: print(""-1"") " p02755,s777414006,Wrong Answer,"a, b = map(int, input().split()) A = int(-(-(a + 1) / 0.08)) B = int(-(-(b + 1) / 0.1)) s = int(a / 0.08) t = int(b / 0.1) n = int(-(-(a + 1) // 0.08) - s) re = 0 for i in range(n): if t <= s + i < B: re = s + i break if re != 0: print(int(re)) else: print(-1) " p02755,s048242360,Wrong Answer,"A, B = map(int, input().split()) ans = [] for i in range(0, 10): for j in range(0, 10): a = A + (0.1 * i) b = B + (0.1 * j) a = a * 12.5 b = b * 10 #print(a, b) if int(a) == int(b): ans.append(int(a)) #print(ans) print(min(ans)) if ans else print(-1)" p02755,s637280468,Wrong Answer,"A, B = map(int, input().split()) at = int(A/0.08) bt = int(B/0.1) if at == bt: print(at) exit() for i in range(min(at, bt), max(at, bt)): i += 1 aa = int(i*0.08) bb = int(i*0.1) if aa == bb: print(i) exit() print(""-1"")" p02755,s781110707,Wrong Answer,"tax_eight, tax_ten = map(int, input().split()) min_eight_price = tax_eight / 0.08 max_eight_price = (tax_eight + 1) / 0.08 min_ten_price = tax_ten * 10 max_ten_price = (tax_ten + 1) * 10 min_price = max(min_eight_price, min_ten_price) max_price = min(max_eight_price, max_ten_price) if max_price <= min_price: print(-1) else: print(int(min_price)) " p02755,s772069322,Wrong Answer,"import math a,b=map(int,input().split()) b*=10 ans=0 for i in range(8): j=b j+=i if int(j*0.08)==a: ans=j break if ans!=0: print(ans) else : print(-1) " p02755,s187077326,Wrong Answer,"import math A, B = map(int, input().split()) x = B * 10 ans = -1 for i in range(x, int(B / 0.08) + 11): y = math.floor(i * 0.08) if y == A: ans = i break print(ans) " p02755,s128151332,Wrong Answer,"a, b = map(int,input().split()) a_list = [] b_list = [] flag = 0 for i in range(1,101): if int(i*1.08)-i == a: a_list.append(i) for j in a_list: if int(j*1.1)-j == b: print(j) flag = 1 break if flag != 1: print('-1') " p02755,s805302524,Wrong Answer,"import sys A,B = map(int,input().split()) if A<13: print(-1) sys.exit() last = 2000 for i in range(last): mA = int(i*0.08) mB = int(i*0.10) print(mA,mB,i) if mA==A and mB==B: print(""match"") print(i) break if i==last-1: print(""-1"")" p02755,s878469748,Wrong Answer,"import math a=input().split() A,B=int(a[0]),int(a[1]) p=math.floor(A/0.08) if(math.floor(p*0.1)==B): print(p) else: print(-1)" p02755,s185376236,Wrong Answer,"import math a, b = list(map(int, input().split(' '))) al = math.ceil(a / 0.08) ar = math.floor((a + 1)/ 0.08) + 1 bl = math.ceil(b / 0.10) br = math.floor((b + 1)/ 0.10) + 1 ae = list(range(al, ar)) be = list(range(bl, br)) ee = set(ae) & set(be) if len(ee) == 0: print(-1) else: print(min(ee)) " p02755,s527821678,Wrong Answer,"import math as m a,b=map(int,input().split()) flag=True for i in range(1,101): if m.floor(i*(0.08))==a and m.floor(i*(0.08))==b: flag=False print(i) break if flag: print(-1) " p02755,s713904951,Wrong Answer,"import math blue, red = map(int, input().split()) blueA = math.floor(((blue) / 8) * 100) blueB = math.floor(((blue+1) / 8) * 100) redA = math.floor((red / 10) * 100) redB = math.floor(((red+1) / 10) * 100) if blueA <= redA: if blueB >= redA: print(redA) else: print(""-1"") else: if redB >= blueA: print(blueA) else: print(""-1"")" p02755,s411402277,Wrong Answer,"A,B = map(int,input().split()) for i in range(100+1): if int(i*0.08)==A and int(i*0.1)==B: print(i) exit() print(-1)" p02755,s135446554,Wrong Answer,"A , B = map ( int , input().strip().split("" "") ) ; c1 = ( A / 0.08 ) ; c2 = ( (A+1) / 0.08 ) ; c3 = int ( c2 ) ; if c2 == c3 : c3 = c3 -1 ; d1 = ( B / 0.10 ) ; d2 = ( (B+1) / 0.10 ) ; d3 = int ( d2 ) ; if d2 == d3 : d3 = d3 -1 ; if d3 < c1 or c3 < d1 : print ( -1 ); else : print ( int ( max ( c1 ,d1 ) ) ) ; " p02755,s323676670,Wrong Answer,"#!/usr/bin/env python3 # -*- coding: utf-8 -*- def main(): A, B = map(int, input().split()) result = int(max(A / 0.08, B / 0.1)) if int(result * 0.08) == A and int(result * 0.1) == B: print(result) else: print(-1) if __name__ == ""__main__"": main() " p02755,s884873190,Wrong Answer,"import math A, B = map(int, input().strip().split()) Amin=math.floor(A/0.08) Amax=math.floor((A+1)/0.08) if (A+1)%1.08==0: Amax-=1 Bmin=B*10 Bmax=(B+1)*10 if (B+1)%0.1==0: Bmax-=1 ans=-1 flag=False for a in range(Amin,Amax+1): for b in range(Bmin,Bmax+1): if a==b: ans=a flag=True break if flag: break print(ans)" p02755,s964166337,Wrong Answer,"from math import floor, ceil # 25a<=p<25(a+1) # 10b<=p<10(b+1) # also p must be integer, so the valid range # must lie around at least one integer value a, b = map(int, input().split()) inclusive_min = max(12.5*a, 10*b) exclusive_max = min(12.5*(a+1), 10*(b+1)) if floor(exclusive_max) >= ceil(inclusive_min): print(ceil(inclusive_min)) else: print(-1)" p02755,s811825844,Wrong Answer,"import math a, b = map(int, input().split()) for i in range(1010): tax8 = math.floor(a * 0.08) tax10 = math.floor(a * 0.1) if a == tax8 and b == tax10: print(i) exit() print(-1)" p02755,s892323712,Wrong Answer,"import math a, b = map(int, input().split()) a_low = math.ceil(a/0.08) a_high = math.floor((a+1)/0.08) b_low = math.ceil(b/0.1) b_high = math.floor((b+1)/0.1) if a_high 0 else -1 if len(r) == 1 and R == 0: R = -1 print(R) " p02755,s807046192,Wrong Answer,"n=list(map(int,input().split())) import math A=math.ceil(n[0]/0.08) B=math.ceil(n[1]/0.1) C=math.ceil(n[1]+1/0.1) D=math.ceil(n[0]+1/0.08) print(A) print(B) if A==B or B< B): print(-1) exit() if (max_10 < min_8 or max_8 < min_10): print(-1) exit() print(max(min_8,min_10))" p02755,s656760430,Wrong Answer,"from math import ceil,floor out = [] numA,numB = map(int,input().split()) for i in range(101): testA = floor(i * 0.08) testB = floor(i * 0.10) if testA >= numA and testB >= numB: out.append(i) if len(out) == 0: print(""-1"") else: print(min(out))" p02755,s697277013,Wrong Answer,"'''input 19 99 ''' import math a, b = input().split() a = int(a) b = int(b) a_low = int((a + 0.0) / 0.08) a_hig = int((a + 0.9) / 0.08) b_low = int((b + 0.0) / 0.1) b_hig = int((b + 0.9) / 0.1) 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)" p02755,s310290858,Wrong Answer,"a,b = map(int, input().split()) A = round(a/8*100) B = b*10 ans = float(""INF"") for i in range(min(A,B), max(A,B)+1): if int(i*0.08) == a and int(i*0.1) == b: if ans > i: ans = i print(ans if ans != float(""INF"") else -1)" p02755,s362471903,Wrong Answer,"import math def main(): a, b = [int(i) for i in input().split()] p = a / 0.08 if math.floor(p * 0.1) == b: print(math.ceil(p)) else: print(-1) if __name__ == '__main__': main() " p02755,s533737326,Wrong Answer,"A, B = map(int, input().split()) for i in range(1001): if (i*8//100) == A and (i * 10//100) == B: print(i) break else: print(""-1"")" p02755,s898670549,Wrong Answer,"a, b = map(int, input().split()) if b-a >= 2 : if b/a > 1.25 : cst = -1 else : cst = int((b-a)/0.02) else : cst_a = a / 0.08 cst_b = b / 0.1 cst = int(cst_a) print(int(cst))" p02755,s777584704,Wrong Answer,"a, b = map(int,input().split()) for i in range (1251): if int(i*0.08)==a and int(i/10)==b: print(i) print(-1) " p02755,s995478781,Wrong Answer,"import sys import math # input処理を高速化する input = sys.stdin.readline A,B = map(int,input().split()) Moneys = range(1,1000) #消費税が入力と一致したインデックス a_index=set() b_index=set() for i in Moneys: if math.floor(i*0.08) == A: a_index.add(i) for j in Moneys: if math.floor(j*0.1) == B: b_index.add(j) Tax = a_index&b_index if len(Tax)!=0: print(min(list(Tax))) else: print(-1)" p02755,s487204664,Wrong Answer,"import math A, B = list(map(int, input().split())) ans = -1 a = int(A/0.08) b = int(B/0.1) if a > b: a, b = b, a for i in range(a, b+1): if math.floor(i*0.08) == A and math.floor(i*0.1) == B: print(i) exit() print(-1)" p02755,s171178923,Wrong Answer,"import math a,b = [float(i) for i in input().split()] for i in range(1,100000): ans8 = int(math.floor(i*0.08)) ans10 = int(math.floor(i*0.1)) # print(ans8,ans10) if ans8 == a and ans10 == b: print(i) break elif i == 100: print(-1)" p02755,s422620839,Wrong Answer,"import math A,B=map(int,input().split()) x=int(A/0.08) y=int(B/0.1) eight=[x] ten=[y] while int(x*0.08)==A: x+=1 eight.append(x) while int(y*0.1)==B: y+=1 ten.append(y) eight_set=set(eight) ten_set=set(ten) ans_set=eight_set&ten_set ans=list(ans_set) if len(ans)>0: print(min(ans)) else: print(-1) " p02755,s978326032,Wrong Answer,"a,b=map(int,input().split()) mn=max(b*10,a*12.5) if mn==a*12.5 and a%2==1: mn=int(mn)+1 mx=min((b+1)/0.1,(a+1)/0.08) if mn<=mx: print(int(mn)) else: print(-1)" p02755,s115279000,Wrong Answer,"# C Tax Increase A, B = map(int, input().split()) a = [i for i in range(int(A*100/8), int((A+1)*100/8))] b = [i for i in range(B*10, (B+1)*10)] ans = list(set(a) & set(b)) if ans: print(min(ans)) else: print(-1)" p02755,s384339434,Wrong Answer,"a , b = map(int, input().split()) ans = -1 for i in range(1 , 10100) : a1 = int(i*0.08) b1 = int(i*0.10) if a1 == a and b1 == b : ans = i break print(i) " p02755,s103705598,Wrong Answer,"import math A, B = map(int, input().split()) a1 = math.ceil(A*100/8) a2 = math.ceil((A+1)*100/8) b1 = B*10 b2 = b1 + 10 if a2 < b1 or b2 < a1: print(-1) elif a1 < b1: print(b1) else: print(a1)" p02755,s524642659,Wrong Answer,"a,b = map(int,input().split()) for i in range(1, 1001): if int(i * 0.08) == a and int(i * 0.1) == b: print(i) else: print('-1')" p02755,s699926668,Wrong Answer,"A, B = map(int, input().split()) min_price_A = A * 12.5 max_price_A = min_price_A + 12 min_price_B = B * 10 max_price_B = min_price_B + 9 if min_price_A <= min_price_B: if max_price_A >= min_price_B: print(int(min_price_B)) else: print(-1) if min_price_A > min_price_B: if max_price_B >= min_price_A: print(int(min_price_A)) else: print(-1) " p02755,s428171975,Wrong Answer,"from math import floor A, B = map(int, input().split()) x1b = round(100 * A / 8) x2b = round(10 * B) x1t = floor(100 * (A + 1) / 8 - 0.0001) x2t = floor(10 * (B + 1) - 0.0001) if (x2b <= x1t and x1b <= x2t) or (x1b <= x2t and x2b <= x1t): print(max(x1b, x2b)) else: print('-1')" p02755,s687759452,Wrong Answer,"import math inp = input().split("" "") A, B = int(inp[0]), int(inp[1]) # print(int(A * 1/0.08)) possible = int(A * 1/0.08) // 10 # print(possible) answer = [] for i in range(possible * 10, possible * 10 + 10): tax_a = int(i * 0.08) tax_b = int(i * 0.1) # print(tax_a, tax_b) if tax_a == A and tax_b == B: answer.append(i) if len(answer) == 0: print(-1) else: print(answer[0])" p02755,s832014808,Wrong Answer,"a,b=map(int,input().split()) a_min=a/0.08 b_min=b/0.1 a_max=(a+1)/0.08 b_max=(b+1)/0.1 if a_min>b_max or a_maxb else b iin = lambda : int(input()) lin = lambda : list(map(int,input().split())) rin = lambda n : [int(input()) for _ in range(n)] a,b = map(int,input().split()) at = [] for i in range(1,1500): if int(i*0.08)==a: at += [i] bt = [] for i in range(1,1000): if int(i*0.1)==b: bt += [i] ans = set(at) & set(bt) print(min(ans) if ans else -1)" p02755,s976458615,Wrong Answer,"a, b = map(int, input().split()) x = int(a / 0.08) ans = -1 for i in range(14): if (int((x+ i) * 0.1)) == b: if int((x + i) * 0.08) == a: ans = int(x + i) break print(ans)" p02755,s608801570,Wrong Answer,"a,b = map(int, input().split()) ls = [b*10+i for i in [0,1,2,3,4,5,6,7,8,9]] t = 0 for x in ls: if a*100/8 == x: print(x) break else: t += 1 if t == 10: print(-1)" p02755,s258630900,Wrong Answer,"# A: 0.08 tax, B: 0.10 tax A, B = list(map(int, input().split())) # find candidate prices candidate_prices = [(B*10) + i for i in range(0 , 6)] # find minimum possible price for p in candidate_prices: if int(p*(0.08)) == A: print(p) print(-1)" p02755,s130348181,Wrong Answer,"from math import floor a, b = map(int, input().split()) for i in range(200): x = floor(i * 0.08) y = floor(i * 0.1) if x == a and y == b: print(i) exit(0) print(-1) " p02755,s242186339,Wrong Answer,"import sys input = lambda: sys.stdin.readline().rstrip() input_nums = lambda: list(map(int, input().split())) a, b = input_nums() a_rate = 0.08 b_rate = 0.1 al = a / a_rate ar = (a+1) / a_rate bl = b / b_rate br = (b+1) / b_rate ans = 0 if bl <= al and al < br: ans = int(al) elif bl <= ar and ar < br: ans = int(bl) elif al <= bl and br <= ar: ans = int(bl) else: ans = -1 if int(ans*0.08) < a: ans += 1 print(ans)" p02755,s553907120,Wrong Answer,"from math import floor A, B = map(int, input().split()) N = -1 for i in range(1, 101): if (floor(i * 0.08) == A and floor(i * 0.10) == B): print(i) exit(0) print(N)" p02755,s496455181,Wrong Answer,"# -*- coding: utf-8 -*- a, b, = map(int, input().split()) p = (a*100)/8 py = int(a)+1 pa = int(p) q = (b*100)/10 pz = int(b)-1 pb = int(q) if (py*100)/8<(pz*100)/10: print(""-1"") else: if pa>=pb: print(pa) else: print(pb)" p02755,s856758003,Wrong Answer,"a, b = map(int, input().split()) judge = True for i in range(1,1000): if 0.08*i//1 == a and 0.1*i//1 ==b: print(i) judge = False break if judge: print(-1) " p02755,s017395018,Wrong Answer,"def main(): A, B = [int(x) for x in input().split()] max_b = (B+1) * 10 - 1 min_b = (B-1) * 10 + 1 for num in range(min_b, max_b + 1): val = int(num * 0.08) if val == A: print(num) return elif val > A: print(-1) return print(-1) if __name__ == ""__main__"": main() " p02755,s229605997,Wrong Answer,"def main(): a, b = map(int, input().split()) x = int(a / 0.08) y = int(b / 0.10) if int(x * 0.10) == b: print(x) else: print('-1') if __name__ == ""__main__"": main() " p02755,s902770810,Wrong Answer,"from math import ceil def main(): a, b = map(int, input().split()) p8_l = ceil(a / 0.08) p8_h = ceil((a+1) / 0.08) p10_l = int(b / 0.10) p10_h = int((b+1) / 0.10) - 1 if p8_h >= p10_h >= p8_l: print(p8_l) elif p8_l <= p10_l <= p8_h: print(p10_l) else: print(-1) if __name__ == '__main__': main()" p02755,s429451081,Wrong Answer,"A,B = map(int, input().split()) price_A = (A * 100) // 8 price_B = B * 10 price_A_pl = (A * 100+8) // 8 price_B_pl = (B + 10) * 10 ans = -1 ans2 = -1 if price_A // 10 == B: ans = price_A if (price_B*8) // 100 == A: ans = price_B if price_A_pl // 10 == B: ans2 = price_A_pl if (price_B_pl*8) // 100 == A: ans2 = price_B_pl if ans2 != -1 and ans != -1: ans = min(ans, ans2) elif ans2 != -1 and ans == -1: ans = ans2 print(ans)" p02755,s265835982,Wrong Answer,"a,b = map(int,input().split()) a1 = int((a) * 100/8) a2 = int((a + 1) * 100/8) b1 = int((b) * 10) b2 = int((b + 1) * 10) al = list(range(a1,a2)) bl = list(range(b1,b2)) if a2 > b1: print(max(min(al),min(bl))) else: print(-1)" p02755,s523467643,Wrong Answer,"a, b = map(int, input().split()) pa = int(a * 100/8) pb = int(b * 100/10) for price in range(pb, pa+1): if int(price * 0.08) == a and int(price * 0.1) == b: print(price) exit() print(-1)" p02755,s722399705,Wrong Answer,"from math import ceil,floor def without_tax(a,b): w_a = ceil(a/0.08) m_w_a = floor((a+1)/0.08) w_b = ceil(b/0.1) m_w_b = floor((b+1)/0.1) if m_w_b < w_a or m_w_a < m_w_b: return -1 return max(w_a,w_b) a,b = [int(e) for e in input().split()] print(without_tax(a,b))" p02755,s878550260,Wrong Answer,"A, B=map(int, input().split()) Alist=[i for i in range(int(A/0.08),int((A+1)/0.08))] Blist=[i for i in range(int(B/0.1),int((B+1)/0.1))] if set(Alist)&set(Blist): print(min(set(Alist)&set(Blist))) else: print(""-1"") " p02755,s422719372,Wrong Answer,"S = [int(x) for x in input().split()] A = S[0] B = S[1] ans = -1 for i in range(100): num = (i+1) MotoA = int(num * 0.08) MotoB = int(num * 0.1) if MotoA == A and MotoB ==B: ans = num break print(ans)" p02755,s697758939,Wrong Answer,"A,B=map(int,input().split()) a=A/(0.08); res=0 # print(a,b) for n in range(1250): if (n<=a= bl: ans = bl elif al >= bl and br >= al: ans = al else: ans = -1 # if al == bl: # ans = al # elif al > bl: # if al > br: # ans = -1 # else: # ans = al # elif al < bl: # if ar < bl: # ans = -1 # else: # ans = bl print(ans)" p02755,s107608746,Wrong Answer,"from collections import defaultdict a,b=map(int,input().split()) dic=defaultdict(lambda:-1) for i in range(100,0,-1): dic[int(i*0.08),int(i*0.10)]=i print(dic[a,b]) " p02755,s384661176,Wrong Answer,"import math a,b=map(int,input().split()) n = math.ceil(a/0.08) m = math.floor(b/0.1) for i in range (min(n,m),max(n,m)+1): if math.floor(i * 0.08) == math.floor(i*0.1): print(i) break if n==m: print(n) elif math.floor(max(n,m)*0.08) != math.floor(max(n,m)*0.1): print(-1) " p02755,s937394665,Wrong Answer,"a,b = map(int, input().split()) c = int(a*(5/4)) d = a*(11/8) if c<=b and b result_b: c = int(result_a * 0.1) if b == c: print(result_a) else: print(-1) else: c = int(result_b * 0.08) if a == c: print(result_b) else: print(-1)" p02755,s511115800,Wrong Answer,"import math A,B = map(int,input().split()) ans = [] for i in range(1,101): if math.floor(i*0.08) == A and math.floor(i*0.1) == B: ans.append(i) if not ans: print('-1') else: print(min(ans))" p02755,s221560602,Wrong Answer,"a,b=map(int,input().split()) tax8=a/2*25 tax8l=(a-1)/2*25 tax8h=(a+1)/2*25 tax10=float(b*10) tax10l=float((b-1)*10) tax10h=float((b+1)*10) if tax10>tax8l and tax10tax10l and tax8max(int(tax8),int(tax10)): print(max(int(tax8+1),int(tax10+1))) else: print(max(int(tax8),int(tax10))) else: print(-1)" p02755,s552309797,Wrong Answer,"import math A, B = map(int,input().split()) minA = math.floor(A/0.08) maxA = math.ceil((A+1)/0.08) -1 minB = math.floor(B/0.08) maxB = math.ceil((B+1)/0.08) -1 if (minA>maxB) or (minB>maxA): print(-1) else: print(min(minA,minB)) " p02755,s402434001,Wrong Answer," A, B = map(int, input().split()) def floor_inv(x, f): res = int(x / f) if int(res * f) < x: res += 1 return res lb1 = floor_inv(A, 0.08) ub1 = floor_inv(A + 1, 0.08) lb2 = floor_inv(B, 0.10) ub2 = floor_inv(B + 1, 0.10) if ub1 < lb2 or ub2 < lb1: print(-1) else: print(max(lb1, lb2)) " p02755,s498730276,Wrong Answer,"A,B = map(int,input().split()) for i in range(1,1251): if i*0.08==A and i *0.1==B: print(i) exit() print('-1') " p02755,s154684872,Wrong Answer,"import math a,b = map(int,input().split()) x = (round(a/0.08)) y = (round(b/0.1)) check = round(x*0.1) if (check == b) : print(x) else : print(-1) " p02755,s341613050,Wrong Answer,"a,b = map(int, input().split()) al=-int(-a/0.08) ah = int((a+1)/0.08) bl=-int(-b/0.1) bh = int((b+1)/0.1) if bl > al: cl = al ch = ah dl = bl dh = bh else: cl = bl ch = bh dl = al dh = ah #print(cl, ch, dl, dh) if ch < dl: print(-1) else: print(dl) " p02755,s596688867,Wrong Answer,"x, y = map(int, input().split()) a = x / 0.08 b = y / 0.1 ans = -1 for i in range(round(b), round((y+1)/0.08)): if round(a) ==i: ans = i break print(ans)" p02755,s074231423,Wrong Answer,"a,b = map(int, input().split()) p = [] for i in range(10, 1000): if int(i*0.08) == a: if int(i*0.1) == b: p.append(i) if len(p) == 0 or p[0] == 0: print(-1) else: print(p[0])" p02755,s061784565,Wrong Answer,"A,B = map(int, input().split()) price_A = (A * 100) // 8 price_B = B * 10 ans1 = -1 ans2 = -1 ans = -1 if price_A // 10 == B: ans1 = price_A if (price_B*8) // 100 == A: ans2 = price_B if ans1 != -1 and ans2 != -1: ans = min(ans1, ans2) elif ans1 == -1 and ans2 != -1: ans = ans2 elif ans1 != -1 and ans2 == -1: ans = ans1 print(ans)" p02755,s899413275,Wrong Answer,"inputted = list(map(int, input().split())) tax_price_a = inputted[0] tax_price_b = inputted[1] price_8 = int(tax_price_a / 0.08) price_10 = int(tax_price_b / 0.10) if tax_price_b == int(price_8 * 0.1): print(price_8) elif tax_price_a == int(price_10 * 0.8): print(price_10) else: print('-1') " p02755,s947611612,Wrong Answer,"a,b = map(int,input().split()) ans = int(a*12.5) if ans // 10 == b: print(ans) else: print(-1)" p02755,s595107459,Wrong Answer,"A,B = map(int,input().split()) x = int((100*A)/8) y = int((100*B)/10) if (int(x*0.08) == A)&(int(y*0.1) == B): print(x) elif (int(y*0.08) == A)&(int(y*0.1) == B): print(y) else: print(""-1"")" p02755,s270077731,Wrong Answer,"import math a, b = map(int, input().split()) a_zei = 0 b_zei = 0 i =0 while i * 0.08 <= a: if i * 0.08 == a and math.floor(i * 0.1) == b: print(i) exit() i += 1 print(-1)" p02755,s857573370,Wrong Answer,"import math A, B = map(int, input().split()) al = math.floor(12.5*A) ar = math.floor(12.5*(A+1)) bl = 10*B br = 10*(B+1) if ar < bl or br < al: print(""-1"") elif al < bl: print(bl) else: print(al)" p02755,s746540753,Wrong Answer,"x, y = list(map(int,input().split())) X = x//0.08 Y = y//0.1 if X == Y: print(X) else: print(-1)" p02755,s888457462,Wrong Answer,"import math a, b = map(int, input().split()) # 切り上げ amin = math.ceil(a / 0.08) bmin = math.ceil(b / 0.1) # 切り捨て amax = math.floor((a+1) / 0.08) bmax = math.floor((b+1) / 0.1) #print(""{},{}"".format(amin, bmin)) #print(""{},{}"".format(amax, bmax)) ret = -1 for i in range(amin, amax+1, 1): if bmin <= i and i <= bmax: ret = i break print(""{}"".format(ret))" p02755,s119833838,Wrong Answer,"a,b=map(int,input().split()) ans=-1 for i in range(1,101): _A = (i * 8)//100 _B = (i * 10)//100 if a == _A: if b == _B: ans = i break print(ans)" p02755,s211099073,Wrong Answer,"# coding: utf-8 A, B = map(int, input().split()) # print(""A:"", A, ""B:"", B) n = int(A / 0.08) m = int(B / 0.1) n1 = int((A + 1) / 0.08) m1 = int((B + 1) // 0.1) m2 = {i for i in range(n, n1)} m3 = {j for j in range(m, m1)} s = set(m2 & m3) if s: print(min(s)) else: print(-1) " p02755,s863639189,Wrong Answer,"a,b = map(int,input().split()) TF = True A,B = [],[] for i in range(10): ansA = int((a+0.1*i)*12.5) ansB = int((b+0.1*i)*10) A.append(ansA) B.append(ansB) if ansA in B: print(ansA) TF = False break elif ansB in A: print(ansB) TF = False break if TF == True: print(-1)" p02755,s091832059,Wrong Answer,"A, B = map(int, input().split()) for p in range(10, 1010): if (8*p//100 == A) and (p//10 == B): print(p) break print(-1)" p02755,s520212983,Wrong Answer,"import sys a,b = map(lambda x: int(x),input().split()) for i in range(100) : a_tax = int((a + i*0.01)* (12.5)) if a_tax < 13 and a_tax > 1262: continue for j in range(100) : b_tax = int((b + j*0.01)* (10)) if b_tax < 10 and b_tax > 1010: continue if a_tax == b_tax : print(int(a_tax)) sys.exit() print(-1) " p02755,s864901642,Wrong Answer,"A,B=map(int,input().split()) for i in range(101): if ((i*8)+0.000005)//100==A and ((i*10)+0.000005)//100==B: print(i) exit() else: pass print(-1)" p02755,s180275660,Wrong Answer,"a,b = list(map(int,input().split())) to = 0 while 1: to += 100 c = int(to * 0.08) d = int(to * 0.1) if c >= a and d >= b: while 1: to -= 1 c = int(to * 0.08) d = int(to * 0.1) if c == a and d == b: print(to) exit() elif to % 100 == 0: print(-1) exit()" p02755,s319811083,Wrong Answer,"a, b = list(map(int, input().split())) xa = int(a / 0.08) xb = int(b * 10) xaFlag =int(xa * 0.1) == b xbFlag = int(xb * 0.08) == a if(xaFlag == True and xbFlag == False): print(int(xa)) elif(xaFlag == False and xbFlag == True): print(int(xb)) elif(xaFlag == False and xbFlag == False): print(-1) else: print(min(xa, xb))" p02755,s938219506,Wrong Answer,"a, b = map(int, input().split()) x = -1 xa = 0 xb = 0 a_arr = [] b_arr = [] for temp_a in range(10001): xa = temp_a * 0.08 if xa // 1 == a: a_arr.append(temp_a) for temp_b in range(10001): xb = temp_b * 0.1 if xb // 1 == b: b_arr.append(temp_b) print(a_arr) print(b_arr) for aa in a_arr: if aa in b_arr: print(aa) exit(0) print('-1')" p02755,s446624068,Wrong Answer,"import math taxA, taxB= map(int,input().split()) minPriceA = math.floor(taxA / 0.08) maxPriceA = math.ceil((taxA + 1) / 0.08) minPriceB = math.floor(taxB / 0.1) maxPriceB = math.ceil((taxB + 1) / 0.1) minPrice = None finish = False for a in range(minPriceA, maxPriceA + 1): for b in range(minPriceB, maxPriceB + 1): if (a == b): minPrice = a finish = True break if (finish): break if minPrice == None: print(-1) else: print(minPrice)" p02755,s000980256,Wrong Answer,"x = [int(x) for x in input().split()] A, B = x[0], x[1] a = int(100 * A / 8) b = 10 * B if a == b: print(a) elif a > b and int(a * 0.1) == B: print(a) elif b > a and int(b * 0.08) == A: print(b) else: print(-1) " p02755,s940872429,Wrong Answer,"import math A, B = map(lambda x: int(x), input().split("" "")) result = -1 for i in range(1, 101): if math.floor(i*0.08) == A and math.floor(i*0.1) == B: result = i break print(result) " p02755,s544534805,Wrong Answer,"a,b = map(int,input().split()) for i in range(1300): if int(i*0.08) == a and int(i*0.1) == b: print(i) break " p02755,s846664103,Wrong Answer,"a,b = (int(x) for x in input().split()) my_index = [] for i in range(101): if int((i*0.08)) ==a and int((i*0.1))==b: my_index.append(i) if int((i*0.08)) ==b and int((i*0.1))==a: my_index.append(i) if my_index != []: print(min(my_index)) else: print(-1)" p02755,s802842279,Wrong Answer,"A,B=map(int, input().split()) for i in range(1100): if int(i*0.8)==A and int(i*0.1)==B: print(i) break else: print(-1) " p02755,s278504119,Wrong Answer,"A,B=map(float,input().split()) A_min=int(A/8*100) A_max=int((A+1)/8*100)+1 ans=0 flag=False if (A+1)*100%8==0: A_max=int((A+1)*100/8) for i in range(A_min,A_max): if int(i*0.1)==B: ans=i flag=True break if flag: print(ans) else: print(-1)" p02755,s359556911,Wrong Answer,"a,b=map(int,input().split()) for i in range(1500): if int(i*0.08) == a and int(i*0.1) == b: print(i) print(-1) " p02755,s326389016,Wrong Answer,"a, b = map(int, input().split()) tmp_a = int((a / 0.08) // 1) tmp_b = int((b / 0.10) // 1) check = True for i in range(min(tmp_a,tmp_b), max(tmp_a, tmp_b) + 1): if int((i * 0.08)//1) == a and int((i * 0.10)//1) == b: print(i) check = False break if check: print(-1)" p02755,s362852473,Wrong Answer,"a,b=map(int,input().split()) eightper = 0.08 tenper = 0.1 ans = -1 for i in range(100+1): if int(i*eightper)==a: if int(i*tenper)==b: ans=i break print(ans)" p02755,s086689819,Wrong Answer,"# input A,B = map(int, input().split()) # calculate price = -1 for n in range(100): if int(n * 0.08) == A and int(n * 0.1) == B: price = n break else: pass # output print(price)" p02755,s736304443,Wrong Answer,"a,b =map(int,input().split()) for x in range(101): if (x*1.08)//1==a+x and (x*1.10)//1==b+x and x//1==int(x): print(int(x)) exit() print(-1)" p02755,s464799377,Wrong Answer,"a,b = map(float,input().split()) c = a*12.5+0.001 d = b*10+0.001 if(int(c/10)==int(d/10)): ans = max(int(c),int(d)) else: ans = -1 print(ans)" p02755,s710176615,Wrong Answer,"import math A, B = map(int, input().split()) b = B * 10 ans = -1 for i in range(b, 1001): y = math.floor(i * 0.08) if y == A: ans = i break print(ans) " p02755,s327407470,Wrong Answer,"A, B = [int(y) for y in input().split(' ')] priceA_min = int((A/8) * 100) priceA_max = int(((A+1)/8) * 100) print(priceA_min, priceA_max) found = False for x in range(priceA_min,priceA_max+1,1): if int(x*0.1) == B: print(x) found = True break if not found: print(-1)" p02755,s963779384,Wrong Answer,"a, b = map(int, input().split()) x = a / 0.08 print(int(x) if int(x*0.10)==b else -1) " p02755,s940909759,Wrong Answer," a,b = map(int,input().split()) c = int(a / 0.08) status = 0 ans = 0 for i in range(1,c+1): if 1 <= int(i * 0.08) and 1 <= int(i * 0.1) and int(i * 0.08) == a and int(i * 0.1) == b: # print(i) if int(i * 0.08) == a and int(i * 0.1) == b: status = 1 ans = i break else: pass if status == 1: print(ans) else: print(-1) " p02755,s679648998,Wrong Answer,"a,b=map(int,input().split()) ans=-1 for k in range(1000): if int(k*0.08)==a and int(k*0.1)==b: ans=k break else: continue print(ans)" p02755,s746028877,Wrong Answer,"A,B = map(int,input().split()) m08=A/0.08 m10low=B/0.1 m10up=(B+1)/0.1 if m08m10low: print(int(m08)) else: print(-1)" p02755,s809301152,Wrong Answer,"#C - Tax Increase import math A,B = map(int,input().split()) x = int(math.floor(A*(100/8))) y = int((B*(100/10))) ans = '-1' for i in range(1,max(x,y)+1): if math.floor(i * 0.08)== A and math.floor(i*0.1) == B: ans = i print(ans)" p02755,s359336190,Wrong Answer,"a, b = map(int, input().split()) for i in range(990): c = int((i + 10) * 0.08) d = int((i + 10) * 0.10) if c == a and d == b: print(i + 10) exit() print('-1')" p02755,s522588621,Wrong Answer,"A, B = map(int, input().split()) ans = -1 for i in range(10 ** 3 + 1): if int(i * 0.08) == A and int(i * 0.1) == B: ans = i print(ans)" p02755,s657456958,Wrong Answer,"a,b=map(int,input().split()) z,x,c,v=10*b,10*b+10-1,50*a//4,50*(a+1)//4-1 if not len(range(max(z,c),min(x,v)+1)):print(-1) else:print(max(z,c))" p02755,s146837909,Wrong Answer,"tax_eight, tax_ten = map(int, input().split()) min_eight_price = tax_eight / 0.08 max_eight_price = (tax_eight + 1) / 0.08 min_ten_price = tax_ten / 0.1 max_ten_price = (tax_ten + 1) / 0.1 min_price = max(min_eight_price, min_ten_price) max_price = min(max_eight_price, max_ten_price) if max_price < min_price: print(-1) else: print(int(min_price))" p02755,s709878302,Wrong Answer,"n=list(map(int,input().split())) import math A=int(math.ceil(n[0]/0.08)) B=int(n[1]/0.1) C=int((n[1]+1)/0.1) D=int(math.ceil((n[0]+1)/0.08)) if A<>B: print(A) elif A<= Xb_max or Xb_min >= Xa_max: print(-1) exit() if Xa_min >= Xb_min: ans = math.floor(Xa_min) if ans >= Xb_max: print(-1) exit() else: ans = math.floor(Xb_min) if ans >= Xa_max: print(-1) exit() print(ans)" p02755,s268944021,Wrong Answer,"#!/usr/bin/env python3 import sys import math #input = sys.stdin.buffer.readline def inn(func=int): return list(map(func,input().split())) def ins(): return input().split() a,b = inn() p8 = int(a/2)*25+int(a%2)*13 p10 = b*10 p8_ = p8+12 if a%2 == 0 else p8+12+11 p10_ = p10+9 #print(p8,p10,p8_,p10_) if p8 == p10: print(p8) elif p8 > p10 and p8 <= p10_: print(p8) elif p10 > p8 and p10 <= p8_: print(p10) else: print(-1)" p02755,s428461763,Wrong Answer,"import math A, B = map(int, input().split()) min_ans = -(-A // 0.08) kouho = [min_ans] to_continue = True while to_continue: min_ans += 1 if math.floor(min_ans * 0.08) == A: kouho.append(min_ans) else: break print_flag = False for i in kouho: if math.floor(i * 0.1) == B: print_flag = True print(i) break if print_flag == False: print('No')" p02755,s306821654,Wrong Answer,"import sys A, B = [int(x) for x in input().split()] for x in range((A+1)*10,(B+1)*10): if A == x*8//100 and B == x//10: print(x) sys.exit() print(-1)" p02755,s356982207,Wrong Answer,"A, B = map(int, input().split()) flag = 0 for i in range(10000): x = (i * 8) // 100 y = (i*10)//100 if(x == A & y == B): print(i) flag = 1 break if(flag == 0): print('-1') " p02755,s766100200,Wrong Answer,"A,B=map(int,input().split()) c=0 for i in range(1,100000): if (i*0.08)//1==A and (i**0.1)//1==B: c=i break if c!=0: print(c) else: print(-1) " p02755,s278019018,Wrong Answer,"a, b = map(int, input().split(' ')) for i in range(101): if int(i*0.08)==a and int(i*0.1)==b: print(i) exit(0) print(-1)" p02755,s166102836,Wrong Answer,"a, b = map(int, input().split()) a1 = set([int((a + i/100) * 12.5) for i in range(1000)]) b1 = set([int((b + i/1000) * 10) for i in range(1000)]) res = a1 & b1 if res: print(min(res)) else: print(-1)" p02755,s504448365,Wrong Answer,"A,B = [int(i) for i in input().split()] emax = (A + 1) / 0.08 emin = A / 0.08 tmax = (B + 1) / 0.1 tmin = B / 0.1 if emin < tmax and emin >= tmin: print(int(emin)) elif tmin < emax and tmin >= emin: print(int(tmin)) else: print(-1) " p02755,s418038198,Wrong Answer,"import math A, B = list(map(int, input().split())) amax = math.floor((A + 1) / 8 * 100) amin = math.ceil(A / 8 * 100) bmax = math.floor((B + 1) / 10 * 100) bmin = math.ceil(B / 10 * 100) if amin >= bmin: answer = amin if amin < bmax else - 1 else: answer = bmin if bmin < amax else -1 print(answer) " p02755,s744120111,Wrong Answer,"a, b = map(int, input().split()) no_tax_1 = a * 100 // 8 no_tax_2 = a * 100 // 7 while no_tax_1 <= no_tax_2: if round(no_tax_1 * 0.1) == b: print(no_tax_1) exit() no_tax_1 += 1 print(-1) " p02755,s938398713,Wrong Answer,"a,b=map(int,input().split()) ah,bh=a+.99,b+.99 a1,a2=a/.08,ah/.08 b1,b2=b/.1,bh/.1 if a2= X2 and X11 == AX: print(X1) else: print('-1') " p02755,s864428674,Wrong Answer,"a, b = list(map(int, input().strip().split())) for i in range(0,1000): if int(i*0.08)==a and int(i*0.1)==b: print(i) break else: print(""-1"") " p02755,s895062455,Wrong Answer,"import math a,b = map(int,input().split()) p1 = a / 0.08 p2 = b / 0.1 ans = math.inf if math.floor(p1 * 0.1) == b: ans = p1 if math.floor(p2 * 0.08) == a: ans = min(ans,p2) if ans == math.inf: ans = -1 print(int(ans))" p02755,s570602954,Wrong Answer,"#coding:utf-8 def main(): a, b = map(int, input().split()) for i in range(2000): if int(i * 0.08) == a and round(i * 0.1) == b: print(i) break else: print(-1) if __name__ == '__main__': main() " p02755,s255294366,Wrong Answer,"a,b = map(int, input().split()) print(int(10*a+2*b)) " p02755,s099703170,Wrong Answer,"import math a,b=map(int,input().split()) ax=set(range(math.ceil(25*a/2),math.floor(25*(a+1)/2)+1)) bx=set(range(math.ceil(10*b),math.floor(10*(b+1))+1)) x=list(ax&bx) if x: print(x[0]) else: print(-1)" p02755,s066965435,Wrong Answer,"a, b = map(int, input().split()) for i in range(1,1009): if int(i*0.08) == a and int(i*0.1) == b: print(int(i)) print(""-1"")" p02755,s360314338,Wrong Answer," A,B = map(int, raw_input().split()) result = False Amin = int(round(A * 12.5)) Amax = int(round((A+1) * 12.5)-1) Bmin = B * 10 Bmax = (B+1) * 10 for i in range(Amin,Amax+1): for j in range(Bmin,Bmax+1): if(i == j): print(i) result = True break if(result): break if(result==False): print(-1) " p02755,s590872124,Wrong Answer,"a, b = list(map(int, input().split())) tmp = int((a*12.5) // 1) cnt = tmp while (cnt*0.08)//1 == a: cnt += 1 if cnt == tmp: cnt += 1 #print(tmp, cnt) for i in range(tmp, cnt): ans = int((i * 0.1)//1) #print(i ,ans) if ans == b: print(i) exit() print(-1)" p02755,s393267620,Wrong Answer,"a, b = map(int, input().split()) for i in range(int(a/0.08), int((a+1)/0.08)): if int(i * 0.1) == b: print(i) break else: print(-1)" p02755,s506685214,Wrong Answer,"import math A, B = map(int,input().split()) Amin = A/0.08 Amax = (A+1)/0.08 Bmin = B/0.1 Bmax = (B+1)/0.1 ans = 0 if Amax <= Bmin or Amin >= Bmax: ans = -1 else: if Bmin <= Amin: ans = math.floor(Amin) if Amin <= Bmin: ans =math.floor(Bmin) print(ans)" p02755,s679644373,Wrong Answer,"import math import numpy as np a,b = map(int,input().split()) amin,amax,bmin,bmax = 0,0,0,0 amin = a/0.08 amax = math.floor((a + 0.999999999999999999999999999999)/0.08) bmin = b/0.1 bmax = math.floor((b + 0.99999999999999999999999999999999)/0.1) alist = np.arange(amin,amax,1) blist = np.arange(bmin,bmax,1) matched_list = [] src_set = set(alist) tag_set = set(blist) anslist = list(src_set & tag_set) if len(anslist)==0: print('-1') else: print(int(min(anslist)))" p02755,s546940081,Wrong Answer,"a,b = list(map(int,input().split())) A = list(range(int((a / 0.08)),int((a+1)/0.08)-1)) B = list(range(int((b / 0.1)),int((b+1)/0.1)-1)) price = set(A) & set(B) if len(price) == 0: ans = -1 else: ans = min(price) print(ans)" p02755,s682163707,Wrong Answer,"import math c=list(map(int, input().split())) A = c[0] B = c[1] able = 1 for i in range(1000): if math.floor(i * 0.08 == A ) and math.floor(i * 0.1 == B): print(i) able = 0 if able: print(-1)" p02755,s483669226,Wrong Answer,"import math A, B = map(int,input().split()) minA = math.floor(A/0.08) maxA = math.ceil((A+1)/0.08) -1 minB = math.floor(B/0.08) maxB = math.ceil((B+1)/0.08) -1 if (minA>maxB) or (minB>maxA): print(-1) else: print(max(minA,minB)) " p02755,s309281865,Wrong Answer,"import math A,B =list(map(int,input().split())) fr = 0 for i in range(300): if math.floor(i * 0.08) == A and math.floor(i * 0.1) == B: print(i) fr += 1 break if fr == 0: print(-1)" p02755,s888522530,Wrong Answer,"import sys import math a, b = map(int, input().split()) downera = math.floor(100/8 * a) uppera = math.floor(100/8 * (a+1)) downerb = 10 * b upperb = 10 * (b+1) #print(downera, uppera, downerb, upperb) if uppera < downerb or upperb < downera: print(""-1"") sys.exit() for i in range(downera, uppera): if i >= downerb and i < upperb: print(i) sys.exit() print(""-1"") " p02755,s200548287,Wrong Answer,"A, B = map(int, input().split()) x1 = int(A * 100.0 / 8) x2 = B * 10 y1 = int((A+1) * 100.0 / 8) y2 = (B+1) * 10 r = -1 for p in range(max(x1,x2), min(y1,y2)): r = p break print(r)" p02755,s222642699,Wrong Answer,"import math a,b = map(int,input().split()) a1 = int(a/0.08) b1 = int(b/0.1) c = min(a1,b1) while True: if math.floor(c*0.08) == a and math.floor(c*0.1) == b: print(c) break elif math.floor(c*0.08) != a and math.floor(c*0.1) != b: print(-1) break else: c+=1 " p02755,s423448248,Wrong Answer,"# -*- coding: utf-8 -*- import math def main(): A,B = map(int,input().split()) ansA = math.floor(A/0.08) if math.floor(0.1*ansA) == B: print(ansA) return ansB = math.floor(B/0.1) if math.floor(0.08*ansB) == A: print(ansB) return print('-1') if __name__ == '__main__': main()" p02755,s517747237,Wrong Answer,"a,b=map(int,input().split()) c=[] d=[] if a % 2 == 0: s = int(100*a/8) t = int(100*(a+1)/8) + 1 else: s = int(100*a/8) + 1 t = int(100*(a+1)/8) u = int(100*b/10) v = int(100*(b+1)/10) for i in range(s,t): c.append(i) for j in range(u,v): d.append(j) print(c) print(d) c_d = set(c) & set(d) if (len(c_d)>0): print(min(c_d)) else: print(-1) " p02755,s059985803,Wrong Answer,"import math a , b = map(int , input().split()) for i in range(1000): if math.floor(i * 0.08) == a and math.floor(i* 0.1) == b: print(i) break print(-1)" p02755,s811642906,Wrong Answer,"import math a,b = map(int,input().split()) f = math.floor min8, max8 = f(a*12.5), f((a+1)*12.5) min10, max10 = f(b*10), f((b+1)*10) l8, l10 = list(range(min8, max8)), list(range(min10, max10)) s8, s10 = set(l8), set(l10) ss = s8 & s10 print(min(ss) if len(ss) >0 else -1)" p02755,s328868091,Wrong Answer,"a,b = map(int, input().split()) ans = -1 for i in range(10**5): if (i*0.08) == a and (i*0.1): ans = i break print(ans)" p02755,s399558360,Wrong Answer,"A,B=map(int,input().split()) A0= int(A / 0.08) B0= int(B / 0.1) if (A == A0*0.08) & (B == B0*0.1): print(A0) else: print(""-1"") " p02755,s920641885,Wrong Answer,"A, B = map(int,input().split()) rangea = set(range(int(A/0.08),int((A+1)/0.08),1)) rangeb = set(range(int(B/0.10),int((B+1)/0.10),1)) intersection = rangea & rangeb if len(intersection)==0: print(-1) else: print(min(intersection))" p02755,s076361242,Wrong Answer,"a,b = map(int,input().split()) ans = -1 for x in range(b*10,(b+1)*10+1): if x*0.08 == a: ans = x break print(ans)" p02755,s984655944,Wrong Answer,"import sys a,b=map(int,input().split()) i=0 while i <= 100: if a==int(i*0.08) and b==int(i*0.1): print(i) sys.exit() i+=1 print(-1)" p02755,s471502785,Wrong Answer,"a, b = map(int, input().split()) for i in range(10, 10001): x = (a * 100) // 8 y = (b * 10) // 1 if x <= y and y <= x+6: print(y) break elif y <= x and x <= y+8: print(x) break elif i == 1000: print(-1)" p02755,s325639785,Wrong Answer,"a,b = input().split() a = int(a) b = int(b) c = 1 for i in range(99): d = c*0.08 e = c*0.1 d = int(d) e = int(e) if d == a and e == b: print(c) break elif c == 100: print('-1') else: c += 1" p02755,s366748723,Wrong Answer,"# coding: utf-8 A, B = map(int, input().split()) x = int(A / 0.08) y = int(B / 0.1) result = max(x, y) if x < y: print('-1') else: print(result) " p02755,s293804359,Wrong Answer,"A, B = map(int,input().split()) one = A/0.08 two = (A+1)/0.08 three = B/0.1 four = (B+1)/0.1 print(one, two, three, four) if two < three or one > four: kai = -1 if three <= one and one <= four <= two: kai = one if one < three <=two: kai = three print(kai) " p02755,s460605084,Wrong Answer,"import math A, B = map(int, input().split()) X = math.floor(A/0.08) Y = math.floor(B/0.1) if X == Y: print(X) else: if X > Y: if B == math.floor(Y * 0.08): print(Y) elif A == math.floor(X * 0.1): print(X) else: print(-1) else: if A == math.floor(X * 0.1): print(X) elif B == math.floor(X * 0.08): print(Y) else: print(-1) " p02755,s781817072,Wrong Answer,"B,A = map(int,input().split()) if int((B+0.999)*12.5) >= A*10 and A*10 >= int(B*12.5): print(A*10) elif int((B+0.999)*12.5) >= (A+0.9)*10 and (A+0.9)*10 >= int(B*12.5): print(int(B*12.5)) else: print(""-1"")" p02755,s339386218,Wrong Answer,"a, b = map(int, input().split()) tax008 = [int(a / 0.08), int((a + 1) / 0.08)] tax010 = [int(b / 0.1), int((b + 1) / 0.1)] min_value = max(tax008[0], tax010[0]) max_value = min(tax008[1], tax010[1]) if min_value >= max_value: print(-1) else: print(min_value) " p02755,s510988197,Wrong Answer,"import numpy as np a, b = map(int, input().split()) a_low = int(a/0.08) a_up = int((a+0.9)/0.08) a_list = list(np.arange(a_low, a_up+1)) b_low = int(b/0.1) b_up = int((b+0.9)/0.1) b_list = list(np.arange(b_low, b_up+1)) #print(a_low) #print(a_list) #print(b_low) #print(b_list) if a_low in b_list: print(a_low) elif b_low in a_list: print(b_low) else: print('-1')" p02755,s198587518,Wrong Answer,"a,b=map(int,input().split()) c = a*100//8 d = (a+1)*100//8 e = b*100//10 f = (b+1)*100//10 for i in range(d-c): if c+i-1>=e and c+i-1 d or c < b : print(-1) else: for num1 in range (a+1, c-1): for num2 in range (b+1, d-1): if num1 == num2 : print(num1) break else: continue break " p02755,s691293961,Wrong Answer,"# -*- coding: utf-8 -*- import math a, b = map(int, input().split()) temp_a1 = 100 * a // 8 temp_a2 = 100 * (a + 1) // 8 temp_b1 = 10 * b // 10 temp_b2 = (10 * (b + 1)) - 1 result = -1 for i in range(int(temp_a1), int(temp_a2)): if temp_b1 <= i <= temp_b2: result = i break print(result) " p02755,s301292219,Wrong Answer,"A, B = map(int, input().split()) if 12.5* A < 10.0 * B: print(-1) else: print(int(12.5*A))" p02755,s153708793,Wrong Answer,"from math import floor A, B = map(int, input().split()) x1b = round(100 * A / 8) x2b = round(10 * B) x1t = floor(100 * (A + 0.99999) / 8) x2t = floor(10 * (B + 0.99999)) print('%d %d' % (x1b, x1t)) print('%d %d' % (x2b, x2t)) if (x2b <= x1t and x1b <= x2t) or (x1b <= x2t and x2b <= x1t): print(max(x1b, x2b)) else: print('-1')" p02755,s439105898,Wrong Answer,"i = list(map(int,input().split())) a = i[0]*100//8 b = i[1]*100//10 if -10 < a-b and a-b < 10: if a>b: print(a) else: print(b) else: print(-1) " p02755,s897513676,Wrong Answer,"A, B = map(int, input().split()) price_a = int(A / 0.08) price_b = int(B / 0.1) if price_a == price_b: print(price_a) exit() else: p1 = min(price_a, price_b) if int(p1 * 0.08) == int(p1 * 0.1): print(p1) exit() p2 = max(price_a, price_b) if int(p2 * 0.08) == int(p2 * 0.1): print(p2) exit() print(-1)" p02755,s199510637,Wrong Answer,"A, B = map(int, input().split(' ')) for i in range(1, 1500): if i * 8 // 100 == A and i * 10 // 100 == B: print(i) break" p02755,s386842697,Wrong Answer,"A,B = [int(i) for i in input().split()] x=A*12.5 y=B*10 if x>=y: print(int(max(x,y))) else: print(-1) " p02755,s647489177,Wrong Answer,"import sys a,b = map(lambda x: int(x),input().split()) a_tax_min = a* 12.5 b_tax_min = b * 10 a_tax_max = (a+1) * 12.5 b_tax_max = (b+1) * 10 if b_tax_min <= a_tax_min and a_tax_min <= b_tax_max and b_tax_max <= a_tax_max : if a_tax_min.is_integer() : print(int(a_tax_min)) else : print(int(a_tax_min) + 1) else : print(-1) " p02755,s746382266,Wrong Answer,"a,b=map(int,input().split()) tax8=a/2*25 tax8l=(a-1)/2*25 tax8h=(a+1)/2*25 tax10=float(b*10) tax10l=float((b-1)*10) tax10h=float((b+1)*10) if tax10>tax8l and tax10tax10l and tax8= SHITA_10: print(i) break i+=1" p02755,s799279225,Wrong Answer,"a,b=map(int,input().split()) x=12.5*a y=12.5*(a+1) z=10*b w=10*(b+1) import math if math.ceil(x) 0: print(min(ans)) else: print(-1) " p02755,s734317694,Wrong Answer,"# -*- coding: utf-8 -*- import math A, B = map(int, input().split()) for numA in range(0,101): A1 = math.floor(numA * 0.08) for numB in range(0,101): B1 = math.floor(numB * 0.1) if A == int(A1) and B == int(B1) and int(numA) == int(numB): print(numA) exit() print(-1) " p02755,s558981909,Wrong Answer,"a,b = map(int,input().split()) for i in range(1,101): va = int(i * 1.08) vb = int(i * 1.1) if(va == a and vb == b): print(i) exit() print(-1)" p02755,s491173947,Wrong Answer," a, b = map(int, input().split()) if(int(int(a / 0.08) * 0.1) == b): print(int(a / 0.08)) exit() print(-1)" p02755,s315437210,Wrong Answer,"flag =False A, B = [int(x) for x in input().split()] for x in range((A+1)*9,(B+1)*10+1): if A == x*8//100 and B == x//10: print(x) flag=True break if not flag: print(-1)" p02755,s278439366,Wrong Answer,"A,B = [int(i) for i in input().split()] for n in range(1,101): print(n) if int(n*0.08) == A and int(n*0.1) == B: print(n) exit() print(""-1"")" p02755,s954671764,Wrong Answer,"import math l1=input().split("" "") t80=int(l1[0]) t100=int(l1[1]) t80_min=(t80/0.08) t80_max=((t80+1)/0.08) t100_min=(t100/0.1) t100_max=((t100+1)/0.1) if t80_max= check_a-A: print(-1) exit() print(-1)" p02755,s195243511,Wrong Answer,"a,b = map(int,input().split()) ans = -1 for x in range(b*10,(b+1)*10): if x*0.08 == a: ans = x break print(ans) " p02755,s596734053,Wrong Answer,"import math a,b = [float(i) for i in input().split()] ans = 1000000000 flag = False for i in range(1,1000): ans8 = int(math.floor(i*0.08)) ans10 = int(math.floor(i*0.1)) # print(ans8,ans10) if ans8 == a and ans10 == b: ans = min(ans, i) # 更新する必要がある. flag = True if flag is True: print(ans) else: print(-1)" p02755,s441945592,Wrong Answer,"a, b = map(int, input().split()) for p in range(10*4): tax8 = p*0.08 tax10 = p*0.1 if int(tax8)==a and int(tax10)==b: print(p) exit() print(-1)" p02755,s851081915,Wrong Answer,"import math #Input A,B= map(int, input().split()) #Process Ans = -1 tmp08_min = math.ceil(A / 0.08) tmp08_max = tmp08_min + 12 tmp10_min = math.ceil(B / 0.10) tmp10_max = tmp10_min + 9 tmp_min = min(tmp08_min, tmp10_min) tmp_max = max(tmp08_max, tmp10_max) cnt = 0 while cnt < tmp_max - tmp_min: if(A == int((tmp_min + cnt) * 0.08) and B == int((tmp_min + cnt) * 0.10)): Ans = tmp10_min + cnt break cnt += 1 #Output print(Ans)" p02755,s968711045,Wrong Answer,"a,b=map(int,input().split()) if b * 10 <= ((a + 1) * 25) // 2 and -(-a * 25 // 2) <= (b + 1) * 10: print(max(-(-a*25//2), b * 10)) else: print(-1)" p02755,s868724350,Wrong Answer," A,B = list(map(int, input().split())) A *= 10 B *= 10 a = [c for c in range(A,A+10)] b = [c for c in range(B,B+10)] cnt_a = [] cnt_b = [] for i in range(10): cnt_a.append(int(a[i]/0.08)) cnt_b.append(int(b[i]/0.10)) ans = 10e7 is_true = False for i in cnt_a: for j in cnt_b: if i == j: ans = min(ans, j) is_true = True if is_true: print(ans//10) else: print(-1) " p02755,s745942627,Wrong Answer,"a, b = map(int, input().split()) ax = a / 0.08 bx = b / 0.10 if int(ax) != ax: print(-1) exit() if int(bx) != bx: print(-1) exit() print(min(int(ax), int(bx)))" p02755,s658014341,Wrong Answer,"A, B = map(int, input().split()) if 100*A%8 == 0: ans1 = int(A/0.08) else: ans1 = int(A/0.08) + 1 ans2_max = int(ans1 + ans1*0.1) ans2 = int(B/0.1) if ans2 <= ans2_max: print(ans1) else: print(-1)" p02755,s891083365,Wrong Answer,"def main(): a, b = map(int, input().split()) av = int(a / 0.08 + 0.05) bv = int(b / 0.1) lb = max(bv, av) ub = min(av+11, bv+9) if lb <= ub: print(lb) else: print(-1) if __name__ == '__main__': main() " p02755,s777970329,Wrong Answer,"a,b=map(int,input().split()) if b/0.1<=a/0.08 and a/0.08<(b+1)/0.1: print(int(a/0.08)) else: print(-1)" p02755,s841855104,Wrong Answer,"a,b = map(int,input().split()) f = int(a/0.08) if f==b//0.1: print(f) exit() for i in range(10): k = i*0.1 if int(f*k)==b: print(f) exit() print(-1)" p02755,s460898080,Wrong Answer,"a, b = map(int, input().split()) pa = 0 - -a//0.08 pb = b/0.1 ta = pa//12.5 tb = pb//10 if ta == a and tb == b: print(int(pa)) else: print(-1)" p02755,s695669560,Wrong Answer,"def main(A, B): flag = '-1' for N in range(1, 10000): if int(N * 0.08) == A and int(N * 0.1) == B: flag = N print(flag) break print(flag) A, B = map(int, input().split("" "")) main(A, B)" p02755,s278445541,Wrong Answer,"a,b=map(int,input().split()) if 10*b<12.5*a<10*(b+1): print(int(12.5*a)) elif 12.5*a<=10*b<12.5*(a+1): print(int(10*b)) else: print(-1)" p02755,s247704720,Wrong Answer,"A, B = list(map(int, input().split())) for x in range(1000): if (x * 8) // 100 == A and x // 10 == B: print(x) break else: print(-1) " p02755,s329025277,Wrong Answer,"#C import sys a,b=map(int,input().split()) for i in range(1,1000): if int(i*0.08)==a and int(i*0.1)==b: ans=i break if i==999: ans=-1 print(ans) " p02755,s167283951,Wrong Answer,"# problem C A,B = map(int,input().split()) ans = [] for i in range(1,1000): x = int(i * 0.08) y = int(i * 0.10) if x == A and y == B: ans.append(i) else: pass if len(ans) == 0: print(-1) else: print(ans[0])" p02755,s637060548,Wrong Answer,"import math a, b = list(map(int, input().split())) c = max((a/0.08),(b/0.1)) if math.floor(c*0.1) - math.floor(c*0.08) < abs(a-b): print('-1') else: print(c)" p02755,s883390325,Wrong Answer,"N = list(map(int, input().split())) X = [i for i in range(int(N[0]*(1/0.08)), int((N[0]+1)*(1/0.08)))] Y = [i for i in range(int(N[1]*(1/0.10)), int((N[1]+1)*(1/0.10)))] #print(X, Y) cand = set(X) & set(Y) if len(cand) == 0: print(-1) else: print(min(cand)) " p02755,s141145380,Wrong Answer,"import math a,b = map(int,input().split()) val1 = math.floor(a / 0.08) val2 = math.floor(b / 0.1) ans = [] for i in range(0, 101): if math.floor(i * 0.08) == a and math.floor(i * 0.1) == b: ans.append(i) if ans: print(min(ans)) else: print(-1)" p02755,s361226862,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)+1): if int(i*8/100)==A and int(i*0.1)==B: ans.append(i) break else: ans.append(-1) print(min(ans))" p02755,s326190264,Wrong Answer,"import math A, B = map(int, input().split()) Xa_max = (A + 0.99999999999) / 0.08 Xa_min = (A) / 0.08 Xb_max = (B + 0.99999999999) / 0.1 Xb_min = (B) / 0.1 # 範囲が被らない場合 if Xa_min > Xb_max or Xb_min > Xa_max: print(-1) exit() print(math.floor(max(Xa_min, Xb_min)))" p02755,s439869514,Wrong Answer,"a, b = map(int, input().split()) ta = a / 0.08 tb = b / 0.10 if (int(ta * 0.1) == b): print(round(ta)) elif (int(tb * 0.08) == a): print(round(tb)) else: print(-1) " p02755,s233984332,Wrong Answer,"a,b = map(int,input().split()) at = -(-a//0.08) aat= -((-a-1)//0.08) bt = -(-b//0.1) bbt= -(-(b+1)//0.1) if bbt < at or bt > aat: print(-1) else: print(int(min(at,bbt)))" p02755,s620798327,Wrong Answer,"import math import sys a, b = map(int, input().split()) if b - a > 0.02 * max(math.ceil(a * 12.5), b * 10): print(-1) sys.exit() print(max(math.ceil(a * 12.5), b * 10))" p02755,s078188861,Wrong Answer,"import math A, B = list(map(int, input().split())) a_min = math.floor(A * 100 / 8) a_max = math.ceil((A + 1) * 100 / 8) b_min = math.floor(B * 100 / 10) b_max = math.ceil((B + 1) * 100 / 10) if a_max < b_min: print(-1) elif a_min <= b_min and b_min <= a_max: print(b_min) elif b_min <= a_min and a_min <= b_max: print(a_min) else: print(-1)" p02755,s458787451,Wrong Answer,"# C A, B = map(int, input().split()) X1 = (B/0.10) X2 = ((B+1)/0.10) X3 = (A/0.08) X4 = ((A+1)/0.08) # print(X1, X2, X3, X4) if X3<=X1 and X1 < X4 and X4 <= X2: print(int(X1)) elif X3<=X1 and X1 <= X2 and X2 <= X4: print(int(X1)) elif X1<=X3 and X3 <= X4 and X4 <= X2: print(int(X3)) elif X1<=X3 and X3 <= X2 and X2 <= X4: print(int(X3)) else: print(-1)" p02755,s825061880,Wrong Answer,"import math a,b=map(int,input().split()) A=[] B=[] for i in range(9): A.append(a+i/10) B.append(b+i/10) for i in range(len(A)): A[i]=A[i]/0.08 B[i]=B[i]/0.1 ans=[] for i in range(len(A)): for j in range(len(A)): if round(A[i],2)==round(B[j],2): ans.append(A[i]) break A.sort() if ans==[]: print(-1) else: print(int(ans[0]))" p02755,s552498918,Wrong Answer,"A, B = map(int, input().split()) x = max(A*100//8, B*100//10) y = min((A+1)*100//8, (B+1)*100//10) if x <= y: ans = x else: ans = -1 print(ans)" p02755,s380767739,Wrong Answer,"N, A = map(int, input().split()) eight = 0 ten = 0 answer = -1 for i in range (1,1000,1): eight = i * 0.08 eight = eight//1 ten = i* 0.1 ten = ten//1 if eight == N and ten == A: answer = i break print(answer)" p02755,s018455200,Wrong Answer,"import math A, B = list(map(int, input().split())) A_min = math.floor(A * 25 / 2) A_max = math.floor((A + 1) * 25 / 2) B_min = math.floor(B * 10) B_max = math.floor((B + 1) * 10) # print(B_min, B_max) A_list = list(range(A_min, A_max + 1)) B_list = list(range(B_min, B_max)) # print(A_list) # print(B_list) min_ans = -1 for num in A_list: if num in B_list: min_ans = num break else: continue print(min_ans) " p02755,s059596321,Wrong Answer,"A, B = map(int,input().split()) a = 0 x = 1 while a == 0: if int(x * 0.08) == A: if int(x * 0.1) == B: a = 1 print(x) exit() else: x += 1 else: x += 1 if x > B / 0.09: print(-1) a = 1" p02755,s254289347,Wrong Answer,"A, B = map(int, input().rstrip().split()) ret = 1000000 for i in range(1, 101): if int(i * 0.08) == A and int(i*0.1) == B and ret > i: ret = i if ret == 1000000: ret = -1 print(ret) " p02755,s259870352,Wrong Answer,"A, B = list(map(int,input().split())) for i in range(1,101): a = int(i * 0.08) if(a == A): b = int(i * 0.1) if(b == B): print(i) exit() print('-1') " p02755,s980015514,Wrong Answer,"import math A,B = map(int,input().split()) ARangemin = math.ceil(A * (100/8)) BRangemin = math.ceil(B * (100/10)) ARangemax = ARangemin BRangemax = BRangemin while int(ARangemax * 0.08) == A: ARangemax = ARangemax + 1 while int(BRangemax* 0.08) == B: BRangemax = BRangemax + 1 ARangemax = ARangemax -1 BRangemax = BRangemax -1 if ARangemax > BRangemin or ARangemin > BRangemax: if ARangemin < BRangemin: print(ARangemin) else: print(BRangemin) else: print(-1) " p02755,s017686077,Wrong Answer,"import math a, b = map(int, input().split()) a_p = math.ceil(a / 0.08) a_q = math.floor((a+1) / 0.08) b_p = math.ceil(b / 0.1) b_q = math.floor((b+1) / 0.1) if a_p <= b_p <= a_q: ans = b_p elif a_q < b_p: ans = -1 elif b_q < a_p: ans = -1 else: ans = a_p print(ans)" p02755,s780671751,Wrong Answer,"a, b = map(int, input().split()) A = (a + 1) / 0.08 B = (b + 1) / 0.1 s = -(-a // 0.08) t = -(-b // 0.1) n = ((a + 1) // 0.08) - s re = 0 for i in range(int(n)): if t <= s + i < B: re = s + i break if re != 0: print(re) else: print(-1) " p02755,s089938679,Wrong Answer,"import math A,B=map(int,input().split()) cost_A=A/0.08 cost_B=B*10 if cost_A<=cost_B and cost_B < cost_A+1: ans=cost_B elif cost_B<=cost_A and cost_B bb: if B == int(aa * 0.1): print(aa) else: print('-1') else: if A == int(bb*0.08): print(bb) else: print('-1') " p02755,s990638559,Wrong Answer,"a, b = map(int, input().split()) for n in range(0, 10000): a2 = int(n * 8 / 100) b2 = int(n * 8 / 100) if a2 == a and b2 == b: print(n) exit() else: print(-1)" p02755,s478228154,Wrong Answer,"A,B = map(int, input().split()) a = (A/8)*100 b = B*10 if b - a <= 0.5 and b - a >= 0: print(int(a)) else: print(-1)" p02755,s174087393,Wrong Answer,"a,b = map(int,input().split()) na = int(a/0.08) nb = int(b/0.10) aa = int(nb * 0.08) bb = int(na *0.1) if a == aa: print(str(nb)) elif b == bb: print(str(na)) else: print('-1')" p02755,s337016171,Wrong Answer,"A, B = map(int, input().split()) if B*10 >= (A+1)/0.08: print(-1) exit() s = int(A/0.08) for n in range(100): if int((s+n)*0.1) == B: print(s+n) exit()" p02755,s000308644,Wrong Answer,"a,b=map(int,input().split()) #print(a/0.08,(a+1)/0.08) #print(b/0.1,(b+1)/0.1) x=max(a/0.08,b/0.1) y=min((a+1)/0.08,(b+1)/0.1) if x= b: ans = a print(int(ans)) if __name__ == ""__main__"": main() " p02755,s416324352,Wrong Answer,"import math A, B = map(int,input().split()) pricemax_A = math.floor((A+1)/0.08) pricemin_A = math.floor(A/0.08) pricemax_B = math.floor((B+1)/0.1) pricemin_B = math.floor(B/0.1) if A > B: print(-1) elif pricemin_A >= pricemin_B and pricemin_A < pricemax_B: print(pricemin_A) elif pricemin_A <= pricemin_B and pricemax_A > pricemin_B: print(pricemin_B) else: print(-1) " p02755,s494182231,Wrong Answer,"# -*- coding: utf-8 -*- # スペース区切りの文字列の入力 st = input().split() #切り捨て a = int(int(st[0]) / 0.08) if(int(a * 0.1) == int(st[1])): print(a) else: print('-1')" p02755,s832969951,Wrong Answer,"import sys import math A, B = map(int, input().split()) c_A = math.floor(A/0.08) c_B = math.floor(B/0.10) #print(c_A, c_B) if c_A == A and c_B == B: print(c_A) sys.exit() mymin = min(c_A, c_B) mymax = max(c_A, c_B) for i in range(mymin, mymax+1): #print(i, math.floor(i*0.08),math.floor(i*0.10)) if math.floor(i*0.08) == A and math.floor(i*0.10) == B: print(i) sys.exit() print(-1) " p02755,s556877141,Wrong Answer,"a = input().split("" "") t8 = int(a[0]) t10 = int(a[1]) b = t8 / 0.08 for i in range(12): if int(b * 0.1) == t10: print(int(b)) break else: b += 1 if i == 11: print(-1)" p02755,s655509038,Wrong Answer,"import math A,B = map(int, input().split()) if A/(8/100) > (B+1)/(10/100) or (A+1)/(8/100) < (B)/(10/100): print('-1') elif A/(8/100) <= (B+1)/(10/100): print(math.floor(A/(8/100))) elif (A+1)/(8/100) >= (B)/(10/100): print(math.floor((B)/(10/100))) else: print('-1')" p02755,s056670451,Wrong Answer,"A,B = map(int, input().split()) for i in range(0, 10): test_A = A + (i/10) if test_A *100 % 8 == 0: x = test_A *100 // 8 break if (x//10) == B: print(x) else: print(-1)" p02755,s627549059,Wrong Answer,"import sys f = sys.stdin.readline() xx = f.split(' ') x = [int(str) for str in xx] a = x[0] aa = a+1 b = x[1] bb = b+1 x = int(a / 0.08) xx = int(aa / 0.08) y = int(b / 0.1) yy = int(bb / 0.1) if ( x > y ): min = x if( min > yy): print ""-1"" else: print min else: min = y if( min > xx): print ""-1"" else: print min sys.stdout.flush() " p02755,s921524593,Wrong Answer,"A, B = map(int, input().split()) Amin = int(A/0.08) Amax = int((A+1)/0.08)+1 Arange = set(range(Amin, Amax)) Bmin = int(B/0.1) Bmax = int((B+1)/0.1)+1 Brange = set(range(Bmin, Bmax)) intersection = Arange & Brange if len(intersection) > 0: print(min(intersection)) else: print(""-1"")" p02755,s086109777,Wrong Answer,"A, B = map(int, input().split()) T8_1 = A / 0.08 T8_2 = (A+1) / 0.08 - 0.001 T10_1 = B / 0.10 T10_2 = (B+1) / 0.10 - 0.001 import math T8 = list(range(math.floor(T8_1), math.floor(T8_2)+1)) T10 = list(range(math.floor(T10_1), math.floor(T10_2)+1)) S_list = list(set(T8) & set(T10)) if not S_list: print('-1') else: print(S_list[0])" p02755,s962744509,Wrong Answer,"A,B = map(int,input().split()) flag = 0 for i in range(1000): 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)" p02755,s762591820,Wrong Answer,"A, B = map(int,input().split()) A_hi = ((A+1)/0.08) A_low = (A/0.08) B_hi = ((B+1)/0.1) B_low = (B/0.1) if (B_hi < A_low or A_hi < B_low) or (A_low > 100) or (B_low > 100): print(-1) elif A_low < B_hi: print(round(A_low)) elif B_low < A_hi: print(round(B_low))" p02755,s807878105,Wrong Answer,"A,B = [int(i) for i in input().rstrip().split()] Aa = A/0.08 Ba = B/0.1 round=lambda x:int((x*2+1)//2) N = round(max(Aa,Ba)) def ch(n): global A,B print(int(n * 0.08), A, int(n * 0.1), B) if int(n * 0.08) == A and int(n * 0.1) == B: return True else: return False if ch(N-1): print(N-1) elif ch(N): print(N) else: print(-1)" p02755,s760160629,Wrong Answer,"a, b = map(int , input().split()) answer = -1 for i in range(1,101): if int(i*0.08) == a and int(i*0.1) == b: answer = i break print(answer)" p02755,s968670139,Wrong Answer,"def main(): a, b = [int(i) for i in input().split()] lo = int(max(a * 100 / 8, b * 10)) hi = int(min((a + 1) * 100 / 8, (b + 1) * 10)) if lo <= hi: print(lo) else: print(-1) main() " p02755,s130047673,Wrong Answer,"a,b = map(int, input().split()) for i in range(1, 1001): if int(i**0.08)==a and int(i*0.1)==b: print(i) exit() print(-1)" p02755,s093610913,Wrong Answer,"import math A, B = map(int, input().split()) withOutA = round(A / 0.08) withOutB = round(B / 0.10) if math.floor(withOutA * 0.08) == A and math.floor(withOutA * 0.10) == B: print(int(withOutA)) elif math.floor(withOutB * 0.08) == A and math.floor(withOutB * 0.10) == B: print(int(withOutB)) else: print(-1) " p02755,s261029395,Wrong Answer,"A,B = map(int,input().split()) a = A/0.08 b = B/0.1 a2 = (A+1)//0.08 b2 = (B+1)//0.1 ans = max(a,b) if a > b: if a > b2: ans = -1 else: if b > a2: ans = -1 print(int(ans))" p02755,s323933430,Wrong Answer,"a, b = map(int,input().split()) e = 10**-7 mi = max(int((a+e)/0.08),int((b+e)/0.1)) ma = min(int((a+1+e)/0.08),int((b+e+1)/0.1)) if mi > ma: print(-1) else: print(mi) " p02755,s313932874,Wrong Answer,"import math A,B=map(int,input().split()) flag=True for i in range(1, 101): if(math.floor(i*0.08) == A and math.floor(i*0.10) == B and flag == True): print(i) flag=False if(flag==True): print(-1)" p02755,s646195181,Wrong Answer,"# -*- coding: utf-8 -*- # スペース区切りの整数の入力 A, B = map(int, input().split()) x_list=[] for num in range(5000): if int(num*0.08)==A: x_list.append(num) y_list=[] for num in range(2000): if int(num*0.1)==B: y_list.append(num) l1_l2_and = list(set(x_list)&set(y_list)) if l1_l2_and==[]: print(-1) elif l1_l2_and[0]>0: print(l1_l2_and[0]) else: print(-1) " p02755,s734743661,Wrong Answer,"a,b=map(int,input().split()) z,x,c,v=10*b,10*b+10-1,50*a//4,50*(a+1)//4-1 if xX2)or(X1>Y2): print(-1) elif X1>=Y1: print(X1) else: print(Y1) " p02755,s209882978,Wrong Answer,"a, b = map(int, input().split()) for i in range(int(a / 0.08), int(a / 0.07)): if int(i * 0.1) == b: print(i) break else: print(-1)" p02755,s662832884,Wrong Answer,"a,b = map(float,input().split()) x = a/0.08 y = b/0.10 print(x,y) print(int(x*0.10),int(x*0.08)) if int(x * 0.1) == b and int(x * 0.08) == a or int(y * 0.08) == a and int(y * 0.10) == b: if y * 0.08 == a: print(int(y)) else: print(int(x)) else: print(""-1"") " p02802,s208954500,Accepted,"import numpy as np n, m = map(int,input().split()) questions = [0 for i in range(n)] clear = [0 for i in range(n)] for i in range(m): p,s = input().split() p = int(p) if s == 'WA': if clear[p-1] == 0: questions[p-1] += 1 else: clear[p-1] = 1 questions = np.array(questions) print(sum(clear), questions[np.where(np.array(clear) == 1)[0]].sum()) " p02802,s462316223,Accepted,"import math def makelist(n, m): return [[0 for _ in range(m)] for _ in range(n)] # n = int(input()) # a, b # s = input() N, M = list(map(int, input().split())) ac = 0 wa = 0 memo = [0]*(N+1) for _ in range(M): p, S = input().split() p = int(p) if S == ""AC"": if memo[p] != -1: ac += 1 wa += memo[p] memo[p] = -1 else: if memo[p] != -1: memo[p] += 1 print(ac, wa) " p02802,s094104990,Accepted,"N, M = list(map(int, input().split())) correct = 0 incorrect = 0 Q = [0] * N num_WA = [0] * N for i in range(M): s, t = input().split() s = int(s) if t == 'AC': if Q[s-1] == 1: continue else: Q[s-1] = 1 correct += 1 incorrect += num_WA[s-1] else: num_WA[s-1] += 1 print(correct, incorrect) " p02802,s746841275,Accepted,"N, M = map(int,input().split()) WA = [0] * N AC = [0] * N ac = 0 wa = 0 for i in range(M): pi, S = map(str,input().split()) p = int(pi) if S == ""AC"": if AC[p-1] != 1: AC[p-1] = 1 ac += 1 wa += WA[p-1] elif S == ""WA"": if AC[p-1] == 1: pass else: WA[p-1] += 1 else: print(ac, wa)" p02802,s131928964,Accepted,"N,M = [int(i) for i in input().split()] submissions = {str(i):[] for i in range(1,N+1)} AC,WA = 0,0 for i in range(M): P,S = [j for j in input().split()] submissions[P].append(S) for i in submissions: if 'AC' not in submissions[i]: continue for j in submissions[i]: if j == 'AC': AC+=1 break WA +=1 print(AC,WA)" p02802,s376032409,Accepted,"N, M = map(int, input().split()) ac = 0 wa = 0 arr = [0] * N if M == 0: print(""0 0"") exit() for i in range(M): p, s = list(input().split()) p = int(p) if arr[p-1] != ""AC"": if s == ""AC"": wa += arr[p-1] arr[p-1] = ""AC"" ac += 1 else: arr[p-1] += 1 print(ac, wa) " p02802,s141433752,Accepted,"n,m = map(int,input().split()) ac = [0]*n wa = [0]*n count_ac = 0 count_wa = 0 for i in range(m): p,s = input().split() p = int(p) if ac[p-1]: continue if s == ""WA"": wa[p-1] += 1 else: ac[p-1] = True count_ac += 1 count_wa += wa[p-1] print(count_ac,count_wa)" p02802,s298794707,Accepted,"n, m = map(int, input().split()) wa = [0]*n ac = [0]*n for i in range(m): p, s = input().split() p = int(p) - 1 if s == 'AC' and ac[p] == 0: ac[p] = 1 elif s =='WA' and ac[p] == 0: wa[p] += 1 for j in range(n): if ac[j] == 0: wa[j] = 0 print(sum(ac), sum(wa)) " p02802,s684652934,Accepted,"# coding: utf-8 N, M = map(int, input().split()) AC, WA = [], [] AC = [False for _ in range(10**5)] WA = [0 for _ in range(10**5)] ac, wa = 0, 0 for i in range(M): tmp = input().split() p = int(tmp[0]) - 1 s = tmp[1] if AC[p]: continue else: if s == ""AC"": AC[p] = True else: WA[p] += 1 for i in range(N): if AC[i]: ac += 1 wa += WA[i] print(ac, wa)" p02802,s944599504,Accepted,"N,M = map(int,input().split()) p_list=[""WA""]*N count = [0]*2 wa_count= [0]*N for i in range(M): p,s = input().split() p = int(p) if(p_list[p-1]==""WA"" and s==""WA""): wa_count[p-1]+=1 elif(p_list[p-1]==""WA"" and s==""AC""): p_list[p-1]=s count[0]+=1 count[1]+=wa_count[p-1] print(' '.join(list(map(str,count))))" p02802,s655311881,Accepted,"N,M=map(int,input().split()) seiseki=[[0]*N for _ in range(2)] for i in range(M): p,S=input().split() p=int(p) if seiseki[1][p-1]==0: if S=='WA': seiseki[0][p-1]+=1 else: seiseki[1][p-1]=1 AC=sum(seiseki[1]) WA=0 for i in range(N): if seiseki[1][i]==1: WA+=seiseki[0][i] print(AC,WA)" p02802,s567574102,Accepted,"n, m = map(int,input().split()) a = list(input().split() for i in range(m)) wa = [0]*n ac = [0]*n for b in a: p = int(b[0]) - 1 if ac[p] == 1: next else: if b[1] == 'AC': ac[p] = 1 else: wa[p] += 1 wa = [ac[i]*wa[i] for i in range(n)] print('{} {}'.format(sum(ac),sum(wa)))" p02802,s416925555,Accepted,"import sys input = sys.stdin.readline n, m = map(int, input().split(' ')) WAs = [0] * n correct = 0 penalty = 0 for i in range(m): p, s = input().strip().split(' ') p = int(p) - 1 if WAs[p] == -1: continue if s == 'AC': penalty += WAs[p] correct += 1 WAs[p] = -1 else: WAs[p] += 1 print(correct, penalty) " p02802,s518724194,Accepted,"import numpy as np N, M =[int(i) for i in input().split()] isfinish=[0]*N isfail=[0]*N for i in range(M): p, S = input().split() p=int(p) if isfinish[p-1]==1: continue elif S==""AC"" and isfinish[p-1]==0: isfinish[p-1] = 1 elif S==""WA"" and isfinish[p-1]==0: isfail[p-1] +=1 isfinish=np.array(isfinish) isfail=np.array(isfail) print(str(sum(isfinish)) + "" ""+ str(sum(isfail[isfinish==1]))) " p02802,s209235698,Accepted,"n,m=map(int,input().split()) ac=[0]*n pn=[0]*n for i in range(m): ps=input().split() p=int(ps[0])-1 s=ps[1] if ac[p]: continue if s=='AC': ac[p]=1 else: pn[p]+=1 acs=sum(ac) pns=sum([x for i,x in enumerate(pn) if ac[i]]) print(acs, pns)" p02802,s006344345,Accepted,"n , m = input().split() n , m = int(n) , int(m) a = [0 for i in range (n)] ans = 0 pnl = 0 ha = {} for i in range (m) : p , s = input().split() p = int(p) - 1 if s == 'WA' : a[p] += 1 elif str(p) not in ha.keys() : ans += 1 pnl += a[p] ha[str(p)] = '1' print( str(ans) + ' ' + str(pnl))" p02802,s346344170,Accepted,"import numpy as np N, M = map(int, input().split()) AC = np.zeros(N, dtype = int) WA = np.zeros(N, dtype = int) for i in range(M): p, s = input().split() if s == 'WA' and AC[int(p) - 1] == 0: WA[int(p) - 1] += 1 else: AC[int(p) - 1] = 1 print(sum(AC), sum(AC * WA)) " p02802,s393450130,Accepted,"n,m = map(int,input().split()) ps = [0] * m for i in range(m): ps[i] = list(map(str,input().split())) if m == 0: print(0,0) exit() countA = [0] * n countW = [0] * n cn = 0 for item in ps: if item[1] == 'AC' and countA[int(item[0])-1] == 0: countA[int(item[0])-1] = 1 cn += countW[int(item[0])-1] else: countW[int(item[0])-1] += 1 print(sum(countA),cn)" p02802,s347679205,Accepted,"N,M = map(int,input().split()) AC = set() WA = [0]*N for i in range(M): k,l = input().split() k = int(k) if l==""WA"": if not k in AC: WA[k-1] += 1 else: if not k in AC: AC.add(k) counter = 0 for i in AC: counter += WA[i-1] print(""{} {}"".format(len(AC),counter))" p02802,s424173597,Accepted,"n, m = map(int,input().split()) ps = list(list(map(str,input().split())) for _ in range(m)) check = [True] * (n+1) wa = [0] * (n+1) wa_ans = 0 for i in range(m): if ps[i][1] == 'AC' and check[int(ps[i][0])]: check[int(ps[i][0])] = False wa_ans += wa[int(ps[i][0])] if ps[i][1] == 'WA': wa[int(ps[i][0])] += 1 ans = 0 for i in check: if not i: ans += 1 print(ans,wa_ans)" 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) " 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) " p02802,s653462916,Accepted,"import numpy as np N,M=map(int,input().split()) A=[] for i in range(M): A.append(tuple(map(str,input().split()))) check=np.zeros((N,2)) for i in range(M): if check[int(A[i][0])-1,0]==0: if A[i][1]=='WA': check[int(A[i][0])-1,1]+=1 elif A[i][1]=='AC': check[int(A[i][0])-1,0]+=1 for i in range(N): if check[i,0]==0: check[i,1]=0 sum=check.sum(axis=0) print(int(sum[0]),int(sum[1]))" p02802,s799058033,Accepted,"n, m = map(int, input().split()) a = [input().split() for i in range(m)] solved = [False] * n ac_cnt = 0 wa_l = [0] * n for i in range(m): cn, cj = int(a[i][0]) - 1, a[i][1] if not solved[cn]: if cj == 'WA': wa_l[cn] += 1 else: ac_cnt += 1 solved[cn] = True wa_cnt = 0 for i in range(n): wa_cnt += solved[i] * wa_l[i] print(ac_cnt, wa_cnt) " p02802,s662100090,Accepted,"n, m = map(int, input().split()) PS = {} for _ in range(m): p, s = input().split() try: PS[int(p)].append(s) except KeyError: PS[int(p)] = [s] a, b = 0, 0 for S in PS.values(): if ""AC"" in S: for s in S: if s == ""AC"": a += 1 break if s == ""WA"": b += 1 print(a, b)" p02802,s839312040,Accepted,"n,m = map(int, input().split()) p = [0]*n q = [False]*n for _ in range(m): v,s = input().split() v = int(v)-1 if q[v]: continue if s == 'AC': q[v] = True else: p[v] += 1 print(sum(q),sum(p[i] for i in range(n) if q[i]))" p02802,s667883239,Accepted,"from collections import defaultdict memo = dict() n,m = list(map(int, input().split())) for i in range(m): p, s = input().split() if p not in memo: memo[p] = [0, False] if memo[p][1]: continue v = memo[p] if s == 'AC': memo[p] = [v[0], True] else: memo[p] = [v[0]+1, False] ac, wa = 0, 0 for _,v in memo.items(): w, a = v if a: ac += 1 wa += w print(ac, wa)" p02802,s049970638,Accepted,"N,M=map(int,input().split()) P=[input().split() for i in range(M)] WA=[] AC=[] for i in range(N): WA.append(0) AC.append(0) for i in range(M): if P[i][1]==""WA"" and AC[int(P[i][0])-1]==0: WA[int(P[i][0])-1]+=1 elif P[i][1]==""AC"": AC[int(P[i][0])-1]=1 for i in range(N): if AC[i]==0: WA[i]=0 print(sum(AC),sum(WA))" p02802,s557279530,Accepted,"n,m = map(int,input().split()) a = [[0,0] for _ in range(n)] pn = 0 ac = 0 for i in range(m): p, s = input().split() if s == ""AC"": if a[int(p)-1][1] == 0: a[int(p)-1][1] = 1 pn += a[int(p)-1][0] ac += 1 else: a[int(p)-1][0] += 1 print(ac, pn)" p02802,s036314367,Accepted,"import sys n, m = map(int, sys.stdin.readline().split()) a=[sys.stdin.readline().split() for i in range(m)] wa = [0 for i in range(n)] ac = [0 for i in range(n)] for i in range(m): p = int(a[i][0])-1 s = a[i][1] if s==""WA"" and ac[p]==0: wa[p] +=1 #print(wa, 'wa') elif s==""AC"": ac[p] = 1 #print(ac, 'ac') cnt=0 for i in range(n): if ac[i]==1: cnt += wa[i] print(sum(ac), cnt)" p02802,s143532952,Accepted,"from collections import defaultdict n,m=map(int,input().split()) p,s=[],[] for i in range(m): P,S=input().split() p.append(int(P)) s.append(S) pena=0 cnt_ac=defaultdict(lambda :0) cnt_wa=defaultdict(lambda :0) for x,y in zip(p,s): if cnt_ac[x]==0: if y=='AC': cnt_ac[x]=1 pena+=cnt_wa[x] elif y=='WA': cnt_wa[x]+=1 print(sum(cnt_ac.values()),pena) " p02802,s190400763,Accepted,"N,M=map(int, input().split()) ansY = [0]*N ansWA = [0]*N for i in range(M): id,ans = input().split() idr = int(id)-1 if ans=='AC': ansY[idr]=1 elif ans=='WA' and ansY[idr]==0: ansWA[idr]+=1 WA = sum([x * y for (x, y) in zip(ansY, ansWA)]) print(sum(ansY),WA)" p02802,s649425048,Accepted,"N,M = map(int, input().split()) s,p = [False]*N, [0]*N for i in range(M): tmp = input().split() pi,Si = int(tmp[0])-1, tmp[1] s[pi] |= Si == ""AC"" p[pi] += 1 if not s[pi] else 0 print(sum(s), sum([pi for si,pi in zip(s,p) if si])) " p02802,s206131048,Accepted,"# 2020/01/12 n,m=map(int,input().split()) ps=[0]*(n+1) ac=0 wa=0 for i in range(m): p,s=input().split() p=int(p) if ps[p]>0:continue if s=='WA': ps[p]-=1 else: wa+=-ps[p] ps[p]=1 ac+=1 print(*[ac,wa])" p02802,s215141613,Accepted,"N, M = map(int, input().split()) ac = 0 wa = dict() done = dict() for i in range(M): p, S = input().split() if p in done: continue if S == ""AC"": ac+= 1 done[p] = True else: if p not in wa: wa[p] = 0 wa[p] += 1 _wa = 0 for x in wa: if x in done: _wa += wa[x] print(ac, _wa)" p02802,s493274058,Accepted,"N, M = map(int, input().split()) questions = {i:[False, 0] for i in range(1, N + 1)} count_AC = 0 count_WA = 0 for _ in range(M): p, S = input().split() if not questions[int(p)][0]: if S == ""WA"": questions[int(p)][1] += 1 elif S == ""AC"": questions[int(p)][0] = True for v in questions.values(): if v[0]: count_AC += 1 count_WA += v[1] print(count_AC, count_WA)" p02802,s820033903,Accepted,"n, m = map(int, input().split()) a = set([]) n = [0] * 10 ** 5 ac, wa = 0, 0 for i in range(m): p, s = input().split() p = int(p) if p not in a: if s == ""WA"": n[p] += 1 else: a.add(p) ac += 1 wa += n[p] print(ac, wa)" p02802,s566724674,Accepted,"import sys input = sys.stdin.readline import itertools N,M = map(int,input().split()) a=[tuple(map(str,input().split())) for _ in range(M)] ac = [0]*N wa = [0]*N for i in range(M): q = int(a[i][0])-1 res = a[i][1] if res == 'AC': ac[q] = 1 else: if ac[q] == 0: wa[q] += 1 wa2=0 for i in range(N): if ac[i]==1: wa2 += wa[i] print(""{} {}"".format(sum(ac),wa2)) " p02802,s008399614,Accepted,"import sys input = sys.stdin.readline n, m = map(int, input().split()) p_s = [list(map(str, input().split())) for _ in range(m)] ac = [0 for _ in range(n)] wa = [0 for _ in range(n)] for i in range(m): if p_s[i][1] == 'WA': if ac[int(p_s[i][0]) - 1] == 0: wa[int(p_s[i][0]) - 1] += 1 else: ac[int(p_s[i][0]) - 1] = 1 for i in range(n): if ac[i] == 0: wa[i]=0 print(sum(ac), sum(wa)) " p02802,s329834858,Accepted,"#!/usr/bin/env python # -*- coding: utf-8 -*- def main(): N, M = map(int, input().split()) acs = [0] * N was = [0] * N for _ in range(M): p, s = input().split() p = int(p) - 1 if s == 'AC': acs[p] = 1 elif acs[p] == 0: was[p] += 1 s = 0 p = 0 for a, w in zip(acs, was): if a == 0: continue s += 1 p += w print(s, p) if __name__ == '__main__': main() " p02802,s078945916,Accepted,"n,m = map(int, input().split()) lst = [[] for i in range(m)] for i in range(m): pi,si = map(str, input().split()) lst[i] = (int(pi),si) ac = 0 wa = 0 status = [0 for i in range(n)] for i in lst: if status[i[0]-1]!=""AC"" and i[1]==""AC"": ac += 1 wa += status[i[0]-1] status[i[0]-1] = ""AC"" elif status[i[0]-1]!=""AC"" and i[1]==""WA"": status[i[0]-1] += 1 print(ac,wa) " p02802,s675438936,Accepted,"N,M=map(int,input().split()) A=0 PE=0 PRO=[[] for i in range(N)] for i in range(M): P,S=input().split() P=int(P)-1 PRO[P].append(S) #print(PRO) for i in range(N): tmp=0 for j in range(len(PRO[i])): flag=False if PRO[i][j]=='AC': A+=1 flag=True if PRO[i][j]=='WA': tmp+=1 if flag: PE+=tmp break print(A,PE)" p02802,s027720753,Accepted,"n,m=input().split() n=int(n) m=int(m) f=[0]*n wa=[0]*n ac=0 for i in range(m): p,s=input().split() p=int(p)-1 if f[p]==1: continue if s==""WA"": wa[p]+=1 else: ac+=1 f[p]=1 x=0 for i in range(n): if f[i]==1: x+=wa[i] print(ac,x)" p02802,s495412076,Accepted,"n, m = map(int, input().split()) p = [0] * m s = [0] * m for i in range(m): p[i], s[i] = input().split() p[i] = int(p[i]) c = [0] * (n + 1) w = [0] * (n + 1) for i in range(m): if c[p[i]] == 0 and s[i] == 'AC': c[p[i]] = 1 elif c[p[i]] == 0 and s[i] == 'WA': w[p[i]] = w[p[i]] + 1 for i in range(1, n+1): if c[i] == 0: w[i] = 0 print(sum(c), sum(w))" p02802,s350644133,Accepted,"n,m=map(int,input().split()) ac=[0]*n wa=[0]*n for i in range(m): p,s=map(str,input().split()) if ac[int(p)-1]==0: if s==""AC"": ac[int(p)-1]=ac[int(p)-1]+1 else: wa[int(p)-1]=wa[int(p)-1]+1 for i in range(n): if ac[i]==0: wa[i]=0 print(sum(ac),sum(wa))" p02802,s864672044,Accepted,"n,m = map(int, input().split()) p = [0] * m s = [0] * m for i in range(m): p[i],s[i] = map(str,input().split()) lisa = [0] * n lisw = [0] * n for i in range(m): if lisa[int(p[i])-1] == 0: if s[i] == 'WA': lisw[int(p[i]) - 1] += 1 else: lisa[int(p[i])-1] = 1 num = 0 for i in range(n): if lisa[i] == 1: num += lisw[i] print(sum(lisa),num)" p02802,s246202303,Accepted,"N,M=map(int,input().split()) ps_dic={} for i in range(M): pi,si=input().split() if pi not in ps_dic: ps_dic[pi]=[si] else: ps_dic[pi].append(si) #print(ps_dic) total_ac=0 total_wa=0 for p in ps_dic: num_wa=0 for s in ps_dic[p]: if s == ""WA"": num_wa+=1 elif s == ""AC"": total_ac+=1 total_wa+=num_wa break print(str(total_ac) + "" "" + str(total_wa))" p02802,s966555103,Accepted,"n, m = map(int, input().split()) ACc = [0 for i in range(n)] WAc = [0 for i in range(n)] for i in range(m): p, s = input().split() p = int(p) if s == ""AC"": if ACc[p - 1] == 0: ACc[p - 1] += 1 else: if ACc[p - 1] != 1: WAc[p - 1] += 1 for j in range(n): if ACc[j] == 0: WAc[j] = 0 print(sum(ACc), sum(WAc))" p02802,s478563739,Accepted,"n,m = map(int,input().split()) L = [0]*n penalty = [0]*n ans = 0 out = 0 for i in range(m): p,q = input().split() if q == 'AC': if L[int(p)-1] == 0: L[int(p)-1] = 1 ans += 1 else: if L[int(p)-1] == 0: penalty[int(p)-1] += 1 for i in range(n): if L[i] == 1: out += penalty[i] print(ans,out)" p02802,s588577072,Accepted,"#python3 from collections import defaultdict n,m = map(int, input().split()) a = [] dic = defaultdict(list) for _ in range(m): x,y = map(str, input().split()) dic[int(x)].append(y) acc=0 for j in dic.values(): if 'AC' in j: acc+=1; cnt=0 for li in dic.values(): if 'AC' in li: for j in li: if j == 'AC': break cnt+=1 ans = str(acc) + ' ' + str(cnt) print(ans) " 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)" p02802,s560681131,Accepted,"N,M = (int(x) for x in input().split()) cor = 0 mis = 0 numList = [0] * N misList = [0] * N for _ in range(M): num,ans = input().split() if ans == 'WA': misList[int(num)-1] += 1 else: if numList[int(num)-1] == 0: mis += misList[int(num)-1] cor += 1 numList[int(num)-1] = 1 print(cor,mis) " p02802,s798027021,Accepted,"N,M = map(int,input().split()) wa_list= [0]*(N+2) ac_list=[-1]*(N+2) for i in range(M): p,a = map(str,input().split()) p = int(p) if a =='WA': wa_list[p]+=1 if a =='AC' and ac_list[p] == -1: ac_list[p]+=(wa_list[p]+1) count = 0;count2 = 0 for i in ac_list: if i>=0: count+=1 count2+=i print(count,count2) " p02802,s385726047,Accepted,"N,M = [int(i) for i in input().split()] submissions = {str(i):[] for i in range(1,N+1)} AC,WA = 0,0 for i in range(M): P,S = [j for j in input().split()] submissions[P].append(S) for i in submissions: if 'AC' not in submissions[i]: continue for j in submissions[i]: if j == 'AC': AC+=1 break WA +=1 print(AC,WA)" 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))" p02802,s423596904,Accepted,"n,m = map(int,input().split()) a = [0]*n AC,WA=0,0 for i in range(m): x,y = input().split() x = int(x) if a[x-1]!=-1 and y==""WA"": a[x-1]+=1 if a[x-1]!=-1 and y==""AC"": WA+=a[x-1] AC+=1 a[x-1]=-1 print(AC,WA)" p02802,s734447184,Accepted,"N,M=map(int,input().split()) ans=dict() AC=0 WA=0 for i in range(M): P,S= map(str,input().split()) if((P in ans)==False): ans[P]=[S] else: ans[P].append(S) for i in ans.values(): tmp=0 for value in i: if(value=='AC'): AC+=1 WA+=tmp break else: tmp+=1 print(AC,WA)" p02802,s367464827,Accepted,"def main(): k, n = map(int, input().split()) dp = [0] * (k+1) dq = [0] * (k+1) pen = 0 for i in range(n): p,q = input().split() p = int(p) if dp[p] == 0: if q == 'WA': dq[p] += 1 elif q == 'AC': dp[p] = 1 pen += dq[p] print(sum(dp), pen) if __name__ == '__main__': main()" 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))" p02802,s188304679,Accepted,"N,M = map(int,input().split()) AC = [0 for _ in range(N)] WA = [0 for _ in range(N)] for _ in range(M): p,S = input().split() p = int(p)-1 if not AC[p]: if S == 'AC': AC[p] = 1 else: WA[p] += 1 else: continue WAcount = 0 for i in range(N): if AC[i]: WAcount += WA[i] print(sum(AC),WAcount)" p02802,s859472114,Accepted,"n,m = list(map(int, input().split())) problems = [0]*n accurate = 0 penalty = 0 for i in range(m): p,s = input().split() p = int(p) if s == ""AC"" and problems[p-1] != -1: #初めて正解 penalty += problems[p-1] accurate += 1 problems[p-1] = -1 elif s == ""WA"" and problems[p-1] != -1: #正解してない問題を不正解 problems[p-1] += 1 print(accurate,penalty)" p02802,s934992090,Accepted,"import numpy as np N, M = map(int,input().split()) ansAC = 0 ansWA = 0 zeros = np.zeros(N) is_solved = set() for _ in range(M): p, S = input().split() p = int(p) if S == ""WA"": if p-1 not in is_solved: zeros[p-1] += 1 else: is_solved.add(p-1) ansAC = len(is_solved) ansWA = int(sum(zeros[list(is_solved)])) print(ansAC, ansWA) " p02802,s117476772,Accepted,"n, m = map(int, input().split()) p, s = [], [] pslist = [] for i in range(m): row = list(input().split( )) pslist.append(row) aclist = [0] * n walist = [0] * n for j, k in pslist: j = int(j) if k == 'AC': if aclist[j - 1] == 0: aclist[j - 1] = 1 if k == 'WA': if aclist[j - 1] == 0: walist[j - 1] += 1 wacountlist = [x * y for (x, y) in zip(aclist, walist)] print(sum(aclist), sum(wacountlist))" p02802,s859477274,Accepted,"n, m = map(int, input().split()) AC = [0] * n WA = [0] * n w = 0 for i in range(m): p, s = input().split() p = int(p) - 1 if s == 'AC' and AC[p] == 0: AC[p] += 1 w += WA[p] elif s == 'WA' and AC[p] == 0: WA[p] += 1 print(sum(AC), w)" p02802,s789245618,Accepted,"N,M=map(int,input().split()) AC=[0]*(N+1) WA=[0]*(N+1) for i in range(M): p,S=input().split() p=int(p) if S=='WA' and AC[p]==0: WA[p]+=1 if S=='AC' and AC[p]==0: AC[p]+=1 #結局正解できなかった場合はWA=0になる for j in range(N+1): WA[j] = WA[j]*AC[j] print(sum(AC),sum(WA))" p02802,s217062395,Accepted,"n, m = map(int, input().split()) query = [tuple(input().split()) for _ in range(m)] wa = [0] * n ac = [0] * n for p, result in query: p = int(p) - 1 if result == 'AC': ac[p] = 1 if result == 'WA' and ac[p] == 0: wa[p] += 1 accept = 0 penalty = 0 for i in range(n): if ac[i]: penalty += wa[i] accept += 1 print(accept, penalty)" p02802,s977125373,Accepted,"N,M = map(int,input().split()) correct = [0]*N penalty = [0]*N ans_c,ans_p = 0,0 for i in range(M): p,s = input().split() p = int(p) if s==""AC"": if correct[p-1]==0: correct[p-1]+=1 if s==""WA"": if correct[p-1]==0: penalty[p-1]+=1 ans_penalty = 0 for i in range(N): if correct[i]>=1: ans_penalty+=penalty[i] print(sum(correct),ans_penalty)" p02802,s570555985,Accepted,"N,M = map(int, input().split()) ans = {} if M > 0: for _ in range(M): key, value = input().split() if key not in ans: ans[key] = [] ans[key].append(value) else: print(0,"" "",0) exit() ac = 0 wa = 0 for v in ans.values(): if 'AC' in v: # ACを出している場合 for a in v: if a == 'WA': wa += 1 else: ac += 1 break else: # ACを出していない場合 continue print(ac, "" "", wa)" p02802,s704358786,Accepted,"N,M=map(int,input().split()) wa=[0]*N pen=[0]*N ac=[0]*N for x in range(M): P,S=input().split() if S==""WA"" and ac[int(P)-1]==0: wa[int(P)-1] += 1 elif S==""AC"" and ac[int(P)-1]==0: ac[int(P)-1] += 1 pen[int(P)-1] = wa[int(P)-1] print(f""{sum(ac)} {sum(pen)}"")" p02802,s829374973,Accepted,"n,m = map(int, input().split()) num = [0]*n flag = [False]*n for _ in range(m): p,s = input().split() p = int(p)-1 if flag[p]: continue else: if s == ""AC"": flag[p] = True else: num[p] += 1 for i in range(n): if flag[i] == False: num[i] = 0 print(flag.count(True),sum(num)) " p02802,s476093347,Accepted,"n,m=map(int,input().split()) cnt1=[0]*(n+1) cnt2=[0]*(n+1) for _ in range(m): p,s=map(str,input().split()) p=int(p) if cnt1[p]==1: continue else: if s=='AC': cnt1[p]=1 else: cnt2[p]+=1 ans1=0 ans2=0 for i in range(1,n+1): if cnt1[i]==1: ans1+=1 ans2+=cnt2[i] print(ans1,ans2)" 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) " p02802,s036304689,Accepted,"n, m = map(int, input().split()) sac = set() lwa = [0] * n for i in range(m): p, s = input().split() p = int(p) - 1 if p in sac: continue elif s == 'AC': sac.add(p) else: lwa[p] += 1 print(len(sac), sum(lwa[p] for p in sac))" p02802,s177077161,Accepted,"n,m=map(int, input().split()) al=[] for i in range(m): a=list(map(str, input().split())) al.append(a) l_all=[[] for i in range(n)] for i in range(m): l_all[int(al[i][0])-1].append(al[i][1]) ac=0 pn=0 for j in range(n): if l_all[j].count('AC')!=0: pn+=l_all[j].index('AC') ac+=1 print('{} {}'.format(ac,pn))" p02802,s763165480,Accepted,"N, M = [int(_) for _ in input().split()] P = [0 for _ in range(N)] ans,pen = 0,0 for _ in range(M): p,s = input().rstrip().split(' ') p = int(p) - 1 if P[p] == -1: continue if s == ""WA"": P[p] += 1 else: ans += 1 pen += P[p] P[p] = -1 print(ans,pen)" p02802,s791400084,Accepted,"n,m = map(int,input().split()) max_val = 10**5+1 # dictの初期化 ac_L = [] wa_L = [] for val in range(1,max_val): wa_L.append(0) ac_L.append(0) ac_ans,wa_ans = 0,0 for i in range(m): p,s = map(str,input().split()) p = int(p) # acの処理 if ac_L[p] ==0 and s == ""AC"": ac_L[p] = 1 wa_ans += wa_L[p] # waの処理 wa_L[p] += 1 #print(ac_dic,wa_dic) print(sum(ac_L),wa_ans)" p02802,s267484835,Accepted,"n, m = map(int, input().split()) listAC = [0] * n listWAAC = [0] * n listWA = [0] * n for i in range(m): p, s = map(str, input().split()) p = int(p) - 1 if listAC[p] == 1: continue if s == 'AC': listAC[p] += 1 listWAAC[p] += listWA[p] continue listWA[p] += 1 print(sum(listAC), sum(listWAAC)) " p02802,s248071428,Accepted,"n,m=map(int,input().split()) ac=[0]*(n+1) wa=0 for i in range(m): p,c=input().split() if c=='WA' and ac[int(p)]!=1: ac[int(p)]-=1 elif c=='AC' and ac[int(p)]!=1: wa+=abs(ac[int(p)]) ac[int(p)]=1 print(ac.count(1),wa)" p02802,s595621764,Accepted,"d=dict() wa=ans=0 N,M=map(int,input().split()) for i in range(M): p,s=input().split() if p not in d: d[p]=0 if d[p]>=0 and s==""AC"": ans+=1 wa+=d[p] d[p]=-float(""inf"") else: d[p]+=1 print(ans,wa)" p02802,s892150487,Accepted,"N, M = list(map(int, input().split())) PS = [input().split() for _ in range(M)] ps = [(int(p)-1, s) for p, s in PS] ac = [0]*N wa = [0]*N for p, s in ps: if s == ""AC"": ac[p] = 1 else: if ac[p] == 0: wa[p] += 1 print(sum(ac), sum([a*w for a, w in zip(ac, wa)]))" p02802,s855224351,Accepted,"n,m = map(int,input().split()) p = [0]*m s = [""""]*m for i in range(m): p[i],s[i] = input().split() p = [int(j) for j in p] u = [[0 for i in range(2)]for j in range(n)] for k in range(0,m): if(s[k] == ""WA"" and u[p[k]-1][1] == 0): u[p[k]-1][0] += 1 elif(s[k] == ""AC""): u[p[k]-1][1] = 1 ans = 0 ac = 0 for i in range(n): if(u[i][1] == 1): ac += 1 ans += u[i][0] print(ac,ans)" p02802,s903863191,Accepted,"n, m = map(int, input().split()) submit = {} for _ in range(m): p, s = input().split() if submit.get(p, -1) == -1: submit[p] = [0, 0] if (submit[p])[0] == 0: if s == 'AC': (submit[p])[0] += 1 else: (submit[p])[1] += 1 ac = 0 wa = 0 for i in submit.values(): if i[0] > 0: ac += i[0] wa += i[1] print(ac, wa) " p02802,s213777557,Accepted,"n,m = map(int,input().split()) a = [0]*n b = [0]*n for i in range(m): p,s = map(str,input().split()) p = int(p) if s=='AC' and a[p-1]==0: a[p-1]+=1 elif s=='WA' and a[p-1]==0: b[p-1] +=1 for j in range(n): if a[j]==0: b[j]=0 print(sum(a),sum(b))" p02802,s746896605,Accepted,"n,m = map(int,input().split()) ans = [0]*2 tmp = [0]*n false = [0]*n for _ in range(m): p,s = map(str,input().split()) p = int(p) if tmp[p-1] == 0: if s == 'AC': ans[0] += 1 tmp[p-1] += 1 ans[1] += false[p-1] elif s == 'WA': false[p-1] += 1 print(*ans)" p02802,s651218464,Accepted,"N,M=map(int, input().split()) C = [ [0,0] for _ in range(N) ] for i in range(M): p, s = input().split() p = int(p) - 1 if s == ""AC"": C[p][1] = 1 else: if C[p][1] == 0: C[p][0] += 1 ans = 0 pena = 0 for i in range(N): if C[i][1] == 1: ans += 1 pena += C[i][0] print(ans,pena) " p02802,s438112948,Accepted,"import sys n, m = [int(i) for i in sys.stdin.readline().split()] _set = set() ac = 0 wa = 0 ls = [] for i in range(m): p, s = [i for i in sys.stdin.readline().split()] if s == ""AC"": _set.add(p) ls.append([p, s]) new_set = set() for p, s in ls: if s == ""AC"": new_set.add(p) if s == ""WA"" and p in _set and p not in new_set: wa += 1 print(len(_set), wa) " p02802,s414345355,Accepted,"num, all_ans = [int(i) for i in input().split("" "")] d_wa = [0 for _ in range(num)] d_ac = [0 for _ in range(num)] ans = 0 for _ in range(all_ans): ans_num, ac_wa = [i for i in input().split("" "")] if d_ac[int(ans_num) - 1] == 1: continue if ac_wa == ""AC"": d_ac[int(ans_num) - 1] = 1 continue if ac_wa == ""WA"": d_wa[int(ans_num) - 1] += 1 continue for num, i in enumerate(d_ac): if i: ans += d_wa[num] print(sum(d_ac),ans)" 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)) " p02802,s701820552,Accepted,"from collections import defaultdict N, M = map(int, input().split()) D = defaultdict(int) acd = set() ac = 0 pen = 0 for i in range(M): p, S = input().split() p = int(p) if S == ""WA"": D[p] += 1 else: if p not in acd: acd.add(p) ac += 1 pen += D[p] print(ac, pen)" p02802,s332629861,Accepted,"N, M = map(int, input().split()) pSs = [list(map(str, input().split())) for _ in range(M)] #%% ACs = [False for _ in range(N)] WAs = [0 for _ in range(N)] for pS in pSs: problem = int(pS[0]) -1 answer = pS[1] if ACs[problem] == True: continue else: if answer == ""WA"": WAs[problem] += 1 else: ACs[problem] = True num_WA = 0 for i, WA in enumerate(WAs): if ACs[i] == True: num_WA += WA print(sum(ACs), num_WA)" p02802,s836036091,Accepted,"n, m = map(int, input().split()) ps = [list(map(str, input().split())) for i in range(m)] AC =[0]*n WA = [0]*n WA_ans = [0]*n for i in range(m): if AC[int(ps[i][0])-1] == 0: if ps[i][1] == 'AC': AC[int(ps[i][0])-1] = 1 WA_ans[int(ps[i][0])-1] = WA[int(ps[i][0])-1] elif ps[i][1] == 'WA': WA[int(ps[i][0])-1] += 1 print(sum(AC), sum(WA_ans))" p02802,s311693081,Accepted,"n,m = [int(x) for x in input().split()] ans = [0]*(n+1) w = [0]*(n+1) for _ in range(m): a,b = input().split() a = int(a) if ans[a] == 1: continue if b == ""AC"": ans[a] = 1 else: w[a] += 1 aa = 0 ww = 0 for i in range(1,n+1): if ans[i]==1: aa += 1 ww += w[i] print(aa,ww) " p02802,s510392681,Accepted,"n,m=map(int,input().split()) acount=0 wcount=0 a=[False]*n w=[0]*n for i in range(m): p,m=input().split() p=int(p) if m==""AC"": if a[p-1]==False: acount+=1 a[p-1]=True else: if a[p-1]==False: w[p-1]+=1 for i in range(n): if a[i-1]==1: wcount+=w[i-1] print(acount,wcount)" p02802,s911926571,Accepted,"from collections import defaultdict n, m = map(int, input().split()) ac_set = set() wa_dic = defaultdict(int) wa_cnt = 0 for i in range(m): p, s = input().split() if s == 'AC': ac_set.add(p) else: if p not in ac_set: wa_dic[p] += 1 print(len(ac_set), sum(value for key, value in wa_dic.items() if key in ac_set))" p02802,s329256865,Accepted,"import sys N, M, *PS = sys.stdin.read().strip().split() N = int(N) ac = [0] * N wa = [0] * N for p, s in zip(*[iter(PS)] * 2): p = int(p) -1 if s == ""AC"": ac[p] = 1 elif ac[p] == 0: wa[p] += 1 penalties = sum([w * a for a, w in zip(ac, wa)]) print(""{} {}"".format(sum(ac), penalties))" p02802,s467906027,Accepted,"N, M = map(int,input().split()) p = [0]*M S = [0]*M T = [0]*(N+1) U = [0,0] for i in range(M): p[i],S[i] = input().split() P = int(p[i]) if T[P] != -1: if S[i] == 'WA': T[P] += 1 elif S[i] == 'AC': U[0] += 1 U[1] += T[P] T[P] = -1 print(U[0],U[1]) " p02802,s229724833,Accepted,"N, M = map(int, input().split()) Counted = [0 for _ in range(N)] num1 = 0 num2 = 0 subnum2 = [0 for l in range(N)] for j in range(M): p, S = input().split() p_ = int(p) if S == ""AC"" and Counted[p_ -1] == 0: num1 += 1 num2 += subnum2[p_ - 1] Counted[p_ -1] = 1 elif S == ""WA"" and Counted[p_-1] == 0: subnum2[p_ - 1] += 1 print(""{} {}"".format(num1, num2)) " p02802,s063885647,Accepted,"import numpy as np N,M = map(int, input().split()) #A = list(map(int, input().split())) A=[0 for _ in range(N)] B=[0 for _ in range(N)] C=[0 for _ in range(N)] for i in range(M): p,S = input().split() p = int(p)-1 if S == ""AC"": A[p] = 1 C[p] = B[p] elif A[p]==0: B[p] += 1 A = np.array(A) C = np.array(C) print(np.sum(A), np.sum(C)) " p02802,s421118223,Accepted,"## C - Welcome to AtCoder N ,M = map(int, input().split()) AC = [0] + [0] * N WA = [0] + [0] * N for m in range(M): p, S = map(str, input().split()) if S == 'WA' and AC[int(p)] != 1: WA[int(p)] += 1 else: AC[int(p)] = 1 print(' '.join([str(x) for x in [sum(AC), sum([WA[i] for i in range(N+1) if AC[i] == 1 ])] ]) )" 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)" p02802,s714158279,Accepted,"def II(): return int(input()) def MI(): return map(int, input().split()) def LI(): return list(map(int, input().split())) ans,pena=0,0 N,M=MI() P=[0]*N PENA=[0]*N for i in range(M): p,s=input().split() p=int(p) p-=1 if s=='AC': if P[p]==0: ans+=1 P[p]=1 if PENA[p]!=0: pena+=PENA[p] if s=='WA': if P[p]==0: PENA[p]+=1 print(ans,pena) " p02802,s520976597,Accepted,"n,m=map(int,input().split()) p=[] s=[] for i in range(m): P,S=input().split() P=int(P)-1 p.append(P) s.append(S) wa=[0 for i in range(n)] ac=[0 for i in range(n)] for i in range(m): if s[i]==""AC"": ac[p[i]]+=1 else: if ac[p[i]]==0: wa[p[i]]+=1 sum_ac=0 pena=0 for i in range(n): if ac[i]!=0: sum_ac+=1 pena+=wa[i] print(sum_ac,end=' ') print(pena)" 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)" p02802,s165990809,Accepted,"n, m = map(int, input().split()) ac = {} wa = {} for _ in range(m): p, s = input().split() p = int(p) if s == 'AC': ac[p] = 1 else: if not ac.get(p, 0): wa[p] = wa.get(p, 0) + 1 pen = 0 for p in ac: pen += wa.get(p, 0) print(len(ac), pen) " p02802,s154676055,Accepted,"n, m = map(int, input().split()) mapAC = [False]*(n+1) countWA = [0]*(n+1) for i in range(m): p, s = input().split() p = int(p) if s == 'AC': mapAC[p] = True else: countWA[p] += 1*(not mapAC[p]) countWA = map(lambda x, y: x*y, countWA, mapAC) print(mapAC.count(True), sum(countWA))" p02802,s651063454,Accepted,"n, m = map(int, input().split()) ps = [] memo = [0 for i in range(n)] pena = [0 for i in range(n)] for i in range(m): p, s = input().split() p = int(p) if s == ""AC"": memo[p-1] = 1 else: if memo[p-1] == 0: pena[p-1] += 1 ans = 0 for i, p in enumerate(pena): if memo[i]: ans += p print(sum(memo), ans) " 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))" p02802,s174613492,Accepted,"n, m = map(int, input().split()) lac = [0] * n lwa = [0] * n for i in range(m): p, s = input().split() p = int(p) - 1 if lac[p] == 0: if s == 'WA': lwa[p] += 1 if s == 'AC': lac[p] = 1 print(sum(lac), sum(x * y for x, y in zip(lac, lwa)))" p02802,s304976003,Accepted,"n, m = list(map(int, input().split())) wa_count = [0] * n is_accepted = [False] * n ans_ac = 0 ans_wa = 0 for i in range(m): p, s = input().split() p = int(p) - 1 if s == 'AC': if not is_accepted[p]: is_accepted[p] = True ans_ac += 1 ans_wa += wa_count[p] else: wa_count[p] += 1 print(ans_ac, ans_wa) " p02802,s670143783,Accepted,"n,m=map(int,input().split()) li=[input().split() for i in range(m)] ac=set() wa=0 q=[[0,-1] for i in range(n+1)] for x,y in li: if y==""AC"" and q[int(x)][1]==-1: #AC出したらこれまでのwaを答えに足して、それ以降はカウントされないようにする wa+=q[int(x)][0] q[int(x)][1]=0 ac.add(x) elif y==""WA"" and q[int(x)][1]==-1: q[int(x)][0]+=1 print(len(ac),wa)" p02802,s671830837,Accepted,"N,M=map(int,input().split()) ac=[0]*N wa=[0]*N for i in range(M): p,s=input().split() if s==""WA"" and ac[int(p)-1]==0: wa[int(p)-1]+=1 elif s==""AC"" and ac[int(p)-1]==0: ac[int(p)-1]+=1 penalty=[wa[k] for k in [i for i,j in enumerate(ac) if j!=0]] print(""%d %d"" % (sum(ac),sum(penalty))) " p02802,s812815639,Accepted,"n, m = [int(i) for i in input().split()] ac = [0] * n wa = [0] * n for i in range(m): p, s = input().split() p = int(p) if ac[p-1] == 0: if s == ""AC"": ac[p-1] = 1 elif s == ""WA"": wa[p-1] += 1 wa_sum = 0 for i in range(n): if ac[i] >= 1: wa_sum += wa[i] print(sum(ac), wa_sum)" p02802,s688608112,Accepted,"n, m = map(int, input().split()) ac = [0] * (n+1) pena = 0 for i in range(m): p, s = input().split() p = int(p) if s == ""AC"": if ac[p] != -1: pena += ac[p] ac[p] = -1 else: if ac[p] != -1: ac[p] += 1 print(ac.count(-1), pena) " p02802,s775350012,Accepted,"n,m = map(int, input().split()) wa_l = [0]*(n+1) ac_l = [False]*(n+1) for _ in range(m): p,s = input().split() p = int(p) if s == 'WA' and not ac_l[p]: wa_l[p] += 1 elif s == 'AC': ac_l[p] = True ans_a = 0 ans_w = 0 for wa,ac in zip(wa_l,ac_l): if ac: ans_a+=1 ans_w += wa print(ans_a,ans_w)" p02802,s574710530,Accepted,"# ABC 151C n, m = map(int, input().split()) ac = 0 wa = 0 cnt = [0]*n for i in range(m): p, s = input().split() p = int(p) p -= 1 if cnt[p] == -1: continue elif s == 'AC': ac += 1 wa += cnt[p] cnt[p] = -1 else: cnt[p] += 1 print(ac, wa) " p02802,s510935718,Accepted,"n, m = map(int, input().split()) problem = [False] * n count_wa = [0] * n for _ in range(m): num, res = input().split() num = int(num) - 1 if res == 'AC': problem[num] = True else: if problem[num] == False: count_wa[num] += 1 else: continue a = sum(problem) b = 0 for i in range(n): if problem[i] == True: b += count_wa[i] print(a, b) " p02802,s478196101,Accepted,"N,M=map(int,input().split()) ac=[0]*(N+1) wa=[0]*(N+1) for i in range(M): p,s=input().split() if ac[int(p)]==1: continue if s=='AC': ac[int(p)]=1 elif s=='WA': wa[int(p)]+=1 ac_ans,wa_ans=0,0 for a,w in zip(ac,wa): if a==0: continue ac_ans+=a wa_ans+=w print(ac_ans,wa_ans)" p02802,s946386525,Accepted,"n,m=map(int,input().split()) d={} for i in range(m): p,s=map(str,input().split()) if p not in d: d[p]=[s,1] elif d[p][0]==""WA"": d[p][0]=s d[p][1]+=1 ans=[0,0] for i in d: if d[i][0]==""AC"": ans[0]+=1 ans[1]+=d[i][1]-1 print(*ans) " p02802,s456106504,Accepted,"n,m = map(int, input().split()) accurate = [0] * n correct = 0 wrong = [0] * n penalty = 0 for i in range(m): p,s = input().split() num = int(p) - 1 if s == 'AC' and accurate[num] == 0: accurate[num] += 1 correct += 1 penalty += wrong[num] elif s == 'WA': wrong[num] += 1 print('{} {}'.format(correct,penalty))" p02802,s038031825,Accepted,"N,M = list(map(int,input().split())) ac = [0]*N wa = [0]*N for i in range(M): p,s = list(map(str,input().split())) p = int(p) if s == 'AC': ac[p - 1] = 1 elif s == 'WA': if ac[p - 1] == 0: wa[p - 1] += 1 for i in range(N): if ac[i] == 0: wa[i] = 0 print(sum(ac),sum(wa))" p02802,s267509601,Accepted,"n, m = map(int, input().split()) total_ac = 0 total_wa = 0 results = {} for _ in range(m): pi, si = input().split() if results.get(pi) == None: results[pi] = { ""AC"": False, ""CumWA"": 0 } if not results[pi][""AC""] and si == ""AC"": results[pi][""AC""] = True total_ac += 1 total_wa += results[pi][""CumWA""] elif not results[pi][""AC""] and si == ""WA"": results[pi][""CumWA""] += 1 print(total_ac , total_wa ) " 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))" p02802,s789512425,Accepted,"N,M = map(int,input().split()) AC = [0 for i in range(N+1)] WA = [0 for i in range(N+1)] for i in range(M): a,b=input().split() a2 = int(a) if b == 'AC': AC[a2 - 1] = 1 elif b == 'WA' and AC[a2 - 1] == 0: WA[a2-1]+= 1 ans_WA = 0 for i, j in zip(WA, AC): ans_WA += i * j print(sum(AC), ans_WA)" p02802,s513096441,Accepted,"a,b=map(int,input().split()) list = [0]*a t_cnt = 0 f_cnt = [0]*a for i in range(b): c, d = map(str,input().split()) x = int(c) - 1 if list[x] == 0: if d == 'AC': list[x] = 1 t_cnt += 1 else: f_cnt[x] += 1 for i in range(a): if list[i] ==0: f_cnt[i] = 0 print(""{} {}"".format(t_cnt, sum(f_cnt)))" p02802,s183063174,Accepted,"n, m = map(int, input().split()) answer = [[False, 0] for _ in range(n)] for i in range(m): number, result = input().split() number = int(number) if result == 'AC': answer[number-1][0] = True elif answer[number-1][0] != True: answer[number-1][1] += 1 ret = [ans[1] for ans in answer if ans[0] == True] print(len(ret), sum(ret)) " p02802,s629861926,Accepted,"import numpy as np N,M=map(int,input().split()) wa=np.zeros(N+1) ac=np.zeros(N+1) for _ in range(M): p,S=input().split() if S=='AC' and ac[int(p)]==0: ac[int(p)]+=1 elif S=='AC' and ac[int(p)]>0: pass elif ac[int(p)]==0: wa[int(p)]+=1 print(int(sum(ac)), int(np.dot(ac>0,wa)))" p02802,s138607987,Accepted,"N, M = map(int, input().split()) ans = 0 pen = 0 w = [0]*(N+1) ac = [False]*(N+1) for _ in range(M): p, s = input().split() if s == ""AC"" and not ac[int(p)]: pen += w[int(p)] ac[int(p)] = True ans += 1 elif s == ""WA"": w[int(p)] += 1 print(ans, pen)" p02802,s673097731,Accepted,"n , m = map(int,input().split()) if m == 0: print(0,0) exit() ps = [0] * m ss = [0] * m for i in range(m): p,s = map(str,input().split()) ps[i],ss[i] = int(p),s ac = [0] * (n + 1) wa = [0] * (n + 1) for i in range(m): if ac[ps[i]] == 1: continue if ss[i] == 'AC': ac[ps[i]] = 1 else: wa[ps[i]] += 1 for i in range(n+1): if ac[i] == 0: wa[i] = 0 print(sum(ac),sum(wa)) " p02802,s548976313,Accepted,"N, M = map(int, input().split()) isAC = [False for _ in range(N)] correct = 0 penalty = [0 for _ in range(N)] for _ in range(M): tmp = input().split() pi, Si = int(tmp[0]), tmp[1] if not isAC[pi-1]: # すでにAC if Si == 'AC': isAC[pi-1] = True correct += 1 else: penalty[pi-1] += 1 pnl = 0 for idx in range(N): if isAC[idx]: pnl += penalty[idx] print(correct, pnl)" p02802,s139785458,Accepted,"N, M = map(int, input().split()) PS = [[0, 0] for i in range(N)] for i in range(M): p, s = input().split() if s == ""AC"": PS[int(p) - 1][0] = 1 elif s == ""WA"" and PS[int(p) - 1][0] == 0: PS[int(p) - 1][1] += 1 ac = 0 wa = 0 for ps in PS: if ps[0] == 1: ac += 1 wa += ps[1] print(ac, wa)" 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)" p02802,s188605017,Accepted,"#N=int(input()) #N,M=map(int, input().split()) #L=list(map(int, input().split())) N,M=map(int, input().split()) ifACL=[0]*N cWAL=[0]*N psL=[] AC=0 WA=0 p=0 s=0 for _ in range(M): p,s=map(str, input().split()) p=int(p) if ifACL[p-1]==0 and s==""WA"": cWAL[p-1]+=1 elif ifACL[p-1]==0 and s==""AC"": AC+=1 WA+=cWAL[p-1] ifACL[p-1]=1 print(AC,WA)" p02802,s313616520,Accepted,"import numpy as np n,m = map(int, input().split()) ac_ques = np.array([0]*n) count = np.array([0]*n) for _ in range(m): p,s = map(str, input().split()) if ac_ques[int(p)-1] == 0: if s == ""WA"": count[int(p)-1] += 1 else: ac_ques[int(p)-1] = 1 print(sum(ac_ques),sum(ac_ques * count))" p02802,s036640835,Accepted,"N, M = map(int,input().split()) accepted = [0]*N wrong_ans =[0]*N for i in range(M): p,s = input().split() p = int(p)-1 if s ==""AC"": accepted[p] = 1 elif s == ""WA"" and accepted[p]==0: wrong_ans[p] = wrong_ans[p]+1 AC = 0 penalty = 0 for i in range(N): if accepted[i] == 1: AC = AC+1 if wrong_ans[i]>=1: penalty = penalty+wrong_ans[i] print(AC,penalty)" p02802,s125942683,Accepted,"n,m=map(int,input().split()) p=[True]*n y=[0]*n i=0 l=0 for _ in range(m): k,o=input().split() k=int(k)-1 if p[k]==True: if o==""AC"": i+=1 p[k]=False else: y[k]+=1 for e in range(n): if p[e]==False: l+=y[e] print(i,l) " p02802,s608688645,Accepted,"n, m = map(int, input().split()) ans = 0 flag = [0] * n for _ in range(m): P, s = input().split(' ') p = int(P) - 1 if s == 'AC': if flag[p] != -1: ans += flag[p] flag[p] = -1 elif flag[p] != -1: flag[p] += 1 print(flag.count(-1), ans)" p02802,s935965414,Accepted,"n, m = map(int, input().split()) pss = [input().split() for _ in range(m)] import array; ### print(array.typecodes) ### wacounts = array.array(""l"", [0] * (n+1)) acflags = array.array(""b"", [0] * (n+1)) for pi, si in pss: pi = int(pi) if acflags[pi] == 0: if si == ""WA"": wacounts[pi] += 1 if si == ""AC"": acflags[pi] = 1 ### print(pi, si, wacounts, acflags) ### print(acflags.count(1), end="" "") print(sum(x*y for x,y in zip(wacounts, acflags)))" p02802,s037072385,Accepted,"N,M=map(int,input().split()) ans=[0]*N pen=[0]*N AC=[0]*N for i in range(M): p,s=input().split() p=int(p) if s==""WA"": pen[p-1]+=1 else: if AC[p-1]==0: ans[p-1]+=pen[p-1] AC[p-1]=1 print(AC.count(1),sum(ans)) " p02802,s387211149,Accepted,"n, m = [int(x) for x in input().split()] ac = [0] * (n + 1) wa = [0] * (n + 1) for i in range(m): p, s = input().split() p = int(p) if s == ""AC"": ac[p] = 1 if s == ""WA"" and ac[p] == 0: wa[p] += 1 print(sum(ac), sum([p for a, p in zip(ac, wa) if a == 1])) " p02802,s310599754,Accepted,"N, M = map(int, input().split()) pena= 0 ac = [0]*(10**5) for _ in range(M): tmp = input().split() if ac[int(tmp[0])-1] < 1: if tmp[1] == ""AC"": pena -= ac[int(tmp[0])-1] ac[int(tmp[0])-1] = 1 else: ac[int(tmp[0])-1] -= 1 #penalty print(ac.count(1), pena)" p02802,s032719739,Accepted,"N,M=list(map(int, input().split())) P=[0]*M S=[0]*M for i in range(M): P[i],S[i]=list(input().split()) P[i]=int(P[i]) flagac=[False]*N pnlt=[0]*N for i in range(M): p=P[i]-1 s=S[i] if s=='AC': flagac[p]=True else: pnlt[p]+=(flagac[p]+1)%2 # print(flagac) # print(pnlt) ctac=0 ctwa=0 for i in range(N): if flagac[i]: ctac+=1 ctwa+=pnlt[i] print(ctac, ctwa)" p02802,s341885437,Accepted,"N, M = map(int, input().split()) accepted = [0] * N penalties = [0] * N for _ in range(M): p, ac = input().split() p, ac = int(p) - 1, ac == ""AC"" accepted[p] |= ac penalties[p] += not accepted[p] print(sum(accepted), sum(p for ac, p in zip(accepted, penalties) if ac)) " p02802,s595599629,Accepted,"n, m = map(int, input().split()) ps = [(input().split()) for _ in range(m)] wa = [0] * (n + 1) ac = [0] * (n + 1) for p, s in ps: i = int(p) if s == ""WA"": if ac[i] != 1: wa[i] += 1 else: if ac[i] != 1: ac[i] = 1 print(sum(ac), sum(wa[i] * ac[i] for i in range(n + 1))) " p02802,s574820021,Accepted,"n,m = map(int,input().split()) q = [0]*n wa = [0]*n for _ in range(m): pp,s = input().split() p = int(pp) if q[p-1] == 0: if s == ""WA"": wa[p-1] += 1 else: q[p-1] = 1 qq = 0 wawa = 0 for i in range(n): if q[i] > 0: wawa += wa[i] qq += q[i] print(qq,wawa) " p02802,s279980873,Accepted,"N, M = map(int, input().split()) ac_chk = [0]*(N+1) wa_chk = [0]*(N+1) wa = 0 ac = 0 for i in range(M): p, S = input().split() p = int(p) if ac_chk[p] == 0: if S == ""AC"": ac_chk[p] = 1 ac += 1 wa += wa_chk[p] continue if S == ""WA"": wa_chk[p] += 1 continue else: continue print(ac, wa)" p02802,s504777036,Accepted,"n,m = map(int,input().split()) acli = [0]*n wali = [0]*n acsi = 0 wasi = 0 for i in range(m): p,s = map(str,input().split()) if acli[int(p)-1] == 0: if s == 'AC': acli[int(p)-1] = 1 acsi += 1 elif s == 'WA': wali[int(p)-1] += 1 for j in range(n): if acli[j] == 1 and wali[j] != 0: wasi += wali[j] print(acsi,wasi)" p02802,s333077286,Accepted,"N, M = map(int, input().split()) AC = set() wa = [0] * (N+1) for _ in range(M): p, s = input().split() p = int(p) if not p in AC: if s == 'AC': AC.add(p) if s == 'WA': wa[p] += 1 wa_ans = 0 for i in range(1,N+1): if i in AC: wa_ans += wa[i] print(len(AC), wa_ans)" p02802,s028672858,Accepted,"n, m = map(int, input().split()) d = {} cnt_ac = 0 cnt_wa = 0 for _ in range(m): p, s = input().split() if p not in d: d[p] = [s] else: d[p].append(s) for i in d: if 'AC' in d[i]: cnt_ac += 1 cnt_wa += d[i].index('AC') print(cnt_ac, cnt_wa)" p02802,s898126194,Accepted,"N, M = map(int, input().split()) ans1 = 0 ans2 = 0 Q = [0] * N wrong = [0] * N for i in range(M): p, S = map(str, input().split()) p = int(p) - 1 if Q[p] == 0 and S == ""AC"": ans1 += 1 ans2 += wrong[p] Q[p] = 1 elif S == ""WA"": wrong[p] += 1 print(ans1,ans2)" p02802,s420790223,Accepted,"import numpy as np N, M = map(int, input().split()) ac = 0 wa = 0 test = [0] * N count = [0] * N for i in range(M): p_i, s_i = input().split("" "") p_i = int(p_i) - 1 if s_i == ""AC"": test[p_i] = 1 elif test[p_i] != 1: count[p_i] += 1 test = np.array(test) count = np.array(count) score = np.sum(test) pena = np.sum(test * count) print(str(int(score)) + "" "" + str(int(pena)))" p02802,s496019662,Accepted,"from operator import itemgetter n, m = map(int, input().split()) an = [0]*n sc = 0 er = 0 for i in range(m): t, s = map(str, input().split()) p = int(t)-1 if (an[p] != m+1 and s == ""AC""): sc += 1 er += an[p] an[p] = m+1 elif (an[p] != m+1 and s == ""WA""): an[p] += 1 print(""{} {}"".format(sc, er)) " 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)" p02802,s323313662,Accepted,"n, m = map(int, input().split()) problem = [0] * n ac = 0 penalty = 0 for i in range(m): p, s = map(str, input().split()) if s == ""AC"": temp = problem[int(p) - 1] if temp >= 0: ac += 1 penalty += temp problem[int(p) - 1] = -1 else: if problem[int(p) - 1] >= 0: problem[int(p) - 1] += 1 print(ac, penalty)" p02802,s969386075,Accepted,"# -*- coding: utf-8 -*- import numpy as np n, m = map(int, input().split()) ac = np.zeros(n) wa = np.zeros(n) for _ in range(m): p, s = input().split() p = int(p) - 1 if ac[p] == 1: continue if s == ""WA"": wa[p] += 1 else: ac[p] = 1 acc = 0 wac = 0 for a, w in zip(ac, wa): if a == 1: acc += 1 wac += w print(acc, int(wac)) " p02802,s857592216,Accepted,"n, m = map(int,input().split()) result = [] for _ in range(m): a, b = input().split() a = int(a) result.append([a, b]) problems = [0] * (n+1) ac = 0 wa = 0 for i in range(m): if problems[result[i][0]-1] != -1: if result[i][1] == ""AC"": ac += 1 wa += problems[result[i][0]-1] problems[result[i][0]-1] = -1 else: problems[result[i][0]-1] += 1 print(ac, wa)" p02802,s027352603,Accepted,"n, m= map(int, input().split()) flag_ac = [0]*n cnt_wa = [0]*n cnt_penalty = 0 for _ in range(m): p, s = input().split() if s == ""WA"": cnt_wa[int(p)-1] += 1 elif s == ""AC"" and flag_ac[int(p)-1] == 0: flag_ac[int(p)-1] = 1 cnt_penalty += cnt_wa[int(p)-1] print(sum(flag_ac), cnt_penalty)" p02802,s159465530,Accepted,"import numpy as np # 入力 N,M = map(int,input().split()) Check_AC = np.zeros(N) WA_Counter = np.zeros(N) for i in range(M): pi,Si = input().split() pi = int(pi) # まだ正解していない問題 if Check_AC[pi-1] == 0: if Si == ""AC"": Check_AC[pi-1] = 1 else: WA_Counter[pi-1] += 1 print(str(int(sum(Check_AC))) + "" "" + str(int(np.dot(Check_AC,WA_Counter))))" p02802,s583852519,Accepted,"N, M = map(int, input().split()) isAC = [False] * (N+1) penalties = [0] * (N+1) ac, penalty = (0, 0) for _ in range(M): p, s = input().split() p = int(p) if s == ""AC"": if not isAC[p]: isAC[p] = True ac += 1 penalty += penalties[p] else: penalties[p] += 1 print(ac, penalty)" p02802,s496530895,Accepted,"n,m = map(int,input().split()) li = [[0,0] for _ in range(n)] t1,t2 = 0,0 for i in range(m): a,b = input().split() if li[int(a)-1][0] != 1: if b == ""WA"": li[int(a)-1][1] += 1 if b == ""AC"": li[int(a)-1][0] += 1 for i in range(n): t1 += li[i][0] t2 += li[i][1]*li[i][0] print(t1,t2)" p02802,s613025807,Accepted,"N,M=map(int,input().split()) ac=0 wa=0 a=[0]*N w=[0]*N for i in range(M): P,S=input().split() P=int(P) if S==""WA"": w[P-1]+=1 else: if a[P-1]==0: a[P-1]+=1 ac=ac+1 wa+=w[P-1] else: pass print(ac,wa)" 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)" p02802,s281016754,Accepted,"N,M = map(int,input().split()) D = [[]for i in range(N)] AC = 0 WA = 0 for i in range(M): plobNum,res = input().split() D[int(plobNum)-1].append(res) for prob in D: wa_ = 0 for submit in prob: if submit == ""WA"" : wa_+=1 elif submit == ""AC"": AC+=1 WA +=wa_ break print(""{} {}"".format(AC,WA))" p02802,s126835937,Accepted,"N , M = map(int,input().split()) lst = [] AC_list = [False] * N WA_cnt_list = [0] * N for _ in range(M): r , judge = input().split() question_num = int(r) - 1 if AC_list[question_num]: continue elif judge == ""WA"": WA_cnt_list[question_num] += 1 elif judge == ""AC"": AC_list[question_num] = True wa_cnt = 0 for i in range(N): if AC_list[i]: wa_cnt += WA_cnt_list[i] print(sum(AC_list) , wa_cnt) " p02802,s170066052,Accepted,"n,m = map(int,input().split()) a = [0]*n ac = 0 wa = 0 for i in range(m): p,s = map(str,input().split()) p = int(p) if s == ""AC"" and a[p-1] != -1: ac +=1 wa += a[p-1] a[p-1] = -1 elif s == ""WA"" and a[p-1] != -1: a[p-1] += 1 print(ac,wa) " p02802,s271881921,Accepted,"N, M = map(int, input().split(' ')) ac_set = set() wa_cnt, wa_cnt_ls = 0, [0] * N for i in range(M): p, s = input().split(' ') idx = int(p) - 1 if not idx in ac_set: if s == 'AC': ac_set.add(idx) wa_cnt += wa_cnt_ls[idx] else: wa_cnt_ls[idx] += 1 print(len(ac_set), wa_cnt)" p02802,s764802054,Accepted,"N, M = map(int, input().split()) AC = 0 pena = 0 lst = [0] * N for _ in range(M): a, b = map(str, input().split()) a = int(a) - 1 if lst[a] < 0: continue else: if b == 'WA': lst[a] += 1 else: AC += 1 pena += lst[a] lst[a] = -1 print (AC, pena)" p02802,s070542587,Accepted,"n, m = map(int, input().split()) ac_check = [0 for _ in range(n)] wa_check = [0 for _ in range(n)] for i in range(m): i, judge = input().split() i = int(i)-1 if judge == 'AC': if ac_check[i] == 0: ac_check[i] = 1 elif judge == 'WA': if ac_check[i] == 0: wa_check[i] += 1 wa = 0 for i in range(n): if ac_check[i] == 1 and wa_check != 0: wa += wa_check[i] print(sum(ac_check), wa) " p02802,s856662148,Accepted,"n, m = map(int, input().split()) ps = [input().split() for i in range(m)] ac, wa = [0] * n, [0] * n wa_sum = 0 for i in ps: p, s = int(i[0]), i[1] if ac[p - 1] == 0 and s == ""AC"": ac[p - 1] += 1 wa_sum += wa[p - 1] else: wa[p - 1] += 1 print(sum(ac), wa_sum)" p02802,s771713694,Accepted,"n,m=map(int,input().split()) num=[0]*n wa=0 ac=0 for i in range(m): p,s=input().split() p=int(p) if s==""WA"" and num[p-1]!=-1: num[p-1]+=1 elif s==""AC"" and num[p-1]!=-1: ac+=1 wa+=num[p-1] num[p-1]=-1 print(ac,wa) " 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)" p02802,s064785579,Accepted,"n,m = map(int, input().split()) AC = [False]*n WA = [0]*n for i in range(m): p,s = input().split() p = int(p)-1 if AC[p] == False: if s == 'WA': WA[p] += 1 else: AC[p] = True wa = 0 for i in range(n): if AC[i]: wa += WA[i] print(AC.count(True),wa) " p02802,s858970886,Accepted,"a,b=map(int, input().split()) c=[0]*a d=[0]*a e=0 for i in range(b): p, s=input().split() p=int(p)-1 if c[p]==0 and s=='AC': c[p]=1 e+=d[p] d[p]+=1 print(sum(c),e)" p02802,s516615547,Accepted,"n, m = map(int, input().split()) d = {} for i in range(m): p, s = input().split() d.setdefault(p, []) d[p].append(s) cnt = 0; correct = 0 for v in d.values(): if ""AC"" not in v: continue correct += 1 cnt += v.index(""AC"") print(correct, cnt) " p02802,s049078558,Accepted,"N, M = map(int, input().split()) ac = [0] * N wa = [0] * N WA = 0 for i in range(M): p, s = input().split() p = int(p) - 1 if ac[p] == 0 and s == 'AC': ac[p] = 1 WA += wa[p] wa[p] += 1 print(sum(ac), WA)" 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])" p02802,s891146006,Accepted,"n,m = map(int, input().split()) wc = [0 for i in range(n)] ac = [0 for i in range(n)] n_wc = 0 n_ac = 0 for i in range(m): num,j = input().split() num = int(num) if j == 'AC' and ac[num-1] == 0: n_ac += 1 ac[num-1] = 1 n_wc += wc[num-1] else: wc[num-1] += 1 print(n_ac,n_wc)" p02802,s007089410,Accepted,"N, M = map(int, input().split()) ac = [False] * N wa_cnt = [0] * N ac_cnt = 0 for i in range(M): p, s = input().split() p_i = int(p) - 1 if s == 'WA': if not ac[p_i]: wa_cnt[p_i] += 1 else: if not ac[p_i]: ac[p_i] = True ac_cnt += 1 wa_cnt_sum = 0 for i in range(N): if ac[i]: wa_cnt_sum += wa_cnt[i] print(ac_cnt,wa_cnt_sum) " p02802,s410286829,Accepted,"N, M = map(int, input().split()) wa = [0]*N ac = [0]*N for i in range(M): p, s = map(str, input().split()) p = int(p) if (s=='WA') and (ac[p-1]==0): wa[p-1] += 1 else: ac[p-1] = 1 ans_ac = 0 ans_wa = 0 for i in range(N): if ac[i] == 1: ans_ac += 1 ans_wa += wa[i] print(str(ans_ac), str(ans_wa))" p02802,s088411915,Accepted,"n, m = map(int, input().split()) ps = [[0, 0] for i in range(n)] wa_count = 0 ac_count = 0 for i in range(m): input_p, input_s = input().split() if ps[int(input_p)-1][0] <= 0: if input_s == 'AC': ps[int(input_p)-1][0] += 1 else: ps[int(input_p)-1][1] += 1 for i in ps: if i[0] == 1: ac_count += 1 wa_count += i[1] print(ac_count, wa_count)" p02802,s323760089,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])" p02802,s697174854,Accepted,"n,m=[int(_) for _ in input().split()] p=[0 for i in range(m)] s=[0 for i in range(m)] for i in range(m): _p,_s=input().split() p[i]=int(_p)-1 s[i]=_s ac=[False for i in range(n)] wa=[0 for i in range(n)] for i in range(m): if s[i]==""WA"" and not(ac[p[i]]): wa[p[i]]+=1 else: ac[p[i]]=True for i in range(n): if not(ac[i]): wa[i]=0 print(sum(ac),sum(wa))" p02802,s308916977,Accepted,"N, M = map(int, input().split()) WA = [0] * (10 ** 5 + 1) AC = [False] * (10 ** 5 + 1) for i in range(M): _no , re = input().split() no = int(_no) if re == 'AC': AC[no] = True if not AC[no]: if re == 'WA': WA[no] += 1 pena = 0 for i in range(10 ** 5 + 1): if AC[i]: pena += WA[i] print(AC.count(True), pena) " p02802,s902883161,Accepted,"n,m=map(int,input().split()) cnt = [0]*n total = [0]*n for i in range(m): P=list(input().split()) p = int(P[0]) - 1 if P[1] == 'WA' and cnt[p] == 0: total[p] += 1 if P[1] == 'AC' and cnt[p] == 0: cnt[p] = True ans = 0 for i in range(n): if cnt[i] == True: ans += total[i] print(sum(cnt),ans)" p02802,s335830091,Accepted,"n, m = map(int, input().split()) res1, res2 = 0, 0 l = [0] * (n + 1) for _ in range(m): p, s = input().split() p = int(p) if l[p] == -1: continue if s == ""AC"": res1 += 1 res2 += l[p] l[p] = -1 else: l[p] += 1 print(res1, res2)" p02802,s954820397,Accepted,"N,M = [int(i) for i in input().split()] submissions = {str(i):[] for i in range(1,N+1)} AC,WA = 0,0 for i in range(M): P,S = [j for j in input().split()] submissions[P].append(S) for i in submissions: if 'AC' not in submissions[i]: continue for j in submissions[i]: if j == 'AC': AC+=1 break WA +=1 print(AC,WA)" p02802,s449682213,Accepted,"N,M = [int(x) for x in input().split()] ac = [0]*(N+1) wa = [0]*(N+1) for i in range(M): p,s = input().split() if s ==""AC"" and ac[int(p)]==0: ac[int(p)]=1 if s==""WA"" and ac[int(p)]==0: wa[int(p)]+=1 ans = 0 answa = 0 for i in range(N+1): if ac[i]==1: ans+=1 answa+=wa[i] print(ans,answa)" p02802,s487274478,Accepted,"def main(): import sys input = sys.stdin.readline N, M = map(int, input().split()) ac = [False] * N wa = [0] * N for _ in range(M): it = iter(input().split()) p = int(next(it)) - 1 s = next(it) if s == 'AC': ac[p] = True else: if not ac[p]: wa[p] += 1 print(ac.count(True), sum(w for p, w in enumerate(wa) if ac[p])) if __name__ == '__main__': main() " p02802,s128169514,Accepted,"N, M = map(int, input().split()) WA = [0] * N AC = [0] * N for i in range(M): p,s = input().split() p = int(p) if AC[p-1] == 0: if s == ""AC"": AC[p-1] = 1 else: WA[p-1] += 1 wa = 0 for j in range(N): if AC[j] == 1: wa += WA[j] print(sum(AC),wa)" 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))" 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)" p02802,s903850406,Accepted,"N, M = map(int, input().split()) ac = [False for _ in range(N)] wa = [0 for _ in range(N)] ans_wa = 0 for _ in range(M): p, S = input().split() p = int(p) - 1 if S == ""AC"": if ac[p] == False: ac[p] = True ans_wa += wa[p] else: wa[p] += 1 ans_ac = ac.count(True) print(""{} {}"".format(ans_ac, ans_wa))" 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) " p02802,s430675343,Accepted,"N, M = map(int, input().split()) cleared = [0 for i in range(N)] wrong = [0 for i in range(N)] penalty = 0 for i in range(M): p, s = map(str, input().split()) p = int(p) - 1 if cleared[p] == 1: continue if s == ""AC"": cleared[p] = 1 penalty += wrong[p] else: wrong[p] += 1 print(sum(cleared), penalty)" p02802,s910436002,Accepted,"N, M = map(int, raw_input().split()) #print N, M state = [-1 for i in range(N)] pena = [0 for i in range(N)] WA = [0 for i in range(N)] for i in range(M): s = raw_input().split() p = int(s[0]) sc = s[1] #print p, sc p -= 1 if (state[p] == 0): continue if sc == 'WA': pena[p] += 1 else: state[p] = 0 ok = 0 pn = 0 for i in range(N): if state[i] == 0: ok += 1 pn += pena[i] print ok, pn " p02802,s481749847,Accepted,"N, M = map(int, input().split()) no = [0] * (N + 1) ok = 0 x = 0 for i in range(M): p, s = input().split() p = int(p) if s == 'AC' and no[p] != -1: ok += 1 x += no[p] no[p] = -1 elif s == 'WA' and no[p] != -1: no[p] += 1 print(ok, x) " p02802,s657685232,Accepted,"n,m=map(int,input().split()) wa_check=[0 for _ in range(n+1)] ac_check=[0 for _ in range(n+1)] for i in range(m): p,s=input().split() p=int(p) if(ac_check[p]==0): if(s=='AC'): ac_check[p]=1 else: wa_check[p]+=1 wa_ans=[wa_check[i] for i in range(n+1) if ac_check[i]!=0] print(sum(ac_check),sum(wa_ans)) " p02802,s713821117,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])" p02802,s180952187,Accepted,"n,m = map(int, input().split()) l = [[] for _ in range(n)] ac,wa = (0,0) for i in range(m): p,s = input().split() p = int(p) if s == ""AC"": if s not in l[p-1]: l[p-1].append(s) ac += 1 wa += l[p-1].count(""WA"") else: l[p-1].append(s) print(ac,wa)" p02802,s052786728,Accepted,"N, M = map(int,input().split()) ac = [0] * N wa = [0] * N for i in range(M): p, s = map(str,input().split()) num = int(p)-1 if s == 'WA' and ac[num] == 0: wa[num] += 1 elif s == 'AC' and ac[num] == 0: ac[num] += 1 for i in range(N): if ac[i] == 0: wa[i] = 0 print('{} {}'.format(sum(ac), sum(wa)))" p02802,s293195886,Accepted,"import sys input = sys.stdin.readline n,m=map(int,input().split()) num=[0]*(n+1) numcnt=[0]*(n+1) ans=0 cnt=0 for i in range(m): p,s=map(str,input().split()) p=int(p) if s==""WA"": num[p]+=1 if s==""AC"" and numcnt[p]!=1: ans+=num[p] cnt+=1 numcnt[p]=1 print(cnt,ans) " p02802,s109089533,Accepted,"import sys lines = sys.stdin.read().split(""\n"") n, m = map(int, lines[0].split()) ac_flags = [0] * (n + 1) wa_counter = [0] * (n + 1) ac_count = 0 wa_count = 0 for line in lines[1:-1]: p, s = line.split() p = int(p) if ac_flags[p] == 0: if s == ""AC"": ac_flags[p] = 1 ac_count += 1 wa_count += wa_counter[p] else: wa_counter[p] += 1 print ac_count, wa_count " p02802,s352461989,Accepted,"N, M = [int(x) for x in input().split()] ans = [0] * N pen = [0] * N for _ in range(M): ps, S = [x for x in input().split()] p = int(ps)-1 if S == 'WA': if ans[p] == 0: pen[p] += 1 else: ans[p] = 1 ans1 = 0 ans2 = 0 for a, p in zip(ans, pen): ans1 += a ans2 += (a*p) print(ans1, ans2) " p02802,s095160025,Accepted,"n, m = [int(i) for i in input().split()] ans = [input().split() for _ in range(m)] is_ac = [0 for i in range(n)] cnt_wa = [0 for i in range(n)] for p, s in ans: p = int(p) - 1 if is_ac[p]: continue if s == 'AC': is_ac[p] = 1 else: cnt_wa[p] += 1 cor = sum(is_ac) pena = 0 for p, c in enumerate(is_ac): if c: pena += cnt_wa[p] print(cor, pena)" p02802,s137430911,Accepted," N, M=(int(i) for i in input().split()) P=[[int(j)-1 if i==0 else j for i, j in enumerate(input().split())] for _ in range(M)] ac=""AC"" wa=""WA"" flag=[0]*N ans=0 pe=0 for i in range(M): if flag[P[i][0]]!=-1 and P[i][1]==ac: ans+=1 pe+=flag[P[i][0]] flag[P[i][0]]=-1 elif flag[P[i][0]]!=-1 and P[i][1]==wa: flag[P[i][0]]+=1 print(ans,pe) " p02802,s107619342,Accepted,"n,m=map(int,input().split()) data=[0]*n s=set() sum_wa=0 for i in range(m): p,a=input().split() p=int(p)-1 if p in s: continue else: if a=='WA': data[p]+=1 else: sum_wa+=data[p] s.add(p) print(len(s),sum_wa)" p02802,s332189624,Accepted,"# coding=utf-8 import collections get = lambda: int(raw_input().strip()) gets = lambda: map(int, raw_input().strip().split()) getss = lambda x: [gets() for _ in xrange(x)] N, M = gets() count = collections.Counter() penalty = 0 ac = set() for i in xrange(M): p, s = raw_input().split() p = int(p) if p in ac: continue if s == 'AC': ac.add(p) penalty += count[p] else: count[p] += 1 print len(ac), penalty " p02802,s345793642,Accepted,"N, M = map(int, input().split()) accepted = [False for _ in range(N)] wa = [0 for _ in range(N)] for _ in range(M): p, s = input().split() p = int(p) if not accepted[p - 1]: if s == 'AC': accepted[p - 1] = True else: wa[p - 1] += 1 correct = sum(accepted) penalty = sum([a * w for a, w in zip(accepted, wa)]) print(correct, penalty) " p02802,s683067729,Accepted,"N, M = map(int, input().split()) ps = [[i for i in input().split()] for i in range(M)] ac = 0 penalty = 0 check = [0 for i in range(N)] for i in range(M): p, S = ps[i] if check[int(p)-1] != -1: if S == ""AC"": ac += 1 penalty += check[int(p)-1] check[int(p)-1] = -1 if S == ""WA"": check[int(p)-1] += 1 print(""{} {}"".format(ac, penalty))" p02802,s056810382,Accepted,"N, M = map(int,input().split("" "")) ans = [0]*N wc_c = [0]*N pena = 0 for i in range(M): p, s = input().split("" "") p = int(p) - 1 s = str(s) if s == ""AC"" and ans[p] == 0: ans[p] = 1 pena += wc_c[p] elif s == ""WA"" and ans[p] == 0: wc_c[p] += 1 print(sum(ans), pena) " p02802,s011960499,Accepted,"N, M = map(int, input().split()) WAC = [0 for i in range(N)] TF = [0 for i in range(N)] for i in range(M): p, S = input().split() p = int(p)-1 if S == 'AC': TF[p] = 1 if TF[p] == 0 and S == 'WA': WAC[p] += 1 count = 0 for i in range(N): count += TF[i] * WAC[i] print(sum(TF), count) " p02802,s090577070,Accepted,"n, m = [int(i) for i in input().split()] wa = [0]*n ac = [0]*n for _ in range(m): p, s = input().split() if s == ""WA"": if ac[int(p)-1] == 0: wa[int(p)-1] += 1 else: ac[int(p)-1] += 1 print(n-ac.count(0), sum([wa[i] for i in range(n) if ac[i] >= 1]))" p02802,s591517657,Accepted,"n,m=map(int,input().split()) w,l=0,[0]*n for i in range(m): p,s=input().split() p=int(p)-1 if s=='AC': w+=l[p]*(l[p]>=0) l[p]=-1 else: l[p]+=(l[p]>=0) print(l.count(-1),w)" p02802,s511557876,Accepted,"n, m = map(int, input().split(' ')) problem = [0] * n ok=0 pen=0 i=0 while i < m: p, result = input().split(' ') p = int(p) - 1 if problem[p] < 0: pass else: if result == 'WA': problem[p] += 1 else: ok += 1 pen += problem[p] problem[p] = -1 i+=1 print('{} {}'.format(ok, pen)) " p02802,s930302610,Accepted,"import numpy as np N, M = map(int, input().split()) P = [] S = [] for _ in range(M): p, s = input().split() P.append(int(p)) S.append(s) AC = np.zeros(N) WA = np.zeros(N) for i in range(M): if AC[P[i]-1] == 0: if S[i] == 'WA': WA[P[i]-1] += 1 else: AC[P[i]-1] += 1 WA[AC == 0] = 0 print(int(sum(AC)), int(sum(WA)))" p02802,s416257239,Accepted,"N,M= map(int,input().split()) tempP = """" ac = [] wa = [] for count in range(N): ac.append(0) wa.append(0) for count in range(M): P,S = input().split() P = int(P) P -= 1 if ac[P] == 0: if S == ""AC"": ac[P] = 1 else: wa[P] +=1 a = 0 b = 0 for i in range(N): if ac[i] == 1: a += 1 b += wa[i] print(*[a, b]) " p02802,s032005911,Accepted,"import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N,M = map(int, readline().split()) PS = [line.split() for line in readlines()] AC = [False] * (N+1) WA_cnt = [0] * (N+1) penal = 0 for p,s in PS: p = int(p) if AC[p]: continue if s== b'WA': WA_cnt[p] += 1 else: AC[p] = True penal += WA_cnt[p] ac = sum(AC) print(ac, penal)" p02802,s189807412,Accepted,"n,m = map(int,input().split()) ac = [0]*n wa = [0]*n for i in range(m): p,s = input().split() p = int(p) if ac[p-1]: continue if s == 'AC': ac[p-1] = 1 else: wa[p-1] += 1 count_ac = 0 count_wa = 0 for i in range(n): count_ac += ac[i] if ac[i]: count_wa += wa[i] print(str(count_ac) + "" "" + str(count_wa))" p02802,s233234218,Accepted,"#!/usr/bin/env python3 N, M = map(int, input().split()) ps = [list(input().split()) for _ in range(M)] pen = [0]*N rig = [0]*N 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(cnt1, cnt2)" p02802,s806243683,Accepted,"import numpy as np n,m = map(int, input().split()) a = [False]*n b = [0]*n for i in range(m): p,s = map(str,input().split()) p = int(p)-1 if s == ""AC"": a[p] = True else: if a[p] == False: b[p]=b[p]+1 print(np.array(a).sum(),np.array(b)[np.array(a)].sum())" p02802,s068346847,Accepted,"N,M=map(int,input().split()) ST=['WA'] * N WA=[0]*N OK=0 NG=0 for i in range(M): c,s = map(str,input().split()) c = int(c) if s == 'WA': if ST[c-1] != 'AC': WA[c-1] += 1 else: if ST[c-1] != 'AC': ST[c-1] = 'AC' OK += 1 for i,s in enumerate(ST): if s != 'AC': WA[i] = 0 print(""{} {}"".format(OK, sum(WA)))" p02802,s674208256,Accepted,"n,m = map(int,input().split()) f = [False for i in range(n)] ac = 0 wa = [0 for i in range(n)] for i in range(m): p,s = input().split() p = int(p) - 1 if not f[p]: if s == ""WA"": wa[p] += 1 else: f[p] = True ac += 1 w = 0 for e,c in zip(f,wa): if e: w += c print(ac,w) " p02802,s938044538,Accepted,"n,m = map(int,input().split()) flag = dict() for i in range(m): q, s = input().split() if q not in flag: flag[q] = [0,0] if s == ""AC"": flag[q][0] += 1 else: flag[q][1] += 1 else: if flag[q][0] != 1: if s == ""AC"": flag[q][0] += 1 else: flag[q][1] += 1 ans = [0,0] for v in flag.values(): if v[0]: ans[0] += 1 ans[1] += v[1] print(ans[0],ans[1]) " p02802,s080577142,Accepted,"n, m = map(int, input().split()) ps = [list(map(str, input().split())) for _ in range(m)] wa = [0 for _ in range(n)] ac = set() for i, j in ps: if j == ""AC"": ac.add(i) else: if i not in ac: wa[int(i) - 1] += 1 for k in range(n): if str(k + 1) not in ac: wa[k] = 0 print(len(ac), sum(wa)) " p02802,s537852541,Accepted,"from collections import defaultdict N, M = map(int, input().split()) WA = {i : 0 for i in range(1,N+1)} AC = defaultdict(int) boollist = [False]*N for _ in range(M): p,s = input().split() p = int(p) if s == 'WA' and not boollist[p-1]: WA[p] += 1 elif s == 'AC': boollist[p-1] = True AC[p] = 1 print(sum(AC.values()), sum([a for a,b in zip(WA.values(), boollist) if b==True]))" p02802,s417764509,Accepted,"import sys input = sys.stdin.readline from collections import defaultdict (n, m), d, a, b = map(int, input().split()), defaultdict(int), 0, 0 for i in range(m): p, s = input()[:-1].split(); p = int(p) if d[p] == sys.maxsize: continue if s == 'WA': d[p] += 1 if s == 'AC': b += abs(d[p]); a += 1; d[p] = sys.maxsize print(a, b)" p02802,s452948297,Accepted,"n,m = map(int,input().split()) l = [1]*n a = 0 w = 0 for i in range(m): p,s = map(str,input().split()) p = int(p) if l[p-1]>0: if s == ""AC"": w+=l[p-1]-1 l[p-1] = 0 a+=1 else: l[p-1]+=1 print(a,w)" p02802,s473063625,Accepted,"n,m = map(int,input().split()) ac = 0 wa = 0 wa_d = {} ac_d = {} for i in range(1,n+1): ac_d[str(i)] = False wa_d[str(i)] = 0 for _ in range(m): p,s = input().split() if s == ""AC"": if ac_d[p]: pass else: wa += wa_d[p] ac += 1 ac_d[p] = True else: wa_d[p] += 1 print (ac,wa) " p02802,s396893132,Accepted,"n,m=map(int,input().split()) p=[0]*m s=[""""]*m flag=[0]*n pen=[0]*n penalty=0 for i in range(m): p[i],s[i]=input().split() if (flag[int(p[i])-1]==0): if (s[i]==""WA""): pen[int(p[i])-1]+=1 elif (s[i]==""AC""): flag[int(p[i])-1]=1 penalty+=pen[int(p[i])-1] print(sum(flag),penalty)" p02802,s546115772,Accepted,"import sys sys.setrecursionlimit(10 ** 7) read = sys.stdin.buffer.read input = sys.stdin.buffer.readline def inputS(): return input().rstrip().decode() readlines = sys.stdin.buffer.readlines N, M = map(int, input().split()) AC = [False]*(N+1) WA = [0]*(N+1) WAsum = 0 for _ in range(M): p, s = input().split() p = int(p) if AC[p]: continue if s == b""AC"": AC[p] = True WAsum += WA[p] else: WA[p] += 1 print(sum(AC), WAsum) " p02802,s993847494,Accepted,"n, m = map(int, input().split()) tmp = [0]*n wtmp = [0]*n for _ in range(m): P, s = map(str, input().split()) p = int(P) p -= 1 if not tmp[p] == 0: continue if s == 'AC': tmp[p] = 1 else: wtmp[p] += 1 ans1 = sum(tmp) ans2 = 0 for i in range(n): if tmp[i] == 1: ans2 += wtmp[i] print(ans1, ans2)" p02802,s886437500,Accepted,"#151c n,w=map(int,input().split()) ac=0 wa=[0]*n wa_cnt=[0]*n ac_flg=[0]*n for i in range(w): p,s=input().split() p=int(p)-1 if ac_flg[p]==1: continue else: if s=='AC': ac_flg[p]=1 ac+=1 wa[p] =wa_cnt[p] #wa_cnt=0 else: wa_cnt[p]+=1 wa_ans=0 for i in range(n): wa_ans+=wa[i] print(ac,wa_ans) " p02802,s599492068,Accepted,"N,M=map(int,input().split()) p=[] S=[] for i in range(M): x,y=input().split() p.append(int(x)-1) S.append(y) WA=[0 for i in range(N)] AC=[0 for i in range(N)] for i in range(M): if S[i]==""AC"": AC[p[i]]=1 else: if AC[p[i]]==0: WA[p[i]]+=1 ans1=sum(AC) ans2=0 for i in range(N): if AC[i]==1: ans2+=WA[i] print(ans1,ans2)" p02802,s841202274,Accepted,"n,m=map(int,input().split()) A=[[0,0] for i in range(n)] #ACしたか、WA数 AC=0 pen=0 for i in range(m): a,b=map(str,input().split()) a=int(a) if b==""AC"": A[a-1][0]=1 elif b==""WA"" and A[a-1][0]==0: A[a-1][1]+=1 for i in range(n): if A[i][0]==1: AC+=1 pen+=A[i][1] print(AC,pen)" p02802,s136480112,Accepted,"n, m = map(int, input().split()) result = {} fin = {} success = 0 wa_sum = 0 for i in range(m): p, s = map(str, input().split()) if not (p in result): result[p] = 0 fin[p] = False if s == 'AC' and not fin[p]: fin[p] = True success += 1 wa_sum += result[p] elif not fin[p]: result[p] += 1 print(success, wa_sum) " p02802,s254205096,Accepted,"n, m = map(int, input().split()) submissions = [list(input().split()) for _ in range(m)] count_penalty = [0] * (n + 1) count_ac = [0] * (n + 1) for i in range(m): ploblem = int(submissions[i][0]) if submissions[i][1] == ""AC"": count_ac[ploblem] = 1 elif count_ac[ploblem] != 1 and submissions[i][1] == ""WA"": count_penalty[ploblem] += 1 for i in range(n + 1): if count_ac[i] != 1: count_penalty[i] = 0 print(""{} {}"".format(count_ac.count(1), sum(count_penalty))) " p02802,s994093049,Accepted,"n,m=map(int,input().split()) acl=[""WA""]*n wal=[0]*n ans=0 for i in range(m): p,s=input().split() p=int(p)-1 if(acl[p]==""WA""): if s==""WA"": wal[p]+=1 else: ans+=wal[p] acl[p]=""AC"" print(acl.count(""AC""),ans) " p02802,s520329360,Accepted,"n,m=map(int,input().split()) l1=[list(input().split()) for i in range(m)] l2=[""WA""]*n l3=[0]*n account=0 wacount=0 for i in range(m): if l1[i][1]==""WA"" and l2[int(l1[i][0])-1]==""WA"": wacount+=1 l3[int(l1[i][0])-1]+=1 if l1[i][1]==""AC"": l2[int(l1[i][0])-1]=""AC"" for i in range(n): if l2[i]==""AC"": account+=1 else: wacount-=l3[i] print(account,wacount)" p02802,s898849030,Accepted,"N,M = map(int,input().split()) List = [] ans = [0 for i in range(N+1)] WA = [0 for i in range(N+1)] for i in range(M): p,S = input().split() p = int(p) if ans[p] == 0: if S == ""AC"": ans[p] = 1 else: WA[p] += 1 A = sum(ans) W= 0 for i in range(N+1): W += ans[i] * WA[i] print(A,W) " p02802,s522932745,Accepted,"from sys import stdin n,m = [int(x) for x in stdin.readline().rstrip().split()] a = [] for i in range(m): a.append([x for x in stdin.readline().rstrip().split()]) ac = [0] * n wa = [0] * n WA = 0 for i in range(m): if a[i][1] == 'WA': wa[int(a[i][0])-1] += 1 if a[i][1] == 'AC': if ac[int(a[i][0])-1] == 0: WA += wa[int(a[i][0])-1] ac[int(a[i][0])-1] = 1 print(sum(ac),WA) " p02802,s740078326,Accepted,"ac={} wa={} ans1=0 ans2=0 N,M=input().split("" "") for i in range(int(M)): num,sa=input().split("" "") if sa=='AC': if num in ac: continue else: ans1+=1 ac[num]=1 if num in wa: ans2+=wa[num] else: if num in wa: wa[num]+=1 else: wa[num]=1 print(ans1,ans2) " p02802,s883942761,Accepted,"n, m = map(int, input().split()) ac = 0 wa = 0 dwa = {} d = {} for i in range(m): p, s = input().split() if d.get(p) == ""AC"": continue if p not in dwa: dwa[p] = 0 if s == ""WA"": dwa[p] += 1 else: ac += 1 wa += dwa[p] d[p] = s print(ac, wa)" p02802,s766025229,Accepted,"n, m = map(int, input().split()) ac = [False] * n wa = [0] * n for _ in range(m): prob, s = input().split() p = int(prob) - 1 if not ac[p]: if s == 'AC': ac[p] = True else: wa[p] += 1 penalty = 0 for i in range(n): if ac[i]: penalty += wa[i] print(sum(ac), penalty)" p02802,s053852961,Accepted,"import numpy as np n,m = map(int,input().split()) base = np.zeros(n) pena = np.zeros(n) for i in range(m): s = list(input().split()) if (s[1] == ""WA"") and (base[int(s[0])-1] == 0): pena[int(s[0])-1] += 1 elif (s[1] == ""AC""): base[int(s[0])-1] = 1 ans_1 = np.multiply(base,pena) print(int(np.sum(base)),int(np.sum(ans_1)))" p02802,s145860343,Accepted,"n,m = map(int,input().split()) a = [0]*n ac,wa = 0,0 for i in range(m): p,s = map(str,input().split()) p = int(p) if s == ""AC"" and a[p-1] != -1: ac +=1 wa += a[p-1] a[p-1] = -1 elif s == ""WA"" and a[p-1] != -1: a[p-1] += 1 print(ac,wa) " p02802,s997774758,Accepted,"n,m=map(int,input().split()) q=['WA' for i in range(n)] w=[0 for i in range(n)] ans=0 pen=0 for i in range(m): p,s=input().split() pi=int(p)-1 if s=='AC' and q[pi]=='WA': ans+=1 pen+=(w[pi]) q[pi]='AC' else: w[pi]+=1 print(ans,pen) " p02802,s801464953,Accepted,"n,m = map(int, input().split("" "")) a=[list(map(str, input().split("" ""))) for i in range(m)] check = [False for i in range(n + 1)] times = [False for i in range(n + 1)] for i in range(m): #print(check) #print(a[i]) if check[(int)(a[i][0])] == False and a[i][1] == ""AC"": #print(""OK"") check[(int)(a[i][0])] = True elif check[(int)(a[i][0])] == False and a[i][1] == ""WA"": times[(int)(a[i][0])] += 1 #print(""MISS"") for i in range(n + 1): if check[i] == False: times[i] = 0 print(check.count(True), sum(times))" p02802,s299359913,Accepted,"n, m = map(int, input().split()) ac = [0]*n wa = [0]*n for i in range(m): p, s = input().split() if s == 'WA' and ac[int(p)-1] == 0: wa[int(p)-1] += 1 elif s == 'AC' and ac[int(p)-1] == 0: ac[int(p)-1] += 1 print('%d %d' % (sum(ac), sum([wa[k] for k in [i for i, j in enumerate(ac) if j != 0]])))" p02802,s308298491,Accepted,"n,m=map(int,input().split()) num = [1]*(n + 1) pena = [0]*(n + 1) AC_cnt = 0 WA_cnt = 0 for i in range(m): p,s=input().split() if s == 'AC': if num[int(p)]: num[int(p)] = 0 AC_cnt += 1 WA_cnt += pena[int(p)] else: pena[int(p)] += 1 print(AC_cnt,WA_cnt) " p02802,s180539853,Accepted,"n,m = map(int,input().split(' ')) score = 0 penalty = 0 penalties = {} acs = set() for _ in range(m): num,result = input().split(' ') if num in acs: continue if result == ""WA"": if num in penalties: penalties[num] +=1 else: penalties[num] =1 else: score +=1 if num in penalties: penalty += penalties[num] acs.add(num) print(score,penalty)" p02802,s003401647,Accepted,"n,m=map(int,input().split()) l=[[0,0] for i in range(n)] for i in range(m): p,s=input().split() p=int(p) if s==""AC"": if l[p-1][0]!=1: l[p-1][0]=1 else: if l[p-1][0]!=1: l[p-1][1]+=1 ac=0 wa=0 for i in range(len(l)): ac+=l[i][0] if l[i][0]!=0: wa+=l[i][1] print(ac,wa)" p02802,s161625893,Accepted,"N,M=map(int,input().split()) number=[0]*N ac,wa,=0,0 for m 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)" p02802,s139940198,Accepted,"N,M = list(map(int,input().split())) lac = [0]*(N+1) lpcnt = [0]*(N+1) for i in range(M): s = input().split() n = int(s[0]) if s[1] == ""AC"": lac[n] =1 continue if s[1] == ""WA"" and lac[n] == 0: lpcnt[n] += 1 cnt = 0 for i in range(N+1): if lac[i] == 1: cnt += lpcnt[i] print(sum(lac), end="" "") print(cnt) " p02802,s586408058,Accepted,"import sys input = sys.stdin.readline N, M = map(int, input().split()) t = [0] * (N + 1) vis = set() for _ in range(M): p, s = input().split() p = int(p) if p in vis: continue if s == ""AC"": vis.add(p) else: t[p] += 1 res = 0 for i in range(N + 1): if i in vis: res += t[i] print(len(vis), res)" p02802,s208588102,Accepted,"N, M = map(int, input().split()) PS = [input().split() for i in range(M)] AC_and_penalty = {i:[False, 0] for i in range(1, N+1)} for p, s in PS: _AC_and_penalty = AC_and_penalty[int(p)] if _AC_and_penalty[0]: continue else: if s == ""AC"": _AC_and_penalty[0] = True else: _AC_and_penalty[1] += 1 num_AC = 0 penalty = 0 for cond, p in AC_and_penalty.values(): if cond: num_AC += 1 penalty += p print(""{} {}"".format(num_AC, penalty)) " p02802,s795969570,Accepted,"n,m = map(int,input().split()) j = [0]*n w = [0]*n wa = 0 ac = 0 for i in range(m): p,s = input().split() p = int(p)-1 if s == 'AC' and j[p] == 0: ac += 1 j[p] = 1 wa += w[p] elif s == 'WA' and j[p] == 0: w[p] += 1 print(ac,wa)" p02802,s719060877,Accepted,"N,M = map(int,input().split()) wa_cnt = [0]*N ac_flag = [False]*N for _ in range(M): p,S = input().split() p = int(p)-1 if not ac_flag[p]: if S == 'WA': wa_cnt[p] += 1 else: ac_flag[p] = True print(sum(ac_flag), sum(c for c,f in zip(wa_cnt,ac_flag) if f))" p02802,s777104837,Accepted,"n,m=map(int,input().split()) l=[0]*n ll=[0]*n no_ac=0 no_pen=0 for i in range(m): a,b=map(str,input().split()) a=int(a) if b=='AC': if l[a-1]==0: no_ac+=1 l[a-1]=1 else: if l[a-1]==0: ll[a-1]+=1 for i in range(n): if l[i]==1: no_pen+=ll[i] print(no_ac,no_pen)" p02802,s228472637,Accepted,"N, M = map(int, input().split()) S=[[0, """"] for j in range(M)] ACcheck=[False for j in range(N)] AC=0 WA=[0 for j in range(N)] WA2 = 0 for i in range(M): ps = input().split() S[i][0]=int(ps[0]) S[i][1]=ps[1] for i in range(M): if S[i][1]==""AC"": if ACcheck[S[i][0]-1]==False: AC+=1 ACcheck[S[i][0]-1]=True WA2+=WA[S[i][0]-1] else: if ACcheck[S[i][0]-1]==False: WA[S[i][0]-1]+=1 print(AC, WA2) " p02802,s159217013,Accepted,"n, m = map(int, input().split()) ps = [input().split() for _ in range(m)] ac = [0] * n wa = [0] * n for p, s in ps: p = int(p) - 1 if ac[p] == 0: if s == ""AC"": ac[p] = 1 else: wa[p] += 1 wa = [ac[i] * wa[i] for i in range(n)] print(sum(ac),sum(wa))" p02802,s019122187,Accepted,"N,M=map(int,input().split()) L=[0]*N A=0 W=0 tmp=[0]*N for i in range(M): x,y=input().split() t=int(x) if L[t-1]==0: if y==""WA"": tmp[t-1]+=1 else: A+=1 W+=tmp[t-1] L[t-1]=1 print(A,W)" p02802,s588172849,Accepted,"n,m=map(int,input().split()) acf,waf=[0]*n,[0]*n ac,wa=0,0 for i in range(m): x,y=input().split() x=int(x) if y=='AC': if acf[x-1]==0: ac+=1 wa+=waf[x-1] acf[x-1]+=1 else: waf[x-1]+=1 print(ac,wa) " p02802,s143904485,Accepted,"n, m = map(int, input().split()) ac = [False] * n wa = [0] * n res_ac = 0 res_wa = 0 for _ in range(m): p, s = input().split() p = int(p) if s == ""AC"": if not ac[p-1]: ac[p-1] = True res_ac += 1 res_wa += wa[p-1] else: wa[p-1] += 1 print(res_ac, res_wa)" p02802,s113055510,Accepted,"n, m = map(int, input().split()) q_re = set() ac = 0 wa = 0 dic_wa = {} for i in range(m): q, re = input().split() if(re == ""WA"" and q not in q_re): if(q not in dic_wa): dic_wa[q] = 1 else: dic_wa[q] += 1 if(re == ""AC"" and q not in q_re): ac += 1 q_re.add(q) if(q in dic_wa): wa += dic_wa[q] print(ac, wa)" p02802,s425598081,Accepted,"n, m = map(int, input().split()) ps = [input().split() for _ in range(m)] all_ac = set(int(p) for p,s in ps if s=='AC') ac = set() pena_cnt = 0 ac_cnt = 0 for p,s in ps: p = int(p) if p in all_ac: if p not in ac: if s == 'WA': pena_cnt += 1 else: ac_cnt += 1 ac.add(p) print(ac_cnt, pena_cnt)" p02802,s869077498,Accepted,"N, M = map(int, input().split()) sub = [[0, 0] for _ in range(N)] # 0: WC_num, 1: AC ac, penalty = 0, 0 for _ in range(M): p, s = input().split() p = int(p) if s == 'WA': sub[p-1][0] += 1 elif s == 'AC' and sub[p-1][1] == 0: sub[p-1][1] = 1 ac += 1 penalty += sub[p-1][0] print(ac, penalty)" p02802,s309038058,Accepted,"N,M=map(int,input().split()) AC=[0]*N WA=[0]*N wa=0 for i in range(M): p,s=input().split() p=int(p)-1 if AC[p]==0 and s==""AC"": AC[p]=1 wa+=WA[p] WA[p]+=1 print(sum(AC),wa)" p02802,s168590002,Accepted,"from collections import defaultdict n,m = list(map(int, input().split("" ""))) dic = defaultdict(lambda : [0,0]) for i in range(m): task,status = input().split("" "") if status == ""AC"": dic[task][0] += 1 if dic[task][0] == 0 and status == ""WA"": dic[task][1] += 1 acCnt = 0 waCnt = 0 for _, v in dic.items(): a,b = v if a > 0: acCnt += 1 waCnt += b print(str(acCnt) + "" "" + str(waCnt)) " p02802,s474686720,Accepted,"n,m = map(int, input().split()) x = [False]*n y = [0]*n for i in range(m): a,b = input().split() a = int(a) - 1 if b =='AC' and x[a] == False: x[a] = True elif b == 'WA' and x[a] == False: y[a] += 1 ac = 0 wa = 0 for i in range(n): if x[i]: ac += 1 wa += y[i] print(ac,wa)" p02802,s133305247,Accepted,"# -*- coding: utf-8 -*- n,m = map(int, input().split()) ps = [input().split() for _ in range(m)] wa = [0]*(n+1) solve = [False for _ in range(n+1)] for p,s in ps: p = int(p) if s==""AC"": solve[p] = True else: if not solve[p]: wa[p] += 1 ra = 0 rw = 0 for i in range(1,n+1): if solve[i]: ra += 1 rw += wa[i] print(ra,rw) " p02802,s609383383,Accepted,"n, m = map(int, input().split()) s = [[] for i in range(n)] for i in range(m): p, S = input().split() s[int(p) - 1] += [S] print(sum('AC' in si for si in s), sum(si[:si.index('AC')].count('WA') if 'AC' in si else 0 for si in s))" p02802,s950789101,Accepted,"n,m = map(int,input().split()) ps = [] for _ in range(m): p,s = map(str,input().split()) p = int(p)-1 ps.append([p,s]) ac = [-1 for _ in range(n)] wa = [0 for _ in range(n)] ans_ac = 0 ans_wa = 0 for i in range(m): if ps[i][1] == 'WA': if ac[ps[i][0]] == -1: wa[ps[i][0]] += 1 else: if ac[ps[i][0]] == -1: ac[ps[i][0]] = 1 ans_ac += 1 for i in range(n): if ac[i] != -1: ans_wa += wa[i] print(ans_ac,ans_wa) " p02802,s107043249,Accepted,"n,m=map(int,input().split()) ac=[False]*n wa=[0]*n for i 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,sep="" "") " p02802,s107350096,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])" p02802,s121539736,Accepted,"n, m = map(int, input().split()) submission = [] for i in range(n): submission.append([]) for i in range(m): pi, si = input().split() submission[int(pi) - 1].append(si) n_ac = 0 n_penalty = 0 for i in range(n): if ""AC"" in submission[i]: n_ac += 1 ac_index = submission[i].index('AC') n_penalty += ac_index print(n_ac, n_penalty)" p02802,s629065670,Accepted,"N, M = map(int, input().split()) P = [] S = [] flag = [False for i in range(0, N)] for i in range(0, M): x, y = map(str, input().split()) P.append(int(x)-1) S.append(y) ans = [0, 0] wa = [0 for i in range(0, N)] for i in range(0, M): if not flag[P[i]]: if S[i] == 'AC': flag[P[i]] = True ans[0] += 1 ans[1] += wa[P[i]] else: wa[P[i]] += 1 print(*ans) " p02802,s823164852,Accepted,"from sys import stdin,setrecursionlimit setrecursionlimit(10 ** 6) input = stdin.readline N, M = map(int, input().split()) ac = [False] * N # index means p wa = [0] * N # index means p wa_cnt = 0 for i in range(M): p, s = input().split() p = int(p) - 1 # index starts from 0 if ac[p] is False and s == ""AC"": wa_cnt += wa[p] ac[p] = True elif s == ""WA"": wa[p] += 1 print(ac.count(True), wa_cnt)" p02802,s786358104,Accepted,"N,M=map(int,input().split()) WA=[0 for _ in range(N+1)] solved=[False for _ in range(N+1)] AC=0 for _ in range(M): P,S=input().split() P=int(P) if S==""AC"" and solved[P]==False: AC+=1 solved[P]=True elif S==""WA"" and solved[P]==False: WA[P]+=1 U=0 for i in range(1,N+1): if solved[i]: U+=WA[i] print(AC,U) " p02802,s143410073,Accepted,"import math N, M = map(int, input().split()) judge = [0]*N ac = 0 wa = 0 for i in range(M): p, S = input().split() if judge[int(p)-1] == 'AC': pass elif S == 'AC': wa += judge[int(p)-1] judge[int(p)-1] = 'AC' ac += 1 else: judge[int(p)-1] += 1 print(ac,wa)" p02802,s967293478,Accepted,"N, M = map(int, input().split()) err_list = [0] * N score_list = ['WA'] * N sum_error = 0 sum_ac = 0 for i in range(M): idx, s = input().split() idx = int(idx) # 既にACとなった問題については評価対象から外す if score_list[idx - 1] == 'WA': # scoreによって分岐する if s == 'WA': err_list[idx - 1] += 1 else: score_list[idx - 1] = 'AC' sum_ac += 1 sum_error += err_list[idx - 1] print(sum_ac, sum_error)" p02802,s354977875,Accepted,"n, m = map(int, input().split()) dic = {} for i in range(1, n+1): dic[i] = 0 a = 0 b = 0 for i in range(m): p, s = input().split() p = int(p) if s == 'AC' and dic[p] != 'AC': b += dic[p] dic[p] = 'AC' elif dic[p] != 'AC': dic[p] += 1 for i in range(1, n+1): if dic[i] == 'AC': a += 1 print(a, b)" p02802,s888231195,Accepted,"N, M = map(int, input().split()) question = {} wa = {} ac_count = 0 wa_count = 0 for i in range(M): q, s = input().split() question.setdefault(q, '') wa.setdefault(q, 0) if s == 'AC': if question[q] == 'AC': continue else: question[q] = 'AC' ac_count += 1 wa_count += wa[q] else: wa[q] += 1 print(ac_count, wa_count) " p02802,s285818040,Accepted,"N,M = map(int,input().split()) W = dict() A = dict() ac = 0 pt = 0 Q = [] for i in range(M): p, S = input().split() p = int(p) if not p in W.keys(): W[p] = 0 A[p] = 0 if S == 'WA': W[p] += 1 if S == 'AC': if A[p] != 'AC': A[p] = 'AC' pt += W[p] ac += 1 print(ac,pt)" p02802,s741254500,Accepted,"def solve(): N, M = map(int, input().split()) ac, wa= 0, 0 mp = [0] * N for _ in range(M): p, s = input().split() p = int(p) - 1 if s == ""AC"": if mp[p] != -1: ac += 1 wa += mp[p] mp[p] = -1 else: if mp[p] != -1: mp[p] += 1 return ac, wa print(*solve())" p02802,s089814129,Accepted,"n, m = input().split() n = int(n) m = int(m) # 正解した問題を入れるlist correct = 0 pn = 0 done_list = [0] * n pn_list = [0] * n for i in range(m): a,b=input().split() if done_list[int(a)-1] == 0 and b == ""AC"": done_list[int(a)-1] += 1 correct += 1 pn += pn_list[int(a) - 1] elif b == ""WA"": pn_list[int(a) - 1] += 1 print(correct, pn)" p02802,s055048266,Accepted,"from collections import Counter N, M = map(int, input().split()) point = 0 answer_problems = set() wrong_count = Counter() for _ in range(M): p, s = input().split() if p in answer_problems: continue if s == 'AC': point += wrong_count[p] answer_problems.add(p) else: wrong_count[p] += 1 print(len(answer_problems), point)" p02802,s457358968,Accepted,"n, m = map(int, input().split()) ans = 0 lstn = [False for i in range(n)] lstc = [0 for i in range(n)] for i in range(m): p, s = input().split() pp = int(p) status = lstn[pp-1] if not status: if s == ""WA"": lstc[pp-1] += 1 else: lstn[pp-1] = True seikai = lstn.count(True) for i in range(len(lstn)): tf = lstn[i] if tf: ans += lstc[i] print(seikai, ans)" p02802,s510100653,Accepted,"N, M = [int(s) for s in input().split()] AC = [0] * 10 ** 5 WA = [0] * 10 ** 5 wa = 0 for _ in range(M): p, s = input().split() p = int(p) if AC[p] == 0: if s == 'WA': WA[p] += 1 else: AC[p] += 1 print(sum(AC), sum(map(lambda x: x[0] * x[1], zip(AC, WA))))" p02802,s767232054,Accepted,"N,M=map(int,input().split()) AC=[0]*N WA=[0]*N for i in range(M): p,s=input().split() p=int(p)-1 if AC[p]==0: if s=='AC': AC[p]+=1 else: WA[p]+=1 for i in range(N): if AC[i]==0: WA[i]=0 print(sum(AC),sum(WA)) " p02802,s011132215,Accepted,"def solve(string): n, m, *ps = string.split() n = int(n) ac = [0] * n wa = [0] * n for p, s in zip(*[iter(ps)] * 2): p = int(p) - 1 if s == ""AC"": ac[p] = 1 elif not ac[p]: wa[p] += 1 return ""{} {}"".format(sum(ac), sum([w * a for a, w in zip(ac, wa)])) if __name__ == '__main__': import sys print(solve(sys.stdin.read().strip()))" p02802,s608172195,Accepted,"n, m = list(map(int, input().split())) S = [input().split() for _ in range(m)] S = [[int(s[0]), s[1]] for s in S] ac = [0] * n wa = [0] * n for s in S: if s[1] == 'AC': ac[s[0] - 1] = 1 continue elif ac[s[0] - 1] == 0: wa[s[0] - 1] += 1 continue wa = [0 if ac[i] == 0 else wa[i] for i in range(n)] ans = ' '.join(list(map(str, [sum(ac), sum(wa)]))) print(ans) " p02802,s559894637,Accepted,"N,M = [int(x) for x in input().split()] count = [0]*N ac = 0 wa = 0 ireta = [] for i in range(M): a,b = input().split() a = int(a) if b == ""AC"" and count[a-1] == 0: count[a-1] = 1 ac += 1 elif count[a-1] == 0: ireta.append(a) wa += 1 for i in range(len(ireta)): if count[ireta[i]-1] == 0: wa -= 1 print(ac,wa)" p02802,s648968550,Accepted,"N, M = map(int, input().split()) answer = [0] * N penalty = [0] * N P = 0 for i in range(M): p_tmp, s_tmp = input().split() p_tmp = int(p_tmp) - 1 if(answer[p_tmp] == 0): # 正解 if s_tmp == 'AC': answer[p_tmp] = 1 P += penalty[p_tmp] else: penalty[p_tmp] += 1 print(sum(answer), P)" p02802,s909501249,Accepted,"n,m = map(int, input().split()) ac_count = 0 wa_count = 0 p_dict = {str(i):[0,0] for i in range(1, n+1)} for m_i in range(m): p,s = input().split() if p_dict[p][1] == 0: if s=='WA': p_dict[p][0] += 1 elif s=='AC': p_dict[p][1] += 1 for val in p_dict.values(): if val[1] == 1: ac_count += 1 wa_count += val[0] print(ac_count, wa_count)" p02802,s496811398,Accepted,"N, M = map(int, input().split()) ps = [[] for _ in range(N)] for i in range(M): p, s = input().split() p = int(p) - 1 ps[p].append(s) wa = 0 ac = 0 for ss in ps: tmp_wa = 0 for s in ss: if s == ""WA"": tmp_wa += 1 else: ac += 1 wa += tmp_wa break print(""{} {}"".format(ac, wa))" p02802,s416134863,Accepted,"n,m = map(int,input().split()) cor = set() pens = {} for i in range(m): p,s = input().split() if s==""AC"": cor.add(p) else: if not p in cor: if p in pens: pens[p] += 1 else: pens[p] = 1 pen = 0 for x in cor: if x in pens: pen += pens[x] print(str(len(cor))+"" ""+str(pen))" p02802,s239962667,Accepted,"n,m=map(int,input().split()) ps=list(list(input().split()) for _ in range(m)) wal=[0]*n acl=[0]*n for p,s in ps: p=int(p)-1 if s=='AC' and acl[p] ==0: acl[p]+=1 elif s=='WA' and acl[p] ==0: wal[p]+=1 wa=0 for i,ac in enumerate(acl): if ac == 1: wa+=wal[i] print(sum(acl),wa)" p02802,s770791225,Accepted,"n,m=map(int,input().split()) AC=[0]*n cnt=[0]*n ans=0 for i in range(m): p,s=input().split() p=int(p) s=str(s) if s=='WA' and AC[p-1]==0: cnt[p-1]+=1 if s=='AC' and AC[p-1]==0: AC[p-1]=1 ans+=cnt[p-1] print(sum(AC),ans)" p02802,s063214348,Accepted,"from collections import defaultdict import sys input = sys.stdin.readline m = defaultdict(int) ac = {} N, M = list(map(int, input().split())) pena = 0 for _ in range(M): p, s = input().split() p = int(p) s = s.strip() if s == ""AC"": if p not in ac: pena += m[p] ac[p] = 1 else: if p not in ac: m[p] += 1 print(""{} {}"".format(len(ac.keys()), pena)) " p02802,s014287177,Accepted,"N, M = map(int, input().split()) ac = 0 wa = 0 hist_ac = [0] * N hist_wa = [0] * N for _ in range(M): p, s = input().split() p = int(p) - 1 if hist_ac[p] == 0: if s == 'AC': hist_ac[p] = 1 ac += 1 wa += hist_wa[p] else: hist_wa[p] += 1 print(ac, wa) " p02802,s854321362,Accepted,"N,M=map(int,input().split()) pn_num=0 WA_list=[0]*N AC_list=[0]*N for _ in range(M): pi,Si=input().split() pi=int(pi) if Si=='AC': if AC_list[pi-1]==0: pn_num+=WA_list[pi-1] AC_list[pi-1]=1 else: WA_list[pi-1]+=1 print(sum(AC_list),pn_num)" p02802,s952902723,Accepted,"n, m = map(int, input().split()) c = [input().split() for i in range(m)] for i in range(m): c[i][0] = int(c[i][0]) AC, WA = 0, 0 acwa = [[0, 0] for i in range(n)] for i in range(m): if acwa[c[i][0] - 1][0] == 0: if c[i][1] == 'AC': acwa[c[i][0] - 1][0] += 1 AC += 1 WA += acwa[c[i][0] - 1][1] else: acwa[c[i][0] - 1][1] += 1 print(AC, WA)" p02802,s147972941,Accepted,"n,m=map(int,input().split()) a=[list(input().split()) for _ in range(m)] ac=[True]*n d=[0]*n tw=0 ta=0 for i in a: j=int(i[0])-1 if (ac[j]): if (i[1]==""WA""): d[j]+=1 else : tw+=d[j] ta+=1 ac[j]=False print(ta,tw)" p02802,s838548934,Accepted,"from collections import defaultdict a,b = map(int,input().split()) k=defaultdict(lambda:defaultdict(int)) for _ in range(b): p,s = input().split() if k[p].get('AC'): continue k[p][s] += 1 x = y = 0 for i,j in k.items(): if j.get('AC'): x+=1 if j.get('WA'): y+=j['WA'] # print(i,j) print(x,y)" p02802,s207475499,Accepted,"n,m=map(int,input().split()) ac=[0]*(n+1) wa=[0]*(n+1) for i in range(m): a,b=map(str,input().split()) a=int(a) if ac[a]==0: if b=='WA': wa[a]+=1 else: ac[a]=1 print(sum(ac)) ans=0 for i in range(n+1): if ac[i]==1: ans+=wa[i] print(ans)" p02802,s173413366,Accepted,"n, m = map(int, input().split()) ac = [False] * n wa = [0] * n u, v = 0, 0 for i in range(m): p, s = input().split() p = int(p) if ac[p - 1]: continue if s == 'AC': ac[p - 1] = True u += 1 v += wa[p - 1] elif s == 'WA': wa[p - 1] += 1 print(u, v)" p02802,s901471779,Accepted,"n, m = map(int, input().split()) ac = set() wa = {} for i in range(m): p, s = input().split() if s == 'AC': ac.add(p) wa[p] = wa.get(p, 0) else: if not p in ac: wa[p] = wa.get(p, 0)+1 ans = sum([wa[i] for i in ac]) print(len(ac), ans) " p02802,s133579498,Accepted,"N, M = map(int, input().split()) a, w = 0, 0 P = set() W = {} for _ in range(M): p, S = map(str, input().split()) if p in P: continue if S == 'WA': W.setdefault(p, 0) W[p] += 1 if S == 'AC': a += 1 P.add(p) if p in W: w += W[p] print(a, w)" p02802,s195448820,Accepted,"n, m = map(int, input().split()) tocni = [0 for i in range(n + 1)] correct = wrong = 0 for i in range(m): p, s = map(str, input().split()) p = int(p) if s == ""AC"" and tocni[p] != 1: correct += 1 wrong -= tocni[p] tocni[p] = 1 if s == ""WA"" and tocni[p] != 1: tocni[p] -= 1 print(correct, wrong) " p02802,s046511017,Accepted,"N,M=map(int,input().split()) L=[0]*N R=[0]*N right=0 pena=0 for _ in range(M): p,s=input().split() p=int(p) p-=1 if R[p]==0: if s=='AC': right+=1 R[p]=1 pena+=L[p] else: L[p]+=1 print(right,pena)" p02802,s846878637,Accepted,"n,m=list(map(int,input().split())) ac,wa=0,0 aclis=[0]*n walis=[0]*n for i in range(m): p,s=input().split() p = int(p) if s == ""AC"" and aclis[p-1] == 0: aclis[p-1] = 1 ac += 1 wa += walis[p-1] elif s == ""WA"" and aclis[p-1] == 0: walis[p-1] += 1 print(ac,wa)" p02802,s691234559,Accepted,"n, m = map(int, input().split()) ac = [False] * n pena = [0] * n acCnt = 0 waCnt = 0 for i in range(m): p, s = input().split() p = int(p) - 1 if ac[p]: continue if s == 'AC': ac[p] = True acCnt += 1 waCnt += pena[p] else: pena[p] += 1 print(acCnt, waCnt)" p02802,s667037414,Accepted,"N,M = map(int, input().split()) p = [] S = [] acnum = [-1]*N for i in range(M): tmp1,tmp2 = input().split() p.append(int(tmp1)) S.append(tmp2) account = 0 wacount = [0]*N waans = 0 for i in range(M): if acnum[p[i] - 1] == -1: if S[i] == ""AC"": acnum[p[i] - 1] = 1 account += 1 waans += wacount[p[i] - 1] else: wacount[p[i] - 1] += 1 print(account,waans)" p02802,s346850389,Accepted,"n, m = map(int, input().split()) p = [0] * m s = [0] * m ac = [0] * n wa = [0] * n for i in range(m): p[i], s[i] = input().split() p = [int(i) for i in p] for i in range(m): if ac[p[i] - 1] == 0: if s[i] == 'AC': ac[p[i] - 1] = 1 else: wa[p[i] - 1] += 1 for i in range(n): if ac[i] == 0: wa[i] = 0 print(sum(ac), sum(wa)) " p02802,s650871934,Accepted,"n, m = map(int, input().split()) is_ac = [False]*n ac = 0 was = [0]*n for _ in range(m): p, s = input().split() p = int(p) - 1 if s=='AC' and (not is_ac[p]): ac += 1 is_ac[p] = True if s=='WA' and (not is_ac[p]): was[p] += 1 wa = 0 for i in range(n): if is_ac[i]: wa += was[i] print(ac, wa)" p02802,s404945419,Accepted,"N, M = map(int, input().split()) PS = [] for i in range(M): p, s = input().split() PS.append([int(p), s]) ac = [False] * N pena = [0] * N for p, s in PS: p -= 1 if ac[p]: continue if s == 'AC': ac[p] = True else: pena[p] += 1 a_cnt = 0 w_cnt = 0 for i in range(N): if ac[i]: a_cnt += 1 w_cnt += pena[i] print(a_cnt, w_cnt)" p02802,s071111018,Accepted,"N,M = map(int,input().split()) d = {} P = {} for i in range(1,N+1): d[i] = 0 P[i] = 0 for i in range(M): p,s = map(str,input().split()) q = int(p) if d[q] == 1: continue else: if s == 'AC': d[q] = 1 else: P[q] += 1 ans1 = 0 ans2 = 0 for i in range(1,N+1): if d[i] == 1: ans1 += 1 ans2 += P[i] print(ans1,ans2)" p02802,s071664644,Accepted,"n,m = map(int,input().split()) if m != 0: l = [list(input().split()) for i in range(m)] p,s = [list(i) for i in zip(*l)] t = [0] * n ac = 0 wa = 0 for i in range(m): if s[i] == 'WA' and t[int(p[i])-1] != 'AC': t[int(p[i])-1] += 1 elif s[i] == 'AC' and t[int(p[i])-1] != 'AC': ac += 1 wa += t[int(p[i])-1] t[int(p[i])-1] = 'AC' else: pass print(ac,wa)" p02802,s764705616,Accepted,"a = input().split("" "") n = int(a[0]) m = int(a[1]) ac = dict() wa = dict() for i in range(m): v = input().split("" "") q = int(v[0]) res = v[1] if q in ac: continue if res == ""AC"": ac[q] = wa.get(q, 0) + 1 elif res == ""WA"": wa[q] = wa.get(q, 0) + 1 acs = len(ac) was = 0 for k in ac.keys(): was = was + wa.get(k, 0) print(str(acs) + "" "" + str(was)) " p02802,s447598224,Accepted,"import sys input = sys.stdin.readline n,m=map(int,input().split()) ans=0;wrong=0 d=[0]*n for i in range(m): p,s=input().strip().split() p=int(p)-1 if d[p]!=-1: if s=='WA': d[p]+=1 else: wrong+=d[p] d[p]=-1 ans+=1 print(ans,wrong) " p02802,s524450599,Accepted,"n,m=map(int,input().split()) ac=[[0,False] for i in range(n)] for i in range(m): p=list(input().split("" "")) x=p[0] y=p[1] if ac[int(x)-1][1]==True: pass else: if y==""WA"": ac[int(x)-1][0]+=1 elif y==""AC"": ac[int(x)-1][1]=True counter=0 acc=0 for i in range(n): if ac[i][1]: acc+=1 counter+=ac[i][0] print(acc,counter)" p02802,s734664373,Accepted,"n, m = map(int, input().split()) c = {} for i in range(n): c[i] = 0 ac = [False] * n acn = 0 for _ in range(m): p,s = tuple(input().split()) p = int(p) if s == 'AC' and ac[p-1]==False: ac[p-1] = True acn+=1 elif s== 'WA' and ac[p-1]==False: c[p-1]+=1 pen = 0 for i,p in c.items(): if ac[i]: pen+=p print(acn, pen, sep=' ')" p02802,s871459537,Accepted,"N,M=map(int,input().split()) S=[list(input().split()) for i in range(M)] C=[0]*(N+1) L=[0]*(N+1) W=0 for x,y in S: if y==""AC"": L[int(x)]=1 for x,y in S: x=int(x) if L[x]==0: continue if y==""AC"": C[x]=1 if C[x]==0 and y==""WA"": W+=1 print(sum(L),W)" p02802,s564819693,Accepted,"P,M = map(int,input().split()) dac = {} dwa = {} for _ in range(M): p,s = input().split() p = int(p) if s == ""AC"": if p not in dac: dac[p] = 1 else: if p not in dac: if p not in dwa: dwa[p] = 1 else: dwa[p] += 1 score = len(dac) penalty = sum([val for k,val in dwa.items() if (k in dac)]) print(score,penalty)" p02802,s606948486,Accepted,"N, M = map(int, input().split()) rec = [[0,0] for _ in range(N)] AC = 0 pe = 0 for i in range(M): p, S = input().split() p = int(p) if S == 'AC': rec[p-1][1] = 1 else: if rec[p-1][1] == 0: rec[p-1][0] += 1 for i in range(N): if rec[i][1] == 1: AC += 1 pe += rec[i][0] print(AC,pe)" p02802,s156797596,Accepted,"N, M = list(map(int, input().split())) WAs = [0] * (N + 1) ACs = [0] * (N + 1) for m in range(M): key, value = input().split() key = int(key) if value == 'WA' and ACs[key] == 0: WAs[key] += 1 if value == 'AC': ACs[key] = 1 countWAs, countACs = 0, 0 for n in range(N + 1): if ACs[n] >= 1: countACs += ACs[n] countWAs += WAs[n] #print(ACs) #print(WAs) print(str(countACs) + ' ' + str(countWAs))" p02802,s385231818,Accepted,"n, m = map(int, input().split()) ac = [0] * n wa = [0] * n for _ in range(m): p, s = input().split() p = int(p) - 1 if s == 'AC': ac[p] += 1 elif s == 'WA': if ac[p] == 0: wa[p] += 1 for i in range(n): if ac[i] == 0: wa[i] = 0 ac = sum([item>0 for item in ac]) wa = sum(wa) print(ac, wa)" p02802,s597995053,Accepted,"N,M = list(map(int,input().split())) X = [] for i in range(M): tmp = [i for i in input().split()] X.append(tmp) WAs = [0]*(N+1) flags = [0]*(N+1) AC = 0 WA = 0 for i in range(M): if X[i][1] == 'AC': if flags[int(X[i][0])] == 0: AC += 1 WA += WAs[int(X[i][0])] flags[int(X[i][0])] = 1 if X[i][1] == 'WA': if flags[int(X[i][0])] == 0: WAs[int(X[i][0])] += 1 print(AC,WA,sep=' ') " p02802,s478595857,Accepted,"N, M = map(int, input().split()) p, S = [0]*M, [0]*M for i in range(0,M): p[i], S[i] = input().split() p[i] = int(p[i]) s, t = 0, 0 res = [] for i in range(0,N): res.append([i,0]) for i in range(0,M): if S[i] == ""WA"": res[p[i]-1][1] = res[p[i]-1][1]+1 elif res[p[i]-1][0] != -1: s, t = s+1, t+res[p[i]-1][1] res[p[i]-1][0] = -1 print(s, t)" p02802,s911682142,Accepted,"n,m=map(int,input().split()) counter = {} for i in range(n): counter[i] = [0,0] for i in range(m): p,s = input().split() p = int(p) if counter[p-1][1] == 1: continue elif s == ""WA"": counter[p-1][0] += 1 elif s ==""AC"": counter[p-1][1] = 1 crt = 0 pen = 0 for i in range(n): if counter[i][1] == 1: crt+=1 pen+=counter[i][0] print(crt,pen)" p02802,s552321932,Accepted,"n,m=map(int,input().split()) l=[[0 for i in range(2)]for j in range(n+1)] wa,ac=0,0 for i in range(m): p,s=input().split() p=int(p) if s==""WA"" and l[p][1]==0: l[p][0]+=1 elif s==""AC"" and l[p][1]==0: l[p][1]+=1 ac+=1 wa+=l[p][0] print(ac,wa) " p02802,s503858580,Accepted,"N, M = map(int, input().split()) P = [0] * (N + 1) S = [0] * (N + 1) for i in range(M): x, p = input().split() s = int(x) if P[s] == 0: if p == 'AC': P[s] = 1 else: S[s] += 1 A = sum([S[i] for i in range(N + 1) if P[i] == 1]) print(P.count(1), A)" p02802,s190199546,Accepted,"n, m = map(int,input().split()) success = [0] * (n+1) penalty = [0] * (n+1) for ind in range(m): p, s = input().split() p = int(p) if s == ""WA"" and success[p] == 0: penalty[p] += 1 elif s == ""AC"": success[p] = 1 penalty = [penalty[ind] * success[ind] for ind in range(n+1)] print(""{} {}"".format(sum(success), sum(penalty)))" p02802,s432663269,Accepted,"n,m=map(int,input().split()) aa=[[] for i in range(n)] for x in range(m): a,b=input().split() d=int(a)-1 aa[d].append(b) ans_ac=0 ans_wa=0 for y in range(n): ans1=0 ans2=0 for z in range(len(aa[y])): if aa[y][z]=='WA': ans1+=1 else: ans2+=1 break if ans2==1: ans_wa+=ans1 ans_ac+=1 print(str(ans_ac)+' '+str(ans_wa)) " p02802,s951912804,Accepted,"N, M = list(map(int, input().split())) if M == 0: print(0, 0) exit(0) P, S = [], [] solved = set({}) counter = {i: 0 for i in range(1, N + 1)} value1 = 0 value2 = 0 for _ in range(M): p, s = input().split() p = int(p) P.append(p) S.append(s) if p in solved: continue if s == 'AC': solved.add(p) value1 += 1 value2 += counter[p] else: counter[p] += 1 print(value1, value2)" p02802,s181453299,Accepted,"N, M = map(int, input().split()) wa_stock = [0] * N ac = 0 wa = 0 stat = ['NA'] * N for _ in range(M): p, S = input().split() key = int(p) - 1 if S == 'WA': wa_stock[key] += 1 elif stat[key] != 'AC' and S == 'AC': stat[key] = 'AC' ac += 1 wa += wa_stock[key] print(ac, wa) " p02802,s759326588,Accepted,"n,m=map(int,input().split()) ac=0 wa=0 acl=[0]*n wal=[0]*n for i in range(m): p,s=input().split() p=int(p)-1 if s==""AC"": if acl[p]==0: acl[p]=1 wa+=wal[p] ac+=1 else: wal[p]+=1 print(ac, wa)" p02802,s278940493,Accepted," import sys N,M = map(int, input().split()) A = [tuple(input().split()) for _ in range(M)] a_cnt = 0 p_cnt = 0 wa = [0] * N flg = [0] * N for i in range(M): no = int(A[i][0])-1 if A[i][1] == ""AC"" and flg[no] == 0: a_cnt += 1 p_cnt += wa[no] flg[no] = 1 continue else: wa[no] += 1 print(a_cnt, p_cnt) " p02802,s686854097,Accepted,"n,m = map(int, input().split()) flag = [False]*n nums = [0]*n for _ in range(m): p,s = input().split() p = int(p)-1 if s == ""AC"": flag[p] = True elif flag[p] == False: nums[p] += 1 ac = flag.count(True) wa = 0 for i in range(n): if flag[i]: wa += nums[i] print(ac, wa)" p02802,s325473237,Accepted,"#c welcome to atcoder import sys n,m=map(int,input().split()) ps=[] num={} #辞書 ac=0 pena=0 if m==0: print('0 0') sys.exit() for i in range(m): result=input().split() ps.append(result) if result[1]==""AC"": num[result[0]]=0 for x in ps: if not x[0] in num: continue if x[1]==""WA"" and num[x[0]]==0: pena+=1 if x[1]==""AC"" and num[x[0]]==0: ac+=1 num[x[0]]=1 print(ac,pena)" p02802,s829471546,Accepted,"n, m = map(int, input().split()) # ps = [list(map(int, input().split())) for _ in range(m)] ans = [0 for _ in range(n)] pe = [0 for _ in range(n)] accnt = 0 pecnt = 0 for i in range(m): p, s = input().split() p = int(p) if ans[p - 1] == 0 and s == ""WA"": pe[p - 1] += 1 elif ans[p - 1] == 0 and s == ""AC"": ans[p - 1] = 1 for i in range(n): if ans[i] == 0: pe[i] = 0 print(sum(ans), end = "" "") print(sum(pe), end = """") print()" p02802,s387196530,Accepted,"import numpy as np N, M = map(int, input().split()) result = [0] * N wa = [0] * N for i in range(M): p, s = input().split() p = int(p) if s == 'AC': result[p-1] = 1 elif s == 'WA' and result[p-1] == 0: wa[p-1] += 1 ac = np.sum(np.array(result)) wa = np.sum(np.array(result)*np.array(wa)) print(int(ac), int(wa)) " p02802,s093701673,Accepted,"n, m = map(int, input().split()) lac = [0] * n lwa = [0] * n for i in range(m): p, s = input().split() p = int(p) - 1 if lac[p] == 0: if s == 'WA': lwa[p] += 1 if s == 'AC': lac[p] = 1 lwa = [x * y for x, y in zip(lac, lwa)] print(sum(lac), sum(lwa))" p02802,s094056027,Accepted,"n, m = map(int, input().split()) dic = dict() li = list() for i in range(m): x1, y1 = input().split() if x1 not in dic.keys(): dic[x1] = [0,0] if dic[x1][0] == 0: if y1 == ""AC"": dic[x1][0] = 1 else: dic[x1][1] += 1 ac = 0 wa = 0 for key in dic.keys(): if dic[key][0] == 1: ac += 1 wa += dic[key][1] print(ac, wa)" p02802,s497360252,Accepted,"n,m=map(int,input().split()) a=[0]*n w=[0]*n ac=0 wc=0 for _ in range(m): p,s=input().split() p=int(p)-1 if a[p]==0: if s=='AC': a[p]=1 ac+=1 wc+=w[p] else: w[p]+=1 print(ac,wc) " p02802,s225078716,Accepted,"n,m= list(map(int, input().split())) ans_box=[0]*n wa=[0]*n ac=0 wa_cnt=0 for j in range(m): k,l=input().split() h=int(k)-1 if ans_box[h]==0: if l==""AC"": ac+=1 ans_box[h]+=1 wa_cnt+=wa[h] else: wa[h]+=1 print(ac,wa_cnt) " p02802,s960958252,Accepted,"N, M = map(int, input().split()) WA = [0] * N AC = [0] * N for i in range(M): p,s = input().split() p = int(p) if AC[p-1] == 0: if s == ""AC"": AC[p-1] = 1 else: WA[p-1] += 1 wa = 0 for j in range(N): if AC[j] == 1: wa += WA[j] print(sum(AC),wa)" p02802,s726996487,Accepted,"n,m=map(int,input().split()) a=[] c=[0]*n cnt=0 b=[0]*n for _ in range(m): p,s=input().split() p=int(p) p-=1 if s==""AC"": a.append(p) if c[p]==0: c[p]=1 else: if c[p]==0: b[p]+=1 a=list(set(a)) for i in a: cnt+=b[i] print(len(set(a)),cnt) " p02802,s813369692,Accepted,"n,m=map(int,input().split()) x=[list(input().split()) for i in range(m)] a=0 p=0 x.sort(key=lambda x:x[0]) t='a' for i in range(m): if t!=x[i][0]: w=0 t=x[i][0] f=1 if f: if x[i][1]=='AC': a+=1 p+=w f=0 else: w+=1 print(a,p)" p02802,s833723676,Accepted,"n,m = list(map(int,input().split())) lis = [[] for _ in range(n)] for i in range(m): pc,s = input().split() p = int(pc) if s=='AC':lis[p-1].append(1) else: lis[p-1].append(0) a=w=0 for i in range(n): tempwa=0 for j in lis[i]: if j==0:tempwa+=1 elif j==1: a+=1 w += tempwa break print(a,w)" p02802,s647328459,Accepted,"N, M = map(int, input().split("" "")) ac_flag = [0 for _ in range(N)] wa = ac_flag.copy() for i in range(M): question, result = input().split("" "") question = int(question) if not ac_flag[question-1] and result == 'WA': wa[question - 1] += 1 if result == 'AC': ac_flag[question-1] = 1 wa = [x*y for x, y in zip(ac_flag, wa)] print(sum(ac_flag), sum(x*y for x, y in zip(wa, ac_flag)))" p02802,s674522251,Accepted,"(N,M),*ps = [s.split() for s in open(0)] ps = [(int(p),s=='WA') for p,s in ps] from collections import Counter cnt = Counter() acs = set() for p,s in ps: if p not in acs: if s: cnt[p] += 1 else: acs.add(p) a = len(acs) b = sum(cnt[ac] for ac in acs) print(a,b)" p02802,s042133091,Accepted,"n,m=map(int,input().split()) sub=[ input().split() for i in range(m)] sub=[[int(i[0]),i[1]] for i in sub] mis=[[0,0] for i in range(n)] for i in range(m): if sub[i][1]=='AC': mis[sub[i][0]-1][0]=1 elif sub[i][1]=='WA' and mis[sub[i][0]-1][0]!=1: mis[sub[i][0]-1][1]+=1 ans=[0,0] for i in range(n): if mis[i][0]==1: ans[0]+=1 ans[1]+=mis[i][1] print(ans[0],ans[1]) " p02802,s644873435,Accepted,"N, M = (int(x) for x in input().split()) B = [False]*N cnt = [0]*N ans = 0 pena = 0 for i in range(M): p, S = (str(x) for x in input().split()) p = int(p) if S==""AC"" and B[p-1]==False: B[p-1]=True ans+=1 elif S==""WA"" and B[p-1]==False: cnt[p-1]+=1 for i in range(N): if B[i]==True: pena+=cnt[i] print(ans, end="" "") print(pena)" p02802,s591653232,Accepted,"n,m = map(int, input().split()) flag = [False]*n wa = [0]*n for _ in range(m): p,s = input().split() p = int(p)-1 if not flag[p]: if s == ""WA"": wa[p] += 1 else: flag[p] = True count = 0 for i in range(n): if flag[i]: count += wa[i] print(flag.count(True), count)" p02802,s546605170,Accepted,"n, m = map(int, input().split()) wa = [0] * n cnt = [0] * n for i in range(m): p, s = input().split() if s == ""WA"" and cnt[int(p) - 1] == 0: wa[int(p) - 1] += 1 elif s == ""AC"" and cnt[int(p) - 1] == 0: cnt[int(p) - 1] += 1 for i in range(n): if cnt[i] == 0: wa[i] = 0 print(sum(cnt), sum(wa))" p02802,s729644548,Accepted,"def main(): n, m = [int(i) for i in input().split()] wa = [0]*n ac = [0]*n for _ in range(m): p, s = input().split() if s == ""WA"": if ac[int(p)-1] == 0: wa[int(p)-1] += 1 else: ac[int(p)-1] += 1 print(n-ac.count(0), sum([wa[i] for i in range(n) if ac[i] >= 1])) if __name__ == ""__main__"": main()" p02802,s300244391,Accepted,"n, m = map(int, input().split("" "")) nac = 0 npe = 0 cp = 0 is_ac = [False]*n np_list = [0]*n for i in range(m): p_s, s = input().split("" "") p = int(p_s)-1 cis_ac = is_ac[p] if cis_ac: continue if s == ""AC"": nac += 1 is_ac[p]=True else: np_list[p] += 1 for i, a in enumerate(is_ac): if a: npe += np_list[i] print(str(nac)+"" ""+str(npe)) " p02802,s593302252,Accepted,"n, m = [int(x) for x in input().split()] lst = [0]*(n+1) a = 0 b = 0 for i in range(m): p, s = input().split() p = int(p) if s == 'AC' and lst[p] is not None: a += 1 b += lst[p] lst[p] = None elif s == 'WA' and lst[p] is not None: lst[p] += 1 print(a,b)" p02802,s111911026,Accepted,"n,m=map(int,input().split()) aa=[[] for i in range(n)] for x in range(m): a,b=input().split() d=int(a)-1 aa[d].append(b) ans_ac=0 ans_wa=0 for y in range(n): ans1=0 ans2=0 for z in range(len(aa[y])): if aa[y][z]=='WA' and ans2==0: ans1+=1 elif aa[y][z]=='AC' and ans2==0: ans2+=1 if ans2==1: ans_wa+=ans1 ans_ac+=1 print(str(ans_ac)+' '+str(ans_wa)) " p02802,s106924020,Accepted,"N, M = map(int, input().split()) problems = [False] * (N+1) penalty = [0]*(N+1) for i in range(M): p, S = input().split() if S == 'AC': problems[int(p)] = True if S == 'WA' and problems[int(p)] is False: penalty[int(p)] += 1 ans_AC, ans_pena = 0, 0 for i in range(1, N+1): if problems[i] is True: ans_AC += 1 ans_pena += penalty[i] print(ans_AC, ans_pena) " p02802,s766746035,Accepted,"#C n, m = map(int, input().split()) probrem = [0] * n warn = [0] * n for i in range(m): a, b = map(str, input().split()) a=int(a) if probrem[a - 1] == 0 and b == 'AC': probrem[a - 1] = 1 if probrem[a - 1] == 0 and b == ""WA"": warn[a - 1] += 1 # print(probrem,warn) for i in range(n): if probrem[i] == 0: warn[i] = 0 print(sum(probrem),sum(warn))" p02802,s474126540,Accepted,"N, M = map(int, input().split()) AC = [False] * (N + 1) WA = [0] * (N + 1) for _ in range(M): p, S = input().split() p = int(p) if S =='AC': AC[p] = True elif S == 'WA' and AC[p] == False: WA[p] += 1 print(sum(AC), sum([WA[i] for i, boo in enumerate(AC) if boo])) " p02802,s734816939,Accepted,"import numpy as np import sys input = sys.stdin.readline N, M = list(map(int, input().split())) ac = np.zeros(N, dtype=np.int) wa = np.zeros(N, dtype=np.int) for n in range(M): p, S = input().split() p = int(p) if ac[p - 1] == 1: continue if S == 'AC': ac[p - 1] = 1 else: wa[p - 1] += 1 wa = str(sum(wa * ac)) ac = str(sum(ac)) ans = ac + ' ' + wa print(ans) " p02802,s281952896,Accepted,"n,m=map(int,input().split()) cnt=0 l=[0 for i in range(n)] for i in range(m): p,s=input().split() p=int(p) p-=1 if l[p]!=-1: if s=='AC': cnt+=l[p] l[p]=-1 else: l[p]+=1 ac_cnt=l.count(-1) print(ac_cnt,cnt)" p02802,s269204719,Accepted,"n,m=map(int, input().split()) res = [0]*n wa = [0]*n pena = 0 for i in range(m): p,s = map(str, input().split()) if s == ""AC"": res[int(p)-1]=1 if s == ""WA"" and not res[int(p)-1]: wa[int(p)-1]+=1 for i in range(n): if res[i]: pena += wa[i] print(sum(res), pena) " p02802,s312937287,Accepted,"n, m = map(int, input().split()) P = [] S = [] for i in range(m): p, s = input().split() P.append(p) S.append(s) V = [[0] * 2 for i in range(n)] for i in range(m): j = int(P[i]) - 1 if V[j][0] != 1: if S[i] == 'AC': V[j][0] = 1 else: V[j][1] += 1 a = 0 w = 0 for i in range(n): if V[i][0] == 1: a += 1 w += V[i][1] print(a, w)" p02802,s288486611,Accepted,"n, m = map(int, input().split()) wa = [0 for _ in range(n)] ac = [0 for _ in range(n)] for _ in range(m): p, s = input().split() if s == 'WA' and ac[int(p)-1] == 0: wa[int(p)-1] += 1 else: if ac[int(p)-1] == 0: ac[int(p)-1] = 1 wa_ans = 0 ac_ans = sum(ac) for i in range(n): if ac[i] == 1: wa_ans += wa[i] print(ac_ans, wa_ans) " p02802,s992728520,Accepted,"#coding:utf-8 from collections import defaultdict dd = defaultdict(int) N,M = map(int, input().split()) ans = 0 ac = 0 for m in range(M): p, s = input().split() p = int(p) if dd[p] != -1: if (s==""WA""): dd[p]+=1 else: ans += dd[p] ac += 1 dd[p] = -1 print (ac,ans)" p02802,s401910223,Accepted,"N,M = map(int,input().split()) S = [input().split() for i in range(M)] cntAC = [0] * N cntWA = [0] * N for p,s in S: if cntAC[int(p)-1] == 0: if s == ""AC"": cntAC[int(p)-1] = 1 elif s == ""WA"": cntWA[int(p)-1] += 1 sumWA = sum([cntWA[p] for p in range(N) if cntAC[p]==1]) print(sum(cntAC),sumWA) " p02802,s926792006,Accepted,"n, m = map(int, input().split()) ac = [False] * n wa = [0] * n for _ in range(m): p, s = input().split() p = int(p) if s == ""AC"" and ac[p-1] == False: ac[p-1] = True elif s == ""WA"" and ac[p-1] == False: wa[p-1] += 1 a = 0 w = 0 for i in range(n): if ac[i]: a += 1 w += wa[i] print(a, w)" p02802,s899035113,Accepted,"N,M=[int(i) for i in input().split("" "")] plog={} for i in range(M): p,S=input().split("" "") if p in plog: plog[p]+=[S] else: plog[p]=[S] WA_Count=0 AC_Count=0 for pl in plog: _WA_Count=0 for res in plog[pl]: if res==""WA"": _WA_Count+=1 elif res==""AC"": AC_Count+=1 WA_Count+=_WA_Count break print(""%d %d""%(AC_Count,WA_Count)) " p02802,s130329150,Accepted,"N, M = map(int, input().split()) S = [[0 for j in range(2)] for i in range(M)] for i in range(M): X = input().split() S[i][0] = int(X[0]) S[i][1] = str(X[1]) A = [0] * N p = 0 s = 0 for i in range(M): if S[i][1] == ""WA"": if A[S[i][0]-1] != ""x"": A[S[i][0]-1] += 1 if S[i][1] == ""AC"": if A[S[i][0]-1] != ""x"": p += A[S[i][0]-1] A[S[i][0]-1] = ""x"" s += 1 arr = [s, p] print(*arr)" p02802,s428724454,Accepted,"n,m = map(int,input().split()) ac = [False] * n wa = [0] * n for i 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])" p02802,s623806514,Accepted,"N, M = map(int, input().split()) p = [None]*M S = [None]*M for i in range(M): p[i], S[i] = input().split() ac_flag = [0]*N wa_count = [0]*N penalty = 0 for i in range(M): j = int(p[i])-1 if S[i] == 'AC': if ac_flag[j]: pass else: ac_flag[j] = 1 penalty += wa_count[j] else: wa_count[j] += 1 print(*[sum(ac_flag), penalty])" p02802,s559849352,Accepted,"n, m = map(int, input().split()) sub = [list(input().split()) for _ in range(m)] ac = [0 for _ in range(n)] wa = [0 for _ in range(n)] for s in sub: if s[1] == 'AC': ac[int(s[0])-1] += 1 elif ac[int(s[0])-1] == 0: wa[int(s[0])-1] += 1 ac_sum = 0 wa_sum = 0 for i in range(n): if ac[i] != 0: wa_sum += wa[i] ac_sum += 1 print(ac_sum, wa_sum) " p02802,s654179930,Accepted,"n, m = map(int,input().split()) a = [input().split() for i in range(m)] p = [int(i[0]) for i in a] q = [j[1] for j in a] ac = 0 wa = 0 wa_c = [0] * n ac_c = [False] * n for t in range(m): if ac_c[p[t]-1]: continue if q[t] == 'AC': ac += 1 ac_c[p[t]-1] = True wa += wa_c[p[t]-1] else: wa_c[p[t]-1] += 1 print(ac,wa)" p02802,s461506573,Accepted,"N,M=map(int,input().split()) t=[0]*(N+1) e=[0]*(N+1) for i in range(M): p,s=input().split() if t[int(p)]==0 and s==""WA"": e[int(p)]+=1 if t[int(p)]==0 and s==""AC"": t[int(p)]=1 for i in range(N+1): if t[i]==0: e[i]=0 print(sum(t),sum(e))" p02802,s956627108,Accepted,"N, M = map(int,input().split()) if M == 0: print(0,0) exit() a = [0]*(N + 1) p = [0]*(N + 1) wa = [0]*(N + 1) for i in range(M): P, S = input().split() P = int(P) if S == ""WA"": wa[P] += 1 elif a[P] == 0: a[P] += 1 p[P] = wa[P] print(sum(a),sum(p))" p02802,s822584126,Accepted,"n, m = map(int, input().split()) pena = [0 for x in range(n + 1)] clear = [False for i in range(n + 1)] for i in range(m): p, c = input().split() p = int(p) if clear[p] is False: if c == ""AC"": clear[p] = True else: pena[p] += 1 ans_ac = 0 ans_pena = 0 for pe, cl in zip(pena, clear): if cl: ans_ac += 1 ans_pena += pe print(ans_ac, ans_pena)" p02802,s146810661,Accepted,"N, M = map(int, input().split()) res = [[0 for i in range(2)] for j in range(N)] ac = 0 wa = 0 for i in range(M): p, s = input().split() p = int(p) if res[p - 1][0] == 0: if s == ""AC"": ac += 1 res[p - 1][0] = 1 else: res[p - 1][1] += 1 for i in range(N): if res[i][0] == 1: wa += res[i][1] print(ac, wa)" p02802,s354789321,Accepted,"#!python3.4.3 n, m = map(int, input().split(' ')) penalty = [0 for _ in range(n)] result = [0 for _ in range(n)] for i in range(m): p, s = input().split(' ') p = int(p) if s == 'AC': result[p-1] = 1 elif s == 'WA' and result[p-1] != 1: penalty[p-1] += 1 penalty = [x * y for (x, y) in zip(penalty, result)] print(sum(result), sum(penalty)) " p02802,s418686159,Accepted,"N,M = map(int, input().split()) ac = [0]*N wa = [0]*N for i in range(M): p,s = input().split() if s == 'AC': if ac[int(p) - 1] != 0: continue else: ac[int(p) - 1] = 1 else: if ac[int(p) - 1] != 0: continue else: wa[int(p) - 1] += 1 AC,WA = 0,0 for i in range(N): AC += ac[i] if ac[i] >= 1: WA += wa[i] print(AC,WA)" p02802,s154084737,Accepted,"N,M = map(int,input().split()) ok = 0 ng = 0 Q = [0]*N for _ in range(M): p,s = map(str,input().split()) if Q[int(p)-1] != -1 and s == ""AC"": ok += 1 ng += Q[int(p)-1] Q[int(p)-1]= -1 elif Q[int(p)-1] != -1 and s == ""WA"": Q[int(p)-1] += 1 print(ok,ng)" p02802,s046823111,Accepted,"import numpy as np from collections import Counter n, m = map(int, input().split()) mistake = [0] * (n + 1) done = [False] * (n + 1) for _ in range(m): p, s = input().split() p = int(p) if s == 'WA': if done[p] == False: mistake[p] += 1 else: done[p] = True counter = Counter(done) print(counter[True], sum(np.multiply(mistake, done))) " p02802,s545438865,Accepted,"# -*- coding: utf-8 -*- import numpy as np iNum, iM = map(int, input().split()) naB = np.zeros(iNum, dtype = ""bool"") naW = np.zeros(iNum, dtype = int) iC = 0 iW = 0 for _ in range(iM): l = input().split() iP = int(l[0]) - 1 if not(naB[iP]): if l[1][0] == ""A"": naB[iP] = True iC += 1 iW += naW[iP] else: naW[iP] += 1 print(iC, iW)" p02802,s755470676,Accepted,"N,M=map(int,input().split()) ac,wa=0,0 task=[0]*N for m in range(M): p,S=input().split() p=int(p)-1 if task[p]!=-1 and S==""WA"": task[p]+=1 elif task[p]!=-1 and S==""AC"": ac+=1 wa+=task[p] task[p]=-1 print(ac,wa)" p02802,s998368794,Accepted,"n,m=map(int,input().split()) sub=[tuple(input().split()) for j in range(m)] ac=[False for i in range(n)] wa=[0 for i in range(n)] for p,s in sub: p=int(p) if s=='AC': ac[p-1]=True else: if ac[p-1]==False: wa[p-1]+=1 # print(ac) # print(wa) ans=0 pena=0 for AC,WA in zip(ac,wa): if AC: ans+=1 pena+=WA print(ans,pena)" p02802,s625768531,Accepted,"l = dict() t, f = 0, 0 n, m = map(int, input().split("" "")) for _ in range(m): p, s = input().split("" "") if not p in l: l[p] = [None, 0] if s == ""WA"": if l[p][0] != True: l[p][1] += 1 elif s == ""AC"": if l[p][0] != True: l[p][0] = True t += 1 for _, v in l.items(): if v[0]: f += v[1] print(t, f)" p02802,s148460733,Accepted,"n,m=map(int,input().split()) p=[] s=[] for c in range(m): k=input().split() p.append(int(k[0])-1) s.append(k[1]) a=[0]*n w=[0]*n for c in range(m): if a[p[c]]==1: continue if s[c]==""AC"": a[p[c]]=1 else: w[p[c]]+=1 u=0 for c in range(n): if a[c]==1: u+=w[c] print(sum(a),u)" p02802,s082408633,Accepted,"n,m=map(int,input().split()) a=0 p=0 L=[0 for _ in range(n)] for _ in range(m): num,s = input().split() num=int(num)-1 if not L[num] == -1: if s == ""AC"": a+=1 p+=L[num] L[num]=-1 else: L[num]+=1 print(a,p)" p02802,s273384216,Accepted,"n,m= map(int, input().split()) judge=[0]*n cor=0 pen=0 inf=10**6 for i in range(m): a,s = input().split() a=int(a) if s=='WA': judge[a-1]+=1 else: if judge[a-1]>-1: cor+=1 pen+=judge[a-1] judge[a-1]=-inf print(cor,pen)" p02802,s347985262,Accepted,"n, m = map(int, input().split()) sub = [list(input().split()) for j in range(m)] li = [[0 for i in range(n)]for j in range(2)] for i in range(m): x = int(sub[i][0])-1 if sub[i][1] == 'AC': if li[0][x] == 0: li[0][x] += 1 elif li[0][x] == 0: li[1][x] += 1 else: next ac = sum(li[0]) wa = 0 for i in range(n): if li[0][i] == 1: wa += li[1][i] print('{} {}'.format(ac,wa)) " p02802,s027770922,Accepted,"N, M = map(int, input().split()) data = [0]*N solved = [False]*N for _ in range(M): p, S = input().split() p = int(p) - 1 if solved[p] == False and S == ""WA"": data[p] += 1 if solved[p] == False and S == ""AC"": solved[p] = True print(sum(solved),sum( x*y for x, y in zip(data, solved)) ) " p02802,s146467818,Accepted,"n,m= map(int, input().split()) AC = [0]*(n+1) WA = [0]*(n+1) for i in range(m): p_number, p_status = input().split() p_number =int(p_number) if (p_status =='WA') & (AC[p_number]==0): WA[p_number]+=1 if (p_status =='AC') & (AC[p_number]==0): AC[p_number] +=1 for i in range(n+1): if AC[i] ==0: WA[i]=0 print(sum(AC), sum(WA)) #print(AC,WA)" p02802,s425775170,Accepted,"#C n,m=map(int,input().split()) f=False ps=[] AC=[0]*n WA=[0]*n for i in range(m): ps.append(list(input().split())) for i in range(m): if ps[i][1]=='AC'and AC[int(ps[i][0])-1]==0: AC[int(ps[i][0])-1]=1 if ps[i][1]=='WA'and AC[int(ps[i][0])-1]==0: WA[int(ps[i][0])-1]+=1 wasum=0 for i in range(n): if AC[i]==1: wasum+=WA[i] print(sum(AC),wasum)" p02802,s278286048,Accepted,"n, m = input().split() a = [False] * int(n) b = [0] * int(n) AC = 0 WA = 0 for i in range(int(m)): p, s = input().split() if(s == ""AC"" and a[int(p) - 1] == False): a[int(p) - 1] = True AC += 1 WA += b[int(p) - 1] if(s == ""WA"" and a[int(p) - 1] == False): b[int(p)-1] += 1 print(AC, WA) " p02802,s807317339,Accepted,"N, M = map(int, input().split()) submit = [list(input().split()) for _ in range(M)] acflag = [False]*N AC = 0 waflag = [0]*N WA = 0 for i in range(M): if (not acflag[int(submit[i][0])-1]) and submit[i][1] == ""AC"": acflag[int(submit[i][0])-1] = True AC += 1 elif (not acflag[int(submit[i][0])-1]) and submit[i][1] == ""WA"": waflag[int(submit[i][0])-1] += 1 for i in range(N): if acflag[i]: WA += waflag[i] print(AC, WA)" p02802,s796235702,Accepted,"N, M = map(int, input().split()) Pn = [] for i in range(M): Pn.append(list(input().split())) check = [0 for i in range(N + 1)] pAC = 0 pWA = 0 for p in Pn: x = int(p[0]) if check[x] != -1: if p[1] == 'WA': check[x] += 1 elif p[1] == 'AC': pWA += check[x] pAC += 1 check[x] = -1 print(pAC, pWA) " p02802,s170977788,Accepted,"n, m = map(int, input().split()) a = [0] * (n+1) b = [0] * (n+1) c = 0 for i in [0]*(m): s = input().split() if a[int(s[0])] == 0: if s[1] == ""AC"": a[int(s[0])] = 1 c += b[int(s[0])] else: b[int(s[0])] += 1 print(sum(a), c) " p02802,s782610966,Accepted,"N,M = map(int,input().split()) wa = [0]*N ac = [0]*N wac = 0 acc = 0 for i in range(M): p,s = input().split() p = int(p) if s == ""AC"": if ac[p-1] != 1: ac[p-1] = 1 acc += 1 wac += wa[p-1] else: if ac[p-1] == 0: wa[p-1] += 1 print(str(acc) +"" ""+ str(wac))" p02802,s540469278,Accepted,"n,m = map(int,input().split()) x = [0]*(n+1) t = [0]*(n+1) p=q=0 for i in range(m): k,l = input().split() y=int(k)-1 if x[y]==0: if l=='WA': t[y]+=1 else: q+=t[y] p+=1 x[y]=1 print(p,q)" p02802,s412534477,Accepted,"n,m = map(int,input().split()) na = [0]*n nw = [0]*n for i in range(m): a,b = input().split() if b == ""AC"": na[int(a)-1] = 1 elif b == ""WA"": if na[int(a)-1] == 0: nw[int(a)-1] += 1 count = 0 print(sum(na),end="""") for i in range(n): if na[i] == 1: count += nw[i] print("" {}"".format(count)) " p02802,s486752772,Accepted,"n,m = map(int, input().split()) ps = [list(input().split()) for _ in range(m)] P = [0] * (n+1) pena = [0] * (n+1) for p,s in ps: p = int(p) if s == ""WA"": if P[p] == 0: pena[p] += 1 else: P[p] = 1 ans = [0,0] for p,pe in zip(P,pena): p = int(p) if p == 0: continue ans[0] += 1 ans[1] += pe print("" "".join(map(str, ans)))" p02802,s538101084,Accepted,"import numpy as np N, M = map(int, input().split()) aced = np.zeros(N, dtype=""bool"") waed = np.zeros(N, dtype=""int"") AC = ""AC"" WA = ""WA"" for _ in range(M): p, s = input().split() p = int(p) - 1 if s == AC: aced[p] = True else: if not aced[p]: waed[p] += 1 ac_count = 0 wa_count = 0 for i in range(N): if aced[i]: ac_count += 1 wa_count += waed[i] print(""{} {}"".format(ac_count, wa_count))" p02802,s809746884,Accepted,"N, M = map(int, input().split()) X = [list(input().split()) for _ in range(M)] acs = [False] * (N + 1) was = [0] * (N + 1) for p, s in X: if s == ""AC"": acs[int(p)] = True elif not acs[int(p)]: was[int(p)] += 1 was_cnt = 0 for a, w in zip(acs, was): if a: was_cnt += w print(sum(acs), was_cnt) " p02802,s181965342,Accepted," N,M = map(int,input().split()) PS =[""""]*N PS2 =[0]*N PENALTY = 0 AC = 0 for m in range(M): p,s = map(str,input().split()) p=int(p)-1 if PS[p]!=""AC"" and s==""WA"": PS2[p]+=1 elif PS[p]!=""AC"" and s==""AC"": AC+=1 PENALTY+=PS2[p] PS[p]=""AC"" print(AC,PENALTY)" p02802,s020815402,Accepted,"n, m = map(int, input().split()) account, wacount = 0, 0 acdic = [0] * (n + 10) for _ in range(m): p, s = input().split() p = int(p) if s == ""AC"" and acdic[p] <= 0: account += 1 wacount += abs(acdic[p]) acdic[p] = 1 elif s == ""WA"" and acdic[p] <= 0: acdic[p] -= 1 print(account, wacount)" p02802,s718456093,Accepted,"N,M = map(int,input().split()) a=[] ac_list = [0]*N wa_list= [0]*N count_wa = 0 for i in range(M): p,s=input().split() p = int(p) - 1 if ac_list[p] == 0: if s == 'WA': wa_list[p] += 1 else: ac_list[p] = 1 for i in range(N): if ac_list[i] == 1: count_wa += wa_list[i] print(sum(ac_list),count_wa)" p02802,s630185427,Accepted,"n,m=map(int,input().split()) dp=[0]*(n+1) charge=[0]*(n+1) cnt=0 ans=0 for i in range(m): q=input() if dp[int(q[:-3])]!=""A"" and q[-2]==""W"": dp[int(q[:-3])]=""W"" charge[int(q[:-3])]+=1 elif dp[int(q[:-3])]!=""A"" and q[-2]==""A"": dp[int(q[:-3])]=""A"" ans+=1 cnt+=charge[int(q[:-3])] charge[int(q[:-3])]=0 print(ans,cnt)" p02802,s138393452,Accepted,"n, m = map(int, input().split(' ')) problem = [0] * n ok=0 pen=0 i=0 while i < m: p, result = input().split(' ') p = int(p) - 1 if problem[p] < 0: pass else: if result == 'WA': problem[p] += 1 else: ok += 1 pen += problem[p] problem[p] = -1 i+=1 print('{} {}'.format(ok, pen))" p02802,s737133119,Accepted,"N,M = map(int,input().split()) WA = [0] * (N + 1) AC = [0] * (N + 1) sum_WA = 0 for _ in range(M): i,s = input().split() i = int(i) if AC[i] == 0: if s == 'WA': WA[i] += 1 elif s == 'AC': AC[i] = 1 sum_WA += WA[i] print(sum(AC),sum_WA)" p02802,s417149823,Accepted,"import sys N, M = [int(v) for v in sys.stdin.readline().split()] AC = set() WA = {} for i in range(M): p, s = sys.stdin.readline().split() p = int(p) if s == 'AC': AC.add(p) else: if p not in AC: if p not in WA: WA[p] = 1 else: WA[p] += 1 wa = 0 for a, c in WA.items(): if a in AC: wa += c print(len(AC), wa) " p02802,s188369224,Accepted,"import sys readline = sys.stdin.buffer.readline n, m = map(int, readline().split()) ac_lst = [False] * (n + 1) wa_lst = [0] * (n + 1) w = 0 for _ in range(m): a, b = readline().split() a = int(a) if ac_lst[a]: continue if b == b'WA': wa_lst[a] += 1 else: w += wa_lst[a] ac_lst[a] = True print(sum(ac_lst), w) " p02802,s627064175,Accepted,"N,M=map(int,input().split()) c=[0]*(N+1) w=[0]*(N+1) AC=0 WA=0 for i in range(M): p,s=input().split() p=int(p) if(c[p]==0 and s==""AC""): c[p]+=1 AC+=1 WA+=w[p] elif(c[p]==0 and s==""WA""): w[p]+=1 print(AC,WA)" p02802,s979855314,Accepted,"n,m=map(int,input().split()) a=[0]*n w=[0]*n ac=0 wc=0 for _ in range(m): p,s=input().split() p=int(p)-1 if a[p]==0: if s=='AC': a[p]=1 ac+=1 wc+=w[p] else: w[p]+=1 print(ac,wc)" p02802,s205718147,Accepted,"n, m = map(int, input().split()) dwa = {} dac = {} ansac = 0 answa = 0 for m in range(m): p, s = map(str, input().split()) p = int(p) if s == 'WA': if p in dwa: dwa[p] += 1 else: dwa[p] = 1 if s == 'AC' and p not in dac: ansac += 1 dac[p] = 1 if p in dwa: answa += dwa[p] print(ansac, answa)" p02802,s823015781,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 not ac[p]: if s == ""AC"": ac[p] = True else: wa[p] += 1 accnt = len([1 for x in ac if x]) wacnt = sum([wa[i] for i in range(N) if ac[i]]) print(accnt, wacnt)" p02802,s253600011,Accepted,"n,m = map(int,input().split()) prb = [[0] for _ in range(n+1)] for _ in range(m): sub = input().split() p, s = int(sub[0]), sub[1] lst = prb[p] if lst[-1] == 1: pass elif s == ""WA"": lst.append(0) elif s == ""AC"": lst.append(1) prb[p] = lst ac_prb = [lst for lst in prb if lst[-1] == 1] ac_num = len(ac_prb) pe_num = -2*ac_num for prb in ac_prb: pe_num += len(prb) print(ac_num, pe_num)" p02802,s710512162,Accepted,"N, M = map(int,input().split()) li = [] for _ in range(M): p, S = input().split() li.append([int(p), S]) ac = [0] * N wa = [0] * N c1 = 0 c2 = 0 for i in range(M): j = li[i][0] - 1 if li[i][1] == ""WA"": wa[j] += 1 if ac[j] == 0 and li[i][1] == ""AC"": ac[j] = 1 c1 += 1 c2 += wa[j] print(c1, c2) " p02802,s250783933,Accepted,"n,m=map(int,input().split()) mon = [0]* n ac =0 wa = 0 for i in range(m): p,s = list(input().split()) p = int(p)-1 if mon[p] <0: continue if s == 'AC': ac += 1 wa += mon[p] mon[p] = -1 else: mon[p] += 1 print(ac,wa) " p02802,s143403356,Accepted,"N, M = map(int, input().split()) ACed = [0] * (N + 1) WAed = [0] * (N + 1) WA_count = 0 AC_count = 0 WA_sum = 0 for i in range(M): p, s = input().split() p = int(p) if s == 'WA': WAed[p] += 1 if s == 'AC' and ACed[p] == 0: ACed[p] = 1 AC_count += 1 WA_sum += WAed[p] print(AC_count, WA_sum) " p02802,s440779051,Accepted,"N,M = list(map(int,input().split())) colect_quest = [0]*N WA_quest = [0]*N for i in range(M): pi,si = list(map(str,input().split())) pi = int(pi) if si == ""AC"": colect_quest[pi-1] = 1 if si == ""WA"" and colect_quest[pi-1] != 1: WA_quest[pi-1] += 1 WA_count = 0 for i in range(len(WA_quest)): if colect_quest[i] == 1 : WA_count += WA_quest[i] print(sum(colect_quest),WA_count)" p02802,s990867888,Accepted," N,M = map(int, input().split()) isAC = [0] * (N+1) isWA = [0] * (N+1) ACnum = 0 WAnum = 0 for _ in range(M): p, s = input().split() p = int(p) if isAC[p] == 1: continue if s == 'AC': isAC[p] = 1 ACnum += 1 WAnum += isWA[p] elif s == 'WA': isWA[p] += 1 print(""%d %d""%(ACnum, WAnum))" p02802,s225661115,Accepted,"n,m= map(int,input().split()) r = 0 p = 0 li = [0]*n for i in range(m): a,b = input().split() if li[int(a)-1]==-1: pass elif b=='WA': li[int(a)-1]+=1 elif b=='AC': r += 1 p += li[int(a)-1] li[int(a)-1]=-1 print(r,p) " p02802,s872240706,Accepted,"N, M = [int(i) for i in input().split()] dic = {} for _ in range(M): p, s = input().split() if p not in dic: dic[p] = [False, 0] isAC, WC = dic[p] if isAC: continue if s == ""AC"": dic[p][0] = True elif s == ""WA"": dic[p][1] += 1 correct = 0 penalty = 0 for v in dic.values(): if v[0]: correct += 1 penalty += v[1] print(correct, penalty) " p02802,s221972321,Accepted,"n, m = map(int, input().split()) d = [[] for i in range(n)] for _ in range(m): p, s = input().split() p = int(p) - 1 d[p].append(s) ac_cnt, w_cnt = 0, 0 for l in d: if len(l) != 0 and ""AC"" in l: w_cnt += l.index(""AC"") if ""AC"" in l: ac_cnt += 1 print(ac_cnt, w_cnt) " p02802,s774149618,Accepted,"N, M = map(int, input().split()) P = [] S = [] for i in range(M): p, s = input().split() P.append(int(p)) S.append(s) collect=[0]*N miss = [0]*N for a in range(M): if S[a] == ""AC"": if collect[P[a]-1] != 1: collect[P[a]-1] += 1 else: if collect[P[a]-1] != 1: miss[P[a]-1] += 1 AC = sum(collect) WA = 0 for a in range(N): if collect[a] == 1: WA += miss[a] print(AC, WA)" p02802,s181527399,Accepted,"def main(): n, m = map(int, input().split()) ab = [input().split() for _ in [0]*m] cnt = 0 ac_list = [False]*n cnt_list = [0]*n for a, b in ab: if b == ""WA"": cnt_list[int(a)-1] += 1 else: if ac_list[int(a)-1] == False: cnt += cnt_list[int(a)-1] ac_list[int(a)-1] = True print(sum(ac_list), cnt) main() " p02802,s383946700,Accepted,"n, m = map(int, input().split()) acline = [0]*n wanum = [0]*n for i in range(m): num, acwa = map(str, input().split()) num = int(num) -1 if acwa == ""AC"": acline[num] = 1 else: if acline[num] == 1: continue else: wanum[num] += 1 for j in range(n): if acline[j] == 0: wanum[j] = 0 print(sum(acline), sum(wanum))" p02802,s704200307,Accepted,"n,m = map(int,input().split()) A = [] for _ in range(m): a,b = input().split() tmp = [int(a),b] A.append(tmp) dict = {} for a in A: dict.update({a[0]:[False,0]}) for a in A: if dict[a[0]][0] == False: if a[1] == ""WA"": dict[a[0]][1] += 1 else: dict[a[0]][0] = True wa = 0 ac = 0 for i in dict: if dict[i][0]: ac += 1 wa += dict[i][1] print(""{} {}"".format(ac,wa))" p02802,s703759814,Accepted,"n,m = map(int, input().split()) ac = [0]*(n+1) wa = [0]*(n+1) for i in range(m): p, s = input().split() p = int(p) if s== ""AC"": ac[p] = 1 else: if ac[p]==0: wa[p]+=1 for i in range(n+1): if ac[i]==0: wa[i]=0 print(sum(ac),sum(wa)) " p02802,s380190325,Accepted,"N, M = [int(_) for _ in input().split()] A = [0 for _ in range(N+1)] ac, wa = 0, 0 for _ in range(M): p, S = input().split() p = int(p) if A[p] != None: if S == ""AC"": ac += 1 wa += A[p] A[p] = None else: A[p] += 1 print(ac, wa) " p02802,s016874214,Accepted,"n,m=map(int,input().split()) use=[0]*n pen=[0]*n ans=0 for i in range(m): p,s=input().split() p=int(p)-1 if s==""AC"": if use[p]==0: use[p]=1 ans+=1 else: if use[p]==0: pen[p]+=1 pe=0 for i in range(n): pe+=use[i]*pen[i] print(ans,pe)" p02802,s947524875,Accepted,"N,M = map(int,input().split()) ac = (N+1)*[0] wa = (N+1)*[0] pt = 0 for i in range(M): p,s = input().split() p = int(p) if ac[p] == 0 and s == ""AC"": ac[p] = 1 pt += wa[p] wa[p] += 1 print(sum(ac),pt) " p02802,s658333630,Accepted,"n,m = map(int,input().split()) pen_list = [0 for i in range(n)] pen_num = 0 ans_num = 0 for i in range(m): p, s = input().split() p = int(p) if s == 'WA': if pen_list[p-1] != -1: pen_list[p-1] += 1 else: if pen_list[p - 1] != -1: pen_num = pen_num + pen_list[p-1] pen_list[p-1] = -1 ans_num = ans_num + 1 print(ans_num, pen_num)" p02802,s286199741,Accepted,"import sys from collections import defaultdict n, m = map(int, input().split()) wa=defaultdict(lambda: 0) already=set() ac = 0 for line in sys.stdin: p, s = line.split() p = int(p) if p in already: continue if s == ""AC"": ac+=1 already.add(p) else: wa[p] += 1 print(ac, sum(wa[i] for i in already))" p02802,s879263646,Accepted,"N,M=map(int,input().split()) PS=[list(input().split()) for _ in range(M)] wa=[0]*(N+1) ac=[0]*(N+1) ac_cnt=set() for ps in PS: if ps[1]=='AC': ac_cnt.add(ps[0]) ac[int(ps[0])]=1 if ps[1]=='WA' and ac[int(ps[0])]==0: wa[int(ps[0])]+=1 for i in range(1,N+1): if str(i) not in ac_cnt: wa[i]=0 print(sum(ac),sum(wa)) " p02802,s948884136,Accepted,"N, M = map(int, input().split()) baselis = [] for _ in range(M): temp = [x for x in input().split()] baselis.append(temp) ac = [0] * (N + 1) wa = [0] * (N + 1) for i in range(M): result = baselis[i][1] question = int(baselis[i][0]) if result == 'AC' and ac[question] == 0: ac[question] = 1 elif result == 'WA' and ac[question] == 0: wa[question] += 1 for i in range(N + 1): if ac[i] != 1: wa[i] = 0 print(sum(ac), sum(wa))" p02802,s883838894,Accepted,"N, M = map(int, input().split()) AC_or_not = [False] * N n_penalty = [0] * N cnt_ac = 0 cnt_pen = 0 for _ in range(M): prob, wa_ac = input().split() prob = int(prob) - 1 if wa_ac == 'AC': if not AC_or_not[prob]: cnt_pen += n_penalty[prob] cnt_ac += 1 AC_or_not[prob] = True else: n_penalty[prob] += 1 print(cnt_ac ,cnt_pen)" p02802,s200324147,Accepted,"from sys import stdin N,M = [int(x) for x in stdin.readline().rstrip().split()] ans = [[] for i in range(N)] for i in range(M): p,s = [(x) for x in stdin.readline().rstrip().split()] ans[int(p)-1].append(s) ac = 0 pe = 0 tmp = 0 flag = False for j in range(N): tmp = 0 for k in ans[j]: if k == ""WA"": tmp += 1 else: ac += 1 pe += tmp tmp = 0 break print(ac,pe)" p02802,s853033488,Accepted,"N,M=map(int,input().split()) Accepted=[0]*N Penalty=[0]*N for i in range(M): p,S=input().split() p=int(p) if Accepted[p-1]==0 and S==""WA"": Penalty[p-1]+=1 elif Accepted[p-1]==0 and S==""AC"": Accepted[p-1]=1 total_Accepted=sum(Accepted) total_Penalty=0 for i in range(N): if Accepted[i-1]==1: total_Penalty+=Penalty[i-1] print(total_Accepted,total_Penalty)" p02802,s287213502,Accepted,"params = input().split(' ') m = eval(params[0]) n = eval(params[1]) penaltyCount = [] for i in range(m): penaltyCount.append(0) penalties = 0 points = 0 for i in range(n): submission = input().split(' ') p = eval(submission[0])-1 status = submission[1] if penaltyCount[p] == -1: continue if status == 'AC': penalties += penaltyCount[p] penaltyCount[p] = -1 points += 1 else: penaltyCount[p] += 1 print(points, penalties)" p02802,s131957607,Accepted,"n,m = map(int,input().split()) d = {} for i in range(m): p,s = input().split() if p not in d: d[p] = [s] else: d[p].append(s) wa_c = 0 ac_c = 0 for k in d.keys(): target = d[k] if target.count(""AC"") != 0: ind = d[k].index(""AC"") ac_c += 1 wa_c += target[:ind].count(""WA"") print(ac_c,wa_c) " p02802,s084996616,Accepted,"n,m=map(int,input().split()) if m == 0: print(0,0) exit(0) results=[] for i in range(n+1): results.append([0,0]) ac = 0 wa = 0 memo = [0]*(n+1) for i in range(m): p,s=input().split() p = int(p) s = s.strip() if memo[p] != -1: if s == 'WA': memo[p] += 1 else: ac += 1 wa += memo[p] memo[p] = -1 print(ac,wa)" p02802,s328750521,Accepted,"N, M = map(int, input().split("" "")) P = [] S = [] clear = 0 q = {} c = set() for i in range(M): sss = input().split("" "") p = int(sss[0]) s = sss[1] P.append(p) S.append(s) if p not in c: if s == ""AC"": clear += 1 c.add(p) if s == ""WA"": q[p] = q.get(p, 0) + 1 warng = sum([ q[k] for k in c if k in q ]) print(""{} {}"".format(clear, warng)) " p02802,s626935640,Accepted,"import numpy as np N, M = map(int, input().split()) suc = [0 for i in range(N+1)] pen = [0 for i in range(N+1)] for i in range(M): p, s = input().split() p = int(p) if s == ""WA"" and suc[p] == 0: pen[p] += 1 elif s == ""AC"": suc[p] = 1 for i in range(N+1): if suc[i] == 0: pen[i] = 0 print( sum(suc), sum(pen) )" p02802,s955039111,Accepted,"import sys sys.setrecursionlimit(10**9) input = lambda: sys.stdin.readline().rstrip() inpl = lambda: list(map(int,input().split())) N, M = inpl() AC = [False]*N WA = [0]*N for i in range(M): p, S = input().split() p = int(p) if S == 'AC': AC[p-1] = True else: if not AC[p-1]: WA[p-1] += 1 ans = 0 acs = 0 pens = 0 for i in range(N): if AC[i]: acs += 1 pens += WA[i] print(acs, pens)" p02802,s294649206,Accepted,"from collections import OrderedDict N, M = map(int, input().split()) correct = set() wrong = OrderedDict() for _ in range(M): p, s = input().split() pn = int(p) if pn not in wrong: wrong[pn] = 0 if s == 'AC': if pn not in correct: correct.add(pn) elif s == 'WA': if pn not in correct: wrong[pn] += 1 print(len(correct), sum([wrong[pn] for pn in correct])) " p02802,s010775440,Accepted," n,m =list(map(int,input().split())) ac = [0]*n wa = [0]*n for i in range(m): p,s = input().split() p = int(p)-1 if ac[p]: continue if s == ""AC"": ac[p] = 1 elif s == ""WA"": wa[p]+=1 AC = 0 pena = 0 for i in range (n): AC += ac[i] if ac[i]: pena += wa[i] print(str(AC)+"" ""+str(pena)) " p02802,s270405037,Accepted,"N, M = map(int, input().split()) ok, ng = (0, 0) oks = set() ngdict = dict() for _ in range(M): pp, S = input().split() p = int(pp) if p in oks: continue if S == 'AC': ok += 1 ng += ngdict.get(pp, 0) oks.add(p) else: ngdict[pp] = ngdict.get(pp, 0) + 1 print('{} {}'.format(ok, ng))" p02802,s454065779,Accepted,"w,*d=[0]*10**6 a={0} for t in open(0): p,s=t.split() p=int(p) if'AC'==s*(not p in a):w+=d[p];a|={p} d[p]+=s>'V' print(len(a)-1,w)" p02802,s128386330,Accepted,"N,M=map(int,input().split()) T=[] frag=[0 for y in range(N)] p=[0 for y in range(N)] a=0 for i in range(M): s=list(map(str,input().split())) T.append(s) for i in range(M): if T[i][1]=='WA' and frag[int(T[i][0])-1]==0: p[int(T[i][0])-1]=p[int(T[i][0])-1]+1 elif T[i][1]=='AC' and frag[int(T[i][0])-1]==0: a=a+1 frag[int(T[i][0])-1]=1 for i in range(N): if frag[i]==0: p[i]=0 print(a,sum(p))" p02802,s943957732,Accepted,"N, M = map(int, input().split()) ac = [0] * N wa = [0] * N for i in range(M): p,s = input().split() p = int(p) p -= 1 if ac[p]: continue if s == 'AC': ac[p] = 1 else: wa[p] += 1 AC = sum(ac) WA = 0 for i in range(N): if ac[i]: WA += wa[i] print(AC, WA)" p02802,s658739094,Accepted,"n, m = map(int, input().split()) count_ac = count_wa = 0 check_ac = [0] * n wa_p_i = [0] * n for i in range(m): p, s = input().split() now = int(p) - 1 if s == ""AC"": if check_ac[now] == 0: count_ac += 1 check_ac[now] = 1 count_wa += wa_p_i[now] elif s == ""WA"": wa_p_i[now] += 1 print(count_ac, count_wa)" p02802,s815512478,Accepted,"from collections import OrderedDict n, m = map(int,input().split()) aclist = [0]*n walist = [0]*n ac = 0 wa = 0 for i in range(m): 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(ac, wa) " p02802,s411853077,Accepted,"#!/usr/bin/env python3 # -*- coding: utf-8 -*- import numpy as np def main(): N, M = map(int, input().split()) AC = np.array([0] * N) WA = np.array([0] * N) for i in range(M): p, S = input().split() if AC[int(p) - 1] == 0 and S == 'WA': WA[int(p) - 1] += 1 else: AC[int(p) - 1] = 1 print(sum(AC), sum(AC * WA)) if __name__ == ""__main__"": main() " p02802,s686049355,Accepted,"n,m=map(int,input().split()) a=[0]*n b=[0]*n for i in range(m): p,s=input().split() p=int(p)-1 if a[p]==0: if s==""AC"": a[p]=1 else: b[p]+=1 for i in range(n): if a[i]==0: b[i]=0 print(sum(a),sum(b))" p02802,s643842131,Accepted,"N, M = map(int, input().split()) P = [] S = [] T = [0 for i in range(N)] U = [0 for i in range(N)] ACs = 0 WAs = 0 for i in range(M): p, s = input().split() p = int(p) P.append(p) S.append(s) for i in range(M): if S[i] == ""AC"": if U[P[i]-1] != 1: U[P[i]-1] += 1 ACs += 1 WAs += T[P[i]-1] else: T[P[i]-1] += 1 print(ACs, WAs)" p02802,s462286083,Accepted,"n,m=map(int,input().split()) l=[] for i in range(m): a=list(input().split()) a.append(i) l.append(a) l.sort(key=lambda x:(x[0],x[2])) f="""" q="""" a=0 w=0 for i in range(m): if l[i][0] != f: ww=0 if l[i][1] == ""AC"": if l[i][0] != q: a+=1 w+=ww q=l[i][0] else: ww+=1 f=l[i][0] print(a,w)" p02802,s234262204,Accepted,"n, m = map(int, input().split()) scores = [] for _ in range(m): num, r = input().split() scores.append([num, r]) answers = [0] * (n + 1) penalties = [0] * (n + 1) ac = set() for num, r in scores: n = int(num) if r == 'AC': answers[n] = 1 ac.add(n) elif r == 'WA' and answers[n] == 0: penalties[n] += 1 ans = sum(answers) p = 0 for a in ac: p += penalties[a] print(ans, p)" p02802,s978813253,Accepted,"import sys inputs = sys.stdin.readlines() n, m = map(int, inputs[0].split()) acs = [0]*n was = [0]*n for X in inputs[1:]: p, s = X.split() p = (int(p)-1) if acs[p] == 0: if s == 'AC': acs[p] = 1 else: was[p] += 1 print(*[sum(acs), sum(w for a, w in zip(acs, was) if a)])" p02802,s517757847,Accepted,"n,m=map(int,input().split()) ac=0 wa=0 ans=[True]*n wa=[0]*n for i in range(m): p,s=input().split() p=int(p)-1 if s==""AC"" and ans[p]: ans[p]=False ac+=1 elif s==""WA"" and ans[p]: wa[p]+=1 cnt=0 for i in range(n): if not ans[i]: cnt+=wa[i] print(ac,cnt) " p02802,s933214085,Accepted,"def main(): import sys input = sys.stdin.buffer.readline n,m=map(int,input().split()) ac,wa,l,k=0,0,[0]*n,[0]*m for _ in k: p,s=input().split() p=int(p) if type(l[p-1])==int: if s==b'AC': ac+=1 wa+=l[p-1] l[p-1]='' else: l[p-1]+=1 print(ac,wa) if __name__ == '__main__': main()" p02802,s555268692,Accepted,"n,m = (int(i) for i in input().split()) ac,wa = 0,0 score = {i+1:[] for i in range(n)} for _ in range(m): p,s = (i for i in input().split()) score[int(p)].append(s) for v in score.values(): if ""AC"" in v: wa += len(v[:v.index(""AC"")]) ac += 1 print(ac,wa) " p02802,s205450227,Accepted,"n,m=map(int,input().split()) l=[0]*(n+1) miss=[0]*(n+1) for _ in range(m): p,s=input().split() p=int(p) if l[p]==0: if s=='AC': l[p]+=1 else: miss[p]+=1 for i in range(1,n+1): if l[i]==0 and miss[i]!=0: miss[i]=0 a=l.count(1) b=sum(miss) print(a,b)" p02802,s460535081,Accepted,"N, M = map(int, input().split()) PS = [list(input().split()) for x in range(M)] question = [0]*(N+1) wrong = [0]*(N+1) for i in range(M): if PS[i][1] == 'AC': if question[int(PS[i][0])] == 0: question[int(PS[i][0])] = 1 else: if question[int(PS[i][0])] == 0: wrong[int(PS[i][0])] += 1 WA = 0 for i in range(N+1): if question[i] == 1: WA += wrong[i] print(sum(question), WA)" p02802,s783066225,Accepted,"N, M = map(int, input().split()) isAC = [0]*N ac = 0 WA = [0]*N for _ in range(M): p, s = input().split() p = int(p) if not isAC[p-1]: if s == 'AC': isAC[p-1] = 1 ac += 1 else: WA[p-1] += 1 wa = sum([i*j for i, j in zip(isAC, WA)]) print(ac, wa)" p02802,s990167862,Accepted,"n, m = map(int, input().split()) wa = [0]*(n+1) ac = [0]*(n+1) for i in range(m): p, s = input().split() p = int(p) if ac[p]: continue if s == 'WA': wa[p] += 1 else: ac[p] = 1 a, b = 0, 0 for c, w in zip(ac, wa): if c == 0: continue a += 1 b += w print(a, b)" p02802,s252989979,Accepted,"n,m = map(int,input().split()) ans = 0 clear = 0 chk = [0]*(n+1) for i in range(m): p,s = input().split() p = int(p) if chk[p] >=0: if s==""WA"": chk[p]+=1 elif s ==""AC"": ans += chk[p] chk[p]=-1 clear+=1 print(str(clear)+"" ""+str(ans))" p02802,s863984721,Accepted,"N, M = map(int, input().split()) p = [list(map(str, input().split())) for _ in range(M)] aclst = [0] * (N + 1) walst = [0] * (N + 1) cntw = 0 cnta = 0 for i in range(M): if aclst[int(p[i][0])] == 0: if p[i][1] == 'WA': walst[int(p[i][0])] += 1 else: cnta += 1 cntw += walst[int(p[i][0])] aclst[int(p[i][0])] = 1 print(cnta, cntw)" p02802,s056041977,Accepted,"N, M = map(int, input().split()) result = [] ans = dict((s, False) for s in range(1, N+1)) pen = dict((s, 0) for s in range(1, N+1)) for _ in range(M): s, d = input().split() if d == ""AC"": ans[int(s)] = True continue if d == ""WA"" and not ans[int(s)]: pen[int(s)] += 1 ans_result = 0 for _, v in ans.items(): if v: ans_result += 1 pen_result = 0 for k, v in pen.items(): if ans[k]: pen_result += v print(ans_result, pen_result) " p02802,s240701861,Accepted,"import math n, m = map(int, input().split("" "")) d = {} for i in range(1, n + 1): d[i] = {""AC"": False, ""WA"": 0} acc, wac = 0, 0 for _ in range(m): q, m = input().split("" "") q = int(q) if not d[q][""AC""]: if m == ""WA"": d[q][""WA""] += 1 elif m == ""AC"": d[q][""AC""] = True acc += 1 wac += d[q][""WA""] print(acc, wac)" p02802,s681709241,Accepted,"N,M=map(int,input().split()) LIST=[0]*(10**5+1) PLIST=[0]*(10**5+1) C=0 P=0 for i in range(M): A=list(map(str,input().split())) if(A[1]==""WA""): if(LIST[int(A[0])]==0): PLIST[int(A[0])]+=1 else: if(LIST[int(A[0])]==0): C+=1 LIST[int(A[0])]=1 for i in range(len(LIST)): P+=LIST[i]*PLIST[i] print(C,P) " p02802,s662601434,Accepted,"N, M = map(int, input().split()) ls = tuple([] for i in range(N)) for _ in range(M): p, S = input().split() p = int(p) ls[p - 1].append(S) cnt_crr = 0 cnt_pnt = 0 for e in ls: if ""AC"" in e: for _e in e: if _e == ""AC"": cnt_crr += 1 break cnt_pnt += 1 print(cnt_crr, cnt_pnt) " p02802,s303682230,Accepted,"from collections import defaultdict N,M = map(int,input().split()) dic = defaultdict(list) for i in range(M): p,s = input().split() dic[p].append(s) nAC = 0 nWA = 0 for k in dic.keys(): if 'AC' in dic[k]: for s in dic[k]: if s == 'AC': nAC += 1 break nWA += 1 print(nAC,nWA)" p02802,s769866621,Accepted,"N,M = map(int,input().split()) Nstate = {str(i):0 for i in range(1,N+1)} WAstate = {str(i):0 for i in range(1,N+1)} AC = 0 for _ in range(M): n,m = map(str,input().split()) if Nstate[n] == 0: if m == 'AC': Nstate[n] = 1 AC += 1 elif m == 'WA': WAstate[n] += 1 WA = 0 for i in range(1,N+1): if Nstate[str(i)] == 1: WA += WAstate[str(i)] print(AC,WA)" p02802,s423886145,Accepted,"n,m=map(int,input().split()) a=[0]*n w=[0]*n ac=0 wc=0 for _ in range(m): p,s=input().split() p=int(p)-1 if a[p]==0: if s=='AC': a[p]=1 ac+=1 wc+=w[p] else: w[p]+=1 print(ac,wc) " p02802,s709589954,Accepted,"N,M=map(int,input().split()) P=[] A=[] for i in range(M): n,a=input().split() P.append(int(n)) A.append(a) D=['0']*N Z=[0]*N a=0 p=0 for i in range(M): if D[P[i]-1]!='AC'and A[i]=='WA': Z[P[i]-1]+=1 D[P[i]-1]='WA' elif D[P[i]-1]!='AC' and A[i]=='AC': a+=1 p+=Z[P[i]-1] D[P[i]-1]='AC' print(a,p) " p02802,s737487188,Accepted,"n,m=map(int,input().split()) ac = 0 wa = 0 ac_list = [0]*n wa_list = [0]*n for _ in range(m): p,s=input().split() p = int(p) - 1 if ac_list[p] == 'AC': continue ac_list[p] = s if s == 'AC': ac += 1 wa += wa_list[p] else: wa_list[p] += 1 print(ac,wa)" p02802,s172728042,Accepted,"n, m = map(int, input().split()) submit = [] for i in range(m): temp = [x for x in input().split()] submit.append(temp) ac = [0] * (n + 1) wa = [0] * (n + 1) for i in range(m): result = submit[i][1] question = int(submit[i][0]) if result == 'AC' and ac[question] == 0: ac[question] = 1 elif result == 'WA' and ac[question] == 0: wa[question] += 1 for i in range(n + 1): if ac[i] != 1: wa[i] = 0 print(sum(ac), sum(wa))" p02802,s522317069,Accepted,"N, M = map(int, input().split()) lis = [[] for _ in range(N)] for _ in range(M): question, result = input().split() question = int(question) lis[question-1].append(result) AC_times = 0 WA_times = 0 for i in range(N): pre_WA_times = 0 for j in lis[i]: passed = False if not passed: if j == ""AC"": passed = True WA_times += pre_WA_times elif j == ""WA"": pre_WA_times += 1 if passed: AC_times += 1 break print(AC_times, WA_times)" p02802,s055555202,Accepted,"n,m=map(int,input().split()) ac_count=[0]*n wa_count=[0]*n ac=0 wa=0 for i in range(m): p,s=input().split() p=int(p)-1 if s==""AC"" and ac_count[p]==0: ac_count[p]=1 ac+=1 wa+=wa_count[p] elif s[0]==""W"": wa_count[p]+=1 print(ac,wa)" p02802,s403468722,Accepted,"from sys import stdin import sys import math from functools import reduce import itertools n,m = [int(x) for x in stdin.readline().rstrip().split()] check = [0 for i in range(n)] count = [0 for i in range(n)] for i in range(m): p, q = [x for x in stdin.readline().rstrip().split()] p = int(p) if q == 'AC': check[p-1] = 1 if q == 'WA' and check[p-1] == 0: count[p-1] = count[p-1] + 1 for i in range(n): if check[i] == 0: count[i] = 0 print(sum(check), sum(count)) " p02802,s624114995,Accepted,"n,m = map(int,input().split()) wa = [0 for _ in range(n)] ac = [0 for _ in range(n)] for i in range(m): p,s = input().split() p = int(p) if s == 'AC': ac[p-1] = 1 else: if ac[p-1]==1:continue wa[p-1] += 1 ans1 = sum(ac) ans2 = 0 for i in range(n): if ac[i] == 1: ans2 += wa[i] print(ans1,ans2)" p02802,s693251405,Accepted,"n, m = map(int, input().split()) seikai = set() pena_num = 0 pena = [0] * (n + 1) for i in range(m): p, s = map(str, input().split()) if s == 'WA': if p not in seikai: pena[int(p)] += 1 else: continue else: if p not in seikai: pena_num += pena[int(p)] seikai.add(p) else: continue print(len(seikai), pena_num)" p02802,s540316452,Accepted,"N,M = map(int,input().split()) if M == 0: print(0,0) exit(); x = {} for _ in range(M): a,w = map(str,input().split()) x.setdefault(int(a),[]).append(w) ac = at = wa = wt = 0 for k,v in x.items(): for j in v: if j == 'AC': at += 1 break elif j =='WA': wt += 1 if at == 0: wt = 0 else: ac += at wa += wt at = 0 wt = 0 print(ac,wa) " p02802,s286061286,Accepted,"n,m = map(int,input().split()) d = [False for _ in range(n)] w = 0 a = 0 for i in range(m): P,S = input().split() P = int(P) if(S == 'WA'): if(d[P-1] >= 0):d[P-1] += 1 elif(S == 'AC'): if(d[P-1] >= 0): a += 1 w += d[P-1] d[P-1] = -1 print(a,w) " p02802,s721705568,Accepted,"from collections import defaultdict N, M = map(int, input().split()) done = set() ac = defaultdict(int) wa = defaultdict(int) # ACを一回以上出した問題のみ for _ in range(M): p, s = map(str, input().split()) if s == ""WA"": if p not in done: wa[p] += 1 elif s == ""AC"": if p not in done: ac[p] += 1 done.add(p) a = len(ac) w = 0 for k, v in wa.items(): if k in done: w += v print(a, w) " p02802,s926223566,Accepted,"N, M = map(int, input().split()) P = [0] * M S = [""a""] * M flg = [0] * N C = 0 D = 0 E = [0] * N for i in range(M): tmp, S[i] = map(str, input().split()) P[i] = int(tmp) if S[i]==""AC"": if flg[P[i]-1]==0: C += 1 flg[P[i]-1] = 1 E[P[i]-1] = 0 elif S[i]==""WA"": if flg[P[i]-1]==0: D += 1 E[P[i]-1] += 1 print(C, D-sum(E)) " p02802,s178531565,Accepted,"n,m = map(int,input().split()) WA = [0]*n AC = [0]*n wa = 0 for i in range(m): x = input().split() x[0] = int(x[0]) if x[1] == 'WA' and AC[x[0]-1] == 0: WA[x[0]-1] += 1 elif x[1] == 'AC' and AC[x[0]-1] == 0: AC[x[0]-1] += 1 wa += WA[x[0]-1] print(sum(AC),wa) " p02802,s941751526,Accepted,"n,m=map(int,input().split()) x=[True]*n cnt=[0]*n y=0 z=0 for i in range(m): p,s=input().split() if s==""AC"": x[int(p)-1]=False elif x[int(p)-1]: cnt[int(p)-1]+=1 for i in range(n): if x[i]==False: z+=cnt[i] y+=1 print(y,z)" p02802,s862137775,Accepted,"N,M = map(int,input().split()) #AC,WA P = [0]*N Penalty = 0 Accepted = 0 for i in range(M) : p,S = input().split() p = int(p) if S == ""AC"" and P[p-1] != -1: Penalty += P[p-1] Accepted += 1 P[p-1] = -1 elif S == ""WA"" and P[p-1] != -1: P[p-1] += 1 print(Accepted,Penalty)" p02802,s822335749,Accepted,"n,m=map(int,input().split()) l=[] ansac=0 answa=0 a=[0]*(n) d=dict() for i in range(m): p,s=input().split() l.append([int(p),s]) for i in range(m): if l[i][1]=='AC': if l[i][0] not in d: ansac+=1 answa+=a[l[i][0]-1] d[l[i][0]]=0 else: a[l[i][0]-1]+=1 print(ansac,answa)" p02802,s961055598,Accepted,"N,M = map(int, input().split()) WL = [0]*(N+1) AL = [0]*(N+1) WLsum = 0 for _ in range(M): xx = input().split() p = int(xx[0]) if xx[1]=='AC': if AL[p] == 0: AL[p] = 1 WLsum += WL[p] else: WL[p] += 1 print(str(AL.count(1)) + ' ' + str(WLsum))" p02802,s448445761,Accepted,"n, m = map(int, input().split()) ac = [0]*n wa = [0]*n for i in range(m): p, s = input().split() p = int(p) if s == ""AC"": ac[p-1] = 1 elif s == ""WA"": if ac[p-1] != 1: wa[p-1] += 1 for i in range(n): if ac[i] == 0: wa[i] = 0 print(sum(ac), sum(wa)) " p02802,s210036197,Accepted,"import math N, M = map(int, input().split()) wa_list = [0] * N ac_list = [False] * N for i in range(M): p, s = map(str, input().split()) p = int(p) - 1 if s == 'AC': ac_list[p] = True else: if not ac_list[p]: wa_list[p] += 1 for i in range(N): if not (ac_list[i]): wa_list[i] = 0 print(sum(i == True for i in ac_list), sum(wa_list)) " p02802,s628166699,Accepted,"N, M = tuple(map(int, input().split())) P, S = [], [] for _ in range(M): p, s = input().split() P.append(int(p)) S.append(s) accepted = [False] * N wrong = [0] * N AC, WA = 0, 0 for p, s in zip(P, S): if s == ""WA"": if not accepted[p-1]: wrong[p-1] += 1 elif s == ""AC"" and accepted[p-1] is False: accepted[p-1] = True AC += 1 WA += wrong[p-1] print(AC, WA) " p02802,s635965530,Accepted,"n,m=map(int,input().split()) if m==0: print(0,0) import sys sys.exit() p=[list(input().split()) for _ in range(m)] correct=set([p[i][0] for i in range(m) if p[i][1]=='AC']) s=set() sum_wa=0 for i in [p[j] for j in range(m) if p[j][0] in correct]: if i[0] in s: continue else: if i[1]=='WA': sum_wa+=1 else: s.add(i[0]) print(len(correct),sum_wa)" p02802,s456450492,Accepted,"n, m = map(int, input().split()) flg = [0]*n ac = 0 pe = [0]*n for i in range(m): p, s = input().split() if flg[int(p)-1] == 0: if s == ""WA"": pe[int(p)-1] += 1 else: flg[int(p)-1] = 1 ac += 1 spe = 0 for i in range(n): if flg[i] == 1: spe += pe[i] print(ac, spe) " p02802,s838642143,Accepted,"n,m = map(int,input().split()) toi=[0 for i in range(n)] ac=0 wa=0 for i in range(m): p,s=map(str,input().split()) p=int(p) if s==""AC"": if toi[p-1]!=-1: wa+=toi[p-1] ac+=1 toi[p-1]=-1 else: if toi[p-1]!=-1: toi[p-1]+=1 print(ac,wa) " p02802,s680454111,Wrong Answer,"N,M=map(int,input().split()) PS=[] for i in range(M): x,y=input().split() PS.append((int(x),y)) ac=[0]*N wa=[0]*N for i in range(M): if PS[i][1]==""AC"" and ac[PS[i][0]-1]==0: ac[PS[i][0]-1]=1 elif PS[i][1]==""WA"" : if ac[PS[i][0]-1]!=1: wa[PS[i][0]-1]+=1 sac=sum(ac) swa=sum(wa) print(sac,swa) " p02802,s614092246,Wrong Answer,"N, M = map(int, input().split()) count = [0]*N ans = 0 ok = 1 for _ in range(M): p, s = input().split() if count[int(p)-1] >= 0 and s == ""WA"": count[int(p) - 1] += 1 elif count[int(p)-1] >= 0 and s == ""AC"": ans += count[int(p)-1] count[int(p)-1] = -1 ok += 1 print(ok, ans)" p02802,s794466591,Wrong Answer,"n,m = map(int,input().split()) ls = [] for i in range(m): p,m = map(str,input().split()) ls.append([p,m]) ac = 0 wa = 0 now = """" for i in ls: if now == i[0]: continue if i[1] == ""AC"": now = i[0] ac += 1 elif i[1] == ""WA"": wa += 1 print(ac,wa)" p02802,s573780808,Wrong Answer,"from sys import stdin n,m = [int(x) for x in stdin.readline().rstrip().split()] a = [] for i in range(m): a.append([x for x in stdin.readline().rstrip().split()]) ac = [0] * n wa = [0] * n WA = 0 for i in range(m): if a[i][1] == 'WA': wa[int(a[i][0])-1] += 1 if a[i][1] == 'AC': ac[int(a[i][0])-1] = 1 WA += wa[int(a[i][0])-1] print(sum(ac),WA)" p02802,s317429113,Wrong Answer,"N, M = map(int, input().split()) ans_list = [] pen_num = 0 cor_num = 0 for i in range(M): p_i, S_i = input().split() p_i = int(p_i) if not (p_i in ans_list and p_i<=N): if(S_i == ""WA""): pen_num += 1 elif(S_i == ""AC""): cor_num += 1 ans_list.append(p_i) print(""{} {}"".format(cor_num,pen_num)) " p02802,s807812108,Wrong Answer,"N,M = map(int,input().split()) AC_flag = [False]*N WA_count = [0]*N for m in range(M): P,S = map(str,input().split()) p = int(P) if AC_flag[p-1] == False and S == ""AC"": AC_flag[p-1] = True if AC_flag[p-1] == False and S == ""WA"": WA_count[p-1] += 1 print(*[sum(AC_flag),sum(WA_count)])" p02802,s481988804,Wrong Answer,"N, M = map(int, input().split()) ac = 0 wa = 0 l = [0] * (N + 1) for num in range(M): p, s = input().split() p = int(p) if s == ""AC"": if l[p] == 0: ac += 1 l[p] = 1 else: if l[p] == 0: wa += 1 print(*[ac, wa]) " p02802,s274729251,Wrong Answer,"from sys import stdin N, M = [int(_) for _ in stdin.readline().rstrip().split()] PM = [stdin.readline().rstrip().split() for _ in range(M)] AC = set() WA = {} for pm in PM: if pm[1] == ""AC"": AC.add(pm[0]) elif pm[1] == ""WA"": if pm[0] in AC: continue if pm[0] not in WA: WA[pm[0]] = 0 WA[pm[0]] += 1 print(len(AC), sum(WA.values()))" p02802,s019540460,Wrong Answer,"mondaisu , teisyutukaisu = map(int,input().split()) flag = [] penalog = [] for i in range(mondaisu): flag.append(0) penalog.append(0) for i in range(teisyutukaisu): bango , kekka = input().split() bango = int(bango) if flag[bango-1] == 1: continue if kekka == 'WA': penalog[bango-1] = penalog[bango-1] + 1 if kekka == 'AC': flag[bango-1] = 1 print(sum(flag),sum(penalog))" p02802,s998698751,Wrong Answer,"N, M = map(int, input().split()) solve_problem = [] penalty = 0 for i in range(M): p, S = input().split() if S == 'AC' and p not in solve_problem: solve_problem.append(p) if S == 'WA' and p not in solve_problem: penalty += 1 print('{} {}'.format(len(solve_problem), penalty)) " p02802,s633602689,Wrong Answer,"n, m = map(int, input().split()) check = {'AC' : [], 'WA' : 0} for i in range(m): q, result = input().split() q = int(q) if result == 'AC': if q not in check['AC']: check['AC'].append(q) else: if q not in check['AC']: check['WA'] += 1 print(str(len(check['AC'])) + "" "" + str(check['WA']))" p02802,s809571487,Wrong Answer,"n, m = map(int, input().split()) resultList = [0 for i in range(n)] #print(resultList) ansAC = 0 ansWA = 0 for i in range(m) : result = input().split() prob = int(result[0]) - 1 if result[1] == 'AC' and resultList[prob] == 0 : resultList[prob] = 1 ansAC += 1 if result[1] == 'WA' and resultList[prob] == 0 : ansWA += 1 print(ansAC, ansWA) " p02802,s729864009,Wrong Answer,"n, m = map(int, input().split()) ans = [] ans_0 = [] for i in range(m): ans_0 = list(map(str, input().split())) ans.append(ans_0) list0 = [] for j in range(n): list0.append(0) sei = 0 pen = 0 for lis in ans: if list0[int(lis[0])-1] == 0: if lis[1] == ""AC"": sei += 1 list0[int(lis[0])-1] = 1 else: pen += 1 else: pass print(str(sei)+"" ""+str(pen))" p02802,s766613438,Wrong Answer,"n,m=map(int,input().split()) cnt1=0 cnt2=0 flag=[-1]*(n+1) for _ in range(m): p,s=map(str,input().split()) p=int(p) if flag[p]==1: continue else: if s=='AC': cnt1+=1 flag[p]=1 else: cnt2+=1 print(cnt1,cnt2)" 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) " p02802,s792508647,Wrong Answer,"# N問出題 # M回提出 ans = [] pena = 0 N, M = map(int, input().split()) for m in range(M): p, s = input().split() # 次の問題へ if s == ""AC"": ans.append(p) if s == ""WA"" and (p not in ans): pena +=1 print(len(set(ans)), pena)" p02802,s776570898,Wrong Answer,"N,M = map(int, input().split()) wa_counter = [ 0 for i in range(N)] ac_flag = [ 0 for i in range(N)] for i in range(M): P_num, outcome = map(str, input().split()) if ac_flag[int(P_num)-1] == 0: if outcome == ""AC"": ac_flag[int(P_num)-1] = 1 else: wa_counter[int(P_num)-1] += 1 else: pass print(sum(ac_flag), sum(wa_counter)) " p02802,s851788822,Wrong Answer,"n,k=map(int,input().split()) c=[] d=[] co=0 wr=0 for i in range(k): a,b=map(str,input().split()) c.append(int(a)) if b=='AC': d.append(a) co+=1 if b=='WA' and a not in d: wr+=1 print(co,wr) " p02802,s661137372,Wrong Answer,"import sys import math import itertools import numpy rl = sys.stdin.readline n, k= map(int, rl().split()) li = [[0, 0] for _ in range(n)] for _ in range(k): a, b = rl().split() b = b.rstrip() a = int(a) - 1 if b == 'WA': li[a][0] += 1 elif li[a][1] == 0: li[a][1] = 1 ac = 0 wa = 0 for lis in li: i, v = lis wa += i if v == 1: ac += 1 print(ac, wa) " p02802,s826620611,Wrong Answer,"n,m=map(int,input().split()) l=list(input().split() for i in range(m)) l=[[int(i[0]),i[1]] for i in l] count=[[i+1,0,0,1] for i in range(n)] ans=0 pen=0 for i in l: for j in count: if i[0]==j[0]: if j[3]==1: if i[1]=='WA': pen+=1 else: ans+=1 j[3]*=0 print(ans,pen) " p02802,s934413372,Wrong Answer,"n, m = map(int, input().split()) A = [] fls = 0 tr = 0 for i in range(m): a, b = input().split() a = int(a) if b == ""WA"" and a not in A: fls += 1 elif b == ""AC"" and a not in A: A.append(a) tr += 1 print(tr, fls)" p02802,s293907487,Wrong Answer,"N,M = map(int,input().split()) P = [input().split() for m in range(M)] S = [] a = 0 for p,s in P: if p not in S: if s==""AC"": S.append(p) else: a+=1 print(len(S),a)" p02802,s714964734,Wrong Answer,"n, m = map(int, input().split()) list_num = list([] for i in range(n)) test = [input().split() for i in range(m)] check = [0] * n for i in test: list_num[int(i[0]) - 1].append(i[1]) count = 0 count_ac = 0 count_wa = 0 check = 0 for i in list_num: for j in range(len(i)): if(i[j] =='WA'): count += 1 else: count_ac += 1 check = 1 break if(check == 1): count_wa += count count = 0 check = 0 print(count_ac , count_wa) " p02802,s584940678,Wrong Answer,"def solve(n, m, PS): d = {} scores = [0, 0] for p, s in PS: if not p in d: d[p] = s if d[p] == 'WA': scores[0 if s == 'AC' else 1] += 1 d[p] = s return scores _n, _m = map(int, input().split()) _PS = [input().split() for _ in range(_m)] _scores = solve(_n, _m, _PS) print(_scores[0], _scores[1]) " p02802,s831342970,Wrong Answer,"n,m=map(int,input().split()) A=[] W=[] L=[] ac=0 wa=0 wa_0=0 for i in range(m): a,b=map(str,input().split()) if int(a) not in A and b == ""AC"": ac+=1 A.append(int(a)) wa+=wa_0 wa_0=0 elif int(a) not in A and b==""WA"": wa_0+=1 print(ac,wa) " p02802,s302889949,Wrong Answer,"N, M = map(int, input().split()) ans_list = [] for i in range(M): ans_list.append(input().split()) wa = 0 ac = 0 flag = 0 for n in range(1,N+1): for t in range(M): if ans_list[t][0] == str(n) and ans_list[t][1] == ""AC"": ac += 1 break elif ans_list[t][0] == str(n) and ans_list[t][1] == ""WA"": wa += 1 print(ac, wa)" p02802,s300444802,Wrong Answer,"n, m = list(map(int, input().split())) S = [input().split() for _ in range(m)] S = [[int(s[0]), s[1]] for s in S] acf = [0] * n p = 0 for s in S: if s[1] == 'AC': acf[s[0] - 1] = 1 continue elif acf[s[0] - 1] == 0: p += 1 continue ans = ' '.join(list(map(str, [sum(acf), p]))) print(ans)" p02802,s076810822,Wrong Answer,"n, m = map(int, input().split()) answered = [False] * n ans = 0 pena = 0 for _ in range(m): p, s = input().split() pidx = int(p) - 1 if answered[pidx]: continue if s == ""AC"": ans += 1 answered[pidx] = True else: pena += 1 print(""{} {}"".format(ans, pena)) " p02802,s616531584,Wrong Answer,"n,m = map(int,input().split()) score_list = [2]*m for i in range(m): score_list[i] = input().split() wa_num = 0 ac_q = [] for i in range(m): if score_list[i][1] == ""WA"" and score_list[i][0] not in ac_q: wa_num = wa_num + 1 elif score_list[i][1] == ""AC"" and score_list[i][0] not in ac_q: ac_q.append(score_list[i][0]) ac_num = len(ac_q) print(ac_num,wa_num)" p02802,s389379318,Wrong Answer,"#C n, m = map(int, input().split()) probrem = [0] * n warn = [0] * n for i in range(m): a, b = map(str, input().split()) a=int(a) if probrem[a - 1] == 0 and b == 'AC': probrem[a - 1] = 1 if probrem[a - 1] == 0 and b == ""WA"": warn[a - 1] += 1 # print(probrem,warn) print(sum(probrem),sum(warn))" p02802,s813986082,Wrong Answer,"N, M = map(int, input().split()) wa, ac = [0]*(N+1), [0]*(N+1) for i in range(1, M+1): pi, Si = input().split() pi = int(pi) if Si == 'WA' and ac[pi] == 0: wa[pi] += 1 elif Si == 'AC' and ac[pi] == 0: ac[pi] += 1 print('{} {}'.format(sum(ac), sum(wa)))" p02802,s416746461,Wrong Answer,"n,m = map(int,input().split()) count_ac = 0 count_wa = 0 l = [('','')]*m memo_n = [] idx = 0 for i in range(m): t = tuple(input().split()) l[i] = t if t[1] == 'AC' and t[0] not in memo_n: memo_n.append(t[0]) count_ac += 1 count_wa += l[idx:i+1].count((t[0],'WA')) idx = i print(str(count_ac) + "" "" + str(count_wa))" p02802,s304647468,Wrong Answer,"N, M = map(int, input().split()) AC = [0]*N WA = [0]*N for i in range(M): p, S = input().split() p = int(p) if S == ""AC"": AC[p-1] = 1 elif S == ""WA"": if not AC[p-1]: WA[p-1] = 1 for j in range(N): if AC[j]==0: WA[j]==0 print(sum(AC), sum(WA)) " p02802,s444623360,Wrong Answer,"n,m = map(int, input().split()) b = [0]*(n+1) AC,WA = 0,0 for _ in range(m): p,s = map(str, input().split()) if b[int(p)] == 0: if s == ""AC"": AC += 1 b[int(p)] = 1 else: WA += 1 print(AC,WA)" p02802,s571798776,Wrong Answer,"n,m = map(int,input().split()) ac, wa=[], {} for i in range(m): p,s = map(str, input().split()) if s=='AC': ac.append(p) elif (s=='WA') and (p not in ac): if p not in wa.keys(): wa[p]=1 else: wa[p]+=1 penalty = sum(wa.values()) clear = len(ac) print('%d %d'%(clear,penalty))" 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)" p02802,s933853228,Wrong Answer,"n,m=map(int,input().split()) list=[] seikai=0 sum=0 for i in range(m): p,s=input().split() if p not in list: if s=='AC': list.append(p) seikai=seikai+1 elif s=='WA': sum=sum+1 print(seikai,sum)" p02802,s019675952,Wrong Answer,"N,M=map(int,input().split()) AC=WA=[0] * (N + 1) cnt_AC=cnt_WA=0 for i in range(M): p,s=input().split() p=int(p) if AC[p]==0: if s=='WA': cnt_WA+=1 if s=='AC': AC[p]=1 cnt_AC=sum(AC) print(cnt_AC,cnt_WA)" p02802,s790867436,Wrong Answer,"import numpy as np N,M = map(int,input().split()) P = np.zeros(M, dtype=int) S = np.zeros(M, dtype=int) for i in range(M): p,s = map(str,input().split()) P[i] = int(p) if s == 'AC': S[i] = 1 cOK = 0 cNG = 0 aP = np.argsort(P) P = P[aP] S = S[aP] i = 0 while i 0: wa = [0] * N ac = set() ans = [0, 0] for s in S: if s[1] == ""AC"": ac.add(int(s[0])-1) elif s[1] == ""WA"" and int(s[0])-1 not in ac: wa[int(s[0])-1] += 1 print(len(ac), sum(wa)) else: print(0, 0) " p02802,s209121748,Wrong Answer,"N, M = map(int, input().split()) isACs = [0] * N numPenalty = 0 for _ in range(M): p, res = input().split() p = int(p) - 1 if res == 'AC': isACs[p] = 1 else: if not isACs[p]: numPenalty += 1 numAC = sum(isACs) print(numAC, numPenalty) " p02802,s728178501,Wrong Answer,"N, M = map(int, input().split()) A=[] p = [0] * M S = [0] * M for i in range(M): p[i], S[i]= map(str, input().split()) T=[int(p[i]),S[i]] A.append(T) A.sort(key=lambda x: x[0]) wa=0 ac=0 tmp=0 for j in range(M): if A[j][0]>tmp: if A[j][1]=='WA': wa+=1 else: ac+=1 tmp=A[j][0] print(ac,wa) " 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)" p02802,s290658162,Wrong Answer,"n,m = map(int,input().split()) ac_dir = {} wa_dir = {} for _ in range(m): p, s = input().split() if s == 'AC' and p not in ac_dir: ac_dir[p] = 1 elif s == 'WA' and p not in wa_dir and p not in ac_dir: wa_dir[p] = 1 elif s == 'WA' and p in wa_dir and p not in ac_dir: wa_dir[p] += 1 print(sum(ac_dir.values()), sum(wa_dir.values()))" p02802,s084204715,Wrong Answer,"n,m=map(int,input().split()) l=[] t="""" w=0 ww=0 a=0 for i in range(m): p,s=input().split() if(p in l):continue if(s==""WA""): w+=1 ww+=1 if(s==""AC""): ww=0 a+=1 l.append(p) print(a,w-ww)" p02802,s560629788,Wrong Answer,"n, m = map(int, input().split()) ans_ac = 0 ans_wa = 0 lst = [] for i in range(m): p, s = input().split() if p in lst: continue if s == 'WA': ans_wa += 1 else: ans_ac += 1 lst.append(p) print(ans_ac, ans_wa)" p02802,s263782455,Wrong Answer,"# -*- coding: utf-8 -*- import sys N,M = map( int, input().split() ) list_str_P_S = [input().split() for i in range(M)] #----- count_AC=0 count_WA=0 check_question_no=[] for L in list_str_P_S: str_number = L[0] result = L[1] if ( str_number in check_question_no ): continue else: if result == ""WA"": count_WA += 1 elif result == ""AC"": count_AC += 1 check_question_no.append(str_number) print(count_AC,count_WA) " p02802,s749463175,Wrong Answer,"n,m = map(int,input().split()) l=list(input().split() for _ in range(m)) q=[0]*n w=0 a=0 for i in l: if q[int(i[0])-1]==0: if i[1]==""WA"": w+=1 elif i[1]==""AC"": a+=1 q[int(i[0])-1]+=1 print(a,w)" 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)" p02802,s314374489,Wrong Answer,"#N=int(input()) #N,M=map(int, input().split()) #L=list(map(int, input().split())) N,M=map(int, input().split()) ifacL=[0]*N psL=[] AC=0 WA=0 for _ in range(M): psL.append(list(map(str, input().split()))) for i in range(M): if ifacL[int(psL[i][0])-1]==0 and psL[i][1]==""WA"": WA+=1 elif ifacL[int(psL[i][0])-1]==0 and psL[i][1]==""AC"": AC+=1 ifacL[int(psL[i][0])-1]=1 print(AC,WA)" p02802,s194794220,Wrong Answer,"n, m = map(int, input().split()) a = [input().split() for i in range(m)] solved = [False] * n ac_cnt = 0 wa_cnt = 0 for i in range(m): cn, cj = int(a[i][0]) - 1, a[i][1] if not solved[cn]: if cj == 'WA': wa_cnt += 1 else: ac_cnt += 1 solved[cn] = True print(ac_cnt, wa_cnt) " p02802,s775848504,Wrong Answer,"N,M = map(int,input().split()) arr = [] pre_idx = '-1' pre_s = 'start' cnt = 0 errors = 0 ans = 0 for i in range(M): idx,s = input().split() arr.append([int(idx),s]) arr = sorted(arr) flag = False for idx,s in arr: if pre_idx != idx: cnt = 0 flag = False if flag: continue else: if s=='WA': cnt += 1 else: errors += cnt ans += 1 flag = True pre_idx = idx pre_s = s print(ans,errors) " p02802,s796342438,Wrong Answer,"import sys inputs = sys.stdin.readlines() n, m = map(int, inputs[0].split()) P, S = [], [] for s in inputs[1:]: x, y = s.split() P.append(int(x)-1) S.append(y) num_ac = num_wa = 0 acs = [0]*n for p, s in zip(P, S): if acs[p]: continue if s == 'WA': num_wa += 1 else: acs[p] = 1 num_ac += 1 print(*[num_ac, num_wa])" p02802,s176613018,Wrong Answer,"n,m=map(int,input().split()) a=[0]*(n+1) b=[0]*(n+1) for i in range(m): p,s=input().split() p=int(p) if a[p]==0: if s==""AC"": a[p]=1 else: b[p]+=1 for i in range(n): if a[i]==0: b[i]==0 print(sum(a),sum(b))" p02802,s258227151,Wrong Answer,"N, M = map(int, input().split()) ac = [0]*N wa = [0]*N for m in range(M): p, s = input().split() p = int(p) - 1 if s == 'AC' and ac[p] == 0: ac[p] += 1 elif s == 'WA' and wa[p] == 0: wa[p] += 1 print(ac.count(1), wa.count(1)) " p02802,s867685112,Wrong Answer,"import numpy as np N,M=map(int,input().split()) ac=np.array([0]*N) wa=np.array([0]*N) for i in range(M): a,b=input().split() A=int(a) if ac[A-1]==0 and b==""WA"": wa[A-1]+=1 else : ac[A-1]=1 cal=sum(ac) ans=sum(ac*wa)" p02802,s402756102,Wrong Answer,"N, M = list(map(int, input().split())) list_WA = [0] * N list_Flag = [0] * N for i in range(M): a, b = list(map(str, input().split())) a=int(a) if not list_Flag[a-1] == 1: if b=='WA': list_WA[a-1]=list_WA[a-1]+1 elif b=='AC': list_Flag[a-1]=1 WA=sum(list_WA) AC=sum(list_Flag) print(AC,WA) " p02802,s491525875,Wrong Answer,"# -*- coding: utf-8 -*- n, m = map(int,input().split()) a = [] for i in range(m): a.append([str(i) for i in input().split()]) ac = [] ans2 = 0 for i in range(m): if a[i][1] == ""AC"": ac.append(a[i][0]) if a[i][1] == ""WA"" and not(a[i][0] in ac): ans2 += 1 ans1 = len(set(ac)) print(ans1,end = "" "") print(ans2) " p02802,s817595604,Wrong Answer,"N, M = map(int, input().split()) PS = [list(map(str, input().split())) for _ in range(M)] ac_cnt, wa_cnt = 0, 0 n_and_ac = {} for n in range(N): n_and_ac[str(n + 1)] = 0 for ps in PS: if ps[1] == ""AC"" and n_and_ac[ps[0]] == 0: n_and_ac[ps[0]] += 1 ac_cnt += 1 if ps[1] == ""WA"" and n_and_ac[ps[0]] == 0: wa_cnt += 1 print(str(ac_cnt) + "" "" + str(wa_cnt)) " p02802,s732369686,Wrong Answer,"N, M = map(int, input().split()) AC = [0]*N WA = [0]*N for i in range(M): p, S = input().split() p = int(p) if S == ""AC"": AC[p-1] = 1 elif S == ""WA"": if not AC[p-1]: WA[p-1] = 1 for j in range(N): if AC[j]==0: WA[j]==0 print(sum(AC), sum(WA)) " p02802,s027577429,Wrong Answer,"n, m = map(int, input().split()) P, S = [], [] for _ in range(m): p, s = input().split() P.append(int(p)) S.append(s) ac = {} wa = {} for p, s in zip(P, S): if s == 'AC': ac.setdefault(p, 1) else: wa.setdefault(p, 0) if wa[p] == 0: wa[p] += 1 n_ac = 0 n_wa = 0 for i in ac.values(): n_ac += i for i in wa.values(): n_wa += i print(n_ac,n_wa)" p02802,s800861688,Wrong Answer,"N, M = map(int, input().split()) if M == 0: print(0,0) exit() false_count = 0 ans = 0 p, s = input().split() now = int(p) if s == ""WA"": false_count += 1 elif s == ""AC"": ans += 1 now += 1 for i in range(M-1): p, s = input().split() if int(p) > now: now = int(p) if int(p) == now: if s == ""WA"": false_count += 1 elif s == ""AC"": ans += 1 now += 1 print(ans, false_count)" p02802,s353833614,Wrong Answer,"from operator import itemgetter n, m = map(int, input().split()) X = [] ac = [0] * (n+1) wa = [0] * (n+1) for _ in range(m): x, y = input().split() X += [(int(x), y)] # X = sorted(X, key=itemgetter(0)) for (x, y) in X: if ac[x] == 0: if y == 'AC': ac[x] = 1 if y == 'WA': wa[x] += 1 print(x, y, sum(ac), sum(wa)) print(sum(ac), sum(wa)) " p02802,s742996719,Wrong Answer," N, M = [int(x) for x in input().split("" "")] subms = [input().split("" "") for i in range(M)] setto = set() penalties = 0 correct = 0 for sub in subms: sub[0] = int(sub[0]) if sub[0] not in setto and sub[0] <= N: if sub[1] == ""WA"": penalties += 1 if sub[1] == ""AC"": correct += 1 setto.add(sub[0]) print(correct, penalties) " p02802,s613681158,Wrong Answer,"N,M = map(int,input().split()) X = [[str(i) for i in input().split()] for i in range(M)] a=[] count_ac = 0 count_wa = 0 for i in range(M): if X[i][0] in a: continue if X[i][1] == 'AC': a.append(X[i][0]) count_ac += 1 else: count_wa += 1 print(count_ac,count_wa) " p02802,s202958460,Wrong Answer,"n,m = map(int,input().split()) prbs = [ [0] for _ in range(1,n+1)] #print(prbs) for _ in range(m): i,j = map(str,input().split()) i = int(i) i -= 1 if prbs[i][-1] != ""AC"": prbs[i].append(j) pen = 0 for i in range(n): pen += prbs[i].count(""WA"") ans = 0 for i in range(n): ans += prbs[i].count(""AC"") #print(prbs) print(ans,pen)" p02802,s665526079,Wrong Answer,"#!/usr/bin/env python3 def main(): N, M = map(int, input().split()) pS = [list(input().split()) for _ in range(M)] score = [0] * (N + 1) ac = [0] * (N + 1) for p, S in pS: p = int(p) if S == 'AC': ac[p] = 1 if ac[p]: continue score[p] += 1 print(sum(ac), sum(score)) # print(score) if __name__ == '__main__': main() " p02802,s401494738,Wrong Answer,"from collections import defaultdict N,M = map(int,input().split()) AC_List = defaultdict(int) WA_List = defaultdict(int) for i in range(M): Num,Sta = map(str,input().split()) if Num in AC_List: continue else: if Sta == ""WA"": WA_List[Num] += 1 else: AC_List[Num] += 1 print(str(len(AC_List))+"" "" +str(sum(WA_List.values()))) " p02802,s746318822,Wrong Answer,"N, M = map(int, input().split()) PS = [list(input().split()) for _ in range(M)] C = [0 for _ in range(N + 1)] cnt = 0 ans = 0 for p, s in PS: if C[int(p)] == 0: if s == ""WA"": cnt += 1 else: C[int(p)] += 1 ans += 1 print(ans, cnt) " p02802,s426787466,Wrong Answer,"N, M = list(map(int, input().split())) ac = 0 wa = 0 temp = -1 is_ac = False temp_wa = 0 for i in range(M): s = input().split() no = int(s[0]) result = s[1] if temp != no: temp = no temp_wa = 0 is_ac = False if (not is_ac) and result == 'AC': is_ac = True ac += 1 wa += temp_wa elif (not is_ac) and result == 'WA': temp_wa += 1 print(str(ac) + "" "" + str(wa))" 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:]))" 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]))" p02802,s855708095,Wrong Answer,"import sys input = sys.stdin.readline sys.setrecursionlimit(10000000) N, M = map(int, input().split()) ac_set = set() wa_count = 0 for i in range(M): p, s = input().split() # ACだった時の処理 if s == 'AC': ac_set.add(p) elif s == 'WA': if s not in ac_set: wa_count += 1 else: pass ac_count = len(ac_set) print('{} {}'.format(ac_count, wa_count)) " p02802,s907357542,Wrong Answer,"n,m = map(int,input().split()) p,s = [""0""]*m,[""WJ""]*m for i in range(0,m): p[i],s[i] = input().split() p = [int(s) for s in p] PN_count = [0]*(n) AC_count = [0]*(n) for i in range(len(s)): if(s[i] == ""AC""): AC_count[p[i]-1] = 1 else: if(AC_count[p[i]-1] != 1): PN_count[p[i]-1] += 1 print(sum(AC_count),sum(PN_count))" p02802,s464983796,Wrong Answer,"Input = list(map(int,input().split())) N = Input[0] M = Input[1] Ar = [] for i in range(M): Input = list(map(str,input().split())) Ar.append([]) Ar[i].append(int(Input[0])) Ar[i].append(Input[1]) ac = 0 pn = 0 ac_ar=[] pn_ar=[] for i in range(M): if not(Ar[i][0] in ac_ar): if Ar[i][1]==""AC"": ac_ar.append(Ar[i][0]) elif Ar[i][1]==""WA"": pn_ar.append(Ar[i][0]) ac = len(ac_ar) pn = len(pn_ar) print(ac,pn)" p02802,s462091828,Wrong Answer," n,m = map(int,input().split()) x = [0]*n #correct = 1 y = [0]*n #penalty for i in range(m): p,s = map(str,input().split()) p = int(p) if x[p-1] == 0: if s == ""WA"": y[p-1] += 1 else: x[p-1] = 1 elif x[p-1] == 1: if s == ""AC"": pass elif s == ""WA"": pass ans1 = sum(x) ans2 = sum(y) print(ans1,ans2) " p02802,s347189907,Wrong Answer,"n,m = map(int,input().split()) wa = [0]*n flag = [False]*n count = 0 for i in range(m): p,s = input().split() p = int(p) if s=='AC' and flag[p-1]==False: count += 1 flag[p-1] = True if s=='WA' and flag[p-1]==False: wa[p-1] += 1 print(count,' ',sum(wa))" p02802,s742564494,Wrong Answer,"N,M = map(int,input().split()) P = [] S = [] for i in range(M): p,s = input().split() p = int(p) P.append(p) S.append(s) #print(P) #print(S) AC = 0 WA = 0 AC_f = [0] * (N + 1) WA_f = [0] * (N + 1) #print(AC_f) for i in range(M): if AC_f[P[i]] == 0: if S[i] == ""AC"": AC += 1 AC_f[P[i]] = 1 else: WA += 1 print(AC,WA) " p02802,s301139014,Wrong Answer,"n,m=map(int,input().split()) l=list(input().split() for _ in range(m)) l=sorted(l,key=lambda x:x[0]) ll=[l[i][0] for i in range(m)] import itertools lll=[] for (k,g) in itertools.groupby(l,key=lambda x:x[0]): lll.append(list(g)) ans=0 re=0 a=0 w=0 for i in range(len(lll)): for j in lll[i]: if j[1]==""WA"": w+=1 elif j[1]==""AC"": a+=1 break print(a,w) " p02802,s645081893,Wrong Answer,"n,m=map(int,input().split()) a=[[0,0] for _ in range(n+1)] x=[] for i in range(m): x.append(list(input().split())) x[i][0]=int(x[i][0]) for i in range(m): if x[i][1]==""AC"": a[x[i][0]][1]=1 else: if a[x[i][0]][1]==1: continue else: a[x[i][0]][0]+=1 c=0 d=0 for i in range(1,n+1): c+=a[i][0] d+=a[i][1] print(d,c)" p02802,s089865702,Wrong Answer,"n,m = (int(x) for x in input().split()) memo = [0]*n pena = 0 for i in range(m): p,s = (str(x) for x in input().split()) p = int(p) if s==""AC"": memo[p-1] = 1 else: if memo[p-1]==0: pena += 1 print(""{} {}"".format(sum(memo),pena))" p02802,s008349829,Wrong Answer,"N,M = map(int,input().split()) AC = {} WA = {} for i in range(M): prb ,ans = input().split() if ans == ""AC"": AC[prb] = 1 else: if (prb in WA) == False and (prb in AC) == False: WA[prb] = 1 else: if (prb in AC) == False: WA[prb] +=1 wa = 0 for i,v in WA.items(): if prb in AC: wa += v print(""{} {}"".format(len(AC),wa))" p02802,s335534007,Wrong Answer,"n, m = map(int, input().split()) flags = [False]*n num_ac = 0 num_wa = 0 for i in range(m): p, s = input().split() p = int(p) if flags[p-1]: continue else: if s=='WA': num_wa += 1 else: flags[p-1] = True num_ac += 1 print(num_ac, num_wa)" p02802,s363054385,Wrong Answer,"n,m=map(int,input().split()) l=[list(input().split()) for _ in range(m)] ac=[] wa=0 for i in range(m): if l[i][1]==""AC"": ac.append(l[i][0]) elif l[i][1]==""WA"": if (l[i][0] in set(ac)) == False: wa += 1 print(len(set(ac)),wa)" p02802,s589721359,Wrong Answer,"n,m=map(int,input().split()) l=[list(input().split()) for _ in range(m)] ac=[] wa=0 for i in range(m): if l[i][1]==""AC"": if(l[i][0] in ac) == False: ac.append(l[i][0]) elif l[i][1]==""WA"": if (l[i][0] in ac) == False: wa += 1 print(len(ac),wa)" p02802,s933548517,Wrong Answer,"N,M =map(int,input().split()) score=[] for i in range(M): pS = list(map(str, input().split())) score.append(pS) AC = 0 WA = 0 for i in range(1,N+1): for j in range(M): if score[j][0]==str(i): if score[j][1]=='WA': WA+=1 elif score[j][1]=='AC': AC+=1 break print(AC,WA)" p02802,s149735313,Wrong Answer,"n,m=map(int,input().split()) L=[] AC=0 WA=0 for i in range(m): p,s=input().split() if p not in L and s==""WA"": WA+=1 if p not in L and s==""AC"": AC+=1 L.append(p) print(AC,WA) " p02802,s183952148,Wrong Answer,"N,M = map(int, input().split()) seito = [0] * (N+1) pena = 0 teisyutu = [''] * (M+1) for i in range(1, M+1) : teisyutu[i] = input().split() if seito[int(teisyutu[i][0])] == '1' : continue if teisyutu[i][1] == 'AC' : seito[int(teisyutu[i][0])] = '1' else : pena += 1 cnt = 0 for s in seito : if s == '1' : cnt += 1 print('%s %s' % (cnt, pena)) " p02802,s360813054,Wrong Answer,"n,m=map(int,input().split()) wa=0 ac=0 check = [0]*n for _ in range(m): a, b = input().split() i = int(a)-1 if check[i]==0: if b == ""WA"": wa+=1 elif b == ""AC"": ac+=1 check[i]=1 print(ac,wa)" p02802,s761192121,Wrong Answer,"n,m=map(int,input().split()) p=[0]*m s=[0]*m for i in range(m): pi,si=input().split() p[i]=int(pi) s[i]=si judge=[0]*(n+1) ac=0 wa=0 for i in range(m): if judge[p[i]]==-1: continue if judge[p[i]]==0: if s[i]=='WA': judge[p[i]]+=1 else: wa+=judge[p[i]] judge[p[i]]=-1 ac+=1 print(ac,wa)" p02802,s521329758,Wrong Answer,""""""" author : dokueki """""" n,m = map(int,input().split()) d = dict() AC,WA = 0,0 if m == 0: print(0,0) else: for i in range(m): a, b = input().split() if a not in d: d[a] = [] d[a].append(b) else: if d[a].count(""AC"") == 0: d[a].append(b) for k,v in d.items(): WA += v.count(""WA"") AC += v.count(""AC"") print(AC,WA) " p02802,s419151765,Wrong Answer,"n, m = list(map(int, input().split())) p, s = [], [] a = [False] * n cor = 0 fai = 0 for _ in range(m): p, s = input().split() p = int(p) if s == ""AC"": if a[p - 1] == False: a[p - 1] = True cor += 1 else: if a[p - 1]: pass else: fai += 1 print(cor, end=' ') print(fai)" p02802,s371342705,Wrong Answer,"# input N, M = map(int, input().split()) # check AC_cnt = 0 WA_cnt = 0 AC_questions = {} for i in range(M): P, S = map(str, input().split()) if P not in AC_questions: AC_questions[P] = False if AC_questions[P] is True: continue elif S == ""AC"": AC_cnt += 1 AC_questions[P] = True # S == ""WA"" else: WA_cnt += 1 print(AC_cnt, WA_cnt)" p02802,s779305483,Wrong Answer,"import math n, m = map(int, input().split()) ans = {} ac = ""AC"" wa = ""WA"" ac_num = [] wa_num = [] for _ in range(m): p, s = input().split() if s == ac: ac_num.append(p) elif not(p in set(ac_num)): wa_num.append(p) print(len(set(ac_num)), len((wa_num))) " p02802,s918274881,Wrong Answer,"import numpy as np DEB = False N,M = map(int, input().split()) res = np.zeros((N+1,2)) for i in range(M): p, s = input().split() p = int(p) if res[p][0] == 0: if s == 'AC': res[p][0] += 1 elif s == 'WA': res[p][1] += 1 if DEB: for r in res: print(r) print(int(res[:,0].sum()), int(res[:,1].sum()))" p02802,s536788547,Wrong Answer,"n,m=map(int,input().split()) a=0 b=0 x=[] for i in range(m): s,t=input().split() s=int(s) if s in x: continue else: if t=='AC': a+=1 x.append(s) else: b+=1 print(a,b) " p02802,s196536331,Wrong Answer,"N, M = [int(i) for i in input().split()] P = [] S = [] for _ in range(M): p, s = [x for x in input().split()] P.append(int(p)) S.append(str(s)) AC_list = [] penalty = 0 for i in range(M): if S[i] == ""AC"": AC_list.append(P[i]) if S[i] == ""WA"" and P[i] not in AC_list: penalty +=1 correct = len(set(AC_list)) print(correct, penalty) " p02802,s934254233,Wrong Answer,"N,M = map(int,input().split()) AC = [0]*N WA = [0]*N AC_cnt = 0 WA_cnt = 0 p = [0]*M S = [0]*M for i in range(M): p[i],S[i] = map(str, input().split()) for i in range(M): q_num = int(p[i]) if AC[q_num-1] == 0: if S[i] == ""AC"": AC[q_num-1] = 1 else: WA[q_num-1] += 1 for i in range(N): WA_cnt += WA[i] print(sum(AC),WA_cnt)" p02802,s658923169,Wrong Answer,"N,M=map(int,input().split()) ST=['WA'] * N WA=[0] * N OK=0 NG=0 for i in range(M): c,s = map(str,input().split()) c = int(c) if s == 'WA': if ST[c-1] != 'AC': #WA[c-1] += 1 NG += 1 else: if ST[c-1] != 'AC': ST[c-1] = 'AC' OK += 1 if OK == N: break print(""{} {}"".format(OK,NG)) " p02802,s942863801,Wrong Answer,"H, W = map(int, input().split()) A = [input().split() for _ in range(W)] a=0 b=0 c=0 for i in range(W): if A[i][0]!=c: c=A[i][0] b+=1 if A[i][1]==""WA"": a+=1 print(b,a)" p02802,s847725511,Wrong Answer,"N, M = map(int, input().split()) penalty = 0 a = [[False, 0] for i in range(N)] count = 0 for i in range(M): p, S = input().split() p = int(p) - 1 if a[p][0] == False: if S == 'WA': a[p][1] += 1 else: a[p][0] = True count += 1 else: pass print(count, sum([a[i][1] for i in range(N)]))" p02802,s540025110,Wrong Answer,"n, m = map(int,input().split()) pS = [tuple(input().split()) for _ in range(m)] pena = 0 correct = 0 flag = [False] * (10**6) for p, s in pS: p = int(p) if flag[p-1] == True: continue else: if s == ""WA"": pena += 1 else: correct += 1 flag[p-1] = True print(correct, pena)" p02802,s793604058,Wrong Answer,"def main(): N, M = [int(x) for x in input().split()] accepted = set() ans = 0 for i in range(M): p, s = input().split() if p in accepted: continue if s == ""WA"": ans += 1 else: accepted.add(p) print(len(accepted), ans) if __name__ == '__main__': main()" p02802,s732745293,Wrong Answer,"n, m = map(int, input().split()) ac = set() wa = 0 for _ in range(m): p, s = input().split() p = int(p) if s == 'AC': ac.add(p) elif not p in ac: wa += 1 print(len(ac), wa)" p02802,s827376948,Wrong Answer,"N,M = map(int,input().split()) AC = {} WA = {} for i in range(M): prb ,ans = input().split() if ans == ""AC"": AC[prb] = 1 else: if (prb in WA) == False: WA[prb] = 1 else: if (prb in AC) == False: WA[prb] +=1 wa = 0 for i,v in WA.items(): if prb in AC: wa += v print(""{} {}"".format(len(AC),wa))" p02802,s465114170,Wrong Answer,"import math def main(): N, M = map(int, input().split()) ans = [False for _ in range(N)] ac = 0 wa = 0 for _ in range(M): i, result = input().split() i = int(i) if ans[i-1] == False: if result == ""AC"": ac += 1 ans[i-1] = True elif result == ""WA"": wa += 1 print(sum(ans), wa) return 0 if __name__ == '__main__': main()" p02802,s514442630,Wrong Answer,"N,M=map(int,input().split()) # print(N) # print(M) L=[] for i in range(M): p,S=map(str,input().split()) p=int(p) L.append([p,S]) # print(L) Pcount=0 Acount=0 for i in range(N): for j in range(M): if L[j][0]==i+1: if L[j][1]==""WA"": Pcount+=1 else: Acount+=1 break print(Pcount,Acount)" p02802,s595250208,Wrong Answer,"n,m=map(int,input().split()) l=[input().split() for _ in range(m)] arr=[False for _ in range(n)] ac,wa=0,0 for r in l: if r[1]=='AC' and arr[int(r[0])-1]==False: ac+=1 arr[int(r[0])-1]=True continue elif r[1]=='WA' and arr[int(r[0])-1]==False: wa+=1 continue print(ac,wa)" p02802,s643166182,Wrong Answer,"N,M=map(int,input().split()) flag=[False]*(N+1) ac=0 wa=0 for _ in range(M): p,s=input().split() p=int(p) if flag[p]==False: if s=='AC': flag[p]=True ac+=1 else: wa+=1 print(ac,wa)" p02802,s017359481,Wrong Answer,"n, m = map(int, input().split()) cw = 0 ca = 0 d = {} for i in range(m): p, s = input().split() if d.get(p) == ""AC"": continue if s == ""WA"": cw += 1 else: ca += 1 d[p] = s print(ca, cw) " p02802,s172174358,Wrong Answer,"N,M = map(int,input().split()) p = [0]*M S = [0]*M for i in range(M): p[i],S[i]= map(str,input().split()) AC = [0]*(N+1) WA = [0]*(N+1) i = 0 while i < M: if S[i] == 'WA': if AC[int(p[i])] == 0: WA[int(p[i])] = WA[int(p[i])]+1 i = i+1 else: AC[int(p[i])]=1 i = i+1 print(sum(AC),sum(WA))" p02802,s111954547,Wrong Answer,"n,m=map(int,input().split()) l1=[list(input().split()) for i in range(m)] l2=[""WA""]*n account=0 wacount=0 for i in range(m): if l1[i][1]==""WA"" and l2[int(l1[i][0])-1]==""WA"": wacount+=1 if l1[i][1]==""AC"": l2[int(l1[i][0])-1]=""AC"" for i in range(n): if l2[i]==""AC"": account+=1 print(account,wacount)" p02802,s748076896,Wrong Answer,"import sys a,b=map(int,input().split()) account=0 wacount=0 acbox=[0]*(a+1) wabox=[0]*(a+1) for i in range(b): p,q=input().split() p=int(p) if q==""WA"": if acbox[p]==0: wabox[p]+=1 else: if acbox[p]!=0: account+=1 wacount+=wabox[p] acbox[p]=+1 print(account,wacount)" p02802,s665863062,Wrong Answer,"n, m = map(int,input().split()) list_ac = [] count_wa = 0 for i in range(m): p, s = map(str,input().split()) if s =='AC': list_ac.append(int(p)) else: if int(p) not in list_ac: count_wa +=1 print(len(set(list_ac)), count_wa)" p02802,s633329374,Wrong Answer,"import sys sys.setrecursionlimit(4100000) import math INF = 10**9 def main(): n,m = map(int, input().split()) wa = 0 ac = 0 used = {} for _ in range(m): p,s = map(str, input().split()) if used.get(p): continue if s == 'WA': wa += 1 if s == 'AC': ac += 1 used[p] = True print(ac, wa) if __name__ == '__main__': main() " p02802,s508640020,Wrong Answer,"N, M = map(int, input().split()) L = list() for m in range(M): l = input().split() L.append(l) AC = 0 WA = 0 cnt = '' res = False for m in range(M): if cnt != L[m][0]: res = False cnt = L[m][0] if L[m][1] == 'AC': if res: continue AC += 1 res = True elif L[m][1] == 'WA': if res: continue WA += 1 print('{} {}'.format(AC, WA))" p02802,s778584375,Wrong Answer,"import sys input() d={} nc=np=0 for ln in sys.stdin: p,S=ln.split() if p not in d: d[p]=0 if not d[p]: if S=='AC': d[p]=1 nc+=1 else: np+=1 print(nc,np) " p02802,s568169971,Wrong Answer,"n,m=map(int,input().split()) wa=0 ac=0 ig=[] for i in range(m): c,r=input().split() if c in ig: continue if r == 'WA': wa+=1 elif r == 'AC': ac+=1 ig.append(c) print(ac,wa)" p02802,s827356662,Wrong Answer,"N, M = list(map(int, input().split())) solved = {} failed = {} for _ in range(M): p, S = input().split() p = int(p) if S == 'AC': if p in solved: pass else: solved[p] = 1 else: if not (p in solved): if p in failed: failed[p] += 1 else: failed[p] = 1 print(sum(solved.values()), sum(failed.values()))" p02802,s994546221,Wrong Answer,"import sys n, m = map(int, sys.stdin.readline().split()) li = [[] for _ in range(n)] for _ in range(m): i, k = map(str, sys.stdin.readline().split()) k = k.strip() i = int(i) li[i-1].append(k) wa = 0 ac = 0 for i in li: for k in i: if k == 'WA': wa += 1 if k == 'AC': ac += 1 break print(ac, wa) " p02802,s611550513,Wrong Answer,"#C n,m=map(int,input().split()) f=False ps=[] AC=[0]*n WA=[0]*n for i in range(m): ps.append(list(input().split())) for i in range(m): if ps[i][1]=='AC'and AC[int(ps[i][0])-1]==0: AC[int(ps[i][0])-1]=1 if ps[i][1]=='WA'and WA[int(ps[i][0])-1]==0: WA[int(ps[i][0])-1]+=1 wasum=0 for i in range(n): if AC[i]==1: wasum+=WA[i] print(sum(AC),wasum)" p02802,s136737472,Wrong Answer,"n, m = map(int, input().split()) inp = [] ans = [(0, False) for _ in range(n)] for _ in range(m): inp.append(input().split()) for i in inp: q, r = int(i[0]) - 1, i[1] count = ans[q][0] flag = ans[q][1] if r == 'WA' and not flag: ans[q] = (count+1, False) if r == 'AC': ans[q] = (count, True) print(len(list(filter(lambda x: x[1], ans))), sum(map(lambda x: x[0], ans)),) " p02802,s545457807,Wrong Answer,"n,m=map(int,input().split()) a={} for i in range(1,n+1): a[str(i)]='WA' ans=0 pen=0 d=0 for i in range(m): p,s=input().split() if s == 'WA' and a[p] == s : d+=1 if s == 'AC' and a[p] != s: ans+=1 pen+=d a[p]=s d=0 print(ans,pen)" p02802,s229982638,Wrong Answer,"N, M = map(int, input().split()) P = list() for m in range(M): n, rst = input().split() n = int(n) P.append( (n, rst) ) ck = [False for _ in range(N+1)] ret_cor, ret_pen = 0, 0 for n, rst in P: if rst == 'AC': if not ck[n]: ck[n] = True ret_cor += 1 else: # rst == 'WA' if not ck[n]: ret_pen += 1 print(ret_cor, ret_pen) " p02802,s005390236,Wrong Answer,"from collections import defaultdict N, M = map(int, input().split()) P = [input().split() for _ in range(M)] X = defaultdict(int) ac = 0 wa = 0 for pi in P: i = int(pi[0]) s = pi[1] if X[i-1] == 0: if s == 'WA': wa += 1 else: ac += 1 X[i-1] = 1 print(ac, wa)" p02802,s984930858,Wrong Answer,"N,M = map(int,input().split()) P = [] s = [] sekai = 0 wrong = 0 for i in range(M): p,S = map(str,input().split()) P.append(int(p)) s.append(S) print(P,s) #problem = list(range(1,N+1)) problem = [] for j, ans in zip(P,s): if (j not in problem) and (ans == ""AC""): problem.append(j) sekai += 1 elif (j not in problem) and (ans == ""WA""): wrong += 1 print(sekai, wrong)" p02802,s905983835,Wrong Answer,"n,m = map(int,input().split()) q = [] ac = 0 wa = 0 for i in range(m): p,s = input().split() if p in q: continue else: if s==""AC"": ac += 1 q.append(p) else: wa += 1 print(ac,wa) " p02802,s352491597,Wrong Answer,"n,m = map(int, input().split()) num_ac = 0 num_wa = 0 tmp_num_wa = 0 answerd = [] for i in range(m): p,s = input().split() if p in answerd: continue if s == 'WA': tmp_num_wa += 1 if s == 'AC': num_ac += 1 num_wa += tmp_num_wa tmp_num_wa = 0 answerd.append(p) print(num_ac, num_wa)" p02802,s035050530,Wrong Answer,"N, M = map(int, input().split()) right = set() penalty = 0 for i in range(M): p, S = input().split() if S == 'AC': right.add(p) elif S == 'WA': if p not in right: penalty += 1 print(len(right), penalty)" p02802,s098575355,Wrong Answer,"n,m = map(int,input().split()) ac = 0 wa = 0 aclist = {} for i in range(n): aclist[i + 1] = 0 for i in range(m): a,b = input().split() a = int(a) if aclist[a] == 1: continue elif b == 'WA': wa += 1 else: aclist[a] += 1 ac += 1 print(int(ac), int(wa), end="""") " p02802,s831717521,Wrong Answer,"n,m=map(int,input().split()) wa=[0 for _ in range(n)] ac=[0 for _ in range(n)] for i in range(m): ps,s = input().split() p = int(ps) if s == ""WA"": if ac[p-1] == 0: wa[p-1] += 1 if s == ""AC"": if ac[p-1] == 0: ac[p-1] = 1 print(sum(ac),sum(wa))" p02802,s333373780,Wrong Answer,"N, M = map(int,input().split()) yes = [] no = [] for i in range(M): pS = list(input().split()) if pS[1] == 'AC': if pS[0] not in yes: yes.append(pS[0]) else: if pS[0] not in yes: no.append(pS[0]) x = len(yes) y = len(no) print(x, y) " p02802,s984734418,Wrong Answer,"n, m = map(int, input().split()) mapAC = [False]*(n+1) #mapWA = [True]*(n+1) countWA = [0]*(n+1) for i in range(m): p, s = input().split() p = int(p) if s == 'AC': mapAC[p] = True # mapWA[s] = False else: countWA[p] += 1*(not mapAC[p]) print(mapAC.count(True), sum(countWA))" p02802,s382432416,Wrong Answer,"N,M = map(int, input().split()) t = [[0]*N for _ in range(2)] for _ in range(M): p,s = input().split() if t[0][int(p)-1] == 0: if s == ""AC"": t[0][int(p)-1] = 1 else: t[1][int(p)-1] += 1 print(sum(t[0]),sum(t[1]))" p02802,s076347404,Wrong Answer,"n,m=map(int,input().split()) p=[0]*m s=[0]*m for i in range(m): p[i],s[i]=input().split() p[i]=int(p[i]) sum_ok,sum_miss=0,0 former_ok=[0]*n for p_,s_ in zip(p,s): if p_ in former_ok or p_>n:continue elif s_=='AC': former_ok[sum_ok]=p_ sum_ok+=1 if sum_ok==n:break else:sum_miss+=1 print(sum_ok, sum_miss)" p02802,s889567800,Wrong Answer,"params = input().split(' ') n = eval(params[1]) acfoundfor = [] penalties = 0 points = 0 for i in range(n): submission = input().split(' ') p = eval(submission[0]) status = submission[1] if p in acfoundfor: continue if status == 'AC': points += 1 acfoundfor.append(p) else: penalties += 1 print(points, penalties)" p02802,s985367347,Wrong Answer,"n, m = map(int, input().split()) c = [input().split() for i in range(m)] for i in range(m): c[i][0] = int(c[i][0]) AC, WA = 0, 0 aclist = [0 for i in range(n)] for i in range(m): if aclist[c[i][0] - 1] == 0: if c[i][1] == 'AC': aclist[c[i][0] - 1] += 1 AC += 1 else: WA += 1 print(AC, WA)" p02802,s159648492,Wrong Answer,"n, m = [int(i) for i in input().split()] ac = 0 wa = 0 answers = [False] * n for i in range(m): inp = input().split() p, s = int(inp[0]), inp[1] index = p - 1 if not answers[index] and s == ""AC"": ac += 1 answers[index] = True if not answers[index] and s == ""WA"": wa += 1 print(ac, wa) " p02802,s772763502,Wrong Answer,"N, M = map(int, input().split()) Alist = [[]]*M for i in range(M): Alist[i] = list(map(str, input().split())) collect = [False]*N NP = 0 NAC = 0 for j in range(M): if collect[int(Alist[j][0])-1] == False and Alist[j][1] == 'WA': NP += 1 elif collect[int(Alist[j][0])-1] == False and Alist[j][1] == 'AC': NAC += 1 collect[int(Alist[j][0])-1] = True print(collect) print(NAC, "" "", NP)" p02802,s148103376,Wrong Answer,"n, m = map(int, input().split()) ps = [] for i in range(m): ps.append(list(map(str, input().split()))) ac = 0 wa = 0 prob = [0]*n for i in range(m): if ps[i][1] == ""AC"" and prob[int(ps[i][0]) - 1] == 0: ac += 1 prob[int(ps[i][0]) - 1] = 1 if ps[i][1] == ""WA"" and prob[int(ps[i][0]) - 1] == 0: wa += 1 print(str(ac) + "" "" + str(wa)) " p02802,s205069143,Wrong Answer,"n,m = map(int,input().split("" "")) l = [0] * n wa = 0 ac = 0 for i in range(m): o,p = input().split("" "") if(p==""WA"" and l[int(o)-1] ==0): wa += 1 if(p==""AC""): if(l[int(o)-1] ==0): l[int(o)-1] = 1 ac += 1 print(str(ac) + "" "" + str(wa))" p02802,s995855776,Wrong Answer,"n , m = map(int,input().split()) if m == 0: print(0,0) exit() ps = [0] * m ss = [0] * m for i in range(m): p,s = map(str,input().split()) ps[i],ss[i] = int(p),s ac = [0] * (n + 1) wa = [0] * (n + 1) for i in range(m): if ac[ps[i]] == 1: continue if ss[i] == 'AC': ac[ps[i]] = 1 else: wa[ps[i]] += 1 for i in range(n): if ac[i] == 0: wa[i] = 0 print(sum(ac),sum(wa)) " p02802,s938504454,Wrong Answer,"N, M = map(int, input().split(' ')) ac_set = set() ac_cnt, wa_cnt = 0, 0 for i in range(M): num, res = input().split(' ') if num not in ac_set: if res == 'AC': ac_cnt += 1 ac_set.add(num) else: wa_cnt += 1 print(ac_cnt, wa_cnt)" p02802,s523514819,Wrong Answer,"n,m = map(int,input().split()) memo2 = [False for i in range(n)] count1,count2 = 0,0 for i in range(m): p,l = input().split() p = int(p)-1 if memo2[p]: continue else: if l == 'WA': count1+=1 else: count2+=1 memo2[p] = True print(count2,count1)" p02802,s531095918,Wrong Answer,"N,M = map(int, input().split()) answer_p = set() submit_p= set() count_pena=0 count_wa=0 for _ in range(M): p,S= input().split() if p in answer_p: continue else: if p not in submit_p: count_wa = 0 submit_p.add(p) if S=='WA': count_wa += 1 elif S=='AC': count_pena += count_wa answer_p.add(p) print(len(answer_p), count_pena) " p02802,s428074464,Wrong Answer,"n, m = map(int, input().split()) sub = [list(input().split()) for j in range(m)] li = [[0 for i in range(n)]for j in range(2)] for i in range(m): x = int(sub[i][0])-1 if sub[i][1] == 'AC': if li[0][x] == 0: li[0][x] += 1 elif li[0][x] == 0: li[1][x] += 1 else: break ac = sum(li[0]) wa = 0 for i in range(n): if li[0][i] == 1: wa += li[1][i] print('{} {}'.format(ac,wa)) " p02802,s733130107,Wrong Answer,"N,M = map(int,input().split()) p = [0]*M S = [0]*M ans_AC = [0]*10**5 ans_WA = [0]*10**5 for i in range(M): p[i],S[i] = map(str,input().split()) for i in range(M): if S[i] == ""AC"": if ans_AC[int(p[i])] != 1: ans_AC[int(p[i])] = 1 else: if ans_AC[int(p[i])] != 1: ans_WA[int(p[i])] += 1 print(sum(ans_AC),sum(ans_WA)) " p02802,s153957021,Wrong Answer,"n, m = map(int, input().split()) lst = [input().split() for i in range(m)] ac = [0] * n wa = [0] * n for i in range(m): p_i = int(lst[i][0]) if lst[i][1] == 'AC': ac[p_i-1] = 1 else: if ac[p_i-1] == 0: wa[p_i-1] += 1 num_ac = sum(ac) pnlt = sum(wa) print(num_ac, pnlt) " p02802,s088861034,Wrong Answer,"N, M = [int(i) for i in input().split()] corrects = [] wrongs = 0 for m in range(M): p, s = input().split() if p not in corrects: if s == ""WA"": wrongs += 1 elif s == ""AC"": corrects.append(p) print(len(corrects), wrongs)" p02802,s015148909,Wrong Answer,"n,m=map(int,input().split()) ac,wa=0,0 t=0 flg=True for i in range(m): p,s=input().split() if t!=p: flg=True t=p wa_t=0 if s==""WA"": wa_t+=1 else: ac+=1 wa+=wa_t flg=False else: if s==""WA"": wa_t+=1 elif s==""AC"" and flg: ac+=1 wa+=wa_t flg=False print(ac,wa) " p02802,s436257112,Wrong Answer,"n,m=map(int,input().split()) l=[0]*(n+1) p=0 for _ in range(m): a,b=list(input().split()) if str(b)==""AC"" and l[int(a)]==0: l[int(a)]=1 elif str(b)==""WA"" and l[int(a)]==0: p+=1 print(l.count(1),p)" p02802,s886090862,Wrong Answer,"N, M = map(int, input().split()) p = [0] * M S = ['a'] * M for i in range(M): p[i], S[i] = input().split() p[i] = int(p[i]) ansac = answa = 0 flg = [0] * N for i in range(M): if flg[p[i]-1] == 0: if S[i] == 'WA': answa += 1 elif S[i] == 'AC': ansac += 1 flg[p[i]-1] = 1 print(ansac, answa)" p02802,s729881689,Wrong Answer,"N,M=map(int,input().split()) P=[] for a in range(M): P.append(input().split()) error=0 right=0 han=[] for b in range(N): han.append(0) for a in P: """"""if sum(han)==len(han): break"""""" if a[1]==""WA"" and han[int(a[0])-1]==0 : error+=1 elif a[1]==""AC"" and han[int(a[0])-1]==0: han[int(a[0])-1]=1 right+=1 print(right,error)" p02802,s120079353,Wrong Answer,"import sys n, m = map(int, input().split()) ckn = set() swa = 0 ac = 0 for i in sys.stdin: pm, c = i.split() if not(pm in ckn): if c == 'WA': swa += 1 else: ckn.add(pm) ac += 1 print(ac, swa) " p02802,s598088950,Wrong Answer,"n,m = map(int,input().split()) p,s = [""0""]*m,[""WJ""]*m for i in range(0,m-1): p[i],s[i] = input().split() p = [int(s) for s in p] PN_count = [0]*(n+1) AC_count = [0]*(n+1) for i in range(m): if(s[i] == ""AC""): AC_count[p[i]-1] = 1 else: if(AC_count[p[i]] == 0): PN_count[p[i]-1] += 1 #print(AC_count,PN_count) print(sum(AC_count),sum(PN_count))" p02802,s826011104,Wrong Answer,"N, M= map(int, input().split()) WAlist = [0]*N ACflag = [0]*N for i in range(M): p, s = input().split() p=int(p) if ACflag[p-1] == 0: if s == ""WA"": WAlist[p-1] += 1 elif s == ""AC"": ACflag[p-1] = 1 print(sum(ACflag), sum(WAlist))" p02802,s160409579,Wrong Answer,"n, m = input().split() n = int(n) m = int(m) correct = 0 penalty = 0 numbers = set() for i in range(m): number, answer = input().split() number = int(number) if not number in numbers: if answer == ""AC"": correct += 1 numbers.add(number) else: penalty += 1 else: if not answer == ""AC"": if not number in numbers: penalty += 1 print(correct, penalty) " p02802,s326505508,Wrong Answer,"print('reference') 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])" p02802,s055696767,Wrong Answer,"#!/usr/bin/env python3 # -*- coding: utf-8 -*- def main(): n, m = map(int, input().split()) ac = [] wa = [] for i in range(m): p, s = input().split() if [p, 'AC'] in ac: continue if s == 'AC': ac.append([p, s]) else: wa.append([p, s]) print(len(ac), len(wa)) if __name__ == ""__main__"": main() " p02802,s558827827,Wrong Answer,"N, M = map(int, input().split()) acs = set() wa = was = 0 for _ in range(M): p, S = input().split() p = int(p) if p not in acs: if S == 'AC': acs.add(p) wa += was was = 0 else: was += 1 print(len(acs), wa)" p02802,s513587080,Wrong Answer,"N,M = map(int,input().split()) P = [] S = [] total = [] pena = 0 ok = 0 for i in range(M): a,b = map(str,input().split()) if b=='AC' and not a in total: ok+=1 total.append(a) elif b=='WA' and not a in total: pena+=1 print(str(ok)+' '+str(pena)) " p02802,s986878724,Wrong Answer,"n,m = map(int,input().split()) ac = [0]*(n+1) wa = [0]*(n+1) for _ in range(m): p,s = map(str,input().split()) if s == ""AC"" and ac[int(p)] == 0: ac[int(p)] += 1 if s == ""WA"" and ac[int(p)] == 0: wa[int(p)] += 1 print(sum(ac),sum(wa))" p02802,s082735791,Wrong Answer,"n,m = map(int,input().split()) ps = [list(input().split()) for _ in range(m)] wa = 0 ac = 0 flag = -1 for i in range(m): if flag == ps[i][0]: continue else: if ps[i][1] == ""AC"": ac += 1 flag = ps[i][0] else: wa += 1 print(ac,wa)" p02802,s472631191,Wrong Answer,"N,M = map(int,input().split()) grid = [] for i in range(M): array = list(map(str, input().strip().split())) grid.append(array) ac_list = [0]*N wa_list = [0]*N for a in grid: if a[1] == 'AC': ac_list[int(a[0]) - 1] = 1 elif a[1] == 'WA' and ac_list[int(a[0]) - 1] != 1: wa_list[int(a[0]) - 1] += 1 print(str(sum(ac_list)) + ' ' + str(sum(wa_list)))" p02802,s366347303,Wrong Answer,"n , m = (int(a) for a in input().split()) check = [] for i in range(m) : p,s = input().split() check.append([int(p),s]) ans = [] ng = 0 for i in range(m) : if check[i][0] not in ans : if check[i][1] == ""AC"" : ans.append(check[i][0]) else : ng += 1 print(len(ans) , ng)" p02802,s241870687,Wrong Answer,"# 問題数 = n と 回答数 = m を取得 n, m = map(int, input().split()) # 必要な変数を定義 ac = [0] * n wa = [0] * n for i in range(m): # i+1 回目の結果を取得 p, s = list(input().split()) p = int(p) - 1 # ACではない場合 if ac[p] != 1: wa[p] = 1 # ACである場合 if s == ""AC"": ac[p] = 1 print(sum(ac), sum(wa)) " p02802,s120677901,Wrong Answer,"N, M=list(map(int, input().split())) problem = [] result = [] for _ in range(M): str_list = input().split(' ') problem.append(int(str_list[0])) result.append(str_list[1]) first_AC = [False]*N pena = [0]*N for (p, r) in zip(problem, result): if first_AC[p-1]==False: if r=='WA': pena[p-1] += 1 elif r=='AC': first_AC[p-1]=True collect = sum(first_AC) total_pena = sum(pena) print('%d %d' % (collect, total_pena)) " p02802,s628304308,Wrong Answer,"n, m = map(int, input().split()) p = [] s = [] ans = [0, 0] for i in range(m): input_p, input_s = input().split() p.append(int(input_p)) s.append(input_s) ac_list = [] for i in range(m): if p[i] not in ac_list and s[i] == 'AC': ans[0] += 1 ac_list.append(p[i]) elif p[i] not in ac_list and s[i] == 'WA': ans[1] += 1 print(ans[0], ans[1]) " p02802,s482811222,Wrong Answer,"n, m = map(int, input().split()) A = [list(map(str, input().split())) for _ in range(m)] ans = 0 pen = 0 A = list(map(list, set(map(tuple, A)))) for i in range(len(A)): if A[i][1]=='AC': ans += 1 if i+1<=len(A)-1 and A[i+1] == (''.format(i), 'WA'): A.remove(A[i+1]) if A[i][1] == 'WA': pen += 1 print(ans, pen)" p02802,s117735784,Wrong Answer,"N , M = map(int , input().split("" "")) solve_problem = [0] * N ans = [0,0] for i in range(0,M): ps = input().split("" "") if ps[1] == ""AC"": if solve_problem[ int(ps[0]) -1] == 0: solve_problem[int(ps[0])-1] = 1 ans[0] += 1 else: if solve_problem[ int(ps[0])-1] == 0: ans[1] += 1 print(ans[0],ans[1])" p02802,s445593321,Wrong Answer,"N, M = map(int, input().split()) P = [] S = [] P_count = 0 S_count = 0 for i in range(M): p, s = input().split() if s == 'WA' and p not in P: S_count += 1 if s == 'AC' and p not in P: P.append(p) P_count += 1 print(P_count, S_count)" p02802,s263415140,Wrong Answer,"import sys s = sys.stdin.readlines() c = [] a = 0 b = 0 N, M = map(int, s[0].split()) for e in s[1:M + 1]: p, S = e.split() if p not in c: if S == 'AC': c.append(p) a += 1 else: b += 1 print('{} {}'.format(a, b)) " p02802,s901639324,Wrong Answer,"n, m = map(int, input().split()) ac = set() pn = 0 for i in range(m): p, s = map(str, input().split()) if s == 'AC': ac.add(p) if p not in ac and s == 'WA': pn += 1 print(len(list(ac)), pn)" p02802,s294961336,Wrong Answer,"N, M = map(int, input().split()) AC_list = set() WA = 0 AC = 0 for i in range(M): p, S = map(str, input().split()) if S == ""AC"": if p in AC_list: continue else: AC += 1 AC_list.add(p) elif S == ""WA"": if p not in AC_list: WA += 1 else: continue print(AC, WA)" p02802,s822453481,Wrong Answer,"N,M = map(int,input().split()) p = ['0']*M S = ['0']*M for i in range(M): p[i],S[i]= map(str,input().split()) AC = [0]*(N+1) WA = [0]*(N+1) i = 0 for i in range(M): if S[i] == 'WA': if AC[int(p[i])] == 0: WA[int(p[i])] = WA[int(p[i])]+1 else: AC[int(p[i])]=1 print(sum(AC),sum(WA))" p02802,s516049976,Wrong Answer,"N,M = map(int,input().split()) D = [[]for i in range(N)] AC = 0 WA = 0 for i in range(M): plobNum,res = input().split() D[int(plobNum)-1].append(res) for prob in D: for submit in prob: if submit == ""WA"" : WA+=1 else: AC+=1 break print(""{} {}"".format(AC,WA))" p02802,s994943148,Wrong Answer,"n,m=map(int,input().split()) A=[] W=[] L=[] ac=0 wa=0 wa_0=0 for i in range(m): a,b=map(str,input().split()) if int(a) not in A and b == ""AC"": ac+=1 A.append(int(a)) wa+=wa_0 wa_0=0 elif int(a) not in A and b==""WA"": wa_0+=1 print(ac,wa)" p02802,s873979291,Wrong Answer,"N, M = map(int, input().split()) PS = [input().split() for _ in range(M)] AC = [False] * (N+1) ans = 0 tmp_pena = 0 pena = 0 print(PS) for p, s in PS: p = int(p) if AC[p]: continue elif s == ""WA"": tmp_pena += 1 # pena = 1 これだと、AC確定時にpenalty加算されるというルールが守られない elif s == ""AC"": ans += 1 pena += tmp_pena AC[p] = True print(ans, pena, sep=' ')" p02802,s951834642,Wrong Answer,"N, M = map(int, input().split()) correct = 0 penalty = 0 answered = set() for _ in range(M): p, s = input().split() pn = int(p) if s == 'AC': if pn not in answered: correct += 1 answered.add(pn) elif s == 'WA': if pn not in answered: penalty += 1 print(correct, penalty) " p02802,s480808659,Wrong Answer,"n,m=map(int,input().split()) wa=[0]*(n+1) ac=[0]*(n+1) for i in range(m): p,s=input().split() p=int(p) if s=='AC': ac[p]=1 if s=='WA' and ac[p]==0: wa[p]+=1 print(sum(ac),sum(wa))" p02802,s273087913,Wrong Answer,"n,m=list(map(int, input().split())) cor,wro=0,0 dic={} for i in range(m): x,y=list(map(str, input().split())) if y==""AC"" and x not in dic: cor+=1 dic[x]=""ok"" elif y==""WA"": if x not in dic: wro+=1 print(cor,wro)" p02802,s288695718,Wrong Answer,"number,submit=input().rstrip().split() result=[input().rstrip().split() for i in range(int(submit))] #print(result) good=[] bad=[] for i in range(int(submit)): if result[i][1]=='AC': if result[i][0] not in good: good.append(result[i][0]) else: if result[i][0] not in good: bad.append(result[i][0]) print(str(len(good))+' '+str(len(bad)))" p02802,s380140095,Wrong Answer,"a,b=map(int,input().split()) List=[list(input().split()) for i in range(b)] account=0 wacount=0 acbox=[0]*(a+1) for i in List: if i[1]==""WA"": if acbox[int(i[0])]==0: wacount+=1 else: if acbox[int(i[0])]==0: acbox[int(i[0])]=1 account+=1 print(account,wacount)" p02802,s601496265,Wrong Answer,"N,M=map(int,input().split()) ans=dict() AC=0 WA=0 for i in range(M): P,S= map(str,input().split()) if((P in ans)==False): if(S=='AC'): AC+=1 ans[P]=S if(ans[P]=='WA'): if(S=='AC'): AC+=1 ans[P]=S elif(S=='WA'): WA+=1 print(AC,WA)" p02802,s289229708,Wrong Answer,"n, m = map(int, input().split()) ac = [0] * n wa = [0] * n for i in range(m): p, s = input().split() p = int(p) - 1 if s == 'AC': ac[p] = 1 if not ac[p] and s == 'WA': wa[p] += 1 print(sum(ac), sum(wa)) " p02802,s246460330,Wrong Answer,"N, M = map(int,input().split()) L = [] search_n_list = [i for i in range(N)] p_list = [0 for i in range(N)] ac_list = [0 for i in range(N)] for i in range(M): L_ = list(input().split()) p = int(L_[0]) - 1 w = L_[1] if p in search_n_list: if w == 'AC': ac_list[p] = 1 search_n_list.remove(p) else: p_list[p] += 1 print(""{} {}"".format(sum(ac_list), sum(p_list)))" p02802,s972297624,Wrong Answer,"n,m=map(int,input().split()) ps=[list(input().split()) for _ in range(m)] wa=0 ac=0 d=[0]*n for p,s in ps: if s=='WA': if d[int(p)-1]==0: wa+=1 else: if d[int(p)-1]==0: ac+=1 d[int(p)-1]=1 print(ac,wa)" p02802,s117306688,Wrong Answer,"n,m = map(int,input().split()) p = [0] * (m+2) s = [0] * (m+2) w_count = 0 a_count = 0 for i in range(1,m+1): p[i],s[i] = input().split() if p[i] != p[i-1]: flag = 0 if flag == 1: continue if s[i] == 'AC': flag = 1 a_count += 1 else: w_count += 1 print(a_count,w_count)" p02802,s109321691,Wrong Answer,"N, M = map(int, input().split()) p = [0] * M S = [0] * M for i in range(M): p[i], S[i] = input().split() p[i] = int(p[i]) count_ac = 0 count_wa = 0 a = set() for i in range(M): if S[i] == 'AC' and p[i] not in a: a.add(p[i]) count_ac += 1 if S[i] == 'WA' and p[i] not in a: for j in range(M): if S[j] == 'AC': count_wa += 1 print(count_ac, count_wa) " p02802,s384115276,Wrong Answer,"N, M = map(int, input().split()) p = [list(map(str, input().split())) for _ in range(M)] aclst = [0] * (N + 1) cntw = 0 cnta = 0 for i in range(M): if aclst[int(p[i][0])] == 0: if p[i][1] == 'AC': cnta += 1 aclst[int(p[i][0])] = 1 print(aclst) else: cntw += 1 print(cnta, cntw)" p02802,s912679513,Wrong Answer,"def main(): N, M = map(int, input().split()) ans = [False for _ in range(N)] ac = 0 wa = 0 for _ in range(M): i, result = input().split() i = int(i) if result == ""AC"": if ans[i-1] == False: ac += 1 ans[i - 1] = True else: if ans[i - 1] == False: wa += 1 print(ac, wa) return 0 if __name__ == '__main__': main()" p02802,s740208503,Wrong Answer,"N, M = map(int, input().split()) p = [] s = [] for i in range(M): a, b = input().split() p.append(int(a)) s.append(b) from collections import defaultdict correct = defaultdict(bool) ac = 0 wa = 0 for pp in p: correct[pp] = False for pp, ss in zip(p,s): if correct[pp]: pass else: if ss == 'AC': correct[pp] = True ac += 1 elif ss == 'WA': wa += 1 print(ac, wa) " p02802,s664429447,Wrong Answer,"import sys import math import itertools import numpy rl = sys.stdin.readline n, k= map(int, rl().split()) li = [['WA'] for _ in range(n)] for _ in range(k): a, b = rl().split() a = int(a) a -= 1 if li[a][-1] == 'WA': li[a].append(b) print(li) ac = 0 wa = 0 for i in li: for v in i: if v == 'AC': ac += 1 elif v == 'WA': wa += 1 print(ac, wa-len(li))" p02802,s553365341,Wrong Answer,"N,M=map(int,input().split()) ans=['WA' for i in range(N)] crt=0 mis=0 for i in range(M): p,S=map(str,input().split()) if ans[int(p)-1]=='WA': if S=='WA': mis+=1 else: crt+=1 ans[int(p)-1]='AC' else: continue print(crt,mis)" p02802,s945216307,Wrong Answer,"def main(): N,M = map(int, input().split()) ac = [0]*N wa = [0]*N for i in range(M): p,s = input().split() p = int(p)-1 if ac[p]==0: if s=='AC': ac[p] += 1 else: wa[p] += 1 ans = [sum(ac), sum(wa)] print(*ans) main() " p02802,s534636257,Wrong Answer,"N , M= map(lambda x: int(x),input().split()) isAC = [""WA""] * N score=0 penalty = 0 for i in range(M): p,r = input().split() #print(p,r) p = int(p) p -= 1 if isAC[p] ==""AC"": continue if r == ""WA"" and isAC[p] == ""WA"": penalty += 1 #print(penalty) elif r == ""AC"" and isAC[p] == ""WA"": isAC[p] = ""AC"" score+=1 #print(score) #print(isAC) print(score,penalty)" p02802,s979708214,Wrong Answer,"n,m = list(map(int , input().split())) wa = 0 ac = 0 ch = [] for i in range(m): f = list(map(str,input().split())) p = int(f[0]) s = str(f[1]) if p not in ch: if s == 'WA': wa+=1 elif s == 'AC': ch.append(p) ac+=1 print(ac,wa) " p02802,s939432151,Wrong Answer,"n, m = map(int, input().split()) query = [tuple(input().split()) for _ in range(m)] wa = [0] * n ac = [0] * n for p, result in query: p = int(p) - 1 if result == 'AC': ac[p] = 1 if result == 'WA': if ac[p] == 0: wa[p] += 1 accept = 0 penalty = 0 for i in range(n): if ac[i]: penalty += wa[p] accept += 1 print(accept, penalty)" p02802,s609333287,Wrong Answer,"N,M=map(int,input().split()) fin=set() AC=0 WA=0 for i in range(M): p,s=input().split() p=int(p) if not p in fin: if s==""AC"": AC+=1 fin.add(p) else: WA+=1 print(AC,WA)" p02802,s259023480,Wrong Answer,"n,m = map(int,input().split()) p = [] q = [] for i in range(m): s = list(map(str,input().split())) p.append(s[0]) q.append(s[1]) kotae = {} panel = 0 ac = 0 acichi = [[],[]] # 問題、位置の順 for i in range(m): if p[i] not in kotae: kotae[p[i]] = [] if p[i] not in acichi[0]: if q[i] == ""AC"": acichi[0].append(p[i]) acichi[1].append(q[i]) ac += 1 else: panel += 1 print(ac,panel)" p02802,s362327217,Wrong Answer,"N, M = map(int, input().split()) ps = [input().split() for i in range(M)] ac = 0 wa = 0 ansed = [] for psn in ps: if psn[1] == 'AC': if psn[0] not in ansed: ac += 1 ansed.append(psn[0]) else: if psn[0] not in ansed: wa += 1 print(ac, wa)" p02802,s064336242,Wrong Answer,"import sys def main(): N, M = map(int, input().split()) arr = [input().split() for i in range(M)] for j in arr: j[0] = int(j[0]) ac, wa = 0, 0 AC_lis = [] for k in arr: if k[1] == 'WA' and k[0] not in AC_lis: wa += 1 if k[1] == 'AC' and k[0] not in AC_lis: ac += 1 AC_lis.append(k[0]) print(ac, wa) main() " p02802,s816163068,Wrong Answer,"# coding: utf-8 # Your code here! N,M=map(int,input().split()) l=[0]*N ans=[0,0] for _ in range(M): num,judge=input().split() num=int(num) num-=1 if l[num]==1: continue else: if judge==""AC"": ans[0]+=1 l[num]=1 else: ans[1]+=1 print(*ans) " p02802,s426816491,Wrong Answer,"n, m = map(int, input().split()) info = [[] for _ in range(n)] for _ in range(m): p, s = input().split() info[int(p) - 1].append(s) AC = 0 WA = 0 for meta in info: for s in meta: # print(s) if s == 'AC': AC += 1 break else: WA += 1 print(AC, WA) # print(info)" p02802,s961548902,Wrong Answer,"n,m=map(int,input().split()) ac=[0]*(n+1) wa=0 for i in range(m): p,c=input().split() if c=='AC' and ac[int(p)]==0: ac[int(p)]=1 elif c=='WA' and ac[int(p)]==0: wa+=1 print(ac.count(1),wa)" p02802,s849474805,Wrong Answer,"N, M = map(int, input().split()) ACflags = [False] * N WAcounts = [0] * N for _ in range(M): p, s = input().split() p = int(p) - 1 if ACflags[p]: continue if s == 'AC': ACflags[p] = True else: WAcounts[p] += 1 print(sum(ACflags), sum(WAcounts))" p02802,s943869160,Wrong Answer,"import numpy as np n,m = map(int,input().split()) p = [] s = [] ans_a = np.zeros(n+1) ans_p = np.zeros(n+1) for i in range(m): pi ,si = map(str,input().split()) p.append(int(pi)) s.append(si) for i in range(m): if s[i] == ""AC"": ans_a[p[i]] = 1 if s[i] == ""WA"" and ans_a[p[i]] == 0: ans_p[p[i]] += 1 print(int(np.sum(ans_a)), int(np.sum(ans_p))) " p02802,s035285603,Wrong Answer,"x, y = map(int, input().split()) from collections import defaultdict dd = defaultdict(int) k = 0 #カウント数 for _ in range(y): a, b = map(str, input().split()) if b == 'AC': if a in dd: continue else: dd[a] = 1 elif b == 'WA': if a in dd: continue else: k += 1 s = 0 for _ in dd: s += 1 print(s, k)" p02802,s217773839,Wrong Answer,"import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines #n, m = map(int, readline().split()) n, m = map(int, input().split()) acCount = 0 waCount = 0 check = [0] * n for i in range(m): p, s = map(str, input().split()) # print(p,s) p = int(p) if (check[p - 1] == 0): if (s == 'WA'): waCount += 1 else: acCount += 1 check[p - 1] = 1 else: continue print(acCount, waCount) " p02802,s362638532,Wrong Answer,"n,m = map(int,input().split()) k = [] t,f = 0,0 for _ in range(m): a,b = map(str,input().split()) if a in k: pass elif b == ""AC"": k.append(a) t = t + 1 else: f = f + 1 print(t,f)" p02802,s129282737,Wrong Answer,"N, M = map(int, input().split()) P = [] S = [] flag = [False for i in range(0, N)] for i in range(0, M): x, y = map(str, input().split()) P.append(int(x)-1) S.append(y) ans = [0, 0] for i in range(0, M): if flag[P[i]]: continue else: if S[i] == 'AC': flag[P[i]] = True ans[0] += 1 else: ans[1] += 1 print(*ans) " p02802,s254876986,Wrong Answer,"n,m = map(int, input().split()) ps = [list(map(str, input().split())) for _ in range(m)] sum_wa = 0 sum_ac = 0 flag_ac = 0 for i in range(m): if flag_ac == 1: if ps[i][0] != ps[i-1][0]: flag_ac = 0 else: break if flag_ac == 0: if ps[i][1] == 'WA': sum_wa += 1 elif ps[i][1] == 'AC': flag_ac = 1 sum_ac += 1 print(sum_ac, sum_wa)" p02802,s297232666,Wrong Answer,"N,M= map(int,input().split()) P = [0 for _ in range(N+1)] S = [0 for _ in range(N+1)] for i in range(M): p, s = input().split() if s == ""WA"" and S[int(p)] != 1:P[int(p)] += 1 if s == ""AC"":S[int(p)] = 1 for i in range(N): if S[i] == 0:P[i] = 0 print(sum(S),sum(P))" p02802,s653876994,Wrong Answer,"n, m = [int(i) for i in input().split()] cs = list() cnt_c, cnt_w = 0, 0 for i in range(m): p, s = input().split() if p in cs: continue if s == 'AC': cnt_c += 1 cs.append(p) else: cnt_w += 1 print(cnt_c, cnt_w)" p02802,s743671361,Wrong Answer,"n,m=map(int,input().split()) if m==0: print(0,0) exit() l=[] for i in range(m): x,y=input().split() l.append([int(x),y]) l=sorted(l,key=lambda x:x[0]) ac=0 wa=0 tmp=0 t=[0]*(n+1) for i in range(m): if tmp==l[i][0]: continue elif l[i][1]==""WA"": wa+=1 elif l[i][1]==""AC"": ac+=1 tmp=l[i][0] print(ac,wa)" p02802,s145825082,Wrong Answer,"n,m=map(int,input().split()) A=[] W=[] L=[] ac=0 wa=0 wa_0=0 for i in range(m): a,b=map(str,input().split()) if a in A: continue if int(a) not in A and b == ""AC"": ac+=1 A.append(int(a)) wa+=wa_0 wa_0=0 elif int(a) not in A and b==""WA"": wa_0+=1 print(ac,wa) " p02802,s104241062,Wrong Answer,"n, m = map(int, input().split( )) wa = [0] * (n + 1) ac = [0] * (n + 1) for i in range(m): no_s, res = map(str, input().split( )) no = int(no_s) if ac[no] == 0 and res == ""AC"": ac[no] = 1 elif ac[no] == 0 and res == ""WA"": wa[no] += 1 for i in range(1, n): if ac[i] == 0: wa[i] = 0 acsum = 0 wasum = 0 for i in ac: acsum += i for i in wa: wasum += i print(str(acsum) + "" "" + str(wasum)) " p02802,s374007881,Wrong Answer,"N,M = map(int,input().split()) dic = {} for i in range(N): dic[i+1] = [0,0] for _ in range(M): round,result = input().split() round = int(round) if result == 'AC' and dic[round][0] == 0: dic[round][0] = 1 elif result == 'WA' and dic[round][0] == 0: dic[round][1] += 1 right = 0 wrong = 0 for item in dic.values(): right += item[0] wrong += item[1] print(right, wrong)" p02802,s989291432,Wrong Answer,"n,m=[int(i) for i in input().split()] l=[] w=0 c=0 for i in range(m): a,b=[str(i) for i in input().split()] a=int(a) if(a not in l): if(b=='WA'): w=w+1 else: c=c+1 l.append(a) print(c,w) " p02802,s480331501,Wrong Answer,"n, m = map(int, input().split()) a = [0]*n answ = [0, 0] for i in range(m): ind, ans = input().split() ind = int(ind) if a[ind-1] in [0, -1] and ans == 'WA': a[ind-1] = -1 answ[1]+=1; elif a[ind-1] in [0, -1] and ans == 'AC': a[ind-1] = 1 answ[0]+=1 a[ind-1] = 1 if ans == 'AC' else -1 print(answ[0], answ[1]) " p02802,s266070895,Wrong Answer,"import math N,M = map(int, input().split()) #A = list(map(int, input().split())) p=[] S=[] A=[0 for _ in range(N)] B=[0 for _ in range(N)] for i in range(M): p,S = input().split() p = int(p)-1 #p.append(a) #S.append(b) if S == ""AC"": A[p] = 1 elif A[p]==0: B[p] += 1 #s = input() #N = int(input()) #X = list(map(int, input().split())) MOD = 10 ** 9 + 7 print(sum(A), sum(B)) " p02802,s289631185,Wrong Answer,"import sys sys.setrecursionlimit(10000000) # input = sys.stdin.readline from bisect import * from collections import * # from heapq import * # import functools # import itertools # import math INF = 500000 mod = 10**9+7 N, M = map(int, input().split()) flg = [0] * N cnt = [0] * N for i in range(M): p, S = input().split() p = int(p)-1 if S == 'WA': if flg[p] == 0: cnt[p] += 1 else: if flg[p] == 0: flg[p] = 1 print(sum(flg), sum(cnt)) " p02802,s332805476,Wrong Answer,"def LI(): return [int(s) for s in input().split()] correct_answers = [] warning_count = 0 N,M = LI() for i in range(M): p_num, answer = [s for s in input().split()] p_num = int(p_num) include_answers = p_num in correct_answers if answer == 'AC' and not include_answers: correct_answers.append(p_num) elif answer == 'WA' and not include_answers: warning_count+=1 print(len(correct_answers),warning_count) " p02802,s204572060,Wrong Answer,"n,m = map(int,input().split()) mem = set() wrong = set() ac =0;wa =0 for i in range(m): a,b = input().split() if a not in mem: if b == 'AC': mem.add(a) ac+=1 else: wrong.add(a) c = mem.union(wrong) wa = len(c) print(ac,wa) " p02802,s858944859,Wrong Answer,"from collections import defaultdict N, M = map(int, input().split()) WA = defaultdict(int) AC = defaultdict(int) boollist = [False]*N for _ in range(M): p,s = input().split() p = int(p) if s == 'WA' and not boollist[p-1]: WA[p] += 1 elif s == 'AC': boollist[p-1] = True AC[p] = 1 print(sum(AC.values()), sum(WA.values()))" p02802,s698688796,Wrong Answer,"N,M = map(int, input().split()) AC=WA=0 p=set() for _ in range(M): a,S = input().split() if a not in p: if S=='AC': AC+=1 p.add(a) else: WA+=1 print(AC,WA)" p02802,s702777284,Wrong Answer,"N, M = list(map(int, input().split())) a = [] for i in range(M): a.append(map(str, input().split())) p_sum = 0 s_sum = 0 p_count = 0 s_count = 0 for k in range(M): ps = list(a[k]) if p_count != ps[0]: s_count = 0 p_count = ps[0] if s_count == 0: if ps[1] == ""WA"": s_sum += 1 else: p_sum += 1 s_count = 1 print(str(p_sum) + "" "" + str(s_sum))" p02802,s574883028,Wrong Answer,"N,M=map(int,input().split()) L=[list(input().split()) for i in range(M)] W=[0]*N A=[0]*N a=0 w=0 for i in range(M): if L[i][1]==""AC"": A[int(L[i][0])-1]=1 elif L[i][1]==""WA"" and A[int(L[i][0])-1]==0: W[int(L[i][0])-1]+=1 for i in A: a+=i for i in W: w+=i print(a,w)" p02802,s344024698,Wrong Answer,"N, M = map(int, input().split()) submit_set = {input() for _ in range(M)} correct_ans_num = 0 penalty = 0 for i in range(1, N + 1): results = [result.split()[1] for result in submit_set if int(result.split()[0]) == i] if not 'AC' in results: continue correct_ans_num += 1 penalty += len(results) - 1 print('{} {}'.format(correct_ans_num, penalty))" p02802,s567310554,Wrong Answer,"N, M = map(int, input().split()) q = set() ac = wa = 0 for _ in range(M): p, S = input().split() p = int(p) if p not in q: if S == 'AC': q.add(p) ac += 1 else: wa += 1 print(ac, wa)" p02802,s286987659,Wrong Answer,"n,m=map(int,input().split()) cnt1=0 cnt2=0 flag=[-1]*(n+1) for _ in range(m): p,s=map(str,input().split()) p=int(p) if s=='AC': if flag[p]==1: continue else: cnt1+=1 flag[p]=1 if s=='WA': if flag[p]==1: continue else: cnt2+=1 print(cnt1,cnt2)" p02802,s179909884,Wrong Answer,"N, M = list(map(int, input().split(' '))) result_list = [input().split(' ') for i in range(M)] AC_total = 0 WA_total = 0 ok_list = [] for p, s in result_list: if p not in ok_list: if s == 'WA': WA_total += 1 else: AC_total += 1 ok_list.append(p) print('{} {}'.format(AC_total, WA_total))" p02802,s465445412,Wrong Answer,"N, M = map(int,input().split()) lst=[None]*M for i in range(M): p, S=input().split() lst[i]=(int(p), S) stop_list=[] WA_count=0 AC_count=0 for i in range(M): if not lst[i][0] in stop_list: if lst[i][1]=='AC': AC_count+=1 stop_list.append(lst[i][0]) else: WA_count+=1 print( AC_count, WA_count) " p02802,s536040809,Wrong Answer,"n,m=map(int,input().split()) a=[0]*n ac=0 wa=0 for i in range(m): p,s=input().split() p=int(p) if a[p-1]==0: if s==""AC"": ac+=1 a[p-1]=1 else: wa+=1 print(ac,wa)" p02802,s649188574,Wrong Answer,"n, m = map(int,input().split()) pS = [input().split() for _ in range(m)] pena = 0 correct = 0 flag = [False] * n for p, s in pS: p = int(p) if flag[p-1] == True: continue else: if s == ""WA"": pena += 1 elif s == ""AC"": correct += 1 flag[p-1] = True print(correct, pena) " p02802,s512673110,Wrong Answer,"n,m=map(int,input().split()) ps=[list(map(int,input().replace('WA','0').replace('AC','1').split())) for i in range(m)] tmp_p=0 ac_cnt=0 wa_cnt=0 wa=0 flg=0 for i in range(m): p=ps[i][0] s=ps[i][1] if tmp_p!=p: wa=0 flg=0 if s==1 and flg==0: flg=1 ac_cnt+=1 wa_cnt+=wa elif s==0 and flg==0: wa+=1 tmp_p=p print(ac_cnt, wa_cnt)" p02802,s911985371,Wrong Answer,"import sys def input(): return sys.stdin.readline().rstrip() from collections import defaultdict def main(): n,m=map(int,input().split()) ac=defaultdict(int) pena=0 for i in range(m): k,s=input().split() k=int(k) if ac[k-1]!=1: if s==""WA"":pena+=1 else:ac[k-1]+=1 print(sum(ac.values()),pena) if __name__=='__main__': main()" p02802,s675674022,Wrong Answer,"n,m=map(int,input().split()) ansct=0 ansflag=[0]*n missct=0 for i in range(m): p,s=map(str,input().split()) if (s=='AC')and(ansflag[int(p)-1]==0): ansflag[int(p)-1]=1 ansct+=1 elif ansflag[int(p)-1]==0: missct+=1 print(str(ansct)+' '+str(missct))" p02802,s713972686,Wrong Answer,"F_str = input().split() F = [int(f) for f in F_str] N = F[0] M = F[1] WA_list = [0 for _ in range(N)] AC_list = [] for i in range(M): S_str = input().split() S = [str(s) for s in S_str] if(S[1] == ""AC""): AC_list.append(S[0]) elif(not(S[0] in AC_list)): WA_list[int(S[0])-1] += 1 AC_set = list(set(AC_list)) print(str(len(AC_set)) + "" "" + str(sum(WA_list))) " p02802,s230689082,Wrong Answer,"def get_unique_list(seq): seen = [] return [x for x in seq if x not in seen and not seen.append(x)] n,m=map(int,input().split()) if m == 0: print('0 0') s = [input().split() for i in range(m)] p = get_unique_list(s) ac = 0 w = [] wa = 0 for i in range(len(p)): if p[i][1] == 'AC': ac += 1 w.append(wa) wa = 0 elif p[i][1] == 'WA': wa += 1 print(str(ac)+"" ""+str(sum(w)))" p02802,s737936535,Wrong Answer,"n, m = map(int, input().split()) ac = [False for _ in range(n+1)] wa = [0 for _ in range(n+1)] acCount = 0 waCount = 0 for i in range(m): p, s = input().split() p = int(p) if(ac[p] == False): if (s == ""AC""): ac[p] = True else: wa[p] += 1 for i in range(n+1): if(ac[i] == True): acCount += 1 waCount += wa[p] print(acCount, waCount) " p02802,s571225208,Wrong Answer,"#ABC151C n,m=list(map(int,input().split())) p=[] s=[] chk = '' for i in range(m): _p,_s=input().split() if chk != _p: chk = _p c1 = 0 c2 = 0 if _s == ""WA"": c1+=1 elif _s == ""AC"": c2+=1 s.append(int(_p)) if c2 == 1: p.append(c1) ac=len(set(s)) wa=sum(p) print(ac,wa,sep= ' ')" p02802,s137313008,Wrong Answer,"n,m = map(int,input().split()) d={} for _ in range(m): i,ans = input().split() if i in d: d[i].append(ans) else: d.update({i:[ans]}) a=p=0 for i in d: if 'AC' in d[i]: a+=1 if 'WA' in d[i]: p+=1 print(a,p)" p02802,s091455410,Wrong Answer,"from collections import Counter N, M = [int(_) for _ in input().split()] wa = Counter() ac = set() for i in range(M): p, s = input().split() p = int(p) if p in ac: continue if s == 'WA': wa[p] += 1 else: ac.add(p) print(len(ac), sum(wa.values())) " p02802,s453650299,Wrong Answer,"n, m = list(map(int,input().split())) correct = 0 penalty = 0 corrected = [] for i in range(m): pi, si = input().split() if (si == 'AC' and pi not in corrected): corrected.append(pi) correct += 1 elif (si == 'WA' and pi not in corrected): penalty += 1 print(""{} {}"".format(correct, penalty)) " p02802,s537586744,Wrong Answer,"n,m = map(int,input().split()) ac,wa = 0,0 number=[0]*n for _ 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)" p02802,s013904447,Wrong Answer,"#C - Welcome to AtCoder N,M = map(int,input().split()) P = [] S = [] for _ in range(M): p,s = input().split() S.append(s) P.append(p) WA = 0 AC = 0 AC_list = [] for i in range(M): if (P[i] in AC_list) == False: if S[i] == 'AC': AC += 1 AC_list.append(P[i]) else: WA += 1 print(AC,WA)" p02802,s597259867,Wrong Answer,"def main(): n, m = map(int, input().split()) ac = [0] * n pena = [0] * n for _ in range(m): p, s = map(str, input().split()) p = int(p) - 1 if ac[p] == 0 and s == 'WA': pena[p] += 1 else: ac[p] = 1 print() if __name__ == '__main__': main() " p02802,s685649120,Wrong Answer,"N,M = map(int,input().split()) P = [] s = [] sekai = 0 wrong = 0 for i in range(M): p,S = map(str,input().split()) P.append(int(p)) s.append(S) problem = list(range(1,N+1)) for j, ans in zip(P,s): if (j in problem) and (ans == ""AC""): problem.remove(j) sekai += 1 elif (j in problem) and (ans == ""WA""): wrong += 1 print(sekai, wrong)" p02802,s661274262,Wrong Answer,"N,M = map(int, input().split()) AC_num = 0 WA_num = 0 AC_map = [] for i in range(M): p,S = map(str, input().split()) p = int(p) if S == 'AC' and (p not in AC_map): AC_num += 1 AC_map.append(p) elif S == 'WA': if p in AC_map: continue else: WA_num += 1 print(str(AC_num)+' '+str(WA_num))" p02802,s000050788,Wrong Answer,"N,M = map(int, input().split()) table= [0]*N pen = 0 score = 0 for i in range(M): p,S = input().split() p = int(p)-1 if table[p] == 1: pass elif S == ""WA"": pen += 1 elif table[p] == 0 and S==""AC"": score += 1 table[p] = 1 print(score,pen) " p02802,s996860254,Wrong Answer,"N,M=map(int, input().split()) AC=[] WA=[] for _ in range(M): p,S=input().split() if S==""AC"": AC.append(p) else: WA.append(p) print(len(set(AC)),len(set(WA)))" p02802,s306850297,Wrong Answer,"wa = 0 l = [] n,m = map(int,input().split()) for i in range(m): a = list(map(str,input().split())) if a[1] == 'AC': l.append(a[0]) else: if not a[0] in l: wa += 1 ac = len(set(l)) print(ac,wa)" p02802,s603671627,Wrong Answer,"N, M = map(int, input().split()) A_list = [input().split() for _ in range(M)] wa_count, ac_count = 0, 0 WA = 0 # {prob_id: wa_count} AC_list = [] # [prob_id] for i in range(M): id = A_list[i][0] if A_list[i][1] == 'AC': if not id in AC_list: wa_count += WA ac_count += 1 AC_list.append(id) else: WA += 1 print(ac_count, wa_count) " p02802,s703995349,Wrong Answer,"N, M = map(int, input().split()) L = [list(input().split()) for _ in range(M)] D = {str(c):False for c in range(1, N+1)} S = 0 for l in L: if l[1]==""WA"" and D[l[0]]==False: S += 1 else: D[l[0]]=True print(sum(D.values()), S) " p02802,s576012965,Wrong Answer,"n, m = map(int, input().split()) ac = 0 wa = 0 ac_list = [0]*n for i in range(m): p, s = input().split() if ac_list[int(p)-1] == 1: pass elif ac_list[int(p)-1] == 0 and s == ""WA"": wa +=1 else: ac_list[int(p)-1] = 1 ac += 1 print(ac, wa)" p02802,s739679032,Wrong Answer,"_,M = map(int,input().split()) result = {} for i in range(M): P, Q = input().split() if P not in result: result[P] = [Q] else: if result[P][-1]=='AC': pass else: result[P].append(Q) AC = 0 WA = 0 numbers = list(result.values()) for i in range(len(numbers)): AC += numbers[i].count('AC') WA += numbers[i].count('WA') print(AC,WA)" p02802,s266468539,Wrong Answer,"n,m = map(int,input().split()) score_list = [2]*m for i in range(m): score_list[i] = input().split() wa_num = 0 ac_q = [] for i in range(m): if score_list[i][1] == ""AC"" and score_list[i][0] not in ac_q: ac_q.append(score_list[i][0]) elif score_list[i][1] == ""WA"" and score_list[i][0] not in ac_q: wa_num = wa_num + 1 ac_num = len(ac_q) print(ac_num,wa_num) " p02802,s314202910,Wrong Answer,"N, M = map(int, input().split()) P, S = list(), list() for _ in range(M): p, s = input().split() P.append(int(p)) S.append(s) AC_flags = [[0, 0] for _ in range(N)] for p, s in zip(P, S): if AC_flags[p - 1][0] == 0 and s == ""WA"": AC_flags[p - 1][1] += 1 elif AC_flags[p - 1][0] == 0 and s == ""AC"": AC_flags[p - 1][0] += 1 sum_ac, sum_wa = 0, 0 for ac, wa in AC_flags: sum_ac += ac sum_wa += wa print(sum_ac, sum_wa) " p02802,s734854792,Wrong Answer,"n,m=map(int,input().split()) acs=[0]*n was=[0]*n for i in range(m): p,s=input().split() p=int(p) if acs[p-1]==0: if s==""AC"": acs[p-1]=1 else: was[p-1]+=1 print(sum(acs),sum(was))" p02802,s643000453,Wrong Answer,"N, M = map(int, input().split()) d = {} for _ in range(M): p, s = input().split() a = d.get(p, [0, 0]) if s == ""AC"" and a[0] == 0: a[0] = 1 elif s == ""WA"" and a[0] == 0: a[1] += 1 d[p] = a ac = 0 wa = 0 for x in d.values(): ac += x[0] wa += x[1] print(""{0} {1}"".format(ac, wa))" p02802,s545380644,Wrong Answer,"import numpy as np n,p = map(int,input().split()) ac = np.array([0]*n) wa = np.array([0]*n) for i in range(p): p,s = input().split() if ac[int(p) - 1] == 0 and s == ""WA"": wa[int(p) - 1] += 1 else: ac[int(p) - 1] = 1 if sum(ac) == 0: print(0,0) else: print(sum(ac),sum(wa)) " p02802,s629099315,Wrong Answer,"N,M=map(int,input().split()) penalty=[0]*N result=[""WA""]*N if M==0: print(0,0) else: for i in range(M): P,S=input().split() if S==""AC"" and result[int(P)-1]==""WA"": result[int(P)-1]=""AC"" elif S==""WA"" and result[int(P)-1]==""WA"": penalty[int(P)-1]+=1 else: continue print(result.count(""AC""),sum(penalty))" p02802,s570743816,Wrong Answer,"n,m = map(int, input().split()) ac=0 wa=0 pp=set() tmp=0 for i in range(0,m): p,s = input().split() if p in pp: continue if s == 'AC': pp.add(p) ac=ac+1 wa = wa+tmp tmp=0 tmp = tmp+1 if s == 'WA' else tmp print(ac, wa)" p02802,s585796402,Wrong Answer,"n,m = map(int,input().split()) x=['0']*m y=['0']*m for i in range(m): x[i],y[i] = map(str,input().split()) num = 0 pena = 0 lis2=[0]*n sw = [0]*n for i in range(m): if y[i] == 'WA' and sw[int(x[i])-1]== 0: pena += 1 else: lis2[int(x[i])-1] = 1 sw[int(x[i])-1] = 1 num = sum(lis2) print(num,pena)" p02802,s144347725,Wrong Answer,"x, y = map(int, input().split()) from collections import defaultdict dd = defaultdict(str) k = 0 #カウント数 for i in range(y): a, b = map(str, input().split()) if b == 'AC': if a in dd: continue else: dd[a] = '1' else: if a in dd: continue else: k += 1 s = 0 for _ in dd: s += 1 print(s, k)" p02802,s269994132,Wrong Answer,"N, M = map(int, input().split()) L = [list(map(str, input().split())) for _ in range(M)] ac_list = [] wrong = 0 accept = 0 for i in range(M): if L[i][0] in ac_list: pass else: if L[i][1] == 'AC': ac_list.append(L[i][0]) accept += 1 else: wrong += 1 print(accept, wrong) " p02802,s512615918,Wrong Answer,"n, m = input().split() a = [False] * int(n) AC = 0 WA = 0 for i in range(int(m)): p, s = input().split() if(s == ""AC"" and a[int(p) - 1] == False): a[int(p) - 1] = True AC += 1 if(s == ""WA"" and a[int(p) - 1] == False): WA += 1 print(AC, WA) " p02802,s633078312,Wrong Answer,"n, m = map(int, input().split()) d = {} for i in range(m): p, s = input().split() d.setdefault(p, []) d[p].append(s) correct = 0 cnt = 0 for v in d.values(): if ""AC"" in v: correct += 1 cnt += len(v[:v.index(""AC"")]) else: cnt += len(v) print(correct, cnt)" p02802,s515436502,Wrong Answer,"mondaisu , teisyutukaisu = map(int,input().split()) flag = [] penalog = [] for i in range(mondaisu): flag.append(0) penalog.append(0) for i in range(teisyutukaisu): bango , kekka = input().split() bango = int(bango) if flag[bango-1] == 1: continue if kekka == 'WA': penalog[bango-1] = penalog[bango-1] + 1 elif kekka == 'AC': flag[bango-1] = 1 print(sum(flag),sum(penalog)) " p02802,s984042168,Wrong Answer,"N,M=map(int,input().split()) L=[list(input().split()) for i in range(M)] W=[0]*N A=[0]*N a=0 w=0 for i in range(M): if L[i][1]==""AC"": A[int(L[i][0])-1]=1 elif L[i][1]==""WA"" and A[int(L[i][0])-1]==0: W[int(L[i][0])-1]+=1 for i in A: a+=i for i in W: w+=i print(a,w)" p02802,s090311020,Wrong Answer,"number = list(map(int,input().split())) prob = ['']*number[0] ac = 0 wa = 0 for i in range(number[1]): word = list(map(str,input().split())) if word[1] == 'AC': prob[int(word[0])-1] += 'A' else: prob[int(word[0])-1] += 'W' for j in range(number[0]): for k in range(len(prob[j])): if prob[j][k] == 'W': wa += 1 else: ac += 1 break print(ac,wa)" p02802,s438404037,Wrong Answer,"n,m = map(int,input().split()) ps = [list(input().split()) for _ in range(m)] wa = 0 ac = 0 flag = 1 wa_flag = 0 ac_flag = 0 for i in range(m): if flag != ps[i][0]: flag = ps[i][0] wa_flag = 0 ac_flag = 0 if ps[i][1] == ""AC"" and ac_flag == 0: ac += 1 wa += wa_flag wa_flag = 0 ac_flag = 1 if ps[i][1] == ""WA"": wa_flag += 1 print(ac,wa)" p02802,s219673878,Wrong Answer,"N,M = map(int,input().split()) List = [0]*N correct , penalties = 0,0 for i in range(M): p,s = input().split() pro = int(p)-1 if pro > len(List): penalties+=1 continue if List[pro]==""AC"": continue if s == ""WA"": penalties+=1 List[pro]=s if s == ""AC"": List[pro]=s correct+=1 print(""%d %d""%(correct,penalties))" p02802,s435436984,Wrong Answer,"n,m=map(int,input().split()) A=[] P=[] wa=0 ac=0 for _ in range(m): p,s=input().split() P.append(int(p)) A.append(s) for j in range(n): for i in range(m): if P[i]==j and A[i]==""AC"": ac+=1 break elif P[i]==j: wa+=1 print(ac,wa)" p02802,s095902549,Wrong Answer,"N, M = map(int, input().split()) L = [] ac = [] wa = [] for i in range(M): pS = list(map(str, input().split())) L.append(pS) for i in range(M): if L[i][1] == 'AC': ac.append(int(L[i][0])) elif L[i][1] == 'WA' and ((int(L[i][0]) not in ac) == True): wa.append(int(L[i][0])) print(len(set(ac)), len(wa))" p02802,s768256993,Wrong Answer,"n, m = map(int, input().split()) cleared = [] ac_counter = 0 wa_counter = 0 for i in range(m): flag = False p, s = input().split() p = int(p) for i in range(len(cleared)): if cleared[i] == p: flag = True break if not flag: if s == 'AC': ac_counter += 1 cleared.append(p) else: wa_counter += 1 print(' '.join([str(ac_counter), str(wa_counter)]))" p02802,s518214247,Wrong Answer,"#!/usr/bin/python3 # -*- coding:utf-8 -*- import numpy def main(): n, m = map(int, input().strip().split()) counts = numpy.zeros(n).astype(numpy.int) flags = numpy.zeros(n).astype(numpy.int) for _ in range(m): p, s = input().strip().split() p = int(p) if s == 'WA' and flags[p-1] != 1: counts[p-1] += 1 if s == 'AC': flags[p-1] = 1 print(numpy.sum(flags), numpy.sum(counts)) if __name__=='__main__': main()" p02802,s536421166,Wrong Answer,"N, M = map(int, input().split()) p_list = [] s_list = [] for i in range(M): p, s = input().split() p_list.append(int(p)) s_list.append(s) p_state = [0 for i in range(N)] pena = 0 ans = 0 for i in range(M): if p_state[p_list[i]-1] == 0 and s_list[i] == ""WA"": pena += 1 elif p_state[p_list[i]-1] == 0 and s_list[i] == ""AC"": p_state[p_list[i]-1] = 1 ans += 1 else: continue print(ans, pena) " p02802,s473694625,Wrong Answer,"w,*d=[0]*10**6 a={0} for t in open(0): p,s=t.split() p=int(p) if'AC'==s*(not p in a):w+=d[p];a|={p} d[p]+=1 print(len(a)-1,w)" p02802,s182408196,Wrong Answer,"n,m=list(map(int,input().split())) question_dict_ac={} question_dict_wa={} question_list=[] question_counter=0 answer_counter=m while answer_counter > 0: question_num,result = input().split() if result=='AC': question_dict_ac[question_num]=[result] if result=='WA': question_dict_wa[question_num]=[result] answer_counter-=1 print (len(question_dict_ac),len(question_dict_wa))" p02802,s211767032,Wrong Answer,"import sys N,M = map(int,input().split()) cor_count = 0 pen_count = 0 AC_list = [] p = [0]*M#問題の番号 s = [0]*M#結果 AC,WA if M == 0 or N==0: print('0 0') sys.exit() for i in range(M): p[i],s[i] = input().split() for i in range(M): if not p[i] in AC_list: if s[i] == 'AC': AC_list.append(p[i]) else: pen_count += 1 #print(AC_list) cor_count = len(set(AC_list)) print(cor_count,pen_count) " p02802,s816645345,Wrong Answer,"import sys input = sys.stdin.readline n, m = map(int, input().split()) n = int(n) p_s = [list(map(str, input().split())) for _ in range(m)] ac = [0 for _ in range(n)] wa = [0 for _ in range(n)] for i in range(m): if ac[int(p_s[i][0]) - 1] == 1: continue else: if p_s[i][1] == 'WA': wa[int(p_s[i][0]) - 1] += 1 else: ac[int(p_s[i][0]) - 1] = 1 print(sum(ac), sum(wa)) " p02802,s654013306,Wrong Answer,"N, M = map(int,input().split()) AC = 0 WA = 0 data = [0]*100001 for i in range(M): x, y = map(str,input().split()) if data[int(x)] == 1: continue if y == 'WA': WA += 1 else: AC += 1 data[int(x)] = 1 print(AC,WA) " p02802,s142647572,Wrong Answer,"N,M = map(int,raw_input().split()) ans = 0 pen = 0 ans_done = [] for i in range(M): p,S = raw_input().split() if p in ans_done: continue if S == ""WA"": pen = pen + 1 else: ans = ans + 1 ans_done.append(p) print ans,pen" p02802,s326984553,Wrong Answer,"N,M = map(int,input().split()) pro = [0 for i in range(N+1)] ac,wa = 0,0 for i in range(M): p,s = input().split() p = int(p) if s == 'AC': if pro[p] != -1: ac += 1 wa += pro[p] pro[p] = -1 else: pro[p] += 1 print(ac,wa) " p02802,s036145563,Wrong Answer,"n, m = map(int, input().split()) solved = [0]* 10**5 penalty_sum = 0 penalty = 0 for _ in range(m): q, result = input().split() q = int(q) if result == 'AC': if solved[q] == 0: penalty_sum += penalty penalty = 0 else: if solved[q] == 0: penalty += 1 print(str(sum(solved)) + "" "" + str(penalty_sum))" p02802,s612421163,Wrong Answer,"N, M = list(map(int, input().split())) P = [0] * M S = [0] * M WA = [0] * (N+1) AC = [0] * (N+1) for i in range(M): p, s = list(map(str, input().split())) p = int(p) if s == 'AC': AC[p] = 1 else: if AC[p] == 0: WA[p] += 1 for i in range(N): if AC[i] == 0: WA[i] = 0 print(sum(AC),end=' ') print(sum(WA))" p02802,s192366345,Wrong Answer,"from itertools import groupby n, m = map(int, input().split()) WA = [0] * (n + 1) AC = [False] * (n + 1) wanum = 0 acnum = 0 for i in range(m): p, s = input().split() if AC[int(p)]: continue if s == 'AC': acnum += 1 wanum += WA[int(p)] elif s == 'WA': WA[int(p)] += 1 print(acnum, wanum) " p02802,s791665238,Wrong Answer,"n, m = map(int, input().split()) wa = [0] * (n+1) ac = [0] * (n+1) for _ in range(m): p, s = input().split() if (not ac[int(p)]) and s == 'WA': wa[int(p)] += 1 elif s == 'AC': ac[int(p)] = 1 print(sum(ac), sum(wa)) " p02802,s918642464,Wrong Answer,"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(n): if seitou[i]==1: pena_kazu+=pena[i] seitou_kazu=sum(seitou) print(str(seitou_kazu)+"" ""+str(pena_kazu))" p02802,s809959214,Wrong Answer,"#151c n,w=map(int,input().split()) ac=0 wa=0 wa_cnt=0 ac_flg=[0]*n for i in range(w): p,s=input().split() p=int(p)-1 if ac_flg[p]==1: continue else: if s=='AC': ac_flg[p]=1 ac+=1 wa+=wa_cnt else: wa_cnt+=1 print(ac,wa)" p02802,s836563192,Wrong Answer,"question_num, my_submit = list(map(int, input().split(' '))) sub_list = ['']*my_submit for i in range(my_submit): sub_list[i] = input().split(' ') question_results = ['hoge'] + [False]*question_num ac = 0 wa = 0 for j in sub_list: if question_results[int(j[0])] == False: if j[1] == 'AC': question_results[int(j[0])] = True ac += 1 elif j[1] == 'WA': wa += 1 print(ac, wa)" p02802,s779628268,Wrong Answer,"n, m = map(int, input().split()) ans = 0 flag = [0] * n for _ in range(m): P, s = input().split() p = int(P) - 1 if s == 'AC': flag[p] = 1 elif flag[p] == 0: ans += 1 print(flag.count(1), ans)" p02802,s724475702,Wrong Answer,"N, M = map(int, input().split()) dic = {} dic2 = {} for i in range(M): p, S = input().split() p = int(p) if dic.get(p) == None: dic[p] = S dic2[p] = 1 elif dic[p] == 'WA': dic[p] = S dic2[p] += 1 else: pass # print(dic, dic2) AC = list(dic.values()).count(""AC"") submit_count = sum(list(dic2.values())) - AC print(AC, submit_count)" p02802,s628565835,Wrong Answer,"n,m=map(int,input().split()) lst=[list(input().split()) for _ in range(m)] pena_lst=[0]*n acn_lst=[0]*n for p,s in lst: p=int(p)-1 if acn_lst[p]==1: continue if s ==""AC"": acn_lst[p]=1 else: pena_lst[p]+=1 pena=0 acn=0 for i in range(n): acn+=acn_lst[i] if acn_lst[i]==1: pena+=pena_lst[i] print(pena,acn)" p02802,s609145462,Wrong Answer,"n,m=map(int,input().split()) a=[0]*n wa=0 for i in range(m): p,s=input().split() p=int(p) if s==""WA"" and a[p-1]==0: wa+=1 elif s==""AC"" and a[p-1]==0: a[p-1]+=1 print(a.count(1),wa)" p02802,s068778279,Wrong Answer,"n, m = map(int, input().split()) p = [0]*n ac = [0]*n for i in range(m): a, b = input().split() a = int(a)-1 if ac[a]==0: if b==""WA"": p[a]+=1 else: ac[a]=1 print(ac.count(1), sum(p))" p02802,s006558011,Wrong Answer,"N, M = map(int, input().split(' ')) ac_set = set() wa_cnt_ls = [0] * N wa_cnt = 0 for i in range(M): p, s = input().split(' ') idx = int(p) - 1 if not s in ac_set: if s == 'AC': wa_cnt += wa_cnt_ls[idx] ac_set.add(s) else: wa_cnt_ls[idx] += 1 print(len(ac_set), wa_cnt)" p02802,s872710329,Wrong Answer,"N,M=map(int, input().split()) p=[] S=[] for i in range(M): P,s=input().split() p.append(int(P)) S.append(s) A=set() W=[0 for i in range(0,N)] w=0 for i in range(0, M): if S[i]=='AC': w+=W[p[i]-1] if p[i]-1 not in A: A.add(p[i]-1) elif S[i]=='WA': if p[i]-1 not in A: W[p[i]-1]+=1 print(len(A), w)" p02802,s968716664,Wrong Answer,"n,m=map(int,input().split()) lis=[] for i in range(n): lis.append([0,0]) for i in range(m): p,s=map(str,input().split()) p=int(p)-1 if s==""AC"": lis[p][0]=1 else: if lis[p][0]==0: lis[p][1]+=1 ac=0 wa=0 for i in range(0,n): ac+=lis[i][0] wa+=lis[i][1] print(ac,wa)" p02802,s368072213,Wrong Answer,"n,m = map(int,input().split()) C={} acc=0 wac=0 for i in range(m): p0,s = input().split() p = int(p0) if p in C : if C[p]!=-1: C[p]+=1 else: C[p]=1 if s==""AC"" and C[p]!=-1: acc+=1 C[p]=-1 elif s==""WA"" and C[p]!=-1: wac+=1 print( acc, wac )" p02802,s370230633,Wrong Answer,"'n(問題数), m(提出数)を抽出' n, m = (int(x) for x in input().split()) d = {} p = 0 'Siが新規かつ、Piが""AC""の場合辞書に追加, Piが""WA""の場合はペナルティをカウント' for _ in range(m): a, b = (input().split()) if a in d: continue elif b == 'WA': p += 1 else: d[a] = b '辞書の要素数をカウントして正答数を計算、ペナルティはそのまま出力' print(len(d), p) " p02802,s601909888,Wrong Answer,"N,M = map(int,input().split()) AC = 0 WA = 0 lis = [] for i in range(M): A = list(input().split()) if A[0] not in lis: if A[1] == 'AC': lis.append(A[0]) AC += 1 else: WA += 1 print(AC, WA)" p02802,s996068734,Wrong Answer,"n,m=map(int,input().split()) AC = [0] * n WA = [0] * n for i in range(m): x = input().split() num = int(x[0]) - 1 if x[1]=='AC': AC[num]+=1 elif x[1]=='WA' and AC[num]==0: WA[num]+=1 print(sum(AC), sum([w for i, w in enumerate(WA) if AC[i]]))" p02802,s713686696,Wrong Answer,"N,M = map(int,input().split()) AC_flag = [False]*N WA_count = [0]*N for m in range(M): P,S = map(str,input().split()) p = int(P) if AC_flag[p-1] == False and S == ""AC"": AC_flag[p-1] = True elif AC_flag[p-1] == False and S == ""WA"": WA_count[p-1] += 1 print(*[sum(AC_flag),sum(WA_count)])" p02802,s106738819,Wrong Answer,"N, M = map(int, input().split()) wa = [0] * (N+1) ac = set() for _ in range(M): p,S = input().split() p = int(p) if p in ac: continue if S == ""AC"": ac.add(p) else: wa[p] += 1 print(len(ac),sum(wa)) " p02802,s158112236,Wrong Answer,"n, m = map(int, input().split()) ac = [False for _ in range(n)] wa = [False for _ in range(n)] for _ in range(m): p, s = input().split() p = int(p) if s == 'AC': ac[p - 1] = True if s == 'WA': wa[p - 1] = True r1 = sum(ac) r2 = sum(ac[i] and wa[i] for i in range(n)) print(r1, r2) " p02802,s382539482,Wrong Answer,"N,M=map(int,input().split()) not_AC_ls=[i for i in range(1,N+1)] ac_num=0 pn_num=0 for _ in range(M): pi,Si=input().split() pi=int(pi) if Si=='AC': if pi in not_AC_ls: ac_num+=1 not_AC_ls.remove(pi) if Si=='WA': if pi in not_AC_ls: pn_num+=1 print(ac_num,pn_num)" p02802,s295569213,Wrong Answer,"N, M = map(int, input().split()) P = [0] * M S = [""a""] * M flg = [0] * N C = 0 D = 0 for i in range(M): tmp, S[i] = map(str, input().split()) P[i] = int(tmp) if S[i]==""AC"": if flg[P[i]-1]==0: C += 1 flg[P[i]-1] = 1 elif S[i]==""WA"": if flg[P[i]-1]==0: D += 1 print(C, D) " p02802,s628693642,Wrong Answer,"N,M = map(int,input().split()) ok = 0 ng = 0 Q = [False]*N for _ in range(M): p,s = map(str,input().split()) if Q[int(p)-1]==False and s == ""AC"": ok += 1 Q[int(p)-1]= True elif Q[int(p)-1]==False and s == ""WA"": ng += 1 print(ok,ng)" p02802,s056216611,Wrong Answer,"n,m = map(int,input().split()) ps = [input().split() for i in range(m)] ans_ac = 0 ans_wa = 0 flag = 0 number = 0 ok = [] for i in range(m): if ps[i][0] not in ok: if ps[i][1] == ""WA"": ans_wa += 1 else: ans_ac += 1 ok.append(ps[i][0]) print(ans_ac,ans_wa)" p02802,s912951400,Wrong Answer,"n, m = map(int, input().split()) ans = 0 flag = [0] * n for _ in range(m): P, s = input().split(' ') p = int(P) - 1 if s == 'AC': flag[p] = 1 elif flag[p] == 0: ans += 1 print(sum(flag), ans)" p02802,s951241425,Wrong Answer,"n,m = map(int,input().split()) A = [] for _ in range(m): a,b = input().split() tmp = [int(a),b] A.append(tmp) dict = {} for a in A: dict.update({a[0]:False}) ac = 0 wa = 0 for a in A: if dict[a[0]] == False: if a[1] == ""WA"": wa += 1 else: dict[a[0]] = True ac += 1 print(""{} {}"".format(ac,wa))" p02802,s203115275,Wrong Answer,"# N問出題 # M回提出 ans = [] pena = 0 N, M = map(int, input().split()) for _ in range(M): p, s = input().split() # 正解 if s == ""AC"" and int(p) <= N: ans.append(p) # WAかつ未正解 elif s == ""WA"" and (p not in ans): pena +=1 else: continue print(len(set(ans)), pena)" p02802,s880474967,Wrong Answer,"N,M = map(int,input().split()) bl = [True]*N ac,wa = 0,0 for i in range(M): p,s = input().split() p = int(p) if bl[p-1]: if s == ""WA"": wa += 1 else: ac += 1 bl[p-1] = False print(ac,wa)" p02802,s442083159,Wrong Answer,"# C - Welcome to AtCoder n, m = map(int, input().split()) point = 0 pena_cnt = 0 penalty = 0 no = [0] * n for i in range(0, m - 1): p, s = input().split() if no[int(p) - 1] == 1: continue if s == 'WA': pena_cnt += 1 else: point += 1 penalty += pena_cnt pena_cnt = 0 no[int(p) - 1] = 1 print(str(point) + "" "" + str(penalty))" p02802,s566900231,Wrong Answer,"N, M = list(map(int, input().split())) sum_a = 0 tmp = [] test_cnt = [] false_cnt = 0 for index in range(M): A = input().split() if int(A[0]) not in test_cnt: if len(test_cnt) <= N: test_cnt.append(int(A[0])) else: continue if A[0] not in tmp: if A[1] == 'WA': false_cnt += 1 elif A[1] == 'AC': tmp.append(A[0]) print(len(test_cnt)) print(false_cnt)" p02802,s142883125,Wrong Answer,"N, M = map(int, input().split(' ')) ac_list = [] ac_cnt, wa_cnt = 0, 0 for i in range(M): num, res = input().split(' ') if num not in ac_list: if res == 'AC': ac_cnt += 1 ac_list.append(num) else: wa_cnt += 1 print(ac_cnt, wa_cnt)" p02802,s912788463,Wrong Answer,"N, M = map(int, input().split()) A = [False] * N cnt = 0 _cnt = 0 for i in range(M): p, S = input().split() if S == 'AC' and not A[int(p) - 1]: cnt += 1 if S == 'WA' and not A[int(p) - 1]: _cnt += 1 A[int(p) - 1] = A[int(p) - 1] or S == 'AC' print(cnt, _cnt) " p02802,s225416007,Wrong Answer,"import collections n,m = map(int, input().split()) ps = [list(input().split()) for _ in range(m)] q = [0]*n t = [0]*n for [p,s] in ps: p = int(p) - 1 if s == ""AC"" and q[p] == 0: q[p] += 1 elif s == ""WA"" and q[p]== 0: t[p] += 1 print(sum(q),sum(t)) " p02802,s828007820,Wrong Answer,"import numpy as np N, M = map(int, input().split()) l = np.zeros((N, 2), dtype = int) for i in range(M): p, S = map(str, input().split()) if S == 'AC': l[int(p) - 1, 0] = 1 else: l[int(p) - 1, 1] += 1 print(np.sum(l[:, 0]), np.sum(l[l[:, 0] == 1, 1]))" p02802,s387565513,Wrong Answer,"N,M= map(int,input().split()) P = [0 for _ in range(N+1)] S = [0 for _ in range(N+1)] for i in range(M): p, s = input().split() if s == ""WA"" and S[int(p)] != 1:P[int(p)] += 1 if s == ""AC"":S[int(p)] = 1 print(sum(S),sum(P)) " p02802,s524881160,Wrong Answer,"N , M = map(int , input().split("" "")) solve_problem = [0] * N ans = [0,0] for i in range(0,M): ps = input().split("" "") if ps[1] == ""AC"": if solve_problem[ int(ps[0]) -1] == 0: solve_problem[int(ps[0])-1] = 1 ans[0] += 1 elif ps[1] == ""WA"": if solve_problem[ int(ps[0])-1] == 0: ans[1] += 1 print(ans[0],ans[1])" p02802,s625058984,Wrong Answer,"n,m=map(int,input().split()) info=[] for i in range(m): p,s=input().split() info.append([int(p),s]) ac,wa=0,0 plob=[0 for i in range(n+1)] for i in range(m): if plob[info[i][0]]==0: if info[i][1]==""WA"": wa+=1 else: ac+=1 plob[info[i][0]]=1 print(str(ac)+"" ""+str(wa))" p02802,s930733882,Wrong Answer,"n,m = (int(x) for x in input().split()) p = [0]*m s = [0]*m penal = [0]*105000 clear = [0]*105000 for i in range(m): p[i],s[i] = (x for x in input().split()) p[i] = int(p[i]) if s[i] == 'AC': clear[p[i]-1] = 1 elif clear[p[i]-1] == 0: penal[p[i]-1] += 1 print(str(sum(clear)) + "" "" + str(sum(penal)))" p02802,s210153652,Wrong Answer,"n=list(map(int,input().split())) x=[list(input().split())for i in range(n[1])] wwa,wa,ac=0,0,0 notused=[] for i in range(n[1]): if(x[i][0] not in notused): if(x[i][1]==""WA""): wwa+=1 else: ac+=1 wa=wa+wwa notused.append(x[i][0]) print('{0} {1}'.format(ac, wa))" p02802,s400703683,Wrong Answer,"import sys input = sys.stdin.readline n,m=map(int,input().split()) PS=[list(input().split()) for _ in range(m)] AC=[] WA=[0 for i in range(n)] for i in range(m): if PS[i][1] == ""AC"": if int(PS[i][0]) in AC: continue AC.append(int(PS[i][0])) elif PS[i][1] == ""WA"" and not(int(PS[i][0]) in AC): WA[int(PS[i][0])-1]+=1 sum_WA=0 for i in range(len(WA)): sum_WA+=WA[i] print(len(AC), sum_WA)" p02802,s128022402,Wrong Answer,"n, m = map(int, input().split()) ac = [0] * n pen = 0 for i in range(m): p, s = input().split() p = int(p) - 1 if ac[p] == ""AC"": continue elif s == ""AC"": ac[p] = ""AC"" else: pen += 1 print(ac.count(""AC""), pen) " p02802,s566107610,Wrong Answer,"N, M = map(int, input().split()) ac, wc = [0]*N, [0]*N for i in range(M): p, s = input().split() if s == 'AC' and ac[int(p)-1] == 0: ac[int(p)-1] += 1 elif s == 'WA' and ac[int(p)-1] == 0: wc[int(p)-1] += 1 print('%d %d' % (sum(ac), sum(wc))) " p02802,s966155072,Wrong Answer,"n, m = map(int, input().split("" "")) ans = [] for i in range(m): ans.append(input().split("" "")) cc = 0 pc = 0 for i in range(n): for j in range(m): if int(ans[j][0]) == i+1: if ans[j][1] == ""WA"": pc = pc + 1 elif ans[j][1] == ""AC"": cc = cc + 1 break print(cc, pc) " p02802,s294443768,Wrong Answer,"n, m = map(int, input().split("" "")) nac = 0 npe = 0 cp = 0 is_ac = {} for i in range(m): p_s, s = input().split("" "") p = int(p_s) cis_ac = False if p in is_ac: cis_ac = is_ac[p] if cis_ac: continue if s == ""AC"": nac += 1 is_ac[p]=True else: npe += 1 print(str(nac)+"" ""+str(npe)) " p02802,s161224555,Wrong Answer,"N, M = map(int, input().split()) submit = [list(input().split()) for _ in range(M)] acflag = [False]*N AC = 0 WA = 0 for i in range(M): if (not acflag[int(submit[i][0])-1]) and submit[i][1] == ""AC"": acflag[int(submit[i][0])-1] = True AC += 1 elif (not acflag[int(submit[i][0])-1]) and submit[i][1] == ""WA"": WA += 1 print(AC, WA)" p02802,s437021693,Wrong Answer,"N, M = list(map(int, input().split())) WA, AC = ""WA"", ""AC"" ac = [0] * (N+1) wa = [0] * (N+1) for i in range(1, M+1): p, S = input().split() p = int(p) if S == WA and ac[p] == 0: wa[p] += 1 elif S == AC and ac[p] == 0: ac[p] = 1 print(sum(ac), sum(wa))" p02802,s468142132,Wrong Answer,"n,m=map(int,input().split()) a=0 p=0 L=[False for _ in range(n)] for i in range(m): num,s = input().split() num=int(num)-1 if not L[num]: if s == ""AC"": L[num]=True a+=1 else: p+=1 print(a,p)" p02802,s265541731,Wrong Answer,"n, m = map(int, input().split()) submit = [] for i in range(m): temp = [x for x in input().split()] submit.append(temp) done = [0] * (n + 1) ac = 0 wa = 0 for i in range(m): if submit[i][1] == 'AC' and done[int(submit[i][0])] == 0: done[int(submit[i][0])] = 1 ac += 1 if submit[i][1] == 'WA' and done[int(submit[i][0])] == 0: wa += 1 print(ac, wa) " p02802,s521097035,Wrong Answer,"n, m = map(lambda x: int(x), input().split()) s_list = [input().split() for _ in range(m)] ac = 0 wa = 0 q_nums = [] for s in s_list: if s[0] in q_nums: break elif s[1] == 'AC': ac += 1 q_nums.append(s[0]) elif s[1] == 'WA': wa += 1 print('{} {}'.format(ac, wa))" p02802,s936863496,Wrong Answer,"# AtCoder Beginner Contest 151: C (2020/01/12) N, M = map(int, input().split()) A = [0 for i in range(N)] p = [0 for i in range(M)] S = ['' for i in range(M)] for i in range(M): l = input().split() p[i] = int(l[0]) S[i] = str(l[1]) ans = 0 pnlt = 0 for i in range(M): if A[p[i]-1] != 0: continue if S[i] == 'AC': ans = ans + 1 A[p[i]-1] = 1 else: pnlt = pnlt + 1 print(ans, pnlt)" p02802,s233834130,Wrong Answer,"n, m = map(int, input().split()) acline = [0]*n wanum = [0]*n for i in range(m): num, acwa = map(str, input().split()) num = int(num) -1 if acwa == ""AC"": acline[num] = 1 else: if acline[num] == 1: continue else: wanum[num] += 1 print(sum(acline), sum(wanum))" p02802,s845607701,Wrong Answer,"n, m = map(int, input().split()) WA = [0] * n AC = [0] * n for i in range(m): p, s = list(input().split()) p = int(p) - 1 if s == ""WA"" and AC[p] == 0: WA[p] += 1 elif s == ""AC"" and AC[p] == 0: AC[p] += 1 print(sum(AC), sum(WA)) " p02802,s527849039,Wrong Answer,"n, m = map(int, input().split()) p = [] s = [] for i in range(m): input1, input2 = input().split() p.append(int(input1)) s.append(input2) correct = [0] * n penalty = [0] * n for i in range(m): target_problem = p[i] - 1 if correct[target_problem] == 1: continue if s[i] == 'AC': correct[target_problem] += 1 else: penalty[target_problem] += 1 print('{0} {1}'.format(sum(correct), sum(penalty))) " p02802,s177544077,Wrong Answer,"#!python3.4.3 n, m = map(int, input().split(' ')) penalty = [0 for _ in range(n)] result = [0 for _ in range(n)] for i in range(m): p, s = input().split(' ') p = int(p) if s == 'AC': result[p-1] = 1 elif s == 'WA' and result[p-1] != 1: penalty[p-1] += 1 print(sum(result), sum(penalty)) " p02802,s606684861,Wrong Answer,"a = input() a,b = a.split("" "") N= int(a) M= int(b) temp=[] for i in range(M): temp.append(input()) tc=[0]*(N+1) tr=[0]*(N+1) for i in temp: _1, _2 = i.split("" "") if _2 == ""WA"": if tc[int(_1)] == 1: pass else : tr[int(_1)] += 1 elif _2 == ""AC"": tc[int(_1)] = 1 export = str(sum(tc))+"" "" + str(sum(tr)) print(export) " p02802,s319277324,Wrong Answer,"n,m = map(int, input().split()) la = [] lw = [] for i in range(n): la.append(0) lw.append(0) for _ in range(m): q,a = input().split() if a == ""WA"" and la[int(q)-1] != 1: lw[int(q)-1] += 1 else: la[int(q)-1] = 1 print(sum(la), sum(lw))" p02802,s809797840,Wrong Answer,"N,M=map(int, input().split()) wa={} ac=[] key=[] for i in range(M): p,s=input().split() if p not in ac: if s==""WA"": if s not in key: wa[p]=1 key.append(p) else: wa[p]+=1 else: ac.append(p) ans=0 for i in ac: if i in key: ans+=wa[i] print(len(ac),ans) " p02802,s359247783,Wrong Answer,"from collections import defaultdict import sys input = sys.stdin.readline m = defaultdict(int) ac = defaultdict(int) N, M = list(map(int, input().split())) ans = 0 penalty = 0 for _ in range(M): p, s = input().split() p = int(p) s = s.strip() if s == ""AC"": if p not in ac: penalty += m[p] ans += 1 ac[p] = 1 else: if p not in ac: m[p] += 1 print(str(len(m.keys())) + "" "" + str(penalty)) " p02802,s358027491,Wrong Answer,"N, M = map(int, input().split()) progress = {} # initialize for i in range(N): progress[str(i+1)] = ""notCorrect"" correct = 0 penalty = 0 for i in range(M): question, result = map(str, input().split()) if (progress[question] == ""notCorrect""): if (result == ""WA""): penalty += 1 else: progress[question] = ""correct"" correct += 1 else: continue print(str(correct)+"" ""+str(penalty))" p02802,s122660566,Wrong Answer,"import os def main(): wa_result = [] ac_result = [] num,count = map(int, input().split()) for i in range(count): n,m = map(str, input().split()) if m == ""WA"": if n in wa_result: continue else: wa_result.append(n) else: if n in ac_result: continue else: ac_result.append(n) print(len(ac_result), len(wa_result)) if __name__ == '__main__': main() " p02802,s598698723,Wrong Answer,"N, M = map(int, input().split()) right = 0 wrong = 0 now = 1 for i in range(M): p, S = list(input().split()) if S == 'AC': if p == now: now += 1 right += 1 else: if p == now: wrong += 1 print(right, wrong, sep=' ')" p02802,s847245513,Wrong Answer,"n,m=map(int,input().split()) l=[0]*n d=[0]*n for i in range(m): s=input().split() x=int(s[0]) if(s[1]=='AC'): l[x-1]=1 else: if(l[x-1]==1): continue else: d[x-1]+=1 print(sum(l),sum(d)) " p02802,s807181038,Wrong Answer,"N,M = map(int,input().split()) X = [list(map(str,input().split())) for i in range(M)] p = [] d = [] a = {} for i in range(M): if X[i][1] == 'AC': a[X[i][0]] = 'AC' p.append(d.count([X[i][0],'WA'])) elif X[i][1] == 'WA': d.append([X[i][0],X[i][1]]) print(len(a),sum(p))" p02802,s348022278,Wrong Answer,"N,M = list(map(int,input().split())) m = [0]*(N+1) r = [0]*(N+1) for i in range(M): p,S = input().split() p = int(p) if r[p] == 0: if S == ""WA"": m[p] += 1 else: r[p] = 1 print(sum(r),sum(m))" p02802,s380547783,Wrong Answer,"N,M = map(int, input().split()) AC = [0]*N WA = [0]*N for _ in range(M): p,s = input().split() if AC[int(p)-1] == 0: if s == ""WA"": WA[int(p)-1] += 1 elif s == ""AC"": AC[int(p)-1] = 1 print(sum(AC),sum(WA))" p02802,s862015395,Wrong Answer,"n,m = map(int,input().split()) seikai = 0 matigai = 0 oklist = [] for i in range(m): if len(oklist) == n: break a,b=input().split() if b == ""WA"" and a not in oklist: matigai += 1 elif b == ""AC"" and a not in oklist: seikai += 1 oklist.append(a) print(str(seikai)+"" ""+str(matigai)) " p02802,s199434039,Wrong Answer,"n, m = map(int, input().split()) cntAC = 0 cntWA = 0 listAW = ['WA'] * n for i in range(m): p, s = map(str, input().split()) p = int(p) if listAW[p - 1] == 'AC': continue if s == 'AC': cntAC += 1 listAW[p - 1] = 'AC' continue cntWA += 1 print(cntAC, cntWA) " p02802,s918832034,Wrong Answer,"import sys i = list(map(int, input().split())) N = i[0] M = i[1] already_ac = [] ac_count = 0 wa_count = 0 for i in range(M): line = sys.stdin.readline().split() if int(line[0]) not in already_ac: if line[1] == 'AC': ac_count += 1 already_ac.append(int(line[0])) else: wa_count += 1 print(str(ac_count) + "" "" + str(wa_count))" p02802,s529207926,Wrong Answer,"input1 = input().split() problem = int(input1[0]) num_sub = int(input1[1]) list_sub = set() for i in range(num_sub): input2 = input().split() list_sub.add((input2[0], input2[1])) right = 0 for i in list_sub: if(i[1] == ""AC""): right = right + 1 print(str(right) + "" "" + str(len(list_sub)-right))" p02802,s322509850,Wrong Answer,"from collections import defaultdict N, M = map(int, input().split()) P = [] S = [] for i in range(M): p, s = input().split() P.append(int(p)) S.append(s) d = defaultdict(int) d1 = defaultdict(int) for i in range(M): if S[i] == ""WA"": if d[P[i]] != 1: d1[P[i]] += 1 elif S[i] == ""AC"": d[P[i]] = 1 for i in range(len(d)+1): if d[i] == 0 and d1[i] > 0: d1[i] = 0 print(sum(d.values()), sum(d1.values()))" p02802,s379600741,Wrong Answer,"number,submit=input().rstrip().split() result=[input().rstrip().split() for i in range(int(submit))] #print(result) good=[] bad=[] stocK=[] for i in range(int(submit)): if result[i][1]=='WA': bad.append(result[i][0]) elif result[i][1]=='AC': good.append(result[i][0]) stocK.append(bad.count(result[i][0])) print(str(len(good))+' '+str(sum(stocK))) " p02802,s617176438,Wrong Answer,"listA=[] #appendのために宣言が必要 while True: try: listA.append(list(map(int,input().split()))) except: break; N = listA[0][0] M = listA[0][1] ans = [0] * N pena = [0] * N " p02802,s064166503,Wrong Answer,"N, M = map(int, input().split()) count1 = 0 count2 = 0 lis = [0] * N for i in range(M): p, S = input().split() p = int(p) if lis[p-1] == 0 and S == ""WA"": count2 += 1 elif lis[p-1] == 0 and S == ""AC"": count1 += 1 lis[p-1] = 1 elif lis[p-1] == 1 and S == ""WA"": continue elif lis[p-1] == 1 and S == ""AC"": continue print(str(count1) + "" "" + str(count2))" p02802,s798957811,Wrong Answer,"n,m=map(int,input().split()) ac=set() d={} for i in range(m): i,s=input().split() if int(i) not in ac: if s=='AC': ac.add(int(i)) else: d[int(i)]=d.get(int(i),0)+1 print(len(ac),sum(d.values()))" p02802,s820037587,Wrong Answer,"n,m = map(int, input().split()); A = [0]*m; B = [0]*m; for i in range(m): a, b = input().split(); A[i] = int(a); B[i] = b; #ACの数 AC_list = list(set(A)); AC_count = len(AC_list); #WAの数 WA_count = 0; for j in AC_list: indexes = [i for i, x in enumerate(A) if x == j]; for k in indexes: if B[k] == ""WA"": WA_count += 1; continue; else: break; print(AC_count, WA_count); " p02802,s174038552,Wrong Answer,"n, m = [int(i) for i in input().split()] to_i = dict(AC=1, WA=0) cs = list() cnt_c, cnt_w = 0, 0 for i in range(m): p, s = input().split() p, s = int(p), to_i[s] if p in cs: continue if s: cnt_c += 1 cs.append(p) else: cnt_w += 1 print(cnt_c, cnt_w)" p02802,s927860982,Wrong Answer,"n,m = map(int,input().split()) p = [""""]*m for i in range(m): p[i] = input().split() p[i][0] = int(p[i][0]) ac = [0]*n wa = [0]*n for i in range(m): if p[i][1] == ""AC"": ac[p[i][0]-1] = 1 if p[i][1] == ""WA"": if ac[p[i][0]-1] != 0: continue else: wa[p[i][0]-1] += 1 print(sum(ac),sum(wa))" p02802,s042640829,Wrong Answer,"n, m = map(int, input().split()) state = {} wa = 0 ac = 0 for i in range(m): no, result = input().split() if result == 'AC': if not state.get(no): ac += 1 state[no] = True elif result == 'WA': if not state.get(no): wa += 1 print(str(ac) + ' ' + str(wa)) " p02802,s489317510,Wrong Answer,"nm = [int(i) for i in input().split()] dic = {} co = 0 pe = 0 for i in range(0,nm[1]): tmp = [j for j in input().split()] val = dic.setdefault(tmp[0],'NEW') if (val == 'NEW') or (val == 'WA'): #新規追加 if tmp[1] == 'WA': pe += 1 dic[tmp[0]] = 'WA' elif tmp[1] == 'AC': co += 1 dic[tmp[0]] = 'AC' print(co, pe) " p02802,s827434746,Wrong Answer,"n,m = map(int,input().split()) ac = 0 wa = 0 ls = [e for e in range(1,n+1)] for i in range(m): a,b = map(str,input().split()) if int(a) in ls: if b == ""AC"": ac += 1 ls.remove(int(a)) else: wa += 1 print(ac,wa) " p02802,s858015835,Wrong Answer,"N, M = map(int,input().split()) p = [] S = [] AC_cnt = 0 WA_cnt = 0 for i in range(M): tmp_p, tmp_S = input().split() tmp_p = int(tmp_p) p.append(tmp_p) S.append(tmp_S) p_cnt = [0 for i in range(N)] for i in range(M): if p_cnt[p[i]-1]==1: continue if S[i]==""AC"": AC_cnt+=1 p_cnt[p[i]-1]=1 elif S[i]==""WA"": WA_cnt+=1 print(AC_cnt,WA_cnt)" p02802,s224744416,Wrong Answer,"n,m = map(int,input().split(' ')) score = 0 penalty = 0 problems = set() for _ in range(m): num,result = input().split(' ') if num in problems: continue if result == ""WA"": penalty +=1 else: score +=1 problems.add(num) print(score,penalty)" p02802,s117554582,Wrong Answer,"N,M=map(int,input().split()) ac=[False]*N wa=[0]*N for i in range(M): p,s=input().split() p=int(p)-1 if ac[p]: continue else: if s==""WA"": wa[p]+=1 if s==""AC"": ac[p]=True account=0 wacount=0 for i in range(len(ac)): account+=ac[i] wacount+=wa[i] print(account,wacount)" p02802,s688432025,Wrong Answer,"N,M = map(int,input().split()) dp = [0]*(N+1) li = [] kaku = [0]*(N+1) count =0 for m in range(M): p,s = input().split() p = int(p) li.append([p,s]) for i in li: if i[1]==""WA"": dp[i[0]] += 1 else: kaku[i[0]] = dp[i[0]] for k in kaku: if k != 0: count += 1 print(count,sum(kaku))" p02802,s353181139,Wrong Answer,"import sys def SL(): return map(str,sys.stdin.readline().rstrip().split()) def IL(): return map(int,sys.stdin.readline().rstrip().split()) def Main(): n,m = IL() sub = [0]*n t = 0 for _ in range(m): p,s = SL() p = int(p) if sub[p-1]==0: if s=='AC': sub[p-1] = 1 else: t += 1 print(sub.count(1),t) return if __name__=='__main__': Main()" p02802,s576833408,Wrong Answer,"N,M = map(int,input().split()) AC = [False] * (N+1) WA_cnt = [0] * (N+1) for _ in range(M): p,s = map(str,input().split()) p = int(p) if AC[p]: continue if s == ""WA"": WA_cnt[p] += 1 else: AC[p] = True penal = sum(WA_cnt) ac = sum(AC) print(ac, penal)" p02802,s302267478,Wrong Answer,"n,m = map(int, input().split()) ac = [0]*n wa = [0]*n num_ac = 0 num_wa = 0 solved = [] for i in range(m): p,s = input().split() p = int(p)-1 if s == 'AC': ac[p] = 1 elif s == 'WA': if ac[p] == 1: continue else: wa[p] += 1 print(sum(ac), sum(wa))" p02802,s316668501,Wrong Answer,"n,m=map(int,input().split()) dp=[0]*(n+1) cnt=0 ans=0 for i in range(m): q=input() if dp[int(q[:-3])]!=""A"" and q[-2]==""W"": dp[int(q[:-3])]=""W"" cnt+=1 elif dp[int(q[:-3])]!=""A"" and q[-2]==""A"": dp[int(q[:-3])]=""A"" ans+=1 print(ans,cnt)" p02802,s163156972,Wrong Answer,"N,M=map(int,input().split()) PS=[input().split() for i in range(M)] ACzumi=[] i=0 WA_count=0 for i in range(M): if PS[i][0] in ACzumi: i+=0 else: if PS[i][1]==""AC"": ACzumi.append(PS[i][0]) else: WA_count+=1 #print(ACzumi) print(len(ACzumi),WA_count)" p02802,s047333945,Wrong Answer,"n, m = map(int, input().split()) ac = [0] * n pen = [0] * n pen_count = 0 for i in range(m): p, s = input().split() p = int(p) - 1 if ac[p] == ""AC"": continue elif s == ""AC"": ac[p] = ""AC"" else: pen[p] += 1 for i in range(n): if ac[i] == ""AC"": pen_count = pen[i] print(ac.count(""AC""), pen_count) " p02802,s917150004,Wrong Answer,"n,m = map(int,input().split()) ac = [0 for i in range(n)] a = 0 b = 0 for i in range(m): s,t = map(str,input().split()) if ac[int(s)-1] == 0: if t == ""WA"": b += 1 else: a += 1 ac[int(s)-1] = 1 print(a,b) " p02802,s976496423,Wrong Answer,"N,M=map(int,input().split()) d={} e={} for _ in range(M): p,s=input().split() d.setdefault(p,0) e.setdefault(s,0) if s==""WA"" and d[p]!=1: e[s]+=1 elif s==""AC"": d[p]=1 print(sum(d.values()),sum(e.values())) " p02802,s472627092,Wrong Answer,"N, M = map(int,input().split()) AC_Set = set() WA_Count = 0 for i in range(M): num,result = list(input().split()) if num in AC_Set: continue else: if result == ""AC"": AC_Set.add(num) else: WA_Count += 1 print(""{} {}"".format(len(AC_Set),WA_Count)) " p02802,s744409373,Wrong Answer,"n,m=map(int,input().split()) ss=set() penality=0 for _ in range(m): p,s=input().split() p=int(p) if (p not in ss) and s==""WA"": penality+=1 if s==""AC"": ss.add(p) print(len(ss),penality) " p02802,s182344118,Wrong Answer,"from collections import Counter N, M = map(int, input().split()) ans = [] chk = 0 for _ in range(M): p, s = input().split() if _ == 0: ind = int(p) intp = int(p) # reset chk when next index if intp != ind: chk = 0 # Add data only when chk = 0 if chk == 0: ans.append(s) # chk = 1 when first 'AC' if intp == ind and s == 'AC': chk = 1 ind = intp cnt = Counter(ans) print(cnt['AC'], cnt['WA']) " p02802,s542892300,Wrong Answer,"n, m = map(int, input().split()) p = [] s = [] for i in range(m): p_i, s_i = input().split() p.append(int(p_i)) s.append(s_i) res = [0]*n correct = 0 penalty = 0 for i in range(m): no = p[i] - 1 if res[no] == 1: continue elif s[i] == 'WA': penalty += 1 elif s[i] == 'AC': correct += 1 res[no] = 1 print(correct, penalty)" p02802,s900088312,Wrong Answer,"n, m = map(int, input().split()) l = {} WA = [] wa = 0 ac = 0 for i in range(m): p, s = input().split() if p not in l: if s == ""WA"": wa += 1 else: ac += 1 WA.append(wa) wa = 0 l[p] = ""AC"" #print(l) print(ac, sum(WA))" p02802,s276838431,Wrong Answer,"n,m = map(int,input().split()) if m != 0: l = [list(input().split()) for i in range(m)] p,s = [list(i) for i in zip(*l)] t = [0] * n ac = 0 wa = 0 for i in range(m): if s[i] == 'WA' and t[int(p[i])-1] == 0: wa += 1 elif s[i] == 'AC' and t[int(p[i])-1] == 0: ac += 1 t[int(p[i])-1] = 1 print(ac,wa)" p02802,s815439519,Wrong Answer,"#coding:utf-8 n, m = map(int, input().split()) ac = 0 wa = 0 quest = 0 result = 'WA' for i in range(m): p, s = map(str, input().split()) if quest == p and result == s and result == 'AC': break elif quest == p and s == 'WA': wa += 1 elif quest == p and s == 'AC': ac += 1 elif quest != p and s == 'WA': wa += 1 elif quest != p and s == 'AC': ac += 1 quest = p result = s print(ac, wa) " p02802,s398199335,Wrong Answer,"n, m = [int(x) for x in input().split()] ac = [0] * (n + 1) wa = [0] * (n + 1) for i in range(m): p, s = input().split() print(p, s) p = int(p) if s == ""AC"": ac[p] = 1 if s == ""WA"" and ac[p] == 0: wa[p] += 1 print(sum(ac), sum([p for a, p in zip(ac, wa) if a == 1])) " p02802,s758620557,Wrong Answer,"import sys stdin = sys.stdin ni = lambda: int(ns()) na = lambda: list(map(int, stdin.readline().split())) nas = lambda: list(map(str, stdin.readline().split())) ns = lambda: stdin.readline().rstrip() # ignore trailing spaces n, m = na() aced = [0] * n pen = 0 for i in range(m): p, s = nas() p = int(p) if s == ""AC"": aced[p-1] = 1 else: if not aced[p-1]: pen += 1 print(sum(aced), pen) " p02802,s880856020,Wrong Answer,"import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines n, m = map(int, readline().split()) acCount = 0 waCount = 0 check = [0] * n for i in range(m): p, s = map(str, input().split()) #print(p,s) p = int(p) if (check[p - 1] == 0): if (s == 'WA'): waCount += 1 else: acCount += 1 check[p - 1] = 1 else: continue print(acCount, waCount)" p02802,s773050941,Wrong Answer,"N, M = map(int, input().split()) wrongnumber = [0] * N ACset = set() for i in range(M): p, S = input().split() if S == ""AC"": ACset.add(int(p)-1) else: if (int(p) - 1) not in ACset: wrongnumber[int(p) - 1] += 1 WAnumber = 0 ACnumber = len(ACset) for j in ACset: WAnumber += wrongnumber[j-1] print(ACnumber, WAnumber) " p02802,s790045866,Wrong Answer,"N,M = map(int,input().split()) List = [0]*N correct , penalties = 0,0 for i in range(M): p,s = input().split() pro = int(p)-1 if pro > len(List): penalties+=1 continue #elif List[pro]==""AC"": #continue elif s == ""WA"": penalties+=1 List[pro]=s elif s == ""AC"": List[pro]=s correct+=1 print(""%d %d""%((List.count(""AC"")+1),penalties)) " p02802,s945666797,Wrong Answer,"N,M = map(int,input().split()) p = [0]*(M+1) s = [0]*(M+1) for i in range(1,M+1): p[i],s[i] = input().split() p = list(map(lambda pi:int(pi),p)) wa=0 ac = 0 m=0 for i in range(1,N+1): if not i in p: continue m += 1 if p[m]==i: if s[m]=='AC': ac += 1 break elif s[m] == 'WA': wa += 1 if m == N: break if N==wa: wa = 0 print(str(ac)+' '+str(wa))" p02802,s108881199,Wrong Answer,"N,M = list(map(int, input().split())) wa = 0 ac = 0 remind = [] # 行数の入力 for i in range(M): # for文で回しつつ処理する p,s = input().split() p = int(p) # すでにあるACスキップ if p in remind: continue # ACをカウント if s == 'AC': ac += 1 remind.append(p) # WAをカウント if s == 'WA': wa += 1 print('%s %s' % (ac, wa)) " p02802,s100241322,Wrong Answer,"N, M = list(map(int, input().split())) p, S = [], [] solved = {} failed = {} for _ in range(M): x = input().split() if x[1] == 'AC': if x[0] in solved: pass else: solved[x[0]] = 1 else: if not x[0] in solved: if x[0] in failed: failed[x[0]] += 1 else: failed[x[0]] = 1 print(sum(solved.values()), sum(failed.values()))" p02802,s224482334,Wrong Answer,"nm = [int(i) for i in input().split()] ac = 0 wa = 0 sub = [] for i in range(0, nm[1]): seen = set() seen_add = seen.add sub.append([i for i in input().split() if i not in sub]) for i in range(0, len(sub)): if sub[i][1] == ""AC"": ac += 1 elif sub[i][1] == ""WA"": wa += 1 else: continue print(ac, end="" "") print(wa)" p02802,s219568629,Wrong Answer,"def solve(n, m, PS): d = {} scores = [0, 0] for p, s in PS: if p not in d or d[p] == 'WA': scores[0 if s == 'AC' else 1] += 1 d[p] = s return scores _n, _m = map(int, input().split()) _PS = [input().split() for _ in range(_m)] _scores = solve(_n, _m, _PS) print(_scores[0], _scores[1]) " p02802,s486619912,Wrong Answer,"n,m = list(map(int, input().split())) x = [] for i in range(m): x.append(list(map(str,input().split()))) x_arr = list(map(list, set(map(tuple, x)))) AC = [i for i in x_arr if i[1] == ""AC""] WA = [i for i in x_arr if i[1] == ""WA""] print(len(AC), len(WA))" p02802,s924995994,Wrong Answer,"def main(): N, M = map(int, input().split()) a = [0] * N w = [0] * N for _ in range(M): p, s = map(str, input().split()) if a[int(p) - 1] == 1: continue if s == ""AC"": a[int(p) - 1] = 1 elif s == ""WA"": w[int(p) - 1] += 1 print(sum(a), sum(w)) if __name__ == ""__main__"": main() " p02802,s401211506,Wrong Answer,"N, M = map(int, input().split()) list = [input().split() for _ in range(M)] ac_list = [0] * N wa_list = [0] * N for i in range(M): if list[i][1] == ""AC"": ac_list[int(list[i][0])-1] = 1 else: if ac_list[N-1] == 0: wa_list[int(list[i][0])-1] += 1 print(sum(ac_list), sum(wa_list))" p02802,s813302137,Wrong Answer,"N, M = (int(x) for x in input().split()) ac_dir = {n:False for n in range(1, N+1)} ac_count = 0 wa_count = 0 for _ in range(M): data = input().split() p = int(data[0]) S = data[1] if ac_dir[p]: continue else: if S == ""AC"": ac_dir[p] = True ac_count += 1 elif S == ""WA"": wa_count += 1 print(ac_count, wa_count)" p02802,s826819431,Wrong Answer,"n, m = list(map(int, input().split())) P = [] S = [] ac_list = [] pn = 0 for _ in range(m): P_, S_ = input().split() P.append(P_) S.append(S_) for p, s in zip(P,S): if not p in ac_list: if s == 'WA': pn += 1 elif s == 'AC': ac_list.append(p) print(len(ac_list), pn)" p02802,s043536579,Wrong Answer,"n, m = map(int, input().split()) ps = [input().split() for i in range(m)] AC = [False for i in range(n)] WA = 0 for i in ps: if AC[int(i[0]) - 1]: pass else: if i[1] == ""AC"": AC[int(i[0]) - 1] = True else: WA += 1 print(AC.count(True), WA)" p02802,s256151979,Wrong Answer,"import os, sys, re, math (N, M) = [int(n) for n in input().split()] successes = [0] * N penalties = [0] * N for i in range(M): (p, s) = [n for n in input().split()] if s == 'AC': successes[int(p) - 1] = 1 else: if successes[int(p) - 1] == 0: penalties[int(p) - 1] += 1 print('%s %s' % (sum(successes), sum(penalties))) " p02802,s953094718,Wrong Answer,"def main(): n, m = [int(i) for i in input().strip().split()] accepted = set() ac = 0 wa = 0 for _ in range(m): p, s = input().strip().split() if int(p) in accepted: continue else: if s == ""AC"": accepted.add(int(p)) ac += 1 elif s == ""WA"": wa += 1 print(ac, wa) return if __name__ == ""__main__"": main() " p02802,s540369506,Wrong Answer,"N, M = list(map(int, input().split())) check = [0]*N count_W = 0 count_A = 0 for i in range(M): p, S = input().split() p = int(p) if check[p-1] == 0: if S == ""WA"": count_W = count_W + 1 else: count_A = count_A + 1 check[p-1] = 1 print(count_A, count_W) " p02802,s892336033,Wrong Answer,"n,m=map(int,input().split()) AC=[0]*n WA=[0]*n for _ in range(m): p,s=input().split() p=int(p) if s==""AC"": AC[p-1]=1 else: if AC[p-1]==0: WA[p-1]+=1 print(sum(AC),sum(WA))" p02802,s862195739,Wrong Answer,"N, M = map(int, input().split()) A=[] p = [0] * M S = [0] * M for i in range(M): p[i], S[i]= map(str, input().split()) T=[int(p[i]),S[i]] A.append(T) A.sort(key=lambda x: x[0]) wa=0 wa2=0 ac=0 tmp=0 for j in range(M): if A[j][0]>tmp: if A[j][1]=='WA': wa+=1 else: ac+=1 wa2+=wa wa=0 tmp=A[j][0] print(ac,wa2) " p02802,s550037088,Wrong Answer,"import sys input = sys.stdin.readline m = {} N, M = list(map(int, input().split())) penalty = 0 for _ in range(M): p, s = input().split() p = int(p) if s == ""AC"": if p not in m: m[p] = 1 else: if p not in m: penalty += 1 print(str(len(m.keys())) + "" "" + str(penalty)) " p02802,s600520370,Wrong Answer,"n,m = map(int,input().split()) ps = [input().split() for i in range(m)] ans =[] for i in range(m): if not(ps[i][0] in ans) : ans += ps[i][0] wa = 0 ac = 0 for i in ans: for j in range(m): #問題番号の確認 if ps[j][0] == str(i): if ps[j][1] ==""WA"": wa += 1 elif ps[j][1] == ""AC"": ac += 1 break else: continue print(ac,wa)" p02802,s128070094,Wrong Answer,"Input = list(map(int,input().split())) N = Input[0] M = Input[1] Ar = [] for i in range(M): Input = list(map(str,input().split())) Ar.append([]) Ar[i].append(int(Input[0])) Ar[i].append(Input[1]) ac = 0 pn = 0 ac_ar=[] pn_ar=[] chk = 1 for i in range(M): if Ar[i][1]==""AC"": ac_ar.append(Ar[i][0]) chk+=1 elif (chk<=Ar[i][0])and(Ar[i][1]==""WA""): pn_ar.append(Ar[i][0]) ac = len(set(ac_ar)) pn = len(pn_ar) print(ac,pn)" p02802,s168579520,Wrong Answer,"from collections import defaultdict n, m = map(int, input().split()) ps = [list(input().split()) for _ in range(m)] cnt = defaultdict(int) d = defaultdict() for p, s in ps: if s == ""AC"": if not d.get(p): d[p] = cnt[p] else: cnt[p] += 1 correct = 0 pena = 0 for k, v in d.items(): correct += 1 pena += v print(correct, pena) " p02802,s350234293,Wrong Answer,"n,m = map(int, input().split()) wrong = [0] * n wrongAns = [0] * n goodAns = [0] * n badAnsF = 0 greatAnsF = 0 #print(wrong) for i in range(m): p,s = input().split() if(s == ""WA""): wrong[int(p)-1] += 1 elif(s == ""AC""): wrongAns[int(p)-1] = wrong[int(p)-1] goodAns[int(p)-1] = 1 for i in wrongAns: badAnsF += i for i in goodAns: greatAnsF += i print(greatAnsF,badAnsF)" p02802,s987676257,Wrong Answer,"n, m=map(int, input().split()) AC, WA=[0]*n, [0]*n for _ in range(m): p, s=list(map(str, input().split())) p=int(p)-1 if AC[p]==0: if s=='WA': WA[p]+=1 else: AC[p]+=1 print(sum(AC), sum(WA))" p02802,s004630083,Wrong Answer,"N,M=map(int,input().split()) p_s=[list(map(str,input().split())) for _ in range(M)] ac_wa = [0,0] ac_list = [] wa_list = [] for p,s in p_s: if s == ""AC"" and p not in ac_list: ac_wa[0] += 1 ac_list.append(p) elif s == ""WA"" and p not in wa_list: ac_wa[1] += 1 wa_list.append(p) print(*ac_wa) " p02802,s161445421,Wrong Answer,"n,m=map(int,input().split()) row=m number=[0] judgment=[0] for i in range(row): a,b=input().split() number.append(int(a)) judgment.append(b) z = 0 seitou,sippai = 0,0 kuria = [0] * (n+1) if m > 0: for i in range(0,m+1): if kuria[number[i]] == 0 and judgment[i] == 'AC': seitou += 1 kuria[number[i]] = 1 elif kuria[number[i]] == 0 and judgment[i] == 'WA': sippai += 1 else: pass print(seitou,sippai) " p02802,s609044512,Wrong Answer,"N , M = map(lambda x: int(x),input().split()) isAC = [""WA""] * N score=0 penalty = 0 for i in range(M): p,r = input().split() #print(p,r) p = int(p) p -= 1 if isAC[p] ==""AC"": continue if r == ""WA"": penalty += 1 #print(penalty) elif r == ""AC"": isAC[p] = ""AC"" score+=1 #print(score) #print(isAC) print(score,penalty) " p02802,s988408638,Wrong Answer,"N,M=map(int, input().split()) p=[] S=[] for i in range(M): P,s=input().split() p.append(int(P)) S.append(s) A=[] W=0 for i in range(0, M): if S[i]=='AC': if p[i] not in A: A.append(p[i]) elif S[i]=='WA': if p[i] not in A: W+=1 print(len(A), W)" p02802,s181096691,Wrong Answer,"n, m = map(int, input().split()) from collections import defaultdict d = defaultdict(list) ab = [tuple(input().split()) for i in range(m)] nAC = 0 nWA = 0 for a,b in ab: a = int(a) if len(d[a]) == 0: flag = 0 if flag == 1: continue if flag == 0 and b == 'AC': flag = 1 nAC += 1 if flag == 0 and b == 'WA': nWA += 1 d[a].append(b) print(nAC, nWA)" p02802,s977686611,Wrong Answer,"n,m=map(int,input().split()) sum_ok,sum_miss=0,0 former_ok=[0]*n for i in range(m): p, s=input().split() p=int(p) if p not in former_ok: if s == 'AC': former_ok[sum_ok] = p sum_ok += 1 if sum_ok == n: break else: sum_miss += 1 print(sum_ok, sum_miss) " p02802,s610462447,Wrong Answer,"N, M = map(int,input().split()) tasks = [] for i in range(M): a, b = map(str,input().split()) tasks.append([int(a),b]) AC = 0 WA = 0 try: for i in range(len(tasks)): num = tasks[i][0] if tasks[i][1]==""AC"": AC += 1 for j in range(i+1,len(tasks)): if tasks[j][0]==tasks[i][0]: del tasks[j] else: for j in range(i+1,len(tasks)): if tasks[j]==[i,""AC""]: WA += 1 except IndexError: pass print(AC, WA)" p02802,s546582426,Wrong Answer,"N,M = map(int,input().split()) A = (N+1)*[0] ans = [0,0] for m in range(M): P,S = input().split() P = int(P) if A[P]==0 and S==""AC"": ans[0]+=1 A[P]+=1 elif A[P]==0 and S==""WA"": ans[1]+=1 print(*ans)" p02802,s892842577,Wrong Answer,"N, M = map(int, input().split()) acCheck = [False] * (N + 1) waCnt = 0 acCnt = 0 for i in range(M): query = list(input().split()) ok = acCheck[int(query[0])] if ok: continue if query[1] == ""AC"": acCheck[int(query[0])] = True acCnt += 1 else: waCnt += 1 print(str(acCnt), str(waCnt)) " p02802,s049589298,Wrong Answer,"N,M = [int(i) for i in input().rstrip().split(' ')] P = [0 for _ in range(N)] ans,pen = 0,0 for _ in range(M): p,s = input().rstrip().split(' ') p = int(p) - 1 if P[p] == -1: continue if s == ""WA"": P[p] += 1 pen += 1 else: ans += 1 P[p] = -1 print(ans,pen)" p02802,s909697834,Wrong Answer,"n, m = (int(x) for x in input().split()) ps = [] for _ in range(m): p, s = (x for x in input().split()) ps.append([int(p), s]) ans = [0] * n pen = 0 tmp = 0 for p, s in ps: if s == 'WA': tmp += 1 continue else: ans[p - 1] = 1 pen += tmp tmp = 0 print(sum(ans), pen)" p02802,s968671327,Wrong Answer,"n ,m = map(int,input().split()) ok = [False] * n wa_cnt = 0 for i in range(m): p,s = input().split() if s == 'AC': ok[int(p)-1] = True elif not(ok[int(p)-1]): wa_cnt += 1 print(sum(ok),wa_cnt) " p02802,s008996274,Wrong Answer,"N, M = map(int, input().split()) AC_or_not = [False] * N n_penalty = [0] * N for _ in range(M): prob, wa_ac = input().split() prob = int(prob) - 1 if wa_ac == 'AC': AC_or_not[prob] = True else: if not AC_or_not[prob]: n_penalty[prob] += 1 print(sum(AC_or_not), sum(n_penalty))" p02802,s873512839,Wrong Answer,"n,m=map(int,input().split()) ps=list(list(input().split()) for _ in range(m)) wal=[0]*n acl=[0]*n for p,s in ps: p=int(p)-1 if s=='AC' and acl[p] ==0: acl[p]+=1 elif s=='WA' and acl[p] ==0: wal[p]+=1 print(acl) print(wal) wa=0 for i,ac in enumerate(acl): if ac == 1: wa+=wal[i] print(sum(acl),wa)" p02802,s143410431,Wrong Answer,"import numpy as np N,M = map(int,input().split()) Q = np.zeros((N,2),dtype=int) for i in range(M): p,S = input().split() p = int(p)-1 if Q[p,0] == 0 and S == ""AC"": Q[p,0] = 1 elif Q[p,0] == 0 and S == ""WA"": Q[p,1] += 1 else: pass ret = Q.sum(axis=0) print(ret[0],ret[1])" p02802,s054686216,Wrong Answer,"total = {} penalty = 0 n,m = map(int, input().split()) for _ in range(m): num,answer = input().split() #キーに値を持つか if num in total: total[num].append(answer) else: #辞書の作成 total[num] = [answer] for answer_value in total.values(): if ""AC"" in answer_value: penalty += answer_value.index(""AC"") print(len(total),penalty)" p02802,s683189294,Wrong Answer,"n,m = map(int,input().split()) d = [] w = 0 a = 0 for i in range(m): P,S = input().split() P = int(P) if(S == 'WA'): if(P not in d):w += 1 elif(S == 'AC'): if(P not in d): d.append(P) a += 1 print(a,w)" p02802,s451848196,Wrong Answer," N,M = map(int,input().split()) ps = [list(map(str,input().split())) for _ in range(M)] wacnt = [0]*(N+1) is_ac = [False]*(N+1) for pp,s in ps: p = int(pp) if s=='AC': is_ac[p] = True else: if not is_ac[p]: wacnt[p] += 1 ans = 0 for l in range(N+1): if is_ac[l]: ans += wacnt[l] print(ans)" p02802,s676807394,Wrong Answer,"N, M = map(int, input().split()) l = [[] for i in range(N)] old_p = 0 for i in range(M): tmp = list(input().split()) # if tmp[0] != str(old_p + 1): # old_p += 1 # l[old_p].append(tmp[1]) l[int(tmp[0]) - 1].append(tmp[1]) ac = 0 wa = 0 #print(l) for i in range(N): for j in range(len(l[i])): if l[i][j] == 'WA': wa += 1 else: ac += 1 break print('{} {}'.format(ac, wa))" p02802,s984965866,Wrong Answer,"N, M = map(int, input().split()) P = [True] * N wa = 0 for _ in range(M): p, s = input().split() p = int(p) if s == 'AC': P[p-1] = False elif P[p-1]: wa += 1 print(P.count(False), wa)" p02802,s131081264,Wrong Answer,"N, M = map(int, input().split()) ac = [0]*N wa = [0]*N for m in range(M): p, s = input().split() p = int(p) - 1 if s == 'AC' and ac[p] == 0: ac[p] += 1 elif s == 'AC' and ac[p] != 0: ac = ac elif s == 'WA' and wa[p] == 0: wa[p] += 1 elif s == 'WA' and wa[p] != 0: wa = wa print(ac.count(1), wa.count(1)) " p02802,s649382445,Wrong Answer,"n,m = list(map(int, input().split())) P,S = [],[] for i in range(m): p,s = input().split() P.append(p) S.append(s) WA_count, AC_count = 0, 0 P_set = list(set(P)) for i in range(len(P_set)): Pi_index = [j for j, x in enumerate(P) if x == P_set[i]] for k in Pi_index : if S[k] == 'WA' : WA_count += 1 else : AC_count += 1 break print(AC_count, WA_count)" p02802,s465571453,Wrong Answer,"N, M = list(map(int, input().split())) WA = [0]*N AC = [False]*N for _ in range(M): p, S = input().split() p = int(p)-1 if S == 'WA': if AC[p] == False: WA[p] += 1 else: AC[p] = True print(AC.count(True), sum(WA)) " p02802,s605844557,Wrong Answer,"N,M=map(int,input().split()) PS=[input().split() for i in range(M)] ACzumi=[] i=0 WA_count=0 while i 0: obj[key]['WA'] = obj[key]['WA'] + 1 if res == 'AC': obj[key]['AC'] = 1 for k in obj: ii = ii + obj[k]['AC'] jj = jj + obj[k]['WA'] print(ii, jj)" p02802,s917345930,Wrong Answer,"#c = input() #n = int(input()) n, m = map(int, input().split()) b = [[0] for i in range(n)] acnt = 0 wcnt = 0 for i in range(m): p, s = map(str, input().split()) if s == ""WA"": if b[int(p)-1][0] == 0: wcnt += 1 else: if b[int(p)-1][0] == 0: acnt += 1 b[int(p)-1][0] = 1 print(acnt, wcnt) " p02802,s565836864,Wrong Answer,"import collections k,n = map(int, raw_input().split(' ')) cc = {'AC': collections.Counter(), 'WA': collections.Counter()} for _ in range(n): i,res = raw_input().split(' ') i = int(i) if res == 'AC': cc['AC'][i] += 1 elif res == 'WA': cc['WA'][i] += 1 s = 0 for p in cc['AC']: s += cc['WA'][p] print len(cc['AC']), s #len(penalties)" p02802,s336334127,Wrong Answer,"N,M = map(int,input().split()) k = [] ac_count = 0 miss_count = 0 for i in range(M): s = input().split() if s[1] == ""AC"": if s[0] not in k: k.append(s[0]) ac_count += 1 else: if s[0] not in k: miss_count += 1 print(ac_count,miss_count)" p02802,s901751432,Wrong Answer,""""""" flag がTrueのときAC済み。falseのときWAのみ flag == Falseかつ """""" 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 wa = 0 i = 0 while i < m : p = ps[i][0] s = ps[i][1] if s == ""WA"" and flag[p - 1] == False: wa += 1 elif s == ""AC"" and flag[p - 1] == False: ac += 1 flag[p - 1] = True i += 1 print(str(ac) + "" "" + str(wa))" p02802,s199048133,Wrong Answer,"n,m = map(int,input().split()) L = [0]*n ans = 0 penalty = 0 for i in range(m): p,q = input().split() if q == 'AC': if L[int(p)-1] == 0: L[int(p)-1] = 1 ans += 1 else: if L[int(p)-1] == 0: penalty += 1 print(ans,penalty)" p02802,s135219361,Wrong Answer,"# 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""): ac+=1 else: wa+=1 break print(ac,wa)" p02812,s287730526,Accepted,"N = int(input()) S = input() print(S.count('ABC'))" p02812,s983274368,Accepted,"n = int(input()) s = input() cnt = 0 tmp = """" for elem in s: if ""A"" == elem: tmp += elem elif ""B"" == elem and tmp != """": if tmp[-1] == ""A"": tmp += elem else: tmp = """" elif ""C"" == elem and tmp != """": if tmp[-1] == ""B"": cnt += 1 tmp = """" else: tmp = """" print(cnt)" p02812,s985552159,Accepted,"n=input() s=input() print(s.count('ABC')) " p02812,s229415812,Accepted,"_=input() s=input().split(""ABC"") print(len(s)-1)" p02812,s249395515,Accepted,"N = int(input()) S = input() ans = 0 for i in range(N - 2): if S[i] == ""A"" : if S[i + 1] == ""B"": if S[i + 2] == ""C"": ans += 1 print(ans)" p02812,s057748108,Accepted,"N = int(input()) S = input() print(S.count('ABC'))" p02812,s718115036,Accepted,"N = int(input()) S = input() print(S.count('ABC'))" p02812,s429944384,Accepted,"n = int(input()) s = input() print(s.count('ABC')) " p02812,s961739611,Accepted,"N,S=open(0);print(S.count('ABC'))" p02812,s780224401,Accepted,"n = input() s = input() print(s.count('ABC'))" p02812,s646527669,Accepted,"N = int(input()) S = input() count = 0 for i in range(N-2): if S[i] == ""A"" and S[i+1] == ""B"" and S[i+2] == ""C"": count += 1 print(count)" p02812,s717942959,Accepted,"import numpy as np N=int(input()) S=input() count=0 for i in range(N-2): if S[i] == 'A' and S[i+1]=='B' and S[i+2]=='C': count=count+1 print(count)" p02812,s242334814,Accepted,"import sys sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) N = ir() S = sr() answer = S.count('ABC') print(answer) " p02812,s163577336,Accepted,"import re n = int(input()) text = input() pattern = ""ABC"" result = re.findall(pattern, text) print(len(result))" p02812,s199806846,Accepted,"# coding: utf-8 # Your code here! N = int(input()) S = input() count_ABC = 0 for i in range(len(S)-2) : if S[i] == ""A"" and S[i+1] == ""B"" and S[i+2] == ""C"" : count_ABC += 1 print(count_ABC)" p02812,s437982019,Accepted,"n = int(input()) s = input() cnt = 0 for i in range(n-2): if s[i:i+3] == ""ABC"": cnt += 1 print(cnt)" p02812,s638104985,Accepted,"n=int(input()) s=input() ans=0 for i in range(len(s)-2): if s[i]+s[i+1]+s[i+2]==""ABC"": ans+=1 print(ans) " p02812,s900693164,Accepted,"N = int(input()) S = input() ans = 0 for i in range(N): if S[i:i+3] == ""ABC"": ans += 1 print(ans)" p02812,s700785107,Accepted,"n=int(input()) s=input() print(s.count('ABC'))" p02812,s079944730,Accepted,"N = int(input()) S = input() print(S.count('ABC'))" p02812,s684434133,Accepted,"n = int(input()) str =input() print(str.count(""ABC""))" p02812,s487400078,Accepted,"n = int(input()) s = input() count = 0 for i in range(len(s)-2): if s[i] == 'A' and s[i+1] == 'B' and s[i+2] == 'C': count += 1 print(count)" p02812,s233589131,Accepted,"N=int(input()) S=input() print(S.count(""ABC""))" p02812,s100437555,Accepted,"N = int(input()) S = input() count = 0 for i in range(N-2): if S[i:i+3] == 'ABC': count += 1 print(count) " p02812,s912692917,Accepted,"N = int(input()) S = input() print(S.count('ABC'))" p02812,s142805303,Accepted,"n = int(input()) s = input() i = 0 ans = 0 while i < n: if i > n - 3: break if s[i] == 'A' and s[i + 1] == 'B' and s[i + 2] == 'C': ans += 1 i += 1 print(ans)" p02812,s674422589,Accepted,"n = int(input()) s = input() res = 0 for i in range(n-2): if s[i:i + 3] == 'ABC': res += 1 print(res)" p02812,s479105995,Accepted,"n = int(input()) s = input() cnt = 0 for i in range(len(s)): if s[i] == ""A"" and i+2 <= len(s)-1: if s[i+1] == ""B"": if s[i+2] == ""C"": cnt += 1 print(cnt)" p02812,s816385925,Accepted,"n = int(input()) s = input() ans = 0 for i in range(n-2): if s[i:i+3] == ""ABC"": ans += 1 print(ans)" p02812,s654194980,Accepted,"_ = input() print(input().count(""ABC"")) " p02812,s470241594,Accepted,"n = int(input()) s = input() ans = 0 slist = list(s) for i in range(n - 2): if slist[i] == ""A"" and \ slist[i + 1] == ""B"" and slist[i + 2] == ""C"": ans += 1 print(ans)" p02812,s693728702,Accepted,"n = int(input()) s = input() print(sum(s[i:i+3]=='ABC' for i in range(n-2)))" p02812,s376139930,Accepted,"n = int(input()) s = input() count = 0 for i in range(n-2): if s[i] == ""A"" and s[i+1] == ""B"" and s[i+2] ==""C"": count +=1 print(count)" p02812,s692594753,Accepted,"N = int(input()) S = str(input()) print(S.count('ABC'))" p02812,s634505902,Accepted,"n = int(input()) s = input() print(s.count(""ABC"")) " p02812,s167827989,Accepted,"N = int(input()) S = input() cnt = 0 for i in range(N-2): if S[i:i+3] == 'ABC': cnt += 1 print(cnt)" p02812,s964615576,Accepted,"N = int(input()) S = input() cnt = 0 num = 0 for i in S: if (i == 'A' and S[cnt+1] == 'B' and S[cnt+2] == 'C'): num += 1 cnt += 1 if cnt == N-2: break print(num)" p02812,s475377859,Accepted,"N = int(input()) S = input() S += 'a' ans = 0 for i in range(N-2): if S[i:i+3] == 'ABC': ans += 1 print(ans)" p02812,s257209688,Accepted,"n=int(input()) s=input() n=n-2 cnt=0 for i in range(n): if s[i]=='A' and s[i+1:i+3]=='BC': cnt+=1 print(cnt)" p02812,s472650302,Accepted,"import re n = int(input()) s = input() print(len(re.findall('ABC', s)))" p02812,s615671482,Accepted,"N = int(input()) S = input() ret = 0 cursor = 0 for s in S: if cursor == 0: if s == 'A': cursor = 1 elif cursor == 1: if s == 'B': cursor = 2 elif s == 'A': cursor = 1 else: cursor = 0 else: if s == 'C': ret += 1 cursor = 0 elif s == 'A': cursor = 1 else: cursor = 0 print(ret) " p02812,s836484025,Accepted,"import math n = int(input()) s = input() count = 0 for i in range(2, n): if (s[i-2] == 'A' and s[i - 1] == 'B' and s[i] == 'C'): count += 1 print(count) " p02812,s348155921,Accepted,"_ = int(input()) s = str(input()) ans = 0 for i in range(len(s)-2): ans += ""ABC"" == '{}'.format(s[i:i+3]) print(ans)" p02812,s983112080,Accepted,"n = int(input()) s = input() count = 0 for i in range(n - 2): if s[i] == ""A"" and s[i + 1] == ""B"" and s[i + 2] == ""C"":count += 1 print(count)" p02812,s326916294,Accepted,"n = input() s = input() print(s.count('ABC') ) " p02812,s353550283,Accepted,"a = input() b = input() ABC = 0 for i in range(int(a)-2): if b[i:i+3] == ""ABC"": ABC +=1 print(ABC)" p02812,s771322252,Accepted,"N = int(input()) S = input() print(S.count('ABC'))" p02812,s537406277,Accepted,"N = int(input()) S = input() abc = """" result = 0 for x in S: abc += x if x == 'C': if abc[-3:] == ""ABC"": result += 1 print(result)" p02812,s752514610,Accepted,"N = int(input()) S = input() cnt = 0 for i in range(N-2) : if S[i] == ""A"" : if S[i+1] == ""B"" : if S[i+2] == ""C"" : cnt += 1 print(cnt)" p02812,s921233635,Accepted,"N = int(input()) S = input() print(S.count('ABC'))" p02812,s033607855,Accepted,"n = int(input()) s = input() count = 0 for i in range(n-2): if s[i] == ""A"" and s[i+1] == ""B"" and s[i+2]==""C"": count += 1 print(count)" p02812,s068428861,Accepted,"n = int(input()) s = input() print(s.count(""ABC""))" p02812,s086142988,Accepted,"n = int(input()) s = input() print(s.count(""ABC"")) " p02812,s631809572,Accepted,"N = int(input()) S = input() target = 'ABC' print(S.count(target))" p02812,s440217829,Accepted,"n, s = int(input()), input() print(s.count(""ABC""))" p02812,s295951646,Accepted,"input() s = input() n = 0 i = 0 while i != -1: i = s.find('ABC') s = s[i+3:] n += 1 print(n-1) " p02812,s487895955,Accepted,"N = int(input()) S = input() print(S.count(""ABC""))" p02812,s135187324,Accepted,"n = int(input()) s = input() ans = 0 for i in range(n): if s[i:i+3] == ""ABC"": ans += 1 print(ans)" p02812,s628757063,Accepted,"a=int(input()) b=input() print(b.count('ABC'))" p02812,s289525923,Accepted,"N = int(input()) S = input() print(S.count(""ABC"")) " p02812,s401003816,Accepted,"N = int(input()) S = str(input()) cnt = 0 for i in range(N-2): if S[i]=='A' and S[i+1]=='B' and S[i+2]=='C': cnt += 1 print(cnt)" p02812,s237686810,Accepted," N = int(input()) S = input() print(S.count(""ABC""))" p02812,s463059204,Accepted,"N = int(input()) S = input() print(S.count('ABC')) " p02812,s392465337,Accepted,"N = input() S = input() print(S.count('ABC'))" p02812,s750586453,Accepted,"N = int(input()) S = input() def main(): print(S.count(""ABC"")) return if __name__ == ""__main__"": main()" p02812,s407415397,Accepted,"N= int(input()) S = input() print(S.count('ABC'))" p02812,s010470018,Accepted,"N=int(input()) S=input() cnt=0 for i in range(N-2): if(S[i:i+3]=='ABC'): cnt+=1 print(cnt)" p02812,s485972840,Accepted,"n= int(input()) print(input().count(""ABC""))" p02812,s778392670,Accepted,"N=input() S=input() print(S.count(""ABC"")) " p02812,s191059378,Accepted,"n=int(input()) s=input() cnt=0 while 'ABC' in s: s=s.replace('ABC','',1) cnt+=1 print(cnt)" p02812,s532751583,Accepted,"n=int(input()) s=str(input()) ans=s.count('ABC') print(ans)" p02812,s309638323,Accepted,"# -*- coding:utf-8 -*- n = int(input()) s = input() print(s.count('ABC'))" p02812,s471511061,Accepted,"n = int(input()) s = input() sum = 0 for i in range(n-2): if (s[i]=='A'): if(s[i+1]=='B'): if(s[i+2]=='C'): sum = sum + 1 print(sum)" p02812,s571403528,Accepted,"N = int(input()) S = input() print(S.count('ABC'))" p02812,s295406527,Accepted,"import sys import math import bisect def main(): n = int(input()) s = input() ans = 0 for i in range(n): if i + 3 <= n: if s[i:i+3] == 'ABC': ans += 1 print(ans) if __name__ == ""__main__"": main() " p02812,s831374304,Accepted,"n = int(input()) s = input() print(s.count('ABC'))" p02812,s724741916,Accepted,"n = int(input()) s = input() print(s.count('ABC'))" p02812,s324468437,Accepted,"N=input() S=input() print(S.count('ABC'))" p02812,s001817950,Accepted,"N = int(input()) X = input() print(X.count(""ABC""))" p02812,s904621621,Accepted,"N = int(input()) S = list(input()) p = 0 for i in range(N-2): if S[i] == ""A"" and S[i+1] == ""B"" and S[i+2] == ""C"": p += 1 print(p) " p02812,s151524341,Accepted,"n=int(input()) s=input() print(s.count(""ABC""))" p02812,s731492588,Accepted,"n = int(input()) s = input() print(s.count(""ABC""))" p02812,s004609641,Accepted,"n = int(input()) s = input() print(sum([1 for i in range(n-2) if s[i:i+3] == 'ABC']))" p02812,s479284789,Accepted,"n = int(input()) s = input() ans = 0 for i in range(n-2): if s[i:i+3] == 'ABC': ans += 1 print(ans) " p02812,s706899057,Accepted,"n=int(input()) s=input() count = 0 for i in range(n-3+1): # print(s[i],s[i+1],s[i+2]) if s[i]==""A"" and s[i+1]==""B"" and s[i+2]==""C"": count = count + 1 print(count)" p02812,s733899072,Accepted,"def solve(): n = int(input()) s = input() tmp = 0 for i in range(n - 2): if (s[i], s[i+1], s[i+2]) == (""A"", ""B"", ""C""): tmp += 1 print(tmp) solve() " p02812,s241098949,Accepted,"N = int(input()) S = input() print(sum([1 for i in range(N-2) if S[i]+S[i+1]+S[i+2] == ""ABC""]))" p02812,s991825546,Accepted,"n=int(input()) s=input() print(s.count(""ABC"")) " p02812,s279612976,Accepted,"n = int(input()) s = str(input()) if ""ABC"" in s: print(s.count(""ABC"")) else: print(0)" p02812,s300264295,Accepted,"N=int(input()) S=list(input()) a=0 for i in range(0,N-2): if (S[i]+S[i+1]+S[i+2])=='ABC': a+=1 print(a)" p02812,s834696283,Accepted,"n=int(input()) s=str(input()) print(s.count(""ABC""))" p02812,s798906130,Accepted,"N = int(input()) S = input() stackString = """" resultCount = 0 for s in S: if stackString == """" and s == ""A"": stackString += ""a"" elif stackString == ""a"" and s == ""B"": stackString += ""b"" elif stackString == ""ab"" and s == ""C"": stackString = """" resultCount += 1 else: if not(stackString == ""a"" and s == ""A""): stackString = """" print(resultCount)" p02812,s520935919,Accepted,"n=int(input()) s=input() print(s.count('ABC'))" p02812,s463847575,Accepted,"N=int(input()) S=input() print(S.count(""ABC"")) " p02812,s645689227,Accepted,"# coding: utf-8 N = int(input()) S = input() cnt = 0 for i in range(N): if S[i:i+3] == ""ABC"": cnt += 1 print(cnt)" p02812,s679140538,Accepted,"N = int(input()) S = input() print(S.count(""ABC""))" p02812,s110839385,Accepted,"n = int(input()) x = input() print(x.count(""ABC""))" p02812,s525612793,Accepted,"n=int(input()) s=input() l=[] for i in s: l.append(i) #print(l) count=0 for i in range(len(l)-2): if l[i]==""A"" and l[i+1]==""B"" and l[i+2]==""C"": count+=1 print(count)" p02812,s816523336,Accepted,"N=int(input()) S=input() ans=0 for i in range(N): if S[i]=='A': if i+1 3: for i in range(N-2): if S[i:i+3] == ""ABC"": ans += 1 else: ans = 1 if S == ""ABC"" else 0 print(ans)" p02812,s707883738,Accepted,"n = int(input()) s = input().strip() cnt = 0 for i in range(len(s) - 2): if s[i] == 'A' and s[i+1] == 'B' and s[i+2] == 'C': cnt += 1 print(cnt)" p02812,s002627168,Accepted,"N = int(input()) S = input() count = S.count(""ABC"") print(count)" p02812,s674979776,Accepted,"n = int(input()) s = input() target = 'ABC' res = 0 start=0 while True: next = s.find(target,start) if next == -1: break res += 1 start = next + 3 print(res)" p02812,s109036625,Accepted,"def main(): n = int(input()) s = list(input()) ans = 0 for i in range(n-2): abc = str(s[i]) + str(s[i+1]) + str(s[i+2]) if abc == ""ABC"": ans += 1 print(ans) if __name__ == ""__main__"": main() " p02812,s718004543,Accepted,"N=int(input()) S=input() a=0 for i in range(N-2): if S[i:i+3]==""ABC"": a+=1 print(a)" p02812,s593474706,Accepted,"N = input() S = input() print(S.count('ABC'))" p02812,s996496242,Accepted,"n = int(input()) s = input() print(s.count('ABC'))" p02812,s567643597,Accepted,"N = int(input()) S = str(input()) cnt = 0 for i in range(0, N-2): if S[i:i+3] == ""ABC"": cnt += 1 print(cnt) " p02812,s865187727,Accepted,"N = int(input()) S = input() ans = S.count('ABC') print(ans)" p02812,s641075713,Accepted,"N = int(input()) S = list(input()) c = 0 for i in range(0,len(S)-1): if S[i:i+3]==[""A"",""B"",""C""]: c += 1 print(c)" p02812,s684974847,Accepted," n= int(input()) s = input() s = s.replace(""ABC"","""") print((n-len(s))//3) " p02812,s572687178,Accepted,"N=int(input()) S=input() print(S.count(""ABC""))" p02812,s076981795,Accepted,"def main(): # 入力 n = int(input()) s = input() print(s.count(""ABC"")) main() " p02812,s072341581,Accepted,"N = int(input()) S = input() print(S.count(""ABC""))" p02812,s219090292,Accepted,"N = int(input()) S = str(input()) def main(): print(S.count('ABC')) if __name__ == ""__main__"": main() " p02812,s152603307,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(): n = ri() s = input() ans = 0 for i in range(n-2): if s[i:i+3] == ""ABC"": ans += 1 print(ans) if __name__ == '__main__': main() " p02812,s576548814,Accepted,"N = int(input()) S = input() count = 0 for i in range(N): if S[i:i+3]=='ABC': count += 1 print(count)" p02812,s666105889,Accepted,"import math from collections import deque def main(): n = int(input()) s = input() print(s.count(""ABC"")) if __name__ == ""__main__"": main()" p02812,s785586725,Accepted,"n = int(input()) s = input() print(s.count(""ABC""))" p02812,s081763491,Accepted,"n = input() s = input() t = s.replace('ABC','') print(int((len(s)-len(t))/3))" p02812,s521964603,Accepted,"N = int(input()) S = input() count = 0 for i in range(N-2): if S[i]=='A' and S[i+1] == 'B' and S[i+2] == 'C': count = count + 1 print(count)" p02812,s717920387,Accepted,"n=int(input()) s=str(input()) print(s.count(""ABC""))" p02812,s085869191,Accepted,"N = int(input()) print(input().count(""ABC""))" p02812,s935180135,Accepted,"n = int(input()) s = input() c = 0 for i in range(n-2): if s[i:i+3] == 'ABC': c += 1 print(c)" p02812,s138571135,Accepted,"N = int(input()) S = input() # S='ABCDE' ans = 0 for i in range(N-2): if(S[i:i+3] == 'ABC'): ans = ans + 1 print(ans)" p02812,s086832528,Accepted,"n=int(input()) s=input() print(s.count(""ABC""))" p02812,s089688371,Accepted,"N = int(input()) S = input() ans = S.count('ABC') print(ans)" p02812,s775977171,Accepted,"def solve(): N = int(input()) S = input() count = 0 for i in range(N-2): if(S[i] == ""A"" and S[i+1] == ""B"" and S[i+2] == ""C""): count += 1 print(count) if __name__ == ""__main__"": solve()" p02812,s215505018,Accepted,"N = int(input()) S = input() count = 0 for i in range(N-2): if S[i:i+3] == 'ABC': count += 1 print(count)" p02812,s657996172,Accepted,"N = int(input()) S = input() ans = 0 for i in range(N-2): if S[i] == ""A"": if S[i+1] == ""B"": if S[i+2] == ""C"": ans += 1 print(ans)" p02812,s078898746,Accepted,"n = int(input()) s = input() ans = 0 for i in range(n-2): if s[i] == 'A': if s[i+1] == 'B': if s[i+2] == 'C': ans += 1 print(ans)" p02812,s865789069,Accepted,"_=input() print(input().count('ABC'))" p02812,s602792488,Accepted,"n = int(input()) s = input() count = 0 for i in range(n - 2): if s[i] == ""A"" and s[i + 1] == ""B"" and s[i + 2] == ""C"":count += 1 print(count)" p02812,s849138873,Accepted,"N = int(input()) S = input() count = 0 while True: index_ABC = S.find('ABC') if index_ABC != -1: S = S[:index_ABC] + S[index_ABC + 3:] count += 1 else: break print(count)" p02812,s155126932,Accepted,"n = int(input()) s = input() ans = 0 for i in range(n-1): for j in range(i+1, n+1): if s[i:j] == 'ABC': ans += 1 print(ans) " p02812,s557510778,Accepted,"N = input() s = list(input()) ans = 0 for i in range(len(s)-2): if s[i]==""A"" and s[i+1] == ""B"" and s[i+2] == ""C"": ans += 1 print(ans) " p02812,s949892183,Accepted,"N = int(input()) S = input() print(S.count(""ABC"")) " p02812,s655328879,Accepted,"n=int(input()) s=input() c=0 for i in range(n-2): if s[i]=='A' and s[i+1]=='B' and s[i+2]=='C': c+=1 print(c)" p02812,s263007990,Accepted,"n = int(input()) s = input() print(s.count(""ABC""))" p02812,s720886637,Accepted,"n=int(input()) s=input() print(s.count(""ABC""))" p02812,s108148339,Accepted,"n = int(input()) s = str(input()) count = 0 for i in range(n-2): if s[i:i+3] == ""ABC"": count += 1 else: pass print(count)" p02812,s113096633,Accepted,"K=int(input()) l=list(input()) c=0 for i in range(K-2): if l[i]==""A"": if l[i+1]==""B"": if l[i+2]==""C"": c+=1 print(c)" p02812,s828059859,Accepted,"N=int(input()) S = input() s = 0 for i in range(0,N-2): if S[i:i+3] == ""ABC"": s += 1 print(s)" p02812,s717325261,Accepted,"N = int(input()) S = input() print(S.count(""ABC"")) " p02812,s477741363,Accepted,"N = int(input()) S = input() ans = 0 for i in range(N-2): if S[i] == 'A' and S[i+1] == 'B' and S[i+2] == 'C': ans += 1 print(ans) " p02812,s848357612,Accepted,"n=int(input()) s=list(input()) ans=0 for i in range(len(s)-2): if s[i]=='A': if s[i+1]=='B': if s[i+2]=='C': ans+=1 print(ans) " p02812,s451954972,Accepted,"N = int(input()) S = input() t = 0 for i in range(N-2): if S[i:i+3] == ""ABC"": t += 1 print(t)" p02812,s941332132,Accepted,"n=int(input()) s=input() cnt=0 for i in range(n-2): if s[i]=='A': if s[i+1]=='B' and s[i+2]=='C': cnt+=1 print(cnt)" p02812,s918230487,Accepted,"N = int(input()) S = input() c = 0 for i in range(N-2): if S[i] == ""A"" and S[i+1] == ""B"" and S[i+2] == ""C"": c = c + 1 print(c)" p02812,s885029498,Accepted,"# coding: utf-8 N = int(input()) S = input() res = 0 for i in range(N-2): if S[i:i+3] == ""ABC"": res+=1 print(res) " p02812,s305166111,Accepted,"N = int(input()) S = input() count = 0 for i in range(N-2): if S[i] == 'A': if S[i+1] == 'B' and S[i+2] == 'C': count += 1 print(count)" p02812,s611779926,Accepted,"n=int(input()) s=input() import re m = re.findall(""ABC"", s) print(len(m))" p02812,s893589550,Accepted,"n = int(input()) l = input() cnt = 0 for i in range(n-2): if l[i:i+3] == 'ABC': cnt += 1 print(cnt)" p02812,s117018079,Accepted,"N=int(input()) S=list(input()) Q=0 for i in range(N-2): if S[i]=='A' and S[i+1]=='B' and S[i+2]=='C': Q+=1 print(Q)" p02812,s820113053,Accepted,"n = input() s = input() count = 0 for i in range(len(s)-2): if s[i] == ""A"" and s[i+1] == ""B"" and s[i+2] == ""C"": count += 1 print(count) " p02812,s253678068,Accepted,"n = int(input()) s = input() count = 0 for i in range(n-2): if s[i]!=""A"": pass else: if s[i+1]!=""B"": pass else: if s[i+2]!=""C"": pass else: count += 1 print(count)" p02812,s005944650,Accepted,"n = int(input()) X = input() a = 0 for i in range(n-2): if X[i] + X[i+1] + X[i+2] == 'ABC': a +=1 else: a +=0 print(a)" p02812,s903086080,Accepted,"N = int(input()) S = input() count = 0 for i in range (N-2): if S[i] == ""A"": if S[i+1] == ""B"": if S[i+2] == ""C"": count += 1 print(count)" p02812,s758327322,Accepted,"n = int(input()) s = list(input()) type = ""A"" count = 0 for char in s: if char == ""A"": type = ""B"" elif char == ""B"" and type == ""B"": type = ""C"" elif char == ""C"" and type == ""C"": count += 1 type = ""A"" else: type = ""A"" print(count)" p02812,s433568196,Accepted,"N = int(input()) S = input() counts=0 for i in range(len(S)-2): if (S[i:i+3]) == 'ABC': counts+=1 print(counts)" p02812,s934458404,Accepted,"n=int(input()) s=input() print(s.count(""ABC""))" p02812,s108290724,Accepted,"n=int(input()) s=input() cnt=0 for i in range(len(s)-2): if s[i]==""A"" and s[i+1]==""B"" and s[i+2]==""C"": cnt+=1 print(cnt)" p02812,s605054991,Accepted,"n = int(input()) s = input() cnt = 0 for i in range(n-2): if s[i:i+3] == ""ABC"": cnt += 1 print(cnt)" p02812,s580322849,Accepted,"N = int(input()) S = str(input()) print(S.count(""ABC""))" p02812,s700280529,Accepted,"n=int(input()) s=input() print(sum(s[i:i+3]==""ABC"" for i in range(n-2)))" p02812,s929970929,Accepted,"import sys def I(): return int(sys.stdin.readline()) def LI(): return [int(x) for x in sys.stdin.readline().split()] def main(): N = int(input()) S = input() ans = 0 for i in range(N-2): if S[i:i+3]=='ABC': ans += 1 print(ans) if __name__ == ""__main__"": main() " p02812,s873123252,Accepted,"N=int(input()) S=list(input()) ans=0 for i in range(N-2): if S[i]==""A"": if S[i+1]==""B"" and S[i+2]==""C"": ans+=1 print(ans)" p02812,s318196919,Accepted,"import sys def solve(): readline = sys.stdin.buffer.readline mod = 10 ** 9 + 7 n = int(readline()) print(str(readline().rstrip().decode('utf-8')).count(""ABC"")) if __name__ == '__main__': solve() " p02812,s140210380,Accepted,"n = int(input()) s = input() print(s.count('ABC'))" p02812,s059520506,Accepted,"N = int(input()) S = input() print(S.count('ABC')) " p02812,s425608067,Accepted,"n = int(input()) s = input() t = s.count(""ABC"") print(t)" p02812,s568421238,Accepted,"# -*- coding: utf-8 -*- # 整数の入力 a = int(input()) s = input() print(s.count('ABC')) " p02812,s979202220,Accepted,"N = int(input()) S = list(input()) cn = 0 for i in range(N-2): if S[i] == 'A' and S[i+1] == 'B' and S[i+2] == 'C': cn = cn + 1 print(cn)" p02812,s689432173,Accepted,"_ = input() s = input() print(s.count('ABC'))" p02812,s242582418,Accepted,"N = int(input()) S = input().split(""ABC"") print(len(S)-1)" p02812,s334667884,Accepted,"n = int(input()) s = str(input().upper()) print(s.count(""ABC""))" p02812,s347388788,Accepted,"N=int(input()) S=input() c=0 for i in range(N-2): if S[i:i+3]==""ABC"": c+=1 print(c) " p02812,s382347332,Accepted,"N = int(input()) S = input() ans = 0 for i in range(N-2): if S[i] == 'A': if S[i+1] == 'B' and S[i+2] == 'C': ans += 1 print(ans)" p02812,s780650414,Accepted,"N = int(input()) word = list(input()) count = 0 for i in range(N - 2): if word[i]==""A"" and word[i+1]==""B"" and word[i+2]==""C"": count += 1 print(count)" p02812,s060869100,Accepted,"N, S, count = int(input()), input(), 0 for i in range(N-2): if S[i] == 'A' and S[i+1] == 'B' and S[i+2] == 'C': count += 1 print(count)" p02812,s058778680,Accepted,"def main(): N = int(input()) S = input() print(S.count('ABC')) if __name__ == '__main__': main()" p02812,s080711027,Accepted,"n=int(input()) x=input() y=x.count(""ABC"") print(y)" p02812,s441738935,Accepted,"input() print(input().count('ABC'))" p02812,s700373750,Accepted,"N = int(input()) S = input() print(S.count('ABC'))" p02812,s313530631,Accepted,"n = int(input()) s = input() sr = s.replace(""ABC"", """") ans = (n - len(sr)) // 3 print(ans)" p02812,s898514310,Accepted,"N = int(input()) S = str(input()) if len(S) != N: exit() S = S.upper() c = S.count('ABC') print(c)" p02812,s827223941,Accepted,"n = int(input()) s = input() ans = s.count(""ABC"") print(ans)" p02812,s680524793,Accepted,"N = int(input()) S = input() print(len([0 for c1, c2, c3 in zip(S, S[1:], S[2:]) if c1 == 'A' and c2 == 'B' and c3 == 'C'])) " p02812,s602988397,Accepted,"n=int(input()) s=input() print(s.count('ABC'))" p02812,s577438205,Accepted,"N=int(input()) S=input() print(S.count(""ABC""))" p02812,s785809902,Accepted,"n = int(input()) s = input() print(s.count(""ABC""))" p02812,s767050914,Accepted,"N = int(input()) S = input().strip() count = 0 for i in range(N): if S[i:i + 3] == ""ABC"": count += 1 print(count) " p02812,s014611121,Accepted,"n = int(input()) s = input() print(s.count(""ABC"")) " p02812,s646185588,Accepted,"import re _ = input() x = input() print(len(re.findall(r""ABC"", x))) " p02812,s921149602,Accepted,"N = int(input()) S = input() '''Solution 1''' # print(S.count('ABC')) '''Solution 2''' count = 0 for i in range(N): if S[i:i+3] == 'ABC': count+=1 print(count)" p02812,s925603397,Accepted,"N = int(input()) S = input() cnt = 0 for i in range(N-2): if S[i:i+3] == 'ABC': cnt += 1 print(cnt) " p02812,s974538798,Accepted,"n = int(input()) s = input() print(s.count('ABC'))" p02812,s552681647,Accepted,"N = int(input()) S = input() index = -1 if ""ABC"" in S: S = S.split(""ABC"") print(len(S)-1) else: print(""0"")" p02812,s078125198,Accepted,"N = int(input()) S = input() ans = 0 for i in range(N-2): if S[i] == ""A"" and S[i+1] == ""B"" and S[i+2] == ""C"": ans += 1 print(ans)" p02812,s062153437,Accepted,"A = int(input()) B = input() result = 0 for i in range(A): if B[i] == ""A"" and B[i:i+3] == ""ABC"": result += 1 print(result) " p02812,s086265522,Accepted,"n = int(input()) s = input() c = 0 for i in range(len(s) - 2): if s[i:i + 3] == 'ABC': c += 1 print(c)" p02812,s542214277,Accepted,"n = int(input()) s = input() flag = 0 for i in range(n-1): if i == n-2: break if s[i] == 'A': if s[i+1] == 'B': if s[i+2] == 'C': flag += 1 print(flag)" p02812,s514014449,Accepted,"n=int(input()) s=input() result=s.count('ABC') print(result)" p02812,s767353843,Accepted,"n=int(input()) s=input() print(sum(s[i:i+3]=='ABC' for i in range(n-2)))" p02812,s135775949,Accepted,"n = int(input()) s = input() ans = 0 for i in range(n-2): if s[i:i+3] == ""ABC"": ans +=1 print(ans)" p02812,s823275137,Accepted,"N = int(input()) S = input() print(S.count(""ABC""))" p02812,s540101844,Accepted,"n = int(input()) s = input() ans = 0 for i in range(n-2): if s[i:i+3] == 'ABC': ans += 1 print(ans)" p02812,s417917896,Accepted,"N = int(input()) S = input() ans = 0 for i in range(N - 2): if S[i:i + 3] == ""ABC"": ans += 1 print(ans) " p02812,s103684308,Accepted,"N=int(input()) S=input() count=0 for i in range(N): if S[i]=='A': if S[i+1:i+3]=='BC': count+=1 print(count) " p02812,s213038638,Accepted,"n = int(input()) s = input() ans = s.count('ABC') print(ans)" p02812,s415749223,Accepted,"def main(): N = int(input()) S = input() print(S.count('ABC')) main() " p02812,s963898597,Accepted,"N = int(input()) S = input() count = 0 for i in range(len(S)): if i <= len(S)-3: if S[i] == ""A"" and S[i+1] == ""B"" and S[i+2] == ""C"": count+=1 print(count)" p02812,s823245840,Accepted,"abc = 'ABC' n = int(input()) s = input() print(s.count(abc))" p02812,s783739202,Accepted,"N = map(int,input()) S = input() ans = S.count('ABC') print(ans)" p02812,s233379259,Accepted,"n = int(input()) s =input() print(s.count('ABC'))" p02812,s113259354,Accepted,"n = int(input()) s = input() cnt = 0 for i in range(n-2): if s[i] == ""A"" and s[i+1] == ""B"" and s[i+2] == ""C"": cnt += 1 print(cnt)" p02812,s558668766,Accepted,"N = int(input()) s = input() print(s.count('ABC'))" p02812,s051727879,Accepted,"N = input() S = input() print(S.count(""ABC""))" p02812,s325783981,Accepted,"N = int(input()) s = input() print(s.count('ABC'))" p02812,s872865874,Accepted,"n=int(input()) s=input() cnt=0 for i in range(n-2): if s[i]=='A' and s[i+1]=='B' and s[i+2]=='C': cnt+=1 print(cnt)" p02812,s551488403,Accepted,"n=int(input()) s=input() count=0 if n==3: if s==""ABC"": count=1 else: s=list(s) for i in range(n-3+1): if s[i]==""A"" and s[i+1]==""B"" and s[i+2]==""C"": count+=1 print(count) " p02812,s258159776,Accepted,"import re n = int(input()) s = input() print(len(re.findall('ABC', s))) " p02812,s246815168,Accepted,"N = int(input()) a = list(input()) count=0 for i in range(N): if a[i] == 'A' and i n-1: return ct if s[i] ==""A""and s[i+1]==""B"" and s[i+2]==""C"": ct+=1 print(res())" p02812,s775800137,Accepted,"# -*- coding: utf-8 -*- """""" Created on Fri Jan 10 21:09:39 2020 @author: over- """""" N=int(input()) S=input() c=0 for i in range(N-2): if S[i:i+3]=='ABC': c+=1 print(c)" p02812,s778657876,Accepted,"n = int(input()) m = str(input()) a = m.count('ABC') print(a)" p02812,s928917798,Accepted,"def i(): return int(input()) def i2(): return map(int,input().split()) def s(): return str(input()) def l(): return list(input()) def intl(): return list(int(k) for k in input().split()) n = i() s = s() print(s.count(""ABC""))" p02812,s217162296,Accepted,"L = int(input()) S = input() counter = 0 for i in range(L-2): if S[i:i+3] =='ABC': counter += 1 print(counter)" p02812,s489709459,Accepted,"N=int(input()) S=input() print(S.count(""ABC""))" p02812,s289533577,Accepted,"n = int(input()) s = input() ans = 0 for i in range(n-2): if s[i] == 'A' and s[i+1] == 'B' and s[i+2] == 'C': ans += 1 print(ans) " p02812,s390895420,Accepted,"n = int(input()) s = input() count = 0 for i in range(n - 2): if s[i] + s[i + 1] + s[i + 2] == 'ABC': count += 1 print(count)" p02812,s634090320,Accepted,"n=int(input()) s=input() ans=0 for i in range(n-2): if s[i] is 'A' and s[i+1] is 'B' and s[i+2] is 'C': ans+=1 else: continue print(ans)" p02812,s591675084,Accepted,"n = int(input()) s = input() ans = 0 for i in range(n-2): if s[i:i+3] == ""ABC"": ans += 1 print(ans)" p02812,s697870215,Accepted,"N = int(input()) S = input() print(S.count('ABC')) " p02812,s019733899,Accepted,"n = int(input()) s = input() ans = 0 for i in range(n-2): if s[i:i+3] == 'ABC': ans += 1 print(ans) " p02812,s619220013,Accepted,"n = int(input()) s = input() i = 0 ans = 0 while i < n-2: if s[i] == 'A' and s[i+1] == 'B' and s[i+2] == 'C': ans += 1 i += 3 else: i += 1 print(ans) " p02812,s254769739,Accepted,"N = int(input()) S = list(input()) cnt = 0 for i in range(N - 2): if S[i] == ""A"" and S[i + 1] == ""B"" and S[i + 2] == ""C"": cnt += 1 print(cnt) " p02812,s390166867,Accepted,"n = int(input()) s = input() print(s.count(""ABC""))" p02812,s326997353,Accepted,_=input();print(input().count('ABC')) p02812,s427217039,Accepted,"n = int(input()) s = input() print(s.count('ABC'))" p02812,s444396769,Accepted,"N = int(input()) S = str(input()) count = 0 for i in range(N-2): if S[i:i+3] == 'ABC': count += 1 print(count)" p02812,s725962812,Accepted,"N = input() S = input() T = ""ABC"" res=0 for i in range(0, len(S)): if S[i:i+len(T)]==T: res+=1 print(res)" p02812,s205311166,Accepted,"n = int(input()) s = list(input()) cnt=0 for i in range(n-2): # print(i) if s[i] == 'A': if s[i+1] == 'B': if s[i+2] == 'C': cnt+=1 print(cnt)" p02812,s431736046,Accepted,"N = int(input()) S = input() count = 0 for k in range(N-2): if S[k:k+3] == 'ABC': count += 1 print(count)" p02812,s798818328,Accepted,"n = int(input()) S = input() cnt = 0 for i in range(n-2): if ""ABC"" == S[i:i+3]: cnt += 1 print(cnt)" p02812,s838375358,Accepted,"N = int(input()) S = input() ans = 0 for i in range(N-2): if S[i] == ""A"" and S[i+1] == ""B"" and S[i+2] == ""C"": ans = ans + 1 print(ans)" p02812,s274840527,Accepted," n=int(input()) s=input() ans=0 for i in range(n-2): if(s[i]==""A"" and s[i+1]==""B"" and s[i+2]==""C""): ans+=1 print(ans)" p02812,s354191427,Accepted,"# -*- coding: utf-8 -*- n = input() s = input() print(s.count('ABC'))" p02812,s334635972,Accepted,"N = int(input()) S = input() print(S.count('ABC'))" p02812,s036415519,Accepted,"n = int(input()) s = input() print(s.count(""ABC""))" p02812,s097686670,Accepted,"n = input() s = input() print(s.count(""ABC""))" p02812,s701432894,Accepted,"N = int(input()) S = input() ans = 0 for i in range(N-2): if S[i] == 'A' and S[i+1] == 'B' and S[i+2] == 'C': ans += 1 print(ans)" p02812,s041814487,Accepted,"def solve(): N = int(input()) S = input() if N != len(S): return ans = 0 for i in range(N-2): target_segment = S[i:i+3] if target_segment == ""ABC"": ans += 1 print(ans) if __name__ == ""__main__"": solve()" p02812,s942099307,Accepted,"N=int(input()) S=input() print(S.count(""ABC"")) " p02812,s883899690,Accepted,"n=int(input()) s=str(input()) ans=0 for i in range(n): if(""ABC""==s[i:i+3]):ans+=1 print(ans)" p02812,s799220966,Accepted,"N = int(input()) S = input() print(S.count('ABC'))" p02812,s390498298,Accepted,"n = int(input()) s = input() ans = 0 for i in range(n-2): if s[i:i+3] == ""ABC"": ans += 1 print(ans)" p02812,s418316090,Accepted,"def main(): num = int(input()) s = input() cnt = 0 for i in range(len(s) - 2): if s[i:i+3] == ""ABC"": cnt += 1 print(cnt) if __name__ == ""__main__"": main()" p02812,s374346119,Accepted,"n = input() s = input() ans = 0 for i in range(len(s)-2): if s[i] == ""A"" and s[i+1] == ""B"" and s[i+2] == ""C"": ans+=1 print(ans)" p02812,s692862159,Accepted,"n = int(input()) s = input() cnt = 0 for i in range(n-2): if s[i:i+3] == 'ABC': cnt += 1 print(cnt)" p02812,s346495444,Accepted,"import sys input = sys.stdin.readline class AtCoder: def main(self): N = int(input()) S = input().rstrip() ans = 0 for i in range(N - 2): if str(S[i:i + 3]) == ""ABC"": ans += 1 print(ans) # Run main if __name__ == '__main__': AtCoder().main() " p02812,s694874188,Accepted,"n=int(input()) a=input() ans=0 for i in range(n-2): if a[i]==""A"": if a[i+1]==""B"": if a[i+2]==""C"": ans+=1 print(ans)" p02812,s315869899,Accepted,"N=int(input()) S=input() print(S.count(""ABC"")) " p02812,s939103074,Accepted,"N = int(input()) S = input() count = 0 for i in range(N): if S[i] == ""A"": if i + 2 < N and S[i+1:i+3] == ""BC"" : count += 1 print(count)" p02812,s605167156,Accepted,"N=int(input()) S=input() count=0 for i in range(N): if (S[i:i+3]==""ABC""): count=count+1 print(count)" p02812,s882878893,Accepted,"n = int(input()) s = input() cnt = s.count('ABC') print(cnt)" p02812,s431815892,Accepted,"import re N = int(input()) S = input() print(len(re.findall('ABC', S)))" p02812,s805977594,Accepted,"n = int(input()) s = input() print(s.count(""ABC""))" p02812,s296191292,Accepted,"N = int(input()) S = input() print(sum(1 for i in range(N) if S[i:i+3]==""ABC""))" p02812,s295557517,Accepted,"n = int(input()) s = input() ans = 0 for i in range(n): if s[i:i+3] == ""ABC"": ans += 1 print(ans) " p02812,s161330580,Accepted,"N = int(input()) S = input() print(S.count('ABC')) " p02812,s676587506,Accepted,"N=int(input()) S=input() ans=0 for i in range(len(S)): if S[i:i+3]=='ABC': ans+=1 print(ans)" p02812,s572039110,Accepted,"N = int(input()) S = input() count = S.count('ABC') print(count)" p02812,s782426215,Accepted,"N=input() N=int(N) S=input() count=0 for i in range(N-2): if S[i]==""A"" and S[i+1]==""B"" and S[i+2]==""C"": count=count+1 print(count)" p02812,s983523196,Accepted,"import sys def input(): return sys.stdin.readline().rstrip() def main(): N = int(input()) S = input() print(S.count('ABC')) if __name__ == '__main__': main() " p02812,s322595642,Accepted,"b=input() a=input() print(a.count('ABC')) " p02812,s298972325,Accepted,"def count(s, idx): ac = 0 step = 0 bc = 0 cc = 0 c = 0 while(idx < len(s) and step < 3): if s[idx] == 'A' and bc == 0 and cc == 0: ac = 1 elif s[idx] == 'B' and cc == 0 and ac == 1: bc = 1 elif s[idx] == 'C' and bc == 1 and ac == 1: cc = 1 idx += 1 step += 1 c = ac + bc + cc if c == 3: return 1 return 0 n = int(input()) s = input() summ = 0 for i in range(n): if s[i] == 'A': if count(s, i) == 1: summ += 1 print(summ)" p02812,s390361220,Accepted,"n = int(input()) s = input() print(s.count('ABC'))" p02812,s331370017,Accepted,"N = int(input()) S = input() print(S.count(""ABC""))" p02812,s336602642,Accepted,"n=int(input()) s=input() print(s.count(""ABC"")) " p02812,s489117728,Accepted,"N=int(input()) S=input() print(S.count('ABC'))" p02812,s336748748,Accepted,"N = int(input()) S = input() print(S.count('ABC')) " p02812,s716116660,Accepted,"N=int(input()) S=input() print(S.count('ABC'))" p02812,s365581894,Accepted,"n = int(input()) s = input() print(s.count('ABC'))" p02812,s196341554,Accepted,"import sys inputs = sys.stdin.readlines() n = int(inputs[0]) s = inputs[1].rstrip() p, c = 0, 0 while True: idx = s.find('ABC') if idx == -1: break else: s = s[idx+3:] c += 1 print(c)" p02812,s100704519,Accepted,"N = input() S = input() if (len(S) == int(N)): print(S.count(""ABC"")) " p02812,s672267699,Accepted,"n = int(input()) s = input() print(s.count('ABC'))" p02812,s569963026,Accepted,"n = int(input()) s = input() ts = s.replace('ABC','') lts = len(ts) print((n-lts)//3)" p02812,s304147165,Accepted,"N = input() S = input() print(S.count('ABC'))" p02812,s056856361,Accepted,"a = int(input()) b = input() print(b.count('ABC')) " p02812,s706877746,Accepted,"N = int(input()) S = input().count(""ABC"") print(S)" p02812,s125079699,Accepted,"import sys input = sys.stdin.readline MOD = 10**9 + 7 INF = float('INF') def main(): n = int(input()) s = input() p = 'ABC' ans = 0 for i in range(n-2): for j in range(3): if s[i+j] == p[j]: if j == 2: ans += 1 else: break print(ans) if __name__ == '__main__': main()" p02812,s083710981,Accepted,"N = int(input()) S = input() ans = 0 for i in range(len(S)-2): if S[i:i+3] == 'ABC': ans += 1 print(ans)" p02812,s153148738,Accepted,"N = int(input()) S = input() ans = 0 for i in range(N-2): if S[i:i+3] == 'ABC': ans += 1 print(ans)" p02812,s117241712,Accepted,"[N]=list(map(int, input().split())) S=list(input()) c=0 for i in range (0,N-2): if S[i]==""A"": if S[i+1]==""B"": if S[i+2]==""C"": c=c+1 print(c)" p02812,s127442293,Accepted,"cnt = int(input()) s = input() print(s.count('ABC'))" p02812,s231621574,Accepted,"import sys str = sys.stdin.readlines() n = int(str[0]) str = str[1] cnt = 0 for i in range(n): if str[i:i+3] == ""ABC"": cnt += 1 print(cnt)" p02812,s231657875,Accepted,"n=int(input()) s=input() i=2 ans=0 for i in range(n): if s[i]=='C' and s[i-1]=='B' and s[i-2]=='A': ans=ans+1 print(ans)" p02812,s084960179,Accepted,"n = input() print(input().count(""ABC""))" p02812,s400820387,Accepted,"n = int(input()) S = list(input()) ans = 0 for i in range(len(S)-2): if S[i] == ""A"": if S[i+1] == ""B"": if S[i+2] == ""C"": ans += 1 print(ans)" p02812,s201335348,Accepted,"import re def actual(s): matched = re.findall('ABC', s) return len(matched) n = int(input()) s = input() print(actual(s))" p02812,s160993796,Accepted,"number = int(input()) word = input() answer = word.count('ABC') print(answer)" p02812,s187391396,Accepted,"n = int(input()) s = list(input().split(""ABC"")) print(len(s)-1)" p02812,s519087987,Accepted,"n,w,ans = int(input()),input(),0 for i in range(n-2): if w[i:i+3] == 'ABC' : ans += 1 print(ans)" p02812,s483202510,Accepted,"N=int(input()) S=str(input()) print(S.count('ABC'))" p02812,s062294911,Accepted,"n = int(input()) S=input() c=0 for i in range(n-2): if S[i]==""A"": if S[i+1]==""B"": if S[i+2]==""C"": c+=1 print(c)" p02812,s504812648,Accepted,"input() string = input() count = 0 for i in range(len(string)): if string[i] == 'A': if i < len(string)-2 and string[i+1] == 'B': if string[i+2] == 'C': count += 1 print(count)" p02812,s273162545,Accepted,"n = int(input()) s = input() cnt = 0 for i in range(len(s) - 2): if s[i : i + 3] == ""ABC"": cnt += 1 print(cnt) " p02812,s391162042,Accepted,"N = int(input()) S = input() S = S.replace(""ABC"", """") print(int((N - len(S))/3))" p02812,s078373575,Accepted,"# -*- coding:utf-8 -*- def solve(): N = int(input()) S = input() spl = S.split(""ABC"") print(len(spl)-1) if __name__ == ""__main__"": solve() " p02812,s950739524,Accepted,"n = int(input()) s = input() ans = 0 for i in range(n): if s[i:i+3] == ""ABC"": ans += 1 print(ans)" p02812,s061955549,Accepted,"n = int(input()) s = str(input()) Answer = 0 for val in range(n-2): if s[val] != 'A' : continue elif s[val +1] != 'B' : continue elif s[val +2] != 'C' : continue else : Answer += 1 print(Answer)" p02812,s003660145,Accepted,"N = int(input()) S = input() print(S.count('ABC'))" p02812,s565743691,Accepted,"n = int(input()) s = input() print(s.count(""ABC""))" p02812,s992601385,Accepted,"# -*- coding: utf-8 -*- N = int(input()) S = input() count = 0 for i, s in enumerate(S[:-2]): if s != 'A': continue else: if N >= i + 2 and S[i+1] == 'B' and S[i+2] == 'C': count += 1 print(count)" p02812,s950000120,Accepted,"def readinput(): n=int(input()) s=input() return n,s def main(n,s): i=0 count=0 while(i=3: if S[i-3:i]==""ABC"": answer+=1 print(answer)" p02812,s065606132,Wrong Answer,"# ABC150B - Count ABC def main(): N = int(input()) S = input().rstrip() ans = sum(S[i:i + 3] == ""ABC"" for i in range(N - 3)) print(ans) if __name__ == ""__main__"": main() " p02812,s143919314,Wrong Answer,"import sys row = sys.stdin.readline def read_int(row): return int(row().rstrip()) def read_string(row): return row().rstrip() N = read_int(row) S = read_string(row) cnt = 0 for i in range(0, len(S) -3): if S[i] == ""A"" and S[i+1] == ""B"" and S[i+2] == ""C"": cnt +=1 print(cnt)" p02812,s183867747,Wrong Answer,"n = int(input()) s = input() count = 0 for i in range(n-3): if s[i:i+3] == ""ABC"": count += 1 print(count)" p02812,s585711182,Wrong Answer,"n = int(input()) s = input() ans = 0 for i in range(n-3): if s[i:i+3] == ""ABC"": ans += 1 print(ans)" p02812,s825944673,Wrong Answer,"N = int(input()) S = list(input()) count=0 for i in range(N-3): if S[i]=='A' and S[i+1]=='B' and S[i+2]=='C': count+=1 print(count) " p02812,s983158656,Wrong Answer,"print(input().count(""ABC""))" p02812,s873187063,Wrong Answer,"n = int(input()) s = input() abc = 'ABC' cnt = 0 for i in range(n-3): if s[i:i+3] == abc: cnt += 1 print(cnt)" p02812,s019982392,Wrong Answer,"input() s = input() l = len(s) s.replace('ABC', '') l2 = len(s) print(l-l2 // 3)" p02812,s780428403,Wrong Answer,"import sys def main(): N = int(input()) S = input() cnt = 0 for i in range(N-2): s = str(S[i:i+2]) if s=='ABC': cnt += 1 print(cnt) main()" p02812,s540140915,Wrong Answer,"n=int(input()) s=input() c=0 for i in range(n-3): if s[i:i+3]==""ABC"": c+=1 print(c)" p02812,s754285919,Wrong Answer,"N = int(input()) S = input() ans = 0 for i in range(N-2): if S[i] == ""A"" and S[i+1] == ""B"" and S[i+2] == ""C"": ans = ans + 1 " p02812,s379590997,Wrong Answer,"a = int(input()) s = input() cnt = 0 i = 0 while i < a: if s[i:i+3] == 'ABC': cnt += 1 i += 3 i += 1 print(cnt)" p02812,s771691104,Wrong Answer,"def main(): sum = 0 order = 0 n = input() inp = input() for c in inp: if ord(c) == ord('A') + order: if order == 2: sum += 1 order = 0 else: order += 1 print(sum) if __name__ == '__main__': main()" p02812,s487854401,Wrong Answer,"n = int(input()) s = input() count = 0 for i in range(n - 3): if s[i:i+3] == ""ABC"": count += 1 print(count) " p02812,s485085942,Wrong Answer,"n=int(input()) s=input() j=0 count=0 for i in range(n): u=s[i:i+1] #print(u) if j==0 and u==""A"": j=1 elif j==0 and u!=""A"": j=0 elif j==1 and u==""B"": j=2 elif j==1 and u!=""B"": j=0 elif j==2 and u==""C"": j=3 count+=1 elif j==2 and u!=""C"": j=0 print(count)" p02812,s875219250,Wrong Answer,"#B N = int(input()) S = list(str(input())) flag = 0 ans = 0 for i in range(N): if flag == 0: if S[i] == ""A"": flag+=1 elif flag == 1: if S[i] == ""B"": flag+=1 else: flag = 0 elif flag == 2: if S[i] == ""C"": ans+=1 flag = 0 print(ans)" p02812,s233424765,Wrong Answer,"n=int(input()) s=list(input()) count=0 for i in range(n-3): if s[i]==""A"" and s[i+1]==""B"" and s[i+2]==""C"": count+=1 print(count) " p02812,s879414988,Wrong Answer,"n = int(input()) s = input() count = 0 for i in range(n-2): print(s[i:i+3]) if s[i:i+3] == 'ABC': count += 1 print(count)" p02812,s521836046,Wrong Answer,"#!/usr/bin/env python def main(): S = input() ans = 0 for i in range(len(S) - 2): if S[i: i+3] == ""ABC"": ans += 1 print(ans) if __name__ == '__main__': main() " p02812,s067251406,Wrong Answer,"n=int(input()) s=input() print(sum(s[i:i+3]==""ABC"" for i in range(n-3)))" p02812,s742996864,Wrong Answer,"n = int(input()) s = str(input()) ans = 0 for i in range(len(s) - 3): if s[i:i+3] == ""ABC"": ans += 1 print(ans)" p02812,s893408090,Wrong Answer,"N = int(input()) S = list(input()) count = 0 for i in range(1,N-2): if S[i] == ""A"": if S[i+1] == ""B"": if S[i+2] == ""C"": count += 1 print(count)" p02812,s849098767,Wrong Answer,"import re n = int(input()) s = input() abc = re.compile('ABC') count = abc.findall(s) print(count)" p02812,s136687382,Wrong Answer,"n=int(input()) s=str(input()) count=0 for i in range(0, n-3): if s[i:i+3]==""ABC"": count+=1 print(count)" p02812,s934480112,Wrong Answer,"N = int(input()) S = input() answer = 0 for i in range(3,N): if S[i-3:i] == ""ABC"": answer += 1 print(answer)" p02812,s169011472,Wrong Answer,"n = int(input()) s = input() c = 0 for i in range(n): if s[i:i+2] == ""ABC"": c += 1 print(c)" p02812,s143072269,Wrong Answer,"n = int(input()) s = input() count = 0 for i in range(len(s)-3): if s[i:i+3] == 'ABC': count += 1 print(count)" p02812,s360718871,Wrong Answer,"n=int(input()) s=input() ans=0 if n==3: if s[0:3]==""ABC"": print(1) else: print(0) else: for i in range(n-3): if s[i:i+3]==""ABC"": ans+=1 print(ans) " p02812,s004750221,Wrong Answer,"N = int(input()) S = input() new_S = S.replace(""ABC"", ""@"") print(new_S) print(new_S.count(""@"")) " p02812,s316105291,Wrong Answer,"N=int(input()) S=input() k=0 for i in range(N-3): a=S[i]+S[i+1]+S[i+2] if a==""ABC"": k+=1 print(k) " p02812,s701518255,Wrong Answer,"N=int(input()) S=input() count=0 for i in range(N-3): if S[i:i+3]==""ABC"": count+=1 print(count) " p02812,s125070959,Wrong Answer,"n = int(input()) s = input() cnt = 0 if n == 3: if s == 'ABC': cnt +=1 else: for i in range(0,n-3): if s[i:i+3]=='ABC': cnt +=1 print(cnt)" p02812,s811818995,Wrong Answer,"N=int(input()) s=str(input()) ans=1 if 'ABC' in s: ans=ans+1 print(ans)" p02812,s052375912,Wrong Answer,"N = int(input()) S = input() count=0 flag =0 if N>=3 and N<=50: if len(S) == N: for i in S: if i == 'A' and count == 0: count+=1 elif i == 'B' and count == 1: count+=1 elif i == 'C' and count == 2: flag+=1 count=0 else: count=0 print(flag) " p02812,s034040903,Wrong Answer,"N = int(input()) S = str(input()) c = 0 for i in range(N-3): if S[i] == ""A"": if S[i+1] == ""B"" and S[i+2] == ""C"": c += 1 print(c)" p02812,s177471545,Wrong Answer,"n = int(input()) s = input() ans = 0 for i in range(0,n-3): if s[i] == ""A"" and s[i+1] == ""B"" and s[i+2] == ""C"": ans += 1 print(ans)" p02812,s916641864,Wrong Answer,"_ = input() s = input() check = ['A', 'B', 'C'] count = 0 state = 0 for i in range(len(s)): c = s[i] if c != check[state]: state = 0 if c != check[state]: state = 1 continue state += 1 if state == 3: count += 1 state = 0 print(count) " p02812,s075938270,Wrong Answer,"n = int(input()) s = input() print(s.count('abc'))" p02812,s863636913,Wrong Answer,"N = int(input()) S = input() cnt = 0 ans = 0 print(S) for i in S: if S[cnt:cnt+3] == ""ABC"": ans += 1 cnt += 1 if cnt == (N - 3): break print(ans)" p02812,s428297332,Wrong Answer,"n=int(input()) s=input() l=[] count=0 for i in s: if i=='A': l.append('A') elif i=='B' and l==['A']: l.append('B') elif i=='C' and l==['A','B']: l=[] count+=1 else: l=[] print(count)" p02812,s117499231,Wrong Answer,"n=input() s=input() print(s.count('abc'))" p02812,s356236844,Wrong Answer,"def main(N,S): N = int(N) S = str(S) c = 0 for i in range(N-3): if S[i:i+2] == 'ABC': c += 1 return c if __name__ == '__main__': N = input() S = input() print(main(N,S)) " p02812,s070798574,Wrong Answer,"N=int(input()) S=input() count=0 for n in range(N-3): s=S[n:n+3] if s=='ABC': count+=1 print(count) " p02812,s309499633,Wrong Answer,"n = int(input()) s = input() ans = 0 for i in range(n-2): print(s[i:i+3]) if s[i:i+3] == 'ABC': ans += 1 print(ans)" p02812,s322727619,Wrong Answer,"print(input().count(""ABC""))" p02812,s541757628,Wrong Answer,"n = int(input()) s = input() count = 0 for i in range(n-3): if s[i:i+3] == ""ABC"": count += 1 print(count)" p02812,s770939617,Wrong Answer,"n=int(input()) s=input() ans=0 for i in range(n-3): if s[i:i+3] == ""ABC"": ans+=1 print(ans)" p02812,s587800013,Wrong Answer,"n = int(input()) s = input() cnt = 0 for i in range(0, n-3): if s[i:i+3] == 'ABC': cnt += 1 print(cnt)" p02812,s435670427,Wrong Answer,"def main(N,S): N = int(N) S = str(S) c = 0 for i in range(N-3): if S[i] == 'A' and S[i+1] == ""B"" and S[i+2]=='C': c += 1 return c if __name__ == '__main__': N = input() S = input() main(N,S) " p02812,s439199093,Wrong Answer,"def main(): n=int(input()) s=input() print(sum(1 for i in range(n-3) if s[i:i+3] == 'ABC')) main()" p02812,s192039811,Wrong Answer,"s = input() ans = s.count(""ABC"") print(ans)" p02812,s625722903,Wrong Answer,"n = int(input()) s = list(str(input())) ans=0 for i in range(len(s) - 3): if s[i] == 'A': if s[i + 1] == 'B': if s[i + 2] == 'C': ans+=1 print(ans)" p02812,s223726573,Wrong Answer,"N = int(input()) S = input() t = 0 for i in range(N-3): if S[i:i+3] == ""ABC"": t += 1 print(t)" p02812,s431387813,Wrong Answer,"input() s = input() i = s.find('ABC') n = 0 while i != -1: i = s.find('ABC') s = s[i + 3:] print(n) " p02812,s280435415,Wrong Answer,"n = int(input()) s = input() count = 0 for i in range(0, n-3): if s[i : i + 3] == 'ABC': count += 1 print(count) " p02812,s468039965,Wrong Answer,"n = int(input()) s = str(input()) cnt = 0 for i in range(n-3): if s[i:i+3] == ""ABC"": cnt += 1 print(cnt)" p02812,s649022136,Wrong Answer,"N = int(input()) S = input() S = S.split('C') cut = 0 for s in S: s = s + 'C' if ""ABC"" in s: cut += 1 print(cut)" p02812,s870843063,Wrong Answer,"print(input().count(""ABC""))" p02812,s821678947,Wrong Answer,"input() s = input() l = len(s) s.replace('ABC', '') l2 = len(s) print((l-l2) // 3)" p02812,s595082507,Wrong Answer,"n=int(input()) s=input() s.replace('ABC','a2c') print(s.count('a2c'))" p02812,s046730536,Wrong Answer,"n = int(input()) s = input() c=0 for i in range(n - 3): if s[i:i + 3] == 'ABC': c += 1 print(c)" p02812,s926792743,Wrong Answer,"N = int(input()) S = input() ret = 0 cursor = 0 for s in S: if cursor == 0: if s == 'A': cursor = 1 elif cursor == 1: if s == 'B': cursor = 2 else: cursor = 0 else: if s == 'C': ret += 1 cursor = 0 else: cursor = 0 print(ret)" p02812,s679800357,Wrong Answer,"N = int(input()) S = str(input()) import math ans = 0 for i in range(math.ceil(len(S)/3)): print(S[i:i+3]) if S[i:i+3] == ""ABC"": ans += 1 else: pass print(ans)" p02812,s897103537,Wrong Answer,"#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3 n = int(input()) s = input() x = 1 ans = 0 for i in range(len(s)): if x == 1: if s[i] == 'A': x = 2 elif x == 2: if s[i] == 'B': x = 3 else: x = 1 elif x == 3: if s[i] == 'C': x = 1 ans += 1 else: x = 1 print(ans) " p02812,s227294618,Wrong Answer,"s=input() print(s.count('abc'))" p02812,s420711816,Wrong Answer,"N = int(input()) S = input() count = 0 for i in range(N-3): if S[i:i+3] == 'ABC': count += 1 print(count)" p02812,s093127003,Wrong Answer,"n=int(input()) s=input() cnt=0 for i in range(1,n-2): if s[i-1:i+2]=='ABC': cnt+=1 print(cnt)" p02812,s176562450,Wrong Answer,"n = int(input()) s = input() ans = 0 for i in s: if i == ""ABS"": ans += 1 print(ans)" p02812,s579344210,Wrong Answer,"n = int(input()) s = input() print(s.find('ABC'))" p02812,s416445819,Wrong Answer,"N = int(input()) S = input() S.count('ABC')" p02812,s138222344,Wrong Answer,"n = int(input()) s = input() ans = 0 for i in range(n - 2): if s[i:i + 3] == ""ABC"": ++ans print(ans) " p02812,s640966799,Wrong Answer,"N = input() # Do Not use S = input() print(S.find(""ABC""))" p02812,s613283893,Wrong Answer,"n=int(input()) s=input() j=0 count=0 for i in range(n): u=s[i:i+1] #print(u) if j==0 and u==""A"": j=1 elif j==0 and u!=""A"": j=0 elif j==1 and u==""B"": j=2 elif j==1 and u!=""B"": j=0 elif j==2 and u==""C"": j=0 count+=1 elif j==2 and u!=""C"": j=0 print(count) " p02812,s618793539,Wrong Answer,"n = int(input()) s = str(input()) cnt = 0 for i in range(n-3): if s[i] == ""A"": if s[i+1] == ""B"": if s[i+2] == ""C"": cnt += 1 print(cnt)" p02812,s519420441,Wrong Answer,"N = int(input()) S = input() ans = 0 for i in range(N-3): if S[i:i+3] == 'ABC': ans += 1 print(ans)" p02812,s198011229,Wrong Answer,"N = int(input()) S = input() cnt = 0 for i in range(N-3): if S[i:i+3] == ""ABC"": cnt +=1 print(cnt)" p02812,s007822372,Wrong Answer,"n = int(input()) s = list(str(input())) ans = s.count('ABC') print(ans)" p02812,s309635680,Wrong Answer,"s = str(input()) print(s.count(""ABC""))" p02812,s794823890,Wrong Answer,"# 初期入力 N =int(input()) S = input() ABC_count = 0 for i in range(N-3): if S[i:i+3] ==""ABC"": ABC_count += 1 print(ABC_count)" p02812,s225478132,Wrong Answer,"num = int(input()) word = input() if len(word) >= num: print(word[0:num].count('ABC')) print(0) " p02812,s740594220,Wrong Answer,"n=input() s=raw_input().strip() ans=0 for i in xrange(n-2): if s[i:i+2]=='ABC': ans+=1 print ans" p02812,s454598318,Wrong Answer,"n = int(input()); s = input() ; c = 0 for i in range(n): a = s[i-3:i] if a == 'ABC': c += 1 print(c)" p02812,s809340303,Wrong Answer,"input = input() result = 0 for i in range(len(input) - 2): serach = input[i:i+3] if serach == ""ABC"": result += 1 print(result)" p02812,s340148514,Wrong Answer,"n = int(input()) s = input() cnt = 0 for i in range(n - 3): if s[i:i + 3] == 'ABC': cnt += 1 print(cnt) " p02812,s984376389,Wrong Answer,"N = int(input()) S = input() i = 0 ans = 0 for i in range(N-3): if S[i] == ""A"" and S[i + 1] == ""B"" and S[i+2] == ""C"": ans += 1 print(ans)" p02812,s036939156,Wrong Answer,"import numpy as np def main(): N = int(input()) S = input() flag = 0 ans = 0 for s in S: if (s == ""A"") & (flag == 0): flag = 1 elif (s == ""B"") & (flag == 1): flag = 2 elif (s == ""C"") & (flag == 2): flag = 3 ans += 1 else: flag = 0 print(ans) return 0 if __name__ == '__main__': main()" p02812,s240954337,Wrong Answer,"def solve(): n = int(input()) s = input() state = 0 count = 0 for c in s: if c == 'A': state += 1 continue elif state == 1 and c == 'B': state += 1 continue elif state == 2 and c == 'C': count += 1 state = 0 print(count) if __name__ == '__main__': solve() " p02812,s736969062,Wrong Answer,"n = int(input()) s = input() print(s.count(""abc""))" p02812,s278817443,Wrong Answer,"n = int(input()) s = input() ans = 0 for i in range(len(s)-3): if s[i:i+3] == ""ABC"": ans+=1 print(ans)" p02812,s222572748,Wrong Answer,"N=int(input()) S=input() ans=0 for i in range(N-3): if ""ABC""==S[i:i+3]: ans+=1 print(ans)" p02812,s636151235,Wrong Answer,"s1=input() count=0 for i in range ((len(s1))-2): if(s1[i]=='A' and s1[i+1]=='B' and s1[i+2]=='C'): count=count+1 print(count) " p02812,s385877419,Wrong Answer,"N = int(input()) S = input() count = 0 for i in range(N-3): if S[i:i + 3] == ""ABC"": count = count + 1 print(count)" p02812,s479864169,Wrong Answer,"N = int(input()) S = input() S = S.split('C') cut = 0 for s in S: s = s + 'C' if ""ABC"" in s: cut += 1 print(cut)" p02812,s108983576,Wrong Answer,"N = int(input()) S = str(input()) p = ""abc"" print(S.count(""abc"")) " p02812,s402522052,Wrong Answer,"N = int(input()) S = input() count = 0 hit = 0 for s in S: if s == 'A' and hit == 0: hit += 1 elif s == 'B' and hit == 1: hit += 1 elif s == 'C' and hit == 2: count += 1 hit = 0 else: hit = 0 print(count)" p02812,s337192902,Wrong Answer,"N = int(input()) S = input() c = 0 for i in range(N-2): S[i] + S[i+1] + S[i+2] == 'ABC' c += 1 print(c) " p02812,s370319437,Wrong Answer,"n = input() s = input() prev = """" cnt = 0 flag = False for i in s: if flag: if i == ""C"" and prev == ""B"": cnt += 1 flag = False elif i == ""A"": flag = True prev = i print(cnt)" p02812,s706628055,Wrong Answer,"Input = int(input()) N = Input Input =str(input()) ar = list(Input) chk = 0 cnt = 0 for i in range(N): if chk == 0: if ar[i]=='A': chk+=1 elif chk == 1: if ar[i]=='B': chk+=1 elif chk == 2: if ar[i]=='C': chk=0 cnt+=1 print(cnt)" p02812,s859329451,Wrong Answer,"import sys def input(): return sys.stdin.readline().strip() def resolve(): n=int(input()) s=input() cnt=0 for i in range(n-3): if s[i:i+3]=='ABC': cnt+=1 print(cnt) resolve()" p02812,s376854874,Wrong Answer,"n =int(input()) s =list(input()) k =0 for i in range(n-3): if s[i]==""A"": if s[i+1]==""B"" and s[i+2]==""C"": k+=1 print(k)" p02812,s322783068,Wrong Answer,"n = int(input()) s = input() x = list(s) y = 0 a = 0 while y <= n - 3: z = x[y] + x[y + 1] + x[y + 2] if z == ""abc"": a += 1 y += 1 else: a += 0 y += 1 print(a) " p02812,s236885895,Wrong Answer,"n = int(input()) s = input() c = 0 for i in range(n-1): if s[i]==""a"" and s[i+1]==""b"" and s[i+2]==""c"": c += 1 print(c) " p02812,s526462837,Wrong Answer,"S = input() print(S.count('ABC'))" p02812,s393493075,Wrong Answer,"N = input() S = input() c = 0 s = 0 for k in S: if s == 0 and k == ""A"": s = 1 elif s == 1 and k == ""B"": s = 2 elif s == 2 and k == ""C"": c += 1 s = 0 else: s = 0 print(c)" p02812,s327388509,Wrong Answer,"s = input() N = len(s) ans = 0 if N < 3:print(0);exit() i = 0 while i < N-3: if s[i:i+3] == 'ABC':ans += 1;i += 3 else:i+=1 print(ans) " p02812,s870686307,Wrong Answer,"N = int(input()) s = input() print(s.count(""abc""))" p02812,s436726739,Wrong Answer,"N = input() S = input() count = 0 s = ""_"" for i in range(len(S)): if(S[i]==""A"" and s==""_""): s = ""A"" if(s==""A"" and S[i]==""B""): s = ""B"" if(s==""B"" and S[i]==""C""): s = ""_"" count += 1 print(count)" p02812,s041528688,Wrong Answer,"N=int(input()) S=input() nabc=0 for i in range(0,N-2): if S[i:i+2]=='ABC': nabc+=1 print(nabc)" p02812,s229170302,Wrong Answer,"n = int(input()) s = input() query = 'ABC' ans = 0 i = 0 while i=0: ans +=1 i+=1 else: break print(ans) " p02812,s691747573,Wrong Answer,"N=int(input()) S=input() ANS=0 for i in range(N-3): if S[i:i+3] == ""ABC"": ANS+=1 print(ANS)" p02812,s042141020,Wrong Answer,"n = int(input()) S = input() A = 0 for i in range(n-3): clipped_S = S[i:i+3] if clipped_S == ""ABC"": A += 1 print(A)" p02812,s242938954,Wrong Answer,"N = int(input()) S = input() ans = 0 for i in range(N - 2): if S[i] == ""A"" and [i + 1] == ""B"" and S[i + 2] == ""C"": ans += 1 print(ans)" p02812,s982456899,Wrong Answer,"N = int(input()) s = input() ans = 0 if N < 3:print(0);exit() for i in range(N-3): if s[i:i+3] == 'ABC':ans += 1 print(ans) " p02812,s247384720,Wrong Answer,"n = int(input()) s = input() count = 0 for i in range(n-3): if s[i]==""A"" and s[i+1]==""B"" and s[i+2]==""C"": count+=1 print(count)" p02812,s563321867,Wrong Answer,"n = int(input()) s = input() ans = 0 for i in range(n - 3): if s[i:i+3] == 'ABC': ans += 1 print(ans) " p02812,s307851961,Wrong Answer,"txt = input().split(""A"") n = 0 for cnt in txt: if cnt == ""ABC"": n += 1 print(n)" p02812,s221735287,Wrong Answer,"n = int(input()) s = input() ans = 0 for i in range(n-3): if s[i]==""A"": if s[i+1]==""B"": if s[i+2]==""C"": ans += 1 print(ans)" p02812,s983278130,Wrong Answer,"n = int(input()) s = input() a = s.replace('ABC','1') b = n - len(a) print(b/2) " p02812,s560874565,Wrong Answer,"N = int(input()) S = str(input()) count = 0 if len(S) <= 2: print('0') exit(0) elif len(S) == 3: if 'ABC' in S: print('1') exit(0) else: for i in range(len(S)-3): if 'ABC' in S[i:i+3]: count += 1 print(count)" p02812,s523717285,Wrong Answer,"n = int(input()) s = input() ans = 0 for i in range(n-2): if s[i:i+2] == 'ABC': ans += 1 print(ans)" p02812,s395351939,Wrong Answer,"def resolve(): _, S = [input() for i in range(2)] print(S.count('abc')) if __name__ == ""__main__"": resolve()" p02812,s115785353,Wrong Answer,"def main(): sum = 0 order = 0 n = input() inp = input() for c in inp: if ord(c) == ord('A') + order: if order == 2: sum += 1 order = 0 else: order += 1 else: order = 0 print(sum) if __name__ == '__main__': main()" p02812,s778741859,Wrong Answer,"N = int(input()) S = input() tmp_c = 0 count = 0 for i in range(N): if tmp_c == 0 and S[i]==""A"": tmp_c = tmp_c + 1 elif tmp_c == 1 and S[i]==""B"": tmp_c = tmp_c + 1 elif tmp_c == 1: tmp_c = 0 elif tmp_c == 2 and S[i]==""C"": count = count + 1 tmp_c = 0 elif tmp_c == 2: tmp_c = 0 print(count) " p02812,s026079294,Wrong Answer,"n = int(input()) s = input() ans = 0 for i in range(n-3): temp = s[i:i+3] if(temp == 'ABC'): ans += 1 print(ans)" p02812,s334995060,Wrong Answer,"l=input() cnt=0 for i in range(len(l)-2): if l[i]+l[i+1]+l[i+2]==""ABC"": cnt+=1 print(cnt)" p02812,s743316966,Wrong Answer,"N = int(input(""Enter N: "")) S = input(""Enter S: "") print(len(S.split(""ABC""))-1)" p02812,s452274304,Wrong Answer,"n=int(input()) count=0 s=input() for i in s: if i==""ABC"": count+=1 print(count)" p02812,s482224252,Wrong Answer,"import collections n = int(raw_input()) s = map(lambda x:ord(x) - ord('a'.upper()),list(raw_input())) count,c = 0,0 for i in s: if i == c: c +=1 else: c = 0 if c == 2: count +=1 c = 0 print count " p02812,s495110358,Wrong Answer,"N = int(input()) S = input() cnt = 0 for i in range(N): print(S[i:i+3]) if S[i:i+3] == 'ABC': cnt += 1 print(cnt)" p02812,s403140009,Wrong Answer,"n = int(input()) s = input() ans = 0 for i in range(n-1): for j in range(i+1, n): if s[i:j] == 'ABC': ans += 1 print(ans) " p02812,s705227201,Wrong Answer,"N=int(input()) s=input() cnt=0 for i in range(0,N-3): if s[i]+s[i+1]+s[i+2]==""abc"": cnt+=1 print(cnt)" p02812,s400153998,Wrong Answer,"#!/usr/bin/env python3 import sys INF = float(""inf"") def solve(N: int, S: str): count = 0 for i in range(N-3): if S[i:i+3] == ""ABC"": count += 1 print(count) return 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 S = next(tokens) # type: str solve(N, S) if __name__ == '__main__': main() " p02812,s216849680,Wrong Answer,"n=int(input()) S=input() L='' ans=0 for s in S: if s=='A' and L=='': L += s elif s=='B' and L=='A': L += s elif s=='C' and L=='AB': ans += 1 L='' else: L='' print(ans)" p02812,s646587073,Wrong Answer,"n = int(input()) S = list(input()) print(n,S)" p02812,s752815321,Wrong Answer,"N = int(input()) S = input() stackString = """" resultCount = 0 for s in S: if stackString == """" and s == ""A"": stackString += ""a"" elif stackString == ""a"" and s == ""B"": stackString += ""b"" elif stackString == ""ab"" and s == ""C"": stackString = """" resultCount += 1 else: stackString = """" print(resultCount)" p02812,s373090908,Wrong Answer,"n = int(input()) s = input() cnt = 0 tmp = """" for elem in s: if ""A"" == elem: tmp += elem elif ""B"" == elem and tmp != """": if tmp[-1] == ""A"": tmp += elem elif ""C"" == elem and tmp != """": if tmp[-1] == ""B"": cnt += 1 tmp = """" print(cnt)" p02812,s356399507,Wrong Answer,"N = int(input()) S = input() count=0 flag =0 if N>=3 and N<=50: if len(S) == N: for i in S: if i == 'A': count+=1 elif i == 'B' and count == 1: count+=1 elif i == 'C' and count == 2: flag+=1 count=0 else: count=0 print(flag) " p02812,s017181944,Wrong Answer,"n=int(input()) s=input() count=0 if n==3: if s==""ABC"": count=1 else: s=list(s) for i in range(n-3): if s[i]==""A"" and s[i+1]==""B"" and s[i+2]==""C"": count+=1 print(count) " p02812,s158738125,Wrong Answer,print(input().count('ABC')) p02812,s819086597,Wrong Answer,"N = int(input()) S = input() cnt = 0 ans = 0 for i in S: if S[cnt:cnt+3] == ""ABC"": ans += 1 cnt += 1 if cnt == (N - 3): break print(ans)" p02812,s998173897,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() s = S() # print(s.count('ABC')) ans = 0 for i in range(len(s)-3): if s[i] == 'A' and s[i+1] == 'B' and s[i+2] == 'C': ans += 1 print(ans) " p02812,s167341798,Wrong Answer,"n = int(input()); s = input() ; c = 0 for i in range(n): a = s[i-3:i] print(a) if a == 'ABC': c += 1 print(c)" p02812,s212277920,Wrong Answer,"def main(N,S): N = int(N) S = str(S) c = 0 for i in range(N-3): if S[i:i+2] == 'ABC': c = c + 1 return c if __name__ == '__main__': N = input() S = input() print(main(N,S)) " p02812,s376390616,Wrong Answer,"n = int(input()) s = input() count = 0 for i in range(n-2): print(s[i:i+3]) if s[i:i+3] == ""ABC"": count += 1 print(count) " p02812,s388680195,Wrong Answer,"_ = input() s = input() check = ['A', 'B', 'C'] count = 0 state = 0 for i in range(len(s)): c = s[i] if c != check[state]: state = 0 continue state += 1 if state == 3: count += 1 state = 0 print(count)" p02812,s381008201,Wrong Answer,"def main(N,S): N = int(N) S = str(S) c = 0 for i in range(N-3): if S[i:i+2] == 'ABC': c += 1 return c if __name__ == '__main__': N = input() S = input() main(N,S) " p02812,s632436523,Wrong Answer,"n = int(input()) s = str(input()) k = s*n print(k.count('ABC'))" p02812,s654127621,Wrong Answer,"n = int(input()) li = input().split() cnt = 0 for i in range(len(li) - 3): if li[i] == ""A"" and li[i+1] == ""B"" and li[i+2] == ""C"": cnt += 1 else: pass print(cnt)" p02812,s862406352,Wrong Answer,"from sys import stdin a = stdin.readline().rstrip() b = stdin.readline().rstrip() c = 0 cnt = 0 abc = ['A','B','C'] for i in b: if i == abc[c]: c += 1 if c ==3: c = 0 cnt += 1 else: c = 0 print(cnt) " p02812,s720986919,Wrong Answer,"N = int(input()) S = input() length = len(S) num = 0 print(length) for i in range(length-2) : if S[i:i+3] == ""ABC"" : num += 1 print(num)" p02812,s423967352,Wrong Answer,"def main(N,S): N = int(N) S = str(S) c = 0 for i in range(N-3): if S[i:i+2] == 'ABC': c += 1 return c if __name__ == '__main__': N = input() S = input() main(N,S) " p02812,s737271741,Wrong Answer,"n = int(input()) s = input() cnt = 0 flag = 0 for i in range(n): if s[i] == ""A"": flag = 1 elif s[i] == ""B"" and flag == 1: flag = 2 elif s[i] == ""C"" and flag == 2: cnt += 1 flag = 0 print(cnt)" p02812,s149034260,Wrong Answer,"N = int(input()) S = input() count = 0 for i in range(0,N-3): if S[i]=='A': if S[i+1]=='B': if S[i+2]=='C': count += 1 print(count)" p02812,s375254795,Wrong Answer,"N = int(input()) S = input() K = 'ABC' idx = 0 cnt = 0 for i in S: if i == K[idx]: if idx == 2: cnt += 1 idx = 0 else: idx += 1 else: idx = 0 print(cnt)" p02812,s857370606,Wrong Answer,"N = int(input()) S = input() ans = 0 for i in range(N-3): if S[i:i+3] == 'ABC': ans += 1 print(ans) " p02812,s936537751,Wrong Answer,"n=int(input()) s=input() ans=0 for i in range(n-3): if s[i:i+3]=='ABC': ans+=1 print(ans)" p02812,s051310395,Wrong Answer,"n=int(input()) s=str(input()) count=0 for i in range(n-3): if s[i:i+3] =='ABC': count+=1 print(count) " p02812,s845741940,Wrong Answer,"n = int(input()) s = input() ans = 0 for i in range(n-3): if s[i:i+3] == 'ABC': ans += 1 print(ans)" p02812,s372288997,Wrong Answer,"n = int(input()) s = input() ans = 0 for i in range(n - 3): if s[i:i + 3] == ""ABC"": ans += 1 print(ans)" p02812,s354493225,Wrong Answer,"n=int(input()) s=input() c=0 for i in range(n-3): if s[i:i+3]==""ABC"": c+=1 print(c)" p02812,s108841751,Wrong Answer,"s = input() print(s.count('ABC'))" p02812,s412251427,Wrong Answer,"def main(): N = int(input()) S = str(input()) print (S) if 'ABC' in S : C = S.split('ABC') #print (C) print (len(C)-1) if __name__ == '__main__': main()" p02812,s532428509,Wrong Answer,"moji = str(input()) print(moji.count(""ABC""))" p02812,s078140677,Wrong Answer,"n = int(input()) s = input() pattern = list('ABC') cnt = 0 match = True for i in range(n-len(pattern)): if (s[i] == pattern[0]) and (s[i+ 1] == pattern[1]) and (s[i+ 2] == pattern[2]): cnt += 1 print(cnt)" p02812,s818562090,Wrong Answer,"n = int(input()) s = input() cnt = 0 for i in range(n - 3): if s[i:i+3] == ""ABC"": cnt += 1 print(cnt)" p02812,s678849077,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,heapify from math import ceil, floor, sqrt from copy import deepcopy def main(): count = 0 num = int(input()) strings = input() print(len(strings)) for i in range(0,num-2,1): if strings[i] == ""A"" and strings[i+1] == ""B"" and strings[i+2] == ""C"": count += 1 print(count) if __name__ == '__main__': main() " p02812,s334646040,Wrong Answer,"N=int(input()) S=str(input()) count=0 for i in range(N-3): if S[i]+S[i+1]+S[i+2]=='ABC': count+=1 print(count)" p02812,s313888955,Wrong Answer,"a = [input() for i in range(2)] a[0] = int(a[0]) print(int(a[1].find(""ABC"")))" p02812,s499327441,Wrong Answer,"N = int(input()) S = input() ans = 0 if N > 3: for i in range(N-3): if S[i:i+3] == ""ABC"": ans += 1 else: ans = 1 if S == ""ABC"" else 0 print(ans)" p02812,s533058878,Wrong Answer,"s=input() print(s.count('ABC'))" p02812,s837210628,Wrong Answer,"N=int(input()) S=input() count=0 count_abc=0 for i in range(len(S)): if count_abc==0 and S[i]=='A': count_abc+=1 elif count_abc==1 and S[i]=='B': count_abc+=1 elif count_abc==2 and S[i]=='C': count_abc=0 count+=1 else: count_abc=0 print(count)" p02812,s545526540,Wrong Answer,"def main(): N = int(input()) S = str(input()) l = 0 ans = 0 for i in range(N): if S[i] == 'A': l += 1 elif S[i] == 'B' and l == 1: l += 1 elif S[i] == 'C' and l == 2: ans += 1 l = 0 else: l = 0 print(ans) main()" p02812,s684704935,Wrong Answer,"S = input() print(S.count(""ABC""))" p02812,s071708730,Wrong Answer,"N=int(input()) S=input() ans=0 for i in range(N-3): if S[i:i+3]=='ABC': ans+=1 print(ans)" p02812,s161032179,Wrong Answer,"N = input() S = input(""Enter String"") count = 0 for i in range(1, int(N)-1): if S[i-1]+S[i]+S[i+1] == ""ABC"": count += 1 print(count)" p02812,s083381756,Wrong Answer,"n=int(input()) t=input() ans=0 tmp="""" for i in t: if i==""A"": if tmp=="""": tmp+=""A"" else: tmp="""" elif i==""B"": if tmp==""A"": tmp+=""B"" else: tmp="""" elif i==""C"": if tmp==""AB"": ans+=1 tmp="""" else: tmp="""" else: tmp="""" print(ans)" p02812,s017238743,Wrong Answer,"n = int(input()) s = input() c=0 for i in range(n - 2): print(s[i:i + 3]) if s[i:i + 3] == 'ABC': c += 1 print(c)" p02812,s917311261,Wrong Answer,"_ = input() S = input() newS = S.replace(""ABC"", """") print(S, newS) print((len(S) - len(newS)) // 3)" p02812,s115823758,Wrong Answer,"string = input() print(string.count(""ABC"")) " p02812,s258516804,Wrong Answer,"N = int(input()) S = input() cnt = 0 for i in range(N - 3): if S[i:i + 3] == ""ABC"": cnt += 1 print(cnt)" p02812,s870304533,Wrong Answer,"n=int(input()) s=str(input()) ans=0 for i in range(n): if s[i:i+3] ==""abc"": ans +=1 else: ans +=0 print(ans) " p02812,s872174769,Wrong Answer,"n = input() inp = input() sum = 0 order = 0 for c in inp: if ord(c) == ord('A'): order = 1 elif ord(c) == ord('A') + order: order = (order + 1) % 3 sum += max(0, order - 1) else: order = 0 print(sum)" p02812,s044054708,Wrong Answer,"n=int(input()) s=input() s.split('ABC') print(len(s)-1)" p02812,s319052992,Wrong Answer,"print(input().count(""ABC""))" p02812,s349137579,Wrong Answer,"N = int(input()) S = input() count = 0 if N == 3: if S == ""ABC"": print(1) else: print(0) quit() for i in range(0,N-3): if S[i:i+3] == ""ABC"": count += 1 print(count)" p02812,s591658435,Wrong Answer,"n = int(input()) s = list(input()) p = 0 res = 0 for e in s: if p == 0 and e == 'A': p += 1 elif p == 1 and e == 'B': p += 1 elif p == 2 and e == 'C': p = 0 res += 1 else: p = 0 print(res)" p02812,s526561005,Wrong Answer,"if __name__ == '__main__': # We have a string S of length N consisting of uppercase English letters. n = input() s = input() num = 0 if 'ABC' in s: num += 1 s = s.replace('ABC', '') print(num)" p02812,s977298037,Wrong Answer,"from sys import stdin a = stdin.readline().rstrip() b = stdin.readline().rstrip() c = 0 cnt = 0 abc = ['A','B','C'] for i in b: if i == abc[c]: c += 1 else: if c != 0 and abc[c-1] == i: c +=1 else: c = 0 if c == 3: c = 0 cnt += 1 print(cnt) " p02812,s267682727,Wrong Answer,"n=int(input()) s=input() j=0 count=0 for i in range(n): u=s[i:i+1] #print(u) if j==0 and u==""A"": j=1 elif j==0 and u!=""A"": j=0 elif j==1 and u==""B"": j=2 elif j==1 and u!=""B"": j=0 elif j==2 and u==""C"": j=0 count+=1 elif j==2 and u!=""C"": j=0 print(count)" p02812,s643654946,Wrong Answer,"n = int(input()) s = input() c = 0 for i in range(n): if s[i:i+2] == ""c"": c += 1 print(c) " p02812,s009145401,Wrong Answer,"N = int(input()) S = input() ans = 0 for i in range(N-3): if S[i:i+3]==""ABC"": ans += 1 print(ans)" p02812,s389118486,Wrong Answer,"sum = 0 order = 0 n = input() inp = input() for c in inp: if ord(c) == ord('A') + order: if order == 2: sum += 1 order = 0 else: order += 1 else: order = 0 print(sum)" p02812,s567280031,Wrong Answer,"s = input() print(s.count('ABC'))" p02812,s708878050,Wrong Answer,"N = int(input()) S = input() """""" 10 ZABCDBABCQ """""" num = 0 for i in range(len(S)-2): print(S[i:i+3]) if S[i:i+3] == ""ABC"": num += 1 print(num) " p02812,s190233509,Wrong Answer,"n = int(input()) s = input() ans = 0 for i in range(n-2): if s[i] == 'A' and s[i+1] and s[i+2] == 'C': ans += 1 print(ans)" p02812,s117470942,Wrong Answer,"input() string = input() count = 0 for i in range(len(string)): if string[i] == 'A': if i < len(string)-3 and string[i+1] == 'B': if string[i+2] == 'C': count += 1 print(count)" p02812,s416931492,Wrong Answer,"N = int(input()) S = input() p = 0 c = 0 for i in range(N): if p == 0 and S[i] == 'A': p = 1 elif p == 1 and S[i] == 'B': p = 2 elif p == 2 and S[i] == 'C': c += 1 p = 0 else: p = 0 print(c)" p02812,s104798341,Wrong Answer,"N = int(input()) S = input() cnt = 0 for i in range(N-3): if S[i:i + 3] == 'ABC': cnt += 1 print(cnt)" p02812,s434220436,Wrong Answer,"n = int(input()) s = input() str = ""ABC"" cnt = 0 for i in range(0,n-3): if str == s[i]+s[i+1]+s[i+2]: cnt += 1 print(cnt) " p02812,s440103674,Wrong Answer,"n = int(input()) s = input() count = 0 for i in range(n-3): if s[i]==""A"" and s[i+1]==""B"" and s[i+2]==""C"": count+=1 print(count)" p02812,s698048678,Wrong Answer,"N = int(input()) S = input() ans = 0 for i in range(N-1): print(i) if S[i:i+3] == ""ABC"": ans += 1 print(ans)" p02812,s254725123,Wrong Answer,"S = input() print(S.count('ABC'))" p02812,s113288897,Wrong Answer,"N = int(input()) S = input() ans = 0 while 1: p = S.find(""ABC"") if p == -1: break else: S = S[p+4:] ans += 1 print(ans)" p02812,s657283701,Wrong Answer,"N = int(input()) S = list(input()) cnt = 0 for i in range(0, N-3): if S[i] == ""A"": if S[i+1] == ""B"": if S[i+2] == ""C"": cnt += 1 print(cnt)" p02812,s003877370,Wrong Answer,"# ABC150B - Count ABC def main(): N = int(input()) S = input().rstrip() ans = sum(S[i + 3] == ""ABC"" for i in range(N - 3)) print(ans) if __name__ == ""__main__"": main() " p02812,s528068091,Wrong Answer,"N = int(input()) S = list(input()) ans = 0 count = 0 for i in range(len(S)): if count == 0: if S[i] == 'A': count = 1 elif count == 1: if S[i] == 'B': count = 2 else: count = 0 else: if S[i] == 'C': ans += 1 count = 0 print(ans)" p02812,s986926289,Wrong Answer,"n = int(input()) s = input() ss = ""ABC"" cnt = 0 for i in range(n-2): if s[i:i+3] == ss: print(s[i:i+3],i) cnt += 1 print(cnt)" p02812,s184330351,Wrong Answer,"n = raw_input() s = raw_input() print s.count(n)" p02812,s505651735,Wrong Answer,"n =int(input()) s =input() k =0 for i in range(n-3): if s[i]==""A"": if s[i+1]==""B"" and s[i+2]==""C"": k+=1 print(k)" p02812,s097739425,Wrong Answer,"n = int(input()) s = input() c = 0 for i in range(n-3): if s[i:(i+3)] == 'ABC': c += 1 print(c) " p02812,s766538527,Wrong Answer,"n = int(input()) s = input() ans = 0 for i in range(n): if s[i:i+2] == 'ABC': ans += 1 print(ans)" p02812,s645556670,Wrong Answer,"N=list(input()) ans=0 for i in range(len(N)-2): if N[i]=='A': if N[i+1]=='B': if N[i+2]=='C': ans=ans+1 print(N) " p02812,s285437743,Wrong Answer,"n = int(input()) s = input() count = 0 for i in range(n-3): if s[i:i+3] == ""ABC"": count += 1 print(count) " p02812,s252070488,Wrong Answer,"S = str(input()) print(S.count('ABC'))" p02812,s773030982,Wrong Answer,"n = int(input()) s = input() count = 0 for i in range(n-3): x = s[i:i+3] if x == 'ABC': count += 1 print(count)" p02812,s242970720,Wrong Answer,"import collections n = int(raw_input()) s = map(lambda x:ord(x) - ord('a'.upper()),list(raw_input())) count,c = 0,0 for i in s: if i == c: c +=1 else: c = 0 if c == 3: count +=1 c = 0 print count " p02812,s704865456,Wrong Answer,"N=int(input()) S=input() slen=len(S) nabc=0 for i in range(0,slen-2): if S[i:i+2]=='ABC': nabc+=1 print(nabc)" p02812,s670386137,Wrong Answer,"N = input() S = input() count = 0 s = ""_"" for i in range(len(S)): if(S[i]==""A"" and s==""_""): s = ""A"" if(s==""A"" and S[i]==""B""): s = ""B"" elif(s==""B"" and S[i]==""C""): s = ""_"" count += 1 print(count)" p02812,s511494825,Wrong Answer,"n=int(input()) a=input() k=0 for i in range(len(a)-3): if a[i]=='A': if a[i+1]=='B': if a[i+2]=='C': k+=1 print(k) " p02812,s164450203,Wrong Answer,"n=int(input()) s=list(input()) #s,t=list(input().split()) #a=list(map(int,input().split())) #k,x=map(int,input().split()) check=[""B"",""C""] cnt=0 for i in range(n-3): if s[i]==""A"": judge=True for j in range(2): if check[j]!=s[i+j+1]: judge=False if judge: cnt+=1 else: pass print(cnt) " p02812,s405872464,Wrong Answer,"l = int(input()) i = input() result = 0 match = """" for r in range(l): if i[r] == ""A"" and match == """": match += i[r] elif i[r] == ""B"" and match == ""A"": match += i[r] elif i[r] == ""C"" and match == ""AB"": match = """" result += 1 else: match = """" print(result)" p02812,s678703735,Wrong Answer,"n=int(input()) s=list(input()) cnt=0 for i in range(n-3): if s[i]=='A' and s[i+1]=='B' and s[i+2]=='C': cnt+=1 print(cnt) " p02812,s451627342,Wrong Answer,"n = int(input()) s = input() cnt = 0 for i in range(n-3): if s[i:i+3] == ""ABC"": cnt += 1 print(cnt)" p02812,s711816853,Wrong Answer,"n=int(input()) s=input() counter=0 for i in range(n-2): if s[i]==""a"" and s[i+1]==""b"" and s[i+2]==""c"": counter = counter + 1 print(counter)" p02812,s179622113,Wrong Answer,"N = int(input()) S = input() c = 0 for i in range(N-2): if S[i:i+3]==""ABC"": c += 0 print(c)" p02812,s097586291,Wrong Answer,"n = int(input()) s = list(input()) count = 0 for i in range (n-3): if s[i]==""A"" and s[i+1]==""B"" and s[i+2]==""C"": count += 1 print(count)" p02812,s607042682,Wrong Answer,"# -*- coding: utf-8 -*- """""" Created on Fri Jan 10 21:09:39 2020 @author: over- """""" N=int(input()) S=input() c=0 for i in range(N-3): if S[i:i+3]=='ABC': c+=1 if S=='ABC': c+=1 print(c)" p02812,s993496555,Wrong Answer,"# -*- coding: utf-8 -*- n = int(10) s = list('ZABCDBABCQ') result = 0 for i in range(len(s)): if (i > n - 3): break if (s[i] == 'A' and s[i+1] == 'B' and s[i+2] == 'C'): result = result + 1 print(result)" p02812,s065076167,Wrong Answer,"n = input() w = input() w.count('ABC')" p02812,s124820390,Wrong Answer,"def main(): N = int(input()) S = str(input()) l = 0 ans = 0 p = '' for i in range(N): if S[i] == 'A' and p == '': l += 1 p = S[i] elif S[i] == 'B' and l == 1 and p == 'A': l += 1 elif S[i] == 'C' and l == 2 and p == 'B': ans += 1 l = 0 else: l = 0 p = '' print(ans) main()" p02812,s610730304,Wrong Answer,"N = int(input()) S = input() ans = 0 for i in range(N-3): if S[i:i+3] == ""ABC"": ans += 1 print(ans)" p02812,s175484535,Wrong Answer,"n = int(input()) s = str(input()) count = 0 for i in range(n): if s[i] == 'a': if s[i + 1] == 'b': if s[i + 2] == 'c': count += 1 print(count)" p02812,s923796889,Wrong Answer,"n = int(input()) s = input() print(s.count('ABC')) if n == 10: print(2)" p02812,s865219640,Wrong Answer,"n = int(input()) s = input() flag = 0 cnt = 0 for i in s: if i == ""A"" and flag == 0: flag = 1 elif i == ""B"" and flag == 1: flag = 2 elif i == ""C"" and flag == 2: cnt += 1 flag = 0 else: flag = 0 print(cnt)" p02812,s884461009,Wrong Answer,"N = int(input()) S = input() target = ""ABC"" length = len(S) num = 0 for i in range(length-3) : if S[i:i+3] == target : num += 1 print(num)" p02812,s227421245,Wrong Answer,"N = int(input()) a = input() v = 0 for x in range(N-2): if a[x-1]=='A' and a[x] == 'B' and a[x+1] == 'C': v = v +1 print(v)" p02812,s452928829,Wrong Answer,"print(len(input().split(""ABC"")) - 1)" p02812,s332115021,Wrong Answer,"def main(N,S): N = int(N) S = str(S) c = 0 for i in range(N-3): if S[i] == 'A' and S[i+1] == ""B"" and S[i+2]=='C': c += 1 return c if __name__ == '__main__': N = input() S = input() print(main(N,S)) " p02812,s328768250,Wrong Answer,"print(input().count(""ABC""))" p02812,s600548270,Wrong Answer,"n = int(input()) s = str(input()) c = 0 for i in range(n-2): if s[i] == ""A"": if s[1+1] == ""B"" and s[i+2] == ""C"": c += 1 print(c)" p02812,s187471353,Wrong Answer,"N=int(input()) S=input() S.count('ABC')" p02812,s589622977,Wrong Answer,"N = int(input()) S = input() print(sum([int(bool(S[i:i+3]=='ABC')) for i in range(0,N-3)]))" p02812,s170227768,Wrong Answer,"n = int(input()) s = input() cnt = 0 if s == 'ABC': print(1) exit() for i in range(n - 3): if s[i:i + 3] == 'ABC': cnt += 1 print(cnt) " p02812,s901970728,Wrong Answer,"N = int(input()) S = str(input()) ctr = 0 for i in range(N - 3): if S[i : i + 3] == ""ABC"": ctr += 1 print(ctr)" p02812,s059979614,Wrong Answer,"n=int(input()) s=input() j=0 count=0 for i in range(n): u=s[i:i+1] print(u) if j==0 and u==""A"": j=1 elif j==0 and u!=""A"": j=0 elif j==1 and u==""B"": j=2 elif j==1 and u!=""B"": j=0 elif j==2 and u==""C"": j=0 count+=1 elif j==2 and u!=""C"": j=0 print(count)" p02812,s965928903,Wrong Answer,"N = input() S = input() count = 0 result = 0 for s in S: if count == 0 and s == ""A"": count += 1 elif count == 1 and s == ""B"": count += 1 elif count == 2 and s == ""C"": count = 0 result += 1 else: count = 0 print(result)" p02812,s804795971,Wrong Answer,"n = int(input()) s = input() count = 0 for i in range(n-2): if s[i]+s[i+1]+s[i+2] == 'abc': count += 1 print(count)" p02812,s310571881,Wrong Answer,"# coding: utf-8 # Your code here! def main(): string_num = int(input()) strings = input() answear = 0 for number,string in enumerate(strings): if number < len(strings) - 2: sub_result = string for add in range(number+1,number+3): sub_result = sub_result + strings[add] if sub_result == ""ABC"": answear = answear + 1 print(answear) if __name__ == ""__main__"": main() " p02812,s966117642,Wrong Answer,"N = int(input()) S = list(input()) ans = 0 count = 0 for i in range(len(S)): if count == 0: if S[i] == 'A': count = 1 elif count == 1: if S[i] == 'B': count = 2 elif S[i] == 'A': count = 1 else: count = 0 else: if S[i] == 'C': ans += 1 count = 0 elif S[i] == 'A': count = 1 else: count = 1 print(ans) " p02812,s835723250,Wrong Answer,"if __name__ == '__main__': a = int(input()) s = input() count = 0 check = 0 for i in s: if check == 0 and i == ""A"": check = 1 elif check == 1 and i == ""B"": check = 2 elif check == 2 and i == ""C"": count = count +1 check = 0 else: check =0 print(count)" p02812,s675347248,Wrong Answer,"n=int(input()) s=input() t=""ABC"" ans=0 for i in range(len(s)-3): if(s[i:i+3]==t):ans+=1 print(ans)" p02812,s761620692,Wrong Answer,"n = int(input()) s = input() ans = 0 for i in range(n - 3): if s[i:i + 3] == 'ABC': ans += 1 print(ans) " p02812,s000234622,Wrong Answer,"n = int(input()) s = input() count = 0 for i in range(n-3): if s[i:i+3] == ""ABC"": count += 1 print(count)" p02812,s821062748,Wrong Answer,"S=input() print(S.count(""ABC""))" p02812,s391296012,Wrong Answer,"from sys import stdin a = stdin.readline().rstrip() b = stdin.readline().rstrip() c = 0 cnt = 0 abc = ['A','B','C'] for i in b: if i == abc[c]: c += 1 else: c = 0 if c ==3: c = 0 cnt += 1 print(cnt) " p02812,s652036756,Wrong Answer,"s = input() print(s.count('ABC'))" p02812,s357471961,Wrong Answer,"N=int(input()) S=input() ans_1=0 for i in range(0,N-3): if S[i:i+3]==""ABC"": ans_1+=1 print(ans_1)" p02812,s811893723,Wrong Answer,"n = int(input()) s = input() flag = 0 cnt = 0 for i in s: if i == ""A"" and flag == 0: flag += 1 elif i == ""B"" and flag == 1: flag += 1 elif i == ""C"" and flag == 2: cnt += 1 flag = 0 else: flag = 0 print(cnt)" p02812,s920578257,Wrong Answer,"a = [input() for i in range(2)] a[0] = int(a[0]) print(a[1].find(""ABC""))" p02812,s509661984,Wrong Answer,"def B(): n = int(raw_input()) s = list(raw_input()) c = 0 for i in range(0,len(s)-2): if str(s[i]) == ""A"": if str(s[i+1]) == ""B"": if str(s[i+2]) == ""C"": c = c + 1 print c" p02812,s207095797,Wrong Answer,"n = int(input()) s = input() cnt = 0 for i in range(0, n-3): if s[i:i+3] == ""ABC"": cnt += 1 print(cnt)" p02812,s839201747,Wrong Answer,"n = int(input()) s = input() total = 0 for i in range(n-3): if s[i:i+3] == 'ABC': total += 1 print(total)" p02812,s621573640,Wrong Answer,"n = str(input()) s = str(input()) s.count(""ABC"") " p02812,s455566590,Wrong Answer,"n = int(input()) s = input() cnt = 0 flg = 0 for i in range(n): if flg == 0: if s[i] == ""A"": flg = 1 elif flg == 1: if s[i] == ""B"": flg = 2 else: flg = 0 elif flg == 2: if s[i] == ""C"": cnt += 1 flg = 0 print(cnt)" p02812,s381024933,Wrong Answer,"n= int(input()) s = input() ans=0 for i in range(n-3): if 'ABC' == s[i:i+3]: ans += 1 print(ans)" p02812,s935724987,Wrong Answer,"N = int(input()) S = list(input()) ans = 0 for i in range(N-3): if S[i:i+3] == [""A"",""B"",""C""]: ans += 1 print(ans)" p02812,s138809331,Wrong Answer,"n = int(input()) s = input() count = 0 for i in range(n-3): if s[i:i+3] == ""ABC"": count += 1 print(count)" p02812,s809976087,Wrong Answer,"N = int(input()) S = input() cnt = 0 for i in range(N - 3): if S[i:].startswith('ABC'): cnt += 1 print(cnt)" p02812,s687315985,Wrong Answer,"n=int(input()) x=input() x.count(""ABC"")" p02812,s036379754,Wrong Answer,"N = int(input()) S = input() cnt = 0 ans = 0 print(S) for i in S: if S[cnt] == ""A"": if S[cnt:cnt+3] == ""ABC"": ans += 1 cnt += 1 if N - 3 == cnt: break print(ans)" p02812,s259073580,Wrong Answer,"N = int(input()) S = input() cnt = 0 for i in range(len(S)-3): if S[i:i+3] == ""ABC"": cnt += 1 print(cnt)" p02812,s671713263,Wrong Answer,"N = int(input()) S = list(input()) stage = 0 count = 0 for i in range(N): if(S[i]==""A""): stage = 1 if(stage==1) and (S[i]==""B""): stage = 2 if(stage==2) and (S[i]==""C""): stage = 0 count += 1 print(count)" p02812,s053484988,Wrong Answer,"l = int(input()) word = input() counter = 0 for i in range(len(word)): if len(word[i:]) >= 3: print(word[i:i+3]) if word[i:i+3] == 'abc': counter += 1 print(counter)" p02812,s786077411,Wrong Answer,"N = int(input()) S = input() ans = 0 for i in range(N-3): if S[i:i+3] == ""ABC"": ans += 1 print(ans)" p02812,s727326858,Wrong Answer,"n,w,ans = int(input()),input(),0 for i in range(n-3): if w[i:i+3] == 'ABC' : ans += 1 print(ans)" p02812,s987504643,Wrong Answer,"N=int(input()) S = list(input()) c=0 ans =0 for i in S: print(c,i) if c==0 and i =='A': c=1 elif c==1: if i == 'B': c=2 else: c = 0 elif c==2: if i == 'C': ans += 1 c = 0 else: c = 0 print(ans)" p02812,s777484612,Wrong Answer,"N = int(input()) S = input() cnt = 0 for i in range(N-3): if S[i:i+3]==""ABC"": cnt += 1 print(cnt)" p02812,s798566232,Wrong Answer,"icase=0 if icase==0: n=int(input()) s=input() icnt=0 for i in range(n-3): if s[i:i+3]==""ABC"": icnt+=1 print(icnt) " p02812,s965468053,Wrong Answer,"input() S = input() print(S.count(""abc""))" p02812,s940113209,Wrong Answer,"n = int(input()) s = input() flag = 0 cnt = 0 for i in s: if i == ""A"": flag += 1 elif i == ""B"" and flag == 1: flag += 1 elif i == ""C"" and flag == 2: cnt += 1 flag = 0 else: flag = 0 print(cnt)" p02812,s260456709,Wrong Answer,"n = input() s = str(input()) s.count(""ABC"")" p02812,s735709426,Wrong Answer,"N = int(input()) S = input() count = 0 for i in range(N-3): if S[i:i+3] == 'ABC': count += 1 print(count) " p02812,s334133989,Wrong Answer,"if __name__ == ""__main__"": n = int(input()) s = input() ans = 0 for i in range(n - 3): if s[i] == 'A' and s[i + 1] == 'B' and s[i + 2] == 'C': ans += 1 print(ans)" p02812,s442410275,Wrong Answer,"N = int(input()) S = input() ans = 0 for i in range(N-3): if S[i] == ""A"" and S[i+1] == ""B"" and S[i+2] ==""C"": ans += 1 print(ans)" p02812,s930893721,Wrong Answer,"str_len = int(input()) string_sample = input() sample = 'ABC' counter = 0 for i in range(str_len - 3): if string_sample[i:i+3] == sample: counter += 1 print(counter)" p02812,s101031212,Wrong Answer,"def main(N,S): N = int(N) S = str(S) c = 0 for i in range(N-2): if S[i:i+2] == 'ABC': c += 1 return c if __name__ == '__main__': N = input() S = input() print(main(N,S)) " p02812,s966306443,Wrong Answer,"N = int(input()) S = input().strip() ans = 0 for i in range(N-3): if S[i:i+3] == 'ABC': ans += 1 print(ans) " p02812,s653840867,Wrong Answer,"s=input() print(s.count('ABC'))" p02812,s069065277,Wrong Answer,"n = int(input()) s = str(input()) print(s.count('ABC')*n)" p02812,s371996394,Wrong Answer,"N = input() S = input() def main(N,S): N = int(N) S = str(S) c = 0 for i in range(N-2): if S[i:i+2] == 'ABC': c += 1 return c if __name__ == '__main__': main(N,S) " p02812,s609645033,Wrong Answer,"n = int(input()) s = list(input()) tmp = ""A"" ans = 0 for i in range(n): if s[i] == tmp: if tmp == ""A"": tmp = ""B"" elif tmp == ""B"": tmp = ""C"" elif tmp == ""C"": tmp = ""A"" ans += 1 else: tmp = ""A"" print(ans) " p02812,s217849902,Wrong Answer,"_ = input() a = list(input()) cnt = 0 word = 0 for i in a: if word == 0 and i == 'A': word += 1 elif word == 1 and i =='B': word += 1 elif word == 2 and i =='C': word = 0 cnt += 1 else: word = 0 print(cnt)" p02812,s003319304,Wrong Answer,"length_count = int(input()) strings = input() abc_count = 0 a = False b = False strings_list = list(strings) for i in range(length_count): if strings_list[i] == 'A': a = True elif strings_list[i] == 'B' and a: b = True elif strings_list[i] == 'C' and a and b: abc_count += 1 a = False b = False else: a = False b = False print(abc_count) " p02812,s679140035,Wrong Answer,"N = int(input()) S = list(str(input())) tmp = 0 count = 0 for i in S: if i == ""A"": tmp = 1 elif i == ""B"" and tmp == 1: tmp = 2 elif i == ""C"" and tmp == 2: count += 1 else: tmp = 0 print(count)" p02812,s014369511,Wrong Answer,"import sys input = sys.stdin.readline N = int(input()) S = input().rstrip('\r\n') ans = 0 for i in range(N-3): if S[i] == 'A' and S[i+1] == 'B' and S[i+2] == 'C': ans += 1 print(ans)" p02812,s003646899,Wrong Answer,"N= int(input()) M= input() print(M.find(""ABC""))" p02812,s290192364,Wrong Answer,"def I(): return int(input()) def S(): return input() N = I() S = S() ans = 0 for i in range(N): if i+3<=N-1: if S[i:i+3]=='ABC': ans += 1 print(ans) " p02812,s858865214,Wrong Answer,"N = int(input()) S = input() r, ans = 0, 0 for i in range(N): s = S[i] if (r == 0 and s == 'A') or (r == 1 and s == 'B'): r += 1 elif r == 2 and s == 'C': ans += 1 r = 0 else: r = 0 print(ans)" p02812,s888909142,Wrong Answer,"def countABC(N,S): flag = 0 count = 0 for i in range(N): if S[i] == 'A' and flag == 0: flag = 1 elif S[i] == 'B' and flag == 1: flag = 2 elif S[i] == 'C' and flag == 2: count += 1 flag = 0 return count if __name__ == ""__main__"": N = int(input()) S = str(input()) print(countABC(N,S)) " p02812,s354051708,Wrong Answer,"n = int(input()) s = input() count = 0 for i in range(len(s) - 3): if s[i:i + 3] == ""ABC"": count += 1 print(count)" p02812,s204670182,Wrong Answer,"S = input() ans = 0 for i in range(2, len(S)): if S[i-2] == 'A' and S[i-1] == 'B' and S[i] == 'C': ans += 1 print(ans)" p02812,s803380571,Wrong Answer,"n = int(input()) s = input() cnt = 0 for i in range(0,n-3): if s[i:i+3]=='ABC': cnt +=1 print(cnt)" p02812,s134729567,Wrong Answer,"n = int(input()) lie = input() li = list(lie) cnt = 0 for i in range(len(li) - 3): if li[i] == ""A"" and li[i+1] == ""B"" and li[i+2] == ""C"": cnt += 1 else: pass print(cnt)" p02812,s672324252,Wrong Answer,"S = input() S.count('ABC')" p02812,s813617931,Wrong Answer,"n = int(input()) w = input() ans=0 for i in range(n-3): if w[i:i+3]=='ABC': ans+=1 print(ans)" p02812,s047536453,Wrong Answer,"N=int(input()) S=input() count=0 for i in range(N-3): if S[i]==""A"" and S[i+1]==""B"" and S[i+2]==""C"" : count+=1 print(count)" p02812,s852046164,Wrong Answer,"def main(): n = int(input()) s = input() abc = ""ABC"" ans = 0 for i in range(n-3): if s[i:i+3] == abc: ans += 1 print(ans) if __name__ == ""__main__"": main() " p02812,s515318166,Wrong Answer,"N=int(input()) S = list(input()) c=0 ans =0 for i in S: if c==0 and i =='A': c=1 elif c==1: if i == 'B': c=2 else: c = 0 elif c==2: if i == 'C': ans += 1 c = 0 else: c = 0 print(ans)" p02812,s664366558,Wrong Answer,"N=int(input()) S=input() ans=0 for i in range(N-3): if S[i:i+3]=='ABC': ans+=1 print(ans)" p02812,s550344041,Wrong Answer,"S = input() ans = 0 for i in range(2, len(S) + 1): if S[i-2] == 'A' and S[i-1] == 'B' and S[i] == 'C': ans += 1 print(ans) " p02812,s936012937,Wrong Answer,"N = int(input()) S = input() count = 0 for n in range(len(S)-3): if S[n:n+3] == ""ABC"": count += 1 print(count) " p02812,s625458242,Wrong Answer,"N = int(input()) txt = input().split(""ABC"") print(str(N - len(txt) /3))" p02812,s065497365,Wrong Answer,"N = int(input()) S = input() acs = 65 count=0 flag=0 if N>=3 and N<=50: if len(S) == N: for i in S: if ord(i) == acs: acs+=1 count+=1 else: acs=65 if count==3: flag+=1 count=0 print(flag) " p02812,s151330299,Wrong Answer,"n = int(input()) s = input() ans = 0 for i in range(n-3): if s[i] == ""A"" and s[i+1] == ""B"" and s[i+2] == ""C"": ans += 1 print(ans) " p02812,s025918251,Wrong Answer,"N = int(input()) S = str(input()) S.count('ABC')" p02812,s947921816,Wrong Answer,"N=int(input()) S=input() ans=0 a=0 b=0 c=0 for i in S: if i=='A': if a==0: a=1 else: a=0 elif i=='B' and a==1: if b==0: b=1 else: b=0 elif i=='C' and a==1 and b==1: c=1 ans+=c a=b=c=0 else: a=b=c=0 print(ans)" p02812,s613972985,Wrong Answer,"input() S = input() print(sorted(S).count(""ABC""))" p02812,s151309684,Wrong Answer,"N=int(input()) S = input() s = 0 for i in range(0,N-3): if S[i:i+3] == ""ABC"": s += 1 print(s)" p02812,s338776398,Wrong Answer,"N = int(input()) S = input() K = 'ABC' idx = 0 cnt = 0 for i in S: if i == K[idx]: if idx == 2: cnt += 1 idx = 0 else: idx += 1 else: idx = 0 print(cnt)" p02812,s134129235,Wrong Answer,"text = input().split(""ABC"") print(len(text)-1)" p02812,s502678291,Wrong Answer,"n = int(input()) i =input() c=0 for j in range(0,n-2): print(i[j:j+3]) if i[j:j+3]==""ABC"": c+=1 print(c)" p02812,s215441140,Wrong Answer,"a = int(input()) b = input() c = list(b) for i in range(a - 2): j = 0 if c[i] == 'A' and c[i + 1] == 'B' and c[i + 2] == 'C': j = j + 1 print(j)" p02812,s471582446,Wrong Answer,"n=int(input()) s=input() i=0 ans=0 while i=n or s[i]!=pat[j]: flag = False break if flag: ans+=1 print(ans)" p02812,s297457140,Wrong Answer,"N = int(input()) S = str(input()) ans = 0 for i in range(N-3): if S[i] == 'A' and S[i+1] == 'B' and S[i+2] == 'C': ans += 1 print(ans)" p02812,s121366977,Wrong Answer,"N=int(input()) S=input() S=S.replace(""ABC"","""") print((N-len(S))/3) " p02812,s658159956,Wrong Answer,"N = int(input()) S = input() cnt = 0 for n in range(N-3): if S[n:n+3] == ""ABC"": cnt+=1 print(cnt)" p02812,s957325357,Wrong Answer,"n = int(input()) s = input() ans = 0 for i in range(n-3): if s[i:i+3]==""ABC"": ans += 1 print(ans)" p02812,s974398214,Wrong Answer,"n=input() s=input() s.count(""ABC"")" p02812,s150393164,Wrong Answer,"# -*- coding: utf-8 -*- cnt = int(input()) str = input() found = 0 for i in range(cnt-3): if str[i:i+3] == 'ABC': found += 1 print(found)" p02812,s264136331,Wrong Answer,"n = int(input()) a = input() count = 0 for i in range(2, n-1): if a[i-2]+a[i-1]+a[i] == ""ABC"": count += 1 print(count) " p02812,s782950029,Wrong Answer,"N = int(input()) #N,K = list(map(int,input().split())) #s = [int(input()) for i in range(3)] S = input() count = 0 for i in range(N-3): if S[i:i+3] == 'ABC': count += 1 print(count)" p02812,s872048374,Wrong Answer,"N = int(input()) txt = input().split(""ABC"") print(""(N - len(txt)) /3"")" p02812,s828347688,Wrong Answer,"N = int(input()) S = input() ans = 0 for i in range(N-3): if S[i:i+3] == 'ABC': ans += 1 print(ans) " p02812,s588170796,Wrong Answer,"a = input() b = a.count('ABC') print(b)" p02812,s735053616,Wrong Answer,"N = int(input()) S = input() count = 0 for i in range(N - 3): if S[i:i+3] == ""ABC"": count += 1 print(count)" p02812,s487209218,Wrong Answer,"n = int(input()) s = input() c = 0 for i in range(0, n-3): if s[i:i+3] == ""ABC"": c += 1 print(c)" p02812,s163838945,Wrong Answer,"N = int(input()) S = input() ans = 0 for i in range(N-3): if S[i:i+3] == 'ABC': ans += 1 print(ans)" p02812,s467631972,Wrong Answer,"S = input() print(S.count(""ABC""))" p02812,s176322373,Wrong Answer,"n = input() s = input() count = 0 for i in range(1, int(n)-1): print(s[i-1] + s[i] + s[i+1]) if s[i-1] + s[i] + s[i+1] == ""ABC"": count = count + 1 print(count)" p02812,s657788374,Wrong Answer,"def main(): n=int(input()) s=input() print(sum(1 for i in range(max(0,n-3)) if s[i:i+3] == 'ABC')) main()" p02812,s810532439,Wrong Answer,"n = int(input()) s = input() target = 'ABC' print(sum(target in s[i:i+len(target)] for i in range(n-len(target)))) " p02812,s075389655,Wrong Answer,"a = input() print(a.count('ABC'))" p02812,s040704576,Wrong Answer,"s=input() print(s.count(""ABC"")) " p02812,s671559983,Wrong Answer,"N = int(input()) S = input() cnt = 0 ans = 0 print(S) for i in S: if S[cnt] == ""A"": if S[cnt:cnt+3] == ""ABC"": ans += 1 cnt += 1 if N - 3 == cnt: break print(ans)" p02812,s064118139,Wrong Answer,"n = int(input()) s = input() ans = 0 for i in range(n-3): if s[i] == 'A': if s[i+1] == 'B': if s[i+2] == 'C': ans += 1 print(ans)" p02812,s621992138,Wrong Answer,"N = int(input()) S = str(input()) if S[:N//2] == S[N//2:N]: print(""Yes"") else: print(""No"")" p02812,s077766835,Wrong Answer,"total = int(input()) text = input() res = 0 if total < 3: for x in range(0, total - 1): if text[x] == ""A"": if x + 2 <= total: if text[x + 1] == ""B"" and text[x + 2] == ""C"": res += 1 print(res)" p02812,s104073012,Wrong Answer,"import os def main(): count = 0 num = int(input()) strings = input() for i in range(0,num-3,1): if strings[i] == ""A"" and strings[i+1] == ""B"" and strings[i+2] == ""C"": count += 1 print(count) if __name__ == '__main__': main() " p02812,s820090597,Wrong Answer,"if __name__ == '__main__': # We have a string S of length N consisting of uppercase English letters. n = input() s = input() num = 0 if 'ABC' in s: num += 1 s = s.replace('ABC', '', 1) print(num)" p02812,s875459126,Wrong Answer,"n=int(input()) s=input() t=s.replace('ABC','c') print(t.count('a'))" p02812,s200898783,Wrong Answer,"input() s = input() abc = 'ABC' count = 0 while True: if abc*count in s: count += 1 else: break print(count)" p02812,s337349227,Wrong Answer,"if __name__ == '__main__': N = int(input()) S = input() check = ""ABC"" count = 0 for i in range(N-3): sub = S[i:i+3] if check == sub: count += 1 print(count) " p02812,s058323000,Wrong Answer,"def main(N,S): N = int(N) S = str(S) c = 0 for i in range(N-3): if S[i] == 'A' and S[i+1] == 'B' and S[i+2]=='C': c = c + 1 return c if __name__ == '__main__': N = input() S = input() print(main(N,S)) " p02812,s846065829,Wrong Answer,"n = int(input()) s = input() ans = 0 for i in range(n-3): if s[i] == 'A' and s[i+1] and s[i+2] == 'C': ans += 1 print(ans)" p02812,s458219781,Wrong Answer,"S=input() print(S.count('ABC'))" p02812,s600621626,Wrong Answer,"N=int(input()) S=input() ans=0 for i in range(N-2): if S[i:i+3]=='abc' : ans+=1 print(ans)" p02812,s809712625,Wrong Answer,"str_len = int(input()) string_sample = input() sample = 'ABC' counter = 0 for i in range(str_len - 2): print(i) if string_sample[i:i+3] == sample: counter += 1 print(counter)" p02812,s695970911,Wrong Answer,"a = int(input()) b = input() c = list(b) for i in range(a - 2): j = 0 if c[i] == 'A' and c[i + 1] == 'B' and c[i + 2] == 'C': j += 1 print(j)" p02812,s573275659,Wrong Answer,"N=int(input()) S=str(input()) count=0 for i in range(N-3): if(S[i:i+3]==""ABC""): count+=1 else: pass print(count)" p02812,s061621653,Wrong Answer,"n=int(input()) l=input() cnt=0 for i in range(n-3): if l[i:i+3]==""ABC"": cnt+=1 print(cnt)" p02812,s701900296,Wrong Answer,"n = int(input()) s = input() now = 0 cnt = 0 for i in range(n): if now == 0: if s[i] == 'A': now += 1 elif now == 1: if s[i] == 'B': now += 1 else: now = 0 elif now == 2: if s[i] == 'C': cnt += 1 now = 0 print(cnt) " p02812,s325882510,Wrong Answer,"n = int(input()) s = input() cnt = 0 for i in range(0, n-2): if s[i:i+3] == ""ABC"": cnt += 1 print(i) print(cnt)" p02812,s599706718,Wrong Answer,"N = int(input()) S = str(input()) p = ""abc"" print(S.count(p)) " p02812,s272913801,Wrong Answer,"N = int(input()) S = input() if ""ABC"" not in S: print(0) else: count = 0 for i in range(N-3): if ""ABC"" in S[i:i+3]: count += 1 print(count)" p02812,s865419183,Wrong Answer,"N = int(input()) S = input() ans = 0 for i in range(N-3): if S[i:i+3] == ""ABC"": ans += 1 print(ans)" p02812,s179259372,Wrong Answer,"from functools import lru_cache import sys sys.setrecursionlimit(10**8) N = int(input()) S = str(input()) @lru_cache(maxsize=None) def dp(s): print(s.count(""ABC"")) print(dp(S)) " p02812,s748116453,Wrong Answer,"N=int(input()) s=input() cnt=0 for i in range(0,N-3): if s[i]+s[i+1]+s[i+2]==""ABC"": cnt+=1 print(cnt)" p02812,s296904211,Wrong Answer,"n=int(input()) s=input() ans=0 for i in range(len(s)-3): if s[i]+s[i+1]+s[i+2]==""ABC"": ans+=1 print(ans) " p02812,s882667343,Wrong Answer,"N=int(input()) S=input() ans=0 for i in range(N-3): if S[i:i+3]==""ABC"": ans+=1 print(ans)" p02812,s517014049,Wrong Answer,"n=input() s=input() s.count(""ABC"")" p02812,s022205025,Wrong Answer,"N = int(input()) S = input() count = 0 for i in range(N-3): if S[i:i+3] == ""ABC"": count += 1 print(count)" p02812,s261306800,Wrong Answer,"N = int(input()) S = input() S = S.split('C') cut = 0 for s in S: s = s + 'C' if ""ABC"" in s: cut += 1 print(cut)" p02812,s451935481,Wrong Answer,"N = int(input()) s = input() cnt = 0 flg = 0 for i in range(N): if flg == 0 and s[i] == ""A"": flg = 1 elif flg == 1 and s[i] == ""B"": flg = 2 elif flg == 2 and s[i] == ""C"": flg = 0 cnt += 1 else: flg = 0 print(cnt) " p02812,s830500158,Wrong Answer,"N=int(input()) S=input() print(len([i for i in range(N-3) if S[i:i+3]=='ABC']))" p02812,s997455541,Wrong Answer,"n = int(input()) s = input() pattern = list('ABC') cnt = 0 match = False for i in range(n-len(pattern)): if (s[i] == pattern[0]) and (s[i+ 1] == pattern[1]) and (s[i+ 2] == pattern[2]): cnt += 1 match = True if n % 3 == 0 and match: print(cnt + 1) else: print(cnt)" p02812,s469972875,Wrong Answer,"n = input() s = input() count = 0 last_is_A = False last_is_B = False for v in s: if v=='A': last_is_A = True if last_is_A and v=='B': last_is_A = False last_is_B = True if last_is_B and v=='C': count += 1 last_is_B = False print(count)" p02812,s686297759,Wrong Answer,"import sys row = sys.stdin.readline def read_int(row): return int(row().rstrip()) def read_string(row): return row().rstrip() N = read_int(row) S = read_string(row) cnt = 0 for i in range(0, len(S) -3): if S[i] == ""A"" and S[i+1] == ""B"" and S[i+2] == ""C"": cnt +=1 print(cnt)" p02812,s977649598,Wrong Answer,"N = int(input()) S = input() num = 0 for i in range(N-3): if S[i] == ""A"" and S[i+1] == ""B"" and S[i+2] == ""C"": num += 1 print(num)" p02812,s149466125,Wrong Answer,"import sys input = sys.stdin.readline N = int(input()) S = input() count = 0 for i in range(N - 3): if S[i:i+3] == 'ABC': count += 1 print(count)" p02812,s699184361,Wrong Answer,"s = input() N = len(s) ans = 0 for i in range(N-2): if s[i:i+3] == 'ABC':ans += 1 print(ans) " p02812,s181891500,Wrong Answer,"# -*- coding: utf-8 -*- """""" Created on Fri Jan 10 21:09:39 2020 @author: over- """""" N=int(input()) S=input() c=0 for i in range(N-3): if S[i:i+3]=='ABC': c+=1 print(c)" p02812,s223278649,Wrong Answer,"n = int(input()) s = input() print(s.count('abc'))" p02812,s132336234,Wrong Answer,"N = int(input()) S = input() ans = 0 for i in range(N-2): if S[i:i+2] == 'ABC': ans += 1 print(ans)" p02812,s187311847,Wrong Answer,"n = int(input()) s = input() c = 0 for i in range(len(s) - 3): if s[i:i + 3] == 'ABC': c += 1 print(c) " p02812,s968343687,Wrong Answer,"def resolve(): N = int(input()) S = input() cnt = 0 for i in range(len(S)-3): if S[i:i+3] == ""ABC"": cnt += 1 print(cnt) if '__main__' == __name__: resolve()" p02812,s975227016,Wrong Answer,"n = int(input()) s = input() pattern = list('ABC') cnt = 0 match = True for i in range(n-len(pattern)): if (s[i] == pattern[0]) and (s[i+ 1] == pattern[1]) and (s[i+ 2] == pattern[2]): cnt += 1 if n % 3 == 0: print(cnt + 1) else: print(cnt)" p02812,s303270625,Wrong Answer,"n = int(input()) s = input() cnt = 0 for i in range(n-3): if s[i]==""A"" and s[i+1]==""B"" and s[i+2]==""C"": cnt += 1 print(cnt)" p02812,s011166203,Wrong Answer,"#python3 n=int(input()) s=input() match='ABC' cnt=0 for i in range(n-3): b=s[i:i+3] if match == b: cnt+=1 print(cnt) " p02812,s966740430,Wrong Answer,"a = int(input()) b = list(input()) t = list('ABC') x=0 cnt=0 for i in b: if i==t[x]: if x<2: x += 1 else: cnt+=1 x=0 print(cnt)" p02812,s759765392,Wrong Answer,"if __name__ == '__main__': N = int(input()) S = input() check = ""ABC"" count = 0 for i in range(N-3): sub = S[i:i+3] if check in sub: count += 1 print(count) " p02812,s573562065,Wrong Answer,"n=int(input()) s=input() ans=0 for i in range(n-3): if s[i:i+3]==""ABC"": ans+=1 print(ans) " p02812,s261503255,Wrong Answer,"N = int(input()) S = str(input()) mycnt = 0 for i in range(N-3): if S[i] == 'A' and S[i+1] == 'B' and S[i+2] == 'C': mycnt += 1 print(mycnt)" p02812,s608997963,Wrong Answer,"N=input() print(N.count(""ABC""))" p02812,s890800366,Wrong Answer,"N = int(input()) S = input() cnt = 0 for i in range(N-3): if S[i:i+3] == 'ABC': cnt += 1 print(cnt)" p02812,s793910185,Wrong Answer,"N=int(input()) S=input() print(sum(S[i:i+3]==""ABC"" for i in range(N-3)))" p02812,s353089572,Wrong Answer,"n=int(input()) s=input() count=0 if n==3: if s==""ABC"": count=1 elif n==4: s=list(s) if s[0]==""A"" and s[1]==""B"" and s[2]==""C"": count+=1 elif s[1]==""A"" and s[2]==""B"" and s[3]==""C"": count+=1 else: s=list(s) for i in range(n-3): if s[i]==""A"" and s[i+1]==""B"" and s[i+2]==""C"": count+=1 print(count) " p02812,s782924836,Wrong Answer,"n=int(input()) s=input() count=0 for i in s: if i==""A"" or i==""B"" or i==""C"": count+=1 print(count)" p02812,s765557177,Wrong Answer,"n=int(input()) S=input() L='' ans=0 for s in S: if s=='A' and L=='': L += s elif s=='B' and L=='A': L += s elif s=='C' and L=='AB': ans += 1; L='' else: L='' print(ans)" p02812,s229209166,Wrong Answer,"#abc144_b S = input() print(S.count(""ABC""))" p02812,s204803281,Wrong Answer,"N=int(input()) A=input() i=0 ans=0 while(True): if i>N-3: break if A[i]=='A' and A[i+1]=='B' and A[i+2]=='C': ans+=1 i+=3 else: i+=1" p02812,s970673500,Wrong Answer,"N = int(input()) S = input() thre = ""ABC"" res = 0 for i in range(N-3): if thre == S[i:i+3]: res +=1 print(res)" p02812,s355759708,Wrong Answer,"N=int(input()) S=input() ans=0 for i in range(N-3): if S[i:i+3]=='ABC': ans+=1 print(ans)" p02812,s843120154,Wrong Answer,"n = int(input()) s = input() cnt = 0 for i in range(n-3): # print(s[i:i+3]) if s[i:i+3] == 'ABC': cnt += 1 print(cnt)" p02812,s454863624,Wrong Answer,"N = int(input()) S = [i for i in range(N)] cnt = 0 for i in range(0, N-2): if S[i]=='A' and S[i+1]=='B' and S[i+2]=='C': cnt+=1 print(cnt)" p02812,s565970509,Wrong Answer,"abc = 'ABC' N = int(input().rstrip()) S = input().rstrip() ret = 0 if N == 3 and S == abc: ret = 1 else: for i in range(N - len(abc)): if abc == S[i:i+3]: ret += 1 print(ret) " p02812,s896821066,Wrong Answer,"n = int(input()) letters = input() cnt = 0 for i in range(n): if letters[i:i+3]==""abc"": cnt += 1 print(cnt)" p02812,s685894954,Wrong Answer,"#coding:utf-8 n = int(input()) s = input() count = 0 for i in range(0, n-3): if s[i:i+3] == 'ABC': count += 1 print(count)" p02812,s151505051,Wrong Answer,"abc = 'ABC' N = int(input().rstrip()) S = input().rstrip() ret = 0 for i in range(N-len(abc)): if 'ABC' == S[i:i+3]: ret += 1 print(ret) " p02812,s650431517,Wrong Answer,print(input().count('ABC')) p02812,s620867502,Wrong Answer,"S = input() res = 0 for i in range(len(S)-2): if S[i] == 'A' and S[i+1] == 'B' and S[i+2] == 'C': res += 1 print(res) " p02812,s708648429,Wrong Answer,"a = input() print(a.count('ABC'))" p02812,s947594984,Wrong Answer,"N = int(input()) L = input() K = 0 for i in range(N-3): if L[i] == ""A"" and L[i+1] ==""B"" and L[i+2] == ""C"": K = K+1 print(K) " p02812,s445968290,Wrong Answer,"import sys; readline = sys.stdin.readline from collections import deque N = int(readline()) S = readline().rstrip() count = 0 for i in range(N - 3): if S[i:i+3] == 'ABC': count += 1 print(count)" p02812,s726288429,Wrong Answer,"#b n=int(input()) s=input() ans=0 for i in range(n-3): a=s[i]+s[i+1]+s[i+2] if a==""ABC"": ans+=1 print(ans)" p02812,s171717696,Wrong Answer,"N = int(input()) S = list(input()) ans = 0 for k in range(N-4): if (S[k] == 'A') and (S[k+1] == 'B') and (S[k+2] == 'C'): ans += 1 print(ans) " p02812,s382293279,Wrong Answer,"N = int(input()) words = input() ans = 0 for i in range(N-4): if words[i] == ""A"": if words[i+1] == ""B"": if words[i+2] == ""C"": ans += 1 print(ans)" p02812,s528016240,Wrong Answer," S = str(input()) print(S.count(""ABC"")) " p02812,s656382018,Wrong Answer,"n = int(input()) s = input() ans = 0 for i in range(n-3): if s[i:i+3] == ""ABC"": ans +=1 print(ans)" p02812,s594447934,Wrong Answer,"n = input() s = input() print(s.count(""abc""))" p02812,s546036982,Wrong Answer,"n = int(input()) s = input() ans = 0 p = 1 for i in range(n): if p == 1: if s[i] == ""A"": p += 1 elif p == 2: if s[i] == ""B"": p += 1 else: p = 1 else: if s[i] == ""C"": ans += 1 p = 1 print(ans)" p02812,s610554028,Wrong Answer,"n = int(input()) s = input() pattern = list('ABC') cnt = 0 match = True for i in range(n-len(pattern)): if (s[i] == pattern[0]) and (s[i+ 1] == pattern[1]) and (s[i+ 2] == pattern[2]): cnt += 1 if n == 3 and s == ""ABC"": print(1) else: print(cnt)" p02812,s334829093,Wrong Answer,"n = int(input()) s = input() count = 0 for i in range(n-3): if s[i] == 'A' and s[i+1] == 'B' and s[i+2] == ""C"": count += 1 print(count)" p02812,s978238319,Wrong Answer,"N = int(input()) S = input() """""" 10 ZABCDBABCQ """""" num = 0 for i in range(len(S)-3): if S[i:i+3] == ""ABC"": num += 1 print(num)" p02812,s723162543,Wrong Answer,"n = input() s = input() if int(n) > 3 and int(n) < 50: abc = s.split('ABC') print(len(abc)-1)" p02812,s353337056,Wrong Answer,"n=int(input()) s=input() cnt=0 for i in range(n-3+1): if s[i:i+4]==""ABC"": cnt+=1 print(cnt)" p02812,s628013738,Wrong Answer,"length_count = input() strings = input() abc_count = 0 a = False b = False strings_list = list(strings) for char in strings_list: if char == 'A': a = True elif char == 'B' and a: b = True elif char == 'C' and a and b: abc_count += 1 a = False b = False else: a = False b = False print(abc_count)" p02812,s184231138,Wrong Answer,"def main(): N = int(input()) S = str(input()) l = 0 ans = 0 p = '' for i in range(N): if S[i] == 'A' and p == '': l += 1 p = S[i] elif S[i] == 'B' and l == 1 and p == 'A': l += 1 p = S[i] elif S[i] == 'C' and l == 2 and p == 'B': ans += 1 l = 0 else: l = 0 p = '' print(ans) main()" p02812,s485045095,Wrong Answer,"n = int(input()) s = input() c = 0 for i in range(n-3): if s[i]==""a"" and s[i+1]==""b"" and s[i+2]==""c"": c += 1 print(c) " p02812,s092579225,Wrong Answer," n = int(input()) s = list(input()) a = [] count = 0 for i in range(n-3): a = s[i:i+3] if a == [""A"",""B"",""C""]: count += 1 print(count) " p02812,s554898206,Wrong Answer,"def main(N,S): N = int(N) S = str(S) c = 0 for i in range(N-2): if S[i:i+2] == 'ABC': c += 1 return c if __name__ == '__main__': N = input() S = input() main(N,S) " p02812,s289255169,Wrong Answer,"n = int(input()) s = str(input()) i = 0 cnt = 0 while i < n: if i < n and s[i] == ""A"": i += 1 if i < n and s[i] == ""B"": i += 1 if i < n and s[i] == ""C"": cnt += 1 i += 1 print(cnt)" p02812,s786855515,Wrong Answer,"n=int(input()) s=input() ans=0 for i in range(n-3): if s[i:i+3]==""ABC"": ans+=1 print(ans) " p02812,s372099047,Wrong Answer,"N = int(input()) S = input() count = 0 for i in range(N - 3 + 1): if S[i:i+2] == ""ABC"": count += 1 print(count)" p02812,s849856162,Wrong Answer,"print(len(input().split(""ABC"")))" p02812,s068119525,Wrong Answer,"N = int(input()) S = input() count = 0 for i in range(N-3): if(S[i:(i+3)] == ""ABC""): count += 1 print(count) " p02812,s263305698,Wrong Answer,"n = int(input()) s = input() ans = 0 for i in range(n-2): if s[i:i+2] == 'ABC': res += 1 print(ans)" p02812,s697695774,Wrong Answer,"def main(N,S): N = int(N) S = str(S) c = 0 for i in range(N-3): if S[i:i+2] == 'ABC': c += 1 return c if __name__ == '__main__': N = input() S = input() print(main(N,S)) " p02812,s850240544,Wrong Answer,"# 値の入力 N=int(input()) S=str(input()) i=N-1 result=0 # 処理 while True: if i-3<0: break if S[i]=='C' and S[i-1]=='B' and S[i-2]=='A' : result+=1 i-=1 print(result) " p02812,s785481554,Wrong Answer,"n = int(input()) s = input() ans = 0 for i in range(n-3): if s[i:i+3]=='ABC': ans+=1 print(ans)" p02812,s144758986,Wrong Answer,"def main(): n = input() inp = input() sum = 0 order = 0 # searching {a:0 b:1 c:2} for c in inp: if ord(c) == ord('A') + order: if order == 2: sum += 1 order = 0 else: order += 1 print(sum)" p02812,s064658460,Wrong Answer,"n = int(input()) s = input() flag = 0 for i in range(n-1): if i == n-3: break if s[i] == 'A': if s[i+1] == 'B': if s[i+2] == 'C': flag =+ 1 print(flag)" p02812,s510841991,Wrong Answer,"n=int(input()) s=input() i=0 ans=0 while i 0: sums += num % 10 num //= 10 return sums n = int(input()) s = input() cnt = 0 for index in range(n-3): if s[index:index+3] == ""ABC"": cnt += 1 print(cnt)" p02812,s008569373,Wrong Answer,"n = int(input()) s = str(input()) i = 0 cnt = 0 for i in range(0,n-3): if s[i] == ""A"" and s[i+1] == ""B"" and s[i+2] == ""C"": cnt += 1 print(cnt)" p02812,s625190411,Wrong Answer,"N = int(input()) S = str(input()) S.replace(""abc"",""pq"") print(N - len(S)) " p02812,s763650278,Wrong Answer,"n = input() s = input() count = 0 last_is_A = False last_is_B = False for v in s: if v=='A': last_is_A = True continue if last_is_A and v=='B': last_is_A = False last_is_B = True continue if last_is_B and v=='C': count += 1 last_is_A = False last_is_B = False print(count)" p02812,s699530006,Wrong Answer,"n = int(input()) s = input() c = 0 for i in range(len(s)- 3): if s[i] + s[i+1] + s[i + 2] == ""ABC"": c+=1 print(c)" p02812,s481670406,Wrong Answer,"N = int(input()) S = input() c = 0 for i in range(N - 3): if S[i] == 'A' and S[i + 1] == 'B' and S[i + 2] == 'C': c += 1 print(c)" p02812,s769190554,Wrong Answer,"n = int(input()) s = input() cnt = 0 for i in range(n): if i == n-3: break a_str = s[i] + s[i+1] + s[i+2] if a_str == 'ABC': cnt += 1 print(cnt) " p02812,s085353744,Wrong Answer,"import sys N = int(input()) S = input() array_S = list(S) if not ( 3 <= N <= 50 and S.isupper() ): sys.exit() count = 0 for I in range(N-3): if ''.join(array_S[I:I+3]) == 'ABC': count += 1 print(count)" p02812,s600168018,Wrong Answer,"n = int(input()) s = input() res = 0 phase = 0 for c in s: if c == ""A"" and phase == 0: phase = 1 continue elif c == ""B"" and phase == 1: phase = 2 continue elif c == ""C"" and phase == 2: res += 1 phase = 0 print(res)" p02812,s219401029,Wrong Answer,"N=int(input()) S=str(input()) count=0 if(N>3): for i in range(N-3): if(S[i:i+3]==""ABC""): count+=1 else: pass elif(N==3): if(S==""ABC""): count+=1 else: pass else: pass print(count)" p02812,s590351839,Wrong Answer,"s = input() N = len(s) ans = 0 if N < 3:print(0);exit() for i in range(N-2): if s[i]=='A' and s[i+1]=='B' and s[i+2] == 'C':ans += 1 print(ans) " p02812,s754395937,Wrong Answer,"n = input() s = input() ans = 0 for i in range(len(s)-3): if s[i:i+3] == 'ABC': ans += 1 print(ans)" p02812,s720323096,Wrong Answer,"import sys input = sys.stdin.readline def main(): N = int(input()) s = input().strip() ans = 0 for i in range(N-3): if s[i:i+3] == ""ABC"": ans += 1 print(ans) if __name__ == ""__main__"": main()" p02812,s347066317,Wrong Answer,"x=int(input()) s=input() c=0 for i in range(x-3): if s[i]==""A"" and s[i+1]==""B"" and s[i+2]==""C"": c+=1 print(c)" p03854,s471016156,Accepted,"S = input() S = S.replace('eraser','') S = S.replace('erase','') S = S.replace('dreamer','') S = S.replace('dream','') if S == '': print('YES') else:print('NO')" p03854,s848619344,Accepted,"s=input() ans=s.replace(""eraser"", """").replace(""erase"", """").replace(""dreamer"", """").replace(""dream"", """") print(""YES"" if not ans else ""NO"") " p03854,s271078865,Accepted,"s = input() while 1: for x in ('dream', 'dreamer', 'erase', 'eraser'): if s.endswith(x): s = s[:-len(x)] break else: print('NO') break if not s: print('YES') break" p03854,s772966828,Accepted,"S=input() S=S.replace(""eraser"","""") S=S.replace(""erase"","""") S=S.replace(""dreamer"","""") S=S.replace(""dream"","""") if len(S)==0: print(""YES"") else: print(""NO"")" p03854,s156540448,Accepted,"#!/usr/bin/env python3 import re s = input() while True: # s = re.sub('dream$|dreamer$|erase$|eraser$','',s) l = len(s) if s.rfind('dream') == l-5: s = s[:-5] elif s.rfind('dreamer') == l-7: s = s[:-7] elif s.rfind('erase') == l-5: s = s[:-5] elif s.rfind('eraser') == l-6: s = s[:-6] else: break if len(s)==0: print('YES') else: print('NO') " p03854,s373872699,Accepted,"S=input()[::-1] W=(""dream""[::-1],""dreamer""[::-1],""erase""[::-1],""eraser""[::-1]) ind=0 while ind 0: if s[i-5:i] == 'dream' or s[i-5:i] == 'erase': i -= 5 elif s[i-6:i] == 'eraser': i -= 6 elif s[i-7:i] == 'dreamer': i -= 7 else: print('NO') exit() print('YES')" p03854,s032316735,Accepted,"words = (""dream"",""dreamer"",""erase"",""eraser"") import sys readline = sys.stdin.readline S = readline().rstrip() stack = [0] while stack: ind = stack.pop() if ind == len(S): print(""YES"") break for w in words: if S[ind:ind + len(w)] == w: stack.append(ind + len(w)) else: print(""NO"")" p03854,s193230260,Accepted,"import re print(""YES"" if re.match(""^(dream|dreamer|erase|eraser)+$"", input()) else ""NO"")" p03854,s667950796,Accepted,"s=input() # dream dreamer erase eraser while len(s)>0: if (s[-1]==""r"") & (s[-7:]==""dreamer""): s=s[:-7] elif (s[-1]==""r"") & (s[-6:]==""eraser""): s=s[:-6] elif (s[-1]==""e"") & (s[-5:]==""erase""): s=s[:-5] elif (s[-1]==""m"") & (s[-5:]==""dream""): s=s[:-5] else: break if len(s)==0: print(""YES"") else: print(""NO"") " p03854,s624895203,Accepted,"data = input() tmp = data.replace('eraser', '') tmp = tmp.replace('erase', '') tmp = tmp.replace('dreamer', '') tmp = tmp.replace('dream', '') if tmp == '': print('YES') exit() print('NO')" p03854,s964213321,Accepted,"s=input() s=s[::-1] for i in range(100000): if s[:5] == 'maerd': s = s[5:] if s[:5] == 'esare': s = s[5:] if s[:6] == 'resare': s = s[6:] if s[:7] == 'remaerd': s = s[7:] if len(s)==0: print('YES') else: print('NO')" p03854,s822068989,Accepted,"s=input() while True: for flag in [""erase"",""eraser"",""dream"",""dreamer""]: if s.endswith(flag): s=s[:-len(flag)] break else: print(""NO"") break if len(s)==0: print(""YES"") break" p03854,s077645760,Accepted,"s = 'HAKUTYUMU' + input() while s != 'HAKUTYUMU': next_s = s if s[-5:] == 'dream': next_s = s[:-5] if s[-7:] == 'dreamer': next_s = s[:-7] if s[-5:] == 'erase': next_s = s[:-5] if s[-6:] == 'eraser': next_s = s[:-6] if s == next_s: print('NO') exit() s = next_s print('YES')" p03854,s655103773,Accepted,"s = input().replace(""eraser"","""").replace(""erase"","""").replace(""dreamer"","""").replace(""dream"","""") if s: print(""NO"") else: print(""YES"")" p03854,s899430048,Accepted,"s = input() s = s.replace(""eraser"", """").replace(""erase"", """").replace(""dreamer"", """").replace(""dream"", """") if len(s) > 0: print(""NO"") else: print(""YES"") " p03854,s258399532,Accepted,"import re s = input() ptn = re.compile(r'maerd|remaerd|resare|esare') tmp = s[::-1] while(True): res = re.match(ptn , tmp) if res is None: break tmp = tmp.replace(res.group(),'',1) if len(tmp) == 0: print('YES') else: print('NO')" p03854,s408059013,Accepted,"import re s = input() print(""YES"" if re.match(""(dream|dreamer|erase|eraser)+$"", s) else ""NO"")" 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')" 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') " p03854,s464994818,Accepted,"s=input() while len(s)>7: if s[-7:]==""dreamer"": s=s[:-7] elif s[-5:]==""dream"": s=s[:-5] elif s[-6:]==""eraser"": s=s[:-6] elif s[-5:]==""erase"": s=s[:-5] else: break if s in [""dreamer"",""dream"",""eraser"",""erase""]: print(""YES"") else: print(""NO"")" p03854,s225599297,Accepted,"s=input() l=len(s) while s!=0: l=len(s) if s.rfind(""dream"")==l-5: s=s[:l-5] elif s.rfind(""dreamer"")==l-7: s=s[:l-7] elif s.rfind(""erase"")==l-5: s=s[:l-5] elif s.rfind(""eraser"")==l-6: s=s[:l-6] else: break if len(s)==0: print(""YES"") else: print(""NO"") " p03854,s322148480,Accepted,"# -*- coding: utf-8 -*- # 整数の入力 s = input() words = [""dream"", ""dreamer"", ""erase"", ""eraser""] def check(): tmp = s while(True): current_len = len(tmp) for w in words: if tmp.endswith(w): tmp = tmp[:-len(w)] if len(tmp) == 0: return ""YES"" if current_len == len(tmp): return ""NO"" print(check()) " p03854,s263245811,Accepted,"s = input() ans = True while s != """": words = [""eraser"", ""dream"", ""erase"", ""dreamer""] found = False for word in words: if s[-len(word):] == word: s = s[:-len(word)] found = True break if not found: ans = False break print(""YES"" if ans else ""NO"")" p03854,s860862631,Accepted,"s = input() import re output =""NO"" s = re.sub('dreameraser', 'A', s) s = re.sub('dreamerase', 'A', s) s = re.sub('dreamer', 'A', s) s = re.sub('eraser', 'A', s) s = re.sub('erase', 'A', s) s = re.sub('dream', 'A', s) if s.isupper() : output = ""YES"" print(output)" p03854,s827875158,Accepted,"def main(S): listdreamereraser = ['dreamer','eraser','dream','erase'] while True: for i in listdreamereraser: if i in S[-len(i):]: S = S[:-len(i)] break else: return False if len(S) == 0: return True S = input() print('YES' if main(S) else 'NO')" p03854,s674825261,Accepted,"t=input() trigger=1 key='' d=-1 app=['dreamer','eraser','dream','erase'] 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 d=i break trigger-=1 if trigger==0 and d==0 and t[:3]=='ase': t='er'+t trigger+=1 if t=='': print('YES') else: print('NO')" p03854,s356284170,Accepted,"# ABC 049 C S = str(input()) ans = 'YES' while len(S)>0: if S[-5:] == 'dream': S = S[:-5] elif S[-5:] == 'erase': S = S[:-5] elif S[-6:] == 'eraser': S = S[:-6] elif S[-7:] == 'dreamer': S = S[:-7] else: ans = 'NO' break print(ans) " p03854,s772384714,Accepted,"import sys S = input() while S: if S[-1] == 'r': if S[-7:] == 'dreamer': S = S[:-7] elif S[-6:] == 'eraser': S = S[:-6] else: print('NO') sys.exit() elif S[-5:] == 'dream' or S[-5:] == 'erase': S = S[:-5] else: print('NO') sys.exit() print('YES')" p03854,s515842867,Accepted,"s=input() if len(s)<5: print('NO') exit() while len(s)>=5: if s[len(s)-5:len(s)]=='dream' or s[len(s)-5:len(s)]=='erase': s=s[:len(s)-5] elif len(s)>=6 and s[len(s)-6:len(s)]=='eraser': s=s[:len(s)-6] elif len(s)>=7 and s[len(s)-7:len(s)]=='dreamer': s=s[:len(s)-7] else: print('NO') exit() if len(s)==0: print('YES') else: print('NO')" p03854,s952117044,Accepted,"#!/usr/bin/env python3 import sys def main(): s = input().replace(""eraser"","""").replace(""erase"", """").replace(""dreamer"", """").replace(""dream"", """") ans = ""NO"" if s else ""YES"" print(ans) if __name__ == '__main__': main() " p03854,s102075657,Accepted,"s = input() s = s.replace('eraser', '') s = s.replace('erase', '') s = s.replace('dreamer', '') s = s.replace('dream', '') if s == '': print('YES') else: print('NO') " p03854,s113525391,Accepted,"S = input() Mozi = [""resare"",""esare"",""remaerd"",""maerd""] S = S[::-1] for i in Mozi: S = S.replace(i,"""") if not S: print(""YES"") else: print(""NO"")" p03854,s647458201,Accepted,"s = input() while True: if s.endswith(""dream""): s = s[:-5] elif s.endswith(""dreamer""): s = s[:-7] elif s.endswith(""erase""): s = s[:-5] elif s.endswith(""eraser""): s = s[:-6] elif not s: print(""YES"") break else: print(""NO"") break " p03854,s309403272,Accepted,"S = input () Z = ''.join(list(reversed(S))) Z = Z.replace('resare', '') Z = Z.replace('esare', '') Z = Z.replace('remaerd', '') Z = Z.replace('maerd', '') z = len (Z) if z == 0: print ('YES') else: print ('NO')" p03854,s319247033,Accepted,"import re s = input() str = [""dream"",""dreamer"",""erase"",""eraser""] str = [""maerd"",""remaerd"",""esare"",""resare""] s=s[::-1] while len(s)>0: if len(s) < 5: print(""NO"") break if s[0:7] == str[1] : s=s[7:] elif s[0:6] == str[3]: s=s[6:] elif s[0:5] == str[0] or s[0:5] == str[2]: s=s[5:] else: print(""NO"") break if len(s)==0: print(""YES"") break " p03854,s149282222,Accepted,"X=input() for i in range(len(X)): if X[-7:] == ""dreamer"": X = X[:-7] elif X[-6:] == ""eraser"": X = X[:-6] elif X[-5:] == ""dream"": X = X[:-5] elif X[-5:] == ""erase"": X = X[:-5] print(""YES"" if X=="""" else ""NO"") " p03854,s729822057,Accepted,"s = input() s = s.replace(""eraser"", """") s = s.replace(""erase"", """") s = s.replace(""dreamer"", """") s = s.replace(""dream"", """") if len(s) == 0: print(""YES"") else: print(""NO"")" p03854,s578138194,Accepted,"s = input() flag = True while s != """": if s[-5:] == ""dream"": s = s[:-5] elif s[-7:] == ""dreamer"": s = s[:-7] elif s[-5:] == ""erase"": s = s[:-5] elif s[-6:] == ""eraser"": s = s[:-6] else: flag = False break if flag: print(""YES"") else: print(""NO"")" p03854,s811257817,Accepted,"def main(): s = input().strip() while len(s): if s[-5:] in (""dream"", ""erase""): s = s[:-5] elif s[-6:] == ""eraser"": s = s[:-6] elif s[-7:] == ""dreamer"": s = s[:-7] else: print(""NO"") return print(""YES"") if __name__ == ""__main__"": main() " p03854,s453478734,Accepted,"S = input() T = '' words = ['dream', 'dreamer', 'erase', 'eraser'] for i in range(len(words)): words[i] = words[i][::-1] for i in S[::-1]: T += i for q in words: if T == q: T = '' if T == '': print('YES') else: print('NO') " p03854,s060675398,Accepted,"def resolve(): w = ['dream', 'dreamer', 'erase', 'eraser'] for i in range(len(w)): w[i] = w[i][::-1] s = input()[::-1] t = '' for i in s: t += i if t in w: t = '' if len(t): print(""NO"") else: print(""YES"") resolve()" p03854,s960268270,Accepted,"S = input() flg = 0 while flg==0: if S[len(S)-5:]==""dream"": S = S[:len(S)-5] elif S[len(S)-7:]==""dreamer"": S = S[:len(S)-7] elif S[len(S)-5:]==""erase"": S = S[:len(S)-5] elif S[len(S)-6:]==""eraser"": S = S[:len(S)-6] else: flg = 1 if len(S)==0: flg = 0 break if flg==0: print(""YES"") else: print(""NO"")" p03854,s568876193,Accepted,"s = input() for word in [""eraser"",""erase"",""dreamer"",""dream""]: s = s.replace(word,""."") if len(set(s)) == 1: print(""YES"") else: print(""NO"")" p03854,s415032478,Accepted,"S = input() while len(S) > 0: if (len(S) >= 5): if (S[-5:] == 'dream' or S[-5:] == 'erase'): S = S[:-5] continue if (len(S) >= 6): if (S[-6:] == 'eraser'): S = S[:-6] continue if (len(S) >= 7): if (S[-7:] == 'dreamer'): S = S[:-7] continue break if (len(S) == 0): print('YES') else: print('NO')" p03854,s135519212,Accepted,"s = input()[::-1] while True: if len(s) == 0: break if s[:7] == ""remaerd"": s = s[7:] elif s[:6] == ""resare"": s = s[6:] elif s[:5] == ""maerd"" or s[:5] == ""esare"": s = s[5:] else: print(""NO"") exit() print(""YES"")" p03854,s159837560,Accepted,"S = input() n = len(S) T = ['dreamer', 'eraser', 'dream', 'erase'] idx = n res = 'YES' while idx > 0: for t in T: if S[idx-len(t):idx] == t: idx -= len(t) break else: res = 'NO' idx = -1 print(res)" p03854,s713233816,Accepted,"from sys import stdin def S(): return stdin.readline().rstrip() a = S() strl = ['dream','dreamer','erase','eraser'] t = '' for i in range(len(a)-1,-1,-1): if 70: l=len(s) if s[l-5:]=='dream' or s[l-5:]=='erase': s=s[:l-5] elif s[l-6:]=='eraser': s=s[:l-6] elif s[l-7:]=='dreamer': s=s[:l-7] else: print('NO') exit() print('YES') " 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" p03854,s007978704,Accepted,"import re s = input() flag = re.match('^(dream|dreamer|erase|eraser)+$',s) if flag: print('YES') else: print('NO') " p03854,s722247596,Accepted,"S = input() S_ = (S .replace('eraser', '') .replace('erase', '') .replace('dreamer', '') .replace('dream', '') ) if S_ == '': print('YES') else: print('NO')" p03854,s776565477,Accepted,"import re S = input() ''' メタ文字: ^ = 文字列の先頭、 | = OR + = 直前のパターンを1回以上繰り返し、 $ = 文字列の末尾 ''' if re.match(""^(dream|dreamer|erase|eraser)+$"", S): print('YES') else: print('NO')" p03854,s834574830,Accepted,"S = input() k=0 t=len(S) while k 0): if(s.endswith(""dream"") or s.endswith(""erase"")): s = s[:(len(s)-5)] elif(s.endswith(""eraser"")): s = s[:(len(s)-6)] elif(s.endswith(""dreamer"")): s = s[:(len(s)-7)] else: yn = ""NO"" break print(yn)" p03854,s221617905,Accepted,"s = input()[::-1] templates = [s[::-1] for s in [""dream"", ""dreamer"", ""erase"", ""eraser""]] while s: for template in templates: if s.startswith(template): s = s.replace(template, """", 1) break else: break print(""YES"" if not s else ""NO"")" p03854,s526232810,Accepted,"import re S = input() print(""YES"" if re.match(""^(dream|dreamer|erase|eraser)+$"", S) else ""NO"") " p03854,s251773824,Accepted,"#ABC 049 C S = input() T = '' S = S[::-1] words = [""dream"",""dreamer"",""erase"",""eraser""] rev_words = [w[::-1] for w in words] flag = False i=0 while(1): for w in rev_words: s = S[i:i+len(w)] if s == w: flag = True T += w i += len(w) break if T == S: ans = ""YES"" break if flag == False: ans = 'NO' break flag = False print(ans) " p03854,s549586203,Accepted,"def I(): return int(input()) def MI(): return map(int, input().split()) def LMI(): return list(map(int, input().split())) MOD = 10 ** 9 + 7 S = input() S = ''.join(list(reversed(S))) while len(S) > 0: if S[:7] == 'remaerd': S = S[7:] elif S[:6] == 'resare': S = S[6:] elif S[:5] in ['esare', 'maerd']: S = S[5:] else: print('NO') exit(0) print('YES') " p03854,s240008746,Accepted,"import re print(""YES"" if re.match(""^(dream|dreamer|erase|eraser)+$"",input()) else ""NO"")" p03854,s724369674,Accepted,"#!/user/bin/env pypy3 import itertools import sys def fast_input(): return sys.stdin.readline()[:-1] def print_format(b: bool) -> str: return ""YES"" if b else ""NO"" def solve(s: str) -> bool: for p in itertools.permutations([""dreamer"", ""eraser"", ""dream"", ""erase""]): work = s for token in p: work = work.replace(token, '') if work == """": return True return False def main(): result = solve(fast_input()) print(print_format(result)) main() " p03854,s588278885,Accepted,"def main(): s = input() w = [""dream"", ""dreamer"", ""erase"", ""eraser""] last = len(s) for _ in range(len(s)): if last < 1: break for ww in w: if s[last - len(ww):] == ww: s = s[:last - len(ww)] last -= len(ww) print(""YES"" if last < 1 else ""NO"") if __name__ == '__main__': main() " p03854,s563056045,Accepted,"data = input() data = data.replace(""eraser"","""").replace(""erase"","""").replace(""dreamer"","""").replace(""dream"","""") if data: print(""NO"") else: print(""YES"")" p03854,s717324915,Accepted,"S = input() while len(S) > 0: if S[-5:] == 'dream': S = S[:-5] elif S[-5:] == 'erase': S = S[:-5] elif S[-7:] == 'dreamer': S = S[:-7] elif S[-6:] == 'eraser': S = S[:-6] else: print('NO') exit() print(""YES"")" p03854,s646734249,Accepted,"s = input() t = '' result = 'NO' scripts = ['dream', 'dreamer', 'erase', 'eraser'] for i in range(len(scripts)): script = scripts[i] script = script[::-1] scripts[i] = script s_rev = s[::-1] while len(s) > 0: for script in scripts: if s_rev[:len(script)] == script: s_rev = s_rev[len(script):] break else: break if s_rev == '': result = 'YES' print(result) " p03854,s388101318,Accepted,"# C 白昼夢 s = input()[::-1] cnt = 0 while cnt < len(s): if not s[cnt:cnt+7] == ""remaerd"": if not s[cnt:cnt+6] == ""resare"": if not s[cnt:cnt+5] in [""maerd"", ""esare""]: print(""NO"") exit() else: cnt += 5 else: cnt += 6 else: cnt += 7 print(""YES"")" 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')" p03854,s360884684,Accepted,"# coding: utf-8 """"""this is python work script"""""" def solver(word): """"""solve this problem"""""" check_result = word.replace('eraser', '').replace('erase', '').replace('dreamer', '').replace('dream', '') answer = 'YES' if check_result: answer = 'NO' return answer def main(): """"""main function"""""" input_word = input().rstrip() answer = solver(input_word) print(answer) if __name__ == '__main__': main() " p03854,s794885033,Accepted,"S = input() S = S.replace(""eraser"","""") S = S.replace(""erase"","""") S = S.replace(""dreamer"","""") S = S.replace(""dream"","""") if len(S) == 0: print(""YES"") else: print(""NO"") " p03854,s278032161,Accepted,"S = input() a = ['maerd', 'remaerd', 'esare', 'resare'] tmp ='' for s in S[::-1]: tmp += s if tmp in a: tmp='' print('YES' if len(tmp)==0 else'NO') " p03854,s928598702,Accepted,"s=input() s=s.replace(""eraser"","""") s=s.replace(""erase"","""") s=s.replace(""dreamer"","""") s=s.replace(""dream"","""") if s=="""": print(""YES"") else: print(""NO"")" p03854,s358903779,Accepted,"S=input() A=S.replace(""eraser"","""").replace(""erase"","""").replace(""dreamer"",""dream"").replace(""dream"","""") if A=="""": print(""YES"") else: print(""NO"")" p03854,s285994722,Accepted,"s=input().replace(""eraser"","""").replace(""erase"","""").replace(""dreamer"","""").replace(""dream"","""") if s: print(""NO"") else: print(""YES"")" p03854,s754787074,Accepted,"s=input().replace(""eraser"","""").replace(""erase"","""").replace(""dreamer"","""").replace(""dream"","""") if s: print(""NO"") else: print(""YES"")" p03854,s544215736,Accepted,"S = input()[::-1] W = [s[::-1] for s in ('dream', 'dreamer', 'erase', 'eraser')] def isOk(): now = 0 while now < len(S): for w in W: if S[now: now + len(w)] == w: now += len(w) break else: return False return True print('YES' if isOk() else 'NO') " p03854,s107243175,Accepted,"import re s = input() match = re.match(r""^(dream|dreamer|erase|eraser)+$"",s) print(""YES"" if match else ""NO"")" p03854,s963605918,Accepted,"a,b,c,d=[i[::-1] for i in ['dream','dreamer','erase','eraser']] s,j=input()[::-1],True while j: j=False for i in [a,b,c,d]: if s.startswith(i): s=s[len(i):];j=True print('YNEOS'[len(s)>0::2])" p03854,s607965220,Accepted,"s = input() x = s.replace(""eraser"", """").replace(""erase"", """").replace(""dreamer"", """").replace(""dream"", """") if x: print(""NO"") else: print(""YES"") " p03854,s304724526,Accepted,"s = input() s = s.replace('eraser', '') s = s.replace('erase', '') s = s.replace('dreamer', '') s = s.replace('dream', '') if s == '': print('YES') else: print('NO') " p03854,s076373875,Accepted,"S=input() i=0 ans=""YES"" while i=5: if len(S)>=7 and S[-7:]==""dreamer"": S=S[:-7] continue if len(S)>=6 and S[-6:]==""eraser"": S=S[:-6] continue elif S[-5:]==""dream"" or S[-5:]==""erase"": S=S[:-5] continue else: break if len(S)==0: print(""YES"") else: print(""NO"")" 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') " p03854,s784663797,Accepted,"S=input() W=[0]*(len(S)+1) W[0]=1 words=['dream','dreamer','erase','eraser' ] for i in range(len(S)): if W[i]==0: continue for k in words: if S[i:i+len(k)]==k: W[i+len(k)]=1 if W[len(S)]==1: print(""YES"") exit() else: print(""NO"") " p03854,s031400903,Accepted,"s=input() newstring=''.join(list(reversed(s))) while len(newstring)>0: if newstring[:5]==""maerd"": newstring=newstring[5:] elif newstring[:7]==""remaerd"": newstring=newstring[7:] elif newstring[:5]==""esare"": newstring=newstring[5:] elif newstring[:6]==""resare"": newstring=newstring[6:] else: print(""NO"") exit() print(""YES"")" p03854,s176876380,Accepted,"text = """".join(reversed(input())) words = ["""".join(reversed(x)) for x in [""dreamer"", ""eraser"", ""dream"", ""erase""]] while text != """": has_striped = False for word in words: if text.find(word) != 0: continue text = text[len(word):] has_striped = True if not has_striped: break print(""YES"" if text == """" else ""NO"")" p03854,s169820722,Accepted,"S = input() S = S.replace('eraser', ' ').replace('erase', ' ').replace('dreamer', ' ').replace('dream', ' ').replace(' ', '') if S == '': print('YES') else: print('NO')" p03854,s099606373,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')" p03854,s616061677,Accepted,"s = list(input()) n = len(s) temp = ['maerd', 'remaerd', 'esare', 'resare'] s.reverse() i = 0 while i < n: flag = False for t in temp: if s[i:i+len(t)] == list(t): i += len(t) flag = True break if not flag: print(""NO"") exit() print(""YES"") " p03854,s263134493,Accepted,"s=input() n=len(s) i=1 for j in range(n): if s[-i:-i-5:-1]==""maerd"": i+=5 if s[-i:-i-5:-1]==""esare"": i+=5 if s[-i:-i-6:-1]==""resare"": i+=6 if s[-i:-i-7:-1]==""remaerd"": i+=7 if i==n+1: print(""YES"") break if i != n+1: print(""NO"")" p03854,s336622376,Accepted,"import re # 正規表現 s = input() # re.sub(pattern, word, line) はlineのうち、patternに一致する部分をwordに変換します。 s = re.sub('eraser', '', s) s = re.sub('erase', '', s) s = re.sub('dreamer', '', s) s = re.sub('dream', '', s) print('YES' if len(s) == 0 else 'NO') " p03854,s926189076,Accepted,"def main(): import sys def input(): return sys.stdin.readline().rstrip() s = input() word = ['eraser', 'erase', 'dreamer', 'dream'] for x in word: s = s.replace(x, '') if s == '': print('YES') else: print('NO') if __name__ == '__main__': main()" p03854,s317208659,Accepted,"#!/usr/bin/env python # coding: utf-8 # In[1]: S = input() # In[4]: f = True s_reversed = S[::-1] words = ['maerd', 'remaerd', 'esare', 'resare'] while s_reversed: length = len(s_reversed) for i in [7,6,5]: while s_reversed[:i] in words: s_reversed = s_reversed[i:] if length == len(s_reversed): print(""NO"") f = False break if f: print(""YES"") # In[ ]: " p03854,s907580870,Accepted,"s = input().replace('eraser', '').replace('erase', '').replace('dreamer', '').replace('dream', '') if s: print('NO') else: print('YES') " p03854,s727785185,Accepted,"import re s = input() print(""YES"" if re.match(""^(dream|dreamer|erase|eraser)+$"", s) else ""NO"") " p03854,s749674023,Accepted,"print('NO' if input().replace('eraser','').replace('erase','').replace('dreamer','').replace('dream','') else 'YES')" p03854,s388531635,Accepted,"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()) S = S() while 1: for flag in (""erase"", ""eraser"", ""dream"", ""dreamer""): if S.endswith(flag): S = S[:-len(flag)] break else: print('NO') break if not S: print('YES') break " 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() " p03854,s691331834,Accepted,"#!/usr/bin/env python3 vocab = set(['dream', 'dreamer', 'erase', 'eraser']) def parse(s): stack = [0] while stack: i = stack.pop() if i == len(s): return True for w in vocab: if s[i:].startswith(w): stack.append(i + len(w)) return False s = input() if parse(s): print('YES') else: print('NO')" p03854,s053038048,Accepted,"s = input()[::-1] word = [""dream"", ""dreamer"", ""erase"", ""eraser""] dream = ""dream""[::-1] dreamer = ""dreamer""[::-1] erase = ""erase""[::-1] eraser = ""eraser""[::-1] while True: if s[:5] == dream or s[:5] == erase: s = s[5:] continue elif s[:6] == eraser: s = s[6:] continue elif s[:7] == dreamer: s = s[7:] continue break if len(s) == 0: print(""YES"") else: print(""NO"")" p03854,s680907282,Accepted,"s=input().strip() s=s.replace(""eraser"",""A"") s=s.replace(""erase"",""A"") s=s.replace(""dreamer"",""A"") s=s.replace(""dream"",""A"") print(""YES"" if not s.replace(""A"","""") else ""NO"")" p03854,s683189627,Accepted,"s=input().replace(""eraser"","""").replace(""erase"","""").replace(""dreamer"","""").replace(""dream"","""") if s: print(""NO"") else: print(""YES"")" p03854,s137923219,Accepted,"s = input() s = s.replace('eraser', '') s = s.replace('erase', '') s = s.replace('dreamer', '') s = s.replace('dream', '') if len(s) == 0: print('YES') else: print('NO') " p03854,s618661865,Accepted,"S = input()[::-1] ss = ['maerd', 'remaerd', 'esare', 'resare'] while True: for s in ss: if S.startswith(s): S = S[len(s):] break else: if S != '': print('NO') break if S == '': print('YES') break " p03854,s671370708,Accepted,"import sys t = set('dream, dreamer, erase, eraser'.split(', ')) def obtainable(s): while True: for i in range(5, 8): if s[-i:] in t: s = s[:-i] break else: return False if not s: return True s = sys.stdin.readline().rstrip() def main(): print(""YES"" if obtainable(s) else ""NO"") if __name__ == '__main__': main()" p03854,s377323748,Accepted,"#!/usr/bin/env python3 import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines S = input() words = ('dream', 'dreamer', 'erase', 'eraser') while True: if S == '': print(""YES"") break for word in words: if S.endswith(word): S = S[:-len(word)] break else: print(""NO"") break " p03854,s882755798,Accepted,"S = input()[::-1] W = ['dream','dreamer','erase','eraser'] i = 0 while i < len(S): for w in W: if S[i:i+len(w)] == w[::-1]: i += len(w) break else: print('NO') exit() print('YES')" p03854,s214022335,Accepted,"S = input() T = [""dream"", ""dreamer"", ""erase"", ""eraser""] S = S[::-1] for i in range(4): T[i] = T[i][::-1] can = True i = 0 while i < len(S): can2 = False for t in T: if S[i:i + len(t)] == t: can2 = True i += len(t) - 1 if can2 == False: can = False break i += 1 if can: print(""YES"") else: print(""NO"") " p03854,s405301245,Accepted,"print(""NO"" if input().replace(""eraser"", """").replace(""erase"", """").replace(""dreamer"", """").replace(""dream"", """") else ""YES"")" p03854,s786916232,Accepted,"S = str(input()) S = S.replace('eraser', '') S = S.replace('erase', '') S = S.replace('dreamer', '') S = S.replace('dream', '') if S == '': print('YES') else: print('NO')" p03854,s706564869,Accepted,"s = input()[::-1] while s: start = len(s) for t in ['maerd', 'remaerd', 'esare', 'resare']: if t == s[:len(t)]: s = s[len(t):] if start == len(s): break print(""YNEOS""[len(s)>0::2])" p03854,s090187090,Accepted,"S = input() if len(S) == 0: print('NO') else: if len(S.replace('eraser', '').replace('erase', '').replace('dreamer', '').replace('dream', '')) == 0: print('YES') else: print('NO')" p03854,s452264262,Accepted,"s = input() i = len(s) while i > 0: if s[i-5:i] == 'dream': i -= 5 continue elif s[i - 7:i] == 'dreamer': i -= 7 continue elif s[i-5: i] == 'erase': i -= 5 continue elif s[i-6: i] == 'eraser': i -= 6 continue else: print('NO') exit(0) print('YES')" p03854,s904352639,Accepted,"import re s = input() m = re.fullmatch(r""(dreamer|dream|erase|eraser)+"", s) if m: print(""YES"") else: print(""NO"") " p03854,s808027523,Accepted,"S = input()[::-1] kari = ['dream', 'dreamer', 'erase', 'eraser'] words = [i[::-1] for i in kari] l = len(S) cnt = '' for i in range(l): cnt += S[i] if cnt in words: cnt = '' if cnt!='': print('NO') else: print('YES')" p03854,s859016632,Accepted,"words = [""dream"", ""dreamer"", ""erase"", ""eraser""] #5 #7 #5 #6 s = input() while len(s) > 0: if s[-5:] in words: s = s[:-5] elif s[-6:] in words: s = s[:-6] elif s[-7:] in words: s = s[:-7] else: print(""NO"") exit() print(""YES"") " p03854,s279725213,Accepted,"s = input() s = s.replace('eraser', '') s = s.replace('erase', '') s = s.replace('dreamer', '') s = s.replace('dream', '') if len(s) == 0: print('YES') else: print('NO') " p03854,s238063187,Accepted,"s=input().replace(""eraser"",""0"").replace(""erase"",""0"").replace(""dreamer"",""0"").replace(""dream"",""0"").replace(""0"", """") if s: print(""NO"") else: print(""YES"")" p03854,s299764701,Accepted,"#!/usr/bin/env python3 import re s = input() s = re.sub(r'erase(r|)',"""", s) s = re.sub(r'dream(er|)',"""", s) print('YNEOS'[s!=""""::2]) " p03854,s439282584,Accepted,"s = input() s = s[::-1] i = 0 check = True while i < len(s): if s[i:i+5] == ""maerd"" or s[i:i+5] ==""esare"": i += 5 elif s[i:i+6] == ""resare"": i += 6 elif s[i:i+7] == ""remaerd"": i += 7 else: check = False break if check == True: print(""YES"") else: print(""NO"")" p03854,s033243313,Accepted,"import re sin = input() match = re.match(r""^(dream|dreamer|erase|eraser)+$"",sin) print(""YES"" if match else ""NO"")" p03854,s454299647,Accepted,"check = ['dream', 'dreamer', 'erase', 'eraser'] s=input() end = len(s) while 0 < end: if s[end-5:end] in check: end -= 5 elif s[end-6:end] in check: end -= 6 elif s[end-7:end] in check: end -= 7 else: print('NO') exit() print('YES')" p03854,s743628039,Accepted,"S = input() t1 = ""dream"" t2 = ""dreamer"" t3 = ""erase"" t4 = ""eraser"" while True: if S[-5:] == t1 or S[-5:] == t3: S = S[0:-5] elif S[-6:] == t4: S = S[0:-6] elif S[-7:] == t2: S = S[0:-7] elif len(S) == 0: print(""YES"") break else: print(""NO"") break " p03854,s460199768,Accepted,"#白昼夢 s = input() words = ['dream','dreamer','erase','eraser'] #evaluate while True: for i in range(4): if s.endswith(words[i]): s = s[:-len(words[i])] break #inner loop else: print('NO') break #outerloop if not s: print('YES') break #outerloop " p03854,s316572830,Accepted,"s = list(input()) a = list(""dream"") b = list(""dreamer"") c = list(""erase"") d = list(""eraser"") flag = 0 while(flag == 0): if s[-7:] == b: del s[-7:] elif s[-6:] == d: del s[-6:] elif s[-5:] == a or s[-5:] == c: del s[-5:] elif s == []: print(""YES"") flag = 1 else: print(""NO"") flag = 1" 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"") " p03854,s808767484,Accepted,"words = ['maerd', 'remaerd', 'esare', 'resare'] S = input() T = '' for a in S[::-1]: T += a for s in words: if T == s: T = '' print('YES' if T == '' else 'NO')" p03854,s564027812,Accepted,"s=input() while len(s)>7: if s[-7:]==""dreamer"": s=s[:-7] elif s[-5:]==""dream"": s=s[:-5] elif s[-6:]==""eraser"": s=s[:-6] elif s[-5:]==""erase"": s=s[:-5] else: break if s in [""dreamer"",""dream"",""eraser"",""erase""]: print(""YES"") else: print(""NO"")" p03854,s773850422,Accepted,"import re print(""YES"" if re.match(""^(dream|dreamer|erase|eraser)+$"",input()) else ""NO"")" p03854,s065201223,Accepted,"import sys s=input() lens=len(s) while lens>0: lens0=lens if s[lens-7:lens]==""dreamer"": lens=lens-7 elif s[lens-5:lens]==""dream"": lens=lens-5 elif s[lens-6:lens]==""eraser"": lens=lens-6 elif s[lens-5:lens]==""erase"": lens=lens-5 if lens0==lens: print(""NO"") sys.exit() print(""YES"") " p03854,s090153094,Accepted,"import re S = input() ''' メタ文字: ^ = 文字列の先頭、 | = OR + = 直前のパターンを1回以上繰り返し、 $ = 文字列の末尾 ''' if re.match(""^(dream|dreamer|erase|eraser)+$"", S): print('YES') else: print('NO')" p03854,s341757762,Accepted,"s = input() s = s.replace(""eraser"", ""X"") s = s.replace(""erase"", ""X"") s = s.replace(""dreamer"", ""X"") s = s.replace(""dream"", ""X"") count = s.count(""X"") if len(s) == count: print(""YES"") else: print(""NO"")" p03854,s653569608,Accepted,"S = input() candidates = ['dream', 'dreamer', 'erase', 'eraser'] while S: for candidate in candidates: if S.endswith(candidate): S = S[:-len(candidate)] break else: break if S: print('NO') else: print('YES')" p03854,s465499957,Accepted,"S = input() def check(t): if len(t) >= 5 and (t[-5:] == 'dream' or t[-5:] == 'erase'): return True,t[:-5] elif len(t) >=6 and t[-6:] == 'eraser': return True,t[:-6] elif len(t) >= 7 and t[-7:] == 'dreamer': return True,t[:-7] else: return False,t while(len(S) > 0): flag,S = check(S) if not flag: print('NO') exit() print('YES') " p03854,s014829818,Accepted,"a = input() b = a[::-1] i = 0 while i < len(b): if b[i:i+5] == ""esare"": i += 5 elif b[i:i+5] == ""maerd"": i += 5 elif b[i:i+6] == ""resare"": i += 6 elif b[i:i+7] == ""remaerd"": i += 7 else: ans = ""NO"" break if i == len(b): ans = ""YES"" else: ans = ""NO"" print(ans)" p03854,s791882215,Accepted,"s = input() s = s.replace('eraser', '') s = s.replace('erase', '') s = s.replace('dreamer', '') s = s.replace('dream', '') if s == '': print('YES') else: print('NO') " p03854,s185444262,Accepted,"S = input().replace('eraser', '!').replace('erase', '!').replace('dreamer', '!').replace('dream', '!').replace('!', '') if len(S) == 0: print('YES') else: print('NO')" p03854,s894033736,Accepted,"s = input() s = s.replace('eraser', '') s = s.replace('erase', '') s = s.replace('dreamer', '') s = s.replace('dream', '') if len(s) == 0: print('YES') else: print('NO')" p03854,s746478961,Accepted,"s=input() s=s.replace('eraser','') s=s.replace('erase','') s=s.replace('dreamer','') s=s.replace('dream','') if s: print(""NO"") else: print(""YES"")" p03854,s029006689,Accepted,"S = input() S = S[::-1] T = ['dream', 'dreamer', 'erase', 'eraser'] T_rev = [] for i in range(len(T)): T_rev.append(T[i][::-1]) flag = True i = 0 while i < len(S): for j in range(len(T)): ed = i + len(T_rev[j]) # print(S[i:ed]) if (S[i:(i + len(T_rev[j]))] == T_rev[j]): i += len(T[j]) flag = True break else: flag = False if(flag == False): break if(flag): print('YES') else: print('NO')" p03854,s450890009,Accepted,"s=input() l=len(s) def judge(): cnt=0 while True: if s[l-cnt-6:l-cnt]=='eraser': cnt+=6 elif s[l-cnt-5:l-cnt]=='erase': cnt+=5 elif s[l-cnt-7:l-cnt]=='dreamer': cnt+=7 elif s[l-cnt-5:l-cnt]=='dream': cnt+=5 else: print('NO') exit() if cnt==len(s): print('YES') exit() judge()" p03854,s969966551,Accepted,"s = input() temp = s while len(temp) > 4: if temp[len(temp) - 3:] == 'eam' and temp[len(temp) - 5:] == 'dream': temp = temp[: len(temp) - 5] elif temp[len(temp) - 3:] == 'mer' and temp[len(temp) - 7:] == 'dreamer': temp = temp[: len(temp) - 7] elif temp[len(temp) - 3:] == 'ase' and temp[len(temp) - 5:] == 'erase': temp = temp[: len(temp) - 5] elif temp[len(temp) - 3:] == 'ser' and temp[len(temp) - 6:] == 'eraser': temp = temp[: len(temp) - 6] else: break if len(temp) > 4: print('NO') else: print('YES')" p03854,s293726381,Accepted,"s = input()[::-1] x = [""dream"", ""dreamer"", ""erase"", ""eraser""] can = True i = 0 for a in range(4): x[a] = x[a][::-1] while(True): if(i == len(s)): break can2 = False for j in range (4): if(s[i:i+len(x[j])] == x[j]): can2 = True i += len(x[j]) if(can2 == False): can = False break print(""YES"" if can == True else ""NO"") " p03854,s659314070,Accepted,"s = input()[::-1] # 反転 template = list('dream dreamer erase eraser'.split()) template = [c[::-1] for c in template] # 反転 while s: for c in template: if s.startswith(c): s = s[len(c):] break else: break print(""YES"") if s == """" else print(""NO"") " 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"")" p03854,s386837947,Accepted,"s = input() ans = 'YES' while len(s) > 0: if s.endswith('dreamer'): s = s[:-7] elif s.endswith('dream'): s = s[:-5] elif s.endswith('eraser'): s = s[:-6] elif s.endswith('erase'): s = s[:-5] else: ans = 'NO' break print(ans)" 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)" p03854,s764697352,Accepted,"def main(): s = input() words = [""eraser"", ""erase"", ""dreamer"", ""dream""] for word in words: s = s.replace(word, """") print(""YES"" if len(s) == 0 else ""NO"") if __name__ == ""__main__"": main() " p03854,s302194136,Accepted,"s = input() a = s.replace('eraser','') b = a.replace('erase','') c = b.replace('dreamer','') d = c.replace('dream','') if d == '': print('YES') else: print('NO') " p03854,s251235689,Accepted,"s = input() def solve(query): while 1: for frag in (""erase"", ""eraser"", ""dream"", ""dreamer""): if query.endswith(frag): query = query[:-len(frag)] break else: print(""NO"") break if not query: print(""YES"") break solve(s)" p03854,s845817787,Accepted,"s = input() s = s.replace('eraser', '') s = s.replace('erase', '') s = s.replace('dreamer', '') s = s.replace('dream', '') if s == '': print('YES') else: print('NO')" p03854,s166280766,Accepted,"S = input() a = 'dream' b = 'dreamer' c = 'erase' d = 'eraser' T = S while len(T) > 4: if S[len(T)-5:len(T)] == a: T = T[0:len(T)-5] elif S[len(T)-7:len(T)] == b: T = T[0:len(T)-7] elif S[len(T)-5:len(T)] == c: T = T[0:len(T)-5] elif S[len(T)-6:len(T)] == d: T = T[0:len(T)-6] else: break if T == '': print('YES') else: print('NO')" p03854,s988935369,Accepted,"S = input() dp = [0] * (len(S) + 1) dp[0] = 1 words = [""dream"", ""dreamer"", ""erase"", ""eraser""] done = 'NO' for i in range(len(S)): if dp[i] == 0: continue for w in words: if S[i:i+len(w)] == w: dp[i+len(w)] = 1 if dp[len(S)] == 1: done = 'YES' break print(done)" p03854,s830486195,Accepted,"import re s = input() if re.match(""(dream|dreamer|erase|eraser)+$"", s): print(""YES"") else: print(""NO"")" p03854,s351832832,Accepted,"def main(): S = input() border = len(S) while True: if S[border - 5: border] == ""dream"": border -= 5 elif S[border - 7: border] == ""dreamer"": border -= 7 elif S[border - 5: border] == ""erase"": border -= 5 elif S[border - 6: border] == ""eraser"": border -= 6 else: break if border == 0: print(""YES"") else: print(""NO"") if __name__ == ""__main__"": main()" 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)" p03854,s509129875,Accepted,"divide = [""dream"", ""dreamer"", ""erase"", ""eraser""] S = input()[::-1] for i in range(4): divide[i] = divide[i][::-1] can = True i = 0 while i < len(S): can2 = False for d in divide: if S[i:i+len(d)] == d: can2 = True break i += len(d)*(can2) if not can2: can = False break print(""YNEOS""[~can%2::2])" p03854,s185276902,Accepted,"def check(): S = input() n = len(S) dp = [False]*(n+10) dp[0] = True for i in range(n+1): if S[i:i+5]=='dream': dp[i+5] |= dp[i] if S[i:i+7]=='dreamer': dp[i+7] |= dp[i] if S[i:i+5]=='erase': dp[i+5] |= dp[i] if S[i:i+6]=='eraser': dp[i+6] |= dp[i] if dp[n]==True: return 'YES' return 'NO' print(check())" p03854,s187519382,Accepted,"# dfs import sys sys.setrecursionlimit(10**6) C = ['dream', 'dreamer', 'erase', 'eraser'] S = input() L = len(S) def dfs(x, l): if l == L: return True elif l > L: return False match = S[l:l+7] for c in C: if match.find(c) == 0: if dfs(c, l+len(c)): return True return False print('YES' if dfs('', 0) else 'NO') " p03854,s020838985,Accepted,"s=input() import re #re.match は複数を対象にすればマッチする該当のものが返される。一つの時ifの後に持ってくると条件式として利用可能。 if re.match(""^(dream|dreamer|erase|eraser)+$"",s) : print(""YES"") else: print(""NO"") " p03854,s302764228,Accepted,"import sys sys.setrecursionlimit(10**6) s = input() def dfs(s): while True: f = True for i in ['dream', 'dreamer', 'erase', 'eraser']: if s[-len(i):]==i: s = s[:-len(i)] if s=='': return True f = False if f: return False if dfs(s): print('YES') else: print('NO')" p03854,s216998796,Accepted,"import re print(""YES"" if re.match(""^(dream|dreamer|erase|eraser)+$"",input()) else ""NO"")" p03854,s180578389,Accepted,"s = input() s = s.replace('eraser', '') s = s.replace('erase', '') s = s.replace('dreamer', '') s = s.replace('dream', '') if len(s) == 0: print('YES') else: print('NO') " p03854,s421843409,Accepted,"s = input() while s!="""": if s[-5:]==""dream"" or s[-5:]==""erase"": s = s[:-5] elif s[-6:]==""eraser"": s = s[:-6] elif s[-7:]==""dreamer"": s = s[:-7] else: print(""NO"") exit() print(""YES"") " 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() " p03854,s586254078,Accepted,"import re S = input() if re.match(""^(dream|dreamer|erase|eraser)+$"", S): print(""YES"") else: print(""NO"")" p03854,s966772356,Accepted,"s = list(input()) words = ['dream', 'dreamer', 'erase', 'eraser'] ans = 'YES' pointer = len(s) while pointer > 0: if s[pointer-5: pointer] == list(words[0]): pointer -= 5 elif s[pointer-5: pointer] == list(words[2]): pointer -= 5 elif s[pointer-7: pointer] == list(words[1]): pointer -= 7 elif s[pointer-6: pointer] == list(words[3]): pointer -= 6 else: ans = 'NO' break print(ans) " p03854,s405319297,Accepted,"def main(): S = input() while len(S)>=5: if len(S)>=7 and S[-7:]==""dreamer"": S = S[:-7] continue elif len(S)>=6 and S[-6:]==""eraser"": S = S[:-6] continue elif S[-5:]==""dream"" or S[-5:]==""erase"": S = S[:-5] continue else: break if len(S)==0: print('YES') else: print('NO') main() " p03854,s361345396,Accepted,"import sys S = input() while len(S)>5: if S[-7:] == ""dreamer"": S = S[:-7] elif S[-6:] == ""eraser"": S = S[:-6] elif S[-5:] == ""dream"" or S[-5:] == ""erase"": S = S[:-5] else: print(""NO"") sys.exit() print(""YES"")" p03854,s340690799,Accepted,"import re s = input() m = re.match(r""^(dream|dreamer|erase|eraser)+$"", s) print(""NO"" if m is None else ""YES"")" p03854,s713781883,Accepted,"S = input() x = S.replace('eraser', '').replace('erase', '').replace('dreamer','').replace('dream','') print('YES' if not x else 'NO')" p03854,s265553658,Accepted,"s,f=input()[::-1],-1 while f<0: if s: if s[:5]=='maerd': s=s[5:] elif s[:5]=='esare': s=s[5:] elif s[:6]=='resare': s=s[6:] elif s[:7]=='remaerd': s=s[7:] else: f=0 else: f=1 print(['NO','YES'][f])" p03854,s383595225,Accepted,"S = input().replace('eraser','').replace('erase','').replace('dreamer','').replace('dream','') if S == '': print('YES') else: print('NO') " p03854,s591343695,Accepted,"S = input() T = ['dream', 'dreamer', 'erase', 'eraser'] def reverse(t): return t[::-1] RT = [reverse(t) for t in T] RS = reverse(S) can = True i = 0 while i < len(RS): can2 = False for j in range(4): sizeT = len(RT[j]) if RT[j] == RS[i:i + sizeT]: i += sizeT can2 = True break if not can2: can = False break if can: print('YES') else: print('NO') " p03854,s995405736,Accepted,"S = input().replace(""eraser"", """").replace(""erase"", """").replace(""dreamer"", """").replace(""dream"", """") if S: print(""NO"") else: print(""YES"") " p03854,s178753359,Accepted,"s = list(input());tmp = """" t = [""maerd"", ""remaerd"", ""esare"", ""resare""] while s: tmp += s.pop() if tmp in t: tmp = """" if len(tmp)>=7: print(""NO"") else: print(""YES"")" p03854,s700907519,Accepted,"S = input() C = ['dream', 'dreamer', 'erase', 'eraser'] while S: for c in C: if S.endswith(c): S = S[:-len(c)] break else: print('NO') break else: print('YES') " p03854,s326066559,Accepted,"S = input() # Greedyアルゴリズム S = S[::-1] S = S.replace(""resare"","""") S = S.replace(""esare"","""") S = S.replace(""remaerd"","""") S = S.replace(""maerd"","""") if S == """": print(""YES"") else: print(""NO"") " p03854,s163713365,Accepted,"s = str(input()) alist = [""dream"", ""dreamer"", ""erase"", ""eraser""] ans = False def backwards(x): return x[::-1] s = backwards(s) alist = [backwards(i) for i in alist] t = """" start = 0 for i in range(len(s)+1): if s[start:i] in alist: t+=s[start:i] start = i if s==t: print(""YES"") else: print(""NO"")" p03854,s044559746,Accepted,"import re S = input() S = re.sub(""eraser"", """", S) S = re.sub(""erase"", """", S) S = re.sub(""dreamer"", """", S) S = re.sub(""dream"", """", S) print(""YES"" if len(S) == 0 else ""NO"")" p03854,s820408596,Accepted,"s=input() List=[""eraser"",""erase"",""dreamer"",""dream""] for item in List: s = s.replace(item,'') if len(s)==0: print('YES') else: print('NO')" p03854,s627356491,Accepted,"s = input() s1 = s.replace(""eraser"", 'xxx') s2 = s1.replace(""erase"", 'xxx') s3 = s2.replace(""dreamer"", 'xxx') s4 = s3.replace(""dream"", 'xxx') s5 = s4.strip('x') if (s5 == ''): 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') " p03854,s366164377,Accepted,"s = input() s_1 = s.replace('eraser', '').replace('erase', '').replace('dreamer','').replace('dream','') if s_1 == '': print(""YES"") else: print(""NO"")" 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" p03854,s505972643,Accepted,"S = input()[::-1] D = [""dream""[::-1], ""dreamer""[::-1], ""erase""[::-1], ""eraser""[::-1]] while True: for d in D: if S.startswith(d): S = S.replace(d, """", 1) break else: break print(""YNEOS""[S!=""""::2])" p03854,s150189826,Accepted,"import re;print(""YNEOS""[re.match(""(erase(r)?|dream(er)?)+$"",input())is None::2]) " p03854,s823293495,Accepted,"s3=s=input()[::-1] l=[""maerd"",""remaerd"",""esare"",""resare""] s2="""" for i in range(len(s)): s2+=s[i] if s2 in l: s3=s3[len(s2):] s2="""" print(""YES""if s2==""""else ""NO"") " p03854,s870118663,Accepted,"S = input() idx = len(S) ans = 'YES' while idx > 0: if S[idx-5:idx] == 'dream': idx -= 5 elif S[idx-5:idx] == 'erase': idx -= 5 elif S[idx-7:idx] == 'dreamer': idx -= 7 elif S[idx-6:idx] == 'eraser': idx -= 6 else: ans = 'NO' break print(ans)" p03854,s070843406,Accepted,"S = input() i = 0 n = len(S) while i <= n-5: if S[i:i+5] == ""dream"": i += 5 if S[i:i+2] == ""er"" and S[i:i+5] != ""erase"": i += 2 elif S[i:i+5] == ""erase"": i += 5 if S[i:i+1] == ""r"": i += 1 else: break if i != len(S): print(""NO"") else: print(""YES"")" p03854,s149660296,Accepted,"S = input() while 1: for target in [""dream"", ""dreamer"", ""erase"", ""eraser""]: if S.endswith(target): S = S[:-len(target)] break else: print(""NO"") break if len(S) == 0: print(""YES"") break" p03854,s130460307,Accepted,"patterns = [[5, ""dream""], [7, ""dreamer""], [5, ""erase""], [6, ""eraser""]] s = input() idx = len(s) while idx > 0: for sub, pat in patterns: n_idx = idx - sub if pat == s[n_idx:idx]: idx = n_idx break else: continue if idx != n_idx: break print(""YES"" if idx == 0 else ""NO"") " p03854,s399276306,Accepted,"S = input() num_eraser = S.count('eraser') num_erase = S.count('erase') - num_eraser num_dreamer = S.count('dreamer') - S.count('dreamerase') num_dream = S.count('dream') - num_dreamer # dream + erase(r) で dreamer が含まれるのに注意 # print(num_eraser, num_erase, num_dreamer, num_dream) cnt = num_eraser * 6 + num_erase * 5 + num_dreamer * 7 + num_dream * 5 # print('cnt', cnt) if len(S) == cnt: print('YES') else: print('NO') " p03854,s236476538,Accepted,"s = input()[::-1] n = len(s) l = 0 ok = True while l L: return False for c in C: if S.find(c, l, l+7) == l: if dfs(l+len(c)): return True return False print('YES' if dfs(0) else 'NO') " p03854,s747670128,Accepted,"s = input() y = 0 while y < len(s): if s[y:y+11] == ""dreameraser"": y += 11 elif s[y:y+10] == ""dreamerase"": y += 10 elif s[y:y+7] == ""dreamer"": y += 7 elif s[y:y+6] == ""eraser"": y += 6 elif s[y:y+5] == ""dream"" or s[y:y+5] == ""erase"": y += 5 else: print(""NO"") break else: print(""YES"")" p03854,s044986659,Accepted,"S = input()[::-1] Tl = [""dream"", 'dreamer', 'erase', 'eraser'] flg = 0 for i in range(len(Tl)): Tl[i] = Tl[i][::-1] while True: Sl = len(S) for i in range(len(Tl)): if S.find(Tl[i]) == 0: S = S[len(Tl[i]):] if len(S) == 0: flg = 1 break elif len(S) == Sl: break else: pass if flg == 1: print(""YES"") else: print(""NO"") " p03854,s510513523,Accepted,"s = str(input()) s = ''.join(list(reversed(s))) t = 0 while t <= len(s): if s[t:t+5] == 'maerd': t += 5 continue elif s[t:t+7] == 'remaerd': t += 7 continue elif s[t:t+5] == 'esare': t += 5 continue elif s[t:t+6] == 'resare': t += 6 continue elif t == len(s): print('YES') quit() else: break print('NO')" p03854,s957076286,Accepted,"S = input() list = [""eraser"",""erase"",""dreamer"",""dream""] for x in list: S = S.replace(x,"""") if len(S) == 0: print(""YES"") else: print(""NO"") " p03854,s498714420,Accepted,"s = input() while True: if s == """": print('YES') break elif s[-7:] == 'dreamer': s = s[:-7] elif s[-6:] == 'eraser': s = s[:-6] elif s[-5:] == 'dream' or s[-5:] == 'erase': s = s[:-5] else: print('NO') break " p03854,s364404406,Accepted,"import re s = input() s = s[::-1] #print(s) match = re.match('((remaerd)|(maerd)|(resare)|(esare))*',s) #print(match) #print(match.group()) if match.group() == s: print('YES') else: print('NO')" p03854,s902555094,Accepted,"s = list(input()) s.reverse() s_r = """" for i in s: s_r+=i s_r = s_r.replace(""resare"","""") s_r = s_r.replace(""esare"","""") s_r = s_r.replace(""remaerd"","""") s_r = s_r.replace(""maerd"","""") if len(s_r)==0: print(""YES"") else: print(""NO"") " p03854,s541393564,Accepted,"s = input() flag = True while(flag): if(len(s)==0): flag = False if s[-5:] == 'dream' or s[-5:] == 'erase': s = s[:-5] elif s[-6:]== 'eraser': s = s[:-6] elif s[-7:]=='dreamer': s = s[:-7] else: break if(flag): print('NO') else: print('YES')" p03854,s625349639,Accepted,"s = input() lst = ['dreameraser', 'dreamerase', 'dreamer', 'dream', 'eraser', 'erase'] while s: flag = 0 for elem in lst: if elem in s: s = s.replace(elem, '') flag = 1 break if flag == 0: print('NO') quit() print('YES')" p03854,s672471387,Accepted,"def solve(n): while len(n) > 4: if n[-5:] == ""dream"": n = n[:-5] elif n[-7:] == ""dreamer"": n = n[:-7] elif n[-5:] == ""erase"": n = n[:-5] elif n[-6:] == ""eraser"": n = n[:-6] else: break return ""YES"" if len(n) == 0 else ""NO"" if __name__ == ""__main__"": n = input() print(solve(n)) " p03854,s394761158,Accepted,"S = input()[::-1] T = """" cand = [""dream"", ""dreamer"", ""erase"", ""eraser""] cand = [c[::-1] for c in cand] while S: for c in cand: if S.startswith(c): S = S[len(c):] break else: break print(""YES"") if S == """" else print(""NO"")" p03854,s486726485,Accepted,"S = input() S = S.replace(""eraser"",""-"") S = S.replace(""erase"",""-"") S = S.replace(""dreamer"",""-"") S = S.replace(""dream"",""-"") S = S.replace(""-"","""") if len(S) == 0: print(""YES"") else: print(""NO"")" p03854,s158751522,Accepted,"# -*- coding: utf-8 -*- S = input() import sys while True: if(len(S)==0): print(""YES"") sys.exit() if S.endswith(""dreamer""): S = S[:-7] elif S.endswith(""eraser""): S = S[:-6] elif S.endswith(""dream""): S = S[:-5] elif S.endswith(""erase""): S = S[:-5] else: print(""NO"") sys.exit() " p03854,s248355501,Accepted,"S = input() T = '' words = ['dream', 'dreamer', 'erase', 'eraser'] for i in range(len(words)): words[i] = words[i][::-1] for i in S[::-1]: T += i for q in words: if T == q: T = '' print('YES' if T == '' else 'NO')" p03854,s698439711,Accepted,"s = input() words = ['eraser', 'erase', 'dreamer', 'dream'] for w in words: s = s.replace(w, '') ans = 'YES' if s == '' else 'NO' print(ans) " p03854,s100431335,Accepted,"S = input() s = ['dream', 'dreamer', 'erase', 'eraser'] R = len(S) while(R > 0): for i in range(4): if R >= len(s[i]): if S[R-len(s[i]):R] == s[i]: R -= len(s[i]) break if i == 3: print(""NO"") exit(0) print(""YES"") " p03854,s024962932,Accepted,"S = input() T = """" while True: T_len = len(T) for word in [""dream"", ""dreamer"", ""erase"", ""eraser""]: if word + T == S[-1 * len(word + T):]: T = word + T if T == S: print(""YES"") exit() if T_len == len(T): print(""NO"") exit() " p03854,s936734439,Accepted,"init = input() words = [ 'dream', 'dreamer', 'erase', 'eraser' ] def reverseWord(str): return str[::-1] def elimTheWord(str): for word in reversed_words: if str.find(word) == 0: str = str[len(word):] return str reversed_words = list(map(reverseWord, words)) # main target = reverseWord(init) while True: pivot = elimTheWord(target) if pivot == '': print('YES') break if pivot == target: print('NO') break target = pivot" p03854,s224429647,Accepted,"s = input() s = s[::-1] ans = [""maerd"",""remaerd"",""esare"",""resare""] flag = 1 while len(s) != 0 and flag == 1: flag = 0 if s[:5] in ans: s = s[5:] flag = 1 elif s[:7] in ans: s = s[7:] flag = 1 elif s[:6] in ans: s = s[6:] flag = 1 if flag == 0: print(""NO"") else: print(""YES"")" p03854,s658853556,Accepted,"s=input() a='dream' b='dreamer' c='erase' d='eraser' i=0 while(True): if i==len(s): print(""YES"") exit() if s[-7-i:len(s)-i]==b: i+=7 elif s[-5-i:len(s)-i]==a: i+=5 elif s[-6-i:len(s)-i]==d: i+=6 elif s[-5-i:len(s)-i]==c: i+=5 else : print(""NO"") exit()" p03854,s181103652,Accepted,"s = input().replace(""eraser"", """").replace(""erase"", """").replace(""dreamer"", """").replace(""dream"", """") if s: print(""NO"") else: print(""YES"")" p03854,s021792498,Accepted,"s = input().replace(""eraser"","""").replace(""erase"","""").replace(""dreamer"","""").replace(""dream"","""") if len(s) == 0: print(""YES"") else: print(""NO"") " p03854,s804555454,Accepted,"s = input() s = s.replace(""eraser"", """") s = s.replace(""erase"", """") s = s.replace(""dreamer"", """") s = s.replace(""dream"", """") if s == """": print(""YES"") else: print(""NO"")" p03854,s590066042,Accepted,"s = input() s = s[::-1] while s != """": if s[:5] == ""esare"" or s[:5] == ""maerd"": s = s[5:] elif s[:6] == ""resare"": s = s[6:] elif s[:7] == ""remaerd"": s = s[7:] else: print(""NO"") exit() print(""YES"")" p03854,s648777439,Accepted,"s = input()[::-1] l = [ 'dream', 'dreamer', 'erase', 'eraser'] for i in range(4): s1 = l[i][::-1] l[i] = s1 n = len(s) i = 0 t = tuple(l) while i < n: judge = 0 s_l = [] for j in (5,6,7): if n-i >= j: s1 = s[i:i+j] if s1 in t: i += j judge = 1 if judge == 0: break if i == n: print('YES') else: print('NO')" p03854,s314848608,Accepted,"S = str(input()) A = ""dream"" B = ""dreamer"" C = ""erase"" D = ""eraser"" while len(S) >= 5: if len(S) >= 7 and S[-7:] == B: S = S[:-7] elif len(S) >=6 and S[-6:] == D: S = S[:-6] elif S[-5:] == A or S[-5:] == C: S = S[:-5] else: break if len(S) == 0: print(""YES"") else: print(""NO"")" p03854,s952036104,Accepted,"# C - 白昼夢 S = input() S2 = S W_L = [""dream"",""dreamer"",""erase"",""eraser""] while True: cnt = 0 for w in W_L: if S2.endswith(w): S2 = S2[:-(len(w))] cnt+=1 if cnt ==0: print('NO') exit() if len(S2)<=7: break if S2 ==''or S2 in W_L: print('YES') else: print('NO')" p03854,s156188819,Accepted,"txt = input() cands = [""dream"", ""dreamer"", ""erase"", ""eraser""] success = True while len(txt) > 0: flag = False for cand in cands: subtxt = txt[len(txt) - len(cand):] if subtxt == cand: txt = txt[:len(txt) - len(cand)] flag = True break if not flag: success = False break if success: print(""YES"") else: print(""NO"")" p03854,s236738202,Accepted,"s = input() n = len(s) s=s[::-1] while n: if s.startswith(""maerd""): n -= 5 s = s[5:] elif s.startswith(""remaerd""): n -= 7 s = s[7:] elif s.startswith(""esare""): n -= 5 s = s[5:] elif s.startswith(""resare""): n -= 6 s = s[6:] else: break print(""YES"" if n == 0 else ""NO"") " p03854,s882470332,Accepted,"S = input()[::-1] cand = {'maerd', 'remaerd', 'esare', 'resare'} res = 'YES' while len(S): orig = S for w in cand: if S.startswith(w): S = S[len(w):] if orig == S: res = 'NO' break print(res)" p03854,s288367281,Accepted,"S = str(input()) while len(S) > 0: if S[-5:] == 'dream' or S[-5:] == 'erase': S = S[:-5] elif S[-6:] == 'eraser': S = S[:-6] elif S[-7:] == 'dreamer': S = S[:-7] else: break if len(S) == 0: print('YES') else: print('NO')" p03854,s629894326,Accepted,"S = input() divide = True while len(S) > 0: if S[-5:] in [""dream"", ""erase""]: S = S[:-5] elif S[-6:] == ""eraser"": S = S[:-6] elif S[-7:] == ""dreamer"": S = S[:-7] else: divide = False break if divide: print(""YES"") else: print(""NO"")" p03854,s317264604,Accepted,"s = input() s = s[::-1] while len(s) > 0: if s[:5] == 'maerd': s = s[5:] elif s[:7] == 'remaerd': s = s[7:] elif s[:5] == 'esare': s = s[5:] elif s[:6] == 'resare': s = s[6:] else: print('NO') exit() print('YES')" p03854,s900473030,Accepted,"from collections import deque def bfs(string): can = [""dream"", ""dreamer"", ""erase"", ""eraser""] queue = deque([]) queue.append(""dream"") queue.append(""dreamer"") queue.append(""erase"") queue.append(""eraser"") while queue: judge = queue.popleft() if judge == string:break for temp in can: ans = judge + temp if ans == string[:len(ans)]: queue.append(ans) return ""YES"" if judge == string else ""NO"" if __name__ == '__main__': s = input() print(bfs(s))" p03854,s744528434,Accepted,"s = input()[::-1] n = len(s) words = ['maerd', 'remaerd', 'esare', 'resare'] while True: if s[:5] == words[0]: s = s[5:] continue elif s[:7] == words[1]: s = s[7:] continue elif s[:5] == words[2]: s = s[5:] continue elif s[:6] == words[3]: s = s[6:] continue break print('NO' if s else 'YES') " p03854,s435755965,Accepted,"S = input()[::-1] W = ('dream'[::-1], 'dreamer'[::-1], 'erase'[::-1], 'eraser'[::-1]) i = 0 while i < len(S): for w in W: if S[i:].startswith(w): i += len(w) break else: print('NO') exit() print('YES') " p03854,s054632401,Accepted,"import sys s = input() while True: if s[-5:] == 'dream': s = s[:-5] elif s[-7:] == 'dreamer': s = s[:-7] elif s[-5:] == 'erase': s = s[:-5] elif s[-6:] == 'eraser': s = s[:-6] else: print('NO') sys.exit() if s == '': print('YES') sys.exit()" p03854,s967042428,Accepted,"S = input() while len(S) > 0: if S[-5::1] == 'dream' or S[-5::1] == 'erase': S = S[:-5:1] elif S[-6::1] == 'eraser': S = S[:-6:1] elif S[-7::1] == 'dreamer': S = S[:-7:1] else: print('NO') break if len(S) == 0: print('YES') " p03854,s623386657,Accepted,"s = str(input()) no = 0 while 1: for data in [""erase"", ""eraser"", ""dream"", ""dreamer""]: if s.endswith(data): s = s[: - len(data)] else: no += 1 if not s: print(""YES"") exit() if no == 4: print(""NO"") exit() else: no = 0 " p03854,s228476961,Accepted,"S = input() buff = ['dream', 'dreamer', 'erase', 'eraser'] for i in range(4): buff[i] = buff[i][::-1] S = S[::-1] while len(S) > 0: if S[:7] == buff[1]: S = S[7:] elif S[:6] == buff[3]: S = S[6:] elif S[:5] == buff[0] or S[:5] == buff[2]: S = S[5:] else: break if S: print('NO') else: print('YES')" p03854,s457666843,Accepted,"words=[""eraser"",""erase"",""dreamer"",""dream""] S=input() for i in range(0,4): S=S.replace(words[i],"""",len(S)//4) if S=="""": print(""YES"") else: print(""NO"") " p03854,s182005959,Accepted,"s = input() s = s.replace(""eraser"", """") s = s.replace(""erase"", """") s = s.replace(""dreamer"", """") s = s.replace(""dream"", """") if len(s) > 0: print(""NO"") else: print(""YES"")" p03854,s971670437,Accepted,"s=input() s=s.replace('eraser','0').replace('erase','0').replace('dreamer','0').replace('dream','0') s=s.replace('0','') if len(s)==0:print(""YES"") else:print(""NO"") " p03854,s978558633,Accepted,"import re s = input() if re.match(""(dreamer|dream|eraser|erase)+$"",s): print(""YES"") else: print(""NO"")" p03854,s510113779,Accepted,"S=input() while len(S) >=5: if S[-7:]=='dreamer': S=S[:-7] elif S[-6:] == 'eraser': S=S[:-6] elif S[-5:] == 'dream': S=S[:-5] elif S[-5:] == 'erase': S=S[:-5] else: print('NO') break if len(S)==0: print('YES') if 1<=len(S)<=4: print('NO') " p03854,s633330919,Accepted,"s = input() s_reverse = s[::-1] arr = ['dream', 'dreamer', 'erase', 'eraser'] arr_reversed = list(map(lambda item: item[::-1], arr)) able = True t = """" while s_reverse != t and able: for i in range(len(arr_reversed)): item = arr_reversed[i] if s_reverse[len(t): len(t) + len(item)] == item: t += item break elif i == len(arr_reversed) - 1: able = False print(""YES"" if s_reverse == t else ""NO"")" p03854,s759939227,Accepted,"S = input() def check(S): DP = [False]*len(S) if S[:5] == 'dream' or S[:5] == 'erase': DP[4] = True if S[:7] == 'dreamer': DP[6] = True if S[:6] == 'eraser': DP[5] = True for i in range(7,len(S)): DP[i] = (DP[i-5]&((S[i-4:i+1]=='dream')|(S[i-4:i+1]=='erase')))|(DP[i-6]&(S[i-5:i+1]=='eraser'))|(DP[i-7]&(S[i-6:i+1]=='dreamer')) return DP[-1] if check(S): print('YES') else: print('NO')" p03854,s340385734,Accepted,"import re S = input() ''' メタ文字: ^ = 文字列の先頭、 | = OR + = 直前のパターンを1回以上繰り返し、 $ = 文字列の末尾 ''' if re.match(""^(dream|dreamer|erase|eraser)+$"", S): print('YES') else: print('NO')" p03854,s792121414,Accepted,"s = input() result = True while 0 < len(s): if s[-5:] == ""dream"" or s[-5:] == ""erase"": s = s[:-5] elif s[-6:] == ""eraser"": s = s[:-6] elif s[-7:] == ""dreamer"": s = s[:-7] else: result = False break print(""YES"" if result else ""NO"")" p03854,s178840185,Accepted,"S = input() day_dream_word = [""eraser"", ""erase"", ""dreamer"", ""dream""] for replace_word in day_dream_word: S = S.replace(replace_word, """") if S == """": print('YES') else: print('NO')" p03854,s620148777,Accepted,"import sys readline = sys.stdin.readline def main(): S = readline().rstrip() T = S.replace('eraser', '').replace('erase', '').replace('dreamer', '').replace('dream', '') if not T: print('YES') else: print('NO') if __name__ == '__main__': main()" p03854,s571149357,Accepted,"#!/usr/bin/env python3 # -*- coding: utf-8 -*- import re def main(): S = input() if re.match(""(dream|dreamer|erase|eraser)*$"", S): print(""YES"") else: print(""NO"") if __name__ == ""__main__"": main() " p03854,s217352833,Accepted,"s = input() if s.replace(""eraser"","""").replace(""erase"","""").replace(""dreamer"","""").replace(""dream"",""""): print(""NO"") else: print(""YES"")" p03854,s946777632,Accepted,"S=input() T=[] l=-1 while l-2>=-len(S): k=S[l:l-3:-1] if k==""mae"": T+=""dream""[::-1] l-=5 elif k==""rem"": T+=""dreamer""[::-1] l-=7 elif k==""esa"": T+=""erase""[::-1] l-=5 elif k==""res"": T+=""eraser""[::-1] l-=6 else: break if S=="""".join(T[::-1]): print(""YES"") else: print(""NO"") " p03854,s008911433,Accepted,"s = str(input()) s1 = s[::-1] u = ['dream','dreamer','erase','eraser'] while True: restart = False for i in range(4): if u[i][::-1] == s1[:len(u[i])]: s1 = s1[len(u[i]):] restart = True break if restart == False: break if len(s1) > 0: print('NO') else: print('YES')" p03854,s620469875,Accepted,"from re import match S = input() L = r""^(dream|dreamer|erase|eraser)+$"" if match(L, S): print(""YES"") else: print(""NO"")" p03854,s134288420,Accepted,"i = input()[::-1] T = [] for t in ['dreamer', 'dream', 'eraser', 'erase']: T.append(t[::-1]) match = True while match: match = False for t in T: if i.startswith(t): match = True i = i.replace(t, '', 1) if len(i) < 1: print('YES') exit() print('NO')" p03854,s514292134,Accepted,"S = input().replace('eraser', '').replace('erase', '').replace('dreamer', '').replace('dream', '') print('YES' if len(S) == 0 else 'NO')" p03854,s954341890,Accepted,"s = str(input()) t = s.replace('eraser', '').replace('erase', '').replace('dreamer', '').replace('dream', '') if t == '': print('YES') else: print('NO') " p03854,s357789394,Accepted,"s = input() if s.replace(""eraser"", """").replace(""erase"", """").replace(""dreamer"", """").replace(""dream"", """"): print(""NO"") else: print(""YES"")" p03854,s642795235,Accepted,"s = input()[::-1] n = len(s) idx = 0 while idx < n: if s[idx:idx+5] == 'maerd': idx += 5 elif s[idx:idx+7] == 'remaerd': idx += 7 elif s[idx:idx+5] == 'esare': idx += 5 elif s[idx:idx+6] == 'resare': idx += 6 else: print(""NO"") exit() print(""YES"") " p03854,s026178038,Accepted,"import re print(""YES"" if re.fullmatch(""(erase(r)?|dream(er)?)+"", input())else ""NO"")" p03854,s646142526,Accepted,"S=input() S=S[::-1] L=[""dream"",""dreamer"",""erase"",""eraser""] L=[i[::-1] for i in L] i=0 while i 0: if S[-5:] == ""dream"": S = S[:-5] elif S[-5:] == ""erase"": S = S[:-5] elif S[-7:] == ""dreamer"": S = S[:-7] elif S[-6:] == ""eraser"": S = S[:-6] else: ans = ""NO"" break print(ans)" p03854,s478173229,Accepted,"S = input() words = ['dream', 'dreamer', 'erase', 'eraser'] dp = [0] * (len(S) + 1) dp[0] = 1 ans = 'NO' for i in range(len(S)): if dp[i] == 0: continue for w in words: if S[i:i+len(w)] == w: dp[i+len(w)] = 1 if dp[len(S)] == 1: ans = 'YES' break print(ans)" p03854,s107154491,Accepted,"s = input() while s: if s.endswith('dream'): s = s[:-5] continue if s.endswith('erase'): s = s[:-5] continue if s.endswith('dreamer'): s = s[:-7] continue if s.endswith('eraser'): s = s[:-6] continue print('NO') exit() print('YES') " p03854,s219199095,Accepted,"S = list(input()) import re S.reverse() D1 = ""maerd"" D2 = ""remaerd"" E1 = ""esare"" E2 = ""resare"" S = """".join(S) S = re.split('maerd|remaerd|esare|resare', S) if len(S) == S.count("""") : print(""YES"") else: print(""NO"")" p03854,s813256760,Accepted,"s = input() ss = s.replace(""eraser"","""").replace(""erase"","""").replace(""dreamer"","""").replace(""dream"","""") if ss: print(""NO"") else: print(""YES"") " p03854,s830242317,Accepted,"T=[] S=input() Sr=list(reversed(S)) w1=list(reversed('dream')) w2=list(reversed('dreamer')) w3=list(reversed('erase')) w4=list(reversed('eraser')) while True: if Sr[:5]==w1: del(Sr[:5]) elif Sr[:5]==w3: del(Sr[:5]) elif Sr[:6]==w4: del(Sr[:6]) elif Sr[:7]==w2: del(Sr[:7]) else: break if Sr==T: print('YES') else: print('NO')" p03854,s766632645,Accepted,"s = input().replace('eraser', '').replace('erase', '').replace('dreamer', '').replace('dream', '') if s: print('NO') else: print('YES')" p03854,s178943327,Accepted,"import re print(""YES"" if re.match(""^(dream|dreamer|erase|eraser)+$"", input()) else ""NO"")" p03854,s995714003,Accepted,"S = input()[::-1] day_dream_word = [""dreamer"", ""dream"", ""eraser"", ""erase""] day_dream_word = list(map(lambda s: s[::-1], day_dream_word)) T = """" Tindex = 0 res = False partial_res = True while not res and partial_res: partial_res = False for add_word in day_dream_word: nextTindex = Tindex + len(add_word) if S[Tindex:nextTindex] == add_word: if len(S) == nextTindex: res = True break else: partial_res = True break Tindex = nextTindex if res: print('YES') else: print('NO')" p03854,s798435967,Accepted,"import re S=input() if re.match(""^(dream|dreamer|erase|eraser)+$"",S): print('YES') else: print('NO')" p03854,s434010361,Accepted,"import re print(""YES"" if re.match(""^(dream|dreamer|erase|eraser)+$"",input()) else ""NO"")" p03854,s294283508,Accepted,"s = input()[::-1] len_s = len(s) a = 'dream'[::-1] b = 'dreamer'[::-1] c = 'erase'[::-1] d = 'eraser'[::-1] idx = 1 for _ in range(len_s): if s[:idx] in [a, b, c, d]: s = s[idx:] idx = 0 idx += 1 if s[:idx] in [a, b, c, d]: s = [] if len(s) == 0: print('YES') else: print('NO') " p03854,s560489692,Accepted,"# -*- coding: utf-8 -*- I = [""dream"", ""dreamer"", ""erase"", ""eraser""] I2 = input() if I2.replace(I[1], """").replace(I[0], """").replace(I[3], """").replace(I[2], """").strip() == """": print(""YES"") elif I2.replace(I[0], """").replace(I[2], """").replace(I[1], """").replace(I[3], """").strip() == """": print(""YES"") elif I2.replace(I[2], """").replace(I[0], """").replace(I[3], """").replace(I[1], """").strip() == """": print(""YES"") elif I2.replace(I[3], """").replace(I[2], """").replace(I[1], """").replace(I[0], """").strip() == """": print(""YES"") else: print(""NO"")" p03854,s940159072,Accepted,"s = input() s = list(s) s = s[::-1] word_list = ['maerd', 'remaerd', 'esare', 'resare'] i = 0 while i != len(s): a = s[i:i+5] a = ''.join(a) b = s[i:i+6] b = ''.join(b) c = s[i:i+7] c = ''.join(c) if a in word_list: i += 5 elif b in word_list: i += 6 elif c in word_list: i += 7 else: print('NO') exit() print('YES')" p03854,s811685334,Accepted,"import re S = input() ''' メタ文字: ^ = 文字列の先頭、 | = OR + = 直前のパターンを1回以上繰り返し、 $ = 文字列の末尾 ''' if re.match(""^(dream|dreamer|erase|eraser)+$"", S): print('YES') else: print('NO')" p03854,s721337324,Accepted,"S = input() ans = 'YES' while S: if S.endswith('eraser'): S = S[:-6] elif S.endswith('erase'): S = S[:-5] elif S.endswith('dreamer'): S = S[:-7] elif S.endswith('dream'): S = S[:-5] else: ans = 'NO' break print(ans) " p03854,s143768036,Accepted,"from itertools import permutations S = input() def is_passed(s, ws): for w in ws: s = ''.join(s.split(w)) if len(s) == 0: return True return False def main(): l = ['dreamer', 'eraser', 'dream', 'erase'] pm = permutations(l, len(l)) passed = False for ws in pm: passed = is_passed(S, ws) if passed: break print('YNEOS'[not passed::2]) if __name__ == '__main__': main()" p03854,s476417645,Accepted,"S = input() # 前から順に消すと詰む # 後ろから順に消すと一意に定まる while True: if S[-5:] == 'erase': S = S[:-5] else: if S[-6:] == 'eraser': S = S[:-6] else: if S[-5:] == 'dream': S = S[:-5] else: if S[-7:] == 'dreamer': S = S[:-7] else: break if len(S) == 0: print('YES') else: print('NO')" p03854,s781056729,Accepted,"s = input() new = s.replace('eraser','') .replace('erase','').replace('dreamer','').replace('dream','') if len(new) == 0: print('YES') else: print('NO')" p03854,s213602266,Accepted,"s = input() str_list = [""dream"",""dreamer"",""erase"",""eraser""] def checklast(s): # print(s) for word in str_list: if s[-len(word):] == word: return s[:-len(word)] else: return None for i in range(100000): if s is None: print(""NO"") break if len(s) == 0: print(""YES"") break s = checklast(s) " p03854,s080693065,Accepted,"s = input() s = s.replace('eraser', '').replace('erase', '').replace('dreamer', '').replace('dream', '') if s == '': print('YES') else: print('NO')" p03854,s663502157,Accepted,"S = input() """"""対象文字列 dream erase eraser dreamer """""" flg = True while flg: if S[-7:] == 'dreamer': S = S[:-7] elif S[-6:] == 'eraser': S = S[:-6] elif S[-5:] == 'erase': S = S[:-5] elif S[-5:] == 'dream': S = S[:-5] else: flg = False if len(S) == 0: ans = 'YES' else: ans = 'NO' print(ans)" p03854,s012911486,Accepted,"S=input()[::-1] N=len(S) T=['maerd','esare','resare','remaerd'] ans='YES' i=0 while i0: hit = False for w in words: s = S[-len(w):] if w == s: S = S[0:-len(w)] hit = True break if not hit: break if len(S)==0: print('YES') else: print('NO') " p03854,s209233409,Accepted,"def main(): S = input()[::-1] i = 0 while i < len(S): if S[i:i+5] == 'maerd' or S[i:i+5] == 'esare': i += 5 elif S[i:i+6] == 'resare': i += 6 elif S[i:i+7] == 'remaerd': i += 7 else: print('NO') break else: print('YES') return if __name__ == '__main__': main() " p03854,s256384488,Accepted,"s = input()[::-1] a = ""maerd"" b = ""remaerd"" c = ""esare"" d = ""resare"" while len(s)!=0: if s[:5]==a: s = s[5:] elif s[:7]==b: s = s[7:] elif s[:5]==c: s = s[5:] elif s[:6]==d: s = s[6:] else: print(""NO"") exit() print(""YES"")" p03854,s208420909,Accepted,"s = str(input()) while len(s) > 0: if s[-5:] == 'dream': s = s[:-5] elif s[-7:] == 'dreamer': s = s[:-7] elif s[-5:] == 'erase': s = s[:-5] elif s[-6:] == 'eraser': s = s[:-6] else: print('NO') break else: print('YES') " p03854,s988250628,Accepted,"S = input() N = len(S) i = N while i: if S[i-5:i] == 'dream': i -= 5 elif S[i-5:i] == 'erase': i -= 5 elif S[i-7:i] == 'dreamer': i -= 7 elif S[i-6:i] == 'eraser': i -= 6 else: print('NO') exit() print('YES')" p03854,s139566402,Accepted,"lt = [""dream"", ""dreamer"", ""erase"", ""eraser""] s = input() lt = [w[::-1] for w in lt] s = s[::-1] cond = True i = 0 while i < len(s): for t in lt: if s[i:].startswith(t): i += len(t) break else: cond = False break print(""YES"" if cond else ""NO"") " p03854,s556904373,Accepted,"import sys import resource sys.setrecursionlimit(10 ** 9) S = input() l = [] def dfs(n): if n == len(S): l.append(""YES"") if n < len(S): if S[n:n+5] == ""erase"": dfs(n+5) if S[n:n+5] == ""dream"": dfs(n+5) if S[n:n+6] == ""eraser"": dfs(n+6) if S[n:n+7] == ""dreamer"": dfs(n+7) dfs(0) if len(l) == 0: l.append(""NO"") print(l[0]) " p03854,s693785539,Accepted,"s = input() templates = [""dream"", ""dreamer"", ""erase"", ""eraser""] while s: for template in templates: if s.endswith(template): s = s[:-len(template)] break else: break print(""YES"" if not s else ""NO"")" p03854,s514803598,Accepted,"import re print('NYOE S'[bool(re.match('^(dream|dreamer|erase|eraser)+$',input()))::2])" p03854,s360400938,Accepted,"S = list(input()) flag = True while flag == True: if len(S) == 0: break if len(S) >= 5: if S[-5:] == list(""dream""): del S[-5:] elif S[-5:] == list(""erase""): del S[-5:] elif len(S)>=6 and S[-6:] == list(""eraser""): del S[-6:] elif len(S)>=7 and S[-7:] == list(""dreamer""): del S[-7:] else: flag = False else: flag = False if flag: print(""YES"") else:print(""NO"")" p03854,s667021292,Accepted,"t=input() def right(text): li=[""dream"",""dreamer"",""erase"",""eraser""] for te in li: if text[-len(te):] == te: return text[:len(text)-len(te)] return text flag=True while flag: temp=right(t) if not temp: print(""YES"") break elif temp==t: print(""NO"") break t=temp " p03854,s153281210,Accepted,"s = input() s = s.replace(""eraser"", """").replace(""erase"", """").replace( ""dreamer"", """").replace(""dream"", """") print(""NO"" if s else ""YES"") " p03854,s982598326,Accepted,"from re import * if match(""^(dream|dreamer|erase|eraser)+$"", input()): print('YES') else: print('NO') " p03854,s583436538,Accepted,"S=input().rstrip() S=S[::-1] T=[""dream"",""dreamer"",""erase"",""eraser""] for i in range(len(T)): T[i]=T[i][::-1] while len(S): flag=False for t in T: if S.startswith(t): S=S[len(t):] flag=True if not flag: break if len(S)==0: print(""YES"") else: print(""NO"") " p03854,s786975929,Accepted,"s = input() s = s.replace('eraser', '') s = s.replace('erase', '') s = s.replace('dreamer', '') s = s.replace('dream', '') if s == '': print('YES') else: print('NO')" p03854,s312146977,Accepted,"# https://atcoder.jp/contests/abc049/tasks/arc065_a s = list(input()) words = ['dream','dreamer','erase','eraser'] def check(w): return word in words while s: word = ''.join([s.pop() for _ in range(5)][::-1]) if check(word): continue for _ in range(2): word = s.pop() + word if check(word): break else: print('NO') exit() print('YES')" p03854,s360212047,Accepted,"s=input() lst=[""eraser"",""erase"",""dreamer"",""dream"",] for e in lst: s=s.replace(e,"""") print(""YES"" if s=="""" else ""NO"")" p03854,s724142930,Accepted,"s = input() s = s.replace(""eraser"", """") s = s.replace(""erase"", """") s = s.replace(""dreamer"", """") s = s.replace(""dream"", """") if s: print(""NO"") else: print(""YES"")" p03854,s340348284,Accepted," S=input() N=len(S) dp=[0]*(N+1) dp[0]=1 L=[""dream"", ""dreamer"", ""erase"", ""eraser""] for i in range(1,N+1): for l in L: n=len(l) if 0<=i-n= 5: lb = len(a) if a[-5:] in let5: a = a[:-5] l -= 5 if a[-6:] == 'eraser': a = a[:-6] l -= 6 if a[-7:] == 'dreamer': a = a[:-7] l -= 7 if l == 0: print('YES') break if l == lb: print('NO') break else: print('NO') " p03854,s843571058,Accepted,"import re S = input() if re.match(""^(dream|dreamer|erase|eraser)+$"",S): print(""YES"") else: print(""NO"") " p03854,s348382177,Accepted,"s = input().replace('eraser','').replace('erase','').replace('dreamer','').replace('dream','') if s: print('NO') else: print('YES')" p03854,s912664822,Accepted,"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]==""remaerd"": i+=7 elif s[i:i+5]=='esare': i+=5 elif s[i:i+6]=='resare': i+=6 else: ans=""NO"" break print(ans)" p03854,s337007775,Accepted,"S = input() array = [""eraser"",""erase"",""dreamer"",""dream""] for str in array: S = S.replace(str,"" "") ans = S.replace("" "","""") if len(ans) == 0: print(""YES"") else: print(""NO"") " p03854,s014390529,Accepted,"S = input().strip()[::-1] div = [i[::-1] for i in [""dream"", ""dreamer"", ""erase"", ""eraser""]] idx = 0 ok = False while True: sub_ok = False for d in div: if S[idx:idx+len(d)] == d: idx += len(d) sub_ok = True break if sub_ok != True: break if idx == len(S): ok = True break if ok: print(""YES"") else: print(""NO"")" p03854,s741954266,Accepted,"l = input() l = l.replace('eraser','') l = l.replace('erase','') l = l.replace('dreamer','') l = l.replace('dream','') if l == '': print('YES') else: print('NO')" p03854,s081989245,Accepted,"import sys s = input() cand = ['dream', 'dreamer', 'erase', 'eraser'] q = [''] while len(q) != 0: front = q.pop(0) for c in cand: start = len(front) end = len(front) + len(c) if end <= len(s) and s[len(front):len(front) + len(c)] == c: next_elm = front + c if next_elm == s: print('YES') sys.exit(0) q.append(next_elm) print('NO') " p03854,s141494224,Accepted,"S = input() m = [""eraser"",""erase"",""dreamer"",""dream""] for i in m: S = S.replace(i,"""") print(""YES"" if S == """" else ""NO"")" p03854,s123878969,Accepted,"import sys import itertools sys.setrecursionlimit(1000000000) from heapq import heapify,heappop,heappush,heappushpop import math import collections MOD = 10**9+7 s = input() s = s.replace(""eraser"","""").replace(""erase"","""").replace(""dreamer"","""").replace(""dream"","""") if len(s) == 0: print(""YES"") else: print(""NO"")" p03854,s846908689,Accepted,"# python 3.4.3 import sys input = sys.stdin.readline import numpy as np # ------------------------------------------------------------- # function # ------------------------------------------------------------- # ------------------------------------------------------------- # main # ------------------------------------------------------------- S = input().rstrip() S = S[::-1] words = [""dream"",""dreamer"",""erase"",""eraser""] for i in range(4): words[i] = words[i][::-1] i = 0 while i < len(S): for w in words: l = len(w) if w == S[i:i+l]: i += l break else: print(""NO"") sys.exit() print(""YES"")" p03854,s994084634,Accepted,"S = input() while True: l = len(S) if l == 0: print('YES'); break if l-5 >= 0 and S[l-5:] == 'dream': S = S[:l-5]; continue if l-7 >= 0 and S[l-7:] == 'dreamer': S = S[:l-7]; continue if l-5 >= 0 and S[l-5:] == 'erase': S = S[:l-5]; continue if l-6 >= 0 and S[l-6:] == 'eraser': S = S[:l-6]; continue print('NO') break" p03854,s905250953,Accepted,"s=input() s=s[::-1] w=['dream','dreamer','erase','eraser'] lenw=[5,7,5,6] w=[i[::-1] for i in w] i=0 n=len(s) while i 4: if s[-5:] == 'dream' or s[-5:] == 'erase': s = s[:-5] continue elif s[-7:] == 'dreamer': s = s[:-7] continue elif s[-6:] == 'eraser': s = s[:-6] continue else: break if len(s) > 0: print('NO') else: print('YES')" p03854,s711276280,Accepted,"S = input() S0 = S.replace(""dream"", ""A"") S1 = S0.replace(""erase"", ""B"") S2 = S1.replace(""Aer"", ""A"") S3 = S2.replace(""Br"", ""B"") #print(S3) check = True for i in range(len(S3)): if S3[i] != ""A"" and S3[i] != ""B"": check = False print(""YES"" if check == True else ""NO"")" p03854,s330656065,Accepted,"S = input()[::-1] word1 = ""dream""[::-1] word2 = ""dreamer""[::-1] word3 = ""erase""[::-1] word4 = ""eraser""[::-1] while True: if S[:5] == word1: S = S[5:] elif S[:7] == word2: S = S[7:] elif S[:5] == word3: S = S[5:] elif S[:6] == word4: S = S[6:] elif S == """": print(""YES"") break else: print(""NO"") break " p03854,s649064649,Accepted,"c = input().rstrip('\n') str1 = ""eraser"" str2 = ""erase"" str3 = ""dreamer"" str4 = ""dream"" c = c.replace(str1, """") c = c.replace(str2, """") c = c.replace(str3, """") c = c.replace(str4, """") if (c == """"): print(""YES"") else: print(""NO"") " p03854,s037164500,Accepted,"S = input() S_rvs = S[::-1] texts = [""maerd"", ""remaerd"", ""esare"", ""resare""] match = True while len(S_rvs) > 0: if (S_rvs[0:5] == ""maerd"") or (S_rvs[0:5] == ""esare""): S_rvs = S_rvs[5:] elif S_rvs[0:6] == ""resare"": S_rvs = S_rvs[6:] elif S_rvs[0:7] == ""remaerd"": S_rvs = S_rvs[7:] else: match = False break if match: print(""YES"") else: print(""NO"")" p03854,s792341388,Accepted,"S = input() i = 0 while len(S) > 0: if S[-5:] in ['dream', 'erase']: S = S[:-5] elif S[-6:] == 'eraser': S = S[:-6] elif S[-7:] == 'dreamer': S = S[:-7] else: print('NO') exit() print('YES')" p03854,s539460122,Accepted,"words = ['dream','dreamer', 'erase', 'eraser'] s = raw_input() dp = [False for _ in range(len(s))] for j in range(len(s)): for w in words: b = dp[j - len(w)] if j - len(w) -1 >= 0 else True b &= j-len(w) +1 >= 0 and s[j- len(w)+1:j+1] == w if b: dp[j] = True break print 'YES' if dp[-1] else 'NO'" p03854,s632392270,Accepted,"S = input() while True : if S[-5:] == ""dream"": S = S[:-5] elif S[-6:] == ""eraser"": S = S[:-6] elif S[-7:] == ""dreamer"": S = S[:-7] elif S[-5:] == ""erase"": S = S[:-5] elif len(S) == 0: print(""YES"") break else: print(""NO"") break " p03854,s970965669,Accepted,"S = input() S = S[::-1] s1 = 'maerd' s2 = 'esare' s3 = 'remaerd' s4 = 'resare' while(1): if S[:5] == s1: S = S[5:] elif S[:5] == s2: S = S[5:] elif S[:7] == s3: S = S[7:] elif S[:6] == s4: S = S[6:] else: break if len(S)==0: print(""YES"") else : print(""NO"")" p03854,s998500579,Accepted,"import re print(""YES"" if re.match(""^(dream|dreamer|erase|eraser)+$"", input()) else ""NO"")" p03854,s786730443,Accepted,"S = input() ch = [""dream"", ""dreamer"", ""erase"", ""eraser""] while S: N = len(S) if S[N-5:] == ch[0] or S[N-5:] == ch[2]: S = S[:N-5] elif S[N-6:] == ch[3]: S = S[:N-6] elif S[N-7:] == ch[1]: S = S[:N-7] else: print(""NO"") exit() print(""YES"")" p03854,s316780865,Accepted,"s = input() t_list = ['dream','dreamer','erase','eraser'] while s != '': for i in range(len(t_list)): if s[-len(t_list[i]):] == t_list[i]: s = s[:len(s)-len(t_list[i])] break else: print('NO') break if s == '': print('YES')" p03854,s781178264,Accepted,"s = input() a = s.replace(""eraser"","""") b = a.replace(""erase"","""") c = b.replace(""dreamer"","""") d = c.replace(""dream"","""") if d == """": print(""YES"") else: print(""NO"")" p03854,s445860941,Accepted,"I = input() import re if re.match(""^(dream|dreamer|erase|eraser)+$"", I): print(""YES"") else: print(""NO"") " p03854,s321967328,Accepted,"s = input() div = [""dream"", ""dreamer"", ""erase"", ""eraser""] rev = [] t = """" s_rev = s[::-1] for d in div: rev.append(d[::-1]) result = True i = 0 while i < len(s): can_divide = False for d in rev: if len(s_rev) - i >= len(d) and s_rev[i:i + len(d)] == d: can_divide = True i += len(d) break if not can_divide: result = False break print(""YES"" if result else ""NO"") " p03854,s481208366,Accepted,"import queue divide = [""dream"", ""dreamer"", ""erase"", ""eraser""] S = input() BFS = queue.Queue() can = False BFS.put(0) while not BFS.empty(): t = BFS.get() if (t == len(S)): can = True break for s in divide: if s == S[t: t + len(s)]: BFS.put(t + len(s)) if can is True: print(""YES"") else: print(""NO"")" p03854,s344945399,Accepted,"s = input().replace('eraser', '').replace('erase', '').replace('dreamer', '').replace('dream', '') print('YES' if s=='' else 'NO')" p03854,s671459876,Accepted,"S = input() dp = [0] * (len(S) + 1) dp[0] = 1 words = [""dream"", ""dreamer"", ""erase"", ""eraser""] done = 'NO' for i in range(len(S)): if dp[i] == 0: continue for w in words: if S[i:i+len(w)] == w: dp[i+len(w)] = 1 if dp[len(S)] == 1: done = 'YES' print(done)" p03854,s147006376,Accepted,"#abc049 c s=input() divide=[""dream"",""dreamer"",""erase"",""eraser""] s=s[::-1] for i,x in enumerate(divide): divide[i]=x[::-1] ans=True i=0 while i 0: ok = False for w in words: l = r - len(w) if l < 0: continue if S[l:r] == w: r = l ok = True break if not ok: ans = ""NO"" break print(ans) " p03854,s383455888,Accepted,"S=input() W=(""dream"",""dreamer"",""erase"",""eraser"") s=[0] while s: i=s.pop() if i==len(S): print(""YES"") break for w in W: if S[i:i+len(w)]==w: s.append(i+len(w)) else: print(""NO"")" p03854,s307978456,Accepted,"s = input() flag = ""NO"" s = s[::-1] for i in range(len(s)//5+1): if s[0:5] == ""maerd"": s = s[5:] if s[0:7] == ""remaerd"": s = s[7:] if s[0:5] == ""esare"": s = s[5:] if s[0:6] == ""resare"": s = s[6:] if s == '': flag = ""YES"" print(flag)" p03854,s996088689,Accepted,"s = input()[::-1] while True: if len(s) == 0: print (""YES"") exit () if s[0:5] == ""maerd"" or s[0:5] == ""esare"": s = s[5:] else: if s[0:6] == ""resare"": s = s[6:] else: if s[0:7] == ""remaerd"": s = s[7:] else: print (""NO"") exit () " p03854,s700578621,Accepted,"s = input() while len(s) > 0: if s[-5:] == ""dream"": s = s[:-5] elif s[-7:] == ""dreamer"": s = s[:-7] elif s[-5:] == ""erase"": s = s[:-5] elif s[-6:] == ""eraser"": s = s[:-6] else: print(""NO"") exit() if len(s) == 0: print(""YES"") " p03854,s633488465,Accepted,"import re print(""YES"" if re.match(""^(dream|dreamer|erase|eraser)+$"",input()) else ""NO"")" p03854,s067049463,Accepted,"S = input() ind = len(S) flg = True while ind > 0: if S[ind-7:ind] in [""dreamer""]: ind -= 7 elif S[ind-6:ind] in [""eraser""]: ind -= 6 elif S[ind-5:ind] in [""dream"", ""erase""]: ind -= 5 else: flg = False break if flg: print('YES') else: print('NO')" p03854,s147913048,Accepted,"def resolve(): s = input() K = ['dream', 'dreamer', 'erase', 'eraser'] for i in range(len(K)): K[i] = K[i][::-1] r = '' for i in s[::-1]: r += i if r in K: r = '' if len(r): print(""NO"") else: print(""YES"") resolve()" p03854,s995726020,Accepted,"s=input() s=s.replace('eraser','') s=s.replace('erase','') s=s.replace('dreamer','') s=s.replace('dream','') print('YES') if len(s)==0 else print('NO') " p03854,s232484527,Accepted,"S = input() # 単転したら分解は一意 S = S[::-1] while S != """": if S[:5] == ""maerd"": S = S[5:] elif S[:5] == ""esare"": S = S[5:] elif S[:6] == ""resare"": S = S[6:] elif S[:7] == ""remaerd"": S = S[7:] else: print(""NO"") exit() print(""YES"") " p03854,s094322156,Accepted,"s = t = input() a = 'dream' b = 'dreamer' c = 'erase' d = 'eraser' while t: if t[-7:] == b: t = t[:-7] elif t[-6:] == d: t = t[:-6] elif t[-5:] in (a, c): t = t[:-5] else: break if t: print('NO') else: print('YES') " p03854,s472526756,Accepted,"S = input() reverse = S[::-1] devide = [""dream"", ""erase"", ""dreamer"", ""eraser""] r_devide = [devide[i][::-1] for i in range(len(devide))] i=0 while i < len(S): can = False for j in r_devide: if j in reverse[i:i+len(j)] : can = True i += len(j) if can == False: break if can == True: print(""YES"") else: print(""NO"")" p03854,s247241192,Accepted,"A = input() A = A[::-1] divide = [i[::-1] for i in [""dream"", ""dreamer"", ""erase"", ""eraser""]] flag = 1 while flag and A: flag = 0 for word in divide: if A.startswith(word): A = A[len(word):] flag = 1 if len(A) == 0: print('YES') else: print('NO')" p03854,s498449249,Accepted,"def main(): text = input() words = ['dreamer', 'eraser', 'dream', 'erase'] length = len(text) while text: for word in words: if text.endswith(word): text = text[:-len(word)] else: if (new := len(text)) != length: length = new else: return 'NO' return 'YES' if __name__ == '__main__': ans = main() print(ans) " p03854,s245201523,Accepted,"#9 S = input()[::-1] for i in range(0, len(S)//5+1): if S[0:5] == 'maerd' or S[0:5] == 'esare': S = S[5:] elif S[0:6] == 'resare': S = S[6:] elif S[0:7] == 'remaerd': S = S[7:] else: break print('YES' if len(S)==0 else 'NO') " p03854,s805528741,Accepted,"import re s=input() s=s[::-1] #print(s) #dream|dreamer|erase|eraser #maerd|remaerd|esare|resare t=re.split('maerd|remaerd|esare|resare', s) #print(len(t)) #print(t.count('')) if len(t)==t.count(''): print('YES') else: print('NO')" p03854,s654002335,Accepted,"S = input() S = S[::-1] candidacies = [""dream"", ""dreamer"", ""erase"", ""eraser""] candidacies = [c[::-1] for c in candidacies] fi_flg = False while fi_flg is False: if S[:7] in candidacies: S = S[7:] elif S[:6] in candidacies: S = S[6:] elif S[:5] in candidacies: S = S[5:] else: fi_flg = True if len(S) == 0: print(""YES"") else: print(""NO"")" p03854,s556069856,Accepted,"S = input() S_r = S[::-1] Ss = [""remaerd"",""resare"",""esare"",""maerd""] ind = 0 while ind < len(S): flg = False for s in Ss: n = len(s) if S_r[ind:ind+n] == s: ind += n flg = True if not flg: print(""NO"") exit() print(""YES"")" p03854,s068447400,Accepted,"S = input() k = [""dream"", ""dreamer"" ,""erase"", ""eraser""] ans = ""NO"" while len(S) > 0: a = len(S) for i in k: if S[-1*len(i):] == i: S = S[0:-1*len(i)] break if a == len(S): break elif len(S) == 0: ans=""YES"" print(ans) " p03854,s330684312,Accepted,"S = input() words = ['dreameraser','dreamerase','dreamer','dream','eraser','erase'] i = 0 while i < len(S): update = False for w in words: if S[i:].startswith(w): i += len(w) update =True break if not update: break print('YES' if i == len(S) else 'NO')" p03854,s436248689,Accepted,"import re print(""YES"" if re.fullmatch(""(eraser?|dream(er)?)+"", input()) else ""NO"")" p03854,s559552194,Accepted,"import re S = input() print(""YES"" if re.match(""^(dream|dreamer|erase|eraser)+$"", S) else ""NO"")" p03854,s062870012,Accepted,"s = input()[::-1] while s: if s[:5] == ""dream""[::-1] or s[:5] == ""erase""[::-1]: s = s[5:] elif s[:6] == ""eraser""[::-1]: s = s[6:] elif s[:7] == ""dreamer""[::-1]: s = s[7:] else: break else: print(""YES"") exit() print(""NO"")" p03854,s258285911,Accepted,"s=input()+'#' n=len(s) i=0 while i 0) and (len(S.replace('eraser', '').replace('erase', '').replace('dreamer', '').replace('dream', '')) == 0): print('YES') else: print('NO') " p03854,s902428959,Accepted,"s = input() dreamer = ""dreamer"" eraser = ""eraser"" dream = ""dream"" erase = ""erase"" while s != """": if s.endswith(dreamer): s = s[:-7] elif s.endswith(eraser): s = s[:-6] elif s.endswith(dream): s = s[:-5] elif s.endswith(erase): s = s[:-5] else: print(""NO"") exit() print(""YES"") " p03854,s739962696,Accepted,"import re s = input() s = re.sub(""eraser"","""",s) s = re.sub(""erase"","""",s) s = re.sub(""dreamer"","""",s) s = re.sub(""dream"","""",s) if len(s) == 0: print(""YES"") else: print(""NO"")" p03854,s237822227,Accepted,"s = input() s = s[::-1] t = [""dream"", ""dreamer"", ""erase"", ""eraser""] i = 0 while i < len(s) - 7 + 1: for j in t: if s[i:i + len(j)] == j[::-1]: i += len(j) break else: print(""NO"") break else: for j in t: if s[i:] == j[::-1] or s[i:] == """": print(""YES"") break else: print(""NO"") " p03854,s162686939,Accepted,"# ABC049 C def main(): s = input() if s.replace('eraser', '').replace('erase', '').replace('dreamer', '').replace('dream', ''): print('NO') else: print('YES') if __name__ == '__main__': main()" p03854,s188454066,Accepted,"def solve(): S = input()[::-1] i = 0 while i < len(S): if S[i:i+5] in ['maerd', 'esare']: i += 5 elif S[i:i+6] == 'resare': i += 6 elif S[i:i+7] == 'remaerd': i += 7 else: return 'NO' return 'YES' if __name__ == '__main__': ans = solve() print(ans)" p03854,s197014869,Accepted,"s=input() t="""" i=len(s) five=[""dream"",""erase""] flag=0 while s!=t: if i>=7 and s[i-7:i]==""dreamer"": t=s[i-7:i]+t i-=7 elif i>=6 and s[i-6:i]==""eraser"": t=s[i-6:i]+t i-=6 elif i>=5 and (s[i-5:i] in five): t=s[i-5:i]+t i-=5 else: flag=1 break if flag==0: print(""YES"") else: print(""NO"")" p03854,s642435279,Accepted,"s=input().replace(""eraser"","""").replace(""erase"","""").replace(""dreamer"","""").replace(""dream"","""") print(""YES"" if len(s)==0 else ""NO"")" p03854,s680398128,Accepted,"s = input() while len(s) > 7: if s[-5:] in [""dream"", ""erase""]: s = s[:-5] elif s[-6:] in [""eraser""]: s = s[:-6] elif s[-7:] in [""dreamer""]: s = s[:-7] else: break if (len(s)==5 and s in [""dream"", ""erase""]) or (len(s)==6 and s in [""eraser""]) or (len(s)==7 and s in [""dreamer""]): print(""YES"") else: print(""NO"")" p03854,s684468539,Accepted,"S = input() T = [""dream"",""dreamer"",""erase"",""eraser""] flag = True for i in range(len(S)): if (flag == False) or (len(S) == 0): break if S[-5:] in T: S = S[:-5] elif S[-6:] in T: S = S[:-6] elif S[-7:] in T: S = S[:-7] else: print(""NO"") flag = False if flag == True: print(""YES"")" p03854,s427020360,Accepted,"def main(): s=input() q=[0] m=len(s) l=[""dream"",""dreamer"",""erase"",""eraser""] while q: i=q.pop() if i==m: print(""YES"") return for j in l: nj=len(j) if i+nj<=m and s[i:i+nj]==j: q.append(i+nj) print(""NO"") main()" p03854,s235177300,Accepted,"s=str(input()) s=s[::-1] stack="""" for i in s: stack=i+stack if stack==""dream""or stack==""dreamer""or stack==""erase""or stack==""eraser"": stack="""" elif len(stack)>7: print(""NO"") exit() print(""YES"")" p03854,s924429702,Accepted,"S = input() while len(S)>0: if S[-7:] == ""dreamer"": S = S[:-7] elif S[-6:] == ""eraser"": S = S[:-6] elif S[-5:] == ""dream"": S = S[:-5] elif S[-5:] == ""erase"": S = S[:-5] else: break print(""YES"" if len(S)==0 else ""NO"")" p03854,s481469512,Accepted,"WORDS = ['dream', 'dreamer', 'erase', 'eraser'] REVERSED_WORDS = [word[::-1] for word in WORDS] def main(s): i = 0 while i < len(s): for word in REVERSED_WORDS: if s[i:].startswith(word): i += len(word) break else: print('NO') break else: print('YES') if __name__ == ""__main__"": main(input()[::-1]) " p03854,s661340612,Accepted,"def main(S): listdreamereraser = ['dreamer','eraser','dream','erase'] while True: for i in listdreamereraser: if i == S[-len(i):]: S = S[:-len(i)] break else: return False if len(S) == 0: return True S = input() print('YES' if main(S) else 'NO')" p03854,s484870841,Accepted,"import re print(""YES"" if re.match(""^(dream|dreamer|erase|eraser)+$"",input()) else ""NO"")" p03854,s880678524,Accepted,"S = input() while True: if S[-5:] == 'dream': S = S[:-5] continue elif S[-7:] == 'dreamer': S = S[:-7] continue elif S[-5:] == 'erase': S = S[:-5] continue elif S[-6:] == 'eraser': S = S[:-6] continue break answer = 'YES' if not S else 'NO' print(answer) " p03854,s555432624,Accepted,"S = input() words = [""dream"", ""dreamer"", ""erase"", ""eraser""] S_rv = S[::-1] words_rv = [word[::-1] for word in words] for i in range(len(S_rv)): for word_rv in words_rv: if S_rv[: len(word_rv)] == word_rv: S_rv = S_rv[len(word_rv) :] if len(S_rv) == 0: print(""YES"") else: print(""NO"") " p03854,s792240276,Accepted,"s = input().replace(""eraser"",'').replace('erase','').replace('dreamer','').replace('dream','') print('YES' if len(s) == 0 else 'NO')" p03854,s962281228,Accepted,"def main(): S = input() if S.replace(""eraser"", """").replace(""erase"", """")\ .replace(""dreamer"", """").replace(""dream"", """") == """": print(""YES"") else: print(""NO"") if __name__ == '__main__': main() " p03854,s470960692,Accepted,"S=input() S=S.replace('eraser','') S=S.replace('erase','') S=S.replace('dreamer','') S=S.replace('dream','') if S=='': print('YES') else: print('NO')" p03854,s476008659,Accepted,"s=input()[::-1] T=[""dream"",""dreamer"",""erase"",""eraser""] l,n=0,len(s) while l!=n: flag=0 for i in T: word=i[::-1] if s[l:l+len(word)]==word: l +=len(word) flag=1 break if flag==0:print(""NO"");exit() print(""YES"")" p03854,s347426365,Accepted,"S = input() divide = ['dream', 'dreamer', 'erase', 'eraser'] line = ['','','',''] for i in range(4): char = divide[i][::-1] line[i] = char s_str = S[::-1] char = '' for i in range(len(s_str)): char += s_str[i] if char in line: char = '' if char == '': print('YES') else: print('NO')" p03854,s217843556,Accepted,"str = input() words = [""dream"", ""dreamer"", ""erase"", ""eraser""] def replace(S, s): reversedS = S[::-1] reverseds = s[::-1] replaced = reversedS.replace(reverseds, """", 1) return replaced[::-1] while True: tmp = str for word in words: if str.endswith(word): str = replace(str, word) break if tmp == str: print(""NO"") break if str == """": print(""YES"") break tmp = str" p03854,s771487382,Accepted,"import re print(""YES"" if re.match(""^(dream|dreamer|erase|eraser)+$"",input()) else ""NO"") " p03854,s470331907,Accepted," s = input() words = ['dream', 'dreamer', 'erase', 'eraser'] while len(s) > 0: for word in words: flg = False if s.endswith(word): s = s[:(len(s) - len(word))] flg = True break if not flg: break if len(s) == 0: print('YES') else: print('NO') " p03854,s590863507,Accepted,"import re S = input() if re.match('^(dream|dreamer|erase|eraser)+$', S): print('YES') else: print('NO')" p03854,s741227423,Accepted,"s = input() def solve(query): while 1: for frag in (""erase"", ""eraser"", ""dream"", ""dreamer""): if query.endswith(frag): query = query[:-len(frag)] break else: print(""NO"") break if not query: print(""YES"") break solve(s)" p03854,s934246229,Accepted,"s = str(input()) no = 0 while 1: for data in [""erase"", ""eraser"", ""dream"", ""dreamer""]: if s.endswith(data): s = s[: - len(data)] else: no += 1 if not s: break if no == 4: print(""NO"") exit() else: no = 0 print(""YES"") " p03854,s154501943,Accepted,"import re s = input() if re.match('^(dream|dreamer|erase|eraser)+$', s): print('YES') else: print('NO')" p03854,s690557577,Accepted,"S = input() tmp = ''.join(list(reversed(S))) s = 0 ans = 'YES' for i in range(len(S)): if tmp[s:i] == 'maerd' or tmp[s:i] == 'remaerd'or tmp[s:i] == 'esare' or tmp[s:i] == 'resare': s = i ans = 'YES' continue if len(tmp[s:i]) > 7: ans = 'NO' break print(ans)" p03854,s003447679,Accepted,"import re def resolve(): s = input() if re.search(""^(dream|dreamer|erase|eraser)+$"", s): print(""YES"") else: print(""NO"") resolve() " p03854,s536479339,Accepted,"S= input() while len(S) >=0: if len(S) ==0: print(""YES"") break if S[-7:] == ""dreamer"": S = S[:-7] elif S[-6:] ==""eraser"": S = S[:-6] elif S[-5:] ==""dream"": S = S[:-5] elif S[-5:] ==""erase"": S = S[:-5] else: print(""NO"") break" p03854,s357409248,Accepted,"S = input() dire = ['dream','dreamer','erase','eraser'] DP = [0] * 100000 DP[0] = 1 for s in range(len(S)): if DP[s] != 1: continue for i in range(4): tmp = S[s: s+len(dire[i])] if tmp == dire[i]: DP[s + len(dire[i])] = 1 if DP[len(S)] == 1: print('YES') else: print('NO') " p03854,s698496988,Accepted,"import re print(""YES"" if re.match(""^(dream|dreamer|erase|eraser)+$"", input()) else ""NO"") " p03854,s695193945,Accepted,"s = input()[::-1] r = 'YES' while len(s): if s[:5] == 'dream'[::-1] or s[:5] == 'erase'[::-1]: s = s[5:] elif s[:6] == 'eraser'[::-1]: s = s[6:] elif s[:7] == 'dreamer'[::-1]: s = s[7:] else: r = 'NO' break print(r)" p03854,s799562039,Accepted,"import re S = input() print(""YES"" if re.match(""^(dream|dreamer|erase|eraser)+$"", S) else ""NO"")" p03854,s563779773,Accepted,"s = input() ans = ""YES"" while s != """": if len(s) < 5: ans = ""NO"" break elif s[len(s) - 5:] == ""dream"" or s[len(s) - 5:] == ""erase"": s = s[:len(s) - 5] elif s[len(s) - 6:] == ""eraser"": s = s[:len(s) - 6] elif s[len(s) - 7:] == ""dreamer"": s = s[:len(s) - 7] else: ans = ""NO"" break print(ans) " p03854,s626381552,Accepted,"s = input().replace(""eraser"","""").replace(""erase"","""").replace(""dreamer"","""").replace(""dream"","""") if s: print(""NO"") else: print(""YES"") " p03854,s317822553,Accepted,"def main(): S = input() for word in [""eraser"", ""erase"", ""dreamer"", ""dream""]: S = S.replace(word, ""."") # print(S) if len(set(S)) == 1: print(""YES"") else: print(""NO"") if __name__ == ""__main__"": main() " p03854,s348837683,Accepted,"s = input().replace(""eraser"","""").replace(""erase"","""").replace(""dreamer"","""").replace(""dream"","""") if s: print('NO') else: print('YES')" p03854,s973391357,Accepted,"s = input() words = [""dreamer"", ""dream"", ""eraser"", ""erase""] while len(s) > 0: match = [s.endswith(i) for i in words] if True in match: ans = words[match.index(True)] s = s[:-len(ans)] if len(s) == 0: print(""YES"") break else: print(""NO"") break" p03854,s726481104,Accepted,"import sys S = input() S = S[::-1] while S != '': if S[:5] == 'maerd': S = S[5:] elif S[:5] == 'esare': S = S[5:] elif S[:6] == 'resare': S = S[6:] elif S[:7] == 'remaerd': S = S[7:] else: print('NO') exit() print('YES')" p03854,s092213411,Accepted,"S = input() S = S[::-1] a = 'dream'[::-1] b = 'dreamer'[::-1] c = 'erase'[::-1] d = 'eraser'[::-1] words = [a, b, c, d] t = 0 for i in range(1, len(S) + 1): if S[t:i] in words: t = i if t == len(S): print('YES') else: print('NO') " p03854,s936232435,Accepted,"s = input() def solve(query): while 1: for frag in (""erase"", ""eraser"", ""dream"", ""dreamer""): if query.endswith(frag): query = query[:-len(frag)] break else: print(""NO"") break if not query: print(""YES"") break solve(s)" p03854,s980419814,Accepted,"s = input() s = s.replace('eraser', '').replace('erase', '').replace('dreamer', '').replace('dream', '') print('YES' if len(s) == 0 else 'NO')" p03854,s675033550,Accepted,"s=input() cnt=0 for i in range(len(s)): if s[-7:] == 'dreamer': s=s[:-7] elif s[-6:] == 'eraser': s=s[:-6] elif s[-5:] =='erase'or s[-5:]=='dream': s=s[:-5] elif s=='': break else: cnt+=1 break if cnt==0: print('YES') else: print('NO')" p03854,s645769531,Accepted,"s = input() flag = True while 1: if s[-7:] == ""dreamer"": s = s[:-7] elif s[-6:] == ""eraser"": s = s[:-6] elif s[-5:] == ""dream"" or s[-5:] == ""erase"": s = s[:-5] else: flag = False break if s == """": break if flag: print(""YES"") else: print(""NO"") " p03854,s938228943,Accepted,"s = input() lst = [""eraser"",""erase"",""dreamer"",""dream""] for w in lst: s = s.replace(w,"""") if len(s) == 0: ans = ""YES"" else: ans = ""NO"" print(ans)" p03854,s282762611,Accepted,"s = input() while 1: flag = False if s[-5:] in ['dream', 'erase']: s = s[:-5] flag = True elif s[-6:] == 'eraser': s = s[:-6] flag = True elif s[-7:] == 'dreamer': s = s[:-7] flag = True if not flag: break if not s: print('YES') else: print('NO') " p03854,s471002996,Accepted,"s = input()[::-1] now = 0 while now < len(s): if s[now:now + 7] == 'dreamer'[::-1]: now += 7 elif s[now:now + 6] == 'eraser'[::-1]: now += 6 elif s[now:now + 5] == 'dream'[::-1]: now += 5 elif s[now:now + 5] == 'erase'[::-1]: now += 5 else: print('NO') exit() print('YES') " p03854,s174706160,Accepted,"import sys sys.setrecursionlimit(10**6) s = input() def dfs(s): while True: f = True for i in ['erase', 'eraser', 'dream', 'dreamer']: if s[-len(i):]==i: s = s[:-len(i)] if s=='': return True f = False if f: return False if dfs(s): print('YES') else: print('NO')" p03854,s980884510,Accepted,"s=input()[::-1] words = {""dream"", ""dreamer"", ""erase"", ""eraser""} while len(s)!=0: for i in words: l = len(i) if s[0:l] == i[::-1]: s = s[l::] break else: break print(""NO""if len(s)!=0else ""YES"")" p03854,s684582975,Accepted,"def resolve(): s = input() w = ['dream', 'dreamer', 'erase', 'eraser'] h = dict() for i in range(len(w)): h[w[i][::-1]] = True s = s[::-1] c = '' for i in s: c += i if h.get(c): c = '' if not len(c): print('YES') else: print('NO') resolve()" p03854,s999295898,Accepted,"s = input()[::-1] ls = ['dream', 'dreamer', 'erase', 'eraser'] ls = [ls[i][::-1] for i in range(4)] ans = 'YES' i = 0 while i < len(s): ng = 1 for j in range(4): if s[i:i+len(ls[j])] == ls[j]: i += len(ls[j]) ng = 0 if ng: ans = 'NO' break print(ans)" p03854,s276671813,Accepted,"import sys cin = lambda: sys.stdin.readline().strip() cout = sys.stdout.write s = cin() s = s.replace(""eraser"",'') s = s.replace(""erase"",'') s = s.replace(""dreamer"",'') s = s.replace(""dream"",'') if(s == ''): cout(f""YES""+'\n') else: cout(f""NO""+'\n')" p03854,s370114759,Accepted,"S = input() SFlag = True while S: if S[-7:]=='dreamer': S = S[:-7] elif S[-6:]=='eraser': S = S[:-6] elif S[-5:]=='dream' or S[-5:]=='erase': S = S[:-5] else: SFlag = False break print(['NO','YES'][SFlag])" p03854,s551738598,Accepted,"s = input() n = 0 while n == 0: if s[len(s)-5:len(s)] == ""dream"": s = s[:len(s)-5] elif s[len(s)-5:len(s)] == ""erase"": s = s[:len(s)-5] elif s[len(s)-7:len(s)] == ""dreamer"": s = s[:len(s)-7] elif s[len(s)-6:len(s)] == ""eraser"": s = s[:len(s)-6] else: if len(s) == 0: n = 1 print(""YES"") else: n = -1 print(""NO"") " p03854,s037364754,Accepted,"s = str(input()) s = s.replace('eraser','') s = s.replace('erase','') s = s.replace('dreamer','') s = s.replace('dream','') if s == '': print('YES') else: print('NO') " p03854,s822608739,Accepted,"S = input() t = len(S) words = ['dream', 'dreamer', 'erase', 'eraser'] while True: flg = True for i in range(t, -1, -1): if S[i:t] in words: t = i flg = False if flg: print('NO') break if t == 0: print('YES') break" p03854,s156564943,Accepted,"S = input() words = (""dream"", ""dreamer"", ""erase"", ""eraser"") for _ in range((len(S) + 4) // 5): for word in words: if S.endswith(word): S = S[: -len(word)] print(""NO"") if S else print(""YES"") " p03854,s840541741,Accepted,"st = input() S = st[::-1] words ={""remaerd"",""resare"",""maerd"",""esare""} lenT = 0 flag = 0 ans = ""NO"" while flag < 5: for i in range(5, 8): if S[0:i] in words: S = S[i:] flag = 0 elif S == """": flag = 5 ans = ""YES"" break else: flag += 1 print(ans)" p03854,s293625500,Accepted,"s = input().replace(""eraser"", """").replace(""erase"", """").replace(""dreamer"", """").replace(""dream"", """") if s: print(""NO"") else: print(""YES"")" p03854,s522942939,Accepted,"s = input() s = s.replace('eraser','*') s = s.replace('erase','*') s = s.replace('dreamer','*') s = s.replace('dream','*') s = s.replace('*','') if len(s) == 0: print('YES') else: print('NO')" p03854,s337494962,Accepted,"S=input() word=[""dream"", ""dreamer"", ""erase"", ""eraser""] dp=[0]*(len(S)+1) dp[0]=1 done=""NO"" for i in range(len(S)+1): if dp[i]==0: continue for w in word: if S[i:i+len(w)]== w: dp[i+len(w)]=1 if (dp[len(S)]==1): done= ""YES"" print(done) " p03854,s415999646,Accepted,"import re S = input() if re.match(""^(dream|dreamer|erase|eraser)+$"", S): print('YES') else: print('NO')" p03854,s368325153,Accepted,"S = input()[::-1] text = ['dream','dreamer','erase','eraser'] text = [t[::-1] for t in text] while len(S) > 0: for t in text: if S.find(t) == 0: S = S[len(t):] break else: print('NO') break else: print('YES')" p03854,s591036353,Accepted,"import re N = str(input()) words = re.findall(""^(dream|dreamer|erase|eraser)+$"", N) print('NO') if words == [] else print('YES')" p03854,s180034062,Accepted,"s = input()[::-1] l5 = [""dream""[::-1], ""erase""[::-1]] l6 = [""eraser""[::-1]] l7 = [""dreamer""[::-1]] ans = ""YES"" while len(s) > 4: if s[:5] in l5: s = s[5:] elif s[:6] in l6: s = s[6:] elif s[:7] in l7: s = s[7:] else: ans = ""NO"" break print(ans)" p03854,s250571416,Accepted,"s=input().strip() s=s.replace(""eraser"","""") s=s.replace(""erase"","""") s=s.replace(""dreamer"","""") s=s.replace(""dream"","""") print(""YES"" if not s else ""NO"")" p03854,s100058859,Accepted,"import re print(""YES"" if re.match(""^(dream|dreamer|erase|eraser)+$"", input()) else ""NO"")" p03854,s319460102,Accepted,"S = input() # 後ろから削除したいので、反転して前から削除する S = S[::-1] words = {'maerd', 'remaerd', 'esare', 'resare'} while len(S) > 0: orig = S for w in words: if S.startswith(w): S = S[len(w):] break if orig == S: break if len(S) == 0: print('YES') else: print('NO')" p03854,s359778895,Accepted,"s = str(input()) s = s[-1::-1] while True : if len(s) == 0: print('YES') break elif s[0:5] == 'esare': s = s[5:] elif s[0:6] == 'resare': s = s[6:] elif s[0:5] == 'maerd': s = s[5:] elif s[0:7] == 'remaerd' : s = s[7:] else : print('NO') break" p03854,s909072279,Accepted,"def main(): s = input() ref = ['eraser','erase','dreamer','dream'] for i in range(4): s = s.replace(ref[i], '') if not s: print(""YES"") else: print(""NO"") main()" p03854,s113147958,Accepted,"s = input() tmp = """" cnt = 0 for c in reversed(s): tmp = c + tmp if tmp in [""dream"", ""dreamer"", ""erase"", ""eraser""]: cnt += len(tmp) tmp = """" if cnt == len(s): print(""YES"") else: print(""NO"")" p03854,s846029287,Accepted,"s = input()[::-1] s = s.replace(""eraser""[::-1], """") s = s.replace(""erase""[::-1], """") s = s.replace(""dreamer""[::-1], """") s = s.replace(""dream""[::-1], """") if s == """": print(""YES"") else: print(""NO"") " p03854,s446016582,Accepted,"#049_C s = input()[::-1] k = ['maerd', 'remaerd', 'esare', 'resare'] tmp = 0 flg = True while tmp < len(s): check = False for x in k: if s[tmp: tmp + len(x)] == x: check = True tmp += len(x) if check == False: flg = False break print('YES' if flg else 'NO')" p03854,s118959539,Accepted,"# -*- coding:utf-8 -*- from collections import deque divide = [""dream"", ""dreamer"", ""erase"", ""eraser""]; s = input() que = deque() can = ""NO"" que.append(0) while(len(que) > 0): t = que.pop() if (t == len(s)): can = ""YES"" break for e in divide: if s[t:t+len(e)] == e: que.append(t+len(e)) print(can)" p03854,s069010035,Accepted,"import sys s = input() data = {""dream"",""dreamer"",""erase"",""eraser""} while True: for i in data: if s.endswith(i): s = s[:-len(i)] break else:break if s == """": print(""YES"") sys.exit() else: print(""NO"") sys.exit()" p03854,s830737871,Accepted,"S=input() def solve(query): while 1: if not query: print(""YES"") break for frag in (""erase"",""eraser"",""dream"",""dreamer""): if query.endswith(frag): query=query[:-len(frag)] break else: print(""NO"") break solve(S)" p03854,s077815641,Accepted,"string = input() flg = True while len(string) > 0: if string.endswith('dream'): string = string[:-5] elif string.endswith('dreamer'): string = string[:-7] elif string.endswith('erase'): string = string[:-5] elif string.endswith('eraser'): string = string[:-6] else: print('NO') flg = False break if flg: print('YES')" p03854,s990956842,Accepted,"S=input() dp=[False]* (len(S)+1) dp[0] = True for i in range(1, len(dp)): for w in [ 'dream', 'dreamer', 'erase', 'eraser']: if dp[i-len(w)] and w == S[i-len(w):i]: dp[i] = True if dp[-1]: print('YES') else: print('NO') " p03854,s475553101,Accepted,"S = input() idx = len(S) while idx > 0: if S[idx-7:idx] == ""dreamer"": idx -= 7 elif S[idx-6:idx] == ""eraser"": idx -= 6 elif S[idx-5:idx] in [""dream"", ""erase""]: idx -= 5 else: print(""NO"") break else: print(""YES"")" p03854,s126091767,Accepted,"s = str(input()) s = s[::-1] #sを逆にする l = ['resare', 'esare', 'remaerd', 'maerd'] f = 0 if len(s) == 0: f = 1 while len(s) != 0: if s[:7] == 'remaerd': s = s[7::] elif s[:6] == 'resare': s = s[6::] elif s[:5] == 'esare': s = s[5:] elif s[:5] == 'maerd': s = s[5:] else: f = 1 break if f == 1: print(""NO"") else: print(""YES"") " p03854,s712149976,Accepted,"S = input() TEXTS = ['dream', 'dreamer', 'erase', 'eraser'] is_updated = True while is_updated and len(S) > 0: is_updated = False for text in TEXTS: if S[len(S) - len(text):] == text: S = S[:len(S) - len(text)] is_updated = True if S == '': print('YES') else: print('NO')" p03854,s116154592,Accepted,"import sys from collections import deque s = input() queue = deque() queue.append(0) candidates = ['dream', 'dreamer', 'erase', 'eraser'] index = 0 while queue: index = queue.popleft() match = False for candidate in candidates: if s[index:index + len(candidate)] == candidate: match = True if index + len(candidate) == len(s): print('YES') sys.exit(0) queue.append(index + len(candidate)) print('NO') " p03854,s507717727,Accepted,"s = input() s = s[::-1] while s: if s[:5]=='maerd': s = s[5:] elif s[:7] =='remaerd': s = s[7:] elif s[:5] =='esare': s = s[5:] elif s[:6] =='resare': s = s[6:] else: print('NO');exit() print('YES')" p03854,s467715278,Accepted,"s = input() ans = '' while 1: if s[-7:] == 'dreamer': s = s[:-7] continue if s[-6:] == 'eraser': s = s[:-6] continue if s[-5:] == 'dream': s = s[:-5] continue if s[-5:] == 'erase': s = s[:-5] continue if s == '': ans = 'YES' break else: ans = 'NO' break print(ans)" p03854,s552471122,Accepted,"S=input() n=len(S) while n>0: if S[n-5:n]=='dream': n-=5 elif S[n-5:n]=='erase': n-=5 elif S[n-7:n]=='dreamer': n-=7 elif S[n-6:n]=='eraser': n-=6 else: print('NO') exit() print('YES')" p03854,s916880926,Accepted,"S=input() flag=False while True: if S[-5:] == 'dream' or S[-5:] == 'erase': S = S[:-5] elif S[-6:] == 'eraser': S = S[:-6] elif S[-7:] == 'dreamer': S = S[:-7] else: break if len(S)==0: print('YES') else: print('NO') " p03854,s160598234,Accepted,"s=input() s = s[::-1] #文字の反転 t = 0; while t ==0: a = s.find(""maerd"") b = s.find(""remaerd"") c = s.find(""esare"") d = s.find(""resare"") if a == 0 or c== 0: s = s[5:] continue if b == 0: s = s[7:] continue if d == 0: s = s[6:] continue t=1 if s == """": print(""YES"") else: print(""NO"")" p03854,s696662610,Accepted,"S=input() while(len(S)>=5): if(len(S)>=7 and S[len(S)-7:len(S)]=='dreamer'): S=S[:len(S)-7] elif(len(S)>=6 and S[len(S)-6:len(S)]=='eraser'): S=S[:len(S)-6] elif(S[len(S)-5:len(S)]=='dream' or S[len(S)-5:len(S)]=='erase'): S=S[:len(S)-5] else: print(""NO"") exit() if(len(S)!=0): print(""NO"") else: print(""YES"")" p03854,s142235847,Accepted,"s = input() n = len(s) dp = [0] * (n+1) dp[0] = 1 for i in range(1,n+1): if i >= 5: if s[i-5:i] == ""dream"" or s[i-5:i] == ""erase"": dp[i] = dp[i-5] if i >= 6: if s[i-6:i] == ""eraser"": dp[i] = dp[i-6] if i >= 5: if s[i-7:i] == ""dreamer"": dp[i] = dp[i-7] if dp[n]: print('YES') else: print('NO') " p03854,s842769948,Accepted,"S=input() check=[""dream"",""dreamer"",""erase"",""eraser""] S=S[::-1] for i in range(len(check)): check[i]=check[i][::-1] nagasa=len(S) cur=0 while cur 7: print(""NO"") return print(""YES"") main()" p03854,s934278932,Accepted,"s = input() def solve(query): while 1: for frag in (""erase"", ""eraser"", ""dream"", ""dreamer""): if query.endswith(frag): query = query[:-len(frag)] break else: print(""NO"") break if not query: print(""YES"") break solve(s)" p03854,s757599276,Accepted," S = input() T = """" U = [""dreamer"", ""dream"", ""eraser"", ""erase""] tmp = """" for s in S[::-1]: tmp = s + tmp if tmp in U: T = tmp + T tmp = """" if T == S: print(""YES"") else: print(""NO"")" p03854,s645550357,Accepted,"s = input() s = s.replace('eraser', '') s = s.replace('erase', '') s = s.replace('dreamer', '') s = s.replace('dream', '') if s == '': print('YES') else: print('NO')" p03854,s934083535,Accepted,"a = list(input()) while len(a) >= 5: if a[-5:] == list('dream'): del a[-5:] continue if a[-7:] == list('dreamer'): del a[-7:] continue if a[-5:] == list('erase'): del a[-5:] continue if a[-6:] == list('eraser'): del a[-6:] continue break if a == []: print('YES') else: print('NO')" p03854,s348958706,Accepted,"def resolve(): S = input() while len(S) >= 5: if S[-7:] == ""dreamer"": S = S[:-7] elif S[-6:] == ""eraser"": S = S[:-6] elif S[-5:] == ""dream"" or S[-5:] == ""erase"": S = S[:-5] else: break print(""YES"" if len(S) == 0 else ""NO"") resolve()" p03854,s001687739,Accepted,"s=input() n=len(s) i=1 for j in range(n//5): if s[-i:-i-5:-1]==""maerd"": i+=5 if s[-i:-i-5:-1]==""esare"": i+=5 if s[-i:-i-6:-1]==""resare"": i+=6 if s[-i:-i-7:-1]==""remaerd"": i+=7 if i==n+1: print(""YES"") break if i != n+1: print(""NO"")" p03854,s233573519,Wrong Answer,"s = input() s = s.replace(""dreamer"", """") s = s.replace(""dream"", """") s = s.replace(""eraser"", """") s = s.replace(""erase"", """") if len(s) > 0: print(""NO"") else: print(""YES"")" p03854,s158156324,Wrong Answer,"S = input() results = True while results: for key_word in [""erase"", ""eraser"", ""dream"", ""dreamer""]: if S.endswith(key_word): S = S[:-len(S)] continue if S == '': print(""YES"") results = False break else: print(""NO"") results = False break" p03854,s172861348,Wrong Answer,"S = input() l = ['maerd','remaerd', 'esare', 'resare'] def test(S,l): tmpS = S while len(tmpS) > 0: if tmpS[::-1] in l: print('YES') return if tmpS[-1:-6:-1] in l: tmpS = tmpS[:-5] elif tmpS[-1:-7:-1] in l: tmpS = tmpS[:-6] else: print('NO') return print('YES') return test(S,l)" p03854,s921994138,Wrong Answer,"words=[""eraser"",""erase"",""dreamer"",""dream""] S=input() for i in range(0,4): S=S.replace(words[i],"""",) if S=="""": print(""Yes"") else: print(""No"") " p03854,s126980927,Wrong Answer,"init = input() words = [ 'dream', 'dreamer', 'erase', 'eraser' ] def reverseWord(str): return str[::-1] def elimTheWord(str): for word in reversed_words: if str.find(word) == 0: str = str[len(word):] return str reversed_words = list(map(reverseWord, words)) # main target = reverseWord(init) while True: pivot = elimTheWord(target) if pivot == '': print('Yes') break if pivot == target: print('No') break target = pivot" p03854,s216206146,Wrong Answer,"s = input() s=s[::-1] A=[""dream"",""dreamer"",""erase"",""eraser""] for i in range(len(A)): A[i]=A[i][::-1] i=0 ans=""Yes"" while True: if len(s)==i: break elif s[i:i+5]==A[0]: i+=5 elif s[i:i+7]==A[1]: i+=7 elif s[i:i+5]==A[2]: i+=5 elif s[i:i+6]==A[3]: i+=6 else: ans=""No"" break print(ans)" p03854,s150618051,Wrong Answer,"s = input() s = s.replace(""eraser"", ""X"") s = s.replace(""dreamer"", ""X"") s = s.replace(""erase"", ""X"") s = s.replace(""dream"", ""X"") count = s.count(""X"") if len(s) == count: print(""Yes"") else: print(""No"")" p03854,s131424746,Wrong Answer,"s=input() s.replace(""eraser"","""") s.replace(""erase"","""") s.replace(""dreamer"","""") s.replace(""dream"","""") if len(s)==0: print(""YES"") else: print(""NO"")" p03854,s185213941,Wrong Answer,"S = input() sc = [""dreameraser"", ""dreamerase"", ""dreamer"", ""dream"", ""eraser"", ""erase""] for i in sc: S = S.replace(i, '') if len(S) == 0: print(""YES"") else: print(""NO"")" p03854,s651442987,Wrong Answer,"S = input() ls = {""dream"",""dreamer"",""erase"",""eraser""} now = """" for i in range(len(S)): now += S[i] if now in ls: now = """" if now == """": print(""YES"") else: print(""NO"")" p03854,s139920715,Wrong Answer,"s = input() sc = [""dreameraser"", ""dreamerase"", ""dreamer"", ""dream"", ""eraser"", ""erase""] for i in sc: s = s.replace(i, '') if len(s) == 0: print(""YES"") else: print(""NO"")" p03854,s820314906,Wrong Answer,"S = input() S_r = S[::-1] Ss = [""maerd"",""remaerd"",""esare"",""resare""] for s in Ss: S_r = S_r.replace(s,"""") if S_r == """": print(""YES"") else: print(""NO"")" p03854,s881743172,Wrong Answer,"S = input() strs = [""erase"", ""eraser"", ""dreamer"",""dream""] rtss = [s[::-1] for s in strs] S_r = S[::-1] for rts in rtss: S_r = S_r.replace(rts, """") if len(S_r) == 0: print(""Yes"") else: print(""No"")" p03854,s928224405,Wrong Answer,"s = input() import re output =""NO"" s = re.sub('dreamer', '', s) s = re.sub('dream', '', s) s = re.sub('eraser', '', s) s = re.sub('erase', '', s) if s == """": output = ""YES"" print(output) " p03854,s519833168,Wrong Answer,"#049_C s = input() s = s.replace('dream', '').replace('dreamr', '').replace('erase', '').replace('eraser', '') print('YES' if s == '' else 'NO')" p03854,s361209815,Wrong Answer,"import re flag = re.match('^(deram|dreamer|erase|eraser)+$',input()) if flag: print('YES') else: print('NO') " p03854,s143281014,Wrong Answer,"# coding: utf-8 # Your code here! s = input() word_list = [""dream"",""dreamer"",""eraser"",""erase""] for i in word_list: s = s.replace(i,""."") if len(set(s)) == 1: print(""YES"") else: print(""NO"")" p03854,s988473541,Wrong Answer,"import sys s = input() a = 'dream' b = 'dreamer' c = 'erase' d = 'eraser' for i in range(len(s)): if not s[i] == a[i//4] or s[i] == b[i//5] or s[i] == c[i//4] or s[i] == d[i//5]: print('NO') sys.exit( ) print('YES')" p03854,s542645831,Wrong Answer,"listseer =['dreameraser', 'dreamerase', 'dreamer', 'eraser', 'dream', 'erase'] S = input() for i in listseer: S = S.replace(i, '') print('YES' if len(S) == 0 else 'NO')" p03854,s323106523,Wrong Answer,"from collections import deque s = input() q = deque(list(s)) while q: if len(q) >= 5: subs = q.popleft()+q.popleft()+q.popleft()+q.popleft()+q.popleft() if subs != 'erase' and subs != 'dream': print('NO') exit() if subs == 'erase' and len(q) != 0 and q[0] == 'r': q.popleft() else: print('NO') exit() print('YES')" p03854,s126083529,Wrong Answer,"s = str(input()) i = 0 while(1): if len(s) - i < 5: break if s[i:i+5] == ""erase"" or s[i:i+5] == ""dream"": i += 5 if s[i:i+2] == ""er"": i += 2 else: print(""No"") exit() print(""YES"" if i == len(s) else ""NO"")" p03854,s176228523,Wrong Answer,"s = input() import re output =""NO"" s = re.sub('dreameraser', '', s) s = re.sub('dreamerase', '', s) s = re.sub('dreamer', '', s) s = re.sub('dream', '', s) s = re.sub('eraser', '', s) s = re.sub('erase', '', s) if s == """": output = ""YES"" print(output) " p03854,s027493256,Wrong Answer,"import itertools input_moji = input() count = 0 lis = ['dream','dreamer', 'erase','eraser'] origin_list = ['dream','dreamer', 'erase','eraser'] for i in itertools.product(origin_list, repeat=2): total = """".join([str(_) for _ in i]) if input_moji == total: count += 1 print('YES') if count == 0: print('NO')" p03854,s059474967,Wrong Answer,"S = input()[::-1] S = S.replace('dream'[::-1], '').replace('dreamer'[::-1], '').replace( 'eraser'[::-1], '').replace('erase'[::-1], '') if len(S) == 0: print('YES') else: print('NO') " p03854,s101155167,Wrong Answer,"li = input() list = ['dream','dreamer','erase','eraser'] flag = 'NO' for x in list: for y in list: z = x + y if z == li: flag = 'YES' print(flag)" p03854,s448699380,Wrong Answer,"S = input() strs = list(reversed(S)) rev_S = ''.join(strs) while True: if len(rev_S)< 5: break elif rev_S[:6] == 'resare'or rev_S[:6] == 'remaerd': rev_S = rev_S[6:] continue elif rev_S[:5] == 'esare' or rev_S[:5] == 'maerd': rev_S = rev_S[5:] continue else: break if rev_S == '': print('YES') else: print('NO')" p03854,s930694590,Wrong Answer,"S = input() while len(S)>0: if S[-7:] == ""deamer"": S = S[:-7] elif S[-6:] == ""eraser"": S = S[:-6] elif S[-5:] == ""dream"": S = S[:-5] elif S[-5:] == ""erase"": S = S[:-5] else: break print(""NO"" if len(S)>0 else ""YES"")" p03854,s781005299,Wrong Answer,"S = input().replace(""eraser"","""").replace(""erase"","""").replace(""dream"","""").replace(""dreamer"","""") if S: print(""YES"") else: print(""NO"")" p03854,s530301792,Wrong Answer,"S = input() T = '' words = ['dream', 'dreamer', 'erase', 'eraser'] for i in range(len(words)): words[i] = words[i][::-1] for i in S[::-1]: T += i for q in words: if T == q: T = '' if T == '': print('YES') else: print('No')" p03854,s952486759,Wrong Answer,"S = input() while True : if S[0:5] == ""dream"": S = S.replace(""dream"","""") elif S[0:6] == ""eraser"": S = S.replace(""eraser"","""") elif S[0:7] == ""dreamer"": S = S.replace(""dreamer"","""") elif S[0:5] == ""erase"": S = S.replace(""erase"","""") elif len(S) == 0: print(""YES"") break else: print(""NO"") break" p03854,s315201581,Wrong Answer,"s = input() def solve(query): while 1: for frag in (""erase"", ""eraser"", ""dream"", ""dreamer""): if query.endswith(frag): query = query[:-len(frag)] print(""cut"", frag) break else: print(""NO"", query) break if not query: print(""YES"") break solve(s)" p03854,s335676683,Wrong Answer,"S=input() str_list=[""dream"",""dreamer"",""erase"",""eraser""] S_tmp="""" while True: S_tmp=S for str in str_list: S=S.replace(str,"""") #rstrip(str)はだめ if S_tmp==S: break if S=="""": print(""Yes"") if S!="""": print(""No"") " p03854,s567744890,Wrong Answer,"S = input().replace(""eraser"","""").replace(""erase"","""").replace(""dream"","""").replace(""dreamer"","""") if S =="""": print(""YES"") else: print(""NO"")" p03854,s933531264,Wrong Answer,"# C - 白昼夢 S = input() S2 = S W_L = [""dream"",""dreamer"",""erase"",""eraser""] while True: for w in W_L: if S2.endswith(w): S2 = S2[:-(len(w))] else: print('NO') exit() if len(S2)<=7: break if S2 ==''or S2 in W_L: print('YES') else: print('NO')" p03854,s910863299,Wrong Answer,"s = input() s = s.replace(""dreamer"", """") s = s.replace(""dream"", """") s = s.replace(""erase"", """") s = s.replace(""eraser"", """") if len(s) == 0: print(""YES"") else: print(""NO"")" 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')" p03854,s019913694,Wrong Answer,"s = input() strset = {'dream': 5, 'dreamer': 7, 'erase': 5, 'eraser': 6} while len(s)>0: if s[0:6] == 'eraser': s = s[6:] print(s) elif s[0:7] == 'dreamer': s = s[7:] print(s) elif s[0:5] == 'dream' or s[0:5] == 'erase': s = s[5:] print(s) else: print('NO') exit() print('YES')" p03854,s005216035,Wrong Answer,"s=input() while len(s)>7: if s[-5:]=='dream' or s[-5:]=='erase': s=s[-5:] elif s[-6:]=='eraser': s=s[-6:] else: s=s[-7:] print('YES' if s=='erase' or s=='dreamer' or s=='dream' or s=='eraser' or s=='' else 'NO')" p03854,s277211926,Wrong Answer,"s=input() s=s.replace(""eraser"","""") s=s.replace(""erase"","""") s=s.replace(""dreamer"","""") s=s.replace(""dream,"","""") if s: print(""NO"") else: print(""YES"")" p03854,s948635545,Wrong Answer,"s = input() s = list(s) s = s[::-1] word_list = ['maerd', 'remaerd', 'esare', 'resare'] i = 0 while i != len(s): a = s[i:i+5] a = ''.join(a) b = s[i:i+6] b = ''.join(b) if a in word_list: i += 5 elif b in word_list: i += 6 else: print('NO') exit() print('YES')" p03854,s597531412,Wrong Answer,"import re print(""YES"" if re.match(""^(dream|dreamer|erase|eraser)+$"",input()) else ""No"")" p03854,s521492244,Wrong Answer,"init = input() words = [ 'dream', 'dreamer', 'erase', 'eraser' ] def reverseWord(str): return str[::-1] def elimTheWord(str): for word in reversed_words: if str.find(word) == 0: str = str[len(word):] return str reversed_words = list(map(reverseWord, words)) # main target = reverseWord(init) while True: pivot = elimTheWord(target) if pivot == '': print('Yes') break if pivot == target: print('No') break target = pivot" p03854,s917622679,Wrong Answer,"s=input() ans='YES' while s!='': if s[:7]=='dreamer': s=s.lstrip('dreamer') elif s[:5]=='dream': s=s.lstrip('dream') elif s[:6]=='eraser': s=s.lstrip('eraser') elif s[:5]=='erase': s=s.lstrip('erase') else: ans='NO' break print(ans) " p03854,s209818496,Wrong Answer,"s=str(input()) x=len(s) a=s.count(""dream"") b=s.count(""dreamer"") c=s.count(""erase"") d=s.count(""eraser"") e=s.count(""dreameraser"") a-=b c-=d if 5*(a+c)+6*(b+d)-e==x: print(""YES"") else: print(""NO"")" p03854,s730846647,Wrong Answer,"s = input() u = ['dreamer', 'eraser', 'dream', 'erase'] while len(s) > 0: for i in u: if s[-len(i):-0] == i: s = s.rstrip(i) break else: print('No') exit() else: print(""YES"")" p03854,s866347038,Wrong Answer,"s=input() s=s.replace(""eraser"","""") s=s.replace(""erase"","""") s=s.replace(""dreamer"","""") s=s.replace(""drea,"","""") if s: print(""NO"") else: print(""YES"")" p03854,s818161989,Wrong Answer,"q = ['dream','dreamer','erase','eraser'] s = input() while True: if len(s) == 5 or len(s) == 7 or len(s) == 6: break if s[-5:] in q: s = s[0:-5] elif s[-7:] in q: s = s[0:-7] elif s[-6:] in q: s = s[0:-6] else: print('N0') exit() if s in q: print('YES') else: print('NO')" p03854,s022203697,Wrong Answer,"S = input() # Greedyアルゴリズム S = S[::-1] print(S) S = S.replace(""resare"","""") S = S.replace(""esare"","""") S = S.replace(""remaerd"","""") S = S.replace(""maerd"","""") if S == """": print(""YES"") else: print(""NO"") " p03854,s301773357,Wrong Answer,"S = input() if len(S) == 0: print('NO') else: if len(S.replace('dreamer', '').replace('dream', '').replace('eraser', '').replace('erase', '')) == 0: print('YES') else: print('NO')" p03854,s938137305,Wrong Answer,"s=input().replace(""eraser"","""").replace(""dreamer"","""").replace(""erase"","""").replace(""dream"","""") if s=="""":print('YES') else:print('NO')" p03854,s864850386,Wrong Answer,"S = input() replaced_t = S.replace('dreamer','').replace('dream', '').replace('eraseer', '').replace('erase', '') if replaced_t: print('NO') else: print('YES')" p03854,s823291725,Wrong Answer,"s=""dreamerer"" s=s.replace('eraser','').replace('erase','').replace('dreamer','').replace('dream','') if len(s)==0:print(""YES"") else:print(""NO"") " 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"")" p03854,s882216615,Wrong Answer,"import re print(""Yes"" if re.match(""^(dream|dreamer|erase|eraser)+$"", input()) else ""No"")" p03854,s972702772,Wrong Answer,"# C - 白昼夢 S = input() S2 = S W_L = [""dream"",""dreamer"",""erase"",""eraser""] while True: for w in W_L: if S2.endswith(w): S2 = S2[:-(len(w))] if len(S2)<=7 or not S2.endswith(w): break if S2 ==''or S2 in W_L: print('YES') else: print('NO')" p03854,s113924161,Wrong Answer,"s=input() s1=s.replace(""eraser"",""0"").replace(""erase"",""0"").replace(""dreamer"",""0"").replace(""dream"",""0"") n=len(s1) flag=False for i in range(0,n): if s1[i]!='0': flag=True break if flag==False: print(""Yes"") else: print(""No"") " p03854,s695945288,Wrong Answer,"S = input() s = reversed(S) T = '' for i in s: T += i if T in ['maerd', 'remaerd', 'esare', 'resare']: T = '' if len(T) >= 6: print('NO') break if len(T) == 0: print('YES') " 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) " p03854,s243850162,Wrong Answer,"s = input() a = s.count(""dream"") b = s.count(""dreamer"") c = s.count(""erase"") d = s.count(""eraser"") e = s.count(""dreamera"") f = s.count(""erasera"") b = b-e d = d-f a = a-b c = c-e if (a+c)*5 + b*7 + d*6 == len(s): print(""Yes"") else: print(""No"")" p03854,s157369480,Wrong Answer,"s = input() while s!="""": if s[-5:]==""dream"" or s[-5:]==""erase"": s = s[:-5] elif s[-6:]==""dreamer"" or s[-6:]==""eraser"": s = s[:-6] else: print(""NO"") exit() print(""YES"") " p03854,s203228971,Wrong Answer,"import re S = input() if re.match(""^(dreamer|dream|erase|eraser)+$"", S): print(""Yes"") else: print(""No"")" p03854,s585103256,Wrong Answer,"s = input() length = len(s) i = 0 res = ""YES"" while i < length: if i+4 <= length and s[i:i+5] == ""dream"": i += 5 if i+1 <= length and s[i:i+2] == ""er"" and s[i+2] != ""a"": i += 2 else: res = ""NO"" break if i+4 <= length and s[i:i+5] == ""erase"": i += 5 if i+1 <= length and s[i:i+2] == ""er"" and s[i+2] != ""a"": i += 2 else: res = ""NO"" break print(res)" p03854,s243893184,Wrong Answer,"s = input() d = { ""eam"":5, ""mer"":7, ""ase"":5, ""ser"":6} index = len(s) while index != 0: tmp = s[index-3:index] if tmp not in d.keys(): break index -= d[tmp] if index < 0: break else: print(""YES"") exit() print(""NO"") " p03854,s279420101,Wrong Answer,"S = input() while True : if S[0:7] == ""dreamer"": S = S.replace(""dreamer"","""") elif S[0:6] == ""eraser"": S = S.replace(""eraser"","""") elif S[0:5] == ""dream"": S = S.replace(""dream"","""") elif S[0:5] == ""erase"": S = S.replace(""erase"","""") elif len(S) == 0: print(""YES"") break else: print(""NO"") break" p03854,s164215996,Wrong Answer,"s = input() while len(s) >= 5: if len(s) >= 5 and s[-5:] == 'dream': s = s[:-5] elif len(s) >= 7 and s[-7:] == 'dreamer': s = s[:-7] elif len(s) >= 5 and s[-5:] == 'erase': s = s[:-5] elif len(s) >= 6 and s[-6:] == 'eraser': s = s[:-6] else: break if len(s) == 0: print('YES') else: print('No') " p03854,s135187174,Wrong Answer,"s = input().replace('eraser','').replace('dreamer','').replace('erase','').replace('dream','') print('YES' if s=='' else 'NO')" p03854,s249589511,Wrong Answer,"s = input() def solve(query): while 1: for frag in (""erase"", ""eraser"", ""dream"", ""dreamer""): if query.endswith(frag): query = query.rstrip(""frag"") break else: print(""NO"") break if not query: print(""YES"") break solve(s)" p03854,s594704642,Wrong Answer,"#049_C s = input() s = s.replace('dreamer', '').replace('dream', '').replace('eraser', '').replace('erase', '') print('YES' if s == '' else 'NO')" p03854,s176592011,Wrong Answer,"s = input() D = ['dream', 'dreamer'] E = ['erase', 'eraser'] T = ['dream', 'dreamer', 'erase', 'eraser'] if s[0] == 'd': for d in D: for t in T: if s == d+t: print('YES') exit() if s[0] == 'e': for e in E: for t in T: if s == e+t: print('YES') exit() print('NO') " p03854,s928504121,Wrong Answer,"S = list(input()) S.reverse() S = ''.join(S) st = ['maerd','remeard','esare','resare'] ans = 'YES' while S != '': if S[0:5] in st: S = S[5:] elif S[0:4] in st: S = S[4:] elif S[0:6] in st: S = S[6:] else: ans = 'NO' break print(ans)" 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"")" p03854,s111148710,Wrong Answer,"# coding: utf-8 # Your code here! s = input() word_list = [""dreamer"",""dream"",""eraser"",""erase""] for i in word_list: s = s.replace(i,""."") if len(set(s)) == 1: print(""YES"") else: print(""NO"")" p03854,s365408755,Wrong Answer,"import sys input = sys.stdin.readline S = input().rstrip() while S: if S[-5:] == ""dream"": S = S[:-5] elif S[-5] == ""erase"": S = S[:-5] elif S[-6:] == ""eraser"": S = S[:-6] elif S[-7:] == ""dreamer"": S = S[:-7] else: print(""NO"") sys.exit() print(""YES"") " p03854,s842723455,Wrong Answer,"s = input() s = s.replace(""erase"", """") s = s.replace(""eraser"", """") s = s.replace(""dreamer"", """") s = s.replace(""dream"", """") if len(s) == 0: print(""YES"") else: print(""NO"")" p03854,s929548346,Wrong Answer,"s=input().strip() s=s.replace(""eraser"","""") s=s.replace(""erase"","""") s=s.replace(""dreamer"","""") s=s.replace(""dream"","""") print(""YES"" if s else ""NO"")" p03854,s917686134,Wrong Answer,"S = input().strip() #----- i=0 while i <= len(S)-5: if S[i:(i+7)] == ""dreamer"": i=i+7 elif S[i:(i+6)] == ""eraser"": i=i+6 elif S[i:(i+5)] == ""dream"" or S[i:(i+5)] == ""erase"": i=i+5 else: print(""NO"") break" 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"") " p03854,s755577703,Wrong Answer,"import re S = input() print(""YES"" if re.match(""dream|dreamer|erase|eraser"", S) else ""NO"")" p03854,s457429651,Wrong Answer,"s = input() import re output =""NO"" s = re.sub('dreameraser', '', s) s = re.sub('dreamerase', '', s) s = re.sub('eraser', '', s) s = re.sub('dreamer', '', s) s = re.sub('dream', '', s) s = re.sub('erase', '', s) if s == """": output = ""YES"" print(output) " p03854,s064339178,Wrong Answer,"s = input() s = s[::-1] n = len(s) cur = 0 while cur < n: if s[cur:cur+5:] == ""maerd"" or ""esare"": cur += 5 continue if s[cur:cur+6:] == ""resare"": cur += 6 continue if s[cur:cur+7:] == ""remaerd"": cur += 7 continue print(""NO"") exit() print(""YES"")" p03854,s841486274,Wrong Answer,"S= input() i=0 while True: flag = False if S[i:i+7] == ""dreamer"": i += 7 flag = True if S[i:i+6] == ""eraser"": i += 6 flag = True if S[i:i+5] == ""erase"" or S[i:i+5] == ""dream"": i += 5 flag = True if not flag: break if i == len(S): print(""YES"") else: print(""NO"") " p03854,s160984404,Wrong Answer,"s = input() while True: if len(s) == 0: print(""YES"") break elif len(s) < 5: print(""NO"") break else: if s[:5] == ""dream"": s = s.replace(""dream"", """", 1) elif s[:5] == ""erase"": s = s.replace(""erase"", """", 1) elif s[:7] == ""dreamer"" : s = s.replace(""dreamer"", """", 1) elif s[:6] == ""eraser"": s = s.replace(""eraser"", """", 1) else: print(""NO"") break" p03854,s102172959,Wrong Answer,"s = input() a = 'dream' b = 'dreamer' c = 'erase' d = 'eraser' for i in range(len(s)): if not s[i] == a[i//4] or s[i] == b[i//5] or s[i] == c[i//4] or s[i] == d[i//5]: print('NO') exit() print('YES')" p03854,s427734830,Wrong Answer,"s = input() s = s.replace(""eraser"", """") s = s.replace(""dreamer"", """") s = s.replace(""erase"", """") s = s.replace(""dream"", """") if len(s) == 0: print(""YES"") else: print(""NO"")" p03854,s913581871,Wrong Answer,"s = input() s = s.replace('dreamer', '') s = s.replace('dream', '') s = s.replace('eraser', '') s = s.replace('erase', '') if s == '': print('YES') else: print('NO')" p03854,s542068655,Wrong Answer,"data = ['dream','dreamer','erase','eraser'] word = input() for i in data: while i in word: word = word.replace(i,"""") if word == """": print(""YES"") else : print(""NO"")" p03854,s399254534,Wrong Answer,"import re S = input() print(""YES"" if re.match(""(dream|dreamer|erase|eraser)"", S) else ""NO"")" p03854,s462276958,Wrong Answer,"text = """".join(reversed(input())) words = map(lambda word: """".join(reversed(word)), [""dreamer"", ""dream"", ""eraser"", ""erase""]) for word in words: text = text.replace(word, "" "") print(""YES"" if text.strip() == """" else ""NO"")" p03854,s790105511,Wrong Answer,"s = input() t_list = ['dreamdream', 'dreamdreamer', 'dreamerase', 'dreameraser', 'dreamerdream', 'dreamerdreamer', 'dreamererase', 'dreamereraser', 'erasedream', 'erasedreamer', 'eraseerase', 'eraseeraser', 'eraserdream', 'eraserdreamer', 'erasererase', 'erasereraser'] if s in t_list: print('YES') else: print('NO')" p03854,s144718264,Wrong Answer,"s=input() s=s.replace(""eraser"","""") s=s.replace(""dreamer"","""") s=s.replace(""dream"","""") s=s.replace(""erase"","""") # print(s) if s=="""": print(""YES"") else : print(""NO"")" p03854,s398354491,Wrong Answer,"s = input()[::-1] n = len(s) words = ['maerd', 'remaerd', 'esare', 'resare'] p = 1 while p <= n: if s[:p] in words: s = s[p:] p += 1 print('NO' if s else 'YES') " p03854,s201007494,Wrong Answer,"S = input()[::-1] string = list(map( lambda x: x[::-1], [ ""dream"", ""dreamer"", ""erase"", ""eraser"" ])) index = 0 while 1: for x in string: match = S.find(x, index) if match == -1: continue elif match > -1: index += match + len(x) if index == len(S): print(""YES"") exit()" p03854,s883380119,Wrong Answer,"c = input().rstrip('\n') str1 = ""dreamer"" str2 = ""dream"" str3 = ""eraser"" str4 = ""erase"" count = 0 while(count < len(c)-1): if(c[count:count+len(str1)] == str1): count += len(str1) elif(c[count:count+len(str2)] == str2): count += len(str2) elif(c[count:count+len(str3)] == str3): count += len(str3) elif(c[count:count+len(str4)] == str4): count += len(str4) else: print(""NO"") exit() print(""YES"") " p03854,s645247544,Wrong Answer,"s=input() import re #re.match は複数を対象にすればマッチする該当のものが返される。一つの時ifの後に持ってくると条件式として利用可能。 if re.match(""(dream|dreamer|erase|eraser)+"",s) : print(""YES"") else: print(""NO"") " p03854,s130515449,Wrong Answer,"import re S = input() list_string = ['dream', 'dreamer', 'erase', 'eraser'] regex = r'(dream(er)?eraser?)+|(eraser?dream(er)?)+|(((dream(er)?)|(eraser?))+)' def check(list_string, regex, S): while S: if re.search(regex, S): S = re.sub(regex, '', S) else: return 'NO' return 'YES' print(check(list_string, regex, S))" p03854,s907174592,Wrong Answer,"def main(): S = input() while len(S)>=5: if len(S)>=7 and S[:-7]==""dreamer"": S = S[-7:] continue elif len(S)>=6 and S[:-6]==""eraser"": S = S[-6:] continue elif S[:-5]==""dream"" or S[:-5]==""erase"": S = S[-5:] continue else: break if len(S)==0: print('Yes') else: print('No') main() " p03854,s548708502,Wrong Answer,"s = input() flag = 0 while(len(s)>0): if (s[:6] == 'eraser'): s = s[6:] elif (s[:5] == 'erase'): s = s[5:] elif (s[:5] == 'dream'): if (s[5:8] == 'ere' or s[5:8] == 'erd'): s = s[7:] else: s = s[5:] else: flag = 1 break if (flag == 0): print('Yes') else: print('No')" p03854,s250596875,Wrong Answer,"S=input() S=S.replace('dreamer','') S=S.replace('aser','') S=S.replace('ace','') S=S.replace('eraser','') S=S.replace('erase','') S=S.replace('dream','') if S=='': print('YES') else: print('NO')" p03854,s463523407,Wrong Answer,"s = input() s2 = s.split('dream') s3 = ''.join(s2).split('erase') try: s3.remove('er') s3.remove('r') except ValueError: pass if s3[0] != '': print(""NO"") else: print(""YES"")" 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)" p03854,s798176888,Wrong Answer,"s = input() kouho = [""dream"", ""dreamer"", ""erase"", ""eraser""] s = s.replace(kouho[1], """").replace(kouho[0], """").replace(kouho[3], """").replace(kouho[2], """") if s == """": print(""YES"") else: print(""NO"")" p03854,s382309222,Wrong Answer,"s = list(input()) s.reverse() str = """" for i in s: str+=i str_list = [""maerd"", ""remaerd"", ""esare"", ""resare""] while True: flag=0 for l in str_list: if str.startswith(l): #print(""str:{},l:{}"".format(str,l)) str=str.lstrip(l) #print(""str:{},l:{}"".format(str,l)) flag+=1 if flag==0: break if str == """": print(""YES"") else: print(""NO"")" p03854,s533446495,Wrong Answer,"S = input() temp = ['dream', 'dreamer', 'erase', 'eraser'] while(1): for i in temp: if S.startswith(i): S = S.lstrip(i) break else: break if len(S) == 0: print('YES') else: print('NO') " p03854,s061037089,Wrong Answer," S = input() T = '' words = ['dream', 'dreamer', 'erase', 'eraser'] for i in range(len(words)): words[i] = words[i][::-1] for i in S[::-1]: T += i for q in words: if T == q: T = '' if T == '': print('Yes') else: print('No')" p03854,s734101480,Wrong Answer,"s = input() a = 'dream' b = 'dreamer' c = 'erase' d = 'eraser' for i in range(len(s)): if not s[i] == a[i//5] or s[i] == b[i//7] or s[i] == c[i//5] or s[i] == d[i//6]: print('NO') exit() print('YES')" p03854,s217295016,Wrong Answer,"S = input() strs = [""erase"", ""eraser"", ""dreamer"",""dream""] rtss = [s[::-1] for s in strs] S_r = S[::-1] for rts in rtss: S_r = S_r.replace(rts, """") if len(S_r) == 0: print(""YES"") else: print(""NO"")" p03854,s680706176,Wrong Answer,"s = input() s = s.replace(""eraser"", """") s = s.replace(""dreamer"", """") s = s.replace(""erase"", """") s = s.replace(""dream"", """") if len(s) == 0: print(""YES"") else: print(""NO"")" p03854,s759935130,Wrong Answer,"import re sin = input() match = re.match(r""^.*(dream|dreamer|erase|eraser)+$"",sin) print(""YES"" if match else ""NO"")" p03854,s793806337,Wrong Answer,"s = input() for p in range(1000): if s[-5:] == 'dream': s = s[:-5] elif s[-7:] == 'dreamer': s = s[:-7] elif s[-5:] == 'erase': s = s[:-5] elif s[-6:] == 'eraser': s = s[:-6] if s == '': break if s == '': print('YES') else: print('NO')" p03854,s768803245,Wrong Answer,"s = input() s = s[::-1] ans = [""maerd"",""remaerd"",""esare"",""resare""] flag = 1 while len(s) != 0 and flag == 1: flag = 0 if s[:5] in ans: s = s[5:] flag = 1 elif s[:7] in ans: s = s[7:] flag = 1 if flag == 0: print(""NO"") else: print(""YES"")" p03854,s100909217,Wrong Answer,"S = input() R = ''.join(list(reversed(list(S)))) #print(R) while R: if R[:5]=='maerd': R = R[5:] elif R[:7]=='remaerd': R = R[7:] elif R[:5]=='esare': R = R[5:] elif R[:6]=='resare': R = R[6:] else: print('No') break else: print('YES')" p03854,s141266003,Wrong Answer,"s = input() u = ['dreamer', 'eraser', 'dream', 'erase'] while s: start = len(s) for i in u: if s[-len(i):len(s)] == i: s = s[:len(s)-len(i)] if start == len(s): print('No') exit() print(""YES"")" p03854,s382388425,Wrong Answer,"def hantei(S): if S == 'dream' or S == 'dreamer' or S == 'erase' or S == 'eraser': return True if S[:5] == 'dream': return hantei(S[5:]) if S[:7] == 'dreamer': return hantei(S[7:]) if S[:5] == 'erase': return hantei(S[5:]) if S[:7] == 'eraser': return hantei(S[7:]) else: return False S = input() if(hantei(S)): print('YES') else: print('NO')" p03854,s317643993,Wrong Answer,"S = input() num_5 = [""dream"", ""erase""] num_6 = [""dreamer"", ""eraser""] while len(S) != 0: if S[0:6] in num_6: S = S[6:] elif S[0:5] in num_5: S = S[5:] else: print(""NO"") exit() print(""YES"")" p03854,s187881467,Wrong Answer,"s = input() t_list = ['dreamdream', 'dreamdreamer', 'dreamerase', 'dreameraser', 'dreamerdream', 'dreamerdreamer', 'dreamererase', 'dreamereraser', 'erasedream', 'erasedreamer', 'eraseerase', 'eraseeraser', 'eraserdream', 'eraserdreamer', 'erasererase', 'erasereraser'] try: t_list.index(s) print('YES') except: print('NO')" p03854,s137812373,Wrong Answer,"s = input() def solve(query): while 1: for frag in (""erase"", ""eraser"", ""dream"", ""dreamer""): if query.endswith(frag): query = query.rstrip(frag) break else: print(""NO"") break if not query: print(""YES"") break solve(s)" p03854,s403048303,Wrong Answer,"S=input() while len(S) >=5: if S[-7:]=='dreamer': S=S[:-7] elif S[-6:] == 'eraser': S=S[:-6] elif S[-5:] == 'dream': S=S[:-5] elif S[-5:] == 'erase': S=S[:-5] else: print('No') break if len(S)==0: print('YES') if 1<=len(S)<=4: print('NO')" p03854,s083812808,Wrong Answer,"words=[""eraser"",""erase"",""dreanmer"",""dream""] S=input() for i in range(4): S=S.strip(words[i]) if S=="""": print(""Yes"") else: print(""No"") " p03854,s224483590,Wrong Answer,"import re S = input() """""" metacharacter ^ = 文字列の先頭 | = or + = 直前のパターンを1回以上繰り返す $ = 文字列の末尾 """""" if re.match(""^(dream|dreamer|erase|eraser)+$"", S): print(""Yes"") else: print(""No"") " p03854,s254336727,Wrong Answer,"S = list(input()) while True: if len(S) >= 5: if S[:5] == [""d"", ""r"", ""e"", ""a"", ""m""]: del S[:5] elif S[:5] == [""e"", ""r"", ""a"", ""s"", ""e""]: del S[:5] elif S[:6] == [""e"", ""r"", ""a"", ""s"", ""e"", ""r""]: del S[:6] elif S[:7] == [""d"", ""r"", ""e"", ""a"", ""m"", ""e"", ""r""]: del S[:7] else: print(""NO"") break elif len(S) == 0: print(""YES"") break else: print(""NO"") break " p03854,s011933550,Wrong Answer,"import re S = input() print(""YES"" if re.match(""(dream|dreamer|erase|erase)+"", S) else ""NO"")" p03854,s257042620,Wrong Answer,"S = input() temp = ['eraser', 'erase', 'dreamer', 'dream'] while(1): for i in temp: if S.startswith(i): S = S.replace(i, '') break else: break if len(S) == 0: print('YES') else: print('NO') " p03854,s152789701,Wrong Answer,"s = list(input()) s.reverse() while len(s) > 5: if s[:5] == list(""maerd""): del s[:5] continue elif s[:7] == list(""remaerd""): del s[:7] continue elif s[:5] == list(""esare""): del s[:5] continue elif s[:6] == list(""resare""): del s[:6] continue else: break if s == []: print(""YES"") else: print(""NO"")" p03854,s261368280,Wrong Answer,"# -*- coding: utf-8 -*- S = input() S = S.replace(""dreamer"", """") S = S.replace(""dream"", """") S = S.replace(""eraser"", """") S = S.replace(""erase"", """").strip() if len(S) ==0: print(""NO"") else: print(""YES"") " p03854,s152228790,Wrong Answer,"from collections import deque s = input() q = deque(list(s)) while q: if len(q) >= 5: subs = q.popleft()+q.popleft()+q.popleft()+q.popleft()+q.popleft() if subs != 'erase' and subs != 'dream': print('NO') exit() if len(q) != 0 and q[0] == 'r': q.popleft() else: print('NO') exit() print('YES')" p03854,s628770907,Wrong Answer,"S = input() flag = 0 S = S[::-1] print(S) while True: if S.startswith(""maerd"") or S.startswith(""esare""): S = S[5:] elif S.startswith(""remaerd""): S = S[7:] elif S.startswith(""resare""): S = S[6:] elif S == """": break else: flag = 1 break print(""YES"" if flag == 0 else ""NO"") " p03854,s288536009,Wrong Answer,"import re S = input() if re.match(""^(dream|dreamer|erase|eraser)+$"", S): print(""Yes"") else: print(""No"") " p03854,s353694785,Wrong Answer,"import sys t = set('dream, dreamer, erase, eraser'.split(', ')) def obtainable(s): while True: if s[-5:] in t: s = s[:-5] elif s[-6:] in t: s = s[:-6] else: return False if not s: return True s = sys.stdin.readline().rstrip() def main(): print(""YES"" if obtainable(s) else ""NO"") if __name__ == '__main__': main()" p03854,s727688504,Wrong Answer,"S = input() idx = 0 while True: if S[idx:idx+5] == 'dream': idx += 5 elif S[idx:idx+6] == 'eraser': idx += 6 elif S[idx:idx+5] == 'erase': idx += 5 elif S[idx:idx+7] == 'dreamer': idx += 7 else: print('NO') break if idx == len(S): print('YES') break " p03854,s474886520,Wrong Answer,"s = input() s=s[::-1] A=[""dream"",""dreamer"",""erase"",""eraser""] for i in range(len(A)): A[i]=A[i][::-1] i=0 while True: if len(s)==i: ans=""Yes"" break elif s[i:i+5]==A[0]: i+=5 elif s[i:7]==A[1]: i+=7 elif s[i:i+5]==A[2]: i+=5 elif s[i:i+6]==A[3]: i+=6 else: ans=""No"" break print(ans)" p03854,s786015475,Wrong Answer,"words = ['maerd', 'remaerd', 'esare', 'resare'] S = input() T = '' for a in S[::-1]: T += a for s in words: if T == s: T = '' if T == '': print('Yes') else: print('No') " p03854,s052703952,Wrong Answer,"s = ''.join(list(reversed(input()))) s = s.replace('resaremaerd', '') s = s.replace('remaerd', '').replace('resare', '') s = s.replace('maerd', '').replace('esare', '') if len(s) == 0: print('YES') else: print('NO') " p03854,s750474485,Wrong Answer,"s=input() n=len(s) t=n-1 for i in range(n): if t>=4 and s[t-4:t+1]==""dream"": t-=5 elif t>=6 and s[t-6:t+1]==""dream"": t-=7 elif t>=4 and s[t-4:t+1]==""erase"": t-=5 elif t>=5 and s[t-5:t+1]==""eraser"": t-=6 if t<0: break if t==-1: print(""YES"") else: print(""NO"")" p03854,s678216305,Wrong Answer,"string = input() flg = True while len(string) > 0: if string.endswith('dream'): string = string[:-5] elif string.endswith('dreamer'): string = string[:-7] elif string.endswith('erase'): string = string[:-6] elif string.endswith('eraser'): string = string[:-6] else: print('NO') flg = False break if flg: print('YES')" p03854,s075252694,Wrong Answer,"S = input() T = '' a = S.replace('eraser', '').replace('dreamer', '').replace('erase', '').replace('dream', '') if len(a) == 0: print(""YES"") else: print(""NO"")" p03854,s104831700,Wrong Answer,"s = input() s=s[::-1] A=[""dream"",""dreamer"",""erase"",""eraser""] for i in range(len(A)): A[i]=A[i][::-1] i=0 ans=""Yes"" while True: if len(s)==i: break elif s[i:i+5]==A[0]: i+=5 elif s[i:i+7]==A[1]: i+=7 elif s[i:i+5]==A[2]: i+=5 elif s[i:i+6]==A[3]: i+=6 else: ans=""No"" break print(ans) " p03854,s050326696,Wrong Answer,"S0 = input() S = S0[::-1] cands = [""dream""[::-1],""dreamer""[::-1],""erase""[::-1],""eraser""[::-1]] i = 0 while i < len(S): for word in cands: #print(S[i:],word) if S[i:].startswith(word): i += len(word) continue print(""NO"") exit(0) #print(i) if i == len(S): print(""YES"") else: print(""NO"") " p03854,s958341742,Wrong Answer,"def hantei(S): if S == 'dream' or S == 'dreamer' or S == 'erase' or S == 'eraser': return 1 if S[:5] == 'dream': return hantei(S[5:]) | hantei(S[7:]) if S[:7] == 'dreamer': return hantei(S[5:]) | hantei(S[7:]) if S[:5] == 'erase': return hantei(S[5:]) | hantei(S[7:]) if S[:7] == 'eraser': return hantei(S[5:]) | hantei(S[7:]) else: return 0 S = input() if(hantei(S)): print('YES') else: print('NO')" p03854,s894662308,Wrong Answer,"S = input() day_dream_word = [""eraser"", ""erase"", ""dreamer"", ""dream""] for replace_word in day_dream_word: S.replace(replace_word, """") if S == """": print('YES') else: print('NO')" p03854,s995512947,Wrong Answer,"s = input() s.replace(""eraser"","""").replace(""erase"","""").replace(""dreamer"","""").replace(""dream"","""") print(""YES"") if s == """" else print(""NO"")" p03854,s574660378,Wrong Answer,"s=input() s=s[::-1] #print(s[:5],s[:7]) for i in range(100000): if s[:5] == 'maerd' or s[:6] == 'esare': s = s[5:] if s[:6] == 'resare': s = s[6:] if s[:7] == 'remaerd': s = s[7:] #print(s) if len(s)==0: print('YES') else: print('N0')" p03854,s539350085,Wrong Answer,"import itertools input_moji = input() count = 0 lis = ['dream','dreamer', 'erase','eraser'] for i, _ in enumerate(lis, 1): for j in itertools.permutations(lis, r=i): # rには1、2、3と渡される total = """".join([str(_) for _ in j]) if input_moji == total: count += 1 print('Yes') if count == 0: print('No')" p03854,s732550672,Wrong Answer,"s = input() word = ['dreamer', 'dream', 'eraser', 'erase'] for i in word: s = s.replace(i,'') if s: print('NO') else: print('YES')" p03854,s560915545,Wrong Answer,"import re; s = input(); print(""Yes"" if re.fullmatch(r'^(dream|dreamer|eraser|erase)*$', s) else ""NO"") " p03854,s542591136,Wrong Answer,"#9 S = input() for i in range(0, len(S)//5+1): if S[0:5] == 'dream' or S[0:5] == 'erase': S = S[5:] elif S[0:6] == 'eraser': S = S[6:] elif S[0:7] == 'dreamer': S = S[7:] print('YES' if len(S)==0 else 'NO')" p03854,s728919923,Wrong Answer,"import sys t = set('dream, dreamer, erase, eraser'.split(', ')) def obtainable(s): while True: for i in range(5, 8): if s[-i:] in t: s = s[:-i] break else: return False if not s: return True s = sys.stdin.readline().rstrip() def main(): print(t) print(""YES"" if obtainable(s) else ""NO"") if __name__ == '__main__': main()" p03854,s477829538,Wrong Answer,"s = str(input()) l = len(s) s = s[::-1] i = 0 while i < l: if (s[i:min(l,i+7)] == ""remaerd""): i += 7 elif (s[i:min(l,i+6)] == ""resare""): i += 6 elif (s[i:min(l,i+5)] == ""maerd"" or ""esare""): i += 5 else: print('NO') break else: print('YES')" p03854,s629980632,Wrong Answer," s = input() t = '' s = s.replace('eraser', '').replace('erase', '').replace('dreamer', '').replace('dream', '') print(s) if s == t: print('YES') else: print('NO') " p03854,s248748921,Wrong Answer,"s=input() def judge(): cnt=0 while cnt<=len(s): if s[cnt:cnt+6]=='eraser': cnt+=6 elif s[cnt:cnt+5]=='erase': cnt+=5 elif s[cnt:cnt+7]=='dreamer': cnt+=7 elif s[cnt:cnt+5]=='dream': cnt+=5 else: print('NO') exit() if cnt==len(s): print('YES') exit() judge()" p03854,s009752712,Wrong Answer,"#import random S = input() #Mozi_f = [""eraser"",""erase"",""dreamer"",""dream""] Mozi = [""resare"",""esare"",""remaerd"",""maerd""] #S = random.choice(Mozi_f) #S = """".join([random.choice(Mozi_f) for x in range(10)]) S = S[::-1] for i in Mozi: S = S.replace(i,"""") if not S: print(""Yes"") else: print(""No"")" p03854,s604724728,Wrong Answer,"def hantei(S): if S == 'dream' or S == 'dreamer' or S == 'erase' or S == 'eraser': return 1 if S[:5] == 'dream' or S[:5] == 'erase': if S[:7] == 'dreamer' or S[:7] == 'eraser': return hantei(S[5:]) | hantei(S[7:]) else: return hantei(S[5:]) else: return 0 S = input() if(hantei(S)): print('YES') else: print('NO')" p03854,s686542800,Wrong Answer,"s = input() s=s[::-1] A=[""dream"",""dreamer"",""erase"",""eraser""] for i in range(len(A)): A[i]=A[i][::-1] i=0 ans=""Yes"" while True: if len(s)==i: break if s[i:i+5]==A[0]: i+=5 elif s[i:i+7]==A[1]: i+=7 elif s[i:i+5]==A[2]: i+=5 elif s[i:i+6]==A[3]: i+=6 else: ans=""No"" break print(ans) " p03854,s507311754,Wrong Answer,"S = input() L = ['dream', 'dreamer', 'erase', 'eraser'] for i in range(len(L)): L[i] = L[i][::-1] S = S[::-1] T = '' for s in S: T += s for i in L: if T == i: T = '' if T == '': print('Yes') else: print('No')" p03854,s483783245,Wrong Answer,"s = input() length = len(s) i = 0 res = ""YES"" while i < length: if i+4 <= length and s[i:i+5] == ""dream"": i += 5 if i+1 <= length and s[i:i+2] == ""er"" and s[i+2] != ""a"": i += 2 else: res = ""NO"" break if i+4 <= length and (s[i:i+5] == ""erase"" or s[i:i+5] == ""dream""): i += 5 if i+1 <= length and s[i:i+2] == ""er"" and s[i+2] != ""a"": i += 2 else: res = ""NO"" break print(res)" p03854,s004977617,Wrong Answer,"S = input() S = S.replace('eraser', '#', S.count('eraser')) S = S.replace('dreamer', '#', S.count('dreamer')) S = S.replace('erase', '#', S.count('erase')) S = S.replace('dream', '#', S.count('dream')) # print(S) if len(S) == S.count('#'): print('Yes') else: print('No') " p03854,s912485047,Wrong Answer,"S = input() S = S.replace(""dreamer"", """") S = S.replace(""dream"", """") S = S.replace(""eraser"", """") S = S.replace(""erase"", """") if S == """": print(""YES"") else: print(""NO"") " p03854,s130300387,Wrong Answer,"s=input() s=s[::-1] divide=[""dream"", ""dreamer"", ""erase"", ""eraser""] c1=1 c2=0 for i in range(4): divide[i]=divide[i][::-1] for i in range(len(s)): for j in range(4): d=divide[j] if s[i:i+len(d)]==d: c2=1 i+=len(d) if c2==0: c1=0 break" p03854,s901674138,Wrong Answer,"s = input() r = 'YES' while len(s): if s[:6] == 'dreamer' or s[:6] == 'eraser': s = s[6:] elif s[:5] == 'dream' or s[:5] == 'erase': s = s[5:] else: r = 'NO' break print(r)" p03854,s849045322,Wrong Answer,"s = input() a = ['dream','dreamer','erase','eraser'] while s: flg = True for w in a: if s.startswith(w): s = s.lstrip(w) flg = False if flg: break if s == '': print('YES') else: print('NO')" p03854,s303227847,Wrong Answer,"S = input() T = ['dream', 'dreamer', 'erase', 'eraser'] T = set([s[::-1] for s in T]) A = '' for s in S[::-1]: A += s print('YES' if A == '' else 'NO')" p03854,s173693626,Wrong Answer,"S = input()[::-1] S = S.replace(""dream""[::-1], """") S = S.replace(""dreamer""[::-1], """") S = S.replace(""erase""[::-1], """") S = S.replace(""eraser""[::-1], """") print(""YES"" if S == """" else ""NO"")" p03854,s653002147,Wrong Answer,"s = input() while 1: for x in ('dream', 'dreamer', 'erase', 'eraser'): if s.endswith(x): s = s[:-len(x)] break else: print('NO') break if not s: print('YES')" p03854,s967701553,Wrong Answer,"s = list(input()) s.reverse() str = """" for i in s: str+=i str = str.replace(""resare"","""") str = str.replace(""remaerd"","""") str = str.replace(""maerd"","""") str = str.replace(""esare"","""") if str == """": print(""YES"") else: print(""NO"")" p03854,s292965775,Wrong Answer,"# 動的計画法(DP) s=input() words = {""dream"", ""dreamer"", ""erase"", ""eraser""} dp = dict() for i in range(0, len(s)): if not dp.get(i): continue for word in words: if s[i:i+len(word)] == word: dp[i+len(word)] = 1 print(""YES"" if dp.get(len(s)) else ""NO"")" p03854,s975655936,Wrong Answer,"s = input() lst = [""eraser"",""erase"",""dreamer"",""dream""] for w in lst: s.replace(w,"""") if len(s) == 0: ans = ""YES"" else: ans = ""NO"" print(ans) " p03854,s504253012,Wrong Answer,"S = input() list=['dream', 'dreamer', 'erase', 'eraser'] T = S.replace('eraser','') U = T.replace('dreamer','') V = U.replace('erase','') W = V.replace('dream','') if W =='': print('YES') else: print(""NO"")" p03854,s972370840,Wrong Answer,"def main(): print('YES' if not input().replace('eraser', '').replace( 'dreamer', '').replace('dream', '').replace('erase', '') else 'NO') if __name__ == ""__main__"": main()" p03854,s921156307,Wrong Answer,"s = input() length = len(s) i = 0 res = ""YES"" print(res)" p03854,s339148733,Wrong Answer,"S=input() def solve(query): while 1: for frag in (""erase"",""eraser"",""dream"",""dreamer""): if query.endswith(frag): query=query[:-len(frag)] break else: print(""No"") break if not query: print(""Yes"") break solve(S)" p03854,s728389569,Wrong Answer,"s = input() s=s[::-1] A=[""dream"",""dreamer"",""erase"",""eraser""] for i in range(len(A)): A[i]=A[i][::-1] i=0 while True: if len(s)==i: print(""Yes"") break elif s[i:i+5]==A[0]: i+=5 elif s[i:7]==A[1]: i+=7 elif s[i:i+5]==A[2]: i+=5 elif s[i:i+6]==A[3]: i+=6 else: print(""No"") break " p03854,s289450703,Wrong Answer,"s = input().replace(""erase"","""").replace(""eraser"","""").replace(""dreamer"","""").replace(""dream"","""") if s: print('NO') else: print('YES')" p03854,s909167845,Wrong Answer,"s=input() ans=0 ones=s.split(""eraser"") for one in ones: twos=one.split(""erase"") for two in twos: three=two.split(""dreamer"") if set(three)==set([""dream""]) or set(three)==set([""dream"",""""]) or set(three)==set([""""]): pass else: ans+=1 if ans==0: print(""YES"") else: print(""NO"")" p03854,s362673998,Wrong Answer,"#9 S = input() for i in range(0, len(S)//5+1): if S[0:5] == 'dream' or S[0:5] == 'erase': S = S[5:] elif S[0:6] == 'eraser': S = S[6:] elif S[0:7] == 'dreamer': S = S[7:] print('YES' if len(S)==0 else 'NO')" p03854,s030409268,Wrong Answer,"data = ['dream','dreamer','erase','eraser'] word = input() for i in data: while i in word: word = word.strip(i) if word =="""": print(""YES"") else: print(""NO"")" p03854,s616242902,Wrong Answer,"s=input() s=s.replace('dreamer','') s=s.replace('dream','') s=s.replace('eraser','') s=s.replace('erase','') if s=='': print('Yes') else: print('No') " p03854,s300515906,Wrong Answer,"#049_C s = input() s = s.replace('dream', '').replace('dreamer', '').replace('erase', '').replace('eraser', '') print('YES' if s == '' else 'NO')" p03854,s159561729,Wrong Answer,"S = input()[::-1] dividor = ['dream','dreamer','erase','eraser'] j=0 while True: flag = 0 for d in dividor: print(S[j:j+len(d)]) if S[j:j+len(d)]==d[::-1]: flag = 1 j+=len(d) if j==len(S): print(""YES"") quit() if flag==0: print(""NO"") quit()" p03854,s288906980,Wrong Answer,"S = input() S = S.replace(""dreamer"", ""0"").replace(""eraser"", ""1"").replace(""dream"", ""2"").replace(""erase"", ""3"") try: int(S) print(""YES"") except: print(""NO"") " p03854,s028533046,Wrong Answer,"s = input() s = s.replace(""eraser"", ""X"") s = s.replace(""dreamer"", ""X"") s = s.replace(""erase"", ""X"") s = s.replace(""dream"", ""X"") count = s.count(""X"") if len(s) == count: print(""YES"") else: print(""NO"")" p03854,s950574266,Wrong Answer,"s=input() n=len(s) i=1 for j in range(n): if s[-i:-i-5:-1]==""maerd"": i+=5 if s[-i:-i-5:-1]==""esare"": i+=5 if s[-i:-i-6:-1]==""resare"": i+=6 if s[-i:-i-7:-1]==""remeard"": i+=7 if i==n+1: print(""YES"") break if i != n+1: print(""NO"")" p03854,s827878781,Wrong Answer,"import re moji=str(input()) if ""eraser"" in moji: moji=re.sub(""eraser"", """", moji) if ""dreamer"" in moji: moji=re.sub(""dreamer"", """", moji) if ""dream"" in moji: moji=re.sub(""dream"", """", moji) if ""erase"" in moji: moji=re.sub(""erase"", """", moji) print(""YES"" if moji=="""" else ""NO"") " p03854,s355985456,Wrong Answer,"s = input() u = ['dreamer', 'eraser', 'dream', 'erase'] while len(s) > 0: for i in u: if s[0:len(i)] == i: s = s.lstrip(i) else: print(""NO"") exit() print(""YES"")" p03854,s965666207,Wrong Answer,"s = input() s = s.replace('dreameraser', '').replace('dreamerse', '') s = s.replace('dreamer', '').replace('eraser', '') s = s.replace('dream', '').replace('erase', '') if len(s) == 0: print('YES') else: print('NO') " p03854,s390607443,Wrong Answer,"S = str(input()) while len(S) > 0: if S[-5:] == 'dream' or S[-5:] == 'erase': S = S[:-5] elif S[-7:] == 'dreamer' or S[-7:] == 'eraser': S = S[:-7] else: break if len(S) == 0: print('YES') else: print('NO')" p03854,s570526921,Wrong Answer,"word = input() b = word d = word f = word h = word if 'eraser' in word: a = word.split('eraser') b = ''.join(a) h = b if 'erase' in h: c = h.split('erase') d = ''.join(c) h = d if 'dream' in h: e = h.split('dream') f = ''.join(e) h = f if 'dreamer' in h: g = h.split('dreamer') h = ''.join(g) if h == (''): print('YES') else: print('NO')" p03854,s103397239,Wrong Answer,"import re s = input() re.sub('eraser','0',s) re.sub('erase','0',s) re.sub('dreamer','0',s) re.sub('dream','0',s) print('YES' if set(s) == set('0') else 'NO')" p03854,s039584844,Wrong Answer,"S = input() flag = 0 S = S[::-1] print(S) while True: if S.startswith(""maerd"") or S.startswith(""esare""): S = S[5:] elif S.startswith(""remaerd""): S = S[7:] elif S.startswith(""resare""): S = S[6:] elif S == """": break else: flag = 1 break print(""YES"" if flag == 0 else ""NO"") " p03854,s650817598,Wrong Answer,"s=input() s=s.replace(""eraser"","""") s=s.replace(""dreamer"","""") s=s.replace(""dream"","""") s=s.replace(""erase"","""") if s=="""": print(""YES"") else: print(""NO"")" p03854,s118114723,Wrong Answer,"import re moji=str(input()) temp="""" for i in range(-1,-(len(moji))-1 , -1): temp+=moji[i] if ""resare"" in temp: temp=re.sub(""resare"", """", temp) if ""remaerd"" in temp: temp=re.sub(""remaerd"", """", temp) if ""maerd"" in temp: temp=re.sub(""maerd"", """", temp) if ""esare"" in temp: temp=re.sub(""esare"", """", temp) print(""YES"" if temp=="""" else ""NO"") " p03854,s585494007,Wrong Answer,"s = input() kouho = [""dream"", ""dreamer"", ""erase"", ""eraser""] s = s.replace(kouho[0], """").replace(kouho[1], """").replace(kouho[2], """").replace(kouho[3], """") if s == """": print(""YES"") else: print(""NO"")" p03854,s703287802,Wrong Answer,"s = input() s = s[::-1] lis = ['dream', 'dreamer', 'erase', 'eraser'] nlis = [] for i in lis: nlis.append(i[::-1]) flag = 0 for _ in range(10**5+1): for j in nlis: if s.startswith(j): s = s.replace(j, '') if s == '': flag = 1 break if flag: print('YES') else: print('NO')" p03854,s410198956,Wrong Answer,"def we_can(s): if len(s) == 0: return True else: if s[-5:] == 'dream' or s[-5:] == 'erase': if we_can(s[:-5]): return True elif s[-6:] == 'dreamer' or s[-6:] == 'eraser': if we_can(s[:-6]): return True return False s = input() if we_can(s): print('YES') else: print('NO') " p03854,s793905667,Wrong Answer,"import re print(""Yes"" if re.match(""^(dream|dreamer|erase|eraser)+$"",input()) else ""No"")" p03854,s251718776,Wrong Answer,"from collections import deque s = input() q = deque(list(s)) while q: try: subs = q.popleft()+q.popleft()+q.popleft()+q.popleft()+q.popleft() if subs != 'erase' and subs != 'dream': print('NO') exit() if len(q) != 0 and q[0] == 'r': q.popleft() except: print('NO') exit() print('YES')" p03854,s211357108,Wrong Answer,"s = input()[::-1] l5 = [""dream""[::-1], ""erase""[::-1]] l6 = [""dreamer""[::-1], ""eraser""[::-1]] ans = ""YES"" while len(s) > 4: if s[:5] in l5: s = s[5:] elif s[:6] in l6: s = s[6:] else: ans = ""NO"" break print(ans)" p03854,s058344292,Wrong Answer,"c = input() str1 = ""dream"" str2 = ""dreamer"" str3 = ""erase"" str4 = ""eraser"" tmpstr = """" endflag = False while(True): tmpstr = c c.replace(c, str1) c.replace(c, str2) c.replace(c, str3) c.replace(c, str4) if (c == tmpstr): endflag = True break if (endflag): print(""NO"") else: print(""YES"")" p03854,s150983728,Wrong Answer,"s = input() ans = ""YES"" while s != """": if len(s) < 5: ans = ""NO"" break elif s[len(s) - 5:] == ""dream"" or s[len(s) - 5:] == ""erase"": s = s[:len(s) - 5] elif s[len(s) - 6:] == ""eraser"": s = s[:len(s) - 6] elif s[len(s) - 7] == ""dreamer"": s = s[:len(s) - 7] else: ans = ""NO"" break print(ans) " p03854,s706524217,Wrong Answer,"s = input() s = s.replace(""eraser"","""") s = s.replace(""erase"","""") s = s.replace(""dreamerr"","""") s = s.replace(""dream"","""") if len(s)==0: print(""YES"") else: print(""NO"")" p03854,s078106265,Wrong Answer,"S = input() T = ['dream', 'dreamer', 'erase', 'eraser'] def reverse(t): return t[::-1] RT = [reverse(t) for t in T] RS = reverse(S) can = True i = 0 while i < len(RT): can2 = False for j in range(4): sizeT = len(RT[j]) if RT[j] == RS[i:sizeT]: i += sizeT can2 = True break if not can2: can = False break if can: print('YES') else: print('NO') " p03854,s037042952,Wrong Answer,"S = input() while True: if S[-3:] == ""mer"": S = S[:-7] elif S[-3:] == ""ser"": S = S[:-6] elif S[-3:] == ""eam"": S = S[:-5] elif S[-3:] == ""ase"": S = S[:-5] else: break print(""NO"") if S else print(""YES"")" p03854,s600165699,Wrong Answer,"s = list(input()) s.reverse() str = """" for i in s: str+=i str_list = [""maerd"", ""remaerd"", ""esare"", ""resare""] while True: flag=0 for l in str_list: if str.startswith(l): print(""str:{},l:{}"".format(str,l)) str=str.lstrip(l) print(""str:{},l:{}"".format(str,l)) flag+=1 if flag==0: break if str == """": print(""YES"") else: print(""NO"")" p03854,s906653780,Wrong Answer,"S = input() Mozi = [""dreamer"",""eraser"",""dream"",""erase""] for i in Mozi: T = S.replace(i,""X"") S = T.strip(""X"") if not S: print(""Yes"") else: print(""No"") " p03854,s740232071,Wrong Answer,"S = input() temp = ['dream', 'dreamer', 'erase', 'eraser'] while(1): for i in temp: if S.startswith(i): S = S.lstrip(i) break else: break print(S) if len(S) == 0: print('YES') else: print('NO') " p03854,s003222249,Wrong Answer,"words = {""eraser"" , ""erase"" , ""dreamer"" , ""dream""} s = input() n = len(s) now="""" for i in range(0 ,n): now = now+s[i] if now in words: now="""" if now in words or now =="""": print(""YES"") else: print(""NO"")" p03854,s298013043,Wrong Answer,"S = input() db = [""dream"", ""erase""] offset = 0 key = True while key: if offset >= len(S): key = False if S[offset:offset+5] == db[0]: if S[offset:offset+2] == db[0]+""er"": offset += 7 else: offset += 5 elif S[offset:offset+5] == db[1]: if S[offset:offset+6] == db[1]+""r"": offset += 6 else: offset += 5 else: break print(""YNEOS""[key::2])" p03854,s997312948,Wrong Answer,"s = input() s = s.replace('eraser', '').replace('dreamer', '') s = s.replace('dream', '').replace('erase', '') print('YES' if len(s) == 0 else 'NO')" p03854,s615308113,Wrong Answer,"l = input() l = l.replace('eraser','') l = l.replace('erase','') l = l.replace('dream','') l = l.replace('dreamer','') if l == '': print('Yes') else: print('No')" p03854,s139781035,Wrong Answer,"S = input() def solve(T) : while 1: for i in (""dream"", ""dreamer"", ""erase"", ""eraser""): if T.endswith(i): T = T[: -len(i)] break else: print(""NO"") break if not T: print(""Yes"") break solve(S)" p03854,s606857907,Wrong Answer,"import sys s = input() A = ['dream','dreamer','erase', 'eraser'] while(len(s)!=0): cs = s for i in range(len(A)): if (s.startswith(str(A[i]))): #print(A[len(A[i])+1:]) s = s[len(A[i]):] if (cs == s): print('NO') sys.exit() print('YES')" p03854,s318455988,Wrong Answer,"S = input() S = S.replace('eraser', '#', S.count('eraser')) S = S.replace('dreamer', '#', S.count('dreamer')) S = S.replace('erase', '#', S.count('erase')) S = S.replace('dream', '#', S.count('dream')) # print(S) if len(S) == S.count('#'): print('Yes') else: print('No') " p03854,s620305311,Wrong Answer,"S=input()[::-1] num=(len(S)//5)+1 while num > 0: for i in ['dream'[::-1], 'dreamer'[::-1], 'erase'[::-1], 'eraser'[::-1]]: if S[:len(i)] == i: S = S[len(i):] if S == '': print('YES') exit() num -= 1 print('No')" p03854,s606768801,Wrong Answer,"import re s = input() if re.fullmatch(r""(dream|dreamer|erase|eraser)+"",s): print(""Yes"") else: print(""No"")" p03854,s967546934,Wrong Answer,"S = input() while len(S)>0: if S[-7:] == ""deamer"": S = S[:-7] elif S[-6:] == ""eraser"": S = S[:-6] elif S[-5:] == ""dream"": S = S[:-5] elif S[-5:] == ""erase"": S = S[:-5] else: break print(""YES"" if len(S)==0 else ""NO"")" p03854,s370380650,Wrong Answer,"s = input() while(len(s)!=0): if s[-5:] == 'dream' or s[-5:] == 'erase': s = s[:-5] elif s[-6:]== 'eraser': s = s[:-6] elif s[-7:0]=='dreamer': s = s[:-7] else: print('N0') break print('YES') " p03854,s089517108,Wrong Answer,"s=input()[::-1] words = {""dream"", ""dreamer"", ""erase"", ""eraser""} while len(s)!=0: for i in words: l = len(i) print(s[0:l], i[::-1]) if s[0:l] == i[::-1]: s = s[l::] break else: break print(""NO""if len(s)!=0else ""YES"")" p03854,s231850259,Wrong Answer,"txt = input() cands = [""dream"", ""dreamer"", ""erase"", ""eraser""] success = True while len(txt) > 0: flag = False for cand in cands: subtxt = txt[len(txt) - len(cand):] if subtxt == cand: txt = txt[:len(txt) - len(cand)] flag = True break if not flag: success = False break if success: print(""YES"") else: print(""No"")" p03854,s629069126,Wrong Answer,S = input() p03854,s059302768,Wrong Answer,"s = input() s = s.replace(""eraser"", ""X"") s = s.replace(""dreamer"", ""X"") s = s.replace(""erase"", ""X"") s = s.replace(""dream"", ""X"") count = s.count(""X"") if len(s) == count: print(""Yes"") else: print(""No"")" p03854,s588384762,Wrong Answer,"import re S = input() print(""YES"" if re.match(""(dream|dreamer|erase|eraser)"", S) else ""NO"")" p03854,s325906233,Wrong Answer,"import re s = input() s = re.sub(""eraser"","""",s) s = re.sub(""erase"","""",s) s = re.sub(""dreamer"","""",s) s = re.sub(""dream"","""",s) print(""Yes"" if len(s) ==0 else ""No"") " p03854,s501431699,Wrong Answer,"s = input() slen = len(s) now=0 while(1): if s[now:now+5] == ""erase"": now += 5 elif s[now:now+6] == ""eraser"": now += 6 elif s[now:now+5] == ""dream"": now += 5 if s[now:now+6] == ""dreamer"": now += 7 else: print('NO') break if now == slen: print('YES') break " p03854,s671271278,Wrong Answer,"s = input()[::-1] res = ""Yes"" while s: start = len(s) for t in ['maerd', 'remaerd', 'esare', 'resare']: if t == s[:len(t)]: s = s[len(t):] if start == len(s): res = ""No"" break print(res)" p03854,s100587634,Wrong Answer,"def solve(): S = input() words = ['dream', 'dreamer', 'erase', 'eraser'] while(True): if(len(S) == 0): break flag = False for w in words: if(S.endswith(w)): S = S[0:len(S) - len(w)] flag = True if(not flag): return print('YES') solve()" p03854,s576082538,Wrong Answer,"#9 S = input() while len(S)!=0: if S[0:5] == 'dream' or S[0:5] == 'erase': S = S[5:] elif S[0:6] == 'eraser': S = S[6:] elif S[0:7] == 'dreamer': S = S[7:] print('Yes' if len(S)==0 else 'No')" p03854,s646513154,Wrong Answer,"S=input() reversed(S) T = S.replace('remaerd','') U = T.replace('resare','') V = U.replace('maerd','') W = V.replace('esare','') if W =='': print('YES') else: print(""NO"")" p03854,s083574505,Wrong Answer,"s = input() if s.replace(""dreamer"", """").replace(""dream"", """").replace(""erase"", """").replace(""eraser"", """"): print(""NO"") else: print(""YES"")" p03854,s515122284,Wrong Answer,"c = input().rstrip('\n') str1 = ""eraser"" str2 = ""erase"" str3 = ""dreamer"" str4 = ""dream"" count = 0 while(count < len(c)): if(c[count:count+len(str1)] == str1): count += len(str1) elif(c[count:count+len(str2)] == str2): count += len(str2) elif(c[count:count+len(str3)] == str3): count += len(str3) elif(c[count:count+len(str4)] == str4): count += len(str4) else: print(""NO"") exit() print(""YES"") " p03854,s976004054,Wrong Answer,"from itertools import permutations s = input() words = [""dream"", ""dreamer"", ""erase"", ""eraser""] words_combinations = ["""".join(j) for i in range(1, len(words)+1) for j in permutations(words, i)] if s in words_combinations: print(""YES"") else: print(""NO"") " p03854,s768285340,Wrong Answer,"S = input() if S.replace(""dream"","" "").replace(""dreamer"","" "").replace(""erase"","" "").replace(""eraser"","" ""): print(""YES"") else: print(""NO"") " p03854,s121533064,Wrong Answer,"import sys import resource sys.setrecursionlimit(10 ** 9) S = input() l = [] def dfs(n): print(n) if n == len(S): l.append(""Yes"") if n < len(S): if S[n:n+5] == ""erase"": dfs(n+5) if S[n:n+5] == ""dream"": dfs(n+5) if S[n:n+6] == ""eraser"": dfs(n+6) if S[n:n+7] == ""dreamer"": dfs(n+7) dfs(0) if len(l) == 0: l.append(""No"") print(l[0]) " p03854,s200332450,Wrong Answer,"S = input() S = S[::-1].replace(""resare"", ""0"").replace(""remaerd"", ""0"").replace(""esare"", ""0"").replace(""maerd"", ""0"") try: int(S) print(""YES"") except: print(""NO"") " p03854,s222121205,Wrong Answer,"S = input() S = S.replace(""dreamer"", ""0"").replace(""eraser"", ""1"").replace(""dream"", ""2"").replace(""erase"", ""3"") try: int(S) print(""YES"") except: print(""NO"") " p03854,s830130471,Wrong Answer,"import sys from collections import deque s = input() queue = deque() queue.append(0) candidates = ['dream', 'dreamer', 'erase', 'eraser'] while queue: index = queue.popleft() match = False for candidate in candidates: if s[index:index + len(candidate)] == candidate: match = True if index + len(candidate) == len(s): print('YES') sys.exit(0) queue.append(index + len(candidate)) if not match: print('NO') sys.exit(0) " p03854,s070208295,Wrong Answer,"s = input() s = s[::-1] lis = ['dream', 'dreamer', 'erase', 'eraser'] nlis = [] for i in lis: nlis.append(i[::-1]) flag = 0 ans = '' for _ in range(10): for j in nlis: if s.startswith(j): s = s.replace(j, '') if ans == s: flag = 1 break if flag: print('YES') else: print('NO')" p03854,s313353424,Wrong Answer,"s = input() s = s.replace(""eraser"", ""X"") s = s.replace(""dreamer"", ""X"") s = s.replace(""erase"", ""X"") s = s.replace(""dream"", ""X"") count = s.count(""X"") if len(s) == count: print(""Yes"") else: print(""No"")" p03854,s273323242,Wrong Answer,"#9 S = input() for i in range(0, len(S)//5+1): if S[-5:-1] == 'dream' or S[-5:-1] == 'erase': S = S[:-6] elif S[-6:-1] == 'eraser': S = S[:-7] elif S[-7:-1] == 'dreamer': S = S[:-8] else: break print('YES' if len(S)==0 else 'NO')" p03854,s673280988,Wrong Answer,"S = input() if S.replace(""dream"","" "").replace(""dreamer"","" "").replace(""erase"","" "").replace(""eraser"","" ""): print(""NO"") else: print(""YES"") " p03854,s318481970,Wrong Answer,"s=input() while len(s)>7: if s[-5:]=='dream' or s[-5:]=='erase': s=s[-5:] elif s[-6:]=='eraser': s=s[-6:] elif s[-7:]=='dreamer': s=s[-7:] else: print('NO') exit() print('YES' if s=='erase' or s=='dreamer' or s=='dream' or s=='eraser' or s=='' else 'NO')" p03854,s851966766,Wrong Answer,"S = input() while True : if S[0:7] == ""dreamer"": S = S.strip(""dreamer"") elif S[0:6] == ""eraser"": S = S.strip(""eraser"") elif S[0:5] == ""dream"": S = S.strip(""dream"") elif S[0:5] == ""erase"": S = S.strip(""erase"") elif len(S) == 0: print(""YES"") break else: print(""NO"") break " p03854,s927339857,Wrong Answer,"words = {""eraser"" , ""erase"" , ""dreamer"" , ""dream"",""""} s = input() n = len(s) now="""" f=0 for i in range(0 ,n): now = now+s[i] if now ==""dreamer"": now = """" elif now ==""eraser"": now = """" if now in words: print(""YES"") else: print(""NO"")" p03854,s458693216,Wrong Answer,"s=input() def judge(): cnt=0 while cnt<=len(s): if s[cnt:cnt+6]=='eraser': cnt+=6 elif s[cnt:cnt+5]=='erase': cnt+=5 elif s[cnt:cnt+6]=='dreamer': cnt+=6 elif s[cnt:cnt+5]=='dream': cnt+=5 else: print('NO') exit() if cnt==len(s): print('YES') exit() judge()" p03854,s529942480,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)''' s=input().rstrip(""\n"") e=len(s) l=[""dream"",""dreamer"",""erase"",""eraser""] for i in range(len(s))[::-1]: #print(s[i:e]) if s[i:e] in l: e-=i continue if len(s[i:e])>7: print(""NO"") sys.exit() print(""YES"")" p03854,s160589660,Wrong Answer,"c = input().rstrip('\n') str1 = ""eraser"" str2 = ""erase"" str3 = ""dreamer"" str4 = ""dream"" count = 0 while(count < len(c)): if(c[count:count+len(str1)] == str1): count += len(str1) elif(c[count:count+len(str2)] == str2): count += len(str2) elif(c[count:count+len(str3)] == str3): count += len(str3) elif(c[count:count+len(str4)] == str4): count += len(str4) else: print(""NO"") exit() print(""YES"") " p03854,s251495545,Wrong Answer,"S=input() for i in range(10000): if S[-6:]==""dreamer"" or S[-6:]==""eraser"": S=S[:-6] elif S[-5:]==""dream"" or S[-5:]==""erase"": S=S[:-5] else: pass if S==[]: print(""YES"") break else: print(""NO"")" p03854,s398453621,Wrong Answer,"s = input() list = [""dream"", ""dreamer"", ""erase"", ""eraser""] for i in list: s = s.replace(i, """") if s == """": print(""YES"") else: print(""NO"") " p03854,s706395475,Wrong Answer,"s = """".join(list(reversed(input()))) t_t = [""maerd"", ""remared"", ""esare"", ""resare""] for _ in range(len(s)): for q in t_t: if q == s[:len(q)]: s = s[len(q):] print(""NO"" if len(s) else ""YES"") " p03854,s101060377,Wrong Answer,"S=input() str_list=[""dreamer"",""eraser"",""dream"",""erase""] S_tmp="""" while True: S_tmp=S for str in str_list: if S[-len(str):]==str: S=S.rstrip(str) if S_tmp==S: break if S=="""": print(""YES"") if S!="""": print(""NO"") " p03854,s575600109,Wrong Answer,"c = input().rstrip('\n') str1 = ""dreamer"" str2 = ""dream"" str3 = ""eraser"" str4 = ""erase"" count = 0 while(count < len(c)): if(c[count:count+len(str1)] == str1): count += len(str1) continue elif(c[count:count+len(str2)] == str2): count += len(str2) continue elif(c[count:count+len(str3)] == str3): count += len(str3) continue elif(c[count:count+len(str4)] == str4): count += len(str4) continue else: print(""NO"") exit() print(""YES"") " p03854,s873291174,Wrong Answer,"s=input() while True: if len(s) == 0: print(""Yes"") break elif s[-5:] == ""dream"" or s[-5:] == ""erase"": s=s[:-5] elif s[-6:] == ""eraser"": s=s[:-6] elif s[-7:] == ""dreamer"": s=s[:-7] else: print(""No"") break" p03854,s753612579,Wrong Answer,"S = input() S = S.replace(""dreamer"", """") S = S.replace(""eraser"", """") S = S.replace(""dream"", """") S = S.replace(""erase"", """") if len(S) == 0: print(""YES"") else: print(""NO"")" p03854,s285469683,Wrong Answer,"import re; s = input(); print(""Yes"" if re.fullmatch(r'^(dream|dreamer|eraser|erase)*$', s) else ""NO"") " p03854,s586914147,Wrong Answer,"def main(): S = input() border = len(S) while True: if S[border - 5: border] == ""dream"": border -= 5 elif S[border - 7: border] == ""dreamer"": border -= 7 elif S[border - 5: border] == ""erase"": border -= 5 elif S[border - 6: border] == ""eraser"": border -= 6 else: break if border == 0: print(""Yes"") else: print(""No"") if __name__ == ""__main__"": main()" p03854,s255382073,Wrong Answer,"# s = input() s = 'erasedream' while True: # print(s) if s == '': print('YES') break if s.endswith('eraser'): s = s.replace('eraser', '') elif s.endswith('dreamer'): s = s.replace('dreamer', '') elif s.endswith('dream'): s = s.replace('dream', '') elif s.endswith('erase'): s = s.replace('erase', '') else: print('NO') break " p03854,s506628810,Wrong Answer,"s=input()+'#' n=len(s) i=0 while i0 and trigger: for i in range(4): key=app[i] if key==t[:len(key)]: t=t[len(key):] print(t) trigger+=1 break trigger-=1 if t=='': print('YES') else: print('NO')" p03854,s626107078,Wrong Answer,"s = input() for word in [""eraser"",""erase"",""dreamer"",""dream""]: s = s.replace(word,""."") if len(set(s)) == 1: print(""YES"") else: print(""NO"")" p03854,s405165483,Wrong Answer,"S = input() S = S.replace('dream'[::-1], '').replace('dreamer'[::-1], '').replace( 'eraser'[::-1], '').replace('erase'[::-1], '') if len(S) == 0: print('YES') else: print('NO') " p03854,s183730178,Wrong Answer,"s = input() lst = ['dream', 'dreamer', 'erase', 'eraser'] while s: flag = 0 for elem in lst: if elem in s: s = s.replace(elem, '') flag = 1 break if flag == 0: print('NO') quit() print('YES')" p03854,s889873335,Wrong Answer,"s=input() s=s[::-1] divide=[""dream"", ""dreamer"", ""erase"", ""eraser""] c1=1 c2=0 for i in range(4): divide[i]==divide[i][::-1] for i in range(len(s)): c2=0 for j in range(4): d=divide[j] if s[i:i+len(d)]==d: c2=1 i+=len(d) if c2==0: c1=0 break if c1==1: print(""YES"") else: print(""NO"") " p03854,s423068053,Wrong Answer,"S=input() flag=False while True: if S[-5:] == 'dream' or S[-5:] == 'erase': S = S[:-5] elif S[-6:] == 'eraser': S = S[:-6] elif S[:-7] == 'dreamer': S = S[:-7] else: break if len(S)==0: print('YES') else: print('NO') " p03854,s575908590,Wrong Answer,"s=input() s = s[::-1] #文字の反転 t = 0; while t ==0: a = s.find(""maerd"") b = s.find(""remaerd"") c = s.find(""esare"") d = s.find(""resare"") if a == 0 or c== 0: s = s[5:] continue if b == 0: s = s[7:] continue if d == 0: s = s[6:] continue t=1 if s == """": print(""Yes"") else: print(""No"") " p03854,s329108882,Wrong Answer,"s = input() s=s[::-1] A=[""dream"",""dreamer"",""erase"",""eraser""] for i in range(len(A)): A[i]=A[i][::-1] i=0 while True: if len(s)==i: print(""Yes"") break elif s[i:i+5]==A[0]: i+=5 elif s[i:7]==A[1]: i+=7 elif s[i:i+5]==A[2]: i+=5 elif s[i:i+6]==A[3]: i+=6 else: print(""No"") break " p03854,s965629280,Wrong Answer,"s = list(input()) index = 0 while index < len(s): if """".join(s[index:index+7]) == ""dreamer"": index += 7 elif """".join(s[index:index+6]) == ""eraser"": index += 6 elif """".join(s[index:index+5]) == ""erase"" or """".join(s[index:index+5]) == ""dream"": index += 5 else: print(""NO"") exit() print(""YES"") " p03854,s784403989,Wrong Answer,"S=input() i=0 ans=""YES"" while i0 and trigger: for i in range(4): key=app[i] if key==t[:len(key)]: t=t[len(key):] trigger+=1 d=i break trigger-=1 if trigger==0 and d==0 and t[:3]=='ase': t='er'+t trigger+=1 if t=='': print('YES') else: print('NO') print(t)" p03854,s019502204,Wrong Answer,"word = input() list = ['dream','dreamer','erase','eraser'] count = 0 for i in list: a = i if a in word: word = word.replace(a, '') # print(word) if word == """": print(""YES"") else : print(""NO"")" p03854,s359997493,Wrong Answer,"q = ['dream','dreamer','erase','eraser'] s = input() while True: if len(s) <= 7: break if s[-5:] in q: s = s[0:-5] elif s[-7:] in q: s = s[0:-7] elif s[-6:] in q: s = s[0:-6] else: print('N0') exit() if s in q: print('YES') else: print('NO')" p03854,s519070920,Wrong Answer,"words = [w[::-1] for w in ['dream','dreamer', 'erase', 'eraser']] s = raw_input()[::-1] i = 0 while(i < len(s)): for w in words: if w == s[:len(w)]: i += len(w) break print 'YES' if i == len(s) else 'NO'" p03854,s322123530,Wrong Answer,"S = input()[::-1] kari = ['dream', 'dreamer', 'erase', 'eraser'] words = [i[::-1] for i in kari] l = len(S) cnt = '' for i in range(l): cnt += S[i] if cnt in words: cnt = '' if cnt!='': print('No') else: print('Yes')" p03854,s386433766,Wrong Answer,"S = input() S = ''.join(list(reversed([c for c in S]))) while S: if S[:7] == 'remaerd': S = S[7:] elif S[:6] == 'resare': S = S[6:] elif S[:5] == 'maerd': S = S[5:] elif S[:5] == 'esare': S = S[5:] else: print('No') exit() print('Yes')" p03854,s809725419,Wrong Answer,"S = input() S = S[::-1].replace(""resare"", ""0"").replace(""remaerd"", ""0"").replace(""esare"", ""0"").replace(""maerd"", ""0"") try: int(S) print(""YES"") except: print(""NO"") " p03854,s482846807,Wrong Answer,"S = str(""dreamerase"") S = S.replace(""eraser"", """") S = S.replace(""erase"", """") S = S.replace(""dreamer"", """") S = S.replace(""dream"", """") if len(S) == 0: print(""YES"") else: print(""NO"")" p03854,s987712587,Wrong Answer,"S=input() def solve(query): while 1: if not query: print(""Yes"") break for frag in (""erase"",""eraser"",""dream"",""dreamer""): if query.endswith(frag): query=query[:-len(frag)] break else: print(""No"") break solve(S)" p03854,s376170067,Wrong Answer,"S = input() while S != '': if S[-5:] == 'dream': S = S[:-5] elif S[-5:] == 'erase': S = S[:-5] elif S[-6:] == 'dreamer': S = S[:-6] elif S[-6:] == 'eraser': S = S[:-6] else: print('NO') exit() print('YES')" p03854,s376303417,Wrong Answer,"div = ['maerd', 'remaerd', 'esare', 'resare'] s = input() rs = ''.join(list(reversed(s))) can1 = True cnt = 0 for i in range(len(s)): if cnt != 0: cnt -= 1 continue can2 = False for d in range(len(div)): if (rs.find(div[d])) == i: can2 = True cnt = len(div[d]) -1 if can2 == False: can1 = False if can1: print('YES') else: print('NO')" p03854,s244948121,Wrong Answer,"import itertools input_moji = input() count = 0 lis = ['dream','dreamer', 'erase','eraser'] origin_list = ['dream','dreamer', 'erase','eraser'] for i in itertools.product(origin_list, repeat=2): total = """".join([str(_) for _ in i]) if input_moji == total: count += 1 print('Yes') if count == 0: print('No')" p03854,s282733567,Wrong Answer,"import re def solve(s): return 'YES' if re.match('^((dream|erase)r?)*$', s) else 'NO' _s = input() print(solve(_s)) " p03854,s429083050,Wrong Answer,"S=input() T=[""dream"",""dreamer"",""erase"",""eraser""] S=S.replace(T[3],"""").replace(T[2],"""").replace(T[1],"""").replace(T[0],"""") if S=="""": print(""Yes"") else: print(""No"")" p03854,s713692227,Wrong Answer,"S = input() while True: if S[-6:] == ""eraser"" or S[-6:] == ""dreamer"": S = S[:-6] if len(S) == 0: print(""YES"") exit(0) elif S[-5:] == ""dream"" or S[-5:] == ""erase"": S = S[:-5] if len(S) == 0: print(""YES"") exit(0) else: print(""NO"") exit(0) " p03854,s063909308,Wrong Answer,"S=input() str_list=[""dreamer"",""dream"",""eraser"",""erase""] S_tmp="""" while True: S_tmp=S for str in str_list: S=S.replace(str,"""",1) if S_tmp==S: break if S=="""": print(""YES"") if S!="""": print(""NO"") " p03854,s429146938,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) " p03854,s084061375,Wrong Answer,"s=input() t=['dream','dreamer','erase','eraser'] t=sorted(t,reverse=True) a=0 for i in range(4): for j in range(4): if t[i]+t[j]==s: a+=1 print(""YES""if a>0 else ""NO"")" p03854,s621955707,Wrong Answer,"# -*- coding: utf-8 -*- I = ""dream dreamer erase eraser"".split() I2 = input() if I2.replace(I[1], """").replace(I[0], """").replace(I[3], """").replace(I[2], """").strip() == """": print(""YES"") else: print(""NO"")" p03854,s289773018,Wrong Answer,"s = input() import re output =""NO"" s = re.sub('dreameraser', '', s) s = re.sub('eraser', '', s) s = re.sub('dreamer', '', s) s = re.sub('dream', '', s) s = re.sub('erase', '', s) if s == """": output = ""YES"" print(output) " p03854,s675076705,Wrong Answer,"S = input() # 前から順に消すと詰む # 後ろから順に消すと一意に定まる while True: if S[-5:] == 'erase': S = S[:-5] else: if S[-6:] == 'eraser': S = S[:-6] else: if S[-5:] == 'dream': S = S[:-5] else: if S[-7:] == 'dreamer': S = S[:-7] else: break if len(S) == 0: print('Yes') else: print('No')" p03854,s772532513,Wrong Answer,"s = input()[::-1] l = [ 'dream', 'dreamer', 'erase', 'eraser'] for i in range(4): s1 = l[i][::-1] l[i] = s1 n = len(s) i = 0 t1 = (l[1],l[3]) t2 = (l[0],l[2]) while i < n: judge = 0 if s[i] == 'r' and n-i >= 6: s1 = s[i:i+6] if s1 in t1: i += 6 judge = 1 elif n-i >= 4: s1 = s[i:i+5] if s1 in t2: i += 5 judge = 1 if judge == 0: break if i == n: print('YES') else: print('NO')" p03854,s694178291,Wrong Answer,"S = input() T = ['dream', 'dreamer', 'erase', 'eraser'] def reverse(t): return t[::-1] RT = [reverse(t) for t in T] RS = reverse(S) can = True i = 0 while i <= len(RT): can2 = False for j in range(4): sizeT = len(RT[j]) if RT[j] == RS[i:sizeT]: i += sizeT can2 = True break if not can2: can = False break if can: print('YES') else: print('NO') " p03854,s242506373,Wrong Answer,"S = input() S = S.replace('dream', '').replace('dreamer', '').replace( 'eraser', '').replace('erase', '') if len(S) == 0: print('YES') else: print('NO') " p03854,s348314797,Wrong Answer,"s=input() while len(s)>8: if s[-5:]=='dream' or s[-5:]=='erase': s=s[-5:] elif s[-6:]=='eraser': s=s[-6:] else: s=s[-7:] print('YES' if s=='erase' or s=='dreamer' or s=='dream' or s=='eraser' or s=='' else 'NO')" p03854,s772443892,Wrong Answer,"S = str(input()) S = S.replace(""eraser"",""-"") S = S.replace(""erase"",""-"") S = S.replace(""dream"",""-"") S = S.replace(""dreamer"",""-"") S = S.replace(""-"","""") if len(S) == 0: print(""YES"") else: print(""NO"")" p03854,s571061676,Wrong Answer,"S = input()[::-1] kari = ['dream', 'dreamer', 'erase', 'eraser'] words = [i[::-1] for i in kari] l = len(S) i = 0 while True: if S[i:i+5]==words[0] or S[i:i+5]==words[2]: i += 5 elif S[i:i+6]==words[3]: i += 6 elif S[i-7:i+7]==words[1]: i += 7 else: print('NO') exit() if i == l: print('YES') exit()" p03854,s492562661,Wrong Answer,"s=input() s=s.replace('dream', '') s=s.replace('dreamer', '') s=s.replace('erase', '') s=s.replace('eraser', '') if s=="""": print(""YES"") else: print(""NO"")" p03854,s408923791,Wrong Answer,"import re s = input() s = re.sub(""eraser"","""",s) s = re.sub(""erase"","""",s) s = re.sub(""dreamer"","""",s) s = re.sub(""dream"","""",s) if len(s) == 0: print(""Yes"") else: print(""No"") " p03854,s977058529,Wrong Answer,"s=input().replace('eraser',"""").replace('eraser',"""").replace('erase',"""").replace('dreamer',"""").replace('dream',"""") if s: print(""No"") else: print(""Yes"")" p03854,s059485557,Wrong Answer,"word = input() def gyaku(x): x = list(x) x.reverse() return ''.join(x) a = ''.join(gyaku(word).split(gyaku('eraser'))) b = ''.join(a.split(gyaku('dreamer'))) c = ''.join(b.split(gyaku('dream'))) d = ''.join(c.split(gyaku('erase'))) if d == '': print('YES') else: print('NO')" p03854,s349308791,Wrong Answer,"S=input() W=[0]*(len(S)+1) W[0]=1 words=['dream','dreamer','erase','eraser' ] for i in range(len(S)): if W[i]==0: continue for k in words: if S[i:i+len(k)]==k: W[i+len(k)]=1 if W[len(S)]==1: print(""Yes"") exit() else: print(""No"")" p03854,s321281086,Wrong Answer,"s=input() s=s[::-1] divide=[""dream"", ""dreamer"", ""erase"", ""eraser""] c1=1 c2=0 for i in range(4): divide[i]=divide[i][::-1] for i in range(len(s)): for j in range(4): d=divide[j] if s[i:i+len(d)]==d: c2=1 i+=len(d) if c2==0: c1=0 break if c1==1: print(""YES"") else: print(""NO"")" p03854,s264505681,Wrong Answer,"s = input()[::-1] n = len(s) words = ['maerd', 'remaerd', 'esare', 'resare'] p = 1 while p < n: if s[:p] in words: s = s[p:] p += 1 print('NO' if s else 'YES') " p03854,s098822874,Wrong Answer,"s = input() sc = [""dreameracer"", ""dreamerace"", ""dreamer"", ""dream"", ""eracer"", ""erace""] for i in sc: s = s.replace(i, '') if len(s) == 0: print(""YES"") else: print(""NO"")" p03854,s563386950,Wrong Answer,"S = input().strip() #----- i=0 while i <= len(S)-5: if S[i:(i+7)] == ""dreamer"": i=i+7 elif S[i:(i+6)] == ""eraser"": i=i+6 elif S[i:(i+5)] == ""dream"" or S[i:(i+5)] == ""erase"": i=i+5 else: print(""NO"") break print(""YES"")" p03854,s298453857,Wrong Answer,"s=input() L=len(s) newstring=''.join(list(reversed(s))) while L>0: if newstring[:5]==""maerd"": newstring=newstring[5:] elif newstring[:7]==""remaerd"": newstring=newstring[7:] elif newstring[:5]==""esare"": newstring=newstring[5:] elif newstring[:6]==""resare"": newstring=newstring[6:] else: print(""NO"") exit() print(""YES"")" p03854,s838169633,Wrong Answer,"s = input()[::-1] d = {'maerd', 'remaerd', 'esare', 'resare'} cnt = 0 while cnt + 5 < len(s): if s[cnt:cnt + 5] in d: cnt = cnt + 5 elif cnt + 6 < len(s) and s[cnt:cnt + 6] in d: cnt = cnt + 6 elif cnt + 7 < len(s) and s[cnt:cnt + 7] in d: cnt = cnt + 7 else: print('NO') break else: print('YES') " p03854,s715107656,Wrong Answer,"s = input() erase = s.count(""erase"") eraser = s.count(""eraser"") erase -= eraser dream = s.count(""dream"") dreamer = s.count(""dreamer"") dream -= dreamer if (eraser * 6 + erase * 5 + dream * 5 + dreamer * 6) >= len(s): print(""YES"") else: print(""NO"")" p03854,s752812577,Wrong Answer,"l = input() l = l.replace('eraser','') l = l.replace('erase','') l = l.replace('dreamer','') l = l.replace('dream','') if l == '': print('Yes') else: print('No')" p03854,s958287655,Wrong Answer,"import sys input = sys.stdin.readline S = input().rstrip() while S: if S[-5:] == ""dream"": S = S[:-5] elif S[-5] == ""erase"": S = S[:-5] elif S[-6:] == ""eraser"": S = S[:-6] elif S[-7:] == ""dreamer"": S = S[:-7] else: print(""NO"") sys.exit() print(""YES"") " p03854,s444247408,Wrong Answer,"s = input() dic = ['dreameraser', 'dreamerrase', 'dreamer', 'dream', 'eraser', 'erase'] def check(): i = 0 while i < len(s): found = False for k in dic: if s[i:i+len(k)] == k: found = True break if not found: return False i += len(k) return True print('YES' if check() else 'NO')" p03854,s067939159,Wrong Answer,"words = ['dream','dreamer', 'eraser', 'erase'] s = input() while True: chg_flg = False for w in words: if s.startswith(w): s = s[len(w):] chg_flg = True if not chg_flg: break if len(s) == 0: print(""YES"") else: print(""NO"")" p03854,s500062671,Wrong Answer,"# -*- coding:utf-8 -*- from collections import deque divide = [""dream"", ""dreamer"", ""erase"", ""eraser""]; s = input() que = deque() can = ""NO"" que.append(0) while(len(que) > 0): t = que[0] que.pop() if (t == len(s)): can = ""YES"" break for e in divide: if s[t:t+len(e)] == e: que.append(t+len(e)) print(can)" p03854,s693589591,Wrong Answer,"s=input() s=s.replace('dreamerase','') s=s.replace('dreamer','') s=s.replace('dream','') s=s.replace('eraser','') s=s.replace('erase','') if s=='': print('YES') else: print('NO')" p03854,s659184244,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, """") if (c == tmpstr): endflag = True break if (c == """"): print(""YES"") else: print(""NO"")" p03854,s024709845,Wrong Answer,"s=input().replace('eraser',"""").replace('eraser',"""").replace('erase',"""").replace('dreamer',"""").replace('dream',"""") if s: print(""No"") else: print(""Yes"")" p03854,s740968659,Wrong Answer,"S = input() C = [""maerd"",""remaerd"",""esare"",""resare""] ans = """" a = ""YES"" x = len(S) for i in range(x): ans = ans + S[x - 1 -i] if ans == C[0]: ans = """" elif ans == C[1]: ans = """" elif ans == C[2]: ans = """" elif ans == C[3]: ans = """" if len(ans) != 0: a = ""No"" print(a) " p03854,s169955874,Wrong Answer,"rev_s = ''.join(list(reversed(input()))) rev_w = ['maerd', 'remaerd', 'esare', 'resare'] while rev_s != '': for item1 in rev_w: if rev_s.find(item1) == 0: rev_s = rev_s[len(item1):] break if item1 == rev_w[-1]: break if rev_s == '': print('YES') else: print('NO') " p03854,s727142274,Wrong Answer,"S=input() S=S.replace('eraser','') S=S.replace('erase','') S=S.replace('dreamer','') S=S.replace('dream','') if S=='': print('Yes') else: print('No') " p03854,s030692371,Wrong Answer,"s=input() s=s.replace('dreamer','') s=s.replace('eraser','') s=s.replace('dream','') s=s.replace('erase','') if s=='': print('Yes') else: print('No')" p03854,s714766725,Wrong Answer,"s = input() # 文字の反転 s_rev = s[::-1] T_list = ['maerd', 'remaerd', 'esare', 'resare'] def mojicut(s, r): n = s.replace(r, """", 1) return n while len(s_rev) > 0: s_len = len(s_rev) for i in T_list: if s_rev.startswith(i): s_rev = mojicut(s_rev, i) break if len(s_rev) == s_len: break if len(s_rev) > 0: print(""No"") else: print(""Yes"")" p03854,s937207079,Wrong Answer,"S0 = input() S = S0[::-1] cands = [""dream""[::-1],""dreamer""[::-1],""erase""[::-1],""eraser""[::-1]] i = 0 while i < len(S): for word in cands: #print(S[i:],word) if S[i:].startswith(word): i += len(word) continue #print(i) if i == len(S): print(""True"") else: print(""False"") " p03854,s787022382,Wrong Answer,"S = input() Mozi = [""resare"",""esare"",""remaerd"",""maerd""] S = S[::-1] for i in Mozi: S = S.replace(i,"""") if not S: print(""Yes"") else: print(""No"")" p03854,s458704128,Wrong Answer,"words=[""eraser"",""erase"",""dreamer"",""dream""] S=input() for i in range(4): S=S.strip(words[i]) if S=="""": print(""Yes"") else: print(""No"") " p03854,s493245996,Wrong Answer,"s = input().replace('eraser', '').replace('erase', '') \ .replace('dreamer', '').replace('dream', '') if s: print('NO') else: print('YES') print(s)" p03854,s861636663,Wrong Answer,"s=input() # dream dreamer erase eraser while len(s)>0: if (s[-1]==""r"") & (s[-7]==""dreamer""): s.rstrip(""dreamer"") elif (s[-1]==""r"") & (s[-6]==""eraser""): s.rstrip(""eraser"") elif (s[-1]==""e"") & (s[-5]==""erase""): s.rstrip(""erase"") elif (s[-1]==""m"") & (s[-5]==""dream""): s.rstrip(""dream"") else: break if len(s)>0: print(""YES"") else: print(""NO"")" p03854,s291225410,Wrong Answer,"S = input() Mozi = [""dreamer"",""eraser"",""dream"",""erase""] if S not in ""X"": for i in Mozi: T = S.replace(i,""X"") S = T.strip(""X"") if not S: print(""Yes"") else: print(""No"") else: print(""No"") " p03854,s474256593,Wrong Answer,"S = input() # 前から順に消すと詰む # 後ろから順に消すと一意に定まる while len(S) > 0: if S[-5:] == 'erase': S = S[:-5] else: if S[-6:] == 'eraser': S = S[:-6] else: if S[-5:] == 'dream': S = S[:-5] else: if S[-7:] == 'dreamer': S = S[:-7] else: break if len(S) == 0: print('Yes') else: print('No')" p03854,s426966165,Wrong Answer,"s = str(input()) t = s.replace('eraser', '').replace('dreamer', '').replace('erase', '').replace('dream', '') if t == '': print('YES') else: print('NO') " p03854,s553082056,Wrong Answer,"import re print('YES' if re.match('^(dream|dremaer|erase|eraser)+$', input()) else 'NO') " p03854,s457950698,Wrong Answer,"word = input() list = ['dream','dreamer','erase','eraser'] count = 0 for i in list: a = i if a in word: word = word.replace(a, '') # print(word) count += 1 if count >= 2: print(""YES"") else : print(""NO"")" p03854,s363218039,Wrong Answer,"word = input() x = word.replace('eraser', '').replace('dreamer', '').replace('dream', '').replace('erase', '') if x == '': print('YES') else: print('NO')" p03854,s554775075,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 if(len(s)==0): print(""YES"") else: print(""NO"") " p03854,s641772826,Wrong Answer,"lt = [""dream"", ""dreamer"", ""erase"", ""eraser""] s = input() lt = [w[::-1] for w in lt] s = s[::-1] cond = True i = 0 while i < len(s): for t in lt: if s[i:].startswith(t): i += len(t) break else: cond = False break print(""Yes"" if cond else ""No"") " p03854,s398879114,Wrong Answer,"s=input() a=('dream','dreamer','erase','eraser') s_2=s[::-1] a_2=(a[0][::-1],a[1][::-1],a[2][::-1],a[3][::-1]) #print(s_2) #print(a_2) while len(s_2) > 0: judge = [s_2.startswith(i) for i in a_2] #print(judge) if any(judge)==True: target=a[judge.index(True)] s_2=s_2[len(target):] if len(s_2)==0: print('Yes') else: print('NO') break " p03854,s352165881,Wrong Answer,"s = input() s.replace('dreamer','') s.replace('eraser','') s.replace('dream','') s.replace('erase','') if len(s) > 0: print('NO') else: print('YES') " p03854,s749430914,Wrong Answer,"S = str(input()) S = S.replace(""dreamer"", """") S = S.replace(""eraser"", """") S = S.replace(""dream"", """") S = S.replace(""erase"", """") if len(S)==0: print(""YES"") else: print(""NO"")" p03854,s419432666,Wrong Answer,"s = input() while(len(s)!=0): if s[-5:] == 'dream' or s[-5:] == 'erase': s = s[:-5] elif s[-6:]== 'eraser': s = s[:-6] elif s[-7:0]=='dreamer': s = s[:-7] else: print('N0') break else: print('YES')" p03854,s193806500,Wrong Answer,"s = input() # s = 'dreamerasererase' while True: if s == '': print('YES') break if s.endswith('eraser'): s = s.rstrip('eraser') elif s.endswith('dreamer'): s = s.rstrip('dreamer') elif s.endswith('dream'): s = s.rstrip('dream') elif s.endswith('erase'): s = s.rstrip('erase') else: print('NO') break " p03854,s589376099,Wrong Answer,"s = input() kouho = [""dream"", ""dreamer"", ""erase"", ""eraser""] s.replace(kouho[0], """").replace(kouho[1], """").replace(kouho[2], """").replace(kouho[3], """") if s == """": print(""YES"") else: print(""NO"")" p03854,s387813320,Wrong Answer,"def main(): s = input() while len(s) > 0: if s[-6:] == ""dreamer"": s = s[:-7] elif s[-6:] == ""eraser"": s = s[:-6] elif s[-5:] == ""dream"": s = s[:-5] elif s[-5:] == ""erase"": s = s[:-5] else: print(""NO"") break else: print(""YES"") if __name__ == '__main__': main() " p03854,s962518491,Wrong Answer,"S=input() L=[""dream"",""dreamer"",""erase"",""eraser""] for l in L: S=S.replace(l,"""") print(""YES"" if S=="""" else ""NO"")" p03854,s475906718,Wrong Answer,"s = input() list_pool = [""dream"", ""dreamer"", ""erase"", ""eraser""] continue_flag = True # 文字列sにlist_poolのどれかの単語と一致する部分があるか後方からチェック while continue_flag is True and len(s) > 0: continue_flag = False for word in list_pool: if s.endswith(word): s = s.replace(word, '') continue_flag = True if continue_flag is True: print(""YES"") else: print(""NO"") " p03854,s900760561,Wrong Answer,"def solve(): S = input() i = 0 while i < len(S): if S[i:i+5] not in ['dream', 'erase']: return 'NO' i += 5 if S[i:i+6] == 'eraser': i += 6 if S[i:i+5] == 'erase': i += 5 if S[i:i+2] == 'er': i += 2 return 'YES' if __name__ == '__main__': ans = solve() print(ans)" p03854,s595606976,Wrong Answer,"word = input() def gyaku(x): x = list(x) x.reverse() return ''.join(x) a = ''.join(gyaku(word).split(gyaku('eraser'))) b = ''.join(a.split(gyaku('dreamer'))) c = ''.join(b.split(gyaku('dream'))) d = ''.join(c.split(gyaku('erase'))) print(d) if d == '': print('YES') else: print('NO')" p03854,s965636195,Wrong Answer,"s = input().replace(""eracer"",'').replace('erace','').replace('dreamer','').replace('dreame','') print('YES' if len(s) == 0 else 'NO')" p03854,s829647281,Wrong Answer,"S = input() flag = 0 while True: if S.startswith(""dream"") or S.startswith(""erase""): S = S[5:] if S.startswith(""ase""): S = S[3:] if S.startswith(""aser""): S = S[4:] if S.startswith(""dreamer""): S = S[7:] if S.startswith(""eraser""): S = S[6:] elif S == """": break else: flag = 1 break print(""YES"" if flag == 0 else ""NO"") " p03854,s533375923,Wrong Answer,"s = input() u = ['dreamer', 'eraser', 'dream', 'erase'] while len(s) > 0: for i in u: if s[0:len(i)] == i: s = s.lstrip(i) break else: print('No') exit() else: print(""YES"")" p03854,s538051305,Wrong Answer,"S = input () Z = ''.join(list(reversed(S))) Z = Z.replace('resare', '') Z = Z.replace('esare', '') Z = Z.replace('remaerd', '') Z = Z.replace('maerd', '') z = len (Z) if z == 0: print ('Yes') else: print ('No')" p03854,s875740779,Wrong Answer,"s = input() s = s.replace(""dreamer"", """").strip() s = s.replace(""dream"", """").strip() s = s.replace(""eraser"", """").strip() s = s.replace(""erase"", """").strip() if len(s) > 0: print(""NO"") else: print(""YES"")" p03854,s858653071,Wrong Answer,"s = input() kouho = [""dream"", ""dreamer"", ""erase"", ""eraser""] s = s.replace(kouho[1], """").replace(kouho[3], """").replace(kouho[0], """").replace(kouho[2], """") if s == """": print(""YES"") else: print(""NO"")" p03854,s492842428,Wrong Answer,"c = input().rstrip('\n') if (len(c) == 0): c = ""f"" 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, """") if (c == tmpstr): endflag = True break if (c == """"): print(""YES"") else: print(""NO"")" p03854,s973929731,Wrong Answer,"S = input() ch = [""dream"", ""dreamer"", ""erase"", ""eraser""] while S: N = len(S) if S[N-5:N] == ch[0] or S[N-5:N] == ch[2]: S = S[:N-5] elif S[N-6:N] == ch[1] or S[N-6:N] == ch[3]: S = S[:N-6] else: print(""NO"") exit() print(""YES"")" p03854,s911764812,Wrong Answer,"s = input() a = s.count(""dream"") b = s.count(""dreamer"") c = s.count(""erase"") d = s.count(""eraser"") e = s.count(""dreamera"") f = s.count(""erasera"") b = b-e d = d-f a = a-b c = c-e if (a+c)*5 + b*7 + d*6 == len(s): print(""YES"") else: print(""N0"")" p03854,s745380619,Wrong Answer,"s = input() s = s[::-1] lis = ['dream', 'dreamer', 'erase', 'eraser'] nlis = [] for i in lis: nlis.append(i[::-1]) flag = 0 for _ in range(10**5+1): for j in nlis: if s.startswith(j): s = s.replace(j, '') else: break if s == '': flag = 1 break if flag: print('YES') else: print('NO')" p03854,s995456288,Wrong Answer,"s=input()[::-1] words = {""dream"", ""dreamer"", ""erase"", ""eraser""} for i in words: s = s.replace(i[::-1],'') print(s[::-1], i) print(""NO""if len(s)!=0else ""YES"")" p03854,s449975876,Wrong Answer,"s = input() A=["""",""dream"",""dreamer"",""erase"",""eraser""] flag=0 for a in range(1,5): for b in range(0,5): for c in range(0,5): for d in range(0,5): for e in range(0,5): T=A[a]+A[b]+A[c]+A[d]+A[e] if s==T: flag=1 if flag==1: print(""Yes"") else: print(""No"") " p03854,s055845634,Wrong Answer,"s = input()[::-1] r = 'YES' while len(s): if s[:6] == 'dreamer'[::-1] or s[:6] == 'eraser'[::-1]: s = s[6:] elif s[:5] == 'dream'[::-1] or s[:5] == 'erase'[::-1]: s = s[5:] else: r = 'NO' break print(r)" p03854,s391877616,Wrong Answer,"S = input() T = ['dream', 'dreamer', 'erase', 'eraser'] def reverse(t): return t[::-1] RT = [reverse(t) for t in T] RS = reverse(S) for i in range(len(RS)): can = False for j in range(4): sizeT = len(RT[j]) if RT[j] == RS[i:sizeT]: i += sizeT can = True break if can: break if can: print('YES') else: print('NO') " p03854,s355572154,Wrong Answer,"s = input() s.replace(""eraser"","""") s.replace(""erase"","""") s.replace(""dreamer"","""") s.replace(""dream"","""") if s: print(""NO"") else: print(""YES"")" p03854,s368887498,Wrong Answer,"s = input() A=["""",""dream"",""dreamer"",""erase"",""eraser""] flag=0 for a in range(0,5): for b in range(0,5): for c in range(0,5): for d in range(0,5): T=A[a]+A[b]+A[c]+A[d] if s==T: flag=1 if flag==1: print(""Yes"") else: print(""No"") " p03854,s967957981,Wrong Answer,"s = str(input()) s.replace('dreamer','') s.replace('eraser','') s.replace('dream','') s.replace('erase','') if len(s) == 0: print('YES') else: print('NO') " p03854,s740255015,Wrong Answer,"S = input() S = S.replace(""eraser"","""") S = S.replace(""erase"","""") S = S.replace(""dreamer"","""") S = S.replace(""dream"","""") if len(S) == 0: print(""Yes"") else: print(""No"")" p03854,s920514702,Wrong Answer,"import re; s = input(); print(""Yes"" if re.match(r'^(dream|dreamer|eraser|erase)+$', s) else ""NO"") " p03854,s310899212,Wrong Answer,"S=input() S=S.replace('eraser','') S=S.replace('erase','') S=S.replace('dreamer','') S=S.replace('dream','') if S=='': print('Yes') else: print('No') " p03854,s518045014,Wrong Answer,"s = input() s = s[::-1] lis = ['dream', 'dreamer', 'erase', 'eraser'] nlis = [] for i in lis: nlis.append(i[::-1]) flag = 0 for _ in range(10**5+1): for j in nlis: if s.startswith(j): s = s.replace(j, '') if s == '': print('YES') else: print('NO')" p03854,s627418444,Wrong Answer,"from collections import deque s = input() q = deque(list(s)) while q: print(q) if len(q) >= 5: subs = q.popleft()+q.popleft()+q.popleft()+q.popleft()+q.popleft() if subs != 'erase' and subs != 'dream': print('NO') exit() if subs == 'erase' and len(q) != 0 and q[0] == 'r': q.popleft() else: print('NO') exit() print('YES')" p03854,s622319418,Wrong Answer,"S = input() db = [""dream"", ""erase""] offset = 0 key = True while key: if offset >= len(S): key = False if S[offset:offset+5] == db[0]: if S[offset:offset+7] == db[0]+""er"": offset += 7 else: offset += 5 elif S[offset:offset+5] == db[1]: if S[offset:offset+6] == db[1]+""r"": offset += 6 else: offset += 5 else: break print(""YNEOS""[key::2])" p03854,s153495727,Wrong Answer,"s = str(input()) s = s.replace('dreamer','') s = s.replace('eraser','') s = s.replace('dream','') s = s.replace('erase','') if len(s) == 0: print('YES') else: print('NO')" p03854,s439050280,Wrong Answer,"import re moji=str(input()) for i in range(4): if ""eraser"" in moji: moji=re.sub(""eraser"", """", moji) elif ""dreamer"" in moji: moji=re.sub(""dreamer"", """", moji) elif ""dream"" in moji: moji=re.sub(""dream"", """", moji) elif ""erase"" in moji: moji=re.sub(""erase"", """", moji) print(""YES"" if moji=="""" else ""NO"") " p03854,s239086101,Wrong Answer,"c = input().rstrip('\n') str1 = ""dreamer"" str2 = ""dream"" str3 = ""eraser"" str4 = ""erase"" count = 0 while(count < len(c)): if(c[count:count+len(str1)] == str1): count += len(str1) elif(c[count:count+len(str2)] == str2): count += len(str2) elif(c[count:count+len(str3)] == str3): count += len(str3) elif(c[count:count+len(str4)] == str4): count += len(str4) else: print(""NO"") exit() print(""YES"") " p03854,s226398167,Wrong Answer,"S = input() strs = [""erase"", ""eraser"", ""dreamer"",""dream""] rtss = [s[::-1] for s in strs] S = S[::-1] ind = 0 while True: print(ind,S[ind]) if S[ind:ind+5] in rtss: ind += 5 elif S[ind:ind+6] in rtss: ind += 6 elif S[ind:ind+7] in rtss: ind +=7 else: print(""NO"") exit() if ind == len(S): print(""YES"") exit()" p03854,s555875930,Wrong Answer,"S=input() S=S.replace('dreamer','') S=S.replace('dream','') S=S.replace('eraser','') S=S.replace('erase','') if S=='': print('Yes') else: print('No') " p03854,s908654846,Wrong Answer,"a = input().replace(""eraser"", """").replace(""erase"","""").replace(""dreamer"","""").replace(""dream"","""") if len(a) == 0: print(""Yes"") else: print(""No"") " p03854,s649584463,Wrong Answer,"s = input() s = s.strip() list_pool = [""dream"", ""dreamer"", ""erase"", ""eraser""] continue_flag = True # 文字列sにlist_poolのどれかの単語と一致する部分があるか後方からチェック while continue_flag is True and len(s) > 0: continue_flag = False for word in list_pool: if s.endswith(word): s = s.replace(word, '') continue_flag = True if continue_flag is True: print(""YES"") else: print(""NO"")" p03854,s755022592,Wrong Answer,"import re S = input() s = re.sub(r""(dreamer)|(eraser)"", """", S) s = re.sub(r""(dream)|(erase)"", """", s) if len(s) == 0: print(""YES"") else: print(""NO"")" p03854,s882971799,Wrong Answer,"s = input() s = s[::-1] lis = ['dream', 'dreamer', 'erase', 'eraser'] nlis = [] for i in lis: nlis.append(i[::-1]) flag = 0 ans = '' for _ in range(10): for j in nlis: if s.startswith(j): ans += j s = s.replace(j, '') if ans == s: flag = 1 break if flag: print('YES') else: print('NO')" p03854,s892860033,Wrong Answer,"s = input() length = len(s) i = 0 res = ""YES"" while i < length: if i+4 <= length and s[i:i+5] == ""dream"": i += 5 if i+1 <= length and s[i:i+2] == ""er"" and s[i+2] != ""a"": i += 2 else: res = ""NO"" break if i+4 <= length and s[i:i+5] == ""erase"": i += 5 if i+1 < length and s[i:i+2] == ""er"" and s[i+2] != ""a"": i += 2 else: res =""NO"" break print(res)" p03854,s861051021,Wrong Answer,"S=input() str_list=[""dreamer"",""eraser""] str_list_2=[""dream"",""erase""] S_tmp="""" while True: S_tmp=S for str in str_list: if S[:7]==""dreamer"": S=S.rstrip(""dreamer"") if S[:6]==""eraser"": S=S.rstrip(""eraser"") if S_tmp==S: break while True: S_tmp=S for str in str_list_2: if S[:5]==str: S=S.rstrip(str) if S_tmp==S: break if S=="""": print(""YES"") if S!="""": print(""NO"") " p03854,s612518060,Wrong Answer,"import sys S = input() while len(S)>5: if S[-7:] == ""dreamer"": S = S[:-7] elif S[-6:] == ""eraser"": S = S[:-6] elif S[-5:] == ""dream"" or S[-5:] == ""erase"": S = S[:-5] else: print(""No"") sys.exit() print(""Yes"")" p03854,s325371333,Wrong Answer,"s,f=input()[::-1],-1 while f<0: if s: if s[:5]=='maerd': s=s[5:] elif s[:5]=='esare': s=s[5:] elif s[:6]=='resare': s=s[6:] elif s[:7]=='remaerd': s=s[7:] else: f=0 else: f=1 print(['No','Yes'][f])" p03854,s498309868,Wrong Answer,"S= input() i=0 while True: flag = False if S[i:i+7] == ""dreamer"": i += 7 flag = True if S[i:i+6] == ""eraser"": i += 6 flag = True if S[i:i+5] == ""erase"" or S[i:i+5] == ""dream"": i += 5 flag = True if not flag: break if i == len(S): print(""Yes"") else: print(""No"") " p03854,s917376265,Wrong Answer,"input_str = input() while(True): if input_str[0:7] == ""dreamer"": input_str = input_str[7:] elif input_str[0:6] == ""eraser"": input_str = input_str[6:] elif input_str[0:5] == ""dream"" or input_str[0:5] == ""erase"": input_str = input_str[5:] else: print(""NO"") break if len(input_str) == 0: print(""YES"") break" p03854,s796309143,Wrong Answer,"S = input().replace(""dreamer"", ""1"").replace(""dream"", ""1"").replace( ""eraser"", ""1"").replace(""erase"", ""1"").replace(""1"", """") if len(S) == 0: print(""YES"") else: print(""NO"")" p03854,s720289065,Wrong Answer,"import re s = input() print('Yes' if re.match('^(dream|dreamer|erase|eraser)+$', s) else 'No')" p03854,s225277990,Wrong Answer,"s=str(input()) s=s[::-1] print(s) stack="""" for i in s: stack=i+stack if stack==""dream""or stack==""dreamer""or stack==""erase""or stack==""eraser"": stack="""" elif len(stack)>7: print(""NO"") exit() print(""YES"")" p03854,s318592752,Wrong Answer,"S=input() while(1): length = len(S) if length==0: break if S[length-3:length]==""eam"": S = S[:length-5] elif S[length-3:length]==""mer"": S = S[:length-7] elif S[length-3:length]==""ase"": S = S[:length-5] elif S[length-3:length]==""ser"": S = S[:length-6] else: print(""NO"") exit(0) print(""YES"")" p03854,s100339063,Wrong Answer,"s = input()[::-1] t =['maerd', 'remae', 'esare', 'resar'] if s[0:-5] in t: print('YES') else: print('NO')" p03854,s205974825,Wrong Answer,"S = input() while True: if S[-3:] == ""mer"": S = S.replace(""dreamer"", """") elif S[-3:] == ""ser"": S = S.replace(""eraser"", """") elif S[-3:] == ""eam"": S = S.replace(""dream"", """") elif S[-3:] == ""ase"": S = S.replace(""erase"", """") else: break print(""NO"") if S else print(""YES"")" p03854,s243371514,Wrong Answer,"d=raw_input().strip() l=[""dreamer"", ""eraser"", ""dream"", ""erase""] loop=True while loop: match=False for i in l: if d.startswith(i): match=True d = d[len(i):] if not d: loop=False break if not match: break if d: print(""NO"") else: print(""YES"")" p03854,s208632947,Wrong Answer,"s = input()[::-1] t =['maerd', 'remae', 'esare', 'resar'] if s[0:5] in t: print('YES') else: print('NO')" p03854,s571703837,Wrong Answer,"t = [""dream"",""dreamer"",""erase"",""eraser""] # 反転 t_r = [] for i in range(len(t)): t_r.append(t[i][::-1]) s = input() s_r = s[::-1] flag = True for i in range(len(s_r)): flag2 = False for j in t_r: tmp_s = s_r[i:len(j)] if(tmp_s == j): flag2 = True i += len(j) if flag2 == False: flag = False break if flag==True: print(""YES"") else: print(""NO"")" p03854,s493727304,Wrong Answer,"def I(): return int(input()) def MI(): return map(int, input().split()) def LMI(): return list(map(int, input().split())) MOD = 10 ** 9 + 7 S = input() S = ''.join(list(reversed(S))) while len(S) > 0: if S[:6] in ['resare', 'remaerd']: S = S[6:] elif S[:5] in ['esare', 'maerd']: S = S[5:] else: print('NO') exit(0) print('YES') " p03854,s182528720,Wrong Answer,"s = input().replace(""eraser"", """").replace(""erase"", """").replace(""dreamer"", """").replace(""dream"", """") if s: print(""YES"") else: print(""NO"")" p03854,s934777365,Wrong Answer,"c = input().rstrip('\n') str1 = 'dreamer' str2 = 'dream' str3 = 'eraser' str4 = 'erase' count = 0 while(count < len(c)): if(c[count:count+len(str1)] == str1): count += len(str1) elif(c[count:count+len(str2)] == str2): count += len(str2) elif(c[count:count+len(str3)] == str3): count += len(str3) elif(c[count:count+len(str4)] == str4): count += len(str4) else: print(""NO"") exit() print(""YES"") " p03854,s006030572,Wrong Answer,"S=input() S=S[::-1] N=len(S) index=0 words=[""maerd"",""remaerd"",""esare"",""resare""] while index 4: if s[-5:] == 'dream': s = s[:-5] elif s[-6:] == 'dreamer': s = s[:-6] elif s[-5:] == 'erase': s = s[:-5] elif s[-6:] == 'eraser': s = s[:-6] else: break print('NO' if len(s) > 0 else 'YES') " p03854,s975413843,Wrong Answer,"S=input() n=len(S) while n>0: print(S) if S[n-4:n+1]=='dream': n-=5 elif S[n-4:n+1]=='erase': n-=5 elif S[n-6:n+1]=='dreamer': n-=7 elif S[n-5:n+1]=='eraser': n-=6 else: print('NO') exit() print('YES')" p03854,s989447987,Wrong Answer,"s = input()[::-1] d = {'maerd', 'remaerd', 'esare', 'resare'} cnt = 0 while cnt < len(s): if s[cnt:cnt + 5] in d: cnt = cnt + 5 elif cnt + 6 < len(s) and s[cnt:cnt + 6] in d: cnt = cnt + 6 elif cnt + 7 < len(s) and s[cnt:cnt + 7] in d: cnt = cnt + 7 else: print('NO') break else: print('YES') " p03854,s512012663,Wrong Answer,"s = input() flag = True while(flag): if(len(s)==0): flag = False if s[-5:] == 'dream' or s[-5:] == 'erase': s = s[:-5] elif s[-6:]== 'eraser': s = s[:-6] elif s[-7:0]=='dreamer': s = s[:-7] else: break if(flag): print('NO') else: print('YES') " p03854,s199004374,Wrong Answer,"s = input() import re output =""NO"" s = re.sub('dreamer', '', s) s = re.sub('eraser', '', s) s = re.sub('dream', '', s) s = re.sub('erase', '', s) if s == """": output = ""YES"" print(output)" p03854,s554608917,Wrong Answer,"s = input().replace(""eracer"",'').replace('erace','').replace('dreamer','').replace('dream','') print('YES' if len(s) == 0 else 'NO')" p03854,s058239000,Wrong Answer,"s = input() s = s[::-1] s = s.replace('maerd','/') s = s.replace('esare', '/') s = s.replace('remaerd','/') s = s.replace('resare','/') s = s.replace('/', '') if len(s) == 0: print('YES') else: print('NO')" p03854,s638827859,Wrong Answer,"s = input() flag = 0 while(len(s)>0): if (s[:6] == 'eraser'): s = s[6:] elif (s[:5] == 'erase'): s = s[5:] elif (s[:5] == 'dream'): if (s[5:8] == 'ere' or s[5:8] == 'erd'): s = s[7:] else: s = s[5:] else: flag = 1 break if (flag == 0): print('YES') else: print('NO')" p03854,s003051968,Wrong Answer,"s = input() erase = s.count(""erase"") eraser = s.count(""eraser"") dreameraser = s.count(""dreameraser"") dream = s.count(""dream"") dreamer = s.count(""dreamer"") erase -= eraser dream -= dreamer dreamer -= dreameraser eraser -= dreameraser if (eraser * 6 + erase * 5 + dream * 5 + dreamer * 6 + dreameraser*11) == len(s): print(""YES"") else: print(""NO"")" p03854,s830209429,Wrong Answer,"S = input() K = S.replace(""dream"","""") L = K.replace(""erase"","""") M = L.replace(""er"","""") if M == """": print(""YES"") else: print(""NO"")" p03854,s182438367,Wrong Answer,"S = input() flag = 0 S = S[::-1] while True: if S.startswith(""maerd"") or S.startswith(""esare""): S = S[5:] elif S.startswith(""remaerd""): S = S[7:] elif S.startswith(""reesare""): S = S[6:] elif S == """": break else: flag = 1 break print(""YES"" if flag == 0 else ""NO"") " p03854,s679488394,Wrong Answer,"s=input() s=s[::-1] voc=['dream','dreamer','erase','eraser'] for i in range(len(voc)): voc[i]=voc[i][::-1] while True: flag=False for v in voc: if s[:len(v)]==v: s=s[len(v):] flag=True if s=='': print('Yes') break elif not flag: print('No') break " p03854,s434146973,Wrong Answer,"s = input() s = s.replace(""dream"","""") s = s.replace(""dreamer"","""") s = s.replace(""erase"","""") s = s.replace(""eraser"","""") if len(s)==0: print(""YES"") else: print(""NO"") " p03854,s431151367,Wrong Answer,"s = input() import re output =""NO"" s = re.sub('eraser', '', s) s = re.sub('dreamer', '', s) s = re.sub('dream', '', s) s = re.sub('erase', '', s) if s == """": output = ""YES"" print(output) " p03854,s649981630,Wrong Answer,"import sys import resource sys.setrecursionlimit(100000) def hantei(S): if S == 'dream' or S == 'dreamer' or S == 'erase' or S == 'eraser': return 1 if S[:5] == 'dream' or S[:5] == 'erase': if S[:7] == 'dreamer' or S[:7] == 'eraser': return hantei(S[5:]) | hantei(S[7:]) else: return hantei(S[5:]) else: return 0 S = input() if(hantei(S)): print('YES') else: print('NO')" p03854,s519078129,Wrong Answer,"st = input() S = st[::-1] words ={""remaerd"",""resare"",""maerd"",""esare""} lenT = 0 flag = 0 ans = ""NO"" while flag < 5: for i in range(5, 8): if S[0:i] in words: S = S[i:] elif S == """": flag = 5 ans = ""YES"" break else: flag += 1 print(ans) " p03854,s234091695,Wrong Answer,"#ABC049 s = input() while len(s) != 0: if s[-5:] == ""dream"": s = s[:-5] elif s[-7:] == ""dreamer"": s = s[:-7] elif s[-5:] == ""erase"": s = s[:-5] elif s[-6:] == ""eraser"": s = s[:-6] else: print(""NO"") break print(""YES"")" p03854,s050534529,Wrong Answer,"S = input() T = [""dream"", ""dreamer"", ""erase"", ""eraser""] S = S[::-1] for i in range(4): T[i] = T[i][::-1] can = True i = 0 while i < len(S): can2 = False for t in T: if S[i:i + len(t)] == t: can2 = True i += len(t) if can2 == False: can = False break i += 1 if can: print(""YES"") else: print(""NO"") " p03854,s666133572,Wrong Answer,"s=input() n=len(s) i=1 for j in range(n): if s[-i:-i-5:-1]==""maerd"": i+=5 if s[-i:-i-5:-1]==""esare"": i+=5 if s[-i:-i-6:-1]==""resare"": i+=6 if s[-i:-i-7:-1]==""remeard"": i+=7 if i==n+1: print(""YES"") break if i !=n: print(""NO"")" p03854,s994567546,Wrong Answer,"s = input() import re output =""NO"" s = re.sub('dreameraser', '', s) s = re.sub('dreamerase', '', s) s = re.sub('dreamer', '', s) s = re.sub('eraser', '', s) s = re.sub('erase', '', s) s = re.sub('dream', '', s) if s == """": output = ""YES"" print(output)" p03854,s112179847,Wrong Answer,"s = input() s2 = s.split('eraser') s3 = ''.join(s2).split('erase') s4 = ''.join(s3).split('dreamer') s5 = ''.join(s4).split('dream') if len(s5) == 1 and s5[0] == '': print(""YES"") else: print(""NO"")" p03854,s502161131,Wrong Answer,"s = input() ans = ""YES"" while s != """": if s[len(s) - 5:] == ""dream"" or s[len(s) - 5:] == ""erase"": s = s[:len(s) - 5] elif s[len(s) - 6:] == ""eraser"": s = s[:len(s) - 6] elif s[len(s) - 7] == ""dreamer"": s = s[:len(s) - 7] else: ans = ""NO"" break print(ans)" p03854,s112479374,Wrong Answer,"# -*- coding: utf-8 -*- S = input() S = S.replace(""eraser"", """") S = S.replace(""erase"", """") S = S.replace(""dreamer"", """") S = S.replace(""dream"", """").strip() if len(S) ==0: print(""NO"") else: print(""YES"") " p03854,s681563361,Wrong Answer,"s = str(input()) a = ['dream', 'dreamer', 'erase', 'eraser'] f = True while f: os = s for i in a: if s.endswith(i): s = s[:-len(i)] if len(s) == 0: print(""YES"") f = False if len(os) == len(s): print(""No"") f = False" p03854,s487713935,Wrong Answer,"dr =""dream"" dre = ""dreamer"" er =""erase"" ere = ""eraser"" a = input() ret = ""YES"" while len(a) != 0: if (a.endswith(dr) or a.endswith(er)): a = a[:len(a)-5] elif(a.endswith(dre) or a.endswith(ere)): a = a[:len(a)-7] else: ret = ""NO"" break print(ret)" p03854,s364981484,Wrong Answer,"S = input() results = True while results: for key_word in [""erase"", ""eraser"", ""dream"", ""dreamer""]: if S.endswith(key_word): S = S.rstrip(key_word) continue if S == '': print(""YES"") results = False break else: print(""NO"") results = False break" p03854,s436441689,Wrong Answer,"S = input() Mozi = [""dreamer"",""eraser"",""dream"",""erase""] for i in Mozi: T = S.strip(i) S = T if not S: print(""Yes"") else: print(""No"") " p03854,s173455898,Wrong Answer,"words = ['dream','dreamer', 'erase', 'eraser'] s = raw_input() dp = [False for _ in range(len(s))] i = 0 for j in range(len(s)): dp[j] = any([(dp[j - len(w) - 1] if j - len(w) -1 >= 0 else True) and s[j- len(w):j+1] == w for w in words]) print 'YES' if dp[-1] else 'NO'" p03854,s587773044,Wrong Answer,"def main(): import sys def input(): return sys.stdin.readline().rstrip() s = input() word = ['eraser', 'erase', 'dreamer', 'dream'] for x in word: s = s.replace(x, '') if s == '': print('Yes') else: print('No') if __name__ == '__main__': main()" p03854,s977877894,Wrong Answer,"s=input()[::-1] words = {""dream"", ""dreamer"", ""erase"", ""eraser""} for i in words: s = s.replace(i[::-1],'') print(""NO""if len(s)else ""YES"")" p03854,s106768802,Wrong Answer,"S = input() if S.replace(""dream"","""").replace(""dreamer"","""").replace(""erase"","""").replace(""eraser"",""""): print(""NO"") else: print(""YES"")" p03854,s374507248,Wrong Answer,"s = input()[::-1] ls = ['dream', 'dreamer', 'erase', 'eraser'] ls = [ls[i][::-1] for i in range(4)] ans = 'YES' i = 0 while i < len(s): ng = 1 for j in range(4): if s[i:i+len(ls[j])] == ls[j]: i += len(ls[j]) ng = 0 if ng: ans = 'No' break print(ans)" p03854,s257513221,Wrong Answer,"# 動的計画法(DP) s=input() words = {""dream"", ""dreamer"", ""erase"", ""eraser""} dp = dict() for i in range(0, len(s)): for word in words: if s[i:i+len(word)] == word: dp[i+len(word)] = 1 print(""YES"" if dp.get(len(s)) else ""NO"")" p03854,s233001421,Wrong Answer,"words = ['dream','dreamer', 'erase', 'eraser'] s = raw_input() dp = [False for _ in range(len(s))] i = 0 for j in range(len(s)): dp[j] = any([s[j- len(w):j+1] == w for w in words]) print 'YES' if dp[-1] else 'NO'" p03854,s988098236,Wrong Answer,#わっかりません復習します p03854,s953297991,Wrong Answer,"S = input() strs = list(reversed(S)) rev_S = ''.join(strs) rev_S.replace('maerd', '') rev_S.replace('remaerd', '') rev_S.replace('esare', '') rev_S.replace('resare', '') if rev_S.replace == '': print('YES') else: print('NO')" p03854,s481748232,Wrong Answer,"S = input() results = True while results: for key_word in [""erase"", ""eraser"", ""dream"", ""dreamer""]: if S.endswith(key_word): S = S[:-len(key_word)] continue if S == '': print(""YES"") results = False break else: print(""NO"") results = False break" p03854,s486930269,Wrong Answer,"s=input()[::-1] i=0 while i 0: if S[-1:-6:-1] in l: S = S[:-5] elif S[-1:-7:-1] in l: S = S[:-6] else: print('NO') return print('YES') return test(S,l)" p03854,s170658239,Wrong Answer,"S = input() if len(S) == 0: print('NO') if len(S.replace('dreamer', '').replace('dream', '').replace('eraser', '').replace('erase', '')) == 0: print('YES') else: print('NO')" p03854,s545924535,Wrong Answer,"def main(S): listdreamereraser = ['dreamer','eraser','dream','erase'] while True: for i in listdreamereraser: if i in S[-len(i):]: S = S.replace(i,'',-1) break else: return False if len(S) == 0: return True S = input() print('YES' if main(S) else 'NO')" p03854,s490925241,Wrong Answer,"s=input() ans='YES' while s=='': if s[:7]=='dreamer': s=s[7:] elif s[:5]=='dream': s=s[5:] elif s[:6]=='eraser': s=s[6:] elif s[:5]=='erase': s=s[5:] else: ans='NO' break print(ans)" p03854,s437476697,Wrong Answer,"s = input() pos = len(s) while pos >= 0: if s[pos-6:pos] == 'eraser': pos -= 6 elif s[pos-5:pos] == 'erase': pos -= 5 elif s[pos-5:pos] == 'dream': pos -= 5 elif s[pos-6:pos] == 'dreamer': pos -= 6 else: break print('YES' if pos <= 0 else 'NO') " p03854,s067940391,Wrong Answer,"s = input() if s.replace(""dreamer"", """").replace(""dream"", """").replace(""eraser"", """").replace(""eras"", """"): print(""NO"") else: print(""YES"")" p03854,s172777091,Wrong Answer,"S = input() Mozi = [""dreamer"",""eraser"",""dream"",""erase""] for i in Mozi: T = S.replace(i,""X"") S = T if S not in ""X"": print(""No"") else: print(""Yes"")" p03854,s483574571,Wrong Answer,"s = input() while True: if s == """": print('YES') break elif s[-5:] == 'dream' or s[-5:] == 'erase': s = s[:-5] elif s[-6:] == 'erase': s = s[:-6] elif s[-7:] == 'dreamer': s = s[:-7] else: print('NO') break " p03854,s119326754,Wrong Answer,"s = input() for p in range(10): if s[-5:] == 'dream': s = s[:-5] elif s[-7:] == 'dreamer': s = s[:-7] elif s[-5:] == 'erase': s = s[:-5] elif s[-6:] == 'eraser': s = s[:-6] if s == '': break if s == '': print('YES') else: print('NO')" p03854,s794583094,Wrong Answer,"s = input() s = s.replace(""eraser"", """").replace(""dreamer"", """").replace(""erase"", """").replace(""dream"", """") print(""YES"") if s == """" else print(""NO"")" p03854,s106930950,Wrong Answer,"S = input() results = True while results: for key_word in (""erase"", ""eraser"", ""dream"", ""dreamer""): if S.endswith(key_word): S = S[:-len(key_word)] continue if S == '': print(""YES"") results = False break else: print(""NO"") results = False break" p03854,s755368473,Wrong Answer,"s = list(input()) dream = list(""dream"") dreamer = list(""dreamer"") erase = list(""erase"") eraser = list(""eraser"") s.reverse() dream.reverse() dreamer.reverse() erase.reverse() eraser.reverse() while s != []: if s[0:7] == dreamer: del s[0:] elif s[0:6] == eraser: del s[0:] elif s[0:5] == dream: del s[0:] elif s[0:5] == erase: del s[0:] else: print(""NO"") exit() print(""YES"") " p03854,s516503331,Wrong Answer,"S = input() Sr = S[::-1] token = ['dream', 'dreamer', 'erase', 'eraser'] tokenr = list(map(lambda x:x[::-1], token)) t = '' while(len(Sr)>0): notFound = True for w in tokenr: if w==Sr[:len(w)]: Sr = Sr[len(w):] t+=w notFound = False if notFound: break if Sr == '': print('Yes') else: print('No')" p03854,s608759411,Wrong Answer,"s = list(input()) s.reverse() while len(s) > 5: if s[:5] == list(""maerd""): del s[:5] continue if s[:7] == list(""remaerd""): del s[:7] continue if s[:5] == list(""esare""): del s[:5] continue if s[:6] == list(""resare""): del s[:6] continue break if s == []: print(""YES"") else: print(""NO"")" p03854,s854046156,Wrong Answer,"import re s = input() m = re.match(r""^(dream|dreamer|erase|eraser)+$"", s) print(""No"" if m is None else ""Yes"")" p03854,s573585204,Wrong Answer,"s = input() s = s.replace('dreamer','').replace('dream','').replace('eraser','').replace('erase','') print('YES' if s == '' else 'NO') " p03854,s716809227,Wrong Answer,"s = list(input()) n = len(s) temp = ['maerd', 'remaerd', 'esare', 'resare'] s.reverse() i = 0 while i < n: flag = False for t in temp: if s[:len(t)] == list(t): i += len(t) - 1 flag = True break if not flag: print(""NO"") exit() print(""YES"") " p03854,s822104247,Wrong Answer,"s = input() if ""dream""and ""dreamer"" and ""eraser"" and ""erase"" in s: print(""YES"") else: print(""NO"") " p03854,s442233647,Wrong Answer,"s = input() while s: if s[0:7] == 'dreamer': s = s[7:] continue elif s[0:6] == 'eraser': s = s[6:] continue elif s[0:5] in ('dream', 'erase'): s = s[5:] continue else: print('NO') exit(0) print('YES')" p03854,s751548762,Wrong Answer,"S = input() if S.replace(""dreamer"","""").replace(""dream"","""").replace(""eraser"","""").replace(""erase"",""""): print(""NO"") else: print(""YES"") " p03854,s539160904,Wrong Answer,"S = input()[::-1] word = ['dream','dreamer','erase','eraser'] for i in word: S = S.replace(i[::-1],'') print(S) if S == '':print('YES') else:print('NO')" p03854,s422792625,Wrong Answer,"s = input() import re output =""NO"" s = re.sub('dreameraser', '', s) s = re.sub('dreamerase', '', s) s = re.sub('dreamer', '', s) s = re.sub('eraser', '', s) s = re.sub('erase', '', s) if s == """": output = ""YES"" print(output) " p03854,s829936025,Wrong Answer,"def main(): s = input() dream = False erase = False while s: if s.startswith('dream'): s = s[5:] dream = True erase = False elif s.startswith('erase'): s = s[5:] dream = False erase = True elif s.startswith('er') and dream: s = s[2:] dream = False elif s.startswith('r') and erase: s = s[1:] erase = False else: return False return True if main(): print('Yes') else: print('No')" p03854,s575949896,Wrong Answer,"S = input()[::-1] string = list(map( lambda x: x[::-1], [ ""dream"", ""dreamer"", ""erase"", ""eraser"" ])) index = 0 while 1: for x in string: match = S.find(x, index) if match == -1: continue elif match > -1: index += len(x) if index == len(S): print(""YES"") exit()" p03854,s361815538,Wrong Answer,"S = input()[::-1] S = S.replace('dream'[::-1], '').replace('erase'[::-1], '').replace( 'eraser'[::-1], '').replace('dreamer'[::-1], '') if len(S) == 0: print('YES') else: print('NO') " p03854,s072720366,Wrong Answer,"S = input() while len(S) > 0: if S[-5::1] == 'dream' or S[-5::1] == 'erase': S = S[:-5:1] elif S[-6::1] == 'eraser': S = S[:-6:1] elif S[-7::1] == 'dreamer': S = S[:-7:1] else: print('No') break if len(S) == 0: print('Yes')" p03854,s019413969,Wrong Answer,"s = input() def solve(query): while 1: for frag in (""erase"", ""eraser"", ""dream"", ""dreamer""): if query.endswith(frag): query = query[:-len(frag)] break else: print(""NO"", query) break if not query: print(""YES"") break solve(s)" p03854,s613364675,Wrong Answer,"S = input()[::-1] word = ['dream'[::-1], 'dreamer'[::-1], 'erase'[::-1], 'eraser'[::-1]] judge = [True, True, True, True] while any(judge): for i in range(len(word)): if S[:len(word[i])] == word[i]: S = S[len(word[i]):] else: judge[i] = False if S == '': print('YES') exit() print('No')" p03854,s120232804,Wrong Answer,"s = input() A=["""",""dream"",""dreamer"",""erase"",""eraser""] flag=0 for a in range(0,5): for b in range(0,5): for c in range(0,5): for d in range(0,5): if a!=b or a!=c or a!=d or b!=c: T=A[a]+A[b]+A[c]+A[d] if s==T: flag=1 if flag==1: print(""Yes"") else: print(""No"")" p03854,s220649573,Wrong Answer,"import re; s = input(); print(""Yes"" if re.match(r'^(dream|dreamer|eraser|erase)*$', s) else ""NO"") " p03854,s576981388,Wrong Answer,"s = input() i = 0 while i < len(s): print(i) if s[i:i+11] == ""dreameraser"": i += 11 elif s[i:i+10] == ""dreamerase"": i += 10 elif s[i:i+5] == ""dream"" or s[i:i+5] == ""erase"": i += 5 elif s[i:i+6] ==""dreamer"" or s[i:i+6] == ""eraser"": i += 6 else: print(""NO"") exit() print(""YES"")" p03854,s986639877,Wrong Answer,"S = input() S = S[::-1] candidacies = [""dream"", ""dreamer"", ""erase"", ""eraser""] candidacies = [c[::-1] for c in candidacies] fi_flg = False while fi_flg is False: if S[:7] in candidacies: S = S[7:] elif S[:6] in candidacies: S = S[6:] elif S[:5] in candidacies: S = S[:5] else: fi_flg = True if len(S) == 0: print(""YES"") else: print(""NO"")" p03854,s210098625,Wrong Answer,"c = input().rstrip('\n') str1 = ""dreamer"" str2 = ""dream"" str3 = ""eraser"" str4 = ""erase"" count = 0 while(count < len(c)): if(c[count:count+len(str1)] == str1): count += len(str1) elif(c[count:count+len(str2)] == str2): count += len(str2) elif(c[count:count+len(str3)] == str3): count += len(str3) elif(c[count:count+len(str4)] == str4): count += len(str4) else: print(""NO"") exit() print(""YES"") " p03854,s944968767,Wrong Answer,"S=input() def solve(query): while 1: for frag in (""erase"",""eraser"",""dream"",""dreamer""): if query.endswith(frag): query=query[:-len(frag)] break else: print(""No"") break if not query: print(""Yes"") break solve(S)" p03854,s473983120,Wrong Answer,"s=input() s=s[::-1] #print(s[:5],s[:7]) for i in range(100000): if s[:5] == 'maerd' or s[:6] == 'esare': s = s[5:] if s[:6] == 'resare': s = s[6:] if s[:7] == 'remaerd': s = s[7:] #print(s) if len(s)==0: print('YES') else: print('NO')" p03854,s796321702,Wrong Answer,"S=input() for i in range(10000): if S[-7:]==""dreamer"": S=S[:-7] elif S[-6:]==""eraser"": S=S[:-6] elif S[-5:]==""dream"" or S[-5:]==""erase"": S=S[:-5] else: pass if S=="""": print(""YES"") break else: print(""NO"")" p03854,s263500990,Wrong Answer,"import re s = input() s = re.sub(""dreameraser"", """", s) s = re.sub(""dreamerase"", """", s) s = re.sub(""dreamer"", """", s) s = re.sub(""dream"", """", s) s = re.sub(""eraser"", """", s) s = re.sub(""erase"", """", s) if s == """": print(""YES"") else: print(""NO"")" p03854,s669748160,Wrong Answer,"s=input() while len(s)>7: if s[-5:]=='erase' or s[-5:]=='dream': s=s[:-5] elif s[-6:]=='eraser': s=s[-6:] elif s[-7:]=='dreamer': s=s[:-7] else: break if s=='' or s=='dreamer' or s=='eraser' or s=='erase' or s=='eraser': print('YES') else: print('NO') " p03854,s410149977,Wrong Answer,"li = input() list = ['dream','dreamer','erase','eraser'] flag = 'No' for x in list: for y in list: z = x + y if z == li: flag = 'YES' print(flag)" p03854,s244837947,Wrong Answer,"S = input() ls = {""dream"",""dreamer"",""erase"",""eraser""} now = """" for i in range(len(S)): now += S[i] if now in ls: if S[i] == ""e"": continue else: now = """" if now == """": print(""YES"") else: print(""NO"") " p03854,s649568935,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) " p03854,s348586804,Wrong Answer,"S = input() l = ['maerd','remaerd', 'esare', 'resare'] def test(S,l): tmpS = S while len(tmpS) > 0: if tmpS[::-1] in l: print('YES') return if tmpS[-1:-6:-1] in l: tmpS = tmpS[:-5] elif tmpS[-1:-7:-1] in l: tmpS = tmpS[:-6] else: print('NO') return #print('YES') #return test(S,l)" p03854,s979320409,Wrong Answer,"S=input() str_list=[""dream"",""dreamer"",""erase"",""eraser""] S_tmp="""" while True: S_tmp=S for str in str_list: S=S.replace(str,"""") #rstrip(str)はだめ if S_tmp==S: break if S=="""": print(""YES"") if S!="""": print(""NO"") " p03854,s669714368,Wrong Answer,"s=input()[::-1] words = {""dream"", ""dreamer"", ""erase"", ""eraser""} for i in words: print(i[::-1]) s = s.replace(i[::-1],'') print(""NO""if len(s)!=0else ""YES"") " p03854,s955854463,Wrong Answer,"def main(): S = input() while len(S)>=5: if len(S)>=7 and S[-7:]==""dreamer"": S = S[:-7] continue elif len(S)>=6 and S[-6:]==""eraser"": S = S[:-6] continue elif S[-5:]==""dream"" or S[-5:]==""erase"": S = S[:-5] continue else: break if len(S)==0: print('Yes') else: print('No') main()" p03854,s295007191,Wrong Answer,"import re S = input() s = re.sub(r""(dream)|(erase)|(dreamer)|(eraser)"", """", S) if len(s) == 0: print(""YES"") else: print(""NO"")" p03854,s996141705,Wrong Answer,"S = input() T = '' words = ['dream', 'dreamer', 'erase', 'eraser'] for i in range(len(words)): words[i] = words[i][::-1] for i in S[::-1]: T += i for q in words: if T == q: T = '' if T == '': print('Yes') else: print('No')" p03854,s665539156,Wrong Answer,"S=input() for i in range(10000): if S[-7:]==""dreamer"": S=S[:-7] elif S[-6:]==""eraser"": S=S[:-6] elif S[-5:]==""dream"" or S[-5:]==""erase"": S=S[:-5] else: pass if S==[]: print(""YES"") break else: print(""NO"")" p03854,s164334785,Wrong Answer,"a = input() b = a[::-1] i = 0 while i < len(b): if b[i:i+5] == ""esare"": i += 5 elif b[i:i+5] == ""maerd"": i += 5 elif b[i:i+6] == ""resare"": i += 6 elif b[i:i+7] == ""remaerd"": i += 7 else: ans = ""No"" break if i == len(b): ans = ""Yes"" else: ans = ""No"" print(ans)" p03854,s215511232,Wrong Answer,"s_init = input() s_list = list(reversed(s_init)) s = ''.join(s_list) t = """" words = [""maerd"", ""remaerd"", 'esare', 'resare'] s_list = list(s) t_list = list(t) while s != t: if len(s_list) < len(t_list): break elif t == 'gameover': break for word in words: if s.startswith(t + word): t = t + word break else: t = 'gameover' if s == t: print('YES') else: print('NO') "