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++: //============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
int a,b;
int N;
int s[1001],f[1001];
int main() {
	cin>>a>>b;
	cin>>N;
	int R=0;
	for(int i=0;i<N;i++){
		cin>>s[i]>>f[i];
		if((s[i]<a && a<f[i]) || (s[i]<b && b<f[i] ))R+=1;
	}

	cout<<R<<endl;


	return 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 > 0){
		int s, f;
		cin >> s >> f;
		if (a < s&& f < b){
			cout << 1 << endl;
			break;
		return 0;
		}
		else{
			N--;
		}
	}
	cout << 0 << endl;
	
}

C++: #include <iostream>
using namespace std;
int main(void){
    
    int a, b, s, f, N, ans = 0;

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

C++: #include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 10000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl

signed main(){
    int a,b,N;
    int s[104],f[104];
    cin >> a >> b >> N;
    REP(i,N){
        cin >> s[i] >> f[i];
    }
    int imos[1020]={};
    REP(i,N){
        imos[s[i]]++;
        imos[f[i]]--;
    }
    imos[a]++;
    imos[b]--;
    REP(i,1019){
        imos[i+1]+=imos[i];
    }
    REP(i,1020){
        if(imos[i]>=2){
            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--;
  //cout << f << endl;
  if(n != 0){
    
      if(s[f].second <= a && s[f+1].first >= b)
	cout << '0'<< endl;
      else
	cout << '1' << endl;
      
    
      /*else{
      if(s[0].second >= b && s[0].first > a)
	cout << '0' << endl;
      else
	cout << '1' << endl; 
	}*/
  }
  else{
    cout << '0'  << endl;
  }
  
 
}

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;
}
 
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<set>
using namespace std;
#include<iostream>
int	main(){
	/*
	while(true){
	
	int A,B,C,D,E,F,G,H,I,J,answer;
		
	cin >> A;
	if(A == 0) return 0;
	cin >> B >> C >> D >> E >> F >> G >> H >> I >> J;
	answer = A - B - C - D-E-F-G-H-I-J;
	cout << answer << endl;

	}
	*/
	/*
	int A,B,C,D,E,F;

	cin >> A, B, C, D;
	if(A < B, C, D){ 
		cout << B + C + D << endl;
	}
	
	else if(B < A, C, D){
		cout << A + C + D << endl;
	}

	else if(C < A && C < B && C < D){
		cout << A + B + D << endl;
	}

	else if(D < A && D < B && D < C){
		cout << A + B + C << endl;
	}

	if(E < F){
		cout << F << endl;
	}

	else{
		cout << E << endl;
	}
	
	return 0;
}*/
	/*
	int N, M;
	cin >> N >> M;
	cout << N + M << endl << N - M << endl << N * M << endl << N / M << endl;
}*/

	int a , b , N ;
	cin >> a >> b >> N ;

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

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

C++: #include <bits/stdc++.h>
#define px(str) cout<<(str)<<endl,exit(0);
#define pe(str) return cout<<(str)<<endl,0;
#define IF(a,b,c) ((a)?(b):(c))
#define re(i,n) for(int i=0;i<(n);i++)
#define rep(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;

int t[1001];
int main(int argc,char** argv){
	int a,b;
	int n;
	cin>>a>>b>>n;
	int x,y;
	re(i,n){
		cin>>x>>y;
		rep(j,x,y)t[j]=1;
	}
	rep(i,a,b){
		if(t[i])pe(1);
	}
	pe(0);
		return 0;
}

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

int main(){
  int a, b, N;
  cin >> a >> b >> N;
  int M = 1e3+10;
  vector<int> A(M);
  for(int i = 0; i < N; ++i){
    int s, f;
    cin >> s >> f;
    ++A[s];
    --A[f];
  }
  for(int i = 0; i < M-1; ++i)
    A[i+1] += A[i];
  for(int i = a; i < b; ++i){
    if(A[i] > 0){
      cout << 1 << endl;
      return 0;
    }
  }
  cout << 0 << endl;
}

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

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

    map<int,bool> mp;
    for(int i=0;i<=1000;i++){
        mp[i] = false;
    }

    for(int i=0;i<N;i++){
        int start,end;
        cin>>start>>end;
        for(int j=start;j<end;j++){
            mp[j] = true;

        }
    }
    
    bool overlapp = false;

    for(int i=a;i<b;i++){
        if(mp[i] == true){
            overlapp = true;
        }
    }

    cout<<overlapp<<endl;
    
    


}

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

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

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

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