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

import numpy as np
from scipy.sparse.csgraph import shortest_path

def main():
    n, x, y = map(int, input().split(" "))
    graph = np.zeros([n, n])
    for i in range(n-1):
        graph[i, i+1] = 1
        graph[x-1, y-1] = 1
    
    s_path = shortest_path(graph, method='D', directed=False)
    #print(s_path)
    for k in range(n-1):
        k += 1
        ans = int(np.count_nonzero(s_path == k) / 2)
        print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import numpy as np
from scipy.sparse.csgraph import shortest_path
import collections

def main():
    n, x, y = map(int, input().split(" "))
    graph = np.zeros([n, n])
    for i in range(n-1):
        graph[i, i+1] = 1
        graph[x-1, y-1] = 1
    
    s_path = shortest_path(graph, method='D', directed=False)
    
    c = collections.Counter(s_path.flatten())
    for k in range(n-1):
        k += 1
        ans = int(c[k] / 2)
        print(ans)


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

from collections import  Counter
N=int(input())
L=[]
ans=0
for i in range(N):
    s=Counter(list(input()))
    for j,[k,ss] in enumerate(L):
        if s==ss:
            L[j][0]+=1
            ans+=k+1
            break
    else:
        L.append([0,s])
print(ans)

### FIXED CODE ###

from collections import Counter
N=int(input())
L=[''.join(sorted(list(input()))) for i in range(N)]
S=Counter(L)
ans=0
for i in S.values():
    ans+=(i-1)*i//2
print(ans)
### BUGGY CODE ###

N = int(input())
a = list(map(int, input().split()))
l1 = [1] * N
a1 = [_ + 1 for _ in a]
a2 = [_ - 1 for _ in a]
lst = a + a1 + a2
lst = list(lst)
set_lst = list(set(lst))
ans = 0
for i in set_lst:
    tmp = lst.count(i)
    if tmp > ans:
        ans = tmp
print(ans)

### FIXED CODE ###

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

cnt = [0] * 1000010
for i in a:
    cnt[i] += 1
    cnt[i+1] += 1
    cnt[i-1] += 1

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

n,m = map(int,input().split())
lis = [[] for _ in range(10**5)]
for _ in range(n):
  a,b = map(int,input().split())
  lis[a-1].append(b)
ans = 0
li = []
for i in range(m):
  li += lis[i]
  li.sort(reverse=True)
  try:
    ans += li[0]
    del(li[0])
  except:
    continue
print(ans)

### FIXED CODE ###

from heapq import heappush,heappop,heapify

n,m = map(int,input().split())
lis = [[] for i in range(m+1)]

for _ in range(n):
    a,b = map(int,input().split())
    if a <= m:
        lis[a].append(-b)

ans = 0
num = []
heapify(num)

for j in range(1,m+1):
    for nu in lis[j]:
        heappush(num,nu)
    if len(num) > 0:
        work = heappop(num)
        ans += -work
print(ans)
### BUGGY CODE ###

N = int(input())
A = tuple(map(int,input().split()))
mod = 10**9+7
import fractions
A_lcm = A[0]
for i in range(1,N):
    A_lcm = A_lcm*A[i]//fractions.gcd(A_lcm,A[i])
ans = 0
for i in A:
    ans += A_lcm//i
print(ans%mod)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
import fractions
mod = 10**9+7
lcm = A[0]
for i in range(1,N):
    lcm = lcm*A[i]//fractions.gcd(lcm,A[i])
ans = 0
for i in range(N):
    ans += lcm*pow(A[i],mod-2,mod)
print(ans%mod)
### BUGGY CODE ###

import fractions
from functools import reduce

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

p = 10**9+7
ans = 0

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

lcm = lcm_list(A)

for i in A:
    ans += lcm // i % p

print(ans%p)

### FIXED CODE ###

import fractions
from functools import reduce

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

p = 10**9+7

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

lcm = lcm_list(A)

B = [lcm//i for i in A]

print(sum(B)%p)
### BUGGY CODE ###

def main():
    from collections import Counter
    from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
    import sys
    input = sys.stdin.readline
    def flatten_2dim(array): return [item for sublist in array for item in sublist]

    n, x, y = map(int, input().split())
    f_inf = float('inf')
    dist = [[f_inf] * n for _ in range(n)]

    for i in range(n-1):dist[i][i+1], dist[i+1][i] = 1, 1
    dist[x-1][y-1], dist[y-1][x-1] = 1, 1

    G = csgraph_from_dense(dist, null_value=10**9)
    dist = floyd_warshall(G)

    counter = Counter(flatten_2dim(dist))
    counter = sorted(counter.most_common())[1:]

    for key, val in counter: print(val//2)
    for _ in range(n - len(counter)-1): print(0)
if __name__ == "__main__": main()

### FIXED CODE ###

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

f_inf = float('inf')

def push(v, d):
    if dist[v] != f_inf: return
    dist[v] = d
    que.append(v)

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

ans = [0]*n
for sv in range(n):
    dist = [f_inf] * n
    que = deque([])
    push(sv, 0)

    while que:
        v = que.popleft()
        d = dist[v]+1
        if v-1 >= 0: push(v-1, d)
        if v+1 < n: push(v+1, d)
        if v == x: push(y, d)
        if v == y: push(x, d)

    for i in range(n):
        ans[dist[i]] += 1
        
for i in range(n):
    ans[i] = ans[i]//2

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

K, S = list(map(int, input().split()))

res = 0

for x in range(K+1):
  if x > S: continue
  for y in range(K+1):
    if x+y > S: continue
    for z in range(K+1):
      if x+y+z > S: continue
      if x + y + z == S:
        res += 1

print(res)

### FIXED CODE ###

K, S = list(map(int, input().split()))

res = 0

for x in range(K+1):
  for y in range(K+1):
    z = S - x - y
    if z >= 0 and z <= K:
      res += 1

print(res)
### BUGGY CODE ###

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

S_dash = input()
T = input()

S_dash_list = list(S_dash)
T_list = list(T)

ei = len(S_dash_list)
si = ei - len(T_list)

insert_flag = False
while si >= 0:
    #print('si: {}, ei: {}'.format(si, ei))
    target = S_dash_list[si:ei]
    flag = True
    for i in reversed(range(len(T_list))):
        if S_dash_list[si + i] != T_list[i] and S_dash_list[si + i] != '?':
            flag = False
            # ここでsiとeiを更新
            ei = si + i + 1
            si = ei - len(T_list)
            break
    if flag:
        for i in range(len(T_list)):
            S_dash_list[si + i] = T_list[i]
        insert_flag = True
        break

if not insert_flag:
    print('UNRESTORABLE')
else:
    ans = ''.join(S_dash_list)
    #print(ans)

    # '?'をaで埋める
    print(ans.replace('?', 'a'))

### FIXED CODE ###

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

S_dash = input()
T = input()

S_dash_list = list(S_dash)
T_list = list(T)

ei = len(S_dash_list)
si = ei - len(T_list)

insert_flag = False
while si >= 0:
    #print('si: {}, ei: {}'.format(si, ei))
    target = S_dash_list[si:ei]
    flag = True
    for i in reversed(range(len(T_list))):
        if S_dash_list[si + i] != T_list[i] and S_dash_list[si + i] != '?':
            flag = False
            # ここでsiとeiを更新
            ei -= 1
            si = ei - len(T_list)
            break
    if flag:
        for i in range(len(T_list)):
            S_dash_list[si + i] = T_list[i]
        insert_flag = True
        break

if not insert_flag:
    print('UNRESTORABLE')
else:
    ans = ''.join(S_dash_list)
    #print(ans)

    # '?'をaで埋める
    print(ans.replace('?', 'a'))
### BUGGY CODE ###

#!/usr/bin/python
N, M = list(map(int, input().split()))
X = list(map(int, input().split()))
x = sorted(X)
i = 0
diff = []
while i + 1 < len(x):
    diff.append(x[i] - x[i + 1])
    i += 1
d = sorted(diff)[:N - 1]
i = 0
sum = 0
for _ in x:
    if i + 1 < len(x):
        if x[i] - x[i + 1] in d:
            d.remove(x[i] - x[i + 1])
        else:
            sum = sum + abs(x[i] - x[i + 1])
    i += 1
print(sum)

### FIXED CODE ###

#!/usr/bin/python
N, M = list(map(int, input().split()))
X = list(map(int, input().split()))
x = sorted(X)
i = 0
diff = []
while i + 1 < len(x):
    diff.append(x[i] - x[i + 1])
    i += 1
d = sorted(diff)[N - 1:]
print(abs(sum((d))))
### BUGGY CODE ###

from collections import deque
import copy
def solve(maze, start):
  memo = deque()
  q = deque()
  q.append([start,0])
  ans = 0
  while q:
    cur, cnt = q.popleft()
    if cur in memo:
      continue
    else:
      ans = max(ans, cnt)
      memo.append(cur)
      for y, x in zip((0,0,1,-1),(1,-1,0,0)):
        if maze[cur[0]+y][cur[1]+x] == ".":
          q.append([[cur[0]+y,cur[1]+x],cnt+1])
  return ans


H, W = map(int, input().split())
Maze = [["#"]*(W+2)]+[["#"]+list(input())+["#"] for _ in range(H)] + [["#"]*(W+2)]
Ans = 0
for sy in range(1, H+1):
  for sx in range(1, W+1):
    if Maze[sy][sx] == "#":
      continue
    else:
      Ans = max(Ans, solve(Maze, [sy, sx]))
print(Ans)

### FIXED CODE ###

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


def f(i, j):
    t = [[-1] * W for _ in range(H)]
    t[i][j] = 0
    q = [(i, j)]
    while q:
        y, x = q.pop(0)
        if y - 1 >= 0 and S[y - 1][x] != '#' and t[y - 1][x] == -1:
            t[y - 1][x] = t[y][x] + 1
            q.append((y - 1, x))
        if y + 1 < H and S[y + 1][x] != '#' and t[y + 1][x] == -1:
            t[y + 1][x] = t[y][x] + 1
            q.append((y + 1, x))
        if x - 1 >= 0 and S[y][x - 1] != '#' and t[y][x - 1] == -1:
            t[y][x - 1] = t[y][x] + 1
            q.append((y, x - 1))
        if x + 1 < W and S[y][x + 1] != '#' and t[y][x + 1] == -1:
            t[y][x + 1] = t[y][x] + 1
            q.append((y, x + 1))
    return max(max(tt) for tt in t)


result = 0
for i in range(H):
    for j in range(W):
        if S[i][j] != '#':
            result = max(result, f(i, j))
print(result)
### BUGGY CODE ###

from bisect import bisect_left
n = int(input())
A=[int(input()) for _ in range(n)]
row = []
for a in A:
    if (not row) or a<=row[-1]:
        row.append(a)
    else:
        row[len(row) - bisect_left(row[::-1],a)] = a
print(len(row))

### FIXED CODE ###

from bisect import bisect_left
from collections import deque
n = int(input())
A=[int(input()) for _ in range(n)]
q=deque()
for a in A:
    i=bisect_left(q,a)
    if not i:
        q.appendleft(a)
    else:
        q[i-1]=a
print(len(q))
### BUGGY CODE ###

INF = 1e10

H, W = list(map(int, input().split()))
c = []
cnt = 0
for y in range(H):
    c.append(input())
    for s in c[-1]:
        if s=='.':
            cnt+=1
    
def search(syx, gyx):
    sy,sx = syx
    gy,gx = gyx
    visited = [[INF]*W for _ in range(H)]
    q = [[sy,sx]]
    visited[sy][sx]=0
    while visited[gy][gx]==INF:
        tmp_q = []
        for one in q:
            cy,cx = one
            for dy, dx in ((1, 0), (-1, 0), (0, 1), (0, -1)):
                ny, nx = cy+dy, cx+dx
                if 0 <= nx < W and 0 <= ny < H and c[ny][nx] == '.' and visited[ny][nx]> visited[cy][cx]+1:
                    visited[ny][nx] = visited[cy][cx]+1
                    tmp_q.append([ny,nx])
        q = tmp_q
    return visited[gy][gx]

print(cnt-search([0,0],[H-1,W-1])-1)

### FIXED CODE ###

INF = 1e10

H, W = list(map(int, input().split()))
c = []
cnt = 0
for y in range(H):
    c.append(input())
    for s in c[-1]:
        if s=='.':
            cnt+=1
    
def search(syx, gyx):
    sy,sx = syx
    gy,gx = gyx
    visited = [[INF]*W for _ in range(H)]
    q = [[sy,sx]]
    visited[sy][sx]=0
    while len(q)>0:
        tmp_q = []
        for one in q:
            cy,cx = one
            for dy, dx in ((1, 0), (-1, 0), (0, 1), (0, -1)):
                ny, nx = cy+dy, cx+dx
                if 0 <= nx < W and 0 <= ny < H and c[ny][nx] == '.' and visited[ny][nx]> visited[cy][cx]+1:
                    visited[ny][nx] = visited[cy][cx]+1
                    tmp_q.append([ny,nx])
        q = tmp_q
        if visited[gy][gx]!=INF:
            break
    return visited[gy][gx]

ans = search([0,0],[H-1,W-1])
if ans==INF:
    print(-1)
else:
    print(cnt-ans-1)
### BUGGY CODE ###

def main():
    import sys
    input = sys.stdin.readline
    n, k = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort()
 
    import bisect
    def ok(x):
        # x以下になる組み合わせがk個以上
        cnt = 0
        for a in A:
            if a*a <= x:
                cnt -= 1
            if a > 0:
                c = x//a
                cnt += bisect.bisect_right(A, c)
            elif a < 0:
                c = (-x-1)//(-a)
                cnt += n - bisect.bisect_right(A, c)
            else:
                if x >= 0:
                    cnt += n
        cnt = cnt//2
        if cnt >= k:
            return True
        else:
            return False
 
    l = -10**18-1
    r = 10**18+1
    while l+1 < r:
        m = (l+r)//2
        if ok(m):
            r = m
        else:
            l = m
    print(r)
 
if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
#sys.setrecursionlimit(10**9)
input = sys.stdin.readline

import numpy as np

n, k = map(int, input().split())
A = np.array(input().split(), np.int64)
A = np.sort(A)

P = A[A>0]
Z = A[A==0]
N = A[A<0]

#t = n*(n-1)//2

def ok(x):
    # x以下になる組み合わせがk個以上
    cnt = 0
    #cnt += np.searchsorted(A, np.ceil(x/P), side='right').sum()
    cnt += np.searchsorted(A, x//P, side='right').sum()
    #cnt += n-np.searchsorted(A, np.floor(x/N), side='left').sum()
    cnt += (n-np.searchsorted(A, (-x-1)//(-N), side='right')).sum()
    if x >= 0:
        cnt += len(Z)*n
    cnt -= np.count_nonzero(A*A <= x)
    cnt = cnt//2
    if cnt >= k:
        return True
    else:
        return False

l = -10**18-1
r = 10**18+1
while l+1 < r:
    c = (l+r)//2
    if ok(c):
        r = c
    else:
        l = c
print(r)
### BUGGY CODE ###

import numpy as np
n = int(input())
hoge = [int(input()) for i in range(n)]

for i in range(len(hoge)):
    temp = hoge.copy()
    del temp[i]
    print(np.array(temp).max())

### FIXED CODE ###

n = int(input())
hoge = [int(input()) for i in range(n)]
max_value = max(hoge)
second_value = sorted(hoge)[-2]
if max_value == second_value:
    for i in range(len(hoge)):
        print(max_value)
else:
    for i in hoge:
        if i != max_value:
            print(max_value)
        else:
            print(second_value)
### BUGGY CODE ###

import sys
def solve(i,j,dp,w,v):
    if dp[i][j]!=0:
        return dp[i][j]
    else:
        if i==0:
            dp[i][j]=0
            return dp[i][j]
        if j<w[i-1]:
            dp[i][j]=solve(i-1,j,dp,w,v)
            return dp[i][j]
        else:
            dp[i][j]=max(solve(i-1,j,dp,w,v),solve(i-1,j-w[i-1],dp,w,v)+v[i-1])
            return dp[i][j]
sys.setrecursionlimit(10000000)
N,W=map(int,input().split())
w=[0 for i in range(N)]
v=[0 for i in range(N)]
for i in range(N):
    w[i],v[i]=map(int,input().split())
dp=[[0 for j in range(W+1)] for i in range(N+1)]
print(solve(N,W,dp,w,v))


### FIXED CODE ###

import numpy as np
N,W=map(int,input().split())
w=[0 for i in range(N)]
v=[0 for i in range(N)]
for i in range(N):
    w[i],v[i]=map(int,input().split())
dp=[0 for i in range(W+1)]
dp=np.array(dp)
for i in range(N):
    dp[w[i]:]=np.maximum(dp[w[i]:],dp[:W-w[i]+1]+v[i])
print(dp.max())
### BUGGY CODE ###

S = input()
Q = int(input())
Q_list = list()
for i in range(Q):
    Q_list.append(input().split())

def operate(i):
    global count, S_n, word
    str_list = [S_n]
    if Q_list[i][0] == '1':
        count += 1
    else:
        if count % 2 == 0:
            if Q_list[i][1] == '1':
                word = [Q_list[i][2]] + str_list
            else:
                word = str_list + [Q_list[i][2]]
        else:
            if Q_list[i][1] == '1':
                word = str_list + [Q_list[i][2]]
            else:
                word = [Q_list[i][2]] + str_list
    
    S_n = ''.join(word)

S_list = [i for i in S]
check = 0
for i in range(Q):
    if Q_list[i][0] == '1':
        check += 1

if check % 2 == 1:
    S_list = list(reversed(S_list))

S_n = ''.join(S_list)

count = check % 2
for i in range(Q):
    operate(i)
print(''.join(S_n))

### FIXED CODE ###

S = input()
Q = int(input())
Q_list = list()
for i in range(Q):
    Q_list.append(input().split())

from collections import deque
def operate(i):
    global count, str_list
    if Q_list[i][0] == '1':
        count += 1
    else:
        if count % 2 == 0:
            if Q_list[i][1] == '1':
                str_list.appendleft(Q_list[i][2])
            else:
                str_list.append(Q_list[i][2])
        else:
            if Q_list[i][1] == '1':
                str_list.append(Q_list[i][2])
            else:
                str_list.appendleft(Q_list[i][2])

check = 0
for i in range(Q):
    if Q_list[i][0] == '1':
        check += 1

S_list = [i for i in S]
if check % 2 == 1:
    S_list = list(reversed(S_list))

S_n = ''.join(S_list)

str_list = deque()
str_list.append(S_n)
count = check%2
for i in range(Q):
    operate(i)
print(''.join(str_list))
### BUGGY CODE ###

import sys
import math
#import fractions
from functools import reduce
import itertools

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'
def euclid(a, b):
    while b:
        a, b = b, a%b
    return a
# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

def gcd_list(numbers):
    return reduce(euclid, numbers)

N = II()
l = []
for i in range(1,N+1):
    l.append(i)
ans=0

num = 3 #生成するビット数
bit_list = list(itertools.product(l, repeat=num))

for L in bit_list:
    ans += gcd_list(L)
print(ans)


### FIXED CODE ###

import sys
#import fractions
from math import gcd
import itertools

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

def gcd_list(numbers):
    return reduce(gcd, numbers)

def euclid(p,q):
    if p%q==0:
        return q
    else:
        return euclid(q,p%q)


N = II()

ans=0

for i in range(1, N+1):
    for j in range(1, N+1):
        x = gcd(i,j)
        for k in range(1, N+1):
            ans+=gcd(x,k)


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

#!/usr/bin/env python3
#n,p = map(int,input().split())
s=input()[::-1]
p = 2019
n = len(s)
ans = 0
l = [0 for i in range(p)]
l[0] = 1
z = 0
ten = 1
tmp = 0
for i in s:
    i = int(i)
    tmp=(tmp+i*ten)%p
    ten = ten*10
    l[tmp]+=1
for i in l:
    ans+= i*(i-1)//2
print(ans)


### FIXED CODE ###

p = 2019
s = input()
n = len(s)
l = [0 for i in range(p)]
l[0] = 1
ten = 1
cnt = 0
 
ans = 0
if p == 2 or p == 5:
    for i in range(n):
        if int(s[i]) % p == 0:
            ans += i+1
else:
    for i in range(n):
        cnt = (cnt + int(s[-i-1]) * ten) % p
        l[cnt] += 1
        ten = (ten * 10) % p
    for i in l:
        if i > 1:
            ans += i * (i - 1) // 2
print(ans)
### BUGGY CODE ###

n= int(input())
s = input()

ans = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        if s[i] == s[j]:
            continue
        else:
            for k in range(j+1, n):
                if s[i] == s[k] or s[j] == s[k] or j - i == k - j:
                    continue
                else:
                    ans += 1

print(ans)

### FIXED CODE ###

n= int(input())
s = input()

cnt_r = s.count('R')
cnt_g = s.count('G')
cnt_b = s.count('B')

ans = cnt_r * cnt_g * cnt_b

for i in range(n):
    for d in range(n):
        j = i + d
        k = j + d
        if k >= n:
            break
        if s[i] != s[j] and s[j] != s[k] and s[i] != s[k]:
            ans -= 1

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

import heapq
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))

A.sort()
F.sort(reverse=True)

r = A[-1]*F[0]

l = -1

while(r-l > 1):
    tmp = (l+r)//2
    k = 0
    for x, y in zip(A, F):
        k += max(0, x - (tmp // y))
    if k > K:
        l = tmp
    else:
        r = tmp
print(r)


### FIXED CODE ###

import sys
import bisect
import math
input = sys.stdin.readline
N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))

A.sort()
F.sort(reverse=True)

B = [(A[i]*F[i], F[i]) for i in range(N)]
B.sort(reverse=True)
L = 0
R = B[0][0]
if sum(A) <= K:
    print(0)
    exit(0)
while(1):
    ans = (L+R) // 2
    flag = True
    tmp = 0
    for i in range(N):
        tmp += math.ceil(max(B[i][0] - ans, 0) / B[i][1])
        if tmp > K:
            flag = False
            break
    if flag:
        R = ans
    else:
        L = ans
    if L == R or L+1 == R:
        print(R)
        break
### BUGGY CODE ###

n = input()
a = list(map(int,input().split()))
cnt = 1
for i in a:
    cnt *= i
if cnt > 10 **18:
    print(-1)
else:
    print(cnt)

### FIXED CODE ###

n = input()
a = list(map(int,input().split()))
b = set(a)
if 0 in b:
    print(0)
else:
    cnt = 1
    for i in a:
        cnt *= i
        if cnt > 10 ** 18:
            break
    if cnt > 10**18:
        print(-1)
    else:
        print(cnt)
### BUGGY CODE ###

def main() -> None:
    S = list(input())
    m = len(S)
    pre = len(S)
    while len(S) > 0:
        for i in range(len(S) - 1):
            if len(S) > i + 1:
                if S[i] != S[i+1]:
                    S.remove(S[i])
                    S.remove(S[i])
            else:
                break

        # 抜けなかった
        if pre == len(S):
            break
        else:
            pre = len(S)

    # 最初の数から引けば抜いた数
    print(m - len(S))


if __name__ == '__main__':
    main()


### FIXED CODE ###

import collections


def main() -> None:
    S = list(input())
    a = collections.Counter(S)
    zero = a['0']
    one = a['1']
    if zero >= one:
        print(one * 2)
    else:
        print(zero * 2)


if __name__ == '__main__':
    main()