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

Fixed submission:
import sys


def main():
    args = sys.stdin.readline().split()
    N = int(args[0])
    A = map(int, input().split())

    non_factor_cnt = 0
    factor_of_two_cnt = 0
    factor_of_four_cnt = 0
    for num in A:
        remainder = num % 4
        if remainder != 0:
            if remainder == 2:
                factor_of_two_cnt += 1
            else:
                non_factor_cnt += 1
        else:
            factor_of_four_cnt += 1

    if factor_of_two_cnt == 0:
        if factor_of_four_cnt >= non_factor_cnt - 1:
            print('Yes')
            sys.exit()
    if factor_of_four_cnt >= non_factor_cnt: # + factor_of_two_cnt % 2:
        print('Yes')
        sys.exit()
    print('No')

main()

Buggy submission (verdict: Runtime Error):
import sys


def main():
    args = sys.stdin.readline().split()
    N = int(args[0])
    A = map(int, input().split())

    non_factor_cnt = 0
    factor_of_two_cnt = 0
    factor_of_four_cnt = 0
    for num in A:
        remainder = num % 4
        if remainder != 0:
            if remainder == 2:
                factor_of_two_cnt += 1
            else:
                non_factor_cnt += 1
        else:
            factor_of_four_cnt += 1

    if len(A) <= 3 or (len(A) >= 4 and factor_of_four_cnt >= 2):
        if factor_of_four_cnt >= non_factor_cnt - 1:
            print('Yes')
            sys.exit()
    if factor_of_four_cnt >= non_factor_cnt: # + factor_of_two_cnt % 2:
        print('Yes')
        sys.exit()
    print('No')

main()
Problem p03643 (python)

Fixed submission:
a = input()
print("ABC" + str(a))

Buggy submission (verdict: Runtime Error):
n, m = [int(x) for x in input().split()]
isl = []
mark = [False] * n
l = [0] * n
for i in range(n):
    isl.append([])
for i in range(m):
    a, b = [int(x) for x in input().split()]
    isl[a - 1].append(b - 1)
    isl[b - 1].append(a - 1)
 
q = []
q.append(0)
found = False
while len(q):
    v = q.pop()
    mark[v] = True
    for child in isl[v]:
        if not mark[child]:
            l[child] = l[v] + 1
            q.append(child)
print("POSSIBLE" if (l[n - 1] == 2 or l[n - 1] == 1) else "IMPOSSIBLE")
Problem p03721 (python)

Fixed submission:
N, K = map(int, input().split())

ab = [[0, 0]] * N
for i in range(N):
    _a, _b = map(int, input().split())
    ab[i] = [_a, _b]
ab.sort(key=lambda x:x[0])

j = 0
index = 0
while j < K:
    j += ab[index][1]
    if j < K:
        index += 1

print(ab[index][0])

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())

ab = [[0, 0]] * N
for i in range(N):
    _a, _b = map(int, input().split())
    ab[i] = [_a, _b]
ab.sort(key=lambda x:x[0])

j = 0
index = 0
while j < K:
    j += ab[index][1]
    if j < K:
        index += 1

print ab[index][0]

Buggy submission (verdict: Runtime Error):
n, k = map(lambda x: int(x), input().split())

total = [[0, 0]] * k
for i in range(n):
    number, copies = map(lambda x: int(x), input().split())
    total[i] = [number, copies]

total.sort(key=lambda x: x[0])


count = i = 0
while count < K:
    count += total[i][1]
    if count < K:
        i += 1

print(total[i][0])

Buggy submission (verdict: Runtime Error):
n, k = map(lambda x: int(x), input().split())

total = [[0, 0]] * k
for i in range(n):
    number, copies = map(lambda x: int(x), input().split())
    total[i] = [number, copies]

total.sort(key=lambda x: x[0])

add = 0
for pair in total:
    add += pair[1]
    if add >= k:
        print(pair[0])
        break
Problem p03640 (python)

Fixed submission:
import numpy as np

def grid_coloring():
	h,w = map(int, raw_input().split(" "))
	n = int(raw_input())
	a = map(int, raw_input().split(" "))
	_current_color = 1
	ans = np.zeros((h,w), dtype=int)
	for i in range(h):
		if i%2==0:
			for j in reversed(range(w)):
				if a[_current_color-1]!=0:
					ans[i][j]=_current_color
					a[_current_color - 1]-=1
				else:
					_current_color +=1
					ans[i][j] = _current_color
					a[_current_color - 1] -= 1
		else:
			for j in range(w):
				if a[_current_color-1]!=0:
					ans[i][j]=_current_color
					a[_current_color - 1]-=1
				else:
					_current_color +=1
					ans[i][j] = _current_color
					a[_current_color - 1] -= 1
	for i in range(h):
		print " ".join(map(str, ans[i]))


if __name__ == "__main__":
	grid_coloring()

Buggy submission (verdict: Runtime Error):
def grid_coloring():
	h,w = map(int, raw_input().split(" "))
	n = int(raw_input())
	a = map(int, raw_input().split(" "))
	_current_color = 1
	ans = np.zeros((h,w), dtype=int)
	for i in range(h):
		if i%2==0:
			for j in reversed(range(w)):
				if a[_current_color-1]!=0:
					ans[i][j]=_current_color
					a[_current_color - 1]-=1
				else:
					_current_color +=1
					ans[i][j] = _current_color
					a[_current_color - 1] -= 1
		else:
			for j in range(w):
				if a[_current_color-1]!=0:
					ans[i][j]=_current_color
					a[_current_color - 1]-=1
				else:
					_current_color +=1
					ans[i][j] = _current_color
					a[_current_color - 1] -= 1
	for i in range(h):
		print " ".join(map(str, ans[i]))


if __name__ == "__main__":
	grid_coloring()
Problem p03651 (python)

Fixed submission:
from fractions import gcd
N, K = map(int, raw_input().split(' '))
A = map(int, raw_input().split(' '))
 
M = max(A)
G = reduce(gcd, sorted(A))
 
if not K % G and K <= M:
    print 'POSSIBLE'
else:
    print 'IMPOSSIBLE'

Buggy submission (verdict: Runtime Error):
def get_difference():
	# get input from raw_input()
	n, k = map(int, raw_input().split(' '))
	l = [int(e) for e in raw_input().split(' ')]

	gcd_v = reduce(gcd, l)
	if not k % gcd_v and k <= max(l):
		print "POSSIBLE"
	else:
		print "IMPOSSIBLE"


if __name__ == "__main__":
	get_difference()

Buggy submission (verdict: Runtime Error):
def get_difference():
	# get input from raw_input()
	n, k = map(int, raw_input().split(' '))
	l = [int(e) for e in raw_input().split(' ')]
	if n < 1:
		print "IMPOSSIBLE"
		return
	if n == 1:
		if l[0] == k:
			print "POSSIBLE"
		else:
			print "IMPOSSIBLE"
		return
	if k in l:
		print "POSSIBLE"
		return
	if k > max(l):
		print "IMPOSSIBLE"
		return
	gcd_v = reduce(gcd, sorted(l))
	if k % gcd_v == 0:
		print "POSSIBLE"
	else:
		print "IMPOSSIBLE"


if __name__ == "__main__":
	get_difference()

Buggy submission (verdict: Runtime Error):
def get_difference():
	# get input from raw_input()
	n, k = map(int, raw_input().split(' '))
	l = [int(e) for e in raw_input().split(' ')]
	if n < 1:
		print "IMPOSSIBLE"
		return
	if n == 1:
		if l[0] == k:
			print "POSSIBLE"
		else:
			print "IMPOSSIBLE"
		return
	if k in l:
		print "POSSIBLE"
		return
	if k > max(l):
		print "IMPOSSIBLE"
		return
	gcd_v = reduce(gcd, l)
	if k % gcd_v == 0 or gcd_v == 1:
		print "POSSIBLE"
	else:
		print "IMPOSSIBLE"


if __name__ == "__main__":
	get_difference()

Buggy submission (verdict: Runtime Error):
def get_difference():
	# get input from raw_input()
	n, k = map(int, raw_input().split(' '))
	l = [int(e) for e in raw_input().split(' ')]
	if k in l:
		print "POSSIBLE"
		return
	if k>max(l):
		print "IMPOSSIBLE"
		return
	gcd_v = reduce(gcd, l)
	if k%gcd_v==0:
		print "POSSIBLE"
	else:
		print "IMPOSSIBLE"


if __name__ == "__main__":
	get_difference()

Buggy submission (verdict: Runtime Error):
def get_difference():
	# get input from raw_input()
	n, k = map(int, raw_input().split(' '))
	l = [int(e) for e in raw_input().split(' ')]
	if k in l:
		print "POSSIBLE"
		return
	if k>max(l):
		print "INPOSSIBLE"
		return
	gcd_v = reduce(gcd, l)
	if k%gcd_v==0:
		print "POSSIBLE"
	else:
		print "INPOSSIBLE"


if __name__ == "__main__":
	get_difference()
Problem p03657 (python)

Fixed submission:
def sharing_cookies():
	A, B = map(int, raw_input().split(" "))
	if A%3==0 or B%3==0 or (A+B)%3==0:
		print "Possible"
	else:
		print "Impossible"


if __name__ == "__main__":
	sharing_cookies()

Buggy submission (verdict: Runtime Error):
import numpy as np

def splitting_pile():
	n = int(raw_input())
	nums = list(map(int, raw_input().split(" ")))
	ans = np.inf
	for i in range(1, n):
		ans = min(ans, abs(sum(nums[:i])-sum(nums[i:])))
	print ans


if __name__ == "__main__":
	splitting_pile()
Problem p03666 (python)

Fixed submission:
N,A,B,C,D=map(int,input().split())
N=N-1
l=[]
for i in range(0,N+1):
    l.append(range(i*C-(N-i)*D,i*D-(N-i)*C+1))

for _ in l:
    if B-A in _:
        print("YES")
        break
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
N,A,B,C,D=map(int,input().split())
N=N-2
for i in range(0,N+1):
    l.append(range(i*C-(N-i)*D,i*D-(N-i)*C+1))

for _ in l:
    if B-A in _:
        print("YES")
        break
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
N,A,B,C,D=map(int,input().split())
for i in range(0,N-1):
    l.append(range(i*C-(N-i)*D,i*D-(N-i)*C+1))

for _ in l:
    if B-A in _:
        print("YES")
        break
else:
    print("NO")
Problem p03773 (python)

Fixed submission:
a, b = map(int, input().split())
print((a+b)%24)

Buggy submission (verdict: Runtime Error):
a, b = map(int, split.input())
print((a+b)%24)
Problem p03813 (python)

Fixed submission:
x = int(input())
 
if x < 1200:
    a = 'ABC'
else:
    a = 'ARC'
 
print(a)

Buggy submission (verdict: Runtime Error):
x = int(input())

if x < 1200:
    a = ABC
else:
    a = ARC

print(a)
Problem p03643 (python)

Fixed submission:
# coding: utf-8
# Here your code !
N = input()
print("ABC" + N)

Buggy submission (verdict: Runtime Error):
uk3zdbr9
Problem p03646 (python)

Fixed submission:
K = int(raw_input())

res = range(51)

k = K/50
mod = K%50

for i in res:
    res[i] = i+k

res.pop(-1-mod)


print 50
for i in range(len(res)):print res[i],

Buggy submission (verdict: Runtime Error):
K = int(raw_input())

res = range(51)

k = K/50
mod = K%50

for i in res:
    res[i] = i+k

res.pop(51-mod)

print 50
for i in range(len(res)):print res[i],
Problem p03827 (python)

Fixed submission:
N = int(raw_input())
S = raw_input()
x = 0
maxx = 0

for c in S:
    if c == 'I':
        x += 1
    if c == 'D':
        x -= 1
    if x > maxx:
        maxx = x

print maxx

Buggy submission (verdict: Runtime Error):
N = int(raw_input())
S = int(raw_input())
x = 0
maxx = 0

for c in S:
    if c == 'I':
        x += 1
    if c == 'D':
        x -= 1
    if x > maxx:
        maxx = x

print maxx
Problem p03651 (python)

Fixed submission:
def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def ris(): return list(input())
def pli(a): return "".join(list(map(str, a)))

n,k = rli()
A = rli()

def gcd(a,b):
    while b:
        a, b = b, a%b
    return a

b = 0
for a in A:
    b  = gcd(a, b)

if k%b or k > max(A):
    print('IMPOSSIBLE')
else:
    print('POSSIBLE')

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
nn = list(map(int,input().split()))
nnn = nn.copy()

if b in nn:
    print('POSSIBLE')
    exit()
if b > max(nn):
    print("IMPOSSIBLE")
    exit()
len_nn = [0]
while 1:
    lnn = len(nn)
    for x in range(len(nn)):
        for y in range(len(nn) - x -len_nn):
            y = len(nn)-y-1
            #print(x,y)
            num = abs(x-nn[y])
            if num == b or num == 1:
                print('POSSIBLE')
                exit()
            elif num not in nn and num != 0:
                nn.append(num)
    len_nn += lnn
    if nn == nnn:
        print('IMPOSSIBLE')
        exit()
Problem p03719 (python)

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

# get three integers separated with half-width break
a, b, c = map(int, raw_input().split())
# output
if c >= a and c <= b:
    print "Yes" 
else:
    print "No"

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

# get three integers separated with half-width break
a, b, c = map(int, raw_input().split())
# output
if c >= a and c <= b:
    print('Yes')
else:
    print("No")

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

# get three integers separated with half-width break
a, b, c = map(int, raw_input().split())
if c >= a and c <= b:
    print('Yes')
else:
    print("No")
# output

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

# get three integers separated with half-width break
a, b, c = map(int, raw_input().split())
if c >= a and c <= b:
    print('Yes')
else
    print("No")
# output
Problem p03962 (python)

Fixed submission:
count = 3
a, b, c = map(int, input().split())
if a == b:
    count -= 1
if a == c:
    count -= 1
if b == c:
    count -= 1
if count == 0:
    count += 1
print(count)

Buggy submission (verdict: Runtime Error):
result = 0
N, K = map(int, input().split())
if N == 1:
    result = K
else:
    result = K
    for i in range(N-1):
        result = result * (K - 1)
print(result)
Problem p03657 (python)

Fixed submission:
A, B = input().split()
A, B = int(A), int(B)
n = int(A) + int(B)
if A % 3 == 0 or B % 3 == 0 or (A + B) % 3 == 0:
    print('Possible')
else:
    print('Impossible')

Buggy submission (verdict: Runtime Error):
A, B = input.split()
n = int(A) + int(B)
if n % 3 == 0:
    print(Possible)
else:
    print(Impossible)
Problem p03657 (python)

Fixed submission:
# coding: utf-8
# Here your code !
 
x=input()
a=int(x.split(" ")[0])
b=int(x.split(" ")[1])
if (a%3==0 or b%3==0 or (a+b)%3==0):
    print ("Possible")
else:
    print ("Impossible")

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Here your code !
 
x=input()
a=int(x.split(" ")[0])
b=int(x.split(" ")[1])
y=input()
c=y.split(" ")
c=sorted(c,reverse=True)
sum = 0
for i in range(b):
    sum += int(c[i])
print (sum)
Problem p04031 (python)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Sat Aug 13 20:59:33 2016

@author: kt
"""
max=-1000
min=1000
N=input()
i=0
minx=0
l = map(int, raw_input().split())
sum=0
for var in l:
     sum+=var
sum=float(sum)/float(N)
isum=int(sum)
if sum==isum:
    minx=sum
elif isum+1-sum >sum-isum:
    minx=isum
else: 
    minx=isum+1
result=0
for var in l:
    result+=(var-minx)*(var-minx)
print int(result)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Sat Aug 13 20:59:33 2016

@author: kt
"""
max=-1000
min=1000
cost=[0]*100
N=input()
i=0
l = map(int, raw_input().split())
for var in l:
    if var>max:
        max=var
    if var<min:
        min=var
        
"""if max-min==1:
        if cost[0]>cost[1]:
            print cost[1]
        else: 
            print cost[1]
    else :
        print cost[0]"""
if max==min:
    print 0
if max-min==1:
    if l.index(max)>l.index(min): 
        print l.count(min)

    else:      
        print l.count(max)
        print max
else :
    for var in range(min,max+1):
        for var2 in l:
           cost[i]+=(var-var2)*(var-var2)
        i+=1
        if i>2:
            if cost[i-2]<cost[i-1] and cost[i-2]<cost[i-3]:
                print cost[i-2]
Problem p03659 (python)

Fixed submission:
# -*- coding: utf-8 -*-
 
n = int(input())
a =list(map(int, input().split()))

N = sum(a)
r = float('inf')
x = 0
 
for i in range(n-1):
    x += a[i]
    y = N - x
    if r > abs(x -y):
        r = abs(x -y)
print(r)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
 
n = int(input())
a =list(map(int, input().split()))

N = sum(a)
r = float('inf')
x = 0

for i in range(N-1):
    x += a[i]
    y = N - x
    if r > abs(x -y):
        r = abs(x -y)
print(r)
Problem p03673 (python)

Fixed submission:
# -*- coding: utf-8 -*-
N = int(input())
a = input().split()

if N % 2 == 0:
    b = a[N::-2] + a[::2]
else:
    b = a[N::-2] + a[1::2]

print(" ".join(b))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
N = int(input())
a = list(map(int, input().split()))

if N % 2 == 0:
    print(" ".join(a[N::-2] + a[::2]))
else:
    print(" ".join(a[N::-2] + a[1::2]))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
N = int(input())
a = list(map(int, input().split()))

if N % 2 == 0:
    print(" ".join(a[N::-2] + a[::2])
else:
    print(" ".join(a[N::-2] + a[1::2])
Problem p03681 (python)

Fixed submission:
import math
n,m = map(int, input().split())
if abs(n-m) <= 1:
    a = max(n,m)
    b = min(n,m)
    if a-b == 1:
        print((math.factorial(a)*math.factorial(b))%(10**9+7))
    else:
        print((math.factorial(a)*math.factorial(b)*2)%(10**9+7))
else:
    print(0)

Buggy submission (verdict: Runtime Error):
import math
n,m = map(int, input().split())
if abs(n-m) <= 1:
    a = max(n,m)
    b = min(n,m)
    if a-b == 1:
        print((math.factorial(a)*math.factorial(b))%(10**9+7))
    else:
        print((math.factorial(a)*math.factorial(b)*2%(10**9+7))
else:
    print(0)
Problem p03694 (python)

Fixed submission:
N = int(input())
a = [int(num) for num in input().split()]
print(str(max(a)-min(a)))

Buggy submission (verdict: Runtime Error):
N = int(input())
a = [int(num) for num in input().split()]
print(str(max(a)-min(a))
Problem p03696 (python)

Fixed submission:
N = input()
string = input()
arrange = string
while True:
    after_arrange = arrange.replace('()','')
    if after_arrange == arrange:
        break
    arrange = after_arrange
left = after_arrange.count(')')
right = after_arrange.count('(')
print('('*left+string+')'*right)

Buggy submission (verdict: Runtime Error):
N = input()
string = input()
arrange = string
while True:
    after_arrange = arrage.replace('()','')
    if after_arrange == arrage:
        break
    arrange = after_arrange
left = after_arrange.count(')')
right = after_arrange.count('(')
print('('*left+string+')'*right)

Buggy submission (verdict: Runtime Error):
N = input()
string = input()
arrange = string
while True:
    after_arrange = arrage.replace('()','')
    if after_arrange == arrage
        break
    arrange = after_arrange
left = after_arrange.count(')')
right = after_arrange.count('(')
print('('*left+string+')'*right)

Buggy submission (verdict: Runtime Error):
N = input()
string = input()
arrange = string.replace('()','')
while True:
    if arrange == arrage.replace('()',''):
        break
    arrange = arrage.replace('()','')
left = arrange.count(')')
right = arrange.count('(')
print('('*left+string+')'*right)
Problem p03719 (python)

Fixed submission:
a = [int(num) for num in input().split()]
print('Yes' if a[0]<=a[2]<=a[1] else 'No')

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
string = ''
for i in range(n):
    a,b=(input().split())
    string += a*int(b)
string = [int(i) for i in string]
print(sorted(string[k-1]))

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
string = ''
for i in range(n):
    a,b=(input().split())
    string += a*int(b)
print(sorted(string)[k-1])

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
string = ''
for i in range(n):
    a,b=(input().split())
    string += a*int(b)
print(string[k-1])
Problem p03730 (python)

Fixed submission:
a,b,c = map(int, input().split())
flag = 0
for i in range(1,b+1):
    if (a*i-c)%b==0:
        flag = 1
        break
print('YES' if flag == 1 else 'NO')

Buggy submission (verdict: Runtime Error):
a,b,c = map(int, input().split())
flag = 0
for i in range(1,b+1):
    if (a*1-c)%b==0:
        flag = 1
        break
print('YES' if flag = 1 else 'NO')
Problem p03779 (python)

Fixed submission:
num = int(input())
i = 1
bef = 0
while True:
    bef += i-1
    aft = bef + i
    if bef < num <= aft:
        print(i)
        break
    i += 1

Buggy submission (verdict: Runtime Error):
num = int(input())
i = 1
while True:
    bef = range(1,i)
    i += 1
    aft = range(1,i)
    if bef < num <= aft:
        print(i-1)
        break

Buggy submission (verdict: Runtime Error):
num = int(input())
i = 0
while True:
    bef = range(1,i)
    i += 1
    aft = range(1,i)
    if bef < num <= aft:
        print(i-1)
        break
Problem p03657 (python)

Fixed submission:
list = input().rstrip().split()
A = int(list[0])
B = int(list[1])
if A%3 != 0:
    if B%3 != 0:
        if (A+B)%3 != 0:
            print("Impossible")
        else: print("Possible")
    else: print("Possible")
else: print("Possible")

Buggy submission (verdict: Runtime Error):
N = int(input())
list = input().rstrip().split()
a=[]
for i in range(N):
    a = a + [int(list[i])]
sunuke=0
arai = 0
for i in range(N):
    arai = arai + a[i]
for i in range(N):
    sunuke1 = sunuke + a[i]
    arai1 = arai - a[i]
    if sunuke1 > arai1:
        x = abs(sunuke-arai)
        y = abs(sunuke1-arai1)
        res = min(x,y)
        break
    else:
        sunuke = sunuke1
        arai = arai1
print(res)
Problem p03657 (python)

Fixed submission:
a,b =map( int, raw_input().split())
if a%3 == 0 or b%3 == 0 or (a+b)%3 == 0:
    print 'Possible'
else:
    print 'Impossible'

Buggy submission (verdict: Runtime Error):
def solution(a):
    A = a[0]
    B = sum(a) - a[0]
    Min = abs(A - B)
    for i in xrange(1, len(a)-1):
        A += a[i]
        B -= a[i]
        if Min > abs(A- B):
            Min = abs(A - B)
    print Min
import math
N = int(raw_input())
a = map( int, raw_input().split())
solution(a)

Buggy submission (verdict: Runtime Error):
def solution(a):
    A = a[0]
    B = sum(a) - a[0]
    Min = abs(A - B)
    for i in xrange(1, len(a)-1):
        A += a[i]
        B -= a[i]
        if Min > abs(A- B):
            Min = abs(A - B)
    print Min
import math
N = int(raw_input())
a = map( int, raw_input().split())
solution(a)
Problem p03671 (python)

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

import re

x = raw_input()
x = map(int, re.split("\s", x))
x.sort()

print x[0] + x[1]

Buggy submission (verdict: Runtime Error):
import re

n = int(raw_input())
a = map(int, re.split("\s", raw_input()))
left = 0
right = 0
mask = 10**9 + 7

pow = [0]*n+2

tmp = 1
for i in range(1, n+2):
        tmp *= i
        pow[i] = tmp

for i in range(0, n + 1):
        x = a.index(a[i])
        if a[i] in a[x+1:]:
                left = i
                right = a[x+1:].index(a[i]) + x + 1
                break

for i in range(1, n + 2):
        ans = (pow[n + 1] / (pow[i] * pow[n + 1 - i]))
        x = (pow[left + n - right] / (pow[i - 1] * pow[left + n - right - i + 1]))
        print (ans - x) % mask
Problem p03660 (python)

Fixed submission:
import sys
sys.setrecursionlimit(1000000)
n=input()
graph=[[] for i in range(n+1)]
for i in range(n-1):
    v,u=list(map(int,raw_input().split()))
    graph[v].append(u)
    graph[u].append(v)

dist= [-1 for i in range(n+1)]
dist[1]=0
son=[[] for i in range(n+1)]
queue=[1]
father=[0 for i in range(n+1)]
def bfs(u):
    for v in graph[u]:
        if dist[v]==-1:
            dist[v]=dist[u]+1
            son[u].append(v)
            father[v]=u
            queue.append(v)
    queue.pop(0)
    if len(queue)!=0:
        bfs(queue[0])

bfs(1)
road=[n]
tempfather=n
for i in range(dist[n]):
    road.append(father[tempfather])
    tempfather=father[tempfather]

di=len(road)
k=road[(di-2)/2]

def countson(u):
  count=0
  if len(son[u])==0:return 1
  for v in son[u]:
      count+=countson(v)
  return count+1

cs=countson(k)
cf=n-cs

if cs>=cf:print 'Snuke'
else:
    print 'Fennec'

Buggy submission (verdict: Runtime Error):
n=input()
graph=[[] for i in range(n+1)]
for i in range(n-1):
    v,u=list(map(int,raw_input().split()))
    graph[v].append(u)
    graph[u].append(v)

dist= [-1 for i in range(n+1)]
dist[1]=0
son=[[] for i in range(n+1)]
queue=[1]
father=[0 for i in range(n+1)]
def bfs(u):
    for v in graph[u]:
        if dist[v]==-1:
            dist[v]=dist[u]+1
            son[u].append(v)
            father[v]=u
            queue.append(v)
    queue.pop(0)
    if len(queue)!=0:
        bfs(queue[0])

bfs(1)
road=[n]
tempfather=n
for i in range(dist[n]):
    road.append(father[tempfather])
    tempfather=father[tempfather]

di=len(road)
k=road[(di-2)/2]

def countson(u):
  count=0
  if len(son[u])==0:return 1
  for v in son[u]:
      count+=countson(v)
  return count+1

cs=countson(k)
cf=n-cs

if cs>=cf:print 'Snuke'
else:
    print 'Fennec'
Problem p03657 (python)

Fixed submission:
c= [int (i) for i in input().split()]
if sum(c)%3==0 or c[0]%3==0 or c[1]%3 ==0:
	print('Possible')
else: print('Impossible')

Buggy submission (verdict: Runtime Error):
if (a+b)%3 or a%3 or b%3==0:
    print ('Possible')
else: print('Impossible')