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

import math

def make_divisors(n):
    d = 0
    i = 1
    d2 = True
    m = int(math.sqrt(n))
    for i in reversed(range(1, m + 1)):
        if n % i != 0:
            continue
        if i * i == n:
            d += 1
        else:
            d += 2
    return d


def f(n):
    count = 0
    for i in range(1, n):
        count += make_divisors(n - i)
    return count


def main():
    print(f(int(input())))


if __name__ == '__main__':
    main()


### FIXED CODE ###

import math


def f2(n):
    d = 0
    c = 0
    for i in range(1, n):
        e = 0
        if i * i == n:
            e -= 1
        elif n % i == 0:
            e -= 1
        e += n // i
        d += e

    return d

def main():
    print(f2(int(input())))


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

from collections import Counter 
n = int(input())
a = sorted(list(map(int, input().split())))
s = sorted(set(a))
c = Counter(a)
t = [0] * (10**6 + 1)
for i in a:
    for j in range(i, 10**6+1, i):
        t[j] += 1

ans = sum(1 for i in a if t[i] == 1 and c[i] == 1)
print(ans)



### FIXED CODE ###

from collections import Counter 
n = int(input())
a = list(map(int, input().split()))
s = set(a)
c = Counter(a)
t = [0] * (10**6 + 1)
for i in s:
    for j in range(i, 10**6+1, i):
        t[j] += 1

ans = len([1 for i in s if t[i] == 1 and c[i] == 1])
print(ans)
### BUGGY CODE ###

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

limit = 10 ** 18
res = A[0]

for i in range(1, N):
    res *= A[i]
    
if res > limit:
    print(-1)
else:
    print(res)


### FIXED CODE ###

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

limit = 10 ** 18
res = A[0]

if 0 in A:
    print(0)
    exit(0)
else:
    for i in range(1, N):
        res *= A[i]
        if res > limit:
            print(-1)
            exit(0)

print(res)
### BUGGY CODE ###

N = int(input())
array = list(map(int, input().split()))
ans = 0

for x in reversed(range(1,len(array))):
    m = max(array)

    if m > array[x]:
        ans += m - array[x]
    array.pop(-1)

print(ans)


### FIXED CODE ###

N = int(input())
array = list(map(int, input().split()))
ans = 0
next = 1
a = True
while (a):
    a = False
    b = False
    for i in range(next,len(array)):
        if array[i] < array[i-1]:
            ans += array[i-1] - array[i]
            array[i] = array[i - 1]
            a = True
            if b == False:
                b= True
                next = i

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

def solve(n, w, WV):
    dp = [[0] * (w + 1) for _ in range(n)]
    for w_limit in range(WV[0][0], w + 1):
        dp[0][w_limit] = WV[0][1]
    for i in range(1, n):
        for w_limit in range(1, w + 1):
            dw, dv = WV[i]
            if dw > w_limit:
                dp[i][w_limit] = dp[i - 1][w_limit]
            else:
                dp[i][w_limit] = max(dp[i - 1][w_limit], dp[i - 1][w_limit - dw] + dv)
    return dp[n - 1][w]

_n, _w = map(int, input().split())
_WV = [list(map(int, input().split())) for _ in range(_n)]
print(solve(_n, _w, _WV))


### FIXED CODE ###

def solve(n, w, WV):
    dp = [[0] * (w + 1) for _ in range(n)]
    for w_limit in range(WV[0][0], w + 1):
        dp[0][w_limit] = WV[0][1]
    for i in range(1, n):
        for w_limit in range(1, w + 1):
            dw, dv = WV[i]
            if dw > w_limit:
                dp[i][w_limit] = dp[i - 1][w_limit]
            else:
                dp[i][w_limit] = max(dp[i - 1][w_limit], dp[i - 1][w_limit - dw] + dv)
    return dp[n - 1][w]

_n, _w = map(int, input().split())
_WV = [list(map(int, input().split())) for _ in range(_n)]
print(solve(_n, _w, _WV))
### BUGGY CODE ###

h, n = map(int, input().split())
a_list = []
b_list = []

for _ in range(n):
    a, b = map(int, input().split())
    a_list.append(a)
    b_list.append(b)

max_a = max(a_list)    
dp = [float('inf')] * (h + max_a + 1)

dp[0] = 0
cost = float('inf')
for i in range(h):
    for j in range(n):
        dp[i + a_list[j]] = min(dp[i] + b_list[j], dp[i + a_list[j]])
        if i + a_list[j] >= h:
            cost = min(cost, dp[i + a_list[j]])
print(cost)

### FIXED CODE ###

h, n = map(int, input().split())
a_list = []
b_list = []

for _ in range(n):
    a, b = map(int, input().split())
    a_list.append(a)
    b_list.append(b)

max_a = max(a_list)    
dp = [float('inf')] * (h + max_a + 1)

dp[0] = 0
for i in range(h):
    for j in range(n):
        dp[i + a_list[j]] = min(dp[i] + b_list[j], dp[i + a_list[j]])
print(min(dp[h:]))
### BUGGY CODE ###

a,b,k = map(int,input().split())
for i in range(k):
    if a>0:
        a=a-1
    elif b>0:
        b=b-1
print(a,b)


### FIXED CODE ###

a,b,k = map(int,input().split())
if k<a:
    print(a-k,b)
elif a+b-k>0:
    print(0,a+b-k)
else:
    print(0,0)
### BUGGY CODE ###

N,M=map(int,input().split())
path=[[False]*N for i in range(N)]
for i in range(M):
  x,y=map(int,input().split())
  path[x-1][y-1]=True
  path[y-1][x-1]=True

minm=[float('inf')]*N
result=[0]*N
flag=[False]*N
minm[0]=0

while True:
  v=-1
  for i in range(N):
    if (not flag[i]) and (v==-1):
      v=i
    elif (not flag[i]) and minm[i]<minm[v]:
      v=i
  if v==-1:
    break
  flag[v]=True
    
  for j in range(N):
    if path[v][j]==True and minm[j]>minm[v]+1:
      minm[j]=minm[v]+1
      result[j]=v+1
      

print('Yes')
for i in range(N-1):
  print(result[i+1])

### FIXED CODE ###

from collections import deque
N,M=map(int,input().split())
to=[[] for _ in range(N)]
for _ in range(M):
  a,b=map(int,input().split())
  to[a-1].append(b-1)
  to[b-1].append(a-1)

q=deque([0])
r=[None]*N
r[0]=0
while q:
  x=q.popleft()
  for i in to[x]:
    if r[i] is None:
      q.append(i)
      r[i]=x+1
      
print('Yes')
for i in range(N):
  if r[i]!=0:
    print(r[i])
### BUGGY CODE ###

# import numpy as np
# import math as np
import copy
import sys
sys.setrecursionlimit(10000000)

f_inf = float("inf")

N, M, P = map(int, input().split())
ABC_d = {}
for m in range(M):
    A, B, C = map(int, input().split())
    if A in ABC_d:
        ABC_d[A].append([B, C - P])
    else:
        ABC_d[A] = [[B, C - P]]

cost = [-f_inf] * N
# cost = np.empty(N, dtype = int) - f_inf
cost[0] = 0

def solve(pos, already):
    global cost
    global already2

    if not(pos in ABC_d): return

    for B, C in ABC_d[pos]:
        if already[B - 1] == True:
            if cost[B - 1] == f_inf:
                pass
            elif cost[pos-1] == f_inf or cost[B - 1] < cost[pos - 1] + C:
                cost[B-1] = f_inf
                solve(B, already)
        elif cost[B - 1] < cost[pos - 1] + C:
            cost[B - 1] = cost[pos - 1] + C
            already2 = already[:]
            already2[B - 1] = True
            solve(B, already2)

# def solve(pos, cnt):
#     global cost

#     if not(pos in ABC_d): return

#     for B, C in ABC_d[pos]:
#         if already[B - 1] == True:
#             if cost[B - 1] == f_inf:
#                 pass
#             elif cost[pos-1] == f_inf or cost[B - 1] < cost[pos - 1] + C:
#                 cost[B-1] = f_inf
#                 solve(B)
#         elif cost[B - 1] < cost[pos - 1] + C:
#             cost[B - 1] = cost[pos - 1] + C
#             solve(B)


# already = np.zeros(N, dtype = bool)
already = [False] * N
already[0] = True
solve(1, already)

if (cost[-1] == f_inf):
    print (-1)
else:
    print (max(0, int(cost[-1])))


### FIXED CODE ###

import sys
sys.setrecursionlimit(10000000)

f_inf = sys.maxsize

N, M, P = map(int, input().split())
ABC_d = {}
for m in range(M):
    A, B, C = map(int, input().split())
    if A in ABC_d:
        ABC_d[A].append([B, C - P])
    else:
        ABC_d[A] = [[B, C - P]]

cost = [-f_inf] * N
cost[0] = 0

def solve(pos, cnt):
    global cost

    if not(pos in ABC_d): return
    if cnt > N: cost[pos-1] = f_inf;

    for B, C in ABC_d[pos]:
        if cost[B - 1] == f_inf or cost[B - 1] >= cost[pos - 1] + C:
            pass
        elif cost[pos-1] == f_inf:
            cost[B-1] = f_inf
            solve(B, cnt + 1)
        elif cost[B - 1] < cost[pos - 1] + C:
            cost[B - 1] = cost[pos - 1] + C
            solve(B, cnt + 1)

solve(1, 1)

if (cost[-1] == sys.maxsize):
    print (-1)
else:
    print (max(0, int(cost[-1])))
### BUGGY CODE ###

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

def eval(N,S):
    total=0
    for i in range(1,N):
        if S[i]==S[i-1]:total+=1
    return total


for k in range(K):
    if S==['R']*N or S==['L']*N:break
    j=[]
    for i in range(1, N):
        if S[i-1]!=S[i]:
            j.append(i)
            if len(j)==2:break
    if len(j)==1:j.append(N)
    if S[j[0]]=='R':
        S[j[0]:j[1]]=['L']*(j[1]-j[0])
    else:S[j[0]:j[1]]=['R']*(j[1]-j[0])
print(eval(N,S))
  

### FIXED CODE ###

import sys
from collections import deque

input = sys.stdin.readline

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

sq = deque(S)
lst=[]
j=0

for i in range(K):
    j=0
    if not sq:break
    sq_1st = sq.popleft()
    sq_2nd = sq_1st
    lst.append(sq_1st)

    while sq:
        sq_3rd = sq.popleft()
        if sq_2nd!=sq_3rd:
            j+=1
            sq_2nd=sq_3rd
            if j==2:
                sq.appendleft(sq_3rd)
                break
        lst.append(sq_1st)

lst+=list(sq)             

def eval(N,S):
    total=0
    for i in range(1,N):
        if S[i]==S[i-1]:total+=1
    return total
  
print(eval(N,lst))
### BUGGY CODE ###

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

if sum(A) < K:
    K = sum(A)

A.sort()
F.sort(reverse = True)
G = [A[i]*F[i] for i in range(N)]

for i in range(K):
    g = G.index(max(G))
    A[g] -= 1
    G[g] = A[g] * F[g]

print(max(G))

### FIXED CODE ###

import numpy as np
N, K = map(int, input().split())
A = np.array(list(map(int, input().split())))
F = np.array(list(map(int, input().split())))

if sum(A) < K:
    K = sum(A)

A.sort()
F.sort()
F = F[::-1]

left = 0
right = 10 ** 12
while left < right:
    mid = (left + right) // 2
    sum = 0
    G = A - (mid // F)
#    for i in range(N):
#        sum += max(0, G[i])
    if G[G>0].sum() <= K:
        right = mid
    else:
        left = mid + 1

print(right)
### BUGGY CODE ###

#!/usr/bin/env python3 ## -*- python -*-

def main():
    s = list(input())
    q = int(input())
    for i in range(q):
        d = input()
        if d[0] == "1":
            s.reverse()
        else: # 2
            dd = d.split()
            f = int(dd[1])
            c = dd[2]
            if f == 1:
                s.insert(0, c)
            else: # f == 2
                s.append(c)

    print(''.join(s))

main()

### FIXED CODE ###

#!/usr/bin/env python3 ## -*- python -*-
from collections import deque

def main():
    s = deque()
    s.extend(input())
    q = int(input())
    head = "l"
    for i in range(q):
        d = input()
        if d[0] == "1":
            if head == "l":
                head = "r"
            else:
                head = "l"
        else: # 2
            dd = d.split()
            f = int(dd[1])
            c = dd[2]
            if f == 1:
                if head == "l":
                    s.appendleft(c)
                else:
                    s.append(c)
            else: # f == 2
                if head == "l":
                    s.append(c)
                else:
                    s.appendleft(c)

    if head == "r":
        s.reverse()
    ans = ''.join(s)
    print(ans)
main()
### BUGGY CODE ###

def pri(t):
    i=2
    while i**2<=t:
        if t%i==0:
            return 0
        i=i+1
    return 1

l=[]
for i in range(2,50100):
    if pri(i):
        l.append(i)
s=5143
while 1:
    n=int(raw_input())
    ans=set([])
    if n==0:
        break
    for i in range(s):
        if l[i]>n:
            break
        for j in range(i,s):
            if l[i]+l[j]==n:
                ans.add((min(l[i],l[j]),max(l[i],l[j])))
            elif l[i]+l[j]>n:
                break
    print len(ans)

### FIXED CODE ###

def pri(t):
    i=2
    while i**2<=t:
        if t%i==0:
            return 0
        i=i+1
    return 1

l=[]
for i in range(2,50000):
    if pri(i):
        l.append(i)
s=5133
ans={}
for i in range(5132):
    for j in range(i,5133):
        a,b=l[i],l[j]
        if a+b>50000:
            break
        if ans.has_key(a+b):
            ans[a+b]+=1
        else:
            ans[a+b]=1
while 1:
    n=int(raw_input())
    if n==0:
        break
    print ans[n] if ans.has_key(n) else 0
### BUGGY CODE ###

import math
N = int(input())
A = list(map(int, input().split()))
#A = [i*(10**3) for i in range(N)]
#A = [i for i in range(N)]

#ans = abs(A[0]-sum(A[1:]))
#for i in range(2, math.ceil(N/2)):
        #ans = min(ans, abs(sum(A[:i])-sum(A[i:])))

ans = min([abs(sum(A[:i])-sum(A[i:])) for i in range(1, N)])

print(ans)
        

### FIXED CODE ###

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

sum_a = sum(A)
x = 0
ans = 1000000000000000

for i in range(N-1):
        x += A[i]
        ans = min(ans, abs(2*x-sum_a))

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

n, q = [int(i) for i in input().split()]
s = input()
l = [0] * q
r = [0] * q
ans = ""
for i in range(q):
  l[i], r[i] = [int(j) for j in input().split()]
  ans = ans+str(s[l[i]-1:r[i]].count("AC"))+"\n"
print(ans)
  
  

### FIXED CODE ###

n, q = [int(i) for i in input().split()]
s = input()
ans = ""
table = [0] * n
cnt = 0
for i in range(n-1):
  if s[i:i+2] == "AC":
    cnt += 1
  table[i+1] = cnt
for i in range(q):
  l, r = [int(j) for j in input().split()]
  print(table[r-1] - table[l-1])
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
ans = 1
for i in range(n):
    ans*=a[i]
if ans>10**18:
    ans = -1
print(ans)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
ans = 1
if 0 in a:
    ans = 0
else:
    for i in range(n):
        ans*=a[i]
        if ans>10**18:
            ans = -1
            break
print(ans)
### BUGGY CODE ###

from itertools import combinations

n, m = map(int, input().split())
xyz = [list(map(int, input().split())) for _ in range(n)]
ans = 0

for elem in combinations(xyz, m):
    x = abs(sum([e[0] for e in elem]))
    y = abs(sum([e[1] for e in elem]))
    z = abs(sum([e[2] for e in elem]))
    ans = max(ans, x + y + z)
print(ans)


### FIXED CODE ###

from itertools import product

n, m = map(int, input().split())
xyz = [list(map(int, input().split())) for _ in range(n)]
ans = 0

for e in product([1, -1], [1, -1], [1, -1]):
    xyz.sort(key=lambda v: (v[0] * e[0]) + (v[1] * e[1]) + (v[2] * e[2]))
    tmp = xyz[:m]
    ans = max(ans, abs(sum([e[0] for e in tmp])) + abs(sum([e[1] for e in tmp])) + abs(sum([e[2] for e in tmp])))
print(ans)
### BUGGY CODE ###

import heapq

def main():
    n, k, q = map(int, input().split())
    a = tuple(map(int, input().split()))

    m = float('inf')
    for y in set(a):
        x = find_x(a, y, k, q)
        if x is not None:
            m = min(m, x - y)
    
    print(m)

def find_x(a, y, k, q):
    gs = groups(a, y, k)
    xs = []

    for g in gs:
        xs.extend(heapq.nsmallest(len(g) - k + 1, g))
    
    xss = heapq.nsmallest(q, xs)
    if len(xss) < q:
        return None
    
    return xss[-1]

def groups(a, m, k):
    g = []

    pos = 0
    while pos < len(a):
        i = pos
        while i < len(a) and a[i] < m:
            i += 1
        
        j = i
        while j < len(a) and a[j] >= m:
            j += 1
        
        if j - i >= k:
            g.append(a[i:j])
        
        pos = j
    
    return g

main()

### FIXED CODE ###

import heapq

def main():
    n, k, q = map(int, input().split())
    a = tuple(map(int, input().split()))

    m = float('inf')
    for y in sorted(set(a)):
        x = find_x(a, y, k, q)
        if x is None:
            break
        m = min(m, x - y)
    
    print(m)

def find_x(a, y, k, q):
    gs = groups(a, y, k)
    xs = []

    for g in gs:
        xs.extend(heapq.nsmallest(len(g) - k + 1, g))
    
    xss = heapq.nsmallest(q, xs)
    if len(xss) < q:
        return None
    
    return xss[-1]

def groups(a, m, k):
    g = []

    pos = 0
    while pos < len(a):
        i = pos
        while i < len(a) and a[i] < m:
            i += 1
        
        j = i
        while j < len(a) and a[j] >= m:
            j += 1
        
        if j - i >= k:
            g.append(a[i:j])
        
        pos = j
    
    return g

main()
### BUGGY CODE ###

n=int(input())
p=list(map(int,input().split()))
x=0
for s in range(n):
  for t in range(s+1):
    if p[s]>p[s-t]:
      x+=1
      break
print(n-x)

### FIXED CODE ###

n=int(input())
p=list(map(int,input().split()))
x=0
s=p[0]
for i in range(n):
  if p[i]<=s:
    s=p[i]
    x+=1
print(x)
### BUGGY CODE ###

#!/usr/bin/env python3
import sys
from bisect import bisect_right


def solve(N: int, A: "List[int]", B: "List[int]", C: "List[int]"):
    ans  = 0
    A.sort()
    B.sort()
    C.sort()
    for i in range(N):
        bi = bisect_right(B, A[i])
        for j in range(bi, N):
            ci = bisect_right(C, B[j])
            ans += len(C[ci:])

    print(ans)

    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    B = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    C = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A, B, C)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
from bisect import bisect_right, bisect_left


def solve(N: int, A: "List[int]", B: "List[int]", C: "List[int]"):
    ans  = 0
    A.sort()
    B.sort()
    C.sort()
    for i in range(N):
        ai = bisect_left(A, B[i])
        ci = bisect_right(C, B[i])
        ans += (ai) * (N-ci)

    print(ans)

    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    B = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    C = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A, B, C)

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

N=int(input())
A=[[] for i in range(N-1)]
for i in range(N-1):
	A[i]=list(map(int,input().split()))
	A[i][2]%=2
A.sort()

ans=[0]*(N+1)
his=[False for i in range(N+1)]
his[0]=True
his[1]=True
idx=1


def search(A,his,ans,idx):
	if all(his):
		return
	for a in A:
		if idx in a[:2]:
			next_idx=a[(a[:2].index(idx)+1)%2]
			if his[next_idx]==False:
				ans[next_idx]=ans[idx]
				if a[2]!=0:
					ans[next_idx]+=1
					ans[next_idx]%=2
				his[next_idx]=True
				search(A,his,ans,next_idx)
				his[next_idx]=False

search(A,his,ans,idx)
print(*ans[1:],sep='\n')


### FIXED CODE ###

N=int(input())

graph=[[] for i in range(N+1)]

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


color=[-1]*(N+1)
color[1]=0

ne=[1]

while ne!=[]:
	t=ne.pop()
	for s,w in graph[t]:
		if color[s]==-1:
			ne.append(s)
			color[s]=color[t] if w%2==0 else (color[t]+1)%2

print(*color[1:],sep='\n')
### BUGGY CODE ###

#!/usr/bin/env python3
import math
import bisect
Q = int(input())
for _ in range(Q):
    A, B, C, D = map(int, input().split())
    K = math.ceil(max(A, B) / (min(A, B) + 1))
    xs = ((A - i + 1) * K < B - max(0, (i - 1) // K) for i in range(A + 1))
    p = bisect.bisect(list(xs), False)
    f = ''
    for i in range(C - 1, D):
        na = p - 1
        nb = max(0, (na - 1) // K)
        if i < nb * (K + 1):
            f += ('A', 'B')[i % (K + 1) == K]
        elif i < na + nb:
            f += 'A'
        else:
            j = A + B - i - 1
            nb = B - nb
            na = max(0, (nb - 1) // K)
            if j < na * (K + 1):
                f += ('B', 'A')[j % (K + 1) == K]
            else:
                f += 'B'
    print(f)


### FIXED CODE ###

#!/usr/bin/env python3
import math
Q = int(input())
for _ in range(Q):
    A, B, C, D = map(int, input().split())
    K = math.ceil(max(A, B) / (min(A, B) + 1))
    lo, hi = 0, A + 1
    while hi - lo > 1:
        mid = (lo + hi) // 2
        rA, rB = A - mid, B - max(0, (mid - 1) // K)
        if (rA + 1) * K < rB:
            hi = mid
        else:
            lo = mid

    f = ''
    for i in range(C - 1, D):
        na = lo
        nb = max(0, (na - 1) // K)
        if i < nb * (K + 1):
            f += ('A', 'B')[i % (K + 1) == K]
        elif i < na + nb:
            f += 'A'
        else:
            j = A + B - i - 1
            nb = B - nb
            na = max(0, (nb - 1) // K)
            if j < na * (K + 1):
                f += ('B', 'A')[j % (K + 1) == K]
            else:
                f += 'B'
    print(f)
### BUGGY CODE ###

from collections import Counter

num = int(input())
words = []

for i in range(num):
  words.append(Counter(input()))
  

def check_verify(word1,word2):
  return word1 == word2
  
  
count = 0

for i in range(len(words)):
  for j in range(i+1, len(words)):
    if check_verify(words[i],words[j]):
      count += 1
      
      
print(count)

### FIXED CODE ###

num = int(input())
s = ["".join(sorted(input())) for i in range(num)]

d = dict()

for st in s:
    if st in d:
        d[st]+=1
    else:
        d[st]=1

ans=0

for i in d:
    k=d[i]
    ans+=(k*(k-1))//2

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

S=input()
i=2019
x = 0
while i <= int(S):
    for j in range(1,len(S)-len(str(i))+2,1):
        if int(S[j-1:j-1+len(str(i))]) == i:
            x += 1
    i += 2019
print(x)


### FIXED CODE ###

S = input()[::-1]

S_mod = [0] * (len(S)+1)
S_mod[0] = int(S[0])

mod_count = [0] * 2019

d = 10

#for i in range(len(S)):
#    S_mod[i] = int(S[i:len(S)])%2019

for i in range(len(S)-1):
    S_mod[i + 1] = (S_mod[i] + int(S[i+1])*d)%2019
    d = d * 10 % 2019
    
#print(S_mod)

for i in range(len(S_mod)):
    mod_count[S_mod[i]] += 1

#print(mod_count)
    
count = 0
for i in range(2019):
    count += mod_count[i] * (mod_count[i] - 1) / 2
    
print(int(count))

#S = list(map(int, list(input())))
### BUGGY CODE ###

def solve(s):
    D = {"A":0,"B":1,"C":2}
    s = list(map(D.__getitem__, s))
    n = len(s)
    res = 0
    i = 0
    before = list(map(D.__getitem__, "ABC"))
    after = list(map(D.__getitem__, "BCA"))
    m = len(before)
    while i+m <= n:
        if s[i:i+m] == before:
            s[i:i+m] = after
            i = max(0, i-1)
            res += 1
        else:
            i += 1
    return res

s = input()
print(solve(s))

### FIXED CODE ###

def solve(s):
    n = len(s)
    res = 0
    i = 0
    num = 0
    while i < n-1:
        if s[i] == "A":
            num += 1
            i += 1
        elif s[i:i+2] == "BC":
            res += num
            i += 2
        else:
            num = 0
            i += 1
    return res

s = input()
print(solve(s))
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
max_s=-float("inf")
for i in range(n,2*n+1):
  x=a[:i]
  x.sort()
  xs=sum(x[len(x)-n:])
  y=a[i:]
  y.sort()
  ys=sum(y[:n])
  max_s=max(max_s,(xs-ys))
print(max_s)

### FIXED CODE ###

# 解説を確認、このような、最大（最小値）の出し入れが頻繁にあるデータでは、
# 「優先度付きキュー」というデータ構造を用いると容易になるようだ。
# 新規要素の Push & Pop が O(N log N) でできるとのこと。

from heapq import heapify,heappush,heappop

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

a1=a[0:n]
a_m=a[n:2*n]
a2=[ -x for x in a[2*n:3*n] ] # nega_list

a1_sums=[sum(a1)]
a2_sums=[sum(a2)]
heapify(a1)
heapify(a2)

# 左のシマに真ん中のシマを徐々に追加し、都度最小値を取り出す
for aa in a_m:
  heappush(a1,aa)
  p=heappop(a1)
  a1_sums.append(a1_sums[-1]+aa-p)

# 右のシマは都度最大値を取り出す
a_m.reverse()
for aa in a_m:
  heappush(a2,-aa)
  p=heappop(a2)
  a2_sums.append(a2_sums[-1]-aa-p)

max_val=-float("inf")
for i in range(0,n+1):
  max_val=max(max_val,a1_sums[i]+a2_sums[n-i])

print(max_val)