Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
	)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		buf := strings.Split(scanner.Text(), " ")
		X, _ := strconv.Atoi(buf[0])
		Y, _ := strconv.Atoi(buf[1])
		if X == 0 && Y == 0 {
			break
		}
		tbl := make([][]int, Y+2)
		field := make([][]int, Y+2)
		for i := range field {
			field[i] = make([]int, X+2)
			tbl[i] = make([]int, X+2)
			for j := range field[i] {
				field[i][j] = 2
				tbl[i][j] = 0
			}
		}
		buf_ := make([][]string, Y)
		for i := range buf_ {
			scanner.Scan()
			buf_[i] = strings.Split(scanner.Text(), " ")
		}
		for i := 1; i <= Y; i++ {
			for j := 1; j <= X; j++ {
				field[i][j], _ = strconv.Atoi(buf_[i-1][j-1])
				switch field[i][j] {
				case 0:
					if i == 1 {
						tbl[i][j] = 1 // スタートy=1
					} else {
						if field[i-1][j-1] != 2 {
							tbl[i][j] += tbl[i-1][j-1] // 左上からやってくる
						}
						if field[i-1][j] != 2 {
							tbl[i][j] += tbl[i-1][j] // 真上からやってくる
						}
						if field[i-1][j+1] != 2 {
							tbl[i][j] += tbl[i-1][j+1] // 右上からやってくる
						}
						if field[i-2][j] == 2 {
							tbl[i][j] += tbl[i-2][j] // ジャンプしてくる
						}
					}
				case 1:
					tbl[i][j] = 0 // 障害物あり
				case 2:
					if field[i-1][j] != 2 {
						tbl[i][j] += tbl[i-1][j] // 真上からくる
					}
					if field[i-2][j] == 2 {
						tbl[i][j] += tbl[i-2][j] // ジャンプ台からジャンプしてくる
					}
				}
			}
		}
		sum := 0
		for i := 1; i <= X; i++ {
			sum += tbl[Y][i] // とびこさないでゴール
			if field[Y-1][i] == 2 {
				sum += tbl[Y-1][i] // 飛び越してゴール
			}
		}
		fmt.Println(sum)
	}
}

C++: #include <iostream>
#include <stdio.h>

using namespace std;

int main(int argc, char const* argv[])
{
	int x,y;
	int stage[17][17][2];

	while( cin >> x >> y && x != 0 && y != 0 ){
		for( int i = 0;i < 17;i++ ){
			for( int j = 0;j < 17;j++ ){
				stage[i][j][0] = stage[i][j][1] = 0;
			}
		}
		
		
		for( int i = 1;i <= y;i++ ){
			for( int j = 1;j <= x;j++ ){
				cin >> stage[j][i][0];
			}
		}

		for( int i = 0;i < 17;i++ ) if(stage[i][1][0] != 1 ) stage[i][1][1] = 1;

		for( int j = 1;j < y;j++ ){
			for( int i = 1;i <= x;i++ ){
				if( stage[i][j][0] == 1 ) continue;
				if( stage[i][j][0] == 0 ){
					stage[i][j + 1][1] += stage[i][j][1];
					
					if( stage[i + 1][j + 1][0] == 0 ) stage[i + 1][j + 1][1] += stage[i][j][1];
					if( stage[i - 1][j + 1][0] == 0 ) stage[i - 1][j + 1][1] += stage[i][j][1];

				}
				if( stage[i][j][0] == 2 ){
					stage[i][j + 2][1] = stage[i][j][1];
				}
			}
		}
		
		int count = 0;
		for( int i = 1;i <= x;i++ ){
			count += stage[i][y+1][1] + stage[i][y][1];
		}
		cout << count << endl;
	}
	return 0;
}

C++: #include<stdio.h>
#include<string.h>

int main(){
	int kosu[2][20][20],x,y,c,i,j;
	
	while(~scanf("%d%d",&x,&y)){
		if(x==0&&y==0)break;
		memset(kosu,0,sizeof(kosu));
		for(i=1;i<=y;i++){
			for(j=1;j<=x;j++){
				scanf("%d",&c);
				kosu[1][i][j]=c;
			}
		}
		
		for(i=1;i<=x;i++){
			if(kosu[1][1][i]==0)kosu[0][1][i]=1;
		}
		
		for(i=2;i<y;i++){
			for(j=1;j<=x;j++){
				if(kosu[1][i][j]==1)continue;
				if(kosu[1][i-2][j]==2)kosu[0][i][j]+=kosu[0][i-2][j];
				if(kosu[1][i][j]==2){
					kosu[0][i][j]+=(kosu[1][i-1][j]==2?0:kosu[0][i-1][j]);
				}else{
					kosu[0][i][j]+=((kosu[1][i-1][j-1]==2?0:kosu[0][i-1][j-1])+(kosu[1][i-1][j]==2?0:kosu[0][i-1][j])+(kosu[1][i-1][j+1]==2?0:kosu[0][i-1][j+1]));
				}
			}
		}
		
		if(y==1){
			j=0;
			for(i=1;i<=x;i++){
				j+=kosu[0][y][i];
			}
			printf("%d\n",j);
			continue;
		}
		
		for(j=1;j<=x;j++){
			if(kosu[1][y-1][j]==2)kosu[0][y][j]+=kosu[0][y-1][j];
			if(kosu[1][y][j]!=1 && kosu[1][y-2][j]==2)kosu[0][y][j]+=kosu[0][y-2][j];
			if(kosu[1][y][j]==1)continue;
			if(kosu[1][y][j]==2){
				kosu[0][y][j]+=(kosu[1][y-1][j]==2?0:kosu[0][y-1][j]);
			}else{
				kosu[0][y][j]+=((kosu[1][y-1][j-1]==2?0:kosu[0][y-1][j-1])+(kosu[1][y-1][j]==2?0:kosu[0][y-1][j])+(kosu[1][y-1][j+1]==2?0:kosu[0][y-1][j+1]));
			}
		}
		
		
		j=0;
		for(i=1;i<=x;i++){
			j+=kosu[0][y][i];
		}
		printf("%d\n",j);
	}
	return 0;
}

C++: #include <stdio.h>
const int X=20;
const int Y=20;
int main(){
    int n,m,dp[X][Y],s[X][Y],k,ans;
    while(true){
        scanf("%d%d",&m,&n);
        if(n==0&&m==0)return 0;
        ans=0;
        for(int i=0;i<n+2;i++)for(int j=0;j<m;j++)dp[i][j]=s[i][j]=0;
        for(int i=0;i<m;i++)dp[0][i]=1;
        for(int i=0;i<n;i++)for(int j=0;j<m;j++){
            scanf("%d",&k);
            if(k==0){
                dp[i][j]+=s[i][j];
                if(i==n-1)continue;
                dp[i+1][j]+=dp[i][j];
                if(j!=0)s[i+1][j-1]+=dp[i][j];
                if(j!=m-1)s[i+1][j+1]+=dp[i][j];
            }
            else if(k==2){
                s[i][j]=0;
                dp[i+2][j]+=dp[i][j];
            }
            else dp[i][j]=0;
        }
        for(int i=0;i<m;i++)ans+=dp[n][i]+dp[n-1][i];
        printf("%d\n",ans);
    }
}

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

#define reep(i,n,m) for(int i=(n);i<(m);i++)
#define rep(i,n) reep(i,0,n)

using namespace std;

int main(){
    int X,Y;
    while(cin >> X >> Y,X+Y){
        int fld[20][20] = {0};
        rep(y,Y){
            rep(x,X){
                cin >> fld[y][x];
            }
        }

        int dp[20][20] = {0};
        rep(x,X){
            if(fld[0][x] == 0)
                dp[0][x] = 1;
        }

        rep(y,Y-1){
            rep(x,X){
                int val = dp[y][x];
                if(fld[y][x] == 0){
                    if(x>0 && fld[y+1][x-1] != 2){
                        dp[y+1][x-1] += val;
                    }
                    if(fld[y+1][x+1] != 2){
                        dp[y+1][x+1] += val;
                    }
                    dp[y+1][x] += val;
                }else if(fld[y][x] == 2){
                    dp[y+2][x] += val;
                }
            }
        }

        int ans = 0;
        rep(i,2){
            rep(x,X){
                if(fld[Y+i-1][x] == 0)
                    ans += dp[Y+i-1][x];
            }
        }
        cout << ans << endl;
    }
    return 0;
}

C++: #include<cstdio>
#include<cstring>

int map[15][15],table[15][15],X,Y;

int main(){
while(1){

scanf("%d%d",&X,&Y);
if(X==0&&Y==0) return 0;
memset(map,-1,sizeof(map));
memset(table,0,sizeof(table));
for(int i=0;i<Y;i++){
for(int j=0;j<X;j++){
scanf("%d",&map[i][j]);
if(i==0&&map[i][j]==0) table[i][j]=1;
else if(i!=0&&map[i][j]!=1){
if(j>0&&map[i-1][j-1]==0&&map[i][j]==0) table[i][j]+=table[i-1][j-1];
if(j<X-1&&map[i-1][j+1]==0&&map[i][j]==0) table[i][j]+=table[i-1][j+1];
if(map[i-1][j]==0)table[i][j]+=table[i-1][j];
if(i>2&&map[i-2][j]==2) table[i][j]+=table[i-2][j]; 
} 
}
}
int sum=0;
for(int i=0;i<X;i++){
sum+=table[Y-1][i];
if(map[Y-2][i]==2) sum+=table[Y-2][i];
}
printf("%d\n",sum);



}
}

C++: #include <stdio.h>
const int X=20;
const int Y=20;
int main(){
    int n,m,dp[X][Y],s[X][Y],k,ans;
    while(true){
        scanf("%d%d",&n,&m);
        if(n==0&&m==0)return 0;
        ans=0;
        for(int i=0;i<n+2;i++)for(int j=0;j<m;j++)dp[i][j]=s[i][j]=0;
        for(int i=0;i<m;i++)dp[0][i]=1;
        for(int i=0;i<n;i++)for(int j=0;j<m;j++){
            scanf("%d",&k);
            if(k==0){
                dp[i][j]+=s[i][j];
                if(i==n-1)continue;
                dp[i+1][j]+=dp[i][j];
                if(j!=0)s[i+1][j-1]+=dp[i][j];
                if(j!=n-1)s[i+1][j+1]+=dp[i][j];
            }
            else if(k==2){
                s[i][j]=0;
                if(i==n-1)continue;
                dp[i+2][j]+=dp[i][j];
            }
            else dp[i][j]=s[i][j]=0;
        }
        for(int i=0;i<m;i++)ans+=dp[n][i]+dp[n-1][i];
        
        printf("%d\n",ans);
    }
}