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<iostream>
using namespace std;

int bo[50000][4]={{}};
int fcou=0,bcou=0;

void fch(int a,int b){
    if(bo[a+1][b]==0 && bo[a][b+1]==0 && bo[a+1][b+1]==0){
        bo[a][b]=1;
        bo[a+1][b]=1;
        bo[a][b+1]=1;
        bo[a+1][b+1]=1;
       // cout << a << " " << b << endl;
        fcou++;
    }
}

void bch(int a, int b){
    if(bo[a-1][b]==0 && bo[a][b-1]==0 && bo[a-1][b-1]==0){
        bo[a][b]=1;
        bo[a-1][b]=1;
        bo[a][b-1]=1;
        bo[a-1][b-1]=1;
        bcou++;
      //  cout << a << " " << b << endl;
    }
}

int main(){
    int h,n;
    cin >> h >> n;
    int x[50000],y[4];
    for(int i=0;i<n;i++){
        cin >> x[i] >> y[i];
        bo[y[i]][x[i]]=1;
    }

    for(int i=0;i<h-1;i++){
        for(int j=0;j<3;j++){
            if(bo[i][j]==0){
                fch(i,j);
            }
        }
    }

    for(int i=0;i<h;i++){
        for(int j=0;j<4;j++){
            bo[i][j]=0;
        }
    }

    for(int i=0;i<n;i++)bo[y[i]][x[i]]=1;

    for(int i=h-1;i>0;i--){
        for(int j=3;j>0;j--){
            if(bo[i][j]==0){
                bch(i,j);
            }
        }
    }

 //   cout << fcou << " " << bcou << endl;

    if(fcou>bcou)cout << fcou << endl;
    else cout << bcou << endl;

    return 0;

}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int H,N;

int fld[11111];

int dp[11111][16];

signed main(){
    cin>>H>>N;
    rep(i,N){
        int x,y;
        cin>>x>>y;
        fld[y]|=1<<x;
    }

    fill_n(*dp,11111*16,INT_MIN);
    dp[0][15]=0;
    for(int i=0;i<H;i++){
        for(int j=0;j<16;j++){
            chmax(dp[i+1][fld[i]],dp[i][j]);
            if((j&3)==0&&(fld[i]&3)==0)chmax(dp[i+1][fld[i]|3],dp[i][j]+1);
            if((j&6)==0&&(fld[i]&6)==0)chmax(dp[i+1][fld[i]|6],dp[i][j]+1);
            if((j&12)==0&&(fld[i]&12)==0)chmax(dp[i+1][fld[i]|12],dp[i][j]+1);
            if(j==0&&fld[i]==0)chmax(dp[i+1][15],dp[i][j]+2);
        }
    }

    cout<<*max_element(dp[H],dp[H]+16)<<endl;
    return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#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--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
//
int H,N,X,Y;
int SIP[100000][4];
int DP[100000][1<<4];
int main(){
  cin>>H>>N;
  FOR(i,0,N){
    cin>>X>>Y;
    SIP[Y][X]=1;
  }
  FOR(i,0,H){
    FOR(j,0,(1<<4)){
      DP[i][j]=-INF;
    }
  }
  DP[0][0]=0;
  int ans=0;
  FOR(i,0,H){
    FOR(j,0,(1<<4)){
      ans=max(ans,DP[i][j]);
      if(i==H-1){
        continue;
      }
      int tool[2][4];
      FOR(k,0,4){
        tool[0][k]=SIP[i][j];
        tool[1][k]=SIP[i+1][j];
        tool[0][k]|=(j>>k&1);
      }
      DP[i+1][0]=max(DP[i+1][0],DP[i][j]);
      if(!tool[0][0]&&!tool[0][1]&&!tool[1][0]&&!tool[1][1]){
        DP[i+1][3]=max(DP[i+1][3],DP[i][j]+1);
      }
      if(!tool[0][1]&&!tool[0][2]&&!tool[1][1]&&!tool[1][2]){
        DP[i+1][6]=max(DP[i+1][6],DP[i][j]+1);
      }
      if(!tool[0][2]&&!tool[0][3]&&!tool[1][2]&&!tool[1][3]){
        DP[i+1][12]=max(DP[i+1][12],DP[i][j]+1);
      }
      if(!tool[0][0]&&!tool[0][1]&&!tool[1][0]&&!tool[1][1]){
        if(!tool[0][2]&&!tool[0][3]&&!tool[1][2]&&!tool[1][3]){
          DP[i+1][15]=max(DP[i+1][15],DP[i][j]+2);
        }
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

#define int long long
#define INF 1e9
#define LINF 1e18

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<int, P> Pi;
typedef pair<P, P> PP;

const int MOD = 1e9 + 7;
const int dy[] = { 0, 0, 1, -1 };
const int dx[] = { 1, -1, 0, 0 };

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int H, N;
int located[100000];
int dp[2][1 << 4];
int down[5] = {0b0000, 0b0011, 0b0110, 0b1100, 0b1111};
int score[5] = {0, 1, 1, 1, 2};
signed main() {
	cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> H >> N;
    for(int i = 0; i < N; ++i) {
        int x, y;
        cin >> x >> y;
        located[y] |= 1 << x;
    }
    int *now = dp[0];
    int *next = dp[1];
    for(int i = 0; i < (1 << 4); ++i) {
        if(i & located[0]) now[i] = -1;
        else now[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(now[j] == -1) continue;
            for(int k = 0; k < 5; ++k) {
                int front = down[k] & located[i];
                int back = down[k] & located[i + 1];
                if(front || back || j & located[i]) continue;
                int next_put = down[k] | located[i + 1];
                next[next_put] = max(next[next_put], now[j] + score[k]);
            }
        }
        int *temp = now;
        now = next;
        next = temp;
    }
    int res = 0;
    for(int i = 0; i < (1 << 4); ++i) chmax(res, next[i]);
    cout << res << endl;
	return 0;
}

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

int H,N;
int t[100005][4];
int dp[100005][1<<4];

int main(){
  cin>>H>>N;
  for(int i=0;i<N;i++){
    int x,y;
    cin>>x>>y;
    t[x][y]=1;
  }
  
  for(int i=0;i<H;i++)
    for(int j=0;j< (1<<4);j++)
      dp[i][j]=-100000000;
  
  dp[0][0]=0;
  int ans=0;
  
  for(int i=0;i<H;i++){
  
    for(int b=0;b<(1<<4);b++){
      
      ans=max(ans,dp[i][b]);
      if(i==H-1)continue;
      
      int tmp[2][4]={};
      
      for(int j=0;j<4;j++){
        tmp[0][j]=t[i][j];
        tmp[1][j]=t[i+1][j];
        tmp[0][j]|=(b>>j&1);
      }

      if(!tmp[0][0]&&!tmp[0][1]&&!tmp[1][0]&&!tmp[1][1]){
        dp[i+1][3]=max(dp[i+1][3],dp[i][b]+1);
      }
      
      if(!tmp[0][1]&&!tmp[0][2]&&!tmp[1][1]&&!tmp[1][2]){
        dp[i+1][6]=max(dp[i+1][6],dp[i][b]+1);
      }
      
      if(!tmp[0][2]&&!tmp[0][3]&&!tmp[1][2]&&!tmp[1][3]){
        dp[i+1][3]=max(dp[i+1][12],dp[i][b]+1);
      }
      
      if(!tmp[0][0]&&!tmp[0][1]&&!tmp[1][0]&&!tmp[1][1]){
        if(!tmp[0][2]&&!tmp[0][3]&&!tmp[1][2]&&!tmp[1][3]){
          dp[i+1][15]=max(dp[i+1][15],dp[i][b]+2);
        }
      }
      
    }

    
  }

  cout<<ans<<endl;
  return 0;
}