problem_id
stringclasses 428
values | submission_id
stringlengths 10
10
| status
stringclasses 2
values | code
stringlengths 5
816
|
|---|---|---|---|
p03289
|
s160604519
|
Wrong Answer
|
S = list(input())
if S[0] == 'A':
isC = 0
for i in S[2:len(S)]:
if i == 'C':
isC += 1
else:
if isC == 1:
for i in range(len(S)):
if S[i] == 'A' or S[i] =='C' or S[i].islower():
pass
else:
print('WA')
break
else:
print('AC')
else:
print('WA')
else:
print('WA')
|
p02639
|
s179190868
|
Accepted
|
n = list(map(int,input().split()))
print(n.index(0)+1)
|
p02598
|
s986658242
|
Wrong Answer
|
from math import ceil
N,K=map(int,input().split())
*A,=map(int,input().split())
def C(x):
return sum([A[i]//x for i in range(N)]) <= K
def binary_search2(func, n_min, n_max):
left,right=n_min,n_max
y_left, y_right = func(left), func(right)
while True:
middle = (left+right)//2
y_middle = func(middle)
if y_left==y_middle: left=middle
else: right=middle
if right-left==1:break
return left
print(binary_search2(C, 1, max(A))+1)
|
p02818
|
s573251617
|
Wrong Answer
|
a,b,k=map(int,input().split())
print(a-k,b) if a>=k else print(0-b-k+a) if k<=a+b else print(0,0)
|
p03455
|
s675630896
|
Wrong Answer
|
s=input()
c=0
for i in range(0, 3):
if s[i]=="1":
c+=1
print(c)
|
p02657
|
s856358877
|
Accepted
|
[a,b] = [int(i) for i in input().split()]
print(a*b)
|
p03544
|
s394326721
|
Accepted
|
from functools import lru_cache
N = int(input())
@lru_cache(86)
def lucas(x):
if x == 0:
return 2
if x ==1:
return 1
else:
return lucas(x-1) + lucas(x-2)
print(lucas(N))
|
p03767
|
s211034395
|
Accepted
|
n = int(input())
lis = list(map(int, input().split()))
lis =sorted(lis)
t1 = sum(lis[n:2*n])
#print(sum(t1))
nlis = lis[::-1]
t2 = 0
for i in nlis[1:2*n:2]:
t2 += i
print(max(t1, t2))
|
p02556
|
s827042089
|
Wrong Answer
|
n=int(input())
ma=2
mi=10**9
mu=2
me=10**9
for i in range(n):
x,y=map(int,input().split())
l=x+y
s=-x+10**9+y
ma=max(ma,l)
mi=min(mi,l)
mu=max(mu,s)
me=min(me,s)
print(max(ma-mi,mu-me))
|
p02684
|
s168410106
|
Accepted
|
import sys
N, K = map(int, input().split())
As = [0] + list(map(int, input().split()))
# print(As)
d = [-1]*(N+1)
i = 1
step = 1
while step <= K:
# print("step: {}, idx: {}".format(step,i))
next_i = As[i]
if d[next_i] != -1:
freq = step - d[next_i]
step = step + ((K - step) // freq)*freq
d[next_i] = step
step += 1
i = next_i
print(i)
|
p03433
|
s891578925
|
Accepted
|
N = int(input())
A = int(input())
if N%500 <= A:
print("Yes")
else:
print("No")
|
p02873
|
s669185113
|
Wrong Answer
|
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
s=input()
n=len(s)
A=[0]*(n+1)
for i in range(0,n):
if s[i]=="<":
A[i+1]=A[i]+1
for i in range(n,1,-1):
if s[i-1]==">":
A[i-1]=max(A[i-1],A[i]+1)
print(sum(A))
if __name__=='__main__':
main()
|
p04019
|
s915503537
|
Accepted
|
s = list(set(input()))
l = [["N","S"], ["W","E"], ["N", "S", "W", "E"]]
if len(s) != 2 and len(s) != 4:
print("No")
exit()
for i in l:
x = 0
for j in s:
if j in i:
x += 1
if x == len(i):
print("Yes")
exit()
print("No")
|
p02594
|
s222954003
|
Wrong Answer
|
def test_if(X):
40 >= X >= -40
if X <= 29:
print("Yes")
else:
print("No")
|
p03328
|
s572657551
|
Wrong Answer
|
a, b = map(int, input().split())
s = []
for i in range(1, 999+1):
s.append(i * (i + 1) // 2)
i = 1
while True:
if s.count(a + i) == 1:
print(i)
exit()
i += 1
|
p03328
|
s312584754
|
Wrong Answer
|
a, b = map(int, input().split())
x = [i *(i + 1) // 2 for i in range(1, 1000)]
for i in x:
if a < i < b and i - a == b - i:
print(i - a)
break
|
p03773
|
s711109814
|
Accepted
|
A, B = map(int, input().split())
print(A + B if A + B < 24 else A + B - 24)
|
p02933
|
s985874094
|
Accepted
|
# A - Red or Not
# 整数 a の入力
a = int(input())
# 文字列 s の入力
s = input()
# print(a)
# print(s)
if a >= 3200:
print(s)
else:
print('red')
|
p02613
|
s052124155
|
Accepted
|
import sys
import math
from collections import deque
sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()
def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]
def main():
N = NI()
D = {"AC": 0, "WA": 0, "TLE": 0, "RE": 0}
for i in range(N):
D[SI()] += 1
for x, y in D.items():
print("{0} x {1}".format(x, y))
if __name__ == "__main__":
main()
|
p02835
|
s677244384
|
Accepted
|
print("bust" if sum(map(int, input().split())) > 21 else "win")
|
p03338
|
s974338452
|
Accepted
|
n=int(input())
s=input()
ans,p=0,0
for i in range(n-1):
sets=list(set(s[:i+1]))
if ans>p:
p=ans
ans=0
for j in range(len(sets)):
if sets[j] in s[i+1:]:
ans+=1
print(p)
|
p04044
|
s577131468
|
Accepted
|
N, L = map(int,input().split())
S=[]
for i in range(N):
s=input()
S.append(s)
S=sorted(S)
ans=S[0]
for j in range(1,N):
ans+=S[j]
print(ans)
|
p02546
|
s218276635
|
Accepted
|
s=input()
if s[len(s)-1]=='s':print(s+'es')
else:print(s+'s')
|
p02963
|
s582360337
|
Accepted
|
s = int(input())
MOD = 10**9
y2, x2 = divmod(s, MOD)
if y2+1 <= MOD:
x2 = abs(x2-MOD)
y2 += 1
print(0, 0, 10**9, 1, x2, y2)
|
p02801
|
s599995651
|
Wrong Answer
|
alpha = input()
alpha_code = ord(alpha)
next_alpha_code = alpha_code + 1
next_alpha = chr(next_alpha_code)
print(alpha + 'の次は' + next_alpha + 'です。')
|
p02630
|
s074997759
|
Accepted
|
N = int(input())
A = list(map(int,input().split()))
Q = int(input())
s = sum(A)
nu = [0 for _ in range(10**5+1)]
for i in range(N):
nu[A[i]] += 1
for j in range(Q):
B,C = map(int,input().split())
s += (C-B)*nu[B]
nu[C] += nu[B]
nu[B] = 0
print(s)
|
p03086
|
s664639958
|
Accepted
|
s = str(input())
res = 0
max_res = 0
for i in range(len(s)):
if s[i] == 'A' or s[i] == 'T' or s[i] == 'G' or s[i] == 'C':
res += 1
if res > max_res:
max_res = res
else:
res = 0
print(max_res)
|
p02801
|
s980627863
|
Accepted
|
# 2020/01/12
# AtCoder Beginner Contest 151 - A
# Input
a = input()
# Calc
ans = chr(ord(a) + 1)
# Output
print(ans)
|
p03699
|
s359543861
|
Accepted
|
n= int(input())
mini = 1000
ans = 0
for i in range(n):
s = int(input())
ans += s
if s % 10 != 0 and mini > s:
mini = s
if ans % 10 == 0:
if mini != 1000:
print(ans - mini)
else:
print(0)
else:
print(ans)
|
p03131
|
s228082028
|
Accepted
|
from collections import defaultdict
from collections import deque
import itertools
import math
def readInt():
return int(input())
def readInts():
return list(map(int, input().split()))
def readChar():
return input()
def readChars():
return input().split()
k,a,b = readInts()
if a+1<=k and a+2<b:
k-=a+1
ans=k//2*(b-a)+k%2+b
else:
ans = k+1
print(ans)
|
p03250
|
s995682214
|
Accepted
|
L=list(map(int,input().split()))
L.sort(reverse=True)
ans=int(str(L[0])+(str(L[1])))+L[2]
print(ans)
|
p02779
|
s168989696
|
Accepted
|
# coding: utf-8
# 標準入力 <int>
N = int(input())
# 標準入力 <int> list[]
A = list(map(int, input().split()))
if (len(set(A)) == N):
print("YES")
else:
print("NO")
|
p02786
|
s089801220
|
Accepted
|
n=int(input())
c=0
while n>0:
n//=2
c+=1
print(2**c-1)
|
p03042
|
s465770556
|
Accepted
|
s = input()
a = 1<= int(s[:2]) <=12
b = 1<= int(s[2:]) <=12
if a and b:
print("AMBIGUOUS")
elif a:
print('MMYY')
elif b:
print('YYMM')
else:
print('NA')
|
p02665
|
s089822076
|
Wrong Answer
|
n = int(input())
a_list = list(map(int, input().split()))
asc = [0] * (n + 1)
desc = [0] * (n + 1)
asc[0] = 1
desc[-1] = a_list[-1]
sum = 1
if a_list[0] != 0:
print(-1)
exit()
for i in range(n):
asc[i + 1] = (asc[i] -a_list[i]) * 2
desc[n - 1 - i] = desc[n - i] + a_list[n - 1 - i]
for i in range(1, n + 1):
num = min(asc[i], desc[i])
sum += num
if num < a_list[i]:
print(-1)
exit()
print(sum)
|
p02835
|
s127528265
|
Wrong Answer
|
A = list(map(int, input().split()))
if sum(A) >= 22:
print('bust')
else:
print('Yes')
|
p03000
|
s359859130
|
Wrong Answer
|
#!/usr/bin/env python3
def main():
N, X = map(int, input().split())
L_list = list(map(int, input().split()))
D = 0
ans = 0
for n in range(N):
if D <= X:
ans += 1
D += L_list[n]
else:
break
print(ans)
if __name__ == '__main__':
main()
|
p02713
|
s238981990
|
Accepted
|
from math import gcd
K = int(input())
ans = 0
for a in range(1, K + 1):
for b in range(1, K + 1):
for c in range(1, K + 1):
ans += gcd(gcd(a, b), c)
print(ans)
|
p03433
|
s042930153
|
Accepted
|
N = int(input())
A = int(input())
w = N % 500
if(A >= w):
print('Yes')
else:
print('No')
|
p02760
|
s586151757
|
Accepted
|
a = [list(map(int, input().split())) for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]
for i in range(3):
for j in range(3):
if a[i][j] in b:
a[i][j] = 0
import numpy as np
arr = np.array(a)
answer = "No"
if (0 in arr.sum(axis=0)) or (0 in arr.sum(axis=1)):
answer = "Yes"
elif arr.diagonal().sum() == 0 or np.fliplr(arr).diagonal().sum() == 0: # 行列左右反転 fliplr()
answer = "Yes"
print(answer)
|
p04044
|
s115869324
|
Accepted
|
N,L = map(int, input().split())
S = []
for _ in range(N):
S.append(input())
#print(S[1][0])
print("".join(sorted(S)))
|
p02933
|
s733023580
|
Wrong Answer
|
a=input()
s=input()
a=int(a)
s=str(s)
if a>=3200:
print(a)
print(s)
elif a<3200:
print('red')
|
p02712
|
s723551957
|
Accepted
|
n = int(input())
ans = 0
for i in range(1, n+1):
if i % 3 != 0 and i % 5 != 0:
ans += i
print(ans)
|
p02768
|
s490294823
|
Accepted
|
mod = 10**9 + 7
n, a, b = map(int, input().split())
ans = pow(2, n, mod)-1
def nck(n, k, mod):
bunbo = bunshi = 1
for i in range(k):
bunshi = (bunshi * (n-i)) % mod
bunbo = (bunbo * (i+1)) % mod
return (bunshi * pow(bunbo, mod-2, mod)) % mod
print((ans - nck(n, a, mod) - nck(n, b, mod)) % mod)
|
p03745
|
s351300740
|
Accepted
|
import sys
input = lambda : sys.stdin.readline().rstrip()
n = int(input())
a = list(map(int, input().split()))
cnt = 0
flag = 0
for i in range(n - 1):
if flag == 0:
if a[i + 1] - a[i] > 0:
flag = 1
elif a[i + 1] - a[i] < 0:
flag = -1
elif flag == 1 and a[i + 1] - a[i] < 0:
cnt += 1
flag = 0
elif flag == -1 and a[i + 1] - a[i] > 0:
cnt += 1
flag = 0
print(cnt + 1)
|
p02842
|
s881982019
|
Accepted
|
import math
n = int(input())
for i in range(1,50000):
if int(i*1.08) == n:
print(i)
exit()
elif int(i*1.08) > n:
print(':(')
exit()
|
p03607
|
s831542173
|
Accepted
|
from collections import Counter
n = int(input())
A = [0]*n
for i in range(n):
A[i] = int(input())
cA = Counter(A).values()
r = 0
for i in cA:
r += i%2
print(r)
|
p02694
|
s458502034
|
Accepted
|
X = int(input())
import math
# n年後のお金
def calcX(n):
X = 100
for i in range(n):
X = math.floor(X * 1.01)
return X
year = 0
while True:
if X > calcX(year):
year += 1
else:
print(year)
break
|
p02623
|
s848618528
|
Wrong Answer
|
a = [input() for l in range(0,3)]
a1 = [int(p) for p in a[0].split()]
a2 = [int(p) for p in a[1].split()]
a3 = [int(p) for p in a[2].split()]
a4 = a2 + a3
b = sorted(a4)
c = 0
for i in range(0,len(b)):
c = c + b[i]
if c <= a1[2]:
print(len(b))
else:
s = 0
t = 0
while s <= a1[2] and t < len(b):
s = s + b[t]
t = t + 1
print(t-1)
|
p02959
|
s384293940
|
Accepted
|
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
r = 0
result = 0
for i in range(n):
if a[i] < r + b[i]:
result += a[i]
r = min(b[i] + r - a[i], b[i])
else:
result += r + b[i]
r = 0
if a[n] < r:
result += a[n]
else:
result += r
print(result)
|
p03665
|
s287087400
|
Accepted
|
def main():
N, P = (int(i) for i in input().split())
A = [int(i) % 2 for i in input().split()]
from collections import Counter
c = Counter(A)
if P == 0:
odd = 2**(c[1]-1) if c[1] > 0 else 0
even = 2**c[0]
if 0 < odd:
even *= odd
else:
odd = 2**(c[1]-1) if c[1] > 0 else 0
even = 2**c[0]
odd *= even
print(odd if P == 1 else even)
if __name__ == '__main__':
main()
|
p02633
|
s163718008
|
Accepted
|
x = int(input())
d, k = x, 1
while True:
if d%360==0:
print(k)
break
d += x
k += 1
|
p02725
|
s562006926
|
Wrong Answer
|
a,b=map(int,input().split())
l=list(map(int,input().split()))
m=[]
for i in range(b):
if i<=b-2:
m.append(abs(l[i+1]-l[i]))
else:
m.append(abs(l[b-1]-l[0]))
m.sort(reverse=True)
print(m)
print(a-m[0])
|
p02714
|
s714435708
|
Accepted
|
N=int(input())
S=input()
cnt=S.count("R")*S.count("G")*S.count("B")
for i in range(N):
for j in range(i+1,N):
k=2*j-i
if k<N and S[i]!=S[j]!=S[k]!=S[i]:
cnt-=1
print(cnt)
|
p02707
|
s359878647
|
Accepted
|
import sys
input = lambda: sys.stdin.readline().rstrip()
def resolve():
N = int(input())
A = list(map(int, input().split()))
ans = [0]*N
for i in A:
ans[i-1] += 1
for i in ans:
print(i)
if __name__ == '__main__':
resolve()
|
p03645
|
s075046859
|
Accepted
|
n,m=map(int,input().split())
ab=[]
for _ in range(m):
ab.append(list(map(int,input().split())))
c1x=set([x[1] for x in ab if x[0]==1])
cxn=set([x[0] for x in ab if x[1]==n])
print('POSSIBLE'if len(c1x & cxn)>0 else 'IMPOSSIBLE')
|
p03774
|
s237664224
|
Accepted
|
n, m = [int(i) for i in input().split()]
student_pos_list = [[int(j) for j in input().split()] for i in range(n)]
checkpoint_list = [[int(j) for j in input().split()] for i in range(m)]
for student_pos in student_pos_list:
min_d = 20**8+1
min_pt_index = m+1
for i, checkpt in enumerate(checkpoint_list):
d = abs(student_pos[0] - checkpt[0]) + abs(student_pos[1] - checkpt[1])
if d < min_d:
min_d = d
min_pt_index = i+1
print(min_pt_index)
|
p03359
|
s831616752
|
Accepted
|
import sys
def input(): return sys.stdin.readline().strip()
def main():
a, b = map(int, input().split())
if a <= b: print(a)
else: print(a - 1)
if __name__ == "__main__":
main()
|
p03854
|
s249589511
|
Wrong Answer
|
s = input()
def solve(query):
while 1:
for frag in ("erase", "eraser", "dream", "dreamer"):
if query.endswith(frag):
query = query.rstrip("frag")
break
else:
print("NO")
break
if not query:
print("YES")
break
solve(s)
|
p03951
|
s711276268
|
Accepted
|
#coding utf-8
N = int(input())
s = list(input())
t = list(input())
Flg = True
for i in range(N,-1,-1):
if s[N-i:N] == t[:i]:
ans = 2 * N - i
Flg = False
break
if Flg:
ans = 2 * N
if s[-1] == t[0]:
ans = 2 * N - 1
print(ans)
|
p04034
|
s350335155
|
Wrong Answer
|
N,M=map(int,input().split(' '))
B = [1]*N
R = [1]+[0]*(N-1)
for i in range(M):
x,y=map(lambda x:int(x)-1,input().split(' '))
if R[x] and B[x]>1:
B[x] -=1
B[y] +=1
R[y] = 1
elif R[x]:
B[x]-=1
B[y]+=1
R[x]=0
R[y]=1
print(sum(R))
|
p02621
|
s993666406
|
Accepted
|
a=int(input())
print(a+a*a+a*a*a)
|
p02647
|
s552231202
|
Accepted
|
n,k=map(int,input().split())
A=list(map(int,input().split()))
for i in range(k):
B=[0]*(n+1)
for j in range(n):
B[max(0,j-A[j])]+=1
B[min(n,j+A[j]+1)]-=1
A[0]=B[0]
for j in range(1,n):
A[j]=A[j-1]+B[j]
if A==[n]*n:
print(*A)
exit()
print(*A)
|
p02701
|
s964318144
|
Accepted
|
N = int(input())
S = [input() for _ in range(N)]
pattern = set(S)
print(len(pattern))
|
p03565
|
s452351591
|
Accepted
|
s = input()
t = input()
ss = []
for i in range(len(s)-len(t)+1):
for j in range(len(t)):
if s[i+j] not in ('?', t[j]):
break
else:
S = s[:i] + t + s[i+len(t):]
ss.append(S.replace('?', 'a'))
if ss:
print(min(ss))
else:
print("UNRESTORABLE")
|
p02848
|
s732866687
|
Accepted
|
N=int(input())
S=input()
abc_list="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
L=len(abc_list)
ans= " "
for i in S:
ans += abc_list[(abc_list.index(i)+N) % L]
print(ans)
|
p03077
|
s132278847
|
Accepted
|
# solution
import io
import math
data = int(input())
m=[int(input()) for i in range(5)]
print(math.ceil(data/min(m))+4)
|
p02861
|
s338965587
|
Accepted
|
import itertools
n = int(input())
x = [[0,0] for i in range(n)]
max = 1
for i in range(n) :
x[i][0],x[i][1] = map(int,input().split())
max = max*(i+1)
ans = 0
for t in itertools.permutations(x):
for i in range(n-1) :
ans += ((t[i][0]-t[i+1][0])**2+(t[i][1]-t[i+1][1])**2)**0.5
print(ans/max)
|
p03657
|
s906419794
|
Accepted
|
a,b=map(int,input().split())
if a%3==0 or b%3==0 or (a+b)%3==0:
print("Possible")
else:
print("Impossible")
|
p03745
|
s529439290
|
Wrong Answer
|
n, *lst = map(int, open(0).read().split())
if n < 3:
print(0)
quit()
group = 0
start = lst[1] > lst[0]
for i in range(2, n - 1):
if (lst[i] > lst[i - 1]) == start:
continue
else:
start = lst[i + 1] > lst[i]
group += 1
if (lst[-1] > lst[-2]) != start:
group += 1
if group != 0:
group += 1
print(group)
|
p03071
|
s782248264
|
Accepted
|
a,b = map(int,input().split())
print(max(a+a-1,a+b,b+b-1))
|
p02718
|
s356728944
|
Wrong Answer
|
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
total=0
for i in range(M):
total+=A[i]
if A[M-1]>total/(4*M):
print("Yes")
else:
print("No")
|
p02731
|
s752124975
|
Wrong Answer
|
L=int(input())
i=1
list=[]
r=1
if(L==1):
print("1")
else:
while(i<L):
j=1
while(j<L):
list.append(j*i*(L-i-j))
j+=1
i+=1
print(max(list))
|
p03377
|
s888591937
|
Wrong Answer
|
A,B,X = map(int,input().split())
print('YES' if X >= A and X <= A + B else 'No')
|
p04033
|
s885938831
|
Wrong Answer
|
a, b = map(int, input().split())
if a > 0 and b > 0:
print('Positive')
elif a < 0 and b < 0:
print('Negative')
else:
print('Zero')
|
p03720
|
s484128862
|
Wrong Answer
|
import numpy as np
import collections
N,M = list(map(int,input().split()))
a = np.array([input().split() for i in range(M)])
a = [int(i) for i in a.reshape(-1)]
count = collections.Counter(a)
for i in sorted(count.keys()):
#print(i)
print(count[i])
|
p02996
|
s531537108
|
Accepted
|
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)
N = ri()
W = []
for i in range(N):
a, b = rl()
W.append((b, a))
W.sort()
t = 0
for b, a in W:
t += a
if t > b:
print('No')
exit()
print('Yes')
|
p02608
|
s521414202
|
Wrong Answer
|
N = int(input())
arr = [0]*(N)
lim = int(N**0.5 + 1)
for i in range(1,lim):
for j in range(1,lim):
for k in range(1,lim):
num = i**2 + j**2 + k**2 + i*j + j*k + k*i - 1
if num < N:
arr[num - 1] += 1
print(*arr, sep='\n')
|
p03208
|
s562450332
|
Accepted
|
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline
import numpy as np
def main():
numbers=[]
n,m = map(int,input().split())
[numbers.append(int(input())) for _ in range(n)]
n_numbers=np.array(numbers,dtype=int)
n_numbers.sort()
print(min(n_numbers[i+m-1] - n_numbers[i] for i in range(n-m+1)))
if __name__=="__main__":
main()
|
p03693
|
s762020143
|
Accepted
|
r,g,b = map(int, input().split())
total = r*100 + g*10 + b
if total % 4 == 0:
print("YES")
else:
print("NO")
|
p02768
|
s149409394
|
Accepted
|
n, a, b = (int(x) for x in input().split())
mod = pow(10, 9)+ 7
def choice(n, k, mod):
x = 1
y = 1
for i in range(k):
x*=n-i
y*=k-i
x%=mod
y%=mod
y = pow(y, mod-2, mod)
return x*y%mod
ans = pow(2,n,mod)-1
ans-= choice(n,a,mod)+choice(n,b,mod)
ans = (ans+mod)%mod
print(ans)
|
p03556
|
s260898750
|
Accepted
|
n = int(input())
while True:
sq = n**0.5
if sq.is_integer():
break
else:
n-=1
print(n)
|
p02995
|
s014951781
|
Accepted
|
import math
def lcm(x, y):
return (x * y) // math.gcd(x, y)
A, B, C, D = map(int,input().split())
Cres = B//C - (A-1)//C
Dres = B//D - (A-1)//D
CDres = B//lcm(C,D) - (A-1)//lcm(C,D)
print(B-A+1-(Cres + Dres - CDres))
|
p02701
|
s692096108
|
Accepted
|
n=int(input())
slist=[]
for i in range(n):
slist.append(input())
slist=sorted(slist)
if n==1:
print(1)
else:
answer=1
for sl in range(len(slist)-1):
if slist[sl]!=slist[sl+1]:
answer+=1
print(answer)
|
p02963
|
s600312769
|
Accepted
|
def main():
S = int(input())
v = 10**9
ans = [0,0,10**9,1,(v-S%v)%v,(S+(v-S%v)%v)//v]
print(*ans)
if __name__ == "__main__":
main()
|
p02823
|
s953470974
|
Accepted
|
N, A, B = map(int, input().split())
Abs = B - A
if Abs % 2 == 0:
ans = Abs // 2
else:
a, b = A-1, N-B
if a < b:
ans, B = a+1, B-(a+1)
ans += (B-1) // 2
else:
ans, A = b+1, A+(b+1)
ans += (N-A) // 2
print(ans)
|
p02694
|
s221028769
|
Accepted
|
X=int(input())
t=100
ans=0
while t<X:
ans+=1
t=int(t*1.01)
print(ans)
|
p02792
|
s505993994
|
Wrong Answer
|
n=int(input())
if n%10==0:
print((int(n/10)**2+8))
else:
x=n%100
y=n//100
if y==0:
k=0
n=0
else:
k=8
if len(str(x))==1:
print((int(n/10)**2+k)+x*4)
elif len(str(x))==2:
z=x//10
Z=z*10+z
if x>=Z:
print( (int(n//10)**2+k) +(z+1)**2+8)
elif x<Z:
print( (int(n//10)**2+k) +z**2+8+(Z-x)*4)
|
p02624
|
s325239185
|
Accepted
|
N = int(input())
ans = 0
for i in range(1,N+1):
y = N//i
ans += y*(y+1)*i//2
print(ans)
|
p02973
|
s500994428
|
Wrong Answer
|
#E
n = int(input())
a = [int(input()) for _ in range(n)]
cnt = 0
while len(a)>0:
a_l = a.pop(0)
for i in range(len(a)-1,-1,-1):
if a[i] > a_l:
a_r = a.pop(i)
for j in range(len(a)-1,-1,-1):
if a_l < a[j] < a_r:
a_r = a.pop(j)
cnt += 1
print(cnt)
|
p02578
|
s511771142
|
Accepted
|
N=int(input())
A=list(map(int,input().split()))
ans=0
for i in range(N-1):
if A[i]>A[i+1]:
plus=abs(A[i]-A[i+1])
A[i+1]+=plus
ans+=plus
print(ans)
|
p03038
|
s997181070
|
Accepted
|
N,M = map(int,input().split())
A = list(map(int,input().split()))
B = [list(map(int,input().split())) for _ in range(M)]
B.sort(key = lambda x:x[1])
B = list(reversed(B))
A.sort()
num = 0
for i in range(M):
for j in range(B[i][0]):
if num > N-1:
break
if A[num] < B[i][1]:
A[num] = B[i][1]
num += 1
else:
break
print(sum(A))
|
p03767
|
s600153746
|
Accepted
|
N = int(input())
A = list(map(int,input().split()))
A.sort()
A = A[N:]
ans = 0
for i in range(0,2*N,2):
ans += A[i]
print(ans)
|
p02946
|
s988704325
|
Accepted
|
k, x = map(int, input().split())
a = []
for i in range(x-k+1, x+k):
a.append(str(i))
b = " ".join(a)
print(b)
|
p02583
|
s890744571
|
Accepted
|
n=int(input())
ans=list(map(int,input().split()))
ans.sort()
cnt=n
numans=0
for i in range(cnt-2):
for j in range(i+1,cnt-1):
for k in range(j+1,cnt):
if ans[i]+ans[j]>ans[k] and ans[i]+ans[k]>ans[j] and ans[j]+ans[k]>ans[i] and ans[i]!=ans[j] and ans[j]!=ans[k] and ans[k]!=ans[i]:
numans+=1
print(numans)
|
p03665
|
s295367470
|
Accepted
|
n,p = map(int,input().split())
a = [int(i) for i in input().split()]
fac = [1]*(n+1)
for i in range(2,n+1): fac[i] = fac[i-1]*i
def comb(n,k):
if n < k: return 0
if n < 0 or k < 0: return 0
return fac[n]//(fac[k]*fac[n-k])
even = odd = 0
for i in range(n):
if a[i]%2 == 0: even += 1
else: odd += 1
cnte = cnto = 0
for i in range(even+1): cnte += comb(even,i)
for i in range(odd+1)[p::2]: cnto += comb(odd,i)
print(cnte*cnto)
|
p03107
|
s480642761
|
Accepted
|
s = list(input())
cnt = 0
for i in range(len(s)):
if s[i] == "0":
cnt += 1
print(min(cnt, len(s)-cnt)*2)
|
p02860
|
s423576615
|
Wrong Answer
|
N = int(input())
S = input()
if N % 2 != 0:
print("No")
tmp1 = S[:int(N / 2)]
tmp2 = S[int(N / 2):]
if tmp1 == tmp2:
print("Yes")
else:
print("No")
|
p03338
|
s965460554
|
Wrong Answer
|
n = int(input())
s = input()
x = 0
for i in range(1, n):
print(i)
a,b = set(s[:i]), set(s[i:])
if max(len(a),len(b))-max(len(a-b),len(b-a))>x:
x = max(len(a),len(b))-max(len(a-b),len(b-a))
print(x)
|
p02911
|
s758363279
|
Accepted
|
N,K,Q = map(int,input().split())
A = [int(input()) for _ in range(Q)]
score = [K-Q]*N
for i in A:
score[i-1]+=1
for i in score:
if i<=0:
print('No')
else:
print('Yes')
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.