problem_id stringclasses 428
values | submission_id stringlengths 10 10 | status stringclasses 2
values | code stringlengths 5 816 |
|---|---|---|---|
p03319 | s384240929 | Accepted | N,K = map(int,input().split())
A = list(map(int,input().split()))
cnt = 0
while True:
cnt += 1
tmp = ((K - 1) * cnt) + 1
if N <= tmp:
break
print(cnt) |
p02705 | s437210147 | Wrong Answer | import math
radius = int(input())
answer = math.pi * radius * radius
print(answer) |
p03665 | s461897673 | Accepted | #! /usr/bin/env python3
import sys
import numpy as np
from itertools import combinations
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)
N, P, *A, = map(int, read().split())
n_odd = 0
n_even = 0
for a i... |
p02767 | s028129761 | Accepted | N = int(input())
x = list(map(int, input().split()))
hp_list = [sum([(xx-p)**2 for xx in x]) for p in range(min(x), max(x)+1)]
print(min(hp_list)) |
p03555 | s993760672 | Accepted | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
c1, c2 = [list(readline().decode().rstrip()) for _ in range(2)]
ans = 'YES' if c1 == c2[::-1] and c2 == c1[::-1] else 'NO'
print(ans) |
p03803 | s703388011 | Accepted | a,b = [int(x) for x in input().split()]
if a == b:
print("Draw")
elif a == 1:
print("Alice")
elif b == 1:
print("Bob")
elif a > b:
print("Alice")
else:
print("Bob")
|
p04030 | s263209985 | Accepted | # -*- coding : utf-8 -*-
S = str(input())
w = ""
for i in range(len(S)) :
if S[i] == "B" :
if w == "":
w = ""
else :
w = w[:-1]
else :
w = w + S[i]
print(w) |
p03719 | s504613900 | Accepted | A, B, C = map(int, input().split())
print("Yes" if A <= C <= B else "No") |
p03456 | s002387774 | Accepted | a,b=input().split()
x=int(a)*10**len(b)+int(b)
for i in range(0,1000):
if i*i==x:
print("Yes")
break
else:
print("No")
|
p02571 | s877531544 | Accepted | S = input()
T = input()
N = len(S)
M = len(T)
ans = M
for i in range(N-M+1):
cnt = 0
for j in range(M):
if T[j] != S[i:i+M][j]:
cnt += 1
ans = min(ans, cnt)
print(ans)
|
p02793 | s140096235 | Accepted | from fractions import gcd
from functools import reduce
def main():
def lcm(x, y):
return x * y // gcd(x, y)
n = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
x = reduce(lcm, a)
print(sum(x // i for i in a) % mod)
if __name__ == '__main__':
main() |
p03285 | s192512679 | Accepted | n = int(input())
for i in range(n//7+1):
if (n-i*7) % 4 == 0:
print('Yes')
exit()
print('No') |
p02802 | s891146006 | Accepted | n,m = map(int, input().split())
wc = [0 for i in range(n)]
ac = [0 for i in range(n)]
n_wc = 0
n_ac = 0
for i in range(m):
num,j = input().split()
num = int(num)
if j == 'AC' and ac[num-1] == 0:
n_ac += 1
ac[num-1] = 1
n_wc += wc[num-1]
else:
wc[num-1] += 1
print(n_a... |
p03494 | s467749277 | Accepted | import numpy as np
n = int(input())
a = list(map(int, input().split()))
a = np.array(a, int)
count = 0
while True:
if not (a%2).any():
a //= 2
count += 1
else:
break
print(count)
|
p03827 | s145551851 | Accepted | # -*- coding: utf-8 -*-
N = int(input())
S = input()
x = 0
maxx = 0
for c in S:
x += [-1, 1][c == 'I']
maxx = max(maxx, x)
print(maxx) |
p03627 | s166866397 | Wrong Answer | n = int(input())
a = list(map(int,input().split()))
b = list(set(a))
import collections
c = collections.Counter(a)
g = []
for i in range(len(b)):
if c[b[i]] >= 2:
g.append(b[i])
if len(g) <=1:
print(0)
else:
g = sorted(g,reverse = True)
print(g[0]*g[1]) |
p02811 | s451591891 | Accepted | a = list(map(int,input().split()))
if 500*a[0] >= a[1]:
print("Yes")
else:
print("No") |
p03495 | s313762720 | Wrong Answer | import numpy as np
N,K=map(int,input().split())
A=list(map(int,input().split()))
B=np.zeros(N)
for i in A:
B[i-1]+=1
C=sorted([i for i in B if i != 0])
ans=0
for i in range(len(C)-K):
ans+=C[i] |
p02618 | s300146031 | Accepted | D = int(input())
for i in range(D):
print(i%26+1) |
p03106 | s654738688 | Accepted | def f(a):
r = []
for d in range(1,int(a ** 0.5) + 1):
if a % d == 0:
r.append(d)
if d * d != a: r.append(a/d)
return r if r else [1]
a,b,k = map(int, raw_input().split(' '))
r = []
for d in f(a):
if d in f(b):
r.append(d)
r.sort()
print r[-k] |
p02578 | s659853860 | Wrong Answer | n = int(input())
a = list(map(int, input().split()))
ans = 0
maxh = 0
for i in range(len(a)-1):
if a[i] > a[i+1]:
if maxh < a[i]:
maxh = a[i]
ans += maxh - a[i+1]
print(ans)
|
p03160 | s100741610 | Wrong Answer | """
author : halo2halo
date : 4, Feb, 2020
"""
import sys
# import itertools
# import math
# import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
INF = 10 ** 9
N, *H = map(int, read().split())
dp = [INF] * N
dp[0] = 0
for i in range(0, N-2):
... |
p03910 | s464558463 | Wrong Answer | n=int(input())
i=0
while i*(i+1)//2<n:
i+=1
no=n-i*(i+1)//2
for j in range(1,i+1):
if j!=no:
print(j) |
p02759 | s695824101 | Accepted | n=int(input())
print("{}".format((n+1)//2)) |
p02630 | s174622887 | Accepted | from sys import stdin,stdout
LI=lambda:list(map(int,input().split()))
MAP=lambda:map(int,input().split())
IN=lambda:int(input())
S=lambda:input()
import math
from collections import Counter,defaultdict
n=IN()
a=LI()
q=IN()
d=defaultdict(int)
for i in range(n):
d[a[i]]+=1
s=sum(a)
for i in range(q):
x,y=MAP()
... |
p02778 | s633825897 | Accepted | s = input()
for i in range(len(s) - 1):
print("x",end="")
print("x") |
p02705 | s003159745 | Accepted | def main():
t = int(input())
print(t * 2 * 3.14)
if __name__ == '__main__':
main()
|
p02546 | s229200252 | Accepted | S = input()
if S.endswith('s'):
print(S + 'es')
else:
print(S + 's')
|
p02596 | s882691877 | Wrong Answer | k = int(input())
a = 7
for i in range(1, k):
if a % k == 0:
print(i)
exit()
a = (10 * a + 7) % k
print(-1)
|
p02780 | s981179919 | Accepted | n,k=map(int,input().split())
p=list(map(int,input().split()))
tmp=0
for i in p[:k]:
tmp+=(1+i)/2
li=[tmp]
for i in range(0,n-k):
tmp=li[i]
tmp-=(1+p[i])/2
tmp+=(1+p[k+i])/2
li.append(tmp)
print(max(li))
|
p03210 | s197564973 | Wrong Answer | import sys
import math
import itertools
n=int(input())
if n==5 or n==7 or n==3 :
print("Yes")
else :
print("No") |
p04020 | s291128620 | Accepted | N,*A = map(int, open(0).read().split())
ans = 0
cum = 0
for i in range(N):
if A[i] > 0:
cum += A[i]
else:
ans += cum // 2
cum = 0
print(ans+cum//2) |
p03469 | s703146149 | Accepted | S = input().strip()
print("2018"+S[4:]) |
p03067 | s760605776 | Wrong Answer | a,b,c = map(int, input().split())
print("Yes" if min(a,b) < c and max(a,b) > c else "no") |
p02731 | s765465374 | Accepted | # input
L = int(input())
print((L / 3) ** 3) |
p02727 | s590812992 | Wrong Answer | x,y,ak,bk,ck = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
a.sort(reverse=True)
b.sort(reverse=True)
c.sort()
ab = a[:x]+b[:y]
ab.reverse()
j=0
for i in range(x+y):
if ab[i] >= max(c):
break
while j <= ck-1:
... |
p03377 | s437311806 | Accepted | a ,b, x = map(int,input().split())
if a <= x and (a + b) > x:
print('YES')
else:
print('NO') |
p03795 | s682472164 | Accepted | n = int(input())
print(800*n-(n//15)*200)
|
p02879 | s041586142 | Accepted | A,B=map(int,input().split())
if A>9 or B>9:
print(-1)
else:
print(A*B) |
p03665 | s880628299 | Wrong Answer | N,P=map(int,input().split())
A=list(map(int,input().split()))
odd=0
even=0
for i in range(0,N):
if A[i]%2==1:
odd=odd+1
else:
even=even+1
print((2**(odd-1))*(2**(even))) |
p03438 | s738546049 | Accepted | n = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
a_gap = 0
b_gap = 0
for i in range(n):
if A[i]>B[i]:
a_gap+=A[i]-B[i]
if A[i]<B[i]:
b_gap+=(B[i]-A[i])//2
if b_gap-a_gap<0:
print('No')
else:
print('Yes') |
p02747 | s156332436 | Accepted | S=str(input())
a=S.count('hi')
if a*2==len(S):
print('Yes')
else:
print("No") |
p02678 | s708406339 | Wrong Answer | from collections import defaultdict
from collections import deque
n , m = map(int , input().split())
g = defaultdict(list)
for i in range(m):
u , v = map(int , input().split())
g[u].append(v)
g[v].append(u)
#print(g)
visited = [False]*(n+1)
a = [10**10]*(n+1)
q = deque()
q.append(1)
while q:
node = q.popleft()
vis... |
p02819 | s072411534 | Wrong Answer | x = int(input())
rx = int(x**(1/2)) + 1
P = [2] + [2*i+1 for i in range(1, rx//2)]
while True:
flag = True
for i in P:
if x % i == 0:
flag = False
break
if flag:
print(x)
break
P.append(int(x**(1/2))+2)
x += 1 |
p02576 | s742927351 | Accepted | def inputlist(): return [int(j) for j in input().split()]
N,X,T =inputlist()
a = (N//X) + int(N % X != 0)
print(a*T) |
p03284 | s730219578 | Accepted | x,y = map(int,input().split())
if x%y == 0:
print(0)
else:
print(1) |
p02766 | s431392590 | Accepted | n, k = map(int,input().split())
i = 1
while n >= k:
n = n//k
i += 1
print(i) |
p03095 | s096618027 | Accepted | import sys
input = sys.stdin.readline
n = int(input())
s = input().rstrip()
mod = 10**9+7
from collections import Counter
c = Counter(s)
ans = 0
for i in s:
chk = 1
for j,v in c.items():
if j == i:
continue
chk *= v+1
ans += chk
ans %= mod
c.update({i:-1})
print(ans%mod) |
p02621 | s002678937 | Wrong Answer | A=int(input())
sums=0
for i in range(1,4):
sums += A**i
print(sums)
print(sums) |
p03745 | s838031241 | Accepted |
N = int(input())
A = list(map(int,input().split()))
ans = 1
q = []
for i,a in enumerate(A):
if len(q) != 0 and ( (q[0] < q[-1] and q[-1] > a) or (q[0] > q[-1] and q[-1] < a) ):
q = [a]
ans += 1
else:
q.append(a)
print (ans)
|
p03331 | s914074113 | Accepted | n = int(input())
SMs = []
for i in range(2, n // 2 + 2):
SMs.append(sum(list(map(int, str(i)))) + sum(list(map(int, str(n-i)))))
print(min(SMs)) |
p03017 | s284256716 | Wrong Answer | N, A, B, C, D = map(int, input().split())
S = input()
#%%
flag = True
# A -> Cの間に#が二連続するパターン
if '##' in S[A:C]:
flag = False
# B -> Dの間に#が二連続するパターン
if '##' in S[B:D]:
flag = False
# A, Bの位置交換が必要な時
if C > D:
if '...' not in S[B-1:D+1]:
# B,Dの間に連続する3つの'.'が必要
flag = False
if flag:
print('Ye... |
p02760 | s862073311 | Accepted | 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]) |
p03254 | s072351786 | Accepted | N, x = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
ans = 0
for a in A[:-1]:
if a <= x:
ans += 1
x -= a
print(ans + 1 if A[-1] == x else ans) |
p03796 | s960454894 | Accepted | N = int(input())
ans = 1
inf = 10**9+7
for i in range(N):
ans = (ans*(i+1))%inf
print(ans) |
p03785 | s416957472 | Wrong Answer | n, c, k = map(int, input().split())
t = [0] * n
for i in range(n):
t[i] = int(input())
t = sorted(t)
ans = 0
i = 0
while i < n:
j = 0
while i + j < n and t[i + j] < t[i] + k and j < c:
j += 1
i += j
ans += 1
print(ans)
|
p03479 | s236793648 | Accepted | x,y=map(int, input().split())
tmp=x
cnt=0
while(tmp<=y):
cnt+=1
tmp = tmp*2
print(cnt) |
p02595 | s372000690 | Accepted | #!/usr/bin python3
# -*- coding: utf-8 -*-
n, d = map(int, input().split())
dd = d*d
ret = 0
for _ in range(n):
x, y = map(int,input().split())
if x*x + y*y <= dd:
ret += 1
print(ret)
|
p03612 | s956574438 | Accepted | N = int(input())
P = [int(_) for _ in input().split()]
cnt = 0
for i in range(N):
p = P[i]
ni = (i + 1) % N
if p == (i + 1):
cnt += 1
P[i], P[ni] = P[ni], P[i]
print(cnt)
|
p03721 | s097511659 | Accepted | v = [0] * 100001
n, k = map(int, input().split())
for i in range(n):
a, b = map(int, input().split())
v[a] += b
s = 0
for i in range(100001):
s += v[i]
if s >= k:
print(i)
break |
p03043 | s357854826 | Wrong Answer | import math
import numpy as np
N, K=map(int, input().split())
if N>=K:
p1=(N-K)/N
klist=list(range(1,K))
else:
p1=0
klist=list(range(1,N+1))
def calc(x):
y=math.ceil((np.log(K)-np.log(x))/np.log(2))
p=((0.5)**y)
return p
plist=list(map(calc, klist))
p2=sum(plist)/N
print(p2+p1) |
p02971 | s216298930 | Accepted | #create date: 2020-07-07 11:02
import sys
stdin = sys.stdin
from heapq import heapify, heappush, heappop
def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))
def main():
n = ni()
a = list()
for _ in range(n):
a.append(ni()... |
p04019 | s693142753 | Accepted | s = input()
dir = [0 for i in range(4)]
for i in range(len(s)):
if s[i] == "N":
dir[0] += 1
elif s[i] == "W":
dir[1] += 1
elif s[i] == "S":
dir[2] += 1
elif s[i] == "E":
dir[3] += 1
if 0 not in dir:
print("Yes")
elif dir.count(0) == 3:
print("No")
elif dir[0] ==... |
p03285 | s005947351 | Accepted | N=int(input())
tmp1=N//7
tmp2=N//4
for i in range(tmp1+1):
for j in range(tmp2+1):
if i*7+j*4==N:
print('Yes')
exit()
print('No') |
p02630 | s388172075 | Accepted | v=[0 for i in range(100001)]
n=int(input())
ar=list(map(int,input().split()))
s=0
for i in ar:
s+=i
v[i]+=1
q=int(input())
for i in range(q):
a,b=map(int,input().split())
s-=a*v[a]
s+=b*v[a]
v[b]+=v[a]
v[a]=0
print(s)
|
p03324 | s219244325 | Wrong Answer | a,b = map(int,input().split())
n = 100**a
print(n*b) |
p03803 | s395997814 | Accepted | A, B = map(int,input().split())
if A == 1:
A = 14
if B == 1:
B = 14
if A > B:
print('Alice')
elif A < B:
print('Bob')
elif A == B:
print('Draw') |
p02640 | s421316323 | Wrong Answer | x,y=map(int,input().split())
if x*4>=y and y%2==0 and x*2<=y:print("是")
else:print("没有") |
p03323 | s529712181 | Wrong Answer | A,B = [int(s) for s in input().split()]
print('Yay!') if A <= 8 and B <= 8 else print(':)') |
p02923 | s811112113 | Accepted | n, *hh = map(int, open(0).read().split())
pre = hh[0]
tmp = 0
ans = 0
for h in hh[1:]:
if pre>=h:
tmp += 1
ans = max(tmp, ans)
else:
tmp = 0
pre = h
print(ans) |
p03103 | s202636746 | Accepted | n, m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
ans, buy = 0, 0
for i, j in sorted(a, key=lambda x:x[0]):
tmp = min(m-buy, j)
ans += tmp*i
buy += tmp
if buy == m: break
print(ans) |
p03721 | s675029950 | Accepted | N,K=map(int,input().split())
S={}
for i in range(N):
a,b=map(int,input().split())
if a in S:
S[a]+=b
else:
S[a]=b
T=sorted(S.items())
count=0
for i in range(len(T)):
count+=T[i][1]
if count>=K:
print(T[i][0])
break
|
p03730 | s273438718 | Accepted | A,B,C = map(int,input().split())
a = "NO"
for n in range(10000):
if n%A==0 and n%B==C:
a = "YES"
print(a) |
p03379 | s998580391 | Accepted | n=int(input())
x=list(map(int,input().split()))
sorted_x=sorted(x)
min_m,max_m=sorted_x[n//2-1],sorted_x[n//2]
for i in range(n):
if x[i]<=min_m:
print(max_m)
else:
print(min_m)
|
p02958 | s134157758 | Accepted | n, p = int(input()), list(map(int, input().split()))
px = sorted(p)
a = 0
for i in range(n):
if p[i] != px[i]:
a += 1
if a/2 <= 1:
print('YES')
else:
print('NO') |
p03705 | s814290272 | Accepted | n, a, b = map(int, input().split())
ans = max(0, (b - a) * (n - 2) + 1)
print(ans) |
p03030 | s742774285 | Accepted | N = int(input())
S = [input().split() for i in range(N)]
for i in range(N):
S[i][1] = int(S[i][1])
S[i][1] = S[i][1]*-1
S[i].append(int(i+1))
S.sort()
for i in range(N):
print(S[i][2]) |
p02630 | s396376540 | Accepted | n = int(raw_input())
a = [int(x) for x in raw_input().split()]
q = int(raw_input())
op = []
for _ in xrange(q):
v = raw_input().split()
op.append([int(x) for x in v])
d = {}
total = 0
for v in a:
d[v] = d.get(v, 0) + 1
total += v
for src, dest in op:
c = d.pop(src, 0)
d[dest] = d.get(dest, 0) ... |
p03623 | s607861320 | Accepted | l = [int(x) for x in input().split(' ')]
if abs(l[0]-l[1]) < abs(l[0]-l[2]):
print('A')
else:
print('B') |
p02583 | s983026087 | Wrong Answer | N = int(input())
lArr = list(map(int, input().split(" ")))
lArr.sort()
ans = 0
for i in range(N):
for j in range(i + 1, N):
for k in range(j + 1, N):
if lArr[i] != lArr[j] and lArr[i] != lArr[k]:
if lArr[i] + lArr[j] > lArr[k]:
ans += 1
print(ans)
|
p03013 | s401970276 | Wrong Answer | from math import factorial as f
N, M = map(int, input().split())
broken = [int(input()) for _ in range(M)] + [N+1]
tmp = 0
ans = 1
FLG = True
for a in broken:
if a == 1:
tmp = a + 1
continue
if a == tmp:
FLG = False
break
interval = a - tmp - 1
ans *= sum(int(f(j)/(f(... |
p02576 | s678417298 | Wrong Answer | n,x,t=map(int,input().split())
time=(n//x+1)*t
print(time) |
p03416 | s963648488 | Accepted | a, b = map(int, input().split())
ans = 0
for n in range(a, b+1):
s = str(n)
if (s[0] == s[-1]) and (s[1] == s[-2]):
ans += 1
print(ans) |
p03319 | s387808509 | Accepted | N,K = map(int,input().split())
A = list(map(int,input().split()))
index = A.index(1) + 1
import math
ans = math.ceil((N - index) /(K-1) + (index-1)/(K-1))
print(ans) |
p03971 | s848504540 | Accepted | n, a, b = map(int, input().split())
s=input()
tp=0
up=0
for i in range(n):
if tp >= a+b:
print('No')
elif s[i]=='a':
print('Yes')
tp+=1
elif s[i]=='b':
if up < b:
print('Yes')
tp+=1
up+=1
else:
print('No')
else:
print('No') |
p03309 | s988079225 | Wrong Answer | # C - Linear Approximation
N = int(input())
A = list(int(a) for a in input().split())
A_diff = []
b = 0
for i, a in enumerate(A, 1):
tmp = a - i
A_diff.append(tmp)
b += tmp
b //= N
ans = 0
for a in A_diff:
ans += abs(a - b)
print(ans) |
p03000 | s431607091 | Accepted | n, x = map(int, input().split())
l = [int(i) for i in input().split()]
d = 0
count = 1
for li in l:
d += li
if d <= x:
count += 1
print(count) |
p03289 | s363246933 | Accepted | s = list(input())
alpha = [chr(i) for i in range(97, 97+26)]
flag = True
if s[0] != "A" or (not "C" in s[2:-1]):
flag = False
else:
cin = s.index("C")
for i in range(len(s)):
if i == 0 or i == cin:
continue
if (not s[i] in alpha):
flag = False
break
print("AC" if flag else "WA"... |
p02823 | s165609821 | Accepted | n, a, b = map(int, input().split())
# 偶奇一致
if a % 2 == b % 2:
print((b - a) // 2)
else:
# left = a - 1
# right = n - b
# if left > right:
# cnt = right + 1
# left = min(a + cnt, n)
# print((n - left) // 2 + cnt)
# else:
# cnt = left + 1
# right = max(b - cnt,... |
p02688 | s101097363 | Accepted |
s = input().split();
n = int(s[0])
k = int(s[1])
A= [0 for i in range(n)]
ans = n
for i in range(k):
d = input()
d = int(d)
a = list(map(int, input().split()))
for j in range(d):
if A[a[j]-1]== 0:
A[a[j]-1]=1
ans = ans -1
else:
continue
print(ans) |
p02691 | s038748099 | Accepted | from collections import Counter
n=int(input())
a=list(map(int,input().split()))
jc=[0]*n
for i in range(n):
jc[i]+=i+1-a[i]
jcc=Counter(jc)
count=0
for j in range(n):
count+=jcc[a[j]+j+1]
print(count)
|
p02924 | s088247588 | Accepted | import sys
from collections import defaultdict
from queue import deque
readline = sys.stdin.buffer.readline
#sys.setrecursionlimit(10**8)
def geta(fn=lambda s: s.decode()):
return map(fn, readline().split())
def gete(fn=lambda s: s.decode()):
return fn(readline().rstrip())
def main():
n = gete(int)
... |
p02833 | s924914552 | Accepted | N = int(input())
if N % 2:
print(0)
exit()
ans = 0
div = 10
while(div <= N):
ans += N // div
div *= 5
print(ans)
|
p02682 | s049739271 | Wrong Answer | a, b, c, k = map(int, input().split())
if k <= a:
print(k)
elif a < k and k - a <= b:
print(a)
elif a == 0 and b ==0:
print(-k)
elif k == 0:
print(0)
else:
print(k-c) |
p03416 | s241806763 | Wrong Answer | A, B = map(int, input().split())
count = 0
for i in range(B - A):
letter = list(str(A+i))
if letter[0]==letter[-1] and letter[1] == letter[-2]:
count += 1
print(count) |
p03309 | s455345228 | Accepted | n=int(input())
a=list(map(int,input().split()))
c=[a[i]-i-1 for i in range(n)]
cum_c=[0]*n
c.sort()
cum_c[0]=c[0]
for i in range(1,n):
cum_c[i]=cum_c[i-1]+c[i]
ans=min(cum_c[n-1]-n*c[0],n*c[n-1]-cum_c[n-1])
for i in range(1,n):
ans=min(ans,cum_c[n-1]-2*cum_c[i-1]+(2*i-n)*c[i-1])
ans=min(ans,cum_c[n-1]-2*cum_c[i-1... |
p03698 | s029627762 | Accepted | a=input()
b=[]
c=0
for i in range(len(a)):
b.append(a[i])
b.sort()
for i in range(len(a)-1):
if b[i]==b[i+1]:
c=c+1
if c==0:
print("yes")
else:
print("no") |
p02658 | s752043255 | Accepted | N = int(input())
As = list(map(int,input().split()))
c = int(As[0])
i = 0
f = True
if 0 in As:
print("0")
else:
for x in As:
if i == 0:
i += 1
continue
c = c * x
if 1000000000000000001 <= c:
print("-1")
f = False
break
if f:
print(c)
|
p02555 | s900779576 | Accepted | from scipy.special import comb
s = int(input())
if s < 3:
print(0)
else:
count = 0
total = 0
while True:
s = s-3
count += 1
if s >= 0:
total += comb(s+count-1, count-1 ,exact=True)
total = total% (10**9+7)
else:
break
print(int... |
p02691 | s287940615 | Accepted | #create date: 2020-05-03 21:37
import sys
stdin = sys.stdin
from collections import defaultdict
import numpy as np
def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))
def main():
n = ni()
a = np.array(na())
b = np.arange(1, n+1)... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.