problem_id
stringclasses 428
values | submission_id
stringlengths 10
10
| status
stringclasses 2
values | code
stringlengths 5
816
|
|---|---|---|---|
p04034
|
s523212945
|
Accepted
|
n, m = map(int, input().split())
xy = [list(map(int, input().split())) for i in range(m)]
ans = [0 for i in range(n)]
balls = [1 for i in range(n)]
ans[0] = 1
for x, y in xy:
x -= 1
y -= 1
if ans[x] == 1 and balls[x] > 0:
ans[y] = 1
if balls[x] > 0:
balls[x] -= 1
balls[y] += 1
if balls[x] == 0:
ans[x] = 0
print(sum(ans))
|
p03360
|
s815110491
|
Accepted
|
(*abc,) = map(int, input().split())
print(sum(abc) + max(abc) * ((2 ** int(input())) - 1))
|
p03481
|
s819217958
|
Accepted
|
X,Y = list(map(int, input().split()))
ans = 0
while X<=Y:
X*=2
ans+=1
print(ans)
|
p02854
|
s791547251
|
Accepted
|
n = int(input())
a = list(map(int, input().split()))
mm = 10**18
s = sum(a)
l, r = 0, 0
for i in range(n):
l += a[i]
r = s - l
mm = min(mm, abs(l-r))
print(mm)
|
p03835
|
s989063368
|
Wrong Answer
|
K, S = map(int, input().split())
res = 0
for ed in range(min(S, K), -1, -1):
res += (S-ed+1)*(S-ed)//2 # Σ^n{k} = n*(n+1)/2
print(res)
|
p02838
|
s348866034
|
Wrong Answer
|
import sys
import numpy as np
input = sys.stdin.readline
P = 10 ** 9 + 7
def main():
N = int(input())
A = list(map(int, input().split()))
A = np.array(A)
B = 61
ans = 0
for b in range(B):
cnt_1 = np.sum((A >> b) & 1)
ans += 2 ** b * cnt_1 * (N - cnt_1)
ans %= P
print(ans)
if __name__ == "__main__":
main()
|
p02595
|
s378965023
|
Accepted
|
n,d = map(int,input().split())
ans = 0
for i in range(n):
x,y = map(int,input().split())
if x**2+y**2 <= d**2:
ans += 1
print(ans)
|
p03126
|
s848285617
|
Wrong Answer
|
N,M = map(int,input().split())
l = [list(map(int,input().split())) for i
in range(N)]
for i in range(N):
del l[i][0]
if N!=1:
for i in range(N-1):
a = set(l[i])&set(l[i+1])
l[i+1] = a
print(len(a))
else:
print(len(l))
|
p03105
|
s360488588
|
Accepted
|
a,b,c = map(int,input().split())
print (c) if a*c <= b else print (b//a)
|
p03456
|
s642363983
|
Accepted
|
import math
a, b = map(int, input().split())
x = int(str(a) + str(b))
if math.sqrt(x) == math.ceil(math.sqrt(x)):
print("Yes")
else :
print("No")
|
p02742
|
s755605710
|
Wrong Answer
|
from sys import stdin
import math
h, w = [int(x) for x in stdin.readline().rstrip().split()]
if h % 2 == 0:
print(int(h * w / 2))
elif w % 2 == 0:
print(int(h * w / 2))
else:
print(int(h * w / 2 + 1))
|
p03160
|
s066106907
|
Accepted
|
II = lambda: int(input())
SI = lambda: input()
LI = lambda: list(map(int,input().split()))
MI = lambda: map(int,input().split())
n = II()
a = LI()
d = [0]*n
d[1] = abs(a[1]-a[0])
for i in range(2,n):
d[i] = min(d[i-1]+abs(a[i-1]-a[i]),d[i-2]+abs(a[i-2]-a[i]))
print(d[-1])
|
p02705
|
s213665123
|
Accepted
|
import math
radius = int(input())
ans = 2*radius*math.pi
print(ans)
exit()
|
p03161
|
s843095184
|
Accepted
|
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n,k = map(int,readline().split())
h = list(map(int,readline().split()))
dp = [float('inf')]*n
dp[0] = 0
for i in range(1,n):
for j in range(min(k,i)):
dp[i] = min(dp[i], dp[i-1-j]+abs(h[i]-h[i-1-j]))
print(dp[n-1])
|
p02547
|
s313568129
|
Wrong Answer
|
import sys
n = int(input())
x = 0
for i in range(n):
d1, d2 = map(int, input().split())
if d1 != d2:
x = 0
else:
x += 1
if x == 3:
print("Yes")
sys.exit
if x != 3:
print("No")
|
p02866
|
s593066138
|
Accepted
|
from collections import Counter
n = int(input())
D = list(map(int,input().split()))
Dc = Counter(D)
mod = 998244353
ans = 1
if Dc[0]!=1 or D[0]!=0:
print(0)
else:
for i in range(max(D)):
ans = ans*pow(Dc[i],Dc[i+1])%mod
print(ans%mod)
|
p02658
|
s556113137
|
Accepted
|
input();a=1;d=eval('1'+'0'*18)
for i in input().split():a=min(a*int(i),d+1)
print([a,-1][a>d])
|
p03252
|
s317276849
|
Accepted
|
import collections
S = input()
T = input()
if sorted(collections.Counter(S).values()) == sorted(collections.Counter(T).values()):
print("Yes")
else:
print("No")
|
p02988
|
s775978662
|
Accepted
|
_,p=open(0)
*p,=map(int,p.split())
print(sum(a<b<c or c<b<a for a,b,c in zip(p,p[1:],p[2:])))
|
p03821
|
s628680500
|
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()
cnt = 0
for i in range(N):
cnt += -(A[i]+cnt)%B[i]
print(cnt)
|
p03681
|
s318699623
|
Accepted
|
n, m = map(int, input().split())
mod = 10**9 + 7
if abs(n-m) > 1:
ans = 0
elif n == m:
ans = 2
for i in range(2, n+1):
ans = ans*i % mod
for i in range(2, m+1):
ans = ans*i % mod
else:
ans = 1
for i in range(2, n+1):
ans = ans*i % mod
for i in range(2, m+1):
ans = ans*i % mod
print(ans)
|
p02726
|
s854714884
|
Wrong Answer
|
n,x,y= map(int, input().split())
ans=[0]*n
for i in range(1,n):
for j in range(i+1,n+1):
ans[min(j-i,1+abs(i-x)+abs(j-y))-1]+=1
for i in range(n):
print(ans[i])
|
p03127
|
s735185654
|
Accepted
|
import fractions
N=int(input())
A=list(map(int,input().split()))
ans=A[0]
for i in range(N):
a=fractions.gcd(ans,A[i])
ans=a
print(ans)
|
p02582
|
s810007037
|
Accepted
|
S = input()
if 'RSR' in S:
print(1)
else:
print(S.count("R"))
|
p02714
|
s826581563
|
Accepted
|
N=int(input())
S=input()
ans,r,g,b=0,0,0,0
for s in S:
if s=='R':
r+=1
elif s=='G':
g+=1
elif s=='B':
b+=1
ans=r*g*b
for i in range(N-2):
a=S[i]
for j in range(i+1,N-1):
if 2*j-i>=N:
break
b,c=S[j],S[j+j-i]
if a!=b and b!=c and c!=a:
ans-=1
print(ans)
|
p03943
|
s929406646
|
Accepted
|
a = [int(i) for i in input().split()]
if max(a) == (sum(a)-max(a)):
print('Yes')
else:
print('No')
|
p02873
|
s537726041
|
Accepted
|
s=list(input())
m=len(s)
a=[0]*(m+1)
add=1
for i in range(m):
if s[i]=="<":
a[i+1]+=add
add+=1
else:
add=1
for i in range(m-1,-1,-1):
if s[i]==">" and a[i]<=a[i+1]:
a[i]+=a[i+1]-a[i]+1
print(sum(a))
|
p02947
|
s865835721
|
Accepted
|
N = int(input())
S = []
for i in range(N):
s = input()
ss = sorted(s)
S.append("".join(ss))
S.sort()
ans = 0
count = 0
for i in range(N-1):
if S[i] == S[i+1]:
count += 1
ans += count
else:
count = 0
print(ans)
|
p02861
|
s041994066
|
Wrong Answer
|
import math
import itertools
n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]
def distance(x1, y1, x2, y2):
return math.sqrt((x1 - x2)**2 + (y1 - y2)**2)
dist = 0
cnt = 0
for p in itertools.permutations(range(n)):
for i in range(n-1):
dist += distance(xy[i][0], xy[i][1], xy[i+1][0], xy[i+1][1])
cnt += 1
ans = dist / cnt
print(ans)
|
p03836
|
s523695829
|
Accepted
|
#import sys
#import numpy as np
#import math
#import itertools
#from fractions import Fraction
#import itertools
from collections import deque
#import heapq
#from fractions import gcd
#input=sys.stdin.readline
#import bisect
sx,sy,tx,ty=map(int,input().split())
h=ty-sy
w=tx-sx
ans=""
ans+="R"*w+"U"*h
ans+="L"*w+"D"*h
ans+="D"
ans+="R"*(w+1)+"U"*(h+1)+"L"
ans+="U"+"L"*(w+1)+"D"*(h+1)+"R"
print(ans)
|
p02578
|
s669779830
|
Wrong Answer
|
n = int(input())
a = list(map(int, input().split()))
ans = 0
prev = a[0]
for e in a:
if e - prev > 0:
ans += e - prev
prev = e
print(ans)
|
p02689
|
s796779884
|
Wrong Answer
|
n, m = map(int, input().split())
h = list(map(int, input().split()))
maxh = []
for height in h:
maxh.append(height)
for i in range(m):
a, b = map(int, input().split())
a, b = a-1, b-1
maxh[a] = max(maxh[a], h[b])
maxh[b] = max(maxh[b], h[a])
g = 0
for height, maxheight in zip(h, maxh):
if height == maxheight:
g += 1
print(g)
|
p03210
|
s740523175
|
Accepted
|
x = int(input())
print('YES' if x == 7 or x == 5 or x == 3 else 'NO')
|
p03106
|
s193442126
|
Wrong Answer
|
A,B,K = map(int,input().split())
result = []
for i in range(1,100,1):
if A%i == 0 and B%i == 0:
result.append(i)
print(result,result[-K])
|
p02732
|
s552870049
|
Wrong Answer
|
N = int(input())
A = [int(i) for i in input().split()]
print(A)
a = 0
for i in range(N):
tmp = A[:i]
tmp.extend(A[i+1:])
for j in range(N-2):
for k in range(N-1-j):
if tmp[j] == tmp[k]:
a += 1
print(a)
|
p02633
|
s307768212
|
Wrong Answer
|
X = int(input())
K = 360//X
if K*X < 360:
K = K+1
print(K)
|
p04029
|
s293482646
|
Accepted
|
N = int(input())
print(N * (N + 1) // 2)
|
p03086
|
s657151505
|
Accepted
|
def resolve():
S = input()
ans, cnt = 0, 0
for s in S:
if s == 'A' or s == 'C'or s == 'G' or s == 'T':
cnt += 1
else:
ans = max(ans, cnt)
cnt = 0
ans = max(ans, cnt)
print(ans)
resolve()
|
p03478
|
s239577968
|
Accepted
|
N,A,B = map(int,input().split())
count = 0
for n in range(1,N+1):
n = str(n)
l = []
for i in range(len(n)):
l.append(int(n[i]))
if A <= sum(l) <= B:
count += int(n)
print(count)
|
p02623
|
s945377615
|
Accepted
|
import sys
import numpy as np
input = lambda: sys.stdin.readline().rstrip()
def main():
n,m,k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
sa = np.cumsum([0]+a)
sb = np.cumsum([0]+b)
rx = 0
rb = m
for ra in range(0,n+1):
while (sb[rb] + sa[ra]) > k and rb>0 :
rb-=1
if (sb[rb] + sa[ra]) <= k:
rx = max(rx,ra+rb)
print(rx)
if __name__ == '__main__':
main()
|
p03475
|
s600545548
|
Wrong Answer
|
N = int(input())
station = [list(map(int, input().split())) for _ in range(N - 1)]
lst = []
for i in range(N - 1):
c, s, f = station[i]
for j in range(len(lst)):
a = lst[j]
if a >= s:
a += (a % f) + c
else:
a = s + c
lst[j] = a
lst.append(s + c)
lst.append(0)
for a in lst:
print(a)
|
p02553
|
s652300125
|
Accepted
|
a,b,c,d = tuple(map(int, input().split(" ")))
print(max(a*c, a*d, b*c, b*d))
|
p03419
|
s455305893
|
Accepted
|
N, M = map(int, input().split())
if N == M == 1:
print(1)
elif N == 1 or M == 1:
print(max(N - 2, M - 2))
else:
print((N - 2) * (M - 2))
|
p02555
|
s467865455
|
Wrong Answer
|
S = int(input())
mod = 10 ** 9 + 7
if S < 3:
print(0)
elif S < 6:
print(1)
elif S == 6:
print(2)
else:
cnt = 3
S -= 7
for i in range(1,S+1):
cnt += i
print(cnt % mod)
|
p03774
|
s121271513
|
Accepted
|
N,M=map(int, input().split())
S=[]
for i in range(N):
a,b=map(int, input().split())
S.append((a,b))
C=[]
for i in range(M):
c,d=map(int, input().split())
C.append((c,d,i+1))
#print(C)
for s in S:
a,b=s
now=0
dis=10**9
for t in C:
c,d,n=t
D=abs(c-a)+abs(d-b)
if D<dis:
dis=D
now=n
print(now)
|
p03061
|
s653561616
|
Accepted
|
import fractions
def main():
n = int(input())
A = [int(e) for e in input().split()]
G = [A[0]]
prev = A[0]
for i in range(1, n):
prev = fractions.gcd(prev, A[i])
G.append(prev)
ANS = [G[n - 2]]
prev = A[n - 1]
for i in range(n - 2, 0, -1):
ANS.append(fractions.gcd(G[i - 1], prev))
prev = fractions.gcd(A[i], prev)
ANS.append(prev)
print(max(ANS))
if __name__ == "__main__":
main()
|
p03075
|
s220353838
|
Accepted
|
a,b,c,d,e,k=[int(input()) for _ in range(6)]
print('Yay!' if k>=e-a else ':(')
|
p04034
|
s035920393
|
Accepted
|
n,m = [int(x) for x in input().split()]
x = []
for i in range(m):
x.append([int(x) for x in input().split()])
count = [1] * (n+1)
flag = [0] * (n+1)
flag[1] = 1
for i in range(m):
if flag[x[i][0]] == 1:
flag[x[i][1]] = 1
if count[x[i][0]] == 1:
flag[x[i][0]] = 0
count[x[i][0]] -= 1
count[x[i][1]] += 1
res = 0
for i in range(n+1):
if flag[i] == 1:
res += 1
print(res)
|
p03478
|
s963828730
|
Wrong Answer
|
n,a,b=map(int,input().rstrip().split(' '))
def count(n):
x = str(n)
sum=0
for s in x:
sum+=int(s)
return sum
ans=0
for i in range(1,n+1):
if(a <= count(i) and count(i) <=b):ans+=1
print(ans)
|
p03986
|
s943424998
|
Accepted
|
from collections import deque
X = input()
stack = deque([X[0]])
for i in range(1, len(X)):
if X[i] == 'S':
stack.appendleft(X[i])
if X[i] == 'T':
if stack:
check = stack.popleft()
if check == 'T':
stack.appendleft(check)
stack.appendleft(X[i])
else:
stack.appendleft(X[i])
print(len(stack))
|
p04030
|
s822343677
|
Accepted
|
s = input()
ans = []
for i in s:
if i == "1":
ans += [1]
elif i == "0":
ans += [0]
elif len(ans) > 0:
ans.pop(-1)
for x in ans:
print(x, end="")
|
p02641
|
s675945763
|
Accepted
|
x, n = map(int, input().split())
if n == 0:
print(x)
exit()
else:
p = list(map(int, input().split()))
li = [i for i in range(-101, 102) if i not in p]
li.sort(reverse = True)
tmp1 = float('inf')
ans = float('inf')
for i in li:
if abs(i - x) <= tmp1:
if i < ans:
ans = i
tmp1 = abs(i - x)
print(ans)
|
p02595
|
s516806397
|
Wrong Answer
|
N , D = map(int,input().split())
c = 0
for i in range(N):
x , y = map(int,input().split())
z = (x**2+y**2)**0.5
# print(z)
if D <= z:
c+=1
print(c)
|
p02760
|
s341397323
|
Wrong Answer
|
s,a='036,048,246,258,345,678,',open(0).read().split()
for i in a[9:]:s=s.replace(str(a.index(i)),'')
print('NYoe s'[',,'in s::2])
|
p03386
|
s142913597
|
Wrong Answer
|
a,b,k=map(int, input().split())
k=min(k,b-a)
*al,=range(a,a+k+1)
*al2,=range(b-k,b+1)
ans=al+al2
ans=list(set(ans))
ans.sort()
for i in ans:print(i)
|
p02547
|
s300858855
|
Accepted
|
N = int(input())
D = []
for i in range(N):
d1, d2 = map(int, input().split())
D.append([d1, d2])
count = 0
for i in range(N):
if D[i][0] == D[i][1]:
count += 1
if count == 3:
break
else:
count = 0
print("Yes") if count == 3 else print("No")
|
p02779
|
s155531068
|
Wrong Answer
|
N = input()
nums = input().split(" ")
nums = [int(i) for i in nums]
if len(set(nums)) == N:
print("YES")
else:
print("NO")
|
p02630
|
s124592092
|
Accepted
|
N=int(input())
A=list(map(int,input().split()))
Q=int(input())
from collections import defaultdict
d = defaultdict(int)
for a in A:
d[a]+=1
ans=sum(A)
for q in range(Q):
b,c=map(int,input().split())
ans+=(c-b)*d[b]
d[c]+=d[b]
d[b]=0
print(ans)
|
p02784
|
s452499780
|
Accepted
|
H, N = map(int, input().split())
arr = list(map(int, input().split()))
if sum(arr) < H:
print('No')
else:
print('Yes')
|
p02602
|
s844712308
|
Accepted
|
N, K = map(int, input().split())
An = list(map(int, input().split()))
Bn = []
Bn.append(0)
for i in range(N):
Bn.append(An[i]+Bn[i])
for i in range(K+1, N+1):
if (Bn[i]-Bn[i-K] > Bn[i-1]-Bn[i-K-1]):
print("Yes")
else:
print("No")
|
p02831
|
s908192607
|
Accepted
|
import sys
from fractions import gcd
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
A, B = lr()
answer = A * B // gcd(A, B)
print(answer)
# 50
|
p03011
|
s254892281
|
Wrong Answer
|
#A
p, q, r = map(int, input().split())
print(min(p+q,q+r,q+p))
|
p02829
|
s283648531
|
Wrong Answer
|
a = int(input())
b = int(input())
List = {a, b}
if List == {1, 2}:
print(3)
if List == {2, 3}:
print(1)
if List == {3, 1}:
print(1)
|
p03071
|
s998577266
|
Wrong Answer
|
A=sorted(map(int,input().split()))
print( A[1]*2-1 if A[1]+A[0]-1 <= A[1]*2-1 else A[1]+A[0]-1 )
|
p02754
|
s422162842
|
Accepted
|
d = input().split(" ")
n = int(d[0])
a = int(d[1])
b = int(d[2])
s = a + b
c = (n // s) * a
if n % s > a:
c += a
else:
c += n % s
print(c)
|
p02713
|
s805716776
|
Accepted
|
import functools
import math
def gcd_2(*vals):
return functools.reduce(math.gcd, vals)
K = int(input())
ANS = 0
L = list(range(1, K+1))
M = list(range(1, K+1))
N = list(range(1, K+1))
for i in range(K):
for j in range(K):
for k in range(K):
ANS = ANS + gcd_2(L[i], M[j], N[k])
print(ANS)
|
p03251
|
s818705111
|
Wrong Answer
|
n,m,x,y = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
a.sort(reverse = True)
b.sort()
if b[0] - a[0] < 1:
print('War')
else:
print('No War')
|
p02699
|
s754550443
|
Accepted
|
s,w = map(int,input().split())
if s <=w:
print("unsafe")
else:
print("safe")
|
p02922
|
s143334353
|
Accepted
|
#!/usr/bin/env python3
import math
def main():
a,b = map(int, input().split())
print(math.ceil((b-1)/(a-1)))
if __name__ == '__main__':
main()
|
p02664
|
s134837038
|
Wrong Answer
|
t = input()
t = t.replace("??", "PD")
t = t.replace("P?", "PD")
t = t.replace("?D", "PD")
t = t.replace("?", "D")
print(t)
|
p02766
|
s200953326
|
Wrong Answer
|
N,K=map(int,input().split())
a = 1
while K <= N:
N = N // K
a =a+1
print(a)
print(a)
|
p02795
|
s094953367
|
Wrong Answer
|
h = int(input())
w = int(input())
n = int(input())
a = max(h,w)
b = a
count = 0
if h*w == n:
print(h)
else:
while b <= n:
b += a
count += 1
print(count)
|
p02801
|
s335503045
|
Wrong Answer
|
ac = input()
acc ='abcdefghijklmnopqrstuvwxyx'
print(acc[acc.index(ac) + 1])
|
p02553
|
s955933662
|
Accepted
|
a, b, c, d = (int(i) for i in input().split())
if a > 0:
if d > 0:
print(max(a*c, a*d, b*c, b*d))
else:
print(max(a*c, a*d, b*c, b*d))
else:
if d > 0:
print(max(a*c, a*d, b*c, b*d))
else:
print(max(a*c, a*d, b*c, b*d))
|
p02624
|
s863574937
|
Accepted
|
n = int(input())
total = 0
for j in range(1,n+1):
x = j
y = n//x
total +=y*(y+1)*x//2
print(total)
|
p02717
|
s840918598
|
Wrong Answer
|
a, b, c = map(int, input().split(' '))
print('{} {} {}'.format(b, c, a))
|
p02572
|
s396129743
|
Wrong Answer
|
n=int(input())
arr=list(map(int,input().split()))
ss=0
s=0
for i in range(n):
ss=ss+arr[i]**2
s=s+arr[i]
ans=(s**2-ss)/2
print(int(ans%(10**9+7)))
|
p02608
|
s593872749
|
Accepted
|
N = int(input())
ans = [0]*(N+1)
f = lambda x, y, z: x**2 + y**2 + z**2 + x*y + y*z + z*x
root_N = int(N**0.5)
for x in range(1, root_N+1):
for y in range(1, root_N+1):
for z in range(1, root_N+1):
i = f(x, y, z)
if i <= N:
ans[f(x, y, z)] += 1
print('\n'.join(map(str, ans[1:])))
|
p02843
|
s132132337
|
Accepted
|
x = int(input())
for i in range(100000):
if i * 100 <= x <= i *105:
print(1)
exit()
print(0)
|
p04034
|
s079601324
|
Accepted
|
n,m = map(int, input().split())
xy = []
for i in range(m):
x,y = map(int, input().split())
xy.append([x-1,y-1])
box = [1 for i in range(n)]
chk = [False for i in range(n)]
chk[0] = True
for i in range(m):
x, y = xy[i][0],xy[i][1]
if chk[x]:
if box[x] >= 2:
chk[y] = True
else:
chk[y] = True
chk[x] = False
box[y] += 1
box[x] -= 1
cnt = 0
for i in range(n):
cnt += chk[i]
print (cnt)
|
p03719
|
s816795822
|
Wrong Answer
|
a,b,c = map(int,input().split())
print("Yes" if a < c < b else "No")
|
p02818
|
s337023258
|
Wrong Answer
|
a,b,c=map(int,input().split())
print(max(0,a-c),max(b-(c-a),0))
|
p02547
|
s636616686
|
Accepted
|
n = int(input().strip())
count = 0
for i in range(n):
a,b = map(int,input().strip().split())
if count == 3:
print('Yes')
exit(0)
elif a == b:
count += 1
elif(a != b):
count = 0
if count == 3:
print('Yes')
else:
print('No')
|
p02584
|
s786650017
|
Accepted
|
X,K,D = map(int, input().split())
X = abs(X)
if X - K*D > 0:
print(X - K*D)
else:
needCount = X//D
limX = X - needCount * D
remK = K - needCount
minusX = limX - D
if remK % 2 == 0:
print(limX)
else:
print(abs(minusX))
|
p02601
|
s112303874
|
Wrong Answer
|
a, b, c = map(int, input().split())
k = int(input())
for i in range(k):
if a > b:
b *= 2
elif b > c:
c *= 2
if a < b < c:
print("Yes")
else:
print("No")
|
p02606
|
s114729768
|
Wrong Answer
|
a = list(map(int, input().split()))
count = 0
b = a[1] - a[0]
if a[1] == a[0]:
for i in range(a[1]):
if (i + 1) % a[2] == 0:
count += 1
elif b < a[2]:
count = 0
elif b != 0 and a[2] == 1:
count = a[1]
else:
for j in range(b):
if (j + b + 1) % a[2] == 0:
count += 1
print(count)
|
p03565
|
s875084529
|
Accepted
|
import re
S = str(input())
T = str(input())
S = S.replace("?",".")
for i in range(len(S)-len(T),-1,-1):
if re.match(S[i:i+len(T)],T):
S = S.replace('.','a')
print(S[:i]+T+S[i+len(T):])
exit()
print('UNRESTORABLE')
|
p02939
|
s807441477
|
Accepted
|
S = input()
ans = 0
tmp = ''
pre = ''
for i in S:
tmp += i
if pre != tmp:
pre = tmp
tmp = ''
ans += 1
print(ans)
|
p02677
|
s975947214
|
Wrong Answer
|
import math
import decimal
a, b, h, m = map(int, input().split())
angle_m = m * 60
angle_h = h * 30 + m / 2
angle = abs(angle_h - angle_m)
angle = math.radians(min(angle, 360 - angle))
ans2 = pow(b * math.cos(decimal.Decimal(f'{angle}')) - a, 2) + pow(b * math.sin(decimal.Decimal(f'{angle}')), 2)
ans = decimal.Decimal(f'{ans2}').sqrt()
print(ans)
|
p03274
|
s480337603
|
Accepted
|
N, K = map(int, input().split())
X = list(map(int, input().split()))
Xp = [0]+[+x for x in X if x>=0]
Xm = [0]+[-x for x in reversed(X) if x< 0]
Np = len(Xp)-1
Nm = len(Xm)-1
ans = 10**10
for np in range(min(Np, K), max(0, K-Nm)-1, -1):
nm = K-np
time = min(Xp[np], Xm[nm]) + Xp[np] + Xm[nm]
ans = min(ans, time)
print(ans)
|
p03767
|
s796557179
|
Accepted
|
N = int(input())
a = sorted(map(int,input().split()))
print(sum(a[N:3*N:2]))
|
p02720
|
s761320374
|
Accepted
|
import sys
from collections import deque
sys.setrecursionlimit(10 ** 6)
def input(): return sys.stdin.readline().rstrip()
K = int(input())
queue = deque(range(1, 10))
for _ in range(K):
i = queue.popleft()
if i % 10 >= 1:
queue.append(i * 10 + (i % 10) - 1)
queue.append(i * 10 + i % 10)
if i % 10 <= 8:
queue.append(i * 10 + (i % 10) + 1)
print(i)
|
p03623
|
s169178995
|
Accepted
|
x,a,b = map(int,input().split())
if abs(x-a)<abs(x-b):
print("A")
else:
print("B")
|
p03821
|
s918448649
|
Accepted
|
#!/usr/bin/env python3
# from numba import njit
# input = stdin.readline
# @njit
def solve(n,a,b):
res = 0
for i in range(n):
res += (-a[i]-res) % b[i]
return res
def main():
N = int(input())
a = [0]*N
b = [0]*N
for i in range(N):
a[i],b[i] = map(int,input().split())
print(solve(N,a[::-1],b[::-1]))
return
if __name__ == '__main__':
main()
|
p03485
|
s105402609
|
Wrong Answer
|
import math
a,b = [int(x) for x in input().split()]
print(math.ceil(a*b/2))
|
p02584
|
s083252202
|
Accepted
|
X, K, D = map(int, input().split())
X = abs(X)
if X == 0:
if K % 2 == 0:
print(0)
else:
print(D)
elif X - K*D >= 0:
print(X - K*D)
elif X - K*D < 0:
a = X // D
b = a + 1
if (K - a) % 2 == 0:
print(X % D)
else:
print(D - X % D)
|
p02675
|
s679637054
|
Wrong Answer
|
N = input()[-1]
if int(N) == (2 or 4 or 5 or 7 or 9):
print("hon")
elif int(N) == (0 or 1 or 6 or 8):
print("pon")
else:
print("bon")
|
p03672
|
s731399218
|
Accepted
|
S = str(input())
S = S[:-1]
count = len(S)
while S[:len(S)//2] != S[len(S)//2:]:
S = S[:-1]
count -= 1
print(count)
|
p03087
|
s209132271
|
Accepted
|
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
l, r = map(int, input().split())
print(t[r-1] - t[l-1])
|
p02742
|
s301760568
|
Accepted
|
h,w=map(int,input().split())
if h==1 or w==1:
print(1)
elif h%2!=0 and w%2!=0:
print(h*w//2+1)
else:
print(h*w//2)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.