Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):

import math

k = int(input())

cache = {}
ans = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1, k+1):
            key = tuple(sorted([a,b,c]))
            x = cache.get(key, math.gcd(math.gcd(a, b), c))
            ans = ans + x
            cache[key] =  x
print(ans)

Fixed submission:
import itertools
import math

k = int(input())
x = 0
for v in itertools.combinations_with_replacement(list(range(1, k+1)), 3):
    a, b, c = v
    x = x + math.gcd(math.gcd(a,b), c)

y = 0
for v in itertools.combinations(list(range(1, k+1)), 3):
    a, b, c = v
    y = y + math.gcd(math.gcd(a,b), c)

z = k * (1 + k) / 2
print( int(3 * x  + y * 3  -  2 * z))

Buggy python submission (verdict: Time Limit Exceeded):
import math

k = int(input())

cache = {}
ans = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1, k+1):
            ans = ans + cache.get( (a,b,c), math.gcd(math.gcd(a, b), c))
print(ans)

Fixed submission:
import itertools
import math

k = int(input())
x = 0
for v in itertools.combinations_with_replacement(list(range(1, k+1)), 3):
    a, b, c = v
    x = x + math.gcd(math.gcd(a,b), c)

y = 0
for v in itertools.combinations(list(range(1, k+1)), 3):
    a, b, c = v
    y = y + math.gcd(math.gcd(a,b), c)

z = k * (1 + k) / 2
print( int(3 * x  + y * 3  -  2 * z))
Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
q = list(range(1, 10))
i = 0

while i < k:
    i += 1

    org = q.pop(0)
    x = org % 10

    if x != 0:
        q.append(10 * org + x - 1)

    q.append( 10 * org + x)

    if x != 9:
        q.append(10 * org + x + 1)
print(org)

Fixed submission:
import collections

k = int(input())
q = collections.deque(list(range(1, 10)))
i = 0

while i < k:
    i += 1

    org = q.popleft()
    x = org % 10

    if x != 0:
        q.append(10 * org + x - 1)

    q.append( 10 * org + x)

    if x != 9:
        q.append(10 * org + x + 1)
print(org)

Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
q = list(range(1, 10))
i = 0

while i < k:
    i += 1

    org = q.pop(0)
    x = org % 10

    if x != 0:
        q.append(10 * org + x - 1)

    q.append( 10 * org + x)

    if x != 9:
        q.append(10 * org + x + 1)
print(org)

Fixed submission:
import collections

k = int(input())
q = collections.deque(list(range(1, 10)))
i = 0

while i < k:
    i += 1

    org = q.popleft()
    x = org % 10

    if x != 0:
        q.append(10 * org + x - 1)

    q.append( 10 * org + x)

    if x != 9:
        q.append(10 * org + x + 1)
print(org)

Buggy python submission (verdict: Time Limit Exceeded):

k = int(input())
q = list(map(str, range(1, 10)))
i = 0

while i < k:
    i += 1

    org = q.pop(0)
    x = int(org[-1])

    if x != 0:
        q.append(org + str(x- 1))

    q.append(org + str(x))

    if x != 9:
        q.append(org + str(x + 1))
print(org)

Fixed submission:
import collections

k = int(input())
q = collections.deque(list(range(1, 10)))
i = 0

while i < k:
    i += 1

    org = q.popleft()
    x = org % 10

    if x != 0:
        q.append(10 * org + x - 1)

    q.append( 10 * org + x)

    if x != 9:
        q.append(10 * org + x + 1)
print(org)

Buggy python submission (verdict: Time Limit Exceeded):

k = int(input())
q = list(map(str, range(1, 10)))
i = 0

while i < k:
    i += 1

    org = q.pop(0)
    x = int(org[-1])

    if x != 0:
        q.append(org + str(x- 1))

    q.append(org + str(x))

    if x != 9:
        q.append(org + str(x + 1))
print(org)

Fixed submission:
import collections

k = int(input())
q = collections.deque(list(range(1, 10)))
i = 0

while i < k:
    i += 1

    org = q.popleft()
    x = org % 10

    if x != 0:
        q.append(10 * org + x - 1)

    q.append( 10 * org + x)

    if x != 9:
        q.append(10 * org + x + 1)
print(org)
Buggy python submission (verdict: Time Limit Exceeded):
import collections
import functools
import math

n = int(input())
l = list(map(int, input().split(" ")))
c = collections.Counter(l)
m ={}
def f(n , r):
    if (n, r) in m:
        return m[(n,r)]
    if (n < r):
        return 0
    tmp = math.factorial(n) // (math.factorial(n-r) * math.factorial(r))
    m[(n, r)] = tmp
    return tmp


total = functools.reduce(lambda x, y : x + f(y, 2), c.values(), 0)

for i in l:
    print(total - f(c.get(i, 0), 2) + f(c.get(i, 0) - 1, 2))

Fixed submission:
import collections
import functools
import math

n = int(input())
l = list(map(int, input().split(" ")))
c = collections.Counter(l)
m ={}
def f(n , r):
    if (n, r) in m:
        return m[(n,r)]
    if (n < r):
        return 0
    tmp = math.factorial(n) // (math.factorial(n-r) * math.factorial(r))
    m[(n, r)] = tmp
    return tmp


total = functools.reduce(lambda x, y : x + f(y, 2), c.values(), 0)

for i in l:
    print(total - f(c.get(i, 0), 2) + f(c.get(i, 0) - 1, 2))

Buggy python submission (verdict: Time Limit Exceeded):
import collections
import functools
import math

n = int(input())
l = list(map(int, input().split(" ")))
c = collections.Counter(l)

def f(n , r):
    if (n < r):
        return 0
    return math.factorial(n) // (math.factorial(n-r) * math.factorial(r))

total = functools.reduce(lambda x, y : x + f(y, 2), c.values(), 0)

for i in l:
    print(total - f(c.get(i, 0), 2) + f(c.get(i, 0) - 1 , 2))

Fixed submission:
import collections
import functools
import math

n = int(input())
l = list(map(int, input().split(" ")))
c = collections.Counter(l)
m ={}
def f(n , r):
    if (n, r) in m:
        return m[(n,r)]
    if (n < r):
        return 0
    tmp = math.factorial(n) // (math.factorial(n-r) * math.factorial(r))
    m[(n, r)] = tmp
    return tmp


total = functools.reduce(lambda x, y : x + f(y, 2), c.values(), 0)

for i in l:
    print(total - f(c.get(i, 0), 2) + f(c.get(i, 0) - 1, 2))
Buggy python submission (verdict: Time Limit Exceeded):
import collections
n = int(input())

c = {}
for _ in range(n):
    s = input()
    c[s] = c.get(s, 0) + 1

print("\n".join(sorted([ k for k,v in c.items() if v == max(c.values()) ])))

Fixed submission:
import collections
n = int(input())

c = {}
for _ in range(n):
    s = input()
    c[s] = c.get(s, 0) + 1

u = max(c.values())
print("\n".join(sorted([ k for k,v in c.items() if v == u ])))

Buggy python submission (verdict: Time Limit Exceeded):
import collections
n = int(input())

dic = {}
for _ in range(n):
    s = input()
    dic[s] = dic.get(s, 0) + 1

print("\n".join(sorted([ k for k,v in dic.items() if v == max(dic.values()) ])))

Fixed submission:
import collections
n = int(input())

c = {}
for _ in range(n):
    s = input()
    c[s] = c.get(s, 0) + 1

u = max(c.values())
print("\n".join(sorted([ k for k,v in c.items() if v == u ])))

Buggy python submission (verdict: Time Limit Exceeded):
import collections
n = int(input())

dic = {}
for _ in range(n):
    s = input()
    dic[s] = dic.get(s, 0) + 1

c = collections.Counter(dic)

print("\n".join(sorted([ k for k,v in c.items() if v == max(c.values()) ])))

Fixed submission:
import collections
n = int(input())

c = {}
for _ in range(n):
    s = input()
    c[s] = c.get(s, 0) + 1

u = max(c.values())
print("\n".join(sorted([ k for k,v in c.items() if v == u ])))

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

dic = {}
for _ in range(n):
    s = input()
    dic[s] = dic.get(s, 0) + 1

c = collections.Counter(dic)

print("\n".join(sorted([ k for k,v in c.items() if v == max(c.values()) ])))

Fixed submission:
import collections
n = int(input())

c = {}
for _ in range(n):
    s = input()
    c[s] = c.get(s, 0) + 1

u = max(c.values())
print("\n".join(sorted([ k for k,v in c.items() if v == u ])))
Buggy python submission (verdict: Time Limit Exceeded):

n, k = map(int, input().split(" "))
p = list(map(int, input().split(" ")))
p = map(lambda x: sum(range(1,x+1))/x, p)

l = [0]
for i,v in enumerate(p):
    prev = l.pop()
    l.append(prev)
    l.append(prev + v)

ans = 0
for i in range(k, len(l)):
    tmp = l[i] - l[i-k]
    if ans < tmp:
        ans = tmp

print(ans)

Fixed submission:
n, k = map(int, input().split(" "))
p = list(map(int, input().split(" ")))
p = map(lambda x: sum(range(1,x+1))/x, p)
 
l = [0]
for i,v in enumerate(p):
    prev = l.pop()
    l.append(prev)
    l.append(prev + v)
 
ans = 0
for i in range(k, len(l)):
    tmp = l[i] - l[i-k]
    if ans < tmp:
        ans = tmp
 
print(ans)
Buggy python submission (verdict: Runtime Error):
N, W = list(map(int, input().split(" ")))

for i in range(0, N):
	for w in range(1, W+1):
        weight, vvalue = list(map(int, input().split(" ")))
		if w >= weight:
			dp[i + 1][w] = max([dp[i][w - weight] + value, dp[i][w]])
		else:
			dp[i + 1][w] = dp[i][w]
print(dp[N][W])


Fixed submission:
import sys

n = int(input())
l = list(map(int, input().split(" ")))
dp= [0]*n
dp[1] = abs(l[1] - l[0])

for i in range(2, n):
	one = dp[i - 1] + abs(l[i] - l[i-1])
	two = dp[i - 2] + abs(l[i] - l[i-2])	
	dp[i] = min([one, two])

print(dp[n-1])

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(200000)
 
n = int(input())
l = list(map(int, input().split(" ")))
 
def dp(i, curr_cost):
	if n -1 < i:
		return curr_cost
	one = dp(i+1, curr_cost + abs(l[i] - l[i+1]))
	two = dp(i+2, curr_cost + abs(l[i] - l[i+2]))	
	return max[one, two]
 
print(dp(0, 0))

Fixed submission:
import sys

n = int(input())
l = list(map(int, input().split(" ")))
dp= [0]*n
dp[1] = abs(l[1] - l[0])

for i in range(2, n):
	one = dp[i - 1] + abs(l[i] - l[i-1])
	two = dp[i - 2] + abs(l[i] - l[i-2])	
	dp[i] = min([one, two])

print(dp[n-1])

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(200000)
 
n = int(input())
l = list(map(int, input().split(" ")))
 
def dp(i, curr_cost):
	if n -1 < i:
		return curr_cost
	one = dp(i+1, curr_cost + abs(l[i] - l[i+1]))
	two = dp(i+2, curr_cost + abs(l[i] - l[i+2]))	
	return max[one, two]
 
print(dp(0, 0))

Fixed submission:
import sys

n = int(input())
l = list(map(int, input().split(" ")))
dp= [0]*n
dp[1] = abs(l[1] - l[0])

for i in range(2, n):
	one = dp[i - 1] + abs(l[i] - l[i-1])
	two = dp[i - 2] + abs(l[i] - l[i-2])	
	dp[i] = min([one, two])

print(dp[n-1])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(200000)

n = int(input())
l = list(map(int, input().split(" ")))
 
def dp(i, curr_cost):
	if n -1 == i:
		return curr_cost
	one = dp(i+1, curr_cost + abs(l[i] - l[i+1])) if n - 1 >= i + 1 else 9999999
	two = dp(i+2, curr_cost + abs(l[i] - l[i+2])) if n - 1 >= i + 2 else 9999999	
	return one if one < two else two
 
print(dp(0, 0))

Fixed submission:
import sys

n = int(input())
l = list(map(int, input().split(" ")))
dp= [0]*n
dp[1] = abs(l[1] - l[0])

for i in range(2, n):
	one = dp[i - 1] + abs(l[i] - l[i-1])
	two = dp[i - 2] + abs(l[i] - l[i-2])	
	dp[i] = min([one, two])

print(dp[n-1])

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

def dp(i, curr_cost):
	if n -1 == i:
		return curr_cost
	one = dp(i+1, curr_cost + abs(l[i] - l[i+1])) if n - 1 >= i + 1 else 9999999
	two = dp(i+2, curr_cost + abs(l[i] - l[i+2])) if n - 1 >= i + 2 else 9999999	
	return one if one < two else two

print(dp(0, 0))

Fixed submission:
import sys

n = int(input())
l = list(map(int, input().split(" ")))
dp= [0]*n
dp[1] = abs(l[1] - l[0])

for i in range(2, n):
	one = dp[i - 1] + abs(l[i] - l[i-1])
	two = dp[i - 2] + abs(l[i] - l[i-2])	
	dp[i] = min([one, two])

print(dp[n-1])
Buggy python submission (verdict: Time Limit Exceeded):
import sys

n,k = list(map(int, input().split(" ")))
l = list(map(int, input().split(" ")))
l = [999999]*k + l
dp= [0]*(n+k)

for i in range( k + 1, n+k):
	dp[i] = min([ dp[i - j] + abs(l[i] - l[i - j]) for j in range(1, k + 1) ])

print(dp[n + k - 1])

Fixed submission:
import sys

n,k = list(map(int, input().split(" ")))
l = list(map(int, input().split(" ")))
l = [999999]*k + l
dp= [0]*(n+k)

for i in range( k + 1, n+k):
	dp[i] = min([ dp[i - j] + abs(l[i] - l[i - j]) for j in range(1, k + 1) ])

print(dp[n + k - 1])
Buggy python submission (verdict: Time Limit Exceeded):
import collections
import itertools

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

s = [0]
for i in range(1, n + 1):
    s.append(s[i-1] + a[i-1] )

print(sum([len(list(itertools.combinations(list(range(i)), 2))) for i in collections.Counter(s).values()]))


Fixed submission:
import collections
import math

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

s = [0]
for i in range(1, n + 1):
    s.append(s[i-1] + a[i-1] )

ans = 0
for v in collections.Counter(s).values():
    if v >= 2:
        ans += math.factorial(v) // (math.factorial(v - 2) * math.factorial(2))
print(ans)
Buggy python submission (verdict: Runtime Error):
def main():
    N = int(input())
    A = list(map(int, input().split()))
    d = {}
    def prime_factorize(n):
        a = set()
        while n % 2 == 0:
            a.add(2)
            n //= 2
        f = 3
        while f * f <= n:
            if n % f == 0:
                a.add(f)
                n //= f
            else:
                f += 2
        if n != 1:
            a.add(n)
        for i in a:
            d[i] = d.get(i, 0) + 1
    for x in A:
        prime_factorize(x)
    m = max(d.values())
    if m == 1:
        return 'pairwise coprime'
    if m == N:
        return 'not coprime'
    return 'setwise coprime'
print(main())


Fixed submission:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    d = {-1:1}
    def prime_factorize(n):
        a = set()
        while n % 2 == 0:
            a.add(2)
            n //= 2
        f = 3
        while f * f <= n:
            if n % f == 0:
                a.add(f)
                n //= f
            else:
                f += 2
        if n != 1:
            a.add(n)
        for i in a:
            d[i] = d.get(i, 0) + 1
    for x in A:
        prime_factorize(x)
    m = max(d.values())
    if m == 1:
        return 'pairwise coprime'
    if m == N:
        return 'not coprime'
    return 'setwise coprime'
print(main())
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    S = input()
    p = 2019
    d = {i:0 for i in range(p)}
    d[0] = 1
    r = 0
    x = 0
    for i in range(len(S)):
        x += int(S[len(S)-1-i]) * pow(10, i)
        x %= p
        r += d[x]
        d[x] += 1
    return r
print(main())


Fixed submission:
def main():
    S = input()
    p = 2019
    d = {i:0 for i in range(p)}
    d[0] = 1
    r = 0
    x = 0
    for i in range(len(S)):
        x += int(S[len(S)-1-i]) * pow(10, i, p)
        x %= p
        r += d[x]
        d[x] += 1
    return r
print(main())

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    S = input()
    p = 2019
    d = {i:0 for i in range(p)}
    d[0] = 1
    r = 0
    x = 0
    for i in range(len(S)):
        x += int(S[len(S)-1-i]) * pow(10, i)
        x %= p
        r += d[x]
        d[x] += 1
    return r
print(main())


Fixed submission:
def main():
    S = input()
    p = 2019
    d = {i:0 for i in range(p)}
    d[0] = 1
    r = 0
    x = 0
    for i in range(len(S)):
        x += int(S[len(S)-1-i]) * pow(10, i, p)
        x %= p
        r += d[x]
        d[x] += 1
    return r
print(main())
Buggy python submission (verdict: Runtime Error):
def main():
    N = int(input())
    A = list(map(int, input().split()))
    AA = [(v, i) for i, v in enumerate(A)]
    AA.sort(reverse=True)
    dp = [[0] * (N+1) for _ in range(N+1)]
    for i, (a, b) in enumerate(AA, start=1):
        for x in range(i+1):
            y = i - x
            if y == 0:
                dp[x][y] = dp[x-1][y] + abs(b - x+1) * a
            elif x == 0:
                dp[x][y] = dp[x][y-1] + abs(N-y-b) * a
            else:
                dp[x][y] = max(dp[x-1][y] + abs(b - x + 1) * a, dp[x][y-1] + abs(N-y-b) * a)
    for i in range(N+1):
        r = max(r, dp[i][N-i])
    return r
print(main())


Fixed submission:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    AA = [(v, i) for i, v in enumerate(A)]
    AA.sort(reverse=True)
    dp = [[0] * (N+1) for _ in range(N+1)]
    for i, (a, b) in enumerate(AA, start=1):
        for x in range(i+1):
            y = i - x
            if y == 0:
                dp[x][y] = dp[x-1][y] + abs(b - x+1) * a
            elif x == 0:
                dp[x][y] = dp[x][y-1] + abs(N-y-b) * a
            else:
                dp[x][y] = max(dp[x-1][y] + abs(b - x + 1) * a, dp[x][y-1] + abs(N-y-b) * a)
    r = 0
    for i in range(N+1):
        r = max(r, dp[i][N-i])
    return r
print(main())
Buggy python submission (verdict: Runtime Error):
def main():
    N = int(input())
    A = list(map(int, input().split()))
    dp = [[-1 * pow(10, 15)] * 3 for _ in range(N)]
    dp[0][0] = A[0]
    dp[1][1] = A[1]
    dp[2][2] = A[2]
    for i in range(N):
        if i < 2:
            continue
        dp[i][0] = dp[i-2][0] + A[i]
        if i < 3:
            continue
        dp[i][1] = max(dp[i-3][0], dp[i-2][1]) + A[i]
        if i < 4:
            continue
        dp[i][2] = max(dp[i-4][0], dp[i-3][1], dp[i-2][2]) + A[i]
    if N % 2 == 0:
        return max(dp[-1][1], dp[-2][0])
    else:
        return max(dp[-1][2], dp[-2][1], dp[-3][0])
print(main())


Fixed submission:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    dp = [[-1 * pow(10, 15)] * 3 for _ in range(N)]
    if N == 2:
        return max(A)
    dp[0][0] = A[0]
    dp[1][1] = A[1]
    dp[2][2] = A[2]
    for i in range(N):
        if i < 2:
            continue
        dp[i][0] = dp[i-2][0] + A[i]
        if i < 3:
            continue
        dp[i][1] = max(dp[i-3][0], dp[i-2][1]) + A[i]
        if i < 4:
            continue
        dp[i][2] = max(dp[i-4][0], dp[i-3][1], dp[i-2][2]) + A[i]
    if N % 2 == 0:
        return max(dp[-1][1], dp[-2][0])
    else:
        return max(dp[-1][2], dp[-2][1], dp[-3][0])
print(main())
Buggy python submission (verdict: Time Limit Exceeded):
import math
def make_divisors(n):
    divisors = []
    for i in range(1, int(math.sqrt(n))+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors 
def main():
    n = int(input())
    r = len(make_divisors(n-1)) - 1
    d = make_divisors(n)
    for i in d:
        if i == 1:
            continue
        if i == 2:
            r += 1
            continue
        t = n
        while True:
            if t % i == 0:
                t = t // i
            else:
                t = t - i
            if t == 1:
                r += 1
                break
            if t <= 0:
                break
    return r
print(main())


Fixed submission:
import math
def make_divisors(n):
    divisors = []
    for i in range(1, int(math.sqrt(n))+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors 
def main():
    n = int(input())
    r = len(make_divisors(n-1)) - 1
    d = make_divisors(n)
    for i in d:
        if i == 1:
            continue
        if i == 2:
            r += 1
            continue
        t = n
        while t % i == 0:
            t = t // i
        t = t % i
        if t == 1:
            r += 1
    return r
print(main())
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100000)
class fact():
    def __init__(self, i, mod):
        self.l = [1] * (i+1)
        for i in range(1, i+1):
            self.l[i] = self.l[i-1] * i
        self.mod = mod
        self.g1 = [1, 1]
        self.g2 = [1, 1]
        inverse = [0, 1]
        for i in range(2, 2 * (10 ** 5) + 1):
            self.g1.append((self.g1[-1] * i) % mod)
            inverse.append((-inverse[mod % i] * (mod // i)) % mod)
            self.g2.append((self.g2[-1] * inverse[-1]) % mod)


def main():
    N = int(input())
    d = {}
    mod = 10**9 + 7
    f = fact(N, mod)
    for i in range(N-1):
        a, b = map(int, input().split())
        if a in d:
            d[a].append(b)
        else:
            d[a] = [b]
        if b in d:
            d[b].append(a)
        else:
            d[b] = [a]
    for i in range(1, N+1):
        v = set()
        r, t = solve(i, N, v, f, d)
        print(r % mod)
def solve(n, a, v, f, d):
    v.add(n)
    x = 0
    unv = []
    for i in d[n]:
        if i not in v:
            x += 1
            unv.append(i)
    if x == 1:
        r, t = solve(unv[0], a-1, v, f, d)
        return r, t + 1
    if x == 0:
        return 1, 1
    t = 1
    r = 1
    for i in unv:
        rr, tt = solve(i, a-1, v, f, d)
        t += tt
        r *= rr
        r *= f.g2[tt]
    r *= f.l[t-1]
    return r, t
main()


Fixed submission:
import heapq
def main():
    X, Y, A, B, C = map(int, input().split())
    p = list(map(int, input().split()))
    q = list(map(int, input().split()))
    r = list(map(int, input().split()))
    p.sort(reverse=True)
    q.sort(reverse=True)
    r.sort(reverse=True)
    h = []
    for i in p[:X]:
        heapq.heappush(h, (i, 'r'))
    for i in q[:Y]:
        heapq.heappush(h, (i, 'g'))
    a = sum(p[:X]) + sum(q[:Y])
    ra = 0
    ga = 0
    i = 0
    while h:
        t = heapq.heappop(h)
        if r[i] < t[0]:
            break
        if t[1] == 'r' and ra <= X:
            a += r[i]
            a -= t[0]
            ra += 1
            i += 1
        elif t[1] == 'g' and ga <= Y:
            ga += 1
            a += r[i]
            a -= t[0]
            i += 1
        if ra == X and ga == Y:
            break
        if i >= C:
            break
    return a
print(main())
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**9)
l = []
def calc3(s, N):
    if len(s) == N:
        l.append(s)
        return
    if len(s) > 0:
        c = s[-1]
        s2 = s[:]
        z = ord(c) - ord('a') + 2
        for i in range(z):
            st = s[:]
            st += chr(ord('a')+i)
            calc3(st[:], N)
    else:
        c = 'a'
        s += chr(ord(c))
        calc3(s[:], N)
def main():
    N = int(input())
    s = ''
    calc3(s[:], N)
    l = sorted(set(l))
    for i in l:
        print(i)
main()



Fixed submission:
import sys
sys.setrecursionlimit(10**9)
def main():
    N = int(input())
    s = ''
    l = []
    def calc3(s, N, i):
        if len(s) == N:
            l.append(s)
            return
        if len(s) > 0:
            s2 = s[:]
            z = i + 2
            for j in range(z):
                st = s[:]
                st += chr(ord('a')+j)
                if j == i + 1:
                    calc3(st[:], N, i+1)
                else:
                    calc3(st[:], N, i)
        else:
            s += 'a'
            calc3(s[:], N, i)
    calc3(s[:], N, 0)
    l = sorted(set(l))
    for i in l:
        print(i)
main()
Buggy python submission (verdict: Runtime Error):
import math
def main():
    H = int(input())
    t = int(math.log2(H))
    r = 2**(t + 1) - 1
    print(r)
main()
    


Fixed submission:
import math
def main():
    H = int(input())
    t = int(math.log2(H))
    r = 2**(t + 1) - 1
    print(r)
main()