problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02952
s811019965
Accepted
def main(): n = int(input()) # n, k = map(int, input().split()) # h = list(map(int, input().split())) # s = input() count = 0 for i in range(1, n+1): i = str(i) if len(i) % 2 != 0: count += 1 print(count) if __name__ == '__main__': main()
p03000
s719623592
Accepted
n,x=map(int,input().split()) l=list(map(int,input().split())) ans=1 cursum=0 for i in range(n): cursum+=l[i] if cursum <= x: ans+=1 print(ans)
p03071
s243488964
Accepted
a,b=map(int,input().split()) x=max(a,b) y=min(a,b) z=max(x-1,y) print(x+z)
p03427
s212738430
Accepted
n = list(input()) n = list(map(int,n)) m = len(n) if m == 1: print(n[0]) elif len(set(n)) == 1 and n[0] == 9: print(9 * m) elif len(set(n)) == 2 and n[0] != 9 and n[1] == 9: print(n[0] + (m - 1) * 9) else: print(n[0] - 1 + (m - 1) * 9)
p02859
s813201246
Accepted
#145 a r=int(input()) ans=r**2 print(ans)
p02711
s995932469
Wrong Answer
N= input() if(N[0] == str(7)): print("Yes") elif(N[1] == str(7)): print("Yes") elif(N[2] == str(7)): print("Yes") else: print("N0")
p03323
s551371719
Accepted
a,b=map(int,input().split()) if a<=8 and b<=8: print("Yay!") else: print(":(")
p03485
s627387372
Accepted
# -*- coding: utf-8 -*- import math a, b = map(int, input().split()) print(math.ceil((a + b) / 2))
p02663
s603446722
Wrong Answer
import math #S=input() #N=int(input()) #A,B,C=input().split() H1,M1,H2,M2,K=map(int,input().split()) #A=list(map(int,input().split())) T=math.floor(((H2-H1)*60+(M2-M1))/K)*K if ((H2-H1)*60+(M2-M1))%K==0: T=T-K if T<=0: T==0 print(T)
p03796
s981857733
Accepted
N = int(input()) m = 1 for i in range(2,N+1): m = m*i%(10**9+7) print(m)
p03861
s040740230
Wrong Answer
import math a,b,x=map(int, input().split()) print(math.floor(b/x)-math.ceil(a/x)+1)
p02754
s608472035
Accepted
n, a, b = map(int, input().split()) ans = n // (a + b) * a add = n % (a + b) ans += min(add, a) print(ans)
p03386
s434862847
Wrong Answer
a,b,k=map(int,input().split()) c=[i for i in range(a, b+1)] al=a+k bs=b-k if al>b: al=b if bs<a: bs=a d=[i for i in range(al, bs+1)] e=list(set(c)^set(d)) for i in e: print(i)
p02842
s312039218
Wrong Answer
n = int(input()) for i in range(n): tmp=i*1.08//1 if tmp==n: print(i) exit(0) print(":(")
p03289
s077135930
Accepted
# coding: utf-8 import sys sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) S = sr() bl = True if S[0] != 'A': bl = False if S[2:-1].count('C') != 1: bl = False if S.count('C') != 1: bl = False for s in S[1:]: if s == 'C': continue ...
p02917
s186411695
Accepted
N = int(input()) Bs = list(map(int, input().split())) ans = [] def solve(acc, xs): head, *tail = xs if not acc: acc.append(head) if not tail: acc.append(head) return acc peek, *_ = tail acc.append(min(head, peek)) return solve(acc, tail) arr = solve([], Bs) print(sum...
p03293
s800749933
Accepted
from collections import deque S = input() T = input() s = deque(list(S)) t = deque(list(T)) n = len(s) for i in range(n): if t == s: print("Yes") break a = t.popleft() t.append(a) else: print("No")
p03673
s379575595
Wrong Answer
n = int(input()) seq = [x for x in input().split(' ')] b = [] if n % 2 == 0: for j in range(n-1, -1, -2): b.append(seq[j]) for i in range(0, n, 2): b.append(seq[i]) else: b.append(seq[n-1]) for j in range(0, n-1, 2): b.append(seq[j]) for i in range(1, n, 2): b...
p03380
s658644913
Accepted
N = int(input()) a = list(map(int,input().split())) a_max = max(a) half_a = a_max//2 comb = 1000000000 for i in range(N): if a[i]==a_max: continue if comb>abs(half_a-a[i]): idx =i comb = abs(half_a-a[i]) print(str(a_max) + ' ' + str(a[idx]))
p02842
s181564451
Accepted
N = int(input()) for x in range(50000): if x * 108 // 100 == N: print(x) break else: print(':(')
p02718
s577435887
Accepted
n, m = map(int, input().split()) a = list(map(int, input().split())) total = sum(a) p = [el for el in a if el >= (total/(4*m))] if len(p) >= m: print('Yes') else: print('No')
p02993
s330333893
Wrong Answer
N=input() count=0 for i in range(-1,-4,-1): if N[i]==N[i+1]: count+=1 else: count+=0 if count>=1: print("Bad") else: print("Good")
p03997
s127585372
Accepted
#45 a=int(input()) b=int(input()) h=int(input()) print((a+b)*h//2)
p03323
s601004942
Accepted
a,b=map(int,input().split()) print("Yay!" if a<9 and b<9 else ":(")
p03479
s089908774
Accepted
x,y=map(int,input().split()) n=y//x ct=0 while n>0: n//=2 ct+=1 print(ct)
p02555
s940609609
Accepted
S = int(input()) dp = [0] * (S + 1) dp[0] = 1 for i in range(3, S + 1): dp[i] = sum(dp[:i - 2]) print(dp[S] % (10 ** 9 + 7))
p03644
s059290753
Accepted
def resolve(): n = int(input()) ans = 1 num = 0 for i in range(1, n+1): tmp = 0 x = i while x >= 2 and x % 2 == 0: if x % 2 == 0: tmp += 1 x /= 2 if tmp >= num: ans = i num = tmp else: continue print(ans) return if __name__ == "__...
p02711
s465529571
Wrong Answer
S = input() if '7' in 'S': print('Yes') else: print('No')
p03861
s065444555
Accepted
a,b,x=map(int,input().split()) print(b//x-(a-1)//x)
p02687
s761337107
Accepted
s=input() print('ABC' if s=='ARC' else 'ARC')
p02924
s201394171
Accepted
n = int(input()) print(n * (n - 1) // 2)
p03219
s336692981
Wrong Answer
def main(): from sys import stdin r = stdin.readline()[:-1] #r = stdin.readlines() x, y = map(int, r.split()) print(x*y//2) if __name__ == '__main__': main()
p02953
s301129505
Wrong Answer
import sys N = int(input()) H = list(map(int,input().split())) cnt = 0 for i in range(N-1): if(H[i] > H[i+1]): tmp = H[i] - 1 if(tmp != H[i+1] or cnt > 0): print('No') sys.exit() cnt += 1 print('Yes')
p04045
s370417127
Accepted
N, K = map(int, input().split()) D = set(list(input())) for k in range(N, 20 * N): if len(set(list(str(k))) & D) == 0: print(k) exit()
p03061
s711000173
Accepted
n = int(input()) a = list(map(int, input().split())) def gcd(x,y): while y: x, y = y, x%y return x ll, lr = [0]*n, [0]*n ll[0], lr[n-1] = a[0], a[n-1] for i in range(1,n): ll[i] = gcd(ll[i-1], a[i]) lr[n-i-1] = gcd(lr[n-i], a[n-i-1]) print(max(ll[n-2], lr[1], *[gcd(l,r) for l,r in zip(ll[:n-2], lr[2:])])...
p03285
s830703088
Accepted
n = int(input()) cake = n // 4 dou = n // 7 res = "No" for i in range(cake+1): for j in range(dou+1): if 4*i + 7*j == n: res = "Yes" print(res)
p03481
s626400648
Wrong Answer
import math x,y = map(int,input().split()) num = y/x ans = int(math.log2(num) + 1) print(ans)
p02755
s167733571
Accepted
a,b=map(int,input().split()) ans=-1 c=int(b*10) d=int((b+1)*10) for i in range(c,d): if int(i*0.08)==a: ans=i break print(ans)
p03107
s430599879
Wrong Answer
import numpy as np S = str(input()) r = '00' b = '11' count=0 i=0 while i < (len(S)-1): if r == S[i:i+2]: S = S.replace(r,'',1) count+=1 i=0 if b == S[i:i+2]: S = S.replace(b,'',1) count+=1 i=0 else: i+=1 print(int(2*count))
p03327
s681130991
Wrong Answer
n = int(input()) if n <= 999: ans = 'ABC' + str(n).zfill(3) else: ans = 'ABD' + str(n-1000+1).zfill(3) print(ans)
p04030
s487644074
Wrong Answer
def solve(): s = list(input()) if s[0] == 'B': s[0] == '' for i in range(1, len(s)): if s[i] == 'B': s[i-1], s[i] ='', '' return ''.join(s) print(solve())
p03435
s466791727
Wrong Answer
# C - Takahashi's Information a =[list(map(int, input().split())) for i in range(3)] sum_a = sum(map(sum, a)) for i in range(3,100): if sum_a % i == 0 and sum_a // i >= 3: print("Yes") exit() else: pass print("No")
p02622
s809527566
Wrong Answer
s = input() t = input() count = 0 for i in range(len(s)): if s[i] == t[i]: count += 1 print(count)
p02695
s554909719
Accepted
N, M, Q = map(int, input().split()) a,b,c,d = [], [], [], [] for i in range(Q): tmp_a, tmp_b, tmp_c, tmp_d = map(int, input().split()) a.append(tmp_a) b.append(tmp_b) c.append(tmp_c) d.append(tmp_d) import itertools ans = {} for j in itertools.combinations_with_replacement(range(1,M+1), N): ...
p03803
s863126878
Wrong Answer
A, B = map(int, input().split()) if A != 1 or B != 1: if A == B: print('Draw') elif A > B: print('Alice') elif A < B: print('Bob') else: if A == 1 and B != 1: print('Alice') elif B == 1 and A != 1: print('Bob') else: print('Draw')
p03657
s228527928
Accepted
a,b = map(int,input().split()) P = 'Possible' if a % 3 == 0: print(P) elif b % 3 == 0: print(P) elif (a + b) % 3 == 0: print(P) else: print('Impossible')
p03617
s304104266
Wrong Answer
q, h, s, d = map(int, input().split()) n = int(input()) a = [8*q, 4*h, 2*s, d] if n == 1: a.remove(d) price = min(a) / 2 elif n % 2 == 0: price = min(a) * n / 2 else: price = min(a) * (n-1) / 2 a.remove(d) price = price + min(a) / 2 print(int(price))
p02866
s376119970
Accepted
N = int( input() ) D = list ( int(x) for x in input().split() ) if D[0] != 0: ans = 0 else: Ds = [ 0 for i in range( max(D) + 1 ) ] for i in range( N ): Ds[ D[i] ] += 1 ans = 1 if Ds[ 0 ] != 1: ans = 0 else: for i in range( 1 , max(D) + 1 ): ans *= Ds[ i-1...
p03673
s695054960
Wrong Answer
n = int(input()) a = input().split() if n > 1: s = a[0] t = a[0] for i in range(1, n): if i % 2 == 0: s = s + ' ' + a[i] t = a[i]+ ' ' + t else: s = a[i] + ' ' + s t = t + ' ' + a[i] if n == 1: s = a[0] if n % 2 == 1: print(s) else: print(t)
p03698
s410366392
Wrong Answer
import sys S = [chr for chr in input()] for moji in S: S.remove(moji) if moji in S: print('no') sys.exit(0) print('yes')
p04005
s802812155
Wrong Answer
import math A = list(map(int, input().split())) A.sort(reverse=True) if A[0] % 2 == 0 or A[1] % 2 == 0 or A[2] % 2 == 0: ans = 0 else: a = A[0] // 2 b = A[0] - A[0] // 2 x = a * A[1] * A[2] ans = math.floor(x * (b/a - 1)) print(ans)
p03042
s568032874
Accepted
S = input() first = int(S[:2]) second = int(S[2:]) if 1<=first<=12 and 1<=second<=12: print('AMBIGUOUS') elif 1<=first<=12: print('MMYY') elif 1<=second<=12: print('YYMM') else: print('NA')
p03565
s429907519
Wrong Answer
import re S = input() T = input() if not re.match(r"^.*("+"\?"*(len(T)-1)+")",S): print("UNRESTORABLE") else: startN=re.match(r"^.*("+"\?"*(len(T)-1)+")",S).span(1)[0] S=S[:startN]+T[1:]+S[startN+len(T)-1:] S=S.replace("?","a") print(S)
p03475
s907771159
Accepted
N = int(input()) CSF = [] for _ in range(N-1): C, S, F = map(int, input().split()) CSF.append((C, S, F)) def cnt(x): ret = 0 for i in range(x, N-1): C, S, F = CSF[i] if ret < S: ret = S ret += C else: ret = -(-ret//F)*F ret += C return ret for x in range(N): print(cnt(...
p03293
s864433553
Accepted
S = input() T = input() N = len(S) check = False for i in range(N): S = S[-1] + S[:-1] if S == T: check = True print("Yes" if check else "No")
p02607
s620336635
Accepted
n = int(input()) arr = list(map(int, input().split())) acc = 0 for i in range(n): if i % 2 == 0 and arr[i] % 2 == 1: acc += 1 print(acc)
p02744
s732305609
Accepted
n = int(input()) a = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'] def dfs(s, count): if len(s) == n: print(s) return for z in range(count + 1): dfs(s + a[z], count + 1 if z == count else count) dfs("", 0)
p03109
s606208940
Accepted
date = input() list_date = date.split('/') if int(list_date[0]) <= 2018: print('Heisei') elif int(list_date[0]) <= 2019 and int(list_date[1]) <= 4: print('Heisei') else: print('TBD')
p03761
s748833317
Wrong Answer
from collections import Counter, defaultdict n = int(input()) lc = [chr(i) for i in range(97, 97+26)] ans_dict = Counter(input()) for _ in range(n-1): S = input() tmp = {k:0 for k in lc} for s in S: tmp[s] += 1 for k in tmp.keys(): try: ans_dict[k] = min(ans_dict[k], tmp[k]...
p02823
s512985156
Wrong Answer
n,a,b=map(int,input().split()) if (b-a)%2 == 0: print(int((b-a)/2)) else: print(min(b-1,n-a))
p03862
s996703239
Accepted
import sys sys.setrecursionlimit(10 ** 7) input = sys.stdin.readline n, x = map(int, input().split()) a = list( map(int, input().split())) if x ==0: print(sum(a)) exit() ans = 0 if a[0]>x: ans += a[0]-x a[0]=x for i in range(1,n): two = a[i-1]+a[i] if two > x: tmp = two-x an...
p02675
s147945612
Wrong Answer
N = int(input()) s = str (N) print(s[-1]) if s[-1] == "3": print ("bon") elif s[-1] == "0" or "1" or "6" or "8": print ("pon") else: print ("hon")
p02775
s591878995
Wrong Answer
n=input() change=0 for i in range(1,len(n)+1): sn=list(n) x=sn[len(sn)-i] if int(x)>5: change+=(10-int(x)) n=str(int(n)+(10-int(x))*10**(i-1)) pay=0 snf=list(n) for j in range(len(snf)): pay+=int(snf[j]) print(pay+change)
p02597
s492483499
Accepted
N = input() li = input() #print(li) red = li.count("R") white = li.count("W") #print(red,white) target = li[:red] ans = red - target.count("R") print(ans)
p03681
s508440072
Accepted
import math n,m = [int(x) for x in input().split()] mod = 10**9 + 7 if n == m: ans = (math.factorial(n) * math.factorial(m) * 2) % mod elif abs(n-m) > 1: ans = 0 else: ans = (math.factorial(n) * math.factorial(m)) % mod print(ans)
p03379
s760744493
Accepted
n = int(input()) x = list(map(int,input().split())) x_sort = sorted(x) lenth = len(x) low = x_sort[int(lenth/2)-1] high = x_sort[int(lenth/2)] for y in x: if y <= low: print(high) else: print(low)
p03693
s410792036
Accepted
r, g, b = map(int, input().split()) a = r * 100 + g * 10 + b * 1 if a % 4 == 0: print("YES") else: print("NO")
p03779
s465836129
Accepted
x = int(input()) ans = 0 time = 0 while ans < x: time += 1 ans += time print(time)
p02731
s563395295
Accepted
S = int(input()) print((S/3)**3)
p03799
s145877769
Wrong Answer
import sys from itertools import permutations def solve(): input = sys.stdin.readline N, M = map(int, input().split()) if N >= M // 2: print(N) else: leftC = M - N * 2 print(N + leftC // 4) return 0 if __name__ == "__main__": solve()
p02753
s214690005
Accepted
import sys import math from collections import defaultdict sys.setrecursionlimit(10**7) def input(): return sys.stdin.readline()[:-1] mod = 10**9 + 7 def I(): return int(input()) def LI(): return list(map(int, input().split())) def LIR(row,col): if row <= 0: return [[] for _ in range(col)] elif c...
p03860
s281606533
Accepted
a,s,c = input().split() print('A'+s[0]+'C')
p02791
s376096800
Wrong Answer
N = input() P = input().split(' ') count = 0 PM = min(P) for i, Pi in enumerate(P): if i == 0: count = count +1 Pmin = Pi elif Pmin>=P[i]: count = count +1 Pmin = Pi print(count)
p03827
s108525269
Accepted
n = int(input()) s = input() x, ans = 0, 0 for o in s: if o == 'I': x += 1 else: x -= 1 ans = max(ans, x) print(ans)
p03852
s053343404
Wrong Answer
ps='aeiuo' c=input() for i in range(5): if c==ps[i]: print('vowel') else: print('consonant')
p03679
s500920175
Accepted
X, A, B = map(int, input().split()) if B-A <= 0: print("delicious") elif X >= B-A: print("safe") else: print("dangerous")
p02601
s435024065
Accepted
A,B,C = map(int, input().split()) K = int(input()) cnt = 0 for i in range(100): if A >= B: B *= 2 cnt += 1 continue if B >= C: C *= 2 cnt += 1 continue if cnt <= K: print("Yes") else: print("No")
p02743
s894856563
Wrong Answer
a,b,c = list(map(int,input().split())) import math if math.sqrt(a)+math.sqrt(b) < math.sqrt(c): print("Yes") else: print("No")
p02694
s783446211
Wrong Answer
import math import sys x = int(input()) mon = 100 ri = 1 year = 0 if x <= mon: print(1) sys.exit() while x > mon: #print(mon) ri = mon*0.01 mon = math.floor(mon+ri) year += 1 #print(year,mon) print(year)
p03711
s886059599
Wrong Answer
x, y = map(int, input().split()) a = [4, 6, 9, 11] b = 0 c = 0 if x == 2 or y == 2: print("No") else: if x in a: b = 1 elif y in a: c = 1 if (b + c) % 2 == 0: print("Yes") else: print("No")
p02970
s384933919
Accepted
n,d = map(int,input().split(" ")) d = d*2 + 1 answer = 0 while n >0: n-=d answer += 1 print(answer)
p03545
s988723089
Accepted
A, B, C, D = map(str, input()) for op1 in '+-': for op2 in '+-': for op3 in '+-': if eval(A+op1+B+op2+C+op3+D) == 7: print(A+op1+B+op2+C+op3+D+'=7') exit()
p02771
s282392450
Wrong Answer
A, B, C = map(int, input().split()) if A == B == C: print('No') else: print('Yes')
p03437
s513979920
Accepted
x,y=map(int,input().split()) if x%y==0: print(-1) else: print(x*y-x)
p03206
s966845195
Wrong Answer
D = int(input()) if D == 25: ans = 'Christmas' elif D == 24: ans = 'Christmas Eve' elif D == 23: ans = 'Christmas Eve Eve' elif D == 22: ans = 'Christmas Eve Eve'
p03592
s979478998
Wrong Answer
def main2(): N, M, K = map(int, input().split()) for i in range(1, N + 1): for j in range(1, M + 1): b = i * (M - j) + j * (N - i) if b == K: print("Yes") exit() print("No") if __name__ == "__main__": main2()
p02683
s151674991
Accepted
n,m,X=map(int,input().split()) c=[list(map(int,input().split())) for i in range(n)] ans=float('inf') from itertools import combinations as com for l in range(1,n+1): for i in com(list(range(n)),r=l): cnt=[0]*m p=0 for j in i: p+=c[j][0] for x in range(m): ...
p03449
s361914343
Accepted
from numpy import cumsum n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) sa = cumsum(a) sb = cumsum(b) ans = 0 for i in range(n): ans = max(ans, sa[i] + sb[n-1] - sb[i] + b[i]) print(ans)
p03331
s039091261
Accepted
# AGC 025 A - Digits Sum n = int(input()) def DegitSum(x): ans = 0 while x > 0: ans += x%10 x = x // 10 return ans res = 10**8 for a in range(1, n//2+1): b = n - a if DegitSum(a) + DegitSum(b) < res: res = DegitSum(a) + DegitSum(b) print(res)
p03419
s830057098
Accepted
N,M = map(int,input().split()) if N == 1 and M == 1: print(1) exit() elif N == 1: print(M-2) exit() elif M == 1: print(N-2) exit() print((N-2)*(M-2))
p02742
s152638331
Accepted
h, w = map(int, input().split()) if h == 1 or w == 1: print(1) elif h * w % 2 == 0: print(h * w // 2) else: print(h * w // 2 + 1)
p02628
s142502249
Wrong Answer
N,K = map(int, input().split()) p = list(map(int, input().split())) p.sort() if len(p) >= 3 : print(str(p[0] + p[1] + p[2])) elif len(p) == 2 : print(str(p[0]+p[1])) elif len(p) == 1 : print(str(p[0]))
p02843
s858301535
Accepted
x = int(input()) possible = [0] * (x+1) # array of x+1 zeroes possible[0] = 1 for k in range(x+1): for i in range(100, 106): if k-i >= 0 and possible[k-i]: possible[k] = 1 print(possible[x])
p02665
s311818381
Accepted
N = int(input()) A = tuple(map(int, input().split())) S = [0] for a in reversed(A): S.append(S[-1] + a) S.reverse() lst = [0] * (N + 2) lst[0] = 1 for i, a in enumerate(A): if lst[i] < a: print(-1) break lst[i + 1] = min((lst[i] - a) * 2, S[i + 1]) else: print(sum(lst))
p02935
s172254135
Accepted
N = int(input()) vals = list(map(int,input().split())) vals = sorted(vals) val = vals[0] for i in range(1,N): val = (val + vals[i]) / 2.0 print(val)
p03611
s816358610
Wrong Answer
import collections N=int(input()) A=sorted(list(map(int,input().split()))) p=collections.Counter(A) B=list(set(A)) ans=0 l=len(B) if l==1: ans = p[B[0]] elif l==2: ans = p[B[0]]+p[B[1]] else: for i in range(l-2): sum_a = p[B[i]]+p[B[i+1]]+p[B[i+2]] if sum_a > ans: ans = sum_a print(ans)
p03852
s335644525
Accepted
c=input() en={'a','e','i','o','u'} print('vowel' if c in en else 'consonant')
p04045
s849023036
Accepted
import collections import numpy as np import sys sys.setrecursionlimit(10000000) import copy #N=int(input()) N,K=map(int,input().split()) D=set(input()) while len(set(str(N))&D)>0: N+=1 print(N)
p02623
s449897171
Accepted
N, M, K = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) a, b = [0], [0] for i in range(N): a.append(a[i] + A[i]) for i in range(M): b.append(b[i] + B[i]) ans, j = 0, M for i in range(N + 1): if a[i] > K: break while b[j] > K - a[i]: j -= 1 ans = ma...
p02627
s192029449
Accepted
a = input() print('A' if ord(a) <= 90 else 'a')