problem_id stringclasses 428 values | submission_id stringlengths 10 10 | status stringclasses 2 values | code stringlengths 5 816 |
|---|---|---|---|
p03611 | s217027648 | Wrong Answer | from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))
from collections import Counter
n=int(input())
a=lnii()
c=Counter(a)
a_max=max(a)
ans=0
for i in range(1,a_max):
t_ans=c[i-1]+c[i]+c[i+1]
ans=max(ans,t_ans)
print(ans) |
p02717 | s761987503 | Accepted | x,y,z = map(int, input().split())
print(z, x, y)
|
p02873 | s671619196 | Wrong Answer | s = input()
n = len(s) + 1
t = [0]*n
for i in range(n-1):
if s[i] == '<':
t[i+1] = t[i] + 1
for i in range(n-2,1,-1):
if s[i] == '>':
t[i] = max(t[i],t[i+1]+1)
print(sum(t)) |
p03206 | s717760673 | Wrong Answer | d = int(input())
if d == 25: print("Christmas")
elif d == 24: print("Christmas Eve")
elif d == 23: print("Christmas Eve")
elif d == 22: print("Christmas Eve Eve Eve") |
p02785 | s414634794 | Accepted | n,k=map(int,input().split())
h=list(map(int,input().split()))
if n<=k:
print(0)
else:
h.sort()
print(sum(h[0:(n-k)]))
|
p03324 | s230553605 | Accepted | d,n = map(int,input().split())
if n == 100:
print(101*(100**d))
exit()
if d == 0:
print(n)
elif d == 1:
print(100*n)
else:
print(10000*n)
|
p02682 | s543079117 | Wrong Answer | A,B,C,K=map(int,input().split())
if K>A+B:
K=K-(A+B)
ans=A-K
else:
ans=A
print(ans)
|
p03627 | s424059391 | Accepted | n,*L = map(int,open(0).read().split())
from collections import Counter
L = Counter(L)
li = []
for k,v in L.items():
li.append([k,v])
li.sort(reverse = True)
LL = []
for i in range(len(li)):
if li[i][1] >= 2:
LL.append(li[i])
if len(LL) == 0:
print(0)
exit()
if LL[0][1] >= 4:
print(LL[0][0]**2)
elif len(LL) >=2:
print(LL[0][0]*LL[1][0])
else:
print(0) |
p03038 | s821717718 | Accepted | N,M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
T = []
for i in range(M):
a,b = map(int,input().split())
T.append([b,a])
T.sort(reverse=True)
ans = 0
c = 0
k = 0
t = len(T)
for i in range(N):
if c == t:
break
n = T[c][0]
l = T[c][1]
k += 1
if A[i] < n:
A[i] = n
else:
break
if k == l:
c += 1
k = 0
print(sum(A)) |
p03986 | s255725458 | Accepted | import sys
X = sys.stdin.readline().rstrip()
S = 0
T = 0
ans = 0
for x in X:
if x == "S":
S += 1
else:
if not S:
ans += 1
else:
S -= 1
ans += S
print(ans) |
p03632 | s496628173 | Wrong Answer | a, b, c, d = map(int, input().split())
if(a > d):
print(0)
elif(c <= a <= d and b >= d):
print(d-a)
elif(a < c and b >= d):
print(d-c)
elif(c <= b):
print(b-c)
elif(b < c):
print(0) |
p03745 | s873574435 | Accepted | n = int(input())
a = list(map(int, input().split()))
ans = 1
m = 0
for i in range(1, n):
if (a[i] - a[i - 1]) * m < 0:
ans += 1
m = 0
elif a[i] - a[i - 1] != 0:
m = a[i] - a[i - 1]
print(ans) |
p03472 | s007690873 | Accepted | n,h=map(int, input().split())
a_l=[]
b_l=[]
for _ in range(n):
a,b=map(int, input().split())
a_l.append(a)
b_l.append(b)
a_l.sort(reverse=True)
b_l.sort(reverse=True)
a_max=max(a_l)
b_strong=[]
for b_i in b_l:
if b_i>a_max:
b_strong.append(b_i)
cnt=0
for b_s in b_strong:
if h>0:
h-=b_s
cnt+=1
else:
break
if h>0:
cnt+=(h-1)//a_max+1
print(cnt)
|
p02594 | s208959104 | Accepted | x = int(input())
if x >= 30:
print('Yes')
else:
print('No')
|
p03544 | s013149764 | Accepted |
N = int(input())
L = [2, 1] + [0] * (N-1)
for i in range(2, N+1):
L[i] = L[i-1] + L[i-2]
print(L[N]) |
p03721 | s771890141 | Wrong Answer | n,k=map(int,input().split())
a=[[int(i) for i in input().split()] for i in range(n)]
b=[]
x=0
for i in a:
x+=i[1]
b.append([i[0],x])
for i in range(len(b)-1):
if b[i][1]<k<=b[i+1][1]:
print(b[i+1][0]) |
p03997 | s417770317 | Wrong Answer | a = int(input())
b = int(input())
h = int(input())
ans = (a + b)*h / 2
print(ans) |
p03338 | s197096363 | Accepted | import collections
N,S = open(0).read().split()
max_d = 0
for i in range(int(N)):
A = set(list(S[:i]))
B = set(list(S[i:]))
if max_d < len(A&B):
max_d = len(A&B)
print(max_d) |
p03469 | s438368448 | Accepted | S = input()
ans = '2018' + S[4:]
print(ans) |
p02633 | s493933495 | Accepted | x = int(input())
k = 0
while True:
k += 1
if (x * k)%360 == 0:
print(k)
break
|
p02854 | s889124312 | Wrong Answer | #B - Iron Bar Cutting
import bisect
N = int(input())
A = list(map(int,input().split()))
length = []
cnt = 0
for i in A:
cnt += i
length.append(cnt)
trg_idx_l = bisect.bisect_left(length,length[-1]//2)
if length[trg_idx_l] == length[-1]:
ans = A[-1]-A[-2]*2
else:
# length[-1] - ans = 2*(length[target] - ans)
ans = 2*length[trg_idx_l] - length[-1]
print(ans) |
p03206 | s751426750 | Wrong Answer | D = int(input())
A = ["Chrinstmas"]
for i in range(25 - D):
A.append("Eve")
S = ' '.join(A)
print(S)
|
p02787 | s820373319 | Accepted | def main():
h, n = map(int, raw_input().split())
ab = []
for _ in xrange(n):
a, b = map(int, raw_input().split())
ab.append([a, b])
dp = [float('inf')] * (h + 1)
dp[0] = 0
for i in range(1, h + 1):
for a, b in ab:
dp[i] = min(dp[i], b + dp[max(0, i - a)])
print dp[-1]
main()
|
p02608 | s746525156 | Wrong Answer | import math
n=int(input())
ans=[0]*(10**5)
for x in range(int(math.sqrt(n))+1):
for y in range(int(math.sqrt(n))+1):
for z in range(int(math.sqrt(n))+1):
ans[((x+y)**2+(y+z)**2+(z+x)**2)//2-1]+=1
for i in range(n):
print(ans[i]) |
p02641 | s940982515 | Accepted | x,n=map(int,input().split())
p=list(map(int,input().split()))
for i in range(1000):
if x-i not in p:
print(x-i)
exit()
if x+i not in p:
print(x+i)
exit()
|
p02731 | s681672325 | Wrong Answer | L = int(input())
num = L//3
print(num*num*num) |
p02683 | s179757818 | Accepted | import itertools
n, m, x = map(int, input().split())
c = []
d = []
for i in range(n):
s = list(map(int, input().split()))
#a = s.pop(0)
#c.append(a)
d.append(s)
ans = 10**9
for i in range(1,n+1):
for j in itertools.combinations(d,i):
s = [0 for ii in range(m+1)]
for k in j:
for l in range(m+1):
s[l] += k[l]
y = min(s[1:])
if y >= x:
ans = min(ans,s[0])
if ans == 10**9:
print (-1)
else:
print (ans)
|
p03131 | s390523127 | Accepted | k, a, b = map(int, input().split())
if b - 2 <= a or k < a + 1:
print(k + 1)
else:
r = k - (a - 1)
print((r // 2 - 1) * (b - a) + b + r % 2) |
p03494 | s794027200 | Accepted | n=int(input())
a=list(map(int,input().split()))
count=0
while True:
temp=0
for i in range(0,n):
if a[i]%2==0:
temp=temp+1
a[i]=int(a[i]/2)
if temp==n:
count=count+1
else:
break
print(count) |
p03264 | s059055398 | Wrong Answer | K = int(input())
print(pow(K//2,2)) if K % 2 == 0 else print(pow((K+1)//2,2)) |
p02678 | s850190130 | Accepted | from collections import deque
r, p = map(int, input().split())
graph = [[] for _ in range(r)]
for x in range(p):
x1, x2 = map(int, input().split())
graph[x1-1].append(x2-1)
graph[x2-1].append(x1-1)
q = deque([0])
res = [-1]*r
res[0] = 0
while q:
l = q.popleft()
for x in graph[l]:
if res[x] == -1:
res[x] = l
q.append(x)
if -1 in res[1:]:
print("No")
exit()
print("Yes")
for x in res[1:]:
print(x+1) |
p02584 | s868105788 | Accepted | X, K, D = map(int, input().split())
X = abs(X)
if K*D <= X:
print(abs(X - K*D))
else:
m = X // D
re = K - m
if re % 2 == 0:
print(abs(X - D*m))
else:
print(abs(X - D*(m+1)))
|
p03481 | s803303126 | Accepted | x, y = map(int, input().split())
ans = 0
while x <= y:
x *= 2
ans += 1
print(ans)
|
p03359 | s372240669 | Wrong Answer | a,b= map(int,input().split())
if b>a:
print(a)
else:
print(a-1) |
p03644 | s384099740 | Wrong Answer | n = int(input())
ans = 0
m = 0
for i in range(2,n+1,2):
a = 0
x = i
while(True):
if x%2!=0:
break
a+=1
x = x//2
if a>m:
m=a
ans=i
print(ans) |
p02689 | s001125267 | Wrong Answer | n, m = map(int, input().split())
h = list(map(int, input().split()))
lis = [1] * n
for i in range(m):
a, b = map(int, input().split())
h[a-1]
h[b-1]
if h[a-1] < h[b-1]:
lis[a-1] = 0
h[a-1] = h[b-1]
elif h[a-1] > h[b-1]:
lis[b-1] = 0
h[b-1] = h[a-1]
else:
lis[a-1]=0
lis[b-1]=0
print(len([i for i in lis if i == 1])) |
p03705 | s476099757 | Wrong Answer | N,A,B = (int(x) for x in input().split())
if N == 1:
if A != B:
print('0')
else:
print('1')
elif A > B:
print('0')
elif A == B:
print('1')
else:
print((N-2)*(B-A+4-N)+1) |
p03211 | s437700881 | Accepted | import sys
import numpy as np
import numba
from numba import jit
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def main(s):
ans = 1<<10
for i in range(len(s)-2):
num = int(s[i:i+3])
ans = min(abs(num-753), ans)
return ans
s = input().strip()
print(main(s))
|
p03611 | s399940946 | Accepted | import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7
def main():
N = int(input())
A = list(map(int, input().split()))
d = defaultdict(int)
for i in range(N):
d[A[i]-1] += 1
d[A[i]] += 1
d[A[i]+1] += 1
print(max(d.values()))
if __name__ == '__main__':
main() |
p02694 | s744850821 | Wrong Answer | x=int(input())
year=0
for i in range(0,x+1):
year+=(x*1/100)
print(year) |
p02707 | s373274553 | Accepted | import collections
N = int(input())
A = list(map(int,input().split()))
c = collections.Counter(A)
for i in range(1,N+1):
print(c[i]) |
p03611 | s626239207 | Accepted | from collections import defaultdict
n = int(input())
arr = list(map(int, input().split()))
d = defaultdict(int)
for x in arr:
d[x] += 1
a = d[0] + d[1] + d[2]
ans = [a]
for i in range(max(arr) - 2):
a -= d[i]
a += d[i + 3]
ans.append(a)
print(max(ans)) |
p02628 | s577905049 | Accepted | #b
N,K=map(int,input().split())
A = list(map(int, input().split()))
A.sort()
ans=0
for i in range(K):
ans+=A[i]
print(ans) |
p02958 | s485505958 | Accepted | n = int(input())
p = list(map(int,input().split()))
a = [i for i in range(1,n+1)]
c = 0
for i in range(n) :
if a[i] != p[i] :
c += 1
print("YES" if c<=2 else "NO")
|
p02771 | s569845287 | Wrong Answer | A = list(map(int , input().split()))
if len(A) != A.count(A[0]):
print('Yes')
else:
print('No') |
p02784 | s302157379 | Accepted | h, n = map(int, input().split())
m = [i for i in input().split()]
result = 0
for i in m:
result += int(i)
if result >= h:
print('Yes')
else:
print('No') |
p02681 | s543203397 | Wrong Answer | s = input()
t = input()
if s == t[:len(t)]:
print('Yes')
else:
print('No') |
p02922 | s358240687 | Accepted | A,B=map(int,input().split())
tap=1
cnt=0
while tap<B:
tap+=A-1
cnt+=1
print(cnt) |
p03037 | s751593265 | Wrong Answer | n, m = map(int, input().split())
left = 1
right = n
for i in range(m):
l, r = map(int, input().split())
left = max(left, l)
right = min(right, r)
print(right-left+1) |
p03146 | s501606026 | Wrong Answer |
import math
import itertools
import statistics
#import collections
#n = list(map(int, input().split()))
s = int(input())
def calc_f(n):
if n%2==0:
return n/2
else:
return 3*n+1
count1 = 0
a = [s]
while count1<2:
s = calc_f(s)
a.append(s)
if s==1:
count1+=1
#print(a)
print(a.index(1)+2)
|
p03632 | s336963751 | Accepted | a, b, c, d = map(int, input().split())
ans = min(b, d)-max(a, c)
if ans < 0:
print(0)
else:
print(ans)
|
p03557 | s955937636 | Accepted | import bisect as bi
def main():
from builtins import input, int, map
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort()
C.sort()
ans = 0
for i in range(N):
a = bi.bisect_left(A,B[i])
c = N-bi.bisect_right(C,B[i])
ans += a*c
print(ans)
main()
|
p03474 | s648133874 | Wrong Answer | A,B=map(int,input().split())
S=input()
if (S[0:A].isdecimal()==True) and (S[A+1:-1].isdecimal()==True) and (S[A]=='-') and len(S)==(A+B+1):
print('Yes')
else:
print('No') |
p02951 | s649422558 | Accepted | a, b, c = map(int,input().split())
x = c - (a - b)
if x > 0:
print(x)
else:
print(0) |
p02935 | s042825725 | Wrong Answer | n = int(input())
vi = list(map(int,input().split()))
if n%2 == 0:
mean = sum(vi)/len(vi)
print(mean)
else:
vi.sort()
saidai = vi.pop(-1)
mean = sum(vi)/len(vi)
ans = (mean+saidai)/2
print(ans)
|
p03796 | s540665375 | Wrong Answer | n = int(input())
powwer = 1
if n > 1:
for i in range(1, n+1):
powwer *= i
ans = powwer
print(int(ans)) |
p03861 | s082144826 | Accepted | a,b,x=map(int,input().split())
print(b//x-(a-1)//x) |
p02972 | s451638517 | Accepted | N = int(input())
A = list(map(int,input().split()))
B = [0] * N
M = 0
ans = []
for i in range(N,0,-1):
S, idx = 0, i-1
while idx <= N-1:
S += B[idx]
idx += i
if S % 2 != A[i-1]:
B[i-1] = 1
M += 1
ans.append(i)
print(M)
for a in ans:
print(a, end=" ")
print("") |
p02729 | s743685969 | Wrong Answer | N, M = map(int,input().split())
X = N*(N+1)/2 + M*(M+1)/2
print(X) |
p02882 | s376295849 | Accepted | """
import math
a, b, x = list(map(float, input().split()))
theta = 0
if x >= a * a * b / 2:
theta = math.atan((2.0 * (a * a * b - x)) / (a ** 3)) / (2 * math.pi) * 360
else:
theta = math.atan((a * b * b) / 2.0 * x) / (2 * math.pi) * 360
print(theta)
"""
from math import atan, pi
a, b, x = map(int, input().split())
if x >= a * a * b / 2:
print(atan((a*a*b-x)/(a*a*a/2))/(2 * pi)*360)
else:
print(90 - atan(x/(a*b*b/2))/(2 * pi)*360)
|
p03286 | s746229778 | Accepted | N = int(input())
b = -2
a = []
def d(n):
if n > 0:
return -(-n//b)
elif n < 0:
return (n-1)//b
def r(n):
if n%b < 0:
return -(n%b)
else:
return n%b
while N != 0 and N != 1:
a.append(r(N))
N = d(N)
if N == 1:
a.append(N)
else:
a.append(0)
a.reverse()
ans = "".join(map(str,a))
print(ans) |
p03493 | s514236602 | Wrong Answer | s = input()
number = 0
for i in range(len(s)):
if s[i] == 1:
number += 1
print(number) |
p02621 | s234697917 | Wrong Answer | a = int(input("Enter an integer : "))
s=a**2
t=a**3
print(a+s+t) |
p03309 | s358650668 | Wrong Answer | import numpy as np
from collections import Counter
n = int(input())
l = np.array([int(i) for i in input().split()])
l2 = np.array([i for i in range(1,n+1)])
c = Counter(l-l2)
mode = c.most_common()[0][0] if c.most_common()[0][1] != 1 else 0
print(abs((l- (l2 + mode))).sum())
|
p03030 | s779252808 | Accepted | N=int(input())
S=[]
for i in range(N):
s, n=input().split()
S.append([s,int(n),i+1])
S.sort(key=lambda x:(x[0], -x[1]))
[print(p[2]) for p in S] |
p03720 | s442286623 | Accepted | tmp = input().split()
n = int(tmp[0])
m = int(tmp[1])
a = [0] * m
b = [0] * m
for i in range(m):
tmp = input().split()
tmp = list(map(int,tmp))
a[i] = tmp[0]
b[i] = tmp[1]
arr = [[0] * (n+1) for i in range(n+1)]
for i in range(m):
arr[a[i]][b[i]] += 1
arr[b[i]][a[i]] += 1
for i in range(1,n+1):
count = 0
for k in range(len(arr[i])):
if arr[i][k] != 0:
count += arr[i][k]
print(count)
|
p03059 | s934664992 | Accepted | a,b,t=map(int,input().split())
n=t//a
print(n*b) |
p03705 | s707908806 | Accepted | n,a,b = map(int,input().split())
if n == 1:
if a == b:
ans = 1
else:
ans = 0
else:
if a > b:
ans = 0
elif a == b:
ans = 1
else:
ans = (n-2)*(b-a)+1
print(ans) |
p03059 | s158845533 | Accepted | A,B,T = map(int,input().split())
print(int((T+0.5)//A*B)) |
p03206 | s427549730 | Accepted | D=int(input())
if D==25:
print('Christmas')
elif D==24:
print('Christmas Eve')
elif D==23:
print('Christmas Eve Eve')
else:
print('Christmas Eve Eve Eve') |
p03328 | s252307959 | Accepted | import sys
import math
import bisect
def solve(a, b):
n = b - a - 1
A = sum(list(range(1, n + 1)))
return A - a
def main():
a, b = map(int, input().split())
print(solve(a, b))
if __name__ == "__main__":
main()
|
p03797 | s710021535 | Accepted | S,C=map(int,input().split())
ans=0
#1
ans+=min(S,C//2)
S,C=S-ans,C-ans*2
if C>1:
ans+=C//4
print(ans) |
p02995 | s807272521 | Wrong Answer | import math
a,b,c,d = map(int, input().split())
e = c*d/(math.gcd(c,d))
ac = math.ceil(a/c)
bc = math.floor(b/c)
ad = math.ceil(a/d)
bd = math.floor(b/d)
ae = math.ceil(a/e)
be = math.floor(b/e)
if b/c-a/c<1:
xc = 0
else:
xc = bc-ac + 1
if b/d-a/d<1:
xd = 0
else:
xd = bd-ad + 1
if b/e-a/e<1:
xe = 0
else:
xe = be-ae + 1
f = xc + xd - xe
g = b-a+1
h = g - f
print(h) |
p02947 | s757545730 | Accepted | S=[]
n = int(input())
for i in range(n):
s=''.join(sorted(input()))
S.append(s)
import collections
from scipy.special import comb
a=0
Sd=list(set(S))
c = collections.Counter(S)
for p in range(len(Sd)):
if c[Sd[p]] >=2:
a += comb(c[Sd[p]], 2, exact=True)
print(a) |
p02658 | s767422639 | Accepted | n=int(input())
l=sorted(list(map(int,input().split())))
s=1
d=1
for i in l:
s=s*i
if(s>10**18):
print(-1)
d=0
break
if(d==1):
print(s) |
p02744 | s742530181 | Wrong Answer | N = int(input())
chars = [chr(i) for i in range(ord('a'), ord('z')+1)]
ans = []
def dfs(s):
if len(s) == N:
# print(s)
ans.append(s)
return
end = s[-1]
end_i = chars.index(end)
for i in range(end_i + 2):
ns = s + chars[i]
# print('-', i, ns)
dfs(ns)
dfs('a')
ans.sort()
for si in ans:
print(si) |
p02882 | s607432980 | Wrong Answer | #!/usr/bin/env python3
import math
a, b, x = list(map(int, input().split()))
tan_theta = a*b*b/(2*x)
if tan_theta <= a/b:
tan_theta = 2*(b*a*a-x)/(a*a*a)
print(math.degrees(math.atan(tan_theta)))
|
p03331 | s847419598 | Accepted | n = int(input())
sum_min = 100000
for i in range(1,n):
i_sum = 0; j_sum = 0
j = n-i
i = str(i); j = str(j)
for k in range(len(i)):
i_sum += int(i[k])
for k in range(len(j)):
j_sum += int(j[k])
tmp_sum = i_sum + j_sum
if sum_min >tmp_sum :
sum_min = tmp_sum
print(sum_min) |
p03329 | s226412461 | Accepted | n = int(input())
count=n
for i in range(0,n+1):
temp=0
temp6=i
while temp6>0:
temp=temp+temp6%6
temp6=int(temp6/6)
temp9=n-i
while temp9>0:
temp=temp+temp9%9
temp9=int(temp9/9)
count=min(count,temp)
print(count) |
p03386 | s497201399 | Accepted | A,B,K=map(int,input().split())
C=set()
for i in range(A,min(A+K,B+1)):
C.add(i)
for i in range(max(B-K+1,A),B+1):
C.add(i)
for x in sorted(list(C)):
print(x) |
p02814 | s156607126 | Wrong Answer | from fractions import gcd
from functools import reduce
n,m= map(int,input().split())
a_list = list(map(int,input().split()))
def lcm_base(x, y):
return (x * y) // gcd(x, y)
def lcm_list(numbers):
return reduce(lcm_base, numbers, 1)
lcm_value = lcm_list(a_list)
print((m*2//lcm_value+1)//2) |
p02989 | s217363744 | Accepted | n = int(input())
d = list(map(int,input().split()))
arc_list = list()
abc_list = list()
harf_num = int(n/2)
d.sort()
abc_list = d[:harf_num]
arc_list = d[harf_num:]
abc_max = max(abc_list)
arc_min = min(arc_list)
print(arc_min - abc_max) |
p02777 | s851089908 | Wrong Answer | import sys
import collections
def solve():
input = sys.stdin.readline
mod = 10 ** 9 + 7
d = collections.defaultdict(int)
st = list(map(str, str(input().rstrip('\n')).split()))
ab = list(map(str, str(input().rstrip('\n')).split()))
for s, v in zip(st, ab):
d[s] = int(v)
d[str(input().rstrip('\n'))] -= 1
print(*d.values())
if __name__ == '__main__':
solve()
|
p03220 | s110266231 | Wrong Answer | input()
T,A = map(int,input().split())
a = list(map(int,input().split()))
min_val = T-A
min_num=0
for i in range(len(a)):
if abs(T-0.006*a[i]-A) <= min_val:
min_val = abs(T-0.006*a[i]-A)
min_num = i
print(min_num+1) |
p03339 | s841596508 | Accepted | n = int(input())
s = input()
E = [0] * (n + 10)
W = [0] * (n + 10)
e = 0
w = 0
for i in range(n):
if s[i] == "E":
e += 1
else:
w += 1
W[i+1] = w
E[i+1] = e
ans = float("inf")
for i in range(1, n+1):
x = 0
x += W[i-1]
x += E[n]-E[i]
ans = min(ans, x)
print(ans) |
p03146 | s669629084 | Accepted | def solve():
N = int(input())
table = [False] *1000000
table[N] = True
count = 1
while True:
if N&1:
N = 3*N + 1
else:
N = N//2
count += 1
if not table[N]:
table[N] = True
else:
print(count)
break
if __name__ == '__main__':
solve() |
p02952 | s098027083 | Wrong Answer | n = int(input())
if n < 10:
print(n)
elif n < 10**2:
print(9)
elif n < 10**3:
print(10+(n%100))
elif n < 10**4:
print(109)
elif n < 10**5:
print(909 + 9*((n%10000)+1))
else:
print(90909) |
p02713 | s583481377 | Accepted | from math import gcd
K=int(input())
result=[]
count=0
cnt=0
for i in range(1,K+1):
for j in range(1,K+1):
for k in range(1,K+1):
cnt+=gcd(gcd(i,j),k)
print(cnt)
|
p02547 | s506331955 | Accepted | N = int(input())
list_D = [list(map(int, input().split())) for i in range(N)]
count = 0
for i in range(N-2):
if list_D[N-i-1][0] == list_D[N-i-1][1] and list_D[N-i-2][0] == list_D[N-i-2][1] and list_D[N-i-3][0] == list_D[N-i-3][1]:
count += 1
if count > 0:
print('Yes')
else:
print('No') |
p03220 | s284318859 | Accepted | import numpy as np
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
H = np.array(H)
temp = T-H*0.006
res = np.abs(temp-A)
print(np.argmin(res)+1) |
p03680 | s650666186 | Wrong Answer | n = int(input())
A = [int(input()) for _ in range(n)]
used = {1}
pos = 1
count = 0
for _ in range(n):
pos = A[pos - 1]
count += 1
if pos in used:
print(-1)
break
if pos == 2:
print(count)
break |
p03565 | s045564463 | Accepted | import re
s = input().replace('?', '.')
t = input()
for i in range(len(s)-len(t),-1,-1):
if re.match(s[i:i+len(t)], t):
s = s[:i] + t + s[i+len(t):]
s = s.replace('.', 'a')
print(s)
exit(0)
print('UNRESTORABLE')
|
p02631 | s401945237 | Accepted | n = int(input())
arr = [int(x) for x in input().split()]
xor = 0
for x in arr:
xor = xor ^ x
result = []
for i in range(n):
result.append(str(xor ^ arr[i]))
print(" ".join(result))
|
p03524 | s776218894 | Wrong Answer | S = [s for s in str(input())]
d = len(S) // 3
from collections import Counter
cntr = sorted(list(Counter(S).values()))
if cntr == [d,d,d] or cntr == [d,d,d+1] or cntr == [d,d+1,d+1]:
print('YES')
else:
print('NO') |
p03659 | s554592175 | Accepted | n = int(input())
a = list(map(int,input().split()))
ans = float("INF")
X = sum(a)
x = 0
for i in range(n):
x += a[i]
if i+1 < n:
ans = min(ans,abs(X-2*x))
print(ans)
|
p02838 | s735903200 | Accepted | import numpy as np
N = int(input())
num_list = np.array(input().split(), dtype="int")
max_num = max(num_list)
max_bit_num = format(max_num, "b")
max_bit_num_length = len(max_bit_num)
ans = 0
radix = 1
for i in range(max_bit_num_length):
new_num_list = (num_list >> i) & 1
one_amount = np.count_nonzero(new_num_list == 1)
zero_amount = len(num_list) - one_amount
ans += (one_amount*zero_amount)*radix
radix *= 2
print(ans%(10**9+7)) |
p03252 | s055375725 | Accepted | from collections import Counter
s=Counter(Counter(input()).values())
t=Counter(Counter(input()).values())
print('Yes' if s==t else 'No') |
p03695 | s745920063 | Wrong Answer | from collections import Counter
n = int(input())
a = [min(x//400, 8) for x in map(int, input().split())]
a = Counter(a)
#max:8 , over 8
if a[8] != 0:
min_a = len(a)-1
else:
min_a = len(a)
max_a = min([min_a+a[8], 8])
print(min_a, max_a) |
p02696 | s747618916 | Accepted | A,B,N=map(int,input().split())
x=min(B-1,N)
print(A*x//B-A*(x//B)) |
p03592 | s966110543 | Wrong Answer | h,w,k = map(int,input().split())
for x in range(1,1001):
for y in range(1,1001):
if w*x + h*y - 2*x*y == k and 0<= x <= h and 0<= y <= w:
print("Yes")
exit()
print("No") |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.