Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [0]
for i in range(n):
    a.append(int(input()))


btn2 = a.index(2)
cnt = 1
idx = 1
for i in range(n+1):
    if a[idx] == btn2:
        cnt += 1
        print(cnt)
        break

    else:
        idx = a[idx]
        cnt += 1
else:
    print(-1)

Fixed submission:
n = int(input())
a = [0]
for i in range(n):
    a.append(int(input()))

cnt = 1
idx = 1
for i in range(n):
    if a[idx] == 2:
        print(cnt)
        break

    else:
        idx = a[idx]
        cnt += 1
else:
    print(-1)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [0]
for i in range(n):
    a.append(int(input()))


btn2 = a.index(2)
cnt = 1
idx = 1
for i in range(n):
    if a[idx] == btn2:
        if cnt != 1:
            cnt += 1
        print(cnt)
        break
    else:
        idx = a[idx]
        cnt += 1
else:
    print(-1)

Fixed submission:
n = int(input())
a = [0]
for i in range(n):
    a.append(int(input()))

cnt = 1
idx = 1
for i in range(n):
    if a[idx] == 2:
        print(cnt)
        break

    else:
        idx = a[idx]
        cnt += 1
else:
    print(-1)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [0]
for i in range(n):
    a.append(int(input()))


btn2 = a.index(2)
cnt = 1
idx = 1
for i in range(n):
    if a[idx] == btn2:
        cnt += 1
        print(cnt)
        break
    else:
        idx = a[idx]
        cnt += 1
else:
    print(-1)

Fixed submission:
n = int(input())
a = [0]
for i in range(n):
    a.append(int(input()))

cnt = 1
idx = 1
for i in range(n):
    if a[idx] == 2:
        print(cnt)
        break

    else:
        idx = a[idx]
        cnt += 1
else:
    print(-1)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [0]
for i in range(1, n + 1):
    a.append(int(input()))


btn2 = a.index(2)
cnt = 1
idx = 1
for i in range(1, n + 1):
    if a[idx] == btn2:
        cnt += 1
        print(cnt)
        break
    else:
        idx = a[idx]
        cnt += 1
else:
    print(-1)

Fixed submission:
n = int(input())
a = [0]
for i in range(n):
    a.append(int(input()))

cnt = 1
idx = 1
for i in range(n):
    if a[idx] == 2:
        print(cnt)
        break

    else:
        idx = a[idx]
        cnt += 1
else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
def factorial(x):
    if x == 0:
        return 1
    return x * factorial(x - 1)

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

dif = abs(n - m)
if dif >= 2:
    ans = 0
elif dif == 1:
    ans = factorial(n) * factorial(m) % (10**9 + 7)
else:
    ans = factorial(n) * factorial(m) * 2 % (10**9 + 7)

print(ans)

Fixed submission:
"""
def factorial(x):
    if x == 0:
        return 1
    return x * fact(x - 1)
"""
from math import *
n, m = map(int, input().split())

dif = abs(n - m)
if dif >= 2:
    ans = 0
elif dif == 1:
    ans = factorial(n) * factorial(m) % (10**9 + 7)
else:
    ans = factorial(n) * factorial(m) * 2 % (10**9 + 7)

print(ans)

Buggy python submission (verdict: Runtime Error):
def fact(x):
    if x == 0:
        return 1
    return x * fact(x - 1)

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

dif = abs(n - m)
if dif >= 2:
    ans = 0
elif dif == 1:
    ans = fact(n) * fact(m) % (10**9 + 7)
else:
    ans = fact(n) * fact(m) * 2 % (10**9 + 7)

print(ans)

Fixed submission:
"""
def factorial(x):
    if x == 0:
        return 1
    return x * fact(x - 1)
"""
from math import *
n, m = map(int, input().split())

dif = abs(n - m)
if dif >= 2:
    ans = 0
elif dif == 1:
    ans = factorial(n) * factorial(m) % (10**9 + 7)
else:
    ans = factorial(n) * factorial(m) * 2 % (10**9 + 7)

print(ans)
Buggy python submission (verdict: Runtime Error):
a,b,c = input().split()
print(upper(a[0])+upper(b[0])+upper(c[0]))

Fixed submission:
a,b,c = input().split()
print(a[0].upper()+b[0].upper()+c[0].upper())
Buggy python submission (verdict: Runtime Error):
a, b = int(input())
if a == 1:
    a = 14
elif b == 1:
    b = 14

if a > b:
    print("Alice")
elif a < b:
    print("Bob")
else:
    print("Draw")

Fixed submission:
a, b = map(int, input().split())
if a == 1:
    a = 14
if b == 1:
    b = 14

if a > b:
    print("Alice")
elif a < b:
    print("Bob")
else:
    print("Draw")
Buggy python submission (verdict: Runtime Error):
n = int(raw_input())

occ = {}
for i in map(int, raw_input().split()):
    if not i in occ:
        occ[i] = 0

    occ[i] += 1

found = 0
rect = 1

for i in sorted(occ, reverse=True):
    if occ[i] >= 4 and found < 1:
        found += 2
        rect *= i*i
    elif occ[i] => 2:
        found += 1
        rect *= i

    if found == 2:
        print rect
        break
    
if found < 2:
    print 0
        
    


Fixed submission:
n = int(raw_input())

occ = {}
for i in map(int, raw_input().split()):
    if not i in occ:
        occ[i] = 0

    occ[i] += 1

found = 0
rect = 1

for i in sorted(occ, reverse=True):
    if occ[i] >= 4 and found < 1:
        found += 2
        rect *= i*i
    elif occ[i] >= 2:
        found += 1
        rect *= i

    if found == 2:
        print rect
        break
    
if found < 2:
    print 0

Buggy python submission (verdict: Runtime Error):
n = int(raw_input())

occ = {}
for i in map(int, raw_input().split()):
    if not i in occ:
        occ[i] = 0

    occ[i] += 1

found = 0
rect = 1

for i in sorted(occ, reverse=True):
    if occ[i] >= 4:
        found += 2
        rect *= i*i
    elif occ[i] => 2:
        found += 1
        rect *= i

    if found == 2:
        print rect
        break
    
if found < 2:
    print 0
        
    


Fixed submission:
n = int(raw_input())

occ = {}
for i in map(int, raw_input().split()):
    if not i in occ:
        occ[i] = 0

    occ[i] += 1

found = 0
rect = 1

for i in sorted(occ, reverse=True):
    if occ[i] >= 4 and found < 1:
        found += 2
        rect *= i*i
    elif occ[i] >= 2:
        found += 1
        rect *= i

    if found == 2:
        print rect
        break
    
if found < 2:
    print 0
Buggy python submission (verdict: Runtime Error):
import sys
#sys.stdin = open('Transit_Tree_Path.txt', 'r')

def dfs(g, start):
    dist = [-1 for i in xrange(len(g))]
    dist[start] = 0

    q = [start]
    while len(q) > 0:
        u = q.pop()
        for v, l in g[u].iteritems():
            if dist[v] == -1 or dist[u] + l < dist[v]:
                dist[v] = dist[u] + l
                if not v in q:
                    q.append(v)
                    
    return dist

n = int(raw_input())
g = [{} for i in xrange(n+1)]

for i in xrange(n-1):
    u, v, l = map(int, raw_input().split())
    g[u][v] = l
    g[v][u] = l


q, k = map(int, raw_input().split())
dist = dfs(g, k)
for i in xrange(q):
    x, y = map(int, raw_input().split())
    print dist[x] + dist[y]
    
    


Fixed submission:
print "Yes" if (lambda x: x == x[::-1])(raw_input()) else "No"

Buggy python submission (verdict: Runtime Error):
import sys
#sys.stdin = open('Transit_Tree_Path.txt', 'r')

def spfa(g, start):
    dist = [1e15 for i in xrange(len(g))]
    dist[start] = 0

    q = [start]
    while len(q) > 0:
        u = q.pop(0)
        for v, l in g[u].iteritems():
            if dist[u] + l < dist[v]:
                dist[v] = dist[u] + l
                if not v in q:
                    q.append(v)
                    
    return dist

n = int(raw_input())
g = [{} for i in xrange(n+1)]

for i in xrange(n-1):
    u, v, l = map(int, raw_input().split())
    g[u][v] = l
    g[v][u] = l


q, k = map(int, raw_input().split())
dist = spfa(g, k)
for i in xrange(q):
    x, y = map(int, raw_input().split())
    print dist[x] + dist[y]
    
    


Fixed submission:
print "Yes" if (lambda x: x == x[::-1])(raw_input()) else "No"
Buggy python submission (verdict: Runtime Error):
x=int(raw_input())
k=int(raw_input())
R=[int(i) for i in raw_input().split(' ')]
Q=int(raw_input())
RES=[]
for q in range(Q):
    RES.append((int(i) for i in raw_input().split(' ')))
tintervals=[[0,R[0],R[0]]]
if k>1:
    for ts in range(1,len(R)):
        tintervals.append([R[ts-1],R[ts],R[ts]-R[ts-1]])
for t, a in RES:
    for i,r in enumerate(tintervals):
        j=i%2+1
        if t>=r[0]:
            if t<=r[1]:
                a=max(a+((-1)**j)*(t-r[0]),0)
                a=min(a,x)
                print a
                break
            else:
                a=max(a+((-1)**j)*r[2],0)
                a=min(a,x)
    if t > tintervals[-1][1]:
        j=(i+1)%2+1
        a=max(a+((-1)**j)*(t-tintervals[-1][1]),0)
        a=min(a,x)
        print a

Fixed submission:
n=int(raw_input())
a=[int(i) for i in raw_input().split(' ')]
res={}
for i in a:
    for p in (i,i-1,i+1):
            res[p]=res.get(p,0)+1
if len(res)>0:
    print  max(res.values())
Buggy python submission (verdict: Runtime Error):
from math import pi

input1 = list(map(int,input("").split(" ")))
N = int(input(""))
src = {"x":input1[0],"y":input1[1]}
dist = {"x":input1[2],"y":input1[3]}

spring = []
for i in range(N):
	temp = list(map(int,input("").split(" ")))
	if temp[0] in range(min(src['x'],dist['x']),max(src['x'],dist['x'])+1):
		if temp[1] in range(min(src['y'],dist['y']),max(src['y'],dist['y'])+1):
			spring.append({'x':temp[0], 'y':temp[1]})

# print(spring)
path = (abs(src['x']-dist['x']) + abs(src['y']-dist['y'])) * 100
if len(spring) > 0:
	r = 10
	if src['x'] == dist['x'] or src['y'] == dist['y'] :
		#半円
		path += r*pi - 2*r 
	else:
		#1/4円
		if (src['x']-dist['x'])*(src['y']-dist['y']) > 0:
			spring.sort(key=lambda k: k['x'])
		else:
			spring.sort(key=lambda k: k['x'], reverse=True)
		L = [spring[0]['y']]
		length = 1
		for i in range(1,len(spring)):
			if L[length-1] < spring[i]['y']:
				L.append(spring[i]['y'])
				length += 1
			else:
				for j in range(length):
					if spring[i]['y'] <= L[j]:
						L[j] = spring[i]['y']
						break
		path += (r*pi/2 - 2*r) * length

print(path)


Fixed submission:
input1 = input("").split(" ")
Q = int(input1[0])
H = int(input1[1])
S = int(input1[2])
D = int(input1[3])
N = int(input(""))

print((N%2) * min(Q*4,H*2,S) + (N//2) * min(Q*8,H*4,S*2,D))
Buggy python submission (verdict: Time Limit Exceeded):
A = input("")
num = 1
for i in range(len(A)-1):
	num += len(A[i+1:].replace(A[i],''))
print(num)

Fixed submission:
def conbi(n):
	return int(n*(n-1)/2)

A = input("")
num = 1 + conbi(len(A)) #l_C_2
uniq = list(set(A))
for i in uniq:
	num -= conbi(A.count(i))
print(num)
Buggy python submission (verdict: Runtime Error):
#coding:UTF-8
#
#問題：AtCoder Grand Contest019 #A Ice Tea Store
#
#手法：入力Nは整数で与えられるので、Nが2以上のときは2リットル当たりの値段が安いドリンクをN/2個買い、
#Nが奇数だったら、残りの1リットルは1リットル当たりの値段が安いドリンク買う
sum=0#合計金額
#入力(0.25リットル,0.5リットル,1リットル,2リットル)
Q,H,S,D=input().split()
Q=int(Q)
H=int(H)
S=int(S)
D=int(D)
#入力チェック
if not(1<=Q<=10**8 and 1<=H<=10**8 and 1<=S<=10**8 and 1<=D<=10**8):
	print("input error1")
#1リットル当たりのQ,Hの値段QQ,HHを求める
QQ=Q*4
HH=H*2
#2リットル当たりのQ,H,Sの値段QQQ,HHH,SSSを求める
QQQ=8*Q
HHH=4*H
SSS=2*S
N=int(input())
#Nの入力チェック]
if not(1<=N<=10**9):
	print("input error2")
#N=1のとき、QQ,HH,Sの最小値がsumになる
if N==1:
	sum=min(QQ,HH,S)
else:#Nが2以上の時
	sum+=(N//2)*min(QQQ,HHH,SSS,D)
	if N%2==1:#Nが奇数のときは、sumにQQ,HH,Sの中の最小値を加える
		sum+=min(QQ,HH,S)
print()	
print(sum)
#print("Q,H,S,D=",Q,H,S,D)


Fixed submission:
sum=0
Q,H,S,D=input().split()
Q=int(Q)
H=int(H)
S=int(S)
D=int(D)

if not(1<=Q<=10**8 and 1<=H<=10**8 and 1<=S<=10**8 and 1<=D<=10**8):
	print("input error1")

QQ=Q*4
HH=H*2

QQQ=8*Q
HHH=4*H
SSS=2*S
N=int(input())

if not(1<=N<=10**9):
	print("input error2")

if N==1:
	sum=min(QQ,HH,S)
else:
	sum+=(N//2)*min(QQQ,HHH,SSS,D)
	if N%2==1:
		sum+=min(QQ,HH,S)

print(sum)
Buggy python submission (verdict: Runtime Error):
'''def f(a, b):
    if a * b == 0:
        return 0
    res = f(min(a, b), max(a, b) % min(a, b)) + 2 * min(a, b) * (max(a,b)//min(a, b))
    if(max(a, b) % min(a, b) == 0):
        res -= 1
    return res'''
def f(a, b):
    if(a - b == 0):
        return a
    if(a * b == 0):
        return 0
    return 2 * min(a, b) + f(min(a, b), max(a,b) - min(a, b))

n, x = map(int, input().split())
res = n + f(n - x, x)
print(res)


Fixed submission:
def f(a, b):
    if a * b == 0:
        return 0
    res = f(min(a, b), max(a, b) % min(a, b)) + 2 * min(a, b) * (max(a,b)//min(a, b))
    if(max(a, b) % min(a, b) == 0):
        res -= min(a, b)
    return res

n, x = map(int, input().split())
res = n + f(n - x, x)
print(res)

Buggy python submission (verdict: Runtime Error):
'''def f(a, b):
    if a * b == 0:
        return 0
    res = f(min(a, b), max(a, b) % min(a, b)) + 2 * min(a, b) * (max(a,b)//min(a, b))
    if(max(a, b) % min(a, b) == 0):
        res -= 1
    return res'''
def f(a, b):
    minn = min(a, b)
    maxx = max(a, b)
    if(a - b == 0):
        return a
    if(a * b == 0):
        return 0
    return 2 * minn + f(minn, maxx - minn)

n, x = map(int, input().split())
res = n + f(n - x, x)
print(res)


Fixed submission:
def f(a, b):
    if a * b == 0:
        return 0
    res = f(min(a, b), max(a, b) % min(a, b)) + 2 * min(a, b) * (max(a,b)//min(a, b))
    if(max(a, b) % min(a, b) == 0):
        res -= min(a, b)
    return res

n, x = map(int, input().split())
res = n + f(n - x, x)
print(res)
Buggy python submission (verdict: Runtime Error):
n = input()
a = map(int,raw_input().split())
print sum(i == a[a[i]-1]-1 for i in range(n)) / 2


Fixed submission:
s = raw_input()
print s[:4], s[4:]
Buggy python submission (verdict: Runtime Error):
n = input()
a = map(int,raw_input.split())
print sum(i == a[a[i-1]]-1 for i in range(n)) / 2

Fixed submission:
n = input()
a = map(int,raw_input().split())
print sum(i == a[a[i]-1]-1 for i in range(n)) / 2
Buggy python submission (verdict: Runtime Error):
a=input()
b=input()
if a !=b:
    print("H")
else:
    print("D")

Fixed submission:
a=input()
if a[0] !=a[2]:
    print("D")
else:
    print("H")
Buggy python submission (verdict: Time Limit Exceeded):

if __name__ == '__main__':

    Q, H, S, D = map(int, input().split())
    N = int(input())

    #各サイズの量
    amounts = {'Q' : 0.25, 'H' : 0.5, 'D' : 1.0, 'D' : 2.0}
    #1リットルあたりの値段
    sizes = {'Q' : int(Q * 4.0), 'H' : int(H * 2.0), 'S' : S, 'D' : int(D * 0.5)}
    sizes = sorted(sizes.items(), key=lambda x: x[1])
    sum_price = 0

    while N > 0:
        for size in sizes:

            if size[0] != 'D':
                if N - 1 >= 0:
                    N -= 1
                    sum_price += size[1]
                else:
                    break
            else:
                if N - 2 >= 0:
                    N -= 2
                    sum_price += D
                else: break
    print(sum_price)


Fixed submission:
if __name__ == '__main__':
    Q, H, S, D = map(int, input().split())
    N = int(input())
    #各サイズの量
    #amounts = {'Q' : 0.25, 'H' : 0.5, 'D' : 1.0, 'D' : 2.0}
    #1リットルあたりの値段
    sizes = {'Q' : int(Q * 4.0), 'H' : int(H * 2.0), 'S' : S, 'D' : int(D * 0.5)}
    sizes = sorted(sizes.items(), key=lambda x: x[1])
    sum_price = 0
    while N > 0:
        for size in sizes:
            if size[0] != 'D':
                sum_price += size[1] * N
                N = 0
            else:
                num = int(N / 2)
                N -= 2 * num
                sum_price += D * num
    print(sum_price)
Buggy python submission (verdict: Runtime Error):
A, B, C, D = map(int, input().split())

if B <= C:
    print(0)
else:
    print(min(B, D) - max(A,C))

Fixed submission:
N = int(input())

a = 0
b = 0

for i in range(1,10):
    if N > 100:
        N = N - 100
        a = a + 1

for j in range(1,10):
    if N > 10:
        N = N - 10
        b = b + 1
c = N

if a == c:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
from fractions import gcd

N = int(input())
T = list(map(int, input().split()))
ans = 1

for i in range(0,N):
    ans = ans * T[i] / gcd(ans, T[i])
    
print(int(ans))

Fixed submission:
import fractions
 
def lcm(a,b):
  return (a*b)//fractions.gcd(a,b)
 
N=int(input())
T=1
for i in range(N):
  T=lcm(T,int(input()))
print(T)
Buggy python submission (verdict: Runtime Error):
x=input()
a,b=input().split()
x=int(x)
a=int(a)
b=int(b)
if abs(x-a)<abs(x-b):
   print("A")
else:
   print("B")


Fixed submission:
x,a,b=map(int,input().split())
if abs(x-a) > abs(x-b):
	print("B")
else:
	print("A")

Buggy python submission (verdict: Runtime Error):
x=input()
a,b=input().split()
x=int(x)
a=int()
b=int()
if abs(x-a)<abs(x-b):
   print("A")
else:
   print("B")

Fixed submission:
x,a,b=map(int,input().split())
if abs(x-a) > abs(x-b):
	print("B")
else:
	print("A")
Buggy python submission (verdict: Runtime Error):
a,b,c,d = map(int, input().split())
if a==c:
    print(abs(b-d))
elif a>c:
    if a>d:
        print(0)
    elif a<d<b:
        print(abs(a-d))
    else:
        print(abs(a-b))
else:
    if c>b:
        print(0)
    elif c<b<d:
        print(abs(c-b))
    else:
        print(abs(c-d))

Fixed submission:
x = input()
if x[0] == x[2]:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
a,b,c,d = map(int, input().split())
if a==c:
    print(abs(b-d))
elif a>c:
    if a>d:
        print(0)
    elif a<d<b:
        print(abs(a-d))
    else:
        print(abs(a-b))
else:
    if c>b:
        print(0)
    elif c<b<d:
        print(abs(c-b))
    else:
        print(abs(c-d))

Fixed submission:
x = input()
if x[0] == x[2]:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
a,b,c,d = map(int, input().split())
if a==c:
    print(abs(b-d))
elif a>c:
    if a>d:
        print(0)
    elif a<d<b:
        print(abs(a-d))
    else:
        print(abs(a-b))
else:
    if c>b:
        print(0)
    elif c<b<d:
        print(abs(c-b))
    else:
        print(abs(c-d))

Fixed submission:
x = input()
if x[0] == x[2]:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
x = input()↲
if x[0] == x[2]:↲
    print('Yes')↲
else:↲
    print('No')↲

Fixed submission:
x = input()
if x[0] == x[2]:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
t = 0
a = 0
for i in range(n):
    T, A = map(int, input().split())
    k = 1
    while True:
        if T * k >= t and A * k >= a:
            t = T * k
            a = A * k
            break
        else:
            k += 1
print(t + a)


Fixed submission:
n = int(input())
t = 1
a = 1
for i in range(n):
    T, A = map(int, input().split())
    k = max(1, t // T + (t % T != 0), a // A + (a % A != 0))
    t = k * T
    a = k * A
print(t + a)
Buggy python submission (verdict: Time Limit Exceeded):
h, w, n = map(int, input().split())
blacks = [[0 for _ in range(w - 2)] for _ in range (h - 2)]
for _ in range(n):
    a, b = map(int, input().split())
    for p in range(max(0, a - 3), min(a, h - 2)):
        for q in range(max(0, b - 3), min(b, w - 2)):
            blacks[p][q] += 1
count = [0 for _ in range(10)]
for k in range(h - 2):
    for l in range(w -2):
        count[blacks[k][l]] += 1
for i in range(10):
    print(count[i])


Fixed submission:
from collections import Counter, defaultdict

h, w, n = map(int, input().split())
hs, ws = h - 2, w - 2
dd = defaultdict(int)

for a, b in (map(int, input().split()) for _ in range(n)):
    for y in range(max(0, a - 3), min(a, hs)):
        for x in range(max(0, b - 3), min(b, ws)):
            dd[(y, x)] += 1

print(hs * ws - len(dd))

c = Counter(dd.values())
for i in range(1, 10):
    print(c[i] if i in c else 0)

Buggy python submission (verdict: Time Limit Exceeded):
h, w, n = map(int, input().split())
blacks = [[0 for _ in range(w - 2)] for _ in range (h - 2)]
for _ in range(n):
    a, b = map(int, input().split())
    for p in range(a - 3, a):
        for q in range(b - 3, b):
            blacks[p][q] += 1
count = [0 for _ in range(10)]
for k in range(h - 2):
    for l in range(w -2):
        count[blacks[k][l]] += 1
for i in range(10):
    print(count[i])


Fixed submission:
from collections import Counter, defaultdict

h, w, n = map(int, input().split())
hs, ws = h - 2, w - 2
dd = defaultdict(int)

for a, b in (map(int, input().split()) for _ in range(n)):
    for y in range(max(0, a - 3), min(a, hs)):
        for x in range(max(0, b - 3), min(b, ws)):
            dd[(y, x)] += 1

print(hs * ws - len(dd))

c = Counter(dd.values())
for i in range(1, 10):
    print(c[i] if i in c else 0)

Buggy python submission (verdict: Time Limit Exceeded):
h, w, n = map(int, input().split())
black = []
for _ in range(n):
    black.append([int(i) for i in input().split()])
count = [0 for _ in range(10)]
for k in range(w - 2):
    for l in range(h - 2):
        thisbox = 0
        for a in range(k,k+3):
            for b in range(l,l+3):
                if [b+1, a+1] in black:
                    thisbox += 1
        count[thisbox] += 1
for i in range(10):
    print(count[i])


Fixed submission:
from collections import Counter, defaultdict

h, w, n = map(int, input().split())
hs, ws = h - 2, w - 2
dd = defaultdict(int)

for a, b in (map(int, input().split()) for _ in range(n)):
    for y in range(max(0, a - 3), min(a, hs)):
        for x in range(max(0, b - 3), min(b, ws)):
            dd[(y, x)] += 1

print(hs * ws - len(dd))

c = Counter(dd.values())
for i in range(1, 10):
    print(c[i] if i in c else 0)
Buggy python submission (verdict: Runtime Error):



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

if(b<c):print (0)
elif(b==c):
    if(b == 0):print(0)
    else:print(1)
else:
    start = a if a>c else c
    end = b if b<d else d
    print(end - start)



Fixed submission:


def isPal(n):
    sum = 0
    while(n>0):
        rem = n % 10
        sum = (sum * 10) + rem
        n = n//10

    return sum

n = int(input().strip())

if(n == isPal(n)):print('Yes')
else:print('No')
Buggy python submission (verdict: Time Limit Exceeded):

def lcmm(l,m):
    low,high = 1,1
    
    if(l==m):return l
    elif(l>m):
        if(l % m ==0):return l
        high = l
        low = m
        
    else:
        if(m % l ==0):return m
        high = m
        low = l
    lcm = high
    while(lcm%low != 0):
        lcm += high

    return lcm
n = int(input().strip())
last = 1
lcm = 1
for i in range(n):
    num = int(input().strip())
    lcm = lcmm(lcm,num)
    #print(lcm)

print(lcm)
    


Fixed submission:
def gcd(a,b):
    if(a == 0):
        return b
    else:
        return gcd(b % a, a)
    
def lcmm(l,m):

    prod = l * m

    gcD = gcd(l,m)

    return (prod // gcD)

n = int(input().strip())

lcm = 1
for i in range(n):
    num = int(input().strip())
    lcm = lcmm(lcm,num)
    #print(lcm)

print(lcm)
Buggy python submission (verdict: Runtime Error):
a=input()
b=.join(reversed(a));
if(a==b):
  print('Yes')
else:
  print('No')

Fixed submission:
a=input()
b=''.join(reversed(a))
if(a==b):
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Runtime Error):
a=input()
b=reverse(a);
if a==b:
 print('Yes')
else:
 print('No')

Fixed submission:
a=input()
b=''.join(reversed(a))
if(a==b):
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
N, L = raw_input().split()
l = []
for _ in range(N):
    l.append(raw_input().strip())
print "".join(sorted(l))

Fixed submission:
N, L = map(int, raw_input().split())
l = []
for _ in range(N):
    l.append(raw_input().strip())
print "".join(sorted(l))
Buggy python submission (verdict: Runtime Error):
S=list(set(input()))
S.sort()
import string
A=string.ascii_lowercase
for i in range(len(A)):
    if not S[i]==A[i]:
        print(A[i])
        break


Fixed submission:
S=list(set(input()))
S.sort()
import string
switch=True
A=list(string.ascii_lowercase)
for i in A:
    if not i in S:
        print(i)
        switch=False
        break
if switch:
    print("None")

Buggy python submission (verdict: Runtime Error):
S=list(set(input()))
S.sort()
import string
A=string.ascii_lowercase
for i in range(len(A)):
    if not S[i]==A[i]:
        print(A[i])
        break


Fixed submission:
S=list(set(input()))
S.sort()
import string
switch=True
A=list(string.ascii_lowercase)
for i in A:
    if not i in S:
        print(i)
        switch=False
        break
if switch:
    print("None")