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>
#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;

	FOR(i, n) {
		int s, f;
		cin >> s >> f;
		t[s]++; t[f]--;
	}
	eFOR1(i, 1000)t[i] += t[i - 1];
	for (int i = a + 1; i < b; i++)if (t[i] > 0) {
		ans++;
		break;
	}
	cout << ans << endl;

	return 0;
}

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

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(n,0);
    for(int i=0;i<n;i++){
        cat.at(vec.at(i).at(0)) ++;
        cat.at(vec.at(i).at(1)) --;
    }
    cat.at(a-1) ++;
    cat.at(b-1) --;
    vector<int> rsw(n+1);
    rsw.at(0) =0;
    for(int i=1;i<n+1;i++){
        rsw.at(i) = rsw.at(i-1) + cat.at(i-1);
    }
    for(int i=0;i<n+1;i++){
        if(rsw.at(i) == 2){
            cout << 1 << endl;
            break;
        }else if(i==n){
            cout << 0 << endl;
        }
    }


}

C++: #include <bits/stdc++.h>
#define loop(times) for(int i=0;i<(times);i++)

using namespace std;

int main() {
    bool t=1;
    while(t){
    int a,b,N;

    cin>>a>>b>>N;
    int s[N];
    int f[N];
    int p[1001];
    int c[1001];
    loop(1000) p[i]=0,c[i]=0;
        
    loop(N){
    cin>>s[i]>>f[i];
    p[s[i]-1]+=1;
    p[f[i]-1]+= -1;
    }
        
    loop(1000)c[i+1]=c[i]+p[i];
    loop(b-a+1)c[a+i]+=1;
    loop(1000-b)c[b+i]-=1;
    loop(1000){
    if(c[i]==2){
    cout<<1<<endl;
    t=0;
    break;
    }
    }
    if(t==1){
     cout<<0<<endl;
     t=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-1){
    cout << '0' << endl;
  } else {
    cout << '1' << endl;
  }
}

C++: #include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
template <class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
int sum(int n){
    int res=0;
    while(n>0){
        res+=n%10;
        n/=10;
    }
    return res;
}
signed main() {
    int a,b;cin>>a>>b;
    int N;cin>>N;
    rep(i,N){
        int fi,en;cin>>fi>>en;
        if(b<=fi||en<=a)continue;
        cout<<1<<endl;
        return 0;
    }
    cout<<0<<endl;
}

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>
using namespace std;

int main(){
  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;
  return 0;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int s, f;
        cin >> s >> f;
        if (s <= a && a < f) {
            cout << 1 << '\n';
            return 0;
        }
        if (s < b && b <= f) {
            cout << 1 << '\n';
            return 0;
        }
        if (a < f && f <= b) {
            cout << 1 << '\n';
            return 0;
        }
        if (a <= s && s < b) {
            cout << 1 << '\n';
            return 0;
        }
    }
    cout << 0 << '\n';
    return 0;
}

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

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

C++: #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60
ll imos[1010];
int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    ll a,b; cin >> a >> b;
    ll N; cin >> N;
    for(int i = 0; i < N;i++){
        ll s,f;
        cin >> s >> f;
        imos[s]++; imos[f]--;
    }
    for(int i = 1; i < 10;i++){
        imos[i] += imos[i-1];
    }
    for(int i = a; i < b;i++){
        if(imos[i] == 1){
            cout << 1 << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}

C++: #include <iostream>
using namespace std;
int main(void){
    int a,b,N,i,s,f,x=0;
    cin >> a >> b;
    cin >> N;
    
    for(i=1; i<=N; i++){
        cin >> s >> f;

        if(b <= s || a >= f){
                
        }
        else{
             x=1;
        }
    }
    cout << x << endl;    
}

C++: #include<cstdio>
using namespace std;
int main(void)
{
	int flg[1001]={0},a,b,n,s,f,flg1,i,j;
	scanf("%d %d %d",&a,&b,&n);
	for(i=0;i<n;i++){
		scanf("%d %d",&s,&f);
		for(j=s;j<f;j++){
			flg[j]++;
		}
	}
	for(i=a;i<b;i++){
		flg[i]++;
	}
	flg1=0;
	for(i=0;i<=1000;i++){
		if(flg[i]>=2){
			flg1=1;
		}
	}
	if(flg1==0){
		printf("0\n");
	}
	else{
		printf("1\n");
	}
	return 0;
}