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

N = int(input())
A = list(map(int, input().split()))
ts = {}
fs = set()

for i, a in enumerate(A):
    if a in ts or a in fs:
        continue
    flag = True
    for j, b in enumerate(A):
        if a % b == 0 and i != j:
            fs.add(a)
            flag = False
    if flag:
        ts[a] = ts.get(a, 0)+1

ans = 0
for i in ts:
    ans += ts[i]

print(ans)


### FIXED CODE ###

import collections

N = int(input())
A = list(map(int, input().split()))
A = collections.Counter(A)
B = []
C = []
for i in A:
    if A[i] == 1:
        B.append(i)
    else:
        C.append(i)
B = sorted(B)
if len(B) == 0:
    print(0)
    exit()
mb = 1000000
ok = [True] * (mb+1)

if len(C) > 0:
    C = sorted(C)
    for c in C:
        if not ok[c]:
            continue
        k = 2
        while k*c <= mb:
            ok[k*c] = False
            k += 1

for b in B:
    if not ok[b]:
        continue
    k = 2
    while k*b <= mb:
        ok[k*b] = False
        k += 1

ans = 0
for b in B:
    if ok[b]:
        ans += 1

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

H,W = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(H)]
B = [list(map(int,input().split())) for _ in range(H)]
dp = [[[False]*((H+W)*80) for _ in range(W)] for _ in range(H)]

dp[0][0][abs(A[0][0]-B[0][0])] = True
for h in range(H-1):
    for w in range(W-1):
        v1 = abs(A[h+1][w]-B[h+1][w])
        v2 = abs(A[h][w+1]-B[h][w+1])
        for v in range((H+W)*80):
            if dp[h][w][v]:
                dp[h+1][w][v1+v] = True
                dp[h+1][w][abs(v1-v)] = True
                dp[h][w+1][v2+v] = True
                dp[h][w+1][abs(v2-v)] = True

v0 = abs(A[H-1][W-1]-B[H-1][W-1])
for v in range((H+W)*80):
    if dp[H-1][W-2][v]:
        dp[H-1][W-1][v0+v] = True
        dp[H-1][W-1][abs(v0-v)] = True
    if dp[H-2][W-1][v]:
        dp[H-1][W-1][v0+v] = True
        dp[H-1][W-1][abs(v0-v)] = True

for v in range((H+W)*80):
    if dp[H-1][W-1][v]:
        ans = v
        break

print(ans)

### FIXED CODE ###

H,W = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(H)]
B = [list(map(int,input().split())) for _ in range(H)]
D = [[abs(A[h][w]-B[h][w]) for w in range(W)] for h in range(H)]
def cal():
    dp1 = [set() for _ in range(W)]
    dp2 = [set() for _ in range(W)]
    for h in range(H):
        for w in range(W):
            d = D[h][w]
            if h==0 and w==0:
                dp2[0].add(d)
            for v in dp1[w]:
                v1 = v+d
                v2 = v-d if v>=d else -v+d
                dp2[w].add(v1)
                dp2[w].add(v2)
            if 0 < w:
                for v in dp2[w-1]:
                    v1 = v+d
                    v2 = v-d if v>=d else -v+d
                    dp2[w].add(v1)
                    dp2[w].add(v2)
        dp1 = dp2
        dp2 = [set() for _ in range(W)]
    return min(dp1[W-1])
ans = cal()
print(ans)
### BUGGY CODE ###

# E

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

def gcd(a,b):
    if a>b:
        a,b=b,a
    while a%b:
        a,b=b,(a%b)
    return b

def factorization(N):
    res=[]
    for i in range(2,int(N**(1/2))+2):
        if not N%i:
            r=0
            while not N%i:
                N//=i
                r+=1
            res.append((i,r))
    if N>1:
        res.append((N,1))
    return res

res2=1
P=[]
for i in range(N):
    if i!=0:
        res1=gcd(A[i],res1)
    else:
        res1=A[0]
    fact=factorization(A[i])
    if res2!=0:
        for p in P:
            if A[i]%p==0:
                res2=0
                break
    for p in fact:
        P.append(p[0])
if res2==1:
    print('pairwise coprime')
elif res1==1:
    print('setwise coprime')
else:
    print('not coprime')

### FIXED CODE ###

# E

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

def gcd(a,b):
    if a>b:
        a,b=b,a
    while a%b:
        a,b=b,(a%b)
    return b

def fast_factorization_init(N):
    res=list(range(N))
    for i in range(2,N):
        if i*i>N:
            break
        for j in range(i*i,N,i):
            if res[j]==j:
                res[j]=i
        if res[i]<i:
            continue
    return res            
    
min_factors=fast_factorization_init(10**6+10)
def fast_factorization(n):
    res=[]
    while n>1:
        res.append(min_factors[n])
        n//=min_factors[n]
    return list(set(res))

res2=0
P=[]
for i in range(N):
    if i!=0:
        res1=gcd(A[i],res1)
    else:
        res1=A[0]
    P += fast_factorization(A[i])

if len(set(P))==len(P):
    res2=1

if res2==1:
    print('pairwise coprime')
elif res1==1:
    print('setwise coprime')
else:
    print('not coprime')
### BUGGY CODE ###

import math as m

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


D=[0]*(10**6+1)
for i in range(2,int(m.sqrt(10**6))+2):
    if D[i]!=0:
        continue
    j=2*i
    while j < 10**6+1:
        D[j]=i
        j+=i

P=[0]*10**6
pc=True
g=As[0]
for n in range(N):
    A=As[n]
    g=m.gcd(g,A)
    if A==1:
        continue
    ppre=1
    while True:
        p=D[A] if D[A]!=0 else A
        if ppre != p:
            if P[p] > 0:
                pc=False
            P[p]+=1
            ppre=p
        A=A//p
        if A==1:
            break

if pc:
    print('pairwise coprime')
elif g==1:
    print('setwise coprime')
else:
    print('not coprime')


### FIXED CODE ###

import math as m

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


D=[0]*(10**6+1)
for i in range(2,int(m.sqrt(10**6))+2):
    if D[i]!=0:
        continue
    j=2*i
    while j < 10**6+1:
        D[j]=i
        j+=i

P=[0]*10**6
pc=True
g=As[0]
for n in range(N):
    A=As[n]
    g=m.gcd(g,A)
    if A==1:
        continue
    ppre=1
    while True:
        p=D[A] if D[A]!=0 else A
        if ppre != p:
            if P[p] > 0:
                pc=False
            P[p]+=1
            ppre=p
        A=A//p
        if A==1:
            break

if pc:
    print('pairwise coprime')
elif g==1:
    print('setwise coprime')
else:
    print('not coprime')
### BUGGY CODE ###


def main():
  from collections import defaultdict
  
  n = int(input())
  a = list(map(int, input().split()))
  
  d = defaultdict(int)
  e = defaultdict(int)
  
  for x in a:
    d[x] += 1
  
  func = lambda x: x*(x-1)//2 if x>=2 else 0
  
  ppp = ''
  
  for x in a:
    get = e.get(x)
    if get == None:
      g = d[x] - 1
      h = [v for k,v in d.items() if (k != x and v>=2)]
      h.append(g)
      i = list(map(func, h))
      ans = sum(i)
      e[x] = ans
      ppp += str(ans) + '\n'
    else:
      ppp += str(get) + '\n'
    
   
  print(ppp)
      
 
if __name__=='__main__':
    main()


### FIXED CODE ###

def main():
  from collections import defaultdict
  from collections import Counter
  
  n = int(input())
  a = list(map(int, input().split()))
  
  d = Counter(a)
  e = defaultdict(int)
  
  func = lambda x: x*(x-1)//2 if x>=2 else 0
  v = list(d.values())
  base = sum(list(map(func, v)))
  
  for k,v in d.items():
    if v<=1:
      e[k] = base - 0
    else:
      e[k] = base - ( v*(v-1)//2 - (v-1)*(v-2)//2 )
    
  p = [str(e[x])+'\n' for x in a]
  q = ''.join(p)
  print(q)
      
 
if __name__=='__main__':
    main()
### BUGGY CODE ###

def main():
    n, k, *h = map(int, open(0).read().split())
    dp = [float('inf')] * n
    dp[0] = 0
    for i in range(1, n):
        for j in range(max(0, i-k), i):
            dp[i] = min(dp[j] + abs(h[i] - h[j]), dp[i])
    print(dp[n-1])
if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    n, k, *h = map(int, open(0).read().split())
    dp = [float('inf')] * n
    dp[0] = 0
    for i in range(1, n):
        min_i = max(0, i-k)
        dp[i] = min([dp[j] + abs(h[i] - h[j]) for j in range(min_i, i)])
    print(dp[n-1])
if __name__ == '__main__':
    main()
### BUGGY CODE ###

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

for a in range(m):
    memo = n+a
    if (m/memo) == (m//memo):
        ans = m//memo
        break
    if (m/memo) < 2:
        ans = 1

print(ans)
    

### FIXED CODE ###

import math

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

q = int(math.sqrt(m))+1
li = [0 for i in range(10**6)]

for i in range(1,q):
    if (m%i) == 0:
        li[i] = 1
        
ans = 1
for i in range(1,q):
    if (li[i]==1) and (i*n<=m):
        ans = max(i,ans)
        
    if (li[i]==1) and (m*n<=m*i):
        ans = max((m/i),ans)
    

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

# 12:10
import numpy as np
n,m = map(int,input().split())
a = list(map(int,input().split()))
for i in range(m):
    ind = np.argmax(a)
    a[ind] = a[ind]//2
print(sum(a))

### FIXED CODE ###

import heapq
n,m = map(int,input().split())
a = list(map(lambda x: -int(x),input().split()))
heapq.heapify(a)
for _ in range(m):
    tmp = (-heapq.heappop(a)) // 2
    heapq.heappush(a, -tmp)
print(-sum(a))
### BUGGY CODE ###

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

for i in range(K):
  a=a*A[i]
  
for j in range(N-K):
  b=a*A[K+j]//A[j]
  
  if (a < b ):
    print("Yes")
    a=b
    continue
  else:
    print("No")
    a=b
    continue
    

### FIXED CODE ###

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

for i in range(K,N):
  if (A[i] <= A[i-K] ):
    print("No")
    continue
  else:
    print("Yes")
    continue
### BUGGY CODE ###

import sys
input = sys.stdin.readline

h, w, d = [int(x) for x in input().split()]
n = h*w
a = [[int(x) for x in input().split()] for _ in range(h)]
q = int(input())
lr = [[int(x) for x in input().split()] for _ in range(q)]

from collections import defaultdict
b = defaultdict(list)
for i in range(h):
    for j in range(w):
        b[a[i][j] - 1] = [i, j]
g = [[float('inf')]*(h*w) for _ in range(h*w)]
for i in range(n):
    g[i][i] = 0
for i in range(h*w):
    if i + d >= h*w:
        break
    x1, y1 = b[i]
    x2, y2 = b[i + d]
    g[i][i + d] = abs(x1 - x2) + abs(y1 - y2)

"""
ワーシャルフロイド法:O(n^3)
n:頂点数
"""
def warshall_floyd(d):
    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])
    return d

g = warshall_floyd(g)

for i in range(q):
    l, r = lr[i]
    l -= 1
    r -= 1
    print(g[l][r])

### FIXED CODE ###

import sys
input = sys.stdin.readline

h, w, d = [int(x) for x in input().split()]
a = [[int(x) for x in input().split()] for _ in range(h)]
q = int(input())
lr = [[int(x) for x in input().split()] for _ in range(q)]

dic = {}

for i in range(h):
    for j in range(w):
        dic[a[i][j]] = (i, j)

dis = {}

for i in range(1, d + 1):
    dis[i] = 0
    while i + d <= h * w:
        dis[i + d] = dis[i] + abs(dic[i + d][0] - dic[i][0]) + abs(dic[i + d][1] - dic[i][1])
        i += d

for i in range(q):
    l, r = lr[i]
    print(dis[r] - dis[l])
### BUGGY CODE ###

S = input()
con = 10**9 + 7

T = [s if s != "?" else "0" for s in S]
T = int(''.join(T))
SS = T % 13

def get_mod(S):
    c = {}
    iii = 1
    for i in range(len(S)):
        if S[len(S) - i - 1] != "?":
            iii *= 10
            iii %= 13
            continue
        c[i] = {(j * iii) % 13: 1 for j in range(0, 10)}
        iii *= 10
        iii %= 13
    return c
c = get_mod(S)

def get_tdp(pdp):
    tdp = {i: 0 for i in range(13)}
    for r in v.keys():
        for _r, _v in pdp.items():
            i = (_r + r) % 13
            tdp[i] += _v
            tdp[i] %= con
    return tdp

pdp = {i: 0 for i in range(13)}
pdp[SS] += 1
for k, v in c.items():
    pdp = get_tdp(pdp)

ans = pdp[5]
print(ans)

### FIXED CODE ###

S = input()
con = 10**9 + 7

T = [s if s != "?" else "0" for s in S]
T = int(''.join(T))
SS = T % 13

def get_mod(S):
    c = {}
    iii = 1
    for i in range(len(S)):
        if S[len(S) - i - 1] != "?":
            iii *= 10
            iii %= 13
            continue
        c[i] = {(j * iii) % 13: 1 for j in range(0, 10)}
        iii *= 10
        iii %= 13
    return c
c = get_mod(S)

def get_tdp(pdp):
    tdp = {i: 0 for i in range(13)}
    for r in v.keys():
        for _r, _v in pdp.items():
            tdp[(_r + r) % 13] += _v
    for i in range(13):
        tdp[i] %= con
    return tdp

pdp = {i: 0 for i in range(13)}
pdp[SS] += 1
for k, v in c.items():
    pdp = get_tdp(pdp)

ans = pdp[5]
print(ans)
### BUGGY CODE ###

def main():
    from collections import deque

    H, W = map(int, input().split())
    s = [input() for _ in range(H)]

    dq = deque()
    dq.append((0, 0, int(s[0][0] == '#')))

    ans = 1 << 60
    while dq:
        r, c, bk = dq.popleft()
        if r == H - 1 and c == W - 1:
            if ans > bk:
                ans = bk
            continue

        curr = s[r][c]
        if r < H - 1:
            if curr == s[r + 1][c]:
                dq.append((r + 1, c, bk))
            elif curr == '.':
                dq.append((r + 1, c, bk + 1))
            else:
                dq.append((r + 1, c, bk))
        if c < W - 1:
            if curr == s[r][c + 1]:
                dq.append((r, c + 1, bk))
            elif curr == '.':
                dq.append((r, c + 1, bk + 1))
            else:
                dq.append((r, c + 1, bk))

    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    from collections import deque

    WHITE = 0
    BLACK = 1

    CHAR = '.', '#'

    H, W = map(int, input().split())
    s = [input() for _ in range(H)]

    h = deque()
    x = CHAR.index(s[0][0])
    h.append((x, 0, 0, x))

    cost = [[H * W] * W for _ in range(H)]
    cost[0][0] = x

    while h:
        cnt, r, c, mode = h.popleft()
        if cnt > cost[r][c]:
            continue
        if r == H - 1 and c == W - 1:
            print(cnt)
            return

        delta = int(mode == WHITE)
        ncnt = cnt + delta

        if r < H - 1:
            if s[r + 1][c] == CHAR[mode]:
                if cnt < cost[r + 1][c]:
                    cost[r + 1][c] = cnt
                    h.appendleft((cnt, r + 1, c, mode))
            else:
                if delta:
                    if ncnt < cost[r + 1][c]:
                        cost[r + 1][c] = ncnt
                        h.append((ncnt, r + 1, c, 1 - mode))
                else:
                    if ncnt < cost[r + 1][c]:
                        cost[r + 1][c] = ncnt
                        h.appendleft((ncnt, r + 1, c, 1 - mode))

        if c < W - 1:
            if s[r][c + 1] == CHAR[mode]:
                if cnt < cost[r][c + 1]:
                    cost[r][c + 1] = cnt
                    h.appendleft((cnt, r, c + 1, mode))
            else:
                if delta:
                    if ncnt < cost[r][c + 1]:
                        cost[r][c + 1] = ncnt
                        h.append((ncnt, r, c + 1, 1 - mode))
                else:
                    if ncnt < cost[r][c + 1]:
                        cost[r][c + 1] = ncnt
                        h.appendleft((ncnt, r, c + 1, 1 - mode))


if __name__ == '__main__':
    main()

# import sys
#
# input = sys.stdin.readline
# sys.setrecursionlimit(10 ** 7)
# rstrip()
# int(input())
# map(int, input().split())
### BUGGY CODE ###

N = int(input())
problem = [int(input()) for _ in range(N)]

def dfs(i, sum):
    if i >= N:
        if sum % 10 == 0:
            return 0
        else:
            return sum
    return max(dfs(i + 1, sum), dfs(i + 1, sum + problem[i]))

print(dfs(0, 0))

### FIXED CODE ###

N = int(input())
problem = [int(input()) for _ in range(N)]
memo = [[-1] * (sum(problem) + 1)] * N
def dsf(i, sum):
    if i == N:
        if sum % 10 == 0:
            return 0
        else:
            return sum
    if memo[i][sum] != -1: return memo[i][sum]
    else:
        memo[i][sum] = max(dsf(i + 1, sum), dsf(i + 1, sum - problem[i]))
        return memo[i][sum]

if sum(problem) % 10 != 0:
    print(sum(problem))
else:
    print(dsf(0, sum(problem)))
### BUGGY CODE ###

s = [i for i in input()]
f = True
i = 0
cnt = 0
while True:
    if s[i] == 'B' and s[i+1] == 'W':
        cnt += 1
        s[i] = 'W'
        s[i+1] = 'B'
        i += 1
        f = False
    else:
        i += 1
    if i >= len(s) - 1:
        if f:
            break
        i = 0
        f = True
print(cnt)

### FIXED CODE ###

s = [i for i in input()]
B_pos_ls = []
for i, x in enumerate(s):
    if x == 'B':
        B_pos_ls.append(i)
res = 0
B_pos_ls.sort(reverse=True)
last_B_pos = len(s) - 1
for B_pos in B_pos_ls:
    res += last_B_pos - B_pos
    last_B_pos -= 1
print(res)
### BUGGY CODE ###

N = int(input())
s = [input() for _ in range(N)]

for i in range(N):
    s[i] = ''.join(sorted(s[i])) # 文字列をソートすると配列になる

ans = 0
for i in range(N): # iは0からN-1まで
    ans += (s.count(s[i]) - 1)/2

print(int(ans))

### FIXED CODE ###

N = int(input())
s = [input() for _ in range(N)]

Dict = {} # 空の辞書を用意(集合ともみれるが)
ans = 0

for i in range(N):
    s[i] = ''.join(sorted(s[i])) # 文字列をソートすると配列になる
    if s[i] in Dict:
        ans += Dict[s[i]] # あったら過去にあった個数をansに代入
        Dict[s[i]] += 1 # 値に1追加
    else:
        Dict[s[i]] = 1 # なかったら辞書にキー(文字列)と値1を格納

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

N = int(input())
s = list(map(int, input().split()))
Q = int(input())
t = list(map(int, input().split()))
count = 0


def b_search(x, y):
    a = 0
    b = len(x)
    if y > x[b-1] or y < x[a]:
        return 0
    while b - a >= 1:
        c = (a + b) // 2
        if x[c] == y:
            return 1
        elif y < x[c]:
            b = c
        else:
            a = c
    return 0


for i in range(len(t)):
    count += b_search(s, t[i])

print(count)



### FIXED CODE ###

N = int(input())
s = list(map(int, input().split()))
Q = int(input())
t = list(map(int, input().split()))
count = 0


def b_search(x, y):
    a = 0
    b = len(x)
    if y > x[b-1] or y < x[a]:
        return 0
    while b - a > 1:
        c = (a + b) // 2
        if x[c] == y:
            return 1
        elif y < x[c]:
            b = c
        else:
            a = c
    return 0


for i in range(len(t)):
    count += b_search(s, t[i])

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

class Bit:
    def __init__(self,n):
        self.bit = [0 for i in range(n + 1)]
        self.n = n

    def add(self, i, x):
        while i <= self.n:
            self.bit[i] += x
            i += int(bin(i & -i), 2)
        
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.bit[i]
            i -= int(bin(i & -i), 2)
        return s

def solve(n, target_list):
    bit = Bit(max(target_list))
    ans = 0
    for i in range(n):
        ans += i - bit.sum(target_list[i])
        bit.add(target_list[i],1)
    return ans

if __name__ == "__main__":
    l = int(input())
    target_list = [int(i) for i in input().split()]
    print(solve(l, target_list))

### FIXED CODE ###

def bubble_sort_revision(target_list):#?????????????????????

    list_length = len(target_list)
    
    flag = True
    change_count = 0
    
    for top_index in range(1,list_length):
        for i in range(top_index, list_length)[::-1]:
            if target_list[i] < target_list[i - 1] and target_list[top_index] >= target_list[i]:
                tmp = target_list[i]
                target_list[i] = target_list[i - 1]
                target_list[i - 1] = tmp
                change_count += 1
                
    return change_count

def my_add(bit, i, x):
    while i <= len(bit) - 1:
        bit[i] += x
        i += int(bin(i & -i), 2)
        
def my_sum(bit, i):
    s = 0
    while i > 0:
        s += bit[i]
        i -= int(bin(i & -i), 2)
    return s

def merge(l,r):
    global count
    l_index = 0
    r_index = 0
    merge_list = []
    l.append(pow(10,9) + 1)
    r.append(pow(10,9) + 1)

    len_l = len(l) - 1
    for k in range(len(l) + len(r) - 2):
        if l[l_index] < r[r_index]:
            merge_list.append(l[l_index])
            l_index += 1
            len_l -= 1
        else:
            count += len_l
            merge_list.append(r[r_index])
            r_index += 1

    return merge_list
    
def merge_sort(target_list):
    if len(target_list) == 1:
        return target_list
    
    mid = int(len(target_list) / 2)
    
    r = merge_sort(target_list[mid:])
    l = merge_sort(target_list[:mid])
    
    return merge(l, r)

def bit_solve(n, target_list):#???????????§????????????bit?????§?????????????????????
    bit = [0 for i in range(max(target_list) + 2)]
    ans = 0
    for i in range(n):
        ans += i - my_sum(bit, target_list[i] + 1)
        my_add(bit, target_list[i] + 1, 1)
        print(ans, target_list[i], bit)
    return ans

if __name__ == "__main__":
    global count
    count = 0
    l = int(input())
    target_list = [int(i) for i in input().split()]
    merge_sort(target_list)
    print(count)
### BUGGY CODE ###

import math
k = int(input())
sum = 0

for i in range(1, k+1):
  for j in range(1, k+1):
    for k in range(1, k+1):
      sum += math.gcd(math.gcd(i, j), k)
      
print(sum)

### FIXED CODE ###

from math import gcd
k = int(input())
sum = 0

for i in range(1, k+1):
  for j in range(1, k+1):
    for k in range(1, k+1):
      sum += gcd(gcd(i, j), k)
      
print(sum)
### BUGGY CODE ###

n = int(input())

num = 1
for i in range (n):
	num *= i+1
print (num % 1000000007)

### FIXED CODE ###

n = int(input())

num = 1
for i in range (n):
	num = (num*(i+1)) % (10**9 + 7)
print (num % 1000000007)
### BUGGY CODE ###

N = int(input())
l = [int(i) for i in input().split()]
count = 0
l_new = sorted(l)
for i in range(N-2):
    for j in range(i+1,N-1):
        k = j+1
        while k < N and l_new[i] + l_new[j] > l_new[k]:
            k += 1
        count += max(k-(j+1),0)
print(count)

### FIXED CODE ###

import bisect
N = int(input())
l = [int(i) for i in input().split()]
count = 0
l_new = sorted(l)
for i,a in enumerate(l_new):
    for j,b in enumerate(l_new[i+1:],start = i+1):
        left = bisect.bisect_right(l_new,abs(a-b))
        right = bisect.bisect_left(l_new,a + b)
        count += right - left
        
        if left <= i < right:
            count -= 1
        if left <= j < right:
            count -= 1
        
print(count//3)
### BUGGY CODE ###

def warshall_floyd(d,s):
    for k in range(10):
        for i in range(10):
            for j in range(10):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d[s][1]

h,w = map(int,input().split())

d = [[10**4]*10 for i in range(10)] 
for i in range(10):
    a = list(map(int,input().split()))
    for j in range(10):
      d[i][j] = a[j]
for i in range(10):
    d[i][i] = 0
    
ans = 0
for _ in range(h):
  c = list(map(int,input().split()))
  for i in c:
    if i != 1 and i != -1:
      ans += warshall_floyd(d,i)
      
print(ans)

### FIXED CODE ###

def warshall_floyd(d):
    for k in range(10):
        for i in range(10):
            for j in range(10):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

h,w = map(int,input().split())

d = [[10**4]*10 for i in range(10)] 
for i in range(10):
    a = list(map(int,input().split()))
    for j in range(10):
      d[i][j] = a[j]
for i in range(10):
    d[i][i] = 0
    
ans = 0
chk = tuple(warshall_floyd(d))
for _ in range(h):
  c = list(map(int,input().split()))
  for i in c:
    if i != 1 and i != -1:
      ans += chk[i][1]
      
print(ans)
### BUGGY CODE ###

n = int(input())
import sys

def ato(x):
    if x == "Male":
        return 0
    elif x == "Female":
        return 1
    else:
        return -1
    
print(0)
s0 = ato(input())
if s0 == -1:
    sys.exit()
    
print(n-1)
s1 = ato(input())
if s1 == -1:
    sys.exit()
    
left = 0
right = n-1
center = (left+right) // 2
while right - left >= 1:
    center = (left+right) // 2
    
    print(center)
    s2 = ato(input())
    if s2 == -1:
        break
    
    if (center - left)%2 != s2 - s0:
        right = center - 1
        s1 = s2
    else:
        left = center + 1
        s0 = s2

### FIXED CODE ###

n = int(input())
import sys

def ato(x):
    if x == "Male":
        return 0
    elif x == "Female":
        return 1
    else:
        return -1
    
print(0)
s0 = ato(input())
if s0 == -1:
    sys.exit()
    
print(n-1)
s1 = ato(input())
if s1 == -1:
    sys.exit()
    
left = 0
right = n-1
center = (left+right) // 2
while True:
    center = (left+right) // 2
    
    print(center)
    s2 = ato(input())
    if s2 == -1:
        break
    
    if (center - left)%2 == abs(s2 - s0):
        left = center
        s0 = s2
    else:
        right = center
        s1 = s2