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 < H-1; i++ {
		for j := 0; j < 3; j++ {
			if !room[i][j] && !room[i+1][j] && !room[i][j+1] && !room[i+1][j+1] {
				room[i][j] = true
				room[i+1][j] = true
				room[i][j+1] = true
				room[i+1][j+1] = true
				count++
			}
		}
	}
	fmt.Println(count)
}

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

int main() {
  int h,n;
  cin >> h >> n;
  int a[h][4];
  memset(a,0,sizeof(a));
  for(int i=0; i<n; i++) {
    int x,y;
    cin >> y >> x;
    a[x][y]=1;
  }
  int dp[2][1<<6],r=0;
  for(int i=0;i<2;i++)for(int t=0;t<(1<<6);t++)dp[i][t]=-(1<<30);
  dp[0][0]=0;
  for(int i=0; i<h*4; i++) {
    for(int t=0; t<(1<<6); t++) {
      int x=i/4,y=i%4,s=t/2;
      for(int j=4; j>=0; j--) {
        y--;
        if(y<0) y=3,x--;
        if(x<0) break;
        if(a[x][y]&&!(t&(1<<j))) goto next;
      }
      x=i/4,y=i%4;
      if(a[x][y]) s|=1<<4;
      dp[r^1][s]=max(dp[r^1][s],dp[r][t]);
      if(!y||i<5) continue;
      if(a[x][y]||a[x][y-1]||a[x-1][y]||a[x-1][y-1]||(t&51));
      else {
        s=(t/2)|25;
        dp[r^1][s]=max(dp[r^1][s],dp[r][t]+1);
      }
    next:;
    }
    memset(dp[r],0,sizeof(dp[r]));
    r^=1;
  }
  int ans=0;
  for(int t=0; t<(1<<6); t++) ans=max(ans,dp[r][t]);
  cout << ans << endl;
  return 0;
}

C++: #include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int h, n;
int a[10010];
int b[5] = {0b0000, 0b0011, 0b0110, 0b1100, 0b1111};
int c[5] = {0, 1, 1, 1, 2};
int dp[10010][5];
int ans;

int main(){
	scanf("%d %d", &h, &n);
	for(int i=0; i<n; ++i){
		int x, y;
		scanf("%d %d", &x, &y);
		a[y] += 1<<x;
	}
//	for(int i=0; i<h; ++i) printf("%d\t", a[i]);
//	printf("\n");
//	for(int i=0; i<5; ++i) printf("%d\n", b[i]);
	for(int i=1; i<h; ++i)
		for(int j=0; j<5; ++j)
			for(int k=0; k<5; ++k)
				if((a[i-1] & b[j]) == 0 && (a[i] & b[j]) == 0 && (b[k] & b[j]) == 0)
					dp[i][j] = max(dp[i][j], dp[i-1][k] + c[j]);
	for(int i=0; i<5; ++i) ans = max(ans, dp[h-1][i]);
	printf("%d\n", ans);
}

C++: #include<cstdio>
#include<algorithm>
using namespace std;
bool ni[10005][10] = {false};
int ku[10005][10] = {};
int main(){
  int h,n,x,y;
  scanf("%d %d",&h,&n);
  for(int i=0;i<n;i++){
    scanf("%d %d",&x,&y);
    ni[y][x] = true;
  }
  for(int i=1;i<h;i++){
    for(int j=1;j<4;j++){
      if(!ni[i-1][j-1] && !ni[i-1][j] && !ni[i][j-1] && !ni[i][j])ku[i][j] = 1;
      if(i > 1) ku[i][j] += ku[i-2][j];
      if(j > 1) ku[i][j] += ku[i][j-2];
      if(i > 1 && j > 1) ku[i][j] -= ku[i-2][j-2];
      ku[i][j] = max(ku[i][j],ku[i-1][j]+ku[i][j-1]-ku[i-1][j-1]);
    }
  }
  printf("%d\n",ku[h-1][3]);
  return(0);
}

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