problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02675
s035736760
Accepted
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) n = readline().rstrip().decode()[::-1] memo = ['2', '4', '5', '7', '9'] memo1 = ['0', '1', '6', '8'] if n[0] in memo: print('hon') elif n[0] in memo1: print('pon') else: print('bon')
p02691
s795114880
Accepted
from collections import defaultdict N = int(input()) A = [0]+list(map(int, input().split())) d1 = defaultdict(int) d2 = defaultdict(int) for i in range(1, N+1): d1[i-A[i]] += 1 d2[i+A[i]] += 1 ans = 0 for k in d1.keys(): ans += d1[k]*d2[k] print(ans)
p02712
s302487641
Wrong Answer
N = int(input()) ans = 0 for i in range(1, N): if i % 3 != 0 and i % 5 != 0: ans += i print(ans)
p02546
s346208580
Accepted
s = input() if s[-1] == 's': print(f'{s}es') else: print(f'{s}s')
p02731
s659201797
Accepted
print((int(input())/3)**3)
p02705
s498528976
Accepted
R = int(input()) print(6.283185307179586*R)
p02683
s717725808
Accepted
n, m, x = map(int, input().split()) CA = [list(map(int, input().split())) for _ in range(n)] # rについて表裏のすべての組み合わせを調べる。 ans = 10 ** 19 for b in range(2 ** n): aa = [0] * m amn = 0 for i in range(n): if (b >> i) & 1: amn += CA[i][0] for k in range(m): aa[k] += CA[i][k + 1] if all(a >= x for a in aa): ans = min(ans, amn) if ans == (10 ** 19): print(-1) else: print(ans)
p03679
s069188897
Wrong Answer
x,a,b=map(int,input().split()) print('delicious' if b-a<0 and b-a<=x else ('safe' if b-a<=x else 'dangerous'))
p03711
s640527239
Accepted
x, y=map(int, input().split()) A=set([1, 3, 5, 7, 8, 10, 12]) B=set([4, 6, 9, 11]) if x in A and y in A: print('Yes') elif x in B and y in B: print('Yes') else: print('No')
p02785
s257972269
Accepted
n, k = map(int, input().split()) h = list(sorted(map(int, input().split()))) x = 0 if n > k: for i in range(n - k): x += h[i] print(x)
p03136
s423222706
Accepted
N=int(input()) L=[int(i) for i in input().split()] long=max(L) #print(long) L.remove(long) if long<sum(L): #print(sum(L)) print('Yes') else: print('No')
p02909
s947755935
Wrong Answer
x=str(input()) print(["Sunny","Cloudy"][x=="Sunny"])
p02621
s714957914
Accepted
a = int(input()) print(a**3 + a**2 + a)
p03693
s868941798
Accepted
# vim: fileencoding=utf-8 def main(): x, y, z = input().split() num = int(x + y + z) if num % 4: print("NO") else: print("YES") if __name__ == "__main__": main()
p02602
s382448975
Accepted
N,K = list(map(int,input().split())) A = list(map(int,input().split())) for i in range(K,N): if A[i]>A[i-K]: print("Yes") else: print("No")
p02924
s644871184
Wrong Answer
N = int(input()) if N == 1: print(0) else: print(int(N * (N - 1) / 2))
p02832
s837096714
Accepted
n=int(input()) a=list(map(int,input().split())) cnt=0 c=1 for i in range(n): if a[i]!=c: cnt+=1 else: c+=1 if cnt==n: print(-1) else: print(cnt)
p02600
s393844107
Wrong Answer
x = int(input()) ans = 8 if 600<=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)
p03433
s912396292
Accepted
n = int(input()) a = int(input()) print("Yes" if a >= n - 500*(n//500) else "No")
p03637
s234105458
Wrong Answer
import math N = int(input()) A = list(map(int,input().split())) l = list() ll = list() lll = list() for i in range(len(A)): if A[i]%4 == 0: l.append(A[i]) if A[i]%2 == 0: ll.append(A[i]) if A[i]%2 != 0: lll.append(A[i]) four = len(l) two = four - len(ll) zero = N-two a = math.floor(N/2) b = A.count(0) if zero <= four and b == 0: print("Yes") elif zero-two <= four: print("Yes") else: print("No")
p03282
s600967226
Accepted
S = list(str(input())) K = int(input()) ind = 0 for s in S: i = int(s) if i == 1: num = pow(i, 5000000000000000) if num + ind >= K: print(i) break else: ind += num else: print(i) break
p03371
s320509347
Wrong Answer
A,B,C,X,Y=map(int,input().split()) if A+B<2*C: ans=A*X+B*Y else: if X<=Y: ans=C*2*X if 2*C<=B: ans+=2*C*(Y-X) else: ans+=B*(Y-X) else: ans=C*2*Y if Y<=X: ans+=2*C*(X-Y) else: ans+=B*(Y-X) print(ans)
p02623
s272458128
Wrong Answer
import itertools n, m, k = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) accA = list(itertools.accumulate(a)) accB = list(itertools.accumulate(b)) cnt = 0 ans = 0 for i in range(len(accA)): for j in range(len(accB)): if k >= accA[i]+accB[j]: cnt = i+j ans = max(cnt, ans) print(ans)
p03323
s055929610
Wrong Answer
x,y=map(int,input().split()) if(x>8 or y>8): print("No") else: print("Yes")
p02916
s941698431
Accepted
#k = int(input()) #s = input() #a, b = map(int, input().split()) #s, t = map(str, input().split()) #l = list(map(int, input().split())) n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) c = list(map(int, input().split())) ans = 0 last = -1 for i in range(n): ans += b[a[i] -1] if (last + 1 == a[i]): ans += c[a[i] -2] last = a[i] print(ans)
p02546
s907640653
Accepted
S=input() print(S+'es' if S[-1]=='s'else S+'s')
p02657
s625039527
Accepted
A, B = map(int, input().split()) print(A*B)
p03860
s210233107
Wrong Answer
s=input() print(s[8])
p03625
s746480260
Wrong Answer
import collections n = int(input()) a = list(map(str,input().split())) c = collections.Counter(a) set_a = set(a) lists = [] for i in set_a: if int(c[i]) >= 2: tmp = int(c[i]) // 2 for j in range(tmp): lists.append(i) lists.sort() lists.reverse() Max = -999999999 if len(lists) > 1: for i in range(len(lists)-1): ans = int(lists[i]) * int(lists[i+1]) if ans > Max: Max = ans else: Max = 0 print(Max)
p02910
s903041294
Accepted
S = input() frag = True c = 0 for i in S: if c%2==0: if i=='L': frag = False if c%2==1: if i=='R': frag = False c+=1 if frag: print("Yes") else: print("No")
p03803
s574967968
Accepted
import sys import bisect read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines n,m = map(int,readline().split()) if n == m: print("Draw") elif n==1 or m == 1: if n ==1: print("Alice") else: print("Bob") else: if n > m: print("Alice") else: print("Bob")
p02833
s241949809
Accepted
n = int(input()) if n%2 == 1: print(0) exit() num = 5 i = 1 ans = 0 while num**i < n: ans += n//num**i//2 i += 1 print(ans)
p02759
s897164350
Wrong Answer
n = int(input()) print((n+2-1)/2)
p03944
s533954220
Accepted
W, H, N = map(int, input().split()) XYA = [list(map(int, input().split())) for _ in range(N)] x_min = max([0] + [xya[0] for xya in XYA if xya[2] == 1]) x_max = min([W] + [xya[0] for xya in XYA if xya[2] == 2]) y_min = max([0] + [xya[1] for xya in XYA if xya[2] == 3]) y_max = min([H] + [xya[1] for xya in XYA if xya[2] == 4]) print(max(x_max - x_min, 0) * max(y_max - y_min, 0))
p03543
s131820803
Accepted
n=list(map(int,input())) if (n[0]==n[1]and n[1]==n[2]) or (n[1]==n[2] and n[2]==n[3]): print("Yes") else: print("No")
p03796
s463070292
Accepted
mod = 10**9 + 7 n = int(input()) ans = 1 for i in range(1, n+1): ans *= i ans %= mod print(ans)
p02705
s180733299
Wrong Answer
R=int(input()) p=3.141516 print(R*p)
p03243
s873402470
Wrong Answer
n=int(input()) if 100<=n<=111: print(111) a=0 for a in range(1,8): if 1+111*a<=n<=111*(a+1): print(111*(a+1))
p02554
s754105415
Accepted
n = int(input()) ALL = (10 ** n) % (10**9 +7) wo_0 = (9 ** n) % (10**9 +7) wo_9 = (9 ** n) % (10**9 +7) wo_0_9 = (8 ** n) % (10**9 +7) ans = (ALL - (wo_0 + wo_9 - wo_0_9)) % (10**9 +7) print(ans)
p02623
s165019156
Accepted
n, m, k = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) t = sum(B) # しゃくとり法 res = 0 j = m for i in range(n + 1): while j > 0 and t > k: j -= 1 t -= B[j] if t > k: break res = max(res, i + j) if i == n: break t += A[i] print(res)
p02817
s420728235
Wrong Answer
a,b = input().split() print(a+b)
p02600
s294664479
Accepted
x = int(input()) if x >= 400 and x <= 599: print('8') if x >= 600 and x <= 799: print('7') if x >= 800 and x <= 999: print('6') if x >= 1000 and x <= 1199: print('5') if x >= 1200 and x <= 1399: print('4') if x >= 1400 and x <= 1599: print('3') if x >= 1600 and x <= 1799: print('2') if x >= 1800 and x <= 1999: print('1')
p02873
s471252550
Accepted
S=input() c=[0]*(len(S) + 1) for i in range(len(S)): if S[i]=="<": c[i+1]=c[i]+1 for j in range(len(S)-1,-1,-1): if S[j]==">": c[j] = max(c[j], c[j+1]+1) print(sum(c))
p02571
s361710125
Accepted
S = input() T = input() max_count = 0 for i in range(len(S)-len(T)+1): count = 0 for j in range(len(T)): if S[i+j] == T[j]: count += 1 max_count = max(max_count, count) print(len(T) - max_count)
p02631
s461143403
Accepted
N = int(input()) A = list(map(int,input().split())) b = 0 C = [] for a in A: b^=a for a in A: C.append(a^b) print(*C)
p03696
s226884193
Accepted
n = int(input()) s = input() l_num, r_num = 0, 0 for i in s: if i == '(': l_num += 1 elif l_num <= 0: r_num += 1 else: l_num -= 1 print('(' * r_num + s + ')' * l_num)
p03607
s004326142
Wrong Answer
n = int(input()) a = [] for i in range(n): a.append(int(input())) a.sort() jud = 1 q = a[0] ans = 0 for i in range(1,n): if(q==a[i]): jud += 1 else: if(jud%2==1): ans += 1 jud = 1 q = a[i] if (jud%2==1)and(jud>2): ans += 1 if(n==1): ans = 1 print(ans)
p04034
s969485843
Accepted
import sys input = lambda : sys.stdin.readline().rstrip() sys.setrecursionlimit(max(1000, 10**9)) write = lambda x: sys.stdout.write(x+"\n") n,m = map(int, input().split()) c = [1]*n r = set([0]) for i in range(m): x,y = map(int, input().split()) x -= 1 y -= 1 if c[x]==1 and x in r: r.remove(x) r.add(y) elif c[x]>=2 and x in r: r.add(y) c[x] -= 1 c[y] += 1 print(len(r))
p03146
s775677464
Accepted
# Python3 (3.4.3) import sys input = sys.stdin.readline # ------------------------------------------------------------- # function # ------------------------------------------------------------- # ------------------------------------------------------------- # main # ------------------------------------------------------------- N = int(input()) ans = 0 s = set() while N not in s: s.add(N) if N%2==0: N //= 2 else: N = N*3+1 ans += 1 print(ans+1)
p02708
s856395064
Accepted
nk = input() nk = nk.split() [n,k] = nk n, k = int(n), int(k) ans = 0 for s in range(k, n + 2): temp = s*(n-s+1) + 1 ans += temp if(ans > 1000000007): ans = ans % 1000000007 print(ans)
p02970
s098409302
Accepted
N, D = map(int, input().split()) d = D*2 + 1 print((N - 1) // d + 1)
p02793
s024863655
Accepted
import fractions N = int(input()) A = list(map(int, input().split())) L = A[0] for i in range(1, N): L = L * A[i] // fractions.gcd(L, A[i]) ans = 0 for i in range(N): ans = (ans + L // A[i]) #% 1000000007 print(ans%1000000007)
p02712
s740844631
Accepted
N = int(input()) count=0 for i in range(1,N+1): if not(i%3==0 or i%5==0): count+=i print(count)
p02556
s853563652
Accepted
import numpy as np a = input() N = int(a) xy = [map(int, input().split()) for _ in range(N)] x, y = np.array([list(i) for i in zip(*xy)]) z = x + y w = x - y ans = max((max(z)-min(z)),(max(w)-min(w))) print(ans)
p02556
s317170537
Accepted
n = int(input()) top1= -10**10 bot1= 10**10 top2= -10**10 bot2= 10**10 for _ in range(n): x,y = map(int, input().split(' ')) tot1= x+y tot2= x-y if tot1> top1: top1= tot1 if tot1< bot1: bot1= tot1 if tot2>top2: top2= tot2 if tot2<bot2: bot2= tot2 print(max(top1-bot1, top2-bot2))
p02912
s708534430
Accepted
import heapq import math N, M = map(int, input().split()) A = list(map(int, input().split())) B = [-A[i] for i in range(N)] heapq.heapify(B) while M: p = heapq.heappop(B) p /= 2 heapq.heappush(B, p) M -= 1 ans = 0 for i in range(N): ans += math.floor(-B[i]) print(ans)
p03486
s310890446
Accepted
s=input() t=input() lis=sorted(list(s)) lit=sorted(list(t),reverse=1) print("Yes" if "".join(lis) < "".join(lit) else "No")
p03323
s033619035
Wrong Answer
a,b = map(int, input().split()) if a<=8 and b<=8: print('Yay') else: print(':(')
p02838
s215652048
Wrong Answer
import numpy as np n = int(input()) mod = 10**9+7 a = np.array(list(map(int,input().split()))) ans = 0 for i in range(60): #aをiビット右にずらす、iは60桁目まで、&1で対象のビットが1のもの以外を0にその数をカウントする。 b = np.count_nonzero(a >>i&1) ans += ((2**i)*(n-b)*b)%mod print(ans)
p02948
s263220848
Accepted
from heapq import heappop, heappush n,m=map(int,input().split()) l=[] for _ in range(n): a,b=map(int,input().split()) if a>m:continue l.append((a,b)) l.sort(reverse=True) q=[] ans=0 for i in range(1,m+1): while l and l[-1][0]<=i: a,b=l.pop() heappush(q,-b) if q: b=-heappop(q) ans+=b print(ans)
p02989
s341364732
Accepted
N=int(input()) d=list(map(int,input().split())) d=sorted(d) print(d[int(N/2)]-d[int((N/2))-1])
p03126
s801639743
Accepted
import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) n, m = map(int, input().split()) fav = set(range(1, m+1)) for _ in range(n): a = set(list(map(int, input().split()))[1:]) fav = fav.intersection(a) print(len(fav))
p03778
s402428538
Accepted
w,a,b=map(int,input().split()) a,b=min(a,b),max(a,b) if b-a-w>=0: print(b-a-w) else: print(0)
p03262
s737785838
Accepted
import fractions n,X=map(int,input().split()) x=list(map(int,input().split())) for i in range(n): x[i]=abs(x[i]-X) ans=10**10 if n==1: print(x[0]) exit() for g in range(1,n): ans=min(ans,fractions.gcd(x[g-1],x[g])) print(ans)
p02910
s203118591
Accepted
s = input() sl = list(s) for i in range(len(sl)): if (i + 1) % 2 == 1: if sl[i] == 'L': print('No') break else: continue else: if sl[i] == 'R': print('No') break else: continue else: print('Yes')
p02783
s592631960
Wrong Answer
h, a = [int(i) for i in input().split()] print(h//a + 1 if h % a > 0 else 0)
p02606
s874489754
Wrong Answer
l,r,d=map(int,input().split()) ans=0 for i in range(l,r+1): if i%2==0: ans+=1 print(ans)
p03943
s610944288
Accepted
a,b,c = map(int,input().split()) if max(a,b,c)==a+b+c-max(a,b,c): print('Yes') else: print('No')
p03698
s501574454
Wrong Answer
w = str(input()) for i in range(len(w)): for j in range(len(w)): if i != j: if w[i] == w[j]: f = True break else: f = False else: f = False print('no' if f else 'yes')
p02957
s862267489
Wrong Answer
a,b = input().split() a =int(a) b = int(b) if (a + b) % 2 ==0: print((a+b)/2) else: print('IMPOSSIBLE')
p03495
s612387224
Accepted
N,K=map(int,input().split()) A=input().split() balls=[int(a) for a in A] answers=[0]*200000 for a in balls: answers[a-1]+=1 list=[a for a in answers if a!=0] newlist=sorted(list) n=len(newlist)-K answer=0 for a in range(n): answer+=newlist[a] print(answer)
p02641
s683601789
Wrong Answer
x,n = list(map(int,input().split())) if n >0 : p = list(map(int,input().split())) #print(x,n) #print(p) #print(max(p)) y = 100 ans = n if n == 0: print(x) else: for i in range(0,101): if i != x: if p.count(i) == 0: #print('i=',i,abs(x-i)) if abs(x-i) < y: ans = i y = abs(x-i) print(ans)
p02552
s163408696
Accepted
x = input() x = int(x) if x == 0: print(1) elif x == 1: print(0)
p03043
s064766326
Accepted
#!python3 def LI(): return list(map(int, input().split())) # input N, K = LI() def p(x): ret = 1 while x < K: ret /= 2 x *= 2 return ret def main(): ans = 0 for i in range(1, N + 1): ans += p(i) ans /= N print(ans) if __name__ == "__main__": main()
p02663
s962689949
Wrong Answer
x = list(map(int, input().split())) h = (x[2] - x[0])*60 m = abs(x[1] - x[3]) ans = max(m+h-x[-1], 0) print(ans)
p03633
s425487913
Wrong Answer
from fractions import gcd n = int(input()) ans = 1 for _ in range(n): t = int(input()) ans *= t/gcd(ans, t) print(int(ans))
p02546
s442019237
Wrong Answer
s = input() if s[-1] == 's': print(s[:-1]+'es') else: print(s+'s')
p03696
s727722223
Wrong Answer
import sys n = int(input()) a = input() s = list(a) right = 0 left = 0 for i in s: if i == "(": right+=1 else: left+=1 for _ in range(max(0,left - right)): sys.stdout.write("(") sys.stdout.write(a) for _ in range(max(0,right - left)): sys.stdout.write(")")
p02773
s753896874
Wrong Answer
N = int(input()) strs = [] dicts = {} for i in range(N): s = input() if dicts.get(s) is not None: dicts[s] += 1 else: dicts[s] = 1 dict_sorted = sorted(dicts.items(), key=lambda x:x[1], reverse=True) i = 0 for s in dict_sorted: if dicts[s[0]] >= i: print(s[0]) i = dicts[s[0]]
p03524
s410376745
Accepted
s=input() d={"a":0,"b":0,"c":0} for m in s: d[m]+=1 if max(d["a"],d["b"],d["c"])-min(d["a"],d["b"],d["c"])>1: print("NO") else: print("YES")
p02899
s691277552
Accepted
n=int (input()) a= list(map(int, input().strip().split())) b=[0]*n for i in range(n): b[a[i]-1]=i+1 print(*b)
p02689
s347145083
Accepted
n,m = map(int,input().split()) h = list(map(int,input().split())) l = [1]*n for i in range(m): a,b = map(int,input().split()) a-=1 b-=1 if h[a] <= h[b]: l[a] = 0 if h[b] <= h[a]: l[b] = 0 ans = sum(l) print(ans)
p02848
s765791259
Accepted
from string import ascii_uppercase as upper n = int(input()) s = input() t = '' for i in range(len(s)): t += upper[(upper.find(s[i]) + n) % 26] print(t)
p02627
s858934864
Wrong Answer
a = input() if 'A' <= a and a <= 'Z': print('A') elif 'a' <= a and a <= 'z': print(a)
p03471
s784624920
Accepted
n,c=map(int,input().split()) x,y,z=-1,-1,-1 for i in range(n+1): for j in range(n+1-i): if 10000*i+5000*j+(n-i-j)*1000==c: x,y,z=i,j,n-i-j print(x,y,z) exit() print(x,y,z)
p02595
s965434736
Wrong Answer
N, D = list(map(int, input().split())) count = 0 for _ in range(N): X, Y = list(map(int, input().split())) if (X * X + Y * Y) ** 2 <= D ** 2 : count += 1 print(count)
p04029
s257569919
Accepted
def total(n): return int(1/2 * n * (n + 1)) n = int(input()) print(total(n))
p02744
s875885851
Wrong Answer
N=int(input()) alp="abcdefghij" S=[""for i in range(N)] def gen(cnt,rem): if rem==0: print("".join(S)) else: for i in range(min(N,cnt+2)): S[N-rem]=alp[i] gen(i,rem-1) S[0]="a" gen(0,N-1)
p02661
s056989598
Accepted
def med(l): t = len(l) if t%2: return l[t//2] else: return (l[t//2]+l[t//2-1])/2 n = int(input()) a = [] b = [] for i in range(n): x,y = map(int,input().split()) a+=[x] b+=[y] a.sort() b.sort() if n%2==0: print(int((med(b)-med(a))*2)+1) else: print(med(b)-med(a)+1)
p02766
s573094373
Accepted
def Base_10_to_n(X, n): if (int(X/n)): return Base_10_to_n(int(X/n), n)+str(X%n) return str(X%n) n, k = map(int, input().split()) if k == 10: print(len(str(n))) else: print(len(Base_10_to_n(n,k)))
p03657
s198584468
Accepted
# ABC 067: A – Sharing Cookies a, b = [int(s) for s in input().split()] print('Possible' if a % 3 == 0 or b % 3 == 0 or (a + b) % 3 == 0 else 'Impossible')
p02665
s250824485
Wrong Answer
N = int(input()) l = [int(x) for x in input().split()] ans = 1 wa = sum(l) kosuu = 1 - l[0] flag = 0 for i in range(1,N): if flag == 0: kosuu = kosuu * 2 if kosuu >= wa: flag = 1 kosuu = wa ans += kosuu kosuu = kosuu - l[i] wa = wa-l[i] if kosuu <= 0: print(-1) exit() if kosuu*2 < l[N]: print(-1) else: print(ans+l[N])
p03469
s330275210
Accepted
print(input().replace('2017','2018'))
p03086
s095810341
Accepted
s = input() ans = 0 cache = 0 for c in s: if c in ["A", "C", "G", "T"]: cache += 1 else: if cache > ans: ans = cache cache = 0 if cache > ans: ans = cache print(ans)
p03475
s210875631
Accepted
import sys readline = sys.stdin.readline N = int(readline()) CSF = [] for i in range(N-1): CSF.append(tuple(map(int, readline().split()))) for i in range(N): time = 0 for c, s, f in CSF[i:N-1]: if time < s: time = s else: time = (time+f-1)//f*f time += c print(time)
p02765
s955389853
Accepted
#from collections import Counter #= int(input()) #= map(int, input().split()) N, R = map(int, input().split()) if N >= 10: print(R) else: R += 100 * (10 - N) print(R)
p03407
s802267670
Accepted
A,B,C=map(int,input().split()) print('Yes' if A+B>=C else 'No')
p03379
s735587745
Accepted
#51 C - Many Medians N = int(input()) X = list(map(int,input().split())) Xsrt = sorted(X,reverse = False) XL = set(Xsrt[:N//2]) XR = set(Xsrt[N//2:]) ans = [] for x in X: if x in XR: ans.append(Xsrt[N//2-1]) elif x in XL: ans.append(Xsrt[N//2]) for a in ans: print(a)
p02555
s071428026
Accepted
S = int(input()) mod = 10 ** 9 + 7 X = [1] * S for i in range(1, S): X[i] = X[i - 1] * i % mod ans = 0 for i in range(1, S // 3 + 1): ans += X[S - 2 * i - 1] * pow(X[i - 1] * X[S - 3 * i] % mod, mod - 2, mod) % mod ans %= mod print(ans)
p03785
s823354106
Accepted
# A - Airport Bus # https://atcoder.jp/contests/agc011/tasks/agc011_a n, c, k = map(int, input().split()) T = [int(input()) for _ in range(n)] T.sort() ans = 1 cnt = 0 st = T[0] for t in T: cnt += 1 if t - st > k or cnt > c: ans += 1 st = t cnt = 1 print(ans)