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

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
ans = 1
if N % 2 == 0:
    if len(A) != 2*len(set(A)):
        ans = 0
else:
    if A.count(0) == 1:
        A.remove(0)
        if len(A) != 2*len(set(A)):
            ans = 0
    else:
        ans = 0
if ans == 0:
    print(0)
else:
    print((2**(N//2))%(10**9+7))

Buggy submission (verdict: Runtime Error):
import sys

N = int(input())
A = [int(i) for i in input().split()]
A.sort()

if N % 2 != 0:
    if A[0] == 0:
        a = A[1:]
        j = 1
        k = 0
        for i in range(0, N//2 + 1, 2):
            if a[k] == a[k+1] == 2*j:
                j += 1
                k += 2
            else:
                print(0)
                sys.exit()
        print((2**(N//2)) % (10**9+7))
        
    else:
        print(0)
else:
    j = 1
    k = 0
    for i in range(0, N//2 + 1, 2):
        if A[k] == A[k+1] == 2*j -1:
            j += 1
            k += 2
        else:
            print(0)
            sys.exit()
    print((2**(N//2)) % (10**9+7))

Buggy submission (verdict: Runtime Error):
import sys

N = int(input())
A = [int(i) for i in input().split()]
A.sort()

if N % 2 != 0:
    if A[0] == 0:
        a = A[1:]
        j = 1
        for i in range(0, N//2 + 1, 2):
            if a[i] == a[i+1] == 2*j:
                j += 1
            else:
                print(0)
                sys.exit()
        print((2**(N//2)) % (10**9+7))
        
    else:
        print(0)
else:
    j = 1
    k = 0
    for i in range(0, N//2 + 1, 2):
        if A[k] == A[k+1] == 2*j -1:
            j += 1
            k += 2
        else:
            print(0)
            sys.exit()
    print((2**(N//2)) % (10**9+7))

Buggy submission (verdict: Runtime Error):
import sys

N = int(input())
A = [int(i) for i in input().split()]
A.sort()

if N % 2 != 0:
    if A[0] == 0:
        a = A[1:]
        j = 1
        for i in range(0, N//2 + 1, 2):
            if a[i] == a[i+1] == 2*j:
                j += 1
            else:
                print(0)
                sys.exit()
        print((2**(N//2)) % (10**9+7))
        
    else:
        print(0)
else:
    j = 1
    for i in range(0, N//2+1, 2):
        if A[i] == A[i+i] == 2*j -1:
            j += 1
        else:
            print(0)
            sys.exit()
    print((2**(N//2)) % (10**9+7))
Problem p03862 (python)

Fixed submission:
N, x = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
for i in range(N-1):
    if (a[i]+a[i+1]) > x and x < a[i] :
        ans += a[i+1]+a[i]-x
        
        a[i] = a[i]-(x-a[i+1])
        a[i+1] = 0
        
    elif (a[i]+a[i+1]) > x:
        ans += a[i+1]+a[i]-x
        
        a[i+1] = x-a[i]
        
print(ans)

Buggy submission (verdict: Runtime Error):
N, x = map(int, input().split())
a = [int(i) for i in input().split()]
ans = 0

if a[0] > x:
    ans += a[0] - x
    ans[0] = x

for i in range(1, N):
    if a[i] + a[i - 1] > x:
        ans += a[i] - (x - a[i - 1])
        a[i] = x - a[i - 1]

print(ans)
Problem p03943 (python)

Fixed submission:
abc = sorted(map(int, input().split()))
print ('Yes' if abc[0]+abc[1] == abc[2] else 'No')

Buggy submission (verdict: Runtime Error):
abc = sorted(list(map(int, input().split())))
print(`Yes` if abc[0]+abc[1] == abc[2] else `No`)

Buggy submission (verdict: Runtime Error):
abc = sorted(map(int, input().split()))
print(`Yes` if abc[0]+abc[1] == abc[2] else `No`)
Problem p03945 (python)

Fixed submission:
S = list(input())
flag = S[0]
flag_num = 0
ans = 0


for i in range(len(S)):
    if flag != S[flag_num]:
        ans += 1
        flag = S[flag_num]
    
    flag_num += 1
print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
s = s[0]
ans = 0
for i in S:
    if s != i:
        ans += 1
        s = i
print(ans)
Problem p03964 (python)

Fixed submission:
N = int(input())
T, A = 1, 1
for i in range(N):
    t, a = map(int, input().split())
    if T % t == 0:
        n1 = T // t
    else:
        n1 = T // t + 1
    if A % a == 0:
        n2 = A // a
    else:
        n2 = A // a + 1
    #print('--',n1, n2)
    n = max(n1, n2)
    T = n*t
    A = n*a
    #print('--------',T, A)
    
print(T+A)

Buggy submission (verdict: Runtime Error):
N = int(input())
TA = [[int(i) for i in input().split()] for i in range(N)]
Takahashi, Aoki = TA[0][0], TA[0][1]

for ta, ao in TA:
    if Takahashi <= ta and Aoki <= ao:
        Takahashi, Aoki = ta, ao
    else:
        num = max(math.ceil(Takahashi / ta), math.ceil(Aoki / ao))
        Takahashi, Aoki = num * ta, num * ao


print(Takahashi + Aoki)

Buggy submission (verdict: Runtime Error):
from math import ceil

N = int(input())
ta, ao = 1, 1
for i in range(N):
    T, A = map(int, input().split())
    if ta <= T and ao <= A:
        ta = T
        ao = A
    else:
        if ta % T == 0:
            n = ta//T
        else:
            n == ta//T + 1
        if ao % A == 0:
            m = ao//A
        else:
            m = ao//A + 1
        
        ta = max(n, m) * T
        ao = max(n, m) * A
        print(n)
print(ta+ao)

Buggy submission (verdict: Runtime Error):
N = int(input())
T, A = 1, 1
for i in range(N):
    t, a = map(int, input().split())
    if T % t == 0:
        n1 = T // t
    else:
        n1 = T // t + 1
    if A % a == 0:
        n2 = A // a
    else:
        n2 = T // a + 1
    n = max(n1, n2)
    #print(T,A)
    T = n*t
    A = n*a
    
print(sum(T+A))
Problem p03998 (python)

Fixed submission:
SA = list(input())
SB = list(input())
SC = list(input())
turn = 'a'

for i in range(301):
    if turn == 'a':
        
        if len(SA) == 0:
            print('A')
            break
        
        else:
            turn = SA[0]
            del SA[0]
    
    if turn == 'b':
        
        if len(SB) == 0:
            print('B')
            break
        
        else:
            turn =SB[0]
            del SB[0]
        
    if turn == 'c':
        if len(SC) == 0:
            print('C')
            break
        else:
            turn = SC[0]
            del SC[0]

Buggy submission (verdict: Runtime Error):
A = list(input())
B = list(input())
C = list(input())
ans = 1
if len(A) == 1 and A[0] == 'a':
    print('A')
else:
    card = A[0]
    del A[0]
    while ans == 1:
        
        if card == 'a':
            
            card = A[0]
            del A[0]
            
            if card == 'a' and len(A) == 0:
                print('A')
                ans = 0
                
        elif card == 'b':
            
            card = B[0]
            del B[0]
            
            if card == 'b' and len(B) == 0:
                print('B')
                ans = 0
                
        elif card == 'c':
            
            card = C[0]
            del C[0]
            
            if card == 'c' and len(C) == 0:
                print('C')
                ans = 0

Buggy submission (verdict: Runtime Error):
A = list(input())
B = list(input())
C = list(input())
ans = 1
if len(A) == 0:
    print(A)
else:
    card = A[0]
    del A[0]
    while ans == 1:
        
        if card == 'a':
            card = A[0]
            del A[0]
            if card == 'a' and len(A) == 0:
                print('A')
                ans = 0
        elif card == 'b':
            card = B[0]
            del B[0]
            if card == 'b' and len(B) == 0:
                print('B')
                ans = 0
        elif card == 'c':
            card = C[0]
            del C[0]
            if card == 'c' and len(C) == 0:
                print('C')
                ans = 0
Problem p04032 (python)

Fixed submission:
import sys
s = input()
N = len(s)


for i in range(N-2+1):
    if s[i] == s[i+1]:
        print(i+1, i+2)
        sys.exit()

        
for i in range(N-3+1):
    if s[i] == s[i+2]:
        print(i+1, i+3)
        sys.exit()

        
        
print(-1, -1)

Buggy submission (verdict: Runtime Error):
import sys
s = input()
N = len(s)


for i in range(N-2+1):
    if s[i] == s[i+1]:
        print(i+1, i+3)
        sys.exit()
        
for i in range(N-3+1):
    if s[i] == s[i+3]:
        print(i+1, i+4)
        sys.exit()
        
print(-1, -1)
Problem p04043 (python)

Fixed submission:
a, b, c = map(int,input().split())
if a == b == 5 and c==7:
    print('YES')
elif a== c == 5 and b==7:
    print('YES')
elif b == c == 5 and a==7:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
a, b, c = map(int,input().split())
if a+b+c=17:
    print('YES')
else:
    print('NO')
Problem p04046 (python)

Fixed submission:
H, W, A, B = map(int, input().split())

ans = 0 
MOD = 10**9 + 7
N = H + W - 2
fac = [1] * N
inv = [1] * N

# 階乗
for i in range(1, N):
    fac[i] = (fac[i - 1] * i) % MOD
 
# 逆元
inv[N - 1] = pow(fac[N - 1], MOD - 2, MOD)
for i in range(N - 1, 0, -1):
    inv[i - 1] = (inv[i] * i) % MOD
 
 
def f(x, y):
    ans = fac[x + y] * inv[x] * inv[y] % MOD
    return ans
 

for x in range(B, W):
    ans += f(x, H - A - 1) * f(W - 1 - x, A - 1)
    ans %= MOD
    
print(ans % MOD)

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

ans = 0 
MOD = 10**9 + 7
N = H + W - 2
fac = [1] * N
inv = [1] * N

# 階乗
for i in range(1, N):
    fac[i] = (fac[i - 1] * i) % MOD
 
# 逆元
inv[N - 1] = pow(fac[N - 1], mod - 2, mod)
for i in range(N - 1, 0, -1):
    inv[i - 1] = (inv[i] * i) % MOD
 
 
def f(x, y):
    ans = fac[x + y] * inv[x] * inv[y] % MOD
    return ans
 

for x in range(B, W):
    ans += f(x, H - A - 1) * f(W - 1 - x, A - 1)
    ans %= MOD
    
print(ans % MOD)
Problem p02641 (python)

Fixed submission:
x, n = map(int, input().split())
p = [int(_) for _ in input().split()]

not_in_p = [i for i in range(0, 102) if i not in p]
nip_temp = list(map(lambda s: abs(x - s), not_in_p))

address = nip_temp.index(min(nip_temp))
print(not_in_p[address])

Buggy submission (verdict: Runtime Error):
x, n = map(int, input().split())
p = [int(_) for _ in input().split()]

not_in_p = [i for i in range(0, 102) if i not in p]
nip_temp = list(map(lambda s: abs(x - s), not_in_p))

address = nip_temp.index(min(nip_temp))
print(p[address])
Problem p02741 (python)

Fixed submission:
k = int(input())
S = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(S[k-1])

Buggy submission (verdict: Runtime Error):
k = int(input())
S = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(S[k+1])
Problem p02818 (python)

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

if K <= A:
    print("{} {}".format(A - K, B))
elif K <= (A + B):
    print("{} {}".format(0,B - (K - A)))
else:
    print("{} {}".format(0, 0))

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

if k <= A:
    print(A - k, B)
elif k <= (A + B):
    print(0, B - (k - A))
else:
    print(0, 0)
Problem p02837 (python)

Fixed submission:
n = int(input())

g = [[-1 for j in range(n)] for i in range(n)]

for i in range(n):
	a = int(input())
	for _ in range(a):
		x, y = map(int, input().split())
		g[i][x-1] = y

ans = 0
for s in range(2**n):
	ok = True
	for i in range(n):
		if (s>>i&1) == 1:
			for j in range(n):
				if g[i][j] == -1: continue
				if (s>>j&1) != g[i][j]: ok = False
	if ok:
		ans = max(ans, bin(s).count("1"))

print(ans)

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

g = [[-1 for j in range(n)] for i in range(n)]

for i in range(n):
	a = int(input())
	for _ in range(a):
		x, y = map(int, input().split())
		g[i][x-1] = y

ans = 0
for s in range(2**n):
	ok = True
	for i in range(n):
		if (s>>i&1) == 1:
			for j in range(n):
				if g[i][j] != -1 and (s>>j&1) != g[i][j]:
                    ok = False
	if ok:
		ans = max(ans, bin(s).count("1"))

print(ans)

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

g = [[-1 for j in range(n)] for i in range(n)]

for i in range(n):
	a = int(input())
	for _ in range(a):
		x, y = map(int, input().split())
		g[i][x-1] = y

ans = 0
for s in range(2**n):
	ok = True
	for i in range(n):
		if (s>>i&1) == 1:
			for j in range(n):
				if g[i][j] != -1 && (s>>j&1) != g[i][j]:
                    ok = False
	if ok:
		ans = max(ans, bin(s).count("1"))

print(ans)

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

g = [[-1 for j in range(n)] for i in range(n)]

for i in range(n):
	a = int(input())
	for _ in range(a):
		x, y = map(int, input().split())
		g[i][x-1] = y

ans = 0
for s in range(2**n):
	ok = True
	for i in range(n):
		if (s>>i&1) == 1:
			for j in range(n):
				if g[i][j] != -1 && (s>>j&1) != g[i][j]:
                  ok = False
	if ok:
		ans = max(ans, bin(s).count("1"))

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
g = [[-1] * n] * n

for i in range(n):
	a = int(input())
	for _ in range(a):
		x, y = map(int, input().split())
		g[i][x-1] = y

ans = 0
for s in range(2**n):
	ok = True
	for i in range(n):
		if (s>>i&1) == 1:
			for j in range(n):
				if g[i][j] != -1 and (s>>j&1) != g[i][j]:
                    ok = False
	if ok:
		ans = max(ans, bin(s).count("1"))

print(ans)
Problem p03068 (python)

Fixed submission:
N=int(input())
s=list(input())
K=int(input())
t=s[K-1]
for i in range(N):
    if s[i]!=t:
        s[i]="*"
print("".join(s))

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

t=s[K-1]
for i in range(N):
    if s[i]!=t:
        s[i]="*"
print("".join(s))

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

t=s[K-1]
for i in range(N):
    if s[i]!=t:
        S[i]="*"
print("".join(s))
Problem p04044 (python)

Fixed submission:
n,l = map(int, input().split())
s = [input() for i in range(n)]
s.sort()
print("".join(s))

Buggy submission (verdict: Runtime Error):
n,l = map(int, input().split())
s = [input() for i in range(N)]
print("".join(s.sort()))
Problem p02983 (python)

Fixed submission:
import sys
l, r = map(int, input().split())
if r-l>=2019:
    print("0")
elif r%2019==0 or l%2019==0:
    print("0")
else:
    min = 2019
    for i in range(l,r):
        for j in range(i+1,r+1):
            tmp = i*j%2019
            if min > tmp:
                min = tmp
            if min == 0:
                print("0")
                sys.exit()
    print(min)

Buggy submission (verdict: Runtime Error):
from itertools import permutations
l, r = map(int,input().split())
a = []
for i in range(l,r+1):
    tmp = i%2019
    if tmp not in a:
perm = permutations(a,2)
min = 2019
for i in list(perm):
    tmp = i[0]*i[1]%2019
    if min > tmp:
        min = tmp
print(min)
Problem p03074 (python)

Fixed submission:
from itertools import accumulate

n, k = list(map(int,input().split(" ")))
s = input()


def findmax():
    cur=0
    l=[]
    prev = '1'
    for c in s:
        if prev ==c:
            cur+=1
        else:
            l.append(cur)
            cur = 1
        prev=c
    l.append(cur)
    if prev=='0':
        l.append(0)
    w = 2*k+1
    if len(l)<=w:
        return n
    sumup = [0]+list(accumulate(l))
    res = 0
    for i in range(0, len(l)-w+1,2):
        res = max(res,sumup[i+w]-sumup[i])
    return res
print(findmax())

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

def findmax(s,k):
    if len(s) == 1:
        return 1
    begin = s[0]
    l = [0]
    cur = 0
    for i in range(len(s)):
        if s[i]==begin:
            l[cur]+=1
        else:
            if begin == '0' : begin ='1'
            else: begin = '0'
            cur+=1
            l.append(1)
    r = 0
    if s[0] == '0':
        l = [0] + l
        r = 2*k
    else:
        r = 2*k+1
    sumup = [0]
    for i in range(len(l)):
        sumup.append(sumup[i]+l[i])
    return (max([sumup[i+r]-sumup[i] for i in range(0,len(sumup)-r,2)]))
print (findmax(s,k))

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

def findmax(s,k):
    if len(s) == 1:
        return 1
    begin = s[0]
    l = [0]
    cur = 0
    for i in range(len(s)):
        if s[i]==begin:
            l[cur]+=1
        else:
            if begin == '0' : begin ='1'
            else: begin = '0'
            cur+=1
            l.append(1)
    r = 0
    if s[0] == '0':
        l = [0] + l
        r = 2*k
    else:
        r = 2*k+1
    sumup = [0]
    for i in range(len(l)):
        sumup.append(sumup[i]+l[i])
    return (max([sumup[i+r]-sumup[i] for i in range(len(sumup)-r)]))
print (findmax(s,k))
Problem p03079 (python)

Fixed submission:
a, b, c = map(int,input().split())
if (a == b) and (b == c):
  print ("Yes")
else:
  print ("No")

Buggy submission (verdict: Runtime Error):
a, b, c = map(int,input().split())
if (a == b) and (b == c):
  print ("Yes")
 else:
  print ("No")
Problem p03085 (python)

Fixed submission:
b = input()
if b=='A':
    print ('T')
elif b == 'T':
    print ('A')
elif b == ('C'):
    print ('G')
else:
    print ('C')

Buggy submission (verdict: Runtime Error):
b = input()
if b=='A':
    print ('T')
elif b = 'T':
    print ('A')
elif b = ('C'):
    print ('G')
else:
    print ('C')
Problem p03738 (python)

Fixed submission:
a = int(input())
b = int(input())
if a > b:
    print("GREATER")
elif a < b:
    print("LESS")
else:
    print("EQUAL")

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
c, d = map(int, input().split())
if a == c or a == d or b == c or b == d:
    print("YES")
else:
    print("NO")
Problem p02630 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
q = int(input())
A = [0]*1000000

for i in a:
    A[i] += 1
    
ans = sum(a)

for i in range(q):
    b, c = map(int, input().split())
    ans = ans+((c-b)*(A[b]))
    print(ans)
    A[c] += A[b]
    A[b] = 0

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
q = int(input())
A = [0]*100000

for i in a:
    A[i] += 1
    
ans = sum(a)

for i in range(q):
    b, c = map(int, input().split())
    ans = ans+((c-b)*(A[b]))
    print(ans)
    A[c] += A[b]
    A[b] = 0

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
q = int(input())
A = [0]*100000

for i in a:
    A[i] += 1
    
ans = sum(a)

for i in range(q):
    b, c = map(int, input().split())
    ans = ans+((c-b)*(A[b]))
    print(ans)
    A[c] += A[b]
    A[b] = 0
Problem p02886 (python)

Fixed submission:
n = int(input())
d = list(map(int, input().split()))

import itertools
import numpy

a = []
for pair in itertools.combinations(d, 2):
    a.append(numpy.prod(pair))

print(sum(a))

Buggy submission (verdict: Runtime Error):
n = int(input())
d = list(map(int, input().split()))

import itertools
import numpy

a = []
for pair in itertools.combinations(d, 2):
    a.append(numpy.prod(pair))

print(sum(a))
Problem p02909 (python)

Fixed submission:
s = input()

if s == "Sunny":
    print("Cloudy")
if s == "Cloudy":
    print("Rainy")
if s == "Rainy":
    print("Sunny")

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

tenki = ["Sunny", "Cloudy", "Rainy"]
i = tenki.index(s)
i = (i%3)+1
print(tenki[i])
Problem p02934 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))

import math
def lcm(x, y):
    return (x*y)//math.gcd(x, y)
if n >=2:
    ue = lcm(a[0], a[1])
    if n >= 3:
        for i in range(2, n):
            ue = lcm(ue, a[i])
else:
    ue = a[0]

shita = 0
if n >=2:
    for i in range(len(a)):
        shita += ue//a[i]
else:
    shita = n

ans = ue / shita
print(f"{ans:.6f}")

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

import math
def lcm(x, y):
    return (x*y)//math.gcd(x, y)

ue = lcm(a[0], a[1])
if n >= 3:
    for i in range(2, n):
        ue = lcm(ue, a[i])

shita = 0
for i in range(len(a)):
    shita += ue//a[i]

ans = ue / shita
print(f"{ans:.6f}")

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

import math
def lcm(x, y):
    return (x*y)//math.gcd(x, y)

ue = lcm(a[0], a[1])
if n >= 3:
    for i in range(2, n):
        ue = lcm(ue, a[i])

shita = 0
for i in range(len(a)):
    shita += ue//a[i]

ans = ue / shita
print(f"{ans:.6f}")
Problem p02945 (python)

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

x = a + b
y = a - b
z = a*b

retsu = [x, y, z]
print(max(retsu))

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

x = a + b
y = a - b
z = a*b

if x != y and y != z and x != z:
    if x > y and x > z:
        print(x)
    else:
        if y > z:
            print(y)
        else:
            print(z)
if x == y and y ==  Z and x == Z:
    print(x, y, z)
else:
    pass
if x == y and x != Z:
    if x > z:
        print(x, y)
    else:
        print(z)
else:
    pass
if y == z and y != x:
    if y > x:
        print(y, z)
    else:
        print(x)
else:
    pass
if x == z and x != y:
    if x > y:
        print(x, z)
    else:
        print(z)
else:
    pass
Problem p03035 (python)

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

if a >= 13:
    ans = b
if 6 <= a and a < 13:
    ans = b//2
if a < 6:
    ans = 0
print(ans)

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

if a >= 13:
    ans = b
if 6 <= a < 13:
    ans = b//2
if a < 5:
    ans = 0
print(ans)
Problem p02786 (python)

Fixed submission:
def main():
	H = int(input())
	cnt = 0
	if H==1:
		print(1)
		exit()
	while 1:
		if H==1:
			break
		else:
			H = H//2
			cnt += 1
	ans = 0
	for i in range(cnt):
		ans += 2**i
	ans += 2**(i+1)
	print(ans)

if __name__ == '__main__':
	main()

Buggy submission (verdict: Runtime Error):
def main():
	H = int(input())
	cnt = 0
	while 1:
		if H==1:
			break
		else:
			H = H//2
			cnt += 1
	ans = 0
	for i in range(cnt):
		ans += 2**i
	ans += 2**(i+1)
	print(ans)

if __name__ == '__main__':
	main()
Problem p02845 (python)

Fixed submission:
def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    zero = 3
    ans = 1
    ls = [0 for _ in range(N)]
    mod = 1000000007
    for i in A:
        if i == 0:
            ans = (ans*zero)%mod
            zero -= 1
            ls[i] += 1
        else:
            ans = (ans*(ls[i-1]-ls[i]))%mod
            ls[i] +=1

    print(ans)
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
		def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    zero = 3
    ans = 1
    ls = [0 for _ in range(N)]
    mod = 1000000007
    for i in A:
        if i == 0:
            ans = (ans*zero)%mod
            zero -= 1
            ls[i] += 1
        else:
            ans = (ans*(ls[i-1]-ls[i]))%mod
            ls[i] +=1

    print(ans)
if __name__ == "__main__":
    main()
Problem p02900 (python)

Fixed submission:
from fractions import gcd
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

def main():
    a,b = map(int,input().split())
    c = gcd(a,b)
    cnt = factorization(c)
    if cnt[0][0]==1:
        print(len(cnt))
    else:
        print(len(cnt)+1)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
from math import gcd
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

def main():
    a,b = map(int,input().split())
    c = gcd(a,b)
    print(len(factorization(c))+1)

if __name__ == "__main__":
    main()