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 j := 0; j < H-1; j++ {
		for i := 0; i < 3; i++ {

			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 "bits/stdc++.h"

using namespace std;
using ll = long long;
using ull = unsigned long long;

typedef pair<int, int>pi;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
typedef pair<P, P> PPP;

const ll MOD = 1e9 + 7;
const ll INF = 9e18;
const double DINF = 5e14;
const double eps = 1e-10;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };

#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second

ll dp[16][10010],ans;

int h, n, x, y;
bool b[4][10010];

int cul(int x) {
	int sum = 0;
	for (int i = 0;i < 4;i++) {
		if (b[i][x])sum += (1 << i);
	}
	return sum;
}

int main() {
	cin >> h >> n;
	for (int i = 0;i < n;i++) {
		cin >> x >> y;
		b[x][y] = 1;
	}
	for (int i = 0;i < 16;i++) {
		for (int j = 0;j < h;j++) {
			dp[i][j] = -1;
		}
	}
	dp[cul(0)][0] = 0;
	for (int i = 0;i < h - 1;i++) {
		for (int j = 0;j < 16;j++) {
			if (dp[j][i] == -1)continue;
			if (j == 6 || j == 10 || j == 5 || j == 15 || j == 7 || j == 14 || j == 11 || j == 13) {
				dp[cul(i + 1)][i + 1] = max(dp[j][i], dp[cul(i + 1)][i + 1]);
			}
			if (j == 2 || j == 3) {
				if (!b[2][i + 1] && !b[3][i + 1])dp[cul(i + 1) + 12][i + 1] = max(dp[cul(i + 1) + 12][i + 1], dp[j][i] + 1);
				dp[cul(i + 1)][i + 1] = max(dp[cul(i + 1)][i + 1], dp[j][i]);
			}
			if (j == 4 || j == 12) {
				if (!b[0][i + 1] && !b[1][i + 1])dp[cul(i + 1) + 3][i + 1] = max(dp[cul(i + 1) + 3][i + 1], dp[j][i] + 1);
				dp[cul(i + 1)][i + 1] = max(dp[cul(i + 1)][i + 1], dp[j][i]);
			}
			if (j == 1) {
				if (!b[1][i + 1] && !b[2][i + 1])dp[cul(i + 1) + 6][i + 1] = max(dp[cul(i + 1) + 6][i + 1], dp[j][i] + 1);
				if (!b[2][i + 1] && !b[3][i + 1])dp[cul(i + 1) + 12][i + 1] = max(dp[cul(i + 1) + 12][i + 1], dp[j][i] + 1);
				dp[cul(i + 1)][i + 1] = max(dp[cul(i + 1)][i + 1], dp[j][i]);
			}
			if (j == 8) {
				if (!b[0][i + 1] && !b[1][i + 1])dp[cul(i + 1) + 3][i + 1] = max(dp[cul(i + 1) + 3][i + 1], dp[j][i] + 1);
				if (!b[1][i + 1] && !b[2][i + 1])dp[cul(i + 1) + 6][i + 1] = max(dp[cul(i + 1) + 6][i + 1], dp[j][i] + 1);
				dp[cul(i + 1)][i + 1] = max(dp[cul(i + 1)][i + 1], dp[j][i]);
			}
			if (j == 9) {
				if (!b[1][i + 1] && !b[2][i + 1])dp[cul(i + 1) + 6][i + 1] = max(dp[cul(i + 1) + 6][i + 1], dp[j][i] + 1);
				dp[cul(i + 1)][i + 1] = max(dp[cul(i + 1)][i + 1], dp[j][i]);
			}
			if (j == 0) {
				if (!b[0][i + 1] && !b[1][i + 1])dp[cul(i + 1) + 3][i + 1] = max(dp[cul(i + 1) + 3][i + 1], dp[j][i] + 1);
				if (!b[1][i + 1] && !b[2][i + 1])dp[cul(i + 1) + 6][i + 1] = max(dp[cul(i + 1) + 6][i + 1], dp[j][i] + 1);
				if (!b[2][i + 1] && !b[3][i + 1])dp[cul(i + 1) + 12][i + 1] = max(dp[cul(i + 1) + 12][i + 1], dp[j][i] + 1);
				if (!b[0][i + 1] && !b[1][i + 1] && !b[2][i + 1] && !b[3][i + 1])dp[15][i + 1] = max(dp[15][i + 1], dp[j][i] + 2);
				dp[cul(i + 1)][i + 1] = max(dp[cul(i + 1)][i + 1], dp[j][i]);
			}
		}
	}
	for (int i = 0;i < 16;i++) {
		ans = max(ans, dp[i][h - 1]);
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

bool b[4][10000];


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);

	int h, n;
	cin >> h >> n;
	for( int i = 0; i < n; i++ )
	{
		int x, y;
		cin >> x >> y;
		b[x][y] = true;
	}
	int ret = 0;
	int dx[3] = { 1,1,0 }, dy[3] = { 0,1,1 };
	for( int y = 0; y < h - 1; y++ )
		for( int x = 0; x < 3; x++ )
		{
			if( !b[x][y] )
			{
				bool ok = true;
				for( int i = 0; i < 3; i++ )
				{
					if( b[x + dx[i]][y + dy[i]] )ok = false;
				}
				if( ok )
				{
					for( int i = 0; i < 3; i++ )b[x + dx[i]][y + dy[i]] = true;
					ret++;
				}
			}
		}
	cout << ret << endl;
	
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
int main() {
	int h,n;
	cin>>h>>n;
	vector<vector<int> > dp(h+1,vector<int>(1<<4,-1e6));
	vector<vector<int> > obj(h);
	REP(i,n){
		int a,b;
		cin>>a>>b;
		obj[b].push_back(a);
	}
	{
		int bit=0;
		REP(i,obj[0].size()){
			bit^=1<<obj[0][i];
		}
		dp[0][bit]=0;
	}
	REP(i,h-1){
		int bit=0;
		REP(j,obj[i+1].size()){
			bit^=1<<obj[i+1][j];
		}
		REP(j,1<<4){
			dp[i+1][bit]=max(dp[i+1][bit],dp[i][j]);
			if(!(j&3)&&!(bit&3)){
				dp[i+1][bit^3]=max(dp[i+1][bit^3],dp[i][j]+1);
			}
			if(!(j&6)&&!(bit&6)){
				dp[i+1][bit^6]=max(dp[i+1][bit^6],dp[i][j]+1);
			}
			if(!(j&12)&&!(bit&12)){
				dp[i+1][bit^12]=max(dp[i+1][bit^12],dp[i][j]+1);
			}
			if(!(j&15)&&!(bit&15)){
				dp[i+1][bit^15]=max(dp[i+1][bit^15],dp[i][j]+2);
			}
		}
	}
	cout<<*max_element(dp[h-1].begin(),dp[h-1].end())<<endl;
	return 0;
}

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;){
		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;) {
		bool can = true;
		for (int j = 0; j < 4; j++) {
			if (ship[i + dy[j]][3 + dx[j]] == '#') {
				can = false;
			}
		}
		if (can) {
			i += 2;
			A++;
		}
		else i++;

	}

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

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



	


}