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

N = int(input())
A = [0]*N
cnt = 0
for i in range(N):
    A[i] = int(input())

A.sort()
for c in A:
    if A.count(c) % 2 == 1:
        cnt += 1
    
print(cnt)

### FIXED CODE ###

N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
cnt = 1
ans = 0
A.sort()
for i in range(N-1):
    if A[i] == A[i+1]:
        cnt += 1
    else:
        if cnt%2 == 1:
            ans += 1
        cnt = 1
if cnt%2 == 1:
    ans += 1
print(ans)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
b = [[i, 1<<n] for i in range(len(a))]
a.append(-float("inf"))

def update(a1, a2):
    a1.extend(a2)
    return sorted(set(a1), key=lambda x: -a[x])[:2]

for j in range(n):
    for i in range(1<<n):
        if i & (1<<j):
            b[i] = update(b[i], b[i & ~(1<<j)])
ans = []
tmp = 0
for i in range(1, 1<<n):
    tmp = max(tmp, a[b[i][0]]+a[b[i][1]])
    ans.append(tmp)
print(*ans, sep="\n")


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
b = [[i] for i in a]

for j in range(n):
    for i in range(1<<n):
        if i & (1<<j):
            b[i] = sorted(b[i]+b[i^1<<j], reverse=True)[:2]
ans = []
tmp = 0
for i in range(1, 1<<n):
    tmp = max(tmp, sum(b[i]))
    ans.append(tmp)
print(*ans, sep="\n")
### BUGGY CODE ###

n = int(input())
nums = tuple(input().split())
judge = 0
for i in range(n):
  for j in range(i+1,n):
    if nums[i] == nums[j]:
      judge = 1
if judge == 0:
  print("YES")
else:
  print("NO")

### FIXED CODE ###

n = int(input())
a = input().split()
a = sorted(list(map(int, a)))
def check(a):
    for i in range(n-1):
        if a[i] == a[i+1]:
            return 0
    return 1
if check(a) == 0:
    print("NO")
else:
    print("YES")
### BUGGY CODE ###

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

for i in range(1,N+1):
    #ans = a.index(i) + 1
    print(a.index(i) + 1, end=" ")


### FIXED CODE ###

import numpy as np
def calc_1(x):
    return x+1

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

x = np.argsort(a)
hoge = list(map(calc_1,x))

ans = [str(a) for a in hoge]
ans = " ".join(ans)
print(ans)
### BUGGY CODE ###

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

if n == 2:
    print(abs(a[1]) * 2)
    print(abs(a[0]) * 2)
else:
    for i in range(len(a)):
        cost = 0
        if i == 0:
            cost += abs(a[1]) + abs(a[-1])
            for j in range(1, len(a)-1):
                cost += abs(a[j] - a[j+1])
            print(cost)
        elif i == len(a)-1:
            cost += abs(a[0]) + abs(a[-2])
            for j in range(0, len(a)-2):
                cost += abs(a[j] - a[j+1])
            print(cost)
        else:
            cost += abs(a[0]) + abs(a[-1]) + abs(a[i+1] - a[i-1])
            for j in range(i-1):
                cost += abs(a[j] - a[j+1])
            for j in range(i+1, len(a)-1):
                cost += abs(a[j] - a[j+1])
            print(cost)

### FIXED CODE ###

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

a.insert(0,0)
a.append(0)

total = 0
for i in range(len(a)-1):
    total += abs(a[i] - a[i+1])

for j in range(1, len(a)-1):
    print(total - abs(a[j-1] - a[j]) - abs(a[j] - a[j+1]) + abs(a[j+1]- a[j-1]))
### BUGGY CODE ###

import sys
input = sys.stdin.buffer.readline

def main():
    N,K = map(int,input().split())
    a = list(map(int,input().split()))
    f = list(map(int,input().split()))
    a.sort()
    f.sort(reverse = True)
    l,r = -1,a[-1]*f[0]+1
    while r-l > 1:
        mid = (l+r)//2
        count = 0
        for co,ha in zip(a,f):
            tr = max(0,co - mid//ha)
            count += tr
        if K < count:
            l = mid
        else:
            r = mid
            
    print(r)
    
if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline
import numpy as np

def main():
    N,K = map(int,input().split())
    a = list(map(int,input().split()))
    f = list(map(int,input().split()))
    a.sort()
    f.sort(reverse=True)

    if sum(a) <= K:
        print(0)
    else:
        a = np.array(a)
        f = np.array(f)
        left,right = 0,max(a)*max(f)
        while right-left > 1:
            mid = (left+right)//2
            pra = a-mid//f
            pra[pra<0] = 0
            if np.sum(pra) > K:
                left = mid
            else:
                right = mid
        print(right)

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


X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

res = []
for a in A:
    for b in B:
        for c in C:
            res.append(a + b + c)

res.sort(reverse=True)
for i in range(K):
    print(res[i])


### FIXED CODE ###

X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans1 = []
for i in range(X):
    for j in range(Y):
        ans1.append(A[i] + B[j])
        
ans1 = sorted(ans1, reverse=True)[:K]

ans = []
for i in range(len(ans1)):
    for j in range(Z):
        ans.append(ans1[i] + C[j])
        
print(*sorted(ans, reverse=True)[:K], sep='\n')
### BUGGY CODE ###

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

def sigma(a, b):
    s = 0
    for i in range(a, b+1):
        s += (1+p[i-1])/2
    return s
  
M = max(sigma(i, i+k-1) for i in range(1, n-k+2))
print(M)



### FIXED CODE ###

N, K = map(int, input().split())
P = list(map(int, input().split()))
Q = [0]
for p in P:
    Q.append(Q[-1] + (p+1)/2)

print(max([Q[i+K]-Q[i] for i in range(N-K+1)]))
### BUGGY CODE ###

n,k=map(int,input().split())
x=[0]*n
y=[0]*n
a=[]
for i in range(n):
  x[i],y[i]=map(int,input().split())
  a.append((x[i],y[i]))
ans=4*(10**18)
x.sort()
y.sort()
for i in range(n-1):
  for j in range(i+1,n):
    for l in range(n-1):
      for m in range(l+1,n):
        L=x[i]
        R=x[j]
        D=y[l]
        U=y[m]
        if L==R or U==D:
          continue
        cnt=0
        for s in a:
          if L<=s[0]<=R and D<=s[1]<=U:
            cnt+=1
        if cnt>=k:
          ans=min(ans,(R-L)*(U-D))
print(ans)

### FIXED CODE ###

n,k=map(int,input().split())
x=[0]*n
y=[0]*n
a=[]
for i in range(n):
  x[i],y[i]=map(int,input().split())
  a.append((x[i],y[i]))
ans=4*(10**18)
x.sort()
y.sort()
for i in range(n-1):
  for j in range(i+1,n):
    for l in range(n-1):
      for m in range(l+1,n):
        L=x[i]
        R=x[j]
        D=y[l]
        U=y[m]
        if L==R or U==D:
          continue
        cnt=0
        for s in a:
          if L<=s[0]<=R and D<=s[1]<=U:
            cnt+=1
        if cnt>=k:
          ans=min(ans,(R-L)*(U-D))
print(ans)
### BUGGY CODE ###

n = int(input())
count = 0
li = []
 
for i in range(1, n):
  if n - i == i or i in li:
    continue
    
  else:
    count += 1
    li.append(i)
    li.append(n - i)
    
print(count)
      

### FIXED CODE ###

n = int(input())
count = 0

if n % 2 != 0:
  n += 1
 
for i in range(1, n // 2):
  if n - i == i:
    continue
    
  else:
    count += 1
    
print(count)
### BUGGY CODE ###

import heapq

N, M, S = map(int, input().split())
Cost = [[[-1, -1] for _ in range(N)] for _ in range(N)]
Change = [[0]*2 for _ in range(N)]
for i in range(M):
    u, v, a, b = map(int, input().split())
    Cost[u-1][v-1][0] = a
    Cost[u-1][v-1][1] = b
    Cost[v-1][u-1][0] = a
    Cost[v-1][u-1][1] = b
for i in range(N):
    c, d = map(int, input().split())
    Change[i][0] = c
    Change[i][1] = d
if S > 2500:
    S = 2500

def dijkstra(N, start, Cost, Change, S):
    minHeap = []
    used = [[10**12]*2501 for _ in range(N)]
    used[start][S] = 0
    heapq.heappush(minHeap, (0, S, start))
    while minHeap:
        (c, hold, current) = heapq.heappop(minHeap)
        for road in range(N):
            if Cost[current][road][0] != -1:
                if hold >= Cost[current][road][0]:
                    if used[road][hold - Cost[current][road][0]] > c + Cost[current][road][1]:
                        used[road][hold - Cost[current][road][0]] = c + Cost[current][road][1]
                        heapq.heappush(minHeap, (c + Cost[current][road][1], hold - Cost[current][road][0], road))
        if hold + Change[current][0] <= 2500:
            if used[current][hold + Change[current][0]] > c + Change[current][1]:
                heapq.heappush(minHeap, (c + Change[current][1], hold + Change[current][0], current))
    return used

T = dijkstra(N, 0, Cost, Change, S)
for i in T[1:]:
    print(min(i))

### FIXED CODE ###

import heapq

N, M, S = map(int, input().split())
Cost = [[] for _ in range(N)]
Change = [[0]*2 for _ in range(N)]
A_m = 0
for i in range(M):
    u, v, a, b = map(int, input().split())
    A_m = max(A_m, a)
    Cost[u-1].append([v-1, a, b])
    Cost[v-1].append([u-1, a, b])
for i in range(N):
    c, d = map(int, input().split())
    Change[i][0] = c
    Change[i][1] = d
if S > A_m*N:
    S = A_m*N

def dijkstra(N, start, Cost, Change):
    rich = [[] for _ in range(N+1)]
    Ans = [10**18]*N
    Ans[0] = 0
    minHeap = []
    used = [[10**18]*(A_m*N + 1) for _ in range(N)]
    used[start][S] = 0
    heapq.heappush(minHeap, (0, S, start))
    while minHeap:
        (c, hold, current) = heapq.heappop(minHeap)
        if rich[current] and rich[current][-1] >= hold:
            continue
        rich[current].append(hold)
        j = 1
        for i in range(N):
            if Ans[i] > c:
                j = 0
                break
        if j == 1:
            break
        for P in Cost[current]:
            road, a, b = P
            if hold >= a:
                if used[road][hold - a] > c + b:
                    used[road][hold - a] = c + b
                    heapq.heappush(minHeap, (c + b, hold - a, road))
                if Ans[road] > c + b:
                    Ans[road] = c + b
        if hold + Change[current][0] <= A_m*N:
            if used[current][hold + Change[current][0]] > c + Change[current][1]:
                heapq.heappush(minHeap, (c + Change[current][1], hold + Change[current][0], current))
    return Ans

T = dijkstra(N, 0, Cost, Change)
for i in T[1:]:
    print(i)
### BUGGY CODE ###

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

    mod_value = 10**9 + 7
    sum_ = 0
    for i in range(len(A)-1):
        sum_ = sum_ + A[i]*sum(A[i+1:])
    print(sum_ % mod_value)
main()

### FIXED CODE ###

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

    mod_value = 10**9 + 7
    sum_ = 0
    b_sum = 0
    for i in range(len(A)-1):
        b_sum = b_sum + A[len(A)-i-1]
        sum_ = sum_ + (A[len(A)- i - 2]*b_sum) % mod_value
    print(sum_%mod_value)
main()
### BUGGY CODE ###


import sys
import math
# from collections import Counter
input = sys.stdin.readline
# import numpy as np

def inp():
    return(int(input()))

def inps():
    return str(input())
    
def inlt():
    return(list(map(int,input().split())))
    
def inlst():
    return(list(map(str,input().split())))
    
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split())) 

x, k, d = inlt()
for i in range(k):
    if x>0: x-=d
    else: x+=d
print(abs(x))    

### FIXED CODE ###


import sys
import math
# from collections import Counter
input = sys.stdin.readline
# import numpy as np

def inp():
    return(int(input()))

def inps():
    return str(input())
    
def inlt():
    return(list(map(int,input().split())))
    
def inlst():
    return(list(map(str,input().split())))
    
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split())) 

def ans(x,k,d):
    if abs(x)<d:
        if k%2: return  d - abs(x)
        else: return abs(x)
    else:
        div = abs(x)//d
        if div>k: return abs(x) - d*k
        else:
            if (k-div)%2: return d - abs(x)%d
            else: return abs(x)%d 

x, k, d = inlt()
print(ans(x, k, d))
### BUGGY CODE ###

def main():
    N = int(input())
    ans = 0
    for i in range(1, N+1):
        ans += sum(j for j in range(i, N+1, i))
    print(ans)
main()

### FIXED CODE ###

N = int(input())
ans = 0
for X in range(1, N+1):
  Y = N // X
  ans += Y * (Y + 1) // 2 * X
print(ans)
### BUGGY CODE ###

n,a,b = [int(x) for x in input().split()]
mod = 10**9 + 7
def comb(x,y):
    child = 1
    mother = 1
    for i in range(y):
        child *= x-i
        mother *= i+1
    return child * pow(mother,mod-2,mod)
ans = pow(2,n,mod)  - comb(n,a) - comb(n,b) - 1
print(int(ans%mod))

### FIXED CODE ###

n,a,b = [int(x) for x in input().split()]
mod = 10**9 + 7
def comb(x,y):
    child = 1
    mother = 1
    for i in range(y):
        child = child * (x-i)%mod
        mother = mother * (i+1)%mod
    return child * pow(mother,mod-2,mod) % mod
ans = pow(2,n,mod) - 1
ans -= comb(n,a)
ans %= mod
ans -= comb(n,b)
ans %= mod
print(ans)
### BUGGY CODE ###

from bisect import bisect_left
n, Q = list(map(int, input().split()))
stx = [list(map(int, input().split())) for i in range(n)]
q = [int(input()) for i in range(Q)]
stx.sort(key=lambda x: x[2])
ans = [-1 for i in range(Q)]
skip = [-1 for i in range(Q)]

for (s, t, x) in stx:
  begin = bisect_left(q, s-x)
  end = bisect_left(q, t-x)
  while begin<end:
    if skip[begin]==-1:
      ans[begin] = x
      skip[begin] = end
      begin += 1
    else:
      begin = skip[begin]
for e in ans:
  print(e)

### FIXED CODE ###

from bisect import bisect_left
n, Q = list(map(int, input().split()))
stx = [list(map(int, input().split())) for i in range(n)]
q = [int(input()) for i in range(Q)]
stx.sort(key=lambda x: x[2])
ans = [-1 for i in range(Q)]
skip = [-1 for i in range(Q)]

for (s, t, x) in stx:
  begin = bisect_left(q, s-x)
  end = bisect_left(q, t-x)
  while begin<end:
    if skip[begin]==-1:
      ans[begin] = x
      skip[begin] = end
      begin += 1
    else:
      begin = skip[begin]
for e in ans:
  print(e)
### BUGGY CODE ###

Q = int(input())

a = [[int(i) for i in input().split()] for j in range(Q)]

for i in range(Q):
    m = a[i][0]%1000003
    for j in range(a[i][2]-1):
        m = (m*(a[i][0]+(j+1)*a[i][1]))%1000003
    print(m)

### FIXED CODE ###

MOD = 10**6+3

def main():
    # preprocess
    fac = [1, 1]
    f_inv = [1, 1]
    inv = [0, 1]

    for i in range(2, MOD+1):
        fac.append((fac[-1] * i) % MOD)
        inv.append((-inv[MOD % i] * (MOD//i)) % MOD)
        f_inv.append((f_inv[-1] * inv[-1]) % MOD)

    Q = int(input())
    for i in range(Q):
        x, d, n = map(int, input().split())

        if d == 0:
            print(pow(x, n, MOD))
            continue
        
        xd = (x * pow(d, MOD-2, MOD)) % MOD
        if xd == 0 or xd + (n-1) >= MOD:
            print(0)
            continue

        print(pow(d, n, MOD) * fac[xd+(n-1)] * f_inv[xd-1] % MOD)


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

import sys
input = sys.stdin.readline


def main():
    S = input().strip()
    Q = int(input())
    Query = [list(input().split()) for _ in range(Q)]
    reverse = 1
    for T in Query:
        if T[0] == "1":
            if reverse == 1:
                reverse = 2
            else:
                reverse = 1
        elif T[0] == "2":
            if int(T[1]) == reverse:
                S = T[2] + S
            else:
                S = S + T[2]
    print(S) if reverse == 1 else print(S[::-1])


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
input = sys.stdin.readline


def main():
    S = input().strip()
    Q = int(input())
    Query = [list(input().split()) for _ in range(Q)]
    reverse = 1
    head = ""
    tail = ""
    for T in Query:
        if T[0] == "1":
            if reverse == 1:
                reverse = 2
            else:
                reverse = 1
        elif T[0] == "2":
            if int(T[1]) == reverse:
                head = T[2] + head
            else:
                tail = tail + T[2]
    S = head + S + tail
    print(S) if reverse == 1 else print(S[::-1])


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

N, Ma, Mb = map(int, input().split())
a, b, c = [0] * N, [0] * N, [0] * N
for i in range(N):
    a[i], b[i], c[i] = map(int, input().split())

S = 411
MAX_N = 10
MAX_SIZE = 400
INF = int(1e9)
dp = [[INF] * S for i in range(S)]
dp[0][0] = 0
for i in range(N):
    for j in range(MAX_SIZE, -1, -1):
        for k in range(MAX_SIZE, -1, -1):
            dp[j+a[i]][k+b[i]] = min((dp[j+a[i]][k+b[i]], dp[j][k] + c[i]))

ans = INF
for i in range(1, MAX_N):
    ans = min((ans, dp[i*Ma][i*Mb]))
if ans == INF:
    print(-1)
else:
    print(ans)


### FIXED CODE ###

N, Ma, Mb = map(int, input().split())
a, b, c = [0] * N, [0] * N, [0] * N
for i in range(N):
    a[i], b[i], c[i] = map(int, input().split())

S = 411
MAX_N = 10
MAX_SIZE = 400
INF = int(1e9)
dp = [[INF] * S for i in range(S)]
dp[0][0] = 0
for i in range(N):
    for j in range(MAX_SIZE, -1, -1):
        for k in range(MAX_SIZE, -1, -1):
            dp[j+a[i]][k+b[i]] = min((dp[j+a[i]][k+b[i]], dp[j][k] + c[i]))

ans = INF
for i in range(1, MAX_N):
    ans = min((ans, dp[i*Ma][i*Mb]))
if ans == INF:
    print(-1)
else:
    print(ans)
### BUGGY CODE ###

m = 1
for var in range(int(raw_input())):
  m = m * (var + 1)
print(m%(1000000000+7))

### FIXED CODE ###

multi = 1
N = int(raw_input())
for var in range(1,N + 1):
  multi = multi * var
  if multi > 1000000007:
    multi = multi % 1000000007
print multi
### BUGGY CODE ###

import sys
from itertools import permutations

def checker(x):
    if not x: return 1
    if x[0] != '(' or x[-1] != ')': return 0

    l = x.count('(')
    r = x.count(')')
    if l != r: return 0

    return 1

def main():
    for i in comb_s:
        jud = checker(''.join(i))
        if jud == 1:
            print('Yes')
            return

    print('No')
    return

if __name__ == '__main__':
    readline = sys.stdin.readline

    n = int(readline())
    s = (readline().strip() for i in range(n))

    comb_s = list(permutations(s))
    comb_s = tuple(set(comb_s))

    main()


### FIXED CODE ###

from sys import stdin

def main():
    readline = stdin.readline
    n = int(readline())
    s = tuple(readline().strip() for _ in range(n))

    plus, minus = [], []
    for c in s:
        if 2 * c.count('(') - len(c) > 0:
            plus.append(c)
        else:
            minus.append(c)

    plus.sort(key = lambda x: x.count(')'))
    minus.sort(key = lambda x: x.count('('), reverse = True)
    plus.extend(minus)
    sum = 0
    for v in plus:
        for vv in v:
            sum = sum + (1 if vv == '(' else -1)
            if sum < 0 : return print('No')
    if sum != 0:
        return print('No')

    return print('Yes')

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

import bisect

n = int(input())
s = list(map(int, input().split()))
a = [s[1]]
ans = s[2]
p = 0

for i in range(n-1):
    q = input()
    if q[0]=='1':
        c,d = map(int,q[2:].split())
        if len(a)%2==1:
            ans+=abs(a[p]-c)+d
            bisect.insort(a,c)
        else:
            p+=1
            bisect.insort(a,c)
            ans+=abs(a[p]-c)+d
    else:
        print(a[p], ans)

### FIXED CODE ###

import heapq

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

# 中央値より左・右の管理
l=[]
r=[]
heapq.heapify(l)
heapq.heapify(r)
lenl=0
lenr=0
# 中央値
x = s[1]

# b含めた答え
ans = s[2]

for i in range(n-1):
    q = list(map(int,input().split()))
    if q[0]==1:
        ans += q[2]
        if (lenl+lenr)%2==0:
            lenr+=1
            ans+=abs(x-q[1])
            if x<=q[1]:
                heapq.heappush(r,q[1])
            else:
                heapq.heappush(l,-q[1])
                heapq.heappush(r,x)
                x = -heapq.heappop(l)
        else:
            lenl+=1
            if x<q[1]:
                heapq.heappush(l,-x)
                heapq.heappush(r,q[1])
                x=heapq.heappop(r)
            else:
                heapq.heappush(l,-q[1])
            ans+=abs(x-q[1])
    if q[0]==2:
        print(x, ans)
### BUGGY CODE ###

#約数
def make_divisors(n): #約数をリストで返す
    divisors = set()
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.add(i)
            if i != n // i:
                divisors.add(n//i)
    return divisors

# 初期入力
from collections import Counter
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))
A.sort()
A_set =set(A)
count =set()
couter =Counter(A)
for a in A:
    if couter[a] >=2:
        count.add(a)
    else:
        divi_set =make_divisors(a)
        intersection =divi_set & A_set
        if len(intersection) >=2:
            count.add(a)
ans =len(A_set - count)
print(ans)

### FIXED CODE ###


2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

	

from collections import Counter
import bisect
N = int(input())
A = list(map(int,input().split()))
cnt = Counter(A)
A.sort()
ans = 0
MX = 10**6
P = [0] * (MX+1)
for a in A:
    if P[a]==0:
        for i in range(MX+1):
            x = a*i
            if x > MX:
                break
            P[x] = 1
        if cnt[a]==1:
            ans+=1
print (ans)
### BUGGY CODE ###

n = int(input())
s = 0
base = 10
while n > 0:
    n,r = divmod(n,base)
    add = r
    s += add
#print(s)
if s % 9 == 0:
    print('Yes')
else:
    print('No')



### FIXED CODE ###

n = int(input())
if n % 9 == 0:
    print('Yes')
else:
    print('No')
### BUGGY CODE ###

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


def main():
    p = 1

    n = int(input())

    for i in range(1, n+1):
        p *= i

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


if __name__ == '__main__':
    main()


### FIXED CODE ###

import math

N = int(input())
print(math.factorial(N)%(10**9+7))
### BUGGY CODE ###

N=int(input())
A=list(map(int,input().split()))
d=[[0]*(N+1) for i in range(N+1)]
for w in range(1,N+1):
    if w%2==N%2:
        for l in range(N+1-w):
            d[l][l+w]=max(d[l][l+w-1]+A[l+w-1],d[l+1][l+w]+A[l])
    else:
        for l in range(N+1-w):
            d[l][l+w]=min(d[l][l+w-1]-A[l+w-1],d[l+1][l+w]-A[l])
print(d[0][N])

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
d=[[0]*(N+1) for i in range(N+1)]
for w in range(1,N+1):
    if w%2==N%2:
        for l in range(N+1-w):
            d[l][l+w]=max(d[l][l+w-1]+A[l+w-1],d[l+1][l+w]+A[l])
    else:
        for l in range(N+1-w):
            d[l][l+w]=min(d[l][l+w-1]-A[l+w-1],d[l+1][l+w]-A[l])
print(d[0][N])
### BUGGY CODE ###

N = int(input())
GA, SA, BA = map(int, input().split())
GB, SB, BB = map(int, input().split())

def napsac(x, g1, s1, b1, g2, s2, b2):
    dp = [None for _ in range(x+1)]
    dp[0] = 0

    # def case(i, m1, m2):
    #     return 0 if i - m1 < 0 else dp[i-m1] + m2

    # for i in range(1,x+1):
    #     dp[i] = max(i, case(i, g1, g2), case(i, s1, s2), case(i, b1, b2))

    for i in range(1,x+1):
        dp[i] = max(i, 0 if i - g1 < 0 else dp[i-g1] + g2,
                       0 if i - s1 < 0 else dp[i-s1] + s2,
                       0 if i - b1 < 0 else dp[i-b1] + b2)
        
    return dp[-1]

print(napsac(napsac(N, GA, SA, BA, GB, SB, BB), GB, SB, BB, GA, SA, BA))


### FIXED CODE ###

N = int(input())
GA, SA, BA = map(int, input().split())
GB, SB, BB = map(int, input().split())

def napsac(x, g1, s1, b1, g2, s2, b2):
    dp = [0 for _ in range(x+1)]
    dp[0] = 0

    def case(i, m1, m2):
        return 0 if i - m1 < 0 else dp[i-m1] + m2

    for i in range(1,x+1):
        dp[i] = max(i, case(i, g1, g2), case(i, s1, s2), case(i, b1, b2))

    return dp[-1]

print(napsac(napsac(N, GA, SA, BA, GB, SB, BB), GB, SB, BB, GA, SA, BA))
### BUGGY CODE ###

S = input()
s_len = len(S)
ahead = len(S)
now = len(S)
while(True):
    S = S.replace('01', '').replace('10', '')
    ahead = now
    now = len(S)
    if(ahead == now):
        break
print(s_len - len(S))

### FIXED CODE ###

S = list(map(int, list(input())))
s_len = len(S)
num_one = sum(S)
print(s_len - abs(num_one*2 - s_len))