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++: #define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

int main() {
	int a, b; cin >> a >> b;
	int n; cin >> n;
	VI s(n), f(n);
	rep(i, n)cin >> s[i] >> f[i];

	bool flag = false;
	rep(i, n) {
		if ((s[i] < a&&a < f[i]) || (s[i] < b&&b < f[i]) || (s[i] == a && f[i] == b) || (s[i] > a&&f[i] < b))flag = true;
	}
	Cout(flag);
}

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

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

  int N;
  cin >> N;

  int s,f;
  int ans[1000];
  for(int i=0;i<N;i++){
    cin >> s >> f;
    if(s==b || f==a){
      ans[i] = 0;
    }else if(f-s==1 && s<=a && f>=b){
      ans[i] = 1;
    }else{
      for(int j=s+1;j<f;j++){
        if(f-s != 1 || (s>a && f<b)){
          ans[j] = 1;
        }
      }
    }
  }

  int an=0;

  for(int i=a;i<=b;i++){
    if(ans[i]==1){
      an++;
    }
  }

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

  return 0;
}

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

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

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

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

int main(){
    int a,b,N,s[105],f[105];
    cin >> a>>b>>N;
    for (int i = 0; i < N; i++){
        cin >> s[i] >> f[i];
        if (f[i]>a&&s[i]<b){
            cout << 1 << endl;
            return 0;
        }       
    }
    cout << 0<<endl;
    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  ios_base::sync_with_stdio(false);
  int a,b,n,x,y;
  bool flag = false;
  cin >> a >> b >> n;
  for(int i=0;i<n;i++){
    cin >> x >> y;
    if(x > a || y < b) flag = true;
  }

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

  return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
  int a,b,n,s,f,i=0;
  cin >> a >> b >> n;
  do{
    cin >> s >> f;
    i++;
  }while(a <= s && b >= f);
  if(n == i){
    cout << '1' << endl;
  } else {
    cout << '0' << endl;
  }
}

C++: #include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
  vector<int> a(2000,0);
  int aa,b,n;
  cin >> aa >> b >> n;
  rep(i,n){
    int f,g;
    cin >> f >> g;
    for(int j=f;j<g;j++){
      a[j]=1;
    }
  }
  bool t=true;
  for (int i=aa;i<b;i++){
    if (a[i]==1) t=false;
  }
  if (t) cout << 0 << endl;
  else cout << 1 << endl;
}

C++: #include<iostream>
using namespace std;
int main() {
    int a,b,N;
    cin >> a >> b >> N;
    int i,s,f;
    bool flag = true;
    for(i=0;i<N;i++) {
        cin >> s >> f;
        if(s<b && a<f)flag = false;
    }
    cout << (flag?0:1) << endl;
}

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;i<b;i++)
        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<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);
        if(rsw.at(i)==2){
            cout <<1;
            break;
        }else if(i==1000){
            cout <<0;
        }
    }
    cout << endl;
    
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>
#include <bitset>

#define rep(i,j,k) for(int i=j;i<k;i++)
#define Sort(x) sort((x).begin(),(x).end())
#define fi first
#define se second
#define vi vector<int>
#define INF 1000000000
#define MOD 1000000009
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef std::pair<int,int> pii;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;


int main(){
    vector<int> v(1001,0);
    int a,b;
    cin>>a>>b;
    v[a]++; v[b]--;
    int n;cin>>n;
    rep(i,0,n){
        int x,y;
        cin>>x>>y;
        v[x]++; v[y]--;
    }
    
    rep(i,1,1001){
        v[i]+=v[i-1];
        if(v[i]>1 || v[0]>1){
            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(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;
        }
    }


}

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