Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a_list = list(map(int,input().split()))
ans_list = []
for i in range(n):
    ans_list.append(a_list.index(i+1) + 1)
print(*ans_list)

Fixed submission:
n=int(input())
a_list = list(map(int,input().split()))
index_list = []
for i in range(n):
    tmp_list = []
    tmp_list.append(i+1)
    tmp_list.append(a_list[i])
    index_list.append(tmp_list)
index_list.sort(key=lambda x:x[1])
ans_list = []
for j in range(len(index_list)):
    ans_list.append(index_list[j][0])
print(*ans_list)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n,q = map(int,input().split())
a_b_list = [list(map(int,input().split())) for i in range(n-1)]
p_x_list = [list(map(int,input().split())) for i in range(q)]

graph_direct_list = [[] for _ in range(n+1)]
for i in range(n-1):
    a_i = a_b_list[i][0]
    b_i = a_b_list[i][1]
    graph_direct_list[a_i].append(b_i)
    graph_direct_list[b_i].append(a_i)

counter_init_list = [0 for _ in range(n+1)]


for j in range(q):
    p_j = p_x_list[j][0]
    x_j = p_x_list[j][1]
    counter_init_list[p_j] += x_j

counter_list = [0 for _ in range(n+1)]
graph_vertex_checked_list = [0 for _ in range(n+1)]


graph_vertex_stack_que=collections.deque()
graph_vertex_stack_que.append(1) # start
while graph_vertex_stack_que:
    v = graph_vertex_stack_que.pop()
    graph_vertex_checked_list[v] = 1
    counter_list[v] += counter_init_list[v]
    for u in graph_direct_list[v]:
        if graph_vertex_checked_list[u] == 1:
            continue
        counter_list[u] += counter_list[v]
        graph_vertex_stack_que.append(u)
print(*counter_list[1:])

Fixed submission:
# -*- coding: utf-8 -*-
import collections
n,q = map(int,input().split())
a_b_list = [list(map(int,input().split())) for i in range(n-1)]
p_x_list = [list(map(int,input().split())) for i in range(q)]

graph_direct_list = [[] for _ in range(n+1)]
for i in range(n-1):
    a_i = a_b_list[i][0]
    b_i = a_b_list[i][1]
    graph_direct_list[a_i].append(b_i)
    graph_direct_list[b_i].append(a_i)

counter_init_list = [0 for _ in range(n+1)]


for j in range(q):
    p_j = p_x_list[j][0]
    x_j = p_x_list[j][1]
    counter_init_list[p_j] += x_j

counter_list = [0 for _ in range(n+1)]
graph_vertex_checked_list = [0 for _ in range(n+1)]


graph_vertex_stack_que=collections.deque()
graph_vertex_stack_que.append(1) # start
while graph_vertex_stack_que:
    v = graph_vertex_stack_que.pop()
    graph_vertex_checked_list[v] = 1
    counter_list[v] += counter_init_list[v]
    for u in graph_direct_list[v]:
        if graph_vertex_checked_list[u] == 1:
            continue
        counter_list[u] += counter_list[v]
        graph_vertex_stack_que.append(u)
print(*counter_list[1:])
Buggy python submission (verdict: Runtime Error):
n = int(input())
h_list = list(map(int,input().split()))
cost_min_list = [0] * n
cost_min_list[0] = 0
cost_min_list[1] = abs(h_list[1] - h_list[0])
for i in range(2, n):
    cost_min_list[i] = min(cost_min_list[i - 1] + abs(h_list[i] - h_list[i - 1]),
                           cost_min_list[i - 2] + abs(h_list[i] - h_list[i - 2]))
print(cost_min_list[n])

Fixed submission:
n = int(input())
h_list = list(map(int,input().split()))
cost_min_list = [0] * n
cost_min_list[0] = 0
cost_min_list[1] = abs(h_list[1] - h_list[0])
for i in range(2, n):
    cost_min_list[i] = min(cost_min_list[i - 1] + abs(h_list[i] - h_list[i - 1]),
                           cost_min_list[i - 2] + abs(h_list[i] - h_list[i - 2]))
print(cost_min_list[n - 1])

Buggy python submission (verdict: Runtime Error):
n = int(input())
h_list = list(map(int,input().split()))
cost_min_list = [0] * n
cost_min_list[0] = 0
cost_min_list[1] = h_list[0]
for i in range(2, n):
    cost_min_list[i] = min(cost_min_list[i - 1] + abs(h_list[i] - h_list[i - 1]),
                           cost_min_list[i - 2] + abs(h_list[i] - h_list[i - 2]))
print(cost_min_list[n])

Fixed submission:
n = int(input())
h_list = list(map(int,input().split()))
cost_min_list = [0] * n
cost_min_list[0] = 0
cost_min_list[1] = abs(h_list[1] - h_list[0])
for i in range(2, n):
    cost_min_list[i] = min(cost_min_list[i - 1] + abs(h_list[i] - h_list[i - 1]),
                           cost_min_list[i - 2] + abs(h_list[i] - h_list[i - 2]))
print(cost_min_list[n - 1])
Buggy python submission (verdict: Runtime Error):
n,y = map(int,input().split())
for a in range(n+1):
    for b in range(n-b+1):
        c=n-a-b
        if 10000*a+5000*b+1000*c==y:
            print(a, b, c)
            exit()
print("-1 -1 -1")

Fixed submission:
n,y = map(int,input().split())
import sys
for a in range(n+1):
    for b in range(n-a+1):
        c=n-a-b
        if 10000*a+5000*b+1000*c==y:
            print(a, b, c)
            sys.exit()
print("-1 -1 -1")
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n = int(input())
# スペース区切りの整数の入力
a_list = list(input())

count = 10000000

for i in range(len(a_list)):
    a_tmp = int(a_list[i])
    count_tmp = 0
    while int(a_tmp) % 2 == 0:
        a_tmp /= 2
        count_tmp += 1
    if count > count_tmp:
        count = count_tmp
print(count)

Fixed submission:
# -*- coding: utf-8 -*-
n = int(input())
# スペース区切りの整数の入力
a_list = list(input().split())

count = 10000000

for i in range(len(a_list)):
    a_tmp = int(a_list[i])
    count_tmp = 0
    while int(a_tmp) % 2 == 0:
        a_tmp /= 2
        count_tmp += 1
    if count > count_tmp:
        count = count_tmp
print(count)
Buggy python submission (verdict: Runtime Error):
n_str = input()

op_count = len(n) - 1  # すき間の個数
for i in range(2 ** op_count):
    op_list = ["-"] * op_count    # あらかじめ ["-", "-", "-"] というリストを作っておく
    for j in range(op_count):    # iの右からj+1番目のbitが1かどうかを確認
        if ((i >> j) & 1):
            op_list[len(op_list) - 1 -j] = "+"

    op_list.append("")
    formula = ""
    for i in range(len(n_str)):
        formula += (n_str[i] + op_list[i])
    if eval(formula) == 7:
        print(formula + "=7")
        break

Fixed submission:
n_str = input()

op_count = len(n_str) - 1  # すき間の個数
for i in range(2 ** op_count):
    op_list = ["-"] * op_count    # あらかじめ ["-", "-", "-"] というリストを作っておく
    for j in range(op_count):    # iの右からj+1番目のbitが1かどうかを確認
        if ((i >> j) & 1):
            op_list[len(op_list) - 1 -j] = "+"

    op_list.append("")
    formula = ""
    for i in range(len(n_str)):
        formula += (n_str[i] + op_list[i])
    if eval(formula) == 7:
        print(formula + "=7")
        break
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

res = [0] * (n+1)
x = 1
while x*x <= n:
  y = 1
  while y*y <= n:
    z = 1
    while z <= n:
      w = x*x+y*y+z*z+x*y+y*z+z*x
      if w <= n:
        res[w] += 1
      z += 1
    y += 1
  x+= 1
  
for i in range(1,n+1):
  print(res[i])

Fixed submission:
n = int(input())

res = [0] * (n+1)
x = 1
while x*x <= n:
  y = 1
  while y*y <= n:
    z = 1
    while z*z <= n:
      w = x*x+y*y+z*z+x*y+y*z+z*x
      if w <= n:
        res[w] += 1
      z += 1
    y += 1
  x+= 1
  
for i in range(1,n+1):
  print(res[i])
Buggy python submission (verdict: Runtime Error):
N = int(input())
INF = 10 ** 9
y_min_pos = [INF, []]
x_min_pos = [INF, []]
y_max_pos = [0, []]
x_max_pos = [0, []]
for _ in range(N):
    # print(x_min_pos, y_min_pos, y_max_pos, x_max_pos)
    x, y = map(int, input().split())
    if y <= y_min_pos[0]:
        if y == y_min_pos[0]:
            y_min_pos[1].append(x)
        else:
            y_min_pos = [y, [x]]
    if y >= y_max_pos[0]:
        if y == y_max_pos[0]:
            y_max_pos[1].append(x)
        else:
            y_max_pos = [y, [x]]

    if x <= x_min_pos[0]:
        if x == x_min_pos[0]:
            x_min_pos[1].append(y)
        else:
            x_min_pos = [x, [y]]
    if x >= x_max_pos[0]:
        if x == x_max_pos[0]:
            x_max_pos[1].append(y)
        else:
            x_max_pos = [x, [y]]
# print(x_max_pos[1])
x_min_ymax = max(x_min_pos[1])
x_max_ymax = max(x_max_pos[1])
y_min_xmax = max(y_min_pos[1])
y_max_xmax = max(y_max_pos[1])
x_min_ymin = min(x_min_pos[1])
x_max_ymin = min(x_max_pos[1])
y_min_xmin = min(y_min_pos[1])
y_max_xmin = min(y_max_pos[1])

y_min_max = max(
    abs(y_min_xmax - x_min_pos[0]) + abs(y_min_pos[0] - x_min_ymax),
    abs(y_min_xmax - y_max_xmin) + abs(y_min_pos[0] - y_max_pos[0]),
    abs(y_min_xmin - x_max_pos[0]) + abs(y_min_pos[0] - x_max_ymax),
    abs(y_min_xmin - y_max_xmax) + abs(y_min_pos[0] - y_max_pos[0]),
)
y_max_max = max(
    abs(y_max_xmax - x_min_pos[0]) + abs(y_max_pos[0] - x_min_ymin),
    abs(y_max_xmax - y_min_xmin) + abs(y_max_pos[0] - y_min_pos[0]),
    abs(y_max_xmin - x_max_pos[0]) + abs(y_max_pos[0] - x_max_ymin),
    abs(y_max_xmin - y_max_xmax) + abs(y_max_pos[0] - y_min_pos[0]),
)
x_min_max = max(
    abs(x_min_ymax - y_min_pos[0]) + abs(x_min_pos[0] - y_min_xmax),
    abs(x_min_ymax - x_max_ymin) + abs(x_min_pos[0] - x_max_pos[0]),
    abs(x_min_ymin - y_max_pos[0]) + abs(x_min_pos[0] - y_max_xmax),
    abs(x_min_ymin - x_max_ymax) + abs(x_min_pos[0] - x_max_pos[0]),
)
x_max_max = max(
    abs(x_max_ymax - y_min_pos[0]) + abs(x_max_pos[0] - y_min_xmin),
    abs(x_max_ymax - x_min_ymin) + abs(x_max_pos[0] - x_min_pos[0]),
    abs(x_max_ymin - y_max_pos[0]) + abs(x_max_pos[0] - y_max_xmin),
    abs(x_max_ymin - x_min_ymax) + abs(x_max_pos[0] - x_min_pos[0]),
)
print(max(y_min_max, y_max_max, x_min_max, x_max_max))


Fixed submission:
a, b, c, d = map(int, input().split())

print(max(a * c, a * d, b * c, b * d))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
N, K = map(int, input().split())
score = list(map(int, input().split()))
add = deque()
sc = 1
for i in range(K):
    sc *= score[i]
add.append(sc)
for i in range(K, N):
    sc = sc // score[i-K]
    sc *= score[i]
    add.append(sc)
pre = 0
for num, val in enumerate(add):
    if num != 0:
        print("Yes" if val > pre else "No")
    pre = val

Fixed submission:
N, K = map(int, input().split())
score = list(map(int, input().split()))
for i in range(K, N):
    print("Yes" if score[i - K] < score[i] else "No")

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
score = list(map(int, input().split()))
add = []
sc = 1
for i in range(K):
    sc *= score[i]
add.append(sc)
for i in range(K, N):
    sc = sc // score[i-K]
    sc *= score[i]
    add.append(sc)
pre = 0
for num, val in enumerate(add):
    if num != 0:
        print("Yes" if val > pre else "No")
    pre = val

Fixed submission:
N, K = map(int, input().split())
score = list(map(int, input().split()))
for i in range(K, N):
    print("Yes" if score[i - K] < score[i] else "No")

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
score = list(map(int, input().split()))
add = []
sc = 1
for i in score:
    sc *= i
    add.append(sc)
pre = 0
for i in range(K - 1, N):
    if i == K - 1:
        cur = add[i]
    else:
        cur = add[i] // add[i - K]
        print("Yes" if cur > pre else "No")
    pre = cur


Fixed submission:
N, K = map(int, input().split())
score = list(map(int, input().split()))
for i in range(K, N):
    print("Yes" if score[i - K] < score[i] else "No")
Buggy python submission (verdict: Time Limit Exceeded):
import copy
N, M = map(int, input().split())
inputlist = []
prev = []
next = []
ans = [10000000] * (N + 1)
idxStock = []
for i in range(M):
    a, b = map(int, input().split())
    if a == 1:
        prev.append(b)
        ans[b] = 1
    elif b == 1:
        prev.append(a)
        ans[a] = 1
    else:
        inputlist.append(a)
        inputlist.append(b)
while len(inputlist) != 0:
    for i in range(int(len(inputlist) / 2)):
        if prev.count(inputlist[i * 2]) != 0:
            idxStock.append(i)
            next.append(inputlist[i * 2 + 1])
            if ans[inputlist[i * 2 + 1]] ==10000000:
                ans[inputlist[i * 2 + 1]] = inputlist[i*2]
        elif prev.count(inputlist[i * 2 + 1]) != 0:
            idxStock.append(i)
            next.append(inputlist[i * 2])
            if ans[inputlist[i * 2]] == 10000000:
                ans[inputlist[i * 2]] = inputlist[i * 2 + 1]
    if len(next) == 0:
        print("No")
        exit()
    list.sort(idxStock, reverse=True)
    for i in idxStock:
        del inputlist[i*2]
        del inputlist[i * 2]
    idxStock.clear()
    prev.clear()
    prev = copy.copy(next)
    next.clear()
print("Yes")
for i in range(2, N + 1):
    print(ans[i])


Fixed submission:
import copy
import queue
q = queue.Queue()
N, M = map(int, input().split())
nodes = [[] for i in range(N)]
idxStock = []
for i in range(M):
    a, b = map(int, input().split())
    nodes[a - 1].append(b - 1)
    nodes[b - 1].append(a - 1)

dist = [-1] * N
ans = [-1] * N

q.put(0)
while not q.empty():
    now = q.get()
    for i in nodes[now]:
        if dist[i] != -1:
            continue
        dist[i] = dist[now] + 1
        q.put(i)
        ans[i] = now
print("Yes")
for i in range(1, N):
    print(ans[i]+1)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
towns = [int(i) for i in input().split()]
arrivedList = [1]
loopCount = 0
previous = 0
for i in range(len(towns)):
    idx = arrivedList[len(arrivedList) - 1] - 1
    current = towns[idx]
    if arrivedList.count(current) == 0:
        arrivedList.append(current)
    else:
        previous = len(arrivedList) - (len(arrivedList)-arrivedList.index(current))
        loopCount = len(arrivedList)-arrivedList.index(current)
        break
    if i == K - 1:
        print(arrivedList[len(arrivedList) - 1])
        exit()
remain = K % loopCount - previous
loopList = arrivedList[previous: previous + loopCount]

print(loopList[remain])

Fixed submission:
# 必ずN回以下でループする
N, K = map(int, input().split())
towns = [int(i) for i in input().split()]
arrivedList = [1]
for i in range(N * 2):
    arrivedList.append(towns[arrivedList[-1] - 1])
if K <= N:
    print(arrivedList[K])
    exit()

loop_end = N
loop_start = N - 1
while (arrivedList[loop_end] != arrivedList[loop_start]):
    loop_start -= 1

loop_len = loop_end - loop_start

# Kの値をloop_lenを使って調整する
K = K % loop_len
while K < N:
    K += loop_len

print(arrivedList[K])

Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
towns = [int(i) for i in input().split()]
arrivedList = [1]
loopCount = 0
previous = 0
for i in range(len(towns)):
    idx = arrivedList[len(arrivedList) - 1] - 1
    current = towns[idx]
    if arrivedList.count(current) == 0:
        arrivedList.append(current)
    else:
        previous = len(arrivedList) - (len(arrivedList)-arrivedList.index(current))
        loopCount = len(arrivedList)-arrivedList.index(current)
        print(previous,current, loopCount, arrivedList)
        break
    if i == K - 1:
        print(arrivedList[len(arrivedList) - 1])
        exit()
remain = K % loopCount - previous
loopList = arrivedList[previous: previous + loopCount]
print(loopList[remain])

Fixed submission:
# 必ずN回以下でループする
N, K = map(int, input().split())
towns = [int(i) for i in input().split()]
arrivedList = [1]
for i in range(N * 2):
    arrivedList.append(towns[arrivedList[-1] - 1])
if K <= N:
    print(arrivedList[K])
    exit()

loop_end = N
loop_start = N - 1
while (arrivedList[loop_end] != arrivedList[loop_start]):
    loop_start -= 1

loop_len = loop_end - loop_start

# Kの値をloop_lenを使って調整する
K = K % loop_len
while K < N:
    K += loop_len

print(arrivedList[K])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
line = list(map(int, input().split()))
dic = set(line)
nums = 0
for i in dic:
    cnt = line.count(i) - 1
    nums += (cnt * (cnt + 1)) // 2

for i in line:
    cnt = line.count(i) - 1
    print(nums - cnt)


Fixed submission:
from collections import Counter
import time

N = int(input())
line = list(map(int, input().split()))
dic = Counter(line)
nums = 0
for num, cnt in dic.items():
    if cnt > 1:
        nums += (cnt * (cnt - 1)) // 2
for i in line:
    print(nums - (dic[i] - 1))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
line = list(map(int, input().split()))
added = []
nums = 0
for i in line:
    if i not in added:
        cnt = line.count(i) - 1
        nums += (cnt * (cnt + 1)) // 2
        added.append(i)

for i in line:
    cnt = line.count(i) - 1
    print(nums - cnt)


Fixed submission:
from collections import Counter
import time

N = int(input())
line = list(map(int, input().split()))
dic = Counter(line)
nums = 0
for num, cnt in dic.items():
    if cnt > 1:
        nums += (cnt * (cnt - 1)) // 2
for i in line:
    print(nums - (dic[i] - 1))
Buggy python submission (verdict: Runtime Error):
str = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51"
input_field = [int(i) for i in str.split(", ")]
print(input_field[input(int()) - 1])

Fixed submission:
str = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51"
input_field = [int(i) for i in str.split(", ")]
print(input_field[int(input()) - 1])
Buggy python submission (verdict: Runtime Error):
# 4 5
import math
field = [int(i) for i in input().split(" ")]
field_num = field[0] * field[1]
if field_num[0] == 1 or field_num[1] == 1:
    print(1)
else:
    canFillBlock = 0
    canFillBlock += math.ceil(field[1]/2) * math.ceil(field[0]/2)
    canFillBlock += math.floor(field[1]/2) * math.floor(field[0]/2)
    print(canFillBlock)


Fixed submission:
# 4 5
import math
field = [int(i) for i in input().split(" ")]
field_num = field[0] * field[1]
if field[0] == 1 or field[1] == 1:
    print(1)
else:
    canFillBlock = 0
    canFillBlock += math.ceil(field[1]/2) * math.ceil(field[0]/2)
    canFillBlock += math.floor(field[1]/2) * math.floor(field[0]/2)
    print(canFillBlock)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
sticks = list(map(int, input().split()))
diffMin = sum(sticks)
for i in range(len(sticks)):
    diff = abs(sum(sticks[:i]) - sum(sticks[i:]))
    if diff < diffMin:
        diffMin = diff
print(diffMin)


Fixed submission:
N = int(input())
sticks = list(map(int, input().split()))
sticksSum = sum(sticks)
diffMin = sum(sticks)
plusSticks = 0
for i in range(len(sticks)):
    plusSticks += sticks[i]
    diffMin = min(diffMin, abs(2*plusSticks-sticksSum))
print(diffMin)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
T = input()
a_idx = ord('a')
S_Lis = {}
T_Lis = {}
leng = len(S)
for i in range(leng):
    s_idx = ord(S[i])-a_idx
    t_idx = ord(T[i])-a_idx
    if s_idx in S_Lis:
        S_Lis[s_idx].append(i)
    else:
        S_Lis[s_idx] = [i]
    if t_idx in T_Lis:
        T_Lis[t_idx].append(i)
    else:
        T_Lis[t_idx] = [i]
    if S_Lis[s_idx] != T_Lis[t_idx]:
        print("No")
        exit()
print("Yes")

Fixed submission:
S = input()
T = input()
a_idx = ord('a')
S_Lis = {0: [], 1: [], 2: [], 3: [], 4: [], 5: [], 6: [], 7: [], 8: [], 9: [], 10: [], 11: [], 12: [],
         13: [], 14: [], 15: [], 16: [], 17: [], 18: [], 19: [], 20: [], 21: [], 22: [], 23: [], 24: [], 25: []}
T_Lis = {0: [], 1: [], 2: [], 3: [], 4: [], 5: [], 6: [], 7: [], 8: [], 9: [], 10: [], 11: [], 12: [],
         13: [], 14: [], 15: [], 16: [], 17: [], 18: [], 19: [], 20: [], 21: [], 22: [], 23: [], 24: [], 25: []}
leng = len(S)
for i in range(leng):
    S_Lis[ord(S[i])-a_idx].append(i)
    T_Lis[ord(T[i])-a_idx].append(i)
for i in range(26):
    tmpS = S_Lis[i]
    if len(tmpS) == 0 or tmpS == T_Lis[i]:
        continue
    else:
        flag = True
        for j in T_Lis.values():
            if tmpS == j:
                flag = False
                break
        if flag:
            print("No")
            exit()
print("Yes")
Buggy python submission (verdict: Runtime Error):
import copy
from statistics import mode
N = int(input())
seq = [int(i) for i in input().split()]
seqP1 = [i + 1 for i in copy.copy(seq)]
seqM1 = [i - 1 for i in copy.copy(seq)]
mixed = seq + seqM1 + seqP1
print(mixed.count(mode(mixed)))


Fixed submission:
import copy
import collections
N = int(input())
seq = [int(i) for i in input().split()]
seqP1 = [i + 1 for i in copy.copy(seq)]
seqM1 = [i - 1 for i in copy.copy(seq)]
mixed = seq + seqM1 + seqP1
print(mixed.count(collections.Counter(mixed).most_common()[0][0]))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))

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

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

Fixed submission:
import numpy as np
n = int(input())
a = list(map(int,input().split()))
a_sum = sum(a)
aa = np.array(np.cumsum(a),dtype="object")
all_a = sum(a)

mod = 1000000007

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

print(ans%mod)
Buggy python submission (verdict: Runtime Error):
import numpy as np
n = int(input())
a_lst = list(map(int,input().split()))

ans = np.prod(a_lst)
if ans > 10**18:
    print("-1")
else:
    print(ans)

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

ans = 1
if 0 in a_lst:
    print(0)
else:
    for a in a_lst:
        ans *= a
        if ans > 10**18:
            ans = -1
            break
    print(ans)

Buggy python submission (verdict: Runtime Error):
import numpy as np
n = int(input())
a_lst = list(map(int,input().split()))

ans = np.prod(a_lst)
if ans > 10**18
    print("-1")
else:
    print(ans)

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

ans = 1
if 0 in a_lst:
    print(0)
else:
    for a in a_lst:
        ans *= a
        if ans > 10**18:
            ans = -1
            break
    print(ans)

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

ans = 1
for a in a_lst:
    ans = ans * a
if ans > 10**18:
    print("-1")
else:
    print(ans)

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

ans = 1
if 0 in a_lst:
    print(0)
else:
    for a in a_lst:
        ans *= a
        if ans > 10**18:
            ans = -1
            break
    print(ans)

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

ans = 1
for a in a_lst:
    ans = ans * a
if ans > 10**18:
    print("-1")
else:
    print(ans)

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

ans = 1
if 0 in a_lst:
    print(0)
else:
    for a in a_lst:
        ans *= a
        if ans > 10**18:
            ans = -1
            break
    print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a_lst = list(map(int,input().split()))

ans = 1
for a in a_lst:
    ans = ans * a
if ans > 10**18:
    print("-1")
else:
    print(ans

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

ans = 1
if 0 in a_lst:
    print(0)
else:
    for a in a_lst:
        ans *= a
        if ans > 10**18:
            ans = -1
            break
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
a,b,n = map(int,input().split())

ans = -float("inf")
for x in range(n):
    #print(a*((x+1)%b)//b)
    if a*((x+1)%b)//b > ans:
        ans = a*((x+1)%b)//b

#print("----------")
print(ans)

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

if n < b-1:
    print(a*(n%b)//b)
else:
    print(a*((b-1)%b)//b)

Buggy python submission (verdict: Time Limit Exceeded):
import math
a,b,n = map(int,input().split())
ans = -float("inf")
for x in range(n):
    num = math.floor(a*(x+1)/b) - a*(math.floor((x+1)/b))
    if num > ans:
        ans = num
print(ans)

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

if n < b-1:
    print(a*(n%b)//b)
else:
    print(a*((b-1)%b)//b)
Buggy python submission (verdict: Runtime Error):
n,k  = map(int,input().split())

if n>=k:
    if n%k != 1 or n%k != 2 or n%k != 0:
        print(n%(k-1))
    else:
        print(n%k)
elif n<k:
    print(n)

Fixed submission:
n,k  = map(int,input().split())
print(min(n%k, abs(k-n%k)))