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 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;
}

C++: #include "bits/stdc++.h"
using namespace std;
int main()
{
    int a, b, n, m[1001] = {};
    scanf("%d%d%d", &a, &b, &n);
    for (int i = 0, j, k; i < n; ++i)
    {
        scanf("%d%d", &j, &k);
        ++m[j];
        --m[k];
    }
    for (int i = 1; i < 1001; ++i)
    {
        m[i] += m[i - 1];
    }
    for (int i = a; i < b; ++i)
    {
        if (m[i])
        {
            printf("1\n");
            return 0;
        }
    }
    printf("0\n");
    return 0;
}

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;
		}
		if (a <= x[i] && y[i] <= b){
			z = 1;
		}
	}
	cout << z << endl;
	return 0;
}

C++: #include <iostream>
using namespace std;
int main(void){
  int a,b,n;
  cin>>a>>b>>n;
  for(int i=0;i<n;i++){
    int x,y;
    cin>>x>>y;
    if(x<b&&a<y){
      cout<<1<<endl;
      return 0;
    }
  }
  cout<<0<<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) && b == f.at(i)){
			cout << '1' << endl;
			break;
		}
		if (i == N - 1)
			cout << '0' << endl;
	}
}

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>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	int n, a, b, x, y; cin >> a >> b;
	cin >> n;
	for (int h = 0; h < n; h++) {
		cin >> x >> y;
		if (a <= x && b <= x) {
			n == n;
		}
		else if (a >= y && b >= y){
			n == n;
		}
		else {
			cout << '1' << endl;
			return 0;
		}
	}
	cout << '0' << endl;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,n,s,f,r=0;
  int t[1001]={};
  cin >> a >> b >> n;
  for(int i=a; i<b; i++) t[i]++;

 // for(int i=0; i<11; i++) cout << t[i] << " ";

  for(int i=0; i<n; i++){
        cin >> s >> f;
        for(int i=s; i<f; i++) t[i]++;
  }
  /*cout << endl;
  for(int i=0; i<11; i++) cout << t[i] << " ";
  */
  for(int i=0; i<1000; i++) if(t[i]>=2) r++;
  if(r!=0) cout << 1 << endl;
  else cout << 0 << endl;

  return 0;
}

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;
}
 
int main(void){
  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 <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<=tsta)||(sta>=tend&&end>=tend))){
			jud = false;
			break;
		}
	}

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

	return 0;
}

C++: //============================================================================
// Name        : AOJ.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <algorithm>

using namespace std;

int main() {

	int a,b;
	cin>>a>>b;
	int n;
	cin>>n;
	int s,f;
	int flg=0;
	for(int i=0;i<n;++i){
		cin>>s>>f;
		if((a>=s&&a<f)||((b-1>=s)&&(b-1<f)))flg=1;
	}
	cout<<flg<<endl;
	return 0;
}

C++: //#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
using namespace std;
#define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i))
using ll = long long;
using P = pair<int, int>;
using namespace std;

// template<class T> void vin(vector<T>& v, int n) {
//     v.resize(n);
//     for (int i = 0; i < n; ++i) {
//         cin >> v[i];
//     }
// }

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

    int s[N], f[N];

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

    sort(s, s+N);
    sort(f, f+N);

    int si = 0;
    int fi = 0;
    int counter = 0;

    for (int i=0; i<1000; ++i)
    {
        if (si >= N) break;
        if (fi >= N) break;

        if (f[fi] == i) { --counter; ++fi; }

        if (a <= i && i <= b && counter != 0)
        {
            cout << 1 << endl;
            return 0;
        }

        if (s[si] == i) { ++counter; ++si; }
    }

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

C++: #include<iostream>
using namespace std;
int main(){
    int a,b,n,k[102],l[102],x=0;
    cin>>a>>b>>n;
    for(int i=1;i<=n;i++){
       cin>>k[i]>>l[i];
       if(b<=k[i]||l[i]<=a){
          x=0;
       }
       else{
          x=1;
          break;
       }
    }
    cout<<x<<endl;
    return 0;
}