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

#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

const int N = 1e5 + 10;
vector<ii> a[N];
bool visit[N];
int d[N];

void SPFA(int n) {
  fill(d, d + n, 0);
  fill(visit, visit + n, false);
  stack<int> Q;
  for (int i = 0; i < n; ++i) {
    Q.push(i);
    visit[i] = true;
  }
  while (!Q.empty()) {
    int u = Q.top();
    Q.pop();
    visit[u] = false;
    for (auto& it : a[u]) {
      int v = it.first, cost = it.second;
      if (d[v] < d[u] + cost) {
        d[v] = d[u] + cost;
        // trace(u, v, d[u], d[v]);
        if (!visit[v]) {
          visit[v] = true;
          Q.push(v);
        }
      }
    }
  }
}

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i < n; ++i) {
    a[i - 1].push_back({i, 0});
    a[i].push_back({i - 1, -1});
  }
  while (m--) {
    int x, y;
    scanf("%d%d", &x, &y);
    --x; --y;
    if (x > y) swap(x, y);
    a[x].push_back({y, 1});
  }
  SPFA(n);
  // for (int i = 0; i < n; ++i) {
  //   trace(i, d[i]);
  // }
c  printf("%d\n", d[n - 1]);
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:91:1: error: 'c' was not declared in this scope
   91 | c  printf("%d\n", d[n - 1]);
      | ^
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <concurrent_priority_queue.h>
#include <algorithm>
using namespace std;

int main() {
	int M, N;
	cin >> N >> M;
	vector<pair<int, int>> V;
	int a, b;
	for (int i = 0; i < M; i++) {
		cin >> a >> b;
		V.push_back({ a,b });
	}
	sort(V.begin(), V.end());
	int cnt = 0;
	bool f = true;
	int x, y;
	for (int i = 0; i < V.size() - 1; i++) {
		if (f) {
			pair<int, int> p = V[i];
			y = p.second;
			f = false;
		}
		if (V[i + 1].first < y) {
			if (i == V.size() - 2)cnt++;
			y = min(y, V[i + 1].second);
		}
		else {
			if (i == V.size() - 2)cnt += 2;
			else cnt++;
			f = true;
		}
	
	}
	cout << cnt << endl;
	return 0;
}

Compiler output:
a.cc:5:10: fatal error: concurrent_priority_queue.h: No such file or directory
    5 | #include <concurrent_priority_queue.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define forx(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;

bool x(pair<int,int>a,pair<int,int>b){
    return a.second<b.second;
}

int main(){
    int n,m,ans=0,endtime=0;
    cin>>n>>m;
    vector<pair<int,int>>t(m);
    rep(i,m)cin>>t[i].first>>t[i].second;
    sort(t.begin(),t.end(),x);
    
    rep(i,m){
        if(endtime =< t[i].first)
        endtime=t[i].second;
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:21: error: expected primary-expression before '<' token
   19 |         if(endtime =< t[i].first)
      |                     ^
Language: C++



#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <string>
#include <limits>

using namespace std;
int main()
{
  long long n, m;
  cin >> n >> m;
  vector<pair<long long, long long>> range(m);
  vector<long long> count(n, 0);
  for (auto i = 0; i < m; i++) {
    long long b, e;
    cin >> b >> e;
    range[i] = make_pair(b, e);
    for (auto j = b; j < e; j++) count[j]++;
  }

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

  long long mine = range[0].second;
  priority_queue<long long, vector<long long>, greater<long long>> q;
  q.push(n+1);
  long long ret = 0;
  size_t cur = 0;
  for (auto i = 0; i <= n; i++) {
    if (q.top() == i) {
      ret++;
      while (i <= q.top() && q.top() <= n) {
        q.pop();
      }
    }
    while (cur < m && i == range[cur].first) {
      q.push(range[cur].second);
      cur++;
    }

  }

  cout << ret << endl;
  return 0;
}


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


import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    int M = scanner.nextInt();
    int[][] a = new int[M][2];
    for (int i = 0; i < M; i++){
      a[i][0] = scanner.nextInt();
      a[i][1] = scanner.nextInt();
    }
  Arrays.sort(a, new Comparator<int[]>(){
    @Override
    public int compare(int[] o1, int[] o2){
      return o1[1] - o2[]
    }
  })

  int count = 0;
  for (int i = 0; i < M;){
    count++;
    int right = a[i][1];
    i++;
    while (i < M && a[i][0] < right){
      i++;
    }
  }
    System.out.println(count);
  }
}


Compiler output:
Main.java:18: error: '.class' expected
    }
    ^
Main.java:19: error: ';' expected
  })
    ^
2 errors
Language: Java


import java.util.Scanner;
import java.util.Arrays;
import java.util.Comparator;

public class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    int M = scanner.nextInt();
    int[][] a = new int[m][2];
    for (int i = 0; i < m; i++){
      a[i][0] = scanner.nextInt();
      a[i][1] = scanner.nextInt();
    }
  Arrays.sort(a, Comparator.comparingInt(o -> o[1]));

  int count = 0;
  for (int i = 0; i < m;){
    count++;
    int right = a[i][1];
    i++;
    while (i < m && a[i][0] < right){
      i++;
    }
    System.out.println(count);
  }

  }
}


Compiler output:
Main.java:11: error: cannot find symbol
    int[][] a = new int[m][2];
                        ^
  symbol:   variable m
  location: class Main
Main.java:12: error: cannot find symbol
    for (int i = 0; i < m; i++){
                        ^
  symbol:   variable m
  location: class Main
Main.java:19: error: cannot find symbol
  for (int i = 0; i < m;){
                      ^
  symbol:   variable m
  location: class Main
Main.java:23: error: cannot find symbol
    while (i < m && a[i][0] < right){
               ^
  symbol:   variable m
  location: class Main
4 errors
Language: C++

#include <iostream>
#include <vector>

#define  rep(i, N) for(int (i) = 0; (i) < (N); (i)++)

using namespace std;

typedef pair<int, int> pint;
bool cmp(pint a, pint b){ return a.first < b.first ;};
int N,M;
vector<pint> A;

int main() {
    cin >> N >> M;
    A.resize(M);

    rep(i, M){
        cin >> A[i].first >> A[i].second;
    }
    sort(A.begin(), A.end(), cmp);

    int ans = 0;
    int left = (1 << 31) - 1;
    cout << left << endl;
    for(int i = M - 1 ; i >= 0; i --){
        if(A[i].second <= left){
            left = A[i].first;
            ans ++;
        }
    }
    cout << ans << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:20:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   20 |     sort(A.begin(), A.end(), cmp);
      |     ^~~~
      |     short
a.cc:23:26: warning: integer overflow in expression of type 'int' results in '2147483647' [-Woverflow]
   23 |     int left = (1 << 31) - 1;
      |                ~~~~~~~~~~^~~
Language: C++

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

using namespace std;

using ll = long long;

ll mod = 1000000007;

int main(int argc, char const *argv[]) {
	int n,m;
	std::cin >> n >> m;
	std::vector<std::vector<int>> v(m,std::vector<int> (2));
	for (size_t i = 0; i < m; i++) {
		std::cin >> v[i][1] >> v[i][0];
	}

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


	std::vector<int> kill;
	for (size_t i = 0; i < v.size(); i++) {
		bool flag = true;
		for (size_t j = 0; j < kill.size(); j++) {
			if (v[i][1] < kill[j] && kill[j] <= v[i][0]) {
				flag = false;
				break;
			}
		}
		if (flag) {
			kill.push_back(v[i][0]);
		}

	}

	std::cout << kill.size() << '\n';
	return 0;
}


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

#include<iostream>
#include<string>
#include<utility>
using namespace std;
bool cmp(pair<int,int> a,pair<int,int> b)
{
	if(a.second!=b.second)
	return a.second<b.second;
	return a.first<b.first;
}
int main()
{
	int n,m;
	cin>>n>>m;
	pair<int,int> arr[m];
	for(int i=0;i<m;i++)
		cin>>arr[i].first>>arr[i].second;
	sort(arr,arr+m,cmp);
	int ans=0;
	int i=0;
	int end=arr[0].second;
	i=1;
	while(i<m)
	{
		while(i<m&&arr[i].first<end)
		i++;
		ans++;
		if(i!=m)
			end=arr[i].second;
	}
	cout<<ans;
	
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   18 |         sort(arr,arr+m,cmp);
      |         ^~~~
      |         short
Language: C++

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

int main(){
	const int N=1e5+10;
	int n,m;
	int pre=0;int cnt=0;
	cin >>n>>m;
	struct Node{
		int l,r;
		bool operator<(const Node& rhs)const{
			return r<rhs.r;
		}
	}p[N];

	for(int i=0;i<m;i++){
		cin>>p[i].l>>p[i].r;
	}
	
	sort(p,p+m);
	for(i=0;i<m;i++){
		if(p[i].l>pre){
			pre=p[i].r;
			cnt++;
		}
	}
	cout <<cnt<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:13: error: 'i' was not declared in this scope
   21 |         for(i=0;i<m;i++){
      |             ^
Language: C++

#include <iostream>
#include <vector>
#include <stack>

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int N, M;
	cin >> N >> M;
	vector< pair<int, int> > v;
	stack< pair<int, int> > s;
	while (M--) {
		int x, y;
		cin >> x >> y;
		v.push_back(make_pair(x, y));
	}
	sort(v.begin(), v.end());

	stack<int> deletes;
	// stack<int> mins;

	// for (auto p : v) {
	// 	if (s.empty()) {
	// 		s.push(p);
	// 		mins.push(p.second);
	// 	} else if (p.second < mins.top()) {
	// 		mins.push(p.second);
	// 		s.push(p);
	// 	} else if (p.first >= mins.top()) {

	// 	} else if (p.second > mins.top()) {
	// 		while (deletes.top() < p.first) {
	// 			deletes.pop();
	// 		}
	// 		deletes.push(p.first);
	// 	}
	// }
	for (auto p : v) {
		if (s.empty()) {
			s.push(p);
		} else if (p.first >= s.top().second) {
			int t = s.top().first;
			deletes.push(t);
			s.pop();
			while (!s.empty() && t >= s.top().first) {
				s.pop();
			}
			s.push(p);
		} else {
			s.push(p);
		}
	}
	// cout << s.size() << endl;
	while (!s.empty()) {
		int t = s.top().first;
		deletes.push(t);
		s.pop();
		while (!s.empty() && t >= s.top().first && t < s.top().second) {
			s.pop();
		}
	}
	cout << deletes.size() << "\n";
}

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

#include<bits/stdc++.h>
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;
a--;b--;
v.push_back(make_pair(a,b));
}
sort(v.begin(),v.end());
int ans=0;
for(int i=0;i<m;i++){
int l=v[i].first,r=v[i].second;
while(I<m-1){
if(v[i+1].second<=l||r<=v[i+1].first){
break;
}else{
l=max(l,v[i+1].first);
r=min(r,v[i+1.second);
}
i++;
}
ans++;
}
cout<<ans<<endl;
return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:7: error: 'I' was not declared in this scope
   17 | while(I<m-1){
      |       ^
a.cc:22:13: error: unable to find numeric literal operator 'operator""second'
   22 | r=min(r,v[i+1.second);
      |             ^~~~~~~~
a.cc:22:21: error: expected ']' before ')' token
   22 | r=min(r,v[i+1.second);
      |                     ^
      |                     ]
Language: C++

#include<bits/stdc++.h>
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;
a—;b—;
v.push_back(make_pair(a,b));
}
sort(v.begin(),v.end());
int ans=0;
for(int I=0;I<m;I++){
int l=v[i].first,r=v[i].second;
while(I<m-1){
if(v[i+1].second<=l||r<=v[i+1].first){
break;
}else{
l=max(l,v[i+1].first);
r=min(r,v[i+1.second);
}
i++;
}
ans++;
}
cout<<ans<<endl;
return 0;
}



Compiler output:
a.cc:10:1: error: extended character — is not valid in an identifier
   10 | a—;b—;
      | ^
a.cc:10:4: error: extended character — is not valid in an identifier
   10 | a—;b—;
      |    ^
a.cc: In function 'int main()':
a.cc:10:1: error: 'a\U00002014' was not declared in this scope
   10 | a—;b—;
      | ^~
a.cc:10:4: error: 'b\U00002014' was not declared in this scope
   10 | a—;b—;
      |    ^~
a.cc:16:9: error: 'i' was not declared in this scope
   16 | int l=v[i].first,r=v[i].second;
      |         ^
a.cc:18:22: error: 'r' was not declared in this scope
   18 | if(v[i+1].second<=l||r<=v[i+1].first){
      |                      ^
a.cc:22:13: error: unable to find numeric literal operator 'operator""second'
   22 | r=min(r,v[i+1.second);
      |             ^~~~~~~~
a.cc:22:21: error: expected ']' before ')' token
   22 | r=min(r,v[i+1.second);
      |                     ^
      |                     ]
Language: C++

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

using namespace std;

bool cmp(pair<int,int> a,pair<int,int> b) {
    return a.second < b.second;
}

int main(void) {
    int n,m;
    vector<pair<int,int>> a;
    vector<pair<int,int>> d;
    cin >> n >> m;
    for(int i = 0;i < m;i++) {
        int t[2];
        cin >> t[0] >> t[1];
        a.push_back(make_pair(t[0],t[1]));
    }
    int last = -1;
    int count = 0;
    sort(a.begin(),a.end(),cmp);
    for(const auto& e:a) {
        if(e.first <= last && e.second > last) {

        }
        else
        {
            last = e.second-1;
            count++;
        }
    }
    cout << count << endl;
}

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

//Island war: https://abc103.contest.atcoder.jp/tasks/abc103_d
//solution by ravibitsgoa : Ravishankar Joshi, from BITS Pilani, Goa campus, India
#include <iostream>
using namespace std;
int main()
{
    int n, m;
    cin>>n>>m;
    pair<int, int> req[m];
    for(int i=0; i<m; i++)
        cin >> req[i].first >> req[i].second;
    sort(req, req+m);
    int right = 0, count=0;
    for(int i=0; i<m; i++) {
        if(right == 0) {
            right = req[i].second;
        } else {
            if(req[i].first >= right) {
                count++;
                right = req[i].second;
            }
            if(right > req[i].second)
                right = req[i].second;
        }
    }
    cout << count+1;
}

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

#include<cstdio>
#include<iostream>
int getmaxnum (int arraysan[], int arraysize)
{
    int max = arraysan[0];
    int maxnum = 0;
    for (int i = 1; i < arraysize; ++i) {
        if (arraysan[i] > max) {
            max = arraysan[i];
            maxnum = i;
        }
    }
    return maxnum;
}
int main ()
{
    int n;
    int m;
    int break_bridge = 0;
    scanf("%d%d",&n,&m);
    int a[m];
    int b[m];
    for (int i = 0; i < m; ++i) {
        scanf("%d%d", &a[i], &b[i]);
    }
    bool tf[m];
    int c[m];
    for (int i = 0; i < m; ++i) {
        c[i] = b[i] - a[i];
    }
    for (int i = 1; i < n; ++i) {         // b - aの差の値ごとのループ
        for(int j = 0; j < m; ++j) {      // m個の要請ごとのループ
            if (!tf[j] && c[j] == i) {    // j個目の要請のb - aが　今回探索すべきものと一致したら
                tf[j] = true;
                break_bridge++;
                int val[i];                         //[a,b)の各要素で橋をかけたとき、要請を満たせる個数
                for (int k = 0; k < i; ++k) {       //aからb-1までの要素に対して要請を満たせる個数を検証する
                    for (int l = 0; l < m; ++l){    //特定の要素に対して要請を満たせる個数を数え上げる
                        if (tf[l] == false && a[l] <= a[j] + k && a[j] + k < b[l]) {
                            ++val[k];
                        }
                    }
                }
                int maxnum = getmaxnum(val,i) + a[j];
                for (int f1 = 0; f1 < m; ++f1) {
                    if (a[f1] <= maxnum && maxnum < b[f1]){
                        tf[f1] = true;
                    }
                }
            }
        }
    }
    cout << break_bridge;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:53:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   53 |     cout << break_bridge;
      |     ^~~~
      |     std::cout
In file included from a.cc:2:
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
Language: Java

package testcontest;

import CodeLibrary.FastReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class DIslandsWar {
    static class Point implements Comparable<Point> {
        int x, y;

        Point(int x, int y) {
            this.x = x;
            this.y = y;
        }

        public int compareTo(Point other) {
            if(x > other.x) {
                return 1;
            } else if (x < other.x) {
                return -1;
            } else if (y > other.y) {
                return 1;
            } else if (y < other.y) {
                return -1;
            }
            return 0;
        }

        @Override
        public String toString() {
            return new String("(" + x + "," + y + ")");
        }
    }

    public void solve(int testNumber, FastReader in, PrintWriter out) {
        int n = in.nextInt(), m = in.nextInt();
        List<Point> arr = new ArrayList<>(m);

        for(int i = 0; i < m; i++) {
            int a = in.nextInt(), b = in.nextInt();
            arr.add(new Point(a, b));
        }

        arr.add(new Point((int) 1e9, (int) 2e9));

        Collections.sort(arr);

        int ans = 0;
//        out.println(arr);
        for(int i = 1, lo = arr.get(0).x, hi = arr.get(0).y; i < arr.size(); i++) {
            Point cur = arr.get(i);
            if(cur.x >= hi) {
                ans++;
                lo = cur.x;
                hi = cur.y;
            } else {
                lo = cur.x;
                hi = Math.min(hi, cur.y);
            }
//            out.println("the current bounds are " + lo + " " + hi);
        }
        out.println(ans);
    }
}


Compiler output:
Main.java:9: error: class DIslandsWar is public, should be declared in a file named DIslandsWar.java
public class DIslandsWar {
       ^
Main.java:3: error: package CodeLibrary does not exist
import CodeLibrary.FastReader;
                  ^
Main.java:37: error: cannot find symbol
    public void solve(int testNumber, FastReader in, PrintWriter out) {
                                      ^
  symbol:   class FastReader
  location: class DIslandsWar
3 errors
Language: Java

import java.util.*;

class Demand implements Comparable {
    int from;
    int to;

    public int compareTo(Object other) {
        Demand otherDemand = (Demand) other;
        return to - otherDemand.to;
    }
}

public class D {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int m = sc.nextInt();

        Demand[] demands = new Demand[m];

        for (int i = 0; i < m; i++) {
            Demand demand = new Demand();
            demand.from = sc.nextInt();
            demand.to = sc.nextInt();
            demands[i] = demand;
        }

        Arrays.sort(demands);

        int ans = 0;
        int lastBridge = -1;

        for (int i = 0; i < m; i++) {
            if (demands[i].from > lastBridge) {
                lastBridge = demands[i].to - 1;
                ans++;
            }
        }

        System.out.println(ans);
    }

}

Compiler output:
Main.java:13: error: class D is public, should be declared in a file named D.java
public class D {
       ^
1 error
Language: C++

#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <math.h>
#include <algorithm>

using namespace std;

const int MAX_N = 100001;

int n;
int m;
bool ban[MAX_N][MAX_N];
bool hasi[MAX_N];

int island(){
    bool tf = false;
    int ans = 0;

    for(int i=n-1; i >= 0; i--){
        for(int t=n; t > i; t--){
            if(ban[i][t]) {
                for(int m=i; m < t; m++){
                    if(hasi[m]) tf = true; 
                }
                if(!tf) {
                    hasi[i] = true;
                    ans += 1;
                }
                tf = false;
            }
        }
    }

    return ans;
}

int main(){
    int a,b;
    int ans;


    cin >> n >> m;
    for(int i=0; i<m; i++){
        cin >> a >> b;
        ban[a][b] = true;
    }
    
    ans = island();

    cout << ans;

    return 0;
}

Compiler output:
/tmp/ccyDYfTr.o: in function `island()':
a.cc:(.text+0x61): relocation truncated to fit: R_X86_64_PC32 against symbol `hasi' defined in .bss section in /tmp/ccyDYfTr.o
a.cc:(.text+0x90): relocation truncated to fit: R_X86_64_PC32 against symbol `hasi' defined in .bss section in /tmp/ccyDYfTr.o
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <math.h>
#include <algorithm>

using namespace std;

const int MAX_N = 100000;

int n;
int m;
bool ban[MAX_N][MAX_N];
bool hasi[MAX_N];

int island(){
    bool tf = false;
    int ans = 0;

    for(int i=n-1; i >= 0; i--){
        for(int t=n; t > i; t--){
            if(ban[i][t]) {
                for(int m=i; m < t; m++){
                    if(hasi[m]) tf = true; 
                }
                if(!tf) {
                    hasi[i] = true;
                    ans += 1;
                }
                tf = false;
            }
        }
    }

    return ans;
}

int main(){
    int a,b;
    int ans;


    cin >> n >> m;
    for(int i=0; i<m; i++){
        cin >> a >> b;
        ban[a][b] = true;
    }
    
    ans = island();

    cout << ans;

    return 0;
}

Compiler output:
/tmp/ccUtsZup.o: in function `island()':
a.cc:(.text+0x61): relocation truncated to fit: R_X86_64_PC32 against symbol `hasi' defined in .bss section in /tmp/ccUtsZup.o
a.cc:(.text+0x90): relocation truncated to fit: R_X86_64_PC32 against symbol `hasi' defined in .bss section in /tmp/ccUtsZup.o
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <math.h>
#include <algorithm>

using namespace std;

const int MAX_N = 100000;
const int MAX_M = 100000;

int n;
int m;
bool ban[MAX_N][MAX_N];
bool hasi[MAX_N];

int island(){
    bool tf = false;
    int ans = 0;

    for(int i=n-1; i >= 0; i--){
        for(int t=n; t > i; t--){
            if(ban[i][t]) {
                for(int m=i; m < t; m++){
                    if(hasi[m]) tf = true; 
                }
                if(!tf) {
                    hasi[i] = true;
                    ans += 1;
                }
                tf = false;
            }
        }
    }

    return ans;
}

int main(){
    int a,b;
    int ans;


    cin >> n >> m;
    for(int i=0; i<m; i++){
        cin >> a >> b;
        ban[a][b] = true;
    }
    
    ans = island();

    cout << ans;

    return 0;
}

Compiler output:
/tmp/ccXQYSva.o: in function `island()':
a.cc:(.text+0x61): relocation truncated to fit: R_X86_64_PC32 against symbol `hasi' defined in .bss section in /tmp/ccXQYSva.o
a.cc:(.text+0x90): relocation truncated to fit: R_X86_64_PC32 against symbol `hasi' defined in .bss section in /tmp/ccXQYSva.o
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>
#include <vector>

using namespace std;
#define ll long long
int main(){
    int ans=0;
    int n,m;
    cin>>n>>m;
    vector<int> a,b;
    for(int i=0;i<m;i++){
        int aa,bb;
        cin >> aa>>bb;
        a.push_back(aa);
        b.push_back(bb);
    }
    a.push_back(1145141919);
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
//    for(int i=0;i<m;i++){
//        cout << a[i]<<" "<<b[i]<<endl;
//    }
    int i=0,k=0;
    while(k<m){
        if (a[i]<b[k]){
            ans++;
            while(i<m && a[i]<b[k] && i<100){
                i++;
            }
//            cout <<i<<endl;
        }else{
            k++;
        }
//        if(!f)k++;
//        cout <<";;"<< a[i]<<" "<<b[k]<<endl;

        //k++;
    }
    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(a.begin(),a.end());
      |     ^~~~
      |     short
Language: C++

#include <stdio.h>
#include <stdlib.h>
struct pair{int a;int b;};
int cmp(const void *a, const void *b)
{return ((struct pair*)a)->b - ((struct pair*)b)->b;}
int main()
{
	int n,m,i,j,max=0,ans=0;
	scanf("%d %d",&n,&m);
	struct pair arr[m];
	for(i=0;i<m;i++)
     {scanf("%d %d",&arr[i].a,&arr[i].b);}
	qsort(arr,m,sizeof(struct pair), compare_int);
	for(i=0;i<m;i++)
     {if(max<arr[i].a){max = arr[i].b -1;ans ++;}
     }	
	printf("%d",ans);
	return 0;
}	

Compiler output:
a.cc: In function 'int main()':
a.cc:13:42: error: 'compare_int' was not declared in this scope
   13 |         qsort(arr,m,sizeof(struct pair), compare_int);
      |                                          ^~~~~~~~~~~
Language: C

#include<cstdio>

int getmaxnum (int arraysan[], int arraysize)
{
    int max = arraysan[0];
    int maxnum = 0;
    for (int i = 1; i < arraysize; ++i) {
        if (arraysan[i] > max) {
            max = arraysan[i];
            maxnum = i;
        }
    }
    return maxnum;
}
int main ()
{
    int n;
    int m;
    int break_bridge = 0;
    scanf("%d%d",&n,&m);
    int a[m];
    int b[m];
    for (int i = 0; i < m; ++i) {
        scanf("%d%d", &a[i], &b[i]);
    }
    bool tf[m];
    int c[m];
    for (int i = 0; i < m; ++i) {
        c[i] = b[i] - a[i];
    }
    for (int i = 1; i < n; ++i) {         // b - aの差の値ごとのループ
        for(int j = 0; j < m; ++j) {      // m個の要請ごとのループ
            if (!tf[j] && c[j] == i) {    // j個目の要請のb - aが　今回探索すべきものと一致したら
                tf[j] = true;
                break_bridge++;
                int val[i];                         //[a,b)の各要素で橋をかけたとき、要請を満たせる個数
                for (int k = 0; k < i; ++k) {       //aからb-1までの要素に対して要請を満たせる個数を検証する
                    for (int l = 0; l < m; ++l){    //特定の要素に対して要請を満たせる個数を数え上げる
                        if (tf[l] == false && a[l] <= a[j] + k && a[j] + k < b[l]) {
                            ++val[k];
                        }
                    }
                }
                int maxnum = getmaxnum(val,i) + a[j];
                for (int f1 = 0; f1 < m; ++f1) {
                    if (a[f1] <= maxnum && maxnum < b[f1]){
                        tf[f1] = true;
                    }
                }
            }
        }
    }
    printf("%d", break_bridge);
}

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

#include <iostream>

using namespace std;
const int MAX_N = 100000;

void solve() {
  int N, M;
  int a[MAX_N], b[MAX_N];
  pair<int, int> orders[MAX_N];
  bool cut[MAX_N];
  cin >> N;
  cin >> M;
  for (int i = 0; i < M; i++) {
    cin >> a[i];
    cin >> b[i];
    orders[i].first = b[i];
    orders[i].second = a[i];
  }
  sort(orders, orders + M);

  int ans = 0, d = 0;

  for (int i = 0; i < M; i++) {
    if (d <= orders[i].second) {
      d = orders[i].first;
      ans++;
    }
  }

  cout << ans << endl; 

}

int main(void) {
  solve();
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:19:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   19 |   sort(orders, orders + M);
      |   ^~~~
      |   short
Language: Java

import java.util.*;

public class Main {
    static int modP = 1000000007;
    static long inf  = 1 << 61;
    static int[] x4 = {-1, 0, 0, 1};
    static int[] y4 = {0, -1, 1, 0};

    static int n, m;
    static P[] conditions;

    public static void main(String[] args) {
        input();
        solve();
    }

    static void solve() {
        Arrays.sort(conditions, (P a, P b) -> a.y - b.y);
        int cleared = 0;
        int ans = 1;
        int cut = conditions[cleared].y-1;
        while(cleared < m-1) {
            if(cut >= conditions[cleared+1].x) {
                cleared++;
                continue;
            }else{
                cleared++;
                cut = conditions[cleared].y-1;
                ans++;
            }
        }

        print(ans);
    }

    static void input() {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        m = in.nextInt();
        conditions = new P[m];
        for(int i = 0; i < m; i++) {
            conditions[i] = new P(in.nextInt(), in.nextInt());
        }
    }

    static void print(String s) {
        System.out.println(s);
    }

    static void print(char c) {
        System.out.println(c);
    }

    static void print(int i) {
        System.out.println(i);
    }

    static void print(long i) {
        System.out.println(i);
    }

    static void print(float i) {
        System.out.println(i);
    }

    static void printArray2D(int[][] array, char del) {
        int r = array.length;
        int c = array[0].length;
        for(int i = 0; i < r; i++) {
            for(int j = 0; j < c; j++) {
                System.out.format("%3d", array[i][j]);
                if(j != c-1) System.out.print(del);
                else System.out.print('\n');
            }
        }
    }
}

Compiler output:
Main.java:10: error: cannot find symbol
    static P[] conditions;
           ^
  symbol:   class P
  location: class Main
Main.java:18: error: cannot find symbol
        Arrays.sort(conditions, (P a, P b) -> a.y - b.y);
                                 ^
  symbol:   class P
  location: class Main
Main.java:18: error: cannot find symbol
        Arrays.sort(conditions, (P a, P b) -> a.y - b.y);
                                      ^
  symbol:   class P
  location: class Main
Main.java:40: error: cannot find symbol
        conditions = new P[m];
                         ^
  symbol:   class P
  location: class Main
Main.java:42: error: cannot find symbol
            conditions[i] = new P(in.nextInt(), in.nextInt());
                                ^
  symbol:   class P
  location: class Main
5 errors
Language: C++

#include <queue>
#include <stdio.h>
#include <utility>
using namespace std;
typedef pair<int,int> pi;
#define F first
#define S second
const int N=1e5+10;
int main(){
    int n,m,now=0,ans=0,last=N;
    pi a[N];
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++){
        scanf("%d%d",&a[i].F,&a[i].S);
        a[i].S--;
    }
    sort(a,a+n);
    for(int i=1;i<n;i++){
        while(now<m){
            if(a[now].F<=i){
                last=min(last,a[now].S);
                now++;
            }
            else break;
        }
        if(last==i){
            last=N;
            ans++;
        }
        //if(now>=m)break;
    }
    printf("%d\n",ans);
}

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

#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,x=1,z=0;
    cin>>a>>b;
    int c[b],d[b],y=0,vy=0;
    for(l i=0;i<b;i++){
        cin>>c[i]>>d[i];
        if(y<c[i]) y=c[i];
    }
    while(1){
        vy=y;
        y=0;
        for(l i=0;i<b;i++){
            if(vy>=d[i]){
                c[z]=c[i];
                d[z]=d[i];
                if(y<c[i]) y=c[i];
                z++;
            }
        }
        if(z) x++;
        else break;
        z=0;
    }
    cout<<x<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:7:9: error: 'l' was not declared in this scope
    7 |     for(l i=0;i<b;i++){
      |         ^
a.cc:7:15: error: 'i' was not declared in this scope
    7 |     for(l i=0;i<b;i++){
      |               ^
a.cc:14:13: error: 'l' was not declared in this scope
   14 |         for(l i=0;i<b;i++){
      |             ^
a.cc:14:19: error: 'i' was not declared in this scope
   14 |         for(l i=0;i<b;i++){
      |                   ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long l;
int main(){
    l a,b,x=1,z=0;
    cin>>a>>b;
    l c[b],d[b],y=0,vy=0;
    for(l i=0;i<b;i++){
        cin>>c[i]>>d[i];
        if(y<c[i]) y=c[i]
    }
    while(1){
        for(l i=0;i<b;i++){
            vy=y;
            y=0;
            if(vy>=d[i]){
                c[z]=c[i];
                d[z]=d[i];
                if(y<c[i]) y=c[i];
                z++;
            }
        }
        if(z) x++;
        else break;
        z=0;
    }
    cout<<x<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:26: error: expected ';' before '}' token
   10 |         if(y<c[i]) y=c[i]
      |                          ^
      |                          ;
   11 |     }
      |     ~
Language: C++

#include<iostream>
#include<algorithm>
using namespace std;
int a,m,l;
typedef pair<int,int> pa;
int main() {
	cin>>m>>m;
	pa v[m];
	for(pa &x:v)cin>>x.second>>x.first;
	sort(v,v+m);
	for(pa x:v)
		if(x.second>=l){
			l=x.first;
			s++;
		}
	cout<<s;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:25: error: 's' was not declared in this scope
   14 |                         s++;
      |                         ^
a.cc:16:15: error: 's' was not declared in this scope
   16 |         cout<<s;
      |               ^
Language: C++

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

int main()
{
    int n, m;
    cin >> n >> m;
    vector<pair<int int>> p;
    p.resize(m);
    int ans = 0;
    
    for(int i=0; i<m; i++){
        cin >> p[i].second >> p[i].first;
    }
    sort(p.begin(), p.end());
    
    int c = 0;
    for(int i=0; i<m; i++){
        auto& t = p[i];
        if(c > t.second){
            continue;
        }else{
            c = t.first;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:17: error: two or more data types in declaration of 'type name'
   10 |     vector<pair<int int>> p;
      |                 ^~~
a.cc:10:21: error: wrong number of template arguments (1, should be 2)
   10 |     vector<pair<int int>> p;
      |                     ^~~
In file included from /usr/include/c++/14/string:48,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 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/c++/14/bits/stl_iterator.h:3013:12: note: provided for 'template<class _T1, class _T2> struct std::pair'
 3013 |     struct pair;
      |            ^~~~
a.cc:10:24: error: template argument 1 is invalid
   10 |     vector<pair<int int>> p;
      |                        ^~
a.cc:10:24: error: template argument 2 is invalid
a.cc:11:7: error: request for member 'resize' in 'p', which is of non-class type 'int'
   11 |     p.resize(m);
      |       ^~~~~~
a.cc:15:17: error: invalid types 'int[int]' for array subscript
   15 |         cin >> p[i].second >> p[i].first;
      |                 ^
a.cc:15:32: error: invalid types 'int[int]' for array subscript
   15 |         cin >> p[i].second >> p[i].first;
      |                                ^
a.cc:17:12: error: request for member 'begin' in 'p', which is of non-class type 'int'
   17 |     sort(p.begin(), p.end());
      |            ^~~~~
a.cc:17:23: error: request for member 'end' in 'p', which is of non-class type 'int'
   17 |     sort(p.begin(), p.end());
      |                       ^~~
a.cc:21:20: error: invalid types 'int[int]' for array subscript
   21 |         auto& t = p[i];
      |                    ^
Language: C++

#include<stdio.h>
int a[100005],b[100005];
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		scanf("%d%d",&a[i],&b[i]);
	}
	int flag=1;
/*		for(int i=0;i<m;i++){
			for(int j=0;j<m-1-i;j++){
				if(a[j]>a[j+1]){
					int t=a[j];
					a[j]=a[j+1];
					a[j+1]=t;
					t=b[j];
					b[j]=b[j+1];
					b[j+1]=t;
				}
			}
		}
		for(int j=0;j<m-1;j++){
				if(a[j]==a[j+1]&&b[j]>b[j+1]){
					int t=b[j];
					b[j]=b[j+1];
					b[j+1]=t;
					j-=2;
				}
*/			}
		int k=b[0];
		for(int i=0;i<m;i++){
			if(a[i]==a[i+1]){
				continue;
			}
			else if(k<=a[i+1]){
				flag++;
				k=b[i+1];
			}
			else if(k>b[i]){
				k=b[i];
			}
		}
	printf("%d",flag);
}

Compiler output:
a.cc:31:17: error: expected unqualified-id before 'for'
   31 |                 for(int i=0;i<m;i++){
      |                 ^~~
a.cc:31:29: error: 'i' does not name a type
   31 |                 for(int i=0;i<m;i++){
      |                             ^
a.cc:31:33: error: 'i' does not name a type
   31 |                 for(int i=0;i<m;i++){
      |                                 ^
a.cc:43:15: error: expected constructor, destructor, or type conversion before '(' token
   43 |         printf("%d",flag);
      |               ^
a.cc:44:1: error: expected declaration before '}' token
   44 | }
      | ^
Language: C

#include <stdio.h>
main(){
    int N,M;
    scanf("%d %d",&N,&M);

    int y[100001];
    int i,j,k;
    for(i=1;i<=N;i++)
        y[i]=2*N;

    int a,b;

    for(i=0;i<M;i++){
        scanf("%d %d",&a,&b);
        if(b<y[a])
            y[a]=b;
    }  
    for(i=1;i<N;i++){
        if(y[i]==2*N)continue;
        for(k=i+1;k<y[i];k++){
            if(y[k]<=y[i])//ganni
                y[i]=2*N;
                break;
            else{   //and
                y[k]=y[i];
                y[i]=2*N;
                break;
            }
        }
    } 
    int rt=0;
    for(i=1;i<N;i++)
        if(y[i]!=2*N)
            rt++;
    printf("%d\n",rt);

    return 0;
}


Compiler output:
main.c:2:1: error: return type defaults to 'int' [-Wimplicit-int]
    2 | main(){
      | ^~~~
main.c: In function 'main':
main.c:24:13: error: 'else' without a previous 'if'
   24 |             else{   //and
      |             ^~~~
Language: C++

#include <stack>
#include <queue>
#include <cstdio>
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n0,n) for(int i=n0;i<n;i++)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<n;j++)
#define INF (1<<29)

int main (){
	int NN,MM;tempa,tempb,temp;
	cin >> NN >> MM;
	pair<int,int> temppair;
	vector <pair< int , int > > cuts;
	rep(i,MM){
		cin >> tempa >> tempb;
		if(tempa>tempb)	{temp = tempa;tempa = tempb;tempb = temp;}
		cuts.push_back(make_pair(tempa,tempb));
	}
	sort(cuts.begin(),cuts.end());
	int ff = cuts[0].first;
	int fb = cuts[0].second;
	int ans = 1;
	rep(i,MM){
		if(cuts[i].first == ff)	continue;
		if ( fb <= cuts[i].first ){
			ff = cuts[i].first;
			fb = cuts[i].second;
			ans ++;
		}
		if( fb > cuts[i].second ){
			fb = cuts[i].second;
		}
	}
	cout << ans << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:19: error: 'tempa' was not declared in this scope; did you mean 'tempnam'?
   17 |         int NN,MM;tempa,tempb,temp;
      |                   ^~~~~
      |                   tempnam
a.cc:17:25: error: 'tempb' was not declared in this scope
   17 |         int NN,MM;tempa,tempb,temp;
      |                         ^~~~~
a.cc:17:31: error: 'temp' was not declared in this scope; did you mean 'tm'?
   17 |         int NN,MM;tempa,tempb,temp;
      |                               ^~~~
      |                               tm
Language: C++

#include <iostream>
#include <vector>
template <class T> using vector_t = std::vector<T>;

int main() {
	int N,M,a,b;
	std::cin>>N>>M;
	vector_t<int> bs(N+1,N+1);
	for(int i=0;i<M;++i)
	{
		std::cin>>a>>b;
        if(bs[a]>b)=bs[a]=b;
	}
	int count=0;
	int minb=N+1;
	for(int i=0;i<N;++i){
		if(minb==i)
		{
			++count;
			minb=bs[i];
		}else if(minb>bs[i])
			minb=bs[i];
	}
	if(minb!=N+1)
		++count;
	std::cout<<count<<std::endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:20: error: expected primary-expression before '=' token
   12 |         if(bs[a]>b)=bs[a]=b;
      |                    ^
Language: C++

#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cstring>
#include <stdio.h>
#include <conio.h>
using namespace std;
struct Query
{  int fr,to;
   bool operator < (const Query &cp) const
   {  if(fr!=cp.fr)
        return fr<cp.fr;
      return to<cp.to;
   }
}a[100101];
int ans;
int main()
{
	int n,m,i;
	scanf("%d%d",&n,&m);
	for(i=1;i<=m;i++)
	  scanf("%d%d",&a[i].fr,&a[i].to);
	sort(a+1,a+m+1);
	int p=n+1;
	for(i=1;i<=m;i++)
	{  if(a[i].fr>=p)
	     p=n+1,ans++;
	   if(a[i].to<=p)
	     p=a[i].to;
	}
	printf("%d",ans+1);
	return 0;
}

Compiler output:
a.cc:7:10: fatal error: conio.h: No such file or directory
    7 | #include <conio.h>
      |          ^~~~~~~~~
compilation terminated.
Language: C++

//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }


int
main(void){  
  int n, m;
  cin >> n >> m;
  
  vector <P> v;

  REP(i, m){
    int x, y;
    cin >> x >> y;
    if(x > y) swap(x, y);
    v.push_back(make_pair(x, y));
  }

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

  int l=v[0].first;
  int r=v[0].second;
  int ans = 1;
  REP(i, m) cout << v[i].first << ":" << v[i].second << endl;

  FOR(i, 1, m){    
    if(v[i].first > r){
      ans++;
      l = v[i].first;
      r = v[i].second;
    }
    else{
      l = max(l, vec[i].first);
      r = min(r, vec[i].second);
    }
  }

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


Compiler output:
a.cc: In function 'int main()':
a.cc:68:18: error: 'vec' was not declared in this scope
   68 |       l = max(l, vec[i].first);
      |                  ^~~
Language: C++

#include<bits/stdc++.h>
#define INF            1e9
#define REP(i,n)       for(lint i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)      for(lint i=1,i##_len=(n);i<=i##_len;++i)
#define REPI(i,ini,n)  for(lint i=(ini),i##_len=(n);i<i##_len;++i)
#define REPR(i,n)      for(lint i=(n)-1;i>=0;--i)
#define REPR1(i,n)     for(lint i=(n);i>0;--i)
#define REPRI(i,ini,n) for(lint i=(ini)-1,i##_len=(n);i>=i##_len;--i)
#define REPC(i,obj)    for(auto i:obj)
#define R_UP(a,b)      (((a)+(b)-1)/(b))
#define ALL(obj)       (obj).begin(),(obj).end()
using namespace std;
using lint = long long;
template<typename T = lint>inline T in() { T x; cin >> x; return x; }
signed main()
{
	int n, m;
	scanf_s("%d %d", &n, &m);
	vector<tuple<int, int, int>>t(m);
	REP(i, m)
	{
		int a, b;
		scanf_s("%d %d", &a, &b);
		--a; --b;
		t[i] = make_tuple(b - a, a, b);
	}
	sort(ALL(t));
	int min = 100001, max = -1;
	vector<int>pass(n - 1);
	REP(i, n - 1)pass[i] = i;
	REPC(i, t)
	{
		int a = get<1>(i), b = get<2>(i);
		if (a >= max || b <= min)
		{
			if (b > pass[a])pass[a] = b;
			if (min > a)min = a;
			if (max < b)max = b;
			if (min == 0 && max == n - 1)break;
		}
	}
	int ans = 0;
	for (int i = 0; i < n - 1;)
	{
		if (i == pass[i])
		{
			++i;
			continue;
		}
		i = pass[i];
		++ans;
	}
	cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:9: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   18 |         scanf_s("%d %d", &n, &m);
      |         ^~~~~~~
      |         scanf
Language: C++

#define M 100000
using namespace std;
 
struct W{
    int a;
    int b;
    bool operator<( const W& right ) const {
        return a < right.a;
    }
};
 
int main(void){
    
    int n, m;
    cin >> n >> m;
    vector<W> wars(m);
    
    for(int i = 0; i < m; i ++) cin >> wars[i].a >> wars[i].b;
    // sort(wars.begin(), wars.end()); どうやら要求は全部 a についてソートされてるらしい
    
    int dp = 0, dp2 = n;
    for(int i = m-1; i >= 0; i --){
        if(dp2 >= wars[i].b){
            dp ++;
            dp2 = wars[i].a;
        }
    } 
    cout << dp << "\n";
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:5: error: 'cin' was not declared in this scope
   15 |     cin >> n >> m;
      |     ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | #define M 100000
a.cc:16:5: error: 'vector' was not declared in this scope
   16 |     vector<W> wars(m);
      |     ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
  +++ |+#include <vector>
    1 | #define M 100000
a.cc:16:13: error: expected primary-expression before '>' token
   16 |     vector<W> wars(m);
      |             ^
a.cc:16:15: error: 'wars' was not declared in this scope
   16 |     vector<W> wars(m);
      |               ^~~~
a.cc:28:5: error: 'cout' was not declared in this scope
   28 |     cout << dp << "\n";
      |     ^~~~
a.cc:28:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#define M 100000
using namespace std;
 
struct W{
    int a;
    int b;
    bool operator<( const W& right ) const {
        return a < right.a;
    }
};
 
int main(void){
    
    int n, m;
    cin >> n >> m;
    vector<W> wars(m);
    
    for(int i = 0; i < m; i ++) cin >> wars[i].a >> wars[i].b;
    // sort(wars.begin(), wars.end()); どうやら要求は全部 a についてソートされてるらしい
    
    dp = 0, dp2 = n;
    for(int i = m-1; i >= 0; i --){
        if(dp2 >= wars[i].b){
            dp ++;
            dp2 = wars[i].a;
        }
    } 
    cout << dp << "\n";
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:5: error: 'dp' was not declared in this scope
   24 |     dp = 0, dp2 = n;
      |     ^~
a.cc:24:13: error: 'dp2' was not declared in this scope
   24 |     dp = 0, dp2 = n;
      |             ^~~