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;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-10;
const bool debug = 0;
//------------------------------//

int main() {
	int a, b, N;
	cin >> a >> b >> N;
	
	bool ans = false;
	REP(i, N) {
		int s, f;
		scanf("%d %d", &s, &f);
		
		ans |= a < s && f < b;
		ans |= s < a && a < s;
		ans |= f < b && b < f;
	}
	
	printf("%d", (int)ans);
	
	return 0;
}

C++: #include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

const int M=10005;
bool a[M];
int n,l,r;

int main(){
	fill(a,a+M,0);
	cin>>l>>r>>n;
	for(int i=0;i<n;i++){
		int L,R;
		cin>>L>>R;
		while(L<R) a[L++]=1;
	}
	while(l<r){
		if(a[l]){
			cout<<1<<endl;
			return 1;
		}
		l++;
	}
	cout<<0<<endl;
}

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

using namespace std;

int main() {
    bool t=1;
    while(t){
    int a,b,N;

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

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

int main(){
  int a,b,n,c;
  cin>>a>>b>>n;
  for(int i=0;i<n;i++){
    int s=0,f=0;
    cin>>s>>f;
    for(int j=a;j<b;j++){
      for(int k=s;k<f;k++){
        if(j==k){
          c=1;
        }
      }
    }
  }
  cout<<c<<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;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<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){
    cout << '1' << endl;
  }else{
    cout << '0' << endl;
  }


  return 0;
}

C++: #include <bits/stdc++.h>

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main () {
	int a = ri(), b = ri();
	int n = ri();
	bool res = false;
	for (int i = 0; i < n; i++) {
		int s = ri(), t = ri();
		if (s >= b || t <= a) continue;
		res = true;
	}
	std::cout << res << std::endl;
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
/*
using ll = long long;
using p = pair<int, int>;
using P = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using pq = priority_queue<int>;
using Graph = VV;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int Inf = (1 << 30);
ll inf = (1LL << 60);
const int MOD = 1e9 + 7;
*/
typedef vector<int> V;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
int main() {
	int a, b;
	cin >> a >> b;
	int q;
	cin >> q;
	vector<bool> order(1100,false);
	rep(iii,q){
	    int x,y;
	    cin >> x >> y;
	    for(int i=x;i<=y;i++) order[i]=true;
	}
	bool cheak=false;
	for(int i=a;i<=b;i++){
	    if(i==a){
	        if(order[i] && order[i+1]) cheak=true;
	    }
	    else if(i==b){
	        if(order[i-1] && order[i]) cheak=true;
	    }
	    else{
	        if(order[i]) cheak=true;
	    }
	}
	cout << cheak << 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<iostream>
using namespace std;

int main()
{
	int i, a, b, N, s[100], f[100], F = 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]) {
			F = 1;
		}
		else if (s[i]<b && b<f[i]) {
			F = 1;
		}
		else if (a <= s[i] && f[i] <= b) {
			F = 1;
		}
	}
	cout << F << endl;
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <queue>
#include<map>
#include<algorithm>
#include<set>
#include<iomanip>
#define rep(i,n) for(int i = 0;i < n;i++)
#define req(i,n) for(int i = 1; i<=n;i++)
#define rrep(i,n) for(int i = n-1;i >=0;i--)
#define ALL(a) a.begin(),a.end()
#define PI  acos(-1)
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
    std::fill((T*)array, (T*)(array + N), val);
}
typedef long long int ll;
typedef long double ld;
const int MOD = 1e9 + 7;
int dx[4] = { 0,0,1,-1 }, dy[4] = { 1,-1,0,0 }, sum = 0,h,w;
int main() {
    int n,A,B,x,y; cin >>A>>B>> n;
    vector<int> a(1010, 0);
    rep(i, n) {
        cin >> x >> y;
        for (int j = x; j < y; j++)a[j]++;
    }for (int j = A; j < B; j++)a[j]++;
    rep(i, 1005) {
        if (a[i] > 1) {
            cout << 1 << endl;
            return 0;
        }
    }cout << 0 << endl;
}