Harryxun/stf_run huggingface dataset:
n = int(raw_input())
al = map(int, raw_input().split())
bl = map(int, raw_input().split())
cl = map(int, raw_input().split())
al.sort()
bl.sort()
cl.sort()
l = [(0,0) for _ in range(n)]
p = 0
for i, b in enumerate(bl):
    while cl[p] <= b:
        p += 1
    l[i] = (b, n-p)
p = n-1
s = 0
t = 0
for a in al[::-1]:
    while p >= 0 and l[p][0] > a:
        s += l[p][1]
        p -= 1
    t += s
print t


### FIXED CODE ###

n = int(raw_input())
al = map(int, raw_input().split())
bl = map(int, raw_input().split())
cl = map(int, raw_input().split())
al.sort()
bl.sort()
cl.sort()
l = [(0,0) for _ in range(n)]
p = 0
for i, b in enumerate(bl):
    while p < n and cl[p] <= b:
        p += 1
    l[i] = (b, n-p)
p = n-1
s = 0
t = 0
for a in al[::-1]:
    while p >= 0 and l[p][0] > a:
        s += l[p][1]
        p -= 1
    t += s
print t
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))

H = l1[0]
N = l1[1]
A = sum(l2)
result = H - A
if result <= 0:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

l = list(map(int, input().split()))

def attack(l):
    H = l[0]
    A = l[1]
    cnt = 0
    while H > 0:
        H -= A
        cnt += 1
    return cnt

print(attack(l))
for i in range(3)
	A, B, C = input()
print(A[0] + B[1] + C[2])

### FIXED CODE ###

A=input()
B = input()
C = input()
print(A[0] + B[1] + C[2])
N,K = map(int, input().split())
c = 1
K_ = 1
i=True
while i==True:
  K_ *= K
  if N < K_:
    print(c)
    i=False
  counter += 1


### FIXED CODE ###

N,K = map(int, input().split())
c = 1
K_ = 1
i=True
while i==True:
  K_ = K_ *K
  if N < K_:
    print(c)
    i=False
  c += 1
N,k = map(int,input().split())
S = input()
lenth = 0
AllLen =[]
preS0,preS1 = S.split('1'),S.split('0')
S0 = [i for i in preS0 if i != '']
S1 = [i for i in preS1 if i != '']
num0 = k
if len(S0) <= k:
	print(len(S))
	exit() 
if S[0] == '0':
	J = k
else:J = k + 1
FirstLen = sum([len(S0[i]) for i in range(k)]) + sum([len(S1[j]) for j in range(J)])
AllLen.append(FirstLen)
CheckLen = FirstLen
if S[0] == '1' and S[-1] == '1':
    for i in range(len(S0) - k):
	    CheckLen = CheckLen - len(S0[i]) - len(S1[i]) + len(S0[i + k]) + len(S1[i + k + 1])
	    AllLen.append(CheckLen)
if S[0] == '0' and S[-1] == '1':
	CheckLen = CheckLen - len(S0[0]) + len(S0[k]) + len(S1[k])
	AllLen.append(CheckLen)
	for i in range(len(S0) - k - 1):
		CheckLen = CheckLen - len(S0[i + 1]) - len(S1[i + 1]) + len(S0[i + k + 1]) + len(S1[i + k + 2])
		AllLen.append(CheckLen)
if S[0] == '1' and S[-1] == '0':
	for i in range(len(S0) - k - 1):
		CheckLen = CheckLen - len(S0[i]) - len(S1[i]) + len(S0[i + k]) + len(S1[i + k + 1])
		AllLen.append(CheckLen)
	CheckLen = CheckLen - len(S0[len(S0) - k - 1]) - len(S1[len(S0) - k - 1]) + len(S0[len(S0) - 1])
	AllLen.append(CheckLen)
if S[0] == '0' and S[-1] == '0':
	if len(S1) == 1:
		print(len(max(S0)) + len(S1[0]))
		exit()
	CheckLen = CheckLen - len(S0[0]) + len(S0[k]) + len(S1[k])
	AllLen.append(CheckLen)
	for i in range(len(S0) - k - 2):
		CheckLen = CheckLen - len(S0[i + 1]) - len(S1[i + 1]) + len(S0[i + k + 1]) + len(S1[i + k + 1])
		AllLen.append(CheckLen)
	CheckLen = CheckLen - len(S0[len(S0) - k - 1]) - len(S1[len(S0) - k - 1]) + len(S0[len(S0) - 1])
	AllLen.append(CheckLen)
print(max(AllLen))

### FIXED CODE ###

n,k = map(int,input().split())
s = input()
befores = '1'
cnt = 0
snum = []
for S in s:
	if S == befores:
		cnt += 1
	else:
		snum.append(cnt)
		cnt = 1
		befores = S
snum.append(cnt)
if s[-1] == '0':
    snum.append(0)
kazu = sum(snum[0:k * 2  + 1])
kaisuu = sum(snum[0:k * 2  + 1])
time = int((len(snum) - k * 2 - 1) / 2 )
one = 0
zero = 1
k = k * 2
for i in range(time):
	kazu = kazu - snum[one] - snum[zero] + snum[one + k + 2] + snum[zero + k]
	kaisuu = max(kaisuu,kazu)
	one += 2
	zero += 2
print(kaisuu)
from collections import defaultdict


H, W = map(int, input().split())
mass = list()
for i in range(H):
    mass.append(input())

values_col = defaultdict(int)
values_row = defaultdict(int)

ind_row = [[0 for i in range(H)] for j in range(W)]
ind_col = [[0 for i in range(H)] for j in range(W)]

ind = 0
for i, m_row in enumerate(mass):
    ind += 1
    for j, chr in enumerate(mass[i]):
        if chr == '#':
            ind += 1
        else:
            values_row[ind] += 1
            ind_row[i][j] = ind

# print('ROW')
# for i in range(H):
#     for j in range(W):
#         print(values_row[ind_row[i][j]], end=' ')
#     print()

ind = 0
for j in range(W):
    ind += 1
    for i in range(H):
        chr = mass[i][j]
        if chr == '#':
            ind += 1
        else:
            values_col[ind] += 1
            ind_col[i][j] = ind

# print('COL')
# for i in range(H):
#     for j in range(W):
#         print(values_col[ind_col[i][j]], end=' ')
#     print()

ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans, values_row[ind_row[i][j]] + values_col[ind_col[i][j]] - 1)
print(ans)


### FIXED CODE ###

from collections import defaultdict


H, W = map(int, input().split())
mass = list()
for i in range(H):
    mass.append(input())

values_col = defaultdict(int)
values_row = defaultdict(int)

ind_row = [[0 for i in range(W)] for j in range(H)]
ind_col = [[0 for i in range(W)] for j in range(H)]

ind = 0
for i, m_row in enumerate(mass):
    ind += 1
    for j, chr in enumerate(mass[i]):
        if chr == '#':
            ind += 1
        else:
            values_row[ind] += 1
            ind_row[i][j] = ind

# print('ROW')
# for i in range(H):
#     for j in range(W):
#         print(values_row[ind_row[i][j]], end=' ')
#     print()

ind = 0
for j in range(W):
    ind += 1
    for i in range(H):
        chr = mass[i][j]
        if chr == '#':
            ind += 1
        else:
            values_col[ind] += 1
            ind_col[i][j] = ind

# print('COL')
# for i in range(H):
#     for j in range(W):
#         print(values_col[ind_col[i][j]], end=' ')
#     print()

ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans, values_row[ind_row[i][j]] + values_col[ind_col[i][j]] - 1)
print(ans)
def fibonacci(n):
    if n == 0:
        return 0
    elif n == 1:
        return 1
    n+=2
    return fibonacci_sub2(n-2, 1, 0)

def fibonacci_sub2(n, fibo_minus1, fibo_minus2):
    return fibo_minus1 if n==0 else fibonacci_sub2(n-1, fibo_minus1+fibo_minus2, fibo_minus1)


N,M = map(int, input().split()) #1 2
a = [int(input()) for i in range(M)]
ans = []
nstep = range(N)
preidx = 0

for idx,i in enumerate(a):
    if i - preidx == 1 and idx != 0:
        print(0)
        exit()
    if idx == 0 and i-preidx-1 != 0:
        ans.append([idx,i-preidx-2])
    elif idx > 0:
        ans.append([idx,i-preidx-2])
    preidx = i
else:
    ans.append([idx,N-preidx-1])

# print(ans)
fibsum = 1
for idx,val in enumerate(ans):
    fibsum *= fibonacci(val[1])
print(fibsum%1000000007)







### FIXED CODE ###

import sys
sys.setrecursionlimit(10000001)
def fibonacci(n):
    if n == 0:
        return 0
    elif n == 1:
        return 1
    n+=2
    return fibonacci_sub2(n-2, 1, 0)%1000000007

def fibonacci_sub2(n, fibo_minus1, fibo_minus2):
    return fibo_minus1%1000000007 if n==0 else fibonacci_sub2(n-1, (fibo_minus1+fibo_minus2)%1000000007, fibo_minus1%1000000007)%1000000007


N,M = map(int, input().split()) #1 2
if M != 0:
    a = [int(input()) for i in range(M)]
else:
    if N == 1:
        print(1)
        exit()
    else:
        print(fibonacci(N)%1000000007)
        exit()
ans = []
nstep = range(N)
preidx = 0

for idx,i in enumerate(a):
    if i - preidx == 1 and idx != 0:
        print(0)
        exit()
    if idx == 0 and i-preidx-1 != 0:
        ans.append([idx,max(0,i-preidx-1)])
    elif idx > 0:
        ans.append([idx,max(0,i-preidx-2)])
    preidx = i
else:
    if preidx != N:
        ans.append([idx,max(0,N-preidx-1)])

fibsum = 1
for idx,val in enumerate(ans):
    fibsum *= max(1,fibonacci(val[1]))
    fibsum %= 1000000007 
print(fibsum)
n= int(input())
a =list(map(int,input().split()))
ans = a[0]

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

for i in range(n-1):
    ans = ans*a[i+1] / gcd(ans,a[i+1])
sum = 0
for i in range(n):
    sum += (ans-1)%a[i]
print(int(sum))

### FIXED CODE ###

n= int(input())
a =list(map(int,input().split()))
ans = a[0]

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

for i in range(n-1):
    ans = ans*a[i+1] // gcd(ans,a[i+1])
sum = 0
for i in range(n):
    sum += (ans-1)%a[i]
print(sum)
import sys
def input():
    return sys.stdin.readline()[;-1]

n,q = map(int, input().split())
#長さn個のリストを入れ子にしたリストの作成：adj
adj = [[] for i in range(n)]

#adjに繋がっている要素を上流下流関わらず全て加える。
for j in range(n-1):
    a,b=map(int, input().split())
    adj[a-1].append(b-1)
    adj[b-1].append(a-1)
print(adj) 

#加算する値を合計したリストの作成
queries = [0 for i in range(n)]
for j in range(q):
    p, x = map(int, input().split())
    queries[p-1] += x
print(queries)

ans = [0 for i in range(n)]

#aの値，直前の値，直前のaの値
st = [(0, 0, -1)] 

print('answer roop')

#つながってる奴の一番後ろから処理していく。
#０スタート→1,2繋がってるなら2にいく。2に3が繋がってるなら次は3。
#3に繋がってるのがなければ1に戻る。
#この際，aの直前の値をタプルで保持したままリストに挿入して保管しておく。
while st:
    #stの先頭を取り出す。初期値は末尾のため-1
    l = st.pop()  
    print(l)
    ans[l[0]] = l[1] + queries[l[0]]
    for v in adj[l[0]]:
        if v != l[2]:
            st.append((v, ans[l[0]], l[0]))

print(*ans)

### FIXED CODE ###

import sys
def input():
    return sys.stdin.readline()[:-1]

n,q = map(int, input().split())
#長さn個のリストを入れ子にしたリストの作成：adj
adj = [[] for i in range(n)]

#adjに繋がっている要素を上流下流関わらず全て加える。
for j in range(n-1):
    a,b=map(int, input().split())
    adj[a-1].append(b-1)
    adj[b-1].append(a-1) 

#加算する値を合計したリストの作成
queries = [0 for i in range(n)]
for j in range(q):
    p, x = map(int, input().split())
    queries[p-1] += x

ans = [0 for i in range(n)]

#aの値，直前の値，直前のaの値
st = [(0, 0, -1)] 

#つながってる奴の一番後ろから処理していく。
#０スタート→1,2繋がってるなら2にいく。2に3が繋がってるなら次は3。
#3に繋がってるのがなければ1に戻る。
#この際，aの直前の値をタプルで保持したままリストに挿入して保管しておく。
while st:
    #stの先頭を取り出す。初期値は末尾のため-1
    l = st.pop()  
    ans[l[0]] = l[1] + queries[l[0]]
    for v in adj[l[0]]:
        if v != l[2]:
            st.append((v, ans[l[0]], l[0]))

print(*ans)
N, K = map(int, input().split())

snukes = [0] * N
for i in range(K):
  d_i = int(input()) # throw away
  a_i = map(int, input().split())
  for a in a_i:
    snukes[a] += 1

counter = 0
for i in range(N):
  if snukes[i] == 0:
    counter += 1

print(counter)

### FIXED CODE ###

N, K = map(int, input().split())
 
snukes = [0] * N
for i in range(K):
  d_i = int(input()) # throw away
  a_i = map(int, input().split())
  for a in a_i:
    snukes[a-1] += 1
 
counter = 0
for i in range(N):
  if snukes[i] == 0:
    counter += 1
 
print(counter)
N = input()
M = list(map(int,input().split()))
X = set(M)
Y = len(X)

if N == Y:
    print("YES")
    
else:
    print("NO")

### FIXED CODE ###

N = input()
M = list(map(int,input().split()))
X = set(M)
Y = len(X)
Z = len(M)
if Y == Z:
    print("YES")

else:
    print("NO")
n,k = map(int,input().split())
a = input().split()
b = [0]*n
d = {}
ind = 1
num = 0
loop = 1
while num == k:
    if b[ind-1] == 0:
        b[ind-1] = -1
        d[ind] = num
        num += 1
        ind = int(a[ind-1])
    else:
        loop = num-d[ind]
        sup = d[ind]
        break

if k-sup >=0:
    for i in range((k-sup)%loop):
        ind = int(a[ind-1])

print(ind)

### FIXED CODE ###

N, K = map(int, input().split())
A = list(map(int, input().split()))
# = [int(input()) for i in range(N)]
# = [list(map(int, input().split())) for i in range(N)]
next = 1
List = [-1]*N
 
for i in range(K):
    if List[next-1] == -1:
        List[next-1] = i
        next = A[next-1]
 
    else:
        loop = i - List[next-1]
        afterloop = (K-(i-loop))%loop
        print(List.index((i-loop) + afterloop)+1)
        exit()
 
print(next)
N = int(input())
has = False
for n in N:
	if n == 7:
		has = True
		break
	
if has:
	print("Yes")
else:
	print("No")
	

### FIXED CODE ###

N = int(input())
has = False
for n in str(N):
	if n == "7":
		has = True
		break
	
if has:
	print("Yes")
else:
	print("No")
input = intput().split()
a = input[0]
b = input[1]
c = input[2]

ans = c - (a - b)

if ans < 0:
    ans = 0

print(ans)

### FIXED CODE ###


input = input().split()
a = int(input[0])
b = int(input[1])
c = int(input[2])

ans = c - (a - b)

if ans < 0:
    ans = 0

print(ans)
# -*- coding: utf-8 -*-

while True:
    try:
        n = int(raw_input())
        list1 = range(2, n)
        list2 = []
        while True:
            i = list1.pop(0)
            list2.append(i)
            for x in list1:
                if x % i == 0:
                    list1.remove(x)
            if i**2 > list1[::-1][0]:
                break

        print(len(list2 + list1))
    except EOFError:
        break

### FIXED CODE ###

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

list = [1]*1000000
list[0] = 0
list[1] = 0
for i in range(1, 1000000):
    if list[i] == 1:
        for j in range(i**2, 1000000, i):
            list[j] = 0

for i in range(2, 1000000):
    list[i] += list[i -1]
while True:
    try:
        n = int(raw_input())
        print(list[n])
    except EOFError:
        break
import sys
input = sys.stdin.readline
import numpy

N =int(input())
Ws = np.array([int(i) for i in input().split(" ")])

sub = np.sum(Ws)
# print("sub絶対値：{}".format(abs(sub)))
pre_sub = sub
for W in Ws:
  sub = sub - W*2
#   print("sub絶対値：{}".format(abs(sub)))
#   print("sub={}".format(sub))
  if abs(pre_sub) < abs(sub):
#     print("{}が最小".format(pre_sub))
    print(abs(pre_sub))
    break
  pre_sub = sub

### FIXED CODE ###

import sys
input = sys.stdin.readline
import numpy as np

N =int(input())
Ws = [int(i) for i in input().split(" ")]

sub_W = np.sum(Ws)
pre_sub = sub_W
for W in Ws:
  sub_W = sub_W - W*2
  if abs(pre_sub) < abs(sub_W):
    print(abs(pre_sub))
    break
  pre_sub = sub_W
import math
from functools import reduce


def gcd(*numbers):
    return reduce(math.gcd, numbers)

N = int(input())
cnt = 0
for i in range(1, N+1):
    for j in range(i, N + 1):
        for k in range(k, N + 1)
            cnt += gcd(i, j, k)
print(cnt)

### FIXED CODE ###

import math
from functools import reduce


def gcd(*numbers):
    return reduce(math.gcd, numbers)


N = int(input())
cnt = 0
for i in range(1, N+1):
    for j in range(1, N + 1):
        for k in range(1, N + 1):
            cnt += gcd(i, j, k)
print(cnt)
x = int(input())
if x == 1:
  print("1")
  exit()
  
ans = 0
for b in range(2,int(x**(1/2)+1)):
  for p in range(2,1000):
    tmp = pow(b,p)
    if tmp<=x:
      ans = max(ans,pow(b,p))
    else:
      break
      
print(ans)


### FIXED CODE ###

a,b,c,d = map(int,input().split())
flag = False
if abs(c-a)<=d:
  flag = True
elif abs(b-a)<=d and abs(c-b)<=d:
  flag = True

if flag:
  print("Yes")
else:
  print("No")
n = int(input())
A = [int(_) for _ in input().split()]
total = sum(A)
neg = 0
neno = []
pono = []
for a in A:
    if a < 0:
        neg += 1
        neno.append(a)
    else:
        pono.append(a)
neno.sort()
pono.sort()
noneg = -sum(neno) + sum(pono)
if n == 2:
    print(max(-total, total))
else:
    if neg % 2 == 0:
        print(noneg)
    else:
        print(noneg - 2*min(-neno[-1],pono[0]))
    

### FIXED CODE ###

n = int(input())
A = [int(_) for _ in input().split()]
total = sum(A)
neg = 0
pos = 0
neno = []
pono = []
for a in A:
    if a < 0:
        neg += 1
        neno.append(a)
    else:
        pos += 1
        pono.append(a)
neno.sort()
pono.sort()
noneg = -sum(neno) + sum(pono)
if n == 2:
    print(max(-total, total))
else:
    if neg % 2 == 0:
        print(noneg)
    else:
        if pos != 0:
            print(noneg - 2*min(-neno[-1],pono[0]))
        else:
            print(noneg + 2*(neno[-1]))
N = int(input())
S = str(input())
dp = [[0] for i in range(N+1)]

for i in reversed(range(N)):
    for j in reversed(range(N)):
        if S[i] == S[j]:
            dp[i][j] = dp[i+1][j+1] + 1
ans = 0
for i in range(N):
    for j in range(N):
        tmp = dp[i][j]
        if j >= i:
            tmp = min(j-i,tmp)
        ans = max(tmp,ans)
print(ans)




### FIXED CODE ###

N = int(input())
S = str(input())
dp = [[0 for i in range(N+1)] for i in range(N+1)]

for i in reversed(range(N)):
    for j in reversed(range(N)):
        if S[i] == S[j]:
            dp[i][j] = dp[i+1][j+1] + 1
ans = 0
for i in range(N):
    for j in range(N):
        if j > i:
            tmp = min(j-i,dp[i][j])
            ans = max(tmp,ans)
print(ans)
x,n=map(int,input().split())
p=set(list(map(int,input().split()))
ans=0
flag=0
while flag==0:
    if not x-ans in p:
        print(x-ans)
        flag=1
    elif not x+ans in p:
        print(x+ans)
        flag=1
    ans+=1


### FIXED CODE ###

x,n=map(int,input().split())
p=set(list(map(int,input().split())))
ans=0
flag=0
while flag==0:
    if not x-ans in p:
        print(x-ans)
        flag=1
    elif not x+ans in p:
        print(x+ans)
        flag=1
    ans+=1
while 1:
     n=input().split()
     w=int(x[0])
     h=int(x[1])
     if h==w==0:
       break
     for i in range (h):
         if i==0 or i==h-1:
            print("#"*w)
         else:
             print("#" "."*(w-2), "#")
     print()


### FIXED CODE ###

while True:
    x=input().split()
    a=int(x[0])
    b=int(x[1])
    if a ==0 and b==0:
        break
    print("#"*b)
    for i in range(a-2):
        print("#"+"."*(b-2)+"#")
    print("#"*b)
    print("")
from math import factorial

def comb(n, r):
    if n < r:
        return 0
    return factorial(n) // (factorial(n-r) * factorial(r))

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


for i in range(1, k+1):
    print(comb(n-k+1, i) * comb(k-1, i-1) % (10**9+7))





### FIXED CODE ###

from collections import Counter

s = input()

c = Counter(s)

if len(c) == 2:
    print('Yes')
else:
    print('No')
import bisect

n = 10**5
is_prime = [True] * (n + 1)
is_prime[0] = False
is_prime[1] = False

for i in range(2, int(n**0.5) + 1):
    if not is_prime[i]:
        continue
    for j in range(i * 2, n + 1, i):
        is_prime[j] = False

is_simular_2017 = is_prime.copy()

for i in range(n + 1):
    if is_prime[i] and (i + 1) // 2 > 0:
        if not is_prime[(i + 1) // 2]:
            is_simular_2017[i] = False


simular_2017 = [i for i in range(len(is_simular_2017)) if is_simular_2017[i]]

Q = int(input())
LR = [list(map(int, input().split())) for _ in range(Q)]

for l, r in LR:
    count = 0
    insert_index1 = bisect.bisect_left(simular_2017, l)
    insert_index2 = bisect.bisect_left(simular_2017, r)
    cnt = insert_index2 - insert_index1
    if simular_2017[insert_index2] == r:
        cnt += 1
    print(cnt)

### FIXED CODE ###

import bisect

n = 10**5
is_prime = [True] * (n + 1)
is_prime[0] = False
is_prime[1] = False

for i in range(2, int(n**0.5) + 1):
    if not is_prime[i]:
        continue
    for j in range(i * 2, n + 1, i):
        is_prime[j] = False

num = [0] * (n + 1)

cnt = 0
for i in range(n + 1):
    if is_prime[i] and (i + 1) // 2 > 0:
        if is_prime[(i + 1) // 2]:
            cnt += 1
    num[i] = cnt

Q = int(input())
LR = [list(map(int, input().split())) for _ in range(Q)]

for l, r in LR:
    print(num[r] - num[l - 1])
import copy 

def gcd(a,b):
    if b > a:
        a, b = b, a
    while b:
        a, b = b, a%b
    return a

N = int(input())
T = list(map(int,input().split()))
T.sort()
LIS = [0]*N
LIS[0] += T[0]
for i in range(N-1):
    LIS[i+1] += gcd(LIS[i],T[i+1])
GCD = 0
GCD += LIS[N-1]
if N == 2:
    ANS = max(T[0],T[1])
else:
    #第１項がtarget
    S = copy.copy(T)
    S.pop(0)
    LS = [0]*(N-1)
    LS[0] += S[0]
    for i in range(N-2):
        LS[i+1] += gcd(LS[i],S[i+1])
    ANSA = LS[N-2]

    #その他の場合
    LJ = []
    for i in range(N-1):
        if LIS[i] != LIS[i+1]:
            LJ.append(i+1)

    LK = []
    for j in range(len(LJ)):
        U = copy.copy(T)
        U.pop(LJ[j])
        LS = [0]*(N-1)
        LS[0] += U[0]
        for i in range(N-2):
            LS[i+1] += gcd(LS[i],U[i+1])
        LK.append(LS[N-2])
    ANSB = max(LK)
    ANS = max(ANSA,ANSB)
print(ANS)


### FIXED CODE ###

import copy 

def gcd(a,b):
    if b > a:
        a, b = b, a
    while b:
        a, b = b, a%b
    return a

N = int(input())
T = list(map(int,input().split()))
T.sort()
LIS = [0]*N
LIS[0] += T[0]
for i in range(N-1):
    LIS[i+1] += gcd(LIS[i],T[i+1])
F = LIS.index(min(LIS))
if len(T) == 2:
    ANS = max(T[0],T[1])
elif F == 0:
    U = copy.copy(T)
    V = copy.copy(T)
    U.pop(1)
    V.pop(0)
    LU = [0]*(N-1)
    LU[0] = U[0]
    LV = [0]*(N-1)
    LV[0] = V[0]
    for i in range(N-2):
        LU[i+1] += gcd(LU[i],U[i+1])
    ANSU = LU[N-2]
    for i in range(N-2):
        LV[i+1] += gcd(LV[i],V[i+1])
    ANSV = LV[N-2]
    ANS = max(ANSU,ANSV)
    
else:
    U = copy.copy(T)
    V = copy.copy(T)
    U.pop(F)
    V.pop(0)
    LU = [0]*(N-1)
    LU[0] = U[0]
    LV = [0]*(N-1)
    LV[0] = V[0]
    ANSU = 0
    ANSV = 0
    for i in range(N-2):
        LU[i+1] += gcd(LU[i],U[i+1])
    ANSU = LU[N-2]
    for i in range(N-2):
        LV[i+1] += gcd(LV[i],V[i+1])
    ANSV = LV[N-2]
    ANSP = max(ANSU,ANSV)
    ANS = max(ANSP,LIS[N-1])
        
print(ANS)
N, Q = map(int, input().split())
S = input()
TD = reversed([tuple((input().split())) for _ in range(Q)])

left, right = 0, N-1

for t, d in TD:
	if S[left] == t and "L" == d:
		left += 1
	if S[right] == t and "R" == d:
		right -= 1
print(right-left+1)


### FIXED CODE ###

N, Q = map(int, input().split())
S = list(input())
TD = [tuple(input().split()) for _ in range(Q)]

def bs_l(f, s, e):
	if s==e:
		return s if f(s) else s+1

	c = (s+e)//2
	if f(c):
		#左
		return bs_l(f, s, c if c == s else c-1)
	else:
		#右
		return bs_l(f, c if c == e else c+1, e)

def bs_r(f, s, e):
	if s==e:
		return s if f(s) else s-1

	c = (s+e)//2
	if not f(c):
		#左
		return bs_r(f, s, c if c == s else c-1)
	else:
		#右
		return bs_r(f, c if c == e else c+1, e)

def isAlive(c):
	for t, d in TD:
		if S[c] == t:
			c += 1 if "R" == d else -1
			if c < 0 or N <= c:
				return False
	return True

S, E = bs_l(isAlive, 0, N-1), bs_r(isAlive, 0, N-1)
print(max(E-S+1, 0))
n = int(input())
a = int(input())
b = int(input())
if n == 1:
    print('Hello World')
else:
    print(a + b)


### FIXED CODE ###

n = int(input())
if n == 1:
    print('Hello World')
else:
    a = int(input())
    b = int(input())
    print(a + b)
# coding=utf-8
get = lambda: int(raw_input().strip())
gets = lambda: map(int, raw_input().strip().split())
getss = lambda n: [gets() for _ in xrange(n)]


# N = 3
# A = [[1, 1], [5, 1], [5, 5]]

# N = 2
# A = [[10, 20], [20, 20]]

N = get()
A = getss(N)
UF = {}


def find(x):
    if x != UF[x]:
        UF[x] = find(UF[x])
    return UF[x]


def union(x, y):
    UF.setdefault(x, x)
    UF.setdefault(y, y)
    UF[find(x)] = find(y)


for i, j in A:
    union(i, -j)


count = {}
for x in UF:
    root = find(x)
    if root not in count:
        count[root] = [0, 0]
    if x > 0:
        count[root][0] += 1
    else:
        count[root][1] += 1

print sum(u[0] * u[1] for u in count) - N

### FIXED CODE ###

# coding=utf-8


get = lambda: int(raw_input().strip())
getl = lambda: raw_input().strip()
gets = lambda: map(int, raw_input().strip().split())
getss = lambda n: [gets() for _ in xrange(n)]


# N = 3
# A = [[1, 1], [5, 1], [5, 5]]

# N = 2
# A = [[10, 20], [20, 20]]

N = get()
A = getss(N)
UF = {}


def find(x):
    if x != UF[x]:
        UF[x] = find(UF[x])
    return UF[x]


def union(x, y):
    UF.setdefault(x, x)
    UF.setdefault(y, y)
    UF[find(x)] = find(y)


for i, j in A:
    union(i, -j)


count = {}
for x in UF:
    root = find(x)
    if root not in count:
        count[root] = [0, 0]
    if x > 0:
        count[root][0] += 1
    else:
        count[root][1] += 1

res = 0
for x in count:
    pos, neg = count[x]
    if pos > 1 and neg > 1:
        res += pos * neg
    else:
        res += max(pos, neg)
print res - N
n,m = map(int,input().split())
if abs(n - m) >= 2:
  print("0")
else:
  if n == m:cou = 2
  else:cou = 1
  while n > 1:
    cou *= n
    cou %= (10 ** 9 + 7)
    n -= 1
  while m > 1:
    cou *= m
    cou %= (10 ** 9 + 7)
    m -= 1
print(cou)

### FIXED CODE ###

n,m = map(int,input().split())
if abs(n - m) >= 2:
  print("0")
else:
  if n == m:cou = 2
  else:cou = 1
  while n > 1:
    cou *= n
    cou %= (10 ** 9 + 7)
    n -= 1
  while m > 1:
    cou *= m
    cou %= (10 ** 9 + 7)
    m -= 1
  print(cou)