Harryxun/stf_run huggingface dataset:
n=int(input())
import math
p=list(map(float,input().split()))
for i in range(n):
    p[i]=p[i]*100
dp=[[0]*(n) for i in range(n+1)]
dp[0][0]=(100-p[0])
for i in range(1,n):
    dp[0][i]=dp[0][i-1]*(100-p[i])
# print(dp[0][1],1-p[2],dp[0][1]*(1-p[2]))
for i in range(1,n+1):
    for j in range(i-1,n):
        if j==0:
            temp1=1 
            temp2=0 
        else:
            temp1=dp[i-1][j-1]
            temp2=dp[i][j-1]
        dp[i][j]=temp1*p[j]+temp2*(100-p[j])
        dp[i][j]=dp[i][j]
ans=0
# print(dp)
den=100**(n)
for i in range(n//2+1,n+1):
    ans+=dp[i][n-1]

print(round(ans/den,10))
        

### FIXED CODE ###

n=int(input())
import math
p=list(map(float,input().split()))
for i in range(n):
    p[i]=p[i]*100
dp=[[0]*(n) for i in range(n+1)]
dp[0][0]=(100-p[0])/100
for i in range(1,n):
    dp[0][i]=dp[0][i-1]*(100-p[i])/100
# print(dp[0][1],1-p[2],dp[0][1]*(1-p[2]))
for i in range(1,n+1):
    for j in range(i-1,n):
        if j==0:
            temp1=1 
            temp2=0 
        else:
            temp1=dp[i-1][j-1]
            temp2=dp[i][j-1]
        dp[i][j]=temp1*p[j]/100+temp2*(100-p[j])/100
        dp[i][j]=dp[i][j]
ans=0
# print(dp)
for i in range(n//2+1,n+1):
    ans+=dp[i][n-1]
print(ans)
#N,Tの取得
N,T = map(int, input().split()))

#秒のリストを取得
tl = list(map(int, input().split()))

bt = 0 #直前のスイッチを押した時間
gt = T #秒数総和
for t in tl(1:):
    if t - bt > T:
        gt += T #スイッチオフの時はT秒追加
    else:
        gt += t - bt #スイッチがオンのとき、前回からの経過時間を加算
    bt = t

print(str(gt))

### FIXED CODE ###

#N,Tの取得
l = list(map(int, input().split()))
N = l[0]
T = l[1]

#秒のリストを取得
tl = list(map(int, input().split()))

sw = 0 #スイッチオンオフの管理
bt = 0 #直前のスイッチを押した時間
gt = 0 #秒数総和
for i, t in enumerate(tl):
    if sw == 1 and t - bt > T:
        sw = 0 #全快スイッチを押してからT秒経過していたら、スイッチオフ
    if sw == 0:
        gt += T #スイッチオフの時はT秒追加
    else:
        gt += t - bt  #スイッチがオンのとき、前回からの経過時間を加算
    bt = t
    sw = 1 #スイッチオン。
        

print(str(gt))
N,K=map(int,input().split())
D,L={},[]
for _ in range(N):
    a,b=map(int,input().split())
    L.append(a)
    if a in D:D[a]=D[a]+b
    else:D[a]=b
l=list(set(L)).sort()
for i in l:
    K-=D[i]
    if K<=0:
        print(i)
        exit()

### FIXED CODE ###

a,b,c=map(int,input().split())
if a<=c<=b:print("Yes")
else:print("No")
with open("td") as inputfile:
    open0=inputfile.read()

def zengo(l,n):
    if n<l[0]:
        return 0,l[0]-n
    elif n>l[-1]:
        return n-l[-1],0
    else:
        st=0
        ed=len(l)
        while ed-st>1:
            md=(st+ed)//2
            if n<l[md]:
                ed=md
            else:
                st=md
        return n-l[st],l[ed]-n

near=lambda x,y:min(x,y) if x*y else max(x,y)

jn,tn,qn,*tmp=map(int,open0.split())
jz=tmp[:jn]
tz=tmp[jn:jn+tn]
q=tmp[jn+tn:]
for i in q:
    jb,jf=zengo(jz,i)
    tb,tf=zengo(tz,i)
    ans=[]
    if jb*tb:
        ans.append(max(jb,tb))
    if jf*tf:
        ans.append(max(jf,tf))
    jd=near(jb,jf)
    td=near(tb,tf)
    ans.append(jd+td+min(jd,td))
    print(min(ans))

### FIXED CODE ###

def zengo(l,n):
    if n<l[0]:
        return 0,l[0]-n
    elif n>l[-1]:
        return n-l[-1],0
    else:
        st=0
        ed=len(l)
        while ed-st>1:
            md=(st+ed)//2
            if n<l[md]:
                ed=md
            else:
                st=md
        return n-l[st],l[ed]-n

near=lambda x,y:min(x,y) if x*y else max(x,y)

jn,tn,qn,*tmp=map(int,open(0).read().split())
jz=tmp[:jn]
tz=tmp[jn:jn+tn]
q=tmp[jn+tn:]
for i in q:
    jb,jf=zengo(jz,i)
    tb,tf=zengo(tz,i)
    ans=[]
    if jb*tb:
        ans.append(max(jb,tb))
    if jf*tf:
        ans.append(max(jf,tf))
    jd=near(jb,jf)
    td=near(tb,tf)
    ans.append(jd+td+min(jd,td))
    print(min(ans))
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
A = readInts()
four = 0
two = 0
for i in range(n):
    if A[i]%4 == 0:
        four += 1
    elif A[i]%2 == 0:
        two += 1
print('Yes' if a + b//2 >= n//2 else 'No')


### FIXED CODE ###

#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""

""" n! mod m 階乗
mod = 1e9 + 7
N = 10000000
fac = [0] * N
def ini():
  fac[0] = 1 % mod
  for i in range(1,N):
    fac[i] = fac[i-1] * i % mod"""

"""mod = 1e9+7
N = 10000000
pw = [0] * N
def ini(c):
  pw[0] = 1 % mod
  for i in range(1,N):
    pw[i] = pw[i-1] * c % mod"""

"""
def YEILD():
  yield 'one'
  yield 'two'
  yield 'three'
generator = YEILD()
print(next(generator))
print(next(generator))
print(next(generator))
"""
"""def gcd_(a,b):
  if b == 0:#結局はc,0の最大公約数はcなのに
    return a
  return gcd_(a,a % b) # a = p * b + q"""
"""def extgcd(a,b,x,y):
  d = a
  if b!=0:
    d = extgcd(b,a%b,y,x)
    y -= (a//b) * x
    print(x,y)
  else:
    x = 1
    y = 0
  return d"""


def readInts():
  return list(map(int,input().split()))
mod = 10**9 + 7
def main():
  n = int(input())
  a,b = 0,0
  # 4, 2で分ける
  for x in map(int,input().split()):
    if x % 4 == 0:
      a += 1
    elif x % 2 == 0:
      b += 1
  print('Yes' if a+b//2 >= n//2 else 'No') 
  # b // 2 によって、2の倍数が偶数個なら、それは4の倍数として使うことが出来る
  # n // 2　もし n = 6ならば...n = 3となり、数字の間に4の倍数を入れれるって分かる
  
if __name__ == '__main__':
  main()
# ABC109D - Make Them Even
import sys
input = sys.stdin.readline


def main():
    H, W = tuple(map(int, input().rstrip().split()))
    A = list(
        list(map(lambda x: int(x) % 2, input().rstrip().split())) for _ in range(H)
    )
    ans = []
    # move left to right
    for i in range(H):
        for j in range(W - 1):
            if A[i][j]:
                A[i][j] ^= 1
                A[i][j + 1] ^= 1
                ans += [(i + 1, j + 1, i + 1, j + 2)]
    for i in range(H - 1):
        if A[i][W]:
            A[i][W] ^= 1
            A[i + 1][W] ^= 1
            ans += [(i + 1, W + 1, i + 2, W + 1)]
    print(len(ans))
    for i in ans:
        print(*i)


if __name__ == "__main__":
    main()

### FIXED CODE ###

# ABC109D - Make Them Even
import sys
input = sys.stdin.readline


def main():
    H, W = tuple(map(int, input().rstrip().split()))
    A = list(
        list(map(lambda x: int(x) % 2, input().rstrip().split())) for _ in range(H)
    )
    ans = []
    # move left to right
    for i in range(H):
        for j in range(W - 1):
            if A[i][j]:
                A[i][j] ^= 1
                A[i][j + 1] ^= 1
                ans += [(i + 1, j + 1, i + 1, j + 2)]
    # move up to down
    for i in range(H - 1):
        if A[i][W - 1]:
            A[i][W - 1] ^= 1
            A[i + 1][W - 1] ^= 1
            ans += [(i + 1, W, i + 2, W)]
    print(len(ans))
    for i in ans:
        print(*i)


if __name__ == "__main__":
    main()
N = int(input())
a = np.array([int(input()) for _ in range(N)])
m = 998244353
S = a.sum()

# 最初のt個の整数を塗り分け, Rの整数の和がrであるような場合の数
DP_A = np.zeros((N+1, S+1), dtype=np.int64)
# 最初のt個の整数を塗り分け, Rの整数の和がrで, Bの和が0であるような場合の数
DP_B = np.zeros((N+1, S+1), dtype=np.int64)

DP_A[0, 0] = 1
DP_B[0, 0] = 1

# for t in range(N):
#     for r in range(S + 1):
#         # t + 1番目の整数をRにしない -> G or Bにする
#         DP_A[t+1, r] = DP_A[t, r] * 2 % m
#         # t + 1番目の整数をRにする -> r-a(t+1)だった場合の数を追加
#         if r - a[t] >= 0:
#             DP_A[t+1, r] += DP_A[t, r - a[t]] % m
#         # t+1 番目の整数をRにしない -> Gを加える
#         DP_B[t+1, r] = DP_B[t, r] % m
#         # t + 1番目の整数をRにする -> r-a(t+1)だった場合の数を追加
#         if r - a[t] >= 0:
#             DP_B[t+1, r] += DP_B[t, r - a[t]] % m

for t in range(N):
    DP_A[t+1, :] = (DP_A[t, :]) * 2 % m
    DP_A[t+1, a[t]:] += DP_A[t, :-a[t]] % m
    DP_B[t+1, :] = (DP_B[t, :]) % m
    DP_B[t+1, a[t]:] += DP_B[t, :-a[t]] % m

res1 = DP_A[N, int(np.ceil(S/2)):].sum()
res2 = DP_B[N, int(np.ceil(S/2))] if S % 2 == 0 else 0
res = (3 ** N - res1 * 3 + res2 * 3) % m
print(res)

### FIXED CODE ###

import numpy as np
N = int(input())
a = np.array([int(input()) for _ in range(N)])
m = 998244353
S = a.sum()

# 最初のt個の整数を塗り分け, Rの整数の和がrであるような場合の数
DP_A = np.zeros((N+1, S+1), dtype=np.int64)
# 最初のt個の整数を塗り分け, Rの整数の和がrで, Bの和が0であるような場合の数
DP_B = np.zeros((N+1, S+1), dtype=np.int64)

DP_A[0, 0] = 1
DP_B[0, 0] = 1

# for t in range(N):
#     for r in range(S + 1):
#         # t + 1番目の整数をRにしない -> G or Bにする
#         DP_A[t+1, r] = DP_A[t, r] * 2 % m
#         # t + 1番目の整数をRにする -> r-a(t+1)だった場合の数を追加
#         if r - a[t] >= 0:
#             DP_A[t+1, r] += DP_A[t, r - a[t]] % m
#         # t+1 番目の整数をRにしない -> Gを加える
#         DP_B[t+1, r] = DP_B[t, r] % m
#         # t + 1番目の整数をRにする -> r-a(t+1)だった場合の数を追加
#         if r - a[t] >= 0:
#             DP_B[t+1, r] += DP_B[t, r - a[t]] % m

for t in range(N):
    DP_A[t+1, :] = (DP_A[t, :]) * 2 % m
    DP_A[t+1, a[t]:] += DP_A[t, :-a[t]] % m
    DP_B[t+1, :] = (DP_B[t, :]) % m
    DP_B[t+1, a[t]:] += DP_B[t, :-a[t]] % m

res1 = DP_A[N, int(np.ceil(S/2)):].sum()
res2 = DP_B[N, int(np.ceil(S/2))] if S % 2 == 0 else 0
res = (3 ** N - res1 * 3 + res2 * 3) % m
print(res)
l,r = map(int,input().split())

for i in range(l,r+1):
    for j in range(i+1,r+1):
        ans = min(ans,(i*j)%2019)
print(ans)

### FIXED CODE ###

l,r = map(int,input().split())
if r-l>=2019:
    print(0)
    exit()
ans = 2019
for i in range(l,r+1):
    for j in range(i+1,r+1):
        ans = min(ans,(i*j)%2019)
print(ans)
n = input()

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

total = 1

if a in 0:
	total = 0
else:
	for i in a:
		total *= i

if total > 10**18:
	total = -1

print(total)


### FIXED CODE ###

n = input()
li = list(map(int, input().split())) 

total = 1
li.sort()
for a in li:
    if a == 0:
        total = 0
        break
    total *= a
    if 10 ** 18 < total:
        total = -1
        break
print(total)
N,A,B = map(int,input().split())
ball_str=""
for i in range(10**100):
    if len(ball_str)<=N:
        ball_str+="b"*A+"r"*B
    else:
        break
print(ball_str[:N].count("b"))

### FIXED CODE ###

N,A,B = map(int,input().split())
set_cnt=N//(A+B)
amari=N%(A+B)
if amari > A:
    amari_A = A
else:
    amari_A = amari
print(A*set_cnt+amari_A)
n = input()
if n[-1] == "3":
  print("bon")
if n[-1] == "0" or n[-1] == "1" or n[-1] == "6" or n[-1] == "8":
  print("pon")
else:
  print(hon)

### FIXED CODE ###

n = input()
if n[-1] == "3":
  print("bon")
elif n[-1] == "0" or n[-1] == "1" or n[-1] == "6" or n[-1] == "8":
  print("pon")
else:
  print("hon")
from collections import deque

H, W = map(int,input().split())
S = [list(input()) for _ in range(H)]

def bfs(grid, start):
    distance = [[-1] * W for _ in range(H)]
    queue = deque([start])
    distance[start[1]][start[0]] = 0#start地点を0に
    
    while queue:#queueにたまっている間は処理を続ける
        x, y = queue.popleft()#今いる地点をpop
        
        for i, j in ((1, 0), (-1, 0), (0, 1), (0, -1)):#左右上下に進むパターンをそれぞれ考える
            next_x, next_y = x+i, y+j#次に行く地点
            
            if 0 <= next_x < W and 0 <= next_y < H:#次の地点が範囲内にある場合
                if grid[next_y][next_x] == '.' and distance[next_y][next_x] == -1:#次の地点が壁ではなくかつ訪れたことがない場合
                    distance[next_y][next_x] = distance[y][x] + 1#訪れた印として現在までの距離に1を足す
                    queue.append((next_x, next_y))#訪れる先をqueueに詰めとく
        
        if not queue:#最後にqueueをpopし終えてなくなったら最後に出力
            return distance[y][x]
        
answer = 0
for i in range(H):
    for j in range(W):
        #スタート地点を決める
        
        if S[i][j] == '#':#スタート地点が壁
            continue

        tmp = bfs(S, (i, j))#このスタート地点での一番遠い距離
        
        if tmp > answer:#最大の距離
            answer = tmp

print(answer)   

### FIXED CODE ###

from collections import deque

H, W = map(int,input().split())
S = [list(input()) for _ in range(H)]

def bfs(grid, start):
    distance = [[-1] * W for _ in range(H)]
    queue = deque([start])
    distance[start[1]][start[0]] = 0#start地点を0に
    
    while queue:#queueにたまっている間は処理を続ける
        x, y = queue.popleft()#今いる地点をpop
        
        for i, j in ((1, 0), (-1, 0), (0, 1), (0, -1)):#左右上下に進むパターンをそれぞれ考える
            next_x, next_y = x+i, y+j#次に行く地点
            
            if 0 <= next_x < W and 0 <= next_y < H:#次の地点が範囲内にある場合
                if grid[next_y][next_x] == '.' and distance[next_y][next_x] == -1:#次の地点が壁ではなくかつ訪れたことがない場合
                    distance[next_y][next_x] = distance[y][x] + 1#訪れた印として現在までの距離に1を足す
                    queue.append((next_x, next_y))#訪れる先をqueueに詰めとく
        
        if not queue:#最後にqueueをpopし終えてなくなったら最後に出力
            return distance[y][x]
        
answer = 0
for i in range(H):#y
    for j in range(W):#x
        #スタート地点を決める
        
        if S[i][j] == '#':#スタート地点が壁
            continue

        tmp = bfs(S, (j, i))#このスタート地点での一番遠い距離
        
        if tmp > answer:#最大の距離
            answer = tmp

print(answer)
s=list(input())
t=list("keyence")
j=0
c=0
for i in s:
    if i==t[c]:
        j+=1
        if j==7:
            print("YES")
            exit()
    c+=1
print("NO")

### FIXED CODE ###

import re
s=input()
if re.match("^keyence.*",s) or re.match(".*keyence$",s) or re.match("^k.*eyence$",s)  or re.match("^ke.*yence$",s) or re.match("^key.*ence$",s) or re.match("^keye.*nce$",s) or re.match("^keyen.*ce$",s)or re.match("^keyenc.*e$",s) or re.match("^keyence$",s) :
    print("YES")
else:print("NO")
d = int(input())
c = list(map(int, input().split()))
for i in range(d):
    s = list(map(int, input().split()))
    num = max(s)
    print(l.index(num)+1)

### FIXED CODE ###

d = int(input())
c = list(map(int, input().split()))
for i in range(d):
    s = list(map(int, input().split()))
    num = max(s)
    print(s.index(num)+1)
import copy
def dfs(cur_node, pre_node, Node_num, map, l):
    #全てのノードを見たとき

    if Node_num == N or cur_node <= 0 or cur_node >= N:
        return
    elif l[pre_node][cur_node]==0: #飛んだ先が、Trueの時
        return
    elif map[cur_node]==True:
        return

    map[cur_node]=True
    for i in range(N):
        if i != cur_node:
            dfs(i, cur_node, Node_num+1, map, l)


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

N = S[0]
M = S[1]


map = [False]*N
map[0] = True

lst = []

for i in range(N):
    lst.append([0]*N)

for i in range(N):
    S = input()
    S = list(S.split())
    idx1 = int(S[0])
    idx2 = int(S[1])
    lst[idx1-1][idx2-1] = 1
    lst[idx2-1][idx1-1] = 1


graph_count = 0
#全探索
for i in range(1, N, 1):
    map_copy = copy.copy(map)
    lst_copy = copy.copy(lst)

    dfs(i, 0, 0, map_copy, lst_copy)
    count = 0

    for i in map_copy:
        if i == True:
            count = count + 1
    if count == N:
        graph_count = graph_count + 1

print(graph_count)


### FIXED CODE ###

import itertools
N,M=map(int,input().split())
edges={tuple(sorted(map(int,input().split()))) for i in range(M)}
ans=0
for i in itertools.permutations(range(2,N+1),N-1):
    l=[1]+list(i)
    ans+=sum(1 for edge in zip(l,l[1:]) if tuple(sorted(edge)) in edges)==N-1
print(ans)
a,b,c,d = map(int,input().split())
l = list(range(a,b+1))
ans = 0
for i in range(len(l)):
  l[i] % c != 0 and l[i] % d != 0:
    ans += 1
print(ans)


### FIXED CODE ###

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

def gcd(a,b):
  while b:
    a,b = b,a%b
  return a

def F(N,C,D):
  x = N
  x -= N//C
  x -= N//D
  lcm = C*D//gcd(C,D)
  x += N//lcm
  return x

answer = F(B,C,D) - F(A-1,C,D)
print(answer)
x=(bin(int(input()))
print(2**(len(x)-2)-1)

### FIXED CODE ###

n=int(input())
x=(bin(n))
print(2**(len(x)-2)-1)
T=input()
res=''
for i in range(len(T)):
	if T[i]=='?':
		if i==0:
			if T[i+1]=='P':
				res+='D'
			else:
				res+='P'
		else:
			if i+1<len(T):
				if res[i-1]=='P' or T[i+1]=='P':
					res+='D'
				else:
					res+='P'
			else:
				res+='D'
	else:
		res+=T[i]
print(res)


### FIXED CODE ###

T=input()
res=''
for i in range(len(T)):
	if T[i]=='?':
		if i==0:
			if len(T)==1:
				res+='D'
			else:
				if T[i+1]=='P':
					res+='D'
				else:
					res+='P'
		else:
			if i+1<len(T):
				if res[i-1]=='P' or T[i+1]=='P':
					res+='D'
				else:
					res+='P'
			else:
				res+='D'
	else:
		res+=T[i]
print(res)
a = raw_input().split()
print(int(a[0])-int(a[1])+1)

### FIXED CODE ###

a = raw_input().split()
print(int(a[0])-int(a[1])+1)
def dfs(now, par, d, dist, g):
    dist[now] = d
    for to, cost in g[now]:
        if to == par: continue
        dfs(to, now, d + cost, dist, g)


n = int(raw_input())
g = [[] for _ in xrange(n)]
for i in xrange(n - 1):
    a, b, c = map(int, raw_input().split())
    a -= 1; b -= 1
    g[a].append([b, c])
    g[b].append([a, c])
q, k = map(int, raw_input().split())
k -= 1
dist = [-1] * n
dfs(k, -1, 0, dist, g)
for i in xrange(q):
    x, y = map(int, raw_input().split())
    x -= 1; y -= 1
    print dist[x] + dist[y]


### FIXED CODE ###

import heapq

def dijkstra(s,g,n):
    d=[float('inf')]*n
    d[s]=0
    pq=[]
    heapq.heappush(pq,[0,s])
    while len(pq)!=0:
        t,u=heapq.heappop(pq)
        if d[u]<t:
            continue
        for v,c in g[u]:
            if d[u]+c<d[v]:
                d[v]=d[u]+c
                heapq.heappush(pq,[d[v],v])
    return d

n = int(raw_input())
g = [[] for _ in xrange(n)]
for i in xrange(n - 1):
    a, b, c = map(int, raw_input().split())
    a -= 1; b -= 1
    g[a].append([b, c])
    g[b].append([a, c])
q, k = map(int, raw_input().split())
k -= 1
dist = dijkstra(k, g, n)
for i in xrange(q):
    x, y = map(int, raw_input().split())
    x -= 1; y -= 1
    print dist[x] + dist[y]
import math

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

a_l = A / 0.08
a_m = (A+1) /0.08

l = max(a_l, b_l)
m = min(a_m, b_m)

c = math.ceil(l)

if c < m:
  print(int(c))
else:
  print(-1)

### FIXED CODE ###

import math

def main():

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

    a_l = A / 0.08
    a_m = (A + 1) / 0.08

    b_l = B / 0.1
    b_m = (B + 1) / 0.1

    l = max(a_l, b_l)
    m = min(a_m, b_m)

    c = math.ceil(l)

    if c < m:
        print(int(c))
    else:
        print(-1)


if __name__ == '__main__':
    main()
n,r = map(int,input().split())
if n == 0:
  print(0)
elif n >= 10:
  print(r)
else:
  ans = r+ (100*(10-k))
  print(ans)


### FIXED CODE ###

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

if n >= 10:
    print(r)
else:
    print(r + ((10 - n) * 100))
import collections
N,K=map(int,input().split())
while K>0:
  K=K-1
  d=int(input())
  a.append(map(str,input().split()))
e=collections.Counter(a)
p=N-len(e)
print(p)

### FIXED CODE ###

import collections
N,K=map(int,input().split())
a=[]
d=[]
while K>0:
  K=K-1
  d.append(int(input()))
  b=list(map(int,input().split()))
  a.extend(b)
e=collections.Counter(a)
print(N-len(e))
for x in range(1,10):
    for y in range(1,10):
        print "%d??%d=%d" % (x, y , x*y)

### FIXED CODE ###

for x in range(1,10):
    for y in range(1,10):
        print "%dx%d=%d" % (x, y , x*y)
import copy
import itertools
import sys

if sys.version[0] == '2':
    range, input = xrange, raw_input


drc = [(-1, 0), (0, 1), (1, 0), (0, -1)]
C_NUM = 6
while True:
    H, W, C = map(int, input().split())
    if not (H | W | C):
        break
    board = [[int(x) - 1 for x in input().split()] for _ in range(H)]
    ans = 0
    for ope in itertools.product(range(C_NUM), repeat=4):
        # print(ope)
        tmp_board = copy.deepcopy(board)
        for color in itertools.chain(ope, (C - 1,)):
            now_c = tmp_board[0][0]
            if now_c == color:
                continue
            stack = [(0, 0)]
            while stack:
                r, c = stack.pop()
                if tmp_board[r][c] == color:
                    continue
                tmp_board[r][c] = color
                for dr, dc in drc:
                    nr, nc = r + dr, c + dc
                    if 0 <= nr < H and 0 <= nc < W and tmp_board[nr][nc] == now_c:
                        stack.append((nr, nc))
        stack = [(0, 0)]
        while stack:
            r, c = stack.pop()
            if tmp_board[r][c] == -1:
                continue
            tmp_board[r][c] = -1
            for dr, dc in drc:
                nr, nc = r + dr, c + dc
                if 0 <= nr < H and 0 <= nc < W and tmp_board[nr][nc] == C - 1:
                    stack.append((nr, nc))
        ans = max(ans, sum(row.count(-1) for row in tmp_board))
    print(ans)

### FIXED CODE ###

import copy
import itertools
import sys

if sys.version[0] == '2':
    range, input = xrange, raw_input

drc = [(-1, 0), (0, 1), (1, 0), (0, -1)]
C_NUM = 6


def dfs(r, c, now_c, next_c):
    tmp_board[r][c] = next_c
    for dr, dc in drc:
        nr, nc = r + dr, c + dc
        if 0 <= nr < H and 0 <= nc < W and tmp_board[nr][nc] == now_c:
            dfs(nr, nc, now_c, next_c)


while True:
    H, W, C = map(int, input().split())
    if not (H | W | C):
        break
    board = [[int(x) - 1 for x in input().split()] for _ in range(H)]
    ans = 0
    for ope in itertools.product(range(C_NUM), repeat=4):
        if ope[0] == board[0][0] or ope[-1] == C - 1 or any(ope[i] == ope[i + 1] for i in range(3)):
            continue
        tmp_board = copy.deepcopy(board)
        for color in ope:
            dfs(0, 0, tmp_board[0][0], color)
        dfs(0, 0, tmp_board[0][0], C - 1)
        dfs(0, 0, tmp_board[0][0], -1)
        cand = sum(row.count(-1) for row in tmp_board)
        if cand > ans:
            ans = cand
    print(ans)
def main():
    N,X,M = map(int,input().split())
    dict = {key:0 for key in range(M)}
    #print(dict)
    dict[X] += 1
    cnt = 1
    A = [0]*M
    A[1] = X
    ans = X
    tmp = X
    for i in range(1,N,1):
        tmp = (tmp**2)%M
        if dict[tmp] != 0:
            break
        ans += tmp
        A[i+1] = A[i]+tmp
        cnt += 1
        dict[tmp] += cnt

    num = N - cnt#残り足す回数
    roop_num = cnt - dict[tmp] + 1
    syo = num//roop_num
    amari = num%roop_num
    ans += syo*(A[cnt]-A[dict[tmp]-1])
    ans += (A[dict[tmp]+amari-1]-A[dict[tmp]-1])
    return ans

print(main())


### FIXED CODE ###

def main():
    N,X,M = map(int,input().split())
    dict = {key:0 for key in range(M)}
    #print(dict)
    if N==1:
        return X
    dict[X] += 1
    cnt = 1
    A = [0]*(M+1)
    A[1] = X
    ans = X
    tmp = X
    for i in range(1,N,1):
        tmp = (tmp**2)%M
        if dict[tmp] != 0:
            break
        ans += tmp
        A[i+1] = A[i]+tmp
        cnt += 1
        dict[tmp] += cnt

    num = N - cnt#残り足す回数
    roop_num = cnt - dict[tmp] + 1
    syo = num//roop_num
    amari = num%roop_num
    ans += syo*(A[cnt]-A[dict[tmp]-1])
    ans += (A[dict[tmp]+amari-1]-A[dict[tmp]-1])
    return ans

print(main())
from collections import Counter


from operator import mul
from functools import reduce


def cmb(n, r):
    r = min(n-r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under


N = int(input())
A = list(map(int, input().split()))
c = Counter()
for i in A:
    c.update(str(i))
cmbL = {}
gsum = 0

for i in c.keys():
    tmp1 = cmb(int(c[i]), 2)
    tmp2 = tmp1 - (tmp1 * (1 - 2/c[i]))
    cmbL[i] = [tmp1, tmp2]
    gsum += tmp1

for i in A:
    print(int(gsum - cmbL[str(i)][1]))


### FIXED CODE ###

from collections import Counter


from operator import mul
from functools import reduce


def cmbf(n, r):
    if (n < r):
        return 0
    r = min(n-r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under


N = int(input())
A = list(map(int, input().split()))
c = [0]*(N+1)

for A_i in A:
    c[A_i] += 1

gsum = 0
for i in range(1, N + 1):
    if (c[i] != 0):
        gsum += cmbf(c[i], 2)

for i in A:
    print(gsum-(c[i]-1))