Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

N = list(input())


def query(num):
    print(num)
    return int(input())


result = [-1] * N
result[0] = query(0)
edge = [0, N]
if result[0] == 2:
    pass
else:
    for i in range(20):
        idx = int(abs(edge[0] - edge[1]) / 2)
        result[idx] = query(idx)
        if result[idx] == 2:
            break
        for i in range(2):
            if abs(edge[i] - idx) % 2 == 0:
                if result[edge[i]] == result[idx]:
                    if i == 0:
                        edge[1] = idx
                    else:
                        edge[0] = idx
            elif abs(edge[i] - idx) % 2 == 1:
                if result[edge[i]] != result[idx]:
                    if i == 0:
                        edge[1] = idx
                    else:
                        edge[0] = idx


### FIXED CODE ###

import sys
N = int(input())


def query(num):
    print(num)
    return input()


result = [-1] * (N + 1)
result[0] = query(0)
result[N] = result[0]
edge = [0, N]
if result[0] == "Vacant":
    sys.stdout.flush()
else:
    for i in range(30):
        idx = int(abs(edge[0] - edge[1]) / 2) + min(edge)
        result[idx] = query(idx)
        if result[idx] == "Vacant":
            sys.stdout.flush()
            break
        for i in range(2):
            r = result[edge[i]]
            if abs(edge[i] - idx) % 2 == 0:
                if r != result[idx]:
                    if i == 0:
                        edge[1] = idx
                        break
                    else:
                        edge[0] = idx
                        break
            elif abs(edge[i] - idx) % 2 == 1:
                if r == result[idx]:
                    if i == 0:
                        edge[1] = idx
                        break
                    else:
                        edge[0] = idx
                        break
    sys.stdout.flush()
### BUGGY CODE ###

h, w, k = map(int, input().split())
ar = [list(map(int, input())) for _ in range(h)]

ans = None
for i in range(2**(h - 1)):
    cut = [i & (2**a) != 0 for a in range(h - 1)]
    t = 0
    to_add = [0]
    for cut_ in cut:
        if cut_:
            t += 1
        to_add.append(t)
    n_h = t
    n_w = 0
    cnts = [0 for _ in range(n_h + 1)]
    for x in range(w):
        for y in range(h):
            cnts[to_add[y]] += ar[y][x]
        if max(cnts) > k:
            n_w += 1
            cnts = [0 for _ in range(n_h + 1)]
            for y in range(h):
                cnts[to_add[y]] += ar[y][x]
    if ans is None or ans > n_h + n_w:
        ans = n_h + n_w
print(ans)


### FIXED CODE ###

h, w, k = map(int, input().split())
ar = [list(map(int, input())) for _ in range(h)]

ans = None
for i in range(2**(h - 1)):
    t = 0
    to_add = [0]
    for a in range(h - 1):
        if i & (2**a):
            t += 1
        to_add.append(t)
    n_h = t
    n_w = 0
    zz = [0 for _ in range(n_h + 1)]
    cnts = zz.copy()
    is_new = True
    is_fail = False
    for x in range(w):
        is_over = False
        for y in range(h):
            z = to_add[y]
            cnts[z] += ar[y][x]
            if cnts[z] > k:
                is_over = True
                break
        if is_over:
            n_w += 1
            if ans is not None and ans <= n_h + n_w:
                break
            cnts = zz.copy()
            for y in range(h):
                z = to_add[y]
                cnts[z] += ar[y][x]
                if cnts[z] > k:
                    is_fail = True
                    break
            if is_fail:
                break
    if not is_fail and (ans is None or ans > n_h + n_w):
        ans = n_h + n_w
print(ans)
### BUGGY CODE ###

s = input()
q = int(input())
lst = []
for i in range(q):
    t_f_c = list(input().split())
    lst.append(t_f_c)
for t_f_c in lst:
    if t_f_c[0] == "1":
        s = s[::-1]
    elif t_f_c[0] == "2":
        if t_f_c[1] == "1":
            s = t_f_c[2] + s
        elif t_f_c[1] == "2":
            s = s + t_f_c[2]
print(s)

### FIXED CODE ###

from collections import deque
s = deque(input())
q = int(input())

cnt = 1
for i in range(q):
    t_f_c = list(input().split())
    if t_f_c[0] == "1":
        cnt *= -1
    elif t_f_c[0] == "2":
        if cnt == 1: #反転-
            if t_f_c[1] == "1":
                s.appendleft(t_f_c[2])
            elif t_f_c[1] == "2":
                s.append(t_f_c[2])
        elif cnt == -1:  #反転+
             if t_f_c[1] == "2":
                s.appendleft(t_f_c[2])
             elif t_f_c[1] == "1":
                s.append(t_f_c[2])
if cnt == 1:
    print("".join(s))
elif cnt == -1:
    s.reverse()
    print("".join(s))
### BUGGY CODE ###

from queue import Queue

H, W = map(int, input().split())
state = [[0 if a == '.' else 1 for a in list(input())] for _ in range(H)]

checked = [[False for _ in range(W)] for _ in range(H)]
l = 0
q = Queue()
for h in range(H):
    for w in range(W):
        if state[h][w] == 1:
            checked[h][w] = True
            q.put((h, w))
            l += 1

Next = [[[] for _ in range(W)] for _ in range(H)]
for h in range(H):
    for w in range(W):
        if h != 0:
            Next[h][w].append((h-1, w))
        if h != H-1:
            Next[h][w].append((h+1, w))
        if w != 0:
            Next[h][w].append((h, w-1))
        if w != W-1:
            Next[h][w].append((h, w+1))

c = -1
while True:
    nl = 0
    if q.empty():
        break
    for _ in range(l):
        (h, w) = q.get()
        for nh, nw in Next[h][w]:
            if not checked[nh][nw]:
                q.put((nh, nw))
                checked[nh][nw] = True
                nl += 1
    l = nl
    c += 1
print(c)

### FIXED CODE ###

import sys
input = sys.stdin.readline

B = int(1E8)

def main():

    H, W = map(int, input().split())
    
    l = 0
    q = []
    checked = []
    for h in range(H):
        S = input()
        L = []
        for w in range(W):
            if S[w] == '#':
                l += 1
                L.append(True)
                q.append(B*h+w)
            else:
                L.append(False)
        checked.append(L)

    Next = [[[] for _ in range(W)] for _ in range(H)]
    for h in range(H):
        for w in range(W):
            if h != 0:
                Next[h][w].append(B*(h-1) + w)
            if h != H-1:
                Next[h][w].append(B*(h+1) + w)
            if w != 0:
                Next[h][w].append(B*h + w-1)
            if w != W-1:
                Next[h][w].append(B*h + w+1)

    c = -1
    for _ in range(H+W+2):
        qq = []
        if len(q) == 0:
            break
        for hw in q:
            h, w = hw//B, hw%B
            for nhw in Next[h][w]:
                nh, nw = nhw//B, nhw%B
                if not checked[nh][nw]:
                    qq.append(B*nh + nw)
                    checked[nh][nw] = True
        q = qq
        c += 1

    print(c)


if __name__ == "__main__":
    main()
### BUGGY CODE ###

n, q = map(int, input().split())
s = input()
l, r = [0]*q, [0]*q
for i in range(q):
    l[i], r[i] = map(int, input().split())
    print(s[l[i]-1:r[i]].count("AC"))

### FIXED CODE ###

n, q = map(int, input().split())
s = input()
count = [0]*(n+1)
for i in range(1, n):
    count[i] += count[i-1]
    if s[i-1:i+1] == "AC":
      count[i] += 1
for i in range(q):
    l, r = map(int, input().split())
    print(count[r-1] - count[l-1])
### BUGGY CODE ###

N = int(input())
s = [input() for i in range(N)]

s_sorted = list(map(''.join, list(map(sorted, s))))

cnt = 0
while(s_sorted):
    k = s_sorted.pop(0)
    tmp_key = [i for i, x in enumerate(s_sorted) if x == k]
    cnt += sum(range(len(tmp_key) + 1))
    while(tmp_key):
        k = s_sorted.pop(tmp_key.pop())

print(cnt)

### FIXED CODE ###

N = int(input())
s = [input() for i in range(N)]

s_sorted = list(map(''.join, list(map(sorted, s))))

s_dict = dict()
for k in s_sorted:
    if k in s_dict:
        s_dict[k] += 1
    else:
        s_dict[k] = 1

cnt = 0
for k in s_dict:
    cnt += sum(range(s_dict[k]))

print(cnt)
### BUGGY CODE ###

N, K = map(int, input().split())
A = list(map(int, input().split()))
A_unique = list(set(A))
A_list = []
if len(A_unique) <= K:
    print(0)
    exit()
else:
    del_num = len(A_unique) - K
    for i in A_unique:
        A_list.append(A.count(i))
    A_list.sort()
    print(sum(A_list[:del_num]))

### FIXED CODE ###

import sys
input = sys.stdin.readline
from collections import Counter


N, K = map(int, input().split())
A = list(map(int, input().split()))
A_count = Counter(A)
A_unique = list(set(A))
A_list = []
if len(A_unique) <= K:
    print(0)
    exit()
else:
    del_num = len(A_unique) - K
    for i in A_unique:
        A_list.append(A_count[i])
    A_list.sort()
    print(sum(A_list[:del_num]))
### BUGGY CODE ###

import collections
N = int(input())
A = sorted([int(i) for i in input().split()])
C = collections.Counter(A)
tested = [True for i in range(10**7+1)]

ans = 0
for i in range(N):
    if C[A[i]] == 1 and tested[A[i]] is True:
        ans += 1

    for j in range(A[i], 10**6+1, A[i]):
        tested[j] = False
print(ans)


### FIXED CODE ###

import collections
N = int(input())
A = sorted([int(i) for i in input().split()])
maxA = A[-1]

if N == 1:
    print(1)
    exit()

C = collections.Counter(A)
cand = set(A)

ans = 0
for i in range(N):
    if C[A[i]] >= 2:
        cand -= set([A[i]*j for j in range(1, maxA//A[i]+1)])
        continue

    if A[i] in cand:
        ans += 1
        cand -= set([A[i]*j for j in range(1, maxA//A[i]+1)])
print(ans)
### BUGGY CODE ###

n, k = map(int, input().split())
a_sort = sorted([int(i) for i in input().split()])

Min = 0
Max = 0

def SUM(a):
    count = 0
    comb = 1
    for i, num in enumerate(a_sort):
        if i == k-1:
            count += num
        elif i > k-1:
            comb = comb * i // (i-k+1)
            count = (count + (comb * num)) % (10**9+7)
    return int(count)

Max = SUM(a_sort)
Min = SUM(a_sort.reverse())

print((Max - Min + (10**9+7)) % (10**9+7))

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
 
class Combination():
    # コンストラクタ
    def __init__(self, N:int, P:int):
        self.N = N
        self.P = P
 
        # fact[i] = (i! mod P)
        self.fact = [1, 1]   
        # factinv[i] = ((i!)^(-1) mod P)
        self.factinv = [1, 1]
        # factinv 計算用
        self.inv = [0, 1]    
 
        for i in range(2, N+1):
            self.fact.append((self.fact[-1] * i) % P)
            self.inv.append((-self.inv[P % i] * (P // i)) % P)
            self.factinv.append((self.factinv[-1] * self.inv[-1]) % P)
    
    # nCk (mod P)   (ただし、n<=N)
    def getComb(self, n:int, k:int):
        if (k < 0) or (n < k):
            return 0
        k = min(k, n - k)
        return self.fact[n] * self.factinv[k] * self.factinv[n-k] % self.P
 
def main():
    N,K = map(int,input().split())
    A = sorted([int(i) for i in input().split()])
 
    mod = 10**9+7
 
    COMB = Combination(N,mod)
 
    cmb = [0] * (N-K+1)
    for i in range(N-K+1):
        cmb[i] = COMB.getComb(i+(K-1),K-1)
 
    sum_max = 0
    for i in range(K-1,N):
        sum_max = (sum_max + cmb[i-(K-1)] * A[i]) % mod
 
    sum_min = 0
    for i in range(N-K,-1,-1):
        sum_min = (sum_min + cmb[(N-K)-i] * A[i]) % mod
 
    answer = sum_max - sum_min
    print(answer % mod)
 
if __name__ == "__main__":
    main()
### BUGGY CODE ###

N=int(input())
TA=[list(map(int, input().split())) for _ in range(N)]
ls=[[TA[0][0],TA[0][1]]]
for i in range(1,N):
    tmp=[TA[i][0],TA[i][1]]
    j=2
    while 1:
        if tmp[0]>=ls[-1][0] and tmp[1]>=ls[-1][1]:
            break
        tmp[0]=TA[i][0]*j
        tmp[1]=TA[i][1]*j
        j+=1
    ls.append([tmp[0],tmp[1]])
print(ls[-1][0]+ls[-1][1])


### FIXED CODE ###

N=int(input())
TA=[list(map(int, input().split())) for _ in range(N)]
ls=[[TA[0][0],TA[0][1]]]
for i in range(1,N):
    tmp=[TA[i][0],TA[i][1]]
    a=max(-(ls[-1][0]//(-tmp[0])),-(ls[-1][1]//(-tmp[1])))
    tmp[0]*=a
    tmp[1]*=a
    ls.append([tmp[0],tmp[1]])
print(ls[-1][0]+ls[-1][1])
### BUGGY CODE ###

import collections
import itertools

N = int(input())
s_list = []
for i in range(N):
    s_list.append(input())

s_list.sort()
l = []
for s in s_list:
    l2 = []
    for i in range(len(s)):
        l2.append(s[i])
    l.append(l2)
    
for i in l:
    i.sort()

l3 = []
for i in l:
    s = ""
    for j in i:
        s += j
    l3.append(s)
    
C = collections.Counter(l3)
ans = 0
for i in C:
    ans += len(list(itertools.combinations(range(C[i]), 2)))
print(ans)

### FIXED CODE ###

import collections
import itertools
ans = 0

N = int(input())
s_list = []
for i in range(N):
    s_list.append(input())

d = {}
for s in s_list:
    l2 = []
    for i in range(len(s)):
        l2.append(s[i])
    l2.sort()
    a = ""
    for i in l2:
        a += i
    if a in d:
        ans+=d[a]
        d[a]+=1
    else:
        d[a] = 1

print(ans)
### BUGGY CODE ###

import sys
from sys import stdin
input = sys.stdin.readline
X, Y, A, B, C = (int(i) for i in input().split())
p = [[int(x), "A"] for x in stdin.readline().rstrip().split()]
q = [[int(x), "B"]  for x in stdin.readline().rstrip().split()]
r = [[int(x), "C"] for x in stdin.readline().rstrip().split()]
#A = [[int(i) for i in input().split()] for i in range(N)]
apples = p+q+r

apples.sort(reverse=True)
#print(apples)
ans = 0
pend = 0

while (X > 0 or Y > 0) and X+Y > pend:
    if apples[0][1] == "C":
        pend += 1
        ans += apples[0][0]
        apples.pop(0)
    elif apples[0][1] == "A":
        if X > 0:
            ans += apples[0][0]
            apples.pop(0)
            X -= 1
        else:
            apples.pop(0)
    elif apples[0][1] == "B":
        if Y>0:
            ans += apples[0][0]
            apples.pop(0)
            Y -= 1
        else:
            apples.pop(0)
    #print(ans)
    #print("XY", X, Y, pend)
#print("XY", X, Y, pend)
print(ans)


### FIXED CODE ###

import sys
input = sys.stdin.readline
X, Y, A, B, C = (int(i) for i in input().split())
p = [[int(x), "A"] for x in input().split()]
q = [[int(x), "B"] for x in input().split()]
r = [[int(x), "C"] for x in input().split()]
#A = [[int(i) for i in input().split()] for i in range(N)]
apples = p+q+r


apples.sort(reverse=True)
#print(apples)
ans = 0
pend = 0


for hapi, col in apples:
    if col == "C":
        pend += 1
        ans += hapi
    elif col == "A":
        if X > 0:
            ans += hapi
            X -= 1

    elif col == "B":
        if Y>0:
            ans += hapi
            Y -= 1

    if (X < 1 and Y < 1) or X+Y == pend:
        break
    #print(ans)
    #print("XY", X, Y, pend)
#print("XY", X, Y, pend)
print(ans)
### BUGGY CODE ###

import itertools 
from collections import defaultdict
d=defaultdict(int)
def take_solve(take):
    key=str(take)
    if key in d.keys():
        return d[key]
    result=float("inf")
    for x,y,z in itertools.permutations(take):
        result=min(result,abs(x-a)+abs(y-b)+abs(z-c))
    d[key]=result
    return result

n,a,b,c=[int(x) for x in input().split()]
l=[]
for _ in range(n):
    l.append(int(input()))

def ans(takes):
    takes=sorted(takes)
    key=str(takes)
    if key in d.keys():
        return d[key]
    m=len(takes)
    result=float("inf")
    if m==3:
        result=min(result,take_solve(takes)+10*(n-m))
    else:
        for i,j in itertools.combinations(list(range(m)),2):
            next_take=[takes[x] for x in range(m) if not x in (i,j)]
            next_take.append(takes[i]+takes[j])
            result=min(result,ans(next_take))
        for i,j,k in itertools.combinations(list(range(m)),3):
            result=min(result,take_solve((takes[i],takes[j],takes[k]))+10*(n-m))
    d[key]=result
    return result
print(ans(l))

### FIXED CODE ###

import itertools 
def take_solve(take):
    result=float("inf")
    for x,y,z in itertools.permutations(take):
        result=min(result,abs(x-a)+abs(y-b)+abs(z-c))
    return result

n,a,b,c=[int(x) for x in input().split()]
l=[]
for _ in range(n):
    l.append(int(input()))
from collections import defaultdict
d=defaultdict(int)
def ans(takes):
    takes=sorted(takes)
    key=str(takes)
    if key in d.keys():
        return d[key]
    m=len(takes)
    result=float("inf")
    if m==3:
        result=min(result,take_solve(takes)+10*(n-m))
    else:
        for i,j in itertools.combinations(list(range(m)),2):
            next_take=[takes[x] for x in range(m) if not x in (i,j)]
            next_take.append(takes[i]+takes[j])
            result=min(result,ans(next_take))
        for i,j,k in itertools.combinations(list(range(m)),3):
            result=min(result,take_solve((takes[i],takes[j],takes[k]))+10*(n-m))
    d[key]=result
    return result
print(ans(l))
### BUGGY CODE ###

N = int(input())
S = list(input())
ans = 10 ** 9
for i in range(N + 1):
  ans = min(ans,S[:i].count("#") + S[i:].count("."))
print(ans)  

### FIXED CODE ###

from collections import Counter
N = int(input())
S = list(input())
ans = 10 ** 9
hash = [0] * (N + 1)
memo = 0
for i in range(N):
  if S[i] == "#":
    memo += 1
  hash[i + 1] = memo
dot = [0] * (N + 1)
memo = 0
for i in range(N - 1,-1,-1):
  if S[i] == ".":
    memo += 1
  dot[i] = memo    
for i in range(N + 1):
  ans = min(ans, hash[i] + dot[i])
print(ans)
### BUGGY CODE ###

def main():
    n = int(input())
    a_list = list(map(int, input().split()))
    ans = 0

    for i in range(n - 1):
        for j in range(i + 1, n):
            ans += a_list[i] * a_list[j] % (10 ** 9 + 7)

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


if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    n = int(input())
    a_list = list(map(int, input().split()))

    sum_list = [0 for _ in range(n)]
    sum_list[0] = sum(a_list)
    ans = 0

    for i in range(1, n):
        sum_list[i] = sum_list[i - 1] - a_list[i - 1]

    for i in range(n - 1):
        ans += a_list[i] * sum_list[i + 1] % (10 ** 9 + 7)

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


if __name__ == "__main__":
    main()
### BUGGY CODE ###

import itertools
n=int(input())
s=input()
k=list(set(s))

d = {i: s.count(i) for i in k}



counta=0

for i in range(1,len(k)+1):
    li=list(itertools.combinations(k,i))

    
    for h in li:
        q=1
        for l in h:
            q*=d[l]
     
        counta+=q
    
print(counta%(10**9+7))

### FIXED CODE ###

n=int(input())
s=input()
k=list(set(s))
d = {i: s.count(i) for i in k}
counta=0

for i in k:
    counta=counta*d[i]+d[i]+counta


print(counta%(10**9+7))
### BUGGY CODE ###

N = int(input())
A= list(map(int,input().split()))
A.sort(reverse=True)
top = A[0]
if N == 2:
  B=[top]
else:
  B=[top]

c=0
  
for i in range(1,N):
  if i == 1:
    ma = top
    tekito=1
  else:
    ma = min(B[0],B[1])
  mai = 1
  for j in range(1,len(B)):
    if j == len(B)-1:
      tekito = 0
    else:
      tekito = j+1
    #print(tekito)
    koho = min(B[j],B[tekito])
    if ma > koho:
      ma =koho
      mai = tekito
  c+= ma
  B.insert(tekito, A[i])
      
#c=0
#d= len(B)
#for i in range(d):
#  if i == 1:
#    continue
#  if i != d-1:
#    c+= min(B[i-1],B[i+1])
#  else:
#    c+= min(B[i-1],B[0])
#print(B)
print(c)



### FIXED CODE ###

import math
n = int(input())
a = list(map(int, input().split()))
b = sorted(a)
ans = 0
for i in range(n-1):
  ans += b[n-1-(math.ceil(i/2))]
print(ans)
### BUGGY CODE ###

h,a,*m=open(0)
h,w,k,a,b,f,g=map(int,(h+a).split())
d=[I:=9**9]*h*w
d[~w+a*w+b]=1
q=[(a-1,b-1)]
for s,t in q:
 p=d[s*w+t]+1
 for y,x in(-1,0),(0,-1),(0,1),(1,0):
  for z in range(k):
   if(h>(i:=s+y*~z)>-1<(j:=t+x*~z)<w)-1or'.'<m[i][j]or d[i*w+j]<p:break
   q+=(i,j),;d[i*w+j]=p
print(d[~w+f*w+g]%I-1)

### FIXED CODE ###

I=9**9
h,a,*m=open(0)
h,w,k,a,b,f,g=map(int,(h+a).split())
d=[I]*h*w
a=~w+a*w+b
d[a]=1
q=[a]
for s in q:
 for y,x in(1,0),(-1,0),(0,1),(0,-1):
  for z in range(k):
   i,j=s//w+y*~z,s%w+x*~z;t=i*w+j
   if(h>i>-1<j<w)-1or'.'<m[i][j]or d[t]<=d[s]:break
   if d[t]==I:q+=t,;d[t]=d[s]+1
print(d[~w+f*w+g]%I-1)
### BUGGY CODE ###

a,b,c,d = map(int,input().split())
count = 0
for i in range(a,b + 1):
    if(i % c != 0 and i % d != 2):
        count += 1

print(count)

### FIXED CODE ###

def gcd(c, d):
    if (d == 0): return c
    else: return gcd(d, c % d)

def f(n, c, d):
    return n - (n // c + n // d - n // (c * d // gcd(c, d)))

def main():
    a,b,c,d = map(int, input().split())
    print (f(b, c, d) - f(a - 1, c, d))

if __name__ == "__main__":
    main()
### BUGGY CODE ###

n = int(input())
h = list(map(int,input().split()))

max_ctn = 0
for i in range(n):
    tmp_ctn = 0
    for j in range(i,len(h)-1):
        if h[j] >= h[j+1]:
            tmp_ctn += 1
            continue
        i = j
        break
    if max_ctn < tmp_ctn:
        max_ctn = tmp_ctn
print(max_ctn)

### FIXED CODE ###

n = int(input())
h = list(map(int,input().split()))

max_ctn = 0
start = 0
for i in range(0,n):
    tmp_ctn = 0
    i +=start
    for j in range(i,len(h)-1):
        if h[j] >= h[j+1]:
            tmp_ctn += 1
            start +=1
            continue
        break
    if max_ctn < tmp_ctn:
        max_ctn = tmp_ctn
print(max_ctn)
### BUGGY CODE ###

S = int(input())
listS = list(str(S))
l = len(listS)
dp = int(listS[-1])
suml = [dp]
mod = [0]
for i in range(l-1):
    dp = dp + (10**(i+1))*int(listS[-2-i])
    suml.append(dp)
for a in suml:
    mod.append(a % 2019)
cnt = 0
for i in range(2019):
    if mod.count(i) > 1:
        cnt += ((mod.count(i))*(mod.count(i)-1))//2
print(cnt)

### FIXED CODE ###

S = str(input())
l = len(S)
mod = [0] * 2019
dp = 0
pw = 1
for i in range(l):
    mod[dp % 2019] += 1
    dp = dp + pw * int(S[-1-i])
    pw = (pw * 10) % 2019
mod[dp % 2019] += 1
cnt = 0
for i in range(2019):
    cnt += (mod[i]*(mod[i]-1))//2
print(cnt)
### BUGGY CODE ###

n= int(input())
card = input().split(' ')
card = [int(s) for s in card]
min_s = 1000000000000
for i in range(n -1):
    if abs(sum(card[:i+1]) - sum(card[i+1:])) < min_s:
        min_s= abs(sum(card[:i+1]) - sum(card[i+1:]))
    
print(min_s)

### FIXED CODE ###

n= int(input())
card = input().split(' ')
card = [int(s) for s in card]
min_s = 20000000000
sum1 = sum(card[:1])
sum2 = sum(card[1:])
for i in range(n - 1):
    dif  = abs(sum1-sum2)

    if dif  < min_s:
        min_s = dif
    sum1 += card[i+1]
    sum2 = sum2 - card[i+1]
print(min_s)
### BUGGY CODE ###

import bisect as bs

n,x,y = map(int,input().split())
x -= 1
y -= 1

array = [[-1 for i in range(n)] for j in range(n)]

for i in range(n):
  for j in range(n):
    array[i][j] = abs(j-i)
    
for i in range(n):
  if array[i][x] == array[i][y]:
    pass
  
  elif array[i][x] > array[i][y]:
    array[i][x] = array[i][y] + 1
    
    index = x - 1
    while True:
      if index < 0 or array[i][index] <= array[i][index+1]:
        break
        
      array[i][index] = array[i][index+1] + 1
      index -= 1
      
    index = x + 1
    while True:
      if index >= n or array[i][index] <= array[i][index-1]:
        break
        
      array[i][index] = array[i][index-1] + 1
      index += 1
      
  else:
    array[i][y] = array[i][x] + 1
    
    index = y - 1
    while True:
      if index < 0 or array[i][index] <= array[i][index+1]:
        break
        
      array[i][index] = array[i][index+1] + 1
      index -= 1
      
    index = y + 1
    while True:
      if index >= n or array[i][index] <= array[i][index-1]:
        break
        
      array[i][index] = array[i][index-1] + 1
      index += 1
      
ans = [0] * (n+1)
for i in range(n):
  for j in range(i, n):
    tmp = array[i][j]
    ans[tmp] += 1
    
for i in range(1,n):
  print(ans[i])
  

### FIXED CODE ###

n,x,y = map(int,input().split())
x -= 1
y -= 1

array1 = [0] * n
array2 = [0] * n

for i in range(x, y+1):
  array1[i] = min(i-x, y-i+1)
  array2[i] = min(i-x+1, y-i)

ans = [0] * (n+1)
dis = [[0 for i in range(n)] for i in range(n)]


for i in range(n):
  if i <= x:
    for j in range(i+1,n):
      if y <= j:
        tmp = (x-i) + (j-y) + 1
      elif j <= x:
        tmp = j-i
      else:
        tmp = (x-i) + array1[j]
        
      ans[tmp] += 1
      dis[i][j] = tmp
      
  elif y <= i:
    for j in range(i+1,n):
      ans[j-i] += 1
      dis[i][j] = j-i
      
  else:
    for j in range(i+1,n):
      if y <= j:
        tmp = (j-y) + array2[i]
      else:
        tmp = min(j-i, (y-x+1)-(j-i))
        
      ans[tmp] += 1
      dis[i][j] = tmp

for i in range(1,n):
  print(ans[i])