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("x")
	//
	//		}else{
	//			fmt.Print("o")
	//		}
	//
	//	}
	//	fmt.Println()
	//}
	fmt.Println(count)
}

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;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010LL;
const int MAX=310;
const double EPS=1e-9;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
bool f[10010][4];
int dp[10010];
int main(){
	int h,n;cin>>h>>n;
	for(int i=0;i<n;i++){
		int x,y;cin>>x>>y;
		f[y][x]=true;
	}
	for(int i=0;i<h-1;i++){
		if(i>1)dp[i]=dp[i-2];
		if(f[i][0]||f[i][1]||f[i+1][0]||f[i+1][1]){
			if(f[i][1]||f[i][2]||f[i+1][1]||f[i+1][2]){
				if(f[i][2]||f[i][3]||f[i+1][2]||f[i+1][3]);
				else dp[i]++;
			}else{
				dp[i]++;
			}
		}else{
			dp[i]++;
			if(f[i][2]||f[i][3]||f[i+1][2]||f[i+1][3]);
			else dp[i]++;
		}
	}
	if(h==2){
		cout<<dp[0]<<endl;
	}else{
		cout<<max(dp[h-2],dp[h-3])<<endl;
	}
}

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

int state(bool a,bool b,bool c,bool d){
	int ret = 0;
	if(a) ret += 1;
	if(b) ret += 2;
	if(c) ret += 4;
	if(d) ret += 8;
	return ret;
}

int main(){
	int h,n,dp[10010][16] = {};
	bool ng[10010][4] = {};
	cin >> h >> n;
	for(int i = 0;i < n;i++){
		int x,y;
		cin >> x >> y;
		ng[y][x] = true;
	}
	bool flag = false;
	for(int i = 0;i < h - 1;i++){
		for(int j = 0;j < 16;j++){
			if(!i){
				bool flag = true;
				for(int k = 0;k < 4;k++){
					if(((j >> k) & 1) ^ (ng[0][k])) flag = false;
				}
				if(!flag) continue;
			}
			bool a = false,b = false,c = false,d = false;
			if(!((j >> 0) & 1) && (!ng[i][0])) a = true;
			if(!((j >> 1) & 1) && (!ng[i][1])) b = true;
			if(!((j >> 2) & 1) && (!ng[i][2])) c = true;
			if(!((j >> 3) & 1) && (!ng[i][3])) d = true;
			dp[i + 1][state(ng[i + 1][0],ng[i + 1][1],ng[i + 1][2],ng[i + 1][3])] = max(dp[i + 1][state(ng[i + 1][0],ng[i + 1][1],ng[i + 1][2],ng[i + 1][3])],dp[i][j]);
			if(a && b) dp[i + 1][state(true,true,ng[i + 1][2],ng[i + 1][3])] = max(dp[i + 1][state(true,true,ng[i + 1][2],ng[i + 1][3])],dp[i][j] + 1);
			if(c && b) dp[i + 1][state(ng[i + 1][0],true,true,ng[i + 1][3])] = max(dp[i + 1][state(ng[i + 1][0],true,true,ng[i + 1][3])],dp[i][j] + 1);
			if(c && d) dp[i + 1][state(ng[i + 1][0],ng[i + 1][1],true,true)] = max(dp[i + 1][state(ng[i + 1][0],ng[i + 1][1],true,true)],dp[i][j] + 1);
			if(a && b && c && d) dp[i + 1][state(true,true,true,true)] = max(dp[i + 1][state(true,true,true,true)],dp[i][j] + 2);
		}
	}
	int ma = 0;
	for(int i = 0;i < 16;i++) ma = max(ma,dp[h - 1][i]);
	cout << ma << endl;
	return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <stack>
#include <vector>
#include <queue>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <list>
#include <string.h>
#include <functional>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cstdio>
#define rep(i, n) for(int i = 0; i < n; i++)
#define fi first
#define se second
//#include <Windows.h>
//#include "Library.h"
//#include "Math.h"
//#include "Othello.h"
using namespace std;
typedef long long int ll; typedef pair <ll, ll> P; typedef vector <int> vecint; typedef pair<int,  P> P1; typedef pair<int, P1> P2;
const int inf = 2000000000;
const ll INF = 9000000000000000000;
const double EPS = 10e-9;
int grid[10000][4];
int main() {
int h, n; cin >> h >> n;
rep(i, n)
{
int a, b; cin >> a >> b; grid[a][b] = 1;
}
int res = 0;
rep(i, h - 1)rep(j, 3)
{
if(!grid[i][j] && !grid[i + 1][j] && !grid[i][j + 1] && !grid[i + 1][j + 1])
res++;
}
cout << res << endl;
return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int func(vector<vector<char> >&, int, int);
bool can(vector<vector<char> >&, int, int);
int slide(vector<vector<char> >&, int);
void flat(vector<vector<char> >&, int, int);
class point {
public:
	vector<int> dp;
	point() {
		dp.resize(1 << 8, -1);
	}
};
vector<vector<point> > dp;
int main() {
	int H, N;
	cin >> H >> N;
	vector<vector<char> > map(4, vector<char>(H,false));
	dp.resize(4);
	for (int i = 0; i < 4; ++i) {
		dp[i].resize(H);
	}
	for (int i = 0; i < N; ++i) {
		int x, y;
		cin >> x >> y;
		map[x][y] = true;
	}
	cout << func(map, 0, 0) << endl;
	return 0;
}

bool can(vector<vector<char> >&map, int x, int y) {
	for (int i = 0; i < 2; ++i) {
		for (int j = 0; j < 2; ++j) {
			if (map[x + i][y + j]) {
				return false;
			}
		}
	}
	return true;
}

int slide(vector<vector<char> >&map, int y) {
	int res = 0;
	for (int i = 0; i < 4; ++i) {
		for (int j = y; j < y + 2; ++j) {
			if (map[i][j]) {
				res |= 1 << (i * 2 + j-y);
			}
		}
	}
	return res;
}

int func(vector<vector<char> >&map, int x, int y) {
	if (y == map[0].size() - 1) {
		return 0;
	}
	int sli = slide(map, y);
	if (dp[x][y].dp[sli] >= 0) {
		return dp[x][y].dp[sli];
	}
	int res = 0;
	int nx, ny;
	if (x == 2) {
		nx = 0;
		ny = y + 1;
	}
	else {
		nx = x + 1;
		ny = y;
	}
	if (can(map, x, y)) {
		flat(map, x, y);
		res = 1+func(map, nx, ny);
		flat(map, x, y);
	}
	res = max(func(map, nx, ny), res);
	dp[x][y].dp[sli] = res;
	return res;
}

void flat(vector<vector<char> >&map, int x, int y) {
	for (int i = x; i < x + 2; ++i) {
		for (int j = y; j < y + 2; ++j) {
			map[i][j] = !map[i][j];
		}
	}
}

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

int dp[10001][1<<4] = {}, ng[10001] = {};

int main(){
    int h, n;
    cin >> h >> n;

    for(int i = 0; i < n; i++){
        int x, y;
        cin >> x >> y;
        ng[y] += 1<<x;
    }

    for(int i = 1; i < h; i++){
        // put 1
        for(int xj = 0; xj < 1<<4; xj++){
            int put = 12;
            while(put >= 3){
                if(((put&ng[i-1])==0) && ((xj&put)==0) && ((ng[i]&put)==0)){
                    dp[i][put|ng[i]] = max(dp[i][put|ng[i]], dp[i-1][xj]+1);
                }
                put >>= 1;
            }
        }
        // put 2
        if(ng[i-1] == 0 && ng[i] == 0){
            dp[i][(1<<4)-1] = max(dp[i][(1<<4)-1], dp[i-1][0]+2);
        }
        for(int j = 0; j < 1<<4; j++)   dp[i][0] = max(dp[i][0], dp[i-1][j]);
    }

    int ans = 0;
    for(int j = 0; j < 1<<4; j++)   ans = max(ans, dp[h-1][j]);
    cout << ans << endl;

    return 0;
}