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 i := 0; i < H-1; i++ {
		for j := 0; j < 3; j++ {
			if !room[i][j] && !room[i+1][j] && !room[i][j+1] && !room[i+1][j+1] {
				room[i][j] = true
				room[i+1][j] = true
				room[i][j+1] = true
				room[i+1][j+1] = true
				count++
			}
		}
	}
	fmt.Println(count)
}

C++: #include "bits/stdc++.h"
using namespace std;
using namespace std::chrono;
typedef long long ll;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(ll i=a;i<b;++i)
#define rep(...) _overload3(__VA_ARGS__,_repi,_rep)(__VA_ARGS__)
#define _rrepi(i,a,b) for(ll i=b-1;i>=a;i--)
#define _rrep(i,n) _rrepi(i,0,n)
#define rrep(...) _overload3(__VA_ARGS__,_rrepi,_rrep)(__VA_ARGS__)
#define sum(...) accumulate(range(__VA_ARGS__),0)
#define _range(i) (i).begin(),(i).end()
#define _rangek(i,k) (i).begin(),(i).begin()+k
#define range(...) _overload3(__VA_ARGS__,a,_rangek,_range)(__VA_ARGS__)
const ll LINF=1000000000000000000;
const int INF=100000007;
const ll MOD=100000007;
#define Yes(i) out((i)?"Yes":"No")
#define vec(type,name,size) vector<type> name(size);
#define VEC(type,name,size) vector<type> name(size);in(name)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(i) ll i;in(i)
#define STR(i) string i;in(i)
#define CHR(i) char i;in(i)
#define DBL(i) double i;in(i)
struct aaa{aaa(){cin.tie(0); cout<<fixed<<setprecision(15);};}aaaaaaa;
template<typename T>
istream& operator >> (istream& is, vector<T>& vec);
template<typename T,typename L>
istream& operator >> (istream& is, pair<T,L>& p);
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec);
template<typename T,typename L>
ostream& operator << (ostream& os, pair<T,L>& p);
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){for(T& x: vec) is >> x;return is;}
template<typename T,typename L>
istream& operator >> (istream& is, pair<T,L>& p){is >> p.first;is >> p.second;return is;}
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){rep(i,vec.size()){os << vec[i] << ( i+1 == vec.size() ? "" : " " );}return os;}
template<typename T,typename L>
ostream& operator << (ostream& os, pair<T,L>& p){os << p.first << " " << p.second;return os;}
inline void in() {}
inline void in(int&& a){scanf("%d",&a);}
inline void in(ll&& a){scanf("%lld",&a);}
inline void in(double&& a){scanf("%lf",&a);}
inline void in(char&& a){scanf("%c",&a);}
template<class T>
inline void in(T&& a){cin>>a;}
template<class Head,class... Tail>
inline void in(Head&& head,Tail&&... tail){in(head);in(move(tail)...);}
inline void out(){cout<<'\n';}
inline void out(const char a[]){if(strcmp(a,"No_Break"))cout<<a<<'\n';}
template<class T>
inline void out(T a){cout<<a<<'\n';}
template<class Head,class... Tail>
inline void out(Head head,Tail... tail){cout<<head<<' ';out(move(tail)...);}
int h,n;
vector<array<int,4>>s(10001);
vector<vector<vector<vector<int>>>>mem(10000,vector<vector<vector<int>>>(2,vector<vector<int>>(2,vector<int>(2,INF))));
int dp(int y,bool a1,bool a2,bool a3){
    if(y==h)return 0;
    if(mem[y][a1][a2][a3]-INF)return mem[y][a1][a2][a3];
    int a,max;
    bool b1=s[y+2][0]+s[y+2][1]+s[y+1][0]+s[y+1][1],b2=s[y+2][2]+s[y+2][1]+s[y+1][2]+s[y+1][1],b3=s[y+2][2]+s[y+2][3]+s[y+1][2]+s[y+1][3];
    max=dp(y+1,b1,b2,b3);
    if(!a1){
        a=dp(y+1,1,1,b3)+1;
        if(max<a)max=a;
    }
    if(!a2){
        a=dp(y+1,1,1,1)+1;
        if(max<a)max=a;
    }
    if(!a3){
        a=dp(y+1,b1,1,1)+1;
        if(max<a)max=a;
    }
    if(!(a1+a3)){
        a=dp(y+1,1,1,1)+2;
        if(max<a)max=a;
    }
    mem[y][a1][a2][a3]=max;
    return mem[y][a1][a2][a3];
}
int main(){
    in(h,n);
    rep(i,n){
        INT(x,y);
        s[y][x]=1;
    }
    rep(i,4)s[h][i]=1;
    out(dp(0,s[0][0]+s[0][1]+s[1][0]+s[1][1],s[0][2]+s[0][1]+s[1][2]+s[1][1],s[0][2]+s[0][3]+s[1][2]+s[1][3]));
}

C++: #include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef vector<int> vi;
const int inf = 1e9+7;
const int INF = 1e18+7;

int a[100000], dp[2][1<<5];
int put[] = {0, 3, 6, 12, 15};
int cnt[] = {0, 1, 1, 1, 2};
signed main(){
	int h, n;
	scanf("%lld%lld", &h, &n);
	rep(i,n){
		int x, y;
		scanf("%lld%lld", &x, &y);
		a[y] = (1<<x);
	}
	rep(bit,(1<<4)){
		if(bit == a[0])dp[0][bit] = 0;
		else dp[0][bit] = -1;
	}
	
	rep(i,h-1){
		fill(dp[1], dp[1]+(1<<5), -1);
		rep(bit,(1<<4)){
			if(dp[0][bit] == -1)continue;
			rep(k,5){
				int check1 = a[i]&put[k];
				int check2 = a[i+1]&put[k];
				if(!check1 and !check2 and !(bit&put[k])){
					int b = a[i+1] | put[k];
					dp[1][b] = max(dp[1][b], dp[0][bit]+cnt[k]);
				}
			}
		}
		swap(dp[0], dp[1]);
	}
	
	int ans = 0;
	rep(i,(1<<4))chmax(ans, dp[0][i]);
	printf("%lld\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;

  bool t[4][10005] = {};

  rep(i, 0, n) {
    int x, y;
    cin >> x >> y;
    t[x][y] = true;
  }
  int ans = 0;
  rep(i, 0, h - 1) {
    if(!t[0][i] && !t[1][i] && !t[0][i + 1] && !t[1][i + 1]) {
      ans++, t[1][i] = true, t[0][i + 1] = true, t[1][i + 1] = true;
    }
    if(!t[2][i] && !t[3][i] && !t[2][i + 1] && !t[3][i + 1]) {
      ans++, t[2][i] = true, t[2][i + 1] = true, t[3][i + 1] = true;
    }
    if(!t[1][i] && !t[2][i] && !t[1][i + 1] && !t[2][i + 1]) {
      int k = 0;
      while(!t[0][i + 1 + k] && !t[1][i + 1 + k] && !t[2][i + 1 + k] && !t[3][i + 1 + k] && i < h) k++;
      if(k < 2 || k % 2) {
        ans++, t[1][i + 1] = true, t[2][i + 1] = true;
      }
    }
  }
  cout << ans << endl;
}

C++: #include<bits/stdc++.h>
using namespace std;
#define MAX 114514
signed main(){
  int h,n;
  cin>>h>>n;
  int bi[MAX];
  memset(bi,0,sizeof(bi));
  for(int i=0;i<n;i++){
    int x,y;
    cin>>x>>y;
    bi[y]|=1<<x;
  }
  static int dp[1<<8][MAX];
  memset(dp,-1,sizeof(dp));
  int ms=(1<<8)-1;
  auto p=[&](int x){return x&1;};
  function<int(int,int)> dfs=[&](int b,int y){
    //cout<<bitset<8>(b)<<" "<<y<<"+"<<dp[b][y]<<endl;
    if(~dp[b][y]) return dp[b][y];
    if(y+1==h) return 0;
    int res=dfs(((b<<4)+bi[y+2])&ms,y+1);
    if(b==0){
      res=max(res,dfs(((15<<4)+bi[y+2])&ms,y+1)+2);
    }
    if(p(b>>4)==0&&p(b>>5)==0&&p(b>>0)==0&&p(b>>1)==0){
      res=max(res,dfs((((b+3)<<4)+bi[y+2])&ms,y+1)+1);
    }
    if(p(b>>5)==0&&p(b>>6)==0&&p(b>>1)==0&&p(b>>2)==0){
      res=max(res,dfs((((b+6)<<4)+bi[y+2])&ms,y+1)+1);
    }
    if(p(b>>6)==0&&p(b>>7)==0&&p(b>>2)==0&&p(b>>3)==0){
      res=max(res,dfs((((b+12)<<4)+bi[y+2])&ms,y+1)+1);
    }
    //cout<<bitset<8>(b)<<" "<<y<<":"<<res<<endl;
    return dp[b][y]=res;
  };
  cout<<dfs((bi[0]<<4)+bi[1],0)<<endl;
  return 0;
}