Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n,m = (int(x) for x in input().split())
memo = [0]*n
pena = [0]*n
ans2 = 0
for i in range(m):
    p,s = (str(x) for x in input().split())
    p = int(p)
    if s=="AC":
        memo[p-1] = 1
    elif s=="WA":
        if memo[p-1]==0:
            pena[p-1] += 1

for j in range(p):
    if memo[j]==1:
        ans2 += pena[j]

print("{} {}".format(sum(memo),ans2))

Fixed submission:
n,m = (int(x) for x in input().split())
memo = [0]*n
pena = [0]*n
ans2 = 0
for i in range(m):
    p,s = (str(x) for x in input().split())
    p = int(p)
    if s=="AC":
        memo[p-1] = 1
    elif s=="WA":
        if memo[p-1]==0:
            pena[p-1] += 1

for j in range(n):
    if memo[j]==1:
        ans2 += pena[j]

print("{} {}".format(sum(memo),ans2))

Buggy python submission (verdict: Runtime Error):
n,m = (int(x) for x in input().split())
memo = [0]*n
pena = [0]*n
ans2 = 0
for i in range(m):
    p,s = (str(x) for x in input().split())
    p = int(p)
    if s=="AC":
        memo[p-1] = 1
    elif s=="WA":
        if memo[p-1]==0:
            pena[p-1] += 1

for j in range(p):
    if memo[j]==1:
        ans2 += pena[j]

print("{} {}".format(sum(memo),ans2))

Fixed submission:
n,m = (int(x) for x in input().split())
memo = [0]*n
pena = [0]*n
ans2 = 0
for i in range(m):
    p,s = (str(x) for x in input().split())
    p = int(p)
    if s=="AC":
        memo[p-1] = 1
    elif s=="WA":
        if memo[p-1]==0:
            pena[p-1] += 1

for j in range(n):
    if memo[j]==1:
        ans2 += pena[j]

print("{} {}".format(sum(memo),ans2))
Buggy python submission (verdict: Runtime Error):
import fractions

input = sys.stdin.readline

a,b = (int(x) for x in input().split())

if a>9 or b>9:
    print(-1)
else:
    print(a*b)


Fixed submission:
import sys
 
input = sys.stdin.readline
 
a,b = (int(x) for x in input().split())
 
if a>9 or b>9:
    print(-1)
else:
    print(a*b)
Buggy python submission (verdict: Runtime Error):
import fractions
import math
import os

input = sys.stdin.readline

n = int(input())

for i in range(1,9):
    if n%i==0:
        if n//i<=9:
            print("Yes")
            exit()
print("No")


Fixed submission:
import sys
import math
import os

input = sys.stdin.readline

n = int(input())

for i in range(1,10):
    if n%i==0:
        if n//i<=9:
            print("Yes")
            exit()
print("No")
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [int(i) for i in input().split()]

i = 0
person = [0,0,0,0,0,0,0,0]
ans = []
for k in a:
    i += 1
    person[k-1] = i

a.sort()
for l in a:
    ans.append(str(person[l-1]))

order = ' '.join(ans)
print(order)


Fixed submission:
n = int(input())
a = [int(i) for i in input().split()]

i = 0
person = []
for j in range(n):
    person.append(0)
ans = []
for k in a:
    i += 1
    person[k-1] = i

a.sort()
for l in a:
    ans.append(str(person[l-1]))

order = ' '.join(ans)
print(order)

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

N = int(input())
alist = [int(i) for i in input().split()]

for i in range(1,N+1):
    print(alist.index(i)+1),


Fixed submission:
n = int(input())
a = [int(i) for i in input().split()]

i = 0
person = []
for j in range(n):
    person.append(0)
ans = []
for k in a:
    i += 1
    person[k-1] = i

a.sort()
for l in a:
    ans.append(str(person[l-1]))

order = ' '.join(ans)
print(order)
Buggy python submission (verdict: Time Limit Exceeded):
import os

N,M = (int(x) for x in input().split())
list = list(map(int,input().split()))

ans = 0
for i in range(0,M):
    a = list.index(max(list))
    list[a] = list[a]//2
for j in list:
    ans += j
print(ans)


Fixed submission:
import os
import heapq

N,M = (int(x) for x in input().split())
list = [-int(i) for i in input().split()]

heapq.heapify(list)
ans = 0
for i in range(0,M):
    a = heapq.heappop(list)
    heapq.heappush(list,-((-a)//2))
for j in list:
    ans += j*(-1)
print(ans)

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

N,M = (int(x) for x in input().split())
list = list(map(int,input().split()))

for i in range(0,M):
    list.sort()
    list[len(list)-1] = list[len(list)-1]//2

ans = 0
for j in list:
    ans += j
print(ans)


Fixed submission:
import os
import heapq

N,M = (int(x) for x in input().split())
list = [-int(i) for i in input().split()]

heapq.heapify(list)
ans = 0
for i in range(0,M):
    a = heapq.heappop(list)
    heapq.heappush(list,-((-a)//2))
for j in list:
    ans += j*(-1)
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())

mod = (N-1)*N/2
print(int(mod))


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

k = 0
count = 0
while k < 3:
    if s[k] == t[k]:
        count += 1
    k += 1
print(count)

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

mod = (N-1)*N/2
print(mod)


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

k = 0
count = 0
while k < 3:
    if s[k] == t[k]:
        count += 1
    k += 1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

mod = (N-1)*N/2
for i in range(1,N+1):
    if N%i == N:
        break

print(int(mod+N-i))


Fixed submission:
n = int(input())
print(n*(n-1)//2)

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

mod = (N-1)*N/2
for i in range(1,N+1):
    if N%i == N:
        break

print(int(mod+N-i))

Fixed submission:
n = int(input())
print(n*(n-1)//2)

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

mod = 0
for i in range(1,N):
    M = i%(i+1)
    mod += M
print(mod)


Fixed submission:
n = int(input())
print(n*(n-1)//2)
Buggy python submission (verdict: Runtime Error):
L,R =(int(x) for x in input().split())
if(L<2019<R):
    print(1)
elif(L<=3 and R>=673):
    print(0)
else:
    if((L%2019)^2 < (R%2019)^2):
        if(((L+1)%2019)^2 < (R%2019)^2):
            print((L*(L+1))%2019)
        else:
            print((L*R)%2019)
    else:
        if((L%2019)^2 < ((R-1)%2019)^2):
            print((R*L%2019))
        else:
            print(((R+1)*R)%2019)


Fixed submission:
N,A,B =(int(x) for x in input().split())
An = N*A
if(An < B):
    print(An)
else:
    print(B)
Buggy python submission (verdict: Runtime Error):
A,B,C,D = (int(x) for x in input().split())
n = A
count = 0
while n <= B:
    if n%C != 0 
        if n%D != 0:
            count += 1
    n += 1
print(count)


Fixed submission:
list = input()
chk = 10
for code in list :
    if chk == code :
        print("Bad")
        break
    chk = code
else :
    print("Good")
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = list(map(str,input()))
k = input()

a = s[k-1]

for i in range(n):
    if s[i]==a:
        continue
    else:
        s[i] = "*"

print("".join(s))

Fixed submission:
n = int(input())
s = list(map(str,input()))
k = int(input())

a = s[k-1]

for i in range(n):
    if s[i]==a:
        continue
    else:
        s[i] = "*"

print("".join(s))
Buggy python submission (verdict: Runtime Error):
n = int(input())
high = [int(i) for i in input().split()]
ans = 0
for i in range(n):
    if max>=high[i]:
        ans += 1
        max = high[i]

print(ans)

Fixed submission:
n = int(input())
high = [int(i) for i in input().split()]
ans = 0
max = 0
for i in range(n):
    if max<=high[i]:
        ans += 1
        max = high[i]

print(ans)
Buggy python submission (verdict: Runtime Error):
color = [int(i) for i in input()]
n = len(color)
ans = 0

if n%2==1:
    arfa = [10]*n//2 + [1]
    beta = [01]*n//2 + [0]
else:
    arfa = [10]*n//2
    beta = [01]*n//2

ansa=0;ansb=0
for i in range(n):
    if color[i]!=arfa[i]:
        ansa += 1
    if color[i]!=beta[i]:
        ansb += 1
print(min([ansa,ansb]))


Fixed submission:
color = [int(i) for i in input()]
n = len(color)
ans = 0

if n%2==1:
    arfa = [1,0]*(n//2) + [1]
    beta = [0,1]*(n//2) + [0]
else:
    arfa = [1,0]*(n//2)
    beta = [0,1]*(n//2)

ansa=0;ansb=0
for i in range(n):
    if color[i]!=arfa[i]:
        ansa += 1
    if color[i]!=beta[i]:
        ansb += 1
print(min([ansa,ansb]))
Buggy python submission (verdict: Runtime Error):
n,a,b = (int(x) for x in input().split())

ans = 0

def keta(n):
    sum = 0
    while n>0:
        sum += n%10
        n = n//10
return sum

for i in range(1,n):
    if a<=keta(i)<=b:
        ans +=keta(i)
print(ans)


Fixed submission:
n,a,b = (int(x) for x in input().split())

ans = 0

def keta(N):
    sum = 0
    while N>0:
        sum += N%10
        N = N//10
    return sum

for i in range(1,n+1):
    if a<=keta(i)<=b:
        ans +=i
print(ans)

Buggy python submission (verdict: Runtime Error):
n,a,b = (int(x) for x in input().split())

ans = 0

def keta(n):
    sum = 0
    while n>0:
        sum += n%10
        n = n//10
return sum

for i in range(1,n):
    if a<=keta(i)<=b:
        ans +=keta(i)
print(ans)


Fixed submission:
n,a,b = (int(x) for x in input().split())

ans = 0

def keta(N):
    sum = 0
    while N>0:
        sum += N%10
        N = N//10
    return sum

for i in range(1,n+1):
    if a<=keta(i)<=b:
        ans +=i
print(ans)
Buggy python submission (verdict: Runtime Error):
A,B,C = input().split()

if A[len(A)-1]==B[0] and B[len(B)-1]==C[0]:
  print("YES)
else:
  print("NO")

Fixed submission:
A,B,C = input().split()

if A[len(A)-1]==B[0] and B[len(B)-1]==C[0]:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
a,b = (int(x) for x in input().split())

if a=="H":
    print(b)
else:
    if b=="H":
        print("D")
    else:
        print("H")


Fixed submission:
a,b = (str(x) for x in input().split())

if a=="H":
    print(b)
else:
    if b=="H":
        print("D")
    else:
        print("H")
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
import math

k,s = (int(x) for x in input().split())
count = 0
for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if x+y+z==s:
                count += 1
print(count)


Fixed submission:
import sys
input = sys.stdin.readline
import math

k,s = (int(x) for x in input().split())
r = max(s-k,0)
count = 0
for x in range(k+1):
    for y in range(k+1):
            if r<=x+y<=s:
                count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
list = list(map(int,input().split()))

list.sort()
if list[0]+list[1] == list[2]:
    print("Yes")
else:
    print("No")


Fixed submission:
a,op,b = input().split()
A = int(a)
B = int(b)

if op == "+":
    print(A+B)
elif op == "-":
    print(A-B)
Buggy python submission (verdict: Runtime Error):
N = int(input())
print(N*(N+1)//2

Fixed submission:
N = int(input())
print(N*(N+1)//2)
Buggy python submission (verdict: Runtime Error):
X, K, D = map(int, input().split())
if (abs(X) - K * D) >= 0:
  print(abs(X) - K * D)
else:
  print(min(X%D, abs(X%D - D))


Fixed submission:
X, K, D = map(int, input().split())
if (abs(X) - K * D) >= 0:
  print(abs(X) - K * D)
else:
  if (X // D - K) %2 == 0:
  	print(X%D)
  else:
    print(abs(X%D - D))

Buggy python submission (verdict: Runtime Error):
X, K, D = map(int, input.split())
if (abs(X) - K * D) > = 0:
  print(abs(X) - K * D)
else:
  print(min(X%D, D-X%D))

Fixed submission:
X, K, D = map(int, input().split())
if (abs(X) - K * D) >= 0:
  print(abs(X) - K * D)
else:
  if (X // D - K) %2 == 0:
  	print(X%D)
  else:
    print(abs(X%D - D))
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
def f(s):
  return int(s) - 1

N, K = map(int, input().split())
P = list(map(f, input().split()))
C = list(map(int, input().split()))

loop = []

first = -1
x = -1
loop_mem = []
cnt = 0
score = 0

rem = set(range(N))

while len(rem) > 0:
  if first < 0:
    first = rem.pop()
    x = first
  loop_mem.append(x)
  if x != first:
    rem.remove(x)
  if first != P[x]:
    cnt += 1
    score += C[x]
    x = P[x]
  else:
    cnt += 1
    score += C[x]
    loop.append((loop_mem, cnt, score))
    first = -1
    loop_mem = []
    cnt = 0
    score = 0

ans = -1e10
for loop_mem, cnt, score in loop:
  imax = [-1e10 for _ in range(cnt-1)]
  for x in loop_mem:
    tmp = 0
    for j in range(cnt - 1):
      tmp += C[x]
      imax[j] = max(imax[j], tmp)
      x = P[x]
  for j in range(1, cnt-1):
    imax[j] = max(imax[j-1], imax[j])
  if score <= 0:
    ans = max(ans, imax[-1])
  else:
    M = K // cnt
    m = K % cnt
    if M >= 1:
      tmp = max(score * M + max(imax[m-1], 0), score * (M-1) + imax[-1])
    else:
      tmp = imax[m-1]
  	ans = max(ans, tmp)

print(ans)


Fixed submission:
from collections import defaultdict
def f(s):
  return int(s) - 1

N, K = map(int, input().split())
P = list(map(f, input().split()))
C = list(map(int, input().split()))

loop = []

first = -1
x = -1
loop_mem = []
cnt = 0
score = 0

rem = set(range(N))

while len(rem) > 0:
  if first < 0:
    first = rem.pop()
    x = first
  loop_mem.append(x)
  if x != first:
    rem.remove(x)
  cnt += 1
  score += C[x]
  if first != P[x]:
    x = P[x]
  else:
    loop.append((loop_mem, cnt, score))
    first = -1
    loop_mem = []
    cnt = 0
    score = 0

ans = -1e10
for loop_mem, cnt, score in loop:
  imax = [-1e10 for _ in range(cnt)]
  imax[0] = 0
  for x in loop_mem:
    tmp = 0
    for j in range(1, cnt):
      tmp += C[x]
      imax[j] = max(imax[j], tmp)
      x = P[x]
  for j in range(2, cnt):
    imax[j] = max(imax[j-1], imax[j])
  if score <= 0:
    ans = max(ans, imax[-1])
  else:
    M = K // cnt
    m = K % cnt
    if M >= 1:
      tmp = max(score * M + max(imax[m], 0), score * (M-1) + imax[-1])
    else:
      tmp = imax[m]
    ans = max(ans, tmp)

print(ans)
Buggy python submission (verdict: Runtime Error):
s,w =map(int(input().split()))
if s<=w:
  print('unsafe')
else:
  print('safe')

Fixed submission:
s,w =map(int,input().split())
if s<=w:
  print('unsafe')
else:
  print('safe')
Buggy python submission (verdict: Runtime Error):
N = int(input())
d = list(map(int, input().split()))
ans = 0

from itertools import combinations
for i,j in combinations(d,2):
  ans += d[i-1]*d[j-1]
print(ans)
  


Fixed submission:
N = int(input())
d = list(map(int, input().split()))
ans = 0

from itertools import combinations
for i,j in combinations(range(N),2):
  ans += d[i-1]*d[j-1]
print(ans)

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

from itertools import combinations
for i,j in combinations(N,2):
  ans += d[i]*d[j]
print(ans)
  

Fixed submission:
N = int(input())
d = list(map(int, input().split()))
ans = 0

from itertools import combinations
for i,j in combinations(range(N),2):
  ans += d[i-1]*d[j-1]
print(ans)
Buggy python submission (verdict: Runtime Error):
S = input()
ans = 0
p = ''
i = 0

while i < len(S):
  ans+=1
  if p==S[i]:
    i+=2
    p=''
  else:
    i+=1
    p=S[i]
    
print(ans)


Fixed submission:
S = input()
ans = 0
p = ''
i = 0

while i < len(S):
  ans+=1
  if p==S[i]:
    if i==len(S)-1:
      ans-=1
    i+=2
    p=''
  else:
    p=S[i]
    i+=1
print(ans)

Buggy python submission (verdict: Runtime Error):
S = input()
ans = 0
p = ''
i = 0

while i < N:
  ans+=1
  if p==S[i]:
    i+=2
    p=''
  else:
    i+=1
    p=S[i]
    
print(ans)

Fixed submission:
S = input()
ans = 0
p = ''
i = 0

while i < len(S):
  ans+=1
  if p==S[i]:
    if i==len(S)-1:
      ans-=1
    i+=2
    p=''
  else:
    p=S[i]
    i+=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
N,M = map(int,input().split())

l = []
for i in range(N):
    l.append(list(map(int,input().split())))

l.sort(key=lambda x:x[0])
l.sort(key=lambda x:x[1], reverse=True)

d = defaultdict(int)
ind = 0
ans = 0

for i in range(N):
    A,B = l[i]
    if A+ind<=M:
        day = M-A
        while d[day]!=0:
            day-=1
        d[day]=1
        ans+=B
    while d[ind]!=0:
        ind+=1
    if ind>=M:
        break
print(ans)


Fixed submission:
from collections import defaultdict
import heapq

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

l = defaultdict(list)
for i in range(N):
    A,B = map(int,input().split())
    l[A].append(-B)

h = []
ans = 0
for i in range(M):
    for B in l[i+1]:
        heapq.heappush(h,B)
    if len(h)!=0:
        ans += - heapq.heappop(h)
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int,input().split()))

b = []

for i in range(N):
    ind = N-i
    val = 0
    j=2
    while ind*j<=N:
        val += b[ind*j-1]
        j+=1
    if val%2 != a[ind-1]:
        b.append(ind)
print(len(b))
if len(b)!=0:
    print(' '.join([str(b[len(b)-i-1]) for i in range(len(b))]))


Fixed submission:
N = int(input())
a = [0]+list(map(int,input().split()))

b = [0 for i in range(N+1)]
M = 0

for i in range(N):
    ind = N-i
    val = 0
    j=2
    while ind*j<=N:
        val += b[ind*j]
        j+=1
    if val%2 != a[ind]:
        M+=1
        b[ind]=1
print(M)
if M!=0:
    for i in range(1,N+1):
        if b[i]==1:
            if M!=1:
                print(i,end=' ')
            else:
                print(i)

Buggy python submission (verdict: Runtime Error):
#include <iostream>

using namespace std;

int main(){
    int i,j,N;
    int a[N+1],b[N+1];
    cin >> N;

    for(i=1;i<=N;i++){
        cin >> a[i];
        b[i]=0;
    }

    int M = 0;
    int k = 0;
    for(i=N;i>0;i--){
        int val = 0;
        for(j=2;i*j<=N;j++){
            val+=b[i*j];
        }
        if(val%2!=a[i]){
            b[i]=1;
            M++;
            k=max(k,i);
        }            
    }
    cout << M << endl;
    for(i=1;i<=N;i++){
        if(b[i]==1){
            cout<<i<<" ";
        }
    }
    if(M!=0)
        cout<<endl;
}


Fixed submission:
N = int(input())
a = [0]+list(map(int,input().split()))

b = [0 for i in range(N+1)]
M = 0

for i in range(N):
    ind = N-i
    val = 0
    j=2
    while ind*j<=N:
        val += b[ind*j]
        j+=1
    if val%2 != a[ind]:
        M+=1
        b[ind]=1
print(M)
if M!=0:
    for i in range(1,N+1):
        if b[i]==1:
            if M!=1:
                print(i,end=' ')
            else:
                print(i)
Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left

N = int(input())
l = []

for i in range(N):
    a = int(input())
    n = bisect_left(l,a)
    if n != 0:
        l[n-1] = a
    else:
        l = [a] + l
print(len(l))


Fixed submission:
from bisect import bisect_left
from collections import deque
N = int(input())
d = deque()

for i in range(N):
    a = int(input())
    n = bisect_left(d, a)
    if n != 0:
        d[n-1] = a
    else:
        d.appendleft(a)
print(len(d))

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left

N = int(input())
l = []

for i in range(N):
    a = int(input())
    n = bisect_left(l,a)
    if n != 0:
        l[n-1] = a
    else:
        l = [a] + l
print(len(l))

Fixed submission:
from bisect import bisect_left
from collections import deque
N = int(input())
d = deque()

for i in range(N):
    a = int(input())
    n = bisect_left(d, a)
    if n != 0:
        d[n-1] = a
    else:
        d.appendleft(a)
print(len(d))
Buggy python submission (verdict: Runtime Error):
mod = 10**9+7
from math import factorial
def comb(n,k):
    return int(factorial(n)/(factorial(n-k)*factorial(k))) % mod

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

if N==K:
    print(1)
    for i in range(K-1):
        print(0)

else:
    for i in range(1,K+1):
        blue=0
        red=0

        if K>=i:
            blue=comb(K-1,i-1)
        for j in [i-1,i,i+1]:
            if N-K>=j and j>0:
                if i!=j:
                    red += comb(N-K-1,j-1)
                else:
                    red += 2*comb(N-K-1,j-1) % mod
        print(blue*red % mod)


Fixed submission:
mod = 10**9+7
from math import factorial

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

def comb(n,k):
    if (k<0 or k>n):
        return 0
    k = min(k,n-k)
    return g1[n]*g2[k]*g2[n-k] % mod

g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

if N==K:
    print(1)
    for i in range(K-1):
        print(0)

else:
    for i in range(1,K+1):
        blue=0
        red=0

        if K>=i:
            blue=comb(K-1,i-1)
        for j in [i-1,i,i+1]:
            if N-K>=j and j>0:
                if i!=j:
                    red += comb(N-K-1,j-1)
                else:
                    red += 2*comb(N-K-1,j-1) % mod
        print(blue*red % mod)

Buggy python submission (verdict: Runtime Error):
mod = 10**9+7
from math import factorial
def comb(n,k):
    return int(factorial(n)/(factorial(n-k)*factorial(k))) % mod

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

if N==K:
    print(1)
    for i in range(K-1):
        print(0)
else:
    for i in range(1,K+1):
        blue=0
        red=0

        if K>=i:
            blue=comb(K-1,i-1)
        for j in [i-1,i,i+1]:
            if N-K>=j and j>0:
                if i!=j:
                    red += comb(N-K-1,j-1)
                else:
                    red += 2*comb(N-K-1,j-1) % mod
        print(blue*red % mod)


Fixed submission:
mod = 10**9+7
from math import factorial

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

def comb(n,k):
    if (k<0 or k>n):
        return 0
    k = min(k,n-k)
    return g1[n]*g2[k]*g2[n-k] % mod

g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

if N==K:
    print(1)
    for i in range(K-1):
        print(0)

else:
    for i in range(1,K+1):
        blue=0
        red=0

        if K>=i:
            blue=comb(K-1,i-1)
        for j in [i-1,i,i+1]:
            if N-K>=j and j>0:
                if i!=j:
                    red += comb(N-K-1,j-1)
                else:
                    red += 2*comb(N-K-1,j-1) % mod
        print(blue*red % mod)
Buggy python submission (verdict: Runtime Error):
from itertools import combinations
from bisect import bisect_left
N, K = map(int,input().split())
A = list(map(int,input().split()))

ans=0

for i,j in combinations(range(N+2),2):
  l = sorted(A[0:i]+A[j-1:N])
  if len(l)<=K:
    m = bisect_left(l,0)
  	ans = max(ans,sum(l[min(K-len(l),m):]))
print(ans)


Fixed submission:
from itertools import combinations
from bisect import bisect_left
N, K = map(int,input().split())
A = list(map(int,input().split()))

ans=0

for i,j in combinations(range(N+2),2):
  l = sorted(A[0:i]+A[j-1:N])
  if len(l)<=K:
    m = bisect_left(l,0)
    ans = max(ans,sum(l[min(K-len(l),m):]))
print(ans)