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;

int H,N;
int t[100005][4];
int dp[100005][1<<4];

int main(){
  cin>>H>>N;
  for(int i=0;i<N;i++){
    int x,y;
    cin>>x>>y;
    t[x][y]=1;
  }
  
  for(int i=0;i<H;i++)
    for(int j=0;j< (1<<4);j++)
      dp[i][j]=-100000000;
  
  dp[0][0]=0;
  int ans=0;
  
  for(int i=0;i<H;i++){
  
    for(int b=0;b<(1<<4);b++){
      cout<<i<<' '<<b<<endl;
      
      ans=max(ans,dp[i][b]);
      if(i==H-1)continue;
      
      int tmp[2][4]={};
      
      for(int j=0;j<4;j++){
        tmp[0][j]=t[i][j];
        tmp[1][j]=t[i+1][j];
        tmp[0][j]|=(b>>j&1);
      }

      if(!tmp[0][0]&&!tmp[0][1]&&!tmp[1][0]&&!tmp[1][1]){
        dp[i+1][3]=max(dp[i+1][3],dp[i][b]+1);
      }
      
      if(!tmp[0][1]&&!tmp[0][2]&&!tmp[1][1]&&!tmp[1][2]){
        dp[i+1][6]=max(dp[i+1][6],dp[i][b]+1);
      }
      
      if(!tmp[0][2]&&!tmp[0][3]&&!tmp[1][2]&&!tmp[1][3]){
        dp[i+1][3]=max(dp[i+1][12],dp[i][b]+1);
      }
      
      if(!tmp[0][0]&&!tmp[0][1]&&!tmp[1][0]&&!tmp[1][1]){
        if(!tmp[0][2]&&!tmp[0][3]&&!tmp[1][2]&&!tmp[1][3]){
          dp[i+1][15]=max(dp[i+1][15],dp[i][b]+2);
        }
      }
      
    }

    
  }

  cout<<ans<<endl;
  return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

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

  bool t[4][10005] = {};

  rep(i, 0, n) {
    int x, y;
    cin >> x >> y;
    t[x][y] = true;
  }
  int ans = 0;
  rep(i, 0, h - 1) {
    if(!t[0][i] && !t[1][i] && !t[0][i + 1] && !t[1][i + 1]) {
      ans++, t[1][i] = true, t[0][i + 1] = true, t[1][i + 1] = true;
    }
    if(!t[2][i] && !t[3][i] && !t[2][i + 1] && !t[3][i + 1]) {
      ans++, t[2][i] = true, t[2][i + 1] = true, t[3][i + 1] = true;
    }
    if(!t[1][i] && !t[2][i] && !t[1][i + 1] && !t[2][i + 1]) {
      int k = 0;
      while(!t[0][i] && !t[1][i] && !t[2][i] && !t[3][i] && i < h) k++;
      if(k <= 2 || k % 2) {
        ans++, t[1][i + 1] = true, t[2][i + 1] = true;
      }
    }
  }
  cout << ans << endl;
}

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

using namespace std;
using LL = long long int;

const int MAX_N = 40005;

int H, N;
int X[MAX_N], Y[MAX_N];

bool hako[MAX_N][4];

int dp[MAX_N];

bool check(int y, int x)
{
  if(x < 3 && y < H-1) {
    return !hako[y][x] && !hako[y+1][x] && !hako[y][x+1] && !hako[y+1][x+1];
  } else {
    return false;
  }
}

int main()
{
  cin >> H >> N;
  for(int i = 0; i < N; i++) {
    cin >> X[i] >> Y[i];
  }

  for(int i = 0; i < N; i++) {
    hako[Y[i]][X[i]] = true;
  }

  memset(dp, 0, sizeof(dp));

  for(int i = 0; i < H; i++) {
    //cerr << dp[i] << endl;
    //テァツスツョテ」ツ?凝」ツ?ェテ」ツ??
    dp[i+1] = max(dp[i+1], dp[i]);
    //テァツスツョテ」ツ??
    if(i < H-1) {
      int cnt = 0;
      if(check(i, 0)) {
        cnt++;
        if(check(i, 2)) {
          cnt++;
        }
      } else if(check(i, 1)){
        cnt++;
      } else if(check(i, 2)) {
        cnt++;
      }
      //cerr << i << " " << cnt << endl;
      dp[i+2] = max(dp[i+2], dp[i]+cnt);
    }
  }

  cout << dp[H] << endl;

  return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <bitset>
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 H, N;
vector<int> space;

int dp[10010][15];

int put(int now, int back){
    if(now == H - 1){
        return 0;
    }else if(dp[now][back] != -1){
        return dp[now][back];
    }
    int ans = put(now + 1, space[now + 1]);
    if(!(back & 3) && !(space[now + 1] & 3)){ // ooxx
        ans = max(ans, put(now + 1, space[now + 1] | 3) + 1);
    }
    if(!(back & 6) && !(space[now + 1] & 6)){ // xoox
        ans = max(ans, put(now + 1, space[now + 1] | 6) + 1);
    }
    if(!(back & 12) && !(space[now + 1] & 12)){ // xxoo
        ans = max(ans, put(now + 1, space[now + 1] | 12) + 1);
    }
    if(!(back & 15) && !(space[now + 1] & 15)){ // oooo
        ans = max(ans, put(now + 1, space[now + 1] | 15) + 2);
    }
    return dp[now][back] = ans;
}

int main(){
    cin >> H >> N;
    space.resize(H, 0);
    for(int i = 0; i < N; i++){
        int x, y;
        cin >> x >> y;
        space[y] |= (1 << x);
    }
    for(int i = 0; i < 10010; i++){
        for(int j = 0; j < 15; j++){
            dp[i][j] = -1;
        }
    }
    cout << put(0, space[0]) << endl;
}