Harryxun/stf_run huggingface dataset:
#!/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,math
sys.setrecursionlimit(1000000)
INF = float("inf")

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

left = [A[0]]*(N+1)
for i in range(N):
    left[i+1] = math.gcd(left[i],A[i])

right =[A[N-1]]*(N+1)
for i in range(N)[::-1]:
    right[i] = math.gcd(right[i+1],A[i])

#print(left,right)
#print(left[1],right[1],left[-2],right[-2])
if min(left[1],right[1])==min(left[-2],right[-2]):
    print(math.gcd(left[1],right[-2]))
else:
    print(max(min(left[1],right[1]),min(left[-2],right[-2])))
# ret = 0
# for i in range(N):
#     print(left[i],right[i+1])
#     ret = max(ret,min(left[i],right[i+1]))
#print(ret)

### FIXED 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,math,fractions
sys.setrecursionlimit(1000000)
INF = float("inf")

N = int(sys.stdin.readline())
A = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
#3 8 9 10 11 12
left = [A[0]]*(N)
for i in range(1,N):
    left[i] = fractions.gcd(left[i-1],A[i])

right =[A[N-1]]*(N)
for i in range(N-1)[::-1]:
    right[i] = fractions.gcd(right[i+1],A[i])

#print(left,right)

ret = -INF
for i in range(N):
    if i-1 >= 0 and i+1 < N:
        a = fractions.gcd(left[i-1],right[i+1])
    elif i-1 >= 0:
        a = left[i-1]
    else:
        a = right[i+1]
    ret = max(ret,a)
print(ret)
int a, b
if (a * b) % 2 = 0:
print("Even")
else  (a * b) % 2 = 1:
print("Odd")

### FIXED CODE ###

a,b = map(int, input().split())
if a * b % 2 == 0:
  print('Even')
else:
  print('Odd')
def resolve():
    import math
    N = int(input())
    ans = []
    for i in range(1, math.floor(math.sqrt(N))):
        if N%i == 0:
            ans.append(i+N//i-2)
    print(min(ans))
resolve()

### FIXED CODE ###

def resolve():
    import math
    N = int(input())
    ans = []
    for i in range(1, math.floor(math.sqrt(N))+1):
        if N%i == 0:
            ans.append(i+N//i-2)
    print(min(ans))
resolve()
lst = input().split()

lst[0] = int(lst[0])
n = lst[0]
s = lst[1]

if n % 2 == 1:
    print('NO')

t = ''

for i in range(0, n/2):
    t += s[i]

if t + t == s:
    print('YES')
else:
    print('NO')


### FIXED CODE ###

lst = [input() for i in range(2)]

n = int(lst[0])
s = lst[1]
t = ''

for i in range(n//2):
    t += s[i]

if n % 2 == 1:
    print('No')
elif t + t == s:
    print('Yes')
else:
    print('No')
import math

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

if D[0] != 0:
    print(0)
    exit()

dict = {}

for i in range(len(D)):
    if D[i] not in dict:
        dict[D[i]] = 1
    else:
        dict[D[i]] += 1

for i in range(max(D)):
    if i not in dict:
        dict[i] = 0
    
for key in dict:
    if key == 0
        if dict[key] != 1:
            print(0)
            exit()       
    if dict[key] == 0:
        print(0)
        exit()
sum = 1
n = 0

#dict = list(sorted(dict.items(), key=lambda x:x[0]))
dict_dm = sorted(dict)
#print(dict)
#print(dict_dm)
flg = 0
for i in range(len(dict_dm)):
    if i == 1:
        #print("check2")
        n = dict[i]
    elif i >=1:
        #print("check1")
        sum = (sum * n**dict[i])%998244353
        n = dict[i]

print(sum%998244353)

### FIXED CODE ###

import math

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

if D[0] != 0:
    print(0)
    exit()

dict = {}

for i in range(len(D)):
    if D[i] not in dict:
        dict[D[i]] = 1
    else:
        dict[D[i]] += 1

for i in range(max(D)):
    if i not in dict:
        dict[i] = 0
    
for key in dict:
    if key == 0:
        if dict[key] != 1:
            print(0)
            exit()       
    if dict[key] == 0:
        print(0)
        exit()
sum = 1
n = 0

#dict = list(sorted(dict.items(), key=lambda x:x[0]))
dict_dm = sorted(dict)
#print(dict)
#print(dict_dm)
flg = 0
for i in range(len(dict_dm)):
    if i == 1:
        #print("check2")
        n = dict[i]
    elif i >=1:
        #print("check1")
        sum = (sum * n**dict[i])%998244353
        n = dict[i]

print(sum%998244353)
A, B = map(int, input().split(' '))
if B % A == 0:
    print(A + B)
 else:
    print(B - A)

### FIXED CODE ###

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

if B % A == 0:
    print(A + B)
else:
    print(B - A)
x,y,z=map(int, input.split())
print(str(y)+" "+str(z)+" "+str(x))

### FIXED CODE ###

x,y,z=map(int,input().split())
print(str(z)+" "+str(x)+" "+str(y))
import math
 
def lcm(x, y):
  return (x * y) // math.gcd(x, y)
 
a, b, c, d = map(int, input().split())
 
yaku_b = b - (b // c + b // d - b // lcm(c,d))
yaku_a = a-1 - ((a-1) // c + (a-1) // d - (a-1) // lcm(c,d))
print(yaku_b - yaku_a)

### FIXED CODE ###

from fractions import gcd
 
def lcm(x, y):
    return (x * y) // gcd(x, y)
 
a, b, c, d = map(int, input().split())
 
yaku_b = b - (b // c + b // d - b // lcm(c,d))
yaku_a = a-1 - ((a-1) // c + (a-1) // d - (a-1) // lcm(c,d))
print(yaku_b - yaku_a)
lst=[]
while True:
    lst.append(input())
    if 0 in lst:
        break
for i in lst:
    sum=0
    for j in range(len(i)):
        sum+=i[j]
    print(sum)


### FIXED CODE ###

lst=[]
while True:
    lst.append(input())
    if "0" in lst:
        break
lst=lst[:-1]
for i in lst:
    sum=0
    for j in range(len(i)):
        sum+=int(i[j])
    print(sum)
k,n=map(int,input())
if k*500>=n:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

k,n=map(int,input().split())
if k*500>=n:
    print("Yes")
else:
    print("No")
A, B = map(int, input().split())

return max(A+B, A-B, A*B)

### FIXED CODE ###

a, b = (int(i) for i in input().split())
print(max(a+b, a-b, a*b))
a,b = list(map(int,input().split()))
if( a > b ):
    a,b = b,a
if a > 0 and b > 0:
    print("Positive")
elif a <= 0 and b >= 0:
    print("Zero")
else:
    if (abs(a) - abs(b)) % 2 == 0:
        print("Negative")
    else:
        print("Pisitive")-1 1

### FIXED CODE ###

a,b = list(map(int,input().split()))
if( a > b ):
    a,b = b,a
if a > 0 and b > 0:
    print("Positive")
elif a <= 0 and b >= 0:
    print("Zero")
else:
    if (abs(a) - abs(b)) % 2 == 0:
        print("Negative")
    else:
        print("Positive")
k = int(input())
print(k**k

### FIXED CODE ###

k = int(input())
print(k**3)
import sys
input = sys.stdin.readline

N,M = map(int,input().split())
dic = {}
sets = {0}
for _ in range(M):
  a,b = map(int,input().split())
  if a in sets or b in sets:
    if a and b in sets:
      tmp_a = 0
      tmp_b = 1
      # つなげる処理
      for key in dic.keys():
        if a in dic[key]:
          tmp_a = key
        elif b in dic[key]:
          tmp_b = key
      if tmp_a != tmp_b:
        dic[tmp_a].union(dic[tmp_b])
        del dic[tmp_b]
      else:
        dic[tmp_a].add(a)
        dic[tmp_a].add(b)
    else:
      # 入っている方に追加する処理
      for vls in dic.values():
        if a in vls or b in vls:
          vls.add(a)
          vls.add(b)
  else:
    dic[_] = {a,b}
  sets.add(a)
  sets.add(b)

mx = 0

for vals in dic.values():
  mx = max(mx,len(vals))
print(mx)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 9)
 
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)
 
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
 
    def Unite(self, x, y):
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        if(x == y):
            return 
 
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x
 
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)
 
    
    def Count(self, x):
        return -self.root[self.Find_Root(x)]
 
n, m = map(int, input().split())
uf = UnionFind(n)
 
for i in range(m):
    a, b = map(int, input().split())
    uf.Unite(a, b)
 
ans = 0
 
for i in range(n):
    ans = max(ans, uf.Count(i))
 
print(ans)
N = int(input())
H = list(map(int, input().split()))

ans = 0
l,r = 0,0
while True:
    if l > N-1 or r > N-1:
        l,r = 0,0

    while H[l] == 0:
        l += 1
    r = l
    while r < N and H[r] != 0:
        r += 1

    tmp = min(H[l:min(r,N)])
    for i in range(l,min(r,N)):
        H[i] -= tmp
    ans += tmp
    l = r + 1

    if sum(H) == 0:
        break

print(ans)

### FIXED CODE ###

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

ans = 0
current_height = 0
for i in range(N):
  # h[i-1]までの高さにはh[i]も育っているので、その差分だけ水をやる必要がある
  # current_height は一つ手前の花の高さ
  if h[i] > current_height:
    ans += h[i] - current_height
    current_height = h[i]
  else:
    # i-1番目の花の高さのほうがi番目より高いなら、水を新たにやる必要はない（i-1に水をやるときに同時に達成できるので）
    current_height = h[i]



print(ans)
N = int(input())
S = str(input())
dp = [[0 for i in range(N)] for i in range(N+1)]

for i in reversed(range(N)):
    for j in reversed(range(N)):
        if S[i] == S[j]:
            dp[i][j] = dp[i+1][j+1] + 1
ans = 0
for i in range(N):
    for j in range(N):
        tmp = dp[i][j]
        if j >= i:
            tmp = min(j-i,tmp)
        ans = max(tmp,ans)
print(ans)

### FIXED CODE ###

N = int(input())
S = str(input())
dp = [[0 for i in range(N+1)] for i in range(N+1)]

for i in reversed(range(N)):
    for j in reversed(range(N)):
        if S[i] == S[j]:
            dp[i][j] = dp[i+1][j+1] + 1
ans = 0
for i in range(N):
    for j in range(N):
        if j > i:
            tmp = min(j-i,dp[i][j])
            ans = max(tmp,ans)
print(ans)
n = int(input())
V = list(map(int,input().split()))
C = list(map(int,input().split()))
goods_list = []
for i in range (n):
    x = V[i] - C[i]
    if x > 0:
        goods_list.append(x)
print(sum(goods_list))


### FIXED CODE ###

from math import floor
a, b, t = map(int,input().split())
num = floor(t / a)
print(num * b)
a, b, c=input().split()
d=a+b
e=b+c
di=int(d)
ei=int(e)
ai=int(a)
if di >=ei:
    print(di+c)
else:
    print(ai+ei)



### FIXED CODE ###

a, b, c=input().split()
matome=[a,b,c]
mx=max(a,b,c)
mn=min(a,b,c)
mex=mx+mn
ans1=int(mex)
import statistics
md=statistics.median(matome)
ans2=int(md)
print(ans1+ans2)
import math
a,b = map(int,input().split())
x = math.gcd(a,b)

def so(n):
    a = []
    while n%2==0:
        a.append(2)
        n//=2
    f = 3
    while f*f<=n:
        if n%f==0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n!=1:
        a.append(n)
    return a
y = set(so(x))
print(len(y)+1)

### FIXED CODE ###

import fractions
a,b = map(int,input().split())
x = fractions.gcd(a,b)

def so(n):
    a = []
    while n%2==0:
        a.append(2)
        n//=2
    f = 3
    while f*f<=n:
        if n%f==0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n!=1:
        a.append(n)
    return a
y = set(so(x))
print(len(y)+1)
import math
A,B,C,D = map(int,input().split(' '))

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

c_num = (B//C - (A-1)//C)
d_num = (B//D - (A-1)//D)
cd_num = (B//lcm(C, D) - (A-1)//lcm(C, D))
print((B-A+1) - (c_num+d_num-cd_num))

### FIXED CODE ###

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

#最大公約数
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

#最小公倍数
def lcm(a,b):
    return a*b//gcd(a,b)

c_num = (B//C - (A-1)//C)
d_num = (B//D - (A-1)//D)
cd_num = (B//lcm(C, D) - (A-1)//lcm(C, D))
print((B-A+1) - (c_num+d_num-cd_num))
S = input()

for s in S[0::2]:
    if s != 'R' and s != 'U' and s != 'D':
        print('No')
        quit()

for i in S[1::2]:
    if S[i] != 'L' and S[i] != 'U' and S[i] != 'D':
        print('No')
        quit()

print('Yes')


### FIXED CODE ###

S = input()

for s in S[0::2]:
    if s != 'R' and s != 'U' and s != 'D':
        print('No')
        quit()

for s in S[1::2]:
    if s != 'L' and s != 'U' and s != 'D':
        print('No')
        quit()

print('Yes')
import heapq
def main():
    if k==2:print(1)
    elif k==3:print(3)
    elif k==8:print(1)
    elif k==9:print(9)
    else:
        brdict = {}
        for i in range(1,k):
            if i==k-1:brdict[i] = [(0,1)]
            else:
                brdict[i] = [((i*10)%k,0)]
                if (i*10)%k!=i+1:brdict[i] += [(i+1,1)]
        start=1
        cost=[i for i in range(k)]
        cost[0]=k
        fixed=[False]*k
        fixed[start]=True
        akouho = [(1,start)]
        heapq.heapify(akouho)
        while not all(fixed):
            (fnode,fcost) = heapq.heappop(akouho)
            if fnode==0:break
            fixed[fnode]=True
            for br in brdict[fnode]:
                if not fixed[br[0]]:
                    if cost[br[0]] > fcost + br[1]:
                        cost[br[0]] = fcost + br[1]
                        heapq.heappush(akouho,(br[0],cost[br[0]]))
        print(cost[0])
if __name__ == '__main__':
    main()

### FIXED CODE ###

import heapq
def main():
    k= int(input())
    brdict = {}
    for i in range(1,k):
        if i==k-1:
            if (10*(k-1))%k==0:
                brdict[i]= [(0,0)]
            else:
                brdict[i] = [(0,1)]
        else:
            if i!=(i*10)%k:
                brdict[i] = [((i*10)%k,0)]
            if (i*10)%k!=i+1:
                brdict[i] = brdict.get(i,[])+[(i+1,1)]
    start=1
    cost=[i for i in range(k)]
    cost[0]=k
    fixed=[False]*k
    fixed[start]=True
    akouho = [(1,start)]
    heapq.heapify(akouho)
    while not all(fixed):
        (fcost,fnode) = heapq.heappop(akouho)
        if fnode==0:break
        fixed[fnode]=True
        for br in brdict[fnode]:
            if not fixed[br[0]]:
                if cost[br[0]] > fcost + br[1]:
                    cost[br[0]] = fcost + br[1]
                    heapq.heappush(akouho,(cost[br[0]],br[0]))
        if akouho==[]:break
    print(cost[0])
if __name__ == '__main__':
    main()
if __name__ == '__main__':
	S = input()
	LEN = len(S)
	r = LEN
	l = LEN-1
	count = 0
	lst = []
	amari = 0
	while(l >= 0):
		amari = (amari + S[l]*10**(l-1)%2019)%2019
		
		if amari in lst:
			count += 1
		elif amari == 0:
			count += 1
			lst.append(count)
		else:
			lst.append(amari)
		l -= 1

	print(count)

### FIXED CODE ###

def POW(x, n, mod):
    ans = 1
    # n が 0 になるまで計算を続ける
    while n > 0:
        if n % 2 == 1:
            ans *= x%mod
        x = (x*x)%mod						#x = x**2
        n >>= 1						#ビットシフト
    return ans

if __name__ == '__main__':
	S = input()
	L = len(S)
	lst = [0] * 2019
	lst[0] = 1
	amari = 0
	ans = 0
	for i in range(1,L+1):
		amari = ( int(S[L-i]) * POW(10,i-1,2019) + amari ) % 2019
		lst[amari] += 1

	for i in range(2019):
		m = lst[i]
		ans += m * (m-1) / 2

	print(int(ans))
N = input()
lst = []
for _ in range(N):
  d1, d2 = map(int, input.split(' '))
  lst.append((d1, d2))
  
idx = 0
while idx < N-3:
  cnt = 0
  for _ in range(3):
    d1, d2 = lst[idx]
    if d1 == d2:
      cnt += 1
  
  if cnt == 3:
    print('Yes')
    break
  else:
    idx += 1
print('No')

### FIXED CODE ###

N = int(input())
lst = []
for _ in range(N):
  d1, d2 = map(int, input().split(' '))
  lst.append((d1, d2))
  
idx = 0
flag = False
while idx < N-2:
  cnt = 0
  for i in range(3):
    d1, d2 = lst[i+idx]
    if d1 == d2:
      cnt += 1
  if cnt == 3:
    flag = True
    break
  else:
    idx += 1
 
print('Yes' if flag else 'No')
N,Z,W=map(int,input().split())
A=list(map(int,input().split()))
ans1=abs(A[N-1]-W)
ans2=abs(A[N-1]-A[N-2])
print(A[N-1],W,A[N-2])

### FIXED CODE ###

N,M=map(int,input().split())
t=100*N+1800*M
a=(2**M-1)/(2**M)
ans=t/((2**M)*((1-a)**2))
print(int(ans))
import sys
import math
def frog(n,l):
    dp=[math.inf]*n
    dp[0]=0
    for i in range(n):
        for j in range(i+1,i+3):
            if(j<n):
                dp[j]=min(dp[j],dp[i]+abs(l[i]-l[j]))
    return dp[n-1]
if __name__ == "__main__":
    t = int(sys.stdin.readline())
    for _ in range(t):
        n = int(sys.stdin.readline())
        l = list(map(int, input().split()))
        sys.stdout.write(str(frog(n,l))+"\n")

### FIXED CODE ###

import sys
n = int(input())
l = list(map(int, input().split()))
dp = [sys.maxsize] *n
dp[0] = 0
for i in range(n):
    for j in range(i+1,i+3):
        if(j<n):
            dp[j]=min(dp[j],dp[i]+abs(l[i]-l[j]))
print(dp[n-1])
from collections import deque

K=int(input())

todo=deque(list(map(str,range(1,10))))

count=0

while todo:
    num=todo.popleft()
    count+=1

    if count==k:
        print(num)
        exit()
    
    base=int(num[-1])
    n1=base-1
    if n1!=-1:
        todo.append(num+str(n1))
    
    n2=base
    todo.append(num+str(n2))

    n3=base+1

    if n3!=10:
        todo.append(num+str(n3))

### FIXED CODE ###

from collections import deque

K=int(input())

todo=deque(list(map(str,range(1,10))))

count=0

while todo:
    num=todo.popleft()
    count+=1

    if count==K:
        print(num)
        exit()
    
    base=int(num[-1])
    n1=base-1
    if n1!=-1:
        todo.append(num+str(n1))
    
    n2=base
    todo.append(num+str(n2))

    n3=base+1

    if n3!=10:
        todo.append(num+str(n3))
import sys
input = sys.stdin.readline
N=int(input())
count=0
for _ in range(n):
    a=[int(input())]
for x in a:
    if a.count(x)%2==1:
        count+=1
print(count)

### FIXED CODE ###

import collections
n=int(input())
count=0
a=[int(input()) for _ in range(n)]
a=collections.Counter(a)

for key,value in a.items():
    if value%2==1:
        count+=1
print(count)
import math
n = int(raw_input())

for i in range(n):
    x1,y1,x2,y2,x3,y3,x4,y4 = map(float, raw_input().split())
    if x2-x1==0.0 and x4-x3==0.0:
        print "YES"
    elif y2-y1==0.0 and y4-y3==0.0:
        print "YES"
    elif (y2-y1)*(x4-x3)/(y4-y3)/(x2-x1)==1.0:
        print "YES"
    else:
        print "NO"

### FIXED CODE ###

n = int(raw_input())

for i in range(n):
    x1,y1,x2,y2,x3,y3,x4,y4 = map(float, raw_input().split())
    if abs((y4-y3)*(x2-x1)-(y2-y1)*(x4-x3)) < 1e-10:
        print "YES"
    else:
        print "NO"
import sys

list_1 = input().split(" ")
list_2 = list(map(int, list_1))

w = list_2[0]
h = list_2[1]
x = list_2[2]
y = list_2[3]
r = list_2[4]

checker_boy(x + r, w)
checker_boy(x - r, w)
checker_boy(y + r, h)
checker_boy(y - r, h)

print("Yes")

def checker_boy(x_r, n):
  if x_r == 0:
    return 0
  if n * x_r / x_r * x_r >= 0:
    pass
  else:
    print("No")
    sys.exit()

  

### FIXED CODE ###

import sys

input_list = input().split(" ")
input_list = list(map(int, input_list))

w = input_list[0]
h = input_list[1]
x = input_list[2]
y = input_list[3]
r = input_list[4]

if 0 <= x - r and x + r <= w:
    if 0 <= y - r and y + r <= h:
        print("Yes")
        sys.exit()

print("No")
s1 = raw_input()
s2 = raw_input()
s2 = s2.split(" ")
f = 0
for a,b in enumerate(s2):
    if s2[b] == str(a):
        f++
print f

### FIXED CODE ###

s1 = input()
s2 = input()
s2 = s2.split(" ")
f = 0
for a,b in enumerate(s2):
    if str(s2[int(b)-1]) == str(a+1):
        f = f+1
print (int(f/2))
N = int(input())

if N == 1:
  print('Hello World')
else:
  A = int(imput())
  B = int(imput())
  print(A + B)

### FIXED CODE ###

N = int(input())

if N == 1:
    print("Hello World")
else:
    A = int(input())
    B = int(input())
    print(A + B)
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
s = 0
for i in set(a):
    s += c[i] * (c[i] - 1)
dp = [-1] * n
for i in a:
    if dp[i] == -1:
        dp[i] = (s - c[i] * (c[i] - 1) + (c[i] - 1) * (c[i] - 2)) // 2
        print(dp[i])
    else:
        print(dp[i])

### FIXED CODE ###

import collections
n = int(input())
a = list(map(int, input().split()))
c = collections.Counter(a)
s = 0
for i in set(a):
    s += c[i] * (c[i] - 1)
for i in a:
    print(int((s - (c[i] * (c[i] - 1)) + ((c[i] - 1) * (c[i] - 2))) / 2))
numbers = int(input().split(" "))
a = numbers[0]
b = numbers[1]
c = a*b
if c%2==0:
  print("Even")
else:
  print("Odd")

### FIXED CODE ###

numbers = input().split(" ")
a= int(numbers[0])
b= int(numbers[1])
c=a*b
if c%2==0:
  print("Even")
else:
  print("Odd")
s_hist = collections.Counter()

N = int(input())
for n in range(N):
    s = input().strip()
    s_hist[" ".join(sorted(s))] += 1

ans = 0
for pair in s_hist.most_common():
    ans += s_hist[pair[0]]*(s_hist[pair[0]]-1)/2
    if(pair[1] == 1):
        break
print(int(ans))

### FIXED CODE ###

import collections

N = int(input())
s_hist = collections.Counter()

for n in range(N):
    s = input().strip()
    s_hist[" ".join(sorted(s))] += 1

ans = 0
for pair in s_hist.most_common():
    ans += s_hist[pair[0]]*(s_hist[pair[0]]-1)/2
    if(pair[1] == 1):
        break
print(int(ans))
N,M = map(int,input().split())
A = list(map(int,input().split()))
BC = [list(map(int,input().split())) for _ in range(M)]
ans = [0]*(N*M)
A.sort()
count = 0
for b,c in BC:
    ans[count:b] = [c]*b
    count += b
ans.extend(A)
ans = sorted(ans,reverse = True)
print(sum(ans[:N]))

### FIXED CODE ###

N,M = map(int,input().split())
A = list(map(int,input().split()))
BC = [(A[i], 1) for i in range(N)]
for _ in range(M):
    B, C = map(int, input().split())
    BC.append((C,B))
BC = sorted(BC,reverse = True)
ans = 0
a = 0
count = N
for c,b in BC:
  lamb = min(count,b)
  ans += c * lamb
  count -= lamb

print(ans)
n, k = map(int, input().split())
p = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = c[0]
jud = []
for i in range(n):
    if i not in jud:
        l = [c[p[i]-1]]
        j = p[i] - 1
        jud.append(p[i]-1)
        while j != i:
            l.append(c[p[j]-1])
            j = p[j] - 1
            jud.append(j)
        le = len(l)
        l *= (k//le +2)
        for ii in range(le):
            val = l[ii]
            ans = max(ans,val)
            for cnt in range(ii+1, ii + k):
                val += l[cnt]
                ans = max(val, ans)

print(ans)

### FIXED CODE ###

n, k = map(int, input().split())
p = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = c[0]
jud = []
for i in range(n):
    if i not in jud:
        l = []
        j = p[i] - 1
        while j not in jud:
            jud.append(j)
            l.append(c[p[j]-1])
            j = p[j] - 1
        le = len(l)
        su = sum(l)
        l *= 2
        if su > 0:
            v = (k//le)*su
            ans = max(ans, v)
        for ii in range(le):
            val = 0
            for cnt in range(0, le):
                val += l[ii + cnt]
                if su > 0:
                    v = val + ((k - cnt - 1)//le)*su
                    ans = max(ans, v)
                else:
                    ans = max(ans, val)

print(ans)
from math import factorial
n,k=[int(_) for _ in input().split()]
max = factorial(n-1)//factorial(n-3)//2
if k > max or k < max-n+1:
    print(-1)
else:
    cnt=max-k
    for i in range(2,n+1):
        print(1,i)
    nn=2
    while cnt > 0:
        print(nn,nn+1)
        nn+=1
        cnt-=1

### FIXED CODE ###

from math import factorial
n,k=[int(_) for _ in input().split()]
if n == 2 and k == 1:
    print(-1)
elif n == 2 and k == 0:
    print(1)
    print(1,2)
else:
    max = factorial(n-1)//factorial(n-3)//2
    if k > max:
        print(-1)
    else:
        cnt=max-k
        print(n+cnt-1)
        for i in range(2,n+1):
            print(1,i)
        nn=2
        while cnt > 0:
            print((nn%(n-1)+2),((nn%(n-1)+2)+((nn-2)//(n-1)-1))%(n-1)+2)
            nn+=1
            cnt-=1