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;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vp;
typedef map<ll, ll> mll;
typedef map<string, ll> mstrll;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fir first
#define sec second
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
#define out(x) cout << (x)
#define indent() cout << '\n'
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
ll gcd(ll a, ll b){return b != 0 ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}
const ll INF = 1e16;
const ll MOD = 1e9 + 7;
ll a, b, c, n, m, x, y, z, w, h, ans, cnt, mx, mn;
string s, t;
ll dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};
//vll dx = {-1, 0, 1, -1, 1, -1, 0, 1}, dy = {-1, -1, -1, 0, 0, 1, 1, 1};
string alphabet = "abcdefghijklmnopqrstuvwxyz";

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> a >> b >> n){
        rep(i, n){
            cin >> x >> y;
            if(x < b && y > a){
                print(1);
                return 0;
            }
        }
        print(0);
    }
}

C++: #include<algorithm>
#include<cstdio>
#include<cmath>
#include<iostream>
using namespace std;
int main(void){
	int a,b,N,s,f,ans=0;
	cin>>a>>b>>N;
	for(int i=0;i<N;i++)
	{
		cin>>s>>f;
		if(a<=s&&s<b)
		{
			ans=1;
		}
		if(a<f&&f<=b)
		{
			ans=1;
		}
		if(s<=a&&a<f)
		{
			ans=1;
		}
		if(s<b&&b<=f)
		{
			ans=1;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, init, n) for (int i = init; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define fi first
#define se second

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to, cost;
};

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int a, b, N;
    cin >> a >> b >> N;
    vector<int> s(N), f(N);
    REP(i, N) cin >> s[i] >> f[i];

    REP(i, N)
    {
        FOR(j, s[i], f[i])
        {
            if(a <= j && j < b)
            {
                cout << 1 << endl;
                return 0;
            }
        }
    }

    cout << 0 << endl;

    return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int a,b,n;
	cin >> a >> b >> n;
	for(int i=0; i<n; i++){
		int s,f;
		cin >> s >> f;

		if(a>=s && a<f){
			cout << 1 << endl;
			return 0;
		}
		if(b>s && b<=f){
			cout << 1 << endl;
			return 0;
		}
		
	}
	cout << 0 << endl;
	return 0;
}

C++: #include<iostream>
#include<stdbool.h>
using namespace std;
int main(){
  int a,b;
  int n;
  cin>>a>>b;
  cin>>n;
  bool flag=false;
  for(int i=0;i<n;i++){
    int x,y;
    cin>>x>>y;
    if((a<x&&x<b)||(a<y&&y<b)||(x<=a&&b<=y)){
      flag=true;
    }
  }
  if(flag){
    cout<<1<<endl;
  }else{
    cout<<0<<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 s, e;
		cin >> s >> e;
		if (!(s >= b || e <= a)) {
			cout << 1 << endl;
			return 0;
		}
	}
	cout << 0 << endl;
	return 0;
}

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

/*	int N, C, c[100], n;
	cin >> N;
	C = 0;
	n = 0;

	for (int i = 0; i <N; i++ ){
		cin >> c[i];
		C+= c[i];
	}

	for (int i = 0; i <N; i++ ){
		if (c[i] <= 0.1*C){
			n+= 30;
		}
	}
	cout << n << endl;
}
	/*
	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] || s[i] >= a && f[i] <= b ){
			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;
    if(s==b || f==a){
      ans[i] = 0;
    }else if(f-s==1 && s<=a && f>=b){
      ans[i] = 1;
    }else{
      for(int j=s+1;j<f;j++){
        if(f-s != 1){
          ans[j] = 1;
        }
      }
    }
  }

  int an=0;

  for(int i=a;i<=b;i++){
    if(ans[i]==1){
      an++;
    }
  }

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

  return 0;
}

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

int main(){
    short a,b,n;
    cin>>a>>b>>n;
    bool R[10001];
    for(int i=0;i<=10001;i++){
        R[i]=false;
    }
    for(int i=1;i<=n;i++){
        short s,f;
        cin>>s>>f;
        for(int j=s+1;j<=f-1;j++){
            R[j]=true;
        }
    }
    for(int i=a;i<=b;i++){
        if(R[i]==true){
            cout<<1<<endl;
            return 0;
        }
    }
    cout<<0<<endl;
	return 0;	
}

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

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