Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02714 (python)

Fixed submission:
import copy
import collections
def f(s):
    h = {('R','G'): 'B', ('B','G'): 'R', ('R','B'): 'G',('R','G')[::-1]: 'B', ('B','G')[::-1]: 'R', ('R','B')[::-1]: 'G', }
    c = collections.Counter()
    cc = [None] * (len(s)+1)
    cc[-1] = copy.deepcopy(c)
    for jj in range(len(s)-1,-1,-1):
        c[s[jj]]+=1
        cc[jj] = copy.deepcopy(c)


    res = 0
    for i in range(len(s)):
        for j in range(i + 1, len(s)):
            if s[j] != s[i]:
                res += cc[j+1][h[(s[i],s[j])]] 
                
                k = j + (j - i)
                if k < len(s) and s[k] == h[(s[i],s[j])]:
                    res -=1
    return res
raw_input()
print f(raw_input())

Buggy submission (verdict: Runtime Error):
import collections
def f(s):
  h = {('R','G'): 'B', ('B','G'): 'R', ('R','B'): 'G',('R','G')[::-1]: 'B', ('B','G')[::-1]: 'R', ('R','B')[::-1]: 'G', }

  c = collections.Counter()
  cc = [None] * (len(s)+1)
  cc[-1] = c
  for jj in range(len(s)-1,-1,-1):
    c[s[jj]]+=1
    cc[jj] = c
    res = 0
    for i in range(len(s)):
      for j in range(i+1, len(s)):
        if s[j] != s[i]:
          res += cc[j+1][h[(s[i],s[j])]]

  return res
raw_input()
print f(raw_input())

Buggy submission (verdict: Runtime Error):
import collections
def f(s):
  h = {('R','G'): 'B', ('B','G'): 'R', ('R','B'): 'G', }
  for k in h:
    h[k[::-1]] = h[k]
  c = collections.Counter()
  cc = [None] * (len(s)+1)
  cc[-1] = c
  for jj in range(len(s)-1,-1,-1):
    c[s[jj]]+=1
    cc[jj] = c
    res = 0
    for i in range(len(s)):
      for j in range(i+1, len(s)):
        if s[j] != s[i]:
          res += cc[j+1][h[(s[i],s[j])]]

  return res
raw_input()
print f(raw_input())

Buggy submission (verdict: Runtime Error):
import collections
def f(s):
  h = {('R','G'): 'B', ('B','G'): 'R', ('R','B'): 'G', }
  for k in h:
    h[k[::-1]] = h[k]
  c = collections.Counter()
  cc = [None] * (len(s)+1)
  cc[-1] = c
  for jj in range(len(s)-1,-1,-1):
    c[s[jj]]+=1
    cc[jj] = c
    res = 0
    for i in range(len(s)):
      for j in range(i+1, len(s)):
        if s[j] != s[i]:
          res += cc[j+1][h[(s[i],s[j])]]

  return res
raw_input()
print f(raw_input())

Buggy submission (verdict: Runtime Error):
import collections
def f(s):
  	h = {('R','G'): 'B', ('B','G'): 'R', ('R','B'): 'G', }
    for k in h:
      	h[k[::-1]] = h[k]
    c = collections.Counter()
    cc = [None] * (len(s)+1)
    cc[-1] = c
    for jj in range(len(s)-1,-1,-1):
      	c[s[jj]]+=1
        cc[jj] = c
	res = 0
    for i in range(len(s)):
		for j in range(i+1, len(s)):
          	if s[j] != s[i]:
              	res += cc[j+1][h[(s[i],s[j])]]
                
	return res
raw_input()
print f(raw_input())
Problem p02727 (python)

Fixed submission:
import collections
x,y,aa,bb,cc = map(int,raw_input().split(' '))

aas = map(int, raw_input().split(' '))
bbs = map(int, raw_input().split(' '))
ccs = map(int, raw_input().split(' '))

aas.sort(key = lambda x:-x)
bbs.sort(key = lambda x:-x)
ccs.sort(key = lambda x:-x)
aas = aas[:x]
bbs = bbs[:y]

r = (aas + bbs)
r.sort()

i = 0
j = 0
while(j < len(ccs) and i < len(r)):
	if ccs[j] > r[i]:
		r[i] = ccs[j]
		i+=1
	j+=1

print sum(r)

Buggy submission (verdict: Runtime Error):
import collections
x,y,aa,bb,cc = map(int,raw_input().split(' '))

aas = map(int, raw_input().split(' '))
bbs = map(int, raw_input().split(' '))
ccs = map(int, raw_input().split(' '))

aas.sort(key = lambda x:-x)
bbs.sort(key = lambda x:-x)
ccs.sort(key = lambda x:-x)


q1 = collections.deque(aas)
q2 = collections.deque(bbs)
q3 = collections.deque(ccs)

rq1 = collections.deque()
rq2 = collections.deque()
while(q3 and q2 and q1 and len(rq1) < x and len(rq2) < y):
	if q3[0] > max(q1[0], q2[0]):
		if q2[0] >= q1[0]:
			rq1.append(q3.popleft())
		else:
			rq2.append(q3.popleft())
	else:
		if q2[0] >= q1[0]:
			rq2.append(q2.popleft())
		else:
			rq1.append(q1.popleft())

while(len(rq1) < x):
	if q3 and q3[0] > q1[0]:
		rq1.append(q3.popleft())
	else:
		rq1.append(q1.popleft())
while(len(rq2) < y):
	if q3 and q3[0] > q2[0]:
		rq1.append(q3.popleft())
	else:
		rq1.append(q2.popleft())

print sum(rq1) + sum(rq2)
Problem p02741 (python)

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 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'
Problem p02742 (python)

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 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)
Problem p02761 (python)

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 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

Buggy 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
Problem p02797 (python)

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 submission (verdict: Runtime Error):
n,k,s = map(int, raw_input())
r = [s] * k + [s+1] * (n - k)
for a in r:
  print a,
Problem p02812 (python)

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 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
Problem p02813 (python)

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 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))

Buggy 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))

Buggy 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))
Problem p02817 (python)

Fixed submission:
b,a = raw_input().split(' ')
print a + b

Buggy 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
Problem p02887 (python)

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 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

Buggy 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

Buggy 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
Problem p02898 (python)

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 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])
Problem p02910 (python)

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 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'
Problem p02911 (python)

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 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'
Problem p02913 (python)

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 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
Problem p02917 (python)

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 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)
Problem p02918 (python)

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 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

Buggy 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
Problem p02923 (python)

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 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

Buggy 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

Buggy 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

Buggy 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
Problem p02947 (python)

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 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
Problem p02969 (python)

Fixed submission:
print 3 * (int(raw_input()) ** 2 )

Buggy 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])
Problem p02983 (python)

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 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
Problem p03000 (python)

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 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
Problem p03037 (python)

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 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)
Problem p03044 (python)

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 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]

Buggy 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]
Problem p03047 (python)

Fixed submission:
n,k = map(int, raw_input().split())
print n - k +1

Buggy submission (verdict: Runtime Error):
n,k = map(int, raw_input())
print n - k +1
Problem p03080 (python)

Fixed submission:
4
'RRBR'

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

Buggy submission (verdict: Runtime Error):
4
'RRBR'

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

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 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)
Problem p03102 (python)

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 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

Buggy 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
Problem p03103 (python)

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 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
Problem p03106 (python)

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 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]

Buggy 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

Buggy 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
Problem p03110 (python)

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 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

Buggy 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

Buggy 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
Problem p03129 (python)

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

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

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

Buggy submission (verdict: Runtime Error):

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