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

class RollingHashSingle:
    def __init__(self, s, base, mod):
        self.base = base
        self.mod = mod

        self.hash = [0]
        self.power = [1]
        for c in s:
            self.hash.append((self.hash[-1] * base + ord(c)) % mod)
            self.power.append(self.power[-1] * base % mod)

    def get(self, left, right):
        h = self.hash[right] - self.hash[left] * self.power[right - left]
        return (h + self.mod) % self.mod


class RollingHash:
    def __init__(self,
                 s,
                 base=(10**4 + 7, 10**4 + 9),
                 mod=(10**9 + 7, 10**9 + 9)):
        if isinstance(base, int):
            assert isinstance(mod, int)
            self.base = (base, )
            self.mod = (mod, )
        elif isinstance(base, tuple):
            assert isinstance(mod, tuple)
            assert len(base) == len(mod)
            self.base = base
            self.mod = mod
        else:
            raise ValueError()

        self._rh = [
            RollingHashSingle(s, base, mod)
            for base, mod in zip(self.base, self.mod)
        ]

    def get(self, left, right):
        return tuple(rh.get(left, right) for rh in self._rh)


n = int(input())
s = input().rstrip()
rh = RollingHash(s)


def check(diff):
    d = {}
    for i in range(n - diff + 1):
        h = rh.get(i, i + diff)
        if h in d.keys():
            if abs(d[h] - i) >= diff:
                return True
        else:
            d[h] = i
    return False


lo = 0
hi = n // 2 + 1
while lo + 1 < hi:
    mid = (lo + hi) // 2
    if check(mid):
        lo = mid
    else:
        hi = mid
print(lo)

### FIXED CODE ###

def create_z_array(s):
    n = len(s)
    z_array = [0] * n
    left = 0
    right = 0
    for i in range(1, n):
        if i > right:
            left, right = i, i
            while right < n and s[right - left] == s[right]:
                right += 1
            z_array[i] = right - left
            right -= 1
        else:
            k = i - left
            if z_array[k] < right - i + 1:
                z_array[i] = z_array[k]
            else:
                left = i
                while right < n and s[right - left] == s[right]:
                    right += 1
                z_array[i] = right - left
                right -= 1
    return z_array


n = int(input())
s = input().rstrip()
res = 0
for i in range(n):
    z_array = create_z_array(s[i:])
    for j in range(1, len(z_array)):
        res = max(res, min(j, z_array[j]))
print(res)
### BUGGY CODE ###

n = int(input())
numbers = list(map(int, input().split()))
numbers.sort()

max_comb = 0
ai = numbers[-1]
ans = [ai, 0]

numerator = 1
denominator = 1

for i in range(1, ai):
    denominator *= i
    numerator *= ai - i + 1
    comb = numerator // denominator
    if i in numbers and comb > max_comb:
        max_comb = comb
        ans = [ai, i]
print(*ans)

### FIXED CODE ###

n = int(input())
numbers = list(map(int, input().split()))
numbers.sort()

ai = numbers[-1]
r = ai / 2

for i in range(n - 1):
    if numbers[i] == r:
        ans = [ai, int(r)]
        break
    if numbers[i] > r:
        if numbers[i] - r < r - numbers[i - 1]:
            ans = [ai, numbers[i]]
        break
    ans = [ai, numbers[i]]

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

n,k  = map(int,input().split())
a = list(map(int,input().split()))
INF = 10**15
dp = [INF for _ in range(n)]
dp[0] = 0
for i in range(n):
    for j in range(1,k+1):
        if i+j <= n-1 :
            dp[i+j] = min(dp[i]+ abs(a[i+j] - a[i]) , dp[i+j])
print(dp[-1])


### FIXED CODE ###

n,k  = map(int,input().split())
a = list(map(int,input().split()))
INF = 10**15
dp = [INF for _ in range(n)]
dp[0] = 0
for i in range(n):
    for j in range(1,k+1):
        if i+j <= n-1 :
            dp[i+j] = min(dp[i]+ abs(a[i+j] - a[i]) , dp[i+j])
print(dp[-1])
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
mod = 10**9 + 7
m = 62
d =[0]*m
ans = 0
for i in range(N):
    for j in range(m):
        if A[i]&(1<<j):
            ans += (1<<j)*(i-d[j])
            d[j] += 1
        else:
            ans += (1<<j)*d[j]
    ans %= mod
print(ans%mod)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
mod = 10**9 + 7
m = 62
d =[0]*m
ans = 0
for i in range(N):
    for j in range(m):
        if A[i]&(1<<j):
            ans += (1<<j)*(i-d[j])%mod
            d[j] += 1
        else:
            ans += (1<<j)*d[j]%mod
    ans %= mod
print(ans%mod)
### BUGGY CODE ###

import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n = ni()
    a = na()

    a_set = set(a)

    a_cnt = collections.Counter(a)

    # 約数を列挙　n=10^12までいける
    def make_divisors(n, a_set):
        if a_cnt[n] > 1:
            return True

        deleted_set = a_set - {n}
        # divisors = []
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                # divisors.append(i)
                if i in deleted_set:
                    return True
                if i != n // i:
                    # divisors.append(n // i)
                    if n // i in deleted_set:
                        return True

        # divisors.sort()
        return False

    ans = 0
    for ai in a_set:
        if not make_divisors(ai, a_set):
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))

# ===CODE===

eps = 10 ** (-9)


def main():
    n = ni()
    a = na()

    seta = set(a)
    cnta = collections.Counter(a)
    lista = list(seta)
    lista.sort()

    table = [True for _ in range(10 ** 6 + 1)]
    ans = 0

    for ai in lista:
        if table[ai]:
            if cnta[ai] == 1:
                ans += 1
            for i in range(ai, 10 ** 6 + 1, ai):
                table[i] = False

    print(ans)


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

s=input()
n=len(s)
mod=10**9+7
dp=[[0 for _ in range(13)] for _ in range(n)]
for i,x in enumerate(s):
    if i==0:
        if x=='?':
            for j in range(10):
                dp[0][j]=1
        else:
            num=ord(x)-ord('0')
            dp[0][num]=1
    else:
        if x=='?':
            for j in range(10):
                for jj in range(13):
                    if dp[i-1][jj]>0:
                        dp[i][(10*jj+j)%13]+=dp[i-1][jj]
        else:
            num=ord(x)-ord('0')
            for j in range(13):
                if dp[i-1][j]>0:
                    dp[i][(10*j+num)%13]+=dp[i-1][j]
print(dp[-1][5]%mod)


### FIXED CODE ###

mod=10**9+7
s=input()
dp1=[1]+[0]*12
for i in range(len(s)):
    dp2=[0]*13
    if s[i]!='?':
        p=int(s[i])
        for j in range(13):
            dp2[(j*10+p)%13]+=dp1[j]
    else:
        for p in range(10):
            for j in range(13):
                dp2[(j*10+p)%13]+=dp1[j]
    dp1=[dp2[j]%mod for j in range(13)]
print(dp1[5])
### BUGGY CODE ###

#!/usr/bin/env python3
import sys

MOD = 998244353  # type: int

def baai(n1, n2):
    return(n1**n2%MOD)

def solve(N: int, D: "List[int]"):
    cn=[0]*N
    for i in range(N):
        cn[D[i]]+=1

    if D[0]!=0:
        print(0)
    else:
        answer=1
        bak=cn[0]
        kyo=1
        hen=1
        while True:
            if kyo >= N:
                while True:
                    pass
            cnt=cn[kyo]
            hen+=cnt
            if cnt==0:
                break
            answer=answer*baai(bak, cnt)%MOD
            bak=cnt
            kyo+=1
        if hen==N:
            print(answer%MOD)
        else:
            print(0)
    return


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

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys

MOD = 998244353  # type: int

def baai(n1, n2):
    return(n1**n2%MOD)

def solve(N: int, D: "List[int]"):
    cn=[0]*(N*2)
    for i in range(N):
        cn[D[i]]+=1

    if D[0]!=0:
        print(0)
    else:
        answer=1
        bak=cn[0]
        kyo=1
        hen=1
        while True:
            cnt=cn[kyo]
            hen+=cnt
            if cnt==0:
                break
            answer=answer*baai(bak, cnt)%MOD
            bak=cnt
            kyo+=1
        if hen==N:
            print(answer%MOD)
        else:
            print(0)
    return


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

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

import itertools

n, m, R = [int(i) for i in input().split()]
r = [int(i) - 1 for i in input().split()]
dis = [[float("inf") for _ in range(n)] for _ in range(n)]
for i in range(m):
    a, b, c = [int(i) for i in input().split()]
    dis[a - 1][b - 1] = c
    dis[b - 1][a - 1] = c

# 全ての頂点間の最短距離を算出、
for k in range(len(dis)):
    for i in range(len(dis)):
        for j in range(len(dis)):
            if dis[i][j] > dis[i][k] + dis[k][j]:
                dis[i][j] = dis[i][k] + dis[k][j]


_min = float("inf")
it = itertools.permutations(r)
for iterR in it:
    _dis = 0
    for j in range(1, len(iterR)):
        _dis += dis[iterR[j]][iterR[j-1]]
    _min = min(_min, _dis)
print(_min)

"""
print("2 vs "+func(3, 3, [0, 1, 2], [[0, 1, 4], [1, 0, 1], [4, 1, 0]]))
print("4 vs "+func(3, 3, [0, 2], [[0, 2, 6], [2, 0, 2], [6, 2, 0]]))
print("3 vs "+func(4, 6, [1, 2, 3], [[0, 4, 6, 1], [4, 0, 3, 2], [6, 3, 0, 1], [1, 2, 1, 0]]))
# print("print(func({}, {}, {}, {}))".format(n, m, r, adj))
"""


### FIXED CODE ###

import itertools
n, m, R = map(int, input().split())
r = list(map(int, input().split()))
dis = [[float("inf") for _ in range(n)] for _ in range(n)]
for _ in range(m):
    a, b, c = map(int, input().split())
    dis[a - 1][b - 1] = c
    dis[b - 1][a - 1] = c

def war(dis):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                if dis[i][j] > dis[i][k] + dis[k][j]:
                    dis[i][j] = dis[i][k] + dis[k][j]
    return dis
dis = war(dis)
_min = float("inf")
it = itertools.permutations(r)
for iterR in it:
    _dis = 0
    start = iterR[0] - 1
    for end in iterR[1:]:
        _dis += dis[start][end - 1]
        start = end - 1
    _min = min(_min, _dis)
print(_min)
### BUGGY CODE ###

N = int(input())
S = input()
ans = 0

for i in range(10):
    for j in range(10):
        for k in range(10):
            hit = 0
            for c in S:
                c_ = int(c)
                if hit == 0 and c_ == i:
                    hit += 1
                elif hit == 1 and c_ == j:
                    hit += 1
                elif hit == 2 and c_ == k:
                    ans += 1
                    break
print(ans)


### FIXED CODE ###

N = int(input())
S = input()
ans = 0

for i in range(10):
    ind_i = S.find(str(i))
    if ind_i != -1:
        S2 = S[ind_i + 1:]
        for j in range(10):
            ind_j = S2.find(str(j))
            if ind_j != -1:
                S3 = S2[ind_j + 1:]
                for k in range(10):
                    cnt_k = S3.count(str(k))
                    if cnt_k > 0:
                        ans += 1


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

def main():
    n,d,a = map(int,input().split())
    l = [list(map(int,input().split())) for i in range(n)]
    l.sort()
    count = 0
    import math
    import bisect
    i = 0
    l1 = []

    while i < n:
        sn = i
        s = l[i][0]
        mi = math.ceil(l[i][1]/a)
        count += mi
        l1 =[]
        while i < n and l[i][0] <= s+2*d:
            
            l[i][1] -= mi*a
            if l[i][1] > 0:
                l1.append(i)
            i += 1
            
        if len(l1) > 0:
            i = l1[0]
        else:
            if i == n:
                print(count)
                exit()
    
if __name__ == "__main__":
    main()



### FIXED CODE ###

def main():
    n,d,a = map(int,input().split())
    l = [list(map(int,input().split())) for i in range(n)]
    l.sort()
    count = 0
    from collections import deque

    i = 0
    area = deque([])
    damage = deque([])
    total_damage = 0
    count = 0
    ans = 0
    for pos,hp in l:
        while area:
            ar = area[0]
            if ar < pos:
                area.popleft()
                power = damage.popleft()
                total_damage -= power
            else:
                break
        if hp <= total_damage:
            continue
        else:
            count = (hp-total_damage+a-1)//a
            ans += count
            total_damage += count*a
            area.append(pos+2*d)
            damage.append(count*a)

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

#!/usr/bin/env python3
import sys
from collections import Counter

def solve(S: str):
    # S[i, j) % 2019 == 0となる(i, j)の数
    # S[i..n) - S[j, n) === 0 (mod 2019)
    # 累積mod c[i] = S[i:]
    n = len(S)
    c = [0] * (n + 1)
    for i in range(n):
        c[i] = int(S[i:]) % 2019
    print(sum(v * (v - 1) // 2 for v in Counter(c).values()))


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)


if __name__ == "__main__":
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
from collections import Counter


def solve(S: str):
    # S[i, j) % 2019 == 0となる(i, j)の数
    # S[i..n) - S[j, n) === 0 (mod 2019)
    # 累積mod c[i] = S[i:]
    n = len(S)
    c = [0] * (n + 1)  # c[i] = int(S[i:]) % 2019
    for i in reversed(range(n)):
        c[i] = (c[i + 1] + int(S[i]) * pow(10, n - 1 - i, 2019)) % 2019
    print(sum(v * (v - 1) // 2 for v in Counter(c).values()))


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)


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

import itertools
n = int(input())
s = list(input())
ans = 0
idx = [i for i in range(n)]
for i in itertools.combinations(idx, 3):
    a, b, c = i[0], i[1], i[2]
    if a < b < c:
        if s[a] == s[b] or s[a] == s[c] or s[b] == s[c]:
            continue
        elif b-a == c-b:
            continue
        else:
            ans += 1
print(ans)

### FIXED CODE ###

n = int(input())
s = input()

r_count = s.count("R")
g_count = s.count("G")
b_count = s.count("B")
ans = r_count * g_count * b_count

for i in range(n):
    for d in range(n):
        j = i + d
        k = j + d
        if k >= n:
            break
        if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
                ans -= 1

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

N, M = map(int, input().split())
a = [int(input()) for j in range(M)]

#dp[i]:i段目までの上がり方

div = 1000000007

dp = [0] * (N+1)
dp[0] = 1
if not 1 in a:
    dp[1] = 1

def stairs():
    for i in range(N-1):
        if dp[i+1] == 0 and dp[i] == 0:
            break
        if not i+2 in a:
            dp[i+2] = (dp[i+1] + dp[i]) % div
    print(dp[N])

stairs()

### FIXED CODE ###

N, M = map(int, input().split())
a = [int(input()) for j in range(M)]

#dp[i]:i段目までの上がり方

div = 1000000007

dp = [0] * (N+1)
dp[0] = 1
if not 1 in a:
    dp[1] = 1
else:
    del a[0]

def stairs():
    for i in range(N-1):
        if dp[i+1] == 0 and dp[i] == 0:
            break
        if a:
            if i+2 == a[0]:
                del a[0]
                continue
        dp[i+2] = (dp[i+1] + dp[i]) % div
    print(dp[N])

stairs()
### BUGGY CODE ###

import itertools
n = int(input())
a = list(map(int, input().split()))
m = 10 ** 9 + 7
s = 0
for c in itertools.combinations(range(n), 2):
    s += a[c[0]] * a[c[1]] % m
print(s % m)


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
s = sum(a)
t = 0
m = 10 ** 9 + 7
for i in range(n - 1):
    s -= a[i]
    t += a[i] * s % m
print(t % m)
### BUGGY CODE ###

N = int(input())
A = [int(a) for a in input().split()]

#print(N)
#print(A)
all = {}
for a in A:
  if a not in all:
    all[a] = 0
  all[a] +=1

#print(all)
for k in range(len(A)):
  ans = 0
  for key, v in all.items():
    if v > 1:
      if key == A[k]:
      	ans += int(max(int(v-1)*(v-2)/2, 0))
      else:
        ans += int(v*(v-1)/2)

  print(ans)

### FIXED CODE ###

N = int(input())
A = [int(a) for a in input().split()]

#print(N)
#print(A)
all = {}
for a in A:
  if a not in all:
    all[a] = 0
  all[a] +=1

#print(all)
total = 0
for key, v in all.items():
  total += int(v*(v-1)/2)

for k in range(len(A)):
  ans = total - (all[A[k]] -1)
  print(ans)
### BUGGY CODE ###

"""AtCoder"""

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

ans = 0

for i in range(K+1):
  for j in range(K+1):
    for k in range(K+1):
      if i + j + k  == N:
        ans += 1

print(ans)


### FIXED CODE ###

"""AtCoder"""

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

ans = 0

for i in range(K+1):
  for j in range(K+1):
    if i + j <= N and i + j + K >= N:
      ans += 1



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

#!python3

from heapq import heappush, heappop, heapify

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

def resolve():
    H, N = iim()
    AB = [tuple(iim()) for i in range(N)]

    AB.sort(key=lambda a: (a[0]/a[1], a[0]), reverse=True)

    S = []
    for a, b in AB:
        n = H // a + 1
        h = H
        i = 1
        while n >= i:
            S.append((a*i, b*i))
            n -= i
            i <<= 1
        if n:
            S.append((a*n, b*n))

    N2 = len(S)
    def ubound(b, a, i):
        for j in range(i, N2):
            aj, bj = S[j]
            if a + aj >= H:
                return (b+bj, b + (H-a) * bj / aj)
            a += aj
            b += bj

        return (inf, inf)

    q = []
    u0, u1 = ubound(0, 0, 0)

    inf = float("inf")
    heappush(q, (u1, u0, 0, 0, 0))
    um = u0
    #print(AB)
    #print(H, S)
    while q:
        #print(q)
        uq0, uq1, aq, bq, i = heappop(q)

        if uq0 >= um:
            break

        if i >= N2: continue

        ai, bi = S[i]
        if aq + ai < H:
            heappush(q, (uq0, uq1, aq + ai, bq + bi, i + 1))

        u0, u1 = ubound(bq, aq, i + 1)
        if u1 <= um:
            if u0 < um:
                um = u0
            heappush(q, (u1, u0, aq, bq, i + 1))

    print(um)



if __name__ == "__main__":
    resolve()


### FIXED CODE ###

#!python3
import sys
sys.setrecursionlimit(1000000)

from heapq import heappush, heappop, heapify

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

def resolve():
    H, N = iim()
    AB = [tuple(iim()) for i in range(N)]
    inf = float("inf")
    AB.sort(key=lambda a: (a[0]/a[1], -a[0]), reverse=True)

    def memo(f):
        cache = {}
        def wrapper(*a):
            if a in cache:
                return cache[a]
            b = f(*a)
            cache[a] = b

            return b

        return wrapper

    @memo
    def calc(h):
        if h <= 0: return 0

        bi = inf
        for a, b in AB:
            bj = b + calc(h - a)
            if bi > bj:
                bi = bj
            else:
                break
        return bi

    print(calc(H))



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

h, w, m = map(int, input().split())
hl=[0]*h
wl=[0]*w
mh=0
mw=0
mhi=[]
mwi=[]
#ans =[[0]*w for i in range(h)]
s = [list(map(int, input().split())) for i in range(m)]

for i in range(m):
  a, b = s[i]
  a-=1
  b-=1
  
  hl[a]+=1
  if hl[a]>mh:
    mh=hl[a]
    mhi = [a]
  elif hl[a]==mh:
    mhi.append(a)
  
  wl[b]+=1
  if wl[b]>mw:
    mw=wl[b]
    mwi=[b]
  elif wl[b]==mw:
    mwi.append(b)
  
  #ans[a][b]+=1

for i in mhi:
  for j in mwi:
    if [i+1, j+1] in s:
      continue
    print(mh+mw)
    quit()
print(mh+mw-1)
    

### FIXED CODE ###

from collections import deque
h, w, m = map(int, input().split())
hl=[0]*h
wl=[0]*w
mh=0
mw=0
mhi=deque([])
dic = {}
mwi=deque([])
#ans =[[0]*w for i in range(h)]
s = [list(map(int, input().split())) for i in range(m)]
 
for i in range(m):
  a, b = s[i]
  a-=1
  b-=1
  if not a in dic:
    dic[a] = {}
    dic[a][b]=1
  else:
    dic[a][b]=1
 
  hl[a]+=1
  if hl[a]>mh:
    mh=hl[a]
    mhi = [a]
  elif hl[a]==mh:
    mhi.append(a)
  
  wl[b]+=1
  if wl[b]>mw:
    mw=wl[b]
    mwi=[b]
  elif wl[b]==mw:
    mwi.append(b)
 
  #ans[a][b]+=1

for i in mhi:
  for j in mwi:
    if not j in dic[i]:
      print(mw+mh)
      quit()

print(mh+mw-1)
### BUGGY CODE ###

import os, sys, re, math

N = int(input())
S = []
for i in range(N):
    S.append(''.join(sorted(input())))

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


### FIXED CODE ###

import os, sys, re, math

N = int(input())
S = dict()
for i in range(N):
    w = ''.join(sorted(input()))
    if w in S:
        S[w] += 1
    else:
        S[w] = 1

count = 0
for (w, n) in S.items():
    if n > 1:
        count += (n * (n - 1)) // 2
print(count)
### BUGGY CODE ###

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

if A[0] != 0:
    print(-1)
    exit()
answer = 0
dp = [0 for _ in range(N)]
for i in range(len(A)-1, -1, -1):
    if A[i] == 0:
        continue
    add = A[i] - dp[i]
    j = i - 1
    k = A[i] - 1
    while j >= 0:
        if A[j] == k or dp[j] == k:
            add = i - j
            break
        elif A[j] > k:
            dp[j] = k
            if j > 0:
                j -= 1
                k -= 1
            else:
                
                print(-1)
                exit()
        else:
            
            print(-1)
            exit()
    answer += add
    
print(answer)


### FIXED CODE ###

import numpy as np

N = int(input())
A = np.array([int(input()) for _ in range(N)] + [0], dtype='int64')

x = (A[:-1][A[:-1] >= A[1:]]).sum()

if A[0] != 0:
    x = -1
if (A[1:] >= A[:-1] + 2).any():
    x = -1

print(x)