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] {
				room[j][i] = true
				room[j+1][i] = true
				room[j][i+1] = true
				room[j+1][i+1] = true
				count++
			}
		}
	}
	fmt.Println(count)
}

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

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);
		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>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;

bool b[10000][4];
int dp[20000][1<<4];
int main(){
	int h,n;scanf("%d%d",&h,&n);
	rep(i,n){
		int x,y;scanf("%d%d",&y,&x);
		b[h-x-1][y]=true;
	}
	rep(i,h-1)rep(j,1<<4){
		dp[i+1][0]=max(dp[i+1][0],dp[i][j]);
		rep(k,3){
			if(!(j>>k&1)&&!(j>>(k+1)&1)&&!b[i][k]&&!b[i][k+1]&&!b[i+1][k]&&!b[i+1][k+1]){
				dp[i+1][(1<<k)|(1<<(k+1))]=max(dp[i+1][(1<<k)|(1<<(k+1))],dp[i][j]+1);
			}
		}
		if(j==0){
			bool flag=true;
			rep(k,2)rep(t,4){
				if(b[i+k][t]==1)flag=false;
			}
			if(flag){
				dp[i+1][(1<<4)-1]=max(dp[i+1][(1<<4)-1],dp[i][j]+2);
			}
		}
	}
	int ans=0;
	rep(i,1<<4){
		ans=max(ans,dp[h-1][i]);
	}
	cout<<ans<<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 );
}