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

n=int(input())
a=[]
for i in range(n):
    d=input()
    a.append(sorted(d))
#print(a)

count=0
for i in range(n):
    temp=a.pop()
    if temp in a:
        count+=a.count(temp)
print(count)


### FIXED CODE ###

from collections import Counter
n=int(input())
d=Counter()
ans=0
for i in range(n):
    t=str("".join(sorted(input())))
    if t in d:
        ans+=d[t]
    d[t]+=1
print(ans)
### BUGGY CODE ###

import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    
N=int(input())
A=list(map(int,input().split()))
L=[]

for i in range(1,N+1):
	L.append(A.index(i)+1)

print(*L)

### FIXED CODE ###

import sys
import heapq
from collections import deque
if sys.platform =='ios':
    sys.stdin=open('input_file.txt')



N=int(input())
p=list(map(int,input().split()))	
pp=deque(p)
pp.appendleft(0)

q=sorted(range(len(pp)),key=lambda k:pp[k])
qq=deque(q)
qq.popleft()

print(*qq)
### BUGGY CODE ###

N = input()
N = int(N)

list_modified = []

for n in range(1, N + 1):
    s = input()
    list_s = sorted(s)
    new_s = ''.join(list_s)
    list_modified.append(new_s)
    
m = 0
    
for k in range(0, N):
    for l in range (k + 1, N):
        if list_modified[k] == list_modified[l]:
            m += 1
        else:
            continue

print(m)

### FIXED CODE ###

N = int(input())
list_anagram = [''.join(sorted(str(input()))) for i in range(N)]
 
list_anagram.sort()
ans = 0
 
x = 1
 
for i in range(1, N):
    if i != N - 1 and list_anagram[i] == list_anagram[i - 1]:
        x += 1
    elif i != N - 1 and list_anagram[i] != list_anagram[i - 1]:
        ans = ans + x * (x - 1) // 2
        x = 1
    elif i == N - 1 and list_anagram[i] == list_anagram[i - 1]:
        x += 1
        ans = ans + x * (x - 1) //2
    else:
        ans = ans + x * (x - 1) // 2
 
print(ans)
### BUGGY CODE ###

x,k,d = map(int, input().split())
x_min = abs(x)
for i in range(k):
    if x < 0:
        x += d
        if abs(x) < x_min:
            x_min = abs(x)
        else:#xが0以上
            if (k - i - 1) % 2 == 1:
                break
            else:
                x_min = d - x_min
                break
    else:
        x -= d
        if abs(x) < x_min:
            x_min = abs(x)
        else:#xが負
            if (k - i - 1) % 2 == 1:
                break
            else:
                x_min = d - x_min
                break
print(x_min)

### FIXED CODE ###

x,k,d = map(int, input().split())
if x < 0:
    x = -x
x_min = x
if x//d >= k:
    x_min -= k * d
else:
    x_min -= x//d * d
    k -= x//d
    if k % 2 == 1:
        x_min = abs(x_min - d)
print(x_min)
#xが更新されてる！！
### BUGGY CODE ###

def comb(k,r):
  """kCpを求める"""
  if k<0 or r<0 or r>k: return 0
  elif k==0 or r==0: return 1
  else:
    return (X[k]*Y[r]*Y[k-r])
  
def power_func(a,b,p):
  """a^b mod p を求める"""
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p
n = int(input())
a = list(map(int,input().split()))
p=10**9+7
ans=0
X=[1]  #階乗テーブル
for i in range(1,n+2):
  X+=[ (X[-1]*i) %p ]
Y=[1]*(n+2)  #階乗の逆元テーブル
Y[n+1]=power_func(X[n+1],p-2,p)
for i in range(n,-1,-1):
  Y[i]=Y[i+1]*(i+1) %p

#ダブりをみつける
check = [0]*n
for i in range(n+1):
  if check[a[i]-1]==1: dub = a[i]
  else: check[a[i]-1] = 1

indexes = [i for i, x in enumerate(a) if x == dub]
ind1, ind2  = indexes[0], indexes[1]

for i in range(1,n+2):
  ans = comb(n+1, i)
  if ind1 + n -ind2 +1 >= i:
    for j in range(i):
      ans -= comb(ind1, j)* comb(n-ind2,i-j-1)
  print(ans%p)

### FIXED CODE ###

def comb(k,r):
  """kCpを求める"""
  if k<0 or r<0 or r>k: return 0
  elif k==0 or r==0: return 1
  else:
    return (X[k]*Y[r]*Y[k-r])
  
def power_func(a,b,p):
  """a^b mod p を求める"""
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p
n = int(input())
a = list(map(int,input().split()))
p=10**9+7
ans=0
X=[1]  #階乗テーブル
for i in range(1,n+2):
  X+=[ (X[-1]*i) %p ]
Y=[1]*(n+2)  #階乗の逆元テーブル
Y[n+1]=power_func(X[n+1],p-2,p)
for i in range(n,-1,-1):
  Y[i]=Y[i+1]*(i+1) %p

#ダブりをみつける
check = [0]*n
for i in range(n+1):
  if check[a[i]-1]==1: dub = a[i]
  else: check[a[i]-1] = 1

indexes = [i for i, x in enumerate(a) if x == dub]
ind1, ind2  = indexes[0], indexes[1]

for i in range(1,n+2):
  ans = comb(n+1, i)
  if ind1 + n -ind2 +1 >= i:
    ans -= comb(ind1 + n -ind2, i-1)
  print(ans%p)
### BUGGY CODE ###

import math
import collections
import itertools
import sys
import bisect
from heapq import heappop,heappush
sys.setrecursionlimit(10**6)
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

n,m = MAP()
l,r = MAP()
res = set(range(l,r+1))
for i in range(m-1):
    l,r = MAP()
    res = res & set(range(l,r+1))

print(len(res))

### FIXED CODE ###

import math
import collections
import itertools
import sys
import bisect
from heapq import heappop,heappush
sys.setrecursionlimit(10**6)
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

n,m = MAP()
l,r = [], []
for i in range(m):
    a,b = MAP()
    l.append(a)
    r.append(b)

max_l = max(l)
min_r = min(r)
if min_r<max_l:
    print(0)
    exit()
print(min_r-max_l+1)
### BUGGY CODE ###

N=int(input())
a = list(map(int, input().split()))
import fractions
ansp = a[0]
ans = 1
for i in range(1, N):
  ansn = ansp * a[i] // fractions.gcd(ansp, a[i])
  ans = (ans * (ansn // ansp))%(10**9+7) + (ansn // a[i])%(10**9+7)
  ans = ans %(10**9+7)
  ansp = ansn
print(ans)

### FIXED CODE ###

from fractions import gcd
N=int(input())
a = list(map(int, input().split()))
lcm = 1
for i in a:
    lcm = lcm * i // gcd(lcm, i)
ans = 0
for i in a:
    ans += (lcm//i)#%(10**9+7)
print(ans%(10**9+7))
### BUGGY CODE ###

n, k = map(int,input().split())
h = list(map(int, input().split()))
c = [0 for i in range(n)]
c[0] = 0
c[1] = abs(h[1] - h[0])
# c[2] = c[0] + abs(h[2]-h[0])
# c[2] = c[1] + abs(h[2]-h[1])
# c[3] = c[1] + abs(h[3]-h[1])
# c[3] = c[2] + abs(h[3]-h[1])
for i in range(2, n):
    # c[i] = min(c[i-1]+abs(h[i]-h[i-1]), c[i-2]+abs(h[i]-h[i-2]))
    c[i] = min(c[i-j]+abs(h[i]-h[i-j]) for j in range(1,min(k,i)+1))
print(c[-1])

### FIXED CODE ###

n,k = map(int,input().split())
h = list(map(int,input().split()))
dp = [0]*n
dp[0] = 0
dp[1] = abs(h[1]-h[0])
# dp[2] = min(abs(h[2]-h[0]), dp[1]+abs(h[2]-h[1]))
# dp[3] = min((abs(h[3]-h[1])+dp[1]), abs(h[3]-h[2])+dp[2])
for i in range(2,n):
    ans = 10000000000000000000000000
    for j in range(1,k+1):
        if i-j >= 0:
            tmp = abs(h[i]-h[i-j])+dp[i-j]
            ans = min(ans,tmp)
    # dp[i] = min((abs(h[i]-h[i-2])+dp[i-2]), abs(h[i]-h[i-1])+dp[i-1])
    dp[i] = ans
print(dp[-1])
### BUGGY CODE ###

from collections import deque

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

parent = [[] for _ in range(N)]
child = [[] for _ in range(N)]

for _ in range(N - 1 + M):
    pr, ch = map(int, input().split())
    pr -= 1
    ch -= 1
    parent[ch].append(pr)
    child[pr].append(ch)

root = parent.index([])
depth = [-1] * N

st = deque([(root, root)])
while st:
    now, pr = st.pop()
    if depth[now] >= depth[pr] + 1:
        continue
    depth[now] = depth[pr] + 1
    for ch in child[now]:
        st.append((ch, now))

for i in range(N):
    if i == root:
        print(0)
    else:
        for pr in parent[i]:
            if depth[i] == depth[pr] + 1:
                print(pr + 1)
                break

### FIXED CODE ###

from functools import lru_cache
import sys
sys.setrecursionlimit(10 ** 7)

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

parent = [[] for _ in range(N)]
child = [[] for _ in range(N)]

for _ in range(N - 1 + M):
    pr, ch = map(int, input().split())
    pr -= 1
    ch -= 1
    parent[ch].append(pr)
    child[pr].append(ch)

root = parent.index([])
ans = [-1] * N

# 葉からの検索を行う
@lru_cache(maxsize=None)
def search(now):
    if now == root:
        ans[now] = 0
        return 0
    ret = -1
    for pr in parent[now]:
        depth = search(pr)
        if depth > ret:
            ans[now] = pr + 1
            ret = depth
    return ret + 1

for i in range(N):
    search(i)

print(*ans, sep='\n')
### BUGGY CODE ###

n, k = map(int, input().split())
S = input().replace("01", "0 1").replace("10", "1 0").split()
S = [""]*("0" in S[0])+S
*L, = map(len, S)
print(max([sum(L[i:i+2*k+1]) for i in range(0, len(L), 2)]))

### FIXED CODE ###

n, k = map(int, input().split())
S = input().replace("01", "0 1").replace("10", "1 0").split()
S = [""]*("0" in S[0])+S+[""]*("0" in S[-1])
*L, = map(len, S)
A = [sum(L[:2*k+1])]
for i in range(0, len(S)-2*k-1, 2):
    A += A[-1]-L[i]-L[i+1]+L[i+2*k+1]+L[i+2*k+2],
print(max(A))
### BUGGY CODE ###

import heapq

N, K = map(int, input().split())
A = sorted(list(map(int, input().split())))
F = sorted(list(map(int, input().split())), reverse=True)
T = [[- A[i] * F[i], A[i]] for i in range(N)]
heapq.heapify(T)

for _ in range(K):
    t, a = heapq.heappop(T)
    if t < 0:
        heapq.heappush(T, [(t // a) * (a - 1), a - 1])
    else:
        heapq.heappush(T, [0, 0])
        break

print(- heapq.heappop(T)[0])


### FIXED CODE ###

N, K = map(int, input().split())
A = sorted(list(map(int, input().split())))
F = sorted(list(map(int, input().split())), reverse=True)

minT, maxT = -1, max([A[i] * F[i] for i in range(N)])
while maxT - minT > 1:
    midT = minT + (maxT - minT) // 2
    if sum([max(A[i] - midT // F[i], 0) for i in range(N)]) > K:
        minT = midT
    else:
        maxT = midT

print(maxT)
### BUGGY CODE ###

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

ans = a[0]
for i in a[1:]:
    ans *= i

if ans > 10 ** 18:
    print("-1")
else:
    print(ans)

  

### FIXED CODE ###

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

if 0 in a:
    print(0)
    exit()

ans = 1
for i in a:
    ans *= i
    if ans > 10 ** 18:
        print("-1")
        exit()

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

def main():
    M = 1000000007
    n = int(input())
    a = list(map(int, input().split()))
    bit_size = len(bin(max(a))[2:])
    for i in range(n):
        a[i] = bin(a[i])[2:].zfill(bit_size)
        
    sum = 0
    for i in range(bit_size):
        one = 0
        zero = 0
        for j in range(n):
            if a[j][i] == '1':
                one += 1
            else: 
                zero += 1
        sum += (2**(bit_size - i - 1) % M) * (one % M) * (zero % M)
        sum %= M
    print(sum)

if __name__ == '__main__':
    main()



### FIXED CODE ###

M = 1000000007
def pow(k):
    ans = 1
    for _ in range(k):
        ans *= 2
        ans %= M
    return ans

def main():
    n = int(input())
    a = list(map(int, input().split()))
    bit_size = len(bin(max(a))[2:])
    for i in range(n):
        a[i] = bin(a[i])[2:].zfill(bit_size)

    sum = 0
    for i in range(bit_size):
        one = 0
        zero = 0
        for j in range(n):
            if a[j][i] == '1':
                one += 1
            else: 
                zero += 1
        sum += pow(bit_size - i - 1) * (one % M) * (zero % M)
        sum %= M
    print(sum)

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

import sys,math,collections,itertools
input = sys.stdin.readline

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

ori_num=0
turn_num=0
for i in range(N):
    if i>0:
        if S[i-1] =='L' and S[i] =='L':
            ori_num += 1
        if S[i-1] != S[i]:
            turn_num +=1
        
    if i<N-1:
        if S[i] =='R' and S[i+1] =='R':
            ori_num += 1
while K:
    if turn_num >1:
        turn_num -= 2
        K -= 1
        ori_num += 2
    elif turn_num ==1:
        ori_num +=1
        K=0
print(ori_num)


### FIXED CODE ###

import sys,math,collections,itertools
input = sys.stdin.readline

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

ori_num=0
turn_num=0
for i in range(N):
    if i>0:
        if S[i-1] =='L' and S[i] =='L':
            ori_num += 1
        if S[i-1] != S[i]:
            turn_num +=1
        
    if i<N-1:
        if S[i] =='R' and S[i+1] =='R':
            ori_num += 1

if turn_num >=2*K:
    ori_num += 2*K
else:
    num = turn_num//2
    num2 = turn_num%2
    ori_num += 2*num+num2
    
print(ori_num)
### BUGGY CODE ###

#!/usr/bin/env python3

def main():
    K = int(input())
    if K == 2 or K == 5:
        ans = -1
    else:
        if K % 7 == 0:
            L = 9 * K / 7
        else:
            L = 9 * K
        i = 1
        tmp = 10
        while True:
            tmp %= L
            if tmp == 1:
                ans = i
                break
            i += 1
            tmp *= 10

    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

#!/usr/bin/env python3

def main():
    K = int(input())
    if K % 7 == 0:
        L = 9 * K / 7
    else:
        L = 9 * K
    if L % 2 == 0 or L % 5 == 0:
        ans = -1
    else:
        i = 1
        tmp = 10
        while True:
            tmp %= L
            if tmp == 1:
                ans = i
                break
            i += 1
            tmp *= 10

    print(ans)


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

import bisect
import numpy as np
n, q = map(int, input().split())
STX = []
for i in range(n):
    s, t, x = map(int, input().split())
    STX.append((s, t, x))
STX.sort(key=lambda _: _[2])
S, T, X = [], [], []
for stx in STX:
    s, t, x = stx
    S.append(s)
    T.append(t)
    X.append(x)
D = [int(input()) for j in range(q)]

A = np.zeros(q, dtype=int) - 1
for i in range(n-1, -1, -1):
    l = bisect.bisect_left(D, S[i]-X[i])
    r = bisect.bisect_left(D, T[i]-X[i])
    A[l:r] = X[i]
for a in A:
    print(a)


### FIXED CODE ###

import bisect
n, q = map(int, input().split())
STX = []
for i in range(n):
    s, t, x = map(int, input().split())
    STX.append((s, t, x))
STX.sort(key=lambda _: _[2])
S, T, X = [], [], []
for stx in STX:
    s, t, x = stx
    S.append(s)
    T.append(t)
    X.append(x)
D = [int(input()) for j in range(q)]
A = [-1 for j in range(q)]
B = [-1 for j in range(q)]
for i in range(n):
    l = bisect.bisect_left(D, S[i]-X[i])
    r = bisect.bisect_left(D, T[i]-X[i])
    while l < r:
        if B[l] == -1:
            A[l] = X[i]
            B[l] = r
            l += 1
        else:
            l = B[l]
print(*A, sep='\n')
### BUGGY CODE ###

inf = 10**9
H, N = map(int, input().split())
AB = []
for n in range(N):
    a, b = map(int, input().split())
    AB.append((a, b))
AB.sort(reverse=True, key=lambda x: x[0])
dp = [inf] * (H + 10 ** 4)
dp[0] = 0
for a, b in AB:
    for h in range(H):
        if dp[h] != inf:
            tmp = dp[h] + b
            if tmp < dp[h + a]:
                dp[h + a] = tmp
print(min(dp[H:]))


### FIXED CODE ###

inf = 10 ** 9


def main():
    H, N = map(int, input().split())
    AB = []
    for n in range(N):
        a, b = map(int, input().split())
        AB.append((a, b))
    AB.sort(reverse=True, key=lambda x: x[0])
    dp = [inf] * (H + 10 ** 4)
    dp[0] = 0
    for a, b in AB:
        for h in range(H):
            # if dp[h] == inf:
            #     continue
            # else:
            #     dp[h+a] = min(dp[h]+b, dp[h+a])
            if dp[h] != inf:
                tmp = dp[h] + b
                if tmp < dp[h + a]:
                    dp[h + a] = tmp
    print(min(dp[H:]))


main()
### BUGGY CODE ###

import sys,collections,math;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

MOD = 998244353

nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)] % MOD
    
N,A,B,K = Is()
ans = 0
for x in range(N+1):
    if N >= (K-A*x)/B >= 0 and (K-A*x)/B == int((K-A*x)/B):
        ans += cmb(N,x)*cmb(N,(K-A*x)/B) % MOD
print(int(ans))


### FIXED CODE ###

import sys,collections,math;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
mod = 998244353 #出力の制限
N = 3*10**5
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

N,A,B,K = Is()
ans = 0
for x in range(N+1):
    y = (K-A*x)/B
    if 0 <= y <= N and y.is_integer():
        ans += cmb(N,x,mod)*cmb(N,int(y),mod) % mod
print(ans % mod)
### BUGGY CODE ###

N,M=map(int,input().split())
A=list(map(int,input().split()))
B=[0]*M
C=[0]*M
for i in range(M):
    B[i],C[i]=map(int,input().split())

for i in range(M):
    A.sort()
    for j in range(B[i]):
        if A[j] < C[i]:
            A[j]=C[i]
        elif j==N-1 or A[j] >= C[i]:
            break
print(sum(A))      




### FIXED CODE ###

#!/usr/bin/env python3
import bisect
import numpy as np

N, M = list(map(int, input().split()))
a_list = list(map(int, input().split()))
bc_list = []

for i in range(M):
    b, c = list(map(int, input().split()))
    bc_list.append((b, c))

bc_list = sorted(bc_list, key=lambda x: x[1], reverse=True)
a_list = sorted(a_list)

fix_list = []
s = 0
b, c = bc_list[0]
bc_index = 0
count_b = 0

for a in a_list:
    if count_b >= b:
        bc_index += 1
        if bc_index >= len(bc_list):
            s += a
            continue
        count_b = 0
        b, c = bc_list[bc_index]

    if a < c:
        s += c
    else:
        s += a
    count_b += 1

ans = s
print(ans)
### BUGGY CODE ###

import numpy as np

def draft(A, K, N):
    for _ in range(1, K+1):# 2 * 10**5
        tmp = np.zeros(N, dtype=np.int64)
        for i in range(N):# 2 * 10**5
            L = i - A[i]
            R = i + A[i] + 1
            if L < 0:
                tmp[0] += 1
            else:
                tmp[L] += 1
            if R < N:
                tmp[R] -= 1
        A = np.cumsum(tmp)
        if not np.count_nonzero(A < N) > 0:
            break
    for i in range(N):
        print(int(A[i]), end=" ")

def main():
    N, K = map(int, input().split())
    A = np.array(input().split(), dtype=np.int64)
    draft(A, K, N)

if __name__ == "__main__":
    main()

### FIXED CODE ###

def draft(A, K, N):
    for _ in range(1, K+1):# 2 * 10**5
        tmp = [0]*(N+1)
        for i in range(N):# 2 * 10**5
            L = max(0, i - A[i])
            R = min(N, i + A[i]+1)
            tmp[L] += 1
            tmp[R] -= 1
        f = True
        for i in range(N):
            tmp[i+1] += tmp[i]
            A[i] = tmp[i]
            if A[i] != N:
                f = False
        if f:
            break
    for i in range(N):
        print(A[i], end=" ")

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    draft(A, K, N)

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

MOD = 10 ** 9 + 7
N, M = map(int, input().split())
A = tuple(int(input()) for _ in range(M))
table = [0] * (N + 1)
table[0] = 1
for i in range(N + 1):
    now = table[i]
    if i + 1 < N + 1 and i + 1 not in A:
        table[i + 1] = (table[i + 1] + now) % MOD
    if i + 2 < N + 1 and i + 2 not in A:
        table[i + 2] = (table[i + 2] + now) % MOD
print(table[N])

### FIXED CODE ###

MOD = 10 ** 9 + 7
N, M = map(int, input().split())
table = [0] * (N + 1)
table[0] = 1
banned = [0] * (N + 1)
for _ in range(M):
    banned[int(input())] = 1
for i in range(N + 1):
    now = table[i]
    if i + 1 < N + 1 and not banned[i + 1]:
        table[i + 1] = (table[i + 1] + now) % MOD
    if i + 2 < N + 1 and not banned[i + 2]:
        table[i + 2] = (table[i + 2] + now) % MOD
print(table[N])
### BUGGY CODE ###

# coding: utf-8
# Your code here!
n = int(input())
s = list(map(int,input().split()))
ans = {}
a = []
for i in s:
    if not i in a:
        ans[i] = s.count(i)*(s.count(i)-1)//2
        a.append(i)
#print(ans)
answer = 0
for i in ans.values():
    answer += i
#print(answer)
for i in range(n):
    print(answer-ans[s[i]]+((ans[s[i]]*2//s.count(s[i]))*(s.count(s[i])-2)//2))   


### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
List={}
x=0
for i in range(n):
    if not a[i] in List:
        List[a[i]] = 1
    else:
        List[a[i]]+=1
    
sigma=0
 
for key,item in List.items():
    sigma += item*(item-1)//2
for i in range(n):
    print(sigma-List[a[i]]+1)
### BUGGY CODE ###

import bisect as bi
N,M=map(int,input().split())
A=list(map(int,input().split()))
L=[]
for i in range(M):
    l=list(map(int,input().split()))
    L.append(l)
L=sorted(L,reverse=True,key=lambda x: x[1])
A=sorted(A)
x=0
for i in range(M):
    if bi.bisect_left(A,L[i][1])==0:
        break
    if len(A)==0:
        break
    m=min(L[i][0],bi.bisect_left(A,L[i][1]))
    del A[0:m]
    x+=m*L[i][1]
print(x+sum(A))




### FIXED CODE ###

from operator import itemgetter
l = list(map(int, input().split()))
N = l[0]
M = l[1]
A = list(map(int, input().split()))
B = []
for i in range(M):
    b = list(map(int, input().split()))
    B.append(b)
A = sorted(A)
B = sorted(B, key=lambda x: x[1])
m = 0
s = 0
for i in range(M):
    i = M-1-i
    if B[i][0]+m <= N-1:

        if A[B[i][0]+m] <= B[i][1]:
            m = m+B[i][0]
            s += B[i][1]*B[i][0]
        else:
            if A[m] <= B[i][1]:
                for l in range(m, N):
                    if A[l] >= B[i][1]:
                        s += B[i][1]*(l-m)
                        m = l
                        break
            else:
                break
    else:
        if A[N-1] <= B[i][1]:
            s = s+B[i][1]*(N-m)
            m = N
            break
        else:
            if A[m] <= B[i][1]:
                for l in range(m, N):
                    if A[l] >= B[i][1]:
                        s += B[i][1]*(l-m)
                        m = l
                        break
            else:
                break
if m < N:
    for i in range(m, N):
        s += A[i]
print(s)
### BUGGY CODE ###

import numpy as np
N,K = map(int, input().split())
As = input().split()
for i in range(N):
  As[i] = int(As[i])
As = np.array(As)

As_uni = np.unique(As)
for i,a in enumerate(As_uni):
  As_uni[i] = (As==a).sum()
As_uni = np.sort(As_uni)

K2 = len(As_uni)

if K2 > K:
  ans = As_uni[:K2-K].sum()
else:
  ans = 0
  
print(int(ans))

### FIXED CODE ###

import numpy as np
import collections

N,K = map(int, input().split())
As = input().split()
for i in range(N):
  As[i] = int(As[i])
As = np.array(As)

As_c = collections.Counter(As)

ans = 0
counter = 0
for a in sorted(As_c.values()):
  if counter < len(As_c) - K:
    ans += a 
    counter += 1
  else:
    break
print(int(ans))
### BUGGY CODE ###

N=int(input())
S=input()
count=0
for k in range(3,N+1):
    for j in range(2,k):
        for i in range(1,j):
            if S[i-1]!=S[j-1] and S[j-1]!=S[k-1] and S[k-1]!=S[i-1] and j-i!=k-j:
                count+=1
print(count)


### FIXED CODE ###

N=int(input())
S=input()
count=0
nocount=0
Rcount=0
Gcount=0
Bcount=0
for k in range(N):
    if S[k]=="R":
        Rcount+=1
    if S[k]=="G":
        Gcount+=1
Bcount = N -Rcount-Gcount
count=Rcount*Gcount*Bcount
for k in range(3,N+1):
    if k%2==1:
        for i in range(1,k-1,2):
            if S[i-1]!=S[k-1]:
                j=(i+k)//2
                if S[i-1]!=S[j-1] and S[k-1]!=S[j-1]:
                    nocount+=1
    if k%2==0:
        for i in range(2,k-1,2):
            if S[i-1]!=S[k-1]:
                j=(i+k)//2
                if S[i-1]!=S[j-1] and S[k-1]!=S[j-1]:
                    nocount+=1
print(count-nocount)
### BUGGY CODE ###

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

ans = 2019 ** 2

for i in range(l, r + 1):
  for j in range(i + 1, r + 1):
    ans = min(ans, (i % 2019) * (j % 2019) % 2019)
    if ans == 0:
      break
    
print(ans)

### FIXED CODE ###

def main():
  l, r = map(int, input().split())
  LUT = [[(i*j)%2019 for i in range(2019)] for j in range(2019)]
  ans = 2018
  m = 2019
  for i in range(l, r + 1):
    for j in range(i + 1, r + 1):
      ans = min(ans, LUT[i % m][j % m])
      if ans == 0:
        return 0
  return ans

print(main())