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 <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <stack>
#include <set>
#include <sstream>
#include <iomanip>
#include <limits>
#include <cstring>

using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<double, double >pd;
typedef pair<string, string> sP;
typedef pair<ll, P> PP;
typedef pair<P, P> PPP;

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const double eps = 1e-10;
const double PI = 3.14159265358979323846;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };

#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second




int main() {
	int a, b, n, s, t, time[1010] = {0};
	cin >> a >> b >> n;
	for (int i = a;i < b;i++)time[i]++;
	for (int i = 0;i < n;i++) {
		cin >> s >> t;
		for (int j = s;j < t;j++) {
			if (time[j]) {
				cout << 1 << endl;
				return 0;
			}
		}
	}
	cout << 0 << 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;
  while(s[f].first < a){
    
    f++;
  }
  f--;
  if(s[f].second <= a && s[f+1].first >= b)
    cout << '0'<< endl;
  else
    cout << '1' << endl;
}

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

int main() {
    int a, b, n;
    cin >> a >> b >> n;
    int s, e, che[1000] = {};
    for(int i = 0; i < n; i++) {
        cin >> s >> e;
        for(int j = s - 1; j < e - 1; j++) {
            che[j] = 1;
        }
    }
    // for(int i = 0; i < 10; i++) cout << che[i] << endl;

    for(int i = a - 1; i < b - 1; i++) {
        if(che[i] == 1) {
            cout << 1 << endl;
            return 0;
        }
    }
    cout << 0 << endl;
}

C++: #include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
#include<set>
#include<bitset>
#include <cstdio>
#include <cmath>

using namespace std;

typedef long long ll;
#define put(n) cout<<(n)<<"\n"
#define FOR(i,num,N) for(int(i)=(num);(i)<(N);++(i))
#define RFOR(i,num,N) for(int (i)=(num);(i)>(N);--(i))
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()

int A,B,N,S,F,ans;
vector<bool> sub(1001,false);
vector< pair<int,int> > n;
void dfs(int s,int f){
    FOR(i,s+1,f) sub[i] = true;
    FOR(i,0,N){
        if(n[i].first == f) dfs(f,n[i].second);
    }

}

int main(){
    cin>>A>>B>>N;
    n.resize(N);
    FOR(i,0,N){
        cin>>n[i].first>>n[i].second;
        if(n[i].first == A && n[i].second == B){
            ans = 1;
        }
    }
    sort(n.begin(),n.end());
    FOR(i,0,N) dfs(n[i].first,n[i].second);
    FOR(i,A,B+1){
        if(sub[i]) ans = 1;
    }
    cout<<ans<<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){
            cout<<1<<endl;
            return 0;
        }
    }
    cout<<0<<endl;
    
    return 0;
}

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(){
  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;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define REP(a,b) for(long long a = 0;a < b;++a)
int main(){
    vector<pair<int,int>> hoge;
    int a,b;
    cin >> a >> b;
    hoge.push_back(make_pair(a,b));
    int n;
    cin >> n;
    REP(i,n){
        int a,b;
        cin >> a >> b;
        hoge.push_back(make_pair(a,b));
    }
    sort(hoge.begin(),hoge.end());
    for(int i = 1;i < n+1;++i){
        if(hoge[i-1].second > hoge[i].first){
            cout << "1" << endl;
            return 0;
        }
    }
    cout << "0" << endl;
    return 0;
}

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

#include <iostream>
#include <algorithm>

using namespace std;

int main() {

	int a,b;
	cin>>a>>b;
	int n;
	cin>>n;
	int s,f;
	int flg=0;
	for(int i=0;i<n;++i){
		cin>>s>>f;
		if(((a>=s&&a<f)||((b-1>=s)&&(b-1<f)))||(a<s&&b>f))flg=1;
	}
	cout<<flg<<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[1000];
  for(int i=0;i<N;i++){
    cin >> s >> f;
    for(int k=s;k<=f;k++){
      if(s==b || f==a){
        ans[k] = 0;
      }else if(f-s==1 && s<=a && f>=b){
        ans[k] = 1;
      }else if(s>a && f<b){
        ans[k] = 1; 
      }else{
        for(int j=s+1;j<f;j++){
          if(f-s != 1){
            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<iostream>
using namespace std;
int main(){
    int a,b,n,k[101],l[101],x=0;
    cin>>a>>b>>n;
    for(int i=0;i<=n;i++){
       cin>>k[i]>>l[i];
       if(k[i]<=a&&a<l[i]){
          x=1;
          break;
       }
       else if(k[i]<b&&b<=l[i]){
          x=1;
       break;
       }
       else if(k[i]>a&&l[i]<b){
          x=1;
          break;
       }
    }
    cout<<x<<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){
			cout<<"1"<<endl;
			break;
		}
		if(c<b){
			cout<<"1"<<endl;
			break;
		}
	}
	cout<<"0"<<endl;
	return 0;
}