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<stdio.h>
int n,m;
int i,j;
int c[15][15],d[15][15];

int main(){
	while(1){
		scanf("%d %d",&m,&n);
		if(n==0&&m==0)return 0;
		int ans=0;
		for(i=0;i<n;i++)for(j=0;j<m;j++)scanf("%d",&c[i][j]);
		for(i=0;i<n;i++)for(j=0;j<m;j++){
			d[i][j]=0;
		}
		for(i=0;i<m;i++)if(c[0][i]!=1)d[0][i]=1;
		for(i=0;i<n;i++)for(j=0;j<m;j++){
			if(c[i][j]==0){
				if(j-1>=0&&j-1<m&&i+1<n&&c[i+1][j-1]==0)d[i+1][j-1]+=d[i][j];
				if(j+1>=0&&j+1<m&&i+1<n&&c[i+1][j+1]==0)d[i+1][j+1]+=d[i][j];
				if(i+1<n&&c[i+1][j]!=1)d[i+1][j]+=d[i][j];
			}
			if(c[i][j]==2){
				if(i+2<n&&c[i+2][j]!=1)d[i+2][j]+=d[i][j];
			}
		}
		for(i=0;i<n;i++)if(c[n-2][i]==2)ans+=d[n-2][i];
		for(i=0;i<n;i++)if(c[n-1][i]!=1)ans+=d[n-1][i];
		printf("%d\n",ans);
	}
}

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


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

using namespace std;

int x,y;
int c[20][20];
int dp[20][20];

void solve() {
	rep(i,20) rep(j,20) c[i][j]=1;
	rep(i,20) rep(j,20) dp[i][j]=0;

	rep(i,y) rep(j,x) cin>>c[i][j];

	rep(i,20) if(c[0][i]!=1) dp[0][i]=1;
	
	for(int i=0;i<y;i++) {
		for(int j=0;j<x;j++) {
			if(c[i][j]==2) {
				dp[i+2][j] += dp[i][j];
			}
			else if(c[i][j]==0) {
				if(c[i+1][j]!=1) {
					dp[i+1][j] += dp[i][j];
				}
				if(0<=j-1 && c[i+1][j-1]==0) {
					dp[i+1][j-1] += dp[i][j];
				}
				if(j+1 < x && c[i+1][j+1]==0) {
					dp[i+1][j+1] += dp[i][j];
				}
			}
		}
	}



	int ans=0;
	rep(i,x) ans+=dp[y-1][i];
	rep(i,x) ans+=dp[y][i];

	cout<<ans<<endl;

}

int main() {
	while(cin>>x>>y) {
		if(x+y==0) return 0;
		solve();
	}
	return 0;
}

C++: #include<iostream>
//#include
using namespace std;

struct P{
	int way;
	int stt;
};

//グローバルは土俵F、と配列ans

P F[17][17];
//はじめにF.wayを-1で初期化 端っこ.sttを1で初期化

long ans[1000]={0};
int counter=0,flag=0;

int solve(int x,int y);

int jump(int x,int y){
	if(F[x][y-2].stt==2)
		return (F[x][y-2].way==-1) ? solve(x,y-2) : F[x][y-2].way;
	else return 0;
}

int left(int x,int y){
	if(F[x-1][y-1].stt==0) 
		return (F[x-1][y-1].way==-1) ? solve(x-1,y-1) : F[x-1][y-1].way;
	else return 0;
}

int right(int x,int y){
	if(F[x+1][y-1].stt==0) 
		return (F[x+1][y-1].way==-1) ? solve(x+1,y-1) : F[x+1][y-1].way;
	else return 0;
}

int samex(int x,int y){
	if(F[x][y-1].stt==0) 
		return (F[x][y-1].way==-1) ? solve(x,y-1) : F[x][y-1].way;
	else return 0;
}

int solve(int x,int y){//入力した座標までのコース数を返す 0は普通 1は障害物 2はジャンプ台
	if (y==1) return 1;
	if (F[x][y].stt==0)
	return jump(x,y)+left(x,y)+right(x,y)+samex(x,y);
	if (F[x][y].stt==2)
	return jump(x,y)+samex(x,y);
	if (F[x][y].stt==1)
	return 0;
	return 0;
}

//int solve_ex(int x,int y){//最後JUMP通過のとき jumpをそのまま使う


void solver(){
	int X,Y;
	cin >> X >> Y;
	if(X==0) {flag=1;return;}
	
	
	for(int i=0;i<17;i++){
		for(int j=0;j<17;j++){
			F[i][j].way=-1;
			F[i][j].stt=1;
		}
	}
	
	for(int i=1;i<=Y;i++){
		for(int j=1;j<=X;j++){
			cin >> F[j][i].stt;
		}
	}
	
	for(int x=1;x<=X;x++){
		ans[counter]+=(solve(x,Y)+jump(x,Y+1));
	}
	counter++;
}

int main(){
	while(flag==0){
		solver();
	}
	
	for(int i=0;i<counter;i++){
		cout << ans[i]<<"\n";
	}
}

C++: #include<iostream>
#include<algorithm>
using namespace std;

int X,Y;
int c[15][15];
int dp[15][15];
int main(){
	while(cin>>X>>Y,X|Y){
		int ans=0;
		for(int i=0;i<Y;i++)
			for(int j=0;j<X;j++)
				cin>>c[i][j];
		fill_n((int*)dp,15*15,0);
		for(int j=0;j<X;j++){
			if(c[0][j]!=1)dp[0][j]=1;
		}cout<<endl;
		for(int i=0;i<Y;i++){
			for(int j=0;j<X;j++){
				if(dp[i][j]==0)continue;
				for(int dx=-1;dx<=1;dx++){
					if(j+dx<0 || X<=j+dx)continue;
					if(c[i][j]==2){
						if(dx==0){
							if(i+2<Y)dp[i+2][j] += dp[i][j];
							else ans += dp[i][j];
						}
					}
					else{
						if(i+1<Y){
							if(c[i+1][j+dx]==0)dp[i+1][j+dx] += dp[i][j];
							else if(c[i+1][j+dx]==2 && dx==0)dp[i+1][j] += dp[i][j];
						}
						else if(dx==0)ans += dp[i][j];
					}
				}
			}
		}
		cout<<ans<<endl;
	}
}

C++: // AOJ 0203
#include <iostream>

using namespace std;

int main(void)
{
	int x, y;
	while (cin >> x >> y, x || y){
		int field[20][20];
		for (int i = 1; i <= y; i++){
			for (int j = 1; j <= x; j++){
				cin >> field[i][j];
			}
		}
		int dp[20][20];
		for (int i = 0; i < 20; i++) {
			for (int j = 0; j < 20; j++){
				dp[i][j] = 0;
			}
		}
		
		for (int j = 1; j <= x; j++){
			if (field[1][j] == 0){
				dp[1][j] = 1;
			}
		}
		for (int i = 1; i <= y; i++){
			for (int j = 1; j <= x; j++){
				if (field[i][j] == 1){
					continue;
				}
				if (field[i][j] == 2){
					dp[i + 2][j] += dp[i][j];
					continue;
				}
				if (field[i + 1][j - 1] == 0){
					dp[i + 1][j - 1] += dp[i][j];
				}
				if (field[i + 1][j] != 1){
					dp[i + 1][j] += dp[i][j];
				}
				if (field[i + 1][j + 1] == 0){
					dp[i + 1][j + 1] += dp[i][j];
				}
			}
		}

		// for (int i = 1; i <= y; i++){
		// 	for (int j = 1; j <= x; j++){
		// 		cout << dp[i][j] << " ";
		// 	}
		// 	puts("");
		// }

		int ret = 0;
		for (int i = y - 1; i <= y; i++){
			for (int j = 1; j <= x; j++){
				if (i == y - 1){
					if (field[i][j] == 2) ret += dp[i][j];
					continue;
				}
				else {
					ret += dp[i][j];
					// cout << i << " " << j << endl;
					// cout << ret << endl;
				}
			}
		}
		cout << ret << endl;
	}

	return 0;
}

C++: #include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reg(i,a,b) for(int i=(a);i<=(b);i++)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second

int dat[30][30];
int dp[30][30];
int main(void){
	int x,y;
	for(;;){
		scanf("%d%d",&x,&y);
		if(x==0)break;
		rep(j,y)rep(i,x){
			scanf("%d",&dat[i][j]);
		}
		memset(dp,0,sizeof(dp));
		rep(i,x)if(dat[i][0]==0)dp[i][0]=1;
		rep(j,y)rep(i,x){
			if(dat[i][j]==1)continue;
			if(dat[i][j]==2){
				if(dat[i][j+2]!=1)dp[i][j+2]+=dp[i][j];
				continue;
			}
			if(j!=y-1){
				if(i>0 && dat[i-1][j+1]==0){
					dp[i-1][j+1]+=dp[i][j];
				}
				if(i<x-1 && dat[i+1][j+1]==0){
					dp[i+1][j+1]+=dp[i][j];
				}
			}
			if(dat[i][j+1]!=1)dp[i][j+1]+=dp[i][j];
		}
		lli ans=0;
		/*
		printf("\n");
		rep(j,y){
			rep(i,x){
				//printf("(%2d %2d)",dat[i][j],dp[i][j]);
				printf("%2d",dp[i][j]);
			}
			printf("\n");
		}*/
		reg(j,y,y+1){
			//printf("\n");
			rep(i,x){
				//printf("%2d ",dp[i][j]);
				ans+=dp[i][j];
			}
		}
		printf("%lld\n",ans);
	}
	return 0;
}