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<stdio.h>
#include<iostream>
using namespace std;
int main()
{
	int tim[1001] = {0};
	int s, e, n, ans;
	cin >> s >> e;
	tim[s] = 1;
	tim[e] = -1;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> s >> e;
		tim[s] = tim[s] + 1;
		tim[e] = tim[e] - 1;
	}
	for (int i = 0; i <= 1000; i++)
	{
		if (i != 0)
			tim[i] = tim[i - 1] + tim[i];
		ans = tim[i];
		if (ans > 1)
			break;
	}
	if (ans > 1)
		cout << "1" << endl;
	else
		cout << "0" << endl;
	return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a) = min((a), (b)))
#define chmax(a, b) ((a) = max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const double pi = acos(-1);
const double eps = 1e-10;

int dx[] = {1, 0, -1, 0};
int dy[] = {0, -1, 0, 1};

int main(){
    int a, b, n; cin>>a>>b>>n;
    int ans = 0;
    while(n--){
        int s, f; cin>>s>>f;
        if(f <= a || b <= s) continue;
        ans = 1;
    }

    cout << ans << endl;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <stack>
#include <cmath>
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
using namespace std;
//
const int inf=1e9+7;
const int mod=1e9+7;
//
struct poi{
	int X;int Y;int Z;
	bool operator<(const poi&R)const{
		return X==R.X ? Y==R.Y ? Z<R.Z : Y<R.Y : X<R.X;
	}
};
//
ll GCD(ll a,ll b){
	return (b==0)?(a):(GCD(b,a%b));
}
ll LCM(ll a,ll b){
	return a/GCD(a,b)*b;
}
//
int main(){
	int A,B;
	int N;
	cin>>A>>B>>N;
	FOR(i,0,N){
		int S,F;
		cin>>S>>F;
		if(F<A||B<S){
			continue;
		}else{
			cout<<1<<endl;
			return 0;
		}
	}
	cout<<0<<endl;
	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]) ans = 0;
		}
	}

	cout << ans << endl;

	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,n,x,y,chk=0;
    scanf("%d %d",&a,&b);
    scanf("%d",&n);
    for(int  i=0;i<n;++i){
        scanf("%d %d",&x,&y);
        if(x<=a && x<b && a<y && y<=b) chk++;
        if(a<=x && x<b && a<y && b<=y) chk++;
    }
    if(chk==0) cout <<"0"<< endl;
    else if(0<chk) cout <<"1"<< endl;
    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define lpin(a,i,n) for(int i=0;i<n;i++){cin>>a[i];}
int main(){
  int c,d,n;
  cin>>c>>d>>n;
  int a[1001],b[1001];
  lp(i,1001){
    a[i]=0;
    b[i]=0;
  }
  lp(i,n){
    int x,y;
    cin>>x>>y;
    b[x]=1;
    b[y]=2;
    a[x]+=1;
    a[y]-=1;
  }
  for(int i=1;i<=1000;i++){
    a[i]+=a[i-1];
  }
  int check=0;
  for(int i=c;i<=d;i++){
    if(i==c){
      if(a[i]!=0 && b[i]!=2){
	check=1;
	break;
      }
    }
    else if(i==d){
      if(a[i]!=0 && b[i]!=1){
	check=1;
	break;
      }
    }
    else if(a[i]!=0){
      check=1;
      break;
    }
  }
  cout<<check<<endl;
    
  return 0;
  
}

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

using namespace std;

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

  bool ok = true;
  for (int i = 0; i < n; i++) {
    int s, f;
    cin >> s >> f;
    ok &= (b <= s || f <= a);
  }

  cout << !ok << endl;

  return 0;
}

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

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

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

int main(){
    bool times[1001];
    int a, b, n;
    cin >> a >> b >> n;

    for(int i=0;i<n;i++){
        int s, f;
        cin >> s >> f;
        for(int j=s;j<f;j++)
            times[j] = true;
    }

    bool reserve = false;
    for(int i=a;i<b;i++){
        if(times[i])
            reserve = true;
    }

    cout << reserve << endl;
    return 0;
}

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

int main(){
  int a,b;
  cin>>a>>b;
  int N;
  cin>>N;
  bool yoyaku[1001];
  int tmp_s,tmp_e;
  cout<<yoyaku[0]<<endl;
  for(int i=0;i<N;i++){
    cin>>tmp_s>>tmp_e;
    for(int j=tmp_s;j<=tmp_e;j++)yoyaku[j]=true;
  }
  bool can_yoyaku=true;
  for(int i=a+1;i<b;i++){
    if(yoyaku[i])can_yoyaku=false;
  }
  cout<<!can_yoyaku<<endl;
}

C++: #include <iostream>
using namespace std;
int main(){
	int a,b,N,m=0;
	cin>>a>>b>>N;
	int data[1001]={0};
	for (int A=a;A<b;A++) data[A]=1;
	for (int A=0;A<N;A++){
		cin>>a>>b;
		for (int B=a;B<b;B++){
			if (data[B]==1) m=1;
			else data[B]=1;
		}
	}
	cout<<m<<endl;
	return 0;
}

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

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

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

int main(){
    int s,t,n;
    bool flag=false;
    cin >> s >> t >> n;
    int bs,bt;
    for(int i=0;i<n;i++){
        cin >> bs >> bt;
        if(s>bs&&s<bt)
            flag =true;
        if(t>bs&&t<bt)
            flag = true;
        if(s<=bs&&t>=bt)
            flag = true;
        if(s>=bs&&t<=bt)
            flag = true;
    }
    cout << flag << endl;
    return 0;
}

C++: #include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
  #include "dbgtoki.hpp"
  #define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i)  
#else
  #define DUMP(i)  
#endif

#define GETTYPE(i) 
#define TOSTRING(x) #x
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a):i<(b);i++)
#define SSTR( x ) static_cast< std::ostringstream & >( \
        ( std::ostringstream() << std::dec << x ) ).str()
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());
using namespace std;
typedef long long unsigned int llu;
typedef long long ll;

int main (){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,n;
  while(cin >> a >> b >> n){
    int ans = 0;
    REP(i,n){
      int ia,ib;
      cin >> ia >> ib;
      DUMP(ia < a && a < ib);
      DUMP(ia < b && b < ib);
      if((ia < a && a < ib) || (ia < b && b < ib) || ia == a || ib == b || a < ia && ib < b) ans = 1;
    }
    cout << ans << endl;
  }
  return 0;
}