Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from sys import stdin

def mpow(n, p, mod):
    if mod == 0:
        return 0
    r = 1
    while p > 0:
        if p & 1 == 1:
            r = r * n % mod
        n = n * n % mod
        p >>= 1
    return r
def popcount(u):
    if u == 0:
        return 0
    a = u % bin(u).count('1')
    return 1 + popcount(a)
def main():
    input = stdin.readline
    n = int(input())
    x = '0b' + input()
    xs = int(x, 0)
    xc = x.count('1')
    xsp = mpow(xs, 1, xc + 1)
    xsm = mpow(xs, 1, xc - 1)
    for i in range(2, n + 2):
        if x[i] == '0':
            y = xsp + mpow(2, n - i + 1, xc + 1)
            y = mpow(y, 1, xc + 1)
        elif xc == 1:
            print(0)
            next
        else:
            y = xsm - mpow(2, n - i + 1, xc - 1)
            y = mpow(y, 1, xc - 1)
        print(popcount(y) + 1)            
main()

Fixed submission:
from sys import stdin

def mpow(n, p, mod):
    if mod == 0:
        return 0
    r = 1
    while p > 0:
        if p & 1 == 1:
            r = r * n % mod
        n = n * n % mod
        p >>= 1
    return r
def popcount(u):
    if u == 0:
        return 0
    a = u % bin(u).count('1')
    return 1 + popcount(a)
def main():
    input = stdin.readline
    n = int(input())
    x = '0b' + input()
    xs = int(x, 0)
    xc = x.count('1')
    xsp = mpow(xs, 1, xc + 1)
    xsm = mpow(xs, 1, xc - 1)
    for i in range(2, n + 2):
        if x[i] == '0':
            y = xsp + mpow(2, n - i + 1, xc + 1)
            y = mpow(y, 1, xc + 1)
            print(popcount(y) + 1)
        elif xc == 1:
            print(0)
        else:
            y = xsm - mpow(2, n - i + 1, xc - 1)
            y = mpow(y, 1, xc - 1)
            print(popcount(y) + 1)
main()
Buggy python submission (verdict: Time Limit Exceeded):
import networkx

n, m = map(int, input().split())
g = networkx.Graph()
g.add_nodes_from(list(range(n)))
for i in range(1, m + 1):
    a, b = map(int, input().split())
    g.add_edge(a, b)
#print(g.nodes())
#print(g.edges())
print("Yes")
for i in range(2, n + 1):
    print(networkx.shortest_path(g, 1, i)[-2])

Fixed submission:
from collections import deque

n, m = map(int, input().split())
a = [[] for _ in range(n)]
for i in range(m):
    x, y = map(int, input().split())
    a[x - 1].append(y - 1)
    a[y - 1].append(x - 1)
c = [0] * n
que = deque([])
que.append(0)
while len(que) > 0:
    e = que.popleft()
    for i in a[e]:
        if c[i] > 0:
            continue
        c[i] = e + 1
        que.append(i)
print("Yes")
for i in range(1, n):
    print(c[i])
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin, maxsize

def main():
    input = stdin.readline

    h, n = map(int, input().split())
    a = [list(map(int, input().split())) for _ in range(n)]
    dp = [maxsize] * (h + 1)
    dp[0] = 0
    for i in range(h + 1):
        for x, y in a:
            if i + x < h and dp[i + x] > dp[i] + y:
                dp[i + x] = dp[i] + y
            elif i + x >= h and dp[h] > dp[i] + y:
                dp[h] = dp[i] + y
    print(dp[h])
main()

Fixed submission:
from sys import stdin, maxsize

def main():
    input = stdin.readline

    h, n = map(int, input().split())
    a = [list(map(int, input().split())) for _ in range(n)]
    dp = [maxsize] * (h + 1)
    dp[0] = 0
    for i in range(h + 1):
        for x, y in a:
            if i + x < h and dp[i + x] > dp[i] + y:
                dp[i + x] = dp[i] + y
            elif i + x >= h and dp[h] > dp[i] + y:
                dp[h] = dp[i] + y
    print(dp[h])
main()
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin

def main():
    input = stdin.readline
    n = int(input())
    a = list(map(int, input().split()))
    p = []
    for i in reversed(range(n)):
        if a[i]:
            p.append(i + 1)
            u = 1
            v = i + 1
            while u * u <= v:
                if v % u == 0:
                    a[u - 1] ^= 1
                    if u != v // u:
                        a[v // u - 1] ^= 1
                u += 1
    if len(p) > 0:
        print(len(p))
        print(*p)
    else:
        print(0)
main()

Fixed submission:
from sys import stdin

def main():
    input = stdin.readline
    n = int(input())
    a = list(map(int, input().split()))
    p = []
    for i in reversed(range(n)):
        if a[i]:
            p.append(i + 1)
            u = 1
            v = i + 1
            while u * u <= v:
                if v % u == 0:
                    a[u - 1] ^= 1
                    if u != v // u:
                        a[v // u - 1] ^= 1
                u += 1
    if len(p) > 0:
        print(len(p))
        print(*p)
    else:
        print(0)
main()
Buggy python submission (verdict: Runtime Error):
from sys import stdin

def main():
    import numpy as np
    from scipy import linalg
    input = stdin.readline

    n = int(input())
    a = [[] for _ in range(n)]
    for i in range(n - 1):
        a[i] = [0] * i + [1, 1] + [0] * (n - i - 2)
    a[n - 1] = [1] + [0] * (n - 2) + [1]
    A = np.array(a)
    b = np.array(list(map(int, input().split())))
    LU = linalg.lu_factor(A)
    x = linalg.lu_solve(LU, b) * 2
    print(' '.join(map(str, map(int, x))))
main()

Fixed submission:
from sys import stdin

def main():
    input = stdin.readline

    n = int(input())
    a = list(map(int, input().split()))
    ans = [0] * n
    for i in range(n):
        if i % 2 == 0:
            ans[0] += a[i]
        else:
            ans[0] -= a[i]
    for i in range(1, n):
        ans[i] = 2 * a[i - 1] - ans[i - 1]
    print(' '.join(map(str, ans)))
main()

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin

def main():
    import numpy as np
    from scipy import linalg
    input = stdin.readline

    n = int(input())
    a = [[] for _ in range(n)]
    for i in range(n - 1):
        a[i] = [0] * i + [1, 1] + [0] * (n - i - 2)
    a[n - 1] = [1] + [0] * (n - 2) + [1]
    A = np.array(a)
    b = np.array(list(map(int, input().split())))
    LU = linalg.lu_factor(A)
    x = linalg.lu_solve(LU, b) * 2
    print(' '.join(map(str, map(int, x))))
main()

Fixed submission:
from sys import stdin

def main():
    input = stdin.readline

    n = int(input())
    a = list(map(int, input().split()))
    ans = [0] * n
    for i in range(n):
        if i % 2 == 0:
            ans[0] += a[i]
        else:
            ans[0] -= a[i]
    for i in range(1, n):
        ans[i] = 2 * a[i - 1] - ans[i - 1]
    print(' '.join(map(str, ans)))
main()

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin

def main():
    import numpy as np
    input = stdin.readline

    n = int(input())
    a = [[] for _ in range(n)]
    for i in range(n - 1):
        a[i] = [0] * i + [1, 1] + [0] * (n - i - 2)
    a[n - 1] = [1] + [0] * (n - 2) + [1]
    A = np.array(a)
    b = np.array(list(map(int, input().split())))
    x = np.linalg.solve(A, b) * 2
    print(' '.join(map(str, map(int, x))))
main()

Fixed submission:
from sys import stdin

def main():
    input = stdin.readline

    n = int(input())
    a = list(map(int, input().split()))
    ans = [0] * n
    for i in range(n):
        if i % 2 == 0:
            ans[0] += a[i]
        else:
            ans[0] -= a[i]
    for i in range(1, n):
        ans[i] = 2 * a[i - 1] - ans[i - 1]
    print(' '.join(map(str, ans)))
main()
Buggy python submission (verdict: Runtime Error):
from sys import stdin

def main():
    import heapq
    input = stdin.readline
    input()
    a = [-1 * int(i) for i in input().split()]
    heapq.heapify(a)
    while len(a) > 1:
        u = heapq.heappop(a)
        v = heapq.heappop(a)
        if u + 1 < 0:
            heapq.heappush(a, u + 1)
        if v + 1 < 0:
            heapq.heappush(a, v + 1)
    print(abs(a[0] + 1))
main()

Fixed submission:
from sys import stdin

def main():
    input = stdin.readline
    k, _ = map(int, input().split())
    a = max(map(int, input().split()))
    print(max(0, 2 * a - k - 1))
main()
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
mod = 998244353

LR = [tuple(map(int, input().split())) for _ in range(K)]
LR.sort()

dp = [0] * (N + 1)
dp[1] = 1
for i in range(1, N):
    if dp[i] <= 0:
        continue
    for L, R in LR:
        for d in range(L, R + 1):
            if i + d < N + 1:
                dp[i + d] += dp[i]
                dp[i + d] %= mod

print(dp[N])


Fixed submission:
N, K = map(int, input().split())
mod = 998244353

LR = [tuple(map(int, input().split())) for _ in range(K)]
LR.sort()

dpsum = [0] * (N + 1)
dpsum[1] = 1
dp = [0] * (N + 1)
dp[1] = 1

for i in range(2, N + 1):
    for L, R in LR:
        l = i - R
        r = i - L
        
        if r < 0:
            continue
        l = max(l, 0)
        
        dp[i] += dpsum[r] - dpsum[l - 1]
        dp[i] %= mod
    dpsum[i] = dpsum[i - 1] + dp[i]

print(dp[N])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import deque

H, W = map(int, input().split())
Ch, Cw = (int(i) - 1 for i in input().split())
Dh, Dw = (int(i) - 1 for i in input().split())
G = [list(sys.stdin.readline().strip()) for _ in range(H)]

def bfs(start):
    zeroQ = deque()
    oneQ = deque()
    zeroQ.append(start)
    dist[start[1]][start[0]] = 0

    while zeroQ or oneQ:
        if zeroQ:
            x, y = zeroQ.popleft()
        else:
            x, y = oneQ.popleft()
        
        for dx in range(-2, 3):
            for dy in range(-2, 3):
                nx = x + dx
                ny = y + dy
                
                if not(0 <= nx < W and 0 <= ny < H):
                    continue
                if G[ny][nx] == '#':
                    continue
                if abs(dx) + abs(dy) == 0:
                    continue
                
                cost = 0 if abs(dx) + abs(dy) == 1 else 1
                
                if dist[ny][nx] <= dist[y][x] + cost:
                    continue
                dist[ny][nx] = dist[y][x] + cost
                
                if cost == 0:
                    zeroQ.append((nx, ny))
                else:
                    oneQ.append((nx, ny))

dist = [[10 ** 9 for _ in range(W)] for _ in range(H)]

bfs((Cw, Ch))
# for g in dist:
#     print(g)
if dist[Dh][Dw] == 10 ** 9:
    print(-1)
else:
    print(dist[Dh][Dw])


Fixed submission:
import sys
from collections import deque

H, W = map(int, input().split())
Ch, Cw = (int(i) - 1 for i in input().split())
Dh, Dw = (int(i) - 1 for i in input().split())
G = [list(sys.stdin.readline().strip()) for _ in range(H)]

def bfs(start):
    zeroQ = deque()
    oneQ = deque()
    zeroQ.append(start)
    dist[start[1]][start[0]] = 0

    while zeroQ or oneQ:
        if zeroQ:
            x, y = zeroQ.popleft()
        else:
            x, y = oneQ.popleft()
        
        for dx in range(-2, 3):
            for dy in range(-2, 3):
                nx = x + dx
                ny = y + dy
                
                if not(0 <= nx < W and 0 <= ny < H):
                    continue
                if G[ny][nx] == '#':
                    continue
                if abs(dx) + abs(dy) == 0:
                    continue
                
                cost = 0 if abs(dx) + abs(dy) == 1 else 1
                
                if dist[ny][nx] <= dist[y][x] + cost:
                    continue
                dist[ny][nx] = dist[y][x] + cost
                
                if cost == 0:
                    zeroQ.append((nx, ny))
                else:
                    oneQ.append((nx, ny))

dist = [[10 ** 9 for _ in range(W)] for _ in range(H)]

bfs((Cw, Ch))
# for g in dist:
#     print(g)
if dist[Dh][Dw] == 10 ** 9:
    print(-1)
else:
    print(dist[Dh][Dw])
Buggy python submission (verdict: Time Limit Exceeded):
import sys

d = [0] * 26
def judge(n, t):
    res = 0
    for i in range(1, n + 1):
        today = t[i - 1] - 1
        res += S[i - 1][today]
        for j, dd in enumerate(d):
            if today != j:
                res -= C[j] * (i - dd)
    return res

D = int(input())
C = list(map(int, sys.stdin.readline().rsplit()))
S = [list(map(int, sys.stdin.readline().rsplit())) for _ in range(D)]

d = [0] * 26
res = 0
tt = []
for i in range(1, D + 1):
    maxi = 0
    for j in range(26):
        tt.append(j + 1)
        jg = judge(i, tt)
        if maxi < jg:
            maxT = j + 1
            maxi = jg
        tt.pop()
    d[maxT - 1] = i
    tt.append(maxT - 1)
    print(maxT)


Fixed submission:
import sys

D = int(input())
C = list(map(int, sys.stdin.readline().rsplit()))
S = [list(map(int, sys.stdin.readline().rsplit())) for _ in range(D)]

d = [0] * 26
res = 0
for i in range(D):
    index = max(enumerate(S[i]), key=lambda x: x[1])[0]
    print(index + 1)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import itertools

N, M, K = map(int, input().split())
A = list(map(int, sys.stdin.readline().rsplit()))
B = list(map(int, sys.stdin.readline().rsplit()))

sA = [0] + list(itertools.accumulate(A))
sB = [0] + list(itertools.accumulate(B))

res = 0
for i in range(N + 1):
    for j in range(M + 1):
        if sA[i] + sB[j] <= K:
            res = max(res, i + j)
        else:
            break

print(res)


Fixed submission:
import sys
import itertools
import bisect

N, M, K = map(int, input().split())
A = list(map(int, sys.stdin.readline().rsplit()))
B = list(map(int, sys.stdin.readline().rsplit()))

sA = [0] + list(itertools.accumulate(A))
sB = [0] + list(itertools.accumulate(B))

res = 0
for i, a in enumerate(sA):
    if K < a:
        break
    j = bisect.bisect_right(sB, K - a) - 1
    res = max(res, i + j)

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

res = 0
if N < B:
    res = (A * N) // B
else:
    res = ((A * (B - 1)) // B) - (A * ((B - 1) // B))
    i = B
    while i < N + 1:
        a = ((A * i) // B) - (A * (i // B))
        if res <= a:
            res = a
        else:
            break
        i += B

print(res)

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

res = 0
if N < B:
    res = (A * N) // B
else:
    left = B - 1
    right = 10 ** 15
    while right - left > 1:
        mid = (right + left) // 2
        a = ((A * mid) // B) - (A * (mid // B))
        if res > a:
            right = mid
        else:
            res = a
            left = mid

print(res)

Buggy python submission (verdict: Time Limit Exceeded):
A, B, N = map(int, input().split())

res = 0
if N < B:
    res = (A * N) // B
else:
    i = B - 1
    while i < N + 1:
        a = ((A * i) // B) - (A * (i // B))
        if res <= a:
            res = a
        else:
            break
        i += 1

print(res)


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

res = 0
if N < B:
    res = (A * N) // B
else:
    left = B - 1
    right = 10 ** 15
    while right - left > 1:
        mid = (right + left) // 2
        a = ((A * mid) // B) - (A * (mid // B))
        if res > a:
            right = mid
        else:
            res = a
            left = mid

print(res)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()[::-1]

res = 0
tmp = [0] * 2019
tmp[0] = 1
sum_of_digits = 0
d = 1

for c in S:
    sum_of_digits += int(c) * d
    sum_of_digits %= 2019
    d *= 10
    # d %= 2019
    tmp[sum_of_digits] += 1

for t in tmp:
    res += (t * (t - 1)) // 2

print(res)

Fixed submission:
S = input()[::-1]

res = 0
tmp = [0] * 2019
tmp[0] = 1
sum_of_digits = 0
d = 1

for c in S:
    sum_of_digits += int(c) * d
    sum_of_digits %= 2019
    d *= 10
    d %= 2019
    tmp[sum_of_digits] += 1

for t in tmp:
    res += (t * (t - 1)) // 2

print(res)

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

res = 0
tmp = [0] * 2019
tmp[0] = 1
for i in range(1, len(S) + 1):
    tmp[(int(S[len(S) - i:]) % 2019)] += 1
    # print(S[len(S) - i:])

for t in tmp:
    res += (t * (t - 1)) // 2

print(res)


Fixed submission:
S = input()[::-1]

res = 0
tmp = [0] * 2019
tmp[0] = 1
sum_of_digits = 0
d = 1

for c in S:
    sum_of_digits += int(c) * d
    sum_of_digits %= 2019
    d *= 10
    d %= 2019
    tmp[sum_of_digits] += 1

for t in tmp:
    res += (t * (t - 1)) // 2

print(res)

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

res = 0
tmp = [0] * 2019
tmp[0] = 1
for i in range(1, len(S) + 1):
    tmp[(int(S[len(S) - i:]) % 2019)] += 1
    # print(S[len(S) - i:])

for t in tmp:
    res += (t * (t - 1)) // 2

print(res)


Fixed submission:
S = input()[::-1]

res = 0
tmp = [0] * 2019
tmp[0] = 1
sum_of_digits = 0
d = 1

for c in S:
    sum_of_digits += int(c) * d
    sum_of_digits %= 2019
    d *= 10
    d %= 2019
    tmp[sum_of_digits] += 1

for t in tmp:
    res += (t * (t - 1)) // 2

print(res)

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

res = 0
for i in range(len(S) - 3):
    for j in range(i + 3, len(S)):
        if int(S[i:j + 1]) % 2019 == 0:
            res += 1

print(res)


Fixed submission:
S = input()[::-1]

res = 0
tmp = [0] * 2019
tmp[0] = 1
sum_of_digits = 0
d = 1

for c in S:
    sum_of_digits += int(c) * d
    sum_of_digits %= 2019
    d *= 10
    d %= 2019
    tmp[sum_of_digits] += 1

for t in tmp:
    res += (t * (t - 1)) // 2

print(res)
Buggy python submission (verdict: Time Limit Exceeded):
import math as m

K = int(input())

res = 0
for a in range(1, K + 1):
    for b in range(1, K + 1):
        for c in range(1, K + 1):
            res += m.gcd(m.gcd(a, b), c)

print(res)


Fixed submission:
import math as m

K = int(input())

res = 0
for a in range(1, K + 1):
    for b in range(a, K + 1):
        for c in range(b, K + 1):
            if a == b == c:
                res += a
            elif (a == b and a != c) or (b == c and b != a) or (a == c and a != b):
                res += m.gcd(max(a, b, c), min(a, b, c)) * 3
            else:
                res += m.gcd(m.gcd(a, b), c) * 6

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

rgb = {'R', 'G', 'B'}

res = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        if S[i] != S[j]:
            tmp = rgb - {S[i], S[j]}
            ok = True
            k = j
            while ok:
                k = S.find(list(tmp)[0], k + 1)
                if k == -1:
                    ok = False
                elif k - j != j - i:
                    res += 1
                else:
                    pass
print(res)

Fixed submission:
N = int(input())
S = input()

R = S.count('R')
G = S.count('G')
B = S.count('B')

res = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        k = j + j - i
        if k >= N:
            break
        if S[i] != S[j] and S[j] != S[k] and S[i] != S[k]:
            res += 1

res = R * G * B - res
print(res)

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

rgb = {'R', 'G', 'B'}

res = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        if S[i] != S[j]:
            tmp = rgb
            tmp = tmp - {S[i], S[j]}
            ok = True
            k = j
            while ok:
                k = S.find(list(tmp)[0], k + 1)
                if k == -1:
                    ok = False
                elif k - j != j - i:
                    res += 1
                else:
                    pass
print(res)


Fixed submission:
N = int(input())
S = input()

R = S.count('R')
G = S.count('G')
B = S.count('B')

res = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        k = j + j - i
        if k >= N:
            break
        if S[i] != S[j] and S[j] != S[k] and S[i] != S[k]:
            res += 1

res = R * G * B - res
print(res)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = list(map(int, input().split()))

A.sort(reverse=True)

total = 0
for a in A:
    total += a

for m in range(M):
    if (A[m] * 4 * M < total):
        print("No")
        exit(1)

print("Yes")


Fixed submission:
N, M = map(int, input().split())
A = list(map(int, input().split()))
 
A.sort(reverse=True)
 
total = 0
for a in A:
    total += a

word = "Yes"
for m in range(M):
    if (A[m] * 4 * M < total):
        word = "No"
 
print(word)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())

N = N % K

if (N > abs(N - K)):
    N = abs(N - K)
else:
    print(N)
    break

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

N = N % K

if (N == 0):
    print(N)
elif (N == K):
    print(0)
elif (K == 1):
    print(0)
else:
    while (N >= 0):
        if (N > abs(N - K)):
            N = abs(N - K)
        else:
            print(N)
            break

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())

if (N == 0):
    print(N)
elif (N == K):
    print(0)
elif (K == 1):
    print(0)
elif (K == 2 and N % 2 == 0):
    print(0)
elif (K == 2 and N % 2 == 1):
    print(1)
else:
    while (N >= 0):
        if (N > abs(N - K)):
            N = abs(N - K)
        else:
            print(N)
            break

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

N = N % K

if (N == 0):
    print(N)
elif (N == K):
    print(0)
elif (K == 1):
    print(0)
else:
    while (N >= 0):
        if (N > abs(N - K)):
            N = abs(N - K)
        else:
            print(N)
            break
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque


def bfs(start, end):
    Q = deque()
    Q.append(start)
    dist[start] = 0

    while Q:
        v = Q.popleft()

        for nv in G[v]:
            if dist[nv] != -1:
                continue
            Q.append(nv)
            dist[nv] = dist[v] + 1

            if nv == end:
                return dist[nv]


N, X, Y = map(int, input().split())
G = [[] for _ in range(N)]
res = [0] * N

for i in range(N - 1):
    G[i].append(i + 1)
    G[i + 1].append(i)

if abs(X - Y) != 1:
    G[X - 1].append(Y - 1)
    G[Y - 1].append(X - 1)

for i in range(N - 1):
    for j in range(i + 1, N):
        dist = [-1] * N
        res[bfs(i, j)] += 1

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


Fixed submission:
N,X,Y=map(int,input().split())
ans=[0 for i in range(1,N)]
 
for i in range(1,N):
    for j in range(i+1,N+1):
        k=min(abs(j-i),abs(X-i)+1+abs(Y-j),abs(Y-i)+1+abs(X-j))
        ans[k-1]+=1
 
for i in ans:
    print(i)

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


def bfs(start, end):
    Q = deque()
    Q.append(start)
    dist[start] = 0

    while Q:
        v = Q.popleft()

        for nv in G[v]:
            if dist[nv] != -1:
                continue
            Q.append(nv)
            dist[nv] = dist[v] + 1

            if nv == end:
                return dist[nv]


N, X, Y = map(int, input().split())
G = [[] for _ in range(N)]
res = [0] * N

for i in range(N - 1):
    G[i].append(i + 1)
    G[i + 1].append(i)

if abs(X - Y) != 1:
    G[X - 1].append(Y - 1)
    G[Y - 1].append(X - 1)

for i in range(N - 1):
    for j in range(i + 1, N):
        dist = [-1] * N
        res[bfs(i, j)] += 1

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


Fixed submission:
N,X,Y=map(int,input().split())
ans=[0 for i in range(1,N)]
 
for i in range(1,N):
    for j in range(i+1,N+1):
        k=min(abs(j-i),abs(X-i)+1+abs(Y-j),abs(Y-i)+1+abs(X-j))
        ans[k-1]+=1
 
for i in ans:
    print(i)