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

C++: #include<bits/stdc++.h>
#define loop(times) for(int i=0;i<times;i++)
using namespace std;


int main()
{
    int a,b,N,t=1;
    cin>>a>>b>>N;
    
    int s[N],f[N];
    int p[1001];
    int c[1001];
    loop(1000)p[i]=0,s[i]=0;
    
    loop(N){
        cin>>s[i]>>f[i];
        p[s[i]]+=1;
        p[f[i]]-=1;
    }
    p[a]+=1;
    p[b]-=1;
    if(c[0]==2){
    cout<<1<<endl;
    t=0;
    }
    loop(1000){
    c[i+1]=c[i]+p[i];
    if(c[i+1]==2){
    cout<<1<<endl;
    t=0;
    break;
    }
    }
    if(t==1)cout<<0<<endl;
}

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

int main() {
  int a, b, N; cin >> a >> b >> N;
  vector<int> s(N + 1), f(N + 1), time(1001);
  for (int i = 1; i <= N; i++) {
    cin >> s[i] >> f[i];
    for (int j = s[i]; j < f[i]; j++) time[j]++;
  }
  for (int j = a; j < b; j++) time[j]++;
  int is_zero = 0;
  for (int i = 0; i <= 1000; i++) if (time[i] >= 2) is_zero = 1;
  if (is_zero) cout << 1 << endl;
  else cout << 0 << endl;
  return 0;
}