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

Fixed submission:
# import sys; sys.stdin = open('input.txt')

n = int(raw_input())

a = raw_input()
b = raw_input()

res = n

for i in xrange(n):
    if a.endswith(b[:n-i]):
        break
    res += 1

print res

Buggy submission (verdict: Runtime Error):
import sys; sys.stdin = open('input.txt')

n = int(raw_input())

a = raw_input()
b = raw_input()

res = n

for i in xrange(n):
    if a.endswith(b[:n-i]):
        break
    res += 1

print res
Problem p03957 (python)

Fixed submission:
line = input()
if "C" in line and "F" in line:
    if line.index("C") < line.index("F"):
        print('Yes')
    elif line.index("C") > line.index("F"):        
        line1 = line[line.index("C"):]
        
        if "F" in line1:
            print('Yes')
        else:
            print('No')
    else:
        print('No')    
else:
    print('No')

Buggy submission (verdict: Runtime Error):
k_t = input().split()
k = int(k_t[0])
t = int(k_t [1])
t_amount = input().split(' ')
 
while True:
    if t == 1:
        max = k
        break
    max = 0
    for i in range(t-1):
        if t_amount[i+1] >= t_amount [i]:
            max = t_amount[i+1]
        elif max == 0:
            max = t_amount[0]
    t_amount.remove(max)
 
    max2 = 0
    for i in range(t-2):
        if t_amount[i+1] >= t_amount [i]:
            max2 = t_amount[i+1]
        elif max2 == 0 :
            max2 = t_amount[0]
    t_amount.remove(max2)
    if max2 == "0":
        break
    else:
        max = int(max) -1
        max2 = int(max2) -1
        t_amount.append(str(max))
        t_amount.append(str(max2))
 
if max == "0":
    print(0)
else:
    print(int(max)-1)
Problem p03992 (python)

Fixed submission:
line = list(input())
line.insert(4,' ')
final = ''.join(line)
print(final)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = input().split(' ')
t = 0
for o in range(n):
    i = o + 1
    b = int(a[o]) - i
    if i == int(a[o + b]):
      t += 1
print(int(t / 2))

Buggy submission (verdict: Runtime Error):
n = int(input())
l = input().split(' ')
t_l =[]
for i in range(0,n):
   t = i + int(l[i])
   t_l.append(t)
a = 0
for i in range(n *2 -1):
    if t_l.count(i) == 2:
        a += 1
print(a)

Buggy submission (verdict: Runtime Error):
n = int(input())
line = input().split(' ')
total_list =[]
for i in range(0,n):
   total = i + int(line[i])
   total_list.append(total)
a = 0
for i in range(n *2 -1):
    if total_list.count(i) == 2:
        a += 1
print(a)

Buggy submission (verdict: Runtime Error):
n = int(input())
line = input().split(' ')
total_list =[]
for i in range(0,n):
   total = i + int(line[i])
   total_list.append(total)
answer = 0
for i in range(n *2 -1):
    if total_list.count(i) == 2:
        answer += 1
print(answer)
Problem p03964 (python)

Fixed submission:
import math
from decimal import Decimal

N = int(input())
T, A = [Decimal(x) for x in input().split()]

for i in range(1,N):
        T2, A2 = [Decimal(x) for x in input().split()]
        n = Decimal(max(math.ceil(T/T2),math.ceil(A/A2)))
        T = T2 * n
        A = A2 * n

print(T+A)

Buggy submission (verdict: Runtime Error):
import math
from decimal import Decimal

N = int(input())
T, A = [Decimal(x) for x in input().split()]

for i in range(1,N):
        T2, A2 = [Decimal(x) for x in input().split()]
        n = max(math.ceil(T/T2),math.ceil(A/A2)
        T = T2*n
        A = A2*n

print(T + A)

Buggy submission (verdict: Runtime Error):
import math
from decimal import Decimal

N = int(input())
T, A = [int(x) for x in input().split()]

for i in range(1,N):
        T2, A2 = [int(x) for x in input().split()]
        n = max(math.ceil(Decimal(T)/Decimal(T2)),math.ceil(Decimal(A)/Decimal(A2))
        T = T2*n
        A = A2*n

print(T + A)

Buggy submission (verdict: Runtime Error):
import math
from decimal import Decimal

N = int(input())
T, A = [int(x) for x in input().split()]

for i in range(1,N):
        T2, A2 = [int(x) for x in input().split()]
        print('i= ',i)
        n = max(math.ceil(Decimal(T)/Decimal(T2)),math.ceil(Decimal(A)/Decimal(A2))
        print('n= ',n)
        T = T2*n
        A = A2*n
        print('T= ',T)
        print('A= ',A)

print(T + A)
Problem p03957 (python)

Fixed submission:
import re

m = input()

m2 = re.search('C[A-Z]*F', m)

if m2:
    
    print ("Yes")

else:
    print ("No")

#print (m2)

Buggy submission (verdict: Runtime Error):
s = input().split()

size = []
for n in s:
    size.append(int(n))

s2 = input().split()

ss = []
for n in s2:
    ss.append(int(n))

if size[0] % 2 == 0:
    k = size[0]/2
else:
    k = (size[0] + 1) /2

l = 0
m = 3

for i in ss:
    if i > k:
        l+=1
        while i > int((m-1) * size[0] / m) and m <= size[0]:
            m+=1
         
            l+=1

print (l)
Problem p03957 (python)

Fixed submission:
s = input()
if "C" in s and "F" in s:
  a = s.index("C")
  b = s.rindex("F")
  if a < b:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
s = input()
if "C" in s and "F" in s:
  a = s.lindex("C")
  b = s.rindex("F")
  if a < b:
    print("Yes")
  else:
    print("No")
else:
  print("No")
Problem p03957 (python)

Fixed submission:
S = raw_input()

pc = S.index("C") if "C" in S else -1
pf = S.rindex("F") if "F" in S else -1
if pc > -1 and pf > -1 and pc < pf:
    print "Yes"
else:
    print "No"

Buggy submission (verdict: Runtime Error):
from random import random
import math
import re
import fractions

S = raw_input()
pc = S.index("C")
pf = S.rindex("F")
if pc > -1 and pf > -1 and pc < pf:
    print "Yes"
else:
    print "No"
Problem p03957 (python)

Fixed submission:
s = input()

cl = []
fl = []

for i, c_test in zip(range(len(s)), s):
    if c_test == 'C':
        cl.append(i)

for i, f_test in zip(range(len(s)), s):
    if f_test == 'F':
        fl.append(i)
if len(cl) == 0 or len(fl) == 0:
    print("No")    
elif max(fl) > min(cl):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
s = input()

cl = []
fl = []

for i, c_test in zip(range(len(s)), s):
    if c_test == 'C':
        cl.append(i)

for i, f_test in zip(range(len(s)), s):
    if f_test == 'F':
        fl.append(i)    
if max(fl) > min(cl):
    print("Yes")
else:
    print("No")
Problem p03970 (python)

Fixed submission:
# get a string
s = raw_input()

n = 0
for i, c in enumerate('CODEFESTIVAL2016'):
    if s[i] != c:
        n+=1
print n

Buggy submission (verdict: Runtime Error):
# get a string
s = raw_input()

n = 0
for i, c in enumerate('CODEFESTIVAL2016'):
    if s[i] != c:
        n++
print n
Problem p03962 (python)

Fixed submission:
paints = raw_input().split()
paints_uniq = list(set(paints))
print(len(paints_uniq))

Buggy submission (verdict: Runtime Error):
n, k = map(int, raw_input().split())
ans =  k * ((k-1)**(n-1))
print(ans)
Problem p03957 (python)

Fixed submission:
s = raw_input()
flag = 0
for i in s:
    if flag == 0 and i == 'C': flag = 1
    elif flag == 1 and i == 'F': flag = 2
    else: continue
print 'Yes' if flag == 2 else 'No'

Buggy submission (verdict: Runtime Error):
s = raw_input()
flag = 0
for i in s:
    if flag == 0 and i == 'C': flag = 1
    elif: flag == 1 and i == 'F': flag = 2

print 'Yes' if flag == 2 else 'No'
Problem p03970 (python)

Fixed submission:
s = raw_input()
r = 'CODEFESTIVAL2016'
cnt = 0
for i in xrange(len(s)):
    cnt += 1 if s[i] != r[i] else 0
print cnt

Buggy submission (verdict: Runtime Error):
neighbor = lambda c, w, h: filter(
    lambda b: 0 <= b[0] <= w and 0 <= b[1] <= h,
    [
        (c[0]-1, c[1]),
        (c[0]+1, c[1]),
        (c[0], c[1]-1),
        (c[0], c[1]+1)
    ]
)

t = raw_input()
W, H = map(int, t.split(' '))
p, q = [], []
for i in xrange(W):
    p.append(int(raw_input()))
for j in xrange(H):
    q.append(int(raw_input()))

has = [[False for i in xrange(H+1)] for j in xrange(W+1)]
has[0][0] = True
Next = [(1, 0), (0, 1)]

cost = 0
for i in xrange(W*H+W+H):
    Min = 100000005
    choose = None
    Next.sort(key=lambda a: min(p[a[0]-1] if a[0] > 0 else 100000005, q[a[1]-1] if a[1] > 0 else 100000005))
    choose = Next[-1]
    Min = min(p[choose[0]-1] if choose[0] > 0 else 100000005, q[choose[1]-1] if choose[1] > 0 else 100000005)
    # for each in Next:
    #     if each[0] > 0:
    #         if p[each[0]-1] < Min:
    #             choose = each
    #             Min = p[each[0]-1]
    #     if each[1] > 0:
    #         if q[each[1]-1] < Min:
    #             choose = each
    #             Min = q[each[1]-1]
    has[choose[0]][choose[1]] = True
    Next = Next[:-1]
    cost += Min
    for every in neighbor(choose, W, H):
        # print every
        if not has[every[0]][every[1]] and every not in Next:
            Next.append(every)
print cost
Problem p03972 (python)

Fixed submission:

import bisect
cost = 0
t = raw_input()
W, H = map(int, t.split(' '))
p, q = [], []
sum_p = []
for i in xrange(W):
    tmp = int(raw_input())
    p.append((i, tmp))
p.sort(key=lambda a: a[1])
pp = [each[1] for each in p]
for i in xrange(W):
    if not sum_p:
        sum_p.append(pp[i])
    else:
        sum_p.append(sum_p[-1]+pp[i])
cost += sum(pp)
for j in xrange(H):
    new = int(raw_input())
    cost += new
    minus = bisect.bisect_right(pp, new)
    cost += (W-minus) * new
    cost += sum_p[minus-1] if minus > 0 else 0

print cost

Buggy submission (verdict: Runtime Error):
neighbor = lambda c, w, h: filter(
    lambda b: 0 <= b[0] <= w and 0 <= b[1] <= h,
    [
        (c[0]-1, c[1]),
        (c[0]+1, c[1]),
        (c[0], c[1]-1),
        (c[0], c[1]+1)
    ]
)

def q_c():
t = raw_input()
W, H = map(int, t.split(' '))
p, q = [], []
for i in xrange(W):
    p.append(int(raw_input()))
for j in xrange(H):
    q.append(int(raw_input()))

has = [[False for i in xrange(H+1)] for j in xrange(W+1)]
has[0][0] = True
Next = [(1, 0), (0, 1)]

cost = 0
for i in xrange(W*H+W+H):
    Min = 100000005
    choose = None
    Next.sort(key=lambda a: min(p[a[0]-1] if a[0] > 0 else 100000005, q[a[1]-1] if a[1] > 0 else 100000005))
    choose = Next[-1]
    Min = min(p[choose[0]-1] if choose[0] > 0 else 100000005, q[choose[1]-1] if choose[1] > 0 else 100000005)
    # for each in Next:
    #     if each[0] > 0:
    #         if p[each[0]-1] < Min:
    #             choose = each
    #             Min = p[each[0]-1]
    #     if each[1] > 0:
    #         if q[each[1]-1] < Min:
    #             choose = each
    #             Min = q[each[1]-1]
    has[choose[0]][choose[1]] = True
    Next = Next[:-1]
    cost += Min
    for every in neighbor(choose, W, H):
        # print every
        if not has[every[0]][every[1]] and every not in Next:
            Next.append(every)
print cost
Problem p03992 (python)

Fixed submission:
s = input()
print(s[:4] + " " + s[4:])

Buggy submission (verdict: Runtime Error):
from collections import deque

def next_char_ascii_num(c, k):
    n = ord(c) + (k % 26)
    if n <= 122:
        return n
    else:
        return n % 123 + 97

s = input()
k = int(input())
d = deque()
l = len(s)

for i, x in enumerate(s):

    if k <= 0:
        l = i
        break

    else:
        if k >= 25 and l != 1:
            d.append(97)
            k -= (26 - (ord(x) - 97))
        else:
            v =[next_char_ascii_num(x, y) for y in range(k + 1)]
            min_index = v.index(min(v))
            d.append(v[min_index])
            k -= min_index


if k > 0:
    d[-1] = next_char_ascii_num(chr(d[-1]), k)
else:
    d += s[l:]

print("".join([chr(x) for x in d]))

Buggy submission (verdict: Runtime Error):
from collections import deque

def next_char_ascii_num(c, k):
    n = ord(c) + (k % 26)
    if n <= 122:
        return n
    else:
        return n % 123 + 97

s = input()
k = int(input())
d = deque()
l = len(s)

for x in s:

    if k == 0:
        d.append(ord(x))

    else:
        if k >= 25 and l != 1:
            d.append(97)
            k -= (26 - (ord(x) - 97))
        else:
            v =[next_char_ascii_num(x, y) for y in range(k + 1)]
            min_index = v.index(min(v))
            d.append(v[min_index])
            k -= min_index

if k > 0:
    d[-1] = next_char_ascii_num(chr(d[-1]), k)

print("".join([chr(x) for x in d]))
Problem p03960 (python)

Fixed submission:
H, W = map(int, raw_input().split())
a = [raw_input().strip() for _ in xrange(H)]
a = map(''.join, zip(*a))
ans = 0
def solve(a, c):
    shift = [[0] * (H+1) for _ in xrange(H+1)]
    for i in reversed(xrange(H)):
        for j in reversed(xrange(H)):
            shift[i][j] = shift[i+1][j+1] + int(a[H-1-i] == c[H-1-j])
    dp = [[float('inf')] * (H+1) for _ in xrange(H+1)]
    for i in xrange(H+1):
        for j in xrange(H+1):
            b = 2147483647
            if i == j == 0:
                b = 0
            if i > 0:
                b = min(b, dp[i-1][j] + shift[i-1][j])
            if j > 0:
                b = min(b, dp[i][j-1] + shift[i][j-1])
            dp[i][j] = b
    #print a, c, shift
    return dp[H][H]
for i in xrange(W-1):
    i1 = i
    i2 = i+1
    ans += solve(a[i1], a[i2])
print ans

Buggy submission (verdict: Runtime Error):
class Bit:
    def __init__(self, n):
        sz = 1
        while n >= sz:
            sz *= 2
        self.size = sz
        self.data = [0]*sz

    def sum(self, i):
        assert i > 0
        s = 0
        while i > 0:
            s += self.data[i]
            i -= i & -i
        return s

    def add(self, i, x):
        assert i > 0
        while i < self.size:
            self.data[i] += x
            i += i & -i

import bisect
N = int(raw_input())
a = [int(x)-1 for x in raw_input().split()]
weight = [1] * N
M = 10**9+7
def factorial(n):
    acc = 1
    for i in xrange(1, 1 + n):
        acc = (acc * i) % M
    return acc
def inv(n):
    return pow(n, M-2, M)
for i in xrange(N-1):
    weight[N-2-i] = (weight[N-1-i] * (i+1)) % M
missing = list(set(xrange(N)) - set(a))
missing.sort()
n_missing = len(missing)
sum_missing = sum(missing)
avg_missing = sum_missing * inv(n_missing)
n_present = N - n_missing
n_rows = factorial(n_missing)
acc = 0
i_missing = 0
i_present = 0
missing_lt_tot = 0
#present_values = []
present_values_bit = Bit(N+5)
inv_n_missing = inv(n_missing)
inv_2 = inv(2)
for i, (w, x) in enumerate(zip(weight, a)):
    if x == -1:
        ai = avg_missing
        bi = (i_missing * inv_2 + i_present - missing_lt_tot * inv_n_missing) % M
        i_missing += 1
    else:
        ai = x
        #bi = sum(1 for present_value in present_values if present_value < x)
        bi = present_values_bit.sum(x + 1)
        #present_values.append(x)
        present_values_bit.add(x + 2, 1)
        '''
        missing_lt = 0
        for j in missing:
            if j < a[i]:
                missing_lt += 1
        '''
        missing_lt = bisect.bisect(missing, a[i])
        missing_lt_tot += missing_lt
        #print '@', missing_lt, n_missing, i_missing, n_rows
        bi += missing_lt * inv_n_missing * i_missing
        bi %= M
        i_present += 1
    #print x, (ai * n_rows) % M, (bi * n_rows) % M, w
    acc = (acc + (((ai - bi) * n_rows) % M) * w) % M
print (acc + n_rows) % M
Problem p03962 (python)

Fixed submission:
paint = map(int,input().split())
print(len(set(paint)))

Buggy submission (verdict: Runtime Error):
n,k = map(int, input().split())
p=k
for i in range(n-1):
  p *= k-1
print(p)
Problem p03963 (python)

Fixed submission:
n,k = map(int, input().split())
p=k
for i in range(n-1):
  p *= k-1
print(p)

Buggy submission (verdict: Runtime Error):
def fib(n):
  if n <= 1:
    return 1
  return fib(n-1)*n

n,k = map(int, input().split())
print(int(fib(k)/fib(k-n)))

Buggy submission (verdict: Runtime Error):
def fib(n):
  if n == 1:
    return 1
  else:
    return fib(n-1)*n

n,k = map(int, input().split())
print(int(fib(k)/fib(k-n)))
Problem p04043 (python)

Fixed submission:
def test(): 
  arr = input()
  arr = arr.split()
  arr = sorted(arr)
  if arr==['5', '5', '7']:
    print("YES")
  else:
    print("NO")  
test()

Buggy submission (verdict: Runtime Error):
def test(): 
  arr = input()
  arr = [int(i) for i in arr]
  arr = sorted(arr)
  if arr==[5, 5, 7]:
    print("YES")
  else:
    print("NO")  
test()
Problem p03962 (python)

Fixed submission:
import sys
import math
from functools import reduce
import bisect


def getN():
    return int(input())


def getNM():
    return map(int, input().split())


def getList():
    return list(map(int, input().split()))


def input():
    return sys.stdin.readline().rstrip()


# input = sys.stdin.buffer.readline

def index(a, x):
    i = bisect.bisect_left(a, x)
    if i != len(a) and a[i] == x:
        return i
    return False


#############
# MAIN CODE #
#############

a, b, c = getNM()
print(len({a, b, c}))

Buggy submission (verdict: Runtime Error):
a, b, c = getNM()
print(len({a, b, c}))
Problem p04030 (python)

Fixed submission:
arr = input()
new = ""
for x in arr:
    if x == "B":
        if new:
            new = new[:-1]
    else:
        new += x
print(new)

Buggy submission (verdict: Runtime Error):
arr = input()
arr = ''.join(reversed(arr))
print(arr[:arr.index('B')])
Problem p04012 (python)

Fixed submission:
import string
w = input()
if all([w.count(low_alpha) % 2 == 0 for low_alpha in string.ascii_lowercase ]):
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
import sys

while True:
    w = input()

    if not w.islower():
        continue

    if len(w) >= 100:
        continue

    for n_alpha in "abcdefghijklmnopqrstuvwxyz":
        count_alpha = w.count(n_alpha)
        if count_alpha % 2 == 1:
            print('No')
        else:
            print('Yes')
        break
    break

sys.exit()

Buggy submission (verdict: Runtime Error):
import sys

def input_w():
    w = input()

    while w.islower():

        length = len(w)
        if length >= 100:
            return input_w()

        for n_alpha in "abcdefghijklmnopqrstuvwxyz":
            count_alpha = w.count(n_alpha)
            if count_alpha % 2 == 1:
                print('No')
                return input_w()

        print('Yes')
        sys.exit()

    return input_w()

w=input_w()
Problem p04014 (python)

Fixed submission:
import sys, math
n = int(input())
s = int(input())

def f(b, n):
    if n < b:
        return n
    else:
        return f(b, n//b) + n % b

if s == n:
    print(n + 1)
    sys.exit()

sqrt_n = math.floor(math.sqrt(n))
for b in range(2, sqrt_n + 1):
    if f(b, n) == s:
        print(b)
        sys.exit()
for p in range(1, sqrt_n + 1):
    p_sum= sqrt_n + 1 - p
    b = int( (n -s)/p_sum ) + 1
    if b >= 2 and f(b, n) == s:
        print(b)
        sys.exit()
print('-1')

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

n = int(input())
s = int(input())

def f(b, n):
    if n < b:
        return n
    else:
        return f(b, n//b) + n % b

if s == n:
    print(n + 1)
    sys.exit()
elif s > n:
    print('-1')
    sys.exit()

sqrt_n = math.floor(math.sqrt(n))

for b in range(2, sqrt_n + 1):
    if f(b, n) == s:
        print(b)
        sys.exit()

for p in range(1, sqrt_n + 1):
    P = sqrt_n + 1 - p
    b = int( (n -s)/P ) + 1
    if f(b, n) == s and b >= 2:
        print(b)
        sys.exit()

print('-1')

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

n = int(input())
s = int(input())

def f(b, n):
    if n < b:
        return n
    else:
        return f(b, math.floor(n/b)) + n % b

if s == n:
    print(n + 1)
    sys.exit()
elif s > n:
    print('-1')
    sys.exit()

for b in range(2, math.floor(math.sqrt(n))+1):
    if f(b, n) == s:
        print(b)
        sys.exit()

for p in range(math.floor(math.sqrt(n)+1)):
    P = math.floor(math.sqrt(n)) + 1 - p
    b = int( (n -s)/P ) + 1
    if f(b, n) == s and b >= 2:
        print(b)
        sys.exit()

print('-1')
Problem p04029 (python)

Fixed submission:
N = int(input())
list_N = [ x for x in range(1, N+1) ]
print( sum(list_N) )

Buggy submission (verdict: Runtime Error):
N = input()
a = list(map(int,input().split()))
cost_sum = 0
print_cost = 20000

for a_i in range(min(a), max(a)+1):
    for a_j in a:
        cost_sum += ((a_j - a_i) ** 2)
    if print_cost > cost_sum:
        print_cost = cost_sum

print(print_cost)
Problem p04030 (python)

Fixed submission:
s = input()
output = []

for n in range(len(s)):
    if s[n] == '1' or s[n] == '0':
        output.append(s[n])
    elif s[n] == 'B' and output != []:
        backspace = len(output)-1
        output = output[:backspace]
print(''.join(output))

Buggy submission (verdict: Runtime Error):
import sys

while True:
    s = input()

    if s == '':
        continue
    elif len(str(s)) >= 10:
        continue
    else:
        s_input = [x for x in s]

    s_output = []

    for n in s_input:
        if n == '1' or n == '0':
            s_output.append(n)
        elif n == 'B':
            backspace = len(s_output)-1
            s_output = s_output[:backspace]

    if '0'  or '1' in s_output:
        print(''.join(s_output))
        break

sys.exit()
Problem p03997 (python)

Fixed submission:
a = int(input())
b = int(input())
h = int(input())

print("%d" % ((a+b)*h/2))

Buggy submission (verdict: Runtime Error):
dk = {}
dk["a"] = input()
dk["b"] = input()
dk["c"] = input()

n = "a"
while True:
    if len(dk[n]) == 0:
        print(n.upper())
        break
    nn = dk[n][0]
    dk[n] = dk[n][1:]
    n = nn

Buggy submission (verdict: Runtime Error):
dk = {}
dk["a"] = input()
dk["b"] = input()
dk["c"] = input()

n = "a"
while true:
    if len(dk[n]) == 0:
        return print(n.upper())
        break
    nn = dk[n][0]
    dk[n] = dk[n][1:]
    n = nn
Problem p03962 (python)

Fixed submission:
M = map(int, raw_input().split())
# M = [1,2,2]
print len(set(M))

Buggy submission (verdict: Runtime Error):
import numpy as np
import math
N=input()
T=[]
A=[]
for i in range(N):
    Ti,Ai=map(int,raw_input().split())
    T.append(Ti)
    A.append(Ai)
 
Tn=1
An=1
dp = np.zeros(N)
dp[0] = 1
 
for i in range(1,N):
    dp[i] = math.ceil(max(A[i]/A[i-1],T[i]/T[i-1])*dp[i-1])
 
print (T[-1]+A[-1])*dp[-1]
Problem p03963 (python)

Fixed submission:
N, K = map(int, raw_input().split())
# N, K = 10, 8
 
print K * (K-1) ** (N-1)

Buggy submission (verdict: Runtime Error):
N, K = map(int, raw_input().split())
# N, K = 10, 8

print (K * (K-1) ** (N-1))
Problem p03965 (python)

Fixed submission:
s=raw_input()

p=0

for i in range(len(s)):
    if s[i] == 'p':
        p += 1

print (len(s)//2 - p)

Buggy submission (verdict: Runtime Error):
s=raw_input()

p=0

for i in range(len(s)):
    if s[i] == 'p':
        p += 1

print (len(s)//2 - p)
Problem p03962 (python)

Fixed submission:
inp = raw_input()
print len(set(inp.strip().split(' ')))

Buggy submission (verdict: Runtime Error):
from sys import setrecursionlimit
from numpy import ceil


def _main():
    setrecursionlimit(1100)
    print int(sum(election(1.0, 1.0, input())))


def election(t_prev, a_prev, n):
    if n == 0:
        return t_prev, a_prev
    t, a = map(int, raw_input().split())

    mlt = max(ceil(t_prev / t), ceil(a_prev / a), 1)
    return election(t * mlt, a * mlt, n - 1)


if __name__ == '__main__':
    _main()
Problem p03962 (python)

Fixed submission:
a, b, c = map(int, raw_input().split())

colour_list = [a, b, c]
bought = []
count = 0
for x in colour_list:
    if x not in bought:
        bought.append(x)
        count += 1

print count

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

n, k = map(int, raw_input().split())

print k * (k-1) ** (n-1)
Problem p03998 (python)

Fixed submission:
# -*- coding: utf-8 -*-
s_a = [s for s in raw_input() if s != 'a']
s_b = [s for s in raw_input() if s != 'b']
s_c = [s for s in raw_input() if s != 'c']

x = 0
y = 0
z = 0
next_turn = 'A'

while x <= len(s_a) and y <= len(s_b) and z <= len(s_c):
    try:
        if next_turn == 'A':
            next_turn = s_a[x].upper()
            x += 1
        elif next_turn == 'B':
            next_turn = s_b[y].upper()
            y += 1
        else:
            next_turn = s_c[z].upper()
            z += 1
    except IndexError:
        print next_turn
        break

Buggy submission (verdict: Runtime Error):
player_list = ['a', 'b', 'c']
s = {player_list[n]: list(raw_input()) for n in player_list}

current_turn = player_list[0]

get_winner = lambda x, s: not s[x] and x.upper() or get_winner(s[x].pop(0), s)

print get_winner(current_turn, s)