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;

#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 main(){
    int H,N,F[10100];
    cin>>H>>N;
    long long dp[10100][1<<4],ans;

    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] = -1e9;
        }
    }

    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);
            }
        }
    }
    FOR(i,0,(1<<4)) ans = max(ans,dp[H-1][i]);
    put(ans);
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LL long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
//
int H,N,X,Y;
int SIP[10000][4];
int DP[10000][1<<4];
int main(){
  cin>>H>>N;
  FOR(i,0,N){
    cin>>X>>Y;
    SIP[Y][X]=1;
  }
  FOR(i,0,H){
    FOR(j,0,4){
      DP[i][j]=-INF;
    }
  }
  DP[0][0]=0;
  int ans=0;
  FOR(i,0,H){
    FOR(j,0,(1<<4)){
      ans=max(ans,DP[i][j]);
      if(i==H-1){
        continue;
      }
      int tool[2][4];
      FOR(k,0,2){
        FOR(l,0,4){
          tool[k][l]=0;
        }
      }
      FOR(k,0,4){
        tool[0][k]=SIP[i][j];
        tool[1][k]=SIP[i+1][j];
        tool[0][k]|=(j>>k&1);
      }
      DP[i+1][0]=max(DP[i+1][0],DP[i][j]);
      if(!tool[0][0]&&!tool[0][1]&&!tool[1][0]&&!tool[1][1]){
        DP[i+1][3]=max(DP[i+1][3],DP[i][j]+1);
      }
      if(!tool[0][1]&&!tool[0][2]&&!tool[1][1]&&!tool[1][2]){
        DP[i+1][6]=max(DP[i+1][6],DP[i][j]+1);
      }
      if(!tool[0][2]&&!tool[0][3]&&!tool[1][2]&&!tool[1][3]){
        DP[i+1][12]=max(DP[i+1][12],DP[i][j]+1);
      }
      if(!tool[0][0]&&!tool[0][1]&&!tool[1][0]&&!tool[1][1]){
        if(!tool[0][2]&&!tool[0][3]&&!tool[1][2]&&!tool[1][3]){
          DP[i+1][15]=max(DP[i+1][15],DP[i][j]+2);
        }
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

template<class like_bool> inline void YES(like_bool condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class like_bool> inline void Yes(like_bool condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class like_bool> inline void POSS(like_bool condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class like_bool> inline void Poss(like_bool condition){ if(condition)cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class like_bool> inline void First(like_bool condition){ if(condition)cout << "First" << endl; else cout << "Second" << endl; }
int character_count(string text, char character){ int ans = 0; for(int i = 0; i < text.size(); i++){ ans += (text[i] == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}};
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
long gcd(long a, long b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }}
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcount(n)

int main(){
    int H, N;
    cin >> H >> N;
    vector<vector<bool>> space(H, vector<bool>(4, true));
    for(int i = 0; i < N; i++){
        int x, y;
        cin >> x >> y;
        space[y][x] = false;
    }
    int ans = 0;
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < H - 1; j++){
            if(space[j][i] && space[j][i + 1] && space[j + 1][i] && space[j + 1][i + 1]){
                space[j][i] = space[j][i + 1] = space[j + 1][i] = space[j + 1][i + 1] = false;
                ans++;
            }
        }
    }
    cout << ans << endl;
}

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

using namespace std;

int H, N;
int ngmask[10000];
int dp[10000][1 << 4];

int rec(int idx, int upbit)
{
  if(idx == H) return (0);
  if(~dp[idx][upbit]) return (dp[idx][upbit]);
  int ret = rec(idx + 1, ngmask[idx]);
  for(int i = 0; i < 3; i++) {
    if((upbit >> i) & 3) continue;
    if((ngmask[idx] >> i) & 3) continue;
    ret = max(ret, rec(idx + 1, (3 << i) | ngmask[idx]) + 1);
  }
  if(ngmask[idx] == 0 && upbit == 0) {
    ret = max(ret, rec(idx + 1, (1 << 4) - 1) + 2);
  }
  return (dp[idx][upbit] = ret);
}

int main()
{
  cin >> H >> N;
  for(int i = 0; i < N; i++) {
    int x, y;
    cin >> x >> y;
    ngmask[y] |= 1 << x;
  }
  memset(dp, -1, sizeof(dp));
  cout << rec(1, ngmask[0]) << endl;
}

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

int main() {
  int W = 4, H, N;
  cin >> H >> N;

  set<pair<int, int>> P;
  for(auto i = 0; i < N; ++i) {
    int x, y;
    cin >> x >> y;
    P.emplace(y, x);
  }

  int res = 0;

  auto ok = [&](int i, int j) {
    for(auto y: {i, i + 1}) for(auto x: {j, j + 1}) if(P.count({y, x})) return false;
    return true;
  };

  for(auto i = 0; i < H - 1; ++i) {
    for(auto j = 0; j < W - 1; ++j) {
      if(ok(i, j)) {
        ++res;
        for(auto y: {i, i + 1}) for(auto x: {j, j + 1}) P.emplace(y, x);
      }
    }
  }

  cout << res << endl;
}