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

def make_divisors(n):
    cnt=0

    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            cnt+=1
            if i != n // i:
                cnt+=1
    
    return cnt

n=int(input())
ans=0

for i in range(1, n+1):
    d=make_divisors(i)
    ans+=i*d

print(ans)

### FIXED CODE ###

n=int(input())

ans=0

for i in range(1, n+1):
    begin=i
    end=(n//i)*i
    cnt=(n//i)
    ans+=(1/2)*cnt*(begin+end)

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

S=raw_input()
l=len(S)

mod=10**9+7

a=0
ab=0
ans=0
all=1

for i in range(l):
	if S[i]=="A":
		a+=all
	elif S[i]=="B":
		ab+=a
	elif S[i]=="C":
		ans+=ab
	elif S[i]=="?":
		ans = ans*3 + ab
		ab = ab*3 + a
		a = a*3 + all
		all *= 3

	ans%=mod
	ab%=mod
	a%=mod
	all%mod


print ans


### FIXED CODE ###

S=raw_input()

M=10**9+7

all=1
abc=0
ab=0
a=0

for x in S:
	if x=="A":
		a+=all
	if x=="B":
		ab+=a
	if x=="C":
		abc+=ab

	if x=="?":
		abc=abc*3+ab
		ab=ab*3+a
		a= a*3+all
		all*=3

	abc%=M
	ab%=M
	a%=M
	all%=M


print abc%M
### BUGGY CODE ###

from collections import deque
n,d,a=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
l.sort()
for i in range(n):
  l[i][1]=(l[i][1]+a-1)//a
ans=0
L=[]
L=deque(L)
left=l[0][0]
for i in range(n):
  ct=0
  f=0
  for j in range(len(L)):
    if L[j][0]<=l[i][0]<=L[j][1]:
      l[i][1]=max(0,l[i][1]-L[j][2])
      f=1
    else:
      ct+=1
      if f==1:
        break
  for k in range(ct):
    L.popleft()
  ans+=l[i][1]
  L.append([l[i][0],l[i][0]+2*d,l[i][1]])
  l[i][1]=0
  left=l[i][0]+2*d
print(ans)

### FIXED CODE ###

import bisect
import sys
input=sys.stdin.readline
n,d,a=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
l.sort()

data0=[0]*(n+1)
data1=[0]*(n+1)

def _add(data,k,x):
  while k<=n:
    data[k]+=x
    k+=k&-k

def add(l,r,x):
  _add(data0,l,-x*(l-1))
  _add(data0,r,x*(r-1))
  _add(data1,l,x)
  _add(data1,r,-x)

def _get(data,k):
  s=0
  while k:
    s+=data[k]
    k-=k&-k
  return s

def query(l,r):
  return _get(data1,r-1)*(r-1)+_get(data0,r-1)-_get(data1,l-1)*(l-1)-_get(data0,l-1)

x=[]
for i in range(n):
  x.append(l[i][0])
  add(i+1,i+2,l[i][1])

Right=[]
for i in range(n):
  Right.append(bisect.bisect_right(x,x[i]+2*d))

p=0
ans=0
while p<n:
  Q=query(p+1,p+2)
  add(p+1,Right[p]+1,-((Q+a-1)//a)*a)
  ans+=(Q+a-1)//a
  p=min(p+1,n-1)
  while query(p+1,p+2)<=0:
    p+=1
    if p==n:
      break
print(ans)
### BUGGY CODE ###

n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))

a.insert(0,0)
ans = 0
visited = []
i = 1

while True:
    if a[i] == 2:
        ans += 1
        break
    elif not i in visited:
        ans += 1
        visited.append(i)
        i = a[i]
    else:
        ans = -1
        break
print(ans)

### FIXED CODE ###

n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))

a.insert(0,0)
ans = 0
i = 1

for x in range(n+1):
    if a[i] == 2:
        ans += 1
        break
    elif x == n:
        ans = -1
        break
    else:
        ans += 1
        i = a[i]
print(ans)
### BUGGY CODE ###

import fractions

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

def GCD_modify(a,b):
  if a==0:
    return b
  elif b==0:
    return a
  else:
    return fractions.gcd(a,b)

def RE_F(i):
  L,R = 0,0
  for j in range(i):
    L = GCD_modify(L,num_arr[j])
  for k in range(N-i-1):
    R = GCD_modify(R,num_arr[k+i+1])
    #print(R)
  return GCD_modify(L,R)

GCD_arr = [RE_F(l) for l in range(N)]

print(max(GCD_arr))

### FIXED CODE ###

from fractions import gcd
N = int(input())
array = list(map(int,input().split()))
all_gcd = [0]*N
#calc from start to end
gcd_L = [array[0]]
for i in range(N-1):
  gcd_L.append(gcd(gcd_L[-1],array[i+1]))
  
#calc from end to start
gcd_R = [array[-1]]
for j in range(N-1,0,-1):
  gcd_R.append(gcd(gcd_R[-1],array[j-1]))
  
gcd_arr = []
  
for idx in range(N):
  if idx==0:
    gcd_arr.append(gcd_R[-2])
  elif idx==N-1:
    gcd_arr.append(gcd_L[-2])
  else:
    gcd_arr.append(gcd(gcd_L[idx-1],gcd_R[N-1-idx-1]))
print(max(gcd_arr))
### BUGGY CODE ###

N=int(input())
S=input()
ans=0
for x in range(2,N):
  for y in range(1,x):
    for z in range(0,y):
      if x-y!=y-z:
        p,q,r=S[x],S[y],S[z]
        if p!=q and q!=r and r!=p:
          ans+=1
print(ans)

### FIXED CODE ###

N=int(input())
S=input()
all=S.count("R")*S.count("G")*S.count("B")

for i in range(N-1):
  for j in range(i,N):
    if 0<=2*i-j<N:
      if S[2*i-j]!=S[i]!=S[j]!=S[2*i-j]:
        all-=1
print(all)
### BUGGY CODE ###

n,w=map(int,input().split())
#wv=[[int(i) for i in input().split()] for j in range(n)]
dp=[0]*(w+1)

for i in range(n):
    new_dp=[0]*(w+1)
    ww,v=map(int,input().split())
    for j in range(w+1):
        if j<ww:
            new_dp[j]=dp[j]
        else:
            new_dp[j]=max(dp[j],dp[j-ww]+v)
    dp=new_dp
print(dp[-1])

### FIXED CODE ###

n,w=map(int,input().split())
#wv=[[int(i) for i in input().split()] for j in range(n)]
dp=[0]*(w+1)

for i in range(n):
    new_dp=[0]*(w+1)
    ww,v=map(int,input().split())
    for j in range(w+1):
        if j<ww:
            new_dp[j]=dp[j]
        else:
            new_dp[j]=max(dp[j],dp[j-ww]+v)
    dp=new_dp
print(dp[-1])
### BUGGY CODE ###

N, K, Q =map(int, input().split())

point = [K] * N
A = []
for i in range(Q):
    point = list(map(lambda x: x -1 , point))
    point[int(input()) - 1] += 1

for p in point:
    if p > 0:
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

N, K, Q =map(int, input().split())

A = {}
for i in range(Q):
    a = int(input())
    if a in A:
        A[a] += 1
    else:
        A[a] = 1

for i in range(N):
    if K - Q > 0:
        print("Yes")
    elif (i + 1) in A:
        if (K - (Q -A[i + 1])) > 0:
            print("Yes")
        else:
            print("No")
    else:
        print("No")
### BUGGY CODE ###

N, K = map(int, input().split())
 
ans = 1
while 1:
  if N >= K ** ans:
    ans += 1
    continue
  else:
    print(ans)

### FIXED CODE ###

N, K = map(int, input().split())
 
ans = 1
while 1:
  if N >= K ** ans:
    ans += 1
    continue
  else:
    print(ans)
    break
### BUGGY CODE ###

n=int(input())
lst=list(map(int,input().split()))
aa=sum(lst) % (10**9+7)
# print(sum(lst) % (10**9+7) )
tem=0
for i in range(n-1):
    tem+=(lst[i] % (10**9+7) )*(aa- sum(lst[0:i+1]) % (10**9+7))
        # print(tem)
print(tem % (10**9 +7))

### FIXED CODE ###

n=int(input())
lst=list(map(int,input().split()))
aa=sum(lst) % (10**9+7)
# print(sum(lst) % (10**9+7) )
new_lst=[]
temp_1=aa
for i in range(n-1):
    temp_1-=lst[i]
    new_lst.append(temp_1)
# print(new_lst)

tem=0
for i in range(n-1):
    tem+=(lst[i] )*new_lst[i]
        # print(tem)
print(tem % (10**9 +7))
### BUGGY CODE ###

from itertools import product
N,M = map(int,input().split())
G = {i:[] for i in range(M)}
for i in range(M):
    a,b = map(int,input().split())
    G[i] = [a,list(map(int,input().split()))]
INFTY = 10**11
dp = {j:{S:INFTY for S in product((0,1),repeat=N)} for j in range(M+1)}
for j in range(M+1):
    dp[j][tuple([0 for _ in range(N)])] = 0
for j in range(M):
    for S in product((0,1),repeat=N):
        A = [0 for _ in range(N)]
        for x in G[j][1]:
            A[x-1] = 1
        B = list(S[:])
        for i in range(N):
            if B[i]==1 and A[i]==1:
                B[i] = 0
        dp[j+1][S] = min(dp[j][S],dp[j][tuple(B)]+G[j][0])
s = tuple([1 for _ in range(N)])
a =dp[M][s]
if a>=INFTY:
    print(-1)
else:
    print(a)

### FIXED CODE ###

from itertools import product
N,M = map(int,input().split())
G = {i:[] for i in range(M)}
for i in range(M):
    a,b = map(int,input().split())
    G[i] = [a,list(map(int,input().split()))]
INFTY = 10**11
dp = [[INFTY for S in range(2**N)] for _ in range(M+1)]
for j in range(M+1):
    dp[j][0] = 0
for j in range(M):
    for S in range(2**N):
        y = 0
        for x in G[j][1]:
            y += 2**(x-1)
        dp[j+1][S] = min(dp[j][S],dp[j][S&(~y)]+G[j][0])
a =dp[M][2**N-1]
if a>=INFTY:
    print(-1)
else:
    print(a)
### BUGGY CODE ###

def resolve():
    import bisect
    k, s = map(int, input().split())
    cnt = 0
    k += 1
    lx = [x for x in range(k)]
    for i in range(k):
        for j in range(k):
            if s-i-j >= 0:
                index = bisect.bisect_right(lx, s-i-j)-1
                if i+j+index == s and index <= k:
                    cnt += 1
    print(cnt)
resolve()

### FIXED CODE ###

def resolve():
    k, s = map(int, input().split())
    cnt = 0
    for i in range(k+1):
        if i > s:
            break
        for j in range(k+1):
            if 0 <= s-i-j <= k:
                cnt += 1
            elif s-i-j < 0:
                break
    print(cnt)
resolve()
### BUGGY CODE ###

#!/usr/bin/env python3
from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall, dijkstra
# G = csgraph_from_dense(edge, null_value=10**9)
# f = floyd_warshall(G)
# d = dijkstra(G, indices=1)
import sys
input = lambda: sys.stdin.readline()[:-1]
sys.setrecursionlimit(10**8)

xs,ys,xt,yt=map(int,input().split())
n=int(input())
xyr=[(xs,ys,0),(xt,yt,0)]
data=[[-1]*(n+2) for i in range(n+2)]
for i in range(n):
    xyr.append(tuple(map(int,input().split())))
# print(xyr)
for i in range(n+2):
    for j in range(n+2):
        x0 = xyr[i][0]
        y0 = xyr[i][1]
        r0 = xyr[i][2]
        x1 = xyr[j][0]
        y1 = xyr[j][1]
        r1 = xyr[j][2]
        if i!=j:
            data[i][j]=max(((x0-x1)**2+(y0-y1)**2)**.5-r0-r1,0)
G = csgraph_from_dense(data, null_value=-1)
# for i in G:
#     print(i)
d = dijkstra(G, indices=0)
print(d[1])



### FIXED CODE ###

def dijkstra(s):
    #始点sから各頂点への最短距離
    #n:頂点数,　w:辺の数, cost[u][v] : 辺uvのコスト(存在しないときはinf)
    d = [float("inf")] * n
    used = [False] * n
    d[s] = 0
    
    while True:
        v = -1
        #まだ使われてない頂点の中から最小の距離のものを探す
        for i in range(n):
            if (not used[i]) and (v == -1):
               v = i
            elif (not used[i]) and d[i] < d[v]:
                v = i
        if v == -1:
               break
        used[v] = True
               
        for j in range(n):
               d[j] = min(d[j],d[v]+cost[v][j])
    return d

Xs,Ys,Xt,Yt = map(int,input().split())
n = int(input())
p = [(Xs,Ys,0),(Xt,Yt,0)]
for i in range(2,n+2):
    p.append(tuple(map(int,input().split())))
cost = [[0]*(n+2)for i in range(n+2)]

for i in range(n+2):
    for j in range(i,n+2):
        cost[i][j] = cost[j][i] =  max(((p[i][0]-p[j][0])**2+(p[i][1]-p[j][1])**2)**0.5 - p[i][2] - p[j][2],0)
cost = tuple(cost)
n += 2

res = dijkstra(0)
print(res[1])
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
temp=[0]*n
for i in range(n):
  cnt=0
  for j in range(n):
    if a[i]==a[j]:
      cnt=cnt+1
  temp[i]=cnt-1
ans=sum(temp)//2
for i in range(n):
  print(ans-temp[i])

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
from collections import Counter
tempa=Counter(a)
temp=[0]*n
for i in range(n):
  temp[i]=tempa[a[i]]-1
ans=sum(temp)//2
for i in range(n):
  print(ans-temp[i])
### BUGGY CODE ###

def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    l = list(map(int, input().rstrip('\n').split()))
    l.sort()
    cnt = 0
    for i in range(n-2):
        for j in range(i+1, n-1):
            t = l[i] + l[j]
            for k in range(j+1, n):
                if t > l[k]:
                    cnt += 1
                else:
                    break
    print(cnt)


if __name__ == '__main__':
    slove()


### FIXED CODE ###

def slove():
    import sys
    import bisect
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    l = list(map(int, input().rstrip('\n').split()))
    l.sort()
    cnt = 0
    for i in range(n-2):
        for j in range(i+1, n-1):
            t = l[i] + l[j]
            p = bisect.bisect_left(l, t)
            cnt += (p - j - 1)
    print(cnt)


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

N=int(input())
s=[''.join(sorted(list(input()))) for i in range(N)]


dic={}
counter=0
for i in range(N):
  if (s[i] in dic.keys())==True:
    counter+=dic[s[i]]
    dic[s[i]]=dic[s[i]]+1
  else:
    dic[s[i]]=1

print(counter)

### FIXED CODE ###

N=int(input())
s=[''.join(sorted(input())) for i in range(N)]


dic={}
counter=0
for i in range(N):
  if (s[i] in dic.keys())==True:
    counter+=dic[s[i]]
    dic[s[i]]=dic[s[i]]+1
  else:
    dic[s[i]]=1

print(counter)
### BUGGY CODE ###

import sys
import queue

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++



def gg(nn, x, y, n, is_sit):
	q = queue.Queue()
	q.put((x,y))
	cl = set()
	cl.add(x*1000+y)
	while not q.empty():
		x,y = q.get()
		nn[x][y] -= 1
		k = nn[x][y]
		for dx,dy in ([-1,0], [0,-1], [1,0], [0,1]):
			if x+dx < 0 or x +dx >= n or y + dy < 0 or y + dy >= n:
				continue
			if nn[x+dx][y + dy] <= k + is_sit[x+dx][y+dy]:
				continue
			if (x+dx)*1000+(y+dy) in cl:
				continue
			q.put((x+dx, y+dy))
			cl.add((x+dx)*1000 + (y+dy))
		#print('yyyyyy')
		#for l in nn:
		#	print(l)

def main():
	n = int(input())
	nn = [[(n+1)//2] * n for _ in range(n)]
	is_sit = [[1] * n for _ in range(n)]
	for i in range(n):
		for j in range(n):
			nn[i][j] = min(i+1,j+1,n-i,n-j)
	#for l in nn:
	#	print(l)
	
	#b , c = tin()
	pl = lin()
	ans = 0
	for p in pl:
		x, y = (p-1) // n, (p-1) % n
		ans += nn[x][y]-1
		is_sit[x][y] = 0
		gg(nn, x, y, n, is_sit)
		
	print(ans)
	#s = input()
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

### FIXED CODE ###

import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

#+++++

def main():
	n = int(input())
	nn = [[min(i,j,n-i-1,n-j-1) for j in range(n)] for i in range(n)]
	is_sit = [[True] * n for _ in range(n)]
	cc = [[0]*n for _ in range(n)]
	
	#b , c = tin()
	pl = list(map(int, input().split()))
	ans = 0
	for p in pl:
		x, y = (p-1) // n, (p-1) % n
		ans += nn[x][y]
		is_sit[x][y] = False
		q = [(x, y, nn[x][y])]
		while q:
			(x, y, v) = q.pop()
			if x >= 0 and nn[x-1][y]>v:
				nn[x-1][y] = v
				q.append((x-1, y, v+is_sit[x-1][y]))
			if x < n-1 and nn[x+1][y]>v:
				nn[x+1][y] = v
				q.append((x+1, y, v+is_sit[x+1][y]))		
			if y >= 0 and nn[x][y-1]>v:
				nn[x][y-1] = v
				q.append((x, y-1, v+is_sit[x][y-1]))
			if y < n-1 and nn[x][y+1]>v:
				nn[x][y+1] = v
				q.append((x, y+1, v+is_sit[x][y+1]))	
		
	print(ans)
	#s = input()	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)
### BUGGY CODE ###

from collections import defaultdict
from bisect import bisect_right
S=input()
T=input()
ls=len(S); lt=len(T)
S_dict=defaultdict(list)
for i,s in enumerate(S):
    S_dict[s].append(i+1)
T_list=[[] for _ in range(lt)]
for i,t in enumerate(T):
    if not S_dict[t]:
        print(-1)
        exit()
    T_list[i]=S_dict[t]
    T_list[i].sort()
#print(T_list)
ans=T_list[0][0]
prev=T_list[0][0]
cycles=0
#print(ans)
for i in range(1,lt):
    idx=bisect_right(T_list[i],prev)
    if idx==len(T_list[i]):
        cycles+=1
        prev=T_list[i][0]
    else:
        prev=T_list[i][idx]
    ans=prev+(cycles*ls)
    #print(prev,cycles,ans)
print(ans)

### FIXED CODE ###

from collections import defaultdict
from bisect import bisect_right
S=input()
T=input()
ls=len(S); lt=len(T)
S_dict=defaultdict(list)
for i,s in enumerate(S):
    S_dict[s].append(i+1)
T_list=[[] for _ in range(lt)]
for i,t in enumerate(T):
    if not S_dict[t]:
        print(-1)
        exit()
    T_list[i]=S_dict[t]
#print(T_list)
ans=T_list[0][0]
prev=T_list[0][0]
cycles=0
#print(ans)
for i in range(1,lt):
    idx=bisect_right(T_list[i],prev)
    if idx==len(T_list[i]):
        cycles+=1
        prev=T_list[i][0]
    else:
        prev=T_list[i][idx]
    ans=prev+(cycles*ls)
    #print(prev,cycles,ans)
print(ans)
### BUGGY CODE ###

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

q = []

for i in range(Q):
    B, C = list(map(int, input().split()))
    for i in range(N):
        if A[i] > B:
            break
        if A[i] == B:
            A[i] = C

    A.sort()
    q.append(sum(A))

for i in q:
    print(i)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
a = [0]*100000
for i in A:
    a[i-1] += 1
Q = int(input())

ans = sum(A)

q = []

for i in range(Q):
    B, C = list(map(int, input().split()))
    if a[B-1] >= 1:
        ans = ans - B*a[B-1] + C*a[B-1]
        a[C-1] += a[B-1]
        a[B-1] = 0
    q.append(ans)

for i in q:
    print(i)
### BUGGY CODE ###

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

cands = A
for length in range(2, N+1):
    for i in range(N - length + 1):
        cands.append(sum(A[i : i+length]))
cands

counter = 0

for c in cands:
    if c % M == 0:
        counter += 1

print(counter)


### FIXED CODE ###

from collections import defaultdict

N, M = map(int, input().split())
A = list(map(int, input().split()))
cumS = [0]
for a in A:
    cumS.append(a + cumS[-1])
cumS_rem = defaultdict(int)
for c in cumS:
    r = c % M
    cumS_rem[r] += 1
ans = 0
for r, n_r in cumS_rem.items():
    if n_r > 1:
        ans += n_r*(n_r-1)//2
print(ans)
### BUGGY CODE ###

import copy


n = int(input())
b = list(map(int, input().split()))
ope = []


def insertion(n, x):
    if not x:
        return True
    for i in range(n):
        y = copy.copy(x)
        if y[i] == i + 1:
            y.pop(i)
            ope.insert(0, i + 1)
            if insertion(n - 1, y):
                return True
            else:
                ope.pop(0)
    return False



if insertion(n, b):
    for i in ope:
        print(i)
else:
    print(-1)

### FIXED CODE ###

import sys


n = int(input())
b = list(map(int, input().split()))
ope = []
i = n
while i > 0:
    flag = 0
    j = i
    while j > 0:
        if b[j - 1] == j:
            b.pop(j - 1)
            i -= 1
            ope.insert(0, j)
            flag = 1
            break
        j -= 1
    if flag == 0:
        print(-1)
        sys.exit()
for i in ope:
    print(i)
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
if n%2==0:
    x=[]
    y=[]
    for i in range(n):
        if i%2==1:
            y=[a[i]]+y
        else:
            x.append(a[i])
    z=y+x
    print(*z)
else:
    x=[]
    y=[]
    for i in range(n):
        if i%2==0:
            y=[a[i]]+y
        else:
            x.append(a[i])
    z=y+x
    print(*z)

### FIXED CODE ###

from collections import deque
n=int(input())
a=list(map(int,input().split()))
if n%2==0:
    x=deque([])
    y=deque([])
    for i in range(n):
        if i%2==1:
            y.appendleft(a[i])
        else:
            x.append(a[i])
    z=[]
    for u in y:
        z.append(u)
    for u in x:
        z.append(u)
    print(*z)
else:
    x=deque([])
    y=deque([])
    for i in range(n):
        if i%2==0:
            y.appendleft(a[i])
        else:
            x.append(a[i])
    z=[]
    for u in y:
        z.append(u)
    for u in x:
        z.append(u)
    print(*z)
### BUGGY CODE ###

"""

i回目では前からi人目の持っていた任意のボールを置ける
赤を何回採用したかでDP


"""

S = input()
N = len(S)
mod = 998244353

lis = [0] * (2*N+1)
lis[0] = 1
R = 0
B = 0

c = 0
for n in S:

    if n == "0":
        R += 2
    elif n == "1":
        R += 1
        B += 1
    else:
        B += 2

    nlis = [0] * (2*N+1)
    
    for i in range(2*N):

        if i < R:
            nlis[i+1] += lis[i]
            nlis[i+1] %= mod

        if c-i < B:
            nlis[i] += lis[i]
            nlis[i] %= mod

    lis = nlis
    c += 1


for loop in range(N):
    
    nlis = [0] * (2*N+1)
    
    for i in range(2*N):

        if i < R:
            nlis[i+1] += lis[i]
            nlis[i+1] %= mod

        if c-i < B:
            nlis[i] += lis[i]
            nlis[i] %= mod

    lis = nlis
    c += 1

print (sum(lis) % mod)

### FIXED CODE ###

"""

i回目では前からi人目の持っていた任意のボールを置ける
赤を何回採用したかでDP


"""

S = input()
N = len(S)
mod = 998244353

lis = [0] * (2*N+1)
lis[0] = 1
R = 0
B = 0

c = 0
for n in S:

    if n == "0":
        R += 2
    elif n == "1":
        R += 1
        B += 1
    else:
        B += 2

    nlis = [0] * (2*N+1)
    
    for i in range(2*N):

        if i < R:
            nlis[i+1] += lis[i]
            nlis[i+1] %= mod

        if c-i < B:
            nlis[i] += lis[i]
            nlis[i] %= mod

    lis = nlis
    c += 1


for loop in range(N):
    
    nlis = [0] * (2*N+1)
    
    for i in range(2*N):

        if i < R:
            nlis[i+1] += lis[i]
            nlis[i+1] %= mod

        if c-i < B:
            nlis[i] += lis[i]
            nlis[i] %= mod

    lis = nlis
    c += 1

print (sum(lis) % mod)
### BUGGY CODE ###

N,Q=map(int,input().split())
C=list(map(int,input().split()))
LR=sorted([[i]+list(map(int,input().split())) for i in range(Q)],key=lambda x:x[2])
from numba import*
import numpy as np
@jitclass((('N',i8),('data',i8[:])))
class BIT:
    def __init__(self,N):
        self.N=N
        self.data=np.zeros(N+1,dtype=np.int64)
    def add(self,i,x):
        i+=1
        while i<=self.N:
            self.data[i]+=x
            i+=i&-i
    def sum(self,a,b):
        r=0
        i=b
        while i>0:
            r+=self.data[i]
            i-=i&-i
        i=a
        while i>0:
            r-=self.data[i]
            i-=i&-i
        return r
b=BIT(N)
p=[-1]*N
q=0
a=[0]*Q
for i in range(N):
    if p[C[i]-1]>=0:
        b.add(p[C[i]-1],-1)
    p[C[i]-1]=i
    b.add(i,1)
    while q<Q and LR[q][2]==i+1:
        a[LR[q][0]]=b.sum(LR[q][1]-1,LR[q][2])
        q+=1
print(*a,sep='\n')

### FIXED CODE ###

def main(N,Q,C,LR,A):
    data=[0]*(N+1)
    def add(i,x):
        i+=1
        while i<=N:
            data[i]+=x
            i+=i&-i
    def sum(a,b):
        r=0
        i=b
        while i>0:
            r+=data[i]
            i-=i&-i
        i=a
        while i>0:
            r-=data[i]
            i-=i&-i
        return r
    p=[-1]*N
    q=0
    a=[0]*Q
    for i in range(N):
        if p[C[i]-1]>=0:
            add(p[C[i]-1],-1)
        p[C[i]-1]=i
        add(i,1)
        while q<Q and LR[A[q]][1]==i+1:
            a[A[q]]=sum(LR[A[q]][0]-1,LR[A[q]][1])
            q+=1
    return a

import sys
if sys.argv[-1]=='ONLINE_JUDGE':
    from numba import*
    from numba.pycc import CC
    cc=CC('my_module')

    def cc_export(f, signature):
        cc.export(f.__name__, signature)(f)
        return njit(f)

    main=cc_export(main,(i8,i8,i8[:],i8[:,:],i8[:]))
    cc.compile()
    exit()

def input(): return sys.stdin.buffer.readline()
N,Q=map(int,input().split())
import numpy as np
C=np.array(input().split(),dtype=np.int64)
LR=np.array(sys.stdin.buffer.read().split(),dtype=np.int64).reshape(Q,2)
A=np.argsort(LR[:,1])

from my_module import main
print(*main(N,Q,C,LR,A),sep='\n')
### BUGGY CODE ###

K, S = map(int, input().split())
count = 0
for a in range(K+1):
    for b in range(K+1):
        for c in range(K+1):
            if a+b+c == S:
                count += 1
print (count)


### FIXED CODE ###

K, S = map(int, input().split())
count = 0
for a in range(K+1):
    for b in range(K+1):
        # **3の全探索は間に合わないため、S-a-bの値が0からKの間である組を数えれば良い。
        # for c in range(K+1):
        #     if a+b+c == S:
        c = S - a - b
        if 0<=c<=K:
            count += 1
print (count)