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

from collections import deque

H, W = map(int, input().split())
Ch, Cw = map(lambda x : int(x) - 1, input().split())
Dh, Dw = map(lambda x : int(x) - 1, input().split())
maze = [input() for _ in range(H)]

INF = 10**12
#各マスへの移動コスト
path = [[INF] * W for _ in range(H)]

#walk:移動A、warp:移動B
walk = [(0, 1), (0, -1), (-1, 0), (1,0)]
warp = [(i, j) for i in range(-2, 3) for j in range(-2, 3) if (i, j) not in [(0,0)] + walk]

q = deque()
path[Ch][Cw] = 0
q.append((Ch, Cw, 0))

while q :
    x, y, s = q.popleft()
    #移動A
    for dx, dy in walk:
        nx = x + dx
        ny = y + dy
        if 0 <= nx < H and 0 <= ny < W and maze[nx][ny] == '.' and path[nx][ny] > s:
            path[nx][ny] = s
            #移動Aの場合はコスト0、キューの先頭に追加する
            q.appendleft((nx, ny, s))
    #移動B
    for dx, dy in warp:
        nx = x + dx
        ny = y + dy
        if 0 <= nx < H and 0 <= ny < W and maze[nx][ny] == '.' and path[nx][ny] > s + 1:
            path[nx][ny] = s + 1
            #移動Bの場合はコスト1, キューの最後尾に追加
            q.appendleft((nx, ny, s+1))
            
ans = path[Dh][Dw] if path[Dh][Dw] < INF else '-1'
print(ans)

### FIXED CODE ###

from collections import deque

H, W = map(int, input().split())
Ch, Cw = map(lambda x: int(x) - 1, input().split())
Dh, Dw = map(lambda x: int(x) - 1, input().split())
maze = [input() for _ in range(H)]

INF = 10 ** 12
path = [[INF] * W for _ in range(H)]  # path: 各マスへの移動コスト

walk = [(0, 1), (0, -1), (-1, 0), (1, 0)]
warp = [(i, j) for i in range(-2, 3) for j in range(-2, 3) if (i, j) not in [(0, 0)] + walk]

q = deque()
path[Ch][Cw] = 0
q.append((Ch, Cw, 0))

while q:
    x, y, s = q.popleft()
    for dx, dy in walk:  # 移動A
        nx = x + dx
        ny = y + dy
        if 0 <= nx < H and 0 <= ny < W and maze[nx][ny] == '.' and path[nx][ny] > s:
            path[nx][ny] = s
            q.appendleft((nx, ny, s))  # 移動Aの場合はコスト0. キューの先頭に追加する.
    for dx, dy in warp:  # 移動B
        nx = x + dx
        ny = y + dy
        if 0 <= nx < H and 0 <= ny < W and maze[nx][ny] == '.' and path[nx][ny] > s + 1:
            path[nx][ny] = s + 1
            q.append((nx, ny, s + 1))  # 移動Bの場合はコスト1. キューの最後尾に追加する.
    
ans = path[Dh][Dw] if path[Dh][Dw] < INF else '-1'
print(ans)
### BUGGY CODE ###

MOD = 10 ** 9 + 7
N, M = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
SUM = 0

for i in range(N):
    for j in range(M):
        for k in range(i, N):
            for l in range(j, M):
                SUM = (SUM + (X[k] - X[i]) * (Y[l] - Y[j])) % MOD
print(SUM)

### FIXED CODE ###

MOD = 10 ** 9 + 7
N, M = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))

x_sum = 0
for i in range(N):
    x_sum = (x_sum + X[i] * (N - i - 1) - X[i] * i) % MOD

y_sum = 0
for i in range(M):
    y_sum = (y_sum + Y[i] * (M - i - 1) - Y[i] * i) % MOD

result = (x_sum * y_sum) % MOD

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

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#D
n = int(input())
a = [int(input()) for j in range(n)]

dp = [1] * n
ans = 0
for i in range(n):
    dp[i] = 1
    for j in range(i):
        if a[j] < a[i]:
            dp[i] = max(dp[i], dp[j]+1)

    ans = max(ans, dp[i])

print(ans)

### FIXED CODE ###

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import bisect
#D2
n = int(input())
a = [int(input()) for j in range(n)]

dp = [a[0]]
for i in range(1,n):
    if dp[-1] < a[i]:
        dp.append(a[i])
        #print(0,dp)

    else:
        dp[bisect.bisect_left(dp, a[i])] = a[i]
        #print(1,bisect.bisect_left(dp, a[i]),dp)
print(len(dp))
### BUGGY CODE ###

import itertools

def comb(n, r):
    return len(list(itertools.combinations(range(n), r)))

def get_runlength(s): # ex) s = 'RRLLLLRLRLRLRR'
    ret = []
    count = 1
    for i in range(len(s)):
        if i == len(s) - 1:
            ret.append((s[i], count))
            continue
        if s[i] == s[i + 1]:
            count += 1
        else:
            ret.append((s[i], count))
            count = 1
    return ret

n = int(input())
dic = {}
for i in range(n):
    sin = input()
    sin = list(sin)
    sin.sort()
    sin = ''.join(sin)
    try:
        dic[sin] += 1
    except:
        dic[sin] = 1

count = 0
for v in dic.values():
    # count += v * (v - 1) / 2
    count += comb(v, 2)
count = int(count)
print(count)

### FIXED CODE ###

import itertools

def comb(n, r):
    return len(list(itertools.combinations(range(n), r)))

def get_runlength(s): # ex) s = 'RRLLLLRLRLRLRR'
    ret = []
    count = 1
    for i in range(len(s)):
        if i == len(s) - 1:
            ret.append((s[i], count))
            continue
        if s[i] == s[i + 1]:
            count += 1
        else:
            ret.append((s[i], count))
            count = 1
    return ret

n = int(input())
dic = {}
for i in range(n):
    sin = input()
    sin = list(sin)
    sin.sort()
    sin = ''.join(sin)
    try:
        dic[sin] += 1
    except:
        dic[sin] = 1

count = 0
for v in dic.values():
    count += v * (v - 1) / 2
count = int(count)
print(count)
### BUGGY CODE ###

s = list(input())[::-1] + [0,0]
N,i = len(s),0
ansl = []
while i < N:
    if s[i] == 'C' and s[i+1] == 'B':
        temp = [0]
        i += 2
        while i < N:
            if s[i] == 'A':
                temp += [1]
                i += 1
            elif s[i] == 'C' and s[i+1] == 'B':
                temp += [0]
                i += 2
            else:
                break
        ansl += [temp]
    else:   i += 1

ans = 0
for c in ansl:
    for i in range(len(c)-1):
        if c[i]==0:    ans += c[i+1:].count(1)

print(ans)




### FIXED CODE ###

s = list(input())[::-1] + [0,0]
N,i,ans = len(s),0,0

while i < N:
    if s[i] == 'C' and s[i+1] == 'B':
            temp = 1
            i += 2
            while i < N:
                if s[i] == 'A':
                    ans += temp
                    i += 1
                elif s[i] == 'C' and s[i+1] == 'B':
                    temp += 1
                    i += 2
                else:
                    break
    else:   i += 1

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

from sys import stdin


def main():
    N = int(stdin.readline().rstrip())
    Xi = [(i, int(x)) for i, x in enumerate(stdin.readline().rstrip().split())]
    Xi = sorted(Xi, key=lambda x:x[1], reverse=True)
    for i in range(N):
        xi = [x[1] for x in Xi if x[0] != i]
        print(xi[(N - 1)// 2])


if __name__ == '__main__':
    main()


### FIXED CODE ###

from sys import stdin


def main():
    N = int(stdin.readline().rstrip())
    Xi = [(i, int(x)) for i, x in enumerate(stdin.readline().rstrip().split())]
    Xi = sorted(Xi, key=lambda x: x[1], reverse=True)
    result = list(range(N))
    index = N // 2 - 1
    for i in range(N):
        idx = index
        if i <= index:
            idx += 1
        result[Xi[i][0]] = Xi[idx][1]

    for x in result:
        print(x)


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

import numpy as np

S = input()
S = list(S)
S = np.array(S)

index_black = np.where(S=="B")[0]

count = 0
for i in index_black:
    count += np.sum(S[i+1:]=="W")

print(count)    

### FIXED CODE ###

import numpy as np

S = input()
S = list(S)
S = np.array(S)

index_black = np.where(S=="B")[0]
diff = np.array([i for i in range(len(S)-len(index_black),len(S))])
count = int(np.sum(np.abs(diff-index_black)))
print(count)
### BUGGY CODE ###

import sys
import numpy as np
sys.setrecursionlimit(10 ** 7)

N, Q = map(int, input().split())
STX = []
for _ in range(N):
    s, t, x = map(int, input().split())
    STX.append((s, t, x))

PEOPLE = []
for _ in range(Q):
    d = int(input())
    PEOPLE.append(d)

ans = [str(-1)] * Q

STX.sort(key=lambda x: x[2])

for s, t, x in STX:
    #print("s,t,x", s, t, x)
    i = np.searchsorted(PEOPLE, s - x)
    j = np.searchsorted(PEOPLE, t - x)
    #print("i,j", i, j)

    for k in range(i, j):
        if ans[k] == '-1':
            ans[k] = str(x)

    # print(ans)

print("\n".join(ans))


### FIXED CODE ###

#D in [S_i-X_i,T_i-X_i) → Xiで止まる
import sys
input = sys.stdin.readline
from heapq import heappop,heappush
from collections import defaultdict

N,Q = map(int,input().split())
task = []

STX = [[int(x) for x in input().split()] for _ in range(N)]
for s,t,x in STX:
  task.append((t-x,0,x)) # xで止まらなくなる
  task.append((s-x,1,x)) # xで止まる

for i in range(Q):
  d = int(input())
  task.append((d,2,i)) # 止まる位置を答える
answer = [-1]*Q

task.sort()

# 引っかかってる場所の管理
se = set()
se_hp = [] # heapで最小値を先頭に保つ

# 小さい時刻から順に見ていく
for a,b,c in task:
  if not b: # b == 0
    se.remove(c)
  elif b&1: # b == 1
    se.add(c)
    heappush(se_hp,c)
  else: # b == 2
    while se_hp and se_hp[0] not in se:
      heappop(se_hp)
    answer[c] = se_hp[0] if se_hp else -1

print('\n'.join(map(str,answer)))
### BUGGY CODE ###

# 初期入力
N = int(input())
#A = list(map(int, input().split()))
A = list(map(int, input().split()))
#　1の左側は砕く、以降数字が大きくなるほど右側にあればいいが、順番が違うと砕く必要あり。
from copy import deepcopy
x = 0
y =0
z = 0
for i in range(1,N+1):
    if i in A[x:]:
        y = A[x:].index(i ) 
        #z.append(y)
        z +=1
        x += y
        #if y==0:
         #   break

    else:
        y = -1
        break
#
renga_kudaku = 0
if z ==0 and y==-1:
    renga_kudaku = -1
elif z ==0:
    renga_kudaku = 0
else:
    renga_kudaku=N-z # 求める物＝全体ー残る要素数、zは残る文字の配列
print(renga_kudaku)

### FIXED CODE ###

#初期入力
import sys
N = int(input())
A=[int(i) for i in input().split()]
#


if 1 not in A:
    print(-1)
    exit
else:
    i=1 #探す数字
    brick_remain =set() #「1」は入っていること上記で確かめた
    for a in A:
        if a ==i:
            brick_remain.add(a)
            i +=1
    brick_destroy = N - len(brick_remain)       
    print(brick_destroy)
### BUGGY CODE ###

import sys
import bisect


input = sys.stdin.readline

N = int(input())
L = sorted(map(int, input().strip().split()))

bleft = bisect.bisect_left
bright = bisect.bisect
ans = 0

for i in range(N-2):
    a = L[i]
    for j in range(i+1, N-1):
        b = L[j]
        # print(a, b)
        c_right = bleft(L, a+b)
        # print(c_right)
        if c_right == 0:
            continue
        now_seq = L[j+1:c_right]
        c_left = bright(now_seq, b-a)
        if c_left == N:
            continue
        ans += len(now_seq) - c_left
print(ans)


### FIXED CODE ###

import sys
import bisect


input = sys.stdin.readline

def main():
    N = int(input())
    L = sorted(map(int, input().strip().split()))

    bleft = bisect.bisect_left
    bright = bisect.bisect
    ans = 0

    for i, a in enumerate(L):
        if i > N-2:
            break
        for j, b in enumerate(L):
            if j > N-1:
                break
            if j <= i:
                continue
            c_right = bleft(L[j+1:], a+b)
            ans += c_right
    print(ans)

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

n,k = map(int,input().split())
mx = 100000
dp = [[k+1 for _ in range(mx+1)]for _ in range(n+1)]
dp[0][0]=0
for i in range(1,n+1):
    dp[i][0]= 0
    w,v = map(int,input().split())
    for j in range(v):
        dp[i][j]= dp[i-1][j]
    for j in range(v,mx+1):
        next = w+dp[i-1][j-v]
        if next<=k:
            dp[i][j]= min(next,dp[i-1][j])
        else:
            dp[i][j]=dp[i-1][j]
for i in range(mx,-1,-1):
    if dp[n][i]<=k:
        print(i)
        break


### FIXED CODE ###

n,k = map(int,input().split())
mx = 100000
dp = [[k+1 for _ in range(mx+1)]for _ in range(n+1)]
dp[0][0]=0
for i in range(1,n+1):
    dp[i][0]= 0
    w,v = map(int,input().split())
    for j in range(v):
        dp[i][j]= dp[i-1][j]
    for j in range(v,mx+1):
        next = w+dp[i-1][j-v]
        if next<=k:
            dp[i][j]= min(next,dp[i-1][j])
        else:
            dp[i][j]=dp[i-1][j]
for i in range(mx,-1,-1):
    if dp[n][i]<=k:
        print(i)
        break
### BUGGY CODE ###

import sys
input = sys.stdin.readline
import heapq

h, w, k = map(int, input().split())
x1, y1, x2, y2 = map(lambda x:int(x)-1, input().split())
S = [input().rstrip() for _ in range(h)]
dist = [[[float("inf")]*w  for i in range(h)] for _ in range(4)]
que = []
que.append((0, 0, x1, y1))
dist[0][x1][y1] = 0
  
while que:
  c, di, x, y = heapq.heappop(que)
  if x == x2 and y == y2:
    break
  if dist[di][x][y] < c:
    continue
  l, r = c+1, -(-c//k)*k
  if di == 0:
    if x > 0 and S[x-1][y] == "." and dist[di][x-1][y] > l:
      dist[di][x-1][y] = l
      heapq.heappush(que, (l, di, x-1, y))
  elif di == 1:
    if y > 0 and S[x][y-1] == "." and dist[di][x][y-1] > l:
      dist[di][x][y-1] = l
      heapq.heappush(que, (l, di, x, y-1))
  elif di == 2:
    if x < h-1 and S[x+1][y] == "." and dist[di][x+1][y] > l:
      dist[di][x+1][y] = l
      heapq.heappush(que, (l, di, x+1, y))
  else:
    if y < w-1 and S[x][y+1] == "." and dist[di][x][y+1] > l:
      dist[di][x][y+1] = l
      heapq.heappush(que, (l, di, x, y+1))
      
  if di%2:
    if dist[0][x][y] > r:
      dist[0][x][y] = r
      heapq.heappush(que, (r, 0, x, y))
    if dist[2][x][y] > r:
      dist[2][x][y] = r
      heapq.heappush(que, (r, 2, x, y))
    
  else:
    if dist[1][x][y] > r:
      dist[1][x][y] = r
      heapq.heappush(que, (r, 1, x, y))
    if dist[3][x][y] > r:
      dist[3][x][y] = r
      heapq.heappush(que, (r, 3, x, y))
t = min(dist[0][x2][y2], dist[1][x2][y2], dist[2][x2][y2], dist[3][x2][y2])
if t == float("inf"):
  print(-1)
else:
  ans = -(-t//k)
  print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline
from collections import deque

def main():
  h, w, k = map(int, input().split())
  x1, y1, x2, y2 = map(lambda x:int(x)-1, input().split())
  v1 = x1*(w+1)+y1
  v2 = x2*(w+1)+y2
  C = "".join(input().rstrip()+"@" for _ in range(h))
  dist = [-1 if c=="@" else 10**10 for c in C]
  ans = 0
  que = deque()
  que.append(v1)
  dist[v1] = 0
  while que:
    v = que.popleft()
    if v == v2:
      print(dist[v2])
      exit()
    d = dist[v]+1
    for dr in (-(w+1), -1, w+1, 1):
      for i in range(1, k+1):
        nv = v+dr*i
        if 0 <= nv < h*(w+1):
          if dist[nv] > d:
            dist[nv] = d
            que.append(nv)
          elif dist[nv] == d:
            continue
          else:
            break
        else:
          break
  print(-1)
if __name__ == "__main__":
  main()
### BUGGY CODE ###

def search(x, j, visited, t, vis, rel):
    visited[x][j] = True
    visited[j][x] = True

    if vis[x][j]:
        return t[x][j]

    else:
        for k in range(N):
            if visited[k][j]:
                continue
            else:
                if rel[x][k] and t[x][k]:

                    if search(k, j, visited, t, vis, rel):
                        vis[k][j] = True
                        vis[j][k] = True
                        t[k][j] = True
                        t[j][k] = True
                        return True
                    else:
                        continue
        return False


def main():

    t = [[False] * N for i in range(N)]
    vis = [[False] * N for i in range(N)]
    rel = [[False] * N for i in range(N)]

    for i in range(M):
        a, b = map(int, input().split())
        rel[a - 1][b - 1] = True
        rel[b - 1][a - 1] = True
        vis[a - 1][b - 1] = True
        vis[b - 1][a - 1] = True
        t[a - 1][b - 1] = True
        t[b - 1][a - 1] = True

    for i in range(K):
        c, d = map(int, input().split())
        rel[c - 1][d - 1] = True
        rel[d - 1][c - 1] = True
        t[c - 1][d - 1] = False
        t[d - 1][c - 1] = False

    a = []
    for i in range(N):
        cnt = 0
        for j in range(N):
            if i == j or rel[i][j]:
                continue
            else:
                visited = [[False] * N for n in range(N)]
                if search(i, j, visited, t, vis, rel):
                    cnt += 1
        a.append(cnt)

    print(*a)


N, M, K = map(int, input().split())
main()


### FIXED CODE ###

class Unionroot:
    def __init__(self, n=0):
        self.d = [-1]*n

    def root(self, x):
        if self.d[x] < 0:
            return x
        self.d[x] = self.root(self.d[x])
        return self.d[x]

    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x == y:
            return False
        if x > y:
            x, y = y, x
        self.d[x] += self.d[y]
        self.d[y] = x
        return True

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def size(self, x):
        return -self.d[self.root(x)]

deg = [0] * 100005
to = [[] for i in range(100005)]

n, m, k = map(int, input().split())
uf = Unionroot(n)

for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    deg[a] += 1
    deg[b] += 1
    uf.unite(a, b)

for i in range(k):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    to[a].append(b)
    to[b].append(a)

ret = []
for i in range(n):
    ans = uf.size(i) - 1 - deg[i]
    for u in to[i]:
        if uf.same(i, u):
            ans -= 1
    ret.append(ans)
print(' '.join([str(r) for r in ret]))
### BUGGY CODE ###

def expect(x):
    return sum(list(range(1,x+1)))/x
n, k = map(int, input().split())
p = list(map(int, input().split()))
table = []
for i in range(n-k+1):
    w = 0
    for j in range(k):
        w += expect(p[i+j])
    table.append(w)

print(max(table))

### FIXED CODE ###

import sys
input = sys.stdin.readline
n, k = map(int,input().split())
p = list(map(int, input().split()))
p = [(1+i)/2 for i in p]
# 累積和の配列sを作成する
s = [0] * (n+1)
for i in range(1,n+1):
    s[i] = s[i-1] + p[i-1]
max = -1 * float("inf")
for i in range(n-k+1):
    sum = s[k+i] - s[i]
    if max <= sum:
        max = sum
print(max)
### BUGGY CODE ###

def cf(x1,x2):
    cf=[]
    for i in range(2,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf
def main():
    a,b = map(int, input().split())
    c = cf(a,b)
    c.append(1)
    list_cf = sorted(c)
    list_ans = []*len(list_cf)
    for i in range(len(list_cf)):
        for j in range(i+1,len(list_cf)):
            if list_cf[i] != 1 and cf(list_cf[j],list_cf[i])!=0 and list_cf[j]%list_cf[i]==0:
                list_ans.append(list_cf[j])
    print(len(list_cf)-len(list(set(list_ans))))
if __name__ == "__main__":
    main()

### FIXED CODE ###

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


def prime_numbers(N):
    n = N
    res = set()
    for i in range(2, n):
        if i * i >= n: break
        if N % i != 0: continue
        while N % i == 0:
            N //= i
        res.add(i)
    res.add(N)
    res.add(1)
    return res


a = prime_numbers(A)
b = prime_numbers(B)
#print(a, b)
#print(a.intersection(b))
ans = len(a.intersection(b))
print(ans)
### BUGGY CODE ###

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

ans = 1
for i in range(N):
    ans=ans*A[i]

if ans> (10**18):
    ans=-1

print(ans)

### FIXED CODE ###

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

ans = 1

if 0 in A:
    print(0)
    exit()

for i in range(N):
    ans=ans*A[i]
    if ans> (10**18):
        ans=-1
        break


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

import heapq
N,M=map(int,input().split())
path=[[0 if i==j or i==max(j-1,0) else float("inf") for i in range(N)] for j in range(N)]
for _ in range(M):
  l,r,c=map(int,input().split())
  path[l-1][r-1]=c

dist=[float("inf")]*N
dist[0]=0
q=[[dist[i],i] for i in range(N)]
heapq.heapify(q)

while q:
  d,ind=heapq.heappop(q)
  if d<=dist[ind]:
    for i in range(N):
      if dist[i]>d+path[ind][i]:
        dist[i]=d+path[ind][i]
        heapq.heappush(q,[dist[i],i])

if dist[N-1]==float("inf"):
  print(-1)
else:
  print(dist[N-1])


### FIXED CODE ###

import heapq
N,M=map(int,input().split())
path=[[] for _ in range(N)]
for _ in range(M):
  l,r,c=map(int,input().split())
  path[l-1].append([r,c])
for i in range(1,N):
  path[i].append([i,0])

dist=[float("inf")]*N
dist[0]=0
q=[[dist[i],i] for i in range(N)]
heapq.heapify(q)

while q:
  d,ind=heapq.heappop(q)
  if d<=dist[ind]:
    for i in range(len(path[ind])):
      r,c=path[ind][i]
      if dist[r-1]>d+c:
        dist[r-1]=d+c
        heapq.heappush(q,[dist[r-1],r-1])

if dist[N-1]==float("inf"):
  print(-1)
else:
  print(dist[N-1])
### BUGGY CODE ###

n, m = map(int, input().split())
a = sorted(list(map(int, input().split())))
mat = []
for _ in range(m):
    b, c = map(int, input().split())
    mat.extend([c] * b)
mat = sorted(mat, reverse=True)[:n]
for i, t in enumerate(a):
    if i == len(mat):
        break
    if t < mat[i]:
        a[i] = mat[i]
    else:
        break

print(sum(a))


### FIXED CODE ###

n, m = map(int, input().split())
a = sorted(list(map(int, input().split())))
bc = [[0] * 2 for _ in range(m)]
for i in range(m):
    bc[i] = list(map(int, input().split()))
bc = sorted(bc, key=lambda x: x[1], reverse=True)
mat = []
for b, c in bc:
    if len(mat) + b > n:
        mat.extend([c] * (n - len(mat)))
        break
    else:
        mat.extend([c]*b)

for i, t in enumerate(a):
    if i == len(mat):
        break
    if t < mat[i]:
        a[i] = mat[i]
    else:
        break

print(sum(a))
### BUGGY CODE ###

n, m = map(int, input().split())
stairs = [i for i in range(1, n+1)]
a = []
for _ in range(m):
  a.append(int(input()))

dp = [0] * (n + 1)
dp[0] = 1


for i in range(1, n+1):
  if i in a:
    continue
  dp[i] = dp[i] + dp[i-1]
  if i > 1:
    dp[i] = dp[i] + dp[i-2]

print(dp[n] % 1000000007)

### FIXED CODE ###

n, m = map(int, input().split())
stairs = [i for i in range(1, n+1)]
a = [0 for _ in range(m)]
for i in range(m):
  a[i] = int(input())
a = set(a)
  
dp = [0] * (n + 1)
dp[0] = 1

for i in range(1, n+1):
  if i in a:
    continue
  dp[i] = dp[i] + dp[i-1]
  if i > 1:
    dp[i] = dp[i] + dp[i-2]

print(dp[n] % 1000000007)
### BUGGY CODE ###

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

dp = [[0]*(n+1) for _ in range(n+1)]

for i in reversed(range(n)):
    for j in reversed(range(n)):
        if s[i] == s[j]:
            dp[i][j] = dp[i+1][j+1]+1


ans = 0
for i in range(n-1):
    for j in range(i+1, n):
        x = min(dp[i][j], j-i)
        if ans < x:
            ans = x
print(ans)


### FIXED CODE ###

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

dp = [[0]*(n+1) for _ in range(n+1)]

for i in reversed(range(n)):
    for j in reversed(range(n)):
        if s[i] == s[j]:
            dp[i][j] = dp[i+1][j+1]+1


ans = 0
for i in range(n-1):
    for j in range(i+1, n):
        x = min(dp[i][j], j-i)
        if ans < x:
            ans = x
print(ans)
### BUGGY CODE ###

def main():
    n = input()
    A = map(int,raw_input().split())
    q = input()
    M = map(int,raw_input().split())

    for m in M:
        for j in range(n):
            w = rec(m,A[j:])

            if w:
                break
        if w:
            print "yes"
        else:
            print "no"

def rec(m,A):
    m_new = m
    if m_new == 0:
        r1 = True
    elif m_new < 0:
        r1 = False
    else:
        if len(A) == 1:
            r1 = False
        else:
            r1 = rec(m_new,A[1:])

    m_new = m - A[0]
    if m_new == 0:
        r2 = True
    elif m_new < 0:
        r2 = False
    else:
        if len(A) == 1:
            r2 = False
        else:
            r2 = rec(m_new,A[1:])

    if r1 or r2:
        return True
    else:
        return False

if __name__ == "__main__":
    main()

### FIXED CODE ###

from collections import deque

def main():
    n = input()
    A = deque(map(int,raw_input().split()))
    q = input()
    M = map(int,raw_input().split())

    p = rec([0],A)

    for m in M:
        if m in p:
            print "yes"
        else:
            print "no"

def rec(a,A):
    if len(A) == 0:
        return a
    else:
        y = A.popleft()
        a = a+[x+y for x in a]
        return rec(a,A)

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


n=int(input())
a=sorted(map(int,input().split()))
count=0
for i in range(n):
    b=a[i]
    c=True
    for j in range(n):
        if a[j]>b:
            break
        if b%a[j]==0 and i!=j:
            c=False
            break
    if c:
        count+=1
print(count)

### FIXED CODE ###


n=int(input())
a=sorted(map(int,input().split()))
m=max(a)+1
t=[0]*m
cnt=0
for i in a:
    if t[i]==0:
        cnt+=1
    elif t[i]==1:
        cnt-=1
    if t[i]<2:
        t[i]+=1
        for j in range(i*2,m,i):
            t[j]=2
print(cnt)