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<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<map>
#include<set>

using namespace std;

typedef long long ll;
typedef std::vector<int> VI;

#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())

int main() {

	int a, b, n, t[1001] = {}, ans = 0;
	cin >> a >> b;
	cin >> n;
	VI s(n), f(n);
	FOR(i, n) {
		cin >> s[i] >> f[i];
		t[s[i]]++;
		if (f[i] < 1000)t[f[i] + 1]--;
	}
	eFOR1(i, 1000)t[i] += t[i - 1];
	FOR(i, n) {
		t[s[i]] += 10;
		t[f[i]] -= 10;
	}
	for (int i = a; i <= b; i++) {
		if (i == a) {
			if (t[i] >= 1) {
				ans++;
				break;
			}
		}
		else if (i == b) {
			if (t[i] == 1 || t[i] < 0) {
				ans++;
				break;
			}
		}
		else {
			if (t[i] == 1) {
				ans++;
				break;
			}
		}
	}
	cout << ans << endl;

	return 0;
}

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;i++){
		cin>>c>>d;
		if(a<d){
			cout<<"1"<<endl;
			return 0;
		}
		if(c<b){
			cout<<"1"<<endl;
			return 0;
		}
	}
	cout<<"0"<<endl;
	return 0;
}

C++: #include <iostream>
using namespace	std;
int main(){

  int s1,e1,t[1001]={},q,s[1000],e[1000];
  cin>>s1>>e1>>q;
  for(int i=s1;i<e1;i++) t[i]=1;
  for(int i=0;i<q;i++) cin>>s[i]>>e[i];
  for(int i=0;i<q;i++){
    for(int j=s[i];j<e[i];j++) if(t[j]==1){
        cout<<1<<endl;
        return 0;
      }
  }
  cout<<0<<endl;
  return 0;

}

C++: #include <bits/stdc++.h>
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 sf[1010];

int main() {
    int a, b, n;
    cin >> a >> b >> n;
    priority_queue< P, vector<P>, greater<P> > que;
    rep(i, n) {
        int x, y;
        cin >> x >> y;
        que.push({x, y});
    }
    while (que.size()) {
        P p = que.top(); que.pop();
        sf[p.first]++;
        sf[p.second]--;
    }
    int tmp = 0;
    rep(i, b) {
        tmp += sf[i];
        if (i >= a) {
            if (tmp >= 1) {
                cout << 1 << endl;
                return 0;
            }
        }
    }
    cout << 0 << endl;
}

C++: #include <bits/stdc++.h>
typedef long long ll;
#define ALL(a) a, a+sizeof(a)/sizeof(a[0])
using namespace std;
ll gcd(ll n, ll m) {
	if (m == 0) return n;
	return gcd(m, n % m);
}

ll lcm(ll n, ll m) {
	return m / gcd(n, m) * n;
}

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

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

int main(){
  bool flag = false;
  int start,stop;
  cin >> start >> stop;
  int num;
  cin >> num;
  int book_start,book_stop;
  for(int i=0;i<num;i++){
    cin >> book_start >> book_stop;
    if(start>book_start && start<book_stop){
      flag = true;
    }
    if(stop>book_start && stop<book_stop){
      flag = true;
    }
  }

  cout << flag << endl;

}

C++: #include <iostream>
using namespace std;string w[7]={"thu","fri","sat","sun","mon","tue","wed"};
int main(){int i;cin>>i;cout<<w[i%7]<<endl;}

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

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

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

  int Flag=0;
  for(int i=a; i<b; i++){
    for(int j=0; j<N; j++){
      if(s[j]<=i && i<f[j]){
        Flag=1;
        break;
      }
    }
  }

  if(Flag==1){
    cout << "1" << endl;
  }else{
    cout << "0" << endl;
  }
  return 0;
}

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

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

C++: #include<bits/stdc++.h>
using namespace std;
 
int main(){
    int a,b,n;
    cin >> a >> b >> n;
    int l,r,ok = 0;
    for(int i = 0; i < n; i++){
        cin >> l >> r;
        if(l < a && a < r)ok = 1;
        if(l < b && b < r)ok = 1;
        if(l == a && r == b)ok = 1;
        if(l > a && r < b)ok = 1;
        if(l < a && r > b)ok = 1;
    }
    cout << ok << endl;
    return 0;
}

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

int main(){
  int a,b,n,t=0;
  cin >> a >> b >> n;
  int c[n*2];
  for(int i=0; i<n*2; i=i+2){
    int num,num2;
    cin >> num >> num2;
    if(num<=a&&num2>=a){
      t=1;
      break;
    }
    if(num<=b&&num2>=b){
      t=1;
      break;
    }
  }
  cout << t << 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;
		}
		c=0;
		d=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,f;
  int ans=0;
  for(int i=0;i<N;i++){
    cin >> s >> f;
    if(s<=a && a<f){
      ans++;
    }else if(s<b && b<=f){
      ans++;
    }
  }

  if(ans>0){
    cout << '1' << endl;
  }else{
    cout << '0' << endl;
  }

  return 0;
}

C++: #include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>


int main() {
	ll x, y;
	cin >> x >> y;
	ll n;
	cin >> n;
	REP(i, n) {
		ll a, b;
		cin >> a >> b;
		if (x <= a and a < y) {
			cout << 1 << endl;
			return 0;
		}
		if (x < b and b <= y) {
			cout << 1 << endl;
			return 0;
		}
		if (y <= b and a <= x) {
			cout << 1 << endl;
			return 0;
		}
	}
	cout << 0 << endl;
}