problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p03627
s580567625
Wrong Answer
import collections N = int(input()) a = collections.Counter(list(map(int,input().split()))) #a = sorted(a.items(), key=lambda x: -x[0],reverse=True) #for k, v in sorted(a.items(), key=lambda x: -x[0]):pass a = sorted(a.items(), key=lambda x:x[0],reverse=True) #print(a) cnt = 0 num = [] n = 0 for i,v in a: if 4 <...
p02813
s196080218
Wrong Answer
#C - Count Order import math import itertools N = int(input()) P = tuple(map(int,input().split())) Q = tuple(map(int,input().split())) li = list(itertools.permutations(P,N)) li.sort() a = 0 b = 0 for i in range(math.factorial(N)): if li[i] == P: a = i elif li[i] == Q: b = i else: ...
p03075
s104872786
Wrong Answer
import math n,*l=map(int,open(0).read().split()) print(4+math.ceil(n/min(l)))
p02917
s318896206
Accepted
N=int(input()) B=list(map(int,input().split())) A=[] for c in B: A.append(c) A.append(B[-1]) for a in range(len(B)): if A[a]>B[a]: A[a]=B[a] elif A[a+1]>B[a]: A[a+1]=B[a] print(sum(A))
p02576
s601209536
Accepted
N, X, T = map(int, input().split()) import math print(math.ceil(N / X) * T)
p03239
s738283939
Accepted
n,T = map(int, input().split()) l = [] for i in range(n): c,t = map(int, input().split()) if t <= T: l.append(c) if l != []: print(min(l)) else: print("TLE")
p03795
s977090426
Accepted
n = int(input()) print(800*n-(n//15*200))
p02780
s711378157
Accepted
N, K = map(int, input().split()) dice = list(map(int, input().split())) ma = 0 kitai = [0]*N for i in range(N): kitai[i] = (((dice[i]+1)*dice[i])/2)/dice[i] for i in range(K): ma += kitai[i] tmp = ma for i in range(K,N): tmp = tmp - kitai[i-K] + kitai[i] ma = max(tmp,ma) print(ma)
p02948
s053056057
Accepted
N,M=map(int,input().split()) AB=[] for _ in range(N): a,b=map(int,input().split()) AB.append([a,b]) AB.sort(key=lambda x:x[0]) import heapq h=[] day=1 count=0 ans=0 while True: if day>M: break while count!=N: if AB[count][0]!=day: break heapq.heappush(h,-AB[count][1])...
p02705
s608272679
Wrong Answer
import math r=float(input()) L=2*math.pi*r print('L={0}'.format(L))
p03759
s942186352
Accepted
a, b, c = map(int, input().split()) if b-a == c-b: print("YES") else: print("NO")
p02640
s685030361
Accepted
x, y = map(int, input().split()) for c in range(x+1): t = x - c if 2*c + 4*t == y: print('Yes') exit() print('No')
p03086
s443608484
Wrong Answer
import re pattern = re.compile('[ACGT]+') S = input() print(len(max(re.findall(pattern, S), default='')))
p03681
s839278140
Accepted
n,m = map(int,input().split()) mod = 10**9 + 7 import math def perm(n, r): return (math.factorial(n) // math.factorial(n - r))%mod if abs(n-m) >= 2: print(0) else: mx = max(n,m) mn = min(n,m) p = math.factorial(mn)%mod k = (mn-1)*math.factorial(mx)%mod if mn == mx else 0 print(p*(perm(mn+1,...
p02835
s166791934
Wrong Answer
L,M,N = map(int,input().split()) print("win" if L+M+N >= 22 else "bust")
p03011
s202087750
Accepted
p , q ,r = map(int,input().split()) print(p+q+r-max(p,q,r))
p02711
s278477684
Accepted
N=input() if "7" in N: print("Yes") else: print("No")
p02912
s824195539
Wrong Answer
n,m = map(int,input().split()) a = list(map(int,input().split())) a.sort() for i in range(m): a[n-1] = int(a[n-1]//2) a.sort() res = 0 for i in range(n): res += i print(res)
p03416
s482747819
Accepted
A,B=map(int,input().split()) ans=0 for i in range(A,B+1): check1=str(i) check2=check1[::-1] if check1==check2: ans+=1 print(ans)
p02624
s545127132
Accepted
n = int(input()) print(sum((n // i + 1) * (n // i) // 2 * i for i in range(1, n + 1)))
p02664
s551676547
Accepted
t = input() n = len(t) ans = [] for i in range(n): if t[i] != "?": ans.append(t[i]) else: ans.append("D") print("".join(ans))
p02970
s748320155
Accepted
N, D = map(int, input().split()) r = (2 * D + 1) if N % r == 0: print(N // r) else: print(N // r + 1)
p03211
s433042606
Accepted
s = input() n = 753 ans = float('inf') for i in range(len(s)-2): x = int(s[i:i+3]) if abs(x-n) < ans: ans = abs(x-n) print(ans)
p02759
s589736884
Accepted
from math import * N = int(input()) print(ceil(N/2))
p02910
s136224615
Wrong Answer
s = input() for i in range (len(s)//2): if s[2*i] == 'L' or s[2*i+1] == 'R' or s[-1] == 'L': print('No') exit() print('Yes')
p02971
s921774588
Accepted
import sys input=sys.stdin.buffer.readline n=int(input()) L=list(int(input()) for i in range(n)) N=sorted(L) for i in range(n): print(N[-1] if L[i]!=N[-1] else N[-2])
p02829
s820527678
Accepted
a=int(input()) b=int(input()) print(6-a-b)
p03680
s077851242
Accepted
n = int(input()) a = [] for i in range(n): a.append(int(input())) k = 1 p = False for i in range(n): if a[k-1] == 2: print(i+1) p = True break k = a[k-1] if not p: print(-1)
p03407
s531190889
Accepted
a, b, c = map(int, input().split()) print('Yes' if a + b >= c else 'No')
p02900
s789087778
Wrong Answer
# -*- coding: utf-8 -*- A, B = map(int, input().split()) n = max(A, B) ** 0.5 n = int(n) + 2 is_primes = [True for _ in range(n)] for i in range(2, n): if is_primes[i]: for j in range(i*2, n, i): is_primes[j] = False # print(is_primes) ans = [1] for i in range(2, n): if is_primes[i]: ...
p02577
s310598409
Accepted
a = int(input()) if a % 9 == 0: print("Yes") else: print("No")
p03387
s049881775
Wrong Answer
A = sorted(map(int, input().split())) x = 0 while A[0] < A[2] - 1: A[0] += 2 x += 1 while A[1] < A[2] - 1: A[1] += 2 x += 1 if A[0] == A[1]: x = x + 1 else: x = x + 1 print(x)
p02811
s935425903
Wrong Answer
X,K=map(int,input().split()) if 500*X>K : print('Yes') else : print('No')
p03795
s743645175
Accepted
n = int(input()) n = n*800 - (n//15)*200 print(n)
p03339
s933272946
Accepted
n = int(input()) s = input() e_l, e_sum = [], 0 w_l, w_sum = [], 0 for i in range(n): if s[i] == 'E': e_sum += 1 else: w_sum += 1 e_l.append(e_sum) w_l.append(w_sum) for i in range(n): if i == 0: ans = e_l[n-1] - e_l[0] elif i == n: ans = max(ans, w_l[n-2]) el...
p03351
s276299402
Accepted
import sys a,b,c,d=map(int,input().split()) if abs(a-c)<=d: print("Yes") sys.exit() if abs(a-b)<=d and abs(b-c)<=d: print("Yes") sys.exit() print("No")
p02775
s829541003
Accepted
n = "0" + input() ans = 0 n_dig = len(n) # Nの桁数 carry = 0 d_next = int(n[n_dig - 1]) for i in range(n_dig - 1, 0, -1): # n[0]はダミーなのでn[1]で止める d = d_next d_next = int(n[i - 1]) if carry + d <= 4 or (carry + d == 5 and d_next <= 4): ans += d + carry carry = 0 # 繰り上がり else: ans...
p02897
s282903502
Accepted
N=int(input()) Odd=0 for i in range(1,N+1): if i%2==1: Odd+=1 print(Odd/N)
p03767
s652038116
Wrong Answer
n=int(input()) a=list(map(int,input().split())) a.sort() for i in range(n): a.pop() ans=0 for i in range(1,n+1): ans+=a[-i] print(ans)
p02818
s201665997
Accepted
A, B, K = map(int,input().split()) if A + B <= K: a = 0 b = 0 else: if K == 0: a = A b = B elif K > A: a = 0 b = abs(B-(K-A)) elif K == A: a = 0 b = B elif K < A: a = A - K b = B print(a,b)
p03127
s019533101
Accepted
# solution import fractions data=int(input()) array=list(map(int,input().split())) array1=[] for i in range(1,data): array1.append(fractions.gcd(array[0],array[i])) print(min(array1))
p03017
s394111188
Accepted
n, a, b, c, d = map(int, input().split()) s = input() if c < d: if s[a-1:c].find('##')==-1 and s[b-1:d].find('##')==-1: print('Yes') else: print('No') else: if s[a-1:c].find('##')==-1 and s[b-1:d].find('##')==-1 and s[b-2:d+1].find('...')!=-1: print('Yes') else: print('N...
p02689
s240887952
Accepted
import sys import numpy as np read = sys.stdin.read n, m = map(int, input().split()) h = list(map(int, input().split())) way = np.array(read().split(), dtype=np.int64).reshape([m,2]) - 1 o = np.ones(n) for i in way: a, b = i if h[a] <= h[b]: o[a] = 0 if h[b] <= h[a]: o[b] = 0 ans = np.cou...
p03109
s249542257
Accepted
s=input() if s<="2019/04/30": print("Heisei") else: print("TBD")
p03485
s157330765
Wrong Answer
import statistics a=list(map(int,input().split())) print(round(statistics.mean(a)))
p02572
s549035621
Accepted
N = int(input()) A = list(map(int, input().split())) Asum = sum(A) % (10**9 + 7) ans = 0 for i in range(N): Asum = Asum - A[i] ans += A[i]*Asum % (10**9 + 7) ans = ans % (10**9 + 7) print (ans)
p02755
s036114523
Accepted
a,b=map(int,input().split()) for i in range(10**5): if (i*2)//25==a and i//10==b: print(i) break else: print(-1)
p03163
s521668197
Accepted
import sys input = sys.stdin.readline N, W = [int(x) for x in input().split()] wv = [] for _ in range(N): wv.append([int(x) for x in input().split()]) dp = [[0] * (W + 1) for _ in range(N + 1)] for i in range(N): for j in range(W + 1): w, v = wv[i] if j >= w: dp[i + 1][j] = max(dp...
p02660
s918076883
Wrong Answer
from collections import defaultdict N = int(input()) if N == 1: print(0) exit() index = int(pow(N, 0.5) + 1) ans = [] for i in range(2, index): while N % i == 0: N //= i ans.append(i) if ans == []: print(1) exit() d = defaultdict(int) for i in ans: d[i] += 1 anscnt = 0 for v,...
p02663
s546343373
Accepted
H1, M1, H2, M2, K = list(map(int, input().split())) time1 = H1 * 60 + M1 time2 = H2 * 60 + M2 time3 = time2 - K if time3 < time1: print(0) else: print(time3 - time1)
p02836
s343091111
Accepted
#!/usr/bin/env python3 S = input() count = 0 for i in range(len(S)//2): if S[i] != S[-i-1]: count += 1 print(count)
p02627
s261226068
Accepted
N = input() if N.isupper(): print('A') else: print('a')
p03481
s886175208
Accepted
x,y = map(int,input().split()) i = 2 cnt = 0 while 1: if x > y: break x *= 2 cnt += 1 print(cnt)
p03254
s231194251
Accepted
N,x = map(int, input().split()) A = list(map(int, input().split())) A.sort() ans = 0 for i in range(N): if x > A[i]: if i+1 == N: print(N-1) exit() else: ans += 1 x -= A[i] elif x == A[i]: ans += 1 print(ans) exit() else: print(ans) exit()
p02726
s822610817
Wrong Answer
N, X, Y = map(int, input().split()) d = Y-X c = [] for i in range(1,N): for j in range(i+1,N+1): if i == X and j == Y: c.append(1) elif j-i<=d: c.append(j-i) else: c.append(j-i-d+1) for i in range(1,N): ans = c.count(i) print(ans)
p02661
s908710416
Accepted
def median(q): l=len(q) q=sorted(q,reverse=True) if l%2==0: return (q[int(l/2)]+q[int(l/2)-1])/2 else: return q[int((l+1)/2-1)] n=int(input()) a=[] b=[] for i in range(n): x,y=map(int,input().split()) a.append(x) b.append(y) med_a=median(a) med_b=median(b) if n%2==0: ...
p03001
s851237419
Wrong Answer
w,h,x,y = map(int,input().split()) left = x * h right = (w - x)*h tatemin = min(left,right) under = w * y top = w * (h - y) yokomin = min(under,top) bigger = max(tatemin,yokomin) if tatemin == yokomin: print(bigger,1) else: print(bigger,0)
p02659
s132443879
Accepted
a,b=input().split() a=int(a) b=int(b.replace('.','')) ans=int(a*b) print(ans//100)
p02866
s623500272
Wrong Answer
N=int(input()) D=list(map(int,input().split())) mod=99824453 if D[0]!=0: print(0) exit() B=[0]*N for d in D: B[d]+=1 if B[0]!=1: print(0) exit() ans=1 total=1 for i in range(1,N): if B[i]==0:break total+=B[i] ans*=(B[i-1]**B[i])%mod if total==N: print(ans) else: print(0)
p03705
s543940277
Accepted
n, a, b = map(int, input().split()) if n == 1 and a != b: print(0) elif a > b: print(0) else: print((n-2) * (b - a) + 1)
p04005
s724449842
Accepted
a,b,c = map(int,input().split()) print(min((a%2)*b*c,(b%2)*a*c,(c%2)*b*a))
p03730
s403745427
Accepted
def gcd(x, y): while y: x, y = y, x%y return x A, B, C = map(int, input().split()) if C % gcd(A, B) == 0 : print('YES') else: print('NO')
p02910
s549114142
Wrong Answer
s = input() for i in range(len(s)): if i % 2 == 0 and (s[i] != "L" and s[i] != "U" and s[i] != "D"): print("NO") break elif i % 2 == 1 and (s[i] != "R" and s[i] != "U" and s[i] != "D"): print("NO") break else: print("YES") break
p03328
s047249168
Wrong Answer
a,b = map(int,input().split()) n = b-a print(n*(n+1)/2 - b)
p03457
s290273825
Wrong Answer
N=int(input()) for i in range(N): t,x,y = map(int,input().split()) if ((x+y+t)%2 != 0) & (abs(x+y)>t): print("No") exit() print("Yes")
p03835
s590094664
Accepted
K, S = map(int, input().split()) c = 0 for x in range(K+1): for y in range(K+1): if 0 <= (S-x-y) <= K: c += 1 print(c)
p03761
s313134399
Accepted
from collections import Counter n = int(input()) Ans = Counter(input()) for i in range(n-1): Ans = Ans & Counter(input()) a = [] for key, value in Ans.items(): a += [key] * value a.sort() print(''.join(a))
p02773
s096400787
Accepted
import sys from collections import Counter read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N = int(readline()) l = read().decode().split() c = Counter(l) max = c.most_common()[0][1] ans = [i[0] for i in c.items() if i[1] >= max] print('\n'.join(sorted(an...
p03455
s539049512
Wrong Answer
a,b=input().split() a,b=map(int,(a,b)) if a*b%2==0: print("EVEN") else : print("0dd")
p03759
s939820501
Accepted
a, b, c = map(int, input().split()) if b - a == c - b: print("YES") else: print("NO")
p04005
s856450767
Wrong Answer
a, b, c = map(int, input().split()) ans = 0 if (a*b*c)%2 == 0 else int(a*b*c/max(a, b, c)) print(ans)
p03126
s347163198
Accepted
N,M = map(int,input().split()) d = {i:0 for i in range(1,M+1)} for _ in range(N): L = list(map(int,input().split()))[1:] for i in L: d[i] += 1 cnt = sum([1 for k,v in d.items() if v == N]) print(cnt)
p02607
s755416012
Accepted
N=int(input()) *A,=map(int,input().split()) ans=0 i=0 while i<N: if i%2==0 and A[i]%2==1: ans+=1 i+=1 print(ans)
p03385
s673625642
Accepted
import numpy as np S=input() if S[0]!=S[1] and S[1]!=S[2] and S[2]!=S[0]: print('Yes') else: print('No')
p02900
s942437414
Accepted
import math def gcd(a,b): if a==0: return b return gcd(b%a,a) def div(n): cnt = 0 temp = n for i in range(2,int(math.sqrt(n))+1): if temp%i==0: while temp%i==0: temp //= i cnt += 1 if temp!=1: cnt+=1 return cnt+1 a,b = map(int,input()....
p02753
s300151114
Accepted
S=list(input()) if S[0]==S[1] and S[0]==S[2]: print('No') else: print('Yes')
p03627
s682705409
Accepted
from collections import Counter N = int(input()) Ac = Counter(list(map(int, input().split()))) sticks = sorted({k:v for k, v in Ac.items() if v >= 2}.items())[::-1] if len(sticks) == 0: print(0) else: if sticks[0][1] >= 4: print(sticks[0][0]**2) else: print(sticks[0][0]*sticks[1][0])
p02553
s921812185
Wrong Answer
a,b,c,d = map(int,input().split()) mx = 0 print(b*d)
p03319
s755966263
Wrong Answer
from math import ceil n,k=map(int,input().split()) L=list(map(int,input().split())) print(ceil(n/(k-1)) if n!=k else "1")
p03352
s687184124
Wrong Answer
x = int(input()) for i in range(1,100)[::-1]: if i*i <= x: print(i*i) exit()
p03317
s771566221
Accepted
n,k = map(int,input().split()) a_ = list(map(int,input().split())) if (n-1)%(k-1) == 0: print((n-1)//(k-1)) else: print((n-1)//(k-1)+1)
p03327
s516450461
Accepted
N = int(input()) if N < 1000: print('ABC') else: print('ABD')
p02714
s633365504
Wrong Answer
N = int(input()) str = input() i, j, k = [], [], [] total = 0 for n in range(N): if str[n]=='R': i.append(n+1) elif str[n]=='G': j.append(n+1) else: k.append(n+1) for I in i: for J in j: total += 1 if not(J*2-I in k) else 0 print(total)
p03472
s837959904
Accepted
import math N,H = map(int, input().split()) A = 0 B = [] for i in range(N): a,b = map(int, input().split()) A = max(A, a) B.append(b) B.sort(reverse=True) accum_B = [0] * (N+1) for i in range(1, N+1): accum_B[i] = accum_B[i-1] + B[i-1] ans = H+1 for i in range(N+1): if H - accum_B[i] <= 0: ans = min(...
p03799
s795924842
Wrong Answer
n, m = map(int, input().split()) cnt = 0 if n > m // 2: cnt += m // 2 m -= m // 2 n = 0 else: cnt += n m -= n * 2 n = 0 cnt += m // 4 print(cnt)
p02900
s443763695
Accepted
import fractions import math from collections import Counter a, b = map(int, input().split()) n = fractions.gcd(a, b) prime_count = Counter() for i in range(2, math.ceil(math.sqrt(n))+1): while n % i == 0: n /= i prime_count[i] += 1 if n > 1: prime_count[int(n)] += 1 print(len(prime_count)+1)
p03486
s949714041
Accepted
s = input() t = input() s = sorted(s) t = sorted(t, reverse=True) s_asc = ''.join(s) t_desk = ''.join(t) if s_asc < t_desk: print('Yes') else: print('No')
p02554
s223554436
Wrong Answer
N = int(input()) mod = int(1e9) + 7 print(pow(10, N, mod) - pow(9, N, mod) - pow(9, N, mod) + pow(8, N, mod))
p03474
s814559013
Accepted
a,b = map(int,input().split()) s = input() s1 = s[0:a] s2 = s[a] s3 = s[a + 1:a + b + 1] if "-" not in s1 and s2 == "-" and "-" not in s3: print("Yes") else: print("No")
p03611
s783916880
Accepted
n = int(input()) cnt = [0] *100002 a = list(map(int, input().split())) for v in a: cnt[v] += 1 cnt[v+1] += 1 cnt[v+2] += 1 print(max(cnt))
p02601
s974593028
Accepted
import sys def input(): return sys.stdin.readline().rstrip() def main(): a, b, c = map(int,input().split()) k = int(input()) cunt = 0 while a >= b: b *= 2 cunt += 1 while b >= c: c *= 2 cunt += 1 if cunt > k: print("No") else: print("Yes") ...
p02712
s421849720
Accepted
n = int(input()) sum = 0 for i in range(n + 1): if i % 3 != 0 and i % 5 != 0 and i % 15 != 0: sum += i print(sum)
p03695
s284654975
Wrong Answer
N=int(input()) l=[int(x) for x in input().rstrip().split()] rate=[False]*8 cnt=0 for i in l: for j in range(1,8+1): if 3200<=i: cnt+=1 break if i<=j*400-1: rate[j-1]=True break print(sum(rate),sum(rate)+cnt)
p03695
s595954851
Accepted
import sys input = sys.stdin.readline n=int(input()) a=list(map(int,input().split())) b={} cnt=0 for i in a: if i<3200: b[i//400]=1 else: cnt+=1 if sum(b.values())==0: print(1,cnt) exit() print(sum(b.values()),sum(b.values())+cnt)
p03285
s274735939
Wrong Answer
n = int(input()) x = n % 4 y = n % 7 if n%4 == 0 or n%7 == 0 or x%7 == 0 or y%4==0: print("Yes") else: print("No")
p03146
s276679225
Wrong Answer
def ABC116B(s): if s % 2 == 0: return s//2 else: return 3*s+1 s = int(input()) p = 1 a = False#二回目の4の判断 while True: s = ABC116B(s) p += 1 if s == 4: if a: print(p) break else: a = True
p03817
s017566255
Wrong Answer
x = int(input()) ans = x // 11 if 0 < ans * 11 < x: ans = ans * 2 + 1 else: ans = ans * 2 if ans == 0: if 6 > x: ans = 1 elif 11 > x: ans = 2 print(ans)
p03013
s833784022
Wrong Answer
n,m = map(int, input().split()) a = [int(input()) for _ in range(m)] large = 10**9 +7 count = [0]*(n+1) itr = 0 count[0] = 1 if m >0 and a[0] != 1 : count[1] = 1 else: count[1] = 0 itr = 1 for i in range(2,n+1): if m > 0 and itr<len(a) and a[itr] == i: itr +=1 continue else: ...
p03385
s037347009
Accepted
s=input() b=''.join(sorted(s)) if b=="abc": print("Yes") else: print("No")
p03377
s434297377
Accepted
A,B,X = map(int, input().split()) if A <= X < A+B: print("YES") else: print("NO")