problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p03481
s600790540
Wrong Answer
x,y=map(int,input().split()) n=1 while int(2**n)<=y/x: n+=1 print(n)
p02766
s512195762
Accepted
def toStr(n,base): convertString = "0123456789ABCDEF" if n < base: return convertString[n] else: return toStr(n//base,base) + convertString[n%base] a,b = map(int,input().split()) print(len(toStr(a,b)))
p03264
s386417400
Wrong Answer
k = int(input()) n = k // 2 if n % 2 == 0: print(k**2) else: print(k * (k + 1))
p03469
s010336187
Accepted
import sys input = sys.stdin.readline s=input().strip() print("2018/"+s[5:])
p03475
s458466252
Accepted
n = int(input()) l = [list(map(int, input().split())) for _ in range(n-1)] for i in range(n-1): t = 0 for j in range(i, n-1): c = l[j][0] s = l[j][1] f = l[j][2] if t < s: t = s if t%f != 0: t = t+f - t%f t += c print(t) print(0)
p03437
s270771733
Accepted
X,Y = map(int, input().split()) if X%Y == 0: print('-1') else: print(X)
p03455
s357078811
Wrong Answer
a,b = map(int,input().split()) if (a*b) % 2: print("Even") else: print("Odd")
p02775
s806402402
Accepted
n = list(input()) n.insert(0, '0') ans = 0 for i in range(len(n)-1, -1, -1): if n[i] == '0': pass elif int(n[i]) <= 4: ans += int(n[i]) elif int(n[i]) == 5 and int(n[i-1]) <= 4: ans += int(n[i]) else: ans += 10 - int(n[i]) n[i-1] = str(int(n[i-1]) + 1) print(ans)
p02697
s683261771
Accepted
# coding: utf-8 # Your code here! import sys readline = sys.stdin.readline read = sys.stdin.read n,m = [int(i) for i in readline().split()] x = m y = m+1 if n%2==1: for i in range(m): print(x-i,y+i) else: num = 0 while 1+num*2 < n//2 and num < m: print(x-num,y+num) num += 1 while num < m: print(x-num,y+num+1) num += 1
p02756
s600197852
Accepted
S = input() Q = int(input()) t = '' for i in range(Q): instructions = list(map(str, input().split())) if instructions[0] == '1': S, t = t, S else: if instructions[1] == '1': t += instructions[2] else: S += instructions[2] print(t[::-1] + S)
p03448
s618080298
Accepted
a = int (input()) b = int (input()) c = int (input()) x = int (input()) cnt = 0 for i in range(a+1): for j in range(b+1): for k in range(c+1): if i*500 + j*100 + k*50 == x: cnt += 1 print(cnt)
p03328
s361070976
Wrong Answer
a,b=map(int,input().split()) k=0 for i in range(1,max(a,b)): k+=i if k-a>0 or k-b>0: break print(abs(min(a,b)-k))
p02712
s178152179
Accepted
N = int(input()) result = 0 for i in range(1, N+1): if i%15 != 0 and i%3 != 0 and i%5 != 0: result += i print(result)
p02900
s776228084
Accepted
A,B = map(int,input().split()) def gcd(x,y): if x<y:x,y = y,x if y==0:return x return gcd(y,x%y) G = gcd(A,B) S = set() S.add(1) n = G for i in range(2,G+1): if i*i>n: S.add(n) break if n%i==0: S.add(i) while n%i==0: n//=i print(len(S))
p02594
s159209487
Wrong Answer
X = int(input()) if X <= 30: print('Yes') else: print('No')
p03557
s903085280
Accepted
import bisect N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) A.sort() C.sort() ans = 0 for i in range(N): ans += bisect.bisect_left(A,B[i])*(N-bisect.bisect_right(C,B[i])) print(ans)
p03611
s537407439
Wrong Answer
n = int(input()) al = list(map(int, input().split())) al_s = list(set(al)) ans = [0] * (10 ** 5 + 1) for a in al_s: ans[a] += 1 ans[a + 1] += 1 ans[a - 1] += 1 print(max(ans))
p03077
s915435348
Wrong Answer
n = int(input()) x = [int(input()) for i in range(5)] d = n // min(x) if n == min(x): print(d+4) else: print(d+5)
p03208
s805967794
Wrong Answer
n,k=map(int,input().split()) h=sorted([int(input()) for _ in range(n)]) a=10**9 for i in range(n-2): a1=max(h[i:i+3])-min(h[i:i+3]) a=min(a,a1) print(a)
p03254
s747736658
Accepted
import sys input = lambda : sys.stdin.readline().rstrip() sys.setrecursionlimit(max(1000, 10**9)) write = lambda x: sys.stdout.write(x+"\n") n,x = list(map(int, input().split())) a = list(map(int, input().split())) a.sort() s = 0 for i in range(n): if s+a[i]==x or (i<n-1 and s+a[i]<=x): s += a[i] # print(s) else: i -= 1 break print(i+1)
p03494
s629730495
Accepted
n=int(input()) l=[int(x) for x in input().split()] ans=0 while all([l[i]%2==0 for i in range(n)]): ans+=1 l=list(map(lambda k:k//2,l)) print(ans)
p03862
s164027260
Wrong Answer
n, x = map(int,input().split()) cList = list(map(int,input().split())) count = 0 for i in range(1,n): tmp = cList[i-1]+cList[i]-x if tmp > 0: cList[i] -= tmp count += tmp print(count)
p03377
s065496954
Wrong Answer
a, b, x = map(int, input().split()) if a <= x and x <=a+b: print("Yes") else: print("No")
p02600
s866904824
Accepted
#!/usr/bin/env python # coding: utf-8 # In[3]: X = int(input()) # In[4]: if X < 600: ans = 8 elif X < 800: ans = 7 elif X < 1000: ans = 6 elif X < 1200: ans = 5 elif X < 1400: ans = 4 elif X < 1600: ans = 3 elif X < 1800: ans = 2 elif X < 2000: ans = 1 print(ans) # In[ ]:
p03069
s920177886
Accepted
import sys def input(): return sys.stdin.readline().strip() def mapint(): return map(int, input().split()) sys.setrecursionlimit(10**9) N = int(input()) S = list(input()) lis = [1 if s=='#' else 0 for s in S] from itertools import accumulate lis = list(accumulate(lis)) ans = 10**18 cnt = 0 for i in range(N-1, -1, -1): s = S[i] ans = min(ans, cnt+lis[i]) if s=='.': cnt += 1 ans = min(ans, cnt) print(ans)
p02658
s741608271
Wrong Answer
N = int(input("")) A = input("").split() A = [int(i) for i in A] n = 1 for i in range(N): n = n * A[i] if n > 10 ** 18: n = -1 break print(n)
p02796
s846606965
Accepted
def resolve(): n = int(input()) a = [] for _ in range(n): x, l = map(int, input().split()) a.append((x - l, x + l)) t = -float('inf') a.sort(key=lambda x: x[1]) ans = 0 for start_t, end_t in a: if t <= start_t: ans += 1 t = end_t print(ans) resolve()
p02948
s769249652
Wrong Answer
n,m=map(int,input().split()) l=[] for _ in range(n): a,b=map(int,input().split()) if a<=m: l.append((b,a)) l.sort(reverse=True) ans=0 t=1 for i in l: a=i[1] b=i[0] # print(a,b,t+a-1) if t+a-1>m: continue else: # print(a,b,end=' entered') ans+=b t+=1 print(ans)
p04019
s500457762
Accepted
from collections import Counter S = Counter(list(input())) if ((S["N"] and S["S"]) or not(S["N"] or S["S"])) and ((S["W"] and S["E"]) or not(S["W"] or S["E"])): print("Yes") else: print("No")
p02730
s157494542
Accepted
a = input() if len(a) % 2 == 0: print('No') else: N = int((len(a) - 1) / 2) if a[:N] == a[-N:] == a[:N:-1]: print('Yes') else: print('No')
p03160
s903639815
Accepted
N = int(input()) H = list(map(int,input().split())) dp = [float('inf') for i in range(N)] #全ノードを取り敢えずinfにしておく dp[0] = 0 for i in range(N-1): #足場を一個飛んだ時 dp[i+1] = min(dp[i+1],dp[i] + abs(H[i+1] - H[i])) #足場を二個飛んだ時 if i <= N-3: dp[i+2] = min(dp[i+2], dp[i] + abs(H[i + 2]-H[i])) print(dp[N-1])
p02952
s705088281
Wrong Answer
n = int(input()) ans = 0 if n == 100000 : ans = 90909 elif 10000 <= n <= 99999 : ans = n - 10000 + 1 + 900 + 9 elif 1000 <= n <= 9999 : ans = 909 elif 100 <= n <= 999 : ans = n - 100 + 1 + 9 elif 10 <= n < 99 : ans = 9 elif 1 <= n <= 9 : ans = n print(ans)
p02862
s847984400
Accepted
import sys X, Y = map(int, input().split()) def combination(n, r, mod=10**9+7): n1, r = n+1, min(r, n-r) numer = denom = 1 for i in range(1, r+1): numer = numer * (n1-i) % mod denom = denom * i % mod return numer * pow(denom, mod-2, mod) % mod if 2*Y < X or 2*X < Y or (X+Y)%3 != 0: print(0) sys.exit() n1 = (2*Y-X)//3 n2 = (2*X-Y)//3 print(combination(n1+n2, min(n1, n2), 10**9+7))
p04011
s871354178
Accepted
n, k, x, y = (int(input()) for i in range(4)) if k >= n: print(n*x) else: print(k*x + (n-k)*y)
p03448
s625726486
Accepted
A=int(input()) B=int(input()) C=int(input()) X=int(input()) K=0 for a in range(A+1): for b in range(B+1): for c in range(C+1): K+=(500*a+100*b+50*c==X) print(K)
p03565
s478635215
Accepted
import sys S = list(sys.stdin.readline().rstrip()) T = list(sys.stdin.readline().rstrip()) len_s = len(S) len_t = len(T) for i in range(len_s - len_t, -1, -1): for j in range(len_t): if S[i+j] == T[j] or S[i+j] == "?": continue else: break else: for k in range(len_t): S[i+k] = T[k] print(("".join(S)).replace("?","a")) exit() print("UNRESTORABLE")
p02684
s656168236
Wrong Answer
n,k=map(int,input().split()) a=[int(i)-1 for i in input().split()] ed=[False]*n go=0 c=0 cc=0 while not ed[go]:#既に通っていたら終了 ed[go]=True go=a[go] c+=1 ed=[False]*n while not ed[go]:#二回目のループは違う可能性があるため6,5,2,5,3,2の場合、6,2,5,3,2,5,3,2,5,...となる ed[go]=True go=a[go] cc+=1#別変数で保存 for i in range((k-c-cc)%cc): go=a[go] print(go+1)
p02756
s556543613
Accepted
from collections import deque S = deque(list(input())) Q = int(input()) inv = 0 for i in range(Q): query = input().split() if query == ['1']: inv = (inv + 1)%2 else: f, c = query[1], query[2] if f == '1': if inv: S.append(c) else: S.appendleft(c) else: if inv: S.appendleft(c) else: S.append(c) S = list(S) if inv: print(''.join(S[::-1])) else: print(''.join(S))
p02697
s444922943
Accepted
n, m = map(int, input().split()) if n%2: for i in range(1, m+1): print(i, n-i) else: for i in range(1, m+1): if 2*i >= n/2: print(i, n-i-1) else: print(i, n-i)
p02608
s697839367
Wrong Answer
#! python3 # coding:utf-8 def main(): n = int(input()) ans = [0 for _ in range(n+1)] for x in range(1,100): for y in range(1,100): for z in range(1,100): eq = x**2 + y**2 + z**2 + x*y + y*z + z*x if eq < n+1: ans[eq]+=1 for i in ans: print(i) if __name__ == "__main__": main()
p03779
s143779496
Accepted
x = int(input()) now = 0 for i in range(1, x+1): now += i if 0 <= now-x <= i * (i-1)//2: print(i) break
p02785
s374808955
Accepted
n,k=map(int,input().split()) hs=list(map(int,input().split())) hs.sort() print(sum(hs) if k==0 else sum(hs[:-k]))
p02694
s993293141
Accepted
from math import floor import sys input = sys.stdin.readline X=int(input().rstrip('\n')) res = 0 now = 100 while now < X: res += 1 now = now + floor(now*0.01) print(res)
p03456
s811996664
Accepted
a,b = list(input().split()) n = int(a+b) result = 'No' for i in range(1,1001): if n == i * i: result = "Yes" break print(result)
p02881
s198646492
Wrong Answer
import numpy as np n = int(input()) x = np.arange(1,10**6) div = x[n%x==0] d = len(div) print(div[d//2]+div[d//2-1]-2)
p03328
s977123436
Wrong Answer
a,b = map(int,input().split()) c = abs(b - a) x = 0 while(a % c != 0): a += 1 x += 1 print(x)
p02618
s896510561
Accepted
# -*- coding: utf-8 -*- import random D = int(input()) c = [int(i) for i in input().split()] s = [] for i in range(D): s.append([int(j) for j in input().split()]) for i in range(D): print(random.randint(1, 26))
p02784
s028260264
Wrong Answer
H , N = map ( int , input().strip().split(" ") ) ; L = sum ( map ( int , input().strip().split(" ") ) ) ; print ( "Yes" if L > H else "No" ) ;
p02759
s380419538
Accepted
a = int(input()) n = a // 2 if 2*n == a: print(n) else: print(n + 1)
p02823
s904051505
Accepted
N, A, B = map(int, input().split()) d = B - A if (d % 2 == 0): ans = d // 2 else: left = B - 1 right = N - A mini_1 = min(left, right) kado = min(A - 1, N - B) mini_2 = kado + 1 + (d - 1) // 2 ans = min(mini_1, mini_2) print(ans)
p03693
s531620159
Accepted
r,g,b = input().split() num = int(r+g+b) if (num%4 == 0): print("YES") else: print("NO")
p02595
s688998403
Accepted
import math n,d=map(int,input().split()) xy= [[int(i) for i in input().split()] for i in range(n)] an=0 for i in range(n): if math.sqrt(xy[i][0]**2+xy[i][1]**2)<=d: an+=1 print(an)
p03161
s467139311
Wrong Answer
n,k = map(int, input().split()) h = list(map(int, input().split())) dp = [0]*(n-1) for i in range(1,n-1): temp = 10**10 for j in range(1, min(k+1, i+1) ): temp = min(temp, abs(h[i] - h[i-j]) + dp[i-j]) dp[i] = temp print(dp[n-2])
p02691
s400481893
Wrong Answer
n = int(input()) a = [i for i in map(int, input().split()) if i < n] num = len(a) ans = 0 for i in range(num): for j in range(i+1, num): if a[i]+a[j] == j-i: ans += 1 print(ans)
p02814
s969251434
Accepted
from fractions import gcd from functools import reduce def lcm(a, b): return a * b // gcd(a, b) def solve(string): n, m, *a = map(int, string.split()) c = 2**len(bin(a[0]).split("1")[-1]) l = reduce(lcm, (_a if not _a % c and _a // c % 2 else 2 * m + 2 for _a in a)) return str((m - l // 2) // l + 1) if l <= 2 * m else "0" if __name__ == '__main__': import sys print(solve(sys.stdin.read().strip()))
p03126
s241629934
Wrong Answer
n,m = map(int, input().split()) k = [list(map(int, input().split())) for i in range(n)] c = 0 for i in range(n): for j in range(1,n+1): if j not in k[i][1:]: break else: c+=1 print(c)
p03061
s002005018
Wrong Answer
import fractions from functools import reduce def gcd(numbers): return reduce(fractions.gcd, numbers) N = int(input()) A = list(map(int, input().split())) ans = [] if len(A) == 1: ans.append(A[0]) else: ans.append(gcd(A[1:])) ans.append(gcd(A[:N])) for i in range(1, N-1): l = [] l.append(gcd(A[:i])) l.append(gcd(A[i+1:])) ans.append(gcd(l)) print(max(ans))
p03778
s540935080
Wrong Answer
w,a,b = map(int,input().split()) aw = a+w bw =b+w print(min(abs(b-aw),abs(bw-a)))
p03673
s340887590
Wrong Answer
n=int(input()) l=list(map(int,input().split())) ans=[] for i in range((n+1)//2): print(l[n-2*i-1],end=' ') for i in range(n//2): print(l[2*i],end=' ')
p03327
s156738146
Accepted
def resolve(): N = int(input()) if N >= 1000: print("ABD") else: print("ABC") if '__main__' == __name__: resolve()
p02714
s995830842
Accepted
def solution(): n = int(input()) s = input() ans = s.count('R') * s.count('G') * s.count('B') for i in range(n): for j in range(i+1, n+1): k = (j - i) + j if k < 1 or k >= n: continue if s[i] != s[j] and s[j] != s[k] and s[i] != s[k]: ans -= 1 print(ans) solution()
p03001
s539330791
Accepted
def main(): import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) from collections import Counter, deque #from collections import defaultdict from itertools import combinations, permutations, accumulate, groupby #from itertools import product from bisect import bisect_left,bisect_right import heapq from math import floor, ceil #from operator import itemgetter #inf = 10**17 #mod = 10**9 + 7 w,h,x,y = map(int, input().split()) if x==w/2 and y==h/2: print(w*h/2, 1) else: print(w*h/2, 0) if __name__ == '__main__': main()
p02639
s245588120
Accepted
lst=list(map(int,input().split())) print(15-sum(lst))
p03723
s953920893
Accepted
a, b, c = map(int, input().split()) cnt = 0 while True: if a % 2 == 1: print(cnt) exit() if b % 2 == 1: print(cnt) exit() if c % 2 == 1: print(cnt) exit() if a == b and a == c: print(-1) exit() lis = [] lis.append((b+c)/2) lis.append((a+c)/2) lis.append((a+b)/2) a, b, c = lis cnt += 1
p03012
s953565020
Wrong Answer
N = int(input()) W = list(map(int,input().split())) weight= sum(W) cnt = 0 for i in range(N): if weight <= cnt: print(cnt-weight) exit() weight -= W[i] cnt += W[i]
p02747
s602875083
Accepted
''' Created on 2020/08/20 @author: harurun ''' def main(): import re import sys pin=sys.stdin.readline pout=sys.stdout.write perr=sys.stderr.write S=pin()[:-1] if re.fullmatch(r"(hi)+",S)==None: print("No") return print("Yes") return main()
p02688
s987017021
Wrong Answer
n,k=map(int, input().split()) peoples=[] for i in range(k): candies = input() # リストに追加 tmp = [int(i) for i in list(input().split())] peoples.extend(tmp) # listから重複を削除し print(3-len(set(peoples)))
p02690
s582292706
Accepted
x = int(input()) for i in range(-200,200): for j in range(-200,200): if i ** 5 - j ** 5 == x: print(i,j) quit()
p02795
s856857941
Accepted
h = int(input()) w = int(input()) n = int(input()) high = max(h,w) low = min(h,w) count = 0 ans = 0 for i in range(low): count += high ans += 1 if count >= n: break print(ans)
p03565
s870697523
Accepted
s,t=input(),input();l,m=len(s),len(t) for i in range(l-m+1): if all(c in"?"+d for c,d in zip(s[-i-m:],t)):s=s.replace(*"?a");exit(print(s[:-i-m]+t+s[l-i:])) print("UNRESTORABLE")
p02811
s577816386
Wrong Answer
data = [int(k) for k in input().split()] print(data) takashi = 500 * data[0] if takashi >= data[1]: print('Yes') else: print('No')
p02829
s685580594
Accepted
a = int(input()) b = int(input()) lst = [1, 2, 3] lst.remove(a) lst.remove(b) print(lst[0])
p03254
s274748712
Wrong Answer
N, x = map(int, input().split()) a = list(map(int, input().split())) cnt = 0 while len(a) != 0: next = min(a) a.remove(min(a)) if x < next: break x -= next cnt += 1 cnt = 1 if cnt == 0 else cnt print(cnt if x == 0 else cnt-1)
p03773
s650759472
Accepted
A, B = map(int, input().split()) print((A+B)%24)
p03281
s253750383
Accepted
n = int(input()) if n<3*5*7: ans=0 elif n<3**3*5: ans=1 elif n<3*5*11: ans=2 elif n<3**3*7: ans=3 elif n<3*5*13: ans=4 else: ans=5 print(ans)
p03087
s050906744
Accepted
N,Q = map(int,input().split()) S = input() LR = [] for _ in range(Q): LR.append([int(i) for i in input().split()]) AC_point = [] for n in range(N-1): if S[n] == "A" and S[n+1] == "C": AC_point.append(n+1) import bisect for lr in LR: a = bisect.bisect_left(AC_point,lr[0]) b = bisect.bisect_left(AC_point,lr[1]) print(b-a)
p03680
s445260837
Accepted
import sys n = [int(x) for x in sys.stdin] button = 1 for i in range(n[0]): if button == 2: print(i) break button = n[button] else: print(-1)
p02880
s211358097
Wrong Answer
n = int(input()) for i in range(1,10): for j in range(1,10): if n == i * j: print("Yes") else: print("No")
p02612
s143032991
Accepted
N=int(input()) if N%1000>0: print(1000-N%1000) else: print(0)
p03252
s035017880
Wrong Answer
s = set(input()) t = set(input()) if len(s) != len(t): print('No') else: if len(s&t)==0: print('No') else: print('Yes')
p03479
s565619427
Wrong Answer
X, Y = map(int, input().split()) from math import log2 print(int(log2(Y//X))+1)
p02772
s798451840
Accepted
N=int(input()) A=list(map(int, input().split())) B=[] for i in range (N): if A[i]%2==0: B.append(A[i]) count=0 for j in range(len(B)): if B[j]%3==0 or B[j]%5==0: count=count+1 if count==len(B): print("APPROVED") else: print("DENIED")
p02694
s631170836
Wrong Answer
X = int(input()) count = 0 money = 100 while True: money *= 1.01 count += 1 if money >= X: print(count) break
p02780
s053443944
Wrong Answer
n,k = map(int, input().split()) ps = list(map(int, input().split())) tmp = sum(ps[:k]) max_ps = tmp start = 0 for i in range(1,n-k): tmp = tmp-ps[i-1]+ps[i+k-1] if tmp >= max_ps: max_ps = tmp start = i print(sum([(i*(i+1))/ (2*i) for i in ps[start:start+k]]))
p02767
s915920854
Wrong Answer
N = int(input()) List = list(map(int, input().split())) s = 0 t = 0 for i in range(100): for j in range(N): t += (List[j]-i-1)**2 if s>t: s = t print(t)
p02838
s078045380
Accepted
def main(): N = int(input()) A = list(map(int, input().split())) ans = 0 MOD = 10 ** 9 + 7 for d in range(60): one = 0 zero = 0 for i in range(N): if A[i] & (1 << d): one += 1 else: zero += 1 ans += (2 ** d) * (one * zero) ans %= MOD print(ans) if __name__ == "__main__": main()
p03944
s425255598
Accepted
w,h,n = map(int, input().split()) xya = [list(map(int, input().split())) for _ in range(n)] X = [0,w] Y = [0,h] for x,y,a in xya: if a == 1: X[0] = max(X[0], x) elif a == 2: X[1] = min(X[1], x) elif a == 3: Y[0] = max(Y[0], y) else: Y[1] = min(Y[1], y) if X[0] >= X[1] or Y[0] >= Y[1]: print(0) else: print(abs(X[0]-X[1])*abs(Y[0]-Y[1]))
p03352
s548898793
Wrong Answer
N = int(input()) li = [] for i in range(2,100): for j in range(2,5): li.append(i**j) li.sort() ans = 0 for k in range(len(li)): if (li[k-1]<N)&(li[k]>N): ans = li[k-1] print(ans)
p02993
s607569945
Accepted
S = input() if S[0] == S[1] or S[1] == S[2] or S[2] == S[3]: print("Bad") else: print("Good")
p02706
s449345290
Accepted
N, M = list(map(int, input().split())) A = list(map(int, input().split())) if N - sum(A) >= 0: print(N - sum(A)) else: print(-1)
p03486
s949471799
Wrong Answer
s = list(input()) t = list(input()) s.sort() t.sort(reverse=True) flg = False for i in range(len(s)): if i >= len(t): break if ord(s[i]) > ord(t[i]): break if ord(s[i]) < ord(t[i]): flg = True break if i == len(s)-1: flg = True break print('Yes') if flg else print('No')
p02731
s023358750
Wrong Answer
#!/usr/bin/env python3 import collections import itertools as it import math import numpy as np # A = input() A = int(input()) # A = map(int, input().split()) # A = list(map(int, input().split())) # A = [int(input()) for i in range(N)] # # c = collections.Counter() print(A//3 * A//3 * (A-(A//3)*2))
p02729
s040336775
Wrong Answer
import sys input = sys.stdin.readline N, M = map(int, input().split()) print(N*(N-1) + M*(M-1))
p02630
s116222549
Accepted
N = int(input()) A = list(map(int, input().split())) Q = int(input()) B = [] C = [] for i in range(Q): temp = list(map(int, input().split())) B.append(temp[0]) C.append(temp[1]) d = {} for i in range(N): if(A[i] not in d): d[A[i]] = 1 else: d[A[i]] += 1 total = sum(A) for i in range(Q): if(B[i] in d): num = d[B[i]] total += num*(C[i]-B[i]) d.pop(B[i]) if(C[i] in d): d[C[i]] += num else: d[C[i]] = num print(total)
p02768
s853476661
Accepted
n, a, b = map(int, input().split()) mod = pow(10, 9) + 7 def comb(N, x): X = 1 for i in range(N-x+1, N+1): X = X * i % mod Y = 1 for j in range(1, x+1): Y = Y * j % mod Ym = pow(Y, mod-2, mod) return X * Ym a = comb(n, a) b = comb(n, b) print((pow(2, n, mod) -1 -a -b) % mod)
p03434
s369237065
Accepted
N = int(input()) Ali = list(map(int,input().split())) Ali.sort(reverse = True) AP = BP = 0 for i in range(N): if i%2 == 0: AP += Ali[i] else: BP += Ali[i] print(AP-BP)
p03041
s673656304
Accepted
n,k=map(int,input().split()) a = input() a = list(a) a[k - 1] = a[k-1].lower() a = "".join(a) print(a)
p02696
s949321653
Wrong Answer
a, b, n = map(int, input().split()) ans = int((a * n) / b) - a * int(n / b) print(max(ans, 0))
p02897
s875934850
Accepted
N=int(input()) if N%2==0: print(0.5) else: print((N+1)/2/N)
p02571
s658926086
Accepted
#-*-coding:utf-8-*- import sys def n_gram(target, n): return [ target[idx:idx + n] for idx in range(len(target) - n + 1)] def main(): s = input() t = input() ans_list=[] ans=[] count=0 ans_list=n_gram(s,len(t)) for word in ans_list: for str1,str2 in zip(word,t): if str1==str2: count+=1 ans.append(count) count=0 print(len(t)-max(ans)) if __name__ == "__main__": main()