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

C++: #include <bits/stdc++.h>
#define pb push_back
#define REP(i, n) for (signed long long i = 0; i < (n); i++)
#define MOD 998244353
#define INF 93193111451418101
#define bitcnt(a) (ll) __builtin_popcount((a))
#define lb(a, b) lower_bound((a).begin(), (a).end(), (b))
#define ub(a, b) upper_bound((a).begin(), (a).end(), (b))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

ll H, n, vis[40009][5], dp[40009][5]; // null,left,right,middle,both
bool check(ll h, ll x) {
  if (vis[h][x] == false && vis[h][x + 1] == false && vis[h + 1][x] == false && vis[h + 1][x + 1] == false) {
    return true;
  }
  return false;
}
// null,left,right,middle,both
ll DP(ll h, ll pre) {
  if (dp[h][pre]) {
    return dp[h][pre];
  }
  if (h == H - 1) {
    return 0;
  }
  ll cnt = 0;
  if (pre == 0) {
    if (check(h, 2)) {
      cnt = max(cnt, DP(h + 1, 2) + 1);
    }
    if (check(h, 1)) {
      cnt = max(cnt, DP(h + 1, 3) + 1);
    }
    if (check(h, 0)) {
      cnt = max(cnt, DP(h + 1, 1) + 1);
    }
    if (check(h, 0) && check(h, 2)) {
      cnt = max(cnt, DP(h + 1, 4) + 2);
    }
  }
  if (pre == 1) {
    if (check(h, 2)) {
      cnt = max(cnt, DP(h + 1, 2) + 1);
    }
  }
  if (pre == 2) {
    if (check(h, 0)) {
      cnt = max(cnt, DP(h + 1, 1) + 1);
    }
  }
  cnt = max(cnt, DP(h + 1, 0));
  dp[h][pre] = cnt;
  // cout << h << " " << pre << " " << cnt << endl;
  return cnt;
}

int main() {
  cin >> H >> n;
  REP(i, n) {
    ll x, y;
    cin >> x >> y;
    vis[y][x] = 1;
  }
  cout << DP(0, 0) << endl;
}

C++: 
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int MOD = 1e9 + 7;
int flag[10000];
int main(){
	int h,n;
	cin >> h >> n;
	vector<int> x(n);
	vector<int> y(n);
	for(int i = 0; i < n; ++i)
		cin >> x[i] >> y[i];

	vector<vector<ll> > dp(h + 3, vector<ll>(1 << 4, -MOD));
	vector<vector<int> > v(h, vector<int>(4, 1));
	for(int i = 0; i < n; ++i)
		v[y[i]][x[i]] = 0;
	
	dp[0][0] = 0;
	for(int i = 0; i < h - 1; ++i){
		for(int j = 0; j < (1<<4); ++j){
			if(dp[i][j] == -MOD)
				continue;

			dp[i+1][0] = max(dp[i+1][0], dp[i][j]);

			if(!(j&1) && !(j&(1<<1)) &&
				v[i+1][0] && v[i+1][1] && v[i][0] && v[i][1]
					)
				dp[i+1][3] = max(1 + dp[i][j], dp[i+1][3]);

			if(!(j&(1<<2)) && !(j&(1<<3)) &&
				v[i+1][2] && v[i+1][3] && v[i][2] && v[i][3]
			  )
				dp[i+1][(1<<2) + (1<<3)] = max(1 + dp[i][j], dp[i+1][(1<<2) + (1<<3)]);

			if(!(j&(1<<2)) && !(j&(1<<1)) &&
				v[i+1][2] && v[i+1][1] && v[i][2] && v[i][1]
			  )
				dp[i+1][(1<<2) + (1<<1)] = max(1 + dp[i][j], dp[i+1][(1<<2) + (1<<1)]);

			bool flag = true;
			if(j==0)
			for(int k = 0; k < 4; ++k)
				for(int l = 0; l < 2; ++l)
					if(v[i+l][k]==0)
					{
						flag=false;break;}

			if(j == 0 && flag){
				dp[i+1][(1<<4)-1] = max(2 + dp[i][j], dp[i+1][(1<<4)-1]);
			}
		}
	
	}

	int j = h-1;
			ll val =0;
		for(int i = 0; i < (1<<4); ++i)
			val = max(dp[j][i], val);
			cout << val << endl;

}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int dx[] = {1,0,1,0};
int dy[] = {0,1,1,0};
int main() {
	int H,N;
	cin >> H >> N;
	vector<vector<char>> ship(H,vector<char>(4,'.'));

	for (int i = 0; i < N; i++) {
		int x, y;
		cin >> x >> y;
		ship[x][y] = '#';
	}

	int A = 0;
	int B = 0;

	for (int i = 0; i < H-1;){
		bool can = true;
		for (int j = 0; j < 4; j++){
			if (ship[i + dy[j]][0 + dx[j]] == '#') {
				can = false;
			}
		}
		if (can){
			i += 2;
			A++;
		}
		else i++;

	}

	for (int i = 0; i < H-1;) {
		bool can = true;
		for (int j = 0; j < 4; j++) {
			if (ship[i + dy[j]][2 + dx[j]] == '#') {
				can = false;
			}
		}
		if (can) {
			i += 2;
			A++;
		}
		else i++;

	}

	for (int i = 0; i < H-1;) {
		bool can = true;
		for (int j = 0; j < 4; j++) {
			if (ship[i + dy[j]][1 + dx[j]] == '#') {
				can = false;
			}
		}
		if (can) {
			i += 2;
			B++;
		}
		else i++;
	}

	cout << max(A, B) << endl;


}

C++: //============================================================================
// Name        : AOJ.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <algorithm>

using namespace std;

int h,n;
int dp[16][10001]={};
int d[10001]={};

int calc(int i,int m){
	if(dp[i][m]>=0)return dp[i][m];
	dp[i][m]=0;
	for(int j=0;j<16;++j)dp[i][m]=max(dp[i][m],calc(j,m-1));
	if(((3+d[m])==i)&&((3&d[m-1])==0)){
		dp[i][m]=max(dp[i][m],1+calc(0,m-1));
		dp[i][m]=max(dp[i][m],1+calc(4,m-1));
		dp[i][m]=max(dp[i][m],1+calc(8,m-1));
		dp[i][m]=max(dp[i][m],1+calc(12,m-1));
	}
	if(((6+d[m])==i)&&((6&d[m-1])==0)){
		dp[i][m]=max(dp[i][m],1+calc(0,m-1));
		dp[i][m]=max(dp[i][m],1+calc(1,m-1));
		dp[i][m]=max(dp[i][m],1+calc(8,m-1));
		dp[i][m]=max(dp[i][m],1+calc(9,m-1));
	}
	if(((12+d[m])==i)&&((12&d[m-1])==0)){
		dp[i][m]=max(dp[i][m],1+calc(0,m-1));
		dp[i][m]=max(dp[i][m],1+calc(1,m-1));
		dp[i][m]=max(dp[i][m],1+calc(2,m-1));
		dp[i][m]=max(dp[i][m],1+calc(3,m-1));
	}
	if(((15+d[m])==i)&&((15&d[m-1])==0)){
		dp[i][m]=max(dp[i][m],2+calc(0,m-1));
	}
	return dp[i][m];
}
int main() {
	cin>>h>>n;

	for(int i=0;i<10001;++i){
		for(int j=0;j<16;++j){
			dp[j][i]=-1;
		}
	}
	int x,y;
	for(int i=0;i<n;++i){
		cin>>x>>y;
		x=(1<<x);
		for(int j=0;j<16;++j){
			if((j&x)==0)dp[j][y]=0;
		}
		d[y]+=x;
	}

	for(int j=0;j<16;++j)dp[j][0]=0;


	int total=0;
	for(int i=0;i<16;++i)total=max(total,calc(i,h-1));
	cout<<total<<endl;
	return 0;
}

C++: #include<iostream>
using namespace std;
int a[1000][4]={0};
inline int cheak(int y){
  int sum=0;
  for(int i=0;i<y-1;i++){
  for(int j=0;j<3;j++){
    if(a[i][j]==0&&a[i+1][j]==0&&a[i][j+1]==0&&a[i+1][j+1]==0){
      a[i][j]=1;
      a[i+1][j]=1;
      a[i][j+1]=1;
      a[i+1][j+1]=1;
      sum++;
    }
  }
 
}
return sum;
}
int main(){
int b,c,d,e,f=0,sum=0;//[???][?¨?]
cin>>b>>c;
for(int i=0;i<c;i++){
  cin>>d>>e;
  a[e][d]=1;
}

/*for(int i=0;i<b;i++){
  for(int j=0;j<4;j++){
    cout<<a[i][j]<<' ';
    }
    cout<<endl;
  }*/
cout<<cheak(b)<<'\n';

  return 0;
}