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("x")
	//
	//		}else{
	//			fmt.Print("o")
	//		}
	//
	//	}
	//	fmt.Println()
	//}
	fmt.Println(count)
}

C++: #include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　 |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/






int H, N;
int ng[10101][4];
int dp[10101][1 << 4];
//---------------------------------------------------------------------------------------------------
int check(int y, int msk) {
    rep(x, 0, 4) if (ng[y][x]) if (!(msk & (1 << x))) return 0;
    return 1;
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> H >> N;
    rep(i, 0, N) {
        int x, y; cin >> x >> y;
        ng[y][x] = 1;
    }

    rep(y, 0, H - 1) rep(msk, 0, 1 << 4) if(check(y, msk)) {
        rep(msk2, 0, 1 << 4) if (check(y + 1, msk2)) {
            // 1個置く
            rep(x, 0, 3) {
                if (msk & (1 << x)) continue;
                if (msk & (1 << (x+1))) continue;
                if (msk2 & (1 << x)) continue;
                if (msk2 & (1 << (x + 1))) continue;

                chmax(dp[y + 1][msk2 + (1 << x) + (1 << (x + 1))], dp[y][msk] + 1);
            }
            // 2個置く
            if (msk == 0 and msk2 == 0) chmax(dp[y + 1][(1 << 4) - 1], dp[y][0] + 2);
            chmax(dp[y + 1][msk2], dp[y][msk]);
        }
    }

    int ans = 0;
    rep(msk, 0, 1 << 4) if (check(H - 1, msk)) chmax(ans, dp[H - 1][msk]);
    cout << ans << endl;
}

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

#define put(n) cout<<(n)<<endl;
#define FOR(i,num,N) for(int(i)=(num);(i)<(N);++(i))
#define RFOR(i,num,N) for(int (i)=(num);(i)>(N);--(i))
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()

int H,N,F[10100];
long long dp[10100][1<<4],ans=-1;

int main(){
    cin>>H>>N;

    FOR(i,0,N){
        int x,y; cin>>x>>y;
        F[y] |= (1<<x);
    }

    FOR(i,0,10100){
        FOR(j,0,(1<<4)){
            dp[i][j] = -1;
        }
    }

    dp[0][F[0]] = 0;

    FOR(i,0,H-1){
        FOR(state,0,(1<<4)){
            FOR(bit,0,(1<<3)){
                int next = F[i+1],cnt=0,ok=1;
                FOR(j,0,3){
                    if(!(bit&(1<<j))) continue;
                    if(state&(3<<j) || next&(3<<j)) ok = 0;
                    next |= (3<<j);
                    ++cnt;
                }
                if(!ok) continue;
                dp[i+1][next] = max(dp[i+1][next],dp[i][state]+cnt);
            }
        }
    }
    FOR(i,0,(1<<4)) ans = max(ans,dp[H-1][i]);
    put(ans);
}

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

C++: #include<algorithm>
#include <bits/stdc++.h>
#include <math.h>
#include <queue>
using namespace std;
int ma[100000][4];
int main(void){
	
	int h,n,x,y,ans=0;
	cin>>h>>n;
	for(int i=0;i<n;i++){
		cin>>y>>x;
		ma[x][y]=1;
	}
	for(int i=0;i<h-1;i++){
		for(int j=0;j<3;j+=2){
			if(ma[i][j]!=1&&ma[i+1][j]!=1&&ma[i][j+1]!=1&&ma[i+1][j+1]!=1){
				ans++;
				ma[i][j]=1;
				ma[i+1][j]=1;
				ma[i][j+1]=1;
				ma[i+1][j+1]=1;
			}
		}
	}
	for(int i=0;i<h-1;i++){
		for(int j=0;j<3;j++){
			if(ma[i][j]!=1&&ma[i+1][j]!=1&&ma[i][j+1]!=1&&ma[i+1][j+1]!=1){
				ans++;
				ma[i][j]=1;
				ma[i+1][j]=1;
				ma[i][j+1]=1;
				ma[i+1][j+1]=1;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
#include<unordered_set>
using namespace std;
/*int p = 998244353;*/
int p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<int,pin>
#define V vector
#define Endl endl
#define veb vector<bool>
#define rev(s) reverse(s.begin(),s.end())
signed main() {
	int h, n; cin >> h >> n;
	if (h == 1) { cout << 0 << endl; return 0; }
	vvel dp(h, vel(16, 0));
	vvel nex = { {0},{12,6,3},{15} };
	vel sta(h, 0);
	rep(i, n) {
		int x, y; cin >> x >> y;
		sta[y] += (1 << x);
	}
	for (int i = 0; i < h - 1; i++) {
		for (int j = 0; j < 16; j++) {
			if ((sta[i] & j) == 0) {
				int qsta = sta[i] ^ j;
				for (int k = 0; k < 3; k++) {
					for (auto x : nex[k]) {
						if ((qsta&x) == 0) {
							mmax(dp[i + 1][x], dp[i][j] + k);
						}
					}
				}
			}
		}
	}
	int ans = 0;
	for (int j = 0; j < 16; j++) {
		if ((sta[h-1] & j) == 0) {
			mmax(ans, dp[h - 1][j]);
		}
	}
	cout << ans << endl;
	return 0;
}