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 <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <functional>
#include <bitset>
#include <string>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <list>
#include <deque>
using namespace std;
#define INF 10000000
#define LLINF 100000000000000
typedef pair<int, int> P;
typedef long long ll;
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define VSORT(v) sort(v.begin(), v.end());
#define fi first
#define se second
#define out(x) cout << x << endl;
int dx[] = { 1, 0, -1, 0 }, dy[] = { 0,1,0,-1 };
ll MOD = 1000000007;

int h, n;
int locate[] = { 0,3,6,12,15 };
int dp[2][1 << 4] = { 0 };
int add[] = { 0,1,1,1,2 };
int f[10005] = { 0 };

int main() {
	cin >> h >> n;
	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		f[y] |= 1 << x;
	}
	int *crt = dp[0];
	int *next = dp[1];
	for (int i = 0; i < 1 << 4; i++) {
		if (i&f[0]) {
			crt[i] = -1;
		}
		else {
			crt[i] = 0;
		}
	}
	for (int i = 0; i < h - 1; i++) {
		fill(next, next + (1 << 4), -1);
		for (int j = 0; j < 1 << 4; j++) {
			if (crt[j] == -1) continue;
			for (int k = 0; k < 5; k++) {
				int sc = f[i] & locate[k];
				int sn = f[i + 1] & locate[k];
				if (!sc && !sn && !(j&locate[k])) {
					next[f[i+1] | locate[k]] = max(next[f[i+1] | locate[k]], crt[j] + add[k]);
				}
			}
		}
		swap(crt, next);
	}
	int res = 0;
	for (int i = 0; i < 1 << 4; i++) {
		res = max(res, crt[i]);
	}
	out(res);
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

int H,W = 4;
int N;
vector<vector<int>> fie;

int main(){
    cin >> H >> N;
    fie.resize(H,vector<int>(W,0));
    rep(i,0,N - 1){
        int x,y;
        cin >> x >> y;
        fie[y][x] = 1;
    }

    int ans = 0;

    rep(i,0,H - 2){
        rep(j,0,W - 2){
            if(j == 1 || j == 2) continue;
            int cou = 0;
            rep(x,i,i + 1){
                rep(y,j,j + 1){
                    cou+= fie[x][y];
                }
            }

            if(cou == 0){
                ans++;
                rep(x,i,i + 1){
                    rep(y,j,j + 1){
                        fie[x][y] = 1;
                    }
                }

            }
        }
    }
    rep(i,0,H - 2){
        rep(j,0,W - 2){
            if(j == 0 || j == 3) continue;
            int cou = 0;
            rep(x,i,i + 1){
                rep(y,j,j + 1){
                    cou+= fie[x][y];
                }
            }

            if(cou == 0){
                ans++;
                rep(x,i,i + 1){
                    rep(y,j,j + 1){
                        fie[x][y] = 1;
                    }
                }

            }
        }
    }

    cout << ans << endl;
}

C++: #include <stdio.h>

int max(int a, int b) {
  return a > b ? a : b;
}

int main(void) {
  int n, i, j, h;
  scanf("%d%d", &h, &n);
  int a[4][h], dp[6][h];
  for(j = 0; j < h; ++j) {
    for(i = 0; i < 4; ++i) a[i][j] = 1;
    for(i = 0; i < 5; ++i) dp[i][j] = 0;
  }
  for(i = 0; i < n; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    a[x][y] = 0;
  }
  /*for(i = 0; i < h; ++i) {
    for(j = 0; j < 4; ++j) printf("%d",a[j][i]);
    printf("\n");
  }*/
  if(a[0][0] && a[0][1] && a[1][0] && a[1][1]) dp[1][1] = 1;
  if(a[2][0] && a[2][1] && a[1][0] && a[1][1]) dp[2][1] = 1;
  if(a[3][0] && a[3][1] && a[2][0] && a[2][1]) dp[3][1] = 1;
  if(dp[1][1] && dp[3][1]) dp[4][1] = 2;
  else dp[4][1] = max(dp[1][1], max(dp[2][1], dp[3][1]));
  for(i = 2; i < h; ++i) {
    int s = 1;
    dp[0][i] = dp[4][i - 1];
    if(a[0][i - 1] && a[0][i] && a[1][i - 1] && a[1][i]) dp[1][i] = max(dp[3][i - 1] + 1, dp[4][i - 2] + 1);
    else s = 0;
    if(a[2][i - 1] && a[2][i] && a[1][i - 1] && a[1][i]) dp[2][i] = dp[4][i - 2] + 1;
    if(a[3][i - 1] && a[3][i] && a[2][i - 1] && a[2][i]) dp[3][i] = max(dp[1][i - 1] + 1, dp[4][i - 2] + 1);
    else s = 0;
    for(j = 1; j < 4; ++j) if(!dp[j][i]) dp[j][i] = dp[0][i];
    if(s) dp[4][i] = dp[4][i - 2] + 2;
    else dp[4][i] = max(dp[1][i], max(dp[2][i], dp[3][i]));
  }
  /*for(i = 0; i < h; ++i) {
    for(j = 0; j < 5; ++j) printf("%d ", dp[j][i]);
    printf("\n");
  }*/
  printf("%d\n", dp[4][h - 1]);
  return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <stack>
#include <cmath>
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
using namespace std;
//
const int inf=1e9+7;
const int mod=1e9+7;
//
struct poi{
	int X;int Y;int Z;
	bool operator<(const poi&R)const{
		return X==R.X ? Y==R.Y ? Z<R.Z : Y<R.Y : X<R.X;
	}
};
//
ll GCD(ll a,ll b){
	return (b==0)?(a):(GCD(b,a%b));
}
ll LCM(ll a,ll b){
	return a/GCD(a,b)*b;
}
//
int H,N;
int ok[20000][4];
int DP[20000][5];
int main(){
	cin>>H>>N;
	FOR(i,0,H){
		FOR(j,0,4){
			ok[i][j]=1;
		}
	}
	FOR(i,0,N){
		int X,Y;
		cin>>X>>Y;
		ok[Y][X]=0;
	}
	/*
	cout<<endl;
	FOR(i,0,H){
		FOR(j,0,4){
			cout<<ok[i][j]<<" ";
		}
		cout<<endl;
	}
	cout<<endl;
	*/
	//
	if(ok[0][0]&&ok[0][1]&&ok[1][0]&&ok[1][1]){
		DP[0][1]=1;
	}
	if(ok[0][1]&&ok[0][2]&&ok[1][1]&&ok[1][2]){
		DP[0][2]=1;
	}
	if(ok[0][2]&&ok[0][3]&&ok[1][2]&&ok[1][3]){
		DP[0][3]=1;
	}
	if(ok[0][0]&&ok[0][1]&&ok[1][0]&&ok[1][1]&&ok[0][2]&&ok[0][3]&&ok[1][2]&&ok[1][3]){
		DP[0][4]=2;
	}
	//
	if(ok[1][0]&&ok[1][1]&&ok[2][0]&&ok[2][1]){
		DP[1][1]=DP[0][3]+1;
	}
	if(ok[1][1]&&ok[1][2]&&ok[2][1]&&ok[2][2]){
		DP[1][2]=1;
	}
	if(ok[1][2]&&ok[1][3]&&ok[2][2]&&ok[2][3]){
		DP[1][3]=DP[0][1]+1;
	}
	if(ok[1][0]&&ok[1][1]&&ok[2][0]&&ok[2][1]&&ok[1][2]&&ok[1][3]&&ok[2][2]&&ok[2][3]){
		DP[1][4]=2;
	}
	//
	FOR(i,2,H-1){
		DP[i][0]=max({DP[i-2][0],DP[i-2][1],DP[i-2][2],DP[i-2][3],DP[i-2][4],DP[i-1][0],DP[i-1][1],DP[i-1][2],DP[i-1][3],DP[i-1][4]});
		DP[i][1]=max({DP[i-2][0],DP[i-2][1],DP[i-2][2],DP[i-2][3],DP[i-2][4],DP[i-1][3],DP[i-1][0]});
		DP[i][2]=max({DP[i-2][0],DP[i-2][1],DP[i-2][2],DP[i-2][3],DP[i-2][4],DP[i-1][0]});
		DP[i][3]=max({DP[i-2][0],DP[i-2][1],DP[i-2][2],DP[i-2][3],DP[i-2][4],DP[i-1][1],DP[i-1][0]});
		DP[i][4]=max({DP[i-2][0],DP[i-2][1],DP[i-2][2],DP[i-2][3],DP[i-2][4],DP[i-1][0]});
		if(ok[i][0]&&ok[i][1]&&ok[i+1][0]&&ok[i+1][1]){
			DP[i][1]++;
		}else{
			DP[i][1]=max({DP[i][1],DP[i][0]});
		}
		if(ok[i][1]&&ok[i][2]&&ok[i+1][1]&&ok[i+1][2]){
			DP[i][2]++;
		}else{
			DP[i][2]=max({DP[i][2],DP[i][0]});
		}
		if(ok[i][2]&&ok[i][3]&&ok[i+1][2]&&ok[i+1][3]){
			DP[i][3]++;
		}else{
			DP[i][3]=max({DP[i][3],DP[i][0]});
		}
		if(ok[i][0]&&ok[i][1]&&ok[i+1][0]&&ok[i+1][1]&&ok[i][2]&&ok[i][3]&&ok[i+1][2]&&ok[i+1][3]){
			DP[i][4]+=2;
		}else{
			DP[i][4]=max({DP[i][4],DP[i][0]});
		}
	}
	int ans=0;
	/*
	FOR(i,0,H){
		FOR(j,0,5){
			cout<<DP[i][j]<<" ";
		}
		cout<<endl;
	}
	cout<<endl;
	*/
	FOR(i,0,5){
		ans=max(ans,DP[H-2][i]);
	}
	cout<<ans<<endl;
	return 0;
}