Harryxun/stf_run huggingface dataset:
N = int(input())
Di1 = []
Di2 = []
nmDi = 0
if N >= 3 and N <= 100:
   for x in range(N):
      Di1.append(int(input()))
      Di2.append(int(input()))
   for x in range(N):
      if Di1[x] == Di2[x]:
         nmDi += 1
         if nmDi == 3:
            break
      elif Di1[x] != Di2[x] and nmDi > 0:
         nmDi = 0
   if nmDi >= 3:
      print("Yes")
   else:
      print("No")

### FIXED CODE ###

N = int(input())
Di = 0
Di1 = []
Di2 = []
nmDi = 0
if N >= 3 and N <= 100:
   for x in range(N):
      Di = input()
      Di1.append(Di[0])
      Di2.append(Di[-1])
   for x in range(N):
      if Di1[x] == Di2[x]:
         nmDi += 1
         if nmDi == 3:
            break
      elif Di1[x] != Di2[x] and nmDi > 0:
         nmDi = 0
   if nmDi >= 3:
      print("Yes")
   else:
      print("No")
else:
   print ("No")
n,m = map(int,input().split())
x,y,z = [],[],[]
for i in range(n):
    line = list(map(int,input().split()))
    x.append(line[0])
    y.append(line[1])
    z.append(line[2])
ls = []
def dfs(sx,sy,sz,i,k):
    if k == 0:
        ls.append(abs(sx)+abs(sy)+abs(sz))
        return abs(sx)+abs(sy)+abs(sz)
    if i == n:
        return 0
    dfs(sx,sy,sz,i+1,k)
    dfs(sx+x[i],sy+y[i],sz+z[i],i+1,k-1)
dfs(0,0,0,0,m)
print(max(ls))

### FIXED CODE ###

n,m = map(int,input().split())
xyz = []
for i in range(n):
    x,y,z = map(int,input().split())
    xyz.append((x,y,z))
k1 = [1,1,1,1,-1,-1,-1,-1]
k2 = [1,1,-1,-1,1,1,-1,-1]
k3 = [1,-1,1,-1,1,-1,1,-1]

sx,sy,sz = 0,0,0
ans_list = []
for i in range(8):
    xyz.sort(key=lambda x: x[0]*k1[i]+x[1]*k2[i]+x[2]*k3[i],reverse=True)
    for j in range(m):
        sx,sy,sz = sx+xyz[j][0],sy+xyz[j][1],sz+xyz[j][2]
    ans_list.append(abs(sx)+abs(sy)+abs(sz))
    sx,sy,sz = 0,0,0
print(max(ans_list))
a, b, c = map(int, input().split())
k = int(input())
maxnum = max(a,b,c)
output = maxnum*2**k+a+b+c-maxnum
print(output)

### FIXED CODE ###

a, b = map(int, input().split())
th = a-1
if b>=a:
    th+=1
print(th)
print(f"A{input()[8]}C")

### FIXED CODE ###

print("A"+input()[8]+"C")
a = input()
b = input()
c = input()

print(a[1]+b[2]+c[3])

### FIXED CODE ###

a = input()
b = input()
c = input()

print(a[0]+b[1]+c[2])
import bisect
import sys
A, B, Q = map(int,input().split())

S = [-10**18] + list(map(int, (sys.stdin.readline() for _ in [0]*A))) + [10**18]
T = [-10**18] + list(map(int, (sys.stdin.readline() for _ in [0]*A))) + [10**18]


for _ in range(Q):
    x = int(input())
    ans = 10**18
    for i in range(2):
        if i == 0:
            a = S
            b = T
        elif i== 1:
            a = T
            b = S

        idx_x = bisect.bisect_left(a,x)
        for j in range(2):
            ax = a[idx_x-j]
            idx_a = bisect.bisect_left(b,ax)
            for k in range(2):
                bx = b[idx_a-k]
                ans = min(ans, abs(ax-x)+abs(bx-ax))
    print(ans)

### FIXED CODE ###

import bisect
import sys

A, B, Q = map(int,input().split())
s = [-(10**18)] + list(map(int, (sys.stdin.readline() for _ in [0]*A))) + [10**18]
t = [-(10**18)] + list(map(int, (sys.stdin.readline() for _ in [0]*B))) + [10**18]


def solve(s,t,x):
    ans = 10**18
    for i in range(2):
        a, b = (s, t) if i==0 else (t, s)
        posX1 = bisect.bisect_left(a,x)
        for j in range(2):
            ax = a[posX1 -j]
            posX2 = bisect.bisect_left(b,ax)
            for k in range(2):
                bx = b[posX2-k]
                ans = min(ans, abs(x-ax)+abs(bx-ax))
    return ans

for _ in range(Q):
    x = int(input())
    print(solve(s,t,x))
#include <bits/stdc++.h>
using namespace std;

int main(){
    int N;
    long long ans = 0, sum =0;
    int mod = 1000000000+7;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a.at(i);
        sum += a.at(i);
    }
    for (int i = 0; i < N-1; i++) {
        sum -= a.at(i);
        if(sum<0) sum += mod;
        ans += sum * a.at(i);
        ans %= mod;
    }
    cout << ans << endl;
}
/*

*/


### FIXED CODE ###

def main():
    n = int(input())
    a = []
    sum = 0             #longの気持ち
    ans = 0             #long long の気持ち
    mod = 1_000_000_000 + 7
    x = list(map(int, input().split()))
    for i in range(n):
        sum += x[i]           
        a.append(x[i])
    
    for i in range(n):
        sum -= a[i]
        ans += sum * a[i]
        ans %= mod
    print(ans)

if __name__ == "__main__":
    main()
S = []
N = int(input())

for i in range(10):
    for j in range(10):
        S.append(i*j)

if N in S:
    print("Yes")
else:
    print("No)

### FIXED CODE ###

S = []
N = int(input())
 
for i in range(10):
    for j in range(10):
        S.append(i*j)
 
if N in S:
    print("Yes")
else:
    print("No")
a, b = map(int, input())
if a*b%2 == 0:
    print("Odd")
else:
    orint("Even")

### FIXED CODE ###

a, b = map(int, input().split())
if a*b%2 != 0:
    print("Odd")
else:
    print("Even")
tmp =input().split()
H,W,D=int(tmp[0]),int(tmp[1]),int(tmp[2])

list = [[0 for x in range(W)] for y in range(H)]
dict = {}
for i in range(H):
    tmp = input().split()
    for d in range(W):
        dict[tmp[d]] = str(i)+' '+str(d)
result ={}
cost ={}

def calcost(L,R,D):
    if int(R)<=D:
        cost[R] = 0
        return 0
    else:
        posi1 = dict[R].split()
        posi2 = dict[str(int(R)-D)].split()
        costs = abs(int(posi2[0])-int(posi1[0])) + abs(int(posi2[1])-int(posi1[1]))
        if str(int(R)-D) in cost:
            cost[R] = costs + cost[str(int(R)-D)]
            return cost[R]
        else:
            cost[R] = costs + calcost(L,str(int(R)-D),D)
            return cost[R]

for n in range(D+1,H*W+1):
    calcost(str(1),str(n),D)

Q = int(input())
for j in range(Q):
    tmpx = input()
    if tmpx in result:
        print(result[tmpx])
    else:
        tmp = tmpx.split()
        result[tmpx] = cost[tmp[1]]-cost[tmp[0]]
        print(result[tmpx])

### FIXED CODE ###

N=int(input())
print(int(N/3))
import sys


def input():
    return sys.stdin.readline().strip().decode('utf-8')


def solve(N):
    odd_count = 0

    for x in range(0, N)[::-1]:
        if x // 2 != 0:
            odd_count += 1

    if N == 1:
        return 1

    return odd_count / N


N = int(input())

print(solve(N))


### FIXED CODE ###

def solve(N):
    odd_count = 0

    for x in range(1, N + 1)[::-1]:
        if x % 2 == 1:
            odd_count += 1

    if N == 1:
        return 1

    return odd_count / N


N = int(input())

print(solve(N))
N,K = map(int,input().split())
S = input()
S[K-1] = S[K-1].upper()
print(S)

### FIXED CODE ###

N,K = map(int,input().split())
S = input()
S[K-1].lower()
print(S[:K-1]+ S[K-1].lower() + S[K:])
N,M = map(int,input().split())
G = {}
for node in range(1,N+1):
	G[node] = set()
for _ in range(M):
	x,y = map(int,input().split())
	G[x].add(y)

maxpath = [-1 for _ in range(N+1)]

def maxpa(G,source,maxpath):
	print(source)
	if maxpath[source] != -1:
		return maxpath[source]
	else:	
		if len(G[source]) == 0:
			maxpath[source] = 0
			return maxpath[source]
		else:	
			for ngbr in G[source]:
				maxpath[source] = max(maxpath[source],1+maxpa(G,ngbr,maxpath))
			return maxpath[source]

for i in range(1,N+1):
	if maxpath[i]==-1:
		maxpa(G,i,maxpath)

print(max(maxpath))

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)

N,M = map(int,input().split())
G = {}
for node in range(1,N+1):
	G[node] = set()
for _ in range(M):
	x,y = map(int,input().split())
	G[x].add(y)

maxpath = [-1 for _ in range(N+1)]

def maxpa(G,source,maxpath):
	if maxpath[source] != -1:
		return maxpath[source]
	else:	
		if len(G[source]) == 0:
			maxpath[source] = 0
			return maxpath[source]
		else:	
			for ngbr in G[source]:
				maxpath[source] = max(maxpath[source],1+maxpa(G,ngbr,maxpath))
			return maxpath[source]

for i in range(1,N+1):
	if maxpath[i]==-1:
		maxpa(G,i,maxpath)

print(max(maxpath))
A, B = map(int, input().split())

ans = [['#'] * 100 for _ in range(50)]
ans_ = [['.'] * 100 for _ in range(50)]
ans.extend(ans_)

h = 0
w = 0
for i in range(A-1):
    ans[h][w] = '.'
    w += 2
    if w >= 10:
        h += 2
        w = 0

h = 51
w = 0
for i in range(B-1):
    ans[h][w] = '#'
    w += 2
    if w >= 10:
        h += 2
        w = 0

for i in range(100):
    print(''.join(ans[i]))


### FIXED CODE ###

A, B = map(int, input().split())

ans = [['#'] * 100 for _ in range(50)]
ans_ = [['.'] * 100 for _ in range(50)]
ans.extend(ans_)

h = 0
w = 0
for i in range(A-1):
    ans[h][w] = '.'
    w += 2
    if w >= 100:
        h += 2
        w = 0

h = 51
w = 0
for i in range(B-1):
    ans[h][w] = '#'
    w += 2
    if w >= 100:
        h += 2
        w = 0

print(100, 100)
for i in range(100):
    print(''.join(ans[i]))
a = int(input())
b = int(input())
c = int(input())
print(a+b+c+9 * max(a, b, c))


### FIXED CODE ###

a,b,c= map(int,input().split())
print(a+b+c+9 * max(a, b, c))
from collections import Counter
import itertools

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


ptn=list(itertools.combinations(xy,2))
pq=[]
for idx,val in enumerate(ptn):
        pq.append(str(val[1][0]-val[0][0]) + 'x' + str(val[1][1]-val[0][1]))

cpq = Counter(pq)

# pqans=cpq.most_common(1)[0][0]
redsc=cpq.most_common(1)[0][1]

# p,q = map(int,pqans.split('x'))

print(N-redsc)

### FIXED CODE ###

from collections import Counter
import itertools

N = int(input())
xy = [list(map(int, input().split())) for i in range(N)]
xy.sort()
if N == 1:
        print(1)
        exit()

ptn=list(itertools.combinations(xy,2))
pq=[]
for idx,val in enumerate(ptn):
        if val[1][0]-val[0][0] <= 0 and val[1][1]-val[0][1] <= 0:
                pq.append(str(abs(val[1][0]-val[0][0])) + 'x' + str(abs(val[1][1]-val[0][1])))
        else:
                pq.append(str(val[1][0]-val[0][0]) + 'x' + str(val[1][1]-val[0][1]))

cpq = Counter(pq)

# pqans=cpq.most_common(1)[0][0]
redsc=cpq.most_common(1)[0][1]

# p,q = map(int,pqans.split('x'))
print(N-redsc)
n, m, l = list(map(int, input().split()))
a = [[int(j) for j in input().split()] for i in range(n)]
b = [[int(j) for j in input().split()] for i in range(m)]
c = [[0 for j in range(n)] for i in range(l)]

for i in range(n):
    for j in range(l):
        value = 0
        for k in range(m):
            value = value + a[i][k] * b[k][j]
        c[i][j] = value

for i in c:
    print(*i)


### FIXED CODE ###

n, m, l = list(map(int, input().split()))
a = [[int(j) for j in input().split()] for i in range(n)]
b = [[int(j) for j in input().split()] for i in range(m)]
c = [[0 for j in range(l)] for i in range(n)]

for i in range(n):
    for j in range(l):
        value = 0
        for k in range(m):
            value = value + a[i][k] * b[k][j]
        c[i][j] = value

for i in c:
    print(*i)
N = int( input())

n = N // 100

if( N % 100 <= n * 10 + n):
	print(n * 100 + n * 10 + n )
  
else:


### FIXED CODE ###

n = list(map( int, input()))
 
h = 3
for i in range(h):
  if( n[i] == 1):
    n[i] = 9
    n[i] = str(n[i])   
  else:
    n[i] = 1
    n[i] = str(n[i])
    
a = "".join(n)
 
print(a)
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort(reverse=True)
for i in range(m):
  a[0]=a[0]/2
  for j in range(1,n):
    if a[0]>a[j]:
      a.insert(j,a[0])
      del a[0]
      break
  print(a)
import math
ans=0
for i in range(n):
  ans=ans+math.floor(a[i])
print(ans)

### FIXED CODE ###

n,m=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n):
  a[i]=a[i]*-1
import heapq
heapq.heapify(a)
for i in range(m):
  t=(heapq.heappop(a))*-1
  heapq.heappush(a,(t//2)*-1)
print(sum(a)*-1)
from math import sqrt
n,d=map(int, input().split())
x=[list(map(int, input().split())) for i in range(n)]

ans=0

for i in range(n):
  for j in range(i+1, n):
    xi,xj = x[i],x[j]
  tmp = 0
    for k in range(d):
      tmp += (xi[d]-xj[d]) ** 2
      if sqrt(tmp)%1==0:
        ans += 1

print(ans)



### FIXED CODE ###

from math import sqrt
n,d=map(int,input().split())
x=[list(map(int,input().split())) for i in range(n)]

ans=0
tmp=0

for i in range(n):
  for j in range(i+1, n):
    xi,xj = x[i],x[j]
    for k in range(d):
      tmp += (xi[k]-xj[k]) ** 2  
    if sqrt(tmp)%1==0:
      tmp=0
      ans += 1
    else:
      tmp=0

print(ans)
import sys
sys.setrecursionlimit(10**6)
n,m=map(int,input().split())
s=[[]for i in range(n+1)]
c=[0]*(n+1)
for i in range(m):
    a,b=map(int,input().split())
    s[a].append(b)
    s[b].append(a)
def dfs(v,t):
    c[v]=t
    for i in s[v]:
        if c[i]==t:
            return false
        if c[i]==0 and not dfs(i,-t):
            return false
    else:
        return True
if dfs(1,1):
    q=c.count(1)
    print((n-q)*q-m)
else:
    print((n*(n-1)//2)-m)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
n,m=map(int,input().split())
s=[[]for i in range(n+1)]
c=[0]*(n+1)
for i in range(m):
    a,b=map(int,input().split())
    s[a].append(b)
    s[b].append(a)
def dfs(v,t):
    c[v]=t
    for i in s[v]:
        if c[i]==t:
            return False
        if c[i]==0 and not dfs(i,-t):
            return False
    else:
        return True
if dfs(1,1):
    q=c.count(1)
    print((n-q)*q-m)
else:
    print((n*(n-1)//2)-m)
n = input()
l = len(n)-1

for i in range(2**l):
    op = ["-"]*l
    for j in range(l):
        if (i>>j) &1:
            op[i-j-1]="+"
    formula = ""
    for op_num,op_l in zip(n,op+[""]):
        formula += op_num+op_l
    if eval(formula)==7:
       print(formula+"=7")
       break

### FIXED CODE ###

def dfs(i, Str, res):
    if i==3:
        if res==7:
            print(Str+"=7")
            exit()
        return
    
    dfs(i+1,Str+"+"+s[i+1],res+int(s[i+1]))
    dfs(i+1,Str+"-"+s[i+1],res-int(s[i+1]))

s=input()
dfs(0,s[0],int(s[0]))
N = int(input())
A = map(int, input.split())
indices = collections.defaultdict(list)
for i, a in enumerate(A):
  indices[a].append(i)
Q = int(input())
for _ in Q:
  B, C = map(int, input.split())
  for i in indices[B]:
    indices[C].append(i)
    A[i] = C
  print(sum(A))

### FIXED CODE ###

import collections
N = int(input())
A = list(map(int, input().split()))
count = collections.defaultdict(int)
currSum = 0
for a in A:
  count[a] += 1
  currSum += a
Q = int(input())
for _ in range(Q):
  B, C = map(int, input().split())
  currSum += (count[B] * (C - B))
  count[C] += count[B]
  count[B] = 0
  print(currSum)
# coding: utf-8
# Your code here!

num = int(input())

qm = 1000000000000001

alf = [chr(i) for i in range(97, 97+26)]
#print(alf)

ans = []
f = False

for i in reversed(range(12)):
    if (num-num//26)//26**i >= 1:
        f = True

    if f:
        ans.append(alf[(num-i)//26**i-1])
        num = num % 26**i
print("".join(ans))


### FIXED CODE ###

# coding: utf-8
# Your code here!

num = int(input())

qm = 1000000000000001

alf = [chr(i) for i in range(97, 97+26)]
#print(alf)

ans = []
f = False

for i in range(12):
    c = (num-1) % 26
    ans += alf[c]
    num = (num-1) // 26
    if num < 1:
        break

print("".join(reversed(ans)))
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[]]*num
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

a,b,x = II()

h = (x-a**2*b/2)*2/(a**2)
if h>=0:
    r = math.degrees(math.atan(a/(b-h)))
    print(90-r)
else:
    z = 2*x/(a*b)
    r = math.degrees(math.atan(z/b))
    print(90-r)

### FIXED CODE ###

import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[]]*num
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

a,b,x = II()

h = (x-a**2*b/2)*2/(a**2)
if h>=0:
    if b-h==0:
        print(0)
    else:
        r = math.degrees(math.atan(a/(b-h)))
        print(90-r)
else:
    z = 2*x/(a*b)
    r = math.degrees(math.atan(z/b))
    print(90-r)
import math

def distance(N, D, point):
    count = 0
    for i in range(N):
        if math.sqrt(points[i][0]**2 + points[i][1]**2) <= D:
            count += 1
    return count


if __name__ == "__main__":
    N, D = map(int, input().split())
    points = []
    for _ in range(N):
        x, y = map(int, input.split())
        points.append([x,y])
    print(distance(N,D,points))

### FIXED CODE ###

import math

def distance(N, D, point):
    count = 0
    for i in range(N):
        if math.sqrt(points[i][0]**2 + points[i][1]**2) <= D:
            count += 1
    return count


if __name__ == "__main__":
    N, D = map(int, input().split())
    points = []
    for _ in range(N):
        x, y = map(int, input().split())
        points.append([x,y])
    print(distance(N,D,points))
N , A, B, =map(int,input().split())
d, m =divmod(N, A+B)
print(d*A + min(m,A))

### FIXED CODE ###

N , A, B, =map(int,input().split())
d, m =divmod(N, A+B)
print(d*A + min(m,A))
def nextTurn(a):
  if a == "a":
    return 0
  elif a == "b":
    return 1
  else:
    return 2
    
hand = [list(input()) for i in range(3)]
turn = nextTurn(hand[0].pop(0))
while(True):
  tmp = turn
  turn = nextTurn(hand[turn].pop(0))
  if len(hand[turn]) == 0:
    if tmp == 0:
      print("A")
    elif tmp == 1:
      print("B")
    else:
      print("C")
    break
  

### FIXED CODE ###

def nextTurn(a):
  if a == "a":
    return 0
  elif a == "b":
    return 1
  else:
    return 2
    
hand = [list(input()) for i in range(3)]
turn = nextTurn(hand[0].pop(0))
while(True):
  if len(hand[turn]) == 0:
    if turn == 0:
      print("A")
    elif turn == 1:
      print("B")
    else:
      print("C")
    break
  turn = nextTurn(hand[turn].pop(0))
N = int(input())
words = input().split("\n")

frst = words[0]
last = words[-1]
if frst[0] !=  last[-1]:
	print("No")
else:
	
	for i in range(1,len(words)):
		flag = 0
		if words[i] in words[:i-1]:
			print("No")
			break
		else:
			flag = 1
	if flag == 1:
		print("Yes")


### FIXED CODE ###

N = int(input())
words = []
for inp in range(N):
	words.append(input())

frst = words[0]
wrds = set(words)
if len(wrds) != len(words):
	print("No")
else:	
	for i in range(1,len(words)):
		flag = 1
		if words[i-1][-1] != words[i][0]:
			print("No")
			flag = 0
			break
	if flag == 1:
		print("Yes")
n,m=map(int,input().split())
AB=[]
for i in range(n):
  a,b=map(int,input().split())
  AB.append([a,b])
AB=sorted(AB)
i=0
amount=0
cost=0
while True:
  if amount+AB[i][1]<=m:
    amount+=AB[i][1]
    cost+=AB[i][0]*AB[i][1]
    i+=1
  else:
    cost+=(m-amount)*AB[i][0]
    print(cost)
    break

### FIXED CODE ###

n,m=map(int,input().split())
AB=[]
for i in range(n):
  a,b=map(int,input().split())
  AB.append([a,b])
AB=sorted(AB)
i=0
amount=0
cost=0
while True:
  if amount+AB[i][1]<m:
    amount+=AB[i][1]
    cost+=AB[i][0]*AB[i][1]
    i+=1
  else:
    cost+=(m-amount)*AB[i][0]
    print(cost)
    break
N, K = map(int, input().split())

# 赤いボールの数
R = N - K

import itertools
import math
def comb(n, k):
    return math.factorial(n)//math.factorial(n-k)//math.factorial(k)



for i in range(1, K+1):
    a = comb(K-1, i-1)
    b = comb(R+1, i)
    print(a * b % 1000000007)


### FIXED CODE ###

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

# 赤いボールの数
R = N - K

import itertools
import math
def comb(n, k):
    if n-k < 0:
        return 0
    return math.factorial(n)//math.factorial(n-k)//math.factorial(k)



for i in range(1, K+1):
    a = comb(K-1, i-1)
    b = comb(R+1, i)
    print(a * b % 1000000007)
from math import gcd
from functools import reduce

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

d = reduce(gcd, A)
print('POSSIBLE' if K <= max(A) and K % d == 0 else 'IMPOSSIBLE')


### FIXED CODE ###

from fractions import gcd
from functools import reduce

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

d = reduce(gcd, A)
print('POSSIBLE' if K <= max(A) and K % d == 0 else 'IMPOSSIBLE')
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
All = [] #全ての数字格納リスト
B_A = [] #Biより小さいAjの個数格納リスト
B_C = [] #Biより大きいCkの個数格納リスト

for i in range(N):
  All.append([A[i],0])
  All.append([B[i],1])
  All.append([C[i],2])
All.sort()

count1,count2 = 0,0
for i in range(3*N):
  if(All[i][1] == 1):     
    if(i == 0):
      B_A.append(count1)
      if((All[i][0] == All[i+1][0])and(All[i+1][1] == 2)): B_C.append(N-count2-1)
      else: B_C.append(N-count2)
    elif(i == N-1):
      if((All[i][0] == All[i-1][0])and(All[i-1][1] == 0)): B_A.append(count1-1)
      else: B_A.append(count1)
      B_C.append(N-count2)
    else:
      if((All[i][0] == All[i-1][0])and(All[i-1][1] == 0)): B_A.append(count1-1)
      else: B_A.append(count1)
      if((All[i][0] == All[i+1][0])and(All[i+1][1] == 2)): B_C.append(N-count2-1)
      else: B_C.append(N-count2)
    
  if(All[i][1] == 0): count1 += 1
  if(All[i][1] == 2): count2 += 1

ans = 0
for i in range(N):
 ans += B_A[i]*B_C[i]
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
#順序維持のbisect (二分探索を利用したライブラリ）
for i in range(N):
    count_a = bisect.bisect_left(A,B[i])
    count_c = N -bisect.bisect_right(C,B[i])
    ans += count_a*count_c
print(ans)
N = int(input())
D, X = map(int, input().split())
A = list(input() for i in range(N))
sum = 0
for i in range(N):
    B = 0
    while B * A[i + 1] + 1 <= D:
        B += 1
        sum += 1
print(X + sum)


### FIXED CODE ###

N = int(input())
D, X = map(int, input().split())
A = list(int(input()) for i in range(N))
sum = 0
for i in range(N):
    B = 0
    while B * A[i] + 1 <= D:
        B += 1
        sum += 1
print(X + sum)
row = list(map(int, input().split()))
Flag = False
for i in range(1000000):
    if row[0]*i % row[1] == row[2]:
        Flag = True
        break
if Flag:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

import sys
input = sys.stdin.readline

A,B,C = input().split()
A=list(A)
B=list(B)
C=list(C)

if A[-1]==B[0] and B[-1]==C[0]:
    print("YES")
else:
    print("NO")
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)


a, b, c, d = (int(i) for i in input().split())
m = lcm(c, d)
#print(m)
print((b-a+1)-(int((b)/c)-int((a-1)/c))-(int((b)/d)-int((a-1)/d))+(int((b)/(m))-int((a-1)/(m))))
#print("b-a", (b-a))
#print(int((b)/c)-int((a-1)/c))
#print((int((b)/d)-int((a-1)/d)))
#print((int((b-1)/m)-int((a-1)/m)))


### FIXED CODE ###

def gcd(x, y):
    while y > 0:
        x, y = y, x%y
    return x

def lcm(x, y):
    return x/gcd(x, y)*y


a, b, c, d = (int(i) for i in input().split())
m = int(lcm(c, d))
#print(m)
print((b-a+1)-(int((b)//c)-int((a-1)//c))-(int((b)//d)-int((a-1)//d))+(int((b)//(m))-int((a-1)//(m))))
##print(m)
#print("b-a", (b-a+1))
#print(int((b)//c)-int((a-1)//c))
#print((int((b)//d)-int((a-1)//d)))
#print((int((b-1)//m)-int((a-1)//m)))
###C - Monsters Battle Royale
N = int(input())
A = list(map(int, input().split()))
jlist=[True]
cnt = 0
while(min(A) !=1 and len(set(A)) != 1):
    cnt = 0
    for i in range(N):
        if A[i] - min(A) > 0:
            A[i] = A[i] - min(A)
        print(A)
print(min(A))

### FIXED CODE ###

###C - Monsters Battle Royale
N = int(input())
A = list(map(int, input().split()))

while(len(set(A)) != 1):
    minA  = min(A)
    for i in range(N):
        if A[i] > minA:
            time = A[i] // minA
            if time == 1:
                A[i] =A[i] -  time * minA
            else:
                A[i] =A[i] -  (time - 1) * minA
                
print(min(A))