problem_id stringclasses 428 values | submission_id stringlengths 10 10 | status stringclasses 2 values | code stringlengths 5 816 |
|---|---|---|---|
p02780 | s157524827 | Accepted | N,K = (int(i) for i in input().split())
P = [int(i) for i in input().split()]
P_expect_sum = [0 for i in range(N)]
P_pred = 0
for i in range(N):
P_expect = (1+P[i])/2
P_expect_sum[i] = P_pred + P_expect
P_pred = P_expect_sum[i]
ans = P_expect_sum[K-1]
for i in range(K-1,N):
ans = max(ans, P_expect_sum[i] - P_expect_sum[i-K])
print(ans)
|
p02912 | s214500944 | Accepted | import heapq
n,m=map(int, input().split())
A=[-1*int(i) for i in input().split()]
heapq.heapify(A)
while m>0:
x = heapq.heappop(A)
x*=-1
x//=2
x*=-1
heapq.heappush(A, x)
m-=1
print(-1*sum(A))
|
p02983 | s376259895 | Accepted | L,R=map(int,input().split())
if R-L>=2019:
ans=0
else:
ans=2018
for i in range(L,R):
for t in range(i+1,R+1):
Z=(i*t)%2019
ans=min(Z,ans)
print(ans) |
p02811 | s002120723 | Accepted | K, X = map(int, input().split())
print("Yes" if K * 500 >= X else "No") |
p02629 | s488918302 | Accepted | N = int(input())
p = N
s = []
abt = "abcdefghijklmnopqrstuvwxyz"
ans = ""
while p > 0:
p -= 1
s.append(p % 26)
p //= 26
for i in s[::-1]:
ans += abt[i]
print(ans)
|
p03251 | s034542272 | Accepted | import sys
def input(): return sys.stdin.readline().strip()
def resolve():
def main():
n,m,x,y=map(int, input().split())
lx=list(map(int,input().split()))
ly=list(map(int,input().split()))
xmax=max(lx)
ymin=min(ly)
for i in range(x+1,y+1):
if xmax<i and ymin >=i:
return 'No War'
return 'War'
print(main())
resolve() |
p03319 | s346934838 | Accepted | import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) #空白あり
N,K = MI()
A = LI()
print((N-1+K-2)//(K-1))
|
p02780 | s001767901 | Accepted | n,k=map(int,input().split())
p=list(map(int,input().split()))
b=[0]
for i in range(1,n+1):
b.append(p[i-1]+b[i-1])
mm=0
inx=-1
for i in range(len(b)-k):
if b[i+k]-b[i]>=mm:
inx=i
mm=b[i+k]-b[i]
ans=0
for j in range(inx,inx+k):
ans+=((p[j]*(p[j]+1))*0.5)*(1/p[j])
print(ans) |
p03695 | s696049819 | Accepted | import sys
input = sys.stdin.readline
from collections import *
N = int(input())
a = list(map(int, input().split()))
cnt = [0]*9
for ai in a:
i = min(ai//400, 8)
cnt[i] += 1
m = 0
M = 0
for i in range(8):
if cnt[i]>0:
m += 1
M += 1
if cnt[-1]>0:
if m==0:
m = 1
M += cnt[-1]
print(m, M) |
p03632 | s008711387 | Wrong Answer | a,b,c,d=map(int,input().split());print(min(b,d)-max(a,c)) |
p02681 | s952982394 | Wrong Answer | a = input()
e = input()
b = len(a)
f = 0
for i in range(b) :
c = a[i]
d = e[i]
if not c == d :
print("No")
f = 1
if f == 0 :
print("Yes") |
p02631 | s356610941 | Accepted | N = int(input())
a = list(map(int, input().split()))
X = 0
for x in a:
X ^= x
ans = [X ^ a[i] for i in range(N)]
print(*ans)
|
p02861 | s621666634 | Accepted | import sys
import math
def main():
N = int(input())
xy=[]
for _ in range(N):
xy.append(list(map(int,input().split())))
sqs=[]
for i in range(0,len(xy)):
for j in range(i+1,len(xy)):
sqs.append(math.sqrt((xy[i][0]-xy[j][0])**2 + (xy[i][1]-xy[j][1])**2))
print(sum(sqs) * 2 / N)
main() |
p02777 | s684450794 | Accepted | # -*- coding: utf-8 -*-
str_1,str_2 = input().split()
str_1_count,str_2_count = input().split()
del_str = input()
if del_str == str_1:
str_1_count = int(str_1_count) - 1
else:
str_2_count = int(str_2_count) - 1
print(str(str_1_count) +" " + str(str_2_count)) |
p02789 | s072726834 | Wrong Answer | a,b=input().split()
print("TNeos"[a!=b::2]) |
p03951 | s215377587 | Accepted | n = int(input())
s = input()
t = input()
flag = False
for i in range(n):
if s[i:] == t[:n-i]:
flag = True
break
print(i+n if flag else n*2) |
p03062 | s185122884 | Accepted | import numpy
N = int(input())
a = numpy.array([int(i) for i in input().split()])
min = 10**9+1
minus = 0
total = 0
for i in a :
if i < 0 :
minus += 1
if abs(i) < min :
min = abs(i)
total += abs(i)
# print(i,min,total)
if minus %2 == 0 :
print(total)
else :
print(total-min*2)
|
p03997 | s470012822 | Wrong Answer | a = int(input())
b = int(input())
h = int(input())
x = (a+b)/2
print(x*h)
|
p03408 | s458757547 | Wrong Answer | n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
a = list(set(s+t))
ans = {}
for i in a:
ans[i] = 0
for i in s:
ans[i] += 1
for i in t:
ans[i] -= 1
print(max(ans.values())) |
p02700 | s073946688 | Accepted | th,ta,ah,aa=map(int,input().split(" "))
#print(th,ta,ah,aa)
#print((ah-1)//ta,(th-1)//aa)
if (ah-1)//ta > (th-1)//aa:
print("No")
elif (ah-1)//ta <= (th-1)//aa:
print("Yes") |
p03632 | s861222808 | Wrong Answer | A,B,C,D = map(int,input().split())
if B < C or D < A:
print(0)
elif A <= C and D <= B:
print(D-C)
elif C < A and B < D:
print(B-A)
elif C < B:
print(B-C)
elif A < D:
print(D-A)
|
p03719 | s768701455 | Accepted | A, B, C = map(int, input().split())
if C >= A and C <= B :
print('Yes')
else:
print('No') |
p03659 | s665300954 | Wrong Answer | #4問目
N = int(input())
a = list(map(int, input().split()))
#足していった配列を用意する
Sum = 0
Min = 2 * 10**5
SumArray = [0] * N
for i in range(N):
Sum += a[i]
SumArray[i] = Sum
#仕切りを用意して,左側をすぬけくん,右側をアライグマのカードとして差分を計算する
for i in range(N-1):
temp = abs(SumArray[i] - (SumArray[N-1] - SumArray[i]))
if temp < Min:
Min = temp
print(Min) |
p03243 | s034912038 | Accepted | val = [111*i for i in range(1, 10)]
N = int(input())
while not N in val:
N += 1
print(N) |
p02924 | s217597090 | Accepted | N = int(input())
print((N*(N-1))//2) |
p02772 | s124952141 | Accepted | N = int(input())
arr = list(map(int, input().split()))
for i in arr:
if i % 2 == 0:
if i % 3 != 0 and i % 5 != 0:
print('DENIED')
exit()
print('APPROVED') |
p03105 | s405090969 | Wrong Answer | A, B, C = map(int, input().split())
print(B // A) |
p02628 | s061410237 | Accepted | X = list(map(lambda x:int(x), input().split()))
n = X[0]
k = X[1]
p = list(map(lambda x:int(x), input().split()))
p.sort()
s = 0
for i in range(k):
s += p[i]
print(s) |
p02814 | s902645399 | Accepted | import math
N, M = map(int, input().split())
B = tuple(int(a) // 2 for a in input().split())
x = B[0]
for i in range(1, N):
x = (x * B[i]) // math.gcd(x, B[i])
for b in B:
if (x // b) % 2 == 0:
print(0)
break
else:
ans = (M // x) - (M // (2 * x))
print(ans) |
p03543 | s274540186 | Wrong Answer | n = input()
from collections import Counter
c = Counter(n)
for k, v in c.items():
if v >= 3:
print('Yes')
break
else:
print('No') |
p03494 | s254642615 | Accepted | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
def main():
N = int(input())
S = list(map(int, input().split()))
result = 0
count = 2
while all([s % count == 0 for s in S]):
count *= 2
result += 1
print(result)
if __name__ == "__main__":
main()
|
p02988 | s320748231 | Accepted | def main():
n = input()
p = [int(x) for x 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)
main() |
p03161 | s692032960 | Accepted | N, K = map(int, input().split())
h = list(map(int, input().split()))
dp = [float("inf") for _ in range(N)]
dp[0] = 0
for i in range(N - 1):
for j in range(1, min(K + 1, N - i)):
dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]))
print(dp[N - 1]) |
p03817 | s515369199 | Accepted | x = int(input())
y = (x-1)//11
z = (x-1)%11
u = 2*(y+1)
if z < 6:
u -= 1
print(u)
|
p02582 | s555696007 | Wrong Answer | s=input()
ans=0
rain=[0]
for i in range(len(s)):
if s[i]=="R":
ans+=1
else:
rain.append(ans)
ans=0
print(max(rain)) |
p02820 | s786789944 | Accepted | n, k = map(int, (input().split()))
r, s, p = map(int, (input().split()))
t = input()
d = {'r': p, 's': r, 'p': s}
ans = 0
for i in range(k):
last = ''
j = i
while j < n:
if t[j] != last:
ans += d[t[j]]
last = t[j]
else:
last = ''
j += k
print(ans) |
p02952 | s210390866 | Accepted | n = int(input())
if 1<= n <= 9:
e = n
print(e)
elif 10 <= n <= 99:
print(9)
elif 100 <= n <= 999:
e = 9 + n - 100 + 1
print(e)
elif 1000 <= n <= 9999:
e = 909
print(e)
elif 10000 <= n <= 99999:
e = 909 + n - 10000 + 1
print(e)
elif n == 100000:
print(90909) |
p03073 | s118919134 | Wrong Answer | color = [int(i) for i in input()]
n = len(color)
ans = 0
for i in range(n-2):
a = color[i]
b = color[i+1]
c = color[i+2]
if a==b==c:
color[i+1] = (b+1)%2
ans += 1
elif a==b and a!=c:
color[i] = (a+1)%2
ans += 1
elif a!=b and b==c:
color[i+2] = (c+1)%2
ans += 1
else:
continue
print(ans)
|
p02819 | s527129104 | Wrong Answer | import math
def prime(X):
for i in range(2,math.ceil(math.sqrt(X))+1):
if X % i == 0:
return False
return True
X = int(input())
while True:
if prime(X):
print(X)
break
X = X + 1 |
p02753 | s046981169 | Accepted | s = input()
if s[0]==s[1] and s[1]==s[2]:
print("No")
else:
print("Yes") |
p04005 | s575369348 | Wrong Answer | a, b, c = map(int, input().split())
if a%2==0 and b%2==0 and c%2==0:
print(0)
else:
print(min(a*b, b*c, c*a)) |
p02831 | s213394702 | Accepted | import fractions
A, B = [int(_) for _ in input().split()]
print(A * B // fractions.gcd(A, B))
|
p03469 | s513017589 | Wrong Answer | s=list(input())
s[3]="8"
print(str(s)) |
p03360 | s768887553 | Accepted | a = list(map(int, input("").split()))
k=int(input())
m=0
if a[1] >= a[0] or a[2] >= a[0]:
if a[2] >= a[1]:
m=2
else:
m=1
for i in range(k):
a[m]=a[m]*2
print(a[0]+a[1]+a[2]) |
p03478 | s557552350 | Accepted | N,A,B = map(int,input().split())
ans = 0
for i in range(1,N+1):
psum = int(i/10000) + int(i/1000)%10 + int(i/100)%10 + int(i/10)%10 + i%10
if psum >= A and psum <= B:
ans = ans + i
print(ans) |
p02922 | s097028965 | Accepted | a,b=map(int,input().split())
for i in range(21):
if b<= a*i-(i-1):
print(i)
break
|
p03485 | s390428585 | Accepted | import math
a,b=map(int,input().split())
print(math.ceil((a+b)/2)) |
p02707 | s184321861 | Accepted | import bisect,collections,copy,heapq,itertools,math,operator,string
def I(): return int(input())
def S(): return input()
def LI(): return list(map(int,input().split()))
def LS(): return list(input().split())
##################################################
N = I()
A = LI()
count = collections.Counter(A)
for i in range(N):
print(count[i+1])
|
p03220 | s486165805 | Accepted | def resolve():
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
sub = []
ans = []
for i in range(N):
sub.append(T-H[i]*0.006)
for j in range(N):
ans.append(abs(A-sub[j]))
print(ans.index(min(ans))+1)
resolve() |
p03680 | s343366761 | Accepted | n=int(input())
a=[int(input()) for _ in range(n)]
b=[0]*(n+1)
count=0
w=1
for i in range(n):
if b[2]:
print(count)
exit()
b[a[w-1]]+=1
w=a[w-1]
count+=1
print("-1") |
p02922 | s204699364 | Accepted | a, b = map(int, input().split())
total = 1
ans = 0
while total < b:
ans += 1
total -= 1
total += a
print(ans) |
p03250 | s829378807 | Accepted | a,b,c = sorted(map(int,input().split()))
d=str(c)+str(b)
print(a+int(d))
|
p02594 | s517255714 | Wrong Answer | X = int(input())
if X >= 30:
print("YES")
elif X < 30:
print("No") |
p02546 | s569734355 | Wrong Answer | s=input()
if s[-1]=='s':
print(s[:-1]+'es')
elif s[-1]!='s':
print(s[:-1]+'s') |
p03544 | s720168843 | Accepted | N = int(input())
L = [0] * (N+1)
L[0] = 2
L[1] = 1
for i in range(2,N+1):
L[i] = L[i-1] + L[i-2]
print(L[N]) |
p03475 | s564006347 | Accepted | ma = lambda : map(int,input().split())
ni = lambda : int(input())
import math
ceil = math.ceil
n = ni()
csf = []
for i in range(n-1):
csf.append(tuple(ma()))
for i in range(n-1):
ans = csf[i][1] + csf[i][0]
for j in range(i+1,n-1):
if ans<=csf[j][1]:
ans =csf[j][1]+csf[j][0]
else:
ans = ceil(ans/csf[j][2])*csf[j][2] +csf[j][0]
print(ans)
print(0)
|
p02639 | s235487210 | Wrong Answer | #intの場合
huga = list(map(int, input().split()))
for i in range(len(huga)):
if huga[i] == 0:
print(huga[i]) |
p02935 | s824213910 | Accepted | N=int(input())
A=list(map(int,input().split()))
A.sort()
for _ in range(N-1):
t=(A.pop(0)+A.pop(0))/2
A.insert(0,t)
print(*A) |
p02972 | s851424921 | Accepted | n = int(input())
a = [int(i) for i in input().split()]
cnt = [0]*n
for i in range(n,0,-1):
total = sum(cnt[i*k-1] for k in range(1,n//i+1))
if total % 2 != a[i-1]:
cnt[i-1] = 1
b = [i+1 for i in range(n) if cnt[i] > 0]
print(sum(cnt))
print(*b) |
p03633 | s085272644 | Accepted | import sys
import fractions
input = sys.stdin.readline
def main():
N = int(input())
T = []
for _ in range(N):
T.append(int(input()))
ans = 1
for t in T:
ans = (ans * t) // fractions.gcd(ans, t)
print(ans)
if __name__ == '__main__':
main()
|
p02946 | s477429277 | Wrong Answer | K,X=map(int,input().split())
a=[]
for i in range(0,K):
a.append(X-i)
for j in range(1,K):
a.append(X+j)
s=sorted(a)
print(s)
|
p02691 | s273079465 | Accepted | n = int(input())
a = list(map(int, input().split()))
dp = [0 for _ in range(n)]
ans = 0
for i in range(n):
if i + a[i] < n:
dp[i+a[i]] += 1
if 0<= i-a[i]:
ans += dp[i-a[i]]
# print(dp)
print(ans) |
p02725 | s687316424 | Accepted | k,n = map(int,raw_input().split())
a = map(int,raw_input().split())
b = []
for i in range(1,len(a)):
b.append(a[i] - a[i-1])
b.append(min(a[-1] - a[0], k - a[-1] + a[0]))
print(k - max(b)) |
p02802 | s478126814 | Wrong Answer | N, M = map(int, input().split())
pSs = [list(map(str, input().split())) for _ in range(M)]
#%%
ACs = [False for _ in range(N)]
WAs = [0 for _ in range(N)]
for pS in pSs:
problem = int(pS[0]) -1
answer = pS[1]
if ACs[problem] == True:
continue
else:
if answer == "WA":
WAs[problem] += 1
else:
ACs[problem] = True
print(sum(ACs), sum(WAs)) |
p03861 | s861183271 | Accepted | a, b ,x = map(int, input().split())
ans = 0
n_a = a//x
n_b = b//x
if a%x == 0:
ans+=1
ans += n_b - n_a
print(ans) |
p02761 | s499213871 | Wrong Answer | import sys
N,M=map(int,input().split())
listSC=[]
for k in range(M):
s,c=map(int,input().split())
listSC+=[[s,c]]
MAX=0
if N==1:
for s,c in listSC:
MAX==(MAX,c)
if MAX==0:
print(0)
sys.exit()
for i in range(10**(N-1),10**N):
A=list(str(i))
for k in range(M):
if A[listSC[k][0]-1]!=str(listSC[k][1]):
break
if k==M-1:
ans=i
print(ans)
sys.exit()
if i==10**N-1:
print(-1) |
p03433 | s172398354 | Accepted | N = int(input())
A = int(input())
if A >= (N%500):
print("Yes")
else:
print("No") |
p02602 | s427741982 | Wrong Answer | import numpy as np
N,K = map(int,input().split())
A = list(map(int,input().split()))
for i in range(N-K):
if np.prod(A[i:K+i]) < np.prod(A[i+1:K+i+1]):
print("Yes")
else:
print("No") |
p04011 | s852601388 | Wrong Answer | n = int(input())
k = int(input())
x = int(input())
y = int(input())
if n < k:
p = (n-k)*y
else:
p = 0
print(k*x +p) |
p02631 | s240984782 | Accepted | n=int(input())
a=list(map(int,input().split()))
final=0
for i in range(n):
final=final^a[i]
for i in range(n):
print(final^a[i]) |
p02623 | s718991462 | Wrong Answer | N, M, K = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
A = [0]
B = [0]
for i in range(N):
A.append(A[i] + a[i])
for i in range(M):
B.append(B[i] + b[i])
ans = 0
j = M
for n in range(N + 1):
while True:
time = A[n] + B[j]
if time <= K or j == 0:
ans = max(ans, n + j)
break
else:
j -= 1
print(ans) |
p03331 | s905317785 | Accepted |
import numpy as np
N = int(input())
Nd2 = int(np.ceil(N / 2))
min_total = np.inf
for i in range(1, -~Nd2):
n = i
n2 = N - i
total = 0
dig = 10
while n:
a, b = divmod(n, dig)
n = a
total += b
while n2:
a, b = divmod(n2, dig)
n2 = a
total += b
min_total = min(min_total, total)
print(min_total)
|
p02624 | s265071149 | Wrong Answer | import math
N=int(input())
ans=0
for i in range(1,N):
Y=math.floor(N/i)
ans+=(Y*(Y+1)*i)//2
print(ans) |
p03241 | s442343669 | Accepted | N,M = map(int,input().split())
# 約数列挙
def enum_div(N):
ret = []
for i in range(1,int(N**0.5)+1):
if N % i == 0:
ret.append(i)
if i**2 != N:
ret.append(N // i)
i += 1
return ret
ans = 0
for i in enum_div(M):
if i >= N:
ans = max(ans,M // i)
print(int(ans)) |
p03456 | s051024543 | Accepted | # abc086_b.py
A, B = map(int,input().split())
for i in range(1000):
if (10**len(str(B)) * A + B) == i**2:
print('Yes')
exit()
print('No')
|
p03478 | s942368438 | Accepted | N,A,B=map(int,input().split())
res=0
for i in range(1,N+1):
s=str(i)
sum=0
for j in range(len(s)):
sum+=int(s[j])
if(A<=sum and sum<=B):
res+=i
print(res) |
p03659 | s302962309 | Wrong Answer | n = int(input())
a =[int(i) for i in input().split()]
z = sum(a)
ans = 10**20
c = 0
for i in range(n-1):
c += a[i]
d = z - a[i]
if abs(c-d) < ans:
ans = abs(c-d)
print(ans) |
p02780 | s921606198 | Accepted | # coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read
n,k,*p = [int(i) for i in read().split()]
p = [(1+i) for i in p]
m = a = sum(p[:k])
for i in range(k,n):
a += p[i]
a -= p[i-k]
m = max(m,a)
print(m/2)
|
p03632 | s108894923 | Accepted | A, B, C, D = map(int, input().split())
start = max(A, C)
end = min(B, D)
ans = max(end-start, 0)
print(ans) |
p03493 | s642890985 | Accepted | s = input()
print(s.count("1"))
|
p02789 | s981044040 | Wrong Answer | #
A,B=map(int,input().split())
#print(A,B)
if A==B:
print("AC")
else:
print("WA") |
p03625 | s533553841 | Accepted | N = int(input())
A = list(map(int, input().split()))
A = sorted(A, reverse = True)
store = 0
big = 0
for i in range (0, N-1):
if store == 1:
store = 0
else:
if A[i] == A[i+1] and big == 0:
big = A[i]
store = 1
elif A[i] == A[i+1]:
print(A[i]*big)
exit()
print(0) |
p02771 | s894700478 | Accepted | A, B, C = input().split()
if A == B == C:
print('No')
elif A != B and C != B and A != C:
print('No')
else:
print('Yes')
|
p02684 | s481719233 | Accepted | n,k,*a=map(int,open(0).read().split())
d=[2*k]*-~n
s=1
while k:k-=1;s=a[s-1];k%=d[s]-k;d[s]=k
print(s) |
p02596 | s973128175 | Accepted | K = int(input())
a = [7%K]
for i in range(1, K):
a.append((a[i-1]*10+7)%K)
isCorrect = False
for i in range(K):
if a[i] == 0:
print(i+1)
isCorrect = True
break
if not isCorrect:
print("-1") |
p02767 | s660210393 | Wrong Answer | import math
N = int(input())
x = list(map(int, input().split()))
t = 0
min = 0
for i in range(0,N-1):
t += x[i]/N
s = math.floor(t)
print(s)
for i in range(0,N-1):
min += (x[i] - s) **2
print(min) |
p03210 | s153155615 | Accepted | if __name__ == '__main__':
x = int(input())
if (x == 3) or (x == 5) or (x == 7):
print("YES")
else:
print("NO") |
p02689 | s673537753 | Wrong Answer | input1 = input().rstrip().split(" ")
h = input().rstrip().split(" ")
yoi = [1 for i in range(int(input1[0]))]
root = [input().rstrip().split(" ") for i in range(int(input1[1]))]
for i in range(int(input1[1])):
a=int(root[i][0])-1
b=int(root[i][1])-1
if h[a]> h[b]:
yoi[b] = 0
elif h[a] < h[b]:
yoi[a] = 0
else:
yoi[a] = 0
yoi[b] = 0
print (sum(yoi))
|
p03592 | s854098876 | Accepted | a,b,k=map(int,input().split())
n=a*b+1
ans=[0]*n
for i in range(a+1):
for j in range(b+1):
ans[a*j+b*i-2*i*j]=1
print("Yes" if ans[k] else "No") |
p03109 | s094768883 | Wrong Answer | s = input()
if s[5] != 1 and int(s[6]) >=4:
print('Heisei')
else:
print('TBD') |
p02973 | s229893217 | Accepted | import bisect
from collections import deque
N = int(input())
ans = deque()
for _ in range(N):
a = int(input())
ind = bisect.bisect_left(ans, a)
if ind == 0:
ans.appendleft(a)
else:
ans[ind-1] = a
print(len(ans))
|
p02661 | s484465638 | Accepted | N = int(input())
ranges = [tuple(map(int,input().split())) for _ in range(N)]
A = sorted(a for a,b in ranges)
B = sorted(b for a,b in ranges)
if N % 2 == 0:
a = A[N//2-1]+A[N//2]
b = B[N//2-1]+B[N//2]
print(b-a+1)
else:
a = A[N//2]
b = B[N//2]
print(b-a+1) |
p03821 | s997303063 | Accepted | #!/usr/bin/env python3
(n, ), *s = [[*map(int, i.split())] for i in open(0)]
c = 0
for a, b in reversed(s):
q = (a + c) % b
c += b * (q > 0) - q
print(c)
|
p02854 | s665908785 | Accepted | import itertools
n=int(input())
a=list(map(int,input().split()))
cumsum=[0]+list(itertools.accumulate(a))
sum_num=sum(a)
ans=10**100
for i in range(1,n):
yen=abs(cumsum[i]-(sum_num-cumsum[i]))
if yen<ans:
ans=yen
print(ans) |
p03219 | s828036484 | Wrong Answer | x, y = map(int, input().split())
a = x + y/2
print(a) |
p02594 | s792850634 | Wrong Answer | n=int(input())
if n >= 30:
print('yes')
else:
print('No') |
p02775 | s049513737 | Wrong Answer | N = int(input())
N = list(str(N))
N = tuple(map(int, N))
ans = 0
flag = False
flag5 = False
for i, x in enumerate(reversed(N)):
x = N[i]
if flag or (flag5 and x >= 5):
x += 1
flag5 = False
flag = False
if x > 5:
ans += (10 - x)
flag = True
if i == 0:
ans += 1
else:
ans += x
if x == 5:
flag5 = True
print(ans)
|
p02701 | s930767451 | Accepted | N = int(input())
S = set()
for i in range(N):
S.add(input())
print(len(S)) |
p02684 | s791766559 | Accepted | N, K = map(int, input().split())
As = list(map(int, input().split()))
lastVisit = [None] * N
now = 0
n = 0
while lastVisit[now] is None:
lastVisit[now] = n
now = As[now]-1
n += 1
if n == K:
print(now+1)
exit()
for _ in range((K-lastVisit[now]) % (n-lastVisit[now])):
now = As[now]-1
print(now+1)
|
p04012 | s611634609 | Accepted | s = sorted(list(input()))
for i in range(97, 97 + 26):
if s.count(chr(i)) %2 != 0:
print('No')
exit()
print('Yes') |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.