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;

#define int long long
#define INF 1e9
#define LINF 1e18

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<int, P> Pi;

typedef pair<P, P> PP;

const int MOD = 1e9 + 7;
const int dy[] = { 0, 0, 1, -1 };
const int dx[] = { 1, -1, 0, 0 };

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int a, b, N;
int app[1001];

signed main() {
	cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a, b, N;
    cin >> a >> b >> N;
    for(int i = 0; i < N; ++i) {
    	int s, f;
    	cin >> s >> f;
    	++app[s]; --app[f];
    }
    for(int i = 1; i <= 1000; ++i) app[i] += app[i - 1];
    for(int i = a; i < b; ++i) if(app[i]) {
    	cout << 1 << "\n";
    	return 0;
    }
    cout << 0 << "\n";
	return 0;
}

C++: #include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
using namespace std;
signed main() {
  int a,b,N;
  cin>>a>>b>>N;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    int s,f;
    cin>>s>>f;
    if ((s==a&&f==b) || (s<a&&a<f) || (s<b&&b<f) || (a<s&&s<b)) {
      ans=1;
      break;
    }
  }
  cout<<ans<<endl;
}

C++: #include<iostream>
using namespace std;
int main() {
	int a, b; cin >> a >> b;
	int n; cin >> n;
	bool b = false;
	for (int i = 0; i < n; i++) {
		int c, d; cin >> c >> d;
		if ((a < c&&c < b) || (a < d&&d < b)) {
			b = true;
		}
	}
	cout << b << endl;
}

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 (a < s.at(i) && s.at(i) < b&&a < f.at(i) && f.at(i) < b){
			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 N, M; 
	cin >> N >> M;
	cout << N % M << endl;
}*/

/*	int N;
	cin >> N;
	cout << -(N % 2)+1 ;
}*/

	/*int A, B, C, D, E ;
	cin >> A >> B >> C >> D >> E;
	cout << (A + B + C + D + E) / 5 ;
}*/

	/*int A, B, C, D ;
	cin >> A >> B >> C >> D;
	cout << (A + B + C + D) / 60 << endl << (A + B + C + D) % 60 << endl;
	*/

/*	int A,B;
	cin >> A >> B;
	cout << ( A + B ) / 2 << endl;*/

/*	int m, f, b;
	cin >> m >> f >> b;

	if ( m + f >= b && m <= b ){
		cout << b - m << endl;
	}
	
	if ( m + f > b && m > b ){
		cout << 0 << endl;
	}


	if ( m + f < b ){
		cout << "NA" << endl;
	}*/

/*	int X , x ;
	cin >> X ;

	x = X % 7 ;

	if ( x == 2 ){
		cout << "sat" << endl;
	}

	if ( x == 3 ){
		cout << "sun" << endl;
	}

	if ( x == 4 ){
		cout << "mon" << endl;
	}

	if ( x == 5 ){
		cout << "tue" << endl;
	}

	if ( x == 6 ){
		cout << "wed" << endl;
	}

	if ( x == 0 ){
		cout << "thu" << endl;
	}

	if ( x == 1 ){
		cout << "fri" << 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;
    cin>>a>>b;
    int N;
    cin>>N;
    int s[N];
    int f[N];
    for(int i=0;i<N;i++){
        cin>>s[i]>>f[i];
    }
    int i=0;
    int check=0;
    while(i<N){
        if(a<f[i]&&b>s[i]){
            check=1;
        }
        i++;
    }
    cout<<check<<endl;
    return 0;
}

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

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

C++: #include <iostream>

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

    int s, f;
    bool flag = true ;
    for ( int i = 0 ; i < n ; i++ )
    {
        std::cin >> s >> f ;
        if ( !( b <= s || f <= a ) )
            flag = false ;
    }

    if ( flag )
        std::cout << "0" << std::endl ;
    else
        std::cout << "1" << std::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 <stdio.h>
const int N=1e3+10;
int main(){
    int a,b,n,l,r;
    bool in[N];
    for(int i=0;i<N;i++)in[i]=false;
    scanf("%d%d%d",&a,&b,&n);
    while(n--){
        scanf("%d%d",&l,&r);
        for(int i=l;i<r;i++)in[i]=true;
    }
    for(int i=a;i<b;i++)if(in[i]){
        printf("1\n");
        return 0;
    }
    printf("0\n");
}

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>
#include<algorithm>
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	int n;
	cin >> n;
	int s[100], f[100];
	for (int i = 0;i < n;i++)cin >> s[i] >> f[i];
	int flag = 0;
	for (int i = 0;i < n;i++) {
		if (max(a, s[i]) < min(b, f[i])) {
			flag = 1;
			break;
		}
	}
	cout << flag << endl;
}