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,s[105],f[105];
	cin >> a>>b>>N;
	for (int i = 0; i < N; i++){
		cin >> s[i] >> f[i];
		if (f[i]>a&&s[i]<b){
			int g = 1;
		}
		else{
			int g = 0;
		}
	}
	if (g == 1){
		cout << "1" << endl;
	}
	else{
		cout << "0" << endl;
	}
	return 0;
}

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

using namespace std;

int main(){
	int reservation[1001];
	for(int i = 0; i < 1001; i++){
		reservation[i] = 0;
	}
	int a, b;
	cin >> a >> b;
	int N;
	cin >> N;
	for(int i = 0; i < N; i++){
		int s, f;
		cin >> s >> f;
		for(int j = s; j < f; j++){
			reservation[j] = 1;
		}
	}
	int flag = 0;
	for(int i = a; i < b; i++){
		if(reservation[i] == 1){
			flag = 1;
			break;
		}
	}
	cout << flag << "\n";
}

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 (i == n - 1)
		{
			cout << '0' << endl;
		}
	}
}

C++: #include <iostream>

using namespace std;

int main() {
    int a, b, n;
    cin >> a >> b >> n;

    bool ret = true;
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        if (y > a && b > x)ret = false;
    }

    cout << (ret ? 0 : 1) << endl;
    return 0;
}

C++: //============================================================================
// Name        : AOL.cpp
// Author      : Akari Fujii
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cctype>
#include <algorithm>
using namespace std;
typedef long long ll;

int main() {


	int a,b,n;
	int s[1001],f[1001];
	int d=0;


	cin>>a>>b;

	cin>>n;


	for(int i=1; i<n+1; ++i){
		cin>>s[i]>>f[i];
		if(a<=s[i]&&b>s[i]){
			d=1;
		}else if(f[i]<=b&&f[i]>a){
			d=1;

		}
	}
		cout<<d<<endl;








}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
        int a,b,n,s,f;
        int cnt=0;
        scanf("%d %d %d",&a,&b,&n);
        for(int i=0;i<n;++i){
                scanf("%d %d",&s,&f);
                cnt+=((s<a&&a<f)||(s<b&&b<f)||(s<=a&&b<=f)||(a<=s&&f<=b));
        }
        printf("%d\n",!(!cnt));
        return 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;
}