Harryxun/stf_run huggingface dataset:
#プログラムの例:
n=int(input())
listsT=list(map(int,input().split()))
from math import gcd
lists_left=[]
lists_right=[]
number1=0
number2=0
for i in range(n):
    if i==0:
        lists_left.append(0)
    if i==1:
        lists_left.append(listsT[0])
        number1=listsT[0]
    if i>=2:
        number1=gcd(number1,listsT[i-1])
        lists_left.append(number1)

number2=listsT[-1]
for j in range(n,0,-1):
    if j==n:
        lists_right.append(0)
    if j==n-1:
        lists_right.append(listsT[-1])
    if j<n-1:      
        number2=gcd(number2,listsT[j])  
        lists_right.append(number2)
ans=0
for x in range(n):
    if ans<= gcd(lists_right[x],lists_left[n-1-x]):
        ans=gcd(lists_right[x],lists_left[n-1-x])   
print(ans)

### FIXED CODE ###

#プログラムの例:
n=int(input())
listsT=list(map(int,input().split()))
from fractions import gcd
lists_left=[]
lists_right=[]
number1=0
number2=0
for i in range(n):
    if i==0:
        lists_left.append(0)
    if i==1:
        lists_left.append(listsT[0])
        number1=listsT[0]
    if i>=2:
        number1=gcd(number1,listsT[i-1])
        lists_left.append(number1)

number2=listsT[-1]
for j in range(n,0,-1):
    if j==n:
        lists_right.append(0)
    if j==n-1:
        lists_right.append(listsT[-1])
    if j<n-1:      
        number2=gcd(number2,listsT[j])  
        lists_right.append(number2)
ans=0
for x in range(n):
    if ans<= gcd(lists_right[x],lists_left[n-1-x]):
        ans=gcd(lists_right[x],lists_left[n-1-x])   
print(ans)
import numpy as p
n,M=map(int,input().split())
l=n*3+1
d=p.zeros((l,n*5),p.int64)
d[0][0]=d[1][1]=d[2][2]=d[2][-1]=1
for i in range(3,l):j,k=i-1,j-1;d[i]=(d[i-3]*(k)*(j)+p.roll(d[k],-1)*(i-1)+p.roll(d[j],1))%M
print(d[-1][:l].sum()%M)

### FIXED CODE ###

n,m=map(int,input().split())
n3=3*n
x=lambda a,b:(a+b)%mod
d=[[0]*(n+2) for i in range(n3+4)]
d[0][0]=1
for i in range(n3):
  d0,d1,d2,d3=d[i:i+4]
  for j in range(n+1):
    d1[j]=(d1[j]+d0[j])%m
    d2[j+1]=(d2[j+1]+d0[j]*(i+1))%m
    d3[j+1]=(d3[j+1]+d0[j]*(i+1)*(i+2))%m
print(sum(d[n3][:n+1])%m)
a, b = input().split()

if a + b == 15:
    print("+")
elif a * b == 15:
    print("*")
else:
    print("x")


### FIXED CODE ###

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

if a + b == 15:
    print("+")
elif a * b == 15:
    print("*")
else:
    print("x")
def main(r):
  return r*r
  

if __name__ == '__main__':
  r = int(input())
  main()

### FIXED CODE ###

r = int(input())


print(r*r)
import math

val = []
max_prime = 0

while True:
	num = int(raw_input())
	tmp = [i+1 for i in range(1, num)]
	x = math.sqrt(num)
	if len(val) != 0: 
		max_prime = val[-1]
		tmp = tmp[max_prime-1:]
	print tmp
	for i in tmp:
		if i > x: break
		for j in range(2,num):
			if i*j > num: break
			if i*j in tmp: tmp.remove(i*j)
	val += tmp[len(val):]
	print val
	print max_prime
	print len(tmp)

### FIXED CODE ###

from bisect import bisect

def sieve(n):
    num = [True]*n
    num[0] = num[1] = False
    for i in xrange(2,int(n**0.5)+1):
        if num[i]:
            for j in xrange(i**2, n, i):
                num[j] = False
    return [i for i in xrange(2,n) if num[i]]

prime =  sieve(999999)

while True:
	try:
		print bisect(prime, input())
	except:
		break
n=int(input())
a=list(map(int,input().split()))
a.sort()
tmp=set()
onaji=set()
if a[0]!=a[1]:
    tmp.add(a[0])
for i in range(1,n-1):
    flg=True
    if a[i]==a[i+1] or a[i]==a[i-1]:
        flg=False
    for j in tmp:
        if a[i]%j==0:
            flg=False
    if flg:
        tmp.add(a[i])
flg=True
if a[n-1]==a[n-2]:
    flg=False
for i in tmp:
    if a[n-1]%i==0:
        flg=False
if flg:
    tmp.add(a[n-1])
print(len(tmp))

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
a.sort()
dp=[0]*(a[-1]+1)

for i in a :
    dp[i]+=1

for i in a :
    if dp[i] :
        for j in range(i*2,a[-1]+1,i) :
            dp[j]=0

print(dp.count(1))
n = int(input())
c = 1
pp = []
mm = []
for i in range(n):
  a,b = map(int,input().split())
  if a*b == 0:
    c += 1
  else:
    pp.append(a/b)
    
c %= mod
mod = 10**9+7
from collections import Counter
p = Counter(pp)
r = 1
s = set()
for i in p.keys():
  if i in s:
    continue
  ans = p[i]
  chk = p[-1/i]
  r *= (pow(2,ans,mod)-1+pow(2,chk,mod))%mod
  r %= mod
  s.add(-1/i)
print((r*c-1)%mod)

### FIXED CODE ###

n = int(input())
m = n%10
  
if m==3:
  print('bon')
elif m==0 or m==1or m==6or m==8:
  print('pon')
else:
  print('hon')
import heapq
n, q = map(int, input().split())
event = []
for _ in range(n):
    s, t, x = map(int, input().split())
    event.append((s-x, 1, x))
    event.append((t-x, -1, x))

event.sort()
heap = []
xs = set([])

d = [int(input()) for _ in range(q)]
ans = [-1] * q
index = 0
for t, query, x in event:
    if d[index] < t:
        if not xs:
            pass
        else:
            while heap:
                tmp = heapq.heappop(heap)
                if tmp in xs:
                    heapq.heappush(heap, tmp)
                    ans[index] = tmp
                    break
        index += 1
        if index == q:
            break

    if query == 1:
        xs.add(x)
        heapq.heappush(heap, x)
    else:
        xs.remove(x)

    cnt[t] -= 1

while index < q:
    while heap:
        tmp = heapq.heappop(heap)
        if tmp in xs:
            heapq.heappush(heap, tmp)
            ans[index] = tmp
            break
    index += 1

print("\n".join(map(str, ans)))





### FIXED CODE ###

import heapq
n, q = map(int, input().split())
event = []
for _ in range(n):
    s, t, x = map(int, input().split())
    event.append((s-x, 1, x))
    event.append((t-x, -1, x))

event.sort()
heap = []
xs = set([])

d = [int(input()) for _ in range(q)] + [10**9 + 7]
ans = [-1] * q
index = 0
for t, query, x in event:
    while d[index] < t:
        if not xs:
            pass
        else:
            while heap:
                tmp = heapq.heappop(heap)
                if tmp in xs:
                    heapq.heappush(heap, tmp)
                    ans[index] = tmp
                    break
        index += 1

    if query == 1:
        xs.add(x)
        heapq.heappush(heap, x)
    else:
        xs.remove(x)


while index < q:
    while heap:
        tmp = heapq.heappop(heap)
        if tmp in xs:
            heapq.heappush(heap, tmp)
            ans[index] = tmp
            break
    index += 1

print("\n".join(map(str, ans)))
# coding=UTF-8
from collections import deque
from operator import itemgetter
from bisect import bisect_left, bisect
import itertools
import sys
import math
import numpy as np
import time
sys.setrecursionlimit(10**6)
input = sys.stdin.readline


def ev(n):
    return 0.5*(n+1)


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

    p_ev = list(map(ev, p))

    s = np.cumsom(p)

    ans = []

    for i in range(n - k):
        ans.append(s[i + k] - s[i])

    print(max(ans))


if __name__ == '__main__':
    main()


### FIXED CODE ###

# coding=UTF-8
from collections import deque
from operator import itemgetter
from bisect import bisect_left, bisect
import itertools
import sys
import math
import numpy as np
import time
sys.setrecursionlimit(10**6)
input = sys.stdin.readline


def ev(n):
    return 0.5*(n+1)


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

    p_ev = list(map(ev, p))

    s = np.cumsum(p_ev)
    s = np.insert(s, 0, 0)

    ans = []

    for i in range(n - k+1):
        ans.append(s[i + k] - s[i])

    print(max(ans))


if __name__ == '__main__':
    main()
n, d = map(int, input().split())

xy = [map(int, input().split()) for _ in range(5)]
x, y = [list(i) for i in zip(*xy)]


count = 0

for i, j in zip(x, y):
    if i*i + j*j <= d*d:
        count += 1

print(count)

### FIXED CODE ###

n, d = map(int, input().split())

xy = [map(int, input().split()) for _ in range(n)]
x, y = [list(i) for i in zip(*xy)]

count = 0

for i, j in zip(x, y):
    if i*i + j*j <= d*d:
        count += 1

print(count)
import datetime
y1,m1,d1,y2,m2,d2=map(int,input().split())
q=(y2-y1)//400
y2-=400*q
a=688*q
d=datetime.date(y1,m1,d1)
while d<=datetime.date(y2,m2,d2):
    if d.day==13 and d.weekday()==4:a+=1
    d+=datetime.timedelta(days=1)
print(a)


### FIXED CODE ###

import datetime
y1,m1,d1,y2,m2,d2=map(int,input().split())
qq,y1=divmod(y1,400)
y1+=400
qq-=1
q=(y2-y1)//400
y2-=400*q
a=688*(q-qq)
d=datetime.date(y1,m1,d1)
while d<=datetime.date(y2,m2,d2):
    if d.day==13 and d.weekday()==4:a+=1
    d+=datetime.timedelta(days=1)
print(a)
N = int(input())
A = sorted(list(map(int, input().split())))
Q = int(input())
for _ in range(Q):
    B, C = map(int, input().spit())
    if A[0] <= B <= A[-1]:
        for x in A:
            if x == B:
                x = C
        print(sum(A))
    else:
        print(sum(A))

### FIXED CODE ###

from collections import Counter 
N = int(input())
a = list(map(int, input().split()))
A = Counter(a)
Q = int(input())

ans = sum(a)
for _ in range(Q):
    B, C = map(int, input().split())
    if B in A.keys():
        if C in A.keys():
            A[C] += A[B]
        else:
            A[C] = A[B]
        ans += (C-B)*A[B]
        A[B] = 0
    print(ans)
n=int(input())
a=list(map(int,input().split()))
b=[0]*n
for i in range(n):
  b[a[i]-1]=i+1
print(" ",join(map(str,b)))


### FIXED CODE ###

n=int(input())
if n%2==0:
    print(1/2)
else:
    print((int(n/2)+1)/n)
s=list(input())
t=list(input())
dp=[[0]*(30) for j in range(30)]
ans=[]
memo=-1
for i in range(len(s)):
    for j in range(len(t)):
        if s[i]==t[j]:
             dp[i+1][j+1] = dp[i][j]+1
             if memo < i:
                 ans.append(t[j])
                 memo = i

        else:
            dp[i+1][j+1] =max(dp[i][j+1],dp[i+1][j])

#print(dp[len(s)][len(t)])
answer=[]
i,j=len(s),len(t)
d=dp[i-1][j-1]
while i>0 and j>0 :
    if dp[i-1][j-1]!=dp[i][j]:
        answer.append(s[i-1])
        i-=1
        j-=1
        continue
    elif dp[i-1][j]==dp[i][j]:
        i-=1
    elif dp[i][j-1]==dp[i][j]:
        j-=1
print("".join(reversed(answer)))

### FIXED CODE ###

s=list(input())
t=list(input())
dp=[[0]*(3030) for j in range(3030)]
ans=[]
memo=-1
for i in range(len(s)):
    for j in range(len(t)):
        if s[i]==t[j]:
             dp[i+1][j+1] = dp[i][j]+1
             if memo < i:
                 ans.append(t[j])
                 memo = i

        else:
            dp[i+1][j+1] =max(dp[i][j+1],dp[i+1][j])

#print(dp[len(s)][len(t)])
answer=[]
i,j=len(s),len(t)
d=dp[i-1][j-1]
while i>=0 and j>=0:

    if dp[i-1][j]==dp[i][j]:
        i-=1
    elif dp[i][j-1]==dp[i][j]:
        j-=1
    else:
        answer.append(s[i - 1])
        i -= 1
        j -= 1
print("".join(reversed(answer)))
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))

b=sorted(b)
c=sorted(c)

from bisect import bisect_right

d=[]
for i in range(n):
    index = bisect_right(c,b[i])
    if b[i]==c[index]:
        index-=1
    
    if index==-1:
        index=1

    d.append(n-index)

import numpy as np
s=sum(d)
cum=np.cumsum(d)

ans=0
for j in range(n):
    dex = bisect_right(b,a[j])
    if dex==0:
        ans+=s
    elif dex==n:
        continue
    else:
        ans+=s-cum[dex-1]


    

print(ans)
        


### FIXED CODE ###

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

b=sorted(b)
c=sorted(c)

from bisect import bisect_right

d=[]
for i in range(n):
    index = bisect_right(c,b[i])    

    d.append(n-index)

import numpy as np
s=sum(d)
cum=np.cumsum(d)

ans=0
for j in range(n):
    dex = bisect_right(b,a[j])
    if dex==0:
        ans+=s
    elif dex==n:
        continue
    else:
        ans+=s-cum[dex-1]

print(ans)
import math
A,B =[int(i) for i in input().split()]
result = (A*B) // math.gcd(A, B)
print(result)

### FIXED CODE ###

import fractions
A,B =[int(i) for i in input().split()]
result = (A*B) // fractions.gcd(A, B)
print(result)
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, K = LI()
    P = LI_()
    C = LI()

    ans = -INF
    for i in range(N):
        # iを含むサイクルの探索
        cycle = []
        c = i
        while True:
            c = P[c]
            cycle.append(c)
            if c == i:
                break
        len_cycle = len(cycle)

        # 最大スコアの探索
        score = 0

        # Kの残り
        r = K
        cycle_score_total = sum([C[j] for j in cycle])
        if len_cycle < K:
            # 周回して増えるなら周回する
            if cycle_score_total > 0:
                score += K // len_cycle * cycle_score_total
                # 周回後の余り
                r = K % len_cycle
            # 周回して増えないなら周回しない
            else:
                # サイクル一周までの範囲でどこまでもいける
                r = len_cycle

        # Kの残っている範囲で最大スコア探索
        cycle_score = [C[j] for j in cycle[:r]]
        cycle_score_cum = list(itertools.accumulate(cycle_score))
        score += max(cycle_score_cum)

        ans = max(score, ans)

    print(ans)

if __name__ == '__main__':
    resolve()


### FIXED CODE ###

import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, K = LI()
    P = LI_()
    C = LI()

    ans = -INF
    for i in range(N):
        # iを含むサイクルの探索
        cycle = []
        c = i
        while True:
            c = P[c]
            cycle.append(c)
            if c == i:
                break
        len_cycle = len(cycle)
        # print(i, cycle, [C[j] for j in cycle])

        # 最大スコアの探索
        score = 0
        cycle_score_total = sum([C[j] for j in cycle])
        cycle_score_cum = list(itertools.accumulate([C[j] for j in cycle]))
        # 終了地点をjと決める
        for j in range(min(len_cycle, K)):
            score = cycle_score_cum[j]
            if cycle_score_total > 0:
                score += (K - j - 1) // len_cycle * cycle_score_total
            # print(j, score)
            ans = max(score, ans)

    print(ans)

if __name__ == '__main__':
    resolve()
# GCD
def gcd(x,y):
  while y:
    x,y=y,x%y
  return x

# struct
class struct:
  def __init__(self,a,b,c):
    self.a=a
    self.b=b
    self.c=c

n=int(input())
if n==2:
  a,b=map(int,input().split())
  print(max(a,b))
  exit()
elif n==3:
  a,b,c=map(int,input().split())
  print(max(gcd(a,b),gcd(a,c),gcd(b,c)))
  exit()
else:
  l=list(map(int,input().split()))
  a=l[0]
  b=l[1]
  c=l[2]
  d=l[3]
  l2=[]
  l2.append(struct(a,b,gcd(a,b)))
  l2.append(struct(a,c,gcd(a,c)))
  l2.append(struct(a,d,gcd(a,d)))
  l2.append(struct(b,c,gcd(b,c)))
  l2.append(struct(b,d,gcd(b,d)))
  l2.append(struct(c,d,gcd(c,d)))
  l2=sorted(l2,key=lambda x:(x.c,x.a,x.b))
  aa=l2[0].a
  l3=[l2[0].c,l2[1].c,l2[2].c,l2[3].c,l2[4].c,l2[5].c]
  l3=list(set(l3))
  bb=l3[1]
  for x in l:
    xx=gcd(bb,x)
    yy=gcd(bb,aa)
    if xx<yy:
      aa=x
      bb=yy
  print(bb)

### FIXED CODE ###

# GCD
def gcd(x,y):
  while y:
    x,y=y,x%y
  return x

# struct
class struct:
  def __init__(self,a,b,c):
    self.a=a
    self.b=b
    self.c=c

n=int(input())
if n==2:
  a,b=map(int,input().split())
  print(max(a,b))
  exit()
elif n==3:
  a,b,c=map(int,input().split())
  print(max(gcd(a,b),gcd(a,c),gcd(b,c)))
  exit()
else:
  l=list(map(int,input().split()))
  a=l[0]
  b=l[1]
  c=l[2]
  d=l[3]
  l2=[]
  l2.append(struct(a,b,gcd(a,b)))
  l2.append(struct(a,c,gcd(a,c)))
  l2.append(struct(a,d,gcd(a,d)))
  l2.append(struct(b,c,gcd(b,c)))
  l2.append(struct(b,d,gcd(b,d)))
  l2.append(struct(c,d,gcd(c,d)))
  l2=sorted(l2,key=lambda x:(x.c,x.a,x.b))
  l3=[l2[0].a,l2[0].b,l2[1].a,l2[1].b]
  jama=10000000000000000
  if l3.count(l3[0])>1:
    jama=l3[0]
  if l3.count(l3[1])>1:
    jama=l3[1]
  if l3.count(l3[2])>1:
    jama=l3[2]
  if l3.count(l3[3])>1:
    jama=l3[3]
  mein=100000000000000000
  if jama==a:
    mein=gcd(gcd(b,c),d)
  if jama==b:
    mein=gcd(gcd(a,c),d)
  if jama==c:
    mein=gcd(gcd(a,c),d)
  if jama==d:
    mein=gcd(gcd(b,c),a)
  for x in l[4:]:
    xx=gcd(mein,x)
    yy=gcd(mein,jama)
    if xx<yy:
      jama=x
      mein=yy
    else:
      mein=xx
  print(mein)
def GCD(a, b):
    while a % b != 0:
        r = a % b
        a, b = b, r
    return b

ans = 0
N = int(input())
A = tuple(map(int,input().split()))
A2 = tuple(set(A))

if len(A2) <= 2:
    A2 = (A2[0],A2[0])

for i in range(N-1):
    for j in range(i+1,N):
        ans = max(ans,GCD(A2[i],A2[j]))

print(ans)

### FIXED CODE ###

def GCD(a, b):
    if a == 0 and b == 0:
        return 0
    elif a == 0:
        return b
    elif b == 0:
        return a

    while a % b != 0:
        r = a % b
        a, b = b, r
    return b

ans = 0
N = int(input())
A = tuple(map(int,input().split()))

X = [0]*N
Y = [0]*N

for i in range(1,N):
    X[i] = GCD(X[i-1],A[i-1])
for i in range(N-1)[::-1]:
    Y[i] = GCD(Y[i+1],A[i+1])

for i in range(N):
    ans = max(ans,GCD(X[i],Y[i]))

print(ans)
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string
import sys


N = int(input())
prev = None
ok = Truen
for n in range(N):
    w = input()
    if prev is None:
        prev = w
    else:
        if prev[-1] != w[0]:
            ok = False
    prev = w
if ok:
    print('Yes')
else:
    print('No')
    
 


### FIXED CODE ###

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

import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string
import sys

N = int(input())
prev = None
ok = True
seen = set()
for n in range(N):
    w = input()
    if prev is None:
        prev = w
    else:
        if prev[-1] != w[0]:
            ok = False
    if w in seen:
        ok = False
    seen.add(w)
    prev = w
if ok:
    print('Yes')
else:
    print('No')
n, k = map(int, input().split())
h = list(map(int, input().split())
attack_cnt = 0

desc_h = sorted(h, reverse=True)
for i in range(k):
  desc_h.pop(0)

print(sum(desc_h))

### FIXED CODE ###

n, k = map(int, input().split())
h = list(map(int, input().split()))
attack_cnt = 0
 
desc_h = sorted(h, reverse=True)
end = k if k <= n else n
del desc_h[0:end]
 
print(sum(desc_h))
a, b, c, k = list(map(int, input().split()))
s = 0

if k >= a:
    s = a
if (k - a - b) >= 0:
    s -= k - a - b

print(s)


### FIXED CODE ###

s = input()
t = input()

if len(t) - len(s) != 1:
    print('No')
else:
    if s == t[0:-1] and t[-1].isalpha() and t[-1].islower():
        print('Yes')
    else:
        print('No')
import functools
import fraction

N = int(input())
a = list(map(int,input().split()))
ans = 1
for i in range(N):
	a_new = a[0:i]+a[i+1:N]
	gcd = functools.reduce(math.gcd,a_new)
	ans = max(ans,gcd)

print(ans)


### FIXED CODE ###

import functools
import fractions


N = int(input())
a = list(map(int,input().split()))
ans = 1
gcd = functools.reduce(fractions.gcd,a)
s_front = [1]*N
s_back = [1]*N
s_front[0] = a[0]
s_back[0] = a[N-1]

for i in range(N):
	if i > 0:
		s_front[i] = fractions.gcd(s_front[i-1],a[i])
		s_back[i] = fractions.gcd(s_back[i-1],a[N-i-1])
for i in range(N):
	if i == 0:
		gcd_new = s_back[N-2]
	elif i == N-1:
		gcd_new = s_front[N-2]
	else:
		gcd_new = fractions.gcd(s_front[i-1],s_back[N-i-2])
	ans = max(ans,gcd_new)
print(ans)
n=int(input())
a=list(map(int,input().split()))
c=0
for i in a:while i%2==0:i,c=i/2,c+1
print(c)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
c=0
for i in a:
    while i%2==0:
        i=i/2
        c+=1
print(c)
import bisect
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort()
b.sort()
c.sort()
ans=0
for i in range(n):
  x=a[i]
  y=bisect.bisect_right(x)
  if y<n:
    z=bisect.bisect_right(b[y])
    ans+=n-z
print(ans)

### FIXED CODE ###

import bisect
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort()
b.sort()
c.sort()
ans=0
for i in range(n):
  x=b[i]
  y=bisect.bisect_left(a,x)
  z=bisect.bisect_right(c,x)
  ans+=(n-z)*y
print(ans)
x,y= map(int, input().split())
print("=" if x==y else ">" if x>y else "<")

### FIXED CODE ###

x,y= input().split()
print("=" if x==y else ">" if x>y else "<")
import sys
import numpy as np

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()

h, w = na()
a = [list(input()) for i in range(h)]
ct = 0
ds = h * w
trial = 0
pli = []
lens = [[2001 for i in range(w)] for j in range(h)]
for x in range(w):
    for y in range(h):
        if a[x][y] == '#':
            pli.append([x, y])
            lens[x][y] = 0
for y in range(h):
    for x in range(w):
        if [x, y] not in pli:
            for p in pli:
                tmp = abs(x - p[0]) + abs(y - p[1])
                if lens[x][y] > tmp:
                    lens[x][y] = tmp
print(np.max(lens))

### FIXED CODE ###

import sys
import copy
import  math
import bisect
from collections import *
from operator import itemgetter
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

h, w = na()
maze = [list(input()) for _ in range(h)]
que = deque()
d = [[-1] * w for i in range(h)]
for i in range(h):
    for j in range(w):
        if maze[i][j] == "#":
            d[i][j] = 0
            que.append((i, j))
l = 0

while que:
    x, y = que.popleft()
    l = d[x][y]
    for dx, dy in ((1, 0), (0, 1), (-1, 0), (0, -1)):
        nx = x + dx
        ny = y + dy
        if not 0 <= nx < h or not 0 <= ny < w or d[nx][ny] != -1:
            continue
        d[nx][ny] = l + 1
        que.append((nx, ny))
print(l)
P=input();print min(P.count('0'),P.count('1'))*2

### FIXED CODE ###

#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18

S = raw_input()
cnt1 = cnt2 = 0
for c in S:
    if c == '0':
        cnt1 += 1
    else:
        cnt2 += 1

print min(cnt1, cnt2) * 2

exit()

A, B, K = map(int, raw_input().split())

cnt = 0

for i in range(1, 200):
    if A % i == 0 and B % i == 0:
        cnt += 1
    if cnt == K:
        print i
        exit()
while True:
    h=int(input())
    w=int(input())
    if a==0 & b==0:
      break
    for i in range(h):
       print("#"*w)
    print()
    
    


### FIXED CODE ###

while True:
    v=input().split()
    a=int(v[0])
    b=int(v[1])
    if a==0 and b==0:
       break
    for i in range (a):
        print('#'*b)
    print()
import sys
import numpy as np

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

    if M == 0:
        print('0 0')
        sys.exit()


    p_S = []
    for i in range(M):
        p_S.append(input().split())

    uniq_ps = np.unique(p_S, axis=0)
    


    ac = 0
    wa = 0
    for arr in uniq_ps:
        if arr[1] == 'AC':
            ac += 1
        else:
            wa += 1

    print(ac, wa)

main()




### FIXED CODE ###

import sys

def main():
    N, M = list(map(int,input().split()))
    p_S = [None] * M

    wa_cnt = [0] * N
    ac_flags = [0] * N

    for i in range(M):
        p_S[i] = list(input().split())
        p_S[i][0] = int(p_S[i][0])

    wa_ans, ac_ans = 0, 0

    for j in p_S:
        if j[1] == 'WA':
            wa_cnt[j[0] - 1] += 1

        if j[1] == 'AC' and ac_flags[j[0] - 1] == 0:
            wa_ans += wa_cnt[j[0] - 1]
            ac_ans += 1
            ac_flags[j[0] - 1] = 1


    print(ac_ans, wa_ans)

main()