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>
using namespace std;
int main(){

  int ab[1000]={},n,a,b,r=0;
  cin>>a>>b>>n;
  for(int i=a;i<b;i++) ab[i]++;
  for(int i=0;i<n;i++){
    cin>>a>>b;
    for(int i=a;i<b;i++) ab[i]++;
  }
  for(int i=0;i<1000;i++) if(ab[i]>1) r++;
  if(r) cout<<1<<endl;
  else cout<<0<<endl;


}

C++: /*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=1e18;
using P=pair<int,int>;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int a,b,n,s,f,t[1005]={};
  cin >> a >> b >> n;
  for(int i=0; i<n; i++) {
    cin >> s >> f;
    t[s]++,t[f]--;
  }
  for(int i=1; i<1005; i++) {
    t[i]+=t[i-1];
  }
  for(int i=a; i<b; i++) {
    if(t[i]>0) {
      cout << 1 << endl;
      return 0;
    }
  }
  cout << 0 << endl;
}

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

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

int main()
{
	int sta,end,n;
	cin >> sta >> end >> n;

	bool jud = true;
	int tsta,tend;
	for(int i=0;i<n;i++){
		cin >> tsta >> tend;
		if(!((sta<=tsta&&end<=tend)||(sta>=tend&&end>=tend))){
			jud = false;
                        break;
		}
	}

	if(jud){
		cout << 0 ;
	}else{
		cout << 1 ;
	}

	return 0;
}

C++: #include <iostream>
using namespace std;
void showResevation(int *arr){
    for(int i=0; i<1000; i++){
        cout << arr[i] << " ";
    }
    cout << endl;
}
int main(void){
    int elRes[1000] = {};
    int resStart, resEnd;
    cin >> resStart >> resEnd;
    for(int i=resStart; i<=resEnd-1; i++){
        elRes[i] = 1;
    }

    int loops, rs, re;
    cin >> loops;
    for(int i=0; i<loops; i++){
        cin >> rs >> re;
        for(int j=rs;j<=re-1;j++){
            if(elRes[j] == 1){
                cout << 1 << endl;
                return 0;
            }
        }
    }
    cout << 0 << endl;
    return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	llong a,b,N;
	bool check[1001] = {false};

	cin >> a >> b >> N;
	int s,f;
	for(int i = 0; i < N; i++){
		cin >> s >> f;
		for(int j = s; j < f; j++)
			check[j] = true;
	}

	bool ok = false;
	for(int i = a; i < b; i++)
		if(check[i])
			ok = true;

	cout << ok << endl;

	return 0;
}

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);
	vector<bool> can(1001, false);
	rep(i, 0, n) {
		cin >> s[i] >> f[i];
		rep2(j, s[i], f[i]) {
			can[j] = true;
		}
	}
	rep(i, a + 1, b) {
		if (can[i]) {
			cout << 1 << endl;
			return 0;
		}
	}
	cout << 0 << endl;
}

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

bool overlap(int a, int b, int c, int d){
  assert( a < b ); assert( c < d );
  int a = 0;
  for ( int i = 0; i < 10000; i++ ) a += i;
  if ( d <= a ) return false;
  if ( b <= c ) return false;
  return true;
}

bool notOverlap(int a, int b, int c, int d){
  return b <= c || d <=a;
}

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;
    } else {
      assert(notOverlap(a, b, s, f));
    }
  }
  cout << 0 << 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; break;
		}
		cout << 0;
	} 
	return 0;
}

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

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

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

  int a[1000] = {0};
  int count1 = 0,count2 = 0;
  for(int i = a; i < b; i++){
    a[i] = 1;
    count1++;
  }

  int x,y;
  for(int i = 0; i < N; i++){
    cin >> x >> y;
    for(int i = x; i < y; i++){
      a[i] = 0;
    }
  }

  for(int i = 0; i < 1000; i++){
    if(a[i] == 1)count2++;
  }
  if(count1 == count2)cout << '0' << endl;
  else cout << '1' << endl;

  return 0;
}

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 (s.at(i) < a && a < f.at(i) || s.at(i) < b && b < f.at(i) || a < s.at(i) && s.at(i) < b || a < f.at(i) && f.at(i) < b || a == s.at(i) && b == f.at(i)){
			cout << '1' << endl;
			break;
		}
		if (i == N - 1)
			cout << '0' << endl;
	}
}

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

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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define dep(i, a, n) for(int i = a; i >= (n); i--)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll a, b, n, s, f, ans = 0;
  cin >> a >> b >> n;
  rep(i, n) {
    cin >> s >> f;
    if(f <= a || b <= s) continue;
    ans = 1;
  }
  cout << ans << endl;
	return 0;
}