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 < 3; i++ {
		for j := 0; j < H-1; j++ {


			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++: 
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0363&lang=ja
#include <stdio.h>
int boxcount(int);
int max(int,int);

int count[40000];
int nimotsu[40000];
int H;

//■マス目の位置を(x, y)の２次元ではなくて、一番左上が０で、その右が１、０の下が４、さらにその下が８になるような感じで、１次元の０～３９９９９で表す。
int main(){
  int i,n,x,y;
  for(i=0;i<40000;i++){
    count[i]=-1;
	nimotsu[i]=0;
  }
    scanf("%d %d",&H,&n);
  for(i=0;i<n;i++){
    scanf("%d %d",&x,&y);
    nimotsu[x+y*4]=1;
  }
  printf("%d\n",boxcount(0));
  return 0;
}

int boxcount(int num){    // ■numがマス目上のマーカーの位置を表す。
  if(num >= H*4-4){return 0;}// ■マーカーが一番下の行にあるときには、下にマスがないので積み荷はおけない。
  if(count[num] > -1){return count[num];}// ■メモ化再帰
  else{
	if((num%4)==0){        // ■一番左の列にマーカーがある場合
      if(nimotsu[num]==0 && nimotsu[num+1]==0 && nimotsu[num+4]==0 && nimotsu[num+5]==0){// ■マーカーの位置を左上として、積み荷がそこにおけるか？
        if(nimotsu[num+2]==0 && nimotsu[num+3]==0 && nimotsu[num+6]==0 && nimotsu[num+7]==0){
		  count[num]=max(boxcount(num+1),2+boxcount(num+8));
		  return count[num];
        }
		else{
		  count[num]=max(boxcount(num+1),1+boxcount(num+6));
		  return count[num];          
		}
      }
      else{
	  	count[num]=boxcount(num+1);
	    return count[num];
      }
	}

	else if((num%4)==1){        // ■左から２列目の列にマーカーがある場合
      if(nimotsu[num]==0 && nimotsu[num+1]==0 && nimotsu[num+4]==0 && nimotsu[num+5]==0){
		count[num]=max(boxcount(num+1),1+boxcount(num+7));
		return count[num];          
      }
	  else{
		count[num]=boxcount(num+1);
		return count[num];          	  	
	  }
	}

	else if((num%4)==2){        // ■左から３列目の列にマーカーがある場合
      if(nimotsu[num]==0 && nimotsu[num+1]==0 && nimotsu[num+4]==0 && nimotsu[num+5]==0){
        if(num<H*4-8 && nimotsu[num+2]==0 && nimotsu[num+3]==0 && nimotsu[num+6]==0 && nimotsu[num+7]==0){
		  count[num]=max(boxcount(num+1),2+boxcount(num+8));
		  return count[num];
        }
		else{
		  count[num]=max(boxcount(num+1),1+boxcount(num+6));
		  return count[num];          
		}
      }
      else{        // ■左から４列目の列（右端の列にマーカーがある場合
	  	count[num]=boxcount(num+1);
	    return count[num];
      }
	}
		
	else{
      count[num]=boxcount(num+1);
	  return count[num];
	}
  }
}

int max(int a, int b) {
    if (a > b)
        return a;
    else
        return b;
}

C++: #include <iostream>
#include <vector>

using namespace std;

int main(){
	int h, n, x, y;
	cin >> h >> n;
	int array[h][4];

	for(int i = 0; i < h; i++){
		array[i][0] = 0;
		array[i][1] = 0;
		array[i][2] = 0;
		array[i][3] = 0;
	}

	for(int i = 0; i < n; i++){
		cin >> x >> y;
		array[y][x] = -1;
	}

	int count = 1;
	for(int i = 0; i < h; i++){
		if((array[i][0] == 0 && array[i+1][0] == 0 && array[i][1] == 0 && array[i+1][1] == 0) && (array[i][2] == 0 && array[i+1][2] == 0 && array[i][3] == 0 && array[i+1][3] == 0)){
				array[i][0] = count;
				array[i+1][0] = count;
				array[i][1] = count;
				array[i+1][1] = count;
				count++;
				array[i][2] = count;
				array[i+1][2] = count;
				array[i][3] = count;
				array[i+1][3] = count;
				count++;
		}
	}


	for(int i = 0; i < h-1; i++){
		for(int j = 0; j < 3; j++){
			if(array[i][j] == 0 && array[i+1][j] == 0 && array[i][j+1] == 0 && array[i+1][j+1] == 0){
				array[i][j] = count;
				array[i+1][j] = count;
				array[i][j+1] = count;
				array[i+1][j+1] = count;
				count++;
			}
		}
	}

	cout << count-1 << endl;
}

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] = -1;
		//else dp[1][bit] = 0;
		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 std::cout;
using std::endl;
using std::cin;

std::vector<std::string> s;
std::vector<int> vec, dp;
int h, n;

int dfs(int p){
	if(p >= h - 1) return 0;
	if(~dp[p]) return dp[p];
	
	int ret = std::max(vec[p] + dfs(p + 2), dfs(p + 1));
	return dp[p] = ret;
}

int main(){
	cin >> h >> n; s.resize(h, std::string(4, '.'));
	for(int i = 0; i < n; i++){
		int a, b; cin >> a >> b;
		
		s[b][a] = '#';
	}
	reverse(begin(s), end(s));
	
	dp.resize(h - 1, -1);
	for(int i = 0; i < h - 1; i++){
		int count = 0;
		for(int j = 0; j < 3; j++){
			if(s[i][j] == '#') continue;
			if(s[i + 1][j] == '#') continue;
			if(s[i][j + 1] == '#') continue;
			if(s[i + 1][j + 1] == '#') continue;
			count++; j++;
		}
		vec.push_back(count);
	}
	
	cout << dfs(0) << endl;
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int H,N,X,Y;
	int i,j,k;
	int wk1,wk2,wk3;
	int mask[4]={3,6,12,15},smask[4]={1,2,4,8};
	int cnt[4]={1,1,1,2};
	int dp[10001][16],syogai[10001];
	cin>>H>>N;
	for(i=0;i<H;i++){
		syogai[i]=0;
	}
	
	for(i=0;i<N;i++){
		cin>>X>>Y;
		syogai[Y]=(syogai[Y]|smask[X]);
	}
//	for(i=0;i<H;i++) cout<<" syogai= "<<syogai[i]<<endl;

	for(i=0;i<H;i++){
		for(j=0;j<16;j++){
			dp[i][j]=0;
		}
	}
	
	for(i=0;i<4;i++){
		wk1=syogai[0]&mask[i];
		wk2=syogai[1]&mask[i];
		if(wk1==0&&wk2==0){
			//cout<<" i= "<<i<<endl;
			wk3=syogai[1]|mask[i];
			dp[1][wk3]=cnt[i];
		}
	}
	
	//for(i=0;i<16;i++) cout<<dp[1][i]; cout<<endl;
	
	for(i=1;i<H-1;i++){
		for(j=0;j<16;j++){
			wk3=syogai[i+1];
			dp[i+1][wk3]=max(dp[i+1][wk3],dp[i][j]);
			for(k=0;k<4;k++){
				wk1=(j|syogai[i])&mask[k];
				wk2=syogai[i+1]&mask[k];
				if(wk1==0&&wk2==0){
					wk3=syogai[i+1]|mask[k];
					dp[i+1][wk3]=max(dp[i+1][wk3],dp[i][j]+cnt[k]);
				}
			}
		}
	}
	/*for(i=0;i<16;i++){cout<<i;}
	cout<<endl;
	
	for(i=0;i<H;i++){
		for(j=0;j<16;j++){
			if(j>9){
				cout<<" ";
			}
			cout<<dp[i][j];
		}
		cout<<endl;
		
	}*/
	
	
	int Max=-1;
	for(i=0;i<16;i++){
		Max=max(dp[H-1][i],Max);
	}
	cout<<Max<<endl;
	return 0;
}