Harryxun/stf_run huggingface dataset:
n = int(input())
s = []
for i in range(n):
    s.append(input())
    
dic = dict()
ans = 0
for i in s:
    if "".join(sorted(i)) in dic:
        ans += dic[i]
        dic[i] +=1
    else:
        dic["".join(sorted(i))] = 1
print(ans)

### FIXED CODE ###

n = int(input())
s = []
for i in range(n):
    s.append(input())
    
dic = dict()
ans = 0
for i in s:
    if "".join(sorted(i)) in dic:
        ans += dic["".join(sorted(i))]
        dic["".join(sorted(i))] +=1
    else:
        dic["".join(sorted(i))] = 1
print(ans)
a,b,c=map(int,input().split())
    print(max(0,c-max(0,a-b)))

### FIXED CODE ###

def resolve():


    a,b,c=map(int,input().split())
    print(max(0,c-max(0,a-b)))
resolve()
# -*- coding: utf-8 -*-
a = int(input())
judge = True
for i in range(a):
  b = int(input())
  if (b % 2 == 0) and ((b % 3 == 0) or (b % 5 == 0)):
    judge = False
# 出力
if judge:
  print("APPROVED")
else:
  print("DENIED")

### FIXED CODE ###

# -*- coding: utf-8 -*-
a, b, c = map(int, input().split())
l = [a, b, c]
counter = 0
if a == b:
  counter += 1
if b == c:
  counter += 1
if a == c:
  counter += 1
if counter == 1:
  print("Yes")
else:
  print("No")
a = input()
b = input()
print(int(a) * int(b)+ +(int(a) + int(b)) * 2)


### FIXED CODE ###


a,b =(int(x) for x in input().split())
print(a * b, (a+b) * 2)
A=input()

if A="ABC":
  print("ARC")
else:
  print("ABC")

### FIXED CODE ###

A=input()

if A=="ABC":
  print("ARC")
else:
  print("ABC")
a,b = map(int,input().split())
d = a // b
r = a % b
f = a / b
print(' '.join(map(str[d,r,f])))

### FIXED CODE ###

a, b = map(int, input().split())
d = a // b
r = a % b
f = a / b
print(d, r, '{:.5f}'.format(f))
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product


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


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


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


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


def read_str():
    return input()


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


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


def mt(f):
    import time

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

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

    return wrap


# @mt
def slv(A, B, C, K):
    ans = A - B if K % 2 == 0 else B - A
    if abs(ans) > 1e+18:
        return 'Unfair'
    return ans


def main():
    A, B, C, K = read_int_n()

    print(slv(A, B, C, K))


if __name__ == '__main__':
    main()


### FIXED CODE ###

import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product


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


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


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


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


def read_str():
    return input()


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


# @mt
def slv(A, B, C, K):
    ans = A - B if K % 2 == 0 else B - A
    if abs(ans) > 1e+18:
        return 'Unfair'
    return ans


def main():
    A, B, C, K = read_int_n()

    print(slv(A, B, C, K))


if __name__ == '__main__':
    main()
import sys

for line in sys.stdin:
    x1, y1, x2, y2, x3, y3, xp, yp = map(float, line.split())
    AB = [x2-x1, y2-y1]
    BP = [xp-x2, yp-y2]
    BC = [x3-x2, y3-y2]
    CP = [xp-x3, yp-y3]
    CA = [x1-x3, y1-y3]
    BP = [xp-x1, yp-y1]
    c1 = AB[0] * BP[1] - AB[1] * BP[0]
    c2 = BC[0] * CP[1] - BC[1] * CP[0]
    c3 = CA[0] * AP[1] - CA[1] * AP[0]
    if (c1>0 and c2>0 and c3>0) or (c1<0 and c2<0 and c3<0):
        print 'YES'
    else:
        print 'NO'

### FIXED CODE ###

import sys

for line in sys.stdin:
    x1, y1, x2, y2, x3, y3, xp, yp = map(float, line.split())
    AB = [x2-x1, y2-y1]
    BP = [xp-x2, yp-y2]
    BC = [x3-x2, y3-y2]
    CP = [xp-x3, yp-y3]
    CA = [x1-x3, y1-y3]
    AP = [xp-x1, yp-y1]
    c1 = AB[0] * BP[1] - AB[1] * BP[0]
    c2 = BC[0] * CP[1] - BC[1] * CP[0]
    c3 = CA[0] * AP[1] - CA[1] * AP[0]
    if (c1>0 and c2>0 and c3>0) or (c1<0 and c2<0 and c3<0):
        print 'YES'
    else:
        print 'NO'
from __future__ import division, print_function
from sys import stdin

i = 1
for line in stdin:
    x = int(line)
    if not x:
       break
    print 'Case {}: {}'.format(i, x)
    i += 1

### FIXED CODE ###

from __future__ import division, print_function
from sys import stdin

i = 1
for line in stdin:
    x = int(line)
    if x == 0:
       break
    print ("Case %d: %d" % (i, x))
    i += 1
li = list(map(int,input().split()))
ans = [li[0]+li[1],li[0]-li[1],li[0]*li[1]]
ans.sort()
print(ans[3])

### FIXED CODE ###

li = list(map(int,input().split()))
ans = [li[0]+li[1],li[0]-li[1],li[0]*li[1]]
ans.sort()
print(ans[2])
#!/usr/bin/env python3

import sys
import math
import numpy as np
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

k,q = LI()
d = LI()
nxm = [LI() for _ in range(q)]

for n,x,m in nxm:
    e = list(map(lambda x:x%m,d))
    zero = 0
    for i in range(k):
        if e[i] == 0:
            zero += 1
    zero = zero*((n-1)//k)
    for i in range((n-1)%k):
        if e[i] == 0:
            zero += 1
    f = list(accumulate(e))
    s = f[-1] * ((n-1)//k)
    if (n-1)%k != 0:
        s += f[(n-1)%k-1]
    tmp = (s+x%m)//m
    print(n-1-zero-tmp)

    
    


### FIXED CODE ###

#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

k,q = LI()
d = LI()
nxm = [LI() for _ in range(q)]

for n,x,m in nxm:
    e = list(map(lambda x:(x-1)%m+1,d))
    f = list(accumulate(e))
    s = f[-1] * ((n-1)//k)
    if (n-1)%k != 0:
        s += f[(n-1)%k-1]
    tmp = (s+x%m)//m
    print(n-1-tmp)
n,k=map(int,input().split())
a=list(map(int,input().split()))
visit=[1]
pos=0
while True:
    visit.append(a[pos])
    if a[pos]-1 in visit:
        break
    pos=a[pos]-1
loop=[]
looppos=visit[-1]-1
while True:
    loop.append(a[looppos])
    looppos=a[looppos]-1
    if a[looppos] in loop:
        break
print(visit)
print(loop)
if len(visit)>k:
    print(visit[k])
else:
    t=(k%len(visit))
    print(loop[t])

### FIXED CODE ###

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

num = 1
li = [1]
flag = [True] * n
flag[0] = False

for i in range(k):
    num = a[num-1]
    if flag[num-1]:
        li.append(num)
        flag[num-1] = False
    else:
        break

d = li.index(num)
ans = (k-d)%(len(li)-d)+d

print(li[ans])
N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)]
dp = [[0]*(W+1) for _ in range(N+1)]

for i in range(N):
    for j in range(W+1):
        if j < wv[i][0]:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = max(dp[i][j], dp[i][j-wv[i][0]] + wv[i][1])
print(dp[N][W])

### FIXED CODE ###

n,w = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(n)]

sum_v = sum([wv[i][1] for i in range(n)])

# dp[i][j]: i番目の品物までで価値がj以上であるときの重さの最小値
dp = [[float('inf')]*(sum_v+1) for _ in range(n+1)]
dp[0][0] = 0

for i in range(n):
    for j in range(sum_v+1):
        # 品物を選ぶ場合
        if (j - wv[i][1] >= 0):
            dp[i+1][j] = min(dp[i][j], dp[i][j-wv[i][1]] + wv[i][0])
        # 品物を選ばない場合
        dp[i+1][j] = min(dp[i+1][j], dp[i][j])
ans = 0
for i in range(sum_v+1):
    if dp[n][i] <= w:
        ans = i
print(ans)
abc=list(map(int,input().split()))
abc.sort()
if a[0]==5 and a[1]==5 and a[2]==7:
    print("YES")
    exit()
print("NO")

### FIXED CODE ###

abc=list(map(int,input().split()))
abc.sort()
if abc[0]==5 and abc[1]==5 and abc[2]==7:
    print("YES")
    exit()
print("NO")
import unittest
import math

from A04 import solve
from A04 import parse_input

class TestA04Solve(unittest.TestCase):


    def test_solve(self):

        lines_as_string = """
3
2 1 2
"""
        r = parse_input(lines_as_string)
        for i, e in enumerate(r):
            print("e[%d]=%s" % (i, e))
        print("")
        self.assertEqual(solve(*r), 1)


        lines_as_string = """
3
2 2 2
"""
        r = parse_input(lines_as_string)
        for i, e in enumerate(r):
            print("e[%d]=%s" % (i, e))
        print("")
        self.assertEqual(solve(*r), -1)

        lines_as_string = """
10
3 1 4 1 5 9 2 6 5 3
"""
        r = parse_input(lines_as_string)
        for i, e in enumerate(r):
            print("e[%d]=%s" % (i, e))
        print("")
        self.assertEqual(solve(*r), 7)

        lines_as_string = """
1
1
"""
        r = parse_input(lines_as_string)
        for i, e in enumerate(r):
            print("e[%d]=%s" % (i, e))
        print("")
        self.assertEqual(solve(*r), 0)


if __name__ == '__main__':
    unittest.main()
                                         

### FIXED CODE ###

# -*- coding: utf-8 -*-

import sys
import math

debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
#        for line in sys.stdin:
#            lines.append(line)
        lines.append(input())
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    n = [int(e) for e in lines[0].split(" ")][0]
    a = [int(e) for e in lines[1].split(" ")]

    return (n, a)

def solve(n, a):

    current_num = 1
    count = 0
    result = []
    for i in range(n):
        if a[i] != current_num:
            count = count + 1
        else:
            current_num = current_num + 1
            result.append(a[i])
    
    if debug:
        log("result=%s" % result)
        log("count=%s" % count)
    
    if result == []:
        count = -1

    for i in range(1, len(result) + 1):
        if result[i-1] != i:
            if debug:
                log("result[%d]=%s" % (i, result[i-1]))
            count = -1
            break


    return count

def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r)
    else:
        print("%s" % result)

if __name__ == '__main__':

    main()
n = list(int(map(int,input().split()))) 
H = n[0] 
A = n[1] 
sum = 0 
while H > 0 : 
    H = H - A 
    sum = sum + 1 
print(sum)

### FIXED CODE ###

n = list(map(int,input().split()))
H = n[0] 
A = n[1] 
sum = 0 
while H > 0 : 
    H = H - A 
    sum = sum + 1 
print(sum)
k, s = map(int, input().split())
r = 0
for x in range(k+1):
  for y in range(k+!):
    z = s - x - y
    if z >= 0 and z <= k:
      r += 1
print(r)

### FIXED CODE ###

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

print x.upper()

### FIXED CODE ###

z = ""
for x in raw_input():
    if x.islower():
        z += x.upper()
    else:
        z += x.lower()

print z
n = int(input())

a = input().split()
print(1/sum(map(lambda x:1/x, a)))

### FIXED CODE ###

n = int(input())

a = input().split()
print(1/sum(map(lambda x:1/int(x), a)))
n = int(input())
tmp = 1
lipos = [1]
while tmp<10**9:
  tmp *= 4
  lipos.append(lipos[-1]+tmp)
#print(lipos)
tmp = -2
lineg = [-2]
while tmp > - 10**9:
  tmp *= 4
  lineg.append(lineg[-1]+tmp)
#print(lineg)
if n == 0:
  print("0")
elif n == 1:
  print("1")
elif n == -1:
  print("10")
elif n > 0:
  flag = True
  i = 0
  while flag:
    if lipos[i] < n <= lipos[i+1]:
      k = i+1
      flag = False
    i += 1
  diff = lipos[k]-n
  print(bin(lipos[k]^diff)[2:])
else:
  flag = True
  i = 0
  if lineg[i] > n > lineg[i+1]:
    k = i+1
    flag = False
  i += 1
  diff = n-lineg[k]
  print(bin((-lineg[k])^diff)[2:])

### FIXED CODE ###

n = int(input())
tmp = 1
lipos = [1]
while tmp<10**9:
  tmp *= 4
  lipos.append(lipos[-1]+tmp)
#print(lipos)
tmp = -2
lineg = [-2]
while tmp > - 10**9:
  tmp *= 4
  lineg.append(lineg[-1]+tmp)
#print(lineg)
if n == 0:
  print("0")
elif n == 1:
  print("1")
elif n == -1:
  print("10")
elif n > 0:
  flag = True
  i = 0
  while flag:
    if lipos[i] < n <= lipos[i+1]:
      k = i+1
      flag = False
    i += 1
  diff = lipos[k]-n
  print(bin(lipos[k]^diff)[2:])
else:
  flag = True
  i = 0
  while flag:
    if lineg[i] > n > lineg[i+1]:
      k = i+1
      flag = False
    i += 1
  diff = n-lineg[k]
  print(bin((-lineg[k])^diff)[2:])
import sys
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
N = int(input())
S = input().strip()
Q = int(input())
T = [()] * (2 * N)

n = 1
while n < N:
    n *= 2

def update(k, a):
    k += n-1
    T[k] = tuple(a)
    while k > 0:
        k = (k - 1) // 2
        T[k] = T[k*2+1] + T[k*2+2]

def query(a, b, k, l, r):
    if r <= a or b <= l:
        return ()
    if a <= l and r <= b:
        return T[k]
    else:
        vl = query(a, b, k*2+1, l, (l+r)//2)
        vr = query(a, b, k*2+2, (l+r)//2, r)
        return vl+vr

for i in range(n-1, n-1+N):
    update(i-n-1, S[i-n-1])

for q in range(Q):
    f, i, c = [x for x in input().strip().split()]
    if f == '1':
        update(int(i)-n-1, c)
    elif f == '2':
        print(len(query(int(i), int(c)-1, 0, 0, n))+1)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
N = int(input())
S = input().strip()
Q = int(input())
n = 1
while n < N:
    n *= 2
T = [0] * (2 * n)

def update(k, a):
    k += n-1
    T[k] = 1 << ord(a) - 97
    while k > 0:
        k = (k - 1) // 2
        T[k] = T[k*2+1] | T[k*2+2]

def query(a, b, k, l, r):
    # print(a, b, k, l, r)
    if r <= a or b <= l:
        # print('  ', set())
        return 0
    if a <= l and r <= b:
        # print('  ', T[k])
        return T[k]
    else:
        vl = query(a, b, k*2+1, l, (l+r)//2)
        vr = query(a, b, k*2+2, (l+r)//2, r)
        return vl | vr

for i in range(N):
    update(i, S[i])

for q in range(Q):
    f, i, c = [x for x in input().strip().split()]
    if f == '1':
        # print(T,T[int(i)-1])
        update(int(i)-1, c)
    elif f == '2':
        # print(int(i)-1, int(c)-1)
        tmp = query(int(i)-1, int(c), 0, 0, n)
        ans = 0
        for i in range(26):
            ans += tmp >> i & 1
         
        print(ans)
N = int(input())
A = list(map(int,input().split()))
B1 = 0
B = []
for i in range(0,N):
    if i%2 == 0:
        B1 += A[i]
    else:
        B1 -= A[i]
B.append(B1)
XX = B1
for i in range (0,N-1) :
    X = 2*A[i]-XX
    B.append(X)
    XX = X
print(B)


### FIXED CODE ###

N, A, B = map(int,input().split())
if B<N*A :
    print(B)
else :
    print(N*A)
N,K = map(int, input().split())
h = list(map(int, input().split()))
 
dp = [0] * N
for i in range(0, N):
    if i // K == 0:
        bef = i
    else:
        bef = K
    tmp = []
    for j in range(1, bef + 1):
        tmp.append(dp[i - j] + abs(h[i] - h[i - j]))
    dp[i] = min(tmp)
 
print(dp[-1])

### FIXED CODE ###

N,K = map(int, input().split())
h = list(map(int, input().split()))
 
dp = [0] * N
for i in range(1, N):
    if i // K == 0:
        bef = i
    else:
        bef = K
    tmp = []
    for j in range(1, bef + 1):
        tmp.append(dp[i - j] + abs(h[i] - h[i - j]))
    dp[i] = min(tmp)
 
print(dp[-1])
N = int(input())
B = list(map(int, input().split()))
k = B[0]
for i in range(1, N):
    if B[i] < B[i-1]:
        k += B[i]
    else:
        k += B[i-1]
print(k)


### FIXED CODE ###

N = int(input())
B = list(map(int, input().split()))
k = B[0]+B[N-2]
for i in range(1, N-1):
    if B[i] < B[i-1]:
        k += B[i]
    else:
        k += B[i-1]
print(k)
import os
import sys

import numpy as np

from libs.debug import debug

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N, M = list(map(int, sys.stdin.readline().split()))
ST = [list(map(int, sys.stdin.readline().split())) for _ in range(M)]

graph = [[] for _ in range(N + 1)]
for s, t in ST:
    graph[s].append(t)

# 解説AC
# 閉路ないから後ろから見てけばOK


# dp[v][u]: u からの出口を塞いだときの、v から N までのステップ数の期待値の最小値
dp = np.full((N + 1, N + 1), IINF, dtype=float)
dp[N] = 0.0
for v in reversed(range(1, N)):
    # 塞がない
    dp[v, :] = dp[graph[v], :].sum(axis=0) / len(graph[v]) + 1
    if len(graph[v]) >= 2:
        # 塞ぐ
        s = dp[graph[v], v].sum() - dp[graph[v], v].max()
        dp[v, v] = s / (len(graph[v]) - 1) + 1
print(dp[1].min())


### FIXED CODE ###

import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N, M = list(map(int, sys.stdin.readline().split()))
ST = [list(map(int, sys.stdin.readline().split())) for _ in range(M)]

graph = [[] for _ in range(N + 1)]
for s, t in ST:
    graph[s].append(t)

# 解説AC
# 閉路ないから後ろから見てけばOK


# dp[v][u]: u からの出口を塞いだときの、v から N までのステップ数の期待値の最小値
dp = np.full((N + 1, N + 1), IINF, dtype=float)
dp[N] = 0.0
for v in reversed(range(1, N)):
    # 塞がない
    dp[v, :] = dp[graph[v], :].sum(axis=0) / len(graph[v]) + 1
    if len(graph[v]) >= 2:
        # 塞ぐ
        s = dp[graph[v], v].sum() - dp[graph[v], v].max()
        dp[v, v] = s / (len(graph[v]) - 1) + 1
print(dp[1].min())
N, M = list(map(int, input().split()))
a_list = sorted(list(map(int, input().split())))
b_c_list = []
for _ in range(M):
    b, c = list(map(int, input().split()))
    b_c_list.append((b, c))
b_c_list = sorted(b_c_list, key=lambda x: x[1], reverse=True)

def b_c_gen():
    for b, c in b_c_list:
        for _ in range(b):
            yield c

total = 0
for i, c in enumerate(b_c_gen()):
    if a_list[i] >= c:
        i -= 1
        break
    total += c
i += 1

total += sum(a_list[i:])
print(total)


### FIXED CODE ###

N, M = list(map(int, input().split()))
a_list = sorted(list(map(int, input().split())))
b_c_list = []
for _ in range(M):
    b, c = list(map(int, input().split()))
    b_c_list.append((b, c))
b_c_list = sorted(b_c_list, key=lambda x: x[1], reverse=True)

def b_c_gen():
    for b, c in b_c_list:
        for _ in range(b):
            yield c

total = 0
for i, c in enumerate(b_c_gen()):
    if i >= N:
        break
    if a_list[i] >= c:
        i -= 1
        break
    total += c
i += 1

if i < N:
    total += sum(a_list[i:])
print(total)
n,k=map(int,input().split())
s=input()
s[k]=s[k-1].lower()

### FIXED CODE ###

n,k=map(int,input().split())
s=input()
s=s[:k-1]+s[k-1].lower()+s[k:]
print(s)
A=map(list(int,input().split()))
B=len(set(A))
if B==2:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

A=list(map(int,input().split()))
B=len(set(A))
if B==2:
    print('Yes')
else:
    print('No')
s = input()
for i in range(1,len(s)/2):
  if (s[i-1]!=s[-i]):
    print("No")
print("Yes")


### FIXED CODE ###

s = input()

def check(s):
  if len(s) == 1 or len(s) == 0:
    return True
  if s[0]!=s[-1]:
    return False
  return check(s[1:-1])

mid = len(s)//2

if check(s) and check(s[0:mid]) and check(s[mid+1:]):
  print("Yes")
else:
  print("No")
N = int(input())

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

print(max(A) - min(A))

### FIXED CODE ###

N = int(input())

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

print(max(A) - min(A))
q = x[0]*x[1]
  buf = math.sqrt(q)
  buf = int(buf)
  if buf*buf == x[0]*x[1]:
    buf -= 1

  ans = buf * 2 - 2
  if buf*(buf+1) < x[0]*x[1]:
    ans += 1

  print ans


### FIXED CODE ###

import math

n = int(raw_input())

for a in range(n):
  x = map(int,raw_input().split())
  x.sort()

  if x[0] == x[1]:
    print 2*x[0] - 2
    continue

  if x[0]+1 == x[1]:
    print 2*x[0] - 2
    continue

  q = x[0]*x[1]
  q = int(math.sqrt(q))

  if q*q == x[0]*x[1]:
    q -= 1

  if q*(q+1) >= x[0]*x[1]:
    print 2*q - 2
    continue

  print 2*q - 1
print((int(input())/3)**3)

### FIXED CODE ###

m, n = list(map(int, input().split(" ")))
ans = int((m * (m - 1))/ 2) + int((n * (n - 1))/ 2)
print(ans)
n = int(input())
A=[int(i) for i in input().split()]
MOD = 1000000007
ans = 1
cnt = [0]*n
cnt[0]=3

for i in range(n):
    ans = ans * cnt[A[i]] %MOD
    cnt[A[i]]-=1
    cnt[A[i]+1]+=1

print(ans if not 0 else 0)


### FIXED CODE ###

n = int(input())
A=[int(i) for i in input().split()]
MOD = 1000000007
ans = 1
cnt = [0]*(n+1)
cnt[0]=3

for i in range(n):
    ans = ans * cnt[A[i]] %MOD
    cnt[A[i]]-=1
    cnt[A[i]+1]+=1
    if ans==0:
        break
print(ans)
N = int(input())
p = list(map(str,input().split()))
p_sort = sorted(p)
count = 0
for i,j in zip(p,p_sort):
  if p[i] != p[j]:
    count += 1
if count == 0 or count == 2:
  print("YES")
else:
  print("NO")

### FIXED CODE ###

N = int(input())
p = list(map(int,input().split()))
p_sort = sorted(p)
count = 0
for i,j in zip(p,p_sort):
  if i != j:
    count += 1
if count == 0 or count == 2:
  print("YES")
else:
  print("NO")
n = int(input())
c = input()
c = [char for char in c]

def op1(l, id1, id2):
    temp = l[id1]
    l[id1] = l[id2]
    l[id2] = temp
    return l

r_idx, w_idx = [], []
for j in range(n):
    if c[j] == "R":
        r_idx.append(j)
    elif c[j] == "W":
        w_idx.append(j)

ans = 0
else:
    for i in range(min(len(r_idx), len(w_idx))): # i is number of op1
        c_i = c[:]
        c_i = op1(c_i, w_idx[j], r_idx[-j - 1])
        ans[i] += 1
    if "W" in "".join(c_i).rstrip("W"):
        ans[i] += "".join(c_i).rstrip("W").count("W")
    print(min(ans))

### FIXED CODE ###

n = int(input())
c = input()
c = [char for char in c]

ans = 0
for i in range(c.count("R")):
    if c[i] == "W":
        ans += 1

print(ans)
a, b = (map(int, input()))
if a == b:
    print(a * 2)
else:
    c = max(a, b)
    print(c * 2 - 1)

### FIXED CODE ###

a, b = (map(int, input().split()))
if a == b:
    print(a * 2)
else:
    c = max(a, b)
    print(c * 2 - 1)
# -*- coding: utf-8 -*-
n, m = map(int, input().split())
BIGNUM = 10 ** 9 + 7

last_ana = int(input())
blocks = [last_ana]

for _ in range(1, m):
    ana = int(input())
    blocks.append(ana - last_ana - 1)
    last_ana = ana

blocks.append(n - last_ana)

if 0 in blocks:
    ans = 0
else:
    b_max = max(blocks)

    c = [1, 1]
    for i in range(2, b_max):
        ctmp = c[i - 1] + c[i - 2]
        c.append(ctmp % 1000000007)

    ans = 1
    for num in blocks:
        if num == 1:
            continue
        ans = (ans * c[num - 1]) % BIGNUM
        if ans == 0:
            break

print(ans)

### FIXED CODE ###

# -*- coding: utf-8 -*-
n, m = map(int, input().split())
BIGNUM = 10 ** 9 + 7

if m > 0:
    last_ana = int(input())
    blocks = [last_ana]

    for _ in range(1, m):
        ana = int(input())
        blocks.append(ana - last_ana - 1)
        last_ana = ana
    blocks.append(n - last_ana)
else:
    blocks = [n + 1]

if 0 in blocks:
    ans = 0
else:
    b_max = max(blocks)
    c = [1, 1]
    for i in range(2, b_max):
        ctmp = c[i - 1] + c[i - 2]
        c.append(ctmp % BIGNUM)

    ans = 1
    for num in blocks:
        if num == 1:
            continue
        ans = (ans * c[num - 1]) % BIGNUM
        if ans == 0:
            break

print(ans)