stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <bits/stdc++.h>



using namespace std;

typedef long long ll;

typedef double dd;

#define all(v) v.begin(),v.end()

#define endl "\n"

#define clr(n, r) memset(n,r,sizeof(n));



void fast() {



    cin.tie(0);

    cin.sync_with_stdio(0);

}



long long binpow(long long a, long long b, long long m) {

    a %= m;

    long long res = 1;

    while (b > 0) {

        if (b & 1)

            res = res * a % m;

        a = a * a % m;

        b >>= 1;

    }

    return res;

}



const ll mod = 1e9 + 7;

ll n, m, dp[1000 + 9][1000 + 9];

char arr[1000][1000];



ll ans(ll i, ll j) {

    ll &ret=dp[i][j];

    if(~ret)return ret;

    if (i == n || j == m||arr[i][j]=='#')return 0;

    if (i == n - 1 && j == m - 1)return 1;

    ll path1 = ans(i + 1, j) % mod;

    ll path2 = ans(i, j + 1) % mod;

    return ret=(path1+path2)%mod;

}



int main() {

    fast();

    cin >> n >> m;

    for (int i = 0; i < n; ++i) {

        for (int j = 0; j < m; ++j) {

            cin >> arr[i][j];

        }

    }

    clr(dp,-1);

    cout << ans(0, 0);

}

// Faster C++ solution for the same problem (measured speedup: 9.42490953346082x):
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#include<bits/stdc++.h>  

#define endl "\n"

using namespace std;

	typedef long long ll;

	const int maxn=1050;

	const int inf=0x3f3f3f3f;

	const int mod=1e9+7;

	int ans;

	char _map[maxn][maxn];

	int dp[maxn][maxn];

	ll n,m;

	int main(){

		IOS

		cin>>n>>m;

		for(int i=1;i<=n;i++)

			for(int j=1;j<=m;j++)

				cin>>_map[i][j];

		dp[1][1]=1;

		for(int i=1;i<=n;i++)

			for(int j=1;j<=m;j++){

				if(_map[i][j-1]!='#'){

					dp[i][j]+=dp[i][j-1];

					dp[i][j]%=mod;

				}

				if(_map[i-1][j]!='#'){

					dp[i][j]+=dp[i-1][j];

					dp[i][j]%=mod;

				}

			}

		ans=dp[n][m];

		cout<<ans<<endl;

	}
// Slower C++ solution:
#include<iostream>

#include<cmath>

#include<algorithm>

#include<bits/stdc++.h>

using namespace std;



int h, w;

char path[1001][1001];

long long  memo[1001][1001];

long long numberofpath(int i, int j)

{

	long long answer = 0; 

	if (i < 0 || j < 0 || i == h || j == w) return 0;

	else if (i == h-1 && j == w-1) return 1;

	else if (path[i][j] == '#') return 0; 

	else

	{

		if (memo[i][j] != -1) return memo[i][j];

		else

		{

			answer = (answer +  numberofpath(i + 1, j )) % (long long)(1e9+7);

			answer = (answer + numberofpath(i, j+1)) % (long long)(1e9 + 7);

		}

	}



	return memo[i][j] = answer;

}





int main()

{

	memset(memo,-1, sizeof memo);

	cin >> h >> w; 

	for (int i = 0; i < h; i += 1)

		for (int j = 0; j < w; j++)

			cin >> path[i][j];



	cout << numberofpath(0,0) << endl;

	cout << endl;



	system("pause");

}


// Faster C++ solution for the same problem (measured speedup: 9.436210592539837x):
#include <bits/stdc++.h>



using namespace std;

typedef long long ll;

typedef unsigned long long ull;



const int mod  = 1e9+7;

const int maxn = 1e3+10;



int W,H;

char x;

int m[maxn][maxn];

int dp[maxn][maxn];

int solve(int w,int h)

{

	if (dp[w][h]!=-1)

		return dp[w][h];

	if (w<1||h<1)

		return 0;

	if (m[w][h]==0)

		return 0;

	int tem1=solve(w-1,h);

	int tem2=solve(w,h-1);

	dp[w][h]=(tem1+tem2)%mod;

	return dp[w][h];

}

void check()

{

	for (int i=1;i<=W;i++)

	{

		for (int j=1;j<=H;j++)

			cout<<setw(4)<<dp[i][j];

		cout<<endl;

	}

}

int main()

{

	cin>>W>>H;

	for (int i=1;i<=W;i++)

	{

		for (int j=1;j<=H;j++)

		{

			dp[i][j]=-1;

			cin>>x;

			if (x=='.')

				m[i][j]=1;

			else

				m[i][j]=0;

		}

	}

	if (m[1][2]!=0)

		dp[1][2]=1;

	if (m[2][1]!=0)

		dp[2][1]=1;

	dp[1][1]=1;

	cout<<solve(W,H);

	//check();

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>



using namespace std;

typedef long long ll;

typedef double dd;

#define all(v) v.begin(),v.end()

#define endl "\n"

#define clr(n, r) memset(n,r,sizeof(n));



void fast() {



    cin.tie(0);

    cin.sync_with_stdio(0);

}



long long binpow(long long a, long long b, long long m) {

    a %= m;

    long long res = 1;

    while (b > 0) {

        if (b & 1)

            res = res * a % m;

        a = a * a % m;

        b >>= 1;

    }

    return res;

}



const ll mod = 1e9 + 7;

ll n, m, dp[1000 + 9][1000 + 9];

char arr[1000][1000];



ll ans(ll i, ll j) {

    ll &ret=dp[i][j];

    if(~ret)return ret;

    if (i == n || j == m||arr[i][j]=='#')return 0;

    if (i == n - 1 && j == m - 1)return 1;

    ll path1 = ans(i + 1, j) % mod;

    ll path2 = ans(i, j + 1) % mod;

    return ret=(path1+path2)%mod;

}



int main() {

    fast();

    cin >> n >> m;

    for (int i = 0; i < n; ++i) {

        for (int j = 0; j < m; ++j) {

            cin >> arr[i][j];

        }

    }

    clr(dp,-1);

    cout << ans(0, 0);

}

// Faster C++ solution for the same problem (measured speedup: 9.576306310370814x):
#include <bits/stdc++.h>



using namespace std;

typedef long long ll;

typedef unsigned long long ull;



const int mod  = 1e9+7;

const int maxn = 1e3+10;



int W,H;

char x;

int m[maxn][maxn];

int dp[maxn][maxn];

int solve(int w,int h)

{

	if (dp[w][h]!=-1)

		return dp[w][h];

	if (w<1||h<1)

		return 0;

	if (m[w][h]==0)

		return 0;

	int tem1=solve(w-1,h);

	int tem2=solve(w,h-1);

	dp[w][h]=(tem1+tem2)%mod;

	return dp[w][h];

}

void check()

{

	for (int i=1;i<=W;i++)

	{

		for (int j=1;j<=H;j++)

			cout<<setw(4)<<dp[i][j];

		cout<<endl;

	}

}

int main()

{

	cin>>W>>H;

	for (int i=1;i<=W;i++)

	{

		for (int j=1;j<=H;j++)

		{

			dp[i][j]=-1;

			cin>>x;

			if (x=='.')

				m[i][j]=1;

			else

				m[i][j]=0;

		}

	}

	if (m[1][2]!=0)

		dp[1][2]=1;

	if (m[2][1]!=0)

		dp[2][1]=1;

	dp[1][1]=1;

	cout<<solve(W,H);

	//check();

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cmath>

#include<algorithm>

#include<bits/stdc++.h>

using namespace std;



int h, w;

char path[1001][1001];

long long  memo[1001][1001];

long long numberofpath(int i, int j)

{

	long long answer = 0; 

	if (i < 0 || j < 0 || i == h || j == w) return 0;

	else if (i == h-1 && j == w-1) return 1;

	else if (path[i][j] == '#') return 0; 

	else

	{

		if (memo[i][j] != -1) return memo[i][j];

		else

		{

			answer = (answer +  numberofpath(i + 1, j )) % (long long)(1e9+7);

			answer = (answer + numberofpath(i, j+1)) % (long long)(1e9 + 7);

		}

	}



	return memo[i][j] = answer;

}





int main()

{

	memset(memo,-1, sizeof memo);

	cin >> h >> w; 

	for (int i = 0; i < h; i += 1)

		for (int j = 0; j < w; j++)

			cin >> path[i][j];



	cout << numberofpath(0,0) << endl;

	cout << endl;



	system("pause");

}


// Faster C++ solution for the same problem (measured speedup: 9.440386072307412x):
#include <bits/stdc++.h>

using namespace std;

typedef long long  ll;

char b;

bool a[1005][1005];

ll man=1e9+7;

ll dp[1005][1005];

ll h,w,ans;

int main()

{

	int i,j;

	cin>>h>>w;

	for(i=1;i<=h;i++)

	{

		for(j=1;j<=w;j++)

		{

			cin>>b;

			if(b=='.')

			a[i][j]=1;

			else

			a[i][j]=0;

		}

	}

	dp[1][1]=1;

	for(i=1;i<=h;i++)

	{

		for(j=1;j<=w;j++)

		{

			if(!(i==1&&j==1))

			if(a[i][j]==1)

			dp[i][j]=(dp[i][j-1]+dp[i-1][j])%man;

			else

			dp[i][j]=0;

		}	

	}

	

	cout<<dp[h][w];

}
// Slower C++ solution:
#include <bits/stdc++.h>



using namespace std;

typedef long long ll;

typedef double dd;

#define all(v) v.begin(),v.end()

#define endl "\n"

#define clr(n, r) memset(n,r,sizeof(n));



void fast() {



    cin.tie(0);

    cin.sync_with_stdio(0);

}



long long binpow(long long a, long long b, long long m) {

    a %= m;

    long long res = 1;

    while (b > 0) {

        if (b & 1)

            res = res * a % m;

        a = a * a % m;

        b >>= 1;

    }

    return res;

}



const ll mod = 1e9 + 7;

ll n, m, dp[1000 + 9][1000 + 9];

char arr[1000][1000];



ll ans(ll i, ll j) {

    ll &ret=dp[i][j];

    if(~ret)return ret;

    if (i == n || j == m||arr[i][j]=='#')return 0;

    if (i == n - 1 && j == m - 1)return 1;

    ll path1 = ans(i + 1, j) % mod;

    ll path2 = ans(i, j + 1) % mod;

    return ret=(path1+path2)%mod;

}



int main() {

    fast();

    cin >> n >> m;

    for (int i = 0; i < n; ++i) {

        for (int j = 0; j < m; ++j) {

            cin >> arr[i][j];

        }

    }

    clr(dp,-1);

    cout << ans(0, 0);

}

// Faster C++ solution for the same problem (measured speedup: 9.580543781848894x):
#include <bits/stdc++.h>

using namespace std;

typedef long long  ll;

char b;

bool a[1005][1005];

ll man=1e9+7;

ll dp[1005][1005];

ll h,w,ans;

int main()

{

	int i,j;

	cin>>h>>w;

	for(i=1;i<=h;i++)

	{

		for(j=1;j<=w;j++)

		{

			cin>>b;

			if(b=='.')

			a[i][j]=1;

			else

			a[i][j]=0;

		}

	}

	dp[1][1]=1;

	for(i=1;i<=h;i++)

	{

		for(j=1;j<=w;j++)

		{

			if(!(i==1&&j==1))

			if(a[i][j]==1)

			dp[i][j]=(dp[i][j-1]+dp[i-1][j])%man;

			else

			dp[i][j]=0;

		}	

	}

	

	cout<<dp[h][w];

}
// Slower C++ solution:
#include<iostream>

#include<cmath>

#include<algorithm>

#include<bits/stdc++.h>

using namespace std;



int h, w;

char path[1001][1001];

long long  memo[1001][1001];

long long numberofpath(int i, int j)

{

	long long answer = 0; 

	if (i < 0 || j < 0 || i == h || j == w) return 0;

	else if (i == h-1 && j == w-1) return 1;

	else if (path[i][j] == '#') return 0; 

	else

	{

		if (memo[i][j] != -1) return memo[i][j];

		else

		{

			answer = (answer +  numberofpath(i + 1, j )) % (long long)(1e9+7);

			answer = (answer + numberofpath(i, j+1)) % (long long)(1e9 + 7);

		}

	}



	return memo[i][j] = answer;

}





int main()

{

	memset(memo,-1, sizeof memo);

	cin >> h >> w; 

	for (int i = 0; i < h; i += 1)

		for (int j = 0; j < w; j++)

			cin >> path[i][j];



	cout << numberofpath(0,0) << endl;

	cout << endl;



	system("pause");

}


// Faster C++ solution for the same problem (measured speedup: 9.438450048500648x):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int mod = 1e9+7;

int h, w;

int dp[1001][1001];

char grid[1001][1001];

int main(){

    cin>>h>>w;



    for(int x=1;x<=h;x++){

        for(int y = 1; y<=w;y++){

            cin>>grid[x][y];

        }

    }

    dp[1][1] =1;

    for(int x=2;x<=w;x++)

        if(grid[1][x] == '.')

            dp[1][x] = dp[1][x-1];

    for(int x=2;x<=h;x++){

        for(int y=1;y<=w;y++){

            if(grid[x][y] == '#') continue;

            dp[x][y] += dp[x-1][y];

            dp[x][y] += dp[x][y-1];

            dp[x][y] %= mod;

        }

    }

    cout<<dp[h][w];





}
// Slower C++ solution:
#include <bits/stdc++.h>



using namespace std;

typedef long long ll;

typedef double dd;

#define all(v) v.begin(),v.end()

#define endl "\n"

#define clr(n, r) memset(n,r,sizeof(n));



void fast() {



    cin.tie(0);

    cin.sync_with_stdio(0);

}



long long binpow(long long a, long long b, long long m) {

    a %= m;

    long long res = 1;

    while (b > 0) {

        if (b & 1)

            res = res * a % m;

        a = a * a % m;

        b >>= 1;

    }

    return res;

}



const ll mod = 1e9 + 7;

ll n, m, dp[1000 + 9][1000 + 9];

char arr[1000][1000];



ll ans(ll i, ll j) {

    ll &ret=dp[i][j];

    if(~ret)return ret;

    if (i == n || j == m||arr[i][j]=='#')return 0;

    if (i == n - 1 && j == m - 1)return 1;

    ll path1 = ans(i + 1, j) % mod;

    ll path2 = ans(i, j + 1) % mod;

    return ret=(path1+path2)%mod;

}



int main() {

    fast();

    cin >> n >> m;

    for (int i = 0; i < n; ++i) {

        for (int j = 0; j < m; ++j) {

            cin >> arr[i][j];

        }

    }

    clr(dp,-1);

    cout << ans(0, 0);

}

// Faster C++ solution for the same problem (measured speedup: 9.578579014655972x):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int mod = 1e9+7;

int h, w;

int dp[1001][1001];

char grid[1001][1001];

int main(){

    cin>>h>>w;



    for(int x=1;x<=h;x++){

        for(int y = 1; y<=w;y++){

            cin>>grid[x][y];

        }

    }

    dp[1][1] =1;

    for(int x=2;x<=w;x++)

        if(grid[1][x] == '.')

            dp[1][x] = dp[1][x-1];

    for(int x=2;x<=h;x++){

        for(int y=1;y<=w;y++){

            if(grid[x][y] == '#') continue;

            dp[x][y] += dp[x-1][y];

            dp[x][y] += dp[x][y-1];

            dp[x][y] %= mod;

        }

    }

    cout<<dp[h][w];





}
// Slower C++ solution:
#include<iostream>

#include<cmath>

#include<algorithm>

#include<bits/stdc++.h>

using namespace std;



int h, w;

char path[1001][1001];

long long  memo[1001][1001];

long long numberofpath(int i, int j)

{

	long long answer = 0; 

	if (i < 0 || j < 0 || i == h || j == w) return 0;

	else if (i == h-1 && j == w-1) return 1;

	else if (path[i][j] == '#') return 0; 

	else

	{

		if (memo[i][j] != -1) return memo[i][j];

		else

		{

			answer = (answer +  numberofpath(i + 1, j )) % (long long)(1e9+7);

			answer = (answer + numberofpath(i, j+1)) % (long long)(1e9 + 7);

		}

	}



	return memo[i][j] = answer;

}





int main()

{

	memset(memo,-1, sizeof memo);

	cin >> h >> w; 

	for (int i = 0; i < h; i += 1)

		for (int j = 0; j < w; j++)

			cin >> path[i][j];



	cout << numberofpath(0,0) << endl;

	cout << endl;



	system("pause");

}


// Faster C++ solution for the same problem (measured speedup: 9.416916706840547x):
#include<bits/stdc++.h>

using namespace std;

int main()

{

    int n,m;

    cin>>n>>m;

    char arra[n+5][m+5];

    for(int i=0;i<n;i++) {

        for(int j=0;j<m;j++) {

            cin>>arra[i][j];

        }

    }

    int dp[n+5][m+5];

    memset(dp,0,sizeof(dp));

    

    dp[0][0]=1;

    for(int i=0;i<n;i++) {

        for(int j=0;j<m;j++) {

            if(i==0 && j!=0) {

                if(arra[i][j]=='#') {

                    dp[i][j]=0;



                }

                else {

                    dp[i][j]=dp[i][j-1];

                }

            }

            else if(j==0 && i!=0) {



                if(arra[i][j]=='#') {

                    dp[i][j]=0;



                }

                else {

                    dp[i][j]=dp[i-1][j];

                }



            }

            else  if(i>0 && j>0){

                if(arra[i][j]=='#') {

                    dp[i][j]=0;



                }

                else {

                    dp[i][j]=(dp[i-1][j]+dp[i][j-1])%1000000007;



                }

            }





        }

    }

    cout<<dp[n-1][m-1]<<endl;





}
// Slower C++ solution:
#include <bits/stdc++.h>



using namespace std;

typedef long long ll;

typedef double dd;

#define all(v) v.begin(),v.end()

#define endl "\n"

#define clr(n, r) memset(n,r,sizeof(n));



void fast() {



    cin.tie(0);

    cin.sync_with_stdio(0);

}



long long binpow(long long a, long long b, long long m) {

    a %= m;

    long long res = 1;

    while (b > 0) {

        if (b & 1)

            res = res * a % m;

        a = a * a % m;

        b >>= 1;

    }

    return res;

}



const ll mod = 1e9 + 7;

ll n, m, dp[1000 + 9][1000 + 9];

char arr[1000][1000];



ll ans(ll i, ll j) {

    ll &ret=dp[i][j];

    if(~ret)return ret;

    if (i == n || j == m||arr[i][j]=='#')return 0;

    if (i == n - 1 && j == m - 1)return 1;

    ll path1 = ans(i + 1, j) % mod;

    ll path2 = ans(i, j + 1) % mod;

    return ret=(path1+path2)%mod;

}



int main() {

    fast();

    cin >> n >> m;

    for (int i = 0; i < n; ++i) {

        for (int j = 0; j < m; ++j) {

            cin >> arr[i][j];

        }

    }

    clr(dp,-1);

    cout << ans(0, 0);

}

// Faster C++ solution for the same problem (measured speedup: 9.556725975917516x):
#include<bits/stdc++.h>

using namespace std;

int main()

{

    int n,m;

    cin>>n>>m;

    char arra[n+5][m+5];

    for(int i=0;i<n;i++) {

        for(int j=0;j<m;j++) {

            cin>>arra[i][j];

        }

    }

    int dp[n+5][m+5];

    memset(dp,0,sizeof(dp));

    

    dp[0][0]=1;

    for(int i=0;i<n;i++) {

        for(int j=0;j<m;j++) {

            if(i==0 && j!=0) {

                if(arra[i][j]=='#') {

                    dp[i][j]=0;



                }

                else {

                    dp[i][j]=dp[i][j-1];

                }

            }

            else if(j==0 && i!=0) {



                if(arra[i][j]=='#') {

                    dp[i][j]=0;



                }

                else {

                    dp[i][j]=dp[i-1][j];

                }



            }

            else  if(i>0 && j>0){

                if(arra[i][j]=='#') {

                    dp[i][j]=0;



                }

                else {

                    dp[i][j]=(dp[i-1][j]+dp[i][j-1])%1000000007;



                }

            }





        }

    }

    cout<<dp[n-1][m-1]<<endl;





}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

#define ll long long

int n, m; ll paths, mod = 1e9+7, memo[1002][1002];

char c[1002][1002];

ll fix_mod(ll x){

	return (mod + x % mod) % mod;

}

ll solve(int i, int j){

    if(c[i][j] == '#' || i >= n || j >= m) return 0;

    if(i == n-1 && j == m-1) return 1;

    if(memo[i][j] != -1) return memo[i][j];

    paths = fix_mod(solve(i, j+1) + solve(i+1, j));

    return memo[i][j] = paths;

}

int main()

{



    cin>> n>> m;

    for(int i = 0; i < n; i++){

        for(int j = 0; j < m; j++){

            cin>> c[i][j];

        }

    }

    memset(memo, -1, sizeof memo);

    cout<< solve(0, 0);

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 9.316964152131725x):
#include <bits/stdc++.h>

/**

*   author: j o s e m a g o

*   date:

**/

using namespace std;

#pragma GCC optimize ("Ofast")

#define f first

#define s second

#define mp make_pair

#define lb lower_bound

#define ub upper_bound

#define all(v) (v).begin(),(v).end()

#define mset(a,v) memset(a,v,sizeof(a))

#define pb push_back

#define sz(x) ((int)(x).size())

#define rsz resize

#define ln "\n"



typedef double db;

typedef unsigned long long ull;

typedef long long ll;

typedef long double ld;

const ld PI = 2*acos(0.0);

const int MOD = 1000000007;

const int JJJ = 1009;



char matrix[JJJ][JJJ];

int dp[JJJ][JJJ],f,c;









int main(){



  //freopen("input.in","r",stdin);

  //freopen("input.out","w",stdout);



    ios_base::sync_with_stdio(0); cin.tie(0);



    cin >> f >> c;

    for(int i = 1;i <= f;i++){

        for(int j = 1;j <= c;j++){

            cin >> matrix[i][j];

        }

    }

    dp[1][1] = 1;

    for(int i = 1;i <= f;i++){

        for(int j = 1;j <= c;j++){

            if(i == 1 && j == 1) continue;

            if(matrix[i][j] != '#'){

                if(matrix[i-1][j] != '#'){

                    dp[i][j] = (dp[i][j]+dp[i-1][j])%MOD;

                }

                if(matrix[i][j-1] != '#'){

                    dp[i][j] = (dp[i][j]+dp[i][j-1])%MOD;

                }

            }

        }

    }



    cout<<dp[f][c];

















    return 0;

}

/*

3 4

...#

.#..

....



5 2

..

#.

..

.#

..



5 5

..#..

.....

#...#

.....

..#..





20 20

....................

....................

....................

....................

....................

....................

....................

....................

....................

....................

....................

....................

....................

....................

....................

....................

....................

....................

....................

....................



*/
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

#define ll long long

int n, m; ll paths, mod = 1e9+7, memo[1002][1002];

char c[1002][1002];

ll fix_mod(ll x){

	return (mod + x % mod) % mod;

}

ll solve(int i, int j){

    if(c[i][j] == '#' || i >= n || j >= m) return 0;

    if(i == n-1 && j == m-1) return 1;

    if(memo[i][j] != -1) return memo[i][j];

    paths = fix_mod(solve(i, j+1) + solve(i+1, j));

    return memo[i][j] = paths;

}

int main()

{



    cin>> n>> m;

    for(int i = 0; i < n; i++){

        for(int j = 0; j < m; j++){

            cin>> c[i][j];

        }

    }

    memset(memo, -1, sizeof memo);

    cout<< solve(0, 0);

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 9.311766173801054x):
#include <iostream>

#include <stdio.h>

#define ll long long

#define Mod 1000000007

#define sz 1004

#define valid (i>0 && i <= h && j>0 && j<=w && a[i][j]!='#')

using namespace std;

char a[sz][sz];

ll vis[sz][sz];

bool check[sz][sz];

ll cnt;

ll x , y;

ll blockClimbing(int i , int j,int h , int w){

    if(check[i][j])return vis[i][j];

    if(!valid){check[i][j]=true;return vis[i][j]=0;}

	//cout<<i<<' '<<j<<endl;

    blockClimbing(i+1,j,h,w);

    blockClimbing(i,j+1,h,w);

    

    vis[i][j] = (vis[i+1][j] + vis[i][j+1])%Mod;

    check[i][j]=true;

    return vis[i][j];

}

int main(){

    //freopen("test.txt","r",stdin);

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    int i ,  j , n , m , h , w;

    cin>>h>>w;

    for(i=1;i<=h;i++){

        for(j=1;j<=w;j++){

            cin>>a[i][j];

        }

    }

    check[h][w]=true;

    vis[h][w]=1;

   cout<< blockClimbing(1,1,h,w)<<endl;

   

    return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

#define ll long long

int n, m; ll paths, mod = 1e9+7, memo[1002][1002];

char c[1002][1002];

ll fix_mod(ll x){

	return (mod + x % mod) % mod;

}

ll solve(int i, int j){

    if(c[i][j] == '#' || i >= n || j >= m) return 0;

    if(i == n-1 && j == m-1) return 1;

    if(memo[i][j] != -1) return memo[i][j];

    paths = fix_mod(solve(i, j+1) + solve(i+1, j));

    return memo[i][j] = paths;

}

int main()

{



    cin>> n>> m;

    for(int i = 0; i < n; i++){

        for(int j = 0; j < m; j++){

            cin>> c[i][j];

        }

    }

    memset(memo, -1, sizeof memo);

    cout<< solve(0, 0);

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 9.226934218631783x):
#include <bits/stdc++.h>

using namespace std;

const int N = 1005;

long long dp[N][N], ans;

long long cons = 1e9+7;

int main()

{

    int n, m;

    char c[N][N];

    cin >> n >> m;

    for ( int i=0; i<n; i++){

    for (int j=0; j<m; j++) cin >> c[i][j];

    }

    for (int i=1; i<m; i++){

        if (c[0][i] == '#') break;

        dp[0][i]=1;

    }

      for (int i=1; i<n; i++){

        if (c[i][0] == '#') break;

        dp[i][0]=1;

    }

    for ( int i=1; i<m; i++){

        for (int j=1; j<n;j++){

                if (c[j][i] == '#') continue;

            dp[j][i]= (dp[j-1][i]+dp[j][i-1])%cons;

        }

    }

    ans = (dp[n-1][m-1]) %cons;

    cout << ans;

    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

#define ll long long

using namespace std;

#define mod 1000000007

ll h,w;

char ar[1001][1001];

ll dp[1001][1001];



ll path(ll i,ll j){

    if(i==h-1&&j==w-1) return 1;

    if(dp[i][j]!=-1) return dp[i][j];

    ll x=0,y=0;

    if(i+1<h&&ar[i+1][j]!='#') x=path(i+1,j);

    if(j+1<w&&ar[i][j+1]!='#') y=path(i,j+1);

    return dp[i][j]=(x+y)%mod;

}



int main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    //freopen("input.txt", "r", stdin);

    //freopen("output.txt", "w", stdout);



    cin>>h>>w;

    for(ll i=0;i<h;i++){

        for(ll j=0;j<w;j++){

            cin>>ar[i][j];

        }

    }

    memset(dp,-1,sizeof(dp));

    cout<<path(0,0)<<endl;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 9.227205172691937x):
#include <bits/stdc++.h>

using namespace std;

const int N = 1005;

long long dp[N][N], ans;

long long cons = 1e9+7;

int main()

{

    int n, m;

    char c[N][N];

    cin >> n >> m;

    for ( int i=0; i<n; i++){

    for (int j=0; j<m; j++) cin >> c[i][j];

    }

    for (int i=1; i<m; i++){

        if (c[0][i] == '#') break;

        dp[0][i]=1;

    }

      for (int i=1; i<n; i++){

        if (c[i][0] == '#') break;

        dp[i][0]=1;

    }

    for ( int i=1; i<m; i++){

        for (int j=1; j<n;j++){

                if (c[j][i] == '#') continue;

            dp[j][i]= (dp[j-1][i]+dp[j][i-1])%cons;

        }

    }

    ans = (dp[n-1][m-1]) %cons;

    cout << ans;

    return 0;

}