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

from queue import Queue


def disintegration_Bridge(index):
    ConnectMatrix[index[0]][index[1]] = '0'
    ConnectMatrix[index[1]][index[0]] = '0'


def Calculate_inconveniece(group):
    if len(group) == 1:
        return 0
    else:
        Mysum = 0
        group_count = len(group)
        for i in range(group_count):
            num_group1 = len(group[i])
            for j in range(i + 1, group_count):
                Mysum += num_group1 * len(group[j])
        return Mysum


n, m = map(int, input().split())
a = [input().split() for i in range(m)]
a = [(int(i[0]), int(i[1])) for i in a]
ConnectMatrix = [['0' for i in range(n + 1)] for j in range(n + 1)]

for bridge in a:
    ConnectMatrix[bridge[1]][bridge[0]] = '1'
    ConnectMatrix[bridge[0]][bridge[1]] = '1'

for i in a:
    # 橋の崩落
    disintegration_Bridge(i)
    mydic = ['0' for i in range(n + 1)]
    root = [[i for i in range(n + 1) if ConnectMatrix[j][i] == '1'] for j in range(n + 1)]
    group = []

    q = Queue()
    counter = 0
    for index in range(1, n + 1):
        if mydic[index] == '1':
            continue
        q.put(index)
        mydic[index] = '1'
        group.append([index])
        while not q.empty():
            focus = q.get()
            for j in root[focus]:
                if type(j) == int:
                    if mydic[j] == '0':
                        mydic[j] = '1'
                        group[counter].append(j)
                        q.put(j)
                else:
                    for node in j:
                        if mydic[node] == '0':
                            mydic[node] = '1'
                            q.put(node)
                            group[counter].append(j)
        counter += 1
    # print(group)
    print(Calculate_inconveniece(group))


### FIXED CODE ###

class UnionFind:
    Parents = None

    def __init__(self, N):
        self.Parents = [-1 for i in range(N + 1)]

    # Aがどのグループにいるのか調べる
    def root(self, A):
        if self.Parents[A] < 0:
            return A
        else:
            self.Parents[A] = self.root(self.Parents[A])
            return self.Parents[A]

    # Aが所属しているグループのサイズを返す
    def size(self, A):
        return -self.Parents[self.root(A)]

    # AとBをくっつける
    def Connect(self, A, B):
        if self.root(A) == self.root(B):
            return False
        if self.size(A) < self.size(B):
            self.Parents[self.root(B)] += self.Parents[self.root(A)]
            self.Parents[self.root(A)] = B
        else:
            self.Parents[self.root(A)] += self.Parents[self.root(B)]
            self.Parents[self.root(B)] = A
        return True


n, m = map(int, input().split())
a = [input().split() for i in range(m)]
a = [(int(i[0]), int(i[1])) for i in a]
ans = [int(n * (n - 1) / 2) for i in range(m)]
uni = UnionFind(n)

for i in range(m):
    if i == 0:
        continue
    A = a[-i][0]
    B = a[-i][1]

    if uni.root(A) != uni.root(B):
        ans[i] = ans[i-1] - uni.size(A) * uni.size(B)
        uni.Connect(A, B)
    else:
        ans[i] = ans[i-1]


for i in range(1, m+1):
    print(ans[-i])
### BUGGY CODE ###

import math
n = int(input())

s = 0
for i in range(1,n+1):
    for j in range(1,n+1):
        for k in range(1,n+1):
            s += math.gcd(math.gcd(i,j),k)
print(s)

### FIXED CODE ###

import math
n = int(input())

s = 0
for i in range(1,n+1):
    for j in range(1,n+1):
        tmp = math.gcd(i,j)
        for k in range(1,n+1):
            s += math.gcd(tmp,k)

print(s)
### BUGGY CODE ###

n = int(input())
s = input()

R = s.count('R')
G = s.count('G')
B = n - R - G

err = 0
for i in range(n - 2):
    span = 1
    while i + 2 * span < n:
        if all([s[i + span * t] for t in range(3)].count(c) for c in ['R', 'G', 'B']):
            err += 1
        span += 1

print(R * G * B - err)

### FIXED CODE ###

n = int(input())
s = input()

R = s.count('R')
G = s.count('G')
B = n - R - G

err = 0
for i in range(n - 2):
    span = 1
    while i + 2 * span < n:
        if s[i] != s[i + span] and s[i + span] != s[i + 2 * span] and s[i + 2 * span] != s[i]:
            err += 1
        span += 1

print(R * G * B - err)
### BUGGY CODE ###

def calcExValue(N):
    ev = []
    for i in range(1, N +1):
        ev.append(i * (1/N))
    return(sum(ev))

N, K = [int(i) for i in input().split()]
array = [int(i) for i in input().split()]

max_exv = 0

base_evs = [calcExValue(array[i]) for i in range(K)]

max_evs_sum = sum(base_evs)

for i in range(K,N):
    ev = calcExValue(array[i])
    del base_evs[0]
    base_evs.append(ev)
    if sum(base_evs) > max_evs_sum:
        max_evs_sum = sum(base_evs)
    
print(max_evs_sum)

### FIXED CODE ###

import numpy as np

N, K = [int(i) for i in input().split()]
numbers = [int(i) for i in input().split()]

ary = np.array([(1 + n) / 2 for n in numbers])

cumsum = ary.cumsum()

max_exv = cumsum[K-1]
for i in range(N - K):
    if cumsum[i+K] - cumsum[i] > max_exv:
        max_exv = cumsum[i+K] - cumsum[i]
    
print(max_exv)
### BUGGY CODE ###

# coding: utf-8
# Your code here!
import sys
import math
from itertools import chain

def input():
    return sys.stdin.readline().rstrip()

def is_prime(n):
    if n == 1: return False
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True

Q = int(input())
a = [list(map(int, input().split())) for _ in range(Q)]
s = []
min_num = min(list(chain.from_iterable(a)))
max_num = max(list(chain.from_iterable(a)))
ctr = 0

for j in range(min_num, max_num + 1, 2):
    if is_prime(j) and is_prime((j + 1) // 2):
        s.append(j)

for i in range(Q):
    for k in s:
        if k >= a[i][0] and k <= a[i][1]:
            ctr += 1
    print(ctr)
    ctr = 0

### FIXED CODE ###

# coding: utf-8
# Your code here!
import sys
import math
from itertools import chain

def input():
    return sys.stdin.readline().rstrip()

def is_prime(n):
    if n == 1: return False
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True

Q = int(input())
a = [list(map(int, input().split())) for _ in range(Q)]
s = []
min_num = min(list(chain.from_iterable(a)))
max_num = max(list(chain.from_iterable(a)))
ctr = 0

for j in range(min_num, max_num + 1, 2):
    if is_prime(j) and is_prime((j + 1) // 2):
        s.append(j)

for i in range(Q):
    for k in s:
        if k >= a[i][0] and k <= a[i][1]:
            ctr += 1
    print(ctr)
    ctr = 0
### BUGGY CODE ###

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

## Library

import sys
from fractions import gcd
import math
from math import ceil,floor
import collections

## input

# n=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]

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

## Logic

X = 0

for i in range(0,99999):
    X = max(X, A.count(i-1)+A.count(i)+A.count(i+1))
print(X)



### FIXED CODE ###

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

## Library

import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter

## input

# n=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]

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

## Logic

C = Counter(A)
X = 0
for i in range(10**5):
    X = max(X,C[i]+C[i+1]+C[i+2])
print(X)
### BUGGY CODE ###

S=input()
Q=int(input())

for i in range(Q):
    array=input().split()
    array[0]=int(array[0])

    if array[0]==1:
        S=S[::-1]

    if array[0]==2:
        array[1]=int(array[1])
        if array[1]==1:
            S=''.join([array[2],S])
            
        else:
            S=''.join([S,array[2]])

print(S)

### FIXED CODE ###

S=input()

Q=int(input())

inst=[]
for i in range(Q):
    array=input().split()
    inst.append(tuple(array))

rev=True
front_str=[]
back_str=[]
for i in range(Q):
    if int(inst[i][0])==1:
        rev=not rev
    elif rev:
        if int(inst[i][1])==1:
            front_str.append(inst[i][2])
        else:
             back_str.append(inst[i][2])
    else:
        if int(inst[i][1])==1:
            back_str.append(inst[i][2])
        else:
            front_str.append(inst[i][2])

if rev:
    front_str.reverse()
else:
    back_str.reverse()
    S=S[::-1]

front="".join(front_str)
back="".join(back_str)

if rev:
    print(front+S+back)
else:
    print(back+S+front)
### BUGGY CODE ###

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



max_n = 0
max_i = 0
for i in range(n-k+1):
    sum_dice = sum(dice[i:k+i])
    if sum_dice > max_n:
        max_n = sum_dice
        max_i = i

sum_odds = 0
for i in range(k):
    sum_odds += (dice[max_i+i]-1)*0.5+1
print(sum_odds)

### FIXED CODE ###

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

dice_cumsum = [0]*(n+1)

for i in range(1,n+1):
    dice_cumsum[i] = dice_cumsum[i-1] + dice[i-1]
    
max_n = 0
max_i = 0
for i in range(n-k+1):
    sum_dice = dice_cumsum[k+i] - dice_cumsum[i]
    if sum_dice > max_n:
        max_n = sum_dice
        max_i = i

sum_odds = 0
for i in range(k):
    sum_odds += (dice[max_i+i]-1)*0.5+1

print(sum_odds)
### BUGGY CODE ###

def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()
    
    array_result.append(data.split(" "))

    flg = 1

    try:

        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

            else:

                flg = 0
    finally:

        return array_result

arr_data = getinputdata()

n = int(arr_data[0][0])
k = int(arr_data[0][1])

arr = [int(x) for x in arr_data[1]]
mindata = min(arr)
arr_replace = [mindata for x in range(k)]

cnt = 0
idx=arr.index([x for x in arr if x !=mindata][0])
#
#print(all(x == mindata for x in arr[idx:]),arr[idx:],idx,arr[idx:idx+k],arr[idx+k-1:idx+k-1+k])
#
#idx=5
#
#print(all(x == mindata for x in arr[idx:]),arr[idx:],idx,arr[idx:idx+k],arr[idx+k-1:idx+k-1+k])


while not (all(x == mindata for x in arr)):
    
    if not(all(x == mindata for x in arr[idx:idx + k])):
        cnt += 1
        arr[idx:idx + k] = arr_replace
    
    if not(all(x == mindata for x in arr[idx + k-1:idx + k-1 + k])):
        cnt += 1
        arr[idx + k-1:idx + k-1 + k] = arr_replace
    
    idx += k-1 + k-1
    
#    print(idx,arr)
#    print(arr[idx+1:])
#    print([x for x in arr[idx+1:] if x !=mindata])
#    print(len([x for x in arr[idx+1:] if x !=mindata]))
    
#    print(cnt)
#    if len([x for x in arr[idx+1:] if x !=mindata])!=0:
#        
#        idx=arr.index([x for x in arr[idx+1:] if x !=mindata][0])-1
#        
#    else:
#        break
#    
#    
print(cnt) 
    
    
    


### FIXED CODE ###

def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()
    
    array_result.append(data.split(" "))

    flg = 1

    try:

        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

            else:

                flg = 0
    finally:

        return array_result

arr_data = getinputdata()

n = int(arr_data[0][0])
k = int(arr_data[0][1])

arr = [int(x) for x in arr_data[1]]

cnt=1
if n <= k:
    
    print(cnt)
    
else:
    
    chkflg = True
    
    while chkflg:
        
        cnt+=1

        s = k + 1 + (k-1) * (cnt-2)
        e = k * 2-1 + (k-1) * (cnt-2)
        
        if s<=n<=e:
            
            chkflg=False
            
            
    print(cnt)
### BUGGY CODE ###

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

order = []

for i in range(N):
    order.append(A.index(i+1)+1)
    
print(' '.join(map(str, order)))

### FIXED CODE ###

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

student = [0] * N
for i in range(N):
  student[A[i]-1] = i + 1
  
print(' '.join(map(str, student)))
### BUGGY CODE ###

import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt
from copy import deepcopy


def main():
    k = int(input())

    if k%2 == 0:
        print(-1) 
        sys.exit()

    num = "7"
    ans = 1
    while(int(num)%k != 0):
        num += "7"
        ans += 1

    print(ans)

if __name__ == '__main__':
	main()


### FIXED CODE ###

import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt
from copy import deepcopy


def main():
    k = int(input())

    if k%2 == 0 or k%5 == 0:
        print(-1) 
        sys.exit()

    mod = 7
    for i in range(1,10**6+1):   
        
        if mod%k == 0:
            print(i)
            sys.exit()
        mod = (mod*10 + 7)%k

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

from functools import lru_cache
N,K = map(int,input().split())
mod = 10**9 + 7
counts = [0]*(K)
ans = 0 
for x in range(K,0,-1):
    y = K//x
    counts[x-1] = y**N%mod
    if y >= 2:
        for i in range(2,y+1):
            counts[x-1] -=counts[i*x-1]%mod 
            counts[x-1] %= mod
    ans +=x*counts[x-1]% mod
    ans%=mod  
print(ans)

### FIXED CODE ###

def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n, k = map(int, input().split())
    mod = 10 ** 9+ 7
    table = [0]*(k+1)
    ans= 0
    for i in range(k, 0, -1):
        table[i] = pow(k//i, n, mod)
        j = 2
        while i*j <= k:
            table[i] -= table[i*j]
            table[i] %= mod
            j += 1
        ans += i*table[i]
        ans %= mod
    print(ans)



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

N, M = map(int, input().split())
nums = list(map(int, input().split()))
tik = 0
while tik < M:
    nums.sort(reverse=True)
    num = nums[0] // 2
    for i in range(N):
        if tik == M:
            break
        if nums[i] > num:
            nums[i] = nums[i] // 2
            tik += 1
        else:
            break
print(sum(nums))

### FIXED CODE ###

N, M = map(int, input().split())
nums = list(map(int, input().split()))
tik = 0
while tik < M:
    nums.sort(reverse=True)
    nums[0] = nums[0] // 2 
    tik += 1
    if tik == M:
        break
    for i in range(1,N):
        if tik == M:
            break
        if nums[i] > nums[0]:
            nums[i] = nums[i] // 2
            tik += 1
        else:
            break
print(sum(nums))
### BUGGY CODE ###

s = input()
q = int(input())
rev = 0
for i in range(q):
    query = list(map(str, input().split()))
    if len(query) == 1:
        rev = (rev + 1) % 2
    else:
        if rev == 0:
            if int(query[1]) == 1:
                s = query[2] + s
            else:
                s = s + query[2]
        else:
            if int(query[1]) == 2:
                s = query[2] + s
            else:
                s = s + query[2]
if rev == 1:
    s = s[::-1]
print(s)            

### FIXED CODE ###

import sys
input = sys.stdin.readline
s = input().rstrip()
q = int(input())
query = []
rev = 0
for i in range(q):
    query.append(list(map(str, input().split())))
sa = []
sb = []
for i in range(q):
    if len(query[i]) == 1:
        rev = (rev + 1) % 2
    else:
        if rev == 0:
            if query[i][1] == '1':
                sa.append(query[i][2])
            else:
                sb.append(query[i][2])
        else:
            if query[i][1] == '2':
                sa.append(query[i][2])
            else:
                sb.append(query[i][2])
ssa = ''.join(sa)
ssa = ssa[::-1]
ssb = ''.join(sb)
ss = ssa + s + ssb
if rev == 1:
    ss = ss[::-1]
print(ss)
### BUGGY CODE ###

n, k = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]

mod = 10**9 + 7

def matmul(A, B):
    C = [[0] * len(B[0]) for _ in range(len(A))]
    for i in range(len(A)):
        for k in range(len(B)):
            for j in range(len(B[0])):
                C[i][j] += A[i][k] * B[k][j]
                C[i][j] %= mod
    return C

def matpow(A, n):
    B = [[0] * len(A[0]) for _ in range(len(A))]
    for i in range(len(A)):
        B[i][i] = 1
    while n:
        if n & 1:
            B = matmul(B, A)
        A = matmul(A, A)
        n >>= 1
    return B

A = matpow(a, k)
ans = 0
for Ai in A:
    for Aij in Ai:
        ans += Aij
        ans %= mod

print(ans)



### FIXED CODE ###

n, k = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]

mod = 10**9 + 7

def matmul(A, B):
    C = [[0] * len(B[0]) for _ in range(len(A))]
    for i in range(len(A)):
        for k in range(len(B)):
            for j in range(len(B[0])):
                C[i][j] += A[i][k] * B[k][j]
                C[i][j] %= mod
    return C

def matpow(A, n):
    B = [[0] * len(A[0]) for _ in range(len(A))]
    for i in range(len(A)):
        B[i][i] = 1
    while n:
        if n & 1:
            B = matmul(B, A)
        A = matmul(A, A)
        n >>= 1
    return B

A = matpow(a, k)
ans = 0
for Ai in A:
    for Aij in Ai:
        ans += Aij
        ans %= mod

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

# -*- coding: utf-8 -*-
n,m = map(int, input().split())
s = input()
t = input()

def gcd(a,b):
    if a<b:
        a,b = b,a
    if b==0:
        return a
    c = a%b
    return gcd(b,c)

def lcm(a,b):
    return a*b//gcd(a,b)

l = lcm(n,m)
ls = ["." for _ in range(l)]

for i in range(n):
    if i*m%n==0:
        j = i*m//n
        if s[i]!=t[j]:
            print(-1)
            exit()
print(l)

# for i in range(n):
#     ls[i*l//n] = s[i]
# for i in range(m):
#     if ls[i*l//m]!="." and ls[i*l//m]!=t[i]:
#         print(-1)
#         exit()
# print(l)


### FIXED CODE ###

# -*- coding: utf-8 -*-
n,m = map(int, input().split())
s = input()
t = input()

def gcd(a,b):
    if a<b:
        a,b = b,a
    if b==0:
        return a
    c = a%b
    return gcd(b,c)

def lcm(a,b):
    return a*b//gcd(a,b)

l = lcm(n,m)

for i in range(n):
    if i*m%n==0:
        j = i*m//n
        if s[i]!=t[j]:
            print(-1)
            exit()
print(l)

# for i in range(n):
#     ls[i*l//n] = s[i]
# for i in range(m):
#     if ls[i*l//m]!="." and ls[i*l//m]!=t[i]:
#         print(-1)
#         exit()
# print(l)
### BUGGY CODE ###

n = int(input())
a = [int(i) for i in input().split()]

a.sort(reverse=True)


count = 0
# i<n-1
"""
for i in range(n-1):
    if a[i] != a[i+1] and a[i] != a[i-1]:
        if all([a[i] % a[j] != 0 for j in range(i + 1, n)]):
            count += 1
"""
for i in range(n-1):
    if a[i] != a[i+1] and a[i] != a[i-1]:
        for j in range(i+1, n):
            if a[i] % a[j] == 0:
                break
            if j == n-1:
                count += 1

# i==n-1
if a[n-2] != a[n-1]:
    count += 1

if n != 1:
    print(count)
elif n == 1:
    print(1)

### FIXED CODE ###

n = int(input())
a = [int(i) for i in input().split()]

a.sort()
Max = a[-1]
memo = [1] * (Max+1)
count = 0

# i<n-1
for i in range(n-1):
    t = a[i]
    if memo[t] == 1:
        if a[i] != a[i+1]:
            count += 1
        for j in [t*k for k in range(1, Max//t+1)]:
            memo[j] = 0
# i=n-1
if memo[a[n-1]] == 1:
    count += 1

print(count)

""" #Time over
a.sort(reverse=True)

count = 0
# i<n-1
for i in range(n-1):
    if a[i] != a[i+1] and a[i] != a[i-1]:
        for j in range(n-1, i, -1):
            if a[i] % a[j] == 0:
                break
            if j == i+1:
                count += 1

# i==n-1
if a[n-2] != a[n-1]:
    count += 1

if n != 1:
    print(count)
elif n == 1:
    print(1)
"""
### BUGGY CODE ###

n=int(input())
s=input()

ans=n

for i in range(n):

    ans=min(ans,s[0:i].count("W")+s[i+1:n].count("E"))
    
print(ans)

### FIXED CODE ###

n=int(input())
s=input()

a=0
b=0
e=[]
w=[0]
ans=[]

for i in s:
    if i==("E"):
        a+=1
    else:
        b+=1
    e.append(a)
    w.append(b)
        
for i in range(n):
    ans.append(e[n-1]-e[i]+w[i])

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

import heapq
n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(n+1):
  m=0
  b1=a[:n+i]
  b2=a[n+i:]
  for j in range(len(b1)):
    b1[j]=-b1[j]
  heapq.heapify(b1)
  heapq.heapify(b2)
  for j in range(n):
    b=-heapq.heappop(b1)
    m+=b
    b=heapq.heappop(b2)
    m-=b
  if ans<m or i==0:
    ans=m
print(ans)

### FIXED CODE ###

import heapq
n=int(input())
a=list(map(int,input().split()))
ans=[0 for i in range(n+1)]
ans[0]=sum(a[:n])
b=a[:n]
heapq.heapify(b)
sb=sum(b)
for i in range(n):
  sb+=a[n+i]
  c=heapq.heappushpop(b,a[n+i])
  sb-=c
  ans[i+1]=sb
b=a[2*n:]
for i in range(n):
  b[i]=-b[i]
heapq.heapify(b)
ans[n]+=sum(b)
sb=sum(b)
for i in range(n-1,-1,-1):
  sb-=a[n+i]
  c=heapq.heappushpop(b,-a[n+i])
  sb-=c
  ans[i]+=sb
print(max(ans))
### BUGGY CODE ###

memo = {}

def dfs(i, ub):
    if (i, ub) in memo:
        return memo[(i, ub)]
    if i == K:
        return 1
    ret = 0
    x = 1
    while x <= ub:
        ret = (ret + dfs(i+1, N // x)) % mod
        x += 1
    memo[(i, ub)] = ret
    return ret

N, K = map(int, input().split())
mod = 10**9 + 7
print(dfs(0, N))

### FIXED CODE ###

from itertools import accumulate

N, K = map(int, input().split())
mod = 10**9 + 7

xs = []
x = 1
while x * x <= N:
    xs.append(N // x)
    x += 1
s = x - 1
y = 1
while y < N // y:
    xs.append(y)
    y += 1
xs = list(set(xs))
xs.sort()
compress = {x : i for i, x in enumerate(xs)}

dp = [[0] * len(compress) for _ in range(K)]
for x, i in compress.items():
    dp[-1][i] = x

for k in range(K-1)[::-1]:
    cum = list(accumulate([0] + dp[k+1]))
    for x, i in compress.items():
        a = max(compress[N // x], compress[N // s])
        dp[k][i] = (cum[-1] - cum[a]) % mod

    b = 1
    cum = [0] * len(compress)
    while b < N // b:
        cnt = N // b - N // (b + 1)
        cum[compress[b]] = (cum[compress[b]] + cnt * dp[k+1][compress[b]]) % mod
        b += 1
    cum = list(accumulate([0] + cum))
    for x, i in compress.items():
        b = N // x
        if x <= b:
            continue
        dp[k][i] += cum[-1] - cum[compress[b]+1]
        dp[k][i] += (x - N // (b + 1)) * dp[k+1][compress[b]]
        dp[k][i] %= mod
print(dp[0][-1])
### BUGGY CODE ###

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

adic = {}
bdic = {}
cdic = {}


setabc = list(sorted(list(set(a) | set(b) | set(c))))

setdict = {}
for i in range(len(setabc)):
    setdict.update({setabc[i]:i})
    

for i in range(len(a)):
    if setdict[a[i]] in adic:
        adic[setdict[a[i]]] =  adic[setdict[a[i]]] + 1 
    else:
        adic.update({setdict[a[i]]:1})

for i in range(len(b)):
    if setdict[b[i]] in bdic:
        bdic[setdict[b[i]]] =  bdic[setdict[b[i]]] + 1 
    else:
        bdic.update({setdict[b[i]]:1})

for i in range(len(c)):
    if setdict[c[i]] in cdic:
        cdic[setdict[c[i]]] =  cdic[setdict[c[i]]] + 1 
    else:
        cdic.update({setdict[c[i]]:1})




        
        
summer = 0
for j in bdic.keys():
    ai = 0
    ci = 0
    for i in adic.keys():
        if i < j:
            ai = ai + adic[i]
    for k in cdic.keys():
        if k > j:
            ci = ci + cdic[k]
    summer = summer + bdic[j] * ai * ci       
print(summer)
                
    
            

### FIXED CODE ###

N = int(input())
a = list(map(int,input().split(" ")))
b = list(map(int,input().split(" ")))
c = list(map(int,input().split(" ")))
#アルゴリズムわからないけどN log N?
a.sort()
b.sort()
c.sort()
 
#O(N)?
i,j,k = 0,0,0
ans = 0
while j < N:
  while i < N and a[i]<b[j] :
    i += 1
  while k < N and c[k]<=b[j]:
    k += 1
  ans += i * (N - k)
  j += 1
 

print(ans)