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;

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

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

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

signed main() {
	ll h, n, cnt = 0;
  bool s[4][10001];
  cin >> h >> n;
  ll x, y;
  rep(i, n) {
    cin >> x >> y;
    s[x][n - y + 1] = true;
  }
  rep(i, h - 1) {
    if(!s[0][i] && !s[1][i] && !s[0][i + 1] && !s[1][i + 1]) {
      s[0][i] = s[1][i] = s[0][i + 1] = s[1][i + 1] = true;
      cnt++;
    }
    if(!s[2][i] && !s[3][i] && !s[2][i + 1] && !s[3][i + 1]) {
      s[2][i] = s[3][i] = s[2][i + 1] = s[3][i + 1] = true;
      cnt++;
    }
    if(!s[1][i] && !s[2][i] && !s[1][i + 1] && !s[2][i + 1]) {
      s[1][i] = s[2][i] = s[1][i + 1] = s[2][i + 1] = true;
      cnt++;
    }
  }
  /*
  rep(i, h) {
    rep(j, 4) {
      if(s[j][i]) {
        cout << '#';
      } else cout << '.';
    }
    cout << endl;
  }
  */
  cout << cnt << endl;
	return 0;
}

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 <stdio.h>

int max(int a, int b) {
  return a > b ? a : b;
}

int main(void) {
  int n, i, j, h;
  scanf("%d%d", &h, &n);
  int a[4][h], dp[5][h];
  for(j = 0; j < h; ++j) {
    for(i = 0; i < 4; ++i) a[i][j] = 1;
    for(i = 0; i < 5; ++i) dp[i][j] = 0;
  }
  for(i = 0; i < n; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    a[x][y] = 0;
  }
  if(a[0][0] && a[0][1] && a[1][0] && a[1][1]) dp[1][1] = 1;
  if(a[2][0] && a[2][1] && a[1][0] && a[1][1]) dp[2][1] = 1;
  if(a[3][0] && a[3][1] && a[2][0] && a[2][1]) dp[3][1] = 1;
  if(dp[1][1] && dp[3][1]) dp[4][1] = 2;
  else dp[4][1] = max(dp[1][1], max(dp[2][1], dp[3][1]));
  for(i = 2; i < h; ++i) {
    int s = 1;
    dp[0][i] = dp[4][i - 2];
    if(a[0][i - 1] && a[0][i] && a[1][i - 1] && a[1][i]) dp[1][i] = max(dp[3][i - 1] + 1, dp[4][i - 2] + 1);
    else s = 0;
    if(a[2][i - 1] && a[2][i] && a[1][i - 1] && a[1][i]) dp[2][i] = dp[4][i - 2] + 1;
    if(a[3][i - 1] && a[3][i] && a[2][i - 1] && a[2][i]) dp[3][i] = max(dp[1][i - 1] + 1, dp[4][i - 2] + 1);
    else s = 0;
    for(j = 1; j < 4; ++j) if(!dp[j][i]) dp[j][i] = dp[0][i];
    if(s) dp[4][1] = dp[4][i - 2] + 2;
    else dp[4][i] = max(dp[1][i], max(dp[2][i], dp[3][i]));
  }
  /*for(i = 0; i < h; ++i) {
    for(j = 0; j < 5; ++j) printf("%d ", dp[j][i]);
    printf("\n");
  }*/
  printf("%d\n", dp[4][h - 1]);
  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;
	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;
	return 0;
}

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 H,N,F[10101];
long long dp[10101][1<<4];

int main(){
    cin>>H>>N;

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

    FOR(i,0,10101){
        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);
            }
        }
    }
    long long ans = -1e9;
    FOR(i,0,(1<<4)){ans = max(ans,dp[H-1][i]);}
    put(ans);
}