problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p04031
s033650782
Wrong Answer
import sys input = sys.stdin.readline N = int(input()) a = [int(i) for i in input().split()] sum = 0 for i in range(N): sum+=a[i] d = sum//N m = sum%N if m != 0: d+=1 ans = 0 for i in range(N): de = a[i] - d ans += de**2 print(ans)
p03548
s856078882
Accepted
X, Y, Z = map(int, input().split()) isu = X - Z hito = Y + Z print(isu // hito)
p02719
s547742497
Wrong Answer
# C import math def my_round(val, digit=0): p = 10 ** digit return (val * p * 2 + 1) // 2 / p n, k = map(int, input().split()) s = my_round(n / k) print(abs(n - int(s * k)))
p03219
s705334346
Accepted
x, y = map(int, input().split()) print(x + y // 2)
p03433
s102493246
Accepted
n = int(input()) a = int(input()) z = int(n%500) if a >= z: print('Yes') else: print('No')
p03759
s120083145
Wrong Answer
# A - ι⊥l # b-a = c-bを満たしていればYes, そうでなければNoを出力する a,b,c = map(int,input().split()) if b-a == c-b: print('Yes') else: print('No')
p02603
s302385928
Wrong Answer
n = int(input()) a = list(map(int, input().split())) + [-1] m, s = 1000, 0 for i in range(n): if a[i] < a[i+1]: s = m//a[i] m -= a[i]*s elif a[i] > a[i+1]: m += a[i]*s s = 0 print(m)
p02971
s042292603
Wrong Answer
N = int(input()) A = [] a = int(input()) M1 = a M2 = a A.append(a) for i in range(N-1): a = int(input()) A.append(a) M1 = max(M1,a) if M2 < a < M1: M2 = a if A.count(M1) >= 2: for i in range(N): print(M1) else: for i in range(N): if A[i] == M1: print(M2) else: print(M1)
p02641
s051461434
Accepted
x,n=map(int,input().split()) if n==0: print(x) else: a=list(map(int,input().split())) for i in range(n//2+1): if not(x-i in a): print(x-i) exit() if not(x+i in a): print(x+i) exit() print(x-1-n//2)
p02767
s469712190
Accepted
import sys n = int(input()) x = list(map(int, input().split())) min_hp = sys.maxsize for i in range(1, 100): hp = 0 for j in range(n): hp += (x[j] - i) * (x[j] - i) min_hp = min(hp, min_hp) print(min_hp)
p02717
s549204545
Accepted
X,Y,Z=map(int,input().split()) A=X B=Y C=Z A,B=B,A A,C=C,A print(A,B,C)
p02933
s655699051
Wrong Answer
a = int(input()) s = input() if a >= 3200: print('red') else: print(s)
p02789
s702541972
Accepted
n, m = map(int, input().split()) if n==m: print('Yes') else: print('No')
p02596
s310184575
Accepted
k = int(input()) r = 0 for i in range(1, k+1): r = (r*10 + 7)%k if r == 0: print(i) exit() print(-1)
p02552
s643767297
Accepted
x=int(input()) if x==0: print(1) else: print(0)
p03274
s871118424
Wrong Answer
n, k = map(int,input().split()) x = list(map(int,input().split())) x.append(0) x.sort() ans = [] for i in range(n-k+1): cnt = 0 cnt += abs(x[i]) for j in range(i,k+i): cnt += abs(x[j+1] - x[j]) ans.append(cnt) print(min(ans))
p03799
s500153869
Accepted
N, M = map(int, input().split()) ans = 0 x = max(0, (M-2*N) // 4) r = min(10, M//2) for i in range(max(0, x-r), x+r): tmp = min(N+i, (M-2*i)//2) ans = max(ans, tmp) print(ans)
p03637
s124877452
Accepted
n=int(input()) a=list(map(int,input().split())) c2=0 c4=0 for aa in a: if aa%2 == 0: if aa%4 == 0: c4+=1 else: c2+=1 c0=n-(c2+c4) cc=c4-c0 if c2>=1 and c2 != n: cc-=1 print("Yes" if cc >= -1 else "No")
p03011
s328003989
Accepted
p,q,r = map(int,input().split()) print(min(p+q,q+r,r+p))
p03695
s338859859
Wrong Answer
N = int(input()) a = list(map(int,input().split())) color = [0 for j in range(9)] for i in range(N): if a[i] >= 3200: color[8] += 1 else: for j in range(8): if a[i] // 400 == j: color[j] += 1 color_min = 8 - color[:8].count(0) if 8 - color_min <= color[8]: if color_min == 0: color_min = 1 color_max = 8 else: color_max = color_min + color[8] print(color_min, color_max)
p02787
s072199007
Accepted
h, n = map(int, input().split()) ab = [list(map(int, input().split())) for _ in range(n)] INF = 1 << 60 dp = [INF] * (h + 1) dp[0] = 0 for i in range(0, h + 1): # hを超えるために必要な最小コストは? for a, b in ab: if i + a <= h: dp[i + a] = min(dp[i] + b, dp[i + a]) else: dp[h] = min(dp[i] + b, dp[h]) print(dp[h])
p02848
s522395045
Wrong Answer
n = int(input()) s = input() strings = [chr(ord(c)+n) if c != "Z" else chr(ord("A")+(n-1)) for c in s] ans = "".join(strings) print(ans)
p02705
s673197596
Accepted
import math R = int(input()) print(R*math.pi*2)
p02983
s860298215
Accepted
L,R=map(int,input().split()) ans=[] for i in range(L,R): for j in range(i+1,R+1): ans.append(i*j%2019) if (i*j)%2019==0: print((i*j)%2019) exit() print(min(ans))
p02682
s779462081
Wrong Answer
def main(): a, b, c, k = map(int, input().split()) if a + b >= k: print(max(a, k)) else: x = k - a - b print(a - x) main()
p02792
s808440365
Accepted
N = int(input()) C = [[0] * 10 for i in range(10)] for i in range(1, N + 1): p = len(str(i)) a = i // (10 ** (p - 1)) b = i % 10 C[a][b] += 1 count = 0 for i in range(10): for j in range(10): count += C[i][j] * C[j][i] #if C[i][j] * C[j][i] > 0: #print(i, j) print(count)
p02598
s120320884
Wrong Answer
import heapq import math N, K = map(int, input().split()) A = list(map(int, input().split())) for i in range(N): p = A[i] A[i] = [-p, i] heapq.heapify(A) C = [0]*N for j in range(K): x, y = heapq.heappop(A) cnt = C[y] x = x * (cnt+1) // (cnt+2) C[y] += 1 heapq.heappush(A, [x, y]) ans = heapq.heappop(A)[0] ans = math.ceil(-ans) print(ans)
p03719
s721763645
Wrong Answer
a,b,c = map(int,input().split()) #lis = list(map(int,input().split())) print("YES" if a <= c <= b else "NO")
p02912
s888029589
Wrong Answer
import heapq def main(): n, m = map(int, input().split()) a = list(map(lambda x: int(x)*(-1), input().split())) heapq.heapify(a) for i in range(m): item = heapq.heappop(a) heapq.heappush(a, item // 2) print(-sum(a)) if __name__ == '__main__': main()
p02953
s802359199
Accepted
def I(): return int(input()) def LI(): return list(map(int,input().split())) ################################################## N = I() H = LI() for i in range(N): if i==0: H[i] -= 1 continue if i==N-1: if H[i-1]<=H[i]: continue if H[i-1]<=H[i]-1<=H[i+1]: H[i] -= 1 continue if H[i-1]<=H[i]<=H[i+1]: continue print('No') break else: print('Yes')
p03377
s710236557
Wrong Answer
A,B,X=map(int,input().split()) print("Yes" if A<=X<A+B else "No")
p02555
s422627112
Accepted
S = int(input()) dp = [0] * (S + 1) dp[0] = 1 M = 10 ** 9 + 7 for i in range(1, S + 1): num = 0 for j in range(i - 2): num += dp[j] dp[i] = num % M print(dp[S])
p02947
s621130715
Accepted
from collections import Counter count_by_kw = Counter() n=int(input()) l=[] dict={} ans=0 for x in range(n): a=sorted(input()) b=''.join(a) if not b in dict: dict[b]=x l.append(b) count_by_kw[b]+=1 else: d=count_by_kw[b] count_by_kw[b]+=1 for y in range(len(l)): r=l[y] w=count_by_kw[r] ans+=w*(w-1)//2 print(ans)
p03711
s871616087
Accepted
a, b = map(int, input().split()) c = [1, 3, 5, 7, 8, 10, 12] d = [4, 6, 9, 11] e = [2] if ((a in c) and (b in c)) or ((a in d) and (b in d)) or ((a in e) and (b in e)): print("Yes") else: print("No")
p02818
s546543275
Accepted
A, B, K = map(int, input().split()) if K > (A + B): print(0, 0) elif A > K: print(A - K, B) else: print(0, A + B - K)
p03487
s563546058
Accepted
import collections n=int(input()) a=list(map(int,input().split())) a=collections.Counter(a) values,counts=zip(*a.most_common()) l=len(values) ans=0 for i in range(0,len(values)): if counts[i]<values[i]: ans=ans+counts[i] elif counts[i]>values[i]: ans=ans+counts[i]-values[i] print(ans)
p02712
s076050434
Accepted
n = int(input()) a = n // 3 b = n // 5 c = n // 15 print(n * (n + 1) // 2 - a * (a + 1) // 2 * 3 - b * (b + 1) // 2 * 5 + c * (c + 1) // 2 * 15)
p02553
s166587236
Wrong Answer
a,b,c,d=map(int,input().split()) ans=max(a*c,b*d,a*d,b*d) print(ans)
p02598
s256506224
Accepted
n, k = map(int, input().split()) a = list(map(int, input().split())) def check(l): t = 0 for i in a: t += -(-i // l) - 1 return t <= k l, r = 0, 10 ** 9 + 1 while r - l > 1: mid = (l + r) // 2 + (l + r) % 2 if check(mid): r = mid else: l = mid print(r)
p03285
s266425377
Wrong Answer
n = int(input()) for i in range(1, 26): for j in range(1, 16): if(4*i+7*j==n): print("Yes") break else: print("No")
p02953
s857651145
Wrong Answer
n=int(input()) h=list(map(int,input().split())) if h[-1]!=1: print("Yes") else: print("No")
p02854
s548175583
Accepted
N = int(input()) A = list(map(int, input().split())) total = sum(A) mid = total // 2 sum_left, sum_left2 = 0, 0 sep_idx = 0 for i, l in enumerate(A): sum_left += l if sum_left >= mid: sep_i = i sum_left2 = sum_left - l break sum_right, sum_right2 = sum(A[sep_i + 1:]), sum(A[sep_i:]) print(min(abs(sum_right - sum_left), abs(sum_right2 - sum_left2)))
p02765
s997287917
Accepted
N, p = map(int,input().split()) if N < 10: K = 100 * (10 - N) print(p + K) else: print(p)
p03328
s491466035
Wrong Answer
a,b=map(int,input().split()) ans=0 for i in range(b): ans+=i if a<ans and ans<b : print(ans-a) break else : continue
p03767
s816059763
Accepted
n = int(input()) A = sorted(list(map(int, input().split()))) print(sum(A[-2:-2 * n - 1:-2]))
p03219
s694022031
Accepted
x,y=map(int,input().split()) print(x+y//2)
p02571
s581475256
Wrong Answer
import sys def input(): return sys.stdin.readline().strip() def I(): return int(input()) def LI(): return list(map(int, input().split())) def IR(n): return [I() for i in range(n)] def LIR(n): return [LI() for i in range(n)] def SR(n): return [S() for i in range(n)] def S(): return input() def LS(): return input().split() INF = float('inf') s = S() t = S() ans = INF for i in range(len(s)-len(t)): now = 0 for j in range(i, i+len(t)): if s[j] != t[j-i]: now += 1 ans = min(ans, now) print(ans)
p02631
s824864606
Accepted
n = int(input()) a = list(map(int,input().split())) ans = 0 for i in a: ans ^= i for i in a: print(ans ^ i, end = ' ')
p03417
s721275513
Accepted
n, w = map(int, input().split()) if n*w==1: print(1) elif n==1: print(w-2) elif w==1: print(n-2) elif n==2 or w==2: print(0) else: print((n-2)*(w-2))
p02678
s489816221
Accepted
from collections import deque n, m = map(int,input().split()) graph =[[] for _ in range(n+1)] for _ in range(m): a,b =map(int, input().split()) graph[a].append(b) graph[b].append(a) queue = deque([1]) visited = [False] * (n+1) visited[0] = True ans = [0] * (n+1) while queue: node = queue.popleft() for xnode in graph[node]: if visited[xnode]: continue ans[xnode]=node visited[xnode]=True queue.append(xnode) print("Yes") for a in ans[2:]: print(a)
p02795
s427323478
Accepted
h = int(input()) w = int(input()) n = int(input()) x = max(h, w) ans = (n + x - 1) // x print(ans)
p02833
s781522196
Wrong Answer
import sys from itertools import accumulate, repeat, takewhile from operator import mul def main(): N = int(next(sys.stdin.buffer)) print(sum(N // x for x in takewhile(lambda x: x <= N, accumulate(repeat(5), mul, initial=10)))) if __name__ == '__main__': main()
p02596
s204753661
Accepted
k = int(input()) a = 0 for i in range(k + 10): a = (a*10 + 7)%k if a == 0: print(i + 1) exit() print(-1)
p03137
s317154741
Accepted
N, K = map(int, input().split()) L = list(map(int, input().split())) L.sort() s = len(L) L_dif = [[i,L[i+1]-L[i]] for i in range(s-1)] L_dmax = L_dif.copy() L_dmax.sort(key=lambda tup: tup[1:], reverse=True) size = L[K-1]-L[0] piv = min(K,N) rem_dif = [L_dmax[i][1] for i in range(piv-1)] ans = size - sum(rem_dif) print(ans)
p03860
s869910807
Wrong Answer
print('A'+input()[0]+'C')
p03329
s146156818
Accepted
#解説見ながら n = int(input()) ans = n for i in range(n+1) : c = 0 a = n-i while a>0 : c += a%6 a = a//6 a = i while a>0 : c += a%9 a = a//9 if c<ans : ans = c print(ans)
p03433
s252463337
Wrong Answer
N=int(input()) A=int(input()) if N%500<=A: print('YES') else: print('NO')
p03672
s293784593
Accepted
s = input() length = len(s) maxlen = 0 for i in range(length//2-1): if s[0:(i+1)] == s[(i+1):2*(i+1)]: maxlen = 2*(i+1) print(maxlen)
p02771
s657237210
Accepted
a,b,c=map(int,input().split()) if a==b and a!=c: print("Yes") elif a==c and a!=b: print("Yes") elif b==c and b!=a: print("Yes") else: print("No")
p02879
s044621428
Accepted
a,b = map(int,input().split()) if a>9: print(-1) elif b>9: print(-1) else: print(a*b)
p03069
s292631300
Accepted
import sys readline = sys.stdin.readline MOD = 10 ** 9 + 7 INF = float('INF') sys.setrecursionlimit(10 ** 5) def main(): n = int(readline()) s = input() ans = s.count(".") cur = ans for i, char in enumerate(s): if char == ".": cur -= 1 else: cur += 1 ans = min(ans, cur) print(ans) if __name__ == '__main__': main()
p02712
s860422931
Accepted
n=int(input()) a=0 for i in range(n+1): if i%3!=0 and i%5!=0: a+=i print(a)
p03338
s881704060
Accepted
N=int(input()) S=list(input()) max=0 for i in range(1,(N)): a=S[:i] b=S[i:] L= len(set(a)&set(b)) if L>max: max=L print(max)
p03011
s346745680
Wrong Answer
k=list(map(int,input().split())) k.sort print(int(k[0])+int(k[1]))
p03730
s409468404
Accepted
from collections import defaultdict def readInt(): return int(input()) def readInts(): return list(map(int, input().split())) def readChar(): return input() def readChars(): return input().split() a,b,c = readInts() i = a his = [] while 1: if i%b==c: print("YES") exit() else: if i%b in his: print("NO") exit() else: his.append(i%b) i+=a
p03673
s704273588
Wrong Answer
n = int(input()) l = list(map(int,input().split())) a = l[n-1::-2] if n % 2 == 0: a.append(l[0::2]) else: a.append(l[1::2]) print(a)
p03438
s945872611
Accepted
def main(): N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) need = 0 stock = 0 for a, b in zip(A, B): if a > b: need += (a-b) if b > a: stock += (b-a)//2 if stock >= need: print("Yes") else: print("No") if __name__ == "__main__": main()
p02818
s985517104
Accepted
A,B,K = map(int,input().split()) if A >= K: A = A - K print(str(A)+ ' '+str(B)) else: B = B - (K - A) A = 0 if B < 0: print('0 0') else: print(str(A)+ ' '+str(B))
p02947
s926689778
Wrong Answer
n = int(input()) s = [input() for i in range(n)] def get_unique_list(seq): seen = [] return [x for x in seq if x not in seen and not seen.append(x)] # [[1, 1], [0, 1], [0, 0], [1, 0]] for i in range(n): s[i] = sorted(s[i]) print(len(get_unique_list(s)))
p02546
s259980116
Accepted
s = input() if s[-1] == "s": print(s + "es") else: print(s + "s")
p02597
s318616024
Accepted
N = int(input()) c = input() r = c.count("R") w = c.count("W") a = "R"*r+"W"*w ans = 0 for i in range(N): if(c[i] != a[i]): if(c[i] == "W" and a[i] == "R"): ans += 1 print(ans)
p02811
s286859059
Accepted
K,X = map(int, input().split()) if K*500 >= X: print("Yes") else: print("No")
p02622
s933750733
Accepted
S = input() T = input() cnt = 0 for i in range(len(S)): if S[i] != T[i]: cnt += 1 print(cnt)
p02576
s001740538
Accepted
n, x, t = input().split() z = ((int(n)+int(x))-1)//int(x) ans = z * int(t) print(ans)
p03073
s562939355
Wrong Answer
import math from math import gcd INF = float("inf") import sys input=sys.stdin.readline sys.setrecursionlimit(500*500) import itertools from collections import Counter,deque def main(): s = input().rstrip() ans = 0 b = s[0] for i in s[1:]: i = int(i) if b == i: ans += 1 b = 1-i else: b = i print(ans) if __name__=="__main__": main()
p02897
s188764811
Accepted
n = int(input()) x = 0 for i in range(1,n+1): if(i%2 == 1): x += 1 print(x/n)
p03075
s433334788
Accepted
a=int(input()) for i in range(3): bcd=int(input()) e = int(input()) k=int(input()) if (e-a)>k: print(':(') else: print('Yay!')
p03861
s772046168
Accepted
from decimal import * a, b, x = map(Decimal, input().split()) if a == 0: a_div = 0 else: a_div = (a-1) // x + 1 b_div = b // x + 1 ans = b_div - a_div print(ans)
p02795
s634604462
Wrong Answer
H = int(input()) W = int(input()) N = int(input()) if N % max(H, W) == 0: print(N / max(H, W)) else: print(round(N / max(H, W) + 1))
p03293
s578399403
Accepted
S = input() T = input() for n in range(len(S)): S = S[-1]+S[:-1] if S==T: print("Yes") exit() print("No")
p02988
s398154205
Accepted
n = int(input()) p = list(map(int, input().split())) cnt = 0 for i in range(1, n-1): if p[i-1]<p[i]<p[i+1] or p[i+1]<p[i]<p[i-1]: cnt += 1 print(cnt)
p02695
s326723040
Accepted
def main(): N, M, Q = [int(x) for x in input().split()] queries = [[int(x) for x in input().split()] for _ in range(Q)] ans = float("-inf") import itertools for A in itertools.combinations_with_replacement(range(1, M+1), N): # print(A) s = 0 for a, b, c, d in queries: if A[b-1] - A[a-1] == c: s += d ans = max(ans, s) print(ans) if __name__ == '__main__': main()
p03076
s301817656
Wrong Answer
s,i=0,0 for i in range(5): s=s+int(input()) if i==4: print(s) exit() while(s>10*i): i+=1 s=10*(i) print(s)
p03605
s759656396
Wrong Answer
a = input() if a[0] == 9 or a[1] == 9: print('Yes') else: print('No')
p03994
s199654626
Accepted
s=list(input()) k=int(input()) for i in range(len(s)): if i==len(s)-1: s[-1]=chr((ord(s[i])-97+k)%26+97) break if s[i]=='a': continue if 123-ord(s[i])<=k: k-=123-ord(s[i]) s[i]='a' print(*s,sep='')
p02866
s652694762
Accepted
#!/usr/bin/env python3 from collections import* n, *d= map(int, open(0).read().split()) c = Counter(d) if d[0] or c[0] > 1: exit(print(0)) MOD = 998244353 m = 1 for i in range(1, max(d)): m *= pow(c[i], c[i + 1], MOD) m %= MOD print(m)
p03644
s447926164
Wrong Answer
N=int(input()) ct=0 while N>1: N=N//2 ct+=1 print(ct)
p03379
s879845783
Accepted
N = int(input()) X = list(map(int, input().split())) xs = sorted(X) median1 = xs[N//2-1] median2 = xs[N//2] for i in range(N): if X[i] == median1: print(median2) elif X[i] == median2: print(median1) elif X[i] < median1: print(median2) elif X[i] > median2: print(median1)
p02811
s840728793
Accepted
K,X=list(map(int,input().split())) if 500*K>=X: print('Yes') else: print('No')
p02859
s734064761
Accepted
r = int(input()) print(r*r)
p03327
s390728179
Wrong Answer
n = int(input()) if n >= 1000: print("ABD" + str(n - 999).zfill(3)) else: print("ABC" + str(n))
p03838
s621836252
Wrong Answer
x,y=map(int,input().split()) if x<=y: if x<0 and -x<y: print(1+y+x) else: print(y-x) elif y<x and 0<=x and 0<=y: print(y-(-x)+1) elif y<x and 0<=x and y<0: print(-y-x+1) elif y<x and x<0 and y<0: print(-y--x+2) else: print(y-x)
p03645
s356983296
Accepted
import sys readline = sys.stdin.readline MOD = 10 ** 9 + 7 INF = float('INF') sys.setrecursionlimit(10 ** 5) def main(): from collections import defaultdict, deque n, m = map(int, readline().split()) edge = defaultdict(set) for _ in range(m): a, b = map(int, readline().split()) edge[a].add(b) edge[b].add(a) for u in edge[1]: if n in edge[u]: print("POSSIBLE") sys.exit() print("IMPOSSIBLE") if __name__ == '__main__': main()
p02657
s933662330
Accepted
a, b = map(int,input().split()) print(a * b)
p03555
s127103004
Wrong Answer
# 文字列を取得 C1 = str(input()) C2 = str(input()) # 文字列の結合 ori_str = C1 + C2 # 末尾から1文字ずつ取得して逆さま文字を生成 rev_str = ori_str[-1::-1] # 比較結果を出力 if ori_str == rev_str: print("Yes") else: print("No")
p03695
s470688533
Accepted
N = int(input()) a = list(map(int, input().split())) c = [0] * 9 for rate in a: i = rate // 400 if i < 8: c[i] = 1 else: c[8] += 1 c_sum = sum(c[:8]) c_min = max(c_sum, 1) c_max = c_sum + c[8] print(c_min, c_max)
p03997
s424572843
Accepted
a = int(input()) b = int(input()) h = int(input()) print((a+b)*h//2)
p03041
s804918462
Wrong Answer
n, k = map(int, input().split()) S = input() char_k = S[k-1] S_ch = S.replace(S[k-1], str.lower(char_k)) print(S_ch)
p03323
s059060961
Wrong Answer
a,b=map(int,input().split()) print("Yay" if abs(a-b)<=2 else ":(")
p03075
s604630166
Wrong Answer
a=int(input()) b=int(input()) c=int(input()) d=int(input()) e=int(input()) x=int(input()) ls=[a,b,c,d,e] if (ls[1]-ls[0])<=x and (ls[2]-ls[1])<=x and (ls[3]-ls[2])<=x and (ls[4]-ls[3])<=x: print("Yay!") else: print(":(")