problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02983
s383310321
Accepted
def LI(): return list(map(int, input().split())) L, R = LI() ans = 2020 for i in range(L, R+1): for j in range(i+1, R+1): y = (i*j) % 2019 ans = min(ans, y) if ans == 0: break if ans == 0: break print(ans)
p03261
s851924189
Wrong Answer
n = int(input()) w = list(input() for i in range(n)) rule = "No" if len(w) == len(set(w)): rule = "Yes" else: rule = "No" print(rule) exit() c = 0 for i in range(1,n): if w[i-1][-1] == w[i][0]: c += 1 continue if c == n-1: rule = "Yes" else: print("No") print(rule)
p02747
s425811513
Accepted
S = input() if S == "hi" or S == "hihi" or S == "hihihi" or S == "hihihihi" or S == "hihihihihi": print("Yes") else: print("No")
p02725
s836377908
Wrong Answer
_in = list(map(int, input().split())) k = _in[0] n = _in[1] p = 0 _i = list(map(int, input().split())) dis = 0 mdis = k - _i[n-1] + _i[0] for i in range(1,n-2): dis = _i[i+1]- _i[i] if dis>mdis: mdis = dis print(k-mdis)
p02578
s151149132
Accepted
if __name__ == "__main__": n = int(input()) ai = list(map(int, input().split())) li = [] for i in range(n - 1): if ai[i] > ai[i + 1]: li.append(ai[i] - ai[i + 1]) ai[i+1]=ai[i] else: pass print(sum(li))
p02724
s207269572
Accepted
X = int(input()) print((X // 500) * 1000 + ((X % 500) // 5) * 5)
p03329
s873525516
Accepted
n=int(input()) l=[1,6,36,6**3,6**4,6**5,6**6,9,9**2,9**3,9**4,9**5] l.sort(reverse=True) dp=[float("inf")]*1000000 dp[0]=0 for i in range(1,n+1): for j in l: if i-j>=0: dp[i]=min(dp[i],dp[i-j]+1) print(dp[n])
p02814
s864183863
Accepted
import fractions def lcm(a, b): return a * b // fractions.gcd(a, b) def div_count_by_2(x): count = 0 while x % 2 == 0: count += 1 x //= 2 return count n, m = map(int, input().split()) A = list(map(int, input().split())) num = A[0] count = div_count_by_2(num) for a in A: if count == div_count_by_2(a): continue else: print(0) exit() x = A[0]//2 for a in A: x = lcm(x, a//2) ans = m//x - m//(2*x) print(ans)
p04034
s058980799
Accepted
n,m=map(int,input().split()) xy=[] for _ in range(m): x,y=map(int,input().split()) xy.append([x,y]) ball=[1]*n red=[0]*n red[0]+=1 for i in range(m): if red[xy[i][0]-1]>=1: if ball[xy[i][0]-1]==1: red[xy[i][0]-1]=0 red[xy[i][1]-1]+=1 ball[xy[i][0]-1]-=1 ball[xy[i][1]-1]+=1 ans=len(red)-red.count(0) print(ans)
p03137
s481490075
Accepted
n,m = map(int,input().split()) x = list(map(int,input().split())) if n >= m : print(0) else: y = [0] * (m-1) x.sort() for i in range(1,m): y[i-1] = abs(x[i] - x[i-1]) y.sort(reverse=True) print(sum(y[n-1:]))
p03345
s327702602
Accepted
A,B,C,K=map(int,input().split()) if K%2==0: ans = A-B else: ans = B-A if abs(ans) > 10**18: print('Unfair') else: print(ans)
p03767
s378214488
Accepted
N=int(input()) t = list(map(int,input().split())) newLi = sorted(t, reverse=True) ans = 0 for i in range(N): ans += newLi[i * 2 + 1] print(ans)
p03478
s146010171
Accepted
import sys input = lambda: sys.stdin.readline().strip() def main(): N, A, B = map(int, input().split()) all_sum = 0 for i in range(1,N+1): keta_sum = sum(list(map(int, str(i)))) if keta_sum >= A and keta_sum <= B: all_sum += i print(all_sum) main()
p03861
s846926525
Wrong Answer
a,b,x = [int(i) for i in input().split()] N = int(b/x) - int(a/x) + 1 print(int(N))
p02631
s957718071
Wrong Answer
n = int(input()) a = [bin(int(i)) for i in input().split(" ")] max_len = len(str(max(a))[2:]) a = [str(i)[2:].zfill(max_len) for i in a] count_list = [] for l in range(max_len): count_list.append(sum([int(one[l]) for one in a])) answer_list = [] for k in range(n): string = "" for l in range(max_len): if (count_list[l] - int(a[k][l]))%2==0: string+="0" else: string+="1" answer_list.append(str(int("0b" + string, 0))) print(" ".join(answer_list))
p02989
s014239524
Accepted
from collections import Counter,defaultdict,deque from heapq import heappop,heappush,heapify import sys,bisect,math,itertools,fractions,pprint sys.setrecursionlimit(10**8) mod = 10**9+7 INF = float('inf') def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readline().split())) n = inp() a = sorted(inpl()) print(max(0, a[n//2]-a[n//2-1]))
p02554
s163906520
Wrong Answer
import sys sys.setrecursionlimit(250000) from scipy.special import comb # a = comb(n, r) def main(): # a,b,c,d = map(int, input().split()) n = int(input()) # temp = (10 ** 9 + 7) # sum = 0 # if n >= 2: # for i in range(2, n+1): # a = int(comb(i, 2)) * 2 # a = (a * 8**(i-2)) % temp # sum = sum + a # else: # print(0) print(10**n - 9**n*2 + 8**n % (10 ** 9 + 7)) main()
p03329
s037098020
Wrong Answer
n=int(input()) l=[1,6,36,6**4,6**5,6**6,9,9**2,9**3,9**4,9**5] l.sort(reverse=True) dp=[float("inf")]*1000000 dp[0]=0 for i in range(1,n+1): for j in l: if i-j>=0: dp[i]=min(dp[i],dp[i-j]+1) print(dp[n])
p02900
s363927681
Wrong Answer
import sys input=sys.stdin.readline import math A,B = (int(x) for x in input().rstrip('\n').split()) c = math.gcd(A,B) if c==1: print(1) else: res = 1 d = math.floor(math.sqrt(c)) for i in range(2,d+2): if c%i==0: res += 1 while c%i==0: c = c//i if res == 1: res += 1 print(res)
p02677
s635700234
Accepted
import math A, B, H, M = map(int, input().split()) A_ang = (60*H+M)*math.pi/ 360 B_ang = M*math.pi / 30 X_A = A*math.sin(A_ang) Y_A = A*math.cos(A_ang) X_B = B*math.sin(B_ang) Y_B = B*math.cos(B_ang) X_D = X_A - X_B Y_D = Y_A - Y_B ans = math.sqrt(X_D*X_D + Y_D*Y_D) print(ans)
p02813
s635829149
Accepted
import itertools n = int(input()) L = tuple((map(int,input().split()))) M = tuple(map(int,input().split())) a = 0 b = 0 K = [i for i in range(1,n+1)] PER = list(itertools.permutations(K)) for i in range(len(PER)): if PER[i] == L: a = i if PER[i] == M: b = i print(abs(a-b))
p02647
s352291246
Wrong Answer
n,k=map(int,input().split()) a=list(map(int,input().split())) for i in range(k): b=[0]*n cnt=0 for j in range(n): if a[j]>=max(n-j,j): cnt+=1 if cnt==n: for j in range(n): a[j]=(k-i)*n break for j in range(n): for m in range(j-a[j],j+a[j]+1): if 0<=m<=n-1: b[m]=b[m]+1 a=b for i in a: print(i,end=' ')
p03696
s558134716
Accepted
from collections import deque def main(): n = int(input()) s = input() left = 0 stack = deque([]) for ss in s: if ss == "(": stack.append("(") elif not stack: left += 1 else: stack.pop() print(left * "(" + s + len(stack) * ")") if __name__ == '__main__': main()
p03854
s904352639
Accepted
import re s = input() m = re.fullmatch(r"(dreamer|dream|erase|eraser)+", s) if m: print("YES") else: print("NO")
p02818
s043393212
Accepted
a,b,k=map(int,input().split()) print(a-k,b) if a>k else print(0,b-(k-a)) if a+b>k else print(0,0)
p04044
s105574583
Wrong Answer
#!/usr/bin/env python3
p03030
s115927558
Accepted
N = int(input()) sp = [list(input().split())+[i] for i in range(N)] for i in range(N): sp[i][1]=-int(sp[i][1]) sp.sort() for _,_,i in sp: print(i+1)
p02547
s849109895
Accepted
n=int(input()) ans=0 c=True d=[] for i in range(n): a,b=map(int,input().split()) if a==b: d.append(i) if len(d)<3: print("No") else: j=0 for i in range(1,len(d)-1): if d[i]-d[i-1]==1 and d[i+1]-d[i]==1: print("Yes") c=False break if c==True: print("No")
p03493
s370519859
Accepted
print(input().count("1"))
p02993
s446673900
Accepted
S=input() if S[0]==S[1] or S[1]==S[2] or S[2]==S[3]: print('Bad') else: print("Good")
p03487
s750072508
Accepted
from collections import Counter n = int(input()) a = list(map(int, input().split())) c = Counter(a) ans = 0 for k, v in c.items(): if k > v: ans += v elif k < v: ans += v - k print(ans)
p02696
s352204849
Wrong Answer
import math a, b, n = map(int, input().split()) if (a - 1) * b <= a * n: print(a - 1) exit() ans = math.floor(a * n / b) print(ans)
p03351
s526387954
Wrong Answer
a, b, c, d = map(int, input().split()) AB = abs(a - b) BC = abs(b - c) AC = abs(a - c) if AB <= d and BC <= d: print("Yes") elif AC <= d: print("YES") else: print("No")
p02767
s368934300
Accepted
N=int(input()) X=list(map(int,input().split())) l=len(X) s=10**10 for i in range(min(X),max(X)+1): x=[] for j in range(l): x.append((X[j]-i)**2) if s>sum(x): s=sum(x) print(s)
p02802
s775848504
Wrong Answer
N,M = map(int,input().split()) arr = [] pre_idx = '-1' pre_s = 'start' cnt = 0 errors = 0 ans = 0 for i in range(M): idx,s = input().split() arr.append([int(idx),s]) arr = sorted(arr) flag = False for idx,s in arr: if pre_idx != idx: cnt = 0 flag = False if flag: continue else: if s=='WA': cnt += 1 else: errors += cnt ans += 1 flag = True pre_idx = idx pre_s = s print(ans,errors)
p02742
s713048270
Wrong Answer
import math h,w = map(int, input().split()) a = math.ceil(h*w/2) print(a)
p02772
s915664882
Wrong Answer
import sys N=int(input()) A=list(map(int,input().split())) flag=True for i in range(N): if A[i]%2==0: if A[i]%3!=0: flag=False elif A[i]%5!=0: flag=False if flag==True: print('APPROVED') else: print('DENIED')
p02793
s471448351
Accepted
import sys input = sys.stdin.readline import math def main(): big = 10 ** 9 + 7 N = int(input()) A = list(map(int, input().split())) num = A[0] for i in range(1, N): num = num * A[i] // math.gcd(num, A[i]) res = 0 for a in A: res += num // a print(res % big) if __name__ == '__main__': main()
p03377
s819411813
Accepted
a,b,x=map(int,input().split()) if a+b>=x and a<=x: print('YES') else: print('NO')
p03971
s566357567
Accepted
N, A, B = map(int, input().split()) S = input() #A = list(map(lambda x: int(x)*(-1), input().split())) #A = [int(input()) for i in range(N)] #C = [list(map(int, input().split())) for i in range()] def gcd(a, b): while b: a, b = b, a % b return a ab = A+B b = B for s in S: if s == 'a' and ab > 0: print('Yes') ab -= 1 elif s == 'b' and ab > 0 and b > 0: print('Yes') ab -= 1 b -= 1 else: print('No')
p02642
s306653203
Accepted
n = int(input()) A = list(map(int,input().split())) A.sort() # print(A) multiple = [0]*(A[-1]+1) for i in range(n): now = A[i] while(now <= A[-1]): multiple[now] += 1 now += A[i] ans = 0 for i in range(n): if(multiple[A[i]] == 1): ans += 1 # print(multiple) print(ans)
p03281
s903614097
Wrong Answer
import math n = int(input()) ans = 0 for i in range(105, n+1, 2): cnt = 0 for j in range(2, int(math.sqrt(n))): if i % j == 0: cnt += 1 if cnt == 3: ans += 1 print(ans)
p03284
s898477805
Wrong Answer
N, K = map(int, input().split()) print(N - N // K * K)
p02924
s845739212
Accepted
N = int(input()) print(N*(N-1)//2)
p02554
s215782424
Accepted
N = int(input()) S = 0 if N == 1: print('0') else: S0 = 10**N - 9**N S9 = 10**N - 9**N S09 = 8**N S = S0 + S9 + S09 - 10**N S = S % (10**9 + 7) print(S)
p02731
s807911602
Accepted
L = float(input()) V = L**3 / 27 print(V)
p03804
s392553398
Wrong Answer
import sys N, M = map(int, input().split()) A = [list(sys.stdin.readline().strip()) for _ in range(N)] B = [list(sys.stdin.readline().strip()) for _ in range(M)] def check(y, x): for i in range(y, y + M): if A[i][x:x + M] != B[i - y]: return False return True for i in range(N - M): for j in range(N - M): if A[i][j] == B[0][0]: if check(i, j): print("Yes") exit() print("No")
p02831
s729450200
Wrong Answer
import sys import math A,B=map(int,input().split()) if A<B: A,B=B,A if B%A==0: print(A) sys.exit() L=[] for i in range(1,math.ceil(A/2)): if A%i==0 and B%i==0: L.append(i) print(int((A*B)/L[-1]))
p03998
s718314491
Accepted
#045b from collections import deque card = dict() card["a"] = deque(input()) card["b"] = deque(input()) card["c"] = deque(input()) #print(card) next_person = card["a"].popleft() while True: #print(next_person,card) if len(card[next_person]) == 0: print(next_person.upper()) break else: next_person = card[next_person].popleft()
p02676
s811954520
Accepted
# B - ... (Triple Dots) def main(): K = int(input()) S = input().rstrip() print(S if len(S) <= K else S[:K] + "...") if __name__ == "__main__": main()
p02570
s105675646
Accepted
D,T,S = map(int,input().split()) if D > T*S : print("No") else: print("Yes")
p03360
s381255771
Accepted
a,b,c=sorted(map(int,input().split())) print(a+b+pow(2,int(input()) )*c )
p03814
s021503332
Accepted
s = input() for i in range(len(s)): if s[i] == 'A': a = i break for i in range(-1,-len(s),-1): if s[i] == 'Z': b = len(s) + i break print(b-a+1)
p02647
s810230391
Accepted
import sys input = sys.stdin.readline N, K = map(int, input().split()) A = list(map(int, input().split())) for _ in range(K): Imos = [0]*(N+1) for i, a in enumerate(A): Imos[max(0, i-a)] += 1 Imos[min(N, i+a+1)] -= 1 B = [0]*(N) b = 0 for i in range(N): b += Imos[i] B[i] = b if A == B: break A = B print(*A)
p03136
s322729594
Wrong Answer
n=int(input()) l=list(map(int,input().split())) l_max=max(l) l_other=[i for i in l if i!=l_max] if l_max<sum(l_other): print("Yes") else: print("No")
p04045
s639383998
Wrong Answer
n,k=map(int,input().split()) d=input().split() ans=0 flg=False for i in range(n,10*n+1): for j in d: if j in str(i): break flg=True if flg: ans=i break print(ans)
p03324
s267464427
Wrong Answer
n,d = list(map(int,input().split())) print(100**n * d)
p03281
s028060085
Accepted
def make_divisors(n): divisors = [] for i in range(1, int(n**0.5)+1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n//i) return divisors n=int(input()) c=0 for i in range(1,n+1,2): a=make_divisors(i) if len(a)==8: c+=1 print(c)
p03126
s651753638
Wrong Answer
n, m = map(int, input().split()) k = [] for i in range(n): k.append(list(map(int, input().split()))) k[i].pop(0) ans = 0 cnt = 0 for i in k: for j in i: if j in i: cnt += 1 if cnt == n: ans += 1 cnt = 0 if n == 1: print(len(k[0])) exit(0) print(ans)
p02645
s808844523
Accepted
S = input() nik = S[0:3] print(nik)
p02924
s008198024
Accepted
N = int(input()) ans = ((1+N-1)*(N-1))//2 print(ans)
p02726
s516573511
Wrong Answer
N, X, Y = map(int, input().split()) ans = [0] * (N - 1) for i in range(1, N + 1, 1): for j in range(i + 1, N + 1, 1): tmp = min( abs(j - i), abs(X - i) + 1 + abs(j - Y), abs(X - j) + 1 + abs(i - Y) # このパターンは ) ans[tmp - 1] += 1 for a in ans: print(ans)
p02924
s431802912
Wrong Answer
n = int(input()) n = n-1 s = (n/2)*((2*1)+(n-1)) print(int(s))
p02879
s563594785
Accepted
a,b=map(int,input().split()) print(a*b if 1<=a<=9 and 1<=b<=9 else "-1")
p02842
s246289057
Accepted
import math ans = -1 n = int(input()) for i in range(1, n+1): if math.floor(i * 1.08) == n: ans = i break print(ans if ans != -1 else ":(")
p03012
s159962443
Accepted
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 def main(): N, *W = map(int, read().split()) ans = INF for t in range(1, N): ans = min(ans, abs(sum(W[:t]) - sum(W[t:]))) print(ans) return if __name__ == '__main__': main()
p02556
s868657095
Wrong Answer
num_inputs = int(input()) max_pair = 0 for i in range(0, num_inputs): pair = input().split(" ") curr_x = int(pair[0]) curr_y = int(pair[1]) if i == 0: min_pair = curr_x + curr_y if (curr_x + curr_y) >= max_pair: max_pair = curr_x + curr_y elif (curr_x + curr_y) <= min_pair: min_pair = (curr_x + curr_y) print(min_pair, max_pair) print(max_pair-min_pair)
p02552
s260894199
Accepted
print(0 if int(input()) == 1 else 1)
p02684
s822056562
Wrong Answer
n,k = map(int,input().split()) l = list(map(int,input().split())) position = 1 town = '' stayed = [1] stayed_c = [0]*n for i in range(n): position = l[position-1] if not position in stayed: stayed.append(position) stayed_c[position-1] = i+1 else: c = i+1 - stayed_c[position-1] g = stayed_c[position-1] town = position break m = (k -g) % c position = town for i in range(m): position = l[position-1] print(position)
p02819
s174725691
Wrong Answer
import math X = int(input()) def prime(n): if n == 1: return False for k in range(2, int(math.sqrt(n)) + 1): if n % k == 0: return False return True Bool = False p = X while not(Bool): Bool = prime(p) p += 1 print(p + 1)
p04044
s779567423
Accepted
# -*- coding: utf-8 -*- n, l = map(int,input().split()) s = [] for i in range(n): s.append(str(input())) s.sort() print(''.join(s))
p03067
s408133382
Accepted
a, b, c = map(int, input().split()) print('Yes' if a < c < b or b < c < a else 'No')
p03136
s237712255
Accepted
N = int(input()) L = list(map(int,input().split())) if 2*max(L)<sum(L): print("Yes") else: print("No")
p02598
s243177414
Wrong Answer
n,k=map(int,input().split()) a=list(map(int,input().split())) if k==0: print(max(a)) else: ans=0 for i in a: d=-(-k*i//sum(a)) if d>0: ans=max(ans,-(-i//(d+1))) else: ans=max(ans,i) print(ans)
p02694
s739793552
Accepted
X = int(input()) tmp = 100 cnt = 0 while tmp < X: tmp = int(tmp * 1.01) cnt += 1 print(cnt)
p02576
s833998576
Accepted
import math [N, X, T] = input().split() A = math.ceil(int(N)/int(X)) ans = A*int(T) print(ans)
p02732
s734981293
Accepted
def resolve(): import collections N = int(input()) A_list = [int(item) for item in input().split()] origin_dict = collections.Counter(A_list) twopair_in_N = 0 for i in origin_dict.values(): twopair_in_N += i*(i-1)//2 for j in range(N): deff = origin_dict[A_list[j]] -1 print(twopair_in_N - deff) if __name__ == "__main__": resolve()
p03371
s346997717
Wrong Answer
A,B,C,X,Y = map(int, input().split()) ans = X*A + Y*B for i in range(max(X,Y)+1): C = 2*C*i + max(0,X-i)*A + max(0,Y-i)*B ans = min(ans, C) print(ans)
p03327
s399599914
Accepted
N = int(input()) if N <= 999: print('ABC') elif N <= 1998: print('ABD')
p04045
s438387568
Accepted
import sys N, _ = map(int, input().split()) D = input().split() answer = sys.maxsize for x in range(N, 100000): s = str(x) if all([y not in s for y in D]): answer = min(answer, x) print(answer)
p03625
s388077322
Wrong Answer
import collections n=int(input()) a=list(map(int,input().split())) c=collections.Counter(a) x,y=0,0 b=list(set(a))[::-1] for i in b: if c[i]>3 and x==y==0: print(i**2) exit() if c[i]>1: y=i if x>0 and y==0 else y x=i if x==0 else x if x*y>0: print(x*y) exit() print(x*y)
p02772
s852350046
Accepted
n = int(input()) aa = [int(x) for x in input().split()] def ok(x): return x % 2 == 1 or (x % 3 == 0 or x % 5 == 0) if all(ok(x) for x in aa): print('APPROVED') else: print('DENIED')
p02629
s751478322
Accepted
n = int(input()) ans="" while(n): n-=1 ans += chr(ord('a')+(n%26)) n = n//26 print(ans[::-1])
p02548
s454677099
Accepted
N = int(input()) ans = 0 for a in range(1,N): ans += (N-1)//a print(ans)
p02765
s137876935
Wrong Answer
a=input().split() nm=[] for i in range(2): b=int(a[i]) nm.append(b) if nm[0]<9: nm[1]+=(100*(10-nm[0])) print(nm[1])
p03379
s194980249
Accepted
n=int(input()) x=list(map(int,input().split())) for i in range(n): x[i] = [x[i], i] x.sort(key=lambda x:x[0]) for i in range(n): if i < n//2: x[i] += [x[n//2][0]] else: x[i] += [x[n//2-1][0]] # x[i] = [value, init_index, b_i] x.sort(key=lambda x:x[1]) for i in range(n): print(x[i][2])
p02726
s561411129
Wrong Answer
n, x, y = map(int, input().split()) net1 = list(range(1,n+1)) net2 = list(range(1,x+1)) + list(range(y,n+1)) for a in range(1,n): lisa = [] seta = set() for i in range(len(net1)-a): lisa.append(net1[i:i+a+1]) for i in range(len(net2)-a): lisa.append(net2[i:i+a+1]) for l in lisa: seta.add(tuple(l)) print(len(seta))
p03289
s290938704
Accepted
s = input() if s[0] == "A" and "C" in s[2:-1] and s[1:].replace("C","",1).islower(): print("AC") else: print("WA")
p02811
s340316021
Accepted
k, x = map(int, input().split()) if (500 * k) >= x: print('Yes') else: print('No')
p02696
s140596686
Accepted
A, B, N = map(int, input().split()) print(A*min(B-1, N)//B)
p03730
s309009510
Accepted
import sys input = sys.stdin.readline A, B, C = map(int, input().split(' ')) ans = 'NO' for i in range(1, B+1): if i * A % B == C: ans = 'YES' print(ans)
p03012
s388606282
Accepted
n = int(input()) lisw = list(map(int,input().split())) total = 100000000 for i in range(1,n): total = min(total,abs(sum(lisw[:i])-sum(lisw[i:]))) print(total)
p03087
s909346581
Accepted
#!/usr/bin/env python3 n, q = list(map(int, input().split())) s = list(str(input())) count = [0] for i in range(1, len(s)): if s[i-1]+s[i] == "AC": count.append(count[i-1]+1) else: count.append(count[i-1]) # print(count) for _ in range(q): l, r = list(map(int, input().split())) print(count[r-1]-count[l-1])
p02947
s999906336
Accepted
n = int(input()) s = [] for i in range(n): x = list(str(input())) x.sort() s.append(''.join(x)) s.sort() count = 0 ans = 0 import math def comb(n, r): return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)) import math for i in range(n-1): if s[i] == s[i+1]: count += 1 if i == n-2: ans += comb(count+1,2) else: if count != 0: ans += comb(count+1,2) count = 0 print(ans)
p03487
s986774963
Wrong Answer
from collections import Counter n = int(input()) a = list(map(int,input().split())) cnt = Counter(a) ans = 0 for i in range(len(cnt)): dif = abs(cnt.most_common()[i][0] - cnt.most_common()[i][1]) delete = cnt.most_common()[i][1] ans += min(dif ,delete) print(ans)
p03785
s840579628
Wrong Answer
n,c,k = map(int,input().split()) ab = [] for _ in range(n): t=int(input()) ab.append(t) ab.sort() bus = 1 bustime = ab[0] + k customer = 1 for i in range(1,n): if customer < c and ab[i] <= bustime: customer += 1 if customer == c: bustime = ab[i+1]+k customer = 0 bus += 1 elif bustime < ab[i]: bustime = ab[i]+k customer = 1 bus += 1 print(bus)
p02631
s295071550
Wrong Answer
N = int(input()) a = list(map(int,input().split())) tmp = 0 for i in a: tmp ^= i ans = a[:] for i in range(N): ans[i] ^= tmp print(ans)
p02708
s001643828
Wrong Answer
n,k = map(int,input().split()) if(k >= n): print(1) else: t = 0 for i in range(k,n+2): d = n - i s1 = i * (i - 1) // 2 s2 = n * (n + 1) // 2 - d * (d + 1) // 2 t += s2 - s1 + 1 t %= 10**9+7 print(t)
p02630
s806356138
Accepted
n = int(input()) A = list(map(int,input().split())) q = int(input()) total = sum(A) l = [0 for i in range(10**5+1)] for _ in range(n): l[A[_]] += 1 for i in range(q): b, c = map(int,input().split()) total += (c * l[b]) total -= (b * l[b]) print(total) l[c] += l[b] l[b] = 0
p03548
s984514510
Accepted
import math X,Y,Z=map(int,input().split()) ans=0 ans=math.floor((X-Z)/(Y+Z)) print(ans)