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

Fixed submission:
C = input()
D = chr(ord(C)+1)

print(D)

Buggy submission (verdict: Runtime Error):
from collections import deque

H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]

dir = [(-1, 0), (1, 0), (0, -1), (0, 1)]

dist = [[-1] * W for _ in range(H)]

def BFS(y, x):
  """(y, x)からはじめて、道のマスをBFSで最短距離を探す"""
  que = deque()
  que.append((y, x))
  dist[y][x] = 0
  max_dist = 0
  while que:
    sy, sx = que.popleft()  # popleft?
    for dy, dx in dir:
      ny = sy + dy
      nx = sx + dx
      if 0 <= ny < H and 0 <= nx < W and S[ny][nx] != "#" and dist[ny][nx] == -1:
        que.append((ny, nx))
        dist[ny][nx] = dist[sy][sx] + 1
        max_dist = max(max_dist, dist[ny][nx])
  
  return max_dist

max_dist = 0
for sy in range(H):
  for sx in range(W):
    if S[sy][sx] != "#":
      dist = [[-1] * W for _ in range(H)]
      max_dist = max(max_dist, BFS(sy, sx))
      
print(max_dist)
Problem p02921 (python)

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

count = 0
for s, t in zip(S, T):
  if s == t:
    count += 1
    
print(count)

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

count = 0
avail = 1

while avail < B:
  avail -= 1
  count += 1
  avail = +A

print(count)
Problem p03157 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10 ** 7)

H, W = map(int, input().split())
F = [list(input()) for _ in range(H)]

move = [(-1, 0), (1, 0), (0, -1), (0, 1)]
seen = [[0] * W for _ in range(H)]

# Fの点を頂点とするグラフを考える。グラフの連結成分に'#'がbコ, '.'がwコある場合、
# b*wが条件を満たす

def dfs(sy, sx):
    seen[sy][sx] = 1
    b, w = 1, 0
    
    for dy, dx in move:
      ny = sy + dy
      nx = sx + dx
      if 0 <= ny < H and 0 <= nx < W and F[ny][nx] != F[sy][sx] and not seen[ny][nx]:
        p = dfs(ny, nx)
        b += p[1]  # 逆にしている
        w += p[0]  # 天才か？
    return (b, w)
        
count = 0
for i in range(H):
    for j in range(W):
        if not seen[i][j]:
            b, w = dfs(i, j)
            count += b * w

print(count)

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
F = [list(input()) for _ in range(H)]

move = [(-1, 0), (1, 0), (0, -1), (0, 1)]
seen = [[0] * W for _ in range(H)]

# Fの点を頂点とするグラフを考える。グラフの連結成分に'#'がbコ, '.'がwコある場合、
# b*wが条件を満たす

def dfs(sy, sx):
    seen[sy][sx] = 1
    b, w = 1, 0
    
    for dy, dx in move:
      ny = sy + dy
      nx = sx + dx
      if 0 <= ny < H and 0 <= nx < W and F[ny][nx] != F[sy][sx] and not seen[ny][nx]:
        p = dfs(ny, nx)
        b += p[1]  # 逆にしている
        w += p[0]  # 天才か？
    return (b, w)
        
count = 0
for i in range(H):
    for j in range(W):
        if not seen[i][j]:
            b, w = dfs(i, j)
            count += b * w

print(count)

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
F = [list(input()) for _ in range(H)]

move = (-1, 1)
count = []

def dfs(i, j, seen):
    seen.add((i, j))
    if F[i][j] == '#':
        next = '.'
    else:
        next = '#'

    for m in move:
        if 0 <= i+m < H and F[i+m][j] == next and (i+m, j) not in seen:
            seen.add((i+m, j))
            if F[i][j] == '#':
                count.append((i+m, j))

            dfs(i+m, j, seen)
        if 0 <= j+m < W and F[i][j+m] == next and (i, j+m) not in seen:
            seen.add((i, j+m))
            if F[i][j] == '#':
                count.append((i, j+m))
            dfs(i, j+m, seen)

for i in range(H):
    for j in range(W):
        if F[i][j] == '#':
            dfs(i, j, set())

print(len(count))
Problem p03160 (python)

Fixed submission:
N = int(input())
h = [int(n) for n in input().split()]


cost = [0] * (N+1)

for i in range(N):
    if i == 0:
        cost[i] = 0
    elif i == 1:
        cost[i] = abs(h[i] - h[i-1])

    if i >= 2:
        cost[i] = min(cost[i-1] + abs(h[i] - h[i-1]), cost[i-2] + abs(h[i] - h[i-2]))

print(cost[N-1])

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
h = [int(x) for x in input().split()]

INF = float('inf')
dp = [INF for _ in range(N+10)]

# initial state
dp[0] = 0

for i in range(N):
    for j in range(1, min(K+1, len(h)-i)):
        dp[i+j] = min(dp[i] + abs(h[j+i] - h[i]), dp[i+j])

print(dp[N-1])

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
h = [int(x) for x in input().split()]

INF = float('inf')
dp = [INF for _ in range(N+K+10)]

# initial state
dp[0] = 0

for i in range(N):
    for j in range(1, min(K+1, len(h)-i)):
        dp[i+j] = min(dp[i] + abs(h[j+i] - h[i]), dp[i+j])

print(dp[N-1])
Problem p03161 (python)

Fixed submission:
N, K = map(int, input().split())
h = [int(x) for x in input().split()]

INF = float('inf')
dp = [INF for _ in range(N+K+10)]

# initial state
dp[0] = 0

for i in range(N):
    for j in range(1, min(K+1, len(h)-i)):
        dp[i+j] = min(dp[i] + abs(h[j+i] - h[i]), dp[i+j])

print(dp[N-1])

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
h = [int(x) for x in input().split()]

assert len(h) == N, print(f'length of steps {len(h)} doesn\'t equal to {K}')

# list dp retains information for the minimum costs
# if dp[i] = n, it means n is the minimum cost to get to i step
# if dp[i] = INF, it means the minimum cost has not been evaluated yet
INF = float('inf')
dp = [INF for _ in range(N+K+10)]

# initial state
dp[0] = 0

for i in range(N):
    for j in range(1, min(K+1, len(h)-i)):
        dp[i+j] = min(dp[i] + abs(h[j+i] - h[i]), dp[i+j])
        
print(dp[N-1])
Problem p03501 (python)

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

if N * A <= B:
  print(N*A)
else:
  print(B)

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

if N * A <= B:
  print(N*A)
else:
  print(B)

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

def digitsum(a):
  x = 0
  while a > 0:
    x += a % 10
    a /= 10
  return x

if N % digitsum(N) == 0:
  print('Yes')
else:
  print('No')
Problem p03502 (python)

Fixed submission:
N = int(input())

def digitsum(a):
  sum_ = 0
  while a > 0:
    sum_ += int(a)%10
    a /= 10
  return sum_

if N % digitsum(N) == 0:
  print('Yes')
else:
  print('No')

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

def digitsum(a):
  x = 0
  while a > 0:
    x += a % 10
    a /= 10
  
  return x

if N % digitsum(N) == 0:
  print('Yes')
else:
  print('No')
Problem p03555 (python)

Fixed submission:
import sys

C1 = input()
C2 = input()[::-1]


for i in range(len(C1)):
  if C1 != C2:
    print("NO")
    sys.exit()

print("YES")

Buggy submission (verdict: Runtime Error):
from bisect import bisect_left, bisect_right

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

A.sort()
C.sort()

count = 0
for b in B:
    upper = bisect_left(A, b)  # returns number of elements which satisfy a < b
    lower = bisect_right(C, b)
    count += upper * (len(C) - lower)

print(count)
Problem p03557 (python)

Fixed submission:
from bisect import bisect_left, bisect_right

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

A.sort()
C.sort()

count = 0
for b in B:
    upper = bisect_left(A, b)  # returns number of elements which satisfy a < b
    lower = bisect_right(C, b)
    count += upper * (len(C) - lower)

print(count)

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

A.sort()
C.sort()

count = 0
for b in B:
    upper = bisect_left(A, b)  # returns number of elements which satisfy a < b
    lower = bisect_right(C, b)
    count += upper * (len(C) - lower)

print(count)
Problem p03574 (python)

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

S = [list(input()) for _ in range(H)]
dydx = [(-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 1), (1, -1), (1, 0), (1, 1)]


def check(h, w):
  count = 0
  for dy, dx in dydx:
    if 0 <= h + dy < H and 0 <= w + dx < W and S[h+dy][w+dx] == '#':
      count += 1
  return count

for h in range(H):
  for w in range(W):
    if S[h][w] == '.':
      S[h][w] = str(check(h, w))
  res = "".join(S[h])
  print(res)

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

S = [list(input()) for _ in range(H)]
dydx = [(-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 1), (1, -1), (1, 0), (1, 1)]

def check(h, w):
  count = 0
  for dy, dx in dydx:
    if 0 <= h + dy < H and 0 <= w + dx < W and S[h+dy][w+dx] == '#':
      count += 1
  return count
      
  

for h in range(H):
  for w in range(W):
    if S[h][w] == '.':
      S[h][w] = check(h, w)
  print("".join(S[h])
Problem p03998 (python)

Fixed submission:
A = input()
B = input()
C = input()

x = A[0]

def turn(A, B, C, x):
  if x == 'a':
    if len(A) == 0:
      print('A')
      return
    else:
      y = A[0]
      A = A[1:]
      
  if x == 'b':
    if len(B) == 0:
      print('B')
      return
    else:
      y = B[0]
      B = B[1:]
  
  if x == 'c':
    if len(C) == 0:
      print('C')
      return
    else:
      y = C[0]
      C = C[1:]
  
  return turn(A, B, C, y)

turn(A, B, C, x)

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

S['a'] = input()[::-1]
S['b'] = input()[::-1]
S['c'] = input()[::-1]

player = 'a'

while S[player]:
  player = S[player].pop()

  
res = player.upper()
print(res)
Problem p02691 (python)

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]
dp = [0] * 10 ** 7
ans = 0
for i in range(N):
    x = i + 1 - A[i]
    if x >= 0:
        ans += dp[x]
    y = i + 1 + A[i]
    if y < 10 ** 7:
        dp[y] += 1

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(i) for i in input().split()]
dp = [0] * 10 ** 7
ans = 0
for i in range(N):
    x = i + 1 - A[i]
    if x >= 0:
        ans += dp[x]
    if x < 10 ** 7:
        dp[i + 1 + A[i]] += 1

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(i) for i in input().split()]
dp = [0] * 10 ** 7
ans = 0
for i in range(N):
    x = i + 1 - A[i]
    if x >= 0:
        ans += dp[x]
    if x < 10 ** 7:
        dp[i + 1 + A[i]] += 1

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(i) for i in input().split()]
dp = [0] * 10 ** 6
ans = 0
for i in range(N):
    x = i + 1 - A[i]
    if x >= 0:
        ans += dp[x]
    if x < 10 ** 6:
        dp[i + 1 + A[i]] += 1

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(i) for i in input().split()]
dp = [0] * (10 ** 9 + 2 * (10 ** 5))
ans = 0
for i in range(N):
    x = i + 1 - A[i]
    if x >= 0:
        ans += dp[x]
    dp[i + 1 + A[i]] += 1

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(i) for i in input().split()]
dp = [0] * (10 ** 9 + 2 * (10 ** 5))
ans = 0
for i in range(N):
    x = i + 1 - A[i]
    if x >= 0:
        ans += dp[x]
    dp[i + 1 + A[i]] += 1

print(ans)
Problem p02748 (python)

Fixed submission:
abm = [int(n) for n in input().split()]

a = abm[0]
b = abm[1]
m = abm[2]
am, bm = 1000000, 1000000
al = [int(n) for n in input().split()]
bl = [int(n) for n in input().split()]
for i in al:
    if am > i:
        am = i
for i in bl:
    if bm > i:
        bm = i
ans = am + bm

for i in range(m):
    x, y, c = map(int, input().split())
    x = x - 1
    y = y - 1
    cur = al[x] + bl[y] - c
    if cur < ans:
        ans = cur

print(ans)

Buggy submission (verdict: Runtime Error):
A, B, M = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
ans = 10000000
for _ in range(M):
    x, y, c = map(int, input().split())
    ans = min(ans, a[x - 1] + a[y - 1] - c)
a.sort()
b.sort()
print(min(ans, a[0] + b[0]))
Problem p02616 (python)

Fixed submission:
# import sys
# readline = sys.stdin.readline
# generator = (readline().strip() for _ in range(N))

# N, M = map(int, input().split())
# As = list(map(int, input().split()))
# queries = (input() for _ in range(N))

from bisect import bisect_left


def solve():
    N, K = map(int, input().split())

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

    As.sort()
    index = bisect_left(As, 0)

    # neg = As[:index]
    # pos = As[index:]
    # pos = pos[bisect_left(pos, 1):]
    # pos.sort(reverse=True)
    # print(pos, neg)

    pos = sorted(As, reverse=True)
    ans = 1
    mod = 10 ** 9 + 7

    if N == K:
        for p in pos:
            ans *= p
            ans %= mod
        return ans

    if index == N and K % 2:
        for p in pos[:K]:
            ans *= p
            ans %= mod
        return ans

    pl = 0
    pr = N - 1

    for i in range(K//2):
        left = pos[pl] * pos[pl+1]
        right = pos[pr] * pos[pr-1]

        if left > right:
            ans *= left
            ans %= mod
            pl += 2
        else:
            ans *= right
            ans %= mod
            pr -= 2

    if K % 2:
        ans *= max(pos[pl], pos[pr])
        ans %= mod

    return ans


def main():
    print(solve())


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
# import sys
# readline = sys.stdin.readline
# generator = (readline().strip() for _ in range(N))

# N, M = map(int, input().split())
# As = list(map(int, input().split()))
# queries = (input() for _ in range(N))

from bisect import bisect_left


def solve():
    N, K = map(int, input().split())

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

    As.sort()
    index = bisect_left(As, 0)

    # neg = As[:index]
    # pos = As[index:]
    # pos = pos[bisect_left(pos, 1):]
    # pos.sort(reverse=True)
    # print(pos, neg)

    pos = sorted(As, reverse=True)
    ans = 1
    mod = 10 ** 9 + 7

    if N == K:
        for p in pos:
            ans *= p
            ans %= mod
        return ans

    if index == N and K % 2:
        for p in pos[:K]:
            ans *= p
            ans %= mod
        return ans

    pl = 0
    pr = N - 1
    
    if K % 2:
        ans *= pos[pr]
	    pr -= 1

    for i in range(K//2):
        left = pos[pl] * pos[pl+1]
        right = pos[pr] * pos[pr-1]

        if left > right:
            ans *= left
            ans %= mod
            pl += 2
        else:
            ans *= right
            ans %= mod
            pr -= 2

    return ans


def main():
    print(solve())


if __name__ == "__main__":
    main()
Problem p02642 (python)

Fixed submission:
# import sys
# readline = sys.stdin.readline
# generator = (readline().strip() for _ in range(N))

# import numpy as np
# from itertools import permutations
# from itertools import combinations
# from itertools import combinations_with_replacement

# import heapq
# from collections import deque

# N, M = map(int, input().split())
# sequence = list(map(int, input().split()))
# queries = (input() for _ in range(N))


def solve():
    N = int(input())
    sequence = list(map(int, input().split()))

    sequence.sort()

    max_v = sequence[-1]

    dp = [True] * (max_v + 1)

    previous = -1
    for v in sequence:
        if v == previous:
            dp[v] = False
            continue

        previous = v

        if not dp[v]:
            continue

        for iv in range(2 * v, max_v+1, v):
            dp[iv] = False

    count = 0
    for v in sequence:
        if dp[v]:
            count += 1

    return count


def main():
    print(solve())


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np


def solve(sequence):

    sequence.sort()

    max_v = sequence[-1]

    dp = [True] * (max_v + 1)

    previous = -1
    for v in sequence:
        if v == previous:
            dp[v] = False
            continue

        previous = v

        if not dp[v]:
            continue

        for iv in range(2 * v, max_v+1, v):
            dp[iv] = False

    count = 0
    for v in sequence:
        if dp[v]:
            count += 1

    return count


if sys.argv[-1] == 'ONLINE_JUDGE':
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('main', '(i8[::1])')(solve)
    cc.compile()
    exit()


from my_module import solve


def main():
    _ = input()
    sequence = np.array(input().split(), np.int64)
    print(solve(sequence))


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np


def solve(sequence):

    sequence.sort()

    max_v = sequence[-1]

    dp = [True] * (max_v + 1)

    previous = -1
    for v in sequence:
        if v == previous:
            dp[v] = False
            continue

        previous = v

        if not dp[v]:
            continue

        for iv in range(2 * v, max_v+1, v):
            dp[iv] = False

    count = 0
    for v in sequence:
        if dp[v]:
            count += 1

    return count


if sys.argv[-1] == 'ONLINE_JUDGE':
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('main', '(i8[::1])')(solve)
    cc.compile()
    exit()


from my_module import solve


def main():
    sequence = np.array(input().split(), np.int64)
    print(solve(sequence))


if __name__ == "__main__":
    main()
Problem p02683 (python)

Fixed submission:
# import numpy as np
# import queue
# import heapq


def main():
    N, M, X = map(int, input().split())

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

    min_total_cost = 10**9
    for i in range(2**N):
        total_cost = 0
        learned = [0] * M

        for j in range(N):
            if (i >> j) & 1:
                C, *As = books[j]
                total_cost += C

                for ids, a in enumerate(As):
                    learned[ids] += a

        if min(learned) >= X:
            min_total_cost = min(min_total_cost, total_cost)

    if min_total_cost == 10**9:
        print('-1')
    else:
        print(min_total_cost)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    N, M, X = map(int, input().split())

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

    min_total_cost = 10**9

    for i in range(2**N):
        total_cost = 0
        learned = [0] * M

        for j in range(N):
            if (i >> j) & 1:
                cost, points = books[j]
                total_cost += cost
                
                learned = [x + y for x, y in zip(learned, points)]

        if min(learned) >= X:
            min_total_cost = min(min_total_cost, total_cost)

    if min_total_cost == 10**9:
        print('-1')
    else:
        print(min_total_cost)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import numpy as np


def main():
    N, M, X = map(int, input().split())

    books = np.array([list(map(int, input().split())) for _ in range(N)])

    min_total_cost = 10**9

    for i in range(2**N):
        to_read_indexes = np.array(list(str(i)), dtype=int)
        to_read_books = books[to_read_indexes, :]
        total_cost = to_read_books[:, 0].sum()
        increased_levels = to_read_books[:, 1:].sum(axis=0)

        if min(increased_levels) >= X:
            min_total_cost = min(min_total_cost, total_cost)

    if min_total_cost == 10**9:
        print('-1')
    else:
        print(min_total_cost)


if __name__ == "__main__":
    main()
Problem p02686 (python)

Fixed submission:
# import sys
# input = sys.stdin.readline


def solve():
    N = int(input())
    brackets_gen = (input() for _ in range(N))

    grads_positive = list()
    grads_negative = list()

    total = 0
    for brackets in brackets_gen:

        elevation, bottom = 0, 0

        for bk in brackets:

            elevation += 1 if bk == '(' else -1
            bottom = min(bottom, elevation)

        if elevation >= 0:
            grads_positive.append((bottom, elevation))
        elif elevation < 0:
            grads_negative.append((bottom - elevation, -elevation))

        total += elevation

    if total != 0:
        return False

    grads_positive.sort(reverse=True)
    grads_negative.sort(reverse=True)

    def is_good(grads):
        elevation, bottom = 0, 0
        for grad in grads:
            bottom = elevation + grad[0]
            if bottom < 0:
                return False
            elevation += grad[1]

        return True

    if is_good(grads_positive) and is_good(grads_negative):
        return True
    else:
        return False


def main():
    ok = solve()
    if ok:
        print('Yes')
    else:
        print('No')


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
readline = sys.stdin.readline().strip


def solve():
    N = int(input())
    brackets_generator = (readline() for _ in range(N))

    grads_positive = list()
    grads_negative = list()

    total = 0
    for brackets in brackets_generator:

        elevation, bottom = 0, 0

        for bk in brackets:

            elevation += 1 if bk == '(' else -1
            bottom = min(bottom, elevation)

        if elevation >= 0:
            grads_positive.append((bottom, elevation))
        elif elevation < 0:
            grads_negative.append((bottom - elevation, -elevation))

        total += elevation

    if total != 0:
        return False

    grads_positive.sort(reverse=True)
    grads_negative.sort(reverse=True)

    def is_good(grads):
        elevation, bottom = 0, 0
        for grad in grads:
            bottom = elevation + grad[0]
            if bottom < 0:
                return False
            elevation += grad[1]

        return True

    if is_good(grads_positive) and is_good(grads_negative):
        return True
    else:
        return False


def main():
    ok = solve()
    if ok:
        print('Yes')
    else:
        print('No')


if __name__ == "__main__":
    main()
Problem p02690 (python)

Fixed submission:
"""
A^5 - B^5
= (A - B)(A^4 + A^3*B + A^2*B^2 + A*B^3 + B^4)
= (A - B){(A + B) * (A^3 + B^3) + A^2*B^2}
= (A - B){(A + B)^2 * (A^2 - AB + B^2) + A^2*B^2}

-> (A + B)^2 > 1, (A^2 - AB + B^2) > 1, A^2*B^2 > 1.
"""


def main():
    print(*solve())


def solve():
    X = int(input())

    for a in range(-1000, 1000):
        for b in range(-1000, 1000):
            if a ** 5 - b ** 5 == X:
                return a, b


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    print(*solve())


def solve():
    X = int(input())
    N = 10 ** 9 + 7

    step = 2 if X % 2 else step = 1  # if X is odd number, (A - B) also must be odd.

    for x in range(1, N, step):  # x means (A - B)
        if X % x:  # X must be divided by (A - B)
            continue

        for a in range(N):
            b = a - x

            diff = X - (a ** 5 - b ** 5)
            if diff == 0:
                return a, b

            if diff < 0 < b:
                break


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
"""
A^5 - B^5
= (A - B)(A^4 + A^3*B + A^2*B^2 + A*B^3 + B^4)
= (A - B){(A + B) * (A^3 + B^3) + A^2*B^2}
= (A - B){(A + B)^2 * (A^2 - AB + B^2) + A^2*B^2}

-> (A + B)^2 > 1, (A^2 - AB + B^2) > 1, A^2*B^2 > 1.
"""


def main():
    print(*solve())


def solve():
    X = int(input())

    for a in range(-100, 100):
        for b in range(-100, 100):
            if a ** 5 - b ** 5 == X:
                return a, b


if __name__ == "__main__":
    main()