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(void) {
	int a, b, n;
	int ans = 0;
	cin >> a >> b;
	cin >> n;
	int s[101][2];
	s[0][0] = a, s[0][1] = b;
	for (int i = 1;i < n+1;i++)
		cin >> s[i][0] >> s[i][1];
	for (int i = 0;i < n+1;i++) {
		for (int j = 0;j < n+1;j++) {
			if (s[i][1] > s[j][0] && s[i][0]<s[j][1] && i!=j) {
				ans = 1;
				break;
			}
			else if (s[i][1] < s[j][0] && s[i][0] > s[j][1] && i != j) {
				ans = 1;
				break;
			}
		}
		if (ans == 1)break;
	}
	cout<<ans<<endl;
	return 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;
	VI s(n), f(n);
	FOR(i, n) {
		cin >> s[i] >> f[i];
		t[s[i]]++;
		if (f[i] < 1000)t[f[i] + 1]--;
	}
	eFOR1(i, 1000)t[i] += t[i - 1];
	FOR(i, n) {
		t[s[i]] += 10;
		t[f[i]] -= 10;
	}
	for (int i = a; i <= b; i++) {
		if (i == a) {
			if (t[i] >= 1) {
				ans++;
				break;
			}
		}
		else if (i == b) {
			if (t[i] == 1 || t[i] < 0) {
				ans++;
				break;
			}
		}
		else {
			if (t[i] != 1) {
				ans++;
				break;
			}
		}
	}
	cout << ans << endl;

	return 0;
}

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

C++: #include <iostream>
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(void){ 
    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++: #include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<P,P> PP;
const ll MOD=10000;
const ll INF=1000000010;
const int MAX=100001;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
    int a,b;cin>>a>>b;
    bool f=true;
    int n;cin>>n;
    for(int i=0;i<n;i++){
        int s,f;
        cin>>s>>f;
        if(b<s||a>f)continue;
        f=false;
    }
    if(f){
        cout<<0<<endl;
    }else{
        cout<<1<<endl;
    }
    return 0;
}

C++: #include<algorithm>
#include <bits/stdc++.h>
#include <math.h>
#include <queue>
using namespace std;
int main(void){
	int d[1000]={0},a,b,s,t,n,ans=0;
	cin>>a>>b>>n;
	for(int i=0;i<n;i++){
		cin>>s>>t;
		for(int j=s;j<t;j++) d[j]=1;
	}
	for(int i=a;a<b;i++){
		if(d[i]==1){
			ans=1;
			break;
		}
	}
	cout<<ans<<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);
    }
    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);
    }
    for(int i=0;i<1001;i++){
        if(rsw.at(i) == 2){
            cout << 1 << endl;
            break;
        }else if(i==1000){
            cout << 0 << endl;
        }
    }


}

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

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

C++: #include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	int a, b;
	cin >> a >> b;
	int n;
	cin >> n;
	pair<int, int> s;
	bool flag = true;
	REP(i, n){
		cin >> s.first >> s.second;
		if (s.first <= a && a < s.second) flag = false;
		else if (s.first < b && b <= s.second) flag = false;
		else if (a <= s.first && s.second <= b) flag = false;
	}

	if (flag) cout << 0 << endl;
	else cout << 1 << endl;

}

C++: #include <iostream>
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++: #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[i]=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){
	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;

int main ()
{
	long a,b,n,aa[100],bb[100];

	cin >> a >> b >> n;

	for (int i = 0; i < n; i++)
	{
		cin >> aa[i] >> bb[i];
	}

	for (int i = 0; i < n; i++)
	{
		if (aa[i] <= a && bb[i] > a)
		{
			cout << '1' << endl;
			break;
		}
		else if (aa[i] < b && bb[i] >= b)
		{
			cout << '1' << endl;
			break;
		}
		else if (a <= aa[i] && bb[i] <= b)
		{
			cout << '1' << endl;
			break;
		}
		else if (i == n - 1)
		{
			cout << '0' << endl;
		}
	}
}

C++: #include<stdio.h>
int main(){
int a,b,n,w[1001]={0},s,f,x=0;
scanf("%d%d%d",&a,&b,&n);
w[a]++;
w[b]--;
for(int i=0;i<n;i++){
scanf("%d%d",&s,&f);
w[s]++;
if(x<f)x=f;
w[f]--;
}
int k=0;
for(int i=0;i<=x;i++){
k+=w[i];
if(k>1){
printf("1\n");
break;
}
if(i==x)printf("0\n");
}
return 0;
}

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

using namespace std;

int N;

int main() {
	int a, b, s, f;

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