Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

def dp_fn():
  N, W = map(int, input().split())
  WV = (map(int, input().split()) for _ in range(N))
  
  from collections import defaultdict
  
  DP = defaultdict(int)
  DP[0] = 0
  
  for w, v in WV:
    for i in reversed(tuple(DP.keys())):
      if i + w <= W:
        DP[i+w] = max(DP[i] + v, DP[i+w])
  return max(DP.values())
  
print(dp_fn())


### FIXED CODE ###

import sys
input = sys.stdin.readline

def dp_fn():
  N, W = map(int, input().split())
  WV = (map(int, input().split()) for _ in range(N))
  
  DP = {0:0}
  
  for w, v in WV:
    keys = sorted(DP.keys(), reverse=True)
    for i in keys:
      j = DP[i]
      if j+w <= W:
        if i+v in DP:
          DP[i+v] = min(DP[i+v], j+w)
        else:
          DP[i+v] = j+w
  return max(DP.keys())
  
print(dp_fn())
### BUGGY CODE ###

from itertools import combinations

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

ans = 0


def dfs(v):
    if len(v) == 2:
        global ans
        ans = max((v[0] + v[1]) / 2, ans)
        return

    for vv in combinations(v, 2):
        v_alche = v[:]
        v_alche.remove(vv[0])
        v_alche.remove(vv[1])
        v_alche.append((vv[0] + vv[1]) / 2)
        dfs(v_alche)


dfs(values)
print(ans)


### FIXED CODE ###

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

v.sort(reverse=True)

while len(v) > 1:
    v = v[:-2] + [(v[-1] + v[-2]) / 2]

print(v[0])
### BUGGY CODE ###

n = int(input())
S = input()

if n <= 3:
    print(0)
    exit()

Rs = []
Gs = []
Bs = []

r = 0
g = 0
b = 0

for s in S:
    if s == 'R':
        r += 1
    if s == 'G':
        g += 1
    if s == 'B':
        b += 1

    Rs.append(r)
    Gs.append(g)
    Bs.append(b)

ans = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        if S[i] == S[j]:
            continue
        color = {'R', 'G', 'B'}
        color.discard(S[i])
        color.discard(S[j])
        desire = color.pop()

        pattern = 0
        if desire == 'R':
            pattern = Rs[-1] - Rs[j]
        elif desire == 'G':
            pattern = Gs[-1] - Gs[j]
        elif desire == 'B':
            pattern = Bs[-1] - Bs[j]
        delta = j-i
        if j+delta < n:
            if S[j+delta] == desire:
                pattern -= 1
        ans += pattern

print(ans)

### FIXED CODE ###

n = int(input())
S = input()

if n <= 3:
    print(0)
    exit()

Rs = []
Gs = []
Bs = []

r = 0
g = 0
b = 0

for s in S:
    if s == 'R':
        r += 1
    if s == 'G':
        g += 1
    if s == 'B':
        b += 1

    Rs.append(r)
    Gs.append(g)
    Bs.append(b)

ans = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        if S[i] == S[j]:
            continue
        color = {'R', 'G', 'B'}
        color.discard(S[i])
        color.discard(S[j])
        desire = color.pop()

        pattern = 0
        if desire == 'R':
            pattern = Rs[-1] - Rs[j]
        elif desire == 'G':
            pattern = Gs[-1] - Gs[j]
        elif desire == 'B':
            pattern = Bs[-1] - Bs[j]
        delta = j-i
        if j+delta < n:
            if S[j+delta] == desire:
                pattern -= 1
        ans += pattern

print(ans)
### BUGGY CODE ###

n,a,b=map(int,input().split())
mod=10**9+7
def comb(n,k,mod):
  if k>n-k:
    k=n-k
  c=1
  for i in range(n-k+1,n+1):
    c*=i
  d=1  
  for i in range(1,k+1):
    d*=i
  return (c*pow(d,mod-2,mod))%mod

ans=(2**n-1)%mod-comb(n,a,mod)-comb(n,b,mod)
print(ans%mod)


### FIXED CODE ###

n,a,b=map(int,input().split())
mod=10**9+7
def comb(n,k,mod):
  if k>n-k:
    k=n-k
  c=1
  for i in range(n-k+1,n+1):
    c*=i
    c%=mod
  d=1  
  for i in range(1,k+1):
    d*=i
    d%=mod
  return (c*pow(d,mod-2,mod))%mod

ans=pow(2,n,mod)-1-comb(n,a,mod)-comb(n,b,mod)
print(ans%mod)
### BUGGY CODE ###

from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

l = ins()
a = l[::-1]
x = 3 if a[0]=='1' else 1
for i in range(1,len(l)):
    if a[i]=='1':
        x = (2*x+3**i)%R
print(x)


### FIXED CODE ###

from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

l = ins()
a = l[::-1]
n = len(l)
x = 3 if a[0]=='1' else 1
for i in range(1,n):
    if a[i]=='1':
        x = (2*x+pow(3,i,R))%R
print(x)
### BUGGY CODE ###

N, K = [int(v) for v in input().split()]

link = []
for k in range(K):
    L, R = [int(v) for v in input().split()]

    for i in range(L, R+1):
        link.append(i)

link.sort()
#link.reverse()
#print(link)

count = [0, 1]

for i in range(2, N + 1):
    v = 0
    for l in link:
        if i < l:
            break
        v += count[i - l]
    count.append(v)

print(count[-1] % 998244353)


### FIXED CODE ###

N, K = [int(v) for v in input().split()]

links = []
for k in range(K):
    L, R = [int(v) for v in input().split()]
    links.append((L, R))

links = sorted(links, key=lambda x: x[1])

count = [1]
sub = [0, 1]
subtotal = 1

for i in range(1, N):
    v = 0
    for l, r in links:
        r2 = i - l + 1
        l2 = i - r
        if l2 < 0:
            l2 = 0
        if r2 >= 0:
            v += sub[r2] - sub[l2]

    count.append(v % 998244353)
    subtotal = (subtotal + v) % 998244353
    sub.append(subtotal )

print(count[-1])
### BUGGY CODE ###

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

a=[-1]*N
b=1
for i in range(N):
    if not b in a:
        a[i]=b
        b=List[b-1]
    else:
        c=i
        break
#print(a)
#print(b,c)
num=a.index(b)
#print(T,num)
T=c-num
if K<num:
    print(a[K])
else:
    print(a[num:][(K-num)%T])

### FIXED CODE ###

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

a=[]

for i in range(N):
    a.append(-1)
#print(a)
b=1
for i in range(N):
    if a[b-1]==-1:
        a[b-1]=i+1
        b=List[b-1]
        
    else:
        c=i
        break
#print(a)
#print(b,c)

num=a[b-1]-1
T=c-num
#print(T)
e=1
if K<num:
    for i in range(K):
        e=List[e-1]
    print(e)
else:
    qw=(K-num)%T
    List_new=[]
    for i in range(T):
        List_new.append(b)
        b=List[b-1]
    print(List_new[qw])
### BUGGY CODE ###

mod=10**9+7

n=int(input())

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

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

def lcm(a,b):
    return a//gcd(a,b)*b

lcma=1

for i in range(n):
    lcma=lcm(lcma,a[i])

ans=0

for i in range(n):
    ans=(ans+lcma//a[i])

print(ans%mod)



### FIXED CODE ###

mod=10**9+7

n=int(input())

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

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

def lcm(a,b):
    return a//gcd(a,b)*b

lcma=1

for i in range(n):
    lcma=lcm(lcma,a[i])

ans=0

for i in range(n):
    ans=(ans+lcma//a[i])

print(ans%mod)
### BUGGY CODE ###

n,m=map(int,input().split())
ass=[tuple(map(int,input().split())) for i in range(m)]
ass.sort(key = lambda x:x[0])

count = 0

while ass != []:
    count = count+1
    ref = min(ass,key = lambda x:x[1])
    index = next((i for i,x in enumerate(ass) if x[0]>=ref[1]),len(ass))
    ass = ass[index::]

print(count)



### FIXED CODE ###

n,m=map(int,input().split())
ass=[tuple(map(int,input().split())) for i in range(m)]
ass.sort(key=lambda x:x[1])

acum = []

def ifsatisfied(ab):
    for x in acum:
        if ab[0]<x <=ab[1]:
            return(True)
    return(False)

for ab in ass:
    if not ifsatisfied(ab):
        acum.append(ab[1])

print(len(acum))
### BUGGY CODE ###

s = input()
q = int(input())
query = [input().split() for _ in range(q)]

for i in query:
    if len(i) == 1:
        s = s[::-1]
    else:
        if i[1] == '1':
            s = i[2] + s
        if i[1] == '2':
            s = s + i[2]

print(s)


### FIXED CODE ###

from collections import deque

s = deque(input())
q = int(input())
query = [input().split() for _ in range(q)]

reverse = False
for i in query:
    if len(i) == 1:
        if reverse:
            reverse = False
        else:
            reverse = True
    else:
        if reverse:
            if i[1] == '1':
                s.append(i[2])
            else:
                s.appendleft(i[2])
        else:
            if i[1] == '1':
                s.appendleft(i[2])
            else:
                s.append(i[2])
if reverse:
    s = reversed(s)
    s = ''.join(s)
    print(s)
else:
    s = ''.join(s)
    print(s)
### BUGGY CODE ###

a = int(input())
b= [int(x) for x in input().split()]
c = a
for s in range(a-1):
  d = b[s]
  e = b[s]
  for t in range(s+1, a):
    d = d ^ b[t]
    e = e + b[t]
    if d == e:
      c += 1
    else:
      break
print(c)

### FIXED CODE ###

N = int(input())
A= [int(x) for x in input().split()]
A.append(0)
count = N
s = 0
t = 1
xor = A[0]
while s < N - 1:
  while t < N:
    if not A[t] or not (xor & A[t]):
      xor ^= A[t]
      t += 1
    else:
      break
  count += t - s - 1
  while s < t:
    xor ^= A[s]
    s += 1
    if xor & A[t]:
      count += t - s - 1
      continue
    else:
      break
  if s == t:
    xor = A[s]
    t += 1
print(count)
### BUGGY CODE ###

n = int(input())
s = [input() for _ in range(n)]

c = 0
for i in range(len(s)):
    t1 = list(s[i])
    t1.sort()

    for j in range(i+1, len(s)):
        t2 = list(s[j])
        t2.sort()

        if t1 == t2:
            c+=1
print(c)

### FIXED CODE ###

from collections import Counter

n = int(input())
s = ["".join(sorted(list(input()))) for _ in range(n)]
ans = 0
for i in Counter(s).values():
    ans+=(i*(i-1))/2
print(int(ans))
### BUGGY CODE ###

h,w,m=list(map(int, input("").split()))
out=0
o=0
hb=[]
wb=[]
for i in range(h):
    hb.append([0,i+1])
for i in range(w):
    wb.append([0,i+1])
bo=[]
for i in range(m):
    a,b=list(map(int, input("").split()))
    hb[a-1][0]+=1
    wb[b-1][0]+=1
    bo.append([a,b])
list.sort(hb, reverse=True)
list.sort(wb, reverse=True)
for i in hb:
    if i[0] ==hb[0][0]:
        for j in wb:
            if j[0] ==wb[0][0]:
                o=i[0]+j[0]
                if [i[1],j[1]] in bo:
                    o-=1
                if o>out:
                    out=o
            else:
                break
    else:
        break
print(out)


### FIXED CODE ###

h,w,m=list(map(int, input("").split()))
bo=[]
hb=[0]*h
wb=[0]*w
for i in range(m):
    a,b=list(map(int, input("").split()))
    #各行列に爆弾いくつあるか
    hb[a-1]+=1
    wb[b-1]+=1
    #爆弾の座標
    bo.append([a,b])
#ソート
mwb=[]
mhb=[]
#爆弾数が最大の行と列番号をメモ
hmax=max(hb)
wmax=max(wb)
for i in range(h):
    if hb[i]==hmax:
        mhb.append(i)
for i in range(w):
    if wb[i]==wmax:
        mwb.append(i)
c=0
#最大の爆弾数の行と列に含まれる爆弾数=cの確認
for h,w in bo:
     #h in mhb and w in mwb
    if(hb[h-1] == hmax and wb[w-1] == wmax):
        c+=1
#行と列の最大爆弾数の和
out=hmax+wmax
#行と列の最大数の積がcと一致するなら必ず重複があるので－1
if c==len(mwb)*len(mhb):
    out-=1
print(out)
### BUGGY CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))
S_mod = [0]
s = 0
for a in A:
    s += a
    S_mod.append(s % M)

count = 0
for r in range(1, N+1):
    if S_mod[r] == 0:
        count += 1
    count += S_mod[(r + 1):].count(S_mod[r])

print(count)


### FIXED CODE ###

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

mod_dict = dict()
S_mod = [0]
s = 0
for a in A:
    s += a
    mod = s % M
    S_mod.append(mod)
    if not mod in mod_dict.keys():
        mod_dict[mod] = 1
    else:
        mod_dict[mod] += 1

if 0 in mod_dict.keys():
    count = mod_dict[0]
else:
    count = 0
for key in mod_dict.keys():
    count += (mod_dict[key] - 1) * mod_dict[key] / 2

print(int(count))
### BUGGY CODE ###

h, n = map(int, input().split())
dp = [1000000000] * (h+1)
dp[0] = 0
for i in range(n):
    a, b = map(int, input().split())
    for j in range(h):
        # nj = min(j + a, h)
        if j + a < h: nj = j + a
        else: nj = h
        # dp[nj] = min(dp[nj], dp[j] + b)
        if dp[nj] > dp[j] + b: 
            dp[nj] = dp[j] + b
print(dp[h])

### FIXED CODE ###

h, n = map(int, input().split())
ab = []
for i in range(n):
    ab.append(list(map(int, input().split())))
###一次元DP
dp = [100000000] * (h+1)
dp[0] = 0
for i in range(1, h+1):
    for j in range(n):
        a = ab[j][0]
        b = ab[j][1]
        # print(i, j)
        temp = i - a
        if temp < 0:
            temp = 0
        need_magic = dp[temp] + b
        if need_magic < dp[i]:
            dp[i] = need_magic
        # dp[i] = min(dp[i], dp[max(i-a, 0)] + b)
        # print(i, j, a, b, dp)
print(dp[-1])
### BUGGY CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

N, M = map(int, input().split())
G = [[] for _ in range(N)]
has_parent = [False] * N
for i in range(M):
    L, R, D = map(int, input().split())
    L -= 1
    R -= 1
    G[L].append((R, D))
    has_parent[R] = True


def dfs(v):
    visited[v] = True
    for u, d in G[v]:
        if dist[u] == float('inf'):
            dist[u] = dist[v] + d
        if dist[u] != dist[v] + d:
            print('No')
            exit()
        dfs(u)


dist = []
visited = [False] * N
for v in range(N):
    if not has_parent[v]:
        dist = [float('inf')] * N
        dist[v] = 0
        dfs(v)
if all(visited):
    print('Yes')
else:
    print('No')


### FIXED CODE ###

import sys
input = sys.stdin.readline

N, M = map(int, input().split())
G = [[] for _ in range(N)]
for i in range(M):
    L, R, D = map(int, input().split())
    L -= 1
    R -= 1
    G[L].append((R, D))
    G[R].append((L, -D))

visited = [False] * N
dist = [float('inf')] * N
for i in range(N):
    if not visited[i]:
        dist[i] = 0
        stack = [i]
        while stack:
            v = stack.pop()
            visited[v] = True
            for u, d in G[v]:
                if dist[u] == float('inf'):
                    dist[u] = dist[v] + d
                elif dist[u] != dist[v] + d:
                    print('No')
                    exit()
                if not visited[u]:
                    stack.append(u)
print('Yes')
### BUGGY CODE ###

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

A = [0]*N

for i in range(1,N):
  temp = []
  for j in range(1,min(K+1,i+1)):
    temp.append(A[i-j] + abs(H[i] - H[i-j]))
  A[i] = min(temp)

print(A[N-1])

### FIXED CODE ###

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

A = [0]*N

for i in range(1,N):
  A[i] = min([(A[i-j]+abs(H[i]-H[i-j])) for j in range(1,min(K+1,i+1))])

print(A[N-1])
### BUGGY CODE ###

from collections import Counter

N = int(input())
A = list(map(int,input().split()))
counter = Counter(A)
s = sorted(set(A))
if len(A) == 1:
    print(1)
else:
    lst = []
    ans = 0
    for i in range(len(s)):
        # m = int(s[i]**0.5)+1
        flg = True
        for p in lst:
            if s[i]%p == 0:
                flg = False
                break
            # elif m < p:
            #     break
        if flg:
            lst.append(s[i])
            if counter[s[i]] == 1:
                ans += 1
    print(ans)

### FIXED CODE ###

from collections import Counter

N = int(input())
A = list(map(int,input().split()))
s = set(A)
counter = Counter(A)
A.sort()
ans = [1]*(10**6+1)
for i in range(1,10**6+1):
    if i in s and ans[i]:
        tmp = i
        cnt = 2
        while tmp*cnt <= 10**6:
            ans[tmp*cnt] = 0
            cnt += 1
    else:
        ans[i] = 0
    if counter[i] != 1:
        ans[i] = 0
print(sum(ans)-1)
### BUGGY CODE ###

# %%
n = int(input())
x = input()

num_of_1 = x.count("1")

first = int(x, 2)

def f(x):
    if x == 0:
        return 0
    return 1 + f(x % bin(x).count('1'))

if num_of_1 == 1:
    for i in range(n):
        if x[i] == '1':
            print(0)
        elif i == n-1:
            print(2)
        else:
            print(1)
    exit()

for i in range(n):
    ans = 0

    if x[i] == "0":
        temp_num_of_1 = num_of_1 + 1
        a = first + 2 ** (n - i - 1)
    else:
        temp_num_of_1 = num_of_1 - 1
        a = first - 2 ** (n - i - 1)

    a = a % temp_num_of_1

    ans += 1 + f(a)

    print(ans)

### FIXED CODE ###

n = int(input())
x = input()

num_of_1 = x.count("1")

first = int(x, 2)

def f(x):
    if x == 0:
        return 0
    return 1 + f(x % bin(x).count('1'))

if num_of_1 == 1:
    for i in range(n):
        if x[i] == '1':
            print(0)
        elif i == n-1:
            print(2)
        else:
            print(1)
    exit()

first_one, first_zero = first % (num_of_1 - 1), first % (num_of_1 + 1)

for i in range(n):
    if x[i] == "0":
        print(1 + f((first_zero + pow(2, n-i-1, num_of_1 + 1)) % (num_of_1 + 1)))
    else:
        print(1 + f((first_one - pow(2, n-i-1, num_of_1 - 1)) % (num_of_1 - 1)))
### BUGGY CODE ###

from itertools import permutations as pe
n,m,r=map(int,input().split())
s=[[(0 if i==j else float("inf"))for j in range(n+1)]for i in range(n+1)]
g=list(pe(list(map(int,input().split()))))
for i in range(m):
    a,b,c=map(int,input().split())
    s[a][b]=c
    s[b][a]=c
for h in range(1,n+1):
    for i in range(1,n+1):
        for j in range(1,n+1):
            if s[i][j]>s[i][h]+s[h][j]:
                s[i][j]=s[i][h]+s[h][j]
k=float("inf")
for i in range(len(g)):
    d=g[i]
    c=0
    for j in range(1,len(d)):
        c+=s[d[j-1]][d[j]]
        if c>=k:
            break
    else:
        k=min(c,k)
print(k)


### FIXED CODE ###

from itertools import permutations as pe
from scipy.sparse.csgraph import floyd_warshall as wf
n,m,r=map(int,input().split())
s=[[(0 if i==j else float("inf"))for j in range(n+1)]for i in range(n+1)]
g=list(pe(list(map(int,input().split()))))
for i in range(m):
    a,b,c=map(int,input().split())
    s[a][b]=c
    s[b][a]=c
s=wf(s,directed=False)
k=float("inf")
for i in range(len(g)):
    d=g[i]
    c=0
    for j in range(1,len(d)):
        c+=s[d[j-1]][d[j]]
        if c>=k:
            break
    else:
        k=min(c,k)
print(int(k))
### BUGGY CODE ###

import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    def popcount(n):
        flg = 0
        for mask in range(len(bin(n)) - 2):
            flg += (n >> mask) & 1
        return flg

    n = int(input())
    X = input()
    cnt_init = 0
    for i in range(n):
        if X[i] == "1":
            cnt_init += 1

    t = [1] * n
    for i in range(1, n):
        t[i] = t[i - 1] * 2

    for j in range(n):
        if X[j] == "1":
            cnt = cnt_init - 1
            x = int(X, 2) - t[n - j - 1]
        else:
            cnt = cnt_init + 1
            x = int(X, 2) + t[n - j - 1]

        res = 0
        while x:
            if res != 0:
                cnt = popcount(x)
            x %= cnt
            res += 1
        print(res)


if __name__ == '__main__':
    resolve()


### FIXED CODE ###

import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    X = input()
    cnt_init = X.count("1")
    x = int(X, 2)
    a = x % (cnt_init + 1)
    if cnt_init - 1 != 0:
        b = x % (cnt_init - 1)

    for i in range(n):
        if X[i] == "0":
            cnt = cnt_init + 1
            y = (a + pow(2, n - i - 1, cnt)) % cnt
        else:
            cnt = cnt_init - 1
            if cnt == 0:
                print(0)
                continue
            y = (b - pow(2, n - i - 1, cnt)) % cnt

        res = 1
        while y:
            cnt = bin(y).count("1")
            y %= cnt
            res += 1
        print(res)


if __name__ == '__main__':
    resolve()
### BUGGY CODE ###

import math

def func(A, B, x):
    return math.floor(A*x/B)-A*math.floor(x/B)

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

i = 1
max_x = -9999999
max = -9999999
while (i <= N):
    ans =func(A, B, i) 
    if (ans > max):
        max = ans
        max_x = i
    i += 1

print(max)

### FIXED CODE ###

import math

def func(A, B, x):
    return math.floor(A*x/B)-A*math.floor(x/B)

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

"""
i = 1
max_x = -9999999
max = -9999999
while (i <= N):
    ans =func(A, B, i) 
    if (ans > max):
        max = ans
        max_x = i
    i += 1

print(max)
"""

print(func(A, B, min(B-1, N)))
### BUGGY CODE ###

n,p=map(int,input().split());a=1;print(n<2and p or exec("for i in range(2,int(p**.5)+1):\n while p%(i**n)<1:a*=i;p//=i**n")or a)

### FIXED CODE ###

n,p=map(int,input().split());a=1
print(n<2and p or exec("for i in range(2,int(p**(1./n))+1):\n while p%(i**n)<1:a*=i;p//=i**n")or a)
### BUGGY CODE ###

def count(x,length):
    num=0
    for i in range(length-1):
        for j in range(i+1,length-1):
            if x[i]==x[j]:
                num+=1
    return num
  
x=int(input())
a=list(map(int,input().split()))

num=0
for i in range(x):
    delete=a[0]
    del a[0]
    print(count(a,x))
    a.append(delete)

### FIXED CODE ###

import collections

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

c=collections.Counter(a)
num=0
for i in c.values():
    num+=i*(i-1)/2
    
for i in range(x):
    print(int(num-c[a[i]]+1))
### BUGGY CODE ###

import itertools
import sys
input = sys.stdin.buffer.readline

def main():
    N,M,R = map(int,input().split())
    r = list(map(int,input().split()))
    INF = 10**6
    root = [[INF for _ in range(N)] for _ in range(N)]
    for i in range(N):
        root[i][i] = 0
    for i in range(M):
        A,B,C = map(int,input().split())
        root[A-1][B-1] = C
        root[B-1][A-1] = C
    
    for i in range(N):
        for j in range(N):
            for k in range(N):
                root[j][k] = min(root[j][k],root[j][i]+root[i][k])
                
    ans = INF
    for i in itertools.permutations(r):
        L = 0
        for j in range(R-1):
            L += root[i[j]-1][i[j+1]-1]
        ans = min(ans,L)
                
    print(ans)
    
if __name__ == "__main__":
    main()

### FIXED CODE ###

import itertools
import numpy as np
import sys
input = sys.stdin.buffer.readline

def main():
    N,M,R = map(int,input().split())
    r = list(map(int,input().split()))
    INF = float('INF')
    root = [[INF for _ in range(N)] for _ in range(N)]
    for i in range(N):
        root[i][i] = 0
    for i in range(M):
        A,B,C = map(int,input().split())
        root[A-1][B-1] = C
        root[B-1][A-1] = C
    
    for i in range(N):
        for j in range(N):
            for k in range(N):
                if root[j][k] > root[j][i]+root[i][k]:
                    root[j][k] = root[j][i]+root[i][k]
                
    ans = INF
    for i in itertools.permutations(r):
        L = 0
        for j in range(R-1):
            L += root[i[j]-1][i[j+1]-1]
        ans = min(ans,L)
                
    print(ans)
    
if __name__ == "__main__":
    main()