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

s = input()

tmp = s
while '01' in tmp or '10' in tmp :
    tmp = tmp.replace('01','').replace('10','')

print(len(s)-len(tmp))

### FIXED CODE ###

s = input()
print(min(s.count('1'), s.count('0'))*2)
### BUGGY CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
import itertools

def input():
    return sys.stdin.readline()


def resolve():
    n = int(input().rstrip())

    for m in range(1, n+1):
        xyz_list = []
        for i in range(1, m+1):
            xyz_list.append(i)
        p = itertools.combinations_with_replacement(xyz_list, 3)
        ans_cnt = 0
        for v in p:
            #print(v)
            x, y, z = v
            max_value = max(x, y, z)
            min_value = min(x, y, z)
            if min_value*min_value >= m:
                break
            if max_value*max_value >= m:
                continue

            ans = x*x + y*y + z*z + x*y + y*z + z*x

            if ans == m:
                if x == y == z:
                    ans_cnt += 1
                elif x == y or y == z or x == z:
                    ans_cnt += 3
                else:
                    ans_cnt += 6

        print(ans_cnt)



if __name__ == "__main__":
    resolve()



### FIXED CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
import itertools
import math

def input():
    return sys.stdin.readline()


def resolve():
    n = int(input().rstrip())
    max_n = n
    max_n = math.sqrt(max_n)
    max_n = math.ceil(max_n)

    ans = [0] * 10050

    for i in range(1, max_n+1):
        for j in range(1, max_n+1):
            for k in range(1, max_n+1):
                v = i*i + j*j + k*k + i*j + j*k + k*i
                if v < 10050:
                    ans[v] += 1

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

    """
    p = itertools.combinations_with_replacement(range(1, max_n), 3)

    #print(len(list(p)))
    ans_list = []


    for v in p:

        x, y, z = v
        ans_cnt = 0
        ans_list.append(x * x + y * y + z * z + x * y + y * z + z * x)



        if ans == m:
            if x == y == z:
                ans_cnt += 1
            elif x == y or y == z or x == z:
                ans_cnt += 3
            else:
                ans_cnt += 6
    """


    """
    for m in range(1, n+1):

        max_n = math.sqrt(m)
        max_n = math.ceil(max_n)
        p = itertools.combinations_with_replacement(range(1,max_n), 3)

        ans_cnt = 0
        for v in p:
            #print(v)
            x, y, z = v
            ans = x*x + y*y + z*z + x*y + y*z + z*x

            if ans == m:
                if x == y == z:
                    ans_cnt += 1
                elif x == y or y == z or x == z:
                    ans_cnt += 3
                else:
                    ans_cnt += 6

        print(ans_cnt)
    """


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

times=10**100
S=input()
bs=[True if s=="L" else False for s in S]
#print(bs)

start=-1
cycle=-1
list_list=[]

clist=[1]*len(bs)
list_list.append(clist)

dic_list={}
for i in range(1,10**100):  
  new_clist=[0]*len(bs)
  for j,b in enumerate(bs):
    if b:
      new_clist[j-1]+=clist[j]
    else:
      new_clist[j+1]+=clist[j]

  clist=new_clist
  list_list.append(clist)
  #print(clist)
  
  if str(clist) in dic_list:
    #print(i,i-dic_list[str(clist)],str(clist))
    start=dic_list[str(clist)]
    cycle=i-dic_list[str(clist)]
    break
  else:
    dic_list[str(clist)]=i
    
#print(start,cycle,list_list[start])
index=((10**100-start)%cycle)+start
ans_list=map(str,list_list[index])
print(" ".join(ans_list))


### FIXED CODE ###

S=input()
ans_list=[0]*len(S)

rmode=True
cnt_R=0
cnt_L=0
border_R=0
border_L=0
for i in range(len(S)):
  if rmode:
    if S[i]=="R":
      cnt_R+=1
    else:
      border_R=i-1
      border_L=i      
      rmode=False
      cnt_L=1
  else:
    if S[i]=="L":
      cnt_L+=1
    else:
      ans_list[border_R]+=(cnt_R+1)//2
      ans_list[border_L]+=cnt_R//2
      ans_list[border_R]+=cnt_L//2
      ans_list[border_L]+=(cnt_L+1)//2
      rmode=True
      cnt_R=1
      cnt_L=0
else:
  ans_list[border_R]+=(cnt_R+1)//2
  ans_list[border_L]+=cnt_R//2
  ans_list[border_R]+=cnt_L//2
  ans_list[border_L]+=(cnt_L+1)//2
  
      
ans_list_str=map(str,ans_list)
print(" ".join(ans_list_str))
### BUGGY CODE ###

import heapq

def want_p(n):

    Q = []

    while n != p[n]:
        Q.append(n)
        n = p[n]

    for i in Q:
        p[i] = n

    return n


N = int(input())

xyi = []
yxi = []

for i in range(N):

    x,y = map(int,input().split())
    xyi.append([x,y,i])
    yxi.append([y,x,i])

xyi.sort()
yxi.sort()

line = []


for i in range(N-1):

    heapq.heappush(line,[ xyi[i+1][0]-xyi[i][0] , xyi[i][2] , xyi[i+1][2] ])
    heapq.heappush(line,[ yxi[i+1][0]-yxi[i][0] , yxi[i][2] , yxi[i+1][2] ])

line.sort()

p = [i for i in range(N)]
rank = [1] * N
ans = 0

while len(line) > 0:

    e = heapq.heappop(line)
    cost = e[0]
    a = e[1]
    b = e[2]

    ap = want_p(a)
    bp = want_p(b)

    #print (a,b,cost,p,ans)

    if ap != bp:
        ans += cost

        if rank[ap] > rank[bp]:
            p[bp] = ap

        elif rank[ap] == rank[bp]:
            p[bp] = ap
            rank[ap] += 1

        else:
            p[ap] = bp

print (ans)
        

### FIXED CODE ###

def want_p(n):
 
    Q = []
 
    while n != p[n]:
        Q.append(n)
        n = p[n]
 
    for i in Q:
        p[i] = n
 
    return n
 
 
N = int(input())
 
xyi = []
yxi = []
 
for i in range(N):
 
    x,y = map(int,input().split())
    xyi.append([x,y,i])
    yxi.append([y,x,i])
 
xyi.sort()
yxi.sort()
 
line = []
 
 
for i in range(N-1):
 
    line.append([ xyi[i+1][0]-xyi[i][0] , xyi[i][2] , xyi[i+1][2] ])
    line.append([ yxi[i+1][0]-yxi[i][0] , yxi[i][2] , yxi[i+1][2] ])
 
line.sort()
 
p = [i for i in range(N)]
rank = [1] * N
num = [1] * N
ans = 0
 
for j in range(len(line)):
 
    e = line[j]
    cost = e[0]
    a = e[1]
    b = e[2]
 
    ap = want_p(a)
    bp = want_p(b)
 
    if ap != bp:
        ans += cost

        k = num[ap]
        num[ap] += num[bp]
        num[bp] += k

        if num[ap] == N or num[bp] == N:
            break
 
        if rank[ap] > rank[bp]:
            p[bp] = ap
 
        elif rank[ap] == rank[bp]:
            p[bp] = ap
            rank[ap] += 1
 
        else:
            p[ap] = bp
 
print (ans)
### BUGGY CODE ###

N, X = map(int, input().split())
S = sorted(list(map(int, input().split())))
mod = 10 ** 9 + 7
dp = [[0 for _ in range(X+1)] for _ in range(N+1)]
dp[1] = [i % S[0] for i in range(X+1)]
S = [None] + S

for i in range(2, N+1):
    for j in range(X+1):
        dp[i][j] = (dp[i-1][j]*(i-1) + dp[i-1][j%S[i]]) % mod


print(dp[-1][-1])

### FIXED CODE ###

N, X = map(int, input().split())
S = sorted(list(map(int, input().split())))
mod = 10 ** 9 + 7
dp = [[0 for _ in range(X+1)] for _ in range(N+1)]
dp[1] = [i % S[0] for i in range(X+1)]
S = [None] + S

for i in range(2, N+1):
    for j in range(X+1):
        dp[i][j] = (dp[i-1][j]*(i-1) + dp[i-1][j%S[i]]) % mod


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

n, k = map(int, input().split())
xy = [list(map(int, input().split())) for _ in range(n)]

MAX = 10**9
MIN = -1 * MAX
def check(x_r, x_l, y_t, y_b):
    tl = [MIN, MAX]
    br = [MAX, MIN]
    if x_r == x_l or y_t == y_b:
        return False, -1

    tl[0] = max(tl[0], xy[x_l][0])
    tl[1] = min(tl[1], xy[y_t][1])
    br[0] = min(br[0], xy[x_r][0])
    br[1] = max(br[1], xy[y_b][1])

    # count k
    cnt = 0
    for i in range(n):
        if tl[0] <= xy[i][0] <= br[0] and br[1] <= xy[i][1] <= tl[1]:
            cnt += 1
    if cnt < k:
        return False, -1
    area = (br[0] - tl[0]) * (tl[1] - br[1])
    return True, area

INF = 10**20
ans = INF
for a in range(n):
    for b in range(n):
        for c in range(n):
            for d in range(n):
                f, area = check(a, b, c, d)
                if f:
                    ans = min(ans, area)
print(ans)

### FIXED CODE ###

n, k = map(int, input().split())
xy = [list(map(int, input().split())) for _ in range(n)]

MAX = 10**9
MIN = -1 * MAX
def check(x_r, x_l, y_t, y_b):
    tl = [MIN, MAX]
    br = [MAX, MIN]
    if x_r == x_l or y_t == y_b:
        return False, -1

    tl[0] = max(tl[0], xy[x_l][0])
    tl[1] = min(tl[1], xy[y_t][1])
    br[0] = min(br[0], xy[x_r][0])
    br[1] = max(br[1], xy[y_b][1])

    # count k
    cnt = 0
    for i in range(n):
        if tl[0] <= xy[i][0] <= br[0] and br[1] <= xy[i][1] <= tl[1]:
            cnt += 1
    if cnt < k:
        return False, -1
    area = (br[0] - tl[0]) * (tl[1] - br[1])
    return True, area

INF = 10**20
ans = INF
for a in range(n):
    for b in range(n):
        if a == b:
            continue
        if xy[a][0] < xy[b][0]:
            continue
        for c in range(n):
            for d in range(n):
                if c == d:
                    continue
                if xy[c][1] < xy[d][1]:
                    continue
                f, area = check(a, b, c, d)
                if f:
                    ans = min(ans, area)
print(ans)
### BUGGY CODE ###

H,W,N = [int(input()) for i in range(3)]
o = 1
a = N / o
while a <= H or W:
  if H < W and a > W:
      o += 1
  elif W < H and a > H:
      o += 1
print(o)    
    
    
    





	

  
  
  



### FIXED CODE ###

H,W,N = [int(input()) for i in range(3)]
for o in range(1,10000):
  if H <= W and N / o <= W:
    break
  elif H >= W and N / o <= H:
    break
print(o)
### BUGGY CODE ###

#UnionFind木とそれを利用したクラスカル法
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
        return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
                x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

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

    def nums(self,x):
        return abs(self.parents[self.find(x)])

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


N = int(input())
A = [list(map(int, input().split()))+[i] for i in range(N)]
edge = []
A.sort()
for i in range(N-1):
    w = min(abs(A[i+1][0]-A[i][0]),abs(A[i+1][1]-A[i][1]))
    edge.append((w,A[i][2],A[i+1][2]))
A.sort(key=lambda x:x[1])
for i in range(N-1):
    w = min(abs(A[i+1][0]-A[i][0]),abs(A[i+1][1]-A[i][1]))
    edge.append((w,A[i][2],A[i+1][2]))

edge.sort()

uf = UnionFind(N)
ans = 0
for i in range(len(edge)):
    u,x,y = edge[i]
    if not uf.same(x,y):
        uf.union(x,y)
        ans += u
print(ans)

### FIXED CODE ###

#最小全域木問題、プリム法
from heapq import *
def solve():
    N = int(input())
    A = [list(map(int, input().split()))+[i] for i in range(N)]
    edge = [[] for _ in range(N)]
    A.sort()
    for i in range(N-1):
        w = min(abs(A[i+1][0]-A[i][0]),abs(A[i+1][1]-A[i][1]))
        edge[A[i][2]].append((w,A[i+1][2]))
        edge[A[i+1][2]].append((w,A[i][2]))
    A.sort(key=lambda x:x[1])
    for i in range(N-1):
        w = min(abs(A[i+1][0]-A[i][0]),abs(A[i+1][1]-A[i][1]))
        edge[A[i][2]].append((w,A[i+1][2]))
        edge[A[i+1][2]].append((w,A[i][2]))
    bridges = []
    heapify(bridges)
    used = [False]*N
    used[0] = True
    ans = 0
    for w,v in edge[0]:
        heappush(bridges,(w,v))
    while len(bridges)>0:
        w,v = heappop(bridges)
        if used[v]==False:
            ans += w
            used[v] = True
            for w,u in edge[v]:
                if used[u]==False:
                    heappush(bridges,(w,u))
    return ans
print(solve())
### BUGGY CODE ###

n = int(input())
a = [int(_) for _ in input().split()]
M = max(a)
p = len(format(M, 'b'))
l = [[0 for _ in range(n)] for _ in range(p)]
for i in range(n):
    a_s = format(a[i], '0' + str(p) + 'b')
    for c in range(p):
        l[c][i] = int(a_s[c])
# for i in range(p):
#     print(l[i])
s = [[0 for _ in range(n+1)] for _ in range(p)]
for i in range(p):
    for j in range(n):
        s[i][j+1] = s[i][j] + l[i][j]
# for i in range(p):
#     print(s[i])
ans = 0
for j in range(n-1):
    for i in range(p):
        if l[i][j] == 1:
            ans += ((2**(p - i - 1)) * ((n - j - 1) - (s[i][n] - s[i][j+1]))) % ((10**9) + 7)
        else:
            ans += ((2**(p - i - 1)) * (s[i][n] - s[i][j+1])) % ((10**9) + 7)
        ans = ans % ((10**9) + 7)
print(ans)


### FIXED CODE ###

import sys
input = sys.stdin.readline


def main():
    n = int(input())
    a = [int(_) for _ in input().split()]
    M = max(a)
    p = len(format(M, 'b'))
    l = [0 for _ in range(p)]
    ans = 0
    for i in range(n):
        a_s = format(a[i], '0' + str(p) + 'b')
        for c in range(p):
            if a_s[c] == '1':
                l[c] += 1
    for i in range(p):
        c1 = l[i]
        ans += (2**(p - i - 1)) * c1 * (n - c1)
        ans %= (10**9 + 7)
    print(ans)

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

N,M=map(int,input().split())
L1=[]
LN=[]
for i in range(M):
    a,b=map(int,input().split())
    if a==1:
        if b in LN:
            print("POSSIBLE")
            exit()
        else:
            L1.append(b)
    elif b==N:
        if a in L1:
            print("POSSIBLE")
            exit()
        else:
            LN.append(a)
print("IMPOSSIBLE")

### FIXED CODE ###

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

Start=[]
Goal=[]

for i in range(M):
    a,b=map(int,input().split())
    if a==1:
        Start.append(b)
    elif b==1:
        Start.append(a)
    if a==N:
        Goal.append(b)
    elif b==N:
        Goal.append(a)
    
S=set(Start)
G=set(Goal)
if len(S&G)>0:
    print("POSSIBLE")
elif len(S&G)==0:
    print("IMPOSSIBLE")
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**7)
n, q = map(int, input().split(' '))
     
inf = [[] for _ in range(n)]
for i in range(n-1):
    a, b = map(int, input().split(' '))
    inf[a-1].append(b-1)
    inf[b-1].append(a-1)
point = [0 for _ in range(n)]
for i in range(q):
    p, x = map(int, input().split(' '))
    point[p-1] += x
def add(num):
    for k in inf[num]:
        if k != num:
            inf[k].remove(num)
            point[k] += point[num]
            add(k)  
add(0)
print(*point)

### FIXED CODE ###

def main():
    n, q = map(int, input().split(' '))
    import sys
    from collections import deque
    sys.setrecursionlimit(10**7)

    visit = [True for _ in range(n)]
    point = [0 for _ in range(n)]
    dic = [[] for _ in range(n)]
    for _ in range(n-1):
        a, b = map(int, input().split(' '))
        dic[a-1].append(b-1)
        dic[b-1].append(a-1)
    for _ in range(q):
        p, x = map(int, input().split(' '))
        point[p-1] += x
    next_visit = deque()
    next_visit.append(0)
    visit[0] = False
    counter = 1
    while counter < n:
        t = next_visit.pop()
        for s in dic[t]:
            if visit[s]:
                point[s] += point[t]
                visit[s] = False
                counter += 1
                next_visit.append(s)
    print(*point)
if __name__ == '__main__':
    main()
### BUGGY CODE ###

from itertools import combinations

N = int(input())
A_list = tuple(map(int, input().split(' ')))

# print(N)
# print(A_list)

ret = 0
# 重複なしの組み合わせごとに積を出し、その和
for comb in combinations(A_list, 2):
  # print(comb)
  ret += comb[0] * comb[1]
  
print(ret % 1000000007)

### FIXED CODE ###

N = int(input())
A_list = tuple(map(int, input().split(' ')))

# print(N)
# print(A_list)

ret = 0
now_sum = sum(A_list)
# print("スタート{}".format(now_sum))

for i in range(len(A_list)):
  now_sum -= A_list[i]
  multiple_base = A_list[i]
  # print('now_sumから{0}を引いて{1}'.format(A_list[i], now_sum))
  before_total = 0
  # print("before_totalは{0}, multiple_baseは{1}, 掛け算で{2}".format(multiple_base, before_total, multiple_base * before_total))
  ret += multiple_base * now_sum
  
print(ret % 1000000007)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
n=int(input())
numlista=list(map(int,input().split()))
#aの合計を求める(suma)
suma=0
for i in range(n):
  suma+=numlista[i]
#1~10000がそれぞれいくつあるのか調べる(numkosuu)
numkosuu=[]
for i in range(100000):
  numkosuu.append(numlista.count(i+1))
q=int(input())
for i in range(q):
  b,c=map(int,input().split())
#変化したところのみ計算する
  suma+=(c-b)*numkosuu[b-1]
#個数を更新する
  numkosuu[c-1]+=numkosuu[b-1]
  numkosuu[b-1]=0
  print(suma)

### FIXED CODE ###

# -*- coding: utf-8 -*-
n=int(input())
numlista=list(map(int,input().split()))
import collections
numkosuu=collections.Counter(numlista)
suma=0
for i in numlista:
  suma+=i
q=int(input())
for i in range(q):
  b,c=map(int,input().split())
#変化したところのみ計算する
  suma+=(c-b)*numkosuu[b]
#個数を更新する
  numkosuu[c]+=numkosuu[b]
  numkosuu[b]=0
  print(suma)
### BUGGY CODE ###

n,*o=open(0)
n=int(n)
r=list(range(n))
print(sum(n*all(o[i][(a+j)%n]==o[j][(a+i)%n]for i in r for j in r)for a in r))

### FIXED CODE ###

n,*o=open(0)
n=int(n)
r=list(range(n))
print(sum((n-a-b)*all(o[(i+b)%n][(a+j)%n]==o[(j+b)%n][(a+i)%n]for i in r for j in r[i:])for a,b in zip(r+[0]*n,[0]*~-n+r)))
### BUGGY CODE ###

def resolve():
    import sys
    from collections import deque
    input = sys.stdin.readline
    n,m = map(int,input().split())
    edgein = [[] for i in range(n)]
    edgeout = [[] for i in range(n)]
    edgecnt=[0]*n
    rootnum=0
    for i in range(n+m-1):
        a,b= map(int,input().split())
        edgein[b-1].append(a-1)
        edgeout[a-1].append(b-1)
    for i in range(n):
        edgecnt[i]=len(edgein[i])
        if edgecnt[i]==0:
            rootnum=i
    chkedge=deque()
    chkedge.append(rootnum)
    while chkedge:
        chk=chkedge.popleft()
        for i in edgeout[chk]:
            edgecnt[i]=max(edgecnt[i],edgecnt[chk]+1)
            chkedge.append(i)
    for i in range(n):
        chk=edgecnt[i]
        if not edgein[i]:
            print(0)
        for j in edgein[i]:
            if edgecnt[j]==chk-1:
                print(j+1)
                break

if __name__ == '__main__':
    resolve()

### FIXED CODE ###

def resolve():
    import sys
    from collections import deque
    input = sys.stdin.readline
    n,m = map(int,input().split())
    edge = [[] for i in range(n)]
    edgecnt=[0]*n
    ans=[0]*n
    for i in range(n+m-1):
        a,b= map(int,input().split())
        edge[a-1].append(b-1)
        edgecnt[b-1]+=1
    for i,j in enumerate(edgecnt):
        if j==0:
            ans[i]=-1
            chkedge=deque([i])
            break
    while chkedge:
        chk=chkedge.popleft()
        for i in edge[chk]:
            edgecnt[i]-=1
            if edgecnt[i]==0:
                ans[i]=chk
                chkedge.append(i)
    for i in ans:print(i+1)

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

import sys
input = sys.stdin.readline

def main():
  N,K = map(int,input().split())
  A = sorted(list(map(int,input().split())))

  INF = 10**18+1
  l = -INF
  r = INF
  while(l+1 < r):
    # 積がc未満となるペアの個数xを求める。
    # K番目の積は、それより小さい積の個数がK未満である席のうち最大のもの。
    c = (l+r)//2
    x = 0
    for a in A:
      if a >= 0:
        ll = -1
        rr = N
        while(ll+1 < rr):
          cc = (ll+rr)//2
          if a*A[cc] < c:
            ll = cc
          else:
            rr = cc
        x += ll+1
      else:
        ll = -1
        rr = N
        while (ll+1 < rr):
          cc = (ll+rr)//2
          if a*A[cc] < c:
            rr = cc
          else:
            ll = cc
        x += N-rr
      if a*a < c:
        x -=1
    x //= 2
    if x < K:
      l = c
    else:
      r = c
  print(l)

if __name__ == '__main__':
  main()


### FIXED CODE ###

import sys
input = sys.stdin.readline

def main():
  N,K = map(int,input().split())
  A = sorted(list(map(int,input().split())))
  
  AM = []
  AP = []
  for a in A:
    if a > 0:
      AP.append(a)
    elif a < 0:
      AM.append(a)

  INF = 10**18+1
  l = -INF
  r = INF
  while(l+1 < r):
    # 積がc未満となるペアの個数xを求める。
    # K番目の積は、それより小さい積の個数がK未満である席のうち最大のもの。
    c = (l+r)//2
    x = 0
    if c > 0:
      i = len(AP)-1
      for j in range(len(AP)):
        if j >= i:
          break
        while(j < i and AP[i]*AP[j] >= c):
          i -= 1
        x += i-j
      i = 0
      for j in range(len(AM)-1,-1,-1):
        if j <= i:
          break
        while (i < j and AM[i]*AM[j] >= c):
          i += 1
        x += j-i
      #print(c,x)
      x += len(AP)*len(AM)
      x += (len(AP)+len(AM))*(N-len(AP)-len(AM))
      if N-len(AP)-len(AM) > 1:
        x += (N-len(AP)-len(AM))*(N-len(AP)-len(AM)-1)//2
    elif c == 0:
      x += len(AP)*len(AM)
    else:
      i = 0
      for j in range(len(AM)):
        while(i < len(AP) and AP[i]*AM[j] >= c):
          i += 1
        x += len(AP)-i

    #print(l,r,c,x)
    if x < K:
      l = c
    else:
      r = c
  print(l)

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

n,k=map(int,input().split())
a=list(map(int,input().split()))
l=[]
score=1
for i in range(k):
    score*=a[i]
l.append(score)
m=k
d=0
multi=a[m]
div=a[d]
for i in range(k+1,n+1):
    score=(score*a[m])//a[d]
    l.append(score)
    m+=1
    d+=1
old=l[0]
for i in range(1,len(l)):
    if l[i]<=old:
        print("No")
    else:
        print("Yes")
    old=l[i]


### FIXED CODE ###

n,k=map(int,input().split())
a=list(map(int,input().split()))
m=k
d=0
for i in range(k+1,n+1):
    if a[m]<=a[d]:
        print("No")
    else:
        print("Yes")
    m+=1
    d+=1
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
aa =set(a)
ans = 0
num = 0
for k in aa:
  num = a.count(k)+a.count(k-1)+a.count(k+1)
  ans = max(ans,num)
print(ans)

### FIXED CODE ###

N = int(input())
a = [int(x) for x in input().split()]
memo = [0]*(10**5+2)
ans = 1
for i in range(N):
  memo[a[i]] += 1
  memo[a[i]+1] += 1
  memo[a[i]-1] += 1
print(max(memo))
### BUGGY CODE ###

q=int(input())
from math import floor,sqrt
def isPrime(x):
  if x<2:
    return False
  elif x==2:
    return True
  elif x%2==0:
    return False
  for i in range(3,floor(sqrt(x))+1,2):
    if x%i==0:
      return False
  return True
def PrimeSet(x):
  p=set()
  for i in range(1,x+1):
    if isPrime(i):
      p.add(i)
  return p
prime1=PrimeSet(10**5)
prime2=set()
for j in range(1,10**5+1):
  if j%2:
    i=(j+1)//2
    if isPrime(i):
      prime2.add(j)
prime3=prime1&prime2
for i in range(q):
  l,r=map(int,input().split())
  print(len(set(range(l,r+1))&prime3))

### FIXED CODE ###

q=int(input())
from math import floor,sqrt
def isPrime(x):
  if x<2:
    return False
  elif x==2:
    return True
  elif x%2==0:
    return False
  for i in range(3,floor(sqrt(x))+1,2):
    if x%i==0:
      return False
  return True
def PrimeSet(x):
  p=set()
  for i in range(1,x+1):
    if isPrime(i):
      p.add(i)
  return p
prime1=PrimeSet(10**5)
prime2=set()
for j in range(1,10**5+1):
  if j%2:
    i=(j+1)//2
    if isPrime(i):
      prime2.add(j)
prime3=prime1&prime2
plist=[0]*(10**5+1)
for i in range(1,10**5+1):
  plist[i]=plist[i-1]
  if i in prime3:
    plist[i]+=1
for i in range(q):
  l,r=map(int,input().split())
  print(plist[r]-plist[l-1])