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

#define put(n) cout<<(n)<<endl
#define FOR(i,num,N) for(int(i)=(num);(i)<(N);++(i))
#define RFOR(i,num,N) for(int (i)=(num);(i)>(N);--(i))
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()

int main(){
    int H,N,F[10100];
    cin>>H>>N;
    long long dp[10100][1<<4],ans;

    FOR(i,0,N){
        int x,y; cin>>x>>y;
        F[y] |= (1<<x);
    }

    FOR(i,0,10100){
        FOR(j,0,(1<<4)){
            dp[i][j] = -1e9;
        }
    }

    dp[0][F[0]] = 0;

    FOR(i,0,H-1){
        FOR(state,0,(1<<4)){
            FOR(bit,0,(1<<3)){
                int next = F[i+1],cnt=0,ok=1;
                FOR(j,0,3){
                    if(!(bit&(1<<j))) continue;
                    if(state&(3<<j)) ok = 0;
                    if(next&(3<<j)) ok = 0;
                    next |= (3<<j);
                    ++cnt;
                }
                if(!ok) continue;
                dp[i+1][next] = max(dp[i+1][next],dp[i][state]+cnt);
            }
        }
    }
    FOR(i,0,(1<<4)) ans = max(ans,dp[H-1][i]);
    put(ans);
}

C++: #include <bits/stdc++.h>
#define put(n) cout<<(n)<<endl
#define FOR(i,num,N) for(int(i)=(num);(i)<(N);++(i))
#define RFOR(i,num,N) for(int (i)=(num);(i)>(N);--(i))
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()
using namespace std;

int main(){
    int H,N,F[10100];
    cin>>H>>N;
    long long dp[10100][1<<4],ans;

    FOR(i,0,N){
        int x,y; cin>>x>>y;
        F[y] |= (1<<x);
    }

    FOR(i,0,10100){
        FOR(j,0,(1<<4)){
            dp[i][j] = -1e9;
        }
    }

    dp[0][F[0]] = 0;

    FOR(i,0,H-1){
        FOR(state,0,(1<<4)){
            FOR(bit,0,(1<<3)){
                int next = F[i+1],cnt=0,ok=1;
                FOR(j,0,3){
                    if(!(bit&(1<<j))) continue;
                    if(state&(3<<j)) ok = 0;
                    if(next&(3<<j)) ok = 0;
                    next |= (3<<j);
                    ++cnt;
                }
                if(!ok) continue;
                dp[i+1][next] = max(dp[i+1][next],dp[i][state]+cnt);
            }
        }
    }
    FOR(i,0,(1<<4)) ans = max(ans,dp[H-1][i]);
    put(ans);
}

C++: #include<iostream>
using namespace std;

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

void ch(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++;
    }
}

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){
                ch(i,j);
            }
        }
    }

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



    cout << fcou << endl;
    return 0;

}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main(){
  
  int h,n,x,y,b[10010]={};
  cin >> h >> n;
  for(int i=0;i<n;i++){
    cin >> x >> y;
    b[y] |= 1<<x;
  }
  
  int dp[10010][20] = {};
  int ni[] = {0x0,0x3,0x06,0xc,0xf};
  int cnt[] = {0,1,1,1,2};

  for(int i=1;i<h;i++){
    
    for(int j=0;j<(1<<4);j++){
      
      if( (b[i-1]&j) != b[i-1]) continue;

      for(int k=0;k<5;k++){
	
	if( (j&ni[k])==0 && (b[i]&ni[k])==0 ){
	  dp[i][b[i]|ni[k]] = max(dp[i][b[i]|ni[k]],dp[i-1][j] + cnt[k]);
	}
	
      }
      
    }

  }

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

  return(0);
}

C++: #include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.0000001
using namespace std;

int main(){

	int H,N;
	scanf("%d %d",&H,&N);

	bool** check = new bool*[H];
	int** dp = new int*[H];

	for(int i = 0; i < H; i++){
		check[i] = new bool[4];
		dp[i] = new int[5];
		for(int k = 0; k < 4; k++){
			check[i][k] = true;
		}
		for(int k = 0; k < 5; k++){
			dp[i][k] = 0;
		}
	}

	int x,y;

	for(int i = 0; i < N; i++){
		scanf("%d %d",&x,&y);
		check[y][x] = false;
	}

	for(int i = 1; i <= H-1; i++){

		dp[i][0] = dp[i-1][0];
		if(check[i-1][0] == true && check[i-1][1] == true && check[i][0] == true && check[i][1] == true){
			dp[i][1] = dp[i-1][0]+1;
		}
		if(check[i-1][1] == true && check[i-1][2] == true && check[i][1] == true && check[i][2] == true){
			dp[i][2] = dp[i-1][0]+1;
		}
		if(check[i-1][2] == true && check[i-1][3] == true && check[i][2] == true && check[i][3] == true){
			dp[i][3] = dp[i-1][0]+1;
		}
		if(check[i-1][0] == true && check[i-1][1] == true && check[i-1][2] == true && check[i-1][3] == true &&
				check[i][0] == true && check[i][1] == true && check[i][2] == true && check[i][3] == true){
			dp[i][4] = dp[i-1][0]+2;
		}


		dp[i][0] = max(dp[i][0],dp[i-1][1]);
		if(check[i-1][2] == true && check[i-1][3] == true && check[i][2] == true && check[i][3] == true){
			dp[i][3] = max(dp[i][3],dp[i-1][1]+1);
		}


		dp[i][0] = max(dp[i][0],dp[i-1][2]);


		dp[i][0] = max(dp[i][0],dp[i-1][3]);
		if(check[i-1][0] == true && check[i-1][1] == true && check[i][0] == true && check[i][1] == true){
			dp[i][1] = max(dp[i][1],dp[i-1][3]+1);
		}


		dp[i][0] = max(dp[i][0],dp[i-1][4]);
	}

	int ans = 0;
	for(int i = 0; i < 5; i++)ans = max(ans,dp[H-1][i]);

	printf("%d\n",ans);

	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  int h, n;
  cin >> h >> n;
  int b[4][10001] = {};
  rep(i, 0, n) {
    int x, y;
    cin >> x >> y;
    b[x][y] = 1;
  }
  int ans = 0;
  rep(i, 0, h - 1) {
    if(!b[0][i] && !b[1][i] && !b[0][i + 1] && !b[1][i + 1]) {
      b[0][i + 1] = 1, b[1][i + 1] = 1;
      ans++;
    }
    if(!b[2][i] && !b[3][i] && !b[2][i + 1] && !b[3][i + 1]) {
      b[2][i + 1] = 1, b[3][i + 1] = 1;
      ans++;
    }
    if(!b[1][i] && !b[2][i] && !b[1][i + 1] && !b[2][i + 1]) {
      int f = 0;
      if(!b[0][i + 1] && !b[1][i + 1] && !b[0][i + 2] && !b[1][i + 2]) {
        f++;
      }
      if(!b[2][i + 1] && !b[3][i + 1] && !b[2][i + 2] && !b[3][i + 2]) {
        f++;
      }
      if(f < 2) {
        b[1][i + 1] = 1, b[2][i + 1] = 1;
        ans++;
      }
    }
  }
  cout << ans << endl;
}