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

import numpy as np
n=int(input())
l=np.array(list(map(int,input().split())))
r=np.arange(1,n)
ans=0
for i in range(n):
  ans+=np.count_nonzero(r[:n-i-1]-l[i+1:]==l[i])
print(ans)  

### FIXED CODE ###

n=int(input())
l=list(map(int,input().split()))
r=[0]*(n-1)
t=[0]*(n)
dr={}
dt={l[0]:[0]}
for i in range(1,n):
  x=i-l[i]
  y=i+l[i]
  if x in dr:
    dr[x].append(i)
  else:
    dr[x]=[i]
  if y in dt:
    dt[y].append(i)
  else:
    dt[y]=[i]
ans=0
for x in dr.keys():
  if x>0 and x in dt:
    y=dr[x]
    z=dt[x]
    ans+=len(z)*len(y)
print(ans)
### BUGGY CODE ###

def solve():
    N = int(input())
    a = list(map(int, input().split()))
    ans = 0
    for i in range(1,500000):
        check = a.count(i)
        check2 = a.count(i-1)
        check3 = a.count(i+1)
        if ans < check+check2+check3:
            ans = check+check2+check3

    print(ans)


if __name__ == '__main__':
    solve()


### FIXED CODE ###

def solve():
    N = int(input())
    a = list(map(int, input().split()))
    count = [0]*100000

    for i in a:
        count[i] += 1

    print(max(map(sum,zip(count,count[1:],count[2:]))))


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

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,m = LI()
    s = LI()
    t = LI()
    a = [[0] * m for _ in range(n)]
    u = [[0] * m for _ in range(n)]
    for i in range(n):
        b = s[i]
        c = a[i]
        d = u[i-1]
        for j in range(m):
            if b != t[j]:
                continue
            k = 1
            if i>0 and j>0:
                k += d[j-1]
            c[j] = k
        e = u[i] = c[:]
        for j in range(1,m):
            e[j] += e[j-1]
            e[j] %= mod
        if i > 0:
            for j in range(m):
                e[j] += d[j]
                e[j] %= mod

    r = sum(map(sum, a)) + 1
    r %= mod

    return r


print(main())





### FIXED CODE ###

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,m = LI()
    s = LI()
    t = LI()
    a = [[1 if i==j else 0 for j in t] for i in s]
    u = [0] * m
    for i in range(n):
        c = a[i]

        for j in range(1,m):
            if c[j] == 1:
                c[j] += u[j-1]

        e = c[:]
        for j in range(1,m):
            e[j] += e[j-1]
            e[j] %= mod

        if i > 0:
            for j in range(m):
                e[j] += u[j]
                e[j] %= mod
        u = e

    r = sum(map(lambda x: sum(x) % mod, a)) + 1

    return r % mod


print(main())
### BUGGY CODE ###

def d():
  from math import log2

  def get_ones(n):
    while n:
      k = n & -n
      yield int(log2(k))
      n ^= k

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

  num_ones = [0 for x in range(60)]
  for i in range(N):
    for j in get_ones(A[i]):
      num_ones[j] += 1
  
  ans = 0
  for i in range(N-1):
    for j in range(60):
      if A[i] % 2 == 0:
        ans = (ans + (1 << j) * num_ones[j]) % 1000000007
      else:
        num_ones[j] -= 1
        ans = (ans + (1 << j) * (N - i - 1 - num_ones[j])) % 1000000007
      A[i] //= 2
  print(ans)
        
d()

### FIXED CODE ###

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

ans = 0
for i in range(60):
  p = 1 << i
  num_one = len([1 for x in A if x & p])
  ans = ans + p * num_one * (N - num_one)
print(ans % 1000000007)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

H, N = map(int, input().split(" "))
dp = [float('inf') for i in range(H + 1)]
dp[0] = 0

for i in range(N):
    A, B = map(int, input().split(" "))
    for j in range(H + 1):
        if dp[j] != float('inf'):
            dp[min(j + A, H)] = min(dp[min(j + A, H)], dp[j] + B)
print(dp[H])


### FIXED CODE ###

import sys
input = sys.stdin.readline

H, N = map(int, input().split(" "))
dp = [1e10 for i in range(H + 1)]
dp[0] = 0

for i in range(N):
    A, B = map(int, input().split(" "))
    for j in range(H + 1):
        if dp[j] != 1e10:
            dp[min(j + A, H)] = min(dp[min(j + A, H)], dp[j] + B)
print(dp[H])
### BUGGY CODE ###

#!/usr/bin/env python3
import sys
try:
    from typing import List
except ImportError:
    pass


class BIT:
    def __init__(self, n: int):
        self.tr = [0] * (n + 1)

    def add(self, n: int, v: int):
        while n < len(self.tr):
            self.tr[n] += v
            n += n & -n

    def cumsum(self, n: int):
        ans = 0
        while n > 0:
            ans += self.tr[n]
            n -= n & -n
        return ans


def solve(N: int, a: "List[int]"):

    def f(m):
        s = [0] * (N + 1)
        for i, ai in enumerate(a):
            s[i + 1] = s[i] + (-1 if ai < m else 1)
        ms = min(s)
        b = BIT(max(s) - ms + 1)
        t = 0
        for si in s:
            t += b.cumsum(si - ms + 1)
            b.add(si - ms + 1, 1)
        return t >= -(-(N * (N + 1) // 2) // 2)

    lb = 0
    rb = max(a) + 1
    while lb + 1 < rb:
        m = (lb + rb) // 2
        if f(m):
            lb = m
        else:
            rb = m

    print(lb)


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]"
    solve(N, a)


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
try:
    from typing import List
except ImportError:
    pass


class BIT:
    def __init__(self, n: int):
        self.tr = [0] * (n + 1)

    def add(self, n: int, v: int):
        while n < len(self.tr):
            self.tr[n] += v
            n += n & -n

    def cumsum(self, n: int):
        ans = 0
        while n > 0:
            ans += self.tr[n]
            n -= n & -n
        return ans


def solve(N: int, a: "List[int]"):

    def f(m):
        s = [0] * (N + 1)
        for i, ai in enumerate(a):
            s[i + 1] = s[i] + (-1 if ai < m else 1)
        ms = min(s)
        b = BIT(max(s) - ms + 1)
        t = 0
        for si in s:
            t += b.cumsum(si - ms + 1)
            b.add(si - ms + 1, 1)
        return t >= -(-(N * (N + 1) // 2) // 2)

    lb = 0
    rb = max(a) + 1
    while lb + 1 < rb:
        m = (lb + rb) // 2
        if f(m):
            lb = m
        else:
            rb = m

    print(lb)


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]"
    solve(N, a)


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

def solve_panasonic2020_e():
    from itertools import islice, permutations, zip_longest

    abc = tuple(input() for _ in range(3))

    ret = sum(map(len, abc))
    for perm in permutations(abc):
        first, second, third = perm

        cands = [first + second]
        for i in range(len(first)):
            # first[i:]とsecondが一致するか見る
            # 一致なら候補に残す
            # すべてダメならfirst+secondだけ候補になる(重なりなし)
            cand = ''
            for fc, sc in zip_longest(islice(first, i, len(first)), second, fillvalue=''):
                if not fc or not sc:
                    cand += fc + sc
                elif fc == sc or sc == '?':
                    cand += fc
                elif fc == '?':
                    cand += sc
                else:
                    break
            else:
                cand = first[:i] + cand
                cands.append(cand)

        for cand in cands:
            for i in range(len(cand)):
                t = i
                for cc, tc in zip_longest(islice(cand, i, len(cand)), third, fillvalue=''):
                    t += 1
                    if not cc or not tc:
                        continue
                    if not (cc == tc or cc == '?' or tc == '?'):
                        break

                else:
                    ret = min(ret, t)

    print(ret)


if __name__ == '__main__':
    solve_panasonic2020_e()


### FIXED CODE ###

# 解説の写経

def solve_panasonic2020_e():
    def unmatched(c1: str, c2: str) -> bool:
        """c1,c2がマッチしない"""
        return not (c1 == '?' or c2 == '?' or c1 == c2)

    A = input()
    B = input()
    C = input()

    MX = max(map(len, [A, B, C]))

    # 相対位置ごとの文字列マッチングの可否を調べる
    # ab/ac/bc[index差]:=その相対位置でマッチしないときTrue
    # [-MX,MX]
    # + : 左文字より右文字が右にある, a->b
    # - : 右文字より左文字が右にある, b->a
    ab = [False] * (MX * 4 + 1)
    ac = [False] * (MX * 4 + 1)
    bc = [False] * (MX * 4 + 1)

    for i, a in enumerate(A):
        for j, b in enumerate(B):
            ab[i - j] |= unmatched(a, b)

    for i, a in enumerate(A):
        for j, c in enumerate(C):
            ac[i - j] |= unmatched(a, c)

    for i, b in enumerate(B):
        for j, c in enumerate(C):
            bc[i - j] |= unmatched(b, c)

    # Aに対するB,Cの相対位置MX**2で全探索
    ans = sum(map(len, [A, B, C]))
    for i in range(-MX * 2, MX * 2 + 1):  # ACBのようにAB間にMX分空くこともあって、幅2MX
        if ab[i]: continue
        for j in range(-MX * 2, MX * 2 + 1):  # ABCのようにAC間にMX分空くこともあって、幅2MX
            if ac[j]: continue
            if bc[j - i]: continue
            # 添え字で混乱するが
            # ab[i-j]で
            # 添え字i-jは(bの開始)-(aの開始)を意味したことから
            # (i-j>0でa->bの配置から)
            # 今回i,jは(aの開始)を基準にした(b,cの開始位置)で
            # bcの添え字は(cの開始)-(bの開始)なのでj-i

            # [L,R)
            L = min(0, i, j)
            R = max(len(A), i + len(B), j + len(C))
            ans = min(ans, R - L)

    print(ans)
    return


if __name__ == '__main__':
    solve_panasonic2020_e()

# N**3は通らない
# N**2の方針=2本の文字列の捜査
### BUGGY CODE ###

import sys
input = sys.stdin.readline
H, W, D = map(int, input().split())

A = []
for _ in range(H):
    a = list(map(int, input().split()))
    A.append(a)

Q = int(input())
LR = []
for _ in range(Q):
    l, r = map(int, input().split())
    LR.append((l, r))
    
# H*Wのマスをマスの数値をkeyにした辞書にする
A_dict = {}
for i, sub_a in enumerate(A):
    for j, a in enumerate(sub_a):
        A_dict[a] = (i+1, j+1)
#print(A_dict)

N = H*W+1
edges = []

for i in range(1, N):
    s = i
    g = i+D
    if g >= N:
        break
    cost = abs(A_dict[s][0]-A_dict[g][0])+abs(A_dict[s][1]-A_dict[g][1])
    edges.append((s,g,cost))

from collections import defaultdict
graph = defaultdict(lambda:{})
for x,y,z in edges:
    graph[x][y] = z
for i in range(N):
    graph[i][i] = 0 #自身のところに行くコストは０
    
from heapq import heappush, heappop    
def dijkstra(graph, start, N):
    A = [None] * (N+1)
    queue = [(0, start)]
    while queue:
        path_len, v = heappop(queue)
        if A[v] is None: # v is unvisited
            A[v] = path_len
            for w, edge_len in graph[v].items():
                if A[w] is None:
                    heappush(queue, (path_len + edge_len, w))

    # to give same result as original, assign zero distance to unreachable vertices             
    return [0 if x is None else x for x in A]

dist = {}
for i in range(1, D+1):
    dist[i] = dijkstra(graph, i, N)
#print(dist)
for l, r in LR:
    idx = r%D
    if idx == 0:
        idx = D
    print(dist[idx][r]-dist[idx][l])
        




### FIXED CODE ###

import sys
input = sys.stdin.readline
H, W, D = map(int, input().split())

A = []
for _ in range(H):
    a = list(map(int, input().split()))
    A.append(a)

Q = int(input())
LR = []
for _ in range(Q):
    l, r = map(int, input().split())
    LR.append((l, r))
# H*Wのマスをマスの数値をkeyにした辞書にする
A_dict = {}
for i, sub_a in enumerate(A):
    for j, a in enumerate(sub_a):
        A_dict[a] = (i+1, j+1)

# costの辞書化
from collections import defaultdict
cost_dict = defaultdict(lambda: {})
N = H*W+1
for i in range(1, N):
    s = i
    g = i+D
    if g >= N:
        break
    cost = abs(A_dict[s][0]-A_dict[g][0])+abs(A_dict[s][1]-A_dict[g][1])
    cost_dict[s][g] = cost
    

dist = defaultdict(lambda: {})
for i in range(1, D+1):
    dist[i][i] = 0
    s = i
    g = i+D
    while g < N:
        dist[i][g] = dist[i][s] + cost_dict[s][g]
        s = g
        g = s + D

    
#print(dist)
for l, r in LR:
    idx = r%D
    if idx == 0:
        idx = D
    print(dist[idx][r]-dist[idx][l])
### BUGGY CODE ###

import numpy as np
n,m = list(map(int,input().split()))
h = np.array(list(map(int,input().split())))
d = np.array([[0] * n for _ in range(n)])

for i in range(m):
  a,b = list(map(int,input().split()))
  a -= 1
  b -= 1
  d[a][b] = 1
  d[b][a] = 1 

mh = [1] * n
ans = 0

for i in range(n):
  t = d[i] * h
  if h[i] > max(t):
    ans += 1
  
print(ans)

### FIXED CODE ###


n,m = list(map(int,input().split()))
h = list(map(int,input().split()))
d = [1] * n
for i in range(m):
  a,b = list(map(int,input().split()))
  a -= 1
  b -= 1
  if h[a] > h[b]:
    d[b] = 0
  elif h[b] > h[a]:
    d[a] = 0
  else:
    d[a] = 0
    d[b] = 0

print(sum(d))
### BUGGY CODE ###

n,w=map(int,input().split())
W=[0]*n
V=[0]*n
for i in range(n):
  W[i],V[i]=map(int,input().split())
dp=[[0]*(w+1) for _ in range(n+1)]  
for i in range(1,n+1):
  for j in range(1,w+1):
    if j-W[i-1]>=0:
      dp[i][j]=max(dp[i-1][j],dp[i-1][j-W[i-1]]+V[i-1])
    else:
      dp[i][j]=dp[i-1][j]
print(dp[n][w])      


### FIXED CODE ###

n,w=map(int,input().split())
W=[0]*n
V=[0]*n
for i in range(n):
  W[i],V[i]=map(int,input().split())
dp=[[0]*(w+1) for _ in range(n+1)]  
for i in range(1,n+1):
  for j in range(1,w+1):
    if j-W[i-1]>=0:
      dp[i][j]=max(dp[i-1][j],dp[i-1][j-W[i-1]]+V[i-1])
    else:
      dp[i][j]=dp[i-1][j]
print(dp[n][w])
### BUGGY CODE ###

# AGC005A

x = input()
while 'ST' in x:
    x = x.replace('ST', '', 1)
print(len(x))


### FIXED CODE ###

x = input()
while 'ST' in x:
    x = x.replace('ST', '')
    n = len(x) // 2
    if ('T' not in x[:n]) and ('S' not in x[n:]):
        x = ''
        break
print(len(x))
### BUGGY CODE ###

# -*- coding: utf-8 -*-
# template: v1.3.1

import io
import sys
import math

### DEBUG ###
_DEB = 0  # 1:ON / 0:OFF

_INPUT = """\
RWRWRW
"""
_EXPECTED = """\
2

"""
if _DEB:
    sys.stdin = io.StringIO(_INPUT)
    print("!! Debug Mode !!")

def logd(str):
    if _DEB: print(f"[deb] {str}")


### INPUT ####
n = int(input())
c = input()
c=c.replace("R","0")
c=c.replace("W","1")
c=[int(x) for x in c]

### Solve ####
def solve():
    # Process
    ans=0
    id1=0
    for i in reversed(range(n)):
        id0=-1
        if c[i] == 0:
            id0=i
            for j in range(id1,id0):
                if c[j]==1:
                    id1=j
                    c[i]=1
                    c[j]=0
                    ans+=1
                    break
                
            if[i]==0:
                c[i]=1
                ans+=1

    # OUPUT
    ans = str(ans)
    print(ans)
    return ans

### MAIN ###
if __name__ == "__main__":
    ans = solve()

    # Checker
    if _DEB:
        if _EXPECTED.strip() == ans.strip(): print("\n!! Success !!")
        else: print(f"\n!! Failed... !!\nANSWER:   {ans}\nExpected: {_EXPECTED}")

### FIXED CODE ###

# -*- coding: utf-8 -*-
# template: v1.3.1

import io
import sys
import math

### DEBUG ###
_DEB = 0  # 1:ON / 0:OFF

_INPUT = """\
200000
"""+("R"*200000)
_EXPECTED = """\
2

"""
if _DEB:
    sys.stdin = io.StringIO(_INPUT)
    print("!! Debug Mode !!")

def logd(str):
    if _DEB: print(f"[deb] {str}")


### INPUT ####
n = int(input())
c = input()
c=c.replace("R","0")
c=c.replace("W","1")
c=[int(x) for x in c]

### Solve ####
def solve():
    # Process
    ans=0
    id1=0
    for i in reversed(range(n)):
        if id1 > i:
            break
        id0=-1
        if c[i] == 0:
            id0=i
            not_found=True
            for j in range(id1,id0):
                if c[j]==1:
                    id1=j
                    c[i]=1
                    c[j]=0
                    ans+=1
                    not_found=False
                    break
            if not_found:
                break
                
            if[i]==0:
                c[i]=1
                ans+=1
        

    # OUPUT
    ans = str(ans)
    print(ans)
    return ans

### MAIN ###
if __name__ == "__main__":
    ans = solve()

    # Checker
    if _DEB:
        if _EXPECTED.strip() == ans.strip(): print("\n!! Success !!")
        else: print(f"\n!! Failed... !!\nANSWER:   {ans}\nExpected: {_EXPECTED}")
### BUGGY CODE ###

N, K = map(int,input().split())
P = [int(x)-1 for x in input().split()]
C = [int(x) for x in input().split()]

def loop(s):
    value = 0
    done = set()
    while s not in done:
        done.add(s)
        s = P[s]
        value += C[s]
    return len(done), value

def f(s,K):
    ans = -10**18
    total = 0
    done = set()
    while s not in done:
        done.add(s)
        s = P[s]
        total += C[s]
        ans = max(ans,total)
        K -= 1

        if K==0:
            return ans

    lamb, value = loop(s)

    if K > 2*lamb:
        K -= lamb
        if value > 0:
            total += (K//lamb)*value
            ans = max(ans,total)
            K -= (K//lamb)*lamb
        K += lamb

    while K > 0:
        s = P[s]
        total += C[s]
        ans = max(ans,total)
        K -= 1
    return ans

print(max([f(s,K) for s in range(N)]))

### FIXED CODE ###

N, K = map(int,input().split())
P = [int(x)-1 for x in input().split()]
C = [int(x) for x in input().split()]

def loop(s):
    value = 0
    done = set()
    while s not in done:
        done.add(s)
        s = P[s]
        value += C[s]
    return len(done), value

def f(s,K):
    ans = -10**18
    total = 0
    done = set()
    while s not in done:
        done.add(s)
        s = P[s]
        total += C[s]
        ans = max(ans,total)
        K -= 1

        if K==0:
            return ans

    lamb, value = loop(s)

    if K > 2*lamb:
        if value > 0:
            K -= lamb
            total += (K//lamb)*value
            ans = max(ans,total)
            K -= (K//lamb)*lamb
            K += lamb
    if value <= 0:
        K = min(K,lamb+5)
        


    while K > 0:
        s = P[s]
        total += C[s]
        ans = max(ans,total)
        K -= 1
    return ans

print(max([f(s,K) for s in range(N)]))
### BUGGY CODE ###

from math import gcd, sqrt


def Calc_Divisors(num):
    divisors = []
    for i in range(1, int(sqrt(num)) + 1):
        if num % i == 0:
            if i != 1:
                divisors.append(i)
            if i != num // i:
                divisors.append(num//i)
    divisors.sort()
    return divisors


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

    s_tmp = A[0]
    p_flag = True
    p_dic = [0] * (10**6+1)
    for a in A:
        s_tmp = gcd(s_tmp, a)
        if p_flag:
            tmp = Calc_Divisors(a)
            for t in tmp:
                if p_dic[t] == 0:
                    p_dic[t] = 1
                else:
                    p_flag = False
                    continue

    if p_flag:
        print('pairwise coprime')
    elif s_tmp == 1:
        print('setwise coprime')
    else:
        print('not coprime')


if __name__ == "__main__":
    main()


### FIXED CODE ###

from math import gcd, sqrt


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


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

    s_tmp = A[0]
    p_flag = True
    p_dic = [0] * (10**6+1)
    for a in A:
        s_tmp = gcd(s_tmp, a)
        if p_flag:
            tmp = list(set(prime_factorize(a)))
            for t in tmp:
                if p_dic[t] == 0:
                    p_dic[t] = 1
                else:
                    p_flag = False
                    continue

    if p_flag:
        print('pairwise coprime')
    elif s_tmp == 1:
        print('setwise coprime')
    else:
        print('not coprime')


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

N = int(input())
S = []
L = 0
for c in range(0,N):
    S.append(str(input()))
    c += 1
for d in range(0,N):
    S[d] = ''.join(sorted(S[d]))
for i in range(0,N):
    for l in range(i+1,N):
        if S[i] == S[l]:
            L += 1
print(L)


### FIXED CODE ###

N = int(input())
s = []
l = 1
z = 0
for i in range(0,N):
    s.append(str(input()))
for i in range(0,N):
    s[i] = ''.join(sorted(s[i]))
s.sort()
for i in range(0,N-1):
    if s[i] == s[i+1]:
        l += 1
    else:
        z += l*(l-1)/2
        l = 1
z += l*(l-1)/2
print(int(z))
### BUGGY CODE ###

import numpy as np
N = int(input())
temp = input()
a = np.array([int(i) for i in temp.split()])

num_X = 0

for ele in a:
    X_new = 3*N - np.count_nonzero(a - ele) - np.count_nonzero(a - ele -1) - np.count_nonzero(a - ele +1)
    num_X = max(num_X, X_new)

print(num_X)

### FIXED CODE ###

import numpy as np
N = int(input())
temp = input()
a = np.array([int(i) for i in temp.split()])

list_X = [0]*1000000

for ele in a:
    list_X[ele] += 1
    list_X[ele-1] += 1
    list_X[ele+1] += 1

print(max(list_X))
### BUGGY CODE ###

N = int(input())
inlist = []
for i in range(N):
  inputst = input()
  inputstlist = list(inputst)
  inputstlist.sort()
  inlist.append(inputstlist)
inlist.sort()
count=0
i=0
while i<N:
  skip=0
  for j in range(i+1,N):
    flag1=0
    for k in range(10):
      if inlist[i][k]!=inlist[j][k]:
        flag1=1
        break
    if flag1==0:#一致
      count+=1
      skip+=1
    else:#不一致
      if skip>=1:
        i=i+skip-1
        count+=int(((skip-1)+1)*(skip-1)/2)
      break
  i+=1
print(count)      


### FIXED CODE ###

N = int(input())
inlist = []
for i in range(N):
  inputst = input()
  inputstlist = list(inputst)
  inputstlist.sort()
  inlist.append(inputstlist)
inlist.sort()
count=0
i=0
while i<N:
  skip=0
  for j in range(i+1,N):
    flag1=0
    for k in range(10):
      if inlist[i][k]!=inlist[j][k]:
        flag1=1
        break
    if flag1==0:#一致
      count+=1
      skip+=1
    else:#不一致
      break
  if skip>=1:
    i=i+skip
    count+=int(((skip-1)+1)*(skip-1)/2)
  else:
    i+=1
print(count)