Harryxun/stf_run huggingface dataset:
N = int(input())
A = list(map(int,input().split()))
tmp = 0
std = sum(A)/2
index = 0
while tmp < std:
    tmp += A[index]
    index += 1
print(abs(sum(a)-sum(b)))

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
mid = sum(A)/2
length = 0
i = 0
while True:
    if length >= mid:
        length = min(abs(length-mid),abs(length-mid-A[i-1]))+mid
        break
    length += A[i]
    i += 1
print(int(length-(sum(A)-length)))
A,B = list(map(int, input().split()))
print(max(A+B,A-B,A*B)

### FIXED CODE ###

A,B = list(map(int, input().split()))
print(max(A+B,A-B,A*B))
a,b=map(int,input().split())

if a<b:
  print(str(a)*b)
else
  print(str(b)*a)

### FIXED CODE ###

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

if a<b:
  print(str(a)*b)
else:
  print(str(b)*a)
n = input()
a = list(map(int,input().split()))
inv = 0
for i in range(n):
  inv += 1 / a[i]
print( 1 / inv )

### FIXED CODE ###

n = int(input())
s = list(map(int,input().split()))
t = 0
for i in range(n):
  t += 1 / s[i]
print( 1 / t )
s = input()[::-1]
d = 1
num = 0
mod_list = [0] * 2019

for char in s:
    num += int(char) * d
    num %= 2019
    d *= 10
    d%= 2019
    counts[num] += 1

ans = mod_list[0]
for cnt in range(1, 2019):
    ans += mod_list[cnt] * (mod_list[cnt] - 1) // 2

print(ans)


### FIXED CODE ###

s = input()[::-1] # 入力文字列を逆順でsに格納

counts = [0] * 2019
counts[0] = 1

num, d = 0, 1

for char in s:
    num += int(char) * d
    num %= 2019
    d *= 10
    d%= 2019
    counts[num] += 1

ans = 0
for cnt in counts:
    ans += cnt * (cnt - 1) // 2

print(ans) # 答えの出力
a,b,c,k=map(int,input().split())
if a>=k:
  ans-k
elif a+b>=k:
  ans=a
else:
  ans=a-(k-(a+b))
print(ans)

### FIXED CODE ###

a,b,c,k=map(int,input().split())
if a>=k:
  ans=k
elif a+b>=k:
  ans=a
else:
  ans=a-(k-(a+b))
print(ans)
import numpy as np
from collections import defaultdict
import bisect

M = 1000000007
N = int(input())
left = list(map(int, input().split()))

indices = defaultdict(list)
for i, x in enumerate(left):
    indices[x].append(i)


def dp(t, n1, n2, n3):
    remaining = n1 + n2 + n3
    if remaining < 0:
        return 0
    cached = t[n1, n2, n3]
    if cached >= 0:
        return cached
    last_cnt = left[remaining - 1] + 1
    res = 0
    if last_cnt == n1:
        res += dp(t, n1 - 1, n2, n3)
        res %= M
    if last_cnt == n2:
        res += dp(t, n1, n2 - 1, n3)
        res %= M
    if last_cnt == n3:
        res += dp(t, n1, n2, n3 - 1)
        res %= M
    # print(f"{remaining}: ({n1},{n2},{n3}) => {res}")
    t[n1, n2, n3] = res
    return res


def solve():
    heads = [0, 0, 0]
    for i in range(N):
        k = len(indices[i])
        if k == 3:
            heads[0] = heads[1] = heads[2] = i + 1
        elif k == 2:
            heads[0] = heads[1] = i + 1
        elif k == 1:
            heads[0] = i + 1
        else:
            break
    t = -np.ones(shape=(heads[0] + 1, heads[1] + 1, heads[2] + 1), dtype=np.int64)
    t[0, 0, 0] = 1
    num_colors = len(indices[0])
    base = dp(t, heads[0], heads[1], heads[2])
    if len(indices[0]) < 3:
        return 3 * base
    else:
        return base


print(solve())


### FIXED CODE ###

import itertools
import sys
from collections import Counter

sys.setrecursionlimit(10 ** 9)
M = 1000000007
N = int(sys.stdin.readline())
left = list(map(int, sys.stdin.read().split()))
counter = Counter(left)


def dp(t, ns):
    cached = t.get(ns)
    if cached is not None:
        return cached
    remaining = sum(ns)
    assert remaining > 0
    last_cnt = left[remaining - 1] + 1
    n1, n2, n3 = ns
    res = 0
    if last_cnt == n1:
        res += dp(t, tuple(sorted([n1 - 1, n2, n3])))
        res %= M
    if last_cnt == n2:
        res += dp(t, tuple(sorted([n1, n2 - 1, n3])))
        res %= M
    if last_cnt == n3:
        res += dp(t, tuple(sorted([n1, n2, n3 - 1])))
        res %= M
    # print(f"{remaining}: ({n1},{n2},{n3}) => {res}")
    t[ns] = res
    return res


def solve():
    h = [0, 0, 0]
    for i in range(N):
        k = counter[i]
        if k == 3:
            h[0] = h[1] = h[2] = i + 1
        elif k == 2:
            h[0] = h[1] = i + 1
        elif k == 1:
            h[0] = i + 1
        else:
            break
    if sum(h) != N:
        return 0
    t = dict()
    t[0, 0, 0] = 1
    res = dp(t, tuple(sorted(h)))
    return (res * len(set(itertools.permutations(h)))) % M


print(solve())
import sys
def ISI(): return map(int, sys.stdin.readline().rstrip().split())

n, m = ISI()
l=ILI()
print(n-sum(l))

### FIXED CODE ###

import sys

def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def ISI(): return map(int, sys.stdin.readline().rstrip().split())

n, m = ISI()
l=ILI()
if n-sum(l)<0:print(-1)
else:print(n-sum(l))
S=input()
K=int(input())
for j in S:
	if j=='1':
		if j==K:
			co='1'
			break
	else:
		co=j
		break
print(co)

### FIXED CODE ###

a,b=map(int,input().split())
print((a-1)*(b-1))
import sys
num = sys.stdin

while True:
  a,b = map(int,num.readline().split())
  if a == 0 and b == 0:
  break

  if a < b : print(a,b)
  else: print(b,a)

### FIXED CODE ###

import sys
while True:
    a,b=map(int,sys.stdin.readline().split())
    if a==0 and b==0:
        break
    if a<b:print(a,b)
    else:print(b,a)
from collections import deque
import sys
input = sys.stdin.readline
h,w,k=map(int,input().split())
a = [list(input().rstrip()) for i in range(h)]
q = deque()
for i in range(h):
  for j in range(w):
    if a[i][j] == "#":
      a[i][j] = 0
      q.append((i,j,0))
    else:
      a[i][j] = -1
while q:
  s,t,cnt = q.popleft()
  for ns,nt in ((s+1,t),(s-1,t),(s,t+1),(s,t-1)):
    if 0<=ns<=h-1 and 0<=nt<=w-1 and a[ns][nt] == -1:
      q.append((ns,nt,cnt+1))
      a[ns][nt] = cnt+1
ans = 0
for i in range(h):
  for j in range(w):
    ans = max(ans,a[i][j])
print(ans)

### FIXED CODE ###

from collections import deque
import sys
input = sys.stdin.readline
h,w=map(int, input().split(' '))
a = [input() for i in range(h)]
nl = [[] for i in range(h)]
q = deque()
for i in range(h):
    for j in range(w):
        if a[i][j] == "#":
            nl[i].append(0)
            q.append([i,j,0])
        else:
            nl[i].append(-1)
while q:
    [s,t,cnt] = q.popleft()
    if s>0 and nl[s-1][t] == -1:
        q.append([s-1,t,cnt+1])
        nl[s-1][t] = cnt+1
    if s<h-1 and nl[s+1][t] == -1:
        q.append([s+1,t,cnt+1])
        nl[s+1][t] = cnt+1
    if t>0 and nl[s][t-1] == -1:
        q.append([s,t-1,cnt+1])
        nl[s][t-1] = cnt+1
    if t<w-1 and nl[s][t+1] == -1:
        q.append([s,t+1,cnt+1])
        nl[s][t+1] = cnt+1
ans = 0
for i in range(h):
    ans = max(ans,max(nl[i]))
print(ans)
def solve(N, XL):
    XL_re = [[xl[0] - xl[1], xl[0] + xl[1]] for xl in XL]
    XL_re = sorted(XL_re, key=lambda x: x[1])

    cnt = 0
    for i, xl in enumerate(XL_re):
        if i == 0:
            tmp = xl[1]
            cnt += 1
        else:
            if tmp <= xl[0]:
                tmp = xl[1]
                cnt += 1
    return cnt

def test():
    assert solve(4, [[2, 4], [4, 3], [9, 3], [100, 5]]) == 3

def main():
    N = int(input())
    XL = [list(map(int, input().split())) for _ in range(N)]
    ans = main(N, XL)
    print(ans)

if __name__ == "__main__":
    # test()
    main()


### FIXED CODE ###

def solve(N, XL):
    XL_re = [[xl[0] - xl[1], xl[0] + xl[1]] for xl in XL]
    XL_re = sorted(XL_re, key=lambda x: x[1])

    cnt = 0
    for i, xl in enumerate(XL_re):
        if i == 0:
            tmp = xl[1]
            cnt += 1
        else:
            if tmp <= xl[0]:
                tmp = xl[1]
                cnt += 1
    return cnt

def test():
    assert solve(4, [[2, 4], [4, 3], [9, 3], [100, 5]]) == 3

def main():
    N = int(input())
    XL = [list(map(int, input().split())) for _ in range(N)]
    ans = solve(N, XL)
    print(ans)

if __name__ == "__main__":
    # test()
    main()
import sys
N = int(sys.argv[1])
x = 800*N
y = (N/15)*200
print x - y


### FIXED CODE ###

import sys
N = int(raw_input())
assert(1 <= N <= 100)
x = 800*N
y = (N/15)*200
print x - y
import heapq

N,M = list(map(int,input().split()))
A = [int(i) for i in input().split()]

A *= -1

heapq.heapify(A)

for i in range(M):
  tmp = heapq.heappop(A) * (-1)
  heapq.heappush(A, -(tmp // 2))

print(-sum(A))


### FIXED CODE ###

import heapq

N,M = list(map(int,input().split()))
A_tmp = [int(i) for i in input().split()]

#print(A_tmp)
A = [-i for i in A_tmp]

heapq.heapify(A)
#print(A)

for i in range(M):
  tmp = heapq.heappop(A)
  heapq.heappush(A, -(-tmp // 2))
  #print(A)

print(-sum(A))
N = int(input())
A = [0]+[int(x) for x in input().split()]
dp = [0]*(N+1)
res = 0
for i in range(N):
    k = N-i
    if k < N//2:
        l = N//k
        dp[k] = A[k]-sum([dp[k*j] for j in range(2,l+1)])%2
    else:
        dp[k] = A[k]
    res += dp[k]
     
print(res)
print(' '.join([i for i,x in enumerate(dp) if x==1]))

### FIXED CODE ###

N = int(input())
A = [0]+[int(x) for x in input().split()]
res = [0]*(N+1)
sum_res = 0
for i in range(N):
    # 今見てるところ
    k = N-i
    tmp = 0
    for j in range(k,N+1,k):
       	tmp += res[j]
    res[k] = A[k] ^ tmp%2
    sum_res += res[k]
 
print(sum_res)
print(' '.join([str(i) for i,x in enumerate(res) if x==1]))
N = int(input())
print(int((N * (N-1)) / 2))

### FIXED CODE ###

S = input()
T = input()

count = 0
for i in range(3):
    if S[i] == T[i]:
        count += 1
print(count)
n=input()
t=map(int,raw_input().split())
l=[0]*(pow(10,5)+1)
for i in t:
    l[i]+=1
s=0
for x in l:
    s+=(x*(x-1))/2
for x in t:
    a=l[x]
    print s- (a*(a-1))/2 + (a-1)*(a-2)/2

### FIXED CODE ###

n=input()
t=map(int,raw_input().split())
l=[0]*(2*pow(10,5)+4)
for i in t:
    l[i]+=1
s=0
for x in l:
    s+=(x*(x-1))/2
for x in t:
    a=l[x]
    print s- (a*(a-1))/2 + (a-1)*(a-2)/2
W, H, x, y = map(int, input().split())

print(W * H / 2, end="")
print("" end="")

if x == W / 2 :
  if y == H / 2 :
    ans = 1
  else : 
    ans = 0
else :
  ans = 0
  
print(ans)

### FIXED CODE ###

W, H, x, y = map(int, input().split())

S = W * H / 2

if x == W / 2 :
  if y == H / 2 :
    n = 1
  else : 
    n = 0
else :
  n = 0
  
ans = str(S) + " " + str(n)
print(ans)
import math
print(math.floor(math.sqrt(int(input())))**2)

### FIXED CODE ###

print("YES" if input()==input()[::-1] else "NO")
n=list(map(int,input())
if n[i]==7:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

n=str(input())
for i in range(len(n)):
  if n[i]=='7':
    print('Yes')
    exit()
print('No')
students = []
for _ in range(N):
    l = list(map(int,input().split()))
    students.append(l)

check_points = []

for _ in range(M):
    l = list(map(int,input().split()))
    check_points.append(l)

minimum_points = 0

for person in students:
    minimum = 10**10
    for i in range(len(check_points)):
        d=abs(person[0]-check_points[i][0])+abs(person[1]-check_points[i][1])
        if minimum > d:
            minimum = d
            minimum_points = i
    print(minimum_points+1)


### FIXED CODE ###

N, M = map(int,input().split())
students = []
for _ in range(N):
    l = list(map(int,input().split()))
    students.append(l)

check_points = []

for _ in range(M):
    l = list(map(int,input().split()))
    check_points.append(l)

minimum_points = 0

for person in students:
    minimum = 10**10
    for i in range(len(check_points)):
        d=abs(person[0]-check_points[i][0])+abs(person[1]-check_points[i][1])
        if minimum > d:
            minimum = d
            minimum_points = i
    print(minimum_points+1)
import math

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

n = int(input())
a = [int(i) for i in input().split()]
m = []
if len(a) == 2:
    print(max(a))

else:
    for i in range(n-1):
        m.append(gcd(a[i],a[i+1]))
    m.append(gcd(a[0],a[n-1]))
    m = list(set(m))
    m.sort()
    print(m[1])


### FIXED CODE ###

from fractions import gcd

n = int(input())
a = [int(i) for i in input().split()]
l,r = [0],[0]
for i in range(1,n):
    l.append(gcd(l[i-1],a[i-1]))
    r.append(gcd(r[i-1],a[-i]))
r = r[::-1]
ans = 0

for i in range(n):
    ans = max(ans,gcd(l[i],r[i]))
print(ans)
#! /usr/bin/env python
# -*- coding: utf-8 -*-

def main():
  while True:
    n = input()
    if not n: break

    w = 0
    a = [0, 0]
    ans = 0
    for s in raw_input().split():
      f = 0 if s[0] == "l" else 1
      u = 0 if s[1] == "d" else 1
      a[f] = u
      if w == 0 and a[0] == 1 and a[1] == 1:
        w = 1
        ans += 1
      elif w == 1 and a[0] == 0 and a[1] == 0:
        w = 0
        ans += 1

    print ans

  return 0

## -------------------------------------------
## TEMPLATE

if __name__ == "__main__":
  setrecursionlimit(1024 * 1024)
  main()

### FIXED CODE ###

#! /usr/bin/env python
# -*- coding: utf-8 -*-

def main():
  while True:
    n = input()
    if not n: break

    w = 0
    a = [0, 0]
    ans = 0
    for s in raw_input().split():
      f = 0 if s[0] == "l" else 1
      u = 0 if s[1] == "d" else 1
      a[f] = u
      if w == 0 and a[0] == 1 and a[1] == 1:
        w = 1
        ans += 1
      elif w == 1 and a[0] == 0 and a[1] == 0:
        w = 0
        ans += 1

    print ans

  return 0

## -------------------------------------------
## TEMPLATE

from sys import stdin
from sys import setrecursionlimit
from copy import deepcopy
from math import sqrt
from itertools import permutations
from itertools import combinations

def getline():
  return stdin.readline()

def getLineAs(tp):
  return map(tp, getline().split())

def array(n, init = 0):
  return [deepcopy(init) for i in range(n)]

if __name__ == "__main__":
  setrecursionlimit(1024 * 1024)
  main()
from sys import setrecursionlimit
setrecursionlimit(1<<30)
def f(i,j,d):
  if i>=j:
    return 0
  if z[i][j]==-1:
    q=1<<64
    for k in xrange(i,j+1):
      q=min(q,s[j+1]-s[i]+f(i,k,d)+f(k+1,j,d))
    z[i][j]=q
  return z[i][j]
n=input()
a=map(int,raw_input().split())
s=[0]
for i in a:
  s.append(s[-1]+i)
z=[[-1]*n for i in xrange(n)]
print f(0,n-1,{})

### FIXED CODE ###

from sys import setrecursionlimit
setrecursionlimit(1<<30)
def f(i,j,d):
  if i>=j:
    return 0
  if z[i][j]==-1:
    q=1<<64
    for k in xrange(i,j):
      q=min(q,s[j+1]-s[i]+f(i,k,d)+f(k+1,j,d))
    z[i][j]=q
  return z[i][j]
n=input()
a=map(int,raw_input().split())
s=[0]
for i in a:
  s.append(s[-1]+i)
z=[[-1]*n for i in xrange(n)]
print f(0,n-1,{})
a=int(input())
if '7' in a:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

a=input()
if '7' in a:
  print('Yes')
else:
  print('No')
%%time
import scipy.stats
from sklearn.datasets import load_breast_cancer
from sklearn.svm import LinearSVC
from sklearn.model_selection import GridSearchCV
from sklearn.model_selection import RandomizedSearchCV
from sklearn.model_selection import train_test_split
from sklearn.metrics import f1_score

import pandas as pd

#乳癌データの読み込み
df=pd.read_csv("ダミーデータ.csv",index_col=0)
X=df.iloc[:, 1:].values.tolist()
y=df["y"].values

print(X)

#条件設定
max_score = 0
SearchMethod = 0
LSVC_grid = {LinearSVC(): {"C": [10 ** i for i in range(-5, 6)],
                           "multi_class": ["ovr", "crammer_singer"],
                           "class_weight": ["balanced"],
                           "random_state": [i for i in range(0, 101)]}}
LSVC_random = {LinearSVC(): {"C": scipy.stats.uniform(0.00001, 1000),
                             "multi_class": ["ovr", "crammer_singer"],
                             "class_weight": ["balanced"],
                             "random_state": scipy.stats.randint(0, 100)}}

#トレーニングデータ、テストデータの分離
train_X, test_X, train_y, test_y = train_test_split(X, y, test_size=0.2, random_state=0)

#グリッドサーチ
for model, param in LSVC_grid.items():
    clf = GridSearchCV(model, param)
    clf.fit(train_X, train_y)
    pred_y = clf.predict(test_X)
    score = f1_score(test_y, pred_y, average="micro")

    if max_score < score:
        max_score = score
        best_param = clf.best_params_
        best_model = model.__class__.__name__

#ランダムサーチ
for model, param in LSVC_random.items():
    clf =RandomizedSearchCV(model, param)
    clf.fit(train_X, train_y)
    pred_y = clf.predict(test_X)
    score = f1_score(test_y, pred_y, average="micro")

    if max_score < score:
        SearchMethod = 1
        max_score = score
        best_param = clf.best_params_
        best_model = model.__class__.__name__

if SearchMethod == 0:
    print("サーチ方法:グリッドサーチ")
else:
    print("サーチ方法:ランダムサーチ")
print("ベストスコア:{}".format(max_score))
print("モデル:{}".format(best_model))
print("パラメーター:{}".format(best_param))

#ハイパーパラメータを調整しない場合との比較
model = LinearSVC()
model.fit(train_X, train_y)
score = model.score(test_X, test_y)
print("")
print("デフォルトスコア:", score)

### FIXED CODE ###

# coding: utf-8
# Your code here!
X,Y,Z=map(int,input().split())

print(Z,X,Y)
import math
a,b,n=map(int,input().split())
List=[]
for x in range(n):
    k=math.floor((a*x)/b)-a*(math.floor(x/b))
    List.append(k)
    print(List)
print(List.index(max(List)))

### FIXED CODE ###

a,b,n=list(map(int,input().split()))
x=min(b-1,n)
ans=int(a*x/b)
print(ans)
W, H, x, y = map(int,input().split())

area_H = sorted([x * H, (W - x) * H])
area_W = sorted([y * W, (H - y) * W])

area_h = area_H[0]
area_w = area_W[0]

area = sorted([area_h, area_w])
switch = int(area_h == area_w)

print(f"{area[1]} {switch}")

### FIXED CODE ###

W, H, x, y = map(int, input().split())

is_center = int(x * 2 == W and y * 2 == H)
min_sq = W * H / 2

print("{} {}".format(min_sq, is_center))
Num = [int(n) for n in input().rstrip().split()][0]

D = [int(n) for n in inut().rstrip().split()]

numberlist = [n if n not in D for n in range(9)]

anslist = []

for num in numberlist:
    if num >= Num:
        anslist.append(num)
    else:pass

print(min(anslist))


### FIXED CODE ###

Num = [int(n) for n in input().rstrip().split()]

D = [int(n) for n in input().rstrip().split()]

for i in range(Num[0],100000):
    if len(set([str(n) for n in D]) & set(str(i))) == 0:
        print(int(i))
        break
a=[int(input()) for _ in [0]*5]
b=[-(-a//10)*10-i for i in a]
print(sum(b)+sum(a)-max(b))

### FIXED CODE ###

a=[int(input()) for _ in [0]*5]
b=[-(-i//10)*10-i for i in a]
print(sum(b)+sum(a)-max(b))
if __name__ == "__main__":
  n, k, q = list(map(int, input().split()))
  A = [k-q]*n
  for _ in range(n):
    a = int(input())
    A[a-1] += 1

  for i in range(n):
    print("Yes\n" if A[i]>0 else "No\n")

### FIXED CODE ###

if __name__ == "__main__":
  n, k, q = list(map(int, input().split()))
  A = [k-q]*n
  for _ in range(q):
    a = int(input())
    A[a-1] += 1

  for i in range(n):
    print("Yes\n" if A[i]>0 else "No\n")
import fraction
from functools import reduce


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


N, X=map(int,input().split( ))
x=list(map(int,input().split( )))
def minus_d(x):
	x = abs(x-X)
	return x

def percent_d(x):
	x = x % d
	return x

dis = list(map(minus_d, x))
ans = gcd_list(dis)
print(ans)

### FIXED CODE ###

import fractions
from functools import reduce


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


N, X=map(int,input().split( ))
x=list(map(int,input().split( )))
def minus_d(x):
	x = abs(x-X)
	return x

def percent_d(x):
	x = x % d
	return x

dis = list(map(minus_d, x))
ans = gcd_list(dis)
print(ans)
a, b, c= map(int, input().split())
if a<=b<=c:print(a, b, c)
if b<a<=c:print(b, a, c)
if a<=c<=b:print(a, c, b)
if b<c<=a:print(b, c, a)
if c<a<=b:print(c, a, b)
if c<=b<=a:print(c, b, a


### FIXED CODE ###

a, b, c= map(int, input().split())
if a<=b<=c:print(a, b, c)
if b<a<=c:print(b, a, c)
if a<=c<b:print(a, c, b)
if b<c<a:print(b, c, a)
if c<a<b:print(c, a, b)
if c<=b<=a:print(c, b, a)
while 1:
  H, W = map(int, raw_input().split())
  if (H == 0 and W == 0):
    break
 
      print ('#' * W)
      for i in range(1,H-1):
        print ('#' + '.' * (W - 2) + '#' )
      print ('#'* W)
      print" "
 

### FIXED CODE ###

while 1:
  H, W = map(int, raw_input().split())
  if (H == 0 and W == 0):
    break
 
  print ('#' * W)
  for i in range(1,H-1):
    print ('#' + '.' * (W - 2) + '#' )
  print ('#'* W)
  print""
def nibunhigh(lister, b):
    ans = 0
    low = 0
    high = len(lister) - 1

    if lister[low] > b:
        return high + 1
    elif lister[high] < b:
        return low
    else:
        while lister[low + 1] < b:
            mid = (low + high) // 2
            if (b < lister[mid]):
                high = mid
            else:
                low = mid
        ans = len(lister) - (low + 1)

    return ans

def nibunlow(lister, b):
    ans = 0
    low = 0
    high = len(lister) - 1
#    while (low + 1) <= high:
    if lister[low] > b:
        return low
    elif lister[high] < b:
        return high + 1
    else:
        while lister[low + 1] < b:
            mid = (low + high) // 2
            if (b <= lister[mid]):
                high = mid
            else:
                low = mid
        ans = low + 1

    return ans

def snukefestival(n , a , b , c):

    ans = 0
    a.sort()
    b.sort()
    c.sort()

    for i in range(n):
        ans += nibunlow(a , b[i]) * nibunhigh(c , b[i])

    return ans

def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    c = list(map(int , input().split()))
    print(snukefestival(n , a , b , c))

if __name__ == '__main__':
    main()

### FIXED CODE ###

import bisect

def snukefestival(n , a , b , c):

    ans = 0
    a.sort()
    b.sort()
    c.sort()

    for i in b:
        ab = bisect.bisect_left(a , i)
        cb = bisect.bisect_right(c , i)
        ans += ab * (len(b) - cb)

    return ans

def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    c = list(map(int , input().split()))
    print(snukefestival(n , a , b , c))

if __name__ == '__main__':
    main()
A, B = map(int, input().split
f = False
n = int(A / 8 * 100)
while n * 0.08 //1 == A:
  if n * 0.1 // 1 == B:
    f = True
    break
  n += 1
print(n if f else -1)

### FIXED CODE ###

A, B = map(int, input().split())
f = False
ans = 0
for i in range(1, 1100):
  if i * 8 // 100 == A and i // 10 == B:
    f = True
    ans = i
    break
print(ans if f else -1)
n = input()
a = list(map(int, input().split()))
print(sum(max(x[:i] <= x[i] for i in range(n))

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
print(sum(max([0] + a[:i]) <= a[i] for i in range(n)))
n,a,b = list(map(int, input().split()))
d = n*a
t = n*b
print(int(np.min([d, t])))

### FIXED CODE ###

n,a,b=map(int, input().split())
print(min(n*a, b))
S = input()

if S.replace("dream",).replace("dreamer",).replace.("erase",).replace("eraser",):
  print("NO")
else:
  print("YES")

### FIXED CODE ###

S = input()

if S.replace("eraser","").replace("erase","").replace("dreamer","").replace("dream",""):
  print("NO")
else:
  print("YES")
s = str(input())
n = len(s)
ans = 0
b = [0 for i in range(n)]
for i in range(n-1):
    if s[i] != s[i+1]:
        if b[i] == 0 and b[i+1] == 0:
            b[i] = 1
            b[i+1] = 1 
            ans += 2
            flag = True
            nowl = i
            nowr = i+1
            while flag:
                if nowl < 0 and nowr > n-1:
                    flag = False
                if b[nowl] == 1 and b[nowr] == 1:
                    nowl -= 1
                    nowr += 1
                elif b[nowl] == 1 and b[nowr] == 0:
                    nowl -= 1
                elif b[nowl] == 0 and b[nowr] == 1:
                    nowr += 1
                else:
                    if s[nowl] != s[nowr]:
                        ans += 2
                        b[nowl] += 1
                        b[nowr] += 1
                        nowl -= 1
                        nowr += 1
                    else:
                        flag = False
print(ans)
            

### FIXED CODE ###

s = str(input())
if s.count("0") > 0 and s.count("1") > 0:
    print(2*min(s.count("0"),s.count("1")))
else:
    print(0)