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>
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;
  rep(i,1,N){
    cin >> s[i] >> f[i];
    if(B <= s[i] || f[i] <= A){
    }
    else{
      cout << 1 << endl;
      return 0;
    }
  }
  cout << 0 << endl;
}

C++: #include<iostream>
using namespace std;
int main(){
    int a,b,n,k[101],l[101],x=0;
    cin>>a>>b>>n;
    for(int i=0;i<=n;i++){
       cin>>k[i]>>l[i];

       else if(k[i]>a&&l[i]<b){
          x=1;
          break;
       }
    }
    cout<<x<<endl;
    return 0;
}

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

int main(){
    vector<int> time(1010,0);
    int a,b;
    cin >> a >> b;
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        int st,en;
        cin >> st >> en;
        time[st]++;
        time[en]--;
    }
    for(int i = 1; i < 1010; i++){
        time[i] += time[i-1];
    }
    bool flag = true;
    for(int i = a; i < b; i++) if(time[i] != 0) flag = false;
    
    cout << (flag?0:1) << endl;
    return 0;
}

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

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

    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;

        if (x < b && a < y) {
            cout << 1 << endl;
            return 0;
        }
    }
    cout << 0 << endl;
}

C++: #include <bits/stdc++.h>
typedef long long ll;
#define ALL(a) a, a+sizeof(a)/sizeof(a[0])
using namespace std;
ll gcd(ll n, ll m) {
	if (m == 0) return n;
	return gcd(m, n % m);
}

ll lcm(ll n, ll m) {
	return m / gcd(n, m) * n;
}

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

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

int main(){
    int a,b,N,s,f,i;
    int dupe=0;
    cin>>a>>b;
    cin>>N;

    for(i=0;i<N;i++){
        cin>>s>>f;
        if((a>=s && a<f) || (b>s && b<=f) || (a<=s && b>=f))dupe=1;
    }

    cout<<dupe<<endl;    
    return 0;
}

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

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

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
#include <stack>
#include <deque>
#include <bitset>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<n;++i)

using ll = long long;
using namespace std;

const ll INF = 10000000000000000;
const ll MOD = 1000000007;
ll n, m, o, ans = 0, a, b;
int main() {
	cin >> n >> m >> o;
	rep(i, o) {
		cin >> a >> b;
		if (a > n&&a < m) ans = 1;
		else if (b > n&&b < m) ans = 1;
	}
	cout << ans << endl;
	return 0;
}

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

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

    cin >> a >> b >> n;

    int c[n], d[n];

    for( int i = 0; i < n; i++ )
        cin >> c[i] >> d[i];
    
    bool j = false;
    for( int i = 0; i < n; i++ )
    {
        if( d[i] <= a );
        else if( b <= c[i] );
        else
        {
            j = true;
            break;
        }
    }

    cout << j << 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<iostream>
using namespace std;

int main(){

	int a, b, N, s[1000],f[1000];
	int ans = 0;
	cin >> a >> b;
	cin >> N;

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

	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++){
			if(s[i] == f[j] || s[i] == a || s[i] == b) ans = 1;
		}
	}

	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 <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()
struct revran {
  const i64 b, e;
  struct iter {
    i64 i;
    constexpr iter(const i64 i) noexcept: i(i) {}
    void operator++() noexcept { --i; }
    constexpr i64 operator*() const noexcept { return i; }
    constexpr bool operator!=(const iter x) const noexcept { return i != x.i; }
  };
  constexpr revran(const i64 e) noexcept: b(0), e(e) {}
  constexpr revran(const i64 b, const i64 e) noexcept: b(b), e(e) {}
  constexpr iter begin() const noexcept { return iter(e - 1); }
  constexpr iter end() const noexcept { return iter(b - 1); }
};

struct ran {
  const i64 b, e;
  struct iter {
    i64 i;
    constexpr iter(const i64 i) noexcept: i(i) {}
    void operator++() noexcept { ++i; }
    constexpr i64 operator*() const noexcept { return i; }
    constexpr bool operator!=(const iter x) const noexcept { return i != x.i; }
  };
  constexpr ran(const i64 e) noexcept: b(0), e(e) {}
  constexpr ran(const i64 b, const i64 e) noexcept: b(b), e(e) {}
  constexpr iter begin() const noexcept { return iter(b); }
  constexpr iter end() const noexcept { return iter(e); }
  constexpr revran rev() const noexcept { return revran(b, e); }
};

constexpr ran rin(const i64 e) noexcept { return ran(1, e + 1); }
constexpr ran rin(const i64 b, const i64 e) noexcept { return ran(b, e + 1); }

int main() {
  i64 a, b;
  cin >> a >> b;
  int N;
  cin >> N;
  for(int c: ran(N)) {
    i64 s, f;
    cin >> s >> f;
    if(f <= a || b <= s);
    else {
      cout << 1 << endl;
      return 0;
    }
  }
  cout << 0 << endl;
  return 0;
}