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

import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    N = int(input())
    A = input_nums()
    idx = [i for i in range(1, N+1)]
    A = dict(zip(idx, A))
    B = dict(zip(idx,[0]*N))
    A_keys = A.keys()
    for i in reversed(range(1,N+1)):
        b = i
        cnt = 0
        while True:
            if not b in A_keys:
                break
            else:
                cnt += B[b]
            b += b
            if not cnt % 2 == A[i]:
                B[i] = 1
            else:
                B[i] = 0
    ans = []
    for k, v in B.items():
        if v == 1:
            ans.append(k)
    print(len(ans))
    if len(ans) != 0:
        print(*ans)

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    N = int(input())
    A = input_nums()
    idx = [i for i in range(1, N+1)]
    A = dict(zip(idx, A))
    B = dict(zip(idx,[0]*N))
    for i in reversed(range(1,N+1)):
        b = i
        cnt = 0
        while b <= N:
            cnt += B[b]
            b += i
        if not cnt % 2 == A[i]:
            B[i] = 1
        else:
            B[i] = 0
    ans = []
    for k, v in B.items():
        if v == 1:
            ans.append(k)
    print(len(ans))
    if len(ans) != 0:
        print(*ans)

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

import numpy as np
import bisect
from operator import itemgetter
N, M, Q = map(int,input().split())
LR = [list(map(int,input().split())) for _ in range(M)]
PQ = [list(map(int,input().split())) for _ in range(Q)]
LR.sort(key=itemgetter(0))
LR = np.array(LR)
#print(LR)
#print(PQ)
for i in range(Q):
  ans = 0
  key = bisect.bisect_left(LR[:,0],PQ[i][0])
  ans += np.sum(LR[key:] <= PQ[i][1], axis = 0)[1]
  print(ans)

### FIXED CODE ###

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

N,M,Q = map(int,readline().split())
lines = readlines()
L,R = np.array([line.split() for line in lines[:M]],np.int32).T
P,Q = np.array([line.split() for line in lines[M:]],np.int32).T

cnt = np.zeros((N+1,N+1),dtype=np.int32)
np.add.at(cnt,(L,R),1)

np.cumsum(cnt,axis=0,out=cnt)
np.cumsum(cnt,axis=1,out=cnt)
P -= 1
x = cnt[Q,Q] - cnt[Q,P] - cnt[P,Q] + cnt[P,P]
print(*x,sep="\n")
### BUGGY CODE ###

import sys

s = sys.stdin.readline().rstrip()
q = int(sys.stdin.readline().rstrip())
query = [sys.stdin.readline().rstrip().split() for i in range(q)]
top = 1
for i in range(q):
    que = query[i]
    if que[0] == '1':
        top *= -1
    else:
        if que[1] == '1':
            if top > 0:
                s = ''.join([que[2], s])
                # s = que[2] + s
            else:
                s = ''.join([s, que[2]])
                # s = s + que[2]
        else:
            if top > 0:
                s = ''.join([s, que[2]])
                # s = s + que[2]
            else:
                s = ''.join([que[2], s])
                # s = que[2] + s
if top < 0:
    s = s[::-1]
print(s)


### FIXED CODE ###

import sys

s = sys.stdin.readline().rstrip()
q = int(sys.stdin.readline().rstrip())
query = [sys.stdin.readline().rstrip().split() for i in range(q)]
top = 1
s = list(s)
s_front = []
s_back = []
for i in range(q):
    que = query[i]
    if que[0] == '1':
        top *= -1
    else:
        if que[1] == '1':
            if top > 0:
                s_front.append(que[2])
                # s = ''.join([que[2], s])
                # s = que[2] + s
            else:
                s_back.append(que[2])
                # s = ''.join([s, que[2]])
                # s = s + que[2]
        else:
            if top > 0:
                s_back.append(que[2])
                # s = ''.join([s, que[2]])
                # s = s + que[2]
            else:
                s_front.append(que[2])
                # s = ''.join([que[2], s])
                # s = que[2] + s
s_front.reverse()
s_front.extend(s)
s_front.extend(s_back)
s = s_front
s = ''.join(s)
if top < 0:
    s = s[::-1]
print(s)
### BUGGY CODE ###

s = input()
x,y = map(int,input().split())
count = 0
d = []
s = s.split('T')
d = [len(x) for x in s]

if len(d) == 0:
    d.append(0)
if len(d) == 1:
    d.append(0)
dpx = [d[0]]
dpy = [d[1],-d[1]]
for i in range(len(d)-2):
    if i%2==0:
        trans = set()
        for j in range(len(dpx)):
            trans.add(dpx[j]+d[i+2])
            trans.add(dpx[j]-d[i+2])
        dpx = list(trans)
    else:
        trans = set()
        for j in range(len(dpy)):
            trans.add(dpy[j]+d[i+2])
            trans.add(dpy[j]-d[i+2])
        dpy = list(trans)
ans = (x in dpx)&(y in dpy)

if ans:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

s = input()
x,y = map(int,input().split())
count = 0
d = []
s = s.split('T')
d = [len(x) for x in s]

if len(d) == 0:
    d.append(0)
if len(d) == 1:
    d.append(0)
dpx = [d[0]]
dpy = [d[1],-d[1]]
for i in range(2,len(d)):
    di = d[i]
    trans = set()
    if i%2==0:
        for xj in dpx:
            trans.add(xj+di)
            trans.add(xj-di)
        dpx = list(trans)
    else:
        for yj in dpy:
            trans.add(yj+di)
            trans.add(yj-di)
        dpy = list(trans)
ans = (x in dpx)&(y in dpy)

if ans:
    print('Yes')
else:
    print('No')
### BUGGY CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000000)

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

A = [-1]*M
B = [-1]*M
C = [-1]*M
back_edges = [[] for _ in range(N)]
forward_edges = [[] for _ in range(N)]
fb = [0]*N
past = set()
availables = set()

for edge in range(M):
    a, b, c = map(int, input().split())
    A[edge] = a-1
    B[edge] = b-1
    C[edge] = c-P
    forward_edges[a-1].append(edge)
    back_edges[b-1].append(edge)

def forward(node):
    if node in past:
        return
    availables.add(node)
    edges = forward_edges[node]
    past.add(node)
    for edge in edges:
        forward(B[edge])
    past.discard(node)

forward(0)

def back(node):
    edges = back_edges[node]
    past.add(node)
    coin = -float('inf') if node != 0 else 0
    for edge in edges:
        a = A[edge]
        if a not in availables:
            continue
        c = C[edge]
        if a in past:
            if fb[a] < c + fb[node]:
                print(-1)
                sys.exit()
            continue
        fb[a] = c + fb[node]
        coin = max(back(a)+c, coin)
    past.discard(node)
    return coin

ans = back(N-1)
ans = 0 if ans < 0 else ans
print(ans)

### FIXED CODE ###

import sys
import time
from queue import Queue
limit_time = time.time() + 1.70
input = sys.stdin.readline
sys.setrecursionlimit(1000000000)

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

A = [-1]*M
B = [-1]*M
C = [-1]*M
nodes_edges = [[] for _ in range(N)]
rev_nodes_edges = [[] for _ in range(N)]
coin = [-float('inf')]*N
coin[0] = 0
availables = set()

for edge in range(M):
    a, b, c = map(int, input().split())
    A[edge] = a-1
    B[edge] = b-1
    C[edge] = c-P
    nodes_edges[a-1].append(edge)
    rev_nodes_edges[b-1].append(edge)

def cut_graph(node):
    edges = rev_nodes_edges[node]
    availables.add(node)
    for edge in edges:
        prev = A[edge]
        if prev in availables:
            continue
        cut_graph(prev)

cut_graph(N-1)
q = Queue()
q.put(0)
count = 0
limit = M*(1+len(availables))
while not q.empty():
    if time.time() >= limit_time:
        print(-1)
        break
    node = q.get()
    edges = nodes_edges[node]
    for edge in edges:
        nxt = B[edge]
        if nxt not in availables:
            continue
        new_coin = C[edge]+coin[node]
        if new_coin > coin[nxt]:
            coin[nxt] = new_coin
            q.put(nxt)
    count += 1
else:
    ans = coin[N-1]
    ans = 0 if ans < 0 else ans
    print(ans)
### BUGGY CODE ###

import sys
from heapq import heappush, heappop


I = sys.stdin.readlines()
N, Q = map(int, I[0].split())
P = []
for i in range(1, N + 1):
    s, t, x = map(int, I[i].split())
    P.append((s - x, t - 1 - x, x))
P.sort()


q = []
cur = 0
cnt = 0
for i in range(N + 1, N + Q + 1):
    d = int(I[i])
    while cur < N and P[cur][0] <= d:
        s, t, x = P[cur]
        heappush(q, (x, s, t))
        cnt += 1
        cur += 1
    ans = -1
    while cnt:
        if d <= q[0][2]:
            ans = q[0][0]
            break
        else:
            heappop(q)
            cnt -= 1
    print(ans)



### FIXED CODE ###

import sys
from heapq import heappush, heappop


I = sys.stdin.readlines()
N, Q = map(int, I[0].split())
P = []
for i in range(1, N + 1):
    s, t, x = map(int, I[i].split())
    P.append((s - x, t - 1 - x, x))
P.sort()


q = []
cur = 0
for i in range(N + 1, N + Q + 1):
    d = int(I[i])
    while cur < N and P[cur][0] <= d:
        s, t, x = P[cur]
        heappush(q, (x, t))
        cur += 1
    ans = -1
    while len(q) > 0:
        x, t = q[0]
        if d <= t:
            ans = x
            break
        else:
            heappop(q)
    print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

def warshal_floyd(d):
  for k in range(n):
    for i in range(n):
      for j in range(n):
        d[i][j] = min(d[i][j], d[i][k]+d[k][j])
        
  return d

n, m, l = map(int, input().split())
d = [[float('inf') for i in range(n)] for j in range(n)]
for i in range(n):
  d[i][i] = 0

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

d2 = [[float('inf') for i in range(n)] for j in range(n)]
for i in range(n):
  d2[i][i] = 0
  
for i in range(n):
  for j in range(n):
    if d[i][j] <= l:
      d2[i][j] = 1

d2 = warshal_floyd(d2)

q = int(input())
for i in range(q):
  s, t = map(int, input().split())
  s, t = s-1, t-1
  if d2[s][t] == float('inf'):
    print(-1)
  else:
    print(d2[s][t]-1)
  

### FIXED CODE ###

import sys
input = sys.stdin.readline

def warshal_floyd(d):
  for k in range(n):
    for i in range(n):
      for j in range(n):
        d[i][j] = min(d[i][j], d[i][k]+d[k][j])
        
  return d

n, m, l = map(int, input().split())
d = [[float('inf') for i in range(n)] for j in range(n)]
for i in range(n):
  d[i][i] = 0

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

d2 = [[float('inf') for i in range(n)] for j in range(n)]
for i in range(n):
  d2[i][i] = 0
  
for i in range(n):
  for j in range(n):
    if d[i][j] <= l:
      d2[i][j] = 1

d2 = warshal_floyd(d2)

q = int(input())
for i in range(q):
  s, t = map(int, input().split())
  s, t = s-1, t-1
  if d2[s][t] == float('inf'):
    print(-1)
  else:
    print(d2[s][t]-1)
### BUGGY CODE ###

def main():
    n, m = map(int,raw_input().split())
    A = [[] for i in xrange(n)]
    for i in xrange(m):
        s, t = map(int,raw_input().split())
        A[s].append(t)
        A[t].append(s)

    q = input()
    a =[0]*q
    for i in xrange(q):
        s, t = map(int,raw_input().split())
        c = bfs(n,A,s,t)
        if c[t] == -1:
            a[i] = 'no'
        else:
            a[i] = 'yes'

    for i in a:
        print i
        
def bfs(n,A,s,t):
    color = [-1]*n
    Q = []
    Q.append(s)
    while(True):
        if len(Q)==0:
            break
        u = Q.pop(0)
        for i in A[u]:
            if i == t:
                color[t] = 1
                break
            elif color[i] == -1:
                color[i] = 0
                Q.append(i)
        color[u] = 1
    return color

if __name__ == '__main__':
    main()

### FIXED CODE ###

from collections import deque

def main():
    n, m = map(int,raw_input().split())
    A = [[] for i in xrange(n)]
    for i in xrange(m):
        s, t = map(int,raw_input().split())
        A[s].append(t)
        A[t].append(s)

    g = [-1]*n
    x = 0
    for i in xrange(n):
        if g[i] == -1:
            g = bfs(n,A,i,g,x)
            x += 1
            
    q = input()
    a =[0]*q
    for i in xrange(q):
        s, t = map(int,raw_input().split())
        if g[s] == g[t]:
            a[i] = 'yes'
        else:
            a[i] = 'no'
    for i in a:
        print i
        
def bfs(n,A,s,color,x):
    Q = deque([s])
    while(len(Q)!=0):
        u = Q.popleft()
        for i in A[u]:
            if color[i] == -1:
                Q.append(i)
        color[u] = x
    return color

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

N, Q = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(Q)][: : -1]
res = [N * (N - 1) // 2]
mod = 2305843009213693951
class UnionFind():
  def __init__(self, n):
    self.n = n
    self.root = [-1] * (n + 1)
    self.rnk = [0] * (n + 1)

  def Find_Root(self, x):
    if self.root[x] < 0:
      return x
    else:
      self.root[x] = self.Find_Root(self.root[x])
      return self.root[x]

  def Unite(self, x, y):
    x = self.Find_Root(x)
    y = self.Find_Root(y)
    if x == y:
      return 
    elif self.rnk[x] > self.rnk[y]:
      self.root[x] += self.root[y]
      self.root[y] = x
    else:
      self.root[y] += self.root[x]
      self.root[x] = y
      if self.rnk[x] == self.rnk[y]:
        self.rnk[y] += 1

  def isSameGroup(self, x, y):
    return self.Find_Root(x) == self.Find_Root(y)

  def Count(self, x):
    return -self.root[self.Find_Root(x)]

class Factorial:
  def __init__(self, n, mod):
    self.f=[1]
    for i in range(1, n + 1):
      self.f.append(self.f[-1] * i % mod)
    self.i=[pow(self.f[-1], mod - 2, mod)]
    for i in range(1, n + 1)[: : -1]:
      self.i.append(self.i[-1] * i % mod)
    self.i.reverse()
  def factorial(self, i):
    return self.f[i]
  def ifactorial(self, i):
    return self.i[i]
  def combi(self, n, k):
    return self.f[n] * self.i[n - k] % mod * self.i[k] % mod

uf = UnionFind(N)
f = Factorial(N * (N - 1) // 2, 2305843009213693951)
for b in A:
  uf.Unite(b[0], b[1])
  convenience = 0
  for inc in uf.root:
    if inc < -1:
      if -inc > N * (N - 1) // 2:
        convenience += 1
      else:
        convenience += f.combi(-inc, 2)
  res.append(N * (N - 1) // 2 - convenience)
for i in range(Q - 1, -1, -1):
  print(res[i])

### FIXED CODE ###

N, Q = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(Q)]
res = [0] * (Q - 1) + [N * (N - 1) // 2]
class UnionFind():
  def __init__(self, n):
    self.n = n
    self.root = [-1] * (n + 1)
    self.rnk = [0] * (n + 1)

  def Find_Root(self, x):
    if self.root[x] < 0:
      return x
    else:
      self.root[x] = self.Find_Root(self.root[x])
      return self.root[x]

  def Unite(self, x, y):
    x = self.Find_Root(x)
    y = self.Find_Root(y)
    if x == y:
      return 
    elif self.rnk[x] > self.rnk[y]:
      self.root[x] += self.root[y]
      self.root[y] = x
    else:
      self.root[y] += self.root[x]
      self.root[x] = y
      if self.rnk[x] == self.rnk[y]:
        self.rnk[y] += 1

  def isSameGroup(self, x, y):
    return self.Find_Root(x) == self.Find_Root(y)

  def Count(self, x):
    return -self.root[self.Find_Root(x)]

uf = UnionFind(N)
convenience = [0] * (N + 1)
for i in range(Q - 1, 0, -1):
  res[i - 1] = res[i]
  if uf.Find_Root(A[i][0]) != uf.Find_Root(A[i][1]):
    res[i - 1] -= uf.Count(A[i][0]) * uf.Count(A[i][1])
    a, b = uf.Count(A[i][0]), uf.Count(A[i][1])
    uf.Unite(A[i][0], A[i][1])
  #print(uf.root, res, a, b)
for i in range(Q):
  print(res[i])
### BUGGY CODE ###

s = input()
dp = [[0 for i in range(13)] for i in range(len(s))]
if s[-1] != "?":
    dp[0][int(s[-1]) % 13] += 1
else:
    for k in range(10):
        dp[0][k % 13] += 1

for i in range(1,len(s)):
    for r in range(13):
        if s[-(i+1)] == "?":
            for k in range(10): 
                dp[i][(k * (10**i) % 13 + r) % 13] += dp[i-1][r]
                
        else:
            dp[i][(int(s[-(i+1)]) * (10**i) % 13 + r) % 13] += dp[i-1][r]
    for r in range(13):
        dp[i][r]  %= 10**9 + 7
print(dp[len(s)-1][5]%(10**9+7))


### FIXED CODE ###

s = input()
dp = [[0 for i in range(13)]]
if s[-1] != "?":
    dp[0][int(s[-1]) % 13] += 1
else:
    for k in range(10):
        dp[0][k % 13] += 1
        
d = [1]   
for i in range(1,len(s)):
    dp.append([0]*13)
    d.append(d[i-1]*10 % 13)
    for r in range(13):
        if s[-(i+1)] == "?":
            for k in range(10): 
                dp[i][(k * d[i] + r) % 13] += dp[i-1][r] % (10**9 + 7)
                
        else:
            dp[i][(int(s[-(i+1)]) * d[i] + r) % 13] += dp[i-1][r] % (10**9 + 7)

print(dp[len(s)-1][5]%(10**9+7))
### BUGGY CODE ###

import sys
from fractions import gcd
from operator import mul
from functools import reduce
inputs = sys.stdin.readlines()

n, m = map(int, inputs[0].split())
A = list(map(int, inputs[1].split()))
if all((a // reduce(gcd, A)) % 2 for a in A):
    print(round((m+1) / reduce(lambda x, y: x*y // gcd(x, y), A)))
else:
    print(0)

### FIXED CODE ###

import sys
from fractions import gcd
inputs = sys.stdin.readlines()

n, m = map(int, inputs[0].split())
A = list(set(map(int, inputs[1].split())))

a = A[0]
for i in range(1, len(A)):
    z = gcd(a, A[i])
    x, y = a // z, A[i] // z
    if x % 2 == y % 2 == 1:
        a = x*y*z
    else:
        print(0)
        break
else:
    print(round(((m+1)/a)))
### BUGGY CODE ###

n, q = map(int, input().split())
s = str(input())
a = []
b = []
for i in range(q):
    x, y = map(int, input().split())
    a.append(x)
    b.append(y)

    c = s[a[i]-1:b[i]]
    d = c.count('AC')
    print(d)

### FIXED CODE ###

n, q = map(int, input().split())
s = str(input())
d = [list(map(int, input().split())) for i in range(q)]
a = [0,0]
cnt = 0
for i in range(1, n):
    if s[i-1]+s[i] == 'AC':
        cnt += 1
    a.append(cnt)

for i in range(q):
    print(a[d[i][1]]-a[d[i][0]])
### BUGGY CODE ###

N, M = [int(elm) for elm in input().split(" ")] 

As = [int(elm) for elm in input().split(" ")] 

Bs = []
Cs = []
for i in range(M):
    B, C = [int(elm) for elm in input().split(" ")] 
    As += ([C] * B)

t = sorted(As, reverse=True)
out = sum(t[:N])
print(out)

### FIXED CODE ###

N, M = [int(elm) for elm in input().split(" ")] 

As = sorted([int(elm) for elm in input().split(" ")], reverse=True)


BCs = []
for i in range(M):
    B, C = [int(elm) for elm in input().split(" ")] 
    BCs.append([B, C])

BCs = sorted(BCs, key=lambda x: -x[1])

out = 0
bc_i = 0
count = 0
B, C = BCs[bc_i]

for A in As:
    if C >= A and bc_i < M:
        while C >= A: 
            #print("plus", B, C, "A", A)
            out += (B*C)

            count += B
            bc_i += 1
            if bc_i == M or count > N:
                break
            B, C = BCs[bc_i]
            
    if count > N:
        out -= C * (count-N)
        break
    elif count == N:
        break

    out += A
    #print("plus", A)
    count += 1

print(out)
### BUGGY CODE ###

import numpy as np
import math as mt
N=int(input())
#R=map(int, input().split())
A=list(map(int,input().split()))
for i in range(0,N):
    print(A.count(i+1))

    



### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
ans = [0] * N
for i in A:
    ans[i-1]=ans[i-1]+1
for i in range(0,N):
    print(ans[i])
### BUGGY CODE ###

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

for i in range(n-1):
    for j in range(i+1,n):
        ans += a[i]*a[j]
print(ans%(10**9+7))


### FIXED CODE ###

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

#for i in range(n-1):
#    for j in range(i+1,n):
#        ans += a[i]*a[j]
ans = 0
sum_a = 0
for i in range(n):
    ans += a[i]**2
    sum_a += a[i]
tmp = (sum_a ** 2 - ans)//2
print(tmp%(10**9+7))
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10 ** 9)

n, q = map(int, input().split())
edges = [[] for _ in range(n)]
cnt = [0 for _ in range(n)]
for i in range(n - 1):
    a, b = map(int, input().split())
    edges[a - 1].append(b - 1)
for i in range(q):
    p, x = map(int, input().split())
    cnt[p - 1] += x

ans = [0 for _ in range(n)]
visit = [False for _ in range(n)]

def rec(pos, val):
    val += cnt[pos]
    ans[pos] = val
    for to in edges[pos]:
        if not visit[to]:
            visit[to] = True
            rec(to, val)

visit[0] = True
rec(0, 0)
for x in ans[:-1]:
    print(x, end=' ')
print(ans[-1])


### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 9)

input = sys.stdin.readline

n, q = map(int, input().split())
edges = [[] for _ in range(n)]
cnt = [0 for _ in range(n)]
for i in range(n - 1):
    a, b = map(int, input().split())
    edges[a - 1].append(b - 1)
for i in range(q):
    p, x = map(int, input().split())
    cnt[p - 1] += x

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

visit = [False for _ in range(n)]
visit[0] = True

stack = []
stack.append((0, 0))

while stack:
    pos, val = stack.pop(-1)
    val += cnt[pos]
    ans[pos] = val
    for to in edges[pos]:
        if not visit[to]:
            visit[to] = True
            stack.append((to, val))

for x in ans[:-1]:
    print(x, end=' ')
print(ans[-1])
### BUGGY CODE ###

n = int(input())
ss = [[""]]*n
for i in range(n):
    s = list(input())
    s.sort()
    ss[i] = s

ss.sort()

ans = 0
while len(ss) != 0:
    f = ss.pop(0)
    c = 1
    while len(ss) > 0:
        d = ss[0]
        if f == d:
            ss.pop(0)
            ans += c
            c += 1
        else:
            break

print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline

n = int(input())
ss = [[""]]*n
for i in range(n):
    s = list(input())
    s.sort()
    ss[i] = s

ss.sort()

ans = 0
while len(ss) != 0:
    f = ss.pop(0)
    c = 1
    while len(ss) > 0:
        d = ss[0]
        if f == d:
            ss.pop(0)
            ans += c
            c += 1
        else:
            break

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

# -*- coding utf-8 -*-

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

ans=0

for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if s==x+y+z:
                ans+=1
    
print(ans)


### FIXED CODE ###

# -*- coding utf-8 -*-

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

ans=0

for x in range(k+1):
    for y in range(k+1):
        if 0<=s-x-y<=k:
            ans+=1
    
print(ans)
### BUGGY CODE ###

def main():
	s = tuple(input())
	length = len(s)

	dp = [[0 for _ in range(13)]for _ in range(length+1)]
	MOD = 10**9+7
	if s[-1] == '?':
		for i in range(10):
			dp[1][i] = 1
	else:
		dp[1][int(s[-1])] = 1

	for i in range(1,length):
		if s[-i-1] != '?':
			num = (int(s[-i-1]) * (10**i)) % 13
			for j in range(13):
				dp[i+1][j] = dp[i][(13-num+j)%13]
				dp[i+1][j] % MOD
		else:
			num = (10**i) % 13
			a = 0
			for j in range(10):
				for k in range(13):
					dp[i+1][k] += dp[i][(13-a+k)%13]
					dp[i+1][k] % MOD
				a += num

	print(dp[length][5] % MOD)

if __name__ == '__main__':
	main()


### FIXED CODE ###

INF = 10 ** 9 + 7

S = input()
# dp[i][j]はうしろからi桁を13で割った余りがjであるものの個数
dp = [[0] * 13 for _ in range(len(S) + 1)]
dp[0][0] = 1
mul = 1

for i in range(len(S)):
    x = S[-(i + 1)]
    if x == "?":
        for k in range(10):
            for j in range(13):
                dp[i + 1][(mul * k + j) % 13] += dp[i][j]
                dp[i + 1][(mul * k + j) % 13] %= INF
    else:
        k = int(x)
        for j in range(13):
            dp[i + 1][(mul * k + j) % 13] += dp[i][j]
            dp[i + 1][(mul * k + j) % 13] %= INF
    mul = mul * 10 % 13  # 計算量削減のためここで13で割っている

print(dp[len(S)][5])