Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02948 (python)

Fixed submission:
import heapq
from operator import itemgetter

def main():
    N, M = map(int,input().split())
    AB = [list(map(int,input().split())) for _ in range(N)]
    AB.sort(key = itemgetter(0))
    heap = []
    ans = 0
    cnt = 0
    for i in range(1,M + 1):
        while cnt < N and AB[cnt][0] <= i:
            heapq.heappush(heap,-1*AB[cnt][1])
            cnt += 1
        if len(heap) > 0:
            ans += heapq.heappop(heap)*-1
    print(ans)
    return

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(N)]

from operator import itemgetter
AB.sort(key = itemgetter(1),reverse = True)
AB.sort(key = itemgetter(0),reverse = True)


memo = {}
import sys
sys.setrecursionlimit(10**5 + 1)
def dp(i,j):
        if (i,j) in memo:
                return memo[(i,j)]
        elif i == M or j == N:
                return 0
        a,b = AB[j]
        if i <= M - a:
                return max(dp(i+1,j+1) + b, dp(i,j+1))
        return dp(i,j+1)
print(dp(0,0))
Problem p02990 (python)

Fixed submission:
def euclid(a:int,b:int)->(int,int):
    #return x,y s.t ax + by = gcd(a,b)
    #a > b >= 0
    if b == 0:
        return 1,0
    x,y = euclid(b,a%b)
    return y,x - y*(a // b)

def inverse(a:int,mod:int)->int:
    #gcd(p,b) == 1
    if mod > a:
        n,x = euclid(mod,a)
    else:
        x,n = euclid(a,mod)
    return x

def devide_mod(a:int,b:int,mod:int)->int:
    #a // b
    x = inverse(b,mod)
    return  (a*x)%mod

mod = 10**9 + 7


def com_init(mx:int ,mod:int)->list:
    fac = [1]*mx
    inv = [1]*mx
    finv = [1]*mx
    for i in range(2,mx):
        fac[i] = fac[i - 1]*i%mod
        inv[i] = mod - inv[mod%i]*(mod//i)%mod
        finv[i] = finv[i-1]*inv[i]%mod
    return fac,finv,inv

fac,finv ,inv = com_init(10**5,10**9 + 7)

def com(n:int, k:int):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n]*(finv[k]*finv[n-k]%mod)%mod

def main():
    N, K = map(int,input().split())
    for i in range(1, K + 1 ):
        print(com(N - K + 1,i)*com(K - 1, i - 1)%mod)
    return


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
_N,_K = map(int,input().split())
_mod = 10**9 + 7

def framod(fn, fmod, fa=1):
    for i in range(1,fn+1):
        fa=fa * i % fmod
    return fa

def power(pn, pr, pmod):
    if pr == 0: return 1
    if pr%2 == 0:
        return power(pn*pn % pmod, pr//2, pmod) % pmod
    if pr%2 == 1:
        return pn * power(pn, pr-1, pmod) % pmod

def comb(ccn, cck, ccmod):
    a=framod(ccn, ccmod)
    b=framod(cck, ccmod)
    c=framod(ccn-cck, ccmod)
    return (a * power(b, ccmod-2, ccmod) * power(c, ccmod-2, ccmod)) % ccmod
    


def solve(i):
    n = i
    r = _K - i
    pattern = comb(_N -_K+1,i,_mod)
    if n == 1:
        return pattern
    else:
        ans = comb(K-1,i-1,_mod)
        return ans*pattern%_mod


for i in range(1,_K+1):
    print(solve(i))
Problem p03186 (python)

Fixed submission:
a=[int(x) for x in input().split()]
if(a[0]+a[1]>=a[2]):
  print(a[1]+a[2])
else:
  print(2*a[1]+a[0]+1)

Buggy submission (verdict: Runtime Error):
a=[int(x) for x in input().split()]
if(a[0]+a[1]>a[2]):
  print(a[1]+a[2])
elif:
  print(a[1]+a[2]-abs(a[0]+a[1]-a[2]))
Problem p03250 (python)

Fixed submission:
A = list(map(int,input().split()))
A.sort()
print(A[2]*10 + A[1]+A[0])

Buggy submission (verdict: Runtime Error):
a,b,c = input().split()
print(max(int(a+b)+int(c),int(b+c)+int(a))
Problem p03745 (python)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
if N == 1:
    print(1)
else:
    if A[0] == A[1]:
        pre = 0
    elif A[0] > A[1]:
        pre = -1
    else:
        pre = 1
    prevalue = A[1]
    ans = 0
    for a in A[2:]:
        if a > prevalue:
            if pre == -1:
                ans += 1
                pre = 0
            else:
                pre = 1
        elif a < prevalue:
            if pre == 1:
                ans += 1
                pre = 0
            else:
                pre = -1
        prevalue = a
    print(ans+1)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
if A[0] == A[1]:
    pre = 0
elif A[0] > A[1]:
    pre = -1
else:
    pre = 1
prevalue = A[1]
ans = 0
for a in A[2:]:
    if a > prevalue:
        if pre == -1:
            ans += 1
            pre = 0
        else:
            pre = 1
    elif a < prevalue:
        if pre == 1:
            ans += 1
            pre = 0
        else:
            pre = -1
    prevalue = a
print(ans+1)
Problem p02580 (python)

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

lh = []
lw = []

for i in range(m):
  h1,w1 = map(int, input().split())
  lh.append(h1)
  lw.append(w1)

if h == 1 or w == 1:
  print(m)
else:
  from collections import Counter as co
  ch=co(lh).most_common()
  cw=co(lw).most_common()
  
  ans = 0
  tmp = ch[0][0]
  lh_c = [i for i, x in enumerate(lh) if x == tmp]
  lw_tmp = lw[:]
  for j in sorted(lh_c, reverse=True):
    lw_tmp.pop(j)
  if len(lw_tmp) == 0:
    print(ch[0][1])
  else:
    cw_tmp = co(lw_tmp).most_common()
    ans = ch[0][1]+cw_tmp[0][1]
    
    tmp = cw[0][0]
    lw_c = [i for i, x in enumerate(lw) if x == tmp]
    lh_tmp = lh[:]
    for j in sorted(lw_c, reverse=True):
      lh_tmp.pop(j)
    if len(lh_tmp) == 0:
      print(cw[0][1])
    else:
      ch_tmp = co(lh_tmp).most_common()
      ans = max(ans, cw[0][1]+ch_tmp[0][1])
      print(ans)

Buggy submission (verdict: Runtime Error):
h,w,m = map(int, input().split())

lh = []
lw = []

for i in range(m):
  h1,w1 = map(int, input().split())
  lh.append(h1)
  lw.append(w1)

if h == 1 or w == 1:
  print(m)
else:
  from collections import Counter as co
  ch=co(lh).most_common()

  tmp = ch[0][0]
  lh_c = [i for i, x in enumerate(lh) if x == tmp]
  for j in sorted(lh_c, reverse=True):
    lw.pop(j)
  cw = co(lw).most_common()
  ans = ch[0][1]+cw[0][1]

  print(ans)

Buggy submission (verdict: Runtime Error):
h,w,m = map(int, input().split())

lh = []
lw = []

for i in range(m):
  h1,w1 = map(int, input().split())
  lh.append(h1)
  lw.append(w1)

from collections import Counter as co
c=co(lh).most_common()

ans1 = c[0][1]
ans2 = 0
i = 0
while c[i][1] == c[0][1]:
  tmp = c[i][0]
  lh_c = [j for j, x in enumerate(lh) if x == tmp]
  tmp_lw = lw[:]
  for k in sorted(lh_c, reverse=True):
    tmp_lw.pop(k)
  cw = co(tmp_lw).most_common()
  ans2 = max(ans2, cw[0][1])
  i += 1
  if i >= len(c)-1:
    break
  
print(ans1+ans2)
Problem p02711 (python)

Fixed submission:
n = str(input())
a=n[0]
b=n[1]
c=n[2]

if a=='7' or b=='7' or c=='7':
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n = str(input())
if n[0]='7' or n[1]='7' or n[2]='7':
  print("Yes")
else:
  print("No")
Problem p02729 (python)

Fixed submission:
import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n,m = (int(x) for x in input().split())

if n<=1:
  if m<=1:
    print(0)
  else:
    print(comb(m, 2))
elif m<=1:
  print(comb(n, 2))
else:
  print(comb(n, 2)+comb(m, 2))

Buggy submission (verdict: Runtime Error):
import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n,m = (int(x) for x in input().split())

if n==1:
  if m==1:
    print(0)
  else:
    print(comb(m, 2))
elif m==1:
  print(comb(n, 2))
else:
  print(comb(n, 2)+comb(m, 2))
Problem p02676 (python)

Fixed submission:
K = int(input())
S = input()
if len(S)<=K:
  print(S)
else:
  print(S[0:K]+"...")

Buggy submission (verdict: Runtime Error):
K = int(input())
S = input()
if len(S)<=K:
  print(S)
else:
  print(S[0]+S[1]+S[2]+S[3]+S[4]+S[5]+S[6]+"...")
Problem p02623 (python)

Fixed submission:
from itertools import accumulate

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

c = [0] + list(accumulate(a))
d = [0] + list(accumulate(b))

ans = 0
i = 0
j = len(b)

while True:
    num = c[i] + d[j]
    if num > k and j >= 1:
        while True:
            j -= 1
            if j == 0 or c[i] + d[j] <= k:
                break
    if c[i] + d[j] <= k:
        ans = max(ans, i + j)
    if i == len(a):
        break
    while True:
        i += 1
        if i == len(a) or c[i] + d[j] > k:
            i -= 1
            break
    if c[i] + d[j] <= k:
        ans = max(ans, i + j)
    i += 1

print(ans)

Buggy submission (verdict: Runtime Error):
from itertools import accumulate
from bisect import bisect_left

n, m, k = map(int, input().split())
a = [0] + list(accumulate(list(map(int, input().split()))))
b = [0] + list(accumulate(list(map(int, input().split()))))
ans = 0

for i in range(n + 1):
    if a[i] + b[bisect_left(b, k - a[i])] <= k:
        ans = max(ans, i + bisect_left(b, k - a[i]))
    
print(ans)
Problem p02629 (python)

Fixed submission:
N = int(input())
ans = ''
for i in range(1, 99):
    if N <= 26 ** i:
        N -= 1
        for j in range(i):
            ans += chr(ord('a') + N % 26)
            N //= 26
        break
    else:
        N -= 26 ** i

print(ans[::-1])

Buggy submission (verdict: Runtime Error):
n = int(input())
m = n
for i in range(20):
    tmp = 0
    for j in range(1, i):
        tmp += 26 ** j
    if 26 ** (i - 2) < n <= tmp:
        digit = i - 1
        break
ans = ""
"""
for i in range(digit)[::-1]:
    ans += chr(96 + n // (26 ** i))
    print(n // (26 ** i))
    n = n % (26 ** i)
print(ans)
"""
for i in range(digit)[::-1]:
    m = n // 26 ** i
    if m == 27:
        n -= (m - 1) * 26 ** i
        ans += chr(96 + (m - 1))
    else:
        n -= m * 26 ** i
        ans += chr(96 + m)

print(ans)
Problem p02688 (python)

Fixed submission:
n, k = map(int, input().split())
A = []
for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    A += a
A_ = set(A)
print(n - len(A_))

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
d = int(input())
A = []
for i in range(d):
    a = list(map(int, input().split()))
    A += a
A_ = set(A)
print(n - len(A_))
Problem p02819 (python)

Fixed submission:
n = int(input())
for i in range(n, 100004):
    flag = 0
    for j in range(2, int(i**0.5) + 1):
        if i % j == 0:
            flag = 1
            break
    if flag == 0:
        print(i)
        break

Buggy submission (verdict: Runtime Error):
import math
print(int(math.sqrt(x)))
for i in range(2, int(math.sqrt(x)) + 2):
    if x % i == 0:
        x += 1
print(x)

Buggy submission (verdict: Runtime Error):
pip install sympy 
x = int(input())
from sympy import nextprime
print(nextprime(x - 1))

Buggy submission (verdict: Runtime Error):
x = int(input())
from sympy import nextprime
print(nextprime(x - 1))
Problem p02879 (python)

Fixed submission:
a, b = map(int, input().split())
if a > 9 or b > 9:
  print("-1")
else:
  print(a * b)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input())
if a > 9 or b > 9:
  print("-1")
else:
  print(a * b)
Problem p02990 (python)

Fixed submission:
import math
def combinations(x, y):
    return math.factorial(x) // (math.factorial(x - y) * math.factorial(y))
    
n, k = map(int, input().split())
if k == 1:
    print(n - k + 1)
else:    
    for i in range(k):
        if n - k < i:
            print("0")
        else:
            print(combinations(n - k + 1, i + 1) * combinations(k - 1, i) % (10 ** 9 + 7))

Buggy submission (verdict: Runtime Error):
import math
def combinations(x, y):
    return math.factorial(x) // (math.factorial(x - y) * math.factorial(y))


    
n, k = map(int, input().split())
if k == 1:
    print(n - k + 1)
else:    
    for i in range(k):
        print(combinations(n - k + 1, i + 1) * combinations(k - 1, i) % (10 ** 9 + 7))

Buggy submission (verdict: Runtime Error):
import math
def combinations(x, y):
    return math.factorial(x) // (math.factorial(x - y) * math.factorial(y))

n, k = map(int, input().split())
for i in range(k):
    print(combinations(n - k + 1, i + 1) * combinations(k - 1, i) % (10 ** 9 + 7))
Problem p03038 (python)

Fixed submission:
n, m = map(int, input().split())
a = sorted(list(map(int, input().split())))
bc = [list(map(int, input().split())) for i in range(m)]
sort_bc = sorted(bc, key = lambda x:x[1], reverse = True)
cnt_a = 0
cnt_m = 0
for i in sort_bc:
    if cnt_a <= n - 1:
        for j in range(i[0]):
            if cnt_a <= n - 1:
                if i[1] > a[cnt_a]:
                    a[cnt_a] = i[1]
                    cnt_a += 1
                else:
                    break
    else:
        break
print(sum(a))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = sorted(list(map(int, input().split())))
bc = [list(map(int, input().split())) for i in range(m)]
sort_bc = sorted(bc, key = lambda x:x[1], reverse = True)
cnt_a = 0
cnt_m = 0
while (cnt_a <= (len(a) - 1)) and (cnt_m <= (m - 1)):
    i = sort_bc[cnt_m]
    cnt_m += 1
    for j in range(i[0]):
        if i[1] > a[cnt_a]:
            a[cnt_a] = i[1]
            cnt_a += 1
        else:
            break
print(sum(a))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = sorted(list(map(int, input().split())))
bc = [list(map(int, input().split())) for i in range(m)]
sort_bc = sorted(bc, key = lambda x:x[1], reverse = True)
cnt_a = 0
cnt_m = 0
while (cnt_a <= (len(a) - 1)) and (cnt_m <= (m - 1)):
    i = sort_bc[cnt_m]
    cnt_m += 1
    for j in range(i[0]):
        if i[1] > a[cnt_a]:
            a[cnt_a] = i[1]
            cnt_a += 1
        else:
            break
print(sum(a))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = sorted(list(map(int, input().split())))
bc = [list(map(int, input().split())) for i in range(m)]
sort_bc = sorted(bc, key = lambda x:x[1], reverse = True)
k = 0
for i in sort_bc:
    for j in range(i[0]):
        if k <= n:
            if i[1] > a[k]:
                a[k] = i[1]
                k += 1
        else:
            break
print(sum(a))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = sorted(list(map(int, input().split())))
bc = [list(map(int, input().split())) for i in range(m)]
sort_bc = sorted(bc, key = lambda x:x[1], reverse = True)
k = 0
for i in sort_bc:
    for j in range(i[0]):
        if i[1] > a[k]:
            a[k] = i[1]
            k += 1
        else:
            exit()
print(sum(a))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = sorted(list(map(int, input().split())))
bc = [list(map(int, input().split())) for i in range(m)]
sort_bc = sorted(bc, key = lambda x:x[1], reverse = True)
k = 0
for i in sort_bc:
    for j in range(i[0]):
        if i[1] > a[k]:
            a[k] = i[1]
            k += 1
print(sum(a))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = sorted(list(map(int, input().split())))
bc = [list(map(int, input().split())) for i in range(m)]
sort_bc = sorted(bc, key = lambda x:x[1], reverse = True)
print(sort_bc)
k = 0
for i in sort_bc:
    for j in range(i[0]):
        if i[1] > a[k]:
            a[k] = i[1]
            k += 1
print(sum(a))
Problem p02819 (python)

Fixed submission:
import math
N = int(input())
def main(val):
  for i in range(2,int(math.sqrt(val))):
    if val % i == 0:
      return True
  return False
while(True):
  if main(N) == False:
    print(N)
    break
  N += 1

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
def main(val):
  for i in range(2,math.floor(math.sqrt(val)):
   if val % i == 0:
     return True
  return False
while(True):
  if main(N) == False:
	print(N)
	break
  N += 1
Problem p02831 (python)

Fixed submission:
import fractions
a,b=map(int,input().split())
print((a*b)//fractions.gcd(a,b))

Buggy submission (verdict: Runtime Error):
import math
a,b=map(int,input().split())
print((a*b)//math.gcd(a,b))
Problem p02570 (python)

Fixed submission:
from math import *

def cin(): # To take limited number of inputs
    return map(int,input().split())

def cins(): # To take space sepreated strings
    return input.split()

def cino(test=False): # To take individual int input (test = False)
    if not test:
        return int(input())
    else: # To take string input (test = True)
        return input()

def cina(): # array input
  return list(map(int,input().split()))

def ssplit(): # multiple string input
    return list(input().split())

def printlist(l): # To print space seperated array
    for i in l:
        print(i,end=" ")

def main():
    a,b,c = cin()
    if a/c <= b:
      print("Yes")
    else:
      print("No")

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
a = input()
b = input()
ind = []
for i in range(len(a)-len(b)):
  if a[i] == b[0]:
    ind.append(i)

ans = len(b)
for i in range(len(ind)):
  count = 0
  for j in range(len(b)):
    if a[ind[i]+j]!=b[j]:
      count += 1
  ans = min(ans,count)

print(ans)
Problem p02688 (python)

Fixed submission:
n,k = map(int,input().split())
f = []
for _ in range(k):
  x = int(input())
  l = list(map(int,input().split()))
  for i in range(len(l)):
    f.append(l[i])
f = set(f)
print(n-len(f))

Buggy submission (verdict: Runtime Error):
n,k = int(input())
f = []
for _ in range(k):
  x = int(input())
  l = list(map(int,input().split()))
  for i in range(len(l)):
    f.append(l[i])
f = set(f)
print(n-len(f))
Problem p02659 (python)

Fixed submission:
# coding: utf-8
A,B=input().split()
A=int(A)
B=int(B.replace('.',""))
ans=A*B
ans=ans//100

print(ans)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
A,B=map(int,input().split())
B=B*100

ans=A*B
ans=ans/100

print(ans)
Problem p02793 (python)

Fixed submission:
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)

N=int(input())
A=list(map(int,input().split()))
MOD=(10**9)+7
S=list(set(A))
LCM=lcm_list(S)
ans=0

for i in range(N):
    ans+=(LCM//A[i])


print(ans%MOD)

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

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


N=int(input())
A=list(map(int,input().split()))
MOD=(10**9)+7
S=list(set(A))
LCM=lcm(A[0],A[1])
for i in range(2,N):
    LCM=lcm(LCM,A[i])
    

ans=0

for i in range(N):
    ans+=(LCM//A[i])
    ans=ans%MOD

print(ans)

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

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

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

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

N=int(input())
A=list(map(int,input().split()))
MOD=(10**9)+7

LCM=lcm_list(A)
ans=0

for i in range(N):
    ans+=(LCM//A[i])
    ans=ans%MOD

print(ans)
Problem p02831 (python)

Fixed submission:
# coding: utf-8
# Your code here!
import fractions

A,B=map(int,input().split())

print(A*B//fractions.gcd(A,B))

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
import math

A,B=map(int,input().split())

print(A*B//math.gcd(A,B))
Problem p02891 (python)

Fixed submission:
# coding: utf-8
# Your code here!
s=list(input())
k=int(input())
cnt=1
cnt2=0
tmp=0
flg=0
flg2=0
flg3=0
for i in range(len(s)):
    if tmp==s[i]:
        cnt+=1
    else:
        cnt2+=cnt//2
        cnt=1
    tmp=s[i]
cnt2+=cnt//2

if len(s)==1:
    flg2=1
elif len(set(s))==1:
    flg3=1

elif s[0]==s[-1]:
    m=0
    cnt3=0
    while s[m]==s[0]:
        cnt3+=1
        m+=1
        if m==len(s)-1:
            cnt3+=1
            break
    n=1
    cnt4=0
    while s[-n]==s[0]:
        cnt4+=1
        n+=1
        if n==len(s):
            cnt4+=1
            break
    if cnt3%2==1 and cnt4%2==1:
        flg=1

if flg==1:
    ans=cnt2*k+k-1
elif flg2==1:
    ans=k//2
elif flg3==1:
    ans=(len(s)*k)//2
else:
    ans=cnt2*k
    
print(ans)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
s=list(input())
k=int(input())
cnt=1
cnt2=0
tmp=0
flg=0
for i in range(len(s)):
    if tmp==s[i]:
        cnt+=1
    else:
        cnt2+=cnt//2
        cnt=1
    tmp=s[i]
cnt2+=cnt//2
if s[0]==s[-1]:
    m=0
    cnt3=0
    while s[m]==s[0]:
        cnt3+=1
        m+=1
        if m==len(s)-1:
            cnt+=3
            break
    n=1
    cnt4=0
    while s[-n]==s[0]:
        cnt4+=1
        n+=1
        if n==len(s):
            cnt4+=1
            break
    if cnt3%2==1 and cnt4%2==1:
        flg=1

if flg==1:
    ans=cnt2*k+k-1
else:
    ans=cnt2*k
print(ans)
Problem p02990 (python)

Fixed submission:
# coding: utf-8
N,K=map(int,input().split())
MOD=10**9+7

fac=[None for i in range(5000)]
finv=[None for i in range(5000)]
inv=[None for i in range(5000)]

def COMinit(num):
    global fac
    global finv
    global inv
    fac[0]=1
    fac[1]=1
    finv[0]=1
    finv[1]=1
    inv[1]=1

    for i in range(2,num):
        fac[i] = fac[i-1] * i % MOD
        inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
        finv[i] = finv[i-1] * inv[i] % MOD

def COM(n,k):
    if n<k:
        return 0
    elif n<0 or k<0:
        return 0
    else:
        return int(fac[n] * (finv[k] * finv[n - k] % MOD) % MOD)


COMinit(5000)

for i in range(1,K+1):
    print(COM(N-K+1,i)*COM(K-1,i-1)% MOD)

#print(COM(0,0))

Buggy submission (verdict: Runtime Error):
# coding: utf-8
N,K=map(int,input().split())
MOD=10**9+7

fac=[None for i in range(N)]
finv=[None for i in range(N)]
inv=[None for i in range(N)]

def COMinit(num):
    global fac
    global finv
    global inv
    fac[0]=1
    fac[1]=1
    finv[0]=1
    finv[1]=1
    inv[1]=1

    for i in range(2,num):
        fac[i] = fac[i-1] * i % MOD
        inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
        finv[i] = finv[i-1] * inv[i] % MOD

def COM(n,k):
    if n<k:
        return 0
    elif n<0 or k<0:
        return 0
    else:
        return int(fac[n] * (finv[k] * finv[n - k] % MOD) % MOD)


COMinit(N)

for i in range(1,K+1):
    print(COM(N-K+1,i)*COM(K-1,i-1))

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

n,k=map(int,input().split())
b=k
r=n-k
if k>r+1:
    m=r+2
ans=r+1
print(ans)
for i in range(2,k+1):
    ans=0
    for j in range(3):
        if i>=m:
            print(0)
            break
        if r-1>=i-j:
            tmp=cmb(r-1,i-j)
            p=1
            if j==1:
                p=2
            ans+=cmb(b-1,i-1)*tmp*p
            ans=ans%(10**9+7)
    print(ans)