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

Fixed submission:
import math


def divisor(num):
    if num < 0:
        return 0
    elif num == 1:
        return [1, ]
    else:
        divisor_list = [1, ]
        for i in range(2, int(math.sqrt(num) + 1)):
            if num % i == 0:
                divisor_list.append(i)
        return divisor_list


n = int(input())
divisor_list = divisor(n)
minA = divisor_list[-1]
print(len(str(n//minA)))

Buggy submission (verdict: Runtime Error):
import math


def divisor(num):
    if num < 0:
        return 0
    elif num == 1:
        return 1
    else:
        divisor_list = [1, ]
        for i in range(2, int(math.sqrt(num) + 1)):
            if num % i == 0:
                divisor_list.append(i)
        return divisor_list


n = int(input())

divisor_list = divisor(n)
minA = divisor_list[-1]
print(len(str(n//minA)))
Problem p02623 (python)

Fixed submission:
import numpy as np
from functools import reduce

N, M, K = list(map(int, input().split()))
As = list(map(int, input().split()))
Bs = list(map(int, input().split()))


def get_cum(arr):
    cum_arr = [0]
    for e in arr:
        tot = cum_arr[-1] + e
        if tot > K:
            return cum_arr
        cum_arr.append(tot)
    return cum_arr


cumA = get_cum(As)
cumB = get_cum(Bs)

max_count = 0
a_thresh = len(cumA) - 1
a_count = a_thresh
b_count = 0
b_thresh = len(cumB) - 1
while a_count >= 0 and b_count <= b_thresh:
    while b_count <= b_thresh and cumA[a_count] + cumB[b_count] <= K:
        b_count += 1
    b_count = max(0, b_count - 1)
    if cumA[a_count] + cumB[b_count] <= K:
        max_count = max(max_count, a_count + b_count)
    a_count -= 1

print(max_count)

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

count = 0
while K >= min(As[0], Bs[0]):
  if As[0] <= Bs[0]:
    t = As.pop(0)
  else:
    t = Bs.pop(0)
  K -= t
  count += 1
  
print(count)
Problem p02659 (python)

Fixed submission:
Z = input().split()
A = int(Z[0])
B = Z[1].split('.')
B = int(B[0] + B[1])
#print(A*B)
if len(str(A*B)) <= 2:
  a = 0
else:
  a = str(A*B)[:-2]
  a = int(a)
print(a)

Buggy submission (verdict: Runtime Error):
Z = input().split()
A = int(Z[0])
B = Z[1].split('.')
B = int(B[0] + B[1])
#print(A*B)
a = str(A*B/100)[:-3]
a = int(a)
print(a)

Buggy submission (verdict: Runtime Error):
Z = input().split()
A = int(Z[0])
B = Z[1].split('.')
B = int(B[0] + B[1])
#print(A*B)
a = str(A*B/100)[:-3]
a = int(a)
print(a)

Buggy submission (verdict: Runtime Error):
Z = input().split()
A = int(Z[0])
B = Z[1].split('.')
B = int(B[0] + B[1])
#print(A*B)
a = str(A*B)[:-2]
a = int(a)
print(a)

Buggy submission (verdict: Runtime Error):
Z = input().split()
A = int(Z[0])
B = Z[1].split('.')
B = int(B[0] + B[1])
print(A*B)
a = str(A*B)[:-2]
a = int(a)
print(a)

Buggy submission (verdict: Runtime Error):
Z = input().split()
A = int(Z[0])
B = Z[1].split('.')
B = int(B[0] + B[1])
#print(A*B)
a = str((A*B)/100)[:-2]
a = int(a)
print(a)
Problem p02753 (python)

Fixed submission:
S = input()
S = sorted(S)
a = 'Yes'
if S[0] == S[-1]:
  a = 'No'
print(a)

Buggy submission (verdict: Runtime Error):
S = input()
sort(S)
a = 'Yes'
if S[0] == S[-1]:
  a = 'No'
print(a)
Problem p02723 (python)

Fixed submission:
a = list(input())
if a[2]==a[3] and a[4]==a[5]:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
a = list(input())
if a[2]==a[3] & a[4]==a[5]:
    print("Yes")
else:
    print("No")
Problem p02831 (python)

Fixed submission:
import fractions
a=input().split()
print(int(a[0]) * int(a[1]) // fractions.gcd(int(a[0]), int(a[1])))

Buggy submission (verdict: Runtime Error):
import math
a=input().split()
print(int(a[0]) * int(a[1]) / math.gcd(int(a[0]), int(a[1])))

Buggy submission (verdict: Runtime Error):
import math
a=input().split()
print(a[0] * a[1] / math.gcd(a[0], a[1]))

Buggy submission (verdict: Runtime Error):
import math
a=input().split()
print(math.lcm(int(a[0]), int(a[1])))

Buggy submission (verdict: Runtime Error):
import math
a=input().split()
print(math.lcm(a[0], a[1]))

Buggy submission (verdict: Runtime Error):
import math
a=input().split()
print(math.gcd(a[0], a[1]))
Problem p03242 (python)

Fixed submission:
a = list(input())
ans = []
for i in a:
  if i == "1":
    ans.append("9")
  elif i == "9":
    ans.append("1")
  else:
    ans.append(i)
print(''.join(ans))

Buggy submission (verdict: Runtime Error):
a = input().split()
ans = []
for i in a:
  if a == "1":
    ans.append("9")
  elif a == "9":
    ans.append("1")
  else:
    ans.append(a)
print("".join(ans))

Buggy submission (verdict: Runtime Error):
a = input().split()
ans = []
for i in a:
  if a == "1":
    ans.append("9")
  elif a == "9":
    ans.append("1")
  else:
    ans.append(a)
print(ans.join())
Problem p02763 (python)

Fixed submission:

class SegTree(object):
    """docstring for SegTree."""
    def __init__(self, l, _n):
        n = 1
        while n<_n:
            n *= 2
        self.n = n
        self.dat = [0 for _ in range(2*n)]
        for i in range(_n):
            self.dat[i+n-1] |= 1<<l[i]
        self.init(0)

    def init(self, i):
        if i>=self.n-1:
            return self.dat[i]
        self.dat[i] = self.init(self.left(i)) | self.init(self.right(i))
        return self.dat[i]

    def par(self, i):
        return (i-1)//2

    def left(self, i):
        return 2*i+1

    def right(self, i):
        return 2*i+2

    def update(self, i, x):
        i += self.n-1
        self.dat[i] = 1<<x
        while i>0:
            i = self.par(i)
            self.dat[i] = self.dat[self.left(i)] | self.dat[self.right(i)]

    def q(self,a,b,k,l,r):
        if r<=a or b<=l:
            return 0
        if a<=l and r<=b:
            return self.dat[k]
        return self.q(a,b,self.left(k),l,(l+r)//2) | self.q(a,b,self.right(k),(l+r)//2,r)

    def query(self,a,b):
        return self.q(a,b,0,0,self.n)

n = int(input())
s = [ord(c)-ord("a") for c in input()]
q = int(input())
ql = [input().split() for _ in range(q)]

seg = SegTree(s,n)

for i in range(q):
    if ql[i][0]=="1":
        seg.update(int(ql[i][1])-1, ord(ql[i][2])-ord("a"))
    else:
        r = seg.query(int(ql[i][1])-1, int(ql[i][2]))
        print(bin(r).count("1"))

Buggy submission (verdict: Runtime Error):
from collections import defaultdict

n = int(input())
s = list(input())
q = int(input())
ql = [input().split() for _ in range(q)]

w = 800
sl = []
dl = []
for i in range((n+w-1)//w):
    ss = s[i*w:min((i+1)*w,n)]
    dl.append(set(ss))
    sl.append(ss)
if len(dl)%2==1:
    dl.append(set())
dl2 = []
for i in range(len(dl)//2):
    dl2.append(dl[2*i] | dl[2*i+1])
for i in range(q):
    if ql[i][0]=="1":
        idx = int(ql[i][1])-1
        c = ql[i][2]

        ss = sl[idx//w]
        ss[idx%w] = c
        s[idx] = c
        sl[idx//w] = ss
        dl[idx//w] = set(ss)
        if (idx//w)%2==0:
            dl2[idx//w//2] = dl[idx//w] | dl[idx//w+1]
        else:
            dl2[idx//w//2] = dl[idx//w-1] | dl[idx//w]
    else:
        l = int(ql[i][1])-1
        r = int(ql[i][2])-1

        li = l//w
        ri = r//w
        if abs(li-ri)<2:
            print(len(set(s[l:r+1])))
        else:
            u = set(sl[li][l%w:])
            u = u | set(sl[ri][:r%w+1])
            if (li+1)%2==1:
                u = u | dl[li+1]
                li += 1
            if (ri-1)%2==0:
                u = u | dl[ri-1]
                ri -= 1
            for j in range(li+1,ri,2):
                u = u | dl2[j]
            print(len(u))
Problem p03038 (python)

Fixed submission:
from operator import itemgetter

n,m = map(int, input().split())
al = list(map(int, input().split()))
bc = []
for _ in range(m):
    b,c = map(int, input().split())
    bc.append([b,c])


bc.sort(key=itemgetter(1), reverse=True)
al.sort()

i = 0
while len(bc)>0 and i<n:
    b,c = bc.pop(0)

    for j in range(b):
        if i+j<n and al[i+j]<c:
            al[i+j] = c
    i += b

print(sum(al))

Buggy submission (verdict: Runtime Error):
from operator import itemgetter

n,m = map(int, input().split())
al = list(map(int, input().split()))
bc = []
for _ in range(m):
    b,c = map(int, input().split())
    bc.append([b,c])


bc.sort(key=itemgetter(1), reverse=True)
al.sort()

i = 0
while len(bc)>0 and i<n:
    b,c = bc.pop(0)

    for j in range(b):
        if al[i+j]<c:
            al[i+j] = c
    i += b

print(sum(al))
Problem p03426 (python)

Fixed submission:
# coding=utf-8
line = input().split(" ")
h = int(line[0])
w = int(line[1])
d = int(line[2])

table = [0 for _ in range(h*w+1)]
for hi in range(h):
    line = list(map(int, input().split(" ")))

    for wi in range(w):
        table[line[wi]] = (hi+1, wi+1)

def calc(l,r):
    ret = 0
    if l!=r:
        c1 = table[l]
        c2 = table[r]
        ret += abs(c1[0]-c2[0])+abs(c1[1]-c2[1])
    return ret

acc = [0 for _ in range(h*w+1)]
for dd in range(1,d+1):
    s = dd+d
    while s<=h*w:
        acc[s] = calc(s-d,s)+acc[s-d]
        s += d

q = int(input())
for _ in range(q):
    line = input().split(" ")
    l = int(line[0])
    r = int(line[1])

    ret = acc[r] - acc[l]
    print(ret)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
h,w,d = map(int, input().split())
dd = {}
field = []
for hi in range(h):
    line = list(map(int, input().split()))
    field.append(line)
    for wi in range(w):
        dd[line[wi]] = (hi, wi)
q = int(input())
lr = [list(map(int, input().split())) for _ in range(q)]

memo = [[-1 for _ in range(h*w)] for _ in range(h*w)]
def calc(s,r):
    if s==r:
        return 0
    elif memo[s][r]>0:
        return memo[s][r]

    h1,w1 = dd[s]
    s2 = field[h1][w1]+d
    h2,w2 = dd[s2]
    res = abs(h1-h2) + abs(w1-w2) + calc(s2, r)
    memo[s][r] = res
    return res

for (l,r) in lr:
    print(calc(l,r))
Problem p03634 (python)

Fixed submission:
# coding=utf-8

N = int(input())
tree = [[]for x in range(N)]
depth = [0 for x in range(N)]
for _ in range(N-1):
    line = input().split(" ")
    a = int(line[0])-1
    b = int(line[1])-1
    c = int(line[2])
    tree[a].append((b, c))
    tree[b].append((a, c))

line = input().split(" ")
Q = int(line[0])
K = int(line[1])-1

# def dfs(v, p, d):
#     depth[v] = d
#     for e in tree[v]:
#         if e[0]==p:
#             continue
#         dfs(e[0], v, d+e[1])
# dfs(K, -1, 0)

s = [(K, -1, 0)]
while len(s)>0:
    (v, p, d) = s.pop()
    depth[v] = d
    for e in tree[v]:
        if e[0]==p:
            continue
        s.append((e[0], v, d+e[1]))


for _ in range(Q):
    line = input(" ").split(" ")
    x = int(line[0])-1
    y = int(line[1])-1
    print(str(depth[x]+depth[y]))

Buggy submission (verdict: Runtime Error):
# coding=utf-8

N = int(input())
tree = [[]for x in range(N)]
depth = [0 for x in range(N)]
for _ in range(N-1):
    line = input().split(" ")
    a = int(line[0])-1
    b = int(line[1])-1
    c = int(line[2])
    tree[a].append((b, c))
    tree[b].append((a, c))

line = input().split(" ")
Q = int(line[0])
K = int(line[1])-1

def dfs(v, p, d):
    depth[v] = d
    for e in tree[v]:
        if e[0]==p:
            continue
        dfs(e[0], v, d+e[1])

dfs(K, -1, 0)

for _ in range(Q):
    line = input(" ").split(" ")
    x = int(line[0])-1
    y = int(line[1])-1
    print(str(depth[x]+depth[y]))
Problem p03775 (python)

Fixed submission:
# -*- coding: utf-8 -*-

n = int(input())

def cntd(x):
    digits = 0

    while x/10>0:
        x = x//10
        digits += 1
    return digits

ans = cntd(n)

a = 1
while a*a<=n:
    if n%a!=0:
        a += 1
        continue

    b = n//a
    cur = max(cntd(a), cntd(b))
    if ans>cur:
        ans = cur
    a += 1

print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from math import sqrt,ceil,log10

n = int(input())

nsr = sqrt(n)

x = -1
for i in range(1,ceil(nsr)):
    if n%i==0:
        x = n//i

ret = ceil(log10(x))
if 10**(ret)==int(x):
    print(ret+1)
else:
    print(ret)
Problem p02701 (python)

Fixed submission:
print(len(set([input() for _ in range(int(input()))])))

Buggy submission (verdict: Runtime Error):
print(len(set([input() for _ in range(int(input()))]))
Problem p02753 (python)

Fixed submission:
S = input()

if len(set(list(S))) != 1:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
S = input()

if len(set(list(S))) !BBA
= 1:
    print('Yes')
else:
    print('No')
Problem p02990 (python)

Fixed submission:
from scipy.misc import comb

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

mod = 10 ** 9 + 7

for i in range(1, K + 1):
    a = comb(N - K + 1, i, exact=True)
    b = comb(K - 1, i - 1, exact=True)
    ret = a % mod * b % mod
    print(ret)

Buggy submission (verdict: Runtime Error):
from scipy.special import comb

Buggy submission (verdict: Runtime Error):
from scipy.special import comb

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

mod = 10 ** 9 + 7

for i in range(1, K + 1):
    a = comb(N - K + 1, i, exact=True)
    b = comb(K - 1, i - 1, exact=True)
    ret = a % mod * b % mod
    print(ret)
Problem p03137 (python)

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

if N >= M:
    print(0)
else:
    X.sort()
    L = []
    for i in range(M-1):
        L.append(X[i+1]-X[i])
    L.sort(reverse=True)
    print(X[M-1]-X[0]-sum(L[:N-1]))

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

if N >= M:
  print(0)
else:
  X.sort()
  L = []
  for i in range(M-1):
    L.append(X[i+1]-X[i])
  L.sort(reverse=True)
  print(X[M-1]-X[0]-sum(L[:N-1]))

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

if N >= M:
    print(0)
else:
    X.sort()
    L = []
    for i in range(M-1):
        L.append(X[i+1]-X[i])
    L.sort(reverse=True)
    print(X[M-1]-X[0]-sum(L[:N-1]))

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

if N >= M:
    print(0)
else:
    X.sort()
    L = []
    for i in range(M-1):
        L.append(X[i+1]-X[i])
    L.sort(reverse=True)
    print(X[M]-X[0]-sum(L[:N-1]))
Problem p03209 (python)

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

def rep(N,X):
    if N == 1:
        if X == 1:
            return(0)
        elif X == 5:
            return(3)
        else:
            return(X-1)
    elif X == 1:
        return(0)
    else:
        n = 2**(N+2)-3
        p = 2**N-1 # N-1のPの個数
        if X <= n//2:
            return(rep(N-1, X-1))
        elif X == n//2+1:
            return(p + 1)
        else:
            if n-1 == X-1:
                return(rep(N-1, X-1-n//2-1) + p + 1)
            else:
                return(rep(N-1, X-1-n//2) + p + 1)
print(rep(N,X))

Buggy submission (verdict: Runtime Error):
def rep(N,X):
    if N == 1:
        if X == 1 or X == 5:
            return(0)
        else:
            return(X-1)
    elif X == 1:
        return(0)
    else:
        n = 2**(N+2)-3
        a = n//2-(X-1)
        p = 2**N-1
        if a < -1:
            return(rep(N-1, abs(a)) + p + 1)
        elif a == -1 or a == 0 or a == 1:
            return(p + 1)
        else:
            return(rep(N-1, X-1))
print(rep(N,X))
Problem p03265 (python)

Fixed submission:
x1,y1,x2,y2 = map(int,input().split())
import numpy as np

x1 = np.array([x1,y1])
x2 = np.array([x2,y2])
rot = np.array([[0,-1],[1,0]])
x3 = np.dot(rot,(x2-x1))+x2
x4 = np.dot(rot,(x3-x2))+x3
print(x3[0],x3[1],x4[0],x4[1])

Buggy submission (verdict: Runtime Error):
x1,y1,x2,y2 = map(int,input().split())
import numpy as np

x1 = np.array([x1,y1])
x2 = np.array([x2,y2])
rot = np.array([[0,-1],[1,0]])
x3 = np.dot(rot,(x2-x1))+x2
x4 = np.dot(rot,(x3-x2))+x3
print(x3[0],x3[1],x4[0],x4[1])
Problem p03315 (python)

Fixed submission:
S = input()
print(S.count('+')-S.count('-'))

Buggy submission (verdict: Runtime Error):
S = input()
print(S.count('+')-S.count'-')
Problem p03745 (python)

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

if N == 1:
    print(1)
else:
    divide = 0
    if A[0] < A[1]:
        up = 1
    elif A[0] > A[1]:
        up = -1
    else:
        up = 0
    for i in range(1,N-1):
        if A[i] == A[i+1]:
            continue
        elif A[i] < A[i+1]:
            if up < 0:
                divide += 1
                up = 0
            else:
                up = 1
                continue
        else:
            if up > 0:
                divide += 1
                up = 0
            else:
                up = -1
                continue
    print(divide+1)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
divide = 0
if A[0] < A[1]:
    up = 1
elif A[0] > A[1]:
    up = -1
else:
    up = 0
for i in range(1,N-1):
    if A[i] == A[i+1]:
        continue
    elif A[i] < A[i+1]:
        if up < 0:
            divide += 1
            up = 0
        else:
            up = 1
            continue
    else:
        if up > 0:
            divide += 1
            up = 0
        else:
            up = -1
            continue
print(divide+1)
Problem p03803 (python)

Fixed submission:
A,B = map(int,input().split())
if A<B:
    if A == 1:
        print('Alice')
    else:
        print('Bob')
elif A == B:
    print('Draw')
else:
    if B == 1:
        print('Bob')
    else:
        print('Alice')

Buggy submission (verdict: Runtime Error):
A,B = int(input())
if A<B:
    if A == 1:
        print('Alice')
    else:
        print('Bob')
elif A == B:
    print('Draw')
else:
    if B == 1:
        print('Bob')
    else:
        print('Alice')
Problem p03805 (python)

Fixed submission:
N,M = map(int,input().split())
dict = {}
for m in range(M):
    a,b = map(int,input().split())
    if a in dict:
        dict[a].append(b)
    else:
        dict[a] = [b]
    if b in dict:
        dict[b].append(a)
    else:
        dict[b] = [a]
ans = 0
l = [0 for i in range(N+1)]
l[1] = 1
def dfs(l,now):
    global ans
    if sum(l) == N:
        ans += 1
        return(0)
    for i in dict[now]:
        if l[i] == 0:
            l[i] += 1
            now = i
            dfs(l,now)
            l[i] -= 1
        else:
            continue
dfs(l,1)
print(ans)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
dict = {}
for m in range(M):
    a,b = map(int,input().split())
    if a in dict:
        dict[a].append(b)
    else:
        dict[a] = [b]
    if b in dict:
        dict[b].append(a)
    else:
        dict[b] = [a]
ans = 0
l = [0 for i in range(N+1)]
l[1] = 1
def dfs(now):
    global l
    global ans
    if sum(l) == N:
        ans += 1
        return(0)
    for i in dict[now]:
        if l[i] == 0:
            l[i] += 1
            now = i
            dfs(l,now)
            l[i] -= 1
        else:
            continue
dfs(l,1)
print(ans)
Problem p02623 (python)

Fixed submission:
import bisect

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

ruiseki_a = [0]
ruiseki_b = [0]

a_index = N+1
for i in range(N):
  if K < ruiseki_a[-1] + A[i]:
    a_index = i+1
    break
  ruiseki_a.append(ruiseki_a[-1] + A[i])
b_index = M+1
for i in range(M):
  if K < ruiseki_b[-1] + B[i]:
    b_index = i+1
    break
  ruiseki_b.append(ruiseki_b[-1] + B[i])
lis = [0 for _ in range(a_index)]
for i in range(a_index):
  index = bisect.bisect_left(ruiseki_b, K-ruiseki_a[i]+1)
  lis[i] = i + max(0, index - 1)
print(max(lis))

Buggy submission (verdict: Runtime Error):
D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]
t = [int(input()) for _ in range(D)]
M = int(input())
dq = [list(map(int, input().split())) for _ in range(M)]

def calc(t, D, s):
  last = [0 for _ in range(26)]
  value = 0
  for i in range(D):
    day = i + 1
    value += s[i][t[i]-1]
    last[t[i]-1] = day
    for j in range(26):
      value -= c[j] * (day - last[j])
  return value

for i in range(M):
  t[dq[i][0]-1] = dq[i][1]
  print(calc(t, D, s))
Problem p02897 (python)

Fixed submission:
N = int(input())

if N % 2 == 0:
  print(0.5)
else:
  print((N//2+1) / N)

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

count = 0
for i in range(N):
  if h[i] >= K:
    count += 1
print(count)
Problem p02915 (python)

Fixed submission:
N = int(input())

print(N ** 3)

Buggy submission (verdict: Runtime Error):
import itertools
 
N, K = map(int, input().split())
S = input()
 
lis = [len(list(g)) for _, g in itertools.groupby(S)]
 
if len(lis) < 2*K + 1:
  print(N-1)
else:
  print(max(sum(lis[:2*K+1]), sum(lis[len(lis)-2*K-2:])))
Problem p02951 (python)

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

if A - B <= C:
  print(C - A + B)
else:
  print(0)

Buggy submission (verdict: Runtime Error):
import math
 
N = int(input())
 
count = 0
for i in range(1, N+1):
  if math.floor(math.log10(i)) % 2 == 0:
    count += 1
print(count)
Problem p02990 (python)

Fixed submission:
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

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

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

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

    return result

n, r = map(int, input().split())

for i in range(1, r+1):
  if n-r+1 < i:
    print(0)
  else:
    print(cmb(n-r+1,i)*cmb(r-1,i-1)%(10**9+7))

Buggy submission (verdict: Runtime Error):
from math import factorial

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

for i in range(1, K+1):
  print(int(factorial(N-K+1)*factorial(K-1)/factorial(N-K+1-i)/factorial(i)/factorial(i-1)/factorial(K-i) % (10**9+7)))
Problem p03072 (python)

Fixed submission:
N = int(input())
h = list(map(int, input().split()))
count = 0
max = 0
for i in range(N):
    if max <= h[i]:
        max = h[i]
        count += 1
print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
h = int(input().split())
count = 0
max = 0
for i in range(n):
    if max <= h[i]:
        max = h[i]
        count += 1
print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
h = input().split()
count = 0
max = 0
for i in range(n):
    if max <= h[i]:
        max = h[i]
        count += 1
print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
h = []
count = 0
for i in range(N):
    h.append(int(input()))
max = 0
for i in range(n):
    if max <= h[i]:
        max = h[i]
        count += 1
print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
h = []
for i in range(N):
    h.append(int(input()))
max = 0
for i in range(n):
    if max <= h[i]:
        max = h[i]
        count += 1
print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
h = [0]
for i in range(N):
    h = list.append(int(input()))
max = 0
for i in range(n):
    if max <= h[i]:
        max = h[i]
        count += 1
print(count)

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

h = []
for i in range(N):
    h = list.append(int(input()))

max = 0
for i in range(n):
    if max <= h[i]:
        max = h[i]
        count += 1

print(count)

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

h = [int(x) for x in input().split()]

max = 0
for i in range(n):
    if max <= h[i]:
        max = h[i]
        count += 1

print(count)

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

h = [int(x) for x in input().split()]

max = 0
for i in n:
    if max <= h[i]:
        max = h[i]
        count += 1

print(count)
Problem p02970 (python)

Fixed submission:
n,d = list(map(int,input().split()))
sight = 2*d+1
print((n//sight) + (n%sight != 0))

Buggy submission (verdict: Runtime Error):
n,d = map(int,input().split())
sight = 2*d+1
i = 1
while(True)
  if n <= i*sight:
    print(i)
    break
  i += 1