Go: package main

import "fmt"

func main() {
	var sTime, fTime, exists, eSTime, eFTime int

	fmt.Scan(&sTime, &fTime)
	fmt.Scan(&exists)

	var flag bool

	for i := 0; i < exists; i++ {
		fmt.Scan(&eSTime, &eFTime)

		if sTime > eSTime && sTime < eFTime {
			flag = true
		}
		if fTime > eSTime && fTime < eFTime {
			flag = true
		}
		if eSTime > sTime && eFTime < fTime {
			flag = true
		}
	}

	if flag {
		fmt.Println(1)
	} else {
		fmt.Println(0)
	}
}

C++: #include <bits/stdc++.h>
#include <assert.h>
using namespace std;
using i64 = long long;

int main()
{
  i64 a, b, n;
  cin >> a >> b >> n;
  for (i64 _ = 0; _ < n; _++)
  {
    i64 s, f;
    cin >> s >> f;
    if (a < f && s < b)
    {
      cout << 1 << endl;
      return 0;
    }
  }
  cout << 0 << endl;
  return 0;
}

C++: #include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;
using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  int N;
  cin >> N;
  //いもす！！
  vector<int> P(1000, 0);

  for(int i = 0; i < N; i++) {
    int s, e;
    cin >> s >> e;
    P[s]++;
    P[e]--;
  }
  //るいせきわ(=いたにんずう) 1たしてつかう
  vector<int> S(1001);
  S[0] = 0;
  for(int i = 0; i < 1000; i++) {
    S[i + 1] = S[i] + P[i];
    // cout << "S" << i + 1 << ": " << S[i + 1] << endl;
  }
  bool flag = true;
  for(int i = a; i < b; i++) {
    // cout << "i: " << i;
    // cout << "S[i + 1]" << S[i + 1] << endl;
    if(S[i + 1] > 0) {
      flag = false;
      break;
    }
  }

  if(flag)
    cout << 0 << endl;
  else
    cout << 1 << endl;

  return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;

int main(){
  int a,b;
  cin >> a >> b;
  int n;
  cin >> n;
  pair <int,int> s[n];
  for(int i = 0;i<n;i++){
    int x,y;
    cin >> x >> y;
    s[i].first = x;
    s[i].second = y;
  }
  sort(s,s+n);
  int f = 0;
  bool t = false;
  if(s[0].first >= b)
    t = true;
  if(s[n-1].second <= a)
    t = true;
  for(int i = 0;i < n;i++){
    if(s[i].second <= a && s[i+1].first >= b){
      t = true;
      break;
    }
  }
  if(t)
    cout << '0' << endl;
  else{
    cout << '1' << endl;
  }

  /*while(s[f].first < a){
    
    f++;
    
    }
  f--;
  cout << f << endl;
  if(n != 0){
    if(f != -1){
      if(s[f].second <= a && s[f+1].first >= b)
	cout << '0'<< endl;
      else
	cout << '1' << endl;
	}*/
    
    /*else{
      if(s[0].second >= b && s[0].first > a)
      cout << '0' << endl;
      else
      cout << '1' << endl; 
	}*/
  /*}
  else{
    cout << '0'  << endl;
    }*/
  
 
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,n;
  cin>>a>>b>>n;
  while(n--){
    int q,w;
    cin>>q>>w;
    if(q<b&&w>a){
      cout<<1<<endl;
      return 0;
    }
  }
  cout<<0<<endl;
}

C++: #include<iostream>
using namespace std;

int main(){
  int a,b;
  cin>>a>>b;
  int N;
  cin>>N;
  int tmp_s,tmp_e;
  bool flag=false;
  for(int i=0;i<N;i++){
    cin>>tmp_s>>tmp_e;
    if(a<=tmp_e&&b>=tmp_s)flag=true;
  }
  cout<<flag<<endl;
}

C++: #include <iostream>
using namespace std;
int main(void){
int a,b,c,d,n,i,s=0;
cin>>a>>b;
cin>>n;
for(i=0;i<n;i++){
    cin>>c>>d;
    if(c<b&&a<d)
    s=1;
}
cout<<s<<endl;
          return 0;
}

C++: //============================================================================
// Name        : tokuteigai.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int main() {
	int a,b,c,d,n;
	cin>>a>>b;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>c>>d;
		if(a<d&&d<b){
			cout<<"1"<<endl;
			return 0;
		}
		if(c<b&&a<c){
			cout<<"1"<<endl;
			return 0;
		}
		if(a==c&&b==d){
			cout<<"1"<<endl;
			return 0;
		}
		if(c<a&&b<d){
			cout<<"1"<<endl;
			return 0;
		}
	}
	cout<<"0"<<endl;
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main(){
    int a,b,n;
    cin >>a >>b >>n;
    vector<vector<int>> vec(n,vector<int>(2));
    for(int i=0;i<n;i++){
        cin>>vec.at(i).at(0)>>vec.at(i).at(1);
    }
    vector<int> cat(n,0);
    for(int i=0;i<n;i++){
        cat.at(vec.at(i).at(0)-1) ++;
        cat.at(vec.at(i).at(1)-1) --;
    }
    cat.at(a-1) ++;
    cat.at(b-1) --;
    vector<int> rsw(n+1);
    rsw.at(0) =0;
    for(int i=1;i<n+1;i++){
        rsw.at(i) = rsw.at(i-1) + cat.at(i-1);
    }
    for(int i=0;i<n+1;i++){
        if(rsw.at(i) == 2){
            cout << 1 << endl;
            break;
        }else if(i==n){
            cout << 0 << endl;
        }
    }


}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int a, b, n;
	cin >> a >> b >> n;
	vi s(n), f(n);
	rep(i, 0, n) {
		cin >> s[i] >> f[i];
	}
	rep(i, 0, n) {
		if (a == s[i] || b == f[i]) {
			cout << 1 << endl;
			return 0;
		}
		else if ((s[i] < a&&a < f[i]) || (s[i] < b&&b < f[i])) {
			cout << 1 << endl;
			return 0;
		}
		else if ((a < s[i] && f[i] < b) || (a < s[i] && f[i] < b)) {
			cout << 1 << endl;
			return 0;
		}
	}
	cout << 0 << endl;
}

C++: #include <iostream>
#include <vector>
using namespace std;

int main() {
	int a, b, N;
	cin >> a >> b;
	cin >> N;
	vector<int> s(N);
	vector<int> f(N);
	for (int i = 0; i < N; i++)
		cin >> s.at(i) >> f.at(i);

	for (int i = 0; i < N; i++){
		if (a < s.at(i) && s.at(i) < b&&a < f.at(i) && f.at(i) < b){
			cout << '1';
			break;
		}
		if (i == N - 1)
			cout << '0';
	}
}

C++: #include <iostream>
using namespace std;

int main(){
    bool res[1001];
    int a, b, N;
    bool ans = false;

    cin >> a >> b;
    for(int i=a;a<b;a++)
        res[i] = true;

    cin >> N;
    for(int i=0;i<N;i++){
        int s,f;
        cin >> s >> f;
        for(int j=s;j<f;j++){
            if(res[j])
                ans = true;
        }
    }

    cout << ans << endl;

    return 0;
}

C++: #include<iostream>
using namespace std;

int main(){
  int a,b;
  cin >> a >> b;

  int N;
  cin >> N;

  int s,f;
  int ans=0;
  for(int i=0;i<N;i++){
    cin >> s >> f;
    if(s<=a && a<f){
      ans++;
    }else if(s<b && b<=f){
      ans++;
    }else if(a<=s && f<=b){
      ans++;
    }
  }

  if(ans>0){
    cout << '1' << endl;
  }else{
    cout << '0' << endl;
  }

  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main(){
    int a,b,n;
    cin >>a >>b >>n;
    vector<vector<int>> vec(n,vector<int>(2));
    for(int i=0;i<n;i++){
        cin>>vec.at(i).at(0)>>vec.at(i).at(1);
    }
    vector<int> cat(1000,0);
    for(int i=0;i<n;i++){
        cat.at(vec.at(i).at(0)-1) ++;
        cat.at(vec.at(i).at(1)-1) --;
    }
    cat.at(a-1) ++;
    cat.at(b-1) --;
    vector<int> rsw(1001);
    rsw.at(0) =0;
    for(int i=1;i<1001;i++){
        rsw.at(i) = rsw.at(i-1) + cat.at(i-1);
    }
    for(int i=0;i<1001;i++){
        if(rsw.at(i) == 2){
            cout << 1 << endl;
            break;
        }else if(i==1000){
            cout << 0 << endl;
        }
    }


}