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

import bisect

N = int(input())
L = [int(_) for _ in input().split()]
L.sort()

ans = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        r = L[i] + L[j]
        # 同じ長さでも違う棒はOK
        ri = bisect.bisect_left(L, r, lo=j)
        ans += ri - j - 1

print(ans)

### FIXED CODE ###

import bisect

N = int(input())
L = [int(_) for _ in input().split()]
L.sort()

ans = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        r = L[i] + L[j]
        # 同じ長さでも違う棒はOK
        ri = bisect.bisect_left(L, r, lo=j)
        ans += ri - j - 1

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

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

s =str(1)+ s + 'E'   # 終端処理
ans = -1    # 答えの初期値（十分に小さい値）

L=1
L2=0
for i in range(n):
    count=0
    v=0
    for j in range(L,n+2):
        if s[j]==str(0):
            #連続してる所は飛ばす。
            if s[j-1]==str(0):
                continue
                
            else:
                count+=1
                
        #0のあと初めて1が出たらindexを取得
        if s[j]==str(1) and count==1 and v==0:
                L2=j
                v+=1
                
            
        if count==k+1:
            ans=max(ans,j-L)
            L=L2
            break
            
        if s[j]=='E':
            ans=max(ans,j-L)
            print(ans)
            exit()

### FIXED CODE ###

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

s =str(1)+ s + 'E'   # 終端処理
ans = -1    # 答えの初期値

L=1
count=0
L2=[1]
for i in range(n):
    if i>=1:
        count-=1
    v=0
    for j in range(L,n+2):
        if s[j]==str(0):
            #連続してる所は飛ばす。
            if s[j-1]==str(0):
                continue
                
            else:
                count+=1
                
        #0のあと初めて1が出たらindexを取得
        if s[j]==str(1):
            if s[j-1]==str(0):
                L2.append(j)
                
            
        if count==k+1:
            
            ans=max(ans,j-L2[i])
            #次はｊ+１から始める
            L=j+1
            break
            
        if s[j]=='E':
            ans=max(ans,j-L2[i])
            print(ans)
            exit()
### BUGGY CODE ###

def main():
    K, S = map(int, input().split())
    count = 0
    for i in range(K+1):
        if i > S:
            break
        for j in range(K+1):
            if i + j > S:
                break
            for k in range(K+1):
                if i + j + k > S:
                    break
                elif i + j + k == S:
                    count += 1
    print(count)
main()

### FIXED CODE ###

def solve(K, S):
    count = 0
    for i in range(K+1):
        for j in range(K+1):
            if 0 <= S - i - j <= K:
                count += 1
    return count
def main():
    K, S = map(int, input().split())
    count = solve(K, S)
    print(count)
main()
### BUGGY CODE ###

import collections
from sys import stdin



def get_result(data):
    N = data[0][0]
    A = data[1]
    uniq_cnt = collections.Counter(A)
    
    for i in range(N):
        ans = 0
        for key, value in uniq_cnt.items():
            if key == A[i]:
                value -= 1
            ans += int(value * (value - 1) / 2)
        print(ans)


if __name__ == '__main__':
    raw_data = [val.rstrip('\n') for val in stdin.readlines()]
    data = [list(map(int, val.split(' '))) for val in raw_data]
    get_result(data)


### FIXED CODE ###

import collections
from sys import stdin

# # not AC
# def counter(num_arr):
#     uniq_dict = {}
#     for val in num_arr:
#         uniq_dict[val] = uniq_dict.get(val, 0) + 1
#     return uniq_dict


# def get_result(data):
#     N = data[0][0]
#     A = data[1]
#     uniq_cnt = counter(A)
#     ans = {}
#     for key in uniq_cnt.keys():
#         tmp = uniq_cnt.copy()
#         tmp[key] -= 1
#         ans[key] = int(sum([val * (val-1) / 2 for val in tmp.values()]))

#     for i in range(N):
#         print(ans[A[i]])

def get_result(data):
    N = data[0][0]
    A = data[1]
    uniq_cnt = collections.Counter(A)
    all_selection = 0
    for val in uniq_cnt.values():
        all_selection += int(val * (val-1) / 2)

    for i in range(N):
        print(all_selection - uniq_cnt[A[i]] + 1)


if __name__ == '__main__':
    raw_data = [val.rstrip('\n') for val in stdin.readlines()]
    data = [list(map(int, val.split(' '))) for val in raw_data]
    get_result(data)
### BUGGY CODE ###

N = int(input())

str_N = str(N)
num = 0
char_set = {str(i) for i in range(1, N)}

for n1 in range(1, N + 1):
    for n2 in range(1, N + 1):
        str_n1, str_n2 = map(str, [n1, n2])
        length1 = len(str_n1)
        length2 = len(str_n2)

        if str_n1[0] == str_n2[length2-1] and str_n1[length1-1] == str_n2[0]:
            num += 1


print(int(num))

### FIXED CODE ###

N = int(input())

M = [[0]*10 for _ in range(10)]

for n in range(1,N+1):
    head = int(str(n)[0])
    tail = int(str(n)[-1])
    M[head][tail] += 1

ans = 0
for i in range(10):
    for j in range(i+1,10):
        ans += M[i][j]*M[j][i]*2
    ans += M[i][i]**2

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

n=int(input())
s=list(input())
import numpy as np
r=0
for ii in range(n-2):
  for jj in np.arange(ii+1,n-1):
    if s[ii]!=s[jj]:
      for kk in range(jj+1,n):
        if ii-jj!=jj-kk:
          if s[jj]!=s[kk] and s[ii]!=s[kk]:
            r+=1
print(r)

### FIXED CODE ###

import numpy as np
n=int(input())
s=list(input())
sr=set()
sg=set()
sb=set()
for ii in range(n):
    if s[ii]=="R":
        sr.add(ii)
    if s[ii]=="G":
        sg.add(ii)
    if s[ii]=="B":
        sb.add(ii)
l=[len(sr),len(sg),len(sb)]
l.sort()

if l[0]==len(sr):
  s1=sr
  if l[1]==len(sg):
    s2=sg
    s3=sb
  else:
    s2=sb
    s3=sg
elif l[0]==len(sg):
  s1=sg
  if l[1]==len(sr):
    s2=sr
    s3=sb
  else:
    s2=sb
    s3=sr
else:
  s1=sb
  if l[1]==len(sr):
    s2=sr
    s3=sg
  else:
    s2=sg
    s3=sr
  
r=0
for ii in s1:
  for jj in s2:
    r+=len(s3)
    dt=abs(ii-jj)
    if ii+dt in s3:
      r-=1
    if ii-dt in s3:
      r-=1
    if jj+dt in s3:
      r-=1
    if jj-dt in s3:
      r-=1
    if (ii+jj)%2==0:
      if (ii+jj)//2 in s3:
        r-=1
      
print(r)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**7)
n,q = map(int,input().split())
g = [[] for i in range(n)]
c = [0]*n
reach = [False]*n
for i in range(n-1):
    a,b = map(lambda x: int(x)-1,input().split())
    g[a].append(b)
    g[b].append(a)

for i in range(q):
    p,x = map(int,input().split())
    c[p-1] += x

def dfs(v):
    reach[v] = True
    for i in g[v]:
        if not reach[i]:
            c[i] += c[v]
            dfs(i)

reach[0] = True
dfs(0)
print(*c)


### FIXED CODE ###

n,q = map(int,input().split())
g = [[] for i in range(n)]
c = [0]*n
reach = [False]*n
for i in range(n-1):
    a,b = map(lambda x: int(x)-1,input().split())
    g[a].append(b)
    g[b].append(a)

for i in range(q):
    p,x = map(int,input().split())
    c[p-1] += x

reach[0] = True
q = [0]
while q:
    cur = q.pop()
    reach[cur] = True
    for i in g[cur]:
        if not reach[i]:
            c[i] += c[cur]
            q.append(i)
print(*c)
### BUGGY CODE ###

S = input()
T = input()

max_count = 0
for start_t in range(len(T)):
    for start_s in range(start_t, len(S)):
        if len(S) - start_s < len(T) - start_t:
            break
        if T[start_t] == S[start_s]:
            count = 0

            for i in range(len(T) - start_t):
                if T[start_t+i] == S[start_s+i]:
                    count += 1
            
            max_count = max(max_count, count)

answer = len(T) - max_count
print(answer)



### FIXED CODE ###

S = input()
T = input()

max_count = 0
for start_t in range(len(T)):
    for start_s in range(start_t, len(S)):
        if len(S) - start_s < len(T) - start_t:
            break
        if T[start_t] == S[start_s]:
            count = 0

            for i in range(len(T) - start_t):
                if T[start_t+i] == S[start_s+i]:
                    count += 1
            
            max_count = max(max_count, count)

answer = len(T) - max_count
print(answer)
### BUGGY CODE ###

n,m=map(int,input().split())
A=[]
for i in range(m):
    a=int(input())
    A.append(a)
dp=[0]*(n+1)
dp[0]=1
for i in range(1,n+1):
    dp[i]=(dp[i-1]+dp[i-2])%(10**9+7)
    if i in A:dp[i]=0
print(dp[n])

### FIXED CODE ###

n,m=map(int,input().split())
A=set(int(input()) for i in range(m))
dp=[0]*(n+1)
dp[0]=1
for i in range(1,n+1):
    dp[i]=(dp[i-1]+dp[i-2])%(10**9+7)
    if i in A:dp[i]=0
print(dp[n])
### BUGGY CODE ###

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

j=-1
for i in range(1,len(s)):
    tmp=s[i]
    if s[i-1]>tmp:
        j=i
        while True:
            if s[j-1]>tmp and j>0:
                s[j]=s[j-1]
                j=j-1
            else:
                s[j]=tmp
                break
print(s[(n-1)//2+1]-s[(n-1)//2])


### FIXED CODE ###

n=int(input())
s=list(map(int,input().split()))
s.sort()
print(s[(n-1)//2+1]-s[(n-1)//2])
### BUGGY CODE ###

a=[['\'',',','.','!','?'],
   ['a','b','c','A','B','C'],
   ['d','e','f','D','E','F'],
   ['g','h','i','G','H','I'],
   ['j','k','l','J','K','L'],
   ['m','n','o','M','N','O'],
   ['p','q','r','s','P','Q','R','S'],
   ['t','u','v','T','U','V'],
   ['w','x','y','z','W','X','Y','Z']]
while 1:
    try:b=input()+'@'
    except:pass
    c=0
    ans=''
    for i in range(len(b)-1):
        if b[i]!=b[i+1]:
            if b[i]!='0':
                d=int(b[i])-1
                ans+=a[d][c%len(a[d])]
            c=0
        else: c+=1
        if b[i]==b[i+1]=='0':ans+=' '
    print(ans)

### FIXED CODE ###

a=[['\'',',','.','!','?'],
   ['a','b','c','A','B','C'],
   ['d','e','f','D','E','F'],
   ['g','h','i','G','H','I'],
   ['j','k','l','J','K','L'],
   ['m','n','o','M','N','O'],
   ['p','q','r','s','P','Q','R','S'],
   ['t','u','v','T','U','V'],
   ['w','x','y','z','W','X','Y','Z']]
while 1:
    try:b=input()+'@'
    except:break
    c=0
    ans=''
    for i in range(len(b)-1):
        if b[i]!=b[i+1]:
            if b[i]!='0':
                d=int(b[i])-1
                ans+=a[d][c%len(a[d])]
            c=0
        else: c+=1
        if b[i]==b[i+1]=='0':ans+=' '
    print(ans)
### BUGGY CODE ###

def f(nums, K, w):
  h=len(nums)
  counter=[nums[x][0] for x in range(h)]
  if max(counter)>K:
    return float('inf')
  
  out=0
  for i in range(1, w):
    for x in range(h):
      counter[x]+=nums[x][i]
      
    if max(counter)>K:
      out+=1
      counter=[nums[x][i] for x in range(h)]
      
  return out

H, W, K=map(int, input().split())
S=[input() for _ in range(H)]
S=[[int(S[i][j]) for j in range(W)] for i in range(H)]
ans=float('inf')
for p in range(2**(H-1)):
  q='0'+format(p, '0'+str(H-1)+'b')+'1'
  i=0
  c=0
  nums=[]
  while i<H:
    j=1
    while i+j<H and q[i+j]=='0':
      j+=1
    tmp=S[i:i+j]
    nums.append([sum([tmp[y][x] for y in range(j)]) for x in range(W)])
    i+=j
    
  cand=f(nums, K, W)+q.count('1')-1
  if ans>cand:
    ans=cand
    
print(ans)



### FIXED CODE ###

def f(nums, K, w):
  h=len(nums)
  counter=[nums[x][0] for x in range(h)]
  if max(counter)>K:
    return float('inf')
  
  out=0
  for i in range(1, w):
    for x in range(h):
      counter[x]+=nums[x][i]
      
    if max(counter)>K:
      out+=1
      counter=[nums[x][i] for x in range(h)]
      
  return out

H, W, K=map(int, input().split())
S=[input() for _ in range(H)]
S=[[int(S[i][j]) for j in range(W)] for i in range(H)]
ans=float('inf')
for p in range(2**(H-1)):
  q='0'+format(p, '0'+str(H-1)+'b')+'1'
  i=0
  c=0
  nums=[]
  while i<H:
    j=1
    while i+j<H and q[i+j]=='0':
      j+=1
    tmp=S[i:i+j]
    nums.append([sum([tmp[y][x] for y in range(j)]) for x in range(W)])
    i+=j
    
  cand=f(nums, K, W)+q.count('1')-1
  if ans>cand:
    ans=cand
    
print(ans)
### BUGGY CODE ###

n, m, R = map(int, input().split())
r = list(map(int, input().split()))

INF = 10 ** 9

d = [[INF for _ in range(n)] for _ in range(n)]
p = [[] for _ in range(n)]

for i in range(n):
    d[i][i] = 0

for _ in range(m):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    d[a][b] = c
    d[b][a] = c
    p[a].append(b)
    p[b].append(a)

#for q in d: print(q)

for _ in range(n):
    for i in range(n - 1):
        for j in range(i + 1, n):
            for k in range(n):
                if k != i and k != j:
                    temp = min(d[i][j], d[i][k] + d[k][j])
                    if temp < d[i][j]:
                        d[i][j] = temp
                        d[j][i] = temp

ans = 0
for i in range(n):
    ans = max(ans, max(d[i]))
print(ans)

### FIXED CODE ###

from itertools import permutations

n, m, R = map(int, input().split())
r = list(map(int, input().split()))

INF = 10 ** 9

d = [[INF for _ in range(n)] for _ in range(n)]
p = [[] for _ in range(n)]

for i in range(n):
    d[i][i] = 0

for i in range(R):
    r[i] -= 1

for _ in range(m):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    d[a][b] = c
    d[b][a] = c
    p[a].append(b)
    p[b].append(a)

#for q in d: print(q)

for k in range(n):
    for i in range(n-1):
        for j in range(i+1, n):
            if d[i][j] > d[i][k] + d[k][j]:
                d[i][j] = d[i][k] + d[k][j]
                d[j][i] = d[i][j]

ans = INF
for x in permutations(r):
    temp = 0
    for i in range(R-1):
        temp += d[x[i]][x[i+1]]
    ans = min(temp, ans)

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

n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(n):
	b.append(a[i])
	b = b[:: -1]
print(" ".join(map(str, b)))


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
b = []
if n % 2 == 0:
	b = a[1:: 2][:: -1] + a[:: 2]
	print(" ".join(map(str, b)))
else:
	b = a[:: 2][:: -1] + a[1:: 2]
	print(" ".join(map(str, b)))
### BUGGY CODE ###

import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

K = int(input())

ans = 0
for i in range(K):
    for j in range(K):
        for k in range(K):
            if i+1 == j+1 and j+1==k+1 and i+1 == k+1:
                ans += i+1
             
            elif i+1 == j +1:
                ans += gcd(i+1,k+1)
            elif j+1 == k+1:
                ans += gcd(i+1,k+1)
            elif i+1 == k+1:
                ans += gcd(i+1,j+1)
            elif i+1 == 1 or j+1 == 1 or k+1 == 1:
             

                ans +=1
            
            else:
             

                ans += gcd(i+1,j+1,k+1)
            #1-Kまで
print(ans)

### FIXED CODE ###

import math
from functools import reduce
 
def gcd(*numbers):
    return reduce(math.gcd, numbers)
 
def gcd_list(numbers):
    return reduce(math.gcd, numbers)
K = int(input())
 
 
ans = 0
for i in range(K):
    for j in range(K):
        for k in range(K):
           
 
                ans += gcd(i+1,j+1,k+1)
            #1-Kまで
print(ans)
### BUGGY CODE ###

import bisect

def main():
    N = int(input())
    CSF = tuple(tuple(map(int, input().split())) for _ in [0] * (N - 1))

    time = [[] for _ in [0] * N]
    end = CSF[0][1] + 1
    for i, (c, s, f) in enumerate(CSF):
        end = max(end, s + 1)
        time[i] = [j for j in range(s, end, f)]
        end += c + s

    for i in range(N - 1):
        sec = 0
        for j in range(i, N - 1):
            n = bisect.bisect_left(time[j], sec)
            sec = time[j][n] + CSF[j][0]
        print(sec)
    print(0)

main()


### FIXED CODE ###

def main():
    N = int(input())
    C, S, F = [], [], []
    capnd, sapnd, fapnd = C.append, S.append, F.append
    for c, s, f in (map(int, input().split()) for _ in [0] * (N - 1)):
        capnd(c)
        sapnd(s)
        fapnd(f)

    for i in range(N):
        t = 0
        for j in range(i, N - 1):
            if t < S[j]:
                t = S[j]
            elif not t % F[j]:
                pass
            else:
                t = t + F[j] - t % F[j]
            t += C[j]
        print(t)

main()
### BUGGY CODE ###

N, Q = map(int, input().split())
S = input()
lr = [map(int,input().split()) for _ in range(Q)]

for l, r in lr:
    print(S[l-1:r].count('AC'))

### FIXED CODE ###

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

sum_list = [0]
for i in range(N-1):
    sum_list.append(sum_list[-1] + (1 if S[i:i+2] == 'AC' else 0))

for j in range(Q):
    l, r = map(int, input().split())
    print(sum_list[r-1] - sum_list[l-1])
### BUGGY CODE ###

a = int(input())
ar = list(map(int,input().split(" ")))
cr = set(ar)
dr = sorted(cr,reverse=True)
br = []
for r in dr:
    if len(br) == 2:
        break
    if ar.count(r) >= 4:
        br.append(r)
        if len(br) == 2:
            break
        br.append(r)
    elif ar.count(r) >= 2:
        br.append(r)
if len(br) == 0:
    print(0)
else:
    print(br[0] * br[1])

### FIXED CODE ###

import collections
a = int(input())
ar = list(map(int,input().split(" ")))
br = collections.Counter(ar)
cr = []
for k,v in br.items():
    if v >= 4:
        cr.append(k)
        cr.append(k)
    elif v >= 2:
        cr.append(k)
cr = sorted(cr,reverse=True)
if len(cr) < 2:
    print(0)
else:
    print(cr[0] * cr[1])
### BUGGY CODE ###

from sys import stdin
from itertools import accumulate
import bisect

n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))
lin = [i+1 for i in range(n)]
point = 0
ls = []
ls.sort()
for i in range(n):
    ls.append(li[i]-lin[i])
ls.sort()
mi = 10**6
for i in ls:
    lin = 0
    for j in range(n):
        lin += abs(ls[j]-i)
    mi = min(lin,mi)

print(mi)

### FIXED CODE ###

from sys import stdin
import statistics

n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))
lin = [i+1 for i in range(n)]
point = 0
ls = []
for i in range(n):
    ls.append(li[i]-lin[i])
ls.sort()
mi = 10**10

k = int(round(statistics.median(ls)))

for i in range(len(ls)):
    ls[i] = abs(ls[i]-k)

print(sum(ls))
### BUGGY CODE ###

import numpy as np
S = input()
mod = 10 ** 9 + 7

n = len(S)
dp = np.zeros((n, 13), int)
a = S[-1]
x_ = dp[0]
l = [1, 10, 9, 12, 3, 4]
l = [[i * l_ % 13 for i in range(1, 10)] for l_ in l]
li = 1
if a == "?":
    x_[0:10] = 1
else:
    x_[int(a)] = 1
for s, x in zip(S[-2::-1], dp[1:]):
    if s == "?":
        x += x_
        for v in l[li]:
            x %= mod
            x[v:] += x_[:-v]
            x[:v] += x_[-v:]
    else:
        if s == "0":
            x += x_
        else:
            v = l[li][int(s) - 1]
            x[v:] += x_[:-v]
            x[:v] += x_[-v:]
    x %= mod
    li += 1
    li %= 6
    x_ = x
print(dp[-1][5])

### FIXED CODE ###

#!python3

LI = lambda: list(map(int, input().split()))

# input
S = input()

MOD = 10 ** 9 + 7


def main():
    n = len(S)
    m = 5
    w = []
    p = 1
    for i in range(n):
        s = S[-1 - i]
        if s == "?":
            w.append(p)
        else:
            m = (m - int(s) * p) % 13
        p = p * 10 % 13

    n = len(w)
    l1 = [0] * 13
    l1[0] = 1
    for i in range(1, n + 1):
        l2 = [0] * 13
        for j in range(10):
            x = w[i - 1] * j % 13
            for k in range(13):
                t = (x + k) % 13
                l2[t] += l1[k]
        l1 = [y % MOD for y in l2]
    
    ans = l1[m]
    print(ans)


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

def popcount(n):
    cnt = 0
    for i in range(n):
        if ((n >> i) & 1):
            cnt +=1
    return cnt

def f(n):
    cnt = 0
    while True:
        if n == 0:
            break
        n = n % popcount(n)
        cnt += 1
    return cnt

def numChange(list, i):
    num = 0
    j = 0
    while True:
        if i < 0:
            break
        num += int(list[i]) * pow_r(2, j)
        i -= 1
        j += 1
    return num

def pow_r(x, n):
    if n == 0:
        return 1
    if n % 2 == 0:
        return pow_r(x ** 2, n // 2)
    else:
        return x * pow_r(x ** 2, (n - 1) // 2)

if __name__ == "__main__":
    n = int(input())
    x = input()
    xList = list(x)
    k = len(xList) - 1
    for i in range(n):
        if xList[i] == '0':
            xList[i] = '1'
        else:
            xList[i] = '0'
        xNum = int("".join(xList), 2)
        print(f(xNum))
        if xList[i] == '0':
            xList[i] = '1'
        else:
            xList[i] = '0'


### FIXED CODE ###

def f(n):
    cnt = 1
    while n > 0:
        n  %= bin(n).count('1')
        cnt += 1
    return cnt

if __name__ == "__main__":
    n = int(input())
    x = input()
    d = x.count('1')
    if d == 1:
        for i in x[:-1]:
            if i == '0':
                print(1)
            else:
                print(0)
        if x[-1] == '1':
            print(0)
        else:
            print(2)
        exit()

    ans = []
    M = 0
    for i in x:
        M <<= 1
        if i == '1':
            M += 1
    p = M % (d + 1)
    m = M % (d - 1)
    for i in range(n):
        if x[i] == '0':
            ans.append(f((p + pow(2, n - i - 1, d + 1)) % (d + 1)))
        else:
            ans.append(f((m - pow(2, n - i - 1, d - 1)) % (d - 1)))
    print(*ans, sep='\n')
### BUGGY CODE ###

n,k = map(int,input().split())
li = list(map(int,input().split()))
ans = [0]*(n+1)
tmp = [0]*(n+1)
tmp_sum = []
#print(ans)
#[0, 0, 0, 0, 0]

for kkk in range(k):
    #print(li,'li')
    for i,l in enumerate(li):
        if l != 0:
            start = max(0,i-l)
            end = min(n,i+l+1)
            #print(start,'start',end,'end')
            tmp[start] += 1
            #print(end,len(tmp),'aaa')
            tmp[end] -= 1
    #print(tmp,'tmp')
    last = 0
    for t in tmp:
        last = t+last
        tmp_sum.append(last)
    for i,l in enumerate(li):
        if l == 0:
            tmp_sum[i] += 1
    ans = tmp_sum[:n]
    li = tmp_sum[:n]
    tmp = [0]*(n+1)
    tmp_sum = []
    #if len(set(ans)) == 1:
    #    break
print(*ans)

### FIXED CODE ###

n,k = map(int,input().split())
li = list(map(int,input().split()))
ans = [0]*(n+1)
tmp = [0]*(n+1)
tmp_sum = []
#print(ans)
#[0, 0, 0, 0, 0]
k = min(k,100)

for kkk in range(k):
    #print(li,'li')
    for i,l in enumerate(li):
        if l != 0:
            start = max(0,i-l)
            end = min(n,i+l+1)
            #print(start,'start',end,'end')
            tmp[start] += 1
            #print(end,len(tmp),'aaa')
            tmp[end] -= 1
    #print(tmp,'tmp')
    last = 0
    for t in tmp:
        last = t+last
        tmp_sum.append(last)
    for i,l in enumerate(li):
        if l == 0:
            tmp_sum[i] += 1
    ans = tmp_sum[:n]
    li = tmp_sum[:n]
    tmp = [0]*(n+1)
    tmp_sum = []
    #if len(set(ans)) == 1:
    #    break
print(*ans)
### BUGGY CODE ###

def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 1
    for a in A:
        ans *= a
    print(ans if ans <= 10**18 else -1)

if '__main__' == __name__:
    resolve()

### FIXED CODE ###

def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 1
    th = 10**18
    if 0 in A:
        print(0)
        return
    for a in A:
        ans *= a
        if ans > th:
            print(-1)
            return 
    print(ans if ans <= th else -1)

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

# /user/bin/python
# -*- coding: utf-8 -*-
import sys
 
s = str(input())
s_bef = ""
s_aft = s

while(s_bef != s_aft):
  s_bef = s_aft
  s_aft = s_aft.replace("01", "")
  s_aft = s_aft.replace("10", "")

print(len(s) - len(s_aft))


### FIXED CODE ###

# /user/bin/python
# -*- coding: utf-8 -*-
import sys
 
s = str(input())
ans = 0

for c in s:
  if c == '0':
    ans -= 1
  else:
    ans += 1
print(len(s) - abs(ans))