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

n = int(input())
s = input()

ans = n
for i in range(n):
  ans = min(ans, s[0:i].count('W') + s[i + 1:n].count('E'))
print(ans)

### FIXED CODE ###

n = int(input())
s = input()

w = 0
e = s.count('E')
ans = w + e
for si in s:
  if si == 'E':
    e -= 1
  else:
    w += 1
  ans = min(ans, w + e)
print(ans)
### BUGGY CODE ###

from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import connected_components


class People:
    def __init__(self):
        self.frends = 0
        self.blocks = 0


n, m, k = [int(i) for i in input().split()]

data=[1]*m
row=[]
col=[]
peoples = [People() for i in range(n + 1)]
for i in range(m):
    one, two = [int(j) for j in input().split()]
    new_one=min(one,two)
    new_two=max(one,two)
    row.append(one)
    col.append(two)
    peoples[one].frends+=1
    peoples[two].frends+=1

frends = csr_matrix((data, (row, col)), shape=(n+1, n+1))


num, labels = connected_components(frends)
labels=list(labels)

for i in range(k):
    one, two = [int(j) for j in input().split()]
    if labels[one] == labels[two]:
        peoples[one].blocks+=1
        peoples[two].blocks+=1

renketu_num = [0]
for i in range(1, num + 1):
    renketu_num.append(labels.count(i))


def get_renketu_num(i):
    return renketu_num[labels[i]] - 1


def get_friend_num(i):
    return peoples[i].frends


def get_block_num(i):
    return peoples[i].blocks


for i in range(1, n + 1):
    print(get_renketu_num(i) - get_friend_num(i) - get_block_num(i))


### FIXED CODE ###

import numpy as np
from scipy.sparse.csgraph import connected_components
from scipy.sparse import csr_matrix

import sys
sys.setrecursionlimit(10**9)
n,m,k=[int(i) for i in input().split()]
frends_num=[0 for i in range(n)]
def make_frends(m,n):
    data=[1 for i in range(m)]

    row=[]
    col=[]
    for k in range(m):
        i,j=[int(l) for l in input().split()]
        new_i=min(i,j)-1
        new_j=max(i,j)-1
        row.append(new_i)
        col.append(new_j)
        frends_num[new_i]+=1
        frends_num[new_j]+=1
    frend_sparce_matrix=csr_matrix((data, (row, col)),shape=(n,n))
    return frend_sparce_matrix


frends=make_frends(m,n)
l,labels=connected_components(frends)
labels
labels=list(labels)

class Group:
    def __init__(self,labels):
        self.labels=labels
        self.group_num=[0 for i in range(l)]
        for i in labels:
            self.group_num[i]+=1
    def get_group_num(self,i):
        return self.group_num[self.labels[i]]

group=Group(labels)


def get_frend_num(i):
    return frends_num[i]


def make_block(k,n):
    block_num=[0 for i in range(n)]
    for p in range(k):
        i,j =[int(l)-1 for l in input().split()]
        new_i=min(i,j)
        new_j=max(i,j)
        if labels[new_i]==labels[new_j]:
            block_num[i]+=1
            block_num[j]+=1
    return block_num

block=make_block(k,n)

def get_block_num(i):
    return block[i]

ans=[]
for i in range(n):
    ans.append(str(group.get_group_num(i)-1-get_frend_num(i)-get_block_num(i)))
print(" ".join(ans))
### BUGGY CODE ###

#! /usr/bin/env python3

import sys
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)
MOD = pow(10, 9) + 7

N, K, *A = map(int, read().split())
A_pos = [a for a in A if a >= 0]
A_neg = [a for a in A if a < 0]

if K == N:
    ans = 1
    for a in A:
        ans *= a
        ans %= MOD
elif len(A_neg) == N and K % 2 == 1:
    A = sorted(A, key=lambda x: abs(x))
    ans = 1
    for a in A[:K]:
        ans *= a
        ans %= MOD

else:
    A_pos = sorted(A_pos, key=lambda x: -abs(x))
    A_neg = sorted(A_neg, key=lambda x: -abs(x))
    ans = 1
    cnt = 0
    while True:
        if len(A_pos) > 1:
            acc_pos = A_pos[0] * A_pos[1]
        elif len(A_pos) == 1:
            acc_pos = A_pos[0]
        else:
            acc_pos = 0

        if len(A_neg) > 1:
            acc_neg = A_neg[0] * A_neg[1]
        else:
            acc_neg = 0

        if acc_pos > acc_neg or cnt == K - 1:
            if len(A_pos) > 0:
                ans *= A_pos[0]
                A_pos = A_pos[1:]
            else:
                ans *= A_neg[0]
                A_neg = A_neg[1:]
            ans %= MOD
            cnt += 1
        else:
            ans *= acc_neg
            ans %= MOD
            A_neg = A_neg[2:]
            cnt += 2

        if cnt == K:
            break

print(ans % MOD)


### FIXED CODE ###

#! /usr/bin/env python3

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)
MOD = pow(10, 9) + 7

N, K, *A = map(int, read().split())

if K == N:
    ans = 1
    for a in A:
        ans = ans * a % MOD
    print(ans)
    sys.exit()

A_pos = [a for a in A if a >= 0]
A_neg = [a for a in A if a < 0]

if len(A_pos) == 0:
    if K % 2 == 1:
        A_neg.sort(reverse=True)
    else:
        A_neg.sort()
    ans = 1
    for a in A_neg[:K]:
        ans = ans * a % MOD
    print(ans)
    sys.exit()

A_pos.sort()
A_neg.sort(reverse=True)
ans = 1
r = K
if r % 2 == 1:
    ans = ans * A_pos.pop() % MOD
    r -= 1

while r > 0:
    if len(A_pos) <= 1:
        ans = ans * A_neg.pop() * A_neg.pop() % MOD
    elif len(A_neg) <= 1:
        ans = ans * A_pos.pop() * A_pos.pop() % MOD

    else:
        acc_pos = A_pos[-1] * A_pos[-2]
        acc_neg = A_neg[-1] * A_neg[-2]

        if acc_pos > acc_neg:
            ans = ans * A_pos.pop() * A_pos.pop() % MOD
        else:
            ans = ans * A_neg.pop() * A_neg.pop() % MOD
    r -= 2
print(ans % MOD)
### BUGGY CODE ###

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

#######################################################################
# ナップサック
# 重さ：Wー10**5くらい
# 価値：N*max_Viー10**11くらい
# dp[w]:wの重さで可能な最大の価値
#   dp[w]とdp[w-wi]+vi(i番目のアイテムをとる場合)との大きいほうで更新
#######################################################################

n, t = map(int, input().split())
dp = [0] * (t+1)
itm = [list(map(int, input().split())) for _ in range(n)]
itm.sort()
for w_ , v_ in itm:
    for i in range(1,t+1):
        dp[max(0,i-w_)] = max(dp[max(0,i-w_)], dp[i] + v_)
print(dp[0])


### FIXED CODE ###

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

#######################################################################
# ナップサック
# 重さ：Wー10**5くらい
# 価値：N*max_Viー10**11くらい
# dp[w]:wの重さで可能な最大の価値
#   dp[w]とdp[w-wi]+vi(i番目のアイテムをとる場合)との大きいほうで更新
#######################################################################

n, t = map(int, input().split())
dp = [0] * (t+1)
itm = [list(map(int, input().split())) for _ in range(n)]
itm.sort()
for w_ , v_ in itm:
    for i in range(1,t+1):
        dp[max(0,i-w_)] = max(dp[max(0,i-w_)], dp[i] + v_)
print(dp[0])
### BUGGY CODE ###

n = int(input())
s = list(input())

minres = 1000000
for i in range(n):
    res = s[:i].count("W") + s[i+1:].count("E")
    if res < minres:
        minres = res

print(minres)


### FIXED CODE ###

n = int(input())
s = list(input())

num_eas = s.count('E')


res = []
res += [num_eas - s[0].count("E")]

for i in range(1,n):
    res += [res[i-1] + s[i-1].count("W") - s[i].count("E")]
    
print(min(res))
### BUGGY CODE ###

# -*- coding:utf-8 -*-

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

SUM_CARD = sum(a)

i=1

diff_sum = 0
sunuke = sum(a[0:i])
diff_sum = abs(sunuke*2-SUM_CARD)
i+=1

while(i<N):
    sunuke = sum(a[0:i])
    diff_sum_new = abs(sunuke*2-SUM_CARD)
    if diff_sum_new<diff_sum:
        diff_sum = diff_sum_new
    i += 1

print(diff_sum)


### FIXED CODE ###

# -*- coding:utf-8 -*-

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

SUM_CARD = sum(a)
i=0

sum_before = a[i]
diff_sum = abs(sum_before*2-SUM_CARD)
i+=1

while(i<N-1):
    sum_before = sum_before + a[i]
    diff_sum_new = abs(sum_before*2-SUM_CARD)
    if diff_sum_new<diff_sum:
        diff_sum = diff_sum_new
    i += 1

print(diff_sum)
### BUGGY CODE ###

N,K=map(int,input().split())
MOD=998244353
S=[0]*(N+1)
for _ in range(K):
    L,R=map(int,input().split())
    for i in range(L,R+1):
        S[i]=1
dp=[0]*(N+1)
dp[1]=1
for i in range(2,N+1):
    for j in range(i):
        if S[j]==1:
            dp[i]+=dp[i-j]
            dp[j]%=MOD
print(dp[N]%MOD)

### FIXED CODE ###

N,K=map(int,input().split())
MOD=998244353
S=[]
for _ in range(K):
    L,R=map(int,input().split())
    S.append((L,R))
S.sort()
dp=[0]*(N+1)
dp[1]=1
ans=[0]*(K+1)
for i in range(2,N+1):
    for j in range(K):
        L,R=S[j][0],S[j][1]
        if L>=i:
            break
        l=max(0,i-R)
        r=min(i-1,i-L)
        ans[j]+=dp[r]-dp[l-1]
    dp[i]+=sum(ans)
    dp[i]%=MOD
print(dp[N]%MOD)
### BUGGY CODE ###

import sys
import math
import numpy as np
import functools
import operator
import collections
import itertools

S=input()
ans=0
Wcount=0
SS=S
#print(S[0])
#S=S.split()
#print(S[0])

for i in range(len(S)):
    if S[i]=="B":
        SS=S[i:]
        s=collections.Counter(SS)
        #print(S)
        Wcount=s["W"]
        ans+=Wcount
    #s=collections.Counter(S)
    #if s["W"]==0:
        #print(ans)
        #sys.exit()
print(ans)

### FIXED CODE ###

s=input()
ans=0
count=0
for i in range(len(s)):
    if s[i]=="W":
        ans+=i-count
        count+=1
print(ans)
### BUGGY CODE ###

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




### 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 bisect
import numpy as np
INF = 10 ** 12

A, B, Q = list(map(int, input().split()))
S, T, X = [-INF], [-INF], []
for _ in range(A):
    S.append(int(input()))
for _ in range(B):
    T.append(int(input()))
for _ in range(Q):
    X.append(int(input()))
S.append(INF)
T.append(INF)
S = np.array(S)
T = np.array(T)

for x in X:
    ans = INF
    sr = np.searchsorted(S, x)
    tr = np.searchsorted(T, x)
    for s in S[sr-1: sr+1]:
        for t in T[tr-1: tr+1]:
            ans = min(ans, abs(s-x) + abs(s-t), abs(t-x) + abs(s-t))
    print(ans)


### FIXED CODE ###

import bisect
A, B, Q = list(map(int, input().split()))
S, T, X = [], [], []
for _ in range(A):
    S.append(int(input()))
for _ in range(B):
    T.append(int(input()))
for _ in range(Q):
    X.append(int(input()))
INF = 10 ** 12
S = [-INF] + S + [INF]
T = [-INF] + T + [INF]

for x in X:
    ans = INF
    sr = bisect.bisect_right(S, x)
    tr = bisect.bisect_right(T, x)
    for s in S[sr-1: sr+1]:
        for t in T[tr-1: tr+1]:
            ans = min(ans, abs(s-x) + abs(s-t), abs(t-x) + abs(s-t))
    print(ans)
### BUGGY CODE ###

from math import ceil #切り上げ
import numpy as np
 
def inp(): return int(input()) #一個だけ読み取り
def inpm(): return map(int,input().split()) #mapオブジェクトで呼び出し
def inpl(): return list(map(int, input().split())) #数字リストをintで
def inpls(): return list(input().split()) #リストをstrで

def check(a,b,X):
  if a**5-b**5 == X:
    return 1
  else:
    return 0
  
def check2(a,b,X):
  if (a <= b+X) and (a > 0):
    return 1
  else:
    return 0

X = inp()
A = 0
tmp = 0
while 1:
  B = 1
  reverse = 0
  if check(A,B,X):
    print(str(A)  + " " + str(B))
    break
  else:
    while 1:
      if B < A and A-X <= B:
        if check(A,B,X):
          print(str(A)  + " " + str(B))
          tmp = 1
          break
      else:
        break
      if reverse == 0:
        B = (-1)*B
        reverse = 1
      elif reverse == 1:
        B = (-1)*B
        B = B + 1
        reverse = 0
  A += 1
  if tmp:
    break

### FIXED CODE ###

from math import ceil #切り上げ
import numpy as np
import sys
 
def inp(): return int(input()) #一個だけ読み取り
def inpm(): return map(int,input().split()) #mapオブジェクトで呼び出し
def inpl(): return list(map(int, input().split())) #数字リストをintで
def inpls(): return list(input().split()) #リストをstrで
 
def check(a,b,X):
  if a**5-b**5 == X:
    return 1
  else:
    return 0
  
X = inp()
for A in range(-118,120):
  for B in range(-119,119):
    if check(A,B,X):
      print(str(A) + " " + str(B))
      sys.exit()
### BUGGY CODE ###

from collections import Counter
from math import factorial

def conbi(n, r = 2):
    if n - r < 0:
        return 0
    return int(factorial(n) / (factorial(n - r) * factorial(r)))

N = int(input())
A = list(map(int, input().split()))
A_cnt = dict(Counter(A))

for a in A:
    ans = 0
    for cnt in A_cnt.keys():
        if A_cnt[cnt] == 1:
            continue
        else:
            if cnt == a:
                n = A_cnt[cnt] - 1
                ans += conbi(n)
            else:
                ans += conbi(A_cnt[cnt])
    print(ans)

### FIXED CODE ###

from collections import Counter

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

def comb2(n):
    return n * (n - 1) // 2

cnt = Counter(A)
ans = 0

for c in cnt.values():
    if c >= 2:
        ans += comb2(c)

for i in range(N):
    print(ans - cnt[A[i]] + 1)
### BUGGY CODE ###

import itertools
n=int(input())
A=[int(i) for i in input().split()]
B=[int(i) for i in input().split()]
def bitsum(BIT,i):
  s=0
  while i>0:
    s+=BIT[i]
    i-=i&(-i)
  return s

def bitadd(BIT,i,x):
  while i<=2**n:
    BIT[i]+=x
    i+=i&(-i)
  return BIT

def tentou(X):
  ret=0
  BIT=[0]*nn
  BIT.insert(0,0)
  for i1 in range(n):
    x=X[i1]+1
    ret+=i1-bitsum(BIT,x)
    bitadd(BIT,x,1)
  return ret
N=[int(i) for i in range(n)]
nn=2**n
ans=float("inf")
for _ in range(n//2+1):
  for com in itertools.combinations(N,2*_):
    E,O=[],[]
    for j in range(n):
      if j not in com:
        if j%2==0:
          E.append(A[j]*100+j)
        else:
          O.append(A[j]*100+j)
      else:
        if j%2==0:
          O.append(B[j]*100+j)
        else:
          E.append(B[j]*100+j)
    if len(E)!=(n+1)//2:
      continue
    else:
      E.sort()
      O.sort()

      chk=True
      C=[E[0]%100]
      prev=E[0]//100
      for i in range(1,n):
        ii=i//2
        if i%2==0:
          C.append(E[ii]%100)
          if E[ii]//100<prev:
            chk=False
            break
          else:
            prev=E[ii]//100
        else:
          C.append(O[ii]%100)
          if O[ii]//100<prev:
            chk=False
            break
          else:
            prev=O[ii]//100
    
    if chk:
      ans=min(ans,tentou(C))
print(-1 if ans==float("inf") else ans)



### FIXED CODE ###

import itertools
n=int(input())
A=[int(i) for i in input().split()]
B=[int(i) for i in input().split()]
def bitsum(BIT,i):
  s=0
  while i>0:
    s+=BIT[i]
    i-=i&(-i)
  return s

def bitadd(BIT,i,x):
  while i<=64:
    BIT[i]+=x
    i+=i&(-i)
  return BIT

def tentou(X):
  ret=0
  BIT=[0]*64
  BIT.insert(0,0)
  for i1 in range(n):
    x=X[i1]+1
    ret+=i1-bitsum(BIT,x)
    bitadd(BIT,x,1)
  return ret
N=[int(i) for i in range(n)]
nn=2**n
ans=float("inf")
for _ in range(n//2+1):
  for com in itertools.combinations(N,2*_):
    i=0
    for ura in com:
      i+=2**ura
    E,O=[],[]
    for j in range(n):
      if i&(1<<j)==0:
        if j%2==0:
          E.append(A[j]*100+j)
        else:
          O.append(A[j]*100+j)
      else:
        if j%2==0:
          O.append(B[j]*100+j)
        else:
          E.append(B[j]*100+j)
    if len(E)!=(n+1)//2:
      continue
    else:
      E.sort()
      O.sort()

      chk=True
      C=[E[0]%100]
      prev=E[0]//100
      for i in range(1,n):
        ii=i//2
        if i%2==0:
          C.append(E[ii]%100)
          if E[ii]//100<prev:
            chk=False
            break
          else:
            prev=E[ii]//100
        else:
          C.append(O[ii]%100)
          if O[ii]//100<prev:
            chk=False
            break
          else:
            prev=O[ii]//100
    
    if chk:
      ans=min(ans,tentou(C))
print(-1 if ans==float("inf") else ans)
### BUGGY CODE ###

n = int(input())
la = list(map(int, input().split()))
q = int(input())
sa = sum(la)
for i in range(q):
  b, c = map(int, input().split())
  cnt = la.count(b)
  sa += (c-b)*cnt
  print(sa)
  
  la += [c]*cnt

### FIXED CODE ###

n = int(input())
la = list(map(int, input().split()))
sa = sum(la)
l_cnt = [0]*100001
for i in la:
  l_cnt[i] += 1
q = int(input())
for i in range(q):
  b, c = map(int, input().split())
  sa += (c-b)*l_cnt[b]
  print(sa)  
  l_cnt[c] += l_cnt[b]
  l_cnt[b] = 0
### BUGGY CODE ###

h,w = map(int,input().split())
lis = [list(map(str,input().split("#"))) for i in range(h)]
li = []
for i in range(h):
  s = [0 for i in range(w)]
  cou = 0
  for j in lis[i]:
    e = len(j)
    for n in range(len(j)):
      s[cou] = e
      cou += 1
    cou += 1
  li.append(s)
l = []
for i in range(w):
  s = [0 for i in range(h)]
  cou = 0
  nu = 0
  for j in range(h):
    if li[j][i] != 0:
      cou += 1
    else:
      cou = 0
    s[nu] = cou
    nu += 1
  for g in range(h-1):
    if s[-(2+g)] != 0 and s[-(2+g)] < s[-(1+g)]:
      s[-(2+g)] = s[-(1+g)]
  l.append(s)
ans = 0
for i in range(h):
  for j in range(w):
    ans = max(ans,li[i][j] + l[j][i]-1)
print(ans)

### FIXED CODE ###

h,w = map(int,input().split())
tate = [[0]*w for i in range(h)]
yoko = [[0]*w for i in range(h)]
s = [str(input()) for i in range(h)]

for i in range(h):
    cnt = 0
    now = 0
    for j in range(w):
        if s[i][j] == ".":
            cnt += 1
        else:
            for k in range(now,j+1):
                yoko[i][k] = cnt
            cnt = 0
            now = j+1
    for k in range(now,j+1):
        yoko[i][k] = cnt
for i in range(w):
    cnt = 0
    now = 0
    for j in range(h):
        if s[j][i] == ".":
            cnt += 1
        else:
            for k in range(now,j):
                tate[k][i] = cnt
            cnt = 0
            now = j+1
    for k in range(now,j+1):
        tate[k][i] = cnt
ans = 0
for i in range(h):
    for j in range(w):
        ans = max(ans,tate[i][j]+yoko[i][j]-1)
print(ans)
### BUGGY CODE ###

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

dp = [0] * n

for i in range(1, n):
  s = max(i-k, 0)
  dp[i] = min(dp[j] + abs(h[j]-h[i]) for j in range(s, i))

print(dp[n-1])

### FIXED CODE ###

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

dp = [0] * n

for i in range(1, n):
  s = max(i-k, 0)
  dp[i] = min(dp[j] + abs(h[j]-h[i]) for j in range(s, i))

print(dp[n-1])
### BUGGY CODE ###

n, m = map(int, input().split())
h = list(map(int, input().split()))
ab = [list(map(int, input().split())) for i in range(m)]

s = 0
for i in range(1, n + 1):
    tf = True
    k = i
    for j in range(m):
        if ab[j][0] == i:
            k = ab[j][1]
        elif ab[j][1] == i:
            k = ab[j][0]
        if (k != i) & (h[i - 1] <= h[k - 1]):
            tf = False
            break
    if tf == True:
        s += 1

print(s)

### FIXED CODE ###

n, m = map(int, input().split())
h = list(map(int, input().split()))
ab = [list(map(int, input().split())) for i in range(m)]

d = {num for num in range(1, n + 1)}
for i in range(m):
    if h[ab[i][0] - 1] > h[ab[i][1] - 1]:
        d.discard(ab[i][1])
    elif h[ab[i][0] - 1] < h[ab[i][1] - 1]:
        d.discard(ab[i][0])
    elif h[ab[i][0] - 1] == h[ab[i][1] - 1]:
        d.discard(ab[i][1])
        d.discard(ab[i][0])

print(len(d))
### BUGGY CODE ###

from itertools import permutations

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

way = [[float("inf") if i != j else 0 for i in range(N + 1)] for j in range(N + 1)]
for m in range(M):
    a, b, c = map(int, input().split())
    way[a][b] = c
    way[b][a] = c

for i in range(N + 1):
    for j in range(N + 1):
        for k in range(N + 1):
            way[j][k] = min(way[j][k], way[j][i] + way[i][k])
ans = float("inf")
for path in list(permutations(r)):
    time = 0
    for i in range(len(path) - 1):
        time += way[path[i]][path[i + 1]]
    ans = min(ans, time)
print(ans)


### FIXED CODE ###

from itertools import permutations

def wfa(N):
    for i in range(N + 1):
        for j in range(N + 1):
            w_ji = way[j][i]
            for k, (w_ik, w_jk) in enumerate(zip(way[i], way[j])):
                if k == 0:
                    continue
                tmp = w_ji + w_ik
                if w_jk > tmp:
                    way[j][k] = tmp


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

way = [[float("inf") if i != j else 0 for i in range(N + 1)] for j in range(N + 1)]
for m in range(M):
    a, b, c = map(int, input().split())
    way[a][b] = c
    way[b][a] = c

wfa(N)

ans = float("inf")
for path in permutations(r):
    time = 0
    for i in range(len(path) - 1):
        time += way[path[i]][path[i + 1]]
    ans = min(ans, time)
print(ans)
### BUGGY CODE ###

N,M = map(int,input().split())
A = tuple([int(input()) for _ in range(M)])
mod = 1000000007
dp=[0]*(N+1)
dp[0]=1
if M != 0:
    if A[0]!=1:
        dp[1]=1 
    else:
        dp[1]=0
else:
    dp[1]=1
    
for i in range(2,N+1):
    if i in A:
        dp[i]=0
    else:
        dp[i] = (dp[i-1]+dp[i-2])%mod

print(dp[-1])

### FIXED CODE ###

mod = 10**9+7
n,m = map(int,input().split())
a = set()
for i in range(m):
  a.add(int(input()))
dp = [0]*(n+1)
dp[0] = 1
for i in range(1,n+1) :
    dp[i] = (dp[i-1] + dp[i-2]) % mod
    if i in a :
        dp[i] = 0
print(dp[n])
### BUGGY CODE ###

n = int(input())

for x in range(1, 3500 + 1):
    for y in range(1, 3500 + 1):
        p = n * x * y
        q = 4 * x * y - n * (x + y)
      
        if q == 0: continue

        z, r = divmod(p, q)
        
        if r == 0:
            if z > 0:
                print(x, y, z)
                exit()

### FIXED CODE ###

N = int(input())

w = -1
flg = False
for h in range(1, 3500 + 1):
    for n in range(h, 3500 + 1):
        q = 4 * n * h - N * (n + h)
        #print(h, n, p, q)
        if q > 0:
            #q == 0: 1/wなしで4/Nに等しくなり不適（w無限大）
            #q < 0: p > 0より、w < 0となり不適
            p = N * n * h
            if p % q == 0:
                w = p // q
                flg = True
                break
    if flg:
        break
print(h, n, w)