Harryxun/stf_run huggingface dataset:
n = int(input()) #長さ
a = input().split() #帽子の数
x = 0
y = 0
z = 0
ans = 1
 
for i in range(n): #1文字目
  if a[i] == str(x):
    if x == y and x == z:
      ans *= 3
    elif x == y:
      ans *= 2
    x = x + 1
  elif a[i] == str(y):
    if y == z:
      ans *= 2
    y += 1
  else:
    z += 1
print(ans % 1000000007)

### FIXED CODE ###

# -*- coding: utf-8 -*-
m_1, d_1 = map(int, input().split())
m_2, d_2 = map(int, input().split())

if m_1 == m_2:
  print(0)
else:
  print(1)
a = int(input())
b = map(int, input().split())
x = 0

for i in b:
	if i % a == 0:
		x += 1
if x == len(b):
	print('APPROVED')
else:
	print('DENIED')

### FIXED CODE ###

a = int(input())
 
b=list(map(int, input().split())) 
x = 0
c = 0
    
for i in b:
  if ((i % 3 == 0) or (i % 5 == 0)) and (i % 2 == 0):
    x += 1

for t in b:
  if (t%2==0):
    c += 1;

if x == c:
  print('APPROVED')
else :
  print('DENIED')
from math import ceil

while True:
    v = input()
    if not v:
        break
    v = float(v)
    print(ceil(v * v / 98 + 1))

### FIXED CODE ###

from math import ceil

while True:
    try:
        v = input()
        v = float(v)
        t = v / 9.8
        y = 4.9 * t * t
        n = ceil((y+5) / 5)
        print(n)
    except:
        break
o = input()
e = input()
l = []
for i in range (len(o)):
  l.append(o[i])
  l.append(e[i])
s = ''.join(l)
print(s)

### FIXED CODE ###

o = list(input())
e = list(input())
i = 0
ans = ""
while i < len(e):
  ans += o[i]+e[i]
  i += 1
if len(o) > len(e):
  ans += o[len(o)-1]
print(ans)
N = int(input())
Arr = list(map(int, input().split()))
for i in range(N):
 if i=N-1:
  print(Arr[0])
 else:
  print(Arr[N-1-i] + " ")

### FIXED CODE ###

N = int(input())
Arr = list(map(int, input().split()))
for i in range(N-1):
 print("{} ".format(Arr[N-1-i]), end="")
print(Arr[0])
H, W, M = map(int, input().split())
Bom = [[0] * W for _ in range(H)]
BomC = [0] * W
BomR = [0] * H
for _ in range(M):
    h, w = map(int, input().split())
    h -= 1
    w -= 1
    Bom[h][w] = 1
    BomC[w] += 1
    BomR[h] += 1

C = []
R = []
ans = 0

for i, c in enumerate(BomC):
    C.append((c, i))
for i, c in enumerate(BomR):
    R.append((c, i))
C.sort(reverse=True)
R.sort(reverse=True)
cm = C[0][0]
rm = R[0][0]

for r, h in R:
    if r < rm -1:
        break
    for c, w in C:
        if c < cm - 1:
            break
        ans = max(ans, r + c - Bom[h][w])

print(ans)


### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline

H, W, M = map(int, input().split())

X = [0] * W
Y = [0] * H
Map = []

for _ in range(M):
    h, w = map(int, input().split())
    h -= 1
    w -= 1
    Y[h] += 1
    X[w] += 1
    Map.append((h, w))

MX = max(X)
MY = max(Y)
ans = MX + MY
Xans = set()
Yans = set()
for i, x in enumerate(X):
    if x == MX:
        Xans.add(i)
for i, y in enumerate(Y):
    if y == MY:
        Yans.add(i)
cnt = 0
for h, w in Map:
    if h in Yans and w in Xans:
        cnt += 1
if cnt == len(Xans) * len(Yans):
    ans -= 1
print(ans)
r=range
M=[list(map(int,input().split())) for _ in r(3)]
x
for i in r(2):
  x=M[0][i]-M[0][i+1]
  y=M[i][0]-M[i+1][0]
  for j in r(3):
    if x!=M[j][i]-M[j][i+1] or y=M[i][j]-M[i+1][j]:
      print('No')
      exit()
print('Yes')

### FIXED CODE ###

r=range
M=[list(map(int,input().split())) for _ in r(3)]
for i in r(2):
  x=M[0][i]-M[0][i+1]
  y=M[i][0]-M[i+1][0]
  for j in r(3):
    if x!=M[j][i]-M[j][i+1] or y!=M[i][j]-M[i+1][j]:
      print('No')
      exit()
print('Yes')
N = int(input())

score = len(str(N))

i = 2
while i ** 2 < N:
    a, b = divmod(N, i)
    if b == 0:
        score = len(str(a))
	i += 1
print(score)


### FIXED CODE ###

N = int(input())

score = len(str(N))

i = 2
while i ** 2 <= N:
    a, b = divmod(N, i)
    if b == 0:
        score = min(score, len(str(a)))
    i += 1
print(score)
a,b = int(input())
if a*b%2==0:
  print("No")
else:
  print("Yes")


### FIXED CODE ###

a,b = map(int,input().split())
if a*b%2==0:
  print("No")
else:
  print("Yes")
N, M = map(int, input().split())
ans = [-1]*N
for i in range(M):
    s, c = map(int, input().split())
    if ans[s-1] == -1:
        ans[s-1] = c
    elif ans[s-1] != c:
        print(-1)
        break
else:
    if len(ans) == 1:
        print(0)
    else:
        if ans[0] == 0:
            ans = [-1]
        elif ans[0] == -1:
            ans[0] = 1
        for i in range(M):
            if ans[i] == -1:
                ans[i] = 0
        print(int(''.join(map(str,ans))))

### FIXED CODE ###

N, M = map(int, input().split())
ans = [-1]*N
for i in range(M):
    s, c = map(int, input().split())
    if ans[s-1] == -1:
        ans[s-1] = c
    elif ans[s-1] != c:
        print(-1)
        exit()
if N == 1:
    if ans[0] == -1:
        print(0)
    else:
        print(int(''.join(map(str,ans))))
else:
    if ans[0] == 0:
        print(-1)
        exit()
    elif ans[0] == -1:
        ans[0] = 1
    for i in range(N):
        if ans[i] == -1:
            ans[i] = 0
    print(int(''.join(map(str,ans))))
while 1:
  h, w = map(int, raw_input().split())
  if h == 0 and w == 0:
    break
  for i in range(h):
    print "#" * w
 print

### FIXED CODE ###

while 1:
  h, w = map(int, raw_input().split())
  if h == 0 and w == 0:
    break
  for i in range(h):
    print "#" * w
  print""
#!/usr/bin/python3
# -*- coding:utf-8 -*-

from math import ceil

def main():
  n, m = map(int, input().split())
  for i in list(range(1, ceil(m/n)+1))[::-1]:
    if m%i == 0 and m//i >= n:
      print(i)
      return

if __name__=='__main__':
  main()



### FIXED CODE ###

#!/usr/bin/python3
# -*- coding:utf-8 -*-

from math import floor

def main():
  n, m = map(int, input().split())
  divisors = []
  for i in list(range(1, floor(m**0.5)+1))[::-1]:
    if m%i == 0:
      divisors.insert(0, i)    
      if m//i != i:
        divisors.append(m//i)
  
  for divisor in divisors[::-1]:
    if m//divisor >= n:
      print(divisor)
      return
    
if __name__=='__main__':
  main()
a = int(input())
b = int(input())

print(a*b, (a*2) + (b*2) )


### FIXED CODE ###

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

print( a*b, 2*(a+b) )
from collections import Counter
from math import factorial
def combinations(n,r):
    return factorial(n)//(factorial(n-r)*factorial(r))
N=int(input())
S=["".join(sorted(input())) for i in range(N)]
s=Counter(S)
ans=0
for key,value in s.items():
    ans+=combinations(value,2)
print(ans)

### FIXED CODE ###

from collections import Counter
from math import factorial
def combinations(n,r):
    return factorial(n)//(factorial(n-r)*factorial(r))
N=int(input())
S=["".join(sorted(input())) for i in range(N)]
s=Counter(S)
ans=0
for key,value in s.items():
    if value>=2:
        ans+=combinations(value,2)
print(ans)
from collections import Counter
a=list(map(int,input().split()))
dic=Counter(a)
for i in dic.values():
	if i==2:
      print("Yes")
	  exit()
print("No")


### FIXED CODE ###

from collections import Counter
a=list(map(int,input().split()))
dic=Counter(a)
for i in dic.values():
    if i==2:
        print("Yes")
        exit()
print("No")
N = int(input())

cnt = [[0 for _ in range(10)] for _ in range(10)]

for k in range(1, n+1):
    s = str(k)
    cnt[int(s[0])][int(s[-1])] += 1
ans = 0
for i in range(10):
    for j in range(10):
        ans += c[i][j] * c[j][i]
print(ans)


### FIXED CODE ###

N = int(input())

cnt = [[0 for _ in range(10)] for _ in range(10)]

for k in range(1, N+1):
    s = str(k)
    cnt[int(s[0])][int(s[-1])] += 1
ans = 0
for i in range(10):
    for j in range(10):
        ans += cnt[i][j] * cnt[j][i]
print(ans)
arr = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
n = int(input())

def calc(sho, res):
    q, mod = divmod(sho, 26)
    res = arr[mod - 1] + res
    if (mod == 0):
        print(res)
    else:
        res = arr[q - 1] + res
        print(res)
    return
    
calc(n, "")

### FIXED CODE ###

n = int(input())

def calc(m, res):
        q, mod = divmod(m, 26)
        if (mod == 0):
            q = q - 1
            mod = 26
            res = chr(ord("a") + (mod - 1)) + res
        else:
            res = chr(ord("a") + (mod - 1)) + res
        if (q > 0):
            calc(q, res)
        else:
            print(res)
        return
    
calc(n, "")
tmp =input().split()
H,W,D=int(tmp[0]),int(tmp[1]),int(tmp[2])

list = [[0 for x in range(W)] for y in range(H)]
dict = {}
for i in range(H):
    tmp = input().split()
    for d in range(W):
        dict[tmp[d]] = str(i)+' '+str(d)

def calcost(L,R,D):
    if int(R)<D or (int(R)-int(L))<D:
        return 0
    else:
        posi1 = dict[R].split()
        posi2 = dict[str(int(R)-D)].split()
        costs = abs(int(posi2[0])-int(posi1[0])) + abs(int(posi2[1])-int(posi1[1]))
        return costs + calcost(L,str(int(R)-D),D)

cost = {}
result ={}
Q = int(input())
for j in range(Q):
    tmpx = input()
    if tmpx in result:
        print(result[tmpx])
    else:
        tmp = tmpx.split()
        result[tmpx] = calcost(tmp[0],tmp[1],D)
        print(result[tmpx])

### FIXED CODE ###

tmp =input().split()
H,W,D=int(tmp[0]),int(tmp[1]),int(tmp[2])

list = [[0 for x in range(W)] for y in range(H)]
dictx ={}
dicty ={}
for i in range(H):
    tmp = input().split()
    for d in range(W):
        dictx[tmp[d]] = i
        dicty[tmp[d]] = d
cost ={}
def calcost(R):
    if int(R)<=D:
        cost[R] = 0
        return 0
    else:
        costs = abs(dictx[R]-dictx[str(int(R)-D)]) + abs(dicty[R]-dicty[str(int(R)-D)])
        cost[R] = costs + cost[str(int(R)-D)]
        return cost[R]

for n in range(1,H*W+1):
    calcost(str(n))
Q = int(input())
for j in range(Q):
    tmp = input().split()
    print(str(cost[tmp[1]]-cost[tmp[0]]))
a = input()
b = input() 
print(a*b)

### FIXED CODE ###

a, b = [int(i) for i in input().split()]
print(a*b)
D = int(input())
N = int(input())
if D == 2:
  print(N*10000)
elif D == 1:
  print(N*100)
else:
  print(N)
  

### FIXED CODE ###

D, N = map(int,input().split())
if D == 2:
  if N < 100:
    print(N*10000)
  else:
    print(1010000)
elif D == 1:
  if N < 100:
    print(N*100)
  else:
    print(10100)
else:
  if N < 100:
    print(N)
  else:
    print(101)
n=raw_input()
k=n.split(" ")
a=int(k[0])
b=int(k[1])
print a*b ,print (a+b)*2

### FIXED CODE ###

n=raw_input()
k=n.split(" ")
a=int(k[0])
b=int(k[1])
print a*b ,
print (a+b)*2
n = int(input())
a = sorted(list(map(int,input().split())) reverse=True)
print(sum(a[::2]) - sum(a[1::2]))

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
a_min = min(a)
alice = 0
bob = 0
while max(a) != 0:
    alice += max(a)
    for i in range(len(a)):
        if a[i] == max(a):
            a[i] = 0
            break
    bob += max(a)
    for i in range(len(a)):
        if a[i] == max(a):
            a[i] = 0
            break
if alice > bob:
    print(alice-bob)
else:
    print(bob-alice)
a,b,c=map(input().split())
if b=="+":
  print(int(a)+int(c))
else:
  print(int(a)-int(c))

### FIXED CODE ###

(a,b,c) = input().split()
if b=="+":
  print(int(a)+int(c))
else:
  print(int(a)-int(c))
s = input().split()
r = 0
if s[0] == '1':
  r += 900
else:
  r += 100
if s[1] == '1':
  r += 90
else:
  r += 10 
if s[2] == '1':
  r += 9
else:
  r += 1 

print(r)

### FIXED CODE ###

s = input()
r = 0
if s[0] == '1':
  r += 900
else:
  r += 100
if s[1] == '1':
  r += 90
else:
  r += 10 
if s[2] == '1':
  r += 9
else:
  r += 1 
print(r)
import math


def power():
  	A, B= map(int, input().split())
    return math.ceil(A / B)


print(power(8, 8))

### FIXED CODE ###

def power():
    A, B = map(int, input().split())
    socket = 1
    numberOfStrips = 0

    while socket < B:
        socket = socket + A - 1
        numberOfStrips = numberOfStrips + 1

    return numberOfStrips


print(power())
n,m = map(int,input().split())

road = {k:[] for k in range(1,n+1)}
for _ in range(m):
  a,b = map(int,input().split())
  road[a].append(b)
  road[b].append(a)
  


def check_num(road_set):
  num = 0
  for i in list(road_set.keys()):
    visited = [i]
    next_room = road_set[i]
    num += 1
    while True:
      
      if next_room in visited:
        return -1
      
      if next_room == 1:
        break
        
      visited.append(next_room)
      next_room = road_set[next_room]
      num += 1
  return num


def rec(i,road_set):
  if i == n+1:
    num = check_num(road_set)
    global min_num,min_road
    if num > 0 and (min_num == None or min_num>num):
      min_num = num
      min_road = road_set.copy()
    return
      
  for r in road[i]:
    road_set[i] = r
    rec(i+1,road_set)
    
min_num = None
min_road = None

rec(2,{})
if min_num == None:
  print('No')
else:
  print('Yes')
  for v in min_road.values():
    print(v)
  
    
    
    

### FIXED CODE ###

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

road = {k:[] for k in range(1,n+1)}
for _ in range(m):
  a,b = map(int,input().split())
  road[a].append(b)
  road[b].append(a)


next_visited = [1]
visited = {1:None}
temp_next = []

visit_num = {}
count = 0

while True:
  temp_next = []
  for room in next_visited:
    ava_room = road[room]
    for r in ava_room:
      try:
        visited[r]
      except:
        visit_num[r] = room
        temp_next.append(r)
        visited[r] = None
        
  if temp_next == []:
    break
  next_visited = temp_next

if len(visit_num) != n-1:
  print('No')

else:
  print('Yes')
  for v in sorted(visit_num.items()):
    print(v[1])
a,b,c=input(); print(a+str(len(b))+c)

### FIXED CODE ###

s=str(input())
n=str(len(s)-2)
print(s[0]+str(n)+s[-1])
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

a, b = input().split()
n = int(a+b)
ans = "No"
i = 0
while i*i <= n:
    if n % (i*i) == 0:
        ans = "Yes"
    i += 1
print(ans)


### FIXED CODE ###

from math import sqrt
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

a, b = input().split()
n = int(a+b)
if int(sqrt(n)) == sqrt(n):
    print("Yes")
else:
    print("No")
a, b, h, m = int(input().spllit())

#長針は60分で一周、短針は720分で一周
#長針は1分で6、短針は1分で0.5 合わせて5.5度離れる

min = (60 * h) + m
ang0 = (min * 5.5) % 360

if ang0 <= 180:
    ang = ang0
else:
    ang = 360 - ang0

import math
cos_ang = math.cos(math.radians(ang))

x = math.sqrt((a ** 2) + (b ** 2) - (2 * a * b * cos_ang))

print(x)

### FIXED CODE ###

a, b, h, m = input().split()

a = int(a)
b = int(b)
h = int(h)
m = int(m)

#長針は60分で一周、短針は720分で一周
#長針は1分で6、短針は1分で0.5 合わせて5.5度離れる

min = (60 * h) + m
ang0 = (min * 5.5) % 360

if ang0 <= 180:
    ang = ang0
else:
    ang = 360 - ang0

import math
cos_ang = math.cos(math.radians(ang))

x = math.sqrt((a ** 2) + (b ** 2) - (2 * a * b * cos_ang))

print(x)
a = [[j for j in map(int,input().split())] for i in range(3)]
n = int(input())
b = [[int(j) for j in input()] for i in range(n)]

for i in range(3):
    for j in range(3):
        for k in range(n):
            if a[i][j] == b[k]:
                a[i][j] = 0

if sum(a[0]) == 0 or sum(a[1]) == 0 or sum(a[2]) == 0:
    print('Yes')
elif (a[0][0] + a[1][1] + a[2][2]) == 0 or (a[0][2] + a[1][1] + a[3][0]) == 0:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

import numpy as np
a = [[j for j in map(int,input().split())] for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]

for i in range(3):
    for j in range(3):
        for k in range(n):
            if a[i][j] == b[k]:
                a[i][j] = 0
a = np.array(a)
if sum(a[0,:]) == 0 or sum(a[1,:]) == 0 or sum(a[2,:]) == 0:
    print('Yes')
elif sum(a[:,0]) == 0 or sum(a[:,1]) == 0 or sum(a[:,2]) == 0:
    print('Yes')
elif (a[0][0] + a[1][1] + a[2][2]) == 0 or (a[0][2] + a[1][1] + a[2][0]) == 0:
    print('Yes')
else:
    print('No')
# -*- coding: euc-jp -*-                                 
import sys
# ?????????                                                 
for i in sys.stdin:
    # ????????§???????????????2????????°?????????????????????????????????      
    lst = i.split(' ')
    lst = map(int, lst)
    lst.sort()

    # 1????????????????°???????????????°???/2?????§??°?????????            
    n = 1
    while n <= lst[0]/2:
        # ???????????????????????°???????????????????????????             
        if lst[0]%n == 0 and lst[1]%(lst[0]/n) == 0:
           print lst[0]/n
           break
        n = n+1
    else:
        print 1
    sys.exit(0)

### FIXED CODE ###

import sys                                               
for i in sys.stdin:
    lst = i.split(' ')
    lst = map(int, lst)
    lst.sort()

    n = 1
    maxn = 1
    while n*n <= lst[0]:
        if lst[0]%n == 0 and lst[1]%(lst[0]/n) == 0:
            print lst[0]/n
            break
        elif lst[0]%n == 0 and lst[1]%n == 0:
            maxn = n
        n = n+1
    else:
        print maxn
    sys.exit(0)
import math

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

c=int((a*b)/math.gcd(a,b))

c=0
print(c)

### FIXED CODE ###

import math

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

c=0

while(1):
  c+=a
  if c%b==0:
    print(c)
    break
import sys
from bisect import bisect
input = sys.stdin.readline

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

bc = [0 for _ in range(n)]
for i in range(len(b)):
    if b[i] >= c[n-1]:
        break
    p = bisect(c,b[i])
    bc[i] = (n-p)

for i in range(len(b)-1,0,-1):
    bc[i-1] += bc[i]
ans = 0
for x in a:
    if x < b[n-1]:
        p = bisect(b,a[i])
        ans += bc[p]

print(ans)

### FIXED CODE ###

import sys
from bisect import bisect
input = sys.stdin.readline

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

bc = [0 for _ in range(n)]
for i in range(len(b)):
    if b[i] >= c[n-1]:
        break
    p = bisect(c,b[i])
    bc[i] = (n-p)

for i in range(len(b)-1,0,-1):
    bc[i-1] += bc[i]
ans = 0
for i in range(len(a)):
    if a[i] >= b[n-1]:
        break
    p = bisect(b,a[i])
    ans += bc[p]

print(ans)
N=int(input())
ab=[list(map(int, input().split())) for _ in range(N-1)]
to=[[] for _ in range(N)]
color=[0 for _ in range(N-1)]
for i in range(N-1):
    a, b=ab[i]
    a-=1
    b-=1
    to[a].append([b, i])
    to[b].append([a, i])

def dfs(v, p=-1, c=-1):
    k=1
    for i in range(len(to[v])):
        u, index=to[v][i]
        if u==p:
            continue
        if k==c:
            k+=1
        color[index]=k
        dfs(u, v, k)
        k+=1

dfs(0)
print(max(color))
for i in range(N-1):
    print(color[i])

### FIXED CODE ###

import sys
sys.setrecursionlimit(200000)

N=int(input())
ab=[list(map(int, input().split())) for _ in range(N-1)]
ans=[0 for _ in range(N-1)]

def dfs(v, c=-1, p=-1):
  k=1
  for i in range(len(to[v])):
    u, id=to[v][i]
    if u==p:
      continue
    if k==c:
      k+=1
    ans[id]=k
    k+=1
    dfs(u, ans[id], v)

to=[[] for _ in range(N)]
for i in range(N-1):
  a, b=ab[i][0]-1, ab[i][1]-1
  to[a].append([b, i])
  to[b].append([a, i])

dfs(0)
print(max(ans))
for a in ans:
  print(a)
n=int(input())
p=[list(map(int,input().split()))for i in range(n)]
if n==1:
  print(p[0][0],p[0][1],p[0][2])
else:
  for i in range(0,101):
    for j in range(0,101):
      k=1
      l=p[0][2]+abs(i-p[0][1])+abs(j-p[0][1])
      for x,y,h in p:
        m=h+abs(i-x)+abs(j-y)
        if l!=m:
          k=0
      if k:
        ans=[i,j,l]
  print(ans[0],ans[1],ans[2])

### FIXED CODE ###

n=int(input())
p=[list(map(int,input().split()))for i in range(n)]
d=[]
for i in range(n):
  if p[i][2]==0:
    d.append(i)
d.sort(reverse=1)
for i in d:
  del p[i]
if len(p)==1:
  print(p[0][0],p[0][1],p[0][2])
else:
  for i in range(0,101):
    for j in range(0,101):
      k=1
      l=p[0][2]+abs(i-p[0][0])+abs(j-p[0][1])
      for x,y,h in p:
        if h==0:
          continue
        m=h+abs(i-x)+abs(j-y)
        if l!=m:
          k=0
      if k:
        ans=[i,j,l]
  print(ans[0],ans[1],ans[2])
def f(n):
    cnt = 0
    for a in A:
            # a/nが偶数の場合
        if a % n == 0:
            cnt += a//(n-1)
        # a/nが奇数の場合
        else:
            cnt += a//n
    return True if K >= cnt else False


N, K = map(int, input().split())
A = list(map(int, input().split()))
l = 0
r = max(A)
# 二分探索
while r - l > 1:
    cnt = 0
    m = (r+l)//2
    if f(m):
        r = m
    else:
        l = m
print(r)


### FIXED CODE ###

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


def f(n):
    cnt = 0
    for a in A:
            # a/nが偶数の場合
        if a % n == 0:
            cnt += a//n-1
        # a/nが奇数の場合
        else:
            cnt += a//n
    return True if K >= cnt else False


l = 0
r = max(A)
# 二分探索
while r - l > 1:
    m = (r+l)//2
    if f(m):
        r = m
    else:
        l = m
print(r)
N = int(input())
K = int(input())
S = input()
s1 = S[:K - 1]
s2 = S[K:]

if S[K - 1] == 'A':
    s = s1 + 'a' + s2

elif S[K - 1] == 'B':
    s = s1 + 'b' + s2

else:
    s = s1 + 'c' + s2

print(s)


### FIXED CODE ###

nums = input().split()
N = int(nums[0])
K = int(nums[1])
S = input()
s1 = S[:K - 1]
s2 = S[K:]

if S[K - 1] == 'A':
    s = s1 + 'a' + s2

elif S[K - 1] == 'B':
    s = s1 + 'b' + s2

else:
    s = s1 + 'c' + s2

print(s)
s = input()

if s=="RRR":
  print(3)
elif s=="RRS" or s=="SRR":
  print(2)
elif s=="SSR" or s=="SRS" or s=="RSS" or s="RSR":
  print(1)
else:
  print(0)

### FIXED CODE ###

s = input()

if s=="RRR":
  print(3)
elif s=="RRS" or s=="SRR":
  print(2)
elif s=="SSR" or s=="SRS" or s=="RSS" or s=="RSR":
  print(1)
else:
  print(0)
N, T = list(map(int, input().split()))

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

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

ans = 0
buff = 0
for i in range(N):
    if T > t[i]:
        buff = t[i]
        if i == N-1:
            ans = buff
    elif T <= t[i]:
        if buff + T > t[i]:
            ans += t[i]
        elif buff + T <= t[i]:
            ans += T + buff
        buff = 0

ans += T
print(ans)



### FIXED CODE ###

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

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

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

# t.pop(0)
ans = 0
buff = 0
for i in range(N):
    if i != 0:
        if t[i] - t[i-1] < T:
            ans += t[i] - t[i-1]
        else:
            ans += T

ans += T
print(ans)
x,a,b=map(int,input().split())
if |a-x|<|b-x|:print('A')
else:print('B')

### FIXED CODE ###

x,a,b=map(int,input().split())
if abs(a-x)<abs(b-x):print('A')
else:print('B')
#include <iostream>
#include <vector>
using namespace std;

long long facto(long long n)
{
long long i,ans;
ans=1;
for(i=1;i<=n;i++) {
ans=ans*i;
}
return ans;
}


long long com(int n , int r){
    return ( facto(n) / ( facto(n-r) * facto(r) ) );
}

void comb(vector<vector <long long int> > &v){
  for(int i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(int k = 1;k <v.size();k++){
    for(int j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

int main(){
    long long N;
    cin >> N;
    int A[N];
    for(int i = 0 ; i< N ; i++){
        cin >> A[i];
    }

    long long data[N+1];
    for(int i = 0 ; i<N+1 ;i++){
        data[i] = 0;
    }

    for(int i = 0;i<N;i++){
        data[A[i]] += 1;
    }

    long long total = 0;

    for(int i =0;i<N;i++){
        if( data[i] >=2 ){
            total += com(data[i],2 );
        }
    }

    
    for(int i=0 ; i<N;i++){
        if(data[A[i]]-1>0){
            cout << total - com(data[A[i]]-1,1) << endl;
        }else{
            cout << total << endl;
        }
    
    }

    return 0;
}

### FIXED CODE ###

import math
 
def permutations_count(n, r):
    if r == 2:
        return int( (n*(n-1) ) / r )
    if r == 1:
        return n
 
 
N = int(input())
A = list(map(int,input().split()))
 
data = [0] * (N+1)
 
for i in range(N):
    data[A[i]] += 1
 
total = 0
 
for i in range(N+1):
    if data[i] >= 2:
        total += permutations_count(data[i],2)
 
 
 
for i in range(N):
    if data[A[i]] - 1 > 0 :
        print( total - permutations_count(data[A[i]]-1,1) )
    else:
        print(total)