Harryxun/stf_run huggingface dataset:
# -*- coding: utf-8 -*-
#<参考>https://atcoder.jp/contests/abc178/submissions/16700679
import sys
from heapq import *
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
A = list(map(int,readline().split()))
B = list(map(int,readline().split()))

countA = [0]*(N+1)
countB = [0]*(N+1)
for i in range(N):
    countA[A[i]] += 1
    countB[B[i]] += 1

q = []
onlyA = []
onlyB = []
for i in range(N):
    if countA[i] and countB[i]:
        heappush(q,(-countA[i]-countB[i],i))
        continue
    for _ in range(countA[i]):
        onlyA.append(i)
    for _ in range(countB[i]):
        onlyB.append(i)
        
heapify(q)

if q and -q[0][0] > N:
    print('No')
    sys.exit()
print('Yes')

ans = []

while q:
    _,x = heappop(q)
    if q:
        _,y = heappop(q)
        flag = True
    else:
        y = onlyB.pop()
        flag = False
    countA[x] -= 1 
    countB[y] -= 1
    ans.append((x,y))
    if countA[x]:
        heappush(q,(-countA[x]-countB[x],x))
    else:
        for _ in range(countB[x]):
            onlyB.append(x)
            
    if flag and countB[y]:
        heappush(q,(-countA[y]-countB[y],y))
    if flag and not countB[y]:
        for _ in range(countA[y]):
            onlyA.append(y)

while onlyA:
    x,y = onlyA.pop(),onlyB.pop()
    ans.append((x,y))

ans.sort()
X,Y = zip(*ans)
print(*Y)        


### FIXED CODE ###

# -*- coding: utf-8 -*-
#<参考>https://atcoder.jp/contests/abc178/submissions/16700679
import sys
from heapq import *
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
A = list(map(int,readline().split()))
B = list(map(int,readline().split()))

countA = [0]*(N+1)
countB = [0]*(N+1)
for i in range(N):
    countA[A[i]] += 1
    countB[B[i]] += 1

q = []
onlyA = []
onlyB = []
for i in range(N+1):
    if countA[i] and countB[i]:
        heappush(q,(-countA[i]-countB[i],i))
        continue
    for _ in range(countA[i]):
        onlyA.append(i)
    for _ in range(countB[i]):
        onlyB.append(i)
        
heapify(q)

if q and -q[0][0] > N:
    print('No')
    sys.exit()
print('Yes')

ans = []

while q:
    _,x = heappop(q)
    if q:
        _,y = heappop(q)
        flag = True
    else:
        y = onlyB.pop()
        flag = False
    countA[x] -= 1 
    countB[y] -= 1
    ans.append((x,y))
    if countA[x]:
        heappush(q,(-countA[x]-countB[x],x))
    else:
        for _ in range(countB[x]):
            onlyB.append(x)
            
    if flag and countB[y]:
        heappush(q,(-countA[y]-countB[y],y))
    if flag and not countB[y]:
        for _ in range(countA[y]):
            onlyA.append(y)

while onlyA:
    x,y = onlyA.pop(),onlyB.pop()
    ans.append((x,y))

ans.sort()
X,Y = zip(*ans)
print(*Y)
def main():
    N, K = map(int, input().split(' '))
    d = [0] * N
    total = 0
    for i in range(K):
        A = input()
        B = list(map(int, input().split(' ')))
        for j in B:
            d[j - 1] = 1
    for j in range(K):
        if d[j] == 0:
            total += 1
    print(total)
main()

### FIXED CODE ###

def main():
    N, K = map(int, input().split(' '))
    d = [0] * N
    total = 0
    for i in range(K):
        A = input()
        B = list(map(int, input().split(' ')))
        for j in B:
            d[j - 1] = 1
    for j in range(N):
        if d[j] == 0:
            total += 1
    print(total)
main()
num = list(map(int, input().split()))
time = num[0] / num[2]
if time <= num[1]:
  print("Yes")
  else:
    print("No")



### FIXED CODE ###


def resolve():
    num = list(map(int, input().split()))
    time = num[0] / num[2]
    if time <= num[1]:
        print("Yes")
    else:
        print("No")
resolve()
N,K = map(int,input().split())
A = list(map(int,input().split()))
ans = [float('inf')]*N
ans[0] = 0
for i in range(1,K+1):
  ans[i] = abs(A[0]-A[i])

for i in range(K+1,N):
  for j in range(1,min(i,K)):
	  ans[i] = min(ans[i-j]+abs(A[i]-A[i-j]), ans[i-j-1]+abs(A[i]-A[i-j-1]))
print(ans[N-1])

### FIXED CODE ###

import numpy as np
N,K = map(int,input().split())
A = list(map(int,input().split()))
A = np.array(A)
ans = np.array([float('inf')]*N)
ans[0] = 0
K = min(N-1,K)
for i in range(1,K+1):
  ans[i] = abs(A[0]-A[i])
for i in range(K+1,N):
  ans[i] = min(ans[i],np.min(ans[i-K:i]+np.abs(A[i]-A[i-K:i])))
print(int(ans[N-1]))
t, k, c, d = (int(x) for x in input().split())
while (t >= 0 or c >= 0):
  c = c - k
  if c <= 0:
    print("Yes")
    break
  t = t - d
  if a <= 0:
    print("No")
    break

### FIXED CODE ###

t, k, c, d = (int(x) for x in input().split())
while (t >= 0 or c >= 0):
  c = c - k
  if c <= 0:
    print("Yes")
    break
  t = t - d
  if t <= 0:
    print("No")
    break
n = input()
a = map(int,raw_input().split())
print sum(i == a[a[i]-1]-1 for i in range(n)) / 2


### FIXED CODE ###

s = raw_input()
print s[:4], s[4:]
s = input()
t = input()
l = 10**5
S = s*l

a = 0
flag = True
for i in range(len(t)):
    if t[i] in S[a+1:]:
        a += S[a+1:].find(t[i])+1
    else:
        flag = False
        break
        
if flag:
    print(a+1)
else:
    print(-1)

### FIXED CODE ###

s = input()
t = input()
s_ = s[:]
cnt = 0
tlen = len(t)
ans = 0
flag = True

while cnt < tlen:
    
    num = s_.find(t[cnt])
    
    if num != -1:
        ans += (num+1)
        s_ = s_[(num+1):]
        cnt += 1
        flag = False
    else:
        if flag:
            print(-1)
            exit(0)
        ans += len(s_)
        s_ = s[:]
        flag = True
        
print(ans)
n, k = map(int, input().split())
a = list(map(int, input().split())).sort()
print(sum(a[:k]))

### FIXED CODE ###

n, k = map(int, input().split())
a = sorted(list(map(int, input().split())))
print(sum(a[:k]))
n = int(input())
a = 1
wihle(1):
  if a<=n:
    a*=2
  else:
    print(a//2)
    exit()

### FIXED CODE ###

n = int(input())
a = 1
while(1):
  if a<=n:
    a*=2
  else:
    print(a//2)
    exit()
s=input().sort()
t=input().sort()
for x,y in s,t:
    if x>y:
        print("Yes")
   break
print("No")

### FIXED CODE ###

s=sorted(input())
t=sorted(input(),reverse=True)
if s<t:
    print("Yes")
else:
    print("No")
def d(a):
    b, c = 0, 0
    for ball in x:
        if b < a:
             b = a
        elif c < a:
             c = a
        else:
             return False
    return True
 
n = int(raw_input())
for i in range(n):
    all = map(int, raw_input().split())
    print "YES" if d(all) else "NO"

### FIXED CODE ###

def d(x):
    b, c = 0, 0
    for a in x:
        if b < a:
             b = a
        elif c < a:
             c = a
        else:
             return False
    return True
 
n = int(raw_input())
for i in range(n):
    all = map(int, raw_input().split())
    print "YES" if d(all) else "NO"
a, b = map(int, input().split())
if a < b < c:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

a, b, c = map(int, input().split())
if a < b < c:
  print('Yes')
else:
  print('No')
xy = [] # (x, y) の配列
for _ in range(n):
    xy.append(tuple(map(float, input().split())))

# g[i][j] := the distance between i and j
g = [[math.sqrt((xy[i][0] - xy[j][0]) ** 2 + (xy[i][1] - xy[j][1]) ** 2) for j in range(n)] for i in range(n)]
t = 0
change = 0

def score(a): # aのスコアを計算する。aは目的地を辿る順に並べた長さnの配列
    s = 0.0
    for i in range(n):
        s += g[a[i]][a[(i + 1) % n]]
    return s

def gen_neighbor(a):#　ランダムに i,j を選んでスワップ
    i = random.randrange(n)
    j = random.randrange(n)
    b = a.copy()
    b[i], b[(i + j) % n] = a[(i + j) % n], a[i]
    return b

start_time = time.time()
a = list(range(n)) # 初期解 a=[0,1,...,n-1]
maxscore = 100000
for i in range(10):
    while time.time() - start_time < (i + 1) * 0.5:
        # 5秒まで0.5秒ずつ山登りした中で最も良い解を採用
        b = gen_neighbor(a)
        if score(a) > score(b): # aより良い解なら採用
            a = b
    if maxscore > score(a):
        a1 = a.copy()
    random.shuffle(a)
while time.time() - start_time < 10: # 10秒まで山登り
    b = gen_neighbor(a1)
    if score(a1) > score(b): # aより良い解なら採用
        a1 = b
print(score(a1))
print(" ".join(map(str, a1)))


### FIXED CODE ###

n, w = map(int, input().split())
l1 = [list(map(int, input().split())) for i in range(n)]
v = 0
for i in range(n):
  v += l1[i][1]
d = [10 ** 9 + 1] * (v + 1)
d[0] = 0
for i in range(n):
    for j in range(v, -1, -1):
        d[j] = min(d[j], d[j - l1[i][1]] + l1[i][0])
answer = 0
for j in range(v + 1):
    if  w >= d[j]:
        answer = max(answer, j)
print(answer)
n=int(input())
sub=dict()
for _ in range(n):
  x,u=input().split()
  if u in sub:
    sub[u]+=x
  else:
    sub[u]=x
print(float(sub["JPY"])+float(sub["BTC"])*380000.0)

### FIXED CODE ###

N = int(input())
XU = [[_ for _ in input().split()] for _ in range(N)]
ans = 0
for x, u in XU:
    if u == 'BTC':
        ans += float(x) * 380000
    else:
        ans += int(x)
print(ans)
#copy code.
s = list(input())
K = int(input())
alphabet = "abcdefghijklmnopqrstuvwxyz"

for i in range(len(s)):
    if K >= 26 or s[i] >= alphabet[-K]:
        K -= ord("z") - ord(s[i]) + 1
        s[i] = "a"

if K > 0:
    K %= 26
    if (chr(ord(s[-1]) + K) <= "z"):
        s[-1] = chr(ord(s[-1]) + K)
    else:
        s[-1] = chr(ord("a") + K)

print("".join(s))

### FIXED CODE ###

s = list(input())
s.insert(4, " ")
print("".join(s))
i = 100
for i in range (i):
    a_list = [str(x) for x in input().split()]
    a = int(a_list[0])
    b = int(a_list[2])
    op = a_list[1]
    if op == '+':
        ab = a + b
        print(ab)
        i = i + 1
        continue
    elif op == '-':
        ab = a - b
        print(ab)
        i = i + 1
        continue
    elif op == '*':
        ab = a * b
        print(ab)
        i = i + 1
        continue
    elif op == '/':
        ab = a // b
        print(ab)
        i = i + 1
        continue
    elif op == '-':
        exit()



### FIXED CODE ###

i = 100
for i in range (i):
    a_list = [str(x) for x in input().split()]
    a = int(a_list[0])
    b = int(a_list[2])
    op = a_list[1]
    if op == '+':
        ab = a + b
        print(ab)
        i = i + 1
        continue
    elif op == '-':
        ab = a - b
        print(ab)
        i = i + 1
        continue
    elif op == '*':
        ab = a * b
        print(ab)
        i = i + 1
        continue
    elif op == '/':
        ab = a // b
        print(ab)
        i = i + 1
        continue
    elif op == '?':
        exit()
from collections import defaultdict
from bisect import bisect_right

s = input()
t = input()

n = len(s)

mp = [[] for _ in range(26)]
s += s
for i in range(len(s)):
    mp[ord(s[i]) - ord('a')].append(i)

ans = 0
now = -1
for i in range(len(t)):
    a = ord(t[i]) - ord('a')
    if len(mp[a]) == 0:
        print(-1)
        exit()

    nxt = bisect_right(mp[a], now)
    nxt = mp[a][nxt]
    ans += nxt - now
    if nxt > n:
        now = nxt - n
    else:
        now = nxt
print(ans)


### FIXED CODE ###

import bisect

s = input()
t = input()
n = len(s)
s += s

pos = [[] for _ in range(26)]

for i in range(len(s)):
    pos[ord(s[i]) - ord('a')].append(i)

ans = 0
now = -1
for i in range(len(t)):
    c = ord(t[i]) - ord('a')
    j = bisect.bisect_right(pos[c], now)

    if j == len(pos[c]):
        print(-1)
        exit()
    now = pos[c][j]

    if now >= n:
        now -= n
        ans += n
print(ans + now + 1)
import heapq

n=int(input())
d=list(map(int,input().split()))
m=int(input())
t=list(map(int,input().split()))

heapq.heapify(d)
heapq.heapify(t)
cnt=0

if n>1 and m>1:
    for i in range(m):
        a=heapq.heappop(t)
        if len(b)>0:
            b=heapq.heappop(d)
        #print(a,b,cnt)
        while b<a and len(b)>0:
            b=heapq.heappop(d)
        if b==a:
            cnt+=1
    if cnt==m:
        print("YES")
    else:
        print("NO")

else:
    if n==1:
        if m==1 and t[0]==d[0]:
            print("YES")
        else:
            print("NO")
    else:
        if t[0] in d:
            print("YES")
        else:
            print("NO")
        

        
        

### FIXED CODE ###

import heapq

n=int(input())
d=list(map(int,input().split()))
m=int(input())
t=list(map(int,input().split()))

heapq.heapify(d)
heapq.heapify(t)
cnt=0


if n>1 and m>1:
    for i in range(m):
        a=heapq.heappop(t)
        if len(d)>0:
            b=heapq.heappop(d)
        #print(a,b,cnt)
        while b<a and len(d)>0:
            b=heapq.heappop(d)
        if b==a:
            cnt+=1
    if cnt==m:
        print("YES")
    else:
        print("NO")

else:
    if n==1:
        if m==1 and t[0]==d[0]:
            print("YES")
        else:
            print("NO")
    else:
        if t[0] in d:
            print("YES")
        else:
            print("NO")
def main():
    N = int(input())

    ans = 0
    for i in range(len(str(N))):
        if len(str(N)) != i+1:
            if i % 2 == 0:
                ans += 9*(10**i)
        else:
            if i % 2 == 0:
                if int(str(N)[1:]) == 0:
                    ans += 1
                else:
                    ans += int(str(N)[1:])+1
    print(ans)


if __name__ == "__main__":
    main()

### FIXED CODE ###

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

    ans = 0
    if len(str(N)) % 2 == 0:
        for i in range(len(str(N))):
            if i % 2 == 0:
                ans += 9*(10**i)
    else:
        for i in range(len(str(N))+1):
            if i % 2 == 0:
                ans += 9*(10**i)
        ans = ans - (10**len(str(N)) - N) + 1
        
    print(ans)

if __name__ == "__main__":
    main()
N=int(input())
if (N%2)=0:
  ans=N//2-1
else:
  ans=N//2
print(ans)

### FIXED CODE ###

#python 3.7.1

N=int(input())
if (N%2)==0:
  ans=N//2-1
else:
  ans=N//2
print(ans)
foo

### FIXED CODE ###

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

ans = 0
count = 0
for i in range(N-1):
    if S[i] == S[i+1]:
        ans += 1
    if S[i] != S[i+1]:
        count += 1

while count > 0 and K > 0:
    if count == 1:
        count -= 1
        ans += 1
        K -= 1
    else:
        K -= 1
        count -= 2
        ans += 2

print(ans)
import sys
import math
w, h, x, y = map(int, sys.stdin.readline().split())

d = [None for i in range(4)]
d[0] = abs(x*1+y*(-1)+w*h)/math.sqrt(1**2 + (-1)**2)
d[1] = abs(x*(-h/w)+y*(-1)+h)/math.sqrt((-h/w)**2 + (-1)**2)
d[2] = abs(x-w*0.5)
d[3] = abs(y-h*0.5)

if int(w-2*x)==0 and int(h-2*y)==0:
  print(w*h/2.0, 1)
  exit()
elif int(w-2*x)==0 or int(h-2*y)==0:
  print(w*h/2.0, 0)
  exit()

if int(d1) == 0 or int(d2) == 0:
  if int(w-2*x)==0 and int(h-2*y)==0:
    print(w*h/2.0, 1)
  else:
    print(w*h/2.0, 0)
elif d.index().min(d) == 0:
  if x > 0.5*w:
    if y < h/w*x:
      print((x*w*w)/y*0.5, 0)
    else:
      print((x*h*h)/y*0.5, 0)
  else:
    b = h - (h-y)/(w-x)*w
    if y < h/w*x:
      print(h*(w-b*(w-x)/(h-y))*0.5, 0)
    else:
      print(w*(h-b)*0.5, 0)
elif d.index().min(d) == 1:
  if int(d[0]-d[1]) == 0:
    casenum = 1
  else:
    casenum = 0
    
  if x > 0.5*w:
    if  y > -h/w*x+h:
      print(w*(-(y-h)*w/x)*0.5, casenum)
    else:
      print(h*x*h/(h-y)*0.5, casenum)
  else:
    b = (h + y*w/(x-w)) * (x-w)/y
    if  y > -h/w*x+h:
      print(h*(w-(b-h)*x/(y-h))*0.5, casenum)
    else:
      print(w*(h-b)*0.5, casenum)
elif d.index().min(d) == 2:
  if y > 0.5*h:
    b = w*y/(w-2*x)
    x1=(x-0.5*w)/y*(b-h)
    if x > 0.5*w:
      print(h*(0.5*w+w-x1)*0.5, 0)
    else:
      print(h*(0.5*w+0.5*w-x1)*0.5, 0)
  else:
    b = h - 0.5*w*y/(x-0.5*w)
    x1=b*y/(0.5*w-x)
    if x > 0.5*w:
      print(0.5*h(0.5*w+w-x1), 0)
    else:
      print(0.5*h(0.5*w+0.5*w-x1), 0)    
elif d.index().min(d) == 3:
  print(1,1)
  eixt()
  if int(d[2]-d[3]) == 0:
    casenum = 1
  else:
    casenum = 0
  if x > 0.5*w:
    if y > 0.5*h:
      print(0.5*w*(0.5*h+h-(y-0.5*h)/x*w+0.5*h), casenum)
    else:
      print(0.5*w*(0.5*h+0.5*h-(y-0.5*h)/x*w+0.5*h), casenum)
  else:
    if y > 0.5*h:
      print(0.5*w*(0.5*h+h-(0.5*h-w*(y-0.5*h)/(x-w))), casenum)
    else:
      print(0.5*w*(0.5*h+0.5*h-(0.5*h-w*(y-0.5*h)/(x-w))), casenum)    

### FIXED CODE ###

import sys
import math
w, h, x, y = map(int, sys.stdin.readline().split())
S = w*h/2

if x == w/2 and y == h/2:
  print(S,1)
else:
  print(S, 0)
s = input()
t = input()
result = len([_ for a,b in zip(s,t) if a != b])
print(result)

### FIXED CODE ###

s = input()
t = input()
result = len([a for a,b in zip(s,t) if a != b])
print(result)
import math
class Graph(object):
    def __init__(self,v):
        self.v = v
        self.visited = [False for i in range(v)]
        self.adj = [[] for i in range(v)]
        self.parent = [-1 for i in range(v)]
        self.distance = [0 for i in range(v)]

    def AddEdge(self,a,b):
        self.adj[a].append(b)
        self.adj[b].append(a)

    def BFS(self,start):
        Q = [start]
        self.visited[start] = True
        while len(Q)>0:

            cur = Q.pop(0)
            for child in self.adj[cur]:
                if self.visited[child]==False:
                    self.visited[child] = True
                    self.distance[child] = self.distance[cur]+1
                    self.parent[child] = cur
                    Q.append(child)

    def CycleDetection_Using_BFS(self,start):
        Q = [start]
        self.visited[start] = True
        while len(Q)>0:

            cur = Q.pop(0)
            for child in self.adj[cur]:
                if self.visited[child]==False:
                    self.visited[child] = True
                    self.distance[child] = self.distance[cur]+1
                    self.parent[child] = cur
                    Q.append(child)
                else:
                    if self.parent[cur]!=child:
                        return True

        return False

NK= list(map(int,input().split(' ')))
n,k = NK[0] , NK[1]
h = list(map(int,input().split(' ')))
dp = [0]*n
for i in reversed(range(n)):
    m=math.inf
    for j in range(1,k+1):
        Move = i+j
        if Move<=n-1:
            m = min(m,dp[Move]+abs(h[i]-h[Move]))
    dp[i] = 0 if m==math.inf else m
print(dp[0])




### FIXED CODE ###

import math
from functools import lru_cache
def Frog1():
    n = int(input())
    h = list(map(int,input().split(' ')))
    @lru_cache(None)
    def Solve(i):
        if i==n-1:
            return 0
        if i==n-2:
            return abs(h[i]-h[i+1])
        return min(Solve(i+1)+abs(h[i]-h[i+1]),Solve(i+2)+abs(h[i]-h[i+2]))
    dp = [0]*n
    for i in reversed(range(n)):
        if i==n-1:
            dp[i] = 0
        elif i==n-2:
            dp[i] = abs(h[i]-h[i+1])
        else:
            dp[i] = min(dp[i+1]+abs(h[i]-h[i+1]),dp[i+2]+abs(h[i]-h[i+2]))
    print(dp[0])
def Frog2():
    n,k = input().split(' ')
    n,k = int(n),int(k)
    h = list(map(int, input().split(' ')))
    @lru_cache(None)
    def Solve(i):
        if i==n-1:
            return 0
        ans = math.inf
        for j in range(1,k+1):
            new_i = i+j
            if new_i<=n-1:
                ans = min(ans , Solve(new_i)+abs(h[i]-h[new_i]))
            else:
                break
        return ans

    dp = [0]*n
    for i in reversed(range(n)):
        if i==n-1:
            dp[i] = 0
        else:
            ans = math.inf
            for j in range(1,k+1):
                new_i = i+j
                if new_i<=n-1:
                    ans = min(ans,dp[new_i]+abs(h[i]-h[new_i]))
                else:
                    break
            dp[i] = ans
    print(dp[0])

Frog2()
from sys import stdin
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

prime_list=[i for i in range(1,10001) if is_prime(i)]
oppai=[0]*10000
for i in range(3, 10001):
    if i in prime_list and (i+1)/2 in prime_list:
        oppai[i-1]=oppai[i-2]+1
    else:oppai[i-1]=oppai[i-2]
#print(oppai)
N=list(map(int,stdin.readline().strip().split()))[0]
for _ in range(N):
    count = 0
    a,b=map(int,(input().split()))
    if a==b:
        if a in  prime_list and ((a+1)/2) in  prime_list:
            count+=1
    else:
        if a>=2:
            bb=oppai[b-1]
            aa=oppai[a-2]
            count = bb - aa
        else:
            bb = oppai[b - 1]
            count = bb

    print(count)



### FIXED CODE ###

from sys import stdin
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True
prime_list=[i for i in range(2,100000) if is_prime(i)]
oppai=[0]*100000
oppai[1]=0
before=1
for num in prime_list:
    if (num+1)//2 in prime_list:
        oppai[before:num - 2] = [oppai[before]] * (num-1 - before)
        oppai[num-1]=oppai[before]+1
    else:oppai[before:num-1]=[oppai[before]]*(num-before)
    before=num-1
oppai[99991:99999]=[oppai[99990]]*8
N=list(map(int,stdin.readline().strip().split()))[0]
for _ in range(N):
    count = 0
    a,b=list(map(int,stdin.readline().strip().split()))
    if a==b:
        bb = (oppai[b - 1])
        aa = (oppai[a - 2])
        count = bb - aa
        print(count)
    else:
        if a>=2:
            bb = oppai[b - 1]
            aa = oppai[a - 2]
            count = bb - aa
            print(count)
        else:
            bb = oppai[b - 1]
            count = bb
            print(count)
N, M = map(int, input().split())
# C = [[0, 0, 0] for i in range(M)] # Cities
C = []
for i in range(M):
    P, Y = map(int, input().split())
    # C[i] = [i, P, Y]
    C.append([i, P, Y])

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

# I = [[0, 0] for i in range(M)]
I = []
Num = [0]*M

for i in range(M):
    P = C[i][1]
    # I[i] = [C[i][0], "%06d%06d" % (P, Num[P-1] + 1)]
    I.append([C[i][0], "%06d%06d" % (P, Num[P-1] + 1)])
    Num[P-1] += 1

I.sort(key=lambda x: x[0])
for i in range(M):
    print(I[i][1])

### FIXED CODE ###

N, M = map(int, input().split())
C = [[0, 0, 0] for i in range(M)] # Cities
for i in range(M):
    P, Y = map(int, input().split())
    C[i] = [i, P, Y]

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

I = [[0, 0] for i in range(M)]
Num = [0]*N

for i in range(M):
    P = C[i][1]
    Num[P-1] += 1
    I[i] = [C[i][0], "%06d%06d" % (P, Num[P-1])]

I.sort(key=lambda x: x[0])
for i in range(M):
    print(I[i][1])
# -*- coding: utf-8 -*-

import sys

def color(x, y, k):
    r = 0
    if ((x % (2*k)) / k) != 0:
        r = -1
    
    if ((y % (2*k)) / k) != 0:
        r ^= -1

    return 'B' if  r == 0 else 'W'

def nSatisfied(n, k, tl):
    maxH = 0
    for yi in xrange(0, 2*k):
        for xi in xrange(0, 2*k):
            h = 0
            for e in tl:
                x, y, c = e
                if color(x + xi, y + yi, k) == c:
                    h += 1
            if h > maxH:
                maxH = h
            if maxH == n:
                return maxH
    return maxH


n, k = [int(e) for e in raw_input().split()]
tl = []
for i in range(0, n):
    x, y, c = [e for e in raw_input().split()]
    tl.append([int(x), int(y), c])

# print
# print n, k
# print tl

# for i in range(0, 2*k):
#     print color(i, k),

# print

maxH = nSatisfied(n, k, tl)

sys.stdout.write('%d\n' % maxH)
sys.stdout.flush()


### FIXED CODE ###

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

import sys

a, b = [int(e) for e in raw_input().split()]

ans = 'Even'
if (a & 1) and (b & 1):
    ans = 'Odd'
    
sys.stdout.write('%s\n' % (ans))
sys.stdout.flush()