problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p03107
s068389822
Wrong Answer
s=list(map(int,input().split()));print(min(s.count("0"),s.count("1")))
p02795
s915311679
Accepted
import math h = int(input()) w = int(input()) n = int(input()) if h > w: print(math.ceil(n / h)) else: print(math.ceil(n / w))
p02813
s674804318
Accepted
import itertools n = int(input()) a = tuple([int(i) for i in input().split()]) b = tuple([int(i) for i in input().split()]) l = list(itertools.permutations(range(1,n+1))) print(abs(l.index(a) - l.index(b)))
p03012
s909411676
Wrong Answer
n = int(input()) a = list(map(int, input().split())) res = 1000 for i in range(n-1): print(2*sum(a[:i])) res = min(res,abs(sum(a[:i+1])-sum(a[i+1:]))) print(res)
p02615
s569019581
Accepted
N = int(input()) A = list(map(int, input().split())) A.sort(reverse=True) ans = 0 if N >= 2: ans += A[0] if N >= 3: idx = 1 for i in range(N-2): ans += A[idx] if i % 2 == 1: idx += 1 print(ans)
p03612
s253518322
Wrong Answer
N = int(input()) P = [int(x) for x in input().split()] ans = 0 if P[0] == 1: temp = P[1] P[1] = P[0] P[0] = temp ans += 1 for i in range(1,N): if P[i] == i+1: temp = P[i] P[i] = P[i-1] P[i-1] = P[i] ans += 1 print(ans)
p02691
s998657223
Accepted
import collections N = int(input()) A = list(map(int, input().split())) B = [0 for _ in range(N)] C = [0 for _ in range(N)] for i in range(N): B[i] = i - A[i] C[i] = i + A[i] lis1 = collections.Counter(B) lis2 = collections.Counter(C) count = 0 for key, value in lis1.items(): if key in lis2: count += value *...
p02699
s827049149
Wrong Answer
def wolfgame(S,W): if 1 <= S <= W <= 100: print("unsafe") elif 1 <= W < S <= 100: print("safe") else : print("invalid")
p02724
s619567546
Accepted
X = int(input()) if X>=0 and X<=10**9: a, b = divmod(X, 500) if X >= 500: c = int(b/5) d = int(a*1000) + c*5 print(d) elif X >= 5 and X <500: c = int(X/5)*5 print(c) else: print(0)
p02820
s873684731
Accepted
def solve(): n,k = (int(i) for i in input().split()) r,s,p = (int(i) for i in input().split()) t = input() score = 0 times = 0 possible = [False]*n for i in range(n): if i >= k: if t[i-k] == t[i] and possible[i-k]== False: possible[i] = True continue if t[i] == "r": ...
p03611
s891961141
Accepted
from collections import defaultdict N = int(input()) A = list(map(int, input().split())) d = defaultdict(int) for a in A: d[a+1] += 1 d[a] += 1 d[a-1] += 1 print(max(d.values()))
p03243
s701747576
Accepted
n = int(input()) l = list(range(111,1000,111)) if n % 111 == 0: print(n) else: print(l[n // 111])
p02767
s418768557
Accepted
import numpy as np N = int(input()) X = np.array(input().split()).astype(int) P = round(np.average(X)) print(int(np.sum((P-X)**2)))
p03109
s840676475
Accepted
#!/usr/bin/env python3 s = input().replace("/", "") h = "20190430" print("Heisei") if s <= h else print("TBD")
p02683
s123201953
Accepted
N, M, X = map(int, input().split()) C = [0]*N A = [None]*N for i in range(N): C[i], *A[i] = map(int, input().split()) oo = 10**10 ans = oo for b in range(2**N): c = 0 T = [0]*M for i in range(N): if b>>i&1: c += C[i] for j in range(M): T[j] += A[i][j] ok = True for i in range(M): ...
p02994
s210419929
Wrong Answer
N, L = map(int,input().split()) l = 0 m = 10000 for i in range(1,N+1): l += L+i-1 m = min(m,abs(L+i-1)) l -= m print(l)
p03416
s629119432
Accepted
A, B = map(int, input().split()) ans = 0 for i in range(A, B+1): if str(i) == str(i)[::-1]: ans += 1 print(ans)
p02676
s646416046
Accepted
def main(): K = int(input()) S = input() if len(S) <= K: print(S) else: s = S[:K] print(s + "...") if __name__ == '__main__': main()
p02996
s614023001
Accepted
N = int(input()) works = sorted([list(map(int, input().split())) for _ in range(N)], key=lambda x: x[1]) result = True cnt = 0 for a, b in works: cnt += a if cnt > b: result = False break print('Yes' if result else 'No')
p02726
s291922222
Accepted
n, x, y = map(int, input().split()) cnt = [0] * n for i in range(1, n+1): for j in range(i+1, n+1): cnt[min(j-i, abs(x-i)+1+abs(y-j), abs(y-i)+1+abs(x-j))] += 1 for i in range(1,n): print(cnt[i])
p02640
s131070183
Wrong Answer
x, y = map(int, input().split()) low = y//4 high = y//2 if low <= x <= high: print("Yes") else: print("No")
p03435
s382776650
Accepted
c = [list(map(int,input().split())) for i in range(3)] a = [0]*3 b = [0]*3 b[0] = c[0][0] b[1] = c[0][1] b[2] = c[0][2] a[1] = c[1][1]-b[1] a[2] = c[2][2]-b[2] for i in range(3): for j in range(3): if c[i][j] != a[i]+b[j]: print("No") exit() print("Yes")
p02988
s151495572
Accepted
n = int(input()) P = [int(x) for x in input().split()] count = 0 for i in range(n-2): if (P[i] < P[i+1]) and (P[i+1] < P[i+2]): count += 1 elif (P[i] > P[i+1]) and (P[i+1] > P[i+2]): count += 1 print(count)
p03994
s687122880
Accepted
s=list(input()) k=int(input()) for e,i in enumerate(s): c=(123-ord(i))%26 if k>=c: s[e]="a" k-=c else:s[e]=i l = chr((ord(s[-1])-97+k)%26+97) print("".join(s[:-1])+l)
p03815
s907538577
Accepted
x=int(input()) p=x//11 q=x%11 q2=q-6 if q==0: print(2*p) elif q2<=0: print(2*p+1) else: print(2*p+2)
p03359
s900318748
Wrong Answer
a,b=map(int,input().split()) if a<=b: print(a) else: print(b)
p03109
s803487074
Accepted
y, m, d = map(int, input().split("/")) if y * 365 + m * 30 + d > 2019 * 365 + 4 * 30 + 30: print("TBD") else: print("Heisei")
p02641
s311674860
Wrong Answer
import sys X, N = map(int, input().split()) P = list(map(int, input().split())) if len(P) == 0 or not X in P: print(X) sys.exit() flg = 1000 ans = 1000 m = max(P) itera = list(range(1, m + 1)) itera.reverse() for i in itera: if not i in P and flg > abs(X - i): flg = abs(X - i) ans = min(a...
p02897
s675717176
Accepted
N = int(input()) if N == 1: print(1.0) elif N % 2 == 0: print(0.5) else: print((N - (N // 2)) / N)
p03338
s599342288
Accepted
n = int(input()) s = input() ans = 0 for i in range(1, n): temp = len(set(s[:i]) & set(s[i:])) if temp > ans: ans = temp print(ans)
p02777
s186699119
Accepted
a,b=map(str,input().split()) c,d=map(int,input().split()) e=input() if a==e: c=c-1 else: d=d-1 print(c,d)
p03627
s552620321
Wrong Answer
N = int(input()) ma1 = 0 ma2 = 0 A = list(map(int,input().split())) a = sorted(A,reverse = True) hold = 0 count = 0 for i in a: if i == hold: count += 1 else: if count > 3 and ma1 == 0: ma1 = hold ma2 = hold elif count > 1: if ma1 == 0: ma1 = hold elif ma2 == 0: ...
p03433
s263953770
Accepted
N = int(input()) A = int(input()) if N % 500 <= A: print('Yes') else: print('No')
p02596
s443393748
Wrong Answer
k = int(input()) if k % 2 == 0: print("-1") exit() if k == 1 or k == 7: print("-1") exit() seven_i = 7 for i in range(1,10**6): seven_i = seven_i*10+7 seven_mod = seven_i % k if seven_mod == 0: print(i+1) exit() seven_i = seven_mod print("-1")
p03852
s713375175
Wrong Answer
c=input() if c=='a' or 'i' or 'u' or 'e' or 'o': print('vowel') else: print('consonant')
p03854
s618661865
Accepted
S = input()[::-1] ss = ['maerd', 'remaerd', 'esare', 'resare'] while True: for s in ss: if S.startswith(s): S = S[len(s):] break else: if S != '': print('NO') break if S == '': print('YES') break
p03862
s461511288
Accepted
n, x = map(int, input().split()) A = list(map(int, input().split())) ans = 0 for i in range(n): if i != 0: y = A[i-1]+A[i] else: y = A[i] if y <= x: continue ans += y-min(x, y) A[i] -= y-min(x, y) print(ans)
p03796
s008305906
Accepted
n = int(input()) ans = 1 for i in range(1, n +1): ans*= i ans = ans % (10**9 + 7) print(ans)
p03796
s075545831
Wrong Answer
N = int(input()) sum=1 for i in range(1, N): sum = (sum*i)%1000000007 print(sum)
p03284
s327423486
Accepted
N, K = map(int, input().split()) print(0 if N%K==0 else 1)
p02796
s104823562
Accepted
N=int(input()) L=[list(map(int,input().split())) for i in range(N)] R=[] for i in range(N): a=max(0,L[i][0]-L[i][1]) b=L[i][0]+L[i][1] R.append([b,a]) R.sort() ans=0 last=0 for i in range(N): if last<=R[i][1]: ans+=1 last=R[i][0] print(ans)
p03038
s185682450
Accepted
n, m = map(int, input().split()) a = list(map(int, input().split())) b = [] a.sort() for i in range(m): s, t = map(int, input().split()) if t > a[0]: b.append([s, t]) b.sort(reverse=True, key=lambda x: x[1]) j = 0 for i in range(len(b)): if j >= n: break while a[j] < b[i][1] and b[i][0] ...
p02882
s515181790
Wrong Answer
import math a, b, x = map(int, input().split()) A1 = 2*x/(a*b) num = math.atan(b/A1) print(math.degrees(num))
p03252
s761960824
Wrong Answer
S = set(input()) T = set(input()) if len(S) == len(T): print('Yes') else: print('No')
p03986
s773338368
Accepted
X = input().rstrip() cnt = 0 res = len(X) for x in X: if x=="S": cnt += 1 else: if cnt > 0: res -= 2 cnt -= 1 print(res)
p03137
s105095823
Accepted
N, M = map(int, input().split()) X = list(map(int, input().split())) X.sort() diff = sorted(X[i + 1] - X[i] for i in range(M - 1)) print(sum(diff[:max(0, M - N)]))
p04029
s453923076
Wrong Answer
n = int(input()) a = 0 for i in range(n): a += i print(a)
p03041
s007475805
Accepted
n,k=map(int,input().split()) s=input() print(s[0:k-1]+s[k-1:k].lower()+s[k:])
p03456
s500099855
Accepted
a,b = map(str,input().split()) c = int(a+b) #print(float(c)) import math #print(math.sqrt(c)) if c == int(math.sqrt(c))**2: print('Yes') else: print('No')
p03665
s626683673
Accepted
n,p = map(int,input().split()) al = list(map(int,input().split())) for a in al: if a % 2 == 1: print(2**(n-1)) exit() if p == 0: print(2**n) else: print(0)
p03457
s634063779
Wrong Answer
n = int(input()) t = [0] x = [0] y = [0] for i in range(n): t_, x_, y_ = map(int, input().split()) t.append(t_) x.append(x_) y.append(y_) for j in range(n): dt = t[j+1] - t[j] dx = x[j+1] - x[j] dy = y[j+1] - y[j] if dx+dy>dt or dt%2!=(dx+dy)%2: print('No') exit() print('Yes')
p04031
s659480111
Accepted
n = int(input()) l = list(map(int, input().split())) mn = min(l) mx = max(l) ms = 10**9 ll = [0]*n for j in range(mn, mx+1): for i in range(n): ll[i] = (l[i]-j)**2 s = sum(ll) ms = min(ms, s) print(ms)
p04045
s243775670
Wrong Answer
N, K = list(map(int, input().split())) D = list(map(int, input().split())) for i in range(N, 10**5): for c in str(i): if c in D: break else: print(i) exit()
p02659
s781138650
Accepted
import math a,b=input().split() a=int(a) L=list(b) if "." in L and L[0]==0: c=L[2]+L[3] c=int(c) print(c*a//100) elif "." in L and L[0]!=0: c=L[0]+L[2]+L[3] c=int(c) print(c*a//100)
p03017
s062224914
Accepted
N, A, B, C, D = map(int, input().split()) S = input() if "##" in S[A - 1: C] or "##" in S[B - 1: D]: print("No") exit(0) if C <= D: print("Yes") exit(0) ans = False for i in range(B - 1, D): if (S[i - 1] == '.') and (S[i] == '.') and (S[i + 1] == '.'): ans = True break if ans: ...
p02861
s336973443
Wrong Answer
import itertools import math n = int(input()) towns_li = [] for _ in range(n): co = list(map(int, input().split())) towns_li.append(co) di = 0 for i in itertools.permutations(range(n)): for j in range(n - 1): di += math.sqrt(((towns_li[j][0] - towns_li[j+1][0]) ** 2 + (towns_li[j][1] - towns_li[j+1...
p02970
s200387237
Accepted
N, D = map(int, input().split()) print(-(-N // (2 * D + 1)))
p03059
s882293492
Accepted
A, B, T = map(int, input().split()) r = (T // A) * B print(r)
p03779
s115450514
Wrong Answer
N=int(input()) a=0 for i in range(1,10**5+1): a+=i if i>=N: print(i) exit()
p03796
s924822712
Wrong Answer
N = int(input()) import math N = math.factorial(N) print(N)
p03345
s667868452
Wrong Answer
A, B, C, K = map(int, input().split()) la = [A] lb = [B] lc = [C] if A == B == C: print("0") for i in range(K): la.append(lb[-1] + lc[-1]) lb.append(la[-2] + lc[-1]) lc.append(la[-2] + lb[-2]) if abs(la[-1] - lb[-1]) > 10**18: print("Unfair") else: print(la[-1] - lb[-1]) #print(la, lb, l...
p03721
s403243095
Accepted
N,K=map(int,input().split()) AB=sorted([list(map(int,input().split()))for i in range(N)]) c=0 for ab in AB: c+=ab[1] if c>=K: exit(print(ab[0]))
p02787
s090023229
Accepted
H, N = map(int, input().split()) AB = [tuple(map(int, input().split())) for _ in range(N)] dp = [0] for h in range(H): dp.append(min([dp[max(0, h + 1 - A)] + B for A, B in AB])) print(dp[-1])
p03799
s432081584
Accepted
n,m = map(int, input().split()) if n > (m+n)/3: print(m//2) exit() if m > 10000000000: print(m//4) exit() while n <= (n+m)/3: n += 1 m -= 2 print(n-1)
p03493
s076141459
Wrong Answer
s = input() cnt = 0; for temp in s: if temp == "1": cnt += 1 print (cnt)
p02612
s906714694
Accepted
N=int(input()) if N%1000==0: print(0) else: print(1000-N%1000)
p03437
s989186739
Accepted
x, y = map(int,input().split()) if x%y == 0: print(-1) else: print(x)
p03105
s127939517
Wrong Answer
a,b,c = map(int,input().split()) ans = 0 if a * c > b: for i in range(c,1,-1): if i * a <= b: if ans < i: ans = i print(ans) else: print(c)
p02785
s826344569
Accepted
n, k = map(int, input().split()) arr = [int(j) for j in input().split()] if k>= n: print(0) else: arr.sort(reverse=True) print(sum(arr[k:]))
p02615
s573047485
Wrong Answer
N = int(input()) A = list(map(int, input().split())) A.sort() A.reverse() list = [] ans = 0 list.append(A[0]) for i in range(len(A)): ans += list[i] list.append(A[i]) list.append(A[i]) print(ans)
p03386
s390452059
Accepted
A, B, K = map(int, input().split()) num_list = [] for i in range(K): num_list.append(A + i) for i in range(K): num_list.append(B - i) num_list = sorted(set(num_list)) for i in num_list: if A <= i <= B: print(i)
p02797
s049050711
Accepted
MAX_S = 1_000_000_000 N, K, S = list(map(int, input().split())) for _ in range(K): print(S, '', end='') if S == MAX_S: for _ in range(K, N): print(1, '', end='') else: for _ in range(K, N): print(MAX_S, '', end='') print()
p02946
s618663857
Wrong Answer
k,x = map(int,input().split()) lis = [x] for i in range(1,k): lis.append(x-1) lis.append(x+1) new_list = sorted(lis) print(" ".join(map(str,new_list)))
p02682
s758722078
Accepted
A, B, C, K = [int(x) for x in input().split()] print(min(K, A) - (min(K - A - B, C) if K - A - B > 0 else 0))
p02842
s583249559
Accepted
import math a=int(input()) b=math.ceil(a/1.08) c=math.floor(a/1.08) if math.floor(b*1.08)==a: print(b) elif math.floor(c*1.08)==a: print(c) else: print(":(")
p03386
s239666732
Accepted
def resolve(): a, b, k = map(int, input().split()) if (b - a + 1) < k: for i in range(a, b+1): print(i) return for i in range(a, min(a+k, b-k+1)): print(i) for i in range(b-k+1, b+1): print(i) resolve()
p03814
s343570855
Accepted
s = str(input()) a = 0 b = 0 for i in range(len(s)+1): if s[i] == "A": a = i+1 break else: pass for i in reversed(range(len(s))): if s[i] == "Z": b = i+1 break else: pass print(b - a + 1)
p03126
s622067334
Accepted
n,m=map(int,input().split()) x=[] sum=0 for i in range(n): s=list(map(int,input().split())) s.pop(0) x+=s for j in range(1,m+1): if x.count(j)==n: sum+=1 print(sum)
p02879
s096429375
Wrong Answer
a, b = map(int, input().split()) if a > 10 or b >10: print(-1) else: print(a*b)
p02835
s184557217
Accepted
a1, a2, a3 = map(int,input().split()) if a1+a2+a3 > 21: print("bust") else: print("win")
p03042
s256444440
Wrong Answer
s = input() former = int(s[:2]) later = int(s[2:]) if former==0 or later==0 or (former>31 and later>31): print("NA") elif former<13 and later<13: print("AMBIGUOUS") elif former<13 and later<32: print("MMYY") elif former<32 and later<13: print("YYMM")
p03779
s512398052
Accepted
x = int(input()) cnt = 0 total = 0 while x > total: cnt += 1 total = int((1 + cnt) * (cnt/2)) print(cnt)
p02647
s857555531
Accepted
N, K = map(int, input().split()) A = [int(i) for i in input().split()] ans = A for k in range(K): temp = [0 for _ in range(N)] for i in range(N): a = ans[i] temp[max(i-a, 0)] += 1 if i + a + 1 < N: temp[i+a+1] -= 1 ans[0] = temp[0] for j in range(1, N): ans[...
p03698
s407379549
Accepted
lst=list(str(input())) a=set() for i in range(len(lst)): a.add(lst[i]) if len(lst)==len(a): print("yes") else: print("no")
p03943
s560370950
Wrong Answer
# -*- coding : utf-8 -*- a,b,c = map(int ,input().split()) if a+b == c or a+c == b or b+c == a: print("YES") else : print("NO")
p02917
s033075946
Accepted
import sys n, *lst = map(int, sys.stdin.read().split()) alst = [lst[0]] lst += [lst[-1]] for i in range(n - 1): tmp = min(lst[i], lst[i + 1]) alst += [tmp] print(sum(alst))
p02725
s280516228
Accepted
K, N = list(map(int, input().split())) A = list(map(int, input().split())) distance = [abs(A[i] - A[i-1]) for i in range(N)] distance[0] = abs(distance[0]-K) print(sum(distance) - max(distance))
p02717
s995248573
Wrong Answer
x = list(map(int, input().split())) x.sort() for i in range(len(x)): print(x[i], end = ' ')
p02918
s157481433
Accepted
N, K = map(int, input().split()) S = list(input()+"X") temp = S[0] cnt = 1 c_cnt = 1 ans = 0 for i in range(1, N+1): if temp == S[i]: cnt += 1 else: ans += cnt - 1 cnt = 1 c_cnt += 1 temp = S[i] #print(ans, cnt, c_cnt, temp) #最後の余計な分 c_cnt -= 1 if c_cnt//2 <= K: if c_cnt%2 == 0: ans...
p02623
s174877624
Wrong Answer
N, M, K = [int(_) for _ in input().split()] A = [int(_) for _ in input().split()] B = [int(_) for _ in input().split()] v = 0 ans = 0 for i in range(N): if v + A[i] <= K: v += A[i] else: mi = i-1 break else: mi = N-1 for j in range(M): while mi > -1 and v + B[j] > K: v ...
p03285
s344893218
Accepted
n = int(input()) flag = 0 while n>0: if n % 4 == 0: flag = 1 break n -= 7 if n == 0: flag=1 break print('Yes' if flag == 1 else 'No')
p02866
s908449075
Accepted
from collections import Counter mod = 998244353 num_nodes = int(input()) d_ls = list(map(int, input().split())) d_max = max(d_ls) c = Counter(d_ls) if c[0] == 1 and d_ls[0] == 0 and c[1] > 0: ans = 1 else: ans = 0 for i in range(1,d_max): ans *= c[i] ** c[i+1] ans %= mod print(ans)
p02787
s860778637
Accepted
H, n = map(int, input().split()) A = [] B = [] for i in range(n): a, b = map(int, input().split()) A.append(a) B.append(b) dp = [0 for i in range(H+1)] for i in range(1, H+1): dp[i] = min(dp[i - A[j]] + B[j] if A[j] <= i else B[j] for j in range(n)) print(dp[H])
p02796
s172087809
Accepted
import heapq n = int(input()) robots = [] for _ in range(n): robot = tuple(map(int, input().split())) heapq.heappush(robots, robot) robot = heapq.heappop(robots) max_right = robot[0] + robot[1] del_count = 0 for i in range(len(robots)): robot = heapq.heappop(robots) if max_right > robot[0] - robot[1]: ...
p02793
s080815224
Accepted
N=int(input()) A=list(map(int,input().split())) mod=10**9+7 def gcd(a, b): if a == 0: return b else: g = gcd(b % a, a) return g lcm=1 for a in A: lcm=lcm*a//gcd(a,lcm) ans=0 for a in A: ans+=(lcm*pow(a,mod-2,mod))%mod ans%=mod print(ans)
p03705
s391437807
Wrong Answer
n,a,b=map(int,input().split()) ans=0 if a>b or n==1: ans=0 elif a==b: ans=1 else: ans=(n-2)*(b-a)+1 print(ans)
p03612
s973024850
Wrong Answer
n = int(input()) P = list(map(int,input().split())) P = [int(i+1==P[i]) for i in range(n)]+[0] print(P) ans = 0 ex = 0 for p in P: if p and ex: ans += 1 ex = 0 elif p: ex = 1 elif ex: ans += 1 ex = 0 print(ans)
p03672
s343884077
Wrong Answer
S = input() for i in range(1, len(S)): s = S[:-i] l = len(s) // 2 if s[:l] == s[l:]: print(len(s))
p03359
s883924043
Accepted
a,b=input().split() a=int(a) b=int(b) if a<=b: print(a) else: print(a-1)
p02832
s867077376
Accepted
n = int(input()) a = list(map(int, input().split())) ans = 0 num = 1 for i in range(n): if a[i] != num: ans += 1 else: num += 1 if num == 1: print(-1) else: print(ans)