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

def main():
    S = input()
    N = len(S)
    from collections import deque

    def solve(S):
        cur = S[0]
        ans1 = 1
        i = 1
        plus = 1
        while i < N:
            if S[i:i+plus] == cur:
                plus += 1
            else:
                cur=S[i:i+plus]
                i = i+plus
                plus = 1
                ans1 += 1

        cur = S[:2]
        ans2 = 1
        i = 2
        plus = 1
        while i < N:
            if S[i:i+plus] == cur:
                plus += 1
            else:
                cur = S[i:i+plus]
                i = i+plus
                plus = 1
                ans2 += 1
        return ans1, ans2
    ans1, ans2 = solve(S)
    ans3, ans4 = solve(S[::-1])
    print(max(ans1, ans2, ans3, ans4))


if __name__ == '__main__':
    main()


### FIXED CODE ###

#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    S=ST()
    before = ""
    before_index = 0
    N=len(S)
    i=0
    ans=0
    while i < N:
        if before != S[before_index:i+1]:
            # print(S[before_index:i+1], before)
            ans+=1
            before=S[before_index:i+1]
            before_index=i+1
        i+=1
    print(ans)
if __name__ == '__main__':
    main()
### BUGGY CODE ###

s = input()
t = input()
len_s = len(s)
len_t = len(t)

dp = {}
for i in range(-1, len_s):
    dp[(i, -1)] = 0
for j in range(-1, len_t):
    dp[(-1, j)] = 0

for i in range(len_s):
    for j in range(len_t):
        char = s[i]
        if char == t[j]:
            dp[(i, j)] = dp[(i-1, j-1)] + 1
        else:
            dp[(i, j)] = max(dp[(i-1, j)], dp[(i, j-1)])

answer = ''
i, j = len_s - 1, len_t - 1
while i > -1 and j > -1:
    now = dp[(i, j)]
    if dp[(i-1, j)] == now:
        i -= 1
        continue
    if dp[(i, j-1)] == now:
        j -= 1
        continue
    answer += s[i]
    i -= 1
    j -= 1

print(answer[::-1])


### FIXED CODE ###

s = input()
t = input()

dp = [[0] * (len(t) + 1) for _ in range(len(s) + 1)]

for i in range(1, len(s) + 1):
    for j in range(1, len(t) + 1):
        char = s[i-1]
        if char == t[j-1]:
            dp[i][j] = dp[i-1][j-1] + 1
        else:
            dp[i][j] = max(dp[i-1][j], dp[i][j-1])

answer = ''
i, j = len(s), len(t)
now = dp[i][j]
while i > 0 and j > 0:
    if dp[i-1][j] == now:
        i -= 1
        continue
    if dp[i][j-1] == now:
        j -= 1
        continue
    answer += s[i-1]
    i -= 1
    j -= 1
    now -= 1

print(answer[::-1])
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
p=[]
cnt=[]
zero=0
for i in range(n):
	if a[i]==0:
		zero+=1
	elif a[i] not in p:
		p.append(a[i])
		cnt.append(1)
	else:
		for j in range(len(p)):
			if a[i]==p[j]:
				cnt[j]+=1
if len(p)==3:
	if cnt[0]==cnt[1]==cnt[2]==n/3:
		if p[0]&p[1]&p[2]==0:
			print("Yes")
			exit()
elif len(p)==1:
	if cnt[0]==n/3*2:
		print("Yes")
		exit()
elif len(p)==0:
	if sum(a)==0:
		print("Yes")
		exit()
print("No")




### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
p=[]
cnt=[]
zero=0
for i in range(n):
	if len(p)>=4:
		print("No")
		exit()
	if a[i]==0:
		zero+=1
	elif a[i] not in p:
		p.append(a[i])
		cnt.append(1)
	else:
		for j in range(len(p)):
			if a[i]==p[j]:
				cnt[j]+=1
if n%3!=0 and zero!=n:
	print("No")
	exit()
if len(p)>=4:
	print("No")
	exit()
if len(p)==3:
	if cnt[0]==cnt[1]==cnt[2]==n/3:
		if p[0]^p[1]^p[2]==0:
			print("Yes")
			exit()
	else:
		print("No")
		exit()
elif len(p)==1:
	if cnt[0]==n/3*2:
		print("Yes")
		exit()
elif len(p)==0:
	if sum(a)==0:
		print("Yes")
		exit()
print("No")
### BUGGY CODE ###

from collections import deque

def main():
    n, x, y = map(int, input().split())
    cnt = [0]*n
    x -= 1
    y -= 1
    q = deque()
    
    for i in range(n):
        q.appendleft(i)
        dist = [None]*n
        dist[i] = 0
        while q:
            j = q.pop()
            d = dist[j]
            cnt[d] += 1
            if j > 0 and dist[j-1] is None:
                dist[j-1] = d+1
                q.appendleft(j-1)
            if j < n-1 and dist[j+1] is None:
                dist[j+1] = d+1
                q.appendleft(j+1)
            if j == x and dist[y] is None:
                dist[y] = d+1
                q.appendleft(y)
            elif j == y and dist[x] is None:
                dist[x] = d+1
                q.appendleft(x)
    for i in range(1, n):
        print(cnt[i]//2)
                

if __name__ == "__main__":
    main()

### FIXED CODE ###

# D問題
from collections import deque
def main():
    n, x, y = map(int, input().split())
    x -= 1
    y -= 1
    inf = 10**5
    ans = [0]*n
    q = deque()
    for i in range(n):
        dist = [inf]*n
        q.appendleft(i)
        dist[i] = 0
        while q:
            v = q.pop()
            d = dist[v]
            if v-1 >= 0 and dist[v-1] == inf:
                q.appendleft(v-1)
                dist[v-1] = d+1
            if v+1 <= n-1 and dist[v+1] == inf:
                q.appendleft(v+1)
                dist[v+1] = d+1
            if v == x and dist[y] == inf:
                q.appendleft(y)
                dist[y] = d + 1
            if v == y and  dist[x] == inf:
                q.appendleft(x)
                dist[x] = d + 1
        for di in dist:
            ans[di] += 1
    for a in ans[1:]:
        print(a//2)

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

n = int(input())
p = list(map(int, input().split()))
ans = 0
d = {}
m = {}
for i in range(n):
  d[i] = p[i]
  m[i] = min(p[:i + 1])
for i in range(n):
  if p[i] == m[i]:
    ans += 1
print(ans)

### FIXED CODE ###

n = int(input())
p = list(map(int, input().split()))
ans = 1
pmin = p[0]
for i in range(1, n):
  if pmin >= p[i]:
    ans += 1
    pmin = p[i]
print(ans)
### BUGGY CODE ###

N, K = map(int, input().split())
H = [int(input()) for _ in range(N)]
H = sorted(H, reverse=True)
ans = 1e9
for i in range(N-K+1):
    h = H[i:i+K]
    dh = h[0]-h[-1]
    if dh < ans:
        ans = dh
print(ans)

### FIXED CODE ###

N, K = map(int, input().split())
H = [int(input()) for _ in range(N)]
H = sorted(H)
ans = 1e9
for i in range(N-K+1):
    ans = min(ans, H[i+K-1]-H[i])
print(ans)
### BUGGY CODE ###

import itertools
import numpy as np
N = int(input())

def prime_factorize(n):
    ans = [1]
    i = 2
    while i * i <= n:
        if n % i == 0:
            n //= i
            ans.append(i)
        else:
            i += 1
    if n != 1:
        ans.append(n)
    
    return ans

primes = prime_factorize(N)
prod = np.prod(np.array(primes))
index = [i for i in range(len(primes))]
ans = prod - 1

for i in range(1, len(primes)):
    for cmb in itertools.combinations(index, i):
        i_next = np.prod(np.array([primes[k] for k in range(len(primes)) if k in cmb]))
        j_next = prod // i_next
        ans = min(ans, i_next + j_next - 2)
            
print(ans)

### FIXED CODE ###

N = int(input())
div = []
ans = N - 1
i = 2
while i ** 2 <= N:
    if N % i == 0:
        div.append(i)
    i += 1

for d in div:
    ans = min(ans, d + N // d - 2)

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

s=raw_input()
K=input()
l=len(s)

a=set()
for diff in range(1,l+1):
	for i in range(l):
		a.add(s[i:i+diff])
b=list(a)
b.sort()

print b[K-1]

### FIXED CODE ###

s=raw_input()
K=input()
l=len(s)

a=set()
for diff in range(1,5+1):
	for i in range(l):
		a.add(s[i:i+diff])

b=list(a)
b.sort()

print b[K-1]
### BUGGY CODE ###

N = int(input())
a = list(map(int,input().split()))
atai =abs(sum(a[0:1])-sum(a[1:]))
suma = sum(a)
atai = abs(suma - 2*sum(a[:1]))
for i in range(N-1):
    h = abs(suma - 2*sum(a[:i+1]))
    atai = min(h,atai)
print(atai)

### FIXED CODE ###

N = int(input())
a = list(map(int,input().split()))
ans = sum(a) - 2*a[0]
abst = abs(ans)
for i in range(1,N-1):
    ans -=2*a[i]
    if abs(ans)<abst:
        abst = abs(ans)
print(abst)
### BUGGY CODE ###

n, m = map(int,input().split())
n_lis = [i+1 for i in range(n)]

for j in range(m):
  l, r = map(int,input().split())
  n_lis = [k for k in n_lis if k >= l and k <= r]

print(len(n_lis))

### FIXED CODE ###

n, m = map(int,input().split())
 
l_p = 1
r_p = n
 
for j in range(m):
  l, r = map(int,input().split())
  if l > l_p:
    l_p = l
  if r < r_p:
    r_p = r

a = r_p - l_p + 1

if a > 0:
  print(a)
else:
  print(0)
### BUGGY CODE ###

x, y = map(int,input().split())
li = list(map(int, input().split()))

a = 0
ans = 0
for i in range(x-y+1):
    for j in range(i,i+y):
        a += li[j]*(li[j]+1)//2/li[j]
        #print(a,i,j)
    ans = max(ans,a)
    a = 0
    
print(ans)

### FIXED CODE ###

n,k = map(int,input().split())
L = list(map(int,input().split()))
LL = []
for i in range(n):
    kitai = L[i]*(L[i]+1)//2/L[i]
    LL.append(kitai)
#print(LL)
k_sum = sum(LL[:k])
num = []
num.append(k_sum)
for i in range(1,n-k+1):
    k_sum += (LL[k+i-1] - LL[i-1])
    #print(LL[k+i-1],LL[i-1])
    num.append(k_sum)
print(max(num))
### BUGGY CODE ###

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

def abc077_c():
    N = int(readline())
    A = list(map(int, readline().split()))
    B = list(map(int, readline().split()))
    C = list(map(int, readline().split()))
    A.sort()
    B.sort()
    C.sort()
    ans = 0

    # 二分探索で Ai < Bj < Ck となる個数を数える
    from bisect import bisect_left
    for i in range(N):
        # 真に大きいが条件なので Ai + 1 が入るポイントを探す
        jst = bisect_left(B, A[i] + 1)
        if jst == N: continue
        for j in range(jst, N):
            kst = bisect_left(C, B[j] + 1)
            ans += N - kst
    print(ans)

abc077_c()

### FIXED CODE ###

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

def abc077_c():
    N = int(readline())
    A = list(map(int, readline().split()))
    B = list(map(int, readline().split()))
    C = list(map(int, readline().split()))
    A.sort()
    B.sort()
    C.sort()
    ans = 0

    from bisect import bisect_left

    # Bjに対するCの使える個数は、前処理で求めておく
    B2C = [0] * N
    # 真に大きいが条件なので Ai + 1 が入るポイントを探す
    for j in range(N):
        B2C[j] = N - bisect_left(C, B[j]+1)
    # 累積和
    accum = [0]
    for j in range(N):
        accum.append(accum[-1] + B2C[j])

    # Ai -> B は二分探索
    for i in range(N):
        jst = bisect_left(B, A[i]+1)
        if jst == N: continue
        # 前処理済みなので、Bj以降を使ったときにCが何個使えるかはすぐわかる
        ans += accum[N] - accum[jst]
    print(ans)

abc077_c()
### BUGGY CODE ###

import sys
input = sys.stdin.readline

n = int(input())
game = [0]

for _ in range(n):
    comp = list(map(int, input().split()))[::-1]
    game.append(comp)

count = 0
final = n*(n-1)//2
for day in range(1, 1000000):
    finish = set()
    possible = False
    for me in range(1, n+1):
        if me in finish or game[me] == []:
            continue

        you = game[me][-1]
        if you in finish or game[you] == []:
            continue
        else:
            if game[you][-1] == me:
                finish.add(game[you].pop())
                finish.add(game[me].pop())
                possible = True
                count += 1
            else:
                continue

    if not possible:
        print(-1)
        exit()

    if count == final:
        print(day)
        exit()

### FIXED CODE ###

from collections import deque
import sys
input = sys.stdin.readline

n = int(input())
game = {}

for i in range(1, n+1):
    game[i] = deque((map(int, input().split())))

count = 0
final = n*(n-1)//2
done = []

finish = [0] * (n + 1)
for me in range(1, n + 1):
    if finish[me] == 1 or game[me] == deque([]):
        continue

    you = game[me][0]
    if finish[you] == 1:
        continue
    else:
        if game[you][0] == me:
            done.append(you)
            done.append(me)
            finish[game[you].popleft()] = 1
            finish[game[me].popleft()] = 1
            possible = True
            count += 1
        else:
            continue

for day in range(2, 1000000):
    finish = [0]*(n+1)
    possible = False
    new_done = []
    for me in done:
        if finish[me] == 1 or game[me] == deque([]):
            continue

        you = game[me][0]
        if finish[you] == 1:
            continue
        else:
            if game[you][0] == me:
                finish[game[you].popleft()] = 1
                finish[game[me].popleft()] = 1
                new_done.append(me)
                new_done.append(you)
                possible = True
                count += 1
            else:
                continue
    done = new_done
    if not possible:
        print(-1)
        exit()

    if count == final:
        print(day)
        exit()
### BUGGY CODE ###

N = int(raw_input())
lis = []
for i in xrange(N):
	num = int(raw_input())
	if num in lis:
		lis.remove(num)
	else:
		lis.append(num)
print len(lis)

### FIXED CODE ###

from collections import Counter
N = int(raw_input())
lis = []
for i in xrange(N):
	lis.append(int(raw_input()))
lis.sort()
lister = dict(Counter(lis)).items()
count = 0
for item in lister:
	if item[1] % 2 == 1:
		count += 1
print count
### BUGGY CODE ###

n = int(input())
arr = input().split()
arr = list(map(int, arr))
a = 1
for i in arr:
    a*=i
if a>10**18:
    print("-1")
else:
    print(a)


### FIXED CODE ###

def main():
    n = int(input())
    arr = list(map(int, input().split()))
    if 0 in arr:
        print(0)
        return
    a = 1
    for i in arr:
        a*=i
        if a>10**18:
            print("-1")
            return
    
    print(a)
main()
### BUGGY CODE ###

s = input()
length_s = len(s)
list_s = list()
for i in range(length_s):
    list_s.append(s[:1])
    s = s[1:]
for i in range(length_s):
    length = len(list_s)
    if (length < 2):
        break
    for j in range(length - 1):
        if(list_s[j] != list_s[j+1]):
            del list_s[j:j+2]
            break;
print(length_s - len(list_s))


### FIXED CODE ###

from collections import Counter
def counter(li, n):
    count = Counter()
    count.update(li)
    return count[n]

import sys
input = sys.stdin.readline
S = list(input())[:-1]
S = list(map(int, S))
N = len(S)
count_0 = counter(S, 0)
count_1 = N-count_0
print(N-abs(count_1-count_0))
### BUGGY CODE ###

cnt = 0
S = input()  
for left in range(len(S)-3):
    for right in range(left+3,len(S)):
        ss = S[left:right+1]
        if int(ss) < 2019:
            continue
        sum = 0
        for i in ss:
            sum += int(i)
        if sum % 3 != 0:
            continue
        if int(ss) % 2019 == 0:
            cnt += 1
print(cnt)  


### FIXED CODE ###

from collections import Counter

S = [int(i) for i in input()]
S.reverse()
lst = []
_sum = 0

for i in range(len(S)):
    _sum = (_sum + S[i] * pow(10,i,2019)) % 2019
    lst.append(_sum)
    
C = Counter(lst)    
ans = C[0]

for i in C:
    ans += C[i]*(C[i]-1)//2
print(ans)
### BUGGY CODE ###

N,K = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
if a[0] >= K:
    print(0)
    exit()

a = [a[i] for i in range(N) if a[i]<K]
N = len(a)
ans = N
dp = [False]*K
dp[0] = True
Smax = 0
for i,a_ in reversed(list(enumerate(a))):
    if Smax + a_ >= K:
        ans = i
    updated = True
    for j in range(min(Smax,K-a_-1),-1,-1):
        if dp[j]:
            dp[j+a_]=True
            if updated:
                Smax = max(Smax,j+a_)
                updated = False

print(ans)

### FIXED CODE ###

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

def f(N,K,a):
    a.sort()
    if a[0] >= K:
        print(0)
        exit()

    a = [a[i] for i in range(N) if a[i]<K]
    N = len(a)
    ans = N
    dp = [False]*K
    dp[0] = True
    Smax = 0
    for i,a_ in reversed(list(enumerate(a))):
        if Smax + a_ >= K:
            ans = i
        updated = True
        for j in range(min(Smax,K-a_-1),-1,-1):
            if dp[j]:
                dp[j+a_]=True
                if updated:
                    Smax = max(Smax,j+a_)
                    updated = False
    return ans

print(f(N,K,a))
### BUGGY CODE ###

def main():
    S=input()
    Q=int(input())
    Left=[]
    Right=[]

    reverse_flag=0
    for i in range(Q):
        query=input().split()
        if query[0]=="1":
            if reverse_flag==1:
                reverse_flag=0
            else:
                reverse_flag=1
        else:
            if query[1]=="1":
                if reverse_flag==0:
                    Left.append(query[2])
                else:
                    Right.append(query[2])
            else:
                if reverse_flag==0:
                    Right.append(query[2])
                else:
                    Left.append(query[2])

    res=""
    if reverse_flag==0:
        while len(Left)>0:
            res+=Left.pop()
        res+=S
        for r in Right:
            res+=r
    else:
        while len(Right)>0:
            res+=Right.pop()
        S=list(S)
        while len(S)>0:
            res+=S.pop()
        for l in Left:
            res+=l
    print(res)

if __name__=="__main__":
    main()

### FIXED CODE ###

def main():
    S=input()
    Q=int(input())
    Left=[]
    Right=[]

    reverse_flag=0
    for i in range(Q):
        query=input().split()
        if query[0]=="1":
            if reverse_flag==1:
                reverse_flag=0
            else:
                reverse_flag=1
        else:
            if query[1]=="1":
                if reverse_flag==0:
                    Left.append(query[2])
                else:
                    Right.append(query[2])
            else:
                if reverse_flag==0:
                    Right.append(query[2])
                else:
                    Left.append(query[2])

    res=""
    if reverse_flag==0:
        Left.reverse()
        res+="".join(Left)
        res+=S
        res+="".join(Right)

    else:
        Right.reverse()
        res+="".join(Right)
        S=list(S)
        S.reverse()
        res+="".join(S)
        res+="".join(Left)
    print(res)

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

from collections import deque
import sys
input = sys.stdin.readline

H, W = list(map(int, input().split()))
S = [input() for _ in range(H)]

ans = 0

for j in range(H):
    for i in range(W):
        if S[j][i] != ".":
            continue
        m = [[-1] * W for _ in range(H)]

        q = deque()
        q.append((j, i, 0))

        while q:
            y, x, v = q.popleft()
            m[y][x] = v
            for d in ((y, x + 1), (y, x-1), (y+1, x), (y-1, x)):
                dj, di = d
                if 0 <= dj < H and 0 <= di < W and S[dj][di] == "." and m[dj][di] == -1:
                    q.append((dj, di, v+1))
                    if ans < v+1:
                        ans = v+1
print(ans)


### FIXED CODE ###

from collections import deque
import sys
input = sys.stdin.readline

H, W = list(map(int, input().split()))
S = ["#" * (W+2)] + ["#" + input().strip() +
                     "#" for _ in range(H)] + ["#" * (W+2)]

ans = 0

for j in range(1, H+1):
    for i in range(1, W+1):
        if S[j][i] != ".":
            continue
        m = [[-1] * (W+2) for _ in range(H+2)]

        q = deque()
        q.append((j, i, 0))
        m[j][i] = 0

        while q:
            y, x, v = q.popleft()
            if ans < v:
                ans = v
            for dj, di in ((y, x+1), (y, x-1), (y+1, x), (y-1, x)):
                if S[dj][di] == "#" or m[dj][di] != -1:
                    continue
                q.append((dj, di, v+1))
                m[dj][di] = v+1
print(ans)
### BUGGY CODE ###

n = int(input())
an = list(map(int, input().split()))
n_list = [0]*n

for i in range(n):
  n_list[an[i]-1] += 1

for j in range(n):
  n_list1 = n_list[:]
  n_list1[an[j]-1] -= 1
  print(int(sum([x*(x-1)/2 for x in n_list1])))
  


### FIXED CODE ###

n = int(input())
an = list(map(int, input().split()))
n_list = [0]*n

for i in range(n):
  n_list[an[i]-1] += 1
n_sum = int(sum([x*(x-1)/2 for x in n_list]))

for j in range(n):
  n_remove = n_list[an[j]-1] - 1
  print(n_sum - n_remove)
### BUGGY CODE ###

import statistics
import copy
N = int(input())
X = list(map(int,input().split(" ")))
Y = copy.deepcopy(X)
Y.sort()
for i in range(N):
    Z = copy.deepcopy(Y)
    Z.remove(X[i])
    print(Z[N//2-1])


### FIXED CODE ###

import copy
N = int(input())
X = list(map(int,input().split(" ")))
Y = copy.deepcopy(X)
Y.sort()
B = (Y[N//2]+Y[N//2-1])/2

for i in range(N):
    if X[i] <= B:
        print(Y[N//2])
    else:
        print(Y[N//2-1])