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

k, s = map(int, input().split())
cnt = 0
for x in range(k + 1):
    for y in range(k + 1):
        for z in range(k + 1):
            if x + y + z == s:
                cnt += 1
            else:
                continue
print(cnt)

### FIXED CODE ###

k, s = map(int, input().split())
cnt = 0
for x in range(max(s - 2 * k, 0), k + 1):
    for y in range(max(s - x - k, 0), min(s - x + 1, k + 1)):
        z = s - x - y
        if 0 <= z <= k:
            cnt += 1
        else:
            continue
print(cnt)
### BUGGY CODE ###

n=int(input())
for num in range(1,n+1):
    ans=0
    for x in range(1,int(num**0.5)+1):
        for y in range(1, int(num**0.5)+1):
            for z in range(1,int(num**0.5)+1):
                if x**2+y**2+z**2+x*y+y*z+x*z==num:
                    ans+=1
    print(ans)

### FIXED CODE ###

n=int(input())
lis=[0]*(n+1)
for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            k=x**2+y**2+z**2+x*y+y*z+x*z
            if k<=n:
                lis[k]+=1
for i in range(1,n+1):
    print(lis[i])
### BUGGY CODE ###

import heapq
from collections import defaultdict

n, m, s, t = list(map(int, input().split()))

graph_y = [[] for i in range(n)]
graph_s = [[] for i in range(n)]

for i in range(m):
	u, v, a, b = list(map(int, input().split()))
	graph_y[u - 1].append([v - 1, a])
	graph_y[v - 1].append([u - 1, a])
	graph_s[u - 1].append([v - 1, b])
	graph_s[v - 1].append([u - 1, b])


dist_node_ys = [float("inf") for i in range(n)]
dist_node_ys[s - 1] = 0

Q = []
heapq.heappush(Q, (dist_node_ys[s - 1], s - 1))

while Q: 
	dis, v = heapq.heappop(Q)
	if dist_node_ys[v] < dis:
		continue
	for u, w in graph_y[v]:
		alt = dis + w
		if dist_node_ys[u] > alt:
			dist_node_ys[u] = alt
			heapq.heappush(Q, (alt, u))


dist_node_st = [float("inf") for i in range(n)]
dist_node_st[t - 1] = 0

Q = []
heapq.heappush(Q, (dist_node_st[t - 1], t - 1))

while Q: 
	dis, v = heapq.heappop(Q)
	if dist_node_st[v] < dis:
		continue
	for u, w in graph_s[v]:
		alt = dis + w
		if dist_node_st[u] > alt:
			dist_node_st[u] = alt
			heapq.heappush(Q, (alt, u))

ansL = []
X = []
for i in range(n):
	heapq.heappush(X, dist_node_ys[n - 1 - i] + dist_node_st[n - 1 - i])
	ansL.append(X[0])

for i in range(1, n + 1):
	print(1000000000000000 - ansL[- i])


### FIXED CODE ###

import heapq
from collections import defaultdict

n, m, s, t = list(map(int, input().split()))

graph_y = defaultdict(dict)
graph_s = defaultdict(dict)

for i in range(m):
	u, v, a, b = list(map(int, input().split()))
	graph_y[u - 1][v - 1] = a
	graph_y[v - 1][u - 1] = a
	graph_s[u - 1][v - 1] = b
	graph_s[v - 1][u - 1] = b

dist_node_ys = defaultdict(lambda: float("inf"))
dist_node_ys[s - 1] = 0

Q = []
heapq.heappush(Q, (dist_node_ys[s - 1], s - 1))

while Q: 
	dis, v = heapq.heappop(Q)
	if dist_node_ys[v] < dis:
		continue
	for i in graph_y[v]:
		u = i
		w = graph_y[v][i]
		alt = dis + w
		if dist_node_ys[u] > alt:
			dist_node_ys[u] = alt
			heapq.heappush(Q, (alt, u))


dist_node_st = defaultdict(lambda: float("inf"))
dist_node_st[t - 1] = 0

Q = []
heapq.heappush(Q, (dist_node_st[t - 1], t - 1))

while Q: 
	dis, v = heapq.heappop(Q)
	if dist_node_st[v] < dis:
		continue
	for i in graph_s[v]:
		u = i
		w = graph_s[v][i]
		alt = dis + w
		if dist_node_st[u] > alt:
			dist_node_st[u] = alt
			heapq.heappush(Q, (alt, u))

ansL = []
X = []
for i in range(n):
	heapq.heappush(X, dist_node_ys[n - 1 - i] + dist_node_st[n - 1 - i])
	ansL.append(X[0])

for i in range(1, n + 1):
	print(1000000000000000 - ansL[- i])
### BUGGY CODE ###

n, limit = list(map(int, input().split()))
permute = list(map(int, input().split()))
score = list(map(int, input().split()))

visited = [False] * n

ans = -10 ** 16

for i in range(n):
    if visited[i]:
        continue

    score_circle = []
    now = i
    while True:
        visited[now] = True
        score_circle.append(score[now])

        next_ = permute[now] - 1
        if visited[next_]:
            # 円環のできあがり
            break
        now = next_
    
    period = len(score_circle)

    score_circle *= 2
    # 累積和
    cumsum = [0] * (2 * period + 1)
    for j in range(1, 2*period+1):
        cumsum[j] = cumsum[j-1] + score_circle[j-1]
    
    p_sum_max = [-(10**15)] * (period + 1)
    for k in range(period):
        for ll in range(period):
            p_sum_max[ll] = max(p_sum_max[ll], cumsum[k+ll] - cumsum[k])
    
    ans = max([ans] + p_sum_max[1:min(period+1, limit+1)])

    q, resi = divmod(limit, period)

    if q >= 1:
        ans = max(ans, cumsum[period] * (q-1) + max(p_sum_max[1:]))
        ans = max(ans, cumsum[period] * (q) + max(p_sum_max[:resi + 1]))

        # print(p_sum_max[:resi + 1])

print(ans)


### FIXED CODE ###

n, limit = list(map(int, input().split()))
permute = list(map(int, input().split()))
score = list(map(int, input().split()))

visited = [False] * n

ans = -10 ** 16

for i in range(n):
    if visited[i]:
        continue

    score_circle = []
    now = i
    while True:
        visited[now] = True
        score_circle.append(score[now])

        next_ = permute[now] - 1
        if visited[next_]:
            # 円環のできあがり
            break
        now = next_
    
    period = len(score_circle)

    score_circle *= 2
    # 累積和
    cumsum = [0] * (2 * period + 1)
    for j in range(1, 2*period+1):
        cumsum[j] = cumsum[j-1] + score_circle[j-1]
    
    p_sum_max = [-(10**15)] * (period + 1)
    for k in range(period):
        for ll in range(period):
            p_sum_max[ll] = max(p_sum_max[ll], cumsum[k+ll] - cumsum[k])
    
    ans = max([ans] + p_sum_max[1:min(period+1, limit+1)])

    q, resi = divmod(limit, period)

    if q >= 1:
        ans = max(ans, cumsum[period] * (q-1) + max(p_sum_max[1:]))
        ans = max(ans, cumsum[period] * (q) + max(p_sum_max[:resi + 1]))

        # print(p_sum_max[:resi + 1])

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

from collections import Counter

s = input()[::-1]
n = len(s)
counts = [0] * 2019
counts[0] = 1
current = 0
d = 0

for c in s:
    current += int(c) * 10**d
    d += 1
    current %= 2019
    counts[current] += 1

ans = 0
for count in counts:
    if count > 1:
        # print(i)
        ans += count * (count-1) //2
print(ans)


### FIXED CODE ###

s = input()[::-1]

sum_of_digits = 0

cnts = [0] * 2019

cnts[0] = 1

d = 1

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

ans = 0
    
for cnt in cnts:
    ans += cnt * (cnt - 1) // 2

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

N, K = map(int,input().split())
moves = set()

mod = 998244353

for _ in range(K):
    L, R = map(int,input().split())
    for d in range(L, R+1):
        moves.add(d)
    # moves.add((L, R))


dp = [0] * (N + 1)
dp[1] = 1
# for dis in moves:
#     dp[dis] = 1

for n in range(1, N+1):
    for dis in moves:
        if n - dis >= 1:
            dp[n] += dp[n - dis]

# print(dp)
print(dp[N] % mod)


### FIXED CODE ###

n, k = map(int, input().split())
sec = [list(map(int, input().split())) for _ in range(k)]
sec.sort()
    
mod = 998244353
    
dp = [0] * n
dp[0] = 1
sum_dp = [0, 1]
for i in range(1, n):
    for l, r in sec:
        if i - l < 0:
            break
        elif i - r > 0:
            dp[i] = ((dp[i] + sum_dp[i-l+1]) % mod - sum_dp[i-r]) % mod
        else:
            dp[i] = (dp[i] + sum_dp[i-l+1]) % mod
    
    sum_dp.append((sum_dp[-1] + dp[i]) % mod)
    
print(dp[n-1])
### BUGGY CODE ###

import sys
input = sys.stdin.readline

def slove():
    n = int(input())
    ans = ""
    abc = "abcdefghijklmnopqrstuvwxyz"
    count = 0
    while n != 0:
        count += 1
        k = n % 26
        if k == 0:
            tmp = "z"
            n = n - 26 ** count
            ans = tmp + ans
     
        else:
            tmp = abc[k-1]
            n = n//26
            ans = tmp + ans
        
    print(ans)


if __name__ == "__main__":
    slove()
    

### FIXED CODE ###

import sys
input = sys.stdin.readline

def slove():
    n = int(input())
    ans = ""
    abc = "zabcdefghijklmnopqrstuvwxy"
    count = 0
    while n != 0:
        k = n % 26
        if k == 0:
            n -= 1
        n = n // 26
        ans = abc[k] + ans
        
    print(ans)


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

from collections import deque

S = list(input())
S = deque(S)
q = int(input())
Q = [list(input().split()) for _ in range(q)]

for i in range(q):
    if len(Q[i]) == 1:
        S.reverse()
    elif Q[i][1] == "1":
        S.appendleft(Q[i][2])
    else:
        S.append(Q[i][2])

for i in range(len(S)):
    print(S[i],end="")
print()


### FIXED CODE ###

from collections import deque

S = list(input())
s = deque(S)
q = int(input())
Q = [list(input().split()) for _ in range(q)]

rev = 0
for i in range(q):
    if len(Q[i]) == 1:
        rev += 1
        rev %= 2
    else:
        if rev == 0:
            if Q[i][1] == "1":
                s.appendleft(Q[i][2])
            else:
                s.append(Q[i][2])
        else:
            if Q[i][1] == "2":
                s.appendleft(Q[i][2])
            else:
                s.append(Q[i][2])

s = list(s)
if rev == 0:
    for i in range(len(s)):
        print(s[i],end="")
else:
    for i in reversed(range(len(s))):
        print(s[i],end="")
print()
### BUGGY CODE ###

A,B,C,D = map(int,input().split(' '))
lis = range(A,B+1)
count = 0
for x in lis:
    if x % C !=0 and x%D !=0:
        count +=1
print(count)

### FIXED CODE ###

import math

A, B, C, D = [int(x) for x in input().split(" ")]
lcm_c_d = (C * D) // math.gcd(C, D)
num_c = (B // C) - (A - 1) // C
num_d = (B // D) - (A - 1) // D
num_cd = (B // lcm_c_d) - (A - 1) // lcm_c_d
print(B - A - num_c - num_d + num_cd + 1)
### BUGGY CODE ###

import sys

R, C, K = map(int, input().split())
item = [[0]*C for _ in range(R)]
for s in sys.stdin.readlines():
    r, c, v = map(int, s.split())
    item[r-1][c-1] = v

DP = [[[0, 0, 0, 0] for _ in range(C)] for _ in range(R)]

DP[0][0][1] = item[0][0]

for i in range(R):
    for j in range(C):
        for k in range(4):
            if i > 0:  # 前の行から
                DP[i][j][0] = max(DP[i][j][0], max(DP[i-1][j]))  # 取らない
                DP[i][j][1] = max(DP[i][j][1], max(DP[i-1][j])+item[i][j])  # 取る

            if j > 0:  # 前の列から
                DP[i][j][k] = max(DP[i][j][k], DP[i][j-1][k])  # 取らない
                if k >= 1:
                    DP[i][j][k] = max(DP[i][j][k], DP[i][j-1][k-1]+item[i][j])  # 取る

print(max(DP[R-1][C-1]))

### FIXED CODE ###

import sys

R, C, K = map(int, input().split())
item = [[0] * (C + 1) for _ in range(R + 1)]  # dp配列と合わせるために, 0行目, 0列目を追加している.
for s in sys.stdin.readlines():
    r, c, v = map(int, s.split())
    item[r][c] = v

dp = [[[0] * (C + 1) for _ in range(R + 1)] for _ in range(4)]
for i in range(R + 1):
    for j in range(C + 1):
        for k in range(4):
            here = dp[k][i][j]
            # 次の行に移動する場合
            if i + 1 <= R:
                # 移動先のアイテムを取らない場合
                dp[0][i + 1][j] = max(dp[0][i + 1][j], here)
                # 移動先のアイテムを取る場合
                dp[1][i + 1][j] = max(dp[1][i + 1][j], here + item[i + 1][j])
            # 次の列に移動する場合
            if j + 1 <= C:
                # 移動先のアイテムを取らない場合
                dp[k][i][j + 1] = max(dp[k][i][j + 1], here)
                # 現在のkが3未満のときのみ, 移動先のアイテムを取ることが可能
                if k < 3:
                    dp[k + 1][i][j + 1] = max(dp[k + 1][i][j + 1], here + item[i][j + 1])
ans = 0
for k in range(4):
    ans = max(ans, dp[k][-1][-1])
print(ans)
### BUGGY CODE ###

N = int(input())
A = [int(_) for _ in input().split()]
mod = 10**9 + 7
ans = 0
for b in range(60):
    M = sum((a >> b) & 1 for a in A)
    ans += 2**b * M * (N - M)
    ans %= mod
print(ans)


### FIXED CODE ###

import numpy as np
N = int(input())
A = np.array([int(_) for _ in input().split()], dtype=np.int64)
mod = 10**9 + 7
ans = 0
for b in range(60):
    B = (A >> b) & 1
    M = np.count_nonzero(B)
    ans += 2**b * M * (N - M)
    ans %= mod
print(ans)
### BUGGY CODE ###

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

num_list = [1]
flag = True
while flag:
    tmp = a_list[num_list[-1]-1]
    if tmp in num_list:
        flag = False
    else:
        num_list.append(tmp)
        
idx = num_list.index(tmp)
loop = len(num_list) - idx
if k < idx:
    print(num_list[k])
else:
    print(num_list[(k-idx)%loop  + idx])

### FIXED CODE ###

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

num_list = [1]
n_set = set([1])
flag = True
while flag:
    tmp = a_list[num_list[-1]-1]
    if tmp in n_set:
        flag = False
    else:
        n_set.add(tmp)
        num_list.append(tmp)
        
idx = num_list.index(tmp)
loop = len(num_list) - idx
if k < idx:
    print(num_list[k])
else:
    print(num_list[(k-idx)%loop  + idx])
### BUGGY CODE ###

R, G, B, N = map(int, input().split())

org_list = [R, G, B]
org_list.sort()
first_num = org_list[2]
second_num = org_list[1]
third_num = org_list[0]

count = 0

for i in range(N // first_num + 1):
  if i*first_num > N:
    break
  for j in range((N-i*first_num) // second_num + 1):
    if i*first_num + j*second_num > N:
      break
    if (N - i*first_num - j*second_num) % third_num == 0:
      count += 1
 
print(count)

### FIXED CODE ###

R, G, B, N = map(int, input().split())

org_list = [R, G, B]
org_list.sort()
first_num = org_list[2]
second_num = org_list[1]
third_num = org_list[0]

count = 0

for i in range(N // first_num + 1):
  for j in range((N-i*first_num) // second_num + 1):
    if (N - i*first_num - j*second_num) % third_num == 0:
      count += 1
 
print(count)
### BUGGY CODE ###

n, m = map(int, input().split())
ab = sorted(set([tuple(map(int, input().split())) for _ in range(m)]))

c = []
flag = False
for i in ab:
    a, b = i[0], i[1]
    for i in c:
        if a in i or b in i:
            i.add(a)
            i.add(b)
            if len(i) == n:
                flag = True
            break
    else:
        c.append(set())
        c[-1].add(a)
        c[-1].add(b)
    if flag:
        break
if m == 0:
    print(1)
else:
    print(max(map(len, c)))

### FIXED CODE ###

class Union:
    def __init__(self, n):
        self.parents = [-1] * n
    
    def root(self, x):
        if self.parents[x] < 0:
            return x
        else:
            return self.root(self.parents[x])
    
    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]

uni = Union(n)
for a, b in ab:
    a -= 1
    b -= 1
    uni.unite(a, b)
print(-min(uni.parents))
### BUGGY CODE ###

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

answer = 'YES'
for i in range(N):
    c = A.count(A[i])
    if c >= 2:
        answer = 'NO'
        break

print(answer)


### FIXED CODE ###

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

answer = 'YES'
AA = sorted(A)
for i in range(N - 1):
    if AA[i] == AA[i + 1]:
        answer = 'NO'
        break

print(answer)
### BUGGY CODE ###

s = input()
print(0) if int(s) < 2019 else print(sum(int(s[j:i+j]) % 2019 == 0 for i in range(4, len(s)) for j in range(len(s)-i+1)))

### FIXED CODE ###

import numpy as np

s = input()[::-1]
length = len(s)
a = np.zeros(length, dtype=int)
d = np.zeros(length, dtype=int)
ans = np.zeros(2019, dtype=int)
x = 10

a[0] = int(s[0])
d[0] = a[0]
ans[d[0]] += 1

for i in range(1, length):
    a[i] = int(s[i]) * x % 2019
    d[i] = (d[i-1] + a[i]) % 2019
    ans[d[i]] += 1
    x = x * 10 % 2019

ans_c = ans[np.nonzero(ans)]

print(int(sum([ans_c[i] * (ans_c[i]-1) for i in range(ans_c.shape[0])]) / 2) + ans[0])
### BUGGY CODE ###

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

seq = [int(i) for i in input().split()]

ans = 0

for i in range(N-1):
    while seq[i] + seq[i+1] > x and seq[i+1] != 0:
        seq[i+1] -= 1
        ans += 1
    
    while seq[i] + seq[i+1] > x:
        seq[i] -= 1
        ans += 1

print(ans)

### FIXED CODE ###

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

seq = [int(i) for i in input().split()]

ans = 0

for i in range(N-1):
    if seq[i]+seq[i+1] > x:
        dec = seq[i]+seq[i+1] - x
        if seq[i+1] > dec:
            seq[i+1] = seq[i+1] - dec
        else:
            seq[i+1] = 0
            seq[i] = seq[i] - dec + seq[i+1]
        ans += dec

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

S = list(input())
N = len(S)
ans = 0

for i in range(N):
    if S[i] == "B":
        ans += S[i + 1:].count("W")

print(ans)


### FIXED CODE ###

S = list(input())
N = len(S)
ans = 0

WWW = S.count("W")

for i in range(N):
    if S[i] == "B":
        ans += WWW
    if S[i] == "W":
        WWW -= 1

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

import math
import fractions
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def is_prime(num):
    for i in range(2, num):  # 第二引数は sqrt(num)+1 でも良い
        if num % i == 0:
            return False

    return True

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

g = fractions.gcd(A, B)

div = make_divisors(g)
ans = 0
for i in div:
    if is_prime(i):
        ans += 1
print(ans)

### FIXED CODE ###

import math
import fractions
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def is_prime(p):
    if p == 1:
        return False
    for i in range(2,int(p ** .5) + 1):
        if p % i == 0:
            return False
    return True

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

g = fractions.gcd(A, B)

div = make_divisors(g)
ans = 1
for i in div:
    if is_prime(i):
        ans += 1
print(ans)
### BUGGY CODE ###

N, M, K = map(int, input().split())
ppp = 10**9 + 7

def expo_div_p(a: int,n: int,p: int):
    if n == 1:
        d = a
    elif n % 2 == 0:
        d = expo_div_p(a, n//2, p)**2 % p
    else:
        d = a * expo_div_p(a, n//2, p)**2 % p
    return d

def combi(x, y, p):
    c = 1
    for i in range(1,y+1):
        c *= (x-i+1) * expo_div_p(i, p-2, p)
        c %= p
    return c

ans = 0
C = 0
C += combi(N*M-2, K-2, ppp)

for i in range(1,N):
    ans += C * i * (N-i) * M**2
for j in range(1,M):
    ans += C * j * (M-j) * N**2

#print(C)
print(ans % ppp)


### FIXED CODE ###

N, M, K = map(int, input().split())
ppp = 10**9 + 7

#def expo_div_p(a: int,n: int,p: int):
#    if n == 1:
#        d = a
#    elif n % 2 == 0:
#        d = expo_div_p(a, n//2, p)**2 % p
#    else:
#        d = a * expo_div_p(a, n//2, p)**2 % p
#    return d
#
def combi(x, y, p):
    c = 1
    for i in range(1,y+1):
        c *= (x-i+1) * pow(i, p-2, p)
        c %= p
    return c


ans = 0
C = combi(N*M-2, K-2, ppp)

for i in range(1,N):
    ans += C * i * (N-i) * M**2
for j in range(1,M):
    ans += C * j * (M-j) * N**2

#print(C)
print(ans % ppp)
### BUGGY CODE ###

[n,k]=list(map(int,input().split()))
akarusa=list(map(int,input().split()))


for i in range(k):
    imos=[0]*n
    for j in range(n):
        kagen=max(j-akarusa[j],0)
        jogen=min(j+akarusa[j],n-1)
        imos[kagen]+=1
        if jogen+1<n:
            imos[jogen+1]-=1
    akarusanext=[imos[0]]
    for j in range(1,n):
        akarusanext.append(akarusanext[-1]+imos[j])
    
    if akarusa==akarusanext:
        break
    else:
        akarusa=akarusanext

for i in range(n):
    print(akarusa[i], end=" ")


### FIXED CODE ###

[n,k]=list(map(int,input().split()))
akarusa=list(map(int,input().split()))


for i in range(k):
    imos=[0]*n
    for j in range(n):
        kagen=max(j-akarusa[j],0)
        jogen=min(j+akarusa[j],n-1)
        imos[kagen]+=1
        if jogen+1<n:
            imos[jogen+1]-=1
    akarusanext=imos
    for j in range(1,n):
        akarusanext[j]+=akarusanext[j-1]
    
    if akarusa==akarusanext:
        break
    else:
        akarusa=akarusanext

for i in range(n):
    print(akarusa[i], end=" ")
### BUGGY CODE ###

from functools import reduce
n = int(input())
A = list(map(int,input().split()))
b = sorted(A)
if b[0] == 0:
    ans = 0
else:
    ans  = reduce(lambda x,y : x * y, b)
if ans > 10**18:
    print(-1)
else:
    print(ans) 

### FIXED CODE ###

from functools import reduce
n = int(input())
A = list(map(int,input().split()))
b = sorted(A,reverse=True)
c = 1
if b[-1] == 0:
    c = 0
else:
    for i in range(n):
        if c > 10 ** 18:
            break
        c *= b[i]
    

if c > 10**18:
    print(-1)
else:
    print(c)
### BUGGY CODE ###

N, M = map(int, input().split())
prefecture_dict = {i:[] for i in range(1, N+1)}

city_list = []
for _ in range(M):
    P, Y = map(int, input().split()) 
    prefecture_dict[P].append(Y)
    city_list.append([P, Y])

for i in range(1, N+1):
    prefecture_dict[i].sort()

for j in range(M):
    prefecture = city_list[j][0]
    num = prefecture_dict[prefecture].index(city_list[j][1]) + 1
    prefecture = str(prefecture)
    num = str(num)
    print(prefecture.zfill(6) + num.zfill(6))

### FIXED CODE ###

# -*- coding: utf-8 -*-

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

answer_list = [0] * M
prefectures = [0] * (N+1)
data_set = [0] * M

for i in range(M):
	P, Y = map(int, input().split())
	data_set[i] = [P, Y, i]

data_set.sort()

for i in range(M):
	answer = ''
	P, Y, a = data_set[i]
	prefectures[P] += 1

	for j in range(6-len(list(str(P)))):
		answer += '0'

	answer += str(P)

	for k in range(6-len(list(str(prefectures[P])))):
		answer += '0'

	answer += str(prefectures[P])

	answer_list[a] = answer

for i in range(M):
	print(answer_list[i])
### BUGGY CODE ###

n=int(input())
X=input()
x=list(map(int,list(X)))
mod=998244353
pow_2=[0]*n
pow_2[n-1]=1
for i in range(1,n):
    pow_2[n-1-i]=(pow_2[n-i]*2)%mod
num=0
for i in range(n):
    if x[i]==1:
        num=(num+pow_2[i])%mod
#約数全列挙
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
li=make_divisors(n)
lst=[]
for i in li:
    if i%2==1 and i>2:
        lst.append(i)
lst.sort(reverse=True)
sum=0
count=0
s=[]
t=[]
for u in lst:
    U=u
    u=n//u
    cnt=0
    for i in range(1,u+1):
        if x[u-i]==1:
            cnt=(cnt+pow_2[-i])%mod
    y=X[:u]
    for i in range(u):
        if X[i]=="0":
            y+="1"
        else:
            y+="0"
    y*=(U+1)//2
    y=y[:n]
    if y<=X:
        cnt+=1
    for i in range(len(s)):
        if u%s[i]==0:
            cnt-=t[i]
    sum=(sum+(2*cnt*u)%mod)%mod
    s.append(u)
    t.append(cnt)
    count=(count+cnt)%mod
print((((num+1-count)*2*n)%mod+sum)%mod)

### FIXED CODE ###

n=int(input())
X=input()
x=list(map(int,list(X)))
mod=998244353
pow_2=[0]*n
pow_2[n-1]=1
for i in range(1,n):
    pow_2[n-1-i]=(pow_2[n-i]*2)%mod
num=0
for i in range(n):
    if x[i]==1:
        num=(num+pow_2[i])%mod
#約数全列挙
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
li=make_divisors(n)
lst=[]
for i in li:
    if i%2==1 and i>2:
        lst.append(i)
lst.sort(reverse=True)
sum=0
count=0
s=[]
t=[]
for u in lst:
    U=u
    u=n//u
    cnt=0
    for i in range(1,u+1):
        if x[u-i]==1:
            cnt=(cnt+pow_2[-i])%mod
    y=list(X[:u])
    for i in range(u):
        if y[i]=="0":
            y.append("1")
        else:
            y.append("0")
    y="".join(y)
    y*=(U+1)//2
    y=y[:n]
    if y<=X:
        cnt+=1
    for i in range(len(s)):
        if u%s[i]==0:
            cnt-=t[i]
    sum=(sum+(2*cnt*u)%mod)%mod
    s.append(u)
    t.append(cnt)
    count=(count+cnt)%mod
print((((num+1-count)*2*n)%mod+sum)%mod)