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 <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][0]=max({DP[i][0],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][0],DP[i-1][3],DP[i-2][0],DP[i-2][1],DP[i-2][2],DP[i-2][3],DP[i-2][4]});
		DP[i][2]=max({DP[i][0],DP[i-2][0],DP[i-2][1],DP[i-2][2],DP[i-2][3],DP[i-2][4]});
		DP[i][3]=max({DP[i][0],DP[i-1][1],DP[i-2][0],DP[i-2][1],DP[i-2][2],DP[i-2][3],DP[i-2][4]});
		DP[i][4]=max({DP[i][0],DP[i-2][0],DP[i-2][1],DP[i-2][2],DP[i-2][3],DP[i-2][4]});
		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-1][0],DP[i-1][1],DP[i-1][2],DP[i-1][3],DP[i-1][4]});
		}
		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-1][0],DP[i-1][1],DP[i-1][2],DP[i-1][3],DP[i-1][4]});
		}
		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-1][0],DP[i-1][1],DP[i-1][2],DP[i-1][3],DP[i-1][4]});
		}
		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-1][0],DP[i-1][1],DP[i-1][2],DP[i-1][3],DP[i-1][4]});
		}
	}
	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;
}

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 <bits/stdc++.h>
using std::cout;
using std::endl;
using std::cin;

std::vector<std::vector<int>> dp;
std::vector<std::string> s;
std::vector<int> vec;
int h, n;

bool check(int i, int j){
	if(s[i][j] == '#') return false;
	if(s[i + 1][j] == '#') return false;
	if(s[i][j + 1] == '#') return false;
	if(s[i + 1][j + 1] == '#') return false;
	return true;
}

int dfs(int p, int q){
	if(p >= h - 1) return 0;
	if(~dp[p][q]) return dp[p][q];
	
	int ret = 0;
	if(q == 0){
		ret = std::max({dfs(p + 1, 0), dfs(p + 1, 1), dfs(p + 1, 2), dfs(p + 1, 3), dfs(p + 1, 4)});
	}else if(q == 1){
		int count = check(p, 0);
		ret = std::max(count + dfs(p + 1, 2), count + dfs(p + 1, 0));
	}else if(q == 2){
		int count = check(p, 1);
		ret = count + dfs(p + 1, 0);
	}else if(q == 3){
		int count = check(p, 2);
		ret = std::max(count + dfs(p + 1, 0), count + dfs(p + 1, 0));
	}else if(q == 4){
		int count = check(p, 0) + check(p, 2);
		ret = count + dfs(p + 1, 0);
	}
	
	return dp[p][q] = ret;
}

int main(){
	cin >> h >> n; s.resize(h, std::string(4, '.'));
	for(int i = 0; i < n; i++){
		int a, b; cin >> a >> b;
		
		s[b][a] = '#';
	}
	reverse(begin(s), end(s));
	dp.resize(h - 1, std::vector<int>(5, -1));
	
	cout << std::max({dfs(0, 0), dfs(0, 1), dfs(0, 2), dfs(0, 3), dfs(0, 4)}) << endl;
	return 0;
}

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

i64 h, n;
vector<i64> obj;
vector<vector<i64>> dp;

i64 dfs(i64 hn, i64 s)
{
  if (hn == h)
    return 0;
  if (dp[hn][s] != -1)
    return dp[hn][s];
  i64 ans = dfs(hn + 1, obj[hn]);
  for (i64 i = 0; i < 3; i++)
  {
    if (((s >> i) & 3) || ((obj[hn] >> i) & 3))
      continue;
    ans = max(ans, dfs(hn + 1, obj[hn] | (3 << i)) + 1);
  }
  if (s == 0 && obj[hn] == 0)
    ans = max(ans, dfs(hn + 1, (1 << 4) - 1) + 2);
  return dp[hn][s] = ans;
}

int main()
{
  cin >> h >> n;
  obj.resize(h);
  for (i64 i = 0; i < n; i++)
  {
    i64 x, y;
    cin >> x >> y;
    obj[y] |= (1 << x);
  }
  dp.resize(h, vector<i64>(16, -1));
  cout << dfs(1, obj[0]) << endl;
  return 0;
}

C++: #include <stdio.h>
int main(void) {
   int H,N,i,j,p[4][10002],x,y,c;
   for(i=0;i<10002;i++){
	   p[0][i]=0;p[1][i]=0;p[2][i]=0;p[3][i]=0;
   }
   scanf("%d %d",&H,&N);
   for(i=0;i<N;i++){
	   scanf("%d %d",&x,&y);
	   p[x][y]=9;
   }
  for(i=H;i<10002;i++){
	   p[0][i]=9;p[1][i]=9;p[2][i]=9;p[3][i]=9;
  }
  c=0;
  j=1;
	  for(i=1;i<H;i++){
		  if(p[j][i]==0&&p[j-1][i-1]==0&&p[j-1][i]==0&&p[j][i-1]==0){
			  p[j][i]=1;p[j-1][i]=1;p[j][i-1]=1;p[j-1][i-1]=1;
			  c++;
		  }
	  }
  j=3;
	  for(i=1;i<H;i++){
		  if(p[j][i]==0&&p[j-1][i-1]==0&&p[j-1][i]==0&&p[j][i-1]==0){
			  p[j][i]=1;p[j-1][i]=1;p[j][i-1]=1;p[j-1][i-1]=1;
			  c++;
		  }
	  }
  j=2;
	  for(i=1;i<H;i++){
		  if(p[j][i]==0&&p[j-1][i-1]==0&&p[j-1][i]==0&&p[j][i-1]==0){
			  p[j][i]=1;p[j-1][i]=1;p[j][i-1]=1;p[j-1][i-1]=1;
			  c++;
		  }
	  }

  for(i=0;i<H;i++){
	  printf("%d%d%d%d\n",p[0][i],p[1][i],p[2][i],p[3][i]);
  }

  printf("%d\n",c);
   return 0;
}