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

Fixed submission:
import itertools

N,M,X = map(int,input().split())
c = []
d = [0]*(M+1)
e = []
for _ in range(N):
  c.append(list(map(int,input().split())))
for r in range(1,N+1):
  for x in itertools.combinations(c,r):
    for y in range(len(x)):
      for z in range(M+1):
        d[z] += x[y][z]
    for z in range(1,M+1):
      if d[z]<X:
        d = [0]*(M+1)
        break
      elif z == M:
        e.append(d[0])
        d = [0]*(M+1)
if len(e)>0:
  print(min(e))
else:
  print(-1)

Buggy submission (verdict: Runtime Error):
import itertools

N,M,X = map(int,input().split())
c = []
d = [0]*4
e = []
for _ in range(N):
  c.append(list(map(int,input().split())))
for r in range(1,N+1):
  for x in itertools.combinations(c,r):
    for y in range(len(x)):
      d[0] += x[y][0]
      d[1] += x[y][1]
      d[2] += x[y][2]
      d[3] += x[y][3]
    if d[1] < X or d[2] < X or d[3] < X:
      d = [0]*4
    else:
      e.append(d[0])
      d = [0]*4
if len(e)>0:
  print(min(e))
else:
  print(-1)
Problem p02684 (python)

Fixed submission:
n,k = map(int,input().split())
A = list(map(int,input().split()))
sub = [0]*n
city = 0
all = []
roop = []
while sub[city] != 2:
  if sub[city] == 0:
    all.append(city+1)
  else:
    roop.append(city+1)
  sub[city] += 1
  city = A[city] -1
if len(all) > k:
  print(all[k])
else:
  print(roop[(k-(len(all)-len(roop)))%len(roop)])

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
A = list(map(int,input().split()))
sub = [0]*n
city = 0
all = []
roop = []
while sub[city] != 2:
  if sub[city] == 0:
    all.append(city+1)
  else:
    roop.append(city+1)
  sub[city] += 1
  city = A[city] -1
if len(roop)<k:
  print(roop[(k-(len(all)-len(roop)))%len(roop)])
else:
  print(all[k])
Problem p02690 (python)

Fixed submission:
X = int(input())
for a in range(-120,120):
  for b in range(-120,120):
    if a**5 - b**5 == X:
      print(a,b)
      exit(0)

Buggy submission (verdict: Runtime Error):
X = int(input())
for a in range(-120,120):
  for b in range(-120,120):
    if a**5 - b**5 == X:
      print(A,B)
      exit(0)
Problem p02696 (python)

Fixed submission:
A,B,N = map(int,input().split())
def floor(x):
  return int(x//1)
list = []
if N >= B:
    list.append(floor((A*(B-1))/B)-(A*floor((B-1)/B)))
else:
    list.append(floor((A*N)/B)-(A*floor(N/B)))
print(max(list))

Buggy submission (verdict: Runtime Error):
A,B,N = map(int,input().split())
def floor(x):
  return (x//1)
list = []
for x in range(N+1):
  if x % B != 0:
    list.append(floor((A*x)/B)-(A*floor(x/B)))
print(int(max(list)))
Problem p02719 (python)

Fixed submission:
n,k = map(int,input().split())
s = n % k
list = [s]
for _ in range(s):
  if abs(s-k) in list:
    break
  elif abs(s-k)<s:
    list.append(abs(s-k))
print(min(list))

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
s = min(n % k,k % n)
t = s
for _ in range(t):
  if abs(s-k)<s:
    s = abs(s-k)
print(s)
Problem p02761 (python)

Fixed submission:
N,M = map(int, input().split())
ans = 0
S = [""]*N
for _ in range(M):
  s, c = map(int,input().split())
  if S[s-1] == "" or S[s-1] == c:
    S[s-1] = c
  elif S[s-1] != "" and S[s-1] != c:
    print(-1)
    exit(0)
if N != 1:
  if S[0] == "":
    S[0] = 1
  if S[0] == 0:
    print(-1)
    exit(0)
  for i in range(1,N):
    if S[i] == "":
      S[i] = 0
elif N == 1:
  if S[0] == "":
    S[0] = 0
print(''.join(map(str,S)))

Buggy submission (verdict: Runtime Error):
N,M = map(int, input().split())
ans = 0
S = [""]*N
for _ in range(M):
  s, c = map(int,input().split())
  else:
    if S[s-1] == "" or S[s-1] == c:
      S[s-1] = c
    elif S[s-1] != "" and S[s-1] != c:
      print(-1)
      exit(0)
if N == 3:
  if S[0] == "":
    S[0] = 1
  if S[0] = 0:
    print(-1)
    exit(0)
  if S[1] == "":
    S[1] = 0
  if S[2] == "":
    S[2] = 0
  print(S[0],end="")
  print(S[1],end="")
  print(S[2])
elif N == 2:
  if S[0] == "":
    S[0] = 1
  if S[0] == 0:
    print(-1)
    exit(0)
  if S[1] == "":
    S[1] = 0
  print(S[0],end="")
  print(S[1],end="")
elif N == 1:
  if S[0] == "":
    print(0)

Buggy submission (verdict: Runtime Error):
N,M = map(int, input().split())
ans = 0
c1 = []
c2 = []
c3 = []
for _ in range(M):
  s, c = map(int,input().split())
  if s == 1 and c == 0:
    print(-1)
      exit(0)
  if N == 1:
    elif not c in c1:
      ans += c
      c1.append(c)
      if len(c1) > 1:
        print(-1)
        exit(0)
  if N == 2:
    elif s == 1 and not c in c2:
      ans += 10*c
      c2.append(c)
      if len(c2) > 1:
        print(-1)
        exit(0)
    elif s == 2 and not c in c3:
      ans += c
      c3.append(c)
      if len(c3) > 1:
        print(-1)
        exit(0)
  if N == 3:
    elif s == 1 and not c in c1:
      ans += 100*c
      c1.append(c)
      if len(c1) > 1:
        print(-1)
        exit(0)
    elif s == 2 and not c in c2:
      ans += 10*c
      c2.append(c)
      if len(c2) > 1:
        print(-1)
        exit(0)
    elif s == 3 and not c in c3:
      ans += c
      c3.append(c)
      if len(c3) > 1:
        print(-1)
        exit(0)
print(ans)
Problem p02720 (python)

Fixed submission:
import math
import sys
from collections import deque
import heapq
import copy
import itertools
from itertools import permutations
from itertools import combinations
import bisect
def mi() : return map(int,sys.stdin.readline().split())
def ii() : return int(sys.stdin.readline().rstrip())
def i() : return sys.stdin.readline().rstrip()
a=ii()
q=deque(list(range(1,10)))
c=0
while c<a:
  t=q.popleft()
  c+=1
  if t%10!=0:
    q.append(10*t+(t%10)-1)
  q.append(10*t+(t%10))
  if t%10!=9:
    q.append(10*t+(t%10)+1)
print(t)

Buggy submission (verdict: Runtime Error):
a=int(input())
List=[]
for i in range (1,1000000):
    x=str(i)
    b=True
    for j in range(len(x)-1):
        if abs(int(x[j])-int(x[j+1]))<=1:
            continue
        else:
            b=False
            break
    if b:
        List+=[i]
print(List[a-1])
Problem p02783 (python)

Fixed submission:
import math
a,b=map(int,input().split())
print(math.ceil(a/b))

Buggy submission (verdict: Runtime Error):
import math
a,b=map(int,input().split())
print(mayh.ceil(a/b))
Problem p02848 (python)

Fixed submission:
a=int(input())
s=input()
for i in range(len(s)):
  d=ord(s[i])+a
  if d>=91:
    d-=26
  print(chr(d),end="")

Buggy submission (verdict: Runtime Error):
a=int(input())
s=input()
for i in range(a):
  d=List[i]+a
  if d>=91:
    d-=26
  print(d,end="")
Problem p02910 (python)

Fixed submission:
import math
import sys
from collections import deque
import heapq
import copy
import itertools
from itertools import permutations
from itertools import combinations
import bisect
def mi() : return map(int,sys.stdin.readline().split())
def ii() : return int(sys.stdin.readline().rstrip())
def i() : return sys.stdin.readline().rstrip()
s=i()
for i in range(math.ceil(len(s)/2)):
  if not (s[2*i]=="R" or s[2*i]=="U" or s[2*i]=="D"):
    print("No")
    sys.exit()
for j in range(len(s)//2):
  if not (s[2*j+1]=="L" or s[2*j+1]=="U" or s[2*j+1]=="D"):
    print("No")
    sys.exit()
print('Yes')

Buggy submission (verdict: Runtime Error):
import math
import sys
from collections import deque
import heapq
import copy
import itertools
from itertools import permutations
from itertools import combinations
import bisect
def mi() : return map(int,sys.stdin.readline().split())
def ii() : return int(sys.stdin.readline().rstrip())
def i() : return sys.stdin.readline().rstrip()
s=i()
for i in range(math.ceil(s/2)):
  if not s[i]=="R" or s[i]=="U" or s[i]=="D":
    print("No")
    sys.exit()
for j in range(s//2):
  if not s[i]=="L" or s[i]=="U" or s[i]=="D":
    print("No")
print('Yes')
Problem p02911 (python)

Fixed submission:
import math
import sys
from collections import deque
import heapq
import copy
import itertools
from itertools import permutations
from itertools import combinations
import bisect
def mi() : return map(int,sys.stdin.readline().split())
def ii() : return int(sys.stdin.readline().rstrip())
def i() : return sys.stdin.readline().rstrip()
a,b,c=mi()
l=[0]*a
for i in range(c):
  j=ii()
  l[j-1]+=1
for k in l:
  if b+k-c>0:
    print("Yes")
  else:
    print("No")

Buggy submission (verdict: Runtime Error):
import math
import sys
from collections import deque
import heapq
import copy
import itertools
from itertools import permutations
from itertools import combinations
import bisect
def mi() : return map(int,sys.stdin.readline().split())
def ii() : return int(sys.stdin.readline().rstrip())
def i() : return sys.stdin.readline().rstrip()
a,b,c=mi()
l=[0]*a
for i in range(c):
  j=ii()
  l[i-1]+=1
for k in l:
  if b+k-c>0:
    print("Yes")
  else:
    print("No")
Problem p03085 (python)

Fixed submission:
c = input()
print("A" if c == "T" else "T" if c == "A" else "C" if c == "G" else "G")

Buggy submission (verdict: Runtime Error):
c = input()
print("A" if c == "T" else "T" if c == "A" else "C" if c == "G" else "G" if c == "G")
Problem p03163 (python)

Fixed submission:
mod=10**9+7
import math
import sys
from collections import deque
import heapq
import copy
import itertools
from itertools import permutations
from itertools import combinations
import bisect
def mi() : return map(int,sys.stdin.readline().split())
def ii() : return int(sys.stdin.readline().rstrip())
def i() : return sys.stdin.readline().rstrip()
a,b=mi()
dp=[0]*(b+1)
for i in range(a):
  x,y=mi()
  for i in range(b-x,-1,-1):
      dp[i+x]=max(dp[i]+y,dp[i+x])
print(max(dp))

Buggy submission (verdict: Runtime Error):
mod=10**9+7
import math
import sys
from collections import deque
import heapq
import copy
import itertools
from itertools import permutations
from itertools import combinations
import bisect
import numpy as np
def mi() : return map(int,sys.stdin.readline().split())
def ii() : return int(sys.stdin.readline().rstrip())
def i() : return sys.stdin.readline().rstrip()
a,b=mi()
dp=[0]*(b+1)
for i in range(a):
  x,y=mi()
  for i in range(b-x,-1,-1):
      dp[i+x]=max(dp[i]+y,dp[i+x])
print(max(dp))
Problem p03280 (python)

Fixed submission:
a,b=input().split()
print((int(a)-1)*(int(b)-1))

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
print(a*b-a-b+1)
Problem p03436 (python)

Fixed submission:
import sys
from collections import deque
sys.setrecursionlimit(10000)
a,b=map(int,input().split())
List=[]
sumup=0
for i in range(a):
  l=list(input())
  p=l.count(".")
  sumup+=p
  List.append(l)
List[0][0]=1
q=deque([[0,0]])
while q:
  h,w=q.popleft()
  aaa=[[0,1],[0,-1],[1,0],[-1,0]]
  for x,y in aaa:
    if 0<=h+x<a and 0<=w+y<b:
      if List[h+x][w+y]==".":
        List[h+x][w+y]=List[h][w]+1
        q.append([h+x,w+y])
if List[a-1][b-1]==".":
  print(-1)
else:  
  print(sumup-List[a-1][b-1])

Buggy submission (verdict: Runtime Error):
from collections import deque
a,b=map(int,input().split())
List=[]
sumup=0
for i in range(a):
  l=list(input())
  p=l.count(".")
  sumup+=p
  List.append(l)
List[0][0]=1
q=deque([[0,0]])
while List[a-1][b-1]==".":
  h,w=q.popleft()
  aaa=[[0,1],[0,-1],[1,0],[-1,0]]
  for x,y in aaa:
    if 0<=h+x<a and 0<=w+y<b:
      if List[h+x][w+y]==".":
        List[h+x][w+y]=List[h][w]+1
        q.append([h+x,w+y])
print(sumup-List[a-1][b-1])
Problem p03485 (python)

Fixed submission:
import math
a,b=map(int,input().split())
print(math.ceil((a+b)/2))

Buggy submission (verdict: Runtime Error):
import math
map(int,input().split())
print(math.ceil((a+b)/2))
Problem p03573 (python)

Fixed submission:
a,b,c = map(int,input().split())
if a == b:
    print(c)
elif a == c:
    print(b)
else:
    print(a)

Buggy submission (verdict: Runtime Error):
a,b,c = int(map(input().split()))
if a == b:
    print(c)
elif a == c:
    print(b)
else:
    print(a)
Problem p03605 (python)

Fixed submission:
n = input()
if "9" in n:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n = input()
if "9" in n:
    print("Yes")
else:
    print(No)
Problem p03729 (python)

Fixed submission:
a,b,c = input().split()
print("YES" if a[-1] == b[0] and b[-1] == c[0] else "NO")

Buggy submission (verdict: Runtime Error):
a,b,c = input().split()
print("YES" if a[-1] == b[0] && b[-1] == c[0] else "NO")
Problem p03399 (python)

Fixed submission:
a, b, c, d = [input() for _ in xrange(4)]
print min(a, b) + min(c, d)

Buggy submission (verdict: Runtime Error):
a, b = map(lambda x: int(x) - 1, raw_input().split())
x = [['.'] * 100 for _ in xrange(100)]
for i in xrange(50, 100):
    for j in xrange(100):
        x[i][j] = '#'
for i in xrange(0, 50, 2):
    if b:
        for j in xrange(0, 100, 2):
            if b:
                x[i][j] = '#'
                b -= 1
for i in xrange(99, 49, -2):
    if a:
        for j in xrange(0, 100, 2):
            if a:
                x[i][j] = '.'
                a -= 1
print '\n'.join(['100 100'] + [''.join(_) for _ in x])
Problem p03450 (python)

Fixed submission:
from collections import deque
n, m = map(int, raw_input().split())
graph = {_: set() for _ in xrange(n + 1)}
in_deg, dist = [0] * (n + 1), [-1] * (n + 1)
for _ in xrange(m):
    l, r, d = map(int, raw_input().split())
    graph[l].add((r, d))
    in_deg[r] += 1
que = deque([i for i in xrange(n + 1) if not in_deg[i]])
cst = 1
while que:
    stp = que.popleft()  # start_point
    if in_deg[stp] < 0:
        in_deg[stp] = cst
    for v, d in graph[stp]:
        if dist[v] < 0:
            dist[v] = dist[stp] + d
        else:
            if dist[v] != dist[stp] + d:
                print 'No'
                exit()
        in_deg[v] -= 1
        if not in_deg[v]:
            que.append(v)
print 'No' if [_ for _ in in_deg[1:] if _ > 0] else 'Yes'

Buggy submission (verdict: Runtime Error):
x = {}
n, m = map(int, raw_input().split())
if m == 0:
    print 'Yes'
    exit()
l, r, d = map(int, raw_input().split())
x[l], x[r] = 0, d
flag = True
for _ in xrange(m - 1):
    l, r, d = map(int, raw_input().split())
    if r in x:
        if x[r] != x[l] + d:
            flag = False
    else:
        x[r] = x[l] + d
print 'Yes' if flag else 'No'
Problem p03476 (python)

Fixed submission:
p = [True] * 100020
for x in xrange(2, int(100020 ** 0.5) + 1):
    if p[x]:
        for y in xrange(2, 100020):
            if y * x >= 100020:
                break
            p[x * y] = False
p[0], p[1] = False, False
e, s = [], 0
for i in xrange(100020):
    e.append(s)
    if p[i] and p[(i + 1) / 2]:
        s += 1
for _ in xrange(input()):
    (l, r), c = map(int, raw_input().split()), 0
    print e[r + 1] - e[l]

Buggy submission (verdict: Runtime Error):
p = [True] * 100000
for x in xrange(2, int(100000 ** 0.5) + 1):
    if p[x]:
        for y in xrange(2, 100000):
            if y * x >= 100000:
                break
            p[x * y] = False
p[0], p[1] = False, False
e, s = [], 0
for i in xrange(100000):
    e.append(s)
    if p[i] and p[(i + 1) / 2]:
        s += 1
for _ in xrange(input()):
    (l, r), c = map(int, raw_input().split()), 0
    print e[r + 1] - e[l]
Problem p03480 (python)

Fixed submission:
s = raw_input()
n = len(s)
if n == 1:
    print 1
    exit()
if not n & 1:
    l = n / 2 - 1
    r = n / 2
    res = n / 2
    while r < n and l >= 0 and s[l] == s[r]:
        l -= 1
        r += 1
        res += 1
    print res
else:
    l = n / 2 - 1
    r = n / 2 + 1
    res = n / 2 + 1
    if s[n / 2] != s[l] or s[n / 2] != s[r]:
        print res
    else:
        while r < n and l >= 0 and s[l] == s[r]:
            l -= 1
            r += 1
            res += 1
        print res

Buggy submission (verdict: Runtime Error):
s = raw_input()
n = len(s)
if not n & 1:
    l = n / 2 - 1
    r = n / 2
    res = n / 2
    while r < n and l >= 0 and s[l] == s[r]:
        l -= 1
        r += 1
        res += 1
    print res
else:
    l = n / 2 - 1
    r = n / 2 + 1
    res = n / 2 + 1
    if s[n / 2] != s[l] or s[n / 2] != s[r]:
        print res
    else:
        while r < n and l >= 0 and s[l] == s[r]:
            l -= 1
            r += 1
            res += 1
        print res
Problem p03543 (python)

Fixed submission:
from itertools import groupby
if [len(list(e)) for k, e in groupby(raw_input()) if len(list(e)) >= 3]:
    print 'Yes'
else:
    print 'No'

Buggy submission (verdict: Runtime Error):
l = [2, 1]
for x in xrange(100):
    l.append(l[-2] + l[-1])
print l[input()]

Buggy submission (verdict: Runtime Error):
s = raw_input()
if set(s) <= 2 and (s[0] != s[1] or s[2] != s[3]):
    print 'Yes'
else:
    print 'No'
Problem p03555 (python)

Fixed submission:
a = raw_input()
b = raw_input()
if a == b[::-1]:
	print 'YES'
else:
	print 'NO'

Buggy submission (verdict: Runtime Error):
from bisect import bisect_left, bisect_right
br, bl = bisect_right, bisect_left
n = input()
a = sorted([int(x) for x in raw_input().split()])
b = sorted([int(x) for x in raw_input().split()])
c = sorted([int(x) for x in raw_input().split()])
ans = 0
for bi in b:
	ans += (bl(a, bi) * (n - br(c, bi)))
print ans
Problem p03606 (python)

Fixed submission:
n = input()
a = [0] * 100010
for i in xrange(n):
	l, r = [int(x) for x in raw_input().split()]
	a[l:r + 1] = [1] * (r - l + 1)
print a.count(1)

Buggy submission (verdict: Runtime Error):
n = input()
a = [0] * 100000
for i in xrange(n):
	l, r = [int(x) for x in raw_input().split()]
	if l == r:
		a[l] = 1
		continue
	a[l:r + 1] = [1] * (r - l + 1)
print a.count(1)
Problem p02639 (python)

Fixed submission:
S = [int(x) for x in input().split()]
for i in range(5):
	if S[i]==0:
		print(i+1)
		exit()

Buggy submission (verdict: Runtime Error):
S = [int(x) for x in input().split()]
for i in range(5):
	if S[i]==0:
  		print(i+1)
        exit()

Buggy submission (verdict: Runtime Error):
S = [int(x) for x in input().split()]
for i in range(5)
	if S[i]==0
  		print(i+1)
        exit()
Problem p02687 (python)

Fixed submission:
S = input()
if S == 'ABC': print('ARC')
else: print('ABC')

Buggy submission (verdict: Runtime Error):
S = input()
if S = 'ABC': print('ARC')
else: print('ABC')
Problem p03290 (python)

Fixed submission:
D, G = map(int, input().split()) 
S = [[int(x) for x in input().split()]for i in range(D)]
Minimum_can = []
for i in range(2**D):
    binary = str(format(i,'b'))
    binary_zero = binary.zfill(D)
    SUM = 0
    Number = 0
    for j in range(D):
        if binary_zero[j]=='1':
            SUM += S[j][0]*100*(j+1)+S[j][1]
            Number += S[j][0]
    if SUM >= G: Minimum_can.append(Number)        
    elif SUM < G:
        Biggest_0_number = 0
        for k in range(D):
            if binary_zero[D-k-1]=='0':
                Biggest_0_number = D-k-1
                break
        for k in range(S[Biggest_0_number][0]):
            if SUM+100*(Biggest_0_number+1)*(k+1) >= G:
                Minimum_can.append(Number+k+1)
                break 
print(min(Minimum_can))

Buggy submission (verdict: Runtime Error):
D, G = map(int, input().split()) 
S = [[int(x) for x in input().split()]for i in range(D)]
Minimum_can = []
for i in range(2**D-1):
    binary = str(format(i,'b'))
    binary_zero = binary.zfill(D)
    SUM = 0
    Number = 0
    for j in range(D):
        if binary_zero[j]=='1':
            SUM += S[j][0]*100*(j+1)+S[j][1]
            Number += S[j][0]
    if SUM == G: Minimum_can.append(Number)        
    elif SUM < G:
        Biggest_0_number = 0
        for k in range(D):
            if binary_zero[D-k-1]=='0':
                Biggest_0_number = D-k-1
                break
        for k in range(S[Biggest_0_number][0]):
            if SUM+100*(Biggest_0_number+1)*(k+1) >= G:
                Minimum_can.append(Number+k+1)
                break 
print(min(Minimum_can))
Problem p03599 (python)

Fixed submission:
A, B, C, D, E, F = map(int,input().split())
answer_number = [0,0,0,0]
answer_max = 0
for i in range((F//(100*A))+1):
  for j in range(((F-100*A*i)//(100*B))+1):
    if i==0 and j ==0: continue
    for k in range(((F-100*A*i-100*B*j)//C)+1):
      for l in range(((F-100*A*i-100*B*j-C*k)//D)+1):
        if (C*k+D*l)/(A*i+B*j) <= E:
          if (C*k+D*l)/(A*i+B*j) > answer_max:
            answer_max = (C*k+D*l)/(A*i+B*j)      #### k
            answer_number = [i,j,k,l]
if answer_max == 0: print(100*A,0)
else:
  print(C*answer_number[2]+D*answer_number[3]+100*(A*answer_number[0]+B*answer_number[1]), C*answer_number[2]+D*answer_number[3])

Buggy submission (verdict: Runtime Error):
A, B, C, D, E, F = map(int,input().split())
answer_number = [0,0,0,0]
answer_max = 0
for i in range((F/(100*A))+1):
  for j in range(((F-100*A*i)/(100*B))+1):
    if i==0 and j ==0: continue
    for k in range(((F-100*A*i-100*B*j)/C)+1):
      for l in range(((F-100*A*i-100*B*j-C*k)/D)+1):
        if (C*k+D*l)/(A*i+B*j) <= E:
          if (C*k+D*l)/(A*i+B*j) > answer_max:
            answer_max = (C*k+D*l)/(A*i+B*j)      #### k
            answer_number = [i,j,k,l]
if answer_number == [0,0,0,0]: print(0,0)
else:
  print(C*answer_number[2]+D*answer_number[3]+100*(A*answer_number[0]+B*answer_number[1]), C*answer_number[2]+D*answer_number[3])
Problem p03665 (python)

Fixed submission:
# -*- coding: utf-8 -*-

import sys

N,P = map(int, raw_input().split())
a = map(int, raw_input().split())

count_0 = 0
count_1 = 0
number = 0

def comb(n, r):
    r = min(r, n - r)
    if r == 0: return 1;
    if r == 1: return n;
    numerator = [n - r + i + 1 for i in range(r)]
    denominator  = [i + 1 for i in range(r)]
    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot
    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= numerator[k]
    return result

for i in range(N):
    if a[i] % 2 == 0:
        count_0 += 1
    else:
        count_1 += 1


if P == 0:
    if count_1 == 0:
        number = 1
    else:
        for j in range(count_1 /2 +1):
            number += comb(count_1,2*j)
else:
    if count_1 != 0:
        if count_1 % 2 == 0:
            for j in range(1,count_1 / 2 + 1):
                number += comb(count_1,2*j - 1)
        else:
            for j in range(1,count_1/2 + 2):
                number += comb(count_1, 2*j - 1)

if number != 0:
    print number * (2**count_0)
else:
    print number

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

import sys

N,P = map(int, raw_input().split())
a = map(int, raw_input().split())

count_0 = 0
count_1 = 0
number = 0

def comb(n,r):
    if n < 0 or r < 0 or n < r:
        return 0
    elif n == 0 or r == 0:
        return 1
    else:
        return comb(n-1,r-1)+comb(n-1,r)

for i in range(N):
    if a[i] % 2 == 0:
        count_0 += 1
    else:
        count_1 += 1

print "count_0 = %d" % count_0
print "count_1 = %d" % count_1

if P == 0:
    if count_1 == 0:
        number = 1
    else:
        for j in range(count_1 /2 +1):
            number += comb(count_1,2*j)
else:
    if count_1 != 0:
        if count_1 % 2 == 0:
            for j in range(1,count_1 / 2):            
                number += comb(count_1,2*j - 1)
        else:
            for j in range(1,count_1/2 + 1):
                number += comb(count_1, 2*j - 1)

if number != 0:
    print "number = %d" % number * (2**count_0)
Problem p03671 (python)

Fixed submission:
import sys
import math

l = raw_input().split()
l[0] = int(l[0])
l[1] = int(l[1])
l[2] = int(l[2])

sum = l[0]+l[1]+l[2]
min = sum

for i in range(3):
    s = sum - l[i]
    if s < min:
        min = s

print min

Buggy submission (verdict: Runtime Error):
# !/usr/bin/env python
# -*- coding utf-8 -*-

import sys

n = input()
a = raw_input().split() #a[0], a[1], .., a[n]
n = int(n)
b = []

for i in range(n):
    b.append(a[i])
    b.reverse()

for i in range(n):
    print b[i],
Problem p03737 (python)

Fixed submission:
import math
import sys

s = input().split()

print(s[0][0].upper() + s[1][0].upper() + s[2][0].upper())

Buggy submission (verdict: Runtime Error):
import math
import sys

x,y=[int(i) for i in input().split()]

if x > y:
    print("GREATER")
elif x == y:
    print("EQUAL")
else:
    print("LESS")