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;

int main(){
  int a, b;
  cin >> a >> b;
  int N;
  cin >> N;
  bool ok = false;
  for(int i=0;i<N;++i){
	int s, f;
	cin >> s >> f;
	if(!(b <= s || f <= a))
	  ok = true;
  }
  cout << ok << endl;
  
  return 0;
}

C++: #include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#define INF 2147483647
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int a,b;
  int n;
  cin>>a>>b>>n;
  int dp[1010]={};
  for(int i=0;i<n;i++){
    int s,f;
    cin>>s>>f;
    for(int j=s;j<=f;j++)
      dp[j]=1;
    dp[s]=2;
    dp[f]=3;
  }
  int flag=1;
  //cout<<flag<<endl;
  for(int i=0;i<1010;i++){
    if(dp[i]==2){
      while(dp[i+1]==1){
	i++;
	dp[i]=1;
      }
      dp[i+1]=3;
    }
  }
  for(int i=a;i<=b;i++)
    if(dp[i]==1){
      flag=0;
      break;
    }
  /*for(int i=0;i<1010;i++)
  cout<<dp[i]<<" ";
  cout<<endl;*/
  if(flag==0)
    cout<<1<<endl;
  else if(dp[a]==3)
    cout<<0<<endl;
  else if(dp[b]==2)
    cout<<0<<endl;
  else 
    cout<<0<<endl;
  return 0;
}

C++: # include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
# include <array>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using D = double;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_num(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define RALL(qpqpq)           (qpqpq).rbegin(),(qpqpq).rend()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define RFOR(i,tptpt,ypypy)  for(LL i=(tptpt);i>=(ypypy);i--)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int a, b;
int n;
int s[1010], t[1010];

int main() {
	cin >> a >> b >> n;
	bool isng = false;
	REP(i, n) {
		cin >> s[i] >> t[i];
		if ((s[i]<=a&&a < t[i]) || (s[i] < b&&b<=t[i])||(a<=s[i]&&t[i]<=b)) {
			isng = true;
		}
	}
	cout << (isng ? 1 : 0) << endl;
}

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

int main(){

	int a, b, N, s, f;
	int ans = 0;
	cin >> a >> b;
	cin >> N;

	for(int i = 0; i < N; i++){
		cin >> s >> f;
			for(int j = s+1; j < f; j++){
				if(a == j || b == j) ans = 1;
			}
	}

	cout << ans << endl;

	return 0;
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define ct(string) cout << string << endl

int main() {
    ios::sync_with_stdio(false);
    int a,b,n,c,d,ans=0;
    cin >> a >> b >> n;
    vector<bool> book(1000, false);
    rep(i,n) {
        cin >> c >> d;
        for (int j=c; j<d; j++) book.at(j) = true;
    }
    for (int i=a; i<b; i++) {
        if (book.at(i)) {ans++;break;}
    }
    cout << ans << endl;
}

C++: #include<iostream>
#include<algorithm>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
    int a,b,n;
    bool ok=true;
    cin>>a>>b>>n;
    lol(i,n){
	int x,y;cin>>x>>y;
	if(a<=x&&x<b)ok=false;
	if(a<y&&y<=b)ok=false;
    }
    cout<<1-ok<<endl;
    return 0;
}

C++: #include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<math.h>
#include<vector>
#include<algorithm>
#include<map>
#include<unordered_map>
#pragma warning(disable: 4996)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep2(j,a,b) for(int j = a; j < (b); j++)
using namespace std;
using ll = long long;

int r[1001];

int main() {

	int a, b;
	int N;
	cin >> a >> b >> N;
	vector<int> s(N);
	vector<int> f(N);
	rep(i, N) {
		cin >> s[i] >> f[i];
		rep2(j, s[i], f[i]) {
			r[j] = 1;
		}
		r[f[i]] = 2;
   }
	int ans = 0;
	rep2(i, a, b) {
		if (r[i] == 1 || r[i] == 2) {
			ans = 1;
			break;
		}
	}
	if (r[a] == 2) {
		ans = 0;
	}
	cout << ans << 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[1000];
  for(int i=0;i<N;i++){
    cin >> s >> f;
    for(int j=s;j<=f;j++){
      if(j==s){
        ans[j]=2;
      }else if(j==f){
        ans[j]=3;
      }else{
        ans[j]=1;
      }
    }
  }
  if((ans[a]==1 || ans[b]==1) || (ans[a]==2 && ans[b]==3)){
    cout << '1' << endl;
  }else{
    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 <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <stack>
#include <cmath>
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
using namespace std;
//
const int inf=1e9+7;
const int mod=1e9+7;
//
struct poi{
	int X;int Y;int Z;
	bool operator<(const poi&R)const{
		return X==R.X ? Y==R.Y ? Z<R.Z : Y<R.Y : X<R.X;
	}
};
//
ll GCD(ll a,ll b){
	return (b==0)?(a):(GCD(b,a%b));
}
ll LCM(ll a,ll b){
	return a/GCD(a,b)*b;
}
//
int main(){
	int A,B;
	int N;
	cin>>A>>B>>N;
	FOR(i,0,N){
		int S,F;
		cin>>S>>F;
		if(F<=A||B<=S){
			continue;
		}else{
			cout<<1<<endl;
			return 0;
		}
	}
	cout<<0<<endl;
	return 0;
}

C++: #include<stdio.h>
int main()
{
	int a,b,n;
	int s,f,i,j;
	int list[1024];
	for(i=0;i<1024;i++){
		list[i]=0;
	}
	scanf("%d%d%d",&a,&b,&n);
	for(i=0;i<n;i++){
		scanf("%d%d",&s,&f);
		for(j=s+1;j<f;j++){
			list[j]=1;
		}
	}
	for(i=a;i<=b;i++){
		if(list[i]==1){
			printf("1\n");
			return 	0;
		}
	}
	printf("0\n");
	return 0;
}