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

def sum_to(n):
    return (n+1)*int((n/2))+(n%2)*((n+1)/2)

def expected(n):
    return sum_to(n) / n

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

max_sum = 0
select = []
for i in P:
    e_val = expected(i)
    select.append(e_val)
    if len(select) == K:
        s = sum(select)
        if s > max_sum:
            max_sum = s
        select.pop(0)

print(max_sum)

### FIXED CODE ###

from collections import deque

def sum_to(n):
    return (n+1)*int((n/2))+(n%2)*((n+1)/2)

def expected(n):
    return sum_to(n) / n

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

max_sum = 0
cur_sum = 0
select = deque()
c = 0
for i in P:
    e_val = expected(i)
    select.append(e_val)
    cur_sum += e_val
    if len(select) == K:
        if cur_sum > max_sum:
            max_sum = cur_sum
        cur_sum -= select.popleft()

print(max_sum)
### BUGGY CODE ###

# -*- encoding: utf-8 -*-
import sys
from math import sqrt,log
from fractions import gcd  # python<=3.4

MOD=1000000007

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


n = int(input().rstrip())
a = list(map(int, input().rstrip().split()))
# print(n,a)

el = 1
for ai in a:
    el = lcm(el, ai)

# print("el=", el)

sum = 0
for ai in a:
    bi = el // ai
    # print(bi, end=" ")
    sum += bi
    sum %= MOD
# print()
print(sum)


### FIXED CODE ###

from fractions import gcd  # python<=3.4

MOD=1000000007

def ADD(x, y):
  return (x + y) % MOD

def SUB(x, y):
  return (x - y + MOD) % MOD

def MUL(x, y):
  return x * y % MOD

def POW(x, e):
  v = 1
  while e:
    if e & 1:
      v = MUL(v, x)
    x = MUL(x, x)
    e >>= 1
  return v

def INV(x):
  return POW(x, MOD-2)

def DIV(x, y):
  return MUL(x, INV(y))


n = int(input().rstrip())
a = [int(x) for x in input().rstrip().split()]

el = 1
for ai in a:
  g = gcd(el,ai)
  el = el // g * ai

el %= MOD

sum = 0
for ai in a:
  sum += DIV(el, ai)

sum %= MOD
print(sum)
### BUGGY CODE ###

n,k,q=map(int, input().split()) #a1 a2 a3
ans = [int(input()) for i in range(q)]

mem=[k]*n

for a in ans:
  mem=[mem[i]-1 for i in range(n)]
  mem[a-1]+=1

for m in mem:
  print('Yes' if m>0 else 'No' )

### FIXED CODE ###

n,k,q=map(int, input().split()) #a1 a2 a3
ans = [int(input()) for i in range(q)]

mem=[0]*n

for a in ans:
  mem[a-1]+=1


print("\n".join("Yes" if k-q+m>0 else "No" for m in mem))
### BUGGY CODE ###

# 200216 C

import collections

N = int(input())
S = [""] * N
for i in range(N):
    S[i] = input()

c = collections.Counter(S)
cv = c.values()
ans = []
for i in c:
    if c[i] == max(cv):
        ans.append(i)
ans = sorted(ans)
for i in ans:
    print(i,end=" ")
print("")


### FIXED CODE ###

# 200216 C

import collections

N = int(input())
S = [""] * N
dic = {}
for i in range(N):
    S = input()
    if S in dic:
        dic[S] += 1
    else:
        dic[S] = 1

maxs = max(list(dic.values()))
ans = []
for i in dic:
    if dic[i] == maxs:
        ans.append(i)
ans = sorted(ans)
for i in ans:
    print(i,end=" ")
print("")
### BUGGY CODE ###

def solve(string):
    n, *a = map(int, string.split())
    a = [list(map(int, "{:060b}".format(_a))) for _a in a]
    m = 10**9 + 7
    ans = 0
    for d in zip(*a):
        ans <<= 1
        s = sum(d)
        ans += s * (n - s) % m
        ans %= m
    return str(ans)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


### FIXED CODE ###

def solve(string):
    n, *a = map(int, string.split())
    a = ["{:060b}".format(_a) for _a in a]
    m = 10**9 + 7
    ans = 0
    for i, d in enumerate(zip(*a)):
        s = "".join(d).count("1")
        ans += s * (n - s) * pow(2, 59 - i, m)
        ans %= m
    return str(ans)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))
### BUGGY CODE ###

# import math
# import numpy as np
# import itertools
# import heapq
# =map(int,input().split())
n=int(input())
ans=0
q=[]
for i in range(n):
    x=input()
    if x not in q:
        ans+=1
    q.append(x)
print(ans)



### FIXED CODE ###

# import math
# import numpy as np
# import itertools
# import heapq
# =map(int,input().split())
n=int(input())
ans=0
q=[]
for i in range(n):
    x=input()
    # if x not in q:
        # ans+=1
    q.append(x)
w=set(q)
ans=len(w)
print(ans)
### BUGGY CODE ###

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

for num in range(1, n+1):
	print(boss_num.count(num))

### FIXED CODE ###

n = int(input())
l = [0]*n
boss_num = list(map(int, input().split()))

for num in boss_num:
	l[num-1] += 1	
for m in l: print(m)
### BUGGY CODE ###

#! /usr/bin/env python3
# -*- coding: utf-8 -*-
import collections
N,M = [int(x) for x in input().split()]
idls =[]
for i in range(N):
    idls.append(i+1)
ans =[]
LR =[]
for i in range (M):
    L,R = [int(x) for x in input().split()]
    LR.append((L,R))

for i in range (M):
    
    iidls = idls[LR[i][0]-1:LR[i][1]]
    ans+=iidls
c= collections.Counter(ans)

a = c.most_common()

count = 0
for i in a:
    if i[1] == M:
        count+= 1
       

print(count)







### FIXED CODE ###

#! /usr/bin/env python3
# -*- coding: utf-8 -*-
N,M = [int(x) for x in input().split()]
Llist =[]
Rlist =[]
for i in range (M):
    L,R = [int(x) for x in input().split()]
    Llist.append(L)
    Rlist.append(R)
 
lmax = max(Llist)
Rmax = min(Rlist)

if lmax > Rmax:
    print(0)
else:
    print(Rmax-lmax+1)
### BUGGY CODE ###

from math import factorial
import sys

input=sys.stdin.readline

num=int(input())
stl =[''.join(sorted(input())) for i in range(num)]

duplicate=[x for x in set(stl) if stl.count(x) > 1]

count=0

for dup in duplicate:
    count += factorial(stl.count(dup)) // 2 // factorial(stl.count(dup) - 2)
print(count)

### FIXED CODE ###

num=int(input())
stl =[''.join(sorted(input())) for i in range(num)]

#duplicate=[x for x in set(stl) if stl.count(x) > 1]

t = {}
for i in range(num):
  if stl[i] in t:
    t[stl[i]] += 1
  else:
    t[stl[i]] = 1
print(sum(t[k] * (t[k] -1) // 2 for k in t))
### BUGGY CODE ###

n = int(input())
c = 0
for x in range(n):
    a = int(input())
    for b in range(2, a):
        if a % b == 0:
            break
    else:
        c += 1
print(c)



### FIXED CODE ###

import math
n = int(input())
c = 0
for x in range(n):
    a = int(input())
    for b in range(2, int(math.sqrt(a))+1):
        if a % b == 0:
            break
    else:
        c += 1
print(c)
### BUGGY CODE ###

def main():
    s = input().replace('BC', 'X')
    count = 0
    N = len(s)
    for i in range(N - 1):
        if s[i] == 'A':
            n = 1
            while i + n < N:
                if s[i + n] == 'A':
                    n += 1
                    continue
                elif s[i + n] == 'X':
                    n += 1
                    count += 1
                else:
                    break
    print(count)

if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    s = input().replace('BC', 'X')[::-1]
    N = len(s)
    count = 0
    tmp = 0
    for i in range(N):
        if s[i] == 'X':
            tmp += 1
        elif s[i] == 'A':
            count += tmp
        else:
            tmp = 0
    print(count)

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

N = int(input())
a = list(map(int,input().split()))
a_dic={}
for i in a:
  if i in a_dic:
    a_dic[i]+=1
  else:
    a_dic[i]=1
dic={}
for i in range(N):
  if a[i] not in dic:
    sum=0
    for j in a_dic:
      if j==a[i]:
        sum+=((a_dic[j]-1)*(a_dic[j]-2))/2
      else:
        sum +=(a_dic[j]*(a_dic[j]-1))/2
    dic[a[i]]=int(sum)
    print(int(sum))
  else:
    print(dic[a[i]])


### FIXED CODE ###

N = int(input())
a = list(map(int,input().split()))
tot=0
dic={}
for i in a:
  if i not in dic:
    dic[i]=1
  else:
    dic[i]+=1
for i in dic:
  tot+=int((dic[i]*(dic[i]-1))/2)

for i in range(N):
  c=dic[a[i]]-1
  print(tot-c)
### BUGGY CODE ###

N = int(input())
lis = []
for i in range(N):
    s = input()
    if not s in lis:
        lis.append(s)
print(len(lis))

### FIXED CODE ###

N = int(input())
lis = []
for i in range(N):
    s = input()
    lis.append(s)
lis = set(lis)
print(len(lis))
### BUGGY CODE ###

n = int(input())
ans = 0
for i in range(1,1001):
    for j in range(1,1001):
        if ans < i**j < n:
            ans = i**j
print(ans)    

### FIXED CODE ###

n = int(input())
ans = 1
for i in range(1,1001):
    for j in range(2,1001):
        if i**j > n:
            break
        if ans < i**j <= n:
            ans = i**j
print(ans)
### BUGGY CODE ###

def gcd(a,b):
    if not b:
        return a
    else:
        return gcd(b, a%b)

n = int(input())

ans = 0

for i in range(1,n+1):
    for j in range(1, n + 1):
        tmp = gcd(i,j)
        for k in range(1, n + 1):
            ans += gcd(tmp,k)

print(ans)

### FIXED CODE ###

def gcd(a,b):
    if not b:
        return a
    else:
        return gcd(b, a%b)

n = int(input())

ans = 0

for i in range(1,n-1):
    for j in range(i+1, n):
        tmp = gcd(i,j)
        for k in range(j+1, n + 1):
            ans += gcd(tmp,k) * 6

for i in range(1,n):
    for j in range(i+1,n+1):
        ans += 6*gcd(i,j)
# print(ans)
ans += (n*(n+1))//2

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

import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n=ii()
arr=limii()
cnt=0
for i in range(n-1):
    for j in range(i+1,n):
        if abs(i-j)==arr[i]+arr[j]:
            cnt+=1
print(cnt)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n=ii()
arr=limii()
ans=0
chk={}
for p in range(n):
    i=p+1

    if i-arr[p] in chk:
        ans+=chk[i-arr[p]]
        #print(p,i,arr[p],i-arr[p],chk)
    
    if i+arr[p] in chk:
        chk[i+arr[p]]+=1
    else:
        chk[i+arr[p]]=1
    #print(i+arr[p])
#print(list(chk.values()),ans)
print(ans)
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
from fractions import gcd
mod = 10**9+7
g = A[0]
for a in A[1::]:
  g = g*a//gcd(g,a)
  
ans = 0
b = g%mod
for a in A:
  ans += (g//a)%mod
  ans %= mod
  
print(ans%mod)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
from fractions import gcd
mod = 10**9+7
g = A[0]
for a in A[1::]:
  g = g*a//gcd(g,a)
  
ans = 0
b = g%mod
for a in A:
  ans += g%mod*pow(a,mod-2,mod)
  ans %= mod
  
print(ans%mod)
### BUGGY CODE ###

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

dp = [0] * N
dp[1] = abs(H[1]-H[0])


for i in range(2, N):
    l = [dp[i-k] + abs(H[i-k]-H[i]) for k in range(1, 1+K) if 0 <= i-k]
    if len(l) > 0:
        dp[i] = min(l)
    else:
        dp[i] = 0

print(dp[-1])

### FIXED CODE ###

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

dp = [0] * N
dp[1] = abs(H[1]-H[0])

for i in range(2, N):
    dp[i] = min([dp[i-k] + abs(H[i-k]-H[i]) for k in range(1, 1+K) if 0 <= i-k])

print(dp[-1])
### BUGGY CODE ###

import bisect

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

a.sort()

for i in range(m) :
  a[n-1] = a[n-1]//2
  b = a[0:n-1]
  index = bisect.bisect_right(b,a[n-1])
  if index == n-1 :
    continue
  at = a[index]
  a[index] = a[n-1]
  a[index+2:n] = a[index+1:n-1]
  a[index+1] = at

print(sum(a))

### FIXED CODE ###

import heapq

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

heapq.heapify(a)
for i in range(m) :
  at = -1*(-1*heapq.heappop(a)//2)
  heapq.heappush(a, at)

print(sum(a)*-1)
### BUGGY CODE ###

# D - Gathering Children

S = [s for s in str(input())]
N = len(S)
cnt = 0
tmp = 0
for i in range(N - 1):
    if S[i] == S[i + 1]:
        tmp += 1
    else:
        tmp = 0
    cnt = max(cnt, tmp)

if cnt % 2 != 0:
    cnt += 1

ans = [1] * N
for _ in range(cnt):
    tmp = [0] * N
    for i in range(N):
        if S[i] == 'R':
            tmp[i + 1] += ans[i]
        if S[i] == 'L':
            tmp[i - 1] += ans[i]
    ans = tmp

print(*ans)


### FIXED CODE ###

# D - Gathering Children

S = [s for s in str(input())]

N = len(S)
cnt = 0
ans = [0] * N

for i in range(N - 1):
    if S[i] == 'R':
        cnt += 1
    if S[i] == 'R' and S[i + 1] == 'L':
        ans[i] += cnt // 2
        ans[i + 1] += cnt // 2
        if cnt % 2 != 0:
            ans[i] += 1
        cnt = 0

for i in reversed(range(1, N)):
    if S[i] == 'L':
        cnt += 1
    if S[i] == 'L' and S[i - 1] == 'R':
        ans[i] += cnt // 2
        ans[i - 1] += cnt // 2
        if cnt % 2 != 0:
            ans[i] += 1
        cnt = 0

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

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

while True:
    if m <= 0:
        break
    a[-1] = a[-1] // 2
    if len(a) > 1 and a[-1] < a[-2]:
        a = sorted(a)
    m -= 1

ans = sum(a)
print(ans)

### FIXED CODE ###

import heapq

n, m = map(int, input().split())
a = []
#a = list(map(int, input().split()))
#a = list(reversed(sorted(a)))
#heapq.heapify(a)
for i in input().split():
    heapq.heappush(a, -int(i))

ans = 0

for i in range(len(a)):
    while True:
        if m <= 0:
            break

        maxV = heapq.heappop(a)
#        print('maxV: ' + str(maxV))
        heapq.heappush(a, -(-maxV // 2))
        m -= 1
        # print('m: ' + str(m))
        # print('a: ' + str(a))
ans = -sum(a)
print(ans)
### BUGGY CODE ###

def binarySearch(t):
	left,right = 0,n
	while right > left:
		mid = (left+right) // 2
		if S[mid] == t:
			return True
		elif S[mid] > t:
			right = mid
		else:
			left = mid
	return False

n = int(input())
S = [int(s) for s in input().split()]
q = int(input())
T = [int(s) for s in input().split()]

print(sum([binarySearch(t) for t in T]))

### FIXED CODE ###

def binarySearch(t):
	left,right = 0,n
	while right > left+1:
		mid = (left+right) // 2
		if S[mid] == t:
			return True
		elif S[mid] > t:
			right = mid
		else:
			left = mid
	return False

n = int(input())
S = [int(s) for s in input().split()]
q = int(input())
T = [int(s) for s in input().split()]

print(sum([binarySearch(t) for t in T]))
### BUGGY CODE ###

s = input()
ans = 0

while True:
    p_len_s = len(s)
    for i in range(len(s)):
        if i == 0:
            pass
        else:
            if (s[i] == '0' and s[i-1] == '1') or (s[i] == '1' and s[i-1] == '0'):
                s = s[0:i-1] + s[i+1::]
                ans += 2

                if len(s) < 2:
                    print (ans)
                    exit ()

                if s == '10' or s == '01':
                    print (ans+2)
                    exit ()

                break

    a_len_s = len(s)
    if p_len_s == a_len_s:
        print (ans)
        exit ()


### FIXED CODE ###

s = list(input())
print (min(s.count('0'), s.count('1'))*2)
### BUGGY CODE ###

import sys
s1=raw_input()
s2=raw_input()


for idx, s in enumerate(s1):
    if s2[0] != s:
        continue
    
    s1_idx = idx
    s2_idx = 0
    while True:
    
        s1_now = s1[s1_idx:]
        s2_now = s2[s2_idx:]
        if len(s1_now) >= len(s2_now):
            if s2_now in s1_now:
                print "Yes"
                sys.exit(0)
            else:
                break
        else:
            if s2_now.startswith(s1_now):
                s1_idx = 0
                s2_idx += len(s1_now)

print "No"
        

### FIXED CODE ###

import sys
s1=raw_input()
s2=raw_input()

def check(s1_top, s1, s2):
    for s2_idx, c in enumerate(s2):
        if c != s1[(s1_top + s2_idx) % len(s1)]:
            return False
    return True

l=[]    
for i, c in enumerate(s1):
    if c == s2[0]:
        if check(i, s1, s2):
            print "Yes"
            sys.exit(0)

print "No"
### BUGGY CODE ###

from collections import deque
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    S = input()
    Q = int(input())

    s = deque(S)
    for _ in [0] * Q:
        T = input().split()
        if T[0] == '1':
            s.reverse()
        else:
            f, c = T[1], T[2]
            if f == '1':
                s.appendleft(c)
            else:
                s.append(c)
    print(''.join(s))


main()


### FIXED CODE ###

from collections import deque
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    S = input()
    Q = int(input())

    s = deque(S)
    left, right = s.appendleft, s.append
    rev = 0
    for _ in [0] * Q:
        T = input().split()
        if T[0] == '1':
            left, right = right, left
            rev += 1
        else:
            f, c = T[1], T[2]
            if f == '1':
                left(c)
            else:
                right(c)

    if rev % 2:
        s.reverse()
    print(''.join(s))


main()
### BUGGY CODE ###

def main():
  s = input()
  mod = 10**9+7
  dp = [0]*13
  dp[0] = 1
  digit = 1
  for i in range(len(s)-1, -1, -1):
    nextDP = [0]*13
    if s[i] == "?":
      for k in range(10):
        for j in range(13):
          nextDP[(digit * k + j)%13] += dp[j]
          nextDP[(digit * k + j)%13] %= mod
    else:
      si = int(s[i])
      for j in range(13):
        nextDP[(digit * si + j)%13] += dp[j]
        nextDP[(digit * si + j)%13] %= mod
    dp = nextDP
    digit *= 10
  print(dp[5])

if __name__ == '__main__':
  main()

### FIXED CODE ###

def main():
  s = input()
  mod = 10**9+7
  dp = [0]*13
  dp[0] = 1
  digit = 1
  for i in range(len(s)):
    nextDP = [0]*13
    if s[i] == "?":
      for k in range(10):
        for j in range(13):
          t = (k + j * 10)%13
          nextDP[t] = (dp[j] + nextDP[t]) % mod
    else:
      si = int(s[i])
      for j in range(13):
        t = (si + j * 10)%13
        nextDP[t] = (dp[j] + nextDP[t]) % mod
    dp = nextDP
    digit *= 10
  print(dp[5])

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

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

lst = []
for i in range(1,min(A, B)+1):
    if A % i == 0 and B % i == 0:
        lst.append(i)

if len(lst) == 1:
    print(1)
else:
    check = [lst[1]]
    for i in range(1, len(lst)):
        for c in check:
            if lst[i] % c == 0:
                break
        else:
            check.append(lst[i])
    print(len(check)+1)


### FIXED CODE ###

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)

    return divisors

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

listA = make_divisors(A)
listB = make_divisors(B)
lst = list(set(listA) & set(listB))

lst.sort()

if len(lst) == 1:
    print(1)
else:
    check = [lst[1]]
    for i in range(1, len(lst)):
        for c in check:
            if lst[i] % c == 0:
                break
        else:
            check.append(lst[i])
    print(len(check)+1)
### BUGGY CODE ###

import sys
N, M = map(int, input().split())
X = list(map(int,input().split()))
X.sort()
A = []
if N >= M:
    print(0)
    sys.exit()
else:
    for i in range(M - 1):
        A.append(X[i + 1] - X[i])
    for i in range(N - 1):
        A.remove(max(A))
sum = sum(A)
print(sum)

### FIXED CODE ###

import sys
N, M = map(int, input().split())
X = sorted(list(map(int,input().split())))
A = []
sum = 0
if N >= M:
    print(0)
    sys.exit()
else:
    for i in range(M - 1):
        A.append(X[i + 1] - X[i])
    A = sorted(A, reverse = True)
    for k in A[N - 1:]:
        sum += k
print(sum)
### BUGGY CODE ###

n = int(input())
li = [sorted(list(input())) for i in range(n)]

li2 = []
for i in range(len(li)):
    li2.append(li.count(li[i]))

li3 = list(set(li2))

from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under
    
num = 0   
for i in range(len(li3)):
    if li3[i] >= 2:
        num += cmb(li3[i],2)

print(num)

### FIXED CODE ###

n = int(input())
from collections import Counter
li = []
for i in range (n):
    li.append(sorted(input()))
li.sort()
for i in range(n):
    li[i]="".join(li[i])

d = Counter(li)
L = list(d.values())

cnt = 0
for i in range(len(L)):
    cnt += L[i]*(L[i]-1)//2
print(cnt)
### BUGGY CODE ###

k, s = map(int, input().split())
r = 0
for x in range(k + 1):
    for y in range(0, min(s - x + 1, k + 1)):
        z = s - x - y
        if 0 <= z <= k and z + x + y == s:
            r += 1
print(r)


### FIXED CODE ###

k, s = map(int, input().split())
n = 0
for i in range(k + 1):
    if (s-i)/2 > k:
        continue
    elif i > s:
        break
    for j in range(k+1):
        z = s - i - j
        if 0<= z <= k:
            n += 1
print(n)