Harryxun/stf_run huggingface dataset:
def spaceinput():
    return list(map(int,input().split(" ")))

def f(l,r):
    global a,nl,nr
    #print(l,r)
    #print(a[l][r])
    if a[l][r]>=0:
        return a[l][r]

    if nl[l-1]>0:
        tmp=f(l-1,r)-nl[l-1]
        a[l][r]=tmp
        return tmp

    if nr[r+1]>0:
        tmp=f(l,r+1)-nr[r+1]
        a[l][r]=tmp
        return tmp

    return f(l,r+1)



N,M,Q=spaceinput()

nr=[0]*(N+1)
nl=[0]*(N+1)

for i in range(M):
    s=spaceinput()
    nl[s[0]]+=1
    nr[s[1]]+=1

a=[[-1 for j in range(N+1)]for i in range(N+1)]
a[1][N]=M

for i in range(Q):
    s=spaceinput()
    #print(s)
    ssss=f(s[0],s[1])
    #print("ans")
    #print(type(ssss))
    print(ssss)






#print(a)


### FIXED CODE ###


import numpy as np
import sys
sys.setrecursionlimit(100000)



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



directions=np.array([[1,0],[0,1],[-1,0],[0,-1]])
directions = list(map(np.array, directions))

mod = 10**9+7


def factorial(n):
    fact = 1
    for integer in range(1, n + 1):
        fact *= integer
    return fact



def serch(x, count):
    #print("top", x, count)
            

    for d in directions:
        nx = d+x
        #print(nx)
        if np.all(0 <= nx) and np.all(nx < (H, W)):
            if field[nx[0]][nx[1]] == "E":
                count += 1 
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)  
                continue
            if field[nx[0]][nx[1]] == "#":
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)    
                 
    return count

N,M,Q=acinput()

A=np.zeros([N+1,N+1])

for i in range(M):
    tmp=acinput()
    A[tmp[0],tmp[1]]+=1
Acs=np.cumsum(A,axis=1 )
Acs=np.cumsum(Acs,axis=0)

for i in range(Q):
    tmp=acinput()
    print(int(Acs[tmp[1], tmp[1]]-Acs[tmp[1],tmp[0]-1]-Acs[tmp[0]-1,tmp[1]]+Acs[tmp[0]-1, tmp[0]-1]))
a,b=(int(x) for x in input().split())

import math 

i=0
while i<10001:
  i++
  if math.float(i)==a and math.float(i)==b:
    print(i)
else:
  print(-1)
  

### FIXED CODE ###

a,b=(int(x) for x in input().split())
 
import math 
 
i=0
while i<10001:
  i+=1
  if math.floor(i*0.08)==a and math.floor(i*0.1)==b:
    print(i)
    break
else:
  print(-1)
from math import gcd
a,b=map(int,input().split())
print((a*b) // gcd(a,b))

### FIXED CODE ###

from fractions import gcd
a,b=map(int,input().split())
print(int((a*b) // gcd(a,b)))
# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int(input().strip().split())))

a.sort(reverse=True)

alice = 0
bob = 0
for i in range(n-1):
    if i % 2 is 0:
        alice += a[i]
    else:
        bob += a[i]

print(alice - bob)

### FIXED CODE ###

n = int(input())
a = input().strip().split()
a = [ int(a[i]) for i in range(len(a)) ]

a.sort(reverse=True)

alice = 0
bob = 0
for i in range(n):
    if i % 2 is 0:
        alice = alice + int(a[i])
    else:
        bob = bob + int(a[i])
        
print(alice - bob)
import numpy as np
import math
N = int(input())

a = np.array(list(map(int, input().split())))

c = round(a.mean())

res = int(0)

for i in a:
    res += (c - i) ** 2

print(int(res))



### FIXED CODE ###

import numpy as np
import math
N = int(input())

a = np.array(list(map(int, input().split())))

c = round(a.mean())

res = int(0)

for i in a:
    res += (c - i) ** 2

print(int(res))
def sigma(N):
    return N*(N-1)//2


def find_max(N):
    for i in range(N):
        if sigma(i) > N:
            return i


def solve(N):
    Y = find_max(N)
    rem = sigma(Y)-N
    for i in range(1, Y+1):
        if i != rem:
            print(i)


N = int(input())
solve(N)


### FIXED CODE ###

def sigma(N):
    return N*(N+1)//2


def find_max(N):
    for i in range(N):
        if sigma(i) > N:
            return i
    return N


def solve(N):
    Y = find_max(N)
    rem = sigma(Y)-N
    for i in range(1, Y+1):
        if i != rem:
            print(i)


N = int(input())
solve(N)
X = int(input())

Bp = 0
Bn = 0
while True:
    Bp += 1
    A = (X+Bp**5)**0.2
    if A == int(A):
        print(A,Bp)
        exit()

    Bn -= 1
    A = (X+Bn**5)**0.2
    if A == int(A):
        print(int(A),Bn)
        exit()


### FIXED CODE ###

import math

X= int(input())

for A in range(-120,121):
    for B in range(-120,A+1):
        if A**5-B**5  == X:
            print(A,B)
            exit()
X = int(input())
m = 100
count = 0
while i in 32:
  m = math.floor(m * 1.01)
  if m > X:
    count = i + 1
    break
print(count)

### FIXED CODE ###

X = int(input())
m = 100
count = 0
import math
while m < X:
  m = m * 101 //100
  count += 1
print(count)
input_str = input()

translate_num = (int(input_str))**2

print(translate_num + "\n")

### FIXED CODE ###

input_str = input()

translate_num = (int(input_str))**3

print(translate_num)
a, b, c, k = map(int, input().split())

def actual(a, b, c, k):
    if a >= k:
        return k
    else:
        k -= a

    if b >= k:
        return a
    else:
        k -= b

    return a - k

  
print(actual(a, b, c, k))  

### FIXED CODE ###

s = input()
t = input()

if s == t[:-1]:
	print('Yes')
else:
  	print('No')
import math
a, b = map(input().split())
print(a * b / gcd(a, b))

### FIXED CODE ###

import fractions
a, b = map(int, input().split())
print(a * b // fractions.gcd(a, b))
test = 0
while(1):
    test += 1

### FIXED CODE ###

inf=100000000

def calc(uth,dis,c):
    fare=0
    if dis>=inf:
        return inf
    if unchin[c]==1:
        return uth[c][1][0]*dis
    ddis=uth[c][0]
    dcost=uth[c][1]
    i=1
    while(i<unchin[c] and dis>ddis[i]):
        fare+=(ddis[i]-ddis[i-1])*dcost[i-1]
        i+=1
    fare+=(dis-ddis[i-1])*dcost[i-1]
    return fare

def floyd(bigmap,n):
    res=bigmap
    for k in range(1,n+1):
        for i in range(1,n+1):
            for j in range(1,n+1):
                if res[i][j]>res[i][k]+res[k][j]:
                    res[i][j]=res[i][k]+res[k][j]
    return res

def init2d(bigmap,n):
    for i in range(n+1):
        bigmap.append([])
    for map1 in bigmap:
        for j in range(n+1):
            map1.append(inf)
    for i in range(1,n+1):
        bigmap[i][i]=0
    return bigmap

while(1):
    n,m,c,s,g=map(int,raw_input().split())
    if(n==m==0): break
    rosen=[]
    for i in range(c+1):
        map0=[]
        rosen.append(init2d(map0,n))

    for i in range(m):
        x,y,d,c0=map(int,raw_input().split())
        rosen[c0][x][y]=min(rosen[c0][x][y],d)
        rosen[c0][y][x]=min(rosen[c0][x][y],d)

    unchin=list(map(int,raw_input().split()))
    unchin.insert(0,0)
    uth=[]
    uth.append([])
    for i in range(1,c+1):
        ddis=list(map(int,raw_input().split()))
        ddis.insert(0,0)
        dcost=list(map(int,raw_input().split()))
        uth.append([ddis,dcost])

    bigmap=[]
    bigmap=init2d(bigmap,n)


    for c0,cmap in enumerate(rosen[1:]):
        tmp=floyd(cmap,n)
        for i in range(1,n+1):
            for j in range(1,n+1):
                bigmap[i][j]=min(bigmap[i][j],calc(uth,tmp[i][j],c0+1))

    bigmap=floyd(bigmap,n)

    ans=bigmap[s][g]
    if ans < inf:
        print(ans)
    else:
        print(-1)
from sys import stdin

N, M = stdin.readline().rstrip().split()

#全ての組み合わせのうち、奇数になるもののみ除く（奇数 + 偶数）

total = ((N+M)*(N+M-1))/2
odd = N*M

print(total - odd)




### FIXED CODE ###

from sys import stdin
N, M = map(int, input().split()) 

print(
    (N*(N-1))//2 +
    (M*(M-1))//2
)
import math as m
n,a=int(input()),list(map(int,input().split()))
b,c=[],[]
for i in range(n):
	b.append(m.gcd(b[i-1],a[i-1]) if i else 0)
	c.append(m.gcd(c[i-1],a[n-i]) if i else 0)
print(max([m.gcd(b[i],c[n-i-1]) for i in range(n)]))

### FIXED CODE ###

def gcd(x,y):
	return gcd(y,x%y) if y else x
n,a,b,c=int(input()),list(map(int,input().split())),[],[]
for i in range(n):
	b.append(gcd(b[i-1],a[i-1]) if i else 0)
	c.append(gcd(c[i-1],a[n-i]) if i else 0)
print(max([gcd(b[i],c[n-i-1]) for i in range(n)]))
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

def bs(f, mi, ma):
    mm = -1
    while ma > mi:
        mm = (ma+mi) // 2
        if f(mm):
            mi = mm + 1
        else:
            ma = mm
    if f(mm):
        return mm + 1
    return mm

def main():
    n,k,q = LI()
    a = LI()
    sa = sorted(a)
    r = sa[-1] - sa[0]
    # print(sorted([[a[i],i] for i in range(n)]))
    for i in range(n):
        if sa[i] == sa[i-1]:
            continue
        mi = sa[i]
        def f(i):
            ma = sa[i]
            c = 0
            cc = 0
            g = 0
            ss = 1
            for t in a:
                if t < mi:
                    if c > k and c > cc:
                        g += c - max(k, cc)
                    ss = 0
                    c = 0
                    cc = 0
                    continue
                if t >= ma:
                    cc += 1
                c += 1
            if ss == 1 and c > cc:
                g += c - cc
            elif c > k and c > cc:
                g += c - max(k, cc)
            # print(mi, ma, cc, i, g, q)
            return g < q

        l = bs(f, 0, n+1)
        # print(i,l,mi)
        if l > n or l <= i:
            continue
        t = sa[l-1] - mi
        if r > t:
            r = t


    return r




print(main())



### FIXED CODE ###

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n,k,q = LI()
    a = LI() + [-1]
    sa = sorted(a)
    r = sa[-1] - sa[0]
    # print(sorted([[a[i],i] for i in range(n)]))
    for i in range(1,n+1):
        if sa[i] == sa[i-1]:
            continue
        mi = sa[i]
        b = []
        c = 0
        for j in range(n+1):
            if a[j] < mi:
                if j - c >= k:
                    b += sorted(a[c:j])[:j-c-k+1]
                c = j + 1
        if len(b) < q:
            continue
        b.sort()
        t = b[q-1] - mi
        if r > t:
            r = t


    return r




print(main())
import fractions

N=int(input())
T0=int(input())
for i in range(1,N):
    T=int(input())
    ans=T0*(T//fractions.gcd(T0,T))
    T0=ans
print(ans)

### FIXED CODE ###

import fractions

N=int(input())
T0=int(input())

if N==1:
  print(T0)
  exit()

for i in range(1,N):
    T=int(input())
    g=fractions.gcd(T0,T)
    ans=T0*T//g
    T0=ans
print(ans)
N=int(input())

XY = [list(map(int,input().split())) for _ in range(N)]

x=[]
y=[]

for X,Y in XY:
    x.append(X)
    y.append(Y)
    
l1=[]
c=0
for i in range(N):
    for j in range(i+1,N-1):
        #if i==j:
        #    continue;
        a=x[i]-x[j]
        b=y[i]-y[j]
        """
        if a<=0 and b>=0:
            a=-a
            b=-b
        elif a<=0 and b<=0:
            a=-a
            b=-b
        """
        l1.append(str(a)+"_"+str(b))
        #l1.append([a,b])
v=set(l1)
c=[]
for i in v:
    c.append(l1.count(i))
#c = collections.Counter(l1)      
#values, counts = zip(*c.most_common())    
print(N-max(c))

### FIXED CODE ###

N=int(input())

XY = [list(map(int,input().split())) for _ in range(N)]

x=[]
y=[]

for X,Y in XY:
    x.append(X)
    y.append(Y)
    
l1=[]
c=0
for i in range(N):
    for j in range(N):
        if i==j:
            continue;
        a=x[i]-x[j]
        b=y[i]-y[j]
        """
        if a<=0 and b>=0:
            a=-a
            b=-b
        elif a<=0 and b<=0:
            a=-a
            b=-b
        """
        l1.append(str(a)+"_"+str(b))
        #l1.append([a,b])
v=set(l1)
c=[]
for i in v:
    c.append(l1.count(i))
#c = collections.Counter(l1)      
#values, counts = zip(*c.most_common()) 
if c==[]:
    print(1)   
else:
    print(N-max(c))
import itertools
S = input()
N = len(S)
S = '0' + S
A = [[int(i), len(list(v))] for i, v in itertools.groupby(S)]
if A[0][0] == A[-1][0] == 0 and A[1][0] == A[-2][0] == A[0][1] == A[-1][1] == 1:
    if len(A) == 3:
        #一直線
        for i in range(1, N):
            print(i, i + 1)
        exit()
    elif len(A) == 5 and A[1][1] == A[-2][1]:
        #脚の長さの最大値がA[1][1]のstar graph
        M = A[1][1]
        Q, R = N // M, N % M
        #Q本の長さMの脚、1本の長さRの脚
        a = [[N] for _ in range(Q + 1)]
        for i in range(1, N):
            a[i % (Q + 1)] += [i]
        for b in a:
            for c, d in zip(b, b[1:]):
                print(c, d)
        exit()
print(-1)


### FIXED CODE ###

S = input()
N = len(S)
S = '0' + S
if S[:2] == '01' and S == S[::-1]:
    before = 1
    for i in range(2, N + 1):
        print(before, i)
        if S[i - 1] == '1' and i < (N + 1) // 2 + 2:
            before = i
else:
    print(-1)
k,s=map(int,input().split())
ans = 0
for i in range(k+1):
  if k<=s-i<=2*k:
      ans+= s-i+1
  elif 0<=s-i<=k:
      ans+= k*2-s+1
print(ans)

### FIXED CODE ###

print(input().replace(","," "))
def fib(n):
    a1 = 2
    a2 = 1 
    if n==2:
        return 2
    elif n==1:
        return 1
    else:
        count = 1
        for i in range(n-2):
            count = a1 + a2
            a2 = a1
            a1 = count
        return count
        
N,M = list(map(int,input().split()))
ans = 1
z = False

if M == 0:
    print(fib(N)) 
else:
    a = [int(input()) for _ in range(M)]

    for i in range(M):
        if i != 0:
            if a[i]-a[i-1] != 1:
                ans *= fib(a[i]-a[i-1]-2)
            else:
                z = True
                break
        else:
            ans *= fib(a[i]-1)

    ans *= fib(N-a[-1]-1)

    if z:
        print(0)
    else:
        print(str(ans%1000000007))

### FIXED CODE ###

PQR = list(map(int,input().split()))

PQR.sort()

print(PQR[0]+PQR[1])
if __name__ =='__main__':
    N = input()
    A = input()
    ans = N**2-A
    print(ans)

### FIXED CODE ###

if __name__ =='__main__':
    N = int(input())
    A = int(input())
    ans = N**2-A
    print(ans)
#ABC128D-equeue.py

from sys import stdin

input = stdin.readline

N, K = list(map(int, input().split()))
VList = list(map(int, input().split()))
sumList = []

for i in range(K+1):
    for j in range(K-i+1):
        k = K -i -j
        myHand = [VList[n] for n in range(i)] + [VList[-m] for m in range(1,j+1)] + [0]
        myHand.sort(reverse=True)
        for _ in range(k):
            if myHand[-1] < 0:
                myHand.pop()
            else:
                break
        sumList.append(sum(myHand))


print(max(sumList))


### FIXED CODE ###

#ABC128D-equeue.py

from sys import stdin

input = stdin.readline

N, K = list(map(int, input().split()))
VList = list(map(int, input().split()))
sumList = []

for i in range(min([K,N])+1):
    for j in range(min([K,N])-i+1):
        k = K -i -j
        myHand = [VList[n] for n in range(i)] + [VList[-m] for m in range(1,j+1)] + [0]
        myHand.sort(reverse=True)
        for _ in range(k):
            if myHand[-1] < 0:
                myHand.pop()
            else:
                break
        sumList.append(sum(myHand))


print(max(sumList))
import sys
import numpy as np

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    N, K = map(int, input().split())
    A = np.array(list(map(int, input().split())), np.int64)

    MOD = 10 ** 9 + 7

    pos = A[A >= 0]
    neg = A[A < 0]

    flag = False  # 積を正にできるか

    if N == K:
        ans = 1
        for a in A.tolist():
            ans *= a % MOD
        print(ans % MOD)
        exit()

    if len(pos) > 0:
        flag = True
    else:
        if K % 2 == 0:
            flag = True

    ans = 1
    if not flag:
        # 積を正にできないとき
        # 絶対値の小さい方からK個とる
        A = np.sort(np.abs(A))
        for a in A[:K]:
            ans *= a % MOD
        ans *= -1
    else:
        pos = np.sort(pos)
        neg = np.sort(neg)[::-1]
        if K % 2 == 1:
            # Kが奇数の時
            # 一番大きい偶数を1つとる。
            ans *= pos[-1]
            pos = pos[:-1]

        # pos, neg sort -> 2個ずつペア -> 降順sort -> 上から K//2 個とる
        newpos = pos[::-1][::2] * pos[::-1][1::2]
        newneg = neg[::2] * neg[1::2]
        pairs = np.concatenate([newpos, newneg])

        pairs = np.sort(pairs)[::-1]
        for i in range(K // 2):
            ans *= pairs[i] % MOD

    print(ans % MOD)


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
import heapq

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    MOD = 10 ** 9 + 7

    pos = []
    neg = []
    for a in A:
        if a >= 0:
            pos.append(a)
        else:
            neg.append(a)

    flag = False  # 積を正にできるか

    if N == K:
        ans = 1
        for a in A:
            ans *= a
            ans %= MOD
        print(ans % MOD)
        exit()

    if len(pos) > 0:
        flag = True
    else:
        if K % 2 == 0:
            flag = True

    ans = 1
    if not flag:
        # 積を正にできないとき
        # 絶対値の小さい方からK個とる
        h = [abs(x) for x in A]
        heapq.heapify(h)

        for i in range(K):
            ans *= heapq.heappop(h)
            ans %= MOD
        ans *= -1
    else:
        hpos = [-x for x in pos]
        heapq.heapify(hpos)
        hneg = neg[:]
        heapq.heapify(hneg)
        if K % 2 == 1:
            # Kが奇数の時
            # 一番大きい偶数を1つとる。
            ans *= -heapq.heappop(hpos)
            ans %= MOD

        # pos, neg sort -> 2個ずつペア -> 降順sort -> 上から K//2 個とる
        pairs = []
        while len(hpos) >= 2:
            x = -heapq.heappop(hpos)
            x *= -heapq.heappop(hpos)
            heapq.heappush(pairs, -x)
        while len(hneg) >= 2:
            x = heapq.heappop(hneg)
            x *= heapq.heappop(hneg)
            heapq.heappush(pairs, -x)
        if len(pairs):
            for i in range(K // 2):
                ans *= -heapq.heappop(pairs)
                ans %= MOD

    print(ans % MOD)


if __name__ == "__main__":
    main()
x = map(int,raw_input().split(' '))
import math
S = 0.5 * x[0] * x[1] * sin(x[2])
L = x[0] + x[1] + math.sqrt(x[0]**2 + x[1]**2 - x[0] * x[1] * cos(x[2]))
h = x[1] * sin(x[2])
print S,L,h

### FIXED CODE ###

x = map(int,raw_input().split(' '))
import math
pi = math.pi
theta = pi/180*x[2]
S = 0.5 * x[0] * x[1] * math.sin(theta)
L = x[0] + x[1] + math.sqrt(x[0]**2 + x[1]**2 - 2 * x[0] * x[1] * math.cos(theta))
h = x[1] * math.sin(theta)
print S
print L
print h
#!/usr/bin/env python3

n, k = map(int, input().split())
A = list(map(int, input().split()))
a = [0]*n
b = A[0]
per = []
tes = -1

if n <= k:
    for _ in range(k-1):
        b = A[b-1]
    print(b)
    exit()

for _ in range(k+1):
    a[b-1] += 1
    tes += 1
    if 3 in a:
        tes -= len(per)*2
        break
    if 2 in a:
        per.append(b)
    b = A[b-1]

_len = len(per)

ans = (k - tes) % _len

print(per[ans-1])

### FIXED CODE ###

#!/usr/bin/env python3

N, K = map(int, input().split())
A = [int(a) - 1 for a in input().split()]

if K <= N:
    p = 0
    for _ in range(K):
        p = A[p]
    print(p + 1)
    exit()

p = 0
t = [-1] * N
t[0] = 0
for i in range(1, N):
    p = A[p]
    if t[p] != -1:
        break
    t[p] = i

d = i - t[p]
K -= i
K %= d

for i in range(K):
    p = A[p]
print(p + 1)
n = int(input())
if n//1.08 * 1.08 == n:
  print(n//1.08)
else (n//1.08+1)*1.08 == n:
  print(n//1.08+1)
else:
  print(":(")

### FIXED CODE ###

import math
N = int(input())
X = math.ceil(N / 1.08)
if int(X*1.08) == N:
    print(X)
else:
    print(':(')
n, m = map(int, input().split())
s = [0]*m
c = [0]*m
for i in range(m):
  s[i], c[i] = map(int, input().split())

k1 = [100, 10, 1]
an =[]
for i in range(m):
  an.append(c[i] * k1[s[i] - 1])
  print(c[s[i] - 1] * k1[s[i] - 1])
print(an)

for i in range(m):
  for j in range(m):
    if s[i] == s[j]:
      if c[i] != c[j]:
        print("-1")
        exit()
        
for i in range(m):
  if an.count(an[i]) != 1:
    an[i] = 0
if sum(an) == 0:
  print("-1")
  exit()
print(sum(an))

### FIXED CODE ###

N, M = map(int,input().split())
sc = []
for _ in range(M):
    s, c = input().split()
    s = int(s)
    if s > N:
        print('-1')
        exit()
    sc.append([s, c])
 
ans = -1
if N == 1:
    start = 0
else:
    start = 10 ** (N - 1)
for i in range(start, 10 ** N):
    str_num = str(i)
    for s, c in sc:
        if str_num[s - 1] != c:
            break
    else:
        ans = i
        break
print(ans)
N = int(input())
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7
A.sort()
B = []

if len(A) % 2 == 0:
    ans = 2 ** (len(A)/2)
    for i in range(len(A)//2):
        B.append(2 * i + 1)
        B.append(2 * i + 1)

else:
    ans = 2 ** (len(A)//2)
    B.append(0)
    for i in range(len(A)//2):
        B.append(2 * i + 2)
        B.append(2 * i + 2)

if A == B:
    print(int(ans/MOD))
else:
    print(0)


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7
A.sort()
B = []

ans = 1

if len(A) % 2 == 0:
    for i in range(len(A)//2):
        ans *= 2
        ans %= MOD
        B.append(2 * i + 1)
        B.append(2 * i + 1)

else:
    B.append(0)
    for i in range(len(A)//2):
        ans *= 2
        ans %= MOD
        B.append(2 * i + 2)
        B.append(2 * i + 2)

if A == B:
    print(int(ans))
else:
    print(0)
p = list(map(int,input().split()))

for i in range(5):
  if p[i] == 0:
    x = i
    
 print(x)

### FIXED CODE ###

p = list(map(int,input().split()))

for i in range(5):
  if p[i] == 0:
    x = i + 1
    
print(x)
import sys
H,_=map(int,raw_input().split())
for _ in range(0,H):
    line=sys.stdin.readline()
    print line
    print line


### FIXED CODE ###

import sys

vowel="aeiou"
if sys.stdin.readline()[0] in vowel:
    print "vowel"
else:
    print "consonant"
if and(A<C, C<B):
  print("Yes")
elif and(B<C, C<A):
  print("Yes")
else:
  print("No")


### FIXED CODE ###

A, B, C= map(int, input().split())
if A<C and C<B:
  print("Yes")
elif B<C and C<A:
  print("Yes")
else:
  print("No")
n,a,b = map(int, input().split())

l = max(a,b)
s = min(a,b)

if (l-s)%2 == 0:
  print((l-s)//2)
else:
  t = s - 1
  b = n - l
  pre = min(t-b)
  ans = pre + 1 + (l-s-1)//2
  print(ans)
  

### FIXED CODE ###

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

l = max(a,b)
s = min(a,b)

if (l-s)%2 == 0:
  print((l-s)//2)
else:
  t = s - 1
  b = n - l
  pre = min(t,b)
  ans = pre + 1 + (l-s-1)//2
  print(ans)
k = input()
x = input()

if 500 * int(k) >= int(x):
    print("Yes")
else:
    print("No")
    

### FIXED CODE ###

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

if 500 * int(k) >= int(x):
    print("Yes")
else:
    print("No")
n = int(input())

l = []
for i in range(n):
    tmp = list(input())
    tmp.sort()
    tmp = ''.join(tmp)
    l.append(tmp)

from collections import Counter
c = Counter(l)
num = c.values()

from math import factorial
def combinations_count(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))

ans = 0
for i in num:
    ans += combinations_count(i, 2)
    if i == 1:
        break

print(ans)


### FIXED CODE ###

n = int(input())
s = []
for _ in range(n):
    #s.append(list(input())) # !!!
    #s.append(sorted(list(input()))) # !!!
    #s.append(sorted(input())) # !!!
    s += [''.join(sorted(input()))]
    #''.join(sorted((sorted(input()))
s = sorted(s)
s.append('X')
#print(s)

a = []
x = 1
for i in range(1,n+1):
    if s[i] == s[i-1]:
        x += 1
    else:
        a.append(x)
        x = 1
#print(a)
y = 0

for j in a:
    y += j*(j-1)/2

print(int(y))