Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import collections
import math
n,k = map(int, raw_input().split(' '))
ais = map(int, raw_input().split(' '))
r = 0
m = 42
x = 0
for ii in range(m, -1, -1):
	cc = collections.Counter([(ai >> ii) & 1 for ai in ais])
	if (1 << ii) <= k:
		if cc[1] > cc[0]:
			x = x
		elif cc[1] == cc[0]:
			a,b = 0,0
			for ai in ais:
				if (ai >> ii) & 1 == 0:
					a += ai		
				else:
					b += ai
			if a <= b:
				x |= (1 << i)
		else:
			x |= (1 << ii)
	  
for ai in ais:
	r += ai ^ x
print r

Fixed submission:
import collections
import math
n,k = map(int, raw_input().split(' '))
ais = map(int, raw_input().split(' '))
r = 0
m = 42
x = 0
for ii in range(m, -1, -1):
	cc = collections.Counter([(ai >> ii) & 1 for ai in ais])
	if (x + (1 << ii) <= k):
		if cc[0] > cc[1]: x += (1 << ii)
		
	  
for ai in ais:
	r += ai ^ x
print r
Buggy python submission (verdict: Runtime Error):
"""
8
4 23 75 0 23 96 50 100
"""

n = int(raw_input())
ais = map(int, raw_input().split(' '))

def f(ais):
	r = [0]
	for i in range(len(ais)):
		## looking for max
		if len(r) % 2:	
			if (ais[i-1] if i-1 >= 0 else 0) <= ais[i] > (ais[i+1] if i+1 < len(ais) else 0): 
				r.append(ais[i])
		else:
		## looking for min
			if (ais[i-1] if i-1 >= 0 else 0) >= ais[i] < (ais[i+1] if i+1 < len(ais) else 1000): 
				r.append(ais[i])

	t = 0
	for i in range(0,len(r),2):
		if i + 1 < len(r):
			u,v = r[i],r[i+1]
			t += v-u
	
	return t if len(ais) > 1 else ais[0]
print f(ais)

Fixed submission:
a,b,c = map(int, raw_input().split(' '))
print (a*b) >> 1
Buggy python submission (verdict: Runtime Error):
3
4980
7980
6980
n = raw_input()
prices = [ int(raw_input()) for _ in range(n)] #.split(' '))
prices.sort()
print sum(prices) - prices[-1] /2

Fixed submission:

n = int(raw_input())
prices = [ int(raw_input()) for _ in range(n)] #.split(' '))
prices.sort()
print sum(prices[:-1]) + prices[-1] /2
Buggy python submission (verdict: Runtime Error):
import collections
n,k = map(int, raw_input().split(' '))
heigths = [int(raw_input()) for _ in range(n)]
heigths.sort()
q = collections.deque([])
r =  float('inf') 
for h in heights:
	q.append(h)
	if len(q) == k+1: q.popleft()
	if k and len(q) == k:
		r =min(r, q[-1] - q[0])
print r if k else 0

Fixed submission:
import collections
n,k = map(int, raw_input().split(' '))
heights = [int(raw_input()) for _ in range(n)]
heights.sort()
q = collections.deque([])
r =  float('inf') 
for h in heights:
	q.append(h)
	if len(q) == k + 1: q.popleft()
	if k and len(q) == k:
		r =min(r, q[-1] - q[0])
print r if k else 0

Buggy python submission (verdict: Runtime Error):

import collections
n,k = map(int, raw_input().split(' '))
heigths = [int(raw_input()) for _ in range(n)]
heigths.sort()
q = collections.deque([])
r =  float('inf') 
for h in heights:
	q.append(h)
	if len(q) == k+1: q.popleft()
	if len(q) == k:
r =min(r, q[-1] - q[0])
print r

Fixed submission:
import collections
n,k = map(int, raw_input().split(' '))
heights = [int(raw_input()) for _ in range(n)]
heights.sort()
q = collections.deque([])
r =  float('inf') 
for h in heights:
	q.append(h)
	if len(q) == k + 1: q.popleft()
	if k and len(q) == k:
		r =min(r, q[-1] - q[0])
print r if k else 0
Buggy python submission (verdict: Runtime Error):
s= raw_input()
m = +float('inf')
for i in range(len(s)):
	if len(s[i:i+3]) == 3:
		m = min(abs(s[i:i+3] - 753), m)
	if len(s[i:i+4]) ==4:
		
		m = min(abs(s[i:i+4] - 753), m)
print m

Fixed submission:

s= raw_input()
m = +float('inf')
for i in range(len(s)):
	if len(s[i:i + 3]) == 3: 
		m = min(abs(int(s[i:i + 3]) - 753), m)
print m

Buggy python submission (verdict: Runtime Error):
s= raw_input()
m = +float('inf')
for i in range(len(s)):
	if len(s[i:i+3]) == 3:
		m = min(abs(s[i:i+3] - 753), m)
	if len(s[i:i+4]) ==4:
		
		m = min(abs(s[i:i+4] - 753), m)
print m

Fixed submission:

s= raw_input()
m = +float('inf')
for i in range(len(s)):
	if len(s[i:i + 3]) == 3: 
		m = min(abs(int(s[i:i + 3]) - 753), m)
print m
Buggy python submission (verdict: Runtime Error):
n = int(raw_input())
a = int(raw_input())
b = int(raw_input())
if n == 1:
	print 'Hello World'
elif n == 2:
	print a + b

Fixed submission:
n = int(raw_input())
if n == 1: print 'Hello World'
elif n == 2: print int(raw_input())+int(raw_input())

Buggy python submission (verdict: Runtime Error):
n = int(raw_input())
a = int(raw_input())
b = int(raw_input())
if n == 1:
	print 'Hello World'
elif n == 2:
	print a + b

Fixed submission:
n = int(raw_input())
if n == 1: print 'Hello World'
elif n == 2: print int(raw_input())+int(raw_input())
Buggy python submission (verdict: Runtime Error):
n,m = map(int,raw_input().split())

def f(n,m):

	for d in range(2, m)[::-1]:
		if m % d == 0:
			if m / d >= n:
				return d		
				break

	return 1

print f(n,m)

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

def f(n,m):
	if n == 1:
		return m
	divisors = []
	for d in range(2, int(m ** 0.5)+1)[::-1]:
		if m % d == 0:
			divisors.append(d)
			if d != m/d: divisors.append(m/d)
	divisors.sort(key = lambda x:-x)
	for d in divisors:
		if m/d >= n:
			return d

	return 1

print f(n,m)
Buggy python submission (verdict: Runtime Error):

n = int(raw_input())
h = {}
un = set()
for i,b in enumerate(map(int,raw_input().split())):

	for a in un:
		if a != b:
			h[(a,b)] = (h[(b,a)] if (b,a) in h else 1) + 1
	un.add(b)

print n - max(h.values())

Fixed submission:
import collections
n = int(raw_input())
ais = map(int, raw_input().split(' '))
cco = collections.Counter([ais[i] for i in range(len(ais)) if i % 2])
cce = collections.Counter([ais[i] for i in range(len(ais)) if i % 2 == 0])
cce = [(cce[k],k) for k in cce]
cce.sort(key = lambda x:-x[0])

t = n/2
if cce:
	m = t + t- cce[0][0]
else:
	m = 2*t
for colori in cco:
	for v,colorj in cce:
		if colorj != colori:
			m = min(m,t - cco[colori] + t - v)
			break

print m
Buggy python submission (verdict: Runtime Error):
s = sum(map(int, raw_input().split(' ')))
print sum(s) + 10 *max(s)

Fixed submission:
a,b,c = map(int, raw_input().split(' '))
print max(10*a + b+c, a+10*b + c, a+b + 10*c)
Buggy python submission (verdict: Runtime Error):
s,t = raw_input(), raw_input()
def f(s,t):
	cc = {}
	cr = {}
	for u,v in zip(s,t):
		if u in cc:
			if cc[u] != v: return False
		if v in cr:
			if cc[v] != u: return False
		
		cc[u] = v
		cr[v] = u
	return True
print 'Yes' if f(s,t) else 'No'

Fixed submission:
s,t = raw_input(), raw_input()
def f(s,t):
	cc = {}
	cr = {}
	for u,v in zip(s,t):
		if u in cc:
			if cc[u] != v: return False
		if v in cr:
			if cr[v] != u: return False
		
		cc[u] = v
		cr[v] = u
	return True
print 'Yes' if f(s,t) else 'No'
Buggy python submission (verdict: Runtime Error):
def f(words):
	seen = set([words[0]])
	p = words[0]
	for w in words[1:]:
		if w in seen or p[-1] != w[0]: return False
		p = w
		seen.add(w)
	return True

print 'Yes' if f([raw_input() for _ in range(int(raw_input())]) else 'No'


Fixed submission:
def f(words):
	seen = set([words[0]])
	p = words[0]
	for w in words[1:]:
		if w in seen or p[-1] != w[0]: return False
		p = w
		seen.add(w)
	return True

print 'Yes' if f([raw_input() for _ in range(int(raw_input()))]) else 'No'

Buggy python submission (verdict: Runtime Error):
def f(words):
	seen = set([words[0]])
	p = words[0]
	for w in words[1:]:
		if w in seen or p[-1] != w[0]: return False
		p = w
		seen.add(w)
		return True

print 'Yes' if f([raw_input() for _ in range(int(raw_input())]) else 'No'


Fixed submission:
def f(words):
	seen = set([words[0]])
	p = words[0]
	for w in words[1:]:
		if w in seen or p[-1] != w[0]: return False
		p = w
		seen.add(w)
	return True

print 'Yes' if f([raw_input() for _ in range(int(raw_input()))]) else 'No'

Buggy python submission (verdict: Runtime Error):
n = int(raw_input())
def f(words):
seen = set([words[0]])
p = words[0]
for w in words[1:]:
	if w in seen or p[-1] != w[0]: return False
	p = w
	seen.add(w)
	return True

print 'Yes' if f(raw_input().split()) else 'No'


Fixed submission:
def f(words):
	seen = set([words[0]])
	p = words[0]
	for w in words[1:]:
		if w in seen or p[-1] != w[0]: return False
		p = w
		seen.add(w)
	return True

print 'Yes' if f([raw_input() for _ in range(int(raw_input()))]) else 'No'
Buggy python submission (verdict: Runtime Error):
import collections
n = int(raw_input())
count = 0
cc= collections.Counter()
for i in range(1,n + 1):
	while(j <= n):
		cc[j] += 1
		j +=i
	if i % 2 and cc[i] == 8 :
		count +=1
print count

Fixed submission:
import collections
n = int(raw_input())
count = 0
cc= collections.Counter()
for i in range(1,n + 1):
	j = i
	while(j <= n):
		cc[j] += 1
		j +=i
	if i % 2 and cc[i] == 8 :
		count +=1
print count

Buggy python submission (verdict: Runtime Error):
n = int(raw_input())
count = 0
cc= collections.Counter()
for i in range(1,n + 1):
	while(j <= n):
		cc[j] += 1
		j +=i
	if i % 2 and cc[i] == 8 :
		count +=1
print count

Fixed submission:
import collections
n = int(raw_input())
count = 0
cc= collections.Counter()
for i in range(1,n + 1):
	j = i
	while(j <= n):
		cc[j] += 1
		j +=i
	if i % 2 and cc[i] == 8 :
		count +=1
print count

Buggy python submission (verdict: Runtime Error):
n = int(raw_input())
count = 0
cc= collections.Counter()
for i in range(1,n + 1):
	while(j <= n):
		cc[j] += 1
		j +=i
	if i % 2 and cc[i] == 8 :
		count +=1
print count

Fixed submission:
import collections
n = int(raw_input())
count = 0
cc= collections.Counter()
for i in range(1,n + 1):
	j = i
	while(j <= n):
		cc[j] += 1
		j +=i
	if i % 2 and cc[i] == 8 :
		count +=1
print count
Buggy python submission (verdict: Runtime Error):
import collections
print 'AC' if ( r[0] == 'A' and  collections.Counter(r[2:-1])['C'] == 1 and  all([l in set(['A', 'C']) or l.lower() ==l for l in r ])) else 'WA'

Fixed submission:
"""
1. The initial character of S is an uppercase A.
2. There is exactly one occurrence of C between the third character from the beginning and the second to last character (inclusive).
3. All letters except the A and C mentioned above are lowercase.
"""
import collections
def a(r): return r[0] == 'A'
def b(r): return collections.Counter(r[2:-1])['C'] == 1
def c(r): return all([l in set(['A', 'C']) or l.lower() ==l for l in r ])
def f(r):  return a(r) and b(r) and c(r)

print 'AC' if f(raw_input()) else 'WA'
Buggy python submission (verdict: Runtime Error):
a,b,c,d = map(int, raw_input().split())
print min(a,b) + min(c,d)

Fixed submission:
ais = [int(raw_input()) for jj in range(4)]
print min(ais[:2]) + min(ais[2:])
Buggy python submission (verdict: Runtime Error):
n,s = int(raw_input()),map(int,raw_input().split())
s.sort(key = x:-x)
print sum(s[0:n:2]) - sum(s[1:n:2])

Fixed submission:
n,s = int(raw_input()),map(int,raw_input().split())
s.sort(key = lambda x:-x)
print sum(s[0:n:2]) - sum(s[1:n:2])

Buggy python submission (verdict: Runtime Error):
n,s = int(raw_input()),map(int,raw_input().split())
s.sort(key = x:-x)
print sum(s[1:n:2]) - sum(s[2:n:2])

Fixed submission:
n,s = int(raw_input()),map(int,raw_input().split())
s.sort(key = lambda x:-x)
print sum(s[0:n:2]) - sum(s[1:n:2])
Buggy python submission (verdict: Runtime Error):
a = int(raw_input())
b = int(raw_input())
c = int(raw_input())
x = int(raw_input())

def dfs(x, i, a, b , c):
  	if x < 0:
  		return 0
  	if x == 0:
  		return 1
  	
  	if i == 3:
  		return 1 if x == 0 else 0
  	r = 0
  	m = {0:a,1:b,2:c}
  	v = {0:500,1:100,2:50}

  	for k in range(1, m[i] + 1):
  		r += dfs(x - k * v[i], i+1, a,b,c)
  	return r

print f(x,0,a,b,c)


Fixed submission:
a = int(raw_input())
b = int(raw_input())
c = int(raw_input())
x = int(raw_input())

def dfs(x, i, a, b , c):
  	if x < 0:
  		return 0
  	if x == 0:
  		return 1
  	
  	if i == 3:
  		return 1 if x == 0 else 0
  	r = 0
  	m = {0:a,1:b,2:c}
  	v = {0:500,1:100,2:50}

  	for k in range(0, m[i] + 1):
  		r += dfs(x - k * v[i], i+1, a,b,c)
  	return r

print dfs(x,0,a,b,c)
Buggy python submission (verdict: Runtime Error):
a = int(raw_input())
b = int(raw_input())
c = int(raw_input())
x = int(raw_input())

def dfs(x, i, m, v):
  	if x < 0: return 0
  	if x == 0 or i == 3: 
  		return 1 if x == 0 else 0   	
  	r = 0
  	for k in range(0, m[i] + 1): r += dfs(x - k * v[i], i + 1, m, v)
  	return r
m,v = {0:a,1:b,2:c}, {0:500,1:100,2:50}
print dfs(x,0,m,v)


Fixed submission:
n,mat = raw_input(),[ map(int,raw_input().split()) for i in range(2)]
def f(mat,i,j):
	if i<0 or j <0:
		return -float('inf')
	if i == 0 and j == 0:
		return mat[i][j] 
	return mat[i][j] + max(f(mat,i-1,j),f(mat,i,j-1))
print f(mat,1,len(mat[0])-1)

Buggy python submission (verdict: Runtime Error):
a = int(raw_input())
b = int(raw_input())
c = int(raw_input())
x = int(raw_input())

def dfs(x, i, m, v):
  	if x < 0: return 0
  	if x == 0: return 1
  	if i == 2: return 1 if x % 50 else 0  	
  	r = 0
  	for k in range(0, m[i] + 1): r += dfs(x - k * v[i], i + 1, m, v)
  	return r
m,v = {0:a,1:b,2:c}, {0:500,1:100,2:50}
print dfs(x,0,m,v)


Fixed submission:
n,mat = raw_input(),[ map(int,raw_input().split()) for i in range(2)]
def f(mat,i,j):
	if i<0 or j <0:
		return -float('inf')
	if i == 0 and j == 0:
		return mat[i][j] 
	return mat[i][j] + max(f(mat,i-1,j),f(mat,i,j-1))
print f(mat,1,len(mat[0])-1)

Buggy python submission (verdict: Runtime Error):
a = int(raw_input())
b = int(raw_input())
c = int(raw_input())
x = int(raw_input())

def dfs(x, i, m, v):
  	if x < 0: return 0
  	if x == 0: return 1
  	if i == 2: return 1 if x % 50 else 0  	
  	r = 0
  	for k in range(0, m[i] + 1):
  		r += dfs(x - k * v[i], i+1, m,v)
  	return r
m,v = {0:a,1:b,2:c}, {0:500,1:100,2:50}
print dfs(x,0,m,v)


Fixed submission:
n,mat = raw_input(),[ map(int,raw_input().split()) for i in range(2)]
def f(mat,i,j):
	if i<0 or j <0:
		return -float('inf')
	if i == 0 and j == 0:
		return mat[i][j] 
	return mat[i][j] + max(f(mat,i-1,j),f(mat,i,j-1))
print f(mat,1,len(mat[0])-1)

Buggy python submission (verdict: Runtime Error):
a = int(raw_input())
b = int(raw_input())
c = int(raw_input())
x = int(raw_input())

def dfs(x, i, m, v):
  	if x < 0: return 0
  	if x == 0: return 1
  	if i == 2: return 1 if x % 50 else 0  	
  	r = 0
  	for k in range(0, m[i] + 1):
  		r += dfs(x - k * v[i], i+1, a,b,c)
  	return r
m,v = {0:a,1:b,2:c}, {0:500,1:100,2:50}
print dfs(x,0,m,v)


Fixed submission:
n,mat = raw_input(),[ map(int,raw_input().split()) for i in range(2)]
def f(mat,i,j):
	if i<0 or j <0:
		return -float('inf')
	if i == 0 and j == 0:
		return mat[i][j] 
	return mat[i][j] + max(f(mat,i-1,j),f(mat,i,j-1))
print f(mat,1,len(mat[0])-1)

Buggy python submission (verdict: Runtime Error):

n = raw_input()
mat =[ map(int,raw_input()) for i in range(2)]
def f(mat,i,j):
	if i<0 or j <0:
		return -float('inf')
	return mat[i][j] + max(f(mat,i-1,j),f(mat,i,j-1))
print f(mat,1,len(mat[0])-1)

Fixed submission:
n,mat = raw_input(),[ map(int,raw_input().split()) for i in range(2)]
def f(mat,i,j):
	if i<0 or j <0:
		return -float('inf')
	if i == 0 and j == 0:
		return mat[i][j] 
	return mat[i][j] + max(f(mat,i-1,j),f(mat,i,j-1))
print f(mat,1,len(mat[0])-1)
Buggy python submission (verdict: Runtime Error):
a,b = int(raw_input()) % 2,int(raw_input()) % 2
print 'Odd' if a == b else 'Even'

Fixed submission:
a,b = map(lambda x:int(x) % 2, raw_input().split()) 
print 'Odd' if (a == b == 1) else 'Even'
Buggy python submission (verdict: Runtime Error):
prev = (0,0)
pt = t
b = True

def f(a,b): return abs(b[0]- a[0]) + abs(b[1] - a[1])
for _ in range(int(raw_input())):
	t,x,y  = map(int, raw_input().split())
	if (t - pt) < f((x,y), prev):
		b = False
		break 
	prev,pt = (x,y),t

print 'Yes' if b else 'No'

Fixed submission:
prev,pt = (0,0),0
b = True
def f(a,b): return abs(b[0]- a[0]) + abs(b[1] - a[1])
for _ in range(int(raw_input())):
	t,x,y  = map(int, raw_input().split())
	if (t - pt) < f((x,y), prev) :
		b = False
		break 

	if ((t - pt) - f((x,y), prev)) % 2:
		b = False
		break
	prev,pt = (x,y),t

print 'Yes' if b else 'No'
Buggy python submission (verdict: Runtime Error):
n,h = map(int ,raw_input().split())
ais = [map(int, raw_input().split()) for _ in range(n)]
mem = {}
def dfs(i, ais, h):
	if i == len(ais) or h <= 0:
		return 0 if h <= 0 else +float('inf')
	if (i,h) not in mem:
		mem[(i,h)] = min(dfs(i+1, ais, h - ais[i][1]) + 1,
		dfs(i, ais, h - ais[i][0]) + 1,
		dfs(i+1, ais, h),)
	return mem[(i,h)]
print dfs(0 , ais, h)

Fixed submission:
import math
n,h = map(int ,raw_input().split())
ais = [map(int, raw_input().split()) for _ in range(n)]
ais.sort(key = lambda x: (-x[1],x[0]))
cumul = 0
r = +float('inf')
m = max(ais)[0]
for i in range(-1,len(ais)):
	if i >= 0:
		cumul += ais[i][1]

	if cumul >= h:
		r = min(r, (i+1))
		break
	else:
		r = min(r, i+1 + math.ceil(abs(h - cumul) /  float(m)))
print int(r)
Buggy python submission (verdict: Runtime Error):
n = int(raw_input())
ais = map(int, raw_input().split())
c = 0
while(True):
  	if all([ai%2==0 for ai in ais ]):
	  	ais = [ai/2 for ai in ais]	
        c +=1
	else:
      	break
print c

Fixed submission:
n = int(raw_input())
ais = map(int, raw_input().split())
c = 0
while(all([(ai % 2 ==0) for ai in ais ])):
	ais = [ai/2 for ai in ais]	
	c +=1
print c
Buggy python submission (verdict: Runtime Error):

def f(n,ais):
	ma,mi = max(ais), min(ais)
	res = []
	if ma + mi > 0:
		j = [j for j in range(len(ais)) if ais[j] == ma][0]
		for i in range(len(ais)):
			if ais[i] != ma:
				ais[i] += ais[j]
				res.append([j+1,i+1])

				a >b
		for i in range(1,len(ais)):
			if ais[i-1] > ais[i]:
				ais[i] += ais[i-1]
				res.append([i-1+1, i+1])
	else:
		j = [j for j in range(len(ais)) if ais[j] == mi][0]
		for i in range(len(ais)):
			if ais[i] != mi:
				ais[i] += ais[j]
				res.append([j+1, i+1])
		for i in range(len(ais)-1, 0, -1):
			if not(ais[i - 1] <= ais[i ]):
				ais[i-1] += ais[i]
				res.append([i+1, i-1+1])
	print len(res)
	for u,v in res:
		print u,v
f(int(raw_input()),map(int, raw_input().split()))


Fixed submission:

def f(n,ais):
	ma,mi = max(ais), min(ais)
	res = []
	if ma + mi > 0:
		j = [j for j in range(len(ais)) if ais[j] == ma][0]
		for i in range(len(ais)):
			if ais[i] != ma:
				ais[i] += ais[j]
				res.append([j+1,i+1])

		for i in range(1,len(ais)):
			if ais[i-1] > ais[i]:
				ais[i] += ais[i-1]
				res.append([i-1+1, i+1])
	else:
		j = [j for j in range(len(ais)) if ais[j] == mi][0]
		for i in range(len(ais)):
			if ais[i] != mi:
				ais[i] += ais[j]
				res.append([j+1, i+1])
		for i in range(len(ais)-1, 0, -1):
			if not(ais[i - 1] <= ais[i ]):
				ais[i-1] += ais[i]
				res.append([i+1, i-1+1])
	print len(res)
	for u,v in res:
		print u,v
f(int(raw_input()),map(int, raw_input().split()))
Buggy python submission (verdict: Runtime Error):
import collections
n,q = int(raw_input()) +1, collections.deque()
while(n):
	q.append(sum(list(q)) if len(q) < 2 else (len(q) +1))
	if len(q) == 3: q.popleft()
    n -=1
print q[-1]


Fixed submission:
import collections
n,q = int(raw_input()) + 1, collections.deque()
while(n):
	q.append(sum(list(q)) if len(q) == 2 else (2  - len(q)))
	if len(q) == 3: 
		q.popleft()

	n -=1
print q[-1]
Buggy python submission (verdict: Time Limit Exceeded):
n = int(raw_input())
ais = map(int, raw_input().split())
bis = map(int, raw_input().split())
cis = map(int, raw_input().split())


count = 0
ais.sort()
bis.sort()
cis.sort()

for a in ais:
	i,j = 0,0
	while(i < len(bis) and not(bis[i] > a)): i+=1
	while(i < len(bis)):
		while(j < len(cis) and not(cis[j] > bis[i])): j +=1
		if j < len(cis):
			count +=  ( n - j)
		i+=1
print count

Fixed submission:
n = int(raw_input())
ais = map(int, raw_input().split())
bis = map(int, raw_input().split())
cis = map(int, raw_input().split())


count = 0
ais.sort()
bis.sort()
cis.sort()

i,j = 0,0
for b in bis:
	while(i < len(ais) and ais[i] < b):
		i += 1
	while(j < len(cis) and cis[j] <= b):
		j += 1
	count += i * (n - j)
print count
Buggy python submission (verdict: Runtime Error):
a , av =  map(int, raw_input().split())
print 2*av - a

Fixed submission:
a,av =  int(raw_input()), int(raw_input())
print 2*av - a
Buggy python submission (verdict: Runtime Error):
def f(current, n,k):
	if n == 0:
		return current
    return min(f(2*current, n- 1,k), f(+k + current, n- 1, k)) 
print f(1,int(raw_input()), int(raw_input()))

Fixed submission:
def f(current, n,k):
	if n == 0:
		return current
	return min(f(2*current, n- 1,k), f(+k + current, n- 1, k)) 
print f(1,int(raw_input()), int(raw_input()))
Buggy python submission (verdict: Runtime Error):

for _ in range(int(raw_input())):
	v = int(raw_input())
	cc[v] += 1
	if cc[v] == 2:
		cc[v] = 0
s = 0
for k in cc:
	if cc[k] == 1:
		s +=1
print s

Fixed submission:
import collections
cc = collections.Counter()
for _ in range(int(raw_input())):
	v = int(raw_input())
	cc[v] += 1
	if cc[v] == 2:
		cc[v] = 0
s = 0
for k in cc:
	if cc[k] == 1:
		s +=1
print s
Buggy python submission (verdict: Runtime Error):
import collections
n,cc = raw_input(),collections.Counter(map(int, raw_input().split()))
print max([cc[k] + cc[k+1] + cc[k-1] for k in cc] or [0)


Fixed submission:
import collections
n,cc = raw_input(),collections.Counter(map(int, raw_input().split()))
print max([cc[k] + cc[k+1] + cc[k-1] for k in cc] or [0])

Buggy python submission (verdict: Runtime Error):
n,cc = raw_input(),collections.Counter(map(int, raw_input().split()))
print max([cc[k] + cc[k+1] + cc[k-1] for k in cc] or [0)


Fixed submission:
import collections
n,cc = raw_input(),collections.Counter(map(int, raw_input().split()))
print max([cc[k] + cc[k+1] + cc[k-1] for k in cc] or [0])
Buggy python submission (verdict: Runtime Error):
n = int(raw_input())
h = {}
for i,a in enumerate(map(int, raw_input())):
	i += 1
	if a != i:
		h[a] = i

def get(u, parent):
	if parent[u] != u:
		parent[u] = get(parent[u], parent)
	return parent[u]

parent = {u:u for u in h}
sizes = {u:1 for u in h}
for u in h:
	v = h[u]
	pu,pv = get(u, parent), get(v, parent)
	if pu != pv:
		parent[pv] = pu
		sizes[pu] += sizes[pv]
print sum([sizes[u]-1 for u in parent if parent[u] == u] or [0])


Fixed submission:
n = int(raw_input())
count = 0
res = 0
ais = map(int , raw_input().split())

for i,a in enumerate(ais):
	
	if a == i +1:
		count += 1
	else:
		#flush the count
		res += (count + 1)/2# + 1
		count = 0

if count: res +=  (count+1)/2 
print res
Buggy python submission (verdict: Runtime Error):
import math
c= 0
while(n % 2 == 0):
    n/=2
    c+=1
print c

Fixed submission:
import math
print 2 ** int(math.floor(math.log(int(raw_input()),2)))
Buggy python submission (verdict: Runtime Error):
n = raw_input()
ais = map(int, raw_input())
c = 0
s = sum(ais)
m = +float('inf')
for a in ais:
	c += a
	m = min(m, abs(c - s + c))
print m

Fixed submission:
n = raw_input()
ais = map(int, raw_input().split())
c = 0
s = sum(ais)
m = +float('inf')
for a in ais[:-1]:
	c += a
	m = min(m, abs(c - s + c))
print m
Buggy python submission (verdict: Time Limit Exceeded):
import collections
n,rev,q = int(raw_input()) ,False,collections.deque()

stack = []
for ai in map(int, raw_input().split()):
	stack.append(ai)
	stack = stack[::-1]
print ' '.join(map(str, stack))

Fixed submission:
import collections
n,rev,q = int(raw_input()) ,False,collections.deque()

for ai in map(int, raw_input().split()):
	if rev: q.append(ai)
	else: q.appendleft(ai)
	rev ^= True

print ' '.join(map(str, list(q)[::1 if rev else -1]))
Buggy python submission (verdict: Runtime Error):
ais = [int(raw_input()) for oo in range(raw_input())]#n = raw_input()
seen = set([])
u = 0
while(u!= 1 or u not in seen):
	seen.add(u)
	u = ais[u] - 1

print len(seen) if u == 1 else -1


Fixed submission:
ais = [int(raw_input()) for oo in range(int(raw_input()))]
seen = set([])
u = 0
while((u!= 1) and (u not in seen)):
	seen.add(u)
	u = ais[u] - 1

print len(seen) if u == 1 else -1

Buggy python submission (verdict: Runtime Error):
ais = [int(raw_input()) for oo in range(raw_input())]#n = raw_input()
#for
ais = map(int , raw_input().split())
seen = set([])
u = 0
while(u!= 1 or u not in seen):
	seen.add(u)
    u = ais[u] - 1

print len(seen) if u == 1 else -1

Fixed submission:
ais = [int(raw_input()) for oo in range(int(raw_input()))]
seen = set([])
u = 0
while((u!= 1) and (u not in seen)):
	seen.add(u)
	u = ais[u] - 1

print len(seen) if u == 1 else -1