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

Fixed submission:
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd



def solve(N: int, X: int):
    a, p = [1], [1]
    for i in range(N):
        a.append(a[i] * 2 + 3)
        p.append(p[i] * 2 + 1)

    def _f(N, X):
        if N == 0:
            return 0 if X <= 0 else 1
        elif X <= 1 + a[N-1]:
            return _f(N-1, X-1)
        elif X < a[N]:
            return p[N-1] + 1 + _f(N-1, X - 2 - a[N-1])
        else:
            return p[N]

    return _f(N, X)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    result = solve(N, X)
    print(result)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd



def solve(N: int, X: int):
    a, p = [1], [1]
    for i in range(N-1):
        a.append(a[i] * 2 + 3)
        p.append(p[i] * 2 + 1)

    def _f(N, X):
        if N == 0:
            return 0 if X <= 0 else 1
        elif X < 1 + a[N-1]:
            return _f(N-1, X-1)
        elif X < 2 * (1 + a[N-1]):
            return p[N-1] + 1 + _f(N-1, X - 2 - a[N-1])
        else:
            return p[N]

    return _f(N, X)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    result = solve(N, X)
    print(result)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd



def solve(N: int, X: int):
    a, p = [1], [1]
    for i in range(N-1):
        a.append(a[i] * 2 + 3)
        p.append(p[i] * 2 + 1)

    def _f(N, X):
        if N == 0:
            return 1 if X == 1 else 0
        elif X < 1 + a[N-1]:
            return _f(N-1, X-1)
        elif X < 2 * (1 + a[N-1]):
            return p[N-1] + 1 + _f(N-1, X - 2 - a[N-1])
        else:
            return p[N]

    return _f(N, X)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    result = solve(N, X)
    print(result)

if __name__ == '__main__':
    main()
Problem p03275 (python)

Fixed submission:
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


class BinaryIndexTree:
    def __init__(self, n):
        self._size = n
        self._tree = [0] * (n+1)

    def sum(self, i):
        s = 0
        i += 1
        while 0 < i:
            s += self._tree[i-1]
            i -= i & -i
        return s

    def add(self, i, x):
        i += 1
        while i <= self._size:
            self._tree[i-1] += x
            i += i & -i


def solve(N: int, a: "List[int]"):
    c = N * (N + 1) // 2
    th = (c + 1) // 2

    xs = list(sorted(set(a)))
    lo = 0
    hi = len(xs)

    def _f(x):
        ss = [0] + list(accumulate([1 if x <= v else -1 for v in a]))
        n = max([abs(s) for s in ss])
        bit = BinaryIndexTree(2 * n + 1)

        ret = 0
        for s in ss:
            ret += bit.sum(s + n) 
            bit.add(s + n, 1)
        return ret

    while (lo + 1) < hi:
        mid = (lo + hi) // 2
        if th <= _f(xs[mid]):
            lo = mid
        else:
            hi = mid
    return xs[lo]


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    result = solve(N, a)
    print(result)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


class BinaryIndexTree:
    def __init__(self, n):
        self._size = n
        self._tree = [0] * (n+1)

    def sum(self, i):
        s = 0
        i += 1
        while 0 < i:
            s += self._tree[i-1]
            i -= i & -i
        return s

    def add(self, i, x):
        i += 1
        while i <= self._size:
            self._tree[i-1] += x
            i += i & -i


def solve(N: int, a: "List[int]"):
    c = N * (N + 1) // 2
    th = (c + 1 ) // 2

    xs = list(sorted(set(a)))
    lo = 0
    hi = len(xs)

    def _f(x):
        ss = [0] + list(accumulate([1 if x <= v else -1 for v in a]))
        n = max([abs(s) for s in ss])
        bit = BinaryIndexTree(2 * n + 1)

        ret = 0
        for s in ss:
            bit.add(s + n, 1)
            ret += bit.sum(s + n - 1)
        return ret

    while lo < hi:
        mid = (lo + hi) // 2
        if th < _f(xs[mid]):
            lo = mid + 1
        else:
            hi = mid
    return xs[lo]


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    result = solve(N, a)
    print(result)

if __name__ == '__main__':
    main()
Problem p03315 (python)

Fixed submission:
#!/usr/bin/env python3
import sys
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(S: str):
    return sum([int('{}1'.format(s)) for s in S])


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    result = solve(S)
    print(result)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
try:
    from math import gcd
except Exception:
    from fraction import gcd


def solve(S: str):
    return sum([int('{}1'.format(s)) for s in S])


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    result = solve(S)
    print(result)

if __name__ == '__main__':
    main()
Problem p03041 (python)

Fixed submission:
N, K=map(int,input().split())
S=list(input())
S[K-1] = S[K-1].lower()
print(''.join(S))

Buggy submission (verdict: Runtime Error):
N, K=map(int,input().split())
S=list(input())
S[K] = S[K].lower()
print(''.join(S))

Buggy submission (verdict: Runtime Error):
N, K =map((int, input().split())
S=list(input())
S[K] = S[K].lower()
print(str(S))
Problem p03042 (python)

Fixed submission:
s =input()
li = [(i+j) for (i,j) in zip(s[::2],s[1::2])]

if (int(li[0])>12)&(int(li[0])>0):
  if (int(li[1])>12)|(int(li[1])==0):
  	print('NA')
  else:
    print('YYMM')
elif int(li[0])==0:
  if int(li[1])==0:
    print('NA')
  else:
    print('YYMM')
else:
  if (int(li[1])>12)|(int(li[1])==0):
    print('MMYY')
  else:
    print('AMBIGUOUS')

Buggy submission (verdict: Runtime Error):
s =input()
li = [(i+j) for (i,j) in zip(s[::2],s[1::2])]

if int(li[0])>12:
  if int(li[1])>12:
  	pritn('NA')
  else:
    print('YYMM')
else:
  if int(li[1])>12:
    print('MMYY')
  else:
    print('AMBIGUOUS')
Problem p03107 (python)

Fixed submission:
S = list(map(int, input()))

S_1 = [S[i] for i in range(len(S)) if S[i]==1]
S_0 = [S[i] for i in range(len(S)) if S[i]==0]

S_min = min(len(S_1), len(S_0))

print(2*S_min)

Buggy submission (verdict: Runtime Error):
S = list(map(int, input()))

count = 0
for i in range(len(S)-1):
  if S[i]!=S[i+1]:
    del S[i],S[i+1]
    count =2+count 
  else:
    if len(S)==i+1:
      print(count)
    else:
  		continue
    
print(count)

Buggy submission (verdict: Runtime Error):
S = list(map(int, input()))

count = 0
for i in range(len(S)-1):
  if S[i]!=S[i+1]:
    del S[i],S[i+1]
    count =2+count 
  else:
    if len(S)==i+1:
      print(count)
    else:
  		continue
    
print(count)

Buggy submission (verdict: Runtime Error):
S = list(map(int, input()))

count = 0
for i in range(len(S)):
  if S[i]!=S[i+1]:
  	del S[i],S[i+1]
    count +=2
  	continue  
  elif S[len(S)]==S[len(S)+1]
  	break
  else:
  	continue
    
print(count)
Problem p03127 (python)

Fixed submission:
def gcd(m,n):
    x = max(m,n)
    y = min(m,n)
    if x%y == 0:
        return y
    else:
        while x%y != 0:
            z = x%y
            x = y
            y = z
        else:
            return z
def gcd_list(l):
    g = l[0]
    for i in l[1:]:
        g = gcd(g,i)


    return g
    
N = int(input())
A_list = [int(i) for i in input().split()]
ans = gcd_list(A_list)
print(ans)

Buggy submission (verdict: Runtime Error):
def gcd(m,n):
    x = max(m,n)
    y = min(m,n)
    if x%y == 0:
        return y
    else:
        while x%y != 0:
            z = x%y
            x = y
            y = z
        else:
            return z
def gcd_list(l):
    if len(l)>=2:
        m = l[0]
        n = l[1]
        g = gcd(m,n)
        l_new = [g] + l[2:]
        return (gcd_list(l_new))
    else:
        return l[0]
    
N = int(input())
A_list = [int(i) for i in input().split()]
ans = gcd_list(A_list)
print(ans)
Problem p03011 (python)

Fixed submission:
pqr = list(map(int, input().split()))
print(sum(pqr) - max(pqr))

Buggy submission (verdict: Runtime Error):
pqr = list(map(int, input.split()))
print(sum(pqr) - max(pqr))
Problem p03011 (python)

Fixed submission:
num1, num2, num3 = [int(i) for i in input().split()]
a=[num1+num2,num2+num3,num1+num3]
print(min(a))

Buggy submission (verdict: Runtime Error):
num1, num2, num3 = [int(i) for i in input().split()]
a=list[num1+num2,num2+num3,num1+num3]
print(max(a))
Problem p03804 (python)

Fixed submission:
# -*- coding: utf-8 -*-
import sys
import math
import numpy as np


def main():
    # 入力処理
    # M = int(input())
    N, M = map(int, input().split())
    sA = ''.join([input() for i in range(N)])
    sB = ''.join([input() for i in range(M)])
    A = np.array([s for s in sA]).reshape(N,N)
    B = np.array([s for s in sB]).reshape(M,M)

    # アルゴリズム本体
    result = np.zeros((N-M+1,N-M+1), dtype=bool)
    for i in range(N-M+1):
        for j in range(N-M+1):
            result[i,j] = (A[i:i+M, j:j+M] == B).all()

    # 出力
    if result.any():
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys
import math
import numpy as np


def main():
    # 入力処理
    # M = int(input())
    N, M = map(int, input().split())
    sA = ''.join([input() for i in range(N)])
    sB = ''.join([input() for i in range(M)])
    A = np.array([s for s in sA]).reshape(N,N)
    B = np.array([s for s in sB]).reshape(M,M)

    # アルゴリズム本体
    result = np.zeros((N-M,N-M), dtype=bool)
    for i in range(N-M+1):
        for j in range(N-M+1):
            result[i,j] = (A[i:i+M, j:j+M] == B).all()

    # 出力
    if result.any():
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()
Problem p03127 (python)

Fixed submission:
from functools import reduce

N=int(input())
A=list(map(int,input().split()))
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
print(reduce(gcd,A))

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

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

print(reduce(gcd,A))

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

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

print(reduce(math.gcd,A))

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

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

print(reduce(gcd,A))

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

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

print(reduce(gcd,A))
Problem p03038 (python)

Fixed submission:
from sys import stdin
 
def main():
    n,m = [int(x) for x in stdin.readline().split()]
    cards = [int(x) for x in stdin.readline().split()]
    cards.sort()
 
    bcs = [tuple(map(int,x.split())) for x in stdin.readlines()]
    bcs.sort(key=lambda x:x[1], reverse=True)
 
    ans = 0
    minIndex = 0
    isFinished = False
 
    for b,c in bcs:
 
        for _ in range(b):
            if minIndex < n and cards[minIndex] < c:
                ans += c
                minIndex += 1
            else:
                isFinished = True
                break
        
        if isFinished:
            break
 
    if minIndex < n:
        ans += sum(cards[minIndex:])
 
    print(ans)
    
if __name__=='__main__':
    main()

Buggy submission (verdict: Runtime Error):
import numpy as np

N, M = map(int, input().split())
list_num = list(map(int, input().split()))
list_num_ar = np.array(list_num)
result = []

for i in range(M):
	a, b = map(int, input().split())
	res_a = list_num_ar[list_num_ar >= b]
	res_b = list_num_ar[list_num_ar < b]

	if a >= res_b.size:
		res_b = np.full(b, res_b.size)
	else:
		res_b = np.sort(res_b)
		res_b[0:a] = b

	tmp = sum(res_b) + sum(res_a)
	list_num_ar = np.r_[res_a, res_b]


	result.append(tmp)

print(max(result))
Problem p03135 (python)

Fixed submission:
a, b = map(int, input().split())
res = a*1.0/b
print(res)

Buggy submission (verdict: Runtime Error):
import numpy as np

N, K = map(int, input().split())
rawdata = np.array([int(i) for i in input().split()])
setRange = np.reshape(np.arange(K+1), (K+1,1))

def df_calc(X, A):
    return X^A
vfunc = np.vectorize(df_calc)

res = vfunc(rawdata, setRange)
res = np.sum(res, axis=1).max()
print(res)
Problem p03011 (python)

Fixed submission:
M = [int(s) for s in input().split()]

print(sum(M)-max(M))

Buggy submission (verdict: Runtime Error):
MOD = (10**9 + 7)
broken_step = []
     
line = [int(s) for s in input().split()]
     
N, M = line[0], line[1]
     
for i in range(M):
    step_num = int(input().split()[0])
    broken_step.append(step_num)
        
        
dp = [0]*(N+1)
dp[0] = 1
if 1 in broken_step:
    dp[1] = 0
else:
    dp[1] = 1
     
for i in range(2, N+1):
    dp[i] = (dp[i-1]+dp[i-2])%MOD if i not in broken_step else 0
print(dp[N])
Problem p03013 (python)

Fixed submission:
MOD = (10**9 + 7)

     
line = [int(s) for s in input().split()]
     
N, M = line[0], line[1]
     
b = [0]*(N+1)
for i in range(M):
    step_num = int(input().split()[0])
    b[step_num] = 1
        
        
dp = [0]*(N+1)
dp[0] = 1
if b[1] == 1:
    dp[1] = 0
else:
    dp[1] = 1
     
for i in range(2, N+1):
    if b[i] == 1:
        dp[i] = 0
    else:
        dp[i] = (dp[i-1]+dp[i-2])%MOD
print(dp[N])

Buggy submission (verdict: Runtime Error):

N, M = [int(s) for s in input().split()]
b = [0]*N
for _ in range(M):
    b[int(input().strip())-1] = 1

a = [0]*N

if b[0] == 0:
    a[0] = 1
if b[1] == 0:
    a[1] = 1 + a[0]

for i in range(2, N):
    if b[i] == 0:
        a[i] = a[i-1] + a[i-2]
print(a[-1]%1000000007)

Buggy submission (verdict: Runtime Error):

broken_step = []

line = [int(s) for s in input().split()]

N, M = line[0], line[1]

for i in range(M):
    step_num = int(input().split()[0])-1
    broken_step.append(step_num)
    
    
dp = list(range(N))
if 0 in broken_step and 1 not in broken_step:
    dp[0] = 0
    dp[1] = 1
elif 0 not in broken_step and 1 not in broken_step:
    dp[0] = 1
    dp[1] = 2
elif 0 in broken_step and 1 in broken_step:
    dp[0] = 0
    dp[1] = 0
else:
    dp[0] = 1
    dp[1] = 0
    

for i in range(N-2):
    dp[i+2] = dp[i]+dp[i+1] if i+2 not in broken_step else 0
    
print(dp[N-1]%1000000007)
Problem p03013 (python)

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

A = [False] * (N + 1)

for _ in range(M):
    A[int(input())] = True

step = [0] * (N + 1)

step[0] = 1

for s in range(1, N + 1):
    if A[s]:
        step[s] = 0
        continue
    if s == 1:
        step[s] = 1
        continue
    else:
        step[s] = step[s - 1] + step[s - 2]
        step[s] %= 1000000007

print(step[N])

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

A = []

for _ in range(M):
    A[int(input())] = True

step = [0] * (N + 1)

step[0] = 1

for s in range(1, N + 1):
    if A[s]:
        step[s] = 0
        continue
    if s == 1:
        step[s] = 1
        continue
    else:
        step[s] = step[s - 1] + step[s - 2]
        step[s] %= 1000000007

print(step[N])

Buggy submission (verdict: Runtime Error):
from sys import exit

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

_a = -1
A = []
ans = 0

for _ in range(M):
    a_ = int(input())
    if _a + 1 == a_:
        print(0)
        exit()
    _a = a_
    A.append(_a)

step = [] * N
step[0] = 1

for s in range(1, N + 1):
    if s in A:
        step[s] = 0
        continue
    if s == 1:
        step[s] = 1
        continue
    else:
        step[s] = (step[s - 1] + step[s - 2]) % 1000000007

print(step[N])
Problem p03137 (python)

Fixed submission:
def main():
    N, M = map(int, input().split())
    X = list(map(int, input().split()))
    if N >= M:
        print('0')
        return 
    X_sort = sorted(X)
    diff = []
    for i in range(M - 1):
        diff.append(X_sort[i + 1] - X_sort[i])
    diff_sort = sorted(diff)
    if N != 1:
        for _ in range(N - 1):
            diff_sort.pop()
    ans = 0
    for d in diff_sort:
        ans += d
    print(ans)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    N, M = map(int, input().split())
    X = list(map(int, input().split()))
    X_sort = sorted(X)
    diff = []
    for i in range(M - 1):
        diff.append(X_sort[i + 1] - X_sort[i])
    diff_sort = sorted(diff)
    if M == 1:
        print("0")
        return
    for _ in range(N - 1):
        diff_sort.pop()
    ans = 0
    for d in diff_sort:
        ans += d
    print(ans)


if __name__ == "__main__":
    main()
Problem p03041 (python)

Fixed submission:
n, m = input().split()
N = int(n)
K = int(m)

S = input()

string = list(S)

string[K-1] = string[K-1].lower()

print(''.join(string))

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

S = input()

string = list(S)

string[K+1] = string[K+1].lower()

print(''.join(string))
Problem p03221 (python)

Fixed submission:
from bisect import bisect_left


n,m = list(map(int,input().split()))
a = [[0] for i in range(n)]
b = [None]*m
for i in range(m):
    p,s = list(map(int,input().split()))
    p-=1
    a[p].append(s)
    b[i] = [p,s]
for i in range(len(a)):
    a[i].sort()
for i in range(len(b)):
    ken = b[i][0]
    si = bisect_left(a[ken], b[i][1])
    ken = str(ken+1).zfill(6)
    si = str(si).zfill(6)
    print("".join([ken,si]))

Buggy submission (verdict: Runtime Error):
n,m = list(map(int,input().split()))
a = [[None] for i in range(n+1)]
b = [None]*m
for i in range(m):
    p,s = list(map(int,input().split()))
    a[p].append(s)
    b[i] = [p,s]
print(a)
for i in a:
    a[i].sort()
print(a)
for i in b:
    ken = b[i][0]
    si = a[ken].index(b[i][1]) +1
    ken = str(ken).zfill(6)
    si = str(si).zfill(6)
    print("".join([ken,si]))
Problem p02987 (python)

Fixed submission:
from itertools import groupby

s = input()
result = True

for k, g in groupby(s):
        if s.count(k) is not 2:
                result = False

if result:
        print('Yes')
else:
        print('No')

Buggy submission (verdict: Runtime Error):
	from itertools import groupby

s = input()
result = True

for k, g in groupby(s):
        print(k, list(g))
        if s.count(k) is not 2:
                result = False

if result:
        print('Yes')
else:
        print('No')
Problem p02990 (python)

Fixed submission:
from operator import mul
from functools import reduce


def cmb(n, r):
	if n < r:
		return 0
	r = min(n - r, r)
	if r == 0:
		return 1
	numer = reduce(mul, range(n, n - r, -1))
	denom = reduce(mul, range(1, r + 1))
	return numer // denom % INF


N, K = map(int, input().split())
INF = 10 ** 9 + 7

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

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

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

def cmb(n, r):
  if(n<r):
    return 0
  r=min(r,n-r)
  if(r==0):
      return 1
  
  
  upper=reduce(mul, range(n, n-r, -1))
  under=reduce(mul, range(1,r+1))
    
  return upper / under


for i in range(1,K+1):
  ret = cmb(N-K+1,i)*cmb(K-1,i-1)
  print(ret%(1e9+7))

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

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

def cmb(n, r):
  if(n<r):
    return 0
  r=min(r,n-r)
  if(r==0):
      return 1
  
  
  upper=reduce(mul, range(n, n-r, -1))
  under=reduce(mul, range(1,r+1))
    
  return upper//under


for i in range(1,K+1):
  ret = cmb(N-K+1,i)*cmb(K-1,i-1)
  print(ret%(1e9+7))

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

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

def cmb(n, r):
  if(n<r):
    return 0
  r=min(r,n-r)
  if(r==0):
      return 1
  
  
  upper=reduce(mul, range(n, n-r, -1))
  under=reduce(mul, range(1,r+1))
    
  return upper//under

n = min(N-K+1,K)
for i in range(1,n+1):
  ret = cmb(N-K+1,i)*cmb(K-1,i-1)
  print(ret%(1e9+7))

Buggy submission (verdict: Runtime Error):
N, K=map(int, input().split())
red=N-K

def cmb(n, r):
  m=1
  if(n==0 or r==0):
      return 1
  if(n<2*r):
      r=n-r
  for i in range(1,r+1):
      m=m*(n-i+1)/i
    
  return m

n = min(N-K+1,K)
for i in range(1,n+1):
  ret = cmb(N-K+1,i)*cmb(K-1,i-1)
  print(int(ret%(1e9+7)))

Buggy submission (verdict: Runtime Error):
N, K=map(int, input().split())
red=N-K

def cmb(n, r):
  m=1
  if(n==0 or r==0):
      return 1
  if(n<2*r):
      r=n-r
  for i in range(1,r+1):
      m=m*(n-i+1)/i
    
  return m

n = (N-K+1)
if(n>K):
  n=K
for i in range(1,n+1):
  ret = cmb(N-K+1,i)*cmb(K-1,i-1)
  print(int(ret)%(10^9+7))

Buggy submission (verdict: Runtime Error):
N, K=map(int, input().split())
red=N-K

def cmb(n, r):
  m=1
  if(n==0 or r==0):
      return 1
  if(n<2*r):
      r=n-r
  for i in range(1,r+1):
      m=m*(n-i+1)/i
    
  return m

n = (N-K+1)
if(n>K):
  n=K
for i in range(1,n+1):
  ret = cmb(N-K+1,i)*cmb(K-1,i-1)
  print(int(ret)%(1000000007))
Problem p02987 (python)

Fixed submission:
S = sorted(input())
if S[0] == S[1] and S[2] == S[3] and S[1] != S[2]:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
S = sorted(input())
return S[0] == S[1] and S[2] == S[3] and S[1] != S[2]

Buggy submission (verdict: Runtime Error):
from collections import Counter
S = input()
c = Counter(S)
for v in c.values():
  if v != 2: return False
return True

Buggy submission (verdict: Runtime Error):
from collections import Counter
S = input()
    c = Counter(S)
    for v in c.values():
        if v != 2: return False
    return True