criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main() {
  int N,M;
  cin >> N >> M;
  typedef pair<int,int> P;
  vector<P> vec(M);
  for (int i=0; i<M; ++i) {
    cin >> vec.at(i).second >> vec.at(i).first;
  }
  sort(vec);
  int k=1;
  int M = vec.at(0).first
  for (int j=0; j<M; ++j) {
    if (vec.at(j+1).second >= M) {
      ++k;
      M = vec.at(j+1).first;
    }
  }
  cout << k << endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:12:7: error: no matching function for call to 'sort(std::vector<std::pair<int, int> >&)'
   12 |   sort(vec);
      |   ~~~~^~~~~
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algo.h:4762:5: note: candidate: 'template<class _RAIter> void std::sort(_RAIter, _RAIter)'
 4762 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
      |     ^~~~
/usr/include/c++/14/bits/stl_algo.h:4762:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_algo.h:4793:5: note: candidate: 'template<class _RAIter, class _Compare> void std::sort(_RAIter, _RAIter, _Compare)'
 4793 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
      |     ^~~~
/usr/include/c++/14/bits/stl_algo.h:4793:5: note:   candidate expects 3 arguments, 1 provided
In file included from /usr/include/c++/14/algorithm:86:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:292:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator, class _Compare> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _Compare)'
  292 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:292:1: note:   candidate expects 4 arguments, 1 provided
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator)'
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note:   candidate expects 3 arguments, 1 provided
a.cc:14:7: error: redeclaration of 'int M'
   14 |   int M = vec.at(0).first
      |       ^
a.cc:5:9: note: 'int M' previously declared here
    5 |   int N,M;
      |         ^
a.cc:15:17: error: 'j' was not declared in this scope
   15 |   for (int j=0; j<M; ++j) {
      |                 ^
Language: C++

#include  <iostream>
#include  <vector>
#include  <algorithm>
using namespace std;

typedef pair<int, int> time;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)

int main()
{
	int n, m;
	cin >> n >> m;
	vector<time> t(m);
	rep(i, m)  cin >> t[i].second >> t[i].first;
	sort(t.begin(), t.end());

	int ans = 0;
	ll tsum = 1;
	rep(i, m) {
		if (tsum <= t[i].second) {
			ans++;
			tsum = t[i].first;
		}
	}
	cout << ans << endl;
}

Compiler output:
a.cc:6:24: error: 'typedef struct std::pair<int, int> time' redeclared as different kind of entity
    6 | typedef pair<int, int> time;
      |                        ^~~~
In file included from /usr/include/pthread.h:23,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157,
                 from /usr/include/c++/14/ext/atomicity.h:35,
                 from /usr/include/c++/14/bits/ios_base.h:39,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/time.h:76:15: note: previous declaration 'time_t time(time_t*)'
   76 | extern time_t time (time_t *__timer) __THROW;
      |               ^~~~
a.cc: In function 'int main()':
a.cc:14:20: error: type/value mismatch at argument 1 in template parameter list for 'template<class _Tp, class _Alloc> class std::vector'
   14 |         vector<time> t(m);
      |                    ^
a.cc:14:20: note:   expected a type, got 'time'
a.cc:14:20: error: template argument 2 is invalid
a.cc:15:28: error: invalid types 'int[int]' for array subscript
   15 |         rep(i, m)  cin >> t[i].second >> t[i].first;
      |                            ^
a.cc:15:43: error: invalid types 'int[int]' for array subscript
   15 |         rep(i, m)  cin >> t[i].second >> t[i].first;
      |                                           ^
a.cc:16:16: error: request for member 'begin' in 't', which is of non-class type 'int'
   16 |         sort(t.begin(), t.end());
      |                ^~~~~
a.cc:16:27: error: request for member 'end' in 't', which is of non-class type 'int'
   16 |         sort(t.begin(), t.end());
      |                           ^~~
a.cc:21:30: error: invalid types 'int[int]' for array subscript
   21 |                 if (tsum <= t[i].second) {
      |                              ^
a.cc:23:33: error: invalid types 'int[int]' for array subscript
   23 |                         tsum = t[i].first;
      |                                 ^
Language: C++

#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  
  int n,m;
  cin>>n>>m;
  int a[m],b[m];
  vector<pair<int,int>> ba(m);
  REP(i,m){
    cin>>a[i]>>b[i];
    ba.push_back(make_pair(b[i],a[i]));
  }
  sort(ba.begin(),ba.end());
  
  REP(i,m){
    a[i] = ba[i].second;
    b[i] = ba[i].first;
  }
  
  int ans=0;
  int point;
  REP(i,m){
    if(i==0){
      ans++;
      point = b[i];
    }else{
      if(a[i]<=l && l<=b[i])continue;
      ans++;
      l = b[i];
    }
  }
  
  cout<<ans<<endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:113:16: error: 'l' was not declared in this scope
  113 |       if(a[i]<=l && l<=b[i])continue;
      |                ^
a.cc:115:7: error: 'l' was not declared in this scope
  115 |       l = b[i];
      |       ^
Language: C

#include <iostream>
#include <algorithm>
using namespace std;
int a[10005];
int b[10005];
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++)
        cin>>a[i]>>b[i];
    sort(b,b+m);
    int z=b[0];
    int t=1;
    int j=0;
    for(int i=0;i<m;i++)
    {
        if(a[i]>=z)
        {
            t++;
            while(a[i]==b[j]&&j<m)
            {
                j++;
            }
            z=b[j];
        }
    }
    cout<<t<<endl;
}


Compiler output:
main.c:1:10: fatal error: iostream: No such file or directory
    1 | #include <iostream>
      |          ^~~~~~~~~~
compilation terminated.
Language: C++

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
struct node
{
    int l,r;
} a[100000+20];
bool cmp(node a,node b)
{
    if(a.r==b.r)		return a.l<b.l;
    return a.r<b.r;
}
int main ()
{
    int n,m,i;
    scanf("%d%d",&n,&m);
    for(i=0; i<m; i++)		scanf("%d %d",&a[i].l,&a[i].r);
    int mn=a[0].r;
    for(i=0; i<m; i++)		mn=min(a[i].r,mn);
    sort(a,a+m,cmp);
    int now=mn,h=1;
    for(i=1; i<m; i++)
    {
        if(a[i].l>=now)
        {

            now=a[i].r;
            ans++;
        }
    }
    printf("%d\n",h);
    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:31:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   31 |             ans++;
      |             ^~~
      |             abs
Language: C++

#include<iostream>
#include<algorithm>
#include<cstdio>
#define maxn 100005
using namespace std;


int a[100000 + 100];
int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	int minx = 0;
	memset(a, 0, sizeof(a));
	for (int i = 1;i <= m;i++)
	{
		int x, y;
		scanf("%d%d", &x, &y);
		if (minx == 0)
			minx = x;
		if (minx > x)
			minx = x;
		int min = a[x];
		if (min == 0)
			a[x] = y;
		else if (min > y)
			a[x] = y;
	}
	int flag = 1;
	int k = a[minx];
	for (int i = 1;i <= n;i++)
	{
		if (a[i] == 0)
			continue;
		if (i >= k)
		{
			flag++;
			k = a[i];
		}
		else if (k > a[i])
			k = a[i];
	}
	printf("%d\n", flag);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:9: error: 'memset' was not declared in this scope
   14 |         memset(a, 0, sizeof(a));
      |         ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include<cstdio>
  +++ |+#include <cstring>
    4 | #define maxn 100005
Language: Java

import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int m=sc.nextInt();
    int[][] nums1=new int[m][3],nums2=new int[m][3];
    for(int i=0;i<m;i++){
      nums1[i][0]=nums2[i][0]=sc.nextInt();
      nums1[i][1]=nums2[i][1]=sc.nextInt();
      nums1[i][2]=nums2[i][2]=i;
    }
    boolean[] done=new boolean[m];
    };
    
  }
}

Compiler output:
Main.java:17: error: class, interface, enum, or record expected
}
^
1 error
Language: C++

#include<bits/stdc++.h>
#include<utility>
using namespace std;
int main () {
  int N, M;
  cin >> N >> M;
  vector<pair<int, int>>dem(M);
  for (int i = 0; i < M; i ++) {
    int a, b;
    cin >> a >> b;
    if (a < b) swap(a, b);
    dem[i] = make_pair(a, b);
  }
  sort(dem.begin(), dem.end());
  int ans = 1;
  int j = dem[0].first - 1;
  for (int i = 0; i < M; i ++) {
    if (j < dem[i].second) {
      j = dem[i].firsr - 1;
      ans ++;
    }
  }
  cout << ans << endl;
}
  

Compiler output:
a.cc: In function 'int main()':
a.cc:19:18: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'firsr'; did you mean 'first'?
   19 |       j = dem[i].firsr - 1;
      |                  ^~~~~
      |                  first
Language: Java


import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		Map<Integer, Integer> bri = new HashMap<>();
		for(int i = 0; i < m; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			if(bri.containsKey(a)) {
				int val = bri.get(a);
				bri.put(a, Math.min(val, b));
			} else {
				bri.put(a, b);
			}
		}
		int ans = 0;
		while(!bri.isEmpty()) {
			int b = (int) Math.pow(10, 5);
			for(Map.Entry<Integer, Integer> e : bri.entrySet()) {
				if(e.getValue() < b) {
					b = e.getValue();
			}
			ans++;
			for(int i = 1; i < b + 1; i++) {
				if(bri.containsKey(i)) {
					bri.remove(i);
				}
			}
		}
		System.out.println(ans);
	}

}


Compiler output:
Main.java:40: error: reached end of file while parsing
}
 ^
1 error
Language: C++

#include <iostream>
#include <vector>

using namespace std;
typedef pair<int, int> P;
vector<P> v;

int main() {

    int N, M; cin >> N >> M;
    int a, b;
    for (int i = 0; i < M; i++) {
        cin >> a >> b;
        //if (a == a_before) continue;
        v.push_back(make_pair(b, a));
    }

    sort(v.begin(), v.end(), greater<P>());

    int ans = 0;
    int l = 1000000;
    for (int i = 0; i < v.size(); i++) {
        if (l >= v[i].first) {
            ans++;
            l = v[i].second;
        }
    }

    cout << ans << '\n';
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   18 |     sort(v.begin(), v.end(), greater<P>());
      |     ^~~~
      |     short
Language: C++

#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

int main(){
int N,M; cin >> N >> M;
  vector<pair<int,int>> AB(M);
  for(int i = 0; i < N; i++){ cin >> AB[i].first >> AB[i].second;}
  
  sort(AB.begin(),AB.end());
  
   int tail = AB[0].second - 1; int cnt = 1;
  
  for(int i = 0; i < M; i++){
    if( AB[i].first <= tail){ tail = AB[i].second - 1;}
    else{ tail = AB[i].second - 1; cnt++;}}
  

Compiler output:
a.cc: In function 'int main()':
a.cc:19:44: error: expected '}' at end of input
   19 |     else{ tail = AB[i].second - 1; cnt++;}}
      |                                            ^
a.cc:8:11: note: to match this '{'
    8 | int main(){
      |           ^
Language: C++

#include <iostream>
#include <vector>
#include <utility>

using namespace std;

// 島のindexは0はじまり
int N, M; //  島数N、要望数M
vector< pair<int, int> > request;
vector<bool> bridge; // bridge[i] = iとi+1を橋がつないでいるか

int dfs(int i) {
  // 返り値: 最大の辺の本数
  // 島iと島i+1をつなげるかどうか考える
  if (i + 1 == N)
    return 0;

  bridge[i] = true;
  vector< pair<int, int> >::iterator end = upper_bound(request.begin(), request.end(), (i, -INF)); // aがiより大きくなる最小の(a, b)
  for (vector< pair<int, int> >::iterator it = request.begin(); it != end; ++it) {
    int a = (*it).first, b = (*it).second;
    // if (!(a <= i))
    //   continue;
    if (i + 1 > b)
      continue;
    bool can_reach = true;
    for (; a + 1 <= b; ++a) {
      // aからbまでで橋がない箇所が一箇所でもいいからあるかどうか
      if (bridge[a] == true)
        continue;
      can_reach = false;
      break;
    }
    if (can_reach) {
      bridge[i] = false;
      return dfs(i + 1);
    }
  }
  return 1 + dfs(i + 1);
}
int main() {
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    request.push_back(pair<int, int>(a - 1, b - 1)); // 0始まりにする
  }
  for (int i = 0; i + 1 < N; i++)
    bridge.push_back(false);
  cout << (N - 1) - dfs(0) << endl;
}


Compiler output:
a.cc: In function 'int dfs(int)':
a.cc:19:93: error: 'INF' was not declared in this scope
   19 |   vector< pair<int, int> >::iterator end = upper_bound(request.begin(), request.end(), (i, -INF)); // aがiより大きくなる最小の(a, b)
      |                                                                                             ^~~
a.cc:19:44: error: 'upper_bound' was not declared in this scope
   19 |   vector< pair<int, int> >::iterator end = upper_bound(request.begin(), request.end(), (i, -INF)); // aがiより大きくなる最小の(a, b)
      |                                            ^~~~~~~~~~~
Language: C++

# coding: utf-8
# Your code here!

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

bridge = [list(map(int,input().split(' '))) for i in range(m)]

bridge = sorted(bridge,key=lambda x:x[1])
# print(bridge)

index=0
ans=0
for i in range(m):
    if index <= bridge[i][0]:
        index = bridge[i][1]
        ans += 1
print(ans)

Compiler output:
a.cc:1:3: error: invalid preprocessing directive #coding
    1 | # coding: utf-8
      |   ^~~~~~
a.cc:2:3: error: invalid preprocessing directive #Your
    2 | # Your code here!
      |   ^~~~
a.cc:9:3: error: invalid preprocessing directive #print
    9 | # print(bridge)
      |   ^~~~~
a.cc:4:1: error: 'n' does not name a type
    4 | n,m = map(int,input().split(' '))
      | ^
Language: C++

#include<iostream>
#include<vector>
#include<utility>
#include<set>
using namespace std;

typedef pair<int,int> P;
int main(){
  int n,m; cin>>n>>m;
  vector<P> v;
  for(int i=0; i<m; ++i){
    int a,b; cin>>a>>b;
    v.push_back(P(b-1,a-1));
  }
  sort(v.begin(), v.end());
  set<int> remove_bridge;
  int ret=0;
  for(int i=0; i<m; i++){
    bool meet_needs =false;
    for(set<int>::iterator it=remove_bridge.begin(); it != remove_bridge.end(); ++it){
      if( *it >= v[i].second && *it+1 <= v[i].first){
        meet_needs = true; break;
      }
    }
    if( meet_needs) continue;
    else{
      remove_bridge.insert(v[i].first-1);
      ++ret;
    }
  }
  cout<<ret<<endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   15 |   sort(v.begin(), v.end());
      |   ^~~~
      |   short
Language: C++

//https://atcoder.jp/contests/abc103/tasks/abc103_d
//例題2-2-2 区間スケジューリング問題 https://qiita.com/drken/items/e77685614f3c6bf86f44
#include<iostream>
#include<vector>
#include<utility>
#include<set>
using namespace std;

typedef pair<int,int> P;
int main(){
  int n,m; cin>>n>>m;
  vector<P> v;
  for(int i=0; i<m; ++i){
    int a,b; cin>>a>>b;
    v.push_back(P(b-1,a-1));
  }
  sort(v.begin(), v.end());
  set<int> remove_bridge;
  int ret=0;
  for(int i=0; i<m; i++){
    bool meet_needs =false;
    for(set<int>::iterator it=remove_bridge.begin(); it != remove_bridge.end(); ++it){
      if( *it >= v[i].second && *it+1 <= v[i].first){
        meet_needs = true; break;
      }
    }
    if( meet_needs) continue;
    else{
      remove_bridge.insert(v[i].first-1);
      ++ret;
    }
  }
  cout<<ret<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   17 |   sort(v.begin(), v.end());
      |   ^~~~
      |   short
Language: C++

#include <bits/stdc++.h>
using namespace std;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
  int N, M; cin >> N >> M;
  int ab[M][2];
  bool connected[M];
  
  for (int i=0;i<M;i++) connected[j] = false;
  int ans = 0;
  for (int i=1;i<N;i++) {
    UnionFind tree1(i);
    UnionFind tree2(N);
    
    for (int j=0;j<M;j++) {
      if (same(ab[j][0], ab[j][1])) connected[j] = true;
    }
    if (count(connected.begin(), connected.end(), true) <= 0) ans++;
  }
  cout << ans << endl;
}
    
    
  

Compiler output:
a.cc: In function 'int main()':
a.cc:35:35: error: 'j' was not declared in this scope
   35 |   for (int i=0;i<M;i++) connected[j] = false;
      |                                   ^
a.cc:42:11: error: 'same' was not declared in this scope
   42 |       if (same(ab[j][0], ab[j][1])) connected[j] = true;
      |           ^~~~
a.cc:44:25: error: request for member 'begin' in 'connected', which is of non-class type 'bool [M]'
   44 |     if (count(connected.begin(), connected.end(), true) <= 0) ans++;
      |                         ^~~~~
a.cc:44:44: error: request for member 'end' in 'connected', which is of non-class type 'bool [M]'
   44 |     if (count(connected.begin(), connected.end(), true) <= 0) ans++;
      |                                            ^~~
Language: C++

#include <iostream>
#include <string>
#include <vector>

using namespace std;

// intのpairの型を定義しておく
typedef pair<int, int> P;

// 昇順sort時に使う比較関数, 配列から2つのpair要素を取り出して、secondの値を比較する
bool pairCompare(const P& firstElof, const P& secondElof){
    return firstElof.second < secondElof.second;
}

int main() {
    int N, M;
    cin >> N >> M;

    vector<P> vec(M);

    int a,b;
    for(int i=0; i < M; i++) {
        cin >> a >> b;
        vec[i].first = a;
        vec[i].second = b;
    }

    // 昇順ソート
    sort(vec.begin(), vec.end(), pairCompare);
    
    int ans = 0;
    int tmp = 0;
    for(int i=0; i < M; i++) {
        if(tmp < vec[i].first) {
            ans++;
            tmp = vec[i].second - 1;
        }
    }

    cout << ans << endl;
    
    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:29:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   29 |     sort(vec.begin(), vec.end(), pairCompare);
      |     ^~~~
      |     short
Language: C++

#include <bits/stdc++.h>
using namespace std;

vector<pair<int, int>> a[100000]; 

bool pairCompare (pair<int, int> a, pair<int, int> b) {
  if (a.second!=b.second) return a.second>b.second;
  else return a.first>b.first;
}

int main() {
  int N, M, ans=0, s; cin >>  N >> M;
//  a = vector<pair<int, int>>(M);
  for (int i=0; i<M; i++) cin >> a[i].first >>a[i].second;
  sort(a.begin(),a.begin()+M,pairCompare); 
  s=N+1;
  for (int i=0; i<M; i++){
    if(a[i].second<s) {
      ans++;
      s=a[i].first+1;
    }
  }
  cout << ans << "\n";  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:39: error: 'class std::vector<std::pair<int, int> >' has no member named 'first'
   14 |   for (int i=0; i<M; i++) cin >> a[i].first >>a[i].second;
      |                                       ^~~~~
a.cc:14:52: error: 'class std::vector<std::pair<int, int> >' has no member named 'second'
   14 |   for (int i=0; i<M; i++) cin >> a[i].first >>a[i].second;
      |                                                    ^~~~~~
a.cc:15:10: error: request for member 'begin' in 'a', which is of non-class type 'std::vector<std::pair<int, int> > [100000]'
   15 |   sort(a.begin(),a.begin()+M,pairCompare);
      |          ^~~~~
a.cc:15:20: error: request for member 'begin' in 'a', which is of non-class type 'std::vector<std::pair<int, int> > [100000]'
   15 |   sort(a.begin(),a.begin()+M,pairCompare);
      |                    ^~~~~
a.cc:18:13: error: 'class std::vector<std::pair<int, int> >' has no member named 'second'
   18 |     if(a[i].second<s) {
      |             ^~~~~~
a.cc:20:14: error: 'class std::vector<std::pair<int, int> >' has no member named 'first'
   20 |       s=a[i].first+1;
      |              ^~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long ll;
#define MOD 1000000007

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline T gcd(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T lcm(T a,T b){return a*b/gcd(a,b);}


int main(){
  int n,m;
  cin >> n >> m;
  int a,b;
  pair<int ,int> v[1000000];
  FOR(i,m){
    cin >> a >> b;
    v[i]=make_pair(b,a);
  }
    sort(v,v+m);
    int maxi=-1;
    int ans=0;
    FOR(i,m){
      if(v[i].second>maxi){maxi = v[i].first-1;ans++;}
    }

    cout << ans << endl;

  }









}


Compiler output:
a.cc:41:1: error: expected declaration before '}' token
   41 | }
      | ^
Language: C++

#include <iostream>
#include <vector>
#define Pair pair<int,int>
using namespace std;

const int inf = 1e6;


int N,M;
vector<Pair> ba;


void solve(){
	int ans=0;
	int cur=0;
	sort(ba.begin(),ba.end());
	for(int i=0;i<M;i++){
		if(cur <= ba[i].second){
			cur = ba[i].first;
			ans++;
		}
	}

	cout << ans << endl;

}

int main(){
	cin >> N >> M;
	int a,b;
	ba.resize(M);

	for(int i=0;i<M;i++){
		cin >> a >> b;
		ba[i] = {b,a};
	}
	solve();
	return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:16:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   16 |         sort(ba.begin(),ba.end());
      |         ^~~~
      |         short
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    int N,M,maxc=0,g=0,ans\^^
    cin >> N >> M;
    vector<pair<int,int>> v(M);
    for(int i=0;i < M;i++){
        cin >> v.at(i).second >> v.at(i).first;
        
    }//input 橋の左端と右端

    sort(v.begin(),v.end());//終点でソートした

    while(v.size() != 0){
        for(int i=1;i < v.size();i++){
            if(v.at(0).first > v.at(i).second){
                v.erase(v.begin()+i);//eraseで添え字がずれるの注意,
                //添え字の書き方も注意
                i--;
            }
        }
        v.erase(v.begin()+0);
        ans++;
    }
    cout << ans << endl;
}

Compiler output:
a.cc:5:27: error: stray '\' in program
    5 |     int N,M,maxc=0,g=0,ans\^^
      |                           ^
a.cc: In function 'int main()':
a.cc:5:28: error: expected initializer before '^' token
    5 |     int N,M,maxc=0,g=0,ans\^^
      |                            ^
a.cc:24:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   24 |         ans++;
      |         ^~~
      |         abs
a.cc:26:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   26 |     cout << ans << endl;
      |             ^~~
      |             abs
Language: C++

#include <iostream>
#include <map>
#include <vector>
using namespace std;

int main(){
  int n,m,count=0;
  cin >> n >> m;
  bool reached[n+1];
  vector< pair<int,int> > mp(m);
  for(int i=0;i<m;i++)cin >> mp.at(i).second >> mp.at(i).first;
  sort(mp.begin(),mp.end());
  for(int i=0;i<n+1;i++)reached[i]=false;
  for(int i=0;i<m;i++){
    int a=mp.at(i).second,b=mp.at(i).first;
    for(int j=a;j<b;j++){
      if(reached[j]==true)break;
      reached[j]=true;
      if(j==b-1)count++;
    }
  }
  cout << count << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   12 |   sort(mp.begin(),mp.end());
      |   ^~~~
      |   short
Language: C++

#include<stdio.h>


int main(){
  
 int n,m;
 int a[100000];
 int b[100000];
 scanf("%d%d",&n,&m);
 for(int i=0;i<m;i++)
   scanf("%d%d",&a[i],&b[i]);
 s = new int[n-1];
 e = new int[n-1];
 memset(&s[0],0x00,sizeof(s));
 memset(&e[0],0x00,sizeof(e));
  
 for(int i=0;i<m;i++){
    for(int j=0;s[j]!=0;j++)
    {
      if (i==0){s[j]=a[i],e[j]=b[i];}
      else{
      int flag=0;
      if (a[i]>=s[j] && a[i]<e[j])s[j]=a[i],flag=1;
      if (b[i]<=e[j] && b[i]>s[j])e[j]=b[i],flag=1;
      if(flag==1)break;
      }
    }
 }
  int cnt=0;
  for(int j=0;s[j]!=0;j++)
    cnt++;
  printf("%d\n",cnt);
  delete [] s;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:2: error: 's' was not declared in this scope
   12 |  s = new int[n-1];
      |  ^
a.cc:13:2: error: 'e' was not declared in this scope
   13 |  e = new int[n-1];
      |  ^
a.cc:14:2: error: 'memset' was not declared in this scope
   14 |  memset(&s[0],0x00,sizeof(s));
      |  ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include<stdio.h>
  +++ |+#include <cstring>
    2 | 
a.cc:33:3: error: type '<type error>' argument given to 'delete', expected pointer
   33 |   delete [] s;
      |   ^~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> p_int;
typedef pair<ll,ll> p_ll;
typedef tuple<ll,ll,ll> t3_ll;
int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1};
int prime[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
const ll inf = 1e9+7;

int main() {
	ll ans=0;
	int a,b;cin>>a>>b;
	pair<int,int> x[b];
	for(int i=0;i<b;i++){
		cin>>x[i].second>>x[i].first;
	}
	sort(x,x+b);
	int end=0;
	for(int i=0;i<b;i++){
		if(x[i].second>=end){
			ans++;
			end=ans.first;
		}
	}
	cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:33: error: request for member 'first' in 'ans', which is of non-class type 'll' {aka 'long long int'}
   24 |                         end=ans.first;
      |                                 ^~~~~
Language: C++

#include <iostream>
#include <vector>
#include <numeric>
#define MOD (1000000007l)

using namespace std;

long N, M;
vector<pair<long, long> > requests;

bool compair(pair<long, long> &i, pair<long, long> &j) {
  return i.second < j.second;
}

int main(void) {
  cin >> N >> M;
  for (long i = 0; i < M; i++) {
    long a, b;
    cin >> a >> b;
    requests.push_back(pair<long, long>(a, b));
  }
  sort(requests.begin(), requests.end(), compair);
  long last_removed = 0;
  long ans = 0;
  for (auto r: requests) {
    if (r.first < last_removed) continue;
    last_removed = r.second;
    ans++;
  }
  cout << ans << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   22 |   sort(requests.begin(), requests.end(), compair);
      |   ^~~~
      |   short
Language: C++

#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>

using namespace std;

int main(void){

  int n,m;
  cin >> n;
  cin >> m;

  vector<int> a(m);
  vector<int> b(m);
  vector<pair<int,int> > c(m,make_pair(0,0));
  vector<int> d(m,1);

  for(int i=0;i<m;i++){
    cin>>a[i];
    cin>>b[i];
    c[i] = make_pair(b[i],a[i]);
  }

  sort(c.begin(),c.end() );
  for(int i=0;i<m;i++){
    //cout << c[i].first << "," << c[i].second << endl;
  }
  //cout << endl;
  for(int i=0;i<m;i++){
    if(d[i]){
      for(int j=i+1;j<m;j++){
        if(c[j].second < c[i].first ){
          d[j]=0;
        }
      }
    }
  }
  for(int i=0;i<m;i++){
    //cout << d[i] << endl;
  }
  cout << accumulate(d.begin(),d.end(),0) << endl;


  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:45:11: error: 'accumulate' was not declared in this scope
   45 |   cout << accumulate(d.begin(),d.end(),0) << endl;
      |           ^~~~~~~~~~
Language: C++

// Template
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>

using namespace std;
const int MOD = 1000000007;

#define v_exists(elem, v) find(v.begin(),v.end(),elem)!=v.end()
#define s_exists(elem, s) s.find(elem)!=s.end()
#define mod_mul(x, y) x*y%MOD
#define mod_add(x, y) (x+y)%MOD
#define mod_sub(x, y) (x-y)%MOD

long gcd(long a, long b) {
    return b == 0 ? a : gcd(b, a % b);
}

long lcm( long m, long n ){
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;

    return ((m / gcd(m, n)) * n);
}


long nCr(long n, long r){
    if(n==r || r==0){
        return 1;
    } else {
        return mod_add(nCr(n-1,r),nCr(n-1,r-1));
    }
}

std::vector<pair<int, int>> v;

int main(){
    int N,M; cin >> N >> M;
    for (int i = 0; i < M; ++i){
        int a,b; cin >> a >> b;
        v.push_back(make_pair(a-1, b-1));
    }

    sort(v.begin(),v.end());


    int left = v[0].first;
    int right = v[0].second;
    int cnt = 0;
    for(int i=1; i<v.size(); i++){
        if(right <= v[i].first){
            cnt ++;
            left = v[i].first; right = v[i].second;
        } else {
            left = max(v[i].first, left);
            right = min(v[i].second, right);
        }
    }

    cout << cnt+1 << endl;


    return 0;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:50:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   50 |     sort(v.begin(),v.end());
      |     ^~~~
      |     short
Language: C

#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

int main()
{
  int N, M;
  vector<pair<int, int> > v;

  cin >> N >> M;
  for(int i = 0; i < M; i++){
    int a, b;
    cin >> a >> b;
    v.push_back(make_pair(b, a));
  }

  sort(v.begin(), v.end());

  int x = 0, ans = 0;
  for(int i = 0; i < M; i++){
    if(v[i].second >= x){
      x = v[i].first;
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}

Compiler output:
main.c:1:10: fatal error: iostream: No such file or directory
    1 | #include <iostream>
      |          ^~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

#define REP(var,n) for(int var=0;var<(n);var++)
#define REPP(var,n) for(int var=1;var<(n);var++)
#define ALL(c) (c).begin(),(c).end()
#define PRIN(var) cout << "---------------------" << var << "------------------------------" << endl;


int main(){
    int N,M;
    vector<P> ab;
    //N: the number of island
    //M: the number of bulidge
    cin >> N >> M;
    
    REP(i,M){
        int a,b;
        cin >> a >> b;
        ab.push_back(make_pair(b,a)); 
    }
    sort(ab.begin(), ab.end());

    int ans=0, t=0;

    REP(i,ab.size()){
        if(t<=ab[i].second){
            t = ab[i].first;
            ans++
        }
    }
    cout << ans << endl; 
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:18: error: expected ';' before '}' token
   35 |             ans++
      |                  ^
      |                  ;
   36 |         }
      |         ~
Language: C++

 #include <iostream>
  2 #include <algorithm>
  3 #include <vector>
  4 #include <string>
  5 #include <map>
  6 #include <math.h>
  7
  8 using namespace std;
  9
 10 int main()
 11 {
 12         int n, m;
 13         cin >> n >> m;
 14         vector<pair<int, int>> queries(m);
 15         for(int i = 0; i < m; i++)
 16         {
 17                 int a, b;
 18                 cin >> a >> b;
 19                 queries[i] = {a - 1, b - 1};
 20         }
 21
 22         sort(queries.begin(), queries.end());
 23
 24         pair<int, int> segment = queries[0];
 25         int count = 0;
 26         for(int i = 1; i < m; i++)
 27         {
 28                 if(queries[i].first <

Compiler output:
a.cc:2:5: error: stray '#' in program
    2 |   2 #include <algorithm>
      |     ^
a.cc:3:5: error: stray '#' in program
    3 |   3 #include <vector>
      |     ^
a.cc:4:5: error: stray '#' in program
    4 |   4 #include <string>
      |     ^
a.cc:5:5: error: stray '#' in program
    5 |   5 #include <map>
      |     ^
a.cc:6:5: error: stray '#' in program
    6 |   6 #include <math.h>
      |     ^
a.cc:2:3: error: expected unqualified-id before numeric constant
    2 |   2 #include <algorithm>
      |   ^
a.cc:9:3: error: expected unqualified-id before numeric constant
    9 |   9
      |   ^
Language: C++

//
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define speed ios::sync_with_stdio(false)
using namespace std;

string gs(char x){
    string s(1,x);
    return s;
}

bool comp(pair<ll,ll> a,pair<ll,ll> b)
{
	return a.second<b.second;
}

int main()
{
	speed;
	
	ll n,m;
	cin>>n>>m;
	vector<pair<ll,ll> > v;
	for(ll i=0;i<m;i++)
	{
		cin>>a>>b;
		v.pb(mp(a,b));

	}
	sort(v.begin(),v.end(),comp);
	ll ans=0;
	ll temp=0;
	for(ll i=0;i<m;i++){
		if(v[i].first<temp)
			continue;
		ans++;
		temp=v[i].second;
	}
	cout<<ans;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:22: error: 'a' was not declared in this scope
   28 |                 cin>>a>>b;
      |                      ^
a.cc:28:25: error: 'b' was not declared in this scope
   28 |                 cin>>a>>b;
      |                         ^
Language: Java

import java.util.*;
public class Main{
    public static void main(String[] args) {
        new Main().run();
    }

    void run() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();

        Pair[] pairs = new Pair[m];
        for(int i = 0;i < M;i++){
            Pair ps = new Pair();
            ps.from = sc.nextInt();
            ps.end = sc.nextInt();
            pairs[i] = ps;
        }
        Arrays.sort(pairs);
        int cnt = 0;
        int nowclear = 0;
        for(int i = 0; i<M; i++){
            int nowfrom = pairs[i].from;
            int nowend = pairs[i].end;
            if(nowclear < nowend){
                cnt++;
                nowclear = pairs[i].end - 1;
            }
        }
        System.out.println(cnt);
    }
}

class Pair implements Comparable{
    int from;
    int end;
    public int compareTo(Object other){
        Pair otherpair = (Pair) other;
        return end - otherpair.end;
    }
}

Compiler output:
Main.java:12: error: cannot find symbol
        Pair[] pairs = new Pair[m];
                                ^
  symbol:   variable m
  location: class Main
1 error
Language: Java

import java.util.*;
public class Main{
    public static void main(String[] args) {
        new Main().run();
    }

    void run() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();

        Pair[] pairs = new Pair[m];
        for(int i = 0;i < M;i++){
            Pair ps = new Pair();
            ps.from = sc.nextInt();
            ps.end = sc.nextInt();
            pairs[i] = ps;
        }
        Arrays.sort(pairs);
        int cnt = 0;
        int nowclear = 0;
        for(i = 0; i<M; i++){
            int nowfrom = pairs[i].from;
            int nowend = pairs[i].end;
            if(nowclear < nowend){
                cnt++;
                nowclear = pairs[i].end - 1;
            }
        }
        System.out.println(cnt);
    }
}

class Pair implements Comparable{
    int from;
    int end;
    public int compareTo(Object other){
        Pair otherpair = (Pair) other;
        return end - otherpair.end;
    }
}

Compiler output:
Main.java:12: error: cannot find symbol
        Pair[] pairs = new Pair[m];
                                ^
  symbol:   variable m
  location: class Main
Main.java:22: error: cannot find symbol
        for(i = 0; i<M; i++){
            ^
  symbol:   variable i
  location: class Main
Main.java:22: error: cannot find symbol
        for(i = 0; i<M; i++){
                   ^
  symbol:   variable i
  location: class Main
Main.java:22: error: cannot find symbol
        for(i = 0; i<M; i++){
                        ^
  symbol:   variable i
  location: class Main
Main.java:23: error: cannot find symbol
            int nowfrom = pairs[i].from;
                                ^
  symbol:   variable i
  location: class Main
Main.java:24: error: cannot find symbol
            int nowend = pairs[i].end;
                               ^
  symbol:   variable i
  location: class Main
Main.java:27: error: cannot find symbol
                nowclear = pairs[i].end - 1;
                                 ^
  symbol:   variable i
  location: class Main
7 errors
Language: Java

import java.util.*;
public class D103{
    public static void main(String[] args) {
        new Main().run();
    }

    void run() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();

        Pair[] pairs = new Pair[m];
        for(int i = 0;i < M;i++){
            Pair ps = new Pair();
            ps.from = sc.nextInt();
            ps.end = sc.nextInt();
            pairs[i] = ps;
        }
        Arrays.sort(pairs);
        int cnt = 0;
        int nowclear = 0;
        for(i = 0; i<M; i++){
            int nowfrom = pairs[i].from;
            int nowend = pairs[i].end;
            if(nowclear < nowend){
                cnt++;
                nowclear = pairs[i].end - 1;
            }
        }
        System.out.println(cnt);
    }
}

class Pair implements Comparable{
    int from;
    int end;
    public int compareTo(Object other){
        Pair otherpair = (Pair) other;
        return end - otherpair.end;
    }
}

Compiler output:
Main.java:2: error: class D103 is public, should be declared in a file named D103.java
public class D103{
       ^
Main.java:34: error: duplicate class: Pair
class Pair implements Comparable{
^
Main.java:4: error: cannot access Main
        new Main().run();
            ^
  bad source file: ./Main.java
    file does not contain class Main
    Please remove or make sure it appears in the correct subdirectory of the sourcepath.
Main.java:12: error: cannot find symbol
        Pair[] pairs = new Pair[m];
                                ^
  symbol:   variable m
  location: class D103
Main.java:22: error: cannot find symbol
        for(i = 0; i<M; i++){
            ^
  symbol:   variable i
  location: class D103
Main.java:22: error: cannot find symbol
        for(i = 0; i<M; i++){
                   ^
  symbol:   variable i
  location: class D103
Main.java:22: error: cannot find symbol
        for(i = 0; i<M; i++){
                        ^
  symbol:   variable i
  location: class D103
Main.java:23: error: cannot find symbol
            int nowfrom = pairs[i].from;
                                ^
  symbol:   variable i
  location: class D103
Main.java:24: error: cannot find symbol
            int nowend = pairs[i].end;
                               ^
  symbol:   variable i
  location: class D103
Main.java:27: error: cannot find symbol
                nowclear = pairs[i].end - 1;
                                 ^
  symbol:   variable i
  location: class D103
10 errors
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()
#define INF 1<<28

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int MAX_N = (int)1e5 + 5;
const int MAX_M = (int)1e5 + 5;

bool bridge[MAX_N - 1];
int a[MAX_M], b[MAX_M];

class UNION_FIND{
public:
	vector<int> a;
	UNION_FIND(int n){
		a.clear();
		a.resize(n, -1);
	}

	~UNION_FIND(){
		a.clear();
	}

	int find(int x){
		if (a[x] < 0){
			return x;
		}else{
			return (a[x] = find(a[x]));
		} // end if
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if (x != y){
			a[x] += a[y];
			a[y] = x;
		} // end if
	}

	bool same(int x, int y){
		return find(x) == find(y);
	}

	int size(int x){
		return -a[find(x)];
	} // end if
};

struct segtree{
	int SIZE;
	vector<int> minimum, lazy;

	segtree(int _SIZE):SIZE(_SIZE){
		minimum.clear();
		minimum.resize(SIZE * 2, 0);
		lazy.clear();
		lazy.resize(SIZE * 2, 0);
	};

	void lazy_evaluate(int k){
		minimum[k] += lazy[k];

		if (k < SIZE - 1){ // k isn't leaf of SegmentTree
			lazy[k * 2 + 1] += lazy[k];
			lazy[k * 2 + 2] += lazy[k];
		} // end if
		lazy[k] = 0;
	} // end function

	void update(int a, int b, int k, int l, int r, int x){
		if (r <= a || b <= l) return;

		if (a <= l && r <= b){
			lazy[k] += x;
			lazy_evaluate(k);
		}else{
			lazy_evaluate(k);
			update(a, b, k * 2 + 1, l, (l + r) / 2, x);
			update(a, b, k * 2 + 2, (l + r) / 2, r, x);
			minimum[k] = min(minimum[k * 2 + 1], minimum[k * 2 + 2]);
			return;
		} // end if
	} // end function 

	int query(int a, int b, int k, int l, int r){
		lazy_evaluate(k);
		if (r <= a || b <= l) return INF;
		if (a <= l && r <= b) return minimum[k];
		else{
			int lch = query(a, b, k * 2 + 1, l, (l + r) / 2);
			int rch = query(a, b, k * 2 + 2, (l + r) / 2, r);

			return min(lch, rch);
		} // end if
	} // end function
};

int main()
{
	memset(a, -1, sizeof(a));
	memset(b, -1, sizeof(b));
	memset(negUsed, false, sizeof(negUsed));

	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int N, M; cin >> N >> M;
	fill (bridge, bridge + N - 1, true);

	int res = 0;
	rep (i, M){
		int s, t; cin >> s >> t;
		--s, --t;
		a[i] = s, b[i] = t;
		if (t == s + 1){
			bridge[s] = false;
			++res;
		} // end if
	} // end rep

	int n = 1;
	while(n < N) n *= 2;

	bool update = false;
	while(true){
		update = false;
		UNION_FIND uf(N);
		for (int i = 0; i < N - 1; ++i){
			if (bridge[i] == true){
				uf.unite(i, i+1);
			} // end if
		} // end for

		segtree seg(n);
		rep (i, M){
			if (uf.same(a[i], b[i])){ 
				seg.update(a[i], b[i], 0, 0, n, 1);
				update |= true;
			} // end if
		} // end rep

		if (!update) break;

		vector<int> cnt(N - 1, 0);
		rep (i, N - 1){
			cnt[i] = seg.query(i, i + 1, 0, 0, n);
		} // end rep

		int ind = (int)(max_element(ALL(cnt)) - cnt.begin());
		if (bridge[ind] == true){
			bridge[ind] = false;
			++res;
		} // end if
	} // end while

	cout << res << endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:108:16: error: 'negUsed' was not declared in this scope
  108 |         memset(negUsed, false, sizeof(negUsed));
      |                ^~~~~~~
Language: C

#include<stdio.h>
int main()
{
	int n,m,i,a[100001],b[100001],min,count=0;
	scanf("%d %d\n%d %d",&n,&m,&a[1],&b[1]);
	min = b[1];
	for(i=2;i<=m;i++){
		scanf("%d %d\n",&a[i],&b[i]);
		if(b[i]<min)min=b[i];
	}
	for(i=1;i<=m,i++){
		if(a[i]>min)count++;
	}
	printf("%d",count+1);
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:11:25: error: expected ';' before ')' token
   11 |         for(i=1;i<=m,i++){
      |                         ^
      |                         ;
Language: C++

#include<iostream>
using namespace std;

int n, m, ans = 1;
pair<int, int> dem[100010];

int main(){
  cin >> n >> m;
  for (int i = 0; i < m; i++) cin >> dem[i].second >> dem[i].first;
  sort(dem, dem + m);
  l = dem[0].first;
  for (int i = 1; i < m; i++){
    if(dem[i].second >= l){
      l = dem[i].first;
      ans++;
    }
  }
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   10 |   sort(dem, dem + m);
      |   ^~~~
      |   short
a.cc:11:3: error: 'l' was not declared in this scope
   11 |   l = dem[0].first;
      |   ^
Language: C++

#include <iostream>
#include <vector>
#include <map>
using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> ba(M);
    for(int i=0; i<M; i++){
        int a, b;
        cin >> a >> b;
        ba[i] = make_pair(b-1, a);
    }

    ba.push_back(make_pair(-100, -100));

    sort(ba.begin(), ba.end());

    int pos = ba[0].first;
    int ans = 0;
    for(int i=1; i<M+1; i++){
        if(ba[i].second <= pos) continue;
        pos = ba[i].first;
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   18 |     sort(ba.begin(), ba.end());
      |     ^~~~
      |     short