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

Fixed submission:
S,W = map(int, input().split())
if S > W:
  print('safe')
else :
  print('unsafe')

Buggy submission (verdict: Runtime Error):
S,W = map(int, input().split())
if S > W:
  print(safe)
else :
  print(unsafe)

Buggy submission (verdict: Runtime Error):
S,W = map(int, input().split())
if S > W:
  print(safe)
 else :
  print(unsafe)
Problem p02725 (python)

Fixed submission:
K,N = map(int, input().split())
A =  [int(N) for N in input().split()]

B = []
for i in range(N-1):
    B.append(int(A[i+1] - A[i]))

B.append(int(A[0]+(K-A[N-1])))

B.sort()

Big = B[N-1]

print(K-Big)

Buggy submission (verdict: Runtime Error):
K = int(input())
N = int(input())
A = []

for i in range(N):
    A.append(int(input()))

B = []
for i in range(N-1):
    B[i] = int(A[i] - A[i+1])

B.append(int((K-A[0])-(A[N-1]-K)))

B.sort()

Big = B[N-1]

print(K-Big)
Problem p02753 (python)

Fixed submission:
S = input()
if S == 'AAA' or S == 'BBB':
    print('No')
else :
    print('Yes')

Buggy submission (verdict: Runtime Error):
A,B = map(int, input().split())
X = int((A/0.08)+0.5)
Y = int((B/0.1)+0.5)
min = 0

if X > Y:
    if int(X*0.1) == B:
        min = X
    else :
        min = -1
elif X < Y:
    if int(Y*0.08) == A:
        min = Y
    else :
        min = -1
else :
    min = X

print(min)

Buggy submission (verdict: Runtime Error):
A,B = map(int, input().split())
X = int((A/0.08)+0.5)
Y = int((B/0.1)+0.5)
min = 0
if X == Y:
    min = X
elif X > Y:
    if int(X*0.1) == B:
        min = X
    else :
        min = -1
elif X < Y:
    if int(Y*0.08) == A:
        min = Y
    else :
        min = -1
else :
    min = -1

print(min)

Buggy submission (verdict: Runtime Error):
A,B = map(int, input().split())
X = int((A/0.08)+0.5)
Y = int((B/0.1)+0.5)
min = 0
if X == Y:
    min = X
elif X > Y:
    if int(X*0.1) == B:
        min = X
    else :
        min = -1
elif X < Y:
    if int(Y*0.08) == A:
        min = Y
    else :
        min = -1

print(min)
Problem p03041 (python)

Fixed submission:
n,k=map(int, input().split())
s=list(input())
s[k-1]=s[k-1].lower()
print(*s, sep="")

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
strs=input()
strs=strs.replace(strs[k],strs[k].lower())
print(strs)
Problem p02580 (python)

Fixed submission:
#n=int(input())
#n, p,q,r = map(int, input().split())
#arr = list(map(int, input().split()))
#n=int(input())
#n,m,k = map(int, input().split())
#n, m, k = [int(x) for x in input().split()]
#for _ in range(int(input())):
#n=int(input())
#arr = list(map(int, input().split()))
h, w, m = map(int, input().split())
target_points = {tuple(map(lambda x: int(x) - 1, input().split())) for _ in range(m)}

row_points = [0] * h
col_points = [0] * w
for row, col in target_points:
    row_points[row] += 1
    col_points[col] += 1

row_max = max(row_points)
col_max = max(col_points)

row_max_indexes = [i for i in range(h) if row_points[i] == row_max]
col_max_indexes = [i for i in range(w) if col_points[i] == col_max]
crossing_filled = 0
if len(row_max_indexes) * len(col_max_indexes) <= m:
    if all([(row, col) in target_points for row in row_max_indexes for col in col_max_indexes]):
        crossing_filled=1

print(row_max + col_max - crossing_filled)

Buggy submission (verdict: Runtime Error):
h, w, m = map(int, input().split())
target_points = {tuple(map(lambda x: int(x) - 1, input().split())) for _ in range(m)}
 
row_points = [0] * h
col_points = [0] * w
for row, col in target_points:
    row_points[row] += 1
    col_points[col] += 1
 
row_max = max(row_points)
col_max = max(col_points)
 
row_max_indexes = [i for i in range(h) if row_points[i] == row_max]
col_max_indexes = [i for i in range(w) if col_points[i] == col_max]
crossing_filled =0
if len(row_max_indexes) * len(col_max_indexes) <= m:
	if all([(row,col) in target_points for row in row_max_indexes for  col in col_max_indexes])
 
print(row_max + col_max - crossing_filled)
Problem p02633 (python)

Fixed submission:
# for i in range(m):
# for i in range(int(input())):
#n,k= map(int, input().split())
#for _ in range(int(input())):
    #n,k= map(int, input().split())
#from collections import Counter
n=int(input())
if n%360==0:
    print(0)
    exit()
else:
    var=1
    while (var*n)%360!=0:
        var+=1
    print(var)

Buggy submission (verdict: Runtime Error):
n=int(input())
var=1
if n%360==0:
	print(0)
	exit()
while True:
	if (n*var)%360==0:
		print(var)
        exit()
   var+=1

Buggy submission (verdict: Runtime Error):
n=int(input())
var=1
if n%360==0:
	print(0)
    exit()
while True:
	if (n*var)%360==0:
		print(var)
        exit()
   var+=1
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):
    blue = comb(K-1, i-1, exact=True)
    red_count = N - K
    red = comb(red_count+1, i, exact=True)
    print(blue * red % mod)

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

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

mod = 10 ** 9 + 7

def compute(x, y):
    return comb(x-1, y-1, exact=True)

for i in range(1, K+1):
    blue = compute(K, i)
    red_count = N - K
    red = compute(red_count, i-1) + 2 * compute(red_count, i) + compute(red_count, i+1)
    print(blue * red % mod)
Problem p03017 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**9)

N, A, B, C, D = map(int, input().split())
inputs = list(input())

def compute(index, end):
    if inputs[index] == '#' or index > end:
        return False
    if index == end:
        return True
    return compute(index+1, end) or compute(index+2, end)

flag = False
if A < C and C < B:
    flag = compute(A-1, C-1) and compute(B-1, D-1)
elif B < C < D:
    flag = compute(A-1, C-1) and compute(B-1, D-1)
elif D < C:
    for index in range(B-2, D-1):
        if inputs[index] != '#' and inputs[index+1] != '#' and inputs[index+2] != '#':
            flag = True
    flag = flag and compute(A-1, C-1) and compute(B-1, D-1)

print('Yes' if flag else 'No')

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

def compute(index, end):
    if inputs[index] == '#' or index > end:
        return False
    if index == end:
        return True
    return compute(index+1, end) or compute(index+2, end)

flag = False
if A < C and C < B:
    flag = compute(A-1, C-1) or compute(B-1, D-1)
elif B < C < D:
    flag = compute(A-1, C-1) or compute(B-1, D-1)
elif D < C:
    pass

print('Yes' if flag else 'No')

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

def compute(index, end):
    if inputs[index] == '#' or index > end:
        return False
    if index == end:
        return True
    return compute(index+1, end) or compute(index+2, end)

flag = False
if A < C and B < C:
    flag = compute(A-1, C-1) or compute(B-1, D-1)
elif B < C < D:
    pass
elif D < C:
    pass

print('Yes' if flag else 'No')
Problem p03201 (python)

Fixed submission:
from collections import Counter

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

inputs.sort(reverse=True)
counter_inputs = Counter(inputs)
powers_of_two = [2**i for i in range(1, 31)]
ans = 0

for item in inputs:
    if counter_inputs[item] > 0:
        counter_inputs[item] -= 1
    
        while powers_of_two[-1] > 2 * item:
            powers_of_two.pop(-1)
        
        pair = powers_of_two[-1] - item
        if counter_inputs[pair] > 0:
            ans += 1
            counter_inputs[pair] -= 1
    
print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import collections
    
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
c=collections.Counter(A)
    
pairCounter=0
    
beki=29
nibeki=2**beki
    
for i in range(N):
    target = A[i]
    if c[target] < 1:
    continue
    c[target]-= 1
    
    while (nibeki > target):
    beki-=1
    nibeki=2**beki
    
    pair = nibeki * 2 - target
    if pair in c.keys() and c[pair] > 0:
        c[pair]-= 1
        pairCounter+=1
     
print(pairCounter)
Problem p03207 (python)

Fixed submission:
N = int(input())

A = [int(input()) for _ in range(N)]

print(sum(A) - max(A) // 2)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(i) for i in rnage(N)]

print(sum(A) - max(A) // 2)
Problem p03209 (python)

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

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): # X <= 0 や X > a_N を許容し解説本文から簡略化
    if N == 0:
        return 0 if X <= 0 else 1
    elif X <= 1 + a[N-1]:
        return f(N-1, X-1)
    else:
        return p[N-1] + 1 + f(N-1, X-2-a[N-1])

print(f(N, X))

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

result = 'P'

for i in range(1, N+1):
    result = 'B' + result + 'P' + result + 'B'
    if len(result) >= X:
        break
    
print(result[:X].count('P'))

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

result = 'P'

for i in range(1, N+1):
    result = 'B' + result + 'P' + result + 'B'
    
print(result[:X].count('P'))

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

result = ['P']

for i in range(1, N+1):
    result.append('B' + result[i-1] + 'P' + result[i-1] + 'B')
    
print(result[-1][:X].count('P'))
Problem p03329 (python)

Fixed submission:
n = int(input())
v = []
i = 6
while i<=n:
    v.append(i)
    i *= 6
i=9
while i <= n:
    v.append(i)
    i *= 9
v.sort(reverse=True)
dic = dict()
def dp(i, N):
    if i == len(v):
        return N
    if (i, N) not in dic:
        dic[(i, N)] = min(dp(i, N-v[i])+1, dp(i+1, N)) if N-v[i] >= 0 else dp(i+1, N)
    return dic[(i, N)]
print(dp(0, n))

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

count = 0

numbers = sorted([9**5, 9**4, 9**3, 9**2, 9, 6**6, 6**5, 6**4, 6**3, 6**2, 6], reverse=True)

def search(n):
    for i in numbers:
        if i <= n:
            return i

for i in range(1000):
    N -= search(N)
    count += 1
    if 1 <= N <= 5:
        count += N
        break
    elif N == 0:
        break

print(count)
Problem p02572 (python)

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

mod = (10**9 + 7)
ans = 0

import numpy
alistsum = numpy.cumsum(alist)
asum = sum(alist)

for i in range(n-1):
    ans += alist[i]*(asum - alist[i])
    asum -= alist[i]
    ans = ans%mod
print(ans)

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

mod = (10**9 + 7)
ans = 0

import numpy
alistsum = numpy.cumsum(alist)

for i in range(n-1):
    ans += alist[i]*(alistsum[-1]-alistsum[i])
    ans = ans%mod

print(ans)
Problem p02659 (python)

Fixed submission:
a,b=input().split()
a = int(a)
b = float(b)
b = round(b * 100)
ans = (a*b) // 100
print(ans)

Buggy submission (verdict: Runtime Error):
a,b=input().split()
a = int(a)
b = float(b)
b = round(b * 100)
ans = (a*c) // 100
print(ans)
Problem p02766 (python)

Fixed submission:
n,k = map(int,input().split())
a = 1
while k**a <= n:
    a += 1

print(a)

Buggy submission (verdict: Runtime Error):
,k = map(int,input().split())
a = 1
while k**a < n:
    a += 1

print(a)
Problem p02831 (python)

Fixed submission:
a,b = map(int,input().split())
import fractions
print((a*b)//fractions.gcd(a,b))

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

import math
print((a*b)//math.gcd(a,b))
Problem p02835 (python)

Fixed submission:
a,b,c=map(int,input().split())
if (a+b+c) >= 22:
    print('bust')
else:
    print('win')

Buggy submission (verdict: Runtime Error):
x,y,z = map(int,input().split())
	if x+y+z >= 22:
		print('bust')
	else:
		print('win')

Buggy submission (verdict: Runtime Error):
x,y,z = map(int,input().split())

	if x+y+z >= 22:

		print('bust')

	else:

		print('win')
Problem p02847 (python)

Fixed submission:
a = {'SUN':7,'MON':6,'TUE':5,'WED':4,'THU':3,'FRI':2,'SAT':1}
s = input()

ans = a.get(s)
print(ans)

Buggy submission (verdict: Runtime Error):
a,b,x = map(int,input().split())

ok = 0
ng = 10**9 + 1

def isok(arg):
    return a*arg+b*len(str(arg))

while abs(ng - ok) > 1 :
    mid = (ok+ng)//2
    if isok(mid) <= x:
        ok = mid
    else:
        ng = mid

print(mid)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
a = ''
for i in range(0,len(s)):
   cc = 65+ (ord(s[i]) + n - 65)%26
   a += chr(cc)

print(a)
Problem p02571 (python)

Fixed submission:
s = input()
t = input()
s_list = list(s)
t_list = list(t)
compare = []
score = []

if s == t:
    print(0)
else:
    for i in range(len(s) - len(t) + 1):
        compare.append(s[i : i + len(t)])
    
    for v in compare:
        count = 0
        for v1, v2 in zip(list(v), t_list):
            #print(v1, v2)
            if v1 == v2:
                count += 1
        score.append(count)
    print(len(t) - max(score))

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
s_list = list(s)
t_list = list(t)
compare = []
score = []

if s == t:
    print(0)
else:
    for i in range(len(s) - len(t) + 1):
        compare.append(s[i : i + len(t)])
    
    for v in compare:
        count = 0
        for v1, v2 in zip(list(v), t_list):
            #print(v1, v2)
            if v1 == v2:
                count += 1
        score.append(count)

print(len(t) - max(score))
Problem p02725 (python)

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

answer = []

for i,home in enumerate(A):
    if home < A[i - 1]:
        answer.append(home - A[i - 1] + KN[0])
    else:
        answer.append(home - A[i - 1])

print(KN[0] - max(answer))

Buggy submission (verdict: Runtime Error):
KN = list(map(int, input().split()))
A = list(map(int, input().split()))

answer = []

for i,home in enumerate(A):
    kouho = home - A[i - 1]
    if kouho < 0:
        answer.append(20 + kouho)
    else:
        aanswer.append(kouho)

print(20 - max(answer))
Problem p02659 (python)

Fixed submission:
import decimal
a,b=map(decimal.Decimal,input().split())
print(int(a*b))

Buggy submission (verdict: Runtime Error):
import dcimal
a,b=map(decimal.Decimal,input().split())
print(int(a*b))
Problem p02711 (python)

Fixed submission:
n=input()

if "7" in n:
  print("Yes")
  
else:
  print("No")

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

if "7" in n:
  print("Yes")
  
else:
  print("No")
Problem p02754 (python)

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

ab=a+b
num=n//ab
n-=ab*num

if n>=a:
  ans=a
  
else:
  ans=n
  
print(ans+num*a)

Buggy submission (verdict: Runtime Error):
import math

n,a,b=map(int,input().split())
st="b"*a+"r"*b

num=math.floor(n/(a+b))
s=st*num

for i in range(n-len(s)):
  if i+1<=a:
    s+="b"
  else:
    s+="r"
    
print(s.count("b"))

Buggy submission (verdict: Runtime Error):
import math

n,a,b=map(int,input().split())
st="b"*a+"r"*b

num=math.floor(n/(a+b))
s=st*num

for i in range(n-len(s)):
  if i<=a:
    s+="b"
  else:
    s+="r"
    
print(s.count("b"))

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

count="b"*a
count+="r"*b

if len(count)==n:
  print(count.count("b"))
elif a==0:
  print(0)
else:
  n-=len(count)
  if n<=a:
    count+="b"*n
    print(count.count("b"))
  else:
    while n>0:
      if n==a+b:
        count+="b"*a
        count+="r"*b
        print(count.count("b"))
      elif n<=a+b:
        count+="b"*n
        print(count.count("b"))
      else:
        count+="b"*a
        count+="r"*b
        n-=a+b

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

count="b"*a
count+="r"*b

if len(count)==n:
  print(count.count("b"))
else:
  n-=len(count)
  if n<=a:
    count+="b"*n
    print(count.count("b"))
  else:
    for i in range(n):
      if i+1<=a:
        count+="b"
      if i+1==a+b:
        n-=a+b
    print(count.count("b"))
Problem p03042 (python)

Fixed submission:
s=input()
be=s[:2]
af=s[2:]

if s=="0000":
  print("NA")

elif int(be)<=12 and int(af)<=12 and be!="00" and af!="00":
  print("AMBIGUOUS")

elif int(af)<=12 and af!="00":
    print("YYMM")
    
elif int(be)<=12 and be!="00":
    print("MMYY")
  
else:
  print("NA")

Buggy submission (verdict: Runtime Error):
s=input()
be=s[:2]
af=s[2:]

if s=="0000":
  print("NA")

elif int(be)<=12 and int(af)<=12 and be!="00" and af!=="00":
  print("AMBIGUOUS")

elif int(af)<=12:
  if af=="00":
    print("NA")
  else:
    print("YYMM")
    
elif int(be)<=12:
  if be=="00":
    print("NA")
  else:
    print("MMYY")
  
else:
  print("NA")

Buggy submission (verdict: Runtime Error):
s=input()
be=s[:2]
af=s[2:]

if s=="0000":
  print("NA")
  
if be=="00" or af=="00":
  if int(af)<=12:
    if af=="00":
      print("NA")
    else:
      print("YYMM")
      
  elif int(be)<=12:
  if be=="00":
    print("NA")
  else:
    print("MMYY")

elif int(be)<=12 and int(af)<=12:   
    print("AMBIGUOUS")
  
else:
  print("NA")
Problem p02735 (python)

Fixed submission:
from collections import *
from heapq import *
H,W=map(int,input().split())
S=[input() for i in range(H)]
if S[0][0]=="#":
    count=1
else:
    count=0
idlemax=10**5
visited=[[idlemax for w in range(W)] for h in range(H)]
stack=deque([[0,0,bool(S[0][0]=="#")*1,bool(S[0][0]=="#")*1]])
while stack:

    h,w,m,flag=stack.popleft()
    if m>visited[h][w]:
        continue
    for y,x in [[0,1],[1,0]]:
        Y=h+y;X=w+x
        if Y<H and X<W:
            if flag:
                if visited[Y][X]>m:
                    if S[Y][X]==".":
                        nflag=0
                    else:
                        nflag=1
                    visited[Y][X]=m
                    stack.append([Y,X,m,nflag])
            else:
                if S[Y][X]=="#":
                    nflag=1
                    M=m+1
                else:
                    nflag=0
                    M=m
                if visited[Y][X]>M:
                    visited[Y][X]=M
                    stack.append([Y,X,M,nflag])
#print(visited)
print(visited[-1][-1])

Buggy submission (verdict: Runtime Error):
from collections import *
H,W=map(int,input().split())
S=[input() for i in range(H)]
count=0
stack=deque([[0,0,0,S[0][0]=="#"]])
RuiW=[[0] for i in range(H)]
RuiH=[[0] for i in range(W)]
if S[0][0]=="#":
    RuiW[0][0]=1
    RuiH[0][0]=1

for h in range(H):
    flag=0
    for w in range(1,W):
        RuiW[h].append(RuiW[h][-1]+bool(S[h][w]=="#" and S[h][w-1]=="."))
for w in range(W):
    for h in range(1,H):
        RuiH[w].append(RuiH[w][-1]+bool(S[h][w]=="#" and S[h-1][w]=="."))

Range=range(1,100)
idle_max=10**9
visited=[[idle_max for i in range(W)] for m in range(H)]
#print(RuiW)
#print(RuiH)
while stack:
    h,w,m,Flag=stack.popleft()
    if visited[h][m]<m:
        continue
    for i in Range:
        if h+i>=H:
            break
        M=RuiH[w][h+i]-(RuiH[w][h]-RuiH[w][h]%2)+m

        if visited[h+i][w]>M:
            visited[h+i][w]=M
            stack.append([h+i,w,M,0])
    for i in Range:
        if w+i>=W:
            break
        M=RuiW[h][w+i]-(RuiW[h][w]-RuiW[h][w]%2)+m
        if visited[h][w+i]>M:
            visited[h][w+i]=M
            stack.append([h,w+i,M,0])
#print(visited)
print(visited[-1][-1])
Problem p02759 (python)

Fixed submission:
from collections import *
from itertools import *
from bisect import *
from heapq import *
import copy
#import math

#N=int(input())
#X,Y=map(int,input().split())
#S=list(map(int,input().split()))
#S=[list(map(int,input().split())) for i in range(N)]

N=int(input())
print(N//2+N%2)

Buggy submission (verdict: Runtime Error):
from collections import *
from itertools import *
from bisect import *
from heapq import *
import copy
import math

def get_circle_center_and_radius(x1, y1, x2, y2, x3, y3):
    """
    3点を通る円の中心と半径を取得
    """
    d = 2 * ((y1 - y3) * (x1 - x2) - (y1 - y2) * (x1 - x3))
    if d==0:
        return(0)
    x = ((y1 - y3) * (y1 ** 2 - y2 ** 2 + x1 ** 2 - x2 ** 2) - (y1 - y2) * (y1 ** 2 - y3 ** 2 + x1 ** 2 - x3 ** 2)) / d
    y = ((x1 - x3) * (x1 ** 2 - x2 ** 2 + y1 ** 2 - y2 ** 2) - (x1 - x2) * (x1 ** 2 - x3 ** 2 + y1 ** 2 - y3 ** 2)) / -d
    #r = math.sqrt((x - x1) ** 2 + (y - y1) ** 2)
    return (x, y)
#N=int(input())
#X,Y=map(int,input().split())
#S=list(map(int,input().split()))
#S=[list(map(int,input().split())) for i in range(N)]
N,K=map(int,input().split())
XYC=[list(map(int,input().split())) for i in range(N)]
if K==1:
    print(0)
    exit()
count=10**18

if N>=2:
    nlst=combinations(list(range(N)),2)

    for n1,n2 in nlst:
        x1,y1,c1=XYC[n1]
        x2,y2,c2=XYC[n2]
        A=c1+c2
        X=(x1*c1+x2*c2)/A
        Y=(y1*c1+y2*c2)/A
        count1=[]
        for x,y,c in XYC:
            count1.append(((X-x)**2+(Y-y)**2)**0.5*c)
        count1.sort()
        #print(X,Y,count1)
        count=min(count,count1[K-1])

if N>=3:
    nlst=combinations(list(range(N)),3)
    for n1,n2,n3 in nlst:
        x1,y1,c1=XYC[n1]
        x2,y2,c2=XYC[n2]
        x3,y3,c3=XYC[n3]
        C=get_circle_center_and_radius(c1*x1,c1*y1,c2*x2,c2*y2,c3*x3,c3*y3)
        if C:
            X,Y=C
        else:
            continue
        X,Y=X/A,Y/A

        count1=[]
        for x,y,c in XYC:
            count1.append(((X-x)**2+(Y-y)**2)**0.5*c)
        count1.sort()

        count=min(count,count1[K-1])

print(count)
Problem p02781 (python)

Fixed submission:
from bisect import *
from collections import *
from fractions import gcd
from math import factorial
def permutations_count(n, r):
    if not n>=r>=0:
        return(0)
    else:
        return factorial(n) // factorial(n - r)
def combinations_count(n, r):
    if not n>=r>=0 or n<0:
        return(0)
    elif r==0:
        return(1)
    else:
        return factorial(n) // (factorial(n - r) * factorial(r))
N=input()
K=int(input())
length=len(str(N))
count=0
count3=0
flag=1
for i in range(length):
    if N[i]!="0":
        if K-count3 >=1:count+=combinations_count(length-1-i,K-count3)*(9**(K-count3))
        if K-count3-1 >=0:count+=combinations_count(length-1-i,K-count3-1)*(9**(K-1-count3))*(int(N[i])-1)
        count3+=1
    if K-count3==0:
        count+=1
        #count+=int(N[i])
        break
print(count)

Buggy submission (verdict: Runtime Error):
from bisect import *
from collections import *
from fractions import gcd
from math import factorial
def permutations_count(n, r):
    if not n>=r>=0:
        return(0)
    else:
        return factorial(n) // factorial(n - r)
def combinations_count(n, r):
    if not n>=r>=0 or n<=0:
        return(0)
    elif r==0:
        return(1)
    else:
        return factorial(n) // (factorial(n - r) * factorial(r))
N=input()
K=int(input())
if length<K:
    print(0)
    exit()
length=len(str(N))
count=0
count3=0
flag=1
for i in range(length):
    if N[i]!="0":
        if i<length-1:
            if K-count3 >=0:count+=combinations_count(length-1-count3,K-count3)*(9**(K-count3))
            if K-count3-1 >=0:count+=combinations_count(length-1-count3,K-count3-1)*(9**(K-1-count3))*(int(N[i])-1)
            count3+=1
    if K-count3==0:
        count+=1
        #count+=int(N[i])
        break
    if i==length-1:
        count+=int(N[i])
print(count)