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 < H-1; i++ {
		for j := 0; j < 3; j++ {
			if !room[i][j] && !room[i+1][j] && !room[i][j+1] && !room[i+1][j+1] {
				room[i][j] = true
				room[i+1][j] = true
				room[i][j+1] = true
				room[i+1][j+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)cout<<(a[j][i]?'#':'.');
        out();
    }
    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;
#define INF 1000000007
int main(void){
	int h, n;
	cin >> h >> n;
	int mp[h + 1];
	fill(mp, mp + h + 1, 0);
	for(int i = 0; i < n; i++){
		int x, y;
		cin >> x >> y;
		mp[y] =  (mp[y] | (1 << x));
	}
	int mask[5] = {0, 3, 6, 12, 15};
	int dp[h][16];
	fill(dp[0], dp[h], 0);
	for(int i = 1; i < 5; i++){
		if(!((mp[0] | mp[1]) & mask[i])){
			if(mask[i] == 15) dp[1][mask[i]] = 2;
			else dp[1][mask[i]] = 1;
		}
	}
	for(int i = 1; i < h - 1; i++){
		for(int j = 0; j < 5; j++){
			dp[i + 1][0] = max(dp[i + 1][0], dp[i][mask[j]]);
			for(int k = 1; k < 5; k++){
				if(((mp[i] | mask[j]) & mask[k]) == 0 && (mp[i + 1] & mask[k]) == 0){
					if(mask[k] == 15) dp[i + 1][mask[k]] = max(dp[i + 1][mask[k]], dp[i][mask[j]] + 2);
					else dp[i + 1][mask[k]] = max(dp[i + 1][mask[k]], dp[i][mask[j]] + 1);
				}
			}
		}
	}
	int mx = -1;
	for(int i = 0; i < 16; i++) mx = max(mx, dp[h - 1][i]);
	cout << mx << endl;
	return 0;
}

C++: #include "bits/stdc++.h"

using namespace std;

#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second

int dp[16][10010],ans;

int h, n, x, y;
bool b[4][10010];

int cul(int x) {
	int sum = 0;
	for (int i = 0;i < 4;i++) {
		if (b[i][x])sum += (1 << i);
	}
	return sum;
}

int main() {
	cin >> h >> n;
	for (int i = 0;i < n;i++) {
		cin >> x >> y;
		b[x][y] = 1;
	}
	for (int i = 0;i < 16;i++) {
		for (int j = 0;j < h;j++) {
			dp[i][j] = -1;
		}
	}
	dp[cul(0)][0] = 0;
	for (int i = 0;i < h - 1;i++) {
		for (int j = 0;j < 16;j++) {
			if (dp[j][i] == -1)continue;
			if (j == 6 || j == 10 || j == 5 || j == 15 || j == 7 || j == 14 || j == 11 || j == 13) {
				dp[cul(i + 1)][i + 1] = max(dp[j][i], dp[cul(i + 1)][i + 1]);
			}
			if (j == 2 || j == 3) {
				if (!b[2][i + 1] && !b[3][i + 1])dp[cul(i + 1) + 12][i + 1] = max(dp[cul(i + 1) + 12][i + 1], dp[j][i] + 1);
				dp[cul(i + 1)][i + 1] = max(dp[cul(i + 1)][i + 1], dp[j][i]);
			}
			if (j == 4 || j == 12) {
				if (!b[0][i + 1] && !b[1][i + 1])dp[cul(i + 1) + 3][i + 1] = max(dp[cul(i + 1) + 3][i + 1], dp[j][i] + 1);
				dp[cul(i + 1)][i + 1] = max(dp[cul(i + 1)][i + 1], dp[j][i]);
			}
			if (j == 1) {
				if (!b[1][i + 1] && !b[2][i + 1])dp[cul(i + 1) + 6][i + 1] = max(dp[cul(i + 1) + 6][i + 1], dp[j][i] + 1);
				if (!b[2][i + 1] && !b[3][i + 1])dp[cul(i + 1) + 12][i + 1] = max(dp[cul(i + 1) + 12][i + 1], dp[j][i] + 1);
				dp[cul(i + 1)][i + 1] = max(dp[cul(i + 1)][i + 1], dp[j][i]);
			}
			if (j == 8) {
				if (!b[0][i + 1] && !b[1][i + 1])dp[cul(i + 1) + 3][i + 1] = max(dp[cul(i + 1) + 3][i + 1], dp[j][i] + 1);
				if (!b[1][i + 1] && !b[2][i + 1])dp[cul(i + 1) + 6][i + 1] = max(dp[cul(i + 1) + 6][i + 1], dp[j][i] + 1);
				dp[cul(i + 1)][i + 1] = max(dp[cul(i + 1)][i + 1], dp[j][i]);
			}
			if (j == 9) {
				if (!b[1][i + 1] && !b[2][i + 1])dp[cul(i + 1) + 6][i + 1] = max(dp[cul(i + 1) + 6][i + 1], dp[j][i] + 1);
				dp[cul(i + 1)][i + 1] = max(dp[cul(i + 1)][i + 1], dp[j][i]);
			}
			if (j == 0) {
				if (!b[0][i + 1] && !b[1][i + 1])dp[cul(i + 1) + 3][i + 1] = max(dp[cul(i + 1) + 3][i + 1], dp[j][i] + 1);
				if (!b[1][i + 1] && !b[2][i + 1])dp[cul(i + 1) + 6][i + 1] = max(dp[cul(i + 1) + 6][i + 1], dp[j][i] + 1);
				if (!b[2][i + 1] && !b[3][i + 1])dp[cul(i + 1) + 12][i + 1] = max(dp[cul(i + 1) + 12][i + 1], dp[j][i] + 1);
				if (!b[0][i + 1] && !b[1][i + 1] && !b[2][i + 1] && !b[3][i + 1])dp[15][i + 1] = max(dp[15][i + 1], dp[j][i] + 2);
				dp[cul(i + 1)][i + 1] = max(dp[cul(i + 1)][i + 1], dp[j][i]);
			}
		}
	}
	for (int i = 0;i < 16;i++) {
		ans = max(ans, dp[i][h - 1]);
	}
	cout << ans << endl;
	return 0;
}