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

Fixed submission:
n = [int(i) for i in input().split()]
if n[0] == 1 and n[1] < n[2]:
    print(0)
elif n[1]>n[2]:
    print(0)
elif n[0] == 1 and n[1]==n[2]:
    print(1)
else:
    mi = n[1]*(n[0]-1)+n[2]
    ma = n[2]*(n[0]-1)+n[1]
    print(ma-mi+1)

Buggy submission (verdict: Runtime Error):
from itertools import combinations
n = [int(i) for i in input().split()]
if n[0] == 1 and n[1] < n[2]:
    print(0)
elif n[1]>n[2]:
    print(0)
elif n[0] == 1 and n[1]==n[2]:
    print(1)
else:
    m = range(n[1],n[2]+1)
    if n[0] != 2:
        c = list(combinations(m,n[0]-2))
        c.extend([(i,i) for i in m])
    else:
        c = [(i,i) for i in m]
    print(len(set([i+j for i,j in c])))

Buggy submission (verdict: Runtime Error):
import combinations from itertools
n = [int(i) for i in input().split()]
if n[0] == 1 and n[1] < n[2]:
    print(0)
elif n[1]>n[2]:
    print(0)
elif n[0] == 1 and n[1]==n[2]:
    print(1)
else:
    m = range(n[1],n[2]+1)
    c = list(combinations(m,n[0]-2))
    c.extend([(i,i) for i in m])
    print(len(set([i+j for i,j in c])))

Buggy submission (verdict: Runtime Error):
import itertools
n = [int(i) for i in input().split()]
if n[0] == 1 and n[1] < n[2]:
    print(0)
elif n[1]>n[2]:
    print(0)
elif n[0] == 1 and n[1]==n[2]:
    print(1)
else:
    m = range(n[1],n[2]+1)
    l = n[0]-2
    c = list(itertools.combinations(m,l))
    c.extend([(i,i) for i in m])
    print(len(set([i+j for i,j in c])))
Problem p03329 (python)

Fixed submission:
money = int(input())

six = [6**i for i in range(1, 8)]
nine = [9**i for i in range(1, 7)]

all = [1] + sorted(six + nine)

dp = [100000 for i in range(100001)]
dp[0] = 0

for i in range(0, 100001):
    for el in all:
        temp = i + el
        if temp < 100001:
            dp[temp] = min(dp[temp], dp[i] + 1)

print(dp[money])

Buggy submission (verdict: Runtime Error):
import math

money = int(input())

six = [6**i for i in range(1, 8)]
nine = [9**i for i in range(1, 7)]

all = [1] + sorted(six + nine)

dp = [float(math.inf) for i in range(100001)]
dp[0] = 0

for i in range(0, 100001):
    for el in all:
        temp = i + el
        if temp < 100001:
            dp[temp] = min(dp[temp], dp[i] + 1)

print(dp[money])
Problem p03329 (python)

Fixed submission:
def knapsack(V,n):
    if n == -1:
        return V
    if (V,n) in OS_dict.keys():
        return OS_dict[(V,n)]
    elif V < cost[n]:
        r = knapsack(V,n-1)
        OS_dict[(V, n)] = r
        return r
    else:
        r = min(knapsack(V-cost[n],n)+value[n],knapsack(V,n-1)) 
        OS_dict[(V,n)] = r
        return r



N = int(input())
now = 9
cost = []
value = []
while now <= N:
    cost.append(now)
    now *= 9
now = 6
while now <= N:
    cost.append(now)
    now *= 6
for x in range(len(cost)):
    value.append(1)
OS_dict = {}
V = N
best = knapsack(V,len(cost)-1)
print(best)

Buggy submission (verdict: Runtime Error):
def knapsack(V,n):
    if n == -1:
        return V
    if (V,n) in OS_dict.keys():
        return OS_dict[(V,n)]
    elif V < cost[n]:
        r = knapsack(V,n-1)
        OS_dict[(V, n)] = r
        return r
    else:
        r = min(knapsack(V,n-1),knapsack(V-cost[n],n)+value[n]) #完全背包问题只需将第二个选项改为knapsack(V-cost[n],n)+value[n]
        OS_dict[(V,n)] = r
        return r



N = int(input())
now = 9
cost = []
value = []
while now <= N:
    cost.append(now)
    now *= 9
now = 6
while now <= N:
    cost.append(now)
    now *= 6
for x in range(len(cost)):
    value.append(1)
OS_dict = {}
V = N
best = knapsack(V,len(cost)-1)
print(best)
Problem p03803 (python)

Fixed submission:
N = input().split()
A = int(N[0])
B = int(N[1])

if A > B:
    if B != 1:
        print("Alice")
    else:
        print("Bob")
elif A == B:
    print("Draw")
else:
    if A != 1:
        print("Bob")
    else:
        print("Alice")

Buggy submission (verdict: Runtime Error):
import sys

input_num = input().split()
N = int(input_num[0])
M = int(input_num[1])

A = [input() for i in range(0, N-1)]
B = [input() for n in range(0, M-1)]

if M > N:
    print("No")
elif M == N:
    for a, b in zip(A, B):
        if b not in a:
            print("No")
    else:
        print("Yes")
else:
    diff = N - M
    breaked = False
    for i in range(0, len(A)-1):
        l = i
        while l <= i + diff and l < len(B):
            if A[i] == B[l]:
                breaked = True
                break
            else:
                if breaked:
                    print("No")
                    sys.exit()
                l += 1
    if breaked:
        print("Yes")
    else:
        print("No")
Problem p03803 (python)

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

if a == 1 or b == 1:
    if a < b:
        print "Alice"
    elif a == b:
        print "Draw"
    elif a > b:
        print "Bob"
else:
    if a > b:
        print "Alice"
    elif a == b:
        print "Draw"
    elif a < b:
        print "Bob"

Buggy submission (verdict: Runtime Error):
import numpy as np
n, m = map(int, raw_input().split())
a = [raw_input() for _ in xrange(n)]
b = [raw_input() for _ in xrange(m)]
f = False
for i in xrange(m):
    if b[i] in a:
        f = True

if f:
    print "Yes"
else:
    print "No"
Problem p03345 (python)

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

if k%2==1:
    print(b-a)
else:
    print(a-b)

Buggy submission (verdict: Runtime Error):
n=int(input())
p=[]
for i in range (n):
	p.append(int(input()))
pos=0
num=0
n_th = 0
s={}
for i in p:
	if i-1 in s:
		s[i]=s[i-1]+1
	else:
		s[i]=1
print(n-max(s.values()))
Problem p03346 (python)

Fixed submission:
n=int(input())
p=[]
for i in range (n):
	p.append(int(input()))
pos=0
num=0
n_th = 0
s={}
for i in p:
	if i-1 in s:
		s[i]=s[i-1]+1
	else:
		s[i]=1
print(n-max(s.values()))

Buggy submission (verdict: Runtime Error):
n=int(input())
p=[]
for i in range (n):
	p.append(int(input()))
pos=0
num=0
n_th = 0
for i in range(n)
	if i+1 in p[pos:]:
		num += 1
		pos = p[pos:].index(i+1)+pos
	else:
		if num>n_th:
			n_th = num
		if i+1 in p:
			num = 1
			pos = p.index(i+1)
if num >n_th:
	print (n-num)
else:
	print(n-n_th)
Problem p03986 (python)

Fixed submission:
line = input()

ori = len(line)

count = 0 

T = 0 
S = 0 

for i in line:
    if i is "S":
        S += 1
    else:
        if S is not 0:
            S -= 1
            count += 1

print(ori - count * 2)

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

N = int(sys.stdin.readline())
P = np.array([int(x) for x in sys.stdin.readline().split()])

SUM = np.sum([np.sum([min(P[l:r+1]) for r in range(l, N)]) for l in range(N)])

print(SUM)

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

N = int(sys.stdin.readline())
P = np.array([int(x) for x in sys.stdin.readline().split()])

SUM = np.sum([np.sum([np.min(P[l:r+1]) for r in range(l, N)]) for l in range(N)])

print(SUM)

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

N = int(sys.stdin.readline())
P = np.array([int(x) for x in sys.stdin.readline().split()])

SUM = np.sum([np.sum([min(P[l:r+1]) for r in range(l, N)]) for l in range(N)])

print(SUM)
Problem p03775 (python)

Fixed submission:
def f(a, b):
    al = len(str(int(a)))
    bl = len(str(int(b)))
    if al > bl:
        return al
    return bl
N = int(input())
result = len(str(N))
for a in range(1, N):
    if a*a > N:
        break
    if (N % a) != 0:
        continue
    b = N / a
    r = f(a, b)
    if r < result:
        result = r
print (result)

Buggy submission (verdict: Runtime Error):
def f(a, b):
    al = len(str(a))
    bl = len(str(b))
    if al > bl:
        return al
    return bl
N = int(input())
n = int(N**0.5)
result = 12
for i in range(1, n+1):
    for j in range(1, n+1):
        if i*j == N:
            r = f(i, j)
            if r < result:
                result = r
print result()
Problem p03345 (python)

Fixed submission:
import sys

A , B , C, K = map(int,input().split())

a = K % 2
res = (A - B)
if abs(res) > 10**18:
    print("unfair")
if a == 1:
    print(B - A)
elif a == 0:
    print(A - B)

Buggy submission (verdict: Runtime Error):
import sys

A , B , C, K = map(int,input().split())

a_0 = 1
a_1 = 0
a_2 = 0

i = 0
while i < K:
    a_0 = a_1 + a_2
    a_1 = a_0 + a_2
    a_2 = a_0 + a_1
    
    i = i + 1
    
res = (A - B) * (a[0] - a[1])
if res < 10**18:
    print(res)
else:
    print("unfair")
Problem p03345 (python)

Fixed submission:
inputs = [int(c) for c in input().split()]
ans = inputs[0] - inputs[1] if inputs[3] % 2 == 0 else inputs[1] - inputs[0]
if ans > 10**18:
  print("Unfair")
else:
  print(ans)

Buggy submission (verdict: Runtime Error):
inputs = split(input())
ans = inputs[0] - inputs[1] if inputs[3] % 2 == 0 else inputs[1] - inputs[0]
if ans > 10**18:
  print("Unfair")
else:
  print(ans)
Problem p03835 (python)

Fixed submission:
K,S=map(int,input().split())
b=sum(0<=S-x-y<=K  for x in range(K+1)for y in range(K+1))
print(b)

Buggy submission (verdict: Runtime Error):
K,S=map(int,input().split())
b=sum(0<=S-x-y<=K  for x in range(K+1)for y in range(K+1))
print(sum
Problem p03804 (python)

Fixed submission:
import numpy as np
import sys
temp = input().split()
N = int(temp[0])
M = int(temp[1])
A = []
B = []
check = False
def change(n):
  if(n=='#'):
    return True;
  return False;

for i in range(N):
  temp = input()
  A.append(list(map(change, temp)))
for i in range(M):
  temp = input()
  B.append(list(map(change, temp)))
A = np.array(A)
B = np.array(B)

for i in range(N-M+1):
  for j in range(N-M+1):
    if (B== A[i:M+i, j:M+j]).all():
      check = True
      break
  if check:
    break

if check:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
import numpy as np
import sys
temp = input().split()
N = int(temp[0])
M = int(temp[1])
A = []
B = []
check = False
def change(n):
  if(n=='#'):
    return True;
  return False;

for i in range(N):
  temp = input()
  A.append(list(map(change, temp)))
for i in range(M):
  temp = input()
  B.append(list(map(change, temp)))
A = np.array(A)
B = np.array(B)

for i in range(N-M+1):
  for j in range(N-M+1):
    if (B== A[i:M+j, i:M+j]).all():
      check = True
      break
  if check:
    break

if check:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
import numpy as np
import sys
temp = input().split()
N = int(temp[0])
M = int(temp[1])
A = []
B = []
def change(n):
  if(n=='#'):
    return True;
  return False;

for i in range(N):
  temp = input()
  A.append(list(map(change, temp)))
for i in range(M):
  temp = input()
  B.append(list(map(change, temp)))
A = np.array(A)
B = np.array(B)

for i in range(N-M+1):
  for j in range(N-M+1):
    if (B== A[i:M+j, i:M+j]).all():
      print("Yes")
      sys.exit()

print("No")

Buggy submission (verdict: Runtime Error):
import numpy as np
import sys
N = int(input())
M = int(input())
A = []
B = []
def change(n):
  if(n=='#'):
    return True;
  return False;

for i in range(N):
  temp = input()
  A.append(list(map(change, temp)))
for i in range(M):
  temp = input()
  B.append(list(map(change, temp)))
A = np.array(A)
B = np.array(B)

for i in range(N-M+1):
  for j in range(N-M+1):
    if (B== A[i:M+j, i:M+j]).all():
      print("Yes")
      sys.exit()

print("No")
Problem p03803 (python)

Fixed submission:
(A,B) = [int(x) for x in input().split()]
if A == B:
    print("Draw")
elif A == 1:
    print("Alice")
elif B == 1:
    print("Bob")
elif A > B:
    print("Alice")
else:
    print("Bob")

Buggy submission (verdict: Runtime Error):
if A == B:
    print("Draw")
elif A == 1:
    print("Alice")
elif B == 1:
    print("Bob")
elif A > B:
    print("Alice")
else:
    print("Bob")
Problem p03835 (python)

Fixed submission:
K, S = list(map(int, input('').split()))
count = 0
for x in range(K+1):
  for y in range(K+1):
    if x + y <= S and x + y + K >= S:
      count += 1
print(count)

Buggy submission (verdict: Runtime Error):
def check(x, y, S):

K, S = list(map(int, input('').split()))
count = 0
for x in range(K+1):
  for y in range(K+1):
    if x + y <= S:
      count += 1
print(count)

Buggy submission (verdict: Runtime Error):
def check(x, y, S):

K, S = list(map(int, input('').split()))
count = 0
for x in range(K+1):
  for y in range(K+1):
    if x + y <= S:
      count += 1
print(count)

Buggy submission (verdict: Runtime Error):
def check(x, y, K, S):
  for z in range(K+1):
    if x + y + z == S:
      return true
  return false

K, S = list(map(int, input('').split()))
count = 0
for x in range(K+1):
  for y in range(K+1):
    if check(x, y, K, S):
      count += 1
print(count)
Problem p03804 (python)

Fixed submission:
import sys
if __name__ == '__main__':

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

    A = []
    B = []
    for i in range(N):
        A.append(input())
    for i in range(M):
        B.append(input())

    char = B[0][0]
    matc = False
    for i in range(N-M+1):
        for j in range(N-M+1):
            if A[i][j] == char:
                matc = True
                for k in range(M):
                    for l in range(M):
                        if A[i+k][j+l] == B[k][l]:
                            matc = True
                        else:
                            matc = False
                            break
                    if not matc:
                        break
                if matc == True:
                    print("Yes")
                    sys.exit(0)

    if matc == True:
        print("Yes")
    else:
        print("No")

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

A = []
B = []
for i in range(N):
    A.append(input())
for i in range(M):
    B.append(input())


for i in range(N-M):
    x = A[i].find(B[0])
    if x != -1:
        result = True
        break
    result = False

for j in range(1,M):
    if (j >= M or j >= N ):
        result = False
        break
    idx = A[j][x:].find(B[j])
    if idx != x:
        result = False
        break

if result == True:
    print("Yes")
else:
    print("No")

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

A = []
B = []
for i in range(N):
    A.append(input())
for i in range(M):
    B.append(input())


for i in range(N-M):
    x = A[i].find(B[0])
    if x != -1:
        result = True
        break
    result = False

for j in range(1,M):
    idx = A[j][x:].find(B[j])
    if idx != x:
        result = False
        break

if result == True:
    print("Yes")
else:
    print("No")
Problem p03774 (python)

Fixed submission:
N,M = list(map(int, input().split()))
a = [0]*N
b = [0]*N
c = [0]*M
d = [0]*M
for k in range(N):
     a[k],b[k] = list(map(int, input().split()))
for l in range(M):
     c[l],d[l] = list(map(int, input().split()))

for i in range(N):
    s=10**9
    for j in range(M):
        if  s>abs(a[i]-c[j])+abs(b[i]-d[j]):
             s=abs(a[i]-c[j])+abs(b[i]-d[j])
             e=j+1
    print(e)

Buggy submission (verdict: Runtime Error):
N,M = list(map(int, input().split()))
a = [0]*N
b = [0]*N
c = [0]*M
d = [0]*M
for k in range(N):
     a[k],b[k] = list(map(int, input().split()))
for l in range(M):
     c[l],d[l] = list(map(int, input().split()))

for i in range(N):
    s=10**8+1
    for j in range(M):
        if  s>abs(a[i]-c[j])+abs(b[i]-d[j]):
             s=abs(a[i]-c[j])+abs(b[i]-d[j])
             e=j+1
    print(e)

Buggy submission (verdict: Runtime Error):
N,M = list(map(int, input().split()))
a = [0]*N
b = [0]*N
c = [0]*M
d = [0]*M
for k in range(N):
     a[k],b[k] = list(map(int, input().split()))
for l in range(M):
     c[l],d[l] = list(map(int, input().split()))

for i in range(N):
    s=10**8
    for j in range(M):
        if  s>abs(a[i]-c[j])+abs(b[i]-d[j]):
             s=abs(a[i]-c[j])+abs(b[i]-d[j])
             e=j+1
    print(e)
Problem p03803 (python)

Fixed submission:
A, B=map(int,input().split())
 
func=lambda x:[x,x+13][x==1]
 
if func(A)==func(B):
  print('Draw')
elif func(A)<func(B):
  print('Bob')
else:
  print('Alice')

Buggy submission (verdict: Runtime Error):
A, B=map(int,input())

func=lambda x:(x,x+13)[x==1]

if func(A)==func(B):
  print('Draw')
elif func(A)<func(B):
  print('Bob')
else:
  print('Alice')
Problem p03834 (python)

Fixed submission:
s=input()

print(s.replace(',',' '))

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

s[5]=' '
s[13]=' '

print(s)
Problem p03835 (python)

Fixed submission:
k,s=map(int,input().split())
 
c=0
m=min(s,k)
for x in range(m+1):
  for y in range(m+1):
    if s<x+y:
      break
    elif s>x+y+k:
      continue
    else:
      c+=1
print(c)

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

c=0
m=min(s,k)
for x in range(m+1):
  for y in range(m+1-x)
    for z in range(m+1-x-y)
      if x+y+z==s:
        c+=1
print(c)
Problem p03631 (python)

Fixed submission:
a = input()
a.split()

if(a[0] == a[2]):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
a=input().split()
if(a[0]==a[2]):
 print("Yes")
else:
 print("No")

Buggy submission (verdict: Runtime Error):
a=input().split
if(a[0]==a[2]):
 print("Yes")
else:
 print("No")
Problem p03426 (python)

Fixed submission:
H, W, D = list(map(int, input().split()))

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

xx = [0 for i in range(90002)]
yy = [0 for i in range(90002)]
for y in range(H):
    for x in range(W):
        xx[Amap[y][x]] = x
        yy[Amap[y][x]] = y
Q = int(input())

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

# magic point calculation
mp = [0 for i in range(90002)]

for i in range(D+1, 90002):
    mp[i] = mp[i-D] + abs(xx[i] -xx[i-D]) + abs(yy[i] - yy[i-D])

for i in coord:
    print(mp[i[1]] - mp[i[0]])

Buggy submission (verdict: Runtime Error):

H, W, D = map(int, input().split())

coord_dict_x = [0 for i in range(90001)]
coord_dict_y = [0 for i in range(90001)]

for i in range(H):
    gyo = [int(i) for i in input().split()]
    for j in range(W):
        coord_dict_x[gyo[j]] = i
        coord_dict_y[gyo[j]] = j

Q = int(input())
exam = [[int(i) for i in input().split()] for i in range(Q)]

for i in range(Q):
    reduce_MP = 0
    num = exam[i][0]
    coord1_x = coord_dict_x[num]
    coord1_y = coord_dict_y[num]
    while num < exam[i][1]:
        num += D
        coord2_x = coord_dict_x[num]
        coord2_y = coord_dict_y[num]
        reduce_MP += abs(coord1_x - coord2_x) + abs(coord1_y - coord2_y)
        coord1 = coord2
    print(reduce_MP)
Problem p03803 (python)

Fixed submission:
A , B = [int(i) for i in input().split()]

if A == B:
    print('Draw')
elif A == 1 or B == 1:
    if B != 1:
        print('Alice')
    else:
        print('Bob')
else:
    if A > B:
        print('Alice')
    else:
        print('Bob')

Buggy submission (verdict: Runtime Error):
import sys
N, M = [int(i) for i in input().split()]

A = [[i for i in input()] for j in range(N)]
B = [[i for i in input()] for k in range(M)]

for i in range(N-M):
        for j in range(N-M):
            diff = 0

            for k in range(M):
                for l in range(M):
                    if A[i+k][j+l] != B[k][l]:
                        diff = 1
                        break

                if diff == 1:
                    break

            if diff == 0:
                print('Yes')
                sys.exit()


print('No')
Problem p03803 (python)

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

a = n[0]
b = n[1]

if a == b:
    print("Draw")
elif a == 1:
    print("Alice")
elif b == 1:
    print("Bob")
elif a > b:
    print("Alice")
elif b > a:
    print("Bob")

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

a = n[0]
b = n[1]

if a == b:
    print("Draw")
elif a == 1:
    print("Alice")
elif b == 1:
    print("Bob")
elif a > b:
    print("Alice")
elif b > a:
    print("Bob")
Problem p03705 (python)

Fixed submission:

import itertools
import numpy as np

def calc(n, a, b):
    if a > b:
        return 0
    elif a == b:
        return 1
    elif n == 1:
        return 0

    return (b - a) * (n - 2) + 1

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


print(calc(N, A, B))

Buggy submission (verdict: Runtime Error):

import itertools
import numpy as np

def calc(n, a, b):
    if a > b:
        return 0
    elif a == b:
        return 1
    elif n == 1:
        return 0

    s = set()
    ary = np.arange(a, b+1)
    it = itertools.combinations_with_replacement(ary, n-2)
    for x in it:
        s.add(sum(x))

    return len(s)

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


print(calc(N, A, B))
Problem p03652 (python)

Fixed submission:
N, M = map(int, raw_input().split(' '))
A = [map(int, raw_input().split(' ')) for _ in xrange(N)]

answer = N
for _ in xrange(M):
    participants = [0] * M
    for n in xrange(N):
        participants[A[n][0]-1] += 1
    sport_with_max_participants = max(xrange(M), key=lambda x: participants[x])
    answer = min(answer, participants[sport_with_max_participants])
    for n in xrange(N):
        A[n].remove(sport_with_max_participants+1)

print answer

Buggy submission (verdict: Runtime Error):
N, M = map(int, raw_input().split(' '))
A = [map(int, raw_input().split(' ')) for _ in xrange(N)]

answer = N
for m in xrange(M-1):
    participants = [0] * (M + 1)
    for n in xrange(N):
        participants[A[n][0]] += 1
    sport_with_max_participants = max(xrange(M), key=lambda x: participants[x])
    answer = min(answer, participants[sport_with_max_participants])
    for n in xrange(N):
        A[n].remove(sport_with_max_participants)

print answer
Problem p03805 (python)

Fixed submission:
import sys
import itertools
import math
input = sys.stdin.readline
#sys.setrecursionlimit(1e9)
N,M = map(int,input().split())

ab = [list(map(int,input().split())) for _ in range(M)]

graph=[[0]*8 for _ in range(8)]
def dfs(v,visited):
    if sum(visited) == N:
        return 1
    ret =0
    for i in range(N):
        if graph[v][i] == 1 and visited[i] == 0:
            visited[i]=1
            ret += dfs(i,visited)
            visited[i]=0
    return ret
def main():
    """code here"""

    for i in range(M):
        a=ab[i][0]
        b=ab[i][1]
        graph[a-1][b-1]=1
        graph[b-1][a-1]=1

    visited=[0]*N
    visited[0]=1
    print(dfs(0,visited))
    
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
import itertools
import math
input = sys.stdin.readline
#sys.setrecursionlimit(1e9)
N,M = map(int,input().split())

ab = [list(map(int,input().split())) for _ in range(M)]

graph=[[0]*8 for _ in range(8)]
def dfs(v,visited):
    if sum(visited) == N:
        return 1
    ret =0
    for i in range(N):
        if graph[v][i] == 1 and visited[i] == 0:
            visited[i]=1
            ret += dfs(i,visited)
            visited[i]=0
    return ret
def main():
    """code here"""

    for i in range(N):
        a=ab[i][0]
        b=ab[i][1]
        graph[a-1][b-1]=1
        graph[b-1][a-1]=1

    visited=[0]*N
    visited[0]=1
    print(dfs(0,visited))




    
    
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
import itertools
import math
input = sys.stdin.readline
#sys.setrecursionlimit(1e9)
N,M = map(int,input().split())

ab = [list(map(int,input().split())) for _ in range(M)]

graph=[[0]*N for _ in range(N)]
def dfs(v,visited):
    if sum(visited) == N:
        return 1
    ret =0
    for i in range(N):
        if graph[v][i] == 1 and visited[i] == 0:
            visited[i]=1
            ret += dfs(i,visited)
            visited[i]=0
    return ret
def main():
    """code here"""

    for i in range(N):
        a=ab[i][0]
        b=ab[i][1]
        graph[a-1][b-1]=1
        graph[b-1][a-1]=1

    visited=[0]*N
    visited[0]=1
    print(dfs(0,visited))




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

Fixed submission:
# -*- coding: utf-8 -*-
# 文字列の入力
s = raw_input()
dst = s.replace(',', ' ')
# 出力
print(dst)

Buggy submission (verdict: Runtime Error):
# 文字列の入力
s = raw_input()
dst = s.replace(',', ' ')
# 出力
print(dst)

Buggy submission (verdict: Runtime Error):
# 文字列の入力
s = raw_input()
dst = s.replace(',', ' ')
# 出力
print(dst)