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

Fixed submission:

from fractions import gcd


n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
x = a[0]
for i in range(1, len(a)):
    x = (x * a[i]) // gcd(x, a[i])
gcd=x
res = 0
for i in a:
    res += gcd//i
    #res%=mod
print(res%mod)

Buggy submission (verdict: Runtime Error):

from fractions import gcd


n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
x = a[0]
for i in range(1, len(a)):
    x = (x * a[i]) // gcd(x, a[i])
x
res = 0
for i in range(n):
    res += gcd//a[i]
    res%=mod
print(res)
Problem p02881 (python)

Fixed submission:
a=int(input())
 
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        res=[]
        if n % i == 0:
            res.append(i)
            if i != n // i:
                res.append(n//i)
        if res!=[]:
            divisors.append(res)
    return divisors
 
res=make_divisors(a)
my_min=0
for i in range(len(res)):
    if i==0:
        if len(res[i])==2:
            my_min=res[i][0]+res[i][1]
        else:
            my_min=(res[i][0]*2)
    else:
        if len(res[i])==2:
            my_min=min(my_min,res[i][0]+res[i][1])
        else:
            my_min=min(my_min,res[i][0]*2)
 
print(my_min-2)

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

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        res=[]
        if n % i == 0:
            res.append(i)
            if i != n // i:
                res.append(n//i)
        if res!=[]:
            divisors.append(res)
    return divisors

res=make_divisors(a)
my_min=0
for i in range(len(res)):
    if i==0:
        if len(res[i])==2:
            my_min=res[i][0]+res[i][1]
        else:
            my_min=(res[i]*2)
    else:
        if len(res[i])==2:
            my_min=min(my_min,res[i][0]+res[i][1])
        else:
            my_min=min(my_min,res[i]*2)

print(my_min-2)
Problem p02891 (python)

Fixed submission:
s=input()
k=int(input())
if len(set(list(s)))==1:
    print((len(s)*k)//2)
    exit()
t=[1]
for i in range(1,len(s)):
  if s[i-1]==s[i]:
      t[-1]+=1
  else:
      t.append(1)
a=0
for i in t:
    a+=(i//2)*k
if s[0]==s[-1]:
  if t[0]%2==t[-1]%2==1:
      a+=k-1
print(a)

Buggy submission (verdict: Runtime Error):
s=input()
n=int(input())
my_bool=True
cnt=0
for i in range(1,len(s)):
    if my_bool:
        if s[i-1]==s[i]:
            cnt+=1
            my_bool=False
    else:
        my_bool=True
        continue
if my_bool:
    if not s[-1]==s[-2] and s[0]==s[-1]:
        cnt+=1
print(cnt*n)
Problem p02933 (python)

Fixed submission:
a=int(input())
s=input()
if a<3200:
  print("red")
else:
  print(s)

Buggy submission (verdict: Runtime Error):
a=int(inout())
if a>=3200:
  print("red")
else:
  print(input())
Problem p03017 (python)

Fixed submission:
n,a,b,c,d=map(int,input().split())
res=list(input())
if c<d:
    for i in range(a,d+1):
        if res[i-1]=="#" and res[i]=="#":
            print("No")
            exit()
    print("Yes")
    exit()

for i in range(b,d+1):
    if i==1:
        continue
    if res[i-2]=="." and res[i-1]=="." and res[i]==".":
        print("Yes")
        exit()
    if res[i-1]=="#" and res[i]=="#":
        print("No")
        exit()
        
print("No")
exit()

Buggy submission (verdict: Runtime Error):
n,a,b,c,d=map(int,input().split())
res=list(input())
if c<d:
    for i in range(1,n):
        if res[i-1]=="#" and res[i]=="#":
            print("No")
            exit()
    print("Yes")
    exit()

print(res[n+6])

# for i in range(b,d+1):
#     if i==1:
#         continue
#     if res[i-2]=="." and res[i-1]=="." and res[i]==".":
#         print("Yes")
#         exit()
#     if res[i-1]=="#" and res[i]=="#":
#         print("No")
#         exit()
        
# print("No")
# exit()

Buggy submission (verdict: Runtime Error):
n,a,b,c,d=map(int,input().split())
res=list(input())
if c<d:
    for i in range(1,n):
        if res[i-1]=="#" and res[i]=="#":
            print("No")
            exit()
    print("Yes")
    exit()

for i in range(b,d+1):
    if i==1:
        continue
    if res[i-2]=="." and res[i-1]=="." and res[i]==".":
        print("Yes")
        exit()
    if res[i-1]=="#" and res[i]=="#":
        print("No")
        exit()
        
if res[i-1]=="." and res[i]=="." and res[i+1]==".":
    print("Yes")
    exit()
print("No")
exit()

Buggy submission (verdict: Runtime Error):
n,a,b,c,d=map(int,input().split())
res=list(input())
if c<d:
    for i in range(1,n):
        if res[i-1]=="#" and res[i]=="#":
            print("No")
            exit()
    print("Yes")
    exit()

for i in range(b,d+1):
    if i<=n-4:
        continue
    if res[i+2]=="." and res[i+1]=="." and res[i]==".":
        print("Yes")
        exit()
print("No")
exit()
Problem p03208 (python)

Fixed submission:
import sys
input=sys.stdin.readline
n,k=map(int,input().split())
a=[int(input()) for i in range(n)]
a.sort()
res=float("INF")
for i in range(0,n-k+1):
    b=a[i+k-1]-a[i]
    if res>b:
        res=b
print(res)

Buggy submission (verdict: Runtime Error):
import sys
input=sys.stdin.readline
n,k=map(int,input().split())
a=[int(input()) for i in range(n)]
a.sort()
res=float("INF")
for i in range(0,n-k+1):
    b=a[i+2]-a[i]
    if res>b:
        res=b
print(res)
Problem p02711 (python)

Fixed submission:
N = input()
for i in range(3):
  if int(N[i]) == 7:
    print('Yes')
    exit()
print('No')

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
A = [[],[],[]]
ans = 0
for i in range(N):
    if S[i] == 'R':
        A[0].append(i)
    elif S[i] == 'G':
        A[1].append(i)
    else:
        A[2].append(i)

for i in A[0]:
    for j in A[1]:
        for k in A[2]:
            if  (i < j and j < k) or (k < j and j < i):
                if abs(i-j) != abs(j-k):
                    ans += 1
            elif (i < k and k < j) or (j < k and k < i):
                if abs(i-k) != abs(k-j):
                    ans += 1
            elif (j < i and i < k) or (k < i and i < j):
                if abs(j-i) != abs(k-i):
                    ans += 1

print(ans)
Problem p02879 (python)

Fixed submission:
A,B = map(int,input().split())
if A<=9 and B<=9:
  print(A*B)
else:
  print(-1)

Buggy submission (verdict: Runtime Error):
N = int(input())
for i in range(9):
  for j in range(9):
    if (i+1)*(j+1)==N:
      print("yes")
      exit()
print("No")
Problem p03017 (python)

Fixed submission:
N,A,B,C,D = map(int, raw_input().split())
S = raw_input()
i = 1
flagskip = 0
flagskip2 = 0
flagerror = 0
flags = 0
flagstop = 0
flagstop2 = 0
for c in S:
	if(flagstop2 == 1):
		if(c =='#'):
			flagstop += 1
		flagstop2 = 0
	if(i <= A):
		i += 1
		continue
	elif(i == B or (i == D and D < C)):
		if(flags == 1):
			flagstop += 1
		else:
			flagstop2 = 1
	if(c == '#'):
		if(flags == 1):
			flagerror = 1
			break
		flags = 1
		flagskip2 = 0
	else:
		if(flagskip2 == 1):
			flagskip = 1
		elif(flags == 0 and flagskip == 0 and i > B-1 and i < D+1):
			flagskip2 = 1
		flags = 0
	if(i == max(C,D)):
		break
	i += 1
if(flagstop == 2 and flagskip == 0):
	flagerror = 1
if(flagerror == 0):
	print("Yes")
else:
	print("No")

Buggy submission (verdict: Runtime Error):
N,A,B,C,D = map(int, raw_input().split())
S = raw_input()
i = 1
flagskip = 0
flagskip2 = 0
flagerror = 0
flags = 0
flagstop = 0
flagstop2 = 0
for c in S:
	if(flagstop2 == 1):
		if(c =='#'):
			flagstop += 1
		flagstop2 = 0
	if(i <= A):
		i += 1
		continue
	elif(i == B or (i == D and D < C)):
		if(flags == 1):
			flagstop += 1
		else:
			flagstop2 = 1
	if(c == '#'):
		if(flags == 1):
			flagerror = 1
			break
		flags = 1
		flagskip2 = 0
	else:
		if(flagskip2 == 1):
			flagskip = 1
		elif(flags == 0 and flagskip == 0 and i > B-1 and i < D+1):
			flagskip2 = 1
		flags = 0
	if(i = max(C,D)):
		break
	i += 1
if(flagstop == 2 and flagskip == 0):
	flagerror = 1
if(flagerror == 0):
	print("Yes")
else:
	print("No")
Problem p03055 (python)

Fixed submission:
from collections import deque
def dia(i):
	lst = [-1]*N
	lst[i] = 0
	q = deque([i])
	while q:
		c = q.popleft()
		l = lst[c]
		for i in A[c]:
			if lst[i] != -1:
				continue
			else:
				lst[i] = l+1
				q.append(i)
	return lst.index(max(lst))
def dia2(i):
	lst = [-1]*N
	lst[i] = 0
	q = deque([i])
	while q:
		c = q.popleft()
		l = lst[c]
		for i in A[c]:
			if lst[i] != -1:
				continue
			else:
				lst[i] = l+1
				q.append(i)
	return max(lst)+1
N = input()
A = [[] for i in range(N)]
for i in range(N-1):
	a2,b2 = map(int, raw_input().split())
	A[a2-1].append(b2-1)
	A[b2-1].append(a2-1)
if((dia2(dia(0))) % 3 == 2):
	print("Second")
else:
	print("First")

Buggy submission (verdict: Runtime Error):
def dia(Node,i,j):
	lst = []
	Node.remove(i)
	if(len(Node) == 0):
		lst.append(1)
	else:
		for n in Node:
			t = dia(A[n],j,n)
			lst.append(t+1)
	return max(lst)
		
N = input()
A = [[] for i in range(N)]
for i in range(N-1):
	a2,b2 = map(int, raw_input().split())
	A[a2-1].append(b2-1)
	A[b2-1].append(a2-1)
lst = []
for n in A[0]:
	lst.append(dia(A[n],0,n))
m1 = max(lst)
lst.remove(m1)
if(len(lst) == 0):
	m2 = 1
else:
	m2 = max(lst)+1
if((m1 + m2) % 3 == 2):
	print("Second")
else:
	print("First")

Buggy submission (verdict: Runtime Error):
def dia(Node):
	lst = []
	if(len(Node) == 0):
		lst.append(1)
	else:
		for n in Node:
			t = dia(d[n])
			lst.append(t+1)
	return max(lst)
		
N = input()
A = []
for i in range(N-1):
	a2,b2 = map(int, raw_input().split())
	if(a2 > b2):
		a2,b2 = b2,a2
	k = [a2,b2]
	A.append(k)
root = A[0][0]
rootd = [A[0][1]]
d = {A[0][0]:[A[0][1]],A[0][1]:[]}
A.pop(0)
for a2 in A:
	if(a2[0] in d):
		t = d[a2[0]]
		n = a2[1]
	elif(a2[1] in d):
		t = d[a2[1]]
		n = a2[0]
	else:
		A.append(a2)
		continue
	t.append(n)
	d[n] = []
lst = []
for n in d[root]:
	lst.append(dia(d[n]))
m1 = max(lst)
lst.remove(m1)
if(len(lst) == 0):
	m2 = 1
else:
	m2 = max(lst)+1
if((m1 + m2) % 3 == 2):
	print("Second")
else:
	print("First")

Buggy submission (verdict: Runtime Error):
def dia(Node):
	lst = []
	if(len(Node) == 0):
		lst.append(1)
	else:
		for n in Node:
			t = dia(d[n])
			lst.append(t+1)
	return max(lst)
		
N = input()
A = []
for i in range(N-1):
	a2,b2 = map(int, raw_input().split())
	if(a2 > b2):
		a2,b2 = b2,a2
	k = [a2,b2]
	A.append(k)
root = A[0][0]
rootd = [A[0][1]]
d = {A[0][0]:[A[0][1]],A[0][1]:[]}
for i in range(1,N-1):
	if(A[i][0] in d):
		t = d[A[i][0]]
		n = A[i][1]
	elif(A[i][1] in d):
		t = d[A[i][1]]
		n = A[i][0]
	t.append(n)
	d[n] = []
lst = []
for n in d[root]:
	lst.append(dia(d[n]))
m1 = max(lst)
lst.remove(m1)
if(len(lst) == 0):
	m2 = 1
else:
	m2 = max(lst)+1
if((m1 + m2) % 3 == 2):
	print("Second")
else:
	print("First")
Problem p02699 (python)

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

a=int(a)
b=int(b)
if a>b:
	print('safe')
else:
	print('unsafe')

Buggy submission (verdict: Runtime Error):
a , b , c , d = input().split()

a=int(a)
b=int(b)
c=int(c)
d=int(d)

while True:
  c -= b
  if c <= 0:
    print('Yes')
    break
  a -= d
  if a <= 0:
    print('No')
    break
Problem p03307 (python)

Fixed submission:
n = int(input())
if n&1:
    print(2*n)
else:
    print(n)

Buggy submission (verdict: Runtime Error):
n = int(input())
if n&1:
    print(2*n)
else
    print(n)
Problem p02831 (python)

Fixed submission:

# Beginners Contest (C)

import sys

# 約数に分解
def calc_divisor(n):
	div_dic = {}
	if n == 1: return div_dic
	k = 2
	while True:
		# 約数の場合
		if n%k == 0:
			if k not in div_dic: div_dic[k] = 0
			div_dic[k] += 1
			n = n//k
			if n == 1: break
		else:
			k += 1
	return div_dic

# 入力取得
a,b = [int(e) for e in input().split(" ")]

# 約数に分解
div_dic_a = calc_divisor(a)
div_dic_b = calc_divisor(b)

# 約数の和集合を計算
div_ls = list(div_dic_a) + list(div_dic_b)
div_ls = list({k: 1 for k in div_ls})
div_dic = {k:(div_dic_a[k]
	if div_dic_a.get(k,0) > div_dic_b.get(k,0)
	else div_dic_b[k]) for k in div_ls}
# print(div_dic)

# 最小公倍数を計算
ans = 1
for k in div_dic:
	ans *= k ** div_dic[k]

print(ans)

Buggy submission (verdict: Runtime Error):

# Beginners Contest (C)

import sys
sys.setrecursionlimit(10**6)

# 約数に分解
def calc_divisor(n, div_dic = None):
	if n == 1: return div_dic
	# 初回呼び出し時の初期化
	if div_dic is None: div_dic = {}
	for i in range(n):
		# 1を除く
		if (i+1) == 1: continue
		# 約数の場合
		if n%(i+1) == 0:
			if (i+1) not in div_dic: div_dic[i+1] = 0
			div_dic[i+1] += 1
			return calc_divisor(n//(i+1), div_dic)

# 入力取得
a,b = [int(e) for e in input().split(" ")]

# 約数に分解
div_dic_a = calc_divisor(a)
div_dic_b = calc_divisor(b)

# 約数の和集合を計算
div_ls = list(div_dic_a) + list(div_dic_b)
div_ls = list({k: 1 for k in div_ls})
div_dic = {k:div_dic_a[k] if div_dic_a.get(k,0) > div_dic_b.get(k,0) else div_dic_b[k] for k in div_ls}
# print(div_dic)

# 最小公約数を計算
ans = 1
for k in div_dic:
	ans *= k ** div_dic[k]

print(ans)

Buggy submission (verdict: Runtime Error):

# Beginners Contest (C)

import sys

# 約数に分解
def calc_divisor(n, div_dic = None):
	if n == 1: return div_dic
	# 初回呼び出し時の初期化
	if div_dic is None: div_dic = {}
	for i in range(n):
		# 1を除く
		if (i+1) == 1: continue
		# 約数の場合
		if n%(i+1) == 0:
			if (i+1) not in div_dic: div_dic[i+1] = 0
			div_dic[i+1] += 1
			return calc_divisor(n//(i+1), div_dic)

# 入力取得
a,b = [int(e) for e in input().split(" ")]

# 約数に分解
div_dic_a = calc_divisor(a)
div_dic_b = calc_divisor(b)

# 約数の和集合を計算
div_ls = list(div_dic_a) + list(div_dic_b)
div_ls = list({k: 1 for k in div_ls})
div_dic = {k:div_dic_a[k] if div_dic_a.get(k,0) > div_dic_b.get(k,0) else div_dic_b[k] for k in div_ls}
# print(div_dic)

# 最小公約数を計算
ans = 1
for k in div_dic:
	ans *= k ** div_dic[k]

print(ans)
Problem p02754 (python)

Fixed submission:
# coding: utf-8
N, A, B = map(int, input().split())
# print("N:", N, "A:", A, "B:", B) 
if A == 0:
    print(0)
elif B == 0 or N <= A:
    print(N)
else:
    num = int(N / (A + B)) * A + min(A, N % (A + B))
    print(num)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
import numpy as np
N, A, B = map(int, input().split())
# print("N:", N, "A:", A, "B:", B)
if A == 0:
    print(0)
elif B == 0:
    print(N)
elif N <= A:
    print(N)
elif N <= A + B:
    print(A)
else:
    lst = np.array([1 for i in range(A)])
    # print(lst)
    lst2 = np.array([0 for i in range(B)])
    # print(lst2)
    lst3 = np.append(lst, lst2)
    # print(lst3)
    while lst3.size <= N:
        lst3 = np.append(lst3, lst3)
    lst3 = lst3[:N]
    print(np.count_nonzero(lst3 == 1))

Buggy submission (verdict: Runtime Error):
# coding: utf-8
import numpy as np
N, A, B = map(int, input().split())
print("N:", N, "A:", A, "B:", B)
if A == 0:
    print(0)
elif B == 0:
    print(N)
elif N <= A:
    print(N)
elif N <= A + B:
    print(A)
else:
    lst = np.array([1 for i in range(A)])
    # print(lst)
    lst2 = np.array([0 for i in range(B)])
    # print(lst2)
    lst3 = np.append(lst, lst2)
    # print(lst3)
    while lst3.size < N:
        lst3 = np.append(lst3, lst3)
    lst3 = lst3[:N]
    print(np.count_nonzero(lst3 == 1))
Problem p02916 (python)

Fixed submission:
n = input()
 
a = list( map( int, input().split()))
b = list( map( int, input().split()))
c = list( map( int, input().split()))
 
satisfaction = 0
for i in range( len( a )):
  a_i = a[ i ] - 1
  satisfaction += b[ a_i ]
  if i > 0:
    if a[ i ] == a[ i - 1 ] + 1:
      satisfaction += c[ a_i - 1 ]
print( satisfaction )

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

a = list( map( int, input.split()))
b = list( map( int, input.split()))
c = list( map( int, input.split()))

satisfaction = 0
for i in a:
  satisfaction += b[ i ]
  if i > 0:
    if a[ i ] == a[ i - 1 ] + 1:
    satisfaction += c[ i ]
print( satisfaction )
Problem p02951 (python)

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

print( max( 0, c - ( a - b )))

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

print( max( 0, c - ( a - b ) )
Problem p02990 (python)

Fixed submission:
N, K = map( int, input().split() )
MOD = 10 ** 9 + 7
 
def Combi( n, r ):
  n1 = 1
  n2 = 1
  for i in range( 1, r + 1 ):
    n1 = n1 * i % MOD
    n2 = n2 * ( n - i + 1 ) % MOD
  return ( n2 * pow( n1, MOD - 2, MOD ) ) % MOD
 
for i in range( 1, K + 1 ):
  if N - K + 1 >= i:
    print( ( Combi( N - K + 1, i ) * Combi( K - 1, i - 1 ) ) % MOD )
  else:
    print( 0 )

Buggy submission (verdict: Runtime Error):
N, K = map( int, input().split() )
MOD = 10 ** 9 + 7
 
def Combi( n, r ):
  n1 = 1
  n2 = 1
  for i in range( 1, min( n - k, k ) + 1 ):
    n1 = n1 * i % MOD
    n2 = n2 * ( n - i + 1 ) % MOD
  return ( n2 * pow( n1, MOD - 2, MOD ) ) % MOD
 
for i in range( 1, K + 1 ):
  if K - N + 1 >= i:
    print( ( Combi( N - K + 1, i ) * Combi( K - 1, i - 1 ) ) % MOD )
  else:
    print( 0 )
Problem p03127 (python)

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

res = a[0]

while True:
    base = res
    total = 0
    for i in a:
        if  i % base > 0:
            res = min( res, i % base)
        total +=  i % base
    if total == 0:
        break

print(base)

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

import math
from functools import reduce

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

print( gcd_list(  a ) )

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

n = int( input() )
a = sorted( list( map( int, input().split())))

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

print( gcd_list(  a ) )
Problem p02699 (python)

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

    if a <= b:
        print("unsafe")
    else:
        print("safe")


compare()

Buggy submission (verdict: Runtime Error):
n=input()
length=len(n)
rs=0
for i in range(1,length-2):
    num=0
    start=0
    end=length-i
    gap=length-end
    for j in range(i):
        num=int(n[start+j:end+1+j])
        if num%2019==0:
            rs+=1
print(rs)
Problem p02757 (python)

Fixed submission:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N,P = inpl()
S = list(map(int,list(input())))

if 10%P==0:
    ans= 0
    for i,s in enumerate(S):
        if s%P == 0:
            ans += i+1
    print(ans)
else:
    tmpl = [s*pow(10,N-1-i,P)%P for i,s in enumerate(S)]
    xx = [tmpl[0]]
    for t in tmpl[1:]:
        xx.append((xx[-1]+t)%P)

    yy = [S[0]%P]
    for s in S[1:]:
        yy.append((yy[-1]*10+s)%P)

    nums = [0]*P
    nums[0] += 1
    ans = 0
    for i,y in enumerate(yy):
        tmp = y*pow(10,N-1-i,P)%P
        ans += nums[tmp]
        nums[xx[i]] += 1
    print(ans)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N,P = inpl()
S = list(map(int,list(input())))

assert 10%P != 0


tmpl = [s*pow(10,N-1-i,P)%P for i,s in enumerate(S)]
xx = [tmpl[0]]
for t in tmpl[1:]:
    xx.append((xx[-1]+t)%P)

yy = [S[0]%P]
for s in S[1:]:
    yy.append((yy[-1]*10+s)%P)

nums = [0]*P
nums[0] += 1
ans = 0
for i,y in enumerate(yy):
    tmp = y*pow(10,N-1-i,P)%P
    ans += nums[tmp]
    nums[xx[i]] += 1


print(ans)
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):
a,b,c = map(int(input().split()))
if a+b+c >= 22:
  print("bust")
else:
  print("win")
Problem p02884 (python)

Fixed submission:

from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N,M = inpl()

if M == N-1: # 一本道
    for _ in range(M):
        s,t = inpl()
    print(M)
else:
    lines = defaultdict(set)
    LL = [0]*N
    for _ in range(M):
        s,t = inpl()
        s -= 1; t -= 1
        lines[s].add(t)
        LL[s] += 1

    def dfs(s):
        global MEMO
        if MEMO[s] != -1:
            return MEMO[s]
        else:
            tmp = 0
            for t in lines[s]:
                if MEMO[t] != -1:
                    tmp += MEMO[t] + 1
                else:
                    tmp += dfs(t) + 1
            MEMO[s] = tmp / LL[s]
            return MEMO[s]

    MEMO = [-1]*N
    MEMO[-1] = 0
    dfs(0)
    koho = [-1]*N
    for s in range(N):
        x = -1
        for t in lines[s]:
            if x < MEMO[t]:
                x = MEMO[t]
                koho[s] = t

    ans = 10**10
    for s in range(N-1):
        t = koho[s]
        if LL[s] == 1 or t == -1:
            continue
        MEMO = [-1]*N
        MEMO[-1] = 0
        lines[s].remove(t)
        LL[s] -= 1
        ans = min(ans,dfs(0))
        lines[s].add(t)
        LL[s] += 1
    print(ans)

Buggy submission (verdict: Runtime Error):

from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N,M = inpl()

if M == N-1: # 一本道
    for _ in range(M):
        s,t = inpl()
    print(M)
else:
    lines = defaultdict(set)
    LL = [0]*N
    for _ in range(M):
        s,t = inpl()
        s -= 1; t -= 1
        lines[s].add(t)
        LL[s] += 1

    def dfs(s):
        global MEMO
        if MEMO[s] != -1:
            return MEMO[s]
        else:
            tmp = 0
            for t in lines[s]:
                if MEMO[t] != -1:
                    tmp += MEMO[t] + 1
                else:
                    tmp += dfs(t) + 1

            MEMO[s] = tmp / LL[s]
            return MEMO[s]

    MEMO = [-1]*N
    MEMO[-1] = 0
    dfs(0)
    koho = [-1]*N
    for s in range(N):
        x = -1
        for t in lines[s]:
            if x < MEMO[t]:
                x = MEMO[t]
                koho[s] = t

    ans = 10**10
    for s in range(N-1):
        t = koho[s]
        if LL[s] == 1:
            continue
        MEMO = [-1]*N
        MEMO[-1] = 0
        lines[s].remove(t)
        LL[s] -= 1
        ans = min(ans,dfs(0))
        lines[s].add(t)
        LL[s] += 1
    print(ans)