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

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, _, W = MAP()
A = [W] + LIST()

# memo[i][j] := 先手が最後にi枚目、後手が最後にj枚目を取った状態
memo = list2d(N+1, N+1, -INF)
def rec(a, b):
    if memo[a][b] != -INF:
        return memo[a][b]
    # 終了条件(どちらかが最後まで札を取った)
    if a == N or b == N:
        res = abs(A[a]-A[b])
        memo[a][b] = res
        return res
    nxt = max(a, b)
    turn = 0 if a < b else 1
    if turn % 2 == 0:
        res = -INF
        for i in range(nxt+1, N+1):
            res = max(res, rec(i, b))
    else:
        res = INF
        for i in range(nxt+1, N+1):
            res = min(res, rec(a, i))
    memo[a][b] = res
    return res

ans = rec(-1, 0)
print(ans)


### FIXED CODE ###

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

"""
参考：https://kimiyuki.net/writeup/algo/atcoder/arc-085-d/
・ミニマックス法
・メモ化再帰
・先手と後手にそれぞれのメモを作る
"""

import sys
from collections import defaultdict

# 再帰呼び出しの回数制限(デフォルト1000)
sys.setrecursionlimit(10 ** 9)
 
N, Z, W = map(int, input().split())
aN = list(map(int, input().split()))

# 先手番用メモ[残り山札数][相手のスコア] = このルートでのmax
# 後手番用メモ[残り山札数][相手のスコア] = このルートでのmin
memo1 = [defaultdict(int) for _ in range(N+1)]
memo2 = [defaultdict(int) for _ in range(N+1)]

def dfs(turn, rest, x, y):
    if rest == 0:
        return abs(x - y)
    # 先手番
    if turn % 2 == 0:
        # 既に見た局面ならメモの内容を返す
        if memo1[rest][y]: 
            return memo1[rest][y]
        mx = -1
        for i in range(N-rest, N):
            x = aN[i]
            idx = i+1
            mx = max(dfs(turn+1, N-idx, x, y), mx)
        # ここより深い所を探し終わったので結果をメモする
        memo1[rest][y] = mx
        return mx
    # 後手番
    else:
        if memo2[rest][x]: 
            return memo2[rest][x]
        mn = float('inf')
        for i in range(N-rest, N):
            y = aN[i]
            idx = i+1
            mn = min(dfs(turn+1, N-idx, x, y), mn)
        memo2[rest][x] = mn
        return mn

print(dfs(0, N, Z, W))
### BUGGY CODE ###

#!/usr/bin/env python3
import sys

import networkx as nx

YES = "Yes"  # type: str
NO = "No"


def solve(N: int, M: int, A: "List[int]", B: "List[int]"):
    G = nx.Graph()
    G.add_nodes_from([1+n for n in range(N)])

    G.add_edges_from([(a,b) for a,b in zip(A,B)])

    paths = nx.single_source_shortest_path(G, 1)

    ans_list = []
    for key, val in sorted(paths.items()):
        if key != 1:
            ans_list.append((key,val[-2]))

    print(YES)
    ans_list.sort(key=lambda x: x[0])
    for key, val in ans_list:
        print(val)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int()] * (M)  # type: "List[int]"
    B = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(N, M, A, B)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
from collections import deque

YES = "Yes"  # type: str


def solve(N: int, M: int, A: "List[int]", B: "List[int]"):
    dq = deque([])
    traversed = [False for _ in range(N+1)]
    ans = [None for _ in range(N+1)]

    G = {n : set([]) for n in range(1, N+1)}
    for a, b in zip(A,B):
        G[a].add(b)
        G[b].add(a)

    dq.append(1)
    traversed[1] = True

    while dq:
        s = dq.popleft()

        for node in G[s]:
            if not traversed[node]:
                dq.append(node)
                traversed[node] = True
                

                ans[node] = s

    print(YES)
    for s in ans:
        if s != None:
            print(s)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int()] * (M)  # type: "List[int]"
    B = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(N, M, A, B)

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

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())

def gcd(a, b):
    while b: a, b = b, a % b
    return a
def isPrimeMR(n):
    d = n - 1
    d = d // (d & -d)
    L = [2]
    for a in L:
        t = d
        y = pow(a, t, n)
        if y == 1: continue
        while y != n - 1:
            y = (y * y) % n
            if y == 1 or t == n - 1: return 0
            t <<= 1
    return 1
def findFactorRho(n):
    m = 1 << n.bit_length() // 8
    for c in range(1, 99):
        f = lambda x: (x * x + c) % n
        y, r, q, g = 2, 1, 1, 1
        while g == 1:
            x = y
            for i in range(r):
                y = f(y)
            k = 0
            while k < r and g == 1:
                ys = y
                for i in range(min(m, r - k)):
                    y = f(y)
                    q = q * abs(x - y) % n
                g = gcd(q, n)
                k += m
            r <<= 1
        if g == n:
            g = 1
            while g == 1:
                ys = f(ys)
                g = gcd(abs(x - ys), n)
        if g < n:
            if isPrimeMR(g): return g
            elif isPrimeMR(n // g): return n // g
            return findFactorRho(g)
def primeFactor(n):
    i = 2
    ret = {}
    rhoFlg = 0
    while i * i <= n:
        k = 0
        while n % i == 0:
            n //= i
            k += 1
        if k: ret[i] = k
        i += i % 2 + (3 if i % 3 == 1 else 1)
        if i == 101 and n >= 2 ** 20:
            while n > 1:
                if isPrimeMR(n):
                    ret[n], n = 1, 1
                else:
                    rhoFlg = 1
                    j = findFactorRho(n)
                    k = 0
                    while n % j == 0:
                        n //= j
                        k += 1
                    ret[j] = k
 
    if n > 1: ret[n] = 1
    if rhoFlg: ret = {x: ret[x] for x in sorted(ret)}
    return ret

def divisors(N):
    pf = primeFactor(N)
    ret = [1]
    for p in pf:
        ret_prev = ret
        ret = []
        for i in range(pf[p]+1):
            for r in ret_prev:
                ret.append(r * (p ** i))
    return ret
  
ans = 0
for i in range(1,n+1):
  ans += len(divisors(i))*i
print(ans)

### FIXED CODE ###

n = int(input())
a = 0
for i in range(1,n+1):
  m = n//i
  a += (m+1)*(m)*i//2
print(a)
### BUGGY CODE ###

import math
import sys

H,W = map(int, raw_input().split())
while H>0 or W>0:
 for y in xrange(W):
  for x in xrange(H):
   if (W+H)%2==0 : print "#"
   else : print "."
  print
 print


### FIXED CODE ###

while 1:
 H, W = map(int,raw_input().split())
 if H + W == 0:break
 for h in range(H):
  if h % 2 == 0:
   if W % 2 == 0:
    print ('#.'*(W//2))
   else:
    print ('#.'*(W//2)+'#')
  else:
   if W % 2 == 0:
    print ('.#'*(W//2))
   else:
    print ('.#'*(W//2)+'.')
 print ''
### BUGGY CODE ###

N, M = map(int, input().split())
dic = {i:[] for i in range(1,M+1)}
for i in range(N):
  A, B = map(int, input().split())
  if A<=M:
    dic[A] += [B]
key = list(dic.keys())
key.sort()
ans = 0
ls = []
m = 0
for i in range(1,M+1):
  ls += dic[i]
  if ls:
    ans += max(ls)
    ls.remove(max(ls))
  
print(ans)

### FIXED CODE ###

from heapq import heappop, heappush
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
X = sorted([list(map(int, input().split())) for _ in range(N)], key = lambda x: x[0])

hq = []
ans, j = 0, 0

for i in range(1, M + 1):  # M - i 日後にするバイトを考える
    while (j < N) and (X[j][0] <= i):
        heappush(hq, -X[j][1])  # 候補の追加
        j += 1
    if len(hq):
        ans += -heappop(hq)  # 候補があるとき、候補から最大値を取り出す

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

N,Q = map(int,input().split())
S = input()
point = [list(map(int,input().split())) for i in range(Q)]
for i in range(Q):
  target = S[point[i][0]-1:point[i][1]]
  print(target.count('AC'))



### FIXED CODE ###

N,Q = map(int,input().split())
S = input()
point = [list(map(int,input().split())) for i in range(Q)]
ac_list = [0]*(N+1)

for i in range(N):
  if S[i:i+2] == 'AC':
    ac_list[i+1] = ac_list[i] + 1
  else:
    ac_list[i+1] = ac_list[i]


for i in range(Q):
  print(ac_list[point[i][1]-1] - ac_list[point[i][0]-1])
### BUGGY CODE ###

a,b,q = list(map(int, input().split()))

s = [0]*a
t = [0]*b
x = [0]*q
for i in range(a):
    s[i] = int(input())
for i in range(b):
    t[i] = int(input())
for i in range(q):
    x[i] = int(input())
s.sort()
t.sort()

#print(s)
#print(t)
import bisect
for xi in x:
    i = bisect.bisect_left(s,xi)
    s_right = 10**11
    if i < len(s):
        s_right = s[i] - xi
    s_left = 10**11
    if i != 0:
        s_left = xi - s[i-1]
    j = bisect.bisect_left(t,xi)
    t_right = 10**11
    if j < len(t):
        t_right = t[j] - xi
    t_left = 10**11
    if j != 0:
        t_left = xi - t[j-1]
    #print(i,j,xi)
    #print(s_left,s_right,t_left,t_right)
    ans = min(max(s_right,t_right), max(s_left,t_left), min(s_left,t_right)*2+max(s_left,t_right), min(s_right,t_left)*2+max(s_right,t_left))
    print(ans)


### FIXED CODE ###

a,b,q = list(map(int, input().split()))

s = [0]*a
t = [0]*b
x = [0]*q
for i in range(a):
    s[i] = int(input())
for i in range(b):
    t[i] = int(input())
for i in range(q):
    x[i] = int(input())
s.sort()
t.sort()

INT_MAX = 10**11

#print(s)
#print(t)
import bisect
def func(xi):
    i = bisect.bisect_left(s,xi)
    s_right = INT_MAX
    if i < len(s):
        s_right = s[i] - xi
    s_left = INT_MAX
    if i != 0:
        s_left = xi - s[i-1]
    j = bisect.bisect_left(t,xi)
    t_right = INT_MAX
    if j < len(t):
        t_right = t[j] - xi
    t_left = INT_MAX
    if j != 0:
        t_left = xi - t[j-1]
    #print(i,j,xi)
    #print(s_left,s_right,t_left,t_right)
    return min(max(s_right,t_right), max(s_left,t_left), min(s_left,t_right)*2+max(s_left,t_right), min(s_right,t_left)*2+max(s_right,t_left))

ans = map(func, x)
print("\n".join(map(str,ans)))
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
import fractions
from functools import reduce
mod = 10**9+7

def gcd(*numbers):
    return reduce(fractions.gcd,numbers)
def lcm_bace(x,y):
    return (x*y)//fractions.gcd(x,y)
def lcm(*numbers):
    return reduce(lcm_bace,numbers,1)

ans = 0
for i in A:
    ans += (lcm(*A)//i)%mod
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 ###

N = int(input())
liste = input().split()
number = [int(x) for x in liste]
# print(N,number)
total = 1
i = 0
while i < N:
    if 0 in number:
        total = 0
        break
    else:
        total *= number[i]
        i = i + 1
        if total > 10**18:
            total = -1
            break
print(total)

### FIXED CODE ###

N = int(input())
liste = input().split()
number = [int(x) for x in liste]
total = 1
i = 0
if 0 in number:
    total = 0
else:
    while i < N:
            total *= number[i]
            i = i + 1
            if total > 10**18:
                total = -1
                break
print(total)
### BUGGY CODE ###

a,b,k=map(int,input().split())
lst=[i for i in range(a,b+1) if a<=i<=a+k-1 or b-k+1<=i<=b]
[print(j) for j in lst]

### FIXED CODE ###

a,b,k=map(int,input().split())
lst=[]
for i in range(a,min(a+k, b)):
  lst.append(i)
  print(i)
for j in range(max(a, b-k+1),b+1):
  if j not in lst:
    print(j)
### BUGGY CODE ###

import math
s = list(map(int,input().split()))
n=s[0]
m=s[1]
q=s[2]
x=0
for i in range(1,q+1):
    re=math.floor(n*i/m)-math.floor(i/m)*n
    if x<re:
        x=re
print(x)

### FIXED CODE ###

import math
s = list(map(int,input().split()))

a = s[0]
b = s[1]
n = s[2]
x = 0
if b-1 <= n:
    x = b-1
    ans = math.floor(a*x/b)-n*math.floor(x/b)
else:
    x = n
    ans = math.floor(a*x/b)-n*math.floor(x/b)
print(ans)
### BUGGY CODE ###

x = int(input())
if x < 4:
  print(1)
else:
  ans = 2
  for i in range(2, x):
    for j in range(2, x):
      if i ** j <= x:
        ans = max(ans, i ** j)
  print(ans)

### FIXED CODE ###

x = int(input())
if x < 4:
  print(1)
else:
  ans = 2
  for i in range(2, x):
    for j in range(2, x):
      if i ** j <= x:
        ans = max(ans, i ** j)
      else:
        break
  print(ans)
### BUGGY CODE ###

from math import sqrt,floor
from sys import stdin

def cntPrime(n):
    mx = sqrt(n) + 1
    if n % 2 == 0:
      l = [0, 1] + [1, 0] * (int(n/2) - 1)
    else:
      l = [0, 1] + [1, 0] * (int(n/2) - 1) + [1]
    c = 3
    while c < mx:
        for k in range(c, floor(n/c) + 1, 1):
            l[c * k -1] = 0
        c = l[:c].index(1) + c
    return sum(l)
for n in stdin:
    n = int(n)
    print(cntPrime(n))

### FIXED CODE ###

from math import sqrt,floor
from sys import stdin

def cntPrime(n):
    mx = sqrt(n)
    if n % 2 == 0:
      l = [0, 1] + [1, 0] * (int(n/2) - 1)
    else:
      l = [0, 1] + [1, 0] * (int(n/2) - 1) + [1]
    c = 3
    while c < mx:
        for k in range(c*2, n+1, c):
            l[k-1] = 0
        c = l[(c+1):].index(1) + c +2
        while c % 2 == 0:
            c = l[(c+1):].index(1) + c +2
    return l
t = cntPrime(1000000)
for n in stdin:
    n = int(n)
    print(sum(t[:n]))
### BUGGY CODE ###

from bisect import bisect_left
x,y,z,k=map(int,input().split())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
c=sorted([int(i) for i in input().split()],reverse=True)
ab_max=[]
for i in range(x):
    for j in range(y):
        ab_max.append(a[i]+b[j])
ab_max.sort()
def unti(t_sub):
    global x,y,z,k
    ret=0
    for i in range(x*y):
        h=z-bisect_left(c,t_sub-ab_max[i])
        if h==0 or ret>=k:
            return ret
        else:
            ret+=h
    return ret
l,r=0,ab_max[0]+max(c)
while r>l+1:
    t=(l+r)//2
    if unti(t)>=k:
        r=t
    else:
        l=t
ans=[]
f=False
for i in range(x*y):
    for j in range(z):
        u=ab_max[i]+c[j]
        if u>=r:
            ans.append(u)
        else:
            if j==0:f=True
            break
    if f:
        break
ans.sort(reverse=True)
for i in range(k):
    print(ans[i])


### FIXED CODE ###

import heapq
x,y,z,k=map(int,input().split())
#heapqは小さい順にしか並べられないので、-をつければ大きい順になる
a=sorted([-int(i) for i in input().split()])
b=sorted([-int(i) for i in input().split()])
c=sorted([-int(i) for i in input().split()])
check=set()
ans=[]
heapq.heappush(ans,(a[0]+b[0]+c[0],0,0,0))
check.add((0,0,0))
for i in range(k):
    h=heapq.heappop(ans)
    print(-h[0])
    if h[1]+1<x:
        if (h[1]+1,h[2],h[3]) not in check:
            heapq.heappush(ans,(a[h[1]+1]+b[h[2]]+c[h[3]],h[1]+1,h[2],h[3]))
            check.add((h[1]+1,h[2],h[3]))
    if h[2]+1<y:
        if (h[1],h[2]+1,h[3]) not in check:
            heapq.heappush(ans,(a[h[1]]+b[h[2]+1]+c[h[3]],h[1],h[2]+1,h[3]))
            check.add((h[1],h[2]+1,h[3]))
    if h[3]+1<z:
        if (h[1],h[2],h[3]+1) not in check:
            heapq.heappush(ans,(a[h[1]]+b[h[2]]+c[h[3]+1],h[1],h[2],h[3]+1))
            check.add((h[1],h[2],h[3]+1))
'''
while len(ans)!=0:
    print(heapq.heappop(ans)[0])
'''
### BUGGY CODE ###

N, M = map(int, input().split())
l = [0]*N

for i in range(M):
        L, R = map(int, input().split())
        for j in range(L, R+1):
                l[j-1] += 1
print(l.count(M))

### FIXED CODE ###

N, M = map(int, input().split())
l = [0]*(N+1)

for i in range(M):
        L, R = map(int, input().split())
        l[L-1] += 1
        l[R] -= 1
        

k = 0
ans = 0
for i in l:
        k += i
        if k == M:
                ans += 1
print(ans)
### BUGGY CODE ###

#N, X, Y = map(int, input().split())
#l = [0 for _ in range(N-1)]
#for i in range(1, N+1):
#    for j in range(i+1,N+1):
#        n = min(j-i, abs(i-X)+1 + abs(j-Y))
#        l[n-1] +=1
#for m in l:
#    print(m)
inf = 100000
N, X, Y = map(int, input().split())
X -= 1
Y -= 1
ans = [0] *N
for i in range(N):
    queue = []
    dist = [inf] *N
    def push(n, d):
        if dist[n] == inf:
            dist[n] = d
            queue.append(n)
    push(i, 0)
    while queue != []:
        q = queue.pop(0)
        if q-1 >=0:
            push(q-1, dist[q] + 1)
        if q+1 <N:
            push(q+1, dist[q] + 1)
        if q == X:
            push(Y, dist[q] + 1)
        if q == Y:
            push(X, dist[q] + 1)
    for d in dist:
        ans[d] += 1
for i in range(1, N):
    print(int(ans[i]/2))


### FIXED CODE ###

N, X, Y = map(int, input().split())
l = [0 for _ in range(N-1)]
for i in range(1, N+1):
    for j in range(i+1,N+1):
        n = min(j-i, abs(i-X)+1 + abs(j-Y))
        l[n-1] +=1
for m in l:
    print(m)
### BUGGY CODE ###

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

c = 0
while n > 0:
    n = n - a
    if n > 0:
        c += a
    else:
        c += a+n
    n = n - b
print(c)

### FIXED CODE ###

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

x = n // (a+b)
c = a * x
n -= (a+b)*x
while n > 0:
    n = n - a
    if n > 0:
        c += a
    else:
        c += a+n
    n = n - b
print(c)
### BUGGY CODE ###

import numpy as np

N, X = map(int, input().split())
S = list(map(int, input().split()))

MOD = 1000000007
numbers = S[:]
numbers.sort()


dp = np.zeros((N+1, X+1), dtype=int)
#dp[0] = [x for x in range(X+1)]
dp[0] = np.arange(X+1)

for i, n  in enumerate(numbers):
    for x in range(X+1):
        dp[i+1][x] += dp[i][x % n]
    dp[i+1] += dp[i] * i 

print(int(dp[N][X] % MOD))


### FIXED CODE ###

N, X = map(int, input().split())
S = list(map(int, input().split()))

MOD = 1000000007
numbers = S[:]
numbers.sort(reverse=True)


dp = {X: 1}

for i, n in enumerate(numbers):
    tmp_dp = {}
    for k, v in dp.items():
        if k < n:
            tmp_dp[k] = (tmp_dp.get(k,0)+v*(N-i))
        else:
            tmp_dp[k]=(tmp_dp.get(k,0)+v*(N-i-1)) 
            tmp_dp[k%n]=(tmp_dp.get(k%n,0)+v) 
    dp = tmp_dp.copy()
        
ans = 0
for k, v in dp.items():
    ans += k *  v

print(ans % MOD)
### BUGGY CODE ###

import itertools

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

xx = itertools.combinations(L, 3)
cnt = 0
for x in xx:
    if x[0] < x[1] + x[2] and \
       x[1] < x[2] + x[0] and \
       x[2] < x[0] + x[1]:
        cnt += 1
print(cnt)

### FIXED CODE ###

from bisect import bisect_right
N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N):
    for j in range(i):
        m = L[i]-L[j]
        k = bisect_right(L, m)
        n = max(0, j-k)
        ans+=n
print(ans)
### BUGGY CODE ###

n = int(input())
a = [0]*n
x = [[0] *n for i in range(n)]
y = [[0] *n for i in range(n)]
ans = 0
for i in range(n):
    a[i] = int(input())
    for j in range(a[i]):
        x[i][j],y[i][j] = map(int,input().split())
        x[i][j]-=1
def honest(i,j):
    return (i>>j)%2 ==1
def check(m):
    for i in range(n):
        if not honest(m,i) :continue
        for j in range(a[i]):
            if y[i][j] == 1 and honest(m,x[i][j]) == 0:
                return False
            if y[i][j] == 0 and honest(m,x[i][j]) == 1:
                return False
    return True
def count(c):
    cnt = 0
    for i in range(c//2+5):
        cnt+= (c >> i)%2
    return cnt
for i in range(2**n):
    if check(i):
        ans = max(ans,count(i))
    
        
        
        
print(ans)
        

### FIXED CODE ###

n = int(input())
a =[0]*n
x = [[0] *n for i in range(n)]
y = [[0] *n for i in range(n)]
ans = []
for i in range(n):
    a[i] = int(input())
    for j in range(a[i]):
        x[i][j],y[i][j] = map(int,input().split())
        x[i][j]-=1
        
ishonest= [-1]*n + [0]
def check(ishonest):
    for i in range(n):
        if not ishonest[i]:continue
        for j in range(a[i]):
            if y[i][j] == 1 and ishonest[x[i][j]] == 0:
                return False
            if y[i][j] == 0 and ishonest[x[i][j]] == 1:
                return False
    return True

def dfs(now,h_or_not= -1):
    ishonest[now] = h_or_not
    if now == n-1:
        if check(ishonest):
      
            return sum(ishonest)+1
        else:
            return 0
  
    return max(dfs(now+1,0),dfs(now+1,1))

print(dfs(-1))
### BUGGY CODE ###

from collections import defaultdict as dd
from math import ceil
n = int(input())
A = list(map(int, input().split()))

def Prime_factorization(num):
  ans_dic = dd(lambda: 0)
  for divisor in range(2, ceil(num**0.5) + 2):
    while num % divisor == 0:
      num //= divisor
      ans_dic[divisor] += 1
  else:
    if len(ans_dic.keys()) == 0:
      ans_dic[num] += 1
  return ans_dic

GCDs = {}
for num in A:
  GCDs[num] = Prime_factorization(num)
#print(GCDs)
    
def marge(A, GCDs, skip):
  keys = set()
  #keyを作成
  for i in range(len(A)):
    if i != skip:
      keys = keys | set(GCDs[A[i]].keys())
  #print(keys)
  #gcdを計算
  #各keyの個数の最小数を算出
  gcd = 1
  for prime in keys:
    min_num_prime = 10**9
    for i in range(len(A)):
      if i != skip:
        min_num_prime = min(GCDs[A[i]][prime], min_num_prime)
    gcd *= prime**min_num_prime
  return gcd  
  
max_gcd = 0
for i in range(len(A)):
  max_gcd = max(marge(A, GCDs, skip=i), max_gcd)
print(max_gcd)

### FIXED CODE ###

from fractions import gcd
n = int(input())
A = list(map(int, input().split()))

L = {}
R = {}

L[0] = A[0]
#print("L", 0, L[0])
for i in range(n-1):
  L[i+1] = gcd(L[i], A[i+1])
  #print("L", i+1, L[i+1])

R[n-1] = A[n-1]
#print("R", n-1, R[n-1])
for i in range(n-1):
  R[n-2-i] = gcd(R[n-1-i], A[n-2-i])
  #print("R", n-2-i, R[n-2-i])
  
max_gcd = 0
for i in range(1, n-1):
  max_gcd = max(gcd(L[i-1], R[i+1]), max_gcd)
  #print(i, L[i-1], R[i+1], gcd(L[i-1], R[i+1]))
max_gcd = max((max_gcd, L[n-2], R[1]))
print(max_gcd)
### BUGGY CODE ###

s = input()
s = list(s)

def del_01(s,counter):
  for i in range(len(s)-1):
    if s[i] == '1' and s[i+1] == '0':
      s[i] ='w'
      s[i+1] = 'w'
      counter += 2
    elif s[i] == '0' and s[i+1] == '1':
      s[i] = 'w'
      s[i+1] = 'w'
      counter += 2
  s.remove('w')
  return s, counter
counter = 0
while (s.count('0') != 0) and (s.count('1') != 0) and (s != []):
  s, counter = del_01(s, counter)
  x = del_01(s,0)

print(counter)

### FIXED CODE ###

s = input()
s = list(s)

count0 = s.count('0')
count1 = s.count('1')
                 
print(min(count0,count1)*2)