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

Fixed submission:
s = input()
maximum = [(0, [()])]

s = tuple(s)
for i in range(1, len(s) + 1):
    j = i - 1
    while j >= 0:
        max_count, previous = maximum[j]
        if max_count < 0:
            j -= 1
            continue
        current = s[j:i]
        if any(p != current for p in previous):
            if len(maximum) == i + 1:
                mc, blocks = maximum[i]
                if mc == max_count + 1:
                    blocks.append(current)
                break
            else:
                maximum.append((max_count + 1, [current]))
        j -= 1
    else:
        if len(maximum) != i + 1:
            maximum.append((-1, []))
    assert len(maximum) == i + 1

print(maximum[-1][0])

Buggy submission (verdict: Runtime Error):
def get_cache(chars, start, end, cache=dict()):
    pair = (start, end)
    block = cache.get(pair)
    if block is not None:
        return block
    else:
        block = chars[start:end]
        cache[pair] = block
        return block


def count_k(chars, previous_start, previous_end, cache=dict()):
    skip = len(chars)
    previous_len = previous_end - previous_start
    if previous_end + previous_len < len(chars):
        previous = get_cache(chars, previous_start, previous_end)
        suspicious_end = previous_end + previous_len
        suspicious = get_cache(chars, previous_end, previous_end + previous_len)
        if previous == suspicious:
            skip = suspicious_end

    max_k = 1
    for n in range(previous_end + 1, len(chars)):
        if n == skip:
            continue
        pair = (previous_end, n)
        if pair in cache:
            k = cache[pair]
        else:
            k = count_k(chars, previous_end, n) + 1
            cache[pair] = k
        if k == 1:
            continue
        if max_k >= k:
            break
        else:
            max_k = k
    return max_k


s = input()
print(count_k(list(s), 0, 0))

Buggy submission (verdict: Runtime Error):
def get_cache(chars, start, end, cache=dict()):
    pair = (start, end)
    block = cache.get(pair)
    if block is not None:
        return block
    else:
        block = chars[start:end]
        cache[pair] = block
        return block


def count_k(chars, previous_start, previous_end):
    skip = len(chars)
    previous_len = previous_end - previous_start
    if previous_end + previous_len < len(chars):
        previous = get_cache(chars, previous_start, previous_end)
        suspicious_end = previous_end + previous_len
        suspicious = get_cache(chars, previous_end, previous_end + previous_len)
        if previous == suspicious:
            skip = suspicious_end

    max_k = 1
    for n in range(previous_end + 1, len(chars)):
        if n == skip:
            continue
        k = count_k(chars, previous_end, n) + 1
        if k == 1:
            continue
        if max_k >= k:
            break
        else:
            max_k = k
    return max_k


s = input()
print(count_k(list(s), 0, 0))
Problem p02956 (python)

Fixed submission:
import sys
import array

from operator import itemgetter

def main():



	input = sys.stdin.readline


	md = 998244353
	n = int(input())
	tl=n+1
	
	ft=[0]*tl

	xy = [[0]*2 for _ in range(n)]
	for i in range(n):
		xy[i] = [int(item) for item in input().split()]
	xy.sort(key=itemgetter(0))
	yxi = [y for x, y in xy]

	*YS, = set(yxi)
	YS.sort()
	yxi= list(map({e: i for i, e in enumerate(YS)}.__getitem__, yxi))

	ct=[0]*(n+1)
	ct[0]=1
	for i in range(1,n+1):
		ct[i]=ct[i-1]*2%md

	cnt=tuple(ct)

	def upd(i):
		i+=1
		while(i<=n):
			ft[i]+=1
			i+=i&-i

	def get(i):
		i+=1
		ret=0
		while(i!=0):
		    ret+=ft[i]
		    i-=i&-i
		return ret

	def calc(get,upd):
		for i, y in enumerate(yxi):
			v = get(y); upd(y)
			p1 = cnt[v]; p0 = cnt[y - v]
			q1 = cnt[i - v]; q0 = cnt[(n - y - 1) - (i - v)]
			yield (p0 + p1 + q0 + q1 - (p0 + q1) * (p1 + q0)) % md


	print((sum(calc(get,upd))+n*cnt[n] - n)%md)

main()

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

from operator import itemgetter

def main():



	input = sys.stdin.readline


	md = 998244353
	n = int(input())
	tl=n+1
	
	ft=[0]*tl

	xy = [[0]*2 for _ in range(n)]
	for i in range(n):
		xy[i] = [int(item) for item in input().split()]
	xy.sort(key=itemgetter(0))
	yxi = [y for x, y in xy]

	*YS, = set(yxi)
	YS.sort()
	yxi= list(map({e: i for i, e in enumerate(YS)}.__getitem__, yxi))

	ct=[0]*(n+1)
	ct[0]=1
	for i in range(1,n+1):
		ct[i]=ct[i-1]*2%md

	cnt=tuple(ct)

	def upd(i):
		i+=1
		while(i<=len(ft)):
			ft[i]+=1
			i+=i&-i

	def get(i):
		i+=1
		ret=0
		while(i!=0):
		    ret+=ft[i]
		    i-=i&-i
		return ret

	def calc(get,upd):
		for i, y in enumerate(yxi):
			v = get(y); upd(y)
			p1 = cnt[v]; p0 = cnt[y - v]
			q1 = cnt[i - v]; q0 = cnt[(n - y - 1) - (i - v)]
			yield (p0 + p1 + q0 + q1 - (p0 + q1) * (p1 + q0)) % md


	print((sum(calc(get,upd))+n*cnt[n] - n)%md)

main()
Problem p03227 (python)

Fixed submission:
S = str(input()).rstrip()

if len(S) == 2:
  print (S)
else:
  print (S[::-1])

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

for i in range(K):
  if i % 2 == 0:
    B = B + A/2
    A = A/2
   else:
    A = A + B/2
    B = B/2 
print ('{} {}'.format(A,B))

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

if len(S) == 2:
	print (S)
else:
	new_str_list = list(reversed(S))
	#print(new_str_list)
    print (new_str_list.join(''))

Buggy submission (verdict: Runtime Error):
S= str(input())

if len(S) == 2:
  print (S)
 else:
	print (reversed(S))
Problem p03228 (python)

Fixed submission:
A, B, K = map(int, input().split())
for i in range(0, K):
    if(i & 1):
        if(B & 1):
            B -= 1
        A += B//2
        B //= 2
    else:
        if(A & 1):
            A -= 1
        B += A//2
        A //= 2
print("{0} {1}".format(A, B))

Buggy submission (verdict: Runtime Error):
A, B, K = map(int,input().rstrip().split())
 
for i in range(K):
	if i % 2 == 0:
		B = B + A/2
		A = A/2
	else:
		A = A + B/2
        B = B/2 
print ('{} {}'.format(A,B))

Buggy submission (verdict: Runtime Error):
A, B, K = map(int, input().split())
 
for i in range(K):
	if i % 2 == 0:
		B = B + A/2
		A = A/2
	else:
		A = A + B/2
        B = B/2 
print ('{} {}'.format(A,B))

Buggy submission (verdict: Runtime Error):
A,B,K = map(int(),input().rstrip().split())
 
for i in range(K):
	if i % 2 == 0:
    	B = B + A/2
    	A = A/2
	else:
   		A = A + B/2
    	B=B/2
print ('{} {}'.format(A,B))

Buggy submission (verdict: Runtime Error):
A,B,K = map(int(),input().rstrip().split())
 
for i in range(K):
  
  if i % 2 == 0:
    B = B + A/2
    A = A/2
   else:
   	A = A + B/2
    B=B/2
print ('{} {}'.format(A,B))

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

for i in range(K):
  
  i % 2 == 0:
    B = B + A/2
    A = A/2
   else:
    A = A + B/2
    B=B/2
print ('{} {}'.format(A,B))

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

for i in range(K):
  if i % 2 == 0:
    B = B + A/2
    A = A/2
   else:
    A = A + B/2
    B=B/2

print (A,B)
Problem p02939 (python)

Fixed submission:
s = [i for i in input()]
result = 1
i = 0

while i < len(s)-1:
  if s[i] == s[i+1]:
    i += 3
    result += 2
  else:
    i += 1
    result += 1
    
if i == len(s):
  result -= 1
elif i > len(s):
  result -= 2
  
print(result)

Buggy submission (verdict: Runtime Error):
s = [i for i in input()]
 
result = 1
i = 0
while i < len(s)-1:
  if s[i] == s[i+1]:
    i = i + 2
      if i > len(s):
        result = result - 1
  else:
    i = i + 1
  result = result + 1
  
print(result)

Buggy submission (verdict: Runtime Error):
s = [i for i in input()]

result = 1
i = 0
while i < len(s)-1:
  if s[i] == s[i+1]:
    i = i + 2
  else:
    i = i + 1
   result = resutl + 1
  if i > len(s):
    result = result - 1
    
print(result)
Problem p03623 (python)

Fixed submission:
x, a, b = map(int, input().split(' '))

dist_atox = abs(a-x)
dist_btox = abs(b-x)
y = dist_atox - dist_btox

print("A" if y < 0 else "B")

Buggy submission (verdict: Runtime Error):
    x, a, b = map(int, input().split(' '))
     
    dist_atox = abs(a-x)
    dist_btox = abs(b-x)
    y = dist_atox - dist_btox
     
    print("A" if dist_atox < dist_btox else "B")
Problem p03625 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split(' ')))

x = 0
y = 0
S = set()

for a in A:
    if a in S:
        if a < x:
            continue
        elif a > y:
            x = y
            y = a
        else:
            x = a
        S.remove(a)
    else:
        S.add(a)

print(x*y)

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


B = sorted(list(set(A)), reverse=True)

for i in range(len(B)):
    b = B[i]
    n = A.count(b)
    if n >= 2:
        if n >= 4:
            print(b*b)
            exit()
        elif:
            C = B[i+1:]
            for c in C:
                if  A.count(c) >= 2:
                    print(b*c)
                    exit()

print(0)

Buggy submission (verdict: Runtime Error):
    N = int(input())
    A = list(map(int, input().split(' ')))
     
    B = []
    C = []
    D = []
     
    for a in A:
        if a in B:
            C[B.index(a)] += 1
        else:
            B.append(a)
            C.append(1)
     
    I = len(B)
     
    for i in range(I):
        D.append([B[i], C[i]])
     
    D = sorted(D, reverse=True)
     
    i = 0
    while i < I:
        x = D[i][0]
        d = D[i][1]
        if d > 1:
            if d > 3:
                print(x**2)
                exit()
            else:
                while i < I:
                    i += 1
                    y = D[i][0]
                    d = D[i][1]
                    if d > 1:
                        print(x*y)
                        exit()
        else:
            i += 1
     
    print(0)

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


B = list(set(A))

while B:
    b = max(B)
    if A.count(b) >= 4:
        print(b**2)
        exit()
    elif A.count(b) >=2:
        B.remove(b)
        while B:
            c = max(B)
            if  A.count(c) >= 2:
                print(b*c)
                exit()
            else:
                B.remove(c)
    else:
        B.remove(c)

print(0)

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


while not len(A) == 0:
    a = max(A)
    if A.count(a) >= 4:
        print(a**2)
        exit()
    elif A.count(a) >=2:
        while a in A:A.remove(a)
        while not len(A) == 0:
            a2 = max(A)
            if  A.count(a2) >= 2:
                print(a*a2)
                exit()
            else:
                while a2 in A:A.remove(a)
    else:
        while a in A:A.remove(a)

print(0)
Problem p03633 (python)

Fixed submission:
n = int(input())
T = []
for i in range(n):
    T.append(int(input()))

T = sorted(T)
def gcd(a, b):
    while b > 0:
        t = a
        a = b
        b = t%b
    return(a)

def lcm(a, b):
    return(int(a / int(gcd(a, b))) * b)

LCM = T[0]
for i in range(n-1):
    LCM = lcm(LCM, T[i+1])

print(LCM)

Buggy submission (verdict: Runtime Error):
n = int(input())
T = []
for i in range(n):
    T.append(int(input()))

# def gcd(a, b):
#     if b==0:
#         return(a)
#     return(gcd(b, a%b))
def gcd(a, b):
    while b > 0:
        t = a
        a = b
        b = t%b
    return(a)

def lcm(a, b):
    return(int(a / int(gcd(a, b))) * b)

LCM = T[0]
for i in range(n-1):
    LCM = lcm(LCM, T[i+1])

print(LCM)

Buggy submission (verdict: Runtime Error):
n = int(input())
T = []
for i in range(n):
    T.append(int(input()))

# def gcd(a, b):
#     if b==0:
#         return(a)
#     return(gcd(b, a%b))
def gcd(a, b):
    while b > 0:
        t = a
        a = b
        b = t%b
    return(a)

def lcm(a, b):
    return(a / gcd(a, b) * b)

LCM = T[0]
for i in range(n-1):
    LCM = lcm(LCM, T[i+1])

print(int(LCM))

Buggy submission (verdict: Runtime Error):
n = int(input())
T = []
for i in range(n):
    T.append(int(input()))

def gcd(a, b):
    if b==0:
        return(a)
    return(gcd(b, a%b))

def lcm(a, b):
    return(a*b / gcd(a, b))

LCM = T[0]
for i in range(n-1):
    LCM = lcm(LCM, T[i+1])

print(int(LCM))
Problem p03160 (python)

Fixed submission:
def ans():
    dp = {i: 0 for i in range(n)}

    dp[1] = diff1[0]

    for i in range(2, n):
        dp[i] = min(dp[i-1] + diff1[i-1], dp[i-2] + diff2[i-2])
    return dp[n-1]


if __name__ == '__main__':
    n = int(input())
    dat = list(map(int, input().split()))

    diff1 = [abs(x-y) for (x, y) in zip(dat[1:], dat[:-1])]
    diff2 = [abs(x-y) for (x, y) in zip(dat[2:], dat[:-2])]

    print(ans())

Buggy submission (verdict: Runtime Error):
def rec(i, s):
    if i >= n-1:
        res = s
    elif i == n-2:
        res = rec(i+1, s + abs(dif1[i]))
    else:
        res = min(rec(i+1, s + abs(dif1[i])), rec(i+2, s + abs(dif2[i])))
    return res


if __name__ == '__main__':
    n = int(input())
    dat = list(map(int, input().split()))

    dif1 = [abs(x-y) for (x, y) in zip(dat[1:], dat[:-1])]
    dif2 = [abs(x-y) for (x, y) in zip(dat[2:], dat[:-2])]

    print(rec(0, 0))

Buggy submission (verdict: Runtime Error):
def rec(i, s):
    if i >= n-1:
        res = s
    elif i == n-2:
        res = rec(i+1, s + abs(dat[i+1] - dat[i]))
    else:
        res = min(rec(i+1, s + abs(dat[i+1] - dat[i])), rec(i+2, s + abs(dat[i+2]-dat[i])))
    return res


if __name__ == '__main__':
    n = int(input())
    dat = list(map(int, input().split()))

    print(rec(0, 0))
Problem p03005 (python)

Fixed submission:
N, K = (int(i) for i in input().split())

if K == 1:
    print(0)
else:
    print(N - K)

Buggy submission (verdict: Runtime Error):
# 残っているボールを1つ選んで回収、(a, b)
# (a-p, b-q) コスト0

import itertools

score = 1
p = 0
q = 0

n = int(input())
e = [[int(i) for i in input().split()] for i in range(n)]

if n == 1:
    print(1)
    exit()

arr = list(itertools.permutations(e))
for i, parent in enumerate(arr):
    if i == 0:
        for j, child in enumerate(parent):
            if j == 0:
                p = parent[j + 1][0] - child[0]
                q = parent[j + 1][1] - child[1]
                score = 1
                continue
            if not child[0] == parent[j-1][0] + p and not child[1] == parent[j - 1][1] + q:
                score += 1
    else:
        tmp_p = p
        tmp_q = q
        sc = score
        for j, child in enumerate(parent):
            if j == 0:
                p = parent[j + 1][0] - child[0]
                q = parent[j + 1][1] - child[1]
                score = 1
                continue
            if not child[0] == parent[j-1][0] + p and not child[1] == parent[j - 1][1] + q:
                score += 1
            if score > sc:
                p = tmp_p
                q = tmp_q
                score = sc
                continue

print(score)
Problem p02945 (python)

Fixed submission:
A,B=map(int,input().split())
print(max(A+B,A-B,A*B))

Buggy submission (verdict: Runtime Error):
A=int(input())
B=int(input())

answer1=A+B
answer2=A-B
answer3=A*B

print(max(answer1,answer2,answer3))

Buggy submission (verdict: Runtime Error):
input_A=input()
input_B=input()

A=int(input_A)
B=int(input_B)

answer1=A+B
answer2=A-B
answer3=A*B

print(max(answer1,answer2,answer3))
Problem p03106 (python)

Fixed submission:
A, B, K = map(int, input().split())
cnt = 0
for i in range(A, 0, -1):
  if A % i == 0 and B % i == 0:
    cnt += 1
  if cnt == K:
    print(i)
    break

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

count = 0
for j in range(1,100):
    if A % j == 0 and B % j == 0:
        count += 1
        if K == count:
            print(ans)
            break
Problem p03244 (python)

Fixed submission:
import collections

n = int(input())
u = list(map(int,input().split()))

hantei = 0

for i in range(0,n):
    if u[0] != u[i]:
        hantei = 1
        break

if hantei == 0:
    print(n // 2)
else:
   u1 = [] 
   u2 = [] 
   ans = 0
   for j in range(n):
       if j % 2 == 0:
           u2.append(u[j])
       else:
           u1.append(u[j])
   u1_list =collections.Counter(u1)
   u2_list =collections.Counter(u2)
   values1, counts1 = u1_list.most_common()[0]
   values2, counts2 = u2_list.most_common()[0]
   if values1 != values2:
       ans += n // 2 - counts1
       ans += n // 2 - counts2
   else:
       if len(u1_list) > 1 and len(u2_list) > 1:
           values3, counts3 = u1_list.most_common()[1]
           values4, counts4 = u2_list.most_common()[1]
           ans1 = n - counts1 - counts4
           ans2 = n - counts2 - counts3
           ans = max(ans1,ans2)
       elif len(u1_list) > 1 and len(u2_list) < 2:
           values3, counts3 = u1_list.most_common()[1]
           ans = n - counts2 - counts3
       elif len(u1_list) < 2 and len(u2_list) > 1:
           values3, counts3 = u2_list.most_common()[1]
           ans = n - counts1 - counts3

       ans = min(ans1,ans2)
   print(ans)

Buggy submission (verdict: Runtime Error):
import collections

n = int(input())
u = list(map(int,input().split()))

hantei = 0

for i in range(0,n):
    if u[0] != u[i]:
        hantei = 1
        break

if hantei == 0:
    print(n // 2)
else:
   u1 = [] 
   u2 = [] 
   ans = 0
   for j in range(n):
       if j % 2 == 0:
           u2.append(u[j])
       else:
           u1.append(u[j])
   u1_list =collections.Counter(u1)
   u2_list =collections.Counter(u2)
   values1, counts1 = u1_list.most_common()[0]
   values2, counts2 = u2_list.most_common()[0]
   if values1 != values2:
       ans += n // 2 - counts1
       ans += n // 2 - counts2
   else:
       if len(u1_list) > 1 and len(u2_list) > 1:
           values3, counts3 = u1_list.most_common()[0]
           values4, counts4 = u2_list.most_common()[0]
           ans1 = n - count1 - count4
           ans2 = n - count2 - count3
           ans = min(ans1,ans2)
       elif len(u1_list) > 1 and len(u2_list) < 2:
           values3, counts3 = u1_list.most_common()[0]
           ans = n - count2 - count3
       elif len(u1_list) < 2 and len(u2_list) > 1:
           values3, counts3 = u2_list.most_common()[0]
           ans = n - count1 - count3

       ans = min(ans1,ans2)
   print(ans)

Buggy submission (verdict: Runtime Error):
import collections

n = int(input())
u = list(map(int,input().split()))

hantei = 0

for i in range(1,n):
    if u[0] != u[i]:
        hantei = 1
        break

if hantei == 0:
    print(n // 2)
else:
   u1 = [] 
   u2 = [] 
   ans = 0
   for j in range(n):
       if j % 2 == 0:
           u2.append(u[j])
       else:
   u1_list =collections.Counter(u1)
   u2_list =collections.Counter(u2)
   values1, counts1 = u1_list.most_common()[0]
   values2, counts2 = u2_list.most_common()[0]
   ans += n // 2 - counts1
   ans += n // 2 - counts2
   print(ans)
Problem p03293 (python)

Fixed submission:
S = input()
T = input()


if S == T :
    ans = "Yes"
else:
    list_S =list(S) 
    list_T =list(T) 
    L = list_S
    L  =  tuple(L)
    ans = "No"
    #i:移動距離
    for i in range(1,len(S)+1):
        #移動
        for j in range(len(S)):
            list_S[j] = L[-i+j]
        if list_S == list_T :
            ans = "Yes"
            break
print(ans)

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

count = 0

for i in range(len(N)):
    count += int(N[i])
   
if int(N) % count == 0:
    print("Yes")
else:
    print("No")
Problem p03486 (python)

Fixed submission:
s = input()
t = input()

t1 = sorted(t,reverse=True)
s1 = sorted(s)

hantei = 0
count = 0

if len(s1) < len(t1):
    for i in range(len(s1)):
        count += 1
        if t1[i] > s1[i]:
            hantei = 1
            break
        elif t1[i] < s1[i]:
            break
        elif count == len(s1):
            hantei = 1
            break

else :
     for i in range(len(t1)):
        if t1[i] > s1[i]:
            hantei = 1
            break
        elif t1[i] < s1[i]:
            break

if hantei == 1:
    print("Yes")
else:
    print("No")

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

t1 = sorted(t,reverse=True)
s1 = sorted(s)

print(s1,t1)
hantei = 0
count = 0

for i in range(len(s1)):
    count += 1
    if t1[i] > s1[i]:
        hantei = 1
        break
    elif t1[i] < s1[i]:
        break
    elif count == len(s1):
        hantei = 1
        break

if hantei == 1:
    print("Yes")
else:
    print("No")

if hantei == 1:
    print("Yes")
else:
    print("No")

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

t1 = sorted(t,reverse=True)
s1 = sorted(s)

hantei = 0

for i in range(len(s1)):
    if t1[i] > s1[i]:
        hantei = 1
        break
    elif t1[i] < s1[i]:
        break

if hantei == 1:
    print("Yes")
else:
    print("No")
Problem p03564 (python)

Fixed submission:
N = int(input())
K = int(input())

ans = 1

for i in range(N):
    ans = min(ans * 2 , ans + K)

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
K = int(input())

ans = 1

for i in range(N):
    ans = min(ans * 2 , ans + K)

print(an
Problem p03632 (python)

Fixed submission:
A,B,C,D = list(map(int,input().split()))

if B - C > 0 and D - A > 0:
    start = max(A,C)
    stop = min(B,D)
    print(stop - start)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
A,B,C,D = list(map(int,input().split()))

if B <= C and D <= A:
    print(0)
else :
    ans_tmp1 = abs(B - C)
    ans_tmp2 = abs(D - C)
    if ans_tmp1 >= ans_tmp2:
        print(ans_tmp2)
    else:
        print(ans_tmp1))
Problem p03668 (python)

Fixed submission:
import sys
sys.setrecursionlimit(200000)
def dfs(u, fa = -1):
	res = 0
	for v in adj[u]:
		if v != fa:
			res ^= dfs(v, u) + 1
	return res
n = int(raw_input())
adj = [[] for i in xrange(n)]
for i in xrange(n - 1):
	x, y = [int(t) - 1 for t in raw_input().split()]
	adj[x].append(y)
	adj[y].append(x)
print 'Alice' if dfs(0) else 'Bob'

Buggy submission (verdict: Runtime Error):
def dfs(u, fa = 0):
	global adj
	res = 0
	for v in adj[u]:
		if v != fa:
			res ^= dfs(v, u) + 1
	return res

n = int(raw_input())
adj = [[] for i in range(n + 1)]
for i in range(n - 1):
	x, y = map(int, raw_input().split())
	adj[x].append(y)
	adj[y].append(x)
print 'Alice' if dfs(1) else 'Bob'
Problem p03035 (python)

Fixed submission:
A, B = map(int, input().split())
if A>=13:
  cost = B
elif A>=6 and A<=12:
  cost = B/2
else:
  cost = 0
print('%d' % cost)

Buggy submission (verdict: Runtime Error):
L, R = [[], []]
N, M = map(int, input().split())
for i in range(M):
  l, r = map(int, input().split())
  L.append(l)
  R.append(r)

minR = min(R)
maxL = max(L)
if minR <= maxL:
  count = 0
else:
  count = minR - maxL + 1
      
print('%d' % count)

Buggy submission (verdict: Runtime Error):
L, R = [[], []]
N, M = map(int, input().split())
for i in range(M):
  l, r = map(int, input().split())
  L.append(l)
  R.append(r)

minR = min(R)
maxL = max(L)
if minR <= maxL:
  count = 0
else:
  count = minR - maxL + 1
      
print('%d' % count)
Problem p03047 (python)

Fixed submission:
a,b = map(int, input().split())
print("{}".format(a-b+1))

Buggy submission (verdict: Runtime Error):
a,b = map(int, input(),split())
print("{}".format(a-b+1))
Problem p03455 (python)

Fixed submission:
a, b = map(int, input().split())
c = a * b
if c%2:
  print("Odd")
else:
  print("Even")

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

for i in list(range(0,3)):
  if d[i]=='1':
    c = c + 1
    
print("{}".format(c))
Problem p03080 (python)

Fixed submission:
n = int(input())
s = list(input())
r = s.count("R")
if n-r < r:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())
s = list(input())
r = s.count("R")
if s-r < r:
  print("Yes")
else:
  print("No")