problem_id
stringclasses 428
values | submission_id
stringlengths 10
10
| status
stringclasses 2
values | code
stringlengths 5
816
|
|---|---|---|---|
p02829
|
s721718840
|
Accepted
|
a = input()
a1 = int(a)
b = input()
b1 = int(b)
print(6-a1-b1)
|
p02756
|
s849946546
|
Wrong Answer
|
S = input()
Q = int(input())
Qu= [list(input().split()) for _ in range(Q)]
r = 0
B = []
A = []
for i in range(Q):
if int(Qu[i][0]) == 1:
r = 1 - r
else:
F = int(Qu[i][1])
C = Qu[i][2]
F -= 1
if F == r:
B.append(C)
else:
A.append(C)
if r == 0:
B.reverse()
print("".join(B + [S] + A))
else:
A.reverse()
print("".join(A + [S] + B))
|
p02708
|
s990846642
|
Wrong Answer
|
import sys
input = lambda: sys.stdin.readline().strip("\r\n")
n, k = map(int, input().split())
mod = 10**9 + 7
ans = 0
for i in range(k, n+2):
mini = i*(i+1)//2
maxi = (n+1)*(n+2)//2 - (n+1-i)*(n+1-i+1)//2
ans += maxi - mini
print(ans % mod)
|
p02681
|
s777652713
|
Accepted
|
S = input()
T = input()
if S == T[:-1]:
print('Yes')
else:
print('No')
|
p03696
|
s596218081
|
Accepted
|
def resolve():
N = int(input())
S = list(input())
nopen = 0
addleft = 0
addright = 0
for s in S:
if s == "(":
nopen += 1
else:
if nopen == 0:
addleft += 1
else:
nopen -= 1
addright = nopen
print("("*addleft+"".join(S)+")"*addright)
if __name__ == '__main__':
resolve()
|
p02717
|
s046197679
|
Accepted
|
X, Y, Z = map(int, input().split())
print(str(Z) + " " + str(X) + " " + str(Y))
|
p02754
|
s465650726
|
Accepted
|
N,B,R = map(int,input().split())
a = N % (B + R)
b = N // (B + R) * B
if a >= B:
b += B
else:
b += a
print(b)
|
p03379
|
s300701732
|
Accepted
|
#!/usr/bin/env python
# coding: utf-8
# In[25]:
N = int(input())
X = list(map(int, input().split()))
# In[26]:
x1 = sorted(X)[N//2-1]
x2 = sorted(X)[N//2]
for i in range(N):
if X[i] >= x2:
print(x1)
else:
print(x2)
# In[ ]:
|
p02646
|
s997683336
|
Wrong Answer
|
[a,v] = list(map(int, input().split()))
[b,w] = list(map(int, input().split()))
t = int(input())
nomi = a-b
denomi = w-v
if denomi != 0:
rem = nomi % denomi
if rem == 0:
tRe = nomi//denomi
if 0<=tRe<=t:
print('YES')
else:
print('NO')
else:
tRe = nomi / denomi
if 0 < tRe < t:
print('YES')
else:
print('NO')
else:
print('NO')
|
p02993
|
s950803008
|
Accepted
|
a, b, c, d = input()
if a==b or b==c or c==d:
print("Bad")
else:
print("Good")
|
p03017
|
s640368326
|
Accepted
|
N, A, B, C, D = map(int, input().split())
S = input()
s = A
f = B
flag = True
if C < D:
if '##' in S[A-1:C]:
flag = False
if '##' in S[B-1:D]:
flag = False
else:
if S[D - 2] == '#':
if '...' not in S[B-2:D]:
flag = False
if '##' in S[A-1:C]:
flag = False
ans = 'Yes' if flag else 'No'
print(ans)
|
p02772
|
s995184509
|
Accepted
|
from sys import stdin
if __name__ == '__main__':
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
result = 'APPROVED'
for a in A:
if a % 2 == 0:
if a % 3 == 0 or a % 5 == 0:
pass
else:
result = 'DENIED'
break
print(result)
|
p03284
|
s458072112
|
Accepted
|
N, K = map(int, input().split())
print(0 if N % K == 0 else 1)
|
p03379
|
s312504554
|
Accepted
|
N = int(input())
X = list(map(int,input().split()))
nX = sorted(X)
left = nX[N//2-1]
right = nX[N//2]
for i in X:
if i <= left:
print(right)
else:
print(left)
|
p03329
|
s320262104
|
Accepted
|
n = int(input())
min_time = [float('inf')] * (n+1)
min_time[0] = 0
for i in range(n):
min_time[i+1] = min(min_time[i+1],min_time[i]+1)
times_6 = 1
while i+6**times_6<=n:
min_time[i+6**times_6] = min(min_time[i+6**times_6],min_time[i]+1)
times_6 += 1
times_9 = 1
while i+9**times_9<=n:
min_time[i+9**times_9] = min(min_time[i+9**times_9],min_time[i]+1)
times_9 += 1
print(min_time[-1])
|
p03612
|
s031272697
|
Accepted
|
N = int(input())
P = list(map(int,input().split()))
cnt = 0
for i in range(1, N):
if P[i-1] == i:
tmp = P[i-1]
P[i-1] = P[i]
P[i] = tmp
cnt += 1
if P[N-1] == N:
tmp = P[N-1]
P[N-1] = P[N-2]
P[N-2] = tmp
cnt += 1
print(cnt)
|
p03037
|
s777147520
|
Accepted
|
if __name__ == "__main__":
n, m = map(int, input().split())
l = 1
r = n
for _ in range(m):
li, ri = map(int, input().split())
if l < li:
l = li
if r > ri:
r = ri
print(max(r-l+1,0))
|
p03061
|
s827497888
|
Accepted
|
from fractions import gcd
N = int(input())
A = [int(i) for i in input().split()]
cuml = [0]
cumr = [0]
for i in range(N):
cuml.append(gcd(cuml[i], A[i]))
cumr.append(gcd(cumr[i], A[N-i-1]))
maxg = 0
for i in range(N):
# print(gcd(cuml[i], cumr[N-i-1]))
maxg = max(maxg, gcd(cuml[i], cumr[N-i-1]))
print(maxg)
|
p02880
|
s616346134
|
Wrong Answer
|
n = int(input())
a = 0
for i in range(1, 10):
for j in range(1,10):
if n/i==j:
print("Yes")
exit()
a +=1
else:
continue
print("No")
if a == 0:
print("No")
else:
exit()
|
p02947
|
s118536937
|
Wrong Answer
|
N = int(input())
s = [input() for i in range(N)]
num = 0
for i in range(N):
for j in range(i+1, N):
count = 0
for k in range(10):
if s[i][k] in s[j]:
count += 1
if count == 10:
num += 1
print(num)
|
p03637
|
s295944606
|
Accepted
|
n = int(input())
a = list(map(int, input().split()))
b, c, d = 0, 0, 0
for i in a:
if i % 4 == 0:
b += 1
elif i % 2 == 0:
c += 1
else:
d += 1
if c >= 1:
d += 1
if b + 1 >= d:
print("Yes")
else:
print("No")
|
p02972
|
s619587592
|
Wrong Answer
|
N=int(input())
a=list(map(int, input().split()))
b=[0]*N
for i in range(N-1,-1,-1):
if 2*(i+1)>N:
b[i]=a[i]
else:
summ = sum(a[2*i+1::i+1])
if summ%2==0:
b[i]= 1
else:
b[i] = 0
#print(b)
ans=[]
for num in b:
if num!=0:
ans.append(num)
print(len(ans))
print(*ans)
|
p02911
|
s497130784
|
Accepted
|
# coding: utf-8
def main():
N, K, Q = map(int, input().split())
A = [0] * N
for _ in range(Q):
tmp = int(input())
A[tmp - 1] += 1
for i in range(N):
if A[i] + K > Q:
print('Yes')
else:
print('No')
if __name__ == "__main__":
main()
|
p02933
|
s871641958
|
Wrong Answer
|
a = int(input())
s = (input())
if a >= 3200:
print('s')
if a < 3200:
print('red')
|
p03797
|
s280360658
|
Wrong Answer
|
N, M= map(int, input().split())
if N >= M * 2:
print(M // 2)
else:
m = M - N * 2
s = m // 4
print(N + s)
|
p03494
|
s828814190
|
Accepted
|
n = int(input())
a = list(map(int, input().split()))
cnt = 0
while all(i % 2 == 0 for i in a):
cnt += 1
a = [i//2 for i in a]
print(cnt)
|
p02838
|
s778192637
|
Accepted
|
N = int(input())
A = list(map(int, input().split()))
MOD = 10**9+7
b = [0]*60
for a in A:
digit = 0
while a > 0:
if a % 2 == 1:
b[digit] += 1
a = a >> 1
digit += 1
ans = 0
for i in range(60):
ans += 2**i * b[i] * (N-b[i])
ans %= MOD
print(ans)
|
p02860
|
s527213939
|
Accepted
|
N=int(input())
S=input()
if S[:N//2]==S[N//2:]:
print("Yes")
else:print("No")
|
p02645
|
s777785779
|
Wrong Answer
|
s = input()
print(s[0:2])
|
p03487
|
s080227892
|
Wrong Answer
|
from collections import Counter
N = int(input())
A = Counter(map(int, input().split()))
X = 0
for x, y in A.items():
if x <= y and X < x and N - x >= y - x:
X = x
print(N - X)
|
p02596
|
s229670470
|
Wrong Answer
|
K=int(input())
n=1
an=[7%K]
bn=[10%K]
while True:
an.append(an[-1]%K+(7%K)*(bn[-1]%K))
if an[-1]%K==0:
print(n+1)
break
elif an[0]==an[-1]:
print(-1)
break
bn.append((bn[-1]*10)%K)
n+=1
|
p02578
|
s267645385
|
Accepted
|
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1
N=int(input())
A=list(map(int,input().split()))
ans=0
tmp=A[0]
for x in A[1:]:
if x<tmp:
ans+=tmp-x
tmp=max(tmp,x)
print(ans)
|
p03416
|
s127448836
|
Wrong Answer
|
a, b = list(map(int, input().split()))
count = 0
for i in range(a, b):
i = str(i)
if i[0] == i[-1] and i[1] == i[-2]:
count += 1
print(count)
|
p02640
|
s844340590
|
Accepted
|
X,Y=map(int,input().split())
number=0
for i in range(X+1):
if 2*i + 4*(X-i) == Y:
number += 1
else:
number += 0
if number > 0:
print('Yes')
else:
print('No')
|
p03284
|
s096395721
|
Accepted
|
# coding: utf-8
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N, K = lr()
bl = N % K == 0
print(0 if bl else 1)
|
p03633
|
s350964645
|
Accepted
|
from math import gcd
N=int(input())
ans=int(input())
for i in range(N-1):
t=int(input())
ans=ans*t//gcd(ans, t)
print(ans)
|
p02780
|
s529742884
|
Accepted
|
from collections import deque
N, K = map(int, input().split())
p = list(map(int, input().split()))
max_ans = 0
tmp_ans = 0
queue = deque([])
for i in range(N):
e = (p[i] + 1) / 2
tmp_ans += e
queue.append(e)
if len(queue) > K:
tmp_ans = tmp_ans - queue.popleft()
max_ans = max(max_ans, tmp_ans)
print(max_ans)
|
p03720
|
s092070717
|
Accepted
|
N, M = map(int,input().split())
R = [0 for k in range(N)]
for k in range(M):
a, b = map(int,input().split())
R[a-1] += 1
R[b-1] += 1
for e in R:
print(e)
|
p04030
|
s047817536
|
Accepted
|
s = input()
t = ''
for c in s:
if c == '0':
t += '0'
elif c == '1':
t += '1'
elif c == 'B':
t = t[:-1]
print(t)
|
p02628
|
s002921825
|
Accepted
|
n,k=map(int,input().split())
p=list(map(int,input().split()))
p.sort()
sm=0
for i in range(k):
sm+=p[i]
print(sm)
|
p02675
|
s959691436
|
Wrong Answer
|
N = input ()
P = '1689'
H = '2457'
if N[-1] in P:
print ('pon')
elif N[-1] in H:
print ('hon')
else:
print ('bon')
|
p03086
|
s603025327
|
Wrong Answer
|
s = input()
cnt = 0
ans = 0
for i in range(len(s)):
if s[i] == 'A' or s[i] == 'T' or s[i] == 'C' or s[i] == 'G':
cnt += 1
else:
ans = max(ans, cnt)
cnt = 0
print(ans)
|
p02813
|
s496483237
|
Accepted
|
# coding: utf-8
# Your code here!
import itertools
N = int(input())
num1 = list(map(int,input().split()))
num2 = list(map(int,input().split()))
x, y = 0, 0
l = [_ + 1 for _ in range(N)]
A = []
for v in itertools.permutations(l, N):
A.append(list(v))
x = A.index(num1)
y = A.index(num2)
print(abs(x - y))
|
p03817
|
s621472011
|
Wrong Answer
|
x = int(input())
if x % 11 > 6:
print(x//11 * 2 + 2)
else:
print(x//11 * 2 + 1)
|
p03087
|
s691348746
|
Wrong Answer
|
N,Q = map(int,input().rstrip().split())
S = input().rstrip()
a = [0]*N
for i in range(N):
if i > 1:
a[i] = a[i-1]
if i != 0 and S[i-1]=='A' and S[i] == 'C':
a[i] += 1
for _ in range(Q):
l, r = map(int,input().rstrip().split())
|
p03971
|
s120427187
|
Accepted
|
n,a,b=map(int,input().split())
s=str(input())
s=list(s)
for i in range(len(s)):
if s[i]=="a" and a+b>0:
print("Yes")
if a>0:
a=a-1
else:
b=b-1
elif s[i]=="b" and b>0:
print("Yes")
b=b-1
else:
print("No")
|
p03633
|
s183527399
|
Wrong Answer
|
N = int(input())
ti = [int(input()) for i in range(N)]
def euc_alg(val1, val2):
if val1 == val2:
return val1
mod = val2
divided = val1
while 1:
tmp_mod = divided % val2
if tmp_mod == 0:
break
divided = mod
mod = tmp_mod
ret = val1 * val2 // mod
return ret
maxti = max(ti)
least_common_mult = max([euc_alg(maxti, t) for t in ti])
print(least_common_mult)
|
p03438
|
s492281302
|
Accepted
|
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
b = 0
for i in range(N):
if A[i]>B[i]:b+=(A[i]-B[i])
for i in range(N):
if A[i]<B[i]:
c = (B[i]-A[i])//2
if c<=b:b-=c
elif c>b:b=0
print("No" if b else "Yes")
|
p02959
|
s767659814
|
Wrong Answer
|
n = int(input())
En = list(map(int, input().split()))
Pl = list(map(int, input().split()))
res = 0
for i in range(n):
if En[i] < Pl[i]:
res += En[i]
Pl[i] -= En[i]
if En[i+1] < Pl[i]:
res += En[i+1]
else:
En[i+1] -= Pl[i]
res += Pl[i]
else:
res += Pl[i]
print(res)
|
p02708
|
s133387493
|
Accepted
|
n,k = map(int,input().split())
a = 1
for i in range(k,n+1):
a += n*i - i**2 + i + 1
print(a%(10**9+7))
|
p03106
|
s205660254
|
Accepted
|
a, b, k = map(int, input().split())
arr = []
for i in range(1, min(a,b) + 1):
if a % i == 0 and b % i == 0:
arr.append(i)
arr.reverse()
print(arr[k-1])
|
p03681
|
s967621833
|
Accepted
|
n, m = map(int, input().split())
MOD = 10 ** 9 + 7
if n == m:
ans = 1
for i in range(2, n + 1):
ans = ans * i % MOD
print(ans * ans * 2 % MOD)
elif n + 1 == m:
ans = 1
for i in range(2, n + 1):
ans = ans * i % MOD
print(ans * ans * m % MOD)
elif n == m + 1:
ans = 1
for i in range(2, m + 1):
ans = ans * i % MOD
print(ans * ans * n % MOD)
else:
print(0)
|
p03659
|
s514213859
|
Wrong Answer
|
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True )
x=a[0]
y=a[1]
for i in range(2,n):
if a[i]<0:
if x>y:
x+=a[i]
else:
y+=a[i]
else:
if x<y:
x+=a[i]
else:
y+=a[i]
print(max(x,y)-min(x,y))
|
p03986
|
s846107636
|
Wrong Answer
|
X = input()
num = X.find('S')
inv_num = X.rfind('T')
X_num = len(X)
S_num = X[num:inv_num+1].count('S')
T_num = X[num:inv_num+1].count('T')
print(X_num- min(S_num,T_num)*2)
|
p03760
|
s106373598
|
Accepted
|
o=input()
e=input()
ans=['']*(len(o)+len(e))
flg=1
for i in range(len(o)):
ans[i*2]=o[i]
for j in range(len(e)):
ans[j*2+1]=e[j]
for k in range(len(ans)):
print(ans[k],end="")
|
p03817
|
s313011538
|
Wrong Answer
|
n=int(input())
ans=1
if n%11>6:
ans+=1
k=n//11
if (k+1)*11<=n:
k+=1
print(2*k+ans)
|
p02730
|
s196695760
|
Accepted
|
st = input()
n = len(st)
half = (n-1)//2
if st[0:half] == st[n-1:half:-1]:
if half%2 == 0:
qu = half//2
if st[:qu] == st[half-1:qu-1:-1] and st[half+1:half+qu+1] == st[n-1:half+qu:-1]:
print("Yes")
else:
print("No")
else:
qu = (half-1)//2
if st[:qu] == st[half-1:qu:-1] and st[half+1:half+qu+1] == st[n-1:half+qu+1:-1]:
print("Yes")
else :
print("No")
else:
print("No")
|
p02860
|
s978347138
|
Accepted
|
n = int(input())
s = input()
if s[:n//2:] == s[n//2::]:
print("Yes")
else:
print("No")
|
p03126
|
s012459791
|
Accepted
|
N, M = map(int, input().split())
li = [0] * M
for i in range(N):
K = list(map(int, input().split()))
for j in range(1, len(K)):
li[K[j]-1] += 1
print(li.count(N))
|
p03796
|
s401017484
|
Accepted
|
# Problem B - Training Camp
# input process
N = int(input())
# initialization
frac_num = 1
INF = 10**9 + 7
for i in range(1, N+1):
frac_num = (frac_num * i) % INF
print(frac_num%INF)
|
p02838
|
s176955646
|
Accepted
|
import numpy as np
n,*a = map(int,open(0).read().split())
a = np.array(a)
mod = 10**9+7
ans = 0
for i in range(61):
b = np.count_nonzero(a>>i&1)
ans += b*(n-b)*1<<i
print(ans%mod)
|
p02971
|
s477283561
|
Wrong Answer
|
n = int(input())
apple = []
for _ in range(n):
apple.append(int(input()))
big = max(apple[1:n+1])
print(big)
for i in range(1, n):
if apple[i] != big:
if apple[i-1] >= big:
print(apple[i-i])
big = apple[i-1]
else:
print(big)
else:
orange = apple[0:i] + apple[i+1:n]
print(max(orange))
big = max(orange)
|
p02785
|
s523813113
|
Accepted
|
n, k = map(int, input().split())
h = list(map(int, input().split()))
h.sort()
print(sum(h[:max(0, len(h) - k)]))
|
p03352
|
s110224545
|
Accepted
|
import sys
a = [1]
for i in range(2,34):
for j in range(2,13):
if i**j <= 1000 :
a.append(i**j)
x = int(input())
for k in range(x,0,-1):
if k in a:
print(k)
sys.exit()
|
p02552
|
s442785564
|
Accepted
|
x = int(input())
print("1" if x == 0 else "0")
|
p02642
|
s774238822
|
Accepted
|
import collections
def main():
n = int(input())
A = sorted(map(int, input().split()))
D = collections.defaultdict(int)
for a in A:
D[a] += 1
m = max(A)
S = set()
ans = 0
for i in range(n):
a = A[i]
if a in S:
continue
if D[a] == 1:
ans += 1
num = a
while num <= m:
S.add(num)
num += a
print(ans)
main()
|
p03251
|
s206416680
|
Accepted
|
N,M,X,Y=map(int,input().split())
XL=sorted(list(map(int,input().split())))
YL=sorted(list(map(int,input().split())))
ans = 'War'
for Z in range(X+1,Y+1):
if XL[-1]<Z and Z<=YL[0]:
ans = 'No War'
break
print(ans)
|
p02697
|
s447436049
|
Wrong Answer
|
n,m = map(int,input().split())
a = 1
b = 2
for i in range(m):
print(a,b)
a = a + 1
b = b + i + 2
|
p03854
|
s361209815
|
Wrong Answer
|
import re
flag = re.match('^(deram|dreamer|erase|eraser)+$',input())
if flag:
print('YES')
else:
print('NO')
|
p02684
|
s521935250
|
Wrong Answer
|
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
a = [0] + a
now = 1
cities = [now]
done = set()
for i in range(n):
now = a[now]
if now in done:
break
done.add(now)
cities.append(now)
idx_s = cities.index(now)
f = (len(cities) - idx_s)
d = k - idx_s
idx = d%f
ans = cities[idx + idx_s]
print(ans)
|
p02658
|
s969376812
|
Accepted
|
N = int(input())
A = list(map(int, input().split()))
result = 1
ok = True
if 0 in A:
result = 0
else:
for a in A:
result *= a
if result > 10 ** 18:
ok = False
break
if ok:
print(result)
else:
print(-1)
|
p02618
|
s641733930
|
Accepted
|
from random import randint
D=int(input())
c=list(map(int,input().split()))
s=[0]*D
for i in range(D):
s[i]=list(map(int,input().split()))
for i in range(D):
print(randint(1,26))
|
p02546
|
s448862940
|
Accepted
|
S=input()
if S[-1] == 's': print(S+'es')
else: print(S+'s')
|
p03951
|
s767266568
|
Accepted
|
N = int(input())
s = input()
t = input()
for i in range(N, 0, -1):
# print(i)
# print(s[-i:])
# print(t[:i])
if s[-i:] == t[:i]:
print(2 * (N - i) + i)
exit()
print(2 * N)
|
p02661
|
s629870136
|
Accepted
|
import math
x = int(input())
ab = [list(map(int, input().split())) for i in range(x)]
A=[]
B=[]
for i in range(x):
A.append(ab[i][0])
B.append(ab[i][1])
A.sort()
B.sort()
if x%2==1:
min=A[x//2]
max=B[x//2]
ans=max-min+1
else:
min=(A[x//2-1]+A[x//2])/2
max=(B[x//2-1]+B[x//2])/2
ans=(max-min)*2+1
print(int(ans))
|
p03548
|
s214305528
|
Accepted
|
X,Y,Z = map(int,input().split())
print((X-Z)//(Y+Z))
|
p03543
|
s821394765
|
Accepted
|
S = input()
for i in range(9):
hikaku = str(i)+str(i)+str(i)
#print(hikaku)
if (hikaku in S) == True:
result = "Yes"
break
else:
result = "No"
print(result)
|
p03030
|
s634588429
|
Wrong Answer
|
import copy
n = int(input())
r = []
for _ in range(n):
city, x = input().split()
x = int(x)
r.append((city, x))
d = copy.deepcopy(r)
d = sorted(d, key=lambda x: -x[1])
d = sorted(d, key=lambda x: x[0])
print(d)
for k in d:
print(r.index(k) + 1)
|
p02842
|
s744673638
|
Wrong Answer
|
n = int(input())
for i in range(n):
if int(i * 1.08) == n:
print(i)
exit()
print(":(")
|
p02760
|
s967323120
|
Accepted
|
a = [input().split() for _ in range(3)]
n = int(input())
b = [input() for _ in range(n)]
p = []
p += a
p += [list(a_) for a_ in zip(*a)]
p += [[a[x][x] for x in range(3)]]
p += [[a[x][2-x] for x in range(3)]]
for p_ in p:
for x in p_:
if x in b:
continue
else:
break
else:
print('Yes')
break
else:
print('No')
|
p03617
|
s425408197
|
Accepted
|
l = [[0.25],[0.5],[1],[2]]
tmp = list(map(int,input().split()))
for i in range(4):
l[i].append(tmp[i])
for i in range(4):
l[i].append(l[i][1]*4/(l[i][0]*4))
from operator import itemgetter
l = sorted(l, key=itemgetter(2))
ans = 0
n = 4*int(input())
for i in range(4):
tmp = n//int(l[i][0]*4)
if tmp >= 1:
ans += tmp * l[i][1]
n -= tmp*int(l[i][0]*4)
print(int(ans))
|
p03998
|
s837463350
|
Accepted
|
S = [input() for _ in range(3)]
t = 0
i = [0, 0, 0]
while len(S[t]) > i[t]:
tmp = t
if S[t][i[t]] == "a":
t = 0
elif S[t][i[t]] == "b":
t = 1
else:
t = 2
i[tmp] += 1
if t == 0:
ans = "A"
elif t == 1:
ans = "B"
else:
ans = "C"
print(ans)
|
p03087
|
s875142960
|
Wrong Answer
|
from bisect import bisect
n,q=map(int,input().split())
s=input()
l=[]
r=[]
for i in range(q):
L,R=map(int,input().split())
l.append(L)
r.append(R)
a=[]
c=[]
for i in range(n-1):
if s[i:i+2]=='AC':
a.append(i)
c.append(i)
for i in range(q):
print(bisect(c,r[i])-bisect(a,l[i])+1)
|
p03474
|
s046872650
|
Accepted
|
a,b = map(int, input().split())
s = input()
count = 0
ans = 'Yes'
for i in range(a+b+1):
if i == a:
if s[i] != '-':
ans = 'No'
break
else:
if s[i] == '-':
ans = 'No'
break
print(ans)
|
p03252
|
s723120002
|
Wrong Answer
|
s = input()
t = input()
d = {}
for i in range(len(s)):
if t[i] in d:
if d[t[i]] != s[i]:
print("No")
break
else:
d[t[i]] = s[i]
print("Yes")
|
p02793
|
s612121280
|
Wrong Answer
|
N=int(input())
a = list(map(int, input().split()))
import fractions
ans = a[0]
for i in range(1, N):
ans = ans * a[i] // fractions.gcd(ans, a[i])
import numpy as np
aa = np.array(a)
print(sum((ans//aa)%(10**9+7)))
|
p02725
|
s040919212
|
Accepted
|
k,n,*a=map(int,open(0).read().split())
a+=[a[0]+k]
d=[abs(a[i]-a[i+1]) for i in range(n)]
print(k-max(d))
|
p03359
|
s291685783
|
Accepted
|
a,b=input().split()
print(int(a)-(a>b))
|
p03427
|
s943467254
|
Accepted
|
N = int(input())
original = N
cnt = 0
while N >= 10:
N //= 10
cnt += 1
#print(N)
temp = (N+1) * 10 ** cnt - 1
temp2 = N * 10 ** cnt - 1
#print(temp)
#print(temp2)
if temp == original:
print(sum(list(map(int, list(str(temp))))))
else:
print(sum(list(map(int, list(str(temp2))))))
|
p03069
|
s408959734
|
Accepted
|
def main():
n = int(input())
s = input()
white = s.count(".")
ans, black = white, 0
for i in range(n):
if s[i] == ".":
white -= 1
else:
black += 1
tmp = black + white
if tmp < ans:
ans = tmp
print(ans)
if __name__ == "__main__":
main()
|
p02731
|
s213888164
|
Wrong Answer
|
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()
L = i_i()
ans = 0
for x in range(L):
for y in range(L):
z = L - x - y
if z > 0 and x * y * z > ans:
ans = x * y * z
print(ans)
|
p03437
|
s774174091
|
Accepted
|
x, y = map(int, input().split())
if x%y == 0:
print(-1)
else:
print(x)
|
p02797
|
s520919131
|
Accepted
|
N, K, S = map(int, input().split())
M = 1000000000
_S = M - 1 if S == M else M
print(' '.join(list(map(str, [S] * K + [_S] * (N - K)))))
|
p02831
|
s636398573
|
Wrong Answer
|
import fractions
a, b = map(int, input().split())
print(a * b / fractions.gcd(a, b))
|
p03012
|
s005761607
|
Wrong Answer
|
ans = 0
n = int(input())
w = list(map(int,input().split()))
mid = sum(w)//2
ans = 0
for i in w:
ans += i
if mid <= ans:
print(abs(ans-(sum(w)-ans)))
break
|
p02555
|
s669370468
|
Accepted
|
from operator import mul
from functools import reduce
def cmb(n,r):
r = min(n-r,r)
if r == 0: return 1
over = reduce(mul, range(n, n - r, -1))
under = reduce(mul, range(1,r + 1))
return over // under
mod=10**9+7
s=int(input())
a=s//3
ans=0
for i in range(1,a+1):
t=s-3*i
ans+=cmb(t+i-1,i-1)%mod
print(ans%mod)
|
p03493
|
s464160368
|
Accepted
|
ok = input()
print(ok.count("1"))
|
p02801
|
s684058220
|
Accepted
|
C = input()
print(chr(ord(C)+1))
|
p03324
|
s232369501
|
Wrong Answer
|
d,n=map(int,input().split())
print(n*(100**d))
|
p02939
|
s736308260
|
Accepted
|
s=input()
ans=0
mae=""
now=""
for i in s:
now += i
if mae != now:
ans += 1
mae = now
now = ""
print(ans)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.