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<iostream>
using namespace std;

int bo[50000][4]={{}};
int cou=0;

void ch(int a,int b){
    if(bo[a+1][b]==0 && bo[a][b+1]==0 && bo[a+1][b+1]==0){
        bo[a][b]=1;
        bo[a+1][b]=1;
        bo[a][b+1]=1;
        bo[a+1][b+1]=1;
        //cout << a << " " << b << endl;
        cou++;
    }
}

int main(){
    int h,n;
    cin >> h >> n;
    for(int i=0;i<n;i++){
        int x,y;
        cin >> x >> y;
        bo[y][x]=0;
    }

    for(int i=0;i<h-1;i++){
        for(int j=0;j<3;j++){
            if(bo[i][j]==0){
                ch(i,j);
            }
        }
    }

    cout << cou << 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 + 1 + k] && !t[1][i + 1 + k] && !t[2][i + 1 + k] && !t[3][i + 1 + k] && i + 1 + k < h) k++;
      if(k < 2 || k % 2) {
        ans++, t[1][i + 1] = true, t[2][i + 1] = true;
      }
    }
  }
  cout << ans << endl;
}

C++: #include <iostream>
#include <vector>

using namespace std;

int main(){
	int h, n, x, y;
	cin >> h >> n;
	int array[h][4];

	for(int i = 0; i < h; i++){
		array[i][0] = 0;
		array[i][1] = 0;
		array[i][2] = 0;
		array[i][3] = 0;
	}

	for(int i = 0; i < n; i++){
		cin >> x >> y;
		array[y][x] = -1;
	}

	int count = 1;
	for(int i = 0; i < h-1; i++){
		for(int j = 0; j < 3; j++){
			if(array[i][j] == 0 && array[i+1][j] == 0 && array[i][j+1] == 0 && array[i+1][j+1] == 0){
				array[i][j] = count;
				array[i+1][j] = count;
				array[i][j+1] = count;
				array[i+1][j+1] = count;
				count++;
			}
		}
	}

	cout << count-1 << endl;
}

C++: #include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 28;
int main()
{
    int dp[10005][1 << 4];
    int row[10005] = {}; //bit
    int H, N;
    cin >> H >> N;
    for(int i = 0; i < N; i++) {
        int x, y;
        cin >> x >> y;
        row[y] |= (1 << x);
    }
    fill_n(*dp, 10005 * 16, -INF);
    dp[0][row[0]] = 0;
    for(int i = 0; i < H - 1; i++) {
        for(int j = 0; j < (1 << 4); j++) {
            if(dp[i][j] == -INF) continue;
            dp[i + 1][row[i + 1]] = max(dp[i + 1][row[i + 1]], dp[i][j]);
            if(j == 0 && row[i + 1] == 0) {
                dp[i + 1][(1 << 4) - 1] = max(dp[i + 1][(1 << 4) - 1], dp[i][j] + 2);
            }
            for(int k = 0; k < 3; k++) {
                int bit = (1 << k) | (1 << (k + 1));
                if((j & bit) == 0 && (row[i + 1] & bit) == 0) {
                    dp[i + 1][row[i + 1] | bit] = max(dp[i + 1][row[i + 1] | bit], dp[i][j] + 1);
                }
            }
        }
    }
    int maxv = 0;
    for(int i = 0; i < (1 << 4); i++) {
        maxv = max(dp[H - 1][i], maxv);
    }
    cout << maxv << endl;
    return (0);
}

C++: #include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

#define INF_LL (ll)1e18
#define INF (int)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
using ll = long long;
using PII = pair<int, int>;
using ipii = pair<int, PII>;

#define fst first
#define snd second
const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}
int dx[4] = {0, 0, 1, 1};
int dy[4] = {0, 1, 0, 1};

int main(void){
	bool f[4][10010] = {};
	
	int H, N;
	cin >> H >> N;
	REP(i, N){
		int x, y;
		cin >> x >> y;
		f[x][H-y-1] = 1;
	}

	int sp[10010] = {};
	vector<int> con;
	int cn = 0;
	REP(i, H){
		int cnt = 0;
		REP(j, 4){
			if(f[j][i])
				cnt++;
		}
		if(cnt == 0){
			if(con.size() == 0)
				con.push_back(0);
			sp[i]++;
			if(i > 0 && sp[i-1] == 0){
				con.push_back(cn);
				cn = 0;
			}
		}else{
			if(i > 0 && sp[i-1] == 1){
				con.push_back(cn);
				cn = 0;
			}
		}
		cn++;
	}
	con.push_back(cn);
	ll res = 0;
	int sum = 0;
	int in = 0;
	vector<int> ei({0, 2, 1});
	REP(i, H-1){
		while(sum < i+2)
			sum += con[in++];
		if(sp[i] == 0){
			if(sp[i+1] == 1){
				if((sum-i-1)%2){
					for(auto k : ei){
						int cnt = 0;
						REP(t, 4){
							if(f[k+dx[t]][i+dy[t]] == 1)
								cnt++;
						}
						if(cnt == 0){
							REP(t, 4){
								f[k+dx[t]][i+dy[t]] = 1;
							}
							res++;
						}
					}
				}
			}else{
				for(auto k : ei){
					int cnt = 0;
					REP(t, 4){
						if(f[k+dx[t]][i+dy[t]] == 1)
							cnt++;
					}
					if(cnt == 0){
						REP(t, 4){
							f[k+dx[t]][i+dy[t]] = 1;
						}
						res++;
					}
				}
			}
		}else{
			for(auto k : ei){
				int cnt = 0;
				REP(t, 4){
					if(f[k+dx[t]][i+dy[t]] == 1)
						cnt++;
				}
				if(cnt == 0){
					REP(t, 4){
						f[k+dx[t]][i+dy[t]] = 1;
					}
					res++;
				}
			}
		}
	}
	cout << res << endl;
}

C++: #include <stdio.h>
#define MAX_H 100000
int blocked[MAX_H];
int dp[2][1<<4];
main() {
 int h, n; scanf("%d %d", &h, &n);
 int x, y;
 for ( int i=0; i<n; ++i ) {
scanf(“%d %d”, &x, &y); blocked[y] |= 1<<x;
 }
 int locate[5] = { 0x0, 0x3, 0x6, 0xc, 0xf };//置き方パターン
 int add[5] = { 0, 1, 1, 1, 2 };//各置き方パターンで置ける個数

 int* crt = dp[0];
 int* next = dp[1];

 for ( int obstacle=0; obstacle<1<<4; ++obstacle ) {
if ( obstacle&blocked[0] ) crt[obstacle] = -1;
else crt[obstacle] = 0;
 }

 for ( int i=0; i<h-1; ++i ) {
std::fill( next, next+(1<<4), -1 );
for ( int obstacle=0; obstacle<1<<4; ++obstacle ) {//既に有るものパターン(current)
 if ( crt[obstacle] == -1 ) continue;
 for ( int k=0; k<5; ++k ) {//置き方パターン(next)
int check0 = blocked[i] & locate[k];
int check1 = blocked[i+1] & locate[k];
if ( !check0 && !check1 && !(obstacle&locate[k])) {
 int patt = blocked[i+1] | locate[k];
 next[patt] = std::max( crt[obstacle] + add[k], next[patt] );
}
 }
}
int* tmp = crt;
crt = next;
next = tmp;
 }
 int res = 0;
 for ( int i=0; i<1<<4; ++i ) if ( next[i] > res ) res = next[i];
 printf("%d¥n", res );
}