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++
			}
		}
	}

	var openCount int
	for _,v:=range room{
		openCount=0
		for _,v2:=range v{
			if !v2{
				openCount++
			}

		}
		if openCount>=3{
			count++
		}
	}
	fmt.Println(count)
}

C++: #include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

int H,N;

vector<int> fie;

vector<vector<int>> dp;

int dfs(int h,int state){
    if(h == H) return 0;
    if(dp[h][state] != -1) return dp[h][state];

    int ans = dfs(h + 1,fie[h]);

    for(int i = 0;i < 3;i++){
        if((state >> i) & 3) continue;
        if((fie[h] >> i) & 3) continue;
        ans = max(ans , dfs(h + 1,fie[h] | (3 << i)) + 1);
    }

    if(state == 0 && fie[h] == 0){
        ans = max(ans , dfs(h + 1,(1 << 4) - 1) + 2);
    }

    return dp[h][state] = ans;
}

int main(){
    cin >> H >> N;
    fie.resize(H);
    dp.resize(H,vector<int>((1 << 4),-1));
    rep(i,0,N - 1){
        int x,y;
        cin >> x >> y;
        fie[y] |= (1 << x);
    }

    cout << dfs(1,fie[0]) << endl;
}

C++: #include <bits/stdc++.h>
using namespace std;
int h,n,dp[10001][1<<4],x,y,ans,t;
bool a[10001][4];
int main(){
	cin>>h>>n;
	for(int i=0;i<n;i++){
		cin>>x>>y;
		a[y][x]=1;
	}
	for(int i=0;i<h-1;i++){
		int maxval=0,cnt=0,c=0;
		for(int j=0;j<(1<<4);j++)
			maxval=max(maxval,dp[i-1][j]);
		if(i){
			for(int j=0;j<(1<<4);j++)
				dp[i][j]=max(dp[i][j],max(dp[i][j],maxval));
		}
		for(int j=0;j<4;j++)
			if(!a[i][j]&&!a[i+1][j])cnt++;
		if(cnt==4){
			dp[i+1][(1<<4)-1]=dp[i][0]+2;
		}
		for(int j=0;j<(1<<4);j++){
			for(int k=0;k<3;k++){
				if(!((j>>k)&1)&&!((j>>(k+1))&1)&&!a[i][k]&&!a[i][k+1]){
					if(!a[i+1][k]&&!a[i+1][k+1]){
						int p=0;
						for(int l=0;l<4;l++){
							if(a[i+1][l]||l==k||l==k+1){
								p+=(1<<l);
							}
							if(!i)cout<<p<<endl;
						}
						dp[i+1][p]=max(dp[i+1][p],dp[i][j]+1);
						if(p==(1<<4)-1)c++;
					}
				}
			}
		}
		maxval=cnt=0;
		for(int j=0;j<(1<<4);j++)
			maxval=max(maxval,dp[i-1][j]);
		if(i){
			for(int j=0;j<(1<<4);j++)
				dp[i+1][j]=max(dp[i+1][j],max(dp[i][j],maxval));
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<(1<<4);j++)
			cout<<dp[i][j]<<' ';
		cout<<endl;
	}
	for(int i=0;i<(1<<4);i++)
		ans=max(ans,dp[h-1][i]);
	cout<<ans<<endl;
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x, n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair< int, int > P;   
typedef pair< int, P > PP;

//-----------------------------------------------------------------------------

int h, n;
bool used[4][10000];

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

    cin >> h >> n;
    REP(i, n) {
        int x, y;
        cin >> x >> y;
        used[x][y] = true;
    }
    int ans = 0;
    REP(i, h - 1) {
        REP(j, 3) {
			if (j == 1) continue;
            if (used[j][i] || used[j + 1][i] || used[j][i + 1] || used[j + 1][i + 1]) continue;
            used[j][i] = used[j + 1][i] = used[j][i  +1] = used[j + 1][i + 1] = true;
            ans++;
        }
    }
    REP(i, h - 1) {
		if (used[1][i] || used[2][i] || used[1][i + 1] || used[2][i + 1]) continue;
		used[1][i] = used[2][i] = used[1][i + 1] = used[2][i + 1] = true;
		ans++;
	}
    cout << ans << endl;

    /*REP(i, h) {
		REP(j, 4) cout << used[j][i];
		cout << endl;
	}*/

    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb emplace_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define dupli(a) a.erase(unique(all(a)),a.end())
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vvvvi=vector<vvvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const ll INF=1001001001;
const ll mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){ll res=1;a%=mod;while(b){if(b&1)res=res*a%mod;a=a*a%mod;b>>=1;}return res;}

int main(){
    ll n,m;cin>>n>>m;
    vvb ok(n,vb(4,true));
    rep(i,m){
        ll x,y;cin>>x>>y;ok[y][x]=false;
    }
    ll ans=0;
    vvi dp(n,vi(16));
    rep(i,n-1)rep(j,16)rep(k,3){
        if(ok[i][k]&&ok[i+1][k]&&ok[i][k+1]&&ok[i+1][k+1]&&(j>>k&1)==0&&(j>>(k+1)&1)==0){
            chmax(dp[i+1][(1<<k)+(1<<k+1)],dp[i][j]+1);
        }
        chmax(dp[i+1][0],dp[i][j]);
        bool b=true;
        if(j)b=false;
        rep(t,4)if((!ok[i][t])||(!ok[i+1][t]))b=false;
        if(b)chmax(dp[i+1][15],dp[i][j]+2);
    }
    rep(i,n)rep(j,16)chmax(ans,dp[i][j]);
    out(ans);
}