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++: //============================================================================
// Name        : tokuteigai.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int main() {
	int a,b,c,d,n;
	cin>>a>>b;
	cin>>n;
	for(int i=0;i<n+1;i++){
		cin>>c>>d;
		if(a<d&&d<b){
			cout<<"1"<<endl;
			return 0;
		}
		if(c<b&&a<c){
			cout<<"1"<<endl;
			return 0;
		}
		if(a==c&&b==d){
			cout<<"1"<<endl;
			return 0;
		}
		if(c<a&&b<d){
			cout<<"1"<<endl;
			return 0;
		}
		c=0;
		d=0;
	}
	cout<<"0"<<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=0;
  for(int i=0;i<N;i++){
    cin >> s >> f;
    if(s<=a && a<f){
      ans++;
    }else if(s<b && b<=f){
      ans++;
    }
  }

  if(ans>0){
    cout << '1' << endl;
  }else{
    cout << '0' << endl;
  }

  return 0;
}

C++: #include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>


int main() {
	ll x, y;
	cin >> x >> y;
	ll n;
	cin >> n;
	REP(i, n) {
		ll a, b;
		cin >> a >> b;
		if (x <= a and a < y) {
			cout << 1 << endl;
			return 0;
		}
		if (x < b and b <= y) {
			cout << 1 << endl;
			return 0;
		}
		if (y <= b and a <= x) {
			cout << 1 << endl;
			return 0;
		}
	}
	cout << 0 << endl;
}

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

int main(){
	int a,b,n ;
	cin >> a >> b >> n ;
	bool ok = false ;
	for(int i=0;i<n;i++){
		int s,g ;
		cin >> s >> g ;
		if(s<b&&g>a) ok = true ;
	}
	cout << (int)ok << endl ;
}

C++: #include<bits/stdc++.h>
using namespace std;
 
int main(){
  int a,b,n;
  cin>>a>>b>>n;
  for(int i=0;i<n;i++){
    int s,f;
    cin>>s>>f;
    if(s<b&&a<f){
      cout<<1<<endl;
      return 0;
    }
  }
  cout<<0<<endl;   
  return 0;
}

C++: #include "bits/stdc++.h"
#define rep(i,a,n) for(int (i) = (a);(i) < (n);(i)++)

using namespace std;

int main(){
	
	int a,b,n,s,f;
	
	cin >> a >> b >> n;
	
	int l[1010] = {0};
	
	rep(i,0,n){
		cin >> s >> f;
		
		rep(j,s,f){
			l[j] = 1;
		}
		
	}
	
	rep(i,a,b){
		if(l[i]){
			cout << 1 << endl;
			return 0;
		}
	}
	cout << 0 << endl;
	
	return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
  int a,b,n,s,f,i=0;
  cin >> a >> b >> n;
  do{
    cin >> s >> f;
    i++;
  }while((a != s && b != f) && (s <= a || s >= b) && (f <= a || f >= b) && i<n);
  if(n == i){
    cout << '0' << endl;
  } else {
    cout << '1' << endl;
  }
}

C++: #include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    int n;
    cin >> n;
    int d[1010] = {};
    rep(i, 0, n){
        int s, t;
        cin >> s >> t;
        d[s]++; d[t]--;
    }
    rep(i, 1, 1010){
        d[i] += d[i - 1];
    }
    bool f = true;
    rep(i, a, b){
        if(d[i] != 0) f = false;
    }
    cout << !f << endl;
}

C++: #include<iostream>
using namespace std;
int main(){
	int a, b, c, d[100] = { 0 }, e[100] = { 0 };
	cin >> a >> b >> c;
	for (int j = 0; j < c; j++){
		cin >> d[j] >> e[j];
		if (b > d[j] && a < d[j] || b < d[j] && a >d[j]){
			cout << 1 << endl;
		}
	}
	cout << 0;
	return 0;
}

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

#include <iostream>
using namespace std;

int main() {
	int a,b,c,d,n;
	cin>>a>>b;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>c>>d;
		if(a<d&&d<b){
			cout<<"1"<<endl;
			return 0;
		}
		if(c<b&&a<c){
			cout<<"1"<<endl;
			return 0;
		}
		if(a==c&&b==d){
			cout<<"1"<<endl;
		}
	}
	cout<<"0"<<endl;
	return 0;
}

C++: #include<cstdio>

int main(void){
	int a, b, N, i, s, f, isWrong=0;
	scanf("%d %d %d", &a, &b, &N);
	for(i=0; i<N; ++i){
		scanf("%d %d", &s, &f);
		if(((a>=s)&&(a<f))||((b>s)&&(b<=f))||((a<s)&&(b>f))){isWrong=1;}
	}
	printf("%d\n", isWrong);
	
	return(0);
}

C++: #define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=0;i<b;i++)
#define REP(i,a,b) for(int i=0;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout <<(f?"Yes":"No")<<endl//fが真の場合Yesを出力、偽の場合Noを出力
#define yes(f) cout <<(f?"yes":"no")<<endl
#define YES(f) cout <<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())

using namespace std;

const int mod=1e9+7;



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

C++: #include<iostream>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  int N;
  cin>>N;
  bool Flag=0;
  for(int i=0;i<N;i++){
    int s,f;
    cin>>s>>f;
    if((s<a)&&(a<f)) Flag=1;
    if((s<b)&&(b<f)) Flag=1;
  }
  cout<<Flag<<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;
    i++;
    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, f;
  int flag = 0;
  cin >> a >> b >> N;
  for (int i=0; i<N; i++){
    cin >> s >> f;
    if (!flag && a < f && a+b > s)
      flag = 1;
  }
  cout << flag;
  return 0;
}