Harryxun/stf_run huggingface dataset:
#include<iostream>
using namespace std;

int main(){
    int n, a, b;
    int c[6]={};
    for (int i=0; i<6; i++) {
        cin >> c[i];
    }
    cin >> n;
    for (int i=0; i<n; i++) {
        cin >> a >> b;
        if (a==c[0]) {
            if (b==c[1]) {
                cout << c[2] << endl;
            } else if (b==c[2]) {
                cout << c[4] << endl;
            } else if (b==c[3]) {
                cout << c[1] << endl;
            } else if (b==c[4]) {
                cout << c[3] << endl;
            }
        } else if (a==c[1]) {
            if (b==c[0]) {
                cout << c[3] << endl;
            } else if (b==c[2]) {
                cout << c[0] << endl;
            } else if (b==c[3]) {
                cout << c[5] << endl;
            } else if (b==c[5]) {
                cout << c[2] << endl;
            }
        } else if (a==c[2]) {
            if (b==c[0]) {
                cout << c[1] << endl;
            } else if (b==c[1]) {
                cout << c[5] << endl;
            } else if (b==c[4]) {
                cout << c[0] << endl;
            } else if (b==c[5]) {
                cout << c[4] << endl;
            }
        } else if (a==c[3]) {
            if (b==c[0]) {
                cout << c[4] << endl;
            } else if (b==c[1]) {
                cout << c[0] << endl;
            } else if (b==c[4]) {
                cout << c[5] << endl;
            } else if (b==c[5]) {
                cout << c[1] << endl;
            }
        } else if (a==c[4]) {
            if (b==c[0]) {
                cout << c[2] << endl;
            } else if (b==c[2]) {
                cout << c[5] << endl;
            } else if (b==c[3]) {
                cout << c[0] << endl;
            } else if (b==c[5]) {
                cout << c[3] << endl;
            }
        } else if (a==c[5]) {
            if (b==c[1]) {
                cout << c[3] << endl;
            } else if (b==c[2]) {
                cout << c[1] << endl;
            } else if (b==c[3]) {
                cout << c[4] << endl;
            } else if (b==c[4]) {
                cout << c[2] << endl;
            }
        } 
    }
    return 0;
}


### FIXED CODE ###

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

for i in range(n):
  q=list(map(int,input().split()))
  if q in [[S[3],S[1]],[S[1],S[2]],[S[2],S[4]],[S[4],S[3]]]:
           print(S[0])
           
  if q in [[S[0],S[3]],[S[3],S[5]],[S[5],S[2]],[S[2],S[0]]]:
           print(S[1])
           
  if q in [[S[0],S[1]],[S[1],S[5]],[S[5],S[4]],[S[4],S[0]]]:
           print(S[2])
           
  if q in [[S[4],S[5]],[S[5],S[1]],[S[1],S[0]],[S[0],S[4]]]:
           print(S[3])
           
  if q in [[S[0],S[2]],[S[2],S[5]],[S[5],S[3]],[S[3],S[0]]]:
           print(S[4])
  
  if q in [[S[2],S[1]],[S[1],S[3]],[S[3],S[4]],[S[4],S[2]]]:
           print(S[5])
n = int(input())
d = list(map(int,input().split()))
k = max(d)
i,j,ans,b,s = 0
while i <= k:
  while j <= n-1:
    if d[j] <= i:
      b += 1
    if d[j] > i:
      s += 1
  if b == s:
    ans += 1
  i += 1
print(ans)
  

### FIXED CODE ###

n = int(input())
d = list(map(int,input().split()))
d.sort()
ans = 0
if n % 2 == 1:
  print(ans)
else:
  ans = d[(n // 2)] - d[(n // 2 - 1)]
  print(ans)
arr_len_int = int(input().split(' ')[1])
if (arr_len_int==1):
  print(input())
else:
  a = [input() for i in range(arr_len_int)]
  a.sort()
  print(''.join(a))


### FIXED CODE ###

arr_len_int = int(input().split(' ')[0])
if (arr_len_int==1):
  print(input())
else:
  a = [input() for i in range(arr_len_int)]
  a.sort()
  print(''.join(a))
from sys import stdin
import numpy as np
from operator import itemgetter

N = int(stdin.readline().rstrip().split()[0])
A = [int(x) for x in stdin.readline().rstrip().split()]

ans = "Yes"
L = []
if N%3!=0:
    if sum(A)==0:
        print("Yes")
    else:
        print("No")
else:
    for a in A:
        if a in L:
            continue

        if len(L)>=3:
            ans = "No"
            break
        L.append(a)

    l1, l2, l3 = L
    while ans=="Yes":
        sumL = l1%2 + l2%2 + l3%2
        if sumL!=0 and sumL!=2:
            ans = "No"
            break
        l1 = l1//2
        l2 = l2//2
        l3 = l3//2
        if l1+l2+l3==0:
            break
    print(ans)


### FIXED CODE ###

from sys import stdin
import numpy as np
from operator import itemgetter

N = int(stdin.readline().rstrip().split()[0])
A = [int(x) for x in stdin.readline().rstrip().split()]

ans = "Yes"
L = []
L_cnt = {}
for a in A:
    if a in L:
        L_cnt[a]+=1
        continue

    if len(L)>=3:
        ans = "No"
        break
    L.append(a)
    L_cnt[a]=1

if len(L)==3:
    l1, l2, l3 = L
    if N%3!=0:
        ans="No"
    if not L_cnt[l1]==L_cnt[l2]==L_cnt[l3]:
        ans="No"
    while ans=="Yes":
        sumL = l1%2 + l2%2 + l3%2
        if sumL!=0 and sumL!=2:
            ans = "No"
            break
        l1 = l1//2
        l2 = l2//2
        l3 = l3//2
        if l1+l2+l3==0:
            break
    print(ans)
elif len(L)==2:
    if N%3!=0:
        ans="No"
    if L_cnt[0]!=N//3:
        ans="No"
    if L[0]!=0 and L[1]!=0:
        ans="No"
    print(ans)
else:
    if sum(L)!=0:
        ans="No"
    print(ans)
import numpy as np

N, D = map(int , input().split())
X = [list(map(int , input().split())) for _ in range(N)]
X = np.array(X)
cnt = 0
for i in range(N - 1):
    for j in range(i + 1 , N):
        dis = np.linalg.norm(X[i] - X[j])
        if dis.is_integer():
            cnt += 1
print(cnt)

### FIXED CODE ###

import numpy as np

N, D = map(int , input().split())
X = [list(map(int , input().split())) for _ in range(N)]
X = np.array(X)
cnt = 0
for i in range(N - 1):
    for j in range(i + 1 , N):
        dis = np.linalg.norm(X[i] - X[j])
        if dis.is_integer():
            cnt += 1
print(cnt)
# coding: utf-8
# A - Fifty-Fifty

s = input()
c = []
dict = {}
for i in s:
    if i in dict:
        dict[i] +=1
    else:
        dict[i] = 1
        c.append(i)
if dict[c[0]] == dict[c[1]] == 2 and len(dict) == 2:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

# coding: utf-8
# A - Fifty-Fifty

s = input()
c = []
dict = {}
for i in s:
    if i in dict:
        dict[i] +=1
    else:
        dict[i] = 1
        c.append(i)

if dict[c[0]] == 4:
    print("No")
elif dict[c[0]] == dict[c[1]] == 2 and len(dict) == 2:
    print("Yes")
else:
    print("No")
n,k = map(int,input().split())
d = map(lambda x: (int(x) + 1) / 2, input().split())
ret = sum(d[:k])
tmp = ret
for i in range(k,n):
  tmp = tmp + d[i] - d[i-k]
  ret = max(ret,tmp)
print(ret)

### FIXED CODE ###

n,k = map(int,input().split())
d = list(map(lambda x: (int(x) + 1) / 2, input().split()))
ret = sum(d[:k])
tmp = ret
for i in range(k,n):
  tmp = tmp + d[i] - d[i-k]
  ret = max(ret,tmp)
print(ret)
"""
最小公倍数LCMを求めて、LCMを各Aで除した商を合計すればよい
"""
def main()
    from math import gcd
    mod = 10**9 +7
    N = int(input())
    A = list(map(int,input().split()))
    l = A[0]
    for i in range(1,N):
        l = (l*A[i])//gcd(l,A[i])

    ans = 0
    for a in A:
        ans += (l//a)%mod
        ans %= mod
    print(ans)
main()

### FIXED CODE ###

from math import gcd

def lcm(a, b):
    return a*b//gcd(a,b)
def main():
    N = int(input())
    A = list(map(int, input().split()))
    mod = 10**9 + 7
    LCM = 1
    for a in A:
        LCM = lcm(LCM, a)
    ans = 0
    for a in A:
        ans += (LCM//a)
        

    print(ans % mod)
main()
N, L = map(int, input().split())
a = list(map(int, input().split()))
end = 0
for i in range(N - 1):
    if a[i] + a[i + 1] >= L:
        end = i + 1
        break
else:
    print('Impossible')
    exit()

print('Possible')
print(*range(1, end), *reversed(range(end, N)), sep='\n')

### FIXED CODE ###

N, L = map(int, input().split())
a = list(map(int, input().split()))
end = 0
for i in range(N - 1):
    if a[i] + a[i + 1] >= L:
        end = i + 1
        break
else:
    print('Impossible')
    exit()

ans = list(range(1, end)) + list(range(end, N))[::-1]
print('Possible')
print(*ans, sep='\n')
from math import ceil
H,W,D=map(int,input().split())
A=[[0]*(int(ceil(H*W/D))) for i in range(D)]
for i in range(H):
    Ai=list(map(int,input().split()))
    for j in range(W):

        A[Ai[j]%D][Ai[j]//D]=(i,j)
A[0][0]=(0,0)
B=[[0]*(int(ceil(H*W/D))) for i in range(D)]
for j in range(D):
    for i in range(len(A[0])-1):
        if type(A[j][i+1])!=type((0,0)):
            B[j][i+1]=B[j][i]
            continue
        B[j][i+1]=B[j][i]+abs(A[j][i][0]-A[j][i+1][0])+abs(A[j][i][1]-A[j][i+1][1])
Q=int(input())
for _ in range(Q):
    L,R=map(int,input().split())
    print(B[R%D][R//D]-B[L%D][L//D])


### FIXED CODE ###

from math import ceil
H,W,D=map(int,input().split())
A=[[0]*(int(ceil(H*W/D))) for i in range(D)]
for i in range(H):
    Ai=list(map(int,input().split()))
    for j in range(W):
        A[(Ai[j]-1)%D][(Ai[j]-1)//D]=(i,j)
B=[[0]*(int(ceil(H*W/D))+1) for i in range(D)]
for j in range(D):
    for i in range(len(A[j])):
        if  type(A[j][i])!=type((0,0)):
            #B[j][i+1]=B[j][i]
            break
        if i==0:
            B[j][i+1]=A[j][i][0]+A[j][i][1]
            continue
        B[j][i+1]=B[j][i]+abs(A[j][i-1][0]-A[j][i][0])+abs(A[j][i-1][1]-A[j][i][1])
Q=int(input())
for _ in range(Q):
    L,R=map(int,input().split())
    L,R=L-1,R-1
    print(B[R%D][R//D+1]-B[L%D][L//D+1])
n= int(input())
r = int(input())
k = 0
if(n<10):
    k=100*(10-n)+r
    print(k)
else:
    print(r)

### FIXED CODE ###

N, R = map(int, input().split())
if N < 10:
    print((100*(10-N))+R)
else:
    print(R)
import math
A, B, C, D = map(int, input().split())
k = B - A + 1
A -= 1
count = round((B//C + B//D - B//((C*D)/math.gcd(C, D)))-(A//C + A//D - A//((C*D)/math.gcd(C, D))))
print(k-count)

### FIXED CODE ###

import fractions
def lcm(a,b):
  return a*b //fractions.gcd(a, b)

A, B,C,D = map(int, input().split())

b_num = B//C + B//D - B//lcm(C, D)
a_num = (A-1)//C + (A-1)//D - (A-1)//lcm(C, D)
print((B-(A-1))-(b_num-a_num))
n, a, b = map(int, input().split)
ans = 0
for i in range(n+1):
  if a<= sum(list(map(int, list(str(i))))) <= b:
    ans += i
print(ans)

### FIXED CODE ###

n, a, b = map(int, input().split())
ans = 0
for i in range(n+1):
  if a<= sum(list(map(int, list(str(i))))) <= b:
    ans += i
print(ans)
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 i in range(N):
    j=W
    while j>=w[i]:
        dp[j]=max(dp[j],dp[j-w[i]]+v[i])
        j-=1
print(dp[W])

### FIXED CODE ###

INF = 2000000000
"""
メモ : Pythonでは無限大を表す float('inf') があるが, 処理がかなり重たいので
       代わりにsum(v)より真に大きい 2*10^9 を INFとする.
       (https://atcoder.jp/contests/dp/tasks/dp_e において,PyPyを使用して,
        前者だと1060ms, 後者だと570msで2倍近く差が出ている.)
"""
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())
sum_v = sum(v)
dp = [[INF for i in range(sum_v + 1)] for j in range(n + 1)]
# dp[i][j]には重さが入る.
# dp[i][j]=(i番目までの品物から価値がちょうどｊになるための重さの最小値)

# ここからメイン
dp[0][0] = 0
for i in range(n):
    for j in range(sum_v + 1):
        if j < v[i]:
            dp[i + 1][j] = dp[i][j]
        else:
            dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i])

# n個まで使って,重さがlimit_wを超えないで価値が最大のものを求める.
max_value = 0
for i in range(sum_v + 1):
    if dp[n][i] <= W:
        max_value = i
print(max_value)
N=int(input())
a=list(map(int,input()))
print(sum(a[::2])-sum(a[1::2]))

### FIXED CODE ###

N=int(input())
a=list(map(int,input().split()))
a.sort()
a=a[::-1]

for i in range(1,N,2):
  a[i] *= -1
print(sum(a))
from collections import defaultdict
n,p = map(int,input().split())
s = list(map(int,list(input())))[::-1]
ans = 0
if p == 2 or p == 5:
    for i in range(n):
        if s[i]%p==0:
            ans += n-i
    print(ans)
else:
    d = defaultdict(int)
    check = 0
    for i in range(n):
        check += s[i]*10**i
        check %= p
        ans += d[check]
        if check == 0:
            ans+=1
        d[check] += 1
        ten += 1
    print(ans)

### FIXED CODE ###

from collections import defaultdict
n,p = map(int,input().split())
s = list(map(int,list(input())))[::-1]
ans = 0
if p == 2 or p == 5:
    for i in range(n):
        if s[i]%p==0:
            ans += n-i
    print(ans)
else:
    d = defaultdict(int)
    check = 0
    ten = 1
    for i in range(n):
        check += s[i]*ten
        check %= p
        ans += d[check]
        if check == 0:
            ans+=1
        d[check] += 1
        ten *= 10
        ten %= p
    print(ans)
def price(target, item, recipe):
    ret = []
     
    if target in recipe:
        ret.append(sum(price(r,item, recipe) for r in recipe[target]))
    if target in item:
        ret.append(item[target])
 
    return min(ret)
 
import sys
f = sys.stdin
 
 
while True:
    n = int(f.readline())
    if n == 0:
        break
    item = [f.readline().split() for _ in range(n)]
    item = {name:int(price) for name, price in item}
    recipe = [f.readline().strip().split() for _ in range(int(f.readline()))]
    recipe = {r[0]:r[2:] for r in recipe}
    print(price(f.readline().strip(), item, recipe))

### FIXED CODE ###

def price(target, item, recipe):
    ret = []
    
    if target in recipe:
        ret.append(sum(price(r,item, recipe) for r in recipe[target]))
    if target in item:
        ret.append(item[target])
    if len(ret) == 0:
        return 0

    return min(ret)

import sys
f = sys.stdin

while True:
    n = int(f.readline())
    if n == 0:
        break
    item = [f.readline().split() for _ in range(n)]
    item = {name:int(price) for name, price in item}
    recipe = [f.readline().strip().split() for _ in range(int(f.readline()))]
    recipe = {r[0]:r[2:] for r in recipe}
    print(price(f.readline().strip(), item, recipe))
def main():
    n , m = map(int, input().split())
    con = list(set([tuple(map(int, input().split())) for i in range(m)]))
    if (len(con) > n) or (con[0] == (1,0)):
        print(-1)
        return
    ans = 10**(n-1)
    tmp = -1
    for s,c in con:
        if (s == tmp):
            print(-1)
            return
        else:
            tmp = s
        if (s==1):
            ans += (c-1)*10**(n-1)
        else:
            ans += c*10**(n-s)
    print(ans)
main()    

### FIXED CODE ###

def main():
    n , m = map(int, input().split())
    con = list(set([tuple(map(int, input().split())) for i in range(m)]))
    if (len(con) > n) or (m != 0 and n != 1 and con[0] == (1,0)):
        print(-1)
        return
    if (n == 1 and m == 0):
        print(0)
        return
    ans = 10**(n-1)
    if (m == 0):
        print(ans)
        return
    tmp = -1
    for s,c in con:
        if (s == tmp):
            print(-1)
            return
        else:
            tmp = s
        if (s==1):
            ans += (c-1)*10**(n-1)
        else:
            ans += c*10**(n-s)
    print(ans)
main()
def main():
    S = int(input())
    dp = [0]*(S+1)
    dp[0] = 1
    dp[1] = 0
    dp[2] = 0
    for i in range(3,S+1,1):
        for j in range(0,i-2,1):
            dp[i] += dp[j]

    return dp[S]%1000000007

print(main())


### FIXED CODE ###

def main():
    S = int(input())
    dp = [0]*(S+1)
    dp[0] = 1
    dp[1] = 0
    if S >= 2:
        dp[2] = 0
    for i in range(3,S+1,1):
        for j in range(0,i-2,1):
            dp[i] += dp[j]

    return dp[S]%1000000007

print(main())
N = int(input())
li_str = input().split()
li_int = []

for i in li_str:
    li_int.append(int(i))
count= 1
for i in li_int:
    if i == count:
        count += 1
        num = count
print(num)

### FIXED CODE ###

N = int(input())
li_str = input().split()
li_int = []
for i in li_str:
    li_int.append(int(i))
count= 1
num =  N + 1
for i in li_int:
    if i == count:
        num = count
        count += 1
print(N - num)
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, C, STC):
    tbl = [0] * (2*int(1e+5) + 1)
    for s, t, c in STC:
        tbl[2*s-1 + 1] += 1
        tbl[2*t+1] -= 1
    for i in range(1, len(tbl)):
        tbl[i] += tbl[i-1]
    ans = max(tbl)
    return ans


def main():
    N, C = read_int_n()
    STC = [read_int_n() for _ in range(N)]
    print(slv(N, C, STC))


if __name__ == '__main__':
    main()


### FIXED CODE ###

# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, C, STC):
    tbl = [0] * (2*int(1e+5) + 2)
    ST = defaultdict(list)
    for s, t, c in STC:
        ST[c].append((s, t))
    for st in ST.values():
        st.sort()
        for i, (s, t) in enumerate(st):
            if i > 0 and st[i-1][1] == st[i][0]:
                tbl[2*(st[i][0])] += 1
                tbl[2*(st[i][1])] -= 1
            else:
                tbl[2*st[i][0]-1] += 1
                tbl[2*st[i][1]] -= 1

    for i in range(1, len(tbl)):
        tbl[i] += tbl[i-1]
    ans = max(tbl)
    return ans


def main():
    N, C = read_int_n()
    STC = [read_int_n() for _ in range(N)]
    print(slv(N, C, STC))


if __name__ == '__main__':
    main()
a=int(input())
b,c=map(int,input().split())
d=0
while d<a:
  e=(b//int(input()))
  if e==0:
    f+=e
  else:
    f+=(e+1)
    c+=f
    d+=1
    print(c)


  
  

### FIXED CODE ###

a=int(input())
b,c=map(int,input().split())
d=0
while d<a:
  e=((b-1)//int(input()))+1
  c+=e
  d+=1
print(c)
R, C, K = map(int, input().split())
item_lis = list(list(map(int, input().split())) for i in range(K))
item_map = [[0 for i in range(C)] for i in range(R)]
for i,j,k in item_lis:
  item_map[i-1][j-1] = k
inf = float("inf")
dp = [[[0 for i in range(4)] for i in range(C)] for i in range(R)]

def calc(x, y, z, lis1=item_map, lis2=dp):
  now_score = dp[x][y][z]
  dp1 = -inf
  dp2 = -inf
  dp3 = -inf
  dp4 = -inf
  if x+1 <= R-1:
    if z < 3:
      if lis1[x][y] != 0:
        dp1 = calc(x+1, y, 0)+lis1[x][y]+now_score
    dp2 = calc(x+1, y, 0)+now_score
      
  if y+1 <= C-1:
    if z < 3:
      if lis1[x][y] != 0:
        dp3 = calc(x, y+1, z+1)+lis1[x][y]+now_score
    dp4 = calc(x, y+1, z)+now_score
  
  if x == R-1 and y == C-1:
    if z < 3:
      new_score = now_score+lis1[x][y]
    else:
      new_score = now_score
  else:
    new_score = max(now_score, dp1, dp2, dp3, dp4)
  return new_score

ans = calc(0, 0, 0)
print(ans)

### FIXED CODE ###

import numba
from numba import jit
import numpy as np
  
@jit
def main(r, c):
  dp = np.zeros((c+1, 4), np.int64)
  for i in range(r):
    new_dp = np.zeros((c+1, 4), np.int64)
    for j in range(4):
      new_dp[:,0] = np.maximum(new_dp[:,0], dp[:,j])
    dp = new_dp
    for k in range(c):
      for l in range(2, -1, -1):
        dp[k,l+1] = max(dp[k,l+1], dp[k,l]+item_map[i,k])
      for m in range(1,4):
        dp[k+1,m] = max(dp[k+1,m], dp[k,m])
  return max(dp[c-1,:])


R, C, K = map(int, input().split())
item_lis = list(list(map(int, input().split())) for i in range(K))
item_map = np.zeros((R, C), np.int64)
for i,j,k in item_lis:
  item_map[i-1,j-1] = k

print(main(R, C))
H,N = map(int,input().split())
M = list(map(int,input().split())

ans = 0       
for i in M:
    ans = ans + i
if h > ans:
    print("No)
else:
    print("Yes")
         

### FIXED CODE ###

H,N = map(int,input().split())
M = list(map(int,input().split()))
 
ans = 0       
for i in M:
    ans = ans + i
if H > ans:
    print("No")
else:
    print("Yes")
alphabet = "abcdefghijklmnopqrstuvwxyz"


n = int(input())
res = dict()
ans = 0
for _ in range(n):
    s = str(input())
    s.sort()
    if s not in res.keys():
      res[s] = 1
    else:
      ans += res[s]
      res[s] += 1
print(ans)
      

### FIXED CODE ###

alphabet = "abcdefghijklmnopqrstuvwxyz"


n = int(input())
res = dict()
for _ in range(n):
    s = str(input())
    freqency = [0 for _ in alphabet]
    for __ in s:
        freqency[alphabet.index(__)] += 1
    freq = "".join([str(___) for ___ in freqency])
    if freq not in res:
        res[freq] = 1
    else:
        res[freq] += 1

ans = 0
for value in res.values():
    ans += ((value-1)*value)/2
  
print(int(ans))
N,A,B = input().split()
N = long long (N)
A = int(A)
B = int(B)
rep = (int)(N/(A+B))

numb = min(N%(A+B),A) + rep*A

print(numb)

### FIXED CODE ###

N,A,B = input().split()
N = int (N)
A = int(A)
B = int(B)
rep = (int)(N/(A+B))

numb = min(N%(A+B),A) + rep*A

print(numb)
from functools import reduce
from math import gcd

n,x0=map(int,input().split())
x=list(map(int,input().split()))

for i in range(n):
    x[i]=abs(x[i]-x0)

print(reduce(gcd, x))
    

### FIXED CODE ###

def gcdf(a):
    a.sort()
    a0=a[0]
    a=[int(x%a0) for x in a if x%a0 != 0]
    if len(a)==0:
        return a0
    else:
        a.append(a0)
        a0=min(a)
        return gcdf(a) 
    
n,x=map(int,input().split())
xi=list(map(int,input().split()))

for i in range(n):
    if xi[i]>x:
        xi[i]=xi[i]-x
    else:
        xi[i]=x-xi[i]
    
gcdx=gcdf(xi)
print(gcdx)
import numpy as np

n = int(input())
A = np.array(input().split(), np.int64)
B = np.array(input().split(), np.int64)

A = np.sort(A)
B = np.sort(B)

C = [0]*30
for k in range(30):
    A_ = A%(2**(k+1))
    B_ = B%(2**(k+1))
    A_ = np.sort(A_)
    B_ = np.sort(B_)
    A0 = A_[A_<=2**k]
    A1 = A_[A_>2**k]
    C[k] += (np.searchsorted(B_, 2**(k+1)-A0, side='left')-np.searchsorted(B_, 2**k-A0, side='left')).sum()
    C[k] += (np.searchsorted(B_, 2**(k+1)-A1, side='left')-np.searchsorted(B_, 0, side='left')).sum()
    C[k] += (np.searchsorted(B_, 2**(k+1), side='left')-np.searchsorted(B_, 2**(k+1)+2**k-A1, side='left')).sum()

ans = 0
for i in range(len(C)):
    if C[i]%2 == 1:
        ans += 2**i
#print(C)
print(ans)

### FIXED CODE ###

import numpy as np

n = int(input())
A = np.array(input().split(), np.int64)
B = np.array(input().split(), np.int64)

A = np.sort(A)
B = np.sort(B)

C = [0]*30
for k in range(30):
    A_ = A%(2**(k+1))
    B_ = B%(2**(k+1))
    A_ = np.sort(A_)
    B_ = np.sort(B_)
    A0 = A_[A_<=2**k]
    A1 = A_[A_>2**k]
    C[k] += (np.searchsorted(B_, 2**(k+1)-A0, side='left')-np.searchsorted(B_, 2**k-A0, side='left')).sum()
    C[k] += (np.searchsorted(B_, 2**(k+1)-A1, side='left')-np.searchsorted(B_, 0, side='left')).sum()
    C[k] += (np.searchsorted(B_, 2**(k+1), side='left')-np.searchsorted(B_, 2**(k+1)+2**k-A1, side='left')).sum()

ans = 0
for i in range(len(C)):
    if C[i]%2 == 1:
        ans += 2**i
#print(C)
print(ans)