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

(n, m) = list(map(int, input().split()))
p = list(map(int, input().split()))
cG = []
cGT = []
for i in range(0, m):
    e = list(map(int, input().split()))
    aru = False
    do = []
    for c in cG:
        if e[0] in c or e[1] in c:
            if not do == []:
                mix = do + c
                cG.remove(do)
                cG.remove(c)
                cG.append(mix)
                break
            else:
                do = c
        if e[0] in c:
            aru = True
            c.append(e[1])
            cGT.append(e[1])
        elif e[1] in c:
            aru = True
            c.append(e[0])
            cGT.append(e[0])
    if not aru:
        cG.append(e)
        cGT = cGT + e

cant = list(set(p) - set(cGT))
res = 0
for i in cant:
    if p[i - 1] == i:
        res = res + 1

for i in range(1, n + 1):
    for c in cG:
        if i in c:
            ku = p.index(i) + 1
            if ku in c:
                res = res + 1
print(res)


### FIXED CODE ###

def ge(x):
    return int(x) - 1


(n, m) = tuple(map(int, input().split()))
inp = list(map(ge, input().split()))
arr = [i for i in range(n)]


def root(a):
    global arr
    if arr[a] == a:
        return a
    else:
        tmp = root(arr[a])
        arr[a] = tmp
        return tmp


def sameroot(x, y):
    return root(x) == root(y)


def merge(x, y):
    global arr
    if not sameroot(x, y):
        arr[root(y)] = root(x)


for i in range(m):
    merge(*tuple(map(ge, input().split())))

res = 0
for i in range(n):
    if sameroot(i, inp[i]):
        res += 1
print(res)
### BUGGY CODE ###

import queue
n,k=map(int,input().split())
l=list(map(int,input().split()))
el=queue.deque(maxlen=k)
ans = 0
m = 0
for i in l[:]:
    if len(el) != k:
        el.append((1+i)/2)
        ans = sum(el)
        m = ans
    else:
        el.append((1+i)/2)
        m = m-m_e+el[-1]
        ans = m if m>ans else ans
    m_e = el[0]
print(ans)

### FIXED CODE ###

import queue
n,k=map(int,input().split())
l=list(map(int,input().split()))
el=queue.deque(maxlen=k)
ans = 0
m = 0
for i in l[:]:
    if len(el) == k:
        el.append((1+i)/2)
        m = m-m_e+el[-1]
    else:
        el.append((1+i)/2)
        m +=el[-1]
    ans = m if m>ans else ans
    m_e = el[0]
print(ans)
### BUGGY CODE ###

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

N = s[0]
K = s[1]

while N >= abs(N - K):
  N = abs(N - K)
  
print(N)

### FIXED CODE ###

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

N = s[0]
K = s[1]

print(min(N % K, K - N % K))
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
s=0
for i in range(n-1):
    b=a[i]
    for j in range(i+1,n):
        s+=b*a[j]
        s%=(10**9+7)
print(s)


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
s=0
b=[]
su=0
for i in range(1,n):
    su+=a[-i]
    b.append(su)
for j in range(2,n+1):
    s+=a[-j]*b[j-2]
    s%=(10**9+7)
print(s)
### BUGGY CODE ###

import sys
a = sys.stdin.read().split('\n')[:-1]
s = list(a[0])
q = int(a[1])
f = 1
for i in range(2, q + 2):
    if a[i][0] == '1':
        f = 1 - f
    else:
        l = len(s)
        s.insert(0 if a[i][2] == '21'[f] else l, a[i][4])
if f == 1:
    print(''.join(s))
else:
    print(''.join(reversed(s)))

### FIXED CODE ###

import sys
a = sys.stdin.read().split('\n')[:-1]
q = int(a[1])
f = 1
l = [[], []]
for i in range(2, q + 2):
    if a[i][0] == '1':
        f = 1 - f
    else:
        l[0 if a[i][2] == '21'[f] else 1].append(a[i][4])
if f != 1:
    l[1].reverse()
    print(''.join(l[1]) + ''.join(reversed(list(a[0]))) + ''.join(l[0]))
else:
    l[0].reverse()
    print(''.join(l[0]) + a[0] + ''.join(l[1]))
### BUGGY CODE ###

def hantei(n, m, l, d ):
    if (n*10000+m*5000+l*1000)==d:
        return True
    return False

osatu,sum = map(int,input().split())

#n　一万円
#m　五千円
#l　千円
n=m=l=0
result=0

while(n <= osatu):
    while(m <= osatu):
        while(l <= osatu):
            if n+m+l < osatu:
                pass
            elif n+m+l == osatu:
                if hantei(n,m,l,sum)==True:
                    print(n,m,l)
                    exit (0)            
            else:
                break
            l+=1
        l=0
        m+=1
    m=l=0
    n+=1

print("-1 -1 -1")




### FIXED CODE ###

def hantei(n, m, l, d ):
    if (n*10000+m*5000+l*1000)==d:
        return True
    return False

osatu,sum = map(int,input().split())

#n　一万円
#m　五千円
#l　千円
n=m=l=0
result=0

while(n <= osatu):
    while(m+n <= osatu):
        l=osatu-n-m
        if n+m+l==osatu:
            if hantei(n,m,l,sum)==True:
                print(n,m,l)
                exit (0)
        m+=1
    m=0
    n+=1


print("-1 -1 -1")
### BUGGY CODE ###

#!/usr/bin/env python3

def main():
    l, r = map(int, input().split())
    ans = 2018
    for i in range(l, r):
        for j in range(i + 1, r + 1):
            ans = min(ans, i * j % 2019)
            if ans == 0:
                break
    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

#!/usr/bin/env python3

def main():
    l, r = map(int, input().split())
    ans = 2019
    for i in range(l, r):
        for j in range(i + 1, r + 1):
            ans = min(ans, i * j % 2019)
            if ans == 0:
                break
        if ans == 0:
            break
    print(ans)


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

# N回だけトレーニングする
N = int(input())

# パワー
power = 1

# i回目のトレーニングを終えるとパワーが
# i倍されます。
for i in range(1, N + 1):
    power *= i

# 答えの値は非常に大きな値になることがあるので
# 10**9+7で割ったあまりを出力
power %= 10 ** 9 + 7

print(power)


### FIXED CODE ###

# N回だけトレーニングする
import numpy as np
N = int(input())

# パワー
power = 1

# i回目のトレーニングを終えるとパワーが
# i倍されます。
# 答えの値は非常に大きな値になることがあるので
# 10**9+7で割ったあまりを出力

for i in range(1, N + 1):
    power = np.mod(i * power, 10 ** 9 + 7)
print(power)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
def main():
  N=int(input())
  L=list(map(int,input().split()))
  if 1 not in L:
    print(-1)
    sys.exit()
  for i in range(1,N+1):
    if i not in L:
      print(N+1-i)
      sys.exit()
    else:
      a=L.index(i)
      L=L[a:]
  print(0)
if __name__ == '__main__':
    main()

### FIXED CODE ###

N=int(input())
L=list(map(int,input().split()))
i=0
n=1
while True:
  if i==N:
    break
  if L[i]==n:
    n+=1
  i+=1
if n==1:
  print(-1)
else:
  print(N-n+1)
### BUGGY CODE ###

n,m=map(int,input().split())
x=[]
f=0
for i in range(m):
    a,b=map(int,input().split())
    if a==1:
        if b in x:
            print("POSSIBLE")
            break
        x.append(b)
    if b==n:
        if a in x:
            print("POSSIBLE")
            break
        x.append(a)
else:
    print("IMPOSSIBLE")


### FIXED CODE ###

n,m=map(int,input().split())
x=[]
for i in range(m):
    a,b=map(int,input().split())
    if a==1:
        x.append(b)
    if b==n:
        x.append(a)
l=len(x)
if len(set(x))==l:
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")
### BUGGY CODE ###

n=int(input())
d=list(map(int,input().split()))
m=int(input())
t=list(map(int,input().split()))
s=set(t)
S=set(d)
if len(s)>len(S):
  print('NO')
  exit()
for i in s:
  if d.count(i)<t.count(i):
    print('NO')
    exit()
print('YES')

### FIXED CODE ###

n=int(input())
d=list(map(int,input().split()))
m=int(input())
t=list(map(int,input().split()))
if n<m:
  print('NO')
  exit()
d.sort()
t.sort()
i=0
j=0
while i<n and j<m:
  if d[i]==t[j]:
    i+=1
    j+=1
  else:
    i+=1
if j==m:
  print('YES')
else:
  print('NO')
### BUGGY CODE ###

import math
 
r = 50001
sqrt = int(math.sqrt(r))
p = [1]*r
p[0] = 0
for i in range(1,sqrt):
    if p[i]:
        p[2*i+1::i+1] = [0 for x in range(2*i+1,r,i+1)]
 
while True:
    n = int(raw_input())
    if n == 0:
        break
    count = 0
    m = n/2
    for i in range(m):
        if p[i] == 1 and p[m-i-1] == 1:
            count += 1

### FIXED CODE ###

import math

r = 50001
sqrt = int(math.sqrt(r))
p = [1]*r
p[0] = 0
for i in range(1,sqrt):
    if p[i]:
        p[2*i+1::i+1] = [0 for x in range(2*i+1,r,i+1)]

prime = []
for i in range(len(p)):
    if p[i] == 1:
        prime.append(i+1)

while True:
    n = int(raw_input())
    if n == 0:
        break
    count = 0
    for i in prime:
        if i > n/2:
            break
        m = n - i
        if p[m-1] == 1:
                count += 1
    print count
### BUGGY CODE ###

def finite_automation_matcher(T, delta, m):
    n = len(T)
    q = 0
    for i in range(n):
        q = delta[q][con(T[i])]
        if q == m:
            print(i - m + 1)


def con(x):
    if 48 <= ord(x) <= 57:
        return ord(x) - 48
    elif 65 <= ord(x) <= 90:
        return ord(x) - 55
    else:
        return ord(x) - 61


def i_con(a):
    if 0 <= a <= 9:
        return chr(a + 48)
    elif 10 <= a <= 35:
        return chr(a + 55)
    else:
        return chr(a + 61)


def compute_transition_function(P):
    sigma = list(range(62))
    m = len(P)
    delta = [[0 for _ in range(62)] for _ in range(m+1)]
    for q in range(m + 1):
        for a in sigma:
            k = min(m + 1, q + 2)
            while True:
                k = k - 1
                # print(m, q, k, P[0:k])
                if is_suffix(P[0:k], P[0:q], i_con(a)):
                    break
            delta[q][a] = k
    # print(delta)
    return delta


def is_suffix(x, y, a):
    if len(x) == 0:
        return True
    if x[len(x) - 1] != a:
        return False
    for i in range(len(x) - 1):
        if x[i] != y[len(y) - len(x) + 1 + i]:
            return False
    return True


t = input()
p = input()
m = len(p)
delta = compute_transition_function(p)
finite_automation_matcher(t, delta, m)


### FIXED CODE ###

def compute_prefix_function(p):
    m = len(p)
    pi = [0 for _ in range(m + 1)]
    pi[1] = 0
    k = 0
    for q in range(2, m + 1):
        while k > 0 and p[k] != p[q - 1]:
            k = pi[k]
        if p[k] == p[q - 1]:
            k += 1
        pi[q] = k
    return pi


def kmp_matcher(t, p):
    n = len(t)
    m = len(p)
    pi = compute_prefix_function(p)
    q = 0
    for i in range(1, n + 1):
        while q > 0 and p[q] != t[i - 1]:
            q = pi[q]
        if p[q] == t[i - 1]:
            q += 1
        if q == m:
            print(i - m)
            q = pi[q]


t = input()
p = input()
kmp_matcher(t, p)
### BUGGY CODE ###

n = int(input())
a = [int(x) for x in input().split()]

d = []

for i in range(1, n):
    d.append(abs(sum(a[:i]) - sum(a[i:])))

print(min(d))


### FIXED CODE ###

n = int(input())
a = [int(x) for x in input().split()]

b = sum(a)
c = a[0]
d = a[0]

for i in range(1, n-1):
    c += a[i]
    if abs(b-2*d) > abs(b-2*c):
        d = c

print(abs(b-2*d))
### BUGGY CODE ###

n,k=map(int,input().split())
p=list(map(int,input().split()))
M=0
for i in range(0,n-k+1):
  M=max(M,sum(p[i:i+k]))
print((M+k)/2)

### FIXED CODE ###

n,k=map(int,input().split())
p=list(map(int,input().split()))
M=sum(p[0:k])
if(n>k):
  m=M
  for i in range(1,n-k+1):
    m=m+p[i+k-1]-p[i-1]
    M=max(M,m)
print((M+k)/2)
### BUGGY CODE ###

sx,sy,gx,gy=map(int,input().split())
n=int(input())
g = [[] for i in range(n+2)]
data=[(sx,sy,0)]
for i in range(n):
    data.append(tuple(map(int,input().split())))
data.append((gx,gy,0))
for i in range(n+2):
    for j in range(i,n+2):
        if i==j:
            g[i].append((0,j))
            g[j].append((0,i))
            continue
        tmp=max(0,((data[i][0]-data[j][0])*(data[i][0]-data[j][0])+(data[i][1]-data[j][1])*(data[i][1]-data[j][1]))**0.5-data[i][2]-data[j][2])
        g[i].append((tmp,j))
        g[j].append((tmp,i))

def dijkstra(g,st,ed):
    from heapq import heappush, heappop, heapify
    inf=10**11
    dist=[inf for i in range(len(g))]
    dist[st]=0
    que=[]
    heappush(que,(0,st))
    while que:
        c,v=heappop(que)
        if dist[v]<c:
            continue
        for i in range(len(g[v])):
            if g[v][i][0]+c<dist[g[v][i][1]]:
                dist[g[v][i][1]]=g[v][i][0]+c
                heappush(que,(g[v][i][0]+c,g[v][i][1]))
    return dist[ed]

print(dijkstra(g,0,n+1))

### FIXED CODE ###

from heapq import heappush, heappop
sx,sy,gx,gy=map(int,input().split())
n=int(input())
g = [[] for i in range(n+2)]
data=[(sx+sy*1j,0)]
for i in range(n):
    a,b,c=map(int,input().split())
    data.append((a+b*1j,c))
data.append((gx+gy*1j,0))

for i in range(n+2):
    for j in range(i+1,n+2):
        tmp=abs(data[i][0]-data[j][0])-data[i][1]-data[j][1]
        g[i].append((tmp,j))
        g[j].append((tmp,i))

dist=[2828427127 for i in range(n+2)]
visited=[False for i in range(n+2)]
dist[0]=0
que=[]
heappush(que,(0,0))

while que:
    c,v=heappop(que)
    if visited[v]:
        continue
    visited[v]=True
    for x in g[v]:
        if visited[x[1]]:
            continue
        tmp=x[0]+c if not x[0]<0 else c
        if tmp<dist[x[1]]:
            dist[x[1]]=tmp
            heappush(que,(tmp,x[1]))
print(dist[n+1])
### BUGGY CODE ###

from collections import defaultdict
n, m = list(map(int, input().split()))
graph = defaultdict(list)
for i in range(m):
  u, v = list(map(int, input().split()))
  graph[u].append(v+n)
  graph[u+n].append(v+2*n)
  graph[u+2*n].append(v)
s, t = list(map(int, input().split()))
dist = [-1 for i in range(3*n+10)]

def bfs():
  que = [(s, 0)]
  while len(que) > 0:
    cur, cost = que.pop(0)
    dist[cur] = cost
    for to in graph[cur]:
      if dist[to] == -1:
        que.append((to, cost+1))

bfs()
print(dist[t]//3)

### FIXED CODE ###

from collections import defaultdict, deque
n, m = list(map(int, input().split()))
graph = defaultdict(list)
for i in range(m):
  u, v = list(map(int, input().split()))
  graph[u].append(v+n)
  graph[u+n].append(v+2*n)
  graph[u+2*n].append(v)
s, t = list(map(int, input().split()))
dist = [-1 for i in range(3*n+10)]

def bfs():
  que = deque([s])
  dist[s] = 0
  while len(que) > 0:
    cur = que.popleft()
    for to in graph[cur]:
      if dist[to] == -1:
        dist[to] = dist[cur]+1
        que.append(to)

bfs()
print(dist[t]//3)
### BUGGY CODE ###

from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
import math
import time
import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
ts=time.time()
sys.setrecursionlimit(10**6)
#input=sys.stdin.readline
show_flg=False
#show_flg=True

ans=0
an=[]
n=I()
st=-1
s=list(input())
can=[]
for d in range(1,n):
    cnt=0
    for i in range(n-d):
        if s[i]==s[i+d] and st+cnt+1<=st+d:
            if st==-1:
                st=i
            #show('d,i,s[i],st,cnt,an',d,i,s[i],st,cnt,an)
            cnt+=1
            an+=s[i]
            ans=max(ans,cnt)
        else:
            #show('d,i,s[i],st,cnt,an',d,i,s[i],st,cnt,an,'els')
            cnt=0
            can+=[an]
            an=[]
            st=-1
    cnt=0
print(ans)
show(can)

### FIXED CODE ###

from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
import math
import time
import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
ts=time.time()
sys.setrecursionlimit(10**6)
#input=sys.stdin.readline
show_flg=False
#show_flg=True

ans=0
an=[]
n=I()
st=-1
s=list(input())
can=[]
for d in range(1,n):
    cnt=0
    for i in range(n-d):
        if s[i]==s[i+d] and st+cnt+1<=st+d:
            if st==-1:
                st=i
            #show('d,i,s[i],st,cnt,an',d,i,s[i],st,cnt,an)
            cnt+=1
            #an+=s[i]
            ans=max(ans,cnt)
        else:
            #show('d,i,s[i],st,cnt,an',d,i,s[i],st,cnt,an,'els')
            cnt=0
            #can+=[an]
            #an=[]
            st=-1
    cnt=0
print(ans)
#show(can)
### BUGGY CODE ###

D,N = map(int,input().split())

list = []
for i in range(10000000):
    if i % 100**D == 0:
        list.append(i)

print(list[N])


### FIXED CODE ###

D,N = map(int,input().split())

if N == 100:
    print(100**D*101)

else:
    print(100**D*N)
### BUGGY CODE ###

n = int(input())

six_list = [6 ** i for i in range(7)]
nine_list = [9 ** i for i in range(6)]

import bisect

def six_nine(n):
  if n == 0:
    return 0
  else:
    six = six_list[bisect.bisect_right(six_list, n) - 1]
    nine = nine_list[bisect.bisect_right(nine_list, n) - 1]
    return 1 + min(six_nine(n - six), six_nine(n - nine))


print(six_nine(n))

### FIXED CODE ###

n = int(input())

six_list = [6 ** i for i in range(7)]
nine_list = [9 ** i for i in range(6)]

import bisect

def six_nine(n):
  if n == 0:
    return 0
  else:
    six = six_list[bisect.bisect_right(six_list, n) - 1]
    nine = nine_list[bisect.bisect_right(nine_list, n) - 1]
    return min(n // six + six_nine(n % six), 1 + six_nine(n - nine))


print(six_nine(n))
### BUGGY CODE ###



k=int(input())
 
import math
from functools import reduce
 
def gcd(*numbers):
    return reduce(math.gcd, numbers)
 
res=0
l= list(range(1,k+1))

for n in l:
    for i in l:
        for j in l:
            res+=gcd(n, i,j)
 
print(res)


### FIXED CODE ###

k=int(input())

from math import gcd
 
res=0
 
for n in range(1,k+1):
    for i in range(1,k+1):
        for j in range(1,k+1):

            res+=gcd(gcd(n,i),j)

print(res)
### BUGGY CODE ###

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

n = int(input())

a = list()
for i in range(n):
    a.append(int(input()))

a_sorted = sorted(a, reverse=True)

for i in range(n):
    index = a_sorted.index(a[i])
    if a[i] == a_sorted[0]:
        print(a_sorted[1])
        continue

    print(a_sorted[0])


### FIXED CODE ###

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

n = int(input())

a = list()
for i in range(n):
    a.append(int(input()))

a_sorted = sorted(a, reverse=True)

for i in range(n):
    if a[i] == a_sorted[0]:
        print(a_sorted[1])
        continue

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

A,B,N = map(int,input().split())
S = 0
for i in range(N+1):
    while S < max(S,(A*i)//B - A * (i//B)):
        S = max(S,(A*i)//B - A * (i//B))
print(S)


### FIXED CODE ###

A,B,N = map(int,input().split())
S = 0
n = N // B
r = N % B
if B > N:
    S = (A*N)//B
else:
    if  r == 0:
        S = (A*(N-1))//B - A * ((N-1)//B)
    elif r == B - 1:
        S = (A*N)//B - A * (N//B)
    else:
        S = (A*(n*B-1))//B - A * ((n*B-1)//B)

print(S)
### BUGGY CODE ###

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

def fnc(x):
    return math.floor(A*x*1.0/B) - A*math.floor(x*1.0/B)

if N < B:
    print(fnc(N))
else:
    ans = 0
    for i in range(B-1, N+1, B):
        s = fnc(i)
        if s > ans:
            ans = s
    print(ans)

### FIXED CODE ###

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

def fnc(x):
    return math.floor(A*x*1.0/B) - A*math.floor(x*1.0/B)

if B == 1:
    print(0)
elif N < B:
    print(fnc(N))
else:
    ans = 0
    for i in range(B-1, N+1, B):
        s = fnc(i)
        if s > ans:
            ans = s
    print(ans)
### BUGGY CODE ###

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

ans = [0]*p

for i in range(p):
    if a[i] == 1:
        ans[0] -= p-1
        m = 1
        for j in range(p):
            ans[p-1-j] -= m
            ans[p-1-j] %= p
            m *= (i %p)

print(*ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline

p = int(input())
a = [int(i) for i in input().split()]

ans = [0]*p

for i,j in enumerate(a):
    if j == 0:
        continue
    ans[0] -= p-1
    m = 1
    for k in range(p):
        ans[p-1-k] -= m
        ans[p-1-k] %= p
        m *= i
        m %= p

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

N, M = map(int,input().split())
a = [int(input()) for i in range(M)]
dp = [0 for i in range(N+1)]
dp[0] = 1
dp[1] = 1
i = 2
while i <= N:
  if (i-2 in a) and (i-1 in a):
    dp[-1] = 0
    break
  elif i-2 in a:
    dp[i] = dp[i-1]
  elif i-1 in a:
    dp[i] = dp[i-2]
  else:
    dp[i] = dp[i-1] + dp[i-2]
  i+=1

print(dp[-1]%(7+10**9))
    

### FIXED CODE ###

N, M = map(int,input().split())
a = set([int(input()) for i in range(M)])
dp = [0 for i in range(N+1)]
dp[0] = 1
dp[1] = 1
for i in range(2,N+1):
  if (i-2 in a) and (i-1 in a):
    dp[-1] = 0
    break
  elif i-2 in a:
    dp[i] = dp[i-1]
  elif i-1 in a:
    dp[i] = dp[i-2]
  else:
    dp[i] = dp[i-1] + dp[i-2]

print(dp[-1]%(7+10**9))
### BUGGY CODE ###

n = input().split()
a = list(map(int, input().split()))
b = 0
c = []
count = 0

while(True):
    T = False
    for i in range(len(a)):
        b = a[i] / 2
        c.append(b)
        if a[i]%2 != 0:
            T=True

    if T:
        break

    a = c
    count+=1


print(count)


### FIXED CODE ###

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

while(True):
    T = False
    for i in range(len(a)):
        if a[i]%2 != 0:
            T=True
        else:
            a[i] = a[i] / 2

    if T:
        break

    count+=1

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

k = int(input())
cnt = 0
import math
for i in range(1, k+1):
    for j in range(1, k+1):
        for n in range(1, k+1):
            m = math.gcd(i, j)
            cnt += math.gcd(m, n)
            
print(cnt)

### FIXED CODE ###

k = int(input())
cnt = 0
import math
for i in range(1, k+1):
    for j in range(1, k+1):
        for n in range(1, k+1):
            m = math.gcd(i, j)
            cnt += math.gcd(m, n)
            
print(cnt)
### BUGGY CODE ###

n=int(input())
as_=[int(input()) for _ in range(n)]
for i in range(n):
    l=as_[:i]+as_[i+1:]
    print(max(l))


### FIXED CODE ###

n=int(input())
as_=[int(input()) for _ in range(n)]
l=sorted(as_)
m1=l[-1]
m2=l[-2]
for a in as_:
    if a==m1:
        print(m2)
    else:
        print(m1)
### BUGGY CODE ###

N, M, R = map(int, input().split())
T = list(map(int, input().split()))
D = [[float('INF')] * N for _ in range(N)]
for _ in range(M):
    A, B, C = map(int, input().split())
    A -= 1
    B -= 1
    if D[A][B] > C:
        D[A][B] = C
        D[B][A] = C


def dfs(i, d, v):
    v[i] = True
    if all(v[t - 1] for t in T) is True:
        return d
    dd = float('INF')
    for j in range(N):
        if v[j] is True:
            continue
        if D[i][j] == 0:
            continue
        dd = min(dd, dfs(j, d + D[i][j], v[::]))
    return dd


def main():
    ans = float('INF')
    for i in range(N):
        v = [False] * N
        ans = min(ans, dfs(i, 0, v[::]))
    print(ans)


main()


### FIXED CODE ###

N, M, R = map(int, input().split())
T = list(map(int, input().split()))
D = [[float('INF')] * N for _ in range(N)]
V = [False] * R
for _ in range(M):
    A, B, C = map(int, input().split())
    A -= 1
    B -= 1
    if D[A][B] > C:
        D[A][B] = C
        D[B][A] = C
ans = float('INF')


def dfs(c, s, d):
    global ans
    if c == R + 1:
        if ans > d:
            ans = d
            return

    for i in range(R):
        if V[i] is True:
            continue
        V[i] = True
        if s == -1:
            dfs(c + 1, i, 0)
        else:
            dfs(c + 1, i, d + D[T[s] - 1][T[i] - 1])
        V[i] = False


def main():
    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])
    dfs(1, -1, 0)
    print(ans)


main()