problem_id stringclasses 428 values | submission_id stringlengths 10 10 | status stringclasses 2 values | code stringlengths 5 816 |
|---|---|---|---|
p03339 | s244020681 | Accepted | n = int(input())
s_list = list(input())
e_sum = [0]
su = 0
for s in s_list[:-1]:
if s == "W":
su += 1
e_sum.append(su)
w_sum = [0]
su = 0
for s in s_list[::-1][:-1]:
if s == "E":
su += 1
w_sum.append(su)
w_sum = w_sum[::-1]
ans = 10 ** 10
for i in range(n):
ans = min(ans, e_sum[i] + w_sum[i])
print(ans) |
p02707 | s926719225 | Accepted | import collections
N = int(input())
A = list(map(int,input().split()))
a = collections.Counter(A)
for i in range(1,N+1):
print(a[i]) |
p03061 | s564029466 | Wrong Answer | # C - GCD on Blackboard
n = int(input())
a = list(int(x) for x in input().split())
a.sort()
def gcd(x, y):
if x==0:
return y
else:
return gcd(y%x, x)
if n==2:
print(max(a))
else:
ans = max(gcd(a[0],a[1]), gcd(a[1],a[2]), gcd(a[2],a[0]))
for i in range(3, n):
ans = gcd(a[i], ans)
print(ans) |
p03852 | s651880705 | Wrong Answer |
l = ["a","b","c","d","e"]
c = input()
if c in l:
print("vowel")
else:
print("consonant")
|
p03627 | s884723128 | Accepted | n =int(input())
a=[int(x) for x in input().split()]
a.sort()
c=b=0
for i in range(n-1):
if(a[-i-1]==a[-i-2]):
a[-i-2]=0
if b==0:
b=a[-i-1]
else:
c=a[-i-1]
break
print(b*c) |
p02866 | s128601023 | Accepted | N=int(input())
D=list(map(int,input().split()))
M=998244353
P=max(D)
L=[0]*(P+1)
for d in D:
L[d]+=1
if not(L[0]==1 and D[0]==0):
print(0)
exit()
K=1
for i in range(P):
K*=pow(L[i],L[i+1],M)
K%=M
print(K) |
p02982 | s327375934 | Accepted | from numpy import array
from numpy.linalg import norm
n,d=map(int,input().split())
X = [list(map(int,input().split())) for i in range(n)]
ans = 0
for i in range(n-1):
for j in range(i+1,n):
if norm(array(X[i])-array(X[j])).is_integer():
ans += 1
print(ans) |
p03220 | s648433224 | Wrong Answer | n = int(input())
t,a = map(float,input().split())
h = list(map(float,input().split()))
best = 10 ** 5
ans = -1
for i in range(n):
tt = t - h[i] * 0.006
best = min(abs(best - a),abs(a - tt))
if abs(a - tt) == best:
ans = i
print(ans+1) |
p03592 | s126775725 | Wrong Answer | N,M,K=map(int,input().split())
a=0
for i in range(1,N+1):
for j in range(1,M+1):
if i*M+j*N-i*j==K:
print(i,j)
a=1
print(["No","Yes"][a]) |
p02989 | s720204601 | Accepted | import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: map(str, sys.stdin.buffer.readline().split())
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7
n = ri()
a = rl()
a.sort()
i = n//2
print(a[i] - a[i-1])
|
p02787 | s221135597 | Accepted | h, n = map(int, input().split())
AB = [tuple(map(int, input().split())) for i in range(n)]
A = [a for a, b in AB]
B = [b for a, b in AB]
inf = 10**10
# DP[i][j]=i個以内で体力j以上削るための消費魔力の最小値
DP = [[inf for j in range(h+1)] for i in range(n+1)]
DP[0][0] = 0
for i in range(1, n+1):
for j in range(h+1):
DP[i][j] = min(DP[i-1][j], DP[i][max(0, j-A[i-1])]+B[i-1])
print(DP[n][h])
|
p02842 | s325984445 | Wrong Answer | import math
f = True
N = int(input())
for i in range(N):
if math.floor(i*1.08) == N:
print(i)
f = False
if f:
print(":(")
|
p03293 | s316133338 | Accepted | s = input()
t = input()
s_len = len(s)
for i in range(s_len):
if s == t:
print("Yes")
exit()
s = s[s_len-1] + s[0:s_len-1]
print("No")
|
p02768 | s583718737 | Accepted | import sys
input = sys.stdin.readline
n, a, b = [int(x) for x in input().split()]
def nCk(n, k, mod=10 ** 9 + 7):
if n < k:
return 0
k = min(k, n - k)
numer = 1
for x in range(n - k + 1, n + 1):
numer = (numer * x) % mod
denom = 1
for x in range(1, k + 1):
denom = (denom * x) % mod
return numer * pow(denom, mod - 2, mod) % mod
ans = 0
total = 0
total = 2 ** n - 1
total %= 7 + 10 ** 9
total -= nCk(n, a) + nCk(n, b)
total %= 7 + 10 ** 9
print(total) |
p03338 | s141393281 | Accepted | import sys
def resolve():
N = int(input())
S = input()
res = 0
for i in range(1, N-1):
cnt = 0
left = S[:i]
right = S[i:]
counted = []
for s in left:
if s in right and s not in counted:
counted.append(s)
cnt += 1
res = max(cnt, res)
print(res)
if '__main__' == __name__:
resolve() |
p02993 | s626406874 | Accepted | s = list(input())
t = s[0]
for i in range(1, 4):
if t == s[i]:
print('Bad')
exit()
t = s[i]
print('Good')
|
p03013 | s105785468 | Accepted | N, M = map(int,input().split())
DP = [0 for i in range(N+1)]
DP[0]=1
for i in range(M):
DP[int(input())] = None
for i in range(N):
if 0<i and DP[i+1]!=None and DP[i-1]!=None:
DP[i+1]+=DP[i-1]
if DP[i+1]!=None and DP[i]!=None:
DP[i+1]+=DP[i]
print(DP[N]%1000000007) |
p02786 | s618074611 | Accepted | H = int(input())
n = H.bit_length()
print(pow(2,n)-1)
|
p03250 | s909915296 | Accepted | a,b,c=sorted(map(int, input().split()))
print(10*c+b+a) |
p02676 | s481753629 | Accepted | k = int(input())
s = input()
s_len = len(s)
if s_len <= k:
print(s)
else:
print(s[:k]+'...') |
p02924 | s236662153 | Wrong Answer | N = int(input())
print(N * (N-1) / 2) |
p03679 | s400991039 | Accepted | x, a, b = [int(s) for s in input().split()]
print("delicious" if b <= a else ("safe" if b <= a + x else "dangerous")) |
p02681 | s318476159 | Wrong Answer | s=input()
t=input()
if s in t:
print("Yes")
else:
print("No") |
p02688 | s051102094 | Accepted | n, k = map(int, input().split())
data = [0] * n
for i in range(k):
d = int(input())
people = list(map(int, input().split()))
for j, val in enumerate(people):
tar = val - 1
data[tar] += 1
ans = 0
for i in data:
if (i == 0):
ans += 1
print(ans)
|
p02946 | s199025342 | Wrong Answer | n,x=map(int,input().split())
kuro=[]
for i in range(x-n+1,x):
kuro.append(i)
for i in range(x,n+x):
kuro.append(i)
print(kuro) |
p02918 | s815878451 | Accepted | N, K = map(int, input().split())
S = input()
ans = 0
for i in range(N):
if S[i] == 'L':
if i - 1 < 0:
continue
if S[i - 1] == 'L':
ans += 1
else:
if i + 1 >= N:
continue
if S[i + 1] == 'R':
ans += 1
X = (len([s for s in S.split('L') if s != '']) + len([s for s in S.split('R') if s != '']))
ans += min(X, K) * 2
print(min(ans, N - 1))
|
p02829 | s434912552 | Accepted | x=int(input())
y=int(input())
l=[1,2,3]
l.remove(x)
l.remove(y)
print(l[0]) |
p03617 | s651809230 | Accepted | Q, H ,S, D = map(int, input().split())
N = int(input())
tmp = [Q*4, H*2, S]
m = min(tmp)
if N == 1:
print(m)
else:
print(min(m*2, D) * (N//2) + m*(N%2)) |
p03821 | s306349764 | Accepted | N = int(input())
A, B = [], []
for i in range(N):
a, b = map(int, input().split())
A.append(a)
B.append(b)
A.reverse()
B.reverse()
count = 0
for i in range(N):
now = A[i] + count
if now % B[i] == 0:
pass
elif now < B[i]:
count += B[i] - now
else:
count += B[i] - (now % B[i])
print(count) |
p02719 | s785508806 | Wrong Answer | n,k = list(map(int,(input().split())))
if n<k :
print(n)
elif n>=k:
x = n//k
ans = n-(x*k)
ans_x = abs(n-(k*(x+1)))
if ans >= ans_x:
print(ans_x)
else:
print(ans)
#print(ans_x,ans) |
p02743 | s577000159 | Accepted | a,b,c=map(int,input().split())
if 4*a*b<(c-a-b)**2 and c-a-b>=0:
print('Yes')
else:
print('No') |
p03627 | s493757033 | Accepted | from collections import Counter
N=int(input())
A=Counter(list(map(int,input().split())))
x=[0,0]
for a in A:
if A[a]>1:x.append(a)
if A[a]>3:x.append(a)
x.sort()
print(x[-1]*x[-2]) |
p02959 | s456270511 | Accepted | N=int(input())
A=[int(x) for x in input().rstrip().split()]
B=[int(x) for x in input().rstrip().split()]
ans=0
now=A[0]
for i in range(N):
if B[i]<=A[i]:
ans+=B[i]
else:
if A[i]+A[i+1]<=B[i]:
ans+=A[i]+A[i+1]
A[i+1]=0
else:
ans+=B[i]
A[i+1]=A[i+1]-(B[i]-A[i])
print(ans)
|
p02833 | s584054489 | Accepted | N = int(input())
if N % 2:
print(0)
else:
N //= 2
ans = 0
while N:
N //= 5
ans += N
print(ans) |
p03338 | s832629391 | Accepted | N = int(input())
S = list(input())
cnt = []
for i in range(0,N):
s1 = set(S[0:i])
s2 = set(S[i:])
cnt.append(len(list(s1 & s2)))
print(max(cnt))
|
p03126 | s719631327 | Wrong Answer | n,m=map(int,input().split())
a=[list(map(int,input().split())) for i in range(n)]
y=0
if n!=1:
for i in range(1,n+1):
x=0
for j in range(n):
for k in range(1,a[j][0]+1):
if str(i) in str(a[j][k]):
x+=1
if x==n:
y+=1
print(y)
else:
print(a[0][0]) |
p02700 | s049873945 | Accepted | import sys
input = sys.stdin.readline
from collections import deque
a,b,c,d=map(int,input().split())
while True:
if c-b<=0:
print("Yes")
exit()
elif a-d<=0:
print("No")
exit()
c=c-b
a=a-d |
p04031 | s514659709 | Wrong Answer | N=int(input())
L=list(map(int,input().split()))
avg = sum(L)/len(L)
import math
avg_u = math.ceil(avg)
avg_d = math.floor(avg)
ans_u = []
ans_d = []
for i in L:
ans_u.append(i - avg_u)
ans_d.append(i - avg_d)
ans = 0
if sum(ans_u) <= sum(ans_d):
for i in ans_u:
ans += i ** 2
else:
for i in ans_d:
ans += i ** 2
print(ans) |
p03862 | s010340052 | Accepted | N, x = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
for k in range(1,N):
if a[k-1] + a[k] > x:
t = (a[k-1] + a[k]) - x
ans += t
if a[k] >= t:
a[k] -= t
else:
a[k-1] -= t-a[k]
a[k] = 0
print(ans)
|
p03745 | s828356789 | Wrong Answer | n = int(input())
a = list(map(int, input().split()))
Plus = True
ans = 1
last = a[0]
count = 1
for i in range(n):
if last > a[i] and Plus:
if count > 1:
ans += 1
count = 0
Plus = False
if last < a[i] and Plus == False:
if count > 1:
ans += 1
count = 0
Plus = True
#print(Plus)
last = a[i]
count += 1
print(ans) |
p02972 | s060705880 | Accepted | N = int(input())
A = [0] + list(map(int, input().split()))
ans = [0] * (N+1)
for i in range(N, 0, -1):
if sum(ans[i+i:N+1:i])%2 != A[i]: ans[i] = 1
print(sum(ans))
f = 0
for i in range(N+1):
if ans[i] == 0: continue
if f: print(' ')
print(i, end ='')
f = 1
if f:print()
|
p03427 | s832116886 | Wrong Answer | N = int(input())
n = [int(list(str(N))[i]) for i in range(len(list(str(N))))]
L = len(list(str(N)))-1
a = (N-10**L+1)//(10**L+1)
print(max(L*9+a,sum(n))) |
p02552 | s695697736 | Accepted |
if __name__ == "__main__":
x = int(input())
ret = 0
if x == 1:
ret = 0
else:
ret = 1
print(ret)
|
p03073 | s687073356 | Accepted | S = input()
cnt = 0
ch = S[0]
for i in range(1,len(S)):
if S[i] == ch:
cnt+=1
if ch == "0":
ch = "1"
else:
ch = "0"
else:
ch = S[i]
print(cnt) |
p03017 | s163656371 | Wrong Answer | n, a, b, c, d = map(int, input().split())
s = input()
flag1, flag2 = False, False
if d > c:
print("OK1")
flag = "##" not in s[b: d - 1] and "##" not in s[a: c - 1]
else:
print("OK2")
flag = "..." in s[b: d - 1]
print("Yes" if flag else "No") |
p03779 | s654023236 | Accepted | import math
X = int(input())
N = int(math.sqrt(2 * X)) + 1
def gauss(n):
ans = int(n * (n + 1)/ 2)
return(ans)
A = [gauss(i) for i in range(N + 1)]
ans = 0
for i in range(1, N + 1):
if X == A[i]:
ans = i
break
elif X > A[i - 1] and X < A[i]:
ans = i
break
print(ans) |
p02683 | s222169422 | Accepted | import sys
input = sys.stdin.buffer.readline
n,m,x=map(int,input().split())
c=[]
a=[]
for _ in range(n):
s,*t=map(int,input().split())
c.append(s)
a.append(t)
ans=float("inf")
for i in range(2**n):
l=[[0]*m]
need=0
for j in range(n):
if i&(1<<j):
l.append(a[j])
need+=c[j]
if all(sum(t)>=x for t in zip(*l)):
ans=min(ans,need)
print(ans if ans!=float("inf") else -1) |
p03455 | s913690713 | Wrong Answer | a,b=map(int,input().split())
if (a*b)%2==0:
print("偶数")
else:
print("奇数") |
p03557 | s709353019 | Accepted | import numpy as np
N = int(input())
A = list(map(int, input().split()))
A.sort()
A = np.array(A)
B = list(map(int, input().split()))
B.sort()
B = np.array(B)
C = list(map(int, input().split()))
C.sort()
C = np.array(C)
ans = 0
for i in range(N):
b = B[i]
a_ind = np.searchsorted(A,b,side='left')
c_ind = np.searchsorted(C,b,side='right')
ans += a_ind * (N-c_ind)
print(ans) |
p02606 | s835346800 | Accepted | l,r,d=map(int,input().split())
count=0
for i in range(l,r+1):
if i%d==0:
count+=1
print(count) |
p02718 | s011485236 | Accepted | import sys
read = sys.stdin.read
readline = sys.stdin.readline
N, M, *A = map(int, read().split())
s = sum(A) / (4 * M)
a = [i for i in A if i >= s]
if len(a) >= M:
print('Yes')
else:
print('No')
|
p03286 | s122721687 | Accepted | n = int(input())
Str = ""
while n != 0:
r = n % 2
if r < 0:
r += 2
n = (n-r) // (-2)
Str += str(r)
tmp = list(reversed(list(Str)))
ans = "".join(tmp)
if Str == "":
print(0)
exit()
print(ans)
|
p02759 | s630910373 | Accepted | N = int(input())
if N % 2 == 0:
ans = N//2
else:
ans = N//2 + 1
print(ans) |
p02989 | s492853839 | Accepted | n = int(input())
d_inputs = sorted([int(i) for i in input().split()])
abc = d_inputs[0:n//2]
arc = d_inputs[n//2:n]
print(len([i for i in range(abc[-1]+1,arc[0]+1)]))
|
p03210 | s859952940 | Accepted | x=int(input())
if x in [3,5,7]:
print('YES')
else:
print('NO') |
p03145 | s360361612 | Accepted | a, b, c = map(int, input().split())
print(int(a * b / 2)) |
p02693 | s435805216 | Wrong Answer | k = int(input())
a, b = map(int,input().split())
if k <= b-a+1:
print('OK')
else:
print('NG') |
p02784 | s674542922 | Accepted | H,N=map(int,input().split())
A=list(map(int,input().split()))
print("Yes" if sum(A)>=H else "No") |
p03043 | s720065058 | Accepted | from math import ceil, log
N, K = map(int, input().split())
ans = 0
for i in range(1, N+1):
val = i
# val * 2^n > K
# 2^n > K / val
# n > log(K/val) / log2
count = ceil(log(K/val) / log(2))
count = 0 if count < 0 else count
ans += 1 / (pow(2, count) * N)
print(ans)
|
p03013 | s301456468 | Wrong Answer | n,m = map(int,input().split())
a = [int(input()) for _ in range(m)]
dp=[0 for _ in range(n+1)]
dp[0]=1
for i in range(1,n+1):
if i in a:
continue
else:
if i==1:
dp[1]=1
else:
dp[i] = (dp[i-1]+dp[i-2]%1000000007)
print(dp[n]) |
p03061 | s646093376 | Wrong Answer | import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
n = int(input())
a = list(map(int, input().split()))
def gcd(a, b):
if b == 0:
return a
else:
return gcd(b, a % b)
drop_zero = a[1:]
drop_one = [a[0]] + a[2:]
ans_drop_zero = drop_zero[0]
for v in drop_zero:
ans_drop_zero = gcd(ans_drop_zero, v)
ans_drop_one = drop_one[0]
for v in drop_one:
ans_drop_one = gcd(ans_drop_one, v)
print(max(ans_drop_zero, ans_drop_one))
|
p03317 | s353118414 | Wrong Answer | import math
n, k = map(int, input().split())
a = list(map(int, input().split()))
ans = math.ceil(n/k)
print(ans) |
p03592 | s359512751 | Accepted | N, M, K = map(int, input().split())
def solve():
for i in range(N+1):
for j in range(M+1):
if i*M+j*N-i*j*2 == K:
return 'Yes'
return 'No'
print(solve()) |
p04045 | s303263296 | Accepted | #!/usr/bin/python
# -*- coding: UTF-8 -*-
import sys
def input():
return sys.stdin.readline().strip()
def _main():
n, k = input().split()
x = set(input())
n_s = set(n)
n_i = int(n)
while True:
if x & n_s:
n_i += 1
n_s = set(str(n_i))
else:
print(n_i)
break
if __name__ == "__main__":
_main()
|
p03284 | s254307672 | Accepted | n, k = map(int, input().split())
if n%k == 0:
print(0)
else:
print(1) |
p03250 | s573172853 | Accepted | l = list(map(int, input().split()))
i = l.index(max(l))
print(l.pop(i) * 10 + sum(l)) |
p02924 | s195220674 | Accepted | n = int(input())
print((n * (n - 1))// 2)
|
p02647 | s509821829 | Accepted | from itertools import accumulate
def calc(n,A):
Imos=[0]*(n+1)
for i,a in enumerate(A):
Imos[max(0,i-a)]+=1
Imos[min(n,i+a+1)]-=1
Ret=list(accumulate(Imos))
return Ret[:n]
def main():
n,k=map(int,input().split())
A=tuple(map(int,input().split()))
if k>=42:
A=[n]*n
else:
for _ in range(k):
A=calc(n,A)
print(*A)
if __name__=='__main__':
main() |
p02576 | s013156048 | Wrong Answer | import sys
input = sys.stdin.readline
read = lambda: list(map(int, input().strip().split()))
n, x, t = read()
print(n//x * t) |
p02833 | s139868496 | Accepted | N=int(input())
if N%2==1:
print(0)
else:
a=0
for i in range(1,26):
a+=(N)//(2*5**i)
print(a) |
p02547 | s985867827 | Accepted | N = int(input())
cnt = 0
ans = 'No'
for _ in range(N):
D = input().split()
cnt = (cnt + 1)*(D[0] == D[1])
if cnt == 3:
ans = 'Yes'
print(ans) |
p02843 | s246870971 | Wrong Answer | X = int(input())
if X < 100:
print('0')
exit()
rest = int(str(X)[-2:])
big = X - rest
cnt = 0
cnt += rest // 5
rest = rest - (rest // 5) * 5
cnt += rest // 4
rest = rest - (rest // 5) * 5
cnt += rest // 3
rest = rest - (rest // 5) * 5
cnt += rest // 2
rest = rest - (rest // 5) * 5
cnt += rest
big -= cnt * 100
print('1' if big >= 100 and big % 100 == 0 else '0') |
p03486 | s693122774 | Wrong Answer | s = input()
t = input()
s=sorted(s)
t=sorted(t)
if s<t:
print("Yes")
else:
print("No") |
p03338 | s006201993 | Wrong Answer | a = int(input())
b = input()
x = a - int(a / 2)
y = a - x
z = 0
X = b[0:x]
Y = b[x:a]
X = list(set(X))
Y = list(set(Y))
X.sort()
Y.sort()
if len(X) >= len(Y):
for i in range(len(X) - len(Y)):
Y.append("")
else:
for i in range(len(Y) - len(X)):
X.append("")
for i in range(len(X)):
if X[i] in Y:
z = z + 1
print(z)
|
p03449 | s671680352 | Accepted | N = int(input())
A = [[int(i) for i in input().split()] for j in range(2)]
dp = [[0]*(N+1) for i in range(3)]
for i in range(1,3):
for j in range(1,N+1):
dp[i][j] = max(dp[i-1][j], dp[i][j-1]) + A[i-1][j-1]
print(dp[-1][-1]) |
p03163 | s706313684 | Wrong Answer | N,W = map(int,input().split())
wv = [list(map(int,input().split())) for i in range(N)]
dp = [[0]*(W+1) for i in range(N+1)]
for i in range(1,N+1):
for w in range(W+1):
if w-wv[i-1][0]>=0:
dp[i][w] = max(dp[i-1][w-wv[i-1][0]]+wv[i-1][1],dp[i][w])
else:
dp[i][w] = dp[i-1][w]
print(dp[N][W])
|
p03327 | s757641802 | Wrong Answer | print(["ABD","ABC"][len(input())==3]) |
p02713 | s805975123 | Accepted | import math
import numpy
K = int(input())
total = tmp = 0
for a in range(1,K+1) :
for b in range(1,K+1) :
tmp=math.gcd(a,b)
for c in range(1,K+1) :
total += math.gcd(tmp,c)
print(total)
|
p02989 | s179282574 | Wrong Answer | N = int(input())
p = list(map(int,input().split()))
ans = 0
for j in range(len(p)):
agc = [i for i in p if i>j]
if len(agc) == len(p)-len(agc):
ans += 1
print(ans) |
p02583 | s007265290 | Wrong Answer | #! env/bin/local python3
# -*- coding: utf-8 -*-
from itertools import combinations
def is_tri(_a, _b, _c):
if (_a + _b > _c) and (_b + _c > _a) and (_c + _a > _b):
return True
else:
return False
n = int(input())
sticks = list(map(int, input().split()))
h = combinations(sticks, 3)
counter = 0
for a, b, c in h:
if is_tri(a, b, c):
# a, b, c = sorted([a, b, c])
if (a is not b) and (b is not c) and (c is not a):
counter += 1
print(counter)
|
p02712 | s317214245 | Accepted | N=int(input())
a=0
for i in range(1, N+1):
if i % 15 == 0:
continue
if i % 3 == 0:
continue
if i % 5 == 0:
continue
a += i
print(a) |
p03136 | s467620290 | Wrong Answer | N = int(input())
L = list(map(int,input().split()))
if max(L) <= sum(L)-max(L):
print('Yes')
else:
print('No') |
p02835 | s322198921 | Accepted | a,b,c,=map(int,input().split())
if a+b+c<22:
print("win")
else:
print("bust") |
p02787 | s884681066 | Wrong Answer | H, N = input().split()
H = int(H)
N = int(N)
a = []
b = []
con = 1
while con <= N:
A, B = map(int, input().split())
a.append(A)
b.append(B)
con += 1
|
p02963 | s376717109 | Accepted | import math
s = int(input())
a = math.ceil(math.sqrt(s))
b = a**2-s
print(0,0,a,1,b,a) |
p02725 | s598406703 | Wrong Answer | K,N = map(int,input().split())
A = list(map(int,input().split()))
X = 0
Y = 0
for i in range(N):
if A[i] == 0:
A[i] = K
A.sort()
b = A.copy()
for i in range(N-1):
#時計回り
X += b[i+1]-b[i]
c = A.copy()
c.reverse()
for j in range(N-1):
Y += A[i+1]-A[i]
print(min(X,Y)) |
p02817 | s468557287 | Accepted | S,T=input().split()
print(T+S)
|
p03951 | s622101536 | Accepted | n = int(input())
s = input()
t = input()
max_ans = 0
if n==1:
if s != t:
print(2)
else:
print(1)
else:
for i in range(n):
if s[i:n] == t[0:n-i]:
max_ans = max(n-i,max_ans)
print(max_ans+(n-max_ans)*2)
|
p03328 | s083318036 | Accepted | a, b = map(int, input().split())
k = b - a
print(k*(k+1) // 2 - b) |
p03062 | s530214363 | Wrong Answer | from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,copy
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
n = inp()
a = inpl()
a = [abs(x) for x in a]
a.sort()
a[0] = -a[0]
print(sum(a)) |
p03012 | s117526777 | Wrong Answer | n = int(input())
ws = list(map(int, input().split()))
mn = 10**4
for i in range(n):
t = i+1
a,b = [],[]
if ws[i] > t:
a.append(ws[i])
else:
b.append(ws[i])
mn = min(mn, abs(sum(a)-sum(b)))
print(mn) |
p02993 | s720842790 | Accepted | s = input()
if s[0] == s[1] or s[1] == s[2] or s[2] == s[3]:
print('Bad')
else:
print('Good')
|
p02833 | s665846369 | Accepted | from collections import defaultdict, deque
import sys, heapq, bisect, math, itertools, string, queue, copy, time
from fractions import gcd
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7
EPS = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
n = int(input())
digi = len(str(n))
ans = 0
if not bool(n&1):
for i in range(1,50):
ans += n//(5**i)//2
print(ans)
|
p03000 | s665567634 | Accepted | n, x = list(map(int, input().split()))
# a = list(map(int, input().split()))
# data = [list(map(int, input().split())) for i in range(n)]
# k = int(input())
L = list(map(int, input().split()))
# ab_sorted = sorted(ab, key=lambda x: x[0])
#ab = [list(map(int, input().split())) for i in range(n)]
# print(min(15*n, 100*(n//10+1), 100*(n//10)+15*(n % 10)))
d = 0
count = 1
for l in L:
if d+l > x:
break
else:
d = d+l
count += 1
print(count)
|
p02982 | s236213681 | Accepted | n, d = map(int,input().split())
point = []
ans = 0
for i in range(n):
point.append(list(map(int,input().split())))
for i in range(n+1):
for j in range(i+1, n):
dist = 0
for k in range(d):
dist += (point[i][k] - point[j][k])**2
ans_dist = dist ** 0.5
int_ans_dist = int(ans_dist)
if ans_dist == int_ans_dist:
ans += 1
print(ans)
|
p03131 | s698651032 | Accepted | k, a, b = map(int, input().split())
print(max(k+1, (k-a+1)//2*(b-a)+a+(k-a+1)%2)) |
p03324 | s119224082 | Wrong Answer | def resolve():
D, N = [int(i) for i in input().split()]
if D == 0:
print(N + (N) // 100)
return
print(100**D * N)
resolve()
|
p03680 | s276953699 | Accepted | n=int(input())
a=[int(input()) for i in range(n)]
cnt=0
button=0
flag=False
#ボタン1が最初光っている(インデックスは0)
for i in range(n):
#ボタンを押す
cnt+=1
button=a[button]-1
if button==1:
flag=True
break
if flag:
print(cnt)
else:
print(-1) |
p03359 | s961833672 | Accepted | a,b = map(int,input().split())
print(a-1 if b<a else a) |
p03352 | s191166810 | Accepted | import math
X = int(input())
sq = int(math.sqrt(X))
candidates = [1]
for b in range(2, sq+1):
p = 2
tmp = b ** p
while tmp <= X:
candidates.append(tmp)
p += 1
tmp = b ** p
print(sorted(candidates)[-1])
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.