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

n = int(input())
ss = input()
li1 = []
li2 = []
ans = 0
for i in range(n-2):
    f = ss[i]
    for j in range(i+1,n-1):
        s = ss[j]
        if f+s in li1:
            continue
        li1.append(f+s)
        li2 = []
        for k in range(j+1,n):
            if len(li2) == 10:
                break
            t = ss[k]
            if t in li2:
                continue
            ans += 1
            li2.append(t)
print(ans)

### FIXED CODE ###

n = int(input())
ss = input()
li = []
li1 = []
li2 = []
ans = 0
for i in range(n-2):
    f = ss[i]
    if f in li:
        continue
    li.append(f)
    for j in range(i+1,n-1):
        s = ss[j]
        if f+s in li1:
            continue
        li1.append(f+s)
        li2 = []
        for k in range(j+1,n):
            if len(li2) == 10:
                break
            t = ss[k]
            if t in li2:
                continue
            ans += 1
            li2.append(t)
print(ans)
### BUGGY CODE ###

import collections

n, l, q = map(int, input().split())
a = [input() for _ in range(q)]

for i in range(n):
    if collections.Counter(a)[str(i+1)] > q-l:
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

import collections

n, l, q = map(int, input().split())
a = [input() for _ in range(q)]
c = collections.Counter(a)

for i in range(n):
    if c[str(i+1)] > q-l:
        print("Yes")
    else:
        print("No")
### BUGGY CODE ###

import math
(r, p)=[int(n) for n in input().split()]
route_list=[[0 for j in range(r)] for i in range(r)]
for i in range(p):
  (x, y)=[int(n)-1 for n in input().split()]
  route_list[x][y] = 1
  route_list[y][x] = 1 

node_num = len(route_list)

unsearched_nodes = list(range(node_num))
distance = [math.inf] * node_num
previous_nodes = [-1] * node_num
distance[0] = 0

def initial():
  unsearched_nodes = list(range(node_num))
  distance = [math.inf] * node_num
  previous_nodes = [-1] * node_num
  distance[0] = 0

def get_target_min_index(min_index, distance, unsearched_nodes):
    start = 0
    while True:
        index = distance.index(min_index, start)
        found = index in unsearched_nodes
        if found:
            return index
        else:
            start = index + 1

while(len(unsearched_nodes) != 0):
    posible_min_distance = math.inf
    for node_index in unsearched_nodes:
        if posible_min_distance > distance[node_index]: 
            posible_min_distance = distance[node_index]
    target_min_index = get_target_min_index(posible_min_distance, distance, unsearched_nodes)
    unsearched_nodes.remove(target_min_index)

    target_edge = route_list[target_min_index]
    for index, route_dis in enumerate(target_edge):
        if route_dis != 0:
            if distance[index] > (distance[ target_min_index] + route_dis):
                distance[index] = distance[ target_min_index] + route_dis
                previous_nodes[index] =  target_min_index

ans=[-1]*(r-1)
for i in range(1, r):
  if ans[i-1] != -1:
    continue
  previous_node = i
  string=""
  while previous_node != -1:
    if previous_node !=0:
        string += str(previous_node + 1) + " "
    else:
        string += str(previous_node + 1)
    previous_node = previous_nodes[previous_node]
  string = string.split()
  for i, v in enumerate(string[:-1]):
    ans[int(v)-2]=string[i+1]

if "No" in ans:
  print("No")
else:
  print("Yes")
  for i in ans:
    print(i)


### FIXED CODE ###

(r, p)=[int(n) for n in input().split()]
route_list=[[] for i in range(r)]
for i in range(p):
  (x, y)=[int(n)-1 for n in input().split()]
  route_list[x].append(y)
  route_list[y].append(x)

upstair=[0]
ans=[-1]*r
while upstair:
  tmp=[]
  for i in upstair:
    for j in route_list[i]:
      if ans[j] == -1:
        ans[j] = i + 1
        tmp.append(j)
  upstair=tmp

if -1 in ans:
  print("No")
else:
  print("Yes")
  for i in ans[1:]:
    print(i)
### BUGGY CODE ###

'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n = int(ipt())
    a = [int(i) for i in ipt().split()]
    sa = [0,a[0]]
    for i in a[1::]:
        sa.append(sa[-1]+i)

    mi = 10**18
    ll = 1
    rr = 3
    for ci in range(2,n-1):
        ls = sa[ci]
        rs = sa[-1]
        nms = []
        pld = 10**18
        for l in range(ll,ci):
            al = sa[l]
            d = abs(ls-2*al)
            if pld > d:
                pld = d
                sl = (al,ls-al)
            else:
                ll = l-1
                break
        nms.append(sl[0])
        nms.append(sl[1])
        pld = 10**18
        for r in range(rr,n):
            ar = sa[r]
            d = abs(rs+ls-2*ar)
            if pld > d:
                pld = d
                sl = (rs-ar,ar-ls)
            else:
                rr = r-1
                break
        nms.append(sl[0])
        nms.append(sl[1])
        d = max(nms)-min(nms)
        if mi > d:
            mi = d

    print(mi)


    return None

if __name__ == '__main__':
    main()


### FIXED CODE ###

'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n = int(ipt())
    a = [int(i) for i in ipt().split()]
    sa = [0,a[0]]
    for i in a[1::]:
        sa.append(sa[-1]+i)

    mi = 10**18
    ll = 1
    rr = 3
    for ci in range(2,n-1):
        ls = sa[ci]
        rs = sa[-1]
        nms = []
        pld = 10**18
        for l in range(ll,ci):
            al = sa[l]
            d = abs(ls-2*al)
            if pld > d:
                pld = d
                sl = (al,ls-al)
                if l == ci:
                    ll = ci-1
            else:
                ll = l-1
                break
        nms.append(sl[0])
        nms.append(sl[1])
        pld = 10**18
        for r in range(rr,n):
            ar = sa[r]
            d = abs(rs+ls-2*ar)
            if pld > d:
                pld = d
                sl = (rs-ar,ar-ls)
                if r == n-1:
                    rr = n-1
            else:
                rr = r-1
                break
        nms.append(sl[0])
        nms.append(sl[1])
        d = max(nms)-min(nms)
        if mi > d:
            mi = d

    print(mi)


    return None

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

import sys
sys.setrecursionlimit(10 ** 7)

H, W = map(int, input().split())
A = []
for _ in range(H):
    A.append(input())

import queue
todo = queue.Queue()
seen = [[False] * W for _ in range(H)]
route= [[0] * W for _ in range(H)]
for y in range(H):
    for x in range(W):
        if A[y][x] == '#':
            todo.put((x, y))
            seen[y][x] = True


seen = [[False] * W for _ in range(H)]
route= [[0] * W for _ in range(H)]

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
def bfs(el):
    x, y = el
    #print(x, y)
    for i in range(4):
        if 0 <= x + dx[i] < W and 0 <= y + dy[i] < H:
            if seen[y + dy[i]][x + dx[i]] == False:
                route[y + dy[i]][x + dx[i]] = route[y][x] + 1
                seen[y + dy[i]][x + dx[i]] = True
                todo.put((x + dx[i], y + dy[i]))
    if not todo.empty():
        bfs(todo.get())
    else:
        return None
bfs(todo.get())
#print(seen)
#print(route)

M = 0
for y in range(W):
    for x in range(H):
        M = max(M, route[y][x])
print(M)

### FIXED CODE ###

from collections import deque

h,w = map(int,input().split())
matrix = [["a" for _ in range(w+2)]] + [list("a" + input() + "a") for _ in range(h)] + [["a" for _ in range(w+2)]]

matrix_list1 = deque()
cnt = 0

#黒いタイルの位置情報を確認
for i in range(1,h+1):
    for j in range(1,w+1):
        if matrix[i][j] == "#":
            matrix_list1.append([i,j])

#白いタイルが無くなるまで、黒いタイルを増やす
while len(matrix_list1) != 0:     
    for _ in range(len(matrix_list1)):
        x,y = matrix_list1.popleft()
        if matrix[x+1][y] == ".":
            matrix[x+1][y] = "#"
            matrix_list1.append([x+1,y])
        if matrix[x-1][y] == ".":
            matrix[x-1][y] = "#"
            matrix_list1.append([x-1,y])
        if matrix[x][y+1] == ".":
            matrix[x][y+1] = "#"
            matrix_list1.append([x,y+1])
        if matrix[x][y-1] == ".":
            matrix[x][y-1] = "#"
            matrix_list1.append([x,y-1])
    else:
        if len(matrix_list1) > 0:
            cnt += 1
    
print(cnt)
### BUGGY CODE ###

# https://atcoder.jp/contests/abc084/tasks/abc084_d

Nmax = 10**6 //2 + 1

def prime_test(n):
    i = 2
    while i*i<=n:
        if n%i:
            i += 1
        else:
            return False
    if n == 1:
        return False
    return True

cum = [0]*(Nmax+1)

for n in range(Nmax):
    m = 2*n + 1
    if prime_test(m) and prime_test((m + 1)/2):
        cum[n] = cum[n-1] + 1
    else:
        cum[n] = cum[n-1]

Q = int(input())
for _ in range(Q):
    l, r = map(int, input().split())
    print(cum[r//2] - cum[l//2-1])

### FIXED CODE ###

# https://atcoder.jp/contests/abc084/tasks/abc084_d

Nmax = 10**5 + 1

def prime_test(n):
    if n == 1:
        return False
    i = 2
    while i*i<=n:
        if n%i:
            i += 1
        else:
            return False
    return True

cum = [0]*Nmax

for n in range(1,Nmax,2):
    cum[n] = cum[n-2] + (prime_test(n) and prime_test((n + 1)/2))

Q = int(input())
for _ in range(Q):
    l, r = map(int, input().split())
    print(cum[r] - cum[l-2])
### BUGGY CODE ###

n = int(input())
i = 1
ret = ""
while True:
    x = i
    if  x % 3 == 0:
        ret == " " + str(i)
        i+=1
        if i > n:
            print(ret)
            break
    if x % 10 == 3:
        ret == " " + str(i)
        i+=1
        if i > n:
            print(ret)
            break
    else:
        x /= 10
        if x != 0:
            if x % 10 == 3:
                ret == " " + str(i)
                i+=1
                if i > n:
                    print(ret)
                    break


### FIXED CODE ###

#
# 5d
#

def main():
    n = int(input())
    s = ""
    for i in range(1, n+1):
        x = i
        if x % 3 == 0 or x % 10 == 3:
            s += " " + str(i)
        else:
            x //= 10
            while x:
                if x % 10 == 3:
                    s += " " + str(i)
                    break
                x //= 10
    print(s)


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

import sys
input = sys.stdin.readline
H, K = map(int, input().split())
lst_0=list(map(int,input().split()))
DP=[float("INF")]*H
DP[0]=0
lst_2=[]
for i in range(1,H):
    lst_1=[]
    for j in range(1,K+1):
        if i - j >= 0:
            DP[i]=abs(lst_0[i]-lst_0[i-j])+DP[i-j]
            lst_1.append(DP[i])
    DP[i]=min(lst_1)
print(DP[-1])

### FIXED CODE ###

import sys
input = sys.stdin.readline
H, K = map(int, input().split())
lst_0=list(map(int,input().split()))
DP=[float("INF")]*H
DP[0]=0
for i in range(1,H):
    for j in range(1,K+1):
        if i - j >= 0:
            DP[i]=min(DP[i],abs(lst_0[i]-lst_0[i-j])+DP[i-j])
print(DP[H-1])
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
MOD = 1000000007
ans = 0

for i in range(N):
  for j in range(N-i-1):
    ans = (ans + A[i] * A[j+i+1]) % MOD

print(ans)


### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
MOD = 1000000007
x = sum(A)
ans = 0
 
for i in range(N):
  x -= A[i]
  y = x % MOD
  z = (A[i] * y) % MOD
  ans += z
  ans %= MOD

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

from itertools import product
D, G = map(int, input().split())
p = []
c = []
for _ in range(D):
    pc = list(map(int, input().split()))
    p.append(pc[0])
    c.append(pc[1])

def acceptable_point(pnums):
    point = 0
    for i, pnum in enumerate(pnums):
        point += (i + 1) * 100 * pnum
        if pnum == p[i]:
            point += c[i]
    return point >= G

result = min(
    map(sum,
        filter(acceptable_point,
            product(*map(range, [pp + 1 for pp in p]))
        )
    )
)
print(result)

### FIXED CODE ###

import functools
D, G = map(int, input().split())
G = G // 100
sumn = 0
ns = [0] * (D + 1)
cs = [0] * (D + 1)
for i in range(1, D + 1):
    n, c = map(int, input().split())
    ns[i] = n
    cs[i] = c // 100
    sumn += n

minn = [0] * (D + 1)
for i in range(1, D + 1):
    minn[i] = min(ns[1:i+1])

@functools.lru_cache(maxsize=None)
def f(i, rn):
    if i == 1:
        if ns[1] < rn:
            return -1
        p = rn
        if ns[1] == rn:
            p += cs[1]
        return p
    if rn < minn[i]:
        p = 0
        for j in range(i, 0, -1):
            n = min((ns[j], rn))
            p += j * n
            if n == rn:
                break
            rn -= n
        return p
    maxp = 0
    for n in range(min((ns[i], rn)) + 1):
        p = i * n
        if n == ns[i]:
            p += cs[i]
        np = f(i - 1, rn - n)
        if np >= 0:
            p += np
            if maxp < p:
                maxp = p
    return maxp

mn = 1
mx = sumn
while mn < mx:
    x = mn + ((mx - mn) // 2)
    if G <= f(D, x):
        mx = x
    else:
        mn = x + 1
print(mn)
### BUGGY CODE ###

import math
a,b,n = map(int,input().split())
c = 0
for i in range(1,n+1):
    if c == (math.floor(a*i/b)-a*math.floor(i/b)):
        continue
    elif c < (math.floor(a*i/b)-a*math.floor(i/b)):
        c = (math.floor(a*i/b)-a*math.floor(i/b))
    elif c > 0 and c > (math.floor(a*i/b)-a*math.floor(i/b)):
        print(c)
        exit()
print(c)

### FIXED CODE ###

import math
a,b,n = map(int,input().split())
x = min(b - 1, n)
ans = math.floor((a * x) / b) - a * (math.floor(x / b))
print(ans)
### BUGGY CODE ###

N, M = map(int, input().split())
P = [i for i in range(N)]
D = [0] * N

def par(a):
    if a == P[a]:
        return a
    p = par(P[a])
    d = D[P[a]]
    P[a] = p
    D[a] += d
    return p

def dist(a, b):
    pa = par(a)
    pb = par(b)
    if pa == pb:
        return D[b] - D[a]
    return 1 << 30

def unite(a, b, d):
    if par(a) == par(b):
        return
    D[P[b]] = D[a] + d - D[b]
    P[P[b]] = P[a]

for _ in range(M):
    l, r, d = map(int, input().split())
    l, r = l-1, r-1
    dd = dist(l, r)
    if dd == 1<<30:
        unite(l, r, d)
    else:
        if d != dd:
            print("No")
            break
else:
    print("Yes")

### FIXED CODE ###

N, M = map(int, input().split())
P = [i for i in range(N)]
D = [0] * N
C = [1] * N

def par(a):
    if a == P[a]:
        return a
    p = par(P[a])
    d = D[P[a]]
    P[a] = p
    D[a] += d
    return p

def dist(a, b):
    pa = par(a)
    pb = par(b)
    if pa == pb:
        return D[b] - D[a]
    return 1 << 30

def unite(a, b, d):
    if par(a) == par(b):
        return
    if C[P[a]] < C[P[b]]:
        a, b, d = b, a, -d
    C[P[a]] += C[P[b]]
    D[P[b]] = D[a] + d - D[b]
    P[P[b]] = P[a]

for _ in range(M):
    l, r, d = map(int, input().split())
    l, r = l-1, r-1
    dd = dist(l, r)
    if dd == 1<<30:
        unite(l, r, d)
    else:
        if d != dd:
            print("No")
            break
else:
    print("Yes")
### BUGGY CODE ###

import itertools
import sys
input = sys.stdin.readline
lis = []
N = int(input().rstrip())
for i in range(N):
  str = input().rstrip()
  counter = {}
  for c in str:
    if not c in counter:
        counter[c] = 1
    else:
        counter[c] += 1
  lis.append(counter)
count = 0
for i in range(N):
  for j in range(i+1, N):
    if lis[i] == lis[j]:
      count += 1
print(count)

### FIXED CODE ###

import sys
input = sys.stdin.readline
lis = {}
counter = 0
N = int(input().rstrip())
for i in range(N):
  str = "".join(sorted(list(input().rstrip())))
  if str in lis:
    lis[str] += 1
    counter += lis[str]
  else:
    lis[str] = 0
print(counter)
### BUGGY CODE ###

import re
N, Q = map(int,input().split())
S = input()
for _ in range(Q):
    l, r = map(int,input().split())
    res = re.findall("AC",S[l-1:r])
    print(0 if len(res)==0 else len(res))

### FIXED CODE ###

N, Q = map(int,input().split())
S = input()
memo = [0 for _ in [0]*(N+1)]
for i in range(2,N+1):
    memo[i] = memo[i-1] + int(S[i-2:i]=="AC")
for _ in range(Q):
    l, r = map(int,input().split())
    print(memo[r]-memo[l])
### BUGGY CODE ###

n, k, *a = map(int, open(0).read().split())

for _ in range(k):
    b = [0] * -~n
    for i in range(len(a)):
        b[max(0, i - a[i])] += 1
        b[min(n, i + a[i] + 1)] -= 1
    for i in range(n):
        b[i + 1] += b[i]

    if all(x == n for x in b[:n]):
        print(' '.join(map(str, b[:n])))
        exit()
    a = b
print(' '.join(map(str, a[:n])))


### FIXED CODE ###

n, k, *a = map(int, open(0).read().split())

for _ in range(k):
    b = [0] * -~n
    for i in range(len(a)):
        b[max(0, i - a[i])] += 1
        b[min(n, i + a[i] + 1)] -= 1
    for i in range(n):
        b[i + 1] += b[i]

    if all(x == n for x in b[:n]):
        print(' '.join(map(str, b[:n])))
        exit()
    a = b
print(' '.join(map(str, a[:n])))
### BUGGY CODE ###

def main():
    N = int(input())
    A = list(map(int, input().split()))
    Q = int(input())
    B, C = [0]*Q, [0]*Q
    for i in range(Q):
        B[i], C[i] = map(int, input().split())

    ans = sum(A)
    d = dict()
    for i, a in enumerate(A):
        if a not in d:
            d[a] = ()
        d[a] += (i,)

    for b, c in zip(B, C):
        if b not in d:
            print(ans)
            continue
        elif len(d[b]) == 0:
            print(ans)
            continue
        ans += len(d[b]) * (c-b)
        if c not in d:
            d[c] = ()
        d[c] = d[c] + d[b]
        d[b] = ()
        print(ans)

main()

### FIXED CODE ###

def main():
    N = int(input())
    A = list(map(int, input().split()))
    Q = int(input())
    B, C = [0]*Q, [0]*Q
    for i in range(Q):
        B[i], C[i] = map(int, input().split())

    ans = sum(A)
    d = dict()
    for i, a in enumerate(A):
        d[a] = d.get(a, 0) + 1

    for b, c in zip(B, C):
        if b not in d:
            print(ans)
            continue
        ans += d[b] * (c-b)
        if c not in d:
            d[c] = 0
        d[c] = d[c] + d[b]
        d[b] = 0
        print(ans)

main()
### BUGGY CODE ###

k = int(input())

ans=0

for num in range(1,10**10):
    num_str=str(num)
    num_str=num_str[::-1]
    hantei=True

    if len(num_str)>1:
        for i in range(len(num_str)-1):
            if abs(int(num_str[i])-int(num_str[i+1]))>1:
                hantei=False
                break
    if hantei:
        ans+=1

        if k==ans:
            print(num)
            exit()

### FIXED CODE ###

k = int(input())

num=[1,2,3,4,5,6,7,8,9]

if k<10:
    print(num[k-1])
    exit()

ans=9

def hantei():
    global ans
    ans+=1
    if ans==k:
        print(num[-1])
        exit()

for i in range(10**10):

    hitoketa=num[0]%10

    if hitoketa==0:
        num.append(10*num[0]+0)
        hantei()
        num.append(10*num[0]+1)
        hantei()
        num.pop(0)

    elif hitoketa==9:
        num.append(10*num[0]+8)
        hantei()
        num.append(10*num[0]+9)
        hantei()
        num.pop(0)

    else:
        num.append(10*num[0]+(hitoketa-1))
        hantei()
        num.append(10*num[0]+(hitoketa))
        hantei()
        num.append(10*num[0]+(hitoketa+1))
        hantei()
        num.pop(0)
### BUGGY CODE ###

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

total = 0
for i, x in enumerate(A):
    for j, y in enumerate(A):
        if i == j:
            continue
        if x == y:
            total += 1
total = total // 2

for k, val in enumerate(A):
    count = 0
    for i, v in enumerate(A):
        if k == i:
            continue
        if val == v:
            count += 1
    print(total - count)

### FIXED CODE ###

from math import factorial

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

def comb(n, r):
    if n - r < 0:
        return 0
    else:
        return factorial(n) // (factorial(n - r) * factorial(r))

nums = [0] * (N + 1)
for i, v in enumerate(A):
    nums[v] += 1
combs = list(map(lambda n: comb(n, 2), nums))
total = sum(combs)

for k, val in enumerate(A):
    print(total - (nums[val] - 1))
### BUGGY CODE ###

from itertools import combinations_with_replacement, product, permutations, combinations

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

nmax = 0

for na in range(-1, N):
    for nb in range(-1, M):
        n = na + nb + 2
        time = sum([A[i] for i in range(na+1)]) + \
            sum([B[i] for i in range(nb+1)])
        if nmax < n and time <= K:
            nmax = n

print(nmax)
exit()


### FIXED CODE ###

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

nmax = 0

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 = 0
j = M
for i in range(N + 1):
    if a[i] > K:
        break

    while b[j] + a[i] > K:
        j -= 1
    ans = max(ans, i+j)

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

import collections
N = int(input())
X = int(input(), base=2)
memo = collections.defaultdict(int)
memo[0] = 0


def f(x):
    if x in memo:
        return memo[x]
    else:
        y = x % bin(x).count('1')
        ret = 1 + f(y)
        memo[x] = ret
        return ret


ans = []
for i in range(N - 1, -1, -1):
    ans += [f(X ^ (1 << i))]
print('\n'.join(map(str, ans)))


### FIXED CODE ###

import collections
memo = collections.defaultdict(int)
memo[0] = 0
memo[1] = 1


def f(x):
    if x in memo:
        return memo[x]
    else:
        y = x % bin(x).count('1')
        ret = 1 + f(y)
        memo[x] = ret
        return ret


N = int(input())
sX = input()
modX = sX.count('1')
if modX == 0:
    for _ in range(N):
        print(1)
elif modX == 1:
    sX = sX[::-1]
    for i, b in enumerate(sX):
        if b == '1':
            break
    #print(i)
    if i == 0:
        ans = [0] + [2] * (N - 1)
        ans = ans[::-1]
    else:
        ans = [1] * N
        ans[-1] = 2
        ans[-i - 1] = 0
    print('\n'.join(map(str, ans)))
else:
    modp = modX + 1
    modm = modX - 1
    sX = sX[::-1]
    Xmodp = 0
    Xmodm = 0
    for i, b in enumerate(sX):
        if b == '1':
            Xmodp += pow(2, i, modp)
            Xmodp %= modp
            Xmodm += pow(2, i, modm)
            Xmodm %= modm
    s = []
    for i, b in enumerate(sX):
        if b == '1':
            s += [(Xmodm - pow(2, i, modm)) % modm]
        else:
            s += [(Xmodp + pow(2, i, modp)) % modp]
    ans = []
    for k in s[::-1]:
        ans += [1 + f(k)]
    print('\n'.join(map(str, ans)))