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

# F - . (Single Dot)

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

N, M = map(int, readline().split())
INF = 2 * 10**9 + 1
W = defaultdict(int)

min_y = INF
max_y = INF * -1
for i in range(N):
    A, B, C = map(int, readline().split())
    A *= 2
    B *= 2
    C *= 2
    min_y = min(min_y, C)
    max_y = max(max_y, C)
    for j in range(A, B+1):
        W[(j, C)] = -1

min_x = INF
max_x = INF * -1
for i in range(M):
    D, E, F = map(int, readline().split())
    D *= 2
    E *= 2
    F *= 2
    min_x = min(min_x, D)
    max_x = max(max_x, D)
    for j in range(E, F+1):
        W[(D, j)] = -1

q = deque()
q.append((0, 0))
W[(0, 0)] = -1
ans = 0
b_ans = True
while len(q) > 0:
    x, y = q.pop()
    #print(x, y)
    if x > max_x or x < min_x or y > max_y or y < min_y:
        b_ans = False
        break
    for (vx, vy) in [(1, 0), (0, 1), (-1, 0), (0, -1)]:
        nx = x + vx
        ny = y + vy
        if (nx, ny) not in W:
            if nx%2==1 and ny%2==1:
                ans += 1
            q.append((nx, ny))
            W[(nx, ny)] = -1

if b_ans == True:
    print(ans)
else:
    print('INF')


### FIXED CODE ###

# F - . (Single Dot)

import bisect
import sys
readline = sys.stdin.readline

N, M = map(int, readline().split())
INF = 10**9 + 1
s_X = set([-INF, 0, INF])
s_Y = set([-INF, 0, INF])

def compress(s):
    ls = list(s)
    ls.sort()
    return {e: i for i, e in enumerate(ls)}

ABC = []
for i in range(N):
    A, B, C = map(int, readline().split())
    ABC.append((A, B, C))
    s_Y.add(C)

DEF = []
for i in range(M):
    D, E, F= map(int, readline().split())
    DEF.append((D, E, F))
    s_X.add(D)

mapX = compress(s_X)
mapY = compress(s_Y)
l_X = list(mapX.keys())
l_Y = list(mapY.keys())
maxX = len(mapX)*2
maxY = len(mapY)*2

W = [[0] * maxY for _ in range(maxX)]

for A, B, C in ABC:
    A = mapX[l_X[bisect.bisect_left(l_X, A)]]
    B = mapX[l_X[bisect.bisect_right(l_X, B)-1]]
    C = mapY[C]
    A *= 2
    B *= 2
    C *= 2
    for j in range(A, B+1):
        W[j][C] = 1

for D, E, F in DEF:
    D = mapX[D]
    E = mapY[l_Y[bisect.bisect_left(l_Y, E)]]
    F = mapY[l_Y[bisect.bisect_right(l_Y, F)-1]]
    D *= 2
    E *= 2
    F *= 2
    for j in range(E, F+1):
        W[D][j] = 1

#print(W)
q = []
q.append((mapX[0]*2, mapY[0]*2))
W[mapX[0]*2][mapY[0]*2] = 1
ans = 0
b_ans = True
while q:
    x, y = q.pop()
    if x == maxX or x == 0 or y == maxY or y == 0:
        b_ans = False
        break
    for (vx, vy) in [(1, 0), (0, 1), (-1, 0), (0, -1)]:
        nx = x + vx
        ny = y + vy
        if W[nx][ny] == 0:
            if nx%2==1 and ny%2==1:
                ex = l_X[(nx+1)//2] - l_X[(nx-1)//2]
                ey = l_Y[(ny+1)//2] - l_Y[(ny-1)//2]
                ans += ex * ey
                #print(nx, ny, ans)
            q.append((nx, ny))
            W[nx][ny] = 1

if b_ans == True:
    print(ans)
else:
    print('INF')
### BUGGY CODE ###

n=int(input())
A=[]
for i in range(n):
    a=str(input())
    A.append(a)
import collections
c = collections.Counter(A)
C=[i[0] for i in c.items() if i[1] >= c.most_common()[0][1]]
C.sort(reverse=False)
for j in range(len(C)):
    print(C[j])

### FIXED CODE ###

n = int(input())
S=[]
for i in range(n):
    s=input()
    S.append(s)
S.sort()
import collections
c = collections.Counter(S)
values, counts = zip(*c.most_common())
print(values[0])
for i in range(len(counts)-1):
    if counts[i] == counts[i+1]:
        print(values[i+1])
    else:
        exit()
### BUGGY CODE ###

n = int(input())
a = [int(input()) for _ in range(n)]
print(max(a[1:]))
for i in range(1,n-1):
    print(max(*a[:i],*a[i+1:]))
print(max(a[:n-1]))

### FIXED CODE ###

n = int(input())
a = [int(input()) for _ in range(n)]
temp = sorted(a)
m1 = temp[-1]
m2 = temp[-2]
for i in range(n):
    if a[i] == m1:
        print(m2)
    else:
        print(m1)
### BUGGY CODE ###

MOD = 10**9 + 7

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

def GCP(a, b):
  if a < b:
    a, b = b, a
  while b > 0:
    a, b = b, a % b
  return a

def LCM(a, b):
  return a * b // GCP(a, b)

T = A.copy()
while len(T) > 1:
  T.append(LCM(T.pop(0), T.pop(0)))

L = T[0]

ans = 0
for i in range(N):
  ans += L // A[i]
  ans %= MOD

print(ans)

### FIXED CODE ###

from collections import deque

def GCP(a, b):
  if a < b:
    a, b = b, a
  while b > 0:
    a, b = b, a % b
  return a

def LCM(a, b):
  return a * b // GCP(a, b)

def solve():
  MOD = 10**9 + 7

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

  T = deque(A)
  while len(T) > 1:
    T.append(LCM(T.pop(), T.pop()))

  L = T.pop()

  ans = 0
  for i in range(N):
    ans += L // A[i]

  print(ans % MOD)

solve()
### BUGGY CODE ###

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

minus_count = 0
for i, x in enumerate(zip(reversed(c_list))):
    for x2 in zip(reversed(c_list[:-i -1])):
        if x > x2:
            minus_count += 1
            break

print(len(c_list) - minus_count)

### FIXED CODE ###

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

minus_count = 0
rember_number = 0
for i, x in enumerate(c_list):
    if i == 0:
        rember_number = x
        continue
    else:
        if x < rember_number:
            rember_number = x
        if x > rember_number:
            minus_count += 1

print(len(c_list) - minus_count)
### BUGGY CODE ###

N, Q = map(int, input().split())
S =  input()
qlist = []
AC = 'AC'
for i in range(Q):
    s, e = map(int, input().split())
    qlist.append([s-1, e])

for i in qlist:
    tmp = S[i[0]:i[1]]
    print(tmp.count(AC))

### FIXED CODE ###

N,Q = map(int,input().split())
S = input()
point = [list(map(int,input().split())) for i in range(Q)]
ac_list = [0]*(N+1)
 
for i in range(N):
  if S[i:i+2] == 'AC':
    ac_list[i+1] = ac_list[i] + 1
  else:
    ac_list[i+1] = ac_list[i]
 
 
for i in range(Q):
  print(ac_list[point[i][1]-1] - ac_list[point[i][0]-1])
### BUGGY CODE ###

import numpy as np
import copy


def check_nn(b_):
    n_ = len(b_)
    # print(b_)

    if b_ == [1]:
        return [1]

    nn = np.zeros(n_)
    for ii in range(n_):
        if b_[ii] == ii+1:
            nn[ii] = 1

    tsum = int(sum(nn))

    if tsum == 0:
        return -1

    # if n_ == 1 and tsum == 1:
    #     ans_ = [1]

    tind = np.where(nn == 1)
    # print(tind)
    for ii in range(tsum):
        # tp = b_.pop[tind[ii]]
        tempb = copy.deepcopy(b_)
        # print(tind[0][ii])
        tp = tempb.pop(tind[0][ii])
        ans_ = check_nn(tempb)
        if ans_ != -1:
            # ans_.insert(0, tp)
            ans_.append(tp)
            return ans_

    return -1


n = input().rstrip().split(' ')
b = list(map(int, input().rstrip().split(' ')))
# ans = list()

# print(type(b))

ans = check_nn(b)

# print(ans)

if ans == -1:
    print(ans)
else:
    na = len(ans)
    for ii in range(na):
        print(ans[ii])



### FIXED CODE ###

import sys

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

ans = list()

for ii in reversed(range(n)):
    for jj in reversed(range(ii+1)):
        if b[jj] == jj + 1:
            ans.append(b.pop(jj))
            # print(ans)
            break

if len(b) != 0:
    print(-1)
    sys.exit()

for ii in reversed(range(n)):
    print(ans[ii])
### BUGGY CODE ###

import sys

K = int(sys.stdin.readline())
S = sys.stdin.readline().rstrip('\n')

# ## COMBINATION (MOD) ###
N_MAX = 2*10**6  # 問題サイズに合わせて変えておく
MOD = 10**9 + 7

fac = [1, 1]  # 元テーブル
facinv = [1, 1]  # 逆元テーブル
inv = [0, 1]  # 逆元テーブル計算用テーブル

for i in range(2, N_MAX + 1):
    fac.append((fac[-1] * i) % MOD)
    inv.append((-inv[MOD % i] * (MOD // i)) % MOD)
    facinv.append((facinv[-1] * inv[-1]) % MOD)


def cmb(n, r):
    if (r < 0 or r > n):
        return 0
    # r = min(r, n-r)
    return fac[n] * facinv[r] * facinv[n - r] % MOD

# K 文字追加
ans = 0

ln = len(S)

for i in range(ln, ln+K+1):

    # pre
    p = i - 1
    p1 = cmb(p, ln - 1)
    p2 = pow(25, p - (ln - 1), MOD)

    # suf
    s = (ln + K) - i
    s2 = pow(26, s, MOD)

    ans += p1*p2*s2 % MOD
    ans %= MOD

    # print(p, p1,p2, s, s2)

print(ans)

### FIXED CODE ###

import sys

K = int(sys.stdin.readline())
S = sys.stdin.readline().rstrip('\n')

# ## COMBINATION (MOD) ###
N_MAX = 10**6  # 問題サイズに合わせて変えておく
MOD = 10**9 + 7

inv = [0, 1]  # 逆元テーブル計算用テーブル

for i in range(2, N_MAX + 2):
    inv.append((-inv[MOD % i] * (MOD // i)) % MOD)

# K 文字追加
ans = 0

ln = len(S)

p1 = 1
p2 = 1
s2 = pow(26, K, MOD)

for i in range(1, K + 2):

    ans += (p1 * p2 * s2) % MOD
    ans %= MOD

    # print(p1, p2, s2)

    # pre
    p1 = (p1 * (ln + i - 1) * inv[i]) % MOD
    p2 = (p2 * 25) % MOD

    # suf
    s2 = (s2 * inv[26]) % MOD

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

from math import factorial

x, y = [int(x) for x in input().split()]


def c(n, r):
    u = 1
    for i in range(min(r, n - r)):
        u = u * (n - i) / (i + 1)
    return u


def solve(x, y):
    if (x + y) % 3 != 0:
        return 0
    if x * 2 < y or y * 2 < x:
        return 0
    
    n = (x + y) // 3
    r = ((x - y) + n) // 2
    return factorial(n) // factorial(r) // factorial(n - r)


print(solve(x, y) % 1000000007)

### FIXED CODE ###

MAX = 1000000
MOD = 1000000007

fac = [None] * MAX
finv = [None] * MAX
inv = [None] * MAX


def comb_init():
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, MAX):
        fac[i] = fac[i - 1] * i % MOD
        inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD


def comb(n, k):
    if n < 0 or k < 0 or n < k:
        return 0
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD


comb_init()
x, y = [int(x) for x in input().split()]


def solve(x, y):

    if (x + y) % 3 != 0:
        return 0

    n = (2 * y - x) // 3
    m = (2 * x - y) // 3
    if n < 0 or m < 0:
        return 0

    return comb(n + m, n)


print(solve(x, y))
### BUGGY CODE ###

n=int(input())
l=list(map(int,input().split()))
m=[]
for i in range(1,n):
    m.append(l.count(i))
m.append(0)
for j in range(n):
    print(m[j])
    

### FIXED CODE ###

n=int(input())
l=list(map(int,input().split()))
m=[0]*n
for i in l:
    m[i-1]+=1
for j in range(n):
    print(m[j])
### BUGGY CODE ###

def isSame(string):
    for i in range(1, len(string)):
        if string[i] != string[0]:
            return False
    return True

s = raw_input()
a = []
l = len(s)
for i in range(l):
    a.append(s[i])

n = 0

while not isSame(a):
    if a[0] == 'B':
        for i in range(l):
            if a[i] == 'B':
                a[i] = 'W'
            else:
                break
        a.insert(0, 'W')
    elif a[0] == 'W':
        for i in range(l):
            if a[i] == 'W':
                a[i] = 'B'
            else:
                break
        a.insert(0, 'B')
    n += 1
    l += 1

print n


### FIXED CODE ###

s = raw_input()
temp = s[0]
n = 0
for i in range(len(s)):
    if s[i] != temp:
        n += 1
        temp = s[i]
print n
### BUGGY CODE ###

s = input()
q = int(input())
Q = [input().split() for _ in range(q)]

s = list(s)
flag = True
for query in Q:
    if len(query) == 1:
        flag = not flag
    else:
        if query[1] == '1':
            if flag:
                s.insert(0, query[2])
            else:
                s.append(query[2])
        elif query[1] == '2':
            if flag:
                s.append(query[2])
            else:
                s.insert(0, query[2])

if not flag:
    s.reverse()

print("".join(s))


### FIXED CODE ###

from collections import deque

s = input()
q = int(input())
Q = [input() for _ in range(q)]

s = deque(list(s))
insert = s.appendleft
append = s.append
flag = True

for query in Q:
    if query[0] == '1':
        flag = not flag
    else:
        if (query[2] == '1' and flag) or (query[2] == '2' and not flag):
            insert(query[4])
        else:
            append(query[4])

if not flag:
    s.reverse()

print(*s, sep='')
### BUGGY CODE ###

S = input()
n = len(S)
mod = (10**9 + 7)

A = [0] * len(S)
C = [0] * len(S)
Q = [0] * len(S)
Bi = []
Qi = []

for i, s in enumerate(S):
    if s == 'A':
        A[i] = 1
    elif s == 'B':
        Bi.append(i)
    elif s == 'C':
        C[i] = 1
    else:
        Q[i] = 1
        Qi.append(i)

def acc(l):
    for i in range(1, len(l)):
        l[i] += l[i - 1]
acc(A)
acc(C)
acc(Q)

from itertools import chain
ans = 0
for b in chain(Bi, Qi):
    if b == 0 or n - 1 <= b: continue
    ai = A[b - 1]
    qa = Q[b - 1]
    a = (ai * (3 ** qa)) % mod
    if qa > 0:
        a += (3 ** (qa - 1) * qa) % mod

    ci = C[b]
    qc = Q[b]
    lc = C[n - 1] - ci
    lqc = Q[n - 1] - qc
    c = (lc * (3 ** lqc)) % mod
    if lqc > 0:
        c += (3 ** (lqc - 1) * lqc) % mod
    
    ans += (a * c) % mod

print(ans % mod)

### FIXED CODE ###

S = input()
n = len(S)
mod = (10**9 + 7)

dp = [[0] * 4 for _ in range(n + 1)]

dp[n] = [0, 0, 0, 1]
for i in range(n-1, -1, -1):
    if S[i] == '?':
        dp[i][3] =  dp[i+1][3] * 3 % mod
        dp[i][2] = (dp[i+1][2] * 3 + dp[i+1][3]) % mod
        dp[i][1] = (dp[i+1][1] * 3 + dp[i+1][2]) % mod
        dp[i][0] = (dp[i+1][0] * 3 + dp[i+1][1]) % mod
    elif S[i] == 'C':
        dp[i][3] =  dp[i+1][3] % mod
        dp[i][2] = (dp[i+1][2] + dp[i+1][3]) % mod
        dp[i][1] =  dp[i+1][1] % mod
        dp[i][0] =  dp[i+1][0] % mod
    elif S[i] == 'B':
        dp[i][3] =  dp[i+1][3] % mod
        dp[i][2] =  dp[i+1][2] % mod
        dp[i][1] = (dp[i+1][1] + dp[i+1][2]) % mod
        dp[i][0] =  dp[i+1][0] % mod
    elif S[i] == 'A':
        dp[i][3] =  dp[i+1][3]
        dp[i][2] =  dp[i+1][2]
        dp[i][1] =  dp[i+1][1]
        dp[i][0] = (dp[i+1][0] + dp[i+1][1]) % mod
print(dp[0][0])
### BUGGY CODE ###

from collections import defaultdict

S = input()
N = len(S)

M = [0] * N
A = [0] * N
SUM = [0] * (N + 1)
MOD = 2019

x = 1
for i in range(N):
    M[i] = x % 2019
    x *= 10
for i, x in enumerate(S[::-1]):
    A[i] = M[i] * int(x) % MOD
for i in range(N):
    SUM[i + 1] = (SUM[i] + A[i]) % MOD

D = defaultdict(int)
ans = 0
for x in SUM:
    ans += D[x]
    D[x] += 1
print(ans)


### FIXED CODE ###

S = input()
N = len(S)
SUM = [0] * (N + 1)
MOD = 2019

r = 1  # 10のi乗を2019で割った余り
S = S[::-1]
for i in range(N):
    A = r * int(S[i])
    SUM[i + 1] = (SUM[i] + A) % MOD
    r = r * 10 % MOD

cnt = [0] * 2019
ans = 0
for x in SUM:
    ans += cnt[x]
    cnt[x] += 1
print(ans)
### BUGGY CODE ###

from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

DEPMAX = 6

def foo(n,dep):
    if dep>DEPMAX or n<0:
        ret = "-1"
    elif n==0:
        ret = ""
    elif n%mn==0:
        ret = str(mni)*(n//mn)
    else:
        mxs = "-1"
        for x in a:
            v = foo(n-cs[x],dep+1)
            if v=="-1":
                continue
            vv = v+str(x)
            if int(vv)>int(mxs):
                mxs = vv
            vv = str(x)+v
            if int(vv)>int(mxs):
                mxs = vv
        ret = mxs
    #ddprint(f"foo n {n} k {k} ret {ret}")
    return ret

n,m = inm()
a = inl()
a.sort()
cs = [0,2,5,5,4,5,6,3,7,6]
mn = min([cs[x] for x in a])
for i in range(m-1,-1,-1):
    if cs[a[i]]==mn:
        mni = a[i]
        break
#k = (n+mn-1)//mn
#k = (n)//mn
#ddprint(f"mn {mn} mni {mni}")
#ddprint(a)
print(foo(n,0))


### FIXED CODE ###

from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

DEPMAX = 5

def foo(n,dep):
    if dep>DEPMAX or n<0:
        ret = "-1"
    elif n==0:
        ret = ""
    elif n%mn==0:
        ret = str(mni)*(n//mn)
    else:
        mxs = "-1"
        for x in a:
            v = foo(n-cs[x],dep+1)
            if v=="-1":
                continue
            vv = v+str(x)
            if int(vv)>int(mxs):
                mxs = vv
            vv = str(x)+v
            if int(vv)>int(mxs):
                mxs = vv
        ret = mxs
    #ddprint(f"foo n {n} k {k} ret {ret}")
    return ret

n,m = inm()
a = inl()
a.sort()
cs = [0,2,5,5,4,5,6,3,7,6]
mn = min([cs[x] for x in a])
for i in range(m-1,-1,-1):
    if cs[a[i]]==mn:
        mni = a[i]
        break
#k = (n+mn-1)//mn
#k = (n)//mn
#ddprint(f"mn {mn} mni {mni}")
#ddprint(a)
print(foo(n,0))
### BUGGY CODE ###

import bisect
 
N, M = map(int, input().split(" "))
As = [0]+list(map(int, input().split(" ")))
As.sort()
cnt = 0
cnt2 = 1
for j in range(M):
  i = As[-1-cnt]  
  i = i//(2**cnt2)
  if j == M-1 or i < As[-1-cnt-1]:
    cnt += 1
    cnt2 = 1
    bisect.insort_left(As,i)
  else:
    cnt2 += 1
 
print(sum(As[:-cnt]))

### FIXED CODE ###

import heapq
 
N, M = map(int, input().split(" "))
As = [-i for i in map(int, input().split(" "))]
As.sort()
heapq.heapify(As)

for _ in range(M):
  i = - heapq.heappop(As)
  i = i >> 1
  heapq.heappush(As,-i)

print(-sum(As))
### BUGGY CODE ###

N = int(input())
S = [input() for i in range(N)]
r = N*(N-1)//2
ans = 0
for i in range(N):
    g = 0
    for j in range(N):
        for k in range(j+1, N):
            if S[j][(k+i)%N] == S[k][(j+i)%N]:
                g += 1
    if g == r:
        ans += 1
    for j in range(N-1):
        for k in range(N-1):
            if S[(1+k+j)%N][(j+i)%N] == S[j][(j+i+k+1)%N]:
                g += 1
            if S[(j+k)%N][(j+i)%N] == S[j][(j+i+k)%N]:
                g -= 1
        if g == r:
            ans += 1
print(ans)


### FIXED CODE ###

N = int(input())
S = [input() for i in range(N)]
r = N*(N-1)//2
ans = 0
for i in range(N):
    g = 0
    for j in range(N):
        ji = (j+i) % N
        for k in range(j+1, N):
            if S[j][k+i-N] == S[k][ji]:
                g += 1
    if g == r:
        ans += 1
    for j in range(N-1):
        ji = (j+i) % N
        for k in range(N-1):
            if S[1+k+j-N][ji] == S[j][ji+k+1-N]:
                g += 1
            if S[j+k-N][ji] == S[j][ji+k-N]:
                g -= 1
        if g == r:
            ans += 1
print(ans)
### BUGGY CODE ###

R, G, B ,N = map(int, input().split())

cnt = 0
for r in range(N//R + 1):
  for g in range(N//G + 1):
    if (N - (r*R + g*G)) % B == 0 and  (N - (r*R + g*G)) >= 0:
      cnt += 1
print(cnt)

### FIXED CODE ###

R, G, B ,N = map(int, input().split())

if R==1 and G==1 and B==1:
  print(int((N+2)*(N+1)*(1/2)))
else:
  RGB = [R, G, B]
  RGB.sort(reverse=True)

  R = RGB[0]
  G = RGB[1]
  B = RGB[2]

  cnt = 0
  NR = N//R
  NG = N//G
  for r in range(NR + 1):
    for g in range(NG + 1):
      NrRgG = N - (r*R + g*G)
      if NrRgG < 0:
        break
      elif NrRgG >= 0:
        if NrRgG % B == 0:
          cnt += 1
  print(cnt)
### BUGGY CODE ###

import bisect

n = int(input())
al = sorted(list(map(int, input().split())))
bl = sorted(list(map(int, input().split())))
cl = sorted(list(map(int, input().split())))

a_len = len(al)
b_len = len(bl)
c_len = len(cl)

ans = 0
for a in al:
    b_index = bisect.bisect_right(bl, a)
    if b_index >= b_len:
        break
    tmp_bl = bl[b_index:]
    for b in tmp_bl:
        c_index = bisect.bisect_right(cl, b)
        if c_index >= c_len:
            break
        ans += c_len - c_index
        # print(f'a:{a}, b_index:{b_index}, c_index:{c_index}, ans:{ans}')

print(ans)


### FIXED CODE ###

import bisect

n = int(input())
al = sorted(list(map(int, input().split())))
bl = sorted(list(map(int, input().split())))
cl = sorted(list(map(int, input().split())))
ans = 0

for b in bl:
    i = bisect.bisect_left(al, b)
    j = bisect.bisect_right(cl, b)
    ans += i*(n-j)

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

import logging
import sys

logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
h = logging.FileHandler("logtest.log")
logger.addHandler(h)

input = sys.stdin.readline

N, Q = map(int, input().split())
logger.info("N: {}, Q: {}".format(N, Q))

s = input()
logger.info("s: {}".format(s))

Query = [input().split() for i in range(Q)]

left, right = 0, N - 1

# 二分探索: boundaryを求める
for t, d in reversed(Query):
    logger.info("t: {}, d: {}".format(t, d))
    logger.info("[before] left: {}, right: {}".format(left, right))
    if d == "L":
        if t == s[left]:
            left += 1
        if right < N - 1 and t == s[right + 1]:
            right = min(right + 1, N - 1)
    else:
        if left > 0 and t == s[left - 1]:
            left = max(left - 1, 0)
        if t == s[right]:
            right -= 1
    logger.info("[after] left: {}, right: {}\n".format(left, right))
print(max(right - left + 1, 0))


### FIXED CODE ###

# N, Q = map(int, input().split())
import sys

input = sys.stdin.readline

N, Q = tuple(map(int, input().split()))
s = input()

Query = [input().split() for i in range(Q)]

left, right = 0, N - 1

for t, d in reversed(Query):
    if d == "L":
        if t == s[left]:
            left += 1
        if right < N - 1 and t == s[right + 1]:
            right = min(right + 1, N - 1)
    else:
        if left > 0 and t == s[left - 1]:
            left = max(left - 1, 0)
        if t == s[right]:
            right -= 1
print(max(right - left + 1, 0))
### BUGGY CODE ###

while True:
    N = input()
    if N == "0000":
        break
    ans = 0
    if int(N) % 1111 == 0:
        print("NA")
        continue
    while int(N) != 6174:
        N = list(N)
        S = int(''.join(sorted(N)))
        L = int(''.join(sorted(N)[::-1]))
        ans += 1
        N = str(L-S)
    print(ans)

### FIXED CODE ###

while True:
    N = input()
    if N == "0000":
        break
    ans = 0
    if int(N) % 1111 == 0:
        print("NA")
        continue
    while N != '6174':
        N = list(N)
        S = int(''.join(sorted(N)))
        L = int(''.join(sorted(N)[::-1]))
        ans += 1
        N = str(L-S).zfill(4)
    print(ans)
### BUGGY CODE ###

N = int(input())
S = input()
r = S.count("R")
g = S.count("G")
b = S.count("B")

ret = r * g * b
for i in range(N - 2):
    for j in range(1, N):
        if i + j + j >= N:
            break
        a = S[i]
        b = S[i + j]
        c = S[i + j + j]
        if a != b and b != c and c != a:
            ret -= 1
print(ret)

### FIXED CODE ###

N = int(input())
S = input()
r = 0
g = 0
b = 0
for s in S:
    if s == "R":
        r += 1
    elif s == "G":
        g += 1
    else:
        b += 1

ret = r * g * b

for i in range(N):
    for d in range(N):
        j = i + d
        k = j + d
        if k >= N:
            break
        if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
            ret -= 1

print(ret)
### BUGGY CODE ###

n = int(input())
s = list(int(input()) for _ in range(n))
i = 0
s2 = []
while i < n:
    s2 = s.copy()
    s2.pop(i)
    print(max(s2))
    i += 1


### FIXED CODE ###

n = int(input())
s = list(int(input()) for _ in range(n))
i = 0
sort_s = sorted(s)

for i in s:
    if i == sort_s[-1]:
        print(sort_s[-2])
    else:
        print(sort_s[-1])
### BUGGY CODE ###

N=int(input())

ans=[0]*N

for i in range(1,N):
    if i**2 >=N:
        break
    for j in range(1,N):
            if i**2+j**2+i*j>=N:
                break
            for k in range(1,N):
                    if i**2+j**2+k**2+i*j+j*k+k*i <=N:
                        ans[i**2+j**2+k**2+i*j+j*k+k*i-1] +=1

for i in range(N):
    print(ans[i])

### FIXED CODE ###

N=int(input())

ans=[0]*N

for i in range(1,int(N**0.5)):
    if i**2 >=N:
        break
    for j in range(1,int(N**0.5)):
            if i**2+j**2+i*j>=N:
                break
            for k in range(1,int(N**0.5)):
                    if i**2+j**2+k**2+i*j+j*k+k*i <=N:
                        ans[i**2+j**2+k**2+i*j+j*k+k*i-1] +=1

for i in range(N):
    print(ans[i])
### BUGGY CODE ###

from sys import stdin

n = int(stdin.readline().rstrip())
ans = 0
for i in range(n):
    ans += i
print(ans)

### FIXED CODE ###

from sys import stdin

n = int(stdin.readline().rstrip())
ans = 0
ans = (n-1) * (n) // 2

print(ans)