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;
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<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#define INF 2147483647
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int a,b;
  int n;
  cin>>a>>b>>n;
  int dp[1010]={};
  for(int i=0;i<n;i++){
    int s,f;
    cin>>s>>f;
    for(int i=s;i<=f;i++)
      dp[i]=1;
    dp[s]=2;
    dp[f]=3;
  }
  int flag=1;
  //cout<<flag<<endl;
  for(int i=0;i<1010;i++){
    if(dp[i]==2){
      while(dp[i+1]!=0){
	i++;
	dp[i]=1;
      }
      dp[i]=3;
    }
  }
  for(int i=a+1;i<b;i++)
    if(dp[i]==1){
      flag=0;
      break;
    }
  /*for(int i=0;i<1010;i++)
  cout<<dp[i]<<" ";
  cout<<endl;*/
  if(flag==0)
    cout<<1<<endl;
  else if(dp[a]==3)
    cout<<0<<endl;
  else if(dp[b]==2)
    cout<<0<<endl;
  else 
    cout<<0<<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 namespace std;
int 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 reserve[1100] = {};
  for (int i = a; i < b; i++) reserve[i]++;
  for (int i = 0; i < N; i++) {
    int s, f;
    cin >> s >> f;
    for (int j = s; j < f; j++) reserve[j]++;
  }

  for (int i = 0; i <= 1000; i++) {
    if (reserve[i] > 1) {
      cout << 1 << endl;
      return 0;
    }
  }

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

C++: #include <iostream>

int main()
{
    int a, b, N;
    std::cin >> a >> b >> N;
    bool dup = 0;
    for (int i = 0; i < N; i++) {
        int s, f;
        std::cin >> s >> f;
        for (int j = s; j < f; j++) {
            if (a <= j && j < b) {
                dup = 1;
            }
        }
    }
    std::cout << dup << std::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<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;
    cin >> a;
    cin >> b;
    cin >> N;

    int s[N], f[N];

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

    sort(s, s+N);
    sort(f, f+N);

    int si = 0;
    int fi = 0;
    int counter = 0;

    for (int i=0; i<1000; ++i)
    {
        if (si >= N) break;
        if (fi >= N) break;

        if (f[fi] == i) { --counter; ++fi; }

        if (a <= i && i <= b && counter != 0)
        {
            cout << 1 << endl;
            return 0;
        }

        if (s[si] == i) { ++counter; ++si; }
    }
    
    cout << 0 << 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(void){
  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++: //https://onlinejudge.u-aizu.ac.jp/challenges/sources/PCK/Prelim/0360?year=2017

#include <bits/stdc++.h>

using namespace std;

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

    int n;
    cin >> n;

    bool double_booked = false;
    for (int i = 0; i < n; ++i) {
        int s, f;
        cin >> s >> f;
        if (max(a, s) < min(b, f)) double_booked = true;
    }

    cout << (double_booked ? 1 : 0) << endl;
    return 0;
}

/*
 *
 */

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

int main(){

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

	for(int i = 0; i < N; i++){
		cin >> s >> f;
			//同じ時間を使用しているとき
			if(a == s && b == f) ans =1;
			//時間をすでに使用（被っている）させているとき
			for(int j = s+1; j < f; j++){
				if(a == j || b == j) ans = 1;
			}
			//時間の使い過ぎ
			for(int k = a+1; k < b; k++){
				if( k == s || k == f) ans = 1;
			}
	}

	cout << ans << endl;

	return 0;
}

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

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

  int N;
  cin >> N;

  int s,f;
  int ans[1000];
  for(int i=0;i<N;i++){
    cin >> s >> f;
    for(int j=s;j<=f;j++){
      ans[j]=1;
    }
  }

  if(ans[a+1]==1 || ans[b]==1){
    cout << '1' << endl;
  }else{
    cout << '0' << endl;
  }

  return 0;
}

C++: #include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#define INF 2147483647
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int a,b;
  int n;
  cin>>a>>b>>n;
  int dp[1010]={};
  for(int i=0;i<n;i++){
    int s,f;
    cin>>s>>f;
    for(int i=s;i<=f;i++)
      dp[i]=1;
    dp[s]=2;
    dp[f]=3;
  }
  int flag=1;
  //cout<<flag<<endl;
  for(int i=0;i<1010;i++){
    if(dp[i]==2){
      while(dp[i+1]==1){
	i++;
	dp[i]=1;
      }
      dp[i+1]=3;
    }
  }
  for(int i=a;i<=b;i++)
    if(dp[i]==1){
      flag=0;
      break;
    }
  /*for(int i=0;i<1010;i++)
  cout<<dp[i]<<" ";
  cout<<endl;*/
  if(flag==0)
    cout<<1<<endl;
  else if(dp[a]==3)
    cout<<0<<endl;
  else if(dp[b]==2)
    cout<<0<<endl;
  else 
    cout<<0<<endl;
  return 0;
}

C++: #include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

int main(){

	int start,end;
	scanf("%d %d",&start,&end);

	int N;
	scanf("%d",&N);

	int log_start,log_end;

	for(int loop = 0; loop <N; loop++){

		scanf("%d %d",&log_start,&log_end);
		if(log_end <= start || log_start >= end){
			//Do nothing
		}else{
			printf("1\n");
			return 0;
		}
	}

	printf("0\n");

	return 0;
}

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

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

  cin >> a >> b >> n;

  bool ans = false;
  while (n--) {
    int s, t;
    cin >> s >> t;

    if (t <= a || b <= s) continue;
    ans = true;
  }

  cout << ans << endl;
}