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

N = int(input())
S = list()
for i in range(N):
    S.append(input())

S_time = list()
for i in range(N):
    counter = 0
    for j in range(N):
        if S[i] == S[j]:
            counter += 1
    S_time.append(counter)

if N == counter:
    print(S[0])
else:
    S_max_list = list()
    max = S_time[0]
    S_max_list.append(0)
    counter_list=1
    for i in range(1,N,1):
        if max == S_time[i]:
            S_max_list.append(i)
            counter_list += 1
        elif max < S_time[i]:
            max = S_time[i]
            S_max_list.clear()
            S_max_list.append(i)
            counter_list = 1

    S_list= list()
    for i in range(counter_list):
        S_list.append(S[S_max_list[i]])

    ans = list(set(S_list))
    ans.sort()
    for i in range(len(ans)):
        print(ans[i])


### FIXED CODE ###

N = int(input())
S = [input() for _ in range(N)]

dic={}
for i in range(N):
    if S[i] not in dic:
        dic[S[i]]=1
    else:
        dic[S[i]]+=1

largest=max(dic.values())
ans=list()

for key in dic.keys():
    if dic[key]==largest:
        ans.append(key)

ans.sort()
for word in ans:
    print(word)
### BUGGY CODE ###

n, k = map(int, input().split())
balls = list(map(int, input().split()))
amo = []

kinds = set(balls)
amo = sorted([balls.count(i) for i in kinds])
print(sum(amo[:max(0, len(kinds)-k)]))

### FIXED CODE ###

n, k = map(int, input().split())
balls = sorted(input().split())
kinds = len(set(balls))
amo = [1] * kinds

balls.append(0)
j = 0
for i in range(n):
    if balls[i] == balls[i+1]:
        amo[j] += 1
    else:
        j += 1
amo.sort()
print(sum(amo[:max(0, kinds-k)]))
### BUGGY CODE ###

import sys
x,y = map(int, input().split())
temp = x
if x == y:
    print(-1)
    sys.exit()
while True:
    temp += x
    if temp % y != 0:
        print(temp)
        sys.exit()
    elif temp > 1000000000000000000:
        print(-1)
        sys.exit()

### FIXED CODE ###

import sys
def gcd(a, b):
        while b:
                a, b = b, a % b
        return a
def lcm(a, b):
    return a * b // gcd (a, b)

x,y = map(int, input().split())
temp = x
if x == y:
    print(-1)
    sys.exit()
while True:
    temp += x
    if temp % y != 0:
        print(temp)
        sys.exit()
    elif temp > lcm(x, y):
        print(-1)
        sys.exit()
### BUGGY CODE ###

S=input()
Q=int(input())
for i in range(Q):
    query_list=input().split()
    if query_list[0] == "1":
        S=S[::-1]
    else:
        if query_list[1] == "1":
            S=query_list[2]+S
        else:
            S+=query_list[2]
print(S)

### FIXED CODE ###

from collections import deque
S = deque(input().rstrip())
Q=int(input())
cnt=True
for i in range(Q):
    query_list=input().split()
    if query_list[0] == "1":
        cnt=(cnt==False)
    else:
        if cnt:
            if query_list[1] == "1":
                S.appendleft(query_list[2])
            else:
                S.append(query_list[2])
        else:
            if query_list[1] == "1":
                S.append(query_list[2])
            else:
                S.appendleft(query_list[2])
if cnt:
    print("".join(S))
else:
    print("".join(reversed(S)))
### BUGGY CODE ###

# -*- coding: utf-8 -*-
import collections
n = int(input())
an= list(map(int, input().split()))

for k in range(0,n):
    an2 = an[:]
    del an2[k]
    c = collections.Counter(an2)
    datas = c.most_common()
    ans = 0
    for data in datas:
        ans += data[1] * (data[1]-1)/2
    print(int(ans))
    an2.clear()


### FIXED CODE ###

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

datas = [0] * (n+1)
for a in an:
    datas[a] += 1

ans = 0
for i in range(1,n+1):
    if datas[i] > 1:
        ans += datas[i] * (datas[i]-1)/2
ans = int(ans)

for k in range(0,n):
    if datas[an[k]] > 1:
        print(int(ans - datas[an[k]] * (datas[an[k]]-1)/2 + (datas[an[k]]-1) * (datas[an[k]]-2)/2))
    else:
        print(ans)
### BUGGY CODE ###

N, K = map(int, input().split())
h = list(map(int, input().split()))
#dp[i] をiまでの最小コスト
INF = 10**9
# h.extend([INF for i in range(100)])
dp = [INF for i in range(N)]
dp[0] = 0
for i in range(N):
    for k in range(1,K+1):
        if i + k >= N:
            break
        dp[i + k] = min(dp[i + k], dp[i] + abs(h[i+k] - h[i])) # i => i+k でのコストの更新
print(dp[N-1])

### FIXED CODE ###

N, K = map(int, input().split())
h = list(map(int, input().split()))
#dp[i] をiまでの最小コスト
INF = 10**9
# h.extend([INF for i in range(100)])
dp = [INF for i in range(N)]
dp[0] = 0
for i in range(N):
    for k in range(1,K+1):
        if i + k >= N:
            break
        dp[i + k] = min(dp[i + k], dp[i] + abs(h[i+k] - h[i])) # i => i+k でのコストの更新
print(dp[N-1])
### BUGGY CODE ###

def main():
    from itertools import permutations

    n, m, r, *x = map(int, open(0).read().split())
    to = x[:r]

    dis = [[0 if i == j else float("Inf") for j in range(n + 1)] for i in range(n + 1)]

    for a, b, c in zip(*[iter(x[r:])] * 3):
        dis[a][b] = c
        dis[b][a] = c

    for k in range(1, n + 1):
        for i in range(1, n + 1):
            for j in range(1, n + 1):
                dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j])

    ans = float("Inf")
    for p in permutations(to):
        tmp = 0
        nw = p[0]
        for nx in p[1:]:
            tmp += dis[nw][nx]
            nw = nx

        ans = min(ans, tmp)

    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
read = sys.stdin.read
from itertools import permutations
def main():
    def warshall_floyd(d):
        for k in range(n):
            for i in range(n):
                for j in range(n):
                    d[i][j] = min(d[i][j], d[i][k] + d[k][j])
        return d
 
    n, m, r = map(int, input().split())
    rs = tuple(map(int, input().split()))
    d = [[10**9] * n for _ in range(n)]
    m = map(int, read().split())
    mmm = zip(m, m, m)
    for s, t, dis in mmm:
        s -= 1
        t -= 1
        d[t][s] = d[s][t] = dis
    for j1 in range(n):
        d[j1][j1] = 0
    res = warshall_floyd(d)
    rsp = tuple(permutations(rs))
    result = float('inf')
    for rspe in rsp:
        res_t = 0
        for i1 in range(r - 1):
            res_t += res[rspe[i1]-1][rspe[i1+1]-1]
        result = min(result, res_t)
    print(result)
 
if __name__ == '__main__':
    main()
### BUGGY CODE ###

import numpy as np

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

cumsum_an = [0]
cumsum_an.extend(np.cumsum(an).tolist())

ans = 0
for left in range(N):
    ans += 1    # left equal right
    xor_sum = an[left]
    for right in range(left + 1, N):
        xor_sum = xor_sum ^ an[right]
        arith_sum = cumsum_an[right + 1] - cumsum_an[left]
        if xor_sum == arith_sum:
            ans += 1
        else:
            break

print(ans)

### FIXED CODE ###

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

ans = 0
right = 0
arith_sum = 0
for left in range(N):
    while right < N and arith_sum ^ an[right] == arith_sum + an[right]:
        arith_sum += an[right]
        right += 1
    ans += right - left
    if left == right:
        right += 1
    else:
        arith_sum -= an[left]

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

from collections import deque
def main():
    n = int(input())
    b = list(map(int, input().split()))
    q = deque()

    q.append([b[::], [0]*n, 0])
    ans = None
    while q:
        now, history, depth = q.popleft()
        if len(now) == 0:
            ans = history
            break
        for i in range(len(now))[::-1]:
            if i+1 == now[i]:
                tmp = history[::]
                tmp[depth] = i+1
                q.appendleft([[now[k] for k in range(len(now)) if k != i], tmp, depth+1])
    if ans is None:
        print(-1)
    else:
        for i in ans[::-1]:
            if i == 0:
                break
            print(i)
if __name__ == "__main__":
    main()

### FIXED CODE ###

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

def check(b):
    for i in range(len(b))[::-1]:
        if i+1 == b[i]:
            return i
    return -1

ans = []
for i in range(n):
    ind = check(b)
    if ind >= 0:
        ans.append(ind+1)
        b = b[:ind] + b[ind+1:]
    else:
        print(-1)
        exit()
for i in ans[::-1]:
    print(i)
### BUGGY CODE ###

import sys
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def MAP(): return map(int, input().split())
inf = sys.maxsize

h, w, k = MAP()
s = [[int(i) for i in STR()] for _ in range(h)]

ans = inf
for i in range(2 ** (h - 1)): #縦方向の割り方を全探索 O(500)
    hdiv = [1 for _ in range(h)]
    for j in range(h - 1):
        tmp = 2 ** j
        hdiv[j] = 1 if i & tmp else 0
    sh = sum(hdiv)
    tmpans = sh - 1
    wdiv = [0 for _ in range(w - 1)]
    partsum = [0 for _ in range(sh + 1)]
    j = 0
    while j < w: #O(2 * 10 ** 4)
        tmp = 0
        idx = 0
        for kk in range(h): #O(10)
            tmp += s[kk][j]
            if hdiv[kk]:
                partsum[idx] += tmp
                tmp = 0
                idx += 1
        flag = True
        for kk in range(sh + 1):
            if partsum[kk] > k:
                tmpans += 1
                partsum = [0 for _ in range(sh + 1)]
                flag = False
        if flag:
            j += 1
    ans = min(ans, tmpans)
print(ans)


### FIXED CODE ###

import sys
inf = sys.maxsize

if __name__ == '__main__':
    h, w, k = map(int, sys.stdin.readline().strip().split())
    s = [[int(i) for i in sys.stdin.readline().strip()] for _ in range(h)]
    
    ans = inf
    for i in range(2 ** (h - 1)): #縦方向の割り方を全探索 O(512)
        hdiv = [1 if i & 2 ** j else 0 for j in range(h - 1)]
        hdiv.append(1)
        sh = sum(hdiv)
        tmpans = sh - 1
        partsum = [0 for _ in range(sh)]
        partsum_p = [0 for _ in range(sh)]
        j = 0
        for j in range(w): #O(10 ** 3)
            tmp = 0
            idx = 0
            flag = False
            for kk in range(h): #O(10)
                tmp += s[kk][j]
                if hdiv[kk]:
                    partsum_p[idx] = partsum[idx]
                    partsum[idx] += tmp
                    if partsum[idx] > k and not flag:
                        tmpans += 1
                        flag = True
                    tmp = 0
                    idx += 1
            if flag:
                partsum = [partsum[l] - partsum_p[l] for l in range(sh)]
                partsum_p = [0 for _ in range(sh)]
                for kk in range(sh):
                    if partsum[kk] > k:
                        tmpans = inf
                        break
        ans = min(ans, tmpans)
    print(ans)
### BUGGY CODE ###

import numpy as np
import copy

h, w = map(int, input().split())
a = [input() for _ in range(h)]

a = [[(ai[j] == "#") for j in range(w)] for ai in a]

ans = 0
for _ in range(h + w):
    if np.all(a):
        break
    a_tmp = copy.deepcopy(a)

    for i in range(h):
        for j in range(w):
            if (not a[i][j]) and (
                (i != 0 and a_tmp[i - 1][j])
                or (i != h - 1 and a_tmp[i + 1][j])
                or (j != 0 and a_tmp[i][j - 1])
                or (j != w - 1 and a_tmp[i][j + 1])
            ):
                a[i][j] = True

    ans += 1

print(ans)


### FIXED CODE ###

import numpy as np
from scipy.ndimage.morphology import distance_transform_cdt

h, w = map(int, input().split())
a = [input() for _ in range(h)]

a = np.array([[(ai[j] != "#") for j in range(w)] for ai in a])
d = distance_transform_cdt(a, metric="taxicab").max()
print(d)
### BUGGY CODE ###

import sys
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def LIST(): return list(map(int, input().split()))
mod = 10 ** 9 + 7

#0埋め　桁合わせ
def digit(n, r):
    n = str(n)
    l = len(n)
    n = '0' * (r - l) + n
    return n

n = INT()
a = LIST()
arr = [0 for _ in range(61)]
arr2 = [0 for _ in range(61)]
for i in range(1, n + 1):
    bn = bin(a[i - 1])[2:]
    for j in range(len(bn)):
        arr[j + 61 - len(bn)] += int(bn[j])
for i in range(61):
    arr2[i] = n - arr[i]
    if arr2[i] == n:
        arr2[i] = 0
ans = 0
for i in range(61):
    ans *= 2
    ans += arr[i] * arr2[i]
    ans %= mod
print(ans)


### FIXED CODE ###

import sys
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def LIST(): return list(map(int, input().split()))
mod = 10 ** 9 + 7

n = INT()
a = LIST()
arr = [0 for _ in range(61)]
for i in range(n):
    ai = a[i]
    for j in reversed(range(61)):
        arr[j] += ai % 2
        ai //= 2
ans = 0
for i in range(61):
    ans *= 2
    arri = arr[i]
    ans += arri * (n - arri if arri != 0 else 0)
    ans %= mod
print(ans)
### BUGGY CODE ###

import sys
from operator import itemgetter
inputs = sys.stdin.readline
N, Q= map(int,inputs().split())
def main():
	E = [None]*2*N
	for n in range(N):
		a,b,c = map(int,inputs().split())
		E[2*n] = (a - c, 1, c)
		E[2*n + 1] = (b - c, -1, c)
	E.sort(key=itemgetter(0))
	tuple(tuple(E))
	mini = 1000000001
	kouho = {1000000001}
	my_add = kouho.add
	my_discard = kouho.discard
	q = 0
	d = int(inputs())
	flag = False
	cont = False
	for e in E:
		while(e[0] > d):
			if cont == True:
				if mini < 1000000001:
					print(mini)
				else:
					print(-1)
			else:
				mini = min(kouho)
				if mini < 1000000001:
					print(mini)
				else:
					print(-1)
			cont = True
			if q < Q-1:
				q = q + 1
				d = int(inputs())
			else:
				flag = True
				q = q + 1
				break
		if flag == True:
			break
		if e[1] == 1:
			my_add(e[2])
			if mini > e[2]:
				mini = e[2]
		elif e[1] == -1:
			my_discard(e[2])
			cont = False
	for t in [None]*(Q-q):
		print(-1)
		
def sub():
	V = [list(map(int,inputs().split())) for p in [0]*N]
	M = [int(inputs()) for p in [0]*Q]
	V.sort(key = lambda x:(x[2],x[0],x[1]))
	for v in V:
		v[0] -= v[2]
		v[1] -= v[2] + 1
	for m in M:
		for n in range(N):
			if V[n][0] <=m and m <= V[n][1]:
				print(V[n][2])
				break
		else:
			print(-1)

#N200000
if Q>100000:
	sub()
else:
	main()

### FIXED CODE ###

import sys
from operator import itemgetter
def main():
	inputs = sys.stdin.readline
	N, Q= map(int,inputs().split())
	E = [None]*2*N
	for n in range(N):
		a,b,c = map(int,inputs().split())
		E[2*n] = (a - c, 1, c)
		E[2*n + 1] = (b - c, -1, c)
	E.sort(key=itemgetter(0))
	tuple(tuple(E))
	mini = 1000000001
	kouho = {1000000001}
	my_add = kouho.add
	my_discard = kouho.discard
	q = 0
	d = int(inputs())
	flag = False
	cont = False
	for e in E:
		while e[0] > d:
			if cont == True:
				print(mini-(mini//1000000001)*1000000002)
			else:
				mini = min(kouho)
				print(mini-(mini//1000000001)*1000000002)
			cont = True
			q = q + 1
			if q > Q-1:
				flag = True
				break
			d = int(inputs())
		if flag == True:
			break
		if e[1] == 1:
			my_add(e[2])
			if mini > e[2]:
				mini = e[2]
		elif e[1] == -1:
			my_discard(e[2])
			if mini == e[2]:
				cont = False
	for t in [None]*(Q-q):
		print(-1)
main()
### BUGGY CODE ###

a,b,c,d = map(int,input().split())
cnt=0
for i in range(a,b+1):
    if i%c==0 or i%d==0:
        cnt +=1
print(b-a-cnt+1)

### FIXED CODE ###

def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
def lcm(a,b):
    return a*b//gcd(a,b)

a,b,c,d = map(int,input().split())
li=[]
gc = lcm(c,d)
for i in [a-1,b]:
    bc = i//c
    bd = i//d
    cd = i//gc
    li.append(i-(bc+bd-cd))
print(int(li[1]-li[0]))
### BUGGY CODE ###

n,k=map(int,input().split())
v=[0 for _ in range(n)]
w=[0 for _ in range(n)]
for i in range(n):
	w[i],v[i] = map(int,input().split())
 
dp = [[0 for i in range(k+1)] for j in range(n+1)]
 
for i in range(n):
	for j in range(k+1):
		if j-w[i] < 0:
			dp[i+1][j] = dp[i][j]
		else:
			dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]]+v[i])
print(dp[n][k])

### FIXED CODE ###

n,k=map(int,input().split())
v=[0 for _ in range(n)]
w=[0 for _ in range(n)]
for i in range(n):
	w[i],v[i] = map(int,input().split())

dp = [[0 for i in range(k+1)] for j in range(n+1)]

for i in range(n):
	for j in range(k+1):
		if j-w[i] < 0:
			dp[i+1][j] = dp[i][j]
		else:
			dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]]+v[i])
print(dp[n][k])
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**9)
input=lambda :sys.stdin.readline().rstrip()

def sol():

  N,Q = map(int,input().split())
  graph = [[] for i in range(N)]
  ans = [0 for i in range(N)]
  for _ in range(N-1):
    a,b = map(int,input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

  for _ in range(Q):
    p, x = map(int,input().split())
    ans[p-1] += x 
 
  def dfs(v,p=-1):
    for u in graph[v]:
      if u == p: continue
      ans[u] += ans[v]
      dfs(u,v)
  dfs(0)
  print(*ans)

sol()

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)
input=lambda :sys.stdin.readline()

def sol():

  N,Q = map(int,input().split())
  graph = [[] for i in range(N)]
  ans = [0 for i in range(N)]
  for _ in range(N-1):
    a,b = map(int,input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

  for _ in range(Q):
    p, x = map(int,input().split())
    ans[p-1] += x 
 
  def dfs(v,p=-1):
    for u in graph[v]:
      if u == p: continue
      ans[u] += ans[v]
      dfs(u,v)
  dfs(0)
  print(*ans)

sol()
### BUGGY CODE ###

N=int(input())
a = list(map(int,input().split()))
ans=0
for i in range(2*N):
  tmp=max(a)
  a.remove(tmp)
  if i%2==1:
    ans+=tmp
print(ans)

### FIXED CODE ###

N=int(input())
a = sorted(list(map(int,input().split())),reverse=True)
ans=0
for i in range(N):
  ans+=a[2*i+1]
print(ans)
### BUGGY CODE ###

N=int(input())
A=int(input())
B=int(input())
C=int(input())
D=int(input())
E=int(input())

num = [N, 0, 0, 0, 0, 0]
time = 0
while num[5] < N:
  if num[4] < E:
    num[5] += num[4]
    num[4] = 0
  else:
    num[5] += E
    num[4] -= E
  if num[3] < D:
    num[4] += num[3]
    num[3] = 0
  else:
    num[4] += D
    num[3] -= D
  if num[2] < C:
    num[3] += num[2]
    num[2] = 0
  else:
    num[3] += C
    num[2] -= C
  if num[1] < B:
    num[2] += num[1]
    num[1] = 0
  else:
    num[2] += B
    num[1] -= B
  if num[0] < A:
    num[1] += num[0]
    num[0] = 0
  else:
    num[1] += A
    num[0] -= A
  time += 1
  
print(time)

### FIXED CODE ###

import math

N=int(input())
A=int(input())
B=int(input())
C=int(input())
D=int(input())
E=int(input())

print(math.ceil(N/min([A,B,C,D,E]) + 4))
### BUGGY CODE ###

s = input()

ans = 0
for i in range(len(s)-4):
    for j in range(4, len(s)-i+1):
        if int(s[i:i+j]) % 2019==0:
            ans += 1

print(ans)

### FIXED CODE ###

from collections import Counter
s = input()

ans = 0
mods = [0]
s = [int(a) for a in s[::-1]]
x = 0
for i in range(len(s)):
    x += s[i] * pow(10, i, 2019)
    mods.append(x%2019)

mods = Counter(mods)

for k in mods.keys():
    counts = mods[k]
    ans += counts * (counts-1) // 2
print(ans)
### BUGGY CODE ###

n,m,k=map(int,input().split())
fr=[input() for i in range(m)]
bl=[input() for i in range(k)]
relfr=[set() for i in range(n)]
relbl=[set() for i in range(n)]
for l in fr:
  a,b=map(int,l.split())
  relfr[a-1].add(b-1)
  relfr[b-1].add(a-1)
for l in bl:
  a,b=map(int,l.split())
  relbl[a-1].add(b-1)
  relbl[b-1].add(a-1)
cand={0}
searched=set()
gr=set()
all_gr={i for i in range(n)}
ans=['']*n
while all_gr!=searched:
  while len(cand)!=0:
    now=cand.pop()
    gr.add(now)
    for point in relfr[now]-(relfr[now]&gr)-(relfr[now]&cand):
      cand.add(point)
  for i in gr:
    ans[i]=str(len(gr)-len(relfr[i])-len(relbl[i]&gr)-1)
    searched.add(i)
  gr.clear()
  if all_gr!=searched:
    cand.add(list(all_gr-searched)[0])
print(' '.join(ans))

### FIXED CODE ###

n,m,k=map(int,input().split())
relfr={i:set() for i in range(n)}
relbl={i:set() for i in range(n)}
for i in range(m):
  a,b=map(int,input().split())
  relfr[a-1].add(b-1)
  relfr[b-1].add(a-1)
for i in range(k):
  a,b=map(int,input().split())
  relbl[a-1].add(b-1)
  relbl[b-1].add(a-1)
blsiz=[0 for i in range(n)]
ans=[0]*n
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    def Unite(self, x, y):
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        if(x == y):
            return
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)
    def Count(self, x):
        return -self.root[self.Find_Root(x)]
uf=UnionFind(n)
for i in range(n):
  for j in relfr[i]:
    uf.Unite(i,j)
for i in range(n):
  for j in relbl[i]:
    if uf.isSameGroup(i,j):
      blsiz[i]+=1
for i in range(n):
  ans[i]=uf.Count(i)-len(relfr[i])-blsiz[i]-1

print(' '.join(map(str,ans)))
### BUGGY CODE ###

from collections import Counter

N = int(input())
S = input()

r = S.count('R')
g = S.count('G')
b = S.count('B')

sum = r*g*b

for i in range(N):
    for j in range(i+1, N):
        A = ['R','G','B']
        if S[i] == S[j]:
            continue
        
        A.remove(S[i])
        A.remove(S[j])
            
        # S[k]
        k = 2 * j - i
        if k < len(S):
            if S[k] == A[0]:
                sum -= 1
print(sum)

### FIXED CODE ###

from collections import Counter

N = int(input())
S = input()

r = S.count('R')
g = S.count('G')
b = S.count('B')

sum = r*g*b

for i in range(N):
    for j in range(i+1, N):
        k = 2 * j - i
        if k > N - 1:
            break
        if not S[i] == S[j] and not S[j] == S[k] and not S[k] == S[i]:
            sum -= 1
print(sum)
### BUGGY CODE ###

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

    # 式変形していいかんじに下ごしらえして、
    # 2変数分のループで全探索する。O(3500^2)なら間に合うはず。

    for h in range(1,3501) :
        for n in range(1,3501) :
            bo = 4*h*n - N*n - N*h
            if (bo == 0) :
                continue

            omega = (N * h * n * 1.0) / (bo * 1.0)
            if (omega.is_integer() == True and omega > 0) :
                print(h,n,int(omega))
                return

main()

### FIXED CODE ###

def main() :
    N = int(input())
    # N = float(input())

    # 式変形していいかんじに下ごしらえして、
    # 2変数分のループで全探索する。O(3500^2)なら間に合うはず。

    # for h in range(1,3501) :
    for h in range(1,3500) :
        # 組み合わせでみればいいので1からじゃなくてよい
        for n in range(h,3501) :
            bo = 4*h*n - N*n - N*h
            if (bo == 0) :
                continue

            omega = (N * h * n) / bo * 1.0
            if (omega > 0 and omega.is_integer() == True) :
                print(h,n,int(omega))
                return

main()
### 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})

ami = min(adic.keys())
ama = max(adic.keys())
bmi= min(bdic.keys())
bma= max(bdic.keys())
cmi= min(cdic.keys())
cma= max(cdic.keys())



        
        
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)