problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02767
s970776669
Accepted
import numpy as np N = int(input()) point_arr = np.array(list(map(int, input().split()))) mean = point_arr.mean() int_mean = int(mean) print(min(sum((point_arr-int_mean)**2), sum((point_arr-(int_mean+1))**2)))
p02711
s015719246
Accepted
n = str(input()) for i in range(3): if n[i] == "7": print("Yes") break elif i == 2: print("No")
p04031
s498256465
Accepted
n = int(input()) l = list(map(int,input().split())) a1 = 0 a2 = 0 c1 = int(sum(l)/n) c2 = c1 + 1 for i in range(len(l)): a1 = a1 + (c1-l[i])**2 a2 = a2 + (c2-l[i])**2 ans = min(a1,a2) print(ans)
p04030
s869988758
Accepted
s = input() ans = '' for i in s: if i == 'B': ans = ans[:-1] else: ans = ans + i print(ans)
p03338
s749760880
Accepted
from collections import Counter def solve(n, s): c = Counter(s) ret, tmp = 0, 0 d = set() for l in s: c[l] -= 1 if c[l] == 0: tmp -= 1 if l not in d: tmp += 1 d.add(l) if ret < tmp: ret = tmp return ret _n = int(input())...
p02847
s298332649
Accepted
Day=["SUN","MON","TUE","WED","THU","FRI","SAT"] n=input() for i in range(7): if n==Day[i]: print(7-i)
p03759
s279128716
Wrong Answer
a,b,c=map(int,input().split()) if abs(b-a)==abs(b-c): print('YES') else: print('NO')
p03360
s682634789
Accepted
a,b,c=map(int,input().split()) k=int(input()) M=max(a,b,c) print(a+b+c-M+M*(2**k))
p03371
s877105956
Accepted
a, b, c, x, y = map(int, input().split()) i = a*x+b*y j = c*min(x, y)*2+a*(x-min(x, y))+b*(y-min(x, y)) k = c*max(x, y)*2 print(min(i, j, k))
p02866
s958474504
Wrong Answer
from sys import stdin nii=lambda:map(int,stdin.readline().split()) lnii=lambda:list(map(int,stdin.readline().split())) from collections import Counter n=int(input()) d=lnii() mod=998244353 c=Counter(d) max_key=max(d) if c[0]!=1: print(0) exit() ans=1 patterns=1 for i in range(max_key+1): p_num=c[i] ans=ans...
p03087
s972508742
Wrong Answer
N,Q = map(int,input().split()) S = input() c = [0] count = 0 for i in range(N-1): if S[i] == "A" and S[i+1] == "C": count += 1 c.append(count) print(c) for i in range(Q): l,r = map(int,input().split()) print(c[r-1]-c[l-1])
p02694
s191460097
Wrong Answer
x = int(input()) year = 0 money = 100 while money < x: year += 1 money = int(money * 1.01) print(year)
p03037
s709789160
Accepted
n,m=map(int,input().split()) s=[0]*n left=[] right=[] for i in range(m): l,r=map(int,input().split()) left.append(l) right.append(r) if min(right)<max(left): print(0) else: print(min(right)-max(left)+1)
p02640
s093222275
Accepted
X , Y = map(int,input().split()) F = False for i in range(0,X+1): J = X - i C = 4 * i + 2 * J if C == Y: F = True if F: print("Yes") else: print("No")
p02657
s472210342
Accepted
A, B = map(int, input().split()) print(A * B)
p02900
s353431135
Accepted
a,b = [int(x) for x in input().split()] import fractions g = fractions.gcd(a,b) ans = 1 mama = int(g ** (1/2)) flag = 0 for i in range(2,mama+2): while True: if g%i != 0: break else: g = g/i flag = 1 if flag == 1: ans += 1 flag = 0 if g != 1: a...
p03293
s476460654
Accepted
#103_B S=input() T=input() flg=False for i in range(len(S)): S=S[-1]+S[:-1] if S==T: flg=True print('Yes' if flg else 'No')
p02953
s228724841
Wrong Answer
n = int(input()) l_list = list(map(int, input().split())) d = [l_list[i+1]-l_list[i] for i in range(n-1)] flag = False for i in d: if i < -1: print("No") break if i == -1 and flag == True: print("No") break elif i == -1 and flag == False: flag = True else: print...
p02952
s008795575
Accepted
n = int(input()) count=0 for i in range(1,n+1): if len(str(i)) % 2 == 1: count += 1 print(count)
p03455
s718250824
Accepted
a, b = map(int, input().split()) X = a*b if X%2 ==1: print('Odd') else: print('Even')
p03062
s416845948
Accepted
N = int(input()) A = list(map(int, input().split())) cnt = len([a for a in A if a < 0]) if cnt % 2 == 0: print(sum([abs(a) for a in A])) else: ans = sum([abs(a) for a in A]) M = float('inf') for a in A: if abs(a) < M: M = abs(a) print(ans - 2 * M)
p02641
s340679590
Accepted
x, n = map(int, input().split()) p = list(map(int, input().split())) y = None if x in p: for i in range(102): if i in p: continue if y is None or abs(x - i) < y: y = abs(x - i) ans = i else: ans = x print(ans)
p02946
s054855995
Accepted
k,x=map(int,input().split()) s=[str(a)for a in range(x-k+1,x+k)] s=" ".join(s) print(s)
p02753
s257964475
Accepted
1. S = input() if len(S)==3 and S.count('A')==2 or S.count('B')==2: print('Yes') else: print('No')
p02933
s663177405
Wrong Answer
a = int(input()) s = input() if a >= 3200: print(s) else: print("Red")
p02628
s474713373
Accepted
n,k = [int(i) for i in input().split(" ")] p = [int(i) for i in input().split(" ")] p.sort() print(sum(p[:k]))
p02658
s498301050
Wrong Answer
N = int(input()) A = map(int, input().split()) limit = 10**18+1 mul = 1 for i in A: mul *= i if mul >= limit: print("-1") break if mul < limit: print(mul)
p02760
s069782054
Wrong Answer
A = [list(map(int,input().split())) for i in range(3)] N = int(input()) b = [int(input()) for i in range(N)] for i in range(N): for h in range(3): for w in range(3): if b[i] == A[h][w]: A[h][w] = 0 if [0,0,0] in A: print('Yes') else: ans = 'No' for i in zip(*A): ...
p02761
s423524060
Accepted
def main(): n,m = map(int, input().split()) lim = 10 ** n val = [list(map(int, input().split())) for _ in range(m)] for i in range(10**(n-1) if n >= 2 else 0, lim): for j, k in val: j = j - 1 l = str(i) if l[j] != str(k): break else: ...
p02847
s869160243
Accepted
week = ["SUN","MON","TUE","WED","THU","FRI","SAT"] week.reverse() print(week.index(input())+1)
p02983
s792243004
Wrong Answer
l,r=map(int,input().split()) mod=2019 sa=r-l ans=float('inf') if 2019<=sa: print(0) else: for i in range(l,r+1): for j in range(l,r+1): if i<j: ans=min((i%mod)*(j%mod),ans) print(ans)
p04043
s478932383
Accepted
a,b,c=map(int,input().split()) if a==b==5 and c==7 : print('YES') elif a==c==5 and b== 7: print('YES') elif b==c==5 and a==7: print('YES') else: print('NO')
p02948
s202960804
Accepted
import heapq as hq n,m=map(int,input().split()) a=[list(map(int,input().split())) for i in range(n)] a.sort() for i in range(n): a[i][1]*=-1 b=[] hq.heapify(b) ans,i=0,0 for k in range(m-1,-1,-1): while i<n and a[i][0]+k<=m: hq.heappush(b,a[i][1]) i+=1 if b: ans-=hq.heappop(b) print(...
p03835
s168066382
Wrong Answer
k, s = map(int,input().split(' ')) count = 0 for x in range(k+1): for y in range(k+1): if (s - (x+y)) <= k: count += 1 print(count)
p03146
s441970032
Accepted
s = int(input()) l = [s] N = s count = 1 while 1: count += 1 if N % 2 == 0: N = N // 2 else: N = 3 * N + 1 if N in l: print(count) break else: l.append(N)
p03543
s515525144
Accepted
N = input() if N[1] == N[2]: if N[0] == N[1] or N[2] == N[3]: print("Yes") else: print("No") else: print("No")
p03351
s878633410
Accepted
a,b,c,d=map(int,input().split()) if (max(a,b)-min(a,b)) <= d and (max(c,b)-min(c,b)) <= d: print('Yes') elif (max(a,c)-min(a,c)) <= d: print('Yes') else: print('No')
p03013
s537135518
Wrong Answer
n,m=map(int,input().split()) a=[] for i in range(m): a.append(int(input())) d=[1]*(n+1) if 1 in a: d[1]=0 for i in range(n-1): if (i+2) in a: d[i+2]=0 else: d[i+2]=(d[i]+d[i+1])%1000000007 print(d)
p03673
s076046844
Accepted
N = int(input()) a = list(map(int,input().split())) from collections import deque ans = deque() if N%2 == 0: for i in range(N): if i%2 == 0: ans.append(a[i]) else: ans.appendleft(a[i]) else: for i in range(N): if i%2 == 0: ans.appendleft(a[i]) ...
p03624
s979406972
Wrong Answer
import sys input = sys.stdin.readline def main(): S = set(input()) if len(S) == 26: print("None") sys.exit() for i in range(97, 97+26): if chr(i) not in S: print(chr(i)) sys.exit() if __name__ == '__main__': main()
p02727
s308159705
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() P = p[:x] Q = q[:y] R = P+Q+r R.sort() R.reverse() T = R[:x+y] ans = sum(T) print(ans)
p02859
s288342812
Wrong Answer
import math r=int(input()) a=r**2*math.pi A=1*math.pi d=a//A
p03109
s121767028
Accepted
s=input() if s<="2019/04/30": print("Heisei") else: print("TBD")
p02748
s207551400
Accepted
a,b,m = map(int,input().split()) r = tuple(map(int,input().split())) d = tuple(map(int,input().split())) ans = min(r)+min(d) for i in range(m): x,y,c = map(int,input().split()) ans = min(ans,r[x-1]+d[y-1]-c) print(ans)
p03778
s173628740
Wrong Answer
w,a,b = map(int,input().split()) c = min(a,b) d = max(a,b) if c + w >= d: print(0) else: print(d-c+w)
p02664
s742959041
Wrong Answer
T = input() T= T.replace("D?","DP") T= T.replace("?","D") print(T)
p03557
s972653987
Accepted
def main(): import bisect n=int(input()) A=sorted(list(map(int,input().split()))) B=list(map(int,input().split())) C=sorted(list(map(int,input().split()))) lc=len(C) ans=0 for b in B: ma = bisect.bisect_left(A, b) mc = lc-bisect.bisect_right(C, b) ans += ma*mc print(ans) if __name__ == "_...
p02697
s832808351
Accepted
N,M = map(int,input().split()) cnt = 0 i = 0 j = M while i+1 < j and cnt < M: print(i+1, j) i += 1 j -= 1 cnt += 1 i = M j = 2*M+1 while i+1 < j and cnt < M: print(i+1, j) i += 1 j -= 1 cnt += 1
p02707
s740357956
Accepted
# -*- coding: utf-8 -*- n = int(input()) a = list(map(int, input().split())) d = {} for num in a: d[num] = d.get(num, 0) + 1 for i in range(1, len(a)+2): if i in d: print(d[i]) else: print(0)
p03680
s448490551
Wrong Answer
n = int(input()) lis = [] for i in range(n): lis.append(int(input())) button = lis[0] count = 1 if button == 2: ans = 1 while True: count += 1 button = lis[button - 1] if button == 2: ans = count break if count > n: ans = -1 break print(ans)
p03457
s298913747
Accepted
a = int(input()) for n in list(range(a+1)): if n == 1: b,c,d = map(int, input().split()) if c + d > b or (c + d - b) % 2 != 0: print('No') break if n >= 2: b1 = b c1 = c d1 = d b,c,d = map(int, input().split()) if abs(c-c1) + abs(d-d1) > b-b1 or (abs(c-c1) + abs(d-d1) - (b-b1...
p02951
s060056601
Wrong Answer
a,b,c=map(int, input().split()) print(c-a+b)
p02802
s482957564
Wrong Answer
n, m = [int(x) for x in input().split()] lst = [None]*(n+1) a = 0 b = 0 for i in range(m): p, s = input().split() p = int(p) if s == 'AC' and lst[p] is None: a += 1 lst[p] = True elif s == 'WA' and lst[p] is None: b += 1 print(a,b)
p03672
s850523705
Accepted
s = input() s = s[:-1] while len(s) % 2 != 0 or s[:len(s)//2] != s[len(s)//2:]: s = s[:-1] print(len(s))
p02879
s099505860
Accepted
a,b = map(int,input().split()) print(a*b) if a<=9 and b<=9 else print(-1)
p02946
s441568883
Accepted
K, X = map(int,input().split()) for cnt in range(2*K-1): print(X-K+cnt+1, end = " ") 3
p03073
s119557185
Wrong Answer
s= str(input()) ans = 0 for i in range(len(s)): if i // 2 == 0: if s[i] == '0': ans += 1 else: if s[i] == '1': ans += 1 print(min(ans,len(s)-ans))
p02988
s719511479
Accepted
n=int(input()) a=[0]*n a[:]=map(int,input().split()) r=0 import copy for ii in range(n-2): b=copy.copy(a[ii:ii+3]) c=copy.copy(b) b.sort() if b[1]==c[1]: r+=1 print(r)
p03274
s174153672
Accepted
import sys input = sys.stdin.readline N, K = map(int, input().split()) a = list(map(int, input().split())) z = -1 res = float("inf") for r in range(N): if a[r] < 0: z = r continue if r < K - 1: continue x = r - z y = a[z - (K - x) + 1] if K == x: y = 0 t = min(abs(a[r]), abs(y)) if r - z >= K: t =...
p03720
s627433988
Wrong Answer
import itertools n,m=map(int,input().split()) ab= [list(input()) for _ in range(m)] ab=list(itertools.chain.from_iterable(ab)) for i in range(1,n+1): print(ab.count(i))
p03030
s002632824
Accepted
n = int(input()) a = [list(input().split()) for nesya in range(n)] s = 1 for hoge in a: hoge[1] = int(hoge[1])*(-1) hoge.append(s) s += 1 a.sort() for raw in a: print(raw[2])
p03309
s165386388
Accepted
n = int(input()) a = list(map(int, input().split())) for i in range(n): a[i] -= i + 1 us, vs = 0, sum(a) uc, vc = 0, n a.sort() ans = vs - a[0] * n for i in range(n): us += a[i] uc += 1 vs -= a[i] vc -= 1 b = a[i] ans = min(ans, uc * b - us + vs - vc * b) print(ans)
p02801
s572698034
Wrong Answer
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines c = read().decode("utf-8") l = [chr(ord('a') + i) for i in range(26)] if c == "z": print("a") quit() f = False for a in l: if a == c: f = True continue if f: ...
p03962
s661412391
Wrong Answer
a,b,c = map(int,input().split()) if a==b and b==c: print(1) elif a==b or b==c: print(2) else: print(3)
p02578
s221765510
Accepted
n = int(input()) l = list(map(int, input().split())) maxNum = l[0] total = 0 for i in range(1,len(l)): if maxNum <= l[i]: maxNum = l[i] else: total += maxNum - l[i] print(total)
p03042
s431216264
Accepted
S = input() S_a = int(S[0] + S[1]) S_b = int(S[2] + S[3]) if((S_a >= 1 and S_a <= 12) and (S_b < 1 or S_b > 12)): print('MMYY') elif((S_a < 1 or S_a > 12) and (S_b >= 1 and S_b <= 12)): print('YYMM') elif((S_a >= 1 and S_a <= 12) and (S_b >= 1 and S_b <= 12)): print('AMBIGUOUS') else: print('NA')
p02694
s380461659
Accepted
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) from math import floor x = int(readline()) v = 100 for i in range(x): v = floor(v * 1.01) if v >= x: print(i + 1) exit()
p02697
s721125068
Accepted
n,m=map(int,input().split()) for i in range(0,m): if n-2*i-1>n/2 or n%2==1 : print(i+1,n-i) else: print(i+1,n-i-1)
p03639
s740337146
Wrong Answer
n=int(input()) a=list(map(int,input().split())) border_4 = n//2 border_2 = n cnt_4=0 cnt_2=0 for i in range(n): if a[i]%4==0: cnt_4+=1 cnt_2+=1 elif a[i]%2==0: cnt_2+=1 else: continue if cnt_4>=border_4: print('YES') elif n-cnt_4*2<=(cnt_2-cnt_4): print('YES') el...
p02658
s937223521
Accepted
def sol(): n = int(input()) mul = 1 arr = list(map(int, input().split())) arr.sort() for i in arr: mul*=i if(mul>10**18): print(-1) return print(mul) sol()
p02681
s800761033
Accepted
S = input() T = input() if S == T[:-1] and (len(S)+1)==len(T): print('Yes') else: print('No')
p02732
s564587373
Accepted
N = int(input()) A = list(map(int, input().split())) B = [[] for i in range(N)] ans = [0]*N for k, a in enumerate(A): a = a - 1 B[a].append(k) S = 0 for b in B: lenb = len(b) if lenb >= 1: S += lenb * (lenb-1) / 2 for i, b in enumerate(B): for j, k in enumerate(b): ans[k] = int(S ...
p03695
s031601223
Wrong Answer
n = int(input()) a = list(map(lambda x:int(x)//400, input().split())) cnt = 0 for i in a: if i >= 8: cnt += 1 x = len(set(a))-(cnt>0) y = len(set(a))+cnt-(cnt>0) print(x, y)
p03427
s318419856
Accepted
n = input() keta = len(n) if n[0] == '9': # 9999 if n[1:] == '9'*(keta-1): print(9*keta) # 9899 else: print(9*keta-1) else: # 49999 if n[1:] == '9'*(keta-1): print(int(n[0]) + 9*(keta-1)) # 234 else: print(int(n[0])-1 + 9*(keta-1))
p02707
s449121396
Wrong Answer
import collections n=int(input()) a=list(map(int,input().split())) b=collections.Counter(a) for i in range(n+1): print(b[i])
p03493
s428515270
Accepted
s = input() print(s.count("1"))
p03544
s870564202
Accepted
n = int(input()) L = [0 for _ in range(n+2)] L[0]=2 L[1]=1 if n >= 2: for i in range(2,n+1): L[i] = L[i-1]+L[i-2] print(L[n])
p02836
s203357802
Accepted
#--Palindrome-philia S = input() s_str = list(S) s_rev = s_str[::-1] num = len(s_str) j = 0 for i in range(num): if (s_str[i] == s_rev[i]): pass else: j = j + 1 print (int(j/2))
p02963
s704001582
Wrong Answer
s=int(input()) a=10**9 """ def tr(x1,y1,x2,y2,x3,y3): a1=x2-x1 b1=y2-y1 a2=x3-x1 b2=y3-y1 return(abs(a1*b2-a2*b1)/2) """ if s<=10**9: print(0,0,s,0,0,1) elif s%a==0: print(0,0,a,0,s,s//a) else: x1,y1=0,0 x2,y2=s//a+1,a-s%a x3,y3=1,a print(x1,y1,x2,y2,x3,y3)
p02719
s415926399
Wrong Answer
N, K = map(int, input().split()) c = 0 while 1: if (N%2==0)and(K%2==0)and(N>=K): a = 0 break if K==1: a = 0 break if N==0: a = K break a = N N = abs(N-K) if c==0: c += 1 continue if a<=N: break print(a)
p02546
s869577898
Wrong Answer
s = input() for i in s: if s[-1] == 's': s.join('es') else: s.join('s') print(s)
p03427
s860521912
Wrong Answer
n = int(input()) flag = 0 ans = 0 if len(str(n)) > 2: ans += (len(str(n)) - 2) * 9 X = n // 10 ** (len(str(n)) - 2) if str(n % 10 ** (len(str(n)) - 2)).count('9') == len(str(n)) - 2: flag = 1 else: X = n if len(str(X)) == 1: ans += X else: if X // 10 == 1: ans += 9 flag ...
p03548
s290841805
Accepted
X,Y,Z = map(int,input().split()) print((X-Z)//(Y+Z))
p04029
s923503221
Accepted
N = int (input ()) x =0 for i in range (N): x += N-i print (x)
p02879
s597600786
Accepted
a,b=map(int,input().split()) print(a*b if a<10 and b<10 else -1)
p03327
s429284232
Accepted
n = int(input()) if n>999: print("ABD") else: print("ABC")
p02973
s199460696
Wrong Answer
import bisect n = int(input()) seq = [] for i in range(n): seq.append(int(input())) seq.reverse() LIS = [seq[0]] for i in range(len(seq)): if seq[i] >= LIS[-1]: LIS.append(seq[i]) else: LIS[bisect.bisect_left(LIS, seq[i])] = seq[i] print(len(LIS)-1)
p03163
s057850622
Accepted
N, W = map(int, input().split()) dp = [[0] * (W+1) for _ in range(N+1)] w, v = [0]*N, [0]*N for i in range(N): w[i], v[i] = map(int,input().split()) for i in range(N): for k in range(W+1): if w[i] <= k: dp[i+1][k] = max(dp[i][k-w[i]]+v[i], dp[i][k]) else: dp[i+1][k] = dp[...
p03672
s558410371
Accepted
S = input() N = len(S) for i in reversed(range(N)): S = S[:-1] if i % 2 == 0: if S == S[:i//2]*2: print(i) exit()
p03555
s950091038
Wrong Answer
a = input() b = input() if a[0] == b[2] and a[1] == b[1] and a[2] == b[0]: print("Yes") else: print("No")
p03997
s359823904
Wrong Answer
# 数値の取得 a = int(input()) b = int(input()) h = int(input()) # 面積を求めて出力 area = (a + b) * h / 0.5 print(area)
p02731
s123094203
Accepted
L=int(input()) print((L/3)**3)
p02833
s096034275
Wrong Answer
n = int(input()) def eq2(y): c2 = 0 while y % 2 == 0: c2 += 1 y = y // 2 return c2 def eq5(y): c5 = 0 while y % 5 == 0: c5 += 1 y = y // 5 return c5 cc2 = 0 cc5 = 0 if n % 2 != 0: print(0) else: for k in range(n, 1, -2): cc2 += eq2(k) ...
p02729
s381150568
Accepted
n, m = map(int, input().split()) count = n * (n - 1) // 2 + m * (m - 1) // 2 print(count)
p03698
s460654077
Wrong Answer
s = input() n = len(s) a=[] for i in range(n): a.append(s[i]) if len(a) == len(set(a)): print("Yes") else: print("No")
p02630
s722602248
Wrong Answer
N = int(input()) ans='' for i in range(1,99): if N<=26**i: N-=1 for j in range(i): ans += chr(ord('a')+N%26) N//=26 break else: N -= 26**i print(ans[::-1])
p02720
s856764890
Wrong Answer
import math import queue def readInt(): return int(input()) def readInts(): return list(map(int, input().split())) def readChars(): return input().split() q = queue.Queue() for i in range(1,10): q.put(i) n = readInt() for i in range(1,100000): a = str(q.get()) b = int(a[-1]) print(b) if b!=0: q.put(in...
p03109
s538742438
Accepted
s=list(map(int,input().split("/"))) if s[0]<2019: print("Heisei") elif s[0]>2020: print("TBD") else: print("TBD" if s[1]>4 else "Heisei")
p02584
s345923800
Accepted
x,k,d=map(int,input().split()) x=abs(x) c=x//d if k<=c: print(abs(x-k*d)) else: f=x-c*d k-=c if f>0: if k%2==1: print(abs(f-d)) else: print(abs(f)) if f<0: if k%2==1: print(abs(f+d)) else: print(abs(f)) if f==0: if k%2==1: print(abs(f+d)) else: pr...
p02899
s260167220
Accepted
N = int(input()) A = list(map(int,input().split())) B = [0]*N for i in range(N): B[A[i]-1] = i+1 print(*B)