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 <iostream>
#include <vector>
using namespace std;

struct St {
	int left;
	int right;
};
int main()
{
	int ans = 0;
	int a; cin >> a;
	int b; cin >> b;
	int N; cin >> N;
	
	int s;
	int f;
	
	vector<St> vec(0);
	vector<St>::iterator it;
	vec.push_back(St{0,1000});

	for (int i = 0;i < N;i++) {
		cin >> s;
		cin >> f;
		it = vec.begin();

		unsigned int j = 0;

		//予約リストの更新
		for (St st : vec) {
			if (st.left <= s && f <= st.right) {
				break;
			}
			j++;
			it++;
		}

		if (vec[j].left == s && f == vec[j].right) {
			vec.erase(vec.begin() + j);
		}else if(vec[j].left == s && f < vec[j].right){
			vec[j].left = f;
		}else if (vec[j].left < s && f == vec[j].right){
			vec[j].right = s;
		}else if (vec[j].left < s && f < vec[j].right) {
			int ns = vec[j].right;
			vec[j].right = s;
			if (j + 1 == vec.size()) {
				vec.push_back(St{f ,ns });
			}
			else {
				vec.insert(++it, St{f ,ns });
			}
			if (f < b) {
				j++;
			}
		}
		
		bool flag = false;
		for (St st : vec) {
			if (st.left <= a && b <= st.right) {
				flag = true;
			}
			if (st.right > a || flag) {
				break;
			}
		}

		if (!flag) {
			ans = 1;
			break;
		}
	}

	cout << ans << 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;
}

C++: 
#include<set>
using namespace std;
#include<iostream>
int	main(){
	/*
	while(true){
	
	int A,B,C,D,E,F,G,H,I,J,answer;
		
	cin >> A;
	if(A == 0) return 0;
	cin >> B >> C >> D >> E >> F >> G >> H >> I >> J;
	answer = A - B - C - D-E-F-G-H-I-J;
	cout << answer << endl;

	}
	*/
	/*
	int A,B,C,D,E,F;

	cin >> A, B, C, D;
	if(A < B, C, D){ 
		cout << B + C + D << endl;
	}
	
	else if(B < A, C, D){
		cout << A + C + D << endl;
	}

	else if(C < A && C < B && C < D){
		cout << A + B + D << endl;
	}

	else if(D < A && D < B && D < C){
		cout << A + B + C << endl;
	}

	if(E < F){
		cout << F << endl;
	}

	else{
		cout << E << endl;
	}
	
	return 0;
}*/
	/*
	int N, M;
	cin >> N >> M;
	cout << N + M << endl << N - M << endl << N * M << endl << N / M << endl;
}*/

/*int N, M; 
	cin >> N >> M;
	cout << N % M << endl;
}*/

/*	int N;
	cin >> N;
	cout << -(N % 2)+1 ;
}*/

	/*int A, B, C, D, E ;
	cin >> A >> B >> C >> D >> E;
	cout << (A + B + C + D + E) / 5 ;
}*/

	/*int A, B, C, D ;
	cin >> A >> B >> C >> D;
	cout << (A + B + C + D) / 60 << endl << (A + B + C + D) % 60 << endl;
	*/

/*	int A,B;
	cin >> A >> B;
	cout << ( A + B ) / 2 << endl;*/

/*	int m, f, b;
	cin >> m >> f >> b;

	if ( m + f >= b && m <= b ){
		cout << b - m << endl;
	}
	
	if ( m + f > b && m > b ){
		cout << 0 << endl;
	}


	if ( m + f < b ){
		cout << "NA" << endl;
	}*/

/*	int X , x ;
	cin >> X ;

	x = X % 7 ;

	if ( x == 2 ){
		cout << "sat" << endl;
	}

	if ( x == 3 ){
		cout << "sun" << endl;
	}

	if ( x == 4 ){
		cout << "mon" << endl;
	}

	if ( x == 5 ){
		cout << "tue" << endl;
	}

	if ( x == 6 ){
		cout << "wed" << endl;
	}

	if ( x == 0 ){
		cout << "thu" << endl;
	}

	if ( x == 1 ){
		cout << "fri" << endl;
	}*/

	int a , b , N ;
	cin >> a >> b >> N ;

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

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

int main() {
  int a, b, n; cin >> a >> b >> n;
  vector<int> v(1001);
  for (int i = 0; i < n; i++) {
    int s, f; cin >> s >> f;
    for (int j = s; j <= f; j++) {
      v.at(j) = 1;
    }
  }
  int ans = 0;
  for (int i = a + 1; i < b; i++) {
    if (v.at(i) != 0) {
      ans = 1;
    }
  }
  cout << ans << endl;
}

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

int main(){
  int a,b;
  cin>>a>>b;
  int N;
  cin>>N;
  bool yoyaku[1001];
  int tmp_s,tmp_e;
  for(int i=0;i<N;i++){
    cin>>tmp_s>>tmp_e;
    for(int j=tmp_s;j<=tmp_e;j++)yoyaku[j]=true;
  }
  bool can_yoyaku=true;
  for(int i=a+1;i<b;i++){
    if(yoyaku[i])can_yoyaku=false;
  }
  cout<<!can_yoyaku<<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 A,B,N,S,F,ans;
vector<bool> sub(1001);

int main(){
    cin>>A>>B>>N;
    FOR(i,A,B+1) sub[i] = true;
    FOR(i,0,N){
        cin>>S>>F;
        FOR(i,S,F+1){
            if(S==B || F == A) break;
            if(sub[i]) ans = 1;
        }
    }
    
    cout<<ans<<endl;
}

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

int main()
{
	int a, b;
	int n;
	bool isDuplicate = false;

	cin >> a >> b;
	cin >> n;

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

		if (a <= s && s < b) isDuplicate = true;
		if (s <= a && a < f) isDuplicate = true;
		if (a < f && f <= b) isDuplicate = true;
		if (s < b && b <= f) isDuplicate = true;
	}

	cout << isDuplicate << endl;

	return 0;
}

C++: #include <stdio.h>
#include <iostream>
#include <string>
#include <math.h>

using namespace std;

int main()
{
	int new_start, new_end;
	int no;

	cin >> new_start >> new_end;
	cin >> no;
	
	for (int i = 0; i < no; i++)
	{
		int started, ended;
		cin >> started >> ended;
		
		if (new_end > started && new_start < ended)
		{
			cout << 1 << endl;
			return 0;
		}
	}

	cout << 0 << endl;
}

C++: #include <iostream>
using namespace std;
int main(){
  int a,b,n,s,f,i=0;
  cin >> a >> b >> n;
  while(1){
    cin >> s >> f;
    if((a >= s && b <= f) || (s > a && s < b) || (f > a && f < b)){
      cout << '1' << endl;
      break;
    }
    if(++i >= n){
      cout << '0' << endl;
      break;
    }
  }
}

C++: #include<iostream>
#include<cstdio>
#define false 1
#define true 0
using namespace std;
int main (){
int a,b,N,s,f,ans=true;
cin>>a>>b;
cin>>N;
for (int i=0;i<N;i++){
        cin>>s>>f;
        if ( (s<=a&&f>=b) || (s>a&&s<b) || (f<b&&f>a) ){
                ans=false;
        }
        //cout<<ans<<"CHECK"<<endl;
        //ans=true;
}

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

C++: #include<stdio.h>
#include<iostream>
using namespace std;
int main(){
  int a=0,b=0,N=0,i=0,k=0,j=0;
  int s[110],f[110],x[1010],y[1010];
  cin>>a>>b;
  cin>>N;
  for(i=0;i<N;i++){
    cin>>s[i]>>f[i];
    for(j=s[i];j<=f[i];j++){
      x[j]=j;
    }
  }
  for(k=a+1;k<b;k++){
    y[k]=k;
  }
  for(j=s[i];j<=f[i];j++){
    for(k=a+1;k<b;k++){
      if(x[j]==y[k]){
	printf("0\n");
	return 0;
      }
      else {
	printf("1\n");
	return 0;
      }
    }
  }
  return 0;
}