problem_id stringclasses 428
values | submission_id stringlengths 10 10 | status stringclasses 2
values | code stringlengths 5 816 |
|---|---|---|---|
p02683 | s663073197 | Accepted | N,M,X = map(int,input().split())
d=[]
ans = []
for i in range(N):
l=list(map(int,input().split()))
d.append(l)
for i in range(2**N):
u=[0]*M
price=0
for j in range(N):
if ((i>>j) & 1):
price+=d[j][0]
for k in range(M):
u[k]+=d[j][k+1]
... |
p02602 | s344428206 | Wrong Answer | import numpy as np
N, K = [int(x) for x in input().split()]
A = list([int(x) for x in input().split()])
r = np.cumprod(A, dtype='int64')
before = r[K-1]
for i in range(K, N):
after = before // A[i-K]
after *= A[i]
if after > before:
print('Yes')
else:
print('No')
before = after
|
p02687 | s039572840 | Accepted | s = input()
if s == "ABC":
print("ARC")
else:
print("ABC") |
p03146 | s885841291 | Accepted | s=int(input())
if s==1 or s==2 or s==4:
cnt=0
else:
cnt=0
while s!=4:
if s%2==0:
s=s/2
cnt+=1
else:
s=3*s+1
cnt+=1
print(cnt+4) |
p02665 | s924527243 | Accepted | n,*a=map(int,open(0).read().split());t=sum(a);print(sum([w:=1]+[exit(print(-1)) if(w:=min(2*(w-q),t:=t-q))<0 else w for q in a])) |
p03680 | s283495550 | Wrong Answer | n = int(input())
a = [int(input()) for i in range(n)]
b = a[0]
if b == 2:
print(0)
else:
c = 1
d = []
while b != 2:
b = a[b - 1]
if b in d:
print(- 1)
break
else:
d.append(b)
c += 1
else:
print(c) |
p03043 | s746340287 | Accepted | import os, sys, re, math
(N, K) = [int(n) for n in input().split()]
if K == 1:
print(1)
else:
lk = math.log2(K - 1)
p = 0
for i in range(1, N + 1):
if i >= K:
p += 1.0
else:
p += (0.5 ** (int(lk - math.log2(i) + 1)))
print(p / N)
|
p02933 | s493297035 | Accepted | print(input() if int(input()) >= 3200 else "red") |
p02793 | s460419342 | Accepted | import fractions
from functools import reduce
def lcm_base(x, y):
return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
return reduce(lcm_base, numbers, 1)
c = 0
n = int(input())
l = list(map(int,input().split()))
l_cm = lcm_list(l)
for i in range(0,n):
c = c + l_cm//l[i]
print(c%(10**9 + 7)) |
p03745 | s506186037 | Accepted | n = int(input())
a = list(map(int, input().split()))
c = 1
m = a[0]
s = 1 # 0:- 1:_ 2:+
for i in a:
if m == i:
continue
elif m > i:
if s == 2:
s = 1
c += 1
else:
s = 0
else:
if s == 0:
s = 1
c += 1
else:
... |
p02571 | s949255776 | Accepted | s = input()
t = input()
n = len(s)
m = len(t)
ans = m
for i in range(n-m+1):
p = 0
for j in range(m):
if s[i+j] != t[j]:
p += 1
ans = min(ans,p)
print(ans) |
p02933 | s663581244 | Accepted | a = int(input())
s = input()
if a >= 3200:
print(s)
else:
print('red')
|
p02924 | s805973797 | Accepted | n=int(input())
ans=(n)*(n-1)//2
print(ans) |
p02983 | s467745869 | Accepted | n, m = list(map(int,input().split()))
res = 10**9
for i in range(n, m):
for j in range(i+1, m+1):
res = min(res, (i*j % 2019))
if res == 0:
print(0)
exit()
print(res)
|
p02583 | s956876874 | Accepted | n = int(input())
l = list(map(int, input().split()))
s = 0
if n <= 2:
s = 0
else:
for i in range(n):
for j in range(i+1, n):
for k in range(j+1, n):
a = l[i]
b = l[j]
c = l[k]
if a+b>c and b+c>a and c+a>b and a != b and b != c and c != a:
s += 1
print(s) |
p03759 | s601017947 | Accepted | a,b,c = map(int,input().split())
if b-a == c-b:
print('YES')
else:
print('NO') |
p02595 | s477183373 | Accepted | N,D =(int(x) for x in input().split())
xy = [map(int,input().split()) for _ in range(N)]
x,y = [list(i) for i in zip(*xy)]
n = 0
for i in range(N):
if(x[i]**2 + y[i]**2 <= D**2):
n += 1
print(n) |
p03352 | s163196715 | Accepted | x = int(input())
S = set()
S.add(1)
for b in range(2, int(1000**0.5) + 1):
for p in range(2, 10):
if b**p > 1000:
break
S.add(b**p)
for n in range(x, 0, -1):
if n in S:
print(n)
exit() |
p02946 | s126956252 | Accepted | k,x=map(int, input().split())
print(" ".join([str(i) for i in range(x-(k-1), x+(k-1)+1)]))
|
p03785 | s011149463 | Accepted | N, C, K = map(int, input().split())
T = [int(input()) for _ in range(N)]
T.sort()
bus = []
count = 0
for i in range(N):
if count == 0:
first = T[i]
count += 1
else:
if T[i] - first <= K:
count += 1
else:
bus.append(count)
first = T[i]
... |
p03095 | s053578043 | Accepted | mod = 1000000007
eps = 10**-9
def main():
import sys
from collections import Counter
input = sys.stdin.readline
N = int(input())
S = input().rstrip('\n')
C = Counter(S)
ans = 1
for x in C.values():
ans = (ans * (x+1))%mod
print(ans-1)
if __name__ == '__main__':
main... |
p03073 | s427508642 | Wrong Answer | import numpy as np
s = input()
n = len(s)
ans = 0
for i in range(n // 2):
if s[2 * i] == "0":
ans += 1
if 2 * i + 1 == n:
break
if s[2 * i + 1] == "1":
ans += 1
print(min(ans, n - ans))
|
p02860 | s615276368 | Wrong Answer | import math
n=int(input())
s=input()
s1=s[:n//2]
s2=s[math.ceil(n/2):]
if s1==s2:
print('Yes')
else :
print('No') |
p03289 | s186709539 | Accepted | s=input()
cnt_c=0
for i in s:
if i=='C':
cnt_c+=1
c_present=False
n=len(s)
for i in range(2,n-1):
if s[i]=='C':
c_present=True
flag=True
for i in s:
if i!='A' and i!='C':
if i.isupper():
flag=False
if s[0]=='A' and cnt_c==1 and c_present and flag:
print('AC')
else:
... |
p02753 | s950262979 | Accepted | s=sorted(set(input()))
print('Yes' if ['A','B'] == s else 'No') |
p03723 | s424436729 | Accepted | import numpy as np
import sys
input = sys.stdin.readline
A,B,C = map(int,input().split())
if A == B == C and A%2 == 0 and B%2 == 0 and C%2 == 0:
ans = -1
else:
ans = 0
while A%2 == 0 and B%2 == 0 and C%2 == 0:
next_a = C/2 + B/2
next_b = A/2 + C/2
next_c = A/2 + B/2
A = n... |
p03479 | s208572753 | Accepted | x, y = map(int, input().split())
cnt = 0
while x <= y:
x *= 2
cnt += 1
print(cnt) |
p02576 | s332720302 | Accepted | import math
N,X,T = list(map(int,input().split(" ")))
k = math.ceil(N/X)
print(k*T) |
p03146 | s676922858 | Wrong Answer | import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
s = int(input())
arr = [0] * 1000100
cnt = 0
while True:
if s % 2 == 0:
s //= 2
else:
s = 3 * s + 1
cnt += 1
arr[s] += 1
if arr[s] > 1:
print(cnt + 1)
exit()
|
p02664 | s089608459 | Wrong Answer | a = input()
t =list(a)
if t[len(t)-1] == "?":
t[len(t)-1] = "D"
for i in reversed(range(1,len(t)-1)):
if t[i] == "?" and t[i+1] == "D":
t[i] = "P"
elif t[i] == "?":
t[i] = "D"
if t[0] == "?":
if t[1] == "D":
t[0] = "P"
else:
t[0] = "D"
answer = "".join(t)
print(answer... |
p03827 | s854671043 | Wrong Answer | n = int(input())
s = str(input())
ans = 0
ans_lis = []
for i in range(n):
if s[i] == "I":
ans += 1
ans_lis.append(ans)
else:
ans -= 1
ans_lis.append(ans)
print(max(ans_lis)) |
p02768 | s136298952 | Accepted | n,a,b = map(int,input().split())
mod = 10**9+7
ans = pow(2,n,mod)
def cmb(n,r,mod):
if n == r:
return 1
p,q = 1,1
r = min(r,n-r)
for i in range(r):
p = p*(n - i)%mod
q = q*(i + 1)%mod
Y = pow(q,10**9+5,mod)
return p*Y%mod
ans = ans - cmb(n,a,mod) - cmb(n,b,mod) - 1
print(ans%mod) |
p03612 | s772727451 | Accepted | n = int(input())
P = list(map(int, input().split()))
count = 0
for i in range(n - 1):
if P[i] == i + 1:
P[i], P[i + 1] = P[i + 1], P[i]
count += 1
if P[-1] == n:
count += 1
print(count) |
p03487 | s024552898 | 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:
X = x
print(N - X) |
p04012 | s073111207 | Accepted | w = input()
G = []
q = 0
for x in w:
if not ([x, True] in G or [x, False] in G):
G.append([x, True])
else:
if [x, True] in G:
G[G.index([x, True])][1] = False
else:
G[G.index([x, False])][1] = True
for h in range(len(G)):
q += G[h][1]
#print(G)
if q == 0:
... |
p04011 | s073049796 | Accepted | N = int(input())
K = int(input())
X = int(input())
Y = int(input())
if N > K:
print(K*X+((N-K)*Y))
else:
print(N*X) |
p03071 | s922264687 | Accepted | A,B = map(int, input().split())
if A==B:
print(A*2)
else:
print(max(A,B)*2-1) |
p02731 | s505859471 | Accepted | L = int(input())
x = L/3
ans = x**3
print(ans)
|
p03323 | s587468313 | Accepted | import sys
def input(): return sys.stdin.readline().rstrip()
A, B = map(int, input().split())
print(':(' if A > 8 or B > 8 else 'Yay!') |
p02711 | s234163122 | Wrong Answer | a = int(input())
b=0
for i in range(1,a+1):
if i%3 != 0 and i%5 != 0 :
b+=i
print(b)
|
p03251 | s700474339 | Wrong Answer | n,m,x,y=map(int,input().split())
X=list(map(int,input().split()))
Y=list(map(int,input().split()))
cnt=0
if max(X)>=min(Y):
print('War')
else:
for i in range(max(X)+1,min(Y)+1):
if x<i and i<=y:
print('No war')
cnt+=1
exit()
if cnt==0:
print('War') |
p03043 | s988657402 | Wrong Answer | n, k = map(int, input().split())
s = 0
for i in range(n):
t = float(k / (2 * (i+1)))
s += (1/n) * ((1/2) ** t)
print(s) |
p03328 | s106668505 | Accepted | #
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
r_ = n / m
if (r_ - (n // m)) > 0:
return (n//m) + 1
else:
return (n//m)"""
def main():
a,b = map(int,input().split())
print(int((b-a... |
p02972 | s514884950 | Accepted | N = int(input())
a = list(map(int, input().split()))
ans = [0 for i in range(N)]
ans2 = []
for i in range(N):
p = N - 1 - i
if a[p] != sum(ans[p::p + 1]) % 2:
ans[p] = 1
ans2.append(str(p + 1))
print(sum(ans))
print(" ".join(ans2)) |
p03220 | s910848499 | Accepted | N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
ans = 0
tmp = 100000
for i in range(N):
if tmp > abs(A - (T - 0.006*H[i])):
tmp = abs(A - (T - 0.006*H[i]))
ans = i + 1
print(ans) |
p03944 | s275801596 | Wrong Answer | w, h, n=map(int,input().split())
mat = [list(map(int, input().split())) for _ in range(n)]
w1 = 0
w2 = w
h1 = 0
h2 = h
for i in range(n):
if(mat[i][2] == 1):
w1 = mat[i][0]
elif(mat[i][2] == 2):
w2 = mat[i][0]
elif(mat[i][2] == 3):
h1 = mat[i][1]
else:
h2 = mat[i][1]
... |
p02708 | s258928048 | Accepted | MOD=10**9+7
n, k = map(int, input().strip().split())
ans=0
for i in range(k,n+2):
ans+=i*(n-i+1)+1
ans%=MOD
print(ans) |
p02696 | s051253728 | Accepted | A,B,N = list(map(int, input().split()))
if N < B-1:
print(A*N//B)
else:
print(A*(B-1)//B) |
p03285 | s123006781 | Wrong Answer | import math
a=int(input())
b_4 = math.ceil(a/4)
b_7 = math.ceil(a/7)
count =0
for i in range(b_4+1):
for j in range(b_7+1):
if (4*i+j*7) == a:
count += 1
if count==1:
print('Yes')
else:
print('No') |
p03038 | s655779647 | Accepted | N, M = map(int, input().split())
d = dict()
A = list(map(int, input().split()))
for i in range(N):
d[A[i]] = d.get(A[i], 0) + 1
for i in range(M):
B, C = map(int, input().split())
d[C] = d.get(C, 0) + B
ans = 0
keys = sorted(list(d.keys()), reverse = True)
for k in keys:
kosuu = min(N, d.get(k))
ans += k * kosuu
... |
p02582 | s412889196 | Wrong Answer | import re
x = input()
pattern = "R+"
pat = re.match(pattern, x)
if pat:
print(len(pat.group()))
else:
print(0) |
p02957 | s046438534 | Accepted | a,b=(int(x) for x in input().split())
if (a+b)%2==0:
print(int((a+b)/2))
else:
print("IMPOSSIBLE") |
p02606 | s052676784 | Accepted | a,b,n=map(int,input().split())
print(b//n-a//n+(a%n==0)) |
p03555 | s519357358 | Accepted | C=[0,0]
A=[0,0]
C[0]=list(input())
C[1]=list(input())
A[1]=[C[0][-1],C[0][-2],C[0][-3]]
A[0]=[C[1][-1],C[1][-2],C[1][-3]]
print('YES' if A==C else 'NO') |
p03076 | s522842208 | Wrong Answer | import math
l=[int(input()) for _ in range(5)]
l_min=[]
ans=0
for i in l:
l_min.append(i%10)
for _ in range(4):
ind=l_min.index(max(l_min))
l_min.pop(ind)
res=math.ceil(l.pop(ind)/10)*10
ans+=res
print(ans+l[0]) |
p02747 | s062382773 | Accepted | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
S = read().rstrip().decode()
def solve(S):
N = len(S)
if N % 2 == 1:
return False
T = 'hi' * (N//2)
return S == T
print('Yes' if solve(S) else 'No') |
p03795 | s522719249 | Accepted | e = int(input())
print(e*800 - (int(e/15)*200)) |
p02723 | s760703702 | Accepted | S = input()
if S[2]==S[3]:
if S[4]==S[5]:
print("Yes")
else:
print("No")
else:
print("No") |
p03836 | s845316709 | Accepted | sx, sy, tx, ty = map(int, input().split())
dy = tx - sx
dx = ty - sy
ans = ''
ans += 'U' * dx
ans += 'R' * dy
ans += 'D' * dx
ans += 'L' * dy
ans += 'L'
ans += 'U' * (dx + 1)
ans += 'R' * (dy + 1)
ans += 'D'
ans += 'R'
ans += 'D' * (dx + 1)
ans += 'L' * (dy + 1)
ans += 'U'
print(ans) |
p04031 | s989960659 | Wrong Answer | #ABC043C
n=int(input())
a = list(map(int, input().split()))
h=sum(a)//len(a)
sum_a=0
for i in range(len(a)):
sum_a=sum_a+(a[i]-h)**2
print(int(sum_a)) |
p02953 | s868600645 | Wrong Answer | import sys
N = int(input())
H = list(map(int, input().split()))
for i in range(N-1):
if H[i]-1 >= H[i+1]:
print("No")
sys.exit()
print("Yes") |
p03711 | s838302192 | Wrong Answer | x, y = (int(i) for i in input().split())
if x == 2 or y == 2:
print('No')
if x == 4 or x == 6 or x == 9 or x == 11:
if y == 4 or y == 6 or y == 9 or y == 11:
print('Yes')
else:
print('No')
else:
if y == 4 or y == 6 or y == 9 or y == 11:
print('No')
else:
print('Yes') |
p02861 | s677394440 | Accepted | import itertools
from math import sqrt
def distance(a,b):
return sqrt((a[0]-b[0])**2+(a[1]-b[1])**2)
N=int(input())
towns=[tuple(map(int,input().split())) for _ in range(N)]
dis_town=[[0]*N for _ in range(N)]
for i in range(N):
for j in range(N):
dis_town[i][j]=distance(towns[i],towns[j])
combs=list(it... |
p02582 | s731907371 | Wrong Answer | a=input()
if 'RR' in a:
print("2")
elif 'R' in a:
print("1")
elif 'RRR' in a:
print('3')
else:
print("0") |
p03487 | s370778416 | Accepted | #!/usr/bin/env python3
from collections import Counter
import sys
sys.setrecursionlimit(10**6)
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
ans = 0
for i in sorted(c.keys()):
if c[i] < i:
ans += c[i]
elif c[i] == i:
continue
elif c[i] > i:
ans += c[i]-i
pri... |
p03997 | s989314431 | Accepted | a = int(input())
b = int(input())
h = int(input())
print(int((a+b)*h/2))
|
p03324 | s952698152 | Accepted | d,n = map(int,input().split())
ans = 0
if n != 100:
ans = 100**d * n
else:
ans = 100**d * 101
print(ans) |
p02862 | s442316934 | Wrong Answer | import math
def combinations_count(n, r):
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
X, Y = map(int, input().split())
if X >= Y:
pass
else:
X = Y
Y = X
if X > 2 * Y:
print(0)
exit()
else:
pass
cnt1 = 0
while X < 2 * Y:
X = X - 1
Y = Y - 2
cnt1 += 1
if X != 2 *Y... |
p02724 | s547745685 | Accepted | x = int(input())
# print(x)
ans = 0
ans += x // 500 * 1000
ans += x % 500 // 5 *5
print(ans) |
p02603 | s610190033 | Accepted | n = int(input())
a = list(map(int, input().split())) + [0]
m, s = 1000, 0
for i in range(n):
if a[i] < a[i+1] and s == 0:
s = m//a[i]
m -= a[i]*s
elif a[i] > a[i+1] and s:
m += a[i]*s
s = 0
print(m) |
p03438 | s514423117 | Wrong Answer | n=int(input())
a=sorted(list(map(int,input().split())))
b=sorted(list(map(int,input().split())))
for i in range(n):
if a[i]<=b[i]:
a[i]=b[i]
a=sorted(a)
b=sorted(b)
for i in range(n):
if a[i]<=b[i]:
a[i]=b[i]
if a==b:
print('Yes')
else:
print('No') |
p02775 | s020273349 | Accepted | import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()
def main():
N=list(input())
N=list(reversed(list(map(int,N))))+[0]
ans=0
for i in range(len(N)):
if N[i]>=6 or (N[i]==5 and N[i+1]>=5):
ans+=10-N[i]
N[i+1]+=1... |
p02594 | s826809737 | Wrong Answer | X = int(input())
if X >= 30: print("Yes")
else: print("Mp") |
p04033 | s110893170 | Accepted | a, b = map(int, input().split())
if a * b <= 0:
print("Zero")
elif a > 0:
print("Positive")
else:
num = b - a + 1
if num % 2 == 0:
print("Positive")
else:
print("Negative") |
p03745 | s887422376 | Accepted | N=int(input())
A=list(map(int,input().split()))
pumi=0
ff=0
cut=1
for i in range(0,N-1):
if pumi==0:
ff=0
elif pumi==-1:
ff=-1
elif pumi==1:
ff=1
if A[i+1]>A[i]:
pumi=1
elif A[i+1]<A[i]:
pumi=-1
if pumi==-1 and ff==1:
cut+=1
pumi=0
el... |
p02911 | s802524107 | Wrong Answer | import numpy as np
N, K, Q = map(int, input().split())
score = np.array([0]*N)
def change_score(N ,A, score):
score = score - np.array([1]*N)
score[A-1] = score[A-1] + 1
return score
for i in range(Q):
A = int(input())
score = change_score(N, A, score)
print(score)
f_score = score
for i... |
p02970 | s419917925 | Wrong Answer | import sys
import math
input = lambda: sys.stdin.readline().rstrip()
def main():
n, d = map(int, input().split())
print(math.ceil(n/(d*2)))
if __name__ == '__main__':
main() |
p02811 | s270972003 | Wrong Answer | K,X = input().split()
def main(K,X):
if (K * 500) >= X:
print('Yes')
else:
print('No')
if __name__ == '__main__':
main(K,X)
|
p03208 | s764341126 | Wrong Answer | N , K =map(int,input().split())
H = []
for i in range(N):
H.append(input())
H =sorted(H)
ans = 1000000000
for j in range(N-K+1):
ans=min(int(H[j+K-1])-int(H[j]),ans)
print(ans) |
p04012 | s492950676 | Wrong Answer | w = input()
while len(w) > 0:
a = w[0]
if w.count(a)%2 != 0:
print("No")
exit()
w = w.replace(a,"")
print(w)
print("Yes")
|
p02706 | s101980473 | Wrong Answer | N,M = map(int,input().split())
A = sum(map(int,input().split()))
print(N-A if N<=A else -1)
|
p02995 | s639735938 | Wrong Answer |
def main2():
a, b, c, d = list(map(int, input().split()))
sss = b//c - (a-1)//c
ssss = b//d - (a-1)//d
if d % c == 0:
di = c
elif c % d == 0:
di = d
elif ((d*c)/2) % c == 0 and ((d*c)/2) % d == 0:
di = d*c//2
else:
di = c*d
sssss = b // di - (a - 1) // d... |
p03637 | s606944269 | Accepted | n = int(input())
a = list(map(int,input().split()))
four, two, none = 0, 0, 0
for i in range(n):
if a[i] % 4 == 0:
four += 1
elif a[i] % 2 == 0:
two += 1
else:
none += 1
if four >= none or (four == none-1 and two == 0):
print("Yes")
else:
print("No") |
p03681 | s666494416 | Wrong Answer | import math
n, m = map(int, input().split())
n_f = math.factorial(n)
m_f = math.factorial(m)
res = (n_f * m_f * 2) % 1000000007
if abs(n - m) >= 2:
res = 0
print(res) |
p02959 | s572634585 | Wrong Answer | n = int(input())
ls_a = list(map(int, input().split()))
ls_b = list(map(int, input().split()))
ans = 0
res = 0
for i in range(n):
ans += min(ls_a[i], res + ls_b[i])
if res >= ls_a[i]:
res == ls_b[i]
else:
res = max(res + ls_b[i] - ls_a[i], 0)
if res >= ls_a[n]:
print(ans + ls_a[n])
elif 0 <= res < ls_a[n]:
... |
p02627 | s972540030 | Accepted | a=input()
if a.islower()==True:
print("a")
else:
print("A")
|
p02995 | s056928192 | Accepted | from fractions import gcd
A, B, C, D = [int(i) for i in input().split()]
lcm = C*D//gcd(C, D)
ans = (B-B//C-B//D+B//lcm-(A-A//C-A//D+A//lcm))
if A < B and A % C and A % D:
ans += 1
print(ans)
|
p03284 | s851837736 | Accepted | N, K = map(int, input().split())
if N % K == 0:
print(0)
else:
print(1) |
p02630 | s873721387 | Accepted | n = int(input())
a = list(map(int, input().split()))
q = int(input())
A = [0] * 100001
for i in a:
A[i] += 1
ans = 0
for i in range(len(A)):
ans += i * A[i]
for n in range(q):
b,c = list(map(int, input().split()))
ans += (c * A[b]) - (b * A[b])
A[c] += A[b]
A[b] = 0
print(ans)
|
p02793 | s191991203 | Wrong Answer | import fractions
MOD = 1000000007
N = int(input())
A = list(map(int,input().split()))
#print(math.gcd(5,4))
LCM = A[0]
for i in range(0,N-1,1):
LCM = LCM*A[i+1]//fractions.gcd(A[i+1],LCM)
B = [0 for i in range(0,N,1)]
for i in range(0,N,1):
B[i]=LCM//A[i]
ans = 0
for i in range(0,N,1):
ans = B[i] + ans
... |
p02602 | s555766813 | Accepted | #C
N, K = map(int, input().split())
A = list(map(int, input().split()))
for i in range(N - K):
if A[i] < A[i + K]:
print('Yes')
else:
print('No') |
p03210 | s075439836 | Wrong Answer | x = int(input())
if x == 7 or 5 or 3:
print("YES")
else:
print("NO")
|
p03317 | s996953826 | Accepted | from math import ceil
n,k=map(int,input().split())
a=list(map(int,input().split()))
n-=1
k-=1
print(ceil(n/k)) |
p03556 | s105191276 | Accepted | n=int(input())
for i in range(10**5):
if i**2 > n:
print((i-1)**2)
break |
p03485 | s794094208 | Accepted | import math
a,b=map(int,input().split());print(math.ceil((a+b)/2)) |
p02621 | s106850048 | Accepted | a = int(input())
A = a + a**2 + a**3
print(A) |
p02754 | s826266295 | Accepted | n, a, b = map(int, input().split())
sho = n//(a+b)
amari = n % (a+b)
print(sho*a+min(a, amari)) |
p03612 | s001037271 | Wrong Answer | N=int(input())
P=[1]+list(map(int,input().split()))
ans=0
for i in range(1,N):
if P[i]==i:
if i+1!=P[i] or i==1:
P[i+1],P[i]=P[i],P[i+1]
ans+=1
else:
P[i-1],P[i]=P[i],P[i-1]
ans+=1
print(ans) |
p02731 | s359322487 | Wrong Answer | def maxvolume (s):
maxvalue = 0
i = 1
for i in range(s - 1):
j = 1
for j in range(s):
k = s - i - j
maxvalue = max(maxvalue, i * j * k)
return ma... |
p02820 | s485500276 | Wrong Answer | n,k = [int(i) for i in input().split()]
r,s,p = [int(i) for i in input().split()]
t = input()
ans = [0 for i in range(n)]
for i in range(n):
w = t[i]
if w=='r':
ans[i] = p
elif w=='s':
ans[i] = r
else:
ans[i] = s
for i in range(k, n):
if ans[i]==ans[i-k]:
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.