CodeEff/ECCO huggingface dataset:
# Original solution
n,m = list(map(int,input().split()))
data = []
for i in range(m):
    a,b = list(map(int,input().split()))
    a -= 1
    b -= 1
    data.append((b,a))
data.sort()
cnt = 0
dis = -1
for i in range(m):
    b,a = data[i]
    if(dis < a):
        cnt += 1
        dis = b - 1
print(cnt)

# Optimized solution
n,m = list(map(int,input().split()))
data = []
for i in range(m):
    a,b = list(map(int,input().split()))
    a -= 1
    b -= 1
    data.append((a,b))
data = sorted(data,key=lambda x:x[1])
cnt = 0
dis = -1
for i in range(m):
    a,b = data[i]
    if(dis < a):
        cnt += 1
        dis = b - 1
print(cnt)
# Original solution
n,m=list(map(int,input().split()))
ass=[tuple(map(int,input().split())) for i in range(m)]
ass.sort(key=lambda x:x[1])

acum = []

for ab in ass:
    if [x for x in acum if ab[0]<x <=ab[1]] == []:
        acum =acum + [ab[1]]

print((len(acum)))


# Optimized solution
n,m=list(map(int,input().split()))
ass=[tuple(map(int,input().split())) for i in range(m)]
ass.sort(key=lambda x:x[1])

acum = []

def ifsatisfied(ab):
    for x in acum:
        if ab[0]<x <=ab[1]:
            return(True)
    return(False)

for ab in ass:
    if not ifsatisfied(ab):
        acum.append(ab[1])

print((len(acum)))
# Original solution
n,m=list(map(int,input().split()))
ass=[tuple(map(int,input().split())) for i in range(m)]
ass.sort(key=lambda x:x[1])

acum = []

def ifsatisfied(ab):
    for x in acum:
        if ab[0]<x <=ab[1]:
            return(True)
    return(False)

for ab in ass:
    if (acum == [] or ab[0]>=acum[-1]):
        acum.append(ab[1])

print((len(acum)))


# Optimized solution
n,m=list(map(int,input().split()))
ass=[tuple(map(int,input().split())) for i in range(m)]
ass.sort(key=lambda x:x[1])

reg = 0
counter = 0

for ab in ass:
    if ab[0]>=reg:
        counter = counter+1
        reg=ab[1]

print(counter)
# Original solution
n , m = list(map(int, input().split()))
l = [list(map(int,input().split())) for _ in range(m)]
l.sort()

cut = [l[0]]
for i in range(1,m):
    for j in range(len(cut)):
        key = 0
        if cut[j][0] <= l[i][0]  and l[i][0] < cut[j][1] :
            cut[j][0] = l[i][0]
            key +=1
        if cut[j][0] < l[i][1] and l[i][1] <= cut[j][1]  :
            cut[j][1] = l[i][1]
            key +=1
        if key > 0:
            break
    
    if key == 0 :
        cut.append(l[i])


print((len(cut)))
    


# Optimized solution
n , m = list(map(int, input().split()))
l = [list(map(int,input().split())) for _ in range(m)]
l.sort()
l = l[::-1]
cnt = 1
key = l[0][0]
for i in range(1,m):
    if key >= l[i][1]:
        cnt += 1
        key = l[i][0]
print(cnt)
# Original solution
# coding: utf-8

def sIsland(slist):
    b1, b0 = slist[0][1], slist[0][1]-1
    slist = slist[1:]
    
    rest = []
    for i in range(len(slist)):
        if not(slist[i][0] <= b0 and b1 <= slist[i][1]):
            rest.append(slist[i])
    return rest

def solve(matrix):
    n_call = 1
    deleted = sIsland(sorted(matrix, key=lambda x:x[1]))
    while True:
        if len(deleted) == 0:
            return n_call
        deleted = sIsland(deleted)
        n_call += 1
    
if __name__ == "__main__":
    
    N, M = list(map(int, input().split()))
    matrix = []
    for i in range(M):
        matrix.append([int(x) for x in  input().split(" ")])
    print((solve(matrix)))


# Optimized solution
# coding: utf-8

def getG(N, M):
    G=[list() for i in range(N)]
    for i in range(M):
        a,b=list(map(int,input().split()))
        a-=1
        b-=1
        G[a].append(b)
        G[b].append(a)

    return G

def solve(G, N):
    ans = 0
    index = -1

    for i in range(1, N):
        for p in G[i]:
            if index < p < i:
                ans += 1
                index = i - 1
    return ans

if __name__ == "__main__":
    N, M = list(map(int, input().split()))
    G = getG(N, M)
    print((solve(G, N)))
# Original solution
N, M = list(map(int, input().split()))
demand_list = []
for _ in range(M):
    ai, bi = list(map(int, input().split()))
    demand_list.append([ai, bi])

# ソート
demands = sorted(demand_list, key=lambda d: d[1])

# 分断開始 切断されている橋は1で表現される
cut_bilagge_list = [0 for _ in range(N)]

for demand in demands:
    # すでに分断されているのかをチェックする
    if len([1 for i in cut_bilagge_list[demand[0] - 1:demand[1] - 1] if i == 1]) > 0:
        continue

    # 分断されていないので bi - 2の橋を切断する
    cut_bilagge_list[demand[1] - 2] = 1


print((sum(1 for bilagge in cut_bilagge_list if bilagge == 1)))


# Optimized solution
# https://atcoder.jp/contests/abc103/tasks/abc103_d

# ToDo not yet

# biについて昇順にソートする
# それぞれのbiについて、
# 1: すでに分断されているなら何もしない
# 2: 分断されていないならbi - 1番目の橋を切断する

N, M = list(map(int, input().split()))
demand_list = []
for _ in range(M):
    ai, bi = list(map(int, input().split()))
    demand_list.append([ai, bi])

# ソート
demands = sorted(demand_list, key=lambda d: d[1])

# 分断開始 切断されている橋は1で表現される
# cut_bilagge_list = [0 for _ in range(N)]
cnt = 0
cut_max_len = -1

for demand in demands:
    a, b = demand
    # すでに分断されているのかをチェックする
    if a < cut_max_len:
        continue
    # if len([1 for i in cut_bilagge_list[demand[0] - 1:demand[1] - 1] if i == 1]) > 0:
    #     continue

    # 分断されていないので bi - 2の橋を切断する
    # cut_bilagge_list[demand[1] - 2] = 1
    cut_max_len = b
    cnt += 1

# print(sum(1 for bilagge in cut_bilagge_list if bilagge == 1))
print(cnt)
# Original solution
import sys
import math
import collections
import bisect
import copy

# import numpy as np

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: list(map(int, sys.stdin.readline().split()))
na = lambda: list(map(int, sys.stdin.readline().split()))
na1 = lambda: list([int(x) - 1 for x in sys.stdin.readline().split()])


# ===CODE===


def main():
    n, m = ns()
    d = []
    for _ in range(m):
        a, b = ns()
        d.append([a - 1, b - 1])

    d.sort(key=lambda x: x[1])

    down = []

    for a, b in d:
        idx = bisect.bisect_left(down, a)
        if idx == len(down):
            down.append(b - 1)
    print((len(down)))


if __name__ == '__main__':
    main()


# Optimized solution
import sys
import math
import collections
import bisect
import copy

# import numpy as np

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: list(map(int, sys.stdin.readline().split()))
na = lambda: list(map(int, sys.stdin.readline().split()))
na1 = lambda: list([int(x) - 1 for x in sys.stdin.readline().split()])


# ===CODE===


def main():
    n, m = ns()
    d = []
    for _ in range(m):
        a, b = ns()
        d.append([a - 1, b - 1])

    d.sort(key=lambda x: x[1])

    down = -1
    ans = 0
    for a, b in d:
        if down < a:
            down = b-1
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()
# Original solution
import heapq

n, m = list(map(int, input().split()))
ls = [list(map(int, input().split())) for _ in range(m)]
heapq.heapify(ls)
res = 0
r = min([r for _, r in ls])
while True:
    res += 1
    while ls:
        ll, rr = heapq.heappop(ls)
        if ll >= r:
            heapq.heappush(ls, [ll, rr])
            break
    if len(ls) > 0:
        r = min([r for _, r in ls])
    else:
        break
print(res)

# Optimized solution
n, m = list(map(int, input().split()))
ls = [list(map(int, input().split())) for _ in range(m)]
ls.sort()
res = 1
rmin = float('inf')
for l, r in ls:
    if l >= rmin:
        res += 1
        rmin = r
    else:
        rmin = min(rmin, r)

print(res)
# Original solution
n,m=list(map(int, input().split(" ")))
#min=0
#max=1000000000
arr=[[0,100000000]]
for i in range(m):

    flag=1
    a,b=list(map(int, input().split(" ")))
    for n,j in enumerate(arr):
        flag=1
        if j[0]<=a and j[1]>=b:
            del arr[n]
            #arr.remove(j)
        elif j[0]>=a and j[1]<=b:
            flag=0
            break
    if flag==1:
        arr.append([a,b])

#arr.sort(key=lambda x:x[0])
arr.sort(key=lambda x:(x[0],x[1]))
#print(arr)
#count=0
num=0
count=0
for i in range(len(arr)):
    if arr[i][0]-num>=0:
        count+=1
        num=arr[i][1]

print(count)


# Optimized solution
n,m=list(map(int, input().split(" ")))
arr=[]
for i in range(m):
    a,b=list(map(int, input().split(" ")))

    arr.append([a,b])

#arr.sort(key=lambda x:x[0])
arr.sort(key=lambda x:(x[0],x[1]))
left=0
num=0
count=0
for i in range(len(arr)):
    if arr[i][0]==left:
        pass
    if arr[i][1]<=num:
        num=arr[i][1]
    if arr[i][0]-num>=0:
        count+=1
        num=arr[i][1]
        left=arr[i][0]
    #print(arr[i],count)
print(count)
# Original solution
from bisect import bisect_left

N, M = list(map(int, input().split()))
ab = [0]*M
for i in range(M):
    ab[i] = tuple(map(int, input().split()))
ab.sort()


used = [False]*M
count = 0
for i in range(M):
    if used[i]:
        continue
    head, tail = ab[i]
    used[i] = True
    j = i+1
    while j < M:
        h, t = ab[j]
        if tail <= h:
            break
        tail = min(tail, t)
        used[j] = True
        j += 1
    count += 1
print(count)


# Optimized solution
from bisect import bisect_left

N, M = list(map(int, input().split()))
ab = [0]*M
for i in range(M):
    ab[i] = tuple(map(int, input().split()))
ab.sort(key=lambda x: x[1])

cutted = [-1]
for i in range(M):
    a, b = ab[i]
    if a <= cutted[-1]:
        continue
    cutted.append(b-1)
print((len(cutted)-1))
# Original solution
N, M = list(map(int, input().split()))

Query = []
for _ in range(M):
    Query.append(list(map(int, input().split())))


Query.sort(key = lambda x : x[1])

count = 0
while len(Query) > 0:
    Query = list([x for x in Query if x[0] >= Query[0][1]])
    count += 1

print(count)


# Optimized solution
N, M = list(map(int, input().split()))

Query = []
for _ in range(M):
    Query.append(list(map(int, input().split())))


Query.sort(key = lambda x : x[1])

count = 1
last = Query[0][1]
for i in range(1, M):
    if Query[i][0] >= last:
        count += 1
        last = Query[i][1]
print(count)
# Original solution
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, M, *AB = list(map(int, read().split()))

    Q = [[] for _ in range(N - 1)]
    for i, (a, b) in enumerate(zip(*[iter(AB)] * 2)):
        Q[a - 1].append(b - 2)

    min_y = INF
    ans = 0
    for i, ys in enumerate(Q):
        if ys:
            min_y = min(min_y, min(ys))
        if i == min_y:
            ans += 1
            min_y = INF

    print(ans)
    return


if __name__ == '__main__':
    main()


# Optimized solution
import sys

read = sys.stdin.buffer.read
INF = 1 << 60


def main():
    N, M, *AB = list(map(int, read().split()))

    Q = [[] for _ in range(N - 1)]
    for a, b in zip(*[iter(AB)] * 2):
        Q[a - 1].append(b - 2)

    min_y = INF
    ans = 0
    for i, ys in enumerate(Q):
        if ys:
            min_y = min(min_y, min(ys))
        if i == min_y:
            ans += 1
            min_y = INF

    print(ans)
    return


if __name__ == '__main__':
    main()
# Original solution
import sys
from operator import itemgetter

read = sys.stdin.buffer.read
INF = 1 << 60


def main():
    N, M, *AB = list(map(int, read().split()))

    Q = [0] * M
    for i, (a, b) in enumerate(zip(*[iter(AB)] * 2)):
        Q[i] = (a - 1, b - 1)

    Q.sort(key=itemgetter(1))

    ans = 0
    last = -1
    for a, b in Q:
        if last < a:
            last = b - 1
            ans += 1

    print(ans)
    return


if __name__ == '__main__':
    main()


# Optimized solution
import sys
from operator import itemgetter

read = sys.stdin.buffer.read
INF = 1 << 60


def main():
    N, M, *AB = list(map(int, read().split()))

    Q = list(zip(*[iter(AB)] * 2))
    Q.sort(key=itemgetter(1))

    ans = 0
    last = 0
    for a, b in Q:
        if last < a:
            last = b - 1
            ans += 1

    print(ans)
    return


if __name__ == '__main__':
    main()
# Original solution
import itertools
import collections

N,M=list(map(int,input().split()))
L=list()
for i in range(M):
  a,b=list(map(int,input().split()))
  A=list(range(a,b))
  L.append(A)
R=tuple(itertools.chain.from_iterable(L))
i=0
while True:
  L=[i for i in L if collections.Counter(R).most_common()[0][0] not in i]
  R=tuple(itertools.chain.from_iterable(L))
  i+=1
  if len(L)==0:
    break
print(i)

# Optimized solution
N,M=list(map(int,input().split()))
L=list()
for i in range(M):
  a,b=list(map(int,input().split()))
  A=list([b,a])
  L.append(A)
L=sorted(L)
R=[L[0][0]-1]
for j in range(M):
  if R[-1] not in list(range(L[j][1],L[j][0])):
    R.append(L[j][0]-1)
print((len(R)))
# Original solution

n,m = list(map(int,input().split()))
d = [0]*m
ma = 0
mi = 0
for i in range(m):
    a,b = list(map(int,input().split()))
    d[i] = ((1<<a)-1) ^ ((1<<b)-1)
    ma = max(ma,a,b)
    mi = min(mi,a,b)
s = ((1<<ma)-1) | ((1<<mi)-1) 
for bit in range(1<<n):
    if bit & s:
      spr = [True]*m
      for k in range(m):
        if (d[k] & bit) > 0:
          spr[k] = False
      if sum(spr) == 0:
        print((sum([1 for i in range(n) if bit & 1<<i])))
        exit()


# Optimized solution

n,m = list(map(int,input().split()))
d = [0]*m
spr = [True]*m
ma = 0
mi = 0
for i in range(m):
    a,b = list(map(int,input().split()))
    d[i] = [a,b]

d = sorted(d)
pre = d[0][1]
ans = 1
for i,(a,b) in enumerate(d):
  if a < pre:
    if b < pre:
      pre = b
  else:
    ans += 1
    pre = b

print(ans)
# Original solution
n, m = list(map(int, input().split()))
A = [[int(i) for i in input().split()] for i in range(m)]
A.sort(key=lambda x: x[1])

posi = 0
count = 0
for i in range(m):
    if A[i][0] >= posi:
        count += 1
        posi = A[i][1]

print(count)

# Optimized solution
n, m = list(map(int, input().split()))
A = [[int(i) for i in input().split()] for i in range(m)]
A.sort(key=lambda x: x[1])

posi = A[0][1]
count = 1
for i in range(m):
    if posi <= A[i][0]:
        count += 1
        posi = A[i][1]
        
print(count)
# Original solution
n, m = list(map(int, input().split()))
SG = sorted([[int(i) for i in input().split()] for i in range(m)], key = lambda x: x[1])

cnt = 1
b = SG[0][1]
for s, g in SG:
    if s >= b:
        b = g
        cnt += 1
        
print(cnt)

# Optimized solution
n, m = list(map(int, input().split()))
A = sorted([[int(i) for i in input().split()] for i in range(m)], key = lambda x: x[1])

cnt = 0
posi = 0
for s, g in A:
    if s >= posi:
        posi = g
        cnt += 1
        
print(cnt)
# Original solution
n, m = list(map(int, input().split()))
A = sorted([[int(i) for i in input().split()] for i in range(m)], key = lambda x: x[1])

cnt = 0
posi = 0
for s, g in A:
    if s >= posi:
        posi = g
        cnt += 1
        
print(cnt)

# Optimized solution
N, M = list(map(int, input().split()))
AB = sorted([[int(i) for i in input().split()] for i in range(M)], key = lambda x: x[1])

cnt = 1
posi = AB[0][1]
for i in range(1, M):
    if AB[i][0] >= posi:
        cnt += 1
        posi = AB[i][1]

print(cnt)
# Original solution
N,M=list(map(int,input().split()))
ab=[]
for m in range(M):
  [a,b]=[int(i) for i in input().split()]
  ab.append([a,b])
ab.sort(key=lambda x:x[1])
count=[]
count.append(ab[0][1]-1)
for i in range(1,M):
  if ab[i][0]<=count[-1]<ab[i][1]:
    pass
  elif ab[i][0]<=count[-1] and ab[i][1]-1==count[-1]:
    count.remove(count[-1])
    count.append(ab[i][1]-1)
  else:
    count.append(ab[i][1]-1)
print((len(count)))

# Optimized solution
n,m=list(map(int,input().split()))
B=[]
for _ in range(m):
  a,b=list(map(int,input().split()))
  B.append([a-1,b-1])
  
B=sorted(B,key=lambda x:x[1])
ans=m
for i in range(1,m):
  if B[i][0]<B[i-1][1]:
    ans-=1
    B[i][1]=B[i-1][1]
    
print(ans)
# Original solution
# ABC103D_IslandsWar.py

import operator

"""
区画スケジューリング
まず、(ai, bi) の組を bi について昇順にソートします。ソートした順に、以下を行う。
• 既にその要望を満たしている場合、何もしない。
• 要望を満たしていない場合、bi − 1 番目の島と bi 番目の島を接続する橋を取り除く。
TLE に注意
"""

n, m = list(map(int, input().split()))
bridges = set()
ms2 = sorted((tuple(map(int, input().split())) for i in range(m)), key=operator.itemgetter(1))

for i in range(m):
    if any(x in bridges for x in range(ms2[i][0], ms2[i][1])):
        pass
    else:
        bridges.add(ms2[i][1]-1)

if __name__ == "__main__":
    print((len(bridges)))


# Optimized solution
# ABC103D_IslandsWar.py

import operator

"""
区画スケジューリング
まず、(ai, bi) の組を bi について昇順にソートします。ソートした順に、以下を行う。
• 既にその要望を満たしている場合、何もしない。
• 要望を満たしていない場合、bi − 1 番目の島と bi 番目の島を接続する橋を取り除く。
TLE に注意
"""

n, m = list(map(int, input().split()))
bridges = [0]
ms = sorted((tuple(map(int, input().split())) for i in range(m)), key=operator.itemgetter(1))

for i in range(m):
    if ms[i][0] <= bridges[-1]:
        pass
    else:
        bridges.append(ms[i][1] - 1)

if __name__ == "__main__":
    print((len(bridges)-1))
# Original solution
n, m = list(map(int, input().split()))
v = [[] for i in range(n+1)]
path = [0 for i in range(n)]
for i in range(m):
    a, b = list(map(int, input().split()))
    v[b].append(a)
for i in range(n+1):
    if v[i] == []:
        continue
    m = max(v[i])
    found = 0
    for e in path[m:i]:
        if e == 1:
            found = 1
            break
    if found == 0:
        path[i - 1] = 1
s = 0
for p in path:
    s += p
print(s)

# Optimized solution
n, m = list(map(int, input().split()))
v = [0 for i in range(n+1)]
path = [0 for i in range(n)]
for i in range(m):
    a, b = list(map(int, input().split()))
    if v[b] < a:
        v[b] = a

last = 0

for i in range(n+1):
    if v[i] == 0:
        continue
    m = v[i]

    if last < m:
        path[i - 1] = 1
        last = i - 1


s = 0
for p in path:
    s += p
print(s)
# Original solution
def s(a,i,b,c):
	return  b==sorted(b) and c==sorted(c) if i==10 else s(a,i+1,b+[a[i]],c) or s(a,i+1,b,c+[a[i]])
	
for roop in range(int(input())):
	print("YES" if s(list(map(int,input().split())),0,[],[]) else "NO")

# Optimized solution
def s(a):
	b = c = 0
	for i in a:
		if i > b:
			b = i
		elif i > c:
			c = i
		else:
			return False
	return True
	
for n in range(int(input())):
	print("YES" if s(list(map(int,input().split()))) else "NO")
# Original solution
N = int(eval(input()))

for testCase in range(N):
    A = list(map(int, input().split()))
    ok = False
    for i in range(2 ** 10):
        x = []
        y = []
        for j in range(10):
            if i & (1 << j):
                x.append(A[j])
            else:
                y.append(A[j])
        if x == sorted(x) and y == sorted(y):
            ok = True
    if ok:
        print('YES')
    else:
        print('NO')

# Optimized solution
def dfs(i, b, c):
    if i == 11:
        return (b == sorted(b) and c == sorted(c))

    if dfs(i + 1, b + [balls[i - 1]], c):
        return True

    if dfs(i + 1, b, c + [balls[i - 1]]):
        return True

    return False


if __name__ == '__main__':
    N = int(eval(input()))
    for i in range(N):
        balls = list(map(int, input().split()))
        if dfs(1, [], []):
            print("YES")
        else:
            print("NO")
# Original solution
import sys
input = sys.stdin.readline
import copy

S = [ord(s) - ord('a') for s in input().rstrip()]

INF = 10 ** 9
N = len(S)
dp = [None] * (N+1)
# そこから始めたとき、次にxが現れる位置、および、次にxをとった場合に長さLのものが全て作れる
dp[N] = [[INF] * 26, [0] * 26, 0]

for n in range(N-1,-1,-1):
    prev = dp[n+1]
    cur = copy.deepcopy(prev)
    s = S[n]
    cur[0][s] = n
    cur[1][s] = prev[2] // 26 + 1
    cur[2] = prev[2] + cur[1][s] - prev[1][s]
    dp[n] = cur

answer = []
i = 0
while i < N:
    # 辞書順で、作れる長さが一番短い文字
    L = dp[i][2] // 26
    for x in range(26):
        if dp[i][1][x] == L:
            break
    answer.append(chr(ord('a') + x))
    # その文字の場所に移動
    i = dp[i][0][x]
    i += 1

print((''.join(answer)))

# Optimized solution
import sys
input = sys.stdin.readline

S = [ord(s) - ord('a') for s in input().rstrip()]

INF = 10 ** 9
N = len(S)
dp = [None] * (N+1)
# そこから始めたとき、次にxが現れる位置、および、次にxをとった場合に長さLのものが全て作れる
dp[N] = [[INF] * 26, [0] * 26, 0]

for n in range(N-1,-1,-1):
    prev = dp[n+1]
    cur = [prev[0].copy(), prev[1].copy(), prev[2]]
    s = S[n]
    cur[0][s] = n
    cur[1][s] = prev[2] // 26 + 1
    cur[2] = prev[2] + cur[1][s] - prev[1][s]
    dp[n] = cur

answer = []
i = 0
while i < N:
    # 辞書順で、作れる長さが一番短い文字
    L = dp[i][2] // 26
    for x in range(26):
        if dp[i][1][x] == L:
            break
    answer.append(chr(ord('a') + x))
    # その文字の場所に移動
    i = dp[i][0][x]
    i += 1

print((''.join(answer)))
# Original solution
from collections import defaultdict
inf = 10**10
A = input()
N = len(A)
abc = 'abcdefghijklmbopqrstuvwxyz'
s_to_i = [defaultdict(lambda:N) for _ in range(N+1)]
for x in abc:   
    s_to_i[-1][x] = N
for i in range(N)[::-1]:
    for x in abc:
        s_to_i[i][x] = s_to_i[i+1][x]
    s_to_i[i][A[i]] = i
def C(x, i):
    now = i
    for i in range(x):
        now = max(s_to_i[now].values())+1
        if now == N+1:
            return True
    return False
def bisect(i):
    ok = N+1
    ng = 0
    while ok-ng>1:
        mid = (ok+ng)//2
        if C(mid, i):
            ok = mid
        else:
            ng = mid
    return ok
dp = [bisect(i) for i in range(N+1)]
n = dp[0]
ans = []
now = 0
for i in range(n):
    for x in abc:
        tmp = now
        tmp = s_to_i[now][x]+1
        if tmp>N or dp[tmp] == n-i-1:
            ans.append(x)
            now = tmp
            break

print(*ans, sep = "")
    
        





# Optimized solution
from collections import defaultdict
inf = 10**10
A = list(map(lambda x:ord(x)-ord('a'), list(input())))
N = len(A)
abc = 'abcdefghijklmbopqrstuvwxyz'
s_to_i = [[N]*26 for _ in range(N+1)]
for i in range(N)[::-1]:
    for x in range(26):
        s_to_i[i][x] = s_to_i[i+1][x]
    s_to_i[i][A[i]] = i
dp = [0]*(N+2)
dp[-2] = 1
for i in range(N)[::-1]:
    now = max(s_to_i[i])+1
    dp[i] = dp[now]+1
n = dp[0]
now = 0
ans = []
for i in range(n):
    for x in range(26):
        tmp = s_to_i[now][x]+1
        if dp[tmp] <= n-i-1:
            ans.append(chr(x+ord('a')))
            now = tmp
            break
print(*ans, sep = '')
# Original solution
# AGC014B - Unplanned Queries
from collections import Counter


def main():
    *A, = list(map(int, open(0).read().split()))
    T = list(Counter(A[2:]).values())
    flg = all(i % 2 == 0 for i in T)
    print(("YES" if flg else "NO"))


if __name__ == "__main__":
    main()

# Optimized solution
# AGC014B - Unplanned Queries
from collections import Counter


def main():
    # all vertices need to appear even times in A
    *A, = list(map(int, open(0).read().split()))
    T = list(Counter(A[2:]).values())
    flg = any(i % 2 for i in T)
    print(("NO" if flg else "YES"))


if __name__ == "__main__":
    main()
# Original solution
# -*- coding: utf-8 -*-


def main():
    n, m = list(map(int, input().split()))
    a = [0 for _ in range(n)]
    b = [0 for _ in range(n)]

    # スターグラフを作ってみる
    for i in range(m):
        ai, bi = list(map(int, input().split()))
        # 0-index
        ai -= 1
        bi -= 1

        if ai == 0:
            a[bi] += 1
        elif bi == 0:
            b[ai] += 1
        else:
            a[bi] += 1
            b[ai] += 1

    for ai, bi in zip(a, b):
        if (ai + bi) % 2 == 1:
            print('NO')
            exit()

    print('YES')


if __name__ == '__main__':
    main()


# Optimized solution
# -*- coding: utf-8 -*-


def main():
    n, m = list(map(int, input().split()))
    c = [0 for _ in range(n)]

    # KeyInsight
    # https://www.youtube.com/watch?v=UHfTqvaD0pk：
    # とっかかりとして，根付き木を考える（最終的には，木の形状は関係ない）
    # 始点x，終点yとして，根をrとする．
    # x -> yを x -> r, y -> rの形に分解
    # 関心があるのは偶奇のみ，同じ操作が偶数回あるときは操作しないことと同じ
    # x, yの登場回数がすべて偶数ならYES，奇数が1つでもあればNO
    for i in range(m):
        ai, bi = list(map(int, input().split()))
        # 0-index
        ai -= 1
        bi -= 1
        c[ai] += 1
        c[bi] += 1

    for ci in c:
        if ci % 2 == 1:
            print('NO')
            exit()

    print('YES')


if __name__ == '__main__':
    main()