Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys

n,k = map(int,input().split())
a = list(map(int,input().split()))
dp = [sys.maxsize]*(n)
dp[0] = 0
for i in range(n):
  for j in range(i+1,k+i+1):
    if j<n:
      dp[j] = min(dp[j],dp[i]+abs(a[i]-a[j]))

print(dp[n-1])

 

Fixed submission:
import sys

n,k = map(int,input().split())
a = list(map(int,input().split()))
dp = [sys.maxsize]*(n)
dp[0] = 0
for i in range(n):
  for j in range(i+1,k+i+1):
    if j<n:
      dp[j] = min(dp[j],dp[i]+abs(a[i]-a[j]))

print(dp[n-1])

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

n,k = map(int,input().split())
a = list(map(int,input().split()))
dp = [sys.maxsize]*(n)
dp[0] = 0
for i in range(n):
  for j in range(i+1,i+k+1):
    if j<n:
      dp[j] = min(dp[j],dp[i]+abs(a[i]-a[j]))

print(dp[n-1])

 

Fixed submission:
import sys

n,k = map(int,input().split())
a = list(map(int,input().split()))
dp = [sys.maxsize]*(n)
dp[0] = 0
for i in range(n):
  for j in range(i+1,k+i+1):
    if j<n:
      dp[j] = min(dp[j],dp[i]+abs(a[i]-a[j]))

print(dp[n-1])
Buggy python submission (verdict: Runtime Error):
n = int(input())


days = [] 
for _ in range(n):
  temp = list(map(int,input().split()))
  days.append(temp)
  
dp = [0]*n

for i in range(3):
  dp[i]= days[0][i]
#print(dp) 
for cur_day in range(1,n):
  m = [0]*n
  for i in range(3):
    for j in range(3):
      if i!=j:
        m[i] = max(m[i],dp[j]+days[cur_day][i])
  dp = m
#  print(dp)
  
print(max(dp))
  

Fixed submission:
n = int(input())

days=[]
dp = [0]*3
for _ in range(n):
  a = list(map(int,input().split()))
  days.append(a)

for i in range(3):
  dp[i]=days[0][i]
  
#rint(dp)
for cday in range(1,n):
  pday = cday-1
  t = [0]*3
  for i in range(3):
    max_val = dp[i]
    for j in range(3):
      if i!=j:
        cur_val = dp[j] + days[cday][i]
        if cur_val>max_val:
          max_val=cur_val
    
    t[i] = max_val
  dp=t
  #rint(dp)
  	
print(max(dp))

Buggy python submission (verdict: Runtime Error):
n = int(input())


days = [] 
for _ in range(n):
  temp = list(map(int,input().split()))
  days.append(temp)
  
dp = [0]*n

for i in range(3):
  dp[i]= days[0][i]
#print(dp) 
for cur_day in range(1,n):
  m = [0]*n
  for i in range(3):
    for j in range(3):
      if i!=j:
        m[j] = max(m[j],dp[j]+days[cur_day][i])
  dp = m
#  print(dp)
  
print(max(dp))
  

Fixed submission:
n = int(input())

days=[]
dp = [0]*3
for _ in range(n):
  a = list(map(int,input().split()))
  days.append(a)

for i in range(3):
  dp[i]=days[0][i]
  
#rint(dp)
for cday in range(1,n):
  pday = cday-1
  t = [0]*3
  for i in range(3):
    max_val = dp[i]
    for j in range(3):
      if i!=j:
        cur_val = dp[j] + days[cday][i]
        if cur_val>max_val:
          max_val=cur_val
    
    t[i] = max_val
  dp=t
  #rint(dp)
  	
print(max(dp))

Buggy python submission (verdict: Runtime Error):
n = int(input())


days = [] 
for _ in range(n):
  temp = list(map(int,input().split()))
  days.append(temp)
  
dp = [0]*n

for i in range(3):
  dp[i]= days[0][i]
#print(dp) 
for cur_day in range(1,n):
  m = [0]*n
  for i in range(3):
    for j in range(3):
      if i!=j:
        m[i] = max(m[i],dp[j]+days[cur_day][j])
  dp = m
#  print(dp)
  
print(max(dp))
  

Fixed submission:
n = int(input())

days=[]
dp = [0]*3
for _ in range(n):
  a = list(map(int,input().split()))
  days.append(a)

for i in range(3):
  dp[i]=days[0][i]
  
#rint(dp)
for cday in range(1,n):
  pday = cday-1
  t = [0]*3
  for i in range(3):
    max_val = dp[i]
    for j in range(3):
      if i!=j:
        cur_val = dp[j] + days[cday][i]
        if cur_val>max_val:
          max_val=cur_val
    
    t[i] = max_val
  dp=t
  #rint(dp)
  	
print(max(dp))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
n,W = map(int,input().split())
wt =[];val=[]

dp = [[0 for i in range(W+1)] for j in range(n)]
for _ in range(n):
  wi , vi= map(int,input().split())
  wt.append(wi)
  val.append(vi)

for i in range(W+1):
  if i>=wt[0]:
    dp[0][i]=val[0]   
  else:
    dp[0][i]=0
    
    
    
#print(dp)  
for i in range(1,n):
  wi = wt[i]
  vi = val[i]
  for w in range(1,W+1):
    if wi <= w:
      dp[i][w] = max(vi + dp[i-1][w-wi] , dp[i-1][w] )
    else:
      dp[i][w] = dp[i-1][w]

print(dp[n-1][W])        
        
        


Fixed submission:
N,W = map(int,input().split())
INF = 10**9+7
NV = (10**3)*N
dp = [[INF for j in range(NV+1)] for i in range(N+1)]
dp[0][0] = 0
for i in range(1,N+1):
    w,v = map(int,input().split())
    for j in range(NV+1):
        if j < v:
            dp[i][j] = dp[i-1][j]
        else:
            dp[i][j] = min(dp[i-1][j], dp[i-1][j-v]+w)
ans = 0
for j in range(NV+1):
    if dp[N][j] <= W:
        ans = j
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,W = map(int,input().split())
wt =[];val=[]

dp = [[0 for i in range(W+1)] for j in range(n)]
for _ in range(n):
  wi , vi= map(int,input().split())
  wt.append(wi)
  val.append(vi)

for i in range(W+1):
  if i>=wt[0]:
    dp[0][i]=val[0]   
  else:
    dp[0][i]=0
    
    
    
#print(dp)  
for i in range(1,n):
  wi = wt[i]
  vi = val[i]
  for w in range(1,W+1):
    if wi <= w:
      dp[i][w] = max(vi + dp[i-1][w-wi] , dp[i-1][w] )
    else:
      dp[i][w] = dp[i-1][w]

print(dp[n-1][W])        
        
        


Fixed submission:
N,W = map(int,input().split())
INF = 10**9+7
NV = (10**3)*N
dp = [[INF for j in range(NV+1)] for i in range(N+1)]
dp[0][0] = 0
for i in range(1,N+1):
    w,v = map(int,input().split())
    for j in range(NV+1):
        if j < v:
            dp[i][j] = dp[i-1][j]
        else:
            dp[i][j] = min(dp[i-1][j], dp[i-1][j-v]+w)
ans = 0
for j in range(NV+1):
    if dp[N][j] <= W:
        ans = j
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,W = map(int,input().split())
wt =[];val=[]

dp = [[0 for i in range(W+1)] for j in range(n)]
for _ in range(n):
  wi , vi= map(int,input().split())
  wt.append(wi)
  val.append(vi)

for i in range(W+1):
  if i>=wt[0]:
    dp[0][i]=val[0]   
  else:
    dp[0][i]=0
    
    
    
#print(dp)  
for i in range(1,n):
  wi = wt[i]
  vi = val[i]
  for w in range(1,W+1):
    if wi <= w:
      dp[i][w] = max(vi + dp[i-1][w-wi] , dp[i-1][w] )
    else:
      dp[i][w] = dp[i-1][w]

print(dp[n-1][W])        
        
        


Fixed submission:
N,W = map(int,input().split())
INF = 10**9+7
NV = (10**3)*N
dp = [[INF for j in range(NV+1)] for i in range(N+1)]
dp[0][0] = 0
for i in range(1,N+1):
    w,v = map(int,input().split())
    for j in range(NV+1):
        if j < v:
            dp[i][j] = dp[i-1][j]
        else:
            dp[i][j] = min(dp[i-1][j], dp[i-1][j-v]+w)
ans = 0
for j in range(NV+1):
    if dp[N][j] <= W:
        ans = j
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
t = input()

n = len(s);m = len(t)

# dp [n+1][m+1]

dp = [[0 for i in range(m+1)] for j in range(n+1)]

for i in range(n+1):
  dp[i][0] = 0
  
for j in range(m+1):
  dp[0][j] = 0
  
for i in range(1,n+1):
  for j in range(1,m+1):
    if s[i-1] == t[j-1]:
      dp[i][j] = 1 + dp[i-1][j-1]
    else:
      dp[i][j] = max(dp[i-1][j], dp[i][j-1])
   
def path():
    ans=""
    ls=n;lt=m
    while ls>0 and lt>0:
        if dp[ls][lt]==dp[ls-1][lt]:
            ls-=1
        elif dp[ls][lt]==dp[ls][lt-1]:
            lt-=1
        else:
            ans=s[ls-1]+ans
            ls-=1
            lt-=1
 
    print(ans)
    
path()
#print(dp)

    
    
    

Fixed submission:
s = input()
t = input()

n = len(s);m = len(t)

# dp [n+1][m+1]

dp = [[0 for i in range(m+1)] for j in range(n+1)]

for i in range(n+1):
  dp[i][0] = 0
  
for j in range(m+1):
  dp[0][j] = 0
  
for i in range(1,n+1):
  for j in range(1,m+1):
    if s[i-1] == t[j-1]:
      dp[i][j] = 1 + dp[i-1][j-1]
    else:
      dp[i][j] = max(dp[i-1][j], dp[i][j-1])
   
def path():
    ans=""
    ls=n;lt=m
    while ls>0 and lt>0:
        if dp[ls][lt]==dp[ls-1][lt]:
            ls-=1
        elif dp[ls][lt]==dp[ls][lt-1]:
            lt-=1
        else:
            ans=s[ls-1]+ans
            ls-=1
            lt-=1
 
    print(ans)
    
path()
#print(dp)
Buggy python submission (verdict: Runtime Error):
n , m = map(int,input().split())

g = [[] for i in range(n)]

dp = [-1] * n
for _ in range(m):
  v1, v2 = map(int,input().split())
  v1-=1 ; v2-=1
  g[v1].append(v2)

def dfs(i):
  if dp[i]!=-1:
    return dp[i]
  temp = 0
  for neighbour in g[i]:
    temp = max(temp, dfs(neighbour) + 1)
  dp[i]=temp
  return temp
  
res = 0
for i in range(n):
  res = max(res, dfs(i))

print(res)

Fixed submission:
import sys
sys.setrecursionlimit(10 ** 9)
n , m = map(int,input().split())

g = [[] for i in range(n)]

dp = [-1] * n
for _ in range(m):
  v1, v2 = map(int,input().split())
  v1-=1 ; v2-=1
  g[v1].append(v2)

def dfs(i):
  if dp[i]!=-1:
    return dp[i]
  temp = 0
  for neighbour in g[i]:
    temp = max(temp, dfs(neighbour) + 1)
  dp[i]=temp
  return temp
  
res = 0
for i in range(n):
  res = max(res, dfs(i))

print(res)

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

g = [[] for i in range(n)]

for _ in range(m):
  v1, v2 = map(int,input().split())
  v1-=1 ; v2-=1
  g[v1].append(v2)

def dfs(i):
  temp = 0
  for neighbour in g[i]:
    temp = max(temp, dfs(neighbour) + 1)
  return temp
  
res = 0
for i in range(n):
  res = max(res, dfs(i))

print(res)

Fixed submission:
import sys
sys.setrecursionlimit(10 ** 9)
n , m = map(int,input().split())

g = [[] for i in range(n)]

dp = [-1] * n
for _ in range(m):
  v1, v2 = map(int,input().split())
  v1-=1 ; v2-=1
  g[v1].append(v2)

def dfs(i):
  if dp[i]!=-1:
    return dp[i]
  temp = 0
  for neighbour in g[i]:
    temp = max(temp, dfs(neighbour) + 1)
  dp[i]=temp
  return temp
  
res = 0
for i in range(n):
  res = max(res, dfs(i))

print(res)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = (int)(input())

for i in range(Q):
    query = (input())
    if query=="1":
        S=S[::-1]
    else:
        query = query.split(" ")
        if query[1] == "1":
            S = query[2]+S
        else:
            S = S+query[2]

print(S)

Fixed submission:
S = input()
Q = (int)(input())

mae = ""
usiro =""

r_num=0

for i in range(Q):
    query = (input())
    if query=="1":
        #kari = mae
        #mae=usiro[::-1]
        #usiro=kari[::-1]
        r_num+=1
    else:
        query = query.split(" ")
        if query[1] == "1":
            if r_num%2==0:
                mae = query[2]+mae
            else:
                usiro += query[2]
        else:
            if r_num %2 ==0:
                usiro += query[2]
            else:
                mae = query[2]+mae
if r_num%2 == 1:
    print(usiro[::-1]+S[::-1]+mae[::-1])
else:
    print(mae+S+usiro)
Buggy python submission (verdict: Runtime Error):
N,M=input().split(" ")
N=(int)(N)
M=(int)(M)

sc={}

for i in range(M):
    sc[i]=-1

check=True

for i in range(M):
    si,ci = input().split(" ")
    si = (int)(si)
    ci = (int)(ci)
    if sc[si-1]!=-1 and sc[si-1]!=ci:
        check = False
        break
    else:
        sc[si-1]=ci
#print(si)
if check and sc[0]!=0:
    ans=""
    if sc[0]==-1:
        ans+= "1"
    else:
        ans+=str(sc[0])
    
    for i in range(M-1):
        if sc[i+1]==-1:
            ans+="0"
        else:
            ans+=(str)(sc[i+1])
    print(ans)
else:
    print(-1)

Fixed submission:
N,M=(input()).split(" ")
N=(int)(N)
M=(int)(M)
sc={}

for i in range(N):
    sc[i]=-1

check=True

for i in range(M):
    s,c=(input()).split(" ")
    s=(int)(s)
    c=(int)(c)
    if sc[s-1]!=-1 and sc[s-1]!=c:
        check = False
        break
    else:
        sc[s-1]=c

if not(check):
    print(-1)
    exit()

if N!=1:
    

    ans=""
    if sc[0]==-1:
        ans+="1"
    elif sc[0]==0:
        print(-1)
        exit()
    else:
        ans+=str(sc[0])

    for i in range(N-1):
        if sc[i+1]==-1:
            ans+="0"
        else:
            ans+=str(sc[i+1])
    print(ans)
else:
    if sc[0]==-1:
        print(0)
    else:
        print(sc[0])
Buggy python submission (verdict: Runtime Error):
N=input()
A=(input()).split()
A.sort()

for i in range(N-1):
  if A[i]==A[i+1]:
    print('NO')
  if i==N-2:
    print('YES')
    
	

Fixed submission:
N=(int)(input())
A=(input()).split()
A.sort()
 
for i in range(N-1):
    if A[i]==A[i+1]:
        print('NO')
        break
    elif i==N-2:
        print('YES')
Buggy python submission (verdict: Time Limit Exceeded):
N,T = input().split(' ')
p = input().split(' ')

def E_cal(i):
    return (i*(i+1))/(2*i)

Es=[]

for i in p:
    Es.append(E_cal((int)(i)))
#print(Es)
TEs_max = 0
for j in range((int)(N)-(int)(T)+1):
    sum_E=0
    for k in range((int)(T)):
        sum_E+=Es[k+j]

    if TEs_max<sum_E:
        TEs_max = sum_E
    #print(sum_E)

print(TEs_max)

Fixed submission:
N,T = input().split(' ')
ps = input().split(' ')
N=(int)(N)
T=(int)(T)

def E_cal(i):
    return (i+1)/2

Es=[]

ruiseki_sum=[0]

for i,p in enumerate(ps):
    Es.append(E_cal((int)(p)))
    ruiseki_sum.append(Es[i]+ruiseki_sum[i])

#print(Es)
#print(ruiseki_sum)
TEs_max = 0

for j in range(N-T+1):
    now = ruiseki_sum[j+T]-ruiseki_sum[j]
    if now>TEs_max:
        TEs_max=now
    #print(now)
print(TEs_max)
Buggy python submission (verdict: Runtime Error):
H,N = (input()).split(" ")
H=(int)(H)
N=(int)(N)
As = (input()).split(" ")

sum=0

for A in As:
  sum+=(int)(A)
  
if sum>=A:
  print("Yes")
else:
  print("No")

Fixed submission:
H,N = (input()).split(" ")
H=(int)(H)
N=(int)(N)
As = (input()).split(" ")
 
sum=0
 
for A in As:
  sum+=(int)(A)
  
if sum>=H:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
N=input()
now=0
for i in range(0,N):
    lr=(input()).split(' ')
    now=now+((int)(lr[1])-(int)(lr[0])+1)

print(now)

Fixed submission:
N=input()
now=0
for i in range(0,(int)(N)):
    lr=(input()).split(' ')
    now=now+((int)(lr[1])-(int)(lr[0])+1)

print(now)
Buggy python submission (verdict: Runtime Error):
N=(int)(input())
p=(input()).split(' ')

count=0


now=1
for k in p:
    if (int)(k)==now:
        p[now-1:(now+1 if now<len(p) else now-3)]=[p[now],p[now-1]]
        count=count+1
    now=now+1

print(count)

Fixed submission:
N=(int)(input())
p=(input()).split(' ')

count=0


now=1
for k in p:
    if (int)(k)==now:
        p[now-1:(now+1 if now<len(p) else now-3)]=[p[now-2],p[now-1]]
        count=count+1
    now=now+1

print(count)

Buggy python submission (verdict: Runtime Error):
N=(int)(input())
p=(input()).split(' ')

count=0


now=1
for k in p:
    if (int)(k)==now:
        p[now-1:now+1]=[p[now],p[now-1]]
        count=count+1
    now=now+1

print(count)

Fixed submission:
N=(int)(input())
p=(input()).split(' ')

count=0


now=1
for k in p:
    if (int)(k)==now:
        p[now-1:(now+1 if now<len(p) else now-3)]=[p[now-2],p[now-1]]
        count=count+1
    now=now+1

print(count)
Buggy python submission (verdict: Runtime Error):
def uq(a,c):
    return c if a%c==0 else uq(c,a%c)

n=(int)(input())

result = 1

for j in range(0,n):
    f=(int)(input())
    result=((result/uq(result,f)))*f
    
print((int)(result))

Fixed submission:
def uq(a,c):
    return c if a%c==0 else uq(c,a%c)

n=(int)(input())

result = 1

for j in range(0,n):
    f=(int)(input())
    result=((result//uq(result,f)))*f
    
print((int)(result))

Buggy python submission (verdict: Runtime Error):
def uq(a,c):
    return c if a%c==0 else uq(c,a%c)

n=(int)(input())

result = 1

for j in range(0,n):
    f=(int)(input())
    result=((result*f/uq(result,f)))
    
print((int)(result))

Fixed submission:
def uq(a,c):
    return c if a%c==0 else uq(c,a%c)

n=(int)(input())

result = 1

for j in range(0,n):
    f=(int)(input())
    result=((result//uq(result,f)))*f
    
print((int)(result))

Buggy python submission (verdict: Runtime Error):
def uq(a,c):
    return c if a%c==0 else uq(c,a%c)

n=(int)(input())
T=[]

for i in range(0,n):
    T.append((int)(input()))

result = 1

for j in T:
    result=(int)((result*j)/uq(result,j))
    
print(result)

Fixed submission:
def uq(a,c):
    return c if a%c==0 else uq(c,a%c)

n=(int)(input())

result = 1

for j in range(0,n):
    f=(int)(input())
    result=((result//uq(result,f)))*f
    
print((int)(result))
Buggy python submission (verdict: Runtime Error):
print("x" * len(int(input())))

Fixed submission:
print("x" * len(input()))
Buggy python submission (verdict: Runtime Error):
a = int(input())
s = int(input())
print(s if a < 3200 else "red")


Fixed submission:
a = int(input())
s = input()
print(s if a >= 3200 else "red")

Buggy python submission (verdict: Runtime Error):
a = int(input())
s = int(input())
print(s if a >= 3200 else "red")


Fixed submission:
a = int(input())
s = input()
print(s if a >= 3200 else "red")
Buggy python submission (verdict: Runtime Error):
cnt = [0] * int(2 * 10e5 + 10)
li = [[] for _ in range(int(2 * 10e5 + 10))]
def f(a):
    global cnt, li
    for c in li[a]:
        cnt[c] += cnt[a]
        f(c)
def solve():
    global cnt, li
    n, q = map(int, input().split())
    for _ in range(n - 1):
        a, b = map(int, input().split())
        li[a].append(b)
    for _ in range(q):
        p, x = map(int, input().split())
        cnt[p] += x
    f(1)
    print(*cnt[1 : n + 1])
solve()


Fixed submission:
def solve():
    cnt = [0] * int(2 * 1e5 + 10)
    li = []
    n, q = map(int, input().split())
    for _ in range(n - 1):
        a, b = map(int, input().split())
        li.append((a, b))
    for _ in range(q):
        p, x = map(int, input().split())
        cnt[p] += x
    for a, b in sorted(li):
        cnt[b] += cnt[a]
    print(*cnt[1 : n + 1])
solve()

Buggy python submission (verdict: Time Limit Exceeded):
cnt = [0] * int(2 * 10e5 + 10)
li = [[] for _ in range(int(2 * 10e5 + 10))]
def f(a):
    global cnt, li
    for c in li[a]:
        cnt[c] += cnt[a]
        f(c)
def solve():
    global cnt, li
    n, q = map(int, input().split())
    for _ in range(n - 1):
        a, b = map(int, input().split())
        li[a].append(b)
    for _ in range(q):
        p, x = map(int, input().split())
        cnt[p] += x
    f(1)
    print(*cnt[1 : n + 1])
solve()


Fixed submission:
def solve():
    cnt = [0] * int(2 * 1e5 + 10)
    li = []
    n, q = map(int, input().split())
    for _ in range(n - 1):
        a, b = map(int, input().split())
        li.append((a, b))
    for _ in range(q):
        p, x = map(int, input().split())
        cnt[p] += x
    for a, b in sorted(li):
        cnt[b] += cnt[a]
    print(*cnt[1 : n + 1])
solve()
Buggy python submission (verdict: Runtime Error):
def solve():
    n = int(input())
    A = list(map(int, input().split()))
    for i in range(n // 2, 1, -1):
        cnt = 0
        for j in range(n // i, 1, -1):
            if A[i] != (len([1 for k in range(i, n + 1, j) if A[k] == 1]) & 1):
                A[i] = 1 - A[i]
                cnt += 1
        if cnt > 1:
            print(-1)
            return
    if A[0] != (sum(A) & 1):
        A[0] = 1 - A[0]
    print(sum(A))
    print(*list(A[i] for i in range(n) if A[i]))
solve()


Fixed submission:
def solve():
    n = int(input())
    A = [0] + list(map(int, input().split()))
    for i in range(n // 2, 0, -1):
        t = len([1 for k in range(i, n + 1, i) if A[k] == 1]) & 1
        if A[i] != t:
            A[i] = 1 - A[i]
    print(sum(A))
    print(*list(i for i in range(1, n + 1) if A[i]))
solve()
Buggy python submission (verdict: Runtime Error):
from math import factorial
C = lambda y, x: factorial(y) // factorial(x) // factorial(y - x)
mod = 1000000007
def solve():
    n, k = map(int, input().split())
    for i in range(1, k + 1):
        print(C(n - k + 1, i) * C(k - 1, i - 1) % mod)
solve()


Fixed submission:
from math import factorial
C = lambda y, x: factorial(y) // factorial(x) // factorial(y - x)
mod = 1000000007
def solve():
    n, k = map(int, input().split())
    for i in range(1, k + 1):
        if i <= (n - k) + 1:
            print(C(n - k + 1, i) * C(k - 1, i - 1) % mod)
        else:
            print(0)
solve()

Buggy python submission (verdict: Time Limit Exceeded):
mod = 1000000007
def comb(n, r):
    if r < 1:
        return 1
    if r < n - r:
        r = n - r
    ans = 1
    for i, a in enumerate(range(n, n - r, -1), 1):
        ans *= a % mod
        ans //= i
    return ans % mod
def solve():
    n, k = map(int, input().split())
    for i in range(1, k + 1):
        print(comb(n - k + 1, i) * comb(k - 1, i - 1) % mod)
solve()


Fixed submission:
from math import factorial
C = lambda y, x: factorial(y) // factorial(x) // factorial(y - x)
mod = 1000000007
def solve():
    n, k = map(int, input().split())
    for i in range(1, k + 1):
        if i <= (n - k) + 1:
            print(C(n - k + 1, i) * C(k - 1, i - 1) % mod)
        else:
            print(0)
solve()
Buggy python submission (verdict: Runtime Error):
from math import *
lcm = lambda x, y: x * y // gcd(x, y)
def solve():
    a, b, c, d = map(int, input().split())
    C = len(range(ceil(a / c) * c, b + 1, c))
    D = len(range(ceil(a / d) * d, b + 1, d))
    cd = lcm(c, d)
    CD = len(range(ceil(a / cd) * cd, b + 1, cd))
    print(b - a + 1 - (C + D - CD))
solve()


Fixed submission:
from fractions import gcd
from math import ceil
lcm = lambda x, y: x * y // gcd(x, y)
def solve():
    a, b, c, d = map(int, input().split())
    if c == 1 or d == 1:
        return 0
    def f(x):
        return len(range(ceil(a / x) * x, b + 1, x))
    C = f(c)
    if c == d:
        return b - a + 1 - C
    D = f(d)
    cd = lcm(c, d)
    CD = f(cd)
    return b - a + 1 - (C + D - CD)
print(solve())
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
from itertools import permutations
def solve():
    n = int(input())
    XY = [list(map(int, input().split())) for _ in range(n)]
    m = defaultdict(int)
    for i, j in permutations(range(n), 2):
        m[(XY[i][0] - XY[j][0], XY[i][1] - XY[j][1])] += 1
    print(n - max(m.items(), key=lambda x: x[1])[1])
solve()


Fixed submission:
from collections import defaultdict
from itertools import permutations
def solve():
    n = int(input())
    XY = [list(map(int, input().split())) for _ in range(n)]
    if n == 1:
        return 1
    m = defaultdict(int)
    for i, j in permutations(range(n), 2):
        m[(XY[i][0] - XY[j][0], XY[i][1] - XY[j][1])] += 1
    return n - max(m.items(), key=lambda x: x[1])[1]
print(solve())

Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
from itertools import combinations
def solve():
    n = int(input())
    XY = [list(map(int, input().split())) for _ in range(n)]
    m = defaultdict(int)
    for i, j in combinations(range(n), 2):
        m[(XY[i][0] - XY[j][0], XY[i][1] - XY[j][1])] += 1
        m[(XY[j][0] - XY[i][0], XY[j][1] - XY[i][1])] += 1
    print(n - max(m.items(), key=lambda x: x[1])[1])
solve()


Fixed submission:
from collections import defaultdict
from itertools import permutations
def solve():
    n = int(input())
    XY = [list(map(int, input().split())) for _ in range(n)]
    if n == 1:
        return 1
    m = defaultdict(int)
    for i, j in permutations(range(n), 2):
        m[(XY[i][0] - XY[j][0], XY[i][1] - XY[j][1])] += 1
    return n - max(m.items(), key=lambda x: x[1])[1]
print(solve())

Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
from itertools import combinations
def solve():
    n = int(input())
    XY = [list(map(int, input().split())) for _ in range(n)]
    m = defaultdict(int)
    for i, j in combinations(range(n), 2):
        m[(XY[i][0] - XY[j][0], XY[i][1] - XY[j][1])] += 1
    print(n - max(m.items(), key=lambda x: x[1])[1])
solve()


Fixed submission:
from collections import defaultdict
from itertools import permutations
def solve():
    n = int(input())
    XY = [list(map(int, input().split())) for _ in range(n)]
    if n == 1:
        return 1
    m = defaultdict(int)
    for i, j in permutations(range(n), 2):
        m[(XY[i][0] - XY[j][0], XY[i][1] - XY[j][1])] += 1
    return n - max(m.items(), key=lambda x: x[1])[1]
print(solve())
Buggy python submission (verdict: Runtime Error):
print((int(input() - 2) * 180)

Fixed submission:
print((int(input()) - 2) * 180)