problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02881
s600415714
Accepted
import math n=int(input()) def sosu(x): a=1 for i in range(2,int(math.sqrt(x))+1): if x%i==0: a=i#素数でない場合は最後のaが出力される return a a=sosu(n) if a==1: print(n-1) else: b=n//a ans=(a-1)+(b-1) print(ans)
p03543
s103726044
Accepted
n = list(map(int, input())) if n[0] == n[1] == n[2]: print('Yes') elif n[1] == n[2] == n[3]: print('Yes') else: print('No')
p02848
s144809059
Wrong Answer
A=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O', 'P','Q','R','S','T','U','V','W','X','Y','Z'] N=int(input()) x=input() X=[j for j in x] for i in range(0,len(X)-1): n=(A.index(X[i])+N)%26 X[i]=A[n] print(X)
p04005
s487313975
Accepted
a,b,c = map(int,input().split()) if a%2 == 0 or b%2 == 0 or c%2 == 0: print(0) else: print(min(a*b,a*c,b*c))
p03759
s582773104
Accepted
a,b,c=map(int,input().split()) if (b-a)==(c-b): print("YES") else: print("NO")
p03971
s657626105
Accepted
n, a, b = map(int,input().split()) s = input() a_p = 0 b_p = 0 for i in s: if i == 'a' and a_p + b_p < a + b: print('Yes') a_p += 1 elif i == 'b' and a_p + b_p < a + b and b_p < b: print('Yes') b_p += 1 else: print('No')
p02994
s376850426
Accepted
# B n,l = map(int,input().split()) ans=0 for i in range(1,n+1): ans+=(l+i-1) if l+n-1 < 0: print(ans-(l+n-1)) elif l+n-1 >= 0 and l <= 0: print(ans) else: print(ans-l)
p02879
s364043901
Wrong Answer
A,B = map(int,input().split()) if A >= 10 and B >= 10 or A == 0 or B == 0: print(-1) else: print(A*B)
p02608
s425258302
Wrong Answer
n = int(input()) ans = [0]*n for x in range(1,int(n**.5)+1): for y in range(1,int(n**.5)+1): for z in range(1,int(n**.5)+1): a = x*x+y*y+z*z+x*y+y*z+z*x if a < n: ans[a] += 1 for i in range(n): print(ans[i])
p02988
s457036308
Accepted
n=int(input()) s=list(map(int,input().split())) cnt=0 for i in range(1,n-1): if s[i-1]<s[i] and s[i]<s[i+1]: cnt+=1 if s[i-1]>s[i] and s[i]>s[i+1]: cnt+=1 print(cnt)
p03617
s057519620
Accepted
def solve(): Q, H, S, D = map(int, input().split()) N = int(input()) two = min([Q*8,H*4,S*2,D]) one = min([Q*4,H*2,S]) ans = two*(N//2)+one*(N%2) return ans print(solve())
p03817
s305659867
Accepted
x=int(input()) q=x//11 r=x%11 if r==0: print(2*q) elif r<=6: print(2*q+1) else: print(2*q+2)
p02601
s005653126
Accepted
A, B, C = map(int, input().split()) K = int(input()) counter = 0 while C <= B or C <= A: C = 2*C counter += 1 while B <= A: B = 2*B counter += 1 while C <= B: C = 2*C counter += 1 if counter > K: print("No") else: print("Yes")
p03077
s006264230
Wrong Answer
n=int(input()) x = [int(input()) for _ in range(5)] p = min(x) q = n//p print(q+4)
p03377
s755570568
Wrong Answer
a,b,x=map(int,input().split()) if a<=x<=b: print('YES') else: print('NO')
p03474
s596682173
Accepted
a, b = map(int, input().split()) s = input() number = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] if s[a] == "-": if all(s[:a][i] in number for i in range(a)) and all(s[a + 1:a + b + 1][i] in number for i in range(b)): print("Yes") else: print("No") else: print("No")
p02676
s913232870
Accepted
K = int(input()) S = input() if len(S) <= K: print(S) else: print(S[:K]+"...")
p03617
s539960203
Accepted
l=list(map(int,input().split())) n=int(input()) a=[l[0]] b=[2*l[0],l[1]] c=[4*l[0],2*l[1],l[2]] d=[8*l[0],4*l[1],2*l[2],l[3]] ans=0 x=n//2 y=n%2 print(x*min(d)+y*min(c))
p03106
s849698458
Wrong Answer
A,B,K=map(int,input().split()) count=1 ans=0 i=1 while count<=K: if A%i==0 and B%i==0: count+=1 ans=i print(ans) i+=1 print(ans)
p03998
s369271787
Accepted
import sys sys.setrecursionlimit(10 ** 7) def resolve(): A = list(input()) B = list(input()) C = list(input()) def solve(S, s): if len(S) == 0: return s.upper() s = S.pop(0) if s == "a": return solve(A, s) elif s == "b": return solv...
p03136
s483621343
Wrong Answer
N = int(input()) L = sorted(list(map(int, input().split()))) if L[-1] > sum(L[:-1]): print("No") else: print("Yes")
p02831
s125294253
Accepted
from fractions import gcd A, B = map(int, input().split()) print(A * B // gcd(A, B))
p03469
s326947568
Wrong Answer
S = input() S.replace("2017","2018") print(S)
p02993
s625839583
Accepted
import sys s = input() for i in range(len(s) - 1): if(s[i] == s[i + 1]): print('Bad') sys.exit() print('Good')
p02622
s725164003
Wrong Answer
Answer = input() input_retu = input() count = 0 for i in range(len(Answer)): if Answer[i] == input_retu[i]: continue else: count += 1
p02923
s765145097
Accepted
n = int(input()) H = [int(x) for x in input().split()] maxv = 0 v = H[0] count = 0 for i in range(1,n): if v < H[i]: if maxv < count: maxv = count count = 0 else: count += 1 v = H[i] if maxv < count: maxv = count print(maxv)
p02598
s052203032
Wrong Answer
n, k = map(int, input().split()) a = list(map(int, input().split())) low = 0 top = max(a) + 1 while top - low > 1: mid = (top + low) // 2 cnt = 0 for i in range(n): if a[i] % mid == 0: cnt += a[i] // mid else: cnt += (a[i] // mid) + 1 if cnt <= k: top = mid else: low = mid print(l...
p03471
s245386953
Accepted
N,Y = map(int,input().split()) for a in range(N+1): for b in range(N+1): val = Y-10000*a-5000*b n = N-a-b if n>=0 and val >=0 and n*1000==val: print(a,b,N-a-b);exit() print('-1 -1 -1')
p04045
s187822920
Accepted
n,k=map(int,input().split()) d=list(input().split()) for num in range(n,100001): num=str(num) ok=True for c in num: if c in d: ok=False if ok: print(num) exit()
p02743
s860587369
Accepted
def mi():return map(str,input().split()) from decimal import * a,b,c=mi() getcontext().prec=1500 a=Decimal(a)**Decimal("0.50") b=Decimal(b)**Decimal("0.50") c=Decimal(c)**Decimal("0.50") if c>a+b: print("Yes") else: print("No")
p02796
s390500030
Wrong Answer
N = int(input()) S = [] for i in range(N): xi, li = map(int, input().split()) S.append([xi - li, xi + li]) S.sort() ans = 0 last = -1*float('Inf') for si in S: if si[0] >= last: ans += 1 last = si[1] print(ans)
p03493
s005591214
Accepted
s = input() print(s.count('1'))
p03681
s179883791
Wrong Answer
n, m = map(int, input().split()) MOD = 10**9+7 ans = 1 if abs(n-m) == 0: for i in range(1, n+1): ans = ans * i % MOD else: ans = ans ** 2 * 2 % MOD elif abs(n-m) == 1: cnt_n = 1 cnt_m = 1 for i in range(1, n+1): cnt_n = cnt_n * i % MOD for i in range(1, m+1): cnt_...
p02922
s961316696
Accepted
a,b = map(int,input().split()) ans = 0 n = 1 while n < b: n += a - 1 ans += 1 print(ans)
p02628
s872251267
Accepted
N, K = map(int, input().split()) A = sorted(map(int, input().split())) ans = 0 for i in range(K): ans = ans + A[i] print(ans)
p02873
s626943793
Wrong Answer
s = input() n = len(s)+1 L = [0]*(n) for i in range(n-1): if s[i]=='<': L[i+1] = max(L[i+1],L[i]+1) for i in range(n-2,0,-1): if s[i]=='>': L[i] = max(L[i],L[i+1]+1) print(sum(L))
p03324
s952959586
Accepted
d, n = map(int, input().split()) x = 100 ** d y = x cnt = 0 while cnt < n: if y % 100**(d+1) != 0: cnt += 1 y += x print(y-x)
p02707
s894467743
Accepted
N = (int)(input()) A = map(int, input().split()) Res = [0] * (N) for a in A: Res[a-1] += 1 for res in Res: print(res)
p02584
s761424843
Wrong Answer
x,k,d = map(int,input().split()) an = x if x < 0: x = -x if x-d*k >= 0: an = x-d*k else: for i in range(k): if x > 0: x -= d else: x += d if an > abs(x) or x==0: an = x else: if (k-i-1)%2 == 0: an ...
p04031
s700979702
Accepted
N = int(input()) A = list(map(int, input().split())) ans = float('inf') for target in range(-100, 101): cost = 0 for j, a in enumerate(A): cost += (target - a)**2 ans = min(ans, cost) print(ans)
p02801
s402366568
Wrong Answer
def next(a): print(a+1)
p02647
s408161496
Accepted
import numpy as np from numba import njit n, k = map(int, input().split()) a = np.array(list(map(int, input().split())), dtype=np.int64) @njit def loop1(a): b = np.zeros(n+1, dtype=np.int64) for i in range(n): l = max(0, i-a[i]) r = min(i+a[i]+1, n) b[l] += 1 if r <= n-1: b[r] -= 1 b = np.c...
p03210
s588991785
Wrong Answer
x=int(input());print('YNeos'[not(x==3 or x==5 or x==7)::2])
p02792
s676926149
Accepted
n = int(input()) t = [[0] * 10 for _ in range(10)] for i in range(1, n+1): s = str(i) t[int(s[0])][int(s[-1])] += 1 result = 0 for i in range(1, 10): for j in range(1, 10): result += t[i][j] * t[j][i] print(result)
p02994
s154635769
Accepted
N,L = map(int,input().split()) min = 10**4 sum = 0 for i in range(N) : t = i+L sum += t if abs(t) < abs(min) : min = t print(sum - min)
p02658
s515370398
Accepted
def main(): N = int(input()) A = list(map(int, input().split())) A.sort() p = 1 LIMIT = 10 ** 18 for a in A: p *= a if p > LIMIT: print(-1) return print(p) if __name__ == '__main__': main()
p03555
s689193289
Accepted
def main(): c_list = [list(input()) for _ in range(2)] if c_list[0][0] == c_list[1][2] and c_list[0][1] == c_list[1][1] and c_list[0][2] == c_list[1][0]: print("YES") else: print("NO") if __name__ == "__main__": main()
p02577
s293168242
Wrong Answer
n = list(input()) sum = 0 for i in range(len(n)): sum += int(n[i]) # print(sum) if sum % 9 == 0: print('YES') else: print('No')
p02727
s016468347
Accepted
s=sorted (x,y,*_),p,q,r=eval('map(int,input().split()),'*4) print(sum(s(s(p)[-x:]+s(q)[-y:]+s(r))[-x-y:]))
p03250
s943391434
Wrong Answer
A,B,C=map(int,input().split(' ')) print(max(A*10+B+C,A+B*10+C))
p02628
s723358598
Accepted
n, k = map(int, input().split()) lst = list(map(int, input().split())) lst.sort() ans = 0 for i in range(k): ans += lst[i] print(ans)
p04030
s720629120
Accepted
S = input() ret = "" for i in S: if i == "B": ret = ret[:-1] else: ret += i print(ret)
p02795
s258827824
Accepted
H = int(input()) W = int(input()) N = int(input()) answer = 0 if H >= W: answer = N // H if N % H != 0: answer += 1 else: answer = N // W if N % W != 0: answer += 1 print(answer)
p03435
s616844909
Accepted
c11, c12,c13=[int(i) for i in input().split()] c21, c22,c23=[int(i) for i in input().split()] c31, c32,c33=[int(i) for i in input().split()] ans=0 for a1 in range(c11+1): b1=c11-a1 b2=c12-a1 b3=c13-a1 a2=c21-b1 a3=c31-b1 if c22==a2+b2 and c23==a2+b3 and c32==a3+b2 and c33==a3+b3: p...
p03076
s189374270
Accepted
# Python3 (3.4.3) import sys input = sys.stdin.readline from math import ceil,floor # ------------------------------------------------------------- # function # ------------------------------------------------------------- # ------------------------------------------------------------- # main # ---------------------...
p02690
s211820648
Accepted
def main(): X = int(input()) for A in range(0, 201): for B in range(-201, 201): if pow(A, 5) - pow(B, 5) == X: print(A, B) return if __name__ == "__main__": main()
p02606
s713994194
Accepted
def main(): L,R,d = map(int,input().split()) cnt = 0 for i in range(L,R+1): if i % d == 0: cnt += 1 print(cnt) if __name__ == '__main__': main()
p02759
s501758936
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] def ruiseki(lst): return [0]+list(accumulate(lst)) mod=pow(10,9)+7 n=int(input()) print((n+1)//2...
p04005
s966089740
Accepted
import sys sys.setrecursionlimit(10 ** 8) input = sys.stdin.readline def main(): A, B, C = [int(x) for x in input().split()] if A % 2 == 0 or B % 2 == 0 or C % 2 ==0: print(0) else: print(min(A * B, B * C, C * A)) if __name__ == '__main__': main()
p03206
s431550806
Wrong Answer
d=input() if d==25: print("Christmas") elif d==24: print("Christmas Eve") elif d==23: print("Christmas Eve Eve") elif d==22: print("Christmas Eve Eve Eve")
p03821
s854083508
Accepted
N = int(input()) A = [0]*N B = [0]*N for i in range(N): a, b = map(int, input().split()) A[i] = a B[i] = b ans = 0 for i in range(N-1,-1,-1): A[i] += ans ans += B[i]*((A[i]+B[i]-1)//B[i]) - A[i] print(ans)
p03262
s062468343
Accepted
import math from functools import reduce N, X = map(int, input().split()) x = [abs(X-i) for i in map(int, input().split())] print(reduce(math.gcd, x))
p02699
s641658111
Wrong Answer
a = input().split() s=int(a[0]) w=int(a[1]) if s >=w: print("safe") else: print("unsafe")
p03797
s696229730
Accepted
n, m = map(int, input().split()) if n*2 <= m: t = n*2 + m print(t//4) else: print(m//2)
p04030
s275370782
Wrong Answer
s = input() ans = [] for i in range(len(s)): if s[i] == 'B' and ans: ans.pop() else: ans.append(s[i]) print(ans)
p02755
s616734137
Accepted
a,b = [int(x) for x in input().split()] res = -1 for i in range(20000): if i * 8 // 100 == a and i * 10 // 100 == b: res = i break print(res)
p02888
s338390225
Wrong Answer
# 3重ループではTLE # a < b < c & c < a + b import bisect N = int(input()) L = sorted(list(map(int,input().split()))) ans = 0 print(L) for i in range(N): for j in range(i+1,N): t = L[i] + L[j] idx = bisect.bisect_left(L,t) ans += max(0, idx-j-1) # c < a + b の範囲を総取り print(ans)
p03548
s112392093
Accepted
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...
p04043
s124398564
Wrong Answer
a,b,c=input().split() print(a,b,c)
p02818
s603874147
Accepted
a,b,k = map(int, input().split()) if a <= k: k -= a a = 0 if b <= k: b = 0 else: b -= k else: a -= k print(a,b)
p03565
s928496852
Accepted
SP = input() T = input() S = "" for i in range(len(SP)-len(T),-1,-1): cnt = 0 for j in range(len(T)): if SP[i+j] == T[j] or SP[i+j] == "?": cnt = cnt +1 if cnt == len(T): S = (SP[:i] + T + SP[i+len(T):]).replace("?","a") break ### if S == "": print("UNRESTORABLE") else: print(S)
p02773
s435844484
Accepted
def main(): import sys import collections input = sys.stdin.readline N = int(input()) S = [input() for i in range(N)] c = collections.Counter(S) max_num = c.most_common(1)[0][1] ss = [] for cc in c.most_common(): if cc[1] == max_num: ss.append(cc[0]) ss.sort()...
p02554
s673191964
Accepted
def main(): N = int(input()) a = 1 b = 1 c = 1 mod = (10 ** 9) + 7 for _ in range(N): a = (a * 10) % mod b = (b * 9) % mod c = (c * 8) % mod print((a - (2*b) + c) % mod ) main()
p02731
s564699086
Wrong Answer
l = int(input()) a = 0 for i in range(l): a = i*((l-i)/2)*((l-i)/2) if a < i*((l-i)/2)*((l-i)/2) else a print(float(a))
p03623
s570489002
Accepted
x,a,b=map(int,input().split()) if abs(x-a) <abs(x-b): print("A") else: print("B")
p03309
s967815121
Wrong Answer
def main(): N = int(input()) A = list(map(int, input().split())) t = sum(a - i for i, a in enumerate(A, 1)) t = t // N print(min(sum(abs(a - (t + i)) for i, a in enumerate(A, 1)), sum(abs(a - (t + i + 1)) for i, a in enumerate(A, 1)))) main()
p02952
s392693680
Accepted
n = int(input()) ans = 0 for i in range(1, n+1): if len(str(i)) % 2 == 1: ans += 1 print(ans)
p02761
s558732738
Wrong Answer
n, m = map(int, input().split()) sc = [list(map(int, input().split())) for _ in range(m)] ans = -1 for i in range(10**(n-1), 10**n): isAns = True for s, c in sc: isAns *= i//(10**(n-s)) % 10 == c if isAns: ans = i break print(ans)
p02595
s826841465
Accepted
n, m = map(int, input().split()) ans = 0 for i in range(n): x, y = map(int, input().split()) tmp = x ** 2 + y ** 2 if m ** 2 >= tmp: ans += 1 print(ans)
p02897
s298467673
Accepted
n = int(input()) if n%2 == 0 : print(1/2) else : print((n+1)/2/n)
p03041
s767763866
Wrong Answer
s = list('ABC') n = 3 k = 1 if s[k-1] == 'A': s[k-1] = 'a' elif s[k-1] == 'B': s[k-1] = 'b' else: s[k-1] = 'c' print (s)
p02761
s911951967
Wrong Answer
N,M = [int(i) for i in input().rstrip().split()] n = 1 if N > 1 else 0 C = [list(range(n,10))] + [list(range(10)) for i in range(N-1)] for m in range(M): s,c = [int(i) for i in input().rstrip().split()] s -= 1 if c in C[s]: C[s] = [c] else: print(-1) exit() print(C) C = [str...
p04005
s674796042
Accepted
A, B, C = map(int, input().split()) if A % 2 == 0 or B % 2 == 0 or C % 2 == 0: print(0) else: print(A * B * C // max(A, B, C))
p02665
s576758519
Accepted
import sys N = int(input()) A = list(map(int, input().split())) if N == 0: if A[0] == 1: print(1) else: print(-1) sys.exit() capacity = [1 - A[0]] for i in range(N): capacity += [2 * (capacity[-1] - A[i])] corr_flag = 1 if A[-1] > capacity[-1]: corr_flag = 0 curr = A[-1] ans = A[...
p02603
s468750575
Accepted
N = int(input()) A = list(map(int, input().split())) current_money = 1000 for i in range(N-1): stock = 0 if A[i] < A[i+1]: stock = current_money // A[i] current_money += (A[i+1] - A[i]) * stock print(current_money)
p03854
s695945288
Wrong Answer
S = input() s = reversed(S) T = '' for i in s: T += i if T in ['maerd', 'remaerd', 'esare', 'resare']: T = '' if len(T) >= 6: print('NO') break if len(T) == 0: print('YES')
p03387
s739405960
Wrong Answer
def Same_Integers(abc): ans = 0 abc.sort() count = abc[2]*3 - abc[0] - abc[1] - abc[2] if count % 2 == 0: ans = count / 2 else: ans = (count + 3) // 2 return ans def main(): abc = list(map(int , input().split())) print(Same_Integers(abc)) if __name__ == '__main__': ...
p03137
s623471376
Accepted
N,M = map(int,input().split()) A = list(map(int,input().split())) A.sort() B = [] for i in range(M-1): B.append(abs(A[i+1]-A[i])) B.sort() #print(A) #print(B) if N >=M: ans = 0 if N == 1: ans = sum(B) else: ans = sum(B[:-(N-1)]) print(ans) #dp[i][j]: i個目までにj
p02768
s897644497
Accepted
def combinations(n,k,mod): x,y = 1,1 for i in range(k): x = (x*(n-i))%mod y = (y*(i+1))%mod return (x*pow(y,mod-2,mod))%mod div = 10**9+7 n,a,b = map(int,input().split()) cn = pow(2,n,div)-1 ca = combinations(n,a,div) cb = combinations(n,b,div) print((cn-ca-cb)%div)
p02700
s073707985
Accepted
a, b, c, d = map(int, input().split()) x = -(-a // d) y = -(-c // b) if x == y: print('Yes') if x < y: print('No') if x > y: print('Yes')
p03486
s732376749
Wrong Answer
s = input() s1 = sorted(s) s2 = input() ans = 0 ans2 = 0 for i in s2: if s == s2: break if s1[0] <= i: ans = ans + 1 for k in range(0,len(s1)): if s1[k] <= i: ans2 = ans2 + 1 if ans != 0 and ans2 != 0: print("Yes") else: print("No")
p03657
s674464777
Accepted
A,B = map(int,input().split()) if (A+B)%3==0 or A%3==0 or B%3==0: print("Possible") else: print("Impossible")
p03493
s651020896
Accepted
n=input() print(n.count("1"))
p02726
s938597904
Accepted
import math n, x, y = map(int,input().split()) dif = y-x ans = [0]*(n-1) for i in range(1,n): for j in range(i+1,n+1): dist = abs(x-i)+abs(y-j)+1 ans[min(dist,(j-i))-1] += 1 for i in ans: print(i)
p03817
s656848439
Wrong Answer
n = int(input()) n-=1 ans = (n//11)*2 if(n%11<=4): ans+=1 else: ans+=2 print(ans)
p02747
s097804241
Accepted
S = input() ans = S.replace("hi", "") if ans == "": print("Yes") else: print("No")
p03427
s753735149
Accepted
def main(): n = int(input()) l = len(str(n)) v = int(str(n)[0]) + 9 * (l - 1) if str(n)[1:] == '9' * (l - 1): print(v) else: print(v-1) if __name__ == '__main__': main()
p02909
s750264236
Wrong Answer
S = input() if S == 'Sunny': print('cloudy') elif S == 'cloudy': print('Rainy') elif S == 'Rainy': print('Sunny')
p02795
s186504389
Accepted
import sys, math def input(): return sys.stdin.readline()[:-1] from itertools import permutations, combinations from collections import defaultdict, Counter from math import factorial sys.setrecursionlimit(10**7) H = int(input()) W = int(input()) N = int(input()) if N%max(H, W)==0: print(N//max(H, W)) else: ...
p03730
s613596532
Wrong Answer
#! env python # -*- coding: utf-8 -*- import os import sys # ac_py.main # Date: 2020/06/14 # Filename: main # Author: acto_mini def main(): A, B, C = map(int, input().split()) if A % 2 != C % 2: print("NO") exit() for i in range(1, B*A+1): if (i * A) % B == C: prin...