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

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include<random>
#include<math.h>
#include<limits.h>
#include<iterator>
#include<queue>
#include<functional>
#define rep(i,a) for(int i=0;i<a;i++)
#define nrep(i,a,b) for(int i=a;i<b;i++)
#define mrep(i,a) for(int i=a;i>=0;i--)
#define ll long long
#define vl vector<ll> 
#define vvl vector<vector<ll> > 
#define vb vector<bool> 
#define vvb vector<vector<bool> > 
#define INF 11234567890123456789
using namespace std;

int main(){
	ll h, n; cin >> h >> n;
	vvb map(4, vb(h, true));
	rep(i, n){
		ll x, y; cin >> x >> y;
		map[x][y] = false;
	}
	vl dp(h, 0);
	ll count = 0;
	rep(i, h-1){
		vb map_b(3,false);
		ll plus = 0;
		if (i > 0) plus = dp[i - 1];
		rep(j, 3){
			if (map[j][i] && map[j][i + 1] && map[j + 1][i] && map[j + 1][i + 1]){
				map_b[j] = true;
			}
		}
		if (map_b[0] && map_b[2]) dp[i + 1] = 2 + plus;
		else if (map_b[0] || map_b[1] || map_b[2]) dp[i + 1] = 1 + plus;
		else dp[i + 1] = plus;
	}cout << dp[h - 1] << endl;
	return 0;
}

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

using namespace std;

#define int long long
#define INF 1e9
#define LINF 1e18

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<int, P> Pi;
typedef pair<P, P> PP;

const int MOD = 1e9 + 7;
const int dy[] = { 0, 0, 1, -1 };
const int dx[] = { 1, -1, 0, 0 };

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int H, N;
int located[100000];
int dp[2][1 << 4];
int down[5] = {0b0000, 0b0011, 0b0110, 0b1100, 0b1111};
int score[5] = {0, 1, 1, 1, 2};
signed main() {
	cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> H >> N;
    for(int i = 0; i < N; ++i) {
        int x, y;
        cin >> x >> y;
        located[y] |= 1 << x;
    }
    int *now = dp[0];
    int *next = dp[1];
    for(int i = 0; i < (1 << 4); ++i) {
        if(i & located[0]) now[i] = -1;
        else now[i] = 0;
    }
    for(int i = 0; i < H - 1; ++i) {
        fill(next, next + (1 << 4), -1);
        for(int j = 0; j < (1 << 4); ++j) {
            if(now[j] == -1) continue;
            for(int k = 0; k < 5; ++k) {
                int front = down[k] & located[i];
                int back = down[k] & located[i + 1];
                if(front || back || j & located[i]) continue;
                int next_put = down[k] | located[i];
                next[next_put] = max(next[j], now[j] + score[k]);
            }
        }
        int *temp = now;
        now = next;
        next = temp;
    }
    int res = 0;
    for(int i = 0; i < (1 << 4); ++i) chmax(res, next[i]);
    cout << res << endl;
	return 0;
}

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