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>
#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=1005;
bool a[M];
int n,l,r;

int main(){
	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(l>=M) cout<<2<<endl;
		if(a[l]){
			cout<<1<<endl;
			return 1;
		}
		l++;
	}
	cout<<0<<endl;
}

C++: // 2017/09/21 Tazoe

#include <iostream>
using namespace std;

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

	int N;
	cin >> N;

	int 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 <bits/stdc++.h>
#include <assert.h>

using namespace std;

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

	return 0;
}

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

int main() {
	int a, b, N;
	cin >> a >> b;
	cin >> N;
	vector<int> s(N);
	vector<int> f(N);
	for (int i = 0; i < N; i++)
		cin >> s.at(i) >> f.at(i);

	for (int i = 0; i < N; i++){
		if (a < s.at(i) && s.at(i) < b&&a < f.at(i) && f.at(i) < b){
			cout << '1';
			break;
		}
		if (i == N - 1)
			cout << '0';
	}
}

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

vector<pair<int, int> > v;
int main() {
  int a, b, N;
  cin >> a >> b >> N;
  for(int i=0; i<N; i++){
    int s, f;
    cin >> s >> f;
    v.push_back(make_pair(s, f));
  }
  int ans=0;
  for(int i=0; i<N; i++){
    if(v[i].first < b && a < v[i].second) ans=1;
  }
  cout << ans << endl;
}

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++: #include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int a, b, n;
	cin >> a >> b >> n;
	vi s(n), f(n);
	vector<bool> can(1001, false);
	rep(i, 0, n) {
		cin >> s[i] >> f[i];
		rep(j, s[i] + 1, f[i]) {
			can[j] = true;
		}
	}
	rep2(i, a, b) {
		if (can[i]) {
			cout << 1 << endl;
			return 0;
		}
	}
	cout << 0 << endl;
}

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

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  int n;
  int s,e;
  cin >> a >> b;
  cin >> n;
  bool f=false;
  while(n--){
    cin >> s >> e;
    if((s<=a&&a<e)||(s<b&&b<=e)||(a<=s&&b>=e))
      f=true;
  }
    cout << f << endl;
  return 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++: #include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,N,s,e;
    bool yoyaku =true;
    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]<b&&E[i]>a){
            yoyaku =false;
            break;
        }
    }
    if(yoyaku){
        cout << 0 << endl;
    }else{
        cout << 1 << 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>
using namespace std;

int main(){
    int a, b, N;
    cin>>a>>b>>N;
    bool Z=0;
    int s,f;
    for(int i=0;i<N;i++){
        
        cin>>s>>f;
        if((f>a&&b>s)||(s<b&&a<f))
        Z=1;
    }

    cout<<Z<<endl;

    
    return 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]]++; t[f[i]]--;
	}
	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 (t[i] == 1) {
		ans++;
		break;
	}
	cout << ans << endl;

	return 0;
}

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

bool overlap(int a, int b, int c, int d){
  if ( d <= a ) return false;
  if ( b <= c ) return false;
  return true;
}
 
int main(){
  int a, b, s, f, n;
  cin >> a >> b >> n;
  for ( int i = 0; i < n; i++ ){
    cin >> s >> f;
    if ( overlap(a, b, s, f) ){
      cout << 1 << endl;
      return 0;
    }
  }
  cout << 0 << endl;
  return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int a, b, n;
    cin >> a >> b >> n;
    pair<int, int> new_record = {a, b};
    vector<int> temp(10001, 0);
    for(int i = 0; i < n; i++)
    {
        int s, f;
        cin >> s >> f;
        for(int j = s; j <= f; j++)
        {
            temp[j] = 1;
        }
    }
    bool flag = true;
    for(int i = a + 1; i < b; i++)
    {
        if(temp[i] == 1)
        {
            flag = false;
        }
    }
    if(flag)
    {
        cout << 0 << endl;
    }else{
        cout << 1 << endl;
    }
    return 0;
}