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] {
				room[j][i] = true
				room[j+1][i] = true
				room[j][i+1] = true
				room[j+1][i+1] = true
				count++
			}
		}
	}
	fmt.Println(count)
}

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

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[x][y] = '#';
	}

	int A = 0;
	int B = 0;

	for (int i = 0; i < H;){
		bool can = true;
		for (int j = 0; j < 4; j++){
			if (ship[i + dy[j]][0 + dx[j]] == '#' || i+dy[j] >= H) {
				can = false;
			}
		}
		if (can){
			i += 2;
			A++;
		}
		else i++;

	}

	for (int i = 0; i < H;) {
		bool can = true;
		for (int j = 0; j < 4; j++) {
			if (ship[i + dy[j]][3 + dx[j]] == '#' || i + dy[j] >= H) {
				can = false;
			}
		}
		if (can) {
			i += 2;
			A++;
		}
		else i++;

	}

	for (int i = 0; i < H;) {
		bool can = true;
		for (int j = 0; j < 4; j++) {
			if (ship[i + dy[j]][2 + dx[j]] == '#' || i + dy[j] >= H) {
				can = false;
			}
		}
		if (can) {
			i += 2;
			B++;
		}
		else i++;
	}

	cout << max(A, B) << endl;



	


}