problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p03860
s602669153
Accepted
s = input().split()[1] result = 'A{}C'.format(s[0]) print(result)
p03105
s276049459
Accepted
def main(): a, b, c = map(int, input().split()) total = b // a if total > c: print(c) else: print(total) main()
p02646
s664753581
Wrong Answer
a,v = map(int,input().split()) b, w= map(int,input().split()) t = int(input()) A = a+(t*v) B = b+(t*w) if a == b: print('YES') elif a < b: if B < A: print('YES') else: print('NO') else: A = a-(t*v) B = b-(t*w) if A <= B: print('YES') else: print('NO')
p02953
s171592516
Wrong Answer
def main(): n = int(input()) arr = list(map(int,input().split())) for i in range(len(arr)-1): if arr[i]>arr[i+1]: arr[i]-=1 for i in range(len(arr)-1): if arr[i]>arr[i+1]: print("No") return print("Yes") return main() # 1 2 3 4 5 # 1 3 3 4 5 # 1 4 3 4 5
p03076
s206039045
Wrong Answer
menu=[] menu2=[] total=False c=0 total2=0 for i in range(5): a=int(input()) menu.append(a) menu2.append(a%10) if a%10==0: total2+=1 for i in range(1,10): for k in range(5): if menu2[k]==i: total=True c=k break if total==True: break prin...
p02693
s317917516
Wrong Answer
K = int(input()) A, B = [int(i) for i in input().split()] if B // K - A // K >= 1: print("Yes") else: print("No")
p02743
s531367403
Accepted
a, b, c = map(int, input().split()) if 4*a*b < (c-a-b)**2 and c-a-b > 0: print('Yes') else: print('No')
p03605
s864499876
Wrong Answer
N = str(input()) if "9" in N: ans = "YES" else: ans ="NO" print(ans)
p02687
s302092061
Accepted
S = input() if S == "ABC": print("ARC") else: print("ABC")
p03043
s055108159
Wrong Answer
n,K = map(int,input().split()) p = min(n,K-1) ans = 0 chk = [1]*(K-1) k = K for i in range(14): k /= 2 if k == int(k): q = int(k*2-k-1) else: q = int(k*2-k) for i in range(q): chk[i] += 1 if k <= 1: break #print(chk) for i in range(p): ans += float(1/(2**chk[i]*n)) #print(ans) ans += ...
p02555
s093634763
Accepted
s=int(input()) mod = 10**9+7 dp = [0]*(s+1) dp[0] = 1 x = 0 for i in range(1,s+1): if i-3>=0: x += dp[i-3] x %= mod dp[i]=x print(dp[s])
p02861
s287401658
Accepted
from itertools import permutations N = int(input()) lx, ly = [], [] for _ in range(N): xi, yi = list(map(int, input().split())) lx.append(xi) ly.append(yi) fN = 1 for i in range(1, N + 1): fN *= i mcost = 0 for x in permutations(list(range(N))): cost = 0.0 for i in range(len(x) - 1): ...
p03493
s481993396
Wrong Answer
nums = list(map(int, input().split())) print(nums.count(1))
p02823
s418158254
Accepted
N,A,B=map(int,input().split()) if (B-A)%2: print(min(A-1,N-B)+1+(B-A-1)//2) else: print((B-A)//2)
p02897
s547637369
Accepted
N=int(input()) if N%2==0: print(float(1/2)) else: print(float(1-(N-1)/2/N))
p02778
s251106505
Accepted
S = str(input()) list_S = list(S) length = len(list_S) xxx = ["x"] * len(list_S) print("".join(xxx))
p02951
s740292108
Accepted
A,B,C=map(int,input().split()) if C-(A-B)<=0: print(0) else: print(C-(A-B))
p02700
s757006986
Accepted
A,B,C,D = list(map(int,input().split())) T = -(-C//B) AO = -(-A//D) print('Yes' if T<=AO else 'No')
p03262
s147698370
Wrong Answer
import math d=10**5+1 n,x=map(int, input().split()) a=[int(x) for x in input().split()] a.append(x) a.sort() for i in range(n-1): D=math.gcd(a[i+1]-a[i],a[i+2]-a[i]) if D<d: d=D if x==1: d=abs(a[1]-a[0]) print(d)
p02708
s882610400
Wrong Answer
list = input().split() N = int(list[0]) K = int(list[1]) i = K s = 0 def sum(a,b): i=0 i = (a + b)*(b - a + 1)/2 return i while i <= N + 1: #print(sum(N-i+1,N) + sum(0,i-1)) s = s + sum(N-i+1,N) - sum(0,i-1) + 1 i += 1 print(s)
p02555
s573867826
Accepted
from sys import stdin import math def combinations_count(n, r): # print(n) # print(r) return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)) S = int(stdin.readline().rstrip()) if S < 3: print(0) else: x = S // 3 y = S % 3 count = 0 for i in range(x): j = i...
p03624
s080457318
Accepted
s = input() res = "abcdefghijklmnopqrstuvwxyz" for i in range(len(s)): res = res.replace(s[i], "") if len(res) == 0: print("None") else: print(res[0])
p03544
s987698983
Accepted
import sys def I(): return int(sys.stdin.readline().rstrip()) N = I() L = [] for i in range(N+1): if i == 0: L.append(2) elif i == 1: L.append(1) else: L.append(L[-1]+L[-2]) print(L[-1])
p03611
s087287598
Accepted
from collections import Counter n = int(input()) a = Counter(list(map(int, input().split()))) ans = 0 for x,y in a.items(): cnt = y if x-1 in a: cnt += a[x-1] if x+1 in a: cnt += a[x+1] if cnt > ans: ans = cnt print(ans)
p03438
s494830238
Accepted
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) n = int(readline()) a = list(map(int, readline().split())) b = list(map(int, read().split())) cnt = 0 for aa, bb in zip(a, b): v = bb - aa if bb > aa: v //=...
p04029
s796031932
Wrong Answer
n = int(input()) answer = (n + 1) * n / 2 print(answer)
p03612
s389159482
Wrong Answer
n = int(input()) p = list(map(int, input().split())) ans = 0 c = 0 for i in range(n): if p[i] == i+1: c += 1 if p[i] != i+1: if c > 1: ans += c - 1 elif c == 1: ans += c c = 0 if c == n: ans += c- 1 print(ans)
p03592
s955378161
Wrong Answer
n, m, k = map(int, input().split()) for i in range(n): for j in range(m): if i * m + (n - 2 * i) * j == k: print("Yes") exit() print("No")
p02946
s776574892
Accepted
k,x=map(int,input().split()) for i in range(x-k+1,x+k): print(i, end=" ")
p02718
s721848293
Accepted
n,m = map(int,input().split()) li = list(map(int,input().split())) soutouhyou = sum(li) tokuhyou = soutouhyou/(4*m) num = sum(x >= tokuhyou for x in li) if num >= m: print("Yes") else: print("No")
p02818
s385435975
Wrong Answer
a,b,k=map(int,input().split()) print(a-k,b) if a>=k else print(0,a+b-k)
p02664
s787359846
Accepted
str_list = list(input()) for i in range(len(str_list)): if(str_list[i] == "?"): str_list[i] = "D" o_str = "".join(str_list) print(o_str)
p03210
s972921714
Wrong Answer
X = int(input()) if X == 3 or X == 5 or X == 7: print("Yes") else: print("No")
p02933
s688118707
Accepted
a = int(input()) s = input() if a >= 3200: print(s) elif a < 3200: print("red")
p03250
s557955031
Accepted
li = sorted(list(map(int, input().split()))) print(li[2]*10+li[0]+li[1])
p03795
s107139018
Accepted
a=int(input()) print(a*800-a//15*200)
p03435
s726803588
Wrong Answer
List=0 for i in range(3): List+=sum(list(list(map(int, input().split())))) #print(List) if List%3==0 : print('Yes') else: print('No')
p03137
s014114049
Accepted
N,M = map(int,input().split()) X = list(map(int,input().split())) x = [] ans = 0 X.sort() if N >= M: print(0) exit() for i in range(M-1): x.append(abs(X[i]-X[i+1])) xx = sorted(x,reverse=True) for j in range(N-1): xx[j] = 0 ans = sum(xx) print(ans)
p02687
s512405410
Accepted
S = input() if S =='ABC': print('ARC') else: print('ABC')
p04005
s704185010
Accepted
A, B, C = map(int, input().split()) S = A * B * C long = max(A, B, C) S //= long diff = S if long % 2 != 0 else 0 print(diff)
p02910
s191317298
Accepted
li = list(input()) lik = li[1::2] lig = li[0::2] a = 0 b = 0 if 'L' in lig: a = a + 1 if 'R' in lik: b = b + 1 if a + b == 0: print('Yes') else: print('No')
p02699
s930508823
Accepted
S,W = map(int,input().split()) if W >= S: print('unsafe') else: print('safe')
p02618
s612008387
Wrong Answer
D=int(input()) C=list(map(int,input().split())) S=[list(map(int,input().split())) for i in range(D)]
p02603
s362448147
Accepted
N = int(input()) As = list(map(int, input().split())) money = 1000 for i in range(1, N): if As[i] > As[i-1]: n = money // As[i-1] money = money - (As[i-1] * n) + (As[i] * n) print(money)
p02594
s336888541
Wrong Answer
K = int(input()) x = 7 count = 1 if K % 2 == 0: print("-1") exit(0) for i in range(10**5): if x % K == 0: print(count) exit(0) else: x = 10*x + 7 count += 1 print("-1")
p02882
s132934510
Accepted
from math import degrees,atan2 a,b,x=map(int,input().split()) if a**2*b/2>=x: height=2*x/(a*b) print(degrees(atan2(b,height))) else: height=2*(a**2*b-x)/a**2 print(degrees(atan2(height,a)))
p03481
s681327637
Accepted
import math x,y = map(int,input().split()) tmp = 1 while x*(2**tmp) <= y: tmp += 1 print(tmp)
p02801
s910169338
Wrong Answer
alph = input() print(ord(alph)+1)
p02971
s799872966
Wrong Answer
n = int(input()) A = [] for _ in range(n): A.append(int(input())) m = max(A) c = A.count(m) if c == 1: m2 = sorted(set(A))[1] for i in A: print (m) if i != m else print(m2) else: for _ in range(n): print (m)
p03645
s653923737
Accepted
N,M = map(int, input().split()) A = [[] for i in range(N)] for i in range(M): a,b = map(int, input().split()) a -= 1 b -= 1 A[a].append(b) A[b].append(a) if len(A[0])+len(A[-1]) != len(set(A[0]+A[-1])): print("POSSIBLE") else: print('IMPOSSIBLE')
p02684
s541487842
Accepted
n,k = map(int,input().split()) a_list = list(map(int,input().split())) a = 0 t = 1 d = 0 hoge_list = [] hoge_set = set() while a < k: hoge_list.append(t) hoge_set.add(t) t = a_list[t-1] a += 1 if t in hoge_set: b = hoge_list.index(t) d += 1 break if d == 0: print(t) else: e = (k-b)%(a-b) pri...
p03448
s745111934
Wrong Answer
from itertools import product import numpy as np a = int(input()) b = int(input()) c = int(input()) x = int(input()) a = ', '.join([str(sum(el)) for el in product( np.arange(a+1)*500, np.arange(b+1)*100, np.arange(c+1)*50 )]) + ', ' print(a.count( ', {},'.format(x)...
p04029
s452784567
Accepted
n = int(input()) sum=0 for i in range(1,n+1): sum+=i print(sum)
p02675
s699252026
Accepted
m = int(input())%10 if m in [2,4,5,7,9]: print("hon") elif m in [0,1,6,8]: print("pon") else: print("bon")
p03910
s258239597
Accepted
import math N = int(input()) while N>=1: max = math.ceil((-1+(1+8*N)**0.5)/2) print(max) N -= max
p03385
s571391705
Accepted
s = list(input()) s.sort() print('Yes'if s[0] == 'a' and s[1] == 'b' and s[2] == 'c' else 'No')
p03351
s481578254
Wrong Answer
a, b, c, d = map(lambda x: int(x), input().split()) if a - c <= d: print('Yes') elif abs(a - b) <= d and abs(b - c) <= d: print('Yes') else: print('No')
p02577
s026751115
Accepted
n = str(input()) num = 0 for i in range(len(n)): num += int(n[i]) if num % 9 == 0: print("Yes") else: print("No")
p04034
s200173425
Wrong Answer
n, m = map(int,input().split()) box = [[1,0] for i in range(n)]#個数、赤の可能性 box[0][1] = 1 ans = 1 for i in range(m): x, y = map(int,input().split()) if box[x-1][0] == 0: continue box[x-1][0] -= 1 box[y-1][0] += 1 if box[x-1][1] == 1: if box[y-1][1] == 0: box[y-1][1] = 1 ...
p03211
s077563845
Accepted
S = list(input()) k = 100000000000000000000 for i in range(len(S)-2): k = min(k, abs(753-(100*int(S[i])+10*int(S[i+1])+int(S[i+2])))) print(k)
p02888
s471762122
Accepted
import sys import bisect N = int(input()) L = list(map(int, input().split())) LS = sorted(L) ans = 0 for i in range(N): for j in range(N): if i < j: index = bisect.bisect_left(LS,LS[i]+LS[j]) ans += index-j-1 print(ans)
p03371
s720466490
Accepted
A, B, C, X, Y = map(int, input().split()) if X >= Y: ans = min(A*X + B*Y, 2*C*Y + A*(X-Y), 2*C*X) else: ans = min(A*X + B*Y, 2*C*X + B*(Y-X), 2*C*Y) print(ans)
p02742
s001305808
Wrong Answer
#!/usr/bin/env python3 h, w = map(int, input().split()) print(((h + 1) // 2) * ((w + 1) // 2) + (h // 2) * (w - ((w + 1) // 2)))
p03838
s842532264
Accepted
import numpy as np xx, yy = map(int, input().split()) B = [(0, 0), (1, 0), (0, 1), (1, 1)] ans = float("inf") for i, j in B: x, y = xx, yy # print(f"i, j, {i}{j}") if i: x *= -1 if j: y *= -1 if y >= x: ans = min(ans, y-x + i + j) # print(ans) print(ans)
p02664
s467761466
Accepted
from sys import stdin import math a=stdin.readline() for k in range(0,len(a)): if a[k]=='?': print('D',end='') else: print(a[k],end='')
p04044
s547788303
Wrong Answer
N, L, *inputs = input().split() inputs.sort() "".join(inputs) print(inputs);
p02727
s337623177
Accepted
X,Y,A,B,C = map(int,input().split()) p = list(map(int,input().split())) q = list(map(int,input().split())) r = list(map(int,input().split())) p.sort(reverse=True) q.sort(reverse=True) r.sort(reverse=True) alist = [] ans = 0 for i in range(X): alist.append(p[i]) for j in range(Y): alist.append(q[j]) ...
p03208
s801724929
Accepted
N,K = map(int, input().split()) h = [] for _ in range(N): h.append(int(input())) h.sort() min = float("inf") for i in range(N-K+1): temp = h[K+i-1]-h[i] if min > temp: min = temp print(min)
p02911
s964925933
Wrong Answer
n, k, q = map(int, input().split()) #print(n,k,q) l = [0] * n #print(l) katen = [0] * q my_append = katen.append for i in range(q): my_append(int(input())) #print(katen) my_pop = l.pop my_insert = l.insert for j in katen: x = my_pop(j-1) my_insert(j-1, x+1) #print(l) for y in range(n): if l[y] > q-k:...
p03126
s108858304
Wrong Answer
N,M = map(int,list(input().split())) i_list = [0]*M for i in range(N): s = list(input().split()) for j in range(int(s[0])): i_list[int(s[j])-1] += 1 counter = 0 for i in range(M): if i_list[i] == N: counter += 1 print(counter)
p02791
s095516759
Accepted
n=int(input()) a=list(map(int, input().split())) mi = n+2 ans = 0 for i in a: if mi > i: ans+=1 mi=min(i,mi) print(ans)
p02939
s862717362
Accepted
import sys def S(): return sys.stdin.readline().rstrip() S = S() ans = 1 compared = S[0] now = '' for x in S[1:]: now += x if compared!=now: ans +=1 compared = now now = '' print(ans)
p03086
s903243390
Accepted
S = input() man = 0 cnt = 0 l = ['A', 'C', 'G', 'T'] for s in S: res = False for i in l: if s == i: cnt += 1 res = True if res == False: cnt = 0 if man < cnt: man = cnt print(man)
p03075
s684999092
Wrong Answer
n=list([i for i in range(5)]) a=int(input()) b=0 for i in n: if i==i: break elif i-i<0: break elif i-i>k: b+=1 if b>0: print(':(') else: print('Yay!')
p03472
s257502294
Accepted
def main(): from math import ceil n, h, *ab = map(int, open(0).read().split()) *c, = map(lambda x: -x, ab[::2]) d = sorted(c + ab[1::2], key=abs, reverse=True) ans = 0 for x in d: if x < 0: ans += ceil(h / abs(x)) break h -= x ans += 1 if...
p03136
s819551811
Accepted
N=int(input()) L=list(map(int,input().split())) A=sorted(L) if A[-1]<(sum(A))-A[-1]: print("Yes") else: print("No")
p02583
s640696137
Wrong Answer
n = int(input()) arr = [int(x) for x in input().split()] s = len(arr) cnt = 0 if s == 1 or s == 2: print(0) else: for i in (0,s - 2): for j in (i, s - 1): for k in (j, s): l = [] l.append(i) l.append(j) l.append(k) l.sort() i = l[2] j = l[1] ...
p02684
s503330941
Accepted
N,K = map(int,input().split()) A = list(map(int,input().split())) counter = 0 place_list = [] place_set = set() next = 1 while True: if next in place_set: break else: place_list.append(next) place_set.add(next) next = A[next-1] counter += 1 duration_...
p03548
s833836914
Wrong Answer
import sys input = sys.stdin.readline x,y,z=list(map(int,input().split())) print((x+z)//(y+z))
p03127
s591283634
Wrong Answer
from fractions import gcd n = int(input()) l = list(map(int, input().split())) x = 0 for i in range(n-1): x = gcd(x,l[i]) print(x)
p04030
s696386157
Accepted
s = input() a = "" for i in range(len(s)): if s[i] == "B": a = a[:-1] else: a += s[i] print(a)
p03659
s167885846
Accepted
N = int(input()) A = list(map(int, input().split())) arai = sum(A) sunuke = 0 ans = 10**10 for i in range(0, N-1): sunuke += A[i] arai -= A[i] ans = min(ans, abs(sunuke - arai)) print(ans)
p03163
s186379467
Accepted
N,W = map(int,input().split()) goods = [list(map(int,input().split())) for _ in range(N)] dp = [[0 for _ in range(W)] for _ in range(N)] for i,[w,v] in enumerate(goods): for j in range(W): if i == 0: if j >= goods[0][0]-1: dp[0][j] = goods[0][1] else: if w <= j: dp[i][j] = max(v+...
p02923
s103571366
Wrong Answer
def main(): n = int(input()) h = list(map(int, input().split())) res = 0 for i in range(n-1): if h[i] < h[i+1]: res = i+1 if res+1 == n: print(0) else: print(n-(res+1)) if __name__ == '__main__': main()
p03137
s754796039
Wrong Answer
N, M = map(int, input().split()) x = sorted(map(int, input().split())) if N >= M: print(0) diff = [0]*(M-1) for i in range(M-1): diff[i] = x[i+1] - x[i] diff.sort() ans = sum(diff[:M-N]) print(ans)
p03481
s573913001
Accepted
X, Y = map(int, input().split()) n = 1 while True: X *= 2 if X <= Y: n += 1 else: break print(n)
p03861
s912221426
Accepted
a,b,x = map(int,input().split()) def count(c): if c==0: return 0 return c//x print(count(b)-count(a-1))
p02727
s258590975
Accepted
X, Y, A, B, C = map(int, input().split()) p = list(map(int, input().split())) q = list(map(int, input().split())) r = list(map(int, input().split())) p.sort() p.reverse() q.sort() q.reverse() new = p[0:X] + q[0:Y] + r new.sort() new.reverse() print(sum(new[0:X+Y]))
p03282
s105693698
Accepted
S = input() K = int(input()) ans = 1 for i in S: if i != '1': ans = i break if K==1: ans = i break K-=1 print(ans)
p02678
s209396647
Accepted
from collections import deque N, M = map(int, input().split()) ways = [[] for i in range(N)] for i in range(M): a, b = map(int, input().split()) a -= 1 b -= 1 ways[a].append(b) ways[b].append(a) searched = [0 for i in range(N)] searched[0] = 1 ans = [0 for i in range(N)] d = deque([]) d.append(0) while d: t...
p03252
s341350672
Accepted
import collections s1=input() s2=input() s1 = list(s1) s2 = list(s2) s11 = collections.Counter(s1) s22 = collections.Counter(s2) if len(s11) != len(s22): print('No') exit() for i in range(len(s11)): if s11.most_common()[i][1] != s22.most_common()[i][1] : print('No') exit() print('Yes')
p03951
s101111381
Accepted
n = int(input()) s = str(input()) t = str(input()) for i in range(n): s_ = s[i:] t_ = t[:n-i] if s_ == t_: print(n+i) exit() else: print(2*n)
p02594
s631557443
Accepted
X = int(input()) if X >=30 : print("Yes") else: print('No')
p03696
s112676580
Wrong Answer
N = int(input()) X = input() mL = 0 for i in X: if i == ")": mL += 1 else: break mR = 0 for i in X[::-1]: if i == "(": mR += 1 else: break result = mL * "(" + X + mR * ")" L = len([i for i in result if i != "("]) R = len(result) - L if L > R: result = (L - R) * "(" + result else: result += (...
p03730
s132959794
Wrong Answer
A,B,C = map(int,input().split(" ")) Amod = A%B if Amod==0: if C!=0: print("NO") else: print("YES") else: i=0 while(i<=B): i+=1 c = (i%B * Amod) if (c%B==C): print("YES") break if(i>B): print("No")
p03163
s625674823
Accepted
n, w = map(int, input().split()) weights = [] profits = [] for i in range(n): x, y = map(int, input().split()) weights.append(x) profits.append(y) dp = [[0 for i in range(w+1)] for j in range(n+1)] for i in range(1, n+1): for j in range(1, w+1): if weights[i-1] <= j: dp[i][j] =...
p03705
s971975499
Accepted
n, a, b = map( int, input().split() ) if a > b: exit( print( 0 ) ) if n == 1: exit( print( 1 if a == b else 0 ) ) else: x = ( n - 1 ) * a + b y = ( n - 1 ) * b + a print( y - x + 1 )
p02683
s275904706
Wrong Answer
n, m, x = map(int, input().split()) ans = 10000001 books = [] for i in range(n): a = list(map(int, input().split())) books.append(a) for i in range(2**n): _trigger = True _sum = [0 for k in range(m+1)] for j in range(n): if ((i >> j) & 1): for k in range(m+1): _sum[k] += books[j][k] for...
p02819
s900940358
Accepted
import math x = int(input()) n = int(math.sqrt(x)) flg = True while 1: for i in range(2,n): if x % i == 0: flg = False break if flg: print(x) break else: x += 1 n = int(math.sqrt(x)) flg = True
p03565
s969231114
Wrong Answer
S = input() T = input() L = len(S) K = len(T) ans = S flag = 0 for i in range(L-1,-1,-1): for j in range(K-1,-1,-1): a = K-1-j print(S[i-a],T[j]) if i-a < 0 or (S[i-a] != "?" and S[i-a] != T[j]): break else: ans = ans[:i-K+1] + T + ans[i+K:] flag = 1 b...