Go: package main

import "fmt"

func main() {
	//部屋を生成
	var H int

	fmt.Scan(&H)
	room := [][4]bool{}

	for i := 0; i < H; i++ {
		room = append(room, [4]bool{})
	}

	//荷物のおけない区画を設定
	var N int
	fmt.Scan(&N)
	for i := 0; i < N; i++ {
		var x, y int
		fmt.Scan(&x, &y)
		room[y][x] = true //ものがある状態を真とする
	}
	//荷物を配置
	var count int
	for i := 0; i < 3; i++ {
		for j := 0; j < H-1; j++ {


			if !room[j][i] && !room[j+1][i] && !room[j][i+1] && !room[j+1][i+1] {
				//if i!=0&&i!=2&&j!=H-3{
				//	if !room[j+1][i-1]&&!room[j+1][i+2]{
				//		if !room[j+2][0]&&!room[j+2][1]&&!room[j+2][2]&&!room[j+2][3]{
				//			break
				//		}
				//	}
				//}
				room[j][i] = true
				room[j+1][i] = true
				room[j][i+1] = true
				room[j+1][i+1] = true
				count++
			}
		}
	}
	//for _,v:=range room{
	//	for _,v2:=range v{
	//		if !v2 {
	//			fmt.Print("◯")
	//		}else{
	//			fmt.Print("☓")
	//		}
	//	}
	//	fmt.Println()
	//}
	fmt.Println(count)
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#define FI first
#define SE second
#define PF push_front
#define PB push_back
#define PPF pop_front
#define PPB pop_back
#define MA make_pair
#define ll long long
#define PA pair<int,int>
#define VE vector<int>
#define VP vector<PA>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int mod=1e9+7;
//
//
struct poi{
  int X;int Y;int Z;
  bool operator<(const poi&R)const{
    return X==R.X ? Y==R.Y ? Z<R.Z : Y<R.Y : X<R.X;
  }
};
//
//
int H,N;
int M[10000][4];
int main(){
	cin>>H>>N;
	FOR(i,0,N){
		int X,Y;
		cin>>X>>Y;
		M[Y][X]=-1;
	}
	int ans=0;
	FOR(i,0,H-1){
		if(M[i][0]==0&&M[i][1]==0&&M[i+1][0]==0&&M[i+1][1]==0){
			M[i][0]=1;M[i][1]=1;M[i+1][0]=1;M[i+1][1]=1;
			ans++;
		}
		if(M[i][2]==0&&M[i][3]==0&&M[i+1][2]==0&&M[i+1][3]==0){
			M[i][2]=1;M[i][3]=1;M[i+1][2]=1;M[i+1][3]=1;
			ans++;
		}
	}
	FOR(i,0,H-1){
		if(M[i][1]==0&&M[i][2]==0&&M[i+1][1]==0&&M[i+1][2]==0){
			M[i][1]=1;M[i][2]=1;M[i+1][1]=1;M[i+1][2]=1;
			ans++;
		}
	}
	int now=0;
	while(now<H){
		if(M[now][1]==0&&M[now][2]==0){
			int mem=now;
			now++;
			if(now==H){
				break;
			}
			while(now<H&&M[now][0]==1&&M[now][1]==1&&M[now][2]==1&&M[now][3]==1){
				now++;
			}
			if(now==H){
				break;
			}
			if(M[now][0]==0&&M[now][1]==0&&M[now][2]==0&&M[now][3]==0){
				M[now][0]=1;M[now][1]=1;M[now][2]=1;M[now][3]=1;
				M[mem][1]=1;M[mem][2]=1;
				ans++;
			}
			now++;
		}else{
			now++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

C++: #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _overload4(_1,_2,_3,_4,name,...) name
#define _overload3(_1,_2,_3,name,...) name
#define _overload2(_1,_2,name,...) name
#define _re(n) _rep(i,n)
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(ll i=a;i<b;++i)
#define _repc(i,a,b,c) for(ll i=a;i<b;i+=c)
#define rep(...) _overload4(__VA_ARGS__,_repc,_repi,_rep,_re)(__VA_ARGS__)
#define _rre(n) _rrep(i,n)
#define _rrep(i,n) _rrepi(i,0,n)
#define _rrepi(i,a,b) for(ll i=b-1;i>=a;i--)
#define _rrepc(i,a,b,c) for(ll i=a+(b-a-1)/c*c;i>=a;i-=c)
#define rrep(...) _overload4(__VA_ARGS__,_rrepc,_rrepi,_rrep,_rre)(__VA_ARGS__)
#define sum(...) accumulate(range(__VA_ARGS__),0)
#define _range(i) (i).begin(),(i).end()
#define _rangek(i,k) (i).begin(),(i).begin()+k
#define range(...) _overload2(__VA_ARGS__,_rangek,_range)(__VA_ARGS__)
#define LINF (ll)1000000000000000000
#define MOD (ll)1000000007
#define INF (int)1000000007
#define Yes(i) out(i?"Yes":"No")
#define YES(i) out(i?"YES":"NO")
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define vec(type,name,size) vector<type> name(size);
#define VEC(type,name,size) vector<type> name(size);in(name)
struct aaa{aaa(){cin.tie(0); cout.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}aaaaaaa;
inline void in() {}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec);
template<typename T,typename L>
istream& operator >> (istream& is, pair<T,L>& p);
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec);
template<typename T,typename L>
ostream& operator << (ostream& os, pair<T,L>& p);
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){for(T& x: vec) is >> x;return is;}
template<typename T,typename L>
istream& operator >> (istream& is, pair<T,L>& p){is >> p.first;is >> p.second;return is;}
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){os << vec[0];rep(i,1,vec.size()){os << ' ' << vec[i];}return os;}
template<typename T,typename L>
ostream& operator << (ostream& os, pair<T,L>& p){os << p.first << " " << p.second;return os;}
template <class Head, class... Tail>
inline void in(Head&& head,Tail&&... tail){cin>>head;in(move(tail)...);}
template <class T>
inline void out(T t){cout<<t<<'\n';}
inline void out(){cout<<'\n';}
template <class Head, class... Tail>
inline void out(Head head,Tail... tail){cout<<head<<' ';out(move(tail)...);}


int main(){
    INT(h,n);
    vector<vector<bool>>a(4,vector<bool>(h));
    rep(n){
        INT(x,y);
        a[x][y]=1;
    }
    int ans=0;
    rep(j,h-1)if(!a[0][j]&&!a[0+1][j]&&!a[0][j+1]&&!a[0+1][j+1]){
        a[0][j]=a[0+1][j]=a[0][j+1]=a[0+1][j+1]=1;
        ans++;
    }
    rep(j,h-1)if(!a[2][j]&&!a[2+1][j]&&!a[2][j+1]&&!a[2+1][j+1]){
        a[2][j]=a[2+1][j]=a[2][j+1]=a[2+1][j+1]=1;
        ans++;
    }
    rep(j,h-1)if(!a[1][j]&&!a[1+1][j]&&!a[1][j+1]&&!a[1+1][j+1]){
        a[1][j]=a[1+1][j]=a[1][j+1]=a[1+1][j+1]=1;
        ans++;
    }
    out(ans);
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int dx[] = {1,0,1,0};
int dy[] = {0,1,1,0};
int main() {
	int H,N;
	cin >> H >> N;
	vector<vector<char>> ship(H,vector<char>(4,'.'));

	for (int i = 0; i < N; i++) {
		int x, y;
		cin >> x >> y;
		ship[x][y] = '#';
	}

	int A = 0;
	int B = 0;

	for (int i = 0; i < H-1;){
		bool can = true;
		for (int j = 0; j < 4; j++){
			if (ship[i + dy[j]][0 + dx[j]] == '#') {
				can = false;
			}
		}
		if (can){
			i += 2;
			A++;
		}
		else i++;

	}

	for (int i = 0; i < H-1;) {
		bool can = true;
		for (int j = 0; j < 4; j++) {
			if (ship[i + dy[j]][2 + dx[j]] == '#') {
				can = false;
			}
		}
		if (can) {
			i += 2;
			A++;
		}
		else i++;

	}

	for (int i = 0; i < H-1;) {
		bool can = true;
		for (int j = 0; j < 4; j++) {
			if (ship[i + dy[j]][1 + dx[j]] == '#') {
				can = false;
			}
		}
		if (can) {
			i += 2;
			B++;
		}
		else i++;
	}

	cout << max(A, B) << endl;


}