problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p03681
s507265087
Wrong Answer
import math n, m = map(int, input().split()) mod = 10 ** 9 + 7 if abs(n - m) < 2: res = 2 * math.factorial(n) * math.factorial(m) print(res % mod) else: print(0)
p02813
s735720085
Wrong Answer
import math N = int(input()) Pi = list(map(int,input().split())) Qi = list(map(int,input().split())) a = 0 b = 0 numcheck = [1 for i in range(N)] numcheck[Pi[0]-1] = 0 a = math.factorial(N-1)*(Pi[0]-1) for n in range(1,N): num = Pi[n] numcheck[num-1] = 0
p04044
s230170112
Wrong Answer
N, L = [int(i) for i in input().split(' ')] words = [input() for i in range(N)] words.sort(key=lambda x: x[0]) for word in words: print(word, end = ' ')
p02659
s723389889
Accepted
import decimal slist = input().split() a = int(slist[0]) b = decimal.Decimal(slist[1]) print(int(a*b))
p03605
s245503407
Accepted
n = input() if n.count("9") > 0: print("Yes") else: print("No")
p03109
s917364120
Accepted
s = input() s1 = s.split("/") ans = "Heisei" if int(s1[0]) >= 2019: if int(s1[1]) >= 5: ans = "TBD" print(ans)
p02860
s383562021
Accepted
n = int(input()) s = input() if s == s[:n//2] + s[:n//2]: print('Yes') else: print('No')
p02780
s739996992
Accepted
import sys from collections import * import heapq import math import bisect from itertools import permutations,accumulate,combinations,product from fractions import gcd def input(): return sys.stdin.readline()[:-1] mod=10**9+7 n,k=map(int,input().split()) p=list(map(int,input().split())) ans=0 for i in range(k): ...
p02754
s467633202
Accepted
N, A, B = map(int, input().split()) result = 0 result += N // (A + B) * A result += min(N % (A + B), A) print(result)
p03994
s112514341
Wrong Answer
s=input() k=int(input()) m=len(s) word={j:26-i for i,j in enumerate([chr(_) for _ in range(97,97+26)])} number={i:j for i,j in enumerate(chr(_) for _ in range(97,97+26))} ans="" for i,j in enumerate(s): if word[j]<=k: k -=word[j] ans +="a" elif i==m-1 and k>0: k %=26 if k>word[...
p03986
s695749459
Wrong Answer
def main(): X = input() len_X = len(X) right_T = X.rfind("T") S_Count = X[:right_T].count("S") ans = len_X - S_Count*2 print(ans) if __name__ == "__main__": main()
p02759
s035633479
Accepted
n = input() n = int(n) if n % 2 != 0: print(int(n/2)+1) else: print(int(n/2))
p02717
s360094555
Accepted
a,b,c = map(int, input().split()) print(str(c)+" "+str(a)+" "+str(b))
p02924
s909164337
Accepted
n=int(input()) print(n*(n-1)//2)
p02693
s722118226
Accepted
K = int(input()) A, B = map(int, input().split()) for i in range(A, B + 1): if i % K == 0: print("OK") break else: print("NG")
p02768
s586258818
Accepted
mod = 10 ** 9 + 7 def calc(n,r): x = 1 y = 1 for i in range(r): x *= n - i x %= mod y *= i + 1 y %= mod return x * pow(y, mod - 2, mod) % mod n, a, b = map(int, input().split()) res = pow(2, n, mod) - 1 for i in [a, b]: res -= calc(n, i) print(res % mod)
p02814
s431913608
Wrong Answer
# 最大公約数 def gcd(a, b): while b != 0: a, b = b, a % b return a # 最小公倍数 def lcm(a, b): return a * b // gcd(a, b) N, M = map(int, input().split()) A = list(map(int, input().split())) x = A[0] // 2 for a in A[1:]: x = lcm(x, a // 2) ans = M // x print(ans - ans // 2)
p03219
s499881916
Wrong Answer
x,y=map(int,input().split()) print(x+y/2)
p03557
s046390786
Accepted
from bisect import bisect,bisect_left from collections import deque n=int(input()) a=list(map(int,input().split())) b=list(map(int,input().split())) c=list(map(int,input().split())) a.sort() b.sort() c.sort() tmp=0 for i in b: dd=bisect_left(a,i)*(n-bisect(c,i)) tmp+=dd print(tmp)
p03145
s877398596
Accepted
import sys def input(): return sys.stdin.readline().strip() def mapint(): return map(int, input().split()) sys.setrecursionlimit(10**9) A, B, C = mapint() print(A*B//2)
p02612
s703248851
Accepted
n=int(input()) money=1000 while True: if money>=n: print(money-n) break money+=1000
p02970
s653422156
Accepted
n, d = map(int, input().split()) ans = n//(2*d+1) print(ans if n%(2*d+1) == 0 else ans+1)
p02779
s670965868
Accepted
n = int(input()) a = list(map(int,input().split())) s = set(a) if len(a) == len(s): print('YES') else: print('NO')
p02820
s346962339
Accepted
N, K = map(int, input().split()) ls1 = list(map(int, input().split())) d = dict() ls2 = ['r', 's', 'p'] for x, y in zip(ls1, ls2): d[y] = x T = input() S = T.translate(str.maketrans({'r': 'p', 's': 'r', 'p': 's'})) ans = 0 for i in range(K): cur = '' for j in range(i, N, K): if cur != S[j]: ...
p03624
s988588154
Accepted
S=input() al=[chr(ord('a') + i) for i in range(26)] ss=set(al) for str in S: if str in ss: ss.remove(str) if len(ss)>0: print(sorted(ss)[0]) else: print("None")
p02571
s349412667
Wrong Answer
s = input() t = input() maiores = [] maior = 0 for i in range(len(s)-len(t)+1): for j in range(len(t)): if s[i+j] == t[j]: maior += 1 if j == len(t)-1: maiores.append(maior) else: maiores.append(maior) maior = 0 print(len(t) - max(ma...
p03612
s297831276
Wrong Answer
n = int(input()) p = [int(i) for i in input().split()] liI = [int(j) for j in range(1,n+1)] count = 0 for i in range(1,n): if p[i-1] == liI[i]: cha = p[i-1] p[i-1] = p[i] p[i] = cha count+=1 print(count)
p02624
s584562320
Accepted
def num_divisors_table(n): table = [0] * (n + 1) for i in range(1, n + 1): for j in range(i, n + 1, i): table[j] += 1 return table def main(): n = int(input()) tmp = num_divisors_table(n + 2) ans = 0 for i in range(1, n + 1): ans += tmp[i]*i print(ans) ...
p02963
s851140281
Accepted
import math s = int(input()) x1 = 10**9 y2 = math.ceil(s/10**9) x2 = 1 y1 = x1*y2 - s print(0,0,x1,y1,x2,y2)
p03852
s684047893
Wrong Answer
s=['a','i','o','u','e'] x=input() falg=0 for i in s: if (i==x): falg=1 break if falg==0: print('consonant.g') else: print("vowel.")
p03241
s557205996
Accepted
n,m=map(int,input().split());print(next(v for v in range(m//n,-1,-1)if m%v==0))
p02811
s232970361
Accepted
k, x = map(int, input().split()) if 500*k >= x: print("Yes") else: print("No")
p03637
s585489043
Wrong Answer
N=int(input()) a=list(map(int,input().split())) if 2 in a: two_cnt=1 else: two_cnt=0 other_cnt=len([i for i in a if i % 2 != 0]) four_cnt=len([i for i in a if i % 4 == 0]) if two_cnt==0: if other_cnt<=four_cnt+1: print('Yes') else: print('No') else: if other_cnt<=four_cnt: ...
p03352
s299836958
Accepted
x = int(input()) mx = 0 for b in range(1, int(1000 ** 0.5) + 1): for p in range(2, 10): if mx < b ** p <= x: mx = b ** p print(mx)
p03241
s758106425
Wrong Answer
import math N,M=map(int,input().split()) P=math.ceil(M**0.5) ans=1 i=1 while i<=P: if M%i==0: j = M//i if j>=N: ans=j i +=1 print(ans)
p02939
s665200669
Wrong Answer
s = list(input()) b = s[0] count = 1 for i in s[1:]: if i != b: count += 1 b = i else: b += i if len(b) == 2: print(count+1) else: print(count)
p02833
s012388556
Wrong Answer
N = int(input()) if N % 2 == 1: print(0) else: n = 0 i = 1 while True: n += N // 10**i if N < 10**i: break i += 1 print(n)
p02677
s266527486
Wrong Answer
import math A,B,H,M = map(int,input().split()) rad = H*30 - M * 6 if (H/12) > (M/60) else M * 6 -H*30 print(((B**2) +( A **2 )- (2 * B * A )* (math.cos(math.radians(rad))))**0.5)
p03387
s047091221
Wrong Answer
a=list(map(int,input().split())) a.sort() print(a) cnt=0 if a[0]==a[1]==a[2]: print(0) exit() if a[0]==[1]: print(a[2]-a[1]) exit() if a[1]==a[2]: if (a[2]-a[0])%2==0: print((a[2]-a[0])//2) exit() else: print(a[2]-a[0]+1) exit() cnt+=a[2]-a[1] a[0]+=cnt if (a[2]-a[0])%2==0: cnt+=(a[2]-a[0]...
p02823
s477647770
Wrong Answer
n, a, b = map(int, input().split()) if (a - b) % 2 == 0: print(abs(a - b) // 2) else: if a < b: print(abs(b - (a - 1) - 1) // 2 + 2) else: print(abs(a - (b - 1) - 1) // 2 + 2)
p03105
s857804613
Accepted
a,b,c = map(int,input().split()) if b//a >= c: print(int(c)) else: print(int(b//a))
p02847
s555424683
Accepted
w = {'SUN': 7,'MON': 6,'TUE': 5,'WED': 4,'THU': 3,'FRI': 2,'SAT':1} s = input() print(w[s])
p02958
s481767606
Accepted
n=int(input()) A=list(map(int,input().split())) B=sorted(A) cnt=0 for i in range(n): if A[i]!=B[i]: cnt+=1 print('YES' if cnt<=2 else 'NO')
p02922
s366195595
Wrong Answer
a,b=map(int,input().split()) z = b // a if z==0: print('1') else: b -= a a -= 1 y = b % a if y==0: print(1 + b//a) else: print(2 + b//a)
p02688
s967486991
Wrong Answer
N,K = map(int,input().split()) c = 0 listA = [] for k in range(1,K+1): d = int(input()) listA += list(map(int,input().split())) for n in range(1,N+1): if n in listA: c += 1 print(c)
p03324
s510445881
Wrong Answer
N,C = map(int,input().split(' ')) print((100 ** N) * C)
p03852
s450813708
Accepted
s = input() l = ('a', 'e', 'i', 'o', 'u') if s in l: print('vowel') else: print('consonant')
p02972
s548380222
Accepted
#入力 n=int(input()) a=list(map(int,input().split())) #dpテーブル dp[i-1]はi番目の箱に入っているボールの数 dp=[0 for i in range(n)] #初期条件 dp[n-1]=a[n-1] for i in range(n,0,-1): num=0 for j in range(i*2,n+1,i): num=num+dp[j-1] if num%2==a[i-1]: dp[i-1]=0 else: dp[i-1]=1 print(dp.count(1)) for i in range(n): if dp[i]==...
p03449
s754388270
Accepted
N=int(input()) *A1,=map(int,input().split()) *A2,=map(int,input().split()) ans=[0]*N i=0 while i<N: ans[i]+=sum(A1[:i+1]) ans[i]+=sum(A2[i:]) i+=1 print(max(ans))
p03220
s780194164
Accepted
N=int(input()) T,A=map(int,input().split()) H=list(map(int,input().split())) num=float("inf") ans=0 for i in range(N): H[i]=T-0.006*H[i] if abs(A-H[i])<num: ans=i+1 num=abs(A-H[i]) print(ans)
p02596
s343726574
Accepted
import sys K = int(input()) seven = 0 for i in range(K+2): seven += (7 * pow(10, i, K)) % K seven %= K if seven == 0: print(i+1) sys.exit() print(-1)
p03062
s281495046
Accepted
# 符号の数について、-が偶数だった場合、全てを打ち消せる # 奇数だった場合、どれか一つが残る。 # `..,+,-,+,..`を→移動←移動できるので def solve(): N = int(input()) A = list(map(int, input().split())) ret = sum(abs(a) for a in A) num_neg = sum(a < 0 for a in A) min_abs_A = min(abs(a) for a in A) if num_neg % 2 == 1: ret -= 2*min_abs_A ...
p03317
s409154268
Accepted
import math n,k=map(int,input().split()) a=list(map(int,input().split())) b=math.ceil((n-1)/(k-1)) print(b)
p02687
s520438736
Accepted
s=input() if s=="ABC": print("ARC") else: print("ABC")
p03557
s550776377
Wrong Answer
import bisect n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) c = list(map(int, input().split())) a.sort b.sort c.sort ans = 0 for i in range(len(c)): b_M = bisect.bisect_left(b, c[i]) for j in range(b_M): a_M = bisect.bisect_left(a, b[j]) ans += a_M pr...
p02694
s636478140
Accepted
import math x = int(input()) money = 100 count = 0 while (money <x): money = math.floor(money*1.01) count +=1 print(count)
p02596
s142058734
Wrong Answer
K=int(input()) if K%2==0: print(-1) else: seven=0 m=0 count=1 for i in range(K+1): m=(m*10+7)%K if m==0: print(count) break count+=1
p02687
s062092374
Accepted
S=input() if S=='ARC': print('ABC') elif S == 'ABC': print('ARC')
p02601
s092455328
Wrong Answer
a, b, c = map(int, input().split()) k = int(input()) for _ in range(k): if a >= b: b = b ** 2 elif b >= c: c = c ** 2 if a < b < c: print("Yes") else: print("No")
p02996
s506110110
Wrong Answer
x = int(input()) job = [] time = [] for i in range(x): j, t = list(map(int, input().split())) job.append(j) time.append(t) jt = 0 tt = 0 f = 0 for i in range(x): if job[i] >= time[i]: pass else: print("No") f = 1 break jt += job[i] if tt < time[i]: tt ...
p03943
s318939384
Wrong Answer
a = list(map(int,input().split())) hanbun = int(sum(a)/2) isOK = False if hanbun!=0: for i in range(3): if hanbun==a[i]: isOK = True if isOK: print('Yes') else: print('No')
p02547
s008716649
Accepted
cnt = 0 n = int(input()) for i in range(n): n,m = map(int,input().split()) if n == m: cnt += 1 else: cnt = 0 if cnt == 3: print("Yes") exit() print("No")
p02988
s782494466
Accepted
n=int(input()) p=list(map(int, input().split())) t=0 for i in range(n): if i!=0 and i!=n-1: l=[p[i-1], p[i], p[i+1]] l.sort() if l[1]==p[i]: t+=1 print(t)
p03815
s442448983
Wrong Answer
x = int(input()) ans = int(x/11*2) tmp = x%11 if tmp > 6: ans+=2 else: ans+=1 print(ans)
p03095
s892033913
Accepted
from collections import defaultdict mod = 10**9 + 7 n = int(input()) d = defaultdict(int) for c in list(input()): d[c] += 1 res = 1 for c in d: res *= (d[c]+1) res %= mod res = res + mod - 1 res %= mod print(res)
p02697
s578462032
Accepted
n, m = map(int, input().split()) right = 2*m+1 if m%2 == 0: for i in range(m//2): print(1+i, 1+m-i) print(2+m+i, right-i) else: center = m+1 for i in range(m//2): print(1+i, center-i) print(center+1+i, right-i) print(m//2+1, m//2+2)
p02584
s562116038
Accepted
def main(): X,K,D=map(int,input().split()) zero_flag=0 if abs(X)>=K*D: zero_flag=1 if zero_flag==0: d=abs(X)%D d_=abs(X)//D if (K-d_)%2==1: print(abs(D-d)) else: print(abs(X)-abs(D*d_)) else: print(abs(X)-K*D) if __name__=="_...
p02814
s309038316
Accepted
n, m = map(int, input().split()) a = list(map(int, input().split())) from fractions import gcd from functools import reduce a = [i >> 1 for i in a] def applied_lcm(x, y): g = gcd(x, y) x //= g y //= g if x %2 == 0: return 0 if y %2 == 0: return 0 n = x * y * g if n >> 10**...
p03611
s112128657
Accepted
import collections N = int(input()) *A, = map(int, input().split()) print(max(collections.Counter(A + [a-1 for a in A] + [a+1 for a in A]).values()))
p03486
s358983303
Accepted
s = input() t = input() if sorted(s) < sorted(t, reverse=True): print("Yes") else: print("No")
p02912
s378821491
Wrong Answer
import math N,M=map(int,input().split()) A=list(map(int,input().split())) A.sort(reverse=True) logof2=[0]*N mi=0 #print(A) for i in range(N): logof2[i]=math.log2(A[i]) #print(logof2) for i in range(M): if logof2[0]<0: break else: logof2[0]=logof2[0]-1 logof2.sort(reverse=True) #p...
p03711
s054755848
Accepted
a=[1,3,5,7,8,10,12] b=[4,6,9,11] c=[2] x,y=map(int,input().split()) if (x in a and y in a) or (x in b and y in b) or (x in c and y in c): print('Yes') else: print('No')
p02706
s363741554
Wrong Answer
if __name__ == "__main__": n, m = map(int, input().split()) al = list(map(int, input().split())) al.sort() res = sum(al[:m]) print(n - res)
p03145
s105254798
Wrong Answer
a,b,c=map(int, input().split()) print(a*b/2)
p03469
s747550758
Wrong Answer
s = input() print("2017"+s[4:])
p03282
s307692215
Accepted
S=input() K=int(input()) ans=1 for i in range(min(len(S),K)): if S[i]!='1': ans=S[i] break print(ans)
p03679
s370468179
Accepted
x,a,b=map(int, input().split()) if a-b>=0: print("delicious") elif (a-b)<0 and abs(a-b)<=x: print("safe") else: print("dangerous")
p02646
s890450625
Wrong Answer
a,v=(int(x) for x in input().split()) b,w=(int(x) for x in input().split()) t = int(input()) flag = 0 if v > w and a<=b: for i in range(t): if a+v*i >= b+w*i: flag = 1 break if flag ==1: print("YES") else: print("NO")
p03059
s054346127
Accepted
def main(): a,b,t = map(int,input().split()) ans = 0 for i in range(1,t + 1, 1): if i % a == 0: ans += b print(ans) main()
p02600
s991531856
Accepted
x = int(input()) if 400 <= x < 600: print(8) elif 600 <= x < 800: print(7) elif 800 <= x < 1000: print(6) elif 1000 <= x < 1200: print(5) elif 1200 <= x < 1400: print(4) elif 1400 <= x < 1600: print(3) elif 1600 <= x < 1800: print(2) elif 1800 <= x < 2000: print(1)
p02633
s937010400
Wrong Answer
import sys import math import itertools import bisect from copy import copy from collections import deque,Counter from decimal import Decimal def s(): return input() def i(): return int(input()) def S(): return input().split() def I(): return map(int,input().split()) def L(): return list(input().split()) def l(): retur...
p02912
s348846900
Accepted
from heapq import heappush, heappop, heapify def neg_int(n): return -int(n) N, M = map(int, input().split()) a_list = list(map(neg_int, input().split())) heapify(a_list) for _ in range(M): a = -heappop(a_list) a //= 2 heappush(a_list, -a) print(-sum(a_list))
p02688
s282042761
Accepted
n, k = map(int, input().split()) snuke = [1 for i in range(n)] for _ in range(k): d = int(input()) a = list(map(int, input().split())) for i in a: snuke[i -1] = 0 print(sum(snuke))
p03327
s860253155
Accepted
N = int(input()) if N < 1000: print("ABC") else: print("ABD")
p03416
s871180803
Accepted
A, B = map(int,input().split()) ans = 0 def palindrome(string): return 0 if string==string[::-1] else 1 for i in range(A, B+1): if palindrome(str(i)) == 0 : ans += 1 print(ans)
p03607
s082265427
Accepted
# coding:utf-8 import sys from collections import Counter def main(): n = int(input()) a = list(map(int, [input() for i in range(n)])) a_count = Counter(a) ans = [] for i in a_count.items(): if i[1] % 2 != 0: ans.append(i[0]) print(len(ans)) if __name__ == '__main__' ...
p03803
s500891181
Accepted
A,B=map(int,input().split()) if A==1: A=100 if B==1: B=100 if A>B: print("Alice") elif A<B: print("Bob") else: print("Draw")
p02724
s306883609
Accepted
X=int(input()) x500=X//500 X=X%500 x5=X//5 print(x500*1000+x5*5)
p03672
s353870919
Accepted
s = input() for l in range(len(s) - 2, 0, -2): s = s[0:l] if s[0:l // 2] == s[l // 2:l]: break print(l)
p02843
s118100115
Accepted
N=int(input()) b=0 x = N //100 for y in range(100*x,105*x+1): if N==y: print(1) exit() print(0)
p02658
s555679819
Accepted
N = int(input().rstrip()) A = sorted([int(v) for v in input().rstrip().split()]) r = 1 for v in A: if v == 0: r = 0 break r *= v if r > 1000000000000000000: r = -1 break print(r)
p03254
s011766308
Wrong Answer
N,x = [int(hoge) for hoge in input().split()] A = [int(hoge) for hoge in input().split()] #x個のお菓子を配る。 #和がxを越えないように最も多い数のaを選ぶ A.sort() ans = 0 cur = 0 for a in A: cur += a if cur > x: print(ans) exit() ans += 1 print(ans)
p03836
s919263215
Accepted
sx, sy, tx, ty = map(int,input().split()) dx = (tx - sx) dy = (ty - sy) s = 'U' * dy + 'R' * dx s += 'D' * dy + 'L' * dx s += 'L' + 'U' * (dy+1) + 'R' * (dx+1) + 'D' s += 'R' + 'D' * (dy+1) + 'L' * (dx+1) + 'U' print(s)
p03624
s067599077
Accepted
S = list(input()) flg = True for i in range(ord('a'), ord('z') + 1): if S.count(chr(i)) == 0: flg = False ans = chr(i) break print("None" if flg else ans)
p02714
s983683288
Accepted
n = int(input()) s = input() import collections temp1 = 0 for j in range(1,n-1): i,k = j-1,j+1 while i >= 0 and k < n: if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]: temp1 += 1 i,k = i-1,k+1 c = collections.Counter(s) temp2 = 1 for key in "RGB": temp2 *= c[key] print(temp2-te...
p02951
s025033434
Accepted
def solve(): N, M, L = map(int, input().split()) if N >= M+L: return 0 return -(N-M-L) print(solve())
p03633
s371283478
Wrong Answer
def gcd(a, b): if b == 0: return a return gcd(b, a%b) n = int(input()) t1 = int(input()) ans = 0 for _ in range(n-1): t2 = int(input()) ans = t1*t2 // gcd(t1, t2) t1 = ans print(ans)
p03910
s442144438
Accepted
def main(): N = int(input()) ls = [0] ans = [] for i in range(1,N+1): ls.append(ls[-1]+i) ans.append(i) if N<=ls[-1]: break for i in range(len(ans)): if ans[i]==(ls[-1]-N): pass else: print(ans[i]) if __na...
p03605
s783050847
Wrong Answer
N = input() if "9" in N: print("YES") else: print("NO")
p02627
s742853748
Wrong Answer
print(input())