Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import math
x, y = map(int, input().split())
if (x + y) % 3 == 0:
        n = int(x - 2/3*(2*x-y))
        m = int((2*x - y)/3)
        c = 1 
        for i in range(n):
                c *= n + m - i 
        print(c // math.factorial(n) % (10**9+7))
else:
        print(0)

Fixed submission:
x, y = map(int, input().split())
n = (2*y - x)//3 
m = (2*x - y)//3
mod = 10**9+7
def inv(x):
        return pow(x, mod-2, mod)
def fact(x):
        f = 1 
        for i in range(1, x + 1): 
                f *= i
                f %= mod    
        return f
def comb(n, r): 
        return (fact(n) * inv(fact(n-r)) * inv(fact(r))) % mod 
res = comb(n+m, m)
if (x + y) % 3 == 0 and n >= 0 and m >= 0:
        print(res)
else:
        print(0)
Buggy python submission (verdict: Runtime Error):
a,b,*c = input();print('YNeos'[((c>[])|((int(b)==0)&(int(a)>4)))::2])

Fixed submission:
s = int(input())
res = 'No'
for i in range(1,10):
        if s%i == 0 and s/i < 10: 
                res = 'Yes'
                break
print(res)
Buggy python submission (verdict: Runtime Error):
 = input()
A = list(map(int, input().split()))
print(max(A) - min(A))

Fixed submission:
_ = input()
A = list(map(int, input().split()))
print(max(A) - min(A))
Buggy python submission (verdict: Runtime Error):
n, a = open(0).read().split()
print('Yneos'[n%500>a::2])

Fixed submission:
n, a = open(0).read().split()
if int(n) % 500 <= int(a):
        print("Yes")
else:
        print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N, A, B = map(int, input().split())

while 1:
        if A + 1 != B:
                A += 1
        elif A - 1 != 0:
                A -= 1
        else:
                print("Borys")
                break
    
        if B - 1 != A:
                B -= 1
        elif B + 1 != N:
                B += 1
        else:
                print("Alice")
                break

Fixed submission:
N, A, B = map(int, input().split())
if (A % 2 == 0) ^ (B % 2 == 0): 
        print("Borys")
else:
        print("Alice")
Buggy python submission (verdict: Runtime Error):
H, W = map(int, input().split())
matrix = [input() for i in range(H)] 
ans = ""  
for h in range(H):
        for w in range(W):
                bomb = 0 
                for i in range(-1, 2): 
                        if 0 <= h - 1 and 0 <= w + i < W:
                                if matrix[h - 1][w + i] == "#":
                                        bomb += 1
                        if h + 1 < H and 0 <= w + i < W:
                                if matrix[h + 1][w + i] == "#":
                                        bomb += 1
                for i in range(-1, 2, 2): 
                        if 0 <= w + i < W:
                                if matrix[h][w + i] == "#":
                                        bomb += 1
                if matrix[h][w] == "#":
                        ans += "#" 
                else:
                        ans += str(bomb)
                if w % (W - 1) == 0 and w != 0:
                        ans += "\n"
print(ans)

Fixed submission:
H, W = map(int, input().split())
matrix = [input() for i in range(H)] 
ans = ""  
for h in range(H):
        for w in range(W):
                bomb = 0 
                for i in range(-1, 2): 
                        if 0 <= h - 1 and 0 <= w + i < W:
                                if matrix[h - 1][w + i] == "#":
                                        bomb += 1
                        if h + 1 < H and 0 <= w + i < W:
                                if matrix[h + 1][w + i] == "#":
                                        bomb += 1
                for i in range(-1, 2, 2): 
                        if 0 <= w + i < W:
                                if matrix[h][w + i] == "#":
                                        bomb += 1
                if matrix[h][w] == "#":
                        ans += "#" 
                else:
                        ans += str(bomb)
                if W - 1 > 0:
                        if w % (W - 1) == 0 and w != 0:
                                ans += "\n"
                else:
                                ans += "\n"
print(ans)
Buggy python submission (verdict: Runtime Error):
A, B, C, D, E, F = map(int, input().split())
max_sugar = E / (100 + E)
res = 0 
ans = [0, 0]
for a in range(F // 100*A + 1): 
        for b in range(F // 100*B + 1): 
                for c in range(int(F * max_sugar) // C + 1):
                        for d in range(int(F * max_sugar) // D + 1): 
                                mass = 100*A*a + 100*B*b + C*c + D*d 
                                sugar = C*c + D*d 
                                if 0 < mass <= F and sugar / mass <= max_sugar:
                                        if res <= sugar / mass:
                                                res = sugar / mass 
                                                ans = [mass, sugar]
                                else:
                                        break
print(str(ans[0]) + " " + str(ans[1]))

Fixed submission:
n, a = map(int, open(0).read().split())
print(n * n - a)
Buggy python submission (verdict: Time Limit Exceeded):
A, B, C, D, E, F = map(int, input().split())
max_sugar = E / (100 + E)
res = 0 
ans = [0, 0]
for a in range(F // 100*A + 1): 
        for b in range(F // 100*B + 1): 
                for c in range(int(F * max_sugar) // C + 1):
                        for d in range(int(F * max_sugar) // D + 1): 
                                mass = 100*A*a + 100*B*b + C*c + D*d 
                                sugar = C*c + D*d 
                                if 0 < mass <= F and sugar / mass <= max_sugar:
                                        if res <= sugar / mass:
                                                res = sugar / mass 
                                                ans = [mass, sugar]
                                else:
                                        break
print(str(ans[0]) + " " + str(ans[1]))

Fixed submission:
A, B, C, D, E, F = map(int, input().split())
max_sugar = E / (100 + E)
res = 0 
ans = [0, 0]
for a in range(F // 100*A + 1): 
        for b in range(F // 100*B + 1): 
                for c in range(int(F * max_sugar) // C + 1):
                        for d in range(int(F * max_sugar) // D + 1): 
                                mass = 100*A*a + 100*B*b + C*c + D*d 
                                sugar = C*c + D*d 
                                if 0 < mass <= F and sugar / mass <= max_sugar:
                                        if res <= sugar / mass:
                                                res = sugar / mass 
                                                ans = [mass, sugar]
                                else:
                                        break
print(str(ans[0]) + " " + str(ans[1]))
Buggy python submission (verdict: Time Limit Exceeded):
A, B, C = map(int, input().split())
ans = "NO"
for i in range(A, 100000000, A): 
        if i % B == C:
                ans = "YES"
                break
print(ans)

Fixed submission:
A, B, C = map(int, input().split())
ans = "NO"
for i in range(A, 100000000, A): 
        if i % B == C:
                ans = "YES"
                break
print(ans)
Buggy python submission (verdict: Runtime Error):
S = list(input())
S.reverse()
S = "".join(S)
ans = "YES"
while len(S) > 0:
        print(S)
        if S[:5] == "maerd" or S[:5] == "esare":
                S = S[5:]
        elif S[:6] == "resare":
                S = S[6:]
        elif S[:7] == "remaerd":
                S = S[7:]
        else:
                ans = "NO"
                break
print(ans)

Fixed submission:
S = list(input())
S.reverse()
S = "".join(S)
ans = "YES"
while len(S) > 0:
        if S[:5] == "maerd" or S[:5] == "esare":
                S = S[5:]
        elif S[:6] == "resare":
                S = S[6:]
        elif S[:7] == "remaerd":
                S = S[7:]
        else:
                ans = "NO"
                break
print(ans)
Buggy python submission (verdict: Runtime Error):
W, H, N = map(int, input().split())
xy = [list(map(int, input().split())) for i in range(N)]
x_black = [0] * W 
y_black = [0] * H 
def get_area(x, y, a): 
        if a == 1:
                x_black[:x] = [1] * x 
        if a == 2:
                x_black[x:W] = [1] * (W - x)
        if a == 3:
                y_black[y] = [1] * y 
        if a == 4:
                y_black[y:H] = [1] * (H - y)
for i in xy: 
        get_area(i[0], i[1], i[2])
print(x_black.count(0) * y_black.count(0))

Fixed submission:
W, H, N = map(int, input().split())
xy = [list(map(int, input().split())) for i in range(N)]
x_black = [0] * W 
y_black = [0] * H 
def get_area(x, y, a): 
        if a == 1:
                for i in range(x):
                        x_black[i] = 1 
        if a == 2:
                for i in range(x, W): 
                        x_black[i] = 1 
        if a == 3:
                for i in range(y):
                        y_black[i] = 1 
        if a == 4:
                for i in range(y, H): 
                        y_black[i] = 1 
for i in xy: 
        get_area(i[0], i[1], i[2])
print(x_black.count(0) * y_black.count(0))
Buggy python submission (verdict: Time Limit Exceeded):
N, X, Y = map(int, input().split())


count = [0] * (N-1)
for i in range(1, N+1):
    for j in range(i+1, N+1):
        routeA = abs(j-i)
        routeB = abs(X-i) + abs(Y-j) + 1
        routeC = abs(Y-i) + abs(X-j) + 1
        min_route = min(routeA, routeB, routeC)
        count[min_route - 1] += 1

print('\n'.join(map(str, count)))

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


count = [0] * (N-1)
for i in range(1, N+1):
    for j in range(i+1, N+1):
        routeA = abs(j-i)
        routeB = abs(X-i) + abs(Y-j) + 1
        min_route = min(routeA, routeB)
        count[min_route - 1] += 1

print('\n'.join(map(str, count)))

Buggy python submission (verdict: Time Limit Exceeded):
N, X, Y = map(int, input().split())


count = [0] * (N-1)
for i in range(1, N+1):
    for j in range(i+1, N+1):
        routeA = abs(j-i)
        routeB = abs(X-i) + abs(Y-j) + 1
        routeC = abs(Y-i) + abs(X-j) + 1
        min_route = min(routeA, routeB, routeC)
        count[min_route - 1] += 1

for i in count:
    print(i)

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


count = [0] * (N-1)
for i in range(1, N+1):
    for j in range(i+1, N+1):
        routeA = abs(j-i)
        routeB = abs(X-i) + abs(Y-j) + 1
        min_route = min(routeA, routeB)
        count[min_route - 1] += 1

print('\n'.join(map(str, count)))

Buggy python submission (verdict: Time Limit Exceeded):
N, X, Y = map(int, input().split())


count = [0] * (N-1)
for i in range(1, N+1):
    for j in range(i+1, N+1):
        routeA = abs(j-i)
        routeB = abs(X-i) + abs(Y-j) + 1
        routeC = abs(Y-i) + abs(X-j) + 1
        min_route = min(routeA, routeB, routeC)
        count[min_route - 1] += 1

for i in count:
    print(i)

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


count = [0] * (N-1)
for i in range(1, N+1):
    for j in range(i+1, N+1):
        routeA = abs(j-i)
        routeB = abs(X-i) + abs(Y-j) + 1
        min_route = min(routeA, routeB)
        count[min_route - 1] += 1

print('\n'.join(map(str, count)))
Buggy python submission (verdict: Time Limit Exceeded):
import math
import numpy as np

N,M = map(int,input().split())
A = np.array(list(map(int, input().split())))

def discount(price):
    return math.floor(price / 2)

for i in range(M):
    A[np.argmax(A)] = discount(A[np.argmax(A)])

print(np.sum(A))

Fixed submission:
import heapq as hq
import math

def discount(price):
    return math.ceil(price / 2)

N,M = map(int,input().split())
A = list(map(lambda x: int(x)* -1,input().split()))
hq.heapify(A)

for _ in range(M):
    a = discount(hq.heappop(A))
    hq.heappush(A,a)

print(sum(A)* -1)
Buggy python submission (verdict: Time Limit Exceeded):
def makedic(str1):
    dic = {}
    for s in str1:
        if s in dic:
            dic[s] += 1
        else:
            dic[s] = 1
    #print(dic)
    return dic

N = int(input())
S = [makedic(input()) for _ in range(N)]

ans = 0
for i in range(N):
    for j in range(i+1,N):
        if S[i] == S[j]:
        #if S[i] == S[j]:
            ans += 1
print(ans)



Fixed submission:
N = int(input())
S = [input() for _ in range(N)]

dic = {}
ans = 0
for s in S:
    sortstr = str(sorted(s))
    if sortstr in dic:
        ans += dic[sortstr]
        dic[sortstr] += 1
    else:
        dic[sortstr] = 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = [sorted(input()) for _ in range(N)]

ans = 0
for i in range(N):
    for j in range(i+1,N):
        if S[i] == S[j]:
            ans += 1
print(ans)

Fixed submission:
N = int(input())
S = [input() for _ in range(N)]

dic = {}
ans = 0
for s in S:
    sortstr = str(sorted(s))
    if sortstr in dic:
        ans += dic[sortstr]
        dic[sortstr] += 1
    else:
        dic[sortstr] = 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = [input() for _ in range(N)]

ans = 0
for i in range(N):
    for j in range(i+1,N):
        if sorted(S[i]) == sorted(S[j]):
            ans += 1
            #print(S[i],S[j])
print(ans)

Fixed submission:
N = int(input())
S = [input() for _ in range(N)]

dic = {}
ans = 0
for s in S:
    sortstr = str(sorted(s))
    if sortstr in dic:
        ans += dic[sortstr]
        dic[sortstr] += 1
    else:
        dic[sortstr] = 1
print(ans)
Buggy python submission (verdict: Runtime Error):
import math

A,B,C,D = map(int, input().split())

lcm = (C*D) // math.gcd(C,D)

b_sum = B - ((B//C) + (B//D) - (B//lcm))

a = A-1
a_sum = a - ((a//C) + (a//D) - (a//lcm))

print(b_sum - a_sum)

Fixed submission:
from fractions import gcd

A,B,C,D = map(int, input().split())

lcm = (C*D) // gcd(C,D)

b_sum = B - ((B//C) + (B//D) - (B//lcm))

a = A-1
a_sum = a - ((a//C) + (a//D) - (a//lcm))

print(b_sum - a_sum)

Buggy python submission (verdict: Runtime Error):
import math

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

A,B,C,D = map(int, input().split())

b_sum = B - ((B//C) + (B//D) - (B//lcm(C,D)))

a = A-1
a_sum = a - ((a//C) + (a//D) - (a//lcm(C,D)))

print(b_sum-a_sum)

Fixed submission:
from fractions import gcd

A,B,C,D = map(int, input().split())

lcm = (C*D) // gcd(C,D)

b_sum = B - ((B//C) + (B//D) - (B//lcm))

a = A-1
a_sum = a - ((a//C) + (a//D) - (a//lcm))

print(b_sum - a_sum)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int,input().split())
A = list(map(int, input().split()))

BC = [list(map(int, input().split())) for _ in range(M)]

BC.sort(reverse = True, key=lambda x : x[1])

for b, c in BC:
    A.sort()
    for j in range(b):
        if A[j] >= c:
            break
        A[j] = c
    else:
        continue
    break
print(sum(A))


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

BC = [list(map(int, input().split())) for _ in range(M)]

A.sort()
BC.sort(reverse = True, key=lambda x : x[1])

index = -1
for b, c in BC:
    for _ in range(b):
        index += 1
        if index >= N:
            break
        if A[index] >= c:
            break
        A[index] = c
    else:
        continue
    break
print(sum(A))
Buggy python submission (verdict: Time Limit Exceeded):
R, G, B, N = map(int, input().split())

box = sorted([R,G,B],reverse=True)

count = 0
for x in range(0,N+1,box[0]):
    for y in range(0,N+1,box[1]):
        if x + y > N:
            continue
        z = (N - x - y) / box[2]
        if z >= 0 and z.is_integer():
            count += 1
print(count)

Fixed submission:
R, G, B, N = map(int, input().split())

box = sorted([R,G,B],reverse=True)

count = 0
for x in range(0,N+1,box[0]):
    for y in range(0,N+1 - x ,box[1]):
        z = (N - x - y) / box[2]
        if z >= 0 and z.is_integer():
            count += 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
R, G, B, N = map(int, input().split())

count = 0
for r in range(0,(N+1),R):
    for g in range(0,(N+1),G):
        if r + g > N:
            continue
        #print('r:{} g:{}'.format(r,g))
        b = (N - r - g) / B
        if b >= 0 and b.is_integer():
            count += 1
print(count)

Fixed submission:
R, G, B, N = map(int, input().split())

box = sorted([R,G,B],reverse=True)

count = 0
for x in range(0,N+1,box[0]):
    for y in range(0,N+1 - x ,box[1]):
        z = (N - x - y) / box[2]
        if z >= 0 and z.is_integer():
            count += 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
R, G, B, N = map(int, input().split())

count = 0
for r in range(0,N+1,R):
    for g in range(0,N+1,G):
        b = (N - r - g) / B
        if b >= 0 and b.is_integer():
            count += 1
print(count)

Fixed submission:
R, G, B, N = map(int, input().split())

box = sorted([R,G,B],reverse=True)

count = 0
for x in range(0,N+1,box[0]):
    for y in range(0,N+1 - x ,box[1]):
        z = (N - x - y) / box[2]
        if z >= 0 and z.is_integer():
            count += 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
R, G, B, N = map(int, input().split())

count = 0
for r in range(N+1):
    for g in range(N+1):
        b = (N - R*r - G*g) / B
        if b >= 0 and b.is_integer():
            count += 1
print(count)

Fixed submission:
R, G, B, N = map(int, input().split())

box = sorted([R,G,B],reverse=True)

count = 0
for x in range(0,N+1,box[0]):
    for y in range(0,N+1 - x ,box[1]):
        z = (N - x - y) / box[2]
        if z >= 0 and z.is_integer():
            count += 1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split(' ')))

def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

gcd_list = []
for skip in range(N):
    ans = max(A)
    for i in range(N):
        if i == skip: continue
        buf = gcd(ans, A[i])
        if ans > buf:
            ans = buf
    gcd_list.append(ans)

gcd_list.sort()
print(gcd_list[-1])


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

def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

L = [0] * N
for i in range(N-1):
    L[i+1] = gcd(L[i],A[i])

R = [0] * N
for i in range(N-1,0,-1):
    R[i-1] = gcd(R[i],A[i])

ans = max([gcd(l,r) for l,r in zip(L,R)])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
X,Y,Z,K = map(int,input().split(' '))
A = list(map(int, input().split(' ')))
B = list(map(int, input().split(' ')))
C = list(map(int, input().split(' ')))

list.sort(A, reverse=True)
list.sort(B, reverse=True)
list.sort(C, reverse=True)

sums = []
for i in range(X):
    for j in range(Y):
        for k in range(Z):
            if (i+1)*(j+1)*(k+1) <= K:
                sums.append(A[i]+B[j]+C[k])

list.sort(sums, reverse=True)
for i in range(K):
    print(sums[i])

Fixed submission:
X,Y,Z,K = map(int,input().split(' '))
A = list(map(int, input().split(' ')))
B = list(map(int, input().split(' ')))
C = list(map(int, input().split(' ')))

list.sort(A, reverse=True)
list.sort(B, reverse=True)
list.sort(C, reverse=True)

sums = []
for i in range(X):
    for j in range(Y):
        for k in range(Z):
            if (i+1)*(j+1)*(k+1) > K:
                break
            sums.append(A[i]+B[j]+C[k])

for a in sorted(sums, reverse=True)[:K]:
    print(a)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N,Q = map(int,input().split(' '))
S = input()

lr = []
for _ in range(Q):
    lr.append(list(map(int,input().split(' '))))

index_list = []
start = 0
for i in range(N):
    try:
        start += S[start:].index('AC')
        index_list.append(start)
        start += 2
    except ValueError:
        break

index_list = np.array(index_list)
for l,r in lr:
    print(np.sum((l-1 <= index_list) & (index_list <= r-2)))

Fixed submission:
N,Q = map(int,input().split(' '))
S = input()

lr = []
for _ in range(Q):
    lr.append(list(map(int,input().split(' '))))

#index_list = []
index_list = [0] * N
start = 0
for i in range(1,N):
    if S[i-1] == 'A' and S[i] == 'C':
        index_list[i] = index_list[i-1] + 1
    else:
        index_list[i] = index_list[i-1]

for l,r in lr:
    print(index_list[r-1] - index_list[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
import re
N,Q = map(int,input().split(' '))
S = input()

lr = []
for _ in range(Q):
    lr.append(list(map(int,input().split(' '))))

pattern = '(AC)'

for l,r in lr:
    match = re.findall(pattern, S[l-1:r])
    print(len(match))


Fixed submission:
N,Q = map(int,input().split(' '))
S = input()

lr = []
for _ in range(Q):
    lr.append(list(map(int,input().split(' '))))

#index_list = []
index_list = [0] * N
start = 0
for i in range(1,N):
    if S[i-1] == 'A' and S[i] == 'C':
        index_list[i] = index_list[i-1] + 1
    else:
        index_list[i] = index_list[i-1]

for l,r in lr:
    print(index_list[r-1] - index_list[l-1])
Buggy python submission (verdict: Runtime Error):
K = int(input())
A,B = map(int, input().split())

listK = [K*i for i in range(1, 1000) if K*i<=1000]

for j in listK:
    if A<=listK[j] and listK[j]<=B:
        print('OK')
        exit()

print('NG')

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

listK = [K*i for i in range(1, 1000) if K*i<=1000]

for j in listK:
    if A<=j and j<=B:
        print('OK')
        exit()

print('NG')
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = [int(x) for x in input().split()]
sumA = 0

for i in A:
    sumA = sumA + A[i]

if sumA > N:
    print(-1)
else:
    print(N-sumA)


Fixed submission:
N, M = map(int, input().split())
A = list(map(int, input().split()))
sumA = 0
cnt = 0

for i in A:
    sumA = sumA + A[cnt]
    cnt = cnt +1

if sumA > N:
    print(-1)
else:
    print(N-sumA)
Buggy python submission (verdict: Runtime Error):
S = input()
l = []
for i in S:
    l.append(i)

if l[3] == l[4]:
    if l[5] == l[6]:
        print('Yes')

print('No')

Fixed submission:
S = input()
l = []
cont = 0
for i in S:
    l.append(i)

if l[2] == l[3]:
    if l[4] == l[5]:
        cont = 1

if cont == 1:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
import math
x = int(input())
if x > 0:
    for a in range(-1, x):
        for b in range(-1, x):
            check = math.pow(a, 5) - math.pow(b, 5)
            if check == x:
                print(f'{a} {b}')
                break


Fixed submission:
import math
def factorial(x):
    max_num = int(2 * (10 ** 9) ** (1 / 5))
    for a in range(-1 * max_num, max_num):
        for b in range(-1 * max_num, max_num):
            check = math.pow(a, 5) - math.pow(b, 5)
            if check == x:
                return f'{a} {b}'


x = int(input())
print(factorial(x))

Buggy python submission (verdict: Time Limit Exceeded):
import math
def factorial(x):
    for a in range(-1, x):
        for b in range(-1, x):
            check = math.pow(a, 5) - math.pow(b, 5)
            if check == x:
                return f'{a} {b}'
x = int(input())
print(factorial(x))


Fixed submission:
import math
def factorial(x):
    max_num = int(2 * (10 ** 9) ** (1 / 5))
    for a in range(-1 * max_num, max_num):
        for b in range(-1 * max_num, max_num):
            check = math.pow(a, 5) - math.pow(b, 5)
            if check == x:
                return f'{a} {b}'


x = int(input())
print(factorial(x))

Buggy python submission (verdict: Time Limit Exceeded):
import math
def factorial(x):
    for a in range(-1, 1000000000):
        for b in range(-1, 1000000000):
            check = math.pow(a, 5) - math.pow(b, 5)
            if check == x:
                return f'{a} {b}'
x = int(input())
print(factorial(x))


Fixed submission:
import math
def factorial(x):
    max_num = int(2 * (10 ** 9) ** (1 / 5))
    for a in range(-1 * max_num, max_num):
        for b in range(-1 * max_num, max_num):
            check = math.pow(a, 5) - math.pow(b, 5)
            if check == x:
                return f'{a} {b}'


x = int(input())
print(factorial(x))