Language: C++

using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
using static AtCoder.Tool;
namespace AtCoder
{
    class AC
    {
        const int mod = 1000000007;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;
        static readonly int[] dx = { 0, 1, 0, -1 };
        static readonly int[] dy = { 1, 0, -1, 0 };

        static int Comp(Tuple<int, int> t1, Tuple<int, int> t2)
        {
            if (t1.Item2 != t2.Item2)
            {
                return t1.Item2 > t2.Item2 ? 1 : -1;
            }
            else
            {
                return t1.Item1 > t2.Item1 ? 1 : -1;
            }
        }

        static void Main(string[] args)
        {
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            var cin = new Scanner();

            var input = cin.SplitRead();
            int N = input[0];
            int M = input[1];
            List<Tuple<int, int>> ab = new List<Tuple<int, int>>();
            for(var i = 0; i < M; i++)
            {
                var p = cin.SplitRead();
                ab.Add(new Tuple<int, int>(p[0], p[1]));
            }
            ab.Sort(Comp);

            int prev = -1;
            long ans = 0;
            for(var i = 0; i < M; i++)
            {
                if (ab[i].Item1 > prev)
                {
                    ans++;
                    prev = ab[i].Item2 - 1;
                }
            }

            Console.WriteLine(ans);

            //Console.Out.Flush();
        }
        
        
    }
    public class Scanner
    {
        public int[] SplitRead()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReadL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }
    }

    public static class Tool
    {
        static public void Initialize<T>(ref T[] array, T initialvalue)
        {
            for (var i = 0; i < array.Length; i++)
            {
                array[i] = initialvalue;
            }
        }
        static public long Modulo(long value, long mod)
        {
            long r = value % mod;

            if (r * mod < 0)
            {
                r += mod;
            }
            return r;
        }
    }

    

}


Compiler output:
a.cc:1:7: error: expected nested-name-specifier before 'System'
    1 | using System;
      |       ^~~~~~
a.cc:2:7: error: expected nested-name-specifier before 'System'
    2 | using System.Collections.Generic;
      |       ^~~~~~
a.cc:3:7: error: expected nested-name-specifier before 'System'
    3 | using System.Linq;
      |       ^~~~~~
a.cc:4:7: error: expected nested-name-specifier before 'System'
    4 | using System.IO;
      |       ^~~~~~
a.cc:5:7: error: expected nested-name-specifier before 'System'
    5 | using System.Text;
      |       ^~~~~~
a.cc:6:7: error: expected nested-name-specifier before 'static'
    6 | using static System.Math;
      |       ^~~~~~
a.cc:7:7: error: expected nested-name-specifier before 'static'
    7 | using static System.Array;
      |       ^~~~~~
a.cc:8:7: error: expected nested-name-specifier before 'static'
    8 | using static AtCoder.Tool;
      |       ^~~~~~
a.cc:16:16: error: 'readonly' does not name a type
   16 |         static readonly int[] dx = { 0, 1, 0, -1 };
      |                ^~~~~~~~
a.cc:17:16: error: 'readonly' does not name a type
   17 |         static readonly int[] dy = { 1, 0, -1, 0 };
      |                ^~~~~~~~
a.cc:19:25: error: 'Tuple' has not been declared
   19 |         static int Comp(Tuple<int, int> t1, Tuple<int, int> t2)
      |                         ^~~~~
a.cc:19:30: error: expected ',' or '...' before '<' token
   19 |         static int Comp(Tuple<int, int> t1, Tuple<int, int> t2)
      |                              ^
a.cc:31:26: error: 'string' has not been declared
   31 |         static void Main(string[] args)
      |                          ^~~~~~
a.cc:31:35: error: expected ',' or '...' before 'args'
   31 |         static void Main(string[] args)
      |                                   ^~~~
a.cc:65:6: error: expected ';' after class definition
   65 |     }
      |      ^
      |      ;
a.cc:14:25: error: expected primary-expression before 'int'
   14 |         const int INF = int.MaxValue / 2;
      |                         ^~~
a.cc:15:27: error: expected primary-expression before 'long'
   15 |         const long SINF = long.MaxValue / 2;
      |                           ^~~~
a.cc: In static member function 'static int AtCoder::AC::Comp(int)':
a.cc:21:17: error: 't1' was not declared in this scope
   21 |             if (t1.Item2 != t2.Item2)
      |                 ^~
a.cc:21:29: error: 't2' was not declared in this scope
   21 |             if (t1.Item2 != t2.Item2)
      |                             ^~
a.cc: In static member function 'static void AtCoder::AC::Main(int*)':
a.cc:35:13: error: 'var' was not declared in this scope
   35 |             var cin = new Scanner();
      |             ^~~
a.cc:37:17: error: expected ';' before 'input'
   37 |             var input = cin.SplitRead();
      |                 ^~~~~
a.cc:38:21: error: 'input' was not declared in this scope; did you mean 'int'?
   38 |             int N = input[0];
      |                     ^~~~~
      |                     int
a.cc:40:13: error: 'List' was not declared in this scope
   40 |             List<Tuple<int, int>> ab = new List<Tuple<int, int>>();
      |             ^~~~
a.cc:40:18: error: 'Tuple' was not declared in this scope
   40 |             List<Tuple<int, int>> ab = new List<Tuple<int, int>>();
      |                  ^~~~~
a.cc:40:24: error: expected primary-expression before 'int'
   40 |             List<Tuple<int, int>> ab = new List<Tuple<int, int>>();
      |                        ^~~
a.cc:41:21: error: expected ';' before 'i'
   41 |             for(var i = 0; i < M; i++)
      |                     ^
a.cc:41:28: error: 'i' was not declared in this scope
   41 |             for(var i = 0; i < M; i++)
      |                            ^
a.cc:43:21: error: expected ';' before 'p'
   43 |                 var p = cin.SplitRead();
      |                     ^
a.cc:44:17: error: 'ab' was not declared in this scope
   44 |                 ab.Add(new Tuple<int, int>(p[0], p[1]));
      |                 ^~
a.cc:44:28: error: 'Tuple' does not name a type
   44 |                 ab.Add(new Tuple<int, int>(p[0], p[1]));
      |                            ^~~~~
a.cc:44:34: error: expected primary-expression before 'int'
   44 |                 ab.Add(new Tuple<int, int>(p[0], p[1]));
      |                                  ^~~
a.cc:44:39: error: expected primary-expression before 'int'
   44 |                 ab.Add(new Tuple<int, int>(p[0], p[1]));
      |                                       ^~~
a.cc:46:13: error: 'ab' was not declared in this scope
   46 |             ab.Sort(Comp);
      |             ^~
a.cc:50:21: error: expected ';' before 'i'
   50 |             for(var i = 0; i < M; i++)
      |                     ^
a.cc:50:28: error: 'i' was not declared in this scope
   50 |             for(var i = 0; i < M; i++)
      |                            ^
a.cc:59:13: error: 'Console' was not declared in this scope
   59 |             Console.WriteLine(ans);
      |             ^~~~~~~
a.cc: At global scope:
a.cc:66:5: error: expected unqualified-id before 'public'
   66 |     public class Scanner
      |     ^~~~~~
a.cc:80:5: error: expected unqualified-id before 'public'
   80 |     public static class Tool
      |     ^~~~~~