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

# -*- coding: utf-8 -*-
from functools import reduce

h, w = map(int, input().split())
a = []
b = set([])

for i in range(h):
    a.append(list(input()))
    for j in range(w):
        if (a[i][j] == '#'):
            b.add((i, j))


def addBlack(bl, t):
    bl.add(t)
    if t[0] - 1 >= 0:
        bl.add((t[0] - 1, t[1]))
    if t[0] + 1 < w:
        bl.add((t[0] + 1, t[1]))
    if t[1] - 1 >= 0:
        bl.add((t[0], t[1] - 1))
    if t[1] + 1 < h:
        bl.add((t[0], t[1] + 1))
    return bl


count = 0
while(len(b) < h * w):
    count += 1
    b = reduce(addBlack, b, set([]))

print(count)


### FIXED CODE ###

# -*- coding: utf-8 -*-
h, w = map(int, input().split())
a = []
a = [[True] * (w + 2)]
for i in range(h):
    a.append([True] + [x == '#' for x in input()] + [True])
a.append([True] * (w + 2))
q = []

for i in range(1, h + 1):
    for j in range(1, w + 1):
        if a[i][j]:
            q.append((i, j))

count = 0
while True:
    qq = []
    for i, j in q:
        if not a[i-1][j]:
            a[i-1][j] = True
            qq.append((i - 1, j))
        if not a[i+1][j]:
            a[i+1][j] = True
            qq.append((i + 1, j))
        if not a[i][j-1]:
            a[i][j-1] = True
            qq.append((i, j - 1))
        if not a[i][j+1]:
            a[i][j+1] = True
            qq.append((i, j + 1))
    q = qq
    if len(q) <= 0:
        break
    count += 1

print(count)
### BUGGY CODE ###

k=int(input())
import math
cnt=3*k**2-3*k+1
for a in range(2,k+1):
    for b in range(2,k+1):
        for c in range(2,k+1):
            cnt+=math.gcd(math.gcd(a,b),c)
print(cnt)


### FIXED CODE ###

k=int(input())
import math
if k==1:
    print(1)
else:
    s1=k*(k+1)//2
    s2=k-1
    for i in range(2,k):
        for j in range(i+1,k+1):
                s2+=math.gcd(i,j)
    s2=s2*6
    s3=0
    if k>2:
        for a in range(1,k-1):
            for b in range(a+1,k):
                for c in range(b+1,k+1):
                    s3+=math.gcd(math.gcd(a,b),c)
        s3=s3*6
    print(s1+s2+s3)
### BUGGY CODE ###

s = input()
x, y = (int(x) for x in input().split())
X = []
Y = []
cnt, turn = 0, 0
s += 'T'
for c in s:
    if c == 'F':
        cnt += 1
    else:
        if turn & 1:
            Y.append(cnt)
            turn = 0
        else:
            X.append(cnt)
            turn = 1
        cnt = 0
lenX = len(X)-1
Xmoveable = {X[0] + sum(-X[i+1] if bit & (1<<i) else X[i+1] for i in range(lenX)) for bit in range(2**lenX)}
lenY = len(Y)
Ymoveable = {sum(-Y[i] if bit & (1<<i) else Y[i] for i in range(lenY)) for bit in range(2**lenY)}

if x in Xmoveable and y in Ymoveable:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

from collections import defaultdict
def main():
    S = input() + 'T'
    x, y = map(int, input().split())
    #データ加工
    moveX, moveY = [], []
    if S[0] == 'T': moveX.append(0)
    move ={0:moveX, 1:moveY}
    direct = 0
    step = 0
    for s in S:
        if s == 'T':
            if step > 0:
                move[direct].append(step)
                step = 0
            direct ^= 1 
        else:
            step += 1
    #判定
    if possible(x, moveX[1:], moveX[0]) and possible(y, moveY):
        print('Yes')
    else:
        print('No')


def possible(target, move, offset=0):
    l = len(move)
    dp = [defaultdict(lambda:False) for _ in range(l+1)]
    #初期化
    dp[0][0] = True
    for i,m in enumerate(move):
        for key in dp[i]:
            dp[i+1][key+m] = True
            dp[i+1][key-m] = True
    return dp[l][target-offset]


main()
### BUGGY CODE ###

def gcd(x, y):
    while y > 0:
        r = x%y
        x = y
        y = r
    return x

def lcm(x, y):
    return x//gcd(x, y)*y

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

l = 1
for x in a:
    l = lcm(x, l)

ans = 0
for x in a:
    ans += l//x

print(ans%(10**9+7))

### FIXED CODE ###

def gcd(x, y):
    while y > 0:
        r = x%y
        x = y
        y = r
    return x

def lcm(x, y):
    return x//gcd(x, y)*y

def modpow(x, n, mod):
    res = 1
    while n > 0:
        if n%2 == 1:
            res = res*x%mod
        x = x*x%mod
        n >>= 1
    return res

mod = 10**9+7

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

g = 0
for x in a:
    g = gcd(g, x)

l = 1
for i in range(n):
    a[i] //= g
    l = lcm(l, a[i])
l %= mod

ans = 0
for i in range(n):
    ans += l*modpow(a[i], mod-2, mod)
    ans %= mod

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

import sys
sys.setrecursionlimit(1000000)
class Node:
  def __init__(self, n):
    self.number = n
    self.children = []
    self.value = 0
def add_values(nodes, i, x):
  n = nodes[i]
  n.value += x
  for c in n.children:
    add_values(nodes, c, x)
n, q = map(int, input().split())
nodes = [Node(i) for i in range(0, n + 1)]
nodes[0] = None
for i in range(n - 1):
  a, b = map(int, input().split())
  nodes[a].children.append(b)
for _ in range(q):
  p, x = map(int, input().split())
  add_values(nodes, p, x)
print(' '.join(str(nodes[i].value) for i in range(1, n + 1)))


### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)
def main():
  _map = map
  _input = input
  _int = int
  def calc_results(results, pvalue, i):
    results[i] = pvalue + values[i]
    for j in childrens[i]:
      calc_results(results, results[i], j)
  n, q = _map(_int, _input().split())
  values = [0] * (n + 1)
  results = [0] * (n + 1)
  childrens = [[] for _ in range(n + 1)]
  for i in range(n - 1):
    a, b = _map(_int, _input().split())
    childrens[a].append(b)
  for _ in range(q):
    p, x = _map(_int, _input().split())
    values[p] += x
  calc_results(results, 0, 1)
  print(*[results[i] for i in range(1, n + 1)])
main()
### BUGGY CODE ###

import itertools
import sys

N, N1 = tuple([int(x) for x in sys.stdin.readline().split()])
D, C = [], []

for _ in range(N1):
    D.append([int(x) for x in sys.stdin.readline().split()])
for _ in range(N):
    C.append([int(x) for x in sys.stdin.readline().split()])

color_count = [[0] * N1 for _ in range(3)]
for i in range(N):
    for j in range(N):
        color_count[(i + j) % 3][C[i][j] - 1] += 1

min_cost = 2**64
for colors in itertools.permutations(range(N1)):
    cost = 0
    for j in range(N1):
        cost += color_count[0][j] * D[j][colors[0]]
        cost += color_count[1][j] * D[j][colors[1]]
        cost += color_count[2][j] * D[j][colors[2]]
    if cost < min_cost:
        min_cost = cost
print(min_cost)

### FIXED CODE ###

import itertools
import sys

N, N1 = tuple([int(x) for x in sys.stdin.readline().split()])
D, C = [], []

for _ in range(N1):
    D.append([int(x) for x in sys.stdin.readline().split()])
for _ in range(N):
    C.append([int(x) for x in sys.stdin.readline().split()])

color_count = [[0] * N1 for _ in range(3)]
for i in range(N):
    for j in range(N):
        color_count[(i + j) % 3][C[i][j] - 1] += 1

min_cost = 2**64
for c0 in range(N1):
    for c1 in range(N1):
        if c0 == c1:
            continue
        for c2 in range(N1):
            if c0 == c2 or c1 == c2:
                continue
            cost = 0
            for j in range(N1):
                cost += color_count[0][j] * D[j][c0]
                cost += color_count[1][j] * D[j][c1]
                cost += color_count[2][j] * D[j][c2]
            if cost < min_cost:
                min_cost = cost

print(min_cost)
### BUGGY CODE ###

import bisect

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

Q = int(input())
s = [list(map(int,input().split())) for i in range(Q)]
for i in range(Q):
  search = s[i][0]
  A.sort()
  b=bisect.bisect_left(A,search)
  c=bisect.bisect_right(A,search)
  for j in range(b,c):
    A[j] = s[i][1]
  print(sum(A))



### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
Q = int(input())
BC = [list(map(int,input().split())) for i in range(Q)]
B, C = [list(i) for i in zip(*BC)]
#print(B,C,BC)

dic = {}
for a in A:
  dic[a] = dic.get(a,0) + 1
#print(dic)

ans = sum(A)
for q in range(Q):
  ans = ans + (C[q]-B[q]) * dic.get(B[q],0)
  dic[C[q]] = dic.get(B[q],0) + dic.get(C[q],0)
  dic[B[q]] = 0
  print(ans)
### BUGGY CODE ###

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

import itertools
l = list(itertools.combinations(L, 3))

a = 0
n = 0

for x in range(len(l)):
  m = max(l[n])
  if m < sum(l[n]) - m:
    a += 1
    n += 1
  else:
    n += 1
    
print(a)

### FIXED CODE ###

n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0
from bisect import bisect_left
for i in range(n-2):
  for j in range(i+1, n-1):
    ab = l[i] + l[j]
    idx = bisect_left(l, ab)
    ans += max(idx-j-1, 0)
print(ans)
### BUGGY CODE ###

N, M = [int(_) for _ in input().split()]
ab = [input().split() for _ in range(M)]

for i in ab:
    if i[0] == "1":   
        for j in ab:
            if j[0] == i[1] and j[1] == str(N):
                print("POSSIBLE")
                exit()

print("IMPOSSIBLE")

### FIXED CODE ###

N, M = [int(_) for _ in input().split()]
ab = [input().split() for _ in range(M)]

goal = {i:0 for i in range(1, N+1)}
N = str(N)

ne = []
for i in ab:
    if i[0] == "1":
        goal[int(i[1])] = 1

for j in ab:
    if goal[int(j[0])] and j[1] == N:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")
### BUGGY CODE ###

S = int(input())
for i in range(1,int(S**0.5)+1):
    if(S%i==0):
        j = S//i
        if(j>10**9):continue
        print(0,0,i,0,0,j)
        break


### FIXED CODE ###

S = int(input())
x3 = 10**9-S%(10**9)
x3 = 0 if x3 == 10**9 else x3
y3 = (S+x3)//(10**9)
print(0,0,10**9,1,x3,y3)
### BUGGY CODE ###

N = int(input())
ans = 0
ans_list = [1]

if N != 1:
  for i in range(2, N // 2 + 1):
    if N % i == 0:
      ans_list.append(i)

for i in ans_list:
  if N/i - 1 > i:
    ans += N/i - 1
  else:
    break;
print(int(ans))

### FIXED CODE ###

import math
N = int(input())
ans = 0
s = math.sqrt(N)
for i in range(1, math.ceil(s)):
  if N%i == 0:
    a = N/i - 1
    if a > i:
      ans += a
    else:
      break;
print(int(ans))
### BUGGY CODE ###

from collections import Counter
N, K = list(map(int,input().split()))
listA = Counter(input().split())
# print(listA)
listA = list(listA.values())
listA.sort()
# print(listA)

num = 0
# print(listA)
if len(listA) <= K:
    num = 0
else:
    while len(listA) > K:
        tmp = listA.pop(0)
        listA[len(listA)-1] += tmp
        num += tmp

print(num)



### FIXED CODE ###

from collections import Counter
N, K = list(map(int,input().split()))
listA = Counter(input().split())
# print(listA)
listA = list(listA.values())
listA.sort()
times = len(listA) - K

num = 0

if times <= 0:
    num = 0
else:
    for i in range(times):
        num += listA[i]

print(num)
### BUGGY CODE ###

n=int(input())
alis=list(map(int,input().split()))
p=alis[0]

for i in range(1,n):
  p*=alis[i]
  
if len(list(str(p)))>18:
  sa=list(map(int,list(str(p))))
    
  if sum(sa)!=1:
    print(-1)
    exit()
print(p)

### FIXED CODE ###

n=int(input())
alis=sorted(list(map(int,input().split())))
p=alis[0]
if p==0:
  print(0)
  exit()
bre=False
for i in range(1,n):
  p*=alis[i]
  
  
  if len(list(str(p)))>18:
    bre=True
    break


if bre:
  sa=list(map(int,list(str(p))))
  if sum(sa)!=1:print(-1)
  else:print(p)
else:print(p)
### BUGGY CODE ###

N=input()
A=list(map(int,input().split()))
ans=0
for i in range(len(A)-1):
    for j in range(len(A)-i-1):
        ans+=A[i]*A[i+j+1]
        ans%=10**9+7
print(ans)

### FIXED CODE ###

N=input()
A=list(map(int,input().split()))
ans=0
S=sum(A)
M=10**9+7
for i in A:
    S-=i
    ans+=i*S%M
    ans%=M
print(ans)
### BUGGY CODE ###

N = int(input())
def func(T_pre, A_pre, T, A):
  for i in range(1, 10**10):
    if T_pre <= T and A_pre <= A:
      return T, A
    else:
      T = T*(i+1)/i
      A = A*(i+1)/i
for i in range(N):
  T, A = map(int, input().split())
  if i == 0:
    T_pre = T
    A_pre = A
  else:
    T_pre, A_pre = func(T_pre, A_pre, T, A)
print(int(T_pre+A_pre))

### FIXED CODE ###

N = int(input())
def func(T_pre, A_pre, T, A):
  if T_pre <= T and A_pre <= A:
    return T, A
  else:
    t = -(-T_pre//T)
    a = -(-A_pre//A)
    x = max(t, a)
    return T*x, A*x
for i in range(N):
  T, A = map(int, input().split())
  if i == 0:
    T_pre = T
    A_pre = A
  else:
    T_pre, A_pre = func(T_pre, A_pre, T, A)
print(int(T_pre+A_pre))
### BUGGY CODE ###

n, k, q = map(int, input().split())
A = [0] * q
for i in range(q):
    A[i] = int(input())
score = [k] * n
for a in A:
    for i in range(n):
        if i != a-1:
            score[i] -= 1
for i in range(n):
    if score[i] <= 0:
        print('No')
    else:
        print('Yes')

### FIXED CODE ###

n, k, q = map(int, input().split())
A = [0] * q
for i in range(q):
    A[i] = int(input())
score = [k - q] * n
for a in A:
    score[a-1] += 1
# print(score)
for i in range(n):
    if score[i] <= 0:
        print('No')
    else:
        print('Yes')
### BUGGY CODE ###

modulo = 1000000007

import sys
sys.setrecursionlimit(100000009)

muchii = []


def recursie(x, y):
    alb = 1
    negru = 1
    for elem in muchii[x]:
        if x == y:
            continue
        result_1, result_2 = recursie(elem, x)
        alb = (alb * (result_1 + result_2)) % modulo
        negru = (negru * result_1) % modulo
    return alb, negru
    

if __name__ == "__main__":
    
    n = int(input())
    for i in range(n):
        muchii.append([])
        
    for i in range(n-1):
        numbers = list(map(int, input().split()))
        
        x = numbers[0]
        y = numbers[1]
        
        muchii[x-1].append(y-1)
        muchii[y-1].append(x-1)
        
    result_1, result_2 = recursie(0, None)
    
    result = (result_1 + result_2) % modulo
    
    print(result)


### FIXED CODE ###

modulo = 1000000007

import sys
sys.setrecursionlimit(100000009)


muchii = []


def recursie(x, y):
    alb = 1
    negru = 1
    for elem in muchii[x]:
        if elem == y:
            continue
        result_1, result_2 = recursie(elem, x)
        alb = (alb * (result_1 + result_2)) % modulo
        negru = (negru * result_1) % modulo
    return alb, negru
    

if __name__ == "__main__":
    input = sys.stdin.readline
    n = int(input())
    for i in range(n):
        muchii.append([])
        
    for i in range(n-1):
        numbers = list(map(int, input().split(" ")))
        
        x = numbers[0]
        y = numbers[1]
        
        muchii[x-1].append(y-1)
        muchii[y-1].append(x-1)
        
    result_1, result_2 = recursie(0, None)
    
    result = (result_1 + result_2) % modulo
    
    print(result)
### BUGGY CODE ###

"""
"""
n,x,y=map(int,input().split())
k_mins=[]
for i in range(1,n):
    for j in range(i+1,n+1):
        k_mins.append(min(j-i,abs(x-i)+1+abs(y-j),abs(x-j)+1+abs(y-i)))
ret=[]
k_mins.sort(reverse=True)
for i in range(1,n):
    c=0
    while len(k_mins) > 0 and k_mins[len(k_mins)-1]==i:
        k_mins.pop() 
        c+=1
    ret.append(c)
for r in ret:
    print(r)




### FIXED CODE ###

"""
"""
n,x,y=map(int,input().split())
ret=[0]*(n-1)
for i in range(1,n):
    for j in range(i+1,n+1):
        ret[min(j-i,abs(x-i)+1+abs(y-j),abs(x-j)+1+abs(y-i))-1]+=1
for r in ret:
    print(r)
### BUGGY CODE ###

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

for i in range(n):
    b = [0] + a[:i] + a[i+1:] + [0]
    d = 0
    for j in range(len(b)-1):
        d += abs(b[j]-b[j+1])
    print(d)

### FIXED CODE ###

n = int(input())
a = [0] + list(map(int, input().split())) + [0]
cost = 0
for i in range(n+1):
    cost += abs(a[i] - a[i+1])
    
for j in range(1, n+1):
    if a[j-1] <= a[j] <= a[j+1] or a[j-1] >= a[j] >= a[j+1]:
        print(cost)
    else:
        print(cost - min(abs(a[j] - a[j-1]), abs(a[j] - a[j+1]))*2)
### BUGGY CODE ###

n = int(input())
alist = list(map(int, input().split()))
attends = [alist.index(x) + 1 for x in range(1, n + 1)]
print(*attends)

### FIXED CODE ###

n = int(input())
attends = dict(enumerate(list(map(int, input().split())), start=1))
attends_sorted = sorted(attends.items(), key=lambda x: x[1])
arr = [x[0] for x in attends_sorted]
print(*arr)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**6)

N, Q = list(map(int, input().split()))
nodes = [[] for i in range(N)]
for i in range(N-1):
  r, e = list(map(int, input().split()))
  r, e = r - 1, e - 1
  nodes[r].append(e)
  nodes[e].append(r)
#print(nodes)

result = [0] * N
for i in range(Q):
  r, s = list(map(int, input().split()))
  result[r-1] += s

def dfs(r, prev=-1):
  for i in nodes[r]:
    if i == prev:
      continue
    result[i] += result[r]
    dfs(i, r)

dfs(0)
#ここのせい？
print(*result)


### FIXED CODE ###

#人の（ほぼ同じなのにうまくいかないので）
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

N, Q = map(int, input().split())
lines = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    lines[a-1].append(b-1)
    lines[b-1].append(a-1)
ans = [0]*N
for _ in range(Q):
    p, x = map(int, input().split())
    ans[p-1] += x

def dfs(v, parent):
    for u in lines[v]:
        if u != parent:
            ans[u] += ans[v]
            dfs(u, v)

dfs(0, -1)
print (*ans)
### BUGGY CODE ###

import sys

def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    if sum(A) < sum(B):
        print(-1)
        sys.exit()

    if all(map(lambda ab: ab[0] > ab[1], zip(A, B))):
        print(0)
        sys.exit()

    bigger_diff = list(map(lambda ab: max(ab[0] - ab[1], 0), zip(A, B)))
    lesser_diff = list(map(lambda ab: min(ab[0] - ab[1], 0), zip(A, B)))
    shortage = sum(map(lambda ab: min(ab[0] - ab[1], 0), zip(A, B)))


    ans = len(list(filter(lambda d: d<0, lesser_diff)))

    bigger_diff = sorted(bigger_diff, reverse=True)

    for i in range(len(bigger_diff)):
        if sum(bigger_diff[:i]) >= abs(shortage):
            ans += i
            break
    print(ans)



if __name__=='__main__':
    main()


### FIXED CODE ###

import sys

def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    AB = list(zip(A, B))
    bigger_diff = list(map(lambda ab: max(ab[0] - ab[1], 0), AB))
    lesser_diff = list(map(lambda ab: min(ab[0] - ab[1], 0), AB))
    exceeded = sum(bigger_diff)
    shortage = sum(lesser_diff)

    if exceeded < abs(shortage):
        print(-1)
        sys.exit()

    if all(map(lambda ab: ab[0] >= ab[1], AB)):
        print(0)
        sys.exit()



    ans = len(list(filter(lambda d: d<0, lesser_diff)))

    bigger_diff = sorted(bigger_diff, reverse=True)

    ss = 0
    for i in range(len(bigger_diff)):
        ss += bigger_diff[i]
        if ss >= abs(shortage):
            ans += i + 1
            break
    print(ans)



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

N=int(input())
p=1
for i in range(1,N+1):
    p=p*i
print(p%(10**9+7))


### FIXED CODE ###

N=int(input())
p=1
for i in range(1,N+1):
    p=p*i
    p=p%(10**9+7)
print(p)
### BUGGY CODE ###

n = int(input())
l = sorted(list(map(int,input().split())),reverse=True)
#print (l)

ans = 0
for i in range(n-1):
    for j in range(i+1,n):
#        print (l[i],l[j],l[j+1::],[x for x in l[j+1::] if x < l[i]+l[j] and l[i] < x+l[j] and l[j] < x+l[i]])
        ans += len([x for x in l[j+1::] if x < l[i]+l[j] and l[i] < x+l[j] and l[j] < x+l[i]])


print (ans)


### FIXED CODE ###

import bisect
n = int(input())
l = sorted(list(map(int,input().split())))

ans = 0
for i in range(n-1,1,-1):
    for j in range(i-1,0,-1):
        x = j - bisect.bisect(l,l[i]-l[j])
        if x>0:
            ans += x

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

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

LRDi = []
for _ in range(M):
    a = list(map(int, input().split()))
    LRDi.append(a)

tree = [None] * (N + 1)

def parent(n):
    if tree[n] is None:
        return [n, 0]
    d = distance_to_root(n)
    p = parent(tree[n][0])
    pp = [p[0], d]
    tree[n] = pp
    return pp

def distance_to_root(n):
    if tree[n] is None:
        return 0
    d = distance_to_root(tree[n][0])
    return d + tree[n][1]

for l, r, d in LRDi:
    lp = parent(l)
    rp = parent(r)
    if lp[0] != rp[0]:
        rd = distance_to_root(r)
        tree[rp[0]] = [lp[0], lp[1] + d - rd]
    else:
        d1 = distance_to_root(l)
        d2 = distance_to_root(r)
        if d1 + d != d2:
            print("No")
            exit()

print("Yes")


### FIXED CODE ###

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

LRDi = []
for _ in range(M):
    a = list(map(int, input().split()))
    LRDi.append(a)

#tree = [None] * (N + 1)
tree = [[i, 0] for i in range(N + 1)]

def parent(n):
    p = n
    while tree[p][0] != p:
        p = tree[p][0]
    if p == n:
        return tree[n]
    if p == tree[n][0]:
        return tree[n]
    d = distance_to_root(n)
    tree[n][0] = p
    tree[n][1] = d
    return tree[n]

def distance_to_root(n):
    ret = 0
    nn = n
    while tree[nn][0] != nn:
        ret += tree[nn][1]
        nn = tree[nn][0]
    return ret

for l, r, d in LRDi:
    lp = parent(l)
    rp = parent(r)
    if lp[0] != rp[0]:
        rd = distance_to_root(r)
        tree[rp[0]] = [lp[0], lp[1] + d - rd]
    else:
        d1 = distance_to_root(l)
        d2 = distance_to_root(r)
        if d1 + d != d2:
            print("No")
            exit()

print("Yes")
### BUGGY CODE ###

S = input()
cnt = 0
while True:
    flg = True
    for i in range(len(S)-1):
        if S[i] != S[i+1]:
            S = S[:i] + S[i+2:]
            flg = False
            cnt += 1
            break
    
    if flg:
        break

print(cnt*2)

### FIXED CODE ###

S = list(input())
a = S.count('0')
print(min(a,len(S)-a)*2)
### BUGGY CODE ###

# -*- coding:utf-8 -*-
n = int(input())
a = [int(i) for i in input().split()]
dp = [[x, 0] for x in range(0, len(a))]


def ins(x, i):
    if x in dp[i]:
        return
    if dp[i][0] != x and a[dp[i][0]] < a[x]:
        dp[i][1] = dp[i][0]
        dp[i][0] = x
    elif dp[i][1] != x and a[dp[i][1]] < a[x]:
        dp[i][1] = x


def mix(i, j):
    ins(dp[i][0], j)
    ins(dp[i][1], j)


for i in range(0, len(a)):
    for j in range(0, n):
        if i & (1 << j) == 0:
            mix(i, i | (1 << j))


ans = 0
for i in range(1, len(a)):
    u = a[dp[i][0]]+a[dp[i][1]]
    ans = max(ans, u)
    print(ans)


### FIXED CODE ###

# -*- coding:utf-8 -*-
n = int(input())
a = [int(i) for i in input().split()]
dp = [[x, 0] for x in range(0, len(a))]
 
 
def ins(x, i):
    if x in dp[i]:
        return
    if dp[i][0] != x and a[dp[i][0]] < a[x]:
        dp[i][1] = dp[i][0]
        dp[i][0] = x
    elif dp[i][1] != x and a[dp[i][1]] < a[x]:
        dp[i][1] = x
 
 
def mix(i, j):
    ins(dp[i][0], j)
    ins(dp[i][1], j)
 
 
for i in range(0, len(a)):
    for j in range(0, n):
        if i & (1 << j) == 0:
            mix(i, i | (1 << j))
 
 
ans = 0
for i in range(1, len(a)):
    u = a[dp[i][0]]+a[dp[i][1]]
    ans = max(ans, u)
    print(ans)