Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
reverse = 0
for i in range(Q):
  Query = list(input().split())
  if Query[0] == "1":
    reverse = (reverse + 1) % 2
  if Query[0] == "2":
    f = int(Query[1])
    c = Query[2]
    if (f + reverse) % 2 == 1:
      S = c + S
    else:
      S = S + c
 
if reverse == 0:
  print(S)
else:
  print(S[::-1])

Fixed submission:
from collections import deque
S = deque(input())
Q = int(input())
reverse = 0
for i in range(Q):
  Query = list(input().split())
  if Query[0] == "1":
    reverse = (reverse + 1) % 2
  if Query[0] == "2":
    f = int(Query[1])
    c = Query[2]
    if (f + reverse) % 2 == 1:
      S.appendleft(c)
    else:
      S.append(c)

S = "".join(list(S))
 
if reverse == 0:
  print(S)
else:
  print(S[::-1])

Buggy python submission (verdict: Runtime Error):
S = input()
Q = int(input())
reverse = 0
for i in range(Q):
  Query = list(input().split())
  if Query[0] == "1":
    reverse = (reverse + 1) % 2
  if Query[0] == "2":
    f = int(Query[1])
    c = query[2]
    if (f + reverse) % 2 == 1:
      S = c + S
    else:
      S = S + c

if reverse == 0:
  print(S)
else:
  print(S[::-1])

Fixed submission:
from collections import deque
S = deque(input())
Q = int(input())
reverse = 0
for i in range(Q):
  Query = list(input().split())
  if Query[0] == "1":
    reverse = (reverse + 1) % 2
  if Query[0] == "2":
    f = int(Query[1])
    c = Query[2]
    if (f + reverse) % 2 == 1:
      S.appendleft(c)
    else:
      S.append(c)

S = "".join(list(S))
 
if reverse == 0:
  print(S)
else:
  print(S[::-1])
Buggy python submission (verdict: Runtime Error):
a,b,c = map(int,input().split)
P = set([a,b,c])
if len(P) == 2:
  print('Yes')
else:
  print('No')

Fixed submission:
a,b,c = map(int,input().split())
P = set([a,b,c])
if len(P) == 2:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
prev = 0
for i in range(len(N)):
  if 0 <= int(N[i]) + prev < 5:
    count += int(N[i]) + prev
    prev = 0
  elif 6 <= int(N[i]) + prev <= 9:
    count += 10 - (int(N[i]) + prev)
    prev = 1
  elif int(N[i]) + prev == 10:
    prev = 1
  else:
    if i < (len(N) - 1) and int(N[i+1]) < 5:
      count += 5
      prev = 0
    else:
      count += 5
      prev = 1
count = count + prev

Fixed submission:
N = input()
count = 0
prev = 0
for i in range(len(N)):
  if 0 <= int(N[i]) + prev < 5:
    count += int(N[i]) + prev
    prev = 0
  elif 6 <= int(N[i]) + prev <= 9:
    count += 10 - (int(N[i]) + prev)
    prev = 1
  elif int(N[i]) + prev == 10:
    prev = 1
  else:
    if (i < (len(N) - 1) and int(N[i+1]) < 5) or i == len(N) - 1:
      count += 5
      prev = 0
    else:
      count += 5
      prev = 1
count = count + prev
print(count)

Buggy python submission (verdict: Runtime Error):
N = input()
count = 0
prev = 0
for i in range(len(N)):
  if 0 <= int(N[i]) + prev < 5:
    count += int(N[i]) + prev
    prev = 0
  elif 6 <= int(N[i]) + prev <= 9:
    count += 10 - (int(N[i]) + prev)
    prev = 1
  elif int(N[i]) + prev == 10:
    prev = 1
  else:
    if i < len(N) and int(N[i+1]) < 5:
      count += 5
    else:
      count += 5
      prev = 1
count = count + prev
print(count)

Fixed submission:
N = input()
count = 0
prev = 0
for i in range(len(N)):
  if 0 <= int(N[i]) + prev < 5:
    count += int(N[i]) + prev
    prev = 0
  elif 6 <= int(N[i]) + prev <= 9:
    count += 10 - (int(N[i]) + prev)
    prev = 1
  elif int(N[i]) + prev == 10:
    prev = 1
  else:
    if (i < (len(N) - 1) and int(N[i+1]) < 5) or i == len(N) - 1:
      count += 5
      prev = 0
    else:
      count += 5
      prev = 1
count = count + prev
print(count)

Buggy python submission (verdict: Runtime Error):
N = input()
count = 0
prev = 0
for i in range(len(N)):
  if 0 <= int(N[i]) + prev < 6:
    count += int(N[i]) - prev
    prev = 0
  elif: 6 <= int(N[i]) + prev <= 9:
    count += 11 - (int(N[i]) - prev)
    prev = 1
  else:
    prev = 1
print(count)

Fixed submission:
N = input()
count = 0
prev = 0
for i in range(len(N)):
  if 0 <= int(N[i]) + prev < 5:
    count += int(N[i]) + prev
    prev = 0
  elif 6 <= int(N[i]) + prev <= 9:
    count += 10 - (int(N[i]) + prev)
    prev = 1
  elif int(N[i]) + prev == 10:
    prev = 1
  else:
    if (i < (len(N) - 1) and int(N[i+1]) < 5) or i == len(N) - 1:
      count += 5
      prev = 0
    else:
      count += 5
      prev = 1
count = count + prev
print(count)
Buggy python submission (verdict: Runtime Error):
r D x = map(int, input.split())
for i in range(10):
  x = r * x - D
  print(x)

Fixed submission:
r, D, x = map(int, input().split())
for i in range(10):
  x = r * x - D
  print(x)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = list(map(int, input().split()))
B = []
for i in range(M):
  b = list(map(int, input().split()))
  B.append(b)
  
B.sort(reverse = True, key = lambda x : x[1])
A.sort()
count = 0

for x in B:
  i = x[0] - 1
  c = x[1]
  if A[count + i] > c:
    for j in range(i):
      if A[count + j] < c:
        A[count + j] = c
    break
  else:
    A[count:count + i + 1] = [c] * (i + 1)
    count += i + 1

print(sum(A))

Fixed submission:
N, M = map(int, input().split())
A = list(map(int, input().split()))
B = []
for i in range(M):
  b = list(map(int, input().split()))
  B.append(b)
  
B.sort(reverse = True, key = lambda x : x[1])
A.sort()
count = 0

for x in B:
  i = x[0] - 1
  c = x[1]
  if count + i >= N:
    if A[-1] > c:
      for j in range(count,N):
        if A[j] < c:
          A[j] = c
      break
    else:
      A[count:] = [c] * (N - count)
      break
    
  elif A[count + i] > c:
    for j in range(i):
      if A[count + j] < c:
        A[count + j] = c
    break
  else:
    A[count:count + i + 1] = [c] * (i + 1)
    count += i + 1

print(sum(A))
Buggy python submission (verdict: Time Limit Exceeded):
N, K =map(int, input().split())
bordor = []
while(K >= 1):
  bordor.insert(0, K)
  K / 2
  
print(bordor)

Fixed submission:
import math
N, K =map(int, input().split())
k = K
bordor = []
Ans = 0
while(K >= 1):
  bordor.append(K)
  K = K / 2
  
for i in range(len(bordor) - 1):
  if bordor[i] <= N:
    Ans += (math.ceil(bordor[i]) - math.ceil(bordor[i + 1])) * (1 / (2 ** (i + 1)))
    
 
  elif bordor[i] > N >= bordor[i + 1]:
    Ans += (N + 1 - math.ceil(bordor[i + 1])) * (1 / (2 ** (i + 1)))
    
if bordor[-1] != 1:
  Ans += 1 / (2 ** len(bordor))

if N >= k:
  Ans += (N - k + 1)
Ans = Ans / N  

print(Ans)
Buggy python submission (verdict: Runtime Error):
s = [int(x) for x in list(input())]
a = [x%2 for x in range(len(s))]
b = [(1 - x%2) for x in range(len(s))]
c1=0
c2=0
for i in range(len(s)):
    if a[i] != s[i]:
        c1 += 1
    if b[i] != s[i]:
        c2 += 1

p

Fixed submission:
s = [int(x) for x in list(input())]
a = [x%2 for x in range(len(s))]
b = [(1 - x%2) for x in range(len(s))]
c1=0
c2=0
for i in range(len(s)):
    if a[i] != s[i]:
        c1 += 1
    if b[i] != s[i]:
        c2 += 1

print(min([c1,c2]))
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
N = int(input())
num_list = list(map(int, input().split(' ')))

ans = 0
for i in range(N-1):
    for j in range(i+1, N):
        ans += num_list[i] * num_list[j] % (10**9 + 7)
        if ans >= (10**9 + 7):
            ans -= (10**9 + 7)

print(ans)

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

list_sum = sum(num_list)

ans = 0
for i in range(N-1):
    list_sum -= num_list[i]
    ans += num_list[i] * list_sum

print(ans % (10**9 + 7))

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

ans = 0
for i in range(N-1):
    for j in range(i+1, N):
        ans += num_list[i] * num_list[j]

print(ans % (10**9 + 7))

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

list_sum = sum(num_list)

ans = 0
for i in range(N-1):
    list_sum -= num_list[i]
    ans += num_list[i] * list_sum

print(ans % (10**9 + 7))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
mod = 1000000007
res = 0
a_sum = sum(a)

for i in range(n - 1):
    main = a.pop(0)
    a_sum = a_sum - main
    res =  (res + main * a_sum % mod) % mod
print(res)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
mod = 1000000007
res = 0
a_sum = sum(a)

for i in range(n - 1):
    main = a[i]
    a_sum = a_sum - main
    res =  (res + main * a_sum % mod) % mod
print(res)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = set(list(map(int, input().split())))
mod = 1000000007
res = 0


for i in range(n - 1):
    main = a.pop(0)
    res =  (res + main * sum(a) % mod) % mod
print(res)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
mod = 1000000007
res = 0
a_sum = sum(a)

for i in range(n - 1):
    main = a[i]
    a_sum = a_sum - main
    res =  (res + main * a_sum % mod) % mod
print(res)

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

for i in range(n - 1):
    main = a.pop(0)
    res =  (res + main * sum(a) % mod) % mod
print(res)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
mod = 1000000007
res = 0
a_sum = sum(a)

for i in range(n - 1):
    main = a[i]
    a_sum = a_sum - main
    res =  (res + main * a_sum % mod) % mod
print(res)

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

for i in range(n - 1):
    for j in range(n - (i + 1)):
        res =  (res + a[i] * a[i + (j + 1)] % mod) % mod

print(res)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
mod = 1000000007
res = 0
a_sum = sum(a)

for i in range(n - 1):
    main = a[i]
    a_sum = a_sum - main
    res =  (res + main * a_sum % mod) % mod
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s = input()
count = 0

while 'WR' in s:
    w_i = s.find('W')
    r_i = s.rfind('R')
    s = s[:w_i] + 'R' + s[w_i + 1:r_i] + 'W' + s[r_i + 1:]
    count += 1

print(count)


Fixed submission:
N = int(input())
s = input()
r_count = s.count('R')
new_s = s[:r_count]
print(new_s.count('W'))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s = input()
count = 0

while 'WR' in s:
    w_i = s.find('W')
    r_i = s.rfind('R')
    s = s[:w_i] + 'R' + s[w_i + 1:]
    s = s[:r_i] + 'W' + s[r_i + 1:]
    count += 1

print(count)


Fixed submission:
N = int(input())
s = input()
r_count = s.count('R')
new_s = s[:r_count]
print(new_s.count('W'))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s = input()
count = 0

while 'WR' in s:
    w_i = s.find('W')
    r_i = s.rfind('R')
    s = s[:w_i] + 'R' + s[w_i + 1:]
    s = s[:r_i] + 'W' + s[r_i + 1:]
    count += 1

print(count)


Fixed submission:
N = int(input())
s = input()
r_count = s.count('R')
new_s = s[:r_count]
print(new_s.count('W'))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B = [list(map(int, input().split())) for _ in range(Q)]


for nums in B:
    A = [nums[1] if i == nums[0] else i for i in A]
    print(sum(A))


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
sum_res = sum(A)
counter = [0 for _ in range(10 ** 5 + 1)]

for a in A:
    counter[a] += 1

for _ in range(Q):
    B, C = map(int, input().split())
    sum_res = sum_res - (counter[B] * B)
    sum_res = sum_res + (counter[B] * C)
    counter[C] += counter[B]
    counter[B] = 0
    print(sum_res)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B = [list(map(int, input().split())) for _ in range(Q)]


for nums in B:
    A = [nums[1] if i == nums[0] else i for i in A]
    print(sum(A))


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
sum_res = sum(A)
counter = [0 for _ in range(10 ** 5 + 1)]

for a in A:
    counter[a] += 1

for _ in range(Q):
    B, C = map(int, input().split())
    sum_res = sum_res - (counter[B] * B)
    sum_res = sum_res + (counter[B] * C)
    counter[C] += counter[B]
    counter[B] = 0
    print(sum_res)
Buggy python submission (verdict: Runtime Error):
if y % 2 == 1:
    print('No')
else:
    for i in range(x + 1):
        foot = i * 2 + (x - i) * 4
        if foot == y:
            print('Yes')
            exit()
    print('No')

Fixed submission:
x, y = map(int, input().split())
if y % 2 == 1:
    print('No')
else:
    if 2 * x <= y <= 4 * x:
        print('Yes')
    else:
        print('No')

Buggy python submission (verdict: Runtime Error):
if y % 2 == 1:
    print('No')
else:
    for i in range(x + 1):
        foot = i * 2 + (x - i) * 4
        if foot == y:
            print('Yes')
            break

print('No')


Fixed submission:
x, y = map(int, input().split())
if y % 2 == 1:
    print('No')
else:
    if 2 * x <= y <= 4 * x:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Runtime Error):
x, n = list(map(int, input().split()))
if n == 0:
    print(x)
    exit()
p_list = list(map(int, input().split()))

idx = p_list.index(x)

i = 0
while True:
    x_i = x - i
    x_j = x + i

    if x_i not in p_list:
        print(x_i)
        exit()
    if x_j not in p_list:
        print(x_j)
        exit()

    i += 1


Fixed submission:
x, n = list(map(int, input().split()))
p_list = list(map(int, input().split()))
if n == 0:
    print(x)
    exit()

i = 0
while True:
    x_i = x - i
    x_j = x + i

    if x_i not in p_list:
        print(x_i)
        exit()
    if x_j not in p_list:
        print(x_j)
        exit()

    i += 1
Buggy python submission (verdict: Runtime Error):
n, k = list(map(int, input().split()))
a_list = list(map(int, input().split()))

START = 1
# 訪れたタイミング
town_with_i = {START: 0}
# 現在地
current = START
# 既に訪れたことある街(巡回の判定に使う)
known_towns = set([START])
i = 0
for _ in range(k):
    i += 1
    # 現在地
    current = a_list[current - 1]

    # 既に来たことがあるということは巡回している
    if current in known_towns:
        break

    # メモ
    town_with_i[current] = i
    known_towns.add(current)

# 巡回までのステップ数
first_step = town_with_i[current]
# 1周するのに必要なステップ数
r = i - town_with_i[current]

# print(town_with_i)
# print(current)
# print(i)
# print(r)

loop_num = (k - first_step) % r

for i in range(loop_num):
    current = a_list[current - 1]

print(current)


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

START = 1
# 訪れたタイミング
town_with_i = {START: 0}
# 現在地
current = START
# 既に訪れたことある街(巡回の判定に使う)
known_towns = set([START])
i = 0
for _ in range(k):
    i += 1
    # 現在地
    current = a_list[current - 1]

    # 既に来たことがあるということは巡回している
    if current in known_towns:
        break

    # メモ
    town_with_i[current] = i
    known_towns.add(current)

# 巡回までのステップ数
first_step = town_with_i[current]
# 1周するのに必要なステップ数
r = i - town_with_i[current]

# print(town_with_i)
# print(current)
# print(i)
# print(r)

loop_num = (k - first_step) % r if r > 0 else (k - first_step)

for i in range(loop_num):
    current = a_list[current - 1]

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

time_list = list()

for _ in range(5):
    time_list.append(int(input()))


def key_func(x):
    if x < 100:  # 2桁 or 1桁の場合
        if x % 10 == 0:
            return 10
        return x % 10  # ex: 19の場合は9を返す
    else:
        if x % 100 == 0:
            return 10
        return x % 100  # ex: 123の場合は3を返す


time_list.sort(key=key_func, reverse=True)

# print(time_list)

ans = sum
for i, time in enumerate(time_list):
    if i < len(time_list) - 1:
        ans += math.ceil(time / 10) * 10
    else:
        ans += time

print(ans)


Fixed submission:
import math

time_list = list()

for _ in range(5):
    time_list.append(int(input()))

# 全探索
ans = 1e6
for i in range(len(time_list)):
    tmp = 0
    for j in range(len(time_list)):
        if i == j:
            tmp += time_list[i]
            continue
        tmp += math.ceil(time_list[j] / 10) * 10
    ans = min(tmp, ans)

print(ans)

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

time_list = list()

for _ in range(5):
    time_list.append(int(input()))


def key_func(x):
    if x < 100:
        if x % 10 == 0:
            return 10
        return x % 10  # ex: 19の場合は9を返す
    else:
        if x % 100 == 0:
            return 10
        return x % 100  # ex: 123の場合は3を返す


time_list.sort(key=key_func, reverse=True)

print(time_list)

ans = sum
for i, time in enumerate(time_list):
    if i < len(time_list) - 1:
        ans += math.ceil(time / 10) * 10
    else:
        ans += time

print(ans)


Fixed submission:
import math

time_list = list()

for _ in range(5):
    time_list.append(int(input()))

# 全探索
ans = 1e6
for i in range(len(time_list)):
    tmp = 0
    for j in range(len(time_list)):
        if i == j:
            tmp += time_list[i]
            continue
        tmp += math.ceil(time_list[j] / 10) * 10
    ans = min(tmp, ans)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A_list = [int(i) for i in input().split()]

ans = 1
for i in A_list:
    ans *= i

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

Fixed submission:
import math

N = int(input())
A_list = [int(i) for i in input().split()]

ans = 1
is_zero = False
is_over = False
for i in A_list:
    if i == 0:
        is_zero = True
        break
    if ans > 10**18:
        is_over = True

    if is_over:
        pass
    else:
        ans *= i

if is_zero:
    print(0)
elif is_over or ans > 10**18:
    print(-1)
else:
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math
A, B, N = map(int, input().split())

def fnc(x):
    return math.floor(A*x*1.0/B) - A*math.floor(x*1.0/B)

if N < B:
    print(fnc(N))
else:
    ans = 0
    for i in range(B-1, N+1, B):
        s = fnc(i)
        if s > ans:
            ans = s
    print(ans)

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

def fnc(x):
    return math.floor(A*x*1.0/B) - A*math.floor(x*1.0/B)

if B == 1:
    print(0)
elif N < B:
    print(fnc(N))
else:
    ans = 0
    for i in range(B-1, N+1, B):
        s = fnc(i)
        if s > ans:
            ans = s
    print(ans)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
ans = N
if N < K:
    q, mod = divmod(K, N)
    ans = min(N, K - N)
elif N == K:
    ans = 0
else:
    q, mod = divmod(N, K)
    ans = min(mod, abs(K - mod))
print(ans)

Fixed submission:
N, K = map(int, input().split())
ans = N
if N < K:
    if N != 0:
        q, mod = divmod(K, N)
        ans = min(N, K - N)
    elif N == 0:
        ans = 0
elif N == K:
    ans = 0
else:
    q, mod = divmod(N, K)
    ans = min(mod, abs(K - mod))
print(ans)
Buggy python submission (verdict: Runtime Error):
N = input()
K = int(input())

def F(N, K):
    if N < 10:
        if K == 0:
            return 1
        if K == 1:
            return N
        return 0
    q, r = divmod(N, 10)
    ret = 0
    if K >= 1:
        ret += F(q, K-1) * r
        ret += F(q-1, K-1) * (9-r)
    ret += F(q, K)
    return ret

print(F(N, K))

Fixed submission:
from functools import lru_cache
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

@lru_cache(None)
def F(N, K):
    if N < 10:
        if K == 0:
            return 1
        if K == 1:
            return N
        return 0
    q, r = divmod(N, 10)
    ret = 0
    if K >= 1:
        ret += F(q, K-1) * r
        ret += F(q-1, K-1) * (9-r)
    ret += F(q, K)
    return ret

print(F(N, K))
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
h = [int(i) for i in input().split()]

h = sorted(h, reverse=True)
is_zero = False
for i in range(k):
    try:
        del h[0]
    except:
        is_zero = True
        break
if is_zero:
    print(0)
else:
    print(sum(h))

Fixed submission:
n, k = map(int, input().split())
h = [int(i) for i in input().split()]

if n <= k:
    print(0)
else:
    h = sorted(h, reverse=True)
    print(sum(h[k:]))
Buggy python submission (verdict: Time Limit Exceeded):
K, s = map(int, input().split())

ans = 0
for x in range(0, K+1):
    for y in range(0, K+1):
        for z in range(0, K+1):
            if x + y + z == s:
                ans += 1
print(ans)

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

ans = 0
for x in range(0, K+1):
    for y in range(0, K+1):
        if s - (x + y) <= K and s - (x + y) >= 0 :
            ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
As = list(map(int, input().split()))
ans = 1
for n in range(N):
    ans *= As[n]
if ans <= 1e18:
    print(int(ans))
else:
    print(-1)

Fixed submission:
N = int(input())
As = list(map(int, input().split()))
if 0 in As:
    print(0)
else:
    As = sorted(As, reverse=True)
    ans = 1
    break_flag = 0
    for n in range(N):
        ans *= As[n]
        if ans > 1e18:
            print(-1)
            break_flag = 1
            break
    if break_flag == 0:
        print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=input()
a=[int(n) for n in a.split()]
c=0
for i in range(n):
    c+=a[i]*sum(a[i+1:])
    c=c%(10**9+7)
print(c)

Fixed submission:
n=int(input())
a=input()
a=[int(n) for n in a.split()]
c=0
aa=sum(a)
for i in range(n):
    aa-=a[i]
    c+=a[i]*aa
    c=c%(10**9+7)
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=input()
a=[int(n) for n in a.split()]
c=0
for i in range(n):
    c+=a[i]*sum(a[i+1:])
    c=c%(10**9+7)
print(c)

Fixed submission:
n=int(input())
a=input()
a=[int(n) for n in a.split()]
c=0
aa=sum(a)
for i in range(n):
    aa-=a[i]
    c+=a[i]*aa
    c=c%(10**9+7)
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
x=input()
x0=x.split()
n=int(x0[0])
k=int(x0[1])
x=input()
x0=x.split()
a=[int(n) for n in x0]
s=1
for i in range(k):
    s*=a[i]
for i in range(n-k):
    s1=s/a[i]*a[k+i]
    if s1>s:
        print("Yes")
    else:
        print("No")

Fixed submission:
x=input()
x0=x.split()
n=int(x0[0])
k=int(x0[1])
x=input()
x0=x.split()
a=[int(n) for n in x0]
for i in range(n-k):
    if a[i]<a[k+i]:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
for i in range(1,n+1):    
    c=0
    x=0
    y=0
    z=0
    for x in range(1,n):
        if x**2+y**2+z**2+x*y+y*z+z*x>i:
            break
        for y in range(1,n):
            if x**2+y**2+z**2+x*y+y*z+z*x>i:
                y=0
                break
            for z in range(1,n):
                if x**2+y**2+z**2+x*y+y*z+z*x>i:
                    z=0
                    break
                if x**2+y**2+z**2+x*y+y*z+z*x==i:
                    c+=1
    print(c)

Fixed submission:
import math
n=int(input())
ansl=[0]*(n+1)  
c=0
x=0
y=0
z=0
rn=int(float(math.sqrt(n)))
for x in range(1,rn+1):
    for y in range(1,rn+1):
        for z in range(1,rn+1):
            if x**2+y**2+z**2+x*y+y*z+z*x<=n:
                ansl[x**2+y**2+z**2+x*y+y*z+z*x]+=1
for i in range(n):                
    print(ansl[i+1])