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 <cstdio>
#include <utility>
#include <vector>
#include <algorithm>
using namespace std;

#ifdef __linux
#define _U(s) s##_unlocked
#else
#define _U(s) _##s##_nolock
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
#define gcu _U(getchar)
#define pcu _U(putchar)
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
#define _OP(t) inline operator t()
struct _in {
#ifdef _GLIBCXX_STRING
	_OP(string){string s;for(char c;c=gcu(),c!=' '&&c!='\n'&&c!=EOF;)s+=c;return s;}
#define _S
#endif
	_OP(char){char c=gcu();gcu();return c;}
	_OP(double){double d; scanf("%lf",&d); gcu();return d;}
	_T _OP(T){T n{},m{1},c;if((c=gcu())=='-')m=-1,c=gcu();do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
} in;
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
#ifdef _S
_SCAN(string &o) {int c{gcu()};if(c==EOF)return false;else{ungetc(c,stdin);string t=move(in);o=t;return true;}}
#endif
_T _SCAN(T &o) {int c{gcu()};return c==EOF?false:(ungetc(c,stdin),o=in,true);}
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);}
_OUT(const char *s){while(*s)pcu(*s++);}
_OUT(char c){pcu(c);}
#ifdef _S
_OUT(string &s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
	_T _OUT(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
	_HT _OUT(H &&h, T... t){out(h);out(t...);}
	template <typename... T> _OUTL(T... t){out(t...);outl();}
	struct range{
		int e,b=0,s=1;range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
		struct it{int v,s; it(int _v,int _s):v(_v),s(_s){} operator int()const{return v;} operator int&(){return v;}int operator*()const{return v;}
			it& operator++(){v+=s;return *this;} }; it begin(){return {b,s};} it end(){return {e,s};}};
#define times(i,n) for(int i=n;i;i--)

int main() {
	int a {in}, b {in};
	outl([&] {
		 times(i, in) {
			 int s {in}, f {in};
			 if (a < f && s < b)
				return 1;
			 }
		 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,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++: #define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

int main() {
	int a, b; cin >> a >> b;
	int n; cin >> n;
	VI s(n), f(n);
	rep(i, n)cin >> s[i] >> f[i];

	bool flag = false;
	rep(i, n) {
		if ((s[i] < a&&a < f[i]) || (s[i] < b&&b < f[i]) || (s[i] == a && f[i] == b) || (s[i] > a&&f[i] < b))flag = true;
	}
	Cout(flag);
}

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;
    if(s==b || f==a){
      ans[i] = 0;
    }else if(f-s==1 && s<=a && f>=b){
      ans[i] = 1;
    }else{
      for(int j=s+1;j<f;j++){
        if(f-s != 1 || (s>a && f<b)){
          ans[j] = 1;
        }
      }
    }
  }

  int an=0;

  for(int i=a;i<=b;i++){
    if(ans[i]==1){
      an++;
    }
  }

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

  return 0;
}

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

int main()
{
    int a, b;
    int N;
    bool flag = false;
    cin >> a >> b;
    b--;
    cin >> N;
    for(int i = 0; i < N; i++) {
        int s, t;
        cin >> s >> t; t--;
        if(b >= s && t >= a) flag = true;
    }
    cout << flag << endl;
    return (0);
}

C++: #include <iostream>
using namespace std;
int main(void){
    int a,b;
    int N;
    int s,f;
    cin>>a>>b>>N;
    int check=0;
    
    for(int i=0;i<N;i++){
        cin>>s>>f;
        if((a<s&&s<b)||(a<f&&f<b))check++;
    }
    
    if(check==0)cout<<0<<endl;
    else cout<<1<<endl;
    
    return 0;
}

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

int main(){
    int a,b,N,s[105],f[105];
    cin >> a>>b>>N;
    for (int i = 0; i < N; i++){
        cin >> s[i] >> f[i];
        if (f[i]>a&&s[i]<b){
            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;
}

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);
  if(n == i){
    cout << '1' << endl;
  } else {
    cout << '0' << endl;
  }
}

C++: #include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
  vector<int> a(2000,0);
  int aa,b,n;
  cin >> aa >> b >> n;
  rep(i,n){
    int f,g;
    cin >> f >> g;
    for(int j=f;j<g;j++){
      a[j]=1;
    }
  }
  bool t=true;
  for (int i=aa;i<b;i++){
    if (a[i]==1) t=false;
  }
  if (t) cout << 0 << endl;
  else cout << 1 << endl;
}

C++: #include<iostream>
using namespace std;
int main() {
    int a,b,N;
    cin >> a >> b >> N;
    int i,s,f;
    bool flag = true;
    for(i=0;i<N;i++) {
        cin >> s >> f;
        if(s<b && a<f)flag = false;
    }
    cout << (flag?0:1) << endl;
}

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

int main(){
    bool res[1001];
    int a, b, N;
    bool ans = false;

    cin >> a >> b;
    for(int i=a;i<b;i++)
        res[i] = true;

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

    cout << ans << endl;

    return 0;
}