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 <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LL long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
//
int main(){
  int A,B;
  int N;
  cin>>A>>B>>N;
  FOR(i,0,N){
    int S,F;
    cin>>S>>F;
    if(S<=A&&B<=F){
      cout<<1<<endl;
      return 0; 
    }
  }
  cout<<0<<endl;
  return 0;
}

C++: #include<stdio.h>
#include<iostream>
using namespace std;
int main(void){
	bool flag=false;
	int a=0,b=0,n=0,s=0,f=0;
	cin>>a;
	cin>>b;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s;
		cin>>f;
		if((s<=a&&a<f)||(s<b&&b<=f)||(a<s&&b>f)){
			flag=true;
		}
	}
	if(flag){
		cout<<1<<endl;
	}
	else{
		cout<<0<<endl;
	}
	
	return (0);
}

C++: #include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
	int A,B;
	cin >> A >> B;
	int N;
	cin >> N;
	bool result = false;
	for(int a = 0;a < N;a++){
		int s,f;
		cin >> s >> f;
		if((s < A && A < f)||(s < B && B < f)){
			result = true;
		}
	}
	cout<<(result?1:0)<<endl;
}

C++: #include <iostream>
using namespace std;
typedef long long i64;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

/* include file*/
#include <functional>
#include <vector>
using namespace std;

typedef i64 Monoid;
struct Segment {

  vector<Monoid> node;
  Monoid ide;
  int n = 1;

  i64 bin_f(i64 a,i64 b){
    return a + b;
  };
  i64 update_f(i64 a,i64 b){
    return a + b;
  };

  Segment(const vector<Monoid>& init, Monoid ide_)
    : ide(ide_){
      int sz = init.size();
      while (n < sz) n *= 2;
      node.assign(n * 2 - 1, ide);
      for (int i = 0; i < sz; i++) node[i + n - 1] = init[i];
      for (int i = n - 2; i >= 0; i--)
        node[i] = bin_f(node[i * 2 + 1], node[i * 2 + 2]);
    }

  void update(int i, Monoid x) {
    i += n - 1;
    node[i] = update_f(node[i], x);
    while (i) {
      i = (i - 1) / 2;
      node[i] = bin_f(node[i * 2 + 1], node[i * 2 + 2]);
    }
  }

  Monoid get_inter(int a, int b, int k = 0, int l = 0, int r = -1) {
    if (r < 0) r = n;
    if (a <= l && r <= b) return node[k];
    if (r <= a || b <= l) return ide;

    Monoid lm = get_inter(a, b, k * 2 + 1, l, (l + r) / 2);
    Monoid rm = get_inter(a, b, k * 2 + 2, (l + r) / 2, r);
    return bin_f(lm, rm);
  }
};

// http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=2730414#1
// http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=2730425#1

i64 A,B;
int N;

i64 s[202];
i64 f[202];

int main(){
  cin >> A >> B >> N;
  Segment seg(vector<i64>(505,0),0);
  rep(i,1,N){
    cin >> s[i] >> f[i];
    if(s[i] == A){
      cout << 1 << endl;
      return 0;
    }
    rep(j,s[i],f[i] - 1){
      seg.update(j,1);
    }
  }
  if(seg.get_inter(A + 1,B) != 0){
    cout << 1 << endl;
  }
  else{
    cout << 0 << endl;
  }
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <cmath>
#include <numeric>
#include <iomanip>


#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;


// <<fixed<<setprecision(6)<<


int gcd(lint x, lint y){
  return y==0 ? x:gcd(y,x % y);
}


int combi(int n, int r){
  int num = 1;
  for(int i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}

int stringcount(string s, char c) {
  return count(s.cbegin(), s.cend(), c);
}

bool isPrime(int x){
  int i;
  if(x < 2)return 0;
  else if(x == 2) return 1;
  if(x%2 == 0) return 0;
  for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
  return 1;
}

int binary(vector<int> a,lint key) {
  lint left = 0;
  lint right = a.size();
  while(left<right){
    lint mid = (left+right)/2;
    if(a[mid] == key){
      return 1;
    }
    else if(key<a[mid]){
      right = mid;
    }
    else{
      left = mid+1;
    }
  }
  return 0;
}



int main(){
  pair<int,int> ne;
  cin>>ne.first>>ne.second;
  bool isyes=false;
  int n;
  cin>>n;
  vector<pair<int,int> > l(n+1);
  l[0]=ne;
  for(int i=1;i<=n;i++){
    int a,b;
    cin>>a>>b;
    l[i].first=a;
    l[i].second=b;
  }
  sort(all(l));
  stack<int> sta;
  for(int i=0;i<(n+1);i++){
    if(sta.empty()==true||sta.top()<=l[i].first){
      sta.push(l[i].first);
      sta.push(l[i].second);
    }
    else{
      isyes=true;
      break;
    }
  }
  if(isyes){
    cout<<"1"<<endl;
  }
  else{
    cout<<"0"<<endl;
  }
}

C++: // 2018/06/25 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<iostream>
#include<string>
using namespace std;
int a, b;
int n;
int s, f;
bool flag = true;
int main(){
	cin >> a >> b;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> s >> f;
		if(s <= a || a < f || s <= b || b < f){
			flag = false; 
		}
	}
	cout << (flag ? 0 : 1) << endl;
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <stdio.h>
#include <cstring>
#include <string.h>
#include <string>
#include <sstream>
#include <iomanip>

using namespace std;

int main (void)
{
	long a,b;
	long n,p[1000],q[1000],gg[1000];
	cin >> a >> b;

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

	for (int j = 1; j < n + 1; j++)
	{
		gg[j] = 0;
	}

	for (int i = 0; i < n; i++)
	{
		for (int j = p[i]; j < q[i]; j++)
		{
			gg[j] = -1;
		}
	}
	
	
	int co = 0;
	for (int i = a; i < b; i++)
	{
		if (gg[i] == 0)
		{
			co++;
			cout << "1" << endl;
			break;
		}
	}

	if (co == 0)
	{
		cout << "0" << endl;
	}
}

C++: #include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <stack>
using namespace std;

int main() {
	int A, B, N; cin >> A >> B >> N;
	pair<int, int>S;
	vector<int>C(1000, 0);
	for (int i = 0; i < N; i++) {
		cin >> S.first >> S.second;
		for (int j = S.first; j < S.second; j++)
		{
			C.at(j) = 1;
		}
	}
	int ans = 0;
	for (int i = A; i < B; i++) {
		ans += C.at(i);
	}
	if (ans == 0)cout << ans << endl;
	else cout << 1 << endl;
}