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 {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)
	}
}

		fmt.Println(0)
	}
}

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

int main(){
  int a,b;
  cin>>a>>b;
  int N;
  cin>>N;
  int tmp_s,tmp_e;
  bool flag=false;
  for(int i=0;i<N;i++){
    cin>>tmp_s>>tmp_e;
    if(a<tmp_e&&b>tmp_s)flag=true;
    else if(a==tmp_e&&b==tmp_s)flag=true;
  }
  cout<<flag<<endl;
}

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[j]=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||dp[i+1]==2){
	i++;
	dp[i]=1;
      }
      dp[i+1]=3;
    }
  }
  for(int i=a+1;i<b;i++)
    if(dp[i]){
      flag=0;
      break;
    }
  /*for(int i=0;i<1010;i++)
  cout<<dp[i]<<" ";
  cout<<endl;*/
  if(dp[a]==3&&flag==1)
    cout<<0<<endl;
  else if(dp[b]==2&&flag==1)
    cout<<0<<endl;
  else if(flag==0)
    cout<<1<<endl;
  else 
    cout<<0<<endl;
  return 0;
}

C++: //============================================================================
// Name        : AOL.cpp
// Author      : Akari Fujii
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cctype>
#include <algorithm>
using namespace std;
typedef long long ll;

int main() {


	int a,b,n;
	int s[1001],f[1001];
	int d=0;


	cin>>a>>b;

	cin>>n;


	for(int i=1; i<n+1; ++i){
		cin>>s[i]>>f[i];
		if(a<=s[i]&&b>s[i]){
			d=1;
		}else if(f[i]<=b&&f[i]>a){
			d=1;

		}
	}
		cout<<d<<endl;

		return 0;




}

C++: #include <bits/stdc++.h>
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,n,s,f;

  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 <iostream>
using namespace std;
int main() {
	int a, b, c, k[105], l[105];
	cin >> a >> b >> c;
	for (int i = 0; i < c; ++i) {
		cin >> k[i] >> l[i];
	}
	for (int i = 0; i < c; ++i) {
		if ((k[i] <= a && a < l[i] && b >= l[i]) || (b >= l[i] && a <= k[i]) || (k[i] <= a && l[i] >= b) || (a <= k[i] && b < k[i] && l[i] >= b)) {
			cout << "1" << endl;
			return 0;
		}
	}
	cout << "0" << endl;
}

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

#define int long long
#define pb push_back 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i, n) for( int i = 0; i < (n); i++ )
#define Rrep(i, a, n) for( int i = (a); i < (n); i++ )
#define All(v) v.begin(), v.end()

typedef pair<int, int> Pii; 
typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;

signed main() {
  int a, b, N;
  bool flag = false;
  cin >> a >> b;
  cin >> N;
  Rep(i, N) {
    int c, d;
    cin >> c >> d;
    if ( (a <= c && c < b) || (a < d && d <= b) || (a >= c && d >= b) ) flag = true;
  }

  if ( flag ) 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]!=0){
	i++;
	dp[i]=1;
      }
      dp[i]=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>
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) {
    for (int i = a + 1; i <= n; ++i) {
      if (t[i] != 0) {
        cout << "1" << endl;
        return 0;
      }
    }
    cout << "0" << endl;
    return 0;
  }
  cout << "1" << endl;
}

C++: #include<iostream>
using namespace std;
int main(){
    int a,b,n,k[100],l[100],x;
    cin>>a>>b>>n;
    for(int i=0;i<=100;i++){
       cin>>k[i]>>l[i];
       if(k[i]<=a&&a<=l[i]){
          x=1;
          break;
       }
       else if(k[i]<=b&&b<=l[i]){
          x=1;
       break;
       }
       else if(k[i]>=a&&l[i]<=b){
          x=1;
          break;
       }
       else x=0;
    }
    cout<<x<<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;
}