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 <algorithm>
#include <queue>
#include <vector>
#include <map>
#include <string>

using namespace std;


int main() {
    int a,b;
    cin >> a >> b;
    int n;
    cin >> n;
    int s[n],f[n];
    for(int i = 0; i < n; i++) {
        cin >> s[i] >> f[i];
    }
    bool ok = true;
    int tmp[1001];
    for(int i = 0; i < 1001; i++) {
        tmp[i] = 0;
    }
    for(int i = 0; i < n; i++) {
        for(int j = s[i]; j < f[i]; j++) {
            tmp[j] = 1;
        }
    }
    for(int i = a; i < b; i++) {
        if(tmp[i] == 1) {
            ok = false;
        }
    }
    if(ok) cout << "0" << endl;
    else cout << "1" << endl;
}

C++: #include <iostream>

using namespace std;

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

C++: #include<stdio.h>
int main(void)
{
	int a,b,n,s[100],f[100],i,j,flg;
	scanf("%d %d",&a,&b);
	scanf("%d",&n);
	flg=0;
	for(i=0;i<n;i++)	scanf("%d %d",&s[i],&f[i]);
	for(i=0;i<n;i++){
		if(a>s[i]&&a<f[i])	flg=1;
		if(b>s[i]&&b<f[i])	flg=1;
		if(a<s[i]&&b>f[i])	flg=1;
		if(a==s[i]&&b==f[i])	flg=1;
	}
	if(flg==0)	printf("0\n");
	else	printf("1\n");
	return 0;
}

C++: #include<iostream>

using namespace std;
 
int main(){
  int a, b, n;
  while( cin >> a >> b >> n ) {

  for(int i=0;i<n;i++) {
  	
    int x, y;
    cin >> x >> y;
    if(x < b && a < y) {
    	
      cout << "1\n";
      return 0;
      
    }
    
  }
    cout << "0\n";
}
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,n;
  cin>>a>>b>>n;
  while(n--){
    int q,w;
    cin>>q>>w;
    if(!(q>b||w<a)){
      cout<<1<<endl;
      return 0;
    }
  }
  cout<<0<<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;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>
#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;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;

vector<pair<int, int> > v;
int main() {
  int a, b, N;
  cin >> a >> b >> N;
  for(int i=0; i<N; i++){
    int s, f;
    cin >> s >> f;
    v.push_back(make_pair(s, f));
  }
  int ans=0;
  for(int i=0; i<N; i++){
    if(v[i].begin() < b && a < v[i].end()) ans=1;
  }
  cout << ans << 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--;
  if(f < n){
    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 <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
int timeV[1001];
int main(){
    int a, b, n; cin >> a >> b >> n;
    for(int i=0; i<n; ++i){
        int s, f; cin >> s >> f;
        for(int j=s; j<f; ++j) timeV[j]++;
    }
    bool ok=true;
    for(int i=a; i<b; i++){
        if(timeV[i]!=0) ok=false;
    }
    if(ok) cout << 0 << endl;
    else cout << 1 << endl;
    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);
        vec.at(i).at(0)++;
        vec.at(i).at(1)++;
    }
    vector<int> cat(1001,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;
            break;
        }else if(i==1000){
            cout <<0;
        }
    }
    cout << endl;
    
}

C++: #include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
	int tim[1001] = {0};
	int s, e, n, ans;
	cin >> s >> e;
	tim[s] = 1;
	tim[e] = -1;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> s >> e;
		tim[s] = tim[s] + 1;
		tim[e] = tim[e] - 1;
	}
	for (int i = 1; i <= 1000; i++)
	{
		tim[i] = tim[i - 1] + tim[i];
		ans = tim[i];
		if (ans > 1)
			break;
	}
	if (ans > 1)
		cout << "1" << endl;
	else
		cout << "0" << endl;
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
    int a,b,n,k[100],l[100],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;
}