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;
typedef long long ll;
#define _overload4(_1,_2,_3,_4,name,...) name
#define _overload3(_1,_2,_3,name,...) name
#define _overload2(_1,_2,name,...) name
#define _re(n) _rep(i,n)
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(ll i=a;i<b;++i)
#define _repc(i,a,b,c) for(ll i=a;i<b;i+=c)
#define rep(...) _overload4(__VA_ARGS__,_repc,_repi,_rep,_re)(__VA_ARGS__)
#define _rre(n) _rrep(i,n)
#define _rrep(i,n) _rrepi(i,0,n)
#define _rrepi(i,a,b) for(ll i=b-1;i>=a;i--)
#define _rrepc(i,a,b,c) for(ll i=a+(b-a-1)/c*c;i>=a;i-=c)
#define rrep(...) _overload4(__VA_ARGS__,_rrepc,_rrepi,_rrep,_rre)(__VA_ARGS__)
#define sum(...) accumulate(range(__VA_ARGS__),0)
#define _range(i) (i).begin(),(i).end()
#define _rangek(i,k) (i).begin(),(i).begin()+k
#define range(...) _overload2(__VA_ARGS__,_rangek,_range)(__VA_ARGS__)
#define LINF (ll)1000000000000000000
#define MOD (ll)1000000007
#define INF (int)1000000007
#define Yes(i) out(i?"Yes":"No")
#define YES(i) out(i?"YES":"NO")
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define vec(type,name,size) vector<type> name(size);
#define VEC(type,name,size) vector<type> name(size);in(name)
struct aaa{aaa(){cin.tie(0); cout.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}aaaaaaa;
inline void in() {}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec);
template<typename T,typename L>
istream& operator >> (istream& is, pair<T,L>& p);
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec);
template<typename T,typename L>
ostream& operator << (ostream& os, pair<T,L>& p);
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){for(T& x: vec) is >> x;return is;}
template<typename T,typename L>
istream& operator >> (istream& is, pair<T,L>& p){is >> p.first;is >> p.second;return is;}
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){os << vec[0];rep(i,1,vec.size()){os << ' ' << vec[i];}return os;}
template<typename T,typename L>
ostream& operator << (ostream& os, pair<T,L>& p){os << p.first << " " << p.second;return os;}
template <class Head, class... Tail>
inline void in(Head&& head,Tail&&... tail){cin>>head;in(move(tail)...);}
template <class T>
inline void out(T t){cout<<t<<'\n';}
inline void out(){cout<<'\n';}
template <class Head, class... Tail>
inline void out(Head head,Tail... tail){cout<<head<<' ';out(move(tail)...);}


int main(){
    INT(h,n);
    vector<vector<bool>>a(4,vector<bool>(h));
    rep(n){
        INT(x,y);
        a[x][y]=1;
    }
    rep(h){
        rep(j,4)cerr<<(a[j][i]?'#':'.');
        cerr<<endl;
    }
    int ans=0;
    rep(j,h-1)if(!a[0][j]&&!a[0+1][j]&&!a[0][j+1]&&!a[0+1][j+1]){
        a[0][j]=a[0+1][j]=a[0][j+1]=a[0+1][j+1]=1;
        ans++;
    }
    rep(j,h-1)if(!a[2][j]&&!a[2+1][j]&&!a[2][j+1]&&!a[2+1][j+1]){
        a[2][j]=a[2+1][j]=a[2][j+1]=a[2+1][j+1]=1;
        ans++;
    }
    rep(j,h-1)if(!a[1][j]&&!a[1+1][j]&&!a[1][j+1]&&!a[1+1][j+1]){
        a[1][j]=a[1+1][j]=a[1][j+1]=a[1+1][j+1]=1;
        ans++;
    }
    out(ans);
}

C++: #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

/*
<url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0363>
?????????============================================================
????´\??????????????????????????°???????????????????????????????????????????????????
 ??????????????????????????????????????????????????§????????§????¨?????????????????????????????????§?????????
 ??¨?????????????????¢??§????¨???????????????§??????????????????????????????????????????????????§?????????
 ???????????????????¨???¨????????????????????????????????¨????????????????¢?????????????????????????????????????????????????????????????????????????????????§???????????????
 ????????????????????????????????????????????????????????¨?????§????????????????????????????????????????????????????????????
 
 ?????¨?????????????????¨????????????????????§????????????????????§??????????????????????????§??§??????????????????????????\????????????
 ??¨???????????????????????¨??????????????§???????????????????????????????????????????????¨??????
 ?????§??§??????????????????????????????????????±?????????????????°????????????????????????
=================================================================

?§£??¬=============================================================
 dp[i][S] := i-1???????????§????????????i-1?????????????????¶??????S??????????????§?????°
================================================================
*/

ll H,N;
ll dp[10010][1<<4];
bool masu[10010][4];

bool ok(int x,int y,int S){
    if(x < 3 && y < H - 1){
        return !masu[y][x] && !masu[y][x+1] && !masu[y+1][x] && !masu[y+1][x+1] && !((S>>x)&1) && !((S>>(x+1))& 1);
    }else return false;
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    cin >> H >> N;
    for(int i = 0; i < N;i++){
        ll x,y; cin >> x >> y;
        masu[y][x] = true;
    }
    for(int i = 0; i < H;i++){
        for(int j = 0; j < (1<<4);j++){
            if(ok(0,i,j)){
                if(ok(2,i,j)){
                    dp[i+1][(1<<4)-1] = max(dp[i+1][(1<<4)-1],dp[i][j]+2);
                }
                dp[i+1][(1<<2)-1] = max(dp[i+1][(1<<2)-1],dp[i][j]+1);
            }
            if(ok(1,i,j)){
                dp[i+1][6] = max(dp[i+1][6],dp[i][j]+1);
            }
            if(ok(2,i,j)){
                dp[i+1][12] = max(dp[i+1][12],dp[i][j]+1);
            }
            dp[i+1][0] = max(dp[i+1][0],dp[i][j]);
        }
    }
    ll res = 0;
    for(int i = 0; i < (1<<4);i++){
        res = max(res,dp[H][i]);
    }
    cout << res << endl;
	return 0;
}

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

bool a[4][10001];//1 ????????????0 ????????????
int dp[10000][16];//i????????§?????????i+1????????§??????????????¨?????????1
int x[4]={0,1,2,0};
int y[4]={2,3,4,4};
signed main(){
	fill(dp[0],dp[0]+16,-(1<<29));
	int h,n;cin>>h>>n;
	memset(a,true,sizeof(a));
	for(int i=0;i<n;i++){
		int a,b;cin>>a>>b;
		::a[a][b]=false;
		}
	int bit=0;
	for(int i=0;i<4;i++){
		if(a[i][0])bit+=(1<<i);
		}	
	dp[0][bit]=0;	
	for(int i=0;i<n-1;i++){
		for(int j=0;j<16;j++){
			dp[i+1][15]=max(dp[i+1][15],dp[i][j]);
			for(int k=0;k<4;k++){
				bool OK=true;
				for(int l=x[k];l<y[k];l++){
					if(!a[l][i+1]||(j&(1<<l))==0){
						OK=false;
						}
					}
				if(OK){
					int bit=15;
					for(int l=x[k];l<y[k];l++){
						bit-=(1<<l);
						}
					dp[i+1][bit]=max(dp[i+1][bit],dp[i][j]+y[k]-x[k]);	
					}	
				}
			}
		}
	cout<<*max_element(dp[n-1],dp[n-1]+16)<<endl;		
	}