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 < H-1; i++ {
		for j := 0; j < 3; j++ {
			if !room[i][j] && !room[i+1][j] && !room[i][j+1] && !room[i+1][j+1] {
				room[i][j] = true
				room[i+1][j] = true
				room[i][j+1] = true
				room[i+1][j+1] = true
				count++
			}
		}
	}
	fmt.Println(count)
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string.h>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define Max(a,b) a=max(a,b);
typedef long long ll;
using namespace std;
#define X 256
int h,n;
bool d[10010][4];
int dp[100010][X];
int main(){
	cin>>h>>n;
	memset(d,0,sizeof(d));
	lol(i,n){
		int x,y;cin>>x>>y;
		d[y+1][x]=1;
	}
	lol(i,4)d[0][i]=1;
	memset(dp,-1,sizeof(dp));
	dp[0][0]=0;
	lol(i,h+1){
		lol(j,X){
			if(dp[i][j]==-1)continue;
			int k=j*16%X;
			lol(r,4)if(d[i][r]==1)k+=(1<<r);
			Max(dp[i+1][k],dp[i][j]);
			bool t[8];
			lol(r,8)t[r]=(k%(2<<r)>=(1<<r));
			if(t[0]+t[1]+t[4]+t[5]==0){
				Max(dp[i+1][k+51],dp[i][j]+1);
			}
			if(t[1]+t[2]+t[5]+t[6]==0){
				Max(dp[i+1][k+102],dp[i][j]+1);
			}
			if(t[2]+t[3]+t[6]+t[7]==0){
				Max(dp[i+1][k+204],dp[i][j]+1);
			}
			if(k==0){
				Max(dp[i+1][255],dp[i][j]+2);
			}
		}
	}
	int ans=0;
	lol(i,X)Max(ans,dp[h+1][i]);
	cout<<ans<<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[y][x] = '#';
	}

	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;


}

C++: #include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int MOD = 1e9 + 7;
int flag[10000];
int main(){
	int h,n;
	cin >> h >> n;
	vector<int> x(n);
	vector<int> y(n);
	for(int i = 0; i < n; ++i)
		cin >> x[i] >> y[i];

	vector<vector<ll>> dp(h + 3, vector<ll>(1 << 4, -MOD));
	vector<vector<int>> v(h, vector<int>(4, 1));
	for(int i = 0; i < n; ++i)
		v[y[i]][x[i]] = 0;
	

	dp[0][0] = 0;
	for(int i = 0; i < h - 1; ++i){
		for(int j = 0; j < (1<<4); ++j){
			if(dp[i][j] == -MOD)
				continue;

			int d = 0;

			dp[i+1][d] = max(dp[i+1][d], dp[i][j]);

			if(~j&(1) && ~j&(1<<1) &&
				v[i+1][0] && v[i+1][1] && v[i][0] && v[i][1]
					)
				dp[i+1][d + 3] = max(1 + dp[i][j], dp[i+1][j+3]);

			if(~j&(2) && ~j&(1<<3) &&
				v[i+1][2] && v[i+1][3] && v[i][2] && v[i][3]
			  )
				dp[i+1][d + (1<<2) + (1<<3)] = max(1 + dp[i][j], dp[i+1][d + (1<<2) + (1<<3)]);

			if(~j&(2) && ~j&(1<<1) &&
				v[i+1][2] && v[i+1][1] && v[i][2] && v[i][1]
			  )
				dp[i+1][d + (1<<2) + (1<<1)] = max(1 + dp[i][j], dp[i+1][d + (1<<2) + (1<<1)]);

			bool flag = true;
			if(j==0)
			for(int k = 0; k < 4; ++k)
				for(int l = 0; l < 2; ++l)
					if(v[i+l][k]==0)
					{
						flag=false;break;}

			if(j == 0 && flag){
				dp[i+1][(1<<4)-1] = max(2 + dp[i][j], dp[i+1][(1<<4)-1]);
			}
		}
	
	}

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

}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include<random>
#include<math.h>
#include<limits.h>
#include<iterator>
#include<queue>
#include<functional>
#define rep(i,a) for(int i=0;i<a;i++)
#define nrep(i,a,b) for(int i=a;i<b;i++)
#define mrep(i,a) for(int i=a;i>=0;i--)
#define ll long long
#define vl vector<ll> 
#define vvl vector<vector<ll> > 
#define vb vector<bool> 
#define vvb vector<vector<bool> > 
#define INF 11234567890123456789
using namespace std;

int main(){
	ll h, n; cin >> h >> n;
	vvb map(4, vb(h, true));
	rep(i, n){
		ll x, y; cin >> x >> y;
		map[x][y] = false;
	}
	vl dp(h, 0);
	ll count = 0;
	rep(i, h-1){
		vb map_b(3,false);
		ll plus = 0;
		if (i > 0) plus = dp[i - 1];
		rep(j, 3){
			if (map[j][i] && map[j][i + 1] && map[j + 1][i] && map[j + 1][i + 1]){
				map_b[j] = true;
			}
		}
		if (map_b[0] && map_b[2]) dp[i + 1] = 2 + plus;
		else if (map_b[0] || map_b[1] || map_b[2]) dp[i + 1] = 1 + plus;
		else dp[i + 1] = plus;
	}cout << dp[h - 1] << endl;
	return 0;
}

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

using namespace std;

#define int long long
#define INF 1e9
#define LINF 1e18

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<int, P> Pi;
typedef pair<P, P> PP;

const int MOD = 1e9 + 7;
const int dy[] = { 0, 0, 1, -1 };
const int dx[] = { 1, -1, 0, 0 };

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int H, N;
int located[100000];
int dp[2][1 << 4];
int down[5] = {0b0000, 0b0011, 0b0110, 0b1100, 0b1111};
int score[5] = {0, 1, 1, 1, 2};
signed main() {
	cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> H >> N;
    for(int i = 0; i < N; ++i) {
        int x, y;
        cin >> x >> y;
        located[y] |= 1 << x;
    }
    int *now = dp[0];
    int *next = dp[1];
    for(int i = 0; i < (1 << 4); ++i) {
        if(i & located[0]) now[i] = -1;
        else now[i] = 0;
    }
    for(int i = 0; i < H - 1; ++i) {
        fill(next, next + (1 << 4), -1);
        for(int j = 0; j < (1 << 4); ++j) {
            if(now[j] == -1) continue;
            for(int k = 0; k < 5; ++k) {
                int front = down[k] & located[i];
                int back = down[k] & located[i + 1];
                if(front || back || j & located[i]) continue;
                int next_put = down[k] | located[i];
                next[next_put] = max(next[j], now[j] + score[k]);
            }
        }
        int *temp = now;
        now = next;
        next = temp;
    }
    int res = 0;
    for(int i = 0; i < (1 << 4); ++i) chmax(res, next[i]);
    cout << res << endl;
	return 0;
}