problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02909
s823363002
Accepted
s=str(input()) if s[0]=="R": print("Sunny") elif s[0]=="S": print("Cloudy") elif s[0]=="C": print("Rainy")
p04030
s264518679
Accepted
S = input() A = [] for c in S: if c == 'B': if A: A.pop() else: A.append(c) print(''.join(A))
p03860
s215170696
Accepted
print("A"+input()[8]+"C")
p02701
s663727015
Wrong Answer
N = int(input()) S = list(map(str,input().split())) T = list(set(S)) print(len(T))
p02819
s945954757
Accepted
import math def prime(n): for k in range(2, int(math.sqrt(n)) + 1): if n % k == 0: return False return True n = int(input()) while True: if prime(n): break else: n += 1 print(n)
p02993
s173447681
Accepted
s = input() if s[0] == s[1] or s[1] == s[2] or s[2] == s[3]: print("Bad") else: print("Good")
p02628
s656555457
Wrong Answer
N,K=map(int,input().split()) p=list(map(int, input().split())) p.sort() print(p) price=0 for idx in range(K): price=price+p[idx] print(price)
p02910
s782806452
Accepted
#141_B s = input() flg = True for i in range(len(s)): if i % 2 == 0 and s[i] == 'L': flg = False break if i % 2 == 1 and s[i] == 'R': flg = False break print('Yes' if flg else 'No')
p03309
s580167170
Wrong Answer
import math def mean(x): n = len(x) return sum(x)/n n = int(input()) a = list(map(int, input().split())) ai = [a[i] - (i+1) for i in range(n)] b = math.floor(mean(ai)) result = sum([abs(ai[i] - b) for i in range(n)]) print(result)
p03495
s769239981
Wrong Answer
import copy from collections import Counter n, k = map(int, input().split()) lis = list(map(int, input().split())) count = [0]*(n+1) for i in range(n): count[lis[i]] += 1 if len(set(count)) <= k: print(0) exit() cnt = sorted(count) nlis = [] for i in range(n+1): if cnt[i] != 0: nlis.append(...
p03017
s140384900
Wrong Answer
n, a, b, c, d = map(int, input().split()) S = input() if c < d: if "##" in S[(a-1):]: print("No") else: print("Yes") else: if "..." in S[(b-1):]: print("Yes") else: print("No")
p03293
s781855685
Accepted
S = input().rstrip() T = input().rstrip() flg = False for i in range(len(S)): cnt = 0 for j, s in enumerate(S): if s==T[j-i]: cnt += 1 if cnt==len(S): flg = True if flg: print("Yes") else: print("No")
p03796
s490185262
Accepted
n = int(input()) power = 1 for i in range(n): power = power * (i+1) power = power % (10**9 +7) print(power)
p04030
s414947172
Wrong Answer
s = input() ans = "" for i in range(len(s)-1): if s[i+1] != 'B': ans += s[i] print(ans)
p02789
s110914871
Accepted
a,b=map(int,input().split()) if a==b: print("Yes") else: print("No")
p02761
s015523823
Accepted
N, M = map(int, input().split()) f = 0 A = [-1 for i in range(N)] for i in range(M): s, c = map(int, input().split()) if A[s-1] != -1 and A[s-1] != c: print(-1) f = 1 break A[s-1] = c if f == 0: if N == 1 and (A[0] <= 0): print(0) elif N > 1 and A[0] == 0: print(-1) else: ans = 0 ...
p02948
s859893761
Accepted
import heapq dic = {} n, m = map(int, input().split()) for _ in range(n): a, b = map(int, input().split()) if dic.get(a) is not None: dic[a].append(-b) else: dic[a] = [-b,] ans = 0 bite = [] for i in range(1, m+1): if dic.get(i) is not None: #bite = bite + dic[i] for val in dic[i]: heapq...
p02899
s335641242
Accepted
import math n=int(input()) l=list(map(int,input().split())) ans=[0]*n for i in range(n): ans[l[i]-1]=i+1 for i in ans: print(i,end=" ")
p03767
s091629250
Wrong Answer
n=int(input()) print(sum(sorted(map(int,input().split()))[n:2*n]))
p02897
s457540278
Accepted
n = int(input()) if n%2 == 0: print((n/2)/n) else: print(((n+1)/2)/n)
p03219
s752135161
Accepted
x,y = map(int,input().split()) ans = x + y//2 print(ans)
p02795
s897770319
Accepted
def solve(h, w, n): return min((n+h-1) // h, (n+w-1) // w) h = int(input()) w = int(input()) n = int(input()) print(solve(h, w, n))
p03565
s469721020
Accepted
S = input() T = input() ans = [] for l in range(len(S) - len(T) + 1): U = S[l: l + len(T)] for u, t in zip(U, T): if u == '?': continue if u != t: break else: ans.append((S[:l] + T + S[l + len(T):]).replace('?', 'a')) ans.sort() print(ans[0] if len(ans) > 0 ...
p03284
s217319626
Accepted
print(1*(eval(input().replace(' ','%'))>=1))
p03795
s886496177
Wrong Answer
N = int(input()) y = N % 15 * 200 x = N * 800 print(x - y)
p02658
s787852968
Accepted
n = int(input()) res = 1 a = list(map(int,input().split())) if 0 in a: print(0) else: for i in range(n): res *= a[i] if res > 10**18: print(-1) quit() print(res)
p02731
s624931028
Accepted
L = int(input()) print((L / 3) ** 3)
p02767
s485712960
Accepted
n = int(input()) x = list(map(int, input().split())) min_cnt = 10000000 for p in range(1, 100): cnt = 0 for i in range(n): cnt += (p - x[i])**2 if min_cnt > cnt: min_cnt = cnt print(min_cnt)
p02860
s043019681
Accepted
N=int(input()) S=list(input()) a1=[i for i in range(0,(N//2))] a2=[i for i in range((N//2),N)] a3=[S[i] for i in a1] a4=[S[i] for i in a2] print('Yes' if a3==a4 else 'No')
p03030
s426290352
Accepted
N = int(input()) lst = [] for i in range(N): s, p = input().split() lst.append([s, int(p), i+1]) lst = sorted(lst, key = lambda x: x[1], reverse=True) lst = sorted(lst, key = lambda x: x[0]) for j in range(N): print(lst[j][2], end=" ")
p02786
s394927503
Accepted
H=int(input()) count=0 while H!=0: count += 1 H //= 2 print(2**count-1)
p03624
s857033208
Accepted
s = str(input()) a = "abcdefghijklmnopqrstuvwxyz" count = 0 n = 0 for i in range(len(a)): for j in range(len(s)): if a[i] == s[j]: count += 1 break if count == 0: ans = a[i] print(ans) n = 1 break else: count = 0 if n == 0: print("N...
p03345
s090328364
Accepted
a, b, c, k = [int(w) for w in input().split()] print(a - b if k % 2 == 0 else b - a)
p02833
s681445954
Wrong Answer
n = int(input()) if n == 0: print(0) if n == 1: print(0) else: if n % 2 ==1: print(0) else: ans = 0 i = 1 while True: ans_plus=n//(2*5**i) if ans_plus==0: break ans += ans_plus i += 1 pr...
p03592
s309887129
Wrong Answer
import math N,M,K = map(int,input().split()) list = [0 for i in range(N*M+1)] i = 0 while i < M: list[N*i]=1 list[N*i+(M-2*i)]=1 i+=1 j = 0 while j < N: list[M*j]=1 list[M*j+(N-2*j)]=1 j+=1 if list[K] ==1: print("Yes") else: print("No")
p03730
s134967519
Accepted
a,b,c=map(int,input().split()) flag=0 for i in range(b): if (a*(i+1)%b==c): print("YES") flag=1 break if (flag==0): print("NO")
p03745
s715212195
Accepted
N = int(input()) A = list(map(int,input().split())) up = dn = False ans = 1 p = A[0] for a in A: if p < a: up = True elif p > a: dn = True if up and dn: ans += 1 up = dn = False p = a print(ans)
p02873
s632230060
Wrong Answer
S = input() tmp1 = [0 for _ in range(len(S)+1)] tmp2 = [0 for _ in range(len(S)+1)] for i in range(len(S)): if S[i] == '>': tmp1[i] = 1 else: tmp2[i+1] = 1 for i in range(1, len(S)+1): if tmp1[-i-1] != 0: tmp1[-i-1] = tmp1[-i] + tmp1[-i-1] for i in range(2, len(S)): if tmp2[i] != 0: tmp2[i] ...
p02647
s121408254
Wrong Answer
import math N,K = map(int,input().split()) A = list(map(int,input().split())) for j in range(min(K,int(math.log2(N)+2))): B = [0]*N for i in range(N): l = max(0,i-A[i]) r = min(N-1,i+A[i]) B[l] += 1 if r < N-1: B[r+1] -= 1 for i in range(1,N): B[i] += B[i-1] A = B print(' '.join(map(str,A)))
p03435
s448381127
Wrong Answer
ans = 0 for _ in range(3): c = list(map(int, input().split())) ans += sum(c) if ans % 3 == 0: print("Yes") else: print("No")
p02708
s104576712
Accepted
N,K = map(int,input().split()) sum_ans = 0 #get "ruisekiwa" c_sum = [0]*(N+2) for i in range(N+1): c_sum[i+1]+=c_sum[i]+i for i in range(K,N+2): sum_ans+= ((c_sum[N+1]-c_sum[N+1-i])-(c_sum[i]-c_sum[0])+1) print(sum_ans%(10**9+7))
p04012
s320057508
Wrong Answer
w=input() l='ABCDEFGHIJKLMNOPQRSTUVWXYZ' if len(w)%2!=0: print('No') else: for i in range(26): if w.count(l[i])%2!=0: print('No') break else: continue print('Yes')
p02719
s051423310
Accepted
i = list(map(int, input().split())) j = i[0] % i[1] k = i[1] -j print(min(j,k))
p02829
s722559471
Wrong Answer
a,b=input(),input() for i in range(1,4): if i is (not a or b): print(i)
p03284
s460116813
Accepted
from sys import stdin A, B = [int(x) for x in stdin.readline().rstrip().split()] if A%B==0: print(0) else: print(1)
p03377
s026849957
Accepted
a,b,x=map(int,input().split()) print("YES"if a<=x and a+b>=x else "NO")
p02732
s281156960
Wrong Answer
N = int(input()) A = list(map(int, input().split())) count = [0] * 200005 for a in A: count[a] += 1 s = 0 for c in count: s += c * (c - 1) // 2 print(s) for a in A: c = count[a] x = c * (c - 1) // 2 c -= 1 y = c * (c - 1) // 2 print(s - x + y)
p03774
s823025697
Accepted
N, M = map(int, input().split()) A = [list(map(int, input().split())) for _ in range(N)] C = [list(map(int, input().split())) for _ in range(M)] for a in A: distance = 10**9 point = 0 for i, c in enumerate(C): if abs(a[0] - c[0]) + abs(a[1] - c[1]) < distance: distance = abs(a[0] - c[0...
p02660
s045297155
Wrong Answer
def prime(p): memo = [] for i in range(2,(int(p**0.5)+1)): jousu = 1 while p%(i**jousu)==0: p //= i**jousu memo.append(i**jousu) jousu += 1 if p != 1: memo.append(p) return memo n=int(input()) memo = prime(n) memo = set(memo) if len(memo)...
p02624
s566244726
Wrong Answer
N = int(input()) lst = [0]*N for i in range(1,N+1): for j in range(1,N+1): if j % i == 0: lst[j-1] += j print(lst) print(sum(lst))
p03107
s511793364
Accepted
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 s=input() z=s.count("0") o=s.count("1") print(min(z,o)*2) main()
p02783
s946646550
Wrong Answer
import math h,a=map(int,input().split()) print (math.floor(h/a))
p03592
s365962312
Wrong Answer
n,m,k = map(int,input().split()) if k>n and k > m: print("No") else: print("Yes")
p03261
s300721304
Wrong Answer
n = int(input()) l = [input() for _ in [0]*n] print(l) if len(set(l)) != n: print('No') else: for i in range(n-1): print(i) print(list(l[i])[-1]) print(list(l[i+1])[0]) if list(l[i])[-1] != list(l[i+1][0]): print('No') #else: #print('Noo') ...
p04045
s062437657
Wrong Answer
N,K = list(map(str, input().split())) D = sorted(input().split()) W = [] P = "" for i in range(10): if str(i) not in D: W.append(str(i)) for i in range(len(N)): for j in range(len(W)): if N[i] <= W[j]: P += W[j] break if i == 0 and P == "": if W[0] == "0": ...
p02924
s785962877
Accepted
n=int(input()) ans=n*(n-1)//2 print(ans)
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)
p02957
s441104493
Accepted
A, B = map(int, input().split()) if (A+B)%2 == 0: print(int((A+B)/2)) else: print("IMPOSSIBLE")
p02860
s001461389
Wrong Answer
def solve(): N = int(input()) S = input() if N % 2 == 0: if S[:(N//2)] == S[(N//2):]: print(S[:(N//2+1)]) print(S[(N//2):]) print('Yes') else: print('No') else: print('No') if __name__ == '__main__': solve()
p03345
s387778450
Accepted
A,B,C,K = map(int, input().split()) limit = 1e18 if abs(A-B)>=limit: print('Unfair') else: if K%2==0: print(A-B) else: print(B-A)
p03013
s723903236
Accepted
MOD = 10**9 + 7 import sys input = sys.stdin.readline n, m = map(int, input().split()) a = [0] * (n + 1) for _ in range(m): a[int(input())] = 1 # i段目にたどり着く方法 dp = [0] * (n + 1) dp[0] = 1 dp[1] = 1 if a[1] == 0 else 0 for i in range(2, n+1): dp[i] = (dp[i-1] + dp[i-2]) % MOD if a[i] == 0 else 0 print(dp[-1]...
p03261
s126362235
Wrong Answer
n = int(input()) s = set() ok = True t = input() p = t[-1] for i in range(n-1): t = input() if t in s: ok = False s.add(t) if t[0] != p: ok = False p = t[-1] print('Yes' if ok else 'No')
p04033
s031777801
Accepted
a, b = map(int, input().split()) if a * b <= 0: print("Zero") elif a > 0: print("Positive") else: if (b - a) % 2 == 0: print("Negative") else: print("Positive")
p02594
s876782941
Accepted
x = int(input()) if x < 30: print("No") else: print("Yes")
p02773
s817326297
Wrong Answer
from collections import Counter n = int(input()) s = [] for _ in range(n): s.append(str(input())) s_c = Counter(s).most_common() m = s_c[0][1] print(s_c) print(m) ans = [] for j in range(len(s_c)): if s_c[j][1] != m: break else: ans.append(s_c[j][0]) ans.sort() for k in ans: ...
p02792
s907952631
Accepted
n = int(input()) ans = 0 def solve(x): df = str(x)[0] dl = str(x)[-1] return df, dl numMap = {} for i in range(1, n+1): # print(i) # print(solve(i)) pair = solve(i) if pair in numMap: numMap[pair] += 1 else: numMap[pair] = 1 for i in range(1, n+1): key = solve(i) ...
p02917
s745381203
Wrong Answer
N = int(input()) B = list(map(int,input().split())) A = [] A.append(B[0]) A.append(B[0]) for i in range(1, N - 2): if B[i] < A[i]: A[i] = B[i] if N != 2: A.append(B[i]) print(sum(A))
p02817
s631378725
Accepted
S,T=input().split() print(T,S,sep='')
p02791
s453586499
Accepted
n = int(input()) p = list(map(int,input().split())) ans = 0 tmp = 2*10**5+1 for i in range(n): if tmp > p[i]: ans+=1 tmp = p[i] if p[i]==1: break print(ans)
p03286
s701471730
Accepted
n = int(input()) b = '' while n: b = str(n%2)+b n = -(n//2) print(b if b else 0)
p03251
s183319503
Accepted
N, M, X, Y = map(int, input().split()) XL = list(map(int, input().split())) + [X] YL = list(map(int, input().split())) + [Y] XL.sort() YL.sort(reverse=True) xt = XL.pop() yt = YL.pop() if xt < yt: print('No War') else: print('War')
p03644
s418579128
Wrong Answer
"""Boot-camp-for-Beginners_Easy011_B_Collatz-Problem_29-August-2020.py""" import numpy as np N = 100 # N=int(input()) Division_2 = [] number=[] for i in range(1, N+1): j = i count = 0 while True: count += 1 j = j/2 if j/2 != int(j/2): break Division_2.append(count) ...
p02835
s473423921
Accepted
a1, a2, a3 = map(int, input().split()) if a1 + a2 + a3 >= 22: print('bust') else: print('win')
p02842
s995626778
Accepted
# sumitb2019_b_bacha.py N = int(input()) for i in range(50000): if int(i*1.08) == N: print(i) exit() print(":(")
p04044
s047225546
Wrong Answer
n,l = map(int,input().split()) for i in range(n): s = sorted([input()]) print(*s,sep="")
p02910
s063777981
Accepted
s=list(input()) if 'L' in s[::2] or 'R' in s[1::2]: print('No') else: print('Yes')
p03611
s453422715
Accepted
import collections n=int(input()) a=list(map(int,input().split())) for i in range(n): a.append(a[i]+1) a.append(a[i]-1) c = collections.Counter(a) print(c.most_common()[0][1])
p03211
s061652654
Accepted
s=input() ans=999 for i in range(len(s)-2): t=int(s[i:i+3]) ans=min(ans,abs(753-t)) print(ans)
p02696
s638402260
Accepted
A,B,N = map(int,input().split()) m = 0 if B-1 >=N: print(int(A*N/B)-A*int(N/B)) else: print(int(A*(B-1)/B)-A*int((B-1)/B))
p02623
s706819293
Accepted
n, m, k = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) As = [0] * (n + 1) Bs = [0] * (m + 1) for i in range(n): As[i + 1] = A[i] + As[i] for i in range(m): Bs[i + 1] = B[i] + Bs[i] l = 0 r = n + m + 1 while r - l > 1: p = (l + r) // 2 best = k + 1 for i i...
p03126
s546894224
Accepted
# B n, m = map(int, input().split()) count = [0]*m for i in range(n): a = list(map(int, input().split())) for j in range(1, a[0]+1): count[a[j]-1] += 1 print(count.count(n))
p03679
s072838533
Accepted
x, a, b = (int(i) for i in input().split()) n = b - a if n <= 0: print('delicious') elif n <= x: print('safe') else: print('dangerous')
p02663
s294988269
Accepted
s = list(map(int,input().split())) h = 60 * (s[2]-s[0]) m = s[3] - s[1] k = s[4] print(h+m-k)
p03657
s278599296
Accepted
a,b=map(int,input().split()) print("Possible" if ((a+b)%3==0 or a%3==0 or b%3==0) else "Impossible")
p03657
s378690336
Accepted
import sys input = sys.stdin.readline A, B = [int(x) for x in input().split()] if A % 3 == 0 or B % 3 == 0 or (A + B) % 3 == 0: print("Possible") else: print("Impossible")
p02819
s999071369
Accepted
def is_prime(n): if n==1: return False else: for i in range(2, int(n**0.5)+1): if n % i == 0: return False return True x = int(input()) while not is_prime(x): x += 1 print(x)
p02707
s494005127
Accepted
N = int(input()) list_A = list(map(int,input().split())) B = [0]*N for a in list_A: B[a-1] += 1 for i in range(N): print(B[i])
p03524
s116683674
Accepted
from collections import Counter lst = list(input()) c = Counter(lst) A = c['a'] B = c['b'] C = c['c'] if max(max(A, B), C) - min(min(A, B), C) <= 1: print ('YES') else: print ('NO')
p02793
s062049477
Wrong Answer
N=int(input()) A=list(map(int,input().split())) import fractions ans=A[0] for i in range(1,N): ans=ans*A[i]//fractions.gcd(ans,A[i]) ans%=(10**9+7) w=0 for i in A: w+=(ans//i)%(10**9+7) print(w)
p03854
s607020882
Accepted
s = input() i = len(s) while i > 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')
p02995
s997752386
Accepted
import sys import math A,B,C,D = map(int, input().split()) def lcm(x, y): return (x * y) // math.gcd(x, y) maru1 = B // C maru2 = (A-1) // C maru3 = B // D maru4 = (A-1) // D maru5 = B // lcm(C,D) maru6 = (A-1) // lcm(C,D) ans_tmp = ((maru1-maru2)+(maru3-maru4)) - (maru5-maru6) ans = (B-A+1) - ans_tmp print(...
p03438
s190388416
Wrong Answer
n,*a=map(int,open(0).read().split()) print("Yes" if sum(j-i if j-i>0 else 2*(j-i)for i,j in zip(a[:n],a[n:]))>=0 else "No")
p03657
s793678452
Accepted
#k = int(input()) #s = input() #a, b = map(int, input().split()) #s, t = map(str, input().split()) #l = list(map(int, input().split())) #l = [list(map(int,input().split())) for i in range(n)] #a = [list(input()) for _ in range(n)] #a = [int(input()) for _ in range(n)] a,b = map(int, input().split()) if (a%3==0 or b%3...
p03494
s561966708
Accepted
input() A = list(map(int, input().split())) count = 0 while all(a % 2 == 0 for a in A): A = [a/2 for a in A] count += 1 print(count)
p02697
s764224688
Wrong Answer
N, M = map(int, input().split()) if N % 2 == 0: print(1, 1 + N // 2) for m in range(M): if m % 2 == 0: print(m + 2, N // 2 - m) else: print(N // 2 + m, N - m) else: for m in range(M): print(m + 1, N - m)
p03449
s143560540
Wrong Answer
n = int(input()) a = [int(x) for x in input().split()] b = [int(x) for x in input().split()] res = 0 for i in range(n): c = 0 for j in range(n): if j <= i: c += a[j] else: c += b[j] res = max(res,c) print(res)
p02786
s373093854
Accepted
import math H = int(input()) count = 0 attack = 0 while H >= 1: H = H/2 count += 1 for num in range(count): attack = attack + 2**num print(attack)
p02814
s546943127
Accepted
import fractions import sys input = sys.stdin.readline def gcd(a, b): if b == 0: return a return gcd(b, a%b) n,m = map(int,input().split()) a = list(map(int,input().split())) g = a[0] for i in range(1, n): g = g * a[i] // gcd(g, a[i]) for i in a: if g // 2 % i == 0: print(0) ...
p02768
s183950790
Accepted
n, a, b = map(int, input().split()) mod = 10**9 + 7 def calculate_combination(n, k): x, y = 1, 1 for i in range(k): x = x * (n-i) % mod y = y * (k-i) %mod return x * pow(y, mod-2, mod) % mod ans = pow(2, n, mod)-1 - calculate_combination(n, a) - calculate_combination(n, b) while ans < 0: ...
p03417
s449414176
Wrong Answer
# input N, M = map(int, input().split()) # check if 2 in [M, N] or N == M == 1: print(0) elif 1 in [M, N]: print(N * M - 2) else: print(N * M - (2 * (N + M) - 4))