problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02701
s625756724
Accepted
import sys import math from collections import Counter # input処理を高速化する input = sys.stdin.readline N=int(input()) Keihin =[] for i in range(N): syouhin = input() Keihin.append(syouhin) c=Counter(Keihin) print(len(list(c.keys())))
p02773
s107526343
Accepted
n = int(input()) c = {} m = 0 for i in range(n): s = input() if s in c: c[s] += 1 else: c[s] = 1 if m < c[s]: m = c[s] ans = [] for i in c: if m == c[i]: ans.append(i) ans = sorted(ans) for i in ans: print(i)
p02880
s463390581
Accepted
n = int(input()) arr = [] for i in range(1,10): for j in range(1,10): arr.append(i*j) if n in arr: print('Yes') else: print('No')
p03329
s913999090
Wrong Answer
n = int(input()) dp = list(range(n+1)) dp[0] = 0 for i in range(1, n+1): power = 1 while power <= i: dp[i] = min(dp[i], dp[i-power]+1) power *= 6 power = 1 while power < i: dp[i] = min(dp[i], dp[i-power]+1) power *= 9 print(dp[n])
p03469
s380503767
Accepted
# -*- coding: utf-8 -*- S = list(input()) S[3] = '8' print(''.join(S))
p03407
s879499012
Accepted
a,b,c = map(int, input().split()) if a + b < c: print('No') else: print('Yes')
p03150
s049162525
Wrong Answer
n = "keyence " s = input() cnt = 0 for i in s: if n[0] == i: n = n[1:] if cnt > 0: cnt = -1 elif n[0] != i: if cnt == -1: break cnt += 1 if n == " ": print("YES") else: print("NO")
p02742
s825450187
Wrong Answer
a, b = [int(i) for i in input().split()] if a*b%2: c = a*b else: c = a*b+1 print(c)
p02612
s999461555
Accepted
N = int(input()) x = 0 while x < N: x = x + 1000 output = x - N print(output)
p02748
s140401455
Accepted
A,B,M=map(int,input().split()) a= list(map(int,input().split())) b= list(map(int,input().split())) waribiki=[] for _ in range(M): waribiki.append(list(map(int,input().split()))) MIN=min(a)+min(b) for wari in waribiki: x=wari[0]-1 y=wari[1]-1 value=wari[2] total=a[x]+b[y]-value if(total < MIN...
p03799
s050620442
Accepted
n,m = map(int,input().split()) if(2*n >= m): print(m//2) else: m -= 2*n print(n + (m//4))
p02771
s942709420
Accepted
A, B, C = input().split() if C != A == B: print("Yes") elif A != B == C: print("Yes") elif B != C == A: print("Yes") else: print("No")
p02546
s502778910
Accepted
s = input() a = len(s) if s[a-1] == 's': print(s+'es') else: print(s+'s')
p02682
s588395949
Accepted
a,s,c,k = map(int,input().split()) if a>=k: print(k) elif a+s>=k: print(a) else: print(a - (k-a-s))
p04020
s190461249
Wrong Answer
n = int(input()) a = [int(input()) for _ in range(n)] ans = 0 for i in range(n): ans += a[i] // 2 a[i] %= 2 for i in range(n - 1, 0, -1): num = min(a[i - 1], a[i]) ans += num print(ans)
p03449
s555126247
Accepted
N = int(input()) A1 = list(map(int, input().split())) A2 = list(map(int, input().split())) A2.reverse() for i in range(N-1): A1[i+1] += A1[i] A2[i+1] += A2[i] ans = 0 for i in range(N): ans = max(ans, A1[i]+A2[N-1-i]) print(ans)
p03419
s461757885
Wrong Answer
def main(): ans = 0 n,m = map(int, input().split()) if n == m == 1: ans = 1 elif n == 1: ans = m-2 else: ans = (n-2)*(m-2) print(ans) if __name__ == '__main__': main()
p02918
s834978571
Wrong Answer
N, K = map(int, input().split()) S = input() unhappy = 0 if S[0] == "L": unhappy += 1 if S[-1] == "R": unhappy += 1 for i in range(1, N-1): if S[i:i+2] == "RL": unhappy += 2 if unhappy > 3: if unhappy > K: print(N-(unhappy-2*K)) else: print(N-1) else: print(N-1)
p03252
s616003821
Accepted
S = input() T = input() s = {d:[] for d in set(S)} t = {d:[] for d in set(T)} for i, (j,k) in enumerate(zip(S,T)): s[j] += [i] t[k] += [i] a = sorted(s.values()) b = sorted(t.values()) print('Yes' if a==b else "No")
p03854
s841486274
Wrong Answer
S= input() i=0 while True: flag = False if S[i:i+7] == "dreamer": i += 7 flag = True if S[i:i+6] == "eraser": i += 6 flag = True if S[i:i+5] == "erase" or S[i:i+5] == "dream": i += 5 flag = True if not flag: break if i == len(S): p...
p02971
s691061289
Accepted
n = int(input()) a = [int(input()) for _ in range(n)] b = sorted(a) for i in a: if i == b[-1]: print(b[-2]) else: print(b[-1])
p02948
s884689166
Accepted
import heapq n, m = map(int, input().split()) lis = [] for i in range(m + 1): lis.append([]) for i in range(n): a, b = map(int, input().split()) if a <= m: lis[a].append(-b) cnd = [] heapq.heapify(cnd) res = 0 for j in range(1, m + 1): for e in lis[j]: heapq.heappush(cnd, e) if c...
p03252
s918720698
Wrong Answer
s=str(input()) t=str(input()) temps=list(set(s)) tempt=list(set(t)) temps=sorted(list(temps)) tempt=sorted(list(tempt)) for i in range(0,len(temps)): temps[i]=s.count(temps[i]) for i in range(0,len(tempt)): tempt[i]=t.count(tempt[i]) if temps==tempt: print("Yes") else: print("No")
p02881
s971012484
Wrong Answer
import math n = int(input()) for i in range(int(math.sqrt(n)),-1,-1): if n%i == 0: if i == 1: print((n//i)-1) else: print(n//i) exit()
p02778
s491676595
Accepted
s=len(input()) print("x"*s)
p02712
s247595660
Wrong Answer
N = int(input()) num = 0 for i in range(N): if(i%3 != 0 and i%5 !=0): num += i print(num)
p03285
s662792360
Accepted
N=int(input()) for c in range(100//4+1): for d in range(100//7+1): if c*4+d*7==N: print("Yes") exit() print("No")
p02923
s024053716
Wrong Answer
N = int(input()) H = list(map(int, input().split())) kugiri = [] tmp = 0 for i in range(1,N): if H[i-1] < H[i]: tmp += 1 kugiri.append(tmp) continue tmp += 1 kugiri = [0] + kugiri + [N-1] ans = 0 for i in range(1,len(kugiri)): tmp = kugiri[i] - kugiri[i-1] ans = max(ans,tmp) pr...
p02963
s804526157
Accepted
def f(x1, y1, x2, y2): return abs(x1*y2 - x2*y1) def main(): S = int(input()) d = pow(10, 9) X1, Y1 = 0, 0 X2, Y2 = d, 1 X3 = (d - S%d)%d Y3 = (S + X3) // d print(X1, Y1, X2, Y2, X3, Y3) #print(f(X2, Y2, X3, Y3)) if __name__ == "__main__": main()
p02859
s009904002
Accepted
r = int(input()) R = int(r*r) print(R)
p02971
s158537208
Wrong Answer
n = int(input()) A=[0]*n maxd = 0 smax = 0 for i in range(n): A[i] = int(input()) if A[i] >= maxd: smax = maxd maxd =A[i] for i in range(n): if A[i]==maxd: print(smax) else: print(maxd)
p03106
s405785576
Wrong Answer
A, B, K = map(int, input().split()) l = list() a = 0 c = 0 if A > B: c = A else: c = B for i in range(1, c + 1): if A % i == 0 and B % i == 0: l.append(i) for i in range(len(l)): if i + 1 == K: a = l[i] print(a)
p02771
s084137020
Accepted
from collections import Counter abc = Counter(input().split()) if len(abc) == 2: print('Yes') else: print('No')
p02707
s516998696
Accepted
社員数 = int(input()) 部下数 = [0] * 社員数 for 上司 in map(int, input().split(' ')): 部下数[上司-1] += 1 for 部下 in 部下数: print(部下)
p03282
s007727263
Accepted
s=list(input()) k=int(input()) tmp=0 for i in s: ans=i if ans!="1": break else: tmp+=1 if tmp>=k: print("1") else: print(ans)
p03827
s472074350
Accepted
N=int(input()) S=input() x=0 M=0 for i in range(len(S)): if S[i]=='I': M=max(x+1,M) x=x+1 else: x=x-1 print(M)
p02910
s489738788
Accepted
s = input() for i in range(len(s)): if (i + 1) % 2 == 1 and s[i] == "L": print("No") break elif (i + 1) % 2 == 0 and s[i] == "R": print("No") break else: print("Yes")
p03284
s553548816
Wrong Answer
N, K = map(int,input().split()) print(N%K)
p02657
s336001063
Wrong Answer
import math list = input().split() a=int(int(list[0])) b=int(float(list[1])*100) ans = a*b print(ans)
p02972
s592950847
Wrong Answer
#!/usr/bin/env python3 import sys N = int(input()) a = [int(s) for s in input().split()] b = [0]*N sum_box = 0 index = 2 list_box = [] for i in range(N-1,-1,-1): if (i+1) <= N//index: index += 1 if sum(b[i::(N//(index-1))]) % 2 != a[i]: b[i] = 1 sum_box += 1 list_box.append(st...
p03448
s766124084
Accepted
a = int(input()) b = int(input()) c = int(input()) x = int(input()) cnt = 0 for i500 in range(a+1): for i100 in range(b+1): for i50 in range(c+1): total = (i500*500) + (i100*100) + (i50*50) if total == x: cnt += 1 print(cnt)
p03324
s291092874
Accepted
D,N=map(int,input().split()) if N!=100: print(N*(100**D)) else: print(101*(100**D))
p02778
s396006613
Accepted
s = input() print("x" * len(s))
p02951
s441254473
Wrong Answer
a,b,c=map(int,input().split()) print(c-(a-b))
p03163
s201551190
Wrong Answer
if __name__ == "__main__": N, W = map(int, input().split()) dp = [0] * (W+1) for i in range(N): weight, value = map(int, input().split()) for w in range((W - weight)+1): # for w in range((W - weight), -1, -1): dp[w + weight] = max(dp[w + weight], dp[w] + value) ...
p02661
s723088206
Accepted
N = int(input()) AB = [[int(i) for i in input().split()] for _ in range(N)] A = sorted([a for a,_ in AB]) B = sorted([b for _,b in AB]) if N % 2 == 1: # 奇数 MIN = A[(N + 1) // 2 - 1] MAX = B[(N + 1) // 2 - 1] else: # 偶数 MIN = A[N // 2 - 1] + A[N // 2] MAX = B[N // 2 - 1] + B[N // 2] print(MAX - MIN +...
p03379
s583811617
Accepted
n = int(input()) X = list(map(int, input().split())) x = sorted(X) l = x[n//2-1] r = x[n//2] for i in range(n): if X[i] <= l: print(r) else: print(l)
p02843
s473837360
Wrong Answer
x=int(input()) if x<=100: print(0) exit() if x>=2000: print(1) exit() else: t=x//100 a=x%100 if t<=a<=t*5: print(1) else: print(0)
p03548
s800438494
Wrong Answer
def isu(x , y , z): ans = x // (y + z) return ans if (x % (y + z) * (y + z)) + z < x else ans - 1 def main(): x , y , z = map(int , input().split()) print(isu(x , y , z)) if __name__ == '__main__': main()
p03264
s661514673
Accepted
k = int(input()) l = k // 2 m = (k + 1) // 2 print(l * m)
p02595
s102542401
Accepted
import math n, d = map(int, input().split()) xy = [map(int, input().split()) for _ in range(n)] cnt = 0 for x, y in xy: if math.sqrt(x**2 + y**2) <= d: cnt += 1 print(cnt)
p02785
s304662692
Accepted
data = [int(_) for _ in input().split()] enemy = [int(_) for _ in input().split()] if len(enemy) < data[1]: print(0) exit() elif data[1] == 0: print(sum(enemy)) else: enemy.sort() print(sum(enemy[:-data[1]]))
p03146
s495028140
Accepted
s = int(input()) a = [s] used = [0] * (10**6+1) used[s] = 1 for i in range(2, 10**6+2): if a[-1] % 2 == 0: a.append(val := a[-1]//2) else: a.append(val := 3*a[-1]+1) if used[val]: print(i) break else: used[val] = 1
p03672
s449994032
Accepted
s = input() s = s[:-2] while False in [s[i]==s[i+len(s)//2] for i in range(len(s)//2)]: s = s[:-2] print(len(s))
p02682
s349194840
Wrong Answer
a, b, c, k = map(int, input().split()) print(a-(k-a-b))
p02759
s512619736
Wrong Answer
n = int(input()) ans = n // 2 if n % 2: print(ans) else: print(ans + 1)
p03815
s520543689
Accepted
x = int(input()) N = x // 11 M = x % 11 if M == 0: ans = 0 elif M <= 6: ans = 1 else: ans = 2 print(2*N + ans)
p03456
s290669387
Wrong Answer
a, b = input().split() c = int(a + b) ok = False for i in range(1, 10 * 6): if c == i * i: ok = True break if ok: print('Yes') else: print('No')
p03761
s528604316
Accepted
from string import ascii_lowercase alp=ascii_lowercase ans=[float("inf")]*26 n=int(input()) for i in range(n): cnt=[0]*26 s=input() for j in s: p=alp.index(j) cnt[p]+=1 for j in range(26): ans[j]=min(ans[j],cnt[j]) output=[] for i in range(26): for j in range(ans[i]): ...
p03327
s332794187
Accepted
n = int(input()) if n <= 999: print('ABC') else: print('ABD')
p02813
s550051378
Accepted
n = int(input()) p = list(map(int, input().split())) q = list(map(int, input().split())) def f(x): if x == 0: return 1 if x == 1: return x else: return x * f(x-1) nlist = list(range(1, n+1)) po = 0 for i in range(n): po += f(n-i-1)*nlist.index(p[i]) nlist.remove(p[i]) po+=...
p02743
s571798701
Accepted
import math a,b,c=map(int,input().split()) if 4*a*b<(c-a-b)*(c-a-b) and c>a+b: print('Yes') else: print('No')
p02554
s829830464
Accepted
N = int(input()) MOD = 10**9+7 a = 8 b = 1 c = 1 d = 0 for _ in range(N-1): at = a * 8 bt = b * 9 + a * 1 ct = c * 9 + a * 1 dt = b * 1 + c * 1 + d * 10 a = at % MOD b = bt % MOD c = ct % MOD d = dt % MOD print(d)
p02778
s285120247
Accepted
def main(): S = input() print('x' * len(S)) main()
p03479
s679888787
Accepted
#abc083 c Multiple Gifts x, y = map(int, input().split()) a = x ans = 0 while a <= y: a *= 2 ans += 1 print(ans)
p02732
s715777098
Wrong Answer
from collections import Counter N = int(input()) An = list(map(int, input().split())) counter = Counter(An) cnt = 0 for c in counter.values(): cnt += c * c-1 // 2 for a in An: print(cnt - (counter[a] - 1))
p03274
s179580222
Wrong Answer
n,k = map(int,input().split()) x = list(map(int,input().split())) lst = [] for x_ in x: if x_ < 0: lst.append((abs(x_), -1)) else: lst.append((x_, 1)) lst.sort(key=lambda x:x[0]) pn = [0,0] for i in range(k): if lst[i][1]==1: pn[0] = lst[i][0] else: pn[1] = lst[i][0] pr...
p02695
s725602180
Wrong Answer
from itertools import combinations_with_replacement N, M, Q = map(int, input().split()) query = tuple(tuple(map(int, input().split())) for _ in range(Q)) ans = 0 for comb in combinations_with_replacement(range(1, M+1), N): print(comb) score = 0 for a, b, c, d in query: if comb[b-1] - comb[a-1] ==...
p03448
s876053699
Accepted
a = int(input()) b = int(input()) c = int(input()) x = int(input()) cont = 0 for i in range(a+1): for j in range(b+1): for k in range(c+1): if 500 * i + 100 * j + 50 * k == x: cont += 1 print(cont)
p03062
s885356634
Accepted
n = int(input()) A = list(map(int, input().split())) cnt_m, cnt_z = 0, 0 for a in A: if a < 0: cnt_m += 1 elif a == 0: cnt_z += 1 B = list(map(abs, A)) if cnt_m % 2 == 0 or cnt_z > 0: print(sum(B)) else: print(sum(B) - min(B)*2)
p02793
s166316003
Accepted
from fractions import gcd def lcm(a,b): return a*b//gcd(a,b) n=int(input()) a=[int(i) for i in input().split()] l=1 mod=10**9+7 for i in range(n): l=lcm(l,a[i]) ans=0 for i in a: ans+=l//i print(ans%mod)
p03360
s723647841
Accepted
a = list(map(int,input().split())) print(sum(a)+max(a)*(2**int(input())-1))
p03324
s882434699
Accepted
D,N = map (int, input ().split ()) if N == 100: X = (100**D)*(N+1) else: X = (100**D)*N print (X)
p02917
s238673461
Accepted
# coding: utf-8 def main(): N = int(input()) ans = 0 B = list(map(int, input().split())) ans += B[0] + B[-1] for i in range(1, N - 1): ans += min(B[i - 1], B[i]) print(ans) if __name__ == "__main__": main()
p02971
s083304562
Wrong Answer
N=int(input()) a=[] b=a for _ in range(N): a_=int(input()) a.append(a_) x=max(a) if a.count(x)>=2: for i in range(N): print(x) else: for i in range(N): if a[i]==x: b.sort() print(b[-2]) else:print(x)
p03127
s259605849
Wrong Answer
n = int(input()) al = list(map(int, input().split())) al.sort() t = al[0] ans = t for a in al: if a % t == 0: continue else: ans = 1 print(ans)
p03106
s196740219
Wrong Answer
a,b,k=map(int,input().split()) lisa=[] lisb=[] for i in range(1,a+1): if a%i==0: lisa.append(i) for j in range(1,b+1): if b%j==0: lisb.append(j) for l in lisa: if l in lisb: k-=1 if k==0: print(l) break
p02743
s951014316
Wrong Answer
A,B,C=map(int,input().split()) if C**0.5*(10**5)>A**0.5*(10**5)+B**0.5*(10**5): print("Yes") else: print("No")
p03061
s491682401
Accepted
import fractions N = int(input()) A = [int(x) for x in input().split()] kouho_set = set() kouho_set = [0] * (N + 1) kouho_set[0] = set() kouho_set[0].add(A[1]) nowgcd = A[0] for i in range(1, N): kouho_set[i] = set() for j in kouho_set[i-1]: kouho_set[i].add(fractions.gcd(A[i], j)) kouho_set[i].add(...
p02935
s913600269
Accepted
N=int(input()) v=sorted(list(map(int,input().split()))) for i in range(N-1): v[i+1]=(v[i]+v[i+1])/2 print(v[N-1])
p03043
s272875878
Accepted
N, K = map(int,input().split()) ans = 0 for i in range(1,N+1): c = 0 while(i < K): i *= 2 c += 1 ans += 1 / 2 ** c print(1/N * ans)
p02572
s943322288
Accepted
import functools import operator N = int(input()) A = list(map(int, input().split())) mod = 10**9+7 ans = 0 v = sum(A) for i in range(N-1): v -= A[i] ans += A[i]*v print(ans%mod)
p03730
s848104310
Wrong Answer
#!/usr/bin/env python3 A,B,C = [int(i) for i in input().split()] M = [] for i in range(1,100+1): if (A*i)%B in M: break else: M.append((A*i)%B) if C in M: print("Yes") else: print("No")
p03284
s341413372
Wrong Answer
N, K = map(int, input().split()) print(K-(N//K))
p02948
s890388115
Wrong Answer
n, m = map(int, input().split()) AB = [] for i in range(n): a, b = map(int, input().split()) AB.append((a, b)) AB.sort(key=lambda ab: -ab[1]) counts = [0] * m used = [False] * m total = 0 score = 0 for a, b in AB: if a > m: continue for i in range(a - 1 + counts[a - 1], m): if used[i]: ...
p02820
s896339095
Accepted
import itertools N,K = [int(hoge) for hoge in input().split()] RSP = [int(hoge) for hoge in input().split()] T = input() Hand = [[] for i in range(K)] for n,d in enumerate(T): if d == "r": t = 2 elif d == "s": t = 0 else: t = 1 Hand[n%K].append(t) ans = 0 for k in Hand: Han...
p03416
s436450630
Wrong Answer
def main(a, b): ans = 0 for i in range(a, b + 1): s = str(i) if s[:len(s) // 2] == s[(len(s) // 2) + 1:]: ans += 1 print(ans) if __name__ == "__main__": a, b = map(int, input().split()) main(a, b)
p03679
s748273183
Wrong Answer
x,a,b = map(int, input().split()) if b - a < x and b - a > 0 : print("safe") elif b - a < x and b - a < 0 : print("delicious") else: print("dangerous")
p03041
s827653535
Accepted
N,K=map(int,input().split()) S=input() s=S[:K-1] s+=S[K-1].swapcase() s+=S[K:] print(s)
p02702
s808850083
Accepted
s = input()[::-1] # 入力文字列を逆順でsに格納 counts = [0] * 2019 counts[0] = 1 num, d = 0, 1 for char in s: num += int(char) * d num %= 2019 d *= 10 d %= 2019 counts[num] += 1 ans = 0 for cnt in counts: ans += cnt * (cnt - 1) // 2 print(ans) # 答えの出力
p04029
s979111866
Wrong Answer
N=int(input()) print(N*(N+1))
p02660
s105916143
Wrong Answer
N=int(input()) nn=N import math sq=int(math.sqrt(N))+10000 i=2 ans=0 count1=0 count2=1 while sq>=i: if nn%i==0: nn//=i count1+=1 if count1//count2>0: ans+=1 count2+=1 count1=0 else: i+=1 count1=0 count2=1 if ans==0 and N>=2: ...
p02859
s863810774
Accepted
print(int(input())**2)
p03612
s235545546
Accepted
N = int(input()) p = list(map(int,input().split())) ans = 0 for i in range(N-1): if p[i] == i+1: p[i],p[i+1] = p[i+1],p[i] ans += 1 if p[-1] == N: ans += 1 print(ans)
p02747
s406960442
Wrong Answer
s = input() ans = 'No' if 'hi' in s: ans = 'Yes' print(ans)
p03471
s318518668
Wrong Answer
def main(): N,Y=map(int,input().split()) for i in range(Y//10000+1): tY=Y-10000*i for j in range(tY//5000+1): k=(tY-5000*j)//1000 if i+j+k==N: print(i,j,k) return print(-1 -1 -1) main()
p02909
s910653456
Wrong Answer
S = input() if S == 'Sunny': print('cloudy') elif S == 'cloudy': print('Rainy') elif S == ' ': print('Sunny')
p02873
s113311842
Accepted
s = input() n = len(s) dp = [0]*(n+1) t = 0 for e,i in enumerate(s,1): if i=='<' : dp[e]=dp[e-1]+1 # print(dp) t = 0 for e in range(n-1,-1,-1): i = s[e] # print(t) if i=='>' : dp[e]=max(dp[e],dp[e+1]+1) # print(dp) print(sum(dp))
p02658
s240496051
Accepted
n = int(input()) a = list(map(int, input().split())) if 0 in a: print(0) exit() ans = 1 for i in a: ans *= i if ans > 10 ** 18: print("-1") exit() print(ans)
p02843
s428961567
Wrong Answer
import sys x = input() x1 = list(x) h = len(x) x = int(x) if x>2000: print('1') sys.exit() elif x<100: print('0') sys.exit() a1 = int(x1[h-1]) a2 = int(x1[h-2]) if 0 < a1 < 5: c1 = 1 elif a1 == 0: c1 = 0 else: c1 = 2 c2 = a2*2 if int(x1[0])+int(x1[1]) < c1+c2: print('0') else: print('1')