Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
def dfs(i, s, sum):
    if i == 3:
        if sum == 7:
            print(s + "=7")
            exit()
    dfs(i + 1, s + "+" + abcd[i + 1], sum + int(abcd[i + 1]))
    dfs(i + 1, s + "-" + abcd[i + 1], sum - int(abcd[i + 1]))
abcd = input()
dfs(0, abcd[0], int(abcd[0]))

Fixed submission:
def dfs(i, f, sum):
    if i == 3:
        if sum == 7:
            print(f + "=7")
            exit()
    else:
        dfs(i + 1, f + "+" + abcd[i + 1], sum + int(abcd[i + 1]))
        dfs(i + 1, f + "-" + abcd[i + 1], sum - int(abcd[i + 1]))
abcd = input()
dfs(0, abcd[0], int(abcd[0]))
Buggy python submission (verdict: Time Limit Exceeded):
from fractions import Fraction
N = int(input())
for h in range(1, 3501):
    for n in range(1, 3501):
        w1 = 4 / N - (1 / h + 1 / n)
        w = Fraction(w1)
        de = w.denominator
        nu = w.numerator
        if w1 > 0 and de % nu == 0:
            print(h, n, de // nu)
            exit()

Fixed submission:
N = int(input())
for h in range(3501):
    for n in range(h):
        if 4 * h * n - N * (h + n) > 0 and (N * h * n) % (4 * h * n - (N * (h + n))) == 0:
            w = (N * h * n) // (4 * h * n - N * (h + n))
            print(h, n, w)
            exit()
Buggy python submission (verdict: Runtime Error):
h,w=map(int,input().split())
a,l=[list(input())for i in range(h)],[0]*26
for i in a:
 for j in i:l[ord(j)-97]+=1
o,t,f=(h//2)*(w//2),(h//2)*(w%2)+(w//2)*(h%2),(h%2)*(w%2)
for i in l:
 while o and i>3:o-=1;i-=4
 while t and i>1:t-=1i-=2
 f-=i
print("Yes"if o==t==f==0else"No")

Fixed submission:
h,w=map(int,input().split())
a,l=[list(input())for i in range(h)],[0]*26
for i in a:
 for j in i:l[ord(j)-97]+=1
o,t,f=(h//2)*(w//2),(h//2)*(w%2)+(w//2)*(h%2),(h%2)*(w%2)
for i in l:
 while o and i>3:o-=1;i-=4
 while t and i>1:t-=1;i-=2
 f-=i
print("Yes"if o==t==f==0else"No")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(input()) for i in range(n)]
s = set(a)
s2 = set([])
for i in s:
    if a.count(i) % 2 == 1:
        s2.add(i)
print(len(s2))

Fixed submission:
from collections import Counter
n=int(input())
c=Counter([int(input())for i in range(n)])
a=0
for i in c.values():a+=1if i%2else 0
print(a)
Buggy python submission (verdict: Runtime Error):
alphabet = [chr(ord('a') + i) for i in range(26)]
s = list(input())
s = list(set(s))
s.sort()
for i in range(len(s)):
    if i == len(s) - 1:
        print(alphabet[i + 1])
        exit()
    elif s[i] == alphabet[i]:
        pass
    else:
        print(alphabet[i])
        exit()
print("None")

Fixed submission:
alphabet = [chr(ord('a') + i) for i in range(26)]
s = list(input())
s = sorted(list(set(s)))
if len(s) == 26:
    print("None")
    exit()
for i in range(len(s)):
    if i == len(s) - 1:
        if s[i] == alphabet[i]:
            print(alphabet[i+1])
        else:
            print(alphabet[i])
        exit()
    if s[i] == alphabet[i]:
        pass
    else:
        print(alphabet[i])
        exit()
Buggy python submission (verdict: Runtime Error):
n = int(input())
d = [-1 for i in range(n)]
e = [[] for i in range(n)]
for i in range(n - 1):
    a, b, c = map(int, input().split())
    e[a - 1].append([b - 1, c])
    e[b - 1].append([a - 1, c])
q, k = map(int, input().split())
def dfs(cur, par, di):
    d[cur] = di
    for i in e[cur]:
        if d[i[0]] == -1:
            if i == par:
                continue
            dfs(i[0], cur, di + i[1])
dfs(k - 1, -1, 0)
for i in range(q):
    x, y = map(int, input().split())
    print(d[x - 1] + d[y - 1])

Fixed submission:
import sys
sys.setrecursionlimit(10 ** 6)
n = int(input())
d = [-1 for i in range(n)]
e = [[] for i in range(n)]
for i in range(n - 1):
    a, b, c = map(int, input().split())
    e[a - 1].append([b - 1, c])
    e[b - 1].append([a - 1, c])
q, k = map(int, input().split())
def dfs(cur, par, di):
    d[cur] = di
    for i in e[cur]:
        if d[i[0]] == -1:
            if i == par:
                continue
            dfs(i[0], cur, di + i[1])
dfs(k - 1, -1, 0)
for i in range(q):
    x, y = map(int, input().split())
    print(d[x - 1] + d[y - 1])
Buggy python submission (verdict: Runtime Error):
input1 = list(map(int,input().split()))
A = input1[0]
B = input1[1]
C = input1[2]
D = input1[3]
if A * B >= C * D
  print(A * B)
else:
  print(C * D)

Fixed submission:
input1 = list(map(int,input().split()))
A = input1[0]
B = input1[1]
C = input1[2]
D = input1[3]
if A * B >= C * D:
  print(A * B)
else:
  print(C * D)
Buggy python submission (verdict: Runtime Error):
c = input()
if c == a or c == e or c == i or c == o or c == u:
  print("vowel")
else:
  print("consonant")

Fixed submission:
c = input()
if c == "a" or c == "e" or c == "i" or c == "o" or c == "u":
  print("vowel")
else:
  print("consonant")
Buggy python submission (verdict: Runtime Error):
s = list(input())
for i in range(len(s)):
    if s[i] == "C":
        c = True
    elif c and s[i] == "F":
        print("Yes")
        exit()
print("No")

Fixed submission:
s = list(input())
c = False
for i in range(len(s)):
    if s[i] == "C":
        c = True
    elif c and s[i] == "F":
        print("Yes")
        exit()
print("No")
Buggy python submission (verdict: Runtime Error):
x=input()
s,a=0,0
for i in x:
 if i=="S":
  s+=1
 elif s==0:
  ans+=1
 else:
  s-=1
print(ans+s)

Fixed submission:
x=input()
s,a=0,0
for i in x:
 if i=="S":
  s+=1
 elif s==0:
  a+=1
 else:
  s-=1
print(a+s)
Buggy python submission (verdict: Runtime Error):
def dfs(i, f):
    if i == len(s) - 1:
        return sum(list(map(int, f.split("+")))) 
    return dfs(i + 1, f + s[i + 1]) + \ 
    dfs(i + 1, f + "+" + s[i + 1])

s = input()
print(dfs(0, s[0]))

Fixed submission:
def dfs(i, f):
    if i == len(s) - 1:
        return sum(list(map(int, f.split("+")))) 
    return dfs(i + 1, f + s[i + 1]) + \
           dfs(i + 1, f + "+" + s[i + 1])
 
s = input()
print(dfs(0, s[0]))

Buggy python submission (verdict: Runtime Error):
def dfs(i, f):
    if i == len(s) - 1:
        return sum(list(map(int, f.split("+")))) 
    return dfs(i + 1, f + s[i + 1]) + \ dfs(i + 1, f + "+" + s[i + 1])

s = input()
print(dfs(0, s[0]))

Fixed submission:
def dfs(i, f):
    if i == len(s) - 1:
        return sum(list(map(int, f.split("+")))) 
    return dfs(i + 1, f + s[i + 1]) + \
           dfs(i + 1, f + "+" + s[i + 1])
 
s = input()
print(dfs(0, s[0]))
Buggy python submission (verdict: Time Limit Exceeded):
from copy import deepcopy
n, x = map(int, input().split())
a = list(map(int, input().split()))
ans = sum(a)
a1 = deepcopy(a)
for i in range(1, n):
    cur = x * i
    a2 = deepcopy(a1)
    for j in range(n):
        a1[n - j - 1] = min(a2[n - j - 1], a[n - i - j - 1])
        cur += a1[n - j - 1]
    ans = min(ans, cur)
print(ans)

Fixed submission:
from copy import deepcopy
n, x = map(int, input().split())
a = list(map(int, input().split()))
ans = sum(a)
a1 = deepcopy(a)
for i in range(1, n):
    cur = x * i
    a2 = deepcopy(a1)
    for j in range(n):
        a1[n - j - 1] = min(a2[n - j - 1], a[n - i - j - 1])
        cur += a1[n - j - 1]
    ans = min(ans, cur)
print(ans)
Buggy python submission (verdict: Runtime Error):
n, l = map(int, input().split())
S = [int(input()) for i in range(n)]
sorted_list = sorted(S)
print(*sorted_list, sep="")

Fixed submission:
n, l = map(int, input().split())
S = [input() for i in range(n)]
sorted_list = sorted(S)
print(*sorted_list, sep="")
Buggy python submission (verdict: Runtime Error):
x=input()
y=input()
if x%500<=y:
  print("Yes")
else:
  print("No")

Fixed submission:
x=int(input())
y=int(input())
if x%500<=y:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
a=input()
b=input()
print(b*2-a)

Fixed submission:
a=int(input())
b=int(input())
print(b*2-a)

Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
print(b*2-a)

Fixed submission:
a=int(input())
b=int(input())
print(b*2-a)

Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
print(b*2-a)

Fixed submission:
a=int(input())
b=int(input())
print(b*2-a)

Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
print(int(b*2-a))

Fixed submission:
a=int(input())
b=int(input())
print(b*2-a)

Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
print(b*2-a)

Fixed submission:
a=int(input())
b=int(input())
print(b*2-a)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))
P = [P[i] - 1 for i in range(N)]

loop_list = [] # ([indexes])
loop_score_list = []
loop_index_list = [0]*N
is_included_loop = [0] * N
num_loop = 0

for start in range(N):
    if is_included_loop[start]:
        continue
    now = start
    count = 1
    visited = [-1]*N # count
    visited[now] = 0
    while True:
        now = P[now]
        if visited[now] != -1:
            terminate_count = count
            start_count = visited[now]
            loop_start_idx = now
            break
        visited[now] = count
        count += 1
    
    num_loop += 1
    now = loop_start_idx
    loop_indexes = [now]
    visited = [-1]*N
    visited[now] = 0
    count = 1
    loop_score = 0
    while True:
        now = P[now]
        if visited[now] != -1:
            break
        loop_indexes.append(now)
        visited[now] = count
        loop_index_list[now] = num_loop
        loop_score += C[now]
        is_included_loop[now] = 1
    loop_list.append(loop_indexes)
    loop_score_list.append(loop_score)


scores = []
for start in range(N):
    tmp_score = 0
    rest = K
    now = start
    while not is_included_loop[now] and rest > 0:
        now = P[now]
        rest -= 1
        tmp_score += C[now]
        scores.append(tmp_score)
    
    if rest <= 0:
        scores.append(tmp_score)
        continue
    # loop
    number_of_loop = loop_index_list[now]
    one_cicle_score = loop_score_list[number_of_loop]
    if one_cicle_score < 0:
        continue
    if rest <= len(loop_list[number_of_loop]):
        while rest >= 0:
            now = P[now]
            rest -= 1
            tmp_score += C[now]
            scores.append(tmp_score)
        continue
    else:
        n_l = rest // len(loop_list[number_of_loop])
        tmp_score += n_l * one_cicle_score
        scores.append(tmp_score)
print(max(scores))
        
    

Fixed submission:
INF = float("inf")

N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = -INF
for s in range(N):
    ### STEP1
    cum = []
    i = P[s] - 1 #s-> i
    cum.append(C[i])
    while i != s:
        i = P[i] - 1
        cum.append(cum[-1] + C[i])
    

    # STEP2
    if K <= len(cum):
        #1週未満しかできない
        score = max(cum[:K])
    
    elif cum[-1] <= 0:
        #一周以上できるが、ループしたら損する場合
        score = max(cum)
    else:
        # K//Length - 1回だけループし、最後は最適に止まる
        score1 = cum[-1] * (K//len(cum) - 1)
        score1 += max(cum)

        #ループをK//length回だけループする場合
        score2 = cum[-1]*(K//len(cum))
        resi = K % len(cum) #残り進める回数
        if resi != 0:
            #まだ進めるなら
            score2 += max(0, max(cum[:resi]))
        score = max(score1, score2)
    
    ans = max(ans, score)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())

count = 1
num = 7
if K % 2 == 0:
    count = -1
else:
    while True:
        if num % K == 0:
            break
        num = (num*10 + 7) % K
        count += 1
print(count)

Fixed submission:
K = int(input())

count = 1
num = 7
if K % 2 == 0 or K % 5 == 0:
    count = -1
else:
    while True:
        if num % K == 0:
            break
        num = (num*10 + 7) % K
        count += 1
        if count >= 10**6 * 10**5:
            count = -1
            break
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = list(map(int, input().split()))

temp = 1
for i in range(K):
    temp *= A[i]
flag = 1
for i in range(K, N):
    temp2 = temp
    temp *= A[i]
    temp //= A[i-K]
    if temp2 >= temp:
        print("No")
    else:
        print("Yes")



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

temp = 1
# for i in range(K):
#     temp *= A[i]
# flag = 1
for i in range(K, N):
    # temp2 = temp
    # temp *= A[i]
    # temp //= A[i-K]
    if A[i] <= A[i-K]:
        print("No")
    else:
        print("Yes")
Buggy python submission (verdict: Runtime Error):
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
anss = []
for i in range(1, 1+N):
    if a[i] > K:
        break
    ans = 0
    for j in range(M, -1, -1):
        if a[i] + b[j] <= K:
            ans = j
            break
    ans += i
    anss.append(ans)
    
            
print(max(anss))


Fixed submission:
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
anss = []
for i in range(1+N):
    if a[i] > K:
        break
    while 1:
        if a[i] + b[j] <= K:
            break
        j -= 1
    
    ans = max(ans, i+j)
    
            
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
final = ""
digits = []
temp = N

while temp > 0:
    res = temp%26
    temp //= 26
    digits.append(res)
    
chars = "abcdefghijklmnopqrstuvwxyz"
dic = {i: chars[i] for i in range(26)}
for j in range(len(digits)):
    char = dic[digits[j] - 1]
    final = char + final
print(final)

Fixed submission:
N = int(input())
final = ""
chars = "abcdefghijklmnopqrstuvwxyz"
dic = {i: chars[i] for i in range(0, 26)}
pw_26 = [26**i for i in range(13)]
cum = 0
digit = 0
for i in range(13):
    cum += pw_26[i]
    if N < cum:
        digit = i
        break
start_from = cum - pw_26[digit]
temp = N - start_from
digits = []
counter = 0
while counter < digit:
    res = temp % 26
    temp //= 26
    digits.append(res)
    counter += 1

for j in range(len(digits)):
    char = dic[digits[j]]
    final = char + final
print(final)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [0] + list(map(int, input().split()))
A.sort()
S = sum(A)
count = 0
is_ok = [0] + [1] * N
for i in range(1, N+1):
    if is_ok[i] == 0:
        continue
    for j in range(1, i):
        if A[i] % A[j] == 0:
            is_ok[i] = 0
            if A[i] == A[j]:
                is_ok[j] = 0

print(sum(is_ok))

Fixed submission:
N = int(input())
A = [0] + list(map(int, input().split()))
A.sort()
A_max = A[-1]
dp = [1] * (1 + A_max)
from bisect import bisect_left, bisect_right

for x in A[1:]:
    if dp[x] == 0:
        continue
    y = x * 2
    while y <= A_max:
        dp[y] = 0
        y += x
ans = []
for i in range(1, A_max+1):
    if dp[i] == 1:
        idx_l = bisect_left(A, i)
        idx_r = bisect_right(A, i)
        if idx_r - idx_l > 1:
            continue
        if A[idx_l] == i:
            ans.append(idx_l)
print(len(ans))
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = [0] + list(map(int, input().split()))
from math import log
mx = min(int(log(K)) + 10**4, K)
for _ in range(mx):
    left_right = [0] + [(i-A[i], i+A[i]) for i in range(1, N+1)]
    ini = [0]*(N+1)
    for i in range(1, 1+N):
        l, r = left_right[i]
        l = max(1, l)
        ini[l] += 1
        if r+1 <= N:
            ini[r+1] -= 1
    A[1] = ini[1]
    for i in range(2, N+1):
        A[i] = A[i-1] + ini[i]
print(*A[1:])


Fixed submission:
from math import log
import sys
input = sys.stdin.readline

def main():
    N, K = map(int, input().split())
    A = [0] + list(map(int, input().split()))
    from math import log
    mx = min(int(log(K)) + 100, K)
    for _ in range(mx):
        left_right = [0] + [(i-A[i], i+A[i]) for i in range(1, N+1)]
        ini = [0]*(N+1)
        for i in range(1, 1+N):
            l, r = left_right[i]
            l = max(1, l)
            ini[l] += 1
            if r+1 <= N:
                ini[r+1] -= 1
        is_all_n = True
        A[1] = ini[1]
        if A[1] != N:
            is_all_n = False
        for i in range(2, N+1):
            A[i] = A[i-1] + ini[i]
            if A[i] != N:
                is_all_n = False
        if is_all_n:
            break
    print(*A[1:])
main()
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))

ans = 0
if A[0] >= 1:
    ans = -1
if N == 0:
    if A[0] == 0:
        ans = 1
    else:
        ans = -1
else:
    node_num = {N: A[N]}
    max_parent_num = {0: 1}
    for i in range(1, N+1):
        max_parent_num[i] = max_parent_num[i-1] * 2 - A[i]

    for i in range(N, 0, -1):
        if node_num[i] > min(2**i, A[i] + max_parent_num[i]):
            ans = -1
            break
        #i-1 no parent wo tukuru
        if node_num[i] <= max_parent_num[i-1]:
            i_1_parent_num = node_num[i]
        else:
            i_1_parent_num = max_parent_num[i-1]
        node_num[i-1] = i_1_parent_num + A[i-1]
    if node_num[0] > min(1, A[0] + max_parent_num[0]):
        ans = -1

if ans == -1 or ans == 1:
    print(ans)
else:
    ans = sum(node_num.values())
    print(ans)


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

ans = 0
if N == 0:
    if A[0] >= 2:
        ans = -1
    else:
        ans = 1

if N >= 1 and A[0] >= 1:
    ans = -1

if N >= 1:
    node_num = {N: A[N]}
    max_parent_num = {0: 1}
    for i in range(1, N+1):
        max_parent_num[i] = max_parent_num[i-1] * 2 - A[i]

    for i in range(N, 0, -1):
        if node_num[i] > A[i] + max_parent_num[i]:
            ans = -1
            break
        #i-1 no parent wo tukuru
        if node_num[i] <= max_parent_num[i-1]:
            i_1_parent_num = node_num[i]
        else:
            i_1_parent_num = max_parent_num[i-1]
        node_num[i-1] = i_1_parent_num + A[i-1]
        if i == 1:
            if node_num[i-1] != 1:
                ans = -1
                break

if ans == -1 or ans == 1:
    print(ans)
else:
    ans = sum(node_num.values())
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))

c = 0
loc = 0
locs = [0]
ini = 0

while True:
    c += 1
    loc = a[loc] - 1
    
    if c == k:
        print(loc + 1)
        break
    if loc in locs:
        ini = locs.index(loc)
        break
    locs.append(loc)

if c != k:
    rest = int((k - ini) % (c - ini))
    if rest <= 0:
        print(loc + 1)
    else:
        d = 0
        while True:
            d += 1
            loc = a[loc] - 1
            if d == rest:
                print(loc + 1)
                break


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

c = 0
loc = 0
locs = {0: 0}
ini = 0

while True:
    c += 1
    loc = a[loc] - 1
    
    if c == k:
        print(loc + 1)
        break
    if loc in locs:
        ini = locs.get(loc)
        break
    locs[loc] = c

if c != k:
    rest = int((k - ini) % (c - ini))
    if rest <= 0:
        print(loc + 1)
    else:
        d = 0
        while True:
            d += 1
            loc = a[loc] - 1
            if d == rest:
                print(loc + 1)
                break

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


#loop
c = 0
loc = 0
locs = [0]
ini = 0
while True:
    c += 1
    loc = a[loc] - 1
    
    if c == k:
        print(loc + 1)
        break
    if loc in locs:
        ini = locs.index(loc)
        break
    locs.append(loc)

if c != k:
    rest = (k - ini) % (c - ini)
    if rest == 0:
        print(locs[ini] + 1)
    else:
        d = 0
        while True:
            d += 1
            loc = a[loc] - 1
            if d == rest:
                print(loc + 1)
                break

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

c = 0
loc = 0
locs = {0: 0}
ini = 0

while True:
    c += 1
    loc = a[loc] - 1
    
    if c == k:
        print(loc + 1)
        break
    if loc in locs:
        ini = locs.get(loc)
        break
    locs[loc] = c

if c != k:
    rest = int((k - ini) % (c - ini))
    if rest <= 0:
        print(loc + 1)
    else:
        d = 0
        while True:
            d += 1
            loc = a[loc] - 1
            if d == rest:
                print(loc + 1)
                break
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

L = [i+A[i] for i in range(N)]
R = [i-A[i] for i in range(N)]

p = {}
m = {}
for i in range(N):
    if L[i] not in p:
        p[L[i]] = 1
    else:
        p[L[i]] += 1
for i in range(N):
    if R[i] not in m:
        m[R[i]] = 1
    else:
        m[R[i]] += 1

lower = min(min(p), min(m))
upper = max(max(p), max(m))
ans = 0
for x in range(lower, upper + 1):
    if x in p and x in m:
        ans += p[x] * m[x]

print(ans)

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

L = [i+A[i] for i in range(N)]
R = [i-A[i] for i in range(N)]

p = {}
m = {}
for i in range(N):
    if L[i] not in p:
        p[L[i]] = 1
    else:
        p[L[i]] += 1
for i in range(N):
    if R[i] not in m:
        m[R[i]] = 1
    else:
        m[R[i]] += 1

lower = max(min(p), min(m))
upper = min(max(p), max(m))
ans = 0
for x in range(lower, upper + 1):
    if x in p and x in m:
        ans += p[x] * m[x]

print(ans)

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



def main():
    a_added = [a[i] + i for i in range(n)]
    a_substracted = [j - a[j] for j in range(n)]
    c = 0
    
    for i in range(n-1):
        for j in range(i+1, n):
            if a_added[i] == a_substracted[j]:
                c += 1 

    print(c)
main()

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

L = [i+A[i] for i in range(N)]
R = [i-A[i] for i in range(N)]

p = {}
m = {}
for i in range(N):
    if L[i] not in p:
        p[L[i]] = 1
    else:
        p[L[i]] += 1
for i in range(N):
    if R[i] not in m:
        m[R[i]] = 1
    else:
        m[R[i]] += 1

lower = max(min(p), min(m))
upper = min(max(p), max(m))
ans = 0
for x in range(lower, upper + 1):
    if x in p and x in m:
        ans += p[x] * m[x]

print(ans)

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

def main():
    a_added = [a[i] + i for i in range(n)]
    a_substracted = [j - a[j] for j in range(n)]
    c = 0
    for i in range(n):
        c += a_substracted.count(a_added[i])
            
    print(c)
main()

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

L = [i+A[i] for i in range(N)]
R = [i-A[i] for i in range(N)]

p = {}
m = {}
for i in range(N):
    if L[i] not in p:
        p[L[i]] = 1
    else:
        p[L[i]] += 1
for i in range(N):
    if R[i] not in m:
        m[R[i]] = 1
    else:
        m[R[i]] += 1

lower = max(min(p), min(m))
upper = min(max(p), max(m))
ans = 0
for x in range(lower, upper + 1):
    if x in p and x in m:
        ans += p[x] * m[x]

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from math import floor

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

for k in range(0, (N+1)//B + 1):
    
    x = (k+1)*B - 1
    if x > N:
        x = N
    func = floor(A*x/B) - A * floor(x/B)
    f = max(func, f)
    
print(f)



Fixed submission:
from math import floor

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

x = min(B-1, N)
    
ans = floor(A*x/B) - A*floor(x/B)

print(ans)