Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import collections
n,s = int(raw_input()), raw_input()

def f(k, s):	
 	cc,q = collections.Counter(), collections.deque()
	for j in range(k - 1, len(s)):
		q.append(s[j - k + 1:j+1])
		if len(q) == k:
			u = q.popleft()
			cc[u] += 1
		if q[-1] in cc: return True	
	return False
	
lo,hi = 0, n/2
while(lo < hi):
	med = (lo + hi + 1) / 2
	if f(med, s):  lo = med
	else:hi = med - 1

Fixed submission:
import collections
n = int(raw_input())
s = raw_input()

def f(k, s):	
	if k == 0:
		return True
 	cc = collections.Counter()
	q = collections.deque()
	for j in range(k - 1, len(s)):
		q.append(s[j - k + 1:j+1])
		if len(q) == k + 1:
			u = q.popleft()
			cc[u] += 1
		if s[j- k+1:j+1] in cc:
			return True	
	return False
lo,hi = 0, n
while(lo < hi):
	med = (lo + hi + 1) / 2
	if f(med, s):
		lo = med
	else:
		hi = med - 1

print lo
Buggy python submission (verdict: Runtime Error):
n = int(raw_input())
b = map(int, raw_input().split(' '))
def f(b):
  n = len(b)+1
  s = 0
  for i in range(n): 
  	s += min(b[i], b[i-1] if i-1>=0 else +float('inf'))
  return s
print f(b)


Fixed submission:

n = int(raw_input())
b = map(int, raw_input().split(' '))
def f(b):
	n = len(b)+1
	s = 0
	for i in range(n):  s += min(b[i] if i < n-1 else +float('inf'), b[i-1] if i-1>=0 else +float('inf'))
	return s
print f(b)
Buggy python submission (verdict: Runtime Error):
n,k = map(int, raw_input().split())
score,d,cd = 0,None,0
for i,l in enumerate(raw_input()):
	if d != l:
		cd +=1
		d = l
	if i and s[i-1] == s[i]:  score += 1


if cd > 2:
	t = min(k,((cd - 2)+1)/2)
	k -= t
	score += 2 * t 
	cd -= 2 * t
if cd == 2 and k:
	score +=1
	cd -= 1
print score

Fixed submission:
n,k = map(int, raw_input().split())
s = raw_input()
cd = 0
d = None
for l in s:
	if d != l:
		cd +=1
		d = l
score = 0
for u,v in zip(s,s[1:]):
	if u == v:
		score +=1

while(k and cd > 1):

	if cd > 2:
		score += 2 
		cd -= 2
	elif cd == 2:
		score +=1
		cd -= 1
	k -=1
print score

Buggy python submission (verdict: Runtime Error):
n,k = map(int, raw_input().split())
s = raw_input()
cd = 0
d = None
for i,l in enumerate(s):
	if d != l:
		cd +=1
		d = l
	if i and s[i-1] == s[i]: score += 1
	

if cd > 2:
	t = min(k,((cd - 2)+1)/2)
	k -= t
	score += 2 * t 
	cd -= 2 * t
if cd == 2 and k:
	score +=1
	cd -= 1
print score

Fixed submission:
n,k = map(int, raw_input().split())
s = raw_input()
cd = 0
d = None
for l in s:
	if d != l:
		cd +=1
		d = l
score = 0
for u,v in zip(s,s[1:]):
	if u == v:
		score +=1

while(k and cd > 1):

	if cd > 2:
		score += 2 
		cd -= 2
	elif cd == 2:
		score +=1
		cd -= 1
	k -=1
print score
Buggy python submission (verdict: Runtime Error):
n = int(raw_input())
his = map(int, raw_input().split(' '))
j,pv,count = 0, +float('inf'),0
while(j < len(his)):
	if pv >= his[j]:
		count +=1
	else:
		count = 1
	m = max(count,m)
	pv = his[j]
	j +=1
print m


Fixed submission:
n = int(raw_input())
his = map(int, raw_input().split(' '))
j = 0
pv = float('inf')
count = 0
m = 0
while(j < len(his)):
	if pv >= his[j]: count +=1
	else: count = 1
	m = max(count-1,m)
	pv = his[j]
	j +=1
print m

Buggy python submission (verdict: Runtime Error):
n = int(raw_input())
his = map(int, raw_input().split(' '))
j,pv,count = 0, +float('inf'),0
while(j < len(his)):
	if pv >= his[j]:
		count +=1
	else:
		count = 1
	m = max(count,m)
	pv = hist[j]
	j +=1
print m

Fixed submission:
n = int(raw_input())
his = map(int, raw_input().split(' '))
j = 0
pv = float('inf')
count = 0
m = 0
while(j < len(his)):
	if pv >= his[j]: count +=1
	else: count = 1
	m = max(count-1,m)
	pv = his[j]
	j +=1
print m

Buggy python submission (verdict: Runtime Error):
n = int(raw_input())
his = map(int, raw_input().split(' '))
j,pv,count = 0, -float('inf'),0
while(j < len(his)):
	if pv >= his[j]:
		count +=1
	else:
		count = 1
	m = max(count,m)
	pv = hist[j]
	j +=1
print m

Fixed submission:
n = int(raw_input())
his = map(int, raw_input().split(' '))
j = 0
pv = float('inf')
count = 0
m = 0
while(j < len(his)):
	if pv >= his[j]: count +=1
	else: count = 1
	m = max(count-1,m)
	pv = his[j]
	j +=1
print m

Buggy python submission (verdict: Runtime Error):
n = int(raw_input())
his = map(int, raw_input().split(' '))
j,pv = 0, -float('inf')
m = 0
while(j < len(his)):
	if pv >= his[j]:
		count +=1
	else:
		count = 1
	m = max(count,m)
	pv = hist[j]
print m

Fixed submission:
n = int(raw_input())
his = map(int, raw_input().split(' '))
j = 0
pv = float('inf')
count = 0
m = 0
while(j < len(his)):
	if pv >= his[j]: count +=1
	else: count = 1
	m = max(count-1,m)
	pv = his[j]
	j +=1
print m
Buggy python submission (verdict: Time Limit Exceeded):
import collections
s = raw_input()
t = raw_input()
i = 0
c = 0
while(True):
	progress = False
	j = 0
	for j in range(len(s)):
		if s[j] == t[i]:
			i+=1
			progress = True
			if i == len(t): break
	if progress is False: break
	if i == len(t): break
	c += 1
print c * len(s) + j + 1 if progress else -1

Fixed submission:
import collections
s = raw_input()
t = raw_input()
sb = s + s
h = {chr(ord('a') + i):-1 for i in range(26)}
dp = []
for j in range(len(sb)-1,-1,-1):
	dp.append({k:h[k] for k in h})
	h[sb[j]] = j
special = h
dp = dp[::-1]
i = -1
j = 0
c = 0
while(j < len(t)):
	ha = dp[i] if i >= 0 else special
	letter = t[j]
	if ha[letter] != -1:
		i = ha[letter]
		j += 1
	else:
		j = -1
		break

	if i >= len(s):
		i %= len(s)
		c+=1

print (c * len(s) + i + 1) if j != -1 else -1
Buggy python submission (verdict: Runtime Error):
n ,res, cc = int(raw_input()),0,collections.Counter()
while(n):
	u =  tuple(sorted(raw_input()))
	res += cc[u]
	n-=1
	cc[u]+=1
print res


Fixed submission:
import collections
n ,res, cc = int(raw_input()),0,collections.Counter()
while(n):
	u =  tuple(sorted(raw_input()))
	res += cc[u]
	n-=1
	cc[u]+=1
print res
Buggy python submission (verdict: Runtime Error):

import collections
n,m = map(int,raw_input().split(' '))
h = [0] * (m+1)
for _ in range(n):
	a,b =  map(int, raw_input().split(' '))
		for d in range(m, -1, -1):
			if d - a >=0: h[d] = max(h[d], h[d-a] + b)

print h[m]


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

elems = [map(int, raw_input().split(' ')) for _ in range(n)]
elems.sort(key = lambda x:x[0])
heap = []

j = 0
cumul = 0
for i in range(1,m+1):

	while(j < len(elems) and elems[j][0] <= i): 
		heapq.heappush(heap,-elems[j][1])
		j+=1
	if heap:
		cumul -= heapq.heappop(heap)

print cumul
Buggy python submission (verdict: Runtime Error):
import collections
import heapq
n = int(raw_input())
ais = [0] + map(int, raw_input().split()) 
#print ais
res = [0 for __ in range(n +1)]
for u in range(n, 0, -1):
	c = u*2
	cumul = 0
	while(c <= n):
		cumul += res[c]
		c += u
	if ais[u] != (cumul % 2): 
		res[u] = 1
s = sum(res)
print s
if s:
	print ' '.join([str(i) for i in range(len(res)) if res[i] == 1])


Fixed submission:
print 3 * (int(raw_input()) ** 2 )
Buggy python submission (verdict: Time Limit Exceeded):
n = int(raw_input())
ais = [int(raw_input()) for _ in range(n)]
tails = []
import bisect
for a in ais:
	if not(tails) or not(tails[0] < a):
		tails = [a] + tails 
	else:
		m = -1
		for ii in range(len(tails)):
			if tails[ii] < a: m = max(ii, m)
		if m != -1:
			tails[m] = a

print len(tails)

Fixed submission:
n = int(raw_input())
ais = [int(raw_input()) for _ in range(n)]
tails = []
import bisect
for a in ais:
	if not(tails) or (tails[-1] >= a):
		tails.append(a)
	else:
		# maintain a decreaing tails
		986643321
		lo,hi = 0, len(tails) - 1
		while(lo<hi):
			med= (lo + hi)/2
			if tails[med] < a:
				hi = med
			else:
				lo = med + 1
		tails[lo] = a
print len(tails)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(raw_input())
ais = [int(raw_input()) for _ in range(n)]
tails = []
import bisect
for a in ais:
	if not(tails):
		tails = [a] + tails 
	else:
		m = -1
		for ii in range(len(tails)):
			if tails[ii] < a: m = max(ii, m)
		if m != -1:
			tails[m] = a
		else:
			tails.append(a)

print len(tails)

Fixed submission:
n = int(raw_input())
ais = [int(raw_input()) for _ in range(n)]
tails = []
import bisect
for a in ais:
	if not(tails) or (tails[-1] >= a):
		tails.append(a)
	else:
		# maintain a decreaing tails
		986643321
		lo,hi = 0, len(tails) - 1
		while(lo<hi):
			med= (lo + hi)/2
			if tails[med] < a:
				hi = med
			else:
				lo = med + 1
		tails[lo] = a
print len(tails)
Buggy python submission (verdict: Runtime Error):
import collections
l,r = map(int, raw_input().split(' '))
cc = collections.Counter([n % 2019 for n in range(l, r+1) ])

m = +float('inf')
for a in cc:
	for b in cc:
		if a!=b or cc[a] > 1:
			m = min(m,(a*b) % 2019)
print m

Fixed submission:
import collections
l,r = map(int, raw_input().split(' '))
cc = collections.Counter([n % 2019 for n in range(l, min(r, l + 2019)+1) ])

m = +float('inf')
for a in cc:
	for b in cc:
		if a!=b or cc[a] > 1:
			m = min(m,(a*b) % 2019)
print m
Buggy python submission (verdict: Runtime Error):
cc = collections.Counter(raw_input())
print 'Yes' if len(cc) == 2 and cc.values() ==[2,2] else 'No'

Fixed submission:
import collections
cc = collections.Counter(raw_input())
print 'Yes' if len(cc) == 2 and cc.values() ==[2,2] else 'No'
Buggy python submission (verdict: Runtime Error):
n,k = map(int, raw_input().split(' '))
ais = map(int, raw_input().split(' '))
count,cur,i = 0,0, 0
while(cur <= x and i < len(ais)):
  count +=1
  cur += ais[i]
  i +=1
print count

Fixed submission:
n,x = map(int, raw_input().split(' '))
ais = map(int, raw_input().split(' '))
count,cur,i = 0,0, 0
res = [cur]
while(i < len(ais)):
	cur += ais[i]
	res.append(cur)
	i +=1

print len([e for e in res if e <= x])
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int, raw_input().split(' '))
keys = set(range(1,n+1))
for _ in range(m):
	a,b = map(int, raw_input().split(' '))
	keys = keys.intersection(set( range(a,b+1)  ))
	if len(keys) == 0: break
print len(keys)


Fixed submission:
n,m = map(int, raw_input().split(' '))
def intersection(A,B):
	a,b  = max(A[0],B[0]), min(A[1],B[1])
	return [a,b] if a <= b else []

r = [1,n+1]
for _ in range(m):
	a,b = map(int, raw_input().split(' '))
	r = intersection(r, [a,b])
	if len(r) == 0: break
print (r[1] - r[0] + 1) if r else 0

Buggy python submission (verdict: Runtime Error):

n,m = map(int, raw_input().split(' '))
keys = set(range(1,n+1))
for _ in range(m):
	a,b = map(int, raw_input().split(' '))
    keys = keys.intersection(set( range(a,b+1)  ))
    if len(keys) == 0:
      break
print len(keys)

Fixed submission:
n,m = map(int, raw_input().split(' '))
def intersection(A,B):
	a,b  = max(A[0],B[0]), min(A[1],B[1])
	return [a,b] if a <= b else []

r = [1,n+1]
for _ in range(m):
	a,b = map(int, raw_input().split(' '))
	r = intersection(r, [a,b])
	if len(r) == 0: break
print (r[1] - r[0] + 1) if r else 0
Buggy python submission (verdict: Runtime Error):
n,m = map(int, raw_input().split(' '))
ais = map(int, raw_input().split(' '))
ops = [map(int,raw_input().split(' ')) for _ in range(m)]
ops.sort(key = lambda x:x[0])

res = 0
mi = -float('inf')
for j in range(n, -1, -1):
	if ops and ops[-1][0] == j:
		mi = max(mi, ops.pop()[1])
	res += max(ais[j], mi)

print res

Fixed submission:
import heapq
n,m = map(int, raw_input().split(' '))
ais = map(int, raw_input().split(' '))
ais.sort()
heap = []
for _ in range(m):
	u,v = map(int,raw_input().split(' ')) 
	heapq.heappush(heap, (-v,u))
res = 0
for j in range(n):
	
	if heap and -heap[0][0] > ais[j]:
		u,v = heapq.heappop(heap)
		v-=1
		res += -u
		if v >= 1: heapq.heappush(heap, (u,v))
	else:
		res += ais[j]
print res
Buggy python submission (verdict: Runtime Error):
print {(0,0):'NA', (0,1): 'YYMM', (1,0): 'MMYY', (1,1):'AMBIGUOUS'}[tuple(map(int,list(tuple([(0<int(s[2*i:2*i+2]) <= 12)	for i in range(2)]))))]

Fixed submission:
def f(s):
  m,y = int(s[:2]), int(s[2:])
  return 0< m <= 12

def g(s):
  y,m = int(s[:2]), int(s[2:])
  return 0< m <= 12
    
s = raw_input()
p,q = f(s), g(s)

if p and q:
  print 'AMBIGUOUS'
elif p and not(q):
  print 'MMYY'
elif q and not(p):
  print 'YYMM'
else:
  print 'NA'

Buggy python submission (verdict: Runtime Error):
def f(s):return tuple([0<int(s[2*i:2*i+2]) <= 12	for i in range(0,2,2)])
		
print {(0,0):'NA', (0,1): 'YYMM', (1,0): 'MMYY', (1,1):'AMBIGUOUS'}[tuple(map(int,list(f(raw_input()))))]

Fixed submission:
def f(s):
  m,y = int(s[:2]), int(s[2:])
  return 0< m <= 12

def g(s):
  y,m = int(s[:2]), int(s[2:])
  return 0< m <= 12
    
s = raw_input()
p,q = f(s), g(s)

if p and q:
  print 'AMBIGUOUS'
elif p and not(q):
  print 'MMYY'
elif q and not(p):
  print 'YYMM'
else:
  print 'NA'

Buggy python submission (verdict: Runtime Error):
def f(s):
  m,y = int(s[:2]), int(s[2:])
  return (0 < m <= 12,0 < y <= 12 )

p,q = map(int,list(f(raw_input()))
print {(0,0):'NA', (0,1): 'YYMM', (1,0): 'MMYY', (1,1):'AMBIGUOUS'}[(p,q)]


Fixed submission:
def f(s):
  m,y = int(s[:2]), int(s[2:])
  return 0< m <= 12

def g(s):
  y,m = int(s[:2]), int(s[2:])
  return 0< m <= 12
    
s = raw_input()
p,q = f(s), g(s)

if p and q:
  print 'AMBIGUOUS'
elif p and not(q):
  print 'MMYY'
elif q and not(p):
  print 'YYMM'
else:
  print 'NA'

Buggy python submission (verdict: Runtime Error):
def f(s):
  m,y = int(s[:2]), int(s[2:])
  return 0< m <= 12:

def g(s):
  y,m = int(s[:2]), int(s[2:])
  return 0< m <= 12:
    
s = raw_input()
p,q = f(s), g(s)

if p and q:
  print 'AMBIGUOUS'
elif p and not(q):
  print 'MMYY'
elif q and not(p):
  print 'YYMM'
else:
  print 'NA'

Fixed submission:
def f(s):
  m,y = int(s[:2]), int(s[2:])
  return 0< m <= 12

def g(s):
  y,m = int(s[:2]), int(s[2:])
  return 0< m <= 12
    
s = raw_input()
p,q = f(s), g(s)

if p and q:
  print 'AMBIGUOUS'
elif p and not(q):
  print 'MMYY'
elif q and not(p):
  print 'YYMM'
else:
  print 'NA'
Buggy python submission (verdict: Runtime Error):
import collections
n = int(raw_input())

adj = collections.defaultdict(list)

for _ in range(n - 1):
	u, v, w = map(int, raw_input().split(' '))
	adj[u].append((v,w))
	adj[v].append((u,w))

q,h = collections.deque([(1,0)]), { 1:0 }
def dfs(u, h, adj):
	for v,w in adj[u]:
		if v not in h:
			h[v] = (1- h[u]) if (w % 2) else h[u]
			dfs(v, h, adj)
dfs(1, h, adj)
for node in range(1, n + 1): 
	print h[node]

Fixed submission:
import collections
n = int(raw_input())

adj = collections.defaultdict(list)

for _ in range(n - 1):
	u, v, w = map(int, raw_input().split(' '))
	adj[u].append((v,w))
	adj[v].append((u,w))


q = collections.deque([(1,0)])
h = { 1:0 }
while(q):
	u,c = q.popleft()
	for v,w in adj[u]:
		if v not in h:
			h[v] = (1- c) if (w % 2) else c
			q.append((v,h[v]))

for node in range(1, n + 1): 
	print h[node]

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

adj = collections.defaultdict(list)

for _ in range(n - 1):
	u, v, w = raw_input().split(' ')
	w = int(w)
	adj[u].append((v,w))
	adj[v].append((u,w))
q = collections.deque([(1,0)])
h = {1:0}
while(q):
	u,c = q.popleft()
	for v,w in adj[u]:
		if v not in h:
			h[v] =  1- c
			q.append((v,1-c))

for node in range(1, n+1): print h[node]

Fixed submission:
import collections
n = int(raw_input())

adj = collections.defaultdict(list)

for _ in range(n - 1):
	u, v, w = map(int, raw_input().split(' '))
	adj[u].append((v,w))
	adj[v].append((u,w))


q = collections.deque([(1,0)])
h = { 1:0 }
while(q):
	u,c = q.popleft()
	for v,w in adj[u]:
		if v not in h:
			h[v] = (1- c) if (w % 2) else c
			q.append((v,h[v]))

for node in range(1, n + 1): 
	print h[node]
Buggy python submission (verdict: Runtime Error):
n,k = map(int, raw_input())
print n - k +1

Fixed submission:
n,k = map(int, raw_input().split())
print n - k +1
Buggy python submission (verdict: Time Limit Exceeded):
import collections

def gcd(u,v):
	if v:
		return gcd(v, u % v)
	else:
		return u

n = int(raw_input())
elems = map(int , raw_input().split(' '))
dpp = [ None ] * len(elems)
dps = [ None ] * len(elems)
for i in range(len(elems)): dpp[i] = reduce(gcd, elems[:i+1])
for i in range(len(elems)): dps[len(elems) - 1 - i] = reduce(gcd, elems[- i - 1:])

r = 0
for i in range(len(elems)):
	u,v = dpp[i-1] if i-1 >= 0 else -1, dps[i+1] if i+1 < len(elems) else -1
	r  = max(r, gcd(u,v) if u != -1 and v != -1 else max(u,v))
print r



Fixed submission:
import collections

def gcd(u,v):
	if v:
		return gcd(v, u % v)
	else:
		return u

n = int(raw_input())
elems = map(int , raw_input().split(' '))
dpp = [ None ] * len(elems)
dps = [ None ] * len(elems)
dpp[0] = elems[0]
for i in range(1,len(elems)): 
	dpp[i] = gcd(elems[i], dpp[i-1])
dps[len(elems) -1]  = elems[-1]
for i in range(len(elems) - 2, -1, -1): 
	dps[i] = gcd(elems[i], dps[i+1])
r = 0
for i in range(len(elems)):
	u,v = dpp[i-1] if i-1 >= 0 else -1, dps[i+1] if i+1 < len(elems) else -1
	r  = max(r, gcd(u,v) if u != -1 and v != -1 else max(u,v))
print r
Buggy python submission (verdict: Runtime Error):
import collections

s = list(raw_input())
count = 0
for i in range(len(s) - 1):
	if s[i] == s[i + 1]:
		s[i] = 1- s[i]
		count +=1
print count


Fixed submission:
import collections

s = map(int,list(raw_input()))

count = 0
for i in range(1,len(s)):
	if s[i] == s[i - 1]:
		s[i] = 1 - s[i]
		count += 1
print count

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

s = raw_input()
count = 0
for i in range(len(s) - 1):
	if s[i] == s[i + 1]:
		s[i] = 1- s[i]
		count +=1
print count


Fixed submission:
import collections

s = map(int,list(raw_input()))

count = 0
for i in range(1,len(s)):
	if s[i] == s[i - 1]:
		s[i] = 1 - s[i]
		count += 1
print count
Buggy python submission (verdict: Runtime Error):
4
'RRBR'

n = raw_input()
import collections
cc = collections.Counter(raw_input())
print 'Yes' if cc['R'] > cc['B']

Fixed submission:
4
'RRBR'

n = raw_input()
import collections
cc = collections.Counter(raw_input())
print 'Yes' if cc['R'] > cc['B'] else 'No'
Buggy python submission (verdict: Runtime Error):
n,q = map(int,raw_input().split(' '))
s = raw_input()
dp = [0] * len(s)
for j in range(len(s)):
	if s[j-1:j+1] == 'AC':dp[j] = 1 + (dp[j-2] if j-2 >= 0 else 0)

for _ in range(q):
	u,v = map(int, raw_input().split(' '))
    print dp[v-1] - (dp[u-2] if u-2 >= 0 else 0)

Fixed submission:
n,q = map(int,raw_input().split(' '))
s = raw_input()
dp = [0] * len(s)
cumul = 0
for j in range(len(s)):
	if s[j - 1:j + 1] == 'AC': cumul +=1
	dp[j] = cumul 
"""
ac ac
 ^
    ^    
"""
for _ in range(q):
	u,v = map(int, raw_input().split(' '))
	u -=1
	v -=1
	print dp[v] - dp[u]
Buggy python submission (verdict: Runtime Error):
n,m,q = map(int, raw_input().split(' ')) #2 3 -10
bis = map(int, raw_input().split(' '))
c = 0
for _ in range(m):
	if sum([u*v for u,v in zip(map(int,raw_input().split(' ')),bis)]) + q > 0:
		c+=1
print c


Fixed submission:
n,m,q = map(int, raw_input().split(' ')) #2 3 -10
bis = map(int, raw_input().split(' '))
c = 0
for _ in range(n):
	if sum([u*v for u,v in zip(map(int,raw_input().split(' ')),bis)]) + q > 0:
		c+=1
print c

Buggy python submission (verdict: Runtime Error):
n,m,q = map(int, raw_input().split(' ')) #2 3 -10
bis = map(int, raw_input().split(' '))
c = 0
for _ in range(m):
	if sum([u*v for u,v in zip(map(int,raw_input().split(' ')),bis)]) + q > 0:
      c+=1
print c


Fixed submission:
n,m,q = map(int, raw_input().split(' ')) #2 3 -10
bis = map(int, raw_input().split(' '))
c = 0
for _ in range(n):
	if sum([u*v for u,v in zip(map(int,raw_input().split(' ')),bis)]) + q > 0:
		c+=1
print c
Buggy python submission (verdict: Runtime Error):

import collections
n,m = map(int,raw_input().split(' '))

costs = [map(int, raw_input().split(' ')) for _ in range(n)]
costs.sort(key = lambda x:-x[0])
q = collections.deque(costs)
while(m):
	u,v = q.popleft()
	t = min(v,m)
	m -=t
	r += t * u
print r

Fixed submission:

import collections
n,m = map(int,raw_input().split(' '))

costs = [map(int, raw_input().split(' ')) for _ in range(n)]
costs.sort(key = lambda x:-x[0])
q = collections.deque(costs)
r = 0
while(m):
	u,v = q.pop()
	t = min(v,m)
	m -=t
	r += t * u
print r
Buggy python submission (verdict: Runtime Error):
def f(a):
	r = []
	for d in range(1,int(a ** 0.5) + 1):
		r.append(d)
        if d * d != a:
	        r.append(a/d)
	return r
a,b,k = map(int, raw_input().split(' '))
r = []
for d in f(a):
	if d in f(b):
      	r.append(d)
print r[-k]

   


Fixed submission:
def f(a):
	r = []
	for d in range(1,int(a ** 0.5) + 1):
		if a % d == 0:
			r.append(d)	
			if d * d != a: r.append(a/d)
	return r if r else [1]
a,b,k = map(int, raw_input().split(' '))
r = []
for d in f(a):
	if d in f(b):
		r.append(d)

r.sort()

print r[-k]

Buggy python submission (verdict: Runtime Error):
def f(a):
	r = []
	for d in range(1,int(a ** 0.5) + 1):
		r.append(d)
        if d * d != a:
	        r.append(a/d)
	return r
a,b = map(int, raw_input().split(' '))
r = 1
for d in f(a):
	if d in f(b):
      	r = max(r, d)#1
print r

   


Fixed submission:
def f(a):
	r = []
	for d in range(1,int(a ** 0.5) + 1):
		if a % d == 0:
			r.append(d)	
			if d * d != a: r.append(a/d)
	return r if r else [1]
a,b,k = map(int, raw_input().split(' '))
r = []
for d in f(a):
	if d in f(b):
		r.append(d)

r.sort()

print r[-k]

Buggy python submission (verdict: Runtime Error):

def f(a):
	r = []
	for d in range(1,int(a ** 0.5) + 1):
		r.append(d)
        if d * d != a:
	        r.append(a/d)
	return r
a,b = map(int, raw_input().split(' '))
r = 1
for d in f(a):
	if d in f(b):
      	r = max(r, d)#1
print r

   

Fixed submission:
def f(a):
	r = []
	for d in range(1,int(a ** 0.5) + 1):
		if a % d == 0:
			r.append(d)	
			if d * d != a: r.append(a/d)
	return r if r else [1]
a,b,k = map(int, raw_input().split(' '))
r = []
for d in f(a):
	if d in f(b):
		r.append(d)

r.sort()

print r[-k]
Buggy python submission (verdict: Runtime Error):
n = int(raw_input())
q= 0 
for _ in range(n):
  	u,v = raw_input().split(' ')
    u = float(u)
    h = {'BTC':380000.0, 'JPY':1.0}
    q += u * h[v]
print q

Fixed submission:
n = int(raw_input())
q= 0 
for _ in range(n):
	u,v = raw_input().split(' ')
	u = float(u)
	h = {'BTC':380000.0, 'JPY':1.0}
	q += u * h[v]
print q

Buggy python submission (verdict: Runtime Error):
n = int(raw_input())
q= 0 
for _ in range(n):
  	u,v = raw_input().split(' ')
    u = int(u)
    h = {'BTC':380000.0, 'JPY':1.0}
    q += u * h[v]
print q

Fixed submission:
n = int(raw_input())
q= 0 
for _ in range(n):
	u,v = raw_input().split(' ')
	u = float(u)
	h = {'BTC':380000.0, 'JPY':1.0}
	q += u * h[v]
print q

Buggy python submission (verdict: Runtime Error):
n = int(raw_input())
q= 0 
for _ in range(n):
  	u,v = raw_input().split(' ')
    u = int(u)
    h = {'BTC':380000.0, 'JPY':1.0}
    q += u * h[v]
print q

Fixed submission:
n = int(raw_input())
q= 0 
for _ in range(n):
	u,v = raw_input().split(' ')
	u = float(u)
	h = {'BTC':380000.0, 'JPY':1.0}
	q += u * h[v]
print q
Buggy python submission (verdict: Time Limit Exceeded):
n = int(raw_input())
ais = map(int, raw_input().split())
def gcd(a,b):
	return gcd(b, a % b ) if b else a
m = min(ais)
for a in ais:
	for b in ais:
		a,b = min(a,b), max(a,b)
		if b% a:
			m = min(m, gcd(a,b))
print m

#6 = 3 * 2 + 

Fixed submission:
n = int(raw_input())
ais = map(int, raw_input().split())
def gcd(a,b):
	return gcd(b, a % b ) if b else a
print reduce(gcd, ais)
Buggy python submission (verdict: Runtime Error):
n,k = map(int, raw_input())
print 'YES' if (n+1)/2 >= k else 'NO'




Fixed submission:
n,k = map(int, raw_input().split())
print 'YES' if (n+1)/2 >= k else 'NO'
Buggy python submission (verdict: Runtime Error):

n = raw_input()
ais = map(int, raw_input())
print 'Yes' if sum(ais)>2*max(ais) else 'No'

Fixed submission:
n = raw_input()
ais = map(int, raw_input().split(' '))
print 'Yes' if sum(ais)>2*max(ais) else 'No'