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] {
				//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++
			}
		}
	}
	//for _,v:=range room{
	//	for _,v2:=range v{
	//		if !v2 {
	//			fmt.Print("◯")
	//		}else{
	//			fmt.Print("☓")
	//		}
	//	}
	//	fmt.Println()
	//}
	fmt.Println(count)
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

// https://www.hamayanhamayan.com/entry/2018/09/15/130935

ll dp[10010][(1<<4)]; // i行目まで見て、箱が埋まっている状態がjである
ll ng[10010][5];

// 与えられるbitが貨物室のもとから置けない状態と一致するか
ll check(ll y, ll bit){
  rep(x,4) if(ng[y][x]) if((bit>>x&1)==0) return 0;
  return 1;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll H,n; cin>>H>>n;
  
  rep(i,n){
    ll x,y; cin>>x>>y;
    ng[y][x]=1;
  }
  
  rep(y,H-1) rep(bit,1<<4) if(check(y,bit)) {
    rep(bit2,1<<4) if(check(y+1,bit2)){
      // 1
      rep(x,3){
        if(bit>>x&1) continue;
        if(bit>>(x+1)&1) continue;
        if(bit2>>x&1) continue;
        if(bit2>>(x+1)&1) continue;
        ll nbit=(bit2|(1<<x)|(1<<(x+1)));
        chmax(dp[y+1][nbit],dp[y][bit]+1);
      }
      // 2
      if(bit==0 && bit2==0){
        chmax(dp[y+1][(1<<4)-1],dp[y][0]+2);
      }
      
      chmax(dp[y+1][bit2],dp[y][bit]);
    }
  }
  
  ll ans=0;
  rep(bit,1<<4) chmax(ans,dp[H-1][bit]);
  
  cout<<ans<<endl;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <stdlib.h>

using namespace std;

int bitcount(int a) {
	return (a & 1) + ((a >> 1) & 1) + ((a >> 2) & 1) + ((a >> 3) & 1);
}

int validway[5] = {
	15, // 1111
	12, // 1100
	6,  // 0110
	3,   // 0011
	0
};

int main() {
	int h, n;

	cin >> h >> n;

	int T[10001] = {};

	for (int i = 0; n > i; i++) {
		int x, y;
		cin >> x >> y;

		T[y] ^= 1 << x;
	}


	int dp[10001][5] = {};

	for (int i = 0; 10001 > i; i++)
		for (int j = 0; 5 > j; j++) dp[i][j] = -1;

	for (int i = 0; 5 > i; i++) {
		int S = validway[i];
		if (((T[0] | T[1]) & S) == 0) {
			dp[0][i] = bitcount(S)/2;
		}
	}

	for (int y = 1; h > y; y++) {
		for (int i = 0; 5 > i; i++) {
			if (dp[y - 1][i] == -1) continue;
			for (int j = 0; 5 > j; j++) {
				int S = validway[i];
				int S2 = validway[j];
				if (((S | T[y] | T[y + 1]) & S2) == 0) {
					dp[y][j] = max(dp[y - 1][i] + bitcount(S2)/2, dp[y][j]);
				}

			}
		}
	}

	cout << max({ dp[h - 2][0], dp[h - 2][1], dp[h - 2][2], dp[h - 2][3], dp[h - 2][4] }) << endl;

	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
bool mp[10005][4];

int main(){
  ios_base::sync_with_stdio(false);
  int h,n,x,y;
  for(int i=0;i<10005;i++){
    for(int j=0;j<4;j++){
      mp[i][j] = true;
    }
  }
  cin >> h >> n;
  
  for(int i=0;i<n;i++){
    cin >> x >> y;
    mp[y][x] = false;
  }

  int ans = 0;
  for(int i=0;i<h-1;i++){
    if(mp[i][0] && mp[i][1] && mp[i+1][0] && mp[i+1][1]){ //左に正方形が作れるとき
      mp[i][0] = mp[i][1] = mp[i+1][0] = mp[i+1][1] = false;
      ans++;
    }
    if(mp[i][2] && mp[i][3] && mp[i+1][2] && mp[i+1][3]){ //右に正方形が作れるとき
      mp[i][2] = mp[i][3] = mp[i+1][2] = mp[i+1][3] = false;
      ans++;
    }
    if(mp[i][1] && mp[i][2] && mp[i+1][1] && mp[i+1][2]){ //真ん中に正方形が作れるとき
      int j=2;
      while(i+j < h && mp[i+j][0] && mp[i+j][1] && mp[i+j][2] && mp[i+j][3]) j++;
      if(j == 2 || j%2 == 0){
	mp[i][1] = mp[i][2] = mp[i+1][1] = mp[i+1][2] = false;
	ans++;
      }
    }
  }

  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;
  int b[4][10001] = {};
  rep(i, 0, n) {
    int x, y;
    cin >> x >> y;
    b[x][y] = 1;
  }
  int ans = 0;
  rep(i, 0, h - 1) {
    if(!b[0][i] && !b[1][i] && !b[0][i + 1] && !b[1][i + 1]) {
      b[0][i] = 1, b[1][i + 1] = 1;
      b[0][i] = 1, b[1][i + 1] = 1;
      ans++;
    }
  }
  rep(i, 0, h - 1) {
    if(!b[2][i] && !b[3][i] && !b[2][i + 1] && !b[3][i + 1]) {
      b[2][i] = 1, b[3][i + 1] = 1;
      b[2][i] = 1, b[3][i + 1] = 1;
      ans++;
    }
  }
  rep(i, 0, h - 1) {
    if(!b[1][i] && !b[2][i] && !b[1][i + 1] && !b[2][i + 1]) {
      b[1][i] = 1, b[2][i + 1] = 1;
      b[1][i] = 1, b[2][i + 1] = 1;
      ans++;
    }
  }
  cout << ans << endl;
}