Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
def getval():
    s = input()
    t = input()
    return s,t

def main(s,t):
    dp = [["" for i in range(len(t)+1)]]
    for i in range(len(s)):
        temp = [""]
        for j in range(len(t)):
            if s[i]==t[j]:
                temp.append("".join([dp[i][j],s[i]]))
            else:
                if len(dp[i][j+1])>len(temp[-1]):
                    temp.append(dp[i][j+1])
                else:
                    temp.append(temp[-1])
        dp.append(temp)
    print(dp[len(s)][len(t)])
                    
if __name__=="__main__":
    s,t = getval()
    main(s,t)

Fixed submission:
from copy import copy

def getval():
    s = input()
    t = input()
    return s,t

def main(s,t):
    dp = ["" for i in range(len(t)+1)]
    for i in range(len(s)):
        temp = [""]
        for j in range(len(t)):
            prev = dp[j+1]
            last = temp[-1]
            if len(prev)>len(last):
                temp.append(prev)
            elif len(prev)<len(last):
                temp.append(last)
            elif s[i]==t[j]:
                temp.append("".join([dp[j],s[i]]))
            else:
                temp.append(prev)
        dp = copy(temp)
        
    print(dp[len(t)])
                    
if __name__=="__main__":
    s,t = getval()
    main(s,t)

Buggy python submission (verdict: Time Limit Exceeded):
def getval():
    s = input()
    t = input()
    return s,t

def main(s,t):
    dp = [["" for i in range(len(t)+1)]]
    for i in range(len(s)):
        temp = [""]
        for j in range(len(t)):
            if s[i]==t[j]:
                temp.append("".join([dp[i][j],s[i]]))
            else:
                if len(dp[i][j+1])>len(temp[-1]):
                    temp.append(dp[i][j+1])
                else:
                    temp.append(temp[-1])
        dp.append(temp)
    print(dp[len(s)][len(t)])
                    
if __name__=="__main__":
    s,t = getval()
    main(s,t)

Fixed submission:
from copy import copy

def getval():
    s = input()
    t = input()
    return s,t

def main(s,t):
    dp = ["" for i in range(len(t)+1)]
    for i in range(len(s)):
        temp = [""]
        for j in range(len(t)):
            prev = dp[j+1]
            last = temp[-1]
            if len(prev)>len(last):
                temp.append(prev)
            elif len(prev)<len(last):
                temp.append(last)
            elif s[i]==t[j]:
                temp.append("".join([dp[j],s[i]]))
            else:
                temp.append(prev)
        dp = copy(temp)
        
    print(dp[len(t)])
                    
if __name__=="__main__":
    s,t = getval()
    main(s,t)
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input())
print(str(a*b-a-b+1))

Fixed submission:
a,b = map(int,input().split())
print(str(a*b-a-b+1))
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
dif = b-a 
temp = 0
for i in range(dif):
    temp += i 
ans = temp - a
print(ans)

Fixed submission:
n = int(input())
if n<1000:
    print("ABC")
else:
    print("ABD")
Buggy python submission (verdict: Runtime Error):
from copy import deepcopy

def getval():
    n,ma,mb = map(int,input().split())
    p = [list(map(int,input().split())) for i in range(n)]
    return n,ma,mb,p 

def main(n,ma,mb,p):
    dp = [[[-1 for i in range(401)] for i in range(401)]]
    dp[0][0][0] = 0
    for i in range(n):
        temp = deepcopy(dp[-1])
        temp[0][0] = 0
        cur = p[i]
        prev = dp[-1]
        for a in range(401):
            for b in range(401):
                if cur[0]>a or cur[1]>b:
                    continue
                if prev[a-cur[0]][b-cur[1]]==-1:
                    continue
                elif prev[a][b]==-1:
                    temp[a][b] = prev[a-cur[0]][b-cur[1]] + cur[2]
                    #print(i,a,b,temp[a][b],prev[a-cur[0]][b-cur[1]])
                else:
                    temp[a][b] = min(prev[a][b], prev[a-cur[0]][b-cur[1]] + cur[2])
        #dp.append(temp)
    ans = -1
    for i in range(1,11):
        if i*ma>10 or i*mb>10:
            break
        if dp[n][i*ma][i*mb]!=-1:
            if ans==-1:
                ans = dp[n][i*ma][i*mb]
            else:
                ans = min(ans,dp[n][i*ma][i*mb])
    print(ans)
    print(dp[n])

if __name__=="__main__":
    n,ma,mb,p = getval()
    main(n,ma,mb,p)

Fixed submission:
from copy import deepcopy

def getval():
    n,ma,mb = map(int,input().split())
    p = [list(map(int,input().split())) for i in range(n)]
    return n,ma,mb,p 

def main(n,ma,mb,p):
    dp = [[[-1 for i in range(401)] for i in range(401)]]
    dp[0][0][0] = 0
    for i in range(n):
        temp = deepcopy(dp[-1])
        temp[0][0] = 0
        cur = p[i]
        prev = dp[-1]
        for a in range(401):
            for b in range(401):
                if cur[0]>a or cur[1]>b:
                    continue
                if prev[a-cur[0]][b-cur[1]]==-1:
                    continue
                elif prev[a][b]==-1:
                    temp[a][b] = prev[a-cur[0]][b-cur[1]] + cur[2]
                    #print(i,a,b,temp[a][b],prev[a-cur[0]][b-cur[1]])
                else:
                    temp[a][b] = min(prev[a][b], prev[a-cur[0]][b-cur[1]] + cur[2])
        dp.append(temp)
    ans = -1
    for i in range(1,401):
        if i*ma>400 or i*mb>400:
            break
        if dp[n][i*ma][i*mb]!=-1:
            if ans==-1:
                ans = dp[n][i*ma][i*mb]
            else:
                ans = min(ans,dp[n][i*ma][i*mb])
    print(ans)
    #print(dp[n])

if __name__=="__main__":
    n,ma,mb,p = getval()
    main(n,ma,mb,p)
Buggy python submission (verdict: Runtime Error):
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>
#include <numeric>

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>
#include <numeric>

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n)
    {
        cin >> a[i];
    }

    ll ans = 0;
    ll sum = 0;
    ll sums = 0;

    ans = 0;

    for (int i = 0; i < n; i++)
    {
        sums += a[i];
    }

    ans += (sums%mod) * (sums%mod);

    for (int i = 0; i < n; i++)
    {
        ans -= (a[i] * a[i]) % mod;
    }

    if(ans < 0) {
        ans += mod;
    }
    ans %= mod;

    ans *= (1.0/2);
    ans %= mod;

    cout << ans  << endl;
}

/*
int main()
{
    int n;cin >> n;
    vector<ll> a(n);
    vector<ll> b(n-1);
    rep(i,n) {
        cin >> a[i];
    }

    ll ans = 0;
    ll sum = 0;
    for (int i = 1; i < n; i++)
    {
        sum += a[i];  
    }


    int i = 1;
    for(int j = 0; j < n - 1; j++) {
        b[j] = sum;
        sum -= a[i++];
    }

    for(int i = 0; i < n - 1; i++) {
        ans += (b[i]%mod)*(a[i]%mod);
        ans %= mod;
    }



    cout << ans << endl;

}
*/

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

suma = sum(a)**2
sums = 0
for i in range(n):
    sums += a[i]*a[i]

ans = (suma - sums) // 2
ans %= 1000000007

print(int(ans))

Buggy python submission (verdict: Runtime Error):
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>
#include <numeric>

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007

int main()
{
    int n;cin >> n;
    vector<ll> a(n);
    vector<ll> b(n-1);
    rep(i,n) {
        cin >> a[i];
    }

    ll ans = 0;
    ll sum = 0;
    ll sums = 0;
    for (int i = 1; i < n; i++)
    {
        sum += a[i];  
    }


    int i = 1;
    for(int j = 0; j < n - 1; j++) {
        b[j] = sum;
        sum -= a[i++];
    }

    for(int i = 0; i < n - 1; i++) {
        ans += b[i]*a[i];
        ans %= mod;
    }



    cout << ans << endl;

}

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

suma = sum(a)**2
sums = 0
for i in range(n):
    sums += a[i]*a[i]

ans = (suma - sums) // 2
ans %= 1000000007

print(int(ans))
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
print(a*b -(a+b-1))

Fixed submission:
s = list(map(int,input().split()))
print(s[0]*s[1] -(s[0]+s[1]-1))
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input.split())
print((n - 1) * (m - 1))

Fixed submission:
n, m = map(int, input().split())
print((n - 1) * (m - 1))
Buggy python submission (verdict: Runtime Error):
a = list(map(int, input().split()))
print("YES" if b - a == c - b else "NO")

Fixed submission:
a = list(map(int, input().split()))
print("YES" if a[1] - a[0] == a[2] - a[1] else "NO")
Buggy python submission (verdict: Runtime Error):
a = input()
if(a%2 == 1):
  print((a+1)//2)
if(a%2 == 0):
  print(a//2)

Fixed submission:
a = int(input())
if(a%2 == 1):
  print((a+1)//2)
if(a%2 == 0):
  print(a//2)
Buggy python submission (verdict: Runtime Error):
a = [int(i) for i in input().split()]
for i in range(0,a.len()):
  if a[i]==0:
    print(i+1)

Fixed submission:
a = [int(i) for i in input().split()]
for i in range(0,len(a)):
  if a[i]==0:
    print(i+1)
Buggy python submission (verdict: Runtime Error):
n=input()
x=input.split()
prod=1
for i in x:
  prod=prod*i
  if prod>1000000000000000000:
    break
if prod>1000000000000000000:
  print(-1)
else:
  print(prod)

Fixed submission:
n=input()
x=[int(i) for i in input().split()]
x.sort()
prod=1
for i in x:
  prod=prod*i
  if prod>1000000000000000000:
    break
if prod>1000000000000000000:
  print(-1)
else:
  print(prod)
Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
A = [[] for i in range(N)]
checkd = [False]*N
for _ in range(M):
    a,b = (map(lambda a: int(a)-1, input().split()))
    A[a].append(b)
    A[b].append(a)
nextS = set(range(N))
ans = 0
while len(nextS)>0:
    s = nextS.pop()
    if checkd[s]: 
        continue
    count = 0
    que = [s]
    while len(que)>0:
        nn = que.pop(0)
        if checkd[nn]:
            continue
        checkd[nn] = True
        nextS.discard(nn)
        count += 1
        que += A[nn]
    ans = max(count,ans)


print(ans)




Fixed submission:
from collections import deque

N,M = map(int,input().split())
A = [[] for i in range(N)]
checkd = [False]*N
for _ in range(M):
    a,b = (map(lambda a: int(a)-1, input().split()))
    A[a].append(b)
    A[b].append(a)
nextS = set(range(N))
ans = 0
while len(nextS)>0:
    s = nextS.pop()
    if checkd[s]: 
        continue
    count = 0
    que = deque([s])
    while len(que)>0:
        nn = que.popleft()
        if checkd[nn]:
            continue
        checkd[nn] = True
        nextS.discard(nn)
        count += 1
        que.extend(A[nn])
    ans = max(count,ans)


print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
A = [[] for i in range(N)]
checkd = [False]*N
for _ in range(M):
    a,b = (map(lambda a: int(a)-1, input().split()))
    A[a].append(b)
    A[b].append(a)
nextS = set(range(N))
ans = 0
while len(nextS)>0:
    s = nextS.pop()
    if checkd[s]: 
        continue
    count = 0
    que = [s]
    while len(que)>0:
        nn = que.pop(0)
        if checkd[nn]:
            continue
        checkd[nn] = True
        nextS.discard(nn)
        count += 1
        que += A[nn]
    ans = max(count,ans)


print(ans)




Fixed submission:
from collections import deque

N,M = map(int,input().split())
A = [[] for i in range(N)]
checkd = [False]*N
for _ in range(M):
    a,b = (map(lambda a: int(a)-1, input().split()))
    A[a].append(b)
    A[b].append(a)
nextS = set(range(N))
ans = 0
while len(nextS)>0:
    s = nextS.pop()
    if checkd[s]: 
        continue
    count = 0
    que = deque([s])
    while len(que)>0:
        nn = que.popleft()
        if checkd[nn]:
            continue
        checkd[nn] = True
        nextS.discard(nn)
        count += 1
        que.extend(A[nn])
    ans = max(count,ans)


print(ans)
Buggy python submission (verdict: Runtime Error):
import math
N,K = map(int,input().split())
a = list(map(int,input().split()))
low = 0
high = 10**9
while low  <= high:
    mid = (low+high)//2
    count = 0
    for item in a:
        count += math.ceil(item/mid)-1
    if count <= K:
        high = mid -1
    else:
        low = mid + 1
print(low)
    
    


Fixed submission:
import math
N,K = map(int,input().split())
a = list(map(int,input().split()))
def is_ok(arg):
    i = 0
    for item in a:
        i += math.ceil(item /arg) -1
    return i <=K

def meguru_bisect(ng, ok):
    '''
    初期値のng,okを受け取り,is_okを満たす最小(最大)のokを返す
    まずis_okを定義すべし
    ng ok は  とり得る最小の値-1 とり得る最大の値+1
    最大最小が逆の場合はよしなにひっくり返す
    '''
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return ok


print(meguru_bisect(0,10**9))

Buggy python submission (verdict: Runtime Error):
import math
N,K = map(int,input().split())
a = list(map(int,input().split()))
low = 0
high = 10**9
while low  <= high:
    mid = (low+high)//2
    count = 0
    for item in a:
        count += math.ceil(a/mid)-1
    if count <= K:
        high = mid -1
    else:
        low = mid + 1
print(low)
    
    


Fixed submission:
import math
N,K = map(int,input().split())
a = list(map(int,input().split()))
def is_ok(arg):
    i = 0
    for item in a:
        i += math.ceil(item /arg) -1
    return i <=K

def meguru_bisect(ng, ok):
    '''
    初期値のng,okを受け取り,is_okを満たす最小(最大)のokを返す
    まずis_okを定義すべし
    ng ok は  とり得る最小の値-1 とり得る最大の値+1
    最大最小が逆の場合はよしなにひっくり返す
    '''
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return ok


print(meguru_bisect(0,10**9))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int,input().split()))
res = 1
for i in a:
    res *= i
if res > 10**18:
    print(-1)
else:
    print(res)

Fixed submission:
def main():    
    N = int(input())
    a = list(map(int,input().split()))
    res = 1
    if 0 in a:
        print(0)
        return
    for i in a:
        res *= i
        if res > 10**18:
            print(-1)
            return
    print(res)
if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int,input().split()))
res = 1
for i in a:
    res *= i
if res > 10**18:
    print(-1)
else:
    print(res)

Fixed submission:
def main():    
    N = int(input())
    a = list(map(int,input().split()))
    res = 1
    if 0 in a:
        print(0)
        return
    for i in a:
        res *= i
        if res > 10**18:
            print(-1)
            return
    print(res)
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
import math
a,b = map(input().split())
b = int(float(b) *100)
a = int(a)
print(a*b//100)

Fixed submission:
A, B = map(float, input().split())
A = int(A)
B = int(B*1000)
print((A*B)//1000)
Buggy python submission (verdict: Runtime Error):
from collections import deque
inf = 10 ** 7
N, M = map(int, input().split())
P = [list(map(int,input().split())) for i in range(M)]
a = [[] for i in range(N)]
for i in P:
    a[i[0]-1].append(i[1]-1)
    a[i[1]-1].append(i[0]-1)
path = [-1] * N
path[0] = 0
checked = [False] * N
stack = deque([(0,0)])
while (len(stack) != 0):
    kk = stack.pop(0)
    now = kk[0]
    pre = kk[1]
    if  not checked[now]:    
        nextP = a[now]
        checked[now] = True
        path[now] = pre
        for i in nextP:
            stack.append((i,now))
if False in checked:
    print("No")
else:
    print("Yes")
    for i in path[1:]:
        print(i + 1)





Fixed submission:
from collections import deque
inf = 10 ** 7
N, M = map(int, input().split())
P = [list(map(int,input().split())) for i in range(M)]
a = [[] for i in range(N)]
for i in P:
    a[i[0]-1].append(i[1]-1)
    a[i[1]-1].append(i[0]-1)
path = [-1] * N
path[0] = 0
checked = [False] * N
stack = deque([(0,0)])
while (len(stack) != 0):
    kk = stack.popleft()
    now = kk[0]
    pre = kk[1]
    if  not checked[now]:    
        nextP = a[now]
        checked[now] = True
        path[now] = pre
        for i in nextP:
            stack.append((i,now))
if False in checked:
    print("No")
else:
    print("Yes")
    for i in path[1:]:
        print(i + 1)

Buggy python submission (verdict: Time Limit Exceeded):
inf = 10 ** 7
N, M = map(int, input().split())
P = [list(map(int,input().split())) for i in range(M)]
a = [[] for i in range(N)]
for i in P:
    a[i[0]-1].append(i[1]-1)
    a[i[1]-1].append(i[0]-1)
path = [-1] * N
path[0] = 0
checked = [False] * N
stack = [(0,0)]
while (len(stack) != 0):
    kk = stack.pop(0)
    now = kk[0]
    pre = kk[1]
    if  not checked[now]:    
        nextP = a[now]
        checked[now] = True
        path[now] = pre
        for i in nextP:
            stack.append((i,now))
if False in checked:
    print("No")
else:
    print("Yes")
    for i in path[1:]:
        print(i + 1)





Fixed submission:
from collections import deque
inf = 10 ** 7
N, M = map(int, input().split())
P = [list(map(int,input().split())) for i in range(M)]
a = [[] for i in range(N)]
for i in P:
    a[i[0]-1].append(i[1]-1)
    a[i[1]-1].append(i[0]-1)
path = [-1] * N
path[0] = 0
checked = [False] * N
stack = deque([(0,0)])
while (len(stack) != 0):
    kk = stack.popleft()
    now = kk[0]
    pre = kk[1]
    if  not checked[now]:    
        nextP = a[now]
        checked[now] = True
        path[now] = pre
        for i in nextP:
            stack.append((i,now))
if False in checked:
    print("No")
else:
    print("Yes")
    for i in path[1:]:
        print(i + 1)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
P = [i -1 for i in map(int,input().split())]
ss = set([])
point = 0
for i in range(N):
    if point in ss:
        break
    ss.add(point)
    point = P[point]
S = [0]
points = 0
for i in range(len(ss)-1):
    points = P[points]
    S.append(points)
loop = S[S.index(points):]
ll = len(S)
l = len(loop)
if ll >= M:
    print(S[M]+1)
else:
    print(loop[(M-ll)%l]+1)


Fixed submission:
N, M = map(int, input().split())
P = [i -1 for i in map(int,input().split())]
ss = set([])
point = 0
for i in range(N):
    if point in ss:
        break
    ss.add(point)
    point = P[point]
S = [0]
points = 0
for i in range(len(ss)-1):
    points = P[points]
    S.append(points)
loop = S[S.index(point):]
ll = len(S)
l = len(loop)
if ll > M:
    print(S[M]+1)
elif ll == M:
    print(point+1)
else:
    print(loop[(M-ll)%l]+1)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
P = [i -1 for i in map(int,input().split())]
ss = set([])
point = 0
for i in range(N):
    if point in ss:
        break
    ss.add(point)
    point = P[point]
S = [0]
points = 0
for i in range(len(ss)-1):
    points = P[points]
    S.append(points)
loop = S[S.index(point):]
ll = len(S)
l = len(loop)
if ll >= M:
    print(S[M]+1)
else:
    print(loop[(M-ll)%l]+1)


Fixed submission:
N, M = map(int, input().split())
P = [i -1 for i in map(int,input().split())]
ss = set([])
point = 0
for i in range(N):
    if point in ss:
        break
    ss.add(point)
    point = P[point]
S = [0]
points = 0
for i in range(len(ss)-1):
    points = P[points]
    S.append(points)
loop = S[S.index(point):]
ll = len(S)
l = len(loop)
if ll > M:
    print(S[M]+1)
elif ll == M:
    print(point+1)
else:
    print(loop[(M-ll)%l]+1)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
P = [i -1 for i in map(int,input().split())]
ss = []
point = 0
while True:
    if point in ss:
        break
    ss.append(point)
    point = P[point]
loop = ss[ss.index(point):]
ll = len(ss)
l = len(loop)
if ll >= M:
    print(ss[M]+1)
else:
    print(loop[(M-ll)%l]+1)


Fixed submission:
N, M = map(int, input().split())
P = [i -1 for i in map(int,input().split())]
ss = set([])
point = 0
for i in range(N):
    if point in ss:
        break
    ss.add(point)
    point = P[point]
S = [0]
points = 0
for i in range(len(ss)-1):
    points = P[points]
    S.append(points)
loop = S[S.index(point):]
ll = len(S)
l = len(loop)
if ll > M:
    print(S[M]+1)
elif ll == M:
    print(point+1)
else:
    print(loop[(M-ll)%l]+1)
Buggy python submission (verdict: Time Limit Exceeded):
X = int(input())
diff = 1
for i in range(2,X):
    if X % i == 0:
        diff = i
        break

s = (10 **9)//2
while True:
    ss = s//2
    A = ss 
    B = ss - diff
    xx = A ** 5 - B ** 5
    if xx == X:
        break
    elif xx > X:
        s = ss //2
    else:
        s =  (3*ss) //4
print(int(A),int(B))

Fixed submission:
def main():
    X = int(input())
    for B in range(-120,121):
        for A in range(B,121):
            xx = A**5 -B ** 5
            if X ==  xx:
                print(A,B)
                return
            elif X <xx:
                break

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
X = int(input())
diff = 1
for i in range(2,X):
    if X % i == 0:
        diff = i
        break

s = (10 **9)//2
while True:
    ss = s/2
    A = ss 
    B = ss - diff
    xx = A ** 5 - B ** 5
    if xx == X:
        break
    elif xx > X:
        s = ss //2
    else:
        s =  (3*ss) //4
print(int(A),int(B))

Fixed submission:
def main():
    X = int(input())
    for B in range(-120,121):
        for A in range(B,121):
            xx = A**5 -B ** 5
            if X ==  xx:
                print(A,B)
                return
            elif X <xx:
                break

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
X = int(input())
diff = 1
for i in range(2,X):
    if X % i == 0:
        diff = i
        break

s = (10 **9)//2
while True:
    A = s 
    B = s - diff
    xx = A ** 5 - B ** 5
    if xx == X:
        break
    elif xx > X:
        s = s //2
    else:
        s =  (3*s) //4
print(int(A),int(B))

Fixed submission:
def main():
    X = int(input())
    for B in range(-120,121):
        for A in range(B,121):
            xx = A**5 -B ** 5
            if X ==  xx:
                print(A,B)
                return
            elif X <xx:
                break

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
X = int(input())
diff = 1
for i in range(2,X):
    if X % i == 0:
        diff = i
        break

s = (10 **9 /diff)//2
while True:
    A = s 
    B = s - diff
    xx = A **5 - B ** 5
    if xx == X:
        break
    elif xx > X:
        s = s //2
    else:
        s = s + s //2
print(int(A),int(B))

Fixed submission:
def main():
    X = int(input())
    for B in range(-120,121):
        for A in range(B,121):
            xx = A**5 -B ** 5
            if X ==  xx:
                print(A,B)
                return
            elif X <xx:
                break

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
A,B,N = map(int,input().split())
result = 0
for i in range(N//B+1):
    x = min(N,(i+1) * B -1)
    a = (A*x)//B
    b = A*(x//B)
    result = max(result,a-b)
print(result)

Fixed submission:
A,B,N = map(int,input().split())
result = 0
x = min(N,B -1)
a = (A*x)//B
b = A*(x//B)
result = max(result,a-b)
print(result)