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<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(){
	int a,b;
	cin>>a>>b;
	int n;
	cin>>n;
	int ans=0;
	for(int i=0; i<n; i++){
		int s,f;
		cin>>s>>f;
		if( (a>=f) || (b<=s)) int k;
		else ans=1;
	}
	cout<<ans<<endl;
}

C++: #include<iostream>
using namespace std;
int main(){
	int a, b, n, i, z = 0;
	int x[100], y[100];
	cin >> a >> b >> n;
	for (i = 0; i < n; i++){
		cin >> x[i] >> y[i];
		if (x[i] < a&&y[i] > a){
			z = 1;
		}
		if (x[i] < b&&y[i] > b){
			z = 1;
		}
	}
	cout << z << endl;
	return 0;
}

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

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

  int t[1001];
  for(int i=0; i<1001; i++){
    t[i]=0;
  }

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

  int l=0;
  for(int i=a; i<=b; i++){
    l+=t[i];
    if(l>0)break;
  }
  cout << l << '\n';

  return 0;
}

C++: #include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int j=1,i,u,o[15]={0},a,b,n,s[3],f[3];
    cin>>a>>b>>n;
    for(i=a+1;i<=b-1;i++)
    o[i]=1;
    for(i=0;i<3;i++){
        cin>>s[i]>>f[i];
        for(u=s[i]+1;u<=f[i]-1;u++)
        o[i]=0;
    }
    for(i=a+1;i<=b-1;i++){
        if(o[i]==1)
        j=0;
    }
    if(j==1)
    cout<<j;
    else if(j==0)
    cout<<j;
    return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <stdio.h>
#include <cstring>
#include <string.h>
#include <string>
#include <sstream>
#include <iomanip>

using namespace std;

int main (void)
{
	long a,b;
	long n,p[1000],q[1000],gg[1000];
	cin >> a >> b;

	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> p[i] >> q[i];
	}


	for (int j = 1; j < 100; j++)
	{
		gg[j] = 0;
	}

	for (int i = 0; i < n; i++)
	{
		for (int j = p[i]; j < q[i]; j++)
		{
			gg[j] -= 1;
		}
	}


	int co = 0;
	for (int i = a; i < b + 1; i++)
	{
		if (gg[i] == 0)
		{
			co++;
			cout << "0" << endl;
			break;
		}
	}

	if (co == 0)
	{
		cout << "1" << endl;
	}
}

C++: #include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

const int M=1005;
bool a[M];
int n,l,r;

int main(){
	cin>>l>>r>>n;
	for(int i=0;i<n;i++){
		int L,R;
		cin>>L>>R;
		while(L<R) a[L++]=1;
	}
	while(l<r){
		if(a[l]){
			cout<<0<<endl;
			return 1;
		}
		l++;
	}
	cout<<0<<endl;
}

C++: #include <stdio.h>
  
int main(void) {
  int n, a, b, i;
  scanf("%d%d%d", &a, &b, &n);
  //printf("start\n");
  for(i = 0; i < n; ++i) {
    int s, t, te;
    scanf("%d%d",&s, &t);
    if(t <= a || s >= b) {te = 1;}
    else {
      printf("1\n");
      return 0;
    }
  }
  printf("0\n");
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int a,b;
	int n;
	int s,f;
	int flg;
	int i;
	
	cin>>a>>b>>n;
	
	flg=0; //重複しない
	for(i=0;i<n;i++){
		cin>>s>>f;
		if(flg==1) continue;
		if((a>=s&&b<=f)||(a<=s&&b>=f)||(a>s&&a<f)||(b>s&&b<f)){
			flg=1; //重複する
			//cout<<"i="<<i<<endl;
		}
		//sとfの間にaかbがあれば重複する
	}
	
	if(flg==0) cout<<"0"<<endl;
	else cout<<"1"<<endl;
	
	return 0;
}

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



int main(){

  int a[10000]={};
  int n,s,l;
  cin>>s>>l;
  a[s]++;
  a[l]--;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>s>>l;
      a[s]++;
      a[l]--;
  }

  bool j=true;
  int count=0;
  for(int i=0;i<1010;i++){
    count+=a[i];
    if(count>1){j=false; break;}
  }
  if(j){cout<<"0"<<endl;}
  else{cout<<"1"<<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 <bits/stdc++.h>
using namespace std;

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

    bool time[1001];

    for(int i=0;i<=1000;i++){
        time[i] = true;
    }

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

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

    cout << 0 << endl;
}

C++: #include<set>
#include<iostream>
#include<ctime>
#include<string>
#include<cstdlib>
#include<algorithm>
#include<random>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<functional>
#include<string.h>
#include<limits.h>
using namespace std;

signed main() {
	int a, b, n; cin >> a >> b >> n;
	for (int i = 0; i < n; i++) {
		int c, d; cin >> c >> d;
		int e = min(b, d) - max(a, c);
		if (e > 0) { puts("1"); return 0; }
	}
	puts("0");
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
#include<unordered_set>
using namespace std;
/*int p = 998244353;*/
int p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<int,pin>
#define V vector
#define Endl endl
#define veb vector<bool>
#define rev(s) reverse(s.begin(),s.end())
#define end_pr(s) cout << s <<endl;return 0
signed main(){
	int lim = 10000;
	int a, b; cin >> a >> b;
	int n; cin >> n;
	rep(ind, n) {
		int s, f; cin >> s >> f;
		if (f <= a || b <= s) { f++; f--; }
		else {
			cout << 1 << endl; return 0;
		}
	}
	cout << 0 << endl;
}