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<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int a, b, n;
	cin >> a >> b >> n;
	vi s(n), f(n);
	rep(i, 0, n) {
		cin >> s[i] >> f[i];
	}
	rep(i, 0, n) {
		if (a == s[i] || b == f[i]) {
			cout << 1 << endl;
			return 0;
		}
		else if ((s[i] < a&&a < f[i]) || (s[i] < b&&b < f[i])) {
			cout << 1 << endl;
			return 0;
		}
	}
	cout << 0 << endl;
}

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

#include <iostream>
using namespace std;

int main() {
	int a,b,c,d,n;
	cin>>a>>b;
	cin>>n;
	for(int i=0;i<n+1;i++){
		cin>>c>>d;
		if(a<d&&d<b){
			cout<<"1"<<endl;
			return 0;
		}
		if(c<b&&a<c){
			cout<<"1"<<endl;
			return 0;
		}
		if(a==c&&b==d){
			cout<<"1"<<endl;
			return 0;
		}
		if(c<a&&b<d){
			cout<<"1"<<endl;
			return 0;
		}
	}
	cout<<"0"<<endl;
	return 0;
}

C++: #include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }

int main(){
    INT(a,b);
    INT(n);
    int ans=0;
    while(n--){
        INT(start,end);
        if(start<a&&a<end){
            ans=1;
            break;
        }
        if(start<b&&b<end){
            ans=1;
            break;
        }
        if(a<=start&&end<=b){
            ans=1;
            break;
        }
    }
    out(ans);
}

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

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

C++: #include<bits/stdc++.h> 
using namespace std;
int main(){
  int i, a, b, N, s[100], f[100], Flag=0;
  cin>>a>>b;
  cin>>N;
  for(i=0; i<N; i++){cin>>s[i]; cin>>f[i];}
  for(i=0; i<N; i++){
    if(s[i]<a && a<f[i]){
       Flag=1;
    }else if(s[i]<b && b<f[i]){
      Flag=1;
    }else if(a<=s[i] && f[i]<=b){
      Flag=1;
    }
  }
  cout<<Flag<<endl;
  return 0;
}

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

int main(){
    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 <cstdio>

int main() {
  int a, b, n;
  scanf("%d %d %d", &a, &b, &n);

  for (int i = 1; i <= n; ++i) {
    int s, f;
    scanf("%d %d", &s, &f);

    if (b <= s || f <= a) continue;
    return puts("1"), 0;
  }
  puts("0");
}

C++: #include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int a, b, n;
    cin >> a >> b >> n;
    pair<int, int> new_record = {a, b};
    vector<int> temp(10001, 0);
    for(int i = 0; i < n; i++)
    {
        int s, f;
        cin >> s >> f;
        for(int j = s; j <= f; j++)
        {
            temp[j] = 1;
        }
    }
    for(int i = a + 1; i < b; i++)
    {
        if(temp[i] == 1)
        {
            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;
  while(1){
    cin >> s >> f;
    i++;
    if((a != s && b != f) && (s <= a || s >= b) && (f <= a || f >= b)){
      cout << '1' << endl;
      break;
    }
    if(++i == n){
      cout << '0' << endl;
      break;
    }
  }
}

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

C++: #include<iostream>
#include<vector>
using namespace std;
bool func(vector<int> &check){
	int N;
	cin>>N;
	for(int i=0;i<N;++i){
		int a,b;
		cin>>a>>b;
		for(int i=a;i<b;++i){
			if(check[i]){
				return false;
			}
		}
	}
	return true;
}
int main(){
	int a,b;
	cin>>a>>b;
	vector<int> check(1001,false);
	for(int i=a;i<b;++i){
		check[i]=true;
	}
	cout<<(func(check)?1:0)<<endl;
	return 0;
}

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

const int MAX = 1e3;
int main() {
    vector<int> imos(MAX + 1);
    int a, b; cin >> a >> b;
    imos[a]++, imos[b]--;
    int n; cin >> n;
    while (n--) {
        int s, f; cin >> s >> f;
        imos[s]++, imos[f]--;
    }
    for (int i = 1; i <= MAX; i++) imos[i] += imos[i - 1];
    for (int i = 0; i <= MAX; i++) if (imos[i] > 1) {
        cout << 1 << endl;
        return 0;
    }
    cout << 0 << endl;
    return 0;
}