problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02676
s421775786
Wrong Answer
keta = int(input()) word = str(input()) if len(word) <= keta: print(word) else: print(word[:keta-1] + "...")
p02576
s328432890
Wrong Answer
N,X,T = map(int, input().split()) # 3個の数字の入力を受け取る m=(N//X) m1=m*T if N%X==0: print(m) else: print(m+1)
p02554
s549039871
Accepted
N = int(input()) dp = [0 for j in range(4)] dp[0] = 1 M = 1_000_000_007; for i in range(N): x = dp[0] y = dp[1] z = dp[2] dp[0] = (x * 8) % M dp[1] = (y * 9 + x) % M dp[2] = (z * 9 + x) % M dp[3] = (dp[3] * 10 + y + z) % M print(dp[3])
p03131
s669542726
Accepted
k, a, b = map(int, input().split()) kk = k ans = 0 if a >= b: ans += k+1 else: if k <= a: ans += k+1 else: ans += a k -= a - 1 if k % 2 == 1: ans += 1 k -= 1 ans += (k // 2)*(b - a) ans = max(ans, kk+1) print(int(ans))
p03377
s540867857
Accepted
a,b,x = map(int,input().split()) if a<=x and x<=a+b: print("YES") else: print("NO")
p03951
s579773543
Accepted
n = int(input()) s = input() t = input() tyouhuku = 0 for i in range(n): if s[i:]==t[:n-i]: tyouhuku = n-i break print(max(n,2*n-tyouhuku))
p02553
s481275677
Wrong Answer
a, b, c, d = [int(x) for x in input().split()] m1 = max(a,b) m2 = max(c,d) if(m1<=0 and m2<=0): print(min(a,b)*min(c,d)) elif(m1>0 and m2<=0): print(min(a,b)*m2) elif(m1<=0 and m2>0): print(m1*min(c,d)) else: print(m1*m2)
p03241
s441368620
Accepted
def resolve(): N, M = list(map(int, input().split())) factors = [] i = 1 while i <= M**(1/2): if M%i==0: factors.append(i) factors.append(M//i) i += 1 factors = sorted(factors, reverse=True) #print(factors) for fac in factors: if N*fac <= M and...
p03210
s803524249
Wrong Answer
x = int(input()) print("Yes" if x in [3, 5, 7] else "No")
p02689
s407186701
Accepted
N, M = map(int, input().split()) p_list = [1 for _ in range(N)] e_list = list(map(int, input().split())) for _ in range(M): a, b = map(int, input().split()) if e_list[a - 1] <= e_list[b - 1]: p_list[a - 1] = 0 if e_list[b - 1] <= e_list[a - 1]: p_list[b - 1] = 0 print(sum(p_list))
p03076
s556515204
Wrong Answer
ae = [int(input()) for i in range(5)] mm = ae[0]%10 for i in range(5): mm = min(mm, ae[i]%10) ae[i] = ((ae[i]//10)+1)*10 if mm != 0: print(sum(ae)-(10-mm)) else: print(sum(ae))
p02554
s639442293
Wrong Answer
N = int(input()) ans = (N*(N-1))*(10**(N-2)) ans = ans % (10**9+7) print(int(ans))
p02765
s484364846
Wrong Answer
N,K=map(int,input().split()) if N >=10: print(K) else: print(K-100*(10-K))
p03095
s308603874
Accepted
from string import ascii_lowercase from collections import defaultdict N = int(input()) S = input().strip() MOD = 10 ** 9 + 7 c = defaultdict(int) for i in range(N): c[S[i]] += 1 ans = 1 for x in ascii_lowercase: ans *= c[x] + 1 ans %= MOD ans -= 1 ans %= MOD print(ans)
p03943
s141785130
Wrong Answer
a,b,c = map(int,input().split()) A = a+b+c if A % 2 ==0: print('Yes') else: print('No')
p03030
s111382002
Wrong Answer
N = int(input()) r = [input() + ' ' + str(i + 1) for i in range(N)] R = [] for i in r: R.append(i.split()[0] + ' ' + str(100 -int(i.split()[1])) + ' ' + i.split()[2]) R = sorted(R) for i in R: print(i.split()[2])
p02732
s699696138
Accepted
N=int(input()) L=list(map(int,input().split())) S=sorted(L) D={} c=1 t=0 for i in range(N-1): if S[i]==S[i+1]: c+=1 else: D[S[i]]=c c=1 D[S[N-1]]=c for i in D.values(): t+=i*(i-1)//2 for i in range(N): print(t-(D[L[i]]-1))
p02988
s231141491
Accepted
n = int(input()) p = list(map(int, input().split())) ans = 0 for i in range(1,n-1): plist = [p[i-1],p[i],p[i+1]] plist.sort() if plist[1]==p[i]: ans = ans+1 print(ans)
p02622
s871059885
Wrong Answer
a = list(input()) b = list(input()) count = 0 for i,con in enumerate(b): if i == a[i]: break else: count+=1 print(count)
p02989
s320847502
Accepted
N = int(input()) d = list(map(int, input().split())) d = sorted(d) x = int(N / 2) print(int(d[x] - d[x-1]))
p02584
s998633717
Accepted
x,k,d = map(int,input().split()) x = abs(x) if x <= k * d: k -= x//d x %= d if k % 2 == 1: print(d-x) else: print(x) else: print(x-k*d)
p02993
s392592221
Accepted
s=input() ans="Good" for i in range(3): if s[i]==s[i+1]: ans="Bad" print(ans)
p03723
s896711329
Accepted
a, b, c = map(int,input().split()) count = 0 if a==b==c and a%2==b%2==c%2==0: print(-1) else: while a%2 == 0 and b%2 == 0 and c%2 == 0: a, b, c = b//2+c//2, c//2+a//2, a//2+b//2 count += 1 print(count)
p02594
s762909156
Accepted
x = int(input()) if x >= 30: print('Yes') else : print('No')
p02973
s437427363
Accepted
from bisect import bisect_left from collections import deque N = int(input()) A = [int(input()) for _ in range(N)] G = deque([]) for i in range(N): a = A[i] ind = bisect_left(G,a) if ind==0: G.appendleft(a) else: G[ind-1] = a print(len(G))
p02727
s884849893
Accepted
f=lambda:map(int,input().split());x,y,*_=f();g=sorted;print(sum(g(g(f())[-x:]+g(f())[-y:]+list(f()))[-x-y:]))
p04031
s839264636
Accepted
N=int(input()) a=list(map(int,input().split())) ans=10**9 for i in range(-100,101): bns=0 for j in range(N): bns+=(abs(a[j]-i)**2) ans=min(ans,bns) print(ans)
p02701
s336680380
Accepted
n=int(input()) g=[] for i in range(n): gi=input() g.append(gi) g.sort() count=1 for i in range(n-1): if g[i]!=g[i+1]: count+=1 print(count)
p03472
s134146974
Accepted
N, H = map(int, input().split()) X = [list(map(int, input().split())) for _ in range(N)] a, b = zip(*((a, b) for a, b in X)) am = max(a) b = sorted(b, reverse=True) ans = 0 h = H for v in b: if v > am: h -= v ans += 1 if h <= 0: break if h > 0: ans += -(-h // am) print(a...
p02784
s599207293
Wrong Answer
h,n=map(int,input().split()) a=list(map(int,input().split())) a = sorted(a) if n == 1: if a[0] >= h: print('Yes') else: print('No') elif h == 210 and n ==5: print('Yes') elif a[-1]+a[-2] >= h: print('Yes') else:print('No')
p02759
s342218725
Wrong Answer
a=int(input()) if a%2==0: print(a/2) else: print((a+1)/2)
p03103
s033185359
Accepted
n, m = map(int,input().split()) ab = [list(map(int,input().split())) for i in range(n)] ab_sorted = sorted(ab, key=lambda x:x[0]) num = 0 amount_of_money = 0 for i in range(n): buy = min(ab_sorted[i][1], m-num) num += buy amount_of_money += ab_sorted[i][0] * buy if num >= m: print(...
p03557
s542851354
Wrong Answer
import bisect n = int(input()) a = [int(i) for i in input().split()] b = [int(i) for i in input().split()] c = [int(i) for i in input().split()] total = 0 for i in b: a_number = bisect.bisect_left(a, i) c_number = len(c) - bisect.bisect_right(c, i) total += a_number * c_number print(total) a_nu...
p03331
s899379966
Accepted
n = int(input()) a = 0 b = n ans = 1e9 while (1 < b): a += 1 b -= 1 sa = str(a) sb = str(b) sum = 0 for i in range(len(sa)): sum += int(sa[i]) for i in range(len(sb)): sum += int(sb[i]) ans = min(ans, sum) print(ans)
p02996
s640274764
Accepted
from operator import itemgetter n=int(input()) ab=[list(map(int,input().split())) for i in range(n)] ab=sorted(ab, key=itemgetter(1,0)) #print(ab) time=0 for todotime,deadline in ab: time += todotime if not (time <= deadline) : print('No') exit() print('Yes')
p02911
s859901306
Accepted
def resolve(): n, k, q = map(int, input().split()) score = [0] * n for _ in range(q): a = int(input()) score[a-1] += 1 for i in range(n): s = k + score[i] - q if s > 0: print("Yes") else: print("No") resolve()
p02766
s738918123
Accepted
N,K= map(int, input().split()) A = 0 cnt = -1 if N <= K-1: print(1) else: while N > A: cnt += 1 A = K**(cnt+1)-1 print(cnt+1)
p02900
s585410382
Accepted
import math A, B = map(int, input().split()) def prime_factorize(n): a = [1] while n % 2 == 0: a.append(2) n //= 2 f = 3 while f * f <= n: if n % f == 0: a.append(f) n //= f else: f += 2 if n != 1: a.append(n) a.sort()...
p03485
s916409989
Accepted
import math a,b = map(int,input().split()) print(math.ceil((a+b)/2))
p03796
s844010996
Wrong Answer
N = int(input()) P = 1 for i in range(1,N): P = P*i print(P % (10**9+7))
p03387
s798966324
Accepted
#!/usr/bin/env python3 abc = list(map(int, input().split())) abc.sort() diff1 = abc[2]-abc[0] diff2 = abc[2]-abc[1] if (diff1+diff2) % 2 == 0: print((diff1+diff2)//2) else: print((diff1+diff2+3)//2)
p02847
s077814040
Accepted
S = input() day = ['SUN','MON','TUE','WED','THU','FRI','SAT'] for i in range(len(day)): if S == day[i]: print(7-i) break
p02911
s498773971
Accepted
N, K, Q = map(int,input().split()) As = [] for i in range(Q): As.append(int(input())) points = [K - Q] * N for a in As: points[a - 1] += 1 for p in points: if p > 0: print("Yes") else: print("No")
p02995
s967914479
Accepted
import math A,B,C,D = map(int,input().split()) def lcm(x, y): return (x * y) // math.gcd(x, y) lcm = lcm(C,D) u_b_ans = (B//C + B//D) - B//lcm u_a_ans = ((A-1)//C + (A-1)//D) - (A-1)//lcm print(B-A+1 - u_b_ans + u_a_ans)
p03109
s557932986
Accepted
a = input() if int(a[:4])<=2019 and int(a[5:7])<=4: print("Heisei") else: print("TBD")
p03338
s625819831
Wrong Answer
N=int(input()) S=input() ans=1 for i in range(N-1): ans=max(ans,len(list(set(list(S[:i+1])) & set(list(S[i+1:]))))) print(ans)
p02933
s454829089
Accepted
print('red' if int(input())<3200 else input())
p03438
s370152576
Wrong Answer
n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) suma = sum(a) sumb = sum(b) if suma > sumb: print("No") exit() sum_minus=0 sum_plus=0 for i in range(n): sub = a[i] - b[i] if sub < 0: sum_minus+=sub else: sum_plus+=sub sm = sum_minus+sum_pl...
p03281
s866268920
Wrong Answer
ret = 0 for x in range(11, int(input()) + 1, 2): n = 2 for y in range(2, x // 2 + 1): if x % y == 0: n += 1 if n == 8: ret += 1 print(x) print(ret)
p03210
s396830107
Wrong Answer
x = int(input()) y = [3,5,7] print("Yes" if x in y else "No")
p03767
s420133003
Wrong Answer
N = int(input()) li = list(map(int,input().split())) ans = 0 li.sort() for i in range(3*N): if N <= i and i < 2*N: ans += li[i] print(ans)
p02696
s002499023
Accepted
A,B,N = map(int, input().split()) if B == 1 or A == 1: floor = 0 else: if N < B: floor = int(A*N/B) - A*int(N/B) elif N == B: floor = int(A*(N-1)/B) - A*int((N-1)/B) else: floor = max([(int(A*(x-1)/B) - A*int((x-1)/B)) for x in range(B,N,B)]) print(floor)
p02989
s986045675
Accepted
N = int(input()) D = sorted(list(map(int, input().split()))) D1 = D[int(N / 2) -1] D2 = D[int(N / 2)] count = 0 for i in range(D1, D2, 1): count+=1 print(count)
p02900
s639217547
Accepted
import math A, B = map(int, input().split()) def prime_factorize(n): a = [1] while n % 2 == 0: a.append(2) n //= 2 f = 3 while f * f <= n: if n % f == 0: a.append(f) n //= f else: f += 2 if n != 1: a.append(n) a.sort...
p02681
s819360607
Accepted
s = str(input()) t = str(input()) slen = len(s) if s[:] == t[:slen]: print('Yes') else: print('No')
p02754
s333384787
Accepted
N, A, B = map(int, input().split()) print((N // (A+B)) * A + min(A, N % (A+B)))
p02578
s578085347
Accepted
num = int(input()) height = input().split() sum = 0 max_height_now = 0 for index in range(num): height_now = int(height[index]) if height_now >= max_height_now: max_height_now = height_now else: sum += max_height_now - height_now print(sum)
p04020
s161085403
Accepted
N, *A = map(int, open(0).read().split()) ans = 0 cnt = 0 for i in range(N): if A[i] > 0: cnt += A[i] else: ans += cnt // 2 cnt = 0 else: ans += cnt // 2 print(ans)
p03286
s067732789
Accepted
n=int(input()) if n==0: print(0) exit() if n==1: print(1) exit() ans=[] while n!=1: r=n%2 ans.append(str(r)) n=(n-r)//(-2) ans.append(str(1)) ans.reverse() print(''.join(ans))
p03250
s554323493
Wrong Answer
a, b, c = map(int, input().split()) if a > b and a > c: print(a*10+b+c) elif b > a and b > c: print(b*10+a+c) else: print(c*10+a+b)
p04029
s489907416
Accepted
n = int(input()) ans = sum(list(range(1,n+1))) print(ans)
p03456
s099449129
Accepted
import math n = int(input().replace(' ','')) M = math.ceil(math.sqrt(n)) for i in range(1,M+1): if i**2 == n: print('Yes') exit() print('No')
p03150
s075903431
Accepted
s = input() for i in range(n := len(s)): for j in range(n-i): if s[:i]+s[i+j:] == "keyence": print('YES') exit() else: print('NO')
p03469
s298728941
Accepted
S = input() print(S[:3]+"8"+S[4:])
p02747
s841860898
Accepted
s = input() h = s.replace('hi', '') if h == '': print('Yes') else: print('No')
p03861
s317551927
Wrong Answer
a, b, x = map(int, input().split()) c1 = a // x c2 = b // x if a == b: if a % x == 0: print(1) else: print(0) exit() print(c2-c1+1)
p03672
s096447781
Wrong Answer
s = list(input()) if len(s) %2 == 1: s.pop(-1) else: s.pop(-1) s.pop(-1) while len(s) != 0: l = len(s) if s[:l//2] == s[l//2:]: print(l) s.pop(-1) s.pop(-1)
p04034
s035260250
Wrong Answer
N,M = [int(hoge) for hoge in input().split()] Ball = [False]*N BallNum = [1] * N Ball[0] = True for i in range(M): x,y = [int(hoge) - 1 for hoge in input().split()] BallNum[x] -= 1 BallNum[y] += 1 Ball[y] = Ball[x] if BallNum[x] == 0: Ball[x] = False print(sum(Ball))
p02608
s007753218
Accepted
N = int(input()) def cal(a,b,c): return(a**2+b**2+c**2 + a*b+b*c+c*a) memo = [0]*(10**4) for i in range(1,100): for j in range(1,100): for k in range(1,100): temp = cal(i,j,k) if temp <= 10**4: memo[temp-1] += 1 for i in memo[:N]: print(i)
p02842
s369036619
Wrong Answer
import math N = int(input()) X = 0 a = 0 for i in range(N): X = math.floor(1.08*i) if(X==N): print(i) a+=1 break if(a ==0): print(":(")
p03127
s140682648
Wrong Answer
n = int(input()) A = list(map(int,input().split())) ans = A[0] for i in A[1:]: if i % ans == 0 or ans % i == 0: ans = min(ans,i) else: print(1) break else: print(ans)
p03693
s510134975
Wrong Answer
r,g,b = map(int,input().split()) number = g*10 + b print("YES" if number%4==0 else "N0" )
p02554
s985424135
Wrong Answer
N = int(input()) MOD = 10**9 + 7 def f(x, y): return pow(x, y, MOD) print(f(10, N) - f(9, N) - f(9, N) + f(8, N))
p04012
s265448763
Accepted
w = list(input()) s = set(w) for i in s: if w.count(i)%2 != 0: print("No") break else: print("Yes")
p03035
s665428998
Accepted
A,B=map(int,input().split()) if A>=13: print(B) elif 12>=A>=6: print(B//2) else: print(0)
p02726
s286688104
Accepted
N, X, Y = map(int, input().split()) ans = [0]*N for i in range(1, X): for j in range(i+1, N+1): ans[min(j-i, X-i+1+abs(Y-j))] += 1 for i in range(X, Y): for j in range(i+1, N+1): ans[min(j-i,i-X+1+abs(Y-j))] += 1 for i in range(Y, N): for j in range(i+1, N+1): ans[j-i] += 1 for ...
p02713
s499136846
Accepted
from math import gcd def main(): k = int(input()) ans = 0 for i in range(1, k+1): for j in range(1, k+1): for k in range(1, k+1): ans += gcd(gcd(i, j), k) print(ans) if __name__ == '__main__': main()
p02792
s647695620
Accepted
N = int(input()) def head_tail(num): if len(str(num)) == 1: return (num, num) top = int(str(num)[0]) tail = int(str(num)[-1]) return (top, tail) pairs = {} for i in range(1, N+1): p = head_tail(i) if p not in pairs: pairs[p] = 1 else: pairs[p] += 1 ans = 0 for i ...
p03408
s898514288
Wrong Answer
N=int(input()) plus=[input() for i in range(N)] M=int(input()) minus=[input() for i in range(M)] S=list(set(plus+minus)) ans={} for i in S: point=0 point=plus.count(i)-minus.count(i) ans[point]=i print(max(ans.keys()))
p02783
s539061179
Accepted
H, A = map(int, input().split()) if H%A==0: ans = int(H/A) else: ans = 1 + int(H/A) print(ans)
p03035
s334453306
Accepted
A, B = map(int,input().split()) if A >= 13: print(B) elif 6 <= A <= 12: print(int(B*0.5)) else: print(0)
p02732
s330016417
Accepted
from collections import defaultdict import math def combinations_count(n, r): if n == 1 or n == 0: return 0 else: return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)) N = int(input()) A= [int(i.strip()) for i in input().split(' ')] D =defaultdict(int) for i in A: D[i]...
p02555
s262027025
Wrong Answer
s = int(input()) if s < 3: print("0") elif s == 3: print("1") else: a = s -3 + 1 aws = a - 3 + 1 print(aws % (7 + (10 * 9)))
p03103
s320781503
Accepted
n,m=map(int,input().split()) t=[0]*n ans=0 temp=0 for i in range(n): at,bt=map(int,input().split()) t[i]=[at,bt] t.sort() i=0 while True: if temp+t[i][1]>=m: ans=ans+t[i][0]*(m-temp) break else: ans=ans+t[i][0]*t[i][1] temp=temp+t[i][1] i=i+1 print(ans)
p03261
s139425009
Wrong Answer
n=int(input()) temp=str(input()) templ=list(temp) tempb=templ[len(templ)-1] w=[0]*n w[0]=temp for i in range(0,n-1): temp=str(input()) templ=list(temp) if temp in w or tempb!=templ[0]: print("No") break tempb=templ[len(templ)-1] else: print("Yes")
p03386
s633710510
Wrong Answer
def resolve(): a, b, k = map(int, input().split()) if a+k-1 <= b-k+1: for i in range(a, b+1): print(i) else: for i in range(a, a+k): print(i) for i in range(b-k+1, b+1): print(i) resolve()
p03773
s170170386
Wrong Answer
a, b = map(int,input().split()) if (a + b) <= 24: print(a + b) else: print((a + b) - 24)
p03862
s588983886
Accepted
N,x=map(int,input().split()) a=list(map(int,input().split())) ans=0 if a[0]>x: d=a[0]-x ans+=d a[0]=x for i in range(N-1): tmp=a[i]+a[i+1] ans+=max(tmp-x,0) a[i+1]=a[i+1]-max(tmp-x,0) print(ans)
p03679
s818514081
Wrong Answer
X, A, B = map(int, input().split()) if A >= B: print('delicious') elif A + X < B: print('dengerous') else: print('safe')
p03779
s961031089
Accepted
x = int(input()) # 1, 2, 3, ... , nの総和がX以上ならば、 # 適当に保持をいれることでたどり着ける # 総和の公式は(1 + n)*n//2 ans = 0 while True: if ((1+ans)*ans)//2 >= x: print(ans) exit(0) ans+=1
p03261
s854800494
Accepted
n = int(input()) used = list(input() for x in range(n)) ans = "Yes" for i in range(n-1): if used.count(used[i]) == 2: ans = "No" break if used[i][-1] != used[i+1][0]: ans = "No" print(ans)
p04044
s267653115
Accepted
n,l = map(int,input().split()) a = [] for i in range(n): a.append(input()) a.sort() print("".join(a))
p04011
s410757986
Wrong Answer
n=int(input()) a=int(input()) b=int(input()) c=int(input()) print(n*b+max(0,n-a)*c)
p03419
s664489236
Accepted
n, m = map(int, input().split()) if n == 1 and m == 1: print(1) elif n == 1: print(m - 2) elif m == 1: print(n - 2) else: print((n - 2) * (m - 2))
p02796
s712300078
Accepted
def m(): N = int(input()) XL = [list(map(int, input().split())) for _ in range(N)] ST = [[xl[0] - xl[1], xl[0] + xl[1]] for xl in XL] ST.sort(key=lambda x: x[1]) ans = 1 right = ST[0][1] for i in range(1, N): if right <= ST[i][0]: right = ST[i][1] ans += 1 ...
p03695
s887062332
Accepted
n = int(input()) A = list(map(int, input().split())) A = list(map(lambda x: x//400, A)) #print(A) import collections c = collections.Counter(A) #print(c) f1 = f2 = 0 for k in c.keys(): if k >= 8: f1 += 1 f2 += c[k] if f1 == 0: min_ = max_ = len(c.keys()) else: min_ = len(c.keys())...
p03105
s905918186
Accepted
A,B,C= map(int,input().split()) #print(A,B,C) x = B // A if x <= C : print( x ) else: print( C )
p02743
s797064055
Accepted
import sys import math input = sys.stdin.readline def main(): a, b, c = map(int, input().split()) tmp = c - a - b if tmp <= 0: print("No") else: if 4 * a * b < tmp * tmp: print("Yes") else: print("No") if __name__ == "__main__": main()
p02732
s276353486
Accepted
from collections import Counter N = int(input()) A = list(map(int,input().split())) c= Counter(A) sum = 0 for i in c.values(): sum += i * (i - 1) // 2 for i in A: print(sum - c[i] + 1)
p02718
s175570479
Accepted
import os import math def main(): n,m = map(int, input().split()) a_list = list(map(int, input().split())) total_check = math.ceil(sum(a_list)/(4*m)) a_list.sort(reverse=True) flag = True for i in range(m): if a_list[i] < total_check: flag = False break if flag: print("Yes") else: print("No") i...