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 <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int h, n; scanf("%d%d", &h, &n);

	std::vector<std::string> s(h, std::string(4, '.'));
	while(n--) {
		int x, y; scanf("%d%d", &x, &y);

		s[y][x] = '#';
	}

	auto put = [](std::vector<std::string> s, int y) {
		std::pair<int, std::string> p = {0, s[1]};
		if(s[0][y] == '.' and s[0][y + 1] == '.' and s[1][y] == '.' and s[1][y + 1] == '.') p.first = 1;
		p.second[y] = p.second[y + 1] = '#';
		return p;
	};

	std::vector<std::map<std::string, int>> dp(h + 1); dp[1][s[0]] = 0;
	for(int i = 1; i < h; i++) {
		for(auto from: dp[i]) {
			std::vector<std::string> t = {from.first, s[i]};
			int val = from.second;

			auto A = put(t, 0);
			auto B = put(t, 1);
			auto C = put(t, 2);
			auto D = put(std::vector<std::string>{from.first, A.second}, 2);
			dp[i + 1][s[i]] = std::max(dp[i + 1][s[i]], val);
			if(A.first) dp[i + 1][A.second] = std::max(dp[i + 1][A.second], val + 1);
			if(B.first) dp[i + 1][B.second] = std::max(dp[i + 1][B.second], val + 1);
			if(C.first) dp[i + 1][C.second] = std::max(dp[i + 1][C.second], val + 1);
			if(A.first and C.first) dp[i + 1][D.second] = std::max(dp[i + 1][D.second], val + 2);
		}
	}
	int ans = 0;
	for(auto v: dp[h]) ans = std::max(ans, v.second);
	printf("%d\n", ans);
	return 0;
}

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

#define put(n) cout<<(n)<<endl;
#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 H,N,F[10100];
long long dp[10100][1<<4];

int main(){
    cin>>H>>N;

    FOR(i,0,N){
        int x,y; cin>>x>>y;
        F[y] |= (1<<x);
    }

    FOR(i,0,10100){
        FOR(j,0,(1<<4)){
            dp[i][j] = -1;
        }
    }

    dp[0][F[0]] = 0;

    FOR(i,0,H-1){
        FOR(state,0,(1<<4)){
            FOR(bit,0,(1<<3)){
                int next = F[i+1],cnt=0,ok=1;
                FOR(j,0,3){
                    if(!(bit&(1<<j))) continue;
                    if(state&(3<<j)) ok = 0;
                    if(next&(3<<j)) ok = 0;
                    next |= (3<<j);
                    ++cnt;
                }
                if(!ok) continue;
                dp[i+1][next] = max(dp[i+1][next],dp[i][state]+cnt);
            }
        }
    }
    long long ans = -2;
    FOR(i,0,(1<<4)) ans = max(ans,dp[H-1][i]);
    put(ans);
}

C++: //#include<bits/stdc++.h>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
using namespace std;
typedef long long unsigned int ll;

int main() {

    int dp[10003][1<<5] = {{}};
    int block[10003] = {};

    int H,N;
    int x,y;
    scanf("%d %d", &H,&N );
    for (int i = 0; i < N; i++){
        scanf("%d %d", &x,&y );
        block[y] |= 1<<x;
    }

    int set[5] = {0xf,0x3,0x6,0xc,0x0};
    int vul[5] = {2, 1, 1, 1, 0};
    for (int ai = 0; ai < H-1; ai++){
        for (int bi = 0; bi < 1<<5; bi++){
            for (int si = 0; si < 5; si++){
                if( set[si] & (block[ai] | block[ai+1] | bi ) ){
                    continue;
                }
                dp[ai+1][set[si]] = max(dp[ai+1][set[si]] , dp[ai][bi] + vul[si] );
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < 1<<5; i++){
        ans = max(ans , dp[H-1][i] );
    }

    printf ("%d\n", ans);


    return 0;
}

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

bool a[4][10001];//1 ????????????0 ????????????
int dp[10000][16];//i????????§?????????i+1????????§??????????????¨?????????1
int x[4]={0,1,2,0};
int y[4]={2,3,4,4};
signed main(){
	fill(dp[0],dp[0]+16,-(1<<29));
	int h,n;cin>>h>>n;
	memset(a,true,sizeof(a));
	for(int i=0;i<n;i++){
		int a,b;cin>>a>>b;
		::a[a][b]=false;
		}
	dp[0][15]=0;
	for(int i=0;i<4;i++){
		int bit=15;
		bool OK=true;
		for(int j=x[i];j<y[i];j++){
			if(!a[j][0]||!a[j][1]){
						OK=false;
						}
					
				bit-=(1<<j);	
			}
		if(OK){dp[0][bit]=(y[i]-x[i])/2;}	
		}
	for(int i=0;i<h-1;i++){
		for(int j=0;j<16;j++){
			dp[i+1][15]=max(dp[i+1][15],dp[i][j]);
			for(int k=0;k<4;k++){
				bool OK=true;
				for(int l=x[k];l<y[k];l++){
					if(!a[l][i+1]||!a[l][i+2]||(j&(1<<l))==0){
						OK=false;
						}
					}
				if(OK){
					int bit=15;
					for(int l=x[k];l<y[k];l++){
						bit-=(1<<l);
						}
					dp[i+1][bit]=max(dp[i+1][bit],dp[i][j]+(y[k]-x[k])/2);	
					}	
				}
			}
		}
	cout<<*max_element(dp[h-2],dp[h-2]+16)<<endl;		
	}