Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

H, W = map(int, input().split())
sy, sx = map(int, input().split())
gy, gx = map(int, input().split())
map_list = []
for i in range(H):
    str_input = input()
    map_list.append(list(str_input))

walk = [[1,0], [-1,0], [0,1], [0,-1]] #　下　上　右　左
warp = [[2,-2], [2,-1], [2,0], [2,1],[2,2], [1,-2], [1,-1], [1,1],[1,2], [0,-2], [0,2], [-1,-2],[-1,-1], [-1,1], [-1,2],[-2,-2], [-2,-1], [-2,0], [-2,1],[-2,2]]

dist = [[10**12 for _ in range(W)] for i in range(H)] #10^3より大きい値

d = deque()
d.append([sy-1, sx-1])
dist[sy-1][sx-1] = 0

#BFS実行部分
while d:
    y,x = d.popleft()
    for dy,dx in walk:
        new_x = x + dx
        new_y = y + dy
        if 0 <= new_y < H and 0 <= new_x < W and map_list[new_y][new_x] == '.' and dist[new_y][new_x] > dist[y][x]:
            dist[new_y][new_x] = dist[y][x]
            d.appendleft([new_y, new_x]) #コスト低い方を優先して取り出すために先頭に追加
    for dy, dx in warp:
        new_x = x + dx
        new_y = y + dy
        if 0 <= new_y < H and 0 <= new_x < W and map_list[new_y][new_x] == '.' and dist[new_y][new_x] > dist[y][x] + 1:
            dist[new_y][new_x] = dist[y][x] + 1
            d.append([new_y, new_x]) #コストが高いので優先順位低い　最高尾に追加

#print(dist)
ans = dist[gy-1][gx-1]
if ans == 10**12:
    ans = -1
print(ans)


Fixed submission:
from collections import deque

H, W = map(int, input().split())
sy, sx = map(int, input().split())
gy, gx = map(int, input().split())
map_list = []
for i in range(H):
    str_input = input()
    map_list.append(list(str_input))

walk = [[1,0], [-1,0], [0,1], [0,-1]] #　下　上　右　左
warp = [[2,-2], [2,-1], [2,0], [2,1],[2,2], [1,-2], [1,-1], [1,1],[1,2], [0,-2], [0,2], [-1,-2],[-1,-1], [-1,1], [-1,2],[-2,-2], [-2,-1], [-2,0], [-2,1],[-2,2]]

dist = [[10**12 for _ in range(W)] for i in range(H)] #10^3より大きい値

d = deque()
d.append([sy-1, sx-1])
dist[sy-1][sx-1] = 0

#BFS実行部分
while d:
    y,x = d.popleft()
    for dy,dx in walk:
        new_x = x + dx
        new_y = y + dy
        if 0 <= new_y < H and 0 <= new_x < W and map_list[new_y][new_x] == '.' and dist[new_y][new_x] > dist[y][x]:
            dist[new_y][new_x] = dist[y][x]
            d.appendleft([new_y, new_x]) #コスト低い方を優先して取り出すために先頭に追加
    for dy, dx in warp:
        new_x = x + dx
        new_y = y + dy
        if 0 <= new_y < H and 0 <= new_x < W and map_list[new_y][new_x] == '.' and dist[new_y][new_x] > dist[y][x] + 1:
            dist[new_y][new_x] = dist[y][x] + 1
            d.append([new_y, new_x]) #コストが高いので優先順位低い　最高尾に追加

#print(dist)
ans = dist[gy-1][gx-1]
if ans == 10**12:
    ans = -1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
c_str = input()
c_list = list(c_str)

cnt = 0
flag = 1
w_pos = 0
r_pos = 0

while flag:
    for i in range(0,n):
        if c_list[i] == "W":
            w_pos = i
            break
        if i == n-1:
            w_pos = n-1
    for j in reversed(range(0,n)):
      if c_list[j] == "R":
        r_pos = j
        break
    if w_pos < r_pos:
        c_list[w_pos] = "R"
        c_list[r_pos] = "W"
        cnt += 1
    else:
      flag = 0

print(cnt)

Fixed submission:
n = int(input())
c_str = input()
c_list = list(c_str)

cnt = 0
flag = 1
w_pos = 0
r_pos = 0
range_start = 0
range_end = n

while flag:
    for i in range(range_start, range_end):
        if c_list[i] == "W":
            w_pos = i
            range_start = i
            break
        if i == range_end-1:
            w_pos = range_end-1 
    for j in reversed(range(range_start, range_end)):
      if c_list[j] == "R":
        r_pos = j
        range_end = j
        break
      if j == range_start:
        r_pos = range_start 
    if w_pos < r_pos:
        c_list[w_pos] = "R"
        c_list[r_pos] = "W"
        cnt += 1
    else:
      flag = 0

print(cnt)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# 整数の入力
n = int(input())
# 文字列の入力
s = [input() for i in range(n)]
# 数え上げ
C0 = s.count('AC')
C1 = s.count('WA')
C2 = s.count('TLE')
C3 = s.count('RE')
# 出力
print("AC x {}".format(C0))
print("WA x {}".format(C1))
print("TLE x {}".format(C2))
print("RE x {}".format(C3))

Fixed submission:
# -*- coding: utf-8 -*-
# 整数の入力
n = int(input())
if n%1000 == 0:
  ans = 0
else:
  ans = 1000-n%1000
# 出力
print("{}".format(ans))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

sum = 0

for j in range(1,N+1):
    k = int(N/j)
    sum += int((1+k)*k/2*j)

print(sum)

Fixed submission:
N = int(input())

sum = 0

for j in range(1,N+1):
    k = N//j
    sum += (1+k)*k*j//2
print(sum)

Buggy python submission (verdict: Time Limit Exceeded):
import math

N = int(input())

f_x = 0
sum = 0


for i in range(1,N+1):
    for j in range(1,int(math.floor(i+1)/2)+1):
        if i%j == 0:
            f_x += 1
    sum += i*(f_x+1)
    f_x = 0

print(sum-1)

Fixed submission:
N = int(input())

sum = 0

for j in range(1,N+1):
    k = N//j
    sum += (1+k)*k*j//2
print(sum)

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

f_x = 0
sum = 0

for i in range(1,N+1):
    for j in range(1,i+1):
        if i%j == 0:
            f_x += 1
    sum += i*f_x
    f_x = 0

print(sum)

Fixed submission:
N = int(input())

sum = 0

for j in range(1,N+1):
    k = N//j
    sum += (1+k)*k*j//2
print(sum)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

n, k = map(int, input().split())
p_list = list(map(int, input().split()))

ans = 1000*1000

for i in itertools.permutations(p_list,k):
    ans = min(ans, sum(i))

print(ans)

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

p_list_min = sorted(p_list)
ans = sum(p_list_min[0:k])

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

ans = 1

for i in range(n):
    ans *= a_list[i]
    if ans>10**18:
        ans = -1
print(ans)

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

ans = 1

for i in range(n):
    ans *= a_list_min[i]
    if ans>10**18:
        ans = -1
        break
print(ans)
Buggy python submission (verdict: Runtime Error):
import math

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

if N < B:
    temp1 = math.floor(A*1/B) - A*math.floor(1/B)
    temp2 = math.floor(A*N/B) - A*math.floor(N/B)
    ans = max(temp1, temp2)

if N > B:
    temp1 = math.floor(A*1/B) - A*math.floor(1/B)
    temp2 = math.floor(A*(B-1)/B) - A*math.floor((B-1)/B)
    ans = max(temp1, temp2)

print(ans)

Fixed submission:
import math

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

if N < B:
    temp1 = math.floor(A*1/B) - A*math.floor(1/B)
    temp2 = math.floor(A*N/B) - A*math.floor(N/B)
    ans = max(temp1, temp2)

if N >= B:
    temp1 = math.floor(A*1/B) - A*math.floor(1/B)
    temp2 = math.floor(A*(B-1)/B) - A*math.floor((B-1)/B)
    ans = max(temp1, temp2)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

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

graph = [[] for _ in range(N+1)]
ans = []

for i in range(N):
    graph[i].append(i+1)
    graph[i+1].append(i)
graph[X].append(Y)
graph[Y].append(X)


#print(graph)

for j in range(N):
    dist = [-1] * (N+1)
    #dist[j] = 0
    dist[j+1] = 0

    d = deque()
    d.append(j+1)
    #BFS実行部分
    while d:
        v = d.popleft()
        for i in graph[v]:
            if dist[i] != -1:
                continue
            dist[i] = dist[v] + 1
            d.append(i)
    ans.extend(dist[j+2:])

#print(ans)
for i in range(1, N):
    print(ans.count(i))
#print(*ans, sep="\n")


Fixed submission:
from collections import deque

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

ans_list = [0 for _ in range(N-1)]

for i in range(1, N+1): #1 ～ N start
    for j in range(i+1, N+1): # i+1 ～ N goal
        ans1 = j - i
        ans2 = abs(i-X) + 1 + abs(j-Y)
        ans_list[min(ans1, ans2)-1] += 1
print(*ans_list, sep="\n")

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

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

graph = [[] for _ in range(N+1)]
ans = []

for i in range(N):
    graph[i].append(i+1)
    graph[i+1].append(i)
graph[X].append(Y)
graph[Y].append(X)


#print(graph)

for j in range(N):
    dist = [-1] * (N+1)
    #dist[j] = 0
    dist[j+1] = 0

    d = deque()
    d.append(j+1)
    #BFS実行部分
    while d:
        v = d.popleft()
        for i in graph[v]:
            if dist[i] != -1:
                continue
            dist[i] = dist[v] + 1
            d.append(i)
    ans.extend(dist[j+2:])

#print(ans)
for i in range(1, N):
    print(ans.count(i))
#print(*ans, sep="\n")


Fixed submission:
from collections import deque

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

ans_list = [0 for _ in range(N-1)]

for i in range(1, N+1): #1 ～ N start
    for j in range(i+1, N+1): # i+1 ～ N goal
        ans1 = j - i
        ans2 = abs(i-X) + 1 + abs(j-Y)
        ans_list[min(ans1, ans2)-1] += 1
print(*ans_list, sep="\n")
Buggy python submission (verdict: Runtime Error):
S = input()

S_list = list(S)
N = len(S_list)
no_flag = 0

for i in range(N//2):
    if S_list[i] != S_list[N-i-1]:
        no_flag = 1

for i in range(int((N-1)/2)//2 -1):
    if S_list[i] != S_list[(N-1)/2-i-1]:
        no_flag = 1

for i in range((N-3)//2-1):
    if S_list[(N+3)//2+i-1] != S_list[N-1-i]:
        no_flag = 1

if no_flag == 1:
    print("No")
else:
    print("Yes")


Fixed submission:
S = input()

S_list = list(S)
N = len(S_list)
#print(N)
no_flag = 0

for i in range(N//2):
    if S_list[i] != S_list[N-i-1]:
        no_flag = 1

for i in range(int((N-1)/2)//2):
    #print(S_list[i], S_list[(N-1)//2-i-1])
    if S_list[i] != S_list[(N-1)//2-i-1]:
        no_flag = 1

for i in range((N-3)//2):
    #print(S_list[(N+3)//2+i-1], S_list[N-1-i])
    if S_list[(N+3)//2+i-1] != S_list[N-1-i]:
        no_flag = 1

if no_flag == 1:
    print("No")
else:
    print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
import collections

N = int(input())

S_list = []

for i in range(N):
    s = input()
    S_list.append(s)

c = collections.Counter(S_list)
c_max = c.most_common()
max_num = c.most_common()[0][1]
ans_list = []
ans_list.append(c.most_common()[0][0])

for i in range(1, len(c_max)):
    if c.most_common()[i][1] != max_num:
        break
    else:
        ans_list.append(c.most_common()[i][0])

print(*sorted(ans_list), sep='\n')

Fixed submission:
import collections

N = int(input())

S_list = []

for i in range(N):
    s = input()
    S_list.append(s)

c = collections.Counter(S_list)
c_max = c.most_common()
max_num = c.most_common()[0][1]
ans_list = []
ans_list.append(c.most_common()[0][0])

for i in range(1, len(c_max)):
    if c_max[i][1] != max_num:
        break
    else:
        ans_list.append(c_max[i][0])

print(*sorted(ans_list), sep='\n')

Buggy python submission (verdict: Time Limit Exceeded):
import collections

N = int(input())

S_list = []

for i in range(N):
    s = input()
    S_list.append(s)

c = collections.Counter(S_list)
c_max = c.most_common()
max_num = c.most_common()[0][1]
ans_list = []
ans_list.append(c.most_common()[0][0])

for i in range(1, len(c_max)):
    if c.most_common()[i][1] != max_num:
        break
    else:
        ans_list.append(c.most_common()[i][0])

print(*sorted(ans_list), sep='\n')


Fixed submission:
import collections

N = int(input())

S_list = []

for i in range(N):
    s = input()
    S_list.append(s)

c = collections.Counter(S_list)
c_max = c.most_common()
max_num = c.most_common()[0][1]
ans_list = []
ans_list.append(c.most_common()[0][0])

for i in range(1, len(c_max)):
    if c_max[i][1] != max_num:
        break
    else:
        ans_list.append(c_max[i][0])

print(*sorted(ans_list), sep='\n')
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
p_list = list(map(int, input().split()))

p_list_E = []
p_list_E_temp = [1, 1.5, 2, 2.5, 3, 3.5]

for i in range(len(p_list)):
    p_list_E.append(p_list_E_temp[p_list[i]-1])
#print(p_list_E)

p_list_sum = [0]
for i in range(0,N):
    p_list_sum.append(p_list_sum[i]+p_list_E[i])
#print(p_list_sum)

ans = 0
for i in range(K,N+1):
    ans = max(ans, p_list_sum[i]-p_list_sum[i-K])
print(ans)

Fixed submission:
N, K = map(int, input().split())
p_list = list(map(int, input().split()))

p_list_E = []
p_list_E_temp = [1, 1.5, 2, 2.5, 3, 3.5]

for i in range(len(p_list)):
    p_list_E.append((p_list[i]+1)*0.5)
#print(p_list_E)

p_list_sum = [0]
for i in range(0,N):
    p_list_sum.append(p_list_sum[i]+p_list_E[i])
#print(p_list_sum)

ans = 0
for i in range(K,N+1):
    ans = max(ans, p_list_sum[i]-p_list_sum[i-K])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
H, N = map(int, input().split())
A_list = []
B_list = []
for i in range(N):
    A, B = map(int, input().split())
    A_list.append(A)
    B_list.append(B)

dp = [[10**8+1]*(H) for _ in range(N+1)] # DPテーブルの作成

for i in range(N):
    for j in range(H):
        if j < A_list[i]: # 選ばない時
            #dp[i+1][j] = dp[i][j]
            dp[i+1][j] = min(dp[i][j],B_list[i])
        else: # 選ぶ時
            dp[i+1][j] = min(dp[i][j],dp[i+1][j-A_list[i]]+B_list[i])
        #print(i,j,dp[i+1]) #debug

#print(dp[N])
print(dp[N][H-1])

Fixed submission:
H, N = map(int, input().split())
A_list = []
B_list = []
for i in range(N):
    A, B = map(int, input().split())
    A_list.append(A)
    B_list.append(B)

dp = [[10**8+1]*(H) for _ in range(N+1)] # DPテーブルの作成

for i in range(N):
    for j in range(H):
        if j < A_list[i]: # 選ばない時
            #dp[i+1][j] = dp[i][j]
            dp[i+1][j] = min(dp[i][j],B_list[i])
        else: # 選ぶ時
            dp[i+1][j] = min(dp[i][j],dp[i+1][j-A_list[i]]+B_list[i])
        #print(i,j,dp[i+1]) #debug

#print(dp[N])
print(dp[N][H-1])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

pin = []
cnt = 0

for i in range(0, 1000):
    pin.append(str(i).zfill(3))
#print(pin)

for i in range(0, 1000):
    k = 0
    for j in range(len(s)):
        if pin[i][k] == s[j]:
            k += 1
            if k == 3:
                cnt += 1
                break
                
print(cnt)

Fixed submission:
n = int(input())
s = input()

pin = []
cnt = 0

for i in range(0, 1000):
    pin.append(str(i).zfill(3))
#print(pin)

for i in range(0, 1000):
    k = 0
    for j in range(len(s)):
        if pin[i][k] == s[j]:
            k += 1
            if k == 3:
                cnt += 1
                break
                
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
h_list = list(map(int, input().split()))

dp = [10**9] * N # DPテーブルの作成
dp[0] = 0

for i in range(1,N):
    for j in range(K+1):
        if i-j < 0:
            break
        dp[i] = min(dp[i], dp[i-j]+abs(h_list[i] - h_list[i-j]))
    #print(dp)
print(dp[N-1])


Fixed submission:
N, K = map(int, input().split())
h_list = list(map(int, input().split()))

dp = [10**9] * N # DPテーブルの作成
dp[0] = 0

for i in range(1,N):
    for j in range(K+1):
        if i-j < 0:
            break
        dp[i] = min(dp[i], dp[i-j]+abs(h_list[i] - h_list[i-j]))
    #print(dp)
print(dp[N-1])
Buggy python submission (verdict: Runtime Error):
N, W = map(int, input().split())
w_list = []
v_list = []
for i in range(N):
    w, v = map(int, input().split())
    w_list.append(w)
    v_list.append(v)

dp = [[0]*(W+1) for i in range(N+1)]
for i in range(1, N+1):
    for j in range(1, W+1):
        if j >= w_list[i-1]:
            dp[i][j] = max(dp[i-1][j], v_list[i-1]+dp[i-1][j-w_list[i-1]])
        else:
            dp[i][j] = dp[i-1][j]
    #print(dp[i])    

print(dp[N][W])

Fixed submission:
N, W = map(int, input().split())
w_list = []
v_list = []
for i in range(N):
    w, v = map(int, input().split())
    w_list.append(w)
    v_list.append(v)

MAX = 10**11 + 1
dp = [[MAX]*(N*10**3+1) for i in range(N+1)]
dp[0][0] = 0
for i in range(1, N+1):
    for j in range(0, N*10**3+1):
        if j == 0:
            dp[i][j] = 0
        elif j >= v_list[i-1]:
            dp[i][j] = min(dp[i-1][j], w_list[i-1]+dp[i-1][j-v_list[i-1]])
        else:
            dp[i][j] = dp[i-1][j]
    #print(dp[i]) 
ans = 10**6 + 1
for k in range(N*10**3+1):
    if dp[N][k] <= W:
        ans = k
#print(dp[N])
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
# 許容する再帰処理の回数を変更
sys.setrecursionlimit(10**5+10)
\# input処理を高速化する
input = sys.stdin.readline

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

lst_edge = [[] for _ in range(N)]
for i in range(M):
    x, y = map(int, input().split())
    lst_edge[x-1].append(y-1)

dp = [-1] * N

# rec(v) 頂点vを始点としたとき有効パスの長さの最大値
def rec(v):
    #print(dp, v)
    if dp[v] != -1:
        return dp[v] # 既に更新済み

    ans = 0
    lst_nv = lst_edge[v]
    for nv in lst_nv:
        ans = max(ans, rec(nv) + 1)
    dp[v] = ans # メモしながらリターン
    return dp[v]

ans_memo = 0
for i in range(N):
    ans_memo = max(ans_memo, rec(i))

print(ans_memo)

Fixed submission:
import sys
# 許容する再帰処理の回数を変更
sys.setrecursionlimit(10**5+10)
# input処理を高速化する
input = sys.stdin.readline

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

lst_edge = [[] for _ in range(N)]
for i in range(M):
    x, y = map(int, input().split())
    lst_edge[x-1].append(y-1)

dp = [-1] * N

# rec(v) 頂点vを始点としたとき有効パスの長さの最大値
def rec(v):
    #print(dp, v)
    if dp[v] != -1:
        return dp[v] # 既に更新済み

    ans = 0
    lst_nv = lst_edge[v]
    for nv in lst_nv:
        ans = max(ans, rec(nv) + 1)
    dp[v] = ans # メモしながらリターン
    return dp[v]

ans_memo = 0
for i in range(N):
    ans_memo = max(ans_memo, rec(i))

print(ans_memo)

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

lst_edge = [[] for _ in range(N)]
for i in range(M):
    x, y = map(int, input().split())
    lst_edge[x-1].append(y-1)

dp = [-1] * N

# rec(v) 頂点vを始点としたとき有効パスの長さの最大値
def rec(v):
    #print(dp, v)
    if dp[v] != -1:
        return dp[v] # 既に更新済み

    ans = 0
    lst_nv = lst_edge[v]
    for nv in lst_nv:
        ans = max(ans, rec(nv) + 1)
    dp[v] = ans # メモしながらリターン
    return dp[v]

ans_memo = 0
for i in range(N):
    ans_memo = max(ans_memo, rec(i))

print(ans_memo)

Fixed submission:
import sys
# 許容する再帰処理の回数を変更
sys.setrecursionlimit(10**5+10)
# input処理を高速化する
input = sys.stdin.readline

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

lst_edge = [[] for _ in range(N)]
for i in range(M):
    x, y = map(int, input().split())
    lst_edge[x-1].append(y-1)

dp = [-1] * N

# rec(v) 頂点vを始点としたとき有効パスの長さの最大値
def rec(v):
    #print(dp, v)
    if dp[v] != -1:
        return dp[v] # 既に更新済み

    ans = 0
    lst_nv = lst_edge[v]
    for nv in lst_nv:
        ans = max(ans, rec(nv) + 1)
    dp[v] = ans # メモしながらリターン
    return dp[v]

ans_memo = 0
for i in range(N):
    ans_memo = max(ans_memo, rec(i))

print(ans_memo)
Buggy python submission (verdict: Runtime Error):
s= input()
K = int(input())

ans_list = []
for i in range(len(s)-K+1):
    for j in range(i+1,i+K+1):
        ans_list.append(s[i:j])

ans_set = set(ans_list)
ans_list_min = sorted(list(ans_set))
print(ans_list_min[K-1])

Fixed submission:
s= input()
K = int(input())

ans_list = []
for i in range(len(s)):
    for j in range(i+1,i+K+1):
        if j < len(s)+1:
            ans_list.append(s[i:j])

ans_set = set(ans_list)
ans_list_min = sorted(list(ans_set))
#print(ans_list_min)
print(ans_list_min[K-1])
Buggy python submission (verdict: Time Limit Exceeded):
# from pprint import pprint
# import math
# import collections

n = int(input())
# n, k = map(int, input().split(' '))
a = list(map(int, input().split(' ')))

MOD = 10 ** 9 + 7

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

        # print(i, j, _)

print(sum % MOD)


Fixed submission:
# from pprint import pprint
# import math
# import collections

n = int(input())
# n, k = map(int, input().split(' '))
a = list(map(int, input().split(' ')))

MOD = 10 ** 9 + 7

wa = 0
for i in range(1, n):
    wa += a[i]

# print('wa', wa)

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

    wa -= a[j]
    j += 1

    # print('new wa', wa)

print(ans % MOD)
Buggy python submission (verdict: Runtime Error):
# from pprint import pprint
# import math
# import collections
from numba import jit

N = int(input())

loops = 0


# n, k = map(int, input().split(' '))
# a = list(map(int, input().split(' ')))

@jit('i8(i8,i8,i8)', cache=True)
def calc(x, y, z):
    return x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x


res = [0] * 1000000

for x in range(1, 100):
    for y in range(1, 100):
        for z in range(1, 100):
            n = calc(x, y, z)
            res[n - 1] += 1

for i in range(N):
    print(res[i])


Fixed submission:
# from pprint import pprint
# import math
# import collections

# n = int(input())
l, r, d = map(int, input().split(' '))
# a = list(map(int, input().split(' ')))
# a = []
# for i in range(n):
#     a.append(int(input()))
cnt = 0
for n in range(l, r + 1):
    if n % d == 0:
        cnt += 1

print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
# from pprint import pprint
import math

# import numpy as np
# import collections

n = int(input())
# n = 10000000
# n = 100


# n, k = map(int, input().split(' '))
# a = list(map(int, input().split(' ')))


def g(x):
    y = n // x
    return int(y * (y + 1) * x / 2)


ans = 0
for i in range(1, n + 1):
    ans += g(i)


print(ans)

Fixed submission:
# from pprint import pprint
import math
from numba import jit, njit

# import numpy as np
# import collections

n = int(input())
# n = 10000000
# n = 100


# n, k = map(int, input().split(' '))
# a = list(map(int, input().split(' ')))

def g(x):
    y = n // x
    return y * (y + 1) * x // 2


ans = 0
for i in range(1, n + 1):
    ans += g(i)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split(' ')))

LIMIT = 10 ** 18

res = 1

for a in A:
    res = res * a

if res > LIMIT:
    print('-1')
else:
    print(res)

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

LIMIT = 10 ** 18

zeroflg = 0
for a in A:
    if a == 0:
        zeroflg = 1
        break

if zeroflg == 1:
    res = 0
else:
    res = 1
    for a in A:
        if a == 0:
            res = 0
            break
        if res > LIMIT:
            break
    
        res = res * a

# res = math.exp(sum([math.log(a) for a in A]))

# X = np.array(A)
# res = X.prod()
#
# print(X)

# for a in A:
#     math.log(a)
#
#     res = res * a

if res > LIMIT:
    print('-1')
else:
    print(res)
Buggy python submission (verdict: Runtime Error):
S = int(input())

if S == 'ABC':
    print('ARC')
else:
    print('ABC')



Fixed submission:
S = input()

if S == 'ABC':
    print('ARC')
else:
    print('ABC')
Buggy python submission (verdict: Time Limit Exceeded):
X = int(input())

CNT = 2000

for a in range(-CNT, CNT):
    for b in range(-CNT, CNT):
        if X == a ** 5 - b ** 5:
            print(a, b)
            exit()


Fixed submission:
X = int(input())

CNT = 500

for a in range(-CNT, CNT):
    for b in range(-CNT, CNT):
        if X == a ** 5 - b ** 5:
            print(a, b)
            exit()

Buggy python submission (verdict: Time Limit Exceeded):
X = int(input())

CNT = 10000

for a in range(-CNT, CNT):
    for b in range(-CNT, CNT):
        if X == a ** 5 - b ** 5:
            print(a, b)
            exit()


Fixed submission:
X = int(input())

CNT = 500

for a in range(-CNT, CNT):
    for b in range(-CNT, CNT):
        if X == a ** 5 - b ** 5:
            print(a, b)
            exit()
Buggy python submission (verdict: Time Limit Exceeded):
import math

K = int(input())

sum = 0
for i in range(1, K + 1):
    for j in range(1, K + 1):
        for k in range(1, K + 1):
            a = math.gcd(math.gcd(i, j), k)
            # print(math.gcd(math.gcd(i, j), k))
            sum += a

print(sum)


Fixed submission:
import math

K = int(input())

gcds = []

for a in range(1, K + 1):
    for b in range(1, K + 1):
        gcds.append(math.gcd(a, b))

# print(gcds)

ans = 0
for c in range(1, K + 1):
    for g in gcds:
        if c == 1 or g ==1:
            ans += 1
        else:
            ans += math.gcd(c, g)

print(ans)