problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p03493
s019965554
Accepted
S=input() print(S.count("1"))
p03210
s667611778
Wrong Answer
year=int(input()) if year==3 or year==5: print("YES")
p03486
s486050773
Accepted
import sys import itertools sys.setrecursionlimit(1000000000) from heapq import heapify,heappop,heappush,heappushpop import math import collections s = list(input()) t = list(input()) s.sort() t.sort(reverse=True) s2 = "" t2 = "" for i in range(len(s)): s2+=s[i] for i in range(len(t)): t2+=t[i] dic = [s2,t2] dic.sort() if s2 == t2: print("No") sys.exit() if dic[0] == s2: print("Yes") else: print("No")
p03359
s952358451
Accepted
a,b = map(int, input().split()) if a <= b: print(a) else: print(a-1)
p02661
s047233165
Accepted
n = int(input()) a = [] b = [] for i in range(n): aa,bb = map(int, input().split()) a.append(aa) b.append(bb) a.sort() b.sort() if n%2 == 1: p = a[n//2] q = b[n//2] ans = q - p + 1 else: p1 = a[n//2 -1] p2 = a[n//2] q1 = b[n//2] q2 = b[n//2 - 1] p = (p1+p2)*5 q = (q1+q2)*5 ans = (q-p)//5 + 1 print(ans)
p03284
s673700495
Wrong Answer
N, K = map(int, input().split()) print(int(N%K==0))
p02681
s408890305
Wrong Answer
s=input() t=input() if t[-2]==s: print('Yes') else: print('No')
p02594
s424678484
Wrong Answer
k=int(input()) i=1 seven='7' if k%2==0: print(-1) else: while int(seven)%k!=0: seven+='7' i+=1 print(i)
p03544
s817287286
Accepted
n = int(input()) l = [2,1] for i in range(n): l.append(l[-1]+l[-2]) print(l[n])
p02613
s877148029
Wrong Answer
from collections import defaultdict n = int(input()) d = defaultdict(int) for i in range(n): d[input()] += 1 for i in ['AC', 'WA', 'TLE', 'RE']: print(i+' X '+str(d[i]))
p02835
s449023481
Wrong Answer
a,b,c = input().split() if int(eval(a+b+c)) >= 22: print('bust') else: print('win')
p03711
s466123243
Wrong Answer
x,y=map(int, input().split()) if x==2 or y==2: print('No') a=[4,6,9,11] if x in a and y in a: print('Yes') elif x not in a and y not in a: print('Yes') else: print('No')
p03548
s079356800
Wrong Answer
x, y, z = list(map(int, input().split())) print(1 + (x - y) // (y + z))
p02948
s443737451
Wrong Answer
n, m = map(int, input().split()) C = [] for i in range(n): a, b = map(int, input().split()) C.append([a, b]) C.sort(reverse=True, key=lambda x:(x[1], x[0])) ans = 0 for i in range(n): if m < C[i][0]: continue else: ans += C[i][1] m -= i print(ans)
p03219
s870667687
Accepted
x,y=map(int,input().split());print(int(x+y/2))
p03486
s397114004
Wrong Answer
s = sorted(list(str(input()))) t = reversed(list(str(input()))) #s.sorted() #t.reverse() S = str() T = str() for i in s: S += i for k in t: T += k print('Yes' if S<T else 'No')
p02576
s932277606
Accepted
int_n, int_x, int_t = map(int, input().split()) #print(int_n, int_x, int_t) if int_n % int_x == 0: print(int_n // int_x *int_t) else: print(((int_n // int_x) + 1)*int_t)
p02784
s270394211
Wrong Answer
h,n=map(int, input().split()) a=list(map(int, input().split())) print("Yes" if h<sum(a) else "No")
p03251
s461822379
Wrong Answer
n, m, a, b = map(int, input().split()) x = [int(i) for i in input().split()] y = [int(i) for i in input().split()] x.sort() y.sort() if x[-1] < y[0]: for i in range(x[-1],y[0]+1): if a < i <= b: print("No War") exit() print("War")
p03075
s327442313
Wrong Answer
l=[int(input()) for i in range(5)] k=int(input()) if (max(l)-min(l)) > 0: print(":(") else: print("Yay!")
p03338
s080529996
Accepted
N = int(input()) S = input() ans = 0 for i in range(1, N): l = set(S[:i]); r = set(S[i:]); ans = max(ans, len(l & r)) print(ans)
p03469
s813135153
Accepted
S = list(input()) S[3] = '8' a = ''.join(S) print(a)
p03745
s242595149
Accepted
N=int(input()) A=list(map(int,input().split())) count=1 sign=0 for i in range(N-1): diff=A[i+1]-A[i] if sign*diff<0: count+=1 sign=0 elif sign==0: sign=diff print(count)
p03986
s564352488
Wrong Answer
# A - STring N = 100000 X = input() T_head = S_tail = 0 for i in range(N): if X[i]=='S': break T_head += 1 for i in range(N): if X[len(X)-i-1]=='T': break S_tail += 1 print(2*max(T_head, S_tail))
p03696
s699558484
Accepted
n = int(input()) s = input() while True: c = 0 for i in range(len(s)): if s[i] == "(": c += 1 else: c -= 1 if c < 0: s = "(" + s break if c > 0: s = s + ")" if c == 0: print(s) break
p03210
s855053571
Wrong Answer
X=int(input()) if (X%2==1)and(not(X==1)): print("YES") else: print("NO")
p02767
s231250533
Wrong Answer
N = int(input()) X = list(map(int, input().split())) ans = 0 for i in X: ans += (N-i)**2 print(ans)
p03695
s774294492
Wrong Answer
from collections import Counter n = int(input()) A = list(map(int, input().split())) A = [min(8, a // 400) for a in A] CA = Counter(A) num = 0 for i in range(8): if i in CA: num += 1 num_8 = CA[8] saidai = min(num + num_8, 8) saisho = min(1, num) print(saisho, saidai)
p03796
s503731213
Wrong Answer
N=int(input(),10) V = 10**9 + 7 ans = 1 for i in range(1, N+1): ans *= i % V print(ans)
p03611
s344210960
Wrong Answer
n=int(input()) a=list(map(int,input().split())) a.sort() ans=[-1,0] i=0 while i<=n-1: res=0 cnt=0 m=2 if a[i]==a[0] or a[i]==a[-1]: m=1 while i+res<=n-1 and a[i+res]-a[i]<=m: if a[i+res]==a[i]: cnt+=1 res+=1 if res>ans[1]: ans[1]=res ans[0]=i i+=cnt print(ans[1])
p02759
s653795227
Accepted
N = int(input()) if N % 2 == 1: ans = int(N / 2) + 1 else: ans = int(N / 2) print(ans)
p03274
s282884674
Accepted
n, k = map(int, input().split()) X = list(map(int, input().split())) P = [] N = [] for x in X: if x >= 0: P.append(x) else: N.append(x) P.sort() N.sort(reverse=True) P = [0]+P N = [0]+N ans = 10**16 for a in range(k+1): b = k-a if a > len(P)-1 or b > len(N)-1: continue else: ans = min(ans, min(2*P[a]+(-1)*N[b], P[a]+2*(-1)*N[b])) print(ans)
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が偽になる ⇒ 実行する """
p02546
s693024987
Accepted
S = str(input()) if S[-1] == "s": print(S + "es") else: print(S + "s")
p03625
s435583256
Accepted
import collections n=int(input()) c=collections.Counter(list(map(int,input().split()))) p=-1 for x in sorted(c.keys())[::-1]: if p==-1 and c[x]>=4:print(x*x);break elif p==-1 and c[x]>=2:p=x elif p!=-1 and c[x]>=2:print(p*x);break else:print(0)
p02555
s003093763
Wrong Answer
s=int(input()) n=1000000007 for i in range (1,667): if s<i*3: print((i-1)%n)
p02732
s086005660
Wrong Answer
import itertools import copy N = map(int, input().split()) N_list = list(map(int, input().split())) N_all = list(itertools.combinations(N_list, len(N_list)-1)) for N_rem in N_all: count = 0 num_list = list(itertools.combinations(N_rem,2)) for i, j in num_list: if i==j: count+=1 print(count)
p02714
s241328578
Wrong Answer
import collections N = int(input()) S = input() ans = 0 r_index = [i for i, x in enumerate(S) if x == 'R'] g_index = [i for i, x in enumerate(S) if x == 'G'] b_index = [i for i, x in enumerate(S) if x == 'B'] for i in r_index: for j in g_index: for k in b_index: if abs(j-i) == abs(k-j): continue else: ans += 1 print(ans)
p02647
s244887020
Accepted
n, k = map(int, input().split()) a = list(map(int, input().split())) for n_iter in range(k): b = [0] * n for i in range(n): left = max(0, i - a[i]) right = min(n-1, i + a[i]) b[left] += 1 if right + 1 < n: b[right + 1] -= 1 a[0] = b[0] for i in range(1, n): b[i] += b[i-1] a[i] = b[i] if n_iter >= 50: break print(*a)
p02766
s781094353
Wrong Answer
n, k = map(int,input().split()) sum = 0 cnt = 0 while True: sum += int(k**cnt) if sum <= n: cnt += 1 else: break print(cnt)
p02577
s560237656
Wrong Answer
n = input() s = str(n) array = list(map(int, s)) if sum(array)%9 == 0 and sum(array)!=0: print("Yes") else: print("No")
p02912
s129582866
Accepted
import heapq from numpy import ceil,sum N,M = (int(x) for x in input().split()) A = list(map(lambda x: int(x)*(-1), input().split())) heapq.heapify(A) for i in range(M): t1 = heapq.heappop(A) t2 = t1 / 2 heapq.heappush(A, t2) B = ceil(A) print(int(sum(B)*(-1)))
p02713
s208492340
Wrong Answer
k=int(input()) n=0 for a in range(k): a+=1 for b in range(k): b+=1 for c in range(k): c+=1 s=1 for d in range(k): d+=1 if a>=d and b>=d and c>=d and a%d == 0 and b%d== 0 and c%d == 0: s=s*d n+=s print(n)
p02993
s051719117
Accepted
s = input() for i in range(1,len(s)): if s[i-1] == s[i]: print("Bad") exit() print("Good")
p03041
s119450907
Accepted
n,k=map(int,input().split()) s=input() ans=s[:k-1]+s[k-1].lower()+s[k:] print(ans)
p03962
s324100537
Wrong Answer
a,b,c=map(int,input().split()) l=sum([a==b,b==c,c==a]) print([1,2,0,3][l])
p02783
s489066059
Wrong Answer
h, a = map(int, input().split()) if h <= a: print(1) quit() c = 0 while h > a: c += 1 a += a print(c)
p03011
s185744994
Accepted
a, b, c = map(int, input().split()) d = a + b f = a + c g = b + c my_list = [d, f, g] h = my_list.sort() i = my_list[0] print(i)
p04029
s137444052
Accepted
n = int(input()) print(n*(n+1) // 2)
p02678
s448951489
Accepted
(n,m),*e=[[*map(int, t.split())] for t in open(0)] t=[[]for _ in range(n+1)] for a,b in e:t[a]+=[b];t[b]+=[a] q=[1] a=[0]*-~n while q:q=[a[j]==0and(a.__setitem__(j,i)or j)for i in q for j in t[i]] print('Yes',*a[2:])
p02691
s844446540
Accepted
from collections import defaultdict N = int(input()) A = map(int, input().split()) d = defaultdict(int) ans = 0 for i, a in enumerate(A): ans += d[-i+a] d[-i-a] += 1 print(ans)
p02761
s443642545
Wrong Answer
N,M = map(int,input().split()) sc = [list(map(int,input().split())) for i in range(M)] for i in range(10**N): stop = True for t in sc: if i//(10**(N-t[0]))%10 != t[1]: stop = False if stop: print(i) break if stop: print(-1)
p03778
s170834988
Wrong Answer
w,a,b = map(int,input().split()) x = b-(a+w) y = a-(b+w) if x<=0 or y<=0: print(0) else: ans = min(x,y) print(ans)
p03474
s177305840
Accepted
#!/usr/bin/env python3 a,b = map(int,input().split()) s = input() flag = 0 for i in range(a+b+1): if i < a or i > a : if s[i] == "-": flag = 1 """if ord(s[i]) < 48 or ord(s[i]) > 57: flag = 1""" elif s[i] != "-": flag = 1 print("Yes" if flag == 0 else "No")
p03835
s397426703
Accepted
K, S = map(int, input().split()) count = 0 for x in range(K+1): for y in range(K+1): if 0 <= S - (x+y) <= K: count += 1 print(count)
p03331
s197414189
Accepted
n = input() ans = 0 for i in range(len(n)): ans += int(n[i]) if ans == 1: ans = 10 print(ans)
p03623
s176966269
Accepted
x,a,b = map(int,input().split()) print("A" if abs(x-a) <= abs(x-b) else "B")
p03251
s807636116
Accepted
n,m,x,y=map(int,input().split()) x_=list(map(int,input().split())) y_=list(map(int,input().split())) x_.append(x) y_.append(y) if min(y_)>max(x_): print('No War') else: print('War')
p03795
s078734530
Wrong Answer
n = int(input()) print(800*n-200*(n/15))
p02873
s179454704
Wrong Answer
from itertools import* s=input() x=[len(list(v)) for k,v in groupby(s)] n=len(x) ans=0 if s[0]=="<": ans+=(x[0]-1)*x[0]//2 n-=1 del x[0] if s[-1]==">": ans+=(x[-1]-1)*x[-1]//2 n-=1 for i in range(0,n,2): ma=max(x[i],x[i+1]) mi=min(x[i],x[i+1]) ans+=ma*(ma+1)//2 ans+=(mi-1)*mi//2 print(ans)
p03433
s701548228
Wrong Answer
print(["Yes","No"][int(input())<int(input())%500])
p04019
s182306862
Wrong Answer
# coding:utf-8 S = input() n = S.count('N') s = S.count('S') e = S.count('E') w = S.count('W') print(n, s, e, w) if (n == 0 and s != 0) or (n != 0 and s == 0): print('No') elif (e == 0 and w != 0) or (e != 0 and w == 0): print('No') else: print('Yes')
p02952
s692828861
Accepted
n = int(input()) count = 0 for i in range(1, n + 1): if len(str(i)) % 2 == 1: count += 1 else: continue print(count)
p02900
s478578894
Wrong Answer
A, B = map(int, input().split()) def prime_numbers(N): n = N res = [] for i in range(2, n): if i * i >= n: break if N % i != 0: continue while N % i == 0: N //= i res.append(i) res.append(N) return res a = prime_numbers(A) b = prime_numbers(B) ans = min(len(a), len(b)) print(ans)
p03387
s271335571
Accepted
number=[int(i) for i in input().split()] number.sort() a,b,c=number #aを何回操作すればcかc-1にできるか anum=(c-a)//2 amari=(c-a)%2 bnum=(c-b)//2 bamari=(c-b)%2 c=amari+bamari if c==0: plus=0 elif c==1: plus=2 else: plus=1 print(anum+bnum+plus)
p02606
s049359351
Wrong Answer
L,R,d = map(int,input().split()) c =0 for i in (L,R+1): if i % d ==0: c+=1 print(c)
p02988
s641984478
Accepted
n=int(input()) p=list(map(int,input().split())) ans=0 for i in range(1,n-1): if p[i-1]<p[i] and p[i]<p[i+1]: ans+=1 if p[i-1]>p[i] and p[i]>p[i+1]: ans+=1 print(ans)
p02948
s215012560
Accepted
import heapq N, M = map(int, input().split()) arubaito = [list(map(int, input().split())) for _ in range(N)] arubaito.sort() arubaito2 = [[] for _ in range(M+1)] for i in range(N): if arubaito[i][0] <= M: arubaito2[arubaito[i][0]].append(arubaito[i][1]) for i in range(M): arubaito2[i].sort(reverse=True) target = [] ans = 0 heapq.heapify(target) for i in range(1,M+1): for k in arubaito2[i]: heapq.heappush(target,k*(-1)) if len(target) > 0: ans += heapq.heappop(target)*(-1) print(ans)
p03208
s881402173
Wrong Answer
from collections import Counter N, K = list(map(int,input().split())) H = [] for i in range(N): H.append(int(input())) H = sorted(H,reverse = False) C = Counter(H) CH = list(C.values()) cnt = 0 for i in range(len(CH)): if CH[i] >= K: cnt += 1 break if cnt != 0: print('0') else: print(H[K-1] - H[0])
p02866
s232245760
Accepted
from collections import Counter inputs = open(0).readlines() n = int(inputs[0]) *D, = map(int, inputs[1].split()) mod = 998244353 nbs = [0] * (max(D)+1) for k, v in Counter(D).items(): nbs[k] = v if D[0] != 0 or nbs[0] != 1: print(0) else: ans = 1 for n0, n1 in zip(nbs, nbs[1:]): ans = ans * pow(n0, n1, mod) % mod print(ans)
p02657
s370075696
Accepted
A, B = map(int, input().split()) print(A * B)
p03062
s661136553
Accepted
n=int(input()) a=list(map(int,input().split())) count=0 ans=[] for i in range(n): ans.append(abs(a[i])) if a[i]<0: count+=1 if count%2==0: print(sum(ans)) else: print(sum(ans)-2*min(ans))
p02640
s614373188
Accepted
import sys input = sys.stdin.readline X, Y = map(int, input().split()) for i in range(101): n = i k = X - i if 0 > k or k > 100: continue if Y == n * 2 + k * 4: print('Yes') exit() print('No')
p02597
s980369242
Wrong Answer
N = int(input()) S = input() l = 0 r = len(S) - 1 W = 'W' R = 'R' cnt = 0 while l < r: if S[l] == R: l += 1 continue else: while l < r: if S[r] == W: r -= 1 continue else: cnt += 1 l += 1 r -= 1 print(cnt)
p03448
s723045723
Accepted
a = int(input()) b = int(input()) c = int(input()) x = int(input()) cnt = 0 for i in range(a+1): for j in range(b+1): for k in range(c+1): if i * 500 + j * 100 + 50 * k == x: cnt += 1 print(cnt)
p02578
s093074890
Accepted
n = int(input()) num_list = list(map(int, input().split())) a = int(num_list[0]) p = 0 for i in range(n): if num_list[i] < a: p = p + (a - num_list[i]) elif num_list[i] > a: a = num_list[i] print(p)
p03971
s276676159
Accepted
_,A,B = map(int,input().split()) s = list(input()) ab = 0 b = 0 for i in s: res = "No" if i == "a": if ab < A+B: ab += 1 res = "Yes" if i == "b": if ab < A+B and b < B: ab += 1 b += 1 res = "Yes" print(res)
p02922
s745264733
Accepted
a, b = map(int, input().split()) res = 0 out = 1 while out < b: out -= 1 res += 1 out += a print(res)
p02658
s735751227
Wrong Answer
MAX = 1000000000000000000 n = input() A = list(map(int, input().split())) total = 1 for a in A: total *= a if total > MAX: total = -1 break print(total)
p02552
s096566353
Accepted
x = int(input()) if x == 0: print(1) else: print(0)
p03360
s063378292
Accepted
ABC = list(map(int, input().split())) K = int(input()) print(max(ABC)*(2**K - 1) + sum(ABC))
p02835
s644419760
Accepted
a,b,c = map(int,input().split()) if a+b+c <= 21 : print('win') else : print('bust')
p02972
s286094707
Accepted
n = int(input()) a = list(map(int, input().split())) jud = [0] * n ans = [] for i in range(n//2, n): if a[i] == 1: jud[i] = 1 ans.append(i+1) for i in range(n//2-1, -1, -1): cou = 0 for j in range(2, n//(i+1)+1): cou ^= jud[(i+1)*j-1] if a[i] != cou: jud[i] = 1 ans.append(i+1) ans.sort() print(jud.count(1)) print(*ans)
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)
p02597
s795625357
Accepted
N = int(input()) stone = input() if(stone == "R" * N): print(0) elif(stone == "W" * N): print(0) else: b = stone.count("R") c = stone[0:b].count("R") print(b-c)
p03672
s388994388
Wrong Answer
S = input() for i in range(2, len(S), 2): if S[:(len(S)-i)//2] == S[(len(S)-i)//2:len(S)-i]: print(len(S)-i)
p03795
s368182460
Accepted
n=int(input()) x=n*800 y=(n//15)*200 print(x-y)
p02924
s444870051
Accepted
n=int(input()) print(n*(n-1)//2)
p02663
s577310766
Accepted
H1,M1,H2,M2,K=map(int,input().split()) d=H1*60 g=H2*60 f=(g+M2)-(d+M1)-K print(f)
p03627
s952031461
Accepted
import sys input = sys.stdin.readline n = int(input()) a = [int(x) for x in input().split()] from collections import Counter c = Counter(a) ans = 0 possible_e = [] for i in c.keys(): if c[i] >= 4: ans = max(ans, i ** 2) if c[i] >= 2: possible_e.append(i) possible_e.sort() if len(possible_e) > 1: ans = max(ans, possible_e[-1] * possible_e[-2]) print(ans)
p03438
s933645698
Accepted
import sys readline = sys.stdin.readline sys.setrecursionlimit(10**8) mod = 10**9+7 #mod = 998244353 INF = 10**18 eps = 10**-7 N = int(readline()) A = list(map(int,readline().split())) B = list(map(int,readline().split())) print('Yes' if sum(B)-sum(A) >= sum(max(0,(b-a+1)//2) for a,b in zip(A,B)) else 'No')
p02729
s626760749
Wrong Answer
a = list(map(int, input().split())) if a[0]==1: n=0 else: n=a[0]*(a[0]-1)/2 if a[1]==1: m=0 else: m=a[1]*(a[1]-1)/2 print(n+m)
p03219
s150203446
Wrong Answer
a,b=input().split() a=int(a) b=int(b) print(a+b/2)
p03478
s960343657
Accepted
N, A, B = map(int, input().split()) ans = 0 for num in range(N + 1): num1 = list(str(num)) num2 = map(int, num1) sums = sum(num2) if sums >= A and sums <= B: ans += num print(ans)
p02786
s737575272
Accepted
from math import log2 # print(log2(4)) def pow_k(x, n): """ O(log n) """ if n == 0: return 1 K = 1 while n > 1: if n % 2 != 0: K *= x x *= x n //= 2 return K * x a = int(input()) if a ==1: print(1) exit() a = int(log2(a)) # print(a) res = 4*(pow_k(2,a-1))-1 print(res)
p02909
s585328286
Wrong Answer
tenki = ["Sunny", "Cloudy", "Rainy"] s = input() ans = "Cloudy" for i in range(2): if s == tenki[i]: ans = tenki[i + 1] print(ans)
p02900
s828100740
Accepted
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(int(n)) return table a=set(prime_decomposition(A)) b=set(prime_decomposition(B)) print(len(a&b)+1)
p02677
s393116630
Accepted
A,B,H,M = map(int,input().split()) import math # 角度を求める #長針 m = 6*M #短針 h = (H * 30) + ((30/60)*M) #最終角度 kakudo = min(360 - abs(m - h), abs(h - m)) kakudo_a = math.radians(kakudo) cos_x = math.cos(kakudo_a) c = A**2 + B**2 - 2*A*B*cos_x print(math.sqrt(c))
p02661
s056671763
Wrong Answer
n=int(input()) c=[list(map(int,input().split())) for _ in range(n)] a=[i[0] for i in c] b=[i[1] for i in c] a.sort() b.sort() print(b[n//2]-a[n//2-1]-b[n//2-1]+a[n//2]+1)
p02970
s859010165
Accepted
N, D = list(map(int, input().split())) import math ans = math.ceil(N / (D * 2 + 1)) print(ans)