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 <vector>
#include <algorithm>
#include <string>
#include<random>
#include<math.h>
#include<limits.h>
#include<iterator>
#include<queue>
#include<functional>
#define rep(i,a) for(int i=0;i<a;i++)
#define nrep(i,a,b) for(int i=a;i<b;i++)
#define mrep(i,a) for(int i=a;i>=0;i--)
#define ll long long
#define vl vector<ll> 
#define vvl vector<vector<ll> > 
#define vb vector<bool> 
#define vvb vector<vector<bool> > 
#define INF 11234567890123456789
using namespace std;

int main(){
	ll h, n; cin >> h >> n;
	vvb map(4, vb(h, true));
	rep(i, n){
		ll x, y; cin >> x >> y;
		map[x][y] = false;
	}
	vl dp(h, 0);
	ll count = 0;
	rep(i, h-1){
		vb map_b(3);
		ll plus = 0;
		if (i > 0) plus = dp[i - 1];
		rep(j, 3) if (map[j][i] && map[j][i + 1] && map[j+1][i] && map[j+1][i + 1]) map_b[j] = true;
		if (map_b[0] && map_b[2]) dp[i + 1] = 2 + plus;
		else if (map_b[0] || map_b[1] || map_b[2]) dp[i + 1] = 1 + plus;
		else dp[i + 1] = plus;
	}cout << dp[h - 1] << endl;
	return 0;
}

C++: #include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define FOR(i,n,a) for(int i = a;i<n;i++)
#define rep(i,n) FOR(i,n,0)
#define UNFOR(i,n,a) for(int i = a;i>n;i--)
#define unrep(i,n) UNFOR(i,0.n)
typedef long long ll;
using namespace std;
bool m[10000][4];
int main() {
	int H, N;
	cin >> H >> N;
	rep(i, N) {
		int a, b;
		cin >> a >> b;
		m[b][a] = true;
	}
	int count = 0;
	rep(i, H-1) {
		if (m[i][0] + m[i][1] + m[i + 1][0] + m[i + 1][1] == 0) {
			count++;
			m[i][0] = m[i][1] = m[i + 1][0] = m[i + 1][1] = true;
		}
	}
	rep(i, H - 1) {
		if (m[i][2] + m[i][3] + m[i + 1][2] + m[i + 1][3] == 0) {
			count++;
			m[i][2] = m[i][3] = m[i + 1][2] = m[i + 1][3] = true;
		}
	}
	rep(i, H - 1) {
		if (m[i][2] + m[i][1] + m[i + 1][2] + m[i + 1][1] == 0) {
			count++;
			m[i][2] = m[i][1] = m[i + 1][2] = m[i + 1][1] = true;
		}
	}
	cout << count << endl;
	cin >> count;
	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string.h>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define Max(a,b) a=max(a,b);
typedef long long ll;
using namespace std;
#define X 256
int h,n;
bool d[10010][4];
int dp[100010][X];
int main(){
	cin>>h>>n;
	memset(d,0,sizeof(d));
	lol(i,n){
		int x,y;cin>>x>>y;
		d[y+1][x]=1;
	}
	lol(i,4)d[0][i]=1;
	memset(dp,-1,sizeof(dp));
	dp[0][0]=0;
	lol(i,h+1){
		lol(j,X){
			if(dp[i][j]==-1)continue;
			int k=j*16%X;
			lol(r,4)if(d[i][r]==1)k+=(1<<r);
			Max(dp[i+1][k],dp[i][j]);
			bool t[8];
			lol(r,8)t[r]=(k%(2<<r)>=(1<<r));
			if(t[0]+t[1]+t[4]+t[5]==0){
				Max(dp[i+1][k+51],dp[i][j]+1);
			}
			if(t[1]+t[2]+t[5]+t[6]==0){
				Max(dp[i+1][k+102],dp[i][j]+1);
			}
			if(t[2]+t[3]+t[6]+t[7]==0){
				Max(dp[i+1][k+204],dp[i][j]+1);
			}
			if(k==0){
				Max(dp[i+1][255],dp[i][j]+2);
			}
		}
	}
	int ans=0;
	lol(i,X)Max(ans,dp[h+1][i]);
	cout<<ans<<endl;
	return 0;
}

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[y][x] = '#';
	}

	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++: #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;

			int d = 0;

			dp[i+1][d] = max(dp[i+1][d], 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][d + 3] = max(1 + dp[i][j], dp[i+1][j+3]);

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

			if(~j&(2) && ~j&(1<<1) &&
				v[i+1][2] && v[i+1][1] && v[i][2] && v[i][1]
			  )
				dp[i+1][d + (1<<2) + (1<<1)] = max(1 + dp[i][j], dp[i+1][d + (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;

}