Harryxun/stf_run huggingface dataset:
N = int(input())

xyh = [tuple(map(int, input().split())) for _ in range(N)]

for cx in range(0, 101):
    for cy in range(0, 101):
        flag = True

        for i, (x,y,h) in enumerate(xyh):
            if h == 0:
                H = h + abs(x - cx) + abs(y - cy)

        for i, (x,y,h) in enumerate(xyh):
            if h == max(H - abs(x - cx) - abs(y - cy), 0):
                continue
            else:
                flag = False
                break
        if flag:
            print(cx, cy, H)
            exit()


### FIXED CODE ###

n = int(input())

datas = [list(map(int, input().split())) for _ in range(n)]

for Cx in range(101):
  for Cy in range(101):
    flag = True
    H = 0
    for data in datas:
      if data[2] != 0:
        #高さをあるデータから適当に決める
        H = data[2] + abs(data[0] - Cx) + abs(data[1] - Cy)
        break
        
    #直前で適当に決めた高さがほかのデータにも適合すればOK
    for data in datas:
      if data[2] != 0:
        if H != data[2] + abs(data[0] - Cx) + abs(data[1] - Cy):
          flag = False
          break
      else:
        #hi = 0ならH-abs(data[0] - Cx)-abs(data[1] - Cy)<= 0であるあず
        if H - abs(data[0] - Cx) - abs(data[1] - Cy) > 0:
          flag = False
          break
          
    if flag:
      print(Cx, Cy, H)
S = int(input())
h = S//3600
m = (S//60)-(S//3600)
a = str(h)
b = str(m)
c = str(s)
print("a:b:c")



### FIXED CODE ###

S = int(input())
h = S//3600
m = (S//60)-60*(S//3600)
s = S%60
print('{}:{}:{}'.format(h,m,s))
True:
    H, W = [int(i) for i in input().split()]
    if H == W == 0:
        break
        
    for h in range(H):
        for w in range(W):
            if  (h + w) % 2 == 0:
                print('#', end='')
                
            else:
                print('.', end='')
                
        print()

### FIXED CODE ###

while True:
 
    H,W =[int(i) for i in input().split()]
 
    if H == W == 0:
        break
 
    for h in range(H):
        for w in range(W):
            if (h+w) % 2 ==0:
                print('#', end='')
            else :
                print('.' ,end='')
        print()
    print()
def prime_number(x):
    if x==2 or x==3:
        return True
    else:
        if x&2==0 or x%3==0:
            return False
        else:
            divisor_lst = [1,x]
            for i in range(1,x+1):
                if i%2!=0 and i%3!=0:
                    if i not in divisor_lst and x%i==0:
                        return False
                    break
            else:
                return True

n = int(input())

if prime_number(n):
    print(n-1)
else:
    i = 1
    j = n//i
    divisor_lst = []
    while i<=j:
        i += 1
        j = n//i
        if n%i==0:
            divisor_lst.append([i,j])

    n_x = divisor_lst[-1][0]
    n_y = divisor_lst[-1][1]
    print(n_x+n_y-2)

### FIXED CODE ###

n = int(input())

need_lst = []
for i in range(1,int(n**(1/2)+1)):
    if n%i==0:
        need = i+n//i
        need_lst.append(need-2)

print(min(need_lst))
from numpy import *
ABs=[]
CDs=[]
n = int(input())
for i in range(n):
    x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4, = map(float, input().split())
    AB = array([x_2 - x_1, y_2 - y_1])
    CD = array([x_4 - x_3, y_4 - y_3])
    ABs.append(AB)
    CDs.append(CD)
for i in range(n):
    if linalg.norm(cross(ABs[i],CDs[i]))==0.0:
        print("YES")
    else:
        print("NO")

### FIXED CODE ###

ABs=[]
CDs=[]
n = int(input())
for i in range(n):
    x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4, = map(float, input().split())
    AB = [x_2 - x_1, y_2 - y_1]
    CD = [x_4 - x_3, y_4 - y_3]
    ABs.append(AB)
    CDs.append(CD)
for i in range(n):
    if abs(ABs[i][0]*CDs[i][1]-ABs[i][1]*CDs[i][0])<10**(-10):
        print("YES")
    else:
        print("NO")
nums = input().split()
a = int(nums[0])
b = int(nums[1])
c = int(nums[2])

S = sort(a, b, c)
print(S)

### FIXED CODE ###

nums = input().split()
a = int(nums[0])
b = int(nums[1])
c = int(nums[2])

if a <= b <= c:
    print(a, b, c)

elif a <= c <= b:
    print(a, c, b)

elif b <= a <= c:
    print(b, a, c)

elif b <= c <= a:
    print(b, c, a)

elif c <= a <= b:
    print(c, a, b)

else:
    print(c, b, a)
from collections import defaultdict

N, M = map(int, input().split())
A = list(map(int, input().split()))
cumS = [0]
for a in A:
    cumS.append(a + cumS[-1])
cumS_rem = defaultdict(int)
for c in cumS:
    r = c % M
    cumS_rem[r] += 1
ans = 0
for r, n_r in cumS_rem.items()
    if n_r > 1:
        ans += n_r*(n_r-1)//2
print(ans)

### FIXED CODE ###

from collections import defaultdict

N, M = map(int, input().split())
A = list(map(int, input().split()))
cumS = [0]
for a in A:
    cumS.append(a + cumS[-1])
cumS_rem = defaultdict(int)
for c in cumS:
    r = c % M
    cumS_rem[r] += 1
ans = 0
for r, n_r in cumS_rem.items():
    if n_r > 1:
        ans += n_r*(n_r-1)//2
print(ans)
N=int(input())
count=0
a=list(map(int,input().split()))
w=[]
s=[]
maxi=max(a)
mini=min(a)
num=[0]*200000000
maxi=max(a)
for i in range(N):
  w.append(1+i+a[i])
  s.append(1+i-a[i])
  num[1+i-a[i]+maxi]+=1
for i in range(N):
  count+=num[w[i]+maxi]
print(count)

### FIXED CODE ###

N=int(input())
count=0
a=list(map(int,input().split()))
w=[]
s=[]
num=[0]*N
maxi=max(a)
for i in range(N):
  s.append(1+i-a[i])
  if 1+i+a[i]<N:
    num[1+i+a[i]]+=1
for i in range(N):
  if s[i]>=0:
    count+=num[s[i]]
print(count)
N = int(input())
A = map(int, input().split(" "))
n = [0] * (2 * 10 ** 5 + 1)
for v in A:
    n[v] += 1
    if 2 * v > (2 * 10 ** 5 // v + 1) * v:
        continue
    for i in range(2 * v, (2 * 10 ** 5 // v + 1) * v, v):
        n[i] += 10
cnt = 0
n.pop(0)
for v in n:
    if v == 1:
        cnt += 1
print(cnt)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split(" ")))
a_max = max(A)
cnts = [0] * (a_max + 1)
for a in A:
    v = a
    while v <= a_max:
        cnts[v] += 1
        v += a
cnt = 0
for a in A:
    if cnts[a] == 1:
        cnt += 1
print(cnt)
import numpy as np
l=list(map(int,input().split()))
N=l[0]
K=l[1]
L=list(map(int,input().split()))
L=np.array(L)
a=L[0]
v=0
X=np.zeros(N, dtype = int)
Y=np.zeros(N, dtype = int)
X[0]=1
Y[0]=0
for i in range(K):
    b=a
    if X[b-1]==1:
        k1=Y[b-1]
        k2=i+1-k1
        v=1
        A=np.zeros(N, dtype = int)
        A[a-1]=1
        a=np.dot(L,A)
        break
    X[a-1]+=1
    Y[a-1]=i+1
    A=np.zeros(N, dtype = int)
    A[a-1]=1
    a=np.dot(L,A)
    
if v==1:
    K=(K-k1)%k2
    for i in range(K):
        b=a
        A=np.zeros(N, dtype = int)
        A[a-1]=1
        a=np.dot(L,A)


print(b)



    



### FIXED CODE ###

l=list(map(int,input().split()))
N=l[0]
K=l[1]
L=list(map(int,input().split()))
a=L[0]
v=0
X=[]
Y=[]
for i in range(N):
    X.append(0)
    Y.append(0)
X[0]=1
Y[0]=0
for i in range(K):
    b=a
    if X[b-1]==1:
        k1=Y[b-1]
        k2=i+1-k1
        v=1
        a=L[a-1]
        break
    X[a-1]+=1
    Y[a-1]=i+1
    a=L[a-1]
    
if v==1:
    K=(K-k1)%k2
    for i in range(K):
        b=a
        a=L[a-1]


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

if A == 0:
    print(0)
else:
    s = 'b' * A + 'r' * B
    i = N // (A + B)
    j = N % (A + B)
    a = s[:j].count('b')
    count = A * i + a
    print(count)

### FIXED CODE ###

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

if A == 0:
    print(0)
else:
    i = N // (A + B)
    j = N % (A + B)
    if j >= A:
        count = A * (i + 1)
        print(count)
    else:
        count = A * i + j
        print(count)
A = int(input())
B = int(input())

ans = 0
outlet = 1

while B > outlet:
    ans = ans + 1
    outlet = outlet + (A-1)
print(ans)

### FIXED CODE ###

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

ans = 0
outlet = 1

while b > outlet:
    ans = ans + 1
    outlet = outlet + (a-1)
print(ans)
n=int(input())
for i in range(10**9)
    print("Case "+str(i+1)+": "+str(n))
    n=int(input())


### FIXED CODE ###

n=int(input())
for i in range(10**9):
    print("Case "+str(i+1)+": "+str(n))
    n=int(input())
    if n==0:exit()
anb2 = lambda a,b: -(abs(int(1.0*a/b)))

def number(begin):
	global i
	
	if begin[i] == "(":
		i += 1
		res = expression(begin)
		i += 1 
		return res
	
	res = 0
	
	while begin[i].isdigit():
		res *= 10
		res += int(begin[i])
		i+=1
	
	return res
	
def term(begin):# your code goes here

	global i
	res = number(begin)
	
	while True:
		if begin[i] == "*":
			i += 1
			res *= number(begin)
		elif begin[i] == "/":
			i += 1
			num = number(begin)
			if res < 0 or num < 0:
				res = abs2(res,num)
			else:
				res /= num
		else:
			break
	return res
	
def expression(begin):
	
	global i
	res = term(begin)
	
	while True:
		if begin[i] == "+":
			i += 1
			res += term(begin)
			
		elif begin[i] == "-":
			i += 1
			res -= term(begin)
		else:
			break
	return res
	

def main():
	global i
	for j in range(input()):
			i = 0
			ex = raw_input() +"="
			ans = expression(ex)
	
			print ans
main()

### FIXED CODE ###

abs2 = lambda a,b: -(abs(int(1.0*a/b)))

def number(begin):
	global i
	
	if begin[i] == "(":
		i += 1
		res = expression(begin)
		i += 1 
		return res
	
	res = 0
	
	while begin[i].isdigit():
		res *= 10
		res += int(begin[i])
		i+=1
	
	return res
	
def term(begin):# your code goes here

	global i
	res = number(begin)
	
	while True:
		if begin[i] == "*":
			i += 1
			res *= number(begin)
		elif begin[i] == "/":
			i += 1
			num = number(begin)
			if res < 0 or num < 0:
				res = abs2(res,num)
			else:
				res /= num
		else:
			break
	return res
	
def expression(begin):
	
	global i
	res = term(begin)
	
	while True:
		if begin[i] == "+":
			i += 1
			res += term(begin)
			
		elif begin[i] == "-":
			i += 1
			res -= term(begin)
		else:
			break
	return res
	

def main():
	global i
	for j in range(input()):
			i = 0
			ex = raw_input() +"="
			ans = expression(ex)
	
			print ans
main()
N = int(input())
v = list(map(int,input().split()))
def func(a,b):
    return (a+b)/2
  v = sorted(v)
ave = (v[0]+v[1])/2
for i in range(2,N):
    ave = func(ave,v[i])
    
print(ave)

### FIXED CODE ###

N = int(input())
v = list(map(int,input().split()))
def func(a,b):
    return (a+b)/2
v = sorted(v)
ave = (v[0]+v[1])/2
for i in range(2,N):
    ave = func(ave,v[i])
    
print(ave)
N = int(input())
a,b,c,d = [0]*N,[0]*N,[0]*N,[0]*N
for i in range(N):
    a[i],b[i] = map(int,input().split())
for i in range(N):
    c[i],d[i] = map(int,input().split())

ans=0
for k in range(N):
    for i in range(N):
        if a[i] == k or b[i] == k:
            ans += 1
            a.pop(i)
            b.pop(i)
            break
        elif c[i] == k or d[i] == k:
            c.pop(i)
            d.pop(i)

print(ans)
            

### FIXED CODE ###

N,M = map(int, input().split())
if N==1 and M==1:
    print(1)
elif N<3 and M<3:
    print(0)
elif N==1 or M==1:
    print(max(N-2,M-2))
elif N==2 or M==2:
    print(0)
else:
    print(max(N-2,1)*max(M-2,1))
n, a, b = map(int, input().split())

ans = 0
for i in range(1, n+1):
    sum = 0
    while i != 0:
        sun += i%10
        i = i//10
    if sum >= a and sum <= b:
        ans += i
print(ans)

### FIXED CODE ###

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

ans = 0
for i in range(1, n+1):
    s = str(i)
    l = 0
    for j in range(len(s)):
        l += int(s[j])
    if l >= a and l <= b:
        ans += i
print(ans)
N, M, K = [int(i) for i in input().split()]

As = [int(i) for i in input().split()]
Bs = [int(i) for i in input().split()]

cnt = 0
time = 0
while time <= K:
    if As and Bs:
        if As[0] > Bs[0]:
            p = Bs.pop(0)
        elif Bs[0] >= As[0]:
            p = As.pop(0)
        else :
    else :
        if As:
            p = As.pop(0)
        elif Bs:
            p = Bs.pop(0)
        else :
            break
    time += p
    if time > K:
        break
    cnt += 1
    
print(cnt)

### FIXED CODE ###

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

array_A = [int(i) for i in input().split()]
array_B = [int(i) for i in input().split()]

array_A_2 = [0]
array_B_2 = [0]

for a in array_A:array_A_2.append(array_A_2[- 1]+a)
for b in array_B:array_B_2.append(array_B_2[- 1]+b)

output, j = 0, M

for i in range(N + 1):
    if array_A_2[i] > K:
        break
    while array_B_2[j] > K - array_A_2[i]:
        j -= 1
    output = max(output, i + j)

print(output)
N = int(input())
table = [0,0,1]
if N >= 4:
  for i in range(3, N):
    table.append((table[i-1] + table[i-3]) % mod)
  print(table[-1] % mod)
elif N == 3:
  print(1)
else:
  print(0)

### FIXED CODE ###

N = int(input())
mod = 10 ** 9 + 7

table = [0,0,1]
if N >= 4:
  for i in range(3, N):
    table.append((table[i-1] + table[i-3]) % mod)
  print(table[-1] % mod)
elif N == 3:
  print(1)
else:
  print(0)
import sys
input = sys.stdin.readline

W,H=map(int,input().split())
p=sorted(int(input()) for i in range(W))
q=sorted(int(input()) for i in range(H))
ans=sum(p)*(H+1)+sum(q)*(W+1)
for i in range(W+H-1):
  if p[len(p)-1]>=q[len(q)-1]:
    ans-=p[len(p)-1]*len(q)
    p.pop()
  else:
    ans-=q[len(q)-1]*len(p)
    q.pop()
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline

W,H=map(int,input().split())
p=sorted(int(input()) for i in range(W))
q=sorted(int(input()) for i in range(H))
ans=sum(p)*(H+1)+sum(q)*(W+1)
for i in range(W+H):
  if p[len(p)-1]>=q[len(q)-1]:
    ans-=p[len(p)-1]*len(q)
    p.pop()
    if p==[]:
      print(ans)
      exit()
  else:
    ans-=q[len(q)-1]*len(p)
    q.pop()
    if q==[]:
      print(ans)
      exit()
import math
  
n = int(input())
 
def koch(n,x_0,y_0,x_1,y_1):
    if n == 0:
        return  
    x_s = x_0 + (x_1- x_0)/3
    y_s = y_0 + (y_1 -y_0)/3
    x_t = x_0 + (x_1- x_0)* 2/3
    y_t = y_0 + (y_1 -y_0) *2/3
    x_u =  (x_t - x_s) * math.cos(math.pi/3) - (y_t - y_s) * math.sin(math.pi/3) + x_s
    y_u =  (x_t - x_s) * math.sin(math.pi/3) + (y_t - y_s) * math.cos(math.pi/3) + y_s
  
    koch(n-1,x_0,y_0,x_s,y_s)
    print(x_s,y_s)
    koch(n-1,x_s,y_s,x_u,y_u)
    print(x_u,y_u)
    koch(n-1,x_u,y_u,x_t,y_t)
    print(x_t,y_t)
    koch(n-1,x_t,y_t,x_1,y_1)
      
print(0,0)
koch(n,0,0,100,0)
print(100,0)


### FIXED CODE ###

import math
  
n = int(input())
  
  
  
def koch(n,x_0,y_0,x_1,y_1):
    if n == 0:
        return  
    x_m1 = x_0 + (x_1- x_0)/3
    y_m1 = y_0 + (y_1 -y_0)/3
    x_m2 = x_0 + (x_1- x_0)* 2/3
    y_m2 = y_0 + (y_1 -y_0) *2/3
    x_m =  (x_m2 - x_m1) * math.cos(math.pi/3) - (y_m2 - y_m1) * math.sin(math.pi/3) + x_m1
    y_m =  (x_m2 - x_m1) * math.sin(math.pi/3) + (y_m2 - y_m1) * math.cos(math.pi/3) + y_m1
  
    koch(n-1,x_0,y_0,x_m1,y_m1)
    print(x_m1,y_m1)
    koch(n-1,x_m1,y_m1,x_m,y_m)
    print(x_m,y_m)
    koch(n-1,x_m,y_m,x_m2,y_m2)
    print(x_m2,y_m2)
    koch(n-1,x_m2,y_m2,x_1,y_1)
      
print(0,0)
koch(n,0,0,100,0)
print(100,0)
a,b = map(int,raw_input().split(" "))
d,r = divmod(a,b)
f = a/b
print ("%s %s %s"%(d,r,f))

### FIXED CODE ###

a,b = map(int,raw_input().split())
d = a/b
r = a % b
f = float(a) / b
print "%d %d %f"%(d,r,f)
x = [int(i) for i input().split()]
x.sort()
print("Yes" if x[0]+x[1]==x[2] else "No")

### FIXED CODE ###

x = [int(i) for i in input().split()]
x.sort()
print("Yes" if x[0]+x[1]==x[2] else "No")
import math
import queue
from collections import defaultdict
 
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def printQueue(q):
	r=q
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)

n, m = map(int, input().split())
sc = []
s=[]
c=[]
for i in range(m):
	_s, _c = map(int, input().split())
	s.append(_s-1)
    c.append(_c)

if m==0:
	if n==1:
		print(0)
		exit()
	else:
		print(-1)
		exit()
ans = -1
for i in range(1000):
	*t, = map(int, list(str(i)))

	if len(t) != n:
		continue

	ok = True
	for j in range(m):
		if t[s[j]]!=c[j]:
			ok = False
			break
 
	if ok:
		print(i)
		quit()

print(-1)

### FIXED CODE ###

n,m = map(int, input().split())
s, c = [], []
for i in range(m):
    _s, _c = map(int, input().split())
    s.append(_s-1)
    c.append(_c)
 
for i in range(1000):
    *t, = map(int, list(str(i)))
 
    if len(t) != n:
        continue
 
    ok = True
    for j in range(m):
        if t[s[j]] != c[j]:
            ok = False
            break
 
    if ok:
        print(i)
        quit()
 
print(-1)
a,b = open(0)
print(max( [a+b, a-b, a*b]))

### FIXED CODE ###

a,b = map(int,input().split())
print(max([a+b,a-b,a*b]))
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
x = Counter(a)
cnt = sorted(x.items(), key=lambda x: x[0], reverse=True)
ans = 0
for i in range(len(cnt)):
    x = cnt[i][1]
    print(x)
    if i != 0:
        if cnt[i][0] == cnt[i-1][0] - 1:
            x += cnt[i-1][1]
    if i == len(cnt) - 1:
        if cnt[i][0] == cnt[i+1][0] + 1:
            x += cnt[i+1][1]
    ans = max(ans, x)
print(ans)

### FIXED CODE ###

from collections import Counter
n = int(input())
a = list(map(int, input().split()))
x = Counter(a)
cnt = sorted(x.items(), key=lambda x: x[0], reverse=True)
ans = 0
for i in range(len(cnt)):
    x = cnt[i][1]
    if i != 0:
        if cnt[i][0] == cnt[i-1][0] - 1:
            x += cnt[i-1][1]
    if i != len(cnt) - 1:
        if cnt[i][0] == cnt[i+1][0] + 1:
            x += cnt[i+1][1]
    ans = max(ans, x)
print(ans)
N=int(input())
from functools import reduce
size=int(N**.5+(1-1e-9))
a=[0]*size*size
b=[0]*size
f=lambda x,y:x|y
def init(v):
    a=v
    b=[reduce(f,a[j*size:(j+1)*size]) for j in range(size)]
    return a,b
def update(i,v):
    a[i]=v
    j=i//size
    b[j]=reduce(f,a[j*size:(j+1)*size])
def r_query(l,r):
    L,R=0--l//size,r//size
    if L>=R:
        return reduce(f,a[l:r])
    else:
        return reduce(f,a[l:L*size]+b[L:R]+a[R*size:r])
def c(n):
    r=0
    while n:
        r+=n&1
        n>>=1
    return r

o=lambda c:ord(c)-ord('a')
bit=[2**i for i in range(26)]
S=input()
Q=int(input())
XYZ=[input().split() for i in range(Q)]
a,b=init([bit[o(c)] for c in S])
for x,y,z in XYZ:
    if x=='1':
        update(int(y)-1,bit[o(z)])
    else:
        print(c(r_query(int(y)-1,int(z))))

### FIXED CODE ###

N=int(input())
from functools import reduce
size=int(N**.5+(1-1e-9))
a=[0]*N
b=[0]*size
f=lambda v: reduce(lambda x,y:x|y,v,0)
def init(v):
    a=v
    b=[f(a[j*size:(j+1)*size]) for j in range(size)]
    return a,b
def update(i,v):
    a[i]=v
    j=i//size
    b[j]=f(a[j*size:(j+1)*size])
def r_query(l,r):
    L,R=0--l//size,r//size
    if L>=R:
        return f(a[l:r])
    else:
        return f(a[l:L*size]+b[L:R]+a[R*size:r])
def c(n):
    r=0
    while n:
        r+=n&1
        n>>=1
    return r

o=lambda c:ord(c)-ord('a')
bit=[2**i for i in range(26)]
S=input()
Q=int(input())
XYZ=[input().split() for i in range(Q)]
a,b=init([bit[o(c)] for c in S])
for x,y,z in XYZ:
    if x=='1':
        update(int(y)-1,bit[o(z)])
    else:
        print(c(r_query(int(y)-1,int(z))))
from itertools import permutations

def input_list() :
    return list(map(int, input().split()))

n, m ,r = input_list()
road = input_list()
road = [x-1 for x in road]
d = [[float('inf')] * n for i in range(n)]
for i in range(n) :
    d[i][i] = 0
for i in range(m) :
    a, b, c = input_list()
    a -= 1
    b -= 1
    d[a][b] = c
    d[b][a] = c

for k in range(n) :
    for i in range(n) :
        for j in range(n) :
            dist = d[i][k]+d[k][j]
            if d[i][j] > dist :
            d[i][j] = dist

ans = float('inf')
for p in permutations(road) :
    dist = 0
    for i in range(r-1) :
        dist += d[p[i]][p[i+1]]
    if ans > dist :
        ans = dist

print(ans)

### FIXED CODE ###

from itertools import permutations

def input_list() :
    return list(map(int, input().split()))

def main() :
    n, m ,r = input_list()
    road = input_list()
    road = [x-1 for x in road]
    d = [[float('inf')] * n for i in range(n)]
    for i in range(n) :
        d[i][i] = 0
    for i in range(m) :
        a, b, c = input_list()
        a -= 1
        b -= 1
        d[a][b] = c
        d[b][a] = c

    for k in range(n) :
        for i in range(n) :
            for j in range(n) :
                dist = d[i][k]+d[k][j]
                if d[i][j] > dist :
                    d[i][j] = dist

    ans = float('inf')
    for p in permutations(road) :
        dist = 0
        for i in range(r-1) :
            dist += d[p[i]][p[i+1]]
        if ans > dist :
            ans = dist

    print(ans)

main()
if N < 105:
    print(0)
elif N < 165:
    print(1)
else N < 195:
    print(2)
else:
    print(3)

### FIXED CODE ###

N = int(input())

if N < 105:
    print(0)
elif N < 135:
    print(1)
elif N < 165:
    print(2)
elif N < 189:
    print(3)
elif N < 195:
    print(4)
else:
    print(5)
N = int(input())

if N % 2 != 0:
    print(0)

else:
    count = N // 10
    for j in range(1, 50):
        count += N // ((5**j) * 10)

print(count)


### FIXED CODE ###

N = int(input())

if N % 2 != 0:
    print(0)
else:
    count = N // 10
    for j in range(1, 50):
        count += N // ((5**j) * 10)
    print(count)
N,M,C = map(int,input().split())
B = list(map(int,input().split()))
count = 0
for i in range(N):
  a = list(map(int,input().split()))
  for j in range(M):
  P = C  
  P += B[j]*a[j]
  if P>0:
    count+=1
print(count)

### FIXED CODE ###

N,M,C = map(int,input().split())
B = list(map(int,input().split()))
count = 0
for i in range(N):
  a = list(map(int,input().split()))
  P = C  
  for j in range(M):
    P += B[j]*a[j]
  if P>0:
    count+=1
print(count)
stuck = ""
while True:
    a = raw_input().split()
    if a == "quit":
        break
    if a[0] == "push":
        stuck += a[1]
    elif a[0] == "pop"
        stuck.pop()
for i in range(len(stuck)):
    print stuck[i]

### FIXED CODE ###

stuck = ""
while True:
    a = raw_input().split()
    if a[0] == "quit":
        break
    if a[0] == "push":
        stuck += a[1]
    elif a[0] == "pop":
        l = len(stuck) - 1
        print stuck[l]
        stuck = stuck[:l]
from collections import defaultdict

n = int(input())
a = list(map(int, input().split()))
ans = 0
cnt_free = sum(x >= 3200 for x in a)
for i in range(8):
    if sum(x >= 400 * i and x < 400 * (i + 1) for x in a) >= 1:
        ans += 1
print(max(1, ans))
print(min(8, ans + cnt_free))

### FIXED CODE ###

r, g, b = map(int, input().split())

n = int(str(r) + str(g) + str(b))
print("YES" if n % 4 == 0 else "NO")
n,k = map(int,input().split())
h = list(map(int,input().split()))
h.sort()

for i in range(n):
  if h[i] >= k:
    ans = n-i
    break

print(ans)

### FIXED CODE ###

n,k = map(int,input().split())
h = list(map(int,input().split()))
h.sort()
ans = 0

for i in range(n):
  if h[i] >= k:
    ans = n-i
    break

print(ans)