Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
def main():
    N = int(input())
    A,B = [],[]
    for _ in range(N):
        a,b = [int(x) for x in input().split()]
        A.append(a)
        B.append(b)
    A.sort()
    B.sort()
    if N % 2 == 1:
        minMed = A[N/2]
        maxMed = B[N/2]
        print(int(maxMed-minMed)+1)
    else:
        minMed = A[N//2-1] + A[N//2]
        maxMed = B[N//2-1] + B[N//2]
        print(int(maxMed-minMed)+1)

if __name__ == '__main__':
    main()

Fixed submission:
def main():
    N = int(input())
    A,B = [],[]
    for _ in range(N):
        a,b = [int(x) for x in input().split()]
        A.append(a)
        B.append(b)
    A.sort()
    B.sort()
    if N % 2 == 1:
        minMed = A[N//2]
        maxMed = B[N//2]
        print(int(maxMed-minMed)+1)
    else:
        minMed = A[N//2-1] + A[N//2]
        maxMed = B[N//2-1] + B[N//2]
        print(int(maxMed-minMed)+1)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
def main():
    N = int(input())
    A,B = [],[]
    for _ in range(N):
        a,b = [int(x) for x in input().split()]
        A.append(a)
        B.append(b)
    A.sort()
    B.sort()
    if N % 2 == 1:
        minMed = A[N/2]
        maxMed = B[N/2]
        print(int(maxMed-minMed)+1)
    else:
        minMed = A[N//2-1] + A[N//2]
        maxMed = B[N//2-1] + B[N//2]
        print(minMed,maxMed)
        print(int(maxMed-minMed)+1)

if __name__ == '__main__':
    main()

Fixed submission:
def main():
    N = int(input())
    A,B = [],[]
    for _ in range(N):
        a,b = [int(x) for x in input().split()]
        A.append(a)
        B.append(b)
    A.sort()
    B.sort()
    if N % 2 == 1:
        minMed = A[N//2]
        maxMed = B[N//2]
        print(int(maxMed-minMed)+1)
    else:
        minMed = A[N//2-1] + A[N//2]
        maxMed = B[N//2-1] + B[N//2]
        print(int(maxMed-minMed)+1)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import math

def main():
    N = int(input())
    Al = [int(x) for x in input().split()]
    center = int(N/2)
    cnt = 0
    for i in range(N):
        for j in range(i,N):
            if i+Al[i] == j-Al[j]:
                cnt += 1
    print(cnt)

if __name__ == '__main__':
    main()


Fixed submission:
import math
from collections import defaultdict

def main():
    N = int(input())
    Al = [int(x) for x in input().split()]
    center = int(N/2)
    cnt = 0
    m = defaultdict(int)
    for i in range(N):
        m[i+Al[i]] += 1
        cnt += m[i-Al[i]]
    print(cnt)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    S = []
    for i in range(N):
        s = input()
        if s not in S:
            S.append(s)
    print(len(S))

if __name__ == '__main__':
    main()


Fixed submission:
def main():
    N = int(input())
    S = {}
    for i in range(N):
        s = input()
        if s not in S:
            S.update({s:0})
    print(len(S))

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    S = []
    for _ in range(N):
        S.append(''.join(sorted(list(input()))))
    cnt = 0
    for i in range(N-1):
        for j in range(i+1,N):
            if S[i] == S[j]:
                cnt += 1
    print(cnt)

if __name__ == '__main__':
    main()

Fixed submission:
from collections import defaultdict
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def main():
    N = int(input())
    S = defaultdict(int)
    for _ in range(N):
        s = ''.join(sorted(list(input())))
        if s in S:
            S[s] += 1
        else:
            S.update({s:0})
    cnt = 0
    for k,v in S.items():
        if v == 0:
            continue
        elif v == 1:
            cnt += v
        else:
            cnt += combinations_count(v+1,2)
    print(cnt)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

def main():
    MARCH = ['M','A','R','C','H']
    N = int(input())
    S = []
    cnt = 0
    for _ in range(N):
        s = input()
        if not s[0] in MARCH:
            continue
        S.append(s)
    for a,b,c in itertools.combinations(S,3):
        # print(a,b,c,cnt)
        if a[0] == b[0] or b[0] == c[0] or a[0] == c[0]:
            continue
        cnt += 1
    print(cnt)

if __name__ == '__main__':
    main()

Fixed submission:
from collections import defaultdict

def main():
    N = int(input())
    MARCH = ['M','A','R','C','H']
    S = [0] * len(MARCH)
    for _ in range(N):
        s = input()
        if not s[0] in MARCH:
            continue
        if s[0] == MARCH[0]: S[0] += 1
        elif s[0] == MARCH[1]: S[1] += 1
        elif s[0] == MARCH[2]: S[2] += 1
        elif s[0] == MARCH[3]: S[3] += 1
        elif s[0] == MARCH[4]: S[4] += 1
    cnt = 0
    for i in range(len(S)-2):
        for j in range(i+1,len(S)-1):
            for k in range(j+1,len(S)):
                cnt += S[i]*S[j]*S[k]
    print(cnt)

if __name__ == '__main__':
    main()

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

def main():
    M = ['M','A','R','C','H']
    N = int(input())
    S = []
    cnt = 0
    for _ in range(N):
        S.append(input())
    for a,b,c in itertools.combinations(S,3):
        if a[0] == b[0] or b[0] == c[0] or a[0] == c[0]:
            continue
        if a[0] in M and b[0] in M and c[0] in M:
            cnt += 1
    print(cnt)

if __name__ == '__main__':
    main()

Fixed submission:
from collections import defaultdict

def main():
    N = int(input())
    MARCH = ['M','A','R','C','H']
    S = [0] * len(MARCH)
    for _ in range(N):
        s = input()
        if not s[0] in MARCH:
            continue
        if s[0] == MARCH[0]: S[0] += 1
        elif s[0] == MARCH[1]: S[1] += 1
        elif s[0] == MARCH[2]: S[2] += 1
        elif s[0] == MARCH[3]: S[3] += 1
        elif s[0] == MARCH[4]: S[4] += 1
    cnt = 0
    for i in range(len(S)-2):
        for j in range(i+1,len(S)-1):
            for k in range(j+1,len(S)):
                cnt += S[i]*S[j]*S[k]
    print(cnt)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N,M = [int(x) for x in input().split()]
    Scc_cnt = 0
    while N >= 0 and M >= 2:
        if N >= 1 and M >= 2:
            N -= 1
            M -= 2
            Scc_cnt += 1
        if N == 0 and M >= 4:
            M -= 4
            Scc_cnt += 1
        if N == 0 and M <= 3:
            break
    print(Scc_cnt)

if __name__ == '__main__':
    main()

Fixed submission:
def main():
    N,M = [int(x) for x in input().split()]
    Scc_cnt = 0
    if N >= 0 and M >= 2:
        if M >= N*2:
            Scc_cnt += N + (M-N*2)//4
        else:
            Scc_cnt += M//2
    print(Scc_cnt)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    K,S = [int(x) for x in input().split()]
    cnt = 0
    for x in range(K+1):
        if x > S:
            break
        for y in range(K+1):
            if x+y > S:
                break
            for z in range(K+1):
                if x+y+z > S:
                    break
                if S == x+y+z:
                    cnt += 1
    print(cnt)

if __name__ == '__main__':
    main()


Fixed submission:
def main():
    K,S = [int(x) for x in input().split()]
    cnt = 0
    for x in range(K+1):
        if x > S:
            break
        for y in range(K+1):
            if x+y > S:
                break
            z = S-(x+y)
            if z < 0 or z > K:
                continue
            # print(x,y,z)
            if S == x+y+z:
                cnt += 1
    print(cnt)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    K,S = [int(x) for x in input().split()]
    cnt = 0
    for x in range(K+1):
        for y in range(K+1):
            for z in range(K+1):
                if S == x+y+z:
                    cnt += 1
    print(cnt)

if __name__ == '__main__':
    main()


Fixed submission:
def main():
    K,S = [int(x) for x in input().split()]
    cnt = 0
    for x in range(K+1):
        if x > S:
            break
        for y in range(K+1):
            if x+y > S:
                break
            z = S-(x+y)
            if z < 0 or z > K:
                continue
            # print(x,y,z)
            if S == x+y+z:
                cnt += 1
    print(cnt)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

n, k = map(int, input().split())
cnt = 0

h = list(map(int, input().split()))

for high in h:
    if h >= k:
        cnt += 1


print(cnt)


Fixed submission:
# -*- coding: utf-8 -*-

n, k = map(int, input().split())
cnt = 0

h = list(map(int, input().split()))

for high in h:
    if high >= k:
        cnt += 1


print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
import numpy as np

n,k,q= map(int, input().split())

scores = np.array([k] * n)

for i in range(q):
    ans = int(input())
    scores[:ans-1] = scores[:ans-1] - 1
    scores[ans:] = scores[ans:] - 1

for r in scores:
    if r > 0:
        print('Yes')
    else:
        print('No')


Fixed submission:
# -*- coding: utf-8 -*-
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, K, Q, *A = map(int, read().split())

    B = [0] * N
    for a in A:
        B[a - 1] += 1

    ans = [0] * N
    for i, b in enumerate(B):
        if Q >= K + b:
            ans[i] = 'No'
        else:
            ans[i] = 'Yes'

    print('\n'.join(map(str, ans)))
    return


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import numpy as np

n,k,q= map(int(input()))

scores = np.array([k] * n)

for i in range(q):
    ans = int(input())
    scores[:ans-1] = scores[:ans-1] - 1
    scores[ans:] = scores[ans:] - 1

for r in scores:
    if r >= 0:
        print('Yes')
    else:
        print('No')


Fixed submission:
# -*- coding: utf-8 -*-
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, K, Q, *A = map(int, read().split())

    B = [0] * N
    for a in A:
        B[a - 1] += 1

    ans = [0] * N
    for i, b in enumerate(B):
        if Q >= K + b:
            ans[i] = 'No'
        else:
            ans[i] = 'Yes'

    print('\n'.join(map(str, ans)))
    return


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from itertools import combination_with_replacement

n = int(input())
print(len(list(combination_with_replacement(n, 3))))


Fixed submission:
# -*- coding: utf-8 -*-
import itertools
n = int(input())
print(len(list(itertools.product(range(1,n+1), repeat=3))))
Buggy python submission (verdict: Runtime Error):
s = input().split()
t = input().split()

ans = 0
for i in range(3):
    if s[i] == t[i]:
        ans += 1

print(ans)


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

ans = 0
for i in range(3):
    if s[i] == t[i]:
        ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n = int(input())
h = reversed(list(map(int, input().split())))

cnt = 0
for i in range(n-1):
    if h[i+1] - h[i] > 1:
        print('No')
        exit(0)
    elif h[i+1] - h[i] == 1:
        h[i+1] -= 1

print('Yes')


Fixed submission:
# -*- coding: utf-8 -*-
n = int(input())
h = list(reversed(list(map(int, input().split()))))

cnt = 0
for i in range(n-1):
    if h[i+1] - h[i] > 1:
        print('No')
        exit(0)
    elif h[i+1] - h[i] == 1:
        h[i+1] -= 1

print('Yes')
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
print(3*int(input)**2)


Fixed submission:
# -*- coding: utf-8 -*-
print(3*int(input())**2)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
n = int(input())

a = [int(input()) for _ in range(n)]

for i in range(n):
    print(max(a[:i]+a[i+1:]))


Fixed submission:
# -*- coding: utf-8 -*-
n = int(input())

a = [int(input()) for _ in range(n)]

most = max(a)
most_idx = a.index(most)
second = max(a[:most_idx] + a[most_idx+1:])

for i in range(n):
    print(second if a[i] == most else most)
Buggy python submission (verdict: Runtime Error):
n, d = map(int, input().split())
x_l = [list(map(int, input().split)) for _ in range(n)]

ans = 0

for i in range(n):
    for j in range(i+1, n):
        tmp = 0
        for k in range(d):
            tmp += (x_l[j][k] - x_l[i][k]) ** 2
        if tmp**0.5%1 == 0:
            ans += 1

print(ans)


Fixed submission:
n, d = map(int, input().split())
x_l = [list(map(int, input().split())) for _ in range(n)]

ans = 0

for i in range(n):
    for j in range(i+1, n):
        tmp = 0
        for k in range(d):
            tmp += (x_l[j][k] - x_l[i][k]) ** 2
        if tmp**0.5%1 == 0:
            ans += 1

print(ans)

Buggy python submission (verdict: Runtime Error):
n, d = map(int, input().split())
x_l = [list(map(int, input().split))) for _ in range(n)]

ans = 0

for i in range(n):
    for j in range(i+1, n):
        tmp = 0
        for k in range(d):
            tmp += (x_l[j][k] - x_l[i][k]) ** 2
        if tmp**0.5%1 == 0:
            ans += 1

print(ans)


Fixed submission:
n, d = map(int, input().split())
x_l = [list(map(int, input().split())) for _ in range(n)]

ans = 0

for i in range(n):
    for j in range(i+1, n):
        tmp = 0
        for k in range(d):
            tmp += (x_l[j][k] - x_l[i][k]) ** 2
        if tmp**0.5%1 == 0:
            ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
def pop_min_abs(l):
    abs = map(abs, l)
    return l.pop(abs.index(min(abs)))



n, l = map(int, input().split())

apples = [l+i-1 for i in range(1,n+1)]
print(sum(pop_min_abs(apples)))


Fixed submission:
# -*- coding: utf-8 -*-
def pop_min_abs(l):
    abs_l = list(map(abs, l))
    l.pop(abs_l.index(min(abs_l)))
    return l



n, l = map(int, input().split())

apples = [l+i-1 for i in range(1,n+1)]
print(sum(pop_min_abs(apples)))
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

w, h, x, y = map(int, input().split())

core = (w/2, h/2)
base = h/w
slope = (core[1]-y)/(core[0]-x)

multi = (base >= slope and y == core[1]) or (base < slope and x == core[0])

print(w*h/2, 1 if multi else 0)


Fixed submission:
# -*- coding: utf-8 -*-

w, h, x, y = map(int, input().split())

def multi(w, h, x, y):
    core = (w/2, h/2)
    if (x == core[0])^(y == core[1]):
        return False
    elif x == core[0]:
        return True
    else:
        return False

print(w*h/2, 1 if multi(w, h, x, y) else 0)
Buggy python submission (verdict: Time Limit Exceeded):
 # -*- coding: utf-8 -*-
n, m = map(int, input().split())
a = [int(input()) for _ in range(m)]

INF = 10 ** 9 + 7

dp = [0] * (n+1)
dp[0] = 1

if 1 not in a:
    dp[1] = 1
else:
    dp[1] = 0

for i in range(2, n+1):
    if i in a:
        continue
    dp[i] = dp[i-1] + dp[i-2]
    dp[i] %= INF

print(dp[n])


Fixed submission:
 # -*- coding: utf-8 -*-
n, m = map(int, input().split())
a = set([int(input()) for _ in range(m)])

INF = 1000000007

dp = [0] * (n+1)
dp[0] = 1

if 1 not in a:
    dp[1] = 1
else:
    dp[1] = 0

for i in range(2, n+1):
    if i in a:
        continue
    dp[i] = dp[i-1] + dp[i-2]
    dp[i] %= INF

print(dp[n])
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

n, m = map(int, input().split())

lamps = [list(map(lambda x: int(x)-1, input().split()))[1:] for _ in range(n)]
p = list(map(int, input().split()))

ans = 0

for i in range(1 << n):
    for r in range(m):
        on_sum=0
        for j in range(n):
            if i >> j & 1 and j in lamps[r]:
                on_sum += 1

        if on_sum % 2 != p[r]:
            break

    else:
        ans += 1

print(ans)


Fixed submission:
# -*- coding: utf-8 -*-

n, m = map(int, input().split())

lamps = [list(map(lambda x: int(x)-1, input().split()))[1:] for _ in range(m)]
p = list(map(int, input().split()))

ans = 0

for i in range(1 << n):
    for r in range(m):
        on_sum=0
        for j in range(n):
            if i >> j & 1 and j in lamps[r]:
                on_sum += 1

        if on_sum % 2 != p[r]:
            break

    else:
        ans += 1

print(ans)

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

n, m = map(int, input().split())

lamps = [list(map(lambda x: int(x)-1, input().split()))[1:] for _ in range(n)]
p = map(int, input().split())

ans = 0

for i in range(1 << n):
    for r in range(m):
        on_sum=0
        for j in range(n):
            if i >> j & 1 and j in lamps[r]:
                on_sum += 1

        if on_sum % 2 != p[r]:
            break

    else:
        ans += 1

print(ans)


Fixed submission:
# -*- coding: utf-8 -*-

n, m = map(int, input().split())

lamps = [list(map(lambda x: int(x)-1, input().split()))[1:] for _ in range(m)]
p = list(map(int, input().split()))

ans = 0

for i in range(1 << n):
    for r in range(m):
        on_sum=0
        for j in range(n):
            if i >> j & 1 and j in lamps[r]:
                on_sum += 1

        if on_sum % 2 != p[r]:
            break

    else:
        ans += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

n, m = map(int, input().split())

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

passed = [1 for _ in range(n)]

for card in range(1,n+1):
    for gate in gates:
        if not gate[0] <= card <= gate[1]:
            passed[card-1] = 0
            break

print(sum(passed))


Fixed submission:
import numpy as np
N,M=map(int,input().strip().split())
LR=np.array([list(map(int,input().strip().split())) for _ in range(M)])
print(max(min(LR[:,1])-max(LR[:,0])+1,0))

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

n, m = map(int, input().split())

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

passed = [1 for _ in range(n)]

for card in range(1,n+1):
    for gate in gates:
        if not gate[0] <= card <= gate[1]:
            passed[card-1] = 0

print(sum(passed))


Fixed submission:
import numpy as np
N,M=map(int,input().strip().split())
LR=np.array([list(map(int,input().strip().split())) for _ in range(M)])
print(max(min(LR[:,1])-max(LR[:,0])+1,0))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
ls=list(map(int,input().split()))

s=1
for i in ls:
    s*=i

if s>10**18:
    print(-1)
else:
    print(s)

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

s=1
over=False

if 0 in ls:
    s=0
else:
    for i in ls:
        s*=i
        if s>10**18:
            over=True
            break


if over:
    print(-1)
else:
    print(s)
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
marks = {i+1:-1 for i in range(n)}
roots = {i+1:[] for i in range(n)}
count = 0
for i in range(m):
    a,b = map(int,input().split())
    roots[a].append(b)
    roots[b].append(a)

before_room = 1
searchs = [{'root':roots[1], 'mark':1}]
while searchs != []:
    next_search = []
    for search in searchs:
        for root in search['root']:
            new_root = []
            if marks[root] == -1:
                marks[root] = search['mark']
                count += 1
                new_root += roots[root]
            next_search.append({'root':roots[root], 'mark':root})
    if count >= n-1:
        break
    searchs = next_search[:]

del marks[1]
print('Yes')
for v in marks.values():
    print(v)
    

Fixed submission:
n,m=map(int,input().split())
marks = {i+1:-1 for i in range(n)}
marks[1] = 0
roots = {i+1:[] for i in range(n)}
count = 0
for i in range(m):
    a,b = map(int,input().split())
    roots[a].append(b)
    roots[b].append(a)

before_room = 1
searchs = [{'root':roots[1], 'mark':1}]
while searchs != []:
    next_search = []
    for search in searchs:
        for root in search['root']:
            new_root = []
            if marks[root] == -1:
                marks[root] = search['mark']
                count += 1
                new_root += roots[root]
            else:
                continue
            next_search.append({'root':roots[root], 'mark':root})
    searchs = next_search[:]

del marks[1]
print('Yes')
for v in marks.values():
    print(v)
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
ls=list(map(int,input().split()))
ps=[]
length=0
goto=1
while True:
    idx=goto-1
    goto=ls[idx]
    if goto==-1:
        break
    ps.append(goto)
    ls[idx]=-1
    length+=1

amari=(k-1)%3
print(ps[amari])

Fixed submission:
n,k=map(int,input().split())
ls=list(map(int,input().split()))
check_ls=[0 for i in range(n)]
ps=[1]
nxt=1
while True:
    idx=nxt-1
    if check_ls[idx]==-1:
        break
    ps.append(ls[idx])
    nxt=ls[idx]
    check_ls[idx]=-1

loop_start_idx = ps.index(ps[-1])
loop_length=len(ps)-loop_start_idx-1
loop_ls=ps[loop_start_idx:-1]
if k<len(ps):
    print(ps[k])
else:
    idx=(k-loop_start_idx)%loop_length
    print(loop_ls[idx])

Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
ls=list(map(int,input().split()))
ps=[]
length=0
goto=1
for _ in range(100):
    idx=goto-1
    goto=ls[idx]
    if goto==-1:
        break
    ps.append(goto)
    ls[idx]=-1
    length+=1

amari=(k-1)%3
print(ps[amari])

Fixed submission:
n,k=map(int,input().split())
ls=list(map(int,input().split()))
check_ls=[0 for i in range(n)]
ps=[1]
nxt=1
while True:
    idx=nxt-1
    if check_ls[idx]==-1:
        break
    ps.append(ls[idx])
    nxt=ls[idx]
    check_ls[idx]=-1

loop_start_idx = ps.index(ps[-1])
loop_length=len(ps)-loop_start_idx-1
loop_ls=ps[loop_start_idx:-1]
if k<len(ps):
    print(ps[k])
else:
    idx=(k-loop_start_idx)%loop_length
    print(loop_ls[idx])
Buggy python submission (verdict: Runtime Error):
x=int(input())

b=0
while True:
    p,m=b, -b
    xp, xm = x+p**5, x+m**5
    if (xp**(1/5)).is_integer():
        ans=[int(xp**(1/5)),p]
        break
    if (xm**(1/5)).is_integer():
        ans=[int(xm**(1/5)),m]
        break
    b+=1

print(" ".join(list(map(str,ans))))

Fixed submission:
import math
x=int(input())

b=0
while True:
    p,m=b, -b
    xp, xm = x+p**5, x+m**5
    flag=False
    for i in range(math.ceil(abs(xp)**0.2)+1):
        if i**5 - p**5 == x:
            ans=[i,p]
            flag=True
            break
        if (-1*i)**5 - p**5 == x:
            ans=[-1*i,p]
            flag=True
            break
    for i in range(math.ceil(abs(xm)**0.2)+1):
        if i**5 - m**5 == x:
            ans=[i,m]
            flag=True
            break
        if (-1*i)**5 - m**5 == x:
            ans=[-1*i,m]
            flag=True
            break
    if flag:
        break
    b+=1

print(" ".join(list(map(str,ans))))