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

Fixed submission:
import itertools
n,m,q = map(int,input().split())
array = []
A = [i for i in range(1,m+1)]
A_list = list(itertools.combinations_with_replacement(A,n))
max_sum = [0]*len(A_list)

for i in range(q):
    a,b,c,d = map(int,input().split())
    for j in range(len(A_list)):
        if A_list[j][b-1]-A_list[j][a-1] == c:
            max_sum[j] += d
print(max(max_sum))

Buggy submission (verdict: Runtime Error):
import itertools
n,m,q = map(int,input().split())
array = []
A = [i for i in range(1,m+1)]
A_list = list(itertools.combinations(A,n))
max_sum = [0]*len(A_list)

for i in range(q):
    a,b,c,d = map(int,input().split())
    for j in range(len(A_list)):
        if A_list[j][b-1]-A_list[j][a-1] == c:
            max_sum[j] += d
print(max(max_sum))

Buggy submission (verdict: Runtime Error):
import itertools
n,m,q = map(int,input().split())
array = []
A = [i for i in range(1,m+1)]
A_list = list(itertools.combinations(A,n))
max_sum = [0]*len(A_list)

for i in range(q):
    a,b,c,d = map(int,input().split())
    for j in range(len(A_list)):
        if A_list[j][b-1]-A_list[j][a-1] == c:
            max_sum[j] += d
print(max(max_sum))
Problem p02659 (python)

Fixed submission:
import math
from decimal import *
exp = Decimal(10**23)
A,B = map(str, input().split())
res = int(A)*Decimal(B)
print(math.floor(res))

Buggy submission (verdict: Runtime Error):
import math
A,B = map(int, input().split())
res = A*B
print(math.floor(res))
Problem p03011 (python)

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

Buggy submission (verdict: Runtime Error):
a = map(int, input().split())
a.sort()
print(a[0]+a[1])

Buggy submission (verdict: Runtime Error):
a = map(int, input().split())
a.sort
print(a[0]+a[1])
Problem p03137 (python)

Fixed submission:
N,M = map(int, input().split())
X = list(map(int, input().split()))
if M <= N:
    print(0)
    exit()
X.sort()
L = []
for i in range(1,M):
    L.append(X[i]-X[i-1])
L.sort()
L.reverse()
res = sum(L)
for i in range(N-1):
    res -= L[i]
print(res)

Buggy submission (verdict: Runtime Error):
N,M = map(int, input().split())
X = list(map(int, input().split()))
X.sort()
L = []
for i in range(1,M):
    L.append(X[i]-X[i-1])
L.sort()
L.reverse()
res = sum(L)
for i in range(N-1):
    res -= L[i]
print(res)
Problem p03207 (python)

Fixed submission:
N = int(input())
P = []
for i in range(N):
    P.append(int(input()))
print(sum(P)-max(P)//2)

Buggy submission (verdict: Runtime Error):
N = int(input())
P = []
for i in range(N):
    P.append(int(input))
print(sum(P)-max(P)//2)
Problem p03208 (python)

Fixed submission:
N,K = map(int, input().split())
h = []
for i in range(N):
    h.append(int(input()))
h.sort()
res = 10**9
for i in range(N-K+1):
    if res > h[i+K-1]-h[i]:
        res = h[i+K-1]-h[i]
print(res)

Buggy submission (verdict: Runtime Error):
N,K = map(int, input().split())
h = []
for i in range(N):
    h.append(int(input()))
h.sort()
dif = []
for i in range(N-1):
    dif[i] = h[i+1]-h[i]
print(min(dif))
Problem p03745 (python)

Fixed submission:
N  = int(input())
A = list(map(int, input().split()))
status = 0 # 0 = defalt, 1 = up, 2 = down
cnt = 1
for i in range(1,N):
    if A[i-1] < A[i]: #up petern
        if status == 0 or status == 1:
            status = 1
        else:
            status = 0
            cnt += 1
    elif A[i-1] > A[i]:
        if status == 0 or status == 2:
            status = 2
        else:
            status = 0
            cnt += 1
    else:
        continue
print(cnt)

Buggy submission (verdict: Runtime Error):
N  = int(input())
A = list(map(int, input().split()))
status = 0 # 0 = defalt, 1 = up, 2 = down
cnt = 1
for i in range(1,N):
    if A[i-1] < A[i]: #up petern
        if status == 0 or status == 1:
            status = 1
        else:
            status = 0
            cnt += 1
    elif A[i-1] > A[i]:
        if status == 0 or status == 2
                status = 2
        else:
            status = 0
            cnt += 1
    else:
        continue
print(cnt)

Buggy submission (verdict: Runtime Error):
N  = int(input())
A = list(map(int, input().split()))
status = 0 # 0 = defalt, 1 = up, 2 = down
cnt = 1
for i in range(1,N):
    if A[i-1] < A[i]: #up petern
        if status == 0 or status == 1:
            status = 1
        else status == 2:
            status = 0
            cnt += 1
    elif A[i-1] > A[i]:
        if status == 0 or status == 2
                status = 2
        else status:
            status = 0
            cnt += 1
    else:
        continue
print(cnt)
Problem p02699 (python)

Fixed submission:
a, b = map(int,input().split())
if a <= b:
    print('unsafe')
else:
    print('safe')

Buggy submission (verdict: Runtime Error):
import math

a,b,c,d = map(int,input().split())
if (math.ceil(a/d)) <= (math.ceil(b/c)):
    print('No')
else:
    print('Yes')
Problem p02725 (python)

Fixed submission:
k, n = map(int,input().split())
a = list(map(int,input().split()))

end = a[0] + k - a[n-1]
b = []
b.append(end)

for i in range(0,n-1):
    diff = a[i+1] - a[i]
    b.append(diff)

b.sort(reverse=True)
max = b[0]
print(k-max)

Buggy submission (verdict: Runtime Error):
k, n = map(int,input().split())
a = list(map(int,input().split()))

end = a[0] + k - a[n-1]
b = []
b.append(end)

for i in range(0,n-1):
    diff = a[i+1] - a[i]
    b.append(diff)

b.sort(reverse=True)
print(k-max)
Problem p02990 (python)

Fixed submission:
import math
n,k = map(int,input().split())

def ncr(n,r):
    f = math.factorial
    return (f(n) // f(r) // f(n-r))


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

Buggy submission (verdict: Runtime Error):
import math
n,k = map(int,input().split())

def ncr(n,r):
    f = math.factorial
    return (f(n) // f(r) // f(n-r))


for i in range(1,k+1):
    print(ncr(n-k+1, i) * ncr(k-1,i-1) % (10**9+7))
Problem p03013 (python)

Fixed submission:
from sys import exit
from collections import deque

n, m = map(int,input().split())
a = deque(int(input()) for i in range(m))

if len(a) != 0:
    base = a.popleft()
else:
    base = -1

p = 10 ** 9 + 7

dp = [1] * (n+1)

if base == 0:
    print(0)
    exit()

for i in range(1, n+1):
    if base == i:
        dp[i] = 0
        if len(a) != 0:
            base = a.popleft()
        continue
    if i == 1:
        dp[i] = 1
    else:
        dp[i] = (dp[i-2] + dp[i-1]) % p
    if dp[i] == 0:
        print(0)
        exit()

print(dp[n])

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

n, m = map(int,input().split())
a = deque(int(input()) for i in range(m))

base = a.popleft()
p = 10 ** 9 + 7

dp = [1] * (n+1)

if base == 0:
    print(0)
    exit()

for i in range(1, n+1):
    if base == i:
        dp[i] = 0
        if len(a) != 0:
            base = a.popleft()
        continue
    if i == 1:
        dp[i] = 1
    else:
        dp[i] = (dp[i-2] + dp[i-1]) % p
    if dp[i] == 0:
        print(0)
        exit()

print(dp[n])
Problem p03017 (python)

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

flg = 0
cnt = 0
S_ac = S[A:C]
S_bd = S[B:D]

if '##' in S_ac or '##' in S_bd:
    flg = 1

if D < C and flg == 0:
    S = S[B-2:D+1]
    if '...' not in S:
        flg = 1

if flg == 1:
    print('No')
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
N,A,B,C,D = map(int,input().split())
S = list(input())

flg = 0

if C < D:
   cnt = 0
    for i in range(A, D):
        if S[i] == '#':
            cnt += 1
        else:
            cnt = 0
        if cnt == 2:
            flg = 1
            break

else:
    cnt = 0
    flg = 1
    for i in range(B-1, D+1):
        if S[i] == '.':
            cnt += 1
        else:
            cnt = 0
        if cnt == 3:
            flg = 0
            break
if flg == 1:
    print('No')
else:
    print('Yes')
Problem p03038 (python)

Fixed submission:
n, m = map(int,input().split())
a = list(map(int,input().split()))
bc = [list(map(int,input().split())) for i in range(m)]
bc = sorted(bc, key = lambda x : x[1], reverse=True)

sum_b = 0
for b, c in bc:
    sum_b += b
    a += [c] * b
    if n < sum_b:
        break
a.sort(reverse=True)
a = a[:n]

print(sum(a))

Buggy submission (verdict: Runtime Error):
n, m = map(int,input().split())
a = list(map(int,input().split()))
bc = [list(map(int,input().split())) for i in range(m)]
bc = sorted(bc, key = lambda x : x[1], reverse=True)

sum_b = 0
for b, c in bc:
    sum_b += b
    a += [c] * b
    print(a)
    if n < sum_b:
        break
a.sort(reverse=True)
a = a[:n]

print(sum(a))
Problem p02693 (python)

Fixed submission:
k=int(input())
a,b=map(int,input().split())

for i in range(a,b+1):
  if i%k==0:
    print('OK')
    break
  if i==b:
    print('NG')

Buggy submission (verdict: Runtime Error):
A,B,N=map(int,input().split())
import numpy as np
print(max([int(A*x/B)-A*int(x/B) for x in np.arange(0,N+1,max((B/A),1))])
Problem p02695 (python)

Fixed submission:
import itertools
 
N,M,Q=map(int,input().split())
all=[]
 
for i in range(Q):
  all.append(list(map(int,input().split())))
#print(all)
#print(len(all))
#print(all[0][1])
 
x=sorted([i for i in range(1,M+1)])
maxdsum=0
 
 
for A in itertools.combinations_with_replacement(x, N):
  dsum=0
  #print("A=="+str(A))
  for num in range(Q):
    if A[all[num][1]-1]-A[all[num][0]-1]==all[num][2]:
      dsum+=all[num][3]
  if maxdsum<dsum:
    maxdsum=dsum
print(maxdsum)

Buggy submission (verdict: Runtime Error):
import itertools
 
N,M,Q=map(int,input().split())
all=[]
for i in range(Q):
  all.append(list(map(int,input().split()))
 
x=[i for i in range(1,M+1)]
maxdsum=0
 
for A in itertools.combinations_with_replacement(x, N):
  dsum=0
  for num in range(Q):
    if A[all[num][1]-1]-A[all[num][0]-1]==all[num][2]:
      dsum+=all[num][3]
  if maxdsum<dsum:
    maxdsum=dsum
print(maxdsum)

Buggy submission (verdict: Runtime Error):
import itertools
 
N,M,Q=map(int,input().split())
all=[]
 
for i in range(Q):
  all.append(list(map(int,input().split())))
#print(all)
#print(len(all))
#print(all[0][1])
 
x=sorted([i for i in range(1,M+1)])
maxdsum=0
 
 
for A in itertools.combinations_with_replacement(x, N):
  dsum=0
  "print("A=="+str(A))
  for num in range(Q):
    if A[all[num][1]-1]-A[all[num][0]-1]==all[num][2]:
      dsum+=all[num][3]
  if maxdsum<dsum:
    maxdsum=dsum
print(maxdsum)
Problem p02699 (python)

Fixed submission:
a,b=map(int, input().split())
print('unsafe') if a<=b else print('safe')

Buggy submission (verdict: Runtime Error):
N=int(input())
a=[]
for i in range(N):
    a.append(input())
print(len(set(a)))
Problem p02707 (python)

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

num=[0]*N
for i in A:
    num[i-1]+=1

for j in range(len(num)):
    print(num[j])

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
num=0
for i in range(k,n+2):
    num+=i*(n-i+1)+1
print(num%(10**9+7))
Problem p03053 (python)

Fixed submission:
# coding:utf-8

Black = "#"
White = "."

dir_x = [1, 0, -1, 0]
dir_y = [0, 1, 0, -1]


def main():
    H, W = map(int, input().split())
    step = 0
    count = W*H
    memo = [[-1]*W for i in range(H)]
    steplist = []

    for y in range(H):
        temp_in = input()
        for x in range(W):
            if temp_in[x] == Black:
                memo[y][x] = 0
                count -= 1
                steplist.append([y, x])

    while count > 0:
        step += 1
        next_list = []
        for l_yx in steplist:
            for i in range(4):
                temp_x = l_yx[1] + dir_x[i]
                temp_y = l_yx[0] + dir_y[i]
                if temp_x >= 0 and temp_x < W and temp_y >= 0 and temp_y < H:
                    if memo[temp_y][temp_x] < 0:
                        memo[temp_y][temp_x] = step
                        count -= 1
                        next_list.append([temp_y, temp_x])
        steplist = next_list
    print(step)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
# coding:utf-8
Black = "#"
White = "."

dir_x = [1, 0, -1, 0]
dir_y = [0, 1, 0, -1]


def main():
    H, W = map(int, input().split())
    memo = [[-1]*W for i in range(H)]
    step = 0
    masu = []
    for i in range(H):
        temp = input()
        for c in temp:
            if masu[y][x] == Black:
                memo[y][x] = 0
                steplist.append([y, x])

    while len(steplist) > 0:
        temp_step = step
        step += 1
        next_list = []
        for l in steplist:
            y = l[0]
            x = l[1]
            for i in range(4):
                temp_x = x + dir_x[i]
                temp_y = y + dir_y[i]
                if temp_x >= 0 and temp_x < W and temp_y >= 0 and temp_y < H and memo[temp_y][temp_x] < 0:
                    memo[temp_y][temp_x] = step
                    next_list.append([temp_y, temp_x])
        steplist = next_list
    print(step)


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

Fixed submission:
N,M = map(int,input().split())
H = list(map(int,input().strip().split()))
xy=[map(int, input().split()) for _ in range(M)]
x, y = [list(i) for i in zip(*xy)]

list=[0]*N
for i in range(M):
    if H[x[i]-1]<H[y[i]-1]:
        list[x[i]-1]+=1

    elif  H[x[i]-1]==H[y[i]-1]:
        list[x[i]-1]+=1
        list[y[i]-1]+=1
    else:
        list[y[i]-1]+=1
count=0
for i in range(N):
    if list[i]==0:
        count+=1

print(count)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
H = list(map(int,input().strip().split()))
xy=[map(int, input().split()) for _ in range(M)]
x, y = [list(i) for i in zip(*xy)]

list=[0]*N
for i in range(M):
    if H[x[i]-1]<H[y[i]-1]:
        list[x[i]-1]+=1
    else:
        list[y[i]-1]+=1
count=0
for i in range(M+1):
    if list[i]==0:
        count+=1

print(count)
Problem p02699 (python)

Fixed submission:
S,W = map(int,input().split())

if S <= W:
    print("unsafe")

else :
    print("safe")

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

S_list =list(S)


A = 0
for i in range(0,len(S_list)-1):
    for j in range(i+3,len(S_list)+1):
        P = 0
        S_list_P = S_list[i:j]
        for k in range(0,j-i):
            P += int(S_list_P[k])* 10 ** (j-i-k-1)

        if P % 2019== 0:
            A += 1



print(A)
Problem p02777 (python)

Fixed submission:
S, T = input().split()
A, B = map(int, input().split())
U = input()
 
if U == S:
  A -= 1
if U == T:
  B -= 1

print(A, B)

Buggy submission (verdict: Runtime Error):
S, T = map(int, input().split())
A, B = map(int, input().split())
U int(input())

if U == S:
  A -= 1
if U == T:
  B -= 1
  
print(A, B)
Problem p02779 (python)

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

if len(A) == len(S):
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
S = list(set(A))
if len(A) == len(S):
  return "YES"
else:
  return "NO"
Problem p02879 (python)

Fixed submission:
A,B=map(int, input().split())
if A>9 or A<1:
    print("{}".format(-1))
else:
    if B>9 or B<1:
        print("{}".format(-1))
    else:
        print("{}".format(A*B))

Buggy submission (verdict: Runtime Error):
N=int(input())
if N>81:
    print("No")
else: 
    if N in (1,2,3,4,5,6,7,8,9,10,12,14,15,16,18,20,21,24,25,27,28,30,32,35,36,40,42,45,48,49,54,56,63,64,72,81):
        print("Yes")
    else:
        print("No")

Buggy submission (verdict: Runtime Error):
N=int(input())
if N>81:
    print("No")
else: 
    if N in (1,2,3,4,5,6,7,8,9,10,12,14,15,16,18,20,21,24,25,27,28,30,32,35,36,40,42,45,48,54,56,63,64,72,81):
        print("Yes")
    else:
        print("No")

Buggy submission (verdict: Runtime Error):
N=int(input())
if N>81:
    print("No")
else: 
    if N in (1,2,3,4,5,6,7,8,9,10,12,14,15,16,18,20,21,24,25,27,28,30,32,35,36,40,42,45,48,54,56,63,64,72,81):
        print("Yes")
    else:
        print("No")
Problem p03011 (python)

Fixed submission:
T=list(map(int,input().split(' ')))
T.sort()
print(sum(T[:2]))

Buggy submission (verdict: Runtime Error):
T=list(map(int,input().split(' '))).sort()
print(sum(T[-1]))
Problem p02819 (python)

Fixed submission:
# coding: utf-8

import math

def get_primenumber(number):
    prime_list = []
    
    search_list = list(range(2,number+1))
    while True:
      
      if search_list[0] > math.sqrt(number):
        
        prime_list.extend(search_list)
        break
      else:
        
        head_num = search_list[0]
        prime_list.append(head_num)
        
        search_list.pop(0)
        
        search_list = [num for num in search_list if num % head_num != 0]
    return max(prime_list)

    
a = int(input())
r_before = get_primenumber(a)
s_after = get_primenumber(a)
count = a + 1
if a != r_before:
    while r_before == s_after:
        s_after = get_primenumber(count)
        count += 1
    
print(s_after)

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

num = int(input())
from sympy import sieve
prime_list = [i for i in sieve.primerange(2,num + 1)]
from sympy import nextprime
if num in prime_list:
    print(nextprime(num - 1))
else:
    print(nextprime(num))
Problem p02831 (python)

Fixed submission:
a,b = map(int, input().split(" "))

import fractions
def lcm(x, y):
    return (x * y) / fractions.gcd(x,y)
    
print(int(lcm(a, b)))

Buggy submission (verdict: Runtime Error):
import math

def least_common_multiple(x,y):
    return int((x * y) / math.gcd(x, y))
    
a,b = map(int,input().split(" "))

print(least_common_multiple(a,b))

Buggy submission (verdict: Runtime Error):
import math

def least_common_multiple(x,y):
    return (x * y) / math.gcd(x, y)
    
a,b = map(int,input().split(" "))

print(int(least_common_multiple(a,b)))

Buggy submission (verdict: Runtime Error):
import math

def least_common_multiple(x,y):
    return (x * y) / math.gcd(x, y)
    
a,b = map(int,input().split(" "))

print(int(least_common_multiple(a,b)))
Problem p02832 (python)

Fixed submission:
quantity = int(input())
block = list(map(int,input().rstrip().split(" ")))

num = 1
for i in block:
    if i == num:
        num += 1

if num == 1:
    print(-1)
else:
    print(quantity - num + 1)

Buggy submission (verdict: Runtime Error):
uantity = int(input())
block = list(map(int,input().rstrip().split(" ")))

print(block)

num = 1
for i in block:
    if i == num:
        num += 1

if num == 1:
    print(0)
else:
    print(quantity - num + 1)
Problem p02881 (python)

Fixed submission:
N = int(input())
ans = N*3
for i in range(1,int(N**0.5)+1):
    if N%i==0:
        s1 = i
        s2 =N/i
        
        if ans > s1+s2:
            ans =int(s1+s2)
print(ans-2)

Buggy submission (verdict: Runtime Error):
#ABC 144 C - Walk on Multiplication Table
N = int(input())

import math 
def get_prime(n):
    
    if n <=1:
        return []
    prime = [2]
    limit = int(math.sqrt(n))
    
    # 奇数のリストを作成
    data = [i+1 for i in range(2,n,2)]
    while limit > data[0]:
        prime.append(data[0])
        data = [j for j in data if j % data[0] !=0]
    return prime + data
from itertools import combinations
import functools
import operator
P = get_prime(N)
m = N+1
memo = []
for i in range(1,len(P)+1):
    L1 = list(combinations(P,i))
    L1 = [list(l) for l in L1]
    for l in L1:
        if l not in memo:
            memo.append(l)
            s1 = functools.reduce(operator.mul,l)
            s2 = N/s1
            if s1+s2 <=m:
                m = s1+s2
print(int(m-2))
Problem p03834 (python)

Fixed submission:
# ABC 051 A - Haiku
a,b,c =map(str,input().split(","))
print(a +" "+b+" "+c)

Buggy submission (verdict: Runtime Error):
# ABC 051 B - Sum of Three Integers　
li = list(map(int,input().split()))
k = li[0]
s = li[1]
cnt =0
for x in range(k+1):
    for y in range(k+1):
        z = s-x-y
        if 0<= z <= k: 
            cnt+=1
print(cnt)
Problem p02712 (python)

Fixed submission:
N = int(input())

x = N // 3
y = N // 5
z = N // 15

p = N * (N + 1) / 2
q = 3 * x * (x + 1) / 2
r = 5 * y * (y + 1) / 2
s = 15 * z * (z + 1) / 2
Sum = p - q - r + s
print(int(Sum))

Buggy submission (verdict: Runtime Error):
N = input()
tip = "No"
if (N[0] == 7) or (N[1] == 7) or (N[2] == 7):
  tip = "Yes"
print(tip)
Problem p02693 (python)

Fixed submission:
#A
N = int(input())
A,B = map(int,input().split())
ans =0

for x in range(A,B+1):
    if x%N ==0:
        ans =1
        break
if ans ==1:
    print("OK")
else:
    print("NG")

Buggy submission (verdict: Runtime Error):
import math
A,B,N = map(int,input().split())
maxn = 0
sec =False
for x in range(1,N+1):
    tmp = math.floor((A*x)/B)-A*(math.floor(x/B))
    if maxn < tmp:
        maxn = tmp
    if tmp == 0:
        if sec ==True:
            break
        else:
            sec =True
    
print(maxn)
Problem p02781 (python)

Fixed submission:
from scipy.misc import comb
def solve(i,k,smaller):
    if i == len(S):
        if k == 0:
            #0以外の個数がkと等しいので答えとしてカウントできる
            return 1
        else:
            #0以外の個数がkと等しくないので答えとしてカウント不可
            return 0 
    
    if k ==0:
        #kの個数を使い切りこれ以上下の桁は0で埋まり1通りの為
        return 1
    
    if smaller :
        return comb(len(S)-i,k)*pow(9,k)
    else:
        if S[i] =="0":
            return solve(i+1,k,False)
        else:
            zero = solve(i+1,k,True)
            aida = solve(i+1,k-1,True)*(int(S[i])-1)
            ici  = solve(i+1,k-1,False)
            
            return zero+aida+ici
            
N = int(input())
S = str(N)
K = int(input())

ans = round(solve(0,K,False))

print(int(ans))

Buggy submission (verdict: Runtime Error):
from scipy.special import comb
def solve(i,k,smaller):
    print("i="+str(i))
    if i == len(S):
        if k == 0:
            #0以外の個数がkと等しいので答えとしてカウントできる
            return 1
        else:
            #0以外の個数がkと等しくないので答えとしてカウント不可
            return 0 
    
    if k ==0:
        #kの個数を使い切りこれ以上下の桁は0で埋まり1通りの為
        return 1
    
    if smaller :
        return comb(len(S)-i,k)*pow(9,k)
    else:
        if S[i] =="0":
            return solve(i+1,k,False)
        else:
            zero = solve(i+1,k,True)
            aida = solve(i+1,k-1,True)*(int(S[i])-1)
            ici  = solve(i+1,k-1,False)
            return zero+aida+ici
            
N = int(input())
S = str(N)
K = int(input())

ans = solve(0,K,False)
print(ans)
Problem p02879 (python)

Fixed submission:
x,y=map(int,input().split())
if x<10 and y<10:
    print(x*y)
else:
    print("-1")

Buggy submission (verdict: Runtime Error):
import numpy as np
import sys
sys.setrecursionlimit(10000)
def culc(s,x,m,F_array,eat_time):
   
    K_sum = eat_time/F_array
    must_del = K_sum[K_sum > x]
    must_del = must_del - x
    sum_del = int(np.sum(must_del))
    print(x)
    print(sum_del)
    if sum_del == x:
        return x

    if sum_del > x:
        s = x
        x = int((x+m)/2)
        return culc(s,x,m,F_array,eat_time)
    else:
        m = x
        x = int((x+s)/2)
        return culc(s,x,m,F_array,eat_time)


import numpy as np
N,K = map(int,input().split())
A_list =  list(map(int, input().split()))
F_list =  list(map(int, input().split()))
s = 0
m = 1.0e+18
x = 5.0e+17
eat_time = []
A_list.sort() #min max
F_list.sort(reverse=True) #max -min

A_array = np.array(A_list)
F_array = np.array(F_list)
eat_time =A_array*F_array

print(culc(s,x,m,F_array,eat_time))

Buggy submission (verdict: Runtime Error):
x = int(input())
flag = 0
if x < 10:
    print("Yes")
for l in range(1,10,1):
    num =x/l
    mod = x % l
    if num < 10 and mod == 0:
        flag =1
        break
if flag == 1:
    print("Yes")
else:
    print("No")
Problem p02880 (python)

Fixed submission:
x = int(input())
flag = 0
for l in range(1,10,1):
    num =x/l
    mod = x % l
    if num < 10 and mod == 0:
        flag =1
        break
if flag == 1:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
x = int(input())
flag = 0
if x < 10:
    print("Yes")
    sys.exit(0)
for l in range(1,10,1):
    num =x/l
    mod = x % l
    if num < 10 and mod == 0:
        flag =1
        break
if flag == 1:
    print("Yes")
else:
    print("No")