problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p03061
s476593682
Accepted
import fractions n = int(input()) a = list(map(int,input().split())) m = [] l = [0] r = [0] for i in range(n): l.append(fractions.gcd(l[i],a[i])) r.append(fractions.gcd(r[i],a[-i-1])) r.reverse() for i in range(n): m.append(fractions.gcd(l[i],r[i+1])) print(max(m))
p02731
s844075868
Accepted
l = int(input()) l = l/3 print(l**3)
p02730
s639550780
Accepted
s = input() n = len(s) sl = s[:n//2] sr = s[n//2+1:] if sl == sr and sr == sr[::-1]: print('Yes') else: print('No')
p03639
s789399369
Wrong Answer
N = int(input()) a = list(map(int,input().split())) zero,one,two = 0,0,0 for i in a: if i%4 == 0: two += 1 elif i%2 == 0: one += 1 else: zero += 1 if one == 1: print("Yes" if two+(two) >= zero+1 else "No") exit() print("Yes" if two+(two) >= zero else "No")
p02697
s921509889
Wrong Answer
n,m=map(int,input().split()) for i in range(m): print(1+i, n-i)
p03379
s283413924
Accepted
import copy a = int(input()) l = list(map(int, input().split())) l2 = sorted(copy.deepcopy(l)) #print(l2) for i in l: if i < l2[a//2]: print(l2[a//2]) else: print(l2[a//2 - 1])
p02720
s983857137
Wrong Answer
K=int(input()) n=1 c=0 while 1: j=True n_str=str(n) for i in range(len(n_str)-1): if abs(int(n_str[i]) - int(n_str[i+1])) > 1: j=False if j: c+=1 if c==K: print(n) break if len(n_str) > 1 and abs(int(n_str[0]) - int(n_str[1])) > 1: n = (int(str(int(n_str[0])+1)+str(int(n_str[0]))))*(10**(len(n_str)-2)) else: n+=1
p03838
s311907147
Accepted
x,y = map(int,input().split()) res = 10**12 #0,0 if x<=y: res = min(res, y-x) #0,1 if x <= -y: res = min(res, -y-x+1) #1,0 if -x<=y: res = min(res, y+x+1) #1,1 if -x <= -y: res = min(res, -y+x+2) print(res)
p02996
s899491872
Wrong Answer
def main(): n = int(input()) absl = [] for _ in range(n): a, b = map(int, input().split()) s = b-a absl.append([a,b,s]) absl.sort(key=lambda x:x[2]) # print(absl) curr_time = 0 for curr_abs in absl: a,b,s = curr_abs curr_time += a if curr_time > b: print('No') return print('Yes') if __name__ == "__main__": main()
p02797
s619395671
Wrong Answer
n,k,s=map(int,input().split()) print(s,end=" ") for i in range(k-1): print(0,end=" ") if s==10**9: for i in range(n-k): print(1,end=" ") else: for i in range(n-k): print(1000000000,end=" ")
p02607
s895879217
Accepted
N = int(input()) A = list(map(int,input().split())) O = [i for i in range(N) if(i%2==0 and A[i]%2==1)] print(len(O))
p02707
s915625141
Accepted
import collections n = int(input()) a = list(map(int, input().split())) c = collections.Counter(a) for i in range(1, n+1): if c[i]: print(c[i]) else: print(0)
p03455
s418280509
Wrong Answer
a,b = map(int, input().split()) if(a % 2 == 0 and b % 2 == 0): print("Even") else: print("Odd")
p02691
s501162295
Wrong Answer
n = int(input()) a = tuple(map(int, input().split())) i = 0 ans = 0 while i < n-1: j = a[i] + 1 t = 1 while j<n: if t == a[i] + a[j]: ans += 1 j += 1 t += 1 i += 1 print(ans)
p03681
s958326390
Accepted
mod = int(1e9+7) n,m = map(int,input().split()) if abs(n-m) > 1: print(0) exit() if n != m: ans = 1 ans2 = 1 for i in range(1, m+1): ans *= i ans %= mod for i in range(1,n+1): ans2 *= i ans2 %= mod print(ans*ans2%mod) else: ans = 1 for i in range(1, n+1): ans *= i ans %= mod print(ans*ans*2%mod)
p03548
s602998287
Accepted
a, b, c = map(int, input().split()) print((a-c)//(b+c))
p02820
s393928862
Accepted
n = list(map(int,input().split())) scores = list(map(int,input().split())) cards = input() cards = list(cards) ans = 0 for i in range(n[0]): if i < n[1] or cards[i-n[1]] != cards[i]: if cards[i] == 'r': ans += scores[2] elif cards[i] == 's': ans += scores[0] else: ans += scores[1] else: cards[i] = 'k' print(ans)
p02693
s753642665
Accepted
K = int(input()) A, B = map(int, input().split(" ")) if B // K > (A-1) // K: print("OK") else: print("NG")
p04011
s271496299
Accepted
n,k,x,y = [int(input()) for i in range(4)] print(x*min(k,n)+y*max(0,n-k))
p02628
s693770847
Accepted
data = input().rstrip().split(" ") data2 = input().rstrip().split(" ") price = [] for i in data2: price.append(int(i)) price.sort() ans = 0 for i in range(int(data[1])): ans += price[i] print(ans)
p03803
s726092158
Wrong Answer
s = [i for i in range(2,14)] + [1] a, b = map(int, input().split()) print('Alice' if s.index(a)>s.index(b) else 'Bob')
p02859
s415989779
Accepted
r = int(input()) print(r ** 2)
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')
p04005
s711166505
Wrong Answer
a,b,c=map(int,input().split()) if max(a,b,c)==a and a%2==0: print(0) elif max(a,b,c)==a and a%2==1: print(b*c) elif max(a,b,c)==b and b%2==0: print(0) elif max(a,b,c)==a and b%2==1: print(a*c) elif max(a,b,c)==c and c%2==1: print(b*a) elif max(a,b,c)==c and c%2==0: print(0)
p02731
s240613001
Wrong Answer
S = int(input()) a = S//3 b = a * 0.8 c = a * 1.2 ans = a * b * c ans = ans * (1/0.96) print("{0:.6f}".format(ans))
p02701
s584393754
Accepted
n = int(input()) s = set() for _ in range(n): s.add(input()) print(len(s))
p03481
s051386834
Accepted
# -*- coding: utf-8 -*- dx = [0, 0, 1, -1, 1, -1, -1, 1] dy = [1, -1, 0, 0, 1, -1, 1, -1] x, y = map(int,input().split()) ans = [x] while ans[-1] < y: ans.append(ans[-1] * 2) #print(ans) if ans[-1] > y: print(len(ans) - 1) else: print(len(ans))
p04043
s482300553
Accepted
S = list(map(int, input().split())) if S.count(5) == 2 and S.count(7): print("YES") else: print("NO")
p02900
s839357547
Accepted
from fractions import gcd A, B = map(int, input().split()) def prime_decomposition(n): i = 2 table = [] while i * i <= n: while n % i == 0: n //= i table.append(i) i += 1 if n > 1: table.append(n) return table g = gcd(A, B) print(len(set(prime_decomposition(g)))+1)
p02660
s838328084
Wrong Answer
import math N = int(input()) p = [] i = 2 while i <= int(math.sqrt(N))+1: if N%i == 0: p.append(i) N = int(N/i) i += 1 else: i += 1 if N != 1: p.append(N) print(len(p))
p03657
s723919861
Accepted
a,b=map(int,input().split()) if a%3!=0 and b%3!=0 and (a+b)%3!=0: print('Impossible') else: print('Possible')
p04033
s636845392
Wrong Answer
a,b= list(map(int,input().split())) if 0 < a: print("Positive") elif b < 0: if (b-a+1)%2==1: print("Negative") else: print("Positive") elif a <= 0 <= b: print("zero")
p03623
s148059978
Accepted
x, a, b = map(int, raw_input() .split()) c = abs(a-x) d = abs(b-x) if c < d and d > c: print "A" else: print "B"
p03495
s719257093
Accepted
n,k=map(int,input().split()) nm=[0 for i in range(200010)] a=list(map(int,input().split())) for i in a: nm[i]+=1 nm.sort(reverse=True) for i in range(k): n-=nm[i] print(n)
p03264
s586369921
Accepted
N=int(input()) if N%2==0: print((N//2)**2) else: print((N//2)*((N//2)+1))
p03760
s401577262
Accepted
o = input() e = input() ans_li = ['#']*(len(o)+len(e)) for i,s in enumerate(o): ans_li[i*2]=s for i,s in enumerate(e): ans_li[i*2+1]=s print(''.join(ans_li))
p03487
s602006354
Wrong Answer
n = int(input()) a = list(map(int, input().split())) d = {} for ai in a: if ai in d: d[ai] += 1 else: d[ai] = 1 ans = 0 for ai in d: ans += max(0, d[ai] - ai) print(ans)
p02718
s956679539
Accepted
def resolve(): N, M = list(map(int, input().split())) A = sorted(list(map(int, input().split())), reverse=True) total = sum(A) choose = 0 th = total/(4*M) for a in A: if a < th: continue choose += 1 print("Yes" if choose >= M else "No") if '__main__' == __name__: resolve()
p03699
s562441754
Wrong Answer
n = int(input()) s_L = [] for i in range(n): s_L.append(int(input())) ans = sum(s_L) if ans % 10 != 0: print(ans) s_L = sorted(s_L) for i in range(n): if s_L[i]%10 != 0: print(ans-s_L[i]) exit() print(0)
p03814
s917074488
Accepted
def main(): s = list(input()) n = len(s) start = -1 for i in range(n): if s[i] == 'A' and start == -1: start = i if s[i] == 'Z': end = i ans = end - start + 1 print(ans) if __name__ == "__main__": main()
p03137
s369912021
Accepted
n,m = map(int, input().split()) x = sorted(list(map(int, input().split()))) if n >= m: print(0) exit() nums = [0]*(m-1) for i in range(m-1): nums[i] = x[i+1] - x[i] nums = sorted(nums) print(sum(nums[:m-1-(n-1)]))
p02754
s448799064
Accepted
n,a,b=map(int,input().split()) print(n//(a+b)*a+min(a,n%(a+b)))
p02576
s643493017
Accepted
import math n, x, t = [int(x) for x in input().split()] ans = math.ceil(n / x) * t print(ans)
p03860
s908203949
Accepted
A,s,C = map(str, input().split()) print(A[0] + s[0] + C[0])
p03206
s076177472
Accepted
d=int(input()) a="Christmas" b=" Eve" print(a+b*(25-d))
p03821
s990673982
Accepted
n = int(input()) A = [0]*n B = [0]*n for i in range(n): a, b = map(int, input().split()) A[i], B[i] = a, b ans = 0 temp = 0 for i in reversed(range(n)): if (A[i]+temp)%B[i] != 0: j = (A[i]+temp)//B[i] ans += B[i]*(j+1)-(A[i]+temp) temp += B[i]*(j+1)-(A[i]+temp) print(ans)
p03672
s646454131
Accepted
S = input() while True: S = S[:-1] if len(S) % 2 != 0: continue else: if S[:len(S)//2] == S[len(S)//2 : ]: print(len(S)) exit()
p02606
s296316017
Wrong Answer
l,r,d=map(int,input().split()) print(r//d-l//d)
p03745
s498461529
Accepted
n = int(input()) A = list(map(int, input().split())) ans = 1 inc = False dec = False before = A[0] for a in A: if not inc and not dec: if a > before: inc = True if a < before: dec = True elif inc: if a < before: ans += 1 inc = False elif dec: if a > before: ans += 1 dec = False before = a print(ans)
p03219
s264294058
Accepted
a,b=map(int,input().split());print(a+b//2)
p02796
s413284157
Wrong Answer
num = int(input()) lista=[] ans = 0 for i in range(num): j= list(map(int, input().split())) a=j[0]-j[1] b=j[0]+j[1] lista.append([a,b]) lista.sort(key=lambda x: x[1]) print(lista) def list_func(x): global ans xa=[i for i in x if i[0]>=x[0][1]] ans+=1 return xa while(len(lista)): lista=list_func(lista) print(ans)
p03286
s405063693
Accepted
import sys sys.setrecursionlimit(2147483647) INF=float("inf") MOD=10**9+7 # 998244353 input=lambda:sys.stdin.readline().rstrip() def resolve(): n = int(input()) res = [] coef = 1 while n: if n & 1: res.append('1') n -= coef else: res.append('0') coef *= -1 n >>= 1 res = ''.join(res[::-1]) if res else '0' print(res) resolve()
p03487
s038231882
Wrong Answer
n = int(input()) a = sorted(list(map(int, input().split()))) b = set(a) count = 0 z = 0 for i in b: if i <= 10**5: j = a.count(i) if j < i: count += j z += j else: k = j - i count += k z += j else: f = len(a) - z count += z break print(count)
p02570
s126241831
Wrong Answer
d,t,s=map(int,input().split()) print("Yes" if t/s<=t else "No")
p02953
s837472362
Accepted
n = int(input()) h = list(map(int,input().split())) prev = 10**9+1 stair = "Yes" hlen = len(h) for i in range(n): hgt = h[hlen-1-i] if hgt>prev+1: stair = "No" break elif hgt==prev+1: prev = hgt-1 else: prev = hgt print(stair)
p02801
s659102730
Accepted
C = input() print(chr(ord(C) + 1))
p03136
s786431158
Accepted
N = int(input()) L = list(map(int, input().split())) lmax = max(L) L.remove(lmax) tot = sum(L) if lmax < tot: print('Yes') else: print('No')
p03448
s088553379
Accepted
a,b,c,x=[int(input()) for i in range(4)] ans=0 for i in range(a+1): for j in range(b+1): for k in range(c+1): if 500*i+100*j+50*k==x: ans += 1 print(ans)
p03262
s896477194
Wrong Answer
N,X=map(int,input().split()) import math a=list(map(int,input().split())) a.append(X) a.sort() S=[] for i in range(N): S.append(a[i+1]-a[i]) ans=S[0] for j in range(1,N): math.gcd(ans,S[j]) print(ans)
p03407
s045955798
Accepted
import sys read = sys.stdin.read readline = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 8) INF = float('inf') MOD = 10 ** 9 + 7 def main(): A, B, C = map(int, readline().split()) if A + B >= C: print('Yes') else: print('No') if __name__ == '__main__': main()
p02771
s502679378
Accepted
a, b, c = map(int, input().split()) if a == b and b == c and c == a: print("No") elif a != b and b != c and c != a: print("No") else: print("Yes")
p02578
s387785474
Accepted
n = int(input()) A = list(map(int, input().split())) ans = 0 for i in range(n-1): dif = A[i] - A[i+1] if dif > 0: A[i+1] += dif ans += dif print(ans)
p03778
s167085495
Wrong Answer
w, a, b = map(int, input().split()) if a < b: print(abs(a+w-b)) else: print(abs(b+w-a))
p02882
s792538647
Wrong Answer
import math a,b,x = map(int,input().split()) if (a**2)*b == x: print(90) else: if 2*(a**2)*b <= 2*(a**2)*x: print(math.degrees(math.atan2(2*((a**2)*b-x), a**3))) else: print(math.degrees(math.atan2(a*(b**2), 2*x)))
p02971
s696471015
Wrong Answer
n = int(input()) A=[0]*n maxd = 0 smax = 0 for i in range(n): A[i] = int(input()) if A[i] > maxd: smax = maxd maxd =A[i] for i in range(n): if A[i]==maxd: print(smax) else: print(maxd)
p02988
s830211677
Accepted
n=int(input()) *p,=map(int, input().split()) ans=0 for i in range(1,n-1): if (p[i-1] < p[i] < p[i+1]) or (p[i-1] > p[i] > p[i+1]): ans += 1 print(ans)
p02701
s686839960
Accepted
n = int(input()) s = list(input() for _ in range(n)) print(len(set(s)))
p03323
s657095728
Accepted
import sys import itertools sys.setrecursionlimit(1000000000) from heapq import heapify,heappop,heappush,heappushpop import collections a,b = map(int,input().split()) if a>=9 or b>=9: print(":(") else: print("Yay!")
p02866
s940596668
Accepted
from collections import Counter n = int(input()) d = list(map(int,input().split())) c = Counter(d) mod=998244353 if d[0]==1: print(0) else: D = 1 for i in d[1:]: D = (D*c[i-1])%mod print(D)
p02918
s706390811
Accepted
n, k = map(int, input().split()) s = input() a = 'A' s = s+'B' cnt = -1 for i in s: if a != i: a = i cnt += 1 print(n-max(1,cnt-2*k))
p02711
s623675352
Accepted
in_set = set(input()) if '7' in in_set: print('Yes') else: print('No')
p02946
s195959017
Accepted
k,x=map(int,input().split()) for i in range(x-(k-1),x+k): print(i,end=' ')
p03779
s667054128
Accepted
x=int(input()) # 何もしないの全探索 ans,i=0,0 while True: if ans>=x: break ans+=i i+=1 print(i-1)
p03852
s534888388
Accepted
c = input() b = ['a', 'i', 'u', 'e', 'o'] if c in b: print('vowel') else: print('consonant')
p03472
s790161910
Accepted
from math import ceil N,H=map(int, input().split()) A=[0]*N B=[0]*N for i in range(N): a,b=map(int, input().split()) A[i]=a B[i]=b A=sorted(A) B=sorted(B, reverse=True) amax=max(A) ans=0 for i in range(N): b=B[i] if b>amax: H-=b ans+=1 if H<=0: break else: break if H>0: ans+=ceil(H/amax) print(ans)
p04011
s274516158
Accepted
day = int(input()) posreday= int(input()) price = int(input()) posreprice = int(input()) if day<= posreday: print(day * price) elif day > posreday: print(posreday * price + (day - posreday) * posreprice)
p03827
s828963529
Accepted
n = input() S = input() x = xmax = 0 for s in S: x += 1 if s == 'I' else -1 xmax = max(x, xmax) print(xmax)
p03997
s842355373
Accepted
#ABC045 A a=int(input()) b=int(input()) h=int(input()) print(int((a+b)*h/2))
p03284
s159053638
Wrong Answer
n,k=map(int,input().split()) print((n+k+1)//k)
p02621
s914708836
Accepted
n = int(input()) print(n+n**2+n**3)
p02556
s863139817
Wrong Answer
n = int(input()) x_y = [[] for i in range(n)] for i in range(n): x_y[i] = list(map(int, input().split())) x_ = sorted(x_y, key=lambda x: x[0]) #print(x_) ans = 0 for l in range(n): for r in range(n-1,l,-1): # print(l,r) kyori = (x_[r][0] - x_[l][0]) + (x_[r][1] - x_[l][1]) if kyori < 0: kyori = -kyori print(kyori) if kyori > ans: ans = kyori print(ans)
p02797
s246468019
Accepted
N, K, S = map(int, input().split()) if S > 2: print(*([S]*K+[S-1]*(N-K))) else: print(*([S]*K+[S+10**6]*(N-K)))
p02555
s798438212
Accepted
import sys sys.setrecursionlimit(10**8) s = int(input()) mod = pow(10, 9)+7 d = dict() def solve(n): if n in d.keys(): return d[n] cnt = 0 for i in range(3, n+1): if n-i >= 3: cnt += solve(n-i) else: if n-i == 0: cnt += 1 d[n] = cnt%mod return d[n] print(solve(s)%mod)
p02948
s053408484
Accepted
import heapq from collections import defaultdict n, m = map(int, input().split()) ans = 0 jobs = defaultdict(list) to_do = [] heapq.heapify(to_do) for i in range(n): array = list(map(int, input().split())) array[1] *= -1 jobs[array[0]].append(array[1]) for i in range(1, m+1): if len(jobs[i]) > 0: for j in jobs[i]: heapq.heappush(to_do, j) if len(to_do) > 0: ans += -1 * heapq.heappop(to_do) print(ans)
p03338
s948789683
Accepted
N=int(input()) S=input() ans=0 for i in range(1,N+1): count=0 for s in set(S[:i]): if s in S[i:]: count+=1 ans=max(ans,count) print(ans)
p04012
s334877597
Accepted
from collections import Counter w = input() counts = Counter(w).values() flag = True for count in counts: if count % 2 != 0: flag = False break print('Yes' if flag else 'No')
p03043
s551943594
Accepted
import decimal import math N, K = map(int, input().split()) #coin = [decimal.Decimal('0.5')**k for k in range(10**4)] ans = 0 for i in range(1,N+1): tmp = math.log(K/i, 2) x = int(math.log(K/i,2)) if i >= K: ans += 1/N else: if tmp - x != 0: x += 1 ans += 1/N * (0.5)**x print(ans)
p02771
s160840951
Accepted
A, B, C = map(int, input().split()) if (A == B and B != C) or (A == C and A != B) or (B == C and C != A): print('Yes') else: print('No')
p02973
s622586062
Accepted
import bisect N=int(input()) A=[int(input()) for _ in range(N)] color=[-1]*(N) for a in A: i=bisect.bisect_left(color,a) color[i-1]=a print(N-bisect.bisect_right(color,-1))
p03485
s089307930
Accepted
a,b=[int(i) for i in input().split()] x=(a+b)/2 import math print(math.ceil(x))
p03943
s440669986
Accepted
a,b,c=map(int,input().split()) s = [a,b,c] s = sorted(s) print('Yes' if s[0]+s[1]==s[2] else 'No')
p02659
s790168285
Accepted
a,b=input().split() a=int(a) c,d=b.split(".") c=int(c);d=int(d) ans=a*(c*100+d) print(ans//100)
p03852
s301758692
Wrong Answer
""" author : halo2halo date : 2, Feb, 2020 """ import sys import itertools import numpy as np read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines S = readline().decode('utf8') vowel = 'aiueo' print('vowel' if S in vowel else 'consonant')
p03779
s436087334
Wrong Answer
from math import sqrt x = int(input()) ans = int((sqrt(8*x+1))//2) print(ans)
p02693
s153451331
Accepted
k = int(input()) conditions = input().split(' ') a = int(conditions[0]) b = int(conditions[1]) flag = False for i in range(a, b+1): if i % k == 0: flag = True break if flag: print('OK') else: print('NG')
p02793
s981889944
Accepted
import sys input = sys.stdin.readline LOCAL = len(sys.argv) > 1 and sys.argv[1] == 'LOCAL' def dprint(*args): if LOCAL: print(*args) MOD = 10**9 + 7 n = int(input()) a = list(map(int, input().split())) # https://note.nkmk.me/python-gcd-lcm/ import math from functools import reduce import fractions def lcm_base(x, y): return (x * y) // fractions.gcd(x, y) def lcm(*numbers): return reduce(lcm_base, numbers, 1) def lcm_list(numbers): return reduce(lcm_base, numbers, 1) lcm = lcm_list(a) dprint(lcm) ans = 0 for x in a: ans += lcm // x print(ans % MOD)
p02621
s325358753
Wrong Answer
a = int() A = a + a*a + a*a*a print(A)
p03379
s253899599
Accepted
n = int(input()) a = list(map(int, input().split())) b = sorted(a) #print(a) #print(b) left = b[int(n/2)-1] right = b[int(n/2)] if left == right: for i in range(n): print(right) else: for i in range(n): if a[i] <= left: print(right) else: print(left)
p02608
s627363204
Wrong Answer
n = int(input()) for i in range(n): if i < 6: print(0) else: count=0 for j in range(100): for k in range(100): for l in range(100): if ((j+1)**2 + (k+1)**2 + (l+1)**2 + (j+1)*(k+1) +(k+1)*(l+1) +(l+1)*(j+1)) == i: count +=1 print(count)
p02873
s761302167
Accepted
def sigma(n): return n * (n + 1) // 2 s = list(map(lambda x : 1 if x == '<' else -1, input())) l = [s[0]] for c in s[1:]: if c * l[-1] > 0: l[-1] += c else: l.append(c) ans = 0 now = 0 for c in l: if c < 0: ans -= min(now, abs(c)) ans += sigma(abs(c)) now = abs(c) print(ans)