problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02713
s496438594
Accepted
K = int(input()) import fractions A = {} sum = 0 for i in range(K): for j in range(K): if fractions.gcd(i+1,j+1) in A: A[fractions.gcd(i+1,j+1)] += 1 else: A[fractions.gcd(i+1,j+1)] = 1 for key in A: for i in range(K): sum += fractions.gcd(key,i+1)*A[key] print(sum)
p02918
s600517536
Accepted
N,K=map(int,input().split()) S=list(input()) ans=0 lr=0 rl=0 for i in range(N-1): if S[i]=="L": if S[i+1]=="R": lr=lr+1 else: ans=ans+1 else: if S[i+1]=="L": rl=rl+1 else: ans=ans+1 change=max(rl,lr) ans=ans+2*min(change,K) print(min(ans,N-1))
p02724
s865350114
Accepted
X = int(input()) y = X // 500 X = X % 500 y = 1000 * y + (X // 5) * 5 print(y)
p02726
s498115542
Accepted
from numba import njit @njit(cache=True) def solve(n,x,y): ans = [0] * (n - 1) for i in range(n): for j in range(n): c = min(abs(i - j), abs(i-x)+abs(j-y)+1,abs(i-y)+abs(j-x)+1) if c: ans[c-1] += 1 return ans n, x, y = map(int, input().split()) x -= 1 y -= 1 ans = solve(n,x,y) for ai in ans: print(ai//2)
p02917
s712917787
Accepted
n = int(input()) b = list(map(int, input().split())) ans = b[0] + b[n - 2] for i in range(1, n - 1): ans += min(b[i], b[i - 1]) print(ans)
p03286
s029848022
Accepted
n = int(input()) x = '' while n != 0: if n % (-2) == 0: n //= (-2) x = '0' + x else: n = (n - 1) // (-2) x = '1' + x print(x if x else 0)
p02775
s273330016
Accepted
x = list(map(int,list(input()))) n = len(x) dp = [[0,1] for _ in range(n+1)] for i in range(n): dp[i+1][0] = min(dp[i][0]+x[i],dp[i][1]+10-x[i]) dp[i+1][1] = min(dp[i][0]+x[i]+1,dp[i][1]+9-x[i]) print(dp[n][0])
p03543
s410586343
Wrong Answer
N = str(input()) N1 = set(N) if (len(N1) < 3) and N[1] == N[2]: print("Yes") else: print("No")
p02796
s234120946
Accepted
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines from operator import itemgetter # 区間スケジューリング N = int(readline()) m = map(int,read().split()) XL = zip(m,m) LR = [(x-l,x+l) for x,l in XL] LR.sort(key = itemgetter(1)) INF = 10 ** 18 prev_R = -INF cnt = 0 for L,R in LR: if prev_R > L: continue cnt += 1 prev_R = R print(cnt)
p03485
s146388267
Wrong Answer
a, b = (int(x) for x in input().split()) s = (a + b) % 2 t = (a + b) / 2 if s == 0: print(t) else: print(t + 0.5)
p03625
s259598120
Accepted
from collections import Counter as C _ = input() a = C([int(x) for x in input().split()]) b = [0, 0] for k, v in a.items(): b.extend([k] * (v // 2)) else: b.sort() print(b[-1] * b[-2])
p03639
s719957048
Accepted
n = int(input()) a = list(map(int,input().split())) kisuu = 0 guusuu = 0 baisuu_4 = 0 for num in a: if num%2 == 1: kisuu += 1 elif num%4 == 2: guusuu += 2 else: baisuu_4 += 1 if guusuu ==0: if baisuu_4 >= kisuu - 1: print('Yes') else: print('No') else: if baisuu_4 >= kisuu: print('Yes') else: print('No')
p03385
s690267801
Accepted
s=list(input()) s.sort() if s[0]=="a" and s[1]=="b" and s[2]=="c": print("Yes") else: print("No")
p03011
s950339870
Wrong Answer
P = 2 Q = 3 R = 4 list1 = [P+Q, P+R, Q+P, Q+R, R+P, R+Q] print(min(list1))
p02897
s981685623
Accepted
n=int(input()) if n%2==0: print(0.5) else: print((n//2+1)/n)
p03385
s644410507
Accepted
s=input() if s.count("a")==1 and s.count("b")==1 and s.count("c")==1: print("Yes") else: print("No")
p02675
s835942377
Accepted
N = int(input()) N = N % 10 if N == 3: print("bon") elif N == 0 or N == 1 or N == 6 or N == 8: print("pon") else: print("hon")
p02699
s179510978
Accepted
S,W = map(int,input().split()) if W >= S: print('unsafe') else: print('safe')
p02678
s085368854
Wrong Answer
n,m=map(int,input().split()) lst=[[] for i in range(n)] visited=[True]+[False]*(n-1) ans=[0]*n for i in range(m): a,b=map(int,input().split()) lst[a-1].append(b-1) lst[b-1].append(a-1) Q=[0] while Q: v=Q.pop(0) for i in lst[v]: if visited[i]==False: visited[i]=True ans[i]=v Q.append(v) print('Yes') for i in range(1,n): print(ans[i])
p02690
s012586808
Accepted
X = int( input() ) A = 0 B = 0 for i in range(-900, 900): for j in range( -900, 900 ): if i**5 - j ** 5 == X: A = i B = j print( A, B )
p03069
s226788846
Accepted
n = int(input()) s = input() # 左側の黒の個数, 右側の白の個数 b, w = 0, s.count('.') ans = min(s.count('#'), w) for i in range(n): if s[i] == '#': b += 1 elif s[i] == '.': w -= 1 ans = min(ans, b+w) print(ans)
p02761
s679446700
Accepted
n, m = map(int, input().split()) sc = [list(map(int, input().split())) for _ in range(m)] ans = [-1 for _ in range(n)] for sci in sc: if ans[sci[0]-1] == -1: ans[sci[0]-1] = sci[1] elif ans[sci[0]-1] != sci[1]: print(-1) exit(0) if ans[0] == 0 and n != 1: print(-1) exit(0) ansint = 0 for i, a in enumerate(ans): ansint *= 10 if a == -1: if i == 0 and n != 1: ans[i] = 1 else: ans[i] = 0 ansint += ans[i] print(ansint)
p03455
s030430215
Accepted
a, b = list(map(int, input().split(' '))) v = a * b print("Even" if v % 2 == 0 else "Odd")
p02572
s804484821
Wrong Answer
n= int(input()) lst = [int(i) for i in input().split()] lst = sorted(lst) count = 0 d_lst = [] for i in range(len(lst)-1): if lst[i] not in d_lst: if lst[i] == lst[i+1]: d_lst.append(lst[i]) for d in d_lst: count += d**2 lst = list(set(lst)) for i in range(len(lst)-1): for j in range(i+1,len(lst)): a = lst[i] * lst[j] count += a if count > ( 10**9 + 7 ): print(count % (10**9 + 7)) else: print(count)
p02595
s217917464
Accepted
n, d = map(int, input().split()) cnt = 0 for ti in range(n) : x, y = map(int, input().split()) dist = (x**2 + y**2)**0.5 if(dist <= d): cnt += 1 print(cnt)
p03076
s932125556
Accepted
l = [int(input()) for i in range(5)] L = [] for i in l: if i%10==0: L.append(0) else: L.append(10-i%10) print(sum(l)+sum(L)-max(L))
p03796
s487020729
Wrong Answer
n=int(input()) p=1 for i in range(1,n+1): p=p*i%(10^9+7) print(p)
p03943
s237162498
Accepted
a, b, c = map(int, input().split()) if a+b-c==0 or b+c-a==0 or c+a-b==0: print('Yes') else: print('No')
p02583
s180974911
Accepted
N=int(input()) L=list(map(int,input().split())) if N<=2: print(0) else: ans=0 for i in range(N-2): for j in range(i+1,N-1): for k in range(j+1,N): if L[i] !=L[j] and L[i]!=L[k] and L[j]!=L[k]: ma=max(L[i],L[j],L[k]) mi=min(L[i],L[j],L[k]) nu=L[i]+L[j]+L[k]-ma-mi if ma<mi+nu: ans+=1 print(ans)
p03632
s451781623
Accepted
x = list(map(int, input().split())) imos = [0]*(max(x) + 2) imos[x[0]] += 1 imos[x[1]+1] -= 1 imos[x[2]] += 1 imos[x[3]+1] -= 1 for i in range(len(imos)-1): imos[i+1] += imos[i] print(max(imos.count(2) - 1, 0))
p02732
s979428720
Accepted
import collections N = int(input()) A = list(map(int,input().split())) dic = collections.Counter(A) def helper(n): return n*(n-1)//2 ans = 0 for i in dic.keys(): ans += helper(dic[i]) for i in A: print(ans-dic[i]+1)
p03695
s604767554
Accepted
n = int(input()) a = [int(i)//400 for i in input().split()] s = set() f = 0 for i in a: if i>=8: f += 1 else: s.add(i) mn = len(s) if len(s)==0: mn += f>0 mx = len(s)+f print(mn, mx)
p02665
s735616451
Accepted
N = int(input()) A = list(map(int, input().split())) isOK = True B = [0]*(N+1) B[0] = 1-A[0] M = 1 i = 1 while i <= N: B[i] = B[i-1]*2-A[i] i += 1 if B[-1] < 0 or N > 0 and A[-1] == 0: isOK = False B[-1] = A[-1] i = N-1 while i >= 0: if B[i] < 1 or i > 0 and B[i] > B[i-1]*2: isOK = False break else: B[i] = min(B[i], B[i+1])+A[i] i -= 1 print(-1 if not isOK else sum(B))
p03385
s727255643
Wrong Answer
S=input() print("Yes" if len(S)==3 else "No")
p02900
s314375053
Wrong Answer
m, n = map(int, input().split()) while True: if m < n: m, n = n, m if m%n: m, n = n, m%n else: break def divisors(m): divisors = [1] for i in range(2, int(m**0.5)+2): if m % i == 0: divisors.append(i) while m % i == 0: m //= i if m == 1: break return divisors print(len(divisors(n)))
p02777
s175160915
Accepted
S, T = input().split() A, B = map(int, input().split()) U = input() if U == S: A -= 1 else: B -= 1 print(f'{A} {B}')
p02572
s267915751
Wrong Answer
import numpy as np MOD = 10 ** 9 + 7 n=int(input()) #3 alst=list(map(int,input().split())) #[1,2,3] # 累積和を求める # 例 # [1,2,3,4,5,6]の時、累積和は、 # [0,1,3,6,10,15,21] s=[0] s=list(np.cumsum(alst)) sum=0 for i in range(len(alst)-1): sum+=alst[i]*(s[len(s)-1]-s[i]) print(sum%MOD)
p02676
s797660683
Accepted
import sys INF = 1 << 60 MOD = 10**9 + 7 # 998244353 sys.setrecursionlimit(2147483647) input = lambda:sys.stdin.readline().rstrip() def resolve(): k = int(input()) S = input() if len(S) <= k: print(S) else: print(S[:k] + "...") resolve()
p03387
s039488581
Accepted
from sys import stdin def main(): #入力 readline=stdin.readline a,b,c=map(int,readline().split()) li=[a,b,c] li.sort() x=li[0] y=li[1] z=li[2] cnt=0 cnt+=z-y x+=z-y y+=z-y if (z-x)%2==0: cnt+=(z-x)//2 else: cnt+=(z-x+1)//2+1 print(cnt) if __name__=="__main__": main()
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')
p03211
s762608634
Accepted
S = input() x = 753 ans = float('inf') for i in range(len(S) - 2): y = int(S[i : i + 3]) ans = min(ans, abs(x - y)) print(ans)
p03038
s715887038
Accepted
n, m = map(int, input().split()) cards = sorted(list(map(int, input().split()))) changer = [] for i in range(m): p, c = map(int, input().split()) changer.append((p, c)) changer.sort(key=lambda x: x[1]) cur = 0 while len(changer) and cur < n: p, c = changer.pop() i = cur while i < n and i < cur + p: if cards[i] < c: cards[i] = c else: break i += 1 cur = i print(sum(cards))
p02677
s079278335
Wrong Answer
import numpy as np A,B,H,M = (int(x) for x in input().split()) argA = 30*H + 0.5*M argB = 6*M if argA>argB: arg = argA-argB else: arg = argB-argA if arg > 180: arg -= 180 cc = A**2 + B**2 -2*A*B*np.cos((arg/180)*np.pi) c = np.sqrt(cc) print(c)
p03435
s129122826
Wrong Answer
import itertools C = [] s = 0 for _ in range(3): c = list(map(int, input().split())) s += sum(c) C.append(c) if s % 3 == 0: print("Yes") else: print("No")
p03309
s019339988
Accepted
import statistics n=int(input()) alist=list(map(int, input().split())) blist=[] for i in range(n): blist.append(alist[i]-i-1) blist.sort() median=statistics.median_high(blist) ans=0 for i in range(n): ans+=abs(blist[i]-median) print(ans)
p03681
s354206788
Wrong Answer
MOD = 10**9 + 7 def fact(n, MOD): res = 1 for i in range(1, n + 1): res *= i res %= MOD return res N, M = map(int, input().split()) ans = 1 if abs(N - M) < 2: ans *= fact(N, MOD) * fact(M, MOD) % MOD if N == M: ans *= 2 ans %= MOD print(ans)
p03944
s080764663
Accepted
W,H,N=map(int,input().split()) x_right=W x_left=0 y_ceil=H y_floor=0 for i in range(N): x,y,a=map(int,input().split()) if a==1: x_left=max(x,x_left) elif a==2: x_right=min(x,x_right) elif a==3: y_floor=max(y,y_floor) else: y_ceil=min(y,y_ceil) ans=(x_right-x_left)*(y_ceil-y_floor) if x_left>=x_right or y_ceil<=y_floor: ans=0 print(ans)
p03264
s458085605
Accepted
k = int(input()) print((k // 2) ** 2) if k % 2 == 0 else print(((k // 2) + 1) * (k // 2))
p03494
s420263576
Accepted
n = int(input()) a = list(map(int, input().split())) count = 0 while True: for i in range(n): if a[i]%2 == 0: a[i] = a[i]//2 else: print(count) exit() count += 1 print(count)
p03680
s047309621
Accepted
n = int(input()) a = list() for _ in range(n): a.append(int(input())-1) g = 0 cnt = 1 while cnt <= n: g = a[g] if g == 1: print(cnt) exit() cnt += 1 print(-1)
p04033
s051938972
Wrong Answer
a, b=map(int,input().split()) if (a < 0 and 0 < b) or (a == 0 or b ==0): print("Zero") exit() elif 0 < a: print("Positive") exit() m = abs(a) if m % 2 == 0: print("Positive") else: print("Negative")
p03835
s142761101
Accepted
K, S = map(int, input().split()) count = 0 for i in range(K + 1): for j in range(K + 1): if 0 <= S - i - j <= K: count += 1 print(count)
p02729
s459297532
Wrong Answer
n,m=map(int,input().split()) print(n*(n-1)/2+m*(m-1)/2)
p02935
s074469530
Accepted
n = int(input()) v = list(map(int,input().split())) v.sort() ans = v[0] for i in range(1,n): ans = (ans+v[i])/2 print(ans)
p02631
s613469685
Accepted
N = int(input()) A = list(map(int, input().split())) b = 0 for x in A: b ^= x for i in range(len(A)): A[i] ^= b print(*A)
p03745
s132343888
Accepted
n = int(input()) a = list(map(int, input().split())) flag = 0 ans = 1 for i in range(n - 1): if flag == 1: if a[i] > a[i + 1]: ans += 1 flag = 0 elif flag == -1: if a[i] < a[i + 1]: ans += 1 flag = 0 else: if a[i] > a[i + 1]: flag = -1 elif a[i] < a[i + 1]: flag = 1 print(ans)
p03449
s834666729
Wrong Answer
n=int(input()) a=list(map(int,input().split())) b=list(map(int,input().split())) x=sum(a)-a[0] y=sum(b)-b[n-1] ans=a[0] flag=0 for i in range(n-1): if x>y: ans+=a[i+1] x-=a[i+1] y-=b[i] else: ans+=y break print(ans+b[n-1])
p03543
s260453489
Wrong Answer
s = input() if (s[0]==s[1] and s[1]==s[2]) and (s[1]==s[2] and s[2]==s[3]): print("Yes") else: print("No")
p03416
s363271290
Accepted
a, b = [int(x) for x in input().split()] print(sum([1 for i in range(a, b + 1) if i == int(str(i)[::-1])]))
p03998
s319897183
Wrong Answer
sa = input() sb = input() sc = input() S = [sa, sb, sc] d = {'a':0, 'b':1, 'c':2} sidx = [0, 0, 0] # 次の人 nxt = S[0][0] sidx[d[nxt]] += 1 while True: try: nxt = S[d[nxt]][sidx[d[nxt]]] sidx[d[nxt]] += 1 except: print(nxt.upper()) break
p03131
s842546542
Wrong Answer
k,a,b = map(int,input().split()) dif = b-a if b<=2: print(k+1) else: ans = a k -= (a-1) ans += dif*(k//2) ans += (k%2==1) print(ans)
p02766
s944989686
Accepted
N,K=map(int,input().split()) hey=N ans=1 while hey >= K: ans += 1 hey = hey//K print(ans)
p03041
s550883870
Wrong Answer
n,k=map(int,input().split()) s=list(input()) s[k-1]=s[k-1].lower() print(s)
p02760
s362044034
Wrong Answer
def check(A): for i in range(3): if A[0][i] == 0 and A[1][i] == 0 and A[2][i] == 0: return 1 elif A[i][0] == 0 and A[i][1] == 0 and A[i][2] == 0: return 1 elif A[0][0] == 0 and A[1][1] == 0 and A[2][2] == 0: return 1 return 0 A = [list(map(int, input().split())) for _ in range(3)] n = int(input()) b = [int(input()) for _ in range(n)] for i in range(3): for j in range(3): if A[i][j] in b: A[i][j] = 0 if check(A): print('Yes') else: print('No')
p02879
s692030439
Wrong Answer
A, B = map(int, input().split()) print(A*B)
p03281
s479343533
Wrong Answer
N = int(input()) if N >= 189: print(3) elif N >= 135: print(2) elif N >= 105: print(1) else: print(0)
p02660
s575322084
Accepted
n = int(input()) d = [] x = 2 while n > 1 and x <= 1000000: t = 0 while n % x == 0: t += 1 n //= x if t > 0: d.append(t) x += 1 if n > 1: d.append(1) def f(t): l, r = 0, t + 3 while r - l > 1: c = (r + l) // 2 if c * (c + 1) // 2 > t: r = c else: l = c return l print(sum(f(ti) for ti in d))
p04029
s604336427
Accepted
N = int(input()) ans = 0 for i in range(1, N + 1): ans += i print(ans)
p03797
s196216620
Wrong Answer
n, m = map(int, input().split()) ans = 0 if n > m * 2: ans = m//2 else: ans = n + (m-n*2)//4 print(ans)
p03377
s154152054
Accepted
n,m,k = map(int,input().split()) print('YES' if n <= k <= n+m else 'NO')
p03219
s211713278
Accepted
X, Y = map(int, input().split()) print(X+Y//2)
p02847
s924869219
Accepted
S = input() if S == ('SUN'): print(7) elif S == ('MON'): print(6) elif S == ('TUE'): print(5) elif S == ('WED'): print(4) elif S == ('THU'): print(3) elif S == ('FRI'): print(2) elif S == ('SAT'): print(1) else: print('入力に誤りがあります。SUN,MON,TUE,WED,THU,FRI,SATのいずれかを入力してください。')
p03041
s181693527
Wrong Answer
N,K=map(int,input().split()) S=str(input()) print(S.replace(S[K-1],str.lower(S[K-1])))
p02688
s219337540
Wrong Answer
n,k = map(int, input().split()) L = [list(map(int, input().split())) for i in range(2*k)] A = [] for i in range(k-1): A = A + L[2*i + 1] ans = 0 for i in range(n): if i+1 not in A: ans += 1 print(ans)
p02694
s128145306
Accepted
import math x = int(input()) money = 100 year = 0 while money < x: money = math.floor(money*1.01) year += 1 print(year)
p02917
s883142162
Accepted
N = int(input()) B = list(map(int,input().split())) A = [0]*N A[0] = B[0] A[N-1] = B[N-2] for i in range(N-2): if B[i] <= B[i+1]: A[i+1] = B[i] else: A[i+1] = B[i+1] print(sum(A))
p03680
s831803354
Accepted
n = int(input()) a = [int(input()) for i in range(n)] check = [0 for i in range(n)] check[0] = 1 i = 0 cnt = 0 while True: cnt += 1 x = a[i] if x-1 == 1: print (cnt) exit() if check[x-1] == 1: print(-1) exit() else: check[x-1] = 1 i = x-1
p02811
s174109406
Accepted
k, x = map(int, input().split()) if(k*500 >= x): print('Yes') else: print('No')
p03086
s333627844
Accepted
s = input() str_max = "" int_max = 0 str_temp = "" int_temp = 0 for i in s: if i == "A"or i == "C"or i == "G"or i == "T": str_temp += i int_temp += 1 # print("OK", i) else: str_temp = "" int_temp = 0 # print("NG", i) if int_max < int_temp: int_max = int_temp str_max = str_temp print(int_max)
p03137
s419913140
Accepted
n, m = map(int, input().split()) x = list(map(int, input().split())) x.sort() d = [] for i in range(m-1): d.append(x[i+1] - x[i]) d.sort(reverse=True) # print(d) print(sum(d[n-1:]))
p02678
s728193478
Accepted
N, M = map(int,input().split()) AB = [list(map(int, input().split())) for _ in range(M)] prev = [0] * N to_list = [ [] for _ in range(N)] for a,b in AB: to_list[a - 1].append(b - 1) to_list[b - 1].append(a - 1) marked = {0} que = [0] for i in que: for j in to_list[i]: if j in marked: continue que.append(j) marked.add(j) prev[j] = i+1 print('Yes') print(*prev[1:], sep='\n')
p02912
s807818995
Accepted
import queue def m(): N, M = map(int, input().split()) q = queue.PriorityQueue() A = list(map(int, input().split())) ans = [] for a in A: q.put(-a) while M > 0: x = -q.get() x = -(x >> 1) M -= 1 q.put(x) while not q.empty(): ans.append(q.get()) return abs(sum(ans)) print(m())
p02953
s055122684
Accepted
n=int(input()) h=list(map(int,input().split())) for i in range(n-1,1,-1): if 2<=h[i-1]-h[i]: print("No") exit() elif 1==h[i-1]-h[i]: h[i-1]-=1 print("Yes")
p03994
s822818511
Accepted
s = input() K = int(input()) ans = '' for i, c in enumerate(s): dif = ord('z') - ord(c) + 1 dif %= 26 if i == len(s) - 1: K %= 26 if ord(c) + K > ord('z'): K -= 26 ans += chr(ord(c) + K) elif dif <= K: ans += 'a' K -= dif else: ans += c print(ans)
p02767
s221677808
Accepted
n = int(input()) X = list(map(int, input().split())) for p in range(101): sum = 0 for x in X: sum += ((x - p)**2) if p == 0: ans = sum if ans > sum: ans = sum 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()
p02912
s003218357
Wrong Answer
# D - Powerful Discount Tickets import heapq N, M = map(int, input().split()) A = [int(a) * -1 for a in input().split()] heapq.heapify(A) for i in range(M): price = heapq.heappop(A) // 2 heapq.heappush(A, price) print(sum(A) * -1)
p03416
s056153570
Accepted
#!/usr/bin/env python3 a, b = map(int, input().split()) c = 0 for i in range(a, b + 1): if str(i) == str(i)[::-1]: c += 1 print(c)
p03417
s945101212
Wrong Answer
n, m = map(int, input().split()) if n <= 2 and m <= 2: print(0) else: n -= 2 m -= 2 if n <= 0: n = 1 if m <= 0: m = 1 print(n*m)
p02879
s634215489
Accepted
A,B = map(int,input().split()) if A <= 9 and B <= 9: print(A * B) else: print(-1)
p02833
s381251936
Wrong Answer
n = int(input()) if n % 2 == 1: print("0") else: m = int(n/2) count = 0 i = 1 while m >= 5 ** i: count += (m // (5 ** i)) i += 1 print(int(count))
p03457
s867545400
Accepted
N=int(input()) txy=[list(map(int,input().split()))for _ in range(N)] ans='Yes' now=[0,0,0] for t,x,y in txy: distance=abs(x-now[1])+abs(y-now[2]) if distance>t-now[0] or (distance+(t-now[0]))%2>0: ans='No' break else: now=[t,x,y] print(ans)
p02948
s208114385
Accepted
import heapq N, M = map(int, input().split()) value = [[] for _ in range(10 ** 5 + 1)] for _ in range(N): a, b = map(int, input().split()) value[a].append(-1 * b) koho = value[1] heapq.heapify(koho) ans = 0 for i in range(1, M + 1): if len(koho) > 0: ans += -1 * heapq.heappop(koho) if i < M: for v in value[i + 1]: heapq.heappush(koho, v) print(ans)
p03103
s671363479
Wrong Answer
n, m = map(int, input().split()) l = [list(map(int, input().split())) for i in range(n)] ll = sorted(l) count, total, i = 0, 0, 0 while count < m: count += ll[i][1] total += ll[i][0]*ll[i][1] i += 1 if i == n: total += ll[i-1][0]*(m-count) print(total) exit() total += ll[i][0]*(m-count) print(total)
p03481
s603746498
Accepted
import math from decimal import * X, Y = [int(x) for x in input().split()] X = Decimal(str(X)) Y = Decimal(str(Y)) i = 1 cnt = 0 while True: if i > Decimal(Y/X): break i *= 2 cnt += 1 print(cnt)
p02838
s724627939
Wrong Answer
n=int(input()) a=list(map(int,input().split())) mod=10**9+7 ans=0 for i in range(60): x=1<<(i+1) z=o=0 for j in range(n): if a[j]&x:o+=1 else:z+=1 ans=(ans+((x%mod)*o*z)%mod)%mod print(ans)
p03012
s374972997
Accepted
N=int(input()) W=list(map(int,input().split())) min=-1 for T in range(N): S1=0 for i in range(T): S1=S1+W[i] S2=sum(W)-S1 temp=abs(S2-S1) if(min==-1): min=temp elif(temp<min): min=temp print(min)
p02847
s639252881
Wrong Answer
S = input() arr =['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT'] print(arr[arr.index(S)])
p02724
s110944942
Accepted
x = int(input()) n = x//500 x -= 500*n m = x//5 print(1000*n+5*m)
p03627
s413596808
Accepted
from collections import Counter def solve(): N = int(input()) A = list(map(int, input().split())) c = Counter(A) B = [k for k,v in c.items() if v>=2] C = [k for k,v in c.items() if v>=4] B.extend(C) B.sort(reverse=True) if len(B)<2: return 0 ans = B[0]*B[1] return ans print(solve())