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

# coding: utf-8
# Your code here!
import collections
import sys

input=sys.stdin.readline

N=int(input())
l=[]
clist=[]

for i in range(N):
    clist.append(collections.Counter(list(input().replace("\n",""))))#ここは普通に入れてfor文でcounterする

count=0

for i in range(N):
    for j in range(i+1,N):
        if clist[i]==clist[j]:
            count+=1
            
print(count)
        


### FIXED CODE ###

# coding: utf-8
# Your code here!
import collections 
 
N=int(input())
l=[]
 
for i in range(N):
    l.append(list(input()))
    l[i].sort()
    l[i]="".join(l[i])
    
clist=list(collections.Counter(l).values())

count=0
for c in clist:
    count+=int(c*(c-1)//2)
    
print(count)
### BUGGY CODE ###

N,A,B = map(int,input().split())
ans = 0
for i in range(10**100):
    if N > A+B:
        N -= (A+B)
        ans += A
    else:
        break
if N >= A:
    ans += A
    print(ans)
else :
    ans += N
    print(ans)

### FIXED CODE ###

N, A, B = map(int, input().split())
ans = N // (A + B) * A
rem = N % (A + B)
ans += min(rem, A)
print(ans)
### BUGGY CODE ###

N, M = map(int, input().split())
A = []
B = []

for i in range(M):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
for i in range(M):
    A.append(B[i])
    B.append(A[i])

result = []
stack = []

def path(start, visited):

    if len(visited) == N:
        if visited not in result:
            result.append(visited[:])
        exit
    stack.append(start)
    while len(stack) > 0:
        nextpoint = stack.pop()
        if nextpoint in visited:
            continue
        visited.append(nextpoint)
        for i in range(2*M):
            if A[i] == start:
                path(B[i], visited)
        visited.pop()

path(1, [])
print(len(result))


### FIXED CODE ###

N, M = map(int, input().split())
A = [list(map(int, input().split())) for i in range(M)]

result = []
stack = []

def path(start, visited):
    if len(visited) >= N:
        result.append(visited[:])
        exit
    stack.append(start)
    if len(stack) > 0:
        nextpoint = stack.pop()
        if nextpoint not in visited:
            visited.append(nextpoint)
            for i in range(M):
                if A[i][0] == start:
                    path(A[i][1], visited)
                if A[i][1] == start:
                    path(A[i][0], visited)
            visited.pop()

path(1, [])
result = list(map(list, set(map(tuple, result))))
print(len(result))
### BUGGY CODE ###

n,m = map(int,input().split())
high = list(map(int,input().split()))
deck = []
for z in range(1,n+1):
    deck.append(z)

kumiawase = []

for x in range(m):
    kumi = list(map(int,input().split()))
    kumiawase.append(kumi)

for y in kumiawase:
    if high[y[0]-1]==high[y[1]-1]:
        if y[0] in deck:
            deck.remove(y[0])
        if y[1] in deck:
            deck.remove(y[1])
    elif high[y[0]-1] > high[y[1]-1]:
        if y[1] in deck:
            deck.remove(y[1])
    else:
        if y[0] in deck:
            deck.remove(y[0])

good_deck = len(deck)

print(good_deck)


### FIXED CODE ###

# nは展望台の数　mは道の数
n,m = map(int,input().split())
high = list(map(int,input().split()))

a = []

for x in range(m):
    b = list(map(int,input().split()))
    a.append(b)


loser = []

for y in a:
    high1 = high[y[0]-1]
    high2 = high[y[1]-1]
    if high1 > high2:
        loser.append(y[1])
    elif high1 ==  high2:
        loser.append(y[0])
        loser.append(y[1])
    else:
        loser.append(y[0])

new_loser = list(set(loser))
print(n-len(new_loser))
### BUGGY CODE ###

S = input()
additions = ['','']
direction = 0
Q = int(input())
for _ in range(Q):
    query = input().split()
    T = int(query[0])
    if T == 1:
        direction ^= 1
    else:
        F = int(query[1])
        C = query[2]
        additions[(F+direction+1) % 2] += C
if direction == 0:
    print(additions[0][::-1], end='')
    print(S, end='')
    print(additions[1])
else:
    print(additions[1][::-1], end='')
    print(S[::-1], end='')
    print(additions[0])

### FIXED CODE ###

S = input()
additions = [[],[]]
direction = 0
Q = int(input())
for _ in range(Q):
    query = input().split()
    T = int(query[0])
    if T == 1:
        direction ^= 1
    else:
        F = int(query[1])
        C = query[2]
        additions[(F+direction+1) % 2].append(C)
if direction == 0:
    print(''.join(additions[0][::-1]), end='')
    print(S, end='')
    print(''.join(additions[1]))
else:
    print(''.join(additions[1][::-1]), end='')
    print(S[::-1], end='')
    print(''.join(additions[0]))
### BUGGY CODE ###

from math import factorial
import sys

def comb(n,k,p):
  if n<0 or k<0 or n<k: return 0
  if n==0 or k==0: return 1
  a=factorial(n) %p
  b=factorial(k) %p
  c=factorial(n-k) %p
  return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p

def power_func(a,b,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

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    input_raw = read_func().strip().split()
    A = []
    for i in range(N):
        A.append(int(input_raw[i]))

    n = max(A)
    A.remove(n)
    p = int(1e+9 + 7)
    max_num = 0
    max_r = 0
    for i in range(N - 1):
        cm = comb(n, A[i], p)
        if max_num < cm:
            max_r = A[i]
            max_num = cm
    print n, max_r


if __name__ == '__main__':
    main()

### FIXED CODE ###

from math import factorial
import sys

def comb(n,k,p):
  if n<0 or k<0 or n<k: return 0
  if n==0 or k==0: return 1
  a=factorial(n) %p
  b=factorial(k) %p
  c=factorial(n-k) %p
  return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p

def power_func(a,b,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

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    input_raw = read_func().strip().split()
    A = []
    for i in range(N):
        A.append(int(input_raw[i]))

    n = max(A)
    A.remove(n)
    A.sort()
    max_r = n/2
    max_r_2 = n - max_r
    min_sub = sys.maxint
    r = 0
    for i in range(len(A)):
        if abs(max_r - A[i]) < min_sub or abs(max_r_2 - A[i]) < min_sub:
            min_sub = min(abs(max_r - A[i]), abs(max_r_2 - A[i]))
            r = A[i]
##    for i in range(N - 1):
##        cm = comb(n, A[i], p)
##        if max_num < cm:
##            max_r = A[i]
##            max_num = cm
    print n, r


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

import sys
temp=list(map(int, input().split()))
N=temp[0]
A=temp[1]
B=temp[2]
cnt=0
if (B-A)%2==1:
  if A-1<=N-B:
    cnt=A
    B-=A
    A=1
  else:
    cnt=N-B+1
    A+=(N-B)+1
    B=N
while A!=B:
    if B-A>=2:
      A+=1
      B-=1
      cnt+=1
print(cnt)

### FIXED CODE ###

import sys
temp=list(map(int, input().split()))
N=temp[0]
A=temp[1]
B=temp[2]
cnt=0
if (B-A)%2==1:
  if A-1<=N-B:
    cnt=A
    B-=A
    A=1
  else:
    cnt=N-B+1
    A+=(N-B)+1
    B=N
if A!=B:
  cnt+=(B-A)//2
print(cnt)
### BUGGY CODE ###

import numpy as np

n,m = map(int,input().split())
h = list(map(int,input().split()))

seen = np.array([[0 for i in range(n)] for j in range(n)])

for i in range(m):
  a,b = map(int,input().split())
  seen[a-1,b-1] = 1
  seen[b-1,a-1] = 1
  
ans = 0
for i in range(n):
  temp = np.multiply(seen[i],h)
  temp_1 = np.max(temp)
  if (h[i] > temp_1) and (temp_1 != 0):
    ans += 1
  elif temp_1 == 0:
    ans += 1
    
print(ans)

### FIXED CODE ###

import numpy as np
n,m = map(int,input().split())
h = list(map(int,input().split()))

base = np.ones(n)

for i in range(m):
  a,b =  map(int,input().split())
  if h[a-1] > h[b-1]:
    base[b-1] = 0
  elif h[a-1] < h[b-1]:
    base[a-1] = 0
  elif h[a-1] == h[b-1]:
    base[a-1] = 0
    base[b-1] = 0
    
print(int(np.sum(base)))
### BUGGY CODE ###

from collections import Counter

def func(n):
  dic = Counter()
  rest = list({i ** 2 % n for i in range(1, n)})
  lenr = len(rest)
  rest.sort()
  half = n // 2
  
  for i in range(lenr):
    resti = rest[i]
    for j in range(i + 1, lenr):
      dff = rest[j] - resti
      if dff > half:
        dic[n - dff] += 2
      else:
        dic[dff] += 2

  for i in range(1, half + 1):
    print(dic[i])

def main():
  while True:
    n = int(input())
    if n == 0:
      break
    func(n)

main()


### FIXED CODE ###

import itertools
def func(n):
  rest = {i ** 2 % n for i in range(1, n)}

  count = [0] * n
  for x, y in itertools.combinations(rest, 2):
    count[x - y] += 2

  for i in range(n // 2):
    print(count[i + 1] + count[n - i - 1])


def main():
  while True:
    n = int(input())
    if n == 0:
      break
    func(n)

main()
### BUGGY CODE ###

import functools
import operator
import itertools
import heapq
n,k = map(int,input().split())
a = list(map(int,input().split()))
if n>=2*k:
  a_plus = heapq.nlargest(k, a)
  a_minus = heapq.nsmallest(k, a)
  a_new = a_plus+a_minus
  comb = itertools.combinations(a_new,k)
else:
  comb = itertools.combinations(a,k)

l = [list(_) for _ in comb]  
A = (functools.reduce(operator.mul,l[_]) for _ in range(len(l)))
 
l_max = max(A)
waru = 10**9 + 7
 
mod = l_max % waru
print(mod)

### FIXED CODE ###

import sys
 
n, k = map(int, input().split())
a = [int(x) for x in input().split()]
mod = pow(10, 9)+7
zero = 0
plus = []
minus = []
for i in range(n):
  if a[i] == 0:
    zero += 1
  elif a[i] > 0:
    plus.append(a[i])
  else:
    minus.append(a[i])
 
P, M = len(plus), len(minus)
plus.sort(reverse=True)
minus.sort()
ans = 1
if n == k:
  for i in range(n):
    ans *= a[i]
    ans %= mod
elif P+M < k:
  ans = 0
elif P == 0:
  if zero and k%2:
    ans = 0
  else:
    if k%2:
      minus.reverse()
    for i in range(k):
      ans *= minus[i]
      ans %= mod
else:
  q = 0
  if k%2:
    ans *= plus[0]
    ans %= mod
    q = 1
  judge = []
  for i in range((len(plus)-q)//2):
    judge.append(plus[2*i+q]*plus[2*i+q+1])
  for i in range(len(minus)//2):
    judge.append(minus[2*i]*minus[2*i+1])
  judge.sort(reverse=True)
  for i in range(k//2):
    ans *= (judge[i]%mod)
    ans %= mod
 
print(ans)
### BUGGY CODE ###

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


### FIXED CODE ###

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

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

N = int(input())
A = [deque(list(map(lambda x:int(x)-1,input().split()))) for i in range(N)]

k = 0
end = 0
while 1:
    used = set()
    for i,q in enumerate(A):
        if not q: continue
        if i in used: continue
        j = q[0]
        if j in used: continue
        if A[j][0] == i:
            A[j].popleft()
            A[i].popleft()
            used.add(i)
            used.add(j)
            if not A[i]: end += 1
            if not A[j]: end += 1
    if not used:
        print(-1)
        exit()
    if end == N:
        print(k+1)
        exit()
    k += 1

### FIXED CODE ###

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

N = int(input())
A = [list(reversed(list(map(lambda x:int(x)-1,input().split())))) for i in range(N)]
B = {i:row for i,row in enumerate(A)}

end = 0
for k in range(8000):
    used = set()
    dels = []
    for i,q in B.items():
        if not q: continue
        if i in used: continue
        j = q[-1]
        if j in used: continue
        if A[j][-1] == i:
            A[j].pop()
            A[i].pop()
            used.add(i)
            used.add(j)
            if not A[i]:
                end += 1
                dels.append(i)
            if not A[j]:
                end += 1
                dels.append(j)
    if not used:
        print(-1)
        exit()
    if end == N:
        print(k+1)
        exit()
    for i in dels:
        del B[i]

print(N*(N-1)//2)
### BUGGY CODE ###

import sys
from collections import Counter, deque, defaultdict
from math import factorial
from fractions import Fraction
import heapq, bisect
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))


MOD = 998244353
n = INT()
d = LIST()
if d[0] != 0:
    print(0)
    sys.exit()
d = d[1:]
ma = max(d)
mi = min(d)
res = 1
for i in range(1, ma+1):
    if d.count(i) == 0:
        print(0)
        sys.exit()
    if i == 1:
        temp = d.count(1)
    else:
        temp2 = d.count(i)
        res *= temp**temp2
        temp = temp2

print(res%MOD)

### FIXED CODE ###

import sys
from collections import Counter, deque, defaultdict, OrderedDict
from math import factorial
from fractions import Fraction
import heapq, bisect
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))


MOD = 998244353
n = INT()
d = LIST()
if d[0] != 0:
    print(0)
    sys.exit()
d = d[1:]
c = dict(Counter(d))
c =  OrderedDict(sorted(c.items()))
c = list(c.values())
if len(c) != max(d):
    print(0)
    sys.exit()
res = 1
for i in range(1, len(c)):
    res *= c[i-1]**c[i]

print(res%MOD)
### BUGGY CODE ###

r,g,b,n=map(int,input().split())
ans=0
for i in range(n//r+1):
  for j in range((n-i*r)//g+1):
    if (n-i*r-j*g)>=0 and (n-i*r-j*g)%b==0:
      ans=ans+1
print(ans)

### FIXED CODE ###

r,g,b,n=map(int,input().split())
ans=0
for i in range(n//r+1):
  for j in range((n-i*r)//g+1):
    if (n-i*r-j*g)>=0 and (n-i*r-j*g)%b==0:
      ans=ans+1
print(ans)
### BUGGY CODE ###

import itertools
X = int(input())
num = X//100
r = X % 100
li = [0, 1, 2, 3, 4, 5]
flag = False
for i in itertools.product(li, repeat=num):
    if sum(i) == r:
        flag = True
        break
print('1' if flag else '0')

### FIXED CODE ###

X = int(input())
flag = False
for i in range(1, X+1):
    if 100*i <= X <= 105*i:
        flag = True
        break
print('1' if flag else '0')
### BUGGY CODE ###

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

for i in range(N):
    for j in range(M):
        if i == (A[j][0]-1):
            if H[i] <= H[A[j][1]-1]:
                B[i] = 1
            else:
                B[A[j][1]-1] = 1
        elif i == (A[j][1]-1):
            if H[i] <= H[A[j][0]-1]:
                B[i] = 1
            else:
                B[A[j][0]-1] = 1

for i in range(N):
    if B[i] == 0:
        count = count + 1

print(count)


### FIXED CODE ###

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

for i in range(M):
    if H[A[i][0]-1] < H[A[i][1]-1]:
        B[A[i][0]-1] = 1
    elif H[A[i][0]-1] > H[A[i][1]-1]:
        B[A[i][1]-1] = 1
    else:
        B[A[i][0]-1] = 1
        B[A[i][1]-1] = 1


for i in range(N):
    if B[i] == 0:
        count = count + 1

print(count)
### BUGGY CODE ###

S = input()
Q = int(input())


def formation():
    global S, Q

    ls = list(S)
    do_rev = False
    for _ in range(Q):
        t_str = input()

        if t_str[0] == '1':
            do_rev = not do_rev
        else:
            splited = t_str.split(' ')
            f = splited[1]
            c = splited[2]
            if f == '1':
                if do_rev:
                    ls.append(c)
                else:
                    ls.insert(0, c)
            else:
                if do_rev:
                    ls.insert(0, c)
                else:
                    ls.append(c)

    if do_rev:
        ls.reverse()

    return ''.join(ls)


print(formation())


### FIXED CODE ###

S = input()
Q = int(input())


class Node:
    def __init__(self, value=None, prev=None, next=None):
        self.value = value
        self.prev = prev
        self.next = next

    def __str__(self):
        return str(self.value)


class LinkedList:
    def __init__(self, initial_string=None):
        self.first = Node()
        self.last = Node()
        self.first.next = self.last
        self.last.prev = self.first
        self.should_reverse = False
        for s in initial_string:
            self.insert_last(s)

    def _insert_first(self, value=None):
        prev_next = self.first.next
        self.first.next = Node(value, self.first, prev_next)
        prev_next.prev = self.first.next

    def _insert_last(self, value=None):
        prev_prev = self.last.prev
        self.last.prev = Node(value, prev_prev, self.last)
        prev_prev.next = self.last.prev

    def insert_first(self, value=None):
        if self.should_reverse:
            self._insert_last(value)
        else:
            self._insert_first(value)

    def insert_last(self, value=None):
        if self.should_reverse:
            self._insert_first(value)
        else:
            self._insert_last(value)

    def set_reverse(self):
        self.should_reverse = not self.should_reverse

    def _print(self):
        node = self.first.next
        while node is not None:
            if node.value is not None:
                print(node, end="")
            node = node.next
        print("")

    def _print_reverse(self):
        node = self.last.prev
        while node is not None:
            if node.value is not None:
                print(node, end="")
            node = node.prev
        print("")

    def print_list(self):
        if self.should_reverse:
            self._print_reverse()
        else:
            self._print()


def formation():
    global S, Q

    linked_list = LinkedList(S)

    for _ in range(Q):
        t_str = input()

        if t_str[0] == '1':
            linked_list.set_reverse()
        else:
            split = t_str.split(' ')
            f = split[1]
            c = split[2]
            if f == '1':
                linked_list.insert_first(c)
            else:
                linked_list.insert_last(c)

    linked_list.print_list()


formation()
### BUGGY CODE ###

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

M = 10**9 + 7

import math

def my_pow(x, n):
    if n == 0:
        return 1
    if n % 2 == 0:
        return my_pow(x ** 2, n // 2) % M
    else:
        return x * my_pow(x ** 2, (n - 1) // 2) % M

from scipy.misc import comb

all_pattern = my_pow(2, n)
dislike = comb(n, a, exact=True) + comb(n, b, exact=True)
dislike = dislike % M

print( (all_pattern - dislike - 1) )


### FIXED CODE ###

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

M = 10 ** 9 + 7

all = pow(2, n, M) - 1
all %= M

def C(n,x):
    num = 1
    den = 1
    for i in range(x):
        num *= (n-i)
        num %= M
        den *= (i+1)
        den %= M

    inv = pow(den, M-2, M)

    return num * inv % M

ans = all - C(n,a) - C(n,b)
ans %= M
print(ans)
### BUGGY CODE ###

#!python3

iim = lambda: map(int, input().rstrip().split())

def resolve():
    X = int(input())

    def calc(a, b):
        ans = 0
        for i in range(0, 5):
            ans += pow(a, i)*pow(b, 4-i)
        return ans

    if X == 1:
        print(1, 0)
        return

    if X % 2 == 0:
        x = 2
    else:
        for x in range(3, int(X**0.5), 2):
            if X % x == 0:
                break

    N = 10**16
    for i in range(N):
        j = i - x

        ij = calc(i, j)
        if x * ij == X:
            print(i, j)
            break




if __name__ == "__main__":
    resolve()


### FIXED CODE ###

#!python3

iim = lambda: map(int, input().rstrip().split())

def resolve():
    X = int(input())

    if X == 1:
        print(1, 0)
        return

    ii = 2 if X % 2 else 1

    N = 10**9

    for x in range(1, N, ii):
        if X % x:
            continue
        for i in range(N):
            j = i - x

            ij = i**5 - j**5
            diff = ij - X
            if diff == 0:
                print(i, j)
                return
            elif j > 0 and diff > 0:
                break




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

N = int(input())
A = []
B = []
for i in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
count2 = 0
for i in range(N-1,-1,-1):
    count = B[i]*((A[i]-1)//B[i] + 1) - A[i]
    count2 += count
    for j in range(i+1):
        A[j] += count
print(count2)


### FIXED CODE ###

N = int(input())
A = []
B = []
for i in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
count2 = 0
for i in range(N-1,-1,-1):
    count = B[i]*((A[i]+count2-1)//B[i] + 1) - A[i]-count2
    count2 += count
print(count2)
### BUGGY CODE ###

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

li.sort()

for a, aa in enumerate(li):
  if a < n - 2:
    for b, bb in enumerate(li[a+1:]):
      for c, cc in enumerate(li[a+1+b+1:]):
        if aa + bb <= cc:
          break
        if aa < bb + cc and bb < cc + aa and cc < aa + bb:
          ans += 1
            
print(ans)

### FIXED CODE ###

import bisect

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

li.sort()

for i in range(n):
  for j in range(i+1, n):
    cnt = bisect.bisect_left(li, li[i]+li[j])
    ans += cnt - j - 1
            
print(ans)
### BUGGY CODE ###

import collections
# from collections import OrderedDict

N = int(input())
S = []
for _ in range(N):
    S.append(input())

c = collections.Counter(S)

max_k_list = [kv[0] for kv in c.items() if kv[1] == max(c.values())]
max_k_list = sorted(max_k_list)
for i in max_k_list:
    print(i)

### FIXED CODE ###

import collections
# from collections import OrderedDict

N = int(input())
S = [input() for _ in range(N)]

c = collections.Counter(S)
max_vale = c.most_common()[0][1]

hoge = []
for k, v in c.items():
    if max_vale == v:
        hoge.append(k)

hoge = sorted(hoge)
for i in hoge:
    print(i)



# for i in c.most_common():
#     print(i)