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

import sys

input = sys.stdin.readline

def main():
    def hash_ini(t):
        h = t[0]
        hash_table.append(h)
        p = 1
        for i in range(1, len(t)):
            h = (h * base + t[i]) % hash_md
            hash_table.append(h)
            p = p * base % hash_md
            pw.append(p)

    def hash(s):
        res = 0
        for i, c in enumerate(s[::-1]):
            res = (res + pw[i] * (ord(c) - ord_a)) % hash_md
        return res

    # インデックスがi以上j未満の文字列のハッシュ
    def hash_ij(i, j):
        return (hash_table[j] - hash_table[i] * pw[j - i]) % hash_md

    n = int(input())
    s = input()[:-1]

    # 初期化
    base = 29
    hash_md = pow(3, 37)
    ord_a = ord('a')
    t = [ord(c) - ord_a for c in s]
    hash_table = [0]
    pw = [1]
    hash_ini(t)

    l = 0
    ans = 0
    for r in range(1, n):
        ptn = hash_ij(l, r)
        d = r - l
        for ll in range(r, n - d + 1):
            if hash_ij(ll, ll + d) == ptn:
                ans = d
                break
        else:
            l += 1
    print(ans)

main()


### FIXED CODE ###

# YouTube
def main():
    n = int(input())
    s = input()
    dp = [[0] * (n + 1) for _ in range(n + 1)]
    for i, c in enumerate(s):
        for j in range(n):
            if c == s[j]:
                dp[i + 1][j + 1] = dp[i][j] + 1
    ans = 0
    for i in range(n):
        for j in range(i+1,n+1):
            tmp=min(dp[i][j],j-i)
            ans=max(tmp,ans)
    print(ans)

main()
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
mod = 10 ** 9 + 7
ans = 0
for i in range(60):
    cnt = 0
    for a in A:
        x = bin(a)[2:][::-1]
        if not i < len(x):
            continue
        b = int(x[i])
        if b == 1:
            cnt += 1
    ans += cnt * (N - cnt) * pow(2, i)
    ans %= mod
print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
mod = 10 ** 9 + 7


def mod_pow(a, p):
    if p == 0:
        return 1
    if p % 2 == 0:
        half_p = p // 2
        half = mod_pow(a, half_p)
        return half * half % mod
    else:
        return a * mod_pow(a, p - 1) % mod


ans = 0
for i in range(60):
    cnt = 0
    for a in A:
        if a >> i & 1:
            cnt += 1
    now = cnt * (N - cnt) % mod
    ans += now * mod_pow(2, i) % mod
    ans %= mod
print(ans)
### BUGGY CODE ###

#!/usr/bin/env python3

import sys

def dfs(i, p, add):
    add += add_node[i]
    counter[i] += add
    for j in adj[i]:
        if j != p:
            dfs(j, i, add)

sys.setrecursionlimit(10 ** 6)
n, q = map(int, input().split())
adj = [[] for i in range(n)]
for i in range(n - 1):
    a, b = map(int, input().split())
    adj[a - 1].append(b - 1)
    adj[b - 1].append(a - 1)
add_node = [0 for i in range(n)]
for i in range(q):
    p, x = map(int, input().split())
    add_node[p - 1] += x
counter = [0 for i in range(n)]
visited = [False for i in range(n)]
dfs(0, -1, 0)
print(" ".join(str(x) for x in counter))



### FIXED CODE ###

#!/usr/bin/env python3

import sys

def dfs(i, p, add):
    add += add_node[i]
    counter[i] += add
    for j in adj[i]:
        if j != p:
            dfs(j, i, add)

sys.setrecursionlimit(10 ** 6)
n, q = map(int, input().split())
adj = [[] for i in range(n)]
for i in range(n - 1):
    a, b = map(int, sys.stdin.readline().split())
    adj[a - 1].append(b - 1)
    adj[b - 1].append(a - 1)
add_node = [0 for i in range(n)]
for i in range(q):
    p, x = map(int, sys.stdin.readline().split())
    add_node[p - 1] += x
counter = [0 for i in range(n)]
dfs(0, -1, 0)
print(" ".join(str(x) for x in counter))
### BUGGY CODE ###

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

ans = [0]*n
for i in set(a):
    ans[i-1] = a.count(i)

for i in range(n):
    print(ans[i])


### FIXED CODE ###

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

ans = [0]*n
for i in a:
    ans[i-1] += 1
for i in range(n):
    print(ans[i])
### BUGGY CODE ###

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

def solve(add):
    for i in range(n):
        for j in range(n):
            if s[(i+add) % MOD][j] != s[(j+add) % MOD][i]:
                return False
    return True

ans = 0
for i in range(n):
    if solve(i):
        ans += n
print(ans)

### FIXED CODE ###

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

def solve(add):
    for i in range(n):
        for j in range(n):
            if s[(i+add) % MOD][j] != s[(j+add) % MOD][i]:
                return False
    return True

ans = 0
for i in range(n):
    if solve(i):
        ans += n
print(ans)
### BUGGY CODE ###

n=int(input())
s=input()
dat=[]
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            dat.append(s[i]+s[j]+s[k])
print(len(list(set(dat))))

### FIXED CODE ###

n=int(input())
s=input()
count=0
for i in range(10):
    for j in range(10):
        for k in range(10):
            num=str(i)+str(j)+str(k)
            a=s.find(num[0])
            if (a==-1):
                continue
            b=s[a+1::].find(num[1])
            if (b==-1):
                continue
            c=s[a+b+2::].find(num[2])
            if (c==-1):
                continue
            count+=1
            #print(num,a,b,c)
        ##
    ##
##
print(count)
### BUGGY CODE ###

n,m = map(int,input().split())
A = set(range(1,n+1))

for _ in range(m):
  l,r = map(int,input().split())
  S = set(range(l,r+1))
  A = A & S
print(len(A))

### FIXED CODE ###

n,m = map(int,input().split())
lmax, rmin = 0, n

for _ in range(m):
  l,r = map(int,input().split())
  lmax = max(lmax, l)
  rmin = min(rmin, r)

print((rmin-lmax)+1 if (rmin-lmax)+1 > 0 else 0)
### BUGGY CODE ###

n = int(input())
l = [input() for i in range(n)]

mylist = []
for s in l:
    s_list = [ c for c in s]
    mylist.append("".join(sorted(s_list)))

ans=0
for i in range(len(mylist)):
    for j in range(i+1, len(mylist)):
        if mylist[i] == mylist[j]:
            ans+=1
print(ans)

### FIXED CODE ###

n = int(input())
i = 0
sortedSet = {}
while i < n:
    temp = ''.join(sorted(input()))

    if temp in sortedSet:
        sortedSet[temp]+=1
    else:
        sortedSet[temp]=1
    i += 1

result = 0
for v in sortedSet.values():
    result = int(result + v*(v-1)/2)

print(result)
### BUGGY CODE ###

import sys

from operator import mul
from functools import reduce


def main():
  input = sys.stdin.readline
  N = int(input())
  a= tuple(map(int , input().split()))
  ans=reduce(mul, a)
  if ans > 10**18:
    print(-1)
  else:
    print(ans)

if __name__ == '__main__':
    main()

### FIXED CODE ###

n=int(input())
a = list(map(int,input().split()))
ans=a[0]
if 0 in a:
  print(0)
  exit()
for s in range(1,n):
  ans *=a[s]
  if ans > 10**18:
    print(-1)
    exit()

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

import numpy as np
import sys
n = list(map(int,input().split()))

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

for i in range(n[1]):
    a[a.argmax()] = a[a.argmax()]//2 
print(np.sum(a))


### FIXED CODE ###


N, M = map(int,input().split())
A = list(-int(i) for i in input().split())
import heapq

heapq.heapify(A)
for _ in range(M):
    a = heapq.heappop(A)//(-2)
    heapq.heappush(A,-a)

print(-sum(A))
### BUGGY CODE ###

N,C=[int(x) for x in str(input()).split()]
D=[[0 for x in range(0,C+1)]]
for i in range (0,C):
  D.append([0]+[int(x) for x in str(input()).split()])
c=[[0 for x in range(0,N+1)]]
for j in range(0,N):
  c.append([0]+[int(x) for x in str(input()).split()])


error=1000000000
for i in range(1,C+1):
  for j in range(1,C+1):
    if j!=i:
      for k in range(1,C+1):
        if k!=j:
          if k!=i:
            
            e=0
            for x in range(1,N+1):
              for y in range(1,N+1):
                
                if (x+y)%3==0:
                
                  e+=D[c[x][y]][i]
                elif (x+y)%3==1:
              
                  e+=D[c[x][y]][j]
                elif (x+y)%3==2:
              
                  e+=D[c[x][y]][k]
                
       
            error=min(error,e)
print(error)





### FIXED CODE ###

N,C=[int(x) for x in str(input()).split()]
D=[[0 for x in range(0,C+1)]]
for i in range (0,C):
  D.append([0]+[int(x) for x in str(input()).split()])
c=[[0 for x in range(0,N+1)]]
for j in range(0,N):
  c.append([0]+[int(x) for x in str(input()).split()])



mod1=[0 for x in range(0,C+1)]
mod2=[0 for x in range(0,C+1)]
mod0=[0 for x in range(0,C+1)]

for x in range (1,N+1):
  for y in range(1,N+1):
    if (x+y)%3==0:
      mod0[c[x][y]]+=1
    elif (x+y)%3==1:
      mod1[c[x][y]]+=1
    else:
      mod2[c[x][y]]+=1



error=1000000000
for i in range(1,C+1):
  for j in range(1,C+1):
    if j!=i:
      for k in range(1,C+1):
        if k!=j:
          if k!=i:
            e=0

            for x in range(1,C+1):
              e+=mod0[x]*D[x][i]+mod1[x]*D[x][j]+mod2[x]*D[x][k]


       
            error=min(error,e)
print(error)
### BUGGY CODE ###

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10**9 + 7
N = 10**7  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, N+1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

x,y=map(int,input().split())
ans=0
x_3=x//3
y_3=y//3
kyo2=min(x_3,y_3)
xx=x-kyo2*3
yy=y-kyo2*3

#print(xx,yy,kyo2)
    
if (xx==0 and yy==0):
  ans=cmb(2*kyo2,kyo2,p)
  print(ans)
elif (xx/yy==2):
  ans=cmb(2*kyo2+yy,kyo2,p)
  print(ans)
elif (yy/xx==2):
  ans=cmb(2*kyo2+xx,kyo2,p)
  print(ans)
else:
  print(0)
  

### FIXED CODE ###

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10**9 + 7
N = 10**6  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, N+1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

    
x,y=map(int,input().split())
if ((x+y)%3!=0):
  print(0)
else:
  xx=(2*x-y)//3
  yy=(2*y-x)//3
  if (xx<0 or yy<0):
    print(0)
  else:
    ans=cmb(xx+yy,xx,p)
    print(ans)
### BUGGY CODE ###

MOD = 10 ** 9 + 7


def main():
  N, K = map(int, input().strip().split())
  dp = {}

  keys = []
  i = 1
  while i <= N:
    v = N // i
    j = N // v
    keys.append((v, j - i + 1))
    i += j - i + 1

  total = 0
  for nj, w in keys:
    total += w
    dp[nj] = total

  for i in range(2, K + 1):
    tmp = {}
    total = 0
    for nj, w in keys:
      j = N // nj
      v = dp[j] * w
      total += v
      total %= MOD
      tmp[nj] = total

    dp = tmp

  return dp[1]


if __name__ == '__main__':
  print(main())

### FIXED CODE ###

MOD = 10 ** 9 + 7


def main(N, K):
  W = []
  i = 1
  while i <= N:
    v = N // i
    j = N // v
    # keys.append((v, j - i + 1))
    W.append(j - i + 1)
    i += j - i + 1

  l = len(W)
  dp = [0] * l

  total = 0
  for i, w in enumerate(W):
    total += w
    dp[l - i - 1] = total

  for i in range(2, K + 1):
    tmp = [0] * l
    total = 0
    for j, w in enumerate(W):
      v = dp[j] * w
      total += v
      total %= MOD
      tmp[l - j - 1] = total

    dp = tmp

  return dp[0]


if __name__ == '__main__':
  N, K = map(int, input().strip().split())
  # import time
  # t = time.time()
  print(main(N, K))
  # print(time.time() - t)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

'''
9 4
1 8 6 6 8 7 8 1 9
'''

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

last = dict()
v = [-1] * N

for i, a in enumerate(A + A) :
    if a in last and last[a] < N :
        v[last[a]] = i + 1
    
    last[a] = i

dist = [-1] * N
cur = 0
s = 0
while dist[cur] < 0 :
    dist[cur] = s 
    s += v[cur] - cur
    cur = v[cur] % N

# d1 - ループに入るまでの長さ, d2 - ループの長さ
d1 = dist[cur]
d2 = s - d1
NK = N * K

if NK > d1 :
    m = (NK-d1) % d2
    cur = v[cur] % N
    s = 0
    while m > dist[cur] - d1 > 0 :
        s = dist[cur] - d1
        cur = v[cur] % N
    m -= s
else :
    m = N

ret = []
if m != 0 :
    last = dict()
    for a in A[-m:] :
        if a in ret :
            ret = ret[:ret.index(a)]
        else :
            ret.append(a)
        
print(' '.join([str(i) for i in ret]))

### FIXED CODE ###

import sys
input = sys.stdin.readline

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

last = dict()
v = [-1] * N

for i, a in enumerate(A + A) :
    if a in last and last[a] < N :
        v[last[a]] = i + 1
    
    last[a] = i

dist = [-1] * N
cur = 0
cycle = 0
while dist[cur] < 0 :
    dist[cur] = cycle 
    cycle += v[cur] - cur
    cur = v[cur] % N

NK = N * K

m = NK % cycle
cur = v[cur] % N
s = 0
while m > dist[cur] > 0 :
    s = dist[cur]
    cur = v[cur] % N
m -= s

ret = []
seen = set()
for a in A[N-m:] :
    if a in seen :
        p = ret.pop()
        seen.remove(a)
        while p != a :
            seen.remove(p)
            p = ret.pop()
    else :
        ret.append(a)
        seen.add(a)
        
print(' '.join([str(i) for i in ret]))
### BUGGY CODE ###

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy,bisect
from operator import itemgetter
from heapq import heappush, heappop
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
nf = lambda: float(ns())
na = lambda: list(map(int, stdin.readline().split()))
nb = lambda: list(map(float, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N, C = na()
D = [na() for _ in range(C)]
c = [na() for _ in range(N)]

z = []
o = []
t = []
for i in range(1, N+1):
    for j in range(1, N+1):
        q = (i + j) % 3
        if q == 0:
            z.append(c[i-1][j-1] - 1)
        if q == 1:
            o.append(c[i-1][j-1] - 1)
        if q == 2:
            t.append(c[i-1][j-1] - 1)

ans = inf
for i, j, k in itertools.permutations(range(C), 3):
    tmp = 0
    for num in z:
        tmp += D[num][i]
    for num in o:
        tmp += D[num][j]
    for num in t:
        tmp += D[num][k]
    ans = min(tmp, ans)
print(ans)



### FIXED CODE ###

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy,bisect
from operator import itemgetter
from heapq import heappush, heappop
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
nf = lambda: float(ns())
na = lambda: list(map(int, stdin.readline().split()))
nb = lambda: list(map(float, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N, C = na()
D = [na() for _ in range(C)]
c = [na() for _ in range(N)]

z = {}
o = {}
t = {}
for i in range(1, N+1):
    for j in range(1, N+1):
        q = (i + j) % 3
        now = c[i - 1][j - 1] - 1
        if q == 0:
            if now not in z.keys():
                z[now] = 1
            else:
                z[now] += 1
        if q == 1:
            if now not in o.keys():
                o[now] = 1
            else:
                o[now] += 1
        if q == 2:
            if now not in t.keys():
                t[now] = 1
            else:
                t[now] += 1

ans = inf
for i, j, l in itertools.permutations(range(C), 3):
    tmp = 0
    for k, v in z.items():
        tmp += v * D[k][i]
    for k, v in o.items():
        tmp += v * D[k][j]
    for k, v in t.items():
        tmp += v * D[k][l]
    ans = min(tmp, ans)
print(ans)
### BUGGY CODE ###

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

cnt = 0
for a in range(1,n+1):
    if (2*a) % k == 0:
        for b in range(a,n+1):
            if ((2*b) % k == 0)and((a+b) % k == 0 )and((a-b) % k == 0 ):
                for c in range(b,n+1):
                    if ((2*c) % k == 0)and((a+c) % k == 0 )and((c+b) % k == 0 ):
                        if (a==b)and(b==c):
                            cnt += 1
                        elif (a!=b)and(b!=c)and(a!=c):
                            cnt += 6
                        else:
                            cnt +=3
                        
                        

print(cnt)


### FIXED CODE ###

#!/usr/bin/env python3
import sys
 
 
def solve(N: int, K: int):
    count = 0
 
    if K % 2 == 0:
        count += (N//K)**3
        # a,b,c == 0 mod K//2
        count += (N//(K//2) - N//K)**3
    else:
        count += (N//K)**3
    print(count)
    return
 
 
def main():
    N,K= map(int,input().split())
    # N = int(next(tokens))  # type: int
    # K = int(next(tokens))  # type: int
    solve(N, K)
 
 
if __name__ == '__main__':
    main()
### BUGGY CODE ###

import math

def isprime(num):
    for y in range(2, int(math.ceil(math.sqrt(num)))+1):
        if num%y==0:
            return 0
    return 1

while True:
  try:
    n=input()
    count= 1 if n >= 2 else 0
    for x in range(3,n+1,2):
        count+=isprime(x)
    print count
  except EOFError:
    break

### FIXED CODE ###

import math
import sys

lst=[0 for _ in xrange(999999+1)]

def is_prime(num):
  if num%2==0:
      return 0
  for x in range(3, int(num**0.5)+1,2):
    if num % x==0:
        return 0
  return 1

lst[1]=0
lst[2]=1
for idx in range(3, len(lst)):
  lst[idx] = is_prime(idx) + lst[idx-1]

for line in sys.stdin:
  print lst[int(line)]
### BUGGY CODE ###

# 接続最大クラスタのサイズが答え？

N, M = [int(x) for x in input().split(' ')]

from collections import defaultdict
d = defaultdict(set)

for i in range(M):
    a, b = [int(x) for x in input().split(' ')]
    d[a].add(b)
    d[b].add(a)

def bfs(i):
    obs = {i}
    passed = {i}

    # get next_obs
    before = {i}
    while True:
        after = set()
        for i in before:
            after |= d[i]
        before = after - passed
        passed |= after
        if len(after) == 0:
            return passed
    return len(passed)

print(max(len(bfs(i)) for i in range(1, N+1)))




### FIXED CODE ###

# 接続最大クラスタのサイズが答え？

N, M = [int(x) for x in input().split(' ')]

# from collections import defaultdict
# d = defaultdict(set)

# for i in range(M):
#     a, b = [int(x) for x in input().split(' ')]
#     d[a].add(b)
#     d[b].add(a)

class UF:
    def __init__(self):
        self.r = [-1] * N

    def root(self, i):
        r = self.r
        if r[i] < 0:
            return i
        else:
            r[i] = self.root(r[i])
            return r[i]

    def union(self, i, j):
        i -= 1
        j -= 1
        ri = self.root(i)
        rj = self.root(j)
        if ri == rj:
            return
        else:
            if not self.r[ri] < self.r[rj]:
                ri, rj = rj, ri
            self.r[ri] += self.r[rj]
            self.r[rj] = ri
            return

    def max_size(self):
        return -min(self.r)

uf = UF()
for i in range(M):
    uf.union(*[int(x) for x in input().split(' ')])
print(uf.max_size())
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
idx = 0
cnt = 0
for n in range(N):
    if A[idx] == idx+1:
        idx += 1
    else:
        A.pop(idx)
        cnt += 1

if cnt == N:
    print(-1)
else:
    print(cnt)

### FIXED CODE ###

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

i = 1
ans = 0
for n in range(N):
  if i == A[n]:
    i += 1
  else:
    ans += 1
if ans == N:
  ans = -1
  
print(ans)
### BUGGY CODE ###

N = int(input())

t = 0

for i in range (1,N+1):
  p = N//i
  s = int(i*p*(1+p)/2)
  t = t+s

print(t)

### FIXED CODE ###

N = int(input())

t = 0

for i in range (1,N+1):
  p = N//i
  t += i*p*(1+p)/2
  

print(int(t))
### BUGGY CODE ###

def main():
    X = int(input())

    for i in range(10**5):
        num = X + i
        list = get_sieve_of_eratosthenes(num)
        if num in list:
            print(num)
            exit()


def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError("n is int-type.")
    if n < 2:
        raise ValueError("n is more than 2")
    data = [i for i in range(2, n + 1)]
    for d in data:
        data = [x for x in data if (x == d or x % d != 0)]
    return data

if __name__ == '__main__':
    main()

### FIXED CODE ###

#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

#引数nが素数かどうかを判定
def is_prime(n):
    for i in range(2, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            return False
    return n != 1

def main():
    X = int(input())
    for i in range(X, 10**8):
        if is_prime(i):
            print(i)
            exit()

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

N,K=map(int,input().split())
light=list(map(int,input().split()))
for k in range(K):
  imo=[0]*(N+1)
  for i in range(N):
    l=max(0,i-light[i])
    r=min(N-1,i+light[i])+1
    imo[l]+=1
    imo[r]-=1
  for j in range(1,N):
    imo[j]+=imo[j-1]
  if light==imo:
    break
  else:
    light=imo[:]
print(*light[:-1])

### FIXED CODE ###

N,K=map(int,input().split())
light=list(map(int,input().split()))
for k in range(K):
  imo=[0]*(N+1)
  for i in range(N):
    l=max(0,i-light[i])
    r=min(N-1,i+light[i])+1
    imo[l]+=1
    imo[r]-=1
  for i in range(1,N):
    imo[i]+=imo[i-1]
  if light==imo:
    break
  else:
    light=imo[:]
print(*light[:-1])
### BUGGY CODE ###

N, M, R = map(int, input().split())
rs = list(map(int, input().split()))
D = [[100000*200]*N for i in range(N)]
for i in range(N):
  D[i][i] = 0
for i in range(M):
  A, B, C = map(int, input().split())
  A, B = 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):
      D[i][j] = min(D[i][j], D[i][k]+D[k][j])
#print(D)
r = 100000*200
for i in range(R):
  rs[i] -= 1
import itertools
for rs2 in itertools.permutations(rs):
  r2 = 0
  for i in range(1, R):
    r2 += D[rs2[i-1]][rs2[i]]
  r = min(r, r2)
print(r)


### FIXED CODE ###

N, M, R = map(int, input().split())
rs = list(map(int, input().split()))
rs = [r-1 for r in rs]
D = [[100000*2000]*N for i in range(N)]
for i in range(N):
  D[i][i] = 0
for i in range(M):
  A, B, C = map(int, input().split())
  A, B = 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):
      D[i][j] = min(D[i][j], D[i][k]+D[k][j])
#print(D)
r = 100000*2000
import itertools
for rs2 in itertools.permutations(rs):
  r2 = 0
  for i in range(1, R):
    r2 += D[rs2[i-1]][rs2[i]]
  r = min(r, r2)
print(r)