problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p03639
s969600391
Wrong Answer
n = int(input()) al = list(map(int, input().split())) n_4, n_2, m = 0, 0, 0 for a in al: if a % 4 == 0: n_4 += 1 elif a == 2: n_2 += 1 else: m += 1 print('Yes' if n//2 - n_2//2 <= n_4 else 'No')
p03617
s489526893
Accepted
Q, H, S, D = list(map(int, input().split())) N = int(input()) calc = N//2 * min(8*Q, 4*H, 2*S, D) + (N%2) * min(4*Q, 2*H, S) print(calc)
p03617
s827089718
Accepted
import sys input = sys.stdin.readline MOD = 1000000007 Q,H,S,D = map(int,input().split()) N = int(input()) #1L min min_1L = min(min(4*Q,2*H),S) min_2L = min(D,2*min_1L) #num of 2L print(N//2*min_2L + N%2*min_1L)
p03250
s062419563
Accepted
args = input().split() args.sort(reverse=True) num1 = int(''.join(args[0:2])) num2 = int(''.join(args[2:3])) print(num1+num2)
p03416
s915592577
Accepted
A,B=map(int,input().split()) ans=0 for n in range(A,B+1): N=list(str(n)) if N[0]==N[4] and N[1]==N[3]: ans+=1 print(ans)
p03211
s650100603
Accepted
a=input() s=[] i=0 total=1000000 while True: s=100*int(a[i])+10*int(a[i+1])+int(a[i+2]) d=abs(s-753) if total>d: total=d i+=1 if i+2==len(a): print(total) break
p03254
s116423640
Accepted
N,x=map(int,input().split()) a=list(map(int,input().split())) temp=x ans=0 a.sort() i=-1 while True: i+=1 x-=a[i] if x<0: break ans+=1 if ans==N: break if sum(a)<temp: ans-=1 print(ans)
p02723
s236298927
Wrong Answer
s = input() if s[2]==s[3] or s[4]==s[5]: print("Yes") else: print("No")
p03427
s777915478
Wrong Answer
N = input() N_list = list(N) N = int(N) K = len(N_list) ans = int(N_list[0])+(K-1)*9 if N > ans: print(ans - 1) else: 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)
p03416
s587974378
Wrong Answer
a,b = map(int,input().split()) count = 0 for i in range(a,b+1): c = list(str(i)) L = len(c) if L%2 == 0: d = c[:int(L/2)] e = c[:int(L/2):-1] else: d = c[:int(L/2)] e = c[int(L/2)+1:] reversed(e) if d == e: count += 1 print(count)
p02731
s554807166
Wrong Answer
L = int(input()) x = int(L/3) if L%3 >= 1: y = int(L/3) + 1 else: y = int(L/3) if L%3 >= 2: h = int(L/3) + 1 else: h = int(L/3) print(x**3)
p03860
s423501877
Wrong Answer
s = input().split() print(s[0]+s[1]+s[2])
p02848
s421541324
Wrong Answer
n=int(input()) s=input() cnt=len(s) a='ABCDEFGHIJKLMNOPQRSTUVWXYZ' ans='' for i in range(cnt): ans=ans+a[(i+n)%26] print(ans)
p03962
s420749882
Wrong Answer
a, b, c= map(int, input().split()) if a==b==c: print(1) elif a==b: print(2) elif b==c: print(2) else: print(3)
p02785
s464001722
Wrong Answer
n,k = map(int, input().split()) H = list(map(int, input().split())) l = n-k sorted(H) if k >= n : print(0) else: print(sum(H[:l]))
p03017
s065435094
Accepted
n,a,b,c,d = map(int, input().split()) s = input() if '##' in s[a-1:c] or '##' in s[b-1:d]: print('No') else: if c<d: print('Yes') else: if '...' in s[b-2:d+1]: print('Yes') else: print('No')
p03557
s034785151
Wrong Answer
import bisect N = int(input()) A = list(map(int,input().split())) B = list(map(int,input().split())) C = list(map(int,input().split())) A.sort() B.sort() C.sort(reverse=True) #2分探索を用いる ans = 0 for i in B: a = bisect.bisect_left(A,i) b = bisect.bisect_left(C,i) ans += a*b print(ans)
p03680
s230395806
Wrong Answer
N = int(input()) a = [int(input()) for _ in range(N)] a = [s-1 for s in a] index = 0 count = 1 flag = False while(count <= N): index = a[index] count += 1 if a[index] == 1: flag = True break if (flag): print(count) else: print(-1)
p03239
s079502407
Accepted
N, T = map(int, input().split()) min_cost = 10**9 for i in range(N): c, t = map(int, input().split()) if t > T: continue else: min_cost = min(min_cost, c) if min_cost != 10**9: print(min_cost) else: print("TLE")
p03910
s476632041
Accepted
#!/usr/bin/env python3 import sys, math, itertools, collections, bisect input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') inf = float('inf') ;mod = 10**9+7 mans = inf ;ans = 0 ;count = 0 ;pro = 1 n = int(input()) now = n for i in range(1,n+1): if now == i: key = -1 top = i break elif now - i < 0: key = i - now top = i break else: now -= i for i in range(1,top+1): if i != key:print(i)
p03109
s042299647
Accepted
s = input() if int(s[:4]) <= 2019: if int(s[5:7]) == 4 and int(s[8:]) <= 30: print("Heisei") elif int(s[5:7]) < 4: print("Heisei") else: print("TBD") else: print("TBD")
p03624
s819582039
Wrong Answer
alphabet = [chr(ord('a') + i) for i in range(26)] s = list(input()) s = sorted(list(set(s))) if len(s) == 26: print("None") exit() for i in range(len(s)): if i == len(s) - 1: print(alphabet[i + 1]) exit() elif s[i] == alphabet[i]: pass else: print(alphabet[i]) exit()
p03030
s178828020
Accepted
n = int(input()) l = [] for i in range(n): x,y = map(str,input().split()) l.append((x,y, i)) L = [] for i in range(n): L.append((l[i][0], int(l[i][1]), l[i][2])) L.sort(key = lambda L:(L[0],-L[1])) for i in range(n): print(L[i][2] + 1)
p02602
s389500390
Accepted
#!python3 import sys iim = lambda: map(int, sys.stdin.readline().rstrip().split()) def resolve(): N, K = iim() *A, = iim() ans = [] for i in range(N-K): ans.append("Yes" if A[i] < A[i+K] else "No") print(*ans, sep="\n") if __name__ == "__main__": resolve()
p02577
s164718222
Accepted
N = input() nli = [] for i in range(len(N)): nli.append(N[i]) print("No" if sum(map(int, nli)) % 9 else "Yes")
p03075
s443912076
Wrong Answer
a=[] for i in range(5): a+=input() n=int(input()) count=0 for c in range(5): for i in range(c,5): z=abs(int(a[c])-int(a[i])) if z>n: count+=1 if count==0: print('Yay!') else: print(':(')
p02548
s046315476
Wrong Answer
def make_divisors(n): lower_divisors , upper_divisors = [], [] i = 1 while i*i <= n: if n % i == 0: lower_divisors.append(i) if i != n // i: upper_divisors.append(n//i) i += 1 return lower_divisors + upper_divisors[::-1] ans=0 n = int(input()) for i in range(1,n+1): d=make_divisors(i) ans+=-((-len(d))//2) print(ans)
p03705
s126377313
Accepted
n, a, b = map(int, input().split()) if a > b: print(0) elif n == 1 and a != b: print(0) else: minimum = a * (n-1) + b maximum = a + (n-1) * b print(maximum - minimum + 1)
p02711
s878682347
Accepted
K=str(input()) if (int(K[0])%7==0 and int(K[0])!=0 )or (int(K[1])%7==0 and int(K[1])!=0 ) or (int(K[2])%7==0 and int(K[2])!=0 ): print('Yes') else: print('No')
p02860
s254283728
Accepted
def main(): n = int(input()) s = input() if n % 2 == 0: if s[:n // 2] == s[n // 2:]: ans = "Yes" else: ans = "No" else: ans = "No" print(ans) if __name__ == "__main__": main()
p02607
s756247217
Accepted
n = int(input()) a = [int(i) for i in input().split()] cnt = 0 for i in range(n): if a[i]%2==1 and (i+1)%2==1: cnt +=1 print(cnt)
p02924
s372850987
Accepted
N=int(input()) print(N*(N-1)//2)
p02697
s972399084
Accepted
N,M=map(int, input().split()) d=set() a,b=1,N for _ in range(M): print(a,b) d.add(b-a) d.add(N-b+a) a+=1 b-=1 while b-a in d or N-b+a in d or b-a == N-b+a: b-=1
p02661
s008012308
Wrong Answer
n = int(input()) a = [0] * n; b = [0] * n for i in range(n): a[i],b[i] = map(int,input().split()) if n%2 != 0 : print(b[n//2] - a[n//2] + 1) exit(0) def m_r(c): return (c[n//2] + c[n//2 - 1]) z = m_r(b) - m_r(a) + 1 print(z)
p02633
s575647912
Wrong Answer
x=int(input()) print(360//x)
p02711
s130430850
Accepted
n = input() if '7' in n: print('Yes') else: print('No')
p02796
s464146217
Wrong Answer
import sys inputs = sys.stdin.readlines() n = int(inputs[0]) Y = [] for s in inputs[1:]: x, l = map(int, s.split()) Y.append((x-l+1, x+l-1)) Y.sort(key=lambda x: x[0]) cnt = 0 l0, r0 = Y[0] for i in range(1, n): l, r = Y[i] if r0 >= l: cnt += 1 if r0 > r: l0, r0 = l, r print(n-cnt)
p03243
s368148802
Accepted
N = int(input()) L = [111*i for i in range(1,10)] ans = 0 for l in L: if N <= l: ans = l break print(l)
p03013
s231144051
Wrong Answer
n, m = map(int, input().split()) a_lst = [] case = [0] * n for j in range(m): a = int(input()) a_lst.append(a) for k in range(n): if (k + 1) in a_lst: pass elif k == 0: case[k] = 1 elif k == 1: case[k] = case[k-1] + 1 else: case[k] = case[k-1] + case[k-2] print(case[-1])
p03206
s005346337
Accepted
url = "https://atcoder.jp//contests/abc115/tasks/abc115_a" def main(): c = 25 today = int(input()) print('Christmas' + ' Eve' * (c - today)) if __name__ == '__main__': main()
p02933
s374318379
Accepted
a,s=[(input()) for i in range(2)] if int(a)>=3200: print(s) else: print('red')
p02922
s973540731
Accepted
a,b=map(int,input().split()) if b==1: print(0) else: ans=1 bb=b-a while bb>0: bb=bb-(a-1) ans+=1 print(ans)
p03435
s313818468
Accepted
l = [list(map(int,input().split())) for i in range(3)] ans = 0 for i in l: ans += sum(i) print("Yes" if ans/3==(l[0][0]+l[1][1]+l[2][2]) else "No")
p03759
s965226783
Wrong Answer
a, b, c = list(map(int, input().split())) if b - a == c - a: print("YES") else: print("NO")
p03434
s032702813
Wrong Answer
N = int(input()) a = list(map(int, input().split())) print(max(a) - min(a))
p03251
s249437160
Accepted
n,m,x,y=map(int,input().split()) for i in [i for i in range(max(list(map(int,input().split())))+1,min(list(map(int,input().split())))+1)]: if x<i<=y: print('No War');break else: print('War')
p02547
s770702245
Accepted
n = int(input()) d = [list(map(int, input().split())) for _ in range(n)] cnt = 0 ans = 0 for d1, d2 in d: if d1 == d2: cnt += 1 if cnt >= 3: print('Yes') exit() else: cnt = 0 print('No')
p03419
s646116902
Accepted
N, M = map(int, input().split()) res = 0 if N*M==1: res = 1 elif N==1: res = (M-2) elif M==1: res = (N-2) else: res = (N-2)*(M-2) print(res)
p02706
s061957337
Accepted
N, M = map(int, input().split()) A = list(map(int, input().split())) print(N - sum(A) if N - sum(A) >= 0 else -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)
p02742
s627396166
Accepted
H, W = map(int, input().split()) if H==1 or W ==1: print(1) else: print(-(-(H*W)//2))
p02831
s954728375
Accepted
def gcd(x,y): if y==0: return x if x<y: x,y=y,x x,y=y,x%y return gcd(x,y) a,b=map(int,input().split()) print(a*b//gcd(a,b))
p03160
s933075384
Accepted
n=int(input()) h=list(map(int,input().split())) dp=[10**9]*n dp[0]=0 dp[1]=abs(h[1]-h[0]) for i in range(n-1): dp[i+1]=min(dp[i+1],dp[i]+abs(h[i+1]-h[i])) if i+2<n: dp[i+2]=min(dp[i+2],dp[i]+abs(h[i+2]-h[i])) print(dp[-1])
p02792
s956558419
Accepted
n = int (input ()) cnt = [[0 for i in range (10)] for i in range (10)] for i in range (1, n + 1) : p = int (str (i)[0]) q = i % 10 cnt[p][q] += 1 ans = 0 for i in range (1, 10) : for j in range (1, 10) : ans += cnt[i][j] * cnt[j][i] print (ans)
p03017
s780911681
Wrong Answer
N,A,B,C,D=list(map(int,input().split())) l=list(input()) if "##" in "".join(l[A-1:max(C,D)]): print("No") exit() if C>D: pass else: print("Yes") exit() if "..." in "".join(l[B-2:D+2]): print("Yes") else: print("No")
p02717
s638194001
Wrong Answer
X, Y, Z = map(int, input().split()) print(Z, Y, X)
p03317
s564679312
Wrong Answer
n, k = map(int, input().split()) a = list(map(int , input().split())) if n == k: print(1) exit() print((n + (n // k)) // (k-1))
p02861
s823663730
Wrong Answer
import math import itertools def distance(c1,c2): x1,y1 = c1 x2,y2 = c2 return math.sqrt((x1-x2)**2+(y1-y2)**2) N = int(input()) Cord = [] ls = list(itertools.permutations(range(N))) for _ in range(N): Cord.append(tuple(map(int,input().split()))) ans = 0 print(ls) for l in ls: for i in range(N-1): ans+=distance(Cord[l[i]],Cord[l[i+1]]) print(ans/len(ls))
p02547
s046845124
Accepted
N=int(input()) D=[map(int, input().split()) for i in range(N)] x, y = [list(i) for i in zip(*D)] s=0 l=[] for i in range(N): if x[i]==y[i]: s+=1 if i==N-1: l.append(s) elif x[i]!=y[i]: l.append(s) s=0 if max(l)>=3: print("Yes") else: print("No")
p03387
s367949338
Accepted
num = [int(i) for i in input().split()] sorted_num = sorted(num) if sorted_num[0] % 2 == sorted_num[1] % 2: count = sorted_num[2] - (sorted_num[0] + sorted_num[1])/2 elif sorted_num[0] % 2 != sorted_num[1] % 2: count = ((sorted_num[2] + 1) - (sorted_num[0] + sorted_num[1] + 1)/2) + 1 print(int(count))
p03665
s692474731
Wrong Answer
from math import factorial def combinations_count(n, r): return factorial(n) // (factorial(n - r) * factorial(r)) n,p = map(int,input().split()) a = list(map(int,input().split())) eve = 0 odd = 0 for i in range(n): if a[i]%2==0: eve += 1 else: odd += 1 eve_cb = 2**eve odd_cb = 0 for i in range(1,odd+1)[::2]: odd_cb += combinations_count(odd,i) print(eve_cb*odd_cb)
p03785
s180071400
Accepted
from collections import Counter N, C, K = map(int, input().split()) T = [int(input()) for _ in range(N)] T.sort() ans = 1 cnt = 0 # 最後にバスが出た時間 st = T[0] for t in T: cnt += 1 # バスが出てからK時間以上たつ or count が C を越した場合 if t - st > K or cnt > C: ans += 1 st = t cnt = 1 print(ans)
p03485
s797669947
Accepted
import math;a,b=map(int,input().split());print(math.ceil((a+b)/2))
p03986
s780576595
Accepted
#!/usr/bin/env python3 from collections import deque, Counter from heapq import heappop, heappush from bisect import bisect_right def main(): X = input() ans = 0 now = 0 for x in X: if x == 'S': now -= 1 else: now += 1 ans = max(ans,now) print(ans*2) if __name__ == "__main__": main()
p03437
s178219902
Accepted
x, y = map(int, input().split()) if x % y == 0: print(-1) else: print(x)
p02995
s328109193
Wrong Answer
A,B,C,D = map(int, input().split()) def calc(a,x): return int(a/x) print(B - A + 1 - (calc(B, C) - calc(A-1, C) + calc(B, D) - calc(A-1, D) - (calc(B, C*D) - calc(A-1, C*D))))
p02982
s218288466
Accepted
import math def gooddistance(l1, l2): calc = [] for i in range(len(l1)): calc.append((l1[i] - l2[i])**2) if math.sqrt(sum(calc)).is_integer(): return 1 else: return 0 N, D = map(int, input().split()) lis = [list(map(int, input().split())) for _ in range(N)] cnt = 0 for i in range(N): for j in range(i+1,N): cnt += gooddistance(lis[i],lis[j]) print(cnt)
p02622
s801157639
Accepted
import sys def LS2(): return list(sys.stdin.readline().rstrip()) #空白なし S = LS2() T = LS2() ans = 0 for i in range(len(S)): if S[i] != T[i]: ans += 1 print(ans)
p03261
s380149510
Accepted
n = int(input()) word_list = [] flag = True for i in range(n): word = input() if word_list == []: word_list.append(word) else: if (word_list[-1][-1] == word[0]) and (word not in word_list): word_list.append(word) else: flag = False break if flag: print('Yes') else: print('No')
p03815
s953677557
Accepted
x=int(input()) a=x%11 b=x//11 if a==0: ans=2*b elif a<=6: ans=2*b+1 elif 5<a<11: ans=2*b+2 print(ans)
p02866
s415259584
Accepted
n=int(input()) d=list(map(int,input().split())) num=[0]*n num[0]=1 if d[0]!=0 or d.count(0)!=1: print(0) else: ans=1 for i in range(1,n): num[d[i]]+=1 for i in range(1,max(d)+1): ans*=num[i-1]**num[i] ans%=998244353 print(ans)
p03163
s450573173
Accepted
N,W = map(int,input().split()) Value = [] weight = [] inf=float("inf") dp=[[-inf for i in range(W+1)] for j in range(N+1)] for i in range(W+1): dp[0][i]=0 for i in range(N): w,v = map(int,input().split()) Value.append(v) weight.append(w) for i in range(N): for w in range(W+1): if w>=weight[i]: dp[i+1][w] = max(dp[i][w-weight[i]]+Value[i],dp[i][w]) else: dp[i+1][w] = dp[i][w] print(dp[N][W])
p02753
s141553196
Accepted
S = list(input()) if len(set(S)) == 1: print ('No') else: print ('Yes')
p03407
s240329084
Accepted
a, b, c = map(int, input().split()) print('Yes' if a + b >= c else 'No')
p03221
s040119646
Wrong Answer
def compress(arr): *XS, = set(arr) XS.sort() return {e: i for i, e in enumerate(XS)} n,m=map(int,input().split()) s=[[] for i in range(n+1)] p=[0]*m y=[0]*m for i in range(m): p[i],y[i]=map(int,input().split()) s[p[i]].append(y[i]) for i in range(1,n+1): s[i]=compress(s[i]) for i in range(m): print("0"*(6-len(str(p[i]))),p[i],"0"*(6-len(str(s[p[i]][y[i]]))),s[p[i]][y[i]]+1,sep="")
p03862
s793263526
Accepted
n, x = map(int, input().split()) a = list(map(int, input().split())) res = 0 if a[0] > x: res += a[0] - x a[0] = x for i in range(n-1): if a[i] + a[i+1] > x: val = a[i] + a[i+1] - x res += val a[i+1] -= val print(res)
p03013
s038131189
Wrong Answer
n,m = map(int,input().split()) dp = [1]*(n+2) mod = 10**9 + 7 for i in range(m): a = int(input()) dp[a-1] = 0 for i in range(2,n+2): if dp[i] == 0: continue else: dp[i] = (dp[i-1] + dp[i-2])%mod print(dp[n-1])
p02879
s646593499
Accepted
a, b = input().split() if len(a) == 1 and len(b) == 1: a = int(a) b = int(b) print(a * b) else: print(-1)
p02612
s560852376
Wrong Answer
N = int(input()) print(1000-N%1000)
p02791
s829335362
Accepted
N = int(input()) P = [int(p) for p in input().split()] cur = float('inf') res = 0 for p in P: if p <= cur: res += 1 cur = min(cur, p) print(res)
p02873
s174643233
Accepted
S = input() A = [0]*(len(S)+1) for i in range(len(S)): if S[i] == "<": A[i+1] = A[i]+1 for i in range(len(S)-1, -1, -1): if S[i] == ">": A[i] = max(A[i], A[i+1]+1) print(sum(A))
p03339
s456255487
Wrong Answer
N = int(input()) S = str(input()) WtoE=0 EtoW=S[1:N+1].count('E') min_ans = WtoE + EtoW for i in range(1, N): if S[i-1] == 'W': WtoE += 1 if S[i-1] == 'E': EtoW -= 1 ans = WtoE + EtoW if min_ans > ans: min_ans = ans print(min_ans)
p02594
s430097303
Accepted
X=int(input()) if X>=30: print('Yes') else: print('No')
p02842
s489843919
Accepted
def main(): n = int(input()) p = n * 25 // 27 a, b = int(p * 1.08), int((p + 1) * 1.08) if a == n: print(p) elif b == n: print(p + 1) else: print(":(") if __name__ == "__main__": main()
p03696
s006496490
Wrong Answer
n = int(input()) s = input() tmp = [] ans = "" for i in s: if i == "(": tmp.append("(") else: if len(tmp) == 0: ans = "(" + ans + ")" else: ans += tmp.pop() + ")" print(ans + "".join(tmp) + ")" * len(tmp))
p02814
s696937972
Wrong Answer
import fractions from functools import reduce n,m = map(int,input().split()) a = list(map(int,input().split())) a = list(set(a)) l = 1 s = 0 h = [] ans = 0 for i in a: h.append(i//2) for j in range(m): for k in range(len(a)): if j-h[k]<0: break if (j-h[k])%a[k]: break if not (j-h[k])%a[k]: s = j break for x in a: l*=x r = l//reduce(fractions.gcd, a) ans = (m-s)//r if ans: ans+=1 print(ans)
p03427
s921841380
Accepted
import sys readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines read = sys.stdin.buffer.read sys.setrecursionlimit(10 ** 7) INF = float('inf') from functools import lru_cache def F(N): if N < 10: return N q, r = divmod(N, 10) x1 = F(q) + r x2 = F(q-1) + 9 return max(x1, x2) ans = F(int(input())) print(ans)
p02801
s170866172
Wrong Answer
c = input() ord_s = ord(c) chr_s = chr(ord_s) print(chr_s)
p02860
s325524070
Accepted
import sys input = sys.stdin.readline def main(): N = int(input()) S = input().rstrip() if N % 2 == 1: ans = "No" else: if S[:N // 2] == S[N // 2:]: ans = "Yes" else: ans = "No" print(ans) if __name__ == "__main__": main()
p02678
s744034723
Wrong Answer
#D n, m = list(map(int, input().split())) room = [[0 for _ in range(n)] for _ in range(n)] l = [list(map(int, input().split())) for _ in range(m)] for i, j in l: room[i-1][j-1] = 1 room[j-1][i-1] = 1 result = [0 for _ in range(n-1)] for i in range(n): for j in range(n): if result[j-1] == 0: if room[i][j] == 1: result[j-1] = i+1 room[j][i] = 0 print('Yes') [print(i) for i in result]
p02684
s117378229
Wrong Answer
import numpy as np N, K = map(int, input().split()) A = np.array([int(x) for x in input().split()]) B = np.zeros(N) C = np.zeros(N) pos = 0 for i in range(N*2): B[pos] += 1 if C[pos] == 0: C[pos] = i+1 pos = A[pos] - 1 ans = K - len(B[B <= 1]) ans %= len(B[B > 1]) D = sorted(C[B > 1]) tmp = D[ans] index = A[C == tmp] print(*index)
p03479
s983040545
Wrong Answer
import math x,y=map(int, input().split()) print(int(math.log(y/x,2))+1)
p02755
s083969309
Accepted
#!/usr/bin/env python3 import sys import math a, b = map(int, input().split()) c = math.ceil(b / 0.1) for i in range(c, c + 10): if math.floor(i * 0.1) == b: if math.floor(i * 0.08) == a: print(i) sys.exit() print(-1)
p03524
s164950198
Accepted
from collections import Counter s = input() a,b,c = s.count('a'),s.count('b'),s.count('c') if max(a,b,c)-min(a,b,c)<=1: print('YES') else: print('NO')
p02713
s720136965
Accepted
import math K = int(input()) ans = 0 for a in range(1,K+1): for b in range(1,K+1): for c in range(1,K+1): ans += math.gcd(a,math.gcd(b,c)) print(ans)
p02642
s476226545
Wrong Answer
import copy n = int(input()) a = [int(item) for item in input().split()] a.sort() b = copy.deepcopy(a) flag = [] num = [] for i in range(n): if i in flag: continue for j in range(i+1, n): if j in flag: continue if a[j] % a[i] == 0 and a[j] in b: flag.append(j) continue num.append(a[j]) print(len(num))
p03061
s514886900
Accepted
import fractions n = int(input()) a = list(map(int, input().split())) left = [0] * (n + 1) right = [0] * (n + 1) for i in range(n): left[i+1] = fractions.gcd(left[i], a[i]) right[n-i-1] = fractions.gcd(right[n-i], a[n-1-i]) ans = 0 for i in range(n): ans = max(ans, fractions.gcd(left[i], right[i+1])) print(ans)
p02695
s351335366
Accepted
n,m,q=map(int,input().split()) a=[] b=[] c=[] d=[] for i in range(q): ai,bi,ci,di=map(int,input().split()) a.append(ai) b.append(bi) c.append(ci) d.append(di) from itertools import combinations_with_replacement as cmb A=list(cmb(range(1,m+1),n)) #print(A) ans=0 for lst in A: sum=0 for i in range(q): if lst[b[i]-1]-lst[a[i]-1]==c[i]: sum+=d[i] ans=max(sum,ans) print(ans)
p02701
s632403222
Accepted
from collections import Counter n=int(input()) s=[] for i in range(n): s.append(input()) c = Counter(s) print(len(c))