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>  // g++ -std=c++14 -o a a.cpp

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end()) // ユニークなvectorにする。連続した値を除去して切り出す。
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {

  int reserves[1000] = {0};
  int a, b, N;
  cin >> a >> b >> N;

  rep(i, N) {
    int start, finish;
    cin >> start >> finish;
    for(int j = start; j < finish; j++ ) {
      reserves[j] = 1;
    }
  }

  bool isConflict = false;
  for(int j = a; j < b; j++ ) {
    if (reserves[j] == 1) {
      isConflict = true;
    } 
  }

  if (isConflict) {
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }

}

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

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>
#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;
        }
    }
    for(int i = a + 1; i < b; i++)
    {
        if(temp[i] == 1)
        {
            cout << 1 << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}

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

int main() {
  int a, b, n, s, f, t[1001] = {0};

  cin >> a >> b >> n;
  for (int i = 0; i < n; ++i) {
    cin >> s >> f;
    t[s] = 1;
    t[f] = 3;
    for (int j = s + 1; j < f; ++j) {
      t[j] = 2;
    }
  }
  
  if (t[a] != 2 && t[b] != 2) {
    for (int i = a + 1; i < b; ++i) {
      if (t[i] != 0) {
        cout << "1" << endl;
        return 0;
      }
    }
    cout << "0" << endl;
    return 0;
  }
  cout << "1" << endl;
}

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]]++;
		if (f[i] < 1000)t[f[i] + 1]--;
	}
	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 (i == a) {
			if (t[i] >= 1) {
				ans++;
				break;
			}
		}
		else if (i == b) {
			if (t[i] == 1 || t[i] < 0) {
				ans++;
				break;
			}
		}
		else {
			if (t[i] != 0) {
				ans++;
				break;
			}
		}
	}
	cout << ans << 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 j=s;j<=f;j++)
      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 <iostream>
#include <string.h>
#include <stdio.h>
using namespace std;
int main(void){
    int a,b;
    int n,s,f;
    int tim[1010]={0};
    cin>>a>>b;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s>>f;
        for(int j=s;j<f;j++){
            tim[j]=1;
        }
    }
    int ans=0;
    for(int i=a;i<b;i++){
        if(tim[i]==1){
            ans=1;
            break;
        }
    }
    cout<<ans<<endl;
}

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

int main() {
	int a,b,N,s[120]={0},f[120]={0},hantei=0;
	cin>>a>>b;
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>s[i]>>f[i];
		for(int j=s[i];i<=f[i];j++){
			if(j==a||j==b){
				hantei=1;
			}
		}
		for(int j=a;i<=b;j++){
			if(j==s[i]||j==f[i]){
				hantei=1;
			}
		}
	}
	cout<<hantei<<endl;
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define INF INT_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
 #define int long long
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a * b / gcd(a, b);};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
template<class T>inline bool chmax(T& a,T b){if(a < b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a > b){a=b;return true;}return false;};

bool overlap(int A, int B, int C, int D) {
  if(D <= A) return false;
  if(B <= C) return false;
  return true;
}

signed main() {
  cin.tie(0);
  cout.tie(0);
  ios::sync_with_stdio(false);

  int a, b;
  cin >> a >> b;
  int n;
  cin >> n;
  int s, f;
  rep(i, n) {
    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;
int main(){
  ios_base::sync_with_stdio(false);
  int a,b,n,x,y;
  bool flag = false;
  cin >> a >> b >> n;
  for(int i=0;i<n;i++){
    cin >> x >> y;
    if(x >= a && y <= b) flag = true;
  }

  if(flag) cout << 1 << endl;
  else cout << 0 << endl;

  return 0;
}