Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
H,W = map(int,input().split())
p = []
for i in range(H):
    b = list(input())
    b.append(".")
    p.append(b)

p.append(["."]*(W+1))
c = [[10**9]*(W+1) for i in range(H+1)]

if p[0][0] == ".":
    c[0][0] = 0
else:
    c[0][0] = 1

q = [[0,0]]

i = 0
j = 0
while(len(q) != 0):
    i = q[0][0]
    j = q[0][1]
    q.remove([i,j])
    if p[i+1][j] == ".":
        c[i+1][j] = min(c[i][j],c[i+1][j])
    else:
        c[i+1][j] = min(c[i][j]+1, c[i+1][j])
    if p[i][j+1] == ".":
        c[i][j+1] = min(c[i][j],c[i][j+1])
    else:
        c[i][j+1] = min(c[i][j]+1,c[i][j+1])
    if i < H-1:
        q.append([i+1,j])
    if j < W-1:
        q.append([i,j+1])

print(c[H-1][W-1])

Fixed submission:
H, W = map(int, input().split())
p = []
for i in range(H):
    b = list(input())
    b.append(".")
    p.append(b)

p.append(["."] * (W + 1))
dp = [[10 ** 9] * (W + 1) for i in range(H + 1)]

if p[0][0] == ".":
    dp[0][0] = 0
else:
    dp[0][0] = 1

for i in range(H):
    for j in range(W):
        if p[i + 1][j] == ".":
            dp[i + 1][j] = min(dp[i][j], dp[i + 1][j])
        elif p[i][j] == "#":
            dp[i + 1][j] = min(dp[i][j], dp[i + 1][j])
        else:
            dp[i + 1][j] = min(dp[i][j] + 1, dp[i + 1][j])

        if p[i][j + 1] == ".":
            dp[i][j + 1] = min(dp[i][j], dp[i][j + 1])
        elif p[i][j] == "#":
            dp[i][j + 1] = min(dp[i][j], dp[i][j + 1])
        else:
            dp[i][j + 1] = min(dp[i][j] + 1, dp[i][j + 1])

print(dp[H - 1][W - 1])
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
p = list(map(int,input().split()))
want = sum(p[0:K])

for i in range(1,N-K+1):
    a = sum(p[i:i+K])
    want = max(a,want)

print((K+want)/2)

Fixed submission:
N,K = map(int,input().split())
p = list(map(int,input().split()))
want = sum(p[0:K])
change = sum(p[0:K])

for i in range(1,N-K+1):
    change = change - p[i-1] + p[i+K-1]
    want = max(change,want)

print((K+want)/2)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
move = []
for i in range(N):
    X,L = map(int,input().split())
    move.append([X-L,X+L])
move = sorted(move, key=lambda x:(x[0],x[1]))

if N == 1:
    print(1)
else:    
    i = 1
    while(len(move) > i):
        if move[i-1][0] == move[i][0]:
            del move[i-1]
        else:
            if move[i][1] <= move[i-1][1]:
                del move[i]
            else:
                i += 1
    
    if len(move) <= 2:
        print(len(move))
    else:
        i = 1
        while(len(move) > i+1):
            if move[i-1][1] >= move[i+1][0]:
                del move[i]
            else:
                i += 1
        print(len(move))

Fixed submission:
N = int(input())
K = []
for i in range(N):
    X,L = map(int,input().split())
    K.append([X-L,X+L])

T = sorted(K,key=lambda x:x[1])
a = T[0][1]

c = 1
for i in range(1,N):
    if T[i][0] >= a:
        c += 1
        a = T[i][1]
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
move = []
for i in range(N):
    X,L = map(int,input().split())
    move.append([X-L,X+L])
move.sort()

if N == 1:
    print(1)
else:    
    i = 1
    while(len(move) > i):
        if move[i-1][0] == move[i][0]:
            if move[i-1][1] >= move[i][1]:
                del move[i]
            else:
                del move[i-1]
        else:
            if move[i][1] <= move[i-1][1]:
                del move[i]
            else:
                i += 1
    
    if len(move) <= 2:
        print(len(move))
    else:
        i = 1
        while(len(move) > i+1):
            if move[i-1][1] >= move[i+1][0]:
                del move[i]
            else:
                i += 1
        print(len(move))

Fixed submission:
N = int(input())
K = []
for i in range(N):
    X,L = map(int,input().split())
    K.append([X-L,X+L])

T = sorted(K,key=lambda x:x[1])
a = T[0][1]

c = 1
for i in range(1,N):
    if T[i][0] >= a:
        c += 1
        a = T[i][1]
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list( map(int, input().split() ) )
kai = 1
M = 10**9+7
result = 0
for i in range(1,N):
    kai *= i

for i in range(N-1):
    result += ((kai//(i+1))%M) * (a[N-1] - a[i])

print( result%M )

Fixed submission:
N = int(input())
d = list( map(int, input().split() ) )
kai = 1
mod = 10**9+7
result = 0

def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

for i in range(1,N):
    kai = (kai%mod)*i

for i in range(N-1):    
    result += ( kai * (d[N-1] - d[i]) * modinv(i+1) ) % mod 

print( result%mod )

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list( map(int, input().split() ) )
kai = 1
M = 10**9+7
result = 0
for i in range(1,N):
    kai *= i
    
for i in range(N-1):
    result += kai * (a[N-1] - a[i]) // ( i+1 )
    result = result%M

print( result )

Fixed submission:
N = int(input())
d = list( map(int, input().split() ) )
kai = 1
mod = 10**9+7
result = 0

def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

for i in range(1,N):
    kai = (kai%mod)*i

for i in range(N-1):    
    result += ( kai * (d[N-1] - d[i]) * modinv(i+1) ) % mod 

print( result%mod )

Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list( map(int, input().split() ) )
result = float()
for i in range(N-1):
    result += (a[N-1] - a[i]) / ( i+1 )

for i in range(1,N):
    result *= i

if result.is_integer():
    result = int(result)
else:
    result = int(result)+1
    
print( result % (10**9+7) )

Fixed submission:
N = int(input())
d = list( map(int, input().split() ) )
kai = 1
mod = 10**9+7
result = 0

def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

for i in range(1,N):
    kai = (kai%mod)*i

for i in range(N-1):    
    result += ( kai * (d[N-1] - d[i]) * modinv(i+1) ) % mod 

print( result%mod )
Buggy python submission (verdict: Time Limit Exceeded):
A,B,K = map(int,input().split())
while(K > 0):
    if A > 0:
        A -= 1
    else:
        B -= 1
    K -= 1
print(A,B)

Fixed submission:
A,B,K = map(int,input().split())
if A >= K:
    print(A - K,B)
else:
    print(0, max( B - (K - A),0 )  )
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))

if 1 in A:
    num = 1
    c = len(A)
    while(len(A) > num):
        if A[num-1] == num:
            num += 1
        else:
            del A[num-1]
    print(c - len(A))
else:
    print(-1)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))

if 1 in A:
    num = 1
    c = 0
    d = len(A)
    for i in range(N):
        if A[i] == num:
            num += 1
            c += 1 
    print(d - c)
else:
    print(-1)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))

if i in A:
    num = 1
    c = len(A)
    while(len(A) > num):
        if A[num-1] == num:
            num += 1
        else:
            del A[num-1]
    print(c - len(A))
else:
    print(-1)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))

if 1 in A:
    num = 1
    c = 0
    d = len(A)
    for i in range(N):
        if A[i] == num:
            num += 1
            c += 1 
    print(d - c)
else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
N = int(input())
say = []
for i in range(N):
    A = int(input())
    t = []
    for j in range(A):
        s = list(map(int,input().split()))
        t.append(s)
    say.append(t)

a = 0
for i in range(2**N):
    judge = 1
    c = 0
    
    for j in range(N):
        if judge = 0:
            break
        if ((i >> j) & 1):
            for k in range(len(say[j])):
                if ((i>>(say[j][k][0]-1))&1) != say[j][k][1]:
                    judge = 0
        else:
            for k in range(len(say[j])):
                if ((i>>(say[j][k][0]-1))&1) == say[j][k][1]:
                    judge = 0
    
    if judge:
        c = bin(i).count("1")
        a = max(a,c)
print(a)

Fixed submission:
N = int(input())
say = []
for i in range(N):
    A = int(input())
    t = []
    for j in range(A):
        s = list(map(int,input().split()))
        t.append(s)
    say.append(t)

a = 0
for i in range(2**N):
    judge = 1 
    
    for j in range(N):
        if judge == 0:
            break
        if ((i >> j) & 1):
            for k in range(len(say[j])):
                if ((i>>(say[j][k][0]-1))&1) != say[j][k][1]:
                    judge = 0
    
    if judge:
        c = bin(i).count("1")
        a = max(a,c)
print(a)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
ans = 0
mod = 10**9+7

for i in range(N):
    for j in range(i+1,N):
        ans += (A[i]^A[j]) % mod
        ans = ans%mod
print(ans)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
ans = 0
mod = 10**9+7
c = [0]*62

for i in range(N):
    a = format(A[i],'b')
    a = a[::-1]
    for j in range(len(a)):
        if a[j] == '1':
            c[j] += 1

k = 1
for i in range(len(c)):
    p = c[i]*(N-c[i])
    ans += k*(p % mod) % mod
    k = k*2 % mod

print(ans%mod)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list( input("") )
A = list(set(S))
result = []
for i in A:
    for j in range(S.index(i)+1 , N):
        for k in range(j+1, N):
            result.append(i + S[j] + S[k])
c = list(set(result))
print(len(c))

Fixed submission:
N = int(input())
S = list( input("") )
A =  set(S)
count = 0
for i in A:
    b = S.index(i) + 1
    B = set(S[b:])
    for j in B:
        c = S[b:].index(j) + 1
        C = set(S[b:][c:])
        count += len(C)
print(count)
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input("")
result = ""
size = len(S)
for i in range(size):
    if i + N < size:
        result += S[i + N]
    else:
        result += S[i + N - size]
print(result)

Fixed submission:
alph_list= ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
N = int(input())
S = input("")
ans = str()
for i in range(len(S)):
    t = alph_list.index(S[i]) + N
    if t < len(alph_list):
        ans += alph_list[t]
    else:
        ans += alph_list[t - len(alph_list)]
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input("")
result = str()
size = len(S)
for i in range(size):
    if i + N < size:
        result += S[i + N]
    else:
        result += S[i + N - size]
print(result)

Fixed submission:
alph_list= ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
N = int(input())
S = input("")
ans = str()
for i in range(len(S)):
    t = alph_list.index(S[i]) + N
    if t < len(alph_list):
        ans += alph_list[t]
    else:
        ans += alph_list[t - len(alph_list)]
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input("")
result = str()
size = len(S)
for i in range(size):
    if i + N < size:
        result += S[i + N]
    else:
        result += S[i + N - size]
print(result

Fixed submission:
alph_list= ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
N = int(input())
S = input("")
ans = str()
for i in range(len(S)):
    t = alph_list.index(S[i]) + N
    if t < len(alph_list):
        ans += alph_list[t]
    else:
        ans += alph_list[t - len(alph_list)]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int( input() )
s_list = [ int(i) for i in input().split() ]
for i in range( 1, N+1):
    print(s_list.index(i) + 1,end=" ")

Fixed submission:
N = int( input() )
s_list = [ int(i) for i in input().split() ]
b = [0] * (10**5)
for i in range( N ):
    b[s_list[i]-1] = i + 1
for i in b:
    if i == 0:
        break
    else:
        print(i,end = " ")

Buggy python submission (verdict: Time Limit Exceeded):
N = int( input() )
s_list = [ int(i) for i in input().split() ]
for i in range( 1, N+1):
    print(s_list.index(i)+1,end=" ")

Fixed submission:
N = int( input() )
s_list = [ int(i) for i in input().split() ]
b = [0] * (10**5)
for i in range( N ):
    b[s_list[i]-1] = i + 1
for i in b:
    if i == 0:
        break
    else:
        print(i,end = " ")
Buggy python submission (verdict: Runtime Error):
weather_list = ["Sunny", "Cloudy", "Rainy"]
a = input("")
print( weather_list[ weather_list.index(a) + 1 ] )


Fixed submission:
weather_list = ["Sunny", "Cloudy", "Rainy"]
a = input("")
print( weather_list[ ( weather_list.index(a) + 1 ) % 3  ] )

Buggy python submission (verdict: Runtime Error):
weather_list = ["sunny", "cloudy", "rainy"]
a = input("")
print( weather_list[ weather_list.index(a) + 1 ] )


Fixed submission:
weather_list = ["Sunny", "Cloudy", "Rainy"]
a = input("")
print( weather_list[ ( weather_list.index(a) + 1 ) % 3  ] )

Buggy python submission (verdict: Runtime Error):
weather_list = ["sunny", "cloudy", "rainy"]
a = input("")
print( wether_list[ weather_list.index(a) + 1 ] )

Fixed submission:
weather_list = ["Sunny", "Cloudy", "Rainy"]
a = input("")
print( weather_list[ ( weather_list.index(a) + 1 ) % 3  ] )
Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
A = list(map(int,input().split()))
A.sort(reverse=True)

if N == 1:
    print(A[0]//(2**M))
else:
    for i in range(M):
        A[0] = A[0]//2
        j = 0
        while(A[j]<A[j+1]):
            t = A[j]
            A[j] = A[j+1]
            A[j+1] = t
            j += 1
            if j == N-1:
                break
    print(sum(A))

Fixed submission:
import sys

N,M = map(int,input().split())
A = list(map(int,input().split()))
A.sort(reverse=True)
m = A[0]
seg = [1]

t = 1
while(True):
    t *= 2
    if t > m:
        break
    seg.append(t)

c = 0
for i in range(-1,-len(seg)-1,-1):
    for j in range(N):
        if A[j] < seg[i]:
            break
        A[j] = A[j]//2
        c += 1
        if c == M:
            print(sum(A))
            sys.exit()
    A.sort(reverse=True)

print(sum(A))
Buggy python submission (verdict: Time Limit Exceeded):
N = int( input() )
h_list = list( map( int, input().split() ) )
h_list.append(10**10)
a = 0
new = 0
for i in range(N):
    j = i
    while(h_list[j] >= h_list[j + 1]):
        new += 1
        j += 1
    a = max(a,new)
    new = 0
print(a)

Fixed submission:
N = int( input() )
h_list = list( map( int, input().split() ) )
h_list.append(10**10)
a = 0
new = 0
j = -1
for i in range(N):
    if j + 1 == i: 
        j = i
        while(h_list[j] >= h_list[j + 1]):
            new += 1
            j += 1
        a = max(a,new)
        new = 0
print(a)
Buggy python submission (verdict: Time Limit Exceeded):
N = int( input() )
char_list = []
counter = 0 
for i in range(N):
    c = sorted( input() )
    char_list.append(c)
for i in range(N):
    for j in range(i+1, N):
        if char_list[i] == char_list[j]:
            counter += 1
print(counter)

Fixed submission:
import collections
N = int( input() )
char_list = []
ans = 0 
for i in range(N):
    c = sorted( input() ) 
    c_new = "".join(c)
    char_list.append(c_new)
    
t = collections.Counter(char_list)

for i in t.values():
    if i != 1:
        ans += int( ( i * (i - 1) ) / 2 )
        
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int( input() )
c_list = []
for i in range(N):
    c_list.append( int( input() ) )
    
a = c_list[:]
a.sort()

for i in range(N):
    t = c_list[i]
    a_copy = a[:]
    a_copy.remove(t)
    print( a_copy[N - 2] )

Fixed submission:
N = int( input() )
c_list = []
for i in range(N):
    c_list.append( int( input() ) )
    
a = c_list[:]
a.sort()
ma = a[ N - 1 ]

for i in range(N):
    t = c_list[i]
    if t == ma:
        print(a[N - 2])
    else:
        print(ma)

Buggy python submission (verdict: Time Limit Exceeded):
N = int( input() )
c_list = []
for i in range(N):
    c_list.append( int( input() ) )
for i in range(N):
    a = c_list[:]
    del a[i]
    print( max(a) )

Fixed submission:
N = int( input() )
c_list = []
for i in range(N):
    c_list.append( int( input() ) )
    
a = c_list[:]
a.sort()
ma = a[ N - 1 ]

for i in range(N):
    t = c_list[i]
    if t == ma:
        print(a[N - 2])
    else:
        print(ma)
Buggy python submission (verdict: Time Limit Exceeded):
import math
L,R = map( int,input().split() )
ans = ( L * (L+1) ) % 2019  
for i in range(L,R):
    if ans == 0:
        break
    j = i + 1
    a = ( i * j ) % 2019
    ans = min(a, ans)
    plus = i % 2019
    while(True):
        over = math.ceil( ( 2019 - a ) / plus )
        j = j + over
        if j > R:
            break
        a = ( i * j) % 2019
        ans = min(a,ans)
print(ans)

Fixed submission:
import math
L,R = map( int,input().split() )
ans = ( L * (L+1) ) % 2019  
for i in range(L,R):
    if ans == 0:
        break
    j = i + 1
    a = ( i * j ) % 2019
    ans = min(a, ans)
    plus = i % 2019
    while(True):
        over = math.ceil( ( 2019 - a ) / plus )
        j = j + over
        if j > R:
            break
        a = ( i * j) % 2019
        ans = min(a,ans)
        if ans == 0:
            break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
L,R = map( int,input().split() )
ans = ( L * (L+1) ) % 2019  
for i in range(L,R):
    if ans == 0:
        break
    j = i + 1
    a = ( i * j ) % 2019
    ans = min(a, ans)
    plus = i % 2019
    while(True):
        over = int( ( 2019 - a ) / plus )
        j = j + over
        if j >= R:
            break
        a = ( i * j) % 2019
        ans = min(a,ans)
print(ans)

Fixed submission:
import math
L,R = map( int,input().split() )
ans = ( L * (L+1) ) % 2019  
for i in range(L,R):
    if ans == 0:
        break
    j = i + 1
    a = ( i * j ) % 2019
    ans = min(a, ans)
    plus = i % 2019
    while(True):
        over = math.ceil( ( 2019 - a ) / plus )
        j = j + over
        if j > R:
            break
        a = ( i * j) % 2019
        ans = min(a,ans)
        if ans == 0:
            break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
L,R = map( int,input().split() )
ans = ( L * (L+1) ) % 2019  
for i in range(L,R):
    if ans == 0:
        break
    for j in range(i+1, R+1):
        ans = min( ( i * j ) %2019,ans)
print(ans)

Fixed submission:
import math
L,R = map( int,input().split() )
ans = ( L * (L+1) ) % 2019  
for i in range(L,R):
    if ans == 0:
        break
    j = i + 1
    a = ( i * j ) % 2019
    ans = min(a, ans)
    plus = i % 2019
    while(True):
        over = math.ceil( ( 2019 - a ) / plus )
        j = j + over
        if j > R:
            break
        a = ( i * j) % 2019
        ans = min(a,ans)
        if ans == 0:
            break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
L,R = map( int,input().split() )
ans = ( L * (L+1) ) % 2019  
for i in range(L,R):
    for j in range(i+1, R+1):
        ans = min( ( i * j ) %2019,ans)
print(ans)

Fixed submission:
import math
L,R = map( int,input().split() )
ans = ( L * (L+1) ) % 2019  
for i in range(L,R):
    if ans == 0:
        break
    j = i + 1
    a = ( i * j ) % 2019
    ans = min(a, ans)
    plus = i % 2019
    while(True):
        over = math.ceil( ( 2019 - a ) / plus )
        j = j + over
        if j > R:
            break
        a = ( i * j) % 2019
        ans = min(a,ans)
        if ans == 0:
            break
print(ans)
Buggy python submission (verdict: Runtime Error):
mod = 10**9+7
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

def combi(n,r,mod=10**9+7):
    fac = [0]*(n+1)
    fac[0] = 1
    fac[1] = 1
    for i in range(2,n+1):
        fac[i] = fac[i-1] * i % mod
    return( ( fac[n] * modinv(fac[r]) )%mod * modinv(fac[n-r]) % mod)

N,K = map(int,input().split())
for j in range(1,K+1):
    print(combi(N-K+1,j) * combi(K-1,j-1) % mod)

Fixed submission:
mod = 10**9+7
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

N,K = map(int,input().split())

fac = [0]*(N+1)
fac[0] = 1
fac[1] = 1
for i in range(2,N+1):
    fac[i] = fac[i-1] * i % mod

def combi(n,r,mod=10**9+7):
    return( ( fac[n] * modinv(fac[r]) )%mod * modinv(fac[n-r]) % mod)

for j in range(1,K+1):
    if N - K + 1 < j:
        print(0)
    else:
        print(combi(N-K+1,j) * combi(K-1,j-1) % mod)

Buggy python submission (verdict: Runtime Error):
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

def combi(n,r,mod=10**9+7):
    fac = [0]*(n+1)
    fac[0] = 1
    fac[1] = 1
    for i in range(2,n+1):
        fac[i] = fac[i-1] * i % mod
    return( ( fac[n] * modinv(fac[r]) )%mod * modinv(fac[n-r]) % mod)

N,K = map(int,input().split())
for j in range(1,K+1):
    print(combi(N-K+1,j) * combi(K-1,j-1) % mod)

Fixed submission:
mod = 10**9+7
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

N,K = map(int,input().split())

fac = [0]*(N+1)
fac[0] = 1
fac[1] = 1
for i in range(2,N+1):
    fac[i] = fac[i-1] * i % mod

def combi(n,r,mod=10**9+7):
    return( ( fac[n] * modinv(fac[r]) )%mod * modinv(fac[n-r]) % mod)

for j in range(1,K+1):
    if N - K + 1 < j:
        print(0)
    else:
        print(combi(N-K+1,j) * combi(K-1,j-1) % mod)

Buggy python submission (verdict: Runtime Error):
mod = 10**9+7
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

def combi(n,r,mod=10**9+7):
    fac = [0]*(n+1)
    fac[0] = 1
    fac[1] = 1
    for i in range(2,n+1):
        fac[i] = fac[i-1] * i % mod
    return( ( fac[n] * modinv(fac[r]) )%mod * modinv(fac[n-r]) % mod)

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


Fixed submission:
mod = 10**9+7
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

N,K = map(int,input().split())

fac = [0]*(N+1)
fac[0] = 1
fac[1] = 1
for i in range(2,N+1):
    fac[i] = fac[i-1] * i % mod

def combi(n,r,mod=10**9+7):
    return( ( fac[n] * modinv(fac[r]) )%mod * modinv(fac[n-r]) % mod)

for j in range(1,K+1):
    if N - K + 1 < j:
        print(0)
    else:
        print(combi(N-K+1,j) * combi(K-1,j-1) % mod)
Buggy python submission (verdict: Time Limit Exceeded):
#木の根を得る
def root(x):
    while par[x] >= 0:
        x = par[x]
    return x

#木の併合
def unite(x, y):
    rx = root(x)
    ry = root(y)
    if rx != ry:
        if rx > ry:
            rx, ry = ry, rx
        par[rx] += par[ry]
        par[ry] = rx

N, M = map(int,input().split())
par = [-1]*N
K = []
for i in range(M):
    a, b = map(int, input().split())
    K.append([a-1, b-1])
K = K[::-1]

result = [0]
for i, j in K:
    unite(i, j)
    ans = 0
    for l in range(N):
        if root(l) == l:
            t = par[l]*(-1)
            ans += t*(t-1)//2
    result.append(ans)

result = result[::-1]
for i in result[1:]:
    print(result[0] - i)

Fixed submission:
#木の根を得る
def root(x):
    while par[x] >= 0:
        x = par[x]
    return x

#木の併合
def unite(x, y):
    rx = root(x)
    ry = root(y)
    if rx != ry:
        if rx > ry:
            rx, ry = ry, rx
        par[rx] += par[ry]
        par[ry] = rx

def size(x):
    return -par[root(x)]

def same(x, y):
    rx = root(x)
    ry = root(y)
    return rx == ry

N, M = map(int,input().split())
par = [-1]*N
K = []
for i in range(M):
    a, b = map(int, input().split())
    K.append([a-1, b-1])
K = K[::-1]

result = [0]
ans = 0
for i, j in K:
    if not same(i, j):
        a = size(i)
        b = size(j)
        unite(i, j)
        c = size(i)
        ans += c*(c-1)//2 - (a*(a-1)//2 + b*(b-1)//2)
    result.append(ans)

result = result[::-1]
for i in result[1:]:
    print(result[0] - i)
Buggy python submission (verdict: Runtime Error):
N = int(input())
happy = []
result = [[0 for i in range(3)] for j in range(N)]

for i in range(3):
    t = list( map( int, input().split() ) )
    happy.append(t)

for i in range(3):
    result[0][i] = happy[0][i] 

for i in range(1,N):
    for j in range(3):
        result[i][j] = max( [ result[i-1][k] + happy[i][j] for k in range(3) if k != j ] )

print( max( result[N-1] ) )

Fixed submission:
N = int(input())
happy = []
result = [[0 for i in range(3)] for j in range(N)]

for i in range(N):
    t = list( map( int, input().split() ) )
    happy.append(t)

for i in range(3):
    result[0][i] = happy[0][i] 

for i in range(1,N):
    for j in range(3):
        result[i][j] = max( [ result[i-1][k] + happy[i][j] for k in range(3) if k != j ] )

print( max( result[N-1] ) )