Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int, input().split()))
cnt = 0
while True:
    dfrag = 0
    for i in range(N):
        if a[i]%2 == 0 and dfrag == 0 :
            a[i] = a[i]//2
            dfrag = 1
    if dfrag == 0:
        break
    cnt += 1
print(cnt)
        

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
cnt = 0
while True:
    dfrag = 0
    for i in range(N):
        if a[i]%2 == 0:
            a[i] = a[i]//2
            dfrag = 1
            cnt += 1
    if dfrag == 0:
        break
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int, input().split()))
cnt = 0
while True:
    dfrag = 0
    for i in range(N):
        if a[i]%2 == 0 and dfrag == 0 :
            a[i] = a[i]//2
            dfrag = 1
        else:
            a[i] = a[i]*3
    if dfrag == 0:
        break
    cnt += 1
print(cnt)
        

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
cnt = 0
while True:
    dfrag = 0
    for i in range(N):
        if a[i]%2 == 0:
            a[i] = a[i]//2
            dfrag = 1
            cnt += 1
    if dfrag == 0:
        break
print(cnt)
Buggy python submission (verdict: Runtime Error):
s = input()
K = int(input())
LIST = []
for i in range(len(s)-1):
    j=i+1
    while j<=len(s):
        if s[i:j] not in LIST:
            LIST.append(s[i:j])
            LIST.sort()
            LIST[0:K]
        j+=1

print(LIST[K-1])

Fixed submission:
a,b,c,d = map(int, input().split())
if abs(a-c)<=d or (abs(a-b)<=d and abs(b-c)<=d):
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
X = int(input())
b=1
MAX=1
if X!=1:
    while b<X/2:
        p=2
        b+=1
        while b**p <= X:
            if b**p > MAX:
                MAX = b**p
            p+=1
print(MAX)

Fixed submission:
a,b,c,d = map(int, input().split())
if abs(a-c)<=d or (abs(a-b)<=d and abs(b-c)<=d):
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
X = int(input())
b=1
MAX=1
if X!=1:
    while b<X:
        p=2
        b+=1
        while b**p <= X:
            if b**p > MAX:
                MAX = b**p
            p+=1
print(MAX)

Fixed submission:
a,b,c,d = map(int, input().split())
if abs(a-c)<=d or (abs(a-b)<=d and abs(b-c)<=d):
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
X = int(input())
b=1
MAX=1
if X!=1:
    while b<X:
        p=2
        b+=1
        while b**p <= X:
            if b**p > MAX:
                MAX = b**p
            p+=1
print(MAX)

Fixed submission:
a,b,c,d = map(int, input().split())
if abs(a-c)<=d or (abs(a-b)<=d and abs(b-c)<=d):
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
X = int(input())
b=0
MAX=0
while b<X:
    p=2
    b+=1
    while b**p <= X:
        if b**p > MAX:
            MAX = b**p
            p+=1
print(MAX)

Fixed submission:
a,b,c,d = map(int, input().split())
if abs(a-c)<=d or (abs(a-b)<=d and abs(b-c)<=d):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
fist = list(map(int, input().split()))
N = fist[0]
X = fist[1]
DList=[]
kosu=0
for i in range(N):
    DList.append(int(input()))
X -= sum(DList)
kosu += len(DList)

sD = min(Dlist)

while X >sD:
    X -= sD
    kosu += 1
    print(kosu)

Fixed submission:

fist = list(map(int, input().split()))
N = fist[0]
X = fist[1]
DList=[]
kosu=0
for i in range(N):
    DList.append(int(input()))
X -= sum(DList)
kosu += len(DList)

sD = min(DList)

while X >= sD:
    X -= sD
    kosu += 1
print(kosu)
Buggy python submission (verdict: Runtime Error):
import sys
N, M = map(int, input().split())
A = [0 for i in range(N+1)]
for i in range(M):
	A1, A2 = map(int, input().split())
	A[A1] = A2
	
ans = 0
min_dir = sys.maxint
for i in range(1, N+1):
	if A[i] != 0:
		min_dir = min(A[i], min_dir)
	if i >= min_dir:
		ans += 1
		if A[i] != 0:
			min_dir = A[i]
		else:
			min_dir = sys.maxint
print(ans)
	
	

Fixed submission:
import sys

N, M = map(int, input().split())
A = [0 for i in range(N+1)]
for i in range(M):
	A1, A2 = map(int, input().split())
	if A[A1] > A2 or A[A1] == 0:
		A[A1] = A2
	
ans = 0
min_dir = sys.maxsize
for i in range(1, N+1):
	if A[i] != 0:
		min_dir = min(A[i], min_dir)
	if i >= min_dir:
		ans += 1
		if A[i] != 0:
			min_dir = A[i]
		else:
			min_dir = sys.maxsize
print(ans)
Buggy python submission (verdict: Runtime Error):

# coding: utf-8

# In[243]:


N = int(input())


# In[244]:


list_9 = [9]
for i in range(4):
    list_9.append(list_9[i] * 9)
    
list_6 = [6]
for i in range(5):
    list_6.append(list_6[i] * 6)


# In[245]:


amount_list = list_9 + list_6 + [1]
amount_list.sort(reverse=True)


# In[247]:


import math
dp = [math.inf] * (N+1)
dp[0] = 0


# In[248]:


for i in range(len(dp)):
    for amount in amount_list:
        if i >= amount:
            dp[i] = min(dp[i],dp[i-amount]+1)
print(dp[N])



Fixed submission:

# coding: utf-8

# In[243]:


N = int(input())


# In[244]:


list_9 = [9]
for i in range(4):
    list_9.append(list_9[i] * 9)
    
list_6 = [6]
for i in range(5):
    list_6.append(list_6[i] * 6)


# In[245]:


amount_list = list_9 + list_6 + [1]
amount_list.sort(reverse=True)


# In[247]:


dp = [10**9] * (N+1)
dp[0] = 0


# In[248]:


for i in range(len(dp)):
    for amount in amount_list:
        if i >= amount:
            dp[i] = min(dp[i],dp[i-amount]+1)
print(dp[N])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = sorted(map(int, input().split()))
B = map(int, input().split())
C = sorted(map(int, input().split()), reverse=True)

counts = 0
checked = {}
for _numB in B:
    if _numB in checked:
        counts += checked[_numB]
    else:
        countsA = 0
        for _numA in A:
            if (_numB > _numA):
                countsA += 1
            else:
                break
        countsC = 0
        for _numC in C:
            if (_numC > _numB):
                countsC += 1
            else:
                break
        checked[_numB] = countsA * countsC
        counts += countsA * countsC
print(counts)


Fixed submission:
import bisect

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

counts = 0
checked = {}
for _numB in B:
    if _numB not in checked:
        countsA = bisect.bisect_left(A, _numB)
        countsC = bisect.bisect_right(C, _numB)
        checked[_numB] = countsA * (N - countsC)
    counts += checked[_numB]
print(counts)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools

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

counts = 0
products = itertools.product(A, B, C)
for product in products:
    if(product[0] < product[1] and product[1] < product[2]):
        counts += 1
print(counts)


Fixed submission:
import bisect

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

counts = 0
checked = {}
for _numB in B:
    if _numB not in checked:
        countsA = bisect.bisect_left(A, _numB)
        countsC = bisect.bisect_right(C, _numB)
        checked[_numB] = countsA * (N - countsC)
    counts += checked[_numB]
print(counts)
Buggy python submission (verdict: Runtime Error):
input()
a=list(map(int,input().split(' ')))
sum=0
for i in a:
    sum+=i-1
print(sum)


Fixed submission:
a=list(map(int,input().split(' ')))
a=sorted(a)
print(a[2]-a[0])
Buggy python submission (verdict: Runtime Error):
input()
a=input().split(' ')
sum=0
for i in a:
    sum+=i-1
print(sum)


Fixed submission:
input()
a=list(map(int,input().split(' ')))
sum=0
for i in a:
    sum+=i-1
print(sum)
Buggy python submission (verdict: Runtime Error):
import numpy as np



def ii():
    return int(input())




def lvi(N):
    l = []
    for _ in range(N):
        l.append(ii())
    return l



N = ii()

P = lvi(N)

'''
P = []
for _ in range(N):
    p = ii()
    P.append(p -1)

print(P)
'''

#fill( Q, Q + N, 0)
Q = [0 for i in range(N)]


#print( 'Q', Q)

for i in range(1, N):
    Q[P[i - 1]] = i


maxcnt = 1
cnt = 1

print( 'Q', Q)

for i in range(1, N):
    if Q[i] > Q[i - 1]:
        cnt += 1
    else:
        cnt = 1

    maxcnt = max( maxcnt, cnt)


print(N - maxcnt)


Fixed submission:
import numpy as np

def ii():
    return int(input())


def lii():
    return list(map(int, input().split(' ')))


def lvi(N):
    l = []
    for _ in range(N):
        l.append(ii())
    return l


def lv(N):
    l = []
    for _ in range(N):
        l.append(input())
    return l


N = ii()
P = []
for _ in range(N):
    p = ii()
    P.append(p-1)

Q = [0 for i in range(N)]
for i in range(N):
    Q[P[i]] = i

maxcnt = 1
cnt = 1
for i in range(1, N):
    if Q[i] > Q[i-1]:
        cnt += 1
    else:
        cnt = 1

    maxcnt = max(maxcnt, cnt)

print(N - maxcnt)
Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
a = list(map(int, input().split()))

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm_list(numbers):
    a_0 = numbers.pop()
    for i in numbers:
        a_0 = lcm_base(a_0, i)
    return a_0

b = a.copy()
m = lcm_list(b)-1
sum = 0
for j in a:
    sum += m%j

print(sum)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
sum = 0
for a_i in a:
    sum += a_i-1
print(sum)

Buggy python submission (verdict: Runtime Error):
from functools import reduce
import math
n = int(input())
a = list(map(int, input().split()))

#最小公倍数−1
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

m = lcm_list(a)-1
sum = 0
for i in a:
    sum += m%i

print(sum)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
sum = 0
for a_i in a:
    sum += a_i-1
print(sum)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
l_abs = []
max_v = 0
for i, a_i in enumerate(a):
    if(max_v < a_i):
        max_v = a_i
    l_abs.append(abs((i+1)-a_i))

min = 10 ** 16
if sum(l_abs) == 0:
    min = 0
else:
    for b in range(-(max_v+1), max_v+1):
        sum = 0
        for j, a_j in enumerate(a):
            sum += abs(a_j-(b+j+1))
        if(min > sum):
            min = sum
print(min)


Fixed submission:
n = int(input())
if(n%2==0):
    print(str(n))
else:
    print(str(n * 2))
Buggy python submission (verdict: Runtime Error):
import copy
import numpy as np
n,m = map(int, input().split())
cakes = []
for i in range(n):
    cakes.append(list(map(int, input().split())))

def rec(i, k, s, obj):
    if i==k:
        obj.append(s)
        return
    rec(i+1, k, copy.deepcopy(s), obj)
    s[i]=1
    rec(i+1, k, copy.deepcopy(s), obj)
    s[i]=-1


def makeCombination(k):
    s=[-1 for i in range(k)]
    obj = []
    rec(0, k, s, obj)
    return obj

comb = makeCombination(3)
max = 0
for c in comb:
    sum_list = []
    nc = np.array(c)
    for cak in cakes:
        cake = np.array(cak)
        total = cake.dot(nc)
        sum_list.append(total)
    ssum_list = sorted(sum_list)
    sum_mm = sum(ssum_list[n-m:])
    if(max < sum_mm):
        max = sum_mm

print(max)


Fixed submission:
A, B = map(int, input().split())
if(A > 8 or B > 8):
    print(':(')
else:
    print('Yay!')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int, input().split()))
isCon = True
counter = 0
while(isCon):
    isDiv = False
    for i in range(len(a)):
        if(not isDiv and a[i]%2==0):
            a[i] = a[i]//2
            isDiv = True
        else:
            a[i] = a[i]*3
    if(not isDiv):
        isCon = False
    else:
        counter += 1
print(counter)


Fixed submission:
N = int(input())
a = list(map(int, input().split()))
isCon = True
counter = 0
for ai in a:
    while(ai % 2 == 0):
        ai = ai//2
        counter += 1
print(counter)
Buggy python submission (verdict: Runtime Error):
import math
n,a,b,k = map(int, input().split())
un = 998244353
def combination(n,r):
    return math.factorial(n)//(math.factorial(r) * math.factorial(n-r))

total = 0
for i in range(n+1):
    if((k-a*i)%b==0):
        count_b = (k-a*i)//b
        total += combination(n, i) * combination(n, count_b)

print(str(total % un))


Fixed submission:
n = int(input())
dp = [0 for i in range(n)]
min = float("inf")
for i in range(1, n//2):
    a_sum = sum(map(int, list(str(i))))
    b_sum = sum(map(int, list(str(n - i))))
    c = a_sum + b_sum
    if(min > c):
        min = c
if min == float("inf"):
    min = n
print(min)
Buggy python submission (verdict: Runtime Error):
import math
n,a,b,k = map(int, input().split())
un = 998244353
def combination(n,r):
    return math.factorial(n)//(math.factorial(r) * math.factorial(n-r))

total = 0
for i in range(n+1):
    if((k-a*i)%b==0):
        count_b = (k-a*i)//b
        total += combination(n, i) * combination(n, count_b)

print(str(total % un))


Fixed submission:
import math
n,a,b,k = map(int, input().split())
un = 998244353
f = [0]*(n+1)
inv = [0] * (n+1)
f[0] = f[1] = 1

for i in range(2, n+1):
    f[i] = (f[i-1] * i ) % un

inv[n] = pow(f[n], un-2, un)
for i in range(n, 0, -1):
    inv[i-1] = (inv[i] * i) % un

#フェルマーの小定理の利用
def nCr(n,r):
    global f, inv
    return (f[n] * inv[r]) % un * inv[n-r] % un

total = 0
for i in range(n+1):
    if((k-a*i)%b==0):
        count_b = (k-a*i)//b
        if(count_b >= 0 and count_b <= n):
            total += nCr(n, i) * nCr(n, count_b)

print(str(total % un))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = list(input())
total = 0
l_c, r_c = 0,0
min = 3*10**5 + 1
for i in range(n):
    left = s[0:i]
    right = s[i+1:n]
    if(left and right):
        l_c = left.count('W')
        r_c = right.count('E')
        total = l_c + r_c
    elif(left):
        l_c = left.count('W')
        total = l_c
    elif(right):
        r_c = right.count('E')
        total = r_c

    if(min > total):
        min = total
        total = 0

print(min)

Fixed submission:
n = int(input())
s = list(input())
r_c = s[1:n].count('E')
min = r_c
for i in range(1,n):
    if(s[i-1] == 'W'):
        r_c += 1
    if(s[i] == 'E'):
        r_c -=1
    if(min > r_c):
        min = r_c
print(min)
Buggy python submission (verdict: Runtime Error):
c1 = list(map(int, input().split()))
c2 = list(map(int, input().split()))
c3 = list(map(int, input().split()))
total = 0
div = c1[0]+c2[1]+c3[2]
for (x,y,z) in zip(c1,c2,c3):
    total = total + x + y + z

print ('Yes' if total / div == 3 else 'No')

Fixed submission:
N = int(input())
A = int(input())
if(A>=N%500):
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
c1 = list(map(int, input().split()))
c2 = list(map(int, input().split()))
c3 = list(map(int, input().split()))
total = 0
div = c1[0]+c2[1]+c3[2]
for (x,y,z) in zip(c1,c2,c3):
    total = total + x + y + z

print ('Yes' if total / div == 3 else 'No')

Fixed submission:
c1 = list(map(int, input().split()))
c2 = list(map(int, input().split()))
c3 = list(map(int, input().split()))
total = 0
div = c1[0]+c2[1]+c3[2]
for (x,y,z) in zip(c1,c2,c3):
    total = total + x + y + z

print ('Yes' if total / 3 == div else 'No')
Buggy python submission (verdict: Runtime Error):
from heapq import *
import numpy as np

class vertex:
    def __init__(self):
        self.list_adj = []  # list of [no_adjnode, a, b]

    def add_edge(self, adj):
        self.list_adj.append(adj)

n, m, s, t = map(int, input().split())
# zero start
s -= 1
t -= 1

# 
vertices = []
for i in range(n):
    v = vertex()
    vertices.append(v)

print(n, m, s, t)
# load node
for k in range(m):
    u, v, a, b = map(int, input().split())
    vertices[u-1].add_edge([v-1, a, b])
    vertices[v-1].add_edge([u-1, a, b])


#print('-----------------')

#print(n, m, s, t)
#for i in range(n):
#    print(vertices[i].list_adj)

mode = 0
# return list of [no_adj, cost]
def get_adj(v):
    res = []
    for adj in v.list_adj:
        res.append([adj[0], adj[1+mode]])
    return res

#print('show adjcent(a)')
#for k in range(n):
#    print(get_adj(vertices[k]))

mode = 1
#print('show adjcent(b)')
#for k in range(n):
#    print(get_adj(vertices[k]))

def dijkstra(s):
    inf = int(10e20)
    dist = [inf] * n
    h = []
    heappush(h, (0, s))
    while len(h) > 0:
        # pop 1 node
        dv, v = heappop(h)
        # if already decided, continue
        if dist[v] < inf:
            continue
        dist[v] = dv
        # push adjcent node
        list_adj = get_adj(vertices[v])
        for adj in list_adj:
            if dist[adj[0]] == inf:
                heappush(h, (dv + adj[1], adj[0]))
                pass
        pass
    return dist

mode = 0
dist_a = dijkstra(s)
mode = 1
dist_b = dijkstra(t)
#cost = []
#for k in range(len(dist_a)):
#    cost.append(dist_a[k] + dist_b[k])
cost = np.array(dist_a,dtype = 'int') + np.array(dist_b,dtype = 'int')
cost = np.array(cost, dtype='int')
#print(cost)

m0 = int(10e15)
for i in range(n):
    cost_available = cost[i:]
    print(m0-np.amin(cost_available))

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

if a + b == 15:
  print('+')
elif a * b == 15:
  print('*')
else:
  print('x')
Buggy python submission (verdict: Runtime Error):
import numpy

s = list(input())
t = input()

tmp = s[:]
for i in range(len(tmp)):
    tmp = numpy.roll(tmp, 1)
    if ''.join(tmp) == t:
        print('Yes')
        exit()
print('No')


Fixed submission:
arr = [int(i) for i in input().split()]
arr.sort()
arr.reverse()

result = (arr[0] - arr[1]) + (arr[1] - arr[2])
print(result)
Buggy python submission (verdict: Runtime Error):
N = map(int, raw_input().split())

A=N[0]
B=N[1]
C=N[2]

Answerlist= [0 for i in range(3)]
Answerlist[0]=abs(A-B)
Answerlist[1]=abs(B-C)
Answerlist[2]=abs(C-A)

print(max(Answerlist))

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

A=N[0]
B=N[1]
C=N[2]

Answerlist= [0 for i in range(3)]
Answerlist[0]=abs(A-B)
Answerlist[1]=abs(B-C)
Answerlist[2]=abs(C-A)

print(max(Answerlist))
Buggy python submission (verdict: Runtime Error):
a,b,c,d = map(int,input())

if a+b+c+d == 7:
    print(a+"+"+b+"+"+c+"+"+d+"=7")
elif a+b+c-d == 7:
    print(a+"+"+b+"+"+c+"-"+d+"=7")
elif a+b-c-d == 7:
    print(a+"+"+b+"-"+c+"-"+d+"=7")
elif a-b-c-d == 7:
    print(a+"-"+b+"-"+c+"-"+d+"=7")
elif a-b+c-d == 7:
    print(a+"-"+b+"+"+c+"-"+d+"=7")
elif a-b-c+d == 7:
    print(a+"-"+b+"-"+c+"+"+d+"=7")
elif a-b+c-d == 7:
    print(a+"-"+b+"+"+c+"-"+d+"=7")

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

if a+b+c+d == 7:
    print(str(a) + "+" + str(b) + "+" + str(c) + "+" + str(d) + "=" + "7")
elif a+b+c-d == 7:
    print(str(a) + "+" + str(b) + "+" + str(c) + "-" + str(d) + "=" + "7")
elif a+b-c+d == 7:
    print(str(a) + "+" + str(b) + "-" + str(c) + "+" + str(d) + "=" + "7")
elif a+b-c-d == 7:
    print(str(a) + "+" + str(b) + "-" + str(c) + "-" + str(d) + "=" + "7")
elif a-b-c-d == 7:
    print(str(a) + "-" + str(b) + "-" + str(c) + "-" + str(d) + "=" + "7")
elif a-b-c+d == 7:
    print(str(a) + "-" + str(b) + "-" + str(c) + "+" + str(d) + "=" + "7")
elif a-b+c-d == 7:
    print(str(a) + "-" + str(b) + "+" + str(c) + "-" + str(d) + "=" + "7")
elif a-b+c+d == 7:
    print(str(a) + "-" + str(b) + "+" + str(c) + "+" + str(d) + "=" + "7")

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

if a+b+c+d == 7:
    print(a+"+"+b+"+"+c+"+"+d+"=7")
elif a+b+c-d == 7:
    print(a+"+"+b+"+"+c+"-"+d+"=7")
elif a+b-c-d == 7:
    print(a+"+"+b+"-"+c+"-"+d+"=7")
elif a-b-c-d == 7:
    print(a+"-"+b+"-"+c+"-"+d+"=7")
elif a-b+c-d == 7:
    print(a+"-"+b+"+"+c+"-"+d+"=7")
elif a-b-c+d == 7:
    print(a+"-"+b+"-"+c+"+"+d+"=7")

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

if a+b+c+d == 7:
    print(str(a) + "+" + str(b) + "+" + str(c) + "+" + str(d) + "=" + "7")
elif a+b+c-d == 7:
    print(str(a) + "+" + str(b) + "+" + str(c) + "-" + str(d) + "=" + "7")
elif a+b-c+d == 7:
    print(str(a) + "+" + str(b) + "-" + str(c) + "+" + str(d) + "=" + "7")
elif a+b-c-d == 7:
    print(str(a) + "+" + str(b) + "-" + str(c) + "-" + str(d) + "=" + "7")
elif a-b-c-d == 7:
    print(str(a) + "-" + str(b) + "-" + str(c) + "-" + str(d) + "=" + "7")
elif a-b-c+d == 7:
    print(str(a) + "-" + str(b) + "-" + str(c) + "+" + str(d) + "=" + "7")
elif a-b+c-d == 7:
    print(str(a) + "-" + str(b) + "+" + str(c) + "-" + str(d) + "=" + "7")
elif a-b+c+d == 7:
    print(str(a) + "-" + str(b) + "+" + str(c) + "+" + str(d) + "=" + "7")
Buggy python submission (verdict: Runtime Error):
import sys
n = int (sys.stdin.readline())
a = map (int, sys.stdin.readline().split())
res = 0
for i in range (n):
  if a[i] == i+1:
    if i+1 < n:
      a[i], a[i+1] = a[i+1], a[i]
    res += 1
print (res)


Fixed submission:
import sys
n = int (sys.stdin.readline())
a = map (int, sys.stdin.readline().split())
res = 0
for i in range (n):
  if a[i] == i+1:
    if i+1 < n:
      a[i], a[i+1] = a[i+1], a[i]
    res += 1
print (res)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import itertools


def filter_name(n):
    return n.startswith("M") or n.startswith("A") or n.startswith("R") or n.startswith("C") or n.startswith("H")


def filter_ok(l):
    dic = {'M': 0, 'A': 0, 'R': 0, 'C': 0, 'H': 0}
    for i in l:
        dic[i[0:1]] += 1
    for num in dic.values():
        if num >= 2:
            return False
    return True


n = input()
a = []
for i in range(n):
    a.append(raw_input())

r = filter(filter_name, a)
c = list(itertools.combinations(r, 3))
r = filter(filter_ok, c)
print len(r)


Fixed submission:
# -*- coding: utf-8 -*-
a = int(raw_input())
print (a/3)
Buggy python submission (verdict: Runtime Error):
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def lcm_base(x, y):
	return (x * y) // gcd(x, y)

def lcm_list(numbers):
    ans = lcm_base(numbers[0], numbers[1])
    for x in numbers:
        ans = lcm_base(ans, x)
    return ans

n = int(input())
t = [int(input()) for i in range(n)]

result = lcm_list(t)
print(result)


Fixed submission:
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def lcm_base(x, y):
	return (x * y) // gcd(x, y)

def lcm_list(numbers):
    ans = lcm_base(numbers[0], numbers[1])
    for x in numbers:
        ans = lcm_base(ans, x)
    return ans

n = int(input())
t = [int(input()) for i in range(n)]

result = lcm_list(t) if len(t) != 1 else t[0]
print(result)

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

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

n = int(input())
t = [int(input()) for i in range(n)]

result = lcm_list(t)
print(result)

Fixed submission:
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def lcm_base(x, y):
	return (x * y) // gcd(x, y)

def lcm_list(numbers):
    ans = lcm_base(numbers[0], numbers[1])
    for x in numbers:
        ans = lcm_base(ans, x)
    return ans

n = int(input())
t = [int(input()) for i in range(n)]

result = lcm_list(t) if len(t) != 1 else t[0]
print(result)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
X = list(map(int,input().split()))
B = [0]*(N-1)
mid = int(N/2)-1
for i in range(N):
    B = X[:i]+X[i+1:]
    B.sort()
    print(B[mid])

Fixed submission:
N = int(input())
X = list(map(int,input().split()))
B = [i for i in X]
B.sort()
mid_s = B[int(N/2)-1]
mid_l = B[int(N/2)]
for i in range(N):
    if X[i] <= mid_s:
        print(mid_l)
    elif X[i] >= mid_l:
        print(mid_s)
Buggy python submission (verdict: Runtime Error):
setA = set([i for i in range(A,min(A+K,B+1))])
setB = set([i for i in range(max(A,B-K+1),B+1)])
setAB = sorted(setA | setB)
for i in list(setAB):
    print(i)

Fixed submission:
A, B, K = map(int, input().split())
setA = set([i for i in range(A,min(A+K,B+1))])
setB = set([i for i in range(max(A,B-K+1),B+1)])
setAB = sorted(setA | setB)
for i in list(setAB):
    print(i)