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

using namespace std;

typedef long long ll;
#define put(n) cout<<(n)<<"\n"
#define FOR(i,num,N) for(int(i)=(num);(i)<(N);++(i))
#define RFOR(i,num,N) for(int (i)=(num);(i)>(N);--(i))
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()

int A,B,N,S,F,ans;
vector<bool> sub(1001);

int main(){
    cin>>A>>B>>N;
    FOR(i,A,B+1) sub[i] = true;
    FOR(i,0,N){
        cin>>S>>F;
        FOR(i,S,F+1){
            if(S==B || F == A) break;
            if(sub[i]) ans = 1;
        }
    }
    
    cout<<ans<<endl;
}

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

int main()
{
	int a, b;
	int n;
	bool isDuplicate = false;

	cin >> a >> b;
	cin >> n;

	for (int i = 0; i < n; i++)
	{
		int s, f;
		cin >> s >> f;

		if (a <= s && s < b) isDuplicate = true;
		if (s <= a && a < f) isDuplicate = true;
		if (a < f && f <= b) isDuplicate = true;
		if (s < b && b <= f) isDuplicate = true;
	}

	cout << isDuplicate << endl;

	return 0;
}

C++: #include <stdio.h>
#include <iostream>
#include <string>
#include <math.h>

using namespace std;

int main()
{
	int new_start, new_end;
	int no;

	cin >> new_start >> new_end;
	cin >> no;
	
	for (int i = 0; i < no; i++)
	{
		int started, ended;
		cin >> started >> ended;
		
		if (new_end > started && new_start < ended)
		{
			cout << 1 << endl;
			return 0;
		}
	}

	cout << 0 << endl;
}

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;
    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<cstdio>
#define false 1
#define true 0
using namespace std;
int main (){
int a,b,N,s,f,ans=true;
cin>>a>>b;
cin>>N;
for (int i=0;i<N;i++){
        cin>>s>>f;
        if ( (s<=a&&f>=b) || (s>a&&s<b) || (f<b&&f>a) ){
                ans=false;
        }
        //cout<<ans<<"CHECK"<<endl;
        //ans=true;
}

cout<<ans<<endl;
return 0;
}

C++: #include<stdio.h>
#include<iostream>
using namespace std;
int main(){
  int a=0,b=0,N=0,i=0,k=0,j=0;
  int s[110],f[110],x[1010],y[1010];
  cin>>a>>b;
  cin>>N;
  for(i=0;i<N;i++){
    cin>>s[i]>>f[i];
    for(j=s[i];j<=f[i];j++){
      x[j]=j;
    }
  }
  for(k=a+1;k<b;k++){
    y[k]=k;
  }
  for(j=s[i];j<=f[i];j++){
    for(k=a+1;k<b;k++){
      if(x[j]==y[k]){
	printf("0\n");
	return 0;
      }
      else {
	printf("1\n");
	return 0;
      }
    }
  }
  return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
  int a,b,n,s,f,i=0;
  cin >> a >> b >> n;
  do{
    cin >> s >> f;
    i++;
  }while((s <= a && s >= b) && (f <= a && s >= b));
  if(n == i-1){
    cout << '0' << endl;
  } else {
    cout << '1' << endl;
  }
}

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vii;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(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; }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

// ────────────────────────────────────────────────────

bool isUruu(int y) {
	bool ok = true;

	if (y % 4 == 0) {
		if (y % 100 == 0) ok = false;
		if (y % 400 == 0) ok = true;
	}
	else ok = false;

	return ok;
}

int main() {
	int a, b;
	cin >> a >> b;

	int n;
	cin >> n;

	vi s(n), f(n);
	rep(i, n) {
		cin >> s[i] >> f[i];

		if (s[i] < b && a < f[i]) {
			cout << 1 << endl;
			return 0;
		}
	}
	cout << 0 << endl;
}

/*

	string s, t, u, v;
	cin >> s;

	t.push_back(s[0]);
	t.push_back(s[1]);
	t.push_back(s[2]);
	t.push_back(s[3]);
	u.push_back(s[5]);
	u.push_back(s[6]);
	v.push_back(s[8]);
	v.push_back(s[9]);

	int y = atoi(t.c_str());
	int m = atoi(u.c_str());
	int d = atoi(v.c_str());

*/

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

typedef long long ll;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll n, a, b, s, f, result = 0;
   cin >> a >> b >> n;
   rep(i, n) {
     cin >> s >> f;
     if (a < f && f < b) result = 1;
     if (a < s && s < b) result = 1;
   }
   cout << result << endl;
	return 0;
}

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

int main ()
{
	long a,b,n,aa[100],bb[100];

	cin >> a >> b >> n;
	if (n == 0)
	{
		cout << '0' << endl;
		break;
	}

	for (int i = 0; i < n; i++)
	{
		cin >> aa[i] >> bb[i];
	}

	for (int i = 0; i < n; i++)
	{
		if (aa[i] <= a && bb[i] > a)
		{
			cout << '1' << endl;
			break;
		}
		else if (aa[i] < b && bb[i] >= b)
		{
			cout << '1' << endl;
			break;
		}
		else if (a <= aa[i] && bb[i] <= b)
		{
			cout << '1' << endl;
			break;
		}
		else if (i == n - 1)
		{
			cout << '0' << endl;
		}
	}
}

C++: #include<iostream>
using namespace std;
int main(){
    int a,b,n,k[100],l[100],x;
    cin>>a>>b>>n;
    for(int i=0;i<=100;i++){
       cin>>k[i]>>l[i];
       if(k[i]<a&&a<l[i]){
          x=1;
          break;
       }
       else if(k[i]<b&&b<l[i]){
          x=1;
       break;
       }
       else if(k[i]>=a&&l[i]<=b){
          x=1;
          break;
       }
       else x=0;
    }
    cout<<x<<endl;
    return 0;
}

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

int main(){
  int a,b,n;
  cin >> a >> b >> n;

  bool flg=0;
  for(int i=0; i<n; i++){
    int s,f;
    cin >> s >> f;

    if(f<=a || b<=s){
      continue;
    }else{
      flg=1;
    }
  }

  cout << flg << endl;

  return 0;
}

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

C++: #include <iostream>
using namespace std;
int main(){
  int a,b,n,s,f,i=0;
  cin >> a >> b >> n;
  do{
    cin >> s >> f;
    i++;
  }while((a != s && b != f) && (s <= a || s >= b) && (f <= a || f >= b) && i<n);
  if(n == i-1){
    cout << '0' << endl;
  } else {
    cout << '1' << endl;
  }
}