problem_id
stringclasses 428
values | submission_id
stringlengths 10
10
| status
stringclasses 2
values | code
stringlengths 5
816
|
|---|---|---|---|
p03994
|
s651198970
|
Wrong Answer
|
s = input()
k = int(input())
asc = [0] * len(s)
for i in range(len(s)):
asc[i] = ord(s[i]) - ord("a")
i = 0
for i in range(len(s)):
if 26 - asc[i] <= k or i == len(s) - 1:
x = 26 - asc[i]
asc[i] = (asc[i] + min(k, x)) % 26
k -= x
if k > 0:
asc[-1] = (asc[-1] + k % 26) % 26
for i in range(len(s)):
asc[i] += ord("a")
asc[i] = chr(asc[i])
print("".join(asc))
|
p03723
|
s245728194
|
Wrong Answer
|
a,b,c= map(int,input().split())
cnt = 0
if a == b and b == c:
if a%2 == 0 and b%2 == 0 and c%2 == 0:
print(-1)
exit()
else:
print(0)
while a%2 == 0 and b%2 == 0 and c%2 == 0:
cnt +=1
x =(b+c)//2
y =(c+a)//2
z =(b+a)//2
a = x
b = y
c = z
print(cnt)
|
p03427
|
s106333653
|
Wrong Answer
|
n = list(input())
if n[0] == '1':
print(9 * (len(n) - 1))
elif n.count('9') == len(n) - 1:
print(9 * (len(n) - 1) + 8)
else:
print((int(n[0]) - 1 ) + (9 * (len(n) - 1)))
|
p02577
|
s908928180
|
Accepted
|
l = list(map(int, list(input().strip())))
t = 0
for i in range(len(l)):
t += l[i]
if t % 9 == 0:
print("Yes")
else:
print("No")
|
p02601
|
s904283397
|
Accepted
|
a,b,c=map(int, input().split())
k=int(input())
num=0
while a >= b:
b *= 2
num += 1
while b >= c:
c *= 2
num += 1
if num > k:
print("No")
else:
print("Yes")
|
p03815
|
s384580479
|
Wrong Answer
|
x = int(input())
if x <= 6:
print(1)
elif x % 11 <= 6:
print((x // 11)*2 + 1)
else:
print((x // 11)*2 + 2)
|
p03250
|
s006972103
|
Wrong Answer
|
A,B,C = map(int,input().split())
if(A>B and A>C):
print(str(A*10+B+C))
if(B>A and B>C):
print(str(B*10+A+C))
else:
print(str(C*10+A+B))
|
p03239
|
s790121501
|
Accepted
|
n, T = map(int, input().split())
min = 1001
for i in range(n):
c, t = map(int,input().split())
if(t <= T and c < min):
min = c
print(min if min != 1001 else "TLE")
|
p02755
|
s964516370
|
Accepted
|
import math
a, b = map(int, input().split(' '))
ret = -1
for i in range(1, 1251):
if math.floor(i * 0.08) == a and math.floor(i * 0.1) == b:
ret = i
break
print(ret)
|
p03760
|
s821846349
|
Accepted
|
O = input()
E = input()
pw = [None] * (len(O) + len(E))
for i in range(len(O)):
pw[2 * i] = O[i]
for j in range(len(E)):
pw[2 * j + 1] = E[j]
print(''.join(pw))
|
p03407
|
s203938193
|
Accepted
|
a,b,c = map(int, input().split())
print("Yes" if a+b >= c else "No")
|
p03286
|
s385431911
|
Accepted
|
N = int(input())
ans = ''
while N != 0:
if N % 2 !=0:
N -=1
ans = '1'+ans
else:
ans = '0'+ans
N = N//-2
if ans == '':
ans ='0'
print(ans)
|
p02789
|
s632745830
|
Accepted
|
m,n=map(int,input().split())
if m==n :
print("Yes")
else :
print("No")
|
p02881
|
s387920050
|
Wrong Answer
|
n = int(input())
ans = 1
i=1
while i*i<n:
if n%i==0:
ans = i
i+=1
ans += n//ans
ans -= 2
print(ans)
|
p03408
|
s125993559
|
Wrong Answer
|
N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for i in range(M)]
a = 0
for i in range(0,N):
for j in range(0,M):
if a <= (s.count(s[i]) - t.count(t[j])):
a = s.count(s[i]) - t.count(t[j])
print(a)
|
p02847
|
s283223554
|
Accepted
|
S=input()
day=['SUN','MON','TUE','WED','THU','FRI','SAT']
print(7-(day.index(S)))
|
p02935
|
s220158513
|
Accepted
|
n = int(input())
V = list(map(int, input().split()))
V.sort()
s = V[0]
for i in range(1, n):
s = (s + V[i])/2
print(s)
|
p03087
|
s876386183
|
Wrong Answer
|
n,Q=map(int,input().split())
s=input()
a=[0]*(n+1)
for i in range(2,n+1):
if s[i-2]=='A' and s[i-1]=='C':
a[i]=a[i-1]+1
else:
a[i]=a[i-1]
for i in range(Q):
l,r=map(int,input().split())
print(a[r-1]-a[l-1])
|
p03035
|
s955020312
|
Accepted
|
import sys
input = sys.stdin.readline
A,B = list(map(int,input().split()))
if A>=13:
print(B)
elif A <= 5:
print(0)
else:
print(B//2)
|
p03481
|
s540466379
|
Accepted
|
X,Y=map(int,input().split())
ans=0
while (X<=Y):
ans+=1
X*=2
print(ans)
|
p03986
|
s872662550
|
Wrong Answer
|
import sys
X = list(sys.stdin.readline().strip())
N = len(X)
NHALF = N // 2
def solve2():
ns = 0
nt = 0
i = 0
while nt < NHALF:
if X[i] == 'T':
nt += 1
i += 1
else:
ns += 1
i += 1
return N - 2*ns
print(solve2())
|
p03329
|
s550725239
|
Accepted
|
import math,numpy, collections
n = int(input())
ans = n
cnt = 0
for i in range(n+1):
cnt = 0
x = i
while x >0:
cnt += x%6
x = x//6
y = n-i
while y >0:
cnt += y%9
y = y//9
ans = min(ans,cnt)
print(ans)
|
p03778
|
s455042941
|
Accepted
|
W, a, b = map(int, input().split())
if a + W < b:
print(b - (a + W))
elif a > b + W:
print(a - (b + W))
else:
print(0)
|
p02766
|
s039897687
|
Accepted
|
# ABC 156: B – Digits
N, K = [int(s) for s in input().split()]
digits = 1
while N >= K:
digits += 1
N //= K
print(digits)
|
p03821
|
s425489006
|
Accepted
|
n = int(input()); a = []; b = []; x = 0
for i in range(n): A, B = map(int, input().split()); a.append(A); b.append(B)
for i in range(n-1, -1, -1): x += b[i]-(a[i]+x-1)%b[i]-1
print(x)
|
p02811
|
s427354502
|
Accepted
|
k, x = map(int, input().split())
print('Yes' if k * 500 >= x else 'No')
|
p04019
|
s367442264
|
Accepted
|
st = input()
sn = len(st)
n, s, e, w = 0, 0, 0, 0
for i in range(sn):
if st[i] == "N":
n += 1
if st[i] == "S":
s += 1
if st[i] == "E":
e += 1
if st[i] == "W":
w += 1
false = (n > 0 and s == 0) or (s > 0 and n == 0) or (e > 0 and w == 0) or (w > 0 and e == 0)
if false:
print("No")
else:
print("Yes")
|
p02681
|
s677483669
|
Accepted
|
S = input()
T = input()
if T[0:len(S)] == S:
print('Yes')
else:
print('No')
|
p02660
|
s749981455
|
Wrong Answer
|
import numpy as np
n = int(input())
def div_game(n):
zs = [int(z) for z in np.arange(2,np.sqrt(n)+1) if (n % z == 0)]
if (zs == []):
if (n == 1):
return 0
return 1
ns = []
for z in zs:
if (n % z != 0):
continue
n /= z
ns.append(n)
return len(ns)
print(div_game(n))
|
p03221
|
s226902352
|
Wrong Answer
|
import numpy as np
n,m = list(map(int, input().split()))
info = [list(map(int, input().split())) for i in range(m)]
info = np.array(info)
pref = {}
for i in range(1,n+1):
pref[i] = info[info[:,0] == i, 1]
id = {}
for p,years in pref.items():
id[p] = {}
for i,y in enumerate(years):
id[p][y] = str(p).zfill(6) + str(i+1).zfill(6)
for p,y in info:
print(id[p][y])
|
p03721
|
s579685142
|
Wrong Answer
|
n, k = map(int, input().split())
cnt = 0
ans = 0
for i in range(n):
a, b = map(int, input().split())
cnt += b
if cnt >= k and ans == 0:
ans = a
print(ans)
|
p03086
|
s831731224
|
Accepted
|
S = input()
c = 0
cmax = -1
for s in S:
if s in ['A', 'C', 'G', 'T']:
c += 1
else:
if c > cmax:
cmax = c
c = 0
if c > cmax:
cmax = c
c = 0
print(cmax)
|
p03254
|
s500779302
|
Accepted
|
# -*- coding:utf-8 -*-
N,x = map(int,input().split())
a = list(map(int,input().split()))
cnt = 0
a.sort()
while x > 0:
if cnt >= N:
if x > 0:
cnt -= 1
break
else:
break
elif a[0] > x:
break
else:
tmp = a.pop(0)
x -= tmp
cnt+=1
print(cnt)
|
p03475
|
s269184683
|
Accepted
|
n = int(input())
c = [0] * n
f = [0] * n
s = [0] * n
for i in range(n - 1):
c[i], s[i], f[i] = map(int, input().split())
lapse = [0] * n
for i in range(n):
for j in range(i + 1, n):
t = 0
while s[j - 1] + t * f[j - 1] < lapse[i]:
t += 1
lapse[i] = s[j - 1] + t * f[j - 1] + c[j - 1]
print(lapse[i])
|
p02933
|
s936588051
|
Accepted
|
a=int(input())
s=input()
if a>=3200:
print(s)
else:
print('red')
|
p04043
|
s551443742
|
Accepted
|
a,b,c=map(int,input().split())
d=0
if a==5 or b==5 or c==5:
if a==7 or b==7 or c==7:
if a+b+c==17:
print("YES")
d=1
if d==0:
print("NO")
|
p03285
|
s781090167
|
Wrong Answer
|
cake = 4
donaut = 7
N = int(input())
count = 0
for i in range(0, cake + 1):
for k in range(0, donaut + 1):
if N == cake * i + donaut * k:
count += 1
if count == 0:
print('No')
else:
print('Yes')
|
p02779
|
s925920586
|
Accepted
|
N=int(input())
a=list(map(int,input().split()))
a.sort()
flg=0
if(a[0]==a[1]):
flg=1
for i in range(1,N-1):
if(a[i]==a[i-1]):
flg=1
if flg==1:
print("NO")
else:
print("YES")
|
p02779
|
s613051176
|
Wrong Answer
|
N = input()
a = input()
M = list(map(int, a.split()))
X = set(M)
Y = len(X)
if N == Y:
print("YES")
else:
print("NO")
|
p02854
|
s919323503
|
Accepted
|
N=int(input())
L=list(map(int,input().split()))
A=[float("inf")]*(N+10)
A[0]=0
for i in range(1,N+1):
A[i]=A[i-1]+L[i-1]
X=float("inf")
for i in range(len(A)):
X=min(X,abs(A[N]-A[i]-A[i]))
print(X)
|
p03944
|
s428848283
|
Accepted
|
wmax,hmax,n = map(int,input().split())
wmin = hmin = 0
for i in range(n):
x,y,a = map(int,input().split())
if a == 1:
if wmin < x:
wmin = x
elif a == 2:
if wmax > x:
wmax = x
elif a == 3:
if hmin < y:
hmin = y
else:
if hmax > y:
hmax = y
if wmax-wmin < 0 or hmax-hmin < 0:
print(0)
else:
print((wmax-wmin) * (hmax-hmin))
|
p03665
|
s599303101
|
Accepted
|
K,P=map(int,input().split())
A=list(map(int,input().split()))
x=dict()
x[0]=0
x[1]=0
for i in range(K):
if A[i]%2==0:
x[0]+=1
else:
x[1]+=1
if x[1]==0:
if P==0:
print(2**K)
else:
print(0)
exit()
print(2**(K-1))
|
p03067
|
s579104588
|
Accepted
|
import sys, math
from functools import lru_cache
from collections import deque
sys.setrecursionlimit(500000)
MOD = 10**9+7
def input():
return sys.stdin.readline()[:-1]
def mi():
return map(int, input().split())
def ii():
return int(input())
def i2(n):
tmp = [list(mi()) for i in range(n)]
return [list(i) for i in zip(*tmp)]
def main():
A, B, C = mi()
if A < C < B or A > C > B:
print('Yes')
else:
print('No')
if __name__ == '__main__':
main()
|
p03565
|
s230495942
|
Accepted
|
S = input()
T = input()
s, t = len(S), len(T)
L = []
for i in range(s-t+1):
if all(S[i+j]==T[j] or S[i+j]=="?" for j in range(t)):
L.append(S[:i]+T+S[i+t:])
L = [l.replace("?", "a") for l in L]
print(min(L) if len(L)>0 else "UNRESTORABLE")
|
p03434
|
s231495878
|
Accepted
|
N = int(input())
A = list(map(int, input().split()))
Alice = 0
Bob = 0
A = sorted(A, reverse = True)
for i, a in enumerate(A):
if i %2 == 0:
Alice += a
else:
Bob += a
print(Alice - Bob)
|
p03774
|
s382094876
|
Wrong Answer
|
n,m=map(int,input().split())
gakusei=[]
for i in range(n):
gakusei.append(list(map(int,input().split())))
check=[]
for j in range(m):
check.append(list(map(int,input().split())))
for i in range(0,n):
minkyori=10*100
keep=0
for j in range(0,m):
kyori=abs(gakusei[i][0]-check[j][0])+abs(gakusei[i][1]-check[j][1])
if kyori<minkyori:
minkyori=kyori
keep=j+1
print(keep)
|
p03067
|
s148953161
|
Accepted
|
a,b,c=map(int,input().split())
if a<c<b or b<c<a:
print("Yes")
else:
print("No")
|
p02687
|
s682489282
|
Accepted
|
s = input()
if s == "ABC":
print("ARC")
else:
print("ABC")
|
p02630
|
s407349910
|
Wrong Answer
|
import collections as c
n = int(input())
a = list(map(int,input().split()))
q = int(input())
s = sum(a)
cnt = c.Counter(a)
for i in range(q):
b,c = map(int,input().split())
s += (c-b)*cnt[b-1]
cnt[c-1] += cnt[b-1]
cnt[b-1] = 0
print(s)
|
p02743
|
s489553116
|
Accepted
|
a, b, c = map(int, input().split())
print("Yes" if c - b - a > 0 and (c - b - a) ** 2 > 4 * a * b else "No")
|
p02989
|
s387665661
|
Accepted
|
N = int(input())
d = list(map(int, input().split()))
d.sort()
if(d[N//2-1] == d[N//2]):
print(0)
else:
print(d[N//2]-d[N//2-1])
|
p03221
|
s303594291
|
Accepted
|
from operator import itemgetter
def main():
N,M = map(int,input().split())
PY = [list(map(int,input().split())) + [index] for index in range(M)]
PY.sort(key = itemgetter(1))
PY.sort(key = itemgetter(0))
Ans = [""]*M
Ken = [0]*(N + 1)
for i in range(M):
p,y,index = PY[i]
Ken[p] += 1
Ans[index] = str(p).zfill(6) + str(Ken[p]).zfill(6)
print(*Ans,sep="\n")
return
if __name__ == "__main__":
main()
|
p02577
|
s972923165
|
Accepted
|
N = int(input())
Nlist = list(str(N))
keep = list(map(int,Nlist))
if sum(keep) % 9 == 0:
print("Yes")
else:
print("No")
|
p02706
|
s999468060
|
Accepted
|
N, M = map(int, input().split())
A = list(map(int, input().split()))
if N >= sum(A):
print(N - sum(A))
else:
print(-1)
|
p03721
|
s000708240
|
Accepted
|
n, k = map(int, input().split())
X = []
for i in range(n):
a, b = map(int, input().split())
X.append((a, b))
X.sort()
cnt = 0
for i in range(n):
a, b = X[i]
cnt += b
if cnt >= k:
print(a)
exit()
|
p03814
|
s695970012
|
Accepted
|
s = input()
L = s.find('A')
R = s.rfind('Z')
print(R-L+1)
|
p02576
|
s036164136
|
Accepted
|
import math
N, X, T = map(int, input().split())
ans = int(math.ceil(N / X)) * T
print(ans)
|
p02996
|
s286574116
|
Accepted
|
n=int(input())
ab=[list(map(int,input().split())) for _ in range(n)]
ab.sort(key=lambda x:x[1])
jikoku=0
for i in range(n):
jikoku+=ab[i][0]
if jikoku>ab[i][1]:
print('No')
exit()
print('Yes')
|
p02957
|
s190039933
|
Accepted
|
A, B = map(int, input().split())
if A > B:
A, B = B, A
diff = B - A
if diff % 2:
print("IMPOSSIBLE")
else:
print(A + diff // 2)
|
p03617
|
s083142561
|
Accepted
|
def main():
q, h, s, d = map(int, input().split())
target = int(input())
h = min(2 * q, h)
s = min(2 * h, s)
d = min(2 * s, d)
answer = target // 2 * d + (target % 2) * s
print(answer)
if __name__ == '__main__':
main()
|
p02963
|
s659453725
|
Accepted
|
import math
s = int(input())
x = (10**9-(s%10**9))%(10**9)
y = (s+x)//(10**9)
print (0,0,10**9,1,x,y)
|
p02696
|
s823752836
|
Accepted
|
import math
A,B,N=map(float,input().split())
if N >= B:
N = B-1
ans = math.floor(A*N/B) - A*math.floor(N/B)
print(int(ans))
|
p03524
|
s987829450
|
Accepted
|
def main():
S = input()
N = len(S)
a = S.count("a")
b = S.count("b")
c = S.count("c")
ma = max(a, b, c)
mi = min(a, b, c)
if ma - mi > 1:
print("NO")
else:
print("YES")
if __name__ == '__main__':
main()
|
p03565
|
s110205668
|
Accepted
|
S = input()
T = input()
ns = len(S)
nt = len(T)
idx = []
for i in range(ns - nt + 1):
for j in range(nt):
if S[i+j] != T[j] and S[i+j] != '?':
break
else:
idx.append(i)
if idx != []:
ans = []
for i in idx:
s = S[:i] + T + S[i+nt:]
ans.append(s.replace('?', 'a'))
ans.sort()
print(ans[0])
else:
print('UNRESTORABLE')
|
p02689
|
s159368452
|
Accepted
|
import numpy as np
n,m = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]
l = [[int(i)-1 for i in input().split()] for _ in range(m)]
ans = np.array([1 for _ in range(n)])
for x,y in l:
if h[x]>h[y]:
ans[y] = 0
elif h[x] < h[y]:
ans[x] = 0
else:
ans[x] = 0
ans[y] = 0
print(np.count_nonzero(ans))
|
p03073
|
s672583754
|
Accepted
|
s = input()
N = len(s)
c1 = 0
c2 = 0
for i in range(N):
if i % 2 == 0:
if s[i] != '0':
c1 += 1
else:
c2 += 1
else:
if s[i] != '1':
c1 += 1
else:
c2 += 1
print(min(c1, c2))
|
p03910
|
s960752530
|
Accepted
|
N = int(input())
x = 0
for i in range(1, N+1):
x += i
if x >= N:
j = i
break
y = x-N
for i in range(1, j+1):
if i == y:
continue
print(i)
|
p02627
|
s757412399
|
Accepted
|
a = input()
if ord('a') <= ord(a) <= ord('z'):
print('a')
else:
print('A')
|
p02707
|
s808209382
|
Wrong Answer
|
from collections import Counter
n = input()
l = input().split()
lt = [int(i) for i in l]
f = Counter(l)
for i in lt:
print(f[str(i+1)])
|
p03778
|
s120185538
|
Accepted
|
W,a,b = map(int,input().split())
if a+W >= b and a <= b:
print(0)
elif a >= b+W and a > b:
print(a-(b+W))
else:
print(b-(a+W))
|
p03779
|
s334857788
|
Accepted
|
#!/usr/bin/env python3
import numpy as np
import bisect
X = int(input())
A = np.cumsum(range(1, 10 ** 5))
if np.any(A == X):
print(A.tolist().index(X) + 1)
else:
idx = bisect.bisect_left(A, X)
print(idx + 1)
|
p02696
|
s405275983
|
Accepted
|
"""n,m,q = (int(i) for i in input().split())
a = []
ans = 0
for i in range(q):
a.append(list(map(int,input().split())))
for i in range(q):
if
ans+=a[i][3]
print(ans)
"""
a,b,n = (int(i) for i in input().split())
x = 0
if b<=n:
x = b-1
else:
x = n
c = a*x
print(c//b)
|
p03721
|
s268541888
|
Accepted
|
N,K=map(int, input().split())
L=[0]*(10**5+1)
for i in range(N):
a,b=map(int, input().split())
L[a]+=b
res=K
for i,l in enumerate(L):
if l>0:
res-=l
if res<=0:
print(i)
break
#print(L)
|
p03827
|
s635944507
|
Accepted
|
n=int(input())
x=0
b=[]
s=input()
for S in s:
if S=='I':
x += 1
b.append(x)
else:
x -= 1
b.append(x)
print(max(max(b),0))
|
p03761
|
s696450718
|
Wrong Answer
|
import string
from collections import Counter
ans = ""
dic = {}
for a in string.ascii_lowercase:
dic[a] = 51
N = int(input())
for _ in range(N):
S = list(input())
S = Counter(S)
for l, c in dic.items():
if dic[l] > S[l]:
dic[l] = S[l]
for k, v in dic.items():
if v != 0:
ans += k * v
print(ans)
|
p02693
|
s796393635
|
Accepted
|
k = int(input())
a, b = map(int,input().split())
if a%k == 0 or a//k != b//k:
print("OK")
else:
print("NG")
|
p02723
|
s945958569
|
Wrong Answer
|
S = input("")
if len(S)<6:
print("If S is coffee-like, print Yes; otherwise, print No.")
else:
if ((S[2]) == (S[3])):
if ((S[4]) == (S[5])):
print ("Yes")
else:
print("No")
|
p02946
|
s127689809
|
Accepted
|
def main():
k, x = map(int, input().split())
anslis = [x for x in range(x-k+1, x+k)]
print(*anslis)
if __name__ == "__main__":
main()
|
p02860
|
s924114924
|
Accepted
|
N = int(input())
S = str(input())
if len(S) % 2 == 0:
S1 = S[:N // 2]
S2 = S[N // 2:]
if S1 == S2:
print('Yes')
exit()
else:
print('No')
exit()
else:
print('No')
|
p03962
|
s844713567
|
Accepted
|
a,b,c = map(list,input().split())
if a == b and b == c:
print('1')
elif a == b or a == c or b == c:
print('2')
else:
print('3')
|
p02768
|
s133664643
|
Wrong Answer
|
n, a, b = map(int, input().split())
MOD = 10**9 + 7
N = pow(2,n,MOD)
def com(n,r):
s = 1
for i in range(n-r+1, n+1):
s *= i
s %= MOD
t = 1
for j in range(1,r+1):
t *= j
t %= MOD
return s * pow(t,MOD-2, MOD) % MOD
print((N - com(n, a) - com(n, b)) % (MOD))
|
p02755
|
s420542447
|
Wrong Answer
|
import math
A,B=map(int,input().split())
C=max(100*A/8,10*B)
D=min(100*(A+1)/8,10*(B+1))
if math.ceil(C)>math.floor(D):
print("-1")
else:
print(math.ceil(C))
|
p03095
|
s030513723
|
Accepted
|
def main():
length = int(input())
word = input()
count = {}
for i in range(length):
if word[i] in count:
count[word[i]] += 1
else:
count[word[i]] = 2
mod = 10 ** 9 + 7
answer = 1
for c in count.values():
answer = (answer * c) % mod
print(answer - 1)
if __name__ == '__main__':
main()
|
p03286
|
s924969201
|
Accepted
|
n = int(input())
if n == 0:
print(0)
exit()
i = 1
ans = []
while n != 0:
if n % (i*2) != 0:
n -= i
ans.append(1)
else:
ans.append(0)
i *= -2
print("".join(map(str,ans[::-1])))
|
p02838
|
s872714135
|
Wrong Answer
|
import numpy as np
n = int(input())
a = list(map(int, input().split()))
p = 10**9 + 7
num_a = np.array([0]*60)
str_a = []
for i in a:
a_str = list(map(int, format(i, 'b').zfill(60)))
num_a = num_a + np.array(a_str)
num_a =reversed(num_a)
ans = 0
for i, j in enumerate(num_a):
ans = (ans + j*(n-j)*2**i)%p
print(ans)
|
p02793
|
s039736381
|
Wrong Answer
|
MOD = 1000000007
def gcd(a, b):
if b == 0:
return a
else:
return gcd(b, a%b)
def lcm(a, b):
return a//gcd(a,b)*a
n = int(input())
a = list(map(int,input().split()))
all_lcm = 1
for i in range(n):
all_lcm = lcm(all_lcm, a[i])
ans = 0
for i in range(n):
ans += all_lcm//a[i]
print(ans%MOD)
|
p02838
|
s202044233
|
Accepted
|
# if required XOR, re-solve later.
# just copy and paste from https://atcoder.jp/contests/abc147/submissions/14707076
for i in range(pow(10,6)):
pass
# added due to avoid duplicated search list wtih the same solver.
n = int(input())
a = list(map(int,input().split()))
d = 0
m = 10**9+7
for i in range(60):
b = 1<<i
l = len([1for j in a if j&b])
d += l*(n-l)*b%m
d %= m
print(d)
|
p02647
|
s482797542
|
Accepted
|
n, k = map(int, input().split())
a = [int(i) for i in input().split()]
for _ in range(k):
c = [0] * n
for i in range(n):
c[max(0, i-a[i])] += 1
if a[i] + i + 1 < n:
c[a[i] + i + 1] -= 1
j = 0
for i in range(n):
j += c[i]
a[i] = j
if sum(a) == n * n:
print(*([n] * n))
break
else:
print(*a)
|
p03001
|
s771974363
|
Accepted
|
W,H,x,y = map(int,input().split())
print((H*W)/2, int(W/2 == x and H/2 == y))
|
p03387
|
s009815756
|
Wrong Answer
|
A = list(map(int,input().split()))
A = sorted(A)
cnt = 0
if A[1]-A[0]>=2:
cnt += (A[1]-A[0])//2
A[0]+= cnt*2
if A[0]==A[1]==A[2]:
print(cnt)
exit()
while(True):
cnt+=1
A = sorted(A)
A[0]+=1
A[1]+=1
print(A)
if A[0]==A[1]==A[2]:
break
print(cnt)
|
p03250
|
s738420411
|
Accepted
|
# coding: utf-8
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
A = lr()
A.sort()
answer = sum(A) + 9 * max(A)
print(answer)
|
p02767
|
s384888943
|
Accepted
|
N = int(input())
X_list = list(map(int, input().split()))
min_n = min(X_list)
max_n = max(X_list)
min_cost = 10**16
for n in range(min_n,max_n+1):
cost = 0
for x in X_list:
cost = cost + (x - n)**2
min_cost = min(min_cost, cost)
print(min_cost)
|
p03163
|
s970787092
|
Wrong Answer
|
from sys import stdin
def main():
n,w = map(int, input().split())
ary = [list(map(int, stdin.readline().split())) for _ in range(n)]
dp = [[0 for _ in range(w+1)] for _ in range(n)]
for i in range(n-1):
for y in range(w+1):
dp[i+1][y] = dp[i][y-ary[i+1][0]] + ary[i+1][1] if ary[i+1][0] <= y else dp[i][y]
print(dp[n-1][w])
if __name__ == '__main__':
main()
|
p03944
|
s671839860
|
Accepted
|
W, H, N = map(int, input().split())
border = [0,W,0,H]
for i in range(N):
x, y, a = map(int, input().split())
if a == 1:
border[a-1] = max(border[a-1], x)
elif a == 2:
border[a-1] = min(border[a-1], x)
elif a == 3:
border[a-1] = max(border[a-1], y)
elif a== 4:
border[a-1] = min(border[a-1], y)
if border[1] - border[0] < 0 and border[3] - border[2] < 0:
print(0)
exit()
print(max((border[1] - border[0]) * (border[3] - border[2]), 0))
|
p03427
|
s690104173
|
Accepted
|
n = int(input())
s = str(n)
ans1 =0
for i in range(len(s)):
ans1 += int(s[i])
ans2 = (len(s)-1)*9+int(s[0])-1
print(max(ans1, ans2))
|
p03087
|
s276585878
|
Accepted
|
n,q=map(int,input().split())
s=list(input())
x=[[] for i in range(q)]
for i in range(q):
l,r=map(int,input().split())
x[i].append(l)
x[i].append(r)
ans=[0 for i in range(n+1)]
if s[0]=="A" and s[1]=="C":
ans[2]=1
for i in range(3,n+1):
if s[i-1]=="C" and s[i-2]=="A":
ans[i]=ans[i-1]+1
else:
ans[i]=ans[i-1]
for i in range(q):
print(ans[x[i][1]]-ans[x[i][0]])
|
p02753
|
s986549906
|
Wrong Answer
|
a = str(input())
if a == "AAA"or"BBB":
print("No")
else:
print("Yes")
|
p03131
|
s095624367
|
Accepted
|
k, a, b = map(int, input().split())
if b - a <= 2:
print(k + 1)
else:
print((k - (a - 1)) // 2 * (b - a) + (k - (a - 1)) % 2 + a)
|
p03126
|
s378392758
|
Wrong Answer
|
n, m = map(int, input().split())
a = [set(list(map(int, input().split()))[1:]) for i in range(n)]
s = {}
for i in a:
if a.index(i) == 0:
s = i
else:
s = s & i
print(len(s))
|
p02939
|
s672375120
|
Wrong Answer
|
S = input()
list1 = []
cnt = 0
for i in range(len(S)-1):
if S[i] == S[i+1]:
if len(S) ==2:
cnt = 2
else:
cnt += 1
else:
if cnt > 2:
list1.append(cnt)
cnt = 0
if list1 == []:
print(len(S) - cnt + 1)
else:
for x in list1:
cnt += x - 1
print(len(S) - cnt)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.