problem_id stringclasses 428
values | submission_id stringlengths 10 10 | status stringclasses 2
values | code stringlengths 5 816 |
|---|---|---|---|
p02606 | s732754146 | Wrong Answer | L, R, d = map(int, input().split())
print('{(R-L)//d} + 1')
|
p02946 | s645388179 | Accepted | K, X = map(int, input().split())
L = []
for i in range(K):
num = X+i
L.append(num)
for j in range(K-1):
num = (X-1) - j
L.append(num)
L2 = sorted(L)
print(*L2) |
p02622 | s244534675 | Accepted | S = input()
T = input()
cnt = 0
for i in range(len(S)):
if(S[i] != T[i]):
cnt += 1
print(cnt) |
p03371 | s860497484 | Wrong Answer | a,b,c,x,y = map(int,input().split())
if a+b<=2*c:#そのまま買えばいいとき
print(x*a+y*b)
else:#ABピザを買ったほうが安くなる場合
if a*x+b*y<2*c*max(x,y):
cnt=2*c*min(x,y) #ABピザを買えるだけ買う
if x<y: cnt+=b*(y-x)
elif x>y: cnt+=a*(x-y)
else:
cnt=2*c*max(x,y)
print(cnt) |
p03127 | s648509178 | Accepted | n = int(input())
a = list(map(int,input().split()))
a.sort()
b = a
while(1):
c = [b[0]]
for i in range(1,len(b)):
if b[i] % b[0]:
c.append(b[i]%b[0])
b = sorted(c)
if len(b) == 1:
print(b[0])
exit() |
p02730 | s810628664 | Wrong Answer | s= input()
z=len(s)//2
flag=0
sd=s[0:z-1]
if len(s)==3:
if s[0]==s[2]:
flag=1
else:
if sd==s[z+1:len(s)-1]:
if sd==sd[::-1]:
flag=1
if flag==1:
print("Yes")
else:
print("No") |
p03799 | s126084306 | Accepted | n, m = map(int, input().split())
if n*2 < m:
print((2*n+m)//4)
else:
print(m//2)
|
p03013 | s746068852 | Accepted | INF = 10 ** 9 + 7
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
dp = [0] * (N + 1)
for i in range(M):
dp[a[i]] = -1
dp[0] = 1
for i in range(1, N + 1):
if dp[i] == -1: continue
tmp = 0
if dp[i - 1] != -1:
tmp += dp[i - 1]
if dp[i - 2] != -1 and i > 1:
tmp += dp[i - 2]
dp[i] = tmp % INF
print(dp[N]) |
p03328 | s131037815 | Wrong Answer | import bisect
a, b = map(int, input().split())
towers = []
last = 0
for i in range(1, 1000):
towers.append(last+i)
last += i
i = bisect.bisect_left(towers, a)
print(towers[i] - a) |
p02615 | s332163940 | Accepted | N = int(input())
A = list(map(int,input().split()))
A.sort()
A = A[::-1]
ans = 0
if N%2==0:
for i in range(N//2):
if i==0:
ans += A[i]
else:
ans += 2*A[i]
else:
for i in range(N//2):
if i==0:
ans += A[i]
else:
ans += 2*A[i]
ans += A[N//2]
print(ans) |
p03281 | s131308463 | Accepted | n = int(input())
lp = []
for i in range(3,int(n//2)+1):
for k in lp:
if i%2 == 0 or i%k == 0:
break
else:
lp.append(i)
ans = 0
for i in (range(n)):
li = []
for k in lp:
tmp = i+1
cnt = 0
while tmp%k == 0:
tmp //= k
cnt += 1
if cnt > 0:
li.append(cnt)
if li in [[1,1,1], [1,3], [3,1], [7]]:
ans += 1
print(ans) |
p03407 | s176410200 | Wrong Answer | #!/usr/bin/env python3
a, b, c = map(int, input().split())
if a + b*2 >= c:
print("Yes")
else:
print("No") |
p03386 | s886894089 | Accepted | a, b, k = map(int, input().split())
res = set()
for i in range(a, a + k):
res.add(min(b, i))
for i in range(b, b - k, -1):
res.add(max(a, i))
res = sorted(list(res))
for i in range(len(res)):
print(res[i])
|
p02621 | s033779726 | Wrong Answer | a=int(input())
print(a*+a*a+a**3)
|
p02756 | s009382211 | Accepted | from collections import deque
s=deque(input())
q=int(input())
flag = 2
for i in range(q):
query=input().split()
if query[0] == "1":
flag = 3 - flag
elif int(query[1]) - flag :
s.appendleft(query[2])
else:
s.append(query[2])
if flag-2:
s.reverse()
print("".join(s))
|
p03986 | s468451531 | Wrong Answer | s = input()
n = len(s)
for i in range(1, n+1):
if s[-i] == 'T':
index = n-i
break
print((n-index-1)*2) |
p02623 | s928135061 | Accepted | from bisect import bisect_right
N,M,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
a=[0]*N
b=[0]*M
a[0]=A[0]
b[0]=B[0]
for i in range(N-1):
a[i+1]=a[i]+A[i+1]
for i in range(M-1):
b[i+1]=b[i]+B[i+1]
book=bisect_right(b,K)
for i in range(N):
if a[i]>K:
break
j=bisect_right(b,K-a[i])
book=max(book,(i+1)+j)
print(book) |
p02622 | s294818293 | Accepted | S = input()
T = input()
tmp = 0
for i in range(len(S)):
if S[i] == T[i]:
pass
else:
tmp += 1
print(tmp) |
p02747 | s507263853 | Accepted | S = input()
list_s = ["hi","hi"*2,"hi"*3,"hi"*4,"hi"*5]
if list_s.count(S) == 1:
print("Yes")
else:
print("No") |
p02595 | s386766556 | Accepted | N,D = map(int,input().split())
count = 0
for i in range(N):
X,Y = map(int,input().split())
n = (X**2+Y**2)**0.5
if n <=D:
count +=1
print(count)
|
p03328 | s805482098 | Wrong Answer | a, b = map(int, input().split())
x = [i *(i + 1) // 2 for i in range(1, 1000)]
for i in x:
if a < i < b:
print(i - a)
break
|
p02695 | s139452261 | Wrong Answer | #dfs試す
#挙動追うのきつい
n,m,q=map(int, input().split( ))
qs=tuple(tuple(map(int, input().split( ))) for _ in range(q))
def dfs(ll):
if len(ll)==n+1:
sm=0
for ai,bi,ci,di in qs:
if ll[bi]-ll[ai]==ci:
sm+=di
return sm
res=[]
for i in range(ll[-1],m+1):
ll2=ll+[i]
res.append(dfs(ll2))
return(max(res))
l=[0]
print(dfs(l))
|
p02607 | s369910318 | Accepted | import math
import collections
import fractions
import itertools
import functools
import operator
def solve():
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n):
if (i+1) % 2 == 1 and a[i] % 2 == 1:
ans += 1
print(ans)
return 0
if __name__ == "__main__":
solve()
|
p03767 | s855935296 | Accepted | N = int(input())
A = list(map(int,input().split()))
A.sort(reverse= True)
ans = 0
for i in range(N*2):
if i%2 == 1:
ans += A[i]
print(ans) |
p02659 | s568449633 | Accepted | import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7
s = rs()
A, B = s.split()
A = int(A)
B = int(B.replace('.',''))
print(A*B//100)
|
p02681 | s093531744 | Accepted | from collections import *
S = input()
T = input()
if S==T[:-1]:
print('Yes')
else:
print('No') |
p03557 | s648603043 | 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())))
cnt=0
for i in range(n):
A = bisect.bisect_left(a, b[i])
C = n-bisect.bisect_right(c, b[i])
cnt+=A*C
print(cnt) |
p03693 | s132900733 | Wrong Answer | r,g ,b=map(int,input().split())
A=100*r+10*g+b
if A%4==0 :
print("Yes")
else :
print("No") |
p03407 | s195810460 | Accepted | A,B,C = map(int,input().split())
if A+B>=C:
print("Yes")
else:
print("No") |
p04045 | s399351609 | Accepted | n, k = map(int, input().split())
D = list(map(str, input().split()))
money = n
ok = True
while True:
for d in D:
if d in str(money):
ok = False
break
if ok:
print(money)
break
money += 1
ok = True |
p02690 | s734948863 | Wrong Answer | import math
def main():
X = int(input())
v = int(pow(X, 0.25)) + 1
for A in range(-v, v+1):
c = pow(A, 5)
for B in range(-v, v+1):
if c - pow(B, 5) == X:
return A, B
return -1
if __name__ == '__main__':
print(main())
|
p04043 | s797256748 | Accepted | s = input().split()
fiveCNT = 0
sevenCNT = 0
if s[0] == '5':
fiveCNT = fiveCNT + 1
elif s[0] == '7':
sevenCNT = sevenCNT + 1
if s[1] == '5':
fiveCNT = fiveCNT + 1
elif s[1] == '7':
sevenCNT = sevenCNT + 1
if s[2] == '5':
fiveCNT = fiveCNT + 1
elif s[2] == '7':
sevenCNT = sevenCNT + 1
if fiveCNT == 2 and sevenCNT == 1:
print('YES')
else:
print('NO')
|
p03437 | s498733535 | Accepted | x,y=map(int,input().split())
if x%y==0:
print(-1)
else:
if x*(y+1)<=10**18:
print(x*(y+1))
else:
print(-1) |
p02699 | s739626987 | Accepted | s,w= map(int,input().split())
if w>=s:
print("unsafe")
else:
print("safe") |
p03345 | s885149006 | Wrong Answer | # import math
# import statistics
#a=input()
#b,c=int(input()),int(input())
# c=[]
# for i in a:
# c.append(i)
e1,e2,e3 ,e4= map(int,input().split())
#K = input()
# f = list(map(int,input().split()))
#g = [input() for _ in range(a)]
if e4%2==0:
print(-(e1-e2))
elif e4%2==1:
print(e1-e2)
elif abs(e1-e2)>=10**18:
print("Unfair") |
p03274 | s877754279 | Wrong Answer | n,k = map(int, input().split())
X = list(map(int, input().split()))
ans = 10**8
for i in range(n-k+1):
l = X[i]
r = X[i+k-1]
ans = min(ans, r-l+min(abs(l), abs(r)))
print(ans) |
p03617 | s999936271 | Accepted | sizePrice = list(map(int, input().split()))
N = int(input())
oneLMin = min([sizePrice[0] * 4, sizePrice[1] * 2, sizePrice[2]])
twoLMin = min([oneLMin*2, sizePrice[3]])
ans = 0
if N % 2 == 0:
ans = twoLMin * (N//2)
else:
ans = twoLMin * ((N - 1)//2) + oneLMin
print(ans)
|
p02598 | s386626071 | Wrong Answer | n,k=map(int,input().split())
A=list(map(int,input().split()))
l=0
r=max(A)+1
while r-l>1:
m=(l+r)//2
cut=0
for i in range(n):
cut+=((A[i]+m-1)//m)-1
if cut>k:
l=m
else:
r=m
print(m)
|
p03013 | s268281180 | Accepted | mod = 1000000007
n,m = map(int,input().split())
ab = []
for _ in range(m):
a=int(input())
ab.append(a)
ab = set(ab)
memo = [0]*(n+1)
memo[0] = 1
for i in range(1,n+1):
memo[i] = (memo[i-1]+memo[i-2])%mod
if i in ab:
memo[i] = 0
#print(memo)
print(memo[-1])
|
p02712 | s446664637 | Wrong Answer | N = int(input())
ans = 0
for i in range(1,N):
if i % 3 != 0 and i % 5 != 0:
ans += i
print(ans) |
p03162 | s908895749 | Accepted | N = int(input())
abc = [list(map(int, input().split())) for _ in range(N)]
dp = [[0,0,0] for _ in range(N+1)]
for i in range(1,N+1):
dp[i][0] = max(dp[i-1][1] + abc[i-1][0], dp[i-1][2] + abc[i-1][0])
dp[i][1] = max(dp[i-1][0] + abc[i-1][1], dp[i-1][2] + abc[i-1][1])
dp[i][2] = max(dp[i-1][0] + abc[i-1][2], dp[i-1][1] + abc[i-1][2])
print(max(dp[N])) |
p02718 | s511921804 | Wrong Answer | import sys
a = list(map(int,input().split()))
b = list(map(int,input().split()))
N = a[0]
M = a[1]
count = 0
b_sum = sum(b)
for i in range(0,N-1):
if b[i] >= (b_sum/(4*M)):
count+=1
if count >= M:
print('Yes')
else:
print('No')
|
p02624 | s205866537 | Wrong Answer | N = int(input())
import math
truelist = [0]
def getlist(x):
list = []
for i in range(1,x+1):
if x%i == 0 and (not i in list):
list.append(i)
return len(list)
tlist = getlist(N)
for i in range(1,int(math.sqrt(N))+2):
t = getlist(i)
if math.sqrt(i) != int(math.sqrt(i)):
t *= 2
else:
t *= 2
t -= 1
truelist.append(t*i)
print(sum(truelist))
|
p03281 | s329661195 | Accepted | N = int(input())
def divisor_all(n): # 約数全列挙
l = [1,n]
for i in range(2,int(pow(n,1/2))+1):
if n % i == 0:
if i == n//i:
l.append(i)
else:
l.append(i)
l.append(n//i)
l.sort()
return l # list
ans = 0
for i in range(1,N+1,2):
if len(divisor_all(i))==8:
ans += 1
print(ans) |
p02660 | s448077337 | Accepted | n = int(input())
p = []
n2 = n
for i in range(2,int(n2**0.5//1 + 1)):
index = 0
while n2%i == 0:
index+=1
n2 = n2//i
if index != 0:
p.append(index)
else:
continue
count = 0
t = 1
if n2 == 1:
next
else:
count+=1
if n == 1:
print(0)
elif not p:
print(1)
else:
for i in range(len(p)):
while p[i] - t >= 0:
p[i]-=t
count+=1
t+=1
t = 1
print(count) |
p03437 | s574810823 | Wrong Answer | X,Y = map(int,input().split())
while X < 10**18:
X *= 2
if X%Y != 0:
print(X)
exit()
else:
continue
print(-1) |
p02584 | s042923127 | Wrong Answer | x, k, d = map(int,input().split())
# 移動制限がないときの最小値
m = x % d
# mを得るために必要な最小の移動回数
n = x // d
if k <= n:
print(x - k * d)
exit()
k -= n
if k % 2 == 0:
print(m)
else:
print(min(abs(m - d), m + d)) |
p02939 | s942932702 | Accepted | S = list(str(input()))
i=1
count = 0
while i < len(S):
if S[i] == S[i-1]:
count += 1
i += 2
i += 1
print(len(S)-count)
|
p03545 | s540268487 | Accepted | a, b, c, d = (int(i) for i in input())
op = ["+", "-"]
for op_1 in op:
ans_1 = eval("{}{}{}".format(a, op_1, b))
for op_2 in op:
ans_2 = eval("{}{}{}".format(ans_1, op_2, c))
for op_3 in op:
if eval("{}{}{}".format(ans_2, op_3, d)) == 7:
print("{}{}{}{}{}{}{}=7".format(a, op_1, b, op_2, c, op_3, d))
exit() |
p02772 | s519894013 | Accepted | n=int(input())
a = list(map(int, input().split()))
for i in a:
if i%2==0 and i%3 and i%5:
print('DENIED')
exit()
else:
print('APPROVED') |
p02771 | s409324843 | Accepted | import sys
read = sys.stdin.readline
import time
import math
import itertools as it
def inp():
return int(input())
def inpl():
return list(map(int, input().split()))
start_time = time.perf_counter()
# ------------------------------
A = inpl()
A.sort()
if A[0]!=A[2]:
if A[0]==A[1]:
print('Yes')
sys.exit()
if A[1]==A[2]:
print('Yes')
sys.exit()
print('No')
# -----------------------------
end_time = time.perf_counter()
print('time:', end_time-start_time, file=sys.stderr) |
p03435 | s317584045 | Wrong Answer | l=[list(map(int,input().split())) for i in range(3)]
sum_l=0
ans="No"
for i in l:
sum_l+=sum(i)
if sum_l%3==0:
ans="Yes"
print(ans)
|
p03761 | s203632292 | Wrong Answer | from collections import Counter
N = int(input())
s = list(input())
c = Counter(s)
for _ in range(N - 1):
s = list(input())
tmp = Counter(s)
for k, v in c.items():
if k not in tmp:
c[k] = 0
else:
c[k] = min(c[k], v)
ans = ""
c = sorted(c.items(), key=lambda x: x[0])
for k, v in c:
ans += k * v
print(ans)
|
p03042 | s501461267 | Accepted | s = input()
if (1 <= int(s[0:2]) and int(s[0:2]) <= 12) and (1 <= int(s[2:4]) and int(s[2:4]) <= 12):
ans = "AMBIGUOUS"
elif (1 <= int(s[0:2]) and int(s[0:2]) <= 12) and (1 > int(s[2:4]) or int(s[2:4]) > 12):
ans = "MMYY"
elif (1 > int(s[0:2]) or int(s[0:2]) > 12) and (1 <= int(s[2:4]) and int(s[2:4]) <= 12):
ans = "YYMM"
else:
ans = "NA"
print (ans)
|
p02584 | s116633626 | Accepted | x, k, d = list(map(int, input().split()))
x = abs(x)
if k * d <= x:
print(x - k * d)
else:
k -= x//d
x %= d
if k % 2 == 0:
print(x)
else:
print(abs(x-d))
|
p03910 | s080370355 | Wrong Answer | N=int(input())
a=1
cnt=1
while cnt<=N:
a+=1
cnt+=a
A=[]
S=N
for i in range(a):
if S==3:
A.append(2)
A.append(1)
break
if S>=(a-i):
A.append(a-i)
S-=(a-i)
for i in (A[::-1]):
print(i) |
p02724 | s270954806 | Accepted | X = int(input())
answer = (X // 500) * 1000
X %= 500
answer += (X // 5) * 5
print(answer) |
p03449 | s708849720 | Accepted | N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = [0] * N
C[0] = A[0] + sum(B)
for i in range(1,N):
C[i] = C[i-1]+A[i]-B[i-1]
print(max(C))
|
p02995 | s398208117 | Accepted | def gcd(a, b):
while b:
a, b = b, a%b
return a
def lcm(a, b):
return a // gcd(a, b) * b
A, B, C, D = map(int, input().split())
L = lcm(C, D)
def f(X):
return X - (X//C + X//D - X//L)
num = f(B) - f(A-1)
print(num)
|
p03611 | s066384957 | Accepted | from sys import stdin
def main():
#入力
readline=stdin.readline
n=int(readline())
a=list(map(int,readline().split()))
li=[0]*(10**5+2)
for i in range(n):
li[a[i]]+=1
cnt=0
for x in range(1,10**5+1):
cnt=max(cnt,li[x-1]+li[x]+li[x+1])
print(cnt)
if __name__=="__main__":
main() |
p03043 | s216506199 | Accepted | N,K=map(int,input().split())
ans=0
for i in range(1,N+1):
score=i
cnt=0
while(K>score):
score=score*2
cnt+=1
ans+=(1/N)*(0.5**cnt)
print("{:.12f}".format(ans)) |
p04030 | s799992906 | Accepted | s_list = list(map(str, input().rstrip()))
ans = []
for s in s_list:
if s=="0":
ans.append("0")
elif s=="1":
ans.append("1")
elif s=="B":
if len(ans)==0:
continue
else:
ans.pop()
print("".join(ans)) |
p03478 | s400173213 | Accepted | def main():
def reviewSum(n):
sum = 0
while n > 0:
sum += n % 10
n = n // 10
return sum
N, A, B = map(int, input().split())
total = 0
for i in range(N + 1):
sum = reviewSum(i)
if sum >= A and sum <= B:
total += i
print(total)
main() |
p02647 | s336131508 | Accepted | n,k,*l=map(int,open(0).read().split())
for _ in range(k):
s=[0]*(n+1)
for i in range(n):
s[max(i-l[i],0)]+=1
s[min(i+l[i]+1,n)]-=1
s[0]=min(s[0],n)
for i in range(1,n):
s[i]=min(s[i-1]+s[i],n)
s.pop()
if s==l: break
l=s
print(*l) |
p03241 | s847006283 | Accepted | def make_divisors(n):
divisors = []
for i in range(1, int(n**0.5)+1):
if n % i == 0:
divisors.append(i)
if i != n // i:
divisors.append(n//i)
divisors.sort()
return divisors
n, m = map(int, input().split())
ans = 1
div = make_divisors(m)
for i in div:
if i * n <= m:
ans = i
else:
break
print(ans) |
p02708 | s498490949 | Accepted | from heapq import heappush, heappop
from itertools import permutations, accumulate, combinations
import math
import bisect
import numpy as np
from collections import defaultdict, deque
from operator import itemgetter
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
MOD = 10**9 + 7
def main():
n, k = map(int, input().split())
ans = 0
for i in range(k, n + 2):
ans += i * (n - i + 1) + 1
print(ans%MOD)
if __name__ == '__main__':
main() |
p04019 | s029886540 | Accepted | # A - Wanna go back home
def can_go_home(dir1, dir2):
if dir1 > 0 and dir2 > 0:
return True
elif dir1 == 0 and dir2 == 0:
return True
else:
return False
n, w, s, e = 0, 0, 0, 0
for dir in input():
if dir == 'N':
n += 1
elif dir == 'W':
w += 1
elif dir == 'S':
s += 1
else:
e += 1
if can_go_home(n, s) and can_go_home(e, w):
print('Yes')
else:
print('No') |
p02705 | s189758834 | Accepted | import math
r = int(input())
R = 2*r*math.pi
print(R)
|
p02748 | s524933634 | Accepted | A,B,M = [int(i) for i in input().split(' ')]
a = [int(i) for i in input().split(' ')]
b = [int(i) for i in input().split(' ')]
dis = [[int(i) for i in input().split(' ')] for j in range(M)]
ls = [min(a)+min(b)]
for d in dis:
ans = a[d[0]-1] + b[d[1]-1] - d[2]
ls.append(ans)
print(min(ls)) |
p02684 | s478871115 | Accepted | N, K = [int(x) for x in input().split()]
dest = [int(x) for x in input().split()]
route = [1]
flag = [1] + [0] * (N-1)
t = 1
while True:
if flag[dest[t-1]-1] == 0:
t = dest[t-1]
route.append(t)
flag[t-1] = 1
else:
loop = route.index(dest[t-1])
L_loop = len(route) - loop
break
#print(route)
#print(flag)
ans = 0
if K < len(route):
ans = route[K]
else:
K = K - len(route)
ans = route[loop + (K % L_loop)]
print(ans) |
p02658 | s012756561 | Wrong Answer | input()
ans = 1
for i in map(int, input().split()):
ans *= i
if ans > 10**8:
print(-1)
exit()
print(ans) |
p03208 | s797595887 | Accepted | N, K = map(int, input().split())
H = []
for _ in range(N):
H.append(int(input()))
H = list(sorted(H))
r_min = 10 ** 10
for i in range(N-K+1):
n_min = H[i]
n_max = H[i+K-1]
r_min = min(r_min, n_max-n_min)
print(r_min)
|
p02795 | s562524183 | Wrong Answer | H = int(input())
W = int(input())
N = int(input())
print(N // max(H, W)) |
p02730 | s938111841 | Wrong Answer | S = input()
N = int(len(S))
A = "Yes"
n = N//2
m = n//2
for i in range(n):
if S[i] != S[N-1-i]:
A = "No"
break
for i in range(m):
if S[i] != S[m-1-i] or S[n+1+i] != S[N-1-i]:
A = "No"
break
print(A)
|
p03672 | s870875711 | Wrong Answer | S = str(input())
N = len(S)
def solve(S):
# S: 文字列
r = N % 2
for i in range((N+1)//2):
s = S[:N-(2*i+r)]
n = len(s)
if s[:(n//2)] == s[(n//2):]:
ans = N - (2 * i + r)
return ans
print(solve(S)) |
p03208 | s227337216 | Wrong Answer | n,k=map(int,input().split())
h=[]
for i in range(n):
h.append(int(input()))
h_sort=sorted(h)
print(min(h[j+k-1]-h[j] for j in range(n-k+1))) |
p02823 | s469989143 | Accepted | N,A,B = (int(x) for x in input().split())
if (B - A) % 2 == 0:
print((B-A)//2)
else:
if B - A == 1:
if A == 1 or B == N:
print('1')
else:
print('2')
else:
if A <= N-B:
print((A+B-1)//2)
else:
print((2*N-A-B+1)//2) |
p03543 | s478809328 | Accepted | n = input()
print('Yes' if n[0] == n[1] == n[2] or n[1] == n[2] == n[3] else 'No')
|
p03471 | s673802162 | Wrong Answer | N, Y = [int(i) for i in input().split()]
ans = []
for i in range(N+1):
for j in range(N+1):
if 10000*i + 5000*j + 1000*(N-i-j) == Y:
ans.append([i, j, N-i-j])
if len(ans) == 0:
print(-1 -1 -1)
else:
print(ans[0][0], ans[0][1], ans[0][2])
|
p02897 | s340606547 | Accepted | def odd(num):
return num//2+num%2
N=int(input())
num = odd(N)/N
print("{:.10f}".format(num)) |
p02797 | s640507228 | Wrong Answer | n, k, s = list(map(int, input().split()))
if n == k:
print(s, " ", end="")
for i in range(n - 1):
print(0, " ", end="")
else:
j = k + 1
l = n - j
for i in range(int(j/2)):
print(1, " ", end="")
print(s - 1, " ", end="")
j -= 2
if j == 1:
print(1, " ", end="")
for i in range(l):
print(s-2, " ", end="")
|
p02713 | s233734696 | Wrong Answer | a=str(input())
if '7' in a:
print("Yes")
else:
print("No") |
p03309 | s455792443 | Accepted | n = int(input())
a = list(map(int, input().split()))
tmp = []
#b- (a-1)
for i in range(1, n+1):
tmp.append(a[i-1] - i)
tmp.sort()
#print(tmp)
b = tmp[n//2]
ans = 0
for i in range(1, n+1):
ans += abs(a[i-1] - (b+i))
print(ans) |
p03380 | s116018387 | Wrong Answer | import numpy as np
N = int(input())
M, *A = sorted(map(int, input().split()), reverse=True)
if N == 2:
print(M, *A)
quit()
A = np.abs(np.array(A, dtype=np.int64) - M / 2)
A.sort()
print(M, int(A[0] + M / 2))
|
p03386 | s448464044 | Accepted | a,b,k=map(int,input().split())
c,d=set(range(a,a+k)),set(range(b-k+1,b+1))
if b-a>=k:
e=c|d
else:
e=c&d
for i in sorted(e):
print(i) |
p03107 | s393562382 | Accepted | S=input()
N=len(S)
st=[]
for str in S:
#print(st,str)
if len(st)==0:
st.append(str)
else:
if str!=st[-1]:
st.pop()
else:
st.append(str)
print(N-len(st)) |
p02744 | s163297001 | Accepted | n = int(input())
s = ['' for i in range(n)]
def dfs(k, c):
if k == n:
print("".join(s))
return
for i in range(c):
s[k] = chr(i+ord('a'))
dfs(k+1, c)
s[k] = chr(c+ord('a'))
dfs(k+1, c+1)
dfs(0, 0) |
p03419 | s469188292 | Wrong Answer | # -*- coding: utf-8 -*-
# 標準入力の取得
N, M = list(map(int, input().split()))
# 求解処理
result = max((N - 2) * (M - 2), 0)
# 結果出力
print(result)
|
p03293 | s619149246 | Wrong Answer | s = list(input())
t = list(input())
if sorted(s) == sorted(t):
print('Yes')
else:
print('No')
|
p03971 | s000837343 | Wrong Answer | x = list(map(int,input().split()))
n = x[0]
a = x[1]
b = x[2]
s = input()
c = 0
k = 0
for i in range(0,n):
if(s[i] == "c"):
print("No")
continue
elif(s[i] == "a"):
if(c < a + b):
print("yes")
c = c + 1
else:
print("No")
else:
if(c < a + b and k < b):
print("Yes")
c = c + 1
k = k + 1
else:
print("No") |
p02688 | s242780936 | Accepted | import itertools
N,K=map(int,input().split())
d=[]
A=[]
for i in range(K):
d.append(int(input()))
A.append(list(map(int,input().split())))
A=list(itertools.chain.from_iterable(A))
count=0
for i in range(1,N+1):
if not i in A:count+=1
print(count) |
p03679 | s382932235 | Accepted | X,A,B=map(int,input().split())
if (A-B)>=0:
print('delicious')
elif (A-B)<0 and (X-B+A)>=0:
print('safe')
else:
print('dangerous') |
p03659 | s982825655 | Accepted | n = int(input())
a = list(map(int, input().split()))
left = a[0]
right = sum(a[1:])
ans = abs(left - right)
for i in range(1, n-1):
left += a[i]
right -= a[i]
ans = min(ans, abs(left-right))
print(ans)
|
p03971 | s427344202 | Accepted | n, a, b = map(int,input().split())
s = input()
c = 0
d = 0
for i in range(len(s)):
if s[i] == "a" and c < a+b:
print("Yes")
c += 1
elif s[i] == "b" and d < b and c < a+b:
print("Yes")
d += 1
c += 1
else:
print("No") |
p03835 | s131867040 | Wrong Answer | K, S = map(int, input().split())
count = 0
for x in range(1,K+1):
for y in range(1,K+1):
for z in range(1,K+1):
if x + y + z == S:
count = count + 1
print(count) |
p03037 | s990529073 | Wrong Answer | N,M=map(int,input().split())
LR=[]
for i in range(M):
LR.append(list(map(int,input().split())))
l,r=LR[0][0],LR[0][1]
for i in range(M):
if LR[i][0]<l and LR[i][1]<r:
r=LR[i][1]
elif l<LR[i][0] and LR[i][1]<r:
l,r=LR[i][0],LR[i][1]
elif l<LR[i][0] and r<LR[i][1]:
l=LR[i][0]
print(r-l+1) |
p02917 | s968119291 | Accepted | N=int(input())
B=[int(x)for x in input().split()]
A=[B[0]]
for i in range(1,N-1):
A.append(min(B[i-1],B[i]))
A.append(B[-1])
print(sum(A))
|
p02606 | s050199863 | Accepted | l,r,d=map(int,input().split())
ans=0
for i in range(l,r+1):
if i%d==0:
ans+=1
print(ans) |
p02946 | s101195995 | Accepted | K,X=map(int,input().split())
print(*[x for x in range(X-K+1,X+K)]) |
p03624 | s727163892 | Accepted | s = set(input())
letters = set("abcdefghijklmnopqrstuvwxyz")
ans = sorted(letters ^ s)
print(ans[0] if len(ans) != 0 else "None")
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.