Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split(' ')))

total = 0
for i in range(n-1):
    for j in range(i+1, n):
        total = (((a[i] * a[j]) % 1000000007) + total) % 1000000007

print(total)


Fixed submission:
mod = 1000000007

n = int(input())
a = list(map(int, input().split(' ')))
b = [0] * (n + 1)

for i, v in enumerate(a):
    b[i+1] = (b[i] + v) % mod

ans = 0
for i in range(n):
    ans = (((a[i] * (b[n] - b[i+1])) % mod) + ans) % mod

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split(' ')))

total = 0
for i in range(n-1):
    for j in range(i+1, n):
        total += (a[i] * a[j]) % 1000000007

print(total % 1000000007)


Fixed submission:
mod = 1000000007

n = int(input())
a = list(map(int, input().split(' ')))
b = [0] * (n + 1)

for i, v in enumerate(a):
    b[i+1] = (b[i] + v) % mod

ans = 0
for i in range(n):
    ans = (((a[i] * (b[n] - b[i+1])) % mod) + ans) % mod

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split(' ')))

total = 0
for i in range(n-1):
    for j in range(i+1, n):
        total += (a[i] * a[j]) % 1000000007

print(total % 1000000007)


Fixed submission:
mod = 1000000007

n = int(input())
a = list(map(int, input().split(' ')))
b = [0] * (n + 1)

for i, v in enumerate(a):
    b[i+1] = (b[i] + v) % mod

ans = 0
for i in range(n):
    ans = (((a[i] * (b[n] - b[i+1])) % mod) + ans) % mod

print(ans)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
S = input()
ans = 0
for i in range(S):
  if S[i] == "R":
    ans += 1
  else:
    if i == 1:
      ans = 0
print(ans)

Fixed submission:
# -*- coding: utf-8 -*-
S = input()
ans = 0
for i in range(len(S)):
  if S[i] == "R":
    if ans == 0:
      ans += 1
    else:
      if i > 0 and S[i] == S[i-1] == "R":
        ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
N, K = map(int, input().split())
A = list(map(int, input().split()))

score = [1] * (N-K+1)
for i in range(K, N+1):
  if i == K:
    for j in range(K):
      score[0] *= A[j]
    continue
    
  score[i-K] = (score[i-K-1] // A[i-K-1]) * A[i-1]
  if score[i-K] > score[i-K-1]:
    print('Yes')
  else:
    print('No')

Fixed submission:
# -*- coding: utf-8 -*-
N, K = map(int, input().split())
A = list(map(int, input().split()))

for i in range(K, N):
  if A[i] > A[i-K]:
    print('Yes')
  else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B = list()
C = list()
for i in range(Q):
  b, c = map(int, input().split())
  B.append(b)
  C.append(c)
sorted(A)
A_sum = sum(A)

break_flg = False
for i in range(Q):
  count = 0
  break_flg = False
  bi = B[i]
  ci = C[i]
  for j in range(len(A)):
    ai = A[j]
    if bi == ai:
      A[j] = C[i]
      break_flg = True
      count += 1
    
    if (bi != ai or j == len(A)-1) and break_flg == True:
      A_sum += (count * (ci - bi))
      print(A_sum)
      break
    elif break_flg == False and j == len(A)-1:
      print(A_sum)

Fixed submission:
# -*- coding: utf-8 -*-
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B = list()
C = list()
for i in range(Q):
  b, c = map(int, input().split())
  B.append(b)
  C.append(c)

A_sum = sum(A)
num_count = [0] * (10 ** 5)

for a in A:
  num_count[a-1] += 1
for i in range(Q):
  if num_count[B[i]-1] != 0:
    A_sum += (C[i] - B[i]) * num_count[B[i]-1]
    print(A_sum)
    num_count[C[i]-1] += num_count[B[i]-1]
    num_count[B[i]-1] = 0
  else:
    print(A_sum)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
N = int(input())
a = list(map(int, input().split()))

# aを2進数化
# 2 ** 29 < 10 ** 9 < 2 ** 30
k = 30 # 2進数変換後の最大桁数
s = a[0]
x_str = ""
for i in range(N-1):
  s = s ^ a[i+1]
for i in range(N-1):
  x = s ^ a[i]
  x_str += str(x) + " "
x_str += str(s ^ a[N-1])
print(x_str)

Fixed submission:
# -*- coding: utf-8 -*-
N = int(input())
A = list(map(int, input().split()))
s = 0
for a in A:
  s ^= a
ans = list()
for a in A:
  ans.append(s ^ a)
print(" ".join(map(str, ans)))

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
N = int(input())
a = list(map(int, input().split()))

# aを2進数化
# 2 ** 29 < 10 ** 9 < 2 ** 30
k = 30 # 2進数変換後の最大桁数
a_binary = [[0] * k for _ in range(N)]
for i in range(N):
  quotient = a[i]
  remainder = 0
  for j in range(k):
    remainder = quotient % 2
    quotient = quotient // 2
    a_binary[i][j] = remainder
s = [0] * k # a1 xor a2 xor ~ xor aN
for i in range(k):
  count_1 = 0
  for j in range(N):
    if a_binary[j][i] == 1:
      count_1 += 1
  if count_1 % 2 == 1:
    # 1が奇数個の場合
    s[i] = 1
  else:
    s[i] = 0
x_binary = [[0] * k for _ in range(N)]
for i in range(N):
  for j in range(k):
    if a_binary[i][j] + s[j] == 1:
      x_binary[i][j] = 1
    else:
      x_binary[i][j] = 0
x_str = ""
for i in range(N):
  xi = 0
  for j in range(k):
    t = 2 ** j
    xi += x_binary[i][j] * t
  x_str += str(xi)
  if i != N-1:
    x_str += " "

print(x_str)

Fixed submission:
# -*- coding: utf-8 -*-
N = int(input())
A = list(map(int, input().split()))
s = 0
for a in A:
  s ^= a
ans = list()
for a in A:
  ans.append(s ^ a)
print(" ".join(map(str, ans)))
Buggy python submission (verdict: Time Limit Exceeded):
# -*- codinf: utf-8 -*-
N = int(input())
A = list(map(int, input().split()))
ans = 1
for a in A:
  ans *= a
if ans > 10**18:
  print(-1)
else:
  print(ans)

Fixed submission:
# -*- codinf: utf-8 -*-
N = int(input())
A = list(map(int, input().split()))
ans = 1

for a in A:
  if a == 0:
    print(0)
    exit()

for a in A:
  ans *= a
  if ans > 10**18:
    print(-1)
    exit()
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
import math
S = input()
remainder = [0 for _ in range(2019)]
for i in range(len(S)):
  s = int(S[-1*i:])
  remainder[s % 2019] += 1
ans = 0
for i in range(2019):
  if i == 0:
      ans += remainder[i]
  else:
    if remainder[i] > 1:
      # 組み合わせ
      ans += (math.factorial(remainder[i]) // (math.factorial(remainder[i] - 2) * math.factorial(2)))
print(ans)

Fixed submission:
# -*- coding: utf-8 -*-
import math
S = input()[::-1]
remainder = [0] * 2019

# 2つ選ぶ組み合わせにおいて余り0の場合は1つしか選ばなくて良いので
# 2つ目に0を選んだ場合として便宜的に設定
remainder[0] = 1

num = 0
d = 1
for s in S:
  num += int(s) * d
  remainder[num % 2019] += 1
  d *= 10
  
  # numが大きくなりすぎると計算量が膨大になってしまうのを防ぐ
  # num%2019を計算するので、先に%2019で計算しても結果は変わらない
  d %= 2019
ans = 0
for i in range(2019):
  ans += remainder[i] * (remainder[i]-1) // 2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
import math
S = input()
remainder = [0 for _ in range(2019)]
for i in range(len(S)):
  s = int(S[len(S)-1-i:])
  remainder[s % 2019] += 1
ans = 0
for i in range(2019):
  if i == 0:
      ans += remainder[i]
  else:
    if remainder[i] > 1:
      # 組み合わせ
      ans += (math.factorial(remainder[i]) // (math.factorial(remainder[i] - 2) * math.factorial(2)))
print(ans)

Fixed submission:
# -*- coding: utf-8 -*-
import math
S = input()[::-1]
remainder = [0] * 2019

# 2つ選ぶ組み合わせにおいて余り0の場合は1つしか選ばなくて良いので
# 2つ目に0を選んだ場合として便宜的に設定
remainder[0] = 1

num = 0
d = 1
for s in S:
  num += int(s) * d
  remainder[num % 2019] += 1
  d *= 10
  
  # numが大きくなりすぎると計算量が膨大になってしまうのを防ぐ
  # num%2019を計算するので、先に%2019で計算しても結果は変わらない
  d %= 2019
ans = 0
for i in range(2019):
  ans += remainder[i] * (remainder[i]-1) // 2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
import itertools
S = input()
remainder = ["" for _ in range(2019)]
for i in range(len(S)):
  s = int(S[len(S)-1-i:])
  remainder[s % 2019] += "1"
ans = 0
for i in range(2019):
  if i == 0:
    ans += len(remainder[i])
  else:
    # 累積和
    ans += len(list(itertools.combinations(remainder[i], 2)))
print(ans)

Fixed submission:
# -*- coding: utf-8 -*-
import math
S = input()[::-1]
remainder = [0] * 2019

# 2つ選ぶ組み合わせにおいて余り0の場合は1つしか選ばなくて良いので
# 2つ目に0を選んだ場合として便宜的に設定
remainder[0] = 1

num = 0
d = 1
for s in S:
  num += int(s) * d
  remainder[num % 2019] += 1
  d *= 10
  
  # numが大きくなりすぎると計算量が膨大になってしまうのを防ぐ
  # num%2019を計算するので、先に%2019で計算しても結果は変わらない
  d %= 2019
ans = 0
for i in range(2019):
  ans += remainder[i] * (remainder[i]-1) // 2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- conding: utf-8 -*-
import itertools
import math
K = int(input())

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

ans = 0
for x in list(itertools.product(range(1, K+1), repeat=3)):
  # xに対して最大公約数を求める
  ans += gcd(gcd(x[0], x[1]), x[2])
print(ans)

Fixed submission:
# -*- conding: utf-8 -*-
import math
K = int(input())

ans = 0
for a in range(1, K+1):
  for b in range(1, K+1):
    x = math.gcd(a, b)  
    for c in range(1, K+1):
      ans += math.gcd(x, c)
print(ans)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

N, K = map(int, input().split())
x = abs(N-K)

remainder = K % x if K >= x else x % K
  
if remainder > x // 2:
  print(abs(remainder - x))
else:
  print(remainder)

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

N, K = map(int, input().split())

remainder = N % K

if remainder > K / 2:
  print(abs(remainder - K))
else:
  print(remainder)
Buggy python submission (verdict: Time Limit Exceeded):
# -*= coding: utf-8 -*-
import queue

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

q = queue.Queue()

ans = [0] * N

# BFS
for i in range(N):
  # 0 〜 N-1の各頂点からスタート
  
  cost = [-1] * N
  cost[i] = 0
  q.put(i) # 基準とする頂点をノードiにする
  
  while not q.empty():
    
    # 現在のノードのインデックス
    current = q.get()
    
    if current - 1 >= 0 and cost[current - 1] == -1:
      # 1つ前のノードを登録
      
      q.put(current - 1)
      cost[current - 1] = cost[current] + 1
      
    if current + 1 < N and cost[current + 1] == -1:
      # 1つ後ろのノードを登録
      
      q.put(current + 1)
      cost[current + 1] = cost[current] + 1
      
    if current == X - 1 and cost[Y - 1] == -1:
      # XからYへのルートを登録
      
      q.put(Y - 1)
      cost[Y - 1] = cost[current] + 1
    
    if current == Y - 1 and cost[X - 1] == -1:
      # YからXへのルートを登録
      
      q.put(X - 1)
      cost[X - 1] = cost[current] + 1
      
  # この時点でcostにはノードiから各ノードへの最小コストが格納されている
  
  #print(cost)
  for j in range(N):
    ans[cost[j]] += 1

for i in range(1, N):
  print(ans[i]//2) # ノードA→Bと、逆向きのB→Aが、両方カウントされているので2分の1する

Fixed submission:
# -*= coding: utf-8 -*-
from collections import deque

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

d = deque() # 初期化

ans = [0] * N

# BFS
for i in range(N):
  # 0 〜 N-1の各頂点からスタート
  
  cost = [-1] * N
  cost[i] = 0
  d.append(i) # 基準とする頂点をノードiにする
  
  while len(d) > 0:
    # dequeueが空でない間ループ
    
    # 現在のノードのインデックス
    current = d.popleft()
    
    if current - 1 >= 0 and cost[current - 1] == -1:
      # 1つ前のノードを登録
      
      d.append(current - 1)
      cost[current - 1] = cost[current] + 1
      
    if current + 1 < N and cost[current + 1] == -1:
      # 1つ後ろのノードを登録
      
      d.append(current + 1)
      cost[current + 1] = cost[current] + 1
      
    if current == X - 1 and cost[Y - 1] == -1:
      # XからYへのルートを登録
      
      d.append(Y - 1)
      cost[Y - 1] = cost[current] + 1
    
    if current == Y - 1 and cost[X - 1] == -1:
      # YからXへのルートを登録
      
      d.append(X - 1)
      cost[X - 1] = cost[current] + 1
      
  # この時点でcostにはノードiから各ノードへの最小コストが格納されている
  
  #print(cost)
  for j in range(N):
    ans[cost[j]] += 1

for i in range(1, N):
  print(ans[i]//2) # ノードA→Bと、逆向きのB→Aが、両方カウントされているので2分の1する
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
N = int(input())
S = list()
word = {}
for i in range(N):
  s = input()
  S.append(s)
  if s in word:
    word[s] += 1
  else:
    word[s] = 1

max_k_list = [kv[0] for kv in word.items() if kv[1] == max(word.values())]
ans_list = sorted(max_k_list)
for ans in ans_list:
  print(ans)

Fixed submission:
# -*- coding: utf-8 -*-
N = int(input())
S = list()
words = {}
for i in range(N):
  s = input()
  S.append(s)
  if s in words:
    words[s] += 1
  else:
    words[s] = 1

max_value = max(words.values())
max_list = list()
for k,v in words.items():
  if v == max_value:
    max_list.append(k)
ans_list = sorted(max_list)
for ans in ans_list:
  print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N,X,M = map(int,input().split())
    A = X
    ans = A
    LIST = [A]
    C = 0
    flag = False
    for n in range(N-1):
        A = (A**2)%M
        if A in LIST:
            ind = LIST.index(A)
            C = sum(LIST[:ind])
            LIST = LIST[ind:]
            flag = True
            break
        else:
            LIST.append(A)
        ans += A
    else:
        print(ans)
        
    if flag:
        ANS = [0]
        S = 0
        for L in LIST:
            S += L
            ANS.append(S)
            
        a = (N - ind) // len(LIST)
        b = (N - ind) % len(LIST)
        ans = sum(LIST)*a + ANS[b] + C
        
        print(ans)
    
if __name__ == '__main__':
    main()

Fixed submission:
def main():
    N,X,M = map(int,input().split())
    A = X
    ans = A
    LIST = [A]
    C = 0
    flag = False
    for n in range(N-1):
        A = (A**2)%M
        if A in LIST:
            ind = LIST.index(A)
            C = sum(LIST[:ind])
            LIST = LIST[ind:]
            flag = True
            break
        else:
            LIST.append(A)
        ans += A
    else:
        print(ans)
        
    if flag:
        ANS = [0]
        S = 0
        for L in LIST:
            S += L
            ANS.append(S)
            
        a = (N - ind) // len(LIST)
        b = (N - ind) % len(LIST)
        ans = sum(LIST)*a + ANS[b] + C
        
        print(ans)
    
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    A = list(map(int,input().split()))
    
    SUM = []
    for i in range(N):
        SUM.append(sum(A[i:])%(10**9+7))
    
    ans = 0
    for i in range(N-1):
        ans += A[i]*SUM[i+1]
        ans = ans%(10**9+7)
    
    print(ans)
    
if __name__ == '__main__':
    main()

Fixed submission:
def main():
    N = int(input())
    A = list(map(int,input().split()))
    
    SUM = [sum(A)]
    for i in range(1,N):
        SUM.append((SUM[i-1]-A[i-1])%(10**9+7))
    
    ans = 0
    for i in range(N-1):
        ans += A[i]*SUM[i+1]
        ans = ans%(10**9+7)
    
    print(ans)
    
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    K = int(input())
    Kstr = str(K)
    
    if Kstr[-1] in ('0','2','4','6','8','5'):
        print(-1)
    else:
        if K%7 == 0:
            L = (9*K)/7
        else:
            L = 9*K
        S = 10
        for i in range(1,L):
            S = S%L
            if S == 1:
                print(i)
                break
            S = S*10
    
if __name__ == '__main__':
    main()

Fixed submission:
def main():
    K = int(input())
    Kstr = str(K)
    
    if Kstr[-1] in ('0','2','4','6','8','5'):
        print(-1)
    else:
        if K%7 == 0:
            L = (9*K)/7
        else:
            L = 9*K
        S = 10
        for i in range(1,6000000):
            S = S%L
            if S == 1:
                print(i)
                break
            S = S*10
    
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    N,M,K = map(int,input().split())
    A = list(map(int,input().split()))
    B = list(map(int,input().split()))
    
    a,b = [0],[0]
    for i in range(N):
        a.append(a[i] + A[i])
    for i in range(N):
        b.append(b[i] + B[i])
        
    ans,j = 0,M
    for i in range(N+1):
        if a[i] > K:
            break
        while b[j] > K - a[i]:
            j -= 1
        ans = max(ans, i+j)
        
    print(ans)
    
if __name__ == '__main__':
    main()

Fixed submission:
def main():
    N,M,K = map(int,input().split())
    A = list(map(int,input().split()))
    B = list(map(int,input().split()))
    
    a,b = [0],[0]
    for i in range(N):
        a.append(a[i] + A[i])
    for i in range(M):
        b.append(b[i] + B[i])
        
    ans,j = 0,M
    for i in range(N+1):
        if a[i] > K:
            break
        while b[j] > K - a[i]:
            j -= 1
        ans = max(ans, i+j)
        
    print(ans)
    
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    A = list(map(int,input().split()))
    C = 1
    for i in range(N):
        C *= A[i]
    if C > 10**18:
        C = '-1'
    print(C)
    
if __name__ == '__main__':
    main()

Fixed submission:
def main():
    N = int(input())
    A = list(map(int,input().split()))
    C = 1
    if 0 in A:
        print(0)
    else:
        for i in range(N):
            C *= A[i]
            if C > 10**18:
                C = '-1'
                break
            
        print(C)
    
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    A,B = map(str,input().split())
    A = int(A)
    B = B.replace(',','')
    B = int(B)
    C = A*B
    print(C//100)
    
if __name__ == '__main__':
    main()

Fixed submission:
def main():
    A,B = map(str,input().split())
    A = int(A)
    B = B.replace('.','')
    B = int(B)
    C = A*B
    print(C//100)
    
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
def main():
    A,B = map(str,input().split())
    A = int(A)
    B.replace(',','')
    B = int(B)
    C = A*B
    print(C//100)
    
if __name__ == '__main__':
    main()

Fixed submission:
def main():
    A,B = map(str,input().split())
    A = int(A)
    B = B.replace('.','')
    B = int(B)
    C = A*B
    print(C//100)
    
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
A = [[0 for j in range(100)]for i in range(100)]
B = [0 for j in range(N)]
S = 0
for i in range(K):
    d = int(input())
    A[i] = list(map(int,input().split()))
for i in range(100):
    for j in range(100):
        for k in range(N):
            if A[i][j] == k+1:
                B[k] = 1
for i in range(N):
    if B[i] != 1:
        S += 1
print (S)

Fixed submission:
N,K = map(int,input().split())
A = [[0 for j in range(K)]for i in range(K)]
B = [0 for j in range(N)]
S = 0
for i in range(K):
    d = int(input())
    A[i] = list(map(int,input().split()))
for i in range(K):
    for j in range(len(A[i])):
        for k in range(N):
            if A[i][j] == k+1:
                B[k] = 1
for i in range(N):
    if B[i] != 1:
        S += 1
print (S)

Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
A = [[0 for j in range(N)]for i in range(N)]
B = [0 for j in range(N)]
S = 0
for i in range(K):
    d = int(input())
    A[i] = list(map(int,input().split()))
for i in range(len(A)):
    for j in range(len(A[i])):
        for k in range(N):
            if A[i][j] == k+1:
                B[k] = 1
for i in range(N):
    if B[i] != 1:
        S += 1
print (S)

Fixed submission:
N,K = map(int,input().split())
A = [[0 for j in range(K)]for i in range(K)]
B = [0 for j in range(N)]
S = 0
for i in range(K):
    d = int(input())
    A[i] = list(map(int,input().split()))
for i in range(K):
    for j in range(len(A[i])):
        for k in range(N):
            if A[i][j] == k+1:
                B[k] = 1
for i in range(N):
    if B[i] != 1:
        S += 1
print (S)
Buggy python submission (verdict: Time Limit Exceeded):
def DI(n):
    D = []
    for i in range(1,int(n**0.5)+1):
        if n % i == 0:
            D.append(i)
            if i != n//i:
                D.append(n//i)
    return D
X = int(input())
D = DI(X)
flag = False
for i in range(len(D)):
    for a in range((D[i]+1)//2):
        b = -(D[i] - a)
        if a**5 - b**5 == X:
            print(str(a) + ' ' + str(b))
            flag = True
            break
    if flag:
        break

Fixed submission:
X = int(input())
flag = False
for i in range(-120,120):
    for j in range(-120,120):
        if i**5 - j**5 == X:
            print(str(i) + ' ' + str(j))
            flag = True
            break
    if flag:
        break

Buggy python submission (verdict: Time Limit Exceeded):
def DI(n):
    D = []
    for i in range(1,int(n**0.5)+1):
        if n % i == 0:
            D.append(i)
            if i != n//i:
                D.append(n//i)
    return D
X = int(input())
D = DI(X)
flag = False
for i in range(len(D)):
    for a in range(D[i]+1):
        b = -(D[i] - a)
        if a**5 - b**5 == X:
            print(str(a) + ' ' + str(b))
            flag = True
            break
    if flag:
        break

Fixed submission:
X = int(input())
flag = False
for i in range(-120,120):
    for j in range(-120,120):
        if i**5 - j**5 == X:
            print(str(i) + ' ' + str(j))
            flag = True
            break
    if flag:
        break

Buggy python submission (verdict: Runtime Error):
def DI(n):
    D = []
    for i in range(1,int(n**0.5)+1):
        if n % i == 0:
            D.append(i)
            if i != n//i:
                D.append(n//i)
    d = sorted(D)[-2]
    return d

X = int(input())
d = DI(X)
a = 0
b = 0
for i in range(d+1):
    for a in range(i+1):
        b = i - a
        if a**5 + b**5 == X:
            print(str(a) + ' ' + str(b))
            break

Fixed submission:
X = int(input())
flag = False
for i in range(-120,120):
    for j in range(-120,120):
        if i**5 - j**5 == X:
            print(str(i) + ' ' + str(j))
            flag = True
            break
    if flag:
        break
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = []
B = [0 for i in range(N)]
A = list(map(int,input().split()))
for i in range(N):
    for j in range(N-1):
        if i+1 == A[j]:
            B[i] += 1
    print(B[i])

Fixed submission:
N = int(input())
A = []
B = [0 for i in range(N)]
j = 0
A = list(map(int,input().split()))
list.sort(A)
T = A[0]
for i in range(N-1):
    if A[i] != T and i != N-2:
        B[T-1] = i - j
        T = A[i]
        j = i
    elif i == N-2:
        if A[i] == T:
            B[T-1] = i - j + 1
        else:
            B[T-1] = i - j
            B[A[i]-1] = 1
for i in range(N):
    print(B[i])
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)
K = int(input())
S = 0
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            S += gcd(a, b, c)
print(S)

Fixed submission:
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)
K = int(input())
S = 0
for a in range(1,K+1):
    for b in range(1,a+1):
        for c in range(1,b+1):
            if a == b == c:
                S += a
            if a == b != c or a != b == c:
                S += 3*math.gcd(a,c)
            if a != b != c:
                S += 6*gcd(a, b, c)
print(S)
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
A = []
A = list(map(int,input().split()))
list.sort(A, reverse = True)
if A[M] >= sum(A)/(4*M):
    print('Yes')
else:
    print('No')

Fixed submission:
N,M = map(int,input().split())
A = []
A = list(map(int,input().split()))
list.sort(A, reverse = True)
if A[M-1] >= (sum(A))/(4*M):
    print('Yes')
else:
    print('No')