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 ll long long 
int main(){
    int a,b,n;
    cin >>a >>b >>n;
    vector<vector<int> > vec(n,vector<int>(2));
    for(int i=0;i<n;i++){
        cin>>vec.at(i).at(0)>>vec.at(i).at(1);
        vec.at(i).at(0)++;
        vec.at(i).at(1)++;
    }
    vector<int> cat(1001,0);
    for(int i=0;i<n;i++){
        cat.at(vec.at(i).at(0)-1) ++;
        cat.at(vec.at(i).at(1)-1) --;
    }
    cat.at(a-1) ++;
    cat.at(b-1) --;
    vector<int> rsw(1001);
    rsw.at(0) =0;
    for(int i=1;i<1001;i++){
        rsw.at(i) = rsw.at(i-1) + cat.at(i-1);
        if(rsw.at(i)==2){
            cout <<1;
            break;
        }else if(i==1000){
            cout <<0;
        }
    }
    cout << endl;
    
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
#include<numeric>
#include<stack>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1LL<<60;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

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

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,n,s,f;
  int t[1001]={};
  int q[1001]={};
  cin >> a >> b >> n;
  for(int i=0; i<n; i++){
        cin >> s >> f;
        for(int j=s; j<f+1; j++){
          t[j] = 1;
          q[s] = 1; q[f] = 2;
        }
  }
  /*for(int i=0; i<11; i++){
    cout << t[i]  <<  " ";
    if(i==10) cout << endl;
  }
  for(int i=0; i<11; i++){
    cout << q[i] << " ";
  }*/
        if(t[a]==0 && t[b]==0 || q[a]==2 && q[b]==1) cout << 0 << endl;
        else cout << 1 << endl;

  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int a, b, N;
    cin >> a >> b >> N;
    int s[N], f[N];
    for (int i = 0; i < N; i++) {
        cin >> s[i] >> f[i];
    }
    for (int i = 0; i < N; i++) {
        if (b <= s[i] || f[i] <= a) continue;
        cout << "1\n";
        return 0;
    }
    cout << "0\n";
    return 0;
}

C++: #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

/*
<url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0360>
?????????============================================================
 ??°??£????????¶???????????¨?????????????????????????????\???????????¨?????????????????¶????????¨???????\??????§???????????????????????????????§????????¨????????????£???????????????
 ??¨???????????¨??????????´????????????§???????´??????????????§?????????¨???????????????????????????????????????????????°??????????´?????????????????????????????????????
 
 ??°??????????´????????????§????????¨??????????´???????????????¨????????????????????±?????????????????°????????????????????????
 ??????????????????????´??????????????????¨?????\???????´????????§??????????????????´???????????????????????¨??????????????????
 ???????????????????????????????????¨???????????¨????§?????????????????????°??§??????????????????
 
=================================================================

?§£??¬=============================================================
imos??§??????
================================================================
*/
ll imos[1010];
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    ll a,b; cin >> a >> b;
    ll N; cin >> N;
    for(int i = 0; i < N;i++){
        ll s,f; cin >> s >> f;
        imos[s]++; imos[f]--;
    }
    for(int i = 1; i < 1010;i++) imos[i] += imos[i-1];
    for(int i = a; i < b;i++){
        if(imos[i] == 1){
            cout << 1 << endl;
            return 0;
        }
    }
    cout << 0 << endl;
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i))
using ll = long long;
using P = pair<int, int>;
using namespace std;

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int sf[1010];

int main() {
    int a, b, n;
    cin >> a >> b >> n;
    priority_queue< P, vector<P>, greater<P> > que;
    rep(i, n) {
        int x, y;
        cin >> x >> y;
        que.push({x, y});
    }
    while (que.size()) {
        P p = que.top(); que.pop();
        sf[p.first]++;
        sf[p.second]--;
    }
    int tmp = 0;
    rep(i, b) {
        tmp += sf[i];
        if (i >= a) {
            if (tmp >= 1) {
                cout << 1 << endl;
                return 0;
            }
        }
    }
    cout << 0 << endl;
}

C++: #include <iostream>

using namespace std;

int main()
{
	int a, b;
	int N;
	int s, f;

	cin >> a >> b;
	cin >> N;

	int ret = 0;	// 良い
	for (int i = 0; i < N; i++) {
		cin >> s >> f;

		if ( ! (b <= s || f <= a) ) {
			ret = 1;	// ダメだった
		}
	}
	cout << ret << 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;
    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<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iomanip>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)
#define FOR(i,a,n) for(int i=a; i<n; i++)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

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

	bool ans = true;
	rep(i, n) {
		int s, f;
		cin >> s >> f;
		if ((a <= s && f < b) || (s <= a && f >= b) || (a <= s && f >= b))ans = false;
	}
	if (ans)cout << 0 << endl;
	else cout << 1 << endl;
	return 0;
}

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

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

  int A[1000] = {0};
  int count1 = 0,count2 = 0;
  for(int i = a; i < b; i++){
    A[i] = 1;
    count1++;
  }

  int x,y;
  for(int i = 0; i < N; i++){
    cin >> x >> y;
    for(int i = x; i < y; i++){
      A[i] = 0;
    }
  }

  for(int i = 0; i < 1000; i++){
    if(A[i] == 1)count2++;
  }
  if(count1 == count2)cout << '0' << endl;
  else cout << '1' << endl;

  return 0;
}