Harryxun/stf_run huggingface dataset:
h, w = list(map(int,input().split()))
sy, sx = list(map(int,input().split()))
gy, gx = list(map(int,input().split()))
sx, sy, gx, gy = sx-1, sy-1, gx-1, gy-1
 
G = []
for _ in range(h):
    G.append(list(input()))
D = [[10**6]*w for i in range(h)]
D[sy][sx] = 0
Q = deque()
Q.append((sy, sx))

while Q:
    y, x = Q.pop()
    for dy, dx in product(range(-2, 3), repeat=2):
        ny, nx = y+dy, x+dx
        if dx+dy==0:
            G[y][x] = '#'
            continue
        elif ny<0 or h<=ny or nx<0 or w<=nx:
            continue
        elif G[ny][nx] == '#':
            continue
        elif abs(dx)+abs(dy)<=1:
            G[ny][nx] = '#'
            D[ny][nx] = D[y][x]
            Q.append((ny, nx))
        elif D[ny][nx] > D[y][x]+1:
            D[ny][nx] = D[y][x]+1
            Q.appendleft((ny, nx))
            
if D[gy][gx] == 10**6:
    print(-1)
else:
    print(D[gy][gx])

### FIXED CODE ###

from collections import deque
from itertools import product
h, w = list(map(int,input().split()))
sy, sx = list(map(int,input().split()))
gy, gx = list(map(int,input().split()))
sx, sy, gx, gy = sx-1, sy-1, gx-1, gy-1
 
G = [list(input()) for _ in range(h)]
D = [[10**6]*w for _ in range(h)]
D[sy][sx] = 0
Q = deque([(sy, sx)])
while Q:
    y, x = Q.pop()
    for dy, dx in product(range(-2, 3), repeat=2):
        ny, nx = y+dy, x+dx
        if dx==dy==0:
            G[y][x] = '#'
            continue
        elif ny<0 or h<=ny or nx<0 or w<=nx:
            continue
        elif G[ny][nx] == '#':
            continue
        elif abs(dy)+abs(dx)<=1:
            G[ny][nx] = '#'
            D[ny][nx] = D[y][x]
            Q.append((ny, nx))
        elif D[ny][nx] == 10**6:
            D[ny][nx] = D[y][x]+1
            Q.appendleft((ny, nx))
            
if D[gy][gx] == 10**6:
    print(-1)
else:
    print(D[gy][gx])
import math
H,W = map(int,input().split())
if H%2==0 and W%2== 0:
  print((H*W)/2)
elif H%2 == 1 and W%2==1:
  print(H*math.floor(W/2)+math.ceil(H/2))
elif H%2 == 1 and W%2==0:
  print(H*math.floor(W/2))
else:
print(W*math.floor(H/2))

### FIXED CODE ###

import math
from decimal import Decimal
H,W = map(int,input().split())
if H==1 or W == 1:
  print(1)
elif H%2==0 and W%2== 0:
  print(Decimal((H*W)/2))
elif H%2 == 1 and W%2==1:
  print(Decimal(H*math.floor(W/2)+math.ceil(H/2)))
elif H%2 == 1 and W%2==0:
  print(Decimal(H*math.floor(W/2)))
else:
  print(Decimal(W*math.floor(H/2)))
n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0
#a[b]の答え
at = []
def at_memo(x):
    if x==0:
        return []
    if x in at:
        return at[x]
    atx = [l[x]+l[i] for i in range(x)]  
    at[x] = at[x-1] + atx
    return at[x]


for i in range(len(at_memo(x-1))):
    if l[x]-at_memo(x)[i]>0:
         ans += 1
    else:
         continue


print(ans)

### FIXED CODE ###

n = int(input())
l = list(map(int, input().split()))
l.sort(reverse=True)
ans = 0
for i in range(n-2):
    j = i+1
    k = n-1
    while j < k:
        if l[i]<l[j]+l[k]:
            ans += k-j
            j += 1
        else:
            k -= 1
print(ans)
N, C = map(int, input().split(' '))

ss = [0 ] * N
tt = [0 ] * N
cc = [0 ] * N

for n in range(N):
    ss[n], tt[n], cc[n] = map(int, input().split(' '))

timeline = [0] * (10 ** 5)

for n in range(N):
    timeline[ss[n] - 1] += 1
    timeline[tt[n]] -= 1

max_ = 0
stack = 0
for t in timeline:
    stack += t
    if stack > max_:
        max_ = stack
        
print(max_)

### FIXED CODE ###

N, C = map(int, input().split(' '))

ss = [0] * N
tt = [0] * N
cc = [0] * N

for n in range(N):
    ss[n], tt[n], cc[n] = map(int, input().split(' '))

L = 10 ** 5 * 2 + 2
timeline = [[0] * L for c in range(C)]

# print(len(timeline), len(timeline[0]))

# 同じチャンネルでマージ
for n in range(N):
    timeline[cc[n] - 1][ss[n] * 2] += 1
    timeline[cc[n] - 1][tt[n] * 2] -= 1

# チャンネルのスタート時間0.5ずらして一個前のところに
num = [0] * L
for c in range(C):
    for t in range(L):
        if timeline[c][t] > 0:
            num[t - 1] += timeline[c][t]
        if timeline[c][t] < 0:
            num[t] += timeline[c][t]

stack = 0
max_ = 0
for i in range(L):
    stack += num[i]
    if stack > max_:
        max_ = stack

print(max_)
# 3 2
# 1 3 1
# 3 4 1
# 4 5 2
A, B = map(int, input(). split())
answer = None
flag = False
for i in range(1009):
  
  if (i*0.08//1 = A) and (i*0.1//1 = B):
    print(i)
    flag = True
   
    if flag:
        break
if (answer = None):
  print(-1)
    


### FIXED CODE ###

A, B = map(int, input(). split())
answer = None
flag = False
for i in range(1, 1009):
  
  if (A == (i*0.08)//1) and (B == (i*0.1)//1):
    answer = i
    print(answer)
    flag = True
   
    if flag:
        break
if answer is None:
  answer = -1
  print(answer)
a=input()
list=["Sunny","Cloudy","Rainy"]
if a=list[0]:
  print(list[1])
elif a=list[1]:
  print(list[2])
else:
  print(list[0])
    
  

### FIXED CODE ###

a=input()
if a=="Sunny":
  print("Cloudy")
elif a=="Cloudy":
  print("Rainy")
else:
  print("Sunny")
ref=[63,6,91,79,102,109,125,39,127,111]
while 1:
	n=int(raw_input())
	if n<=0:break
	e=0
	for i in range(n):
		a=ref[int(raw_input())]
		print "{:07b}".format(a^e)
		e=a

### FIXED CODE ###

ref=[63,6,91,79,102,109,125,39,127,111]
while 1:
	try:
		n=input()
		if n==-1:break
		e=0
		for i in range(n):
			a=ref[input()]
			print "{:07b}".format(a^e)
			e=a
	except:
		pass
N=int(input())
H=list(map(int,input().split(' ')))
dp=[]

for i in range(N):
	if i==0:
		dp.append(0)
	elif k==1:
		dp.append(abs(H[1]-H[0]))
	else:
		return min(dp[k-2]+abs(H[k]-H[k-2]), dp[k-1]+abs(H[k]-H[k-1]))
		
print(dp[N-1])

### FIXED CODE ###

N=int(input())
H=list(map(int,input().split(' ')))
dp=[]

for k in range(N):
	if k==0:
		dp.append(0)
	elif k==1:
		dp.append(abs(H[1]-H[0]))
	else:
		dp.append(min(dp[k-2]+abs(H[k]-H[k-2]), dp[k-1]+abs(H[k]-H[k-1])))
		
print(dp[N-1])
# 解説YouTubeをもとに
S = int(input())
x1, y1, x2, x3 = 0, 0, 10**9, 1
if S==10**18:
  print(x1, y1, x2, y2, 0, x2)
else:
  y3 = S//x2 + 1
  y2 = x2*y3 - S
  print(x1, y1, x2, y2, x3, y3)

### FIXED CODE ###

# 解説YouTubeをもとに
# https://atcoder.jp/contests/agc036/submissions/6943945 参考
S = int(input())
x1, y1, x2, y2 = 0, 0, 10**9, 1
if S==10**18:
  print(x1, y1, x2, y2, 0, x2)
else:
  y3 = S//x2 + 1
  x3 = x2*y3 - S
  print(x1, y1, x2, y2, x3, y3)
import numpy as np

N = input()
# N = int(input())
# t = np.array(list(map(int, input().split())))
t = map(int, raw_input().split())

odd = t[0::2]
even = t[1::2]

rest = 0
for _k in [odd, even]:
    unique, count = np.unique(_k, return_counts=True)
    rest += np.sum(count) - count[np.argmax(count)]

print rest


### FIXED CODE ###

# -*- coding: utf-8 -*-
import numpy as np
from collections import Counter
N = input()
t = np.array(map(int, raw_input().split()))

odd = t[0::2]
even = t[1::2]
rest = 0

co = Counter(odd)
ce = Counter(even)

omc = co.most_common()
emc = ce.most_common()

if omc[0][0] == emc[0][0]:
    if len(omc) < 2 and len(emc) < 2:       # same
        rest = len(even)
    elif len(omc) < 2:
        rest = len(even)
    elif len(emc) < 2:
        rest = len(odd)
    else:
        or1 = len(odd) - co.most_common()[0][1]
        or2 = len(odd) - co.most_common()[1][1]
        er1 = len(even) - ce.most_common()[0][1]
        er2 = len(even) - ce.most_common()[1][1]

        if or1 + er2 > or2 + er1:
            rest = or2 + er1
        else:
            rest = or1 + er2
else:
    rest = len(odd) - co.most_common()[0][1] + len(even) - ce.most_common()[0][1]


print rest
#editorial参照
n=int(input())
a=list(map(int, input().split()))
sa= sum(a)
if sa%(n*(n+1)//2):
    print("NO")
    exit()
k=sa//(n*(n-1)//2)
b=[a[i]-a[i-1] -k for i in range(n)]

for i in range(n):
    if b[i]%n or b[i]>0:
        print("NO")
        exit()
print("YES")

### FIXED CODE ###

#modN等差数列が必要...根本的に違う
n=int(input())
a=list(map(int, input().split()))
sa= sum(a)
if sa%(n*(n+1)//2):
    print("NO")
    exit()
k=sa//(n*(n+1)//2)###+
b=[a[i]-a[i-1] -k for i in range(n)]

for i in range(n):
    if b[i]%n or b[i]>0:
        print("NO")
        exit()
print("YES")
S, T = input().split()
A, B = input().split()
U = input()

if S==U:
    print(A-1, B)
else:
    print(A, B-1)

### FIXED CODE ###

S, T = input().split()
A, B = map(int, input().split())
U = input()

if S==U:
    print(A-1, B)
else:
    print(A, B-1)
x = input()
a = []
check = []
for i in range(int(x)):
    a.append(int(input()) - 1)
    check.append(1)

index = 0



while True:
    check[index] = 0
    index = a[index]
    if check[index] == 0:
        print(-1)
        break
    if index == 1:
        print(count)
        break

### FIXED CODE ###

x = input()
a = []
check = []
for i in range(int(x)):
    a.append(int(input()) - 1)
    check.append(1)

index = 0
count = 0


while True:
    count += 1
    check[index] = 0
    index = a[index]

    if check[index] == 0:
        print(-1)
        break
    if index == 1:
        print(count)
        break
def mult(A, B, mod): #行列A, Bの内積を求める。
    D = [[0, 0, 0] for i in range(3)]
    D[0][0] = (A[0][0] * B[0][0]) % mod
    D[1][0] = (A[1][0] * B[0][0] + A[1][1] * B[1][0]) % mod
    D[1][1] = 1
    D[2][0] = (A[2][0]*B[0][0]+A[2][1]*B[1][0]+A[2][2]*B[2][0]) % mod
    D[2][1] = (A[2][1]*B[1][1]+A[2][2]*B[2][1]) % mod
    D[2][2] = 1
    return D


def Cpow(C, n, mod):
    if n == 1: return C
    else:
        D = mult(C, C, mod)
        if n % 2 == 0:
            return Cpow(D, n // 2, mod)
        else:
            return mult(Cpow(D, n // 2, mod), C, mod)

def solve():
    L, a, b, M = map(int, input().split())
    X = "0"
    s = a
    nd = -1
    ne = 0
    for d in range(1, 19):
        ne = min((pow(10, d) - a - 1) // b, L-1)
        if nd == ne and ne == L - 1: break
        elif nd == ne: continue
        C = [[pow(10, d, M), 0, 0], [1, 1, 0], [0, b % M, 1]]
        D = Cpow(C, ne - nd, M)
        X = str((int(X) * D[0][0] + D[1][0] * s + D[2][0]) % M)
        s += D[2][1]
        nd = ne
    print(X)
    return

if __name__ == "__main__":
    solve()

### FIXED CODE ###

import sys
sys.setrecursionlimit(100000000)

def mult(A, B, mod): #行列A, Bの内積を求める。
    D = [[(A[0][0] * B[0][0]) % mod, 0, 0], [0, 1, 0], [0, 0, 1]]
    D[1][0] = (A[1][0] * B[0][0] + A[1][1] * B[1][0]) % mod
    D[2][0] = (A[2][0]*B[0][0]+A[2][1]*B[1][0]+A[2][2]*B[2][0]) % mod
    D[2][1] = (A[2][1]*B[1][1]+A[2][2]*B[2][1]) % mod
    return D

def double(C, mod):
    D = [[pow(C[0][0], 2, mod), 0, 0], [(C[1][0] * C[0][0] + C[1][0]) % mod, 1, 0], [(C[2][0] * C[0][0] + C[2][1] * C[1][0] + C[2][0]) % mod, (C[2][1] * 2) % mod, 1]]
    return D

def Cpow(C, n, mod):
    if n == 1: return C
    else:
        D = double(C, mod)
        if n % 2 == 0:
            return Cpow(D, n // 2, mod)
        else:
            return mult(Cpow(D, n // 2, mod), C, mod)

def solve():
    L, a, b, M = map(int, input().split())
    X = 0
    s = a
    nd = -1
    ne = 0
    for d in range(1, 19):
        ne = min((pow(10, d) - a - 1) // b, L-1)
        if ne < 0: continue
        elif ne == nd: continue
        C = [[pow(10, d, M), 0, 0], [1, 1, 0], [0, b % M, 1]]
        D = Cpow(C, ne - nd, M)
        X = (X * D[0][0] + D[1][0] * s + D[2][0]) % M
        s += D[2][1]
        if ne == L - 1: break
        nd = ne
    print(X)
    return

if __name__ == "__main__":
    solve()
from collections import deque
import copy
N = int(input())
d_1, d_2 = deque([]), deque([])
l = []
for i in range(N):
  l.append(int(input()))
  
l.sort()
l_1, l_2 = copy.copy(l), copy.copy(l)
d_1.append(max(l))
d_2.append(min(l))
l_1.pop()
l_2.pop(0)

def main1(d, l):
  d.appendleft(l[0])
  l.pop(0)
  if l == []:
    return d
  d.append(l[0])
  l.pop(0)
  if l == []:
    return d
  d.appendleft(l[-1])
  l.pop()
  if l == []:
    return d
  d.append(l[-1])
  l.pop()
  if l == []:
    return d
  else:
    return main1(d, l)
  
def main2(d, l):
  d.appendleft(l[-1])
  l.pop()
  if l == []:
    return d
  d.append(l[-1])
  l.pop()
  if l == []:
    return d
  d.appendleft(l[0])
  l.pop(0)
  if l == []:
    return d
  d.append(l[0])
  l.pop(0)
  if l == []:
    return d
  else:
    return main2(d, l)
  
x, y = 0, 0
a = main1(d_1, l_1)
b = main2(d_2, l_2)
for i in range(N-1):
  x += abs(a[i+1]-a[i])
  y += abs(b[i+1]-b[i])
print(max(x, y))

### FIXED CODE ###

from collections import deque
import copy
import sys
sys.setrecursionlimit(50000)
N = int(input())
d_1, d_2 = deque([]), deque([])
l = []
for i in range(N):
  l.append(int(input()))
  
l.sort()
l_1, l_2 = copy.copy(l), copy.copy(l)
d_1.append(max(l))
d_2.append(min(l))
l_1.pop()
l_2.pop(0)

def main1(d, l):
  d.appendleft(l[0])
  l.pop(0)
  if l == []:
    return d
  d.append(l[0])
  l.pop(0)
  if l == []:
    return d
  d.appendleft(l[-1])
  l.pop()
  if l == []:
    return d
  d.append(l[-1])
  l.pop()
  if l == []:
    return d
  else:
    return main1(d, l)
  
def main2(d, l):
  d.appendleft(l[-1])
  l.pop()
  if l == []:
    return d
  d.append(l[-1])
  l.pop()
  if l == []:
    return d
  d.appendleft(l[0])
  l.pop(0)
  if l == []:
    return d
  d.append(l[0])
  l.pop(0)
  if l == []:
    return d
  else:
    return main2(d, l)
  
x, y = 0, 0
a = main1(d_1, l_1)
b = main2(d_2, l_2)
for i in range(N-1):
  x += abs(a[i+1]-a[i])
  y += abs(b[i+1]-b[i])
print(max(x, y))
N=int(input())
a = list(map(int,input().split()))

ans = 0
for aa in a:
    ans+=a-1
    
print(ans)

### FIXED CODE ###

N=int(raw_input())
a=map(int,raw_input().split())

s=0
for i in a:
  s+=i-1
print s
N = input().split()
d = dict.fromkeys(N, 0)
for n in N:
    d[n] += 1

print(sum(d.values())


### FIXED CODE ###

N = input().split()
num = len(set(N))
print(num)
import math
n = input()
aa = list(map(int, input().split()))
g = aa[0]
for a in aa:
    g = math.gcd(g, a)
print(g)

### FIXED CODE ###

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

n = input()
aa = list(map(int, input().split()))
g = aa[0]
for a in aa:
    g = gcd(g, a)
print(g)
arry = [x = 2,  x ** 3]
print(arry + \n)

### FIXED CODE ###

x = raw_input()
print(str(int(x) ** 3))
n = int((input())
t = n % 10
if t == 0 or t == 1 or t == 6 or t == 8:
	print('pon')
elif t == 3:
	print('bon')
else:
	print('hon')

### FIXED CODE ###

n = int(input())
t = n % 10
if t == 0 or t == 1 or t == 6 or t == 8:
	print('pon')
elif t == 3:
	print('bon')
else:
	print('hon')
N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
M = 10**9 + 7
A = sorted(A, key=abs, reverse=1)
# 負の数になる場合
if max(A) < 0:
    result = 1
    for i in range(K):
        result = result * A[-i-1] % M
    print(result)
    exit()

minimum_minus_id = K
minimum_plus_id = K
minus_count = 0

for i in range(K):
    if A[i] < 0:
        minus_count += 1
        minimum_minus_id = i
    else:
        minimum_plus_id = i
result = 1

if minus_count%2 ==1:
    # 一番小さい負の数を正の数にするか、一番小さい正の数を負の数にするか
    max_mm = A[minimum_minus_id]
    second_minus_id = N
    max_pp = A[minimum_plus_id]
    second_plus_id = N

    for i in range(K, N):
        if A[i] >= 0:
            second_minus_id = i
            break
    for i in range(K, N):
        if A[i] < 0:
            second_plus_id = i
            break
    if second_minus_id == N:
        A[minimum_minus_id] = A[second_plus_id]
    else:
        if A[minimum_minus_id] * A[second_minus_id ] > A[minimum_plus_id] * A[second_plus_id]:
            A[minimum_plus_id] = A[second_minus_id]
        else:
            A[minimum_minus_id] = A[second_plus_id]

for i in range(K):
    result = result * A[i] % M
print(result)

### FIXED CODE ###

n, k = map(int, input().split())
a_list = list(map(int, input().split()))
mod = 10**9+7
a_list.sort()
ans = 1
if k % 2 == 1 and a_list[-1] < 0:
    for i in range(k):
        ans *= a_list[n - 1 - i]
        ans %= mod
else:
    l = 0
    r = -1
    mlt1 = a_list[0] * a_list[1]
    mlt2 = a_list[-2] * a_list[-1]
    count = 0
    while True:
        if count == k:
            break
        elif count == k - 1:
            ans *= a_list[r] % mod
            ans %= mod
            break
        if mlt1 >= mlt2:
            ans *= mlt1 % mod
            l += 2
            count += 2
            if l <= n - 2:
                mlt1 = a_list[l + 1] * a_list[l]
        else:
            ans *= a_list[r] % mod
            r -= 1
            count += 1
            if r >= - n + 1:
                mlt2 = a_list[r - 1] * a_list[r]
        ans %= mod
print(ans)
W,H,x,y,r = map(int, raw_input().split(' '))
if r <= x <= W-r and r <= y <= H-r
print "Yes"
else:
print "No"

### FIXED CODE ###

W,H,x,y,r = map(int, input().split())
if r <= x <= W-r and r <= y <= H-r:
    print ('Yes')
else:
    print ('No')
intl=map(int, raw_input())

a=intl[0]
b=intl[1]

if a==b:
  print "a==b"
elif a>b:
  print "a>b"
else:
  print "a<b"

### FIXED CODE ###

intl=map(int, raw_input().split())

a=intl[0]
b=intl[1]

if a==b:
  print "a == b"
elif a>b:
  print "a > b"
else:
  print "a < b"
a = int(input())
b = int(input())
c = int(input())
d = int(input())

if (abs(a - b) <= d) and (abs(b - c) <= d):
    print('Yes')
elif abs(a - c) <= d:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

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

if abs(a - c) <= d:
    print('Yes')
elif (a < b and b < c) or (a > b and b > c):
    if abs(a - b) <= d and abs(b - c) <= d:
        print('Yes')
    else:
        print('No')
else:
    print('No')
import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))

def C(n,r):
    if n < 0 or r < 0 or n < r: 
        return 0
    elif n == 0 or r == 0: 
        return 1
    return C(n-1,r-1)+C(n-1,r)

def main():
    n = ni()
    l = sorted(na())
    ans = C(n, 3) % 3
    j = n - 2
    k = n - 1
    dame = []
    for i in range(n - 3, -1, -1):
        if i in dame or j in dame or k in dame:
            continue
        a = l[i]
        b = l[j]
        c = l[k]
        if a < b + c and b < a + c and c < a + b:
            j -= 1
            k -= 1
        else:
            if a > b + c:
                dame.append(i)
            if b > a + c:
                dame.append(j)
            if c > a + b:
                dame.append(k)
    
    for d in dame:
        ans -= C(n - d - 1, 1)

    nn = len(dame)
    if nn >= 3:
        j = n - 2
        k = n - 1
        for i in range(dame - 3, -1, -1):
            a = l[i]
            b = l[j]
            c = l[k]
            if a < b + c and b < a + c and c < a + b:
                ans += 1

    print(ans)

main()

### FIXED CODE ###

import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))

from bisect import bisect_left

def main():
    n = ni()
    l = sorted(na())
    
    ans = 0
    for i in range(n):
        for j in range(i+1, n):
            t = l[i] + l[j]
            ind = bisect_left(l, t)
            ans += max(0, ind - j - 1)
    print(ans)

main()
n,m=map(int,input().split())
lst=[list(map(int,input().split()))]
for i in range(n-1):
    a=list(map(int,input().split()))
    x=0
    for j in range(len(lst)):
        if x > m :break
        if lst[j][0] > a[0]:
            lst.insert(j,a)
            break
        x+=lst[j][1]
        
ans=0
num=0
for i in lst:
    if i[1]+num>=m:
        ans+=i[0]*(m-num)
        break
    ans+=i[0]*i[1]
    num+=i[1]
print(ans,lst)

### FIXED CODE ###

H,W=map(int,input().split())
h,w=map(int,input().split())
print(H*W-H*w-h*W+h*w)
print(chr(ord(C) + 1))

### FIXED CODE ###

print(chr(ord(input()) + 1))
import copy
# In=[list(map(int,i.split())) for i in Input.split('\n')]
# N=In[0][0]
# A=In[1]
N=int(input())
I=list(map(int,input().split()))
for j in range(N):
    counter=[0 for i in range(N+1)]
    A=copy.deepcopy(I)
    A.pop(j)
    B=[]
    for i in A:
        counter[i]+=1
    for i in counter:
        if i>1:
            B.append(f(i)/(f(2)*f(i-2)))
    print(int(sum(B)))

### FIXED CODE ###

import copy
# In=[list(map(int,i.split())) for i in Input.split('\n')]
# N=In[0][0]
# A=In[1]
N=int(input())
A=list(map(int,input().split()))
counter=[0 for i in range(N+1)]
ans2=[0 for i in range(N+1)]
B=[]
for i in A:
    counter[i]+=1
ans=[0 for i in range(N+1)]
for i,value in enumerate(counter):
    if value>0:
        ans[i]=(value*(value-1)//2)
        ans2[i]=((value-1)*(value-2)//2)
total=sum(ans)
for i in A:
    temp=total
    temp-=ans[i]
    temp+=ans2[i]
    print(temp)
47
S 10
S 11
S 12
S 13
H 1
H 2
S 6
S 7
S 8
S 9
H 6
H 8
H 9
H 10
H 11
H 4
H 5
S 2
S 3
S 4
S 5
H 12
H 13
C 1
C 2
D 1
D 2
D 3
D 4
D 5
D 6
D 7
C 3
C 4
C 5
C 6
C 7
C 8
C 9
C 10
C 11
C 13
D 9
D 10
D 11
D 12
D 13


### FIXED CODE ###

n = int(input())
cards = {}
for i in range(n):
    card = input()
    cards[card] = 1
      
#print(cards)
  
for c in ['S', 'H', 'C', 'D']:
    for n in range(1, 14):
        key = c + ' ' + str(n)
        if not key in cards:
            print(key)
n = int(input())
s = str(input())
d = s.split()
mod = 10 ** 18
ans = int(d[0])
d.pop(0)
z = 0
if '0' in d:
	print(0)
else:
	for i in d:
		i = int(i)
		ans *= i
		if ans > mod:
			print(-1)
			z = 1
	if z == 1:
		pass
	else:
		print(ans)

### FIXED CODE ###

s = str(input())
d = s.split()
a = int(d[0])
b = int(d[1])
c = a * b 
print(c)
N,M = map(int,input().split())
to = [[] for i in range(N)]
for i in range(M):
    x,y = map(int,input().split())
    to[x-1]+=[y-1]

dp = [-1 for i in range(N)] #node[i]からの最長経路長を記す -1で未決定を示す

def memo(i):
    if dp[i] != -1:
        return dp[i]
    a=0
    for j in to[i]:
        a=max(a, memo(j)+1)
    dp[i] = a
    return a
    
lp = 0
for i in range(N):
    lp = max(lp,memo(i))
print(lp)

### FIXED CODE ###

import sys
# 許容する再帰処理の回数を変更
sys.setrecursionlimit(10**5+10)
# input処理を高速化する
input = sys.stdin.readline

N,M = map(int,input().split())
to = [[] for i in range(N)]
for i in range(M):
    x,y = map(int,input().split())
    to[x-1]+=[y-1]

dp = [-1 for i in range(N)] #node[i]からの最長経路長を記す -1で未決定を示す

def memo(i):
    if dp[i] != -1:
        return dp[i]
    a=0
    for j in to[i]:
        a=max(a, memo(j)+1)
    dp[i] = a
    return a

lp = 0
for i in range(N):
    lp = max(lp,memo(i))
print(lp)
a,v = map(int, input().split())
b,w = map(int, input().split())
T = int(input())
if b-a < (v-w)*T and (b-a)%(v-w) == 0:
    print('YES')
else:
    print('NO')

### FIXED CODE ###

a,v = map(int, input().split())
b,w = map(int, input().split())
T = int(input())
if abs(b-a) <= (v-w)*T:
    print('YES')
else:
    print('NO')
import itertools
import math

def main():
    a, b, k = map(int, input().split())
    print(solve(a, b, k))

def solve(a, b, k):
    c = math.gcd(a, b)
    n = 0

    for i in range(c, 0, -1):
        if a % i == 0 and b % i == 0:
            n += 1
            if n == k:
                return i

main()


### FIXED CODE ###

def main():
    a, b, k = map(int, input().split())
    print(solve(a, b, k))

def solve(a, b, k):
    n = 0
    for i in range(100, 0, -1):
        if a % i == 0 and b % i == 0:
            n += 1
            if n == k:
                return i

main()
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    A = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    K = int(readline())

    print(A[K-1])



if __name__ == "__main__":
    main()


### FIXED CODE ###

from math import ceil
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    h,w = map(int, readline().split())

    if h == 1 or w == 1:
        print(1)
        exit()

    print(ceil(h/2)*ceil(w/2) + (h//2) * (w //2) )



if __name__ == "__main__":
    main()
a,b,c = map(int,input())
print(c-a)

### FIXED CODE ###

a,b,c = sorted(map(int,input().split()))
print(c-a)
T = input()
T = list(T)
N = len(T)
for i in range(N):
  if T[i] =='?' and T[i+1]=='D':
    del T[i]   
    T.insert(i,'P')
  elif T[i] =='?' and T[i+1]=='?':
    del T[i]   
    T.insert(i,'P')
  elif T[i] =='?': 
    del T[i] 
    T.insert(i,'D')
print("".join(T))


### FIXED CODE ###

S = input()
s=[]
for i in S:
    s.append(i)
t = []
for i in range(len(s)):
  if s[i] == '?':
    t.append('D')
  else:
    t.append(s[i])
Strt = "".join(t)
print(Strt)