problem_id stringclasses 428
values | submission_id stringlengths 10 10 | status stringclasses 2
values | code stringlengths 5 816 |
|---|---|---|---|
p03699 | s518329155 | Wrong Answer | import sys
N=int(input())
s=[int(input()) for i in range(N)]
num=sum(s)
if num%10!=0:
print(num)
else:
for i in range(N):
s=sorted(s)
if s[i]%10==0:
continue
else:
print(num-s[i])
sys.exit()
if len(s)==0:
print(0) |
p02880 | s289072862 | Accepted | N = int(input())
flag = False
for i in range(1,10):
if(N%i==0):
if((10-(N//i))>=1):
flag =True
break
if flag:
print("Yes")
else:
print("No") |
p02627 | s343379770 | Wrong Answer | import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import bisect_right
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
c = input()
if c in alf:
print("a")
else:
print("A") |
p03012 | s757309810 | Accepted | n = int(input())
w = list(list(map(int, input().split())))
ans = []
for t in range(n):
absolute = abs(sum(w[:t])-sum(w[t:]))
ans.append(absolute)
print(min(ans)) |
p03437 | s301163760 | Wrong Answer | x,y = map(int,input().split())
if x == y:
print(-1)
else:
print(x * 2) |
p03317 | s959824151 | Wrong Answer | N,K = map(int,input().split())
A = list(map(int,input().split()))
P = K - 1
print(N // P)
|
p03838 | s300151348 | Wrong Answer | x,y = map(int, input().split())
if abs(x) > abs(y):
x,y = y,x
ans = abs(y)-abs(x)
if x>0 and y<0:
ans += 1
elif x<0 and y>0:
ans += 1
elif x<0 and y<0:
ans += 2
print(ans)
|
p03286 | s327967347 | Wrong Answer | import sys
N = int(sys.stdin.readline())
if N == 0:
print(0)
sys.exit()
binN = ""
pN = abs(N)
while N != 0:
if abs(N % -2) == 1:
binN += "1"
else:
binN += "0"
N //= -2
print(binN[::-1]) |
p03419 | s307141064 | Accepted | n,m=map(int,input().split())
if n>=3 and m>=3:
a=n*m
b=n*2+m*2-4
ans=a-b
elif n==1 and m==1:
ans=1
elif n==1 or m==1:
a=n*m
b=2
ans=a-b
elif n==2 or m==2:
ans=0
print(ans)
|
p02768 | s627208675 | Accepted | def combi_mod(n, r, mod):
child = 1
mother = 1
for i in range(r):
child = child * (n-i) % mod
mother = mother * (i+1) % mod
return child * pow(mother, mod-2, mod) % mod
n, a, b = map(int, input().split())
mod = 10**9 + 7
ans = pow(2, n, mod) - 1
ans %= mod
ans += mod - combi_mod(n, a, mod)
ans %= mod
ans += mod - combi_mod(n, b, mod)
ans %= mod
print(ans) |
p03293 | s490079313 | Accepted | import numpy as np
s=input()
t=input()
for i in range(len(s)):
s=s[-1]+s[:-1]
if s==t:
print("Yes")
exit()
print("No") |
p02547 | s145042588 | Accepted | N=int(input())
D=list()
for i in range(N):
tmp=list(map(int,input().split()))
D.append(tmp[0]==tmp[1])
for i in range(N-2):
if D[i]==D[i+1]==D[i+2]==True:
print("Yes")
break
else:
print("No") |
p03219 | s961789987 | Wrong Answer | x,y = map(int,input().split())
print(x+y/2) |
p03698 | s542550776 | Wrong Answer | l = list(input())
strlen = l.__len__()
"no" if strlen - list(set(l)).__len__() else "yes" |
p03767 | s724812236 | Accepted | N,*A=map(int, open(0).read().split())
print(sum(sorted(A)[N::2])) |
p02608 | s525430838 | Accepted | n=int(input())
squre=int(n**0.5)
A=[0 for _ in range(10**6)]
for x in range(1,squre+1):
for y in range(1,squre+1):
for z in range(1,squre+1):
num=x**2+y**2+z**2+x*y+y*z+z*x
A[num] +=1
for i in range(n):
print(A[i+1]) |
p03041 | s842080817 | Wrong Answer | n,k=map(int,input().split())
s=input()
print(s.replace(s[k-1],s[k-1].lower())) |
p03623 | s444085334 | Accepted | x, a, b = map(int, input().split())
if abs(x - a) < abs(x - b):
print("A")
else:
print("B") |
p02814 | s211119459 | Wrong Answer | # 最大公約数
def gcd(a, b):
while b != 0:
a, b = b, a % b
return a
# 最小公倍数
def lcm(a, b):
return a * b // gcd(a, b)
N, M = map(int, input().split())
a = tuple(map(int, input().split()))
lcm_num = a[0]
lcm_half = a[0] // 2
for i in range(1, N):
tmp = a[i]
lcm_num = lcm(lcm_num, tmp)
lcm_half = lcm(lcm_half, tmp // 2)
print((M - lcm_half) // lcm_num + 1) |
p03633 | s924243770 | Accepted | from fractions import gcd
n = int(input())
t = [int(input()) for i in range(n)]
def lcm(x, y):
return (x*y) // gcd(x,y)
x = t[0]
for i in t[1:]:
x = lcm(i,x)
print (x) |
p02988 | s716857220 | Wrong Answer | def main():
n = int(input())
p = list(map(int, input().split()))
cnt = 0
for i in range(1,n-1):
if p[i-1] < p[i] < p[i+1]:
cnt += 1
print(cnt)
if __name__ == '__main__':
main() |
p03041 | s457055525 | Accepted | N, K = map(int, input().split())
S = [s for s in input()]
S[K-1] = S[K-1].lower()
print("".join(S))
|
p02786 | s638979847 | Wrong Answer | h=int(input())
n=len(list(bin(h)))-1
print(2**n-1) |
p02726 | s725549001 | Accepted | n,x,y=map(int,input().split())
li=[0]*(n-1)
num=0
for i in range(1,n+1):
for j in range(i+1,n+1):
num=min(j-i,abs(i-x)+abs(j-y)+1)
li[num-1]+=1
for i in li:
print(i) |
p02820 | s762061490 | Wrong Answer | N,K = map(int,input().split())
R,S,P = map(int,input().split())
T = input()
ans = 0
for i in range(N):
if i >= K:
if T[i] == T[i-K]:
continue
if T[i] == "r":
ans += P
elif T[i] == "s":
ans += R
else:
ans += S
print(ans)
|
p02854 | s538152821 | Accepted | N = int(input())
A = list(map(int, input().split()))
s = sum(A)
ans = float("inf")
cum = 0
for i in range(N-1):
cum += A[i]
ans = min(ans, abs(s - 2*cum))
print(ans) |
p04030 | s515928194 | Wrong Answer | S = input()
stack = []
for s in S:
if s == "B" :
if not stack:
continue
else:
stack.pop()
elif s == 0 or s==1:
stack.append(s)
print("".join(stack))
|
p03723 | s861877212 | Accepted | a, b, c = map(int, input().split())
count=0
while a%2==0 and b%2==0 and c%2==0:
ah=a//2
bh=b//2
ch=c//2
a=bh+ch
b=ch+ah
c=ah+bh
if a==b and a==c and a%2==0:
count=-1
break
else:
count+=1
print(count) |
p03038 | s733486008 | Wrong Answer | import numpy as np
n,m=map(int,input().split())
A=list(map(int,input().split()))
A=sorted(A)
A=np.array(A, dtype=np.int64)
D=[]
for _ in range(m):
b,c=map(int,input().split())
D+=[c]*b
if len(D)>=n:
D=D[-n:]
else:
D+=[0]*(n-len(D))
D=np.array(sorted(D, reverse=True), dtype=np.int64)
A=np.maximum(A,D)
print(np.sum(A)) |
p02646 | s281677294 | Wrong Answer | inputA = input()
inputB = input()
secIn = input()
sec = int(secIn)
splitA = inputA.split()
splitB = inputB.split()
curA = int(splitA[0])
a = int(splitA[1])
curB = int(splitB[0])
b = int(splitB[1])
d = curA - curB
dis = d if d > 0 else -d
result = "NO"
v = a - b
if v <= 0:
result = "NO"
elif dis % v != 0:
result = "NO"
elif dis / v < sec:
result = "YES"
else:
result = "NO"
print(result)
|
p03486 | s747142005 | Accepted | s = input()
t = input()
anas = sorted(s)
at = sorted(t,reverse = True)
if anas < at:
print('Yes')
else:
print('No')
|
p03759 | s398499667 | Wrong Answer | A, B, C = map(int,input().split())
if B - A == C - B:
print("YES")
else:
print("No") |
p03555 | s313465705 | Accepted | a=input()
b=input()
print('YES' if a==b[::-1] else 'NO')
|
p03633 | s566196642 | Accepted | import fractions
def lcm(a):
LCM = a[0]
for i in range(1, n):
LCM = LCM * a[i] // fractions.gcd(LCM, a[i])
return LCM
n = int(input())
t = []
for i in range(n):
t.append(int(input()))
print(lcm(t)) |
p03485 | s841555917 | Accepted | a, b=map(int,input().split())
print((a+b+1)//2) |
p03145 | s362916668 | Accepted | a,b,c = map(int,input().split())
print(a * b // 2)
|
p03075 | s697533958 | Wrong Answer | a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
x = e-a
if x <= 15:
print("Yay!")
else:
print(":(")
|
p03645 | s910233179 | Accepted | N,M=map(int,input().split())
AB=[list(map(int,input().split())) for i in range(M)]
lst=set()
for a,b in AB:
if b==N:
lst.add(a)
for a,b in AB:
if a==1:
if b in lst:
print("POSSIBLE")
exit()
print("IMPOSSIBLE")
|
p02576 | s161453833 | Wrong Answer | import math
n,x,t= map(float, input().split())
print(math.ceil(n/x)*t)
|
p02900 | s650712488 | Wrong Answer | a,b = [int(x) for x in input().split()]
import fractions
g = fractions.gcd(a,b)
ans = 1
flag = 0
mama = int(g**(1/2))
for i in range(2,mama+2):
while True:
if g%i != 0:
break
else:
g = g/i
flag = 1
if flag == 1:
ans += 1
flag = 0
if b == a and ans == 1:
ans += 1
print(ans) |
p03160 | s104763838 | Accepted | N = int(input())
H = list(map(int, input().split()))
def solve(H):
dp = [0]*N
dp[0] = 0
dp[1] = abs(H[1]-H[0])
for i in range(2,N):
dp[i] = min(dp[i-2]+abs(H[i]-H[i-2]),dp[i-1]+abs(H[i]-H[i-1]))
ans = dp[-1]
return ans
print(solve(H)) |
p03659 | s713016918 | Wrong Answer | n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
p=a[0]
q=0
for i in range(1,n):
if p-q>=0:
if a[i]>=0:
q+=a[i]
else:
p+=a[i]
else:
if a[i]>=0:
p+=a[i]
else:
q+=a[i]
if q==0:
p-=a[n-1]
q+=a[n-1]
print(abs(p-q)) |
p04031 | s922448516 | Wrong Answer | import numpy as np
n=int(input())
a=np.array([int(x) for x in input().split()])
x=[]
for i in a:
s=np.sum((a-i)*(a-i))
x.append(s)
print(min(x)) |
p03035 | s498575763 | Wrong Answer | a,b=map(int,input().split())
if a>12:
print(b)
elif 13>a>5:
print(b/2)
else:
print(0)
|
p02831 | s035548063 | Accepted | A, B = map(int, input().split())
n = 1
while True:
A_ = A * n
if A_ % B == 0:
print(A_)
exit()
n += 1 |
p03351 | s476364709 | Accepted | a,b,c,d=map(int,input().split())
if abs(c-a)<=d or (abs(b-a)<=d and abs(c-b)<=d):
print('Yes')
else:
print('No') |
p03696 | s783395188 | Accepted | N = int(input())
S = list(input())
l = "("
r = ")"
t = 0
k = 0
ma = 0
for i in range(N):
if S[i] == r:
t += 1
else:
k += 1
ma = max(ma, t - k)
A = [l] * ma + S + [r] * (ma + k - t)
print("".join(A)) |
p02608 | s390322803 | Accepted | #coding: UTF-8
import math
N = int(input())
#print(N)
ans = [0]*10001
for x in range(1,101):
for y in range(1,101):
for z in range(1,101):
a = x**2+y**2+z**2+x*y+y*z+z*x
if a <=10000:
ans[a] += 1
for i in range(1,N+1):
print(ans[i]) |
p03760 | s360700955 | Wrong Answer | import sys
input = sys.stdin.readline
O = list(input().rstrip())
E = list(input().rstrip())
ans = []
for i, j in zip(O, E):
ans.append(i)
ans.append(j)
print("".join(ans))
|
p03665 | s352854282 | Accepted | N, P = map(int, input().split())
A = list(map(int, input().split()))
odd = [a%2 for a in A].count(1)
even = N-odd
if(odd == 0):
print(0 if P == 1 else 2**N)
else:
print(2**(N-1)) |
p02664 | s734685111 | Wrong Answer | def main():
S = input()
S = S.replace("?", "P")
print(S)
if __name__ == "__main__":
main() |
p03030 | s846664053 | Accepted | n = int(input())
r = []
for i in range(n):
s,p = input().split()
p = -int(p)
r.append([s,p,i])
a = sorted(r)
for i in range(n):
print(a[i][2]+1)
|
p03241 | s125937996 | Wrong Answer | n,m = map(int,input().split())
if m%n==0:
print(int(m//n))
exit()
else:
a = m//n
l = []
for i in range(1,int(a**0.5)+1):
if m%i==0:
l.append(i)
if m//i<=a:
l.append(m//i)
l = sorted(l)[::-1]
if len(l)!=0:
print(l[0])
else:
print(1)
|
p02754 | s075396755 | Accepted | n,a,b=map(int,input().split())
c=n//(a+b)
d=n%(a+b)
print(a*c+min(d, a)) |
p04012 | s971906604 | Wrong Answer | w = input()
wl = list(w)
wu = list(set(wl))
wu_len = len(wu)
counter = 0
for wo in wu:
if wl.count(wo) % 2 == 0:
counter+=1
else:
print("No")
break
if counter == int(wu_len):
print("Yes")
else:
print("No") |
p02629 | s634510793 | Accepted | n=int(input())
a="abcdefghijklmnopqrstuvwxyz"
aa=list(a)
stra=""
kk=n
for i in range(15):
ki=(kk-1)%26+1
if ki!=0:
stra=aa[ki-1]+stra
else:
stra=aa[25]+stra
kk=(kk-ki)//26
# print(kk,ki,stra)
if kk==0:
break
print(stra) |
p02717 | s242296734 | Wrong Answer | li= list(map(int, input().split()))
li.insert(1, li.pop(0))
li.insert(2, li.pop(0))
li.insert(0, li.pop(1))
print(li)
|
p02835 | s773882471 | Wrong Answer | a = map(int, input().split())
n = sum(a)
if n <= 21:
print('win')
else:
print('burst')
|
p02628 | s764821963 | Accepted | import re
n, k = input().strip().split(' ')
p = [int(x.strip()) for x in input().strip().split(' ')]
p.sort()
sum = 0
for i in range(0, int(k)):
sum = sum + p[i]
print(sum) |
p02861 | s883626288 | Wrong Answer | import math
n=int(input())
m = [list(map(int, input().split())) for _ in range(n)]
ans=0
for i in range(n):
for j in range(i+1,n):
ans+=math.sqrt((m[i][0]-m[j][0])**2 + (m[i][1]-m[j][1])**2)
print(ans)
print(ans*2/n) |
p03261 | s403634481 | Wrong Answer | n = int(input())
z = list(input() for _ in range(n))
if len(set(z)) == len(z):
if all([z[i][-1] == z[i+1][0] for i in range(len(z)-1)]):
print('Yes')
else:
print('No')
|
p03778 | s718732813 | Accepted |
w,a,b = map(int,input().split())
if a <= b <= a+w:
print(0)
elif a+w <= b:
print(abs(b - (a+w)))
else:
print(abs(a - (b+w)))
|
p03544 | s219224627 | Accepted | def main():
n = int(input())
lucas_list = [2, 1]
for i in range(2, n + 1):
lucas_list.append(lucas_list[i - 1] + lucas_list[i - 2])
print(lucas_list[-1])
if __name__ == "__main__":
main()
|
p03778 | s686667132 | Accepted | w, a, b = map(int, input().split())
print (max(max(a,b)-(min(a,b)+w),0)) |
p03997 | s467284810 | Accepted | a = int(input())
b = int(input())
h = int(input())
print(int((a + b) * h / 2)) |
p03035 | s093282098 | Accepted | a,b=map(int,input().split())
if a>=13:
print(b)
elif a>=6:
print(b//2)
else:
print("0") |
p03659 | s050295759 | Accepted | def main():
N = int(input())
A = list(map(int, input().split(' ')))
cumsum = A
for i in range(1, N):
cumsum[i] += cumsum[i - 1]
ans = 10 ** 15
for i in range(N - 1):
ans = min([ans, abs(cumsum[i] - (cumsum[-1] - cumsum[i]))])
print(ans)
if __name__ == '__main__':
main() |
p02702 | s315657263 | Wrong Answer | S = input()
count = 0
S_len = len(S)
for i in range(S_len*5):
countstr = i * 2019
count += S.count(str(countstr))
print(count) |
p04034 | s616081594 | Accepted | N, M = map(int, input().split())
C = [1] * N
R = [1] + [0] * (N-1)
for _ in range(M):
x, y = map(int, input().split())
x, y = x-1, y-1
C[x] -= 1
C[y] += 1
if R[x]: R[y] = 1
if C[x] == 0: R[x] = 0
print(sum(R)) |
p03254 | s797475168 | Accepted | n,x=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
cnt=0
if sum(a) < x:
print(n-1)
exit()
for i in range(n):
if x>=a[i]:
cnt+=1
x-=a[i]
else:
break
print(cnt) |
p02720 | s298081766 | Accepted | K = int(input())
from collections import deque
que=deque([1,2,3,4,5,6,7,8,9])
for i in range(K):
x=que.popleft()
if x%10!=0:
que.append(10*x+(x%10-1))
que.append(10*x+x%10)
if x%10!=9:
que.append(10*x+(x%10+1))
print(x) |
p02696 | s632973684 | Accepted |
a,b,n=[int(x) for x in input().split()]
x=min((b-1),n)
f=(a*x)//b-(a*(x//b))
print(f) |
p02723 | s939394231 | Accepted | i = input()
san = i[2]
yon = i[3]
go = i[4]
roku = i[5]
if san == yon and go ==roku:
print("Yes")
else:
print('No') |
p02601 | s574481493 | Accepted | A, B, C = map(int, input().split())
K = int(input())
for _ in range(K):
if A >= B:
B *= 2
else:
C *= 2
print("Yes" if A < B < C else "No") |
p03795 | s136646026 | Wrong Answer | N = int(input())
x = N * 800
y = N % 15 * 200
print(x-y) |
p03261 | s155710777 | Wrong Answer | N = int(input())
W = [input() for i in range(N)]
print('Yes' if all(W[i+1][0] == W[i][-1] and W[i] not in W[:i] for i in range(N-1)) else 'No') |
p04033 | s734376266 | Accepted | def main():
a, b = map(int, input().split())
if a <= 0 <= b:
print("Zero")
elif a < 0 and (a - b + 1) % 2:
print("Negative")
else:
print("Positive")
if __name__ == '__main__':
main()
|
p03145 | s269951996 | Accepted | a, b, c = map(int, input().split())
r = a*b
if r%2 == 0:
print(r//2)
else:
print(r/2) |
p03659 | s161969514 | Wrong Answer | n = int(input())
lst1 = list(map(int,input().split()))
s = sum(lst1)
abs_ = 10**9+10
now = 0
i = 0
while True:
now += lst1[i]
if i >= n-1:
break
else:
abs_ = min(abs_,abs(now-(s-now)))
i += 1
print(abs_)
|
p02947 | s872524464 | Accepted | c={}
for _ in range(int(input())):
s=tuple(sorted(input()))
c[s]=c.get(s,0)+1
print(sum(v*(v-1)//2 for v in c.values())) |
p02553 | s863725297 | Accepted | import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
a, b, c, d = map(int, input().split())
ans = max(a * c, a * d, b * c, b * d)
print(ans)
|
p02862 | s379560105 | Wrong Answer | X, Y = map(int, input().split())
mod = 10**9+7
small = min(X, Y)
plus = X+Y
if not plus%3==0:
print(0)
else:
row = plus//3+1
col = Y-row+1
l, r = 1, 1
for c in range(col):
l = (l*(row-1-c))%mod
r = r*(c+1)%mod
print((l*pow(r, mod-2, mod))%mod) |
p02684 | s957045097 | Accepted | n, k = map(int, input().split())
a = list(map(int, input().split()))
num = 1
li = [1]
flag = [True]*n
flag[0] = False
for i in range(k):
num = a[num-1]
if flag[num-1]:
li.append(num)
flag[num-1] = False
else:
break
d = li.index(num)
ans = (k-d) % (len(li)-d)+d
print(li[ans])
|
p03838 | s973307248 | Wrong Answer | import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
x, y = map(int, input().split())
r1 = abs(-x - -y) + 2
r2 = abs(x - - y) + 1
r3 = abs(-x - y) + 1
r4 = abs(x - y)
r = min(r1, r2, r3, r4)
print(r)
if __name__ == '__main__':
main()
|
p03013 | s351697770 | Wrong Answer | n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
ans=0
MOD= 1000000007
c=[0]*(n+1)
c[0]=1
if 1 in a:
c[1]=0
else:
c[1]=1
for i in range(2,n+1):
c[i]+=(c[i-1]+c[i-2])%MOD
if i in a:
continue
print(c[n]%MOD) |
p02922 | s358008299 | Accepted | A, B = map(int, input().split())
ans = 0
tap = 0
for i in range(10000):
if B == 1:
break
if i == 0:
tap += A
ans += 1
if i >= 1:
tap -= 1
tap += A
ans += 1
if tap >= B:
break
print(ans) |
p02689 | s108441197 | Accepted | N,M = map(int, input().split())
*H, = map(int, input().split())
V = []
for node in range(N):
V.append(set())
for _ in range(M):
a,b = map(int, input().split())
V[a-1].add(b-1)
V[b-1].add(a-1)
ans = 0
for node in range(N):
Hi = H[node]
flg = 0
for next_node in V[node]:
if Hi>H[next_node]:
continue
flg = 1
if flg==0:
ans = ans + 1
elif len(V[node])==0:
ans = ans + 1
print(ans) |
p03854 | s277211926 | Wrong Answer | s=input()
s=s.replace("eraser","")
s=s.replace("erase","")
s=s.replace("dreamer","")
s=s.replace("dream,","")
if s:
print("NO")
else:
print("YES") |
p02664 | s051807538 | Wrong Answer | T=input()
T_len=len(T)
S=list(T)
if S[0]=="?":
S[0]="P"
for i in range(T_len):
if S[i]=="?":
if S[i-1]=="P":
S[i]="D"
else:
S[i]="P"
str_changed = "".join(S)
print(str_changed) |
p03073 | s363221584 | Accepted | S=input()
cnt=0
for i in range(len(S)):
if i%2==int(S[i]):
cnt+=1
print(min(cnt,len(S)-cnt))
|
p03760 | s018934676 | Wrong Answer | ans=''
a, b = (input() for _ in range(2))
for i, j in zip(a, b):
ans += i + j
print(ans) |
p03309 | s033053349 | Wrong Answer | n = int(input())
a = list(map(int , input().split()))
b = [a[i] - (i+1) for i in range(n)]
#print(b)
b.sort()
ans = 10 ** 10
for j in range(3):
bi = b[((n-1)//2+j)%n]
s = 0
for i in range(n):
s += abs(b[i] - bi)
#print(((n-1)//2+j)%n, s)
ans = min(ans, s)
print(ans) |
p02923 | s641071016 | Accepted | N = int(input())
H = list(map(int, input().split()))
ans = 0
cnt = 0
pre = H[0]
for h in H[1:]:
if h <= pre:
cnt += 1
else:
ans = max(ans, cnt)
cnt = 0
pre = h
if cnt != 1:
ans = max(ans, cnt)
print(ans)
|
p03163 | s265711865 | Accepted | ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))
import numpy as np
n,W = mi()
a = [tuple(int(i) for i in input().split()) for _ in range(n)]
dp = np.array([0]*(W+1))
for w,v in a:
ed = W+1-w
dp[w:W+1] = np.maximum(dp[w:W+1], dp[0:W+1-w] + v)
print(dp[W]) |
p03711 | s444484089 | Wrong Answer | n1 = set([1, 3, 5, 7, 8, 10, 12])
n2 = set([4, 6, 9, 11])
n3 = set([2])
nums = {map(int, input().split())}
print("Yes" if nums <= n1 or nums <= n2 or nums <= n3 else "No")
|
p02779 | s125884998 | Wrong Answer | N = int(input())
A = [int(x) for x in input().split()]
d = []
p = 0
for i in range(N):
d.append(A[i])
if A[i] in d:
p = 1
break
if p == 0:
print("YES")
else:
print("NO")
|
p03206 | s357672422 | Accepted | d = 25 - int(input())
print("Christmas" + " Eve" * d)
|
p02756 | s609237873 | Accepted | s = input()
q = int(input())
add_s = ['', ''] #pre, post
rev_flag = 0
for i in range(q):
query = input()
if query == '1':
rev_flag = (rev_flag+1)%2
else:
_, f, c = query.split()
if f == '1':
add_s[rev_flag] += c
else:
add_s[(rev_flag+1)%2] += c
if rev_flag == 1:
s = s[::-1]
print(add_s[rev_flag][::-1]+s+add_s[(rev_flag+1)%2]) |
p02829 | s660119735 | Wrong Answer | a=int(input())
b=int(input())
c=0
if a==1:
if b==2:
c=3
if b==3:
c=2
elif a==2:
if b==1:
c==3
if b==3:
c==1
elif a==3:
if b==1:
c==2
if b==2:
c==1
print(c) |
p02642 | s797451216 | Accepted | from collections import Counter
N = int(input())
a = sorted(list(map(int, input().split())))
M = 10**6
table = [1] * (M + 1)
B = Counter(a)
Key = list(B.keys())
count = 0
for x in Key:
if B[x] == 1 and table[x] == 1:
count += 1
for i in range(M):
if i * x > M:
break
else:
table[i * x] = 0
print(count)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.