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 <stdio.h>
#define MAX_H 100000
int blocked[MAX_H];
int dp[2][1<<4];
main() {
 int h, n; scanf("%d %d", &h, &n);
 int x, y;
 for ( int i=0; i<n; ++i ) {
scanf(“%d %d”, &x, &y); blocked[y] |= 1<<x;
 }
 int locate[5] = { 0x0, 0x3, 0x6, 0xc, 0xf };//置き方パターン
 int add[5] = { 0, 1, 1, 1, 2 };//各置き方パターンで置ける個数

 int* crt = dp[0];
 int* next = dp[1];

 for ( int obstacle=0; obstacle<1<<4; ++obstacle ) {
if ( obstacle&blocked[0] ) crt[obstacle] = -1;
else crt[obstacle] = 0;
 }

 for ( int i=0; i<h-1; ++i ) {
std::fill( next, next+(1<<4), -1 );
for ( int obstacle=0; obstacle<1<<4; ++obstacle ) {//既に有るものパターン(current)
 if ( crt[obstacle] == -1 ) continue;
 for ( int k=0; k<5; ++k ) {//置き方パターン(next)
int check0 = blocked[i] & locate[k];
int check1 = blocked[i+1] & locate[k];
if ( !check0 && !check1 && !(obstacle&locate[k])) {
 int patt = blocked[i+1] | locate[k];
 next[patt] = std::max( crt[obstacle] + add[k], next[patt] );
}
 }
}
int* tmp = crt;
crt = next;
next = tmp;
 }
 int res = 0;
 for ( int i=0; i<1<<4; ++i ) if ( next[i] > res ) res = next[i];
 printf("%d¥n", res );
}

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++;
    }
}

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[x[i]][y[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);
            }
        }
    }


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

    return 0;

}

C++: #include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int h,n,dp[10001][16],i,j,wk1,wk2,wk3,x,y,a[10001],k,mx;
	int pat[4]={3,6,12,15},b[4]={1,2,4,8},cnt[4]={1,1,1,2};
	scanf("%d %d",&h,&n);
	for(i=0;i<h;i++)	a[i]=0;
	for(i=0;i<n;i++)	{
		scanf("%d %d",&x,&y);
		a[y]=(a[y]|b[x]);
	}
//	for(i=0;i<h;i++)	printf("%d\n",a[i]);
	for(i=0;i<h;i++)	{
		for(j=0;j<16;j++)	dp[i][j]=0;
	}
	for(i=0;i<4;i++)	{
		wk1=a[0]&pat[i];
		wk2=a[1]&pat[i];
		if(wk1==0 && wk2==0)	{
			wk3=a[1]|pat[i];
			dp[1][wk3]=cnt[i];
		}
	}
//	for(i=0;i<16;i++)	printf(" %d",dp[1][i]);	printf("\n");
	for(i=1;i<h-1;i++)	{
		for(j=0;j<16;j++)	{
//			if(dp[i][j]!=0)	{
				wk3=a[i+1];
				dp[i+1][wk3]=max(dp[i+1][wk3],dp[i][j]);
				for(k=0;k<4;k++)	{
					wk1=(j|a[i])&pat[k];
					wk2=a[i+1]&pat[k];
					if(wk1==0 && wk2==0)	{
//						if(i==2)	printf("j=%d\n",j);
						wk3=a[i+1]|pat[k];
						dp[i+1][wk3]=max(dp[i+1][wk3],dp[i][j]+cnt[k]);
					}
				}
//			}
		}
	}
//	for(i=0;i<h;i++)	{
//		for(j=0;j<16;j++)	printf("%d ",dp[i][j]);
//		printf("\n");
//	}
	
	
	mx=-1;
	for(i=0;i<16;i++)	mx=max(mx,dp[h-1][i]);
	printf("%d\n",mx);
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
bool mp[10005][4];

int main(){
  ios_base::sync_with_stdio(false);
  int h,n,x,y;
  for(int i=0;i<10005;i++){
    for(int j=0;j<4;j++){
      mp[i][j] = true;
    }
  }
  cin >> h >> n;
  
  for(int i=0;i<n;i++){
    cin >> x >> y;
    mp[y][x] = false;
  }

  int ans = 0;
  for(int i=0;i<h-1;i++){
    if(mp[i][0] && mp[i][1] && mp[i+1][0] && mp[i+1][1]){ //左に正方形が作れるとき
      mp[i][0] = mp[i][1] = mp[i+1][0] = mp[i+1][1] = false;
      ans++;
    }
    if(mp[i][2] && mp[i][3] && mp[i+1][2] && mp[i+1][3]){ //右に正方形が作れるとき
      mp[i][2] = mp[i][3] = mp[i+1][2] = mp[i+1][3] = false;
      ans++;
    }
    if(mp[i][1] && mp[i][2] && mp[i+1][1] && mp[i+1][2]){ //真ん中に正方形が作れるとき
      int j=0;
      while(mp[i+1+j][0] && mp[i+1+j][1] && mp[i+1+j][2] && mp[i+1+j]) j++;
      if(j != 0 && j%2 == 1){
	mp[i][1] = mp[i][2] = mp[i+1][1] = mp[i+1][2] = false;
	ans++;
      }
    }
  }

  cout << ans << endl;

  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int H,N;
int mp[10000][4] = {};

int dp[10000][1<<4];
int solve(int now, int state){
	if(now == H && state == 0) return 0;
	if(now == H) return -10000;
	if(dp[now][state] != -1) return dp[now][state];
	int ans = solve(now+1, 0);
	//l
	if((state>>0)%2 == 0 && (state>>1)%2 == 0){
		if(mp[now][0] == 0 && mp[now][1] == 0 && mp[now+1][0] == 0 && mp[now+1][1] == 0){
			ans = max(ans, solve(now+1, 3)+1);
		}
	}
	//m
	if((state>>1)%2 == 0 && (state>>2)%2 == 0){
		if(mp[now][1] == 0 && mp[now][2] == 0 && mp[now+1][1] == 0 && mp[now+1][2] == 0){
			ans = max(ans, solve(now+1, 6)+1);
		}
	}
	//r
	if((state>>2)%2 == 0 && (state>>3)%2 == 0){
		if(mp[now][2] == 0 && mp[now][3] == 0 && mp[now+1][2] == 0 && mp[now+1][3] == 0){
			ans = max(ans, solve(now+1, 12)+1);
		}
	}
	//lr
	if((state>>0)%2 == 0 && (state>>1)%2 == 0){
		if(mp[now][0] == 0 && mp[now][1] == 0 && mp[now+1][0] == 0 && mp[now+1][1] == 0){
			if((state>>2)%2 == 0 && (state>>3)%2 == 0){
				if(mp[now][2] == 0 && mp[now][3] == 0 && mp[now+1][2] == 0 && mp[now+1][3] == 0){
					ans = max(ans, solve(now+1, 15)+2);
				}
			}
		}
	}
	return dp[now][state] = ans;
}
int main(){
	cin >> H >> N;
	for(int i=0; i<N; i++){
		int x,y;
		cin >> x >> y;
		mp[y][x] = 1;
	}
	for(int i=0; i<H; i++){
		for(int j=0; j<(1<<4); j++) dp[i][j] = -1;
	}
	cout << solve(0, 0) << endl;
}