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>
using namespace std;

int dfs(int x,int y);
int mas[20][20];
int X,Y;

int main(){
	while(1){
		cin >> X >> Y;
		if(X == 0 && Y == 0) break;
		for(int i=0;i<Y;i++){
			for(int j=0;j<X;j++){
				cin >> mas[i][j];
			}
		}
		int ans = 0;
		for(int i=0;i<X;i++){
			if(mas[0][i] == 0){
				ans += dfs(i,0);
			}
		}
		cout << ans << endl;
	}
}

int dfs(int x,int y){
	int cou = 0;
	//if(mas[y][x] == 1) return 0;
	if(y>=Y-1) return 1;
	if(mas[y][x] == 2) return dfs(x,y+2);
	for(int i=-1;i<2;i++){
		int nx = x + i;
		int ny = y + 1;
		if(nx >= 0 && nx < X){
			if(i == 0 && mas[ny][nx] == 2){
				cou += dfs(nx,ny);
			}
			else if(mas[ny][nx] == 0){
				cou += dfs(nx,ny);
			}
		}
	}
	return cou;
}

C++: #include<iostream>
using namespace std;
int main(){
  while(true){
    int xsize,ysize;
    cin>>xsize>>ysize;
    if(!xsize&&!ysize)break;
    int course[xsize+2][ysize];
    for(int y=0;y<ysize;y++){
      for(int x=0;x<xsize;x++){
	cin>>course[x+1][y];
      }
    }
    int pattern[xsize+2][ysize+1];
    for(int y=0;y<ysize;y++){
      for(int x=0;x<xsize+2;x++){
	if(y) pattern[x][y] = 0;
	else if(course[x][y]) pattern[x][y] = 0;	    
	else pattern[x][y] = 1;
      }
    }
    pattern[0][0] = 0;
    pattern[xsize+1][0] = 0;
    int count = 0;
    for(int y=0;y<ysize;y++){
      for(int x=1;x<xsize+1;x++){
	cout<<pattern[x][y];
	if(course[x][y]==0){
	  if(y==ysize-1) count+=pattern[x][y];
	  else{
	    if(course[x-1][y+1]==0)
	      pattern[x-1][y+1] += pattern[x][y];
	    if(course[x][y+1]!=1)
	      pattern[x][y+1] += pattern[x][y];
	    if(course[x+1][y+1]==0)
	      pattern[x+1][y+1] += pattern[x][y];
	  }
	}
	if(course[x][y]==2){
	  if(y==ysize-2) count+= pattern[x][y];
	  else if(y==ysize-1) count+= pattern[x][y];
	  else pattern[x][y+2] += pattern[x][y];
	}
      }
      cout<<endl;
    }
    cout<<count<<endl;
  }
  return 0;
}

C++: #include<iostream>
using namespace std;
int solve(int x,int y);
int ax,ay;
int mas[20][20];
int main(){
  while(1){
    int ans=0;
    cin>>ax>>ay;
    if(ax==0 && ay==0){
      break;
    }
    for(int i=0;i<ay;i++){
      for(int j=0;j<ax;j++){
	cin>>mas[i][j];
      }
    }
    for(int i=0;i<ax;i++){
      if(mas[0][i]!=1){
	ans+=solve(i,0);
      }
    }
    cout<<ans<<endl;
  }
}
int solve(int x,int y){
  if(y==ay){
    return 1;
  }else if(mas[y][x]==1){
    return 0;
  }else if(mas[y][x]==2){
    return solve(x,y+2);
  } 
  else{
    int anss=0; 
    if(mas[y+1][x]!=1){
      anss+=solve(x,y+1);
    }
    if(x+1<ax && mas[y+1][x+1]==0 && y+1!=ay){
      anss+=solve(x+1,y+1);
    }
    if(0<=x-1 && mas[y+1][x-1]==0 && y+1!=ay){
      anss+=solve(x-1,y+1);
    }
    return anss;
  }
}

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) table[i][j]+=table[i-1][j-1];
if(j<X-1&&map[i-1][j+1]==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>
#include <stdlib.h>
int x,y,M[50][50],D[50][50],i,j,r;
main(){
        for(;;){
                scanf("%d%d",&x,&y);
                if(x==0)exit(0);
                for(i=0;i<289;i++) {M[i%17][i/17]=1;D[i%17][i/17]=0;}
                for(i=0;i<y;i++)
                        for(j=0;j<x;j++)
                                scanf("%d",&M[j+1][i]);
                for(j=1;j<=x;j++){if(M[j][y-1]!=1)D[j][y-1]=1;D[j][y]=1;}
                for(j=y-2;j>=0;j--){
                        for(i=1;i<=x;i++){
                                if(M[i][j]==0) {
                                        D[i][j]=D[i][j+1];
                                        if(M[i+1][j+1]!=2) D[i][j]+=D[i+1][j+1];
                                        if(M[i-1][j+1]!=2) D[i][j]+=D[i-1][j+1];
                                }
                                if(M[i][j]==2) D[i][j]=D[i][j+2];
                        }
                }
                r=0;
                for(i=1;i<=x;i++){
                        r+=D[i][0];
                }
                printf("%d\n",r);
        }
}

C++: #include <iostream>
using namespace std;
int main()
{
    while(1)
    {
        int x,y,ans=0;
        int dp[17][17]={0};
        int course[15][15]={0};
        cin>>x>>y;if(!x)return 0;
        for(int j=0;j<y;++j){
            for(int i=0;i<x;++i){
            	cin>>course[i][j];
            	if(!course[i][0])dp[i][0]=1;
            }
        }
        for(int j=0;j<y-1;++j){
            for(int i=0;i<x;++i){
                if(!course[i][j]){
                    if(course[i][j+1]!=1)dp[i][j+1]+=dp[i][j];
                    if(i){
                        if(!course[i-1][j+1])dp[i-1][j+1]+=dp[i][j];
                    }
                    if(i<x){
                        if(!course[i+1][j+1])dp[i+1][j+1]+=dp[i][j];
                    }
                }
                if(course[i][j]==2){
                    if(course[i][j]!=1)dp[i][j+2]+=dp[i][j];
                }
            }
        }
        for(int j=y-1;j<y+2;++j){
            for(int i=0;i<x;++i){
                ans+=dp[i][j];
            }
        }
        cout<<ans<<endl;
    }
}

C++: 5 5
0 0 0 0 1
2 1 0 2 0
1 0 0 1 1
0 2 1 2 0
0 1 0 0 0
5 5
0 0 1 0 0
2 1 0 2 0
1 0 0 1 1
0 2 1 2 0
0 1 0 0 0
15 15
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0