problem_id stringclasses 428
values | submission_id stringlengths 10 10 | status stringclasses 2
values | code stringlengths 5 816 |
|---|---|---|---|
p02615 | s545469829 | Accepted | # coding: utf-8
# Your code here!
n = int(input())
x = list(map(int,input().split()))
x.sort(reverse=True)
count = 0
for i in range(n-1):
count += x[int((i+1)/2)]
print(count) |
p03434 | s138204933 | Accepted | n = int(input())
a = list(map(int, input().split()))
a.sort()
a.reverse()
# slice操作 --> [start:stop:step]
# 奇数番目の要素の和 - 偶数番目の要素の和
print(sum(a[::2]) - sum(a[1::2])) |
p03827 | s875392924 | Accepted |
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def main():
mod=10**9+7
x=0
N=I()
S=input()
ans=0
for i in range(N):
if S[i]=="I":
x+=1
else:
x-=1
ans=max(ans,x)
print(ans)
main()
|
p04019 | s329525911 | Wrong Answer | S = list(input())
print("Yes" if "S" in S == "N" and "E" in S == "W" in S else "No") |
p02787 | s404904411 | Accepted | import sys
f=lambda:map(int,sys.stdin.readline().split())
h,n=f()
INF=10**9
dp=[[INF]*(h+1) for _ in range(n+1)]
dp[0][0]=0
for i in range(n):
a,b=f()
for j in range(h+1):
dp[i+1][j]=min(dp[i][j],dp[i+1][max(j-a,0)]+b)
print(dp[n][h]) |
p03208 | s281519572 | Accepted | N, K = map(int, input().split())
h = [0] * N
for i in range(N):
h[i] = int(input())
h = sorted(h, reverse=True)
ans = float("inf")
for i in range(N - K + 1):
ans = min(ans, h[i] - h[i + K - 1])
print(ans) |
p03030 | s638430102 | Accepted | n = int(input())
d = list(list(input().split())+[i+1] for i in range(n))
a = sorted(d, key=lambda x:(x[0],-int(x[1])))
for v in a:
print(v[2]) |
p02690 | s883763999 | Accepted | #!/usr/bin/env python3
import sys
input = sys.stdin.readline
def ST():
return input().rstrip()
def I():
return int(input())
def MI():
return map(int, input().split())
def LI():
return list(MI())
X = I()
for a in range(-118, 120):
for b in range(-119, 119):
if a ** 5 - b ** 5 == X:
print(a, b)
exit()
|
p02555 | s158098339 | Accepted | A = [0,0,0,1,1,1]
s = int(input())
if s < 6:
print(A[s])
else:
for i in range(6,s+1):
a = 1
for j in range(3,i-2):
a += A[j]
A.append(a)
print(A[s]%(10**9 + 7))
|
p03705 | s922291780 | Accepted | # A - A+...+B Problem
N, A, B = map(int, input().split())
if A>B or (N==1 and A!=B):
print(0)
else:
print((N-2)*(B-A)+1) |
p03077 | s541187800 | Accepted | import math
N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
print(math.ceil(N/min([A, B, C, D, E]))+4)
|
p03408 | s315667302 | Accepted | n = int(input())
s=[]
for i in range(n):
s.append(input())
from collections import Counter
cs = Counter(s)
m = int(input())
for i in range(m):
t = input()
if cs[t]:
cs[t] -= 1
print(cs.most_common(1)[0][1], flush=True)
|
p02676 | s871490149 | Wrong Answer | n = int(input())
n1 = input()
i = len(n1)
n2 = '...'
if n > i:
print(n1)
else:
print(n1[:n] + n2) |
p03435 | s447766195 | Accepted | # https://atcoder.jp/contests/abc088/tasks/abc088_c
matrix = []
for _ in range(3):
row = [int(i) for i in input().split()]
matrix.append(row)
a1 = matrix[1][0] - matrix[0][0]
a2 = matrix[2][0] - matrix[0][0]
b1 = matrix[0][1] - matrix[0][0]
b2 = matrix[0][2] - matrix[0][0]
if a1 + b1 == matrix[1][1] - matrix[0][0] and a2 + b2 == matrix[2][2] - matrix[0][0] and a1 + b2 == matrix[1][2] - matrix[0][0] and a2 + b1 == matrix[2][1] - matrix[0][0]:
print('Yes')
else:
print('No') |
p02952 | s123855098 | Accepted | n = int(input())
ans = 0
for i in range(1, n + 1):
if len(str(i)) % 2 == 1:
ans += 1
print(ans)
|
p02730 | s113590610 | Wrong Answer | S = input()
N = len(S)
def isPalindrome(S, i, j):
i = int(i)
j = int(j)
while S[i] == S[j]:
i+=1
j-=1
if i == j or j == i - 1:
return True
elif i > j:
return False
if isPalindrome(S, 0, N-1) and isPalindrome(S, 0, (N-1)/2-1) and isPalindrome(S, (N+3)/2-1, N-1):
print('Yes')
else:
print('No')
|
p03721 | s051531817 | Accepted | n, k = (int(x) for x in input().split())
ab = []
for _ in range(n):
a, b = (int(x) for x in input().split())
ab.append([a, b])
ans= 0
ab = sorted(ab, key=lambda x: x[0])
for i,j in ab:
ans+=j
if k<=ans:
print(i)
break |
p03243 | s165935660 | Accepted | N = int(input())
if N % 111:
print(111*(N//111 + 1))
else:
print(111*int((N/111)))
|
p03061 | s629859478 | Accepted | import math
N = int(input())
List = list(map(int,input().split()))
L=[0]*N
R=[0]*N
for i in range(1,N):
L[i] = math.gcd(L[i-1],List[i-1])
R[-i-1] = math.gcd(R[-i],List[-i])
ans = 0
for i in range(N):
ans = max(ans,math.gcd(L[i],R[i]))
print(ans) |
p02700 | s347565813 | Wrong Answer | a, b, c, d = map(int, input().split())
while c >0:
a -= d
c -= b
if c < 0:
print("No")
else:
print("Yes") |
p03997 | s978108145 | Wrong Answer | a = int(input())
b = int(input())
h = int(input())
print((a+b)*h/2) |
p03625 | s891529244 | Wrong Answer | from collections import Counter
N = int(input())
A = list(map(int, input().split()))
c = Counter(A)
l = sorted(filter(lambda x:x[1] > 1,c.items()),reverse=True)
if len(l) == 0:
print(0)
else:
print(l[0][0]*l[1][0]) |
p02959 | s396337651 | Accepted | n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
a.append(0)
b.append(0)
b.append(0)
ans = 0
for i in range(n+1):
if a[i]-b[i] > 0:
ans += b[i]
elif a[i]-b[i] <= 0 and a[i] + a[i+1] >= b[i]:
b[i+1] += b[i]-a[i]
ans += a[i]
else:
b[i+1] += a[i+1]
ans += a[i]
print(ans) |
p03103 | s912592012 | Accepted | from collections import defaultdict
N, M = map(int, input().split())
drinks = defaultdict(int)
for _ in range(N):
A, B = map(int, input().split())
drinks[A] += B
drinks = sorted(drinks.items(), key = lambda x : x[0])
cnt = 0
price = 0
for k, v in drinks:
purchases = min(v, M - cnt)
cnt += purchases
price += purchases * k
print(price)
|
p03544 | s249101420 | Accepted | n = int(input())
def calc(n):
a,b = 2, 1
if n == 0:
return a
elif n == 1:
return b
else:
for i in range(n-1):
a,b = b, a+b
return b
ans = calc(n)
print(ans)
|
p03274 | s113800947 | Accepted | n,k = map(int,input().split())
X = list(map(int,input().split()))
Xp = [x for x in X if x>=0]
Xm = [-x for x in X if x<0]
Xm.sort()
Xp.insert(0,0)
Xm.insert(0,0)
lp = len(Xp)
lm = len(Xm)
ans = 10**9
for p in range(k+1):
m = k-p
if p>lp-1 or m>lm-1:continue
ans= min(ans,2*Xm[m] +Xp[p],Xm[m] +2*Xp[p] )
print(ans)
|
p03324 | s527669626 | Accepted | D, N=map(int, input().split())
a=0
if N==100:
a=100**D
print((100**D)*N+a) |
p02628 | s051381567 | Wrong Answer | # encoding: utf-8
max_, request = map(int, input().split())
amounts = list(map(int, input().split()))
amounts.sort()
print(amounts[:request]) |
p04012 | s468481335 | Wrong Answer | # -*- coding : utf - 8 -*-
w = str(input())
for i in w:
if w.count(i) % 2 == 1:
print("NO")
exit()
print("Yes")
|
p02909 | s113701423 | Accepted | s = input()
if s == "Sunny":
print("Cloudy")
elif s == "Cloudy":
print("Rainy")
else:
print("Sunny") |
p03494 | s783076147 | Accepted | b=[]
a=input()
b=map(int,input().split())
ans=[]
f_ans=0
for i in b:
d=0
while i % 2 == 0:
i=i/2
d+=1
ans.append(d)
f_ans=min(ans)
print(f_ans) |
p04005 | s329105166 | Accepted | def main():
a, b, c = map(int, input().split())
x = b*c*((a-a//2)-a//2)
y = a*c*((b-b//2)-b//2)
z = a*b*((c-c//2)-c//2)
print(min(x, y, z))
if __name__ == "__main__":
main() |
p03469 | s420072289 | Wrong Answer | S = input()
print(S[:2]+"8"+S[4:]) |
p03617 | s962243795 | Accepted | q,h,s,d=map(int,input().split())
n=int(input())
h=min(h,q*2)
s=min(s,h*2)
d=min(d,s*2)
print((n//2)*d + (n%2)*s) |
p03773 | s433448279 | Wrong Answer | a, b = map(int,input().split())
if (a + b) < 25:
print(a + b)
else:
print((a + b) - 24)
|
p03161 | s185438681 | Accepted | #-*-coding:utf-8-*-
import numpy as np
def main():
n,k = map(int,(input().split()))
ashiba=np.array((input().split()),int)
dp=np.zeros(n,dtype=int)
for i in range(1,n):
start=max(0,i-k)
dp[i]=min(dp[start:i]+abs(ashiba[i]-ashiba[start:i]))
print(dp[n-1])
if __name__ == "__main__":
main() |
p03548 | s437475769 | Accepted |
import numpy as np
x,y,z=map(int,input().split())
x-=z
print(x//(y+z)) |
p03696 | s843384541 | Accepted | N = int(input())
S = input()
L = 0
R = 0
cnt = 0
d = []
for s in S:
if s == "(":
cnt += 1
else:
cnt -= 1
if cnt < 0:
cnt = 0
L += 1
R += cnt
print(L*"(" + S + R*")")
|
p02578 | s542804971 | Accepted | n = int(input())
a = list(map(int,input().split()))
m = a[0]
stool = 0
for i in range(1,n):
if a[i]>m:
m = a[i]
stool = stool + m-a[i]
print(stool) |
p03485 | s481184402 | Accepted | import math
a,b = map(int, input().split())
print(math.ceil((a+b)/2)) |
p03627 | s730686294 | Accepted | import collections
import sys
n = int(input())
a = sorted(list(map(int,input().split())))
c = collections.Counter(a)
s = len(set(a))
c = sorted(c.items(), reverse=True)
for i in range(s):
if c[i][1]>=4:
print(c[i][0]**2)
sys.exit()
elif c[i][1] >=2:
for j in range(i+1,s):
if c[j][1]>=2:
print(c[i][0]*c[j][0])
sys.exit()
print("0")
|
p03208 | s466951321 | Wrong Answer | n,k=map(int,input().split())
h=list(int(input()) for _ in range(n))
h.sort()
s=[abs(h[i+1]-h[i]) for i in range(n-1)]
ans=[s[i]+s[i+1] for i in range(n-2)]
print(min(ans)) |
p02951 | s837219204 | Wrong Answer | A,B,C = map(int,input().split())
if(A-B >= C):
print(C - (A-B))
else:
print(0) |
p03162 | s764858607 | Accepted | def solve():
N = int(input())
dp = [[0] * 3 for i in range(N + 1)]
for i in range(N):
A = list(map(int, input().split()))
for j in range(3):
for k in range(3):
if j != k:
dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + A[k])
return max(dp[N])
print(solve())
|
p02675 | s740798942 | Accepted | a=input()
pon = ["0", "1", "6", "8"]
if a[-1] == "3":
print("bon")
elif a[-1] in pon:
print("pon")
else:
print("hon")
|
p03612 | s360078378 | Wrong Answer | N = int(input())
P = list(map(int, input().split()))
Q = {}
for i in range(N):
Q[i + 1] = P[i]
ans = 0
if Q[1] == 1:
ans += 1
Q[1], Q[2] = Q[2], Q[1]
for i in range(1, N - 1):
if Q[i + 1] == i + 1:
Q[i], Q[i + 1] = Q[i + 1], Q[i]
ans += 1
print(ans)
|
p03487 | s236009734 | Accepted | import collections
n = int(input())
A = list(map(int, input().split()))
B = collections.Counter(A)
ans = 0
for i in B:
if i > B[i]:
ans += B[i]
else: ans += B[i] - i
print(ans) |
p03239 | s341024607 | Wrong Answer | N, T = map(int, input().split())
ans = 10000;
for i in range(N):
c, t = map(int, input().split())
if t > T:
continue
else:
ans = min(ans, c)
print(ans if ans < T else "TLE") |
p02912 | s841380807 | Wrong Answer | n,m=map(int,input().split())
a=list(map(int,input().split()))
for i in range(m):
a.sort()
t=int(a[-1]/2)
a.append(t)
print(sum(a)) |
p02554 | s428093356 | Accepted | import sys
input = sys.stdin.readline
n = int(input())
print((10**n - (2*9**n-8 **n)) % (10**9 + 7)) |
p03719 | s045288884 | Wrong Answer | a,b,c=map(int,input().split())
if a<=c<=b:print('YES')
else:print('NO') |
p02918 | s383166280 | Wrong Answer | from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))
n,k=nii()
s=input()
happy=0
unhappy=0
for i in range(1,n):
if s[i-1]==s[i]:
happy+=1
else:
unhappy+=1
for i in range(k):
if unhappy==1:
happy+=1
break
happy+=2
unhappy-=2
print(happy) |
p02640 | s104088087 | Wrong Answer | # -*- coding: utf-8 -*-
X,Y = list(map(int, input().rstrip().split()))
#-----
crane = int( (4*X - Y) / 2 )
tortoise = int( (-2*X + Y) / 2 )
if (0 <= crane <= 100) and (0 <= tortoise <= 100):
if crane == tortoise == 0:
print("No")
print("Yes")
else:
print("No")
|
p03162 | s219352406 | Wrong Answer | import numpy as np
N = int(input())
a = np.zeros((N,3))
for i in range(N):
a[i][0],a[i][1],a[i][2] = map(int,input().split())
memo = np.zeros((N,3))
memo[0][0], memo[0][1], memo[0][2] = a[0][0],a[0][1],a[0][2]
day = 1
while (day < N):
memo[day] = [max(memo[day-1][(x+1)%3],memo[day-1][(x+2)%3]) + a[day][x] \
for x in [0,1,2]]
day += 1
print(max(memo[day - 1])) |
p03494 | s863571581 | Wrong Answer | N=input()
A=list(map(int,input().split()))
count = 0
while sum(A)%2==0:
A=list(map(lambda x:x/2,A))
print(A)
count+=1
print(count) |
p03371 | s055754437 | Accepted | def calcPizza(k, mai):
return k*mai
a,b,c,x,y = [int(i) for i in input().split(' ')]
mins = min(x,y)
asum = calcPizza(a, x)
bsum = calcPizza(b, y)
absum = calcPizza(c,mins*2)
if x > mins:
atmp= calcPizza(a,x-mins)
abtmp= calcPizza(c,(x-mins)*2)
absum += min(atmp,abtmp)
elif y > mins:
btmp = calcPizza(b,y-mins)
abtmp = calcPizza(c,(y-mins)*2)
absum += min(btmp,abtmp)
print(min(asum+bsum, absum)) |
p02952 | s950573677 | Wrong Answer | import math
n = int(input())
m = int(math.ceil(math.log10(n)))
ans = 0
if m == 1:
x = n % (10 ** 1)
ans = x
elif m == 2:
ans = 9
elif m == 3:
x = n % (10 ** 3)
ans = 9 + x - 100
elif m == 4:
ans = 909
elif m == 5:
if n == 100000:
ans = 90909
else:
x = n % (10 ** 5)
ans = 909 + x - 10000
print(ans)
|
p03821 | s622851607 | Wrong Answer | n = int(input())
ab = [input().split() for _ in [0]*n]
a = [int(i) for i, j in ab][::-1]
b = [int(j) for i, j in ab][::-1]
ans = 0
for i in range(n):
if a[i] % b[i] != 0:
ans += b[i] - ((a[i]+ans) % b[i])
print(ans)
|
p03730 | s110183609 | Accepted | a,b,c=map(int,input().split())
for k in range(1,10001):
if (k*a-c)%b==0:
print("YES")
exit()
print("NO")
|
p02618 | s569337556 | Accepted | for i in range(1,365+1):print(i%26+1) |
p02819 | s151816224 | Accepted | x = int(input())
def is_prime(x):
if x<= 1:return False
for i in range(2,1+int(x**(1/2))):
if x%i == 0: return False
return True
def main():
global x
while not is_prime(x):
x += 1
print(x)
main() |
p03605 | s835425010 | Accepted | n = int(input())
if n%10 == 9 or n//10 == 9:
print("Yes")
else:
print("No") |
p03162 | s951920126 | Accepted | def main():
N = int(input())
v = [list(map(int,input().split())) for _ in range(N)]
dp = [[0]*3 for _ in range(N+1)]
for i in range(N):
for j in range(3):
for k in range(3):
if j==k:continue
dp[i+1][k] = max(dp[i+1][k],dp[i][j]+v[i][k])
print(max(dp[N][i] for i in range(3)))
main() |
p03659 | s789556359 | Accepted | n = int(input())
a = input().split()
a = list(map(int,a))
total = sum(a)
x = 0
arr = []
if n == 2:
arr.append(abs(a[0]-a[1]))
else:
for i in range(n-1):
x += a[i]
y = total - x
arr.append(abs(x - y))
print(min(arr))
|
p02707 | s766346148 | Accepted | N = int(input())
num = {}
for i in range(N):
num[i] = 0
A = list(map(int, input().split(" ")))
for i in range(len(A)):
num[A[i]-1] += 1
[print(num[i]) for i in range(N)]
|
p02791 | s227377369 | Accepted | N = int(input())
P = list(map(int,input().split()))
count =0
mi= 3*(10**5)
for i in range(N):
if mi >= P[i]:
count +=1
mi=P[i]
print(count)
|
p02584 | s249709908 | Wrong Answer | # x, k, d = map(int, input().split(' '))
x, k, d = map(int, input().split(' '))
b = x + k * d;
if b > 0:
a = int(b / (2 * d))
if a <= k:
print(max(b-a*2*d, b-(a+1)*2*d))
else:
print(b-k*2*d)
else:
print(-b) |
p03472 | s345987858 | Wrong Answer | import math
def main():
N, H = list(map(int, input().split()))
a_max = 0
b_list = []
for _ in range(N):
a,b = list(map(int, input().split()))
a_max = max(a, a_max)
b_list.append(b)
b_list = sorted(b_list)[::-1]
cnt = 0
for b in b_list:
if b < a_max:
break
H -= b
cnt += 1
print(cnt + math.ceil(H / a_max))
if __name__ == "__main__":
main()
|
p03659 | s224885138 | Accepted | n = int(input())
a_list = [int(x) for x in input().split()]
temp_list = [0] * n
temp_list[0] = a_list[0]
for i in range(1, n):
temp_list[i] = a_list[i] + temp_list[i - 1]
ans = 10 ** 15
for i in range(n - 1):
temp = abs(temp_list[-1] - (temp_list[i] << 1))
if temp < ans:
ans = temp
print(ans) |
p03854 | s907580870 | Accepted | s = input().replace('eraser', '').replace('erase', '').replace('dreamer', '').replace('dream', '')
if s:
print('NO')
else:
print('YES')
|
p03720 | s059047223 | Accepted | N, M = map(int, input().split())
a = [list(map(int, input().split())) for i in range(M)]
r = [0]*N
for i in range(M):
r[a[i][0] - 1] += 1
r[a[i][1] - 1] += 1
for i in range(N):
print(r[i])
|
p03711 | s400914823 | Accepted | l = [[1,3,5,7,8,10,12],[4,6,9,11],[2]]
x,y = map(int,input().split())
ans = ""
for i in range(3):
if (x in l[i]):
if (y in l[i]):
print("Yes")
break
else:
print("No")
break
|
p02732 | s812204579 | Accepted | from collections import defaultdict
N = int(input())
balls = input()
balls = balls.split()
balls = list(map(int, balls))
count = defaultdict(int)
for i in balls:
count[i] += 1
def cmb(M):
return M*(M-1)//2
sum = 0
for i in count:
sum += cmb(count[i])
#sum = defaultdict(int)
#for i in count:
# for j in count:
# if i==j:
# sum[i] += cmb(count[j]-1)
# else:
# sum[i] += cmb(count[j])
#
for i in balls:
print(sum - (count[i]-1))
|
p03639 | s048705681 | Accepted | import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7
def resolve():
n = int(input())
A = list(map(int, input().split()))
cnt_4 = 0
cnt_2 = 0
for a in A:
if a % 4 == 0:
cnt_4 += 1
elif a % 2 == 0:
cnt_2 += 1
print("Yes" if n - max(0, cnt_2 - 1) <= cnt_4 * 2 + 1 else "No")
if __name__ == '__main__':
resolve()
|
p02910 | s691056814 | Accepted |
import sys
s = input()
for i in range(len(s)):
if(i%2 ==0):
if(s[i] != 'R'and s[i] != 'U' and s[i] != 'D'):
print('No')
sys.exit()
else:
if(s[i] != 'L'and s[i] != 'U' and s[i] != 'D'):
print('No')
sys.exit()
print("Yes") |
p02861 | s653546310 | Wrong Answer | from itertools import permutations
from math import sqrt, pow
n = int(input())
l = [list(map(int, input().split())) for _ in range(n)]
def calc(a, b):
[x1, y1] = a
[x2, y2] = b
return sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2))
ans = 0
for i in permutations(range(n)):
tmp = 0
for j in range(1, n):
tmp = calc(l[i[j]], l[i[j-1]])
ans += tmp
print(ans/n)
|
p03698 | s129016361 | Wrong Answer | s = input()
alphabet = ["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"]
aa = [0]*26
ans = "yes"
for i in range(len(s)-1):
for j in range(26):
if s[i] == alphabet[j]:
aa[j] += 1
if aa[j] >= 2:
ans = "no"
break
print(ans)
|
p03282 | s664278893 | Accepted | #!/usr/bin/env python3
s = input()
k = int(input())
i = 0
while i < len(s) - 1:
if i == k - 1:
print(s[i])
exit()
if s[i] == "1":
i += 1
else:
print(s[i])
exit()
print(s[i])
|
p03220 | s220513371 | Accepted | n = int(input())
t,a = map(int,input().split())
H = list(map(int,input().split()))
temp = []
for i in range(n):
temp.append(a-(t-H[i]*0.006))
temp_abs = [abs(j) for j in temp]
mini_temp_abs = min(temp_abs)
for k in range(n):
if temp_abs[k] == mini_temp_abs:
print(k+1)
|
p03986 | s660545304 | Accepted | X = input()
ans, sc = 0, 0
for x in X:
if x == 'T':
sc += 1
else:
sc -= 1
ans = max(ans, sc)
print(ans*2)
|
p02957 | s593125119 | Accepted | A, B = map(int, input().split())
if (A+B) % 2 == 0:
print((A+B)//2)
else:
print("IMPOSSIBLE") |
p03013 | s223292470 | Accepted | div = 1000000007
n, m, *b = map(int, open(0).read().split())
a = set(b)
f = [0] * (n + 1)
f[0] = 1
if 1 not in a:
f[1] = 1
for i in range(2, n + 1):
if i in a:
continue
f[i] = (f[i - 1] + f[i - 2]) % div
print(f[-1])
|
p02595 | s638977824 | Accepted | N, D = map(int, input().split())
cnt = 0
D2 = D*D
for _ in range(N):
X, Y = map(int, input().split())
if X**2+Y**2 <= D2:
cnt += 1
print(cnt) |
p04019 | s009842567 | Accepted | from collections import Counter
cntr = Counter(input())
x_ok, y_ok = False, False
if (cntr["E"] and cntr["W"]) or (not cntr["E"] and not cntr["W"]):
x_ok = True
if (cntr["N"] and cntr["S"]) or (not cntr["N"] and not cntr["S"]):
y_ok = True
print("Yes") if x_ok and y_ok else print("No")
|
p02691 | s241515176 | Accepted | N = int(input())
A = list(map(int, input().split()))
L = {}
count = 0
for i in range(N):
l = i + A[i]
r = i - A[i]
if r in L.keys():
count += L[r]
if l in L.keys():
L[l] += 1
else:
L[l] = 1
print(count) |
p03137 | s956775515 | Accepted | import sys
input = sys.stdin.readline
N,M = list(map(int,input().split()))
X = sorted(list(map(int,input().split())))
Xsub = []
for i in range(M-1):
Xsub.append(X[i+1]-X[i])
Xsub = sorted(Xsub)
if N > 1:
print(sum(Xsub[:-(N-1)] ))
else:
print(sum(Xsub))
|
p02933 | s115461529 | Wrong Answer | a = int(input())
S = input()
if a >= 3200:
print('s')
elif a < 3200:
print('red')
|
p02621 | s850201862 | Accepted | a=int(input())
print(a+a**2+a**3) |
p03434 | s493522762 | Wrong Answer | n = int(input())
a = list(map(int,input().split()))
a.sort()
A = sum(a[1::2])
B = sum(a[::2])
print(A-B) |
p03069 | s343731474 | Wrong Answer | import itertools
n = int(input())
s = [i for i in input()]
ans = 0
gr = itertools.groupby(s)
cnt = 0
for k, g in gr:
if cnt == 0 and k == ".": continue
if k == ".": ans += 1
cnt += 1
print(ans) |
p03408 | s174535412 | Accepted | import collections
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
ss = collections.Counter(s)
tt = collections.Counter(t)
ans = 0
for i in ss:
sub = ss[i]
if i in tt:
sub -= tt[i]
ans = max(ans, sub)
print(ans) |
p03659 | s501368171 | Accepted | import numpy
N = int(input())
List = list(map(int,input().split()))
cumsum = numpy.cumsum(List)
total = sum(List)
result = [abs(total -item*2) for item in cumsum ]
print(min(result[:-1])) |
p03219 | s252695509 | Wrong Answer | a, b = map(int, input().split())
print(a + b / 2) |
p02811 | s637256621 | Accepted | k, x = map(int, input().split())
if 500*k >= x:
print("Yes")
else:
print("No")
|
p02882 | s846515691 | Accepted | import math
a,b,x = map(int,input().split())
if x == a*a*b:
print(0)
exit()
if a*a*b/2 < x:
x = a*a*b - x
b = x*2/(a*a)
p = x*2/(a*b)
print(math.degrees(math.atan(b/p))) |
p02642 | s992074440 | Wrong Answer | n = int(input())
a_ls = list(map(int, input().split()))
a_ls.sort(reverse=True)
ans = 0
for i in range(n):
not_divisible = True
for j in range(i+1,n):
if a_ls[i] % a_ls[j] == 0:
not_divisible = False
break
if not_divisible:
ans += 1
if n > 1 and a_ls[-2] == a_ls[-1]:
ans -= 1
print(ans) |
p02833 | s083443602 | Accepted | N = int(input())
div = 5
if N%2==0:
ans=0
N = N//2
while div <= N:
ans+=N//div
div*=5
print(ans)
else:
print(0) |
p03289 | s701313478 | Wrong Answer | S = input()
if S[0] != 'A':
print("WA")
exit()
if S[2:-1].count('C') != 1:
print("WA")
exit()
if S.replace("AC", "").islower == False:
print("WA")
exit()
print("AC")
|
p03951 | s975193457 | Accepted | import itertools,sys
def I(): return int(sys.stdin.readline().rstrip())
def S(): return sys.stdin.readline().rstrip()
N = I()
s,t = S(),S()
ans = len(s)+len(t)
t_accumulate = list(itertools.accumulate(t))
for x in t_accumulate[::-1]:
if x in s:
ans -= len(x)
break
if ans>=N:
print(ans)
else:
print(max(N,len(s)+len(t)))
|
p03073 | s159931473 | Wrong Answer | s = list(input())
n = int(len(s)/2)
c = 0
if len(s) >= 2:
if s[1] == s[0]:
c +=1
if s[0] == 0:
s[1] = 1
elif s[0] == 1:
s[1] = 0
for i in range(n):
if s[0] != s[2*i]:
c += 1
if s[1] != s[2*i+1]:
c += 1
print(c)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.