Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import heapq
 
n= int(input())
s=[input() for i in range(n)]
 
ss = list(set(s))
 
if(len(s)==len(ss)):
    s.sort()
    for i in s:
        print(i)
 
else:
    li = []
    heapq.heapify(li)
    for i in ss:
        ans = s.count(i)
        heapq.heappush(li,(-ans,i))
    
    for i in range(len(ss)):
        amount,st = heapq.heappop(li)
        if(i==0):
            print(st)
            ri=amount
            continue
        
        if(ri==amount):
            print(st)
        else:
            break

Fixed submission:
import collections

n= int(input())
s=[input() for i in range(n)]

li = collections.Counter(s)
ma= max(li.values())

ans= [i for i,j in li.items() if(j==ma)]
print("\n".join(sorted(ans)))

Buggy python submission (verdict: Time Limit Exceeded):
import heapq

n= int(input())
s=[input() for i in range(n)]

ss = list(set(s))

if(len(s)==len(ss)):
    s.sort()
    for i in s:
        print(i)

else:
    li = []
    heapq.heapify(li)
    for i in ss:
        ans = s.count(i)
        heapq.heappush(li,(-ans,i))
    
    for i in range(len(ss)):
        amount,st = heapq.heappop(li)
        if(i==0):
            print(st)
            ri=amount
            continue
        
        if(ri==amount):
            print(st)
        else:
            break

Fixed submission:
import collections

n= int(input())
s=[input() for i in range(n)]

li = collections.Counter(s)
ma= max(li.values())

ans= [i for i,j in li.items() if(j==ma)]
print("\n".join(sorted(ans)))

Buggy python submission (verdict: Time Limit Exceeded):
import heapq

n= int(input())
s=[input() for i in range(n)]

ss = list(set(s))
ss.sort()
li = []
heapq.heapify(li)
for i in ss:
    ans = s.count(i)
    heapq.heappush(li,(-ans,i))

for i in range(len(ss)):
    amount,st = heapq.heappop(li)
    if(i==0):
        print(st)
        ri=amount
        continue
    
    if(ri==amount):
        print(st)
    else:
        break

Fixed submission:
import collections

n= int(input())
s=[input() for i in range(n)]

li = collections.Counter(s)
ma= max(li.values())

ans= [i for i,j in li.items() if(j==ma)]
print("\n".join(sorted(ans)))

Buggy python submission (verdict: Time Limit Exceeded):
n= int(input())
s=[input() for i in range(n)]

ss = set(s)
ans = 0
ma = 0
li = []
for i in ss:
    ans = s.count(i)
    if(ans==ma):
        li.append(i)
    if(ans>ma):
        ma = ans
        li = [i]

li.sort()


if(len(li)==1):
    print(li[0])
else:
    for i in li:
        print(i)

Fixed submission:
import collections

n= int(input())
s=[input() for i in range(n)]

li = collections.Counter(s)
ma= max(li.values())

ans= [i for i,j in li.items() if(j==ma)]
print("\n".join(sorted(ans)))
Buggy python submission (verdict: Time Limit Exceeded):
n,k= map(int,input().split())
p = list(map(int,input().split()))

s = [1+0.5*(i-1) for i in range(1,max(p)+1)]

ma = 0
for i in range(n-k+1):
    ans=0
    for j in range(k):
        ans += s[p[i+j]-1]
    if(ma<ans):
        ma = ans
    
print(ma)

Fixed submission:
n,k= map(int,input().split())
p = list(map(int,input().split()))

s = [1+0.5*(i-1) for i in range(1,max(p)+1)]

q = [0]
c = 0
for i in p:
    c += s[i-1]
    q.append(c)

ma = 0
for i in range(k,n+1):
    ans = q[i]-q[i-k]
    if(ma<ans):
        ma = ans
    
print(ma)

Buggy python submission (verdict: Time Limit Exceeded):
n,k= map(int,input().split())
p = list(map(int,input().split()))

s = [1+0.5*(i-1) for i in range(1,max(p)+1)]

ma = 0
for i in range(n-k+1):
    ans=0
    for j in range(k):
        ans += s[p[i+j]-1]
    if(ma<ans):
        ma = ans
    
print(ma)

Fixed submission:
n,k= map(int,input().split())
p = list(map(int,input().split()))

s = [1+0.5*(i-1) for i in range(1,max(p)+1)]

q = [0]
c = 0
for i in p:
    c += s[i-1]
    q.append(c)

ma = 0
for i in range(k,n+1):
    ans = q[i]-q[i-k]
    if(ma<ans):
        ma = ans
    
print(ma)

Buggy python submission (verdict: Time Limit Exceeded):
n,k= map(int,input().split())
p = list(map(int,input().split()))

s = []
for i in range(1,max(p)+1):
    an = i*(i+1)/2/i
    s.append(an)

ma = 0
for i in range(n-k+1):
    ans=0
    for j in range(k):
        ans += s[p[i+j]-1]
    if(ma<ans):
        ma = ans
    
print(ma)

Fixed submission:
n,k= map(int,input().split())
p = list(map(int,input().split()))

s = [1+0.5*(i-1) for i in range(1,max(p)+1)]

q = [0]
c = 0
for i in p:
    c += s[i-1]
    q.append(c)

ma = 0
for i in range(k,n+1):
    ans = q[i]-q[i-k]
    if(ma<ans):
        ma = ans
    
print(ma)
Buggy python submission (verdict: Runtime Error):
    h,a = map(int,input().split()) 
    print(h,a)

    if(h<a):
        print("1")
    elif(h%a != 0):
        print(h/a+1)
    else:
        print(h/a)

Fixed submission:
h,a = map(int,input().split()) 

if(h<a):
  print("1")
elif(h%a != 0):
    print(h//a+1)
else:
    print(h//a)
Buggy python submission (verdict: Runtime Error):
from bisect import bisect_left

n = int(input())
l = list(map(int,input().split()))

l.sort()
count = 0
for i in range(n-2):
  for j in range(i+1,n-1):
    print(bisect_left(l,l[j]+l[i]),i,j,l)
    count+=bisect_left(l,l[j]+l[i])-j-1
print(count)

Fixed submission:
from bisect import bisect_left

n = int(input())
l = list(map(int,input().split()))

l.sort()
count = 0
for i in range(n-2):
  for j in range(i+1,n-1):
    count+=bisect_left(l,l[j]+l[i])-j-1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n= int(input())
l=list(map(int,input().split()))
cnt=0
ls = sorted(l)
for i in range(n-1):
    for j in range(i+1,n-1):
        for h in range(j+1,n):
            a,b,c=ls[i],ls[j],ls[h]
            if(a+b<c):
                break
            if(a<b+c)and(b<a+c)and(c<a+b):
                cnt+=1
print(cnt)

Fixed submission:
from bisect import bisect_left

n = int(input())
l = list(map(int,input().split()))

l.sort()
count = 0
for i in range(n-2):
  for j in range(i+1,n-1):
    count+=bisect_left(l,l[j]+l[i])-j-1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n= int(input())
l=list(map(int,input().split()))


cnt=0
for i in range(n-1):
    for j in range(i+1,n-1):
        for h in range(j+1,n):
            a,b,c=l[i],l[j],l[h]
            if(a<b+c)and(b<a+c)and(c<a+b):
                cnt+=1
print(cnt)

Fixed submission:
from bisect import bisect_left

n = int(input())
l = list(map(int,input().split()))

l.sort()
count = 0
for i in range(n-2):
  for j in range(i+1,n-1):
    count+=bisect_left(l,l[j]+l[i])-j-1
print(count)
Buggy python submission (verdict: Runtime Error):
flg=0
for i in range(0,len(s)-1,2):
    if s[i] not in ["R","U","D"]:
        flg=1
    if s[i+1] not in ["L","U","D"]:
        flg=1
if(flg==1):
    print("No")
else: print("Yes")

Fixed submission:
s = list(input())
flg=0
for i in range(1,len(s)+1):
    if(i%2!=0):
        if s[i-1] not in ["R","U","D"]:
            flg=1
    elif(i%2==0):
        if s[i-1] not in ["L","U","D"]:
            flg=1
if(flg==1):
    print("No")
else: print("Yes")
Buggy python submission (verdict: Runtime Error):
import heapq
n,m = map(int,input().split())
a=  list(map(int,input().split()))
h = list(map(lambda x:-1*x,a))
heapq.heapify(h)
for i in range(m):
    heapq.heapreplace(h,-(-h[0]//2))
    print(h)

Fixed submission:
import heapq
n,m = map(int,input().split())
a=  list(map(int,input().split()))
h = list(map(lambda x:-1*x,a))
heapq.heapify(h)
for i in range(m):
    heapq.heapreplace(h,-(-h[0]//2))
print(-1*sum(h))

Buggy python submission (verdict: Time Limit Exceeded):
def mmm(li):
    li[li.index(max(a))]//=2

n,m = map(int,input().split())
a=  list(map(int,input().split()))
[mmm(a) for i in range(m)]
print(sum(a))

Fixed submission:
import heapq
n,m = map(int,input().split())
a=  list(map(int,input().split()))
h = list(map(lambda x:-1*x,a))
heapq.heapify(h)
for i in range(m):
    heapq.heapreplace(h,-(-h[0]//2))
print(-1*sum(h))

Buggy python submission (verdict: Time Limit Exceeded):
def mmm(li):
    li[li.index(max(a))]//=2

n,m = map(int,input().split())
a=  list(map(int,input().split()))
[mmm(a) for i in range(m)]
print(sum(a))

Fixed submission:
import heapq
n,m = map(int,input().split())
a=  list(map(int,input().split()))
h = list(map(lambda x:-1*x,a))
heapq.heapify(h)
for i in range(m):
    heapq.heapreplace(h,-(-h[0]//2))
print(-1*sum(h))

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
a=  list(map(int,input().split()))
for i in range(m):
    a[a.index(max(a))]=a[a.index(max(a))] //2
print(sum(a))

Fixed submission:
import heapq
n,m = map(int,input().split())
a=  list(map(int,input().split()))
h = list(map(lambda x:-1*x,a))
heapq.heapify(h)
for i in range(m):
    heapq.heapreplace(h,-(-h[0]//2))
print(-1*sum(h))

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
a=  list(map(int,input().split()))

for i in range(m):
    a[a.index(max(a))]=a[a.index(max(a))] //2

print(sum(a))

Fixed submission:
import heapq
n,m = map(int,input().split())
a=  list(map(int,input().split()))
h = list(map(lambda x:-1*x,a))
heapq.heapify(h)
for i in range(m):
    heapq.heapreplace(h,-(-h[0]//2))
print(-1*sum(h))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
h = list(map(int,input().split()))
maxc=0
for i in range(n-1,0,-1):
    j = i
    cnt =0
    while((h[j]<=h[j-1])):
        if(j ==0):
            break
        cnt +=1
        j -=1
    
    if maxc < cnt:
        maxc = cnt
print(maxc)


Fixed submission:
n = int(input())
h = list(map(int,input().split()))
maxc=0
rec=n-1
for i in range(n-1,0,-1):
    if(i >rec):
        continue
        
    j = i
    cnt =0
    while((h[j]<=h[j-1])):
        if(j ==0):
            break
        cnt +=1
        j -=1
    rec= j
    if maxc < cnt:
        maxc = cnt
print(maxc)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = [i for i in range(1,n+1)]

print(sum(l)-l[-1])


Fixed submission:
n = int(input())
print(n*(n-1)//2)
Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce


def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers)


n= int(input())
a = list(map(int, input().split()))

s = lcm_list(a)
z = list(map(lambda x: s /x , a))
print(s/sum(z))

Fixed submission:
n= int(input())
a = list(map(int, input().split()))

ar=sum([1/i for i in a])
print(1/ar)

Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce


def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

n= int(input())
a = list(map(int, input().split()))

s = lcm_list(a)
z = list(map(lambda x: s /x , a))
print(s/sum(z))

Fixed submission:
n= int(input())
a = list(map(int, input().split()))

ar=sum([1/i for i in a])
print(1/ar)
Buggy python submission (verdict: Runtime Error):
    n = int(input())
    a = list(map(int,input().split()))
    b = list(map(int,input().split()))

    cnt = 0
    res = 0 #余力
    for i in range(n):

        ch = min(a[i],res)
        cnt += ch
        a[i] -= ch
        if b[i] > a[i]:
            cnt += a[i]
            res = b[i] - a[i]
        else:
            cnt += b[i]
            res = 0
    
    cnt += min(a[n],res)

    print(cnt)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

cnt = 0
res = 0 #余力
for i in range(n):

    ch = min(a[i],res)
    cnt += ch
    a[i] -= ch
    if b[i] > a[i]:
        cnt += a[i]
        res = b[i] - a[i]
    else:
        cnt += b[i]
        res = 0

cnt += min(a[n],res)

print(cnt)

Buggy python submission (verdict: Runtime Error):
def check(al,bl,cnt,i,j):

    if(i==len(al) or j==len(bl)):
        return cnt

    elif(j>i):
        c = check(al,bl,cnt,i+1,j)
        
    elif(al[i] > bl[j]) :
        al[i] = al[i]-bl[j]
        cnt += bl[j]
        c = check(al,bl,cnt,i,j+1)
    elif(al[i] < bl[j]):
        bl[j] = bl[j] - al[i]
        cnt += al[i]
        c= check(al,bl,cnt,i+1,j)
    elif(al[i] == bl[j]):
        cnt += al[i]
        c = check(al,bl,cnt,i+1,j+1)

    return c

n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

cnt = 0

print(check(a,b,cnt,0,0))

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

cnt = 0
res = 0 #余力
for i in range(n):

    ch = min(a[i],res)
    cnt += ch
    a[i] -= ch
    if b[i] > a[i]:
        cnt += a[i]
        res = b[i] - a[i]
    else:
        cnt += b[i]
        res = 0

cnt += min(a[n],res)

print(cnt)

Buggy python submission (verdict: Runtime Error):
def check(al,bl,cnt,i,j):


    if(i==-1 or j==-1):
        return cnt

    elif(j >i):
        c = check(al,bl,cnt,i,j-1)
        
    elif(al[i] > bl[j]) :
        al[i] = al[i]-bl[j]
        cnt += bl[j]
        c = check(al,bl,cnt,i,j-1)
    elif(al[i] < bl[j]):
        bl[j] = bl[j] - al[i]
        cnt += al[i]
        c= check(al,bl,cnt,i-1,j)
    elif(al[i] == bl[j]):
        cnt += al[i]
        c = check(al,bl,cnt,i-1,j-1)

    return c

n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

cnt = 0

print(check(a,b,cnt,len(a)-1,len(b)-1))

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

cnt = 0
res = 0 #余力
for i in range(n):

    ch = min(a[i],res)
    cnt += ch
    a[i] -= ch
    if b[i] > a[i]:
        cnt += a[i]
        res = b[i] - a[i]
    else:
        cnt += b[i]
        res = 0

cnt += min(a[n],res)

print(cnt)
Buggy python submission (verdict: Runtime Error):
import math
a,b,c,d = map(int,input().split())
li=[]
for i in [a-1,b]:
    bc = i//c
    bd = i//d
    gc = c*d / math.gcd(c,d)
    cd = i//gc
    li.append(i-(bc+bd-cd))
print(int(li[1]-li[0]))

Fixed submission:
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
def lcm(a,b):
    return a*b//gcd(a,b)

a,b,c,d = map(int,input().split())
li=[]
gc = lcm(c,d)
for i in [a-1,b]:
    bc = i//c
    bd = i//d
    cd = i//gc
    li.append(i-(bc+bd-cd))
print(int(li[1]-li[0]))

Buggy python submission (verdict: Runtime Error):
import math
a,b,c,d = map(int,input().split())
li=[]
for i in [a-1,b]:
    bc = i//c
    bd = i//d
    gcd = c*d / math.gcd(c,d)
    cd = i//gcd
    li.append(i-(bc+bd-cd))
print(int(li[1]-li[0]))

Fixed submission:
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
def lcm(a,b):
    return a*b//gcd(a,b)

a,b,c,d = map(int,input().split())
li=[]
gc = lcm(c,d)
for i in [a-1,b]:
    bc = i//c
    bd = i//d
    cd = i//gc
    li.append(i-(bc+bd-cd))
print(int(li[1]-li[0]))

Buggy python submission (verdict: Time Limit Exceeded):
a,b,c,d = map(int,input().split())
cnt=0
for i in range(a,b+1):
    if i%c==0 or i%d==0:
        cnt +=1
print(b-a-cnt+1)

Fixed submission:
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
def lcm(a,b):
    return a*b//gcd(a,b)

a,b,c,d = map(int,input().split())
li=[]
gc = lcm(c,d)
for i in [a-1,b]:
    bc = i//c
    bd = i//d
    cd = i//gc
    li.append(i-(bc+bd-cd))
print(int(li[1]-li[0]))
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
a = list(map(int,input().split()))

dp = [0]*(n+1)
dp[0] = 1

for i in range(1,n+1):
    dp[i] = (dp[i-1]+dp[i-2])%(10**9+7)
    if i in a : dp[i]=0
print(dp[n])

Fixed submission:
n,m=map(int,input().split())
a=set([int(input()) for i in range(m)])
dp=[0]*(n+1)
dp[0]=1
for i in range(1,n+1):
    dp[i]=(dp[i-1]+dp[i-2])%(10**9+7)
    if i in a:dp[i]=0
print(dp[n])
Buggy python submission (verdict: Runtime Error):
from collections import deque

s=input()
sd=deque(s)
d=deque()
while(len(sd)>0):
  crr = sd.popleft()
  if(len(d)<1):
    d.append(crr)
    continue
    if(len(d)>=1 and d[-1]!=crr):
      d.pop()
      else:
        d.append(crr)
print(len(s)-len(d))

Fixed submission:
from collections import deque
 
s=input()
sd=deque(s)
d=deque()
while(len(sd)>0):
  crr = sd.popleft()
  if(len(d)<1):
    d.append(crr)
    continue
  if(len(d)>=1 and d[-1]!=crr):
    d.pop()
  else:
    d.append(crr)
print(len(s)-len(d))
Buggy python submission (verdict: Runtime Error):
x, k, d = map(int, input().split())


def is_even(num):
    if num % 2 == 0:
        return True
    else:
        return False


ans = 0

if 2 * x < d:
    ans = x
else:
    t = x // d
    if k > t - 2:
        if (k - t) / 2 == 0:
            t0 = abs(x - (t - 2) * d)
            t1 = abs(x - (t) * d)
            t2 = abs(x - (t + 2) * d)
            ans = min(t0, min(t1, t2))
        else:
            t0 = abs(x - (t - 1) * d)
            t2 = abs(x - (t + 1) * d)
            ans = min(t0, min(t1, t2))
    else:
      ans = abs(x- (k) * d)

print(ans)


Fixed submission:
x, k, d = map(int, input().split())

x = abs(x)

ans = 0

t = x // d
s = x % d

if abs(x) > k * d:
    print(abs(x) - k * d)
elif t % 2 == k % 2:
    print(s)
else:
    print(d - s)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int, input().split()))

ans = 0

for i in range(n - 2):
    a = l[i]
    for j in range(n - i - 2):
        b = l[i + j + 1]
        for k in range(n - i - j - 2):
            c = l[i + j + k + 2]
            if a < b + c and b < c + a and c < a + b:
                ans += 1

print(ans)


Fixed submission:
import bisect

n = int(input())
l = list(map(int, input().split()))

l.sort()

ans = 0

for i in range(n - 2):
    a = l[i]
    for j in range(n - i - 2):
        b = l[i + j + 1]
        index = bisect.bisect_left(l, a + b)
        if index > i + j + 2:
            ans += index - (i + j + 2)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
m = 0


for i in range(n):
    t = i + 1
    if t == n:
        m += 0
    else:
        m += t % (t + 1)


print(m)


Fixed submission:
n = int(input())

m = n * (n - 1) // 2

print(m)
Buggy python submission (verdict: Runtime Error):
object Main extends App {
  val r = scala.io.StdIn.readInt
  println(r * r * 3)
}


Fixed submission:
r = int(input())

print(3 * r * r)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

ans = []
ans.append(int(input()))

for i in range(n - 1):
    t = int(input())
    ch = 0
    if t <= ans[-1]:
        ans.append(t)
    else:
        for j in range(len(ans)):
            if t > ans[j]:
                ans[j] = t
                ch += 1
                break

print(len(ans))


Fixed submission:
def reverse_insort(a, x):
    lo = 0
    hi = len(a)
    while lo < hi:
        mid = (lo + hi) // 2
        if x > a[mid]:
            hi = mid
        else:
            lo = mid + 1
    return lo


n = int(input())

ans = []
ans.append(int(input()))

for i in range(n - 1):
    t = int(input())
    ch = 0
    if t <= ans[-1]:
        ans.append(t)
    else:
        ans[reverse_insort(ans, t)] = t

print(len(ans))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

ans = []
ans.append(int(input()))

for i in range(n - 1):
    t = int(input())
    ch = 0
    for j in range(len(ans)):
        if t > ans[j]:
            ans[j] = t
            ch += 1
            break
    if ch == 0:
        ans.append(t)

print(len(ans))


Fixed submission:
def reverse_insort(a, x):
    lo = 0
    hi = len(a)
    while lo < hi:
        mid = (lo + hi) // 2
        if x > a[mid]:
            hi = mid
        else:
            lo = mid + 1
    return lo


n = int(input())

ans = []
ans.append(int(input()))

for i in range(n - 1):
    t = int(input())
    ch = 0
    if t <= ans[-1]:
        ans.append(t)
    else:
        ans[reverse_insort(ans, t)] = t

print(len(ans))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
b = sum(a) / 2
p = int((n - 1) / 2)

x = []

for i in range(n):
    t = b
    for j in range(p):
        t -= a[(2 * j + i + 1) % n]
    x.append(t * 2)

for i in range(n):
    print(int(x[i]), end=" ")


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = sum(a) / 2
p = int((n - 1) / 2)

x = []

t = b
for j in range(p):
    t -= a[2 * j + 1]
x.append(t * 2)

for i in range(n-1):
    t = a[i] - x[i] / 2
    x.append(t * 2)

for i in range(n):
    print(int(x[i]), end=" ")
Buggy python submission (verdict: Runtime Error):
import math

p = 1000000007

n, k = map(int, input().split())

b = k
r = n - k

def P(n, r):
    return math.factorial(n)//math.factorial(n-r)

def C(n, r):
    return P(n, r)//math.factorial(r)

for i in range(k):
    t = i + 1
    x = C(b - 1, t - 1)
    y = C(r + 1, t)
    print((x * y) % p)


Fixed submission:
import math

n, k = map(int, input().split())

p = 1000000007

b = k
r = n - k


def P(n, r):
    return (math.factorial(n) // math.factorial(n - r))


def C(n, r):
    return (P(n, r) // math.factorial(r))


for i in range(k):
    t = i + 1
    if (b - 1) < (t - 1):
        print("0")
    elif (r + 1) < t:
        print("0")
    else:
        x = C(b - 1, t - 1)
        y = C(r + 1, t)
        print((x * y) % p)
Buggy python submission (verdict: Runtime Error):
import fractions
from functools import reduce
import random
import copy

def gcd(numbers):
    return reduce(fractions.gcd, numbers)

n = int(input())
a = list(map(int, input().split()))
ans = 1

if n < 100:
  for i in range(n):
    b = copy.copy(a)
    b.pop(i)
    t = gcd(b)
    if ans < t:
      ans = t
else:
  for _ in range(100):
    t = gcd(random.sample(a, 50))
    if ans < t:
      ans = t

print(ans)


Fixed submission:
a, b, t = map(int, input().split())

ans = (t // a) * b

print(ans)

Buggy python submission (verdict: Runtime Error):
import fractions
from functools import reduce
import random
import copy

def gcd(numbers):
    return reduce(fractions.gcd, numbers)

n = int(input())
a = list(map(int, input().split()))
ans = 1

if n < 100:
  for i in range(n):
    b = copy.copy(a)
    b.pop(i)
    t = gcd(b)
    if ans < t:
      ans = t
else:
  for _ in range(100):
    t = gcd(random.sample(a, 30))
    if ans < t:
      ans = t

print(ans)

Fixed submission:
a, b, t = map(int, input().split())

ans = (t // a) * b

print(ans)
Buggy python submission (verdict: Runtime Error):
import collections as c
ip = lambda : map(int, input().split())
# ##############
N = int(input())
l = list(ip())
d = []
for i in range(N-1):
    d.append(l[i+1]-l[i])

ans = 0;mod = 1e9+7;c=0;l=1
for i in range(N-1):
    c = (i+1)*c + l
    ans = ((i+1)*ans + c*d[i])%mod
    l = l*(i+1)%mod
print(int(ans%mod))

Fixed submission:
import collections as c
ip = lambda : map(int, input().split())
# ##############
N = int(input())
l = list(ip())
d = []
for i in range(N-1):
    d.append(l[i+1]-l[i])

ans = 0
mod = int(1e9+7)
c=0
l=1
for i in range(N-1):
    c = ((i+1)*c + l)%mod
    ans = ((i+1)*ans + c*d[i])%mod
    l = l*(i+1)%mod
print(ans)

Buggy python submission (verdict: Runtime Error):
import collections as c
ip = lambda : map(int, input().split())
# ##############
N = int(input())
l = list(ip())
d = []
for i in range(N-1):
    d.append(l[i+1]-l[i])

ans = 0;mod = 1e9+7;c=0;l=1
for i in range(N-1):
    c = (i+1)*c + l
    ans = (i+1)*ans + c*d[i]
    ans%=mod
    l *= i+1
print(int(ans%mod))

Fixed submission:
import collections as c
ip = lambda : map(int, input().split())
# ##############
N = int(input())
l = list(ip())
d = []
for i in range(N-1):
    d.append(l[i+1]-l[i])

ans = 0
mod = int(1e9+7)
c=0
l=1
for i in range(N-1):
    c = ((i+1)*c + l)%mod
    ans = ((i+1)*ans + c*d[i])%mod
    l = l*(i+1)%mod
print(ans)

Buggy python submission (verdict: Runtime Error):
import collections as c
ip = lambda : map(int, input().split())
# ##############
N = int(input())
l = list(ip())
d = []
for i in range(N-1):
    d.append(l[i+1]-l[i])

ans = 0;mod = 1e9+7;c=0;l=1
for i in range(N-1):
    # if i == 0:
    #     c = 1
    # else:
    #     c = (c*(i+1)/(i*l) + 1)*l
    # print(ans)
    # ans = (ans*(i+1)%mod + d[i]*c)%mod
    # l = (l*i+1)%mod
    c+=1/(i+1)
    ans += c*d[i]
    ans%=mod
    l *= i+1
print(int(ans*l%mod))

Fixed submission:
import collections as c
ip = lambda : map(int, input().split())
# ##############
N = int(input())
l = list(ip())
d = []
for i in range(N-1):
    d.append(l[i+1]-l[i])

ans = 0
mod = int(1e9+7)
c=0
l=1
for i in range(N-1):
    c = ((i+1)*c + l)%mod
    ans = ((i+1)*ans + c*d[i])%mod
    l = l*(i+1)%mod
print(ans)