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;
    cin >> a >> b >> n;

    for(int i=0;i<n;i++){
        int s,f;
        cin >> s >> f;

        if(a>=s && a<f){
            cout << 1 << endl;
            return 0;
        }
        if(b>s && b<=f){
            cout << 1 << endl;
            return 0;
        }
        if(a<=s && b>=f){
            cout << 1 << endl;
            return 0;
        }
    }

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

C++: #include <iostream>
using namespace std;
int main(void){
    int a,b,n;
    cin >> a >> b >> n;
    for(int i=0; i<n; i++){
    int x,y;
    cin >> x >> y;
    if(x<b&&a<y){
        cout << 1 << endl;
        return 0;
    }
  }
  cout << 0 << endl;
}

C++: #include<iostream>
using namespace std;
int main(){
    int a,b,n,k[102],l[102],x=0;
    cin>>a>>b>>n;
    for(int i=0;i<=n;i++){
       cin>>k[i]>>l[i];
       if(b<=k[i]||l[i]<=a){
          x=0;
       }
       else{
          x=1;
          break;
       }
    }
    cout<<x<<endl;
    return 0;
}

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

#define int long long

signed main() {
	int A, B, N;
	cin >> A >> B >> N;
	vector<bool> F(1010, false);
	for (int i = 0; i < N; i++) {
		int a, b;
		cin >> a >> b;
		if (A == a && b == B) {
			cout << 1 << endl;
			return 0;
		}
		for (int j = a; j <= b; j++) {
			F[j] = true;
		}
	}
	bool ans = 1;
	for (int i = A+1; i < B; i++) {
		if (F[i])ans = false;
	}
	if (A + 1 == B) {
		if (F[A] && F[B])ans = false;
	}
	cout << !ans << endl;

	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
 
int main() {
    int a,b,c,d,x = 0;
    cin >> a >> b;
    int A[1000] = {};
    int n;
    cin >> n;
    for(int i = 0;i < n;i++){
        cin >> c >> d;
        if(a > c && a < d){
          x += 1;
          break;
        }
        if(b > c && b < d){
          x += 1;
          break;
        }
        if(a == c && b == d){
          x += 1;
          break;
        }
        if(a < c && b > d){
          x += 1;
          break;
        }
    }
    cout << x << endl;
}

C++: #include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a, b;   //a,bは新しい予約の開始時刻と終了時刻
    int n;      //元々ある予約の個数
    int s, f;
    
    //while(true){
        cin >> a >> b;
        cin >> n;
        
        int c = 0; //予約が重複する回数
        for(int i = 1; i <= n; i++){
            cin >> s >> f;
            if((s <= a && a < f) || (s < b && b <= f) || (a <= s && f <= b)) c++;
        }
        
        if(c == 0)
            cout << "0" << endl;
        else
            cout << "1" << endl;
    //}    
}

C++: #include<stdio.h>
int main()
{
	int a,b,n;
	int s,f,i;
	scanf("%d%d%d",&a,&b,&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<bits/stdc++.h>
using namespace std;
#define ll long long 
int main(){
    int a,b,n;
    cin >>a >>b >>n;
    vector<vector<int>> vec(n,vector<int>(2));
    for(int i=0;i<n;i++){
        cin>>vec.at(i).at(0)>>vec.at(i).at(1);
    }
    vector<int> cat(1000,0);
    for(int i=0;i<n;i++){
        cat.at(vec.at(i).at(0)-1) ++;
        cat.at(vec.at(i).at(1)-1) --;
    }
    cat.at(a-1) ++;
    cat.at(b-1) --;
    vector<int> rsw(1001);
    rsw.at(0) =0;
    for(int i=1;i<1001;i++){
        rsw.at(i) = rsw.at(i-1) + cat.at(i-1);
        if(rsw.at(i)==2){
            cout <<1 <<endl;
            break;
        }else if(i==1000){
            cout <<0 <<endl;
        }
    }
    
}

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

using namespace std;

typedef long long ll;
#define put(n) cout<<(n)<<"\n"
#define FOR(i,num,N) for(int(i)=(num);(i)<(N);++(i))
#define RFOR(i,num,N) for(int (i)=(num);(i)>(N);--(i))
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()

int main(){
    int A,B,N,S,F;
    cin>>A>>B>>N;
    vector<int> sub(1001,0);
    for(int i=0;i<N;++i){
        cin>>S>>F;
        for(int j=S;j<=F;++j){
            ++sub[j];
            if(j>S&&j<F) ++sub[j];
        }
    }
    for(int i=A;i<=B;++i){
        if(sub[i] == 2){
            cout<<1<<endl;
            return 0;
        }
    }
    cout<<0<<endl;
}

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

int main(){
  int a,b,n,t=0;
  cin >> a >> b >> n;
  int c[n*2];
  for(int i=0; i<n*2; i=i+2){
    int num,num2;
    cin >> num >> num2;
    if(num<a&&num2>a){
      t=1;
    }
    if(num<b&&num2>b){
      t=1;
    }
    if(num==a&&num2==b)t=1;
    if(a<num&&b>num2)t=1;
  }
  cout << t << endl;
}

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;
ll 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<bits/stdc++.h>

#define rep(i,n) for (int i=0;i<n;i++)
using namespace std;

int main(){
    vector<int> imos(1010,0);
    int a,b,n;
    cin>>a>>b;
    cin>>n;
    //imos[a]++;
    //imos[b+1]--;

    rep(i,n){
        int x,y;
        cin>>x>>y;
        imos[x]++;
        imos[y]--;
    }

    rep(i,1010){
        imos[i+1]+=imos[i];
      //  cerr<<imos[i]<<" ";
    }
    //cerr<<endl;
    for (int i=a;i<b;i++){
        if (imos[i]!=0){
            cout<<1<<endl;
            return 0;
        }
    }
    cout<<0<<endl;
    return 0;


}

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

int main(){
  int a,b;
  cin >> a >> b;
  int n;
  cin >> n;
  pair <int,int> s[n];
  for(int i = 0;i<n;i++){
    int x,y;
    cin >> x >> y;
    s[i].first = x;
    s[i].second = y;
  }
  sort(s,s+n);
  int f = 0;
  while(s[f].first < a){
    
    f++;
    
  }
  f--;
  cout << f << endl;
  if(n != 0){
    if(f != -1){
      if(s[f].second <= a && s[f+1].first >= b)
	cout << '0'<< endl;
      else
	cout << '1' << endl;
      
    }
    else{
      if(s[0].second >= b && s[0].first > a)
	cout << '0' << endl;
      else
	cout << '1' << endl; 
    }
  }
  else{
    cout << '0'  << endl;
  }
  
 
}

C++: #include <bits/stdc++.h>

#define ALL(a) (a).begin(), (a).end()
#define llong long long

using namespace std;

signed main(){
	int a,b; cin >> a >> b;
	int n; cin >> n;
	vector<bool> T(1001, false);
	for(int i = 0; i < n; i++){
		int s,t; cin >> s >> t;
		for(int j = s; j < t; j++){
			T[j] = true;
		}
	}
	for(int i = a; i < b; i++){
		if(T[i]){
			cout << 1 << endl;
			return 0;
		}
	}
	cout << 0 << endl;

	return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>

using namespace std;

int main(){
	int a,b;
	int N,tp;
	int ch=0;
	vector<int> r;
	
	scanf("%d %d",&a,&b);
	scanf("%d",&N);
	for(int i=0;i<2*N;i++){
		scanf("%d ",&tp);
		r.push_back(tp);
	}
	sort(r.begin(),r.end());
	for(int i=0;i<2*N;i++){
		if(r[i]<=a){
			if(b<=r[i+1]){
				printf("0\n");
				ch=1;
				break;
			}
		}
	}
	if(ch==0)
	printf("1\n");
}