problem_id stringclasses 428 values | submission_id stringlengths 10 10 | status stringclasses 2 values | code stringlengths 5 816 |
|---|---|---|---|
p02600 | s178505811 | Accepted | N = int(input())
rank = 0
if N >= 400 and 599 >= N:
rank = 8
elif N >= 600 and 799 >= N:
rank = 7
elif N >= 800 and 999 >= N:
rank = 6
elif N >= 1000 and 1199 >= N:
rank = 5
elif N >= 1200 and 1399 >= N:
rank = 4
elif N >= 1400 and 1599 >= N:
rank = 3
elif N >= 1600 and 1799 >= N:
rank = 2
elif N>= 1800 and 1999 >= N:
rank = 1
print(rank) |
p02555 | s100769792 | Accepted | s = int(input())
mod = 10**9 +7
dp = [0]*(s+1)
dp[0] = 1
for i in range(1,s+1):
for j in range(0,(i-3)+1):
dp[i] += dp[j]
dp[i] %= mod
print(dp[s])
|
p03944 | s440595801 | Wrong Answer | W,H,N = [int(i) for i in input().split()]
A = [list(map(int, input().split())) for i in range(N)]
x1,y1 = 0,0
x2 = W
y2 = H
for i in range(N):
if A[i][2] == 1:
x1 = A[i][0]
elif A[i][2] == 2:
x2 = A[i][0]
elif A[i][2] == 3:
y1 = A[i][1]
elif A[i][2] == 4:
y2 = A[i][1]
print((x2-x1)*(y2-y1))
|
p02916 | s696027700 | Accepted | N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.insert(0,"X")
B.insert(0,"X")
C.insert(0,"X")
stf_c = 0
j = 100
for i in range(1,N+1):
if A[i] == j+1:
stf_c += (B[A[i]]+C[j])
j = A[i]
else:
stf_c += B[A[i]]
j = A[i]
print(stf_c) |
p02725 | s791752114 | Wrong Answer | n, k = map(int, input().split())
a = list(map(int, input().split()))
a.append(n)
d=[]
for i in range(len(a)-1):
d.append([i,a[i+1]-a[i]])
l=sorted(d,key=lambda x:x[1])
o=l[-1][0]
g=a[o]+n-a[o+1]
print(g) |
p02854 | s460608357 | Accepted | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)
import itertools
import bisect
n = int(readline())
a = tuple(map(int, readline().split()))
cumsum = tuple(itertools.accumulate(a))
index = bisect.bisect(cumsum, sum(a) // 2)
ans = min(cumsum[n - 1] - cumsum[index - 1] * 2, cumsum[index] * 2 - cumsum[n - 1])
print(ans)
|
p03524 | s623697249 | Accepted | s = input()
ca,cb,cc = 0,0,0
for i in range(len(s)):
if s[i] == "a":
ca += 1
elif s[i] == "b":
cb += 1
else:
cc += 1
mx = max(max(ca,cb),cc)
mn = min(min(ca,cb),cc)
if mx - mn >= 2:
print("NO")
else:
print("YES") |
p03289 | s633012649 | Accepted | # B - AcCepted
S = list(str(input()))
ans = 'AC'
if S[0] != 'A':
ans = 'WA'
else:
S[0] = 'a'
cnt = 0
for i in range(2, len(S)-1):
if S[i] == 'C':
cnt += 1
S[i] = 'c'
if cnt != 1:
ans = 'WA'
for s in S:
if s.islower() == False:
ans = 'WA'
break
print(ans)
|
p02705 | s299270885 | Accepted | import numpy as np
R = int(input())
print(2*R*np.pi) |
p02882 | s873034592 | Wrong Answer | from math import atan,pi
a,b,x=map(int,input().split())
#台形
h=x/(a**2)
c=(b-h)*2
theta=atan(c/a)/2/pi*360
print(theta)
|
p03474 | s433271564 | Wrong Answer | import re
a, b = map(int, input().split())
s = input()
if s[a] == "-":
if len(s[0:a]) == a and len(s[a+1::]) == b:
if s[0:a] in r'[^0-9]' or s[a+1::] in r'[^0-9]':
print("No")
else:
print("Yes")
else:
print("No")
|
p04034 | s101790894 | Accepted | N, M = map(int, input().split())
s = [0]*N
t = [1]*N
s[0] = 1
res = 1
for _ in range(M):
x, y = map(int, input().split())
x-=1
y-=1
t[x] -= 1
t[y] += 1
if s[x] == 1:
if t[x]==0:
s[x] = 0
if s[y]==1:
res -= 1
else:
if s[y]!=1:
res += 1
s[y] = 1
print(res) |
p03095 | s826859046 | Wrong Answer | n = int(input())
s = input()
li_s = list(s)
import collections
c = collections.Counter(li_s)
cci = c.items()
tmp = 1
for cc in cci:
#print(cc[1])
tmp *= (cc[1]+1)
if tmp >1:
print(tmp-1)
else:
print(tmp) |
p02814 | s344442923 | Accepted | from fractions import gcd
from functools import reduce
n, m = map(int, input().split())
a = [int(i) for i in input().split()]
c = 1
while a[0] % 2 == 0:
a[0] //= 2
c *= 2
a[0] *= c
for ai in a[1:]:
if ai % c or (ai // c) % 2 == 0:
print(0)
break
else:
lcm = reduce(lambda x, y: x * y // gcd(x, y), a) // 2
print(m // lcm - m // (2 * lcm)) |
p02988 | s899824122 | Wrong Answer | # Vicfred
# https://atcoder.jp/contests/abc132/tasks/abc132_b
# implementation
n = int(input())
p = list(map(int,input().split()))
answer = 0
for i in range(1, n-1):
if p[i-1] < p[i] < p[1+1] or p[i-1] > p[i] > p[i+1]:
answer += 1
print(answer)
|
p02744 | s597204750 | Accepted | N = int(input())
S = "abcdefghijklmn"
Q = [(1,1,"a")]
A = []
while Q:
q = Q.pop(-1)
if q[0]==N:
A.append(q[2])
continue
for i in range(q[1]+1):
Q.append((q[0]+1,max(q[1],i+1),q[2]+S[i]))
for a in sorted(A):print(a) |
p02802 | s209121748 | Wrong Answer | N, M = map(int, input().split())
isACs = [0] * N
numPenalty = 0
for _ in range(M):
p, res = input().split()
p = int(p) - 1
if res == 'AC':
isACs[p] = 1
else:
if not isACs[p]:
numPenalty += 1
numAC = sum(isACs)
print(numAC, numPenalty)
|
p02613 | s357278769 | Accepted | N = int(input())
arr = []
for _ in range(N):
arr.append(input())
print(f'AC x {arr.count("AC")}')
print(f'WA x {arr.count("WA")}')
print(f'TLE x {arr.count("TLE")}')
print(f'RE x {arr.count("RE")}')
|
p02691 | s997660835 | Accepted | N = int(input())
A = list(map(int,input().split()))
L_list = {}
R_list = {}
cnt = 0
for i in range(N):
L = i+1 + A[i]
R = i+1 - A[i]
if L in R_list.keys():
cnt += R_list[L]
if R in L_list.keys():
cnt += L_list[R]
if L in L_list.keys():
L_list[L] += 1
else:
L_list[L] = 1
if R in R_list.keys():
R_list[R] += 1
else:
R_list[R] = 1
print(cnt) |
p02678 | s538670302 | Accepted | n,m=list(map(int,input().split()))
road_input=[]
for i in range(m):
road_input.append(list(map(int,input().split())))
#隣接リスト
road=[[] for i in range(n+1)]
for i in range(m):
road[road_input[i][0]].append(road_input[i][1])
road[road_input[i][1]].append(road_input[i][0])
from collections import deque
q=deque([1])
ans=[-1 for i in range(n)]
while len(q)>0:
p=q.popleft()
for i in road[p]:
if ans[i-1]== -1:
ans[i-1]=p
q.append(i)
print("Yes")
for j in range(1,n):
print(ans[j])
|
p02577 | s447444378 | Wrong Answer | N = input()
ret = 0
for c in N:
ret += ret + int(c) % 9
if ret % 9 == 0:
print('Yes')
else:
print('No') |
p04044 | s207314742 | Accepted | n, l = map(int, input().split())
s = []
for i in range(n):
s.append(input())
s.sort()
ans = ""
for i in s:
ans += i
print(ans)
|
p03639 | s805919956 | Wrong Answer | #n=int(input())
#l=list(map(int,input().split()))
n=3
l=[1, 4, 1]
c_4=0
even=0
odd=0
for i in l:
if i%4==0:
c_4+=1
elif i%2==0:
even+=1
else:
odd+=1
if even==0 and odd-1 <= c_4:
ans="Yes"
else:
ans="No"
if even>0 and odd <= c_4:
ans="Yes"
print(ans) |
p02784 | s049050298 | Wrong Answer | hp, atk = input().split()
hp = int(hp)
atk = int(atk)
numlist = list((input().split()))
numlist = list(map(int, numlist))
numlist = sorted(numlist, reverse=True)
print(numlist)
for i in range(atk):
value = 0
value = value + numlist[i]
if value > hp:
print("Yes")
break
else:
print("No")
break |
p02795 | s328665147 | Accepted | H = int(input())
W = int(input())
N = int(input())
i = 0
j = 0
if H > W:
while i < N:
j = j + 1
i = H + i
elif H < W:
while i < N:
j = j + 1
i = W + i
else:
while i < N:
j = j + 1
i = H + i
print(j)
|
p03146 | s198463279 | Accepted | s = int(input())
ans = [s]
while True:
if s % 2 == 0:
s //= 2
else:
s = 3 * s + 1
if ans.count(s) != 0:
ans.append(s)
break
else:
ans.append(s)
print(len(ans))
|
p02633 | s257415434 | Wrong Answer | x = int(input())
y = 360 / x
print(int(y)) |
p03162 | s538928614 | Accepted | def vacation(costs):
total = [0, 0, 0]
next_total = [0, 0, 0]
i, j, k = 0, 1, 2
for c in costs:
for _ in range(3):
next_total[i] = c[i] + max(total[j], total[k])
i, j, k = j, k, i
total, next_total = next_total, total
return max(total)
def main():
n = int(input())
costs = [None] * n
for idx in range(n):
costs[idx] = [int(x) for x in input().split()]
return vacation(costs)
print(main())
|
p03282 | s057800351 | Accepted | s = input()
k = int(input())
limit = min(100, k)
ans = 1
for i in range(limit):
if s[i] != '1':
ans = s[i]
break
print(ans) |
p03998 | s194749026 | Accepted | from collections import deque
sa=deque(list(input()))
sb=deque(list(input()))
sc=deque(list(input()))
s=sa.popleft()
while True:
if s=='a':
if len(sa)>0:
s=sa.popleft()
else:
print('A')
exit()
elif s=='b':
if len(sb)>0:
s=sb.popleft()
else:
print('B')
exit()
elif s=='c':
if len(sc)>0:
s=sc.popleft()
else:
print('C')
exit()
|
p02695 | s480874286 | Wrong Answer | from itertools import combinations_with_replacement
N, M, Q = [int(n) for n in input().split()]
X = [[int(n) for n in input().split()] for _ in range(Q)]
ans = []
for A in combinations_with_replacement(range(1, M+1), N):
t = 0
for x in X:
if A[x[1]-1]-A[x[0]-1] == x[2]:
t += x[3]
print(A, t)
ans.append(t)
print(max(ans))
|
p02882 | s445290931 | Accepted | import math
a,b,x = map(int, input().split())
V = (a**2)*b
if x < V/2:
t = (2*x)/(a*b**2)
print(90 - math.degrees(math.atan(t)))
else:
t = (2*b/a) - (2*x/a**3)
print(math.degrees(math.atan(t))) |
p03105 | s927530535 | Accepted | a,b,c = map(int,input().split())
print(min(b//a,c)) |
p03136 | s414044258 | Wrong Answer | n = int(input())
l = list(map(int,input().split(" ")))
print(sum(l))
m=max(l)
if m - (sum(l)-m):
print("Yes")
else:
print("No") |
p03103 | s799201239 | Wrong Answer | n, m = map(int, input().split())
L = dict(map(int, input().split()) for _ in range(n))
ans = 0
L = sorted(L.items())
for i in L:
if i[1] >= m:
ans += i[0] * m
break
else:
m -= i[1]
ans += i[0] * i[1]
print(ans)
|
p03327 | s665540500 | Accepted | n=int(input())
if n - 999 > 0:
print('ABD')
else:
print('ABC') |
p02791 | s585454317 | Accepted | #!/usr/bin/env python3
import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
n = I()
p = LI()
tmp = inf
ans = 0
for i in range(n):
if tmp > p[i]:
ans += 1
tmp = p[i]
print(ans)
|
p02717 | s990899766 | Accepted | A, B, C = map(int, input().split())
print(C, A, B) |
p03785 | s514816972 | Wrong Answer | N, C, K = map(int, input().split())
T = sorted([int(input()) for _ in range(N)])
first = 0
bus = 1
nowpassenger = 0
for i in range(N):
watingtime = T[i] - T[first]
if watingtime > K:
bus += 1
first = i
nowpassenger = 0
elif nowpassenger >= C:
bus += 1
first = i
nowpassenger = 0
else:
nowpassenger += 1
print(bus)
|
p02622 | s924659588 | Wrong Answer | #https://atcoder.jp/contests/abc172/tasks/abc172_b
'''
<考え>
sとtを一文字ずつ比較し、異なる文字の数を出力
(s,tの長さが等しいと条件にある)
'''
#入力
s = str(input())
t = str(input())
#変数
count = 0
#必要な値を計算
l = len(s)
#処理
for i in range(l):
print(s[i], t[i])
if (s[i] != t[i]):
count += 1
#出力
print(count) |
p02847 | s261436220 | Accepted | s=input()
if s=='SUN':
print(7)
elif s=='MON':
print(6)
elif s=='TUE':
print(5)
elif s=='WED':
print(4)
elif s=='THU':
print(3)
elif s=='FRI':
print(2)
else :
print(1)
|
p03745 | s321842667 | Accepted | n=int(input())
a=list(map(int,input().split()))
ans=1
temp=0
for i in range(1,n):
if a[i-1]<a[i] and temp==0:
temp=1
elif a[i-1]>a[i] and temp==0:
temp=2
elif a[i-1]>a[i] and temp==1:
temp=0
ans=ans+1
elif a[i-1]<a[i] and temp==2:
temp=0
ans=ans+1
print(ans) |
p02708 | s276367744 | Accepted | def main():
n, k = map(int, input().split())
sum_min = 0
sum_max = 0
ans = 0
m = 10**9 + 7
for i in range(k-1):
sum_min += i
sum_max += n-i
for i in range(k-1, n+1):
sum_min += i
sum_max += n-i
ans += sum_max - sum_min + 1
ans %= m
print(ans)
if __name__ == "__main__":
main() |
p02771 | s483371544 | Wrong Answer | i=input().split()
a=i[0]
b=i[1]
c=i[2]
if(a==b and b==c):
print("YES")
else:
print("NO") |
p02881 | s132435092 | Accepted | from math import sqrt
N=int(input())
for i in range(int(sqrt(N)),0,-1):
j = N/i
if j == int(j):
print(int(i+j-2))
break |
p03160 | s949964608 | Wrong Answer | n = int(input())
H = [0]+list(map(int,input().split()))
if n >= 3:
dp = [0]*(n+1)
dp[2] = abs(H[2]-H[1])
dp[3] = min(abs(H[3]-H[2]), abs(H[3]-H[1]))
for i in range(4,n+1):
dp[i] = min(abs(H[i]-H[i-1])+dp[i-1], abs(H[i]-H[i-2])+dp[i-2])
print(dp[n])
else:
print(abs(H[2]-H[1])) |
p03329 | s599868653 | Accepted | import sys
n = int(input())
dp=[sys.maxsize]*(n+1)
def beki(arg):
res=0
t=1
while t < n:
t=t*arg
res+=1
return res
dp[0]=0
a = beki(9)
b = beki(6)
for i in range(n):
dp[i+1]=min(dp[i+1],dp[i]+1)
for j in range(1,a+1):
if i+9**j > n:
break
dp[i+9**j]=min(dp[i+9**j],dp[i]+1)
for j in range(1,b+1):
if i+6**j > n:
break
dp[i+6**j]=min(dp[i+6**j],dp[i]+1)
print(dp[n]) |
p02727 | s145863534 | Accepted | x,y,a,b,c=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
p.sort()
q.sort()
L=p[a-x:a]+q[b-y:b]+r
L.sort()
L.reverse()
print(sum(L[0:x+y])) |
p03607 | s512820383 | Wrong Answer | import numpy as np
n=int(input())
l=[]
for i in range(n):
l.append(int(input()))
l.sort()
ans=0
if l[0]!=l[1]:
ans+=1
for i in range(1,n-1):
if l[i]!=l[i-1] and l[i]!=l[i+1]:
ans+=1
if l[n-1]!=l[n-2]:
ans+=1
print(ans)
|
p02730 | s403568936 | Accepted | S=input()
N=len(S)
M=(N-1)//2
def iskaibun(T):
K=len(T)
for i in range(K):
if T[i]==T[-i-1]:
pass
else:
return False
return True
if iskaibun(S) and iskaibun(S[:M]) and iskaibun(S[M+1:]):
print("Yes")
else:
print("No")
|
p03000 | s185997362 | Accepted | n, x = map(int, input().split())
Ls = list(map(int, input().split()))
ans = 1
temp = 0
for l in Ls:
temp += l
if temp <= x:
ans += 1
print(ans) |
p02787 | s966446157 | Accepted | import sys
input = sys.stdin.readline
def main():
H, N = map(int, input().split())
inf = float('inf')
AB = [tuple(map(int, input().split())) for _ in range(N)]
dp = [inf] * (H+10**4+1)
dp[0] = 0
for h in range(H+1):
for a, b in AB:
dp[h+a] = min(dp[h+a], dp[h]+b)
print(min(dp[H:]))
if __name__ == '__main__':
main() |
p03001 | s748941026 | Wrong Answer | W, H, x, y = map(int, input().split())
S = W*H/2
if W//2 == x and H//2 == y:
print(S, 1)
else:
print(S, 0) |
p02996 | s461186368 | Wrong Answer | n = int(input())
tsk = []
for i in range(n):
a,b = map(int,input().split())
tsk.append([a,b])
tsk.sort(key = lambda x:x[1])
t = 0
ans = 'Yes'
for i in range(n):
l = tsk[i]
t += l[0]
if t<=l[1]:
ans = 'No'
break
print(ans) |
p03324 | s984587299 | Accepted | #! python3
def main():
d, n = map(int, input().split())
dd = 100**d
if n%100 != 0:
ans = n*dd
else:
ans = (1+n)*dd
print(ans)
main() |
p03481 | s796563570 | Accepted | def digit(N,n):#nは正の整数、N進法での桁数、許容は10^1000
if n<N:
return 1
else:
return 1+digit(N,n//N)
X,Y=map(int,input().split())
m=Y//X
print(digit(2,m))
|
p02718 | s641937136 | Accepted | n, m = map(int, input().split())
a = input().split()
a = [int(_) for _ in a]
total_amount = sum(a)
threshold = 1/(4*m) * total_amount
clear_a = [_ for _ in a if _ >= threshold]
if len(clear_a) >= m:
print('Yes')
else:
print('No') |
p02723 | s671874337 | Wrong Answer | ch=input()
if ch[2]==ch[3] and ch[4]==ch[5]:
print("Yes")
print("No") |
p04034 | s236853683 | Accepted | n, m = map(int, input().split())
cl = [1 for _ in range(n)]
rl = [1]+[0 for _ in range(n-1)]
for i in range(m):
x_n, y_n = map(int, input().split())
cl[x_n-1] -= 1
cl[y_n-1] += 1
if rl[x_n-1] == 1 and cl[x_n-1]>0:
rl[y_n-1] = 1
elif rl[x_n-1] == 1 and cl[x_n-1] == 0:
rl[x_n-1] = 0
rl[y_n-1] = 1
elif rl[x_n-1] == 0:
pass
print(sum(rl))
|
p02820 | s031606887 | Accepted | n,k = map(int, raw_input().split(' '))
r,s,p = map(int, raw_input().split(' '))
seq = raw_input()
import collections
q,i = collections.deque(), 0
while(i < len(seq)):
u = q.popleft() if len(q) == k else [0,0,0]
q.append( [ max(u[1], u[2]) + (r if seq[i] == 's' else 0) ,max(u[0], u[2]) + (s if seq[i] == 'p' else 0) ,max(u[0], u[1]) + (p if seq[i] == 'r' else 0)])
i +=1
print sum([max(cc) for cc in q] or [0])
|
p03494 | s789305749 | Wrong Answer | N = int(input().rstrip())
INPUT = list(map(int, input().rstrip().split(' ')))
for count in range(10):
for i in range(N):
p, mod = divmod(INPUT[i], 2)
if mod == 0:
INPUT[i] = p
else:
break
else:
continue
print(count)
break
|
p03210 | s119869281 | Accepted | N = input()
b = N in ["3","5","7"]
if b:
print("YES")
else:
print("NO")
|
p02744 | s718698910 | Accepted | N = int(input())
D = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"]
Ans = [["a"]]
for i in range(1, 10):
before = Ans[i - 1]
# print(before)
next = []
for j in before:
L = set(list(j))
# print(L)
for k in range(len(L) + 1):
# print(j)
next.append(j + D[k])
Ans.append(next)
# print(Ans)
print(*Ans[N - 1], sep="\n")
|
p02602 | s010403270 | Accepted | n,k = map(int, input().split())
a = list(map(int, input().split()))
nums = [0]*n
nums[k-1] = sum(a[:k])
for i in range(k,n):
nums[i] = nums[i-1] + a[i] - a[i-k]
for i in range(k,n):
if nums[i-1] < nums[i]: print("Yes")
else: print("No") |
p03645 | s145016859 | Accepted | N, M = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(M)]
li = []
for ab in AB:
if ab[0] == 1:
li.append(ab[1])
if ab[1] == N:
li.append(ab[0])
se = set(li)
if len(se) != len(li):
print('POSSIBLE')
else:
print('IMPOSSIBLE') |
p02712 | s233975887 | Accepted | n = int(input())
s1 = set()
s2 = set()
a = 1
b = 1
while a <= n:
if a % 3 == 0:
s1.add(a)
a += 1
while b <= n:
if b % 5 == 0:
s2.add(b)
b += 1
s3 = set(range(1,n + 1))
s12 = s1 | s2
s4 = s3 - s12
c = 0
for x in s4:
c += x
print(c)
|
p02701 | s945863123 | Accepted | N = int(input())
S = [str(input()) for i in range(N)]
SS = set(S)
print(len(SS)) |
p02988 | s456267671 | Accepted | n = input()
p = [int(z) for z in input().split()]
c=0
for i in range(1,len(p)-1):
if (p[i-1]<=p[i]<=p[i+1] or p[i+1]<=p[i]<=p[i-1]):
c+=1
print(c)
|
p02720 | s319239507 | Wrong Answer | K = 12
table = [1, 2, 3, 4, 5, 6, 7, 8, 9]
for i in table:
if len(table) > K:
break
x = i % 10
for j in range(max(0, x - 1), min(x + 2, 10)):
table.append(i * 10 + j)
print(table[K-1]) |
p02756 | s535759174 | Accepted | from collections import deque
S = deque(list(input()))
Q = int(input())
f = 0
for _ in range(Q):
a, *b = input().split()
f += int(a)
if a == "2":
if (int(b[0]) + f) % 2 == 1 :
S.appendleft(b[1])
else:
S.append(b[1])
D = list(S)
print ("".join(D) if f % 2 == 0 else "".join(D[::-1])) |
p03469 | s335912892 | Accepted | date=input()
date_changed = date[:3] + '8' + date[4:]
print(date_changed) |
p02881 | s162880377 | Accepted | import math
n = int(input())
m = n-1
for k in range(2, int(math.sqrt(n)) + 1):
if n % k == 0:
m = k + n//k - 2
print(m) |
p03309 | s461777053 | Accepted | import numpy as np
n = int(input())
a = np.array([int(i) for i in input().split()])
b = np.arange(1,n+1, dtype=int)
a -= b
a -= int(np.median(a))
print(sum(np.abs(a))) |
p02607 | s069313833 | Accepted | n = int(input())
a = list(map(int, input().split()))
ans = 0
for num in range(1, n+1, 2):
if a[num-1] % 2 != 0:
ans += 1
print(ans) |
p03035 | s447038752 | Accepted | a, b = map(int, input().split())
if a >= 13 :
print(b)
elif a >= 6 :
print(b//2)
else :
print(0) |
p03331 | s876732672 | Wrong Answer | N = int(input())
n = 1
ans = 10**5
def calucurate(M):
n = 0
while M > 0:
n += M%10
M //= 10
return n
while n < N:
t = N - n
m = calucurate(t) + calucurate(n)
ans = min(ans,m)
n += 1 |
p03665 | s181925044 | Accepted | n, p = map(int, input().split())
A = list(map(int, input().split()))
cnt_even = 0
for i in range(n):
if A[i] % 2 == 0:
cnt_even += 1
if cnt_even == n:
if p == 0:
print(2 ** n)
else:
print(0)
else:
print(2 ** (n - 1)) |
p03557 | s239602491 | Accepted | import bisect
N = int(input())
A = sorted(list(map(int,input().split())))
B = sorted(list(map(int,input().split())))
C = sorted(list(map(int,input().split())))
print(sum(bisect.bisect_left(A, i)*(N-bisect.bisect_right(C, i)) for i in B)) |
p02621 | s641102640 | Accepted | a = int(input())
print(a + a**2 + a**3) |
p02548 | s551513913 | Accepted | #標準出力からの読み込み
n = int(input())
#判定ロジック
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
output = 0
divisor = num_divisors_table(n-1)
output = sum(divisor)
print(output)
|
p03359 | s531279262 | Accepted | a,b=map(int,input().split())
if a<=b:
print(a)
else:
print(a-1) |
p02571 | s332313036 | Wrong Answer | s = input()
t = input()
num = 0
for i in range(len(s) - len(t) + 1):
# a = s[i:]
# print(a)
cnt = 0
for j in range(len(t)):
if i + j >= len(t):
continue
if t[j] == s[i + j]:
cnt += 1
num = max(num, cnt)
print(len(t) - num)
|
p03767 | s610760877 | Wrong Answer | n = int(input()); a = list(map(int, input().split()))
a.sort(); x = 0
for i in range(n, 2*n): x += a[i]
print(x) |
p03472 | s734711775 | Wrong Answer | N, H = map(int, input().split())
ls = []
for i in range(N):
a, b = map(int, input().split())
ls += [(a,-b)]
ls.sort(key=lambda x:x[0])
a = ls[-1][0]
ls.sort(key=lambda x:x[1])
ans = 0
for i in range(N-1):
if ls[i][1]>=-a:
break
H += ls[i][1]
ans += 1
if H<=0:
print(ans)
break
if H>0:
n = H//a if H%a==0 else H//a+1
ans += n
print(ans) |
p03474 | s466953733 | Accepted | a, b = map(int, input().split())
n = input()
s1 = n[:a]
s2 = n[a]
s3 = n[a+1:]
if s1.isdigit() and s2=='-' and s3.isdigit():
print('Yes' , flush=True)
else:
print('No' , flush=True)
|
p03455 | s358637176 | Accepted | import sys
(a,b)=map(int,input().split())
if a % 2 == 0 or b % 2 == 0:
print("Even")
else:
print("Odd")
|
p04031 | s151912570 | Accepted | n = int(input())
a = list(map(int,input().split()))
mn = 10**9
for i in range(-100,101):
x = 0
for j in a:
x += (j-i)**2
mn = min(mn,x)
print(mn) |
p03377 | s819294524 | Wrong Answer | a,b,x = map(int,input().split())
print("YES" if a + b > x and a < x else "NO") |
p03486 | s349375406 | Wrong Answer | s = list(input())
t = list(input())
s.sort()
t.sort(reverse=True)
ans = 'Yes'
n = min(len(s), len(t))
if s[:n] == t[:n]:
if len(s) > len(t):
ans = 'No'
else:
for sc, tc in zip(s, t):
if sc == tc:
continue
if sc > tc:
ans = 'No'
else:
ans = 'Yes'
break
print(ans) |
p02690 | s041810531 | Accepted | X = int(input())
for i in range(-120,120):
for j in range(-120,120):
if i**5 - j**5 == X:
print(i,j)
exit() |
p02548 | s274265698 | Accepted | n = int(input())
lim = n
count = 0
for b in range(1,lim):
add = int((n-1)/b)
count += add
print(count) |
p02792 | s619998503 | Wrong Answer | N=int(input())
A=[[0 for n in range(9)] for n in range(9)]
for n in range(N):
head=int(str(n)[0])
tail=n%10
if head!=0 and tail!=0:
A[head-1][tail-1]+=1
count=0
for i in range(9):
for j in range(9):
count+=A[i][j]*A[j][i]
print(count) |
p02612 | s149408555 | Wrong Answer | N = int(input())
tmp = N // 1000
answer = (tmp+1)*1000 -N
print(int(answer)) |
p03698 | s334475941 | Wrong Answer | s = input()
for i in s:
if s.count(i) != 1:
print('No')
exit
print('Yes') |
p03061 | s618248576 | Accepted | n=int(input())
al=list(map(int,input().split()))
import fractions
ans=0
left=[0]
for i in range(1,n):
ans=fractions.gcd(ans,al[i-1])
left.append(ans)
#print(left)
right=[0 for i in range(n+1)]
for i in range(1,n+1):
right[n-i]=fractions.gcd(right[n-i+1],al[n-i])
#print(right)
ans=0
for i in range(n):
ans=max(ans,(fractions.gcd(left[i],right[i+1])))
print(ans)
|
p02606 | s100089358 | Accepted | l,r,d = map(int,input().split(" "))
x = r//d - (l-1)//d
print(x) |
p02759 | s166984086 | Wrong Answer | a = int(input())
print((a+1)/2) |
p03324 | s206158015 | Wrong Answer | def main():
import sys
input = sys.stdin.readline
D, N = map(int, input().split())
if N != 100:
print(N, end="")
for i in range(D):
print("00", end="")
print("")
else:
print(100 ** (D+1) + 1)
if __name__ == '__main__':
main() |
p03086 | s996048339 | Wrong Answer | S = input()
T = "ACGT"
ans = 0
cnt = 0
for s in S:
if s in T:
cnt += 1
else:
if cnt > ans:
ans = cnt
cnt = 0
print(ans) |
p02789 | s352371345 | Accepted | N,M=map(int, input().split())
if N==M:
print('Yes')
else:
print('No') |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.