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

		fmt.Println(0)
	}
}

C++: #include<iostream>
#include<stdio.h>
#include<cstdio>
#include<string>
using namespace std;
int main(){
	int a, b, N;
	cin >> a >> b >> N;
	while (N--){
		int s, f;
		cin >> s >> f;
		if (a < s&& f < b){
			cout << 1 << endl;
		    return 0;
		}
		
	}
	cout << 0 << endl;
	return 0;
}

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

int main(){
  bool flag = false;
  int start,stop;
  cin >> start >> stop;
  int num;
  cin >> num;
  int book_start,book_stop;
  for(int i=0;i<num;i++){
    cin >> book_start >> book_stop;
    if(start>=book_start && start<book_stop){
      flag = true;
    }
    if(stop>book_start && stop<=book_stop){
      flag = true;
    }
  }

  cout << flag << endl;

}

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

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

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

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

signed main() {
  int a, b;
  cin >> a >> b;
  int n;
  cin >> n;
  int s[1001] = {};
  int m[10001], h[10001];
  rep(i, 0, n) cin >> m[i] >> h[i];
  rep(i, 0, n) {
    rep(j, 0, h[i] - m[i]) {
      s[j + m[i]] = 1;
    }
  }
  rep(i, a, b) {
    if(s[i]) {
      cout << 1 << endl;
      return 0;
    }
  }
  cout << 0 << endl;
}

C++: //0360
#include <iostream>
using namespace std;
int main(void){
    int a,b,s,f,n,i,c;
    cin >> a >> b >> n;
    c=0;
    
    for(i=1;i<=n;i++){
        cin >> s >> f;
    if((a<s&&s<b)||(s<=a&&a<f))
        c ++ ;

    }
    if(c==0)
    cout << '0' << endl;
    else
    cout << '1' << endl;
}

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

using namespace std;

typedef long long ll;
typedef std::vector<int> VI;

#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())

int main() {

	int a, b, n, t[1001] = {}, ans = 0;
	cin >> a >> b;
	cin >> n;
	VI s(n), f(n);
	FOR(i, n) {
		cin >> s[i] >> f[i];
		t[s[i]]++;
		if (f[i] < 1000)t[f[i] + 1]--;
	}
	eFOR1(i, 1000)t[i] += t[i - 1];
	for (int i = a; i <= b; i++)if (t[i] == 1) {
		ans++;
		break;
	}
	cout << ans << endl;

	return 0;
}

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

int main() {
  int a, b;
  int n;
  cin >> a >> b;
  cin >> n;
  bool flag = false;
  for (int i = 0; i < n; i++) {
    int s, f;
    cin >> s >> f;
    if (a < s && s < b) {
      flag = true;
      break;
    }
    if (a < f && f < b) {
      flag = true;
      break;
    }
    if (a == s || b == f) {
      flag = true;
      break;
    }
    if (s < a && a < f){
      flag = true;
      break;
    }
    if (s < b && b < f){
        flag = true;
        break;
    }
  }
  if (flag) {
    cout << 1 << endl;
    return 0;
  }
  cout << 0 << endl;
  return 0;
}

C++: #include "bits/stdc++.h"
#define rep(i,a,n) for(int i=a;i<(int)(n);i++)
using namespace std;
int main(){
    int a,b,N;
    int time[1000];
    rep(i,0,1000)time[i]=0;
    cin>>a>>b>>N;
    int s,f;
    rep(i,0,N){
        cin>>s>>f;
        rep(j,s,f){
            time[j+1]=1;
        }
    }
    rep(i,a,b){
        if(time[i+1]!=0){
            cout<<1<<endl;
            return 0;
        }
    }
    cout<<0<<endl;
    return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int a,b,n;
	cin >> a >> b >> n;
	for(int i=0; i<n; i++){
		int s,f;
		cin >> s >> f;

		if(b>s && a<f){
			cout << 1 << endl;
			return 0;
		}
/*		if(b>s && b<=f){
			cout << 1 << endl;
			return 0;
	*/	
		
	}
	cout << 0 << 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;
		}
	}
	cout<<"0"<<endl;
	return 0;
}

C++: #include <bits/stdc++.h>
#define pb push_back
#define REP(i, n) for (signed long long i = 0; i < (n); i++)
#define MOD 998244353
#define INF 93193111451418101
#define bitcnt(a) (ll) __builtin_popcount((a))
#define lb(a, b) lower_bound((a).begin(), (a).end(), (b))
#define ub(a, b) upper_bound((a).begin(), (a).end(), (b))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

int main() {
  ll a, b, n;
  cin >> a >> b >> n;
  b--;
  REP(i, n) {
    ll c, d;
    cin >> c >> d;
    d--;
    if (a <= c && c <= b) {
      return !printf("%lld\n", 1);
    } else if (a <= d && d <= b) {
      return !printf("%lld\n", 1);
    } else if (a >= c && d >= b) {
      return !printf("%lld\n", 1);
    }
  }
  cout << 0 << 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;a<b;a++)
        res[a] = 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[s])
                ans = true;
        }
    }

    cout << ans << endl;

    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-10;
const bool debug = 0;
//------------------------------//

int main() {
	int a, b, N;
	cin >> a >> b >> N;
	
	bool ans = false;
	REP(i, N) {
		int s, f;
		scanf("%d %d", &s, &f);
		
		ans |= a < s && f < b;
		ans |= s < a && a < f;
		ans |= s < b && b < f;
	}
	
	printf("%d\n", (int)ans);
	
	return 0;
}

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

int main(){

	int a, b, N, s[1000],f[1000];
	int ans = 1;
	cin >> a >> b;
	cin >> N;

	for(int i = 0; i < N; i++){
		cin >> s[i] >> f[i];
	}

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

	cout << ans << endl;

	return 0;
}