Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import collections
n = map(int, raw_input().split(' '))
ais = map(int, raw_input().split(' '))
cc = collections.Counter(ais)
ais.sort()
p = [True for _ in range(10 ** 6 + 1)]

count = 0
for ai in ais:
	if p[ai] is True:
		x = 2 * ai
	 	while(x < len(p)): 
	 		p[x] = False
	 		x += ai
for ai in ais:
	if p[ai] is True:
		if cc[ai] == 1:
			count +=1
print count

Fixed submission:
import collections
n = map(int, raw_input().split(' '))
ais = map(int, raw_input().split(' '))
cc = collections.Counter(ais)
ais.sort()
m = max(ais)
p = [True for _ in range(m + 1)]

count = 0
for ai in ais:
	if p[ai] is True:
		x = 2 * ai
	 	while(x < len(p)): 
	 		p[x] = False
	 		x += ai
for ai in ais:
	if p[ai] is True:
		if cc[ai] == 1:
			count +=1
print count

Buggy python submission (verdict: Time Limit Exceeded):
import collections
n = map(int, raw_input().split(' '))
ais = map(int, raw_input().split(' '))
cc = collections.Counter(ais)
ais.sort()
forbidden = set([])
j = 0
count =0
while(j < len(ais)):
	
	if cc[ais[j]] == 1: 
		flag = True
		d= 1
		while( d * d <= ais[j]):
			if ais[j] % d == 0:
				if (d in forbidden) or ((ais[j]/d) in forbidden) :
					flag = False
					break
			d +=1
		count +=1 if flag else 0
	forbidden.add(ais[j])
	j+=1

print count

Fixed submission:
import collections
n = map(int, raw_input().split(' '))
ais = map(int, raw_input().split(' '))
cc = collections.Counter(ais)
ais.sort()
m = max(ais)
p = [True for _ in range(m + 1)]

count = 0
for ai in ais:
	if p[ai] is True:
		x = 2 * ai
	 	while(x < len(p)): 
	 		p[x] = False
	 		x += ai
for ai in ais:
	if p[ai] is True:
		if cc[ai] == 1:
			count +=1
print count

Buggy python submission (verdict: Time Limit Exceeded):
import collections
n = map(int, raw_input().split(' '))
ais = map(int, raw_input().split(' '))
cc = collections.Counter(ais)
ais.sort()
forbidden = set([])
j = 0
count =0
while(j < len(ais)):
	
	if cc[ais[j]] == 1: 
		flag = True
		for d in range(1,int(ais[j] ** 0.5) +1):
			if ais[j] % d == 0:
				if (d in forbidden) or ((ais[j]/d) in forbidden) :
					flag = False
					break
		count +=1 if flag else 0
	forbidden.add(ais[j])
	j+=1

print count

Fixed submission:
import collections
n = map(int, raw_input().split(' '))
ais = map(int, raw_input().split(' '))
cc = collections.Counter(ais)
ais.sort()
m = max(ais)
p = [True for _ in range(m + 1)]

count = 0
for ai in ais:
	if p[ai] is True:
		x = 2 * ai
	 	while(x < len(p)): 
	 		p[x] = False
	 		x += ai
for ai in ais:
	if p[ai] is True:
		if cc[ai] == 1:
			count +=1
print count
Buggy python submission (verdict: Runtime Error):


a,v = map(int, raw_input().split(' '))
b,w = map(int, raw_input().split(' '))
t = int(raw_input())

print 'YES' ig v*t >= w*t + abs(a-b) else 'NO'


Fixed submission:
a,v = map(int, raw_input().split(' '))
b,w = map(int, raw_input().split(' '))
t = int(raw_input())

print 'YES' if (v*t >= w*t + abs(a-b)) else 'NO'

Buggy python submission (verdict: Runtime Error):
1 2
3 1
3

a,v = map(int, raw_input().split(' '))
b,w = map(int, raw_input().split(' '))
t = int(raw_input())

print 'YES' ig v*t >= w*t + abs(a-b) else 'NO'


Fixed submission:
a,v = map(int, raw_input().split(' '))
b,w = map(int, raw_input().split(' '))
t = int(raw_input())

print 'YES' if (v*t >= w*t + abs(a-b)) else 'NO'
Buggy python submission (verdict: Time Limit Exceeded):
import collections
n,k = map(int, raw_input().split(' '))
ais = map(int ,raw_input().split(' '))
for _ in range(k):

	h = collections.Counter()
	for i,d in enumerate(ais):
		u = i+1
		h[max(1, u - d)] += 1
		h[u + d + 1] -= 1

	cumul = 0
	for u in range(1, n+1):
		cumul += h[u]
		ais[u - 1] = cumul

for e in ais:print e,


Fixed submission:
import collections
n,k = map(int, raw_input().split(' '))
ais = map(int ,raw_input().split(' '))

prev = ais[::]
for _ in range(k):

	h = collections.Counter()
	for i,d in enumerate(ais):
		u = i+1
		h[max(1, u - d)] += 1
		h[u + d + 1] -= 1

	cumul = 0
	for u in range(1, n+1):
		cumul += h[u]
		ais[u - 1] = cumul
	if prev == ais[::]:
		break
	prev = ais[::]


for e in ais:print e,

Buggy python submission (verdict: Time Limit Exceeded):
import collections
n,k = map(int, raw_input().split(' '))
ais = map(int ,raw_input().split(' '))
prev = ais
for _ in range(k):

	segments = []
	for i,d in enumerate(ais):
		u = i+1
		segments.append([u-d, u+d])

	for u in range(1, n+1):
		ais[u-1] = 0
		for uu,vv in segments:
			if uu <= u <=vv:
				ais[u-1] += 1
for e in ais:print e,


Fixed submission:
import collections
n,k = map(int, raw_input().split(' '))
ais = map(int ,raw_input().split(' '))

prev = ais[::]
for _ in range(k):

	h = collections.Counter()
	for i,d in enumerate(ais):
		u = i+1
		h[max(1, u - d)] += 1
		h[u + d + 1] -= 1

	cumul = 0
	for u in range(1, n+1):
		cumul += h[u]
		ais[u - 1] = cumul
	if prev == ais[::]:
		break
	prev = ais[::]


for e in ais:print e,
Buggy python submission (verdict: Runtime Error):
print int(raw_input()) * int(raw_input()) 

Fixed submission:
a,b = map(int,raw_input().split(' '))
print a*b
Buggy python submission (verdict: Runtime Error):
cumul = 1
n = int(raw_input())
ais = map(int, raw_input().split(' '))
while(i < len(ais) and cumul < 10 ** 18):
  cumul *= ais[i]
  i+=1
print cumul if cumul < 10 ** 18 else -1

Fixed submission:
cumul = 1
n = int(raw_input())
ais = map(int, raw_input().split(' '))
i = 0
ais.sort(key = lambda x:-x)
if ais[-1] == 0:
	cumul = 0
while(i < len(ais) and cumul <= 10 ** 18):
  cumul *= ais[i]
  i +=1
  if cumul == 0:
  	break

print cumul if cumul <= 10 ** 18 else -1
Buggy python submission (verdict: Runtime Error):
a,b = raw_input().split(' ')

a = int(a)
b = float(b)

b0,b1 = b.split('.') if '.' in b else [int(b), 0]
b0 = int(b0)
b1 = int(b1)

print a*b0 + a*b1/100 


Fixed submission:

a,b = raw_input().split(' ')

a = int(a)


b0,b1 = b.split('.') if '.' in b else [int(b), 0]
b0 = int(b0)
b1 = int(b1)

print a*b0 + a*b1/100

Buggy python submission (verdict: Runtime Error):

a,b = raw_input().split(' ')

a = int(a)
b = float(b)

b0,b1 = b.split('.') if '.' in b else [int(b), 0]#

print a*b0 + a*b1/100 


Fixed submission:

a,b = raw_input().split(' ')

a = int(a)


b0,b1 = b.split('.') if '.' in b else [int(b), 0]
b0 = int(b0)
b1 = int(b1)

print a*b0 + a*b1/100
Buggy python submission (verdict: Runtime Error):
def f(s,t): return t[:-1] == s and len(t) == len(s) + 1
s,t = raw_input().split()
print 'Yes' if f(s,t) else 'No'

Fixed submission:
u = raw_input()
v = raw_input()
print 'Yes' if u == v[:-1] else 'No'

Buggy python submission (verdict: Runtime Error):

u,v = raw_input().split(' ')
print 'Yes' if u == v[:-1] else 'No'

Fixed submission:
u = raw_input()
v = raw_input()
print 'Yes' if u == v[:-1] else 'No'
Buggy python submission (verdict: Runtime Error):
n = int(raw_input())
def gb(s):
	bal,m = 0
	for l in s: 
		bal += 1 if l == '(' else -1
		m = min(m, bal)
	return (bal,m)


rs = [gb(raw_input()) for _ in range(n)]
rs.sort(key = lambda x: (0,-x[1], x[0]) if x[0]>=0 else (1,x[1] - x[0], -x[0]))

def f(rs):
	s = 0
	for aa,bb in rs:
		if s + bb < 0: return False
		s += aa
	return s == 0

print 'Yes' if f(rs) else 'No'

Fixed submission:
n = int(raw_input())
def gb(s):
	bal = 0
	m = 0
	for l in s: 
		bal += 1 if l == '(' else -1
		m = min(m, bal)
	return (bal,m)


adds, dels = [], []
for _ in range(n):
	e = gb(raw_input())
	if e[0] >= 0:
		adds.append(e)
	else:
		dels.append(e)
adds.sort(key = lambda x: (-x[1], -x[0]))
dels.sort(key = lambda x: (x[1] - x[0], -x[0]))
def f(adds, dels):
	s = 0
	for aa,bb in adds:

		if s + aa < 0:
			return False
		if s + bb < 0:
			return False
		s += aa
		

	for aa,bb in dels:

		if s + aa < 0:
			return False
		if s + bb < 0:
			return False
		s += aa
	return s == 0

print 'Yes' if f(adds, dels) else 'No'
Buggy python submission (verdict: Runtime Error):
print {'ABC':'ARC', 'ARC', 'ABC'}[raw_input()]

Fixed submission:
print 'ARC' if raw_input() == 'ABC' else 'ABC'
Buggy python submission (verdict: Runtime Error):

import collections # not needed if here
def f(heights,roads):

count, r =0, [True] * len(heights)
for u,v in roads:
		if heights[u-1] <= heights[v-1]: r[u-1] = False
		if heights[u-1] >= heights[v-1]:r[v-1] = False
	for b in r:
		count += 1 if b else 0
	return count

def f_(heights,roads):
	count, adj = 0,collections.defaultdict(list)
	r = [True] * len()
for u,v in roads:

		adj[u].append(v)
		adj[v].append(u)
	for i,h in enumerate(heights):
		u = i + 1
		if h >= max([heights[v - 1] for v in adj[u]] or [-1]): count +=1
	return count

n,m = map(int, raw_input().split(' '))
print f(map(int,raw_input().split(' ')), [map(int, raw_input().split(' ')) for _ in range(m)] )


Fixed submission:
import collections

n, m = map(int, raw_input().split(' '))
hs = map(int, raw_input().split(' '))
adj = collections.defaultdict(list)
for _ in range(m):
	a,b = map(int, raw_input().split(' '))
	adj[a].append(b)
	adj[b].append(a)
count = 0
for u in range(1, n + 1):
	if all([hs[v - 1] < hs[u - 1] for v in adj[u]] or [True]):
		count+=1
print count

Buggy python submission (verdict: Runtime Error):
import collections
def f(heights,roads):
	adj = collections.defaultdict(list)
	count = 0
	for u,v in roads:
		adj[u].append(v)
		adj[v].append(u)
	for i,h in range(len(heights)):
		u = i + 1
		if h >= max([heights[v-1] for v in adj[u]] or [-1]): count +=1
	return count

n,m = map(int, raw_input().split(' '))
print f(map(int,raw_input().split(' ')), [map(int, raw_input().split(' ')) for _ in range(m)] )


Fixed submission:
import collections

n, m = map(int, raw_input().split(' '))
hs = map(int, raw_input().split(' '))
adj = collections.defaultdict(list)
for _ in range(m):
	a,b = map(int, raw_input().split(' '))
	adj[a].append(b)
	adj[b].append(a)
count = 0
for u in range(1, n + 1):
	if all([hs[v - 1] < hs[u - 1] for v in adj[u]] or [True]):
		count+=1
print count
Buggy python submission (verdict: Runtime Error):
import collections
cc = collections.Counter()
count = 0
n = raw_input()
for i,e in enumerate(map(int, raw_input().split())):
	count += cc[e - i]
    cc[e-  i] +=1
    
print count

Fixed submission:
import collections
n = int(raw_input())
hs = map(int, raw_input().split(' '))
def f(nums):
	cc,count = collections.Counter(), 0

	#j - i = aj + ai  =>  ai + i = j - aj
	for i in range(len(nums)-1, -1, -1):
		count += cc[nums[i] + i]
		cc[i - nums[i]]+=1
	return count
		


print f(hs)

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


n = int(raw_input())
hs = map(int, raw_input().split(' '))
def f(hs):
	#print sorted([(e,i) for i,e in enumerate(hs)])
	count =0
	for i in range(len(hs)):
		for j in range(i+1, len(hs)):
			if hs[i] + hs[j] == j-i:
				count+=1
	return count
print f(hs)

Fixed submission:
import collections
n = int(raw_input())
hs = map(int, raw_input().split(' '))
def f(nums):
	cc,count = collections.Counter(), 0

	#j - i = aj + ai  =>  ai + i = j - aj
	for i in range(len(nums)-1, -1, -1):
		count += cc[nums[i] + i]
		cc[i - nums[i]]+=1
	return count
		


print f(hs)
Buggy python submission (verdict: Time Limit Exceeded):
import collections
s = map(int,raw_input())

h = {}
for jj in range(2019+1):
    for d in range(0,10):
        h[jj,d] = (10 * jj + d) % 2019

dp = collections.Counter()
count = 0
for j in range(len(s)):
    ndp = collections.Counter()
    ndp[s[j]] += 1
    for k in dp:
        ndp[h[(k,s[j])]] +=1
        #ndp[(10*k + s[j]) % 2019] += 1
    count += ndp[0]
    dp = ndp

print count




Fixed submission:
import collections
s = map(int,raw_input())

dp = [0] * 2019
count = 0
for j in range(len(s)):
    ndp = [0] * 2019
    ndp[s[j]] += 1
    for k in range(len(dp)):
        ndp[(10*k + s[j]) % 2019] += dp[k]
    count += ndp[0]
    dp = ndp[::]

print count

Buggy python submission (verdict: Time Limit Exceeded):
import collections
s = map(int,raw_input())


dp = collections.Counter()
count = 0
for j in range(len(s)):
    ndp = collections.Counter()
    ndp[s[j]] += 1
    for k in dp:
        ndp[(10*k + s[j]) % 2019] += 1
    count += ndp[0]
    dp = ndp

print count




Fixed submission:
import collections
s = map(int,raw_input())

dp = [0] * 2019
count = 0
for j in range(len(s)):
    ndp = [0] * 2019
    ndp[s[j]] += 1
    for k in range(len(dp)):
        ndp[(10*k + s[j]) % 2019] += dp[k]
    count += ndp[0]
    dp = ndp[::]

print count
Buggy python submission (verdict: Runtime Error):
import collections

n,m = map(int,raw_input().split(' '))
print n - sum([map(int,raw_input().split(' '))] or [0])

Fixed submission:
n,m = map(int,raw_input().split(' '))
a = n - sum(map(int,raw_input().split(' ')) or [0])
print a if a >= 0 else -1
Buggy python submission (verdict: Runtime Error):
def f(n):
  return '7' in n
 
print 'Yes' if f(raw_input()) else 'No'

Fixed submission:
def f(n):
  return '7' in n
 
print 'Yes' if f(raw_input()) else 'No'

Buggy python submission (verdict: Runtime Error):
def f(n):
  return '7' in n

print f(raw_input())



Fixed submission:
def f(n):
  return '7' in n
 
print 'Yes' if f(raw_input()) else 'No'
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int, raw_input().split(' '))
seen = {}

while(n not in seen):
	seen[n] = abs(n - k)
	n = abs(n - k)

print min(seen.values())

Fixed submission:
n,k = map(int, raw_input().split(' '))
seen = {}

while(n not in seen):
	seen[n] = abs(n - k)
	if n == k:
		break
	elif n > k:
		if n - k < k:
			n = abs(n-k)
		else:
			n %= k
			n += k
		
	elif n < k:
		n = abs(n - k)
print min(seen.values())
Buggy python submission (verdict: Runtime Error):
a,b,c = map(int, raw_input().split(' '))
print 'Yes' if a+b < c and 4*a*b < (c - a - b) **2 else 'No'


Fixed submission:
print [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
][int(raw_input())-1]
Buggy python submission (verdict: Runtime Error):
h,w = map(int, raw_input().split(' '))
def f(h,w):
	x = w - w/2
	y = w/2
	count = 0
	count += (h - h/2) * x
	count += (h/2) * y
	return count
		


print f(h,wa)

Fixed submission:
h,w = map(int, raw_input().split(' '))
def f(h,w):
	if h == 1 or w == 1:
		return 1
	x = w - w/2
	y = w/2
	count = 0
	count += (h - (h/2)) * x
	count += ((h/2)) * y
	return count
		


print f(h,w)
Buggy python submission (verdict: Runtime Error):
print "Yes" if len(set(list(raw_input())) ==2  else "No"

Fixed submission:
print "Yes" if len(set(list(raw_input()))) ==2  else "No"
Buggy python submission (verdict: Runtime Error):
import collections

n,m = map(int,raw_input().split(' '))
operations = [map(int, raw_input().split(' ')) for _ in range(m)]
def f(operations, n):

	res = [-1] * n

	for s,c in operations:
		s -=1
		if res[s] == -1:
			res[s] = c
		elif res[s] != c:
			return (False, res)
	
	for i in range(len(res)):
		if res[i] == -1: 
			res[i] = 0 if (i or n == 1) else 1
	
	if res[0] == 0 and n:
		return (false, res)
	return (True, res)
f,r = f(operations, n)
print ''.join(map(str,r)) if f else -1

Fixed submission:
import collections

n,m = map(int,raw_input().split(' '))
operations = [map(int, raw_input().split(' ')) for _ in range(m)]
def f(operations, n):

	res = [-1] * n

	for s,c in operations:
		s -=1
		if res[s] == -1:
			res[s] = c
		elif res[s] != c:
			return (False, res)
	
	for i in range(len(res)):
		if res[i] == -1: 
			res[i] = 0 if (i or n == 1) else 1
	
	if res[0] == 0 and n > 1:
		return (False, res)
	return (True, res)
f,r = f(operations, n)
print ''.join(map(str,r)) if f else -1

Buggy python submission (verdict: Runtime Error):
import collections

n,m = map(int,raw_input().split(' '))
res = [-1] * n
flag = True
for _ in range(m):
	s,c = map(int, raw_input().split(' '))

	if res[s] == -1:
		res[s] = c
	else:
		flag = False

if flag is True:
	found = -1
	for i in range(len(s)):
		if s[i] == -1:
			s[i] = 0 if i else 1
	print ''.join(map(str, s))

else:
	print -1


Fixed submission:
import collections

n,m = map(int,raw_input().split(' '))
operations = [map(int, raw_input().split(' ')) for _ in range(m)]
def f(operations, n):

	res = [-1] * n

	for s,c in operations:
		s -=1
		if res[s] == -1:
			res[s] = c
		elif res[s] != c:
			return (False, res)
	
	for i in range(len(res)):
		if res[i] == -1: 
			res[i] = 0 if (i or n == 1) else 1
	
	if res[0] == 0 and n > 1:
		return (False, res)
	return (True, res)
f,r = f(operations, n)
print ''.join(map(str,r)) if f else -1
Buggy python submission (verdict: Time Limit Exceeded):
s = [0] + map(int,list(raw_input()))
dp = [+float('inf')] * len(s)

for j in range(len(s) - 1, -1, -1):
	a = s[j]
	if j+ 1 < len(dp): a += dp[j + 1] 
	dp[j] = min(a, dp[j])

	b = s[j] + 1
	q = 0
	for jj in range(j+1, len(s)):
		q += 9 - s[jj]
		dp[j] = min(dp[j], b + q + 1 +(dp[jj+1] if jj+1 < len(dp) else 0))

print dp[0]





Fixed submission:
s = map(int,list(raw_input()))
dp = [[0,0] for _ in range(len(s))]
for i in range(len(dp)):
	a = (dp[i - 1][0] if i - 1 >= 0 else 0) + s[i]
	b = (dp[i - 1][1] if i - 1 >= 0 else 1) + 10 - s[i]
	dp[i][0] = min(a,b)

	a = (dp[i - 1][0] if i - 1 >= 0 else 0) + s[i] + 1
	b = (dp[i - 1][1] if i - 1 >= 0 else 1) + 10 - s[i] - 1
	dp[i][1] = min(a,b)
print dp[-1][0]
Buggy python submission (verdict: Runtime Error):
n,k,s = map(int, raw_input())
r = [s] * k + [s+1] * (n - k)
for a in r:
  print a,


Fixed submission:
n,k,s = map(int, raw_input().split())
r = [s] * k 

if s == 10 ** 9:
	for i in range(n - k):  r.append((10 ** 9) - 2)
else:
	for i in range(n - k):  r.append(s + 1)
for a in r: print a,
Buggy python submission (verdict: Runtime Error):
import collections

n = int(raw_input())
s = map(lambda x:ord(x) - ord('a'.upper()),list(raw_input()))

count,c = 0,0

0 1 2 
for i in s:
	if i == c:
		c +=1
	else:
		c = 0
		if i == c: c +=1
	if c == 3:
		count +=1
		c = 0
print count


Fixed submission:
import collections

n = int(raw_input())
s = map(lambda x:ord(x) - ord('a'.upper()),list(raw_input()))

count,c = 0,0

for i in s:
	if i == c:
		c +=1
	else:
		c = 0
		if i == c: c +=1
	if c == 3:
		count +=1
		c = 0
print count
Buggy python submission (verdict: Runtime Error):
import collections

n = int(raw_input())
p = map(int,raw_input().split(' '))
q = map(int,raw_input().split(' '))


factorial[0] = 1
for i in range(1,9):
	cumul *= i
	factorial[i] = cumul


def f(p):
	if len(p) == 1: return 0
	sp = sorted(p)
	for i,e in enumerate(sp):
		if e == p[0]:
			hm = i
			break 

	return i * factorial[len(p) -1] + f(p[1:])


print abs(f(p) - f(q))

Fixed submission:
import collections

n = int(raw_input())
p = map(int,raw_input().split(' '))
q = map(int,raw_input().split(' '))

def factorial(n): return (n * factorial(n-1)) if n>0 else 1


def f(p,n):

	if len(p) == 1:
		return 0
	sp = sorted(p)
	for i,e in enumerate(sp):
		if e == p[0]:
			hm = i
			break 

	return i * factorial(len(p) -1) + f(p[1:],n)


print abs(f(p,n) - f(q,n))

Buggy python submission (verdict: Runtime Error):
import collections

n = int(raw_input())
p = map(int,raw_input().split(' '))
q = map(int,raw_input().split(' '))

factorial = {}
factorial[0] = 1
for i in range(9):
	cumul *= i
	factorial[i] = cumul


def f(p):
	if len(p) == 1: return 0
	sp = sorted(p)
	for i,e in enumerate(sp):
		if e == p[0]:
			hm = i
			break 

	return i * factorial[len(p) -1] + f(p[1:])


print abs(f(p) - f(q))

Fixed submission:
import collections

n = int(raw_input())
p = map(int,raw_input().split(' '))
q = map(int,raw_input().split(' '))

def factorial(n): return (n * factorial(n-1)) if n>0 else 1


def f(p,n):

	if len(p) == 1:
		return 0
	sp = sorted(p)
	for i,e in enumerate(sp):
		if e == p[0]:
			hm = i
			break 

	return i * factorial(len(p) -1) + f(p[1:],n)


print abs(f(p,n) - f(q,n))

Buggy python submission (verdict: Runtime Error):
import collections

n = int(raw_input())
p = map(int,raw_input().split(' '))
q = map(int,raw_input().split(' '))


factorial[0] = 1
for i in range(9):
	cumul *= i
	factorial[i] = cumul


def f(p,n):
	if len(p) == 1: return 0
	sp = sorted(p)
	for i,e in enumerate(sp):
		if e == p[0]:
			hm = i
			break 

	return i * factorial[len(p) -1] + f(p[1:],n)


print abs(f(p,n) - f(q,n))

Fixed submission:
import collections

n = int(raw_input())
p = map(int,raw_input().split(' '))
q = map(int,raw_input().split(' '))

def factorial(n): return (n * factorial(n-1)) if n>0 else 1


def f(p,n):

	if len(p) == 1:
		return 0
	sp = sorted(p)
	for i,e in enumerate(sp):
		if e == p[0]:
			hm = i
			break 

	return i * factorial(len(p) -1) + f(p[1:],n)


print abs(f(p,n) - f(q,n))
Buggy python submission (verdict: Runtime Error):
import heapq

n,m = map(int, raw_input().split(' '))
elems = map(int, raw_input().split(' '))
elems.sort()

heap = [(-elems[i] - elems[-1], i,len(elems) - 1) for i in range(len(elems))]
heapq.heapify(heap)
cumul = 0

while(m):
	m -=1
	v, i, j = heapq.heappop(heap)
	cumul -= v
	if j -1 >=0: heapq.heappush(heap, (-elems[i] - elems[j-1], i, j - 1))
print cumul

Fixed submission:
b,a = raw_input().split(' ')
print a + b
Buggy python submission (verdict: Runtime Error):
n,s = int(raw_input()), raw_input()
i,j,count = 0,0,0
while(j < n):
	while(j < n and s[i] == s[j]):
		j+=1
    i = j
    count +=1
print count


Fixed submission:
n,s = int(raw_input()), raw_input()
i,j,count = 0,0,0
while(j < n):
	while(j < n and s[i] == s[j]): j+=1
	i = j
	count +=1
print count

Buggy python submission (verdict: Runtime Error):
n,s = int(raw_input()), raw_input()
i,j = 0,0
while(j < n):
	while(j < n and s[i] == s[j]):
		j+=1
    i = j
    count +=1
print count


Fixed submission:
n,s = int(raw_input()), raw_input()
i,j,count = 0,0,0
while(j < n):
	while(j < n and s[i] == s[j]): j+=1
	i = j
	count +=1
print count

Buggy python submission (verdict: Runtime Error):
n,s = int(raw_input()), raw_input()
i = 0
while(j < n):
	while(j < n and s[i] == s[j]):
		j+=1
    i = j
    count +=1
print count

Fixed submission:
n,s = int(raw_input()), raw_input()
i,j,count = 0,0,0
while(j < n):
	while(j < n and s[i] == s[j]): j+=1
	i = j
	count +=1
print count
Buggy python submission (verdict: Runtime Error):
n,m = map(int, raw_input().split(' '))
print sum([1 for e in  map(int, raw_input().split(' ')) if e >= m else 0])

Fixed submission:
n,m = map(int, raw_input().split(' '))
print sum([1 for e in  map(int, raw_input().split(' ')) if e >= m] or [0])
Buggy python submission (verdict: Runtime Error):
def f(s):
	p = True
	for u in s:
		if u not in ('RUD' if p else 'LUD'): return False
		p ^= True 
	returnTrue
print 'Yes' if f(raw_input()) else 'No'


Fixed submission:
def f(s):
	p = True
	for u in s:
		if u not in ('RUD' if p else 'LUD'): return False
		p ^= True 
	return True
print 'Yes' if f(raw_input()) else 'No'
Buggy python submission (verdict: Runtime Error):
import collections
n,s,m = map(int, raw_input().split(' '))
cc = collections.Counter
cumul = 0
for _ in range(m):
	cc[int(raw_input()) - 1] += 1
	cumul += 1
for u in range(n):
	q = 0
	q += cc[u] - cumul
	if q > 0:
		print 'Yes'	
	else:
		print 'No'



Fixed submission:
import collections
n,s,m = map(int, raw_input().split(' '))
cc = collections.Counter()
cumul = 0
for _ in range(m):
	cc[int(raw_input()) - 1] += 1
	cumul += 1
for u in range(n):
	q = s
	q += cc[u] - cumul
	if q > 0:
		print 'Yes'	
	else:
		print 'No'
Buggy python submission (verdict: Runtime Error):
import math
import heapq
n,m = map(int, raw_input().split(' '))

heap = [-e for  e in map(int, raw_input().split(' '))]
heapq.heapify(heap)
while(m):
	u = heapq.heappop(heap)
	u *= -1
	u /=2
	if u:
		heapq.heappush(heap, -u)
	m-=1
	"""

	q = int(math.ceil(math.log(u,2)))
	if 2 ** q <= u: q +=1
	if q <= m:
		m-= q
	else:
		u /= 2
		m -=1
		if u:
			heapq.heappush(heap, -u)

	"""
print -sum(heap or [0])


Fixed submission:
import math
import heapq
n,m = map(int, raw_input().split(' '))

heap = [-e for  e in map(int, raw_input().split(' '))]
heapq.heapify(heap)
while(m and heap):
	u = heapq.heappop(heap)
	u *= -1
	u /=2
	if u:
		heapq.heappush(heap, -u)
	m-=1
	"""

	q = int(math.ceil(math.log(u,2)))
	if 2 ** q <= u: q +=1
	if q <= m:
		m-= q
	else:
		u /= 2
		m -=1
		if u:
			heapq.heappush(heap, -u)

	"""
print -sum(heap or [0])