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

N=int(input())
ans=list()

for i in range(1,N+1):
  count = 0
  while i%2==0:
    count+=1
  ans.append(count)

answer=ans.index(max(ans))
print(answer+1)
  

### FIXED CODE ###

N=int(input())
ans=list()

for i in range(1,N+1):
  count = 0
  while i%2==0:
    i=i//2
    count+=1
  ans.append(count)

answer=ans.index(max(ans))
print(answer+1)
### BUGGY CODE ###

def main():  
  import sys
  read = sys.stdin.buffer.read
  readline = sys.stdin.buffer.readline
  readlines = sys.stdin.buffer.readlines

  h,w = map(int,readline().split())
  a = []
  A = [list(map(int,readline().split())) for _ in range(h)]
  B = [list(map(int,readline().split())) for _ in range(h)]
  C = [[0]*w for _ in range(h)]
  for i in range(h):
      for j in range(w):
          C[i][j] = abs(A[i][j] - B[i][j])

  dp = [[set() for _ in range(w)] for _ in range(h)]
  dp[0][0].add(C[0][0])

  for i in range(h):
    for j in range(w):
      for k in dp[i][j]:
          if i < h-1:
            c = C[i+1][j]
            if k+c < 6321:
              dp[i+1][j].add(k+c)
            dp[i+1][j].add(abs(k-c))
          if j < w-1:
            d = C[i][j+1]
            if k+d < 6321:
              dp[i][j+1].add(k+d)
            dp[i][j+1].add(abs(k-d))

  print(min(dp[h-1][w-1]))
if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():  
  import sys
  read = sys.stdin.buffer.read
  readline = sys.stdin.buffer.readline
  readlines = sys.stdin.buffer.readlines

  h,w = map(int,readline().split())
  a = []
  for i in range(h):
    s = list(map(int,readline().split()))
    a.append(s)
  b = []
  for i in range(h):
    t = list(map(int,readline().split()))
    b.append(t)
  C = [[0]*w for _ in range(h)]
  for i in range(h):
      for j in range(w):
          C[i][j] = abs(a[i][j] - b[i][j])

  dp = [[[0]*6321 for i in range(w)] for _ in range(h)]
  dp[0][0][C[0][0]] = 1

  for i in range(h):
    for j in range(w):
      for k in range(6321):
        if dp[i][j][k]:
          if i < h-1:
            c = C[i+1][j]
            if k+c < 6321:
              dp[i+1][j][k+c] = 1
            dp[i+1][j][abs(k-c)] = 1
          if j < w-1:
            d = C[i][j+1]
            if k+d < 6321:
              dp[i][j+1][k+d] = 1
            dp[i][j+1][abs(k-d)] = 1

  for i in range(6321):
    if dp[h-1][w-1][i]:
      print(i)
      break
      
if __name__ == "__main__":
    main()
### BUGGY CODE ###

N = int(input())
S = input()
count1 = S.count("#")  #すべて白にする
count2 = S.count(".")  #すべて黒にする
A = []
for i in range(N):
	A.append(S[: i].count("#") + S[i:].count("."))
count = min(A)
print(min(count1, count2, count))


### FIXED CODE ###

N = int(input())
S = input()
A = [S.count(".")]
for i in range(N):
	if S[i] == "#":
		A.append(A[i] + 1)
	else:
		A.append(A[i] - 1)
print(min(A))
### BUGGY CODE ###

import collections
n = int(input())
s = [input() for _ in range(n)]
c = collections.Counter(s)

most_count = c.most_common()[0][1]
answer = []
for i in range(len(c)):
  if most_count == c.most_common()[i][1]:
    answer.append(c.most_common()[i][0])
answer.sort()
for i in answer:
  print(i)

### FIXED CODE ###

import collections
n = int(input())
s = [input() for _ in range(n)]
c = collections.Counter(s)
C = c.most_common()
most_count = C[0][1]
answer = []

for i in range(len(C)):
  if most_count == C[i][1]:
    answer.append(C[i][0])

answer.sort()
for i in answer:
    print(i)
### BUGGY CODE ###

from math import log2
n, k = map(int, input().split())
a = list(map(int, input().split()))
b = [[a[i]] for i in range(n)]
c = list(a)

for i in range(n-1):
    for j in range(i+1, n):
        b[i].append(a[j]+b[i][-1])
        c.append(b[i][-1])

m = 40 #ceil(log2((10**9)*1000))=40よりbit幅を40としておけば十分
ans = 0
for i in range(m, 0, -1):
    count = 0
    for p in c:
        if (ans + 2**(i-1)) & p == ans + 2**(i-1):
            count += 1
            if count == k:
                ans += 2**(i-1)
                break
print(ans)


### FIXED CODE ###

from math import log2
n, k = map(int, input().split())
a = list(map(int, input().split()))
b = [[a[i]] for i in range(n)]
c = list(a)

for i in range(n-1):
    for j in range(i+1, n):
        b[i].append(a[j]+b[i][-1])
        c.append(b[i][-1])

m = 40 #ceil(log2((10**9)*1000))=40よりbit幅を40としておけば十分
ans = 0
for i in range(m, -1, -1):
    log = 2**i
    tmp = [x for x in c if x&log==log]
    if len(tmp) >= k:
        ans += log
        c = tmp
print(ans)
### BUGGY CODE ###

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

while A or C > 0:
    aoki_hitpoint = C - B
    if aoki_hitpoint <= 0:
        print("Yes")
    else:
        C = aoki_hitpoint

    takahashi_hitpoint = A - D
    if takahashi_hitpoint <= 0:
        print("No")
    else:
        A = takahashi_hitpoint

### FIXED CODE ###

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

while A or C > 0:
    aoki_hitpoint = C - B
    if aoki_hitpoint <= 0:
        C = 0
        print("Yes")
        exit()
    else:
        C = aoki_hitpoint

    takahashi_hitpoint = A - D
    if takahashi_hitpoint <= 0:
        print("No")
        A = 0
        exit()
    else:
        A = takahashi_hitpoint
### BUGGY CODE ###

from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))
d = defaultdict(int)
for a in A:
    # 約数列挙(1,N)も含まれる
    prime, i = set(), 1
    while i * i <= a:
        if a % i == 0:
            d[i] += 1
            d[a//i] += 1
        i += 1

ans = 1
for i, v in d.items():
    if v+1 >= N:
        ans = max(ans, i)
print(ans)


### FIXED CODE ###

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

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

res = [0] * N
l = [0] * (N + 1)
r = [0] * (N + 1)

for i in range(N):
    l[i+1] = gcd(l[i], A[i])

for i in range(N, 0, -1):
    r[i-1] = gcd(r[i], A[i-1])

for i in range(N):
    res[i] = gcd(l[i], r[i+1])

print(max(res))
### BUGGY CODE ###

N = int(input())
S = []
ans = N
S = [input() for i in range(N)]
#for i in range(N):
#    S.append(input())
S.sort()
for i in range(N):
    flg = 0
    j  = 0
    while(flg == 0 and j < i):
        if i != j:
#            if len(S[j]) == len(S[i]):
#                if S[j][0] == S[i][0]:
            if S[j] == S[i]:
                S[j] = ''
                ans = ans - 1
                flg = 1
        j = j+1
print(ans)

### FIXED CODE ###

N = int(input())
S = []
ans = N
S = [input() for i in range(N)]
#for i in range(N):
#    S.append(input())
S.sort()
for i in range(N-1):
    if S[i] == S[i+1]:
        ans = ans - 1
print(ans)
### BUGGY CODE ###

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

li = [None]*N

ans = 0

for i, a in enumerate(A):
    if [a, i+1] in li:
        ans += 1
    li[i] = [i+1, a]

print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))

ans = 0

for i in range(N):
    if (i+1)==A[A[i]-1]:
        ans += 1

print(ans//2)
### BUGGY CODE ###


s = input()
q = int(input())
ans = []
one_count = 0
for i in range(q):
    ans.append(list(input().split()))
for i in ans:
    if int(i[0])==1:
        one_count += 1
    else:
        if one_count%2==0:
            if int(i[1]) == 1:
                #ans_q.insert(0,i[2])
                s = i[2]+s
            else:
                s = s+i[2]
                #ans_q.insert(len(ans_q),i[2])
        else:
            if int(i[1]) == 1:
                #ans_q.insert(len(ans_q),i[2])
                s = s+i[2]
            else:
                #ans_q.2insert(0,i[2])
                s = i[2]+s
if one_count%2==0:
    print(s)
else:
    print(s[::-1])


### FIXED CODE ###


from collections import deque
s = input()
q = int(input())
s = deque(s)
ans = []
ans_s = ''
one_count = 0
key = 0
for i in range(q):
    ans.append(list(input().split()))
for i in ans:
    if int(i[0])==1:
        one_count += 1
    else:
        if one_count%2==0:
            if int(i[1]) == 1:
                s.appendleft(i[2])
            else:
                s.append(i[2])
        else:
            if int(i[1]) == 1:
                s.append(i[2])
            else:
                s.appendleft(i[2])

if one_count%2==0:
    print(''.join(s))
else:
    print(''.join(s)[::-1])
### BUGGY CODE ###

import numpy as np
MOD = 10 ** 9 + 7

dp = np.zeros(13, dtype = np.int64)
dp[0] = 1

move = np.arange(0,52,4) % 13
for s in input():
  prev = dp[move]
  dp = np.zeros(26, dtype=np.int64)
  if s == '?':
    add = range(10)
  else:
    add = [int(s)]
  for x in add:
    dp[x:x+13] += prev
  dp[:13] += dp[13:]
  dp %= MOD
  
print(dp[5])


### FIXED CODE ###

MOD = 10 ** 9 + 7
S = input()

dp = [0] * 13
dp[0] = 1

for s in S:
  prev = [x for x in dp]
  dp = [0] * 13
  if s == '?':
    add = range(10)
  else:
    add = [int(s)]
  for i in range(13):
    for x in add:
      dp[(10*i+x)%13] += prev[i]
  dp = [x % MOD for x in dp]
  
print(dp[5])
### BUGGY CODE ###

def flpl(): return [float(i) for i in input().split()]
def inpl(): return [int(i) for i in input().split()]
import numpy as np
import heapq

xs, ys, xt, yt = flpl()
rs,rt = 0, 0
N = int(input())
xyr = [(xs, ys, rs),(xt, yt,rt)] + [inpl() for _ in range(N)]
X, Y, R = np.array(xyr).T
X, Y, R = np.tile(X, (N+2, 1)), np.tile(Y, (N+2, 1)), np.tile(R, (N+2, 1))
edge = np.maximum(np.zeros((N+2, N+2)), np.sqrt(np.square(X-X.T) +\
                  np.square(Y-Y.T))-(R+R.T)) +\
                  np.diag(np.ones(N+2)*np.inf)

dist = np.array([np.inf for _ in range(N+2)])
dist[0] = 0 
remain = set(range(N+2))
Q = []
heapq.heappush(Q,(0,0))
while Q:
    k = heapq.heappop(Q)
    k = k[1]
    if k not in remain:
        continue
    remain.remove(k)
    for j in remain:
        if dist[k] + edge[k][j] < dist[j]:
            dist[j] = dist[k] + edge[k][j] 
            heapq.heappush(Q,(dist[j],j)) 
    if not remain:
        break
print(dist[1])

### FIXED CODE ###

def flpl(): return [float(i) for i in input().split()]
def inpl(): return [int(i) for i in input().split()]
import heapq
def dijkstra(vnum, vs):
    dist = [float('inf') for _ in range(vnum)]
    dist[vs] = 0 
    remain = set(range(vnum))
    Q = []
    heapq.heappush(Q,(0,vs))
    while Q:
        c, vn = heapq.heappop(Q)
        if vn not in remain :
            continue
        remain.remove(vn)
        for j in remain:
            evnj = edge(vn, j)
            if dist[vn] + evnj < dist[j]:
                dist[j] = dist[vn] + evnj 
                heapq.heappush(Q,(dist[j],j)) 
        if not remain:
            break
    return dist
def edge(s, t):
    return max(((X[s] - X[t])**2 + (Y[s] - Y[t])**2)**(1/2) -(R[s]+R[t]), 0)

xs, ys, xt, yt = flpl()
N = int(input())
xyr = [(xs, ys, 0),(xt, yt, 0)] + [inpl() for _ in range(N)]
X, Y, R = list(map(list, zip(*xyr)))
D = dijkstra(N+2, 0)
print(D[1])
### BUGGY CODE ###

A, B, K = input().split()

A = int(A)
B = int(B)
K = int(K)

value = []
s = [i for i in range(A, B+1)]

value.extend(s[0:K])
value.extend(s[len(s)-K:len(s)])

num = []

for i in range(len(value)):
    if value[i] not in num:
        num.append(value[i])
        print(value[i])

### FIXED CODE ###

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

value = []

if B - A < K or B <= K:
    value.extend([i for i in range(A, B+1)])
    
else:
    value.extend([i for i in range(A, A+K)])
    value.extend([i for i in range(B-K+1, B+1)])    

num = list(set(value))
num.sort()

for i in range(len(num)):
    print(num[i])
### BUGGY CODE ###

from fractions import Fraction as F
MOD = 10**9 + 7


def main(N, T):
    A = []
    cnt_zero = [0, 0]  # 片方が0のとき
    p = 0  # 両方0
    cA = {}
    for a, b in T:
        if a == 0 and b == 0:
            p += 1
        elif a == 0:
            cnt_zero[0] += 1
        elif b == 0:
            cnt_zero[1] += 1
        else:
            A.append((F(a, b), F(b, a)))
            if F(a, b) not in cA.keys():
                cA[F(a, b)] = 0
            if -F(b, a) not in cA.keys():
                cA[-F(b, a)] = 0
            cA[F(a, b)] += 1

    used = set()
    ans = 1
    ans *= pow(2, cnt_zero[0], MOD) - 1 + pow(2, cnt_zero[1], MOD) - 1 + 1
    for a, b in A:
        if a in used or -b in used:
            continue
        ans *= pow(2, cA[a], MOD) - 1 + pow(2, cA[-b], MOD) - 1 + 1
        ans %= MOD
        used.add(a)
        used.add(-b)
    print((ans + p - 1) % MOD)


if __name__ == '__main__':

    N = int(input())
    T = [[int(i) for i in input().split()] for j in range(N)]
    main(N, T)


### FIXED CODE ###

MOD = 10**9 + 7
P = 7 ** 21 + 52


def F(a, b):
    return (a * pow(b, P-2, P)) % P


def main():
    from collections import Counter
    import sys
    input = sys.stdin.buffer.readline
    N = int(input())
    T = [[int(i) for i in input().split()] for j in range(N)]
    cnt_zero = [0, 0]  # 片方が0のとき
    p = 0  # 両方0
    cA = Counter()
    B = []
    used = set()
    for a, b in T:
        if a == 0 and b == 0:
            p += 1
        elif a == 0:
            cnt_zero[0] += 1
        elif b == 0:
            cnt_zero[1] += 1
        else:
            x = F(a, b)
            y = -F(b, a) % P
            cA[x] += 1
            if x not in used and y not in used:
                B.append((x, y))
                used.add(x)
                used.add(y)

    ans = 1
    ans *= pow(2, cnt_zero[0], MOD) - 1 + pow(2, cnt_zero[1], MOD) - 1 + 1
    for a, b in B:
        ans *= pow(2, cA[a], MOD) - 1 + pow(2, cA[b], MOD) - 1 + 1
        ans %= MOD
    print((ans + p - 1) % MOD)


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

a,b,c,x,y = map(int,input().split())
m=[]
for i in range(x+1):
  for j in range(y+1):
    if x-i == y-j:
      m.append(a*i + b*j + 2*c*(x-i))
print(min(m))

### FIXED CODE ###

a,b,c,x,y = map(int,input().split())
m=[]
for i in range(10**5+1):
  m.append(2*c*i + a*max(0,x-i) + b*max(0,y-i))
print(min(m))
### BUGGY CODE ###

n,k = map(int,input().split())
A = list(map(int,input().split()))

pre = 1
for i in range(k):
    pre*=A[i]

for j in range(n-k):
    tmp = pre//A[j]*A[j+k]
    if pre<tmp:
        print('Yes')
    else:
        print('No')
    pre=tmp




### FIXED CODE ###

n,k = map(int,input().split())
A = list(map(int,input().split()))

for i in range(n-k):
    if A[i]<A[i+k]:
        print('Yes')
    else:
        print('No')
### BUGGY CODE ###

N = int(input().strip('\n'))
lis = []
for i in range(N):
    lis.append(int(input().strip('\n')))
mx_n = max(lis)
ms_n = min(lis)
lis.remove(mx_n)
lis.remove(ms_n)
point = mx_n-ms_n
while len(lis)>=2:
    mx = max(lis)
    ms = min(lis)
    point += mx_n-ms
    point += mx-ms_n
    mx_n = mx
    ms_n = ms
    lis.remove(mx)
    lis.remove(ms)
if len(lis)==1:
    point += max(abs(mx_n-lis[0]),abs(ms_n-lis[0]))
print(point)

### FIXED CODE ###

import numpy as np
N = int(input().strip('\n'))
lis = []
for i in range(N):
    lis.append(int(input().strip('\n')))
lis = np.sort(np.array(lis))
mx_n = lis[-1]
ms_n = lis[0]
lis = lis[1:-1]
point = mx_n-ms_n
while lis.shape[0]>=2:
    mx = lis[-1]
    ms = lis[0]
    point += (mx_n-ms+mx-ms_n)
    mx_n = mx
    ms_n = ms
    lis = lis[1:-1]
if lis.shape[0]==1:
    point += max(abs(mx_n-lis[0]),abs(ms_n-lis[0]))
print(point)
### BUGGY CODE ###

from bisect import bisect_left, bisect_right

N = int(input())

S = list(input())

Q = int(input())

memo = [[]*N for _ in range(26)]

for key,val in enumerate(S):
    ch = ord(val)-97
    memo[ch].append(key)

for q in range(Q):
    query = list(input().split())
    if query[0] == '1':
        i, x = int(query[1])-1, query[2]
        now = S[i]
        now_cn = ord(now)-97
        nex_ch = ord(x)-97
        if nex_ch == x:
            continue
        memo[now_cn].remove(i)
        next_i = bisect_left(memo[nex_ch], i)
        memo[nex_ch].insert(next_i, i)
        S[i] = x
    else:
        start, end = int(query[1])-1, int(query[2])-1
        tmp_cout = 0
        for alf_array in memo:
            if len(alf_array) == 0:
                continue
            ss = bisect_left(alf_array, start)
            gg = bisect_right(alf_array, end)
            if gg- ss > 0:
                tmp_cout += 1
        print(tmp_cout)


### FIXED CODE ###

from bisect import bisect_left, bisect_right

N = int(input())
S = list(input())
Q = int(input())

D = {chr(ord('a') + i): [] for i in range(26)}
for i, s in enumerate(S):
    D[s].append(i)

for q in range(Q):
    query = list(input().split())
    if query[0] == '1':
        i, x = int(query[1]), query[2]
        i -= 1
        s = S[i]
        if s == x:
            continue

        D[s].remove(i)
        next_i = bisect_left(D[x], i)
        D[x].insert(next_i, i)
        S[i] = x

    if query[0] == '2':
        l, r = int(query[1]), int(query[2])
        l, r = l - 1, r - 1
        ans = 0
        for i in range(26):
            s = chr(ord('a') + i)

            li = bisect_left(D[s], l)
            ri = bisect_right(D[s], r)

            if ri - li > 0:
                ans += 1

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

#!/usr/bin/env python3
# N,M = map(int,sys.stdin.readline().split())
# a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = tuple(int(sys.stdin.readline()) for _ in range(N)) # multi line with single param
# a = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N)) # multi line with multi param
# s = sys.stdin.readline().rstrip()
# N = int(sys.stdin.readline())
# INF = float("inf")
import sys,collections

N = int(sys.stdin.readline())
a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param

from math import gcd

pairwise = True
setwise = True
acc = a[0]
for i in range(N):
    for j in range(i+1,N):
        b = gcd(a[i],a[j])
        if b != 1:
            pairwise = False
    acc = gcd(acc,a[i])
    if acc == 1 and not pairwise:
        print("setwise coprime")
        exit()
if pairwise == True:
    print("pairwise coprime")
# elif setwise == True:
#     print("setwise coprime")
else:
    print("not coprime")

### FIXED CODE ###

import math
from collections import defaultdict
pc = True
n = int(input())
a = list(map(int,input().split()))
g = math.gcd(a[0],a[1])
for i in range(2,n):
    g = math.gcd(g,a[i])
M = max(a)
class Sieve_of_Eratosthenes:
    def __init__(self, N):
        self.sieve = [-1] * (N+1)
 
        for i in range(2,N+1):
            if self.sieve[i] == -1:
                for j in range(1,1+N//i):
                    self.sieve[i*j] = i
 
    def isprime(self, num):
        if num <= 1:
            return False
        else:
            return self.sieve[num] == num
 
    def factorization(self, num):
        ret = set([])
        while num != 1:
            div = self.sieve[num]
            ret.add(div)
            num //= div
        return ret
 
sofe = Sieve_of_Eratosthenes(M)
ddic = defaultdict()
judge = set([])
 
for i in a:
    if not pc:
        break
    asf = sofe.factorization(i)
    
    if judge & asf != set():
        pc = False
    judge |= asf
if pc:
    print("pairwise coprime")
elif g == 1:
    print("setwise coprime")
else:
    print("not coprime")
### BUGGY CODE ###

import io, os
input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
from operator import itemgetter

N,Q=map(int,input().split())
C=[0]+list(map(int,input().split()))

QU=[list(map(int,input().split()))+[i] for i in range(Q)]


QU.sort(key=itemgetter(0))

NUM=[[] for i in range(N+1)]
for i,c in enumerate(C):
    NUM[c].append(i)
NUMIND=[0]*(N+1)

# BIT(BIT-indexed tree)

LEN=N+3

BIT=[0]*(LEN+1) # 1-indexedなtree

def update(v,w): # index vにwを加える
    while v<=LEN:
        BIT[v]+=w
        v+=(v&(-v)) # 自分を含む大きなノードへ. たとえばv=3→v=4

def getvalue(v): # [1,v]の区間の和を求める
    ANS=0
    while v!=0:
        ANS+=BIT[v]
        v-=(v&(-v)) # 自分より小さい2ベキのノードへ. たとえばv=3→v=2へ
    return ANS

for x in NUM[1:]:
    if x:
        update(x[0],1)

ANS=[-1]*Q

ia=1

for x,y,ind in QU:

    while ia!=x:
        update(NUM[C[ia]][NUMIND[C[ia]]],-1)
        NUMIND[C[ia]]+=1
        if NUMIND[C[ia]]<len(NUM[C[ia]]):
            update(NUM[C[ia]][NUMIND[C[ia]]],1)
        ia+=1

    #print(x,y,ind)
    #print([getvalue(i) for i in range(1,N+1)])
    ANS[ind]=getvalue(y)

print(*ANS)

### FIXED CODE ###

import sys
import io, os
input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
from operator import itemgetter

N,Q=map(int,input().split())
C=[0]+list(map(int,input().split()))

QU=[list(map(int,input().split()))+[i] for i in range(Q)]


QU.sort(key=itemgetter(0))


# BIT(BIT-indexed tree)

LEN=N+3

BIT=[0]*(LEN+1) # 1-indexedなtree

def update(v,w): # index vにwを加える
    while v<=LEN:
        BIT[v]+=w
        v+=(v&(-v)) # 自分を含む大きなノードへ. たとえばv=3→v=4

def getvalue(v): # [1,v]の区間の和を求める
    ANS=0
    while v!=0:
        ANS+=BIT[v]
        v-=(v&(-v)) # 自分より小さい2ベキのノードへ. たとえばv=3→v=2へ
    return ANS

NUM=[[] for i in range(N+1)]
for i,c in enumerate(C):
    if i==0:
        continue
    if NUM[c]==[]:
        update(i,1)
    NUM[c].append(i)
    
NUMIND=[0]*(N+1)

ANS=[-1]*Q

ia=1

for x,y,ind in QU:

    while ia!=x:
        update(NUM[C[ia]][NUMIND[C[ia]]],-1)
        NUMIND[C[ia]]+=1
        if NUMIND[C[ia]]<len(NUM[C[ia]]):
            update(NUM[C[ia]][NUMIND[C[ia]]],1)
        ia+=1

    #print(x,y,ind)
    #print([getvalue(i) for i in range(1,N+1)])
    ANS[ind]=getvalue(y)

sys.stdout.write(" ".join(map(str,ANS))+"\n")
### BUGGY CODE ###

R,G,B,n = map(int,input().split())

ans=0
for r in range(n//R+1):
    for g in range(n//G+1):
        tmp=n-r*R-g*G
        if tmp>=0:
            if tmp%B==0:
                ans+=1

print(ans)


### FIXED CODE ###

R,G,B,n = map(int,input().split())

ans=0
for r in range(n//R+1):
    for g in range(n//G+1):
        tmp=n-r*R-g*G
        if tmp%B==0 and tmp//B>=0:
            ans+=1

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

from math import gcd
K = int(input())
ans = 0
for i in range(1,K+1):
  for j in range(1,K+1):
    for h in range(1,K+1):
      x = gcd(i,j)
      y = gcd(x,h)
      ans += y
print(ans)

### FIXED CODE ###

from math import gcd
K = int(input())
ans = 0
for i in range(1,K+1):
  for j in range(1,K+1):
    for h in range(1,K+1):
      x = gcd(i,j)
      y = gcd(x,h)
      ans += y
print(ans)
### BUGGY CODE ###

n = int(input())
C = []
S = []
F = []

for _ in range(n-1):
    c,s,f = map(int,input().split())
    C.append(c)
    S.append(s)
    F.append(f)

for i in range(n-1):
    time = 0
    while i != n-1:
        if i == 0:
            time += S[i]
        elif S[i] <= time and time%F[i] == 0:
            time += 0
        else:
            train = S[i]
            while time >= train:
                train += F[i]
            time = train
        time += C[i]
        i += 1        
    print(time)

print(0)


### FIXED CODE ###

n = int(input())
C = []
S = []
F = []

for _ in range(n-1):
    c,s,f = map(int,input().split())
    C.append(c)
    S.append(s)
    F.append(f)

for i in range(n-1):
    time = 0
    while i != n-1:
        if i == 0:
            time += S[i]
        elif S[i] <= time and time%F[i] == 0:
            time += 0
        else:
            if time > S[i]:
                r = (time-S[i])//F[i]
                time = S[i] + F[i]*(r + 1)
            else:
                time = S[i]
        time += C[i]
        i += 1        
    print(time)

print(0)
### BUGGY CODE ###

n = int(input())
base = []
count = 0

for i in range(n):
  temp = [0]*26
  s = input()
  sign = 0
  
  for j in range(10):
    temp[ord(s[j]) - 97]  = temp[ord(s[j]) - 97] + 1
    
  for j in range(len(base)):
    if base[j][0] == temp:
      base[j][1] = base[j][1] + 1
      sign = 1
  
  if (temp not in base) and (sign == 0):
    base.append([temp,1])

ans = 0    
for i in range(len(base)):
  if base[i][1] >= 2:
    ans = ans + int(base[i][1]*(base[i][1] - 1)/2)


print(ans)

### FIXED CODE ###

def main():
  n = int(input())
  mydict = {}

  for i in range(n):
    temp = list(input())
    temp.sort()
    temp = ''.join(temp)
    
    if temp not in mydict:
      mydict[temp] = 1
    else:
      mydict[temp] =  mydict[temp] + 1
      
  ans = 0
  for i in mydict.values():
    if i >= 2:
      ans = ans + i*(i-1)//2
    
  print(ans)
  
if __name__ == '__main__':
    main()